From b0848167e3c54902286ee829aafc2058754a9b04 Mon Sep 17 00:00:00 2001 From: David Howells Date: Thu, 4 Oct 2012 12:10:18 +0100 Subject: [PATCH] --- yaml --- r: 330456 b: refs/heads/master c: 890139529d45ebd3c60d541f4eddc60e042fdf98 h: refs/heads/master v: v3 --- [refs] | 2 +- trunk/Documentation/CodingStyle | 10 - trunk/Documentation/aoe/aoe.txt | 58 +- trunk/Documentation/aoe/mkdevs.sh | 41 + trunk/Documentation/aoe/mkshelf.sh | 28 + trunk/Documentation/aoe/status.sh | 3 - .../devicetree/bindings/arm/xen.txt | 25 - .../devicetree/bindings/crypto/fsl-sec4.txt | 51 - .../devicetree/bindings/mfd/88pm860x.txt | 85 - .../devicetree/bindings/mfd/syscon.txt | 20 - .../devicetree/bindings/mfd/tps65910.txt | 4 - .../devicetree/bindings/mfd/twl4030-audio.txt | 46 - .../devicetree/bindings/mfd/twl6040.txt | 9 +- .../devicetree/bindings/misc/ifm-csi.txt | 41 - .../devicetree/bindings/powerpc/fsl/ifc.txt | 9 +- .../bindings/regulator/88pm860x.txt | 30 - .../devicetree/bindings/regulator/max8907.txt | 69 - .../bindings/regulator/tps6586x.txt | 6 - .../devicetree/bindings/rtc/snvs-rtc.txt | 1 - .../bindings/video/backlight/88pm860x.txt | 15 - trunk/Documentation/printk-formats.txt | 1 - trunk/Documentation/remoteproc.txt | 7 - trunk/Documentation/rtc.txt | 5 +- trunk/Documentation/smsc_ece1099.txt | 56 - trunk/Documentation/sysctl/kernel.txt | 2 - trunk/Documentation/virtual/kvm/api.txt | 33 +- .../Documentation/virtual/kvm/hypercalls.txt | 66 - trunk/Documentation/virtual/kvm/msr.txt | 32 +- trunk/Documentation/virtual/kvm/ppc-pv.txt | 22 - trunk/MAINTAINERS | 43 +- trunk/arch/arm/Kconfig | 10 - trunk/arch/arm/Makefile | 2 - trunk/arch/arm/boot/dts/Makefile | 3 +- trunk/arch/arm/boot/dts/imx6q.dtsi | 9 +- trunk/arch/arm/boot/dts/pxa910-dkb.dts | 137 - trunk/arch/arm/boot/dts/pxa910.dtsi | 4 - trunk/arch/arm/boot/dts/xenvm-4.2.dts | 68 - trunk/arch/arm/crypto/Makefile | 9 - trunk/arch/arm/crypto/aes-armv4.S | 1112 ---- trunk/arch/arm/crypto/aes_glue.c | 108 - trunk/arch/arm/crypto/sha1-armv4-large.S | 503 -- trunk/arch/arm/crypto/sha1_glue.c | 179 - trunk/arch/arm/include/asm/hypervisor.h | 6 - trunk/arch/arm/include/asm/sync_bitops.h | 27 - trunk/arch/arm/include/asm/xen/events.h | 18 - trunk/arch/arm/include/asm/xen/hypercall.h | 69 - trunk/arch/arm/include/asm/xen/hypervisor.h | 19 - trunk/arch/arm/include/asm/xen/interface.h | 73 - trunk/arch/arm/include/asm/xen/page.h | 82 - trunk/arch/arm/mach-at91/clock.c | 2 +- .../arm/mach-davinci/board-tnetv107x-evm.c | 6 +- trunk/arch/arm/mach-davinci/da830.c | 48 +- trunk/arch/arm/mach-davinci/da850.c | 6 +- trunk/arch/arm/mach-imx/Kconfig | 2 +- trunk/arch/arm/mach-imx/mach-imx6q.c | 47 +- trunk/arch/arm/mach-msm/board-qsd8x50.c | 4 +- trunk/arch/arm/mach-omap2/display.c | 6 +- trunk/arch/arm/mach-omap2/usb-host.c | 31 +- trunk/arch/arm/mach-u300/i2c.c | 2 +- trunk/arch/arm/mach-vexpress/v2m.c | 1 - trunk/arch/arm/plat-omap/include/plat/usb.h | 7 - trunk/arch/arm/xen/Makefile | 1 - trunk/arch/arm/xen/enlighten.c | 168 - trunk/arch/arm/xen/grant-table.c | 53 - trunk/arch/arm/xen/hypercall.S | 106 - trunk/arch/arm64/include/asm/compat.h | 60 +- trunk/arch/arm64/include/asm/unistd.h | 4 - trunk/arch/arm64/include/asm/unistd32.h | 4 - trunk/arch/arm64/kernel/signal32.c | 53 + trunk/arch/avr32/include/asm/elf.h | 3 +- trunk/arch/blackfin/include/asm/elf.h | 3 +- trunk/arch/c6x/include/asm/elf.h | 3 +- trunk/arch/c6x/include/asm/unistd.h | 4 - trunk/arch/cris/include/asm/elf.h | 3 +- trunk/arch/frv/include/asm/elf.h | 3 +- trunk/arch/frv/kernel/pm.c | 19 +- trunk/arch/frv/kernel/setup.c | 2 +- trunk/arch/frv/mb93090-mb00/pci-irq.c | 2 +- trunk/arch/h8300/include/asm/elf.h | 3 +- trunk/arch/h8300/kernel/sys_h8300.c | 1 - trunk/arch/h8300/kernel/timer/itu.c | 2 +- trunk/arch/h8300/kernel/timer/timer16.c | 2 +- trunk/arch/h8300/kernel/timer/timer8.c | 2 +- trunk/arch/h8300/kernel/timer/tpu.c | 2 +- trunk/arch/h8300/platform/h8300h/irq.c | 4 +- trunk/arch/h8300/platform/h8s/irq.c | 4 +- trunk/arch/hexagon/include/asm/elf.h | 3 +- trunk/arch/hexagon/include/asm/unistd.h | 5 - trunk/arch/ia64/include/asm/xen/interface.h | 1 - trunk/arch/ia64/kvm/kvm-ia64.c | 41 +- trunk/arch/ia64/xen/irq_xen.c | 2 +- trunk/arch/ia64/xen/irq_xen.h | 2 +- trunk/arch/m32r/include/asm/elf.h | 3 +- trunk/arch/m68k/include/asm/elf.h | 3 +- trunk/arch/microblaze/include/asm/elf.h | 3 +- .../arch/mips/bcm63xx/boards/board_bcm963xx.c | 2 +- trunk/arch/mips/include/asm/compat-signal.h | 62 + trunk/arch/mips/include/asm/compat.h | 69 +- trunk/arch/mips/pci/pci-octeon.c | 2 +- trunk/arch/mn10300/Makefile | 2 +- trunk/arch/mn10300/include/asm/elf.h | 3 +- trunk/arch/openrisc/include/asm/elf.h | 3 +- trunk/arch/openrisc/include/asm/unistd.h | 5 - trunk/arch/parisc/Kconfig | 1 - trunk/arch/parisc/include/asm/compat.h | 59 +- trunk/arch/parisc/kernel/signal32.h | 52 + trunk/arch/powerpc/Kconfig | 17 +- trunk/arch/powerpc/boot/Makefile | 1 - .../boot/dts/fsl/e500mc_power_isa.dtsi | 58 - .../boot/dts/fsl/e500v2_power_isa.dtsi | 52 - .../powerpc/boot/dts/fsl/e5500_power_isa.dtsi | 59 - .../powerpc/boot/dts/fsl/mpc8536si-pre.dtsi | 3 - .../powerpc/boot/dts/fsl/mpc8544si-pre.dtsi | 3 - .../powerpc/boot/dts/fsl/mpc8548si-pre.dtsi | 3 - .../powerpc/boot/dts/fsl/mpc8568si-pre.dtsi | 3 - .../powerpc/boot/dts/fsl/mpc8569si-pre.dtsi | 3 - .../powerpc/boot/dts/fsl/mpc8572si-pre.dtsi | 3 - .../powerpc/boot/dts/fsl/p1010si-pre.dtsi | 3 - .../powerpc/boot/dts/fsl/p1020si-pre.dtsi | 3 - .../powerpc/boot/dts/fsl/p1021si-pre.dtsi | 3 - .../powerpc/boot/dts/fsl/p1022si-pre.dtsi | 3 - .../powerpc/boot/dts/fsl/p1023si-pre.dtsi | 3 - .../powerpc/boot/dts/fsl/p2020si-pre.dtsi | 3 - .../powerpc/boot/dts/fsl/p2041si-pre.dtsi | 3 - .../powerpc/boot/dts/fsl/p3041si-pre.dtsi | 3 - .../powerpc/boot/dts/fsl/p4080si-pre.dtsi | 3 - .../powerpc/boot/dts/fsl/p5020si-pre.dtsi | 3 - .../powerpc/boot/dts/fsl/p5040si-post.dtsi | 320 - .../powerpc/boot/dts/fsl/p5040si-pre.dtsi | 114 - .../powerpc/boot/dts/fsl/qoriq-sec5.2-0.dtsi | 118 - trunk/arch/powerpc/boot/dts/mpc8536ds.dtsi | 4 - trunk/arch/powerpc/boot/dts/mpc8540ads.dts | 2 - trunk/arch/powerpc/boot/dts/mpc8541cds.dts | 2 - trunk/arch/powerpc/boot/dts/mpc8544ds.dts | 4 +- trunk/arch/powerpc/boot/dts/mpc8544ds.dtsi | 39 - trunk/arch/powerpc/boot/dts/mpc8555cds.dts | 2 - trunk/arch/powerpc/boot/dts/mpc8560ads.dts | 2 - trunk/arch/powerpc/boot/dts/o2d.dts | 47 - trunk/arch/powerpc/boot/dts/o2d.dtsi | 139 - trunk/arch/powerpc/boot/dts/o2d300.dts | 52 - trunk/arch/powerpc/boot/dts/o2dnt2.dts | 48 - trunk/arch/powerpc/boot/dts/o2i.dts | 33 - trunk/arch/powerpc/boot/dts/o2mnt.dts | 33 - trunk/arch/powerpc/boot/dts/o3dnt.dts | 48 - .../powerpc/boot/dts/p1020rdb_camp_core0.dts | 63 + .../powerpc/boot/dts/p1020rdb_camp_core1.dts | 141 + trunk/arch/powerpc/boot/dts/p1022ds.dtsi | 4 - trunk/arch/powerpc/boot/dts/p1022rdk.dts | 188 - .../powerpc/boot/dts/p2020rdb_camp_core0.dts | 67 + .../powerpc/boot/dts/p2020rdb_camp_core1.dts | 125 + trunk/arch/powerpc/boot/dts/p2041rdb.dts | 4 - trunk/arch/powerpc/boot/dts/p3041ds.dts | 4 - trunk/arch/powerpc/boot/dts/p4080ds.dts | 4 - trunk/arch/powerpc/boot/dts/p5020ds.dts | 4 - trunk/arch/powerpc/boot/dts/p5040ds.dts | 207 - .../powerpc/configs/85xx/p1023rds_defconfig | 6 - .../powerpc/configs/corenet32_smp_defconfig | 1 - .../powerpc/configs/corenet64_smp_defconfig | 1 - trunk/arch/powerpc/configs/mpc85xx_defconfig | 1 - .../powerpc/configs/mpc85xx_smp_defconfig | 1 - trunk/arch/powerpc/configs/ppc64_defconfig | 4 +- trunk/arch/powerpc/configs/pseries_defconfig | 4 +- trunk/arch/powerpc/include/asm/abs_addr.h | 56 + trunk/arch/powerpc/include/asm/bitops.h | 10 - trunk/arch/powerpc/include/asm/cacheflush.h | 2 - trunk/arch/powerpc/include/asm/compat.h | 60 +- trunk/arch/powerpc/include/asm/debug.h | 2 +- trunk/arch/powerpc/include/asm/eeh.h | 141 +- trunk/arch/powerpc/include/asm/eeh_event.h | 6 +- .../arch/powerpc/include/asm/exception-64e.h | 6 +- trunk/arch/powerpc/include/asm/fsl_guts.h | 2 - trunk/arch/powerpc/include/asm/fsl_ifc.h | 14 +- trunk/arch/powerpc/include/asm/hvcall.h | 5 + .../arch/powerpc/include/asm/hw_breakpoint.h | 9 +- trunk/arch/powerpc/include/asm/kprobes.h | 15 +- trunk/arch/powerpc/include/asm/kvm_book3s.h | 2 +- .../arch/powerpc/include/asm/kvm_book3s_asm.h | 1 + trunk/arch/powerpc/include/asm/kvm_host.h | 3 - trunk/arch/powerpc/include/asm/machdep.h | 9 +- trunk/arch/powerpc/include/asm/mmu-hash64.h | 169 +- trunk/arch/powerpc/include/asm/mmu.h | 9 - trunk/arch/powerpc/include/asm/mpc52xx.h | 2 - trunk/arch/powerpc/include/asm/mpic.h | 19 - trunk/arch/powerpc/include/asm/paca.h | 3 +- trunk/arch/powerpc/include/asm/page_64.h | 10 +- trunk/arch/powerpc/include/asm/pci-bridge.h | 11 - .../powerpc/include/asm/perf_event_server.h | 1 - .../powerpc/include/asm/pgtable-ppc64-4k.h | 4 +- .../powerpc/include/asm/pgtable-ppc64-64k.h | 2 +- .../arch/powerpc/include/asm/pgtable-ppc64.h | 19 +- trunk/arch/powerpc/include/asm/pgtable.h | 10 +- trunk/arch/powerpc/include/asm/ppc-opcode.h | 3 - trunk/arch/powerpc/include/asm/ppc-pci.h | 20 +- trunk/arch/powerpc/include/asm/probes.h | 42 - trunk/arch/powerpc/include/asm/processor.h | 6 +- .../arch/powerpc/include/asm/pte-hash64-64k.h | 18 +- trunk/arch/powerpc/include/asm/reg.h | 54 +- trunk/arch/powerpc/include/asm/setup.h | 2 +- trunk/arch/powerpc/include/asm/siginfo.h | 1 + trunk/arch/powerpc/include/asm/smp.h | 2 - trunk/arch/powerpc/include/asm/sparsemem.h | 4 +- trunk/arch/powerpc/include/asm/swiotlb.h | 6 - trunk/arch/powerpc/include/asm/thread_info.h | 7 +- trunk/arch/powerpc/include/asm/tlbflush.h | 7 +- trunk/arch/powerpc/include/asm/uaccess.h | 11 + trunk/arch/powerpc/include/asm/uprobes.h | 54 - trunk/arch/powerpc/kernel/Makefile | 1 - trunk/arch/powerpc/kernel/asm-offsets.c | 2 +- .../arch/powerpc/kernel/cpu_setup_fsl_booke.S | 74 +- trunk/arch/powerpc/kernel/cputable.c | 4 - trunk/arch/powerpc/kernel/dma-swiotlb.c | 22 +- trunk/arch/powerpc/kernel/dma.c | 3 +- trunk/arch/powerpc/kernel/entry_32.S | 47 +- trunk/arch/powerpc/kernel/entry_64.S | 35 - trunk/arch/powerpc/kernel/exceptions-64e.S | 212 +- trunk/arch/powerpc/kernel/exceptions-64s.S | 127 +- trunk/arch/powerpc/kernel/fadump.c | 3 +- trunk/arch/powerpc/kernel/head_fsl_booke.S | 46 +- trunk/arch/powerpc/kernel/hw_breakpoint.c | 25 +- trunk/arch/powerpc/kernel/ibmebus.c | 1 + trunk/arch/powerpc/kernel/iommu.c | 5 +- trunk/arch/powerpc/kernel/irq.c | 8 +- trunk/arch/powerpc/kernel/machine_kexec.c | 14 +- trunk/arch/powerpc/kernel/paca.c | 1 - trunk/arch/powerpc/kernel/pci-common.c | 16 +- trunk/arch/powerpc/kernel/ppc32.h | 51 + trunk/arch/powerpc/kernel/process.c | 16 +- trunk/arch/powerpc/kernel/prom.c | 4 +- trunk/arch/powerpc/kernel/prom_init.c | 6 +- trunk/arch/powerpc/kernel/ptrace.c | 3 - trunk/arch/powerpc/kernel/rtas_flash.c | 7 +- trunk/arch/powerpc/kernel/rtas_pci.c | 5 +- trunk/arch/powerpc/kernel/setup_64.c | 2 - trunk/arch/powerpc/kernel/signal.c | 8 +- trunk/arch/powerpc/kernel/smp.c | 14 +- trunk/arch/powerpc/kernel/time.c | 8 +- trunk/arch/powerpc/kernel/traps.c | 1 - trunk/arch/powerpc/kernel/uprobes.c | 184 - trunk/arch/powerpc/kernel/vdso.c | 4 +- trunk/arch/powerpc/kernel/vio.c | 1 + trunk/arch/powerpc/kvm/44x_tlb.c | 1 + trunk/arch/powerpc/kvm/book3s_32_mmu_host.c | 8 +- trunk/arch/powerpc/kvm/book3s_64_mmu_host.c | 17 +- trunk/arch/powerpc/kvm/book3s_64_mmu_hv.c | 51 +- trunk/arch/powerpc/kvm/book3s_hv_rm_mmu.c | 6 +- trunk/arch/powerpc/kvm/book3s_hv_rmhandlers.S | 2 +- trunk/arch/powerpc/kvm/book3s_pr.c | 4 +- trunk/arch/powerpc/kvm/e500_tlb.c | 3 +- trunk/arch/powerpc/kvm/powerpc.c | 14 +- trunk/arch/powerpc/kvm/trace.h | 14 +- trunk/arch/powerpc/lib/memcpy_power7.S | 4 +- trunk/arch/powerpc/lib/sstep.c | 36 +- trunk/arch/powerpc/mm/fault.c | 1 - trunk/arch/powerpc/mm/hash_low_64.S | 97 +- trunk/arch/powerpc/mm/hash_native_64.c | 192 +- trunk/arch/powerpc/mm/hash_utils_64.c | 48 +- trunk/arch/powerpc/mm/hugetlbpage-hash64.c | 15 +- trunk/arch/powerpc/mm/init_64.c | 1 + trunk/arch/powerpc/mm/mem.c | 5 +- trunk/arch/powerpc/mm/mmu_context_hash64.c | 10 +- trunk/arch/powerpc/mm/pgtable_64.c | 13 +- trunk/arch/powerpc/mm/slb_low.S | 62 +- trunk/arch/powerpc/mm/slice.c | 112 +- trunk/arch/powerpc/mm/stab.c | 3 +- trunk/arch/powerpc/mm/subpage-prot.c | 6 +- trunk/arch/powerpc/mm/tlb_hash64.c | 11 +- trunk/arch/powerpc/mm/tlb_low_64e.S | 18 +- trunk/arch/powerpc/oprofile/op_model_power4.c | 116 +- trunk/arch/powerpc/perf/core-book3s.c | 46 +- trunk/arch/powerpc/perf/power7-pmu.c | 3 - .../powerpc/platforms/40x/ppc40x_simple.c | 2 +- trunk/arch/powerpc/platforms/44x/currituck.c | 10 +- trunk/arch/powerpc/platforms/512x/Kconfig | 1 - trunk/arch/powerpc/platforms/512x/clock.c | 6 +- .../powerpc/platforms/512x/mpc5121_generic.c | 2 +- .../powerpc/platforms/512x/mpc512x_shared.c | 6 + trunk/arch/powerpc/platforms/52xx/lite5200.c | 2 +- trunk/arch/powerpc/platforms/52xx/media5200.c | 2 +- .../powerpc/platforms/52xx/mpc5200_simple.c | 1 - .../powerpc/platforms/52xx/mpc52xx_lpbfifo.c | 35 +- .../arch/powerpc/platforms/83xx/mpc837x_rdb.c | 2 +- trunk/arch/powerpc/platforms/85xx/Kconfig | 21 - trunk/arch/powerpc/platforms/85xx/Makefile | 2 - trunk/arch/powerpc/platforms/85xx/common.c | 10 - .../arch/powerpc/platforms/85xx/corenet_ds.c | 38 +- trunk/arch/powerpc/platforms/85xx/ge_imp3a.c | 62 +- .../arch/powerpc/platforms/85xx/mpc8536_ds.c | 36 +- .../arch/powerpc/platforms/85xx/mpc85xx_ads.c | 11 +- .../arch/powerpc/platforms/85xx/mpc85xx_cds.c | 44 +- .../arch/powerpc/platforms/85xx/mpc85xx_ds.c | 15 +- .../arch/powerpc/platforms/85xx/mpc85xx_mds.c | 40 +- .../arch/powerpc/platforms/85xx/mpc85xx_rdb.c | 30 +- trunk/arch/powerpc/platforms/85xx/p1010rdb.c | 14 +- trunk/arch/powerpc/platforms/85xx/p1022_ds.c | 36 +- trunk/arch/powerpc/platforms/85xx/p1022_rdk.c | 167 - trunk/arch/powerpc/platforms/85xx/p1023_rds.c | 9 +- trunk/arch/powerpc/platforms/85xx/p2041_rdb.c | 2 +- trunk/arch/powerpc/platforms/85xx/p3041_ds.c | 2 +- trunk/arch/powerpc/platforms/85xx/p4080_ds.c | 2 +- trunk/arch/powerpc/platforms/85xx/p5020_ds.c | 2 +- trunk/arch/powerpc/platforms/85xx/p5040_ds.c | 89 - trunk/arch/powerpc/platforms/85xx/qemu_e500.c | 5 +- trunk/arch/powerpc/platforms/85xx/sbc8548.c | 21 +- trunk/arch/powerpc/platforms/85xx/smp.c | 220 +- trunk/arch/powerpc/platforms/85xx/socrates.c | 11 +- trunk/arch/powerpc/platforms/85xx/stx_gp3.c | 13 +- trunk/arch/powerpc/platforms/85xx/tqm85xx.c | 23 +- .../arch/powerpc/platforms/85xx/xes_mpc85xx.c | 56 +- trunk/arch/powerpc/platforms/86xx/gef_ppc9a.c | 12 +- .../arch/powerpc/platforms/86xx/gef_sbc310.c | 13 +- .../arch/powerpc/platforms/86xx/gef_sbc610.c | 12 +- .../powerpc/platforms/86xx/mpc8610_hpcd.c | 21 +- .../powerpc/platforms/86xx/mpc86xx_hpcn.c | 42 +- trunk/arch/powerpc/platforms/86xx/sbc8641d.c | 14 +- trunk/arch/powerpc/platforms/cell/beat.c | 4 +- trunk/arch/powerpc/platforms/cell/beat.h | 2 +- trunk/arch/powerpc/platforms/cell/beat_htab.c | 45 +- trunk/arch/powerpc/platforms/pasemi/iommu.c | 6 +- .../arch/powerpc/platforms/powernv/pci-ioda.c | 695 ++- .../powerpc/platforms/powernv/pci-p5ioc2.c | 1 + trunk/arch/powerpc/platforms/powernv/pci.c | 7 +- trunk/arch/powerpc/platforms/powernv/pci.h | 21 +- trunk/arch/powerpc/platforms/ps3/htab.c | 22 +- trunk/arch/powerpc/platforms/ps3/setup.c | 10 +- trunk/arch/powerpc/platforms/pseries/Makefile | 5 +- trunk/arch/powerpc/platforms/pseries/eeh.c | 543 +- .../powerpc/platforms/pseries/eeh_cache.c | 59 +- .../arch/powerpc/platforms/pseries/eeh_dev.c | 14 +- .../powerpc/platforms/pseries/eeh_driver.c | 310 +- .../powerpc/platforms/pseries/eeh_event.c | 54 +- trunk/arch/powerpc/platforms/pseries/eeh_pe.c | 652 -- .../powerpc/platforms/pseries/eeh_pseries.c | 247 +- .../powerpc/platforms/pseries/eeh_sysfs.c | 9 + trunk/arch/powerpc/platforms/pseries/iommu.c | 12 +- trunk/arch/powerpc/platforms/pseries/lpar.c | 77 +- trunk/arch/powerpc/platforms/pseries/msi.c | 26 +- trunk/arch/powerpc/platforms/pseries/pci.c | 2 +- .../powerpc/platforms/pseries/pci_dlpar.c | 32 +- trunk/arch/powerpc/platforms/pseries/setup.c | 22 +- trunk/arch/powerpc/sysdev/Makefile | 2 +- trunk/arch/powerpc/sysdev/dart_iommu.c | 19 +- trunk/arch/powerpc/sysdev/fsl_85xx_l2ctlr.c | 10 - trunk/arch/powerpc/sysdev/fsl_ifc.c | 20 +- trunk/arch/powerpc/sysdev/fsl_mpic_err.c | 149 - trunk/arch/powerpc/sysdev/fsl_pci.c | 157 +- trunk/arch/powerpc/sysdev/fsl_pci.h | 20 +- trunk/arch/powerpc/sysdev/mpic.c | 102 +- trunk/arch/powerpc/sysdev/mpic.h | 22 - trunk/arch/powerpc/xmon/xmon.c | 111 +- trunk/arch/s390/crypto/aes_s390.c | 5 + trunk/arch/s390/crypto/des_s390.c | 10 + trunk/arch/s390/crypto/ghash_s390.c | 1 + trunk/arch/s390/include/asm/compat.h | 75 +- trunk/arch/s390/include/asm/processor.h | 1 - trunk/arch/s390/kernel/compat_linux.h | 68 + trunk/arch/s390/kernel/dis.c | 27 - trunk/arch/s390/kvm/Kconfig | 1 - trunk/arch/s390/kvm/diag.c | 4 - trunk/arch/s390/kvm/intercept.c | 11 - trunk/arch/s390/kvm/interrupt.c | 25 +- trunk/arch/s390/kvm/kvm-s390.c | 17 +- trunk/arch/s390/kvm/priv.c | 9 +- trunk/arch/s390/kvm/sigp.c | 2 - trunk/arch/s390/kvm/trace-s390.h | 210 - trunk/arch/s390/kvm/trace.h | 341 -- trunk/arch/score/Kconfig | 1 - trunk/arch/score/include/asm/elf.h | 2 +- trunk/arch/score/include/asm/unistd.h | 5 - trunk/arch/score/kernel/sys_score.c | 1 - trunk/arch/sh/include/asm/elf.h | 3 +- trunk/arch/sh/include/asm/io.h | 2 +- trunk/arch/sh/kernel/ioport.c | 2 +- trunk/arch/sparc/include/asm/compat.h | 61 +- trunk/arch/sparc/include/asm/elf_32.h | 3 +- trunk/arch/sparc/include/asm/siginfo.h | 1 + trunk/arch/sparc/kernel/signal32.c | 52 + trunk/arch/tile/include/asm/compat.h | 62 - trunk/arch/tile/include/asm/elf.h | 4 +- trunk/arch/tile/include/asm/unistd.h | 5 - trunk/arch/tile/kernel/compat_signal.c | 57 + trunk/arch/unicore32/Kconfig | 1 - trunk/arch/unicore32/include/asm/unistd.h | 4 - trunk/arch/x86/Kconfig | 21 +- trunk/arch/x86/crypto/Makefile | 4 - trunk/arch/x86/crypto/aes_glue.c | 1 + trunk/arch/x86/crypto/aesni-intel_glue.c | 258 +- trunk/arch/x86/crypto/blowfish_glue.c | 4 + trunk/arch/x86/crypto/camellia_glue.c | 1382 ++--- .../arch/x86/crypto/cast5-avx-x86_64-asm_64.S | 376 -- trunk/arch/x86/crypto/cast5_avx_glue.c | 530 -- .../arch/x86/crypto/cast6-avx-x86_64-asm_64.S | 383 -- trunk/arch/x86/crypto/cast6_avx_glue.c | 648 -- .../x86/crypto/ghash-clmulni-intel_glue.c | 2 + trunk/arch/x86/crypto/glue_helper.c | 2 +- trunk/arch/x86/crypto/salsa20_glue.c | 1 + trunk/arch/x86/crypto/serpent_avx_glue.c | 10 + trunk/arch/x86/crypto/serpent_sse2_glue.c | 10 + .../x86/crypto/twofish-avx-x86_64-asm_64.S | 227 +- trunk/arch/x86/crypto/twofish_avx_glue.c | 10 + trunk/arch/x86/crypto/twofish_glue.c | 1 + trunk/arch/x86/crypto/twofish_glue_3way.c | 5 + trunk/arch/x86/include/asm/apic.h | 2 +- trunk/arch/x86/include/asm/compat.h | 74 +- trunk/arch/x86/include/asm/ia32.h | 67 + trunk/arch/x86/include/asm/kvm.h | 1 - trunk/arch/x86/include/asm/kvm_emulate.h | 48 +- trunk/arch/x86/include/asm/kvm_host.h | 36 +- trunk/arch/x86/include/asm/kvm_para.h | 6 +- trunk/arch/x86/include/asm/xen/interface.h | 1 - trunk/arch/x86/kernel/Makefile | 3 +- trunk/arch/x86/kernel/apic/apic_numachip.c | 4 +- trunk/arch/x86/kernel/kvm.c | 3 +- trunk/arch/x86/kernel/rtc.c | 2 +- trunk/arch/x86/kernel/setup.c | 2 +- trunk/arch/x86/kvm/Kconfig | 2 - trunk/arch/x86/kvm/Makefile | 2 +- trunk/arch/x86/kvm/cpuid.c | 14 +- trunk/arch/x86/kvm/emulate.c | 538 +- trunk/arch/x86/kvm/i8254.c | 64 +- trunk/arch/x86/kvm/i8254.h | 6 +- trunk/arch/x86/kvm/i8259.c | 70 +- trunk/arch/x86/kvm/irq.h | 2 +- trunk/arch/x86/kvm/kvm_timer.h | 18 + trunk/arch/x86/kvm/lapic.c | 484 +- trunk/arch/x86/kvm/lapic.h | 61 +- trunk/arch/x86/kvm/mmu.c | 240 +- trunk/arch/x86/kvm/mmu.h | 25 +- trunk/arch/x86/kvm/mmu_audit.c | 8 +- trunk/arch/x86/kvm/paging_tmpl.h | 199 +- trunk/arch/x86/kvm/pmu.c | 2 +- trunk/arch/x86/kvm/svm.c | 82 +- trunk/arch/x86/kvm/timer.c | 47 + trunk/arch/x86/kvm/vmx.c | 233 +- trunk/arch/x86/kvm/x86.c | 384 +- trunk/arch/x86/kvm/x86.h | 1 - trunk/arch/x86/xen/enlighten.c | 1 - trunk/arch/x86/xen/irq.c | 1 - trunk/arch/x86/xen/xen-ops.h | 1 + trunk/arch/xtensa/include/asm/elf.h | 3 +- trunk/crypto/842.c | 182 - trunk/crypto/Kconfig | 75 - trunk/crypto/Makefile | 5 +- trunk/crypto/aes_generic.c | 1 + trunk/crypto/ansi_cprng.c | 63 +- trunk/crypto/anubis.c | 1 + trunk/crypto/blowfish_generic.c | 1 + trunk/crypto/camellia_generic.c | 1 + trunk/crypto/{cast5_generic.c => cast5.c} | 80 +- trunk/crypto/{cast6_generic.c => cast6.c} | 73 +- trunk/crypto/crypto_null.c | 57 +- trunk/crypto/crypto_user.c | 2 +- trunk/crypto/deflate.c | 1 + trunk/crypto/des_generic.c | 25 +- trunk/crypto/fcrypt.c | 1 + trunk/crypto/ghash-generic.c | 1 + trunk/crypto/khazad.c | 1 + trunk/crypto/krng.c | 1 + trunk/crypto/lzo.c | 1 + trunk/crypto/salsa20_generic.c | 1 + trunk/crypto/seed.c | 1 + trunk/crypto/serpent_generic.c | 53 +- trunk/crypto/sha256_generic.c | 25 +- trunk/crypto/sha512_generic.c | 20 +- trunk/crypto/shash.c | 36 - trunk/crypto/tcrypt.c | 95 +- trunk/crypto/tcrypt.h | 1 - trunk/crypto/tea.c | 41 +- trunk/crypto/testmgr.c | 472 +- trunk/crypto/testmgr.h | 5443 +++-------------- trunk/crypto/tgr192.c | 38 +- trunk/crypto/twofish_generic.c | 1 + trunk/crypto/vmac.c | 10 +- trunk/crypto/wp512.c | 39 +- trunk/drivers/atm/eni.c | 2 +- trunk/drivers/base/firmware_class.c | 4 +- trunk/drivers/block/aoe/aoe.h | 93 +- trunk/drivers/block/aoe/aoeblk.c | 91 +- trunk/drivers/block/aoe/aoechr.c | 13 +- trunk/drivers/block/aoe/aoecmd.c | 1232 ++-- trunk/drivers/block/aoe/aoedev.c | 265 +- trunk/drivers/block/aoe/aoemain.c | 10 +- trunk/drivers/block/aoe/aoenet.c | 61 +- trunk/drivers/block/nbd.c | 23 +- trunk/drivers/block/xen-blkback/blkback.c | 1 - trunk/drivers/char/hw_random/mxc-rnga.c | 108 +- trunk/drivers/char/hw_random/octeon-rng.c | 17 +- trunk/drivers/char/mbcs.c | 2 +- trunk/drivers/crypto/Kconfig | 22 +- trunk/drivers/crypto/amcc/crypto4xx_core.c | 1 - trunk/drivers/crypto/atmel-aes.c | 7 + trunk/drivers/crypto/atmel-sha.c | 5 + trunk/drivers/crypto/atmel-tdes.c | 6 + trunk/drivers/crypto/caam/caamalg.c | 51 +- trunk/drivers/crypto/caam/caamhash.c | 22 +- trunk/drivers/crypto/caam/caamrng.c | 9 +- trunk/drivers/crypto/caam/compat.h | 1 - trunk/drivers/crypto/caam/ctrl.c | 6 +- trunk/drivers/crypto/caam/error.c | 2 + trunk/drivers/crypto/caam/key_gen.c | 4 - trunk/drivers/crypto/geode-aes.c | 18 +- trunk/drivers/crypto/hifn_795x.c | 5 +- trunk/drivers/crypto/nx/Kconfig | 26 - trunk/drivers/crypto/nx/Makefile | 5 +- trunk/drivers/crypto/nx/nx-842.c | 1617 ----- trunk/drivers/crypto/nx/nx-aes-cbc.c | 1 + trunk/drivers/crypto/nx/nx-aes-ccm.c | 2 + trunk/drivers/crypto/nx/nx-aes-ctr.c | 2 + trunk/drivers/crypto/nx/nx-aes-ecb.c | 1 + trunk/drivers/crypto/nx/nx-aes-gcm.c | 2 + trunk/drivers/crypto/nx/nx.c | 17 +- trunk/drivers/crypto/omap-aes.c | 1 + trunk/drivers/crypto/padlock-aes.c | 3 + trunk/drivers/crypto/s5p-sss.c | 1 + trunk/drivers/crypto/talitos.c | 442 +- trunk/drivers/crypto/tegra-aes.c | 3 +- trunk/drivers/crypto/ux500/cryp/cryp_core.c | 1 - trunk/drivers/crypto/ux500/hash/hash_core.c | 1 + trunk/drivers/dma/dmaengine.c | 2 +- trunk/drivers/edac/mpc85xx_edac.c | 43 +- trunk/drivers/gpio/Kconfig | 7 - trunk/drivers/gpio/Makefile | 1 - trunk/drivers/gpio/gpio-ich.c | 79 +- trunk/drivers/gpio/gpio-twl6040.c | 137 - trunk/drivers/i2c/i2c-core.c | 2 +- trunk/drivers/ide/aec62xx.c | 2 +- trunk/drivers/ide/ali14xx.c | 4 +- trunk/drivers/ide/alim15x3.c | 2 +- trunk/drivers/ide/amd74xx.c | 2 +- trunk/drivers/ide/atiixp.c | 2 +- trunk/drivers/ide/cmd640.c | 2 +- trunk/drivers/ide/cmd64x.c | 2 +- trunk/drivers/ide/cs5520.c | 2 +- trunk/drivers/ide/cs5530.c | 2 +- trunk/drivers/ide/cs5535.c | 2 +- trunk/drivers/ide/cy82c693.c | 2 +- trunk/drivers/ide/dtc2278.c | 2 +- trunk/drivers/ide/hpt366.c | 24 +- trunk/drivers/ide/ht6560b.c | 2 +- trunk/drivers/ide/icside.c | 2 +- trunk/drivers/ide/ide-pci-generic.c | 2 +- trunk/drivers/ide/it8172.c | 2 +- trunk/drivers/ide/it8213.c | 2 +- trunk/drivers/ide/it821x.c | 2 +- trunk/drivers/ide/jmicron.c | 2 +- trunk/drivers/ide/ns87415.c | 2 +- trunk/drivers/ide/opti621.c | 2 +- trunk/drivers/ide/pdc202xx_new.c | 2 +- trunk/drivers/ide/pdc202xx_old.c | 2 +- trunk/drivers/ide/piix.c | 2 +- trunk/drivers/ide/qd65xx.c | 2 +- trunk/drivers/ide/rz1000.c | 2 +- trunk/drivers/ide/sc1200.c | 2 +- trunk/drivers/ide/scc_pata.c | 2 +- trunk/drivers/ide/serverworks.c | 2 +- trunk/drivers/ide/siimage.c | 2 +- trunk/drivers/ide/sis5513.c | 2 +- trunk/drivers/ide/sl82c105.c | 2 +- trunk/drivers/ide/slc90e66.c | 2 +- trunk/drivers/ide/tc86c001.c | 2 +- trunk/drivers/ide/triflex.c | 2 +- trunk/drivers/ide/trm290.c | 2 +- trunk/drivers/ide/tx4938ide.c | 2 +- trunk/drivers/ide/tx4939ide.c | 2 +- trunk/drivers/ide/umc8672.c | 2 +- trunk/drivers/ide/via82cxxx.c | 2 +- trunk/drivers/infiniband/core/cm.c | 2 +- trunk/drivers/infiniband/hw/ehca/ehca_cq.c | 2 +- trunk/drivers/infiniband/hw/ehca/ehca_eq.c | 2 +- trunk/drivers/infiniband/hw/ehca/ehca_mrmw.c | 45 +- trunk/drivers/infiniband/hw/ehca/ehca_qp.c | 6 +- trunk/drivers/infiniband/hw/ehca/ehca_reqs.c | 2 +- trunk/drivers/infiniband/hw/ehca/ehca_tools.h | 1 + trunk/drivers/infiniband/hw/ehca/hcp_if.c | 12 +- trunk/drivers/infiniband/hw/ehca/ipz_pt_fn.c | 2 +- trunk/drivers/infiniband/hw/mlx4/cm.c | 2 +- trunk/drivers/input/misc/twl4030-vibra.c | 18 +- trunk/drivers/input/touchscreen/88pm860x-ts.c | 127 +- trunk/drivers/leds/leds-88pm860x.c | 205 +- trunk/drivers/macintosh/macio_asic.c | 2 +- trunk/drivers/macintosh/smu.c | 3 +- trunk/drivers/mfd/88pm860x-core.c | 805 +-- trunk/drivers/mfd/88pm860x-i2c.c | 174 +- trunk/drivers/mfd/Kconfig | 75 +- trunk/drivers/mfd/Makefile | 12 +- trunk/drivers/mfd/ab3100-core.c | 1 - trunk/drivers/mfd/ab8500-core.c | 37 +- trunk/drivers/mfd/anatop-mfd.c | 124 + trunk/drivers/mfd/arizona-irq.c | 56 +- trunk/drivers/mfd/da9055-core.c | 423 -- trunk/drivers/mfd/da9055-i2c.c | 93 - trunk/drivers/mfd/db8500-prcmu.c | 47 +- trunk/drivers/mfd/lp8788-irq.c | 198 - trunk/drivers/mfd/lp8788.c | 245 - trunk/drivers/mfd/lpc_ich.c | 43 +- trunk/drivers/mfd/max8907.c | 351 -- trunk/drivers/mfd/max8925-core.c | 427 +- trunk/drivers/mfd/mc13xxx-core.c | 1 + trunk/drivers/mfd/omap-usb-host.c | 238 +- trunk/drivers/mfd/omap-usb-tll.c | 471 -- trunk/drivers/mfd/palmas.c | 149 +- trunk/drivers/mfd/rc5t583-irq.c | 2 +- trunk/drivers/mfd/rc5t583.c | 2 +- trunk/drivers/mfd/smsc-ece1099.c | 113 - trunk/drivers/mfd/syscon.c | 176 - trunk/drivers/mfd/tc3589x.c | 112 +- trunk/drivers/mfd/tps65090.c | 2 +- trunk/drivers/mfd/tps65217.c | 3 - trunk/drivers/mfd/tps6586x.c | 19 - trunk/drivers/mfd/tps65910.c | 32 - trunk/drivers/mfd/twl-core.c | 156 +- trunk/drivers/mfd/twl4030-audio.c | 105 +- .../{pwm/pwm-twl6030.c => mfd/twl6030-pwm.c} | 119 +- trunk/drivers/mfd/twl6040-core.c | 17 +- trunk/drivers/mfd/wm5110-tables.c | 96 +- trunk/drivers/mfd/wm831x-core.c | 66 +- trunk/drivers/mfd/wm8994-core.c | 8 +- trunk/drivers/mfd/wm8994-regmap.c | 2 +- trunk/drivers/mmc/host/sdhci-pci.c | 2 +- trunk/drivers/mtd/nand/fsl_ifc_nand.c | 56 +- trunk/drivers/net/bonding/bond_main.c | 2 - trunk/drivers/net/can/mscan/mpc5xxx_can.c | 8 +- trunk/drivers/net/can/sja1000/peak_pci.c | 2 - trunk/drivers/net/can/sja1000/peak_pcmcia.c | 4 +- trunk/drivers/net/can/slcan.c | 2 +- trunk/drivers/net/can/vcan.c | 2 +- trunk/drivers/net/ethernet/8390/ne3210.c | 2 +- trunk/drivers/net/ethernet/adaptec/starfire.c | 2 +- .../net/ethernet/atheros/atl1c/atl1c_main.c | 2 +- .../drivers/net/ethernet/atheros/atlx/atl2.c | 2 +- .../net/ethernet/broadcom/bnx2x/bnx2x_cmn.c | 17 +- .../net/ethernet/broadcom/bnx2x/bnx2x_main.c | 5 +- trunk/drivers/net/ethernet/broadcom/tg3.c | 11 +- .../net/ethernet/chelsio/cxgb4/cxgb4.h | 1 - .../net/ethernet/chelsio/cxgb4/t4_hw.c | 43 +- .../drivers/net/ethernet/dec/tulip/de2104x.c | 7 +- trunk/drivers/net/ethernet/dec/tulip/eeprom.c | 2 +- .../net/ethernet/dec/tulip/tulip_core.c | 7 +- .../net/ethernet/dec/tulip/winbond-840.c | 2 +- trunk/drivers/net/ethernet/dlink/sundance.c | 2 +- trunk/drivers/net/ethernet/fealnx.c | 2 +- trunk/drivers/net/ethernet/ibm/ehea/ehea.h | 1 + .../drivers/net/ethernet/ibm/ehea/ehea_phyp.c | 12 +- .../drivers/net/ethernet/ibm/ehea/ehea_qmr.c | 14 +- .../net/ethernet/intel/ixgbe/ixgbe_82599.c | 2 +- .../net/ethernet/intel/ixgbe/ixgbe_common.c | 1 - .../net/ethernet/intel/ixgbe/ixgbe_ethtool.c | 5 +- .../net/ethernet/intel/ixgbe/ixgbe_main.c | 15 +- .../net/ethernet/intel/ixgbe/ixgbe_ptp.c | 202 +- .../net/ethernet/intel/ixgbe/ixgbe_type.h | 1 - .../net/ethernet/oki-semi/pch_gbe/Kconfig | 2 +- .../net/ethernet/qlogic/qlcnic/qlcnic_hw.c | 2 +- trunk/drivers/net/ethernet/realtek/8139too.c | 2 +- trunk/drivers/net/ethernet/sfc/efx.c | 4 +- trunk/drivers/net/ethernet/sfc/net_driver.h | 12 + trunk/drivers/net/ethernet/sfc/nic.c | 4 +- trunk/drivers/net/ethernet/sis/sis190.c | 2 +- trunk/drivers/net/ethernet/ti/davinci_cpdma.c | 1 - trunk/drivers/net/hamradio/6pack.c | 6 +- trunk/drivers/net/hamradio/bpqether.c | 2 +- trunk/drivers/net/hamradio/mkiss.c | 6 +- trunk/drivers/net/hamradio/scc.c | 2 +- trunk/drivers/net/hamradio/yam.c | 2 +- trunk/drivers/net/rionet.c | 141 +- trunk/drivers/net/team/team.c | 2 - trunk/drivers/net/wan/z85230.c | 2 +- trunk/drivers/net/xen-netback/netback.c | 1 - trunk/drivers/net/xen-netfront.c | 1 - trunk/drivers/pci/hotplug/rpadlpar_core.c | 2 +- trunk/drivers/platform/x86/amilo-rfkill.c | 2 +- trunk/drivers/platform/x86/fujitsu-tablet.c | 10 +- trunk/drivers/platform/x86/thinkpad_acpi.c | 2 +- trunk/drivers/pps/pps.c | 2 +- trunk/drivers/pwm/Kconfig | 9 - trunk/drivers/pwm/Makefile | 1 - trunk/drivers/rapidio/devices/tsi721.c | 94 +- trunk/drivers/rapidio/devices/tsi721.h | 15 +- trunk/drivers/rapidio/rio-scan.c | 335 +- trunk/drivers/rapidio/rio.c | 95 +- trunk/drivers/regulator/88pm8607.c | 136 +- trunk/drivers/regulator/Kconfig | 2 +- trunk/drivers/regulator/ab3100.c | 1 - trunk/drivers/regulator/anatop-regulator.c | 31 +- trunk/drivers/regulator/max8925-regulator.c | 35 +- trunk/drivers/regulator/palmas-regulator.c | 127 +- trunk/drivers/regulator/wm831x-dcdc.c | 12 +- trunk/drivers/regulator/wm831x-isink.c | 4 +- trunk/drivers/regulator/wm831x-ldo.c | 12 +- trunk/drivers/remoteproc/Kconfig | 14 - trunk/drivers/remoteproc/Makefile | 1 - trunk/drivers/remoteproc/omap_remoteproc.c | 3 - trunk/drivers/remoteproc/remoteproc_core.c | 209 +- trunk/drivers/remoteproc/remoteproc_debugfs.c | 85 +- .../drivers/remoteproc/remoteproc_internal.h | 1 - trunk/drivers/remoteproc/ste_modem_rproc.c | 322 - trunk/drivers/rtc/Kconfig | 87 +- trunk/drivers/rtc/Makefile | 5 - trunk/drivers/rtc/class.c | 9 +- trunk/drivers/rtc/hctosys.c | 4 +- trunk/drivers/rtc/rtc-88pm860x.c | 43 +- trunk/drivers/rtc/rtc-at91sam9.c | 13 +- trunk/drivers/rtc/rtc-coh901331.c | 3 +- trunk/drivers/rtc/rtc-ds1672.c | 26 +- trunk/drivers/rtc/rtc-ds2404.c | 303 - trunk/drivers/rtc/rtc-em3027.c | 17 +- trunk/drivers/rtc/rtc-isl1208.c | 21 +- trunk/drivers/rtc/rtc-jz4740.c | 2 +- trunk/drivers/rtc/rtc-m41t80.c | 157 +- trunk/drivers/rtc/rtc-max8907.c | 244 - trunk/drivers/rtc/rtc-mxc.c | 30 +- trunk/drivers/rtc/rtc-pcf8563.c | 13 +- trunk/drivers/rtc/rtc-proc.c | 24 +- trunk/drivers/rtc/rtc-rc5t583.c | 331 - trunk/drivers/rtc/rtc-rs5c372.c | 7 +- trunk/drivers/rtc/rtc-s35390a.c | 129 +- trunk/drivers/rtc/rtc-s3c.c | 4 +- trunk/drivers/rtc/rtc-snvs.c | 350 -- trunk/drivers/rtc/rtc-spear.c | 12 +- trunk/drivers/rtc/rtc-sysfs.c | 6 - trunk/drivers/rtc/rtc-tps65910.c | 349 -- trunk/drivers/rtc/rtc-x1205.c | 92 +- trunk/drivers/scsi/aacraid/linit.c | 2 +- trunk/drivers/scsi/aic94xx/aic94xx_init.c | 2 +- trunk/drivers/scsi/atp870u.c | 11 +- trunk/drivers/scsi/ipr.c | 18 +- trunk/drivers/thermal/thermal_sys.c | 2 +- trunk/drivers/tty/hvc/hvc_console.c | 33 +- trunk/drivers/tty/hvc/hvc_vio.c | 123 +- trunk/drivers/video/aty/aty128fb.c | 2 +- trunk/drivers/video/backlight/88pm860x_bl.c | 146 +- trunk/drivers/video/backlight/Kconfig | 30 +- trunk/drivers/video/backlight/Makefile | 4 +- trunk/drivers/video/backlight/da9052_bl.c | 4 +- trunk/drivers/video/backlight/kb3886_bl.c | 4 +- trunk/drivers/video/backlight/lm3630_bl.c | 475 -- trunk/drivers/video/backlight/lm3639_bl.c | 437 -- trunk/drivers/video/backlight/ltv350qv.c | 6 +- trunk/drivers/video/backlight/max8925_bl.c | 79 +- trunk/drivers/video/backlight/platform_lcd.c | 10 - trunk/drivers/video/backlight/progear_bl.c | 162 + trunk/drivers/video/backlight/tps65217_bl.c | 342 -- trunk/drivers/video/geode/gx1fb_core.c | 2 +- trunk/drivers/video/gxt4500.c | 4 +- trunk/drivers/video/i810/i810_main.c | 2 +- trunk/drivers/video/jz4740_fb.c | 2 +- trunk/drivers/video/ps3fb.c | 3 +- trunk/drivers/watchdog/iTCO_wdt.c | 1 - trunk/drivers/xen/Makefile | 14 +- trunk/drivers/xen/events.c | 14 +- trunk/fs/Kconfig.binfmt | 8 - trunk/fs/Makefile | 3 +- trunk/fs/binfmt_aout.c | 54 +- trunk/fs/binfmt_elf.c | 149 +- trunk/fs/binfmt_elf_fdpic.c | 6 +- trunk/fs/binfmt_flat.c | 2 +- trunk/fs/compat_binfmt_elf.c | 7 - trunk/fs/coredump.c | 20 +- trunk/fs/coredump.h | 6 - trunk/fs/eventpoll.c | 38 +- trunk/fs/exec.c | 3 +- trunk/fs/ext3/super.c | 8 +- trunk/fs/fat/Makefile | 2 +- trunk/fs/fat/cache.c | 10 +- trunk/fs/fat/dir.c | 56 +- trunk/fs/fat/fat.h | 97 +- trunk/fs/fat/fatent.c | 13 +- trunk/fs/fat/inode.c | 187 +- trunk/fs/fat/namei_msdos.c | 7 +- trunk/fs/fat/namei_vfat.c | 5 +- trunk/fs/fat/nfs.c | 101 - trunk/fs/hpfs/anode.c | 6 +- trunk/fs/hpfs/dnode.c | 28 +- trunk/fs/jbd/commit.c | 45 +- trunk/fs/jbd/transaction.c | 64 +- trunk/fs/omfs/file.c | 5 +- trunk/fs/proc/generic.c | 15 +- trunk/fs/proc/inode.c | 1 + trunk/fs/proc/internal.h | 2 +- trunk/fs/proc/proc_sysctl.c | 3 +- trunk/fs/proc/root.c | 2 +- trunk/fs/reiserfs/xattr.c | 2 +- trunk/fs/super.c | 2 +- trunk/fs/udf/file.c | 9 - trunk/fs/udf/inode.c | 59 +- trunk/include/asm-generic/bitops/le.h | 10 - trunk/include/asm-generic/unistd.h | 4 - trunk/include/crypto/cast5.h | 27 - trunk/include/crypto/cast6.h | 28 - trunk/include/crypto/internal/hash.h | 2 - trunk/include/linux/audit.h | 206 +- trunk/include/linux/binfmts.h | 3 +- trunk/include/linux/compat.h | 5 + trunk/include/linux/coredump.h | 5 - trunk/include/linux/elf.h | 6 - trunk/include/linux/eventpoll.h | 1 - trunk/include/linux/genalloc.h | 27 - trunk/include/linux/i2c/twl.h | 1 - trunk/include/linux/idr.h | 10 +- trunk/include/linux/init.h | 27 +- trunk/include/linux/ioport.h | 3 +- trunk/include/linux/kvm.h | 25 +- trunk/include/linux/kvm_host.h | 145 +- trunk/include/linux/libfdt.h | 4 +- trunk/include/linux/mfd/88pm860x.h | 48 +- trunk/include/linux/mfd/ab3100.h | 129 - trunk/include/linux/mfd/abx500.h | 117 +- trunk/include/linux/mfd/abx500/ab8500.h | 2 + trunk/include/linux/mfd/anatop.h | 40 + trunk/include/linux/mfd/da9055/core.h | 94 - trunk/include/linux/mfd/da9055/pdata.h | 32 - trunk/include/linux/mfd/da9055/reg.h | 699 --- trunk/include/linux/mfd/lp8788-isink.h | 52 - trunk/include/linux/mfd/lp8788.h | 364 -- trunk/include/linux/mfd/lpc_ich.h | 1 - trunk/include/linux/mfd/max8907.h | 252 - trunk/include/linux/mfd/max8925.h | 26 +- trunk/include/linux/mfd/palmas.h | 232 +- trunk/include/linux/mfd/rc5t583.h | 22 - trunk/include/linux/mfd/smsc.h | 109 - trunk/include/linux/mfd/syscon.h | 23 - .../linux/mfd/syscon/imx6q-iomuxc-gpr.h | 319 - trunk/include/linux/mfd/tc3589x.h | 1 - trunk/include/linux/mfd/tps65217.h | 18 - trunk/include/linux/mfd/tps6586x.h | 1 - trunk/include/linux/mfd/tps65910.h | 13 - trunk/include/linux/mfd/twl6040.h | 11 +- trunk/include/linux/nbd.h | 15 +- trunk/include/linux/nx842.h | 11 - trunk/include/linux/of.h | 6 - trunk/include/linux/percpu.h | 2 +- trunk/include/linux/platform_data/lm3630_bl.h | 57 - trunk/include/linux/platform_data/lm3639_bl.h | 69 - trunk/include/linux/platform_data/lp855x.h | 2 - .../linux/platform_data/remoteproc-omap.h | 2 - trunk/include/linux/remoteproc.h | 24 - trunk/include/linux/rio.h | 21 +- trunk/include/linux/rio_drv.h | 5 - trunk/include/linux/rtc-ds2404.h | 20 - trunk/include/linux/rtc.h | 2 +- trunk/include/linux/sched.h | 1 + trunk/include/linux/slab.h | 6 +- trunk/include/linux/slab_def.h | 27 +- trunk/include/linux/slob_def.h | 6 +- trunk/include/linux/ste_modem_shm.h | 56 - trunk/include/net/ip_fib.h | 1 - trunk/include/net/net_namespace.h | 2 - trunk/include/net/sctp/structs.h | 2 +- trunk/include/xen/events.h | 2 - trunk/include/xen/interface/features.h | 3 - trunk/include/xen/interface/io/protocols.h | 3 - trunk/include/xen/interface/memory.h | 12 +- trunk/include/xen/interface/physdev.h | 2 +- trunk/include/xen/interface/version.h | 2 +- trunk/include/xen/xen.h | 4 +- trunk/init/Kconfig | 7 - trunk/kernel/jump_label.c | 1 - trunk/kernel/kexec.c | 1 + trunk/kernel/resource.c | 50 +- trunk/kernel/signal.c | 3 +- trunk/kernel/sys.c | 3 +- trunk/kernel/sysctl.c | 12 +- trunk/kernel/taskstats.c | 1 - trunk/lib/Kconfig.debug | 9 +- trunk/lib/crc32.c | 9 +- trunk/lib/decompress.c | 9 +- trunk/lib/gcd.c | 3 - trunk/lib/gen_crc32table.c | 6 +- trunk/lib/genalloc.c | 88 +- trunk/lib/idr.c | 32 +- trunk/lib/parser.c | 10 +- trunk/lib/plist.c | 4 +- trunk/lib/scatterlist.c | 16 +- trunk/lib/spinlock_debug.c | 32 +- trunk/lib/vsprintf.c | 139 +- trunk/mm/percpu.c | 2 +- trunk/mm/slab.c | 348 +- trunk/mm/slab.h | 19 +- trunk/mm/slab_common.c | 159 +- trunk/mm/slob.c | 91 +- trunk/mm/slub.c | 208 +- trunk/mm/util.c | 35 +- trunk/net/8021q/vlan_core.c | 3 +- trunk/net/can/af_can.c | 2 +- trunk/net/can/bcm.c | 2 +- trunk/net/can/gw.c | 2 +- trunk/net/can/raw.c | 2 +- trunk/net/decnet/dn_rules.c | 2 +- trunk/net/ipv4/fib_rules.c | 2 +- trunk/net/ipv4/fib_semantics.c | 2 - trunk/net/ipv4/ipmr.c | 2 +- trunk/net/ipv6/addrconf.c | 15 +- trunk/net/ipv6/addrlabel.c | 2 +- trunk/net/ipv6/fib6_rules.c | 2 +- trunk/net/ipv6/ip6mr.c | 2 +- trunk/net/ipv6/route.c | 11 +- trunk/net/irda/af_irda.c | 2 +- trunk/net/irda/irttp.c | 2 +- trunk/net/nfc/llcp/sock.c | 8 +- trunk/net/sctp/input.c | 2 +- trunk/net/sctp/outqueue.c | 15 +- trunk/net/sctp/sm_sideeffect.c | 4 +- trunk/net/sctp/sm_statefuns.c | 2 +- trunk/net/tipc/socket.c | 1 - trunk/scripts/Kbuild.include | 2 +- trunk/scripts/checkpatch.pl | 37 +- trunk/scripts/kernel-doc | 23 +- trunk/security/device_cgroup.c | 373 +- trunk/sound/soc/codecs/wm5100.c | 2 +- trunk/tools/testing/selftests/Makefile | 2 +- trunk/tools/testing/selftests/epoll/Makefile | 11 - .../testing/selftests/epoll/test_epoll.c | 344 -- trunk/virt/kvm/Kconfig | 3 - trunk/virt/kvm/async_pf.c | 11 +- trunk/virt/kvm/eventfd.c | 150 +- trunk/virt/kvm/ioapic.c | 37 +- trunk/virt/kvm/iommu.c | 16 +- trunk/virt/kvm/irq_comm.c | 17 +- trunk/virt/kvm/kvm_main.c | 544 +- 917 files changed, 12685 insertions(+), 39457 deletions(-) create mode 100644 trunk/Documentation/aoe/mkdevs.sh create mode 100644 trunk/Documentation/aoe/mkshelf.sh delete mode 100644 trunk/Documentation/devicetree/bindings/arm/xen.txt delete mode 100644 trunk/Documentation/devicetree/bindings/mfd/88pm860x.txt delete mode 100644 trunk/Documentation/devicetree/bindings/mfd/syscon.txt delete mode 100644 trunk/Documentation/devicetree/bindings/mfd/twl4030-audio.txt delete mode 100644 trunk/Documentation/devicetree/bindings/misc/ifm-csi.txt delete mode 100644 trunk/Documentation/devicetree/bindings/regulator/88pm860x.txt delete mode 100644 trunk/Documentation/devicetree/bindings/regulator/max8907.txt delete mode 100644 trunk/Documentation/devicetree/bindings/rtc/snvs-rtc.txt delete mode 100644 trunk/Documentation/devicetree/bindings/video/backlight/88pm860x.txt delete mode 100644 trunk/Documentation/smsc_ece1099.txt delete mode 100644 trunk/Documentation/virtual/kvm/hypercalls.txt delete mode 100644 trunk/arch/arm/boot/dts/xenvm-4.2.dts delete mode 100644 trunk/arch/arm/crypto/Makefile delete mode 100644 trunk/arch/arm/crypto/aes-armv4.S delete mode 100644 trunk/arch/arm/crypto/aes_glue.c delete mode 100644 trunk/arch/arm/crypto/sha1-armv4-large.S delete mode 100644 trunk/arch/arm/crypto/sha1_glue.c delete mode 100644 trunk/arch/arm/include/asm/hypervisor.h delete mode 100644 trunk/arch/arm/include/asm/sync_bitops.h delete mode 100644 trunk/arch/arm/include/asm/xen/events.h delete mode 100644 trunk/arch/arm/include/asm/xen/hypercall.h delete mode 100644 trunk/arch/arm/include/asm/xen/hypervisor.h delete mode 100644 trunk/arch/arm/include/asm/xen/interface.h delete mode 100644 trunk/arch/arm/include/asm/xen/page.h delete mode 100644 trunk/arch/arm/xen/Makefile delete mode 100644 trunk/arch/arm/xen/enlighten.c delete mode 100644 trunk/arch/arm/xen/grant-table.c delete mode 100644 trunk/arch/arm/xen/hypercall.S delete mode 100644 trunk/arch/powerpc/boot/dts/fsl/e500mc_power_isa.dtsi delete mode 100644 trunk/arch/powerpc/boot/dts/fsl/e500v2_power_isa.dtsi delete mode 100644 trunk/arch/powerpc/boot/dts/fsl/e5500_power_isa.dtsi delete mode 100644 trunk/arch/powerpc/boot/dts/fsl/p5040si-post.dtsi delete mode 100644 trunk/arch/powerpc/boot/dts/fsl/p5040si-pre.dtsi delete mode 100644 trunk/arch/powerpc/boot/dts/fsl/qoriq-sec5.2-0.dtsi delete mode 100644 trunk/arch/powerpc/boot/dts/o2d.dts delete mode 100644 trunk/arch/powerpc/boot/dts/o2d.dtsi delete mode 100644 trunk/arch/powerpc/boot/dts/o2d300.dts delete mode 100644 trunk/arch/powerpc/boot/dts/o2dnt2.dts delete mode 100644 trunk/arch/powerpc/boot/dts/o2i.dts delete mode 100644 trunk/arch/powerpc/boot/dts/o2mnt.dts delete mode 100644 trunk/arch/powerpc/boot/dts/o3dnt.dts create mode 100644 trunk/arch/powerpc/boot/dts/p1020rdb_camp_core0.dts create mode 100644 trunk/arch/powerpc/boot/dts/p1020rdb_camp_core1.dts delete mode 100644 trunk/arch/powerpc/boot/dts/p1022rdk.dts create mode 100644 trunk/arch/powerpc/boot/dts/p2020rdb_camp_core0.dts create mode 100644 trunk/arch/powerpc/boot/dts/p2020rdb_camp_core1.dts delete mode 100644 trunk/arch/powerpc/boot/dts/p5040ds.dts create mode 100644 trunk/arch/powerpc/include/asm/abs_addr.h delete mode 100644 trunk/arch/powerpc/include/asm/probes.h delete mode 100644 trunk/arch/powerpc/include/asm/uprobes.h delete mode 100644 trunk/arch/powerpc/kernel/uprobes.c delete mode 100644 trunk/arch/powerpc/platforms/85xx/p1022_rdk.c delete mode 100644 trunk/arch/powerpc/platforms/85xx/p5040_ds.c delete mode 100644 trunk/arch/powerpc/platforms/pseries/eeh_pe.c delete mode 100644 trunk/arch/powerpc/sysdev/fsl_mpic_err.c delete mode 100644 trunk/arch/s390/kvm/trace-s390.h delete mode 100644 trunk/arch/s390/kvm/trace.h delete mode 100644 trunk/arch/x86/crypto/cast5-avx-x86_64-asm_64.S delete mode 100644 trunk/arch/x86/crypto/cast5_avx_glue.c delete mode 100644 trunk/arch/x86/crypto/cast6-avx-x86_64-asm_64.S delete mode 100644 trunk/arch/x86/crypto/cast6_avx_glue.c create mode 100644 trunk/arch/x86/kvm/kvm_timer.h create mode 100644 trunk/arch/x86/kvm/timer.c delete mode 100644 trunk/crypto/842.c rename trunk/crypto/{cast5_generic.c => cast5.c} (95%) rename trunk/crypto/{cast6_generic.c => cast6.c} (93%) delete mode 100644 trunk/drivers/crypto/nx/Kconfig delete mode 100644 trunk/drivers/crypto/nx/nx-842.c delete mode 100644 trunk/drivers/gpio/gpio-twl6040.c create mode 100644 trunk/drivers/mfd/anatop-mfd.c delete mode 100644 trunk/drivers/mfd/da9055-core.c delete mode 100644 trunk/drivers/mfd/da9055-i2c.c delete mode 100644 trunk/drivers/mfd/lp8788-irq.c delete mode 100644 trunk/drivers/mfd/lp8788.c delete mode 100644 trunk/drivers/mfd/max8907.c delete mode 100644 trunk/drivers/mfd/omap-usb-tll.c delete mode 100644 trunk/drivers/mfd/smsc-ece1099.c delete mode 100644 trunk/drivers/mfd/syscon.c rename trunk/drivers/{pwm/pwm-twl6030.c => mfd/twl6030-pwm.c} (55%) delete mode 100644 trunk/drivers/remoteproc/ste_modem_rproc.c delete mode 100644 trunk/drivers/rtc/rtc-ds2404.c delete mode 100644 trunk/drivers/rtc/rtc-max8907.c delete mode 100644 trunk/drivers/rtc/rtc-rc5t583.c delete mode 100644 trunk/drivers/rtc/rtc-snvs.c delete mode 100644 trunk/drivers/rtc/rtc-tps65910.c delete mode 100644 trunk/drivers/video/backlight/lm3630_bl.c delete mode 100644 trunk/drivers/video/backlight/lm3639_bl.c create mode 100644 trunk/drivers/video/backlight/progear_bl.c delete mode 100644 trunk/drivers/video/backlight/tps65217_bl.c delete mode 100644 trunk/fs/coredump.h delete mode 100644 trunk/fs/fat/nfs.c delete mode 100644 trunk/include/crypto/cast5.h delete mode 100644 trunk/include/crypto/cast6.h delete mode 100644 trunk/include/linux/mfd/ab3100.h create mode 100644 trunk/include/linux/mfd/anatop.h delete mode 100644 trunk/include/linux/mfd/da9055/core.h delete mode 100644 trunk/include/linux/mfd/da9055/pdata.h delete mode 100644 trunk/include/linux/mfd/da9055/reg.h delete mode 100644 trunk/include/linux/mfd/lp8788-isink.h delete mode 100644 trunk/include/linux/mfd/lp8788.h delete mode 100644 trunk/include/linux/mfd/max8907.h delete mode 100644 trunk/include/linux/mfd/smsc.h delete mode 100644 trunk/include/linux/mfd/syscon.h delete mode 100644 trunk/include/linux/mfd/syscon/imx6q-iomuxc-gpr.h delete mode 100644 trunk/include/linux/nx842.h delete mode 100644 trunk/include/linux/platform_data/lm3630_bl.h delete mode 100644 trunk/include/linux/platform_data/lm3639_bl.h delete mode 100644 trunk/include/linux/rtc-ds2404.h delete mode 100644 trunk/include/linux/ste_modem_shm.h delete mode 100644 trunk/tools/testing/selftests/epoll/Makefile delete mode 100644 trunk/tools/testing/selftests/epoll/test_epoll.c diff --git a/[refs] b/[refs] index d87e34d61bb3..b50eb9e0f1cd 100644 --- a/[refs] +++ b/[refs] @@ -1,2 +1,2 @@ --- -refs/heads/master: 125b79d74a63552be757bb49a425b965782e4952 +refs/heads/master: 890139529d45ebd3c60d541f4eddc60e042fdf98 diff --git a/trunk/Documentation/CodingStyle b/trunk/Documentation/CodingStyle index 495e5ba1634c..cb9258b8fd35 100644 --- a/trunk/Documentation/CodingStyle +++ b/trunk/Documentation/CodingStyle @@ -454,16 +454,6 @@ The preferred style for long (multi-line) comments is: * with beginning and ending almost-blank lines. */ -For files in net/ and drivers/net/ the preferred style for long (multi-line) -comments is a little different. - - /* The preferred comment style for files in net/ and drivers/net - * looks like this. - * - * It is nearly the same as the generally preferred comment style, - * but there is no initial almost-blank line. - */ - It's also important to comment data, whether they are basic types or derived types. To this end, use just one data declaration per line (no commas for multiple data declarations). This leaves you room for a small comment on each diff --git a/trunk/Documentation/aoe/aoe.txt b/trunk/Documentation/aoe/aoe.txt index bfc9cb19abcd..5f5aa16047ff 100644 --- a/trunk/Documentation/aoe/aoe.txt +++ b/trunk/Documentation/aoe/aoe.txt @@ -1,16 +1,8 @@ -ATA over Ethernet is a network protocol that provides simple access to -block storage on the LAN. +The EtherDrive (R) HOWTO for users of 2.6 kernels is found at ... - http://support.coraid.com/documents/AoEr11.txt + http://www.coraid.com/SUPPORT/EtherDrive-HBA -The EtherDrive (R) HOWTO for 2.6 and 3.x kernels is found at ... - - http://support.coraid.com/support/linux/EtherDrive-2.6-HOWTO.html - -It has many tips and hints! Please see, especially, recommended -tunings for virtual memory: - - http://support.coraid.com/support/linux/EtherDrive-2.6-HOWTO-5.html#ss5.19 + It has many tips and hints! The aoetools are userland programs that are designed to work with this driver. The aoetools are on sourceforge. @@ -31,12 +23,20 @@ CREATING DEVICE NODES There is a udev-install.sh script that shows how to install these rules on your system. + If you are not using udev, two scripts are provided in + Documentation/aoe as examples of static device node creation for + using the aoe driver. + + rm -rf /dev/etherd + sh Documentation/aoe/mkdevs.sh /dev/etherd + + ... or to make just one shelf's worth of block device nodes ... + + sh Documentation/aoe/mkshelf.sh /dev/etherd 0 + There is also an autoload script that shows how to edit /etc/modprobe.d/aoe.conf to ensure that the aoe module is loaded when - necessary. Preloading the aoe module is preferable to autoloading, - however, because AoE discovery takes a few seconds. It can be - confusing when an AoE device is not present the first time the a - command is run but appears a second later. + necessary. USING DEVICE NODES @@ -51,9 +51,9 @@ USING DEVICE NODES "echo > /dev/etherd/discover" tells the driver to find out what AoE devices are available. - In the future these character devices may disappear and be replaced - by sysfs counterparts. Using the commands in aoetools insulates - users from these implementation details. + These character devices may disappear and be replaced by sysfs + counterparts. Using the commands in aoetools insulates users from + these implementation details. The block devices are named like this: @@ -76,8 +76,8 @@ USING SYSFS The netif attribute is the network interface on the localhost through which we are communicating with the remote AoE device. - There is a script in this directory that formats this information in - a convenient way. Users with aoetools should use the aoe-stat + There is a script in this directory that formats this information + in a convenient way. Users with aoetools can use the aoe-stat command. root@makki root# sh Documentation/aoe/status.sh @@ -121,21 +121,3 @@ DRIVER OPTIONS usage example for the module parameter. modprobe aoe_iflist="eth1 eth3" - - The aoe_deadsecs module parameter determines the maximum number of - seconds that the driver will wait for an AoE device to provide a - response to an AoE command. After aoe_deadsecs seconds have - elapsed, the AoE device will be marked as "down". - - The aoe_maxout module parameter has a default of 128. This is the - maximum number of unresponded packets that will be sent to an AoE - target at one time. - - The aoe_dyndevs module parameter defaults to 1, meaning that the - driver will assign a block device minor number to a discovered AoE - target based on the order of its discovery. With dynamic minor - device numbers in use, a greater range of AoE shelf and slot - addresses can be supported. Users with udev will never have to - think about minor numbers. Using aoe_dyndevs=0 allows device nodes - to be pre-created using a static minor-number scheme with the - aoe-mkshelf script in the aoetools. diff --git a/trunk/Documentation/aoe/mkdevs.sh b/trunk/Documentation/aoe/mkdevs.sh new file mode 100644 index 000000000000..44c0ab702432 --- /dev/null +++ b/trunk/Documentation/aoe/mkdevs.sh @@ -0,0 +1,41 @@ +#!/bin/sh + +n_shelves=${n_shelves:-10} +n_partitions=${n_partitions:-16} + +if test "$#" != "1"; then + echo "Usage: sh `basename $0` {dir}" 1>&2 + echo " n_partitions=16 sh `basename $0` {dir}" 1>&2 + exit 1 +fi +dir=$1 + +MAJOR=152 + +echo "Creating AoE devnode files in $dir ..." + +set -e + +mkdir -p $dir + +# (Status info is in sysfs. See status.sh.) +# rm -f $dir/stat +# mknod -m 0400 $dir/stat c $MAJOR 1 +rm -f $dir/err +mknod -m 0400 $dir/err c $MAJOR 2 +rm -f $dir/discover +mknod -m 0200 $dir/discover c $MAJOR 3 +rm -f $dir/interfaces +mknod -m 0200 $dir/interfaces c $MAJOR 4 +rm -f $dir/revalidate +mknod -m 0200 $dir/revalidate c $MAJOR 5 +rm -f $dir/flush +mknod -m 0200 $dir/flush c $MAJOR 6 + +export n_partitions +mkshelf=`echo $0 | sed 's!mkdevs!mkshelf!'` +i=0 +while test $i -lt $n_shelves; do + sh -xc "sh $mkshelf $dir $i" + i=`expr $i + 1` +done diff --git a/trunk/Documentation/aoe/mkshelf.sh b/trunk/Documentation/aoe/mkshelf.sh new file mode 100644 index 000000000000..32615814271c --- /dev/null +++ b/trunk/Documentation/aoe/mkshelf.sh @@ -0,0 +1,28 @@ +#! /bin/sh + +if test "$#" != "2"; then + echo "Usage: sh `basename $0` {dir} {shelfaddress}" 1>&2 + echo " n_partitions=16 sh `basename $0` {dir} {shelfaddress}" 1>&2 + exit 1 +fi +n_partitions=${n_partitions:-16} +dir=$1 +shelf=$2 +nslots=16 +maxslot=`echo $nslots 1 - p | dc` +MAJOR=152 + +set -e + +minor=`echo $nslots \* $shelf \* $n_partitions | bc` +endp=`echo $n_partitions - 1 | bc` +for slot in `seq 0 $maxslot`; do + for part in `seq 0 $endp`; do + name=e$shelf.$slot + test "$part" != "0" && name=${name}p$part + rm -f $dir/$name + mknod -m 0660 $dir/$name b $MAJOR $minor + + minor=`expr $minor + 1` + done +done diff --git a/trunk/Documentation/aoe/status.sh b/trunk/Documentation/aoe/status.sh index eeec7baae57a..751f3be514b8 100644 --- a/trunk/Documentation/aoe/status.sh +++ b/trunk/Documentation/aoe/status.sh @@ -1,8 +1,5 @@ #! /bin/sh # collate and present sysfs information about AoE storage -# -# A more complete version of this script is aoe-stat, in the -# aoetools. set -e format="%8s\t%8s\t%8s\n" diff --git a/trunk/Documentation/devicetree/bindings/arm/xen.txt b/trunk/Documentation/devicetree/bindings/arm/xen.txt deleted file mode 100644 index 0f7b9c2109f8..000000000000 --- a/trunk/Documentation/devicetree/bindings/arm/xen.txt +++ /dev/null @@ -1,25 +0,0 @@ -* Xen hypervisor device tree bindings - -Xen ARM virtual platforms shall have a top-level "hypervisor" node with -the following properties: - -- compatible: - compatible = "xen,xen-", "xen,xen"; - where is the version of the Xen ABI of the platform. - -- reg: specifies the base physical address and size of a region in - memory where the grant table should be mapped to, using an - HYPERVISOR_memory_op hypercall. The memory region is large enough to map - the whole grant table (it is larger or equal to gnttab_max_grant_frames()). - -- interrupts: the interrupt used by Xen to inject event notifications. - A GIC node is also required. - - -Example (assuming #address-cells = <2> and #size-cells = <2>): - -hypervisor { - compatible = "xen,xen-4.3", "xen,xen"; - reg = <0 0xb0000000 0 0x20000>; - interrupts = <1 15 0xf08>; -}; diff --git a/trunk/Documentation/devicetree/bindings/crypto/fsl-sec4.txt b/trunk/Documentation/devicetree/bindings/crypto/fsl-sec4.txt index bd7ce120bc13..bf57ecd5d73a 100644 --- a/trunk/Documentation/devicetree/bindings/crypto/fsl-sec4.txt +++ b/trunk/Documentation/devicetree/bindings/crypto/fsl-sec4.txt @@ -9,7 +9,6 @@ Copyright (C) 2008-2011 Freescale Semiconductor Inc. -Run Time Integrity Check (RTIC) Node -Run Time Integrity Check (RTIC) Memory Node -Secure Non-Volatile Storage (SNVS) Node - -Secure Non-Volatile Storage (SNVS) Low Power (LP) RTC Node -Full Example NOTE: the SEC 4 is also known as Freescale's Cryptographic Accelerator @@ -295,27 +294,6 @@ Secure Non-Volatile Storage (SNVS) Node address and length of the SEC4 configuration registers. - - #address-cells - Usage: required - Value type: - Definition: A standard property. Defines the number of cells - for representing physical addresses in child nodes. Must - have a value of 1. - - - #size-cells - Usage: required - Value type: - Definition: A standard property. Defines the number of cells - for representing the size of physical addresses in - child nodes. Must have a value of 1. - - - ranges - Usage: required - Value type: - Definition: A standard property. Specifies the physical address - range of the SNVS register space. A triplet that includes - the child address, parent address, & length. - - interrupts Usage: required Value type: @@ -336,33 +314,10 @@ EXAMPLE sec_mon@314000 { compatible = "fsl,sec-v4.0-mon"; reg = <0x314000 0x1000>; - ranges = <0 0x314000 0x1000>; interrupt-parent = <&mpic>; interrupts = <93 2>; }; -===================================================================== -Secure Non-Volatile Storage (SNVS) Low Power (LP) RTC Node - - A SNVS child node that defines SNVS LP RTC. - - - compatible - Usage: required - Value type: - Definition: Must include "fsl,sec-v4.0-mon-rtc-lp". - - - reg - Usage: required - Value type: - Definition: A standard property. Specifies the physical - address and length of the SNVS LP configuration registers. - -EXAMPLE - sec_mon_rtc_lp@314000 { - compatible = "fsl,sec-v4.0-mon-rtc-lp"; - reg = <0x34 0x58>; - }; - ===================================================================== FULL EXAMPLE @@ -435,14 +390,8 @@ FULL EXAMPLE sec_mon: sec_mon@314000 { compatible = "fsl,sec-v4.0-mon"; reg = <0x314000 0x1000>; - ranges = <0 0x314000 0x1000>; interrupt-parent = <&mpic>; interrupts = <93 2>; - - sec_mon_rtc_lp@34 { - compatible = "fsl,sec-v4.0-mon-rtc-lp"; - reg = <0x34 0x58>; - }; }; ===================================================================== diff --git a/trunk/Documentation/devicetree/bindings/mfd/88pm860x.txt b/trunk/Documentation/devicetree/bindings/mfd/88pm860x.txt deleted file mode 100644 index 63f3ee33759c..000000000000 --- a/trunk/Documentation/devicetree/bindings/mfd/88pm860x.txt +++ /dev/null @@ -1,85 +0,0 @@ -* Marvell 88PM860x Power Management IC - -Required parent device properties: -- compatible : "marvell,88pm860x" -- reg : the I2C slave address for the 88pm860x chip -- interrupts : IRQ line for the 88pm860x chip -- interrupt-controller: describes the 88pm860x as an interrupt controller (has its own domain) -- #interrupt-cells : should be 1. - - The cell is the 88pm860x local IRQ number - -Optional parent device properties: -- marvell,88pm860x-irq-read-clr: inicates whether interrupt status is cleared by read -- marvell,88pm860x-slave-addr: 88pm860x are two chips solution. stores the I2C address - of one chip, and this property stores the I2C address of - another chip. - -88pm860x consists of a large and varied group of sub-devices: - -Device Supply Names Description ------- ------------ ----------- -88pm860x-onkey : : On key -88pm860x-rtc : : RTC -88pm8607 : : Regulators -88pm860x-backlight : : Backlight -88pm860x-led : : Led -88pm860x-touch : : Touchscreen - -Example: - - pmic: 88pm860x@34 { - compatible = "marvell,88pm860x"; - reg = <0x34>; - interrupts = <4>; - interrupt-parent = <&intc>; - interrupt-controller; - #interrupt-cells = <1>; - - marvell,88pm860x-irq-read-clr; - marvell,88pm860x-slave-addr = <0x11>; - - regulators { - BUCK1 { - regulator-min-microvolt = <1000000>; - regulator-max-microvolt = <1500000>; - regulator-boot-on; - regulator-always-on; - }; - LDO1 { - regulator-min-microvolt = <1200000>; - regulator-max-microvolt = <2800000>; - regulator-boot-on; - regulator-always-on; - }; - }; - rtc { - marvell,88pm860x-vrtc = <1>; - }; - touch { - marvell,88pm860x-gpadc-prebias = <1>; - marvell,88pm860x-gpadc-slot-cycle = <1>; - marvell,88pm860x-tsi-prebias = <6>; - marvell,88pm860x-pen-prebias = <16>; - marvell,88pm860x-pen-prechg = <2>; - marvell,88pm860x-resistor-X = <300>; - }; - backlights { - backlight-0 { - marvell,88pm860x-iset = <4>; - marvell,88pm860x-pwm = <3>; - }; - backlight-2 { - }; - }; - leds { - led0-red { - marvell,88pm860x-iset = <12>; - }; - led0-green { - marvell,88pm860x-iset = <12>; - }; - led0-blue { - marvell,88pm860x-iset = <12>; - }; - }; - }; diff --git a/trunk/Documentation/devicetree/bindings/mfd/syscon.txt b/trunk/Documentation/devicetree/bindings/mfd/syscon.txt deleted file mode 100644 index fe8150bb3248..000000000000 --- a/trunk/Documentation/devicetree/bindings/mfd/syscon.txt +++ /dev/null @@ -1,20 +0,0 @@ -* System Controller Registers R/W driver - -System controller node represents a register region containing a set -of miscellaneous registers. The registers are not cohesive enough to -represent as any specific type of device. The typical use-case is for -some other node's driver, or platform-specific code, to acquire a -reference to the syscon node (e.g. by phandle, node path, or search -using a specific compatible value), interrogate the node (or associated -OS driver) to determine the location of the registers, and access the -registers directly. - -Required properties: -- compatible: Should contain "syscon". -- reg: the register region can be accessed from syscon - -Examples: -gpr: iomuxc-gpr@020e0000 { - compatible = "fsl,imx6q-iomuxc-gpr", "syscon"; - reg = <0x020e0000 0x38>; -}; diff --git a/trunk/Documentation/devicetree/bindings/mfd/tps65910.txt b/trunk/Documentation/devicetree/bindings/mfd/tps65910.txt index 2e3304888ffc..db03599ae4dc 100644 --- a/trunk/Documentation/devicetree/bindings/mfd/tps65910.txt +++ b/trunk/Documentation/devicetree/bindings/mfd/tps65910.txt @@ -59,8 +59,6 @@ Optional properties: in TPS6591X datasheet) - ti,en-gpio-sleep: enable sleep control for gpios There should be 9 entries here, one for each gpio. -- ti,system-power-controller: Telling whether or not this pmic is controlling - the system power. Regulator Optional properties: - ti,regulator-ext-sleep-control: enable external sleep @@ -81,8 +79,6 @@ Example: #interrupt-cells = <2>; interrupt-controller; - ti,system-power-controller; - ti,vmbch-threshold = 0; ti,vmbch2-threshold = 0; ti,en-ck32k-xtal; diff --git a/trunk/Documentation/devicetree/bindings/mfd/twl4030-audio.txt b/trunk/Documentation/devicetree/bindings/mfd/twl4030-audio.txt deleted file mode 100644 index 414d2ae0adf6..000000000000 --- a/trunk/Documentation/devicetree/bindings/mfd/twl4030-audio.txt +++ /dev/null @@ -1,46 +0,0 @@ -Texas Instruments TWL family (twl4030) audio module - -The audio module inside the TWL family consist of an audio codec and a vibra -driver. - -Required properties: -- compatible : must be "ti,twl4030-audio" - -Optional properties, nodes: - -Audio functionality: -- codec { }: Need to be present if the audio functionality is used. Within this - section the following options can be used: -- ti,digimic_delay: Delay need after enabling the digimic to reduce artifacts - from the start of the recorded sample (in ms) --ti,ramp_delay_value: HS ramp delay configuration to reduce pop noise --ti,hs_extmute: Use external mute for HS pop reduction --ti,hs_extmute_gpio: Use external GPIO to control the external mute --ti,offset_cncl_path: Offset cancellation path selection, refer to TRM for the - valid values. - -Vibra functionality -- ti,enable-vibra: Need to be set to <1> if the vibra functionality is used. if - missing or it is 0, the vibra functionality is disabled. - -Example: -&i2c1 { - clock-frequency = <2600000>; - - twl: twl@48 { - reg = <0x48>; - interrupts = <7>; /* SYS_NIRQ cascaded to intc */ - interrupt-parent = <&intc>; - - twl_audio: audio { - compatible = "ti,twl4030-audio"; - - ti,enable-vibra = <1>; - - codec { - ti,ramp_delay_value = <3>; - }; - - }; - }; -}; diff --git a/trunk/Documentation/devicetree/bindings/mfd/twl6040.txt b/trunk/Documentation/devicetree/bindings/mfd/twl6040.txt index 0f5dd709d752..c855240f3a0e 100644 --- a/trunk/Documentation/devicetree/bindings/mfd/twl6040.txt +++ b/trunk/Documentation/devicetree/bindings/mfd/twl6040.txt @@ -1,7 +1,7 @@ Texas Instruments TWL6040 family -The TWL6040s are 8-channel high quality low-power audio codecs providing audio, -vibra and GPO functionality on OMAP4+ platforms. +The TWL6040s are 8-channel high quality low-power audio codecs providing audio +and vibra functionality on OMAP4+ platforms. They are connected ot the host processor via i2c for commands, McPDM for audio data and commands. @@ -10,8 +10,6 @@ Required properties: - reg: must be 0x4b for i2c address - interrupts: twl6040 has one interrupt line connecteded to the main SoC - interrupt-parent: The parent interrupt controller -- gpio-controller: -- #gpio-cells = <1>: twl6040 provides GPO lines. - twl6040,audpwron-gpio: Power on GPIO line for the twl6040 - vio-supply: Regulator for the twl6040 VIO supply @@ -39,6 +37,7 @@ Example: &i2c1 { twl6040: twl@4b { compatible = "ti,twl6040"; + reg = <0x4b>; interrupts = <0 119 4>; interrupt-parent = <&gic>; @@ -61,5 +60,3 @@ Example: }; }; }; - -/include/ "twl6040.dtsi" diff --git a/trunk/Documentation/devicetree/bindings/misc/ifm-csi.txt b/trunk/Documentation/devicetree/bindings/misc/ifm-csi.txt deleted file mode 100644 index 5bdfffb0b9f7..000000000000 --- a/trunk/Documentation/devicetree/bindings/misc/ifm-csi.txt +++ /dev/null @@ -1,41 +0,0 @@ -IFM camera sensor interface on mpc5200 LocalPlus bus - -Required properties: -- compatible: "ifm,o2d-csi" -- reg: specifies sensor chip select number and associated address range -- interrupts: external interrupt line number and interrupt sense mode - of the interrupt line signaling frame valid events -- gpios: three gpio-specifiers for "capture", "reset" and "master enable" - GPIOs (strictly in this order). -- ifm,csi-clk-handle: the phandle to a node in the DT describing the sensor - clock generator. This node is usually a general purpose timer controller. -- ifm,csi-addr-bus-width: address bus width (valid values are 16, 24, 25) -- ifm,csi-data-bus-width: data bus width (valid values are 8 and 16) -- ifm,csi-wait-cycles: sensor bus wait cycles - -Optional properties: -- ifm,csi-byte-swap: if this property is present, the byte swapping on - the bus will be enabled. - -Example: - - csi@3,0 { - compatible = "ifm,o2d-csi"; - reg = <3 0 0x00100000>; /* CS 3, 1 MiB range */ - interrupts = <1 1 2>; /* IRQ1, edge falling */ - - ifm,csi-clk-handle = <&timer7>; - gpios = <&gpio_simple 23 0 /* image_capture */ - &gpio_simple 26 0 /* image_reset */ - &gpio_simple 29 0>; /* image_master_en */ - - ifm,csi-addr-bus-width = <24>; - ifm,csi-data-bus-width = <8>; - ifm,csi-wait-cycles = <0>; - }; - -The base address of the used chip select is specified in the -ranges property of the parent localbus node, for example: - - ranges = <0 0 0xff000000 0x01000000 - 3 0 0xe3000000 0x00100000>; diff --git a/trunk/Documentation/devicetree/bindings/powerpc/fsl/ifc.txt b/trunk/Documentation/devicetree/bindings/powerpc/fsl/ifc.txt index d5e370450ac0..939a26d541f6 100644 --- a/trunk/Documentation/devicetree/bindings/powerpc/fsl/ifc.txt +++ b/trunk/Documentation/devicetree/bindings/powerpc/fsl/ifc.txt @@ -12,12 +12,9 @@ Properties: - #size-cells : Either one or two, depending on how large each chipselect can be. - reg : Offset and length of the register set for the device -- interrupts: IFC may have one or two interrupts. If two interrupt - specifiers are present, the first is the "common" - interrupt (CM_EVTER_STAT), and the second is the NAND - interrupt (NAND_EVTER_STAT). If there is only one, - that interrupt reports both types of event. - +- interrupts : IFC has two interrupts. The first one is the "common" + interrupt(CM_EVTER_STAT), and second is the NAND interrupt + (NAND_EVTER_STAT). - ranges : Each range corresponds to a single chipselect, and covers the entire access window as configured. diff --git a/trunk/Documentation/devicetree/bindings/regulator/88pm860x.txt b/trunk/Documentation/devicetree/bindings/regulator/88pm860x.txt deleted file mode 100644 index 1267b3e1a2cc..000000000000 --- a/trunk/Documentation/devicetree/bindings/regulator/88pm860x.txt +++ /dev/null @@ -1,30 +0,0 @@ -Marvell 88PM860x regulator - -Required properties: -- compatible: "marvell,88pm860x" -- reg: I2C slave address -- regulators: A node that houses a sub-node for each regulator within the - device. Each sub-node is identified using the regulator-compatible - property, with valid values listed below. - -Example: - - pmic: 88pm860x@34 { - compatible = "marvell,88pm860x"; - reg = <0x34>; - - regulators { - BUCK1 { - regulator-min-microvolt = <1000000>; - regulator-max-microvolt = <1500000>; - regulator-boot-on; - regulator-always-on; - }; - BUCK3 { - regulator-min-microvolt = <1000000>; - regulator-max-microvolt = <3000000>; - regulator-boot-on; - regulator-always-on; - }; - }; - }; diff --git a/trunk/Documentation/devicetree/bindings/regulator/max8907.txt b/trunk/Documentation/devicetree/bindings/regulator/max8907.txt deleted file mode 100644 index 371eccd1cd68..000000000000 --- a/trunk/Documentation/devicetree/bindings/regulator/max8907.txt +++ /dev/null @@ -1,69 +0,0 @@ -MAX8907 regulator - -Required properties: -- compatible: "maxim,max8907" -- reg: I2C slave address -- interrupts: The interrupt output of the controller -- mbatt-supply: The input supply for MBATT, BBAT, SDBY, VRTC. -- in-v1-supply: The input supply for SD1. -- in-v2-supply: The input supply for SD2. -- in-v3-supply: The input supply for SD3. -- in1-supply: The input supply for LDO1. -... -- in20-supply: The input supply for LDO20. -- regulators: A node that houses a sub-node for each regulator within the - device. Each sub-node is identified using the node's name (or the deprecated - regulator-compatible property if present), with valid values listed below. - The content of each sub-node is defined by the standard binding for - regulators; see regulator.txt. - -Optional properties: -- maxim,system-power-controller: Boolean property indicating that the PMIC - controls the overall system power. - -The valid names for regulators are: - - sd1, sd2, sd3, ldo1, ldo2, ldo3, ldo4, ldo5, ldo6, ldo7, ldo8, ldo9, ldo10, - ldo11, ldo12, ldo13, ldo14, ldo15, ldo16, ldo17, ldo18, ldo19, ldo20, out5v, - out33v, bbat, sdby, vrtc. - -Example: - - max8907@3c { - compatible = "maxim,max8907"; - reg = <0x3c>; - interrupts = <0 86 0x4>; - - maxim,system-power-controller; - - mbatt-supply = <&some_reg>; - in-v1-supply = <&mbatt_reg>; - ... - in1-supply = <&mbatt_reg>; - ... - - regulators { - mbatt_reg: mbatt { - regulator-name = "vbat_pmu"; - regulator-min-microvolt = <5000000>; - regulator-max-microvolt = <5000000>; - regulator-always-on; - }; - - sd1 { - regulator-name = "nvvdd_sv1,vdd_cpu_pmu"; - regulator-min-microvolt = <1000000>; - regulator-max-microvolt = <1000000>; - regulator-always-on; - }; - - sd2 { - regulator-name = "nvvdd_sv2,vdd_core"; - regulator-min-microvolt = <1200000>; - regulator-max-microvolt = <1200000>; - regulator-always-on; - }; -... - }; - }; - }; diff --git a/trunk/Documentation/devicetree/bindings/regulator/tps6586x.txt b/trunk/Documentation/devicetree/bindings/regulator/tps6586x.txt index 8b40cac24d93..07b9ef6e49d5 100644 --- a/trunk/Documentation/devicetree/bindings/regulator/tps6586x.txt +++ b/trunk/Documentation/devicetree/bindings/regulator/tps6586x.txt @@ -22,10 +22,6 @@ Required properties: - vinldo678-supply: The input supply for the LDO6, LDO7 and LDO8 - vinldo9-supply: The input supply for the LDO9 -Optional properties: -- ti,system-power-controller: Telling whether or not this pmic is controlling - the system power. - Each regulator is defined using the standard binding for regulators. Note: LDO5 and LDO_RTC is supplied by SYS regulator internally and driver @@ -41,8 +37,6 @@ Example: #gpio-cells = <2>; gpio-controller; - ti,system-power-controller; - sys-supply = <&some_reg>; vin-sm0-supply = <&some_reg>; vin-sm1-supply = <&some_reg>; diff --git a/trunk/Documentation/devicetree/bindings/rtc/snvs-rtc.txt b/trunk/Documentation/devicetree/bindings/rtc/snvs-rtc.txt deleted file mode 100644 index fb61ed77ada3..000000000000 --- a/trunk/Documentation/devicetree/bindings/rtc/snvs-rtc.txt +++ /dev/null @@ -1 +0,0 @@ -See Documentation/devicetree/bindings/crypto/fsl-sec4.txt for details. diff --git a/trunk/Documentation/devicetree/bindings/video/backlight/88pm860x.txt b/trunk/Documentation/devicetree/bindings/video/backlight/88pm860x.txt deleted file mode 100644 index 261df2799315..000000000000 --- a/trunk/Documentation/devicetree/bindings/video/backlight/88pm860x.txt +++ /dev/null @@ -1,15 +0,0 @@ -88pm860x-backlight bindings - -Optional properties: - - marvell,88pm860x-iset: Current supplies on backlight device. - - marvell,88pm860x-pwm: PWM frequency on backlight device. - -Example: - - backlights { - backlight-0 { - marvell,88pm860x-iset = <4>; - marvell,88pm860x-pwm = <3>; - }; - backlight-2 { - }; diff --git a/trunk/Documentation/printk-formats.txt b/trunk/Documentation/printk-formats.txt index 8ffb274367c7..7561d7ed8e11 100644 --- a/trunk/Documentation/printk-formats.txt +++ b/trunk/Documentation/printk-formats.txt @@ -69,7 +69,6 @@ MAC/FDDI addresses: %pMR 05:04:03:02:01:00 %pMF 00-01-02-03-04-05 %pm 000102030405 - %pmR 050403020100 For printing 6-byte MAC/FDDI addresses in hex notation. The 'M' and 'm' specifiers result in a printed address with ('M') or without ('m') byte diff --git a/trunk/Documentation/remoteproc.txt b/trunk/Documentation/remoteproc.txt index e6469fdcf89a..23a09b884bc7 100644 --- a/trunk/Documentation/remoteproc.txt +++ b/trunk/Documentation/remoteproc.txt @@ -129,13 +129,6 @@ int dummy_rproc_example(struct rproc *my_rproc) Returns 0 on success and -EINVAL if @rproc isn't valid. - void rproc_report_crash(struct rproc *rproc, enum rproc_crash_type type) - - Report a crash in a remoteproc - This function must be called every time a crash is detected by the - platform specific rproc implementation. This should not be called from a - non-remoteproc driver. This function can be called from atomic/interrupt - context. - 5. Implementation callbacks These callbacks should be provided by platform-specific remoteproc diff --git a/trunk/Documentation/rtc.txt b/trunk/Documentation/rtc.txt index 32aa4002de4a..250160469d83 100644 --- a/trunk/Documentation/rtc.txt +++ b/trunk/Documentation/rtc.txt @@ -119,9 +119,8 @@ three different userspace interfaces: * /sys/class/rtc/rtcN ... sysfs attributes support readonly access to some RTC attributes. - * /proc/driver/rtc ... the system clock RTC may expose itself - using a procfs interface. If there is no RTC for the system clock, - rtc0 is used by default. More information is (currently) shown + * /proc/driver/rtc ... the first RTC (rtc0) may expose itself + using a procfs interface. More information is (currently) shown here than through sysfs. The RTC Class framework supports a wide variety of RTCs, ranging from those diff --git a/trunk/Documentation/smsc_ece1099.txt b/trunk/Documentation/smsc_ece1099.txt deleted file mode 100644 index 6b492e82b43d..000000000000 --- a/trunk/Documentation/smsc_ece1099.txt +++ /dev/null @@ -1,56 +0,0 @@ -What is smsc-ece1099? ----------------------- - -The ECE1099 is a 40-Pin 3.3V Keyboard Scan Expansion -or GPIO Expansion device. The device supports a keyboard -scan matrix of 23x8. The device is connected to a Master -via the SMSC BC-Link interface or via the SMBus. -Keypad scan Input(KSI) and Keypad Scan Output(KSO) signals -are multiplexed with GPIOs. - -Interrupt generation --------------------- - -Interrupts can be generated by an edge detection on a GPIO -pin or an edge detection on one of the bus interface pins. -Interrupts can also be detected on the keyboard scan interface. -The bus interrupt pin (BC_INT# or SMBUS_INT#) is asserted if -any bit in one of the Interrupt Status registers is 1 and -the corresponding Interrupt Mask bit is also 1. - -In order for software to determine which device is the source -of an interrupt, it should first read the Group Interrupt Status Register -to determine which Status register group is a source for the interrupt. -Software should read both the Status register and the associated Mask register, -then AND the two values together. Bits that are 1 in the result of the AND -are active interrupts. Software clears an interrupt by writing a 1 to the -corresponding bit in the Status register. - -Communication Protocol ----------------------- - -- SMbus slave Interface - The host processor communicates with the ECE1099 device - through a series of read/write registers via the SMBus - interface. SMBus is a serial communication protocol between - a computer host and its peripheral devices. The SMBus data - rate is 10KHz minimum to 400 KHz maximum - -- Slave Bus Interface - The ECE1099 device SMBus implementation is a subset of the - SMBus interface to the host. The device is a slave-only SMBus device. - The implementation in the device is a subset of SMBus since it - only supports four protocols. - - The Write Byte, Read Byte, Send Byte, and Receive Byte protocols are the - only valid SMBus protocols for the device. - -- BC-LinkTM Interface - The BC-Link is a proprietary bus that allows communication - between a Master device and a Companion device. The Master - device uses this serial bus to read and write registers - located on the Companion device. The bus comprises three signals, - BC_CLK, BC_DAT and BC_INT#. The Master device always provides the - clock, BC_CLK, and the Companion device is the source for an - independent asynchronous interrupt signal, BC_INT#. The ECE1099 - supports BC-Link speeds up to 24MHz. diff --git a/trunk/Documentation/sysctl/kernel.txt b/trunk/Documentation/sysctl/kernel.txt index 2907ba6c3607..6d78841fd416 100644 --- a/trunk/Documentation/sysctl/kernel.txt +++ b/trunk/Documentation/sysctl/kernel.txt @@ -181,8 +181,6 @@ core_pattern is used to specify a core dumpfile pattern name. %p pid %u uid %g gid - %d dump mode, matches PR_SET_DUMPABLE and - /proc/sys/fs/suid_dumpable %s signal number %t UNIX time of dump %h hostname diff --git a/trunk/Documentation/virtual/kvm/api.txt b/trunk/Documentation/virtual/kvm/api.txt index f6ec3a92e621..bf33aaa4c59f 100644 --- a/trunk/Documentation/virtual/kvm/api.txt +++ b/trunk/Documentation/virtual/kvm/api.txt @@ -857,8 +857,7 @@ struct kvm_userspace_memory_region { }; /* for kvm_memory_region::flags */ -#define KVM_MEM_LOG_DIRTY_PAGES (1UL << 0) -#define KVM_MEM_READONLY (1UL << 1) +#define KVM_MEM_LOG_DIRTY_PAGES 1UL This ioctl allows the user to create or modify a guest physical memory slot. When changing an existing slot, it may be moved in the guest @@ -874,17 +873,14 @@ It is recommended that the lower 21 bits of guest_phys_addr and userspace_addr be identical. This allows large pages in the guest to be backed by large pages in the host. -The flags field supports two flag, KVM_MEM_LOG_DIRTY_PAGES, which instructs -kvm to keep track of writes to memory within the slot. See KVM_GET_DIRTY_LOG -ioctl. The KVM_CAP_READONLY_MEM capability indicates the availability of the -KVM_MEM_READONLY flag. When this flag is set for a memory region, KVM only -allows read accesses. Writes will be posted to userspace as KVM_EXIT_MMIO -exits. +The flags field supports just one flag, KVM_MEM_LOG_DIRTY_PAGES, which +instructs kvm to keep track of writes to memory within the slot. See +the KVM_GET_DIRTY_LOG ioctl. -When the KVM_CAP_SYNC_MMU capability is available, changes in the backing of -the memory region are automatically reflected into the guest. For example, an -mmap() that affects the region will be made visible immediately. Another -example is madvise(MADV_DROP). +When the KVM_CAP_SYNC_MMU capability, changes in the backing of the memory +region are automatically reflected into the guest. For example, an mmap() +that affects the region will be made visible immediately. Another example +is madvise(MADV_DROP). It is recommended to use this API instead of the KVM_SET_MEMORY_REGION ioctl. The KVM_SET_MEMORY_REGION does not allow fine grained control over memory @@ -1950,19 +1946,6 @@ the guest using the specified gsi pin. The irqfd is removed using the KVM_IRQFD_FLAG_DEASSIGN flag, specifying both kvm_irqfd.fd and kvm_irqfd.gsi. -With KVM_CAP_IRQFD_RESAMPLE, KVM_IRQFD supports a de-assert and notify -mechanism allowing emulation of level-triggered, irqfd-based -interrupts. When KVM_IRQFD_FLAG_RESAMPLE is set the user must pass an -additional eventfd in the kvm_irqfd.resamplefd field. When operating -in resample mode, posting of an interrupt through kvm_irq.fd asserts -the specified gsi in the irqchip. When the irqchip is resampled, such -as from an EOI, the gsi is de-asserted and the user is notifed via -kvm_irqfd.resamplefd. It is the user's responsibility to re-queue -the interrupt if the device making use of it still requires service. -Note that closing the resamplefd is not sufficient to disable the -irqfd. The KVM_IRQFD_FLAG_RESAMPLE is only necessary on assignment -and need not be specified with KVM_IRQFD_FLAG_DEASSIGN. - 4.76 KVM_PPC_ALLOCATE_HTAB Capability: KVM_CAP_PPC_ALLOC_HTAB diff --git a/trunk/Documentation/virtual/kvm/hypercalls.txt b/trunk/Documentation/virtual/kvm/hypercalls.txt deleted file mode 100644 index ea113b5d87a4..000000000000 --- a/trunk/Documentation/virtual/kvm/hypercalls.txt +++ /dev/null @@ -1,66 +0,0 @@ -Linux KVM Hypercall: -=================== -X86: - KVM Hypercalls have a three-byte sequence of either the vmcall or the vmmcall - instruction. The hypervisor can replace it with instructions that are - guaranteed to be supported. - - Up to four arguments may be passed in rbx, rcx, rdx, and rsi respectively. - The hypercall number should be placed in rax and the return value will be - placed in rax. No other registers will be clobbered unless explicitly stated - by the particular hypercall. - -S390: - R2-R7 are used for parameters 1-6. In addition, R1 is used for hypercall - number. The return value is written to R2. - - S390 uses diagnose instruction as hypercall (0x500) along with hypercall - number in R1. - - PowerPC: - It uses R3-R10 and hypercall number in R11. R4-R11 are used as output registers. - Return value is placed in R3. - - KVM hypercalls uses 4 byte opcode, that are patched with 'hypercall-instructions' - property inside the device tree's /hypervisor node. - For more information refer to Documentation/virtual/kvm/ppc-pv.txt - -KVM Hypercalls Documentation -=========================== -The template for each hypercall is: -1. Hypercall name. -2. Architecture(s) -3. Status (deprecated, obsolete, active) -4. Purpose - -1. KVM_HC_VAPIC_POLL_IRQ ------------------------- -Architecture: x86 -Status: active -Purpose: Trigger guest exit so that the host can check for pending -interrupts on reentry. - -2. KVM_HC_MMU_OP ------------------------- -Architecture: x86 -Status: deprecated. -Purpose: Support MMU operations such as writing to PTE, -flushing TLB, release PT. - -3. KVM_HC_FEATURES ------------------------- -Architecture: PPC -Status: active -Purpose: Expose hypercall availability to the guest. On x86 platforms, cpuid -used to enumerate which hypercalls are available. On PPC, either device tree -based lookup ( which is also what EPAPR dictates) OR KVM specific enumeration -mechanism (which is this hypercall) can be used. - -4. KVM_HC_PPC_MAP_MAGIC_PAGE ------------------------- -Architecture: PPC -Status: active -Purpose: To enable communication between the hypervisor and guest there is a -shared page that contains parts of supervisor visible register state. -The guest can map this shared page to access its supervisor register through -memory using this hypercall. diff --git a/trunk/Documentation/virtual/kvm/msr.txt b/trunk/Documentation/virtual/kvm/msr.txt index 6d470ae7b073..730471048583 100644 --- a/trunk/Documentation/virtual/kvm/msr.txt +++ b/trunk/Documentation/virtual/kvm/msr.txt @@ -34,12 +34,9 @@ MSR_KVM_WALL_CLOCK_NEW: 0x4b564d00 time information and check that they are both equal and even. An odd version indicates an in-progress update. - sec: number of seconds for wallclock at time of boot. + sec: number of seconds for wallclock. - nsec: number of nanoseconds for wallclock at time of boot. - - In order to get the current wallclock time, the system_time from - MSR_KVM_SYSTEM_TIME_NEW needs to be added. + nsec: number of nanoseconds for wallclock. Note that although MSRs are per-CPU entities, the effect of this particular MSR is global. @@ -85,25 +82,20 @@ MSR_KVM_SYSTEM_TIME_NEW: 0x4b564d01 time at the time this structure was last updated. Unit is nanoseconds. - tsc_to_system_mul: multiplier to be used when converting - tsc-related quantity to nanoseconds + tsc_to_system_mul: a function of the tsc frequency. One has + to multiply any tsc-related quantity by this value to get + a value in nanoseconds, besides dividing by 2^tsc_shift - tsc_shift: shift to be used when converting tsc-related - quantity to nanoseconds. This shift will ensure that - multiplication with tsc_to_system_mul does not overflow. - A positive value denotes a left shift, a negative value - a right shift. + tsc_shift: cycle to nanosecond divider, as a power of two, to + allow for shift rights. One has to shift right any tsc-related + quantity by this value to get a value in nanoseconds, besides + multiplying by tsc_to_system_mul. - The conversion from tsc to nanoseconds involves an additional - right shift by 32 bits. With this information, guests can - derive per-CPU time by doing: + With this information, guests can derive per-CPU time by + doing: time = (current_tsc - tsc_timestamp) - if (tsc_shift >= 0) - time <<= tsc_shift; - else - time >>= -tsc_shift; - time = (time * tsc_to_system_mul) >> 32 + time = (time * tsc_to_system_mul) >> tsc_shift time = time + system_time flags: bits in this field indicate extended capabilities diff --git a/trunk/Documentation/virtual/kvm/ppc-pv.txt b/trunk/Documentation/virtual/kvm/ppc-pv.txt index 4cd076febb02..4911cf95c67e 100644 --- a/trunk/Documentation/virtual/kvm/ppc-pv.txt +++ b/trunk/Documentation/virtual/kvm/ppc-pv.txt @@ -174,25 +174,3 @@ following: That way we can inject an arbitrary amount of code as replacement for a single instruction. This allows us to check for pending interrupts when setting EE=1 for example. - -Hypercall ABIs in KVM on PowerPC -================================= -1) KVM hypercalls (ePAPR) - -These are ePAPR compliant hypercall implementation (mentioned above). Even -generic hypercalls are implemented here, like the ePAPR idle hcall. These are -available on all targets. - -2) PAPR hypercalls - -PAPR hypercalls are needed to run server PowerPC PAPR guests (-M pseries in QEMU). -These are the same hypercalls that pHyp, the POWER hypervisor implements. Some of -them are handled in the kernel, some are handled in user space. This is only -available on book3s_64. - -3) OSI hypercalls - -Mac-on-Linux is another user of KVM on PowerPC, which has its own hypercall (long -before KVM). This is supported to maintain compatibility. All these hypercalls get -forwarded to user space. This is only useful on book3s_32, but can be used with -book3s_64 as well. diff --git a/trunk/MAINTAINERS b/trunk/MAINTAINERS index 42c2264a154c..d919e3d4a0db 100644 --- a/trunk/MAINTAINERS +++ b/trunk/MAINTAINERS @@ -572,7 +572,7 @@ F: drivers/net/appletalk/ F: net/appletalk/ ARASAN COMPACT FLASH PATA CONTROLLER -M: Viresh Kumar +M: Viresh Kumar L: linux-ide@vger.kernel.org S: Maintained F: include/linux/pata_arasan_cf_data.h @@ -760,7 +760,6 @@ S: Maintained T: git git://git.pengutronix.de/git/imx/linux-2.6.git F: arch/arm/mach-imx/ F: arch/arm/plat-mxc/ -F: arch/arm/configs/imx*_defconfig ARM/FREESCALE IMX6 M: Shawn Guo @@ -1246,7 +1245,7 @@ F: include/linux/i2c/at24.h ATA OVER ETHERNET (AOE) DRIVER M: "Ed L. Cashin" -W: http://support.coraid.com/support/linux +W: http://www.coraid.com/support/linux S: Supported F: Documentation/aoe/ F: drivers/block/aoe/ @@ -3124,7 +3123,6 @@ T: git git://git.secretlab.ca/git/linux-2.6.git F: Documentation/gpio.txt F: drivers/gpio/ F: include/linux/gpio* -F: include/asm-generic/gpio.h GRE DEMULTIPLEXER DRIVER M: Dmitry Kozlov @@ -3440,18 +3438,6 @@ T: git git://git.kernel.org/pub/scm/linux/kernel/git/aegl/linux.git S: Maintained F: arch/ia64/ -IBM Power in-Nest Crypto Acceleration -M: Kent Yoder -L: linux-crypto@vger.kernel.org -S: Supported -F: drivers/crypto/nx/ - -IBM Power 842 compression accelerator -M: Robert Jennings -S: Supported -F: drivers/crypto/nx/nx-842.c -F: include/linux/nx842.h - IBM Power Linux RAID adapter M: Brian King S: Supported @@ -5267,7 +5253,7 @@ F: include/linux/i2c-algo-pca.h F: include/linux/i2c-pca-platform.h PCDP - PRIMARY CONSOLE AND DEBUG PORT -M: Khalid Aziz +M: Khalid Aziz S: Maintained F: drivers/firmware/pcdp.* @@ -5556,7 +5542,7 @@ S: Maintained W: http://linuxptp.sourceforge.net/ F: Documentation/ABI/testing/sysfs-ptp F: Documentation/ptp/* -F: drivers/net/ethernet/freescale/gianfar_ptp.c +F: drivers/net/gianfar_ptp.c F: drivers/net/phy/dp83640* F: drivers/ptp/* F: include/linux/ptp_cl* @@ -5988,7 +5974,7 @@ S: Maintained F: drivers/tty/serial SYNOPSYS DESIGNWARE DMAC DRIVER -M: Viresh Kumar +M: Viresh Kumar S: Maintained F: include/linux/dw_dmac.h F: drivers/dma/dw_dmac_regs.h @@ -6136,7 +6122,7 @@ S: Maintained F: drivers/mmc/host/sdhci-s3c.c SECURE DIGITAL HOST CONTROLLER INTERFACE (SDHCI) ST SPEAR DRIVER -M: Viresh Kumar +M: Viresh Kumar L: spear-devel@list.st.com L: linux-mmc@vger.kernel.org S: Maintained @@ -6501,7 +6487,7 @@ S: Maintained F: include/linux/compiler.h SPEAR PLATFORM SUPPORT -M: Viresh Kumar +M: Viresh Kumar M: Shiraz Hashim L: spear-devel@list.st.com L: linux-arm-kernel@lists.infradead.org (moderated for non-subscribers) @@ -6510,7 +6496,7 @@ S: Maintained F: arch/arm/plat-spear/ SPEAR13XX MACHINE SUPPORT -M: Viresh Kumar +M: Viresh Kumar M: Shiraz Hashim L: spear-devel@list.st.com L: linux-arm-kernel@lists.infradead.org (moderated for non-subscribers) @@ -6519,7 +6505,7 @@ S: Maintained F: arch/arm/mach-spear13xx/ SPEAR3XX MACHINE SUPPORT -M: Viresh Kumar +M: Viresh Kumar M: Shiraz Hashim L: spear-devel@list.st.com L: linux-arm-kernel@lists.infradead.org (moderated for non-subscribers) @@ -6530,7 +6516,7 @@ F: arch/arm/mach-spear3xx/ SPEAR6XX MACHINE SUPPORT M: Rajeev Kumar M: Shiraz Hashim -M: Viresh Kumar +M: Viresh Kumar L: spear-devel@list.st.com L: linux-arm-kernel@lists.infradead.org (moderated for non-subscribers) W: http://www.st.com/spear @@ -6538,7 +6524,7 @@ S: Maintained F: arch/arm/mach-spear6xx/ SPEAR CLOCK FRAMEWORK SUPPORT -M: Viresh Kumar +M: Viresh Kumar L: spear-devel@list.st.com L: linux-arm-kernel@lists.infradead.org (moderated for non-subscribers) W: http://www.st.com/spear @@ -7803,13 +7789,6 @@ F: drivers/xen/ F: arch/x86/include/asm/xen/ F: include/xen/ -XEN HYPERVISOR ARM -M: Stefano Stabellini -L: xen-devel@lists.xensource.com (moderated for non-subscribers) -S: Supported -F: arch/arm/xen/ -F: arch/arm/include/asm/xen/ - XEN NETWORK BACKEND DRIVER M: Ian Campbell L: xen-devel@lists.xensource.com (moderated for non-subscribers) diff --git a/trunk/arch/arm/Kconfig b/trunk/arch/arm/Kconfig index 3975d10cb3ed..7bab17ed2972 100644 --- a/trunk/arch/arm/Kconfig +++ b/trunk/arch/arm/Kconfig @@ -1829,16 +1829,6 @@ config DEPRECATED_PARAM_STRUCT This was deprecated in 2001 and announced to live on for 5 years. Some old boot loaders still use this way. -config XEN_DOM0 - def_bool y - depends on XEN - -config XEN - bool "Xen guest support on ARM (EXPERIMENTAL)" - depends on EXPERIMENTAL && ARM && OF - help - Say Y if you want to run Linux in a Virtual Machine on Xen on ARM. - endmenu menu "Boot options" diff --git a/trunk/arch/arm/Makefile b/trunk/arch/arm/Makefile index 40ea991b6782..770da51242c4 100644 --- a/trunk/arch/arm/Makefile +++ b/trunk/arch/arm/Makefile @@ -250,12 +250,10 @@ endif core-$(CONFIG_FPE_NWFPE) += arch/arm/nwfpe/ core-$(CONFIG_FPE_FASTFPE) += $(FASTFPE_OBJ) core-$(CONFIG_VFP) += arch/arm/vfp/ -core-$(CONFIG_XEN) += arch/arm/xen/ # If we have a machine-specific directory, then include it in the build. core-y += arch/arm/kernel/ arch/arm/mm/ arch/arm/common/ core-y += arch/arm/net/ -core-y += arch/arm/crypto/ core-y += $(machdirs) $(platdirs) drivers-$(CONFIG_OPROFILE) += arch/arm/oprofile/ diff --git a/trunk/arch/arm/boot/dts/Makefile b/trunk/arch/arm/boot/dts/Makefile index 4745c1f68b49..43c084c2cd66 100644 --- a/trunk/arch/arm/boot/dts/Makefile +++ b/trunk/arch/arm/boot/dts/Makefile @@ -96,7 +96,6 @@ dtb-$(CONFIG_ARCH_TEGRA) += tegra20-harmony.dtb \ dtb-$(CONFIG_ARCH_VEXPRESS) += vexpress-v2p-ca5s.dtb \ vexpress-v2p-ca9.dtb \ vexpress-v2p-ca15-tc1.dtb \ - vexpress-v2p-ca15_a7.dtb \ - xenvm-4.2.dtb + vexpress-v2p-ca15_a7.dtb endif diff --git a/trunk/arch/arm/boot/dts/imx6q.dtsi b/trunk/arch/arm/boot/dts/imx6q.dtsi index f3990b04fecf..35e5895ba3df 100644 --- a/trunk/arch/arm/boot/dts/imx6q.dtsi +++ b/trunk/arch/arm/boot/dts/imx6q.dtsi @@ -400,8 +400,8 @@ #clock-cells = <1>; }; - anatop: anatop@020c8000 { - compatible = "fsl,imx6q-anatop", "syscon", "simple-bus"; + anatop@020c8000 { + compatible = "fsl,imx6q-anatop"; reg = <0x020c8000 0x1000>; interrupts = <0 49 0x04 0 54 0x04 0 127 0x04>; @@ -531,11 +531,6 @@ interrupts = <0 89 0x04 0 90 0x04>; }; - gpr: iomuxc-gpr@020e0000 { - compatible = "fsl,imx6q-iomuxc-gpr", "syscon"; - reg = <0x020e0000 0x38>; - }; - iomuxc@020e0000 { compatible = "fsl,imx6q-iomuxc"; reg = <0x020e0000 0x4000>; diff --git a/trunk/arch/arm/boot/dts/pxa910-dkb.dts b/trunk/arch/arm/boot/dts/pxa910-dkb.dts index 595492aa5053..e92be5a474e7 100644 --- a/trunk/arch/arm/boot/dts/pxa910-dkb.dts +++ b/trunk/arch/arm/boot/dts/pxa910-dkb.dts @@ -29,143 +29,6 @@ }; twsi1: i2c@d4011000 { status = "okay"; - - pmic: 88pm860x@34 { - compatible = "marvell,88pm860x"; - reg = <0x34>; - interrupts = <4>; - interrupt-parent = <&intc>; - interrupt-controller; - #interrupt-cells = <1>; - - marvell,88pm860x-irq-read-clr; - marvell,88pm860x-slave-addr = <0x11>; - - regulators { - BUCK1 { - regulator-min-microvolt = <1000000>; - regulator-max-microvolt = <1500000>; - regulator-boot-on; - regulator-always-on; - }; - BUCK2 { - regulator-min-microvolt = <1000000>; - regulator-max-microvolt = <1500000>; - regulator-boot-on; - regulator-always-on; - }; - BUCK3 { - regulator-min-microvolt = <1000000>; - regulator-max-microvolt = <3000000>; - regulator-boot-on; - regulator-always-on; - }; - LDO1 { - regulator-min-microvolt = <1200000>; - regulator-max-microvolt = <2800000>; - regulator-boot-on; - regulator-always-on; - }; - LDO2 { - regulator-min-microvolt = <1800000>; - regulator-max-microvolt = <3300000>; - regulator-boot-on; - regulator-always-on; - }; - LDO3 { - regulator-min-microvolt = <1800000>; - regulator-max-microvolt = <3300000>; - regulator-boot-on; - regulator-always-on; - }; - LDO4 { - regulator-min-microvolt = <1800000>; - regulator-max-microvolt = <3300000>; - regulator-always-on; - }; - LDO5 { - regulator-min-microvolt = <2900000>; - regulator-max-microvolt = <3300000>; - regulator-boot-on; - regulator-always-on; - }; - LDO6 { - regulator-min-microvolt = <1800000>; - regulator-max-microvolt = <3300000>; - regulator-boot-on; - regulator-always-on; - }; - LDO7 { - regulator-min-microvolt = <1800000>; - regulator-max-microvolt = <2900000>; - regulator-boot-on; - regulator-always-on; - }; - LDO8 { - regulator-min-microvolt = <1800000>; - regulator-max-microvolt = <2900000>; - regulator-boot-on; - regulator-always-on; - }; - LDO9 { - regulator-min-microvolt = <1800000>; - regulator-max-microvolt = <3300000>; - regulator-boot-on; - regulator-always-on; - }; - LDO10 { - regulator-min-microvolt = <1200000>; - regulator-max-microvolt = <3300000>; - regulator-boot-on; - regulator-always-on; - }; - LDO12 { - regulator-min-microvolt = <1200000>; - regulator-max-microvolt = <3300000>; - regulator-always-on; - }; - LDO13 { - regulator-min-microvolt = <1200000>; - regulator-max-microvolt = <3300000>; - regulator-always-on; - }; - LDO14 { - regulator-min-microvolt = <1800000>; - regulator-max-microvolt = <3300000>; - regulator-always-on; - }; - }; - rtc { - marvell,88pm860x-vrtc = <1>; - }; - touch { - marvell,88pm860x-gpadc-prebias = <1>; - marvell,88pm860x-gpadc-slot-cycle = <1>; - marvell,88pm860x-tsi-prebias = <6>; - marvell,88pm860x-pen-prebias = <16>; - marvell,88pm860x-pen-prechg = <2>; - marvell,88pm860x-resistor-X = <300>; - }; - backlights { - backlight-0 { - marvell,88pm860x-iset = <4>; - marvell,88pm860x-pwm = <3>; - }; - backlight-2 { - }; - }; - leds { - led0-red { - marvell,88pm860x-iset = <12>; - }; - led0-green { - marvell,88pm860x-iset = <12>; - }; - led0-blue { - marvell,88pm860x-iset = <12>; - }; - }; - }; }; rtc: rtc@d4010000 { status = "okay"; diff --git a/trunk/arch/arm/boot/dts/pxa910.dtsi b/trunk/arch/arm/boot/dts/pxa910.dtsi index 825aaca33034..a3be44d86bcd 100644 --- a/trunk/arch/arm/boot/dts/pxa910.dtsi +++ b/trunk/arch/arm/boot/dts/pxa910.dtsi @@ -120,8 +120,6 @@ twsi1: i2c@d4011000 { compatible = "mrvl,mmp-twsi"; - #address-cells = <1>; - #size-cells = <0>; reg = <0xd4011000 0x1000>; interrupts = <7>; mrvl,i2c-fast-mode; @@ -130,8 +128,6 @@ twsi2: i2c@d4037000 { compatible = "mrvl,mmp-twsi"; - #address-cells = <1>; - #size-cells = <0>; reg = <0xd4037000 0x1000>; interrupts = <54>; status = "disabled"; diff --git a/trunk/arch/arm/boot/dts/xenvm-4.2.dts b/trunk/arch/arm/boot/dts/xenvm-4.2.dts deleted file mode 100644 index ec3f9528e180..000000000000 --- a/trunk/arch/arm/boot/dts/xenvm-4.2.dts +++ /dev/null @@ -1,68 +0,0 @@ -/* - * Xen Virtual Machine for unprivileged guests - * - * Based on ARM Ltd. Versatile Express CoreTile Express (single CPU) - * Cortex-A15 MPCore (V2P-CA15) - * - */ - -/dts-v1/; - -/ { - model = "XENVM-4.2"; - compatible = "xen,xenvm-4.2", "xen,xenvm"; - interrupt-parent = <&gic>; - #address-cells = <2>; - #size-cells = <2>; - - chosen { - /* this field is going to be adjusted by the hypervisor */ - bootargs = "console=hvc0 root=/dev/xvda"; - }; - - cpus { - #address-cells = <1>; - #size-cells = <0>; - - cpu@0 { - device_type = "cpu"; - compatible = "arm,cortex-a15"; - reg = <0>; - }; - }; - - memory@80000000 { - device_type = "memory"; - /* this field is going to be adjusted by the hypervisor */ - reg = <0 0x80000000 0 0x08000000>; - }; - - gic: interrupt-controller@2c001000 { - compatible = "arm,cortex-a15-gic", "arm,cortex-a9-gic"; - #interrupt-cells = <3>; - #address-cells = <0>; - interrupt-controller; - reg = <0 0x2c001000 0 0x1000>, - <0 0x2c002000 0 0x100>; - }; - - timer { - compatible = "arm,armv7-timer"; - interrupts = <1 13 0xf08>, - <1 14 0xf08>, - <1 11 0xf08>, - <1 10 0xf08>; - }; - - hypervisor { - compatible = "xen,xen-4.2", "xen,xen"; - /* this field is going to be adjusted by the hypervisor */ - reg = <0 0xb0000000 0 0x20000>; - /* this field is going to be adjusted by the hypervisor */ - interrupts = <1 15 0xf08>; - }; - - motherboard { - arm,v2m-memory-map = "rs1"; - }; -}; diff --git a/trunk/arch/arm/crypto/Makefile b/trunk/arch/arm/crypto/Makefile deleted file mode 100644 index a2c83851bc90..000000000000 --- a/trunk/arch/arm/crypto/Makefile +++ /dev/null @@ -1,9 +0,0 @@ -# -# Arch-specific CryptoAPI modules. -# - -obj-$(CONFIG_CRYPTO_AES_ARM) += aes-arm.o -obj-$(CONFIG_CRYPTO_SHA1_ARM) += sha1-arm.o - -aes-arm-y := aes-armv4.o aes_glue.o -sha1-arm-y := sha1-armv4-large.o sha1_glue.o diff --git a/trunk/arch/arm/crypto/aes-armv4.S b/trunk/arch/arm/crypto/aes-armv4.S deleted file mode 100644 index e59b1d505d6c..000000000000 --- a/trunk/arch/arm/crypto/aes-armv4.S +++ /dev/null @@ -1,1112 +0,0 @@ -#define __ARM_ARCH__ __LINUX_ARM_ARCH__ -@ ==================================================================== -@ Written by Andy Polyakov for the OpenSSL -@ project. The module is, however, dual licensed under OpenSSL and -@ CRYPTOGAMS licenses depending on where you obtain it. For further -@ details see http://www.openssl.org/~appro/cryptogams/. -@ ==================================================================== - -@ AES for ARMv4 - -@ January 2007. -@ -@ Code uses single 1K S-box and is >2 times faster than code generated -@ by gcc-3.4.1. This is thanks to unique feature of ARMv4 ISA, which -@ allows to merge logical or arithmetic operation with shift or rotate -@ in one instruction and emit combined result every cycle. The module -@ is endian-neutral. The performance is ~42 cycles/byte for 128-bit -@ key [on single-issue Xscale PXA250 core]. - -@ May 2007. -@ -@ AES_set_[en|de]crypt_key is added. - -@ July 2010. -@ -@ Rescheduling for dual-issue pipeline resulted in 12% improvement on -@ Cortex A8 core and ~25 cycles per byte processed with 128-bit key. - -@ February 2011. -@ -@ Profiler-assisted and platform-specific optimization resulted in 16% -@ improvement on Cortex A8 core and ~21.5 cycles per byte. - -@ A little glue here to select the correct code below for the ARM CPU -@ that is being targetted. - -.text -.code 32 - -.type AES_Te,%object -.align 5 -AES_Te: -.word 0xc66363a5, 0xf87c7c84, 0xee777799, 0xf67b7b8d -.word 0xfff2f20d, 0xd66b6bbd, 0xde6f6fb1, 0x91c5c554 -.word 0x60303050, 0x02010103, 0xce6767a9, 0x562b2b7d -.word 0xe7fefe19, 0xb5d7d762, 0x4dababe6, 0xec76769a -.word 0x8fcaca45, 0x1f82829d, 0x89c9c940, 0xfa7d7d87 -.word 0xeffafa15, 0xb25959eb, 0x8e4747c9, 0xfbf0f00b -.word 0x41adadec, 0xb3d4d467, 0x5fa2a2fd, 0x45afafea -.word 0x239c9cbf, 0x53a4a4f7, 0xe4727296, 0x9bc0c05b -.word 0x75b7b7c2, 0xe1fdfd1c, 0x3d9393ae, 0x4c26266a -.word 0x6c36365a, 0x7e3f3f41, 0xf5f7f702, 0x83cccc4f -.word 0x6834345c, 0x51a5a5f4, 0xd1e5e534, 0xf9f1f108 -.word 0xe2717193, 0xabd8d873, 0x62313153, 0x2a15153f -.word 0x0804040c, 0x95c7c752, 0x46232365, 0x9dc3c35e -.word 0x30181828, 0x379696a1, 0x0a05050f, 0x2f9a9ab5 -.word 0x0e070709, 0x24121236, 0x1b80809b, 0xdfe2e23d -.word 0xcdebeb26, 0x4e272769, 0x7fb2b2cd, 0xea75759f -.word 0x1209091b, 0x1d83839e, 0x582c2c74, 0x341a1a2e -.word 0x361b1b2d, 0xdc6e6eb2, 0xb45a5aee, 0x5ba0a0fb -.word 0xa45252f6, 0x763b3b4d, 0xb7d6d661, 0x7db3b3ce -.word 0x5229297b, 0xdde3e33e, 0x5e2f2f71, 0x13848497 -.word 0xa65353f5, 0xb9d1d168, 0x00000000, 0xc1eded2c -.word 0x40202060, 0xe3fcfc1f, 0x79b1b1c8, 0xb65b5bed -.word 0xd46a6abe, 0x8dcbcb46, 0x67bebed9, 0x7239394b -.word 0x944a4ade, 0x984c4cd4, 0xb05858e8, 0x85cfcf4a -.word 0xbbd0d06b, 0xc5efef2a, 0x4faaaae5, 0xedfbfb16 -.word 0x864343c5, 0x9a4d4dd7, 0x66333355, 0x11858594 -.word 0x8a4545cf, 0xe9f9f910, 0x04020206, 0xfe7f7f81 -.word 0xa05050f0, 0x783c3c44, 0x259f9fba, 0x4ba8a8e3 -.word 0xa25151f3, 0x5da3a3fe, 0x804040c0, 0x058f8f8a -.word 0x3f9292ad, 0x219d9dbc, 0x70383848, 0xf1f5f504 -.word 0x63bcbcdf, 0x77b6b6c1, 0xafdada75, 0x42212163 -.word 0x20101030, 0xe5ffff1a, 0xfdf3f30e, 0xbfd2d26d -.word 0x81cdcd4c, 0x180c0c14, 0x26131335, 0xc3ecec2f -.word 0xbe5f5fe1, 0x359797a2, 0x884444cc, 0x2e171739 -.word 0x93c4c457, 0x55a7a7f2, 0xfc7e7e82, 0x7a3d3d47 -.word 0xc86464ac, 0xba5d5de7, 0x3219192b, 0xe6737395 -.word 0xc06060a0, 0x19818198, 0x9e4f4fd1, 0xa3dcdc7f -.word 0x44222266, 0x542a2a7e, 0x3b9090ab, 0x0b888883 -.word 0x8c4646ca, 0xc7eeee29, 0x6bb8b8d3, 0x2814143c -.word 0xa7dede79, 0xbc5e5ee2, 0x160b0b1d, 0xaddbdb76 -.word 0xdbe0e03b, 0x64323256, 0x743a3a4e, 0x140a0a1e -.word 0x924949db, 0x0c06060a, 0x4824246c, 0xb85c5ce4 -.word 0x9fc2c25d, 0xbdd3d36e, 0x43acacef, 0xc46262a6 -.word 0x399191a8, 0x319595a4, 0xd3e4e437, 0xf279798b -.word 0xd5e7e732, 0x8bc8c843, 0x6e373759, 0xda6d6db7 -.word 0x018d8d8c, 0xb1d5d564, 0x9c4e4ed2, 0x49a9a9e0 -.word 0xd86c6cb4, 0xac5656fa, 0xf3f4f407, 0xcfeaea25 -.word 0xca6565af, 0xf47a7a8e, 0x47aeaee9, 0x10080818 -.word 0x6fbabad5, 0xf0787888, 0x4a25256f, 0x5c2e2e72 -.word 0x381c1c24, 0x57a6a6f1, 0x73b4b4c7, 0x97c6c651 -.word 0xcbe8e823, 0xa1dddd7c, 0xe874749c, 0x3e1f1f21 -.word 0x964b4bdd, 0x61bdbddc, 0x0d8b8b86, 0x0f8a8a85 -.word 0xe0707090, 0x7c3e3e42, 0x71b5b5c4, 0xcc6666aa -.word 0x904848d8, 0x06030305, 0xf7f6f601, 0x1c0e0e12 -.word 0xc26161a3, 0x6a35355f, 0xae5757f9, 0x69b9b9d0 -.word 0x17868691, 0x99c1c158, 0x3a1d1d27, 0x279e9eb9 -.word 0xd9e1e138, 0xebf8f813, 0x2b9898b3, 0x22111133 -.word 0xd26969bb, 0xa9d9d970, 0x078e8e89, 0x339494a7 -.word 0x2d9b9bb6, 0x3c1e1e22, 0x15878792, 0xc9e9e920 -.word 0x87cece49, 0xaa5555ff, 0x50282878, 0xa5dfdf7a -.word 0x038c8c8f, 0x59a1a1f8, 0x09898980, 0x1a0d0d17 -.word 0x65bfbfda, 0xd7e6e631, 0x844242c6, 0xd06868b8 -.word 0x824141c3, 0x299999b0, 0x5a2d2d77, 0x1e0f0f11 -.word 0x7bb0b0cb, 0xa85454fc, 0x6dbbbbd6, 0x2c16163a -@ Te4[256] -.byte 0x63, 0x7c, 0x77, 0x7b, 0xf2, 0x6b, 0x6f, 0xc5 -.byte 0x30, 0x01, 0x67, 0x2b, 0xfe, 0xd7, 0xab, 0x76 -.byte 0xca, 0x82, 0xc9, 0x7d, 0xfa, 0x59, 0x47, 0xf0 -.byte 0xad, 0xd4, 0xa2, 0xaf, 0x9c, 0xa4, 0x72, 0xc0 -.byte 0xb7, 0xfd, 0x93, 0x26, 0x36, 0x3f, 0xf7, 0xcc -.byte 0x34, 0xa5, 0xe5, 0xf1, 0x71, 0xd8, 0x31, 0x15 -.byte 0x04, 0xc7, 0x23, 0xc3, 0x18, 0x96, 0x05, 0x9a -.byte 0x07, 0x12, 0x80, 0xe2, 0xeb, 0x27, 0xb2, 0x75 -.byte 0x09, 0x83, 0x2c, 0x1a, 0x1b, 0x6e, 0x5a, 0xa0 -.byte 0x52, 0x3b, 0xd6, 0xb3, 0x29, 0xe3, 0x2f, 0x84 -.byte 0x53, 0xd1, 0x00, 0xed, 0x20, 0xfc, 0xb1, 0x5b -.byte 0x6a, 0xcb, 0xbe, 0x39, 0x4a, 0x4c, 0x58, 0xcf -.byte 0xd0, 0xef, 0xaa, 0xfb, 0x43, 0x4d, 0x33, 0x85 -.byte 0x45, 0xf9, 0x02, 0x7f, 0x50, 0x3c, 0x9f, 0xa8 -.byte 0x51, 0xa3, 0x40, 0x8f, 0x92, 0x9d, 0x38, 0xf5 -.byte 0xbc, 0xb6, 0xda, 0x21, 0x10, 0xff, 0xf3, 0xd2 -.byte 0xcd, 0x0c, 0x13, 0xec, 0x5f, 0x97, 0x44, 0x17 -.byte 0xc4, 0xa7, 0x7e, 0x3d, 0x64, 0x5d, 0x19, 0x73 -.byte 0x60, 0x81, 0x4f, 0xdc, 0x22, 0x2a, 0x90, 0x88 -.byte 0x46, 0xee, 0xb8, 0x14, 0xde, 0x5e, 0x0b, 0xdb -.byte 0xe0, 0x32, 0x3a, 0x0a, 0x49, 0x06, 0x24, 0x5c -.byte 0xc2, 0xd3, 0xac, 0x62, 0x91, 0x95, 0xe4, 0x79 -.byte 0xe7, 0xc8, 0x37, 0x6d, 0x8d, 0xd5, 0x4e, 0xa9 -.byte 0x6c, 0x56, 0xf4, 0xea, 0x65, 0x7a, 0xae, 0x08 -.byte 0xba, 0x78, 0x25, 0x2e, 0x1c, 0xa6, 0xb4, 0xc6 -.byte 0xe8, 0xdd, 0x74, 0x1f, 0x4b, 0xbd, 0x8b, 0x8a -.byte 0x70, 0x3e, 0xb5, 0x66, 0x48, 0x03, 0xf6, 0x0e -.byte 0x61, 0x35, 0x57, 0xb9, 0x86, 0xc1, 0x1d, 0x9e -.byte 0xe1, 0xf8, 0x98, 0x11, 0x69, 0xd9, 0x8e, 0x94 -.byte 0x9b, 0x1e, 0x87, 0xe9, 0xce, 0x55, 0x28, 0xdf -.byte 0x8c, 0xa1, 0x89, 0x0d, 0xbf, 0xe6, 0x42, 0x68 -.byte 0x41, 0x99, 0x2d, 0x0f, 0xb0, 0x54, 0xbb, 0x16 -@ rcon[] -.word 0x01000000, 0x02000000, 0x04000000, 0x08000000 -.word 0x10000000, 0x20000000, 0x40000000, 0x80000000 -.word 0x1B000000, 0x36000000, 0, 0, 0, 0, 0, 0 -.size AES_Te,.-AES_Te - -@ void AES_encrypt(const unsigned char *in, unsigned char *out, -@ const AES_KEY *key) { -.global AES_encrypt -.type AES_encrypt,%function -.align 5 -AES_encrypt: - sub r3,pc,#8 @ AES_encrypt - stmdb sp!,{r1,r4-r12,lr} - mov r12,r0 @ inp - mov r11,r2 - sub r10,r3,#AES_encrypt-AES_Te @ Te -#if __ARM_ARCH__<7 - ldrb r0,[r12,#3] @ load input data in endian-neutral - ldrb r4,[r12,#2] @ manner... - ldrb r5,[r12,#1] - ldrb r6,[r12,#0] - orr r0,r0,r4,lsl#8 - ldrb r1,[r12,#7] - orr r0,r0,r5,lsl#16 - ldrb r4,[r12,#6] - orr r0,r0,r6,lsl#24 - ldrb r5,[r12,#5] - ldrb r6,[r12,#4] - orr r1,r1,r4,lsl#8 - ldrb r2,[r12,#11] - orr r1,r1,r5,lsl#16 - ldrb r4,[r12,#10] - orr r1,r1,r6,lsl#24 - ldrb r5,[r12,#9] - ldrb r6,[r12,#8] - orr r2,r2,r4,lsl#8 - ldrb r3,[r12,#15] - orr r2,r2,r5,lsl#16 - ldrb r4,[r12,#14] - orr r2,r2,r6,lsl#24 - ldrb r5,[r12,#13] - ldrb r6,[r12,#12] - orr r3,r3,r4,lsl#8 - orr r3,r3,r5,lsl#16 - orr r3,r3,r6,lsl#24 -#else - ldr r0,[r12,#0] - ldr r1,[r12,#4] - ldr r2,[r12,#8] - ldr r3,[r12,#12] -#ifdef __ARMEL__ - rev r0,r0 - rev r1,r1 - rev r2,r2 - rev r3,r3 -#endif -#endif - bl _armv4_AES_encrypt - - ldr r12,[sp],#4 @ pop out -#if __ARM_ARCH__>=7 -#ifdef __ARMEL__ - rev r0,r0 - rev r1,r1 - rev r2,r2 - rev r3,r3 -#endif - str r0,[r12,#0] - str r1,[r12,#4] - str r2,[r12,#8] - str r3,[r12,#12] -#else - mov r4,r0,lsr#24 @ write output in endian-neutral - mov r5,r0,lsr#16 @ manner... - mov r6,r0,lsr#8 - strb r4,[r12,#0] - strb r5,[r12,#1] - mov r4,r1,lsr#24 - strb r6,[r12,#2] - mov r5,r1,lsr#16 - strb r0,[r12,#3] - mov r6,r1,lsr#8 - strb r4,[r12,#4] - strb r5,[r12,#5] - mov r4,r2,lsr#24 - strb r6,[r12,#6] - mov r5,r2,lsr#16 - strb r1,[r12,#7] - mov r6,r2,lsr#8 - strb r4,[r12,#8] - strb r5,[r12,#9] - mov r4,r3,lsr#24 - strb r6,[r12,#10] - mov r5,r3,lsr#16 - strb r2,[r12,#11] - mov r6,r3,lsr#8 - strb r4,[r12,#12] - strb r5,[r12,#13] - strb r6,[r12,#14] - strb r3,[r12,#15] -#endif -#if __ARM_ARCH__>=5 - ldmia sp!,{r4-r12,pc} -#else - ldmia sp!,{r4-r12,lr} - tst lr,#1 - moveq pc,lr @ be binary compatible with V4, yet - .word 0xe12fff1e @ interoperable with Thumb ISA:-) -#endif -.size AES_encrypt,.-AES_encrypt - -.type _armv4_AES_encrypt,%function -.align 2 -_armv4_AES_encrypt: - str lr,[sp,#-4]! @ push lr - ldmia r11!,{r4-r7} - eor r0,r0,r4 - ldr r12,[r11,#240-16] - eor r1,r1,r5 - eor r2,r2,r6 - eor r3,r3,r7 - sub r12,r12,#1 - mov lr,#255 - - and r7,lr,r0 - and r8,lr,r0,lsr#8 - and r9,lr,r0,lsr#16 - mov r0,r0,lsr#24 -.Lenc_loop: - ldr r4,[r10,r7,lsl#2] @ Te3[s0>>0] - and r7,lr,r1,lsr#16 @ i0 - ldr r5,[r10,r8,lsl#2] @ Te2[s0>>8] - and r8,lr,r1 - ldr r6,[r10,r9,lsl#2] @ Te1[s0>>16] - and r9,lr,r1,lsr#8 - ldr r0,[r10,r0,lsl#2] @ Te0[s0>>24] - mov r1,r1,lsr#24 - - ldr r7,[r10,r7,lsl#2] @ Te1[s1>>16] - ldr r8,[r10,r8,lsl#2] @ Te3[s1>>0] - ldr r9,[r10,r9,lsl#2] @ Te2[s1>>8] - eor r0,r0,r7,ror#8 - ldr r1,[r10,r1,lsl#2] @ Te0[s1>>24] - and r7,lr,r2,lsr#8 @ i0 - eor r5,r5,r8,ror#8 - and r8,lr,r2,lsr#16 @ i1 - eor r6,r6,r9,ror#8 - and r9,lr,r2 - ldr r7,[r10,r7,lsl#2] @ Te2[s2>>8] - eor r1,r1,r4,ror#24 - ldr r8,[r10,r8,lsl#2] @ Te1[s2>>16] - mov r2,r2,lsr#24 - - ldr r9,[r10,r9,lsl#2] @ Te3[s2>>0] - eor r0,r0,r7,ror#16 - ldr r2,[r10,r2,lsl#2] @ Te0[s2>>24] - and r7,lr,r3 @ i0 - eor r1,r1,r8,ror#8 - and r8,lr,r3,lsr#8 @ i1 - eor r6,r6,r9,ror#16 - and r9,lr,r3,lsr#16 @ i2 - ldr r7,[r10,r7,lsl#2] @ Te3[s3>>0] - eor r2,r2,r5,ror#16 - ldr r8,[r10,r8,lsl#2] @ Te2[s3>>8] - mov r3,r3,lsr#24 - - ldr r9,[r10,r9,lsl#2] @ Te1[s3>>16] - eor r0,r0,r7,ror#24 - ldr r7,[r11],#16 - eor r1,r1,r8,ror#16 - ldr r3,[r10,r3,lsl#2] @ Te0[s3>>24] - eor r2,r2,r9,ror#8 - ldr r4,[r11,#-12] - eor r3,r3,r6,ror#8 - - ldr r5,[r11,#-8] - eor r0,r0,r7 - ldr r6,[r11,#-4] - and r7,lr,r0 - eor r1,r1,r4 - and r8,lr,r0,lsr#8 - eor r2,r2,r5 - and r9,lr,r0,lsr#16 - eor r3,r3,r6 - mov r0,r0,lsr#24 - - subs r12,r12,#1 - bne .Lenc_loop - - add r10,r10,#2 - - ldrb r4,[r10,r7,lsl#2] @ Te4[s0>>0] - and r7,lr,r1,lsr#16 @ i0 - ldrb r5,[r10,r8,lsl#2] @ Te4[s0>>8] - and r8,lr,r1 - ldrb r6,[r10,r9,lsl#2] @ Te4[s0>>16] - and r9,lr,r1,lsr#8 - ldrb r0,[r10,r0,lsl#2] @ Te4[s0>>24] - mov r1,r1,lsr#24 - - ldrb r7,[r10,r7,lsl#2] @ Te4[s1>>16] - ldrb r8,[r10,r8,lsl#2] @ Te4[s1>>0] - ldrb r9,[r10,r9,lsl#2] @ Te4[s1>>8] - eor r0,r7,r0,lsl#8 - ldrb r1,[r10,r1,lsl#2] @ Te4[s1>>24] - and r7,lr,r2,lsr#8 @ i0 - eor r5,r8,r5,lsl#8 - and r8,lr,r2,lsr#16 @ i1 - eor r6,r9,r6,lsl#8 - and r9,lr,r2 - ldrb r7,[r10,r7,lsl#2] @ Te4[s2>>8] - eor r1,r4,r1,lsl#24 - ldrb r8,[r10,r8,lsl#2] @ Te4[s2>>16] - mov r2,r2,lsr#24 - - ldrb r9,[r10,r9,lsl#2] @ Te4[s2>>0] - eor r0,r7,r0,lsl#8 - ldrb r2,[r10,r2,lsl#2] @ Te4[s2>>24] - and r7,lr,r3 @ i0 - eor r1,r1,r8,lsl#16 - and r8,lr,r3,lsr#8 @ i1 - eor r6,r9,r6,lsl#8 - and r9,lr,r3,lsr#16 @ i2 - ldrb r7,[r10,r7,lsl#2] @ Te4[s3>>0] - eor r2,r5,r2,lsl#24 - ldrb r8,[r10,r8,lsl#2] @ Te4[s3>>8] - mov r3,r3,lsr#24 - - ldrb r9,[r10,r9,lsl#2] @ Te4[s3>>16] - eor r0,r7,r0,lsl#8 - ldr r7,[r11,#0] - ldrb r3,[r10,r3,lsl#2] @ Te4[s3>>24] - eor r1,r1,r8,lsl#8 - ldr r4,[r11,#4] - eor r2,r2,r9,lsl#16 - ldr r5,[r11,#8] - eor r3,r6,r3,lsl#24 - ldr r6,[r11,#12] - - eor r0,r0,r7 - eor r1,r1,r4 - eor r2,r2,r5 - eor r3,r3,r6 - - sub r10,r10,#2 - ldr pc,[sp],#4 @ pop and return -.size _armv4_AES_encrypt,.-_armv4_AES_encrypt - -.global private_AES_set_encrypt_key -.type private_AES_set_encrypt_key,%function -.align 5 -private_AES_set_encrypt_key: -_armv4_AES_set_encrypt_key: - sub r3,pc,#8 @ AES_set_encrypt_key - teq r0,#0 - moveq r0,#-1 - beq .Labrt - teq r2,#0 - moveq r0,#-1 - beq .Labrt - - teq r1,#128 - beq .Lok - teq r1,#192 - beq .Lok - teq r1,#256 - movne r0,#-1 - bne .Labrt - -.Lok: stmdb sp!,{r4-r12,lr} - sub r10,r3,#_armv4_AES_set_encrypt_key-AES_Te-1024 @ Te4 - - mov r12,r0 @ inp - mov lr,r1 @ bits - mov r11,r2 @ key - -#if __ARM_ARCH__<7 - ldrb r0,[r12,#3] @ load input data in endian-neutral - ldrb r4,[r12,#2] @ manner... - ldrb r5,[r12,#1] - ldrb r6,[r12,#0] - orr r0,r0,r4,lsl#8 - ldrb r1,[r12,#7] - orr r0,r0,r5,lsl#16 - ldrb r4,[r12,#6] - orr r0,r0,r6,lsl#24 - ldrb r5,[r12,#5] - ldrb r6,[r12,#4] - orr r1,r1,r4,lsl#8 - ldrb r2,[r12,#11] - orr r1,r1,r5,lsl#16 - ldrb r4,[r12,#10] - orr r1,r1,r6,lsl#24 - ldrb r5,[r12,#9] - ldrb r6,[r12,#8] - orr r2,r2,r4,lsl#8 - ldrb r3,[r12,#15] - orr r2,r2,r5,lsl#16 - ldrb r4,[r12,#14] - orr r2,r2,r6,lsl#24 - ldrb r5,[r12,#13] - ldrb r6,[r12,#12] - orr r3,r3,r4,lsl#8 - str r0,[r11],#16 - orr r3,r3,r5,lsl#16 - str r1,[r11,#-12] - orr r3,r3,r6,lsl#24 - str r2,[r11,#-8] - str r3,[r11,#-4] -#else - ldr r0,[r12,#0] - ldr r1,[r12,#4] - ldr r2,[r12,#8] - ldr r3,[r12,#12] -#ifdef __ARMEL__ - rev r0,r0 - rev r1,r1 - rev r2,r2 - rev r3,r3 -#endif - str r0,[r11],#16 - str r1,[r11,#-12] - str r2,[r11,#-8] - str r3,[r11,#-4] -#endif - - teq lr,#128 - bne .Lnot128 - mov r12,#10 - str r12,[r11,#240-16] - add r6,r10,#256 @ rcon - mov lr,#255 - -.L128_loop: - and r5,lr,r3,lsr#24 - and r7,lr,r3,lsr#16 - ldrb r5,[r10,r5] - and r8,lr,r3,lsr#8 - ldrb r7,[r10,r7] - and r9,lr,r3 - ldrb r8,[r10,r8] - orr r5,r5,r7,lsl#24 - ldrb r9,[r10,r9] - orr r5,r5,r8,lsl#16 - ldr r4,[r6],#4 @ rcon[i++] - orr r5,r5,r9,lsl#8 - eor r5,r5,r4 - eor r0,r0,r5 @ rk[4]=rk[0]^... - eor r1,r1,r0 @ rk[5]=rk[1]^rk[4] - str r0,[r11],#16 - eor r2,r2,r1 @ rk[6]=rk[2]^rk[5] - str r1,[r11,#-12] - eor r3,r3,r2 @ rk[7]=rk[3]^rk[6] - str r2,[r11,#-8] - subs r12,r12,#1 - str r3,[r11,#-4] - bne .L128_loop - sub r2,r11,#176 - b .Ldone - -.Lnot128: -#if __ARM_ARCH__<7 - ldrb r8,[r12,#19] - ldrb r4,[r12,#18] - ldrb r5,[r12,#17] - ldrb r6,[r12,#16] - orr r8,r8,r4,lsl#8 - ldrb r9,[r12,#23] - orr r8,r8,r5,lsl#16 - ldrb r4,[r12,#22] - orr r8,r8,r6,lsl#24 - ldrb r5,[r12,#21] - ldrb r6,[r12,#20] - orr r9,r9,r4,lsl#8 - orr r9,r9,r5,lsl#16 - str r8,[r11],#8 - orr r9,r9,r6,lsl#24 - str r9,[r11,#-4] -#else - ldr r8,[r12,#16] - ldr r9,[r12,#20] -#ifdef __ARMEL__ - rev r8,r8 - rev r9,r9 -#endif - str r8,[r11],#8 - str r9,[r11,#-4] -#endif - - teq lr,#192 - bne .Lnot192 - mov r12,#12 - str r12,[r11,#240-24] - add r6,r10,#256 @ rcon - mov lr,#255 - mov r12,#8 - -.L192_loop: - and r5,lr,r9,lsr#24 - and r7,lr,r9,lsr#16 - ldrb r5,[r10,r5] - and r8,lr,r9,lsr#8 - ldrb r7,[r10,r7] - and r9,lr,r9 - ldrb r8,[r10,r8] - orr r5,r5,r7,lsl#24 - ldrb r9,[r10,r9] - orr r5,r5,r8,lsl#16 - ldr r4,[r6],#4 @ rcon[i++] - orr r5,r5,r9,lsl#8 - eor r9,r5,r4 - eor r0,r0,r9 @ rk[6]=rk[0]^... - eor r1,r1,r0 @ rk[7]=rk[1]^rk[6] - str r0,[r11],#24 - eor r2,r2,r1 @ rk[8]=rk[2]^rk[7] - str r1,[r11,#-20] - eor r3,r3,r2 @ rk[9]=rk[3]^rk[8] - str r2,[r11,#-16] - subs r12,r12,#1 - str r3,[r11,#-12] - subeq r2,r11,#216 - beq .Ldone - - ldr r7,[r11,#-32] - ldr r8,[r11,#-28] - eor r7,r7,r3 @ rk[10]=rk[4]^rk[9] - eor r9,r8,r7 @ rk[11]=rk[5]^rk[10] - str r7,[r11,#-8] - str r9,[r11,#-4] - b .L192_loop - -.Lnot192: -#if __ARM_ARCH__<7 - ldrb r8,[r12,#27] - ldrb r4,[r12,#26] - ldrb r5,[r12,#25] - ldrb r6,[r12,#24] - orr r8,r8,r4,lsl#8 - ldrb r9,[r12,#31] - orr r8,r8,r5,lsl#16 - ldrb r4,[r12,#30] - orr r8,r8,r6,lsl#24 - ldrb r5,[r12,#29] - ldrb r6,[r12,#28] - orr r9,r9,r4,lsl#8 - orr r9,r9,r5,lsl#16 - str r8,[r11],#8 - orr r9,r9,r6,lsl#24 - str r9,[r11,#-4] -#else - ldr r8,[r12,#24] - ldr r9,[r12,#28] -#ifdef __ARMEL__ - rev r8,r8 - rev r9,r9 -#endif - str r8,[r11],#8 - str r9,[r11,#-4] -#endif - - mov r12,#14 - str r12,[r11,#240-32] - add r6,r10,#256 @ rcon - mov lr,#255 - mov r12,#7 - -.L256_loop: - and r5,lr,r9,lsr#24 - and r7,lr,r9,lsr#16 - ldrb r5,[r10,r5] - and r8,lr,r9,lsr#8 - ldrb r7,[r10,r7] - and r9,lr,r9 - ldrb r8,[r10,r8] - orr r5,r5,r7,lsl#24 - ldrb r9,[r10,r9] - orr r5,r5,r8,lsl#16 - ldr r4,[r6],#4 @ rcon[i++] - orr r5,r5,r9,lsl#8 - eor r9,r5,r4 - eor r0,r0,r9 @ rk[8]=rk[0]^... - eor r1,r1,r0 @ rk[9]=rk[1]^rk[8] - str r0,[r11],#32 - eor r2,r2,r1 @ rk[10]=rk[2]^rk[9] - str r1,[r11,#-28] - eor r3,r3,r2 @ rk[11]=rk[3]^rk[10] - str r2,[r11,#-24] - subs r12,r12,#1 - str r3,[r11,#-20] - subeq r2,r11,#256 - beq .Ldone - - and r5,lr,r3 - and r7,lr,r3,lsr#8 - ldrb r5,[r10,r5] - and r8,lr,r3,lsr#16 - ldrb r7,[r10,r7] - and r9,lr,r3,lsr#24 - ldrb r8,[r10,r8] - orr r5,r5,r7,lsl#8 - ldrb r9,[r10,r9] - orr r5,r5,r8,lsl#16 - ldr r4,[r11,#-48] - orr r5,r5,r9,lsl#24 - - ldr r7,[r11,#-44] - ldr r8,[r11,#-40] - eor r4,r4,r5 @ rk[12]=rk[4]^... - ldr r9,[r11,#-36] - eor r7,r7,r4 @ rk[13]=rk[5]^rk[12] - str r4,[r11,#-16] - eor r8,r8,r7 @ rk[14]=rk[6]^rk[13] - str r7,[r11,#-12] - eor r9,r9,r8 @ rk[15]=rk[7]^rk[14] - str r8,[r11,#-8] - str r9,[r11,#-4] - b .L256_loop - -.Ldone: mov r0,#0 - ldmia sp!,{r4-r12,lr} -.Labrt: tst lr,#1 - moveq pc,lr @ be binary compatible with V4, yet - .word 0xe12fff1e @ interoperable with Thumb ISA:-) -.size private_AES_set_encrypt_key,.-private_AES_set_encrypt_key - -.global private_AES_set_decrypt_key -.type private_AES_set_decrypt_key,%function -.align 5 -private_AES_set_decrypt_key: - str lr,[sp,#-4]! @ push lr -#if 0 - @ kernel does both of these in setkey so optimise this bit out by - @ expecting the key to already have the enc_key work done (see aes_glue.c) - bl _armv4_AES_set_encrypt_key -#else - mov r0,#0 -#endif - teq r0,#0 - ldrne lr,[sp],#4 @ pop lr - bne .Labrt - - stmdb sp!,{r4-r12} - - ldr r12,[r2,#240] @ AES_set_encrypt_key preserves r2, - mov r11,r2 @ which is AES_KEY *key - mov r7,r2 - add r8,r2,r12,lsl#4 - -.Linv: ldr r0,[r7] - ldr r1,[r7,#4] - ldr r2,[r7,#8] - ldr r3,[r7,#12] - ldr r4,[r8] - ldr r5,[r8,#4] - ldr r6,[r8,#8] - ldr r9,[r8,#12] - str r0,[r8],#-16 - str r1,[r8,#16+4] - str r2,[r8,#16+8] - str r3,[r8,#16+12] - str r4,[r7],#16 - str r5,[r7,#-12] - str r6,[r7,#-8] - str r9,[r7,#-4] - teq r7,r8 - bne .Linv - ldr r0,[r11,#16]! @ prefetch tp1 - mov r7,#0x80 - mov r8,#0x1b - orr r7,r7,#0x8000 - orr r8,r8,#0x1b00 - orr r7,r7,r7,lsl#16 - orr r8,r8,r8,lsl#16 - sub r12,r12,#1 - mvn r9,r7 - mov r12,r12,lsl#2 @ (rounds-1)*4 - -.Lmix: and r4,r0,r7 - and r1,r0,r9 - sub r4,r4,r4,lsr#7 - and r4,r4,r8 - eor r1,r4,r1,lsl#1 @ tp2 - - and r4,r1,r7 - and r2,r1,r9 - sub r4,r4,r4,lsr#7 - and r4,r4,r8 - eor r2,r4,r2,lsl#1 @ tp4 - - and r4,r2,r7 - and r3,r2,r9 - sub r4,r4,r4,lsr#7 - and r4,r4,r8 - eor r3,r4,r3,lsl#1 @ tp8 - - eor r4,r1,r2 - eor r5,r0,r3 @ tp9 - eor r4,r4,r3 @ tpe - eor r4,r4,r1,ror#24 - eor r4,r4,r5,ror#24 @ ^= ROTATE(tpb=tp9^tp2,8) - eor r4,r4,r2,ror#16 - eor r4,r4,r5,ror#16 @ ^= ROTATE(tpd=tp9^tp4,16) - eor r4,r4,r5,ror#8 @ ^= ROTATE(tp9,24) - - ldr r0,[r11,#4] @ prefetch tp1 - str r4,[r11],#4 - subs r12,r12,#1 - bne .Lmix - - mov r0,#0 -#if __ARM_ARCH__>=5 - ldmia sp!,{r4-r12,pc} -#else - ldmia sp!,{r4-r12,lr} - tst lr,#1 - moveq pc,lr @ be binary compatible with V4, yet - .word 0xe12fff1e @ interoperable with Thumb ISA:-) -#endif -.size private_AES_set_decrypt_key,.-private_AES_set_decrypt_key - -.type AES_Td,%object -.align 5 -AES_Td: -.word 0x51f4a750, 0x7e416553, 0x1a17a4c3, 0x3a275e96 -.word 0x3bab6bcb, 0x1f9d45f1, 0xacfa58ab, 0x4be30393 -.word 0x2030fa55, 0xad766df6, 0x88cc7691, 0xf5024c25 -.word 0x4fe5d7fc, 0xc52acbd7, 0x26354480, 0xb562a38f -.word 0xdeb15a49, 0x25ba1b67, 0x45ea0e98, 0x5dfec0e1 -.word 0xc32f7502, 0x814cf012, 0x8d4697a3, 0x6bd3f9c6 -.word 0x038f5fe7, 0x15929c95, 0xbf6d7aeb, 0x955259da -.word 0xd4be832d, 0x587421d3, 0x49e06929, 0x8ec9c844 -.word 0x75c2896a, 0xf48e7978, 0x99583e6b, 0x27b971dd -.word 0xbee14fb6, 0xf088ad17, 0xc920ac66, 0x7dce3ab4 -.word 0x63df4a18, 0xe51a3182, 0x97513360, 0x62537f45 -.word 0xb16477e0, 0xbb6bae84, 0xfe81a01c, 0xf9082b94 -.word 0x70486858, 0x8f45fd19, 0x94de6c87, 0x527bf8b7 -.word 0xab73d323, 0x724b02e2, 0xe31f8f57, 0x6655ab2a -.word 0xb2eb2807, 0x2fb5c203, 0x86c57b9a, 0xd33708a5 -.word 0x302887f2, 0x23bfa5b2, 0x02036aba, 0xed16825c -.word 0x8acf1c2b, 0xa779b492, 0xf307f2f0, 0x4e69e2a1 -.word 0x65daf4cd, 0x0605bed5, 0xd134621f, 0xc4a6fe8a -.word 0x342e539d, 0xa2f355a0, 0x058ae132, 0xa4f6eb75 -.word 0x0b83ec39, 0x4060efaa, 0x5e719f06, 0xbd6e1051 -.word 0x3e218af9, 0x96dd063d, 0xdd3e05ae, 0x4de6bd46 -.word 0x91548db5, 0x71c45d05, 0x0406d46f, 0x605015ff -.word 0x1998fb24, 0xd6bde997, 0x894043cc, 0x67d99e77 -.word 0xb0e842bd, 0x07898b88, 0xe7195b38, 0x79c8eedb -.word 0xa17c0a47, 0x7c420fe9, 0xf8841ec9, 0x00000000 -.word 0x09808683, 0x322bed48, 0x1e1170ac, 0x6c5a724e -.word 0xfd0efffb, 0x0f853856, 0x3daed51e, 0x362d3927 -.word 0x0a0fd964, 0x685ca621, 0x9b5b54d1, 0x24362e3a -.word 0x0c0a67b1, 0x9357e70f, 0xb4ee96d2, 0x1b9b919e -.word 0x80c0c54f, 0x61dc20a2, 0x5a774b69, 0x1c121a16 -.word 0xe293ba0a, 0xc0a02ae5, 0x3c22e043, 0x121b171d -.word 0x0e090d0b, 0xf28bc7ad, 0x2db6a8b9, 0x141ea9c8 -.word 0x57f11985, 0xaf75074c, 0xee99ddbb, 0xa37f60fd -.word 0xf701269f, 0x5c72f5bc, 0x44663bc5, 0x5bfb7e34 -.word 0x8b432976, 0xcb23c6dc, 0xb6edfc68, 0xb8e4f163 -.word 0xd731dcca, 0x42638510, 0x13972240, 0x84c61120 -.word 0x854a247d, 0xd2bb3df8, 0xaef93211, 0xc729a16d -.word 0x1d9e2f4b, 0xdcb230f3, 0x0d8652ec, 0x77c1e3d0 -.word 0x2bb3166c, 0xa970b999, 0x119448fa, 0x47e96422 -.word 0xa8fc8cc4, 0xa0f03f1a, 0x567d2cd8, 0x223390ef -.word 0x87494ec7, 0xd938d1c1, 0x8ccaa2fe, 0x98d40b36 -.word 0xa6f581cf, 0xa57ade28, 0xdab78e26, 0x3fadbfa4 -.word 0x2c3a9de4, 0x5078920d, 0x6a5fcc9b, 0x547e4662 -.word 0xf68d13c2, 0x90d8b8e8, 0x2e39f75e, 0x82c3aff5 -.word 0x9f5d80be, 0x69d0937c, 0x6fd52da9, 0xcf2512b3 -.word 0xc8ac993b, 0x10187da7, 0xe89c636e, 0xdb3bbb7b -.word 0xcd267809, 0x6e5918f4, 0xec9ab701, 0x834f9aa8 -.word 0xe6956e65, 0xaaffe67e, 0x21bccf08, 0xef15e8e6 -.word 0xbae79bd9, 0x4a6f36ce, 0xea9f09d4, 0x29b07cd6 -.word 0x31a4b2af, 0x2a3f2331, 0xc6a59430, 0x35a266c0 -.word 0x744ebc37, 0xfc82caa6, 0xe090d0b0, 0x33a7d815 -.word 0xf104984a, 0x41ecdaf7, 0x7fcd500e, 0x1791f62f -.word 0x764dd68d, 0x43efb04d, 0xccaa4d54, 0xe49604df -.word 0x9ed1b5e3, 0x4c6a881b, 0xc12c1fb8, 0x4665517f -.word 0x9d5eea04, 0x018c355d, 0xfa877473, 0xfb0b412e -.word 0xb3671d5a, 0x92dbd252, 0xe9105633, 0x6dd64713 -.word 0x9ad7618c, 0x37a10c7a, 0x59f8148e, 0xeb133c89 -.word 0xcea927ee, 0xb761c935, 0xe11ce5ed, 0x7a47b13c -.word 0x9cd2df59, 0x55f2733f, 0x1814ce79, 0x73c737bf -.word 0x53f7cdea, 0x5ffdaa5b, 0xdf3d6f14, 0x7844db86 -.word 0xcaaff381, 0xb968c43e, 0x3824342c, 0xc2a3405f -.word 0x161dc372, 0xbce2250c, 0x283c498b, 0xff0d9541 -.word 0x39a80171, 0x080cb3de, 0xd8b4e49c, 0x6456c190 -.word 0x7bcb8461, 0xd532b670, 0x486c5c74, 0xd0b85742 -@ Td4[256] -.byte 0x52, 0x09, 0x6a, 0xd5, 0x30, 0x36, 0xa5, 0x38 -.byte 0xbf, 0x40, 0xa3, 0x9e, 0x81, 0xf3, 0xd7, 0xfb -.byte 0x7c, 0xe3, 0x39, 0x82, 0x9b, 0x2f, 0xff, 0x87 -.byte 0x34, 0x8e, 0x43, 0x44, 0xc4, 0xde, 0xe9, 0xcb -.byte 0x54, 0x7b, 0x94, 0x32, 0xa6, 0xc2, 0x23, 0x3d -.byte 0xee, 0x4c, 0x95, 0x0b, 0x42, 0xfa, 0xc3, 0x4e -.byte 0x08, 0x2e, 0xa1, 0x66, 0x28, 0xd9, 0x24, 0xb2 -.byte 0x76, 0x5b, 0xa2, 0x49, 0x6d, 0x8b, 0xd1, 0x25 -.byte 0x72, 0xf8, 0xf6, 0x64, 0x86, 0x68, 0x98, 0x16 -.byte 0xd4, 0xa4, 0x5c, 0xcc, 0x5d, 0x65, 0xb6, 0x92 -.byte 0x6c, 0x70, 0x48, 0x50, 0xfd, 0xed, 0xb9, 0xda -.byte 0x5e, 0x15, 0x46, 0x57, 0xa7, 0x8d, 0x9d, 0x84 -.byte 0x90, 0xd8, 0xab, 0x00, 0x8c, 0xbc, 0xd3, 0x0a -.byte 0xf7, 0xe4, 0x58, 0x05, 0xb8, 0xb3, 0x45, 0x06 -.byte 0xd0, 0x2c, 0x1e, 0x8f, 0xca, 0x3f, 0x0f, 0x02 -.byte 0xc1, 0xaf, 0xbd, 0x03, 0x01, 0x13, 0x8a, 0x6b -.byte 0x3a, 0x91, 0x11, 0x41, 0x4f, 0x67, 0xdc, 0xea -.byte 0x97, 0xf2, 0xcf, 0xce, 0xf0, 0xb4, 0xe6, 0x73 -.byte 0x96, 0xac, 0x74, 0x22, 0xe7, 0xad, 0x35, 0x85 -.byte 0xe2, 0xf9, 0x37, 0xe8, 0x1c, 0x75, 0xdf, 0x6e -.byte 0x47, 0xf1, 0x1a, 0x71, 0x1d, 0x29, 0xc5, 0x89 -.byte 0x6f, 0xb7, 0x62, 0x0e, 0xaa, 0x18, 0xbe, 0x1b -.byte 0xfc, 0x56, 0x3e, 0x4b, 0xc6, 0xd2, 0x79, 0x20 -.byte 0x9a, 0xdb, 0xc0, 0xfe, 0x78, 0xcd, 0x5a, 0xf4 -.byte 0x1f, 0xdd, 0xa8, 0x33, 0x88, 0x07, 0xc7, 0x31 -.byte 0xb1, 0x12, 0x10, 0x59, 0x27, 0x80, 0xec, 0x5f -.byte 0x60, 0x51, 0x7f, 0xa9, 0x19, 0xb5, 0x4a, 0x0d -.byte 0x2d, 0xe5, 0x7a, 0x9f, 0x93, 0xc9, 0x9c, 0xef -.byte 0xa0, 0xe0, 0x3b, 0x4d, 0xae, 0x2a, 0xf5, 0xb0 -.byte 0xc8, 0xeb, 0xbb, 0x3c, 0x83, 0x53, 0x99, 0x61 -.byte 0x17, 0x2b, 0x04, 0x7e, 0xba, 0x77, 0xd6, 0x26 -.byte 0xe1, 0x69, 0x14, 0x63, 0x55, 0x21, 0x0c, 0x7d -.size AES_Td,.-AES_Td - -@ void AES_decrypt(const unsigned char *in, unsigned char *out, -@ const AES_KEY *key) { -.global AES_decrypt -.type AES_decrypt,%function -.align 5 -AES_decrypt: - sub r3,pc,#8 @ AES_decrypt - stmdb sp!,{r1,r4-r12,lr} - mov r12,r0 @ inp - mov r11,r2 - sub r10,r3,#AES_decrypt-AES_Td @ Td -#if __ARM_ARCH__<7 - ldrb r0,[r12,#3] @ load input data in endian-neutral - ldrb r4,[r12,#2] @ manner... - ldrb r5,[r12,#1] - ldrb r6,[r12,#0] - orr r0,r0,r4,lsl#8 - ldrb r1,[r12,#7] - orr r0,r0,r5,lsl#16 - ldrb r4,[r12,#6] - orr r0,r0,r6,lsl#24 - ldrb r5,[r12,#5] - ldrb r6,[r12,#4] - orr r1,r1,r4,lsl#8 - ldrb r2,[r12,#11] - orr r1,r1,r5,lsl#16 - ldrb r4,[r12,#10] - orr r1,r1,r6,lsl#24 - ldrb r5,[r12,#9] - ldrb r6,[r12,#8] - orr r2,r2,r4,lsl#8 - ldrb r3,[r12,#15] - orr r2,r2,r5,lsl#16 - ldrb r4,[r12,#14] - orr r2,r2,r6,lsl#24 - ldrb r5,[r12,#13] - ldrb r6,[r12,#12] - orr r3,r3,r4,lsl#8 - orr r3,r3,r5,lsl#16 - orr r3,r3,r6,lsl#24 -#else - ldr r0,[r12,#0] - ldr r1,[r12,#4] - ldr r2,[r12,#8] - ldr r3,[r12,#12] -#ifdef __ARMEL__ - rev r0,r0 - rev r1,r1 - rev r2,r2 - rev r3,r3 -#endif -#endif - bl _armv4_AES_decrypt - - ldr r12,[sp],#4 @ pop out -#if __ARM_ARCH__>=7 -#ifdef __ARMEL__ - rev r0,r0 - rev r1,r1 - rev r2,r2 - rev r3,r3 -#endif - str r0,[r12,#0] - str r1,[r12,#4] - str r2,[r12,#8] - str r3,[r12,#12] -#else - mov r4,r0,lsr#24 @ write output in endian-neutral - mov r5,r0,lsr#16 @ manner... - mov r6,r0,lsr#8 - strb r4,[r12,#0] - strb r5,[r12,#1] - mov r4,r1,lsr#24 - strb r6,[r12,#2] - mov r5,r1,lsr#16 - strb r0,[r12,#3] - mov r6,r1,lsr#8 - strb r4,[r12,#4] - strb r5,[r12,#5] - mov r4,r2,lsr#24 - strb r6,[r12,#6] - mov r5,r2,lsr#16 - strb r1,[r12,#7] - mov r6,r2,lsr#8 - strb r4,[r12,#8] - strb r5,[r12,#9] - mov r4,r3,lsr#24 - strb r6,[r12,#10] - mov r5,r3,lsr#16 - strb r2,[r12,#11] - mov r6,r3,lsr#8 - strb r4,[r12,#12] - strb r5,[r12,#13] - strb r6,[r12,#14] - strb r3,[r12,#15] -#endif -#if __ARM_ARCH__>=5 - ldmia sp!,{r4-r12,pc} -#else - ldmia sp!,{r4-r12,lr} - tst lr,#1 - moveq pc,lr @ be binary compatible with V4, yet - .word 0xe12fff1e @ interoperable with Thumb ISA:-) -#endif -.size AES_decrypt,.-AES_decrypt - -.type _armv4_AES_decrypt,%function -.align 2 -_armv4_AES_decrypt: - str lr,[sp,#-4]! @ push lr - ldmia r11!,{r4-r7} - eor r0,r0,r4 - ldr r12,[r11,#240-16] - eor r1,r1,r5 - eor r2,r2,r6 - eor r3,r3,r7 - sub r12,r12,#1 - mov lr,#255 - - and r7,lr,r0,lsr#16 - and r8,lr,r0,lsr#8 - and r9,lr,r0 - mov r0,r0,lsr#24 -.Ldec_loop: - ldr r4,[r10,r7,lsl#2] @ Td1[s0>>16] - and r7,lr,r1 @ i0 - ldr r5,[r10,r8,lsl#2] @ Td2[s0>>8] - and r8,lr,r1,lsr#16 - ldr r6,[r10,r9,lsl#2] @ Td3[s0>>0] - and r9,lr,r1,lsr#8 - ldr r0,[r10,r0,lsl#2] @ Td0[s0>>24] - mov r1,r1,lsr#24 - - ldr r7,[r10,r7,lsl#2] @ Td3[s1>>0] - ldr r8,[r10,r8,lsl#2] @ Td1[s1>>16] - ldr r9,[r10,r9,lsl#2] @ Td2[s1>>8] - eor r0,r0,r7,ror#24 - ldr r1,[r10,r1,lsl#2] @ Td0[s1>>24] - and r7,lr,r2,lsr#8 @ i0 - eor r5,r8,r5,ror#8 - and r8,lr,r2 @ i1 - eor r6,r9,r6,ror#8 - and r9,lr,r2,lsr#16 - ldr r7,[r10,r7,lsl#2] @ Td2[s2>>8] - eor r1,r1,r4,ror#8 - ldr r8,[r10,r8,lsl#2] @ Td3[s2>>0] - mov r2,r2,lsr#24 - - ldr r9,[r10,r9,lsl#2] @ Td1[s2>>16] - eor r0,r0,r7,ror#16 - ldr r2,[r10,r2,lsl#2] @ Td0[s2>>24] - and r7,lr,r3,lsr#16 @ i0 - eor r1,r1,r8,ror#24 - and r8,lr,r3,lsr#8 @ i1 - eor r6,r9,r6,ror#8 - and r9,lr,r3 @ i2 - ldr r7,[r10,r7,lsl#2] @ Td1[s3>>16] - eor r2,r2,r5,ror#8 - ldr r8,[r10,r8,lsl#2] @ Td2[s3>>8] - mov r3,r3,lsr#24 - - ldr r9,[r10,r9,lsl#2] @ Td3[s3>>0] - eor r0,r0,r7,ror#8 - ldr r7,[r11],#16 - eor r1,r1,r8,ror#16 - ldr r3,[r10,r3,lsl#2] @ Td0[s3>>24] - eor r2,r2,r9,ror#24 - - ldr r4,[r11,#-12] - eor r0,r0,r7 - ldr r5,[r11,#-8] - eor r3,r3,r6,ror#8 - ldr r6,[r11,#-4] - and r7,lr,r0,lsr#16 - eor r1,r1,r4 - and r8,lr,r0,lsr#8 - eor r2,r2,r5 - and r9,lr,r0 - eor r3,r3,r6 - mov r0,r0,lsr#24 - - subs r12,r12,#1 - bne .Ldec_loop - - add r10,r10,#1024 - - ldr r5,[r10,#0] @ prefetch Td4 - ldr r6,[r10,#32] - ldr r4,[r10,#64] - ldr r5,[r10,#96] - ldr r6,[r10,#128] - ldr r4,[r10,#160] - ldr r5,[r10,#192] - ldr r6,[r10,#224] - - ldrb r0,[r10,r0] @ Td4[s0>>24] - ldrb r4,[r10,r7] @ Td4[s0>>16] - and r7,lr,r1 @ i0 - ldrb r5,[r10,r8] @ Td4[s0>>8] - and r8,lr,r1,lsr#16 - ldrb r6,[r10,r9] @ Td4[s0>>0] - and r9,lr,r1,lsr#8 - - ldrb r7,[r10,r7] @ Td4[s1>>0] - ldrb r1,[r10,r1,lsr#24] @ Td4[s1>>24] - ldrb r8,[r10,r8] @ Td4[s1>>16] - eor r0,r7,r0,lsl#24 - ldrb r9,[r10,r9] @ Td4[s1>>8] - eor r1,r4,r1,lsl#8 - and r7,lr,r2,lsr#8 @ i0 - eor r5,r5,r8,lsl#8 - and r8,lr,r2 @ i1 - ldrb r7,[r10,r7] @ Td4[s2>>8] - eor r6,r6,r9,lsl#8 - ldrb r8,[r10,r8] @ Td4[s2>>0] - and r9,lr,r2,lsr#16 - - ldrb r2,[r10,r2,lsr#24] @ Td4[s2>>24] - eor r0,r0,r7,lsl#8 - ldrb r9,[r10,r9] @ Td4[s2>>16] - eor r1,r8,r1,lsl#16 - and r7,lr,r3,lsr#16 @ i0 - eor r2,r5,r2,lsl#16 - and r8,lr,r3,lsr#8 @ i1 - ldrb r7,[r10,r7] @ Td4[s3>>16] - eor r6,r6,r9,lsl#16 - ldrb r8,[r10,r8] @ Td4[s3>>8] - and r9,lr,r3 @ i2 - - ldrb r9,[r10,r9] @ Td4[s3>>0] - ldrb r3,[r10,r3,lsr#24] @ Td4[s3>>24] - eor r0,r0,r7,lsl#16 - ldr r7,[r11,#0] - eor r1,r1,r8,lsl#8 - ldr r4,[r11,#4] - eor r2,r9,r2,lsl#8 - ldr r5,[r11,#8] - eor r3,r6,r3,lsl#24 - ldr r6,[r11,#12] - - eor r0,r0,r7 - eor r1,r1,r4 - eor r2,r2,r5 - eor r3,r3,r6 - - sub r10,r10,#1024 - ldr pc,[sp],#4 @ pop and return -.size _armv4_AES_decrypt,.-_armv4_AES_decrypt -.asciz "AES for ARMv4, CRYPTOGAMS by " -.align 2 diff --git a/trunk/arch/arm/crypto/aes_glue.c b/trunk/arch/arm/crypto/aes_glue.c deleted file mode 100644 index 59f7877ead6a..000000000000 --- a/trunk/arch/arm/crypto/aes_glue.c +++ /dev/null @@ -1,108 +0,0 @@ -/* - * Glue Code for the asm optimized version of the AES Cipher Algorithm - */ - -#include -#include -#include - -#define AES_MAXNR 14 - -typedef struct { - unsigned int rd_key[4 *(AES_MAXNR + 1)]; - int rounds; -} AES_KEY; - -struct AES_CTX { - AES_KEY enc_key; - AES_KEY dec_key; -}; - -asmlinkage void AES_encrypt(const u8 *in, u8 *out, AES_KEY *ctx); -asmlinkage void AES_decrypt(const u8 *in, u8 *out, AES_KEY *ctx); -asmlinkage int private_AES_set_decrypt_key(const unsigned char *userKey, const int bits, AES_KEY *key); -asmlinkage int private_AES_set_encrypt_key(const unsigned char *userKey, const int bits, AES_KEY *key); - -static void aes_encrypt(struct crypto_tfm *tfm, u8 *dst, const u8 *src) -{ - struct AES_CTX *ctx = crypto_tfm_ctx(tfm); - AES_encrypt(src, dst, &ctx->enc_key); -} - -static void aes_decrypt(struct crypto_tfm *tfm, u8 *dst, const u8 *src) -{ - struct AES_CTX *ctx = crypto_tfm_ctx(tfm); - AES_decrypt(src, dst, &ctx->dec_key); -} - -static int aes_set_key(struct crypto_tfm *tfm, const u8 *in_key, - unsigned int key_len) -{ - struct AES_CTX *ctx = crypto_tfm_ctx(tfm); - - switch (key_len) { - case AES_KEYSIZE_128: - key_len = 128; - break; - case AES_KEYSIZE_192: - key_len = 192; - break; - case AES_KEYSIZE_256: - key_len = 256; - break; - default: - tfm->crt_flags |= CRYPTO_TFM_RES_BAD_KEY_LEN; - return -EINVAL; - } - - if (private_AES_set_encrypt_key(in_key, key_len, &ctx->enc_key) == -1) { - tfm->crt_flags |= CRYPTO_TFM_RES_BAD_KEY_LEN; - return -EINVAL; - } - /* private_AES_set_decrypt_key expects an encryption key as input */ - ctx->dec_key = ctx->enc_key; - if (private_AES_set_decrypt_key(in_key, key_len, &ctx->dec_key) == -1) { - tfm->crt_flags |= CRYPTO_TFM_RES_BAD_KEY_LEN; - return -EINVAL; - } - return 0; -} - -static struct crypto_alg aes_alg = { - .cra_name = "aes", - .cra_driver_name = "aes-asm", - .cra_priority = 200, - .cra_flags = CRYPTO_ALG_TYPE_CIPHER, - .cra_blocksize = AES_BLOCK_SIZE, - .cra_ctxsize = sizeof(struct AES_CTX), - .cra_module = THIS_MODULE, - .cra_list = LIST_HEAD_INIT(aes_alg.cra_list), - .cra_u = { - .cipher = { - .cia_min_keysize = AES_MIN_KEY_SIZE, - .cia_max_keysize = AES_MAX_KEY_SIZE, - .cia_setkey = aes_set_key, - .cia_encrypt = aes_encrypt, - .cia_decrypt = aes_decrypt - } - } -}; - -static int __init aes_init(void) -{ - return crypto_register_alg(&aes_alg); -} - -static void __exit aes_fini(void) -{ - crypto_unregister_alg(&aes_alg); -} - -module_init(aes_init); -module_exit(aes_fini); - -MODULE_DESCRIPTION("Rijndael (AES) Cipher Algorithm (ASM)"); -MODULE_LICENSE("GPL"); -MODULE_ALIAS("aes"); -MODULE_ALIAS("aes-asm"); -MODULE_AUTHOR("David McCullough "); diff --git a/trunk/arch/arm/crypto/sha1-armv4-large.S b/trunk/arch/arm/crypto/sha1-armv4-large.S deleted file mode 100644 index 7050ab133b9d..000000000000 --- a/trunk/arch/arm/crypto/sha1-armv4-large.S +++ /dev/null @@ -1,503 +0,0 @@ -#define __ARM_ARCH__ __LINUX_ARM_ARCH__ -@ ==================================================================== -@ Written by Andy Polyakov for the OpenSSL -@ project. The module is, however, dual licensed under OpenSSL and -@ CRYPTOGAMS licenses depending on where you obtain it. For further -@ details see http://www.openssl.org/~appro/cryptogams/. -@ ==================================================================== - -@ sha1_block procedure for ARMv4. -@ -@ January 2007. - -@ Size/performance trade-off -@ ==================================================================== -@ impl size in bytes comp cycles[*] measured performance -@ ==================================================================== -@ thumb 304 3212 4420 -@ armv4-small 392/+29% 1958/+64% 2250/+96% -@ armv4-compact 740/+89% 1552/+26% 1840/+22% -@ armv4-large 1420/+92% 1307/+19% 1370/+34%[***] -@ full unroll ~5100/+260% ~1260/+4% ~1300/+5% -@ ==================================================================== -@ thumb = same as 'small' but in Thumb instructions[**] and -@ with recurring code in two private functions; -@ small = detached Xload/update, loops are folded; -@ compact = detached Xload/update, 5x unroll; -@ large = interleaved Xload/update, 5x unroll; -@ full unroll = interleaved Xload/update, full unroll, estimated[!]; -@ -@ [*] Manually counted instructions in "grand" loop body. Measured -@ performance is affected by prologue and epilogue overhead, -@ i-cache availability, branch penalties, etc. -@ [**] While each Thumb instruction is twice smaller, they are not as -@ diverse as ARM ones: e.g., there are only two arithmetic -@ instructions with 3 arguments, no [fixed] rotate, addressing -@ modes are limited. As result it takes more instructions to do -@ the same job in Thumb, therefore the code is never twice as -@ small and always slower. -@ [***] which is also ~35% better than compiler generated code. Dual- -@ issue Cortex A8 core was measured to process input block in -@ ~990 cycles. - -@ August 2010. -@ -@ Rescheduling for dual-issue pipeline resulted in 13% improvement on -@ Cortex A8 core and in absolute terms ~870 cycles per input block -@ [or 13.6 cycles per byte]. - -@ February 2011. -@ -@ Profiler-assisted and platform-specific optimization resulted in 10% -@ improvement on Cortex A8 core and 12.2 cycles per byte. - -.text - -.global sha1_block_data_order -.type sha1_block_data_order,%function - -.align 2 -sha1_block_data_order: - stmdb sp!,{r4-r12,lr} - add r2,r1,r2,lsl#6 @ r2 to point at the end of r1 - ldmia r0,{r3,r4,r5,r6,r7} -.Lloop: - ldr r8,.LK_00_19 - mov r14,sp - sub sp,sp,#15*4 - mov r5,r5,ror#30 - mov r6,r6,ror#30 - mov r7,r7,ror#30 @ [6] -.L_00_15: -#if __ARM_ARCH__<7 - ldrb r10,[r1,#2] - ldrb r9,[r1,#3] - ldrb r11,[r1,#1] - add r7,r8,r7,ror#2 @ E+=K_00_19 - ldrb r12,[r1],#4 - orr r9,r9,r10,lsl#8 - eor r10,r5,r6 @ F_xx_xx - orr r9,r9,r11,lsl#16 - add r7,r7,r3,ror#27 @ E+=ROR(A,27) - orr r9,r9,r12,lsl#24 -#else - ldr r9,[r1],#4 @ handles unaligned - add r7,r8,r7,ror#2 @ E+=K_00_19 - eor r10,r5,r6 @ F_xx_xx - add r7,r7,r3,ror#27 @ E+=ROR(A,27) -#ifdef __ARMEL__ - rev r9,r9 @ byte swap -#endif -#endif - and r10,r4,r10,ror#2 - add r7,r7,r9 @ E+=X[i] - eor r10,r10,r6,ror#2 @ F_00_19(B,C,D) - str r9,[r14,#-4]! - add r7,r7,r10 @ E+=F_00_19(B,C,D) -#if __ARM_ARCH__<7 - ldrb r10,[r1,#2] - ldrb r9,[r1,#3] - ldrb r11,[r1,#1] - add r6,r8,r6,ror#2 @ E+=K_00_19 - ldrb r12,[r1],#4 - orr r9,r9,r10,lsl#8 - eor r10,r4,r5 @ F_xx_xx - orr r9,r9,r11,lsl#16 - add r6,r6,r7,ror#27 @ E+=ROR(A,27) - orr r9,r9,r12,lsl#24 -#else - ldr r9,[r1],#4 @ handles unaligned - add r6,r8,r6,ror#2 @ E+=K_00_19 - eor r10,r4,r5 @ F_xx_xx - add r6,r6,r7,ror#27 @ E+=ROR(A,27) -#ifdef __ARMEL__ - rev r9,r9 @ byte swap -#endif -#endif - and r10,r3,r10,ror#2 - add r6,r6,r9 @ E+=X[i] - eor r10,r10,r5,ror#2 @ F_00_19(B,C,D) - str r9,[r14,#-4]! - add r6,r6,r10 @ E+=F_00_19(B,C,D) -#if __ARM_ARCH__<7 - ldrb r10,[r1,#2] - ldrb r9,[r1,#3] - ldrb r11,[r1,#1] - add r5,r8,r5,ror#2 @ E+=K_00_19 - ldrb r12,[r1],#4 - orr r9,r9,r10,lsl#8 - eor r10,r3,r4 @ F_xx_xx - orr r9,r9,r11,lsl#16 - add r5,r5,r6,ror#27 @ E+=ROR(A,27) - orr r9,r9,r12,lsl#24 -#else - ldr r9,[r1],#4 @ handles unaligned - add r5,r8,r5,ror#2 @ E+=K_00_19 - eor r10,r3,r4 @ F_xx_xx - add r5,r5,r6,ror#27 @ E+=ROR(A,27) -#ifdef __ARMEL__ - rev r9,r9 @ byte swap -#endif -#endif - and r10,r7,r10,ror#2 - add r5,r5,r9 @ E+=X[i] - eor r10,r10,r4,ror#2 @ F_00_19(B,C,D) - str r9,[r14,#-4]! - add r5,r5,r10 @ E+=F_00_19(B,C,D) -#if __ARM_ARCH__<7 - ldrb r10,[r1,#2] - ldrb r9,[r1,#3] - ldrb r11,[r1,#1] - add r4,r8,r4,ror#2 @ E+=K_00_19 - ldrb r12,[r1],#4 - orr r9,r9,r10,lsl#8 - eor r10,r7,r3 @ F_xx_xx - orr r9,r9,r11,lsl#16 - add r4,r4,r5,ror#27 @ E+=ROR(A,27) - orr r9,r9,r12,lsl#24 -#else - ldr r9,[r1],#4 @ handles unaligned - add r4,r8,r4,ror#2 @ E+=K_00_19 - eor r10,r7,r3 @ F_xx_xx - add r4,r4,r5,ror#27 @ E+=ROR(A,27) -#ifdef __ARMEL__ - rev r9,r9 @ byte swap -#endif -#endif - and r10,r6,r10,ror#2 - add r4,r4,r9 @ E+=X[i] - eor r10,r10,r3,ror#2 @ F_00_19(B,C,D) - str r9,[r14,#-4]! - add r4,r4,r10 @ E+=F_00_19(B,C,D) -#if __ARM_ARCH__<7 - ldrb r10,[r1,#2] - ldrb r9,[r1,#3] - ldrb r11,[r1,#1] - add r3,r8,r3,ror#2 @ E+=K_00_19 - ldrb r12,[r1],#4 - orr r9,r9,r10,lsl#8 - eor r10,r6,r7 @ F_xx_xx - orr r9,r9,r11,lsl#16 - add r3,r3,r4,ror#27 @ E+=ROR(A,27) - orr r9,r9,r12,lsl#24 -#else - ldr r9,[r1],#4 @ handles unaligned - add r3,r8,r3,ror#2 @ E+=K_00_19 - eor r10,r6,r7 @ F_xx_xx - add r3,r3,r4,ror#27 @ E+=ROR(A,27) -#ifdef __ARMEL__ - rev r9,r9 @ byte swap -#endif -#endif - and r10,r5,r10,ror#2 - add r3,r3,r9 @ E+=X[i] - eor r10,r10,r7,ror#2 @ F_00_19(B,C,D) - str r9,[r14,#-4]! - add r3,r3,r10 @ E+=F_00_19(B,C,D) - teq r14,sp - bne .L_00_15 @ [((11+4)*5+2)*3] -#if __ARM_ARCH__<7 - ldrb r10,[r1,#2] - ldrb r9,[r1,#3] - ldrb r11,[r1,#1] - add r7,r8,r7,ror#2 @ E+=K_00_19 - ldrb r12,[r1],#4 - orr r9,r9,r10,lsl#8 - eor r10,r5,r6 @ F_xx_xx - orr r9,r9,r11,lsl#16 - add r7,r7,r3,ror#27 @ E+=ROR(A,27) - orr r9,r9,r12,lsl#24 -#else - ldr r9,[r1],#4 @ handles unaligned - add r7,r8,r7,ror#2 @ E+=K_00_19 - eor r10,r5,r6 @ F_xx_xx - add r7,r7,r3,ror#27 @ E+=ROR(A,27) -#ifdef __ARMEL__ - rev r9,r9 @ byte swap -#endif -#endif - and r10,r4,r10,ror#2 - add r7,r7,r9 @ E+=X[i] - eor r10,r10,r6,ror#2 @ F_00_19(B,C,D) - str r9,[r14,#-4]! - add r7,r7,r10 @ E+=F_00_19(B,C,D) - ldr r9,[r14,#15*4] - ldr r10,[r14,#13*4] - ldr r11,[r14,#7*4] - add r6,r8,r6,ror#2 @ E+=K_xx_xx - ldr r12,[r14,#2*4] - eor r9,r9,r10 - eor r11,r11,r12 @ 1 cycle stall - eor r10,r4,r5 @ F_xx_xx - mov r9,r9,ror#31 - add r6,r6,r7,ror#27 @ E+=ROR(A,27) - eor r9,r9,r11,ror#31 - str r9,[r14,#-4]! - and r10,r3,r10,ror#2 @ F_xx_xx - @ F_xx_xx - add r6,r6,r9 @ E+=X[i] - eor r10,r10,r5,ror#2 @ F_00_19(B,C,D) - add r6,r6,r10 @ E+=F_00_19(B,C,D) - ldr r9,[r14,#15*4] - ldr r10,[r14,#13*4] - ldr r11,[r14,#7*4] - add r5,r8,r5,ror#2 @ E+=K_xx_xx - ldr r12,[r14,#2*4] - eor r9,r9,r10 - eor r11,r11,r12 @ 1 cycle stall - eor r10,r3,r4 @ F_xx_xx - mov r9,r9,ror#31 - add r5,r5,r6,ror#27 @ E+=ROR(A,27) - eor r9,r9,r11,ror#31 - str r9,[r14,#-4]! - and r10,r7,r10,ror#2 @ F_xx_xx - @ F_xx_xx - add r5,r5,r9 @ E+=X[i] - eor r10,r10,r4,ror#2 @ F_00_19(B,C,D) - add r5,r5,r10 @ E+=F_00_19(B,C,D) - ldr r9,[r14,#15*4] - ldr r10,[r14,#13*4] - ldr r11,[r14,#7*4] - add r4,r8,r4,ror#2 @ E+=K_xx_xx - ldr r12,[r14,#2*4] - eor r9,r9,r10 - eor r11,r11,r12 @ 1 cycle stall - eor r10,r7,r3 @ F_xx_xx - mov r9,r9,ror#31 - add r4,r4,r5,ror#27 @ E+=ROR(A,27) - eor r9,r9,r11,ror#31 - str r9,[r14,#-4]! - and r10,r6,r10,ror#2 @ F_xx_xx - @ F_xx_xx - add r4,r4,r9 @ E+=X[i] - eor r10,r10,r3,ror#2 @ F_00_19(B,C,D) - add r4,r4,r10 @ E+=F_00_19(B,C,D) - ldr r9,[r14,#15*4] - ldr r10,[r14,#13*4] - ldr r11,[r14,#7*4] - add r3,r8,r3,ror#2 @ E+=K_xx_xx - ldr r12,[r14,#2*4] - eor r9,r9,r10 - eor r11,r11,r12 @ 1 cycle stall - eor r10,r6,r7 @ F_xx_xx - mov r9,r9,ror#31 - add r3,r3,r4,ror#27 @ E+=ROR(A,27) - eor r9,r9,r11,ror#31 - str r9,[r14,#-4]! - and r10,r5,r10,ror#2 @ F_xx_xx - @ F_xx_xx - add r3,r3,r9 @ E+=X[i] - eor r10,r10,r7,ror#2 @ F_00_19(B,C,D) - add r3,r3,r10 @ E+=F_00_19(B,C,D) - - ldr r8,.LK_20_39 @ [+15+16*4] - sub sp,sp,#25*4 - cmn sp,#0 @ [+3], clear carry to denote 20_39 -.L_20_39_or_60_79: - ldr r9,[r14,#15*4] - ldr r10,[r14,#13*4] - ldr r11,[r14,#7*4] - add r7,r8,r7,ror#2 @ E+=K_xx_xx - ldr r12,[r14,#2*4] - eor r9,r9,r10 - eor r11,r11,r12 @ 1 cycle stall - eor r10,r5,r6 @ F_xx_xx - mov r9,r9,ror#31 - add r7,r7,r3,ror#27 @ E+=ROR(A,27) - eor r9,r9,r11,ror#31 - str r9,[r14,#-4]! - eor r10,r4,r10,ror#2 @ F_xx_xx - @ F_xx_xx - add r7,r7,r9 @ E+=X[i] - add r7,r7,r10 @ E+=F_20_39(B,C,D) - ldr r9,[r14,#15*4] - ldr r10,[r14,#13*4] - ldr r11,[r14,#7*4] - add r6,r8,r6,ror#2 @ E+=K_xx_xx - ldr r12,[r14,#2*4] - eor r9,r9,r10 - eor r11,r11,r12 @ 1 cycle stall - eor r10,r4,r5 @ F_xx_xx - mov r9,r9,ror#31 - add r6,r6,r7,ror#27 @ E+=ROR(A,27) - eor r9,r9,r11,ror#31 - str r9,[r14,#-4]! - eor r10,r3,r10,ror#2 @ F_xx_xx - @ F_xx_xx - add r6,r6,r9 @ E+=X[i] - add r6,r6,r10 @ E+=F_20_39(B,C,D) - ldr r9,[r14,#15*4] - ldr r10,[r14,#13*4] - ldr r11,[r14,#7*4] - add r5,r8,r5,ror#2 @ E+=K_xx_xx - ldr r12,[r14,#2*4] - eor r9,r9,r10 - eor r11,r11,r12 @ 1 cycle stall - eor r10,r3,r4 @ F_xx_xx - mov r9,r9,ror#31 - add r5,r5,r6,ror#27 @ E+=ROR(A,27) - eor r9,r9,r11,ror#31 - str r9,[r14,#-4]! - eor r10,r7,r10,ror#2 @ F_xx_xx - @ F_xx_xx - add r5,r5,r9 @ E+=X[i] - add r5,r5,r10 @ E+=F_20_39(B,C,D) - ldr r9,[r14,#15*4] - ldr r10,[r14,#13*4] - ldr r11,[r14,#7*4] - add r4,r8,r4,ror#2 @ E+=K_xx_xx - ldr r12,[r14,#2*4] - eor r9,r9,r10 - eor r11,r11,r12 @ 1 cycle stall - eor r10,r7,r3 @ F_xx_xx - mov r9,r9,ror#31 - add r4,r4,r5,ror#27 @ E+=ROR(A,27) - eor r9,r9,r11,ror#31 - str r9,[r14,#-4]! - eor r10,r6,r10,ror#2 @ F_xx_xx - @ F_xx_xx - add r4,r4,r9 @ E+=X[i] - add r4,r4,r10 @ E+=F_20_39(B,C,D) - ldr r9,[r14,#15*4] - ldr r10,[r14,#13*4] - ldr r11,[r14,#7*4] - add r3,r8,r3,ror#2 @ E+=K_xx_xx - ldr r12,[r14,#2*4] - eor r9,r9,r10 - eor r11,r11,r12 @ 1 cycle stall - eor r10,r6,r7 @ F_xx_xx - mov r9,r9,ror#31 - add r3,r3,r4,ror#27 @ E+=ROR(A,27) - eor r9,r9,r11,ror#31 - str r9,[r14,#-4]! - eor r10,r5,r10,ror#2 @ F_xx_xx - @ F_xx_xx - add r3,r3,r9 @ E+=X[i] - add r3,r3,r10 @ E+=F_20_39(B,C,D) - teq r14,sp @ preserve carry - bne .L_20_39_or_60_79 @ [+((12+3)*5+2)*4] - bcs .L_done @ [+((12+3)*5+2)*4], spare 300 bytes - - ldr r8,.LK_40_59 - sub sp,sp,#20*4 @ [+2] -.L_40_59: - ldr r9,[r14,#15*4] - ldr r10,[r14,#13*4] - ldr r11,[r14,#7*4] - add r7,r8,r7,ror#2 @ E+=K_xx_xx - ldr r12,[r14,#2*4] - eor r9,r9,r10 - eor r11,r11,r12 @ 1 cycle stall - eor r10,r5,r6 @ F_xx_xx - mov r9,r9,ror#31 - add r7,r7,r3,ror#27 @ E+=ROR(A,27) - eor r9,r9,r11,ror#31 - str r9,[r14,#-4]! - and r10,r4,r10,ror#2 @ F_xx_xx - and r11,r5,r6 @ F_xx_xx - add r7,r7,r9 @ E+=X[i] - add r7,r7,r10 @ E+=F_40_59(B,C,D) - add r7,r7,r11,ror#2 - ldr r9,[r14,#15*4] - ldr r10,[r14,#13*4] - ldr r11,[r14,#7*4] - add r6,r8,r6,ror#2 @ E+=K_xx_xx - ldr r12,[r14,#2*4] - eor r9,r9,r10 - eor r11,r11,r12 @ 1 cycle stall - eor r10,r4,r5 @ F_xx_xx - mov r9,r9,ror#31 - add r6,r6,r7,ror#27 @ E+=ROR(A,27) - eor r9,r9,r11,ror#31 - str r9,[r14,#-4]! - and r10,r3,r10,ror#2 @ F_xx_xx - and r11,r4,r5 @ F_xx_xx - add r6,r6,r9 @ E+=X[i] - add r6,r6,r10 @ E+=F_40_59(B,C,D) - add r6,r6,r11,ror#2 - ldr r9,[r14,#15*4] - ldr r10,[r14,#13*4] - ldr r11,[r14,#7*4] - add r5,r8,r5,ror#2 @ E+=K_xx_xx - ldr r12,[r14,#2*4] - eor r9,r9,r10 - eor r11,r11,r12 @ 1 cycle stall - eor r10,r3,r4 @ F_xx_xx - mov r9,r9,ror#31 - add r5,r5,r6,ror#27 @ E+=ROR(A,27) - eor r9,r9,r11,ror#31 - str r9,[r14,#-4]! - and r10,r7,r10,ror#2 @ F_xx_xx - and r11,r3,r4 @ F_xx_xx - add r5,r5,r9 @ E+=X[i] - add r5,r5,r10 @ E+=F_40_59(B,C,D) - add r5,r5,r11,ror#2 - ldr r9,[r14,#15*4] - ldr r10,[r14,#13*4] - ldr r11,[r14,#7*4] - add r4,r8,r4,ror#2 @ E+=K_xx_xx - ldr r12,[r14,#2*4] - eor r9,r9,r10 - eor r11,r11,r12 @ 1 cycle stall - eor r10,r7,r3 @ F_xx_xx - mov r9,r9,ror#31 - add r4,r4,r5,ror#27 @ E+=ROR(A,27) - eor r9,r9,r11,ror#31 - str r9,[r14,#-4]! - and r10,r6,r10,ror#2 @ F_xx_xx - and r11,r7,r3 @ F_xx_xx - add r4,r4,r9 @ E+=X[i] - add r4,r4,r10 @ E+=F_40_59(B,C,D) - add r4,r4,r11,ror#2 - ldr r9,[r14,#15*4] - ldr r10,[r14,#13*4] - ldr r11,[r14,#7*4] - add r3,r8,r3,ror#2 @ E+=K_xx_xx - ldr r12,[r14,#2*4] - eor r9,r9,r10 - eor r11,r11,r12 @ 1 cycle stall - eor r10,r6,r7 @ F_xx_xx - mov r9,r9,ror#31 - add r3,r3,r4,ror#27 @ E+=ROR(A,27) - eor r9,r9,r11,ror#31 - str r9,[r14,#-4]! - and r10,r5,r10,ror#2 @ F_xx_xx - and r11,r6,r7 @ F_xx_xx - add r3,r3,r9 @ E+=X[i] - add r3,r3,r10 @ E+=F_40_59(B,C,D) - add r3,r3,r11,ror#2 - teq r14,sp - bne .L_40_59 @ [+((12+5)*5+2)*4] - - ldr r8,.LK_60_79 - sub sp,sp,#20*4 - cmp sp,#0 @ set carry to denote 60_79 - b .L_20_39_or_60_79 @ [+4], spare 300 bytes -.L_done: - add sp,sp,#80*4 @ "deallocate" stack frame - ldmia r0,{r8,r9,r10,r11,r12} - add r3,r8,r3 - add r4,r9,r4 - add r5,r10,r5,ror#2 - add r6,r11,r6,ror#2 - add r7,r12,r7,ror#2 - stmia r0,{r3,r4,r5,r6,r7} - teq r1,r2 - bne .Lloop @ [+18], total 1307 - -#if __ARM_ARCH__>=5 - ldmia sp!,{r4-r12,pc} -#else - ldmia sp!,{r4-r12,lr} - tst lr,#1 - moveq pc,lr @ be binary compatible with V4, yet - .word 0xe12fff1e @ interoperable with Thumb ISA:-) -#endif -.align 2 -.LK_00_19: .word 0x5a827999 -.LK_20_39: .word 0x6ed9eba1 -.LK_40_59: .word 0x8f1bbcdc -.LK_60_79: .word 0xca62c1d6 -.size sha1_block_data_order,.-sha1_block_data_order -.asciz "SHA1 block transform for ARMv4, CRYPTOGAMS by " -.align 2 diff --git a/trunk/arch/arm/crypto/sha1_glue.c b/trunk/arch/arm/crypto/sha1_glue.c deleted file mode 100644 index 76cd976230bc..000000000000 --- a/trunk/arch/arm/crypto/sha1_glue.c +++ /dev/null @@ -1,179 +0,0 @@ -/* - * Cryptographic API. - * Glue code for the SHA1 Secure Hash Algorithm assembler implementation - * - * This file is based on sha1_generic.c and sha1_ssse3_glue.c - * - * Copyright (c) Alan Smithee. - * Copyright (c) Andrew McDonald - * Copyright (c) Jean-Francois Dive - * Copyright (c) Mathias Krause - * - * 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 -#include -#include -#include -#include -#include -#include - -struct SHA1_CTX { - uint32_t h0,h1,h2,h3,h4; - u64 count; - u8 data[SHA1_BLOCK_SIZE]; -}; - -asmlinkage void sha1_block_data_order(struct SHA1_CTX *digest, - const unsigned char *data, unsigned int rounds); - - -static int sha1_init(struct shash_desc *desc) -{ - struct SHA1_CTX *sctx = shash_desc_ctx(desc); - memset(sctx, 0, sizeof(*sctx)); - sctx->h0 = SHA1_H0; - sctx->h1 = SHA1_H1; - sctx->h2 = SHA1_H2; - sctx->h3 = SHA1_H3; - sctx->h4 = SHA1_H4; - return 0; -} - - -static int __sha1_update(struct SHA1_CTX *sctx, const u8 *data, - unsigned int len, unsigned int partial) -{ - unsigned int done = 0; - - sctx->count += len; - - if (partial) { - done = SHA1_BLOCK_SIZE - partial; - memcpy(sctx->data + partial, data, done); - sha1_block_data_order(sctx, sctx->data, 1); - } - - if (len - done >= SHA1_BLOCK_SIZE) { - const unsigned int rounds = (len - done) / SHA1_BLOCK_SIZE; - sha1_block_data_order(sctx, data + done, rounds); - done += rounds * SHA1_BLOCK_SIZE; - } - - memcpy(sctx->data, data + done, len - done); - return 0; -} - - -static int sha1_update(struct shash_desc *desc, const u8 *data, - unsigned int len) -{ - struct SHA1_CTX *sctx = shash_desc_ctx(desc); - unsigned int partial = sctx->count % SHA1_BLOCK_SIZE; - int res; - - /* Handle the fast case right here */ - if (partial + len < SHA1_BLOCK_SIZE) { - sctx->count += len; - memcpy(sctx->data + partial, data, len); - return 0; - } - res = __sha1_update(sctx, data, len, partial); - return res; -} - - -/* Add padding and return the message digest. */ -static int sha1_final(struct shash_desc *desc, u8 *out) -{ - struct SHA1_CTX *sctx = shash_desc_ctx(desc); - unsigned int i, index, padlen; - __be32 *dst = (__be32 *)out; - __be64 bits; - static const u8 padding[SHA1_BLOCK_SIZE] = { 0x80, }; - - bits = cpu_to_be64(sctx->count << 3); - - /* Pad out to 56 mod 64 and append length */ - index = sctx->count % SHA1_BLOCK_SIZE; - padlen = (index < 56) ? (56 - index) : ((SHA1_BLOCK_SIZE+56) - index); - /* We need to fill a whole block for __sha1_update() */ - if (padlen <= 56) { - sctx->count += padlen; - memcpy(sctx->data + index, padding, padlen); - } else { - __sha1_update(sctx, padding, padlen, index); - } - __sha1_update(sctx, (const u8 *)&bits, sizeof(bits), 56); - - /* Store state in digest */ - for (i = 0; i < 5; i++) - dst[i] = cpu_to_be32(((u32 *)sctx)[i]); - - /* Wipe context */ - memset(sctx, 0, sizeof(*sctx)); - return 0; -} - - -static int sha1_export(struct shash_desc *desc, void *out) -{ - struct SHA1_CTX *sctx = shash_desc_ctx(desc); - memcpy(out, sctx, sizeof(*sctx)); - return 0; -} - - -static int sha1_import(struct shash_desc *desc, const void *in) -{ - struct SHA1_CTX *sctx = shash_desc_ctx(desc); - memcpy(sctx, in, sizeof(*sctx)); - return 0; -} - - -static struct shash_alg alg = { - .digestsize = SHA1_DIGEST_SIZE, - .init = sha1_init, - .update = sha1_update, - .final = sha1_final, - .export = sha1_export, - .import = sha1_import, - .descsize = sizeof(struct SHA1_CTX), - .statesize = sizeof(struct SHA1_CTX), - .base = { - .cra_name = "sha1", - .cra_driver_name= "sha1-asm", - .cra_priority = 150, - .cra_flags = CRYPTO_ALG_TYPE_SHASH, - .cra_blocksize = SHA1_BLOCK_SIZE, - .cra_module = THIS_MODULE, - } -}; - - -static int __init sha1_mod_init(void) -{ - return crypto_register_shash(&alg); -} - - -static void __exit sha1_mod_fini(void) -{ - crypto_unregister_shash(&alg); -} - - -module_init(sha1_mod_init); -module_exit(sha1_mod_fini); - -MODULE_LICENSE("GPL"); -MODULE_DESCRIPTION("SHA1 Secure Hash Algorithm (ARM)"); -MODULE_ALIAS("sha1"); -MODULE_AUTHOR("David McCullough "); diff --git a/trunk/arch/arm/include/asm/hypervisor.h b/trunk/arch/arm/include/asm/hypervisor.h deleted file mode 100644 index b90d9e523d6f..000000000000 --- a/trunk/arch/arm/include/asm/hypervisor.h +++ /dev/null @@ -1,6 +0,0 @@ -#ifndef _ASM_ARM_HYPERVISOR_H -#define _ASM_ARM_HYPERVISOR_H - -#include - -#endif diff --git a/trunk/arch/arm/include/asm/sync_bitops.h b/trunk/arch/arm/include/asm/sync_bitops.h deleted file mode 100644 index 63479eecbf76..000000000000 --- a/trunk/arch/arm/include/asm/sync_bitops.h +++ /dev/null @@ -1,27 +0,0 @@ -#ifndef __ASM_SYNC_BITOPS_H__ -#define __ASM_SYNC_BITOPS_H__ - -#include -#include - -/* sync_bitops functions are equivalent to the SMP implementation of the - * original functions, independently from CONFIG_SMP being defined. - * - * We need them because _set_bit etc are not SMP safe if !CONFIG_SMP. But - * under Xen you might be communicating with a completely external entity - * who might be on another CPU (e.g. two uniprocessor guests communicating - * via event channels and grant tables). So we need a variant of the bit - * ops which are SMP safe even on a UP kernel. - */ - -#define sync_set_bit(nr, p) _set_bit(nr, p) -#define sync_clear_bit(nr, p) _clear_bit(nr, p) -#define sync_change_bit(nr, p) _change_bit(nr, p) -#define sync_test_and_set_bit(nr, p) _test_and_set_bit(nr, p) -#define sync_test_and_clear_bit(nr, p) _test_and_clear_bit(nr, p) -#define sync_test_and_change_bit(nr, p) _test_and_change_bit(nr, p) -#define sync_test_bit(nr, addr) test_bit(nr, addr) -#define sync_cmpxchg cmpxchg - - -#endif diff --git a/trunk/arch/arm/include/asm/xen/events.h b/trunk/arch/arm/include/asm/xen/events.h deleted file mode 100644 index 94b4e9020b02..000000000000 --- a/trunk/arch/arm/include/asm/xen/events.h +++ /dev/null @@ -1,18 +0,0 @@ -#ifndef _ASM_ARM_XEN_EVENTS_H -#define _ASM_ARM_XEN_EVENTS_H - -#include - -enum ipi_vector { - XEN_PLACEHOLDER_VECTOR, - - /* Xen IPIs go here */ - XEN_NR_IPIS, -}; - -static inline int xen_irqs_disabled(struct pt_regs *regs) -{ - return raw_irqs_disabled_flags(regs->ARM_cpsr); -} - -#endif /* _ASM_ARM_XEN_EVENTS_H */ diff --git a/trunk/arch/arm/include/asm/xen/hypercall.h b/trunk/arch/arm/include/asm/xen/hypercall.h deleted file mode 100644 index 8a823253d775..000000000000 --- a/trunk/arch/arm/include/asm/xen/hypercall.h +++ /dev/null @@ -1,69 +0,0 @@ -/****************************************************************************** - * hypercall.h - * - * Linux-specific hypervisor handling. - * - * Stefano Stabellini , Citrix, 2012 - * - * 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; or, when distributed - * separately from the Linux kernel or incorporated into other - * software packages, subject to the following license: - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this source file (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. - */ - -#ifndef _ASM_ARM_XEN_HYPERCALL_H -#define _ASM_ARM_XEN_HYPERCALL_H - -#include - -long privcmd_call(unsigned call, unsigned long a1, - unsigned long a2, unsigned long a3, - unsigned long a4, unsigned long a5); -int HYPERVISOR_xen_version(int cmd, void *arg); -int HYPERVISOR_console_io(int cmd, int count, char *str); -int HYPERVISOR_grant_table_op(unsigned int cmd, void *uop, unsigned int count); -int HYPERVISOR_sched_op(int cmd, void *arg); -int HYPERVISOR_event_channel_op(int cmd, void *arg); -unsigned long HYPERVISOR_hvm_op(int op, void *arg); -int HYPERVISOR_memory_op(unsigned int cmd, void *arg); -int HYPERVISOR_physdev_op(int cmd, void *arg); - -static inline void -MULTI_update_va_mapping(struct multicall_entry *mcl, unsigned long va, - unsigned int new_val, unsigned long flags) -{ - BUG(); -} - -static inline void -MULTI_mmu_update(struct multicall_entry *mcl, struct mmu_update *req, - int count, int *success_count, domid_t domid) -{ - BUG(); -} - -static inline int -HYPERVISOR_multicall(void *call_list, int nr_calls) -{ - BUG(); -} -#endif /* _ASM_ARM_XEN_HYPERCALL_H */ diff --git a/trunk/arch/arm/include/asm/xen/hypervisor.h b/trunk/arch/arm/include/asm/xen/hypervisor.h deleted file mode 100644 index d7ab99a0c9eb..000000000000 --- a/trunk/arch/arm/include/asm/xen/hypervisor.h +++ /dev/null @@ -1,19 +0,0 @@ -#ifndef _ASM_ARM_XEN_HYPERVISOR_H -#define _ASM_ARM_XEN_HYPERVISOR_H - -extern struct shared_info *HYPERVISOR_shared_info; -extern struct start_info *xen_start_info; - -/* Lazy mode for batching updates / context switch */ -enum paravirt_lazy_mode { - PARAVIRT_LAZY_NONE, - PARAVIRT_LAZY_MMU, - PARAVIRT_LAZY_CPU, -}; - -static inline enum paravirt_lazy_mode paravirt_get_lazy_mode(void) -{ - return PARAVIRT_LAZY_NONE; -} - -#endif /* _ASM_ARM_XEN_HYPERVISOR_H */ diff --git a/trunk/arch/arm/include/asm/xen/interface.h b/trunk/arch/arm/include/asm/xen/interface.h deleted file mode 100644 index ae05e56dd17d..000000000000 --- a/trunk/arch/arm/include/asm/xen/interface.h +++ /dev/null @@ -1,73 +0,0 @@ -/****************************************************************************** - * Guest OS interface to ARM Xen. - * - * Stefano Stabellini , Citrix, 2012 - */ - -#ifndef _ASM_ARM_XEN_INTERFACE_H -#define _ASM_ARM_XEN_INTERFACE_H - -#include - -#define uint64_aligned_t uint64_t __attribute__((aligned(8))) - -#define __DEFINE_GUEST_HANDLE(name, type) \ - typedef struct { union { type *p; uint64_aligned_t q; }; } \ - __guest_handle_ ## name - -#define DEFINE_GUEST_HANDLE_STRUCT(name) \ - __DEFINE_GUEST_HANDLE(name, struct name) -#define DEFINE_GUEST_HANDLE(name) __DEFINE_GUEST_HANDLE(name, name) -#define GUEST_HANDLE(name) __guest_handle_ ## name - -#define set_xen_guest_handle(hnd, val) \ - do { \ - if (sizeof(hnd) == 8) \ - *(uint64_t *)&(hnd) = 0; \ - (hnd).p = val; \ - } while (0) - -#ifndef __ASSEMBLY__ -/* Explicitly size integers that represent pfns in the interface with - * Xen so that we can have one ABI that works for 32 and 64 bit guests. */ -typedef uint64_t xen_pfn_t; -typedef uint64_t xen_ulong_t; -/* Guest handles for primitive C types. */ -__DEFINE_GUEST_HANDLE(uchar, unsigned char); -__DEFINE_GUEST_HANDLE(uint, unsigned int); -__DEFINE_GUEST_HANDLE(ulong, unsigned long); -DEFINE_GUEST_HANDLE(char); -DEFINE_GUEST_HANDLE(int); -DEFINE_GUEST_HANDLE(long); -DEFINE_GUEST_HANDLE(void); -DEFINE_GUEST_HANDLE(uint64_t); -DEFINE_GUEST_HANDLE(uint32_t); -DEFINE_GUEST_HANDLE(xen_pfn_t); - -/* Maximum number of virtual CPUs in multi-processor guests. */ -#define MAX_VIRT_CPUS 1 - -struct arch_vcpu_info { }; -struct arch_shared_info { }; - -/* TODO: Move pvclock definitions some place arch independent */ -struct pvclock_vcpu_time_info { - u32 version; - u32 pad0; - u64 tsc_timestamp; - u64 system_time; - u32 tsc_to_system_mul; - s8 tsc_shift; - u8 flags; - u8 pad[2]; -} __attribute__((__packed__)); /* 32 bytes */ - -/* It is OK to have a 12 bytes struct with no padding because it is packed */ -struct pvclock_wall_clock { - u32 version; - u32 sec; - u32 nsec; -} __attribute__((__packed__)); -#endif - -#endif /* _ASM_ARM_XEN_INTERFACE_H */ diff --git a/trunk/arch/arm/include/asm/xen/page.h b/trunk/arch/arm/include/asm/xen/page.h deleted file mode 100644 index 174202318dff..000000000000 --- a/trunk/arch/arm/include/asm/xen/page.h +++ /dev/null @@ -1,82 +0,0 @@ -#ifndef _ASM_ARM_XEN_PAGE_H -#define _ASM_ARM_XEN_PAGE_H - -#include -#include - -#include -#include - -#include - -#define pfn_to_mfn(pfn) (pfn) -#define phys_to_machine_mapping_valid (1) -#define mfn_to_pfn(mfn) (mfn) -#define mfn_to_virt(m) (__va(mfn_to_pfn(m) << PAGE_SHIFT)) - -#define pte_mfn pte_pfn -#define mfn_pte pfn_pte - -/* Xen machine address */ -typedef struct xmaddr { - phys_addr_t maddr; -} xmaddr_t; - -/* Xen pseudo-physical address */ -typedef struct xpaddr { - phys_addr_t paddr; -} xpaddr_t; - -#define XMADDR(x) ((xmaddr_t) { .maddr = (x) }) -#define XPADDR(x) ((xpaddr_t) { .paddr = (x) }) - -static inline xmaddr_t phys_to_machine(xpaddr_t phys) -{ - unsigned offset = phys.paddr & ~PAGE_MASK; - return XMADDR(PFN_PHYS(pfn_to_mfn(PFN_DOWN(phys.paddr))) | offset); -} - -static inline xpaddr_t machine_to_phys(xmaddr_t machine) -{ - unsigned offset = machine.maddr & ~PAGE_MASK; - return XPADDR(PFN_PHYS(mfn_to_pfn(PFN_DOWN(machine.maddr))) | offset); -} -/* VIRT <-> MACHINE conversion */ -#define virt_to_machine(v) (phys_to_machine(XPADDR(__pa(v)))) -#define virt_to_pfn(v) (PFN_DOWN(__pa(v))) -#define virt_to_mfn(v) (pfn_to_mfn(virt_to_pfn(v))) -#define mfn_to_virt(m) (__va(mfn_to_pfn(m) << PAGE_SHIFT)) - -static inline xmaddr_t arbitrary_virt_to_machine(void *vaddr) -{ - /* TODO: assuming it is mapped in the kernel 1:1 */ - return virt_to_machine(vaddr); -} - -/* TODO: this shouldn't be here but it is because the frontend drivers - * are using it (its rolled in headers) even though we won't hit the code path. - * So for right now just punt with this. - */ -static inline pte_t *lookup_address(unsigned long address, unsigned int *level) -{ - BUG(); - return NULL; -} - -static inline int m2p_add_override(unsigned long mfn, struct page *page, - struct gnttab_map_grant_ref *kmap_op) -{ - return 0; -} - -static inline int m2p_remove_override(struct page *page, bool clear_pte) -{ - return 0; -} - -static inline bool set_phys_to_machine(unsigned long pfn, unsigned long mfn) -{ - BUG(); - return false; -} -#endif /* _ASM_ARM_XEN_PAGE_H */ diff --git a/trunk/arch/arm/mach-at91/clock.c b/trunk/arch/arm/mach-at91/clock.c index 33361505c0cd..188c82971ebd 100644 --- a/trunk/arch/arm/mach-at91/clock.c +++ b/trunk/arch/arm/mach-at91/clock.c @@ -625,7 +625,7 @@ static unsigned __init at91_pll_calc(unsigned main_freq, unsigned out_freq) return 0; } -static struct clk *const standard_pmc_clocks[] __initconst = { +static struct clk *const standard_pmc_clocks[] __initdata = { /* four primary clocks */ &clk32k, &main_clk, diff --git a/trunk/arch/arm/mach-davinci/board-tnetv107x-evm.c b/trunk/arch/arm/mach-davinci/board-tnetv107x-evm.c index be3099733b1f..ac4e003ad863 100644 --- a/trunk/arch/arm/mach-davinci/board-tnetv107x-evm.c +++ b/trunk/arch/arm/mach-davinci/board-tnetv107x-evm.c @@ -88,7 +88,7 @@ static struct davinci_mmc_config mmc_config = { .version = MMC_CTLR_VERSION_1, }; -static const short sdio1_pins[] __initconst = { +static const short sdio1_pins[] __initdata = { TNETV107X_SDIO1_CLK_1, TNETV107X_SDIO1_CMD_1, TNETV107X_SDIO1_DATA0_1, TNETV107X_SDIO1_DATA1_1, TNETV107X_SDIO1_DATA2_1, TNETV107X_SDIO1_DATA3_1, @@ -96,12 +96,12 @@ static const short sdio1_pins[] __initconst = { -1 }; -static const short uart1_pins[] __initconst = { +static const short uart1_pins[] __initdata = { TNETV107X_UART1_RD, TNETV107X_UART1_TD, -1 }; -static const short ssp_pins[] __initconst = { +static const short ssp_pins[] __initdata = { TNETV107X_SSP0_0, TNETV107X_SSP0_1, TNETV107X_SSP0_2, TNETV107X_SSP1_0, TNETV107X_SSP1_1, TNETV107X_SSP1_2, TNETV107X_SSP1_3, -1 diff --git a/trunk/arch/arm/mach-davinci/da830.c b/trunk/arch/arm/mach-davinci/da830.c index 510648e0394b..deee5c2da754 100644 --- a/trunk/arch/arm/mach-davinci/da830.c +++ b/trunk/arch/arm/mach-davinci/da830.c @@ -838,7 +838,7 @@ static const struct mux_config da830_pins[] = { #endif }; -const short da830_emif25_pins[] __initconst = { +const short da830_emif25_pins[] __initdata = { DA830_EMA_D_0, DA830_EMA_D_1, DA830_EMA_D_2, DA830_EMA_D_3, DA830_EMA_D_4, DA830_EMA_D_5, DA830_EMA_D_6, DA830_EMA_D_7, DA830_EMA_D_8, DA830_EMA_D_9, DA830_EMA_D_10, DA830_EMA_D_11, @@ -853,19 +853,19 @@ const short da830_emif25_pins[] __initconst = { -1 }; -const short da830_spi0_pins[] __initconst = { +const short da830_spi0_pins[] __initdata = { DA830_SPI0_SOMI_0, DA830_SPI0_SIMO_0, DA830_SPI0_CLK, DA830_NSPI0_ENA, DA830_NSPI0_SCS_0, -1 }; -const short da830_spi1_pins[] __initconst = { +const short da830_spi1_pins[] __initdata = { DA830_SPI1_SOMI_0, DA830_SPI1_SIMO_0, DA830_SPI1_CLK, DA830_NSPI1_ENA, DA830_NSPI1_SCS_0, -1 }; -const short da830_mmc_sd_pins[] __initconst = { +const short da830_mmc_sd_pins[] __initdata = { DA830_MMCSD_DAT_0, DA830_MMCSD_DAT_1, DA830_MMCSD_DAT_2, DA830_MMCSD_DAT_3, DA830_MMCSD_DAT_4, DA830_MMCSD_DAT_5, DA830_MMCSD_DAT_6, DA830_MMCSD_DAT_7, DA830_MMCSD_CLK, @@ -873,32 +873,32 @@ const short da830_mmc_sd_pins[] __initconst = { -1 }; -const short da830_uart0_pins[] __initconst = { +const short da830_uart0_pins[] __initdata = { DA830_NUART0_CTS, DA830_NUART0_RTS, DA830_UART0_RXD, DA830_UART0_TXD, -1 }; -const short da830_uart1_pins[] __initconst = { +const short da830_uart1_pins[] __initdata = { DA830_UART1_RXD, DA830_UART1_TXD, -1 }; -const short da830_uart2_pins[] __initconst = { +const short da830_uart2_pins[] __initdata = { DA830_UART2_RXD, DA830_UART2_TXD, -1 }; -const short da830_usb20_pins[] __initconst = { +const short da830_usb20_pins[] __initdata = { DA830_USB0_DRVVBUS, DA830_USB_REFCLKIN, -1 }; -const short da830_usb11_pins[] __initconst = { +const short da830_usb11_pins[] __initdata = { DA830_USB_REFCLKIN, -1 }; -const short da830_uhpi_pins[] __initconst = { +const short da830_uhpi_pins[] __initdata = { DA830_UHPI_HD_0, DA830_UHPI_HD_1, DA830_UHPI_HD_2, DA830_UHPI_HD_3, DA830_UHPI_HD_4, DA830_UHPI_HD_5, DA830_UHPI_HD_6, DA830_UHPI_HD_7, DA830_UHPI_HD_8, DA830_UHPI_HD_9, DA830_UHPI_HD_10, DA830_UHPI_HD_11, @@ -909,14 +909,14 @@ const short da830_uhpi_pins[] __initconst = { -1 }; -const short da830_cpgmac_pins[] __initconst = { +const short da830_cpgmac_pins[] __initdata = { DA830_RMII_TXD_0, DA830_RMII_TXD_1, DA830_RMII_TXEN, DA830_RMII_CRS_DV, DA830_RMII_RXD_0, DA830_RMII_RXD_1, DA830_RMII_RXER, DA830_MDIO_CLK, DA830_MDIO_D, -1 }; -const short da830_emif3c_pins[] __initconst = { +const short da830_emif3c_pins[] __initdata = { DA830_EMB_SDCKE, DA830_EMB_CLK_GLUE, DA830_EMB_CLK, DA830_NEMB_CS_0, DA830_NEMB_CAS, DA830_NEMB_RAS, DA830_NEMB_WE, DA830_EMB_BA_1, DA830_EMB_BA_0, DA830_EMB_A_0, DA830_EMB_A_1, DA830_EMB_A_2, @@ -935,7 +935,7 @@ const short da830_emif3c_pins[] __initconst = { -1 }; -const short da830_mcasp0_pins[] __initconst = { +const short da830_mcasp0_pins[] __initdata = { DA830_AHCLKX0, DA830_ACLKX0, DA830_AFSX0, DA830_AHCLKR0, DA830_ACLKR0, DA830_AFSR0, DA830_AMUTE0, DA830_AXR0_0, DA830_AXR0_1, DA830_AXR0_2, DA830_AXR0_3, @@ -945,7 +945,7 @@ const short da830_mcasp0_pins[] __initconst = { -1 }; -const short da830_mcasp1_pins[] __initconst = { +const short da830_mcasp1_pins[] __initdata = { DA830_AHCLKX1, DA830_ACLKX1, DA830_AFSX1, DA830_AHCLKR1, DA830_ACLKR1, DA830_AFSR1, DA830_AMUTE1, DA830_AXR1_0, DA830_AXR1_1, DA830_AXR1_2, DA830_AXR1_3, @@ -954,24 +954,24 @@ const short da830_mcasp1_pins[] __initconst = { -1 }; -const short da830_mcasp2_pins[] __initconst = { +const short da830_mcasp2_pins[] __initdata = { DA830_AHCLKX2, DA830_ACLKX2, DA830_AFSX2, DA830_AHCLKR2, DA830_ACLKR2, DA830_AFSR2, DA830_AMUTE2, DA830_AXR2_0, DA830_AXR2_1, DA830_AXR2_2, DA830_AXR2_3, -1 }; -const short da830_i2c0_pins[] __initconst = { +const short da830_i2c0_pins[] __initdata = { DA830_I2C0_SDA, DA830_I2C0_SCL, -1 }; -const short da830_i2c1_pins[] __initconst = { +const short da830_i2c1_pins[] __initdata = { DA830_I2C1_SCL, DA830_I2C1_SDA, -1 }; -const short da830_lcdcntl_pins[] __initconst = { +const short da830_lcdcntl_pins[] __initdata = { DA830_LCD_D_0, DA830_LCD_D_1, DA830_LCD_D_2, DA830_LCD_D_3, DA830_LCD_D_4, DA830_LCD_D_5, DA830_LCD_D_6, DA830_LCD_D_7, DA830_LCD_D_8, DA830_LCD_D_9, DA830_LCD_D_10, DA830_LCD_D_11, @@ -981,34 +981,34 @@ const short da830_lcdcntl_pins[] __initconst = { -1 }; -const short da830_pwm_pins[] __initconst = { +const short da830_pwm_pins[] __initdata = { DA830_ECAP0_APWM0, DA830_ECAP1_APWM1, DA830_EPWM0B, DA830_EPWM0A, DA830_EPWMSYNCI, DA830_EPWMSYNC0, DA830_ECAP2_APWM2, DA830_EHRPWMGLUETZ, DA830_EPWM2B, DA830_EPWM2A, DA830_EPWM1B, DA830_EPWM1A, -1 }; -const short da830_ecap0_pins[] __initconst = { +const short da830_ecap0_pins[] __initdata = { DA830_ECAP0_APWM0, -1 }; -const short da830_ecap1_pins[] __initconst = { +const short da830_ecap1_pins[] __initdata = { DA830_ECAP1_APWM1, -1 }; -const short da830_ecap2_pins[] __initconst = { +const short da830_ecap2_pins[] __initdata = { DA830_ECAP2_APWM2, -1 }; -const short da830_eqep0_pins[] __initconst = { +const short da830_eqep0_pins[] __initdata = { DA830_EQEP0I, DA830_EQEP0S, DA830_EQEP0A, DA830_EQEP0B, -1 }; -const short da830_eqep1_pins[] __initconst = { +const short da830_eqep1_pins[] __initdata = { DA830_EQEP1I, DA830_EQEP1S, DA830_EQEP1A, DA830_EQEP1B, -1 }; diff --git a/trunk/arch/arm/mach-davinci/da850.c b/trunk/arch/arm/mach-davinci/da850.c index 6676dee7104e..b44dc844e15e 100644 --- a/trunk/arch/arm/mach-davinci/da850.c +++ b/trunk/arch/arm/mach-davinci/da850.c @@ -576,17 +576,17 @@ static const struct mux_config da850_pins[] = { #endif }; -const short da850_i2c0_pins[] __initconst = { +const short da850_i2c0_pins[] __initdata = { DA850_I2C0_SDA, DA850_I2C0_SCL, -1 }; -const short da850_i2c1_pins[] __initconst = { +const short da850_i2c1_pins[] __initdata = { DA850_I2C1_SCL, DA850_I2C1_SDA, -1 }; -const short da850_lcdcntl_pins[] __initconst = { +const short da850_lcdcntl_pins[] __initdata = { DA850_LCD_D_0, DA850_LCD_D_1, DA850_LCD_D_2, DA850_LCD_D_3, DA850_LCD_D_4, DA850_LCD_D_5, DA850_LCD_D_6, DA850_LCD_D_7, DA850_LCD_D_8, DA850_LCD_D_9, DA850_LCD_D_10, DA850_LCD_D_11, diff --git a/trunk/arch/arm/mach-imx/Kconfig b/trunk/arch/arm/mach-imx/Kconfig index 32197c117afe..3a2042fb9712 100644 --- a/trunk/arch/arm/mach-imx/Kconfig +++ b/trunk/arch/arm/mach-imx/Kconfig @@ -758,7 +758,7 @@ config SOC_IMX6Q select HAVE_IMX_MMDC select HAVE_IMX_SRC select HAVE_SMP - select MFD_SYSCON + select MFD_ANATOP select PINCTRL select PINCTRL_IMX6Q diff --git a/trunk/arch/arm/mach-imx/mach-imx6q.c b/trunk/arch/arm/mach-imx/mach-imx6q.c index 47c91f7185d2..36979d3dfe34 100644 --- a/trunk/arch/arm/mach-imx/mach-imx6q.c +++ b/trunk/arch/arm/mach-imx/mach-imx6q.c @@ -23,9 +23,8 @@ #include #include #include -#include #include -#include +#include #include #include #include @@ -119,7 +118,20 @@ static void __init imx6q_sabrelite_init(void) static void __init imx6q_usb_init(void) { - struct regmap *anatop; + struct device_node *np; + struct platform_device *pdev = NULL; + struct anatop *adata = NULL; + + np = of_find_compatible_node(NULL, NULL, "fsl,imx6q-anatop"); + if (np) + pdev = of_find_device_by_node(np); + if (pdev) + adata = platform_get_drvdata(pdev); + if (!adata) { + if (np) + of_node_put(np); + return; + } #define HW_ANADIG_USB1_CHRG_DETECT 0x000001b0 #define HW_ANADIG_USB2_CHRG_DETECT 0x00000210 @@ -127,21 +139,20 @@ static void __init imx6q_usb_init(void) #define BM_ANADIG_USB_CHRG_DETECT_EN_B 0x00100000 #define BM_ANADIG_USB_CHRG_DETECT_CHK_CHRG_B 0x00080000 - anatop = syscon_regmap_lookup_by_compatible("fsl,imx6q-anatop"); - if (!IS_ERR(anatop)) { - /* - * The external charger detector needs to be disabled, - * or the signal at DP will be poor - */ - regmap_write(anatop, HW_ANADIG_USB1_CHRG_DETECT, - BM_ANADIG_USB_CHRG_DETECT_EN_B - | BM_ANADIG_USB_CHRG_DETECT_CHK_CHRG_B); - regmap_write(anatop, HW_ANADIG_USB2_CHRG_DETECT, - BM_ANADIG_USB_CHRG_DETECT_EN_B | - BM_ANADIG_USB_CHRG_DETECT_CHK_CHRG_B); - } else { - pr_warn("failed to find fsl,imx6q-anatop regmap\n"); - } + /* + * The external charger detector needs to be disabled, + * or the signal at DP will be poor + */ + anatop_write_reg(adata, HW_ANADIG_USB1_CHRG_DETECT, + BM_ANADIG_USB_CHRG_DETECT_EN_B + | BM_ANADIG_USB_CHRG_DETECT_CHK_CHRG_B, + ~0); + anatop_write_reg(adata, HW_ANADIG_USB2_CHRG_DETECT, + BM_ANADIG_USB_CHRG_DETECT_EN_B | + BM_ANADIG_USB_CHRG_DETECT_CHK_CHRG_B, + ~0); + + of_node_put(np); } static void __init imx6q_init_machine(void) diff --git a/trunk/arch/arm/mach-msm/board-qsd8x50.c b/trunk/arch/arm/mach-msm/board-qsd8x50.c index 2448fcf09eb1..a344a373928b 100644 --- a/trunk/arch/arm/mach-msm/board-qsd8x50.c +++ b/trunk/arch/arm/mach-msm/board-qsd8x50.c @@ -37,8 +37,8 @@ #include "devices.h" #include "common.h" -static const resource_size_t qsd8x50_surf_smc91x_base __initconst = 0x70000300; -static const unsigned qsd8x50_surf_smc91x_gpio __initconst = 156; +static const resource_size_t qsd8x50_surf_smc91x_base __initdata = 0x70000300; +static const unsigned qsd8x50_surf_smc91x_gpio __initdata = 156; /* Leave smc91x resources empty here, as we'll fill them in * at run-time: they vary from board to board, and the true diff --git a/trunk/arch/arm/mach-omap2/display.c b/trunk/arch/arm/mach-omap2/display.c index e470c6e50acd..af1ed7d24a1f 100644 --- a/trunk/arch/arm/mach-omap2/display.c +++ b/trunk/arch/arm/mach-omap2/display.c @@ -76,14 +76,14 @@ struct omap_dss_hwmod_data { const int id; }; -static const struct omap_dss_hwmod_data omap2_dss_hwmod_data[] __initconst = { +static const struct omap_dss_hwmod_data omap2_dss_hwmod_data[] __initdata = { { "dss_core", "omapdss_dss", -1 }, { "dss_dispc", "omapdss_dispc", -1 }, { "dss_rfbi", "omapdss_rfbi", -1 }, { "dss_venc", "omapdss_venc", -1 }, }; -static const struct omap_dss_hwmod_data omap3_dss_hwmod_data[] __initconst = { +static const struct omap_dss_hwmod_data omap3_dss_hwmod_data[] __initdata = { { "dss_core", "omapdss_dss", -1 }, { "dss_dispc", "omapdss_dispc", -1 }, { "dss_rfbi", "omapdss_rfbi", -1 }, @@ -91,7 +91,7 @@ static const struct omap_dss_hwmod_data omap3_dss_hwmod_data[] __initconst = { { "dss_dsi1", "omapdss_dsi", 0 }, }; -static const struct omap_dss_hwmod_data omap4_dss_hwmod_data[] __initconst = { +static const struct omap_dss_hwmod_data omap4_dss_hwmod_data[] __initdata = { { "dss_core", "omapdss_dss", -1 }, { "dss_dispc", "omapdss_dispc", -1 }, { "dss_rfbi", "omapdss_rfbi", -1 }, diff --git a/trunk/arch/arm/mach-omap2/usb-host.c b/trunk/arch/arm/mach-omap2/usb-host.c index 3c434498e12e..ac95daaa4702 100644 --- a/trunk/arch/arm/mach-omap2/usb-host.c +++ b/trunk/arch/arm/mach-omap2/usb-host.c @@ -33,12 +33,10 @@ #ifdef CONFIG_MFD_OMAP_USB_HOST #define OMAP_USBHS_DEVICE "usbhs_omap" -#define OMAP_USBTLL_DEVICE "usbhs_tll" #define USBHS_UHH_HWMODNAME "usb_host_hs" #define USBHS_TLL_HWMODNAME "usb_tll_hs" static struct usbhs_omap_platform_data usbhs_data; -static struct usbtll_omap_platform_data usbtll_data; static struct ehci_hcd_omap_platform_data ehci_data; static struct ohci_hcd_omap_platform_data ohci_data; @@ -487,14 +485,13 @@ void __init setup_4430ohci_io_mux(const enum usbhs_omap_port_mode *port_mode) void __init usbhs_init(const struct usbhs_omap_board_data *pdata) { - struct omap_hwmod *uhh_hwm, *tll_hwm; + struct omap_hwmod *oh[2]; struct platform_device *pdev; int bus_id = -1; int i; for (i = 0; i < OMAP3_HS_USB_PORTS; i++) { usbhs_data.port_mode[i] = pdata->port_mode[i]; - usbtll_data.port_mode[i] = pdata->port_mode[i]; ohci_data.port_mode[i] = pdata->port_mode[i]; ehci_data.port_mode[i] = pdata->port_mode[i]; ehci_data.reset_gpio_port[i] = pdata->reset_gpio_port[i]; @@ -513,35 +510,25 @@ void __init usbhs_init(const struct usbhs_omap_board_data *pdata) setup_4430ohci_io_mux(pdata->port_mode); } - uhh_hwm = omap_hwmod_lookup(USBHS_UHH_HWMODNAME); - if (!uhh_hwm) { + oh[0] = omap_hwmod_lookup(USBHS_UHH_HWMODNAME); + if (!oh[0]) { pr_err("Could not look up %s\n", USBHS_UHH_HWMODNAME); return; } - tll_hwm = omap_hwmod_lookup(USBHS_TLL_HWMODNAME); - if (!tll_hwm) { + oh[1] = omap_hwmod_lookup(USBHS_TLL_HWMODNAME); + if (!oh[1]) { pr_err("Could not look up %s\n", USBHS_TLL_HWMODNAME); return; } - pdev = omap_device_build(OMAP_USBTLL_DEVICE, bus_id, tll_hwm, - &usbtll_data, sizeof(usbtll_data), + pdev = omap_device_build_ss(OMAP_USBHS_DEVICE, bus_id, oh, 2, + (void *)&usbhs_data, sizeof(usbhs_data), omap_uhhtll_latency, ARRAY_SIZE(omap_uhhtll_latency), false); if (IS_ERR(pdev)) { - pr_err("Could not build hwmod device %s\n", - USBHS_TLL_HWMODNAME); - return; - } - - pdev = omap_device_build(OMAP_USBHS_DEVICE, bus_id, uhh_hwm, - &usbhs_data, sizeof(usbhs_data), - omap_uhhtll_latency, - ARRAY_SIZE(omap_uhhtll_latency), false); - if (IS_ERR(pdev)) { - pr_err("Could not build hwmod devices %s\n", - USBHS_UHH_HWMODNAME); + pr_err("Could not build hwmod devices %s,%s\n", + USBHS_UHH_HWMODNAME, USBHS_TLL_HWMODNAME); return; } } diff --git a/trunk/arch/arm/mach-u300/i2c.c b/trunk/arch/arm/mach-u300/i2c.c index 96800aa1316d..0d4620ed853c 100644 --- a/trunk/arch/arm/mach-u300/i2c.c +++ b/trunk/arch/arm/mach-u300/i2c.c @@ -9,7 +9,7 @@ */ #include #include -#include +#include #include #include #include diff --git a/trunk/arch/arm/mach-vexpress/v2m.c b/trunk/arch/arm/mach-vexpress/v2m.c index 560e0df728f8..5f6b7d543e55 100644 --- a/trunk/arch/arm/mach-vexpress/v2m.c +++ b/trunk/arch/arm/mach-vexpress/v2m.c @@ -659,7 +659,6 @@ static void __init v2m_dt_init(void) const static char *v2m_dt_match[] __initconst = { "arm,vexpress", - "xen,xenvm", NULL, }; diff --git a/trunk/arch/arm/plat-omap/include/plat/usb.h b/trunk/arch/arm/plat-omap/include/plat/usb.h index 87ee140fefaa..bd20588c356b 100644 --- a/trunk/arch/arm/plat-omap/include/plat/usb.h +++ b/trunk/arch/arm/plat-omap/include/plat/usb.h @@ -4,7 +4,6 @@ #define __ASM_ARCH_OMAP_USB_H #include -#include #include #define OMAP3_HS_USB_PORTS 3 @@ -64,10 +63,6 @@ struct usbhs_omap_platform_data { struct ehci_hcd_omap_platform_data *ehci_data; struct ohci_hcd_omap_platform_data *ohci_data; }; - -struct usbtll_omap_platform_data { - enum usbhs_omap_port_mode port_mode[OMAP3_HS_USB_PORTS]; -}; /*-------------------------------------------------------------------------*/ struct omap_musb_board_data { @@ -86,8 +81,6 @@ enum musb_interface {MUSB_INTERFACE_ULPI, MUSB_INTERFACE_UTMI}; extern void usb_musb_init(struct omap_musb_board_data *board_data); extern void usbhs_init(const struct usbhs_omap_board_data *pdata); -extern int omap_tll_enable(void); -extern int omap_tll_disable(void); extern int omap4430_phy_power(struct device *dev, int ID, int on); extern int omap4430_phy_set_clk(struct device *dev, int on); diff --git a/trunk/arch/arm/xen/Makefile b/trunk/arch/arm/xen/Makefile deleted file mode 100644 index 43841033afd3..000000000000 --- a/trunk/arch/arm/xen/Makefile +++ /dev/null @@ -1 +0,0 @@ -obj-y := enlighten.o hypercall.o grant-table.o diff --git a/trunk/arch/arm/xen/enlighten.c b/trunk/arch/arm/xen/enlighten.c deleted file mode 100644 index 59bcb96ac369..000000000000 --- a/trunk/arch/arm/xen/enlighten.c +++ /dev/null @@ -1,168 +0,0 @@ -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -struct start_info _xen_start_info; -struct start_info *xen_start_info = &_xen_start_info; -EXPORT_SYMBOL_GPL(xen_start_info); - -enum xen_domain_type xen_domain_type = XEN_NATIVE; -EXPORT_SYMBOL_GPL(xen_domain_type); - -struct shared_info xen_dummy_shared_info; -struct shared_info *HYPERVISOR_shared_info = (void *)&xen_dummy_shared_info; - -DEFINE_PER_CPU(struct vcpu_info *, xen_vcpu); - -/* TODO: to be removed */ -__read_mostly int xen_have_vector_callback; -EXPORT_SYMBOL_GPL(xen_have_vector_callback); - -int xen_platform_pci_unplug = XEN_UNPLUG_ALL; -EXPORT_SYMBOL_GPL(xen_platform_pci_unplug); - -static __read_mostly int xen_events_irq = -1; - -int xen_remap_domain_mfn_range(struct vm_area_struct *vma, - unsigned long addr, - unsigned long mfn, int nr, - pgprot_t prot, unsigned domid) -{ - return -ENOSYS; -} -EXPORT_SYMBOL_GPL(xen_remap_domain_mfn_range); - -/* - * see Documentation/devicetree/bindings/arm/xen.txt for the - * documentation of the Xen Device Tree format. - */ -#define GRANT_TABLE_PHYSADDR 0 -static int __init xen_guest_init(void) -{ - struct xen_add_to_physmap xatp; - static struct shared_info *shared_info_page = 0; - struct device_node *node; - int len; - const char *s = NULL; - const char *version = NULL; - const char *xen_prefix = "xen,xen-"; - struct resource res; - - node = of_find_compatible_node(NULL, NULL, "xen,xen"); - if (!node) { - pr_debug("No Xen support\n"); - return 0; - } - s = of_get_property(node, "compatible", &len); - if (strlen(xen_prefix) + 3 < len && - !strncmp(xen_prefix, s, strlen(xen_prefix))) - version = s + strlen(xen_prefix); - if (version == NULL) { - pr_debug("Xen version not found\n"); - return 0; - } - if (of_address_to_resource(node, GRANT_TABLE_PHYSADDR, &res)) - return 0; - xen_hvm_resume_frames = res.start >> PAGE_SHIFT; - xen_events_irq = irq_of_parse_and_map(node, 0); - pr_info("Xen %s support found, events_irq=%d gnttab_frame_pfn=%lx\n", - version, xen_events_irq, xen_hvm_resume_frames); - xen_domain_type = XEN_HVM_DOMAIN; - - xen_setup_features(); - if (xen_feature(XENFEAT_dom0)) - xen_start_info->flags |= SIF_INITDOMAIN|SIF_PRIVILEGED; - else - xen_start_info->flags &= ~(SIF_INITDOMAIN|SIF_PRIVILEGED); - - if (!shared_info_page) - shared_info_page = (struct shared_info *) - get_zeroed_page(GFP_KERNEL); - if (!shared_info_page) { - pr_err("not enough memory\n"); - return -ENOMEM; - } - xatp.domid = DOMID_SELF; - xatp.idx = 0; - xatp.space = XENMAPSPACE_shared_info; - xatp.gpfn = __pa(shared_info_page) >> PAGE_SHIFT; - if (HYPERVISOR_memory_op(XENMEM_add_to_physmap, &xatp)) - BUG(); - - HYPERVISOR_shared_info = (struct shared_info *)shared_info_page; - - /* xen_vcpu is a pointer to the vcpu_info struct in the shared_info - * page, we use it in the event channel upcall and in some pvclock - * related functions. We don't need the vcpu_info placement - * optimizations because we don't use any pv_mmu or pv_irq op on - * HVM. - * The shared info contains exactly 1 CPU (the boot CPU). The guest - * is required to use VCPUOP_register_vcpu_info to place vcpu info - * for secondary CPUs as they are brought up. */ - per_cpu(xen_vcpu, 0) = &HYPERVISOR_shared_info->vcpu_info[0]; - - gnttab_init(); - if (!xen_initial_domain()) - xenbus_probe(NULL); - - return 0; -} -core_initcall(xen_guest_init); - -static irqreturn_t xen_arm_callback(int irq, void *arg) -{ - xen_hvm_evtchn_do_upcall(); - return IRQ_HANDLED; -} - -static int __init xen_init_events(void) -{ - if (!xen_domain() || xen_events_irq < 0) - return -ENODEV; - - xen_init_IRQ(); - - if (request_percpu_irq(xen_events_irq, xen_arm_callback, - "events", xen_vcpu)) { - pr_err("Error requesting IRQ %d\n", xen_events_irq); - return -EINVAL; - } - - enable_percpu_irq(xen_events_irq, 0); - - return 0; -} -postcore_initcall(xen_init_events); - -/* XXX: only until balloon is properly working */ -int alloc_xenballooned_pages(int nr_pages, struct page **pages, bool highmem) -{ - *pages = alloc_pages(highmem ? GFP_HIGHUSER : GFP_KERNEL, - get_order(nr_pages)); - if (*pages == NULL) - return -ENOMEM; - return 0; -} -EXPORT_SYMBOL_GPL(alloc_xenballooned_pages); - -void free_xenballooned_pages(int nr_pages, struct page **pages) -{ - kfree(*pages); - *pages = NULL; -} -EXPORT_SYMBOL_GPL(free_xenballooned_pages); diff --git a/trunk/arch/arm/xen/grant-table.c b/trunk/arch/arm/xen/grant-table.c deleted file mode 100644 index dbd1330c0196..000000000000 --- a/trunk/arch/arm/xen/grant-table.c +++ /dev/null @@ -1,53 +0,0 @@ -/****************************************************************************** - * grant_table.c - * ARM specific part - * - * Granting foreign access to our memory reservation. - * - * 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; or, when distributed - * separately from the Linux kernel or incorporated into other - * software packages, subject to the following license: - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this source file (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. - */ - -#include -#include -#include - -int arch_gnttab_map_shared(unsigned long *frames, unsigned long nr_gframes, - unsigned long max_nr_gframes, - void **__shared) -{ - return -ENOSYS; -} - -void arch_gnttab_unmap(void *shared, unsigned long nr_gframes) -{ - return; -} - -int arch_gnttab_map_status(uint64_t *frames, unsigned long nr_gframes, - unsigned long max_nr_gframes, - grant_status_t **__shared) -{ - return -ENOSYS; -} diff --git a/trunk/arch/arm/xen/hypercall.S b/trunk/arch/arm/xen/hypercall.S deleted file mode 100644 index 074f5ed101b9..000000000000 --- a/trunk/arch/arm/xen/hypercall.S +++ /dev/null @@ -1,106 +0,0 @@ -/****************************************************************************** - * hypercall.S - * - * Xen hypercall wrappers - * - * Stefano Stabellini , Citrix, 2012 - * - * 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; or, when distributed - * separately from the Linux kernel or incorporated into other - * software packages, subject to the following license: - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this source file (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. - */ - -/* - * The Xen hypercall calling convention is very similar to the ARM - * procedure calling convention: the first paramter is passed in r0, the - * second in r1, the third in r2 and the fourth in r3. Considering that - * Xen hypercalls have 5 arguments at most, the fifth paramter is passed - * in r4, differently from the procedure calling convention of using the - * stack for that case. - * - * The hypercall number is passed in r12. - * - * The return value is in r0. - * - * The hvc ISS is required to be 0xEA1, that is the Xen specific ARM - * hypercall tag. - */ - -#include -#include -#include - - -/* HVC 0xEA1 */ -#ifdef CONFIG_THUMB2_KERNEL -#define xen_hvc .word 0xf7e08ea1 -#else -#define xen_hvc .word 0xe140ea71 -#endif - -#define HYPERCALL_SIMPLE(hypercall) \ -ENTRY(HYPERVISOR_##hypercall) \ - mov r12, #__HYPERVISOR_##hypercall; \ - xen_hvc; \ - mov pc, lr; \ -ENDPROC(HYPERVISOR_##hypercall) - -#define HYPERCALL0 HYPERCALL_SIMPLE -#define HYPERCALL1 HYPERCALL_SIMPLE -#define HYPERCALL2 HYPERCALL_SIMPLE -#define HYPERCALL3 HYPERCALL_SIMPLE -#define HYPERCALL4 HYPERCALL_SIMPLE - -#define HYPERCALL5(hypercall) \ -ENTRY(HYPERVISOR_##hypercall) \ - stmdb sp!, {r4} \ - ldr r4, [sp, #4] \ - mov r12, #__HYPERVISOR_##hypercall; \ - xen_hvc \ - ldm sp!, {r4} \ - mov pc, lr \ -ENDPROC(HYPERVISOR_##hypercall) - - .text - -HYPERCALL2(xen_version); -HYPERCALL3(console_io); -HYPERCALL3(grant_table_op); -HYPERCALL2(sched_op); -HYPERCALL2(event_channel_op); -HYPERCALL2(hvm_op); -HYPERCALL2(memory_op); -HYPERCALL2(physdev_op); - -ENTRY(privcmd_call) - stmdb sp!, {r4} - mov r12, r0 - mov r0, r1 - mov r1, r2 - mov r2, r3 - ldr r3, [sp, #8] - ldr r4, [sp, #4] - xen_hvc - ldm sp!, {r4} - mov pc, lr -ENDPROC(privcmd_call); diff --git a/trunk/arch/arm64/include/asm/compat.h b/trunk/arch/arm64/include/asm/compat.h index 37e610dc084e..a670a33ad736 100644 --- a/trunk/arch/arm64/include/asm/compat.h +++ b/trunk/arch/arm64/include/asm/compat.h @@ -55,7 +55,6 @@ typedef s64 compat_s64; typedef u32 compat_uint_t; typedef u32 compat_ulong_t; typedef u64 compat_u64; -typedef u32 compat_uptr_t; struct compat_timespec { compat_time_t tv_sec; @@ -131,64 +130,6 @@ typedef u32 compat_old_sigset_t; typedef u32 compat_sigset_word; -typedef union compat_sigval { - compat_int_t sival_int; - compat_uptr_t sival_ptr; -} compat_sigval_t; - -typedef struct compat_siginfo { - int si_signo; - int si_errno; - int si_code; - - union { - /* The padding is the same size as AArch64. */ - int _pad[128/sizeof(int) - 3]; - - /* kill() */ - struct { - compat_pid_t _pid; /* sender's pid */ - __compat_uid32_t _uid; /* sender's uid */ - } _kill; - - /* POSIX.1b timers */ - struct { - compat_timer_t _tid; /* timer id */ - int _overrun; /* overrun count */ - compat_sigval_t _sigval; /* same as below */ - int _sys_private; /* not to be passed to user */ - } _timer; - - /* POSIX.1b signals */ - struct { - compat_pid_t _pid; /* sender's pid */ - __compat_uid32_t _uid; /* sender's uid */ - compat_sigval_t _sigval; - } _rt; - - /* SIGCHLD */ - struct { - compat_pid_t _pid; /* which child */ - __compat_uid32_t _uid; /* sender's uid */ - int _status; /* exit code */ - compat_clock_t _utime; - compat_clock_t _stime; - } _sigchld; - - /* SIGILL, SIGFPE, SIGSEGV, SIGBUS */ - struct { - compat_uptr_t _addr; /* faulting insn/memory ref. */ - short _addr_lsb; /* LSB of the reported address */ - } _sigfault; - - /* SIGPOLL */ - struct { - compat_long_t _band; /* POLL_IN, POLL_OUT, POLL_MSG */ - int _fd; - } _sigpoll; - } _sifields; -} compat_siginfo_t; - #define COMPAT_OFF_T_MAX 0x7fffffff #define COMPAT_LOFF_T_MAX 0x7fffffffffffffffL @@ -198,6 +139,7 @@ typedef struct compat_siginfo { * as pointers because the syscall entry code will have * appropriately converted them already. */ +typedef u32 compat_uptr_t; static inline void __user *compat_ptr(compat_uptr_t uptr) { diff --git a/trunk/arch/arm64/include/asm/unistd.h b/trunk/arch/arm64/include/asm/unistd.h index fe18a683274f..f55ba3e56c32 100644 --- a/trunk/arch/arm64/include/asm/unistd.h +++ b/trunk/arch/arm64/include/asm/unistd.h @@ -13,8 +13,6 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ -#if !defined(__ASM_UNISTD_H) || defined(__SYSCALL) -#define __ASM_UNISTD_H #ifndef __SYSCALL_COMPAT #include @@ -23,5 +21,3 @@ #if defined(__KERNEL__) && defined(CONFIG_COMPAT) #include #endif - -#endif /* __ASM_UNISTD_H */ diff --git a/trunk/arch/arm64/include/asm/unistd32.h b/trunk/arch/arm64/include/asm/unistd32.h index a50405f5ee42..3ba1f1a90629 100644 --- a/trunk/arch/arm64/include/asm/unistd32.h +++ b/trunk/arch/arm64/include/asm/unistd32.h @@ -16,8 +16,6 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ -#if !defined(__ASM_UNISTD32_H) || defined(__SYSCALL) -#define __ASM_UNISTD32_H #ifndef __SYSCALL #define __SYSCALL(x, y) @@ -754,5 +752,3 @@ __SYSCALL(__NR_syncfs, sys_syncfs) #define __ARCH_WANT_SYS_SIGPENDING #define __ARCH_WANT_SYS_SIGPROCMASK #define __ARCH_WANT_COMPAT_SYS_RT_SIGSUSPEND - -#endif /* __ASM_UNISTD32_H */ diff --git a/trunk/arch/arm64/kernel/signal32.c b/trunk/arch/arm64/kernel/signal32.c index 0790a87a4346..ac74c2f261e3 100644 --- a/trunk/arch/arm64/kernel/signal32.c +++ b/trunk/arch/arm64/kernel/signal32.c @@ -30,6 +30,59 @@ #include #include +typedef struct compat_siginfo { + int si_signo; + int si_errno; + int si_code; + + union { + /* The padding is the same size as AArch64. */ + int _pad[SI_PAD_SIZE]; + + /* kill() */ + struct { + compat_pid_t _pid; /* sender's pid */ + __compat_uid32_t _uid; /* sender's uid */ + } _kill; + + /* POSIX.1b timers */ + struct { + compat_timer_t _tid; /* timer id */ + int _overrun; /* overrun count */ + compat_sigval_t _sigval; /* same as below */ + int _sys_private; /* not to be passed to user */ + } _timer; + + /* POSIX.1b signals */ + struct { + compat_pid_t _pid; /* sender's pid */ + __compat_uid32_t _uid; /* sender's uid */ + compat_sigval_t _sigval; + } _rt; + + /* SIGCHLD */ + struct { + compat_pid_t _pid; /* which child */ + __compat_uid32_t _uid; /* sender's uid */ + int _status; /* exit code */ + compat_clock_t _utime; + compat_clock_t _stime; + } _sigchld; + + /* SIGILL, SIGFPE, SIGSEGV, SIGBUS */ + struct { + compat_uptr_t _addr; /* faulting insn/memory ref. */ + short _addr_lsb; /* LSB of the reported address */ + } _sigfault; + + /* SIGPOLL */ + struct { + compat_long_t _band; /* POLL_IN, POLL_OUT, POLL_MSG */ + int _fd; + } _sigpoll; + } _sifields; +} compat_siginfo_t; + struct compat_sigaction { compat_uptr_t sa_handler; compat_ulong_t sa_flags; diff --git a/trunk/arch/avr32/include/asm/elf.h b/trunk/arch/avr32/include/asm/elf.h index e2c328739808..3b3159b710d4 100644 --- a/trunk/arch/avr32/include/asm/elf.h +++ b/trunk/arch/avr32/include/asm/elf.h @@ -102,7 +102,6 @@ typedef struct user_fpu_struct elf_fpregset_t; #define ELF_PLATFORM (NULL) -#define SET_PERSONALITY(ex) \ - set_personality(PER_LINUX_32BIT | (current->personality & (~PER_MASK))) +#define SET_PERSONALITY(ex) set_personality(PER_LINUX_32BIT) #endif /* __ASM_AVR32_ELF_H */ diff --git a/trunk/arch/blackfin/include/asm/elf.h b/trunk/arch/blackfin/include/asm/elf.h index 14bc98ff668f..e6c6812a9abd 100644 --- a/trunk/arch/blackfin/include/asm/elf.h +++ b/trunk/arch/blackfin/include/asm/elf.h @@ -132,7 +132,6 @@ do { \ #define ELF_PLATFORM (NULL) -#define SET_PERSONALITY(ex) \ - set_personality(PER_LINUX | (current->personality & (~PER_MASK))) +#define SET_PERSONALITY(ex) set_personality(PER_LINUX) #endif diff --git a/trunk/arch/c6x/include/asm/elf.h b/trunk/arch/c6x/include/asm/elf.h index 32b997126adf..f4552db20b4a 100644 --- a/trunk/arch/c6x/include/asm/elf.h +++ b/trunk/arch/c6x/include/asm/elf.h @@ -77,8 +77,7 @@ do { \ #define ELF_PLATFORM (NULL) -#define SET_PERSONALITY(ex) \ - set_personality(PER_LINUX | (current->personality & (~PER_MASK))) +#define SET_PERSONALITY(ex) set_personality(PER_LINUX) /* C6X specific section types */ #define SHT_C6000_UNWIND 0x70000001 diff --git a/trunk/arch/c6x/include/asm/unistd.h b/trunk/arch/c6x/include/asm/unistd.h index 6d54ea4262eb..ed2259043eec 100644 --- a/trunk/arch/c6x/include/asm/unistd.h +++ b/trunk/arch/c6x/include/asm/unistd.h @@ -13,8 +13,6 @@ * NON INFRINGEMENT. See the GNU General Public License for * more details. */ -#if !defined(_ASM_C6X_UNISTD_H) || defined(__SYSCALL) -#define _ASM_C6X_UNISTD_H /* Use the standard ABI for syscalls. */ #include @@ -22,5 +20,3 @@ /* C6X-specific syscalls. */ #define __NR_cache_sync (__NR_arch_specific_syscall + 0) __SYSCALL(__NR_cache_sync, sys_cache_sync) - -#endif /* _ASM_C6X_UNISTD_H */ diff --git a/trunk/arch/cris/include/asm/elf.h b/trunk/arch/cris/include/asm/elf.h index 8182f2dc89d0..8a3d8e2b33c1 100644 --- a/trunk/arch/cris/include/asm/elf.h +++ b/trunk/arch/cris/include/asm/elf.h @@ -86,7 +86,6 @@ typedef unsigned long elf_fpregset_t; #define ELF_PLATFORM (NULL) -#define SET_PERSONALITY(ex) \ - set_personality(PER_LINUX | (current->personality & (~PER_MASK))) +#define SET_PERSONALITY(ex) set_personality(PER_LINUX) #endif diff --git a/trunk/arch/frv/include/asm/elf.h b/trunk/arch/frv/include/asm/elf.h index 9ccbc80f0b11..c3819804a74b 100644 --- a/trunk/arch/frv/include/asm/elf.h +++ b/trunk/arch/frv/include/asm/elf.h @@ -137,7 +137,6 @@ do { \ #define ELF_PLATFORM (NULL) -#define SET_PERSONALITY(ex) \ - set_personality(PER_LINUX | (current->personality & (~PER_MASK))) +#define SET_PERSONALITY(ex) set_personality(PER_LINUX) #endif diff --git a/trunk/arch/frv/kernel/pm.c b/trunk/arch/frv/kernel/pm.c index 0b579927439d..5fa3889d858b 100644 --- a/trunk/arch/frv/kernel/pm.c +++ b/trunk/arch/frv/kernel/pm.c @@ -153,22 +153,23 @@ static int user_atoi(char __user *ubuf, size_t len) static int sysctl_pm_do_suspend(ctl_table *ctl, int write, void __user *buffer, size_t *lenp, loff_t *fpos) { - int mode; + int retval, mode; if (*lenp <= 0) return -EIO; mode = user_atoi(buffer, *lenp); - switch (mode) { - case 1: - return pm_do_suspend(); - - case 5: - return pm_do_bus_sleep(); + if ((mode != 1) && (mode != 5)) + return -EINVAL; - default: - return -EINVAL; + if (retval == 0) { + if (mode == 5) + retval = pm_do_bus_sleep(); + else + retval = pm_do_suspend(); } + + return retval; } static int try_set_cmode(int new_cmode) diff --git a/trunk/arch/frv/kernel/setup.c b/trunk/arch/frv/kernel/setup.c index 1f1e5efb3385..75cf7f4b2fa8 100644 --- a/trunk/arch/frv/kernel/setup.c +++ b/trunk/arch/frv/kernel/setup.c @@ -184,7 +184,7 @@ static struct clock_cmode __pminitdata clock_cmodes_fr555[16] = { [6] = { _x1, _x1_5, _x1_5, _x4_5, _x0_375 }, }; -static const struct clock_cmode __pminitconst *clock_cmodes; +static const struct clock_cmode __pminitdata *clock_cmodes; static int __pminitdata clock_doubled; static struct uart_port __pminitdata __frv_uart0 = { diff --git a/trunk/arch/frv/mb93090-mb00/pci-irq.c b/trunk/arch/frv/mb93090-mb00/pci-irq.c index c677b9d81d30..20f6497b2cd5 100644 --- a/trunk/arch/frv/mb93090-mb00/pci-irq.c +++ b/trunk/arch/frv/mb93090-mb00/pci-irq.c @@ -28,7 +28,7 @@ * */ -static const uint8_t __initconst pci_bus0_irq_routing[32][4] = { +static const uint8_t __initdata pci_bus0_irq_routing[32][4] = { [0 ] = { IRQ_FPGA_MB86943_PCI_INTA }, [16] = { IRQ_FPGA_RTL8029_INTA }, [17] = { IRQ_FPGA_PCI_INTC, IRQ_FPGA_PCI_INTD, IRQ_FPGA_PCI_INTA, IRQ_FPGA_PCI_INTB }, diff --git a/trunk/arch/h8300/include/asm/elf.h b/trunk/arch/h8300/include/asm/elf.h index 41193c396bff..c24fa250d653 100644 --- a/trunk/arch/h8300/include/asm/elf.h +++ b/trunk/arch/h8300/include/asm/elf.h @@ -54,8 +54,7 @@ typedef unsigned long elf_fpregset_t; #define ELF_PLATFORM (NULL) -#define SET_PERSONALITY(ex) \ - set_personality(PER_LINUX | (current->personality & (~PER_MASK))) +#define SET_PERSONALITY(ex) set_personality(PER_LINUX) #define R_H8_NONE 0 #define R_H8_DIR32 1 diff --git a/trunk/arch/h8300/kernel/sys_h8300.c b/trunk/arch/h8300/kernel/sys_h8300.c index 4bdc7311784e..aaf5e5a48f93 100644 --- a/trunk/arch/h8300/kernel/sys_h8300.c +++ b/trunk/arch/h8300/kernel/sys_h8300.c @@ -51,7 +51,6 @@ asmlinkage void syscall_print(void *dummy,...) * Do a system call from kernel instead of calling sys_execve so we * end up with proper pt_regs. */ -asmlinkage int kernel_execve(const char *filename, const char *const argv[], const char *const envp[]) diff --git a/trunk/arch/h8300/kernel/timer/itu.c b/trunk/arch/h8300/kernel/timer/itu.c index 0a8b5cd5bf38..a2ae5e952137 100644 --- a/trunk/arch/h8300/kernel/timer/itu.c +++ b/trunk/arch/h8300/kernel/timer/itu.c @@ -62,7 +62,7 @@ static struct irqaction itu_irq = { .flags = IRQF_DISABLED | IRQF_TIMER, }; -static const int __initconst divide_rate[] = {1, 2, 4, 8}; +static const int __initdata divide_rate[] = {1, 2, 4, 8}; void __init h8300_timer_setup(void) { diff --git a/trunk/arch/h8300/kernel/timer/timer16.c b/trunk/arch/h8300/kernel/timer/timer16.c index 462d9f581719..ae0d38161139 100644 --- a/trunk/arch/h8300/kernel/timer/timer16.c +++ b/trunk/arch/h8300/kernel/timer/timer16.c @@ -57,7 +57,7 @@ static struct irqaction timer16_irq = { .flags = IRQF_DISABLED | IRQF_TIMER, }; -static const int __initconst divide_rate[] = {1, 2, 4, 8}; +static const int __initdata divide_rate[] = {1, 2, 4, 8}; void __init h8300_timer_setup(void) { diff --git a/trunk/arch/h8300/kernel/timer/timer8.c b/trunk/arch/h8300/kernel/timer/timer8.c index 505f3415b40f..7a1533fad47d 100644 --- a/trunk/arch/h8300/kernel/timer/timer8.c +++ b/trunk/arch/h8300/kernel/timer/timer8.c @@ -77,7 +77,7 @@ static struct irqaction timer8_irq = { .flags = IRQF_DISABLED | IRQF_TIMER, }; -static const int __initconst divide_rate[] = {8, 64, 8192}; +static const int __initdata divide_rate[] = {8, 64, 8192}; void __init h8300_timer_setup(void) { diff --git a/trunk/arch/h8300/kernel/timer/tpu.c b/trunk/arch/h8300/kernel/timer/tpu.c index 0350f6204ecf..2193a2e2859a 100644 --- a/trunk/arch/h8300/kernel/timer/tpu.c +++ b/trunk/arch/h8300/kernel/timer/tpu.c @@ -66,7 +66,7 @@ static struct irqaction tpu_irq = { .flags = IRQF_DISABLED | IRQF_TIMER, }; -static const int __initconst divide_rate[] = { +static const int __initdata divide_rate[] = { #if CONFIG_H8300_TPU_CH == 0 1,4,16,64,0,0,0,0, #elif (CONFIG_H8300_TPU_CH == 1) || (CONFIG_H8300_TPU_CH == 5) diff --git a/trunk/arch/h8300/platform/h8300h/irq.c b/trunk/arch/h8300/platform/h8300h/irq.c index 0a50353e09d5..bc4f51bceef5 100644 --- a/trunk/arch/h8300/platform/h8300h/irq.c +++ b/trunk/arch/h8300/platform/h8300h/irq.c @@ -14,14 +14,14 @@ #include #include -const int __initconst h8300_saved_vectors[] = { +const int __initdata h8300_saved_vectors[] = { #if defined(CONFIG_GDB_DEBUG) TRAP3_VEC, /* TRAPA #3 is GDB breakpoint */ #endif -1, }; -const h8300_vector __initconst h8300_trap_table[] = { +const h8300_vector __initdata h8300_trap_table[] = { 0, 0, 0, 0, 0, 0, 0, 0, system_call, 0, diff --git a/trunk/arch/h8300/platform/h8s/irq.c b/trunk/arch/h8300/platform/h8s/irq.c index f3a5511c16b1..7b5f29febc07 100644 --- a/trunk/arch/h8300/platform/h8s/irq.c +++ b/trunk/arch/h8300/platform/h8s/irq.c @@ -18,7 +18,7 @@ #include /* saved vector list */ -const int __initconst h8300_saved_vectors[] = { +const int __initdata h8300_saved_vectors[]={ #if defined(CONFIG_GDB_DEBUG) TRACE_VEC, TRAP3_VEC, @@ -27,7 +27,7 @@ const int __initconst h8300_saved_vectors[] = { }; /* trap entry table */ -const H8300_VECTOR __initconst h8300_trap_table[] = { +const H8300_VECTOR __initdata h8300_trap_table[] = { 0,0,0,0,0, trace_break, /* TRACE */ 0,0, diff --git a/trunk/arch/hexagon/include/asm/elf.h b/trunk/arch/hexagon/include/asm/elf.h index 82b499621e05..37976a0d3650 100644 --- a/trunk/arch/hexagon/include/asm/elf.h +++ b/trunk/arch/hexagon/include/asm/elf.h @@ -217,8 +217,7 @@ do { \ #define ELF_PLATFORM (NULL) #ifdef __KERNEL__ -#define SET_PERSONALITY(ex) \ - set_personality(PER_LINUX | (current->personality & (~PER_MASK))) +#define SET_PERSONALITY(ex) set_personality(PER_LINUX) #endif #define ARCH_HAS_SETUP_ADDITIONAL_PAGES 1 diff --git a/trunk/arch/hexagon/include/asm/unistd.h b/trunk/arch/hexagon/include/asm/unistd.h index 4d0ecde3665f..c0d5565030ae 100644 --- a/trunk/arch/hexagon/include/asm/unistd.h +++ b/trunk/arch/hexagon/include/asm/unistd.h @@ -18,9 +18,6 @@ * 02110-1301, USA. */ -#if !defined(_ASM_HEXAGON_UNISTD_H) || defined(__SYSCALL) -#define _ASM_HEXAGON_UNISTD_H - /* * The kernel pulls this unistd.h in three different ways: * 1. the "normal" way which gets all the __NR defines @@ -32,5 +29,3 @@ #define sys_mmap2 sys_mmap_pgoff #include - -#endif diff --git a/trunk/arch/ia64/include/asm/xen/interface.h b/trunk/arch/ia64/include/asm/xen/interface.h index e88c5de27410..3d52a5bbd857 100644 --- a/trunk/arch/ia64/include/asm/xen/interface.h +++ b/trunk/arch/ia64/include/asm/xen/interface.h @@ -71,7 +71,6 @@ * with Xen so that we could have one ABI that works for 32 and 64 bit * guests. */ typedef unsigned long xen_pfn_t; -typedef unsigned long xen_ulong_t; /* Guest handles for primitive C types. */ __DEFINE_GUEST_HANDLE(uchar, unsigned char); __DEFINE_GUEST_HANDLE(uint, unsigned int); diff --git a/trunk/arch/ia64/kvm/kvm-ia64.c b/trunk/arch/ia64/kvm/kvm-ia64.c index 8b3a9c0e771d..bd77cb507c1c 100644 --- a/trunk/arch/ia64/kvm/kvm-ia64.c +++ b/trunk/arch/ia64/kvm/kvm-ia64.c @@ -924,16 +924,6 @@ int kvm_arch_vcpu_ioctl_set_regs(struct kvm_vcpu *vcpu, struct kvm_regs *regs) return 0; } -int kvm_vm_ioctl_irq_line(struct kvm *kvm, struct kvm_irq_level *irq_event) -{ - if (!irqchip_in_kernel(kvm)) - return -ENXIO; - - irq_event->status = kvm_set_irq(kvm, KVM_USERSPACE_IRQ_SOURCE_ID, - irq_event->irq, irq_event->level); - return 0; -} - long kvm_arch_vm_ioctl(struct file *filp, unsigned int ioctl, unsigned long arg) { @@ -973,6 +963,29 @@ long kvm_arch_vm_ioctl(struct file *filp, goto out; } break; + case KVM_IRQ_LINE_STATUS: + case KVM_IRQ_LINE: { + struct kvm_irq_level irq_event; + + r = -EFAULT; + if (copy_from_user(&irq_event, argp, sizeof irq_event)) + goto out; + r = -ENXIO; + if (irqchip_in_kernel(kvm)) { + __s32 status; + status = kvm_set_irq(kvm, KVM_USERSPACE_IRQ_SOURCE_ID, + irq_event.irq, irq_event.level); + if (ioctl == KVM_IRQ_LINE_STATUS) { + r = -EFAULT; + irq_event.status = status; + if (copy_to_user(argp, &irq_event, + sizeof irq_event)) + goto out; + } + r = 0; + } + break; + } case KVM_GET_IRQCHIP: { /* 0: PIC master, 1: PIC slave, 2: IOAPIC */ struct kvm_irqchip chip; @@ -1613,17 +1626,11 @@ void kvm_arch_commit_memory_region(struct kvm *kvm, return; } -void kvm_arch_flush_shadow_all(struct kvm *kvm) +void kvm_arch_flush_shadow(struct kvm *kvm) { kvm_flush_remote_tlbs(kvm); } -void kvm_arch_flush_shadow_memslot(struct kvm *kvm, - struct kvm_memory_slot *slot) -{ - kvm_arch_flush_shadow_all(); -} - long kvm_arch_dev_ioctl(struct file *filp, unsigned int ioctl, unsigned long arg) { diff --git a/trunk/arch/ia64/xen/irq_xen.c b/trunk/arch/ia64/xen/irq_xen.c index 01f479ee1c43..3bb12230721f 100644 --- a/trunk/arch/ia64/xen/irq_xen.c +++ b/trunk/arch/ia64/xen/irq_xen.c @@ -433,7 +433,7 @@ xen_resend_irq(unsigned int vector) (void)resend_irq_on_evtchn(vector); } -const struct pv_irq_ops xen_irq_ops __initconst = { +const struct pv_irq_ops xen_irq_ops __initdata = { .register_ipi = xen_register_ipi, .assign_irq_vector = xen_assign_irq_vector, diff --git a/trunk/arch/ia64/xen/irq_xen.h b/trunk/arch/ia64/xen/irq_xen.h index 1778517b90fe..26110f330c87 100644 --- a/trunk/arch/ia64/xen/irq_xen.h +++ b/trunk/arch/ia64/xen/irq_xen.h @@ -27,7 +27,7 @@ extern void (*late_time_init)(void); extern char xen_event_callback; void __init xen_init_IRQ(void); -extern const struct pv_irq_ops xen_irq_ops __initconst; +extern const struct pv_irq_ops xen_irq_ops __initdata; extern void xen_smp_intr_init(void); extern void xen_send_ipi(int cpu, int vec); diff --git a/trunk/arch/m32r/include/asm/elf.h b/trunk/arch/m32r/include/asm/elf.h index 70896161c636..b8da7d0574d2 100644 --- a/trunk/arch/m32r/include/asm/elf.h +++ b/trunk/arch/m32r/include/asm/elf.h @@ -128,7 +128,6 @@ typedef elf_fpreg_t elf_fpregset_t; intent than poking at uname or /proc/cpuinfo. */ #define ELF_PLATFORM (NULL) -#define SET_PERSONALITY(ex) \ - set_personality(PER_LINUX | (current->personality & (~PER_MASK))) +#define SET_PERSONALITY(ex) set_personality(PER_LINUX) #endif /* _ASM_M32R__ELF_H */ diff --git a/trunk/arch/m68k/include/asm/elf.h b/trunk/arch/m68k/include/asm/elf.h index f83c1d0a87cf..e9b7cda59744 100644 --- a/trunk/arch/m68k/include/asm/elf.h +++ b/trunk/arch/m68k/include/asm/elf.h @@ -113,7 +113,6 @@ typedef struct user_m68kfp_struct elf_fpregset_t; #define ELF_PLATFORM (NULL) -#define SET_PERSONALITY(ex) \ - set_personality(PER_LINUX | (current->personality & (~PER_MASK))) +#define SET_PERSONALITY(ex) set_personality(PER_LINUX) #endif diff --git a/trunk/arch/microblaze/include/asm/elf.h b/trunk/arch/microblaze/include/asm/elf.h index 640ddd4b6a9b..834849f59ae8 100644 --- a/trunk/arch/microblaze/include/asm/elf.h +++ b/trunk/arch/microblaze/include/asm/elf.h @@ -116,8 +116,7 @@ do { \ } while (0) #ifdef __KERNEL__ -#define SET_PERSONALITY(ex) \ - set_personality(PER_LINUX_32BIT | (current->personality & (~PER_MASK))) +#define SET_PERSONALITY(ex) set_personality(PER_LINUX_32BIT) #endif #endif /* __uClinux__ */ diff --git a/trunk/arch/mips/bcm63xx/boards/board_bcm963xx.c b/trunk/arch/mips/bcm63xx/boards/board_bcm963xx.c index dd18e4b761a8..feb05258a4d1 100644 --- a/trunk/arch/mips/bcm63xx/boards/board_bcm963xx.c +++ b/trunk/arch/mips/bcm63xx/boards/board_bcm963xx.c @@ -632,7 +632,7 @@ static struct board_info __initdata board_DWVS0 = { /* * all boards */ -static const struct board_info __initconst *bcm963xx_boards[] = { +static const struct board_info __initdata *bcm963xx_boards[] = { #ifdef CONFIG_BCM63XX_CPU_6328 &board_96328avng, #endif diff --git a/trunk/arch/mips/include/asm/compat-signal.h b/trunk/arch/mips/include/asm/compat-signal.h index 6599a901b63e..368a99e5c3e1 100644 --- a/trunk/arch/mips/include/asm/compat-signal.h +++ b/trunk/arch/mips/include/asm/compat-signal.h @@ -10,6 +10,68 @@ #include +#define SI_PAD_SIZE32 ((SI_MAX_SIZE/sizeof(int)) - 3) + +typedef struct compat_siginfo { + int si_signo; + int si_code; + int si_errno; + + union { + int _pad[SI_PAD_SIZE32]; + + /* kill() */ + struct { + compat_pid_t _pid; /* sender's pid */ + compat_uid_t _uid; /* sender's uid */ + } _kill; + + /* SIGCHLD */ + struct { + compat_pid_t _pid; /* which child */ + compat_uid_t _uid; /* sender's uid */ + int _status; /* exit code */ + compat_clock_t _utime; + compat_clock_t _stime; + } _sigchld; + + /* IRIX SIGCHLD */ + struct { + compat_pid_t _pid; /* which child */ + compat_clock_t _utime; + int _status; /* exit code */ + compat_clock_t _stime; + } _irix_sigchld; + + /* SIGILL, SIGFPE, SIGSEGV, SIGBUS */ + struct { + s32 _addr; /* faulting insn/memory ref. */ + } _sigfault; + + /* SIGPOLL, SIGXFSZ (To do ...) */ + struct { + int _band; /* POLL_IN, POLL_OUT, POLL_MSG */ + int _fd; + } _sigpoll; + + /* POSIX.1b timers */ + struct { + timer_t _tid; /* timer id */ + int _overrun; /* overrun count */ + compat_sigval_t _sigval;/* same as below */ + int _sys_private; /* not to be passed to user */ + } _timer; + + /* POSIX.1b signals */ + struct { + compat_pid_t _pid; /* sender's pid */ + compat_uid_t _uid; /* sender's uid */ + compat_sigval_t _sigval; + } _rt; + + } _sifields; +} compat_siginfo_t; + static inline int __copy_conv_sigset_to_user(compat_sigset_t __user *d, const sigset_t *s) { diff --git a/trunk/arch/mips/include/asm/compat.h b/trunk/arch/mips/include/asm/compat.h index 58277e0e9cd4..b77df0366ee6 100644 --- a/trunk/arch/mips/include/asm/compat.h +++ b/trunk/arch/mips/include/asm/compat.h @@ -43,7 +43,6 @@ typedef s64 compat_s64; typedef u32 compat_uint_t; typedef u32 compat_ulong_t; typedef u64 compat_u64; -typedef u32 compat_uptr_t; struct compat_timespec { compat_time_t tv_sec; @@ -125,73 +124,6 @@ typedef u32 compat_old_sigset_t; /* at least 32 bits */ typedef u32 compat_sigset_word; -typedef union compat_sigval { - compat_int_t sival_int; - compat_uptr_t sival_ptr; -} compat_sigval_t; - -#define SI_PAD_SIZE32 (128/sizeof(int) - 3) - -typedef struct compat_siginfo { - int si_signo; - int si_code; - int si_errno; - - union { - int _pad[SI_PAD_SIZE32]; - - /* kill() */ - struct { - compat_pid_t _pid; /* sender's pid */ - __compat_uid_t _uid; /* sender's uid */ - } _kill; - - /* SIGCHLD */ - struct { - compat_pid_t _pid; /* which child */ - __compat_uid_t _uid; /* sender's uid */ - int _status; /* exit code */ - compat_clock_t _utime; - compat_clock_t _stime; - } _sigchld; - - /* IRIX SIGCHLD */ - struct { - compat_pid_t _pid; /* which child */ - compat_clock_t _utime; - int _status; /* exit code */ - compat_clock_t _stime; - } _irix_sigchld; - - /* SIGILL, SIGFPE, SIGSEGV, SIGBUS */ - struct { - s32 _addr; /* faulting insn/memory ref. */ - } _sigfault; - - /* SIGPOLL, SIGXFSZ (To do ...) */ - struct { - int _band; /* POLL_IN, POLL_OUT, POLL_MSG */ - int _fd; - } _sigpoll; - - /* POSIX.1b timers */ - struct { - timer_t _tid; /* timer id */ - int _overrun; /* overrun count */ - compat_sigval_t _sigval;/* same as below */ - int _sys_private; /* not to be passed to user */ - } _timer; - - /* POSIX.1b signals */ - struct { - compat_pid_t _pid; /* sender's pid */ - __compat_uid_t _uid; /* sender's uid */ - compat_sigval_t _sigval; - } _rt; - - } _sifields; -} compat_siginfo_t; - #define COMPAT_OFF_T_MAX 0x7fffffff #define COMPAT_LOFF_T_MAX 0x7fffffffffffffffL @@ -201,6 +133,7 @@ typedef struct compat_siginfo { * as pointers because the syscall entry code will have * appropriately converted them already. */ +typedef u32 compat_uptr_t; static inline void __user *compat_ptr(compat_uptr_t uptr) { diff --git a/trunk/arch/mips/pci/pci-octeon.c b/trunk/arch/mips/pci/pci-octeon.c index 4b0c347d7a82..c5dfb2c87d44 100644 --- a/trunk/arch/mips/pci/pci-octeon.c +++ b/trunk/arch/mips/pci/pci-octeon.c @@ -58,7 +58,7 @@ union octeon_pci_address { } s; }; -int __initconst (*octeon_pcibios_map_irq)(const struct pci_dev *dev, +int __initdata (*octeon_pcibios_map_irq)(const struct pci_dev *dev, u8 slot, u8 pin); enum octeon_dma_bar_type octeon_dma_bar_type = OCTEON_DMA_BAR_TYPE_INVALID; diff --git a/trunk/arch/mn10300/Makefile b/trunk/arch/mn10300/Makefile index a3d0fef3b126..33188b6e81e4 100644 --- a/trunk/arch/mn10300/Makefile +++ b/trunk/arch/mn10300/Makefile @@ -26,7 +26,7 @@ CHECKFLAGS += PROCESSOR := unset UNIT := unset -KBUILD_CFLAGS += -mam33 -DCPU=AM33 $(call cc-option,-mmem-funcs,) +KBUILD_CFLAGS += -mam33 -mmem-funcs -DCPU=AM33 KBUILD_AFLAGS += -mam33 -DCPU=AM33 ifeq ($(CONFIG_MN10300_CURRENT_IN_E2),y) diff --git a/trunk/arch/mn10300/include/asm/elf.h b/trunk/arch/mn10300/include/asm/elf.h index 4ebd6b3a0a1e..8157c9267f42 100644 --- a/trunk/arch/mn10300/include/asm/elf.h +++ b/trunk/arch/mn10300/include/asm/elf.h @@ -151,8 +151,7 @@ do { \ #define ELF_PLATFORM (NULL) #ifdef __KERNEL__ -#define SET_PERSONALITY(ex) \ - set_personality(PER_LINUX | (current->personality & (~PER_MASK))) +#define SET_PERSONALITY(ex) set_personality(PER_LINUX) #endif #endif /* _ASM_ELF_H */ diff --git a/trunk/arch/openrisc/include/asm/elf.h b/trunk/arch/openrisc/include/asm/elf.h index 225a7ff320ad..a8fe2c513070 100644 --- a/trunk/arch/openrisc/include/asm/elf.h +++ b/trunk/arch/openrisc/include/asm/elf.h @@ -110,8 +110,7 @@ extern void dump_elf_thread(elf_greg_t *dest, struct pt_regs *pt); #define ELF_PLATFORM (NULL) -#define SET_PERSONALITY(ex) \ - set_personality(PER_LINUX | (current->personality & (~PER_MASK))) +#define SET_PERSONALITY(ex) set_personality(PER_LINUX) #endif /* __KERNEL__ */ #endif diff --git a/trunk/arch/openrisc/include/asm/unistd.h b/trunk/arch/openrisc/include/asm/unistd.h index 89af3ab5c2e9..437bdbb61b14 100644 --- a/trunk/arch/openrisc/include/asm/unistd.h +++ b/trunk/arch/openrisc/include/asm/unistd.h @@ -16,9 +16,6 @@ * (at your option) any later version. */ -#if !defined(__ASM_OPENRISC_UNISTD_H) || defined(__SYSCALL) -#define __ASM_OPENRISC_UNISTD_H - #define __ARCH_HAVE_MMU #define sys_mmap2 sys_mmap_pgoff @@ -27,5 +24,3 @@ #define __NR_or1k_atomic __NR_arch_specific_syscall __SYSCALL(__NR_or1k_atomic, sys_or1k_atomic) - -#endif /* __ASM_OPENRISC_UNISTD_H */ diff --git a/trunk/arch/parisc/Kconfig b/trunk/arch/parisc/Kconfig index b87438bb3384..3ff21b536f28 100644 --- a/trunk/arch/parisc/Kconfig +++ b/trunk/arch/parisc/Kconfig @@ -13,7 +13,6 @@ config PARISC select HAVE_PERF_EVENTS select GENERIC_ATOMIC64 if !64BIT select HAVE_GENERIC_HARDIRQS - select BROKEN_RODATA select GENERIC_IRQ_PROBE select GENERIC_PCI_IOMAP select IRQ_PER_CPU diff --git a/trunk/arch/parisc/include/asm/compat.h b/trunk/arch/parisc/include/asm/compat.h index db7a662691a8..760f331d4fa3 100644 --- a/trunk/arch/parisc/include/asm/compat.h +++ b/trunk/arch/parisc/include/asm/compat.h @@ -36,7 +36,6 @@ typedef s64 compat_s64; typedef u32 compat_uint_t; typedef u32 compat_ulong_t; typedef u64 compat_u64; -typedef u32 compat_uptr_t; struct compat_timespec { compat_time_t tv_sec; @@ -128,63 +127,6 @@ typedef u32 compat_old_sigset_t; /* at least 32 bits */ typedef u32 compat_sigset_word; -typedef union compat_sigval { - compat_int_t sival_int; - compat_uptr_t sival_ptr; -} compat_sigval_t; - -typedef struct compat_siginfo { - int si_signo; - int si_errno; - int si_code; - - union { - int _pad[128/sizeof(int) - 3]; - - /* kill() */ - struct { - unsigned int _pid; /* sender's pid */ - unsigned int _uid; /* sender's uid */ - } _kill; - - /* POSIX.1b timers */ - struct { - compat_timer_t _tid; /* timer id */ - int _overrun; /* overrun count */ - char _pad[sizeof(unsigned int) - sizeof(int)]; - compat_sigval_t _sigval; /* same as below */ - int _sys_private; /* not to be passed to user */ - } _timer; - - /* POSIX.1b signals */ - struct { - unsigned int _pid; /* sender's pid */ - unsigned int _uid; /* sender's uid */ - compat_sigval_t _sigval; - } _rt; - - /* SIGCHLD */ - struct { - unsigned int _pid; /* which child */ - unsigned int _uid; /* sender's uid */ - int _status; /* exit code */ - compat_clock_t _utime; - compat_clock_t _stime; - } _sigchld; - - /* SIGILL, SIGFPE, SIGSEGV, SIGBUS */ - struct { - unsigned int _addr; /* faulting insn/memory ref. */ - } _sigfault; - - /* SIGPOLL */ - struct { - int _band; /* POLL_IN, POLL_OUT, POLL_MSG */ - int _fd; - } _sigpoll; - } _sifields; -} compat_siginfo_t; - #define COMPAT_OFF_T_MAX 0x7fffffff #define COMPAT_LOFF_T_MAX 0x7fffffffffffffffL @@ -194,6 +136,7 @@ typedef struct compat_siginfo { * as pointers because the syscall entry code will have * appropriately converted them already. */ +typedef u32 compat_uptr_t; static inline void __user *compat_ptr(compat_uptr_t uptr) { diff --git a/trunk/arch/parisc/kernel/signal32.h b/trunk/arch/parisc/kernel/signal32.h index 08a88b5349a2..c7800846422c 100644 --- a/trunk/arch/parisc/kernel/signal32.h +++ b/trunk/arch/parisc/kernel/signal32.h @@ -55,6 +55,58 @@ struct k_sigaction32 { struct compat_sigaction sa; }; +typedef struct compat_siginfo { + int si_signo; + int si_errno; + int si_code; + + union { + int _pad[((128/sizeof(int)) - 3)]; + + /* kill() */ + struct { + unsigned int _pid; /* sender's pid */ + unsigned int _uid; /* sender's uid */ + } _kill; + + /* POSIX.1b timers */ + struct { + compat_timer_t _tid; /* timer id */ + int _overrun; /* overrun count */ + char _pad[sizeof(unsigned int) - sizeof(int)]; + compat_sigval_t _sigval; /* same as below */ + int _sys_private; /* not to be passed to user */ + } _timer; + + /* POSIX.1b signals */ + struct { + unsigned int _pid; /* sender's pid */ + unsigned int _uid; /* sender's uid */ + compat_sigval_t _sigval; + } _rt; + + /* SIGCHLD */ + struct { + unsigned int _pid; /* which child */ + unsigned int _uid; /* sender's uid */ + int _status; /* exit code */ + compat_clock_t _utime; + compat_clock_t _stime; + } _sigchld; + + /* SIGILL, SIGFPE, SIGSEGV, SIGBUS */ + struct { + unsigned int _addr; /* faulting insn/memory ref. */ + } _sigfault; + + /* SIGPOLL */ + struct { + int _band; /* POLL_IN, POLL_OUT, POLL_MSG */ + int _fd; + } _sigpoll; + } _sifields; +} compat_siginfo_t; + int copy_siginfo_to_user32 (compat_siginfo_t __user *to, siginfo_t *from); int copy_siginfo_from_user32 (siginfo_t *to, compat_siginfo_t __user *from); diff --git a/trunk/arch/powerpc/Kconfig b/trunk/arch/powerpc/Kconfig index 4ce0be32d153..352f416269ce 100644 --- a/trunk/arch/powerpc/Kconfig +++ b/trunk/arch/powerpc/Kconfig @@ -215,8 +215,7 @@ config ARCH_HIBERNATION_POSSIBLE config ARCH_SUSPEND_POSSIBLE def_bool y depends on ADB_PMU || PPC_EFIKA || PPC_LITE5200 || PPC_83xx || \ - (PPC_85xx && !PPC_E500MC) || PPC_86xx || PPC_PSERIES \ - || 44x || 40x + (PPC_85xx && !SMP) || PPC_86xx || PPC_PSERIES || 44x || 40x config PPC_DCR_NATIVE bool @@ -240,9 +239,6 @@ config PPC_OF_PLATFORM_PCI config ARCH_SUPPORTS_DEBUG_PAGEALLOC def_bool y -config ARCH_SUPPORTS_UPROBES - def_bool y - config PPC_ADV_DEBUG_REGS bool depends on 40x || BOOKE @@ -329,8 +325,7 @@ config SWIOTLB config HOTPLUG_CPU bool "Support for enabling/disabling CPUs" - depends on SMP && HOTPLUG && EXPERIMENTAL && (PPC_PSERIES || \ - PPC_PMAC || PPC_POWERNV || (PPC_85xx && !PPC_E500MC)) + depends on SMP && HOTPLUG && EXPERIMENTAL && (PPC_PSERIES || PPC_PMAC || PPC_POWERNV) ---help--- Say Y here to be able to disable and re-enable individual CPUs at runtime on SMP machines. @@ -562,14 +557,6 @@ config SCHED_SMT when dealing with POWER5 cpus at a cost of slightly increased overhead in some places. If unsure say N here. -config PPC_DENORMALISATION - bool "PowerPC denormalisation exception handling" - depends on PPC_BOOK3S_64 - default "n" - ---help--- - Add support for handling denormalisation of single precision - values. Useful for bare metal only. If unsure say Y here. - config CMDLINE_BOOL bool "Default bootloader kernel arguments" diff --git a/trunk/arch/powerpc/boot/Makefile b/trunk/arch/powerpc/boot/Makefile index 6a15c968d214..b7d833382be4 100644 --- a/trunk/arch/powerpc/boot/Makefile +++ b/trunk/arch/powerpc/boot/Makefile @@ -107,7 +107,6 @@ src-boot := $(addprefix $(obj)/, $(src-boot)) obj-boot := $(addsuffix .o, $(basename $(src-boot))) obj-wlib := $(addsuffix .o, $(basename $(addprefix $(obj)/, $(src-wlib)))) obj-plat := $(addsuffix .o, $(basename $(addprefix $(obj)/, $(src-plat)))) -obj-plat: $(libfdt) quiet_cmd_copy_zlib = COPY $@ cmd_copy_zlib = sed "s@__used@@;s@]*\).*@\"\1\"@" $< > $@ diff --git a/trunk/arch/powerpc/boot/dts/fsl/e500mc_power_isa.dtsi b/trunk/arch/powerpc/boot/dts/fsl/e500mc_power_isa.dtsi deleted file mode 100644 index 870c6535a053..000000000000 --- a/trunk/arch/powerpc/boot/dts/fsl/e500mc_power_isa.dtsi +++ /dev/null @@ -1,58 +0,0 @@ -/* - * e500mc Power ISA Device Tree Source (include) - * - * Copyright 2012 Freescale Semiconductor Inc. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * * Neither the name of Freescale Semiconductor nor the - * names of its contributors may be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * - * ALTERNATIVELY, this software may be distributed under the terms of the - * GNU General Public License ("GPL") as published by the Free Software - * Foundation, either version 2 of that License or (at your option) any - * later version. - * - * THIS SOFTWARE IS PROVIDED BY Freescale Semiconductor "AS IS" AND ANY - * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL Freescale Semiconductor BE LIABLE FOR ANY - * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -/ { - cpus { - power-isa-version = "2.06"; - power-isa-b; // Base - power-isa-e; // Embedded - power-isa-atb; // Alternate Time Base - power-isa-cs; // Cache Specification - power-isa-ds; // Decorated Storage - power-isa-e.ed; // Embedded.Enhanced Debug - power-isa-e.pd; // Embedded.External PID - power-isa-e.hv; // Embedded.Hypervisor - power-isa-e.le; // Embedded.Little-Endian - power-isa-e.pm; // Embedded.Performance Monitor - power-isa-e.pc; // Embedded.Processor Control - power-isa-ecl; // Embedded Cache Locking - power-isa-exp; // External Proxy - power-isa-fp; // Floating Point - power-isa-fp.r; // Floating Point.Record - power-isa-mmc; // Memory Coherence - power-isa-scpm; // Store Conditional Page Mobility - power-isa-wt; // Wait - mmu-type = "power-embedded"; - }; -}; diff --git a/trunk/arch/powerpc/boot/dts/fsl/e500v2_power_isa.dtsi b/trunk/arch/powerpc/boot/dts/fsl/e500v2_power_isa.dtsi deleted file mode 100644 index f4928144d2c8..000000000000 --- a/trunk/arch/powerpc/boot/dts/fsl/e500v2_power_isa.dtsi +++ /dev/null @@ -1,52 +0,0 @@ -/* - * e500v2 Power ISA Device Tree Source (include) - * - * Copyright 2012 Freescale Semiconductor Inc. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * * Neither the name of Freescale Semiconductor nor the - * names of its contributors may be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * - * ALTERNATIVELY, this software may be distributed under the terms of the - * GNU General Public License ("GPL") as published by the Free Software - * Foundation, either version 2 of that License or (at your option) any - * later version. - * - * THIS SOFTWARE IS PROVIDED BY Freescale Semiconductor "AS IS" AND ANY - * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL Freescale Semiconductor BE LIABLE FOR ANY - * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -/ { - cpus { - power-isa-version = "2.03"; - power-isa-b; // Base - power-isa-e; // Embedded - power-isa-atb; // Alternate Time Base - power-isa-cs; // Cache Specification - power-isa-e.le; // Embedded.Little-Endian - power-isa-e.pm; // Embedded.Performance Monitor - power-isa-ecl; // Embedded Cache Locking - power-isa-mmc; // Memory Coherence - power-isa-sp; // Signal Processing Engine - power-isa-sp.fd; // SPE.Embedded Float Scalar Double - power-isa-sp.fs; // SPE.Embedded Float Scalar Single - power-isa-sp.fv; // SPE.Embedded Float Vector - mmu-type = "power-embedded"; - }; -}; diff --git a/trunk/arch/powerpc/boot/dts/fsl/e5500_power_isa.dtsi b/trunk/arch/powerpc/boot/dts/fsl/e5500_power_isa.dtsi deleted file mode 100644 index 3230212f7ad5..000000000000 --- a/trunk/arch/powerpc/boot/dts/fsl/e5500_power_isa.dtsi +++ /dev/null @@ -1,59 +0,0 @@ -/* - * e5500 Power ISA Device Tree Source (include) - * - * Copyright 2012 Freescale Semiconductor Inc. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * * Neither the name of Freescale Semiconductor nor the - * names of its contributors may be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * - * ALTERNATIVELY, this software may be distributed under the terms of the - * GNU General Public License ("GPL") as published by the Free Software - * Foundation, either version 2 of that License or (at your option) any - * later version. - * - * THIS SOFTWARE IS PROVIDED BY Freescale Semiconductor "AS IS" AND ANY - * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL Freescale Semiconductor BE LIABLE FOR ANY - * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -/ { - cpus { - power-isa-version = "2.06"; - power-isa-b; // Base - power-isa-e; // Embedded - power-isa-atb; // Alternate Time Base - power-isa-cs; // Cache Specification - power-isa-ds; // Decorated Storage - power-isa-e.ed; // Embedded.Enhanced Debug - power-isa-e.pd; // Embedded.External PID - power-isa-e.hv; // Embedded.Hypervisor - power-isa-e.le; // Embedded.Little-Endian - power-isa-e.pm; // Embedded.Performance Monitor - power-isa-e.pc; // Embedded.Processor Control - power-isa-ecl; // Embedded Cache Locking - power-isa-exp; // External Proxy - power-isa-fp; // Floating Point - power-isa-fp.r; // Floating Point.Record - power-isa-mmc; // Memory Coherence - power-isa-scpm; // Store Conditional Page Mobility - power-isa-wt; // Wait - power-isa-64; // 64-bit - mmu-type = "power-embedded"; - }; -}; diff --git a/trunk/arch/powerpc/boot/dts/fsl/mpc8536si-pre.dtsi b/trunk/arch/powerpc/boot/dts/fsl/mpc8536si-pre.dtsi index 152906f98a0f..7de45a784df6 100644 --- a/trunk/arch/powerpc/boot/dts/fsl/mpc8536si-pre.dtsi +++ b/trunk/arch/powerpc/boot/dts/fsl/mpc8536si-pre.dtsi @@ -33,9 +33,6 @@ */ /dts-v1/; - -/include/ "e500v2_power_isa.dtsi" - / { compatible = "fsl,MPC8536"; #address-cells = <2>; diff --git a/trunk/arch/powerpc/boot/dts/fsl/mpc8544si-pre.dtsi b/trunk/arch/powerpc/boot/dts/fsl/mpc8544si-pre.dtsi index 5a69bafb652a..8777f9239d9e 100644 --- a/trunk/arch/powerpc/boot/dts/fsl/mpc8544si-pre.dtsi +++ b/trunk/arch/powerpc/boot/dts/fsl/mpc8544si-pre.dtsi @@ -33,9 +33,6 @@ */ /dts-v1/; - -/include/ "e500v2_power_isa.dtsi" - / { compatible = "fsl,MPC8544"; #address-cells = <2>; diff --git a/trunk/arch/powerpc/boot/dts/fsl/mpc8548si-pre.dtsi b/trunk/arch/powerpc/boot/dts/fsl/mpc8548si-pre.dtsi index fc1ce977422b..720422d83529 100644 --- a/trunk/arch/powerpc/boot/dts/fsl/mpc8548si-pre.dtsi +++ b/trunk/arch/powerpc/boot/dts/fsl/mpc8548si-pre.dtsi @@ -33,9 +33,6 @@ */ /dts-v1/; - -/include/ "e500v2_power_isa.dtsi" - / { compatible = "fsl,MPC8548"; #address-cells = <2>; diff --git a/trunk/arch/powerpc/boot/dts/fsl/mpc8568si-pre.dtsi b/trunk/arch/powerpc/boot/dts/fsl/mpc8568si-pre.dtsi index 122ca3bd0b03..eacd62c5fe6c 100644 --- a/trunk/arch/powerpc/boot/dts/fsl/mpc8568si-pre.dtsi +++ b/trunk/arch/powerpc/boot/dts/fsl/mpc8568si-pre.dtsi @@ -33,9 +33,6 @@ */ /dts-v1/; - -/include/ "e500v2_power_isa.dtsi" - / { compatible = "fsl,MPC8568"; #address-cells = <2>; diff --git a/trunk/arch/powerpc/boot/dts/fsl/mpc8569si-pre.dtsi b/trunk/arch/powerpc/boot/dts/fsl/mpc8569si-pre.dtsi index 2cd15a2a0422..b07064d11930 100644 --- a/trunk/arch/powerpc/boot/dts/fsl/mpc8569si-pre.dtsi +++ b/trunk/arch/powerpc/boot/dts/fsl/mpc8569si-pre.dtsi @@ -33,9 +33,6 @@ */ /dts-v1/; - -/include/ "e500v2_power_isa.dtsi" - / { compatible = "fsl,MPC8569"; #address-cells = <2>; diff --git a/trunk/arch/powerpc/boot/dts/fsl/mpc8572si-pre.dtsi b/trunk/arch/powerpc/boot/dts/fsl/mpc8572si-pre.dtsi index 28c2a862be96..ca188326c2ca 100644 --- a/trunk/arch/powerpc/boot/dts/fsl/mpc8572si-pre.dtsi +++ b/trunk/arch/powerpc/boot/dts/fsl/mpc8572si-pre.dtsi @@ -33,9 +33,6 @@ */ /dts-v1/; - -/include/ "e500v2_power_isa.dtsi" - / { compatible = "fsl,MPC8572"; #address-cells = <2>; diff --git a/trunk/arch/powerpc/boot/dts/fsl/p1010si-pre.dtsi b/trunk/arch/powerpc/boot/dts/fsl/p1010si-pre.dtsi index 6e76f9b282a1..7354a8f90ea5 100644 --- a/trunk/arch/powerpc/boot/dts/fsl/p1010si-pre.dtsi +++ b/trunk/arch/powerpc/boot/dts/fsl/p1010si-pre.dtsi @@ -33,9 +33,6 @@ */ /dts-v1/; - -/include/ "e500v2_power_isa.dtsi" - / { compatible = "fsl,P1010"; #address-cells = <2>; diff --git a/trunk/arch/powerpc/boot/dts/fsl/p1020si-pre.dtsi b/trunk/arch/powerpc/boot/dts/fsl/p1020si-pre.dtsi index fed9c4c8d962..6f0376e554eb 100644 --- a/trunk/arch/powerpc/boot/dts/fsl/p1020si-pre.dtsi +++ b/trunk/arch/powerpc/boot/dts/fsl/p1020si-pre.dtsi @@ -33,9 +33,6 @@ */ /dts-v1/; - -/include/ "e500v2_power_isa.dtsi" - / { compatible = "fsl,P1020"; #address-cells = <2>; diff --git a/trunk/arch/powerpc/boot/dts/fsl/p1021si-pre.dtsi b/trunk/arch/powerpc/boot/dts/fsl/p1021si-pre.dtsi index 36161b500176..4abd54bc3308 100644 --- a/trunk/arch/powerpc/boot/dts/fsl/p1021si-pre.dtsi +++ b/trunk/arch/powerpc/boot/dts/fsl/p1021si-pre.dtsi @@ -33,9 +33,6 @@ */ /dts-v1/; - -/include/ "e500v2_power_isa.dtsi" - / { compatible = "fsl,P1021"; #address-cells = <2>; diff --git a/trunk/arch/powerpc/boot/dts/fsl/p1022si-pre.dtsi b/trunk/arch/powerpc/boot/dts/fsl/p1022si-pre.dtsi index 1956dea040cc..e930f4f7ca89 100644 --- a/trunk/arch/powerpc/boot/dts/fsl/p1022si-pre.dtsi +++ b/trunk/arch/powerpc/boot/dts/fsl/p1022si-pre.dtsi @@ -33,9 +33,6 @@ */ /dts-v1/; - -/include/ "e500v2_power_isa.dtsi" - / { compatible = "fsl,P1022"; #address-cells = <2>; diff --git a/trunk/arch/powerpc/boot/dts/fsl/p1023si-pre.dtsi b/trunk/arch/powerpc/boot/dts/fsl/p1023si-pre.dtsi index 132a1521921a..ac45f6d93385 100644 --- a/trunk/arch/powerpc/boot/dts/fsl/p1023si-pre.dtsi +++ b/trunk/arch/powerpc/boot/dts/fsl/p1023si-pre.dtsi @@ -33,9 +33,6 @@ */ /dts-v1/; - -/include/ "e500v2_power_isa.dtsi" - / { compatible = "fsl,P1023"; #address-cells = <2>; diff --git a/trunk/arch/powerpc/boot/dts/fsl/p2020si-pre.dtsi b/trunk/arch/powerpc/boot/dts/fsl/p2020si-pre.dtsi index 42bf3c6d25ca..3213288641d1 100644 --- a/trunk/arch/powerpc/boot/dts/fsl/p2020si-pre.dtsi +++ b/trunk/arch/powerpc/boot/dts/fsl/p2020si-pre.dtsi @@ -33,9 +33,6 @@ */ /dts-v1/; - -/include/ "e500v2_power_isa.dtsi" - / { compatible = "fsl,P2020"; #address-cells = <2>; diff --git a/trunk/arch/powerpc/boot/dts/fsl/p2041si-pre.dtsi b/trunk/arch/powerpc/boot/dts/fsl/p2041si-pre.dtsi index 7a2697d04549..2d0a40d6b10f 100644 --- a/trunk/arch/powerpc/boot/dts/fsl/p2041si-pre.dtsi +++ b/trunk/arch/powerpc/boot/dts/fsl/p2041si-pre.dtsi @@ -33,9 +33,6 @@ */ /dts-v1/; - -/include/ "e500mc_power_isa.dtsi" - / { compatible = "fsl,P2041"; #address-cells = <2>; diff --git a/trunk/arch/powerpc/boot/dts/fsl/p3041si-pre.dtsi b/trunk/arch/powerpc/boot/dts/fsl/p3041si-pre.dtsi index c9ca2c305cfe..136def3536b6 100644 --- a/trunk/arch/powerpc/boot/dts/fsl/p3041si-pre.dtsi +++ b/trunk/arch/powerpc/boot/dts/fsl/p3041si-pre.dtsi @@ -33,9 +33,6 @@ */ /dts-v1/; - -/include/ "e500mc_power_isa.dtsi" - / { compatible = "fsl,P3041"; #address-cells = <2>; diff --git a/trunk/arch/powerpc/boot/dts/fsl/p4080si-pre.dtsi b/trunk/arch/powerpc/boot/dts/fsl/p4080si-pre.dtsi index 493d9a056b5c..b9556ee3a639 100644 --- a/trunk/arch/powerpc/boot/dts/fsl/p4080si-pre.dtsi +++ b/trunk/arch/powerpc/boot/dts/fsl/p4080si-pre.dtsi @@ -33,9 +33,6 @@ */ /dts-v1/; - -/include/ "e500mc_power_isa.dtsi" - / { compatible = "fsl,P4080"; #address-cells = <2>; diff --git a/trunk/arch/powerpc/boot/dts/fsl/p5020si-pre.dtsi b/trunk/arch/powerpc/boot/dts/fsl/p5020si-pre.dtsi index 0a198b0a77e5..ae823a47584e 100644 --- a/trunk/arch/powerpc/boot/dts/fsl/p5020si-pre.dtsi +++ b/trunk/arch/powerpc/boot/dts/fsl/p5020si-pre.dtsi @@ -33,9 +33,6 @@ */ /dts-v1/; - -/include/ "e5500_power_isa.dtsi" - / { compatible = "fsl,P5020"; #address-cells = <2>; diff --git a/trunk/arch/powerpc/boot/dts/fsl/p5040si-post.dtsi b/trunk/arch/powerpc/boot/dts/fsl/p5040si-post.dtsi deleted file mode 100644 index db2c9a7b3a0e..000000000000 --- a/trunk/arch/powerpc/boot/dts/fsl/p5040si-post.dtsi +++ /dev/null @@ -1,320 +0,0 @@ -/* - * P5040 Silicon/SoC Device Tree Source (post include) - * - * Copyright 2012 Freescale Semiconductor Inc. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * * Neither the name of Freescale Semiconductor nor the - * names of its contributors may be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * - * ALTERNATIVELY, this software may be distributed under the terms of the - * GNU General Public License ("GPL") as published by the Free Software - * Foundation, either version 2 of that License or (at your option) any - * later version. - * - * This software is provided by Freescale Semiconductor "as is" and any - * express or implied warranties, including, but not limited to, the implied - * warranties of merchantability and fitness for a particular purpose are - * disclaimed. In no event shall Freescale Semiconductor be liable for any - * direct, indirect, incidental, special, exemplary, or consequential damages - * (including, but not limited to, procurement of substitute goods or services; - * loss of use, data, or profits; or business interruption) however caused and - * on any theory of liability, whether in contract, strict liability, or tort - * (including negligence or otherwise) arising in any way out of the use of this - * software, even if advised of the possibility of such damage. - */ - -&lbc { - compatible = "fsl,p5040-elbc", "fsl,elbc", "simple-bus"; - interrupts = <25 2 0 0>; - #address-cells = <2>; - #size-cells = <1>; -}; - -/* controller at 0x200000 */ -&pci0 { - compatible = "fsl,p5040-pcie", "fsl,qoriq-pcie-v2.4"; - device_type = "pci"; - #size-cells = <2>; - #address-cells = <3>; - bus-range = <0x0 0xff>; - clock-frequency = <33333333>; - interrupts = <16 2 1 15>; - pcie@0 { - reg = <0 0 0 0 0>; - #interrupt-cells = <1>; - #size-cells = <2>; - #address-cells = <3>; - device_type = "pci"; - interrupts = <16 2 1 15>; - interrupt-map-mask = <0xf800 0 0 7>; - interrupt-map = < - /* IDSEL 0x0 */ - 0000 0 0 1 &mpic 40 1 0 0 - 0000 0 0 2 &mpic 1 1 0 0 - 0000 0 0 3 &mpic 2 1 0 0 - 0000 0 0 4 &mpic 3 1 0 0 - >; - }; -}; - -/* controller at 0x201000 */ -&pci1 { - compatible = "fsl,p5040-pcie", "fsl,qoriq-pcie-v2.4"; - device_type = "pci"; - #size-cells = <2>; - #address-cells = <3>; - bus-range = <0 0xff>; - clock-frequency = <33333333>; - interrupts = <16 2 1 14>; - pcie@0 { - reg = <0 0 0 0 0>; - #interrupt-cells = <1>; - #size-cells = <2>; - #address-cells = <3>; - device_type = "pci"; - interrupts = <16 2 1 14>; - interrupt-map-mask = <0xf800 0 0 7>; - interrupt-map = < - /* IDSEL 0x0 */ - 0000 0 0 1 &mpic 41 1 0 0 - 0000 0 0 2 &mpic 5 1 0 0 - 0000 0 0 3 &mpic 6 1 0 0 - 0000 0 0 4 &mpic 7 1 0 0 - >; - }; -}; - -/* controller at 0x202000 */ -&pci2 { - compatible = "fsl,p5040-pcie", "fsl,qoriq-pcie-v2.4"; - device_type = "pci"; - #size-cells = <2>; - #address-cells = <3>; - bus-range = <0x0 0xff>; - clock-frequency = <33333333>; - interrupts = <16 2 1 13>; - pcie@0 { - reg = <0 0 0 0 0>; - #interrupt-cells = <1>; - #size-cells = <2>; - #address-cells = <3>; - device_type = "pci"; - interrupts = <16 2 1 13>; - interrupt-map-mask = <0xf800 0 0 7>; - interrupt-map = < - /* IDSEL 0x0 */ - 0000 0 0 1 &mpic 42 1 0 0 - 0000 0 0 2 &mpic 9 1 0 0 - 0000 0 0 3 &mpic 10 1 0 0 - 0000 0 0 4 &mpic 11 1 0 0 - >; - }; -}; - -&dcsr { - #address-cells = <1>; - #size-cells = <1>; - compatible = "fsl,dcsr", "simple-bus"; - - dcsr-epu@0 { - compatible = "fsl,dcsr-epu"; - interrupts = <52 2 0 0 - 84 2 0 0 - 85 2 0 0>; - reg = <0x0 0x1000>; - }; - dcsr-npc { - compatible = "fsl,dcsr-npc"; - reg = <0x1000 0x1000 0x1000000 0x8000>; - }; - dcsr-nxc@2000 { - compatible = "fsl,dcsr-nxc"; - reg = <0x2000 0x1000>; - }; - dcsr-corenet { - compatible = "fsl,dcsr-corenet"; - reg = <0x8000 0x1000 0xB0000 0x1000>; - }; - dcsr-dpaa@9000 { - compatible = "fsl,p5040-dcsr-dpaa", "fsl,dcsr-dpaa"; - reg = <0x9000 0x1000>; - }; - dcsr-ocn@11000 { - compatible = "fsl,p5040-dcsr-ocn", "fsl,dcsr-ocn"; - reg = <0x11000 0x1000>; - }; - dcsr-ddr@12000 { - compatible = "fsl,dcsr-ddr"; - dev-handle = <&ddr1>; - reg = <0x12000 0x1000>; - }; - dcsr-ddr@13000 { - compatible = "fsl,dcsr-ddr"; - dev-handle = <&ddr2>; - reg = <0x13000 0x1000>; - }; - dcsr-nal@18000 { - compatible = "fsl,p5040-dcsr-nal", "fsl,dcsr-nal"; - reg = <0x18000 0x1000>; - }; - dcsr-rcpm@22000 { - compatible = "fsl,p5040-dcsr-rcpm", "fsl,dcsr-rcpm"; - reg = <0x22000 0x1000>; - }; - dcsr-cpu-sb-proxy@40000 { - compatible = "fsl,dcsr-e5500-sb-proxy", "fsl,dcsr-cpu-sb-proxy"; - cpu-handle = <&cpu0>; - reg = <0x40000 0x1000>; - }; - dcsr-cpu-sb-proxy@41000 { - compatible = "fsl,dcsr-e5500-sb-proxy", "fsl,dcsr-cpu-sb-proxy"; - cpu-handle = <&cpu1>; - reg = <0x41000 0x1000>; - }; - dcsr-cpu-sb-proxy@42000 { - compatible = "fsl,dcsr-e5500-sb-proxy", "fsl,dcsr-cpu-sb-proxy"; - cpu-handle = <&cpu2>; - reg = <0x42000 0x1000>; - }; - dcsr-cpu-sb-proxy@43000 { - compatible = "fsl,dcsr-e5500-sb-proxy", "fsl,dcsr-cpu-sb-proxy"; - cpu-handle = <&cpu3>; - reg = <0x43000 0x1000>; - }; -}; - -&soc { - #address-cells = <1>; - #size-cells = <1>; - device_type = "soc"; - compatible = "simple-bus"; - - soc-sram-error { - compatible = "fsl,soc-sram-error"; - interrupts = <16 2 1 29>; - }; - - corenet-law@0 { - compatible = "fsl,corenet-law"; - reg = <0x0 0x1000>; - fsl,num-laws = <32>; - }; - - ddr1: memory-controller@8000 { - compatible = "fsl,qoriq-memory-controller-v4.5", "fsl,qoriq-memory-controller"; - reg = <0x8000 0x1000>; - interrupts = <16 2 1 23>; - }; - - ddr2: memory-controller@9000 { - compatible = "fsl,qoriq-memory-controller-v4.5","fsl,qoriq-memory-controller"; - reg = <0x9000 0x1000>; - interrupts = <16 2 1 22>; - }; - - cpc: l3-cache-controller@10000 { - compatible = "fsl,p5040-l3-cache-controller", "fsl,p4080-l3-cache-controller", "cache"; - reg = <0x10000 0x1000 - 0x11000 0x1000>; - interrupts = <16 2 1 27 - 16 2 1 26>; - }; - - corenet-cf@18000 { - compatible = "fsl,corenet-cf"; - reg = <0x18000 0x1000>; - interrupts = <16 2 1 31>; - fsl,ccf-num-csdids = <32>; - fsl,ccf-num-snoopids = <32>; - }; - - iommu@20000 { - compatible = "fsl,pamu-v1.0", "fsl,pamu"; - reg = <0x20000 0x5000>; - interrupts = < - 24 2 0 0 - 16 2 1 30>; - }; - -/include/ "qoriq-mpic.dtsi" - - guts: global-utilities@e0000 { - compatible = "fsl,p5040-device-config", "fsl,qoriq-device-config-1.0"; - reg = <0xe0000 0xe00>; - fsl,has-rstcr; - #sleep-cells = <1>; - fsl,liodn-bits = <12>; - }; - - pins: global-utilities@e0e00 { - compatible = "fsl,p5040-pin-control", "fsl,qoriq-pin-control-1.0"; - reg = <0xe0e00 0x200>; - #sleep-cells = <2>; - }; - - clockgen: global-utilities@e1000 { - compatible = "fsl,p5040-clockgen", "fsl,qoriq-clockgen-1.0"; - reg = <0xe1000 0x1000>; - clock-frequency = <0>; - }; - - rcpm: global-utilities@e2000 { - compatible = "fsl,p5040-rcpm", "fsl,qoriq-rcpm-1.0"; - reg = <0xe2000 0x1000>; - #sleep-cells = <1>; - }; - - sfp: sfp@e8000 { - compatible = "fsl,p5040-sfp", "fsl,qoriq-sfp-1.0"; - reg = <0xe8000 0x1000>; - }; - - serdes: serdes@ea000 { - compatible = "fsl,p5040-serdes"; - reg = <0xea000 0x1000>; - }; - -/include/ "qoriq-dma-0.dtsi" -/include/ "qoriq-dma-1.dtsi" -/include/ "qoriq-espi-0.dtsi" - spi@110000 { - fsl,espi-num-chipselects = <4>; - }; - -/include/ "qoriq-esdhc-0.dtsi" - sdhc@114000 { - sdhci,auto-cmd12; - }; - -/include/ "qoriq-i2c-0.dtsi" -/include/ "qoriq-i2c-1.dtsi" -/include/ "qoriq-duart-0.dtsi" -/include/ "qoriq-duart-1.dtsi" -/include/ "qoriq-gpio-0.dtsi" -/include/ "qoriq-usb2-mph-0.dtsi" - usb0: usb@210000 { - compatible = "fsl-usb2-mph-v1.6", "fsl,mpc85xx-usb2-mph", "fsl-usb2-mph"; - phy_type = "utmi"; - port0; - }; - -/include/ "qoriq-usb2-dr-0.dtsi" - usb1: usb@211000 { - compatible = "fsl-usb2-dr-v1.6", "fsl,mpc85xx-usb2-dr", "fsl-usb2-dr"; - dr_mode = "host"; - phy_type = "utmi"; - }; - -/include/ "qoriq-sata2-0.dtsi" -/include/ "qoriq-sata2-1.dtsi" -/include/ "qoriq-sec5.2-0.dtsi" -}; diff --git a/trunk/arch/powerpc/boot/dts/fsl/p5040si-pre.dtsi b/trunk/arch/powerpc/boot/dts/fsl/p5040si-pre.dtsi deleted file mode 100644 index 40ca943f5d1c..000000000000 --- a/trunk/arch/powerpc/boot/dts/fsl/p5040si-pre.dtsi +++ /dev/null @@ -1,114 +0,0 @@ -/* - * P5040 Silicon/SoC Device Tree Source (pre include) - * - * Copyright 2012 Freescale Semiconductor Inc. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * * Neither the name of Freescale Semiconductor nor the - * names of its contributors may be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * - * ALTERNATIVELY, this software may be distributed under the terms of the - * GNU General Public License ("GPL") as published by the Free Software - * Foundation, either version 2 of that License or (at your option) any - * later version. - * - * This software is provided by Freescale Semiconductor "as is" and any - * express or implied warranties, including, but not limited to, the implied - * warranties of merchantability and fitness for a particular purpose are - * disclaimed. In no event shall Freescale Semiconductor be liable for any - * direct, indirect, incidental, special, exemplary, or consequential damages - * (including, but not limited to, procurement of substitute goods or services; - * loss of use, data, or profits; or business interruption) however caused and - * on any theory of liability, whether in contract, strict liability, or tort - * (including negligence or otherwise) arising in any way out of the use of this - * software, even if advised of the possibility of such damage. - */ - -/dts-v1/; - -/include/ "e5500_power_isa.dtsi" - -/ { - compatible = "fsl,P5040"; - #address-cells = <2>; - #size-cells = <2>; - interrupt-parent = <&mpic>; - - aliases { - ccsr = &soc; - dcsr = &dcsr; - - serial0 = &serial0; - serial1 = &serial1; - serial2 = &serial2; - serial3 = &serial3; - pci0 = &pci0; - pci1 = &pci1; - pci2 = &pci2; - usb0 = &usb0; - usb1 = &usb1; - dma0 = &dma0; - dma1 = &dma1; - sdhc = &sdhc; - msi0 = &msi0; - msi1 = &msi1; - msi2 = &msi2; - - crypto = &crypto; - sec_jr0 = &sec_jr0; - sec_jr1 = &sec_jr1; - sec_jr2 = &sec_jr2; - sec_jr3 = &sec_jr3; - rtic_a = &rtic_a; - rtic_b = &rtic_b; - rtic_c = &rtic_c; - rtic_d = &rtic_d; - sec_mon = &sec_mon; - }; - - cpus { - #address-cells = <1>; - #size-cells = <0>; - - cpu0: PowerPC,e5500@0 { - device_type = "cpu"; - reg = <0>; - next-level-cache = <&L2_0>; - L2_0: l2-cache { - next-level-cache = <&cpc>; - }; - }; - cpu1: PowerPC,e5500@1 { - device_type = "cpu"; - reg = <1>; - next-level-cache = <&L2_1>; - L2_1: l2-cache { - next-level-cache = <&cpc>; - }; - }; - cpu2: PowerPC,e5500@2 { - device_type = "cpu"; - reg = <2>; - next-level-cache = <&L2_2>; - L2_2: l2-cache { - next-level-cache = <&cpc>; - }; - }; - cpu3: PowerPC,e5500@3 { - device_type = "cpu"; - reg = <3>; - next-level-cache = <&L2_3>; - L2_3: l2-cache { - next-level-cache = <&cpc>; - }; - }; - }; -}; diff --git a/trunk/arch/powerpc/boot/dts/fsl/qoriq-sec5.2-0.dtsi b/trunk/arch/powerpc/boot/dts/fsl/qoriq-sec5.2-0.dtsi deleted file mode 100644 index 7b2ab8a8c1f4..000000000000 --- a/trunk/arch/powerpc/boot/dts/fsl/qoriq-sec5.2-0.dtsi +++ /dev/null @@ -1,118 +0,0 @@ -/* - * QorIQ Sec/Crypto 5.2 device tree stub [ controller @ offset 0x300000 ] - * - * Copyright 2011-2012 Freescale Semiconductor Inc. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * * Neither the name of Freescale Semiconductor nor the - * names of its contributors may be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * - * ALTERNATIVELY, this software may be distributed under the terms of the - * GNU General Public License ("GPL") as published by the Free Software - * Foundation, either version 2 of that License or (at your option) any - * later version. - * - * THIS SOFTWARE IS PROVIDED BY Freescale Semiconductor ``AS IS'' AND ANY - * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL Freescale Semiconductor BE LIABLE FOR ANY - * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -crypto: crypto@300000 { - compatible = "fsl,sec-v5.2", "fsl,sec-v5.0", "fsl,sec-v4.0"; - #address-cells = <1>; - #size-cells = <1>; - reg = <0x300000 0x10000>; - ranges = <0 0x300000 0x10000>; - interrupts = <92 2 0 0>; - - sec_jr0: jr@1000 { - compatible = "fsl,sec-v5.2-job-ring", - "fsl,sec-v5.0-job-ring", - "fsl,sec-v4.0-job-ring"; - reg = <0x1000 0x1000>; - interrupts = <88 2 0 0>; - }; - - sec_jr1: jr@2000 { - compatible = "fsl,sec-v5.2-job-ring", - "fsl,sec-v5.0-job-ring", - "fsl,sec-v4.0-job-ring"; - reg = <0x2000 0x1000>; - interrupts = <89 2 0 0>; - }; - - sec_jr2: jr@3000 { - compatible = "fsl,sec-v5.2-job-ring", - "fsl,sec-v5.0-job-ring", - "fsl,sec-v4.0-job-ring"; - reg = <0x3000 0x1000>; - interrupts = <90 2 0 0>; - }; - - sec_jr3: jr@4000 { - compatible = "fsl,sec-v5.2-job-ring", - "fsl,sec-v5.0-job-ring", - "fsl,sec-v4.0-job-ring"; - reg = <0x4000 0x1000>; - interrupts = <91 2 0 0>; - }; - - rtic@6000 { - compatible = "fsl,sec-v5.2-rtic", - "fsl,sec-v5.0-rtic", - "fsl,sec-v4.0-rtic"; - #address-cells = <1>; - #size-cells = <1>; - reg = <0x6000 0x100>; - ranges = <0x0 0x6100 0xe00>; - - rtic_a: rtic-a@0 { - compatible = "fsl,sec-v5.2-rtic-memory", - "fsl,sec-v5.0-rtic-memory", - "fsl,sec-v4.0-rtic-memory"; - reg = <0x00 0x20 0x100 0x80>; - }; - - rtic_b: rtic-b@20 { - compatible = "fsl,sec-v5.2-rtic-memory", - "fsl,sec-v5.0-rtic-memory", - "fsl,sec-v4.0-rtic-memory"; - reg = <0x20 0x20 0x200 0x80>; - }; - - rtic_c: rtic-c@40 { - compatible = "fsl,sec-v5.2-rtic-memory", - "fsl,sec-v5.0-rtic-memory", - "fsl,sec-v4.0-rtic-memory"; - reg = <0x40 0x20 0x300 0x80>; - }; - - rtic_d: rtic-d@60 { - compatible = "fsl,sec-v5.2-rtic-memory", - "fsl,sec-v5.0-rtic-memory", - "fsl,sec-v4.0-rtic-memory"; - reg = <0x60 0x20 0x500 0x80>; - }; - }; -}; - -sec_mon: sec_mon@314000 { - compatible = "fsl,sec-v5.2-mon", "fsl,sec-v5.0-mon", "fsl,sec-v4.0-mon"; - reg = <0x314000 0x1000>; - interrupts = <93 2 0 0>; -}; diff --git a/trunk/arch/powerpc/boot/dts/mpc8536ds.dtsi b/trunk/arch/powerpc/boot/dts/mpc8536ds.dtsi index 7c3dde84d193..d304a2d68c62 100644 --- a/trunk/arch/powerpc/boot/dts/mpc8536ds.dtsi +++ b/trunk/arch/powerpc/boot/dts/mpc8536ds.dtsi @@ -132,10 +132,6 @@ reg = <0x68>; interrupts = <0 0x1 0 0>; }; - adt7461@4c { - compatible = "adi,adt7461"; - reg = <0x4c>; - }; }; spi@7000 { diff --git a/trunk/arch/powerpc/boot/dts/mpc8540ads.dts b/trunk/arch/powerpc/boot/dts/mpc8540ads.dts index 2d31863accf5..f99fb110c97f 100644 --- a/trunk/arch/powerpc/boot/dts/mpc8540ads.dts +++ b/trunk/arch/powerpc/boot/dts/mpc8540ads.dts @@ -11,8 +11,6 @@ /dts-v1/; -/include/ "fsl/e500v2_power_isa.dtsi" - / { model = "MPC8540ADS"; compatible = "MPC8540ADS", "MPC85xxADS"; diff --git a/trunk/arch/powerpc/boot/dts/mpc8541cds.dts b/trunk/arch/powerpc/boot/dts/mpc8541cds.dts index 1c03c2667373..0f5e93912799 100644 --- a/trunk/arch/powerpc/boot/dts/mpc8541cds.dts +++ b/trunk/arch/powerpc/boot/dts/mpc8541cds.dts @@ -11,8 +11,6 @@ /dts-v1/; -/include/ "fsl/e500v2_power_isa.dtsi" - / { model = "MPC8541CDS"; compatible = "MPC8541CDS", "MPC85xxCDS"; diff --git a/trunk/arch/powerpc/boot/dts/mpc8544ds.dts b/trunk/arch/powerpc/boot/dts/mpc8544ds.dts index ed38874c3a36..e934987e882b 100644 --- a/trunk/arch/powerpc/boot/dts/mpc8544ds.dts +++ b/trunk/arch/powerpc/boot/dts/mpc8544ds.dts @@ -20,10 +20,8 @@ reg = <0 0 0 0>; // Filled by U-Boot }; - board_lbc: lbc: localbus@e0005000 { + lbc: localbus@e0005000 { reg = <0 0xe0005000 0 0x1000>; - - ranges = <0x0 0x0 0x0 0xff800000 0x800000>; }; board_soc: soc: soc8544@e0000000 { diff --git a/trunk/arch/powerpc/boot/dts/mpc8544ds.dtsi b/trunk/arch/powerpc/boot/dts/mpc8544ds.dtsi index b219d035d794..77ebc9f1d37c 100644 --- a/trunk/arch/powerpc/boot/dts/mpc8544ds.dtsi +++ b/trunk/arch/powerpc/boot/dts/mpc8544ds.dtsi @@ -32,45 +32,6 @@ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -&board_lbc { - nor@0,0 { - #address-cells = <1>; - #size-cells = <1>; - compatible = "cfi-flash"; - reg = <0x0 0x0 0x800000>; - bank-width = <2>; - device-width = <1>; - - partition@0 { - reg = <0x0 0x10000>; - label = "dtb-nor"; - }; - - partition@20000 { - reg = <0x20000 0x30000>; - label = "diagnostic-nor"; - read-only; - }; - - partition@200000 { - reg = <0x200000 0x200000>; - label = "dink-nor"; - read-only; - }; - - partition@400000 { - reg = <0x400000 0x380000>; - label = "kernel-nor"; - }; - - partition@780000 { - reg = <0x780000 0x80000>; - label = "u-boot-nor"; - read-only; - }; - }; -}; - &board_soc { enet0: ethernet@24000 { phy-handle = <&phy0>; diff --git a/trunk/arch/powerpc/boot/dts/mpc8555cds.dts b/trunk/arch/powerpc/boot/dts/mpc8555cds.dts index 36a7ea138c2f..fe10438613d6 100644 --- a/trunk/arch/powerpc/boot/dts/mpc8555cds.dts +++ b/trunk/arch/powerpc/boot/dts/mpc8555cds.dts @@ -11,8 +11,6 @@ /dts-v1/; -/include/ "fsl/e500v2_power_isa.dtsi" - / { model = "MPC8555CDS"; compatible = "MPC8555CDS", "MPC85xxCDS"; diff --git a/trunk/arch/powerpc/boot/dts/mpc8560ads.dts b/trunk/arch/powerpc/boot/dts/mpc8560ads.dts index 1a43f5a968f5..6e85e1ba0851 100644 --- a/trunk/arch/powerpc/boot/dts/mpc8560ads.dts +++ b/trunk/arch/powerpc/boot/dts/mpc8560ads.dts @@ -11,8 +11,6 @@ /dts-v1/; -/include/ "fsl/e500v2_power_isa.dtsi" - / { model = "MPC8560ADS"; compatible = "MPC8560ADS", "MPC85xxADS"; diff --git a/trunk/arch/powerpc/boot/dts/o2d.dts b/trunk/arch/powerpc/boot/dts/o2d.dts deleted file mode 100644 index 9f6dd4d889b3..000000000000 --- a/trunk/arch/powerpc/boot/dts/o2d.dts +++ /dev/null @@ -1,47 +0,0 @@ -/* - * O2D Device Tree Source - * - * Copyright (C) 2012 DENX Software Engineering - * Anatolij Gustschin - * - * 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/ "o2d.dtsi" - -/ { - model = "ifm,o2d"; - compatible = "ifm,o2d"; - - memory { - reg = <0x00000000 0x08000000>; // 128MB - }; - - localbus { - ranges = <0 0 0xfc000000 0x02000000 - 3 0 0xe3000000 0x00100000>; - - flash@0,0 { - compatible = "cfi-flash"; - reg = <0 0 0x02000000>; - bank-width = <2>; - device-width = <2>; - #size-cells = <1>; - #address-cells = <1>; - - partition@60000 { - label = "kernel"; - reg = <0x00060000 0x00260000>; - read-only; - }; - /* o2d specific partitions */ - partition@2c0000 { - label = "o2d user defined"; - reg = <0x002c0000 0x01d40000>; - }; - }; - }; -}; diff --git a/trunk/arch/powerpc/boot/dts/o2d.dtsi b/trunk/arch/powerpc/boot/dts/o2d.dtsi deleted file mode 100644 index 3444eb8f0ade..000000000000 --- a/trunk/arch/powerpc/boot/dts/o2d.dtsi +++ /dev/null @@ -1,139 +0,0 @@ -/* - * O2D base Device Tree Source - * - * Copyright (C) 2012 DENX Software Engineering - * Anatolij Gustschin - * - * 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/ "mpc5200b.dtsi" - -/ { - model = "ifm,o2d"; - compatible = "ifm,o2d"; - - memory { - reg = <0x00000000 0x04000000>; // 64MB - }; - - soc5200@f0000000 { - - gpio_simple: gpio@b00 { - }; - - timer@600 { // General Purpose Timer - #gpio-cells = <2>; - gpio-controller; - fsl,has-wdt; - fsl,wdt-on-boot = <0>; - }; - - timer@610 { - #gpio-cells = <2>; - gpio-controller; - }; - - timer7: timer@670 { - }; - - rtc@800 { - status = "disabled"; - }; - - psc@2000 { // PSC1 - compatible = "fsl,mpc5200b-psc-spi","fsl,mpc5200-psc-spi"; - #address-cells = <1>; - #size-cells = <0>; - cell-index = <0>; - - spidev@0 { - compatible = "spidev"; - spi-max-frequency = <250000>; - reg = <0>; - }; - }; - - psc@2200 { // PSC2 - status = "disabled"; - }; - - psc@2400 { // PSC3 - status = "disabled"; - }; - - psc@2600 { // PSC4 - compatible = "fsl,mpc5200b-psc-uart","fsl,mpc5200-psc-uart"; - }; - - psc@2800 { // PSC5 - compatible = "fsl,mpc5200b-psc-uart","fsl,mpc5200-psc-uart"; - }; - - psc@2c00 { // PSC6 - status = "disabled"; - }; - - ethernet@3000 { - phy-handle = <&phy0>; - }; - - mdio@3000 { - phy0: ethernet-phy@0 { - reg = <0>; - }; - }; - - sclpc@3c00 { - compatible = "fsl,mpc5200-lpbfifo"; - reg = <0x3c00 0x60>; - interrupts = <3 23 0>; - }; - }; - - localbus { - ranges = <0 0 0xff000000 0x01000000 - 3 0 0xe3000000 0x00100000>; - - // flash device at LocalPlus Bus CS0 - flash@0,0 { - compatible = "cfi-flash"; - reg = <0 0 0x01000000>; - bank-width = <1>; - device-width = <2>; - #size-cells = <1>; - #address-cells = <1>; - no-unaligned-direct-access; - - /* common layout for all machines */ - partition@0 { - label = "u-boot"; - reg = <0x00000000 0x00040000>; - read-only; - }; - partition@40000 { - label = "env"; - reg = <0x00040000 0x00020000>; - read-only; - }; - }; - - csi@3,0 { - compatible = "ifm,o2d-csi"; - reg = <3 0 0x00100000>; - ifm,csi-clk-handle = <&timer7>; - gpios = <&gpio_simple 23 0 /* imag_capture */ - &gpio_simple 26 0 /* imag_reset */ - &gpio_simple 29 0>; /* imag_master_en */ - - interrupts = <1 1 2>; /* IRQ1, edge falling */ - - ifm,csi-addr-bus-width = <24>; - ifm,csi-data-bus-width = <8>; - ifm,csi-wait-cycles = <0>; - }; - }; -}; diff --git a/trunk/arch/powerpc/boot/dts/o2d300.dts b/trunk/arch/powerpc/boot/dts/o2d300.dts deleted file mode 100644 index 29affe0f0da3..000000000000 --- a/trunk/arch/powerpc/boot/dts/o2d300.dts +++ /dev/null @@ -1,52 +0,0 @@ -/* - * O2D300 Device Tree Source - * - * Copyright (C) 2012 DENX Software Engineering - * Anatolij Gustschin - * - * 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/ "o2d.dtsi" - -/ { - model = "ifm,o2d300"; - compatible = "ifm,o2d"; - - localbus { - ranges = <0 0 0xfc000000 0x02000000 - 3 0 0xe3000000 0x00100000>; - flash@0,0 { - compatible = "cfi-flash"; - reg = <0 0 0x02000000>; - bank-width = <2>; - device-width = <2>; - #size-cells = <1>; - #address-cells = <1>; - - partition@40000 { - label = "env_1"; - reg = <0x00040000 0x00020000>; - read-only; - }; - partition@60000 { - label = "env_2"; - reg = <0x00060000 0x00020000>; - read-only; - }; - partition@80000 { - label = "kernel"; - reg = <0x00080000 0x00260000>; - read-only; - }; - /* o2d300 specific partitions */ - partition@2e0000 { - label = "o2d300 user defined"; - reg = <0x002e0000 0x01d20000>; - }; - }; - }; -}; diff --git a/trunk/arch/powerpc/boot/dts/o2dnt2.dts b/trunk/arch/powerpc/boot/dts/o2dnt2.dts deleted file mode 100644 index a0f5b97a4f06..000000000000 --- a/trunk/arch/powerpc/boot/dts/o2dnt2.dts +++ /dev/null @@ -1,48 +0,0 @@ -/* - * O2DNT2 Device Tree Source - * - * Copyright (C) 2012 DENX Software Engineering - * Anatolij Gustschin - * - * 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/ "o2d.dtsi" - -/ { - model = "ifm,o2dnt2"; - compatible = "ifm,o2d"; - - memory { - reg = <0x00000000 0x08000000>; // 128MB - }; - - localbus { - ranges = <0 0 0xfc000000 0x02000000 - 3 0 0xe3000000 0x00100000>; - - flash@0,0 { - compatible = "cfi-flash"; - reg = <0 0 0x02000000>; - bank-width = <2>; - device-width = <2>; - #size-cells = <1>; - #address-cells = <1>; - - partition@60000 { - label = "kernel"; - reg = <0x00060000 0x00260000>; - read-only; - }; - - /* o2dnt2 specific partitions */ - partition@2c0000 { - label = "o2dnt2 user defined"; - reg = <0x002c0000 0x01d40000>; - }; - }; - }; -}; diff --git a/trunk/arch/powerpc/boot/dts/o2i.dts b/trunk/arch/powerpc/boot/dts/o2i.dts deleted file mode 100644 index e3cc99d1360b..000000000000 --- a/trunk/arch/powerpc/boot/dts/o2i.dts +++ /dev/null @@ -1,33 +0,0 @@ -/* - * O2I Device Tree Source - * - * Copyright (C) 2012 DENX Software Engineering - * Anatolij Gustschin - * - * 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/ "o2d.dtsi" - -/ { - model = "ifm,o2i"; - compatible = "ifm,o2d"; - - localbus { - flash@0,0 { - partition@60000 { - label = "kernel"; - reg = <0x00060000 0x00260000>; - read-only; - }; - /* o2i specific partitions */ - partition@2c0000 { - label = "o2i user defined"; - reg = <0x002c0000 0x00d40000>; - }; - }; - }; -}; diff --git a/trunk/arch/powerpc/boot/dts/o2mnt.dts b/trunk/arch/powerpc/boot/dts/o2mnt.dts deleted file mode 100644 index d91859a9e940..000000000000 --- a/trunk/arch/powerpc/boot/dts/o2mnt.dts +++ /dev/null @@ -1,33 +0,0 @@ -/* - * O2MNT Device Tree Source - * - * Copyright (C) 2012 DENX Software Engineering - * Anatolij Gustschin - * - * 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/ "o2d.dtsi" - -/ { - model = "ifm,o2mnt"; - compatible = "ifm,o2d"; - - localbus { - flash@0,0 { - partition@60000 { - label = "kernel"; - reg = <0x00060000 0x00260000>; - read-only; - }; - /* add o2mnt specific partitions */ - partition@2c0000 { - label = "o2mnt user defined"; - reg = <0x002c0000 0x00d40000>; - }; - }; - }; -}; diff --git a/trunk/arch/powerpc/boot/dts/o3dnt.dts b/trunk/arch/powerpc/boot/dts/o3dnt.dts deleted file mode 100644 index acce49326491..000000000000 --- a/trunk/arch/powerpc/boot/dts/o3dnt.dts +++ /dev/null @@ -1,48 +0,0 @@ -/* - * O3DNT Device Tree Source - * - * Copyright (C) 2012 DENX Software Engineering - * Anatolij Gustschin - * - * 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/ "o2d.dtsi" - -/ { - model = "ifm,o3dnt"; - compatible = "ifm,o2d"; - - memory { - reg = <0x00000000 0x04000000>; // 64MB - }; - - localbus { - ranges = <0 0 0xfc000000 0x01000000 - 3 0 0xe3000000 0x00100000>; - - flash@0,0 { - compatible = "cfi-flash"; - reg = <0 0 0x01000000>; - bank-width = <2>; - device-width = <2>; - #size-cells = <1>; - #address-cells = <1>; - - partition@60000 { - label = "kernel"; - reg = <0x00060000 0x00260000>; - read-only; - }; - - /* o3dnt specific partitions */ - partition@2c0000 { - label = "o3dnt user defined"; - reg = <0x002c0000 0x00d40000>; - }; - }; - }; -}; diff --git a/trunk/arch/powerpc/boot/dts/p1020rdb_camp_core0.dts b/trunk/arch/powerpc/boot/dts/p1020rdb_camp_core0.dts new file mode 100644 index 000000000000..41b4585c5da8 --- /dev/null +++ b/trunk/arch/powerpc/boot/dts/p1020rdb_camp_core0.dts @@ -0,0 +1,63 @@ +/* + * P1020 RDB Core0 Device Tree Source in CAMP mode. + * + * In CAMP mode, each core needs to have its own dts. Only mpic and L2 cache + * can be shared, all the other devices must be assigned to one core only. + * This dts file allows core0 to have memory, l2, i2c, spi, gpio, tdm, dma, usb, + * eth1, eth2, sdhc, crypto, global-util, message, pci0, pci1, msi. + * + * Please note to add "-b 0" for core0's dts compiling. + * + * Copyright 2011 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 as published by the + * Free Software Foundation; either version 2 of the License, or (at your + * option) any later version. + */ + +/include/ "p1020rdb.dts" + +/ { + model = "fsl,P1020RDB"; + compatible = "fsl,P1020RDB", "fsl,MPC85XXRDB-CAMP"; + + aliases { + ethernet1 = &enet1; + ethernet2 = &enet2; + serial0 = &serial0; + pci0 = &pci0; + pci1 = &pci1; + }; + + cpus { + PowerPC,P1020@1 { + status = "disabled"; + }; + }; + + memory { + device_type = "memory"; + }; + + localbus@ffe05000 { + status = "disabled"; + }; + + soc@ffe00000 { + serial1: serial@4600 { + status = "disabled"; + }; + + enet0: ethernet@b0000 { + status = "disabled"; + }; + + mpic: pic@40000 { + protected-sources = < + 42 29 30 34 /* serial1, enet0-queue-group0 */ + 17 18 24 45 /* enet0-queue-group1, crypto */ + >; + }; + }; +}; diff --git a/trunk/arch/powerpc/boot/dts/p1020rdb_camp_core1.dts b/trunk/arch/powerpc/boot/dts/p1020rdb_camp_core1.dts new file mode 100644 index 000000000000..517453821884 --- /dev/null +++ b/trunk/arch/powerpc/boot/dts/p1020rdb_camp_core1.dts @@ -0,0 +1,141 @@ +/* + * P1020 RDB Core1 Device Tree Source in CAMP mode. + * + * In CAMP mode, each core needs to have its own dts. Only mpic and L2 cache + * can be shared, all the other devices must be assigned to one core only. + * This dts allows core1 to have l2, eth0, crypto. + * + * Please note to add "-b 1" for core1's dts compiling. + * + * Copyright 2011 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 as published by the + * Free Software Foundation; either version 2 of the License, or (at your + * option) any later version. + */ + +/include/ "p1020rdb.dts" + +/ { + model = "fsl,P1020RDB"; + compatible = "fsl,P1020RDB", "fsl,MPC85XXRDB-CAMP"; + + aliases { + ethernet0 = &enet0; + serial0 = &serial1; + }; + + cpus { + PowerPC,P1020@0 { + status = "disabled"; + }; + }; + + memory { + device_type = "memory"; + }; + + localbus@ffe05000 { + status = "disabled"; + }; + + soc@ffe00000 { + ecm-law@0 { + status = "disabled"; + }; + + ecm@1000 { + status = "disabled"; + }; + + memory-controller@2000 { + status = "disabled"; + }; + + i2c@3000 { + status = "disabled"; + }; + + i2c@3100 { + status = "disabled"; + }; + + serial0: serial@4500 { + status = "disabled"; + }; + + spi@7000 { + status = "disabled"; + }; + + gpio: gpio-controller@f000 { + status = "disabled"; + }; + + dma@21300 { + status = "disabled"; + }; + + mdio@24000 { + status = "disabled"; + }; + + mdio@25000 { + status = "disabled"; + }; + + enet1: ethernet@b1000 { + status = "disabled"; + }; + + enet2: ethernet@b2000 { + status = "disabled"; + }; + + usb@22000 { + status = "disabled"; + }; + + sdhci@2e000 { + status = "disabled"; + }; + + mpic: pic@40000 { + protected-sources = < + 16 /* ecm, mem, L2, pci0, pci1 */ + 43 42 59 /* i2c, serial0, spi */ + 47 63 62 /* gpio, tdm */ + 20 21 22 23 /* dma */ + 03 02 /* mdio */ + 35 36 40 /* enet1-queue-group0 */ + 51 52 67 /* enet1-queue-group1 */ + 31 32 33 /* enet2-queue-group0 */ + 25 26 27 /* enet2-queue-group1 */ + 28 72 58 /* usb, sdhci, crypto */ + 0xb0 0xb1 0xb2 /* message */ + 0xb3 0xb4 0xb5 + 0xb6 0xb7 + 0xe0 0xe1 0xe2 /* msi */ + 0xe3 0xe4 0xe5 + 0xe6 0xe7 /* sdhci, crypto , pci */ + >; + }; + + msi@41600 { + status = "disabled"; + }; + + global-utilities@e0000 { //global utilities block + status = "disabled"; + }; + }; + + pci0: pcie@ffe09000 { + status = "disabled"; + }; + + pci1: pcie@ffe0a000 { + status = "disabled"; + }; +}; diff --git a/trunk/arch/powerpc/boot/dts/p1022ds.dtsi b/trunk/arch/powerpc/boot/dts/p1022ds.dtsi index 873da350d01b..c3344b04d8ff 100644 --- a/trunk/arch/powerpc/boot/dts/p1022ds.dtsi +++ b/trunk/arch/powerpc/boot/dts/p1022ds.dtsi @@ -149,10 +149,6 @@ compatible = "dallas,ds1339"; reg = <0x68>; }; - adt7461@4c { - compatible = "adi,adt7461"; - reg = <0x4c>; - }; }; spi@7000 { diff --git a/trunk/arch/powerpc/boot/dts/p1022rdk.dts b/trunk/arch/powerpc/boot/dts/p1022rdk.dts deleted file mode 100644 index 51d82de223f3..000000000000 --- a/trunk/arch/powerpc/boot/dts/p1022rdk.dts +++ /dev/null @@ -1,188 +0,0 @@ -/* - * P1022 RDK 32-bit Physical Address Map Device Tree Source - * - * Copyright 2012 Freescale Semiconductor Inc. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * * Neither the name of Freescale Semiconductor nor the - * names of its contributors may be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * - * ALTERNATIVELY, this software may be distributed under the terms of the - * GNU General Public License ("GPL") as published by the Free Software - * Foundation, either version 2 of that License or (at your option) any - * later version. - * - * THIS SOFTWARE IS PROVIDED BY Freescale Semiconductor "AS IS" AND ANY - * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL Freescale Semiconductor BE LIABLE FOR ANY - * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -/include/ "fsl/p1022si-pre.dtsi" -/ { - model = "fsl,P1022RDK"; - compatible = "fsl,P1022RDK"; - - memory { - device_type = "memory"; - }; - - board_lbc: lbc: localbus@ffe05000 { - /* The P1022 RDK does not have any localbus devices */ - status = "disabled"; - }; - - board_soc: soc: soc@ffe00000 { - ranges = <0x0 0x0 0xffe00000 0x100000>; - - i2c@3100 { - wm8960:codec@1a { - compatible = "wlf,wm8960"; - reg = <0x1a>; - /* MCLK source is a stand-alone oscillator */ - clock-frequency = <12288000>; - }; - rtc@68 { - compatible = "stm,m41t62"; - reg = <0x68>; - }; - adt7461@4c{ - compatible = "adi,adt7461"; - reg = <0x4c>; - }; - zl6100@21{ - compatible = "isil,zl6100"; - reg = <0x21>; - }; - zl6100@24{ - compatible = "isil,zl6100"; - reg = <0x24>; - }; - zl6100@26{ - compatible = "isil,zl6100"; - reg = <0x26>; - }; - zl6100@29{ - compatible = "isil,zl6100"; - reg = <0x29>; - }; - }; - - spi@7000 { - flash@0 { - #address-cells = <1>; - #size-cells = <1>; - compatible = "spansion,m25p80"; - reg = <0>; - spi-max-frequency = <1000000>; - partition@0 { - label = "full-spi-flash"; - reg = <0x00000000 0x00100000>; - }; - }; - }; - - ssi@15000 { - fsl,mode = "i2s-slave"; - codec-handle = <&wm8960>; - }; - - usb@22000 { - phy_type = "ulpi"; - }; - - usb@23000 { - phy_type = "ulpi"; - }; - - mdio@24000 { - phy0: ethernet-phy@0 { - interrupts = <3 1 0 0>; - reg = <0x1>; - }; - phy1: ethernet-phy@1 { - interrupts = <9 1 0 0>; - reg = <0x2>; - }; - }; - - mdio@25000 { - tbi0: tbi-phy@11 { - reg = <0x11>; - device_type = "tbi-phy"; - }; - }; - - ethernet@b0000 { - phy-handle = <&phy0>; - phy-connection-type = "rgmii-id"; - }; - - ethernet@b1000 { - phy-handle = <&phy1>; - tbi-handle = <&tbi0>; - phy-connection-type = "sgmii"; - }; - }; - - pci0: pcie@ffe09000 { - ranges = <0x2000000 0x0 0xe0000000 0 0xa0000000 0x0 0x20000000 - 0x1000000 0x0 0x00000000 0 0xffc10000 0x0 0x10000>; - reg = <0x0 0xffe09000 0 0x1000>; - pcie@0 { - ranges = <0x2000000 0x0 0xe0000000 - 0x2000000 0x0 0xe0000000 - 0x0 0x20000000 - - 0x1000000 0x0 0x0 - 0x1000000 0x0 0x0 - 0x0 0x100000>; - }; - }; - - pci1: pcie@ffe0a000 { - ranges = <0x2000000 0x0 0xe0000000 0 0xc0000000 0x0 0x20000000 - 0x1000000 0x0 0x00000000 0 0xffc20000 0x0 0x10000>; - reg = <0 0xffe0a000 0 0x1000>; - pcie@0 { - ranges = <0x2000000 0x0 0xe0000000 - 0x2000000 0x0 0xe0000000 - 0x0 0x20000000 - - 0x1000000 0x0 0x0 - 0x1000000 0x0 0x0 - 0x0 0x100000>; - }; - }; - - pci2: pcie@ffe0b000 { - ranges = <0x2000000 0x0 0xe0000000 0 0x80000000 0x0 0x20000000 - 0x1000000 0x0 0x00000000 0 0xffc00000 0x0 0x10000>; - reg = <0 0xffe0b000 0 0x1000>; - pcie@0 { - ranges = <0x2000000 0x0 0xe0000000 - 0x2000000 0x0 0xe0000000 - 0x0 0x20000000 - - 0x1000000 0x0 0x0 - 0x1000000 0x0 0x0 - 0x0 0x100000>; - }; - }; -}; - -/include/ "fsl/p1022si-post.dtsi" diff --git a/trunk/arch/powerpc/boot/dts/p2020rdb_camp_core0.dts b/trunk/arch/powerpc/boot/dts/p2020rdb_camp_core0.dts new file mode 100644 index 000000000000..66aac864c4cc --- /dev/null +++ b/trunk/arch/powerpc/boot/dts/p2020rdb_camp_core0.dts @@ -0,0 +1,67 @@ +/* + * P2020 RDB Core0 Device Tree Source in CAMP mode. + * + * In CAMP mode, each core needs to have its own dts. Only mpic and L2 cache + * can be shared, all the other devices must be assigned to one core only. + * This dts file allows core0 to have memory, l2, i2c, spi, gpio, dma1, usb, + * eth1, eth2, sdhc, crypto, global-util, pci0. + * + * Copyright 2009-2011 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 as published by the + * Free Software Foundation; either version 2 of the License, or (at your + * option) any later version. + */ + +/include/ "p2020rdb.dts" + +/ { + model = "fsl,P2020RDB"; + compatible = "fsl,P2020RDB", "fsl,MPC85XXRDB-CAMP"; + + cpus { + PowerPC,P2020@1 { + status = "disabled"; + }; + }; + + localbus@ffe05000 { + status = "disabled"; + }; + + soc@ffe00000 { + serial1: serial@4600 { + status = "disabled"; + }; + + dma@c300 { + status = "disabled"; + }; + + enet0: ethernet@24000 { + status = "disabled"; + }; + + mpic: pic@40000 { + protected-sources = < + 42 76 77 78 79 /* serial1 , dma2 */ + 29 30 34 26 /* enet0, pci1 */ + 0xe0 0xe1 0xe2 0xe3 /* msi */ + 0xe4 0xe5 0xe6 0xe7 + >; + }; + + msi@41600 { + status = "disabled"; + }; + }; + + pci0: pcie@ffe08000 { + status = "disabled"; + }; + + pci2: pcie@ffe0a000 { + status = "disabled"; + }; +}; diff --git a/trunk/arch/powerpc/boot/dts/p2020rdb_camp_core1.dts b/trunk/arch/powerpc/boot/dts/p2020rdb_camp_core1.dts new file mode 100644 index 000000000000..9bd8ef493dd2 --- /dev/null +++ b/trunk/arch/powerpc/boot/dts/p2020rdb_camp_core1.dts @@ -0,0 +1,125 @@ +/* + * P2020 RDB Core1 Device Tree Source in CAMP mode. + * + * In CAMP mode, each core needs to have its own dts. Only mpic and L2 cache + * can be shared, all the other devices must be assigned to one core only. + * This dts allows core1 to have l2, dma2, eth0, pci1, msi. + * + * Please note to add "-b 1" for core1's dts compiling. + * + * Copyright 2009-2011 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 as published by the + * Free Software Foundation; either version 2 of the License, or (at your + * option) any later version. + */ + +/include/ "p2020rdb.dts" + +/ { + model = "fsl,P2020RDB"; + compatible = "fsl,P2020RDB", "fsl,MPC85XXRDB-CAMP"; + + cpus { + PowerPC,P2020@0 { + status = "disabled"; + }; + }; + + localbus@ffe05000 { + status = "disabled"; + }; + + soc@ffe00000 { + ecm-law@0 { + status = "disabled"; + }; + + ecm@1000 { + status = "disabled"; + }; + + memory-controller@2000 { + status = "disabled"; + }; + + i2c@3000 { + status = "disabled"; + }; + + i2c@3100 { + status = "disabled"; + }; + + serial0: serial@4500 { + status = "disabled"; + }; + + spi@7000 { + status = "disabled"; + }; + + gpio: gpio-controller@f000 { + status = "disabled"; + }; + + dma@21300 { + status = "disabled"; + }; + + usb@22000 { + status = "disabled"; + }; + + mdio@24520 { + status = "disabled"; + }; + + mdio@25520 { + status = "disabled"; + }; + + mdio@26520 { + status = "disabled"; + }; + + enet1: ethernet@25000 { + status = "disabled"; + }; + + enet2: ethernet@26000 { + status = "disabled"; + }; + + sdhci@2e000 { + status = "disabled"; + }; + + crypto@30000 { + status = "disabled"; + }; + + mpic: pic@40000 { + protected-sources = < + 17 18 43 42 59 47 /*ecm, mem, i2c, serial0, spi,gpio */ + 16 20 21 22 23 28 /* L2, dma1, USB */ + 03 35 36 40 31 32 33 /* mdio, enet1, enet2 */ + 72 45 58 25 /* sdhci, crypto , pci */ + >; + }; + + global-utilities@e0000 { //global utilities block + status = "disabled"; + }; + + }; + + pci0: pcie@ffe08000 { + status = "disabled"; + }; + + pci1: pcie@ffe09000 { + status = "disabled"; + }; +}; diff --git a/trunk/arch/powerpc/boot/dts/p2041rdb.dts b/trunk/arch/powerpc/boot/dts/p2041rdb.dts index d97ad74c7279..baab0347dab0 100644 --- a/trunk/arch/powerpc/boot/dts/p2041rdb.dts +++ b/trunk/arch/powerpc/boot/dts/p2041rdb.dts @@ -94,10 +94,6 @@ compatible = "pericom,pt7c4338"; reg = <0x68>; }; - adt7461@4c { - compatible = "adi,adt7461"; - reg = <0x4c>; - }; }; i2c@118100 { diff --git a/trunk/arch/powerpc/boot/dts/p3041ds.dts b/trunk/arch/powerpc/boot/dts/p3041ds.dts index 2fed3bc0b990..6cdcadc80c30 100644 --- a/trunk/arch/powerpc/boot/dts/p3041ds.dts +++ b/trunk/arch/powerpc/boot/dts/p3041ds.dts @@ -98,10 +98,6 @@ reg = <0x68>; interrupts = <0x1 0x1 0 0>; }; - adt7461@4c { - compatible = "adi,adt7461"; - reg = <0x4c>; - }; }; }; diff --git a/trunk/arch/powerpc/boot/dts/p4080ds.dts b/trunk/arch/powerpc/boot/dts/p4080ds.dts index 1cf6148b8b05..3e204609d02e 100644 --- a/trunk/arch/powerpc/boot/dts/p4080ds.dts +++ b/trunk/arch/powerpc/boot/dts/p4080ds.dts @@ -96,10 +96,6 @@ reg = <0x68>; interrupts = <0x1 0x1 0 0>; }; - adt7461@4c { - compatible = "adi,adt7461"; - reg = <0x4c>; - }; }; usb0: usb@210000 { diff --git a/trunk/arch/powerpc/boot/dts/p5020ds.dts b/trunk/arch/powerpc/boot/dts/p5020ds.dts index 2869fea717dd..27c07ed6adc1 100644 --- a/trunk/arch/powerpc/boot/dts/p5020ds.dts +++ b/trunk/arch/powerpc/boot/dts/p5020ds.dts @@ -98,10 +98,6 @@ reg = <0x68>; interrupts = <0x1 0x1 0 0>; }; - adt7461@4c { - compatible = "adi,adt7461"; - reg = <0x4c>; - }; }; }; diff --git a/trunk/arch/powerpc/boot/dts/p5040ds.dts b/trunk/arch/powerpc/boot/dts/p5040ds.dts deleted file mode 100644 index 860b5ccf76c0..000000000000 --- a/trunk/arch/powerpc/boot/dts/p5040ds.dts +++ /dev/null @@ -1,207 +0,0 @@ -/* - * P5040DS Device Tree Source - * - * Copyright 2012 Freescale Semiconductor Inc. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * * Neither the name of Freescale Semiconductor nor the - * names of its contributors may be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * - * ALTERNATIVELY, this software may be distributed under the terms of the - * GNU General Public License ("GPL") as published by the Free Software - * Foundation, either version 2 of that License or (at your option) any - * later version. - * - * This software is provided by Freescale Semiconductor "as is" and any - * express or implied warranties, including, but not limited to, the implied - * warranties of merchantability and fitness for a particular purpose are - * disclaimed. In no event shall Freescale Semiconductor be liable for any - * direct, indirect, incidental, special, exemplary, or consequential damages - * (including, but not limited to, procurement of substitute goods or services; - * loss of use, data, or profits; or business interruption) however caused and - * on any theory of liability, whether in contract, strict liability, or tort - * (including negligence or otherwise) arising in any way out of the use of this - * software, even if advised of the possibility of such damage. - */ - -/include/ "fsl/p5040si-pre.dtsi" - -/ { - model = "fsl,P5040DS"; - compatible = "fsl,P5040DS"; - #address-cells = <2>; - #size-cells = <2>; - interrupt-parent = <&mpic>; - - memory { - device_type = "memory"; - }; - - dcsr: dcsr@f00000000 { - ranges = <0x00000000 0xf 0x00000000 0x01008000>; - }; - - soc: soc@ffe000000 { - ranges = <0x00000000 0xf 0xfe000000 0x1000000>; - reg = <0xf 0xfe000000 0 0x00001000>; - spi@110000 { - flash@0 { - #address-cells = <1>; - #size-cells = <1>; - compatible = "spansion,s25sl12801"; - reg = <0>; - spi-max-frequency = <40000000>; /* input clock */ - partition@u-boot { - label = "u-boot"; - reg = <0x00000000 0x00100000>; - }; - partition@kernel { - label = "kernel"; - reg = <0x00100000 0x00500000>; - }; - partition@dtb { - label = "dtb"; - reg = <0x00600000 0x00100000>; - }; - partition@fs { - label = "file system"; - reg = <0x00700000 0x00900000>; - }; - }; - }; - - i2c@118100 { - eeprom@51 { - compatible = "at24,24c256"; - reg = <0x51>; - }; - eeprom@52 { - compatible = "at24,24c256"; - reg = <0x52>; - }; - }; - - i2c@119100 { - rtc@68 { - compatible = "dallas,ds3232"; - reg = <0x68>; - interrupts = <0x1 0x1 0 0>; - }; - adt7461@4c { - compatible = "adi,adt7461"; - reg = <0x4c>; - }; - }; - }; - - lbc: localbus@ffe124000 { - reg = <0xf 0xfe124000 0 0x1000>; - ranges = <0 0 0xf 0xe8000000 0x08000000 - 2 0 0xf 0xffa00000 0x00040000 - 3 0 0xf 0xffdf0000 0x00008000>; - - flash@0,0 { - compatible = "cfi-flash"; - reg = <0 0 0x08000000>; - bank-width = <2>; - device-width = <2>; - }; - - nand@2,0 { - #address-cells = <1>; - #size-cells = <1>; - compatible = "fsl,elbc-fcm-nand"; - reg = <0x2 0x0 0x40000>; - - partition@0 { - label = "NAND U-Boot Image"; - reg = <0x0 0x02000000>; - }; - - partition@2000000 { - label = "NAND Root File System"; - reg = <0x02000000 0x10000000>; - }; - - partition@12000000 { - label = "NAND Compressed RFS Image"; - reg = <0x12000000 0x08000000>; - }; - - partition@1a000000 { - label = "NAND Linux Kernel Image"; - reg = <0x1a000000 0x04000000>; - }; - - partition@1e000000 { - label = "NAND DTB Image"; - reg = <0x1e000000 0x01000000>; - }; - - partition@1f000000 { - label = "NAND Writable User area"; - reg = <0x1f000000 0x01000000>; - }; - }; - - board-control@3,0 { - compatible = "fsl,p5040ds-fpga", "fsl,fpga-ngpixis"; - reg = <3 0 0x40>; - }; - }; - - pci0: pcie@ffe200000 { - reg = <0xf 0xfe200000 0 0x1000>; - ranges = <0x02000000 0 0xe0000000 0xc 0x00000000 0x0 0x20000000 - 0x01000000 0 0x00000000 0xf 0xf8000000 0x0 0x00010000>; - pcie@0 { - ranges = <0x02000000 0 0xe0000000 - 0x02000000 0 0xe0000000 - 0 0x20000000 - - 0x01000000 0 0x00000000 - 0x01000000 0 0x00000000 - 0 0x00010000>; - }; - }; - - pci1: pcie@ffe201000 { - reg = <0xf 0xfe201000 0 0x1000>; - ranges = <0x02000000 0x0 0xe0000000 0xc 0x20000000 0x0 0x20000000 - 0x01000000 0x0 0x00000000 0xf 0xf8010000 0x0 0x00010000>; - pcie@0 { - ranges = <0x02000000 0 0xe0000000 - 0x02000000 0 0xe0000000 - 0 0x20000000 - - 0x01000000 0 0x00000000 - 0x01000000 0 0x00000000 - 0 0x00010000>; - }; - }; - - pci2: pcie@ffe202000 { - reg = <0xf 0xfe202000 0 0x1000>; - ranges = <0x02000000 0 0xe0000000 0xc 0x40000000 0 0x20000000 - 0x01000000 0 0x00000000 0xf 0xf8020000 0 0x00010000>; - pcie@0 { - ranges = <0x02000000 0 0xe0000000 - 0x02000000 0 0xe0000000 - 0 0x20000000 - - 0x01000000 0 0x00000000 - 0x01000000 0 0x00000000 - 0 0x00010000>; - }; - }; -}; - -/include/ "fsl/p5040si-post.dtsi" diff --git a/trunk/arch/powerpc/configs/85xx/p1023rds_defconfig b/trunk/arch/powerpc/configs/85xx/p1023rds_defconfig index b80bcc69d1f7..26e541c4662b 100644 --- a/trunk/arch/powerpc/configs/85xx/p1023rds_defconfig +++ b/trunk/arch/powerpc/configs/85xx/p1023rds_defconfig @@ -112,12 +112,6 @@ CONFIG_SND=y CONFIG_SND_MIXER_OSS=y CONFIG_SND_PCM_OSS=y # CONFIG_SND_SUPPORT_OLD_API is not set -CONFIG_USB=y -CONFIG_USB_DEVICEFS=y -CONFIG_USB_MON=y -CONFIG_USB_EHCI_HCD=y -CONFIG_USB_EHCI_FSL=y -CONFIG_USB_STORAGE=y CONFIG_EDAC=y CONFIG_EDAC_MM_EDAC=y CONFIG_RTC_CLASS=y diff --git a/trunk/arch/powerpc/configs/corenet32_smp_defconfig b/trunk/arch/powerpc/configs/corenet32_smp_defconfig index 1c0f2432ecdb..8b3d57c1ebe8 100644 --- a/trunk/arch/powerpc/configs/corenet32_smp_defconfig +++ b/trunk/arch/powerpc/configs/corenet32_smp_defconfig @@ -27,7 +27,6 @@ CONFIG_P2041_RDB=y CONFIG_P3041_DS=y CONFIG_P4080_DS=y CONFIG_P5020_DS=y -CONFIG_P5040_DS=y CONFIG_HIGHMEM=y # CONFIG_CORE_DUMP_DEFAULT_ELF_HEADERS is not set CONFIG_BINFMT_MISC=m diff --git a/trunk/arch/powerpc/configs/corenet64_smp_defconfig b/trunk/arch/powerpc/configs/corenet64_smp_defconfig index 88fa5c46f66f..0516e22ca3de 100644 --- a/trunk/arch/powerpc/configs/corenet64_smp_defconfig +++ b/trunk/arch/powerpc/configs/corenet64_smp_defconfig @@ -23,7 +23,6 @@ CONFIG_MODVERSIONS=y CONFIG_PARTITION_ADVANCED=y CONFIG_MAC_PARTITION=y CONFIG_P5020_DS=y -CONFIG_P5040_DS=y # CONFIG_PPC_OF_BOOT_TRAMPOLINE is not set CONFIG_BINFMT_MISC=m CONFIG_IRQ_ALL_CPUS=y diff --git a/trunk/arch/powerpc/configs/mpc85xx_defconfig b/trunk/arch/powerpc/configs/mpc85xx_defconfig index cf815e847cdc..8b5bda27d248 100644 --- a/trunk/arch/powerpc/configs/mpc85xx_defconfig +++ b/trunk/arch/powerpc/configs/mpc85xx_defconfig @@ -30,7 +30,6 @@ CONFIG_MPC85xx_DS=y CONFIG_MPC85xx_RDB=y CONFIG_P1010_RDB=y CONFIG_P1022_DS=y -CONFIG_P1022_RDK=y CONFIG_P1023_RDS=y CONFIG_SOCRATES=y CONFIG_KSI8560=y diff --git a/trunk/arch/powerpc/configs/mpc85xx_smp_defconfig b/trunk/arch/powerpc/configs/mpc85xx_smp_defconfig index 502cd9e027e4..b0974e7e98ae 100644 --- a/trunk/arch/powerpc/configs/mpc85xx_smp_defconfig +++ b/trunk/arch/powerpc/configs/mpc85xx_smp_defconfig @@ -32,7 +32,6 @@ CONFIG_MPC85xx_DS=y CONFIG_MPC85xx_RDB=y CONFIG_P1010_RDB=y CONFIG_P1022_DS=y -CONFIG_P1022_RDK=y CONFIG_P1023_RDS=y CONFIG_SOCRATES=y CONFIG_KSI8560=y diff --git a/trunk/arch/powerpc/configs/ppc64_defconfig b/trunk/arch/powerpc/configs/ppc64_defconfig index 6d03530b7506..06b56245d78c 100644 --- a/trunk/arch/powerpc/configs/ppc64_defconfig +++ b/trunk/arch/powerpc/configs/ppc64_defconfig @@ -51,7 +51,6 @@ CONFIG_KEXEC=y CONFIG_IRQ_ALL_CPUS=y CONFIG_MEMORY_HOTREMOVE=y CONFIG_SCHED_SMT=y -CONFIG_PPC_DENORMALISATION=y CONFIG_PCCARD=y CONFIG_ELECTRA_CF=y CONFIG_HOTPLUG_PCI=m @@ -487,8 +486,7 @@ CONFIG_CRYPTO_TWOFISH=m CONFIG_CRYPTO_LZO=m # CONFIG_CRYPTO_ANSI_CPRNG is not set CONFIG_CRYPTO_HW=y -CONFIG_CRYPTO_DEV_NX=y -CONFIG_CRYPTO_DEV_NX_ENCRYPT=m +CONFIG_CRYPTO_DEV_NX=m CONFIG_VIRTUALIZATION=y CONFIG_KVM_BOOK3S_64=m CONFIG_KVM_BOOK3S_64_HV=y diff --git a/trunk/arch/powerpc/configs/pseries_defconfig b/trunk/arch/powerpc/configs/pseries_defconfig index 1f710a32ffae..1f65b3c9b59a 100644 --- a/trunk/arch/powerpc/configs/pseries_defconfig +++ b/trunk/arch/powerpc/configs/pseries_defconfig @@ -48,7 +48,6 @@ CONFIG_MEMORY_HOTREMOVE=y CONFIG_PPC_64K_PAGES=y CONFIG_PPC_SUBPAGE_PROT=y CONFIG_SCHED_SMT=y -CONFIG_PPC_DENORMALISATION=y CONFIG_HOTPLUG_PCI=m CONFIG_HOTPLUG_PCI_RPA=m CONFIG_HOTPLUG_PCI_RPA_DLPAR=m @@ -370,8 +369,7 @@ CONFIG_CRYPTO_TWOFISH=m CONFIG_CRYPTO_LZO=m # CONFIG_CRYPTO_ANSI_CPRNG is not set CONFIG_CRYPTO_HW=y -CONFIG_CRYPTO_DEV_NX=y -CONFIG_CRYPTO_DEV_NX_ENCRYPT=m +CONFIG_CRYPTO_DEV_NX=m CONFIG_VIRTUALIZATION=y CONFIG_KVM_BOOK3S_64=m CONFIG_KVM_BOOK3S_64_HV=y diff --git a/trunk/arch/powerpc/include/asm/abs_addr.h b/trunk/arch/powerpc/include/asm/abs_addr.h new file mode 100644 index 000000000000..9d92ba04b033 --- /dev/null +++ b/trunk/arch/powerpc/include/asm/abs_addr.h @@ -0,0 +1,56 @@ +#ifndef _ASM_POWERPC_ABS_ADDR_H +#define _ASM_POWERPC_ABS_ADDR_H +#ifdef __KERNEL__ + + +/* + * c 2001 PPC 64 Team, IBM Corp + * + * 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 + +#include +#include +#include + +struct mschunks_map { + unsigned long num_chunks; + unsigned long chunk_size; + unsigned long chunk_shift; + unsigned long chunk_mask; + u32 *mapping; +}; + +extern struct mschunks_map mschunks_map; + +/* Chunks are 256 KB */ +#define MSCHUNKS_CHUNK_SHIFT (18) +#define MSCHUNKS_CHUNK_SIZE (1UL << MSCHUNKS_CHUNK_SHIFT) +#define MSCHUNKS_OFFSET_MASK (MSCHUNKS_CHUNK_SIZE - 1) + +static inline unsigned long chunk_to_addr(unsigned long chunk) +{ + return chunk << MSCHUNKS_CHUNK_SHIFT; +} + +static inline unsigned long addr_to_chunk(unsigned long addr) +{ + return addr >> MSCHUNKS_CHUNK_SHIFT; +} + +static inline unsigned long phys_to_abs(unsigned long pa) +{ + return pa; +} + +/* Convenience macros */ +#define virt_to_abs(va) phys_to_abs(__pa(va)) +#define abs_to_virt(aa) __va(aa) + +#endif /* __KERNEL__ */ +#endif /* _ASM_POWERPC_ABS_ADDR_H */ diff --git a/trunk/arch/powerpc/include/asm/bitops.h b/trunk/arch/powerpc/include/asm/bitops.h index dc2cf9c6d9e6..efdc92618b38 100644 --- a/trunk/arch/powerpc/include/asm/bitops.h +++ b/trunk/arch/powerpc/include/asm/bitops.h @@ -288,16 +288,6 @@ static __inline__ int test_bit_le(unsigned long nr, return (tmp[nr >> 3] >> (nr & 7)) & 1; } -static inline void set_bit_le(int nr, void *addr) -{ - set_bit(nr ^ BITOP_LE_SWIZZLE, addr); -} - -static inline void clear_bit_le(int nr, void *addr) -{ - clear_bit(nr ^ BITOP_LE_SWIZZLE, addr); -} - static inline void __set_bit_le(int nr, void *addr) { __set_bit(nr ^ BITOP_LE_SWIZZLE, addr); diff --git a/trunk/arch/powerpc/include/asm/cacheflush.h b/trunk/arch/powerpc/include/asm/cacheflush.h index b843e35122e8..ab9e402518e8 100644 --- a/trunk/arch/powerpc/include/asm/cacheflush.h +++ b/trunk/arch/powerpc/include/asm/cacheflush.h @@ -30,8 +30,6 @@ extern void flush_dcache_page(struct page *page); #define flush_dcache_mmap_lock(mapping) do { } while (0) #define flush_dcache_mmap_unlock(mapping) do { } while (0) -extern void __flush_disable_L1(void); - extern void __flush_icache_range(unsigned long, unsigned long); static inline void flush_icache_range(unsigned long start, unsigned long stop) { diff --git a/trunk/arch/powerpc/include/asm/compat.h b/trunk/arch/powerpc/include/asm/compat.h index 84fdf6857c31..88e602f6430d 100644 --- a/trunk/arch/powerpc/include/asm/compat.h +++ b/trunk/arch/powerpc/include/asm/compat.h @@ -38,7 +38,6 @@ typedef s64 compat_s64; typedef u32 compat_uint_t; typedef u32 compat_ulong_t; typedef u64 compat_u64; -typedef u32 compat_uptr_t; struct compat_timespec { compat_time_t tv_sec; @@ -115,64 +114,6 @@ typedef u32 compat_old_sigset_t; typedef u32 compat_sigset_word; -typedef union compat_sigval { - compat_int_t sival_int; - compat_uptr_t sival_ptr; -} compat_sigval_t; - -#define SI_PAD_SIZE32 (128/sizeof(int) - 3) - -typedef struct compat_siginfo { - int si_signo; - int si_errno; - int si_code; - - union { - int _pad[SI_PAD_SIZE32]; - - /* kill() */ - struct { - compat_pid_t _pid; /* sender's pid */ - __compat_uid_t _uid; /* sender's uid */ - } _kill; - - /* POSIX.1b timers */ - struct { - compat_timer_t _tid; /* timer id */ - int _overrun; /* overrun count */ - compat_sigval_t _sigval; /* same as below */ - int _sys_private; /* not to be passed to user */ - } _timer; - - /* POSIX.1b signals */ - struct { - compat_pid_t _pid; /* sender's pid */ - __compat_uid_t _uid; /* sender's uid */ - compat_sigval_t _sigval; - } _rt; - - /* SIGCHLD */ - struct { - compat_pid_t _pid; /* which child */ - __compat_uid_t _uid; /* sender's uid */ - int _status; /* exit code */ - compat_clock_t _utime; - compat_clock_t _stime; - } _sigchld; - - /* SIGILL, SIGFPE, SIGSEGV, SIGBUS, SIGEMT */ - struct { - unsigned int _addr; /* faulting insn/memory ref. */ - } _sigfault; - - /* SIGPOLL */ - struct { - int _band; /* POLL_IN, POLL_OUT, POLL_MSG */ - int _fd; - } _sigpoll; - } _sifields; -} compat_siginfo_t; - #define COMPAT_OFF_T_MAX 0x7fffffff #define COMPAT_LOFF_T_MAX 0x7fffffffffffffffL @@ -182,6 +123,7 @@ typedef struct compat_siginfo { * as pointers because the syscall entry code will have * appropriately converted them already. */ +typedef u32 compat_uptr_t; static inline void __user *compat_ptr(compat_uptr_t uptr) { diff --git a/trunk/arch/powerpc/include/asm/debug.h b/trunk/arch/powerpc/include/asm/debug.h index 32de2577bb6d..716d2f089eb6 100644 --- a/trunk/arch/powerpc/include/asm/debug.h +++ b/trunk/arch/powerpc/include/asm/debug.h @@ -44,7 +44,7 @@ static inline int debugger_dabr_match(struct pt_regs *regs) { return 0; } static inline int debugger_fault_handler(struct pt_regs *regs) { return 0; } #endif -extern int set_dabr(unsigned long dabr, unsigned long dabrx); +extern int set_dabr(unsigned long dabr); #ifdef CONFIG_PPC_ADV_DEBUG_REGS extern void do_send_trap(struct pt_regs *regs, unsigned long address, unsigned long error_code, int signal_code, int brkpt); diff --git a/trunk/arch/powerpc/include/asm/eeh.h b/trunk/arch/powerpc/include/asm/eeh.h index b0ef73882b38..d60f99814ffb 100644 --- a/trunk/arch/powerpc/include/asm/eeh.h +++ b/trunk/arch/powerpc/include/asm/eeh.h @@ -31,46 +31,6 @@ struct device_node; #ifdef CONFIG_EEH -/* - * The struct is used to trace PE related EEH functionality. - * In theory, there will have one instance of the struct to - * be created against particular PE. In nature, PEs corelate - * to each other. the struct has to reflect that hierarchy in - * order to easily pick up those affected PEs when one particular - * PE has EEH errors. - * - * Also, one particular PE might be composed of PCI device, PCI - * bus and its subordinate components. The struct also need ship - * the information. Further more, one particular PE is only meaingful - * in the corresponding PHB. Therefore, the root PEs should be created - * against existing PHBs in on-to-one fashion. - */ -#define EEH_PE_INVALID (1 << 0) /* Invalid */ -#define EEH_PE_PHB (1 << 1) /* PHB PE */ -#define EEH_PE_DEVICE (1 << 2) /* Device PE */ -#define EEH_PE_BUS (1 << 3) /* Bus PE */ - -#define EEH_PE_ISOLATED (1 << 0) /* Isolated PE */ -#define EEH_PE_RECOVERING (1 << 1) /* Recovering PE */ - -struct eeh_pe { - int type; /* PE type: PHB/Bus/Device */ - int state; /* PE EEH dependent mode */ - int config_addr; /* Traditional PCI address */ - int addr; /* PE configuration address */ - struct pci_controller *phb; /* Associated PHB */ - int check_count; /* Times of ignored error */ - int freeze_count; /* Times of froze up */ - int false_positives; /* Times of reported #ff's */ - struct eeh_pe *parent; /* Parent PE */ - struct list_head child_list; /* Link PE to the child list */ - struct list_head edevs; /* Link list of EEH devices */ - struct list_head child; /* Child PEs */ -}; - -#define eeh_pe_for_each_dev(pe, edev) \ - list_for_each_entry(edev, &pe->edevs, list) - /* * The struct is used to trace EEH state for the associated * PCI device node or PCI device. In future, it might @@ -78,16 +38,21 @@ struct eeh_pe { * another tree except the currently existing tree of PCI * buses and PCI devices */ -#define EEH_DEV_IRQ_DISABLED (1<<0) /* Interrupt disabled */ +#define EEH_MODE_SUPPORTED (1<<0) /* EEH supported on the device */ +#define EEH_MODE_NOCHECK (1<<1) /* EEH check should be skipped */ +#define EEH_MODE_ISOLATED (1<<2) /* The device has been isolated */ +#define EEH_MODE_RECOVERING (1<<3) /* Recovering the device */ +#define EEH_MODE_IRQ_DISABLED (1<<4) /* Interrupt disabled */ struct eeh_dev { int mode; /* EEH mode */ int class_code; /* Class code of the device */ int config_addr; /* Config address */ int pe_config_addr; /* PE config address */ + int check_count; /* Times of ignored error */ + int freeze_count; /* Times of froze up */ + int false_positives; /* Times of reported #ff's */ u32 config_space[16]; /* Saved PCI config space */ - struct eeh_pe *pe; /* Associated PE */ - struct list_head list; /* Form link list in the PE */ struct pci_controller *phb; /* Associated PHB */ struct device_node *dn; /* Associated device node */ struct pci_dev *pdev; /* Associated PCI device */ @@ -130,51 +95,19 @@ static inline struct pci_dev *eeh_dev_to_pci_dev(struct eeh_dev *edev) struct eeh_ops { char *name; int (*init)(void); - void* (*of_probe)(struct device_node *dn, void *flag); - void* (*dev_probe)(struct pci_dev *dev, void *flag); - int (*set_option)(struct eeh_pe *pe, int option); - int (*get_pe_addr)(struct eeh_pe *pe); - int (*get_state)(struct eeh_pe *pe, int *state); - int (*reset)(struct eeh_pe *pe, int option); - int (*wait_state)(struct eeh_pe *pe, int max_wait); - int (*get_log)(struct eeh_pe *pe, int severity, char *drv_log, unsigned long len); - int (*configure_bridge)(struct eeh_pe *pe); + int (*set_option)(struct device_node *dn, int option); + int (*get_pe_addr)(struct device_node *dn); + int (*get_state)(struct device_node *dn, int *state); + int (*reset)(struct device_node *dn, int option); + int (*wait_state)(struct device_node *dn, int max_wait); + int (*get_log)(struct device_node *dn, int severity, char *drv_log, unsigned long len); + int (*configure_bridge)(struct device_node *dn); int (*read_config)(struct device_node *dn, int where, int size, u32 *val); int (*write_config)(struct device_node *dn, int where, int size, u32 val); }; extern struct eeh_ops *eeh_ops; extern int eeh_subsystem_enabled; -extern struct mutex eeh_mutex; -extern int eeh_probe_mode; - -#define EEH_PROBE_MODE_DEV (1<<0) /* From PCI device */ -#define EEH_PROBE_MODE_DEVTREE (1<<1) /* From device tree */ - -static inline void eeh_probe_mode_set(int flag) -{ - eeh_probe_mode = flag; -} - -static inline int eeh_probe_mode_devtree(void) -{ - return (eeh_probe_mode == EEH_PROBE_MODE_DEVTREE); -} - -static inline int eeh_probe_mode_dev(void) -{ - return (eeh_probe_mode == EEH_PROBE_MODE_DEV); -} - -static inline void eeh_lock(void) -{ - mutex_lock(&eeh_mutex); -} - -static inline void eeh_unlock(void) -{ - mutex_unlock(&eeh_mutex); -} /* * Max number of EEH freezes allowed before we consider the device @@ -182,26 +115,22 @@ static inline void eeh_unlock(void) */ #define EEH_MAX_ALLOWED_FREEZES 5 -typedef void *(*eeh_traverse_func)(void *data, void *flag); -int __devinit eeh_phb_pe_create(struct pci_controller *phb); -int eeh_add_to_parent_pe(struct eeh_dev *edev); -int eeh_rmv_from_parent_pe(struct eeh_dev *edev, int purge_pe); -void *eeh_pe_dev_traverse(struct eeh_pe *root, - eeh_traverse_func fn, void *flag); -void eeh_pe_restore_bars(struct eeh_pe *pe); -struct pci_bus *eeh_pe_bus_get(struct eeh_pe *pe); - void * __devinit eeh_dev_init(struct device_node *dn, void *data); void __devinit eeh_dev_phb_init_dynamic(struct pci_controller *phb); +void __init eeh_dev_phb_init(void); +void __init eeh_init(void); +#ifdef CONFIG_PPC_PSERIES +int __init eeh_pseries_init(void); +#endif int __init eeh_ops_register(struct eeh_ops *ops); int __exit eeh_ops_unregister(const char *name); unsigned long eeh_check_failure(const volatile void __iomem *token, unsigned long val); -int eeh_dev_check_failure(struct eeh_dev *edev); -void __init eeh_addr_cache_build(void); +int eeh_dn_check_failure(struct device_node *dn, struct pci_dev *dev); +void __init pci_addr_cache_build(void); void eeh_add_device_tree_early(struct device_node *); void eeh_add_device_tree_late(struct pci_bus *); -void eeh_remove_bus_device(struct pci_dev *, int); +void eeh_remove_bus_device(struct pci_dev *); /** * EEH_POSSIBLE_ERROR() -- test for possible MMIO failure. @@ -227,24 +156,34 @@ static inline void *eeh_dev_init(struct device_node *dn, void *data) static inline void eeh_dev_phb_init_dynamic(struct pci_controller *phb) { } +static inline void eeh_dev_phb_init(void) { } + +static inline void eeh_init(void) { } + +#ifdef CONFIG_PPC_PSERIES +static inline int eeh_pseries_init(void) +{ + return 0; +} +#endif /* CONFIG_PPC_PSERIES */ + static inline unsigned long eeh_check_failure(const volatile void __iomem *token, unsigned long val) { return val; } -#define eeh_dev_check_failure(x) (0) +static inline int eeh_dn_check_failure(struct device_node *dn, struct pci_dev *dev) +{ + return 0; +} -static inline void eeh_addr_cache_build(void) { } +static inline void pci_addr_cache_build(void) { } static inline void eeh_add_device_tree_early(struct device_node *dn) { } static inline void eeh_add_device_tree_late(struct pci_bus *bus) { } -static inline void eeh_remove_bus_device(struct pci_dev *dev, int purge_pe) { } - -static inline void eeh_lock(void) { } -static inline void eeh_unlock(void) { } - +static inline void eeh_remove_bus_device(struct pci_dev *dev) { } #define EEH_POSSIBLE_ERROR(val, type) (0) #define EEH_IO_ERROR_VALUE(size) (-1UL) #endif /* CONFIG_EEH */ diff --git a/trunk/arch/powerpc/include/asm/eeh_event.h b/trunk/arch/powerpc/include/asm/eeh_event.h index de67d830151b..c68b012b7797 100644 --- a/trunk/arch/powerpc/include/asm/eeh_event.h +++ b/trunk/arch/powerpc/include/asm/eeh_event.h @@ -28,11 +28,11 @@ */ struct eeh_event { struct list_head list; /* to form event queue */ - struct eeh_pe *pe; /* EEH PE */ + struct eeh_dev *edev; /* EEH device */ }; -int eeh_send_failure_event(struct eeh_pe *pe); -void eeh_handle_event(struct eeh_pe *pe); +int eeh_send_failure_event(struct eeh_dev *edev); +struct eeh_dev *handle_eeh_events(struct eeh_event *); #endif /* __KERNEL__ */ #endif /* ASM_POWERPC_EEH_EVENT_H */ diff --git a/trunk/arch/powerpc/include/asm/exception-64e.h b/trunk/arch/powerpc/include/asm/exception-64e.h index 51fa43e536b9..ac13addb8495 100644 --- a/trunk/arch/powerpc/include/asm/exception-64e.h +++ b/trunk/arch/powerpc/include/asm/exception-64e.h @@ -37,7 +37,6 @@ * critical data */ -#define PACA_EXGDBELL PACA_EXGEN /* We are out of SPRGs so we save some things in the PACA. The normal * exception frame is smaller than the CRIT or MC one though @@ -46,9 +45,8 @@ #define EX_CR (1 * 8) #define EX_R10 (2 * 8) #define EX_R11 (3 * 8) -#define EX_R13 (4 * 8) -#define EX_R14 (5 * 8) -#define EX_R15 (6 * 8) +#define EX_R14 (4 * 8) +#define EX_R15 (5 * 8) /* * The TLB miss exception uses different slots. diff --git a/trunk/arch/powerpc/include/asm/fsl_guts.h b/trunk/arch/powerpc/include/asm/fsl_guts.h index dd5ba2c22771..aa4c488589ce 100644 --- a/trunk/arch/powerpc/include/asm/fsl_guts.h +++ b/trunk/arch/powerpc/include/asm/fsl_guts.h @@ -48,8 +48,6 @@ struct ccsr_guts { __be32 dmuxcr; /* 0x.0068 - DMA Mux Control Register */ u8 res06c[0x70 - 0x6c]; __be32 devdisr; /* 0x.0070 - Device Disable Control */ -#define CCSR_GUTS_DEVDISR_TB1 0x00001000 -#define CCSR_GUTS_DEVDISR_TB0 0x00004000 __be32 devdisr2; /* 0x.0074 - Device Disable Control 2 */ u8 res078[0x7c - 0x78]; __be32 pmjcr; /* 0x.007c - 4 Power Management Jog Control Register */ diff --git a/trunk/arch/powerpc/include/asm/fsl_ifc.h b/trunk/arch/powerpc/include/asm/fsl_ifc.h index b8a4b9bc50b3..b955012939a2 100644 --- a/trunk/arch/powerpc/include/asm/fsl_ifc.h +++ b/trunk/arch/powerpc/include/asm/fsl_ifc.h @@ -768,24 +768,22 @@ struct fsl_ifc_gpcm { */ struct fsl_ifc_regs { __be32 ifc_rev; - u32 res1[0x2]; + u32 res1[0x3]; struct { - __be32 cspr_ext; __be32 cspr; - u32 res2; + u32 res2[0x2]; } cspr_cs[FSL_IFC_BANK_COUNT]; - u32 res3[0x19]; + u32 res3[0x18]; struct { __be32 amask; u32 res4[0x2]; } amask_cs[FSL_IFC_BANK_COUNT]; - u32 res5[0x17]; + u32 res5[0x18]; struct { - __be32 csor_ext; __be32 csor; - u32 res6; + u32 res6[0x2]; } csor_cs[FSL_IFC_BANK_COUNT]; - u32 res7[0x19]; + u32 res7[0x18]; struct { __be32 ftim[4]; u32 res8[0x8]; diff --git a/trunk/arch/powerpc/include/asm/hvcall.h b/trunk/arch/powerpc/include/asm/hvcall.h index 7a867065db79..423cf9eaf4a4 100644 --- a/trunk/arch/powerpc/include/asm/hvcall.h +++ b/trunk/arch/powerpc/include/asm/hvcall.h @@ -152,6 +152,11 @@ #define H_VASI_RESUMED 5 #define H_VASI_COMPLETED 6 +/* DABRX flags */ +#define H_DABRX_HYPERVISOR (1UL<<(63-61)) +#define H_DABRX_KERNEL (1UL<<(63-62)) +#define H_DABRX_USER (1UL<<(63-63)) + /* Each control block has to be on a 4K boundary */ #define H_CB_ALIGNMENT 4096 diff --git a/trunk/arch/powerpc/include/asm/hw_breakpoint.h b/trunk/arch/powerpc/include/asm/hw_breakpoint.h index 423424599dad..be04330af751 100644 --- a/trunk/arch/powerpc/include/asm/hw_breakpoint.h +++ b/trunk/arch/powerpc/include/asm/hw_breakpoint.h @@ -27,11 +27,10 @@ #ifdef CONFIG_HAVE_HW_BREAKPOINT struct arch_hw_breakpoint { - unsigned long address; - unsigned long dabrx; - int type; - u8 len; /* length of the target data symbol */ bool extraneous_interrupt; + u8 len; /* length of the target data symbol */ + int type; + unsigned long address; }; #include @@ -62,7 +61,7 @@ extern void ptrace_triggered(struct perf_event *bp, struct perf_sample_data *data, struct pt_regs *regs); static inline void hw_breakpoint_disable(void) { - set_dabr(0, 0); + set_dabr(0); } extern void thread_change_pc(struct task_struct *tsk, struct pt_regs *regs); diff --git a/trunk/arch/powerpc/include/asm/kprobes.h b/trunk/arch/powerpc/include/asm/kprobes.h index 7b6feab6fd26..be0171afdc0f 100644 --- a/trunk/arch/powerpc/include/asm/kprobes.h +++ b/trunk/arch/powerpc/include/asm/kprobes.h @@ -29,16 +29,21 @@ #include #include #include -#include #define __ARCH_WANT_KPROBES_INSN_SLOT struct pt_regs; struct kprobe; -typedef ppc_opcode_t kprobe_opcode_t; +typedef unsigned int kprobe_opcode_t; +#define BREAKPOINT_INSTRUCTION 0x7fe00008 /* trap */ #define MAX_INSN_SIZE 1 +#define IS_TW(instr) (((instr) & 0xfc0007fe) == 0x7c000008) +#define IS_TD(instr) (((instr) & 0xfc0007fe) == 0x7c000088) +#define IS_TDI(instr) (((instr) & 0xfc000000) == 0x08000000) +#define IS_TWI(instr) (((instr) & 0xfc000000) == 0x0c000000) + #ifdef CONFIG_PPC64 /* * 64bit powerpc uses function descriptors. @@ -67,6 +72,12 @@ typedef ppc_opcode_t kprobe_opcode_t; addr = (kprobe_opcode_t *)kallsyms_lookup_name(dot_name); \ } \ } + +#define is_trap(instr) (IS_TW(instr) || IS_TD(instr) || \ + IS_TWI(instr) || IS_TDI(instr)) +#else +/* Use stock kprobe_lookup_name since ppc32 doesn't use function descriptors */ +#define is_trap(instr) (IS_TW(instr) || IS_TWI(instr)) #endif #define flush_insn_slot(p) do { } while (0) diff --git a/trunk/arch/powerpc/include/asm/kvm_book3s.h b/trunk/arch/powerpc/include/asm/kvm_book3s.h index 7aefdb3e1ce4..f0e0c6a66d97 100644 --- a/trunk/arch/powerpc/include/asm/kvm_book3s.h +++ b/trunk/arch/powerpc/include/asm/kvm_book3s.h @@ -59,7 +59,7 @@ struct hpte_cache { struct hlist_node list_vpte; struct hlist_node list_vpte_long; struct rcu_head rcu_head; - u64 host_vpn; + u64 host_va; u64 pfn; ulong slot; struct kvmppc_pte pte; diff --git a/trunk/arch/powerpc/include/asm/kvm_book3s_asm.h b/trunk/arch/powerpc/include/asm/kvm_book3s_asm.h index 88609b23b775..bfcd00c1485d 100644 --- a/trunk/arch/powerpc/include/asm/kvm_book3s_asm.h +++ b/trunk/arch/powerpc/include/asm/kvm_book3s_asm.h @@ -74,6 +74,7 @@ struct kvmppc_host_state { ulong vmhandler; ulong scratch0; ulong scratch1; + ulong sprg3; u8 in_guest; u8 restore_hid5; u8 napping; diff --git a/trunk/arch/powerpc/include/asm/kvm_host.h b/trunk/arch/powerpc/include/asm/kvm_host.h index 28e8f5e5c63e..a8bf5c673a3c 100644 --- a/trunk/arch/powerpc/include/asm/kvm_host.h +++ b/trunk/arch/powerpc/include/asm/kvm_host.h @@ -53,8 +53,6 @@ struct kvm; extern int kvm_unmap_hva(struct kvm *kvm, unsigned long hva); -extern int kvm_unmap_hva_range(struct kvm *kvm, - unsigned long start, unsigned long end); extern int kvm_age_hva(struct kvm *kvm, unsigned long hva); extern int kvm_test_age_hva(struct kvm *kvm, unsigned long hva); extern void kvm_set_spte_hva(struct kvm *kvm, unsigned long hva, pte_t pte); @@ -222,7 +220,6 @@ struct revmap_entry { #define KVMPPC_GOT_PAGE 0x80 struct kvm_arch_memory_slot { - unsigned long *rmap; }; struct kvm_arch { diff --git a/trunk/arch/powerpc/include/asm/machdep.h b/trunk/arch/powerpc/include/asm/machdep.h index c4231973edd3..f7706d722b39 100644 --- a/trunk/arch/powerpc/include/asm/machdep.h +++ b/trunk/arch/powerpc/include/asm/machdep.h @@ -34,19 +34,19 @@ struct machdep_calls { char *name; #ifdef CONFIG_PPC64 void (*hpte_invalidate)(unsigned long slot, - unsigned long vpn, + unsigned long va, int psize, int ssize, int local); long (*hpte_updatepp)(unsigned long slot, unsigned long newpp, - unsigned long vpn, + unsigned long va, int psize, int ssize, int local); void (*hpte_updateboltedpp)(unsigned long newpp, unsigned long ea, int psize, int ssize); long (*hpte_insert)(unsigned long hpte_group, - unsigned long vpn, + unsigned long va, unsigned long prpn, unsigned long rflags, unsigned long vflags, @@ -180,8 +180,7 @@ struct machdep_calls { void (*enable_pmcs)(void); /* Set DABR for this platform, leave empty for default implemenation */ - int (*set_dabr)(unsigned long dabr, - unsigned long dabrx); + int (*set_dabr)(unsigned long dabr); #ifdef CONFIG_PPC32 /* XXX for now */ /* A general init function, called by ppc_init in init/main.c. diff --git a/trunk/arch/powerpc/include/asm/mmu-hash64.h b/trunk/arch/powerpc/include/asm/mmu-hash64.h index 9673f73eb8db..1c65a59881ea 100644 --- a/trunk/arch/powerpc/include/asm/mmu-hash64.h +++ b/trunk/arch/powerpc/include/asm/mmu-hash64.h @@ -15,13 +15,6 @@ #include #include -/* - * This is necessary to get the definition of PGTABLE_RANGE which we - * need for various slices related matters. Note that this isn't the - * complete pgtable.h but only a portion of it. - */ -#include - /* * Segment table */ @@ -161,25 +154,9 @@ struct mmu_psize_def #define MMU_SEGSIZE_256M 0 #define MMU_SEGSIZE_1T 1 -/* - * encode page number shift. - * in order to fit the 78 bit va in a 64 bit variable we shift the va by - * 12 bits. This enable us to address upto 76 bit va. - * For hpt hash from a va we can ignore the page size bits of va and for - * hpte encoding we ignore up to 23 bits of va. So ignoring lower 12 bits ensure - * we work in all cases including 4k page size. - */ -#define VPN_SHIFT 12 #ifndef __ASSEMBLY__ -static inline int segment_shift(int ssize) -{ - if (ssize == MMU_SEGSIZE_256M) - return SID_SHIFT; - return SID_SHIFT_1T; -} - /* * The current system page and segment sizes */ @@ -202,40 +179,19 @@ extern unsigned long tce_alloc_start, tce_alloc_end; */ extern int mmu_ci_restrictions; -/* - * This computes the AVPN and B fields of the first dword of a HPTE, - * for use when we want to match an existing PTE. The bottom 7 bits - * of the returned value are zero. - */ -static inline unsigned long hpte_encode_avpn(unsigned long vpn, int psize, - int ssize) -{ - unsigned long v; - /* - * The AVA field omits the low-order 23 bits of the 78 bits VA. - * These bits are not needed in the PTE, because the - * low-order b of these bits are part of the byte offset - * into the virtual page and, if b < 23, the high-order - * 23-b of these bits are always used in selecting the - * PTEGs to be searched - */ - v = (vpn >> (23 - VPN_SHIFT)) & ~(mmu_psize_defs[psize].avpnm); - v <<= HPTE_V_AVPN_SHIFT; - v |= ((unsigned long) ssize) << HPTE_V_SSIZE_SHIFT; - return v; -} - /* * This function sets the AVPN and L fields of the HPTE appropriately * for the page size */ -static inline unsigned long hpte_encode_v(unsigned long vpn, - int psize, int ssize) +static inline unsigned long hpte_encode_v(unsigned long va, int psize, + int ssize) { unsigned long v; - v = hpte_encode_avpn(vpn, psize, ssize); + v = (va >> 23) & ~(mmu_psize_defs[psize].avpnm); + v <<= HPTE_V_AVPN_SHIFT; if (psize != MMU_PAGE_4K) v |= HPTE_V_LARGE; + v |= ((unsigned long) ssize) << HPTE_V_SSIZE_SHIFT; return v; } @@ -260,37 +216,30 @@ static inline unsigned long hpte_encode_r(unsigned long pa, int psize) } /* - * Build a VPN_SHIFT bit shifted va given VSID, EA and segment size. + * Build a VA given VSID, EA and segment size */ -static inline unsigned long hpt_vpn(unsigned long ea, - unsigned long vsid, int ssize) +static inline unsigned long hpt_va(unsigned long ea, unsigned long vsid, + int ssize) { - unsigned long mask; - int s_shift = segment_shift(ssize); - - mask = (1ul << (s_shift - VPN_SHIFT)) - 1; - return (vsid << (s_shift - VPN_SHIFT)) | ((ea >> VPN_SHIFT) & mask); + if (ssize == MMU_SEGSIZE_256M) + return (vsid << 28) | (ea & 0xfffffffUL); + return (vsid << 40) | (ea & 0xffffffffffUL); } /* * This hashes a virtual address */ -static inline unsigned long hpt_hash(unsigned long vpn, - unsigned int shift, int ssize) + +static inline unsigned long hpt_hash(unsigned long va, unsigned int shift, + int ssize) { - int mask; unsigned long hash, vsid; - /* VPN_SHIFT can be atmost 12 */ if (ssize == MMU_SEGSIZE_256M) { - mask = (1ul << (SID_SHIFT - VPN_SHIFT)) - 1; - hash = (vpn >> (SID_SHIFT - VPN_SHIFT)) ^ - ((vpn & mask) >> (shift - VPN_SHIFT)); + hash = (va >> 28) ^ ((va & 0x0fffffffUL) >> shift); } else { - mask = (1ul << (SID_SHIFT_1T - VPN_SHIFT)) - 1; - vsid = vpn >> (SID_SHIFT_1T - VPN_SHIFT); - hash = vsid ^ (vsid << 25) ^ - ((vpn & mask) >> (shift - VPN_SHIFT)) ; + vsid = va >> 40; + hash = vsid ^ (vsid << 25) ^ ((va & 0xffffffffffUL) >> shift); } return hash & 0x7fffffffffUL; } @@ -331,61 +280,63 @@ extern void slb_set_size(u16 size); #endif /* __ASSEMBLY__ */ /* - * VSID allocation (256MB segment) - * - * We first generate a 38-bit "proto-VSID". For kernel addresses this - * is equal to the ESID | 1 << 37, for user addresses it is: - * (context << USER_ESID_BITS) | (esid & ((1U << USER_ESID_BITS) - 1) + * VSID allocation * - * This splits the proto-VSID into the below range - * 0 - (2^(CONTEXT_BITS + USER_ESID_BITS) - 1) : User proto-VSID range - * 2^(CONTEXT_BITS + USER_ESID_BITS) - 2^(VSID_BITS) : Kernel proto-VSID range + * We first generate a 36-bit "proto-VSID". For kernel addresses this + * is equal to the ESID, for user addresses it is: + * (context << 15) | (esid & 0x7fff) * - * We also have CONTEXT_BITS + USER_ESID_BITS = VSID_BITS - 1 - * That is, we assign half of the space to user processes and half - * to the kernel. + * The two forms are distinguishable because the top bit is 0 for user + * addresses, whereas the top two bits are 1 for kernel addresses. + * Proto-VSIDs with the top two bits equal to 0b10 are reserved for + * now. * * The proto-VSIDs are then scrambled into real VSIDs with the * multiplicative hash: * * VSID = (proto-VSID * VSID_MULTIPLIER) % VSID_MODULUS + * where VSID_MULTIPLIER = 268435399 = 0xFFFFFC7 + * VSID_MODULUS = 2^36-1 = 0xFFFFFFFFF * - * VSID_MULTIPLIER is prime, so in particular it is + * This scramble is only well defined for proto-VSIDs below + * 0xFFFFFFFFF, so both proto-VSID and actual VSID 0xFFFFFFFFF are + * reserved. VSID_MULTIPLIER is prime, so in particular it is * co-prime to VSID_MODULUS, making this a 1:1 scrambling function. * Because the modulus is 2^n-1 we can compute it efficiently without * a divide or extra multiply (see below). * * This scheme has several advantages over older methods: * - * - We have VSIDs allocated for every kernel address + * - We have VSIDs allocated for every kernel address * (i.e. everything above 0xC000000000000000), except the very top * segment, which simplifies several things. * - * - We allow for USER_ESID_BITS significant bits of ESID and - * CONTEXT_BITS bits of context for user addresses. - * i.e. 64T (46 bits) of address space for up to half a million contexts. + * - We allow for 16 significant bits of ESID and 19 bits of + * context for user addresses. i.e. 16T (44 bits) of address space for + * up to half a million contexts. * - * - The scramble function gives robust scattering in the hash + * - The scramble function gives robust scattering in the hash * table (at least based on some initial results). The previous * method was more susceptible to pathological cases giving excessive * hash collisions. */ - /* - * This should be computed such that protovosid * vsid_mulitplier - * doesn't overflow 64 bits. It should also be co-prime to vsid_modulus + * WARNING - If you change these you must make sure the asm + * implementations in slb_allocate (slb_low.S), do_stab_bolted + * (head.S) and ASM_VSID_SCRAMBLE (below) are changed accordingly. */ -#define VSID_MULTIPLIER_256M ASM_CONST(12538073) /* 24-bit prime */ -#define VSID_BITS_256M 38 + +#define VSID_MULTIPLIER_256M ASM_CONST(200730139) /* 28-bit prime */ +#define VSID_BITS_256M 36 #define VSID_MODULUS_256M ((1UL<> 41) #ifndef __ASSEMBLY__ @@ -467,7 +416,7 @@ typedef struct { #ifdef CONFIG_PPC_MM_SLICES u64 low_slices_psize; /* SLB page size encodings */ - unsigned char high_slices_psize[SLICE_ARRAY_SIZE]; + u64 high_slices_psize; /* 4 bits per slice for now */ #else u16 sllp; /* SLB page size encoding */ #endif @@ -503,32 +452,12 @@ typedef struct { }) #endif /* 1 */ -/* - * This is only valid for addresses >= PAGE_OFFSET - * The proto-VSID space is divided into two class - * User: 0 to 2^(CONTEXT_BITS + USER_ESID_BITS) -1 - * kernel: 2^(CONTEXT_BITS + USER_ESID_BITS) to 2^(VSID_BITS) - 1 - * - * With KERNEL_START at 0xc000000000000000, the proto vsid for - * the kernel ends up with 0xc00000000 (36 bits). With 64TB - * support we need to have kernel proto-VSID in the - * [2^37 to 2^38 - 1] range due to the increased USER_ESID_BITS. - */ +/* This is only valid for addresses >= PAGE_OFFSET */ static inline unsigned long get_kernel_vsid(unsigned long ea, int ssize) { - unsigned long proto_vsid; - /* - * We need to make sure proto_vsid for the kernel is - * >= 2^(CONTEXT_BITS + USER_ESID_BITS[_1T]) - */ - if (ssize == MMU_SEGSIZE_256M) { - proto_vsid = ea >> SID_SHIFT; - proto_vsid |= (1UL << (CONTEXT_BITS + USER_ESID_BITS)); - return vsid_scramble(proto_vsid, 256M); - } - proto_vsid = ea >> SID_SHIFT_1T; - proto_vsid |= (1UL << (CONTEXT_BITS + USER_ESID_BITS_1T)); - return vsid_scramble(proto_vsid, 1T); + if (ssize == MMU_SEGSIZE_256M) + return vsid_scramble(ea >> SID_SHIFT, 256M); + return vsid_scramble(ea >> SID_SHIFT_1T, 1T); } /* Returns the segment size indicator for a user address */ diff --git a/trunk/arch/powerpc/include/asm/mmu.h b/trunk/arch/powerpc/include/asm/mmu.h index 5e38eedea218..e8a26db2e8f3 100644 --- a/trunk/arch/powerpc/include/asm/mmu.h +++ b/trunk/arch/powerpc/include/asm/mmu.h @@ -146,15 +146,6 @@ extern void setup_initial_memory_limit(phys_addr_t first_memblock_base, extern u64 ppc64_rma_size; #endif /* CONFIG_PPC64 */ -struct mm_struct; -#ifdef CONFIG_DEBUG_VM -extern void assert_pte_locked(struct mm_struct *mm, unsigned long addr); -#else /* CONFIG_DEBUG_VM */ -static inline void assert_pte_locked(struct mm_struct *mm, unsigned long addr) -{ -} -#endif /* !CONFIG_DEBUG_VM */ - #endif /* !__ASSEMBLY__ */ /* The kernel use the constants below to index in the page sizes array. diff --git a/trunk/arch/powerpc/include/asm/mpc52xx.h b/trunk/arch/powerpc/include/asm/mpc52xx.h index 0acc7c7c28d1..1f41382eda38 100644 --- a/trunk/arch/powerpc/include/asm/mpc52xx.h +++ b/trunk/arch/powerpc/include/asm/mpc52xx.h @@ -307,7 +307,6 @@ struct mpc52xx_lpbfifo_request { size_t size; size_t pos; /* current position of transfer */ int flags; - int defer_xfer_start; /* What to do when finished */ void (*callback)(struct mpc52xx_lpbfifo_request *); @@ -324,7 +323,6 @@ struct mpc52xx_lpbfifo_request { extern int mpc52xx_lpbfifo_submit(struct mpc52xx_lpbfifo_request *req); extern void mpc52xx_lpbfifo_abort(struct mpc52xx_lpbfifo_request *req); extern void mpc52xx_lpbfifo_poll(void); -extern int mpc52xx_lpbfifo_start_xfer(struct mpc52xx_lpbfifo_request *req); /* mpc52xx_pic.c */ extern void mpc52xx_init_irq(void); diff --git a/trunk/arch/powerpc/include/asm/mpic.h b/trunk/arch/powerpc/include/asm/mpic.h index c0f9ef90f0b8..c9f698a994be 100644 --- a/trunk/arch/powerpc/include/asm/mpic.h +++ b/trunk/arch/powerpc/include/asm/mpic.h @@ -63,7 +63,6 @@ */ #define MPIC_TIMER_BASE 0x01100 #define MPIC_TIMER_STRIDE 0x40 -#define MPIC_TIMER_GROUP_STRIDE 0x1000 #define MPIC_TIMER_CURRENT_CNT 0x00000 #define MPIC_TIMER_BASE_CNT 0x00010 @@ -111,16 +110,10 @@ #define MPIC_VECPRI_SENSE_MASK 0x00400000 #define MPIC_IRQ_DESTINATION 0x00010 -#define MPIC_FSL_BRR1 0x00000 -#define MPIC_FSL_BRR1_VER 0x0000ffff - #define MPIC_MAX_IRQ_SOURCES 2048 #define MPIC_MAX_CPUS 32 #define MPIC_MAX_ISU 32 -#define MPIC_MAX_ERR 32 -#define MPIC_FSL_ERR_INT 16 - /* * Tsi108 implementation of MPIC has many differences from the original one */ @@ -273,7 +266,6 @@ struct mpic struct irq_chip hc_ipi; #endif struct irq_chip hc_tm; - struct irq_chip hc_err; const char *name; /* Flags */ unsigned int flags; @@ -287,8 +279,6 @@ struct mpic /* vector numbers used for internal sources (ipi/timers) */ unsigned int ipi_vecs[4]; unsigned int timer_vecs[8]; - /* vector numbers used for FSL MPIC error interrupts */ - unsigned int err_int_vecs[MPIC_MAX_ERR]; /* Spurious vector to program into unused sources */ unsigned int spurious_vec; @@ -306,15 +296,11 @@ struct mpic phys_addr_t paddr; /* The various ioremap'ed bases */ - struct mpic_reg_bank thiscpuregs; struct mpic_reg_bank gregs; struct mpic_reg_bank tmregs; struct mpic_reg_bank cpuregs[MPIC_MAX_CPUS]; struct mpic_reg_bank isus[MPIC_MAX_ISU]; - /* ioremap'ed base for error interrupt registers */ - u32 __iomem *err_regs; - /* Protected sources */ unsigned long *protected; @@ -379,11 +365,6 @@ struct mpic #define MPIC_NO_RESET 0x00004000 /* Freescale MPIC (compatible includes "fsl,mpic") */ #define MPIC_FSL 0x00008000 -/* Freescale MPIC supports EIMR (error interrupt mask register). - * This flag is set for MPIC version >= 4.1 (version determined - * from the BRR1 register). -*/ -#define MPIC_FSL_HAS_EIMR 0x00010000 /* MPIC HW modification ID */ #define MPIC_REGSET_MASK 0xf0000000 diff --git a/trunk/arch/powerpc/include/asm/paca.h b/trunk/arch/powerpc/include/asm/paca.h index e9e7a6999bb8..daf813fea91f 100644 --- a/trunk/arch/powerpc/include/asm/paca.h +++ b/trunk/arch/powerpc/include/asm/paca.h @@ -100,7 +100,7 @@ struct paca_struct { /* SLB related definitions */ u16 vmalloc_sllp; u16 slb_cache_ptr; - u32 slb_cache[SLB_CACHE_ENTRIES]; + u16 slb_cache[SLB_CACHE_ENTRIES]; #endif /* CONFIG_PPC_STD_MMU_64 */ #ifdef CONFIG_PPC_BOOK3E @@ -136,7 +136,6 @@ struct paca_struct { u8 io_sync; /* writel() needs spin_unlock sync */ u8 irq_work_pending; /* IRQ_WORK interrupt while soft-disable */ u8 nap_state_lost; /* NV GPR values lost in power7_idle */ - u64 sprg3; /* Saved user-visible sprg */ #ifdef CONFIG_PPC_POWERNV /* Pointer to OPAL machine check event structure set by the diff --git a/trunk/arch/powerpc/include/asm/page_64.h b/trunk/arch/powerpc/include/asm/page_64.h index cd915d6b093d..fed85e6290e1 100644 --- a/trunk/arch/powerpc/include/asm/page_64.h +++ b/trunk/arch/powerpc/include/asm/page_64.h @@ -78,19 +78,11 @@ extern u64 ppc64_pft_size; #define GET_LOW_SLICE_INDEX(addr) ((addr) >> SLICE_LOW_SHIFT) #define GET_HIGH_SLICE_INDEX(addr) ((addr) >> SLICE_HIGH_SHIFT) -/* - * 1 bit per slice and we have one slice per 1TB - * Right now we support only 64TB. - * IF we change this we will have to change the type - * of high_slices - */ -#define SLICE_MASK_SIZE 8 - #ifndef __ASSEMBLY__ struct slice_mask { u16 low_slices; - u64 high_slices; + u16 high_slices; }; struct mm_struct; diff --git a/trunk/arch/powerpc/include/asm/pci-bridge.h b/trunk/arch/powerpc/include/asm/pci-bridge.h index 025a130729bc..8cccbee61519 100644 --- a/trunk/arch/powerpc/include/asm/pci-bridge.h +++ b/trunk/arch/powerpc/include/asm/pci-bridge.h @@ -182,25 +182,14 @@ static inline int pci_device_from_OF_node(struct device_node *np, #if defined(CONFIG_EEH) static inline struct eeh_dev *of_node_to_eeh_dev(struct device_node *dn) { - /* - * For those OF nodes whose parent isn't PCI bridge, they - * don't have PCI_DN actually. So we have to skip them for - * any EEH operations. - */ - if (!dn || !PCI_DN(dn)) - return NULL; - return PCI_DN(dn)->edev; } -#else -#define of_node_to_eeh_dev(x) (NULL) #endif /** Find the bus corresponding to the indicated device node */ extern struct pci_bus *pcibios_find_pci_bus(struct device_node *dn); /** Remove all of the PCI devices under this bus */ -extern void __pcibios_remove_pci_devices(struct pci_bus *bus, int purge_pe); extern void pcibios_remove_pci_devices(struct pci_bus *bus); /** Discover new pci devices under this bus, and add them */ diff --git a/trunk/arch/powerpc/include/asm/perf_event_server.h b/trunk/arch/powerpc/include/asm/perf_event_server.h index 9710be3a2d17..078019b5b353 100644 --- a/trunk/arch/powerpc/include/asm/perf_event_server.h +++ b/trunk/arch/powerpc/include/asm/perf_event_server.h @@ -49,7 +49,6 @@ struct power_pmu { #define PPMU_ALT_SIPR 2 /* uses alternate posn for SIPR/HV */ #define PPMU_NO_SIPR 4 /* no SIPR/HV in MMCRA at all */ #define PPMU_NO_CONT_SAMPLING 8 /* no continuous sampling */ -#define PPMU_SIAR_VALID 16 /* Processor has SIAR Valid bit */ /* * Values for flags to get_alternatives() diff --git a/trunk/arch/powerpc/include/asm/pgtable-ppc64-4k.h b/trunk/arch/powerpc/include/asm/pgtable-ppc64-4k.h index 12798c9d4b4b..6eefdcffa359 100644 --- a/trunk/arch/powerpc/include/asm/pgtable-ppc64-4k.h +++ b/trunk/arch/powerpc/include/asm/pgtable-ppc64-4k.h @@ -7,7 +7,7 @@ */ #define PTE_INDEX_SIZE 9 #define PMD_INDEX_SIZE 7 -#define PUD_INDEX_SIZE 9 +#define PUD_INDEX_SIZE 7 #define PGD_INDEX_SIZE 9 #ifndef __ASSEMBLY__ @@ -19,7 +19,7 @@ #define PTRS_PER_PTE (1 << PTE_INDEX_SIZE) #define PTRS_PER_PMD (1 << PMD_INDEX_SIZE) -#define PTRS_PER_PUD (1 << PUD_INDEX_SIZE) +#define PTRS_PER_PUD (1 << PMD_INDEX_SIZE) #define PTRS_PER_PGD (1 << PGD_INDEX_SIZE) /* PMD_SHIFT determines what a second-level page table entry can map */ diff --git a/trunk/arch/powerpc/include/asm/pgtable-ppc64-64k.h b/trunk/arch/powerpc/include/asm/pgtable-ppc64-64k.h index be4e2878fbc0..90533ddcd703 100644 --- a/trunk/arch/powerpc/include/asm/pgtable-ppc64-64k.h +++ b/trunk/arch/powerpc/include/asm/pgtable-ppc64-64k.h @@ -7,7 +7,7 @@ #define PTE_INDEX_SIZE 12 #define PMD_INDEX_SIZE 12 #define PUD_INDEX_SIZE 0 -#define PGD_INDEX_SIZE 6 +#define PGD_INDEX_SIZE 4 #ifndef __ASSEMBLY__ #define PTE_TABLE_SIZE (sizeof(real_pte_t) << PTE_INDEX_SIZE) diff --git a/trunk/arch/powerpc/include/asm/pgtable-ppc64.h b/trunk/arch/powerpc/include/asm/pgtable-ppc64.h index 0182c203e411..c4205616dfb5 100644 --- a/trunk/arch/powerpc/include/asm/pgtable-ppc64.h +++ b/trunk/arch/powerpc/include/asm/pgtable-ppc64.h @@ -21,6 +21,17 @@ #define PGTABLE_RANGE (ASM_CONST(1) << PGTABLE_EADDR_SIZE) +/* Some sanity checking */ +#if TASK_SIZE_USER64 > PGTABLE_RANGE +#error TASK_SIZE_USER64 exceeds pagetable range +#endif + +#ifdef CONFIG_PPC_STD_MMU_64 +#if TASK_SIZE_USER64 > (1UL << (USER_ESID_BITS + SID_SHIFT)) +#error TASK_SIZE_USER64 exceeds user VSID range +#endif +#endif + /* * Define the address range of the kernel non-linear virtual area */ @@ -30,7 +41,7 @@ #else #define KERN_VIRT_START ASM_CONST(0xD000000000000000) #endif -#define KERN_VIRT_SIZE ASM_CONST(0x0000100000000000) +#define KERN_VIRT_SIZE PGTABLE_RANGE /* * The vmalloc space starts at the beginning of that region, and @@ -106,6 +117,9 @@ #ifndef __ASSEMBLY__ +#include +#include + /* * This is the default implementation of various PTE accessors, it's * used in all cases except Book3S with 64K pages where we have a @@ -184,8 +198,7 @@ /* to find an entry in a kernel page-table-directory */ /* This now only contains the vmalloc pages */ #define pgd_offset_k(address) pgd_offset(&init_mm, address) -extern void hpte_need_flush(struct mm_struct *mm, unsigned long addr, - pte_t *ptep, unsigned long pte, int huge); + /* Atomic PTE updates */ static inline unsigned long pte_update(struct mm_struct *mm, diff --git a/trunk/arch/powerpc/include/asm/pgtable.h b/trunk/arch/powerpc/include/asm/pgtable.h index a9cbd3ba5c33..2e0e4110f7ae 100644 --- a/trunk/arch/powerpc/include/asm/pgtable.h +++ b/trunk/arch/powerpc/include/asm/pgtable.h @@ -9,6 +9,14 @@ struct mm_struct; +#ifdef CONFIG_DEBUG_VM +extern void assert_pte_locked(struct mm_struct *mm, unsigned long addr); +#else /* CONFIG_DEBUG_VM */ +static inline void assert_pte_locked(struct mm_struct *mm, unsigned long addr) +{ +} +#endif /* !CONFIG_DEBUG_VM */ + #endif /* !__ASSEMBLY__ */ #if defined(CONFIG_PPC64) @@ -19,8 +27,6 @@ struct mm_struct; #ifndef __ASSEMBLY__ -#include - /* Generic accessors to PTE bits */ static inline int pte_write(pte_t pte) { return pte_val(pte) & _PAGE_RW; } static inline int pte_dirty(pte_t pte) { return pte_val(pte) & _PAGE_DIRTY; } diff --git a/trunk/arch/powerpc/include/asm/ppc-opcode.h b/trunk/arch/powerpc/include/asm/ppc-opcode.h index 5f73ce63fcae..4c25319f2fbc 100644 --- a/trunk/arch/powerpc/include/asm/ppc-opcode.h +++ b/trunk/arch/powerpc/include/asm/ppc-opcode.h @@ -126,7 +126,6 @@ #define PPC_INST_TLBIVAX 0x7c000624 #define PPC_INST_TLBSRX_DOT 0x7c0006a5 #define PPC_INST_XXLOR 0xf0000510 -#define PPC_INST_XVCPSGNDP 0xf0000780 #define PPC_INST_NAP 0x4c000364 #define PPC_INST_SLEEP 0x4c0003a4 @@ -278,8 +277,6 @@ VSX_XX1((s), a, b)) #define XXLOR(t, a, b) stringify_in_c(.long PPC_INST_XXLOR | \ VSX_XX3((t), a, b)) -#define XVCPSGNDP(t, a, b) stringify_in_c(.long (PPC_INST_XVCPSGNDP | \ - VSX_XX3((t), (a), (b)))) #define PPC_NAP stringify_in_c(.long PPC_INST_NAP) #define PPC_SLEEP stringify_in_c(.long PPC_INST_SLEEP) diff --git a/trunk/arch/powerpc/include/asm/ppc-pci.h b/trunk/arch/powerpc/include/asm/ppc-pci.h index ed57fa7920c8..80fa704d410f 100644 --- a/trunk/arch/powerpc/include/asm/ppc-pci.h +++ b/trunk/arch/powerpc/include/asm/ppc-pci.h @@ -47,17 +47,19 @@ extern int rtas_setup_phb(struct pci_controller *phb); #ifdef CONFIG_EEH -void eeh_addr_cache_insert_dev(struct pci_dev *dev); -void eeh_addr_cache_rmv_dev(struct pci_dev *dev); -struct eeh_dev *eeh_addr_cache_get_dev(unsigned long addr); -void eeh_slot_error_detail(struct eeh_pe *pe, int severity); -int eeh_pci_enable(struct eeh_pe *pe, int function); -int eeh_reset_pe(struct eeh_pe *); -void eeh_save_bars(struct eeh_dev *edev); +void pci_addr_cache_build(void); +void pci_addr_cache_insert_device(struct pci_dev *dev); +void pci_addr_cache_remove_device(struct pci_dev *dev); +struct pci_dev *pci_addr_cache_get_device(unsigned long addr); +void eeh_slot_error_detail(struct eeh_dev *edev, int severity); +int eeh_pci_enable(struct eeh_dev *edev, int function); +int eeh_reset_pe(struct eeh_dev *); +void eeh_restore_bars(struct eeh_dev *); int rtas_write_config(struct pci_dn *, int where, int size, u32 val); int rtas_read_config(struct pci_dn *, int where, int size, u32 *val); -void eeh_pe_state_mark(struct eeh_pe *pe, int state); -void eeh_pe_state_clear(struct eeh_pe *pe, int state); +void eeh_mark_slot(struct device_node *dn, int mode_flag); +void eeh_clear_slot(struct device_node *dn, int mode_flag); +struct device_node *eeh_find_device_pe(struct device_node *dn); void eeh_sysfs_add_device(struct pci_dev *pdev); void eeh_sysfs_remove_device(struct pci_dev *pdev); diff --git a/trunk/arch/powerpc/include/asm/probes.h b/trunk/arch/powerpc/include/asm/probes.h deleted file mode 100644 index 5f1e15b68704..000000000000 --- a/trunk/arch/powerpc/include/asm/probes.h +++ /dev/null @@ -1,42 +0,0 @@ -#ifndef _ASM_POWERPC_PROBES_H -#define _ASM_POWERPC_PROBES_H -#ifdef __KERNEL__ -/* - * Definitions common to probes files - * - * 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. - * - * Copyright IBM Corporation, 2012 - */ -#include - -typedef u32 ppc_opcode_t; -#define BREAKPOINT_INSTRUCTION 0x7fe00008 /* trap */ - -/* Trap definitions per ISA */ -#define IS_TW(instr) (((instr) & 0xfc0007fe) == 0x7c000008) -#define IS_TD(instr) (((instr) & 0xfc0007fe) == 0x7c000088) -#define IS_TDI(instr) (((instr) & 0xfc000000) == 0x08000000) -#define IS_TWI(instr) (((instr) & 0xfc000000) == 0x0c000000) - -#ifdef CONFIG_PPC64 -#define is_trap(instr) (IS_TW(instr) || IS_TD(instr) || \ - IS_TWI(instr) || IS_TDI(instr)) -#else -#define is_trap(instr) (IS_TW(instr) || IS_TWI(instr)) -#endif /* CONFIG_PPC64 */ - -#endif /* __KERNEL__ */ -#endif /* _ASM_POWERPC_PROBES_H */ diff --git a/trunk/arch/powerpc/include/asm/processor.h b/trunk/arch/powerpc/include/asm/processor.h index 9dc5cd1fde1a..54b73a28c205 100644 --- a/trunk/arch/powerpc/include/asm/processor.h +++ b/trunk/arch/powerpc/include/asm/processor.h @@ -97,8 +97,8 @@ extern struct task_struct *last_task_used_spe; #endif #ifdef CONFIG_PPC64 -/* 64-bit user address space is 46-bits (64TB user VM) */ -#define TASK_SIZE_USER64 (0x0000400000000000UL) +/* 64-bit user address space is 44-bits (16TB user VM) */ +#define TASK_SIZE_USER64 (0x0000100000000000UL) /* * 32-bit user address space is 4GB - 1 page @@ -219,8 +219,6 @@ struct thread_struct { #endif /* CONFIG_HAVE_HW_BREAKPOINT */ #endif unsigned long dabr; /* Data address breakpoint register */ - unsigned long dabrx; /* ... extension */ - unsigned long trap_nr; /* last trap # on this thread */ #ifdef CONFIG_ALTIVEC /* Complete AltiVec register set */ vector128 vr[32] __attribute__((aligned(16))); diff --git a/trunk/arch/powerpc/include/asm/pte-hash64-64k.h b/trunk/arch/powerpc/include/asm/pte-hash64-64k.h index eedf427c9124..59247e816ac5 100644 --- a/trunk/arch/powerpc/include/asm/pte-hash64-64k.h +++ b/trunk/arch/powerpc/include/asm/pte-hash64-64k.h @@ -58,16 +58,14 @@ /* Trick: we set __end to va + 64k, which happens works for * a 16M page as well as we want only one iteration */ -#define pte_iterate_hashed_subpages(rpte, psize, vpn, index, shift) \ - do { \ - unsigned long __end = vpn + (1UL << (PAGE_SHIFT - VPN_SHIFT)); \ - unsigned __split = (psize == MMU_PAGE_4K || \ - psize == MMU_PAGE_64K_AP); \ - shift = mmu_psize_defs[psize].shift; \ - for (index = 0; vpn < __end; index++, \ - vpn += (1L << (shift - VPN_SHIFT))) { \ - if (!__split || __rpte_sub_valid(rpte, index)) \ - do { +#define pte_iterate_hashed_subpages(rpte, psize, va, index, shift) \ + do { \ + unsigned long __end = va + PAGE_SIZE; \ + unsigned __split = (psize == MMU_PAGE_4K || \ + psize == MMU_PAGE_64K_AP); \ + shift = mmu_psize_defs[psize].shift; \ + for (index = 0; va < __end; index++, va += (1L << shift)) { \ + if (!__split || __rpte_sub_valid(rpte, index)) do { \ #define pte_iterate_hashed_end() } while(0); } } while(0) diff --git a/trunk/arch/powerpc/include/asm/reg.h b/trunk/arch/powerpc/include/asm/reg.h index d24c14163966..638608677e2a 100644 --- a/trunk/arch/powerpc/include/asm/reg.h +++ b/trunk/arch/powerpc/include/asm/reg.h @@ -208,9 +208,6 @@ #define SPRN_DABRX 0x3F7 /* Data Address Breakpoint Register Extension */ #define DABRX_USER (1UL << 0) #define DABRX_KERNEL (1UL << 1) -#define DABRX_HYP (1UL << 2) -#define DABRX_BTI (1UL << 3) -#define DABRX_ALL (DABRX_BTI | DABRX_HYP | DABRX_KERNEL | DABRX_USER) #define SPRN_DAR 0x013 /* Data Address Register */ #define SPRN_DBCR 0x136 /* e300 Data Breakpoint Control Reg */ #define SPRN_DSISR 0x012 /* Data Storage Interrupt Status Register */ @@ -524,7 +521,6 @@ #define SPRN_HSRR0 0x13A /* Save/Restore Register 0 */ #define SPRN_HSRR1 0x13B /* Save/Restore Register 1 */ -#define HSRR1_DENORM 0x00100000 /* Denorm exception */ #define SPRN_TBCTL 0x35f /* PA6T Timebase control register */ #define TBCTL_FREEZE 0x0000000000000000ull /* Freeze all tbs */ @@ -606,10 +602,6 @@ #define POWER6_MMCRA_SIPR 0x0000020000000000ULL #define POWER6_MMCRA_THRM 0x00000020UL #define POWER6_MMCRA_OTHER 0x0000000EUL - -#define POWER7P_MMCRA_SIAR_VALID 0x10000000 /* P7+ SIAR contents valid */ -#define POWER7P_MMCRA_SDAR_VALID 0x08000000 /* P7+ SDAR contents valid */ - #define SPRN_PMC1 787 #define SPRN_PMC2 788 #define SPRN_PMC3 789 @@ -769,8 +761,7 @@ * 64-bit embedded * - SPRG0 generic exception scratch * - SPRG2 TLB exception stack - * - SPRG3 critical exception scratch and - * CPU and NUMA node for VDSO getcpu (user visible) + * - SPRG3 CPU and NUMA node for VDSO getcpu (user visible) * - SPRG4 unused (user visible) * - SPRG6 TLB miss scratch (user visible, sorry !) * - SPRG7 critical exception scratch @@ -867,12 +858,11 @@ #ifdef CONFIG_PPC_BOOK3E_64 #define SPRN_SPRG_MC_SCRATCH SPRN_SPRG8 -#define SPRN_SPRG_CRIT_SCRATCH SPRN_SPRG3 +#define SPRN_SPRG_CRIT_SCRATCH SPRN_SPRG7 #define SPRN_SPRG_DBG_SCRATCH SPRN_SPRG9 #define SPRN_SPRG_TLB_EXFRAME SPRN_SPRG2 #define SPRN_SPRG_TLB_SCRATCH SPRN_SPRG6 #define SPRN_SPRG_GEN_SCRATCH SPRN_SPRG0 -#define SPRN_SPRG_GDBELL_SCRATCH SPRN_SPRG_GEN_SCRATCH #define SET_PACA(rX) mtspr SPRN_SPRG_PACA,rX #define GET_PACA(rX) mfspr rX,SPRN_SPRG_PACA @@ -947,7 +937,7 @@ #define PVR_VER(pvr) (((pvr) >> 16) & 0xFFFF) /* Version field */ #define PVR_REV(pvr) (((pvr) >> 0) & 0xFFFF) /* Revison field */ -#define pvr_version_is(pvr) (PVR_VER(mfspr(SPRN_PVR)) == (pvr)) +#define __is_processor(pv) (PVR_VER(mfspr(SPRN_PVR)) == (pv)) /* * IBM has further subdivided the standard PowerPC 16-bit version and @@ -1012,25 +1002,25 @@ #define PVR_476_ISS 0x00052000 /* 64-bit processors */ -#define PVR_NORTHSTAR 0x0033 -#define PVR_PULSAR 0x0034 -#define PVR_POWER4 0x0035 -#define PVR_ICESTAR 0x0036 -#define PVR_SSTAR 0x0037 -#define PVR_POWER4p 0x0038 -#define PVR_970 0x0039 -#define PVR_POWER5 0x003A -#define PVR_POWER5p 0x003B -#define PVR_970FX 0x003C -#define PVR_POWER6 0x003E -#define PVR_POWER7 0x003F -#define PVR_630 0x0040 -#define PVR_630p 0x0041 -#define PVR_970MP 0x0044 -#define PVR_970GX 0x0045 -#define PVR_POWER7p 0x004A -#define PVR_BE 0x0070 -#define PVR_PA6T 0x0090 +/* XXX the prefix should be PVR_, we'll do a global sweep to fix it one day */ +#define PV_NORTHSTAR 0x0033 +#define PV_PULSAR 0x0034 +#define PV_POWER4 0x0035 +#define PV_ICESTAR 0x0036 +#define PV_SSTAR 0x0037 +#define PV_POWER4p 0x0038 +#define PV_970 0x0039 +#define PV_POWER5 0x003A +#define PV_POWER5p 0x003B +#define PV_970FX 0x003C +#define PV_POWER6 0x003E +#define PV_POWER7 0x003F +#define PV_630 0x0040 +#define PV_630p 0x0041 +#define PV_970MP 0x0044 +#define PV_970GX 0x0045 +#define PV_BE 0x0070 +#define PV_PA6T 0x0090 /* Macros for setting and retrieving special purpose registers */ #ifndef __ASSEMBLY__ diff --git a/trunk/arch/powerpc/include/asm/setup.h b/trunk/arch/powerpc/include/asm/setup.h index 8b9a306260b2..d084ce195fc3 100644 --- a/trunk/arch/powerpc/include/asm/setup.h +++ b/trunk/arch/powerpc/include/asm/setup.h @@ -9,7 +9,7 @@ extern void ppc_printk_progress(char *s, unsigned short hex); extern unsigned int rtas_data; extern int mem_init_done; /* set on boot once kmalloc can be called */ extern int init_bootmem_done; /* set once bootmem is available */ -extern unsigned long long memory_limit; +extern phys_addr_t memory_limit; extern unsigned long klimit; extern void *zalloc_maybe_bootmem(size_t size, gfp_t mask); diff --git a/trunk/arch/powerpc/include/asm/siginfo.h b/trunk/arch/powerpc/include/asm/siginfo.h index ccce3ef5cd86..49495b0534ed 100644 --- a/trunk/arch/powerpc/include/asm/siginfo.h +++ b/trunk/arch/powerpc/include/asm/siginfo.h @@ -10,6 +10,7 @@ #ifdef __powerpc64__ # define __ARCH_SI_PREAMBLE_SIZE (4 * sizeof(int)) +# define SI_PAD_SIZE32 ((SI_MAX_SIZE/sizeof(int)) - 3) #endif #include diff --git a/trunk/arch/powerpc/include/asm/smp.h b/trunk/arch/powerpc/include/asm/smp.h index e807e9d8e3f7..ebc24dc5b1a1 100644 --- a/trunk/arch/powerpc/include/asm/smp.h +++ b/trunk/arch/powerpc/include/asm/smp.h @@ -65,7 +65,6 @@ int generic_cpu_disable(void); void generic_cpu_die(unsigned int cpu); void generic_mach_cpu_die(void); void generic_set_cpu_dead(unsigned int cpu); -void generic_set_cpu_up(unsigned int cpu); int generic_check_cpu_restart(unsigned int cpu); #endif @@ -191,7 +190,6 @@ extern unsigned long __secondary_hold_spinloop; extern unsigned long __secondary_hold_acknowledge; extern char __secondary_hold; -extern void __early_start(void); #endif /* __ASSEMBLY__ */ #endif /* __KERNEL__ */ diff --git a/trunk/arch/powerpc/include/asm/sparsemem.h b/trunk/arch/powerpc/include/asm/sparsemem.h index f6fc0ee813d7..0c5fa3145615 100644 --- a/trunk/arch/powerpc/include/asm/sparsemem.h +++ b/trunk/arch/powerpc/include/asm/sparsemem.h @@ -10,8 +10,8 @@ */ #define SECTION_SIZE_BITS 24 -#define MAX_PHYSADDR_BITS 46 -#define MAX_PHYSMEM_BITS 46 +#define MAX_PHYSADDR_BITS 44 +#define MAX_PHYSMEM_BITS 44 #endif /* CONFIG_SPARSEMEM */ diff --git a/trunk/arch/powerpc/include/asm/swiotlb.h b/trunk/arch/powerpc/include/asm/swiotlb.h index de99d6e29430..8979d4cd3d70 100644 --- a/trunk/arch/powerpc/include/asm/swiotlb.h +++ b/trunk/arch/powerpc/include/asm/swiotlb.h @@ -22,10 +22,4 @@ int __init swiotlb_setup_bus_notifier(void); extern void pci_dma_dev_setup_swiotlb(struct pci_dev *pdev); -#ifdef CONFIG_SWIOTLB -void swiotlb_detect_4g(void); -#else -static inline void swiotlb_detect_4g(void) {} -#endif - #endif /* __ASM_SWIOTLB_H */ diff --git a/trunk/arch/powerpc/include/asm/thread_info.h b/trunk/arch/powerpc/include/asm/thread_info.h index 8ceea14d6fe4..faf93529cbf0 100644 --- a/trunk/arch/powerpc/include/asm/thread_info.h +++ b/trunk/arch/powerpc/include/asm/thread_info.h @@ -102,10 +102,7 @@ static inline struct thread_info *current_thread_info(void) #define TIF_RESTOREALL 11 /* Restore all regs (implies NOERROR) */ #define TIF_NOERROR 12 /* Force successful syscall return */ #define TIF_NOTIFY_RESUME 13 /* callback before returning to user */ -#define TIF_UPROBE 14 /* breakpointed or single-stepping */ #define TIF_SYSCALL_TRACEPOINT 15 /* syscall tracepoint instrumentation */ -#define TIF_EMULATE_STACK_STORE 16 /* Is an instruction emulation - for stack store? */ /* as above, but as bit values */ #define _TIF_SYSCALL_TRACE (1< - */ - -#include -#include - -typedef ppc_opcode_t uprobe_opcode_t; - -#define MAX_UINSN_BYTES 4 -#define UPROBE_XOL_SLOT_BYTES (MAX_UINSN_BYTES) - -/* The following alias is needed for reference from arch-agnostic code */ -#define UPROBE_SWBP_INSN BREAKPOINT_INSTRUCTION -#define UPROBE_SWBP_INSN_SIZE 4 /* swbp insn size in bytes */ - -struct arch_uprobe { - union { - u8 insn[MAX_UINSN_BYTES]; - u32 ainsn; - }; -}; - -struct arch_uprobe_task { - unsigned long saved_trap_nr; -}; - -extern int arch_uprobe_analyze_insn(struct arch_uprobe *aup, struct mm_struct *mm, unsigned long addr); -extern int arch_uprobe_pre_xol(struct arch_uprobe *aup, struct pt_regs *regs); -extern int arch_uprobe_post_xol(struct arch_uprobe *aup, struct pt_regs *regs); -extern bool arch_uprobe_xol_was_trapped(struct task_struct *tsk); -extern int arch_uprobe_exception_notify(struct notifier_block *self, unsigned long val, void *data); -extern void arch_uprobe_abort_xol(struct arch_uprobe *aup, struct pt_regs *regs); -#endif /* _ASM_UPROBES_H */ diff --git a/trunk/arch/powerpc/kernel/Makefile b/trunk/arch/powerpc/kernel/Makefile index cde12f8a4ebc..bb282dd81612 100644 --- a/trunk/arch/powerpc/kernel/Makefile +++ b/trunk/arch/powerpc/kernel/Makefile @@ -96,7 +96,6 @@ obj-$(CONFIG_MODULES) += ppc_ksyms.o obj-$(CONFIG_BOOTX_TEXT) += btext.o obj-$(CONFIG_SMP) += smp.o obj-$(CONFIG_KPROBES) += kprobes.o -obj-$(CONFIG_UPROBES) += uprobes.o obj-$(CONFIG_PPC_UDBG_16550) += legacy_serial.o udbg_16550.o obj-$(CONFIG_STACKTRACE) += stacktrace.o obj-$(CONFIG_SWIOTLB) += dma-swiotlb.o diff --git a/trunk/arch/powerpc/kernel/asm-offsets.c b/trunk/arch/powerpc/kernel/asm-offsets.c index 7523539cfe9f..e8995727b1c1 100644 --- a/trunk/arch/powerpc/kernel/asm-offsets.c +++ b/trunk/arch/powerpc/kernel/asm-offsets.c @@ -206,7 +206,6 @@ int main(void) DEFINE(PACA_SYSTEM_TIME, offsetof(struct paca_struct, system_time)); DEFINE(PACA_TRAP_SAVE, offsetof(struct paca_struct, trap_save)); DEFINE(PACA_NAPSTATELOST, offsetof(struct paca_struct, nap_state_lost)); - DEFINE(PACA_SPRG3, offsetof(struct paca_struct, sprg3)); #endif /* CONFIG_PPC64 */ /* RTAS */ @@ -535,6 +534,7 @@ int main(void) HSTATE_FIELD(HSTATE_VMHANDLER, vmhandler); HSTATE_FIELD(HSTATE_SCRATCH0, scratch0); HSTATE_FIELD(HSTATE_SCRATCH1, scratch1); + HSTATE_FIELD(HSTATE_SPRG3, sprg3); HSTATE_FIELD(HSTATE_IN_GUEST, in_guest); HSTATE_FIELD(HSTATE_RESTORE_HID5, restore_hid5); HSTATE_FIELD(HSTATE_NAPPING, napping); diff --git a/trunk/arch/powerpc/kernel/cpu_setup_fsl_booke.S b/trunk/arch/powerpc/kernel/cpu_setup_fsl_booke.S index dcd881937f7a..69fdd2322a66 100644 --- a/trunk/arch/powerpc/kernel/cpu_setup_fsl_booke.S +++ b/trunk/arch/powerpc/kernel/cpu_setup_fsl_booke.S @@ -16,8 +16,6 @@ #include #include #include -#include -#include _GLOBAL(__e500_icache_setup) mfspr r0, SPRN_L1CSR1 @@ -75,81 +73,27 @@ _GLOBAL(__setup_cpu_e500v2) mtlr r4 blr _GLOBAL(__setup_cpu_e500mc) -_GLOBAL(__setup_cpu_e5500) - mflr r5 + mr r5, r4 + mflr r4 bl __e500_icache_setup bl __e500_dcache_setup bl __setup_e500mc_ivors - /* - * We only want to touch IVOR38-41 if we're running on hardware - * that supports category E.HV. The architectural way to determine - * this is MMUCFG[LPIDSIZE]. - */ - mfspr r3, SPRN_MMUCFG - rlwinm. r3, r3, 0, MMUCFG_LPIDSIZE - beq 1f - bl __setup_ehv_ivors - b 2f -1: - lwz r3, CPU_SPEC_FEATURES(r4) - /* We need this check as cpu_setup is also called for - * the secondary cores. So, if we have already cleared - * the feature on the primary core, avoid doing it on the - * secondary core. - */ - andis. r6, r3, CPU_FTR_EMB_HV@h - beq 2f - rlwinm r3, r3, 0, ~CPU_FTR_EMB_HV - stw r3, CPU_SPEC_FEATURES(r4) -2: - mtlr r5 + mtlr r4 blr #endif - -#ifdef CONFIG_PPC_BOOK3E_64 +/* Right now, restore and setup are the same thing */ _GLOBAL(__restore_cpu_e5500) +_GLOBAL(__setup_cpu_e5500) mflr r4 bl __e500_icache_setup bl __e500_dcache_setup +#ifdef CONFIG_PPC_BOOK3E_64 bl .__setup_base_ivors bl .setup_perfmon_ivor bl .setup_doorbell_ivors - /* - * We only want to touch IVOR38-41 if we're running on hardware - * that supports category E.HV. The architectural way to determine - * this is MMUCFG[LPIDSIZE]. - */ - mfspr r10,SPRN_MMUCFG - rlwinm. r10,r10,0,MMUCFG_LPIDSIZE - beq 1f bl .setup_ehv_ivors -1: +#else + bl __setup_e500mc_ivors +#endif mtlr r4 blr - -_GLOBAL(__setup_cpu_e5500) - mflr r5 - bl __e500_icache_setup - bl __e500_dcache_setup - bl .__setup_base_ivors - bl .setup_perfmon_ivor - bl .setup_doorbell_ivors - /* - * We only want to touch IVOR38-41 if we're running on hardware - * that supports category E.HV. The architectural way to determine - * this is MMUCFG[LPIDSIZE]. - */ - mfspr r10,SPRN_MMUCFG - rlwinm. r10,r10,0,MMUCFG_LPIDSIZE - beq 1f - bl .setup_ehv_ivors - b 2f -1: - ld r10,CPU_SPEC_FEATURES(r4) - LOAD_REG_IMMEDIATE(r9,CPU_FTR_EMB_HV) - andc r10,r10,r9 - std r10,CPU_SPEC_FEATURES(r4) -2: - mtlr r5 - blr -#endif diff --git a/trunk/arch/powerpc/kernel/cputable.c b/trunk/arch/powerpc/kernel/cputable.c index 0514c21f138b..455faa389876 100644 --- a/trunk/arch/powerpc/kernel/cputable.c +++ b/trunk/arch/powerpc/kernel/cputable.c @@ -2016,9 +2016,7 @@ static struct cpu_spec __initdata cpu_specs[] = { .oprofile_cpu_type = "ppc/e500mc", .oprofile_type = PPC_OPROFILE_FSL_EMB, .cpu_setup = __setup_cpu_e5500, -#ifndef CONFIG_PPC32 .cpu_restore = __restore_cpu_e5500, -#endif .machine_check = machine_check_e500mc, .platform = "ppce5500", }, @@ -2036,9 +2034,7 @@ static struct cpu_spec __initdata cpu_specs[] = { .oprofile_cpu_type = "ppc/e6500", .oprofile_type = PPC_OPROFILE_FSL_EMB, .cpu_setup = __setup_cpu_e5500, -#ifndef CONFIG_PPC32 .cpu_restore = __restore_cpu_e5500, -#endif .machine_check = machine_check_e500mc, .platform = "ppce6500", }, diff --git a/trunk/arch/powerpc/kernel/dma-swiotlb.c b/trunk/arch/powerpc/kernel/dma-swiotlb.c index bd1a2aba599f..46943651da23 100644 --- a/trunk/arch/powerpc/kernel/dma-swiotlb.c +++ b/trunk/arch/powerpc/kernel/dma-swiotlb.c @@ -12,7 +12,6 @@ */ #include -#include #include #include #include @@ -21,6 +20,7 @@ #include #include #include +#include unsigned int ppc_swiotlb_enable; @@ -105,23 +105,3 @@ int __init swiotlb_setup_bus_notifier(void) &ppc_swiotlb_plat_bus_notifier); return 0; } - -void swiotlb_detect_4g(void) -{ - if ((memblock_end_of_DRAM() - 1) > 0xffffffff) - ppc_swiotlb_enable = 1; -} - -static int __init swiotlb_late_init(void) -{ - if (ppc_swiotlb_enable) { - swiotlb_print_info(); - set_pci_dma_ops(&swiotlb_dma_ops); - ppc_md.pci_dma_dev_setup = pci_dma_dev_setup_swiotlb; - } else { - swiotlb_free(); - } - - return 0; -} -subsys_initcall(swiotlb_late_init); diff --git a/trunk/arch/powerpc/kernel/dma.c b/trunk/arch/powerpc/kernel/dma.c index 8032b97ccdcb..355b9d84b0f8 100644 --- a/trunk/arch/powerpc/kernel/dma.c +++ b/trunk/arch/powerpc/kernel/dma.c @@ -14,6 +14,7 @@ #include #include #include +#include #include /* @@ -49,7 +50,7 @@ void *dma_direct_alloc_coherent(struct device *dev, size_t size, return NULL; ret = page_address(page); memset(ret, 0, size); - *dma_handle = __pa(ret) + get_dma_offset(dev); + *dma_handle = virt_to_abs(ret) + get_dma_offset(dev); return ret; #endif diff --git a/trunk/arch/powerpc/kernel/entry_32.S b/trunk/arch/powerpc/kernel/entry_32.S index af37528da49f..ead5016b02d0 100644 --- a/trunk/arch/powerpc/kernel/entry_32.S +++ b/trunk/arch/powerpc/kernel/entry_32.S @@ -831,56 +831,19 @@ restore_user: bnel- load_dbcr0 #endif +#ifdef CONFIG_PREEMPT b restore /* N.B. the only way to get here is from the beq following ret_from_except. */ resume_kernel: - /* check current_thread_info, _TIF_EMULATE_STACK_STORE */ - CURRENT_THREAD_INFO(r9, r1) - lwz r8,TI_FLAGS(r9) - andis. r8,r8,_TIF_EMULATE_STACK_STORE@h - beq+ 1f - - addi r8,r1,INT_FRAME_SIZE /* Get the kprobed function entry */ - - lwz r3,GPR1(r1) - subi r3,r3,INT_FRAME_SIZE /* dst: Allocate a trampoline exception frame */ - mr r4,r1 /* src: current exception frame */ - mr r1,r3 /* Reroute the trampoline frame to r1 */ - - /* Copy from the original to the trampoline. */ - li r5,INT_FRAME_SIZE/4 /* size: INT_FRAME_SIZE */ - li r6,0 /* start offset: 0 */ - mtctr r5 -2: lwzx r0,r6,r4 - stwx r0,r6,r3 - addi r6,r6,4 - bdnz 2b - - /* Do real store operation to complete stwu */ - lwz r5,GPR1(r1) - stw r8,0(r5) - - /* Clear _TIF_EMULATE_STACK_STORE flag */ - lis r11,_TIF_EMULATE_STACK_STORE@h - addi r5,r9,TI_FLAGS -0: lwarx r8,0,r5 - andc r8,r8,r11 -#ifdef CONFIG_IBM405_ERR77 - dcbt 0,r5 -#endif - stwcx. r8,0,r5 - bne- 0b -1: - -#ifdef CONFIG_PREEMPT /* check current_thread_info->preempt_count */ + CURRENT_THREAD_INFO(r9, r1) lwz r0,TI_PREEMPT(r9) cmpwi 0,r0,0 /* if non-zero, just restore regs and return */ bne restore - andi. r8,r8,_TIF_NEED_RESCHED + lwz r0,TI_FLAGS(r9) + andi. r0,r0,_TIF_NEED_RESCHED beq+ restore - lwz r3,_MSR(r1) andi. r0,r3,MSR_EE /* interrupts off? */ beq restore /* don't schedule if so */ #ifdef CONFIG_TRACE_IRQFLAGS @@ -901,6 +864,8 @@ resume_kernel: */ bl trace_hardirqs_on #endif +#else +resume_kernel: #endif /* CONFIG_PREEMPT */ /* interrupts are hard-disabled at this point */ diff --git a/trunk/arch/powerpc/kernel/entry_64.S b/trunk/arch/powerpc/kernel/entry_64.S index 0e931aaffca2..b40e0b4815b3 100644 --- a/trunk/arch/powerpc/kernel/entry_64.S +++ b/trunk/arch/powerpc/kernel/entry_64.S @@ -593,41 +593,6 @@ _GLOBAL(ret_from_except_lite) b .ret_from_except resume_kernel: - /* check current_thread_info, _TIF_EMULATE_STACK_STORE */ - CURRENT_THREAD_INFO(r9, r1) - ld r8,TI_FLAGS(r9) - andis. r8,r8,_TIF_EMULATE_STACK_STORE@h - beq+ 1f - - addi r8,r1,INT_FRAME_SIZE /* Get the kprobed function entry */ - - lwz r3,GPR1(r1) - subi r3,r3,INT_FRAME_SIZE /* dst: Allocate a trampoline exception frame */ - mr r4,r1 /* src: current exception frame */ - mr r1,r3 /* Reroute the trampoline frame to r1 */ - - /* Copy from the original to the trampoline. */ - li r5,INT_FRAME_SIZE/8 /* size: INT_FRAME_SIZE */ - li r6,0 /* start offset: 0 */ - mtctr r5 -2: ldx r0,r6,r4 - stdx r0,r6,r3 - addi r6,r6,8 - bdnz 2b - - /* Do real store operation to complete stwu */ - lwz r5,GPR1(r1) - std r8,0(r5) - - /* Clear _TIF_EMULATE_STACK_STORE flag */ - lis r11,_TIF_EMULATE_STACK_STORE@h - addi r5,r9,TI_FLAGS - ldarx r4,0,r5 - andc r4,r4,r11 - stdcx. r4,0,r5 - bne- 0b -1: - #ifdef CONFIG_PREEMPT /* Check if we need to preempt */ andi. r0,r4,_TIF_NEED_RESCHED diff --git a/trunk/arch/powerpc/kernel/exceptions-64e.S b/trunk/arch/powerpc/kernel/exceptions-64e.S index 4684e33a26c3..98be7f0cd227 100644 --- a/trunk/arch/powerpc/kernel/exceptions-64e.S +++ b/trunk/arch/powerpc/kernel/exceptions-64e.S @@ -25,8 +25,6 @@ #include #include #include -#include -#include /* XXX This will ultimately add space for a special exception save * structure used to save things like SRR0/SRR1, SPRGs, MAS, etc... @@ -37,18 +35,16 @@ #define SPECIAL_EXC_FRAME_SIZE INT_FRAME_SIZE /* Exception prolog code for all exceptions */ -#define EXCEPTION_PROLOG(n, intnum, type, addition) \ +#define EXCEPTION_PROLOG(n, type, addition) \ mtspr SPRN_SPRG_##type##_SCRATCH,r13; /* get spare registers */ \ mfspr r13,SPRN_SPRG_PACA; /* get PACA */ \ std r10,PACA_EX##type+EX_R10(r13); \ std r11,PACA_EX##type+EX_R11(r13); \ - PROLOG_STORE_RESTORE_SCRATCH_##type; \ mfcr r10; /* save CR */ \ - mfspr r11,SPRN_##type##_SRR1;/* what are we coming from */ \ - DO_KVM intnum,SPRN_##type##_SRR1; /* KVM hook */ \ - stw r10,PACA_EX##type+EX_CR(r13); /* save old CR in the PACA */ \ addition; /* additional code for that exc. */ \ std r1,PACA_EX##type+EX_R1(r13); /* save old r1 in the PACA */ \ + stw r10,PACA_EX##type+EX_CR(r13); /* save old CR in the PACA */ \ + mfspr r11,SPRN_##type##_SRR1;/* what are we coming from */ \ type##_SET_KSTACK; /* get special stack if necessary */\ andi. r10,r11,MSR_PR; /* save stack pointer */ \ beq 1f; /* branch around if supervisor */ \ @@ -63,10 +59,6 @@ #define SPRN_GEN_SRR0 SPRN_SRR0 #define SPRN_GEN_SRR1 SPRN_SRR1 -#define GDBELL_SET_KSTACK GEN_SET_KSTACK -#define SPRN_GDBELL_SRR0 SPRN_GSRR0 -#define SPRN_GDBELL_SRR1 SPRN_GSRR1 - #define CRIT_SET_KSTACK \ ld r1,PACA_CRIT_STACK(r13); \ subi r1,r1,SPECIAL_EXC_FRAME_SIZE; @@ -85,46 +77,29 @@ #define SPRN_MC_SRR0 SPRN_MCSRR0 #define SPRN_MC_SRR1 SPRN_MCSRR1 -#define NORMAL_EXCEPTION_PROLOG(n, intnum, addition) \ - EXCEPTION_PROLOG(n, intnum, GEN, addition##_GEN(n)) - -#define CRIT_EXCEPTION_PROLOG(n, intnum, addition) \ - EXCEPTION_PROLOG(n, intnum, CRIT, addition##_CRIT(n)) +#define NORMAL_EXCEPTION_PROLOG(n, addition) \ + EXCEPTION_PROLOG(n, GEN, addition##_GEN(n)) -#define DBG_EXCEPTION_PROLOG(n, intnum, addition) \ - EXCEPTION_PROLOG(n, intnum, DBG, addition##_DBG(n)) +#define CRIT_EXCEPTION_PROLOG(n, addition) \ + EXCEPTION_PROLOG(n, CRIT, addition##_CRIT(n)) -#define MC_EXCEPTION_PROLOG(n, intnum, addition) \ - EXCEPTION_PROLOG(n, intnum, MC, addition##_MC(n)) +#define DBG_EXCEPTION_PROLOG(n, addition) \ + EXCEPTION_PROLOG(n, DBG, addition##_DBG(n)) -#define GDBELL_EXCEPTION_PROLOG(n, intnum, addition) \ - EXCEPTION_PROLOG(n, intnum, GDBELL, addition##_GDBELL(n)) +#define MC_EXCEPTION_PROLOG(n, addition) \ + EXCEPTION_PROLOG(n, MC, addition##_MC(n)) -/* - * Store user-visible scratch in PACA exception slots and restore proper value - */ -#define PROLOG_STORE_RESTORE_SCRATCH_GEN -#define PROLOG_STORE_RESTORE_SCRATCH_GDBELL -#define PROLOG_STORE_RESTORE_SCRATCH_DBG -#define PROLOG_STORE_RESTORE_SCRATCH_MC - -#define PROLOG_STORE_RESTORE_SCRATCH_CRIT \ - mfspr r10,SPRN_SPRG_CRIT_SCRATCH; /* get r13 */ \ - std r10,PACA_EXCRIT+EX_R13(r13); \ - ld r11,PACA_SPRG3(r13); \ - mtspr SPRN_SPRG_CRIT_SCRATCH,r11; /* Variants of the "addition" argument for the prolog */ #define PROLOG_ADDITION_NONE_GEN(n) -#define PROLOG_ADDITION_NONE_GDBELL(n) #define PROLOG_ADDITION_NONE_CRIT(n) #define PROLOG_ADDITION_NONE_DBG(n) #define PROLOG_ADDITION_NONE_MC(n) #define PROLOG_ADDITION_MASKABLE_GEN(n) \ - lbz r10,PACASOFTIRQEN(r13); /* are irqs soft-disabled ? */ \ - cmpwi cr0,r10,0; /* yes -> go out of line */ \ + lbz r11,PACASOFTIRQEN(r13); /* are irqs soft-disabled ? */ \ + cmpwi cr0,r11,0; /* yes -> go out of line */ \ beq masked_interrupt_book3e_##n #define PROLOG_ADDITION_2REGS_GEN(n) \ @@ -258,9 +233,9 @@ exc_##n##_bad_stack: \ 1: -#define MASKABLE_EXCEPTION(trapnum, intnum, label, hdlr, ack) \ +#define MASKABLE_EXCEPTION(trapnum, label, hdlr, ack) \ START_EXCEPTION(label); \ - NORMAL_EXCEPTION_PROLOG(trapnum, intnum, PROLOG_ADDITION_MASKABLE)\ + NORMAL_EXCEPTION_PROLOG(trapnum, PROLOG_ADDITION_MASKABLE) \ EXCEPTION_COMMON(trapnum, PACA_EXGEN, INTS_DISABLE) \ ack(r8); \ CHECK_NAPPING(); \ @@ -311,8 +286,7 @@ interrupt_end_book3e: /* Critical Input Interrupt */ START_EXCEPTION(critical_input); - CRIT_EXCEPTION_PROLOG(0x100, BOOKE_INTERRUPT_CRITICAL, - PROLOG_ADDITION_NONE) + CRIT_EXCEPTION_PROLOG(0x100, PROLOG_ADDITION_NONE) // EXCEPTION_COMMON(0x100, PACA_EXCRIT, INTS_DISABLE) // bl special_reg_save_crit // CHECK_NAPPING(); @@ -323,8 +297,7 @@ interrupt_end_book3e: /* Machine Check Interrupt */ START_EXCEPTION(machine_check); - MC_EXCEPTION_PROLOG(0x200, BOOKE_INTERRUPT_MACHINE_CHECK, - PROLOG_ADDITION_NONE) + CRIT_EXCEPTION_PROLOG(0x200, PROLOG_ADDITION_NONE) // EXCEPTION_COMMON(0x200, PACA_EXMC, INTS_DISABLE) // bl special_reg_save_mc // addi r3,r1,STACK_FRAME_OVERHEAD @@ -335,8 +308,7 @@ interrupt_end_book3e: /* Data Storage Interrupt */ START_EXCEPTION(data_storage) - NORMAL_EXCEPTION_PROLOG(0x300, BOOKE_INTERRUPT_DATA_STORAGE, - PROLOG_ADDITION_2REGS) + NORMAL_EXCEPTION_PROLOG(0x300, PROLOG_ADDITION_2REGS) mfspr r14,SPRN_DEAR mfspr r15,SPRN_ESR EXCEPTION_COMMON(0x300, PACA_EXGEN, INTS_DISABLE) @@ -344,21 +316,18 @@ interrupt_end_book3e: /* Instruction Storage Interrupt */ START_EXCEPTION(instruction_storage); - NORMAL_EXCEPTION_PROLOG(0x400, BOOKE_INTERRUPT_INST_STORAGE, - PROLOG_ADDITION_2REGS) + NORMAL_EXCEPTION_PROLOG(0x400, PROLOG_ADDITION_2REGS) li r15,0 mr r14,r10 EXCEPTION_COMMON(0x400, PACA_EXGEN, INTS_DISABLE) b storage_fault_common /* External Input Interrupt */ - MASKABLE_EXCEPTION(0x500, BOOKE_INTERRUPT_EXTERNAL, - external_input, .do_IRQ, ACK_NONE) + MASKABLE_EXCEPTION(0x500, external_input, .do_IRQ, ACK_NONE) /* Alignment */ START_EXCEPTION(alignment); - NORMAL_EXCEPTION_PROLOG(0x600, BOOKE_INTERRUPT_ALIGNMENT, - PROLOG_ADDITION_2REGS) + NORMAL_EXCEPTION_PROLOG(0x600, PROLOG_ADDITION_2REGS) mfspr r14,SPRN_DEAR mfspr r15,SPRN_ESR EXCEPTION_COMMON(0x600, PACA_EXGEN, INTS_KEEP) @@ -366,8 +335,7 @@ interrupt_end_book3e: /* Program Interrupt */ START_EXCEPTION(program); - NORMAL_EXCEPTION_PROLOG(0x700, BOOKE_INTERRUPT_PROGRAM, - PROLOG_ADDITION_1REG) + NORMAL_EXCEPTION_PROLOG(0x700, PROLOG_ADDITION_1REG) mfspr r14,SPRN_ESR EXCEPTION_COMMON(0x700, PACA_EXGEN, INTS_DISABLE) std r14,_DSISR(r1) @@ -379,8 +347,7 @@ interrupt_end_book3e: /* Floating Point Unavailable Interrupt */ START_EXCEPTION(fp_unavailable); - NORMAL_EXCEPTION_PROLOG(0x800, BOOKE_INTERRUPT_FP_UNAVAIL, - PROLOG_ADDITION_NONE) + NORMAL_EXCEPTION_PROLOG(0x800, PROLOG_ADDITION_NONE) /* we can probably do a shorter exception entry for that one... */ EXCEPTION_COMMON(0x800, PACA_EXGEN, INTS_KEEP) ld r12,_MSR(r1) @@ -395,17 +362,14 @@ interrupt_end_book3e: b .ret_from_except /* Decrementer Interrupt */ - MASKABLE_EXCEPTION(0x900, BOOKE_INTERRUPT_DECREMENTER, - decrementer, .timer_interrupt, ACK_DEC) + MASKABLE_EXCEPTION(0x900, decrementer, .timer_interrupt, ACK_DEC) /* Fixed Interval Timer Interrupt */ - MASKABLE_EXCEPTION(0x980, BOOKE_INTERRUPT_FIT, - fixed_interval, .unknown_exception, ACK_FIT) + MASKABLE_EXCEPTION(0x980, fixed_interval, .unknown_exception, ACK_FIT) /* Watchdog Timer Interrupt */ START_EXCEPTION(watchdog); - CRIT_EXCEPTION_PROLOG(0x9f0, BOOKE_INTERRUPT_WATCHDOG, - PROLOG_ADDITION_NONE) + CRIT_EXCEPTION_PROLOG(0x9f0, PROLOG_ADDITION_NONE) // EXCEPTION_COMMON(0x9f0, PACA_EXCRIT, INTS_DISABLE) // bl special_reg_save_crit // CHECK_NAPPING(); @@ -424,8 +388,7 @@ interrupt_end_book3e: /* Auxiliary Processor Unavailable Interrupt */ START_EXCEPTION(ap_unavailable); - NORMAL_EXCEPTION_PROLOG(0xf20, BOOKE_INTERRUPT_AP_UNAVAIL, - PROLOG_ADDITION_NONE) + NORMAL_EXCEPTION_PROLOG(0xf20, PROLOG_ADDITION_NONE) EXCEPTION_COMMON(0xf20, PACA_EXGEN, INTS_DISABLE) bl .save_nvgprs addi r3,r1,STACK_FRAME_OVERHEAD @@ -434,8 +397,7 @@ interrupt_end_book3e: /* Debug exception as a critical interrupt*/ START_EXCEPTION(debug_crit); - CRIT_EXCEPTION_PROLOG(0xd00, BOOKE_INTERRUPT_DEBUG, - PROLOG_ADDITION_2REGS) + CRIT_EXCEPTION_PROLOG(0xd00, PROLOG_ADDITION_2REGS) /* * If there is a single step or branch-taken exception in an @@ -469,7 +431,7 @@ interrupt_end_book3e: mtcr r10 ld r10,PACA_EXCRIT+EX_R10(r13) /* restore registers */ ld r11,PACA_EXCRIT+EX_R11(r13) - ld r13,PACA_EXCRIT+EX_R13(r13) + mfspr r13,SPRN_SPRG_CRIT_SCRATCH rfci /* Normal debug exception */ @@ -482,7 +444,7 @@ interrupt_end_book3e: /* Now we mash up things to make it look like we are coming on a * normal exception */ - ld r15,PACA_EXCRIT+EX_R13(r13) + mfspr r15,SPRN_SPRG_CRIT_SCRATCH mtspr SPRN_SPRG_GEN_SCRATCH,r15 mfspr r14,SPRN_DBSR EXCEPTION_COMMON(0xd00, PACA_EXCRIT, INTS_DISABLE) @@ -500,8 +462,7 @@ kernel_dbg_exc: /* Debug exception as a debug interrupt*/ START_EXCEPTION(debug_debug); - DBG_EXCEPTION_PROLOG(0xd00, BOOKE_INTERRUPT_DEBUG, - PROLOG_ADDITION_2REGS) + DBG_EXCEPTION_PROLOG(0xd08, PROLOG_ADDITION_2REGS) /* * If there is a single step or branch-taken exception in an @@ -562,21 +523,18 @@ kernel_dbg_exc: b .ret_from_except START_EXCEPTION(perfmon); - NORMAL_EXCEPTION_PROLOG(0x260, BOOKE_INTERRUPT_PERFORMANCE_MONITOR, - PROLOG_ADDITION_NONE) + NORMAL_EXCEPTION_PROLOG(0x260, PROLOG_ADDITION_NONE) EXCEPTION_COMMON(0x260, PACA_EXGEN, INTS_DISABLE) addi r3,r1,STACK_FRAME_OVERHEAD bl .performance_monitor_exception b .ret_from_except_lite /* Doorbell interrupt */ - MASKABLE_EXCEPTION(0x280, BOOKE_INTERRUPT_DOORBELL, - doorbell, .doorbell_exception, ACK_NONE) + MASKABLE_EXCEPTION(0x280, doorbell, .doorbell_exception, ACK_NONE) /* Doorbell critical Interrupt */ START_EXCEPTION(doorbell_crit); - CRIT_EXCEPTION_PROLOG(0x2a0, BOOKE_INTERRUPT_DOORBELL_CRITICAL, - PROLOG_ADDITION_NONE) + CRIT_EXCEPTION_PROLOG(0x2a0, PROLOG_ADDITION_NONE) // EXCEPTION_COMMON(0x2a0, PACA_EXCRIT, INTS_DISABLE) // bl special_reg_save_crit // CHECK_NAPPING(); @@ -585,24 +543,12 @@ kernel_dbg_exc: // b ret_from_crit_except b . -/* - * Guest doorbell interrupt - * This general exception use GSRRx save/restore registers - */ - START_EXCEPTION(guest_doorbell); - GDBELL_EXCEPTION_PROLOG(0x2c0, BOOKE_INTERRUPT_GUEST_DBELL, - PROLOG_ADDITION_NONE) - EXCEPTION_COMMON(0x2c0, PACA_EXGEN, INTS_KEEP) - addi r3,r1,STACK_FRAME_OVERHEAD - bl .save_nvgprs - INTS_RESTORE_HARD - bl .unknown_exception - b .ret_from_except +/* Guest Doorbell */ + MASKABLE_EXCEPTION(0x2c0, guest_doorbell, .unknown_exception, ACK_NONE) /* Guest Doorbell critical Interrupt */ START_EXCEPTION(guest_doorbell_crit); - CRIT_EXCEPTION_PROLOG(0x2e0, BOOKE_INTERRUPT_GUEST_DBELL_CRIT, - PROLOG_ADDITION_NONE) + CRIT_EXCEPTION_PROLOG(0x2e0, PROLOG_ADDITION_NONE) // EXCEPTION_COMMON(0x2e0, PACA_EXCRIT, INTS_DISABLE) // bl special_reg_save_crit // CHECK_NAPPING(); @@ -613,8 +559,7 @@ kernel_dbg_exc: /* Hypervisor call */ START_EXCEPTION(hypercall); - NORMAL_EXCEPTION_PROLOG(0x310, BOOKE_INTERRUPT_HV_SYSCALL, - PROLOG_ADDITION_NONE) + NORMAL_EXCEPTION_PROLOG(0x310, PROLOG_ADDITION_NONE) EXCEPTION_COMMON(0x310, PACA_EXGEN, INTS_KEEP) addi r3,r1,STACK_FRAME_OVERHEAD bl .save_nvgprs @@ -624,8 +569,7 @@ kernel_dbg_exc: /* Embedded Hypervisor priviledged */ START_EXCEPTION(ehpriv); - NORMAL_EXCEPTION_PROLOG(0x320, BOOKE_INTERRUPT_HV_PRIV, - PROLOG_ADDITION_NONE) + NORMAL_EXCEPTION_PROLOG(0x320, PROLOG_ADDITION_NONE) EXCEPTION_COMMON(0x320, PACA_EXGEN, INTS_KEEP) addi r3,r1,STACK_FRAME_OVERHEAD bl .save_nvgprs @@ -638,42 +582,44 @@ kernel_dbg_exc: * accordingly and if the interrupt is level sensitive, we hard disable */ -.macro masked_interrupt_book3e paca_irq full_mask - lbz r10,PACAIRQHAPPENED(r13) - ori r10,r10,\paca_irq - stb r10,PACAIRQHAPPENED(r13) - - .if \full_mask == 1 - rldicl r10,r11,48,1 /* clear MSR_EE */ - rotldi r11,r10,16 - mtspr SPRN_SRR1,r11 - .endif - - lwz r11,PACA_EXGEN+EX_CR(r13) - mtcr r11 - ld r10,PACA_EXGEN+EX_R10(r13) - ld r11,PACA_EXGEN+EX_R11(r13) - mfspr r13,SPRN_SPRG_GEN_SCRATCH - rfi - b . -.endm - masked_interrupt_book3e_0x500: - // XXX When adding support for EPR, use PACA_IRQ_EE_EDGE - masked_interrupt_book3e PACA_IRQ_EE 1 + /* XXX When adding support for EPR, use PACA_IRQ_EE_EDGE */ + li r11,PACA_IRQ_EE + b masked_interrupt_book3e_full_mask masked_interrupt_book3e_0x900: - ACK_DEC(r10); - masked_interrupt_book3e PACA_IRQ_DEC 0 - + ACK_DEC(r11); + li r11,PACA_IRQ_DEC + b masked_interrupt_book3e_no_mask masked_interrupt_book3e_0x980: - ACK_FIT(r10); - masked_interrupt_book3e PACA_IRQ_DEC 0 - + ACK_FIT(r11); + li r11,PACA_IRQ_DEC + b masked_interrupt_book3e_no_mask masked_interrupt_book3e_0x280: masked_interrupt_book3e_0x2c0: - masked_interrupt_book3e PACA_IRQ_DBELL 0 + li r11,PACA_IRQ_DBELL + b masked_interrupt_book3e_no_mask +masked_interrupt_book3e_no_mask: + mtcr r10 + lbz r10,PACAIRQHAPPENED(r13) + or r10,r10,r11 + stb r10,PACAIRQHAPPENED(r13) + b 1f +masked_interrupt_book3e_full_mask: + mtcr r10 + lbz r10,PACAIRQHAPPENED(r13) + or r10,r10,r11 + stb r10,PACAIRQHAPPENED(r13) + mfspr r10,SPRN_SRR1 + rldicl r11,r10,48,1 /* clear MSR_EE */ + rotldi r10,r11,16 + mtspr SPRN_SRR1,r10 +1: ld r10,PACA_EXGEN+EX_R10(r13); + ld r11,PACA_EXGEN+EX_R11(r13); + mfspr r13,SPRN_SPRG_GEN_SCRATCH; + rfi + b . /* * Called from arch_local_irq_enable when an interrupt needs * to be resent. r3 contains either 0x500,0x900,0x260 or 0x280 @@ -1356,11 +1302,25 @@ _GLOBAL(setup_perfmon_ivor) _GLOBAL(setup_doorbell_ivors) SET_IVOR(36, 0x280) /* Processor Doorbell */ SET_IVOR(37, 0x2a0) /* Processor Doorbell Crit */ + + /* Check MMUCFG[LPIDSIZE] to determine if we have category E.HV */ + mfspr r10,SPRN_MMUCFG + rlwinm. r10,r10,0,MMUCFG_LPIDSIZE + beqlr + + SET_IVOR(38, 0x2c0) /* Guest Processor Doorbell */ + SET_IVOR(39, 0x2e0) /* Guest Processor Doorbell Crit/MC */ blr _GLOBAL(setup_ehv_ivors) + /* + * We may be running as a guest and lack E.HV even on a chip + * that normally has it. + */ + mfspr r10,SPRN_MMUCFG + rlwinm. r10,r10,0,MMUCFG_LPIDSIZE + beqlr + SET_IVOR(40, 0x300) /* Embedded Hypervisor System Call */ SET_IVOR(41, 0x320) /* Embedded Hypervisor Privilege */ - SET_IVOR(38, 0x2c0) /* Guest Processor Doorbell */ - SET_IVOR(39, 0x2e0) /* Guest Processor Doorbell Crit/MC */ blr diff --git a/trunk/arch/powerpc/kernel/exceptions-64s.S b/trunk/arch/powerpc/kernel/exceptions-64s.S index 10b658ad65e1..39aa97d3ff88 100644 --- a/trunk/arch/powerpc/kernel/exceptions-64s.S +++ b/trunk/arch/powerpc/kernel/exceptions-64s.S @@ -275,31 +275,6 @@ vsx_unavailable_pSeries_1: STD_EXCEPTION_PSERIES(0x1300, 0x1300, instruction_breakpoint) KVM_HANDLER_PR_SKIP(PACA_EXGEN, EXC_STD, 0x1300) - . = 0x1500 - .global denorm_Hypervisor -denorm_exception_hv: - HMT_MEDIUM - mtspr SPRN_SPRG_HSCRATCH0,r13 - mfspr r13,SPRN_SPRG_HPACA - std r9,PACA_EXGEN+EX_R9(r13) - std r10,PACA_EXGEN+EX_R10(r13) - std r11,PACA_EXGEN+EX_R11(r13) - std r12,PACA_EXGEN+EX_R12(r13) - mfspr r9,SPRN_SPRG_HSCRATCH0 - std r9,PACA_EXGEN+EX_R13(r13) - mfcr r9 - -#ifdef CONFIG_PPC_DENORMALISATION - mfspr r10,SPRN_HSRR1 - mfspr r11,SPRN_HSRR0 /* save HSRR0 */ - andis. r10,r10,(HSRR1_DENORM)@h /* denorm? */ - addi r11,r11,-4 /* HSRR0 is next instruction */ - bne+ denorm_assist -#endif - - EXCEPTION_PROLOG_PSERIES_1(denorm_common, EXC_HV) - KVM_HANDLER_SKIP(PACA_EXGEN, EXC_STD, 0x1500) - #ifdef CONFIG_CBE_RAS STD_EXCEPTION_HV(0x1600, 0x1602, cbe_maintenance) KVM_HANDLER_SKIP(PACA_EXGEN, EXC_HV, 0x1602) @@ -361,103 +336,6 @@ do_stab_bolted_pSeries: KVM_HANDLER_PR(PACA_EXGEN, EXC_STD, 0x900) KVM_HANDLER(PACA_EXGEN, EXC_HV, 0x982) -#ifdef CONFIG_PPC_DENORMALISATION -denorm_assist: -BEGIN_FTR_SECTION -/* - * To denormalise we need to move a copy of the register to itself. - * For POWER6 do that here for all FP regs. - */ - mfmsr r10 - ori r10,r10,(MSR_FP|MSR_FE0|MSR_FE1) - xori r10,r10,(MSR_FE0|MSR_FE1) - mtmsrd r10 - sync - fmr 0,0 - fmr 1,1 - fmr 2,2 - fmr 3,3 - fmr 4,4 - fmr 5,5 - fmr 6,6 - fmr 7,7 - fmr 8,8 - fmr 9,9 - fmr 10,10 - fmr 11,11 - fmr 12,12 - fmr 13,13 - fmr 14,14 - fmr 15,15 - fmr 16,16 - fmr 17,17 - fmr 18,18 - fmr 19,19 - fmr 20,20 - fmr 21,21 - fmr 22,22 - fmr 23,23 - fmr 24,24 - fmr 25,25 - fmr 26,26 - fmr 27,27 - fmr 28,28 - fmr 29,29 - fmr 30,30 - fmr 31,31 -FTR_SECTION_ELSE -/* - * To denormalise we need to move a copy of the register to itself. - * For POWER7 do that here for the first 32 VSX registers only. - */ - mfmsr r10 - oris r10,r10,MSR_VSX@h - mtmsrd r10 - sync - XVCPSGNDP(0,0,0) - XVCPSGNDP(1,1,1) - XVCPSGNDP(2,2,2) - XVCPSGNDP(3,3,3) - XVCPSGNDP(4,4,4) - XVCPSGNDP(5,5,5) - XVCPSGNDP(6,6,6) - XVCPSGNDP(7,7,7) - XVCPSGNDP(8,8,8) - XVCPSGNDP(9,9,9) - XVCPSGNDP(10,10,10) - XVCPSGNDP(11,11,11) - XVCPSGNDP(12,12,12) - XVCPSGNDP(13,13,13) - XVCPSGNDP(14,14,14) - XVCPSGNDP(15,15,15) - XVCPSGNDP(16,16,16) - XVCPSGNDP(17,17,17) - XVCPSGNDP(18,18,18) - XVCPSGNDP(19,19,19) - XVCPSGNDP(20,20,20) - XVCPSGNDP(21,21,21) - XVCPSGNDP(22,22,22) - XVCPSGNDP(23,23,23) - XVCPSGNDP(24,24,24) - XVCPSGNDP(25,25,25) - XVCPSGNDP(26,26,26) - XVCPSGNDP(27,27,27) - XVCPSGNDP(28,28,28) - XVCPSGNDP(29,29,29) - XVCPSGNDP(30,30,30) - XVCPSGNDP(31,31,31) -ALT_FTR_SECTION_END_IFCLR(CPU_FTR_ARCH_206) - mtspr SPRN_HSRR0,r11 - mtcrf 0x80,r9 - ld r9,PACA_EXGEN+EX_R9(r13) - ld r10,PACA_EXGEN+EX_R10(r13) - ld r11,PACA_EXGEN+EX_R11(r13) - ld r12,PACA_EXGEN+EX_R12(r13) - ld r13,PACA_EXGEN+EX_R13(r13) - HRFID - b . -#endif - .align 7 /* moved from 0xe00 */ STD_EXCEPTION_HV(., 0xe02, h_data_storage) @@ -617,7 +495,6 @@ machine_check_common: STD_EXCEPTION_COMMON(0xe60, hmi_exception, .unknown_exception) STD_EXCEPTION_COMMON_ASYNC(0xf00, performance_monitor, .performance_monitor_exception) STD_EXCEPTION_COMMON(0x1300, instruction_breakpoint, .instruction_breakpoint_exception) - STD_EXCEPTION_COMMON(0x1502, denorm, .unknown_exception) #ifdef CONFIG_ALTIVEC STD_EXCEPTION_COMMON(0x1700, altivec_assist, .altivec_assist_exception) #else @@ -1083,9 +960,7 @@ _GLOBAL(do_stab_bolted) rldimi r10,r11,7,52 /* r10 = first ste of the group */ /* Calculate VSID */ - /* This is a kernel address, so protovsid = ESID | 1 << 37 */ - li r9,0x1 - rldimi r11,r9,(CONTEXT_BITS + USER_ESID_BITS),0 + /* This is a kernel address, so protovsid = ESID */ ASM_VSID_SCRAMBLE(r11, r9, 256M) rldic r9,r11,12,16 /* r9 = vsid << 12 */ diff --git a/trunk/arch/powerpc/kernel/fadump.c b/trunk/arch/powerpc/kernel/fadump.c index 06c8202a69cf..18bdf74fa164 100644 --- a/trunk/arch/powerpc/kernel/fadump.c +++ b/trunk/arch/powerpc/kernel/fadump.c @@ -289,7 +289,8 @@ int __init fadump_reserve_mem(void) else memory_limit = memblock_end_of_DRAM(); printk(KERN_INFO "Adjusted memory_limit for firmware-assisted" - " dump, now %#016llx\n", memory_limit); + " dump, now %#016llx\n", + (unsigned long long)memory_limit); } if (memory_limit) memory_boundary = memory_limit; diff --git a/trunk/arch/powerpc/kernel/head_fsl_booke.S b/trunk/arch/powerpc/kernel/head_fsl_booke.S index 6f62a737f607..0f59863c3ade 100644 --- a/trunk/arch/powerpc/kernel/head_fsl_booke.S +++ b/trunk/arch/powerpc/kernel/head_fsl_booke.S @@ -895,11 +895,15 @@ _GLOBAL(__setup_e500mc_ivors) mtspr SPRN_IVOR36,r3 li r3,CriticalDoorbell@l mtspr SPRN_IVOR37,r3 - sync - blr -/* setup ehv ivors for */ -_GLOBAL(__setup_ehv_ivors) + /* + * We only want to touch IVOR38-41 if we're running on hardware + * that supports category E.HV. The architectural way to determine + * this is MMUCFG[LPIDSIZE]. + */ + mfspr r3, SPRN_MMUCFG + andis. r3, r3, MMUCFG_LPIDSIZE@h + beq no_hv li r3,GuestDoorbell@l mtspr SPRN_IVOR38,r3 li r3,CriticalGuestDoorbell@l @@ -908,8 +912,14 @@ _GLOBAL(__setup_ehv_ivors) mtspr SPRN_IVOR40,r3 li r3,Ehvpriv@l mtspr SPRN_IVOR41,r3 +skip_hv_ivors: sync blr +no_hv: + lwz r3, CPU_SPEC_FEATURES(r5) + rlwinm r3, r3, 0, ~CPU_FTR_EMB_HV + stw r3, CPU_SPEC_FEATURES(r5) + b skip_hv_ivors #ifdef CONFIG_SPE /* @@ -1033,34 +1043,6 @@ _GLOBAL(flush_dcache_L1) blr -/* Flush L1 d-cache, invalidate and disable d-cache and i-cache */ -_GLOBAL(__flush_disable_L1) - mflr r10 - bl flush_dcache_L1 /* Flush L1 d-cache */ - mtlr r10 - - mfspr r4, SPRN_L1CSR0 /* Invalidate and disable d-cache */ - li r5, 2 - rlwimi r4, r5, 0, 3 - - msync - isync - mtspr SPRN_L1CSR0, r4 - isync - -1: mfspr r4, SPRN_L1CSR0 /* Wait for the invalidate to finish */ - andi. r4, r4, 2 - bne 1b - - mfspr r4, SPRN_L1CSR1 /* Invalidate and disable i-cache */ - li r5, 2 - rlwimi r4, r5, 0, 3 - - mtspr SPRN_L1CSR1, r4 - isync - - blr - #ifdef CONFIG_SMP /* When we get here, r24 needs to hold the CPU # */ .globl __secondary_start diff --git a/trunk/arch/powerpc/kernel/hw_breakpoint.c b/trunk/arch/powerpc/kernel/hw_breakpoint.c index a89cae481b04..956a4c496de9 100644 --- a/trunk/arch/powerpc/kernel/hw_breakpoint.c +++ b/trunk/arch/powerpc/kernel/hw_breakpoint.c @@ -73,7 +73,7 @@ int arch_install_hw_breakpoint(struct perf_event *bp) * If so, DABR will be populated in single_step_dabr_instruction(). */ if (current->thread.last_hit_ubp != bp) - set_dabr(info->address | info->type | DABR_TRANSLATION, info->dabrx); + set_dabr(info->address | info->type | DABR_TRANSLATION); return 0; } @@ -97,7 +97,7 @@ void arch_uninstall_hw_breakpoint(struct perf_event *bp) } *slot = NULL; - set_dabr(0, 0); + set_dabr(0); } /* @@ -170,13 +170,6 @@ int arch_validate_hwbkpt_settings(struct perf_event *bp) info->address = bp->attr.bp_addr; info->len = bp->attr.bp_len; - info->dabrx = DABRX_ALL; - if (bp->attr.exclude_user) - info->dabrx &= ~DABRX_USER; - if (bp->attr.exclude_kernel) - info->dabrx &= ~DABRX_KERNEL; - if (bp->attr.exclude_hv) - info->dabrx &= ~DABRX_HYP; /* * Since breakpoint length can be a maximum of HW_BREAKPOINT_LEN(8) @@ -204,7 +197,7 @@ void thread_change_pc(struct task_struct *tsk, struct pt_regs *regs) info = counter_arch_bp(tsk->thread.last_hit_ubp); regs->msr &= ~MSR_SE; - set_dabr(info->address | info->type | DABR_TRANSLATION, info->dabrx); + set_dabr(info->address | info->type | DABR_TRANSLATION); tsk->thread.last_hit_ubp = NULL; } @@ -222,7 +215,7 @@ int __kprobes hw_breakpoint_handler(struct die_args *args) unsigned long dar = regs->dar; /* Disable breakpoints during exception handling */ - set_dabr(0, 0); + set_dabr(0); /* * The counter may be concurrently released but that can only @@ -288,7 +281,7 @@ int __kprobes hw_breakpoint_handler(struct die_args *args) if (!info->extraneous_interrupt) perf_bp_event(bp, regs); - set_dabr(info->address | info->type | DABR_TRANSLATION, info->dabrx); + set_dabr(info->address | info->type | DABR_TRANSLATION); out: rcu_read_unlock(); return rc; @@ -301,7 +294,7 @@ int __kprobes single_step_dabr_instruction(struct die_args *args) { struct pt_regs *regs = args->regs; struct perf_event *bp = NULL; - struct arch_hw_breakpoint *info; + struct arch_hw_breakpoint *bp_info; bp = current->thread.last_hit_ubp; /* @@ -311,16 +304,16 @@ int __kprobes single_step_dabr_instruction(struct die_args *args) if (!bp) return NOTIFY_DONE; - info = counter_arch_bp(bp); + bp_info = counter_arch_bp(bp); /* * We shall invoke the user-defined callback function in the single * stepping handler to confirm to 'trigger-after-execute' semantics */ - if (!info->extraneous_interrupt) + if (!bp_info->extraneous_interrupt) perf_bp_event(bp, regs); - set_dabr(info->address | info->type | DABR_TRANSLATION, info->dabrx); + set_dabr(bp_info->address | bp_info->type | DABR_TRANSLATION); current->thread.last_hit_ubp = NULL; /* diff --git a/trunk/arch/powerpc/kernel/ibmebus.c b/trunk/arch/powerpc/kernel/ibmebus.c index 8220baa46faf..b01d14eeca8d 100644 --- a/trunk/arch/powerpc/kernel/ibmebus.c +++ b/trunk/arch/powerpc/kernel/ibmebus.c @@ -47,6 +47,7 @@ #include #include #include +#include static struct device ibmebus_bus_device = { /* fake "parent" device */ .init_name = "ibmebus", diff --git a/trunk/arch/powerpc/kernel/iommu.c b/trunk/arch/powerpc/kernel/iommu.c index 8226c6cb348a..ff5a6ce027b8 100644 --- a/trunk/arch/powerpc/kernel/iommu.c +++ b/trunk/arch/powerpc/kernel/iommu.c @@ -215,8 +215,7 @@ static unsigned long iommu_range_alloc(struct device *dev, spin_lock_irqsave(&(pool->lock), flags); again: - if ((pass == 0) && handle && *handle && - (*handle >= pool->start) && (*handle < pool->end)) + if ((pass == 0) && handle && *handle) start = *handle; else start = pool->hint; @@ -237,9 +236,7 @@ static unsigned long iommu_range_alloc(struct device *dev, * but on second pass, start at 0 in pool 0. */ if ((start & mask) >= limit || pass > 0) { - spin_unlock(&(pool->lock)); pool = &(tbl->pools[0]); - spin_lock(&(pool->lock)); start = pool->start; } else { start &= mask; diff --git a/trunk/arch/powerpc/kernel/irq.c b/trunk/arch/powerpc/kernel/irq.c index 71413f41278f..1f017bb7a7ce 100644 --- a/trunk/arch/powerpc/kernel/irq.c +++ b/trunk/arch/powerpc/kernel/irq.c @@ -489,10 +489,10 @@ void do_IRQ(struct pt_regs *regs) struct pt_regs *old_regs = set_irq_regs(regs); unsigned int irq; - irq_enter(); - trace_irq_entry(regs); + irq_enter(); + check_stack_overflow(); /* @@ -511,10 +511,10 @@ void do_IRQ(struct pt_regs *regs) else __get_cpu_var(irq_stat).spurious_irqs++; - trace_irq_exit(regs); - irq_exit(); set_irq_regs(old_regs); + + trace_irq_exit(regs); } void __init init_IRQ(void) diff --git a/trunk/arch/powerpc/kernel/machine_kexec.c b/trunk/arch/powerpc/kernel/machine_kexec.c index fa9f6c72f557..5df777794403 100644 --- a/trunk/arch/powerpc/kernel/machine_kexec.c +++ b/trunk/arch/powerpc/kernel/machine_kexec.c @@ -165,7 +165,7 @@ void __init reserve_crashkernel(void) if (memory_limit && memory_limit <= crashk_res.end) { memory_limit = crashk_res.end + 1; printk("Adjusted memory limit for crashkernel, now 0x%llx\n", - memory_limit); + (unsigned long long)memory_limit); } printk(KERN_INFO "Reserving %ldMB of memory at %ldMB " @@ -204,12 +204,6 @@ static struct property crashk_size_prop = { .value = &crashk_size, }; -static struct property memory_limit_prop = { - .name = "linux,memory-limit", - .length = sizeof(unsigned long long), - .value = &memory_limit, -}; - static void __init export_crashk_values(struct device_node *node) { struct property *prop; @@ -229,12 +223,6 @@ static void __init export_crashk_values(struct device_node *node) crashk_size = resource_size(&crashk_res); prom_add_property(node, &crashk_size_prop); } - - /* - * memory_limit is required by the kexec-tools to limit the - * crash regions to the actual memory used. - */ - prom_update_property(node, &memory_limit_prop); } static int __init kexec_setup(void) diff --git a/trunk/arch/powerpc/kernel/paca.c b/trunk/arch/powerpc/kernel/paca.c index cd6da855090c..fbe1a12dc7f1 100644 --- a/trunk/arch/powerpc/kernel/paca.c +++ b/trunk/arch/powerpc/kernel/paca.c @@ -142,7 +142,6 @@ void __init initialise_paca(struct paca_struct *new_paca, int cpu) new_paca->hw_cpu_id = 0xffff; new_paca->kexec_state = KEXEC_STATE_NONE; new_paca->__current = &init_task; - new_paca->data_offset = 0xfeeeeeeeeeeeeeeeULL; #ifdef CONFIG_PPC_STD_MMU_64 new_paca->slb_shadow_ptr = &slb_shadow[cpu]; #endif /* CONFIG_PPC_STD_MMU_64 */ diff --git a/trunk/arch/powerpc/kernel/pci-common.c b/trunk/arch/powerpc/kernel/pci-common.c index 7f94f760dd0c..43fea543d686 100644 --- a/trunk/arch/powerpc/kernel/pci-common.c +++ b/trunk/arch/powerpc/kernel/pci-common.c @@ -980,14 +980,13 @@ static void __devinit pcibios_fixup_bridge(struct pci_bus *bus) if (i >= 3 && bus->self->transparent) continue; - /* If we're going to reassign everything, we can - * shrink the P2P resource to have size as being - * of 0 in order to save space. + /* If we are going to re-assign everything, mark the resource + * as unset and move it down to 0 */ if (pci_has_flag(PCI_REASSIGN_ALL_RSRC)) { res->flags |= IORESOURCE_UNSET; + res->end -= res->start; res->start = 0; - res->end = -1; continue; } @@ -1249,14 +1248,7 @@ void pcibios_allocate_bus_resources(struct pci_bus *bus) pr_warning("PCI: Cannot allocate resource region " "%d of PCI bridge %d, will remap\n", i, bus->number); clear_resource: - /* The resource might be figured out when doing - * reassignment based on the resources required - * by the downstream PCI devices. Here we set - * the size of the resource to be 0 in order to - * save more space. - */ - res->start = 0; - res->end = -1; + res->start = res->end = 0; res->flags = 0; } diff --git a/trunk/arch/powerpc/kernel/ppc32.h b/trunk/arch/powerpc/kernel/ppc32.h index 02fb0ee26093..dc16aefe1dd0 100644 --- a/trunk/arch/powerpc/kernel/ppc32.h +++ b/trunk/arch/powerpc/kernel/ppc32.h @@ -16,6 +16,57 @@ /* These are here to support 32-bit syscalls on a 64-bit kernel. */ +typedef struct compat_siginfo { + int si_signo; + int si_errno; + int si_code; + + union { + int _pad[SI_PAD_SIZE32]; + + /* kill() */ + struct { + compat_pid_t _pid; /* sender's pid */ + compat_uid_t _uid; /* sender's uid */ + } _kill; + + /* POSIX.1b timers */ + struct { + compat_timer_t _tid; /* timer id */ + int _overrun; /* overrun count */ + compat_sigval_t _sigval; /* same as below */ + int _sys_private; /* not to be passed to user */ + } _timer; + + /* POSIX.1b signals */ + struct { + compat_pid_t _pid; /* sender's pid */ + compat_uid_t _uid; /* sender's uid */ + compat_sigval_t _sigval; + } _rt; + + /* SIGCHLD */ + struct { + compat_pid_t _pid; /* which child */ + compat_uid_t _uid; /* sender's uid */ + int _status; /* exit code */ + compat_clock_t _utime; + compat_clock_t _stime; + } _sigchld; + + /* SIGILL, SIGFPE, SIGSEGV, SIGBUS, SIGEMT */ + struct { + unsigned int _addr; /* faulting insn/memory ref. */ + } _sigfault; + + /* SIGPOLL */ + struct { + int _band; /* POLL_IN, POLL_OUT, POLL_MSG */ + int _fd; + } _sigpoll; + } _sifields; +} compat_siginfo_t; + #define __old_sigaction32 old_sigaction32 struct __old_sigaction32 { diff --git a/trunk/arch/powerpc/kernel/process.c b/trunk/arch/powerpc/kernel/process.c index d5ad666efd8b..e9cb51f5f801 100644 --- a/trunk/arch/powerpc/kernel/process.c +++ b/trunk/arch/powerpc/kernel/process.c @@ -258,7 +258,6 @@ void do_send_trap(struct pt_regs *regs, unsigned long address, { siginfo_t info; - current->thread.trap_nr = signal_code; if (notify_die(DIE_DABR_MATCH, "dabr_match", regs, error_code, 11, SIGSEGV) == NOTIFY_STOP) return; @@ -276,7 +275,6 @@ void do_dabr(struct pt_regs *regs, unsigned long address, { siginfo_t info; - current->thread.trap_nr = TRAP_HWBKPT; if (notify_die(DIE_DABR_MATCH, "dabr_match", regs, error_code, 11, SIGSEGV) == NOTIFY_STOP) return; @@ -285,7 +283,7 @@ void do_dabr(struct pt_regs *regs, unsigned long address, return; /* Clear the DABR */ - set_dabr(0, 0); + set_dabr(0); /* Deliver the signal to userspace */ info.si_signo = SIGTRAP; @@ -366,19 +364,18 @@ static void set_debug_reg_defaults(struct thread_struct *thread) { if (thread->dabr) { thread->dabr = 0; - thread->dabrx = 0; - set_dabr(0, 0); + set_dabr(0); } } #endif /* !CONFIG_HAVE_HW_BREAKPOINT */ #endif /* CONFIG_PPC_ADV_DEBUG_REGS */ -int set_dabr(unsigned long dabr, unsigned long dabrx) +int set_dabr(unsigned long dabr) { __get_cpu_var(current_dabr) = dabr; if (ppc_md.set_dabr) - return ppc_md.set_dabr(dabr, dabrx); + return ppc_md.set_dabr(dabr); /* XXX should we have a CPU_FTR_HAS_DABR ? */ #ifdef CONFIG_PPC_ADV_DEBUG_REGS @@ -388,8 +385,9 @@ int set_dabr(unsigned long dabr, unsigned long dabrx) #endif #elif defined(CONFIG_PPC_BOOK3S) mtspr(SPRN_DABR, dabr); - mtspr(SPRN_DABRX, dabrx); #endif + + return 0; } @@ -482,7 +480,7 @@ struct task_struct *__switch_to(struct task_struct *prev, */ #ifndef CONFIG_HAVE_HW_BREAKPOINT if (unlikely(__get_cpu_var(current_dabr) != new->thread.dabr)) - set_dabr(new->thread.dabr, new->thread.dabrx); + set_dabr(new->thread.dabr); #endif /* CONFIG_HAVE_HW_BREAKPOINT */ #endif diff --git a/trunk/arch/powerpc/kernel/prom.c b/trunk/arch/powerpc/kernel/prom.c index 37725e86651e..f191bf02943a 100644 --- a/trunk/arch/powerpc/kernel/prom.c +++ b/trunk/arch/powerpc/kernel/prom.c @@ -78,7 +78,7 @@ static int __init early_parse_mem(char *p) return 1; memory_limit = PAGE_ALIGN(memparse(p, &p)); - DBG("memory limit = 0x%llx\n", memory_limit); + DBG("memory limit = 0x%llx\n", (unsigned long long)memory_limit); return 0; } @@ -661,7 +661,7 @@ void __init early_init_devtree(void *params) /* make sure we've parsed cmdline for mem= before this */ if (memory_limit) - first_memblock_size = min_t(u64, first_memblock_size, memory_limit); + first_memblock_size = min(first_memblock_size, memory_limit); setup_initial_memory_limit(memstart_addr, first_memblock_size); /* Reserve MEMBLOCK regions used by kernel, initrd, dt, etc... */ memblock_reserve(PHYSICAL_START, __pa(klimit) - PHYSICAL_START); diff --git a/trunk/arch/powerpc/kernel/prom_init.c b/trunk/arch/powerpc/kernel/prom_init.c index cb6c123722a2..e144498bcddd 100644 --- a/trunk/arch/powerpc/kernel/prom_init.c +++ b/trunk/arch/powerpc/kernel/prom_init.c @@ -705,7 +705,6 @@ static void __init early_cmdline_parse(void) #endif #define OV5_TYPE1_AFFINITY 0x80 /* Type 1 NUMA affinity */ #define OV5_PFO_HW_RNG 0x80 /* PFO Random Number Generator */ -#define OV5_PFO_HW_842 0x40 /* PFO Compression Accelerator */ #define OV5_PFO_HW_ENCR 0x20 /* PFO Encryption Accelerator */ /* Option Vector 6: IBM PAPR hints */ @@ -775,7 +774,8 @@ static unsigned char ibm_architecture_vec[] = { 0, 0, 0, - OV5_PFO_HW_RNG | OV5_PFO_HW_ENCR | OV5_PFO_HW_842, + OV5_PFO_HW_RNG | OV5_PFO_HW_ENCR, + /* option vector 6: IBM PAPR hints */ 4 - 2, /* length */ 0, @@ -1748,7 +1748,7 @@ static void __init prom_initialize_tce_table(void) * else will impact performance, so we always allocate 8MB. * Anton */ - if (pvr_version_is(PVR_POWER4) || pvr_version_is(PVR_POWER4p)) + if (__is_processor(PV_POWER4) || __is_processor(PV_POWER4p)) minsize = 8UL << 20; else minsize = 4UL << 20; diff --git a/trunk/arch/powerpc/kernel/ptrace.c b/trunk/arch/powerpc/kernel/ptrace.c index 79d8e56470df..c10fc28b9092 100644 --- a/trunk/arch/powerpc/kernel/ptrace.c +++ b/trunk/arch/powerpc/kernel/ptrace.c @@ -960,7 +960,6 @@ int ptrace_set_debugreg(struct task_struct *task, unsigned long addr, thread->ptrace_bps[0] = bp; ptrace_put_breakpoints(task); thread->dabr = data; - thread->dabrx = DABRX_ALL; return 0; } @@ -984,7 +983,6 @@ int ptrace_set_debugreg(struct task_struct *task, unsigned long addr, /* Move contents to the DABR register */ task->thread.dabr = data; - task->thread.dabrx = DABRX_ALL; #else /* CONFIG_PPC_ADV_DEBUG_REGS */ /* As described above, it was assumed 3 bits were passed with the data * address, but we will assume only the mode bits will be passed @@ -1399,7 +1397,6 @@ static long ppc_set_hwdebug(struct task_struct *child, dabr |= DABR_DATA_WRITE; child->thread.dabr = dabr; - child->thread.dabrx = DABRX_ALL; return 1; #endif /* !CONFIG_PPC_ADV_DEBUG_DVCS */ diff --git a/trunk/arch/powerpc/kernel/rtas_flash.c b/trunk/arch/powerpc/kernel/rtas_flash.c index 20b0120db0c3..2c0ee6405633 100644 --- a/trunk/arch/powerpc/kernel/rtas_flash.c +++ b/trunk/arch/powerpc/kernel/rtas_flash.c @@ -21,6 +21,7 @@ #include #include #include +#include #define MODULE_VERS "1.0" #define MODULE_NAME "rtas_flash" @@ -581,7 +582,7 @@ static void rtas_flash_firmware(int reboot_type) flist = (struct flash_block_list *)&rtas_data_buf[0]; flist->num_blocks = 0; flist->next = rtas_firmware_flash_list; - rtas_block_list = __pa(flist); + rtas_block_list = virt_to_abs(flist); if (rtas_block_list >= 4UL*1024*1024*1024) { printk(KERN_ALERT "FLASH: kernel bug...flash list header addr above 4GB\n"); spin_unlock(&rtas_data_buf_lock); @@ -595,13 +596,13 @@ static void rtas_flash_firmware(int reboot_type) for (f = flist; f; f = next) { /* Translate data addrs to absolute */ for (i = 0; i < f->num_blocks; i++) { - f->blocks[i].data = (char *)__pa(f->blocks[i].data); + f->blocks[i].data = (char *)virt_to_abs(f->blocks[i].data); image_size += f->blocks[i].length; } next = f->next; /* Don't translate NULL pointer for last entry */ if (f->next) - f->next = (struct flash_block_list *)__pa(f->next); + f->next = (struct flash_block_list *)virt_to_abs(f->next); else f->next = NULL; /* make num_blocks into the version/length field */ diff --git a/trunk/arch/powerpc/kernel/rtas_pci.c b/trunk/arch/powerpc/kernel/rtas_pci.c index 6de63e3250bb..179af906dcda 100644 --- a/trunk/arch/powerpc/kernel/rtas_pci.c +++ b/trunk/arch/powerpc/kernel/rtas_pci.c @@ -81,7 +81,7 @@ int rtas_read_config(struct pci_dn *pdn, int where, int size, u32 *val) return PCIBIOS_DEVICE_NOT_FOUND; if (returnval == EEH_IO_ERROR_VALUE(size) && - eeh_dev_check_failure(of_node_to_eeh_dev(pdn->node))) + eeh_dn_check_failure (pdn->node, NULL)) return PCIBIOS_DEVICE_NOT_FOUND; return PCIBIOS_SUCCESSFUL; @@ -275,6 +275,9 @@ void __init find_and_init_phbs(void) of_node_put(root); pci_devs_phb_init(); + /* Create EEH devices for all PHBs */ + eeh_dev_phb_init(); + /* * PCI_PROBE_ONLY and PCI_REASSIGN_ALL_BUS can be set via properties * in chosen. diff --git a/trunk/arch/powerpc/kernel/setup_64.c b/trunk/arch/powerpc/kernel/setup_64.c index efb6a41b3131..389bd4f0cdb1 100644 --- a/trunk/arch/powerpc/kernel/setup_64.c +++ b/trunk/arch/powerpc/kernel/setup_64.c @@ -208,8 +208,6 @@ void __init early_setup(unsigned long dt_ptr) /* Fix up paca fields required for the boot cpu */ get_paca()->cpu_start = 1; - /* Allow percpu accesses to "work" until we setup percpu data */ - get_paca()->data_offset = 0; /* Probe the machine type */ probe_machine(); diff --git a/trunk/arch/powerpc/kernel/signal.c b/trunk/arch/powerpc/kernel/signal.c index a2dc75793bd5..5c023c9cf16e 100644 --- a/trunk/arch/powerpc/kernel/signal.c +++ b/trunk/arch/powerpc/kernel/signal.c @@ -11,7 +11,6 @@ #include #include -#include #include #include #include @@ -131,7 +130,7 @@ static int do_signal(struct pt_regs *regs) * triggered inside the kernel. */ if (current->thread.dabr) - set_dabr(current->thread.dabr, current->thread.dabrx); + set_dabr(current->thread.dabr); #endif /* Re-enable the breakpoints for the signal stack */ thread_change_pc(current, regs); @@ -158,11 +157,6 @@ static int do_signal(struct pt_regs *regs) void do_notify_resume(struct pt_regs *regs, unsigned long thread_info_flags) { - if (thread_info_flags & _TIF_UPROBE) { - clear_thread_flag(TIF_UPROBE); - uprobe_notify_resume(regs); - } - if (thread_info_flags & _TIF_SIGPENDING) do_signal(regs); diff --git a/trunk/arch/powerpc/kernel/smp.c b/trunk/arch/powerpc/kernel/smp.c index 2b952b5386fd..8d4214afc21d 100644 --- a/trunk/arch/powerpc/kernel/smp.c +++ b/trunk/arch/powerpc/kernel/smp.c @@ -102,7 +102,7 @@ int __devinit smp_generic_kick_cpu(int nr) * Ok it's not there, so it might be soft-unplugged, let's * try to bring it back */ - generic_set_cpu_up(nr); + per_cpu(cpu_state, nr) = CPU_UP_PREPARE; smp_wmb(); smp_send_reschedule(nr); #endif /* CONFIG_HOTPLUG_CPU */ @@ -171,7 +171,7 @@ int smp_request_message_ipi(int virq, int msg) } #endif err = request_irq(virq, smp_ipi_action[msg], - IRQF_PERCPU | IRQF_NO_THREAD | IRQF_NO_SUSPEND, + IRQF_PERCPU | IRQF_NO_THREAD, smp_ipi_name[msg], 0); WARN(err < 0, "unable to request_irq %d for %s (rc %d)\n", virq, smp_ipi_name[msg], err); @@ -413,16 +413,6 @@ void generic_set_cpu_dead(unsigned int cpu) per_cpu(cpu_state, cpu) = CPU_DEAD; } -/* - * The cpu_state should be set to CPU_UP_PREPARE in kick_cpu(), otherwise - * the cpu_state is always CPU_DEAD after calling generic_set_cpu_dead(), - * which makes the delay in generic_cpu_die() not happen. - */ -void generic_set_cpu_up(unsigned int cpu) -{ - per_cpu(cpu_state, cpu) = CPU_UP_PREPARE; -} - int generic_check_cpu_restart(unsigned int cpu) { return per_cpu(cpu_state, cpu) == CPU_UP_PREPARE; diff --git a/trunk/arch/powerpc/kernel/time.c b/trunk/arch/powerpc/kernel/time.c index c9986fd400d8..eaa9d0e6abca 100644 --- a/trunk/arch/powerpc/kernel/time.c +++ b/trunk/arch/powerpc/kernel/time.c @@ -508,6 +508,8 @@ void timer_interrupt(struct pt_regs * regs) */ may_hard_irq_enable(); + trace_timer_interrupt_entry(regs); + __get_cpu_var(irq_stat).timer_irqs++; #if defined(CONFIG_PPC32) && defined(CONFIG_PMAC) @@ -518,8 +520,6 @@ void timer_interrupt(struct pt_regs * regs) old_regs = set_irq_regs(regs); irq_enter(); - trace_timer_interrupt_entry(regs); - if (test_irq_work_pending()) { clear_irq_work_pending(); irq_work_run(); @@ -544,10 +544,10 @@ void timer_interrupt(struct pt_regs * regs) } #endif - trace_timer_interrupt_exit(regs); - irq_exit(); set_irq_regs(old_regs); + + trace_timer_interrupt_exit(regs); } /* diff --git a/trunk/arch/powerpc/kernel/traps.c b/trunk/arch/powerpc/kernel/traps.c index 32518401af68..ae0843fa7a61 100644 --- a/trunk/arch/powerpc/kernel/traps.c +++ b/trunk/arch/powerpc/kernel/traps.c @@ -251,7 +251,6 @@ void _exception(int signr, struct pt_regs *regs, int code, unsigned long addr) if (arch_irqs_disabled() && !arch_irq_disabled_regs(regs)) local_irq_enable(); - current->thread.trap_nr = code; memset(&info, 0, sizeof(info)); info.si_signo = signr; info.si_code = code; diff --git a/trunk/arch/powerpc/kernel/uprobes.c b/trunk/arch/powerpc/kernel/uprobes.c deleted file mode 100644 index d2d46d1014f8..000000000000 --- a/trunk/arch/powerpc/kernel/uprobes.c +++ /dev/null @@ -1,184 +0,0 @@ -/* - * User-space Probes (UProbes) for powerpc - * - * 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. - * - * Copyright IBM Corporation, 2007-2012 - * - * Adapted from the x86 port by Ananth N Mavinakayanahalli - */ -#include -#include -#include -#include -#include -#include - -#include - -#define UPROBE_TRAP_NR UINT_MAX - -/** - * arch_uprobe_analyze_insn - * @mm: the probed address space. - * @arch_uprobe: the probepoint information. - * @addr: vaddr to probe. - * Return 0 on success or a -ve number on error. - */ -int arch_uprobe_analyze_insn(struct arch_uprobe *auprobe, - struct mm_struct *mm, unsigned long addr) -{ - if (addr & 0x03) - return -EINVAL; - - /* - * We currently don't support a uprobe on an already - * existing breakpoint instruction underneath - */ - if (is_trap(auprobe->ainsn)) - return -ENOTSUPP; - return 0; -} - -/* - * arch_uprobe_pre_xol - prepare to execute out of line. - * @auprobe: the probepoint information. - * @regs: reflects the saved user state of current task. - */ -int arch_uprobe_pre_xol(struct arch_uprobe *auprobe, struct pt_regs *regs) -{ - struct arch_uprobe_task *autask = ¤t->utask->autask; - - autask->saved_trap_nr = current->thread.trap_nr; - current->thread.trap_nr = UPROBE_TRAP_NR; - regs->nip = current->utask->xol_vaddr; - return 0; -} - -/** - * uprobe_get_swbp_addr - compute address of swbp given post-swbp regs - * @regs: Reflects the saved state of the task after it has hit a breakpoint - * instruction. - * Return the address of the breakpoint instruction. - */ -unsigned long uprobe_get_swbp_addr(struct pt_regs *regs) -{ - return instruction_pointer(regs); -} - -/* - * If xol insn itself traps and generates a signal (SIGILL/SIGSEGV/etc), - * then detect the case where a singlestepped instruction jumps back to its - * own address. It is assumed that anything like do_page_fault/do_trap/etc - * sets thread.trap_nr != UINT_MAX. - * - * arch_uprobe_pre_xol/arch_uprobe_post_xol save/restore thread.trap_nr, - * arch_uprobe_xol_was_trapped() simply checks that ->trap_nr is not equal to - * UPROBE_TRAP_NR == UINT_MAX set by arch_uprobe_pre_xol(). - */ -bool arch_uprobe_xol_was_trapped(struct task_struct *t) -{ - if (t->thread.trap_nr != UPROBE_TRAP_NR) - return true; - - return false; -} - -/* - * Called after single-stepping. To avoid the SMP problems that can - * occur when we temporarily put back the original opcode to - * single-step, we single-stepped a copy of the instruction. - * - * This function prepares to resume execution after the single-step. - */ -int arch_uprobe_post_xol(struct arch_uprobe *auprobe, struct pt_regs *regs) -{ - struct uprobe_task *utask = current->utask; - - WARN_ON_ONCE(current->thread.trap_nr != UPROBE_TRAP_NR); - - current->thread.trap_nr = utask->autask.saved_trap_nr; - - /* - * On powerpc, except for loads and stores, most instructions - * including ones that alter code flow (branches, calls, returns) - * are emulated in the kernel. We get here only if the emulation - * support doesn't exist and have to fix-up the next instruction - * to be executed. - */ - regs->nip = utask->vaddr + MAX_UINSN_BYTES; - return 0; -} - -/* callback routine for handling exceptions. */ -int arch_uprobe_exception_notify(struct notifier_block *self, - unsigned long val, void *data) -{ - struct die_args *args = data; - struct pt_regs *regs = args->regs; - - /* regs == NULL is a kernel bug */ - if (WARN_ON(!regs)) - return NOTIFY_DONE; - - /* We are only interested in userspace traps */ - if (!user_mode(regs)) - return NOTIFY_DONE; - - switch (val) { - case DIE_BPT: - if (uprobe_pre_sstep_notifier(regs)) - return NOTIFY_STOP; - break; - case DIE_SSTEP: - if (uprobe_post_sstep_notifier(regs)) - return NOTIFY_STOP; - default: - break; - } - return NOTIFY_DONE; -} - -/* - * This function gets called when XOL instruction either gets trapped or - * the thread has a fatal signal, so reset the instruction pointer to its - * probed address. - */ -void arch_uprobe_abort_xol(struct arch_uprobe *auprobe, struct pt_regs *regs) -{ - struct uprobe_task *utask = current->utask; - - current->thread.trap_nr = utask->autask.saved_trap_nr; - instruction_pointer_set(regs, utask->vaddr); -} - -/* - * See if the instruction can be emulated. - * Returns true if instruction was emulated, false otherwise. - */ -bool arch_uprobe_skip_sstep(struct arch_uprobe *auprobe, struct pt_regs *regs) -{ - int ret; - - /* - * emulate_step() returns 1 if the insn was successfully emulated. - * For all other cases, we need to single-step in hardware. - */ - ret = emulate_step(regs, auprobe->ainsn); - if (ret > 0) - return true; - - return false; -} diff --git a/trunk/arch/powerpc/kernel/vdso.c b/trunk/arch/powerpc/kernel/vdso.c index 1b2076f049ce..b67db22e102d 100644 --- a/trunk/arch/powerpc/kernel/vdso.c +++ b/trunk/arch/powerpc/kernel/vdso.c @@ -723,7 +723,9 @@ int __cpuinit vdso_getcpu_init(void) val = (cpu & 0xfff) | ((node & 0xffff) << 16); mtspr(SPRN_SPRG3, val); - get_paca()->sprg3 = val; +#ifdef CONFIG_KVM_BOOK3S_HANDLER + get_paca()->kvm_hstate.sprg3 = val; +#endif put_cpu(); diff --git a/trunk/arch/powerpc/kernel/vio.c b/trunk/arch/powerpc/kernel/vio.c index 201ba59738be..02b32216bbc3 100644 --- a/trunk/arch/powerpc/kernel/vio.c +++ b/trunk/arch/powerpc/kernel/vio.c @@ -33,6 +33,7 @@ #include #include #include +#include #include #include diff --git a/trunk/arch/powerpc/kvm/44x_tlb.c b/trunk/arch/powerpc/kvm/44x_tlb.c index 5dd3ab469976..33aa715dab28 100644 --- a/trunk/arch/powerpc/kvm/44x_tlb.c +++ b/trunk/arch/powerpc/kvm/44x_tlb.c @@ -319,6 +319,7 @@ void kvmppc_mmu_map(struct kvm_vcpu *vcpu, u64 gvaddr, gpa_t gpaddr, if (is_error_page(new_page)) { printk(KERN_ERR "Couldn't get guest page for gfn %llx!\n", (unsigned long long)gfn); + kvm_release_page_clean(new_page); return; } hpaddr = page_to_phys(new_page); diff --git a/trunk/arch/powerpc/kvm/book3s_32_mmu_host.c b/trunk/arch/powerpc/kvm/book3s_32_mmu_host.c index 00aa61268e0d..837f13e7b6bf 100644 --- a/trunk/arch/powerpc/kvm/book3s_32_mmu_host.c +++ b/trunk/arch/powerpc/kvm/book3s_32_mmu_host.c @@ -141,7 +141,7 @@ extern char etext[]; int kvmppc_mmu_map_page(struct kvm_vcpu *vcpu, struct kvmppc_pte *orig_pte) { pfn_t hpaddr; - u64 vpn; + u64 va; u64 vsid; struct kvmppc_sid_map *map; volatile u32 *pteg; @@ -173,7 +173,7 @@ int kvmppc_mmu_map_page(struct kvm_vcpu *vcpu, struct kvmppc_pte *orig_pte) BUG_ON(!map); vsid = map->host_vsid; - vpn = (vsid << (SID_SHIFT - VPN_SHIFT)) | ((eaddr & ~ESID_MASK) >> VPN_SHIFT) + va = (vsid << SID_SHIFT) | (eaddr & ~ESID_MASK); next_pteg: if (rr == 16) { @@ -244,11 +244,11 @@ int kvmppc_mmu_map_page(struct kvm_vcpu *vcpu, struct kvmppc_pte *orig_pte) dprintk_mmu("KVM: %c%c Map 0x%llx: [%lx] 0x%llx (0x%llx) -> %lx\n", orig_pte->may_write ? 'w' : '-', orig_pte->may_execute ? 'x' : '-', - orig_pte->eaddr, (ulong)pteg, vpn, + orig_pte->eaddr, (ulong)pteg, va, orig_pte->vpage, hpaddr); pte->slot = (ulong)&pteg[rr]; - pte->host_vpn = vpn; + pte->host_va = va; pte->pte = *orig_pte; pte->pfn = hpaddr >> PAGE_SHIFT; diff --git a/trunk/arch/powerpc/kvm/book3s_64_mmu_host.c b/trunk/arch/powerpc/kvm/book3s_64_mmu_host.c index 4d72f9ebc554..0688b6b39585 100644 --- a/trunk/arch/powerpc/kvm/book3s_64_mmu_host.c +++ b/trunk/arch/powerpc/kvm/book3s_64_mmu_host.c @@ -33,7 +33,7 @@ void kvmppc_mmu_invalidate_pte(struct kvm_vcpu *vcpu, struct hpte_cache *pte) { - ppc_md.hpte_invalidate(pte->slot, pte->host_vpn, + ppc_md.hpte_invalidate(pte->slot, pte->host_va, MMU_PAGE_4K, MMU_SEGSIZE_256M, false); } @@ -80,9 +80,8 @@ static struct kvmppc_sid_map *find_sid_vsid(struct kvm_vcpu *vcpu, u64 gvsid) int kvmppc_mmu_map_page(struct kvm_vcpu *vcpu, struct kvmppc_pte *orig_pte) { - unsigned long vpn; pfn_t hpaddr; - ulong hash, hpteg; + ulong hash, hpteg, va; u64 vsid; int ret; int rflags = 0x192; @@ -118,7 +117,7 @@ int kvmppc_mmu_map_page(struct kvm_vcpu *vcpu, struct kvmppc_pte *orig_pte) } vsid = map->host_vsid; - vpn = hpt_vpn(orig_pte->eaddr, vsid, MMU_SEGSIZE_256M); + va = hpt_va(orig_pte->eaddr, vsid, MMU_SEGSIZE_256M); if (!orig_pte->may_write) rflags |= HPTE_R_PP; @@ -130,7 +129,7 @@ int kvmppc_mmu_map_page(struct kvm_vcpu *vcpu, struct kvmppc_pte *orig_pte) else kvmppc_mmu_flush_icache(hpaddr >> PAGE_SHIFT); - hash = hpt_hash(vpn, PTE_SIZE, MMU_SEGSIZE_256M); + hash = hpt_hash(va, PTE_SIZE, MMU_SEGSIZE_256M); map_again: hpteg = ((hash & htab_hash_mask) * HPTES_PER_GROUP); @@ -142,8 +141,7 @@ int kvmppc_mmu_map_page(struct kvm_vcpu *vcpu, struct kvmppc_pte *orig_pte) goto out; } - ret = ppc_md.hpte_insert(hpteg, vpn, hpaddr, rflags, vflags, - MMU_PAGE_4K, MMU_SEGSIZE_256M); + ret = ppc_md.hpte_insert(hpteg, va, hpaddr, rflags, vflags, MMU_PAGE_4K, MMU_SEGSIZE_256M); if (ret < 0) { /* If we couldn't map a primary PTE, try a secondary */ @@ -154,8 +152,7 @@ int kvmppc_mmu_map_page(struct kvm_vcpu *vcpu, struct kvmppc_pte *orig_pte) } else { struct hpte_cache *pte = kvmppc_mmu_hpte_cache_next(vcpu); - trace_kvm_book3s_64_mmu_map(rflags, hpteg, - vpn, hpaddr, orig_pte); + trace_kvm_book3s_64_mmu_map(rflags, hpteg, va, hpaddr, orig_pte); /* The ppc_md code may give us a secondary entry even though we asked for a primary. Fix up. */ @@ -165,7 +162,7 @@ int kvmppc_mmu_map_page(struct kvm_vcpu *vcpu, struct kvmppc_pte *orig_pte) } pte->slot = hpteg + (ret & 7); - pte->host_vpn = vpn; + pte->host_va = va; pte->pte = *orig_pte; pte->pfn = hpaddr >> PAGE_SHIFT; diff --git a/trunk/arch/powerpc/kvm/book3s_64_mmu_hv.c b/trunk/arch/powerpc/kvm/book3s_64_mmu_hv.c index d95d11322a15..d03eb6f7b058 100644 --- a/trunk/arch/powerpc/kvm/book3s_64_mmu_hv.c +++ b/trunk/arch/powerpc/kvm/book3s_64_mmu_hv.c @@ -705,7 +705,7 @@ int kvmppc_book3s_hv_page_fault(struct kvm_run *run, struct kvm_vcpu *vcpu, goto out_unlock; hpte[0] = (hpte[0] & ~HPTE_V_ABSENT) | HPTE_V_VALID; - rmap = &memslot->arch.rmap[gfn - memslot->base_gfn]; + rmap = &memslot->rmap[gfn - memslot->base_gfn]; lock_rmap(rmap); /* Check if we might have been invalidated; let the guest retry if so */ @@ -756,12 +756,9 @@ int kvmppc_book3s_hv_page_fault(struct kvm_run *run, struct kvm_vcpu *vcpu, goto out_put; } -static int kvm_handle_hva_range(struct kvm *kvm, - unsigned long start, - unsigned long end, - int (*handler)(struct kvm *kvm, - unsigned long *rmapp, - unsigned long gfn)) +static int kvm_handle_hva(struct kvm *kvm, unsigned long hva, + int (*handler)(struct kvm *kvm, unsigned long *rmapp, + unsigned long gfn)) { int ret; int retval = 0; @@ -770,25 +767,15 @@ static int kvm_handle_hva_range(struct kvm *kvm, slots = kvm_memslots(kvm); kvm_for_each_memslot(memslot, slots) { - unsigned long hva_start, hva_end; - gfn_t gfn, gfn_end; + unsigned long start = memslot->userspace_addr; + unsigned long end; - hva_start = max(start, memslot->userspace_addr); - hva_end = min(end, memslot->userspace_addr + - (memslot->npages << PAGE_SHIFT)); - if (hva_start >= hva_end) - continue; - /* - * {gfn(page) | page intersects with [hva_start, hva_end)} = - * {gfn, gfn+1, ..., gfn_end-1}. - */ - gfn = hva_to_gfn_memslot(hva_start, memslot); - gfn_end = hva_to_gfn_memslot(hva_end + PAGE_SIZE - 1, memslot); - - for (; gfn < gfn_end; ++gfn) { - gfn_t gfn_offset = gfn - memslot->base_gfn; + end = start + (memslot->npages << PAGE_SHIFT); + if (hva >= start && hva < end) { + gfn_t gfn_offset = (hva - start) >> PAGE_SHIFT; - ret = handler(kvm, &memslot->arch.rmap[gfn_offset], gfn); + ret = handler(kvm, &memslot->rmap[gfn_offset], + memslot->base_gfn + gfn_offset); retval |= ret; } } @@ -796,13 +783,6 @@ static int kvm_handle_hva_range(struct kvm *kvm, return retval; } -static int kvm_handle_hva(struct kvm *kvm, unsigned long hva, - int (*handler)(struct kvm *kvm, unsigned long *rmapp, - unsigned long gfn)) -{ - return kvm_handle_hva_range(kvm, hva, hva + 1, handler); -} - static int kvm_unmap_rmapp(struct kvm *kvm, unsigned long *rmapp, unsigned long gfn) { @@ -870,13 +850,6 @@ int kvm_unmap_hva(struct kvm *kvm, unsigned long hva) return 0; } -int kvm_unmap_hva_range(struct kvm *kvm, unsigned long start, unsigned long end) -{ - if (kvm->arch.using_mmu_notifiers) - kvm_handle_hva_range(kvm, start, end, kvm_unmap_rmapp); - return 0; -} - static int kvm_age_rmapp(struct kvm *kvm, unsigned long *rmapp, unsigned long gfn) { @@ -1036,7 +1009,7 @@ long kvmppc_hv_get_dirty_log(struct kvm *kvm, struct kvm_memory_slot *memslot) unsigned long *rmapp, *map; preempt_disable(); - rmapp = memslot->arch.rmap; + rmapp = memslot->rmap; map = memslot->dirty_bitmap; for (i = 0; i < memslot->npages; ++i) { if (kvm_test_clear_dirty(kvm, rmapp)) diff --git a/trunk/arch/powerpc/kvm/book3s_hv_rm_mmu.c b/trunk/arch/powerpc/kvm/book3s_hv_rm_mmu.c index fb0e821622d4..5c70d19494f9 100644 --- a/trunk/arch/powerpc/kvm/book3s_hv_rm_mmu.c +++ b/trunk/arch/powerpc/kvm/book3s_hv_rm_mmu.c @@ -84,7 +84,7 @@ static void remove_revmap_chain(struct kvm *kvm, long pte_index, if (!memslot || (memslot->flags & KVM_MEMSLOT_INVALID)) return; - rmap = real_vmalloc_addr(&memslot->arch.rmap[gfn - memslot->base_gfn]); + rmap = real_vmalloc_addr(&memslot->rmap[gfn - memslot->base_gfn]); lock_rmap(rmap); head = *rmap & KVMPPC_RMAP_INDEX; @@ -180,7 +180,7 @@ long kvmppc_h_enter(struct kvm_vcpu *vcpu, unsigned long flags, if (!slot_is_aligned(memslot, psize)) return H_PARAMETER; slot_fn = gfn - memslot->base_gfn; - rmap = &memslot->arch.rmap[slot_fn]; + rmap = &memslot->rmap[slot_fn]; if (!kvm->arch.using_mmu_notifiers) { physp = kvm->arch.slot_phys[memslot->id]; @@ -197,7 +197,7 @@ long kvmppc_h_enter(struct kvm_vcpu *vcpu, unsigned long flags, pa &= PAGE_MASK; } else { /* Translate to host virtual address */ - hva = __gfn_to_hva_memslot(memslot, gfn); + hva = gfn_to_hva_memslot(memslot, gfn); /* Look up the Linux PTE for the backing page */ pte_size = psize; diff --git a/trunk/arch/powerpc/kvm/book3s_hv_rmhandlers.S b/trunk/arch/powerpc/kvm/book3s_hv_rmhandlers.S index 74a24bbb9637..44b72feaff7d 100644 --- a/trunk/arch/powerpc/kvm/book3s_hv_rmhandlers.S +++ b/trunk/arch/powerpc/kvm/book3s_hv_rmhandlers.S @@ -1065,7 +1065,7 @@ END_FTR_SECTION_IFSET(CPU_FTR_ARCH_206) mtspr SPRN_DABRX,r6 /* Restore SPRG3 */ - ld r3,PACA_SPRG3(r13) + ld r3,HSTATE_SPRG3(r13) mtspr SPRN_SPRG3,r3 /* diff --git a/trunk/arch/powerpc/kvm/book3s_pr.c b/trunk/arch/powerpc/kvm/book3s_pr.c index 05c28f59f77f..a1baec340f7e 100644 --- a/trunk/arch/powerpc/kvm/book3s_pr.c +++ b/trunk/arch/powerpc/kvm/book3s_pr.c @@ -242,8 +242,10 @@ static void kvmppc_patch_dcbz(struct kvm_vcpu *vcpu, struct kvmppc_pte *pte) int i; hpage = gfn_to_page(vcpu->kvm, pte->raddr >> PAGE_SHIFT); - if (is_error_page(hpage)) + if (is_error_page(hpage)) { + kvm_release_page_clean(hpage); return; + } hpage_offset = pte->raddr & ~PAGE_MASK; hpage_offset &= ~0xFFFULL; diff --git a/trunk/arch/powerpc/kvm/e500_tlb.c b/trunk/arch/powerpc/kvm/e500_tlb.c index ff38b664195d..a2b66717813d 100644 --- a/trunk/arch/powerpc/kvm/e500_tlb.c +++ b/trunk/arch/powerpc/kvm/e500_tlb.c @@ -520,10 +520,11 @@ static inline void kvmppc_e500_shadow_map(struct kvmppc_vcpu_e500 *vcpu_e500, if (likely(!pfnmap)) { unsigned long tsize_pages = 1 << (tsize + 10 - PAGE_SHIFT); - pfn = gfn_to_pfn_memslot(slot, gfn); + pfn = gfn_to_pfn_memslot(vcpu_e500->vcpu.kvm, slot, gfn); if (is_error_pfn(pfn)) { printk(KERN_ERR "Couldn't get real page for gfn %lx!\n", (long)gfn); + kvm_release_pfn_clean(pfn); return; } diff --git a/trunk/arch/powerpc/kvm/powerpc.c b/trunk/arch/powerpc/kvm/powerpc.c index 4d213b8b0fb5..87f4dc886076 100644 --- a/trunk/arch/powerpc/kvm/powerpc.c +++ b/trunk/arch/powerpc/kvm/powerpc.c @@ -302,18 +302,10 @@ long kvm_arch_dev_ioctl(struct file *filp, void kvm_arch_free_memslot(struct kvm_memory_slot *free, struct kvm_memory_slot *dont) { - if (!dont || free->arch.rmap != dont->arch.rmap) { - vfree(free->arch.rmap); - free->arch.rmap = NULL; - } } int kvm_arch_create_memslot(struct kvm_memory_slot *slot, unsigned long npages) { - slot->arch.rmap = vzalloc(npages * sizeof(*slot->arch.rmap)); - if (!slot->arch.rmap) - return -ENOMEM; - return 0; } @@ -334,12 +326,8 @@ void kvm_arch_commit_memory_region(struct kvm *kvm, kvmppc_core_commit_memory_region(kvm, mem); } -void kvm_arch_flush_shadow_all(struct kvm *kvm) -{ -} -void kvm_arch_flush_shadow_memslot(struct kvm *kvm, - struct kvm_memory_slot *slot) +void kvm_arch_flush_shadow(struct kvm *kvm) { } diff --git a/trunk/arch/powerpc/kvm/trace.h b/trunk/arch/powerpc/kvm/trace.h index ddb6a2149d44..877186b7b1c3 100644 --- a/trunk/arch/powerpc/kvm/trace.h +++ b/trunk/arch/powerpc/kvm/trace.h @@ -189,7 +189,7 @@ TRACE_EVENT(kvm_book3s_mmu_map, TP_ARGS(pte), TP_STRUCT__entry( - __field( u64, host_vpn ) + __field( u64, host_va ) __field( u64, pfn ) __field( ulong, eaddr ) __field( u64, vpage ) @@ -198,7 +198,7 @@ TRACE_EVENT(kvm_book3s_mmu_map, ), TP_fast_assign( - __entry->host_vpn = pte->host_vpn; + __entry->host_va = pte->host_va; __entry->pfn = pte->pfn; __entry->eaddr = pte->pte.eaddr; __entry->vpage = pte->pte.vpage; @@ -208,8 +208,8 @@ TRACE_EVENT(kvm_book3s_mmu_map, (pte->pte.may_execute ? 0x1 : 0); ), - TP_printk("Map: hvpn=%llx pfn=%llx ea=%lx vp=%llx ra=%lx [%x]", - __entry->host_vpn, __entry->pfn, __entry->eaddr, + TP_printk("Map: hva=%llx pfn=%llx ea=%lx vp=%llx ra=%lx [%x]", + __entry->host_va, __entry->pfn, __entry->eaddr, __entry->vpage, __entry->raddr, __entry->flags) ); @@ -218,7 +218,7 @@ TRACE_EVENT(kvm_book3s_mmu_invalidate, TP_ARGS(pte), TP_STRUCT__entry( - __field( u64, host_vpn ) + __field( u64, host_va ) __field( u64, pfn ) __field( ulong, eaddr ) __field( u64, vpage ) @@ -227,7 +227,7 @@ TRACE_EVENT(kvm_book3s_mmu_invalidate, ), TP_fast_assign( - __entry->host_vpn = pte->host_vpn; + __entry->host_va = pte->host_va; __entry->pfn = pte->pfn; __entry->eaddr = pte->pte.eaddr; __entry->vpage = pte->pte.vpage; @@ -238,7 +238,7 @@ TRACE_EVENT(kvm_book3s_mmu_invalidate, ), TP_printk("Flush: hva=%llx pfn=%llx ea=%lx vp=%llx ra=%lx [%x]", - __entry->host_vpn, __entry->pfn, __entry->eaddr, + __entry->host_va, __entry->pfn, __entry->eaddr, __entry->vpage, __entry->raddr, __entry->flags) ); diff --git a/trunk/arch/powerpc/lib/memcpy_power7.S b/trunk/arch/powerpc/lib/memcpy_power7.S index 0663630baf3b..7ba6c96de778 100644 --- a/trunk/arch/powerpc/lib/memcpy_power7.S +++ b/trunk/arch/powerpc/lib/memcpy_power7.S @@ -239,8 +239,8 @@ _GLOBAL(memcpy_power7) ori r9,r9,1 /* stream=1 */ srdi r7,r5,7 /* length in cachelines, capped at 0x3FF */ - cmpldi r7,0x3FF - ble 1f + cmpldi cr1,r7,0x3FF + ble cr1,1f li r7,0x3FF 1: lis r0,0x0E00 /* depth=7 */ sldi r7,r7,7 diff --git a/trunk/arch/powerpc/lib/sstep.c b/trunk/arch/powerpc/lib/sstep.c index e15c521846ca..9a52349874ee 100644 --- a/trunk/arch/powerpc/lib/sstep.c +++ b/trunk/arch/powerpc/lib/sstep.c @@ -566,7 +566,7 @@ int __kprobes emulate_step(struct pt_regs *regs, unsigned int instr) unsigned long int ea; unsigned int cr, mb, me, sh; int err; - unsigned long old_ra, val3; + unsigned long old_ra; long ival; opcode = instr >> 26; @@ -1486,41 +1486,9 @@ int __kprobes emulate_step(struct pt_regs *regs, unsigned int instr) goto ldst_done; case 36: /* stw */ - val = regs->gpr[rd]; - err = write_mem(val, dform_ea(instr, regs), 4, regs); - goto ldst_done; - case 37: /* stwu */ val = regs->gpr[rd]; - val3 = dform_ea(instr, regs); - /* - * For PPC32 we always use stwu to change stack point with r1. So - * this emulated store may corrupt the exception frame, now we - * have to provide the exception frame trampoline, which is pushed - * below the kprobed function stack. So we only update gpr[1] but - * don't emulate the real store operation. We will do real store - * operation safely in exception return code by checking this flag. - */ - if ((ra == 1) && !(regs->msr & MSR_PR) \ - && (val3 >= (regs->gpr[1] - STACK_INT_FRAME_SIZE))) { - /* - * Check if we will touch kernel sack overflow - */ - if (val3 - STACK_INT_FRAME_SIZE <= current->thread.ksp_limit) { - printk(KERN_CRIT "Can't kprobe this since Kernel stack overflow.\n"); - err = -EINVAL; - break; - } - - /* - * Check if we already set since that means we'll - * lose the previous value. - */ - WARN_ON(test_thread_flag(TIF_EMULATE_STACK_STORE)); - set_thread_flag(TIF_EMULATE_STACK_STORE); - err = 0; - } else - err = write_mem(val, val3, 4, regs); + err = write_mem(val, dform_ea(instr, regs), 4, regs); goto ldst_done; case 38: /* stb */ diff --git a/trunk/arch/powerpc/mm/fault.c b/trunk/arch/powerpc/mm/fault.c index 5495ebe983a2..e5f028b5794e 100644 --- a/trunk/arch/powerpc/mm/fault.c +++ b/trunk/arch/powerpc/mm/fault.c @@ -133,7 +133,6 @@ static int do_sigbus(struct pt_regs *regs, unsigned long address) up_read(¤t->mm->mmap_sem); if (user_mode(regs)) { - current->thread.trap_nr = BUS_ADRERR; info.si_signo = SIGBUS; info.si_errno = 0; info.si_code = BUS_ADRERR; diff --git a/trunk/arch/powerpc/mm/hash_low_64.S b/trunk/arch/powerpc/mm/hash_low_64.S index 56585086413a..602aeb06d298 100644 --- a/trunk/arch/powerpc/mm/hash_low_64.S +++ b/trunk/arch/powerpc/mm/hash_low_64.S @@ -63,7 +63,7 @@ _GLOBAL(__hash_page_4K) /* Save non-volatile registers. * r31 will hold "old PTE" * r30 is "new PTE" - * r29 is vpn + * r29 is "va" * r28 is a hash value * r27 is hashtab mask (maybe dynamic patched instead ?) */ @@ -111,10 +111,10 @@ BEGIN_FTR_SECTION cmpdi r9,0 /* check segment size */ bne 3f END_MMU_FTR_SECTION_IFSET(MMU_FTR_1T_SEGMENT) - /* Calc vpn and put it in r29 */ - sldi r29,r5,SID_SHIFT - VPN_SHIFT - rldicl r28,r3,64 - VPN_SHIFT,64 - (SID_SHIFT - VPN_SHIFT) - or r29,r28,r29 + /* Calc va and put it in r29 */ + rldicr r29,r5,28,63-28 + rldicl r3,r3,0,36 + or r29,r3,r29 /* Calculate hash value for primary slot and store it in r28 */ rldicl r5,r5,0,25 /* vsid & 0x0000007fffffffff */ @@ -122,19 +122,14 @@ END_MMU_FTR_SECTION_IFSET(MMU_FTR_1T_SEGMENT) xor r28,r5,r0 b 4f -3: /* Calc vpn and put it in r29 */ - sldi r29,r5,SID_SHIFT_1T - VPN_SHIFT - rldicl r28,r3,64 - VPN_SHIFT,64 - (SID_SHIFT_1T - VPN_SHIFT) - or r29,r28,r29 - - /* - * calculate hash value for primary slot and - * store it in r28 for 1T segment - */ +3: /* Calc VA and hash in r29 and r28 for 1T segment */ + sldi r29,r5,40 /* vsid << 40 */ + clrldi r3,r3,24 /* ea & 0xffffffffff */ rldic r28,r5,25,25 /* (vsid << 25) & 0x7fffffffff */ clrldi r5,r5,40 /* vsid & 0xffffff */ rldicl r0,r3,64-12,36 /* (ea >> 12) & 0xfffffff */ xor r28,r28,r5 + or r29,r3,r29 /* VA */ xor r28,r28,r0 /* hash */ /* Convert linux PTE bits into HW equivalents */ @@ -190,7 +185,7 @@ htab_insert_pte: /* Call ppc_md.hpte_insert */ ld r6,STK_PARAM(R4)(r1) /* Retrieve new pp bits */ - mr r4,r29 /* Retrieve vpn */ + mr r4,r29 /* Retrieve va */ li r7,0 /* !bolted, !secondary */ li r8,MMU_PAGE_4K /* page size */ ld r9,STK_PARAM(R9)(r1) /* segment size */ @@ -213,7 +208,7 @@ _GLOBAL(htab_call_hpte_insert1) /* Call ppc_md.hpte_insert */ ld r6,STK_PARAM(R4)(r1) /* Retrieve new pp bits */ - mr r4,r29 /* Retrieve vpn */ + mr r4,r29 /* Retrieve va */ li r7,HPTE_V_SECONDARY /* !bolted, secondary */ li r8,MMU_PAGE_4K /* page size */ ld r9,STK_PARAM(R9)(r1) /* segment size */ @@ -283,7 +278,7 @@ htab_modify_pte: add r3,r0,r3 /* add slot idx */ /* Call ppc_md.hpte_updatepp */ - mr r5,r29 /* vpn */ + mr r5,r29 /* va */ li r6,MMU_PAGE_4K /* page size */ ld r7,STK_PARAM(R9)(r1) /* segment size */ ld r8,STK_PARAM(R8)(r1) /* get "local" param */ @@ -344,7 +339,7 @@ _GLOBAL(__hash_page_4K) /* Save non-volatile registers. * r31 will hold "old PTE" * r30 is "new PTE" - * r29 is vpn + * r29 is "va" * r28 is a hash value * r27 is hashtab mask (maybe dynamic patched instead ?) * r26 is the hidx mask @@ -399,14 +394,10 @@ BEGIN_FTR_SECTION cmpdi r9,0 /* check segment size */ bne 3f END_MMU_FTR_SECTION_IFSET(MMU_FTR_1T_SEGMENT) - /* Calc vpn and put it in r29 */ - sldi r29,r5,SID_SHIFT - VPN_SHIFT - /* - * clrldi r3,r3,64 - SID_SHIFT --> ea & 0xfffffff - * srdi r28,r3,VPN_SHIFT - */ - rldicl r28,r3,64 - VPN_SHIFT,64 - (SID_SHIFT - VPN_SHIFT) - or r29,r28,r29 + /* Calc va and put it in r29 */ + rldicr r29,r5,28,63-28 /* r29 = (vsid << 28) */ + rldicl r3,r3,0,36 /* r3 = (ea & 0x0fffffff) */ + or r29,r3,r29 /* r29 = va */ /* Calculate hash value for primary slot and store it in r28 */ rldicl r5,r5,0,25 /* vsid & 0x0000007fffffffff */ @@ -414,23 +405,14 @@ END_MMU_FTR_SECTION_IFSET(MMU_FTR_1T_SEGMENT) xor r28,r5,r0 b 4f -3: /* Calc vpn and put it in r29 */ - sldi r29,r5,SID_SHIFT_1T - VPN_SHIFT - /* - * clrldi r3,r3,64 - SID_SHIFT_1T --> ea & 0xffffffffff - * srdi r28,r3,VPN_SHIFT - */ - rldicl r28,r3,64 - VPN_SHIFT,64 - (SID_SHIFT_1T - VPN_SHIFT) - or r29,r28,r29 - - /* - * Calculate hash value for primary slot and - * store it in r28 for 1T segment - */ +3: /* Calc VA and hash in r29 and r28 for 1T segment */ + sldi r29,r5,40 /* vsid << 40 */ + clrldi r3,r3,24 /* ea & 0xffffffffff */ rldic r28,r5,25,25 /* (vsid << 25) & 0x7fffffffff */ clrldi r5,r5,40 /* vsid & 0xffffff */ rldicl r0,r3,64-12,36 /* (ea >> 12) & 0xfffffff */ xor r28,r28,r5 + or r29,r3,r29 /* VA */ xor r28,r28,r0 /* hash */ /* Convert linux PTE bits into HW equivalents */ @@ -506,7 +488,7 @@ htab_special_pfn: /* Call ppc_md.hpte_insert */ ld r6,STK_PARAM(R4)(r1) /* Retrieve new pp bits */ - mr r4,r29 /* Retrieve vpn */ + mr r4,r29 /* Retrieve va */ li r7,0 /* !bolted, !secondary */ li r8,MMU_PAGE_4K /* page size */ ld r9,STK_PARAM(R9)(r1) /* segment size */ @@ -533,7 +515,7 @@ _GLOBAL(htab_call_hpte_insert1) /* Call ppc_md.hpte_insert */ ld r6,STK_PARAM(R4)(r1) /* Retrieve new pp bits */ - mr r4,r29 /* Retrieve vpn */ + mr r4,r29 /* Retrieve va */ li r7,HPTE_V_SECONDARY /* !bolted, secondary */ li r8,MMU_PAGE_4K /* page size */ ld r9,STK_PARAM(R9)(r1) /* segment size */ @@ -565,7 +547,7 @@ _GLOBAL(htab_call_hpte_remove) * useless now that the segment has been switched to 4k pages. */ htab_inval_old_hpte: - mr r3,r29 /* vpn */ + mr r3,r29 /* virtual addr */ mr r4,r31 /* PTE.pte */ li r5,0 /* PTE.hidx */ li r6,MMU_PAGE_64K /* psize */ @@ -638,7 +620,7 @@ htab_modify_pte: add r3,r0,r3 /* add slot idx */ /* Call ppc_md.hpte_updatepp */ - mr r5,r29 /* vpn */ + mr r5,r29 /* va */ li r6,MMU_PAGE_4K /* page size */ ld r7,STK_PARAM(R9)(r1) /* segment size */ ld r8,STK_PARAM(R8)(r1) /* get "local" param */ @@ -694,7 +676,7 @@ _GLOBAL(__hash_page_64K) /* Save non-volatile registers. * r31 will hold "old PTE" * r30 is "new PTE" - * r29 is vpn + * r29 is "va" * r28 is a hash value * r27 is hashtab mask (maybe dynamic patched instead ?) */ @@ -747,10 +729,10 @@ BEGIN_FTR_SECTION cmpdi r9,0 /* check segment size */ bne 3f END_MMU_FTR_SECTION_IFSET(MMU_FTR_1T_SEGMENT) - /* Calc vpn and put it in r29 */ - sldi r29,r5,SID_SHIFT - VPN_SHIFT - rldicl r28,r3,64 - VPN_SHIFT,64 - (SID_SHIFT - VPN_SHIFT) - or r29,r28,r29 + /* Calc va and put it in r29 */ + rldicr r29,r5,28,63-28 + rldicl r3,r3,0,36 + or r29,r3,r29 /* Calculate hash value for primary slot and store it in r28 */ rldicl r5,r5,0,25 /* vsid & 0x0000007fffffffff */ @@ -758,19 +740,14 @@ END_MMU_FTR_SECTION_IFSET(MMU_FTR_1T_SEGMENT) xor r28,r5,r0 b 4f -3: /* Calc vpn and put it in r29 */ - sldi r29,r5,SID_SHIFT_1T - VPN_SHIFT - rldicl r28,r3,64 - VPN_SHIFT,64 - (SID_SHIFT_1T - VPN_SHIFT) - or r29,r28,r29 - - /* - * calculate hash value for primary slot and - * store it in r28 for 1T segment - */ +3: /* Calc VA and hash in r29 and r28 for 1T segment */ + sldi r29,r5,40 /* vsid << 40 */ + clrldi r3,r3,24 /* ea & 0xffffffffff */ rldic r28,r5,25,25 /* (vsid << 25) & 0x7fffffffff */ clrldi r5,r5,40 /* vsid & 0xffffff */ rldicl r0,r3,64-16,40 /* (ea >> 16) & 0xffffff */ xor r28,r28,r5 + or r29,r3,r29 /* VA */ xor r28,r28,r0 /* hash */ /* Convert linux PTE bits into HW equivalents */ @@ -829,7 +806,7 @@ ht64_insert_pte: /* Call ppc_md.hpte_insert */ ld r6,STK_PARAM(R4)(r1) /* Retrieve new pp bits */ - mr r4,r29 /* Retrieve vpn */ + mr r4,r29 /* Retrieve va */ li r7,0 /* !bolted, !secondary */ li r8,MMU_PAGE_64K ld r9,STK_PARAM(R9)(r1) /* segment size */ @@ -852,7 +829,7 @@ _GLOBAL(ht64_call_hpte_insert1) /* Call ppc_md.hpte_insert */ ld r6,STK_PARAM(R4)(r1) /* Retrieve new pp bits */ - mr r4,r29 /* Retrieve vpn */ + mr r4,r29 /* Retrieve va */ li r7,HPTE_V_SECONDARY /* !bolted, secondary */ li r8,MMU_PAGE_64K ld r9,STK_PARAM(R9)(r1) /* segment size */ @@ -922,7 +899,7 @@ ht64_modify_pte: add r3,r0,r3 /* add slot idx */ /* Call ppc_md.hpte_updatepp */ - mr r5,r29 /* vpn */ + mr r5,r29 /* va */ li r6,MMU_PAGE_64K ld r7,STK_PARAM(R9)(r1) /* segment size */ ld r8,STK_PARAM(R8)(r1) /* get "local" param */ diff --git a/trunk/arch/powerpc/mm/hash_native_64.c b/trunk/arch/powerpc/mm/hash_native_64.c index ffc1e00f7a22..90039bc64119 100644 --- a/trunk/arch/powerpc/mm/hash_native_64.c +++ b/trunk/arch/powerpc/mm/hash_native_64.c @@ -14,10 +14,10 @@ #include #include -#include #include #include +#include #include #include #include @@ -39,35 +39,22 @@ DEFINE_RAW_SPINLOCK(native_tlbie_lock); -static inline void __tlbie(unsigned long vpn, int psize, int ssize) +static inline void __tlbie(unsigned long va, int psize, int ssize) { - unsigned long va; unsigned int penc; - /* - * We need 14 to 65 bits of va for a tlibe of 4K page - * With vpn we ignore the lower VPN_SHIFT bits already. - * And top two bits are already ignored because we can - * only accomadate 76 bits in a 64 bit vpn with a VPN_SHIFT - * of 12. - */ - va = vpn << VPN_SHIFT; - /* - * clear top 16 bits of 64bit va, non SLS segment - * Older versions of the architecture (2.02 and earler) require the - * masking of the top 16 bits. - */ + /* clear top 16 bits, non SLS segment */ va &= ~(0xffffULL << 48); switch (psize) { case MMU_PAGE_4K: + va &= ~0xffful; va |= ssize << 8; asm volatile(ASM_FTR_IFCLR("tlbie %0,0", PPC_TLBIE(%1,%0), %2) : : "r" (va), "r"(0), "i" (CPU_FTR_ARCH_206) : "memory"); break; default: - /* We need 14 to 14 + i bits of va */ penc = mmu_psize_defs[psize].penc; va &= ~((1ul << mmu_psize_defs[psize].shift) - 1); va |= penc << 12; @@ -80,28 +67,21 @@ static inline void __tlbie(unsigned long vpn, int psize, int ssize) } } -static inline void __tlbiel(unsigned long vpn, int psize, int ssize) +static inline void __tlbiel(unsigned long va, int psize, int ssize) { - unsigned long va; unsigned int penc; - /* VPN_SHIFT can be atmost 12 */ - va = vpn << VPN_SHIFT; - /* - * clear top 16 bits of 64 bit va, non SLS segment - * Older versions of the architecture (2.02 and earler) require the - * masking of the top 16 bits. - */ + /* clear top 16 bits, non SLS segment */ va &= ~(0xffffULL << 48); switch (psize) { case MMU_PAGE_4K: + va &= ~0xffful; va |= ssize << 8; asm volatile(".long 0x7c000224 | (%0 << 11) | (0 << 21)" : : "r"(va) : "memory"); break; default: - /* We need 14 to 14 + i bits of va */ penc = mmu_psize_defs[psize].penc; va &= ~((1ul << mmu_psize_defs[psize].shift) - 1); va |= penc << 12; @@ -114,7 +94,7 @@ static inline void __tlbiel(unsigned long vpn, int psize, int ssize) } -static inline void tlbie(unsigned long vpn, int psize, int ssize, int local) +static inline void tlbie(unsigned long va, int psize, int ssize, int local) { unsigned int use_local = local && mmu_has_feature(MMU_FTR_TLBIEL); int lock_tlbie = !mmu_has_feature(MMU_FTR_LOCKLESS_TLBIE); @@ -125,10 +105,10 @@ static inline void tlbie(unsigned long vpn, int psize, int ssize, int local) raw_spin_lock(&native_tlbie_lock); asm volatile("ptesync": : :"memory"); if (use_local) { - __tlbiel(vpn, psize, ssize); + __tlbiel(va, psize, ssize); asm volatile("ptesync": : :"memory"); } else { - __tlbie(vpn, psize, ssize); + __tlbie(va, psize, ssize); asm volatile("eieio; tlbsync; ptesync": : :"memory"); } if (lock_tlbie && !use_local) @@ -154,7 +134,7 @@ static inline void native_unlock_hpte(struct hash_pte *hptep) clear_bit_unlock(HPTE_LOCK_BIT, word); } -static long native_hpte_insert(unsigned long hpte_group, unsigned long vpn, +static long native_hpte_insert(unsigned long hpte_group, unsigned long va, unsigned long pa, unsigned long rflags, unsigned long vflags, int psize, int ssize) { @@ -163,9 +143,9 @@ static long native_hpte_insert(unsigned long hpte_group, unsigned long vpn, int i; if (!(vflags & HPTE_V_BOLTED)) { - DBG_LOW(" insert(group=%lx, vpn=%016lx, pa=%016lx," + DBG_LOW(" insert(group=%lx, va=%016lx, pa=%016lx," " rflags=%lx, vflags=%lx, psize=%d)\n", - hpte_group, vpn, pa, rflags, vflags, psize); + hpte_group, va, pa, rflags, vflags, psize); } for (i = 0; i < HPTES_PER_GROUP; i++) { @@ -183,7 +163,7 @@ static long native_hpte_insert(unsigned long hpte_group, unsigned long vpn, if (i == HPTES_PER_GROUP) return -1; - hpte_v = hpte_encode_v(vpn, psize, ssize) | vflags | HPTE_V_VALID; + hpte_v = hpte_encode_v(va, psize, ssize) | vflags | HPTE_V_VALID; hpte_r = hpte_encode_r(pa, psize) | rflags; if (!(vflags & HPTE_V_BOLTED)) { @@ -245,17 +225,17 @@ static long native_hpte_remove(unsigned long hpte_group) } static long native_hpte_updatepp(unsigned long slot, unsigned long newpp, - unsigned long vpn, int psize, int ssize, + unsigned long va, int psize, int ssize, int local) { struct hash_pte *hptep = htab_address + slot; unsigned long hpte_v, want_v; int ret = 0; - want_v = hpte_encode_v(vpn, psize, ssize); + want_v = hpte_encode_v(va, psize, ssize); - DBG_LOW(" update(vpn=%016lx, avpnv=%016lx, group=%lx, newpp=%lx)", - vpn, want_v & HPTE_V_AVPN, slot, newpp); + DBG_LOW(" update(va=%016lx, avpnv=%016lx, hash=%016lx, newpp=%x)", + va, want_v & HPTE_V_AVPN, slot, newpp); native_lock_hpte(hptep); @@ -274,12 +254,12 @@ static long native_hpte_updatepp(unsigned long slot, unsigned long newpp, native_unlock_hpte(hptep); /* Ensure it is out of the tlb too. */ - tlbie(vpn, psize, ssize, local); + tlbie(va, psize, ssize, local); return ret; } -static long native_hpte_find(unsigned long vpn, int psize, int ssize) +static long native_hpte_find(unsigned long va, int psize, int ssize) { struct hash_pte *hptep; unsigned long hash; @@ -287,8 +267,8 @@ static long native_hpte_find(unsigned long vpn, int psize, int ssize) long slot; unsigned long want_v, hpte_v; - hash = hpt_hash(vpn, mmu_psize_defs[psize].shift, ssize); - want_v = hpte_encode_v(vpn, psize, ssize); + hash = hpt_hash(va, mmu_psize_defs[psize].shift, ssize); + want_v = hpte_encode_v(va, psize, ssize); /* Bolted mappings are only ever in the primary group */ slot = (hash & htab_hash_mask) * HPTES_PER_GROUP; @@ -315,15 +295,14 @@ static long native_hpte_find(unsigned long vpn, int psize, int ssize) static void native_hpte_updateboltedpp(unsigned long newpp, unsigned long ea, int psize, int ssize) { - unsigned long vpn; - unsigned long vsid; + unsigned long vsid, va; long slot; struct hash_pte *hptep; vsid = get_kernel_vsid(ea, ssize); - vpn = hpt_vpn(ea, vsid, ssize); + va = hpt_va(ea, vsid, ssize); - slot = native_hpte_find(vpn, psize, ssize); + slot = native_hpte_find(va, psize, ssize); if (slot == -1) panic("could not find page to bolt\n"); hptep = htab_address + slot; @@ -333,10 +312,10 @@ static void native_hpte_updateboltedpp(unsigned long newpp, unsigned long ea, (newpp & (HPTE_R_PP | HPTE_R_N)); /* Ensure it is out of the tlb too. */ - tlbie(vpn, psize, ssize, 0); + tlbie(va, psize, ssize, 0); } -static void native_hpte_invalidate(unsigned long slot, unsigned long vpn, +static void native_hpte_invalidate(unsigned long slot, unsigned long va, int psize, int ssize, int local) { struct hash_pte *hptep = htab_address + slot; @@ -346,9 +325,9 @@ static void native_hpte_invalidate(unsigned long slot, unsigned long vpn, local_irq_save(flags); - DBG_LOW(" invalidate(vpn=%016lx, hash: %lx)\n", vpn, slot); + DBG_LOW(" invalidate(va=%016lx, hash: %x)\n", va, slot); - want_v = hpte_encode_v(vpn, psize, ssize); + want_v = hpte_encode_v(va, psize, ssize); native_lock_hpte(hptep); hpte_v = hptep->v; @@ -360,7 +339,7 @@ static void native_hpte_invalidate(unsigned long slot, unsigned long vpn, hptep->v = 0; /* Invalidate the TLB */ - tlbie(vpn, psize, ssize, local); + tlbie(va, psize, ssize, local); local_irq_restore(flags); } @@ -370,12 +349,11 @@ static void native_hpte_invalidate(unsigned long slot, unsigned long vpn, #define LP_MASK(i) ((0xFF >> (i)) << LP_SHIFT) static void hpte_decode(struct hash_pte *hpte, unsigned long slot, - int *psize, int *ssize, unsigned long *vpn) + int *psize, int *ssize, unsigned long *va) { - unsigned long avpn, pteg, vpi; unsigned long hpte_r = hpte->r; unsigned long hpte_v = hpte->v; - unsigned long vsid, seg_off; + unsigned long avpn; int i, size, shift, penc; if (!(hpte_v & HPTE_V_LARGE)) @@ -402,38 +380,32 @@ static void hpte_decode(struct hash_pte *hpte, unsigned long slot, } /* This works for all page sizes, and for 256M and 1T segments */ - *ssize = hpte_v >> HPTE_V_SSIZE_SHIFT; shift = mmu_psize_defs[size].shift; + avpn = (HPTE_V_AVPN_VAL(hpte_v) & ~mmu_psize_defs[size].avpnm) << 23; - avpn = (HPTE_V_AVPN_VAL(hpte_v) & ~mmu_psize_defs[size].avpnm); - pteg = slot / HPTES_PER_GROUP; - if (hpte_v & HPTE_V_SECONDARY) - pteg = ~pteg; - - switch (*ssize) { - case MMU_SEGSIZE_256M: - /* We only have 28 - 23 bits of seg_off in avpn */ - seg_off = (avpn & 0x1f) << 23; - vsid = avpn >> 5; - /* We can find more bits from the pteg value */ - if (shift < 23) { - vpi = (vsid ^ pteg) & htab_hash_mask; - seg_off |= vpi << shift; - } - *vpn = vsid << (SID_SHIFT - VPN_SHIFT) | seg_off >> VPN_SHIFT; - case MMU_SEGSIZE_1T: - /* We only have 40 - 23 bits of seg_off in avpn */ - seg_off = (avpn & 0x1ffff) << 23; - vsid = avpn >> 17; - if (shift < 23) { + if (shift < 23) { + unsigned long vpi, vsid, pteg; + + pteg = slot / HPTES_PER_GROUP; + if (hpte_v & HPTE_V_SECONDARY) + pteg = ~pteg; + switch (hpte_v >> HPTE_V_SSIZE_SHIFT) { + case MMU_SEGSIZE_256M: + vpi = ((avpn >> 28) ^ pteg) & htab_hash_mask; + break; + case MMU_SEGSIZE_1T: + vsid = avpn >> 40; vpi = (vsid ^ (vsid << 25) ^ pteg) & htab_hash_mask; - seg_off |= vpi << shift; + break; + default: + avpn = vpi = size = 0; } - *vpn = vsid << (SID_SHIFT_1T - VPN_SHIFT) | seg_off >> VPN_SHIFT; - default: - *vpn = size = 0; + avpn |= (vpi << mmu_psize_defs[size].shift); } + + *va = avpn; *psize = size; + *ssize = hpte_v >> HPTE_V_SSIZE_SHIFT; } /* @@ -446,10 +418,9 @@ static void hpte_decode(struct hash_pte *hpte, unsigned long slot, */ static void native_hpte_clear(void) { - unsigned long vpn = 0; unsigned long slot, slots, flags; struct hash_pte *hptep = htab_address; - unsigned long hpte_v; + unsigned long hpte_v, va; unsigned long pteg_count; int psize, ssize; @@ -477,9 +448,9 @@ static void native_hpte_clear(void) * already hold the native_tlbie_lock. */ if (hpte_v & HPTE_V_VALID) { - hpte_decode(hptep, slot, &psize, &ssize, &vpn); + hpte_decode(hptep, slot, &psize, &ssize, &va); hptep->v = 0; - __tlbie(vpn, psize, ssize); + __tlbie(va, psize, ssize); } } @@ -494,8 +465,7 @@ static void native_hpte_clear(void) */ static void native_flush_hash_range(unsigned long number, int local) { - unsigned long vpn; - unsigned long hash, index, hidx, shift, slot; + unsigned long va, hash, index, hidx, shift, slot; struct hash_pte *hptep; unsigned long hpte_v; unsigned long want_v; @@ -509,18 +479,18 @@ static void native_flush_hash_range(unsigned long number, int local) local_irq_save(flags); for (i = 0; i < number; i++) { - vpn = batch->vpn[i]; + va = batch->vaddr[i]; pte = batch->pte[i]; - pte_iterate_hashed_subpages(pte, psize, vpn, index, shift) { - hash = hpt_hash(vpn, shift, ssize); + pte_iterate_hashed_subpages(pte, psize, va, index, shift) { + hash = hpt_hash(va, shift, ssize); hidx = __rpte_to_hidx(pte, index); if (hidx & _PTEIDX_SECONDARY) hash = ~hash; slot = (hash & htab_hash_mask) * HPTES_PER_GROUP; slot += hidx & _PTEIDX_GROUP_IX; hptep = htab_address + slot; - want_v = hpte_encode_v(vpn, psize, ssize); + want_v = hpte_encode_v(va, psize, ssize); native_lock_hpte(hptep); hpte_v = hptep->v; if (!HPTE_V_COMPARE(hpte_v, want_v) || @@ -535,12 +505,12 @@ static void native_flush_hash_range(unsigned long number, int local) mmu_psize_defs[psize].tlbiel && local) { asm volatile("ptesync":::"memory"); for (i = 0; i < number; i++) { - vpn = batch->vpn[i]; + va = batch->vaddr[i]; pte = batch->pte[i]; - pte_iterate_hashed_subpages(pte, psize, - vpn, index, shift) { - __tlbiel(vpn, psize, ssize); + pte_iterate_hashed_subpages(pte, psize, va, index, + shift) { + __tlbiel(va, psize, ssize); } pte_iterate_hashed_end(); } asm volatile("ptesync":::"memory"); @@ -552,12 +522,12 @@ static void native_flush_hash_range(unsigned long number, int local) asm volatile("ptesync":::"memory"); for (i = 0; i < number; i++) { - vpn = batch->vpn[i]; + va = batch->vaddr[i]; pte = batch->pte[i]; - pte_iterate_hashed_subpages(pte, psize, - vpn, index, shift) { - __tlbie(vpn, psize, ssize); + pte_iterate_hashed_subpages(pte, psize, va, index, + shift) { + __tlbie(va, psize, ssize); } pte_iterate_hashed_end(); } asm volatile("eieio; tlbsync; ptesync":::"memory"); @@ -569,6 +539,29 @@ static void native_flush_hash_range(unsigned long number, int local) local_irq_restore(flags); } +#ifdef CONFIG_PPC_PSERIES +/* Disable TLB batching on nighthawk */ +static inline int tlb_batching_enabled(void) +{ + struct device_node *root = of_find_node_by_path("/"); + int enabled = 1; + + if (root) { + const char *model = of_get_property(root, "model", NULL); + if (model && !strcmp(model, "IBM,9076-N81")) + enabled = 0; + of_node_put(root); + } + + return enabled; +} +#else +static inline int tlb_batching_enabled(void) +{ + return 1; +} +#endif + void __init hpte_init_native(void) { ppc_md.hpte_invalidate = native_hpte_invalidate; @@ -577,5 +570,6 @@ void __init hpte_init_native(void) ppc_md.hpte_insert = native_hpte_insert; ppc_md.hpte_remove = native_hpte_remove; ppc_md.hpte_clear_all = native_hpte_clear; - ppc_md.flush_hash_range = native_flush_hash_range; + if (tlb_batching_enabled()) + ppc_md.flush_hash_range = native_flush_hash_range; } diff --git a/trunk/arch/powerpc/mm/hash_utils_64.c b/trunk/arch/powerpc/mm/hash_utils_64.c index 3a292be2e079..377e5cbedbbb 100644 --- a/trunk/arch/powerpc/mm/hash_utils_64.c +++ b/trunk/arch/powerpc/mm/hash_utils_64.c @@ -43,6 +43,7 @@ #include #include #include +#include #include #include #include @@ -191,18 +192,18 @@ int htab_bolt_mapping(unsigned long vstart, unsigned long vend, vaddr += step, paddr += step) { unsigned long hash, hpteg; unsigned long vsid = get_kernel_vsid(vaddr, ssize); - unsigned long vpn = hpt_vpn(vaddr, vsid, ssize); + unsigned long va = hpt_va(vaddr, vsid, ssize); unsigned long tprot = prot; /* Make kernel text executable */ if (overlaps_kernel_text(vaddr, vaddr + step)) tprot &= ~HPTE_R_N; - hash = hpt_hash(vpn, shift, ssize); + hash = hpt_hash(va, shift, ssize); hpteg = ((hash & htab_hash_mask) * HPTES_PER_GROUP); BUG_ON(!ppc_md.hpte_insert); - ret = ppc_md.hpte_insert(hpteg, vpn, paddr, tprot, + ret = ppc_md.hpte_insert(hpteg, va, paddr, tprot, HPTE_V_BOLTED, psize, ssize); if (ret < 0) @@ -650,7 +651,7 @@ static void __init htab_initialize(void) DBG("Hash table allocated at %lx, size: %lx\n", table, htab_size_bytes); - htab_address = __va(table); + htab_address = abs_to_virt(table); /* htab absolute addr + encoded htabsize */ _SDR1 = table + __ilog2(pteg_count) - 11; @@ -803,19 +804,16 @@ unsigned int hash_page_do_lazy_icache(unsigned int pp, pte_t pte, int trap) #ifdef CONFIG_PPC_MM_SLICES unsigned int get_paca_psize(unsigned long addr) { - u64 lpsizes; - unsigned char *hpsizes; - unsigned long index, mask_index; + unsigned long index, slices; if (addr < SLICE_LOW_TOP) { - lpsizes = get_paca()->context.low_slices_psize; + slices = get_paca()->context.low_slices_psize; index = GET_LOW_SLICE_INDEX(addr); - return (lpsizes >> (index * 4)) & 0xF; + } else { + slices = get_paca()->context.high_slices_psize; + index = GET_HIGH_SLICE_INDEX(addr); } - hpsizes = get_paca()->context.high_slices_psize; - index = GET_HIGH_SLICE_INDEX(addr); - mask_index = index & 0x1; - return (hpsizes[index >> 1] >> (mask_index * 4)) & 0xF; + return (slices >> (index * 4)) & 0xF; } #else @@ -1155,21 +1153,21 @@ void hash_preload(struct mm_struct *mm, unsigned long ea, /* WARNING: This is called from hash_low_64.S, if you change this prototype, * do not forget to update the assembly call site ! */ -void flush_hash_page(unsigned long vpn, real_pte_t pte, int psize, int ssize, +void flush_hash_page(unsigned long va, real_pte_t pte, int psize, int ssize, int local) { unsigned long hash, index, shift, hidx, slot; - DBG_LOW("flush_hash_page(vpn=%016lx)\n", vpn); - pte_iterate_hashed_subpages(pte, psize, vpn, index, shift) { - hash = hpt_hash(vpn, shift, ssize); + 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); if (hidx & _PTEIDX_SECONDARY) hash = ~hash; slot = (hash & htab_hash_mask) * HPTES_PER_GROUP; slot += hidx & _PTEIDX_GROUP_IX; DBG_LOW(" sub %ld: hash=%lx, hidx=%lx\n", index, slot, hidx); - ppc_md.hpte_invalidate(slot, vpn, psize, ssize, local); + ppc_md.hpte_invalidate(slot, va, psize, ssize, local); } pte_iterate_hashed_end(); } @@ -1183,7 +1181,7 @@ void flush_hash_range(unsigned long number, int local) &__get_cpu_var(ppc64_tlb_batch); for (i = 0; i < number; i++) - flush_hash_page(batch->vpn[i], batch->pte[i], + flush_hash_page(batch->vaddr[i], batch->pte[i], batch->psize, batch->ssize, local); } } @@ -1210,14 +1208,14 @@ static void kernel_map_linear_page(unsigned long vaddr, unsigned long lmi) { unsigned long hash, hpteg; unsigned long vsid = get_kernel_vsid(vaddr, mmu_kernel_ssize); - unsigned long vpn = hpt_vpn(vaddr, vsid, mmu_kernel_ssize); + unsigned long va = hpt_va(vaddr, vsid, mmu_kernel_ssize); unsigned long mode = htab_convert_pte_flags(PAGE_KERNEL); int ret; - hash = hpt_hash(vpn, PAGE_SHIFT, mmu_kernel_ssize); + hash = hpt_hash(va, PAGE_SHIFT, mmu_kernel_ssize); hpteg = ((hash & htab_hash_mask) * HPTES_PER_GROUP); - ret = ppc_md.hpte_insert(hpteg, vpn, __pa(vaddr), + ret = ppc_md.hpte_insert(hpteg, va, __pa(vaddr), mode, HPTE_V_BOLTED, mmu_linear_psize, mmu_kernel_ssize); BUG_ON (ret < 0); @@ -1231,9 +1229,9 @@ static void kernel_unmap_linear_page(unsigned long vaddr, unsigned long lmi) { unsigned long hash, hidx, slot; unsigned long vsid = get_kernel_vsid(vaddr, mmu_kernel_ssize); - unsigned long vpn = hpt_vpn(vaddr, vsid, mmu_kernel_ssize); + unsigned long va = hpt_va(vaddr, vsid, mmu_kernel_ssize); - hash = hpt_hash(vpn, PAGE_SHIFT, mmu_kernel_ssize); + hash = hpt_hash(va, PAGE_SHIFT, mmu_kernel_ssize); spin_lock(&linear_map_hash_lock); BUG_ON(!(linear_map_hash_slots[lmi] & 0x80)); hidx = linear_map_hash_slots[lmi] & 0x7f; @@ -1243,7 +1241,7 @@ static void kernel_unmap_linear_page(unsigned long vaddr, unsigned long lmi) hash = ~hash; slot = (hash & htab_hash_mask) * HPTES_PER_GROUP; slot += hidx & _PTEIDX_GROUP_IX; - ppc_md.hpte_invalidate(slot, vpn, mmu_linear_psize, mmu_kernel_ssize, 0); + ppc_md.hpte_invalidate(slot, va, mmu_linear_psize, mmu_kernel_ssize, 0); } void kernel_map_pages(struct page *page, int numpages, int enable) diff --git a/trunk/arch/powerpc/mm/hugetlbpage-hash64.c b/trunk/arch/powerpc/mm/hugetlbpage-hash64.c index cecad348f604..cc5c273086cf 100644 --- a/trunk/arch/powerpc/mm/hugetlbpage-hash64.c +++ b/trunk/arch/powerpc/mm/hugetlbpage-hash64.c @@ -18,15 +18,14 @@ int __hash_page_huge(unsigned long ea, unsigned long access, unsigned long vsid, pte_t *ptep, unsigned long trap, int local, int ssize, unsigned int shift, unsigned int mmu_psize) { - unsigned long vpn; unsigned long old_pte, new_pte; - unsigned long rflags, pa, sz; + unsigned long va, rflags, pa, sz; long slot; BUG_ON(shift != mmu_psize_defs[mmu_psize].shift); /* Search the Linux page table for a match with va */ - vpn = hpt_vpn(ea, vsid, ssize); + va = hpt_va(ea, vsid, ssize); /* At this point, we have a pte (old_pte) which can be used to build * or update an HPTE. There are 2 cases: @@ -70,19 +69,19 @@ int __hash_page_huge(unsigned long ea, unsigned long access, unsigned long vsid, /* There MIGHT be an HPTE for this pte */ unsigned long hash, slot; - hash = hpt_hash(vpn, shift, ssize); + hash = hpt_hash(va, shift, ssize); if (old_pte & _PAGE_F_SECOND) hash = ~hash; slot = (hash & htab_hash_mask) * HPTES_PER_GROUP; slot += (old_pte & _PAGE_F_GIX) >> 12; - if (ppc_md.hpte_updatepp(slot, rflags, vpn, mmu_psize, + if (ppc_md.hpte_updatepp(slot, rflags, va, mmu_psize, ssize, local) == -1) old_pte &= ~_PAGE_HPTEFLAGS; } if (likely(!(old_pte & _PAGE_HASHPTE))) { - unsigned long hash = hpt_hash(vpn, shift, ssize); + unsigned long hash = hpt_hash(va, shift, ssize); unsigned long hpte_group; pa = pte_pfn(__pte(old_pte)) << PAGE_SHIFT; @@ -102,14 +101,14 @@ int __hash_page_huge(unsigned long ea, unsigned long access, unsigned long vsid, _PAGE_COHERENT | _PAGE_GUARDED)); /* Insert into the hash table, primary slot */ - slot = ppc_md.hpte_insert(hpte_group, vpn, pa, rflags, 0, + slot = ppc_md.hpte_insert(hpte_group, va, pa, rflags, 0, mmu_psize, ssize); /* Primary is full, try the secondary */ if (unlikely(slot == -1)) { hpte_group = ((~hash & htab_hash_mask) * HPTES_PER_GROUP) & ~0x7UL; - slot = ppc_md.hpte_insert(hpte_group, vpn, pa, rflags, + slot = ppc_md.hpte_insert(hpte_group, va, pa, rflags, HPTE_V_SECONDARY, mmu_psize, ssize); if (slot == -1) { diff --git a/trunk/arch/powerpc/mm/init_64.c b/trunk/arch/powerpc/mm/init_64.c index 95a45293e5ac..620b7acd2fdf 100644 --- a/trunk/arch/powerpc/mm/init_64.c +++ b/trunk/arch/powerpc/mm/init_64.c @@ -62,6 +62,7 @@ #include #include #include +#include #include #include "mmu_decl.h" diff --git a/trunk/arch/powerpc/mm/mem.c b/trunk/arch/powerpc/mm/mem.c index 0dba5066c22a..fbdad0e3929a 100644 --- a/trunk/arch/powerpc/mm/mem.c +++ b/trunk/arch/powerpc/mm/mem.c @@ -62,7 +62,7 @@ int init_bootmem_done; int mem_init_done; -unsigned long long memory_limit; +phys_addr_t memory_limit; #ifdef CONFIG_HIGHMEM pte_t *kmap_pte; @@ -300,7 +300,8 @@ void __init mem_init(void) unsigned long reservedpages = 0, codesize, initsize, datasize, bsssize; #ifdef CONFIG_SWIOTLB - swiotlb_init(0); + if (ppc_swiotlb_enable) + swiotlb_init(1); #endif num_physpages = memblock_phys_mem_size() >> PAGE_SHIFT; diff --git a/trunk/arch/powerpc/mm/mmu_context_hash64.c b/trunk/arch/powerpc/mm/mmu_context_hash64.c index 40bc5b0ace54..40677aa0190e 100644 --- a/trunk/arch/powerpc/mm/mmu_context_hash64.c +++ b/trunk/arch/powerpc/mm/mmu_context_hash64.c @@ -30,13 +30,11 @@ static DEFINE_SPINLOCK(mmu_context_lock); static DEFINE_IDA(mmu_context_ida); /* - * 256MB segment - * The proto-VSID space has 2^(CONTEX_BITS + USER_ESID_BITS) - 1 segments - * available for user mappings. Each segment contains 2^28 bytes. Each - * context maps 2^46 bytes (64TB) so we can support 2^19-1 contexts - * (19 == 37 + 28 - 46). + * The proto-VSID space has 2^35 - 1 segments available for user mappings. + * Each segment contains 2^28 bytes. Each context maps 2^44 bytes, + * so we can support 2^19-1 contexts (19 == 35 + 28 - 44). */ -#define MAX_CONTEXT ((1UL << CONTEXT_BITS) - 1) +#define MAX_CONTEXT ((1UL << 19) - 1) int __init_new_context(void) { diff --git a/trunk/arch/powerpc/mm/pgtable_64.c b/trunk/arch/powerpc/mm/pgtable_64.c index e212a271c7a4..249a0631c4db 100644 --- a/trunk/arch/powerpc/mm/pgtable_64.c +++ b/trunk/arch/powerpc/mm/pgtable_64.c @@ -51,23 +51,14 @@ #include #include #include +#include #include #include "mmu_decl.h" -/* Some sanity checking */ -#if TASK_SIZE_USER64 > PGTABLE_RANGE -#error TASK_SIZE_USER64 exceeds pagetable range -#endif - -#ifdef CONFIG_PPC_STD_MMU_64 -#if TASK_SIZE_USER64 > (1UL << (USER_ESID_BITS + SID_SHIFT)) -#error TASK_SIZE_USER64 exceeds user VSID range -#endif -#endif - unsigned long ioremap_bot = IOREMAP_BASE; + #ifdef CONFIG_PPC_MMU_NOHASH static void *early_alloc_pgtable(unsigned long size) { diff --git a/trunk/arch/powerpc/mm/slb_low.S b/trunk/arch/powerpc/mm/slb_low.S index 1a16ca227757..b9ee79ce2200 100644 --- a/trunk/arch/powerpc/mm/slb_low.S +++ b/trunk/arch/powerpc/mm/slb_low.S @@ -56,12 +56,6 @@ _GLOBAL(slb_allocate_realmode) */ _GLOBAL(slb_miss_kernel_load_linear) li r11,0 - li r9,0x1 - /* - * for 1T we shift 12 bits more. slb_finish_load_1T will do - * the necessary adjustment - */ - rldimi r10,r9,(CONTEXT_BITS + USER_ESID_BITS),0 BEGIN_FTR_SECTION b slb_finish_load END_MMU_FTR_SECTION_IFCLR(MMU_FTR_1T_SEGMENT) @@ -91,12 +85,6 @@ _GLOBAL(slb_miss_kernel_load_vmemmap) _GLOBAL(slb_miss_kernel_load_io) li r11,0 6: - li r9,0x1 - /* - * for 1T we shift 12 bits more. slb_finish_load_1T will do - * the necessary adjustment - */ - rldimi r10,r9,(CONTEXT_BITS + USER_ESID_BITS),0 BEGIN_FTR_SECTION b slb_finish_load END_MMU_FTR_SECTION_IFCLR(MMU_FTR_1T_SEGMENT) @@ -120,31 +108,17 @@ END_MMU_FTR_SECTION_IFCLR(MMU_FTR_1T_SEGMENT) * between 4k and 64k standard page size */ #ifdef CONFIG_PPC_MM_SLICES - /* r10 have esid */ cmpldi r10,16 - /* below SLICE_LOW_TOP */ - blt 5f - /* - * Handle hpsizes, - * r9 is get_paca()->context.high_slices_psize[index], r11 is mask_index - */ - srdi r11,r10,(SLICE_HIGH_SHIFT - SLICE_LOW_SHIFT + 1) /* index */ - addi r9,r11,PACAHIGHSLICEPSIZE - lbzx r9,r13,r9 /* r9 is hpsizes[r11] */ - /* r11 = (r10 >> (SLICE_HIGH_SHIFT - SLICE_LOW_SHIFT)) & 0x1 */ - rldicl r11,r10,(64 - (SLICE_HIGH_SHIFT - SLICE_LOW_SHIFT)),63 - b 6f -5: - /* - * Handle lpsizes - * r9 is get_paca()->context.low_slices_psize, r11 is index - */ + /* Get the slice index * 4 in r11 and matching slice size mask in r9 */ ld r9,PACALOWSLICESPSIZE(r13) - mr r11,r10 -6: - sldi r11,r11,2 /* index * 4 */ - /* Extract the psize and multiply to get an array offset */ + sldi r11,r10,2 + blt 5f + ld r9,PACAHIGHSLICEPSIZE(r13) + srdi r11,r10,(SLICE_HIGH_SHIFT - SLICE_LOW_SHIFT - 2) + andi. r11,r11,0x3c + +5: /* Extract the psize and multiply to get an array offset */ srd r9,r9,r11 andi. r9,r9,0xf mulli r9,r9,MMUPSIZEDEFSIZE @@ -235,11 +209,7 @@ _GLOBAL(slb_allocate_user) */ slb_finish_load: ASM_VSID_SCRAMBLE(r10,r9,256M) - /* - * bits above VSID_BITS_256M need to be ignored from r10 - * also combine VSID and flags - */ - rldimi r11,r10,SLB_VSID_SHIFT,(64 - (SLB_VSID_SHIFT + VSID_BITS_256M)) + rldimi r11,r10,SLB_VSID_SHIFT,16 /* combine VSID and flags */ /* r3 = EA, r11 = VSID data */ /* @@ -282,10 +252,10 @@ _GLOBAL(slb_compare_rr_to_size) bge 1f /* still room in the slb cache */ - sldi r11,r3,2 /* r11 = offset * sizeof(u32) */ - srdi r10,r10,28 /* get the 36 bits of the ESID */ - add r11,r11,r13 /* r11 = (u32 *)paca + offset */ - stw r10,PACASLBCACHE(r11) /* paca->slb_cache[offset] = esid */ + sldi r11,r3,1 /* r11 = offset * sizeof(u16) */ + rldicl r10,r10,36,28 /* get low 16 bits of the ESID */ + add r11,r11,r13 /* r11 = (u16 *)paca + offset */ + sth r10,PACASLBCACHE(r11) /* paca->slb_cache[offset] = esid */ addi r3,r3,1 /* offset++ */ b 2f 1: /* offset >= SLB_CACHE_ENTRIES */ @@ -303,11 +273,7 @@ _GLOBAL(slb_compare_rr_to_size) slb_finish_load_1T: srdi r10,r10,40-28 /* get 1T ESID */ ASM_VSID_SCRAMBLE(r10,r9,1T) - /* - * bits above VSID_BITS_1T need to be ignored from r10 - * also combine VSID and flags - */ - rldimi r11,r10,SLB_VSID_SHIFT_1T,(64 - (SLB_VSID_SHIFT_1T + VSID_BITS_1T)) + rldimi r11,r10,SLB_VSID_SHIFT_1T,16 /* combine VSID and flags */ li r10,MMU_SEGSIZE_1T rldimi r11,r10,SLB_VSID_SSIZE_SHIFT,0 /* insert segment size */ diff --git a/trunk/arch/powerpc/mm/slice.c b/trunk/arch/powerpc/mm/slice.c index 5829d2a950d4..73709f7ce92c 100644 --- a/trunk/arch/powerpc/mm/slice.c +++ b/trunk/arch/powerpc/mm/slice.c @@ -34,11 +34,6 @@ #include #include -/* some sanity checks */ -#if (PGTABLE_RANGE >> 43) > SLICE_MASK_SIZE -#error PGTABLE_RANGE exceeds slice_mask high_slices size -#endif - static DEFINE_SPINLOCK(slice_convert_lock); @@ -47,7 +42,7 @@ int _slice_debug = 1; static void slice_print_mask(const char *label, struct slice_mask mask) { - char *p, buf[16 + 3 + 64 + 1]; + char *p, buf[16 + 3 + 16 + 1]; int i; if (!_slice_debug) @@ -59,7 +54,7 @@ static void slice_print_mask(const char *label, struct slice_mask mask) *(p++) = '-'; *(p++) = ' '; for (i = 0; i < SLICE_NUM_HIGH; i++) - *(p++) = (mask.high_slices & (1ul << i)) ? '1' : '0'; + *(p++) = (mask.high_slices & (1 << i)) ? '1' : '0'; *(p++) = 0; printk(KERN_DEBUG "%s:%s\n", label, buf); @@ -89,8 +84,8 @@ static struct slice_mask slice_range_to_mask(unsigned long start, } if ((start + len) > SLICE_LOW_TOP) - ret.high_slices = (1ul << (GET_HIGH_SLICE_INDEX(end) + 1)) - - (1ul << GET_HIGH_SLICE_INDEX(start)); + ret.high_slices = (1u << (GET_HIGH_SLICE_INDEX(end) + 1)) + - (1u << GET_HIGH_SLICE_INDEX(start)); return ret; } @@ -140,31 +135,26 @@ static struct slice_mask slice_mask_for_free(struct mm_struct *mm) for (i = 0; i < SLICE_NUM_HIGH; i++) if (!slice_high_has_vma(mm, i)) - ret.high_slices |= 1ul << i; + ret.high_slices |= 1u << i; return ret; } static struct slice_mask slice_mask_for_size(struct mm_struct *mm, int psize) { - unsigned char *hpsizes; - int index, mask_index; struct slice_mask ret = { 0, 0 }; unsigned long i; - u64 lpsizes; + u64 psizes; - lpsizes = mm->context.low_slices_psize; + psizes = mm->context.low_slices_psize; for (i = 0; i < SLICE_NUM_LOW; i++) - if (((lpsizes >> (i * 4)) & 0xf) == psize) + if (((psizes >> (i * 4)) & 0xf) == psize) ret.low_slices |= 1u << i; - hpsizes = mm->context.high_slices_psize; - for (i = 0; i < SLICE_NUM_HIGH; i++) { - mask_index = i & 0x1; - index = i >> 1; - if (((hpsizes[index] >> (mask_index * 4)) & 0xf) == psize) - ret.high_slices |= 1ul << i; - } + psizes = mm->context.high_slices_psize; + for (i = 0; i < SLICE_NUM_HIGH; i++) + if (((psizes >> (i * 4)) & 0xf) == psize) + ret.high_slices |= 1u << i; return ret; } @@ -193,10 +183,8 @@ static void slice_flush_segments(void *parm) static void slice_convert(struct mm_struct *mm, struct slice_mask mask, int psize) { - int index, mask_index; /* Write the new slice psize bits */ - unsigned char *hpsizes; - u64 lpsizes; + u64 lpsizes, hpsizes; unsigned long i, flags; slice_dbg("slice_convert(mm=%p, psize=%d)\n", mm, psize); @@ -213,18 +201,14 @@ static void slice_convert(struct mm_struct *mm, struct slice_mask mask, int psiz lpsizes = (lpsizes & ~(0xful << (i * 4))) | (((unsigned long)psize) << (i * 4)); - /* Assign the value back */ - mm->context.low_slices_psize = lpsizes; - hpsizes = mm->context.high_slices_psize; - for (i = 0; i < SLICE_NUM_HIGH; i++) { - mask_index = i & 0x1; - index = i >> 1; - if (mask.high_slices & (1ul << i)) - hpsizes[index] = (hpsizes[index] & - ~(0xf << (mask_index * 4))) | - (((unsigned long)psize) << (mask_index * 4)); - } + for (i = 0; i < SLICE_NUM_HIGH; i++) + if (mask.high_slices & (1u << i)) + hpsizes = (hpsizes & ~(0xful << (i * 4))) | + (((unsigned long)psize) << (i * 4)); + + mm->context.low_slices_psize = lpsizes; + mm->context.high_slices_psize = hpsizes; slice_dbg(" lsps=%lx, hsps=%lx\n", mm->context.low_slices_psize, @@ -603,19 +587,18 @@ unsigned long arch_get_unmapped_area_topdown(struct file *filp, unsigned int get_slice_psize(struct mm_struct *mm, unsigned long addr) { - unsigned char *hpsizes; - int index, mask_index; + u64 psizes; + int index; if (addr < SLICE_LOW_TOP) { - u64 lpsizes; - lpsizes = mm->context.low_slices_psize; + psizes = mm->context.low_slices_psize; index = GET_LOW_SLICE_INDEX(addr); - return (lpsizes >> (index * 4)) & 0xf; + } else { + psizes = mm->context.high_slices_psize; + index = GET_HIGH_SLICE_INDEX(addr); } - hpsizes = mm->context.high_slices_psize; - index = GET_HIGH_SLICE_INDEX(addr); - mask_index = index & 0x1; - return (hpsizes[index >> 1] >> (mask_index * 4)) & 0xf; + + return (psizes >> (index * 4)) & 0xf; } EXPORT_SYMBOL_GPL(get_slice_psize); @@ -635,9 +618,7 @@ EXPORT_SYMBOL_GPL(get_slice_psize); */ void slice_set_user_psize(struct mm_struct *mm, unsigned int psize) { - int index, mask_index; - unsigned char *hpsizes; - unsigned long flags, lpsizes; + unsigned long flags, lpsizes, hpsizes; unsigned int old_psize; int i; @@ -658,21 +639,15 @@ void slice_set_user_psize(struct mm_struct *mm, unsigned int psize) if (((lpsizes >> (i * 4)) & 0xf) == old_psize) lpsizes = (lpsizes & ~(0xful << (i * 4))) | (((unsigned long)psize) << (i * 4)); - /* Assign the value back */ - mm->context.low_slices_psize = lpsizes; hpsizes = mm->context.high_slices_psize; - for (i = 0; i < SLICE_NUM_HIGH; i++) { - mask_index = i & 0x1; - index = i >> 1; - if (((hpsizes[index] >> (mask_index * 4)) & 0xf) == old_psize) - hpsizes[index] = (hpsizes[index] & - ~(0xf << (mask_index * 4))) | - (((unsigned long)psize) << (mask_index * 4)); - } - - + for (i = 0; i < SLICE_NUM_HIGH; i++) + if (((hpsizes >> (i * 4)) & 0xf) == old_psize) + hpsizes = (hpsizes & ~(0xful << (i * 4))) | + (((unsigned long)psize) << (i * 4)); + mm->context.low_slices_psize = lpsizes; + mm->context.high_slices_psize = hpsizes; slice_dbg(" lsps=%lx, hsps=%lx\n", mm->context.low_slices_psize, @@ -685,27 +660,18 @@ void slice_set_user_psize(struct mm_struct *mm, unsigned int psize) void slice_set_psize(struct mm_struct *mm, unsigned long address, unsigned int psize) { - unsigned char *hpsizes; unsigned long i, flags; - u64 *lpsizes; + u64 *p; spin_lock_irqsave(&slice_convert_lock, flags); if (address < SLICE_LOW_TOP) { i = GET_LOW_SLICE_INDEX(address); - lpsizes = &mm->context.low_slices_psize; - *lpsizes = (*lpsizes & ~(0xful << (i * 4))) | - ((unsigned long) psize << (i * 4)); + p = &mm->context.low_slices_psize; } else { - int index, mask_index; i = GET_HIGH_SLICE_INDEX(address); - hpsizes = mm->context.high_slices_psize; - mask_index = i & 0x1; - index = i >> 1; - hpsizes[index] = (hpsizes[index] & - ~(0xf << (mask_index * 4))) | - (((unsigned long)psize) << (mask_index * 4)); + p = &mm->context.high_slices_psize; } - + *p = (*p & ~(0xful << (i * 4))) | ((unsigned long) psize << (i * 4)); spin_unlock_irqrestore(&slice_convert_lock, flags); #ifdef CONFIG_SPU_BASE diff --git a/trunk/arch/powerpc/mm/stab.c b/trunk/arch/powerpc/mm/stab.c index 3f8efa6f2997..9106ebb118f5 100644 --- a/trunk/arch/powerpc/mm/stab.c +++ b/trunk/arch/powerpc/mm/stab.c @@ -20,6 +20,7 @@ #include #include #include +#include struct stab_entry { unsigned long esid_data; @@ -256,7 +257,7 @@ void __init stabs_alloc(void) memset((void *)newstab, 0, HW_PAGE_SIZE); paca[cpu].stab_addr = newstab; - paca[cpu].stab_real = __pa(newstab); + paca[cpu].stab_real = virt_to_abs(newstab); printk(KERN_INFO "Segment table for CPU %d at 0x%llx " "virtual, 0x%llx absolute\n", cpu, paca[cpu].stab_addr, paca[cpu].stab_real); diff --git a/trunk/arch/powerpc/mm/subpage-prot.c b/trunk/arch/powerpc/mm/subpage-prot.c index 7c415ddde948..e4f8f1fc81a5 100644 --- a/trunk/arch/powerpc/mm/subpage-prot.c +++ b/trunk/arch/powerpc/mm/subpage-prot.c @@ -95,8 +95,7 @@ static void subpage_prot_clear(unsigned long addr, unsigned long len) struct mm_struct *mm = current->mm; struct subpage_prot_table *spt = &mm->context.spt; u32 **spm, *spp; - unsigned long i; - size_t nw; + int i, nw; unsigned long next, limit; down_write(&mm->mmap_sem); @@ -145,8 +144,7 @@ long sys_subpage_prot(unsigned long addr, unsigned long len, u32 __user *map) struct mm_struct *mm = current->mm; struct subpage_prot_table *spt = &mm->context.spt; u32 **spm, *spp; - unsigned long i; - size_t nw; + int i, nw; unsigned long next, limit; int err; diff --git a/trunk/arch/powerpc/mm/tlb_hash64.c b/trunk/arch/powerpc/mm/tlb_hash64.c index ae758b3ff72c..31f18207970b 100644 --- a/trunk/arch/powerpc/mm/tlb_hash64.c +++ b/trunk/arch/powerpc/mm/tlb_hash64.c @@ -42,9 +42,8 @@ DEFINE_PER_CPU(struct ppc64_tlb_batch, ppc64_tlb_batch); void hpte_need_flush(struct mm_struct *mm, unsigned long addr, pte_t *ptep, unsigned long pte, int huge) { - unsigned long vpn; struct ppc64_tlb_batch *batch = &get_cpu_var(ppc64_tlb_batch); - unsigned long vsid; + unsigned long vsid, vaddr; unsigned int psize; int ssize; real_pte_t rpte; @@ -87,7 +86,7 @@ void hpte_need_flush(struct mm_struct *mm, unsigned long addr, vsid = get_kernel_vsid(addr, mmu_kernel_ssize); ssize = mmu_kernel_ssize; } - vpn = hpt_vpn(addr, vsid, ssize); + vaddr = hpt_va(addr, vsid, ssize); rpte = __real_pte(__pte(pte), ptep); /* @@ -97,7 +96,7 @@ void hpte_need_flush(struct mm_struct *mm, unsigned long addr, * and decide to use local invalidates instead... */ if (!batch->active) { - flush_hash_page(vpn, rpte, psize, ssize, 0); + flush_hash_page(vaddr, rpte, psize, ssize, 0); put_cpu_var(ppc64_tlb_batch); return; } @@ -123,7 +122,7 @@ void hpte_need_flush(struct mm_struct *mm, unsigned long addr, batch->ssize = ssize; } batch->pte[i] = rpte; - batch->vpn[i] = vpn; + batch->vaddr[i] = vaddr; batch->index = ++i; if (i >= PPC64_TLB_BATCH_NR) __flush_tlb_pending(batch); @@ -147,7 +146,7 @@ void __flush_tlb_pending(struct ppc64_tlb_batch *batch) if (cpumask_equal(mm_cpumask(batch->mm), tmp)) local = 1; if (i == 1) - flush_hash_page(batch->vpn[0], batch->pte[0], + flush_hash_page(batch->vaddr[0], batch->pte[0], batch->psize, batch->ssize, local); else flush_hash_range(i, local); diff --git a/trunk/arch/powerpc/mm/tlb_low_64e.S b/trunk/arch/powerpc/mm/tlb_low_64e.S index b4113bf86353..f09d48e3268d 100644 --- a/trunk/arch/powerpc/mm/tlb_low_64e.S +++ b/trunk/arch/powerpc/mm/tlb_low_64e.S @@ -20,8 +20,6 @@ #include #include #include -#include -#include #ifdef CONFIG_PPC_64K_PAGES #define VPTE_PMD_SHIFT (PTE_INDEX_SIZE+1) @@ -39,18 +37,12 @@ * * **********************************************************************/ -.macro tlb_prolog_bolted intnum addr - mtspr SPRN_SPRG_GEN_SCRATCH,r13 +.macro tlb_prolog_bolted addr + mtspr SPRN_SPRG_TLB_SCRATCH,r13 mfspr r13,SPRN_SPRG_PACA std r10,PACA_EXTLB+EX_TLB_R10(r13) mfcr r10 std r11,PACA_EXTLB+EX_TLB_R11(r13) -#ifdef CONFIG_KVM_BOOKE_HV -BEGIN_FTR_SECTION - mfspr r11, SPRN_SRR1 -END_FTR_SECTION_IFSET(CPU_FTR_EMB_HV) -#endif - DO_KVM \intnum, SPRN_SRR1 std r16,PACA_EXTLB+EX_TLB_R16(r13) mfspr r16,\addr /* get faulting address */ std r14,PACA_EXTLB+EX_TLB_R14(r13) @@ -69,12 +61,12 @@ END_FTR_SECTION_IFSET(CPU_FTR_EMB_HV) ld r15,PACA_EXTLB+EX_TLB_R15(r13) TLB_MISS_RESTORE_STATS_BOLTED ld r16,PACA_EXTLB+EX_TLB_R16(r13) - mfspr r13,SPRN_SPRG_GEN_SCRATCH + mfspr r13,SPRN_SPRG_TLB_SCRATCH .endm /* Data TLB miss */ START_EXCEPTION(data_tlb_miss_bolted) - tlb_prolog_bolted BOOKE_INTERRUPT_DTLB_MISS SPRN_DEAR + tlb_prolog_bolted SPRN_DEAR /* We need _PAGE_PRESENT and _PAGE_ACCESSED set */ @@ -222,7 +214,7 @@ itlb_miss_fault_bolted: /* Instruction TLB miss */ START_EXCEPTION(instruction_tlb_miss_bolted) - tlb_prolog_bolted BOOKE_INTERRUPT_ITLB_MISS SPRN_SRR0 + tlb_prolog_bolted SPRN_SRR0 rldicl. r10,r16,64-PGTABLE_EADDR_SIZE,PGTABLE_EADDR_SIZE+4 srdi r15,r16,60 /* get region */ diff --git a/trunk/arch/powerpc/oprofile/op_model_power4.c b/trunk/arch/powerpc/oprofile/op_model_power4.c index 315f9495e9b2..95ae77dec3f6 100644 --- a/trunk/arch/powerpc/oprofile/op_model_power4.c +++ b/trunk/arch/powerpc/oprofile/op_model_power4.c @@ -21,13 +21,6 @@ #include #define dbg(args...) -#define OPROFILE_PM_PMCSEL_MSK 0xffULL -#define OPROFILE_PM_UNIT_SHIFT 60 -#define OPROFILE_PM_UNIT_MSK 0xfULL -#define OPROFILE_MAX_PMC_NUM 3 -#define OPROFILE_PMSEL_FIELD_WIDTH 8 -#define OPROFILE_UNIT_FIELD_WIDTH 4 -#define MMCRA_SIAR_VALID_MASK 0x10000000ULL static unsigned long reset_value[OP_MAX_COUNTER]; @@ -38,61 +31,6 @@ static int use_slot_nums; static u32 mmcr0_val; static u64 mmcr1_val; static u64 mmcra_val; -static u32 cntr_marked_events; - -static int power7_marked_instr_event(u64 mmcr1) -{ - u64 psel, unit; - int pmc, cntr_marked_events = 0; - - /* Given the MMCR1 value, look at the field for each counter to - * determine if it is a marked event. Code based on the function - * power7_marked_instr_event() in file arch/powerpc/perf/power7-pmu.c. - */ - for (pmc = 0; pmc < 4; pmc++) { - psel = mmcr1 & (OPROFILE_PM_PMCSEL_MSK - << (OPROFILE_MAX_PMC_NUM - pmc) - * OPROFILE_MAX_PMC_NUM); - psel = (psel >> ((OPROFILE_MAX_PMC_NUM - pmc) - * OPROFILE_PMSEL_FIELD_WIDTH)) & ~1ULL; - unit = mmcr1 & (OPROFILE_PM_UNIT_MSK - << (OPROFILE_PM_UNIT_SHIFT - - (pmc * OPROFILE_PMSEL_FIELD_WIDTH ))); - unit = unit >> (OPROFILE_PM_UNIT_SHIFT - - (pmc * OPROFILE_PMSEL_FIELD_WIDTH)); - - switch (psel >> 4) { - case 2: - cntr_marked_events |= (pmc == 1 || pmc == 3) << pmc; - break; - case 3: - if (psel == 0x3c) { - cntr_marked_events |= (pmc == 0) << pmc; - break; - } - - if (psel == 0x3e) { - cntr_marked_events |= (pmc != 1) << pmc; - break; - } - - cntr_marked_events |= 1 << pmc; - break; - case 4: - case 5: - cntr_marked_events |= (unit == 0xd) << pmc; - break; - case 6: - if (psel == 0x64) - cntr_marked_events |= (pmc >= 2) << pmc; - break; - case 8: - cntr_marked_events |= (unit == 0xd) << pmc; - break; - } - } - return cntr_marked_events; -} static int power4_reg_setup(struct op_counter_config *ctr, struct op_system_config *sys, @@ -109,23 +47,6 @@ static int power4_reg_setup(struct op_counter_config *ctr, mmcr1_val = sys->mmcr1; mmcra_val = sys->mmcra; - /* Power 7+ and newer architectures: - * Determine which counter events in the group (the group of events is - * specified by the bit settings in the MMCR1 register) are marked - * events for use in the interrupt handler. Do the calculation once - * before OProfile starts. Information is used in the interrupt - * handler. Starting with Power 7+ we only record the sample for - * marked events if the SIAR valid bit is set. For non marked events - * the sample is always recorded. - */ - if (pvr_version_is(PVR_POWER7p)) - cntr_marked_events = power7_marked_instr_event(mmcr1_val); - else - cntr_marked_events = 0; /* For older processors, set the bit map - * to zero so the sample will always be - * be recorded. - */ - for (i = 0; i < cur_cpu_spec->num_pmcs; ++i) reset_value[i] = 0x80000000UL - ctr[i].count; @@ -140,10 +61,10 @@ static int power4_reg_setup(struct op_counter_config *ctr, else mmcr0_val |= MMCR0_PROBLEM_DISABLE; - if (pvr_version_is(PVR_POWER4) || pvr_version_is(PVR_POWER4p) || - pvr_version_is(PVR_970) || pvr_version_is(PVR_970FX) || - pvr_version_is(PVR_970MP) || pvr_version_is(PVR_970GX) || - pvr_version_is(PVR_POWER5) || pvr_version_is(PVR_POWER5p)) + if (__is_processor(PV_POWER4) || __is_processor(PV_POWER4p) || + __is_processor(PV_970) || __is_processor(PV_970FX) || + __is_processor(PV_970MP) || __is_processor(PV_970GX) || + __is_processor(PV_POWER5) || __is_processor(PV_POWER5p)) use_slot_nums = 1; return 0; @@ -163,9 +84,9 @@ extern void ppc_enable_pmcs(void); */ static inline int mmcra_must_set_sample(void) { - if (pvr_version_is(PVR_POWER4) || pvr_version_is(PVR_POWER4p) || - pvr_version_is(PVR_970) || pvr_version_is(PVR_970FX) || - pvr_version_is(PVR_970MP) || pvr_version_is(PVR_970GX)) + if (__is_processor(PV_POWER4) || __is_processor(PV_POWER4p) || + __is_processor(PV_970) || __is_processor(PV_970FX) || + __is_processor(PV_970MP) || __is_processor(PV_970GX)) return 1; return 0; @@ -355,7 +276,7 @@ static bool pmc_overflow(unsigned long val) * PMCs because a user might set a period of less than 256 and we * don't want to mistakenly reset them. */ - if (pvr_version_is(PVR_POWER7) && ((0x80000000 - val) <= 256)) + if (__is_processor(PV_POWER7) && ((0x80000000 - val) <= 256)) return true; return false; @@ -370,7 +291,6 @@ static void power4_handle_interrupt(struct pt_regs *regs, int i; unsigned int mmcr0; unsigned long mmcra; - bool siar_valid = false; mmcra = mfspr(SPRN_MMCRA); @@ -380,29 +300,11 @@ static void power4_handle_interrupt(struct pt_regs *regs, /* set the PMM bit (see comment below) */ mtmsrd(mfmsr() | MSR_PMM); - /* Check that the SIAR valid bit in MMCRA is set to 1. */ - if ((mmcra & MMCRA_SIAR_VALID_MASK) == MMCRA_SIAR_VALID_MASK) - siar_valid = true; - for (i = 0; i < cur_cpu_spec->num_pmcs; ++i) { val = classic_ctr_read(i); if (pmc_overflow(val)) { if (oprofile_running && ctr[i].enabled) { - /* Power 7+ and newer architectures: - * If the event is a marked event, then only - * save the sample if the SIAR valid bit is - * set. If the event is not marked, then - * always save the sample. - * Note, the Sample enable bit in the MMCRA - * register must be set to 1 if the group - * contains a marked event. - */ - if ((siar_valid && - (cntr_marked_events & (1 << i))) - || !(cntr_marked_events & (1 << i))) - oprofile_add_ext_sample(pc, regs, i, - is_kernel); - + oprofile_add_ext_sample(pc, regs, i, is_kernel); classic_ctr_write(i, reset_value[i]); } else { classic_ctr_write(i, 0); diff --git a/trunk/arch/powerpc/perf/core-book3s.c b/trunk/arch/powerpc/perf/core-book3s.c index 0db88f501f91..7cd2dbd6e4c4 100644 --- a/trunk/arch/powerpc/perf/core-book3s.c +++ b/trunk/arch/powerpc/perf/core-book3s.c @@ -82,11 +82,6 @@ static inline int perf_intr_is_nmi(struct pt_regs *regs) return 0; } -static inline int siar_valid(struct pt_regs *regs) -{ - return 1; -} - #endif /* CONFIG_PPC32 */ /* @@ -111,20 +106,14 @@ static inline unsigned long perf_ip_adjust(struct pt_regs *regs) * If we're not doing instruction sampling, give them the SDAR * (sampled data address). If we are doing instruction sampling, then * only give them the SDAR if it corresponds to the instruction - * pointed to by SIAR; this is indicated by the [POWER6_]MMCRA_SDSYNC or - * the [POWER7P_]MMCRA_SDAR_VALID bit in MMCRA. + * pointed to by SIAR; this is indicated by the [POWER6_]MMCRA_SDSYNC + * bit in MMCRA. */ static inline void perf_get_data_addr(struct pt_regs *regs, u64 *addrp) { unsigned long mmcra = regs->dsisr; - unsigned long sdsync; - - if (ppmu->flags & PPMU_SIAR_VALID) - sdsync = POWER7P_MMCRA_SDAR_VALID; - else if (ppmu->flags & PPMU_ALT_SIPR) - sdsync = POWER6_MMCRA_SDSYNC; - else - sdsync = MMCRA_SDSYNC; + unsigned long sdsync = (ppmu->flags & PPMU_ALT_SIPR) ? + POWER6_MMCRA_SDSYNC : MMCRA_SDSYNC; if (!(mmcra & MMCRA_SAMPLE_ENABLE) || (mmcra & sdsync)) *addrp = mfspr(SPRN_SDAR); @@ -241,24 +230,6 @@ static inline int perf_intr_is_nmi(struct pt_regs *regs) return !regs->softe; } -/* - * On processors like P7+ that have the SIAR-Valid bit, marked instructions - * must be sampled only if the SIAR-valid bit is set. - * - * For unmarked instructions and for processors that don't have the SIAR-Valid - * bit, assume that SIAR is valid. - */ -static inline int siar_valid(struct pt_regs *regs) -{ - unsigned long mmcra = regs->dsisr; - int marked = mmcra & MMCRA_SAMPLE_ENABLE; - - if ((ppmu->flags & PPMU_SIAR_VALID) && marked) - return mmcra & POWER7P_MMCRA_SIAR_VALID; - - return 1; -} - #endif /* CONFIG_PPC64 */ static void perf_event_interrupt(struct pt_regs *regs); @@ -1320,7 +1291,6 @@ struct pmu power_pmu = { .event_idx = power_pmu_event_idx, }; - /* * A counter has overflowed; update its count and record * things if requested. Note that interrupts are hard-disabled @@ -1354,7 +1324,7 @@ static void record_and_restart(struct perf_event *event, unsigned long val, left += period; if (left <= 0) left = period; - record = siar_valid(regs); + record = 1; event->hw.last_period = event->hw.sample_period; } if (left < 0x80000000LL) @@ -1404,10 +1374,8 @@ unsigned long perf_instruction_pointer(struct pt_regs *regs) { unsigned long use_siar = regs->result; - if (use_siar && siar_valid(regs)) + if (use_siar) return mfspr(SPRN_SIAR) + perf_ip_adjust(regs); - else if (use_siar) - return 0; // no valid instruction pointer else return regs->nip; } @@ -1428,7 +1396,7 @@ static bool pmc_overflow(unsigned long val) * PMCs because a user might set a period of less than 256 and we * don't want to mistakenly reset them. */ - if (pvr_version_is(PVR_POWER7) && ((0x80000000 - val) <= 256)) + if (__is_processor(PV_POWER7) && ((0x80000000 - val) <= 256)) return true; return false; diff --git a/trunk/arch/powerpc/perf/power7-pmu.c b/trunk/arch/powerpc/perf/power7-pmu.c index 441af08edf43..1251e4d7e262 100644 --- a/trunk/arch/powerpc/perf/power7-pmu.c +++ b/trunk/arch/powerpc/perf/power7-pmu.c @@ -373,9 +373,6 @@ static int __init init_power7_pmu(void) strcmp(cur_cpu_spec->oprofile_cpu_type, "ppc64/power7")) return -ENODEV; - if (pvr_version_is(PVR_POWER7p)) - power7_pmu.flags |= PPMU_SIAR_VALID; - return register_power_pmu(&power7_pmu); } diff --git a/trunk/arch/powerpc/platforms/40x/ppc40x_simple.c b/trunk/arch/powerpc/platforms/40x/ppc40x_simple.c index 969dddcf3320..97612068fae3 100644 --- a/trunk/arch/powerpc/platforms/40x/ppc40x_simple.c +++ b/trunk/arch/powerpc/platforms/40x/ppc40x_simple.c @@ -50,7 +50,7 @@ machine_device_initcall(ppc40x_simple, ppc40x_device_probe); * Again, if your board needs to do things differently then create a * board.c file for it rather than adding it to this list. */ -static const char * const board[] __initconst = { +static const char *board[] __initdata = { "amcc,acadia", "amcc,haleakala", "amcc,kilauea", diff --git a/trunk/arch/powerpc/platforms/44x/currituck.c b/trunk/arch/powerpc/platforms/44x/currituck.c index 6bd89a0e0dea..9f6c33d63a42 100644 --- a/trunk/arch/powerpc/platforms/44x/currituck.c +++ b/trunk/arch/powerpc/platforms/44x/currituck.c @@ -21,6 +21,7 @@ */ #include +#include #include #include #include @@ -158,8 +159,13 @@ static void __init ppc47x_setup_arch(void) /* No need to check the DMA config as we /know/ our windows are all of * RAM. Lets hope that doesn't change */ - swiotlb_detect_4g(); - +#ifdef CONFIG_SWIOTLB + if ((memblock_end_of_DRAM() - 1) > 0xffffffff) { + ppc_swiotlb_enable = 1; + set_pci_dma_ops(&swiotlb_dma_ops); + ppc_md.pci_dma_dev_setup = pci_dma_dev_setup_swiotlb; + } +#endif ppc47x_smp_init(); } diff --git a/trunk/arch/powerpc/platforms/512x/Kconfig b/trunk/arch/powerpc/platforms/512x/Kconfig index b62508b113db..c16999802ecf 100644 --- a/trunk/arch/powerpc/platforms/512x/Kconfig +++ b/trunk/arch/powerpc/platforms/512x/Kconfig @@ -2,7 +2,6 @@ config PPC_MPC512x bool "512x-based boards" depends on 6xx select FSL_SOC - select FB_FSL_DIU select IPIC select PPC_CLOCK select PPC_PCI_CHOICE diff --git a/trunk/arch/powerpc/platforms/512x/clock.c b/trunk/arch/powerpc/platforms/512x/clock.c index 9f771e05457c..1d8700ff60b0 100644 --- a/trunk/arch/powerpc/platforms/512x/clock.c +++ b/trunk/arch/powerpc/platforms/512x/clock.c @@ -54,16 +54,14 @@ static DEFINE_MUTEX(clocks_mutex); static struct clk *mpc5121_clk_get(struct device *dev, const char *id) { struct clk *p, *clk = ERR_PTR(-ENOENT); - int dev_match; - int id_match; + int dev_match = 0; + int id_match = 0; if (dev == NULL || id == NULL) return clk; mutex_lock(&clocks_mutex); list_for_each_entry(p, &clocks, node) { - dev_match = id_match = 0; - if (dev == p->dev) dev_match++; if (strcmp(id, p->name) == 0) diff --git a/trunk/arch/powerpc/platforms/512x/mpc5121_generic.c b/trunk/arch/powerpc/platforms/512x/mpc5121_generic.c index ca1ca6669990..926731f1ff01 100644 --- a/trunk/arch/powerpc/platforms/512x/mpc5121_generic.c +++ b/trunk/arch/powerpc/platforms/512x/mpc5121_generic.c @@ -26,7 +26,7 @@ /* * list of supported boards */ -static const char * const board[] __initconst = { +static const char *board[] __initdata = { "prt,prtlvt", NULL }; diff --git a/trunk/arch/powerpc/platforms/512x/mpc512x_shared.c b/trunk/arch/powerpc/platforms/512x/mpc512x_shared.c index 1650e090ef3a..cfe958e94e1e 100644 --- a/trunk/arch/powerpc/platforms/512x/mpc512x_shared.c +++ b/trunk/arch/powerpc/platforms/512x/mpc512x_shared.c @@ -191,6 +191,8 @@ mpc512x_valid_monitor_port(enum fsl_diu_monitor_port port) static struct fsl_diu_shared_fb __attribute__ ((__aligned__(8))) diu_shared_fb; +#if defined(CONFIG_FB_FSL_DIU) || \ + defined(CONFIG_FB_FSL_DIU_MODULE) static inline void mpc512x_free_bootmem(struct page *page) { __ClearPageReserved(page); @@ -218,6 +220,7 @@ void mpc512x_release_bootmem(void) } diu_ops.release_bootmem = NULL; } +#endif /* * Check if DIU was pre-initialized. If so, perform steps @@ -320,12 +323,15 @@ void __init mpc512x_setup_diu(void) } } +#if defined(CONFIG_FB_FSL_DIU) || \ + defined(CONFIG_FB_FSL_DIU_MODULE) diu_ops.get_pixel_format = mpc512x_get_pixel_format; diu_ops.set_gamma_table = mpc512x_set_gamma_table; diu_ops.set_monitor_port = mpc512x_set_monitor_port; diu_ops.set_pixel_clock = mpc512x_set_pixel_clock; diu_ops.valid_monitor_port = mpc512x_valid_monitor_port; diu_ops.release_bootmem = mpc512x_release_bootmem; +#endif } void __init mpc512x_init_IRQ(void) diff --git a/trunk/arch/powerpc/platforms/52xx/lite5200.c b/trunk/arch/powerpc/platforms/52xx/lite5200.c index 448d862bcf3d..01ffa64d2aa7 100644 --- a/trunk/arch/powerpc/platforms/52xx/lite5200.c +++ b/trunk/arch/powerpc/platforms/52xx/lite5200.c @@ -172,7 +172,7 @@ static void __init lite5200_setup_arch(void) mpc52xx_setup_pci(); } -static const char * const board[] __initconst = { +static const char *board[] __initdata = { "fsl,lite5200", "fsl,lite5200b", NULL, diff --git a/trunk/arch/powerpc/platforms/52xx/media5200.c b/trunk/arch/powerpc/platforms/52xx/media5200.c index 070d315dd6cd..17d91b7da315 100644 --- a/trunk/arch/powerpc/platforms/52xx/media5200.c +++ b/trunk/arch/powerpc/platforms/52xx/media5200.c @@ -232,7 +232,7 @@ static void __init media5200_setup_arch(void) } /* list of the supported boards */ -static const char * const board[] __initconst = { +static const char *board[] __initdata = { "fsl,media5200", NULL }; diff --git a/trunk/arch/powerpc/platforms/52xx/mpc5200_simple.c b/trunk/arch/powerpc/platforms/52xx/mpc5200_simple.c index 9cf36020cf0d..c0aa04068d69 100644 --- a/trunk/arch/powerpc/platforms/52xx/mpc5200_simple.c +++ b/trunk/arch/powerpc/platforms/52xx/mpc5200_simple.c @@ -52,7 +52,6 @@ static void __init mpc5200_simple_setup_arch(void) static const char *board[] __initdata = { "anonymous,a4m072", "anon,charon", - "ifm,o2d", "intercontrol,digsy-mtc", "manroland,mucmc52", "manroland,uc101", diff --git a/trunk/arch/powerpc/platforms/52xx/mpc52xx_lpbfifo.c b/trunk/arch/powerpc/platforms/52xx/mpc52xx_lpbfifo.c index 2351f9e0fb6f..d61fb1c0c1a0 100644 --- a/trunk/arch/powerpc/platforms/52xx/mpc52xx_lpbfifo.c +++ b/trunk/arch/powerpc/platforms/52xx/mpc52xx_lpbfifo.c @@ -170,8 +170,7 @@ static void mpc52xx_lpbfifo_kick(struct mpc52xx_lpbfifo_request *req) out_be32(lpbfifo.regs + LPBFIFO_REG_CONTROL, bit_fields); /* Kick it off */ - if (!lpbfifo.req->defer_xfer_start) - out_8(lpbfifo.regs + LPBFIFO_REG_PACKET_SIZE, 0x01); + out_8(lpbfifo.regs + LPBFIFO_REG_PACKET_SIZE, 0x01); if (dma) bcom_enable(lpbfifo.bcom_cur_task); } @@ -422,38 +421,6 @@ int mpc52xx_lpbfifo_submit(struct mpc52xx_lpbfifo_request *req) } EXPORT_SYMBOL(mpc52xx_lpbfifo_submit); -int mpc52xx_lpbfifo_start_xfer(struct mpc52xx_lpbfifo_request *req) -{ - unsigned long flags; - - if (!lpbfifo.regs) - return -ENODEV; - - spin_lock_irqsave(&lpbfifo.lock, flags); - - /* - * If the req pointer is already set and a transfer was - * started on submit, then this transfer is in progress - */ - if (lpbfifo.req && !lpbfifo.req->defer_xfer_start) { - spin_unlock_irqrestore(&lpbfifo.lock, flags); - return -EBUSY; - } - - /* - * If the req was previously submitted but not - * started, start it now - */ - if (lpbfifo.req && lpbfifo.req == req && - lpbfifo.req->defer_xfer_start) { - out_8(lpbfifo.regs + LPBFIFO_REG_PACKET_SIZE, 0x01); - } - - spin_unlock_irqrestore(&lpbfifo.lock, flags); - return 0; -} -EXPORT_SYMBOL(mpc52xx_lpbfifo_start_xfer); - void mpc52xx_lpbfifo_abort(struct mpc52xx_lpbfifo_request *req) { unsigned long flags; diff --git a/trunk/arch/powerpc/platforms/83xx/mpc837x_rdb.c b/trunk/arch/powerpc/platforms/83xx/mpc837x_rdb.c index eca1f0960fff..16c9c9cbbb7f 100644 --- a/trunk/arch/powerpc/platforms/83xx/mpc837x_rdb.c +++ b/trunk/arch/powerpc/platforms/83xx/mpc837x_rdb.c @@ -60,7 +60,7 @@ static void __init mpc837x_rdb_setup_arch(void) machine_device_initcall(mpc837x_rdb, mpc83xx_declare_of_platform_devices); -static const char * const board[] __initconst = { +static const char *board[] __initdata = { "fsl,mpc8377rdb", "fsl,mpc8378rdb", "fsl,mpc8379rdb", diff --git a/trunk/arch/powerpc/platforms/85xx/Kconfig b/trunk/arch/powerpc/platforms/85xx/Kconfig index 02d02a09942d..159c01e91463 100644 --- a/trunk/arch/powerpc/platforms/85xx/Kconfig +++ b/trunk/arch/powerpc/platforms/85xx/Kconfig @@ -104,13 +104,6 @@ config P1022_DS help This option enables support for the Freescale P1022DS reference board. -config P1022_RDK - bool "Freescale / iVeia P1022 RDK" - select DEFAULT_UIMAGE - help - This option enables support for the Freescale / iVeia P1022RDK - reference board. - config P1023_RDS bool "Freescale P1023 RDS" select DEFAULT_UIMAGE @@ -261,20 +254,6 @@ config P5020_DS help This option enables support for the P5020 DS board -config P5040_DS - bool "Freescale P5040 DS" - select DEFAULT_UIMAGE - select E500 - select PPC_E500MC - select PHYS_64BIT - select SWIOTLB - select ARCH_REQUIRE_GPIOLIB - select GPIO_MPC8XXX - select HAS_RAPIDIO - select PPC_EPAPR_HV_PIC - help - This option enables support for the P5040 DS board - config PPC_QEMU_E500 bool "QEMU generic e500 platform" depends on EXPERIMENTAL diff --git a/trunk/arch/powerpc/platforms/85xx/Makefile b/trunk/arch/powerpc/platforms/85xx/Makefile index 76f679cb04a0..3dfe81175036 100644 --- a/trunk/arch/powerpc/platforms/85xx/Makefile +++ b/trunk/arch/powerpc/platforms/85xx/Makefile @@ -15,13 +15,11 @@ obj-$(CONFIG_MPC85xx_MDS) += mpc85xx_mds.o obj-$(CONFIG_MPC85xx_RDB) += mpc85xx_rdb.o obj-$(CONFIG_P1010_RDB) += p1010rdb.o obj-$(CONFIG_P1022_DS) += p1022_ds.o -obj-$(CONFIG_P1022_RDK) += p1022_rdk.o obj-$(CONFIG_P1023_RDS) += p1023_rds.o obj-$(CONFIG_P2041_RDB) += p2041_rdb.o corenet_ds.o obj-$(CONFIG_P3041_DS) += p3041_ds.o corenet_ds.o obj-$(CONFIG_P4080_DS) += p4080_ds.o corenet_ds.o obj-$(CONFIG_P5020_DS) += p5020_ds.o corenet_ds.o -obj-$(CONFIG_P5040_DS) += p5040_ds.o corenet_ds.o obj-$(CONFIG_STX_GP3) += stx_gp3.o obj-$(CONFIG_TQM85xx) += tqm85xx.o obj-$(CONFIG_SBC8548) += sbc8548.o diff --git a/trunk/arch/powerpc/platforms/85xx/common.c b/trunk/arch/powerpc/platforms/85xx/common.c index d0861a0d8360..67dac22b4363 100644 --- a/trunk/arch/powerpc/platforms/85xx/common.c +++ b/trunk/arch/powerpc/platforms/85xx/common.c @@ -27,16 +27,6 @@ static struct of_device_id __initdata mpc85xx_common_ids[] = { { .compatible = "fsl,mpc8548-guts", }, /* Probably unnecessary? */ { .compatible = "gpio-leds", }, - /* For all PCI controllers */ - { .compatible = "fsl,mpc8540-pci", }, - { .compatible = "fsl,mpc8548-pcie", }, - { .compatible = "fsl,p1022-pcie", }, - { .compatible = "fsl,p1010-pcie", }, - { .compatible = "fsl,p1023-pcie", }, - { .compatible = "fsl,p4080-pcie", }, - { .compatible = "fsl,qoriq-pcie-v2.4", }, - { .compatible = "fsl,qoriq-pcie-v2.3", }, - { .compatible = "fsl,qoriq-pcie-v2.2", }, {}, }; diff --git a/trunk/arch/powerpc/platforms/85xx/corenet_ds.c b/trunk/arch/powerpc/platforms/85xx/corenet_ds.c index ed69c9250717..925b02874233 100644 --- a/trunk/arch/powerpc/platforms/85xx/corenet_ds.c +++ b/trunk/arch/powerpc/platforms/85xx/corenet_ds.c @@ -16,6 +16,7 @@ #include #include #include +#include #include #include @@ -51,16 +52,37 @@ void __init corenet_ds_pic_init(void) */ void __init corenet_ds_setup_arch(void) { +#ifdef CONFIG_PCI + struct device_node *np; + struct pci_controller *hose; +#endif + dma_addr_t max = 0xffffffff; + mpc85xx_smp_init(); -#if defined(CONFIG_PCI) && defined(CONFIG_PPC64) +#ifdef CONFIG_PCI + for_each_node_by_type(np, "pci") { + if (of_device_is_compatible(np, "fsl,p4080-pcie") || + of_device_is_compatible(np, "fsl,qoriq-pcie-v2.2")) { + fsl_add_bridge(np, 0); + hose = pci_find_hose_for_OF_device(np); + max = min(max, hose->dma_window_base_cur + + hose->dma_window_size); + } + } + +#ifdef CONFIG_PPC64 pci_devs_phb_init(); #endif +#endif - fsl_pci_assign_primary(); - - swiotlb_detect_4g(); - +#ifdef CONFIG_SWIOTLB + if ((memblock_end_of_DRAM() - 1) > max) { + ppc_swiotlb_enable = 1; + set_pci_dma_ops(&swiotlb_dma_ops); + ppc_md.pci_dma_dev_setup = pci_dma_dev_setup_swiotlb; + } +#endif pr_info("%s board from Freescale Semiconductor\n", ppc_md.name); } @@ -77,12 +99,6 @@ static const struct of_device_id of_device_ids[] __devinitconst = { { .compatible = "fsl,qoriq-pcie-v2.2", }, - { - .compatible = "fsl,qoriq-pcie-v2.3", - }, - { - .compatible = "fsl,qoriq-pcie-v2.4", - }, /* The following two are for the Freescale hypervisor */ { .name = "hypervisor", diff --git a/trunk/arch/powerpc/platforms/85xx/ge_imp3a.c b/trunk/arch/powerpc/platforms/85xx/ge_imp3a.c index e6285ae6f423..b6a728b0a8ca 100644 --- a/trunk/arch/powerpc/platforms/85xx/ge_imp3a.c +++ b/trunk/arch/powerpc/platforms/85xx/ge_imp3a.c @@ -22,6 +22,7 @@ #include #include #include +#include #include #include @@ -83,39 +84,53 @@ void __init ge_imp3a_pic_init(void) of_node_put(cascade_node); } -static void ge_imp3a_pci_assign_primary(void) +#ifdef CONFIG_PCI +static int primary_phb_addr; +#endif /* CONFIG_PCI */ + +/* + * Setup the architecture + */ +static void __init ge_imp3a_setup_arch(void) { + struct device_node *regs; #ifdef CONFIG_PCI struct device_node *np; - struct resource rsrc; + struct pci_controller *hose; +#endif + dma_addr_t max = 0xffffffff; + if (ppc_md.progress) + ppc_md.progress("ge_imp3a_setup_arch()", 0); + +#ifdef CONFIG_PCI for_each_node_by_type(np, "pci") { if (of_device_is_compatible(np, "fsl,mpc8540-pci") || of_device_is_compatible(np, "fsl,mpc8548-pcie") || of_device_is_compatible(np, "fsl,p2020-pcie")) { + struct resource rsrc; of_address_to_resource(np, 0, &rsrc); - if ((rsrc.start & 0xfffff) == 0x9000) - fsl_pci_primary = np; + if ((rsrc.start & 0xfffff) == primary_phb_addr) + fsl_add_bridge(np, 1); + else + fsl_add_bridge(np, 0); + + hose = pci_find_hose_for_OF_device(np); + max = min(max, hose->dma_window_base_cur + + hose->dma_window_size); } } #endif -} - -/* - * Setup the architecture - */ -static void __init ge_imp3a_setup_arch(void) -{ - struct device_node *regs; - - if (ppc_md.progress) - ppc_md.progress("ge_imp3a_setup_arch()", 0); mpc85xx_smp_init(); - ge_imp3a_pci_assign_primary(); - - swiotlb_detect_4g(); +#ifdef CONFIG_SWIOTLB + if ((memblock_end_of_DRAM() - 1) > max) { + ppc_swiotlb_enable = 1; + set_pci_dma_ops(&swiotlb_dma_ops); + ppc_md.pci_dma_dev_setup = pci_dma_dev_setup_swiotlb; + } +#endif /* Remap basic board registers */ regs = of_find_compatible_node(NULL, NULL, "ge,imp3a-fpga-regs"); @@ -200,10 +215,17 @@ static int __init ge_imp3a_probe(void) { unsigned long root = of_get_flat_dt_root(); - return of_flat_dt_is_compatible(root, "ge,IMP3A"); + if (of_flat_dt_is_compatible(root, "ge,IMP3A")) { +#ifdef CONFIG_PCI + primary_phb_addr = 0x9000; +#endif + return 1; + } + + return 0; } -machine_arch_initcall(ge_imp3a, mpc85xx_common_publish_devices); +machine_device_initcall(ge_imp3a, mpc85xx_common_publish_devices); machine_arch_initcall(ge_imp3a, swiotlb_setup_bus_notifier); diff --git a/trunk/arch/powerpc/platforms/85xx/mpc8536_ds.c b/trunk/arch/powerpc/platforms/85xx/mpc8536_ds.c index 15ce4b55f117..767c7cf18a9c 100644 --- a/trunk/arch/powerpc/platforms/85xx/mpc8536_ds.c +++ b/trunk/arch/powerpc/platforms/85xx/mpc8536_ds.c @@ -17,6 +17,7 @@ #include #include #include +#include #include #include @@ -45,17 +46,46 @@ void __init mpc8536_ds_pic_init(void) */ static void __init mpc8536_ds_setup_arch(void) { +#ifdef CONFIG_PCI + struct device_node *np; + struct pci_controller *hose; +#endif + dma_addr_t max = 0xffffffff; + if (ppc_md.progress) ppc_md.progress("mpc8536_ds_setup_arch()", 0); - fsl_pci_assign_primary(); +#ifdef CONFIG_PCI + for_each_node_by_type(np, "pci") { + if (of_device_is_compatible(np, "fsl,mpc8540-pci") || + of_device_is_compatible(np, "fsl,mpc8548-pcie")) { + struct resource rsrc; + of_address_to_resource(np, 0, &rsrc); + if ((rsrc.start & 0xfffff) == 0x8000) + fsl_add_bridge(np, 1); + else + fsl_add_bridge(np, 0); + + hose = pci_find_hose_for_OF_device(np); + max = min(max, hose->dma_window_base_cur + + hose->dma_window_size); + } + } + +#endif - swiotlb_detect_4g(); +#ifdef CONFIG_SWIOTLB + if ((memblock_end_of_DRAM() - 1) > max) { + ppc_swiotlb_enable = 1; + set_pci_dma_ops(&swiotlb_dma_ops); + ppc_md.pci_dma_dev_setup = pci_dma_dev_setup_swiotlb; + } +#endif printk("MPC8536 DS board from Freescale Semiconductor\n"); } -machine_arch_initcall(mpc8536_ds, mpc85xx_common_publish_devices); +machine_device_initcall(mpc8536_ds, mpc85xx_common_publish_devices); machine_arch_initcall(mpc8536_ds, swiotlb_setup_bus_notifier); diff --git a/trunk/arch/powerpc/platforms/85xx/mpc85xx_ads.c b/trunk/arch/powerpc/platforms/85xx/mpc85xx_ads.c index 7d12a19aa7ee..29ee8fcd75a2 100644 --- a/trunk/arch/powerpc/platforms/85xx/mpc85xx_ads.c +++ b/trunk/arch/powerpc/platforms/85xx/mpc85xx_ads.c @@ -137,6 +137,10 @@ static void __init init_ioports(void) static void __init mpc85xx_ads_setup_arch(void) { +#ifdef CONFIG_PCI + struct device_node *np; +#endif + if (ppc_md.progress) ppc_md.progress("mpc85xx_ads_setup_arch()", 0); @@ -146,10 +150,11 @@ static void __init mpc85xx_ads_setup_arch(void) #endif #ifdef CONFIG_PCI + for_each_compatible_node(np, "pci", "fsl,mpc8540-pci") + fsl_add_bridge(np, 1); + ppc_md.pci_exclude_device = mpc85xx_exclude_device; #endif - - fsl_pci_assign_primary(); } static void mpc85xx_ads_show_cpuinfo(struct seq_file *m) @@ -168,7 +173,7 @@ static void mpc85xx_ads_show_cpuinfo(struct seq_file *m) seq_printf(m, "PLL setting\t: 0x%x\n", ((phid1 >> 24) & 0x3f)); } -machine_arch_initcall(mpc85xx_ads, mpc85xx_common_publish_devices); +machine_device_initcall(mpc85xx_ads, mpc85xx_common_publish_devices); /* * Called very early, device-tree isn't unflattened diff --git a/trunk/arch/powerpc/platforms/85xx/mpc85xx_cds.c b/trunk/arch/powerpc/platforms/85xx/mpc85xx_cds.c index c474505ad0d0..11156fb53d83 100644 --- a/trunk/arch/powerpc/platforms/85xx/mpc85xx_cds.c +++ b/trunk/arch/powerpc/platforms/85xx/mpc85xx_cds.c @@ -276,33 +276,6 @@ machine_device_initcall(mpc85xx_cds, mpc85xx_cds_8259_attach); #endif /* CONFIG_PPC_I8259 */ -static void mpc85xx_cds_pci_assign_primary(void) -{ -#ifdef CONFIG_PCI - struct device_node *np; - - if (fsl_pci_primary) - return; - - /* - * MPC85xx_CDS has ISA bridge but unfortunately there is no - * isa node in device tree. We now looking for i8259 node as - * a workaround for such a broken device tree. This routine - * is for complying to all device trees. - */ - np = of_find_node_by_name(NULL, "i8259"); - while ((fsl_pci_primary = of_get_parent(np))) { - of_node_put(np); - np = fsl_pci_primary; - - if ((of_device_is_compatible(np, "fsl,mpc8540-pci") || - of_device_is_compatible(np, "fsl,mpc8548-pcie")) && - of_device_is_available(np)) - return; - } -#endif -} - /* * Setup the architecture */ @@ -336,12 +309,21 @@ static void __init mpc85xx_cds_setup_arch(void) } #ifdef CONFIG_PCI + for_each_node_by_type(np, "pci") { + if (of_device_is_compatible(np, "fsl,mpc8540-pci") || + of_device_is_compatible(np, "fsl,mpc8548-pcie")) { + struct resource rsrc; + of_address_to_resource(np, 0, &rsrc); + if ((rsrc.start & 0xfffff) == 0x8000) + fsl_add_bridge(np, 1); + else + fsl_add_bridge(np, 0); + } + } + ppc_md.pci_irq_fixup = mpc85xx_cds_pci_irq_fixup; ppc_md.pci_exclude_device = mpc85xx_exclude_device; #endif - - mpc85xx_cds_pci_assign_primary(); - fsl_pci_assign_primary(); } static void mpc85xx_cds_show_cpuinfo(struct seq_file *m) @@ -373,7 +355,7 @@ static int __init mpc85xx_cds_probe(void) return of_flat_dt_is_compatible(root, "MPC85xxCDS"); } -machine_arch_initcall(mpc85xx_cds, mpc85xx_common_publish_devices); +machine_device_initcall(mpc85xx_cds, mpc85xx_common_publish_devices); define_machine(mpc85xx_cds) { .name = "MPC85xx CDS", diff --git a/trunk/arch/powerpc/platforms/85xx/mpc85xx_ds.c b/trunk/arch/powerpc/platforms/85xx/mpc85xx_ds.c index 9ebb91ed96a3..6d3265fe7718 100644 --- a/trunk/arch/powerpc/platforms/85xx/mpc85xx_ds.c +++ b/trunk/arch/powerpc/platforms/85xx/mpc85xx_ds.c @@ -20,6 +20,7 @@ #include #include #include +#include #include #include @@ -128,11 +129,13 @@ static int mpc85xx_exclude_device(struct pci_controller *hose, } #endif /* CONFIG_PCI */ -static void __init mpc85xx_ds_uli_init(void) +static void __init mpc85xx_ds_pci_init(void) { #ifdef CONFIG_PCI struct device_node *node; + fsl_pci_init(); + /* See if we have a ULI under the primary */ node = of_find_node_by_name(NULL, "uli1575"); @@ -156,9 +159,7 @@ static void __init mpc85xx_ds_setup_arch(void) if (ppc_md.progress) ppc_md.progress("mpc85xx_ds_setup_arch()", 0); - swiotlb_detect_4g(); - fsl_pci_assign_primary(); - mpc85xx_ds_uli_init(); + mpc85xx_ds_pci_init(); mpc85xx_smp_init(); printk("MPC85xx DS board from Freescale Semiconductor\n"); @@ -174,9 +175,9 @@ static int __init mpc8544_ds_probe(void) return !!of_flat_dt_is_compatible(root, "MPC8544DS"); } -machine_arch_initcall(mpc8544_ds, mpc85xx_common_publish_devices); -machine_arch_initcall(mpc8572_ds, mpc85xx_common_publish_devices); -machine_arch_initcall(p2020_ds, mpc85xx_common_publish_devices); +machine_device_initcall(mpc8544_ds, mpc85xx_common_publish_devices); +machine_device_initcall(mpc8572_ds, mpc85xx_common_publish_devices); +machine_device_initcall(p2020_ds, mpc85xx_common_publish_devices); machine_arch_initcall(mpc8544_ds, swiotlb_setup_bus_notifier); machine_arch_initcall(mpc8572_ds, swiotlb_setup_bus_notifier); diff --git a/trunk/arch/powerpc/platforms/85xx/mpc85xx_mds.c b/trunk/arch/powerpc/platforms/85xx/mpc85xx_mds.c index 8498f7323470..8e4b094c553b 100644 --- a/trunk/arch/powerpc/platforms/85xx/mpc85xx_mds.c +++ b/trunk/arch/powerpc/platforms/85xx/mpc85xx_mds.c @@ -327,16 +327,44 @@ static void __init mpc85xx_mds_qeic_init(void) { } static void __init mpc85xx_mds_setup_arch(void) { +#ifdef CONFIG_PCI + struct pci_controller *hose; + struct device_node *np; +#endif + dma_addr_t max = 0xffffffff; + if (ppc_md.progress) ppc_md.progress("mpc85xx_mds_setup_arch()", 0); +#ifdef CONFIG_PCI + for_each_node_by_type(np, "pci") { + if (of_device_is_compatible(np, "fsl,mpc8540-pci") || + of_device_is_compatible(np, "fsl,mpc8548-pcie")) { + struct resource rsrc; + of_address_to_resource(np, 0, &rsrc); + if ((rsrc.start & 0xfffff) == 0x8000) + fsl_add_bridge(np, 1); + else + fsl_add_bridge(np, 0); + + hose = pci_find_hose_for_OF_device(np); + max = min(max, hose->dma_window_base_cur + + hose->dma_window_size); + } + } +#endif + mpc85xx_smp_init(); mpc85xx_mds_qe_init(); - fsl_pci_assign_primary(); - - swiotlb_detect_4g(); +#ifdef CONFIG_SWIOTLB + if ((memblock_end_of_DRAM() - 1) > max) { + ppc_swiotlb_enable = 1; + set_pci_dma_ops(&swiotlb_dma_ops); + ppc_md.pci_dma_dev_setup = pci_dma_dev_setup_swiotlb; + } +#endif } @@ -381,9 +409,9 @@ static int __init mpc85xx_publish_devices(void) return mpc85xx_common_publish_devices(); } -machine_arch_initcall(mpc8568_mds, mpc85xx_publish_devices); -machine_arch_initcall(mpc8569_mds, mpc85xx_publish_devices); -machine_arch_initcall(p1021_mds, mpc85xx_common_publish_devices); +machine_device_initcall(mpc8568_mds, mpc85xx_publish_devices); +machine_device_initcall(mpc8569_mds, mpc85xx_publish_devices); +machine_device_initcall(p1021_mds, mpc85xx_common_publish_devices); machine_arch_initcall(mpc8568_mds, swiotlb_setup_bus_notifier); machine_arch_initcall(mpc8569_mds, swiotlb_setup_bus_notifier); diff --git a/trunk/arch/powerpc/platforms/85xx/mpc85xx_rdb.c b/trunk/arch/powerpc/platforms/85xx/mpc85xx_rdb.c index ede8771d6f02..1910fdcb75b2 100644 --- a/trunk/arch/powerpc/platforms/85xx/mpc85xx_rdb.c +++ b/trunk/arch/powerpc/platforms/85xx/mpc85xx_rdb.c @@ -86,16 +86,22 @@ void __init mpc85xx_rdb_pic_init(void) */ static void __init mpc85xx_rdb_setup_arch(void) { -#ifdef CONFIG_QUICC_ENGINE +#if defined(CONFIG_PCI) || defined(CONFIG_QUICC_ENGINE) struct device_node *np; #endif if (ppc_md.progress) ppc_md.progress("mpc85xx_rdb_setup_arch()", 0); - mpc85xx_smp_init(); +#ifdef CONFIG_PCI + for_each_node_by_type(np, "pci") { + if (of_device_is_compatible(np, "fsl,mpc8548-pcie")) + fsl_add_bridge(np, 0); + } - fsl_pci_assign_primary(); +#endif + + mpc85xx_smp_init(); #ifdef CONFIG_QUICC_ENGINE np = of_find_compatible_node(NULL, NULL, "fsl,qe"); @@ -155,15 +161,15 @@ static void __init mpc85xx_rdb_setup_arch(void) printk(KERN_INFO "MPC85xx RDB board from Freescale Semiconductor\n"); } -machine_arch_initcall(p2020_rdb, mpc85xx_common_publish_devices); -machine_arch_initcall(p2020_rdb_pc, mpc85xx_common_publish_devices); -machine_arch_initcall(p1020_mbg_pc, mpc85xx_common_publish_devices); -machine_arch_initcall(p1020_rdb, mpc85xx_common_publish_devices); -machine_arch_initcall(p1020_rdb_pc, mpc85xx_common_publish_devices); -machine_arch_initcall(p1020_utm_pc, mpc85xx_common_publish_devices); -machine_arch_initcall(p1021_rdb_pc, mpc85xx_common_publish_devices); -machine_arch_initcall(p1025_rdb, mpc85xx_common_publish_devices); -machine_arch_initcall(p1024_rdb, mpc85xx_common_publish_devices); +machine_device_initcall(p2020_rdb, mpc85xx_common_publish_devices); +machine_device_initcall(p2020_rdb_pc, mpc85xx_common_publish_devices); +machine_device_initcall(p1020_mbg_pc, mpc85xx_common_publish_devices); +machine_device_initcall(p1020_rdb, mpc85xx_common_publish_devices); +machine_device_initcall(p1020_rdb_pc, mpc85xx_common_publish_devices); +machine_device_initcall(p1020_utm_pc, mpc85xx_common_publish_devices); +machine_device_initcall(p1021_rdb_pc, mpc85xx_common_publish_devices); +machine_device_initcall(p1025_rdb, mpc85xx_common_publish_devices); +machine_device_initcall(p1024_rdb, mpc85xx_common_publish_devices); /* * Called very early, device-tree isn't unflattened diff --git a/trunk/arch/powerpc/platforms/85xx/p1010rdb.c b/trunk/arch/powerpc/platforms/85xx/p1010rdb.c index 0252961392d5..dbaf44354f0d 100644 --- a/trunk/arch/powerpc/platforms/85xx/p1010rdb.c +++ b/trunk/arch/powerpc/platforms/85xx/p1010rdb.c @@ -46,15 +46,25 @@ void __init p1010_rdb_pic_init(void) */ static void __init p1010_rdb_setup_arch(void) { +#ifdef CONFIG_PCI + struct device_node *np; +#endif + if (ppc_md.progress) ppc_md.progress("p1010_rdb_setup_arch()", 0); - fsl_pci_assign_primary(); +#ifdef CONFIG_PCI + for_each_node_by_type(np, "pci") { + if (of_device_is_compatible(np, "fsl,p1010-pcie")) + fsl_add_bridge(np, 0); + } + +#endif printk(KERN_INFO "P1010 RDB board from Freescale Semiconductor\n"); } -machine_arch_initcall(p1010_rdb, mpc85xx_common_publish_devices); +machine_device_initcall(p1010_rdb, mpc85xx_common_publish_devices); machine_arch_initcall(p1010_rdb, swiotlb_setup_bus_notifier); /* diff --git a/trunk/arch/powerpc/platforms/85xx/p1022_ds.c b/trunk/arch/powerpc/platforms/85xx/p1022_ds.c index 848a3e98e1c1..3c732acf331d 100644 --- a/trunk/arch/powerpc/platforms/85xx/p1022_ds.c +++ b/trunk/arch/powerpc/platforms/85xx/p1022_ds.c @@ -18,6 +18,7 @@ #include #include +#include #include #include #include @@ -506,9 +507,32 @@ early_param("video", early_video_setup); */ static void __init p1022_ds_setup_arch(void) { +#ifdef CONFIG_PCI + struct device_node *np; +#endif + dma_addr_t max = 0xffffffff; + if (ppc_md.progress) ppc_md.progress("p1022_ds_setup_arch()", 0); +#ifdef CONFIG_PCI + for_each_compatible_node(np, "pci", "fsl,p1022-pcie") { + struct resource rsrc; + struct pci_controller *hose; + + of_address_to_resource(np, 0, &rsrc); + + if ((rsrc.start & 0xfffff) == 0x8000) + fsl_add_bridge(np, 1); + else + fsl_add_bridge(np, 0); + + hose = pci_find_hose_for_OF_device(np); + max = min(max, hose->dma_window_base_cur + + hose->dma_window_size); + } +#endif + #if defined(CONFIG_FB_FSL_DIU) || defined(CONFIG_FB_FSL_DIU_MODULE) diu_ops.get_pixel_format = p1022ds_get_pixel_format; diu_ops.set_gamma_table = p1022ds_set_gamma_table; @@ -577,14 +601,18 @@ static void __init p1022_ds_setup_arch(void) mpc85xx_smp_init(); - fsl_pci_assign_primary(); - - swiotlb_detect_4g(); +#ifdef CONFIG_SWIOTLB + if ((memblock_end_of_DRAM() - 1) > max) { + ppc_swiotlb_enable = 1; + set_pci_dma_ops(&swiotlb_dma_ops); + ppc_md.pci_dma_dev_setup = pci_dma_dev_setup_swiotlb; + } +#endif pr_info("Freescale P1022 DS reference board\n"); } -machine_arch_initcall(p1022_ds, mpc85xx_common_publish_devices); +machine_device_initcall(p1022_ds, mpc85xx_common_publish_devices); machine_arch_initcall(p1022_ds, swiotlb_setup_bus_notifier); diff --git a/trunk/arch/powerpc/platforms/85xx/p1022_rdk.c b/trunk/arch/powerpc/platforms/85xx/p1022_rdk.c deleted file mode 100644 index 55ffa1cc380c..000000000000 --- a/trunk/arch/powerpc/platforms/85xx/p1022_rdk.c +++ /dev/null @@ -1,167 +0,0 @@ -/* - * P1022 RDK board specific routines - * - * Copyright 2012 Freescale Semiconductor, Inc. - * - * Author: Timur Tabi - * - * Based on p1022_ds.c - * - * 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. - */ - -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include "smp.h" - -#include "mpc85xx.h" - -#if defined(CONFIG_FB_FSL_DIU) || defined(CONFIG_FB_FSL_DIU_MODULE) - -/* DIU Pixel Clock bits of the CLKDVDR Global Utilities register */ -#define CLKDVDR_PXCKEN 0x80000000 -#define CLKDVDR_PXCKINV 0x10000000 -#define CLKDVDR_PXCKDLY 0x06000000 -#define CLKDVDR_PXCLK_MASK 0x00FF0000 - -/** - * p1022rdk_set_monitor_port: switch the output to a different monitor port - */ -static void p1022rdk_set_monitor_port(enum fsl_diu_monitor_port port) -{ - if (port != FSL_DIU_PORT_DVI) { - pr_err("p1022rdk: unsupported monitor port %i\n", port); - return; - } -} - -/** - * p1022rdk_set_pixel_clock: program the DIU's clock - * - * @pixclock: the wavelength, in picoseconds, of the clock - */ -void p1022rdk_set_pixel_clock(unsigned int pixclock) -{ - struct device_node *guts_np = NULL; - struct ccsr_guts __iomem *guts; - unsigned long freq; - u64 temp; - u32 pxclk; - - /* Map the global utilities registers. */ - guts_np = of_find_compatible_node(NULL, NULL, "fsl,p1022-guts"); - if (!guts_np) { - pr_err("p1022rdk: missing global utilties device node\n"); - return; - } - - guts = of_iomap(guts_np, 0); - of_node_put(guts_np); - if (!guts) { - pr_err("p1022rdk: could not map global utilties device\n"); - return; - } - - /* Convert pixclock from a wavelength to a frequency */ - temp = 1000000000000ULL; - do_div(temp, pixclock); - freq = temp; - - /* - * 'pxclk' is the ratio of the platform clock to the pixel clock. - * This number is programmed into the CLKDVDR register, and the valid - * range of values is 2-255. - */ - pxclk = DIV_ROUND_CLOSEST(fsl_get_sys_freq(), freq); - pxclk = clamp_t(u32, pxclk, 2, 255); - - /* Disable the pixel clock, and set it to non-inverted and no delay */ - clrbits32(&guts->clkdvdr, - CLKDVDR_PXCKEN | CLKDVDR_PXCKDLY | CLKDVDR_PXCLK_MASK); - - /* Enable the clock and set the pxclk */ - setbits32(&guts->clkdvdr, CLKDVDR_PXCKEN | (pxclk << 16)); - - iounmap(guts); -} - -/** - * p1022rdk_valid_monitor_port: set the monitor port for sysfs - */ -enum fsl_diu_monitor_port -p1022rdk_valid_monitor_port(enum fsl_diu_monitor_port port) -{ - return FSL_DIU_PORT_DVI; -} - -#endif - -void __init p1022_rdk_pic_init(void) -{ - struct mpic *mpic = mpic_alloc(NULL, 0, MPIC_BIG_ENDIAN | - MPIC_SINGLE_DEST_CPU, - 0, 256, " OpenPIC "); - BUG_ON(mpic == NULL); - mpic_init(mpic); -} - -/* - * Setup the architecture - */ -static void __init p1022_rdk_setup_arch(void) -{ - if (ppc_md.progress) - ppc_md.progress("p1022_rdk_setup_arch()", 0); - -#if defined(CONFIG_FB_FSL_DIU) || defined(CONFIG_FB_FSL_DIU_MODULE) - diu_ops.set_monitor_port = p1022rdk_set_monitor_port; - diu_ops.set_pixel_clock = p1022rdk_set_pixel_clock; - diu_ops.valid_monitor_port = p1022rdk_valid_monitor_port; -#endif - - mpc85xx_smp_init(); - - fsl_pci_assign_primary(); - - swiotlb_detect_4g(); - - pr_info("Freescale / iVeia P1022 RDK reference board\n"); -} - -machine_arch_initcall(p1022_rdk, mpc85xx_common_publish_devices); - -machine_arch_initcall(p1022_rdk, swiotlb_setup_bus_notifier); - -/* - * Called very early, device-tree isn't unflattened - */ -static int __init p1022_rdk_probe(void) -{ - unsigned long root = of_get_flat_dt_root(); - - return of_flat_dt_is_compatible(root, "fsl,p1022rdk"); -} - -define_machine(p1022_rdk) { - .name = "P1022 RDK", - .probe = p1022_rdk_probe, - .setup_arch = p1022_rdk_setup_arch, - .init_IRQ = p1022_rdk_pic_init, -#ifdef CONFIG_PCI - .pcibios_fixup_bus = fsl_pcibios_fixup_bus, -#endif - .get_irq = mpic_get_irq, - .restart = fsl_rstcr_restart, - .calibrate_decr = generic_calibrate_decr, - .progress = udbg_progress, -}; diff --git a/trunk/arch/powerpc/platforms/85xx/p1023_rds.c b/trunk/arch/powerpc/platforms/85xx/p1023_rds.c index 9cc60a738834..2990e8b13dc9 100644 --- a/trunk/arch/powerpc/platforms/85xx/p1023_rds.c +++ b/trunk/arch/powerpc/platforms/85xx/p1023_rds.c @@ -80,12 +80,15 @@ static void __init mpc85xx_rds_setup_arch(void) } } - mpc85xx_smp_init(); +#ifdef CONFIG_PCI + for_each_compatible_node(np, "pci", "fsl,p1023-pcie") + fsl_add_bridge(np, 0); +#endif - fsl_pci_assign_primary(); + mpc85xx_smp_init(); } -machine_arch_initcall(p1023_rds, mpc85xx_common_publish_devices); +machine_device_initcall(p1023_rds, mpc85xx_common_publish_devices); static void __init mpc85xx_rds_pic_init(void) { diff --git a/trunk/arch/powerpc/platforms/85xx/p2041_rdb.c b/trunk/arch/powerpc/platforms/85xx/p2041_rdb.c index 000c0892fc40..6541fa2630c0 100644 --- a/trunk/arch/powerpc/platforms/85xx/p2041_rdb.c +++ b/trunk/arch/powerpc/platforms/85xx/p2041_rdb.c @@ -80,7 +80,7 @@ define_machine(p2041_rdb) { .power_save = e500_idle, }; -machine_arch_initcall(p2041_rdb, corenet_ds_publish_devices); +machine_device_initcall(p2041_rdb, corenet_ds_publish_devices); #ifdef CONFIG_SWIOTLB machine_arch_initcall(p2041_rdb, swiotlb_setup_bus_notifier); diff --git a/trunk/arch/powerpc/platforms/85xx/p3041_ds.c b/trunk/arch/powerpc/platforms/85xx/p3041_ds.c index b3edc205daa9..f238efa75891 100644 --- a/trunk/arch/powerpc/platforms/85xx/p3041_ds.c +++ b/trunk/arch/powerpc/platforms/85xx/p3041_ds.c @@ -82,7 +82,7 @@ define_machine(p3041_ds) { .power_save = e500_idle, }; -machine_arch_initcall(p3041_ds, corenet_ds_publish_devices); +machine_device_initcall(p3041_ds, corenet_ds_publish_devices); #ifdef CONFIG_SWIOTLB machine_arch_initcall(p3041_ds, swiotlb_setup_bus_notifier); diff --git a/trunk/arch/powerpc/platforms/85xx/p4080_ds.c b/trunk/arch/powerpc/platforms/85xx/p4080_ds.c index 54df10632aea..c92417dc6574 100644 --- a/trunk/arch/powerpc/platforms/85xx/p4080_ds.c +++ b/trunk/arch/powerpc/platforms/85xx/p4080_ds.c @@ -81,7 +81,7 @@ define_machine(p4080_ds) { .power_save = e500_idle, }; -machine_arch_initcall(p4080_ds, corenet_ds_publish_devices); +machine_device_initcall(p4080_ds, corenet_ds_publish_devices); #ifdef CONFIG_SWIOTLB machine_arch_initcall(p4080_ds, swiotlb_setup_bus_notifier); #endif diff --git a/trunk/arch/powerpc/platforms/85xx/p5020_ds.c b/trunk/arch/powerpc/platforms/85xx/p5020_ds.c index 753a42c29d4d..17bef15a85ed 100644 --- a/trunk/arch/powerpc/platforms/85xx/p5020_ds.c +++ b/trunk/arch/powerpc/platforms/85xx/p5020_ds.c @@ -91,7 +91,7 @@ define_machine(p5020_ds) { #endif }; -machine_arch_initcall(p5020_ds, corenet_ds_publish_devices); +machine_device_initcall(p5020_ds, corenet_ds_publish_devices); #ifdef CONFIG_SWIOTLB machine_arch_initcall(p5020_ds, swiotlb_setup_bus_notifier); diff --git a/trunk/arch/powerpc/platforms/85xx/p5040_ds.c b/trunk/arch/powerpc/platforms/85xx/p5040_ds.c deleted file mode 100644 index 11381851828e..000000000000 --- a/trunk/arch/powerpc/platforms/85xx/p5040_ds.c +++ /dev/null @@ -1,89 +0,0 @@ -/* - * P5040 DS Setup - * - * Copyright 2009-2010 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 as published by the - * Free Software Foundation; either version 2 of the License, or (at your - * option) any later version. - */ - -#include -#include - -#include -#include -#include - -#include - -#include -#include -#include - -#include "corenet_ds.h" - -/* - * Called very early, device-tree isn't unflattened - */ -static int __init p5040_ds_probe(void) -{ - unsigned long root = of_get_flat_dt_root(); -#ifdef CONFIG_SMP - extern struct smp_ops_t smp_85xx_ops; -#endif - - if (of_flat_dt_is_compatible(root, "fsl,P5040DS")) - return 1; - - /* Check if we're running under the Freescale hypervisor */ - if (of_flat_dt_is_compatible(root, "fsl,P5040DS-hv")) { - ppc_md.init_IRQ = ehv_pic_init; - ppc_md.get_irq = ehv_pic_get_irq; - ppc_md.restart = fsl_hv_restart; - ppc_md.power_off = fsl_hv_halt; - ppc_md.halt = fsl_hv_halt; -#ifdef CONFIG_SMP - /* - * Disable the timebase sync operations because we can't write - * to the timebase registers under the hypervisor. - */ - smp_85xx_ops.give_timebase = NULL; - smp_85xx_ops.take_timebase = NULL; -#endif - return 1; - } - - return 0; -} - -define_machine(p5040_ds) { - .name = "P5040 DS", - .probe = p5040_ds_probe, - .setup_arch = corenet_ds_setup_arch, - .init_IRQ = corenet_ds_pic_init, -#ifdef CONFIG_PCI - .pcibios_fixup_bus = fsl_pcibios_fixup_bus, -#endif -/* coreint doesn't play nice with lazy EE, use legacy mpic for now */ -#ifdef CONFIG_PPC64 - .get_irq = mpic_get_irq, -#else - .get_irq = mpic_get_coreint_irq, -#endif - .restart = fsl_rstcr_restart, - .calibrate_decr = generic_calibrate_decr, - .progress = udbg_progress, -#ifdef CONFIG_PPC64 - .power_save = book3e_idle, -#else - .power_save = e500_idle, -#endif -}; - -machine_arch_initcall(p5040_ds, corenet_ds_publish_devices); - -#ifdef CONFIG_SWIOTLB -machine_arch_initcall(p5040_ds, swiotlb_setup_bus_notifier); -#endif diff --git a/trunk/arch/powerpc/platforms/85xx/qemu_e500.c b/trunk/arch/powerpc/platforms/85xx/qemu_e500.c index f6ea5618c733..95a2e53af71b 100644 --- a/trunk/arch/powerpc/platforms/85xx/qemu_e500.c +++ b/trunk/arch/powerpc/platforms/85xx/qemu_e500.c @@ -41,8 +41,7 @@ static void __init qemu_e500_setup_arch(void) { ppc_md.progress("qemu_e500_setup_arch()", 0); - fsl_pci_assign_primary(); - swiotlb_detect_4g(); + fsl_pci_init(); mpc85xx_smp_init(); } @@ -56,7 +55,7 @@ static int __init qemu_e500_probe(void) return !!of_flat_dt_is_compatible(root, "fsl,qemu-e500"); } -machine_arch_initcall(qemu_e500, mpc85xx_common_publish_devices); +machine_device_initcall(qemu_e500, mpc85xx_common_publish_devices); define_machine(qemu_e500) { .name = "QEMU e500", diff --git a/trunk/arch/powerpc/platforms/85xx/sbc8548.c b/trunk/arch/powerpc/platforms/85xx/sbc8548.c index f62121825914..cd3a66bdb54b 100644 --- a/trunk/arch/powerpc/platforms/85xx/sbc8548.c +++ b/trunk/arch/powerpc/platforms/85xx/sbc8548.c @@ -88,11 +88,26 @@ static int __init sbc8548_hw_rev(void) */ static void __init sbc8548_setup_arch(void) { +#ifdef CONFIG_PCI + struct device_node *np; +#endif + if (ppc_md.progress) ppc_md.progress("sbc8548_setup_arch()", 0); - fsl_pci_assign_primary(); - +#ifdef CONFIG_PCI + for_each_node_by_type(np, "pci") { + if (of_device_is_compatible(np, "fsl,mpc8540-pci") || + of_device_is_compatible(np, "fsl,mpc8548-pcie")) { + struct resource rsrc; + of_address_to_resource(np, 0, &rsrc); + if ((rsrc.start & 0xfffff) == 0x8000) + fsl_add_bridge(np, 1); + else + fsl_add_bridge(np, 0); + } + } +#endif sbc_rev = sbc8548_hw_rev(); } @@ -113,7 +128,7 @@ static void sbc8548_show_cpuinfo(struct seq_file *m) seq_printf(m, "PLL setting\t: 0x%x\n", ((phid1 >> 24) & 0x3f)); } -machine_arch_initcall(sbc8548, mpc85xx_common_publish_devices); +machine_device_initcall(sbc8548, mpc85xx_common_publish_devices); /* * Called very early, device-tree isn't unflattened diff --git a/trunk/arch/powerpc/platforms/85xx/smp.c b/trunk/arch/powerpc/platforms/85xx/smp.c index 6fcfa12e5c56..ff4249044a3c 100644 --- a/trunk/arch/powerpc/platforms/85xx/smp.c +++ b/trunk/arch/powerpc/platforms/85xx/smp.c @@ -2,7 +2,7 @@ * Author: Andy Fleming * Kumar Gala * - * Copyright 2006-2008, 2011-2012 Freescale Semiconductor Inc. + * Copyright 2006-2008, 2011 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 as published by the @@ -17,7 +17,6 @@ #include #include #include -#include #include #include @@ -25,118 +24,33 @@ #include #include #include -#include #include #include #include "smp.h" -struct epapr_spin_table { - u32 addr_h; - u32 addr_l; - u32 r3_h; - u32 r3_l; - u32 reserved; - u32 pir; -}; - -static struct ccsr_guts __iomem *guts; -static u64 timebase; -static int tb_req; -static int tb_valid; - -static void mpc85xx_timebase_freeze(int freeze) -{ - uint32_t mask; - - mask = CCSR_GUTS_DEVDISR_TB0 | CCSR_GUTS_DEVDISR_TB1; - if (freeze) - setbits32(&guts->devdisr, mask); - else - clrbits32(&guts->devdisr, mask); - - in_be32(&guts->devdisr); -} - -static void mpc85xx_give_timebase(void) -{ - unsigned long flags; - - local_irq_save(flags); - - while (!tb_req) - barrier(); - tb_req = 0; - - mpc85xx_timebase_freeze(1); - timebase = get_tb(); - mb(); - tb_valid = 1; - - while (tb_valid) - barrier(); - - mpc85xx_timebase_freeze(0); - - local_irq_restore(flags); -} - -static void mpc85xx_take_timebase(void) -{ - unsigned long flags; - - local_irq_save(flags); - - tb_req = 1; - while (!tb_valid) - barrier(); - - set_tb(timebase >> 32, timebase & 0xffffffff); - isync(); - tb_valid = 0; - - local_irq_restore(flags); -} - -#ifdef CONFIG_HOTPLUG_CPU -static void __cpuinit smp_85xx_mach_cpu_die(void) -{ - unsigned int cpu = smp_processor_id(); - u32 tmp; - - local_irq_disable(); - idle_task_exit(); - generic_set_cpu_dead(cpu); - mb(); - - mtspr(SPRN_TCR, 0); - - __flush_disable_L1(); - tmp = (mfspr(SPRN_HID0) & ~(HID0_DOZE|HID0_SLEEP)) | HID0_NAP; - mtspr(SPRN_HID0, tmp); - isync(); - - /* Enter NAP mode. */ - tmp = mfmsr(); - tmp |= MSR_WE; - mb(); - mtmsr(tmp); - isync(); - - while (1) - ; -} -#endif - -static int __cpuinit smp_85xx_kick_cpu(int nr) +extern void __early_start(void); + +#define BOOT_ENTRY_ADDR_UPPER 0 +#define BOOT_ENTRY_ADDR_LOWER 1 +#define BOOT_ENTRY_R3_UPPER 2 +#define BOOT_ENTRY_R3_LOWER 3 +#define BOOT_ENTRY_RESV 4 +#define BOOT_ENTRY_PIR 5 +#define BOOT_ENTRY_R6_UPPER 6 +#define BOOT_ENTRY_R6_LOWER 7 +#define NUM_BOOT_ENTRY 8 +#define SIZE_BOOT_ENTRY (NUM_BOOT_ENTRY * sizeof(u32)) + +static int __init +smp_85xx_kick_cpu(int nr) { unsigned long flags; const u64 *cpu_rel_addr; - __iomem struct epapr_spin_table *spin_table; + __iomem u32 *bptr_vaddr; struct device_node *np; - int hw_cpu = get_hard_smp_processor_id(nr); + int n = 0, hw_cpu = get_hard_smp_processor_id(nr); int ioremappable; - int ret = 0; WARN_ON(nr < 0 || nr >= NR_CPUS); WARN_ON(hw_cpu < 0 || hw_cpu >= NR_CPUS); @@ -161,81 +75,46 @@ static int __cpuinit smp_85xx_kick_cpu(int nr) /* Map the spin table */ if (ioremappable) - spin_table = ioremap(*cpu_rel_addr, - sizeof(struct epapr_spin_table)); + bptr_vaddr = ioremap(*cpu_rel_addr, SIZE_BOOT_ENTRY); else - spin_table = phys_to_virt(*cpu_rel_addr); + bptr_vaddr = phys_to_virt(*cpu_rel_addr); local_irq_save(flags); -#ifdef CONFIG_PPC32 -#ifdef CONFIG_HOTPLUG_CPU - /* Corresponding to generic_set_cpu_dead() */ - generic_set_cpu_up(nr); - - if (system_state == SYSTEM_RUNNING) { - out_be32(&spin_table->addr_l, 0); - - /* - * We don't set the BPTR register here since it already points - * to the boot page properly. - */ - mpic_reset_core(hw_cpu); - - /* wait until core is ready... */ - if (!spin_event_timeout(in_be32(&spin_table->addr_l) == 1, - 10000, 100)) { - pr_err("%s: timeout waiting for core %d to reset\n", - __func__, hw_cpu); - ret = -ENOENT; - goto out; - } - /* clear the acknowledge status */ - __secondary_hold_acknowledge = -1; - } -#endif - out_be32(&spin_table->pir, hw_cpu); - out_be32(&spin_table->addr_l, __pa(__early_start)); + out_be32(bptr_vaddr + BOOT_ENTRY_PIR, hw_cpu); +#ifdef CONFIG_PPC32 + out_be32(bptr_vaddr + BOOT_ENTRY_ADDR_LOWER, __pa(__early_start)); if (!ioremappable) - flush_dcache_range((ulong)spin_table, - (ulong)spin_table + sizeof(struct epapr_spin_table)); + flush_dcache_range((ulong)bptr_vaddr, + (ulong)(bptr_vaddr + SIZE_BOOT_ENTRY)); /* Wait a bit for the CPU to ack. */ - if (!spin_event_timeout(__secondary_hold_acknowledge == hw_cpu, - 10000, 100)) { - pr_err("%s: timeout waiting for core %d to ack\n", - __func__, hw_cpu); - ret = -ENOENT; - goto out; - } -out: + while ((__secondary_hold_acknowledge != hw_cpu) && (++n < 1000)) + mdelay(1); #else smp_generic_kick_cpu(nr); - out_be32(&spin_table->pir, hw_cpu); - out_be64((u64 *)(&spin_table->addr_h), - __pa((u64)*((unsigned long long *)generic_secondary_smp_init))); + out_be64((u64 *)(bptr_vaddr + BOOT_ENTRY_ADDR_UPPER), + __pa((u64)*((unsigned long long *) generic_secondary_smp_init))); if (!ioremappable) - flush_dcache_range((ulong)spin_table, - (ulong)spin_table + sizeof(struct epapr_spin_table)); + flush_dcache_range((ulong)bptr_vaddr, + (ulong)(bptr_vaddr + SIZE_BOOT_ENTRY)); #endif local_irq_restore(flags); if (ioremappable) - iounmap(spin_table); + iounmap(bptr_vaddr); + + pr_debug("waited %d msecs for CPU #%d.\n", n, nr); - return ret; + return 0; } struct smp_ops_t smp_85xx_ops = { .kick_cpu = smp_85xx_kick_cpu, -#ifdef CONFIG_HOTPLUG_CPU - .cpu_disable = generic_cpu_disable, - .cpu_die = generic_cpu_die, -#endif #ifdef CONFIG_KEXEC .give_timebase = smp_generic_give_timebase, .take_timebase = smp_generic_take_timebase, @@ -339,7 +218,8 @@ static void mpc85xx_smp_machine_kexec(struct kimage *image) } #endif /* CONFIG_KEXEC */ -static void __cpuinit smp_85xx_setup_cpu(int cpu_nr) +static void __init +smp_85xx_setup_cpu(int cpu_nr) { if (smp_85xx_ops.probe == smp_mpic_probe) mpic_setup_this_cpu(); @@ -348,16 +228,6 @@ static void __cpuinit smp_85xx_setup_cpu(int cpu_nr) doorbell_setup_this_cpu(); } -static const struct of_device_id mpc85xx_smp_guts_ids[] = { - { .compatible = "fsl,mpc8572-guts", }, - { .compatible = "fsl,p1020-guts", }, - { .compatible = "fsl,p1021-guts", }, - { .compatible = "fsl,p1022-guts", }, - { .compatible = "fsl,p1023-guts", }, - { .compatible = "fsl,p2020-guts", }, - {}, -}; - void __init mpc85xx_smp_init(void) { struct device_node *np; @@ -379,22 +249,6 @@ void __init mpc85xx_smp_init(void) smp_85xx_ops.cause_ipi = doorbell_cause_ipi; } - np = of_find_matching_node(NULL, mpc85xx_smp_guts_ids); - if (np) { - guts = of_iomap(np, 0); - of_node_put(np); - if (!guts) { - pr_err("%s: Could not map guts node address\n", - __func__); - return; - } - smp_85xx_ops.give_timebase = mpc85xx_give_timebase; - smp_85xx_ops.take_timebase = mpc85xx_take_timebase; -#ifdef CONFIG_HOTPLUG_CPU - ppc_md.cpu_die = smp_85xx_mach_cpu_die; -#endif - } - smp_ops = &smp_85xx_ops; #ifdef CONFIG_KEXEC diff --git a/trunk/arch/powerpc/platforms/85xx/socrates.c b/trunk/arch/powerpc/platforms/85xx/socrates.c index ae368e0e1076..b9c6daa07b66 100644 --- a/trunk/arch/powerpc/platforms/85xx/socrates.c +++ b/trunk/arch/powerpc/platforms/85xx/socrates.c @@ -66,13 +66,20 @@ static void __init socrates_pic_init(void) */ static void __init socrates_setup_arch(void) { +#ifdef CONFIG_PCI + struct device_node *np; +#endif + if (ppc_md.progress) ppc_md.progress("socrates_setup_arch()", 0); - fsl_pci_assign_primary(); +#ifdef CONFIG_PCI + for_each_compatible_node(np, "pci", "fsl,mpc8540-pci") + fsl_add_bridge(np, 1); +#endif } -machine_arch_initcall(socrates, mpc85xx_common_publish_devices); +machine_device_initcall(socrates, mpc85xx_common_publish_devices); /* * Called very early, device-tree isn't unflattened diff --git a/trunk/arch/powerpc/platforms/85xx/stx_gp3.c b/trunk/arch/powerpc/platforms/85xx/stx_gp3.c index 6f4939b6309e..e0508002b086 100644 --- a/trunk/arch/powerpc/platforms/85xx/stx_gp3.c +++ b/trunk/arch/powerpc/platforms/85xx/stx_gp3.c @@ -60,14 +60,21 @@ static void __init stx_gp3_pic_init(void) */ static void __init stx_gp3_setup_arch(void) { +#ifdef CONFIG_PCI + struct device_node *np; +#endif + if (ppc_md.progress) ppc_md.progress("stx_gp3_setup_arch()", 0); - fsl_pci_assign_primary(); - #ifdef CONFIG_CPM2 cpm2_reset(); #endif + +#ifdef CONFIG_PCI + for_each_compatible_node(np, "pci", "fsl,mpc8540-pci") + fsl_add_bridge(np, 1); +#endif } static void stx_gp3_show_cpuinfo(struct seq_file *m) @@ -86,7 +93,7 @@ static void stx_gp3_show_cpuinfo(struct seq_file *m) seq_printf(m, "PLL setting\t: 0x%x\n", ((phid1 >> 24) & 0x3f)); } -machine_arch_initcall(stx_gp3, mpc85xx_common_publish_devices); +machine_device_initcall(stx_gp3, mpc85xx_common_publish_devices); /* * Called very early, device-tree isn't unflattened diff --git a/trunk/arch/powerpc/platforms/85xx/tqm85xx.c b/trunk/arch/powerpc/platforms/85xx/tqm85xx.c index b4e58cdc09a5..3e70a2035e53 100644 --- a/trunk/arch/powerpc/platforms/85xx/tqm85xx.c +++ b/trunk/arch/powerpc/platforms/85xx/tqm85xx.c @@ -59,6 +59,10 @@ static void __init tqm85xx_pic_init(void) */ static void __init tqm85xx_setup_arch(void) { +#ifdef CONFIG_PCI + struct device_node *np; +#endif + if (ppc_md.progress) ppc_md.progress("tqm85xx_setup_arch()", 0); @@ -66,7 +70,20 @@ static void __init tqm85xx_setup_arch(void) cpm2_reset(); #endif - fsl_pci_assign_primary(); +#ifdef CONFIG_PCI + for_each_node_by_type(np, "pci") { + if (of_device_is_compatible(np, "fsl,mpc8540-pci") || + of_device_is_compatible(np, "fsl,mpc8548-pcie")) { + struct resource rsrc; + if (!of_address_to_resource(np, 0, &rsrc)) { + if ((rsrc.start & 0xfffff) == 0x8000) + fsl_add_bridge(np, 1); + else + fsl_add_bridge(np, 0); + } + } + } +#endif } static void tqm85xx_show_cpuinfo(struct seq_file *m) @@ -106,9 +123,9 @@ static void __devinit tqm85xx_ti1520_fixup(struct pci_dev *pdev) DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_TI, PCI_DEVICE_ID_TI_1520, tqm85xx_ti1520_fixup); -machine_arch_initcall(tqm85xx, mpc85xx_common_publish_devices); +machine_device_initcall(tqm85xx, mpc85xx_common_publish_devices); -static const char * const board[] __initconst = { +static const char *board[] __initdata = { "tqc,tqm8540", "tqc,tqm8541", "tqc,tqm8548", diff --git a/trunk/arch/powerpc/platforms/85xx/xes_mpc85xx.c b/trunk/arch/powerpc/platforms/85xx/xes_mpc85xx.c index dcbf7e42dce7..41c687550ea7 100644 --- a/trunk/arch/powerpc/platforms/85xx/xes_mpc85xx.c +++ b/trunk/arch/powerpc/platforms/85xx/xes_mpc85xx.c @@ -111,11 +111,18 @@ static void xes_mpc85xx_fixups(void) } } +#ifdef CONFIG_PCI +static int primary_phb_addr; +#endif + /* * Setup the architecture */ static void __init xes_mpc85xx_setup_arch(void) { +#ifdef CONFIG_PCI + struct device_node *np; +#endif struct device_node *root; const char *model = "Unknown"; @@ -130,14 +137,26 @@ static void __init xes_mpc85xx_setup_arch(void) xes_mpc85xx_fixups(); - mpc85xx_smp_init(); +#ifdef CONFIG_PCI + for_each_node_by_type(np, "pci") { + if (of_device_is_compatible(np, "fsl,mpc8540-pci") || + of_device_is_compatible(np, "fsl,mpc8548-pcie")) { + struct resource rsrc; + of_address_to_resource(np, 0, &rsrc); + if ((rsrc.start & 0xfffff) == primary_phb_addr) + fsl_add_bridge(np, 1); + else + fsl_add_bridge(np, 0); + } + } +#endif - fsl_pci_assign_primary(); + mpc85xx_smp_init(); } -machine_arch_initcall(xes_mpc8572, mpc85xx_common_publish_devices); -machine_arch_initcall(xes_mpc8548, mpc85xx_common_publish_devices); -machine_arch_initcall(xes_mpc8540, mpc85xx_common_publish_devices); +machine_device_initcall(xes_mpc8572, mpc85xx_common_publish_devices); +machine_device_initcall(xes_mpc8548, mpc85xx_common_publish_devices); +machine_device_initcall(xes_mpc8540, mpc85xx_common_publish_devices); /* * Called very early, device-tree isn't unflattened @@ -146,21 +165,42 @@ static int __init xes_mpc8572_probe(void) { unsigned long root = of_get_flat_dt_root(); - return of_flat_dt_is_compatible(root, "xes,MPC8572"); + if (of_flat_dt_is_compatible(root, "xes,MPC8572")) { +#ifdef CONFIG_PCI + primary_phb_addr = 0x8000; +#endif + return 1; + } else { + return 0; + } } static int __init xes_mpc8548_probe(void) { unsigned long root = of_get_flat_dt_root(); - return of_flat_dt_is_compatible(root, "xes,MPC8548"); + if (of_flat_dt_is_compatible(root, "xes,MPC8548")) { +#ifdef CONFIG_PCI + primary_phb_addr = 0xb000; +#endif + return 1; + } else { + return 0; + } } static int __init xes_mpc8540_probe(void) { unsigned long root = of_get_flat_dt_root(); - return of_flat_dt_is_compatible(root, "xes,MPC8540"); + if (of_flat_dt_is_compatible(root, "xes,MPC8540")) { +#ifdef CONFIG_PCI + primary_phb_addr = 0xb000; +#endif + return 1; + } else { + return 0; + } } define_machine(xes_mpc8572) { diff --git a/trunk/arch/powerpc/platforms/86xx/gef_ppc9a.c b/trunk/arch/powerpc/platforms/86xx/gef_ppc9a.c index bf5338754c5a..563aafa8629c 100644 --- a/trunk/arch/powerpc/platforms/86xx/gef_ppc9a.c +++ b/trunk/arch/powerpc/platforms/86xx/gef_ppc9a.c @@ -73,6 +73,13 @@ static void __init gef_ppc9a_init_irq(void) static void __init gef_ppc9a_setup_arch(void) { struct device_node *regs; +#ifdef CONFIG_PCI + struct device_node *np; + + for_each_compatible_node(np, "pci", "fsl,mpc8641-pcie") { + fsl_add_bridge(np, 1); + } +#endif printk(KERN_INFO "GE Intelligent Platforms PPC9A 6U VME SBC\n"); @@ -80,8 +87,6 @@ static void __init gef_ppc9a_setup_arch(void) mpc86xx_smp_init(); #endif - fsl_pci_assign_primary(); - /* Remap basic board registers */ regs = of_find_compatible_node(NULL, NULL, "gef,ppc9a-fpga-regs"); if (regs) { @@ -216,7 +221,6 @@ static long __init mpc86xx_time_init(void) static __initdata struct of_device_id of_bus_ids[] = { { .compatible = "simple-bus", }, { .compatible = "gianfar", }, - { .compatible = "fsl,mpc8641-pcie", }, {}, }; @@ -227,7 +231,7 @@ static int __init declare_of_platform_devices(void) return 0; } -machine_arch_initcall(gef_ppc9a, declare_of_platform_devices); +machine_device_initcall(gef_ppc9a, declare_of_platform_devices); define_machine(gef_ppc9a) { .name = "GE PPC9A", diff --git a/trunk/arch/powerpc/platforms/86xx/gef_sbc310.c b/trunk/arch/powerpc/platforms/86xx/gef_sbc310.c index 0b7851330a07..cc6a91ae0889 100644 --- a/trunk/arch/powerpc/platforms/86xx/gef_sbc310.c +++ b/trunk/arch/powerpc/platforms/86xx/gef_sbc310.c @@ -73,14 +73,20 @@ static void __init gef_sbc310_init_irq(void) static void __init gef_sbc310_setup_arch(void) { struct device_node *regs; +#ifdef CONFIG_PCI + struct device_node *np; + + for_each_compatible_node(np, "pci", "fsl,mpc8641-pcie") { + fsl_add_bridge(np, 1); + } +#endif + printk(KERN_INFO "GE Intelligent Platforms SBC310 6U VPX SBC\n"); #ifdef CONFIG_SMP mpc86xx_smp_init(); #endif - fsl_pci_assign_primary(); - /* Remap basic board registers */ regs = of_find_compatible_node(NULL, NULL, "gef,fpga-regs"); if (regs) { @@ -203,7 +209,6 @@ static long __init mpc86xx_time_init(void) static __initdata struct of_device_id of_bus_ids[] = { { .compatible = "simple-bus", }, { .compatible = "gianfar", }, - { .compatible = "fsl,mpc8641-pcie", }, {}, }; @@ -214,7 +219,7 @@ static int __init declare_of_platform_devices(void) return 0; } -machine_arch_initcall(gef_sbc310, declare_of_platform_devices); +machine_device_initcall(gef_sbc310, declare_of_platform_devices); define_machine(gef_sbc310) { .name = "GE SBC310", diff --git a/trunk/arch/powerpc/platforms/86xx/gef_sbc610.c b/trunk/arch/powerpc/platforms/86xx/gef_sbc610.c index b9eb174897b1..aead6b337f4a 100644 --- a/trunk/arch/powerpc/platforms/86xx/gef_sbc610.c +++ b/trunk/arch/powerpc/platforms/86xx/gef_sbc610.c @@ -73,6 +73,13 @@ static void __init gef_sbc610_init_irq(void) static void __init gef_sbc610_setup_arch(void) { struct device_node *regs; +#ifdef CONFIG_PCI + struct device_node *np; + + for_each_compatible_node(np, "pci", "fsl,mpc8641-pcie") { + fsl_add_bridge(np, 1); + } +#endif printk(KERN_INFO "GE Intelligent Platforms SBC610 6U VPX SBC\n"); @@ -80,8 +87,6 @@ static void __init gef_sbc610_setup_arch(void) mpc86xx_smp_init(); #endif - fsl_pci_assign_primary(); - /* Remap basic board registers */ regs = of_find_compatible_node(NULL, NULL, "gef,fpga-regs"); if (regs) { @@ -193,7 +198,6 @@ static long __init mpc86xx_time_init(void) static __initdata struct of_device_id of_bus_ids[] = { { .compatible = "simple-bus", }, { .compatible = "gianfar", }, - { .compatible = "fsl,mpc8641-pcie", }, {}, }; @@ -204,7 +208,7 @@ static int __init declare_of_platform_devices(void) return 0; } -machine_arch_initcall(gef_sbc610, declare_of_platform_devices); +machine_device_initcall(gef_sbc610, declare_of_platform_devices); define_machine(gef_sbc610) { .name = "GE SBC610", diff --git a/trunk/arch/powerpc/platforms/86xx/mpc8610_hpcd.c b/trunk/arch/powerpc/platforms/86xx/mpc8610_hpcd.c index a817398a56da..62cd3c555bfb 100644 --- a/trunk/arch/powerpc/platforms/86xx/mpc8610_hpcd.c +++ b/trunk/arch/powerpc/platforms/86xx/mpc8610_hpcd.c @@ -91,9 +91,6 @@ static struct of_device_id __initdata mpc8610_ids[] = { { .compatible = "simple-bus", }, /* So that the DMA channel nodes can be probed individually: */ { .compatible = "fsl,eloplus-dma", }, - /* PCI controllers */ - { .compatible = "fsl,mpc8610-pci", }, - { .compatible = "fsl,mpc8641-pcie", }, {} }; @@ -110,7 +107,7 @@ static int __init mpc8610_declare_of_platform_devices(void) return 0; } -machine_arch_initcall(mpc86xx_hpcd, mpc8610_declare_of_platform_devices); +machine_device_initcall(mpc86xx_hpcd, mpc8610_declare_of_platform_devices); #if defined(CONFIG_FB_FSL_DIU) || defined(CONFIG_FB_FSL_DIU_MODULE) @@ -281,13 +278,25 @@ mpc8610hpcd_valid_monitor_port(enum fsl_diu_monitor_port port) static void __init mpc86xx_hpcd_setup_arch(void) { struct resource r; + struct device_node *np; unsigned char *pixis; if (ppc_md.progress) ppc_md.progress("mpc86xx_hpcd_setup_arch()", 0); - fsl_pci_assign_primary(); - +#ifdef CONFIG_PCI + for_each_node_by_type(np, "pci") { + if (of_device_is_compatible(np, "fsl,mpc8610-pci") + || of_device_is_compatible(np, "fsl,mpc8641-pcie")) { + struct resource rsrc; + of_address_to_resource(np, 0, &rsrc); + if ((rsrc.start & 0xfffff) == 0xa000) + fsl_add_bridge(np, 1); + else + fsl_add_bridge(np, 0); + } + } +#endif #if defined(CONFIG_FB_FSL_DIU) || defined(CONFIG_FB_FSL_DIU_MODULE) diu_ops.get_pixel_format = mpc8610hpcd_get_pixel_format; diu_ops.set_gamma_table = mpc8610hpcd_set_gamma_table; diff --git a/trunk/arch/powerpc/platforms/86xx/mpc86xx_hpcn.c b/trunk/arch/powerpc/platforms/86xx/mpc86xx_hpcn.c index e8bf3fae5606..817245bc0219 100644 --- a/trunk/arch/powerpc/platforms/86xx/mpc86xx_hpcn.c +++ b/trunk/arch/powerpc/platforms/86xx/mpc86xx_hpcn.c @@ -19,6 +19,7 @@ #include #include #include +#include #include #include @@ -50,8 +51,15 @@ extern int uli_exclude_device(struct pci_controller *hose, static int mpc86xx_exclude_device(struct pci_controller *hose, u_char bus, u_char devfn) { - if (hose->dn == fsl_pci_primary) + struct device_node* node; + struct resource rsrc; + + node = hose->dn; + of_address_to_resource(node, 0, &rsrc); + + if ((rsrc.start & 0xfffff) == 0x8000) { return uli_exclude_device(hose, bus, devfn); + } return PCIBIOS_SUCCESSFUL; } @@ -61,11 +69,30 @@ static int mpc86xx_exclude_device(struct pci_controller *hose, static void __init mpc86xx_hpcn_setup_arch(void) { +#ifdef CONFIG_PCI + struct device_node *np; + struct pci_controller *hose; +#endif + dma_addr_t max = 0xffffffff; + if (ppc_md.progress) ppc_md.progress("mpc86xx_hpcn_setup_arch()", 0); #ifdef CONFIG_PCI + for_each_compatible_node(np, "pci", "fsl,mpc8641-pcie") { + struct resource rsrc; + of_address_to_resource(np, 0, &rsrc); + if ((rsrc.start & 0xfffff) == 0x8000) + fsl_add_bridge(np, 1); + else + fsl_add_bridge(np, 0); + hose = pci_find_hose_for_OF_device(np); + max = min(max, hose->dma_window_base_cur + + hose->dma_window_size); + } + ppc_md.pci_exclude_device = mpc86xx_exclude_device; + #endif printk("MPC86xx HPCN board from Freescale Semiconductor\n"); @@ -74,9 +101,13 @@ mpc86xx_hpcn_setup_arch(void) mpc86xx_smp_init(); #endif - fsl_pci_assign_primary(); - - swiotlb_detect_4g(); +#ifdef CONFIG_SWIOTLB + if ((memblock_end_of_DRAM() - 1) > max) { + ppc_swiotlb_enable = 1; + set_pci_dma_ops(&swiotlb_dma_ops); + ppc_md.pci_dma_dev_setup = pci_dma_dev_setup_swiotlb; + } +#endif } @@ -131,7 +162,6 @@ static __initdata struct of_device_id of_bus_ids[] = { { .compatible = "simple-bus", }, { .compatible = "fsl,srio", }, { .compatible = "gianfar", }, - { .compatible = "fsl,mpc8641-pcie", }, {}, }; @@ -141,7 +171,7 @@ static int __init declare_of_platform_devices(void) return 0; } -machine_arch_initcall(mpc86xx_hpcn, declare_of_platform_devices); +machine_device_initcall(mpc86xx_hpcn, declare_of_platform_devices); machine_arch_initcall(mpc86xx_hpcn, swiotlb_setup_bus_notifier); define_machine(mpc86xx_hpcn) { diff --git a/trunk/arch/powerpc/platforms/86xx/sbc8641d.c b/trunk/arch/powerpc/platforms/86xx/sbc8641d.c index b47a8fd0f3d3..e7007d0d949e 100644 --- a/trunk/arch/powerpc/platforms/86xx/sbc8641d.c +++ b/trunk/arch/powerpc/platforms/86xx/sbc8641d.c @@ -38,16 +38,23 @@ static void __init sbc8641_setup_arch(void) { +#ifdef CONFIG_PCI + struct device_node *np; +#endif + if (ppc_md.progress) ppc_md.progress("sbc8641_setup_arch()", 0); +#ifdef CONFIG_PCI + for_each_compatible_node(np, "pci", "fsl,mpc8641-pcie") + fsl_add_bridge(np, 0); +#endif + printk("SBC8641 board from Wind River\n"); #ifdef CONFIG_SMP mpc86xx_smp_init(); #endif - - fsl_pci_assign_primary(); } @@ -95,7 +102,6 @@ mpc86xx_time_init(void) static __initdata struct of_device_id of_bus_ids[] = { { .compatible = "simple-bus", }, { .compatible = "gianfar", }, - { .compatible = "fsl,mpc8641-pcie", }, {}, }; @@ -105,7 +111,7 @@ static int __init declare_of_platform_devices(void) return 0; } -machine_arch_initcall(sbc8641, declare_of_platform_devices); +machine_device_initcall(sbc8641, declare_of_platform_devices); define_machine(sbc8641) { .name = "SBC8641D", diff --git a/trunk/arch/powerpc/platforms/cell/beat.c b/trunk/arch/powerpc/platforms/cell/beat.c index affcf566d460..852592b2b712 100644 --- a/trunk/arch/powerpc/platforms/cell/beat.c +++ b/trunk/arch/powerpc/platforms/cell/beat.c @@ -136,9 +136,9 @@ ssize_t beat_nvram_get_size(void) return BEAT_NVRAM_SIZE; } -int beat_set_xdabr(unsigned long dabr, unsigned long dabrx) +int beat_set_xdabr(unsigned long dabr) { - if (beat_set_dabr(dabr, dabrx)) + if (beat_set_dabr(dabr, DABRX_KERNEL | DABRX_USER)) return -1; return 0; } diff --git a/trunk/arch/powerpc/platforms/cell/beat.h b/trunk/arch/powerpc/platforms/cell/beat.h index bfcb8e351ae5..32c8efcedc80 100644 --- a/trunk/arch/powerpc/platforms/cell/beat.h +++ b/trunk/arch/powerpc/platforms/cell/beat.h @@ -32,7 +32,7 @@ void beat_get_rtc_time(struct rtc_time *); ssize_t beat_nvram_get_size(void); ssize_t beat_nvram_read(char *, size_t, loff_t *); ssize_t beat_nvram_write(char *, size_t, loff_t *); -int beat_set_xdabr(unsigned long, unsigned long); +int beat_set_xdabr(unsigned long); void beat_power_save(void); void beat_kexec_cpu_down(int, int); diff --git a/trunk/arch/powerpc/platforms/cell/beat_htab.c b/trunk/arch/powerpc/platforms/cell/beat_htab.c index 0f6f83988b3d..943c9d39aa16 100644 --- a/trunk/arch/powerpc/platforms/cell/beat_htab.c +++ b/trunk/arch/powerpc/platforms/cell/beat_htab.c @@ -88,7 +88,7 @@ static inline unsigned int beat_read_mask(unsigned hpte_group) } static long beat_lpar_hpte_insert(unsigned long hpte_group, - unsigned long vpn, unsigned long pa, + unsigned long va, unsigned long pa, unsigned long rflags, unsigned long vflags, int psize, int ssize) { @@ -103,7 +103,7 @@ static long beat_lpar_hpte_insert(unsigned long hpte_group, "rflags=%lx, vflags=%lx, psize=%d)\n", hpte_group, va, pa, rflags, vflags, psize); - hpte_v = hpte_encode_v(vpn, psize, MMU_SEGSIZE_256M) | + hpte_v = hpte_encode_v(va, psize, MMU_SEGSIZE_256M) | vflags | HPTE_V_VALID; hpte_r = hpte_encode_r(pa, psize) | rflags; @@ -184,14 +184,14 @@ static void beat_lpar_hptab_clear(void) */ static long beat_lpar_hpte_updatepp(unsigned long slot, unsigned long newpp, - unsigned long vpn, + unsigned long va, int psize, int ssize, int local) { unsigned long lpar_rc; u64 dummy0, dummy1; unsigned long want_v; - want_v = hpte_encode_v(vpn, psize, MMU_SEGSIZE_256M); + want_v = hpte_encode_v(va, psize, MMU_SEGSIZE_256M); DBG_LOW(" update: " "avpnv=%016lx, slot=%016lx, psize: %d, newpp %016lx ... ", @@ -220,15 +220,15 @@ static long beat_lpar_hpte_updatepp(unsigned long slot, return 0; } -static long beat_lpar_hpte_find(unsigned long vpn, int psize) +static long beat_lpar_hpte_find(unsigned long va, int psize) { unsigned long hash; unsigned long i, j; long slot; unsigned long want_v, hpte_v; - hash = hpt_hash(vpn, mmu_psize_defs[psize].shift, MMU_SEGSIZE_256M); - want_v = hpte_encode_v(vpn, psize, MMU_SEGSIZE_256M); + hash = hpt_hash(va, mmu_psize_defs[psize].shift, MMU_SEGSIZE_256M); + want_v = hpte_encode_v(va, psize, MMU_SEGSIZE_256M); for (j = 0; j < 2; j++) { slot = (hash & htab_hash_mask) * HPTES_PER_GROUP; @@ -255,15 +255,14 @@ static void beat_lpar_hpte_updateboltedpp(unsigned long newpp, unsigned long ea, int psize, int ssize) { - unsigned long vpn; - unsigned long lpar_rc, slot, vsid; + unsigned long lpar_rc, slot, vsid, va; u64 dummy0, dummy1; vsid = get_kernel_vsid(ea, MMU_SEGSIZE_256M); - vpn = hpt_vpn(ea, vsid, MMU_SEGSIZE_256M); + va = (vsid << 28) | (ea & 0x0fffffff); raw_spin_lock(&beat_htab_lock); - slot = beat_lpar_hpte_find(vpn, psize); + slot = beat_lpar_hpte_find(va, psize); BUG_ON(slot == -1); lpar_rc = beat_write_htab_entry(0, slot, 0, newpp, 0, 7, @@ -273,7 +272,7 @@ static void beat_lpar_hpte_updateboltedpp(unsigned long newpp, BUG_ON(lpar_rc != 0); } -static void beat_lpar_hpte_invalidate(unsigned long slot, unsigned long vpn, +static void beat_lpar_hpte_invalidate(unsigned long slot, unsigned long va, int psize, int ssize, int local) { unsigned long want_v; @@ -283,7 +282,7 @@ static void beat_lpar_hpte_invalidate(unsigned long slot, unsigned long vpn, DBG_LOW(" inval : slot=%lx, va=%016lx, psize: %d, local: %d\n", slot, va, psize, local); - want_v = hpte_encode_v(vpn, psize, MMU_SEGSIZE_256M); + want_v = hpte_encode_v(va, psize, MMU_SEGSIZE_256M); raw_spin_lock_irqsave(&beat_htab_lock, flags); dummy1 = beat_lpar_hpte_getword0(slot); @@ -312,7 +311,7 @@ void __init hpte_init_beat(void) } static long beat_lpar_hpte_insert_v3(unsigned long hpte_group, - unsigned long vpn, unsigned long pa, + unsigned long va, unsigned long pa, unsigned long rflags, unsigned long vflags, int psize, int ssize) { @@ -323,11 +322,11 @@ static long beat_lpar_hpte_insert_v3(unsigned long hpte_group, return -1; if (!(vflags & HPTE_V_BOLTED)) - DBG_LOW("hpte_insert(group=%lx, vpn=%016lx, pa=%016lx, " + DBG_LOW("hpte_insert(group=%lx, va=%016lx, pa=%016lx, " "rflags=%lx, vflags=%lx, psize=%d)\n", - hpte_group, vpn, pa, rflags, vflags, psize); + hpte_group, va, pa, rflags, vflags, psize); - hpte_v = hpte_encode_v(vpn, psize, MMU_SEGSIZE_256M) | + hpte_v = hpte_encode_v(va, psize, MMU_SEGSIZE_256M) | vflags | HPTE_V_VALID; hpte_r = hpte_encode_r(pa, psize) | rflags; @@ -365,14 +364,14 @@ static long beat_lpar_hpte_insert_v3(unsigned long hpte_group, */ static long beat_lpar_hpte_updatepp_v3(unsigned long slot, unsigned long newpp, - unsigned long vpn, + unsigned long va, int psize, int ssize, int local) { unsigned long lpar_rc; unsigned long want_v; unsigned long pss; - want_v = hpte_encode_v(vpn, psize, MMU_SEGSIZE_256M); + want_v = hpte_encode_v(va, psize, MMU_SEGSIZE_256M); pss = (psize == MMU_PAGE_4K) ? -1UL : mmu_psize_defs[psize].penc; DBG_LOW(" update: " @@ -393,16 +392,16 @@ static long beat_lpar_hpte_updatepp_v3(unsigned long slot, return 0; } -static void beat_lpar_hpte_invalidate_v3(unsigned long slot, unsigned long vpn, +static void beat_lpar_hpte_invalidate_v3(unsigned long slot, unsigned long va, int psize, int ssize, int local) { unsigned long want_v; unsigned long lpar_rc; unsigned long pss; - DBG_LOW(" inval : slot=%lx, vpn=%016lx, psize: %d, local: %d\n", - slot, vpn, psize, local); - want_v = hpte_encode_v(vpn, psize, MMU_SEGSIZE_256M); + DBG_LOW(" inval : slot=%lx, va=%016lx, psize: %d, local: %d\n", + slot, va, psize, local); + want_v = hpte_encode_v(va, psize, MMU_SEGSIZE_256M); pss = (psize == MMU_PAGE_4K) ? -1UL : mmu_psize_defs[psize].penc; lpar_rc = beat_invalidate_htab_entry3(0, slot, want_v, pss); diff --git a/trunk/arch/powerpc/platforms/pasemi/iommu.c b/trunk/arch/powerpc/platforms/pasemi/iommu.c index 7d2d036754b5..14943ef01918 100644 --- a/trunk/arch/powerpc/platforms/pasemi/iommu.c +++ b/trunk/arch/powerpc/platforms/pasemi/iommu.c @@ -19,12 +19,12 @@ #undef DEBUG -#include #include #include #include #include #include +#include #include #define IOBMAP_PAGE_SHIFT 12 @@ -99,7 +99,7 @@ static int iobmap_build(struct iommu_table *tbl, long index, ip = ((u32 *)tbl->it_base) + index; while (npages--) { - rpn = __pa(uaddr) >> IOBMAP_PAGE_SHIFT; + rpn = virt_to_abs(uaddr) >> IOBMAP_PAGE_SHIFT; *(ip++) = IOBMAP_L2E_V | rpn; /* invalidate tlb, can be optimized more */ @@ -258,7 +258,7 @@ void __init alloc_iobmap_l2(void) return; #endif /* For 2G space, 8x64 pages (2^21 bytes) is max total l2 size */ - iob_l2_base = (u32 *)__va(memblock_alloc_base(1UL<<21, 1UL<<21, 0x80000000)); + iob_l2_base = (u32 *)abs_to_virt(memblock_alloc_base(1UL<<21, 1UL<<21, 0x80000000)); printk(KERN_INFO "IOBMAP L2 allocated at: %p\n", iob_l2_base); } diff --git a/trunk/arch/powerpc/platforms/powernv/pci-ioda.c b/trunk/arch/powerpc/platforms/powernv/pci-ioda.c index 471aa3ccd9fd..0e7eccc0f88d 100644 --- a/trunk/arch/powerpc/platforms/powernv/pci-ioda.c +++ b/trunk/arch/powerpc/platforms/powernv/pci-ioda.c @@ -30,10 +30,19 @@ #include #include #include +#include #include "powernv.h" #include "pci.h" +struct resource_wrap { + struct list_head link; + resource_size_t size; + resource_size_t align; + struct pci_dev *dev; /* Set if it's a device */ + struct pci_bus *bus; /* Set if it's a bridge */ +}; + static int __pe_printk(const char *level, const struct pnv_ioda_pe *pe, struct va_format *vaf) { @@ -69,6 +78,273 @@ define_pe_printk_level(pe_err, KERN_ERR); define_pe_printk_level(pe_warn, KERN_WARNING); define_pe_printk_level(pe_info, KERN_INFO); + +/* Calculate resource usage & alignment requirement of a single + * device. This will also assign all resources within the device + * for a given type starting at 0 for the biggest one and then + * assigning in decreasing order of size. + */ +static void __devinit pnv_ioda_calc_dev(struct pci_dev *dev, unsigned int flags, + resource_size_t *size, + resource_size_t *align) +{ + resource_size_t start; + struct resource *r; + int i; + + pr_devel(" -> CDR %s\n", pci_name(dev)); + + *size = *align = 0; + + /* Clear the resources out and mark them all unset */ + for (i = 0; i <= PCI_ROM_RESOURCE; i++) { + r = &dev->resource[i]; + if (!(r->flags & flags)) + continue; + if (r->start) { + r->end -= r->start; + r->start = 0; + } + r->flags |= IORESOURCE_UNSET; + } + + /* We currently keep all memory resources together, we + * will handle prefetch & 64-bit separately in the future + * but for now we stick everybody in M32 + */ + start = 0; + for (;;) { + resource_size_t max_size = 0; + int max_no = -1; + + /* Find next biggest resource */ + for (i = 0; i <= PCI_ROM_RESOURCE; i++) { + r = &dev->resource[i]; + if (!(r->flags & IORESOURCE_UNSET) || + !(r->flags & flags)) + continue; + if (resource_size(r) > max_size) { + max_size = resource_size(r); + max_no = i; + } + } + if (max_no < 0) + break; + r = &dev->resource[max_no]; + if (max_size > *align) + *align = max_size; + *size += max_size; + r->start = start; + start += max_size; + r->end = r->start + max_size - 1; + r->flags &= ~IORESOURCE_UNSET; + pr_devel(" -> R%d %016llx..%016llx\n", + max_no, r->start, r->end); + } + pr_devel(" <- CDR %s size=%llx align=%llx\n", + pci_name(dev), *size, *align); +} + +/* Allocate a resource "wrap" for a given device or bridge and + * insert it at the right position in the sorted list + */ +static void __devinit pnv_ioda_add_wrap(struct list_head *list, + struct pci_bus *bus, + struct pci_dev *dev, + resource_size_t size, + resource_size_t align) +{ + struct resource_wrap *w1, *w = kzalloc(sizeof(*w), GFP_KERNEL); + + w->size = size; + w->align = align; + w->dev = dev; + w->bus = bus; + + list_for_each_entry(w1, list, link) { + if (w1->align < align) { + list_add_tail(&w->link, &w1->link); + return; + } + } + list_add_tail(&w->link, list); +} + +/* Offset device resources of a given type */ +static void __devinit pnv_ioda_offset_dev(struct pci_dev *dev, + unsigned int flags, + resource_size_t offset) +{ + struct resource *r; + int i; + + pr_devel(" -> ODR %s [%x] +%016llx\n", pci_name(dev), flags, offset); + + for (i = 0; i <= PCI_ROM_RESOURCE; i++) { + r = &dev->resource[i]; + if (r->flags & flags) { + dev->resource[i].start += offset; + dev->resource[i].end += offset; + } + } + + pr_devel(" <- ODR %s [%x] +%016llx\n", pci_name(dev), flags, offset); +} + +/* Offset bus resources (& all children) of a given type */ +static void __devinit pnv_ioda_offset_bus(struct pci_bus *bus, + unsigned int flags, + resource_size_t offset) +{ + struct resource *r; + struct pci_dev *dev; + struct pci_bus *cbus; + int i; + + pr_devel(" -> OBR %s [%x] +%016llx\n", + bus->self ? pci_name(bus->self) : "root", flags, offset); + + pci_bus_for_each_resource(bus, r, i) { + if (r && (r->flags & flags)) { + r->start += offset; + r->end += offset; + } + } + list_for_each_entry(dev, &bus->devices, bus_list) + pnv_ioda_offset_dev(dev, flags, offset); + list_for_each_entry(cbus, &bus->children, node) + pnv_ioda_offset_bus(cbus, flags, offset); + + pr_devel(" <- OBR %s [%x]\n", + bus->self ? pci_name(bus->self) : "root", flags); +} + +/* This is the guts of our IODA resource allocation. This is called + * recursively for each bus in the system. It calculates all the + * necessary size and requirements for children and assign them + * resources such that: + * + * - Each function fits in it's own contiguous set of IO/M32 + * segment + * + * - All segments behind a P2P bridge are contiguous and obey + * alignment constraints of those bridges + */ +static void __devinit pnv_ioda_calc_bus(struct pci_bus *bus, unsigned int flags, + resource_size_t *size, + resource_size_t *align) +{ + struct pci_controller *hose = pci_bus_to_host(bus); + struct pnv_phb *phb = hose->private_data; + resource_size_t dev_size, dev_align, start; + resource_size_t min_align, min_balign; + struct pci_dev *cdev; + struct pci_bus *cbus; + struct list_head head; + struct resource_wrap *w; + unsigned int bres; + + *size = *align = 0; + + pr_devel("-> CBR %s [%x]\n", + bus->self ? pci_name(bus->self) : "root", flags); + + /* Calculate alignment requirements based on the type + * of resource we are working on + */ + if (flags & IORESOURCE_IO) { + bres = 0; + min_align = phb->ioda.io_segsize; + min_balign = 0x1000; + } else { + bres = 1; + min_align = phb->ioda.m32_segsize; + min_balign = 0x100000; + } + + /* Gather all our children resources ordered by alignment */ + INIT_LIST_HEAD(&head); + + /* - Busses */ + list_for_each_entry(cbus, &bus->children, node) { + pnv_ioda_calc_bus(cbus, flags, &dev_size, &dev_align); + pnv_ioda_add_wrap(&head, cbus, NULL, dev_size, dev_align); + } + + /* - Devices */ + list_for_each_entry(cdev, &bus->devices, bus_list) { + pnv_ioda_calc_dev(cdev, flags, &dev_size, &dev_align); + /* Align them to segment size */ + if (dev_align < min_align) + dev_align = min_align; + pnv_ioda_add_wrap(&head, NULL, cdev, dev_size, dev_align); + } + if (list_empty(&head)) + goto empty; + + /* Now we can do two things: assign offsets to them within that + * level and get our total alignment & size requirements. The + * assignment algorithm is going to be uber-trivial for now, we + * can try to be smarter later at filling out holes. + */ + if (bus->self) { + /* No offset for downstream bridges */ + start = 0; + } else { + /* Offset from the root */ + if (flags & IORESOURCE_IO) + /* Don't hand out IO 0 */ + start = hose->io_resource.start + 0x1000; + else + start = hose->mem_resources[0].start; + } + while(!list_empty(&head)) { + w = list_first_entry(&head, struct resource_wrap, link); + list_del(&w->link); + if (w->size) { + if (start) { + start = ALIGN(start, w->align); + if (w->dev) + pnv_ioda_offset_dev(w->dev,flags,start); + else if (w->bus) + pnv_ioda_offset_bus(w->bus,flags,start); + } + if (w->align > *align) + *align = w->align; + } + start += w->size; + kfree(w); + } + *size = start; + + /* Align and setup bridge resources */ + *align = max_t(resource_size_t, *align, + max_t(resource_size_t, min_align, min_balign)); + *size = ALIGN(*size, + max_t(resource_size_t, min_align, min_balign)); + empty: + /* Only setup P2P's, not the PHB itself */ + if (bus->self) { + struct resource *res = bus->resource[bres]; + + if (WARN_ON(res == NULL)) + return; + + /* + * FIXME: We should probably export and call + * pci_bridge_check_ranges() to properly re-initialize + * the PCI portion of the flags here, and to detect + * what the bridge actually supports. + */ + res->start = 0; + res->flags = (*size) ? flags : 0; + res->end = (*size) ? (*size - 1) : 0; + } + + pr_devel("<- CBR %s [%x] *size=%016llx *align=%016llx\n", + bus->self ? pci_name(bus->self) : "root", flags,*size,*align); +} + static struct pci_dn *pnv_ioda_get_pdn(struct pci_dev *dev) { struct device_node *np; @@ -79,6 +355,172 @@ static struct pci_dn *pnv_ioda_get_pdn(struct pci_dev *dev) return PCI_DN(np); } +static void __devinit pnv_ioda_setup_pe_segments(struct pci_dev *dev) +{ + struct pci_controller *hose = pci_bus_to_host(dev->bus); + struct pnv_phb *phb = hose->private_data; + struct pci_dn *pdn = pnv_ioda_get_pdn(dev); + unsigned int pe, i; + resource_size_t pos; + struct resource io_res; + struct resource m32_res; + struct pci_bus_region region; + int rc; + + /* Anything not referenced in the device-tree gets PE#0 */ + pe = pdn ? pdn->pe_number : 0; + + /* Calculate the device min/max */ + io_res.start = m32_res.start = (resource_size_t)-1; + io_res.end = m32_res.end = 0; + io_res.flags = IORESOURCE_IO; + m32_res.flags = IORESOURCE_MEM; + + for (i = 0; i <= PCI_ROM_RESOURCE; i++) { + struct resource *r = NULL; + if (dev->resource[i].flags & IORESOURCE_IO) + r = &io_res; + if (dev->resource[i].flags & IORESOURCE_MEM) + r = &m32_res; + if (!r) + continue; + if (dev->resource[i].start < r->start) + r->start = dev->resource[i].start; + if (dev->resource[i].end > r->end) + r->end = dev->resource[i].end; + } + + /* Setup IO segments */ + if (io_res.start < io_res.end) { + pcibios_resource_to_bus(dev, ®ion, &io_res); + pos = region.start; + i = pos / phb->ioda.io_segsize; + while(i < phb->ioda.total_pe && pos <= region.end) { + if (phb->ioda.io_segmap[i]) { + pr_err("%s: Trying to use IO seg #%d which is" + " already used by PE# %d\n", + pci_name(dev), i, + phb->ioda.io_segmap[i]); + /* XXX DO SOMETHING TO DISABLE DEVICE ? */ + break; + } + phb->ioda.io_segmap[i] = pe; + rc = opal_pci_map_pe_mmio_window(phb->opal_id, pe, + OPAL_IO_WINDOW_TYPE, + 0, i); + if (rc != OPAL_SUCCESS) { + pr_err("%s: OPAL error %d setting up mapping" + " for IO seg# %d\n", + pci_name(dev), rc, i); + /* XXX DO SOMETHING TO DISABLE DEVICE ? */ + break; + } + pos += phb->ioda.io_segsize; + i++; + }; + } + + /* Setup M32 segments */ + if (m32_res.start < m32_res.end) { + pcibios_resource_to_bus(dev, ®ion, &m32_res); + pos = region.start; + i = pos / phb->ioda.m32_segsize; + while(i < phb->ioda.total_pe && pos <= region.end) { + if (phb->ioda.m32_segmap[i]) { + pr_err("%s: Trying to use M32 seg #%d which is" + " already used by PE# %d\n", + pci_name(dev), i, + phb->ioda.m32_segmap[i]); + /* XXX DO SOMETHING TO DISABLE DEVICE ? */ + break; + } + phb->ioda.m32_segmap[i] = pe; + rc = opal_pci_map_pe_mmio_window(phb->opal_id, pe, + OPAL_M32_WINDOW_TYPE, + 0, i); + if (rc != OPAL_SUCCESS) { + pr_err("%s: OPAL error %d setting up mapping" + " for M32 seg# %d\n", + pci_name(dev), rc, i); + /* XXX DO SOMETHING TO DISABLE DEVICE ? */ + break; + } + pos += phb->ioda.m32_segsize; + i++; + } + } +} + +/* Check if a resource still fits in the total IO or M32 range + * for a given PHB + */ +static int __devinit pnv_ioda_resource_fit(struct pci_controller *hose, + struct resource *r) +{ + struct resource *bounds; + + if (r->flags & IORESOURCE_IO) + bounds = &hose->io_resource; + else if (r->flags & IORESOURCE_MEM) + bounds = &hose->mem_resources[0]; + else + return 1; + + if (r->start >= bounds->start && r->end <= bounds->end) + return 1; + r->flags = 0; + return 0; +} + +static void __devinit pnv_ioda_update_resources(struct pci_bus *bus) +{ + struct pci_controller *hose = pci_bus_to_host(bus); + struct pci_bus *cbus; + struct pci_dev *cdev; + unsigned int i; + + /* We used to clear all device enables here. However it looks like + * clearing MEM enable causes Obsidian (IPR SCS) to go bonkers, + * and shoot fatal errors to the PHB which in turns fences itself + * and we can't recover from that ... yet. So for now, let's leave + * the enables as-is and hope for the best. + */ + + /* Check if bus resources fit in our IO or M32 range */ + for (i = 0; bus->self && (i < 2); i++) { + struct resource *r = bus->resource[i]; + if (r && !pnv_ioda_resource_fit(hose, r)) + pr_err("%s: Bus %d resource %d disabled, no room\n", + pci_name(bus->self), bus->number, i); + } + + /* Update self if it's not a PHB */ + if (bus->self) + pci_setup_bridge(bus); + + /* Update child devices */ + list_for_each_entry(cdev, &bus->devices, bus_list) { + /* Check if resource fits, if not, disabled it */ + for (i = 0; i <= PCI_ROM_RESOURCE; i++) { + struct resource *r = &cdev->resource[i]; + if (!pnv_ioda_resource_fit(hose, r)) + pr_err("%s: Resource %d disabled, no room\n", + pci_name(cdev), i); + } + + /* Assign segments */ + pnv_ioda_setup_pe_segments(cdev); + + /* Update HW BARs */ + for (i = 0; i <= PCI_ROM_RESOURCE; i++) + pci_update_resource(cdev, i); + } + + /* Update child busses */ + list_for_each_entry(cbus, &bus->children, node) + pnv_ioda_update_resources(cbus); +} + static int __devinit pnv_ioda_alloc_pe(struct pnv_phb *phb) { unsigned long pe; @@ -106,7 +548,7 @@ static void __devinit pnv_ioda_free_pe(struct pnv_phb *phb, int pe) * but in the meantime, we need to protect them to avoid warnings */ #ifdef CONFIG_PCI_MSI -static struct pnv_ioda_pe * __devinit pnv_ioda_get_pe(struct pci_dev *dev) +static struct pnv_ioda_pe * __devinit __pnv_ioda_get_one_pe(struct pci_dev *dev) { struct pci_controller *hose = pci_bus_to_host(dev->bus); struct pnv_phb *phb = hose->private_data; @@ -118,6 +560,19 @@ static struct pnv_ioda_pe * __devinit pnv_ioda_get_pe(struct pci_dev *dev) return NULL; return &phb->ioda.pe_array[pdn->pe_number]; } + +static struct pnv_ioda_pe * __devinit pnv_ioda_get_pe(struct pci_dev *dev) +{ + struct pnv_ioda_pe *pe = __pnv_ioda_get_one_pe(dev); + + while (!pe && dev->bus->self) { + dev = dev->bus->self; + pe = __pnv_ioda_get_one_pe(dev); + if (pe) + pe = pe->bus_pe; + } + return pe; +} #endif /* CONFIG_PCI_MSI */ static int __devinit pnv_ioda_configure_pe(struct pnv_phb *phb, @@ -134,11 +589,7 @@ static int __devinit pnv_ioda_configure_pe(struct pnv_phb *phb, dcomp = OPAL_IGNORE_RID_DEVICE_NUMBER; fcomp = OPAL_IGNORE_RID_FUNCTION_NUMBER; parent = pe->pbus->self; - if (pe->flags & PNV_IODA_PE_BUS_ALL) - count = pe->pbus->busn_res.end - pe->pbus->busn_res.start + 1; - else - count = 1; - + count = pe->pbus->busn_res.end - pe->pbus->busn_res.start + 1; switch(count) { case 1: bcomp = OpalPciBusAll; break; case 2: bcomp = OpalPciBus7Bits; break; @@ -215,13 +666,13 @@ static void __devinit pnv_ioda_link_pe_by_weight(struct pnv_phb *phb, { struct pnv_ioda_pe *lpe; - list_for_each_entry(lpe, &phb->ioda.pe_dma_list, dma_link) { + list_for_each_entry(lpe, &phb->ioda.pe_list, link) { if (lpe->dma_weight < pe->dma_weight) { - list_add_tail(&pe->dma_link, &lpe->dma_link); + list_add_tail(&pe->link, &lpe->link); return; } } - list_add_tail(&pe->dma_link, &phb->ioda.pe_dma_list); + list_add_tail(&pe->link, &phb->ioda.pe_list); } static unsigned int pnv_ioda_dma_weight(struct pci_dev *dev) @@ -248,7 +699,6 @@ static unsigned int pnv_ioda_dma_weight(struct pci_dev *dev) return 10; } -#if 0 static struct pnv_ioda_pe * __devinit pnv_ioda_setup_dev_PE(struct pci_dev *dev) { struct pci_controller *hose = pci_bus_to_host(dev->bus); @@ -317,7 +767,6 @@ static struct pnv_ioda_pe * __devinit pnv_ioda_setup_dev_PE(struct pci_dev *dev) return pe; } -#endif /* Useful for SRIOV case */ static void pnv_ioda_setup_same_PE(struct pci_bus *bus, struct pnv_ioda_pe *pe) { @@ -335,33 +784,34 @@ static void pnv_ioda_setup_same_PE(struct pci_bus *bus, struct pnv_ioda_pe *pe) pdn->pcidev = dev; pdn->pe_number = pe->pe_number; pe->dma_weight += pnv_ioda_dma_weight(dev); - if ((pe->flags & PNV_IODA_PE_BUS_ALL) && dev->subordinate) + if (dev->subordinate) pnv_ioda_setup_same_PE(dev->subordinate, pe); } } -/* - * There're 2 types of PCI bus sensitive PEs: One that is compromised of - * single PCI bus. Another one that contains the primary PCI bus and its - * subordinate PCI devices and buses. The second type of PE is normally - * orgiriated by PCIe-to-PCI bridge or PLX switch downstream ports. - */ -static void __devinit pnv_ioda_setup_bus_PE(struct pci_bus *bus, int all) +static void __devinit pnv_ioda_setup_bus_PE(struct pci_dev *dev, + struct pnv_ioda_pe *ppe) { - struct pci_controller *hose = pci_bus_to_host(bus); + struct pci_controller *hose = pci_bus_to_host(dev->bus); struct pnv_phb *phb = hose->private_data; + struct pci_bus *bus = dev->subordinate; struct pnv_ioda_pe *pe; int pe_num; + if (!bus) { + pr_warning("%s: Bridge without a subordinate bus !\n", + pci_name(dev)); + return; + } pe_num = pnv_ioda_alloc_pe(phb); if (pe_num == IODA_INVALID_PE) { - pr_warning("%s: Not enough PE# available for PCI bus %04x:%02x\n", - __func__, pci_domain_nr(bus), bus->number); + pr_warning("%s: Not enough PE# available, disabling bus\n", + pci_name(dev)); return; } pe = &phb->ioda.pe_array[pe_num]; - pe->flags = (all ? PNV_IODA_PE_BUS_ALL : PNV_IODA_PE_BUS); + ppe->bus_pe = pe; pe->pbus = bus; pe->pdev = NULL; pe->tce32_seg = -1; @@ -369,12 +819,8 @@ static void __devinit pnv_ioda_setup_bus_PE(struct pci_bus *bus, int all) pe->rid = bus->busn_res.start << 8; pe->dma_weight = 0; - if (all) - pe_info(pe, "Secondary bus %d..%d associated with PE#%d\n", - bus->busn_res.start, bus->busn_res.end, pe_num); - else - pe_info(pe, "Secondary bus %d associated with PE#%d\n", - bus->busn_res.start, pe_num); + pe_info(pe, "Secondary busses %pR associated with PE\n", + &bus->busn_res); if (pnv_ioda_configure_pe(phb, pe)) { /* XXX What do we do here ? */ @@ -387,9 +833,6 @@ static void __devinit pnv_ioda_setup_bus_PE(struct pci_bus *bus, int all) /* Associate it with all child devices */ pnv_ioda_setup_same_PE(bus, pe); - /* Put PE to the list */ - list_add_tail(&pe->list, &phb->ioda.pe_list); - /* Account for one DMA PE if at least one DMA capable device exist * below the bridge */ @@ -405,33 +848,17 @@ static void __devinit pnv_ioda_setup_bus_PE(struct pci_bus *bus, int all) static void __devinit pnv_ioda_setup_PEs(struct pci_bus *bus) { struct pci_dev *dev; - - pnv_ioda_setup_bus_PE(bus, 0); + struct pnv_ioda_pe *pe; list_for_each_entry(dev, &bus->devices, bus_list) { - if (dev->subordinate) { - if (pci_pcie_type(dev) == PCI_EXP_TYPE_PCI_BRIDGE) - pnv_ioda_setup_bus_PE(dev->subordinate, 1); - else - pnv_ioda_setup_PEs(dev->subordinate); - } - } -} - -/* - * Configure PEs so that the downstream PCI buses and devices - * could have their associated PE#. Unfortunately, we didn't - * figure out the way to identify the PLX bridge yet. So we - * simply put the PCI bus and the subordinate behind the root - * port to PE# here. The game rule here is expected to be changed - * as soon as we can detected PLX bridge correctly. - */ -static void __devinit pnv_pci_ioda_setup_PEs(void) -{ - struct pci_controller *hose, *tmp; - - list_for_each_entry_safe(hose, tmp, &hose_list, list_node) { - pnv_ioda_setup_PEs(hose->bus); + pe = pnv_ioda_setup_dev_PE(dev); + if (pe == NULL) + continue; + /* Leaving the PCIe domain ... single PE# */ + if (pci_pcie_type(dev) == PCI_EXP_TYPE_PCI_BRIDGE) + pnv_ioda_setup_bus_PE(dev, pe); + else if (dev->subordinate) + pnv_ioda_setup_PEs(dev->subordinate); } } @@ -573,7 +1000,7 @@ static void __devinit pnv_ioda_setup_dma(struct pnv_phb *phb) remaining = phb->ioda.tce32_count; tw = phb->ioda.dma_weight; base = 0; - list_for_each_entry(pe, &phb->ioda.pe_dma_list, dma_link) { + list_for_each_entry(pe, &phb->ioda.pe_list, link) { if (!pe->dma_weight) continue; if (!remaining) { @@ -682,115 +1109,36 @@ static void pnv_pci_init_ioda_msis(struct pnv_phb *phb) static void pnv_pci_init_ioda_msis(struct pnv_phb *phb) { } #endif /* CONFIG_PCI_MSI */ -/* - * This function is supposed to be called on basis of PE from top - * to bottom style. So the the I/O or MMIO segment assigned to - * parent PE could be overrided by its child PEs if necessary. +/* This is the starting point of our IODA specific resource + * allocation process */ -static void __devinit pnv_ioda_setup_pe_seg(struct pci_controller *hose, - struct pnv_ioda_pe *pe) +static void __devinit pnv_pci_ioda_fixup_phb(struct pci_controller *hose) { - struct pnv_phb *phb = hose->private_data; - struct pci_bus_region region; - struct resource *res; - int i, index; - int rc; + resource_size_t size, align; + struct pci_bus *child; - /* - * NOTE: We only care PCI bus based PE for now. For PCI - * device based PE, for example SRIOV sensitive VF should - * be figured out later. - */ - BUG_ON(!(pe->flags & (PNV_IODA_PE_BUS | PNV_IODA_PE_BUS_ALL))); + /* Associate PEs per functions */ + pnv_ioda_setup_PEs(hose->bus); - pci_bus_for_each_resource(pe->pbus, res, i) { - if (!res || !res->flags || - res->start > res->end) - continue; + /* Calculate all resources */ + pnv_ioda_calc_bus(hose->bus, IORESOURCE_IO, &size, &align); + pnv_ioda_calc_bus(hose->bus, IORESOURCE_MEM, &size, &align); - if (res->flags & IORESOURCE_IO) { - region.start = res->start - phb->ioda.io_pci_base; - region.end = res->end - phb->ioda.io_pci_base; - index = region.start / phb->ioda.io_segsize; - - while (index < phb->ioda.total_pe && - region.start <= region.end) { - phb->ioda.io_segmap[index] = pe->pe_number; - rc = opal_pci_map_pe_mmio_window(phb->opal_id, - pe->pe_number, OPAL_IO_WINDOW_TYPE, 0, index); - if (rc != OPAL_SUCCESS) { - pr_err("%s: OPAL error %d when mapping IO " - "segment #%d to PE#%d\n", - __func__, rc, index, pe->pe_number); - break; - } - - region.start += phb->ioda.io_segsize; - index++; - } - } else if (res->flags & IORESOURCE_MEM) { - region.start = res->start - - hose->pci_mem_offset - - phb->ioda.m32_pci_base; - region.end = res->end - - hose->pci_mem_offset - - phb->ioda.m32_pci_base; - index = region.start / phb->ioda.m32_segsize; - - while (index < phb->ioda.total_pe && - region.start <= region.end) { - phb->ioda.m32_segmap[index] = pe->pe_number; - rc = opal_pci_map_pe_mmio_window(phb->opal_id, - pe->pe_number, OPAL_M32_WINDOW_TYPE, 0, index); - if (rc != OPAL_SUCCESS) { - pr_err("%s: OPAL error %d when mapping M32 " - "segment#%d to PE#%d", - __func__, rc, index, pe->pe_number); - break; - } - - region.start += phb->ioda.m32_segsize; - index++; - } - } - } -} + /* Apply then to HW */ + pnv_ioda_update_resources(hose->bus); -static void __devinit pnv_pci_ioda_setup_seg(void) -{ - struct pci_controller *tmp, *hose; - struct pnv_phb *phb; - struct pnv_ioda_pe *pe; - - list_for_each_entry_safe(hose, tmp, &hose_list, list_node) { - phb = hose->private_data; - list_for_each_entry(pe, &phb->ioda.pe_list, list) { - pnv_ioda_setup_pe_seg(hose, pe); - } - } -} - -static void __devinit pnv_pci_ioda_setup_DMA(void) -{ - struct pci_controller *hose, *tmp; - struct pnv_phb *phb; - - list_for_each_entry_safe(hose, tmp, &hose_list, list_node) { - pnv_ioda_setup_dma(hose->private_data); + /* Setup DMA */ + pnv_ioda_setup_dma(hose->private_data); - /* Mark the PHB initialization done */ - phb = hose->private_data; - phb->initialized = 1; + /* Configure PCI Express settings */ + list_for_each_entry(child, &hose->bus->children, node) { + struct pci_dev *self = child->self; + if (!self) + continue; + pcie_bus_configure_settings(child, self->pcie_mpss); } } -static void __devinit pnv_pci_ioda_fixup(void) -{ - pnv_pci_ioda_setup_PEs(); - pnv_pci_ioda_setup_seg(); - pnv_pci_ioda_setup_DMA(); -} - /* * Returns the alignment for I/O or memory windows for P2P * bridges. That actually depends on how PEs are segmented. @@ -834,22 +1182,10 @@ static resource_size_t pnv_pci_window_alignment(struct pci_bus *bus, */ static int __devinit pnv_pci_enable_device_hook(struct pci_dev *dev) { - struct pci_controller *hose = pci_bus_to_host(dev->bus); - struct pnv_phb *phb = hose->private_data; - struct pci_dn *pdn; - - /* The function is probably called while the PEs have - * not be created yet. For example, resource reassignment - * during PCI probe period. We just skip the check if - * PEs isn't ready. - */ - if (!phb->initialized) - return 0; + struct pci_dn *pdn = pnv_ioda_get_pdn(dev); - pdn = pnv_ioda_get_pdn(dev); if (!pdn || pdn->pe_number == IODA_INVALID_PE) return -EINVAL; - return 0; } @@ -940,9 +1276,9 @@ void __init pnv_pci_init_ioda1_phb(struct device_node *np) /* Allocate aux data & arrays */ size = _ALIGN_UP(phb->ioda.total_pe / 8, sizeof(unsigned long)); m32map_off = size; - size += phb->ioda.total_pe * sizeof(phb->ioda.m32_segmap[0]); + size += phb->ioda.total_pe; iomap_off = size; - size += phb->ioda.total_pe * sizeof(phb->ioda.io_segmap[0]); + size += phb->ioda.total_pe; pemap_off = size; size += phb->ioda.total_pe * sizeof(struct pnv_ioda_pe); aux = alloc_bootmem(size); @@ -953,7 +1289,6 @@ void __init pnv_pci_init_ioda1_phb(struct device_node *np) phb->ioda.pe_array = aux + pemap_off; set_bit(0, phb->ioda.pe_alloc); - INIT_LIST_HEAD(&phb->ioda.pe_dma_list); INIT_LIST_HEAD(&phb->ioda.pe_list); /* Calculate how many 32-bit TCE segments we have */ @@ -1002,17 +1337,15 @@ void __init pnv_pci_init_ioda1_phb(struct device_node *np) /* Setup MSI support */ pnv_pci_init_ioda_msis(phb); - /* - * We pass the PCI probe flag PCI_REASSIGN_ALL_RSRC here - * to let the PCI core do resource assignment. It's supposed - * that the PCI core will do correct I/O and MMIO alignment - * for the P2P bridge bars so that each PCI bus (excluding - * the child P2P bridges) can form individual PE. + /* We set both PCI_PROBE_ONLY and PCI_REASSIGN_ALL_RSRC. This is an + * odd combination which essentially means that we skip all resource + * fixups and assignments in the generic code, and do it all + * ourselves here */ - ppc_md.pcibios_fixup = pnv_pci_ioda_fixup; + ppc_md.pcibios_fixup_phb = pnv_pci_ioda_fixup_phb; ppc_md.pcibios_enable_device_hook = pnv_pci_enable_device_hook; ppc_md.pcibios_window_alignment = pnv_pci_window_alignment; - pci_add_flags(PCI_REASSIGN_ALL_RSRC); + pci_add_flags(PCI_PROBE_ONLY | PCI_REASSIGN_ALL_RSRC); /* Reset IODA tables to a clean state */ rc = opal_pci_reset(phb_id, OPAL_PCI_IODA_TABLE_RESET, OPAL_ASSERT_RESET); diff --git a/trunk/arch/powerpc/platforms/powernv/pci-p5ioc2.c b/trunk/arch/powerpc/platforms/powernv/pci-p5ioc2.c index 6b4bef4e9d82..264967770c3a 100644 --- a/trunk/arch/powerpc/platforms/powernv/pci-p5ioc2.c +++ b/trunk/arch/powerpc/platforms/powernv/pci-p5ioc2.c @@ -30,6 +30,7 @@ #include #include #include +#include #include "powernv.h" #include "pci.h" diff --git a/trunk/arch/powerpc/platforms/powernv/pci.c b/trunk/arch/powerpc/platforms/powernv/pci.c index c01688a1a741..be3cfc5ceabb 100644 --- a/trunk/arch/powerpc/platforms/powernv/pci.c +++ b/trunk/arch/powerpc/platforms/powernv/pci.c @@ -30,6 +30,7 @@ #include #include #include +#include #include #include "powernv.h" @@ -446,11 +447,6 @@ static void pnv_tce_free(struct iommu_table *tbl, long index, long npages) pnv_tce_invalidate(tbl, tces, tcep - 1); } -static unsigned long pnv_tce_get(struct iommu_table *tbl, long index) -{ - return ((u64 *)tbl->it_base)[index - tbl->it_offset]; -} - void pnv_pci_setup_iommu_table(struct iommu_table *tbl, void *tce_mem, u64 tce_size, u64 dma_offset) @@ -601,7 +597,6 @@ void __init pnv_pci_init(void) ppc_md.pci_dma_dev_setup = pnv_pci_dma_dev_setup; ppc_md.tce_build = pnv_tce_build; ppc_md.tce_free = pnv_tce_free; - ppc_md.tce_get = pnv_tce_get; ppc_md.pci_probe_mode = pnv_pci_probe_mode; set_pci_dma_ops(&dma_iommu_ops); diff --git a/trunk/arch/powerpc/platforms/powernv/pci.h b/trunk/arch/powerpc/platforms/powernv/pci.h index 7cfb7c883deb..8bc479634643 100644 --- a/trunk/arch/powerpc/platforms/powernv/pci.h +++ b/trunk/arch/powerpc/platforms/powernv/pci.h @@ -17,14 +17,9 @@ enum pnv_phb_model { }; #define PNV_PCI_DIAG_BUF_SIZE 4096 -#define PNV_IODA_PE_DEV (1 << 0) /* PE has single PCI device */ -#define PNV_IODA_PE_BUS (1 << 1) /* PE has primary PCI bus */ -#define PNV_IODA_PE_BUS_ALL (1 << 2) /* PE has subordinate buses */ /* Data associated with a PE, including IOMMU tracking etc.. */ struct pnv_ioda_pe { - unsigned long flags; - /* A PE can be associated with a single device or an * entire bus (& children). In the former case, pdev * is populated, in the later case, pbus is. @@ -45,6 +40,11 @@ struct pnv_ioda_pe { */ unsigned int dma_weight; + /* This is a PCI-E -> PCI-X bridge, this points to the + * corresponding bus PE + */ + struct pnv_ioda_pe *bus_pe; + /* "Base" iommu table, ie, 4K TCEs, 32-bit DMA */ int tce32_seg; int tce32_segcount; @@ -59,8 +59,7 @@ struct pnv_ioda_pe { int mve_number; /* Link in list of PE#s */ - struct list_head dma_link; - struct list_head list; + struct list_head link; }; struct pnv_phb { @@ -69,7 +68,6 @@ struct pnv_phb { enum pnv_phb_model model; u64 opal_id; void __iomem *regs; - int initialized; spinlock_t lock; #ifdef CONFIG_PCI_MSI @@ -109,11 +107,6 @@ struct pnv_phb { unsigned int *io_segmap; struct pnv_ioda_pe *pe_array; - /* Sorted list of used PE's based - * on the sequence of creation - */ - struct list_head pe_list; - /* Reverse map of PEs, will have to extend if * we are to support more than 256 PEs, indexed * bus { bus, devfn } @@ -132,7 +125,7 @@ struct pnv_phb { /* Sorted list of used PE's, sorted at * boot for resource allocation purposes */ - struct list_head pe_dma_list; + struct list_head pe_list; } ioda; }; diff --git a/trunk/arch/powerpc/platforms/ps3/htab.c b/trunk/arch/powerpc/platforms/ps3/htab.c index d00d7b0a3bda..3124cf791ebb 100644 --- a/trunk/arch/powerpc/platforms/ps3/htab.c +++ b/trunk/arch/powerpc/platforms/ps3/htab.c @@ -43,7 +43,7 @@ enum ps3_lpar_vas_id { static DEFINE_SPINLOCK(ps3_htab_lock); -static long ps3_hpte_insert(unsigned long hpte_group, unsigned long vpn, +static long ps3_hpte_insert(unsigned long hpte_group, unsigned long va, unsigned long pa, unsigned long rflags, unsigned long vflags, int psize, int ssize) { @@ -61,7 +61,7 @@ static long ps3_hpte_insert(unsigned long hpte_group, unsigned long vpn, */ vflags &= ~HPTE_V_SECONDARY; - hpte_v = hpte_encode_v(vpn, psize, ssize) | vflags | HPTE_V_VALID; + hpte_v = hpte_encode_v(va, psize, ssize) | vflags | HPTE_V_VALID; hpte_r = hpte_encode_r(ps3_mm_phys_to_lpar(pa), psize) | rflags; spin_lock_irqsave(&ps3_htab_lock, flags); @@ -75,8 +75,8 @@ static long ps3_hpte_insert(unsigned long hpte_group, unsigned long vpn, if (result) { /* all entries bolted !*/ - pr_info("%s:result=%d vpn=%lx pa=%lx ix=%lx v=%llx r=%llx\n", - __func__, result, vpn, pa, hpte_group, hpte_v, hpte_r); + pr_info("%s:result=%d va=%lx pa=%lx ix=%lx v=%llx r=%llx\n", + __func__, result, va, pa, hpte_group, hpte_v, hpte_r); BUG(); } @@ -107,7 +107,7 @@ static long ps3_hpte_remove(unsigned long hpte_group) } static long ps3_hpte_updatepp(unsigned long slot, unsigned long newpp, - unsigned long vpn, int psize, int ssize, int local) + unsigned long va, int psize, int ssize, int local) { int result; u64 hpte_v, want_v, hpte_rs; @@ -115,7 +115,7 @@ static long ps3_hpte_updatepp(unsigned long slot, unsigned long newpp, unsigned long flags; long ret; - want_v = hpte_encode_v(vpn, psize, ssize); + want_v = hpte_encode_v(va, psize, ssize); spin_lock_irqsave(&ps3_htab_lock, flags); @@ -125,8 +125,8 @@ static long ps3_hpte_updatepp(unsigned long slot, unsigned long newpp, &hpte_rs); if (result) { - pr_info("%s: res=%d read vpn=%lx slot=%lx psize=%d\n", - __func__, result, vpn, slot, psize); + pr_info("%s: res=%d read va=%lx slot=%lx psize=%d\n", + __func__, result, va, slot, psize); BUG(); } @@ -159,7 +159,7 @@ static void ps3_hpte_updateboltedpp(unsigned long newpp, unsigned long ea, panic("ps3_hpte_updateboltedpp() not implemented"); } -static void ps3_hpte_invalidate(unsigned long slot, unsigned long vpn, +static void ps3_hpte_invalidate(unsigned long slot, unsigned long va, int psize, int ssize, int local) { unsigned long flags; @@ -170,8 +170,8 @@ static void ps3_hpte_invalidate(unsigned long slot, unsigned long vpn, result = lv1_write_htab_entry(PS3_LPAR_VAS_ID_CURRENT, slot, 0, 0); if (result) { - pr_info("%s: res=%d vpn=%lx slot=%lx psize=%d\n", - __func__, result, vpn, slot, psize); + pr_info("%s: res=%d va=%lx slot=%lx psize=%d\n", + __func__, result, va, slot, psize); BUG(); } diff --git a/trunk/arch/powerpc/platforms/ps3/setup.c b/trunk/arch/powerpc/platforms/ps3/setup.c index 3f509f86432c..2d664c5a83b0 100644 --- a/trunk/arch/powerpc/platforms/ps3/setup.c +++ b/trunk/arch/powerpc/platforms/ps3/setup.c @@ -184,15 +184,11 @@ early_param("ps3flash", early_parse_ps3flash); #define prealloc_ps3flash_bounce_buffer() do { } while (0) #endif -static int ps3_set_dabr(unsigned long dabr, unsigned long dabrx) +static int ps3_set_dabr(unsigned long dabr) { - /* Have to set at least one bit in the DABRX */ - if (dabrx == 0 && dabr == 0) - dabrx = DABRX_USER; - /* hypervisor only allows us to set BTI, Kernel and user */ - dabrx &= DABRX_BTI | DABRX_KERNEL | DABRX_USER; + enum {DABR_USER = 1, DABR_KERNEL = 2,}; - return lv1_set_dabr(dabr, dabrx) ? -1 : 0; + return lv1_set_dabr(dabr, DABR_KERNEL | DABR_USER) ? -1 : 0; } static void __init ps3_setup_arch(void) diff --git a/trunk/arch/powerpc/platforms/pseries/Makefile b/trunk/arch/powerpc/platforms/pseries/Makefile index 890622b87c8f..c222189f5bb2 100644 --- a/trunk/arch/powerpc/platforms/pseries/Makefile +++ b/trunk/arch/powerpc/platforms/pseries/Makefile @@ -6,9 +6,8 @@ obj-y := lpar.o hvCall.o nvram.o reconfig.o \ firmware.o power.o dlpar.o mobility.o obj-$(CONFIG_SMP) += smp.o obj-$(CONFIG_SCANLOG) += scanlog.o -obj-$(CONFIG_EEH) += eeh.o eeh_pe.o eeh_dev.o eeh_cache.o \ - eeh_driver.o eeh_event.o eeh_sysfs.o \ - eeh_pseries.o +obj-$(CONFIG_EEH) += eeh.o eeh_dev.o eeh_cache.o eeh_driver.o \ + eeh_event.o eeh_sysfs.o eeh_pseries.o obj-$(CONFIG_KEXEC) += kexec.o obj-$(CONFIG_PCI) += pci.o pci_dlpar.o obj-$(CONFIG_PSERIES_MSI) += msi.o diff --git a/trunk/arch/powerpc/platforms/pseries/eeh.c b/trunk/arch/powerpc/platforms/pseries/eeh.c index 9a04322b1736..ecd394cf34e6 100644 --- a/trunk/arch/powerpc/platforms/pseries/eeh.c +++ b/trunk/arch/powerpc/platforms/pseries/eeh.c @@ -92,20 +92,6 @@ struct eeh_ops *eeh_ops = NULL; int eeh_subsystem_enabled; EXPORT_SYMBOL(eeh_subsystem_enabled); -/* - * EEH probe mode support. The intention is to support multiple - * platforms for EEH. Some platforms like pSeries do PCI emunation - * based on device tree. However, other platforms like powernv probe - * PCI devices from hardware. The flag is used to distinguish that. - * In addition, struct eeh_ops::probe would be invoked for particular - * OF node or PCI device so that the corresponding PE would be created - * there. - */ -int eeh_probe_mode; - -/* Global EEH mutex */ -DEFINE_MUTEX(eeh_mutex); - /* Lock to avoid races due to multiple reports of an error */ static DEFINE_RAW_SPINLOCK(confirm_error_lock); @@ -218,12 +204,22 @@ static size_t eeh_gather_pci_data(struct eeh_dev *edev, char * buf, size_t len) } } + /* Gather status on devices under the bridge */ + if (dev->class >> 16 == PCI_BASE_CLASS_BRIDGE) { + struct device_node *child; + + for_each_child_of_node(dn, child) { + if (of_node_to_eeh_dev(child)) + n += eeh_gather_pci_data(of_node_to_eeh_dev(child), buf+n, len-n); + } + } + return n; } /** * eeh_slot_error_detail - Generate combined log including driver log and error log - * @pe: EEH PE + * @edev: device to report error log for * @severity: temporary or permanent error log * * This routine should be called to generate the combined log, which @@ -231,22 +227,17 @@ static size_t eeh_gather_pci_data(struct eeh_dev *edev, char * buf, size_t len) * out from the config space of the corresponding PCI device, while * the error log is fetched through platform dependent function call. */ -void eeh_slot_error_detail(struct eeh_pe *pe, int severity) +void eeh_slot_error_detail(struct eeh_dev *edev, int severity) { size_t loglen = 0; - struct eeh_dev *edev; - - eeh_pci_enable(pe, EEH_OPT_THAW_MMIO); - eeh_ops->configure_bridge(pe); - eeh_pe_restore_bars(pe); - pci_regs_buf[0] = 0; - eeh_pe_for_each_dev(pe, edev) { - loglen += eeh_gather_pci_data(edev, pci_regs_buf, - EEH_PCI_REGS_LOG_LEN); - } - eeh_ops->get_log(pe, severity, pci_regs_buf, loglen); + eeh_pci_enable(edev, EEH_OPT_THAW_MMIO); + eeh_ops->configure_bridge(eeh_dev_to_of_node(edev)); + eeh_restore_bars(edev); + loglen = eeh_gather_pci_data(edev, pci_regs_buf, EEH_PCI_REGS_LOG_LEN); + + eeh_ops->get_log(eeh_dev_to_of_node(edev), severity, pci_regs_buf, loglen); } /** @@ -270,8 +261,126 @@ static inline unsigned long eeh_token_to_phys(unsigned long token) } /** - * eeh_dev_check_failure - Check if all 1's data is due to EEH slot freeze - * @edev: eeh device + * eeh_find_device_pe - Retrieve the PE for the given device + * @dn: device node + * + * Return the PE under which this device lies + */ +struct device_node *eeh_find_device_pe(struct device_node *dn) +{ + while (dn->parent && of_node_to_eeh_dev(dn->parent) && + (of_node_to_eeh_dev(dn->parent)->mode & EEH_MODE_SUPPORTED)) { + dn = dn->parent; + } + return dn; +} + +/** + * __eeh_mark_slot - Mark all child devices as failed + * @parent: parent device + * @mode_flag: failure flag + * + * Mark all devices that are children of this device as failed. + * Mark the device driver too, so that it can see the failure + * immediately; this is critical, since some drivers poll + * status registers in interrupts ... If a driver is polling, + * and the slot is frozen, then the driver can deadlock in + * an interrupt context, which is bad. + */ +static void __eeh_mark_slot(struct device_node *parent, int mode_flag) +{ + struct device_node *dn; + + for_each_child_of_node(parent, dn) { + if (of_node_to_eeh_dev(dn)) { + /* Mark the pci device driver too */ + struct pci_dev *dev = of_node_to_eeh_dev(dn)->pdev; + + of_node_to_eeh_dev(dn)->mode |= mode_flag; + + if (dev && dev->driver) + dev->error_state = pci_channel_io_frozen; + + __eeh_mark_slot(dn, mode_flag); + } + } +} + +/** + * eeh_mark_slot - Mark the indicated device and its children as failed + * @dn: parent device + * @mode_flag: failure flag + * + * Mark the indicated device and its child devices as failed. + * The device drivers are marked as failed as well. + */ +void eeh_mark_slot(struct device_node *dn, int mode_flag) +{ + struct pci_dev *dev; + dn = eeh_find_device_pe(dn); + + /* Back up one, since config addrs might be shared */ + if (!pcibios_find_pci_bus(dn) && of_node_to_eeh_dev(dn->parent)) + dn = dn->parent; + + of_node_to_eeh_dev(dn)->mode |= mode_flag; + + /* Mark the pci device too */ + dev = of_node_to_eeh_dev(dn)->pdev; + if (dev) + dev->error_state = pci_channel_io_frozen; + + __eeh_mark_slot(dn, mode_flag); +} + +/** + * __eeh_clear_slot - Clear failure flag for the child devices + * @parent: parent device + * @mode_flag: flag to be cleared + * + * Clear failure flag for the child devices. + */ +static void __eeh_clear_slot(struct device_node *parent, int mode_flag) +{ + struct device_node *dn; + + for_each_child_of_node(parent, dn) { + if (of_node_to_eeh_dev(dn)) { + of_node_to_eeh_dev(dn)->mode &= ~mode_flag; + of_node_to_eeh_dev(dn)->check_count = 0; + __eeh_clear_slot(dn, mode_flag); + } + } +} + +/** + * eeh_clear_slot - Clear failure flag for the indicated device and its children + * @dn: parent device + * @mode_flag: flag to be cleared + * + * Clear failure flag for the indicated device and its children. + */ +void eeh_clear_slot(struct device_node *dn, int mode_flag) +{ + unsigned long flags; + raw_spin_lock_irqsave(&confirm_error_lock, flags); + + dn = eeh_find_device_pe(dn); + + /* Back up one, since config addrs might be shared */ + if (!pcibios_find_pci_bus(dn) && of_node_to_eeh_dev(dn->parent)) + dn = dn->parent; + + of_node_to_eeh_dev(dn)->mode &= ~mode_flag; + of_node_to_eeh_dev(dn)->check_count = 0; + __eeh_clear_slot(dn, mode_flag); + raw_spin_unlock_irqrestore(&confirm_error_lock, flags); +} + +/** + * eeh_dn_check_failure - Check if all 1's data is due to EEH slot freeze + * @dn: device node + * @dev: pci device, if known * * Check for an EEH failure for the given device node. Call this * routine if the result of a read was all 0xff's and you want to @@ -283,13 +392,11 @@ static inline unsigned long eeh_token_to_phys(unsigned long token) * * It is safe to call this routine in an interrupt context. */ -int eeh_dev_check_failure(struct eeh_dev *edev) +int eeh_dn_check_failure(struct device_node *dn, struct pci_dev *dev) { int ret; unsigned long flags; - struct device_node *dn; - struct pci_dev *dev; - struct eeh_pe *pe; + struct eeh_dev *edev; int rc = 0; const char *location; @@ -298,23 +405,23 @@ int eeh_dev_check_failure(struct eeh_dev *edev) if (!eeh_subsystem_enabled) return 0; - if (!edev) { + if (!dn) { eeh_stats.no_dn++; return 0; } - dn = eeh_dev_to_of_node(edev); - dev = eeh_dev_to_pci_dev(edev); - pe = edev->pe; + dn = eeh_find_device_pe(dn); + edev = of_node_to_eeh_dev(dn); /* Access to IO BARs might get this far and still not want checking. */ - if (!pe) { + if (!(edev->mode & EEH_MODE_SUPPORTED) || + edev->mode & EEH_MODE_NOCHECK) { eeh_stats.ignored_check++; - pr_debug("EEH: Ignored check for %s %s\n", - eeh_pci_name(dev), dn->full_name); + pr_debug("EEH: Ignored check (%x) for %s %s\n", + edev->mode, eeh_pci_name(dev), dn->full_name); return 0; } - if (!pe->addr && !pe->config_addr) { + if (!edev->config_addr && !edev->pe_config_addr) { eeh_stats.no_cfg_addr++; return 0; } @@ -327,13 +434,13 @@ int eeh_dev_check_failure(struct eeh_dev *edev) */ raw_spin_lock_irqsave(&confirm_error_lock, flags); rc = 1; - if (pe->state & EEH_PE_ISOLATED) { - pe->check_count++; - if (pe->check_count % EEH_MAX_FAILS == 0) { + if (edev->mode & EEH_MODE_ISOLATED) { + edev->check_count++; + if (edev->check_count % EEH_MAX_FAILS == 0) { location = of_get_property(dn, "ibm,loc-code", NULL); printk(KERN_ERR "EEH: %d reads ignored for recovering device at " "location=%s driver=%s pci addr=%s\n", - pe->check_count, location, + edev->check_count, location, eeh_driver_name(dev), eeh_pci_name(dev)); printk(KERN_ERR "EEH: Might be infinite loop in %s driver\n", eeh_driver_name(dev)); @@ -349,7 +456,7 @@ int eeh_dev_check_failure(struct eeh_dev *edev) * function zero of a multi-function device. * In any case they must share a common PHB. */ - ret = eeh_ops->get_state(pe, NULL); + ret = eeh_ops->get_state(dn, NULL); /* Note that config-io to empty slots may fail; * they are empty when they don't have children. @@ -362,7 +469,7 @@ int eeh_dev_check_failure(struct eeh_dev *edev) (ret & (EEH_STATE_MMIO_ACTIVE | EEH_STATE_DMA_ACTIVE)) == (EEH_STATE_MMIO_ACTIVE | EEH_STATE_DMA_ACTIVE)) { eeh_stats.false_positives++; - pe->false_positives++; + edev->false_positives ++; rc = 0; goto dn_unlock; } @@ -373,10 +480,10 @@ int eeh_dev_check_failure(struct eeh_dev *edev) * with other functions on this device, and functions under * bridges. */ - eeh_pe_state_mark(pe, EEH_PE_ISOLATED); + eeh_mark_slot(dn, EEH_MODE_ISOLATED); raw_spin_unlock_irqrestore(&confirm_error_lock, flags); - eeh_send_failure_event(pe); + eeh_send_failure_event(edev); /* Most EEH events are due to device driver bugs. Having * a stack trace will help the device-driver authors figure @@ -390,7 +497,7 @@ int eeh_dev_check_failure(struct eeh_dev *edev) return rc; } -EXPORT_SYMBOL_GPL(eeh_dev_check_failure); +EXPORT_SYMBOL_GPL(eeh_dn_check_failure); /** * eeh_check_failure - Check if all 1's data is due to EEH slot freeze @@ -407,19 +514,21 @@ EXPORT_SYMBOL_GPL(eeh_dev_check_failure); unsigned long eeh_check_failure(const volatile void __iomem *token, unsigned long val) { unsigned long addr; - struct eeh_dev *edev; + struct pci_dev *dev; + struct device_node *dn; /* Finding the phys addr + pci device; this is pretty quick. */ addr = eeh_token_to_phys((unsigned long __force) token); - edev = eeh_addr_cache_get_dev(addr); - if (!edev) { + dev = pci_addr_cache_get_device(addr); + if (!dev) { eeh_stats.no_device++; return val; } - eeh_dev_check_failure(edev); + dn = pci_device_to_OF_node(dev); + eeh_dn_check_failure(dn, dev); - pci_dev_put(eeh_dev_to_pci_dev(edev)); + pci_dev_put(dev); return val; } @@ -428,22 +537,23 @@ EXPORT_SYMBOL(eeh_check_failure); /** * eeh_pci_enable - Enable MMIO or DMA transfers for this slot - * @pe: EEH PE + * @edev: pci device node * * This routine should be called to reenable frozen MMIO or DMA * so that it would work correctly again. It's useful while doing * recovery or log collection on the indicated device. */ -int eeh_pci_enable(struct eeh_pe *pe, int function) +int eeh_pci_enable(struct eeh_dev *edev, int function) { int rc; + struct device_node *dn = eeh_dev_to_of_node(edev); - rc = eeh_ops->set_option(pe, function); + rc = eeh_ops->set_option(dn, function); if (rc) - pr_warning("%s: Unexpected state change %d on PHB#%d-PE#%x, err=%d\n", - __func__, function, pe->phb->global_number, pe->addr, rc); + printk(KERN_WARNING "EEH: Unexpected state change %d, err=%d dn=%s\n", + function, rc, dn->full_name); - rc = eeh_ops->wait_state(pe, PCI_BUS_RESET_WAIT_MSEC); + rc = eeh_ops->wait_state(dn, PCI_BUS_RESET_WAIT_MSEC); if (rc > 0 && (rc & EEH_STATE_MMIO_ENABLED) && (function == EEH_OPT_THAW_MMIO)) return 0; @@ -461,24 +571,17 @@ int eeh_pci_enable(struct eeh_pe *pe, int function) */ int pcibios_set_pcie_reset_state(struct pci_dev *dev, enum pcie_reset_state state) { - struct eeh_dev *edev = pci_dev_to_eeh_dev(dev); - struct eeh_pe *pe = edev->pe; - - if (!pe) { - pr_err("%s: No PE found on PCI device %s\n", - __func__, pci_name(dev)); - return -EINVAL; - } + struct device_node *dn = pci_device_to_OF_node(dev); switch (state) { case pcie_deassert_reset: - eeh_ops->reset(pe, EEH_RESET_DEACTIVATE); + eeh_ops->reset(dn, EEH_RESET_DEACTIVATE); break; case pcie_hot_reset: - eeh_ops->reset(pe, EEH_RESET_HOT); + eeh_ops->reset(dn, EEH_RESET_HOT); break; case pcie_warm_reset: - eeh_ops->reset(pe, EEH_RESET_FUNDAMENTAL); + eeh_ops->reset(dn, EEH_RESET_FUNDAMENTAL); break; default: return -EINVAL; @@ -488,37 +591,66 @@ int pcibios_set_pcie_reset_state(struct pci_dev *dev, enum pcie_reset_state stat } /** - * eeh_set_pe_freset - Check the required reset for the indicated device - * @data: EEH device - * @flag: return value + * __eeh_set_pe_freset - Check the required reset for child devices + * @parent: parent device + * @freset: return value + * + * Each device might have its preferred reset type: fundamental or + * hot reset. The routine is used to collect the information from + * the child devices so that they could be reset accordingly. + */ +void __eeh_set_pe_freset(struct device_node *parent, unsigned int *freset) +{ + struct device_node *dn; + + for_each_child_of_node(parent, dn) { + if (of_node_to_eeh_dev(dn)) { + struct pci_dev *dev = of_node_to_eeh_dev(dn)->pdev; + + if (dev && dev->driver) + *freset |= dev->needs_freset; + + __eeh_set_pe_freset(dn, freset); + } + } +} + +/** + * eeh_set_pe_freset - Check the required reset for the indicated device and its children + * @dn: parent device + * @freset: return value * * Each device might have its preferred reset type: fundamental or * hot reset. The routine is used to collected the information for * the indicated device and its children so that the bunch of the * devices could be reset properly. */ -static void *eeh_set_dev_freset(void *data, void *flag) +void eeh_set_pe_freset(struct device_node *dn, unsigned int *freset) { struct pci_dev *dev; - unsigned int *freset = (unsigned int *)flag; - struct eeh_dev *edev = (struct eeh_dev *)data; + dn = eeh_find_device_pe(dn); + + /* Back up one, since config addrs might be shared */ + if (!pcibios_find_pci_bus(dn) && of_node_to_eeh_dev(dn->parent)) + dn = dn->parent; - dev = eeh_dev_to_pci_dev(edev); + dev = of_node_to_eeh_dev(dn)->pdev; if (dev) *freset |= dev->needs_freset; - return NULL; + __eeh_set_pe_freset(dn, freset); } /** * eeh_reset_pe_once - Assert the pci #RST line for 1/4 second - * @pe: EEH PE + * @edev: pci device node to be reset. * * Assert the PCI #RST line for 1/4 second. */ -static void eeh_reset_pe_once(struct eeh_pe *pe) +static void eeh_reset_pe_once(struct eeh_dev *edev) { unsigned int freset = 0; + struct device_node *dn = eeh_dev_to_of_node(edev); /* Determine type of EEH reset required for * Partitionable Endpoint, a hot-reset (1) @@ -526,12 +658,12 @@ static void eeh_reset_pe_once(struct eeh_pe *pe) * A fundamental reset required by any device under * Partitionable Endpoint trumps hot-reset. */ - eeh_pe_dev_traverse(pe, eeh_set_dev_freset, &freset); + eeh_set_pe_freset(dn, &freset); if (freset) - eeh_ops->reset(pe, EEH_RESET_FUNDAMENTAL); + eeh_ops->reset(dn, EEH_RESET_FUNDAMENTAL); else - eeh_ops->reset(pe, EEH_RESET_HOT); + eeh_ops->reset(dn, EEH_RESET_HOT); /* The PCI bus requires that the reset be held high for at least * a 100 milliseconds. We wait a bit longer 'just in case'. @@ -543,9 +675,9 @@ static void eeh_reset_pe_once(struct eeh_pe *pe) * pci slot reset line is dropped. Make sure we don't miss * these, and clear the flag now. */ - eeh_pe_state_clear(pe, EEH_PE_ISOLATED); + eeh_clear_slot(dn, EEH_MODE_ISOLATED); - eeh_ops->reset(pe, EEH_RESET_DEACTIVATE); + eeh_ops->reset(dn, EEH_RESET_DEACTIVATE); /* After a PCI slot has been reset, the PCI Express spec requires * a 1.5 second idle time for the bus to stabilize, before starting @@ -557,36 +689,116 @@ static void eeh_reset_pe_once(struct eeh_pe *pe) /** * eeh_reset_pe - Reset the indicated PE - * @pe: EEH PE + * @edev: PCI device associated EEH device * * This routine should be called to reset indicated device, including * PE. A PE might include multiple PCI devices and sometimes PCI bridges * might be involved as well. */ -int eeh_reset_pe(struct eeh_pe *pe) +int eeh_reset_pe(struct eeh_dev *edev) { int i, rc; + struct device_node *dn = eeh_dev_to_of_node(edev); /* Take three shots at resetting the bus */ for (i=0; i<3; i++) { - eeh_reset_pe_once(pe); + eeh_reset_pe_once(edev); - rc = eeh_ops->wait_state(pe, PCI_BUS_RESET_WAIT_MSEC); + rc = eeh_ops->wait_state(dn, PCI_BUS_RESET_WAIT_MSEC); if (rc == (EEH_STATE_MMIO_ACTIVE | EEH_STATE_DMA_ACTIVE)) return 0; if (rc < 0) { - pr_err("%s: Unrecoverable slot failure on PHB#%d-PE#%x", - __func__, pe->phb->global_number, pe->addr); + printk(KERN_ERR "EEH: unrecoverable slot failure %s\n", + dn->full_name); return -1; } - pr_err("EEH: bus reset %d failed on PHB#%d-PE#%x, rc=%d\n", - i+1, pe->phb->global_number, pe->addr, rc); + printk(KERN_ERR "EEH: bus reset %d failed on slot %s, rc=%d\n", + i+1, dn->full_name, rc); } return -1; } +/** Save and restore of PCI BARs + * + * Although firmware will set up BARs during boot, it doesn't + * set up device BAR's after a device reset, although it will, + * if requested, set up bridge configuration. Thus, we need to + * configure the PCI devices ourselves. + */ + +/** + * eeh_restore_one_device_bars - Restore the Base Address Registers for one device + * @edev: PCI device associated EEH device + * + * Loads the PCI configuration space base address registers, + * the expansion ROM base address, the latency timer, and etc. + * from the saved values in the device node. + */ +static inline void eeh_restore_one_device_bars(struct eeh_dev *edev) +{ + int i; + u32 cmd; + struct device_node *dn = eeh_dev_to_of_node(edev); + + if (!edev->phb) + return; + + for (i=4; i<10; i++) { + eeh_ops->write_config(dn, i*4, 4, edev->config_space[i]); + } + + /* 12 == Expansion ROM Address */ + eeh_ops->write_config(dn, 12*4, 4, edev->config_space[12]); + +#define BYTE_SWAP(OFF) (8*((OFF)/4)+3-(OFF)) +#define SAVED_BYTE(OFF) (((u8 *)(edev->config_space))[BYTE_SWAP(OFF)]) + + eeh_ops->write_config(dn, PCI_CACHE_LINE_SIZE, 1, + SAVED_BYTE(PCI_CACHE_LINE_SIZE)); + + eeh_ops->write_config(dn, PCI_LATENCY_TIMER, 1, + SAVED_BYTE(PCI_LATENCY_TIMER)); + + /* max latency, min grant, interrupt pin and line */ + eeh_ops->write_config(dn, 15*4, 4, edev->config_space[15]); + + /* Restore PERR & SERR bits, some devices require it, + * don't touch the other command bits + */ + eeh_ops->read_config(dn, PCI_COMMAND, 4, &cmd); + if (edev->config_space[1] & PCI_COMMAND_PARITY) + cmd |= PCI_COMMAND_PARITY; + else + cmd &= ~PCI_COMMAND_PARITY; + if (edev->config_space[1] & PCI_COMMAND_SERR) + cmd |= PCI_COMMAND_SERR; + else + cmd &= ~PCI_COMMAND_SERR; + eeh_ops->write_config(dn, PCI_COMMAND, 4, cmd); +} + +/** + * eeh_restore_bars - Restore the PCI config space info + * @edev: EEH device + * + * This routine performs a recursive walk to the children + * of this device as well. + */ +void eeh_restore_bars(struct eeh_dev *edev) +{ + struct device_node *dn; + if (!edev) + return; + + if ((edev->mode & EEH_MODE_SUPPORTED) && !IS_BRIDGE(edev->class_code)) + eeh_restore_one_device_bars(edev); + + for_each_child_of_node(eeh_dev_to_of_node(edev), dn) + eeh_restore_bars(of_node_to_eeh_dev(dn)); +} + /** * eeh_save_bars - Save device bars * @edev: PCI device associated EEH device @@ -596,7 +808,7 @@ int eeh_reset_pe(struct eeh_pe *pe) * PCI devices are added individually; but, for the restore, * an entire slot is reset at a time. */ -void eeh_save_bars(struct eeh_dev *edev) +static void eeh_save_bars(struct eeh_dev *edev) { int i; struct device_node *dn; @@ -609,6 +821,102 @@ void eeh_save_bars(struct eeh_dev *edev) eeh_ops->read_config(dn, i * 4, 4, &edev->config_space[i]); } +/** + * eeh_early_enable - Early enable EEH on the indicated device + * @dn: device node + * @data: BUID + * + * Enable EEH functionality on the specified PCI device. The function + * is expected to be called before real PCI probing is done. However, + * the PHBs have been initialized at this point. + */ +static void *eeh_early_enable(struct device_node *dn, void *data) +{ + int ret; + const u32 *class_code = of_get_property(dn, "class-code", NULL); + const u32 *vendor_id = of_get_property(dn, "vendor-id", NULL); + const u32 *device_id = of_get_property(dn, "device-id", NULL); + const u32 *regs; + int enable; + struct eeh_dev *edev = of_node_to_eeh_dev(dn); + + edev->class_code = 0; + edev->mode = 0; + edev->check_count = 0; + edev->freeze_count = 0; + edev->false_positives = 0; + + if (!of_device_is_available(dn)) + return NULL; + + /* Ignore bad nodes. */ + if (!class_code || !vendor_id || !device_id) + return NULL; + + /* There is nothing to check on PCI to ISA bridges */ + if (dn->type && !strcmp(dn->type, "isa")) { + edev->mode |= EEH_MODE_NOCHECK; + return NULL; + } + edev->class_code = *class_code; + + /* Ok... see if this device supports EEH. Some do, some don't, + * and the only way to find out is to check each and every one. + */ + regs = of_get_property(dn, "reg", NULL); + if (regs) { + /* First register entry is addr (00BBSS00) */ + /* Try to enable eeh */ + ret = eeh_ops->set_option(dn, EEH_OPT_ENABLE); + + enable = 0; + if (ret == 0) { + edev->config_addr = regs[0]; + + /* If the newer, better, ibm,get-config-addr-info is supported, + * then use that instead. + */ + edev->pe_config_addr = eeh_ops->get_pe_addr(dn); + + /* Some older systems (Power4) allow the + * ibm,set-eeh-option call to succeed even on nodes + * where EEH is not supported. Verify support + * explicitly. + */ + ret = eeh_ops->get_state(dn, NULL); + if (ret > 0 && ret != EEH_STATE_NOT_SUPPORT) + enable = 1; + } + + if (enable) { + eeh_subsystem_enabled = 1; + edev->mode |= EEH_MODE_SUPPORTED; + + pr_debug("EEH: %s: eeh enabled, config=%x pe_config=%x\n", + dn->full_name, edev->config_addr, + edev->pe_config_addr); + } else { + + /* This device doesn't support EEH, but it may have an + * EEH parent, in which case we mark it as supported. + */ + if (dn->parent && of_node_to_eeh_dev(dn->parent) && + (of_node_to_eeh_dev(dn->parent)->mode & EEH_MODE_SUPPORTED)) { + /* Parent supports EEH. */ + edev->mode |= EEH_MODE_SUPPORTED; + edev->config_addr = of_node_to_eeh_dev(dn->parent)->config_addr; + return NULL; + } + } + } else { + printk(KERN_WARNING "EEH: %s: unable to get reg property.\n", + dn->full_name); + } + + eeh_save_bars(edev); + return NULL; +} + /** * eeh_ops_register - Register platform dependent EEH operations * @ops: platform dependent EEH operations @@ -674,7 +982,7 @@ int __exit eeh_ops_unregister(const char *name) * Even if force-off is set, the EEH hardware is still enabled, so that * newer systems can boot. */ -static int __init eeh_init(void) +void __init eeh_init(void) { struct pci_controller *hose, *tmp; struct device_node *phb; @@ -684,34 +992,27 @@ static int __init eeh_init(void) if (!eeh_ops) { pr_warning("%s: Platform EEH operation not found\n", __func__); - return -EEXIST; + return; } else if ((ret = eeh_ops->init())) { pr_warning("%s: Failed to call platform init function (%d)\n", __func__, ret); - return ret; + return; } raw_spin_lock_init(&confirm_error_lock); /* Enable EEH for all adapters */ - if (eeh_probe_mode_devtree()) { - list_for_each_entry_safe(hose, tmp, - &hose_list, list_node) { - phb = hose->dn; - traverse_pci_devices(phb, eeh_ops->of_probe, NULL); - } + list_for_each_entry_safe(hose, tmp, &hose_list, list_node) { + phb = hose->dn; + traverse_pci_devices(phb, eeh_early_enable, NULL); } if (eeh_subsystem_enabled) - pr_info("EEH: PCI Enhanced I/O Error Handling Enabled\n"); + printk(KERN_INFO "EEH: PCI Enhanced I/O Error Handling Enabled\n"); else - pr_warning("EEH: No capable adapters found\n"); - - return ret; + printk(KERN_WARNING "EEH: No capable adapters found\n"); } -core_initcall_sync(eeh_init); - /** * eeh_add_device_early - Enable EEH for the indicated device_node * @dn: device node for which to set up EEH @@ -728,7 +1029,7 @@ static void eeh_add_device_early(struct device_node *dn) { struct pci_controller *phb; - if (!of_node_to_eeh_dev(dn)) + if (!dn || !of_node_to_eeh_dev(dn)) return; phb = of_node_to_eeh_dev(dn)->phb; @@ -736,8 +1037,7 @@ static void eeh_add_device_early(struct device_node *dn) if (NULL == phb || 0 == phb->buid) return; - /* FIXME: hotplug support on POWERNV */ - eeh_ops->of_probe(dn, NULL); + eeh_early_enable(dn, NULL); } /** @@ -787,7 +1087,7 @@ static void eeh_add_device_late(struct pci_dev *dev) edev->pdev = dev; dev->dev.archdata.edev = edev; - eeh_addr_cache_insert_dev(dev); + pci_addr_cache_insert_device(dev); eeh_sysfs_add_device(dev); } @@ -817,7 +1117,6 @@ EXPORT_SYMBOL_GPL(eeh_add_device_tree_late); /** * eeh_remove_device - Undo EEH setup for the indicated pci device * @dev: pci device to be removed - * @purge_pe: remove the PE or not * * This routine should be called when a device is removed from * a running system (e.g. by hotplug or dlpar). It unregisters @@ -825,7 +1124,7 @@ EXPORT_SYMBOL_GPL(eeh_add_device_tree_late); * this device will no longer be detected after this call; thus, * i/o errors affecting this slot may leave this device unusable. */ -static void eeh_remove_device(struct pci_dev *dev, int purge_pe) +static void eeh_remove_device(struct pci_dev *dev) { struct eeh_dev *edev; @@ -844,30 +1143,28 @@ static void eeh_remove_device(struct pci_dev *dev, int purge_pe) dev->dev.archdata.edev = NULL; pci_dev_put(dev); - eeh_rmv_from_parent_pe(edev, purge_pe); - eeh_addr_cache_rmv_dev(dev); + pci_addr_cache_remove_device(dev); eeh_sysfs_remove_device(dev); } /** * eeh_remove_bus_device - Undo EEH setup for the indicated PCI device * @dev: PCI device - * @purge_pe: remove the corresponding PE or not * * This routine must be called when a device is removed from the * running system through hotplug or dlpar. The corresponding * PCI address cache will be removed. */ -void eeh_remove_bus_device(struct pci_dev *dev, int purge_pe) +void eeh_remove_bus_device(struct pci_dev *dev) { struct pci_bus *bus = dev->subordinate; struct pci_dev *child, *tmp; - eeh_remove_device(dev, purge_pe); + eeh_remove_device(dev); if (bus && dev->hdr_type == PCI_HEADER_TYPE_BRIDGE) { list_for_each_entry_safe(child, tmp, &bus->devices, bus_list) - eeh_remove_bus_device(child, purge_pe); + eeh_remove_bus_device(child); } } EXPORT_SYMBOL_GPL(eeh_remove_bus_device); diff --git a/trunk/arch/powerpc/platforms/pseries/eeh_cache.c b/trunk/arch/powerpc/platforms/pseries/eeh_cache.c index 5a4c87903057..e5ae1c687c66 100644 --- a/trunk/arch/powerpc/platforms/pseries/eeh_cache.c +++ b/trunk/arch/powerpc/platforms/pseries/eeh_cache.c @@ -50,7 +50,6 @@ struct pci_io_addr_range { struct rb_node rb_node; unsigned long addr_lo; unsigned long addr_hi; - struct eeh_dev *edev; struct pci_dev *pcidev; unsigned int flags; }; @@ -60,7 +59,7 @@ static struct pci_io_addr_cache { spinlock_t piar_lock; } pci_io_addr_cache_root; -static inline struct eeh_dev *__eeh_addr_cache_get_device(unsigned long addr) +static inline struct pci_dev *__pci_addr_cache_get_device(unsigned long addr) { struct rb_node *n = pci_io_addr_cache_root.rb_root.rb_node; @@ -75,7 +74,7 @@ static inline struct eeh_dev *__eeh_addr_cache_get_device(unsigned long addr) n = n->rb_right; } else { pci_dev_get(piar->pcidev); - return piar->edev; + return piar->pcidev; } } } @@ -84,7 +83,7 @@ static inline struct eeh_dev *__eeh_addr_cache_get_device(unsigned long addr) } /** - * eeh_addr_cache_get_dev - Get device, given only address + * pci_addr_cache_get_device - Get device, given only address * @addr: mmio (PIO) phys address or i/o port number * * Given an mmio phys address, or a port number, find a pci device @@ -93,15 +92,15 @@ static inline struct eeh_dev *__eeh_addr_cache_get_device(unsigned long addr) * from zero (that is, they do *not* have pci_io_addr added in). * It is safe to call this function within an interrupt. */ -struct eeh_dev *eeh_addr_cache_get_dev(unsigned long addr) +struct pci_dev *pci_addr_cache_get_device(unsigned long addr) { - struct eeh_dev *edev; + struct pci_dev *dev; unsigned long flags; spin_lock_irqsave(&pci_io_addr_cache_root.piar_lock, flags); - edev = __eeh_addr_cache_get_device(addr); + dev = __pci_addr_cache_get_device(addr); spin_unlock_irqrestore(&pci_io_addr_cache_root.piar_lock, flags); - return edev; + return dev; } #ifdef DEBUG @@ -109,7 +108,7 @@ struct eeh_dev *eeh_addr_cache_get_dev(unsigned long addr) * Handy-dandy debug print routine, does nothing more * than print out the contents of our addr cache. */ -static void eeh_addr_cache_print(struct pci_io_addr_cache *cache) +static void pci_addr_cache_print(struct pci_io_addr_cache *cache) { struct rb_node *n; int cnt = 0; @@ -118,7 +117,7 @@ static void eeh_addr_cache_print(struct pci_io_addr_cache *cache) while (n) { struct pci_io_addr_range *piar; piar = rb_entry(n, struct pci_io_addr_range, rb_node); - pr_debug("PCI: %s addr range %d [%lx-%lx]: %s\n", + printk(KERN_DEBUG "PCI: %s addr range %d [%lx-%lx]: %s\n", (piar->flags & IORESOURCE_IO) ? "i/o" : "mem", cnt, piar->addr_lo, piar->addr_hi, pci_name(piar->pcidev)); cnt++; @@ -129,7 +128,7 @@ static void eeh_addr_cache_print(struct pci_io_addr_cache *cache) /* Insert address range into the rb tree. */ static struct pci_io_addr_range * -eeh_addr_cache_insert(struct pci_dev *dev, unsigned long alo, +pci_addr_cache_insert(struct pci_dev *dev, unsigned long alo, unsigned long ahi, unsigned int flags) { struct rb_node **p = &pci_io_addr_cache_root.rb_root.rb_node; @@ -147,24 +146,23 @@ eeh_addr_cache_insert(struct pci_dev *dev, unsigned long alo, } else { if (dev != piar->pcidev || alo != piar->addr_lo || ahi != piar->addr_hi) { - pr_warning("PIAR: overlapping address range\n"); + printk(KERN_WARNING "PIAR: overlapping address range\n"); } return piar; } } - piar = kzalloc(sizeof(struct pci_io_addr_range), GFP_ATOMIC); + piar = kmalloc(sizeof(struct pci_io_addr_range), GFP_ATOMIC); if (!piar) return NULL; pci_dev_get(dev); piar->addr_lo = alo; piar->addr_hi = ahi; - piar->edev = pci_dev_to_eeh_dev(dev); piar->pcidev = dev; piar->flags = flags; #ifdef DEBUG - pr_debug("PIAR: insert range=[%lx:%lx] dev=%s\n", + printk(KERN_DEBUG "PIAR: insert range=[%lx:%lx] dev=%s\n", alo, ahi, pci_name(dev)); #endif @@ -174,7 +172,7 @@ eeh_addr_cache_insert(struct pci_dev *dev, unsigned long alo, return piar; } -static void __eeh_addr_cache_insert_dev(struct pci_dev *dev) +static void __pci_addr_cache_insert_device(struct pci_dev *dev) { struct device_node *dn; struct eeh_dev *edev; @@ -182,7 +180,7 @@ static void __eeh_addr_cache_insert_dev(struct pci_dev *dev) dn = pci_device_to_OF_node(dev); if (!dn) { - pr_warning("PCI: no pci dn found for dev=%s\n", pci_name(dev)); + printk(KERN_WARNING "PCI: no pci dn found for dev=%s\n", pci_name(dev)); return; } @@ -194,7 +192,8 @@ static void __eeh_addr_cache_insert_dev(struct pci_dev *dev) } /* Skip any devices for which EEH is not enabled. */ - if (!edev->pe) { + if (!(edev->mode & EEH_MODE_SUPPORTED) || + edev->mode & EEH_MODE_NOCHECK) { #ifdef DEBUG pr_info("PCI: skip building address cache for=%s - %s\n", pci_name(dev), dn->full_name); @@ -213,19 +212,19 @@ static void __eeh_addr_cache_insert_dev(struct pci_dev *dev) continue; if (start == 0 || ~start == 0 || end == 0 || ~end == 0) continue; - eeh_addr_cache_insert(dev, start, end, flags); + pci_addr_cache_insert(dev, start, end, flags); } } /** - * eeh_addr_cache_insert_dev - Add a device to the address cache + * pci_addr_cache_insert_device - Add a device to the address cache * @dev: PCI device whose I/O addresses we are interested in. * * In order to support the fast lookup of devices based on addresses, * we maintain a cache of devices that can be quickly searched. * This routine adds a device to that cache. */ -void eeh_addr_cache_insert_dev(struct pci_dev *dev) +void pci_addr_cache_insert_device(struct pci_dev *dev) { unsigned long flags; @@ -234,11 +233,11 @@ void eeh_addr_cache_insert_dev(struct pci_dev *dev) return; spin_lock_irqsave(&pci_io_addr_cache_root.piar_lock, flags); - __eeh_addr_cache_insert_dev(dev); + __pci_addr_cache_insert_device(dev); spin_unlock_irqrestore(&pci_io_addr_cache_root.piar_lock, flags); } -static inline void __eeh_addr_cache_rmv_dev(struct pci_dev *dev) +static inline void __pci_addr_cache_remove_device(struct pci_dev *dev) { struct rb_node *n; @@ -259,7 +258,7 @@ static inline void __eeh_addr_cache_rmv_dev(struct pci_dev *dev) } /** - * eeh_addr_cache_rmv_dev - remove pci device from addr cache + * pci_addr_cache_remove_device - remove pci device from addr cache * @dev: device to remove * * Remove a device from the addr-cache tree. @@ -267,17 +266,17 @@ static inline void __eeh_addr_cache_rmv_dev(struct pci_dev *dev) * the tree multiple times (once per resource). * But so what; device removal doesn't need to be that fast. */ -void eeh_addr_cache_rmv_dev(struct pci_dev *dev) +void pci_addr_cache_remove_device(struct pci_dev *dev) { unsigned long flags; spin_lock_irqsave(&pci_io_addr_cache_root.piar_lock, flags); - __eeh_addr_cache_rmv_dev(dev); + __pci_addr_cache_remove_device(dev); spin_unlock_irqrestore(&pci_io_addr_cache_root.piar_lock, flags); } /** - * eeh_addr_cache_build - Build a cache of I/O addresses + * pci_addr_cache_build - Build a cache of I/O addresses * * Build a cache of pci i/o addresses. This cache will be used to * find the pci device that corresponds to a given address. @@ -285,7 +284,7 @@ void eeh_addr_cache_rmv_dev(struct pci_dev *dev) * Must be run late in boot process, after the pci controllers * have been scanned for devices (after all device resources are known). */ -void __init eeh_addr_cache_build(void) +void __init pci_addr_cache_build(void) { struct device_node *dn; struct eeh_dev *edev; @@ -294,7 +293,7 @@ void __init eeh_addr_cache_build(void) spin_lock_init(&pci_io_addr_cache_root.piar_lock); for_each_pci_dev(dev) { - eeh_addr_cache_insert_dev(dev); + pci_addr_cache_insert_device(dev); dn = pci_device_to_OF_node(dev); if (!dn) @@ -313,7 +312,7 @@ void __init eeh_addr_cache_build(void) #ifdef DEBUG /* Verify tree built up above, echo back the list of addrs. */ - eeh_addr_cache_print(&pci_io_addr_cache_root); + pci_addr_cache_print(&pci_io_addr_cache_root); #endif } diff --git a/trunk/arch/powerpc/platforms/pseries/eeh_dev.c b/trunk/arch/powerpc/platforms/pseries/eeh_dev.c index 66442341d3a6..c4507d095900 100644 --- a/trunk/arch/powerpc/platforms/pseries/eeh_dev.c +++ b/trunk/arch/powerpc/platforms/pseries/eeh_dev.c @@ -55,7 +55,7 @@ void * __devinit eeh_dev_init(struct device_node *dn, void *data) struct eeh_dev *edev; /* Allocate EEH device */ - edev = kzalloc(sizeof(*edev), GFP_KERNEL); + edev = zalloc_maybe_bootmem(sizeof(*edev), GFP_KERNEL); if (!edev) { pr_warning("%s: out of memory\n", __func__); return NULL; @@ -65,7 +65,6 @@ void * __devinit eeh_dev_init(struct device_node *dn, void *data) PCI_DN(dn)->edev = edev; edev->dn = dn; edev->phb = phb; - INIT_LIST_HEAD(&edev->list); return NULL; } @@ -81,9 +80,6 @@ void __devinit eeh_dev_phb_init_dynamic(struct pci_controller *phb) { struct device_node *dn = phb->dn; - /* EEH PE for PHB */ - eeh_phb_pe_create(phb); - /* EEH device for PHB */ eeh_dev_init(dn, phb); @@ -97,16 +93,10 @@ void __devinit eeh_dev_phb_init_dynamic(struct pci_controller *phb) * Scan all the existing PHBs and create EEH devices for their OF * nodes and their children OF nodes */ -static int __init eeh_dev_phb_init(void) +void __init eeh_dev_phb_init(void) { struct pci_controller *phb, *tmp; list_for_each_entry_safe(phb, tmp, &hose_list, list_node) eeh_dev_phb_init_dynamic(phb); - - pr_info("EEH: devices created\n"); - - return 0; } - -core_initcall(eeh_dev_phb_init); diff --git a/trunk/arch/powerpc/platforms/pseries/eeh_driver.c b/trunk/arch/powerpc/platforms/pseries/eeh_driver.c index a3fefb61097c..baf92cd9dfab 100644 --- a/trunk/arch/powerpc/platforms/pseries/eeh_driver.c +++ b/trunk/arch/powerpc/platforms/pseries/eeh_driver.c @@ -25,7 +25,6 @@ #include #include #include -#include #include #include #include @@ -48,41 +47,6 @@ static inline const char *eeh_pcid_name(struct pci_dev *pdev) return ""; } -/** - * eeh_pcid_get - Get the PCI device driver - * @pdev: PCI device - * - * The function is used to retrieve the PCI device driver for - * the indicated PCI device. Besides, we will increase the reference - * of the PCI device driver to prevent that being unloaded on - * the fly. Otherwise, kernel crash would be seen. - */ -static inline struct pci_driver *eeh_pcid_get(struct pci_dev *pdev) -{ - if (!pdev || !pdev->driver) - return NULL; - - if (!try_module_get(pdev->driver->driver.owner)) - return NULL; - - return pdev->driver; -} - -/** - * eeh_pcid_put - Dereference on the PCI device driver - * @pdev: PCI device - * - * The function is called to do dereference on the PCI device - * driver of the indicated PCI device. - */ -static inline void eeh_pcid_put(struct pci_dev *pdev) -{ - if (!pdev || !pdev->driver) - return; - - module_put(pdev->driver->driver.owner); -} - #if 0 static void print_device_node_tree(struct pci_dn *pdn, int dent) { @@ -129,7 +93,7 @@ static void eeh_disable_irq(struct pci_dev *dev) if (!irq_has_action(dev->irq)) return; - edev->mode |= EEH_DEV_IRQ_DISABLED; + edev->mode |= EEH_MODE_IRQ_DISABLED; disable_irq_nosync(dev->irq); } @@ -144,44 +108,36 @@ static void eeh_enable_irq(struct pci_dev *dev) { struct eeh_dev *edev = pci_dev_to_eeh_dev(dev); - if ((edev->mode) & EEH_DEV_IRQ_DISABLED) { - edev->mode &= ~EEH_DEV_IRQ_DISABLED; + if ((edev->mode) & EEH_MODE_IRQ_DISABLED) { + edev->mode &= ~EEH_MODE_IRQ_DISABLED; enable_irq(dev->irq); } } /** * eeh_report_error - Report pci error to each device driver - * @data: eeh device + * @dev: PCI device * @userdata: return value * * Report an EEH error to each device driver, collect up and * merge the device driver responses. Cumulative response * passed back in "userdata". */ -static void *eeh_report_error(void *data, void *userdata) +static int eeh_report_error(struct pci_dev *dev, void *userdata) { - struct eeh_dev *edev = (struct eeh_dev *)data; - struct pci_dev *dev = eeh_dev_to_pci_dev(edev); enum pci_ers_result rc, *res = userdata; - struct pci_driver *driver; + struct pci_driver *driver = dev->driver; - /* We might not have the associated PCI device, - * then we should continue for next one. - */ - if (!dev) return NULL; dev->error_state = pci_channel_io_frozen; - driver = eeh_pcid_get(dev); - if (!driver) return NULL; + if (!driver) + return 0; eeh_disable_irq(dev); if (!driver->err_handler || - !driver->err_handler->error_detected) { - eeh_pcid_put(dev); - return NULL; - } + !driver->err_handler->error_detected) + return 0; rc = driver->err_handler->error_detected(dev, pci_channel_io_frozen); @@ -189,34 +145,27 @@ static void *eeh_report_error(void *data, void *userdata) if (rc == PCI_ERS_RESULT_NEED_RESET) *res = rc; if (*res == PCI_ERS_RESULT_NONE) *res = rc; - eeh_pcid_put(dev); - return NULL; + return 0; } /** * eeh_report_mmio_enabled - Tell drivers that MMIO has been enabled - * @data: eeh device + * @dev: PCI device * @userdata: return value * * Tells each device driver that IO ports, MMIO and config space I/O * are now enabled. Collects up and merges the device driver responses. * Cumulative response passed back in "userdata". */ -static void *eeh_report_mmio_enabled(void *data, void *userdata) +static int eeh_report_mmio_enabled(struct pci_dev *dev, void *userdata) { - struct eeh_dev *edev = (struct eeh_dev *)data; - struct pci_dev *dev = eeh_dev_to_pci_dev(edev); enum pci_ers_result rc, *res = userdata; - struct pci_driver *driver; + struct pci_driver *driver = dev->driver; - driver = eeh_pcid_get(dev); - if (!driver) return NULL; - - if (!driver->err_handler || - !driver->err_handler->mmio_enabled) { - eeh_pcid_put(dev); - return NULL; - } + if (!driver || + !driver->err_handler || + !driver->err_handler->mmio_enabled) + return 0; rc = driver->err_handler->mmio_enabled(dev); @@ -224,13 +173,12 @@ static void *eeh_report_mmio_enabled(void *data, void *userdata) if (rc == PCI_ERS_RESULT_NEED_RESET) *res = rc; if (*res == PCI_ERS_RESULT_NONE) *res = rc; - eeh_pcid_put(dev); - return NULL; + return 0; } /** * eeh_report_reset - Tell device that slot has been reset - * @data: eeh device + * @dev: PCI device * @userdata: return value * * This routine must be called while EEH tries to reset particular @@ -238,26 +186,21 @@ static void *eeh_report_mmio_enabled(void *data, void *userdata) * some actions, usually to save data the driver needs so that the * driver can work again while the device is recovered. */ -static void *eeh_report_reset(void *data, void *userdata) +static int eeh_report_reset(struct pci_dev *dev, void *userdata) { - struct eeh_dev *edev = (struct eeh_dev *)data; - struct pci_dev *dev = eeh_dev_to_pci_dev(edev); enum pci_ers_result rc, *res = userdata; - struct pci_driver *driver; + struct pci_driver *driver = dev->driver; - if (!dev) return NULL; - dev->error_state = pci_channel_io_normal; + if (!driver) + return 0; - driver = eeh_pcid_get(dev); - if (!driver) return NULL; + dev->error_state = pci_channel_io_normal; eeh_enable_irq(dev); if (!driver->err_handler || - !driver->err_handler->slot_reset) { - eeh_pcid_put(dev); - return NULL; - } + !driver->err_handler->slot_reset) + return 0; rc = driver->err_handler->slot_reset(dev); if ((*res == PCI_ERS_RESULT_NONE) || @@ -265,115 +208,109 @@ static void *eeh_report_reset(void *data, void *userdata) if (*res == PCI_ERS_RESULT_DISCONNECT && rc == PCI_ERS_RESULT_NEED_RESET) *res = rc; - eeh_pcid_put(dev); - return NULL; + return 0; } /** * eeh_report_resume - Tell device to resume normal operations - * @data: eeh device + * @dev: PCI device * @userdata: return value * * This routine must be called to notify the device driver that it * could resume so that the device driver can do some initialization * to make the recovered device work again. */ -static void *eeh_report_resume(void *data, void *userdata) +static int eeh_report_resume(struct pci_dev *dev, void *userdata) { - struct eeh_dev *edev = (struct eeh_dev *)data; - struct pci_dev *dev = eeh_dev_to_pci_dev(edev); - struct pci_driver *driver; + struct pci_driver *driver = dev->driver; - if (!dev) return NULL; dev->error_state = pci_channel_io_normal; - driver = eeh_pcid_get(dev); - if (!driver) return NULL; + if (!driver) + return 0; eeh_enable_irq(dev); if (!driver->err_handler || - !driver->err_handler->resume) { - eeh_pcid_put(dev); - return NULL; - } + !driver->err_handler->resume) + return 0; driver->err_handler->resume(dev); - eeh_pcid_put(dev); - return NULL; + return 0; } /** * eeh_report_failure - Tell device driver that device is dead. - * @data: eeh device + * @dev: PCI device * @userdata: return value * * This informs the device driver that the device is permanently * dead, and that no further recovery attempts will be made on it. */ -static void *eeh_report_failure(void *data, void *userdata) +static int eeh_report_failure(struct pci_dev *dev, void *userdata) { - struct eeh_dev *edev = (struct eeh_dev *)data; - struct pci_dev *dev = eeh_dev_to_pci_dev(edev); - struct pci_driver *driver; + struct pci_driver *driver = dev->driver; - if (!dev) return NULL; dev->error_state = pci_channel_io_perm_failure; - driver = eeh_pcid_get(dev); - if (!driver) return NULL; + if (!driver) + return 0; eeh_disable_irq(dev); if (!driver->err_handler || - !driver->err_handler->error_detected) { - eeh_pcid_put(dev); - return NULL; - } + !driver->err_handler->error_detected) + return 0; driver->err_handler->error_detected(dev, pci_channel_io_perm_failure); - eeh_pcid_put(dev); - return NULL; + return 0; } /** * eeh_reset_device - Perform actual reset of a pci slot - * @pe: EEH PE + * @edev: PE associated EEH device * @bus: PCI bus corresponding to the isolcated slot * * This routine must be called to do reset on the indicated PE. * During the reset, udev might be invoked because those affected * PCI devices will be removed and then added. */ -static int eeh_reset_device(struct eeh_pe *pe, struct pci_bus *bus) +static int eeh_reset_device(struct eeh_dev *edev, struct pci_bus *bus) { + struct device_node *dn; int cnt, rc; /* pcibios will clear the counter; save the value */ - cnt = pe->freeze_count; + cnt = edev->freeze_count; - /* - * We don't remove the corresponding PE instances because - * we need the information afterwords. The attached EEH - * devices are expected to be attached soon when calling - * into pcibios_add_pci_devices(). - */ if (bus) - __pcibios_remove_pci_devices(bus, 0); + pcibios_remove_pci_devices(bus); /* Reset the pci controller. (Asserts RST#; resets config space). * Reconfigure bridges and devices. Don't try to bring the system * up if the reset failed for some reason. */ - rc = eeh_reset_pe(pe); + rc = eeh_reset_pe(edev); if (rc) return rc; - /* Restore PE */ - eeh_ops->configure_bridge(pe); - eeh_pe_restore_bars(pe); + /* Walk over all functions on this device. */ + dn = eeh_dev_to_of_node(edev); + if (!pcibios_find_pci_bus(dn) && of_node_to_eeh_dev(dn->parent)) + dn = dn->parent->child; + + while (dn) { + struct eeh_dev *pedev = of_node_to_eeh_dev(dn); + + /* On Power4, always true because eeh_pe_config_addr=0 */ + if (edev->pe_config_addr == pedev->pe_config_addr) { + eeh_ops->configure_bridge(dn); + eeh_restore_bars(pedev); + } + dn = dn->sibling; + } /* Give the system 5 seconds to finish running the user-space * hotplug shutdown scripts, e.g. ifdown for ethernet. Yes, @@ -385,7 +322,7 @@ static int eeh_reset_device(struct eeh_pe *pe, struct pci_bus *bus) ssleep(5); pcibios_add_pci_devices(bus); } - pe->freeze_count = cnt; + edev->freeze_count = cnt; return 0; } @@ -397,7 +334,7 @@ static int eeh_reset_device(struct eeh_pe *pe, struct pci_bus *bus) /** * eeh_handle_event - Reset a PCI device after hard lockup. - * @pe: EEH PE + * @event: EEH event * * While PHB detects address or data parity errors on particular PCI * slot, the associated PE will be frozen. Besides, DMA's occurring @@ -412,24 +349,69 @@ static int eeh_reset_device(struct eeh_pe *pe, struct pci_bus *bus) * drivers (which cause a second set of hotplug events to go out to * userspace). */ -void eeh_handle_event(struct eeh_pe *pe) +struct eeh_dev *handle_eeh_events(struct eeh_event *event) { + struct device_node *frozen_dn; + struct eeh_dev *frozen_edev; struct pci_bus *frozen_bus; int rc = 0; enum pci_ers_result result = PCI_ERS_RESULT_NONE; + const char *location, *pci_str, *drv_str, *bus_pci_str, *bus_drv_str; + + frozen_dn = eeh_find_device_pe(eeh_dev_to_of_node(event->edev)); + if (!frozen_dn) { + location = of_get_property(eeh_dev_to_of_node(event->edev), "ibm,loc-code", NULL); + location = location ? location : "unknown"; + printk(KERN_ERR "EEH: Error: Cannot find partition endpoint " + "for location=%s pci addr=%s\n", + location, eeh_pci_name(eeh_dev_to_pci_dev(event->edev))); + return NULL; + } + + frozen_bus = pcibios_find_pci_bus(frozen_dn); + location = of_get_property(frozen_dn, "ibm,loc-code", NULL); + location = location ? location : "unknown"; + + /* There are two different styles for coming up with the PE. + * In the old style, it was the highest EEH-capable device + * which was always an EADS pci bridge. In the new style, + * there might not be any EADS bridges, and even when there are, + * the firmware marks them as "EEH incapable". So another + * two-step is needed to find the pci bus.. + */ + if (!frozen_bus) + frozen_bus = pcibios_find_pci_bus(frozen_dn->parent); - frozen_bus = eeh_pe_bus_get(pe); if (!frozen_bus) { - pr_err("%s: Cannot find PCI bus for PHB#%d-PE#%x\n", - __func__, pe->phb->global_number, pe->addr); - return; + printk(KERN_ERR "EEH: Cannot find PCI bus " + "for location=%s dn=%s\n", + location, frozen_dn->full_name); + return NULL; } - pe->freeze_count++; - if (pe->freeze_count > EEH_MAX_ALLOWED_FREEZES) + frozen_edev = of_node_to_eeh_dev(frozen_dn); + frozen_edev->freeze_count++; + pci_str = eeh_pci_name(eeh_dev_to_pci_dev(event->edev)); + drv_str = eeh_pcid_name(eeh_dev_to_pci_dev(event->edev)); + + if (frozen_edev->freeze_count > EEH_MAX_ALLOWED_FREEZES) goto excess_failures; - pr_warning("EEH: This PCI device has failed %d times in the last hour\n", - pe->freeze_count); + + printk(KERN_WARNING + "EEH: This PCI device has failed %d times in the last hour:\n", + frozen_edev->freeze_count); + + if (frozen_edev->pdev) { + bus_pci_str = pci_name(frozen_edev->pdev); + bus_drv_str = eeh_pcid_name(frozen_edev->pdev); + printk(KERN_WARNING + "EEH: Bus location=%s driver=%s pci addr=%s\n", + location, bus_drv_str, bus_pci_str); + } + + printk(KERN_WARNING + "EEH: Device location=%s driver=%s pci addr=%s\n", + location, drv_str, pci_str); /* Walk the various device drivers attached to this slot through * a reset sequence, giving each an opportunity to do what it needs @@ -437,12 +419,12 @@ void eeh_handle_event(struct eeh_pe *pe) * status ... if any child can't handle the reset, then the entire * slot is dlpar removed and added. */ - eeh_pe_dev_traverse(pe, eeh_report_error, &result); + pci_walk_bus(frozen_bus, eeh_report_error, &result); /* Get the current PCI slot state. This can take a long time, * sometimes over 3 seconds for certain systems. */ - rc = eeh_ops->wait_state(pe, MAX_WAIT_FOR_RECOVERY*1000); + rc = eeh_ops->wait_state(eeh_dev_to_of_node(frozen_edev), MAX_WAIT_FOR_RECOVERY*1000); if (rc < 0 || rc == EEH_STATE_NOT_SUPPORT) { printk(KERN_WARNING "EEH: Permanent failure\n"); goto hard_fail; @@ -452,14 +434,14 @@ void eeh_handle_event(struct eeh_pe *pe) * don't post the error log until after all dev drivers * have been informed. */ - eeh_slot_error_detail(pe, EEH_LOG_TEMP); + eeh_slot_error_detail(frozen_edev, EEH_LOG_TEMP); /* If all device drivers were EEH-unaware, then shut * down all of the device drivers, and hope they * go down willingly, without panicing the system. */ if (result == PCI_ERS_RESULT_NONE) { - rc = eeh_reset_device(pe, frozen_bus); + rc = eeh_reset_device(frozen_edev, frozen_bus); if (rc) { printk(KERN_WARNING "EEH: Unable to reset, rc=%d\n", rc); goto hard_fail; @@ -468,7 +450,7 @@ void eeh_handle_event(struct eeh_pe *pe) /* If all devices reported they can proceed, then re-enable MMIO */ if (result == PCI_ERS_RESULT_CAN_RECOVER) { - rc = eeh_pci_enable(pe, EEH_OPT_THAW_MMIO); + rc = eeh_pci_enable(frozen_edev, EEH_OPT_THAW_MMIO); if (rc < 0) goto hard_fail; @@ -476,13 +458,13 @@ void eeh_handle_event(struct eeh_pe *pe) result = PCI_ERS_RESULT_NEED_RESET; } else { result = PCI_ERS_RESULT_NONE; - eeh_pe_dev_traverse(pe, eeh_report_mmio_enabled, &result); + pci_walk_bus(frozen_bus, eeh_report_mmio_enabled, &result); } } /* If all devices reported they can proceed, then re-enable DMA */ if (result == PCI_ERS_RESULT_CAN_RECOVER) { - rc = eeh_pci_enable(pe, EEH_OPT_THAW_DMA); + rc = eeh_pci_enable(frozen_edev, EEH_OPT_THAW_DMA); if (rc < 0) goto hard_fail; @@ -500,13 +482,13 @@ void eeh_handle_event(struct eeh_pe *pe) /* If any device called out for a reset, then reset the slot */ if (result == PCI_ERS_RESULT_NEED_RESET) { - rc = eeh_reset_device(pe, NULL); + rc = eeh_reset_device(frozen_edev, NULL); if (rc) { printk(KERN_WARNING "EEH: Cannot reset, rc=%d\n", rc); goto hard_fail; } result = PCI_ERS_RESULT_NONE; - eeh_pe_dev_traverse(pe, eeh_report_reset, &result); + pci_walk_bus(frozen_bus, eeh_report_reset, &result); } /* All devices should claim they have recovered by now. */ @@ -517,9 +499,9 @@ void eeh_handle_event(struct eeh_pe *pe) } /* Tell all device drivers that they can resume operations */ - eeh_pe_dev_traverse(pe, eeh_report_resume, NULL); + pci_walk_bus(frozen_bus, eeh_report_resume, NULL); - return; + return frozen_edev; excess_failures: /* @@ -527,26 +509,30 @@ void eeh_handle_event(struct eeh_pe *pe) * are due to poorly seated PCI cards. Only 10% or so are * due to actual, failed cards. */ - pr_err("EEH: PHB#%d-PE#%x has failed %d times in the\n" - "last hour and has been permanently disabled.\n" - "Please try reseating or replacing it.\n", - pe->phb->global_number, pe->addr, - pe->freeze_count); + printk(KERN_ERR + "EEH: PCI device at location=%s driver=%s pci addr=%s\n" + "has failed %d times in the last hour " + "and has been permanently disabled.\n" + "Please try reseating this device or replacing it.\n", + location, drv_str, pci_str, frozen_edev->freeze_count); goto perm_error; hard_fail: - pr_err("EEH: Unable to recover from failure from PHB#%d-PE#%x.\n" - "Please try reseating or replacing it\n", - pe->phb->global_number, pe->addr); + printk(KERN_ERR + "EEH: Unable to recover from failure of PCI device " + "at location=%s driver=%s pci addr=%s\n" + "Please try reseating this device or replacing it.\n", + location, drv_str, pci_str); perm_error: - eeh_slot_error_detail(pe, EEH_LOG_PERM); + eeh_slot_error_detail(frozen_edev, EEH_LOG_PERM); /* Notify all devices that they're about to go down. */ - eeh_pe_dev_traverse(pe, eeh_report_failure, NULL); + pci_walk_bus(frozen_bus, eeh_report_failure, NULL); /* Shut down the device drivers for good. */ - if (frozen_bus) - pcibios_remove_pci_devices(frozen_bus); + pcibios_remove_pci_devices(frozen_bus); + + return NULL; } diff --git a/trunk/arch/powerpc/platforms/pseries/eeh_event.c b/trunk/arch/powerpc/platforms/pseries/eeh_event.c index 51faaac8abe6..fb506317ebb0 100644 --- a/trunk/arch/powerpc/platforms/pseries/eeh_event.c +++ b/trunk/arch/powerpc/platforms/pseries/eeh_event.c @@ -57,7 +57,7 @@ static int eeh_event_handler(void * dummy) { unsigned long flags; struct eeh_event *event; - struct eeh_pe *pe; + struct eeh_dev *edev; set_task_comm(current, "eehd"); @@ -76,23 +76,28 @@ static int eeh_event_handler(void * dummy) /* Serialize processing of EEH events */ mutex_lock(&eeh_event_mutex); - pe = event->pe; - eeh_pe_state_mark(pe, EEH_PE_RECOVERING); - pr_info("EEH: Detected PCI bus error on PHB#%d-PE#%x\n", - pe->phb->global_number, pe->addr); + edev = event->edev; + eeh_mark_slot(eeh_dev_to_of_node(edev), EEH_MODE_RECOVERING); + + printk(KERN_INFO "EEH: Detected PCI bus error on device %s\n", + eeh_pci_name(edev->pdev)); set_current_state(TASK_INTERRUPTIBLE); /* Don't add to load average */ - eeh_handle_event(pe); - eeh_pe_state_clear(pe, EEH_PE_RECOVERING); + edev = handle_eeh_events(event); + + if (edev) { + eeh_clear_slot(eeh_dev_to_of_node(edev), EEH_MODE_RECOVERING); + pci_dev_put(edev->pdev); + } kfree(event); mutex_unlock(&eeh_event_mutex); /* If there are no new errors after an hour, clear the counter. */ - if (pe && pe->freeze_count > 0) { + if (edev && edev->freeze_count>0) { msleep_interruptible(3600*1000); - if (pe->freeze_count > 0) - pe->freeze_count--; + if (edev->freeze_count>0) + edev->freeze_count--; } @@ -114,23 +119,36 @@ static void eeh_thread_launcher(struct work_struct *dummy) /** * eeh_send_failure_event - Generate a PCI error event - * @pe: EEH PE + * @edev: EEH device * * This routine can be called within an interrupt context; * the actual event will be delivered in a normal context * (from a workqueue). */ -int eeh_send_failure_event(struct eeh_pe *pe) +int eeh_send_failure_event(struct eeh_dev *edev) { unsigned long flags; struct eeh_event *event; - - event = kzalloc(sizeof(*event), GFP_ATOMIC); - if (!event) { - pr_err("EEH: out of memory, event not handled\n"); - return -ENOMEM; + struct device_node *dn = eeh_dev_to_of_node(edev); + const char *location; + + if (!mem_init_done) { + printk(KERN_ERR "EEH: event during early boot not handled\n"); + location = of_get_property(dn, "ibm,loc-code", NULL); + printk(KERN_ERR "EEH: device node = %s\n", dn->full_name); + printk(KERN_ERR "EEH: PCI location = %s\n", location); + return 1; } - event->pe = pe; + event = kmalloc(sizeof(*event), GFP_ATOMIC); + if (event == NULL) { + printk(KERN_ERR "EEH: out of memory, event not handled\n"); + return 1; + } + + if (edev->pdev) + pci_dev_get(edev->pdev); + + event->edev = edev; /* We may or may not be called in an interrupt context */ spin_lock_irqsave(&eeh_eventlist_lock, flags); diff --git a/trunk/arch/powerpc/platforms/pseries/eeh_pe.c b/trunk/arch/powerpc/platforms/pseries/eeh_pe.c deleted file mode 100644 index 797cd181dc3f..000000000000 --- a/trunk/arch/powerpc/platforms/pseries/eeh_pe.c +++ /dev/null @@ -1,652 +0,0 @@ -/* - * The file intends to implement PE based on the information from - * platforms. Basically, there have 3 types of PEs: PHB/Bus/Device. - * All the PEs should be organized as hierarchy tree. The first level - * of the tree will be associated to existing PHBs since the particular - * PE is only meaningful in one PHB domain. - * - * Copyright Benjamin Herrenschmidt & Gavin Shan, IBM Corporation 2012. - * - * 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 -#include -#include -#include -#include -#include - -#include -#include - -static LIST_HEAD(eeh_phb_pe); - -/** - * eeh_pe_alloc - Allocate PE - * @phb: PCI controller - * @type: PE type - * - * Allocate PE instance dynamically. - */ -static struct eeh_pe *eeh_pe_alloc(struct pci_controller *phb, int type) -{ - struct eeh_pe *pe; - - /* Allocate PHB PE */ - pe = kzalloc(sizeof(struct eeh_pe), GFP_KERNEL); - if (!pe) return NULL; - - /* Initialize PHB PE */ - pe->type = type; - pe->phb = phb; - INIT_LIST_HEAD(&pe->child_list); - INIT_LIST_HEAD(&pe->child); - INIT_LIST_HEAD(&pe->edevs); - - return pe; -} - -/** - * eeh_phb_pe_create - Create PHB PE - * @phb: PCI controller - * - * The function should be called while the PHB is detected during - * system boot or PCI hotplug in order to create PHB PE. - */ -int __devinit eeh_phb_pe_create(struct pci_controller *phb) -{ - struct eeh_pe *pe; - - /* Allocate PHB PE */ - pe = eeh_pe_alloc(phb, EEH_PE_PHB); - if (!pe) { - pr_err("%s: out of memory!\n", __func__); - return -ENOMEM; - } - - /* Put it into the list */ - eeh_lock(); - list_add_tail(&pe->child, &eeh_phb_pe); - eeh_unlock(); - - pr_debug("EEH: Add PE for PHB#%d\n", phb->global_number); - - return 0; -} - -/** - * eeh_phb_pe_get - Retrieve PHB PE based on the given PHB - * @phb: PCI controller - * - * The overall PEs form hierarchy tree. The first layer of the - * hierarchy tree is composed of PHB PEs. The function is used - * to retrieve the corresponding PHB PE according to the given PHB. - */ -static struct eeh_pe *eeh_phb_pe_get(struct pci_controller *phb) -{ - struct eeh_pe *pe; - - list_for_each_entry(pe, &eeh_phb_pe, child) { - /* - * Actually, we needn't check the type since - * the PE for PHB has been determined when that - * was created. - */ - if ((pe->type & EEH_PE_PHB) && pe->phb == phb) - return pe; - } - - return NULL; -} - -/** - * eeh_pe_next - Retrieve the next PE in the tree - * @pe: current PE - * @root: root PE - * - * The function is used to retrieve the next PE in the - * hierarchy PE tree. - */ -static struct eeh_pe *eeh_pe_next(struct eeh_pe *pe, - struct eeh_pe *root) -{ - struct list_head *next = pe->child_list.next; - - if (next == &pe->child_list) { - while (1) { - if (pe == root) - return NULL; - next = pe->child.next; - if (next != &pe->parent->child_list) - break; - pe = pe->parent; - } - } - - return list_entry(next, struct eeh_pe, child); -} - -/** - * eeh_pe_traverse - Traverse PEs in the specified PHB - * @root: root PE - * @fn: callback - * @flag: extra parameter to callback - * - * The function is used to traverse the specified PE and its - * child PEs. The traversing is to be terminated once the - * callback returns something other than NULL, or no more PEs - * to be traversed. - */ -static void *eeh_pe_traverse(struct eeh_pe *root, - eeh_traverse_func fn, void *flag) -{ - struct eeh_pe *pe; - void *ret; - - for (pe = root; pe; pe = eeh_pe_next(pe, root)) { - ret = fn(pe, flag); - if (ret) return ret; - } - - return NULL; -} - -/** - * eeh_pe_dev_traverse - Traverse the devices from the PE - * @root: EEH PE - * @fn: function callback - * @flag: extra parameter to callback - * - * The function is used to traverse the devices of the specified - * PE and its child PEs. - */ -void *eeh_pe_dev_traverse(struct eeh_pe *root, - eeh_traverse_func fn, void *flag) -{ - struct eeh_pe *pe; - struct eeh_dev *edev; - void *ret; - - if (!root) { - pr_warning("%s: Invalid PE %p\n", __func__, root); - return NULL; - } - - eeh_lock(); - - /* Traverse root PE */ - for (pe = root; pe; pe = eeh_pe_next(pe, root)) { - eeh_pe_for_each_dev(pe, edev) { - ret = fn(edev, flag); - if (ret) { - eeh_unlock(); - return ret; - } - } - } - - eeh_unlock(); - - return NULL; -} - -/** - * __eeh_pe_get - Check the PE address - * @data: EEH PE - * @flag: EEH device - * - * For one particular PE, it can be identified by PE address - * or tranditional BDF address. BDF address is composed of - * Bus/Device/Function number. The extra data referred by flag - * indicates which type of address should be used. - */ -static void *__eeh_pe_get(void *data, void *flag) -{ - struct eeh_pe *pe = (struct eeh_pe *)data; - struct eeh_dev *edev = (struct eeh_dev *)flag; - - /* Unexpected PHB PE */ - if (pe->type & EEH_PE_PHB) - return NULL; - - /* We prefer PE address */ - if (edev->pe_config_addr && - (edev->pe_config_addr == pe->addr)) - return pe; - - /* Try BDF address */ - if (edev->pe_config_addr && - (edev->config_addr == pe->config_addr)) - return pe; - - return NULL; -} - -/** - * eeh_pe_get - Search PE based on the given address - * @edev: EEH device - * - * Search the corresponding PE based on the specified address which - * is included in the eeh device. The function is used to check if - * the associated PE has been created against the PE address. It's - * notable that the PE address has 2 format: traditional PE address - * which is composed of PCI bus/device/function number, or unified - * PE address. - */ -static struct eeh_pe *eeh_pe_get(struct eeh_dev *edev) -{ - struct eeh_pe *root = eeh_phb_pe_get(edev->phb); - struct eeh_pe *pe; - - pe = eeh_pe_traverse(root, __eeh_pe_get, edev); - - return pe; -} - -/** - * eeh_pe_get_parent - Retrieve the parent PE - * @edev: EEH device - * - * The whole PEs existing in the system are organized as hierarchy - * tree. The function is used to retrieve the parent PE according - * to the parent EEH device. - */ -static struct eeh_pe *eeh_pe_get_parent(struct eeh_dev *edev) -{ - struct device_node *dn; - struct eeh_dev *parent; - - /* - * It might have the case for the indirect parent - * EEH device already having associated PE, but - * the direct parent EEH device doesn't have yet. - */ - dn = edev->dn->parent; - while (dn) { - /* We're poking out of PCI territory */ - if (!PCI_DN(dn)) return NULL; - - parent = of_node_to_eeh_dev(dn); - /* We're poking out of PCI territory */ - if (!parent) return NULL; - - if (parent->pe) - return parent->pe; - - dn = dn->parent; - } - - return NULL; -} - -/** - * eeh_add_to_parent_pe - Add EEH device to parent PE - * @edev: EEH device - * - * Add EEH device to the parent PE. If the parent PE already - * exists, the PE type will be changed to EEH_PE_BUS. Otherwise, - * we have to create new PE to hold the EEH device and the new - * PE will be linked to its parent PE as well. - */ -int eeh_add_to_parent_pe(struct eeh_dev *edev) -{ - struct eeh_pe *pe, *parent; - - eeh_lock(); - - /* - * Search the PE has been existing or not according - * to the PE address. If that has been existing, the - * PE should be composed of PCI bus and its subordinate - * components. - */ - pe = eeh_pe_get(edev); - if (pe && !(pe->type & EEH_PE_INVALID)) { - if (!edev->pe_config_addr) { - eeh_unlock(); - pr_err("%s: PE with addr 0x%x already exists\n", - __func__, edev->config_addr); - return -EEXIST; - } - - /* Mark the PE as type of PCI bus */ - pe->type = EEH_PE_BUS; - edev->pe = pe; - - /* Put the edev to PE */ - list_add_tail(&edev->list, &pe->edevs); - eeh_unlock(); - pr_debug("EEH: Add %s to Bus PE#%x\n", - edev->dn->full_name, pe->addr); - - return 0; - } else if (pe && (pe->type & EEH_PE_INVALID)) { - list_add_tail(&edev->list, &pe->edevs); - edev->pe = pe; - /* - * We're running to here because of PCI hotplug caused by - * EEH recovery. We need clear EEH_PE_INVALID until the top. - */ - parent = pe; - while (parent) { - if (!(parent->type & EEH_PE_INVALID)) - break; - parent->type &= ~EEH_PE_INVALID; - parent = parent->parent; - } - eeh_unlock(); - pr_debug("EEH: Add %s to Device PE#%x, Parent PE#%x\n", - edev->dn->full_name, pe->addr, pe->parent->addr); - - return 0; - } - - /* Create a new EEH PE */ - pe = eeh_pe_alloc(edev->phb, EEH_PE_DEVICE); - if (!pe) { - eeh_unlock(); - pr_err("%s: out of memory!\n", __func__); - return -ENOMEM; - } - pe->addr = edev->pe_config_addr; - pe->config_addr = edev->config_addr; - - /* - * Put the new EEH PE into hierarchy tree. If the parent - * can't be found, the newly created PE will be attached - * to PHB directly. Otherwise, we have to associate the - * PE with its parent. - */ - parent = eeh_pe_get_parent(edev); - if (!parent) { - parent = eeh_phb_pe_get(edev->phb); - if (!parent) { - eeh_unlock(); - pr_err("%s: No PHB PE is found (PHB Domain=%d)\n", - __func__, edev->phb->global_number); - edev->pe = NULL; - kfree(pe); - return -EEXIST; - } - } - pe->parent = parent; - - /* - * Put the newly created PE into the child list and - * link the EEH device accordingly. - */ - list_add_tail(&pe->child, &parent->child_list); - list_add_tail(&edev->list, &pe->edevs); - edev->pe = pe; - eeh_unlock(); - pr_debug("EEH: Add %s to Device PE#%x, Parent PE#%x\n", - edev->dn->full_name, pe->addr, pe->parent->addr); - - return 0; -} - -/** - * eeh_rmv_from_parent_pe - Remove one EEH device from the associated PE - * @edev: EEH device - * @purge_pe: remove PE or not - * - * The PE hierarchy tree might be changed when doing PCI hotplug. - * Also, the PCI devices or buses could be removed from the system - * during EEH recovery. So we have to call the function remove the - * corresponding PE accordingly if necessary. - */ -int eeh_rmv_from_parent_pe(struct eeh_dev *edev, int purge_pe) -{ - struct eeh_pe *pe, *parent, *child; - int cnt; - - if (!edev->pe) { - pr_warning("%s: No PE found for EEH device %s\n", - __func__, edev->dn->full_name); - return -EEXIST; - } - - eeh_lock(); - - /* Remove the EEH device */ - pe = edev->pe; - edev->pe = NULL; - list_del(&edev->list); - - /* - * Check if the parent PE includes any EEH devices. - * If not, we should delete that. Also, we should - * delete the parent PE if it doesn't have associated - * child PEs and EEH devices. - */ - while (1) { - parent = pe->parent; - if (pe->type & EEH_PE_PHB) - break; - - if (purge_pe) { - if (list_empty(&pe->edevs) && - list_empty(&pe->child_list)) { - list_del(&pe->child); - kfree(pe); - } else { - break; - } - } else { - if (list_empty(&pe->edevs)) { - cnt = 0; - list_for_each_entry(child, &pe->child_list, child) { - if (!(pe->type & EEH_PE_INVALID)) { - cnt++; - break; - } - } - - if (!cnt) - pe->type |= EEH_PE_INVALID; - else - break; - } - } - - pe = parent; - } - - eeh_unlock(); - - return 0; -} - -/** - * __eeh_pe_state_mark - Mark the state for the PE - * @data: EEH PE - * @flag: state - * - * The function is used to mark the indicated state for the given - * PE. Also, the associated PCI devices will be put into IO frozen - * state as well. - */ -static void *__eeh_pe_state_mark(void *data, void *flag) -{ - struct eeh_pe *pe = (struct eeh_pe *)data; - int state = *((int *)flag); - struct eeh_dev *tmp; - struct pci_dev *pdev; - - /* - * Mark the PE with the indicated state. Also, - * the associated PCI device will be put into - * I/O frozen state to avoid I/O accesses from - * the PCI device driver. - */ - pe->state |= state; - eeh_pe_for_each_dev(pe, tmp) { - pdev = eeh_dev_to_pci_dev(tmp); - if (pdev) - pdev->error_state = pci_channel_io_frozen; - } - - return NULL; -} - -/** - * eeh_pe_state_mark - Mark specified state for PE and its associated device - * @pe: EEH PE - * - * EEH error affects the current PE and its child PEs. The function - * is used to mark appropriate state for the affected PEs and the - * associated devices. - */ -void eeh_pe_state_mark(struct eeh_pe *pe, int state) -{ - eeh_lock(); - eeh_pe_traverse(pe, __eeh_pe_state_mark, &state); - eeh_unlock(); -} - -/** - * __eeh_pe_state_clear - Clear state for the PE - * @data: EEH PE - * @flag: state - * - * The function is used to clear the indicated state from the - * given PE. Besides, we also clear the check count of the PE - * as well. - */ -static void *__eeh_pe_state_clear(void *data, void *flag) -{ - struct eeh_pe *pe = (struct eeh_pe *)data; - int state = *((int *)flag); - - pe->state &= ~state; - pe->check_count = 0; - - return NULL; -} - -/** - * eeh_pe_state_clear - Clear state for the PE and its children - * @pe: PE - * @state: state to be cleared - * - * When the PE and its children has been recovered from error, - * we need clear the error state for that. The function is used - * for the purpose. - */ -void eeh_pe_state_clear(struct eeh_pe *pe, int state) -{ - eeh_lock(); - eeh_pe_traverse(pe, __eeh_pe_state_clear, &state); - eeh_unlock(); -} - -/** - * eeh_restore_one_device_bars - Restore the Base Address Registers for one device - * @data: EEH device - * @flag: Unused - * - * Loads the PCI configuration space base address registers, - * the expansion ROM base address, the latency timer, and etc. - * from the saved values in the device node. - */ -static void *eeh_restore_one_device_bars(void *data, void *flag) -{ - int i; - u32 cmd; - struct eeh_dev *edev = (struct eeh_dev *)data; - struct device_node *dn = eeh_dev_to_of_node(edev); - - for (i = 4; i < 10; i++) - eeh_ops->write_config(dn, i*4, 4, edev->config_space[i]); - /* 12 == Expansion ROM Address */ - eeh_ops->write_config(dn, 12*4, 4, edev->config_space[12]); - -#define BYTE_SWAP(OFF) (8*((OFF)/4)+3-(OFF)) -#define SAVED_BYTE(OFF) (((u8 *)(edev->config_space))[BYTE_SWAP(OFF)]) - - eeh_ops->write_config(dn, PCI_CACHE_LINE_SIZE, 1, - SAVED_BYTE(PCI_CACHE_LINE_SIZE)); - eeh_ops->write_config(dn, PCI_LATENCY_TIMER, 1, - SAVED_BYTE(PCI_LATENCY_TIMER)); - - /* max latency, min grant, interrupt pin and line */ - eeh_ops->write_config(dn, 15*4, 4, edev->config_space[15]); - - /* - * Restore PERR & SERR bits, some devices require it, - * don't touch the other command bits - */ - eeh_ops->read_config(dn, PCI_COMMAND, 4, &cmd); - if (edev->config_space[1] & PCI_COMMAND_PARITY) - cmd |= PCI_COMMAND_PARITY; - else - cmd &= ~PCI_COMMAND_PARITY; - if (edev->config_space[1] & PCI_COMMAND_SERR) - cmd |= PCI_COMMAND_SERR; - else - cmd &= ~PCI_COMMAND_SERR; - eeh_ops->write_config(dn, PCI_COMMAND, 4, cmd); - - return NULL; -} - -/** - * eeh_pe_restore_bars - Restore the PCI config space info - * @pe: EEH PE - * - * This routine performs a recursive walk to the children - * of this device as well. - */ -void eeh_pe_restore_bars(struct eeh_pe *pe) -{ - /* - * We needn't take the EEH lock since eeh_pe_dev_traverse() - * will take that. - */ - eeh_pe_dev_traverse(pe, eeh_restore_one_device_bars, NULL); -} - -/** - * eeh_pe_bus_get - Retrieve PCI bus according to the given PE - * @pe: EEH PE - * - * Retrieve the PCI bus according to the given PE. Basically, - * there're 3 types of PEs: PHB/Bus/Device. For PHB PE, the - * primary PCI bus will be retrieved. The parent bus will be - * returned for BUS PE. However, we don't have associated PCI - * bus for DEVICE PE. - */ -struct pci_bus *eeh_pe_bus_get(struct eeh_pe *pe) -{ - struct pci_bus *bus = NULL; - struct eeh_dev *edev; - struct pci_dev *pdev; - - eeh_lock(); - - if (pe->type & EEH_PE_PHB) { - bus = pe->phb->bus; - } else if (pe->type & EEH_PE_BUS) { - edev = list_first_entry(&pe->edevs, struct eeh_dev, list); - pdev = eeh_dev_to_pci_dev(edev); - if (pdev) - bus = pdev->bus; - } - - eeh_unlock(); - - return bus; -} diff --git a/trunk/arch/powerpc/platforms/pseries/eeh_pseries.c b/trunk/arch/powerpc/platforms/pseries/eeh_pseries.c index 19506f935737..c33360ec4f4f 100644 --- a/trunk/arch/powerpc/platforms/pseries/eeh_pseries.c +++ b/trunk/arch/powerpc/platforms/pseries/eeh_pseries.c @@ -129,117 +129,27 @@ static int pseries_eeh_init(void) eeh_error_buf_size = RTAS_ERROR_LOG_MAX; } - /* Set EEH probe mode */ - eeh_probe_mode_set(EEH_PROBE_MODE_DEVTREE); - return 0; } -/** - * pseries_eeh_of_probe - EEH probe on the given device - * @dn: OF node - * @flag: Unused - * - * When EEH module is installed during system boot, all PCI devices - * are checked one by one to see if it supports EEH. The function - * is introduced for the purpose. - */ -static void *pseries_eeh_of_probe(struct device_node *dn, void *flag) -{ - struct eeh_dev *edev; - struct eeh_pe pe; - const u32 *class_code, *vendor_id, *device_id; - const u32 *regs; - int enable = 0; - int ret; - - /* Retrieve OF node and eeh device */ - edev = of_node_to_eeh_dev(dn); - if (!of_device_is_available(dn)) - return NULL; - - /* Retrieve class/vendor/device IDs */ - class_code = of_get_property(dn, "class-code", NULL); - vendor_id = of_get_property(dn, "vendor-id", NULL); - device_id = of_get_property(dn, "device-id", NULL); - - /* Skip for bad OF node or PCI-ISA bridge */ - if (!class_code || !vendor_id || !device_id) - return NULL; - if (dn->type && !strcmp(dn->type, "isa")) - return NULL; - - /* Update class code and mode of eeh device */ - edev->class_code = *class_code; - edev->mode = 0; - - /* Retrieve the device address */ - regs = of_get_property(dn, "reg", NULL); - if (!regs) { - pr_warning("%s: OF node property %s::reg not found\n", - __func__, dn->full_name); - return NULL; - } - - /* Initialize the fake PE */ - memset(&pe, 0, sizeof(struct eeh_pe)); - pe.phb = edev->phb; - pe.config_addr = regs[0]; - - /* Enable EEH on the device */ - ret = eeh_ops->set_option(&pe, EEH_OPT_ENABLE); - if (!ret) { - edev->config_addr = regs[0]; - /* Retrieve PE address */ - edev->pe_config_addr = eeh_ops->get_pe_addr(&pe); - pe.addr = edev->pe_config_addr; - - /* Some older systems (Power4) allow the ibm,set-eeh-option - * call to succeed even on nodes where EEH is not supported. - * Verify support explicitly. - */ - ret = eeh_ops->get_state(&pe, NULL); - if (ret > 0 && ret != EEH_STATE_NOT_SUPPORT) - enable = 1; - - if (enable) { - eeh_subsystem_enabled = 1; - eeh_add_to_parent_pe(edev); - - pr_debug("%s: EEH enabled on %s PHB#%d-PE#%x, config addr#%x\n", - __func__, dn->full_name, pe.phb->global_number, - pe.addr, pe.config_addr); - } else if (dn->parent && of_node_to_eeh_dev(dn->parent) && - (of_node_to_eeh_dev(dn->parent))->pe) { - /* This device doesn't support EEH, but it may have an - * EEH parent, in which case we mark it as supported. - */ - edev->config_addr = of_node_to_eeh_dev(dn->parent)->config_addr; - edev->pe_config_addr = of_node_to_eeh_dev(dn->parent)->pe_config_addr; - eeh_add_to_parent_pe(edev); - } - } - - /* Save memory bars */ - eeh_save_bars(edev); - - return NULL; -} - /** * pseries_eeh_set_option - Initialize EEH or MMIO/DMA reenable - * @pe: EEH PE + * @dn: device node * @option: operation to be issued * * The function is used to control the EEH functionality globally. * Currently, following options are support according to PAPR: * Enable EEH, Disable EEH, Enable MMIO and Enable DMA */ -static int pseries_eeh_set_option(struct eeh_pe *pe, int option) +static int pseries_eeh_set_option(struct device_node *dn, int option) { int ret = 0; + struct eeh_dev *edev; + const u32 *reg; int config_addr; + edev = of_node_to_eeh_dev(dn); + /* * When we're enabling or disabling EEH functioality on * the particular PE, the PE config address is possibly @@ -249,11 +159,15 @@ static int pseries_eeh_set_option(struct eeh_pe *pe, int option) switch (option) { case EEH_OPT_DISABLE: case EEH_OPT_ENABLE: + reg = of_get_property(dn, "reg", NULL); + config_addr = reg[0]; + break; + case EEH_OPT_THAW_MMIO: case EEH_OPT_THAW_DMA: - config_addr = pe->config_addr; - if (pe->addr) - config_addr = pe->addr; + config_addr = edev->config_addr; + if (edev->pe_config_addr) + config_addr = edev->pe_config_addr; break; default: @@ -263,15 +177,15 @@ static int pseries_eeh_set_option(struct eeh_pe *pe, int option) } ret = rtas_call(ibm_set_eeh_option, 4, 1, NULL, - config_addr, BUID_HI(pe->phb->buid), - BUID_LO(pe->phb->buid), option); + config_addr, BUID_HI(edev->phb->buid), + BUID_LO(edev->phb->buid), option); return ret; } /** * pseries_eeh_get_pe_addr - Retrieve PE address - * @pe: EEH PE + * @dn: device node * * Retrieve the assocated PE address. Actually, there're 2 RTAS * function calls dedicated for the purpose. We need implement @@ -282,11 +196,14 @@ static int pseries_eeh_set_option(struct eeh_pe *pe, int option) * It's notable that zero'ed return value means invalid PE config * address. */ -static int pseries_eeh_get_pe_addr(struct eeh_pe *pe) +static int pseries_eeh_get_pe_addr(struct device_node *dn) { + struct eeh_dev *edev; int ret = 0; int rets[3]; + edev = of_node_to_eeh_dev(dn); + if (ibm_get_config_addr_info2 != RTAS_UNKNOWN_SERVICE) { /* * First of all, we need to make sure there has one PE @@ -294,18 +211,18 @@ static int pseries_eeh_get_pe_addr(struct eeh_pe *pe) * meaningless. */ ret = rtas_call(ibm_get_config_addr_info2, 4, 2, rets, - pe->config_addr, BUID_HI(pe->phb->buid), - BUID_LO(pe->phb->buid), 1); + edev->config_addr, BUID_HI(edev->phb->buid), + BUID_LO(edev->phb->buid), 1); if (ret || (rets[0] == 0)) return 0; /* Retrieve the associated PE config address */ ret = rtas_call(ibm_get_config_addr_info2, 4, 2, rets, - pe->config_addr, BUID_HI(pe->phb->buid), - BUID_LO(pe->phb->buid), 0); + edev->config_addr, BUID_HI(edev->phb->buid), + BUID_LO(edev->phb->buid), 0); if (ret) { - pr_warning("%s: Failed to get address for PHB#%d-PE#%x\n", - __func__, pe->phb->global_number, pe->config_addr); + pr_warning("%s: Failed to get PE address for %s\n", + __func__, dn->full_name); return 0; } @@ -314,11 +231,11 @@ static int pseries_eeh_get_pe_addr(struct eeh_pe *pe) if (ibm_get_config_addr_info != RTAS_UNKNOWN_SERVICE) { ret = rtas_call(ibm_get_config_addr_info, 4, 2, rets, - pe->config_addr, BUID_HI(pe->phb->buid), - BUID_LO(pe->phb->buid), 0); + edev->config_addr, BUID_HI(edev->phb->buid), + BUID_LO(edev->phb->buid), 0); if (ret) { - pr_warning("%s: Failed to get address for PHB#%d-PE#%x\n", - __func__, pe->phb->global_number, pe->config_addr); + pr_warning("%s: Failed to get PE address for %s\n", + __func__, dn->full_name); return 0; } @@ -330,7 +247,7 @@ static int pseries_eeh_get_pe_addr(struct eeh_pe *pe) /** * pseries_eeh_get_state - Retrieve PE state - * @pe: EEH PE + * @dn: PE associated device node * @state: return value * * Retrieve the state of the specified PE. On RTAS compliant @@ -341,28 +258,30 @@ static int pseries_eeh_get_pe_addr(struct eeh_pe *pe) * RTAS calls for the purpose, we need to try the new one and back * to the old one if the new one couldn't work properly. */ -static int pseries_eeh_get_state(struct eeh_pe *pe, int *state) +static int pseries_eeh_get_state(struct device_node *dn, int *state) { + struct eeh_dev *edev; int config_addr; int ret; int rets[4]; int result; /* Figure out PE config address if possible */ - config_addr = pe->config_addr; - if (pe->addr) - config_addr = pe->addr; + edev = of_node_to_eeh_dev(dn); + config_addr = edev->config_addr; + if (edev->pe_config_addr) + config_addr = edev->pe_config_addr; if (ibm_read_slot_reset_state2 != RTAS_UNKNOWN_SERVICE) { ret = rtas_call(ibm_read_slot_reset_state2, 3, 4, rets, - config_addr, BUID_HI(pe->phb->buid), - BUID_LO(pe->phb->buid)); + config_addr, BUID_HI(edev->phb->buid), + BUID_LO(edev->phb->buid)); } else if (ibm_read_slot_reset_state != RTAS_UNKNOWN_SERVICE) { /* Fake PE unavailable info */ rets[2] = 0; ret = rtas_call(ibm_read_slot_reset_state, 3, 3, rets, - config_addr, BUID_HI(pe->phb->buid), - BUID_LO(pe->phb->buid)); + config_addr, BUID_HI(edev->phb->buid), + BUID_LO(edev->phb->buid)); } else { return EEH_STATE_NOT_SUPPORT; } @@ -414,32 +333,34 @@ static int pseries_eeh_get_state(struct eeh_pe *pe, int *state) /** * pseries_eeh_reset - Reset the specified PE - * @pe: EEH PE + * @dn: PE associated device node * @option: reset option * * Reset the specified PE */ -static int pseries_eeh_reset(struct eeh_pe *pe, int option) +static int pseries_eeh_reset(struct device_node *dn, int option) { + struct eeh_dev *edev; int config_addr; int ret; /* Figure out PE address */ - config_addr = pe->config_addr; - if (pe->addr) - config_addr = pe->addr; + edev = of_node_to_eeh_dev(dn); + config_addr = edev->config_addr; + if (edev->pe_config_addr) + config_addr = edev->pe_config_addr; /* Reset PE through RTAS call */ ret = rtas_call(ibm_set_slot_reset, 4, 1, NULL, - config_addr, BUID_HI(pe->phb->buid), - BUID_LO(pe->phb->buid), option); + config_addr, BUID_HI(edev->phb->buid), + BUID_LO(edev->phb->buid), option); /* If fundamental-reset not supported, try hot-reset */ if (option == EEH_RESET_FUNDAMENTAL && ret == -8) { ret = rtas_call(ibm_set_slot_reset, 4, 1, NULL, - config_addr, BUID_HI(pe->phb->buid), - BUID_LO(pe->phb->buid), EEH_RESET_HOT); + config_addr, BUID_HI(edev->phb->buid), + BUID_LO(edev->phb->buid), EEH_RESET_HOT); } return ret; @@ -447,13 +368,13 @@ static int pseries_eeh_reset(struct eeh_pe *pe, int option) /** * pseries_eeh_wait_state - Wait for PE state - * @pe: EEH PE + * @dn: PE associated device node * @max_wait: maximal period in microsecond * * Wait for the state of associated PE. It might take some time * to retrieve the PE's state. */ -static int pseries_eeh_wait_state(struct eeh_pe *pe, int max_wait) +static int pseries_eeh_wait_state(struct device_node *dn, int max_wait) { int ret; int mwait; @@ -470,7 +391,7 @@ static int pseries_eeh_wait_state(struct eeh_pe *pe, int max_wait) #define EEH_STATE_MAX_WAIT_TIME (300 * 1000) while (1) { - ret = pseries_eeh_get_state(pe, &mwait); + ret = pseries_eeh_get_state(dn, &mwait); /* * If the PE's state is temporarily unavailable, @@ -505,7 +426,7 @@ static int pseries_eeh_wait_state(struct eeh_pe *pe, int max_wait) /** * pseries_eeh_get_log - Retrieve error log - * @pe: EEH PE + * @dn: device node * @severity: temporary or permanent error log * @drv_log: driver log to be combined with retrieved error log * @len: length of driver log @@ -514,22 +435,24 @@ static int pseries_eeh_wait_state(struct eeh_pe *pe, int max_wait) * Actually, the error will be retrieved through the dedicated * RTAS call. */ -static int pseries_eeh_get_log(struct eeh_pe *pe, int severity, char *drv_log, unsigned long len) +static int pseries_eeh_get_log(struct device_node *dn, int severity, char *drv_log, unsigned long len) { + struct eeh_dev *edev; int config_addr; unsigned long flags; int ret; + edev = of_node_to_eeh_dev(dn); spin_lock_irqsave(&slot_errbuf_lock, flags); memset(slot_errbuf, 0, eeh_error_buf_size); /* Figure out the PE address */ - config_addr = pe->config_addr; - if (pe->addr) - config_addr = pe->addr; + config_addr = edev->config_addr; + if (edev->pe_config_addr) + config_addr = edev->pe_config_addr; ret = rtas_call(ibm_slot_error_detail, 8, 1, NULL, config_addr, - BUID_HI(pe->phb->buid), BUID_LO(pe->phb->buid), + BUID_HI(edev->phb->buid), BUID_LO(edev->phb->buid), virt_to_phys(drv_log), len, virt_to_phys(slot_errbuf), eeh_error_buf_size, severity); @@ -542,38 +465,40 @@ static int pseries_eeh_get_log(struct eeh_pe *pe, int severity, char *drv_log, u /** * pseries_eeh_configure_bridge - Configure PCI bridges in the indicated PE - * @pe: EEH PE + * @dn: PE associated device node * * The function will be called to reconfigure the bridges included * in the specified PE so that the mulfunctional PE would be recovered * again. */ -static int pseries_eeh_configure_bridge(struct eeh_pe *pe) +static int pseries_eeh_configure_bridge(struct device_node *dn) { + struct eeh_dev *edev; int config_addr; int ret; /* Figure out the PE address */ - config_addr = pe->config_addr; - if (pe->addr) - config_addr = pe->addr; + edev = of_node_to_eeh_dev(dn); + config_addr = edev->config_addr; + if (edev->pe_config_addr) + config_addr = edev->pe_config_addr; /* Use new configure-pe function, if supported */ if (ibm_configure_pe != RTAS_UNKNOWN_SERVICE) { ret = rtas_call(ibm_configure_pe, 3, 1, NULL, - config_addr, BUID_HI(pe->phb->buid), - BUID_LO(pe->phb->buid)); + config_addr, BUID_HI(edev->phb->buid), + BUID_LO(edev->phb->buid)); } else if (ibm_configure_bridge != RTAS_UNKNOWN_SERVICE) { ret = rtas_call(ibm_configure_bridge, 3, 1, NULL, - config_addr, BUID_HI(pe->phb->buid), - BUID_LO(pe->phb->buid)); + config_addr, BUID_HI(edev->phb->buid), + BUID_LO(edev->phb->buid)); } else { return -EFAULT; } if (ret) - pr_warning("%s: Unable to configure bridge PHB#%d-PE#%x (%d)\n", - __func__, pe->phb->global_number, pe->addr, ret); + pr_warning("%s: Unable to configure bridge %d for %s\n", + __func__, ret, dn->full_name); return ret; } @@ -617,8 +542,6 @@ static int pseries_eeh_write_config(struct device_node *dn, int where, int size, static struct eeh_ops pseries_eeh_ops = { .name = "pseries", .init = pseries_eeh_init, - .of_probe = pseries_eeh_of_probe, - .dev_probe = NULL, .set_option = pseries_eeh_set_option, .get_pe_addr = pseries_eeh_get_pe_addr, .get_state = pseries_eeh_get_state, @@ -636,21 +559,7 @@ static struct eeh_ops pseries_eeh_ops = { * EEH initialization on pseries platform. This function should be * called before any EEH related functions. */ -static int __init eeh_pseries_init(void) +int __init eeh_pseries_init(void) { - int ret = -EINVAL; - - if (!machine_is(pseries)) - return ret; - - ret = eeh_ops_register(&pseries_eeh_ops); - if (!ret) - pr_info("EEH: pSeries platform initialized\n"); - else - pr_info("EEH: pSeries platform initialization failure (%d)\n", - ret); - - return ret; + return eeh_ops_register(&pseries_eeh_ops); } - -early_initcall(eeh_pseries_init); diff --git a/trunk/arch/powerpc/platforms/pseries/eeh_sysfs.c b/trunk/arch/powerpc/platforms/pseries/eeh_sysfs.c index d37708360f2e..243b3510d70f 100644 --- a/trunk/arch/powerpc/platforms/pseries/eeh_sysfs.c +++ b/trunk/arch/powerpc/platforms/pseries/eeh_sysfs.c @@ -53,6 +53,9 @@ static DEVICE_ATTR(_name, S_IRUGO, eeh_show_##_name, NULL); EEH_SHOW_ATTR(eeh_mode, mode, "0x%x"); EEH_SHOW_ATTR(eeh_config_addr, config_addr, "0x%x"); EEH_SHOW_ATTR(eeh_pe_config_addr, pe_config_addr, "0x%x"); +EEH_SHOW_ATTR(eeh_check_count, check_count, "%d" ); +EEH_SHOW_ATTR(eeh_freeze_count, freeze_count, "%d" ); +EEH_SHOW_ATTR(eeh_false_positives, false_positives, "%d" ); void eeh_sysfs_add_device(struct pci_dev *pdev) { @@ -61,6 +64,9 @@ void eeh_sysfs_add_device(struct pci_dev *pdev) rc += device_create_file(&pdev->dev, &dev_attr_eeh_mode); rc += device_create_file(&pdev->dev, &dev_attr_eeh_config_addr); rc += device_create_file(&pdev->dev, &dev_attr_eeh_pe_config_addr); + rc += device_create_file(&pdev->dev, &dev_attr_eeh_check_count); + rc += device_create_file(&pdev->dev, &dev_attr_eeh_false_positives); + rc += device_create_file(&pdev->dev, &dev_attr_eeh_freeze_count); if (rc) printk(KERN_WARNING "EEH: Unable to create sysfs entries\n"); @@ -71,5 +77,8 @@ void eeh_sysfs_remove_device(struct pci_dev *pdev) device_remove_file(&pdev->dev, &dev_attr_eeh_mode); device_remove_file(&pdev->dev, &dev_attr_eeh_config_addr); device_remove_file(&pdev->dev, &dev_attr_eeh_pe_config_addr); + device_remove_file(&pdev->dev, &dev_attr_eeh_check_count); + device_remove_file(&pdev->dev, &dev_attr_eeh_false_positives); + device_remove_file(&pdev->dev, &dev_attr_eeh_freeze_count); } diff --git a/trunk/arch/powerpc/platforms/pseries/iommu.c b/trunk/arch/powerpc/platforms/pseries/iommu.c index 6153eea27ce7..bca220f2873c 100644 --- a/trunk/arch/powerpc/platforms/pseries/iommu.c +++ b/trunk/arch/powerpc/platforms/pseries/iommu.c @@ -28,7 +28,6 @@ #include #include #include -#include #include #include /* for show_stack */ #include @@ -42,6 +41,7 @@ #include #include #include +#include #include #include #include @@ -99,7 +99,7 @@ static int tce_build_pSeries(struct iommu_table *tbl, long index, while (npages--) { /* can't move this out since we might cross MEMBLOCK boundary */ - rpn = __pa(uaddr) >> TCE_SHIFT; + rpn = (virt_to_abs(uaddr)) >> TCE_SHIFT; *tcep = proto_tce | (rpn & TCE_RPN_MASK) << TCE_RPN_SHIFT; uaddr += TCE_PAGE_SIZE; @@ -148,7 +148,7 @@ static int tce_build_pSeriesLP(struct iommu_table *tbl, long tcenum, int ret = 0; long tcenum_start = tcenum, npages_start = npages; - rpn = __pa(uaddr) >> TCE_SHIFT; + rpn = (virt_to_abs(uaddr)) >> TCE_SHIFT; proto_tce = TCE_PCI_READ; if (direction != DMA_TO_DEVICE) proto_tce |= TCE_PCI_WRITE; @@ -217,7 +217,7 @@ static int tce_buildmulti_pSeriesLP(struct iommu_table *tbl, long tcenum, __get_cpu_var(tce_page) = tcep; } - rpn = __pa(uaddr) >> TCE_SHIFT; + rpn = (virt_to_abs(uaddr)) >> TCE_SHIFT; proto_tce = TCE_PCI_READ; if (direction != DMA_TO_DEVICE) proto_tce |= TCE_PCI_WRITE; @@ -237,7 +237,7 @@ static int tce_buildmulti_pSeriesLP(struct iommu_table *tbl, long tcenum, rc = plpar_tce_put_indirect((u64)tbl->it_index, (u64)tcenum << 12, - (u64)__pa(tcep), + (u64)virt_to_abs(tcep), limit); npages -= limit; @@ -441,7 +441,7 @@ static int tce_setrange_multi_pSeriesLP(unsigned long start_pfn, rc = plpar_tce_put_indirect(liobn, dma_offset, - (u64)__pa(tcep), + (u64)virt_to_abs(tcep), limit); num_tce -= limit; diff --git a/trunk/arch/powerpc/platforms/pseries/lpar.c b/trunk/arch/powerpc/platforms/pseries/lpar.c index 0da39fed355a..5f3ef876ded2 100644 --- a/trunk/arch/powerpc/platforms/pseries/lpar.c +++ b/trunk/arch/powerpc/platforms/pseries/lpar.c @@ -31,6 +31,7 @@ #include #include #include +#include #include #include #include @@ -107,9 +108,9 @@ void vpa_init(int cpu) } static long pSeries_lpar_hpte_insert(unsigned long hpte_group, - unsigned long vpn, unsigned long pa, - unsigned long rflags, unsigned long vflags, - int psize, int ssize) + unsigned long va, unsigned long pa, + unsigned long rflags, unsigned long vflags, + int psize, int ssize) { unsigned long lpar_rc; unsigned long flags; @@ -117,11 +118,11 @@ static long pSeries_lpar_hpte_insert(unsigned long hpte_group, unsigned long hpte_v, hpte_r; if (!(vflags & HPTE_V_BOLTED)) - pr_devel("hpte_insert(group=%lx, vpn=%016lx, " - "pa=%016lx, rflags=%lx, vflags=%lx, psize=%d)\n", - hpte_group, vpn, pa, rflags, vflags, psize); + pr_devel("hpte_insert(group=%lx, va=%016lx, pa=%016lx, " + "rflags=%lx, vflags=%lx, psize=%d)\n", + hpte_group, va, pa, rflags, vflags, psize); - hpte_v = hpte_encode_v(vpn, psize, ssize) | vflags | HPTE_V_VALID; + hpte_v = hpte_encode_v(va, psize, ssize) | vflags | HPTE_V_VALID; hpte_r = hpte_encode_r(pa, psize) | rflags; if (!(vflags & HPTE_V_BOLTED)) @@ -225,6 +226,22 @@ static void pSeries_lpar_hptab_clear(void) } } +/* + * This computes the AVPN and B fields of the first dword of a HPTE, + * for use when we want to match an existing PTE. The bottom 7 bits + * of the returned value are zero. + */ +static inline unsigned long hpte_encode_avpn(unsigned long va, int psize, + int ssize) +{ + unsigned long v; + + v = (va >> 23) & ~(mmu_psize_defs[psize].avpnm); + v <<= HPTE_V_AVPN_SHIFT; + v |= ((unsigned long) ssize) << HPTE_V_SSIZE_SHIFT; + return v; +} + /* * NOTE: for updatepp ops we are fortunate that the linux "newpp" bits and * the low 3 bits of flags happen to line up. So no transform is needed. @@ -233,14 +250,14 @@ static void pSeries_lpar_hptab_clear(void) */ static long pSeries_lpar_hpte_updatepp(unsigned long slot, unsigned long newpp, - unsigned long vpn, + unsigned long va, int psize, int ssize, int local) { unsigned long lpar_rc; unsigned long flags = (newpp & 7) | H_AVPN; unsigned long want_v; - want_v = hpte_encode_avpn(vpn, psize, ssize); + want_v = hpte_encode_avpn(va, psize, ssize); pr_devel(" update: avpnv=%016lx, hash=%016lx, f=%lx, psize: %d ...", want_v, slot, flags, psize); @@ -278,15 +295,15 @@ static unsigned long pSeries_lpar_hpte_getword0(unsigned long slot) return dword0; } -static long pSeries_lpar_hpte_find(unsigned long vpn, int psize, int ssize) +static long pSeries_lpar_hpte_find(unsigned long va, int psize, int ssize) { unsigned long hash; unsigned long i; long slot; unsigned long want_v, hpte_v; - hash = hpt_hash(vpn, mmu_psize_defs[psize].shift, ssize); - want_v = hpte_encode_avpn(vpn, psize, ssize); + hash = hpt_hash(va, mmu_psize_defs[psize].shift, ssize); + want_v = hpte_encode_avpn(va, psize, ssize); /* Bolted entries are always in the primary group */ slot = (hash & htab_hash_mask) * HPTES_PER_GROUP; @@ -306,13 +323,12 @@ static void pSeries_lpar_hpte_updateboltedpp(unsigned long newpp, unsigned long ea, int psize, int ssize) { - unsigned long vpn; - unsigned long lpar_rc, slot, vsid, flags; + unsigned long lpar_rc, slot, vsid, va, flags; vsid = get_kernel_vsid(ea, ssize); - vpn = hpt_vpn(ea, vsid, ssize); + va = hpt_va(ea, vsid, ssize); - slot = pSeries_lpar_hpte_find(vpn, psize, ssize); + slot = pSeries_lpar_hpte_find(va, psize, ssize); BUG_ON(slot == -1); flags = newpp & 7; @@ -321,17 +337,17 @@ static void pSeries_lpar_hpte_updateboltedpp(unsigned long newpp, BUG_ON(lpar_rc != H_SUCCESS); } -static void pSeries_lpar_hpte_invalidate(unsigned long slot, unsigned long vpn, +static void pSeries_lpar_hpte_invalidate(unsigned long slot, unsigned long va, int psize, int ssize, int local) { unsigned long want_v; unsigned long lpar_rc; unsigned long dummy1, dummy2; - pr_devel(" inval : slot=%lx, vpn=%016lx, psize: %d, local: %d\n", - slot, vpn, psize, local); + pr_devel(" inval : slot=%lx, va=%016lx, psize: %d, local: %d\n", + slot, va, psize, local); - want_v = hpte_encode_avpn(vpn, psize, ssize); + want_v = hpte_encode_avpn(va, psize, ssize); lpar_rc = plpar_pte_remove(H_AVPN, slot, want_v, &dummy1, &dummy2); if (lpar_rc == H_NOT_FOUND) return; @@ -342,16 +358,15 @@ static void pSeries_lpar_hpte_invalidate(unsigned long slot, unsigned long vpn, static void pSeries_lpar_hpte_removebolted(unsigned long ea, int psize, int ssize) { - unsigned long vpn; - unsigned long slot, vsid; + unsigned long slot, vsid, va; vsid = get_kernel_vsid(ea, ssize); - vpn = hpt_vpn(ea, vsid, ssize); + va = hpt_va(ea, vsid, ssize); - slot = pSeries_lpar_hpte_find(vpn, psize, ssize); + slot = pSeries_lpar_hpte_find(va, psize, ssize); BUG_ON(slot == -1); - pSeries_lpar_hpte_invalidate(slot, vpn, psize, ssize, 0); + pSeries_lpar_hpte_invalidate(slot, va, psize, ssize, 0); } /* Flag bits for H_BULK_REMOVE */ @@ -367,12 +382,12 @@ static void pSeries_lpar_hpte_removebolted(unsigned long ea, */ static void pSeries_lpar_flush_hash_range(unsigned long number, int local) { - unsigned long vpn; unsigned long i, pix, rc; unsigned long flags = 0; struct ppc64_tlb_batch *batch = &__get_cpu_var(ppc64_tlb_batch); int lock_tlbie = !mmu_has_feature(MMU_FTR_LOCKLESS_TLBIE); unsigned long param[9]; + unsigned long va; unsigned long hash, index, shift, hidx, slot; real_pte_t pte; int psize, ssize; @@ -384,21 +399,21 @@ static void pSeries_lpar_flush_hash_range(unsigned long number, int local) ssize = batch->ssize; pix = 0; for (i = 0; i < number; i++) { - vpn = batch->vpn[i]; + va = batch->vaddr[i]; pte = batch->pte[i]; - pte_iterate_hashed_subpages(pte, psize, vpn, index, shift) { - hash = hpt_hash(vpn, shift, ssize); + pte_iterate_hashed_subpages(pte, psize, va, index, shift) { + hash = hpt_hash(va, shift, ssize); hidx = __rpte_to_hidx(pte, index); if (hidx & _PTEIDX_SECONDARY) hash = ~hash; slot = (hash & htab_hash_mask) * HPTES_PER_GROUP; slot += hidx & _PTEIDX_GROUP_IX; if (!firmware_has_feature(FW_FEATURE_BULK_REMOVE)) { - pSeries_lpar_hpte_invalidate(slot, vpn, psize, + pSeries_lpar_hpte_invalidate(slot, va, psize, ssize, local); } else { param[pix] = HBR_REQUEST | HBR_AVPN | slot; - param[pix+1] = hpte_encode_avpn(vpn, psize, + param[pix+1] = hpte_encode_avpn(va, psize, ssize); pix += 2; if (pix == 8) { diff --git a/trunk/arch/powerpc/platforms/pseries/msi.c b/trunk/arch/powerpc/platforms/pseries/msi.c index d19f4977c834..109fdb75578d 100644 --- a/trunk/arch/powerpc/platforms/pseries/msi.c +++ b/trunk/arch/powerpc/platforms/pseries/msi.c @@ -210,7 +210,6 @@ static struct device_node *find_pe_total_msi(struct pci_dev *dev, int *total) static struct device_node *find_pe_dn(struct pci_dev *dev, int *total) { struct device_node *dn; - struct eeh_dev *edev; /* Found our PE and assume 8 at that point. */ @@ -218,10 +217,7 @@ static struct device_node *find_pe_dn(struct pci_dev *dev, int *total) if (!dn) return NULL; - /* Get the top level device in the PE */ - edev = of_node_to_eeh_dev(dn); - edev = list_first_entry(&edev->pe->edevs, struct eeh_dev, list); - dn = eeh_dev_to_of_node(edev); + dn = eeh_find_device_pe(dn); if (!dn) return NULL; @@ -391,13 +387,12 @@ static int check_msix_entries(struct pci_dev *pdev) return 0; } -static int rtas_setup_msi_irqs(struct pci_dev *pdev, int nvec_in, int type) +static int rtas_setup_msi_irqs(struct pci_dev *pdev, int nvec, int type) { struct pci_dn *pdn; int hwirq, virq, i, rc; struct msi_desc *entry; struct msi_msg msg; - int nvec = nvec_in; pdn = get_pdn(pdev); if (!pdn) @@ -406,24 +401,11 @@ static int rtas_setup_msi_irqs(struct pci_dev *pdev, int nvec_in, int type) if (type == PCI_CAP_ID_MSIX && check_msix_entries(pdev)) return -EINVAL; - /* - * Firmware currently refuse any non power of two allocation - * so we round up if the quota will allow it. - */ - if (type == PCI_CAP_ID_MSIX) { - int m = roundup_pow_of_two(nvec); - int quota = msi_quota_for_device(pdev, m); - - if (quota >= m) - nvec = m; - } - /* * Try the new more explicit firmware interface, if that fails fall * back to the old interface. The old interface is known to never * return MSI-Xs. */ -again: if (type == PCI_CAP_ID_MSI) { rc = rtas_change_msi(pdn, RTAS_CHANGE_MSI_FN, nvec); @@ -435,10 +417,6 @@ static int rtas_setup_msi_irqs(struct pci_dev *pdev, int nvec_in, int type) rc = rtas_change_msi(pdn, RTAS_CHANGE_MSIX_FN, nvec); if (rc != nvec) { - if (nvec != nvec_in) { - nvec = nvec_in; - goto again; - } pr_debug("rtas_msi: rtas_change_msi() failed\n"); return rc; } diff --git a/trunk/arch/powerpc/platforms/pseries/pci.c b/trunk/arch/powerpc/platforms/pseries/pci.c index 56b864d777ee..2c6ded29f73d 100644 --- a/trunk/arch/powerpc/platforms/pseries/pci.c +++ b/trunk/arch/powerpc/platforms/pseries/pci.c @@ -73,7 +73,7 @@ void __init pSeries_final_fixup(void) { pSeries_request_regions(); - eeh_addr_cache_build(); + pci_addr_cache_build(); } /* diff --git a/trunk/arch/powerpc/platforms/pseries/pci_dlpar.c b/trunk/arch/powerpc/platforms/pseries/pci_dlpar.c index 261a577a3dd2..3ccebc83dc02 100644 --- a/trunk/arch/powerpc/platforms/pseries/pci_dlpar.c +++ b/trunk/arch/powerpc/platforms/pseries/pci_dlpar.c @@ -65,43 +65,27 @@ pcibios_find_pci_bus(struct device_node *dn) EXPORT_SYMBOL_GPL(pcibios_find_pci_bus); /** - * __pcibios_remove_pci_devices - remove all devices under this bus - * @bus: the indicated PCI bus - * @purge_pe: destroy the PE on removal of PCI devices + * pcibios_remove_pci_devices - remove all devices under this bus * * Remove all of the PCI devices under this bus both from the * linux pci device tree, and from the powerpc EEH address cache. - * By default, the corresponding PE will be destroied during the - * normal PCI hotplug path. For PCI hotplug during EEH recovery, - * the corresponding PE won't be destroied and deallocated. */ -void __pcibios_remove_pci_devices(struct pci_bus *bus, int purge_pe) +void pcibios_remove_pci_devices(struct pci_bus *bus) { - struct pci_dev *dev, *tmp; + struct pci_dev *dev, *tmp; struct pci_bus *child_bus; /* First go down child busses */ list_for_each_entry(child_bus, &bus->children, node) - __pcibios_remove_pci_devices(child_bus, purge_pe); + pcibios_remove_pci_devices(child_bus); pr_debug("PCI: Removing devices on bus %04x:%02x\n", - pci_domain_nr(bus), bus->number); + pci_domain_nr(bus), bus->number); list_for_each_entry_safe(dev, tmp, &bus->devices, bus_list) { pr_debug(" * Removing %s...\n", pci_name(dev)); - eeh_remove_bus_device(dev, purge_pe); - pci_stop_and_remove_bus_device(dev); - } -} - -/** - * pcibios_remove_pci_devices - remove all devices under this bus - * - * Remove all of the PCI devices under this bus both from the - * linux pci device tree, and from the powerpc EEH address cache. - */ -void pcibios_remove_pci_devices(struct pci_bus *bus) -{ - __pcibios_remove_pci_devices(bus, 1); + eeh_remove_bus_device(dev); + pci_stop_and_remove_bus_device(dev); + } } EXPORT_SYMBOL_GPL(pcibios_remove_pci_devices); diff --git a/trunk/arch/powerpc/platforms/pseries/setup.c b/trunk/arch/powerpc/platforms/pseries/setup.c index e3cb7ae61658..51ecac920dd8 100644 --- a/trunk/arch/powerpc/platforms/pseries/setup.c +++ b/trunk/arch/powerpc/platforms/pseries/setup.c @@ -388,8 +388,10 @@ static void __init pSeries_setup_arch(void) /* Find and initialize PCI host bridges */ init_pci_config_tokens(); + eeh_pseries_init(); find_and_init_phbs(); pSeries_reconfig_notifier_register(&pci_dn_reconfig_nb); + eeh_init(); pSeries_nvram_init(); @@ -414,20 +416,16 @@ static int __init pSeries_init_panel(void) } machine_arch_initcall(pseries, pSeries_init_panel); -static int pseries_set_dabr(unsigned long dabr, unsigned long dabrx) +static int pseries_set_dabr(unsigned long dabr) { return plpar_hcall_norets(H_SET_DABR, dabr); } -static int pseries_set_xdabr(unsigned long dabr, unsigned long dabrx) +static int pseries_set_xdabr(unsigned long dabr) { - /* Have to set at least one bit in the DABRX according to PAPR */ - if (dabrx == 0 && dabr == 0) - dabrx = DABRX_USER; - /* PAPR says we can only set kernel and user bits */ - dabrx &= DABRX_KERNEL | DABRX_USER; - - return plpar_hcall_norets(H_SET_XDABR, dabr, dabrx); + /* We want to catch accesses from kernel and userspace */ + return plpar_hcall_norets(H_SET_XDABR, dabr, + H_DABRX_KERNEL | H_DABRX_USER); } #define CMO_CHARACTERISTICS_TOKEN 44 @@ -531,10 +529,10 @@ static void __init pSeries_init_early(void) if (firmware_has_feature(FW_FEATURE_LPAR)) hvc_vio_init_early(); #endif - if (firmware_has_feature(FW_FEATURE_XDABR)) - ppc_md.set_dabr = pseries_set_xdabr; - else if (firmware_has_feature(FW_FEATURE_DABR)) + if (firmware_has_feature(FW_FEATURE_DABR)) ppc_md.set_dabr = pseries_set_dabr; + else if (firmware_has_feature(FW_FEATURE_XDABR)) + ppc_md.set_dabr = pseries_set_xdabr; pSeries_cmo_feature_init(); iommu_init_early_pSeries(); diff --git a/trunk/arch/powerpc/sysdev/Makefile b/trunk/arch/powerpc/sysdev/Makefile index a57600b3a4e3..1bd7ecb24620 100644 --- a/trunk/arch/powerpc/sysdev/Makefile +++ b/trunk/arch/powerpc/sysdev/Makefile @@ -15,7 +15,7 @@ obj-$(CONFIG_PPC_DCR_NATIVE) += dcr-low.o obj-$(CONFIG_PPC_PMI) += pmi.o obj-$(CONFIG_U3_DART) += dart_iommu.o obj-$(CONFIG_MMIO_NVRAM) += mmio_nvram.o -obj-$(CONFIG_FSL_SOC) += fsl_soc.o fsl_mpic_err.o +obj-$(CONFIG_FSL_SOC) += fsl_soc.o obj-$(CONFIG_FSL_PCI) += fsl_pci.o $(fsl-msi-obj-y) obj-$(CONFIG_FSL_PMC) += fsl_pmc.o obj-$(CONFIG_FSL_LBC) += fsl_lbc.o diff --git a/trunk/arch/powerpc/sysdev/dart_iommu.c b/trunk/arch/powerpc/sysdev/dart_iommu.c index bd968a43a48b..4f2680f431b5 100644 --- a/trunk/arch/powerpc/sysdev/dart_iommu.c +++ b/trunk/arch/powerpc/sysdev/dart_iommu.c @@ -43,6 +43,7 @@ #include #include #include +#include #include #include @@ -73,16 +74,11 @@ static int dart_is_u4; #define DBG(...) -static DEFINE_SPINLOCK(invalidate_lock); - static inline void dart_tlb_invalidate_all(void) { unsigned long l = 0; unsigned int reg, inv_bit; unsigned long limit; - unsigned long flags; - - spin_lock_irqsave(&invalidate_lock, flags); DBG("dart: flush\n"); @@ -115,17 +111,12 @@ static inline void dart_tlb_invalidate_all(void) panic("DART: TLB did not flush after waiting a long " "time. Buggy U3 ?"); } - - spin_unlock_irqrestore(&invalidate_lock, flags); } static inline void dart_tlb_invalidate_one(unsigned long bus_rpn) { unsigned int reg; unsigned int l, limit; - unsigned long flags; - - spin_lock_irqsave(&invalidate_lock, flags); reg = DART_CNTL_U4_ENABLE | DART_CNTL_U4_IONE | (bus_rpn & DART_CNTL_U4_IONE_MASK); @@ -147,8 +138,6 @@ static inline void dart_tlb_invalidate_one(unsigned long bus_rpn) panic("DART: TLB did not flush after waiting a long " "time. Buggy U4 ?"); } - - spin_unlock_irqrestore(&invalidate_lock, flags); } static void dart_flush(struct iommu_table *tbl) @@ -178,7 +167,7 @@ static int dart_build(struct iommu_table *tbl, long index, */ l = npages; while (l--) { - rpn = __pa(uaddr) >> DART_PAGE_SHIFT; + rpn = virt_to_abs(uaddr) >> DART_PAGE_SHIFT; *(dp++) = DARTMAP_VALID | (rpn & DARTMAP_RPNMASK); @@ -255,7 +244,7 @@ static int __init dart_init(struct device_node *dart_node) panic("DART: Cannot map registers!"); /* Map in DART table */ - dart_vbase = ioremap(__pa(dart_tablebase), dart_tablesize); + dart_vbase = ioremap(virt_to_abs(dart_tablebase), dart_tablesize); /* Fill initial table */ for (i = 0; i < dart_tablesize/4; i++) @@ -474,7 +463,7 @@ void __init alloc_dart_table(void) * will blow up an entire large page anyway in the kernel mapping */ dart_tablebase = (unsigned long) - __va(memblock_alloc_base(1UL<<24, 1UL<<24, 0x80000000L)); + abs_to_virt(memblock_alloc_base(1UL<<24, 1UL<<24, 0x80000000L)); printk(KERN_INFO "DART table allocated at: %lx\n", dart_tablebase); } diff --git a/trunk/arch/powerpc/sysdev/fsl_85xx_l2ctlr.c b/trunk/arch/powerpc/sysdev/fsl_85xx_l2ctlr.c index d131c8a1cb15..68ac3aacb191 100644 --- a/trunk/arch/powerpc/sysdev/fsl_85xx_l2ctlr.c +++ b/trunk/arch/powerpc/sysdev/fsl_85xx_l2ctlr.c @@ -193,16 +193,6 @@ static struct of_device_id mpc85xx_l2ctlr_of_match[] = { { .compatible = "fsl,mpc8548-l2-cache-controller", }, - { .compatible = "fsl,mpc8544-l2-cache-controller",}, - { .compatible = "fsl,mpc8572-l2-cache-controller",}, - { .compatible = "fsl,mpc8536-l2-cache-controller",}, - { .compatible = "fsl,p1021-l2-cache-controller",}, - { .compatible = "fsl,p1012-l2-cache-controller",}, - { .compatible = "fsl,p1025-l2-cache-controller",}, - { .compatible = "fsl,p1016-l2-cache-controller",}, - { .compatible = "fsl,p1024-l2-cache-controller",}, - { .compatible = "fsl,p1015-l2-cache-controller",}, - { .compatible = "fsl,p1010-l2-cache-controller",}, {}, }; diff --git a/trunk/arch/powerpc/sysdev/fsl_ifc.c b/trunk/arch/powerpc/sysdev/fsl_ifc.c index 097cc9d2585b..b31f19f61031 100644 --- a/trunk/arch/powerpc/sysdev/fsl_ifc.c +++ b/trunk/arch/powerpc/sysdev/fsl_ifc.c @@ -244,6 +244,12 @@ static int __devinit fsl_ifc_ctrl_probe(struct platform_device *dev) /* get the nand machine irq */ fsl_ifc_ctrl_dev->nand_irq = irq_of_parse_and_map(dev->dev.of_node, 1); + if (fsl_ifc_ctrl_dev->nand_irq == NO_IRQ) { + dev_err(&dev->dev, "failed to get irq resource " + "for NAND Machine\n"); + ret = -ENODEV; + goto err; + } fsl_ifc_ctrl_dev->dev = &dev->dev; @@ -261,14 +267,12 @@ static int __devinit fsl_ifc_ctrl_probe(struct platform_device *dev) goto err_irq; } - if (fsl_ifc_ctrl_dev->nand_irq) { - ret = request_irq(fsl_ifc_ctrl_dev->nand_irq, fsl_ifc_nand_irq, - 0, "fsl-ifc-nand", fsl_ifc_ctrl_dev); - if (ret != 0) { - dev_err(&dev->dev, "failed to install irq (%d)\n", - fsl_ifc_ctrl_dev->nand_irq); - goto err_nandirq; - } + ret = request_irq(fsl_ifc_ctrl_dev->nand_irq, fsl_ifc_nand_irq, 0, + "fsl-ifc-nand", fsl_ifc_ctrl_dev); + if (ret != 0) { + dev_err(&dev->dev, "failed to install irq (%d)\n", + fsl_ifc_ctrl_dev->nand_irq); + goto err_nandirq; } return 0; diff --git a/trunk/arch/powerpc/sysdev/fsl_mpic_err.c b/trunk/arch/powerpc/sysdev/fsl_mpic_err.c deleted file mode 100644 index b83f32562a37..000000000000 --- a/trunk/arch/powerpc/sysdev/fsl_mpic_err.c +++ /dev/null @@ -1,149 +0,0 @@ -/* - * Copyright (C) 2012 Freescale Semiconductor, Inc. - * - * Author: Varun Sethi - * - * 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 -#include -#include - -#include -#include -#include - -#include "mpic.h" - -#define MPIC_ERR_INT_BASE 0x3900 -#define MPIC_ERR_INT_EISR 0x0000 -#define MPIC_ERR_INT_EIMR 0x0010 - -static inline u32 mpic_fsl_err_read(u32 __iomem *base, unsigned int err_reg) -{ - return in_be32(base + (err_reg >> 2)); -} - -static inline void mpic_fsl_err_write(u32 __iomem *base, u32 value) -{ - out_be32(base + (MPIC_ERR_INT_EIMR >> 2), value); -} - -static void fsl_mpic_mask_err(struct irq_data *d) -{ - u32 eimr; - struct mpic *mpic = irq_data_get_irq_chip_data(d); - unsigned int src = virq_to_hw(d->irq) - mpic->err_int_vecs[0]; - - eimr = mpic_fsl_err_read(mpic->err_regs, MPIC_ERR_INT_EIMR); - eimr |= (1 << (31 - src)); - mpic_fsl_err_write(mpic->err_regs, eimr); -} - -static void fsl_mpic_unmask_err(struct irq_data *d) -{ - u32 eimr; - struct mpic *mpic = irq_data_get_irq_chip_data(d); - unsigned int src = virq_to_hw(d->irq) - mpic->err_int_vecs[0]; - - eimr = mpic_fsl_err_read(mpic->err_regs, MPIC_ERR_INT_EIMR); - eimr &= ~(1 << (31 - src)); - mpic_fsl_err_write(mpic->err_regs, eimr); -} - -static struct irq_chip fsl_mpic_err_chip = { - .irq_disable = fsl_mpic_mask_err, - .irq_mask = fsl_mpic_mask_err, - .irq_unmask = fsl_mpic_unmask_err, -}; - -int mpic_setup_error_int(struct mpic *mpic, int intvec) -{ - int i; - - mpic->err_regs = ioremap(mpic->paddr + MPIC_ERR_INT_BASE, 0x1000); - if (!mpic->err_regs) { - pr_err("could not map mpic error registers\n"); - return -ENOMEM; - } - mpic->hc_err = fsl_mpic_err_chip; - mpic->hc_err.name = mpic->name; - mpic->flags |= MPIC_FSL_HAS_EIMR; - /* allocate interrupt vectors for error interrupts */ - for (i = MPIC_MAX_ERR - 1; i >= 0; i--) - mpic->err_int_vecs[i] = --intvec; - - return 0; -} - -int mpic_map_error_int(struct mpic *mpic, unsigned int virq, irq_hw_number_t hw) -{ - if ((mpic->flags & MPIC_FSL_HAS_EIMR) && - (hw >= mpic->err_int_vecs[0] && - hw <= mpic->err_int_vecs[MPIC_MAX_ERR - 1])) { - WARN_ON(mpic->flags & MPIC_SECONDARY); - - pr_debug("mpic: mapping as Error Interrupt\n"); - irq_set_chip_data(virq, mpic); - irq_set_chip_and_handler(virq, &mpic->hc_err, - handle_level_irq); - return 1; - } - - return 0; -} - -static irqreturn_t fsl_error_int_handler(int irq, void *data) -{ - struct mpic *mpic = (struct mpic *) data; - u32 eisr, eimr; - int errint; - unsigned int cascade_irq; - - eisr = mpic_fsl_err_read(mpic->err_regs, MPIC_ERR_INT_EISR); - eimr = mpic_fsl_err_read(mpic->err_regs, MPIC_ERR_INT_EIMR); - - if (!(eisr & ~eimr)) - return IRQ_NONE; - - while (eisr) { - errint = __builtin_clz(eisr); - cascade_irq = irq_linear_revmap(mpic->irqhost, - mpic->err_int_vecs[errint]); - WARN_ON(cascade_irq == NO_IRQ); - if (cascade_irq != NO_IRQ) { - generic_handle_irq(cascade_irq); - } else { - eimr |= 1 << (31 - errint); - mpic_fsl_err_write(mpic->err_regs, eimr); - } - eisr &= ~(1 << (31 - errint)); - } - - return IRQ_HANDLED; -} - -void mpic_err_int_init(struct mpic *mpic, irq_hw_number_t irqnum) -{ - unsigned int virq; - int ret; - - virq = irq_create_mapping(mpic->irqhost, irqnum); - if (virq == NO_IRQ) { - pr_err("Error interrupt setup failed\n"); - return; - } - - /* Mask all error interrupts */ - mpic_fsl_err_write(mpic->err_regs, ~0); - - ret = request_irq(virq, fsl_error_int_handler, IRQF_NO_THREAD, - "mpic-error-int", mpic); - if (ret) - pr_err("Failed to register error interrupt handler\n"); -} diff --git a/trunk/arch/powerpc/sysdev/fsl_pci.c b/trunk/arch/powerpc/sysdev/fsl_pci.c index ffb93ae9379b..c37f46136321 100644 --- a/trunk/arch/powerpc/sysdev/fsl_pci.c +++ b/trunk/arch/powerpc/sysdev/fsl_pci.c @@ -38,15 +38,15 @@ static int fsl_pcie_bus_fixup, is_mpc83xx_pci; static void __devinit quirk_fsl_pcie_header(struct pci_dev *dev) { - u8 hdr_type; + u8 progif; /* if we aren't a PCIe don't bother */ if (!pci_find_capability(dev, PCI_CAP_ID_EXP)) return; /* if we aren't in host mode don't bother */ - pci_read_config_byte(dev, PCI_HEADER_TYPE, &hdr_type); - if ((hdr_type & 0x7f) != PCI_HEADER_TYPE_BRIDGE) + pci_read_config_byte(dev, PCI_CLASS_PROG, &progif); + if (progif & 0x1) return; dev->class = PCI_CLASS_BRIDGE_PCI << 8; @@ -143,20 +143,18 @@ static void __init setup_pci_atmu(struct pci_controller *hose, pr_debug("PCI memory map start 0x%016llx, size 0x%016llx\n", (u64)rsrc->start, (u64)resource_size(rsrc)); + if (of_device_is_compatible(hose->dn, "fsl,qoriq-pcie-v2.2")) { + win_idx = 2; + start_idx = 0; + end_idx = 3; + } + pci = ioremap(rsrc->start, resource_size(rsrc)); if (!pci) { dev_err(hose->parent, "Unable to map ATMU registers\n"); return; } - if (early_find_capability(hose, 0, 0, PCI_CAP_ID_EXP)) { - if (in_be32(&pci->block_rev1) >= PCIE_IP_REV_2_2) { - win_idx = 2; - start_idx = 0; - end_idx = 3; - } - } - /* Disable all windows (except powar0 since it's ignored) */ for(i = 1; i < 5; i++) out_be32(&pci->pow[i].powar, 0); @@ -427,7 +425,7 @@ int __init fsl_add_bridge(struct device_node *dev, int is_primary) struct pci_controller *hose; struct resource rsrc; const int *bus_range; - u8 hdr_type, progif; + u8 progif; if (!of_device_is_available(dev)) { pr_warning("%s: disabled\n", dev->full_name); @@ -459,17 +457,15 @@ int __init fsl_add_bridge(struct device_node *dev, int is_primary) setup_indirect_pci(hose, rsrc.start, rsrc.start + 0x4, PPC_INDIRECT_TYPE_BIG_ENDIAN); - if (early_find_capability(hose, 0, 0, PCI_CAP_ID_EXP)) { - /* For PCIE read HEADER_TYPE to identify controler mode */ - early_read_config_byte(hose, 0, 0, PCI_HEADER_TYPE, &hdr_type); - if ((hdr_type & 0x7f) != PCI_HEADER_TYPE_BRIDGE) - goto no_bridge; - - } else { - /* For PCI read PROG to identify controller mode */ - early_read_config_byte(hose, 0, 0, PCI_CLASS_PROG, &progif); - if ((progif & 1) == 1) - goto no_bridge; + early_read_config_byte(hose, 0, 0, PCI_CLASS_PROG, &progif); + if ((progif & 1) == 1) { + /* unmap cfg_data & cfg_addr separately if not on same page */ + if (((unsigned long)hose->cfg_data & PAGE_MASK) != + ((unsigned long)hose->cfg_addr & PAGE_MASK)) + iounmap(hose->cfg_data); + iounmap(hose->cfg_addr); + pcibios_free_controller(hose); + return -ENODEV; } setup_pci_cmd(hose); @@ -498,15 +494,6 @@ int __init fsl_add_bridge(struct device_node *dev, int is_primary) setup_pci_atmu(hose, &rsrc); return 0; - -no_bridge: - /* unmap cfg_data & cfg_addr separately if not on same page */ - if (((unsigned long)hose->cfg_data & PAGE_MASK) != - ((unsigned long)hose->cfg_addr & PAGE_MASK)) - iounmap(hose->cfg_data); - iounmap(hose->cfg_addr); - pcibios_free_controller(hose); - return -ENODEV; } #endif /* CONFIG_FSL_SOC_BOOKE || CONFIG_PPC_86xx */ @@ -831,7 +818,6 @@ static const struct of_device_id pci_ids[] = { { .compatible = "fsl,p1010-pcie", }, { .compatible = "fsl,p1023-pcie", }, { .compatible = "fsl,p4080-pcie", }, - { .compatible = "fsl,qoriq-pcie-v2.4", }, { .compatible = "fsl,qoriq-pcie-v2.3", }, { .compatible = "fsl,qoriq-pcie-v2.2", }, {}, @@ -839,80 +825,57 @@ static const struct of_device_id pci_ids[] = { struct device_node *fsl_pci_primary; -void fsl_pci_assign_primary(void) +void __devinit fsl_pci_init(void) { - struct device_node *np; + int ret; + struct device_node *node; + struct pci_controller *hose; + dma_addr_t max = 0xffffffff; /* Callers can specify the primary bus using other means. */ - if (fsl_pci_primary) - return; - - /* If a PCI host bridge contains an ISA node, it's primary. */ - np = of_find_node_by_type(NULL, "isa"); - while ((fsl_pci_primary = of_get_parent(np))) { - of_node_put(np); - np = fsl_pci_primary; - - if (of_match_node(pci_ids, np) && of_device_is_available(np)) - return; + if (!fsl_pci_primary) { + /* If a PCI host bridge contains an ISA node, it's primary. */ + node = of_find_node_by_type(NULL, "isa"); + while ((fsl_pci_primary = of_get_parent(node))) { + of_node_put(node); + node = fsl_pci_primary; + + if (of_match_node(pci_ids, node)) + break; + } } - /* - * If there's no PCI host bridge with ISA, arbitrarily - * designate one as primary. This can go away once - * various bugs with primary-less systems are fixed. - */ - for_each_matching_node(np, pci_ids) { - if (of_device_is_available(np)) { - fsl_pci_primary = np; - of_node_put(np); - return; + node = NULL; + for_each_node_by_type(node, "pci") { + if (of_match_node(pci_ids, node)) { + /* + * If there's no PCI host bridge with ISA, arbitrarily + * designate one as primary. This can go away once + * various bugs with primary-less systems are fixed. + */ + if (!fsl_pci_primary) + fsl_pci_primary = node; + + ret = fsl_add_bridge(node, fsl_pci_primary == node); + if (ret == 0) { + hose = pci_find_hose_for_OF_device(node); + max = min(max, hose->dma_window_base_cur + + hose->dma_window_size); + } } } -} -static int __devinit fsl_pci_probe(struct platform_device *pdev) -{ - int ret; - struct device_node *node; #ifdef CONFIG_SWIOTLB - struct pci_controller *hose; -#endif - - node = pdev->dev.of_node; - ret = fsl_add_bridge(node, fsl_pci_primary == node); - -#ifdef CONFIG_SWIOTLB - if (ret == 0) { - hose = pci_find_hose_for_OF_device(pdev->dev.of_node); - - /* - * if we couldn't map all of DRAM via the dma windows - * we need SWIOTLB to handle buffers located outside of - * dma capable memory region - */ - if (memblock_end_of_DRAM() - 1 > hose->dma_window_base_cur + - hose->dma_window_size) - ppc_swiotlb_enable = 1; + /* + * if we couldn't map all of DRAM via the dma windows + * we need SWIOTLB to handle buffers located outside of + * dma capable memory region + */ + if (memblock_end_of_DRAM() - 1 > max) { + ppc_swiotlb_enable = 1; + set_pci_dma_ops(&swiotlb_dma_ops); + ppc_md.pci_dma_dev_setup = pci_dma_dev_setup_swiotlb; } #endif - - mpc85xx_pci_err_probe(pdev); - - return 0; -} - -static struct platform_driver fsl_pci_driver = { - .driver = { - .name = "fsl-pci", - .of_match_table = pci_ids, - }, - .probe = fsl_pci_probe, -}; - -static int __init fsl_pci_init(void) -{ - return platform_driver_register(&fsl_pci_driver); } -arch_initcall(fsl_pci_init); #endif diff --git a/trunk/arch/powerpc/sysdev/fsl_pci.h b/trunk/arch/powerpc/sysdev/fsl_pci.h index d078537adece..baa0fd18289f 100644 --- a/trunk/arch/powerpc/sysdev/fsl_pci.h +++ b/trunk/arch/powerpc/sysdev/fsl_pci.h @@ -16,7 +16,6 @@ #define PCIE_LTSSM 0x0404 /* PCIE Link Training and Status */ #define PCIE_LTSSM_L0 0x16 /* L0 state */ -#define PCIE_IP_REV_2_2 0x02080202 /* PCIE IP block version Rev2.2 */ #define PIWAR_EN 0x80000000 /* Enable */ #define PIWAR_PF 0x20000000 /* prefetch */ #define PIWAR_TGI_LOCAL 0x00f00000 /* target - local memory */ @@ -58,9 +57,7 @@ struct ccsr_pci { __be32 pex_pme_mes_disr; /* 0x.024 - PCIE PME and message disable register */ __be32 pex_pme_mes_ier; /* 0x.028 - PCIE PME and message interrupt enable register */ __be32 pex_pmcr; /* 0x.02c - PCIE power management command register */ - u8 res3[3016]; - __be32 block_rev1; /* 0x.bf8 - PCIE Block Revision register 1 */ - __be32 block_rev2; /* 0x.bfc - PCIE Block Revision register 2 */ + u8 res3[3024]; /* PCI/PCI Express outbound window 0-4 * Window 0 is the default window and is the only window enabled upon reset. @@ -98,19 +95,10 @@ u64 fsl_pci_immrbar_base(struct pci_controller *hose); extern struct device_node *fsl_pci_primary; -#ifdef CONFIG_PCI -void fsl_pci_assign_primary(void); +#ifdef CONFIG_FSL_PCI +void fsl_pci_init(void); #else -static inline void fsl_pci_assign_primary(void) {} -#endif - -#ifdef CONFIG_EDAC_MPC85XX -int mpc85xx_pci_err_probe(struct platform_device *op); -#else -static inline int mpc85xx_pci_err_probe(struct platform_device *op) -{ - return -ENOTSUPP; -} +static inline void fsl_pci_init(void) {} #endif #endif /* __POWERPC_FSL_PCI_H */ diff --git a/trunk/arch/powerpc/sysdev/mpic.c b/trunk/arch/powerpc/sysdev/mpic.c index 9c6e535daad2..bfc6211e5422 100644 --- a/trunk/arch/powerpc/sysdev/mpic.c +++ b/trunk/arch/powerpc/sysdev/mpic.c @@ -6,7 +6,7 @@ * with various broken implementations of this HW. * * Copyright (C) 2004 Benjamin Herrenschmidt, IBM Corp. - * Copyright 2010-2012 Freescale Semiconductor, Inc. + * Copyright 2010-2011 Freescale Semiconductor, Inc. * * 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 @@ -221,24 +221,24 @@ static inline void _mpic_ipi_write(struct mpic *mpic, unsigned int ipi, u32 valu _mpic_write(mpic->reg_type, &mpic->gregs, offset, value); } -static inline unsigned int mpic_tm_offset(struct mpic *mpic, unsigned int tm) -{ - return (tm >> 2) * MPIC_TIMER_GROUP_STRIDE + - (tm & 3) * MPIC_INFO(TIMER_STRIDE); -} - static inline u32 _mpic_tm_read(struct mpic *mpic, unsigned int tm) { - unsigned int offset = mpic_tm_offset(mpic, tm) + - MPIC_INFO(TIMER_VECTOR_PRI); + unsigned int offset = MPIC_INFO(TIMER_VECTOR_PRI) + + ((tm & 3) * MPIC_INFO(TIMER_STRIDE)); + + if (tm >= 4) + offset += 0x1000 / 4; return _mpic_read(mpic->reg_type, &mpic->tmregs, offset); } static inline void _mpic_tm_write(struct mpic *mpic, unsigned int tm, u32 value) { - unsigned int offset = mpic_tm_offset(mpic, tm) + - MPIC_INFO(TIMER_VECTOR_PRI); + unsigned int offset = MPIC_INFO(TIMER_VECTOR_PRI) + + ((tm & 3) * MPIC_INFO(TIMER_STRIDE)); + + if (tm >= 4) + offset += 0x1000 / 4; _mpic_write(mpic->reg_type, &mpic->tmregs, offset, value); } @@ -1026,9 +1026,6 @@ static int mpic_host_map(struct irq_domain *h, unsigned int virq, return 0; } - if (mpic_map_error_int(mpic, virq, hw)) - return 0; - if (hw >= mpic->num_sources) return -EINVAL; @@ -1088,16 +1085,7 @@ static int mpic_host_xlate(struct irq_domain *h, struct device_node *ct, */ switch (intspec[2]) { case 0: - break; - case 1: - if (!(mpic->flags & MPIC_FSL_HAS_EIMR)) - break; - - if (intspec[3] >= ARRAY_SIZE(mpic->err_int_vecs)) - return -EINVAL; - - *out_hwirq = mpic->err_int_vecs[intspec[3]]; - + case 1: /* no EISR/EIMR support for now, treat as shared IRQ */ break; case 2: if (intspec[0] >= ARRAY_SIZE(mpic->ipi_vecs)) @@ -1313,42 +1301,6 @@ struct mpic * __init mpic_alloc(struct device_node *node, mpic_map(mpic, mpic->paddr, &mpic->gregs, MPIC_INFO(GREG_BASE), 0x1000); mpic_map(mpic, mpic->paddr, &mpic->tmregs, MPIC_INFO(TIMER_BASE), 0x1000); - if (mpic->flags & MPIC_FSL) { - u32 brr1, version; - int ret; - - /* - * Yes, Freescale really did put global registers in the - * magic per-cpu area -- and they don't even show up in the - * non-magic per-cpu copies that this driver normally uses. - */ - mpic_map(mpic, mpic->paddr, &mpic->thiscpuregs, - MPIC_CPU_THISBASE, 0x1000); - - brr1 = _mpic_read(mpic->reg_type, &mpic->thiscpuregs, - MPIC_FSL_BRR1); - version = brr1 & MPIC_FSL_BRR1_VER; - - /* Error interrupt mask register (EIMR) is required for - * handling individual device error interrupts. EIMR - * was added in MPIC version 4.1. - * - * Over here we reserve vector number space for error - * interrupt vectors. This space is stolen from the - * global vector number space, as in case of ipis - * and timer interrupts. - * - * Available vector space = intvec_top - 12, where 12 - * is the number of vectors which have been consumed by - * ipis and timer interrupts. - */ - if (version >= 0x401) { - ret = mpic_setup_error_int(mpic, intvec_top - 12); - if (ret) - return NULL; - } - } - /* Reset */ /* When using a device-node, reset requests are only honored if the MPIC @@ -1488,7 +1440,6 @@ void __init mpic_assign_isu(struct mpic *mpic, unsigned int isu_num, void __init mpic_init(struct mpic *mpic) { int i, cpu; - int num_timers = 4; BUG_ON(mpic->num_sources == 0); @@ -1497,34 +1448,15 @@ void __init mpic_init(struct mpic *mpic) /* Set current processor priority to max */ mpic_cpu_write(MPIC_INFO(CPU_CURRENT_TASK_PRI), 0xf); - if (mpic->flags & MPIC_FSL) { - u32 brr1 = _mpic_read(mpic->reg_type, &mpic->thiscpuregs, - MPIC_FSL_BRR1); - u32 version = brr1 & MPIC_FSL_BRR1_VER; - - /* - * Timer group B is present at the latest in MPIC 3.1 (e.g. - * mpc8536). It is not present in MPIC 2.0 (e.g. mpc8544). - * I don't know about the status of intermediate versions (or - * whether they even exist). - */ - if (version >= 0x0301) - num_timers = 8; - } - - /* FSL mpic error interrupt intialization */ - if (mpic->flags & MPIC_FSL_HAS_EIMR) - mpic_err_int_init(mpic, MPIC_FSL_ERR_INT); - /* Initialize timers to our reserved vectors and mask them for now */ - for (i = 0; i < num_timers; i++) { - unsigned int offset = mpic_tm_offset(mpic, i); - + for (i = 0; i < 4; i++) { mpic_write(mpic->tmregs, - offset + MPIC_INFO(TIMER_DESTINATION), + i * MPIC_INFO(TIMER_STRIDE) + + MPIC_INFO(TIMER_DESTINATION), 1 << hard_smp_processor_id()); mpic_write(mpic->tmregs, - offset + MPIC_INFO(TIMER_VECTOR_PRI), + i * MPIC_INFO(TIMER_STRIDE) + + MPIC_INFO(TIMER_VECTOR_PRI), MPIC_VECPRI_MASK | (9 << MPIC_VECPRI_PRIORITY_SHIFT) | (mpic->timer_vecs[0] + i)); diff --git a/trunk/arch/powerpc/sysdev/mpic.h b/trunk/arch/powerpc/sysdev/mpic.h index 24bf07a63924..13f3e8913a93 100644 --- a/trunk/arch/powerpc/sysdev/mpic.h +++ b/trunk/arch/powerpc/sysdev/mpic.h @@ -40,26 +40,4 @@ extern int mpic_set_affinity(struct irq_data *d, const struct cpumask *cpumask, bool force); extern void mpic_reset_core(int cpu); -#ifdef CONFIG_FSL_SOC -extern int mpic_map_error_int(struct mpic *mpic, unsigned int virq, irq_hw_number_t hw); -extern void mpic_err_int_init(struct mpic *mpic, irq_hw_number_t irqnum); -extern int mpic_setup_error_int(struct mpic *mpic, int intvec); -#else -static inline int mpic_map_error_int(struct mpic *mpic, unsigned int virq, irq_hw_number_t hw) -{ - return 0; -} - - -static inline void mpic_err_int_init(struct mpic *mpic, irq_hw_number_t irqnum) -{ - return; -} - -static inline int mpic_setup_error_int(struct mpic *mpic, int intvec) -{ - return -1; -} -#endif - #endif /* _POWERPC_SYSDEV_MPIC_H */ diff --git a/trunk/arch/powerpc/xmon/xmon.c b/trunk/arch/powerpc/xmon/xmon.c index 3a56a639a92e..9b49c65ee7a4 100644 --- a/trunk/arch/powerpc/xmon/xmon.c +++ b/trunk/arch/powerpc/xmon/xmon.c @@ -60,8 +60,6 @@ static cpumask_t cpus_in_xmon = CPU_MASK_NONE; static unsigned long xmon_taken = 1; static int xmon_owner; static int xmon_gate; -#else -#define xmon_owner 0 #endif /* CONFIG_SMP */ static unsigned long in_xmon __read_mostly = 0; @@ -204,13 +202,7 @@ Commands:\n\ di dump instructions\n\ df dump float values\n\ dd dump double values\n\ - dl dump the kernel log buffer\n" -#ifdef CONFIG_PPC64 - "\ - dp[#] dump paca for current cpu, or cpu #\n\ - dpa dump paca for all possible cpus\n" -#endif - "\ + dl dump the kernel log buffer\n\ dr dump stream of raw bytes\n\ e print exception information\n\ f flush cache\n\ @@ -748,7 +740,7 @@ static void insert_bpts(void) static void insert_cpu_bpts(void) { if (dabr.enabled) - set_dabr(dabr.address | (dabr.enabled & 7), DABRX_ALL); + set_dabr(dabr.address | (dabr.enabled & 7)); if (iabr && cpu_has_feature(CPU_FTR_IABR)) mtspr(SPRN_IABR, iabr->address | (iabr->enabled & (BP_IABR|BP_IABR_TE))); @@ -776,7 +768,7 @@ static void remove_bpts(void) static void remove_cpu_bpts(void) { - set_dabr(0, 0); + set_dabr(0); if (cpu_has_feature(CPU_FTR_IABR)) mtspr(SPRN_IABR, 0); } @@ -2017,95 +2009,6 @@ static void xmon_rawdump (unsigned long adrs, long ndump) printf("\n"); } -#ifdef CONFIG_PPC64 -static void dump_one_paca(int cpu) -{ - struct paca_struct *p; - - if (setjmp(bus_error_jmp) != 0) { - printf("*** Error dumping paca for cpu 0x%x!\n", cpu); - return; - } - - catch_memory_errors = 1; - sync(); - - p = &paca[cpu]; - - printf("paca for cpu 0x%x @ %p:\n", cpu, p); - - printf(" %-*s = %s\n", 16, "possible", cpu_possible(cpu) ? "yes" : "no"); - printf(" %-*s = %s\n", 16, "present", cpu_present(cpu) ? "yes" : "no"); - printf(" %-*s = %s\n", 16, "online", cpu_online(cpu) ? "yes" : "no"); - -#define DUMP(paca, name, format) \ - printf(" %-*s = %#-*"format"\t(0x%lx)\n", 16, #name, 18, paca->name, \ - offsetof(struct paca_struct, name)); - - DUMP(p, lock_token, "x"); - DUMP(p, paca_index, "x"); - DUMP(p, kernel_toc, "lx"); - DUMP(p, kernelbase, "lx"); - DUMP(p, kernel_msr, "lx"); -#ifdef CONFIG_PPC_STD_MMU_64 - DUMP(p, stab_real, "lx"); - DUMP(p, stab_addr, "lx"); -#endif - DUMP(p, emergency_sp, "p"); - DUMP(p, data_offset, "lx"); - DUMP(p, hw_cpu_id, "x"); - DUMP(p, cpu_start, "x"); - DUMP(p, kexec_state, "x"); - DUMP(p, __current, "p"); - DUMP(p, kstack, "lx"); - DUMP(p, stab_rr, "lx"); - DUMP(p, saved_r1, "lx"); - DUMP(p, trap_save, "x"); - DUMP(p, soft_enabled, "x"); - DUMP(p, irq_happened, "x"); - DUMP(p, io_sync, "x"); - DUMP(p, irq_work_pending, "x"); - DUMP(p, nap_state_lost, "x"); - -#undef DUMP - - catch_memory_errors = 0; - sync(); -} - -static void dump_all_pacas(void) -{ - int cpu; - - if (num_possible_cpus() == 0) { - printf("No possible cpus, use 'dp #' to dump individual cpus\n"); - return; - } - - for_each_possible_cpu(cpu) - dump_one_paca(cpu); -} - -static void dump_pacas(void) -{ - unsigned long num; - int c; - - c = inchar(); - if (c == 'a') { - dump_all_pacas(); - return; - } - - termch = c; /* Put c back, it wasn't 'a' */ - - if (scanhex(&num)) - dump_one_paca(num); - else - dump_one_paca(xmon_owner); -} -#endif - #define isxdigit(c) (('0' <= (c) && (c) <= '9') \ || ('a' <= (c) && (c) <= 'f') \ || ('A' <= (c) && (c) <= 'F')) @@ -2115,14 +2018,6 @@ dump(void) int c; c = inchar(); - -#ifdef CONFIG_PPC64 - if (c == 'p') { - dump_pacas(); - return; - } -#endif - if ((isxdigit(c) && c != 'f' && c != 'd') || c == '\n') termch = c; scanhex((void *)&adrs); diff --git a/trunk/arch/s390/crypto/aes_s390.c b/trunk/arch/s390/crypto/aes_s390.c index da3c1a7dcd8e..e402a9dd4eda 100644 --- a/trunk/arch/s390/crypto/aes_s390.c +++ b/trunk/arch/s390/crypto/aes_s390.c @@ -216,6 +216,7 @@ static struct crypto_alg aes_alg = { .cra_blocksize = AES_BLOCK_SIZE, .cra_ctxsize = sizeof(struct s390_aes_ctx), .cra_module = THIS_MODULE, + .cra_list = LIST_HEAD_INIT(aes_alg.cra_list), .cra_init = fallback_init_cip, .cra_exit = fallback_exit_cip, .cra_u = { @@ -397,6 +398,7 @@ static struct crypto_alg ecb_aes_alg = { .cra_ctxsize = sizeof(struct s390_aes_ctx), .cra_type = &crypto_blkcipher_type, .cra_module = THIS_MODULE, + .cra_list = LIST_HEAD_INIT(ecb_aes_alg.cra_list), .cra_init = fallback_init_blk, .cra_exit = fallback_exit_blk, .cra_u = { @@ -506,6 +508,7 @@ static struct crypto_alg cbc_aes_alg = { .cra_ctxsize = sizeof(struct s390_aes_ctx), .cra_type = &crypto_blkcipher_type, .cra_module = THIS_MODULE, + .cra_list = LIST_HEAD_INIT(cbc_aes_alg.cra_list), .cra_init = fallback_init_blk, .cra_exit = fallback_exit_blk, .cra_u = { @@ -707,6 +710,7 @@ static struct crypto_alg xts_aes_alg = { .cra_ctxsize = sizeof(struct s390_xts_ctx), .cra_type = &crypto_blkcipher_type, .cra_module = THIS_MODULE, + .cra_list = LIST_HEAD_INIT(xts_aes_alg.cra_list), .cra_init = xts_fallback_init, .cra_exit = xts_fallback_exit, .cra_u = { @@ -828,6 +832,7 @@ static struct crypto_alg ctr_aes_alg = { .cra_ctxsize = sizeof(struct s390_aes_ctx), .cra_type = &crypto_blkcipher_type, .cra_module = THIS_MODULE, + .cra_list = LIST_HEAD_INIT(ctr_aes_alg.cra_list), .cra_u = { .blkcipher = { .min_keysize = AES_MIN_KEY_SIZE, diff --git a/trunk/arch/s390/crypto/des_s390.c b/trunk/arch/s390/crypto/des_s390.c index b49fb96f4207..1eaa371ca3ee 100644 --- a/trunk/arch/s390/crypto/des_s390.c +++ b/trunk/arch/s390/crypto/des_s390.c @@ -70,6 +70,7 @@ static struct crypto_alg des_alg = { .cra_blocksize = DES_BLOCK_SIZE, .cra_ctxsize = sizeof(struct s390_des_ctx), .cra_module = THIS_MODULE, + .cra_list = LIST_HEAD_INIT(des_alg.cra_list), .cra_u = { .cipher = { .cia_min_keysize = DES_KEY_SIZE, @@ -162,6 +163,7 @@ static struct crypto_alg ecb_des_alg = { .cra_ctxsize = sizeof(struct s390_des_ctx), .cra_type = &crypto_blkcipher_type, .cra_module = THIS_MODULE, + .cra_list = LIST_HEAD_INIT(ecb_des_alg.cra_list), .cra_u = { .blkcipher = { .min_keysize = DES_KEY_SIZE, @@ -204,6 +206,7 @@ static struct crypto_alg cbc_des_alg = { .cra_ctxsize = sizeof(struct s390_des_ctx), .cra_type = &crypto_blkcipher_type, .cra_module = THIS_MODULE, + .cra_list = LIST_HEAD_INIT(cbc_des_alg.cra_list), .cra_u = { .blkcipher = { .min_keysize = DES_KEY_SIZE, @@ -268,6 +271,7 @@ static struct crypto_alg des3_alg = { .cra_blocksize = DES_BLOCK_SIZE, .cra_ctxsize = sizeof(struct s390_des_ctx), .cra_module = THIS_MODULE, + .cra_list = LIST_HEAD_INIT(des3_alg.cra_list), .cra_u = { .cipher = { .cia_min_keysize = DES3_KEY_SIZE, @@ -310,6 +314,8 @@ static struct crypto_alg ecb_des3_alg = { .cra_ctxsize = sizeof(struct s390_des_ctx), .cra_type = &crypto_blkcipher_type, .cra_module = THIS_MODULE, + .cra_list = LIST_HEAD_INIT( + ecb_des3_alg.cra_list), .cra_u = { .blkcipher = { .min_keysize = DES3_KEY_SIZE, @@ -352,6 +358,8 @@ static struct crypto_alg cbc_des3_alg = { .cra_ctxsize = sizeof(struct s390_des_ctx), .cra_type = &crypto_blkcipher_type, .cra_module = THIS_MODULE, + .cra_list = LIST_HEAD_INIT( + cbc_des3_alg.cra_list), .cra_u = { .blkcipher = { .min_keysize = DES3_KEY_SIZE, @@ -444,6 +452,7 @@ static struct crypto_alg ctr_des_alg = { .cra_ctxsize = sizeof(struct s390_des_ctx), .cra_type = &crypto_blkcipher_type, .cra_module = THIS_MODULE, + .cra_list = LIST_HEAD_INIT(ctr_des_alg.cra_list), .cra_u = { .blkcipher = { .min_keysize = DES_KEY_SIZE, @@ -487,6 +496,7 @@ static struct crypto_alg ctr_des3_alg = { .cra_ctxsize = sizeof(struct s390_des_ctx), .cra_type = &crypto_blkcipher_type, .cra_module = THIS_MODULE, + .cra_list = LIST_HEAD_INIT(ctr_des3_alg.cra_list), .cra_u = { .blkcipher = { .min_keysize = DES3_KEY_SIZE, diff --git a/trunk/arch/s390/crypto/ghash_s390.c b/trunk/arch/s390/crypto/ghash_s390.c index 1ebd3a15cca4..b1bd170f24b1 100644 --- a/trunk/arch/s390/crypto/ghash_s390.c +++ b/trunk/arch/s390/crypto/ghash_s390.c @@ -135,6 +135,7 @@ static struct shash_alg ghash_alg = { .cra_blocksize = GHASH_BLOCK_SIZE, .cra_ctxsize = sizeof(struct ghash_ctx), .cra_module = THIS_MODULE, + .cra_list = LIST_HEAD_INIT(ghash_alg.base.cra_list), }, }; diff --git a/trunk/arch/s390/include/asm/compat.h b/trunk/arch/s390/include/asm/compat.h index a34a9d612fc0..234f1d859cea 100644 --- a/trunk/arch/s390/include/asm/compat.h +++ b/trunk/arch/s390/include/asm/compat.h @@ -65,7 +65,6 @@ typedef s64 compat_s64; typedef u32 compat_uint_t; typedef u32 compat_ulong_t; typedef u64 compat_u64; -typedef u32 compat_uptr_t; struct compat_timespec { compat_time_t tv_sec; @@ -145,79 +144,6 @@ typedef u32 compat_old_sigset_t; /* at least 32 bits */ typedef u32 compat_sigset_word; -typedef union compat_sigval { - compat_int_t sival_int; - compat_uptr_t sival_ptr; -} compat_sigval_t; - -typedef struct compat_siginfo { - int si_signo; - int si_errno; - int si_code; - - union { - int _pad[128/sizeof(int) - 3]; - - /* kill() */ - struct { - pid_t _pid; /* sender's pid */ - uid_t _uid; /* sender's uid */ - } _kill; - - /* POSIX.1b timers */ - struct { - compat_timer_t _tid; /* timer id */ - int _overrun; /* overrun count */ - compat_sigval_t _sigval; /* same as below */ - int _sys_private; /* not to be passed to user */ - } _timer; - - /* POSIX.1b signals */ - struct { - pid_t _pid; /* sender's pid */ - uid_t _uid; /* sender's uid */ - compat_sigval_t _sigval; - } _rt; - - /* SIGCHLD */ - struct { - pid_t _pid; /* which child */ - uid_t _uid; /* sender's uid */ - int _status;/* exit code */ - compat_clock_t _utime; - compat_clock_t _stime; - } _sigchld; - - /* SIGILL, SIGFPE, SIGSEGV, SIGBUS */ - struct { - __u32 _addr; /* faulting insn/memory ref. - pointer */ - } _sigfault; - - /* SIGPOLL */ - struct { - int _band; /* POLL_IN, POLL_OUT, POLL_MSG */ - int _fd; - } _sigpoll; - } _sifields; -} compat_siginfo_t; - -/* - * How these fields are to be accessed. - */ -#define si_pid _sifields._kill._pid -#define si_uid _sifields._kill._uid -#define si_status _sifields._sigchld._status -#define si_utime _sifields._sigchld._utime -#define si_stime _sifields._sigchld._stime -#define si_value _sifields._rt._sigval -#define si_int _sifields._rt._sigval.sival_int -#define si_ptr _sifields._rt._sigval.sival_ptr -#define si_addr _sifields._sigfault._addr -#define si_band _sifields._sigpoll._band -#define si_fd _sifields._sigpoll._fd -#define si_tid _sifields._timer._tid -#define si_overrun _sifields._timer._overrun - #define COMPAT_OFF_T_MAX 0x7fffffff #define COMPAT_LOFF_T_MAX 0x7fffffffffffffffL @@ -227,6 +153,7 @@ typedef struct compat_siginfo { * as pointers because the syscall entry code will have * appropriately converted them already. */ +typedef u32 compat_uptr_t; static inline void __user *compat_ptr(compat_uptr_t uptr) { diff --git a/trunk/arch/s390/include/asm/processor.h b/trunk/arch/s390/include/asm/processor.h index 56831dfa9198..f3e0aabfc6bc 100644 --- a/trunk/arch/s390/include/asm/processor.h +++ b/trunk/arch/s390/include/asm/processor.h @@ -159,7 +159,6 @@ extern unsigned long thread_saved_pc(struct task_struct *t); extern void show_code(struct pt_regs *regs); extern void print_fn_code(unsigned char *code, unsigned long len); -extern int insn_to_mnemonic(unsigned char *instruction, char buf[8]); unsigned long get_wchan(struct task_struct *p); #define task_pt_regs(tsk) ((struct pt_regs *) \ diff --git a/trunk/arch/s390/kernel/compat_linux.h b/trunk/arch/s390/kernel/compat_linux.h index 90887bd98cf0..9635d759c2b9 100644 --- a/trunk/arch/s390/kernel/compat_linux.h +++ b/trunk/arch/s390/kernel/compat_linux.h @@ -23,6 +23,74 @@ struct old_sigaction32 { __u32 sa_flags; __u32 sa_restorer; /* Another 32 bit pointer */ }; + +typedef struct compat_siginfo { + int si_signo; + int si_errno; + int si_code; + + union { + int _pad[((128/sizeof(int)) - 3)]; + + /* kill() */ + struct { + pid_t _pid; /* sender's pid */ + uid_t _uid; /* sender's uid */ + } _kill; + + /* POSIX.1b timers */ + struct { + compat_timer_t _tid; /* timer id */ + int _overrun; /* overrun count */ + compat_sigval_t _sigval; /* same as below */ + int _sys_private; /* not to be passed to user */ + } _timer; + + /* POSIX.1b signals */ + struct { + pid_t _pid; /* sender's pid */ + uid_t _uid; /* sender's uid */ + compat_sigval_t _sigval; + } _rt; + + /* SIGCHLD */ + struct { + pid_t _pid; /* which child */ + uid_t _uid; /* sender's uid */ + int _status;/* exit code */ + compat_clock_t _utime; + compat_clock_t _stime; + } _sigchld; + + /* SIGILL, SIGFPE, SIGSEGV, SIGBUS */ + struct { + __u32 _addr; /* faulting insn/memory ref. - pointer */ + } _sigfault; + + /* SIGPOLL */ + struct { + int _band; /* POLL_IN, POLL_OUT, POLL_MSG */ + int _fd; + } _sigpoll; + } _sifields; +} compat_siginfo_t; + +/* + * How these fields are to be accessed. + */ +#define si_pid _sifields._kill._pid +#define si_uid _sifields._kill._uid +#define si_status _sifields._sigchld._status +#define si_utime _sifields._sigchld._utime +#define si_stime _sifields._sigchld._stime +#define si_value _sifields._rt._sigval +#define si_int _sifields._rt._sigval.sival_int +#define si_ptr _sifields._rt._sigval.sival_ptr +#define si_addr _sifields._sigfault._addr +#define si_band _sifields._sigpoll._band +#define si_fd _sifields._sigpoll._fd +#define si_tid _sifields._timer._tid +#define si_overrun _sifields._timer._overrun /* asm/sigcontext.h */ typedef union diff --git a/trunk/arch/s390/kernel/dis.c b/trunk/arch/s390/kernel/dis.c index f00286bd2ef9..cc84a24c023f 100644 --- a/trunk/arch/s390/kernel/dis.c +++ b/trunk/arch/s390/kernel/dis.c @@ -1501,33 +1501,6 @@ static struct insn *find_insn(unsigned char *code) return NULL; } -/** - * insn_to_mnemonic - decode an s390 instruction - * @instruction: instruction to decode - * @buf: buffer to fill with mnemonic - * - * Decode the instruction at @instruction and store the corresponding - * mnemonic into @buf. - * @buf is left unchanged if the instruction could not be decoded. - * Returns: - * %0 on success, %-ENOENT if the instruction was not found. - */ -int insn_to_mnemonic(unsigned char *instruction, char buf[8]) -{ - struct insn *insn; - - insn = find_insn(instruction); - if (!insn) - return -ENOENT; - if (insn->name[0] == '\0') - snprintf(buf, sizeof(buf), "%s", - long_insn_name[(int) insn->name[1]]); - else - snprintf(buf, sizeof(buf), "%.5s", insn->name); - return 0; -} -EXPORT_SYMBOL_GPL(insn_to_mnemonic); - static int print_insn(char *buffer, unsigned char *code, unsigned long addr) { struct insn *insn; diff --git a/trunk/arch/s390/kvm/Kconfig b/trunk/arch/s390/kvm/Kconfig index b58dd869cb32..9b04a32e5695 100644 --- a/trunk/arch/s390/kvm/Kconfig +++ b/trunk/arch/s390/kvm/Kconfig @@ -21,7 +21,6 @@ config KVM depends on HAVE_KVM && EXPERIMENTAL select PREEMPT_NOTIFIERS select ANON_INODES - select HAVE_KVM_CPU_RELAX_INTERCEPT ---help--- Support hosting paravirtualized guest machines using the SIE virtualization capability on the mainframe. This should work diff --git a/trunk/arch/s390/kvm/diag.c b/trunk/arch/s390/kvm/diag.c index a390687feb13..c88bb7793390 100644 --- a/trunk/arch/s390/kvm/diag.c +++ b/trunk/arch/s390/kvm/diag.c @@ -14,8 +14,6 @@ #include #include #include "kvm-s390.h" -#include "trace.h" -#include "trace-s390.h" static int diag_release_pages(struct kvm_vcpu *vcpu) { @@ -100,7 +98,6 @@ static int __diag_ipl_functions(struct kvm_vcpu *vcpu) vcpu->run->exit_reason = KVM_EXIT_S390_RESET; VCPU_EVENT(vcpu, 3, "requesting userspace resets %llx", vcpu->run->s390_reset_flags); - trace_kvm_s390_request_resets(vcpu->run->s390_reset_flags); return -EREMOTE; } @@ -108,7 +105,6 @@ int kvm_s390_handle_diag(struct kvm_vcpu *vcpu) { int code = (vcpu->arch.sie_block->ipb & 0xfff0000) >> 16; - trace_kvm_s390_handle_diag(vcpu, code); switch (code) { case 0x10: return diag_release_pages(vcpu); diff --git a/trunk/arch/s390/kvm/intercept.c b/trunk/arch/s390/kvm/intercept.c index 22798ec33fd1..adae539f12e2 100644 --- a/trunk/arch/s390/kvm/intercept.c +++ b/trunk/arch/s390/kvm/intercept.c @@ -19,8 +19,6 @@ #include "kvm-s390.h" #include "gaccess.h" -#include "trace.h" -#include "trace-s390.h" static int handle_lctlg(struct kvm_vcpu *vcpu) { @@ -47,7 +45,6 @@ static int handle_lctlg(struct kvm_vcpu *vcpu) VCPU_EVENT(vcpu, 5, "lctlg r1:%x, r3:%x,b2:%x,d2:%x", reg1, reg3, base2, disp2); - trace_kvm_s390_handle_lctl(vcpu, 1, reg1, reg3, useraddr); do { rc = get_guest_u64(vcpu, useraddr, @@ -85,7 +82,6 @@ static int handle_lctl(struct kvm_vcpu *vcpu) VCPU_EVENT(vcpu, 5, "lctl r1:%x, r3:%x,b2:%x,d2:%x", reg1, reg3, base2, disp2); - trace_kvm_s390_handle_lctl(vcpu, 0, reg1, reg3, useraddr); reg = reg1; do { @@ -139,8 +135,6 @@ static int handle_stop(struct kvm_vcpu *vcpu) vcpu->stat.exit_stop_request++; spin_lock_bh(&vcpu->arch.local_int.lock); - trace_kvm_s390_stop_request(vcpu->arch.local_int.action_bits); - if (vcpu->arch.local_int.action_bits & ACTION_RELOADVCPU_ON_STOP) { vcpu->arch.local_int.action_bits &= ~ACTION_RELOADVCPU_ON_STOP; rc = SIE_INTERCEPT_RERUNVCPU; @@ -177,7 +171,6 @@ static int handle_validity(struct kvm_vcpu *vcpu) int rc; vcpu->stat.exit_validity++; - trace_kvm_s390_intercept_validity(vcpu, viwhy); if (viwhy == 0x37) { vmaddr = gmap_fault(vcpu->arch.sie_block->prefix, vcpu->arch.gmap); @@ -220,9 +213,6 @@ static int handle_instruction(struct kvm_vcpu *vcpu) intercept_handler_t handler; vcpu->stat.exit_instruction++; - trace_kvm_s390_intercept_instruction(vcpu, - vcpu->arch.sie_block->ipa, - vcpu->arch.sie_block->ipb); handler = instruction_handlers[vcpu->arch.sie_block->ipa >> 8]; if (handler) return handler(vcpu); @@ -232,7 +222,6 @@ static int handle_instruction(struct kvm_vcpu *vcpu) static int handle_prog(struct kvm_vcpu *vcpu) { vcpu->stat.exit_program_interruption++; - trace_kvm_s390_intercept_prog(vcpu, vcpu->arch.sie_block->iprcc); return kvm_s390_inject_program_int(vcpu, vcpu->arch.sie_block->iprcc); } diff --git a/trunk/arch/s390/kvm/interrupt.c b/trunk/arch/s390/kvm/interrupt.c index ff1e2f8ef94a..b7bc1aac8ed2 100644 --- a/trunk/arch/s390/kvm/interrupt.c +++ b/trunk/arch/s390/kvm/interrupt.c @@ -19,7 +19,6 @@ #include #include "kvm-s390.h" #include "gaccess.h" -#include "trace-s390.h" static int psw_extint_disabled(struct kvm_vcpu *vcpu) { @@ -131,8 +130,6 @@ static void __do_deliver_interrupt(struct kvm_vcpu *vcpu, case KVM_S390_INT_EMERGENCY: VCPU_EVENT(vcpu, 4, "%s", "interrupt: sigp emerg"); vcpu->stat.deliver_emergency_signal++; - trace_kvm_s390_deliver_interrupt(vcpu->vcpu_id, inti->type, - inti->emerg.code, 0); rc = put_guest_u16(vcpu, __LC_EXT_INT_CODE, 0x1201); if (rc == -EFAULT) exception = 1; @@ -155,8 +152,6 @@ static void __do_deliver_interrupt(struct kvm_vcpu *vcpu, case KVM_S390_INT_EXTERNAL_CALL: VCPU_EVENT(vcpu, 4, "%s", "interrupt: sigp ext call"); vcpu->stat.deliver_external_call++; - trace_kvm_s390_deliver_interrupt(vcpu->vcpu_id, inti->type, - inti->extcall.code, 0); rc = put_guest_u16(vcpu, __LC_EXT_INT_CODE, 0x1202); if (rc == -EFAULT) exception = 1; @@ -180,8 +175,6 @@ static void __do_deliver_interrupt(struct kvm_vcpu *vcpu, VCPU_EVENT(vcpu, 4, "interrupt: sclp parm:%x", inti->ext.ext_params); vcpu->stat.deliver_service_signal++; - trace_kvm_s390_deliver_interrupt(vcpu->vcpu_id, inti->type, - inti->ext.ext_params, 0); rc = put_guest_u16(vcpu, __LC_EXT_INT_CODE, 0x2401); if (rc == -EFAULT) exception = 1; @@ -205,9 +198,6 @@ static void __do_deliver_interrupt(struct kvm_vcpu *vcpu, VCPU_EVENT(vcpu, 4, "interrupt: virtio parm:%x,parm64:%llx", inti->ext.ext_params, inti->ext.ext_params2); vcpu->stat.deliver_virtio_interrupt++; - trace_kvm_s390_deliver_interrupt(vcpu->vcpu_id, inti->type, - inti->ext.ext_params, - inti->ext.ext_params2); rc = put_guest_u16(vcpu, __LC_EXT_INT_CODE, 0x2603); if (rc == -EFAULT) exception = 1; @@ -239,8 +229,6 @@ static void __do_deliver_interrupt(struct kvm_vcpu *vcpu, case KVM_S390_SIGP_STOP: VCPU_EVENT(vcpu, 4, "%s", "interrupt: cpu stop"); vcpu->stat.deliver_stop_signal++; - trace_kvm_s390_deliver_interrupt(vcpu->vcpu_id, inti->type, - 0, 0); __set_intercept_indicator(vcpu, inti); break; @@ -248,16 +236,12 @@ static void __do_deliver_interrupt(struct kvm_vcpu *vcpu, VCPU_EVENT(vcpu, 4, "interrupt: set prefix to %x", inti->prefix.address); vcpu->stat.deliver_prefix_signal++; - trace_kvm_s390_deliver_interrupt(vcpu->vcpu_id, inti->type, - inti->prefix.address, 0); kvm_s390_set_prefix(vcpu, inti->prefix.address); break; case KVM_S390_RESTART: VCPU_EVENT(vcpu, 4, "%s", "interrupt: cpu restart"); vcpu->stat.deliver_restart_signal++; - trace_kvm_s390_deliver_interrupt(vcpu->vcpu_id, inti->type, - 0, 0); rc = copy_to_guest(vcpu, offsetof(struct _lowcore, restart_old_psw), &vcpu->arch.sie_block->gpsw, sizeof(psw_t)); if (rc == -EFAULT) @@ -275,8 +259,6 @@ static void __do_deliver_interrupt(struct kvm_vcpu *vcpu, inti->pgm.code, table[vcpu->arch.sie_block->ipa >> 14]); vcpu->stat.deliver_program_int++; - trace_kvm_s390_deliver_interrupt(vcpu->vcpu_id, inti->type, - inti->pgm.code, 0); rc = put_guest_u16(vcpu, __LC_PGM_INT_CODE, inti->pgm.code); if (rc == -EFAULT) exception = 1; @@ -423,7 +405,9 @@ int kvm_s390_handle_wait(struct kvm_vcpu *vcpu) set_current_state(TASK_INTERRUPTIBLE); spin_unlock_bh(&vcpu->arch.local_int.lock); spin_unlock(&vcpu->arch.local_int.float_int->lock); + vcpu_put(vcpu); schedule(); + vcpu_load(vcpu); spin_lock(&vcpu->arch.local_int.float_int->lock); spin_lock_bh(&vcpu->arch.local_int.lock); } @@ -531,7 +515,6 @@ int kvm_s390_inject_program_int(struct kvm_vcpu *vcpu, u16 code) inti->pgm.code = code; VCPU_EVENT(vcpu, 3, "inject: program check %d (from kernel)", code); - trace_kvm_s390_inject_vcpu(vcpu->vcpu_id, inti->type, code, 0, 1); spin_lock_bh(&li->lock); list_add(&inti->list, &li->list); atomic_set(&li->active, 1); @@ -573,8 +556,6 @@ int kvm_s390_inject_vm(struct kvm *kvm, kfree(inti); return -EINVAL; } - trace_kvm_s390_inject_vm(s390int->type, s390int->parm, s390int->parm64, - 2); mutex_lock(&kvm->lock); fi = &kvm->arch.float_int; @@ -640,8 +621,6 @@ int kvm_s390_inject_vcpu(struct kvm_vcpu *vcpu, kfree(inti); return -EINVAL; } - trace_kvm_s390_inject_vcpu(vcpu->vcpu_id, s390int->type, s390int->parm, - s390int->parm64, 2); mutex_lock(&vcpu->kvm->lock); li = &vcpu->arch.local_int; diff --git a/trunk/arch/s390/kvm/kvm-s390.c b/trunk/arch/s390/kvm/kvm-s390.c index ecced9d18986..d470ccbfabae 100644 --- a/trunk/arch/s390/kvm/kvm-s390.c +++ b/trunk/arch/s390/kvm/kvm-s390.c @@ -32,10 +32,6 @@ #include "kvm-s390.h" #include "gaccess.h" -#define CREATE_TRACE_POINTS -#include "trace.h" -#include "trace-s390.h" - #define VCPU_STAT(x) offsetof(struct kvm_vcpu, stat.x), KVM_STAT_VCPU struct kvm_stats_debugfs_item debugfs_entries[] = { @@ -246,7 +242,6 @@ int kvm_arch_init_vm(struct kvm *kvm, unsigned long type) void kvm_arch_vcpu_destroy(struct kvm_vcpu *vcpu) { VCPU_EVENT(vcpu, 3, "%s", "free cpu"); - trace_kvm_s390_destroy_vcpu(vcpu->vcpu_id); if (!kvm_is_ucontrol(vcpu->kvm)) { clear_bit(63 - vcpu->vcpu_id, (unsigned long *) &vcpu->kvm->arch.sca->mcn); @@ -422,7 +417,6 @@ struct kvm_vcpu *kvm_arch_vcpu_create(struct kvm *kvm, goto out_free_sie_block; VM_EVENT(kvm, 3, "create cpu %d at %p, sie block at %p", id, vcpu, vcpu->arch.sie_block); - trace_kvm_s390_create_vcpu(id, vcpu, vcpu->arch.sie_block); return vcpu; out_free_sie_block: @@ -613,22 +607,18 @@ static int __vcpu_run(struct kvm_vcpu *vcpu) local_irq_enable(); VCPU_EVENT(vcpu, 6, "entering sie flags %x", atomic_read(&vcpu->arch.sie_block->cpuflags)); - trace_kvm_s390_sie_enter(vcpu, - atomic_read(&vcpu->arch.sie_block->cpuflags)); rc = sie64a(vcpu->arch.sie_block, vcpu->run->s.regs.gprs); if (rc) { if (kvm_is_ucontrol(vcpu->kvm)) { rc = SIE_INTERCEPT_UCONTROL; } else { VCPU_EVENT(vcpu, 3, "%s", "fault in sie instruction"); - trace_kvm_s390_sie_fault(vcpu); kvm_s390_inject_program_int(vcpu, PGM_ADDRESSING); rc = 0; } } VCPU_EVENT(vcpu, 6, "exit sie icptcode %d", vcpu->arch.sie_block->icptcode); - trace_kvm_s390_sie_exit(vcpu, vcpu->arch.sie_block->icptcode); local_irq_disable(); kvm_guest_exit(); local_irq_enable(); @@ -969,12 +959,7 @@ void kvm_arch_commit_memory_region(struct kvm *kvm, return; } -void kvm_arch_flush_shadow_all(struct kvm *kvm) -{ -} - -void kvm_arch_flush_shadow_memslot(struct kvm *kvm, - struct kvm_memory_slot *slot) +void kvm_arch_flush_shadow(struct kvm *kvm) { } diff --git a/trunk/arch/s390/kvm/priv.c b/trunk/arch/s390/kvm/priv.c index d768906f15c8..310be61bead7 100644 --- a/trunk/arch/s390/kvm/priv.c +++ b/trunk/arch/s390/kvm/priv.c @@ -20,7 +20,6 @@ #include #include "gaccess.h" #include "kvm-s390.h" -#include "trace.h" static int handle_set_prefix(struct kvm_vcpu *vcpu) { @@ -60,7 +59,6 @@ static int handle_set_prefix(struct kvm_vcpu *vcpu) kvm_s390_set_prefix(vcpu, address); VCPU_EVENT(vcpu, 5, "setting prefix to %x", address); - trace_kvm_s390_handle_prefix(vcpu, 1, address); out: return 0; } @@ -93,7 +91,6 @@ static int handle_store_prefix(struct kvm_vcpu *vcpu) } VCPU_EVENT(vcpu, 5, "storing prefix to %x", address); - trace_kvm_s390_handle_prefix(vcpu, 0, address); out: return 0; } @@ -122,7 +119,6 @@ static int handle_store_cpu_address(struct kvm_vcpu *vcpu) } VCPU_EVENT(vcpu, 5, "storing cpu address to %llx", useraddr); - trace_kvm_s390_handle_stap(vcpu, useraddr); out: return 0; } @@ -168,11 +164,9 @@ static int handle_stfl(struct kvm_vcpu *vcpu) &facility_list, sizeof(facility_list)); if (rc == -EFAULT) kvm_s390_inject_program_int(vcpu, PGM_ADDRESSING); - else { + else VCPU_EVENT(vcpu, 5, "store facility list value %x", facility_list); - trace_kvm_s390_handle_stfl(vcpu, facility_list); - } return 0; } @@ -284,7 +278,6 @@ static int handle_stsi(struct kvm_vcpu *vcpu) kvm_s390_inject_program_int(vcpu, PGM_ADDRESSING); goto out_mem; } - trace_kvm_s390_handle_stsi(vcpu, fc, sel1, sel2, operand2); free_page(mem); vcpu->arch.sie_block->gpsw.mask &= ~(3ul << 44); vcpu->run->s.regs.gprs[0] = 0; diff --git a/trunk/arch/s390/kvm/sigp.c b/trunk/arch/s390/kvm/sigp.c index 566ddf6e8dfb..56f80e1f98f7 100644 --- a/trunk/arch/s390/kvm/sigp.c +++ b/trunk/arch/s390/kvm/sigp.c @@ -18,7 +18,6 @@ #include #include "gaccess.h" #include "kvm-s390.h" -#include "trace.h" static int __sigp_sense(struct kvm_vcpu *vcpu, u16 cpu_addr, u64 *reg) @@ -345,7 +344,6 @@ int kvm_s390_handle_sigp(struct kvm_vcpu *vcpu) else parameter = vcpu->run->s.regs.gprs[r1 + 1]; - trace_kvm_s390_handle_sigp(vcpu, order_code, cpu_addr, parameter); switch (order_code) { case SIGP_SENSE: vcpu->stat.instruction_sigp_sense++; diff --git a/trunk/arch/s390/kvm/trace-s390.h b/trunk/arch/s390/kvm/trace-s390.h deleted file mode 100644 index 90fdf85b5ff7..000000000000 --- a/trunk/arch/s390/kvm/trace-s390.h +++ /dev/null @@ -1,210 +0,0 @@ -#if !defined(_TRACE_KVMS390_H) || defined(TRACE_HEADER_MULTI_READ) -#define _TRACE_KVMS390_H - -#include - -#undef TRACE_SYSTEM -#define TRACE_SYSTEM kvm-s390 -#define TRACE_INCLUDE_PATH . -#undef TRACE_INCLUDE_FILE -#define TRACE_INCLUDE_FILE trace-s390 - -/* - * Trace point for the creation of the kvm instance. - */ -TRACE_EVENT(kvm_s390_create_vm, - TP_PROTO(unsigned long type), - TP_ARGS(type), - - TP_STRUCT__entry( - __field(unsigned long, type) - ), - - TP_fast_assign( - __entry->type = type; - ), - - TP_printk("create vm%s", - __entry->type & KVM_VM_S390_UCONTROL ? " (UCONTROL)" : "") - ); - -/* - * Trace points for creation and destruction of vpcus. - */ -TRACE_EVENT(kvm_s390_create_vcpu, - TP_PROTO(unsigned int id, struct kvm_vcpu *vcpu, - struct kvm_s390_sie_block *sie_block), - TP_ARGS(id, vcpu, sie_block), - - TP_STRUCT__entry( - __field(unsigned int, id) - __field(struct kvm_vcpu *, vcpu) - __field(struct kvm_s390_sie_block *, sie_block) - ), - - TP_fast_assign( - __entry->id = id; - __entry->vcpu = vcpu; - __entry->sie_block = sie_block; - ), - - TP_printk("create cpu %d at %p, sie block at %p", __entry->id, - __entry->vcpu, __entry->sie_block) - ); - -TRACE_EVENT(kvm_s390_destroy_vcpu, - TP_PROTO(unsigned int id), - TP_ARGS(id), - - TP_STRUCT__entry( - __field(unsigned int, id) - ), - - TP_fast_assign( - __entry->id = id; - ), - - TP_printk("destroy cpu %d", __entry->id) - ); - -/* - * Trace points for injection of interrupts, either per machine or - * per vcpu. - */ - -#define kvm_s390_int_type \ - {KVM_S390_SIGP_STOP, "sigp stop"}, \ - {KVM_S390_PROGRAM_INT, "program interrupt"}, \ - {KVM_S390_SIGP_SET_PREFIX, "sigp set prefix"}, \ - {KVM_S390_RESTART, "sigp restart"}, \ - {KVM_S390_INT_VIRTIO, "virtio interrupt"}, \ - {KVM_S390_INT_SERVICE, "sclp interrupt"}, \ - {KVM_S390_INT_EMERGENCY, "sigp emergency"}, \ - {KVM_S390_INT_EXTERNAL_CALL, "sigp ext call"} - -TRACE_EVENT(kvm_s390_inject_vm, - TP_PROTO(__u64 type, __u32 parm, __u64 parm64, int who), - TP_ARGS(type, parm, parm64, who), - - TP_STRUCT__entry( - __field(__u32, inttype) - __field(__u32, parm) - __field(__u64, parm64) - __field(int, who) - ), - - TP_fast_assign( - __entry->inttype = type & 0x00000000ffffffff; - __entry->parm = parm; - __entry->parm64 = parm64; - __entry->who = who; - ), - - TP_printk("inject%s: type:%x (%s) parm:%x parm64:%llx", - (__entry->who == 1) ? " (from kernel)" : - (__entry->who == 2) ? " (from user)" : "", - __entry->inttype, - __print_symbolic(__entry->inttype, kvm_s390_int_type), - __entry->parm, __entry->parm64) - ); - -TRACE_EVENT(kvm_s390_inject_vcpu, - TP_PROTO(unsigned int id, __u64 type, __u32 parm, __u64 parm64, \ - int who), - TP_ARGS(id, type, parm, parm64, who), - - TP_STRUCT__entry( - __field(int, id) - __field(__u32, inttype) - __field(__u32, parm) - __field(__u64, parm64) - __field(int, who) - ), - - TP_fast_assign( - __entry->id = id; - __entry->inttype = type & 0x00000000ffffffff; - __entry->parm = parm; - __entry->parm64 = parm64; - __entry->who = who; - ), - - TP_printk("inject%s (vcpu %d): type:%x (%s) parm:%x parm64:%llx", - (__entry->who == 1) ? " (from kernel)" : - (__entry->who == 2) ? " (from user)" : "", - __entry->id, __entry->inttype, - __print_symbolic(__entry->inttype, kvm_s390_int_type), - __entry->parm, __entry->parm64) - ); - -/* - * Trace point for the actual delivery of interrupts. - */ -TRACE_EVENT(kvm_s390_deliver_interrupt, - TP_PROTO(unsigned int id, __u64 type, __u32 data0, __u64 data1), - TP_ARGS(id, type, data0, data1), - - TP_STRUCT__entry( - __field(int, id) - __field(__u32, inttype) - __field(__u32, data0) - __field(__u64, data1) - ), - - TP_fast_assign( - __entry->id = id; - __entry->inttype = type & 0x00000000ffffffff; - __entry->data0 = data0; - __entry->data1 = data1; - ), - - TP_printk("deliver interrupt (vcpu %d): type:%x (%s) " \ - "data:%08x %016llx", - __entry->id, __entry->inttype, - __print_symbolic(__entry->inttype, kvm_s390_int_type), - __entry->data0, __entry->data1) - ); - -/* - * Trace point for resets that may be requested from userspace. - */ -TRACE_EVENT(kvm_s390_request_resets, - TP_PROTO(__u64 resets), - TP_ARGS(resets), - - TP_STRUCT__entry( - __field(__u64, resets) - ), - - TP_fast_assign( - __entry->resets = resets; - ), - - TP_printk("requesting userspace resets %llx", - __entry->resets) - ); - -/* - * Trace point for a vcpu's stop requests. - */ -TRACE_EVENT(kvm_s390_stop_request, - TP_PROTO(unsigned int action_bits), - TP_ARGS(action_bits), - - TP_STRUCT__entry( - __field(unsigned int, action_bits) - ), - - TP_fast_assign( - __entry->action_bits = action_bits; - ), - - TP_printk("stop request, action_bits = %08x", - __entry->action_bits) - ); - - -#endif /* _TRACE_KVMS390_H */ - -/* This part must be outside protection */ -#include diff --git a/trunk/arch/s390/kvm/trace.h b/trunk/arch/s390/kvm/trace.h deleted file mode 100644 index 2b29e62351d3..000000000000 --- a/trunk/arch/s390/kvm/trace.h +++ /dev/null @@ -1,341 +0,0 @@ -#if !defined(_TRACE_KVM_H) || defined(TRACE_HEADER_MULTI_READ) -#define _TRACE_KVM_H - -#include -#include -#include - -#undef TRACE_SYSTEM -#define TRACE_SYSTEM kvm -#define TRACE_INCLUDE_PATH . -#undef TRACE_INCLUDE_FILE -#define TRACE_INCLUDE_FILE trace - -/* - * Helpers for vcpu-specific tracepoints containing the same information - * as s390dbf VCPU_EVENTs. - */ -#define VCPU_PROTO_COMMON struct kvm_vcpu *vcpu -#define VCPU_ARGS_COMMON vcpu -#define VCPU_FIELD_COMMON __field(int, id) \ - __field(unsigned long, pswmask) \ - __field(unsigned long, pswaddr) -#define VCPU_ASSIGN_COMMON do { \ - __entry->id = vcpu->vcpu_id; \ - __entry->pswmask = vcpu->arch.sie_block->gpsw.mask; \ - __entry->pswaddr = vcpu->arch.sie_block->gpsw.addr; \ - } while (0); -#define VCPU_TP_PRINTK(p_str, p_args...) \ - TP_printk("%02d[%016lx-%016lx]: " p_str, __entry->id, \ - __entry->pswmask, __entry->pswaddr, p_args) - -/* - * Tracepoints for SIE entry and exit. - */ -TRACE_EVENT(kvm_s390_sie_enter, - TP_PROTO(VCPU_PROTO_COMMON, int cpuflags), - TP_ARGS(VCPU_ARGS_COMMON, cpuflags), - - TP_STRUCT__entry( - VCPU_FIELD_COMMON - __field(int, cpuflags) - ), - - TP_fast_assign( - VCPU_ASSIGN_COMMON - __entry->cpuflags = cpuflags; - ), - - VCPU_TP_PRINTK("entering sie flags %x", __entry->cpuflags) - ); - -TRACE_EVENT(kvm_s390_sie_fault, - TP_PROTO(VCPU_PROTO_COMMON), - TP_ARGS(VCPU_ARGS_COMMON), - - TP_STRUCT__entry( - VCPU_FIELD_COMMON - ), - - TP_fast_assign( - VCPU_ASSIGN_COMMON - ), - - VCPU_TP_PRINTK("%s", "fault in sie instruction") - ); - -#define sie_intercept_code \ - {0x04, "Instruction"}, \ - {0x08, "Program interruption"}, \ - {0x0C, "Instruction and program interuption"}, \ - {0x10, "External request"}, \ - {0x14, "External interruption"}, \ - {0x18, "I/O request"}, \ - {0x1C, "Wait state"}, \ - {0x20, "Validity"}, \ - {0x28, "Stop request"} - -TRACE_EVENT(kvm_s390_sie_exit, - TP_PROTO(VCPU_PROTO_COMMON, u8 icptcode), - TP_ARGS(VCPU_ARGS_COMMON, icptcode), - - TP_STRUCT__entry( - VCPU_FIELD_COMMON - __field(u8, icptcode) - ), - - TP_fast_assign( - VCPU_ASSIGN_COMMON - __entry->icptcode = icptcode; - ), - - VCPU_TP_PRINTK("exit sie icptcode %d (%s)", __entry->icptcode, - __print_symbolic(__entry->icptcode, - sie_intercept_code)) - ); - -/* - * Trace point for intercepted instructions. - */ -TRACE_EVENT(kvm_s390_intercept_instruction, - TP_PROTO(VCPU_PROTO_COMMON, __u16 ipa, __u32 ipb), - TP_ARGS(VCPU_ARGS_COMMON, ipa, ipb), - - TP_STRUCT__entry( - VCPU_FIELD_COMMON - __field(__u64, instruction) - __field(char, insn[8]) - ), - - TP_fast_assign( - VCPU_ASSIGN_COMMON - __entry->instruction = ((__u64)ipa << 48) | - ((__u64)ipb << 16); - ), - - VCPU_TP_PRINTK("intercepted instruction %016llx (%s)", - __entry->instruction, - insn_to_mnemonic((unsigned char *) - &__entry->instruction, - __entry->insn) ? - "unknown" : __entry->insn) - ); - -/* - * Trace point for intercepted program interruptions. - */ -TRACE_EVENT(kvm_s390_intercept_prog, - TP_PROTO(VCPU_PROTO_COMMON, __u16 code), - TP_ARGS(VCPU_ARGS_COMMON, code), - - TP_STRUCT__entry( - VCPU_FIELD_COMMON - __field(__u16, code) - ), - - TP_fast_assign( - VCPU_ASSIGN_COMMON - __entry->code = code; - ), - - VCPU_TP_PRINTK("intercepted program interruption %04x", - __entry->code) - ); - -/* - * Trace point for validity intercepts. - */ -TRACE_EVENT(kvm_s390_intercept_validity, - TP_PROTO(VCPU_PROTO_COMMON, __u16 viwhy), - TP_ARGS(VCPU_ARGS_COMMON, viwhy), - - TP_STRUCT__entry( - VCPU_FIELD_COMMON - __field(__u16, viwhy) - ), - - TP_fast_assign( - VCPU_ASSIGN_COMMON - __entry->viwhy = viwhy; - ), - - VCPU_TP_PRINTK("got validity intercept %04x", __entry->viwhy) - ); - -/* - * Trace points for instructions that are of special interest. - */ - -#define sigp_order_codes \ - {SIGP_SENSE, "sense"}, \ - {SIGP_EXTERNAL_CALL, "external call"}, \ - {SIGP_EMERGENCY_SIGNAL, "emergency signal"}, \ - {SIGP_STOP, "stop"}, \ - {SIGP_STOP_AND_STORE_STATUS, "stop and store status"}, \ - {SIGP_SET_ARCHITECTURE, "set architecture"}, \ - {SIGP_SET_PREFIX, "set prefix"}, \ - {SIGP_SENSE_RUNNING, "sense running"}, \ - {SIGP_RESTART, "restart"} - -TRACE_EVENT(kvm_s390_handle_sigp, - TP_PROTO(VCPU_PROTO_COMMON, __u8 order_code, __u16 cpu_addr, \ - __u32 parameter), - TP_ARGS(VCPU_ARGS_COMMON, order_code, cpu_addr, parameter), - - TP_STRUCT__entry( - VCPU_FIELD_COMMON - __field(__u8, order_code) - __field(__u16, cpu_addr) - __field(__u32, parameter) - ), - - TP_fast_assign( - VCPU_ASSIGN_COMMON - __entry->order_code = order_code; - __entry->cpu_addr = cpu_addr; - __entry->parameter = parameter; - ), - - VCPU_TP_PRINTK("handle sigp order %02x (%s), cpu address %04x, " \ - "parameter %08x", __entry->order_code, - __print_symbolic(__entry->order_code, - sigp_order_codes), - __entry->cpu_addr, __entry->parameter) - ); - -#define diagnose_codes \ - {0x10, "release pages"}, \ - {0x44, "time slice end"}, \ - {0x308, "ipl functions"}, \ - {0x500, "kvm hypercall"}, \ - {0x501, "kvm breakpoint"} - -TRACE_EVENT(kvm_s390_handle_diag, - TP_PROTO(VCPU_PROTO_COMMON, __u16 code), - TP_ARGS(VCPU_ARGS_COMMON, code), - - TP_STRUCT__entry( - VCPU_FIELD_COMMON - __field(__u16, code) - ), - - TP_fast_assign( - VCPU_ASSIGN_COMMON - __entry->code = code; - ), - - VCPU_TP_PRINTK("handle diagnose call %04x (%s)", __entry->code, - __print_symbolic(__entry->code, diagnose_codes)) - ); - -TRACE_EVENT(kvm_s390_handle_lctl, - TP_PROTO(VCPU_PROTO_COMMON, int g, int reg1, int reg3, u64 addr), - TP_ARGS(VCPU_ARGS_COMMON, g, reg1, reg3, addr), - - TP_STRUCT__entry( - VCPU_FIELD_COMMON - __field(int, g) - __field(int, reg1) - __field(int, reg3) - __field(u64, addr) - ), - - TP_fast_assign( - VCPU_ASSIGN_COMMON - __entry->g = g; - __entry->reg1 = reg1; - __entry->reg3 = reg3; - __entry->addr = addr; - ), - - VCPU_TP_PRINTK("%s: loading cr %x-%x from %016llx", - __entry->g ? "lctlg" : "lctl", - __entry->reg1, __entry->reg3, __entry->addr) - ); - -TRACE_EVENT(kvm_s390_handle_prefix, - TP_PROTO(VCPU_PROTO_COMMON, int set, u32 address), - TP_ARGS(VCPU_ARGS_COMMON, set, address), - - TP_STRUCT__entry( - VCPU_FIELD_COMMON - __field(int, set) - __field(u32, address) - ), - - TP_fast_assign( - VCPU_ASSIGN_COMMON - __entry->set = set; - __entry->address = address; - ), - - VCPU_TP_PRINTK("%s prefix to %08x", - __entry->set ? "setting" : "storing", - __entry->address) - ); - -TRACE_EVENT(kvm_s390_handle_stap, - TP_PROTO(VCPU_PROTO_COMMON, u64 address), - TP_ARGS(VCPU_ARGS_COMMON, address), - - TP_STRUCT__entry( - VCPU_FIELD_COMMON - __field(u64, address) - ), - - TP_fast_assign( - VCPU_ASSIGN_COMMON - __entry->address = address; - ), - - VCPU_TP_PRINTK("storing cpu address to %016llx", - __entry->address) - ); - -TRACE_EVENT(kvm_s390_handle_stfl, - TP_PROTO(VCPU_PROTO_COMMON, unsigned int facility_list), - TP_ARGS(VCPU_ARGS_COMMON, facility_list), - - TP_STRUCT__entry( - VCPU_FIELD_COMMON - __field(unsigned int, facility_list) - ), - - TP_fast_assign( - VCPU_ASSIGN_COMMON - __entry->facility_list = facility_list; - ), - - VCPU_TP_PRINTK("store facility list value %08x", - __entry->facility_list) - ); - -TRACE_EVENT(kvm_s390_handle_stsi, - TP_PROTO(VCPU_PROTO_COMMON, int fc, int sel1, int sel2, u64 addr), - TP_ARGS(VCPU_ARGS_COMMON, fc, sel1, sel2, addr), - - TP_STRUCT__entry( - VCPU_FIELD_COMMON - __field(int, fc) - __field(int, sel1) - __field(int, sel2) - __field(u64, addr) - ), - - TP_fast_assign( - VCPU_ASSIGN_COMMON - __entry->fc = fc; - __entry->sel1 = sel1; - __entry->sel2 = sel2; - __entry->addr = addr; - ), - - VCPU_TP_PRINTK("STSI %d.%d.%d information stored to %016llx", - __entry->fc, __entry->sel1, __entry->sel2, - __entry->addr) - ); - -#endif /* _TRACE_KVM_H */ - -/* This part must be outside protection */ -#include diff --git a/trunk/arch/score/Kconfig b/trunk/arch/score/Kconfig index 461c23747491..ba0f412920be 100644 --- a/trunk/arch/score/Kconfig +++ b/trunk/arch/score/Kconfig @@ -5,7 +5,6 @@ config SCORE select HAVE_GENERIC_HARDIRQS select GENERIC_IRQ_SHOW select GENERIC_IOMAP - select GENERIC_ATOMIC64 select HAVE_MEMBLOCK select HAVE_MEMBLOCK_NODE_MAP select ARCH_DISCARD_MEMBLOCK diff --git a/trunk/arch/score/include/asm/elf.h b/trunk/arch/score/include/asm/elf.h index 5d566c7a0af2..f478ce94181f 100644 --- a/trunk/arch/score/include/asm/elf.h +++ b/trunk/arch/score/include/asm/elf.h @@ -54,7 +54,7 @@ typedef elf_fpreg_t elf_fpregset_t; #define SET_PERSONALITY(ex) \ do { \ - set_personality(PER_LINUX | (current->personality & (~PER_MASK))); \ + set_personality(PER_LINUX); \ } while (0) struct task_struct; diff --git a/trunk/arch/score/include/asm/unistd.h b/trunk/arch/score/include/asm/unistd.h index 4aa957364d4d..a862384e9c16 100644 --- a/trunk/arch/score/include/asm/unistd.h +++ b/trunk/arch/score/include/asm/unistd.h @@ -1,6 +1,3 @@ -#if !defined(_ASM_SCORE_UNISTD_H) || defined(__SYSCALL) -#define _ASM_SCORE_UNISTD_H - #define __ARCH_HAVE_MMU #define __ARCH_WANT_SYSCALL_NO_AT @@ -9,5 +6,3 @@ #define __ARCH_WANT_SYSCALL_DEPRECATED #include - -#endif /* _ASM_SCORE_UNISTD_H */ diff --git a/trunk/arch/score/kernel/sys_score.c b/trunk/arch/score/kernel/sys_score.c index 21e867974066..e478bf9a7e91 100644 --- a/trunk/arch/score/kernel/sys_score.c +++ b/trunk/arch/score/kernel/sys_score.c @@ -112,7 +112,6 @@ score_execve(struct pt_regs *regs) * Do a system call from kernel instead of calling sys_execve so we * end up with proper pt_regs. */ -asmlinkage int kernel_execve(const char *filename, const char *const argv[], const char *const envp[]) diff --git a/trunk/arch/sh/include/asm/elf.h b/trunk/arch/sh/include/asm/elf.h index 37924afa8d8a..f38112be67d2 100644 --- a/trunk/arch/sh/include/asm/elf.h +++ b/trunk/arch/sh/include/asm/elf.h @@ -183,8 +183,7 @@ do { \ } while (0) #endif -#define SET_PERSONALITY(ex) \ - set_personality(PER_LINUX_32BIT | (current->personality & (~PER_MASK))) +#define SET_PERSONALITY(ex) set_personality(PER_LINUX_32BIT) #ifdef CONFIG_VSYSCALL /* vDSO has arch_setup_additional_pages */ diff --git a/trunk/arch/sh/include/asm/io.h b/trunk/arch/sh/include/asm/io.h index 73a23f4617a3..0cf60a628814 100644 --- a/trunk/arch/sh/include/asm/io.h +++ b/trunk/arch/sh/include/asm/io.h @@ -134,7 +134,7 @@ __BUILD_MEMORY_STRING(__raw_, q, u64) * load/store instructions. sh_io_port_base is the virtual address to * which all ports are being mapped. */ -extern unsigned long sh_io_port_base; +extern const unsigned long sh_io_port_base; static inline void __set_io_port_base(unsigned long pbase) { diff --git a/trunk/arch/sh/kernel/ioport.c b/trunk/arch/sh/kernel/ioport.c index cca14ba84a37..e3ad6103e7c1 100644 --- a/trunk/arch/sh/kernel/ioport.c +++ b/trunk/arch/sh/kernel/ioport.c @@ -11,7 +11,7 @@ #include #include -unsigned long sh_io_port_base __read_mostly = -1; +const unsigned long sh_io_port_base __read_mostly = -1; EXPORT_SYMBOL(sh_io_port_base); void __iomem *__ioport_map(unsigned long addr, unsigned int size) diff --git a/trunk/arch/sparc/include/asm/compat.h b/trunk/arch/sparc/include/asm/compat.h index cef99fbc0a21..b8be20d42a0a 100644 --- a/trunk/arch/sparc/include/asm/compat.h +++ b/trunk/arch/sparc/include/asm/compat.h @@ -36,7 +36,6 @@ typedef s64 compat_s64; typedef u32 compat_uint_t; typedef u32 compat_ulong_t; typedef u64 compat_u64; -typedef u32 compat_uptr_t; struct compat_timespec { compat_time_t tv_sec; @@ -148,65 +147,6 @@ typedef u32 compat_old_sigset_t; typedef u32 compat_sigset_word; -typedef union compat_sigval { - compat_int_t sival_int; - compat_uptr_t sival_ptr; -} compat_sigval_t; - -#define SI_PAD_SIZE32 (128/sizeof(int) - 3) - -typedef struct compat_siginfo { - int si_signo; - int si_errno; - int si_code; - - union { - int _pad[SI_PAD_SIZE32]; - - /* kill() */ - struct { - compat_pid_t _pid; /* sender's pid */ - unsigned int _uid; /* sender's uid */ - } _kill; - - /* POSIX.1b timers */ - struct { - compat_timer_t _tid; /* timer id */ - int _overrun; /* overrun count */ - compat_sigval_t _sigval; /* same as below */ - int _sys_private; /* not to be passed to user */ - } _timer; - - /* POSIX.1b signals */ - struct { - compat_pid_t _pid; /* sender's pid */ - unsigned int _uid; /* sender's uid */ - compat_sigval_t _sigval; - } _rt; - - /* SIGCHLD */ - struct { - compat_pid_t _pid; /* which child */ - unsigned int _uid; /* sender's uid */ - int _status; /* exit code */ - compat_clock_t _utime; - compat_clock_t _stime; - } _sigchld; - - /* SIGILL, SIGFPE, SIGSEGV, SIGBUS, SIGEMT */ - struct { - u32 _addr; /* faulting insn/memory ref. */ - int _trapno; - } _sigfault; - - /* SIGPOLL */ - struct { - int _band; /* POLL_IN, POLL_OUT, POLL_MSG */ - int _fd; - } _sigpoll; - } _sifields; -} compat_siginfo_t; - #define COMPAT_OFF_T_MAX 0x7fffffff #define COMPAT_LOFF_T_MAX 0x7fffffffffffffffL @@ -216,6 +156,7 @@ typedef struct compat_siginfo { * as pointers because the syscall entry code will have * appropriately converted them already. */ +typedef u32 compat_uptr_t; static inline void __user *compat_ptr(compat_uptr_t uptr) { diff --git a/trunk/arch/sparc/include/asm/elf_32.h b/trunk/arch/sparc/include/asm/elf_32.h index ac74a2c98e6d..2d4d755cba9e 100644 --- a/trunk/arch/sparc/include/asm/elf_32.h +++ b/trunk/arch/sparc/include/asm/elf_32.h @@ -128,7 +128,6 @@ typedef struct { #define ELF_PLATFORM (NULL) -#define SET_PERSONALITY(ex) \ - set_personality(PER_LINUX | (current->personality & (~PER_MASK))) +#define SET_PERSONALITY(ex) set_personality(PER_LINUX) #endif /* !(__ASMSPARC_ELF_H) */ diff --git a/trunk/arch/sparc/include/asm/siginfo.h b/trunk/arch/sparc/include/asm/siginfo.h index dbc182c438b4..215900fce21b 100644 --- a/trunk/arch/sparc/include/asm/siginfo.h +++ b/trunk/arch/sparc/include/asm/siginfo.h @@ -3,6 +3,7 @@ #if defined(__sparc__) && defined(__arch64__) +#define SI_PAD_SIZE32 ((SI_MAX_SIZE/sizeof(int)) - 3) #define __ARCH_SI_PREAMBLE_SIZE (4 * sizeof(int)) #define __ARCH_SI_BAND_T int diff --git a/trunk/arch/sparc/kernel/signal32.c b/trunk/arch/sparc/kernel/signal32.c index 53e48f721ce3..a53e0a5fd3a3 100644 --- a/trunk/arch/sparc/kernel/signal32.c +++ b/trunk/arch/sparc/kernel/signal32.c @@ -54,6 +54,58 @@ struct signal_frame32 { /* __siginfo_rwin_t * */u32 rwin_save; } __attribute__((aligned(8))); +typedef struct compat_siginfo{ + int si_signo; + int si_errno; + int si_code; + + union { + int _pad[SI_PAD_SIZE32]; + + /* kill() */ + struct { + compat_pid_t _pid; /* sender's pid */ + unsigned int _uid; /* sender's uid */ + } _kill; + + /* POSIX.1b timers */ + struct { + compat_timer_t _tid; /* timer id */ + int _overrun; /* overrun count */ + compat_sigval_t _sigval; /* same as below */ + int _sys_private; /* not to be passed to user */ + } _timer; + + /* POSIX.1b signals */ + struct { + compat_pid_t _pid; /* sender's pid */ + unsigned int _uid; /* sender's uid */ + compat_sigval_t _sigval; + } _rt; + + /* SIGCHLD */ + struct { + compat_pid_t _pid; /* which child */ + unsigned int _uid; /* sender's uid */ + int _status; /* exit code */ + compat_clock_t _utime; + compat_clock_t _stime; + } _sigchld; + + /* SIGILL, SIGFPE, SIGSEGV, SIGBUS, SIGEMT */ + struct { + u32 _addr; /* faulting insn/memory ref. */ + int _trapno; + } _sigfault; + + /* SIGPOLL */ + struct { + int _band; /* POLL_IN, POLL_OUT, POLL_MSG */ + int _fd; + } _sigpoll; + } _sifields; +}compat_siginfo_t; + struct rt_signal_frame32 { struct sparc_stackf32 ss; compat_siginfo_t info; diff --git a/trunk/arch/tile/include/asm/compat.h b/trunk/arch/tile/include/asm/compat.h index 3063e6fc8daa..6e74450ff0a1 100644 --- a/trunk/arch/tile/include/asm/compat.h +++ b/trunk/arch/tile/include/asm/compat.h @@ -110,68 +110,6 @@ struct compat_flock64 { typedef u32 compat_sigset_word; -typedef union compat_sigval { - compat_int_t sival_int; - compat_uptr_t sival_ptr; -} compat_sigval_t; - -#define COMPAT_SI_PAD_SIZE (128/sizeof(int) - 3) - -typedef struct compat_siginfo { - int si_signo; - int si_errno; - int si_code; - - union { - int _pad[COMPAT_SI_PAD_SIZE]; - - /* kill() */ - struct { - unsigned int _pid; /* sender's pid */ - unsigned int _uid; /* sender's uid */ - } _kill; - - /* POSIX.1b timers */ - struct { - compat_timer_t _tid; /* timer id */ - int _overrun; /* overrun count */ - compat_sigval_t _sigval; /* same as below */ - int _sys_private; /* not to be passed to user */ - int _overrun_incr; /* amount to add to overrun */ - } _timer; - - /* POSIX.1b signals */ - struct { - unsigned int _pid; /* sender's pid */ - unsigned int _uid; /* sender's uid */ - compat_sigval_t _sigval; - } _rt; - - /* SIGCHLD */ - struct { - unsigned int _pid; /* which child */ - unsigned int _uid; /* sender's uid */ - int _status; /* exit code */ - compat_clock_t _utime; - compat_clock_t _stime; - } _sigchld; - - /* SIGILL, SIGFPE, SIGSEGV, SIGBUS */ - struct { - unsigned int _addr; /* faulting insn/memory ref. */ -#ifdef __ARCH_SI_TRAPNO - int _trapno; /* TRAP # which caused the signal */ -#endif - } _sigfault; - - /* SIGPOLL */ - struct { - int _band; /* POLL_IN, POLL_OUT, POLL_MSG */ - int _fd; - } _sigpoll; - } _sifields; -} compat_siginfo_t; - #define COMPAT_OFF_T_MAX 0x7fffffff #define COMPAT_LOFF_T_MAX 0x7fffffffffffffffL diff --git a/trunk/arch/tile/include/asm/elf.h b/trunk/arch/tile/include/asm/elf.h index f8ccf08f6934..d16d006d660e 100644 --- a/trunk/arch/tile/include/asm/elf.h +++ b/trunk/arch/tile/include/asm/elf.h @@ -156,12 +156,12 @@ extern int arch_setup_additional_pages(struct linux_binprm *bprm, #undef SET_PERSONALITY #define SET_PERSONALITY(ex) \ do { \ - set_personality(PER_LINUX | (current->personality & (~PER_MASK))); \ + current->personality = PER_LINUX; \ current_thread_info()->status &= ~TS_COMPAT; \ } while (0) #define COMPAT_SET_PERSONALITY(ex) \ do { \ - set_personality(PER_LINUX | (current->personality & (~PER_MASK))); \ + current->personality = PER_LINUX_32BIT; \ current_thread_info()->status |= TS_COMPAT; \ } while (0) diff --git a/trunk/arch/tile/include/asm/unistd.h b/trunk/arch/tile/include/asm/unistd.h index a017246ca0ce..0e1f3e66e492 100644 --- a/trunk/arch/tile/include/asm/unistd.h +++ b/trunk/arch/tile/include/asm/unistd.h @@ -12,9 +12,6 @@ * more details. */ -#if !defined(_ASM_TILE_UNISTD_H) || defined(__SYSCALL) -#define _ASM_TILE_UNISTD_H - #if !defined(__LP64__) || defined(__SYSCALL_COMPAT) /* Use the flavor of this syscall that matches the 32-bit API better. */ #define __ARCH_WANT_SYNC_FILE_RANGE2 @@ -43,5 +40,3 @@ __SYSCALL(__NR_cmpxchg_badaddr, sys_cmpxchg_badaddr) #endif #define __ARCH_WANT_SYS_NEWFSTATAT #endif - -#endif /* _ASM_TILE_UNISTD_H */ diff --git a/trunk/arch/tile/kernel/compat_signal.c b/trunk/arch/tile/kernel/compat_signal.c index 7bc0859a9f5e..474571b84085 100644 --- a/trunk/arch/tile/kernel/compat_signal.c +++ b/trunk/arch/tile/kernel/compat_signal.c @@ -55,6 +55,63 @@ struct compat_ucontext { sigset_t uc_sigmask; /* mask last for extensibility */ }; +#define COMPAT_SI_PAD_SIZE ((SI_MAX_SIZE - 3 * sizeof(int)) / sizeof(int)) + +struct compat_siginfo { + int si_signo; + int si_errno; + int si_code; + + union { + int _pad[COMPAT_SI_PAD_SIZE]; + + /* kill() */ + struct { + unsigned int _pid; /* sender's pid */ + unsigned int _uid; /* sender's uid */ + } _kill; + + /* POSIX.1b timers */ + struct { + compat_timer_t _tid; /* timer id */ + int _overrun; /* overrun count */ + compat_sigval_t _sigval; /* same as below */ + int _sys_private; /* not to be passed to user */ + int _overrun_incr; /* amount to add to overrun */ + } _timer; + + /* POSIX.1b signals */ + struct { + unsigned int _pid; /* sender's pid */ + unsigned int _uid; /* sender's uid */ + compat_sigval_t _sigval; + } _rt; + + /* SIGCHLD */ + struct { + unsigned int _pid; /* which child */ + unsigned int _uid; /* sender's uid */ + int _status; /* exit code */ + compat_clock_t _utime; + compat_clock_t _stime; + } _sigchld; + + /* SIGILL, SIGFPE, SIGSEGV, SIGBUS */ + struct { + unsigned int _addr; /* faulting insn/memory ref. */ +#ifdef __ARCH_SI_TRAPNO + int _trapno; /* TRAP # which caused the signal */ +#endif + } _sigfault; + + /* SIGPOLL */ + struct { + int _band; /* POLL_IN, POLL_OUT, POLL_MSG */ + int _fd; + } _sigpoll; + } _sifields; +}; + struct compat_rt_sigframe { unsigned char save_area[C_ABI_SAVE_AREA_SIZE]; /* caller save area */ struct compat_siginfo info; diff --git a/trunk/arch/unicore32/Kconfig b/trunk/arch/unicore32/Kconfig index 1e638e75a6b7..b0a47433341e 100644 --- a/trunk/arch/unicore32/Kconfig +++ b/trunk/arch/unicore32/Kconfig @@ -6,7 +6,6 @@ config UNICORE32 select HAVE_DMA_ATTRS select HAVE_KERNEL_GZIP select HAVE_KERNEL_BZIP2 - select GENERIC_ATOMIC64 select HAVE_KERNEL_LZO select HAVE_KERNEL_LZMA select ARCH_HAVE_CUSTOM_GPIO_H diff --git a/trunk/arch/unicore32/include/asm/unistd.h b/trunk/arch/unicore32/include/asm/unistd.h index 9b2428019961..2abcf61c615d 100644 --- a/trunk/arch/unicore32/include/asm/unistd.h +++ b/trunk/arch/unicore32/include/asm/unistd.h @@ -9,10 +9,6 @@ * it under the terms of the GNU General Public License version 2 as * published by the Free Software Foundation. */ -#if !defined(__UNICORE_UNISTD_H__) || defined(__SYSCALL) -#define __UNICORE_UNISTD_H__ /* Use the standard ABI for syscalls. */ #include - -#endif /* __UNICORE_UNISTD_H__ */ diff --git a/trunk/arch/x86/Kconfig b/trunk/arch/x86/Kconfig index b72777ff32a9..7f9a395c5254 100644 --- a/trunk/arch/x86/Kconfig +++ b/trunk/arch/x86/Kconfig @@ -586,18 +586,23 @@ config PARAVIRT_TIME_ACCOUNTING source "arch/x86/xen/Kconfig" -config KVM_GUEST - bool "KVM Guest support (including kvmclock)" - select PARAVIRT +config KVM_CLOCK + bool "KVM paravirtualized clock" select PARAVIRT select PARAVIRT_CLOCK - default y if PARAVIRT_GUEST + ---help--- + Turning on this option will allow you to run a paravirtualized clock + when running over the KVM hypervisor. Instead of relying on a PIT + (or probably other) emulation by the underlying device model, the host + provides the guest with timing infrastructure such as time of day, and + system time + +config KVM_GUEST + bool "KVM Guest support" + select PARAVIRT ---help--- This option enables various optimizations for running under the KVM - hypervisor. It includes a paravirtualized clock, so that instead - of relying on a PIT (or probably other) emulation by the - underlying device model, the host provides the guest with - timing infrastructure such as time of day, and system time + hypervisor. source "arch/x86/lguest/Kconfig" diff --git a/trunk/arch/x86/crypto/Makefile b/trunk/arch/x86/crypto/Makefile index 5bacb4a226ac..e908e5de82d3 100644 --- a/trunk/arch/x86/crypto/Makefile +++ b/trunk/arch/x86/crypto/Makefile @@ -12,8 +12,6 @@ obj-$(CONFIG_CRYPTO_SERPENT_SSE2_586) += serpent-sse2-i586.o obj-$(CONFIG_CRYPTO_AES_X86_64) += aes-x86_64.o obj-$(CONFIG_CRYPTO_CAMELLIA_X86_64) += camellia-x86_64.o -obj-$(CONFIG_CRYPTO_CAST5_AVX_X86_64) += cast5-avx-x86_64.o -obj-$(CONFIG_CRYPTO_CAST6_AVX_X86_64) += cast6-avx-x86_64.o obj-$(CONFIG_CRYPTO_BLOWFISH_X86_64) += blowfish-x86_64.o obj-$(CONFIG_CRYPTO_TWOFISH_X86_64) += twofish-x86_64.o obj-$(CONFIG_CRYPTO_TWOFISH_X86_64_3WAY) += twofish-x86_64-3way.o @@ -34,8 +32,6 @@ serpent-sse2-i586-y := serpent-sse2-i586-asm_32.o serpent_sse2_glue.o aes-x86_64-y := aes-x86_64-asm_64.o aes_glue.o camellia-x86_64-y := camellia-x86_64-asm_64.o camellia_glue.o -cast5-avx-x86_64-y := cast5-avx-x86_64-asm_64.o cast5_avx_glue.o -cast6-avx-x86_64-y := cast6-avx-x86_64-asm_64.o cast6_avx_glue.o blowfish-x86_64-y := blowfish-x86_64-asm_64.o blowfish_glue.o twofish-x86_64-y := twofish-x86_64-asm_64.o twofish_glue.o twofish-x86_64-3way-y := twofish-x86_64-asm_64-3way.o twofish_glue_3way.o diff --git a/trunk/arch/x86/crypto/aes_glue.c b/trunk/arch/x86/crypto/aes_glue.c index aafe8ce0d65d..59b37deb8c8d 100644 --- a/trunk/arch/x86/crypto/aes_glue.c +++ b/trunk/arch/x86/crypto/aes_glue.c @@ -40,6 +40,7 @@ static struct crypto_alg aes_alg = { .cra_blocksize = AES_BLOCK_SIZE, .cra_ctxsize = sizeof(struct crypto_aes_ctx), .cra_module = THIS_MODULE, + .cra_list = LIST_HEAD_INIT(aes_alg.cra_list), .cra_u = { .cipher = { .cia_min_keysize = AES_MIN_KEY_SIZE, diff --git a/trunk/arch/x86/crypto/aesni-intel_glue.c b/trunk/arch/x86/crypto/aesni-intel_glue.c index 7c04d0da709b..34fdcff4d2c8 100644 --- a/trunk/arch/x86/crypto/aesni-intel_glue.c +++ b/trunk/arch/x86/crypto/aesni-intel_glue.c @@ -28,9 +28,6 @@ #include #include #include -#include -#include -#include #include #include #include @@ -44,10 +41,18 @@ #define HAS_CTR #endif +#if defined(CONFIG_CRYPTO_LRW) || defined(CONFIG_CRYPTO_LRW_MODULE) +#define HAS_LRW +#endif + #if defined(CONFIG_CRYPTO_PCBC) || defined(CONFIG_CRYPTO_PCBC_MODULE) #define HAS_PCBC #endif +#if defined(CONFIG_CRYPTO_XTS) || defined(CONFIG_CRYPTO_XTS_MODULE) +#define HAS_XTS +#endif + /* This data is stored at the end of the crypto_tfm struct. * It's a type of per "session" data storage location. * This needs to be 16 byte aligned. @@ -74,16 +79,6 @@ struct aesni_hash_subkey_req_data { #define AES_BLOCK_MASK (~(AES_BLOCK_SIZE-1)) #define RFC4106_HASH_SUBKEY_SIZE 16 -struct aesni_lrw_ctx { - struct lrw_table_ctx lrw_table; - u8 raw_aes_ctx[sizeof(struct crypto_aes_ctx) + AESNI_ALIGN - 1]; -}; - -struct aesni_xts_ctx { - u8 raw_tweak_ctx[sizeof(struct crypto_aes_ctx) + AESNI_ALIGN - 1]; - u8 raw_crypt_ctx[sizeof(struct crypto_aes_ctx) + AESNI_ALIGN - 1]; -}; - asmlinkage int aesni_set_key(struct crypto_aes_ctx *ctx, const u8 *in_key, unsigned int key_len); asmlinkage void aesni_enc(struct crypto_aes_ctx *ctx, u8 *out, @@ -403,167 +398,26 @@ static int ablk_rfc3686_ctr_init(struct crypto_tfm *tfm) #endif #endif -#ifdef HAS_PCBC -static int ablk_pcbc_init(struct crypto_tfm *tfm) +#ifdef HAS_LRW +static int ablk_lrw_init(struct crypto_tfm *tfm) { - return ablk_init_common(tfm, "fpu(pcbc(__driver-aes-aesni))"); + return ablk_init_common(tfm, "fpu(lrw(__driver-aes-aesni))"); } #endif -static void lrw_xts_encrypt_callback(void *ctx, u8 *blks, unsigned int nbytes) -{ - aesni_ecb_enc(ctx, blks, blks, nbytes); -} - -static void lrw_xts_decrypt_callback(void *ctx, u8 *blks, unsigned int nbytes) -{ - aesni_ecb_dec(ctx, blks, blks, nbytes); -} - -static int lrw_aesni_setkey(struct crypto_tfm *tfm, const u8 *key, - unsigned int keylen) -{ - struct aesni_lrw_ctx *ctx = crypto_tfm_ctx(tfm); - int err; - - err = aes_set_key_common(tfm, ctx->raw_aes_ctx, key, - keylen - AES_BLOCK_SIZE); - if (err) - return err; - - return lrw_init_table(&ctx->lrw_table, key + keylen - AES_BLOCK_SIZE); -} - -static void lrw_aesni_exit_tfm(struct crypto_tfm *tfm) -{ - struct aesni_lrw_ctx *ctx = crypto_tfm_ctx(tfm); - - lrw_free_table(&ctx->lrw_table); -} - -static int lrw_encrypt(struct blkcipher_desc *desc, struct scatterlist *dst, - struct scatterlist *src, unsigned int nbytes) -{ - struct aesni_lrw_ctx *ctx = crypto_blkcipher_ctx(desc->tfm); - be128 buf[8]; - struct lrw_crypt_req req = { - .tbuf = buf, - .tbuflen = sizeof(buf), - - .table_ctx = &ctx->lrw_table, - .crypt_ctx = aes_ctx(ctx->raw_aes_ctx), - .crypt_fn = lrw_xts_encrypt_callback, - }; - int ret; - - desc->flags &= ~CRYPTO_TFM_REQ_MAY_SLEEP; - - kernel_fpu_begin(); - ret = lrw_crypt(desc, dst, src, nbytes, &req); - kernel_fpu_end(); - - return ret; -} - -static int lrw_decrypt(struct blkcipher_desc *desc, struct scatterlist *dst, - struct scatterlist *src, unsigned int nbytes) -{ - struct aesni_lrw_ctx *ctx = crypto_blkcipher_ctx(desc->tfm); - be128 buf[8]; - struct lrw_crypt_req req = { - .tbuf = buf, - .tbuflen = sizeof(buf), - - .table_ctx = &ctx->lrw_table, - .crypt_ctx = aes_ctx(ctx->raw_aes_ctx), - .crypt_fn = lrw_xts_decrypt_callback, - }; - int ret; - - desc->flags &= ~CRYPTO_TFM_REQ_MAY_SLEEP; - - kernel_fpu_begin(); - ret = lrw_crypt(desc, dst, src, nbytes, &req); - kernel_fpu_end(); - - return ret; -} - -static int xts_aesni_setkey(struct crypto_tfm *tfm, const u8 *key, - unsigned int keylen) -{ - struct aesni_xts_ctx *ctx = crypto_tfm_ctx(tfm); - u32 *flags = &tfm->crt_flags; - int err; - - /* key consists of keys of equal size concatenated, therefore - * the length must be even - */ - if (keylen % 2) { - *flags |= CRYPTO_TFM_RES_BAD_KEY_LEN; - return -EINVAL; - } - - /* first half of xts-key is for crypt */ - err = aes_set_key_common(tfm, ctx->raw_crypt_ctx, key, keylen / 2); - if (err) - return err; - - /* second half of xts-key is for tweak */ - return aes_set_key_common(tfm, ctx->raw_tweak_ctx, key + keylen / 2, - keylen / 2); -} - - -static int xts_encrypt(struct blkcipher_desc *desc, struct scatterlist *dst, - struct scatterlist *src, unsigned int nbytes) +#ifdef HAS_PCBC +static int ablk_pcbc_init(struct crypto_tfm *tfm) { - struct aesni_xts_ctx *ctx = crypto_blkcipher_ctx(desc->tfm); - be128 buf[8]; - struct xts_crypt_req req = { - .tbuf = buf, - .tbuflen = sizeof(buf), - - .tweak_ctx = aes_ctx(ctx->raw_tweak_ctx), - .tweak_fn = XTS_TWEAK_CAST(aesni_enc), - .crypt_ctx = aes_ctx(ctx->raw_crypt_ctx), - .crypt_fn = lrw_xts_encrypt_callback, - }; - int ret; - - desc->flags &= ~CRYPTO_TFM_REQ_MAY_SLEEP; - - kernel_fpu_begin(); - ret = xts_crypt(desc, dst, src, nbytes, &req); - kernel_fpu_end(); - - return ret; + return ablk_init_common(tfm, "fpu(pcbc(__driver-aes-aesni))"); } +#endif -static int xts_decrypt(struct blkcipher_desc *desc, struct scatterlist *dst, - struct scatterlist *src, unsigned int nbytes) +#ifdef HAS_XTS +static int ablk_xts_init(struct crypto_tfm *tfm) { - struct aesni_xts_ctx *ctx = crypto_blkcipher_ctx(desc->tfm); - be128 buf[8]; - struct xts_crypt_req req = { - .tbuf = buf, - .tbuflen = sizeof(buf), - - .tweak_ctx = aes_ctx(ctx->raw_tweak_ctx), - .tweak_fn = XTS_TWEAK_CAST(aesni_enc), - .crypt_ctx = aes_ctx(ctx->raw_crypt_ctx), - .crypt_fn = lrw_xts_decrypt_callback, - }; - int ret; - - desc->flags &= ~CRYPTO_TFM_REQ_MAY_SLEEP; - - kernel_fpu_begin(); - ret = xts_crypt(desc, dst, src, nbytes, &req); - kernel_fpu_end(); - - return ret; + return ablk_init_common(tfm, "fpu(xts(__driver-aes-aesni))"); } +#endif #ifdef CONFIG_X86_64 static int rfc4106_init(struct crypto_tfm *tfm) @@ -1181,10 +1035,10 @@ static struct crypto_alg aesni_algs[] = { { }, #endif #endif -#ifdef HAS_PCBC +#ifdef HAS_LRW }, { - .cra_name = "pcbc(aes)", - .cra_driver_name = "pcbc-aes-aesni", + .cra_name = "lrw(aes)", + .cra_driver_name = "lrw-aes-aesni", .cra_priority = 400, .cra_flags = CRYPTO_ALG_TYPE_ABLKCIPHER | CRYPTO_ALG_ASYNC, .cra_blocksize = AES_BLOCK_SIZE, @@ -1192,12 +1046,12 @@ static struct crypto_alg aesni_algs[] = { { .cra_alignmask = 0, .cra_type = &crypto_ablkcipher_type, .cra_module = THIS_MODULE, - .cra_init = ablk_pcbc_init, + .cra_init = ablk_lrw_init, .cra_exit = ablk_exit, .cra_u = { .ablkcipher = { - .min_keysize = AES_MIN_KEY_SIZE, - .max_keysize = AES_MAX_KEY_SIZE, + .min_keysize = AES_MIN_KEY_SIZE + AES_BLOCK_SIZE, + .max_keysize = AES_MAX_KEY_SIZE + AES_BLOCK_SIZE, .ivsize = AES_BLOCK_SIZE, .setkey = ablk_set_key, .encrypt = ablk_encrypt, @@ -1205,50 +1059,10 @@ static struct crypto_alg aesni_algs[] = { { }, }, #endif +#ifdef HAS_PCBC }, { - .cra_name = "__lrw-aes-aesni", - .cra_driver_name = "__driver-lrw-aes-aesni", - .cra_priority = 0, - .cra_flags = CRYPTO_ALG_TYPE_BLKCIPHER, - .cra_blocksize = AES_BLOCK_SIZE, - .cra_ctxsize = sizeof(struct aesni_lrw_ctx), - .cra_alignmask = 0, - .cra_type = &crypto_blkcipher_type, - .cra_module = THIS_MODULE, - .cra_exit = lrw_aesni_exit_tfm, - .cra_u = { - .blkcipher = { - .min_keysize = AES_MIN_KEY_SIZE + AES_BLOCK_SIZE, - .max_keysize = AES_MAX_KEY_SIZE + AES_BLOCK_SIZE, - .ivsize = AES_BLOCK_SIZE, - .setkey = lrw_aesni_setkey, - .encrypt = lrw_encrypt, - .decrypt = lrw_decrypt, - }, - }, -}, { - .cra_name = "__xts-aes-aesni", - .cra_driver_name = "__driver-xts-aes-aesni", - .cra_priority = 0, - .cra_flags = CRYPTO_ALG_TYPE_BLKCIPHER, - .cra_blocksize = AES_BLOCK_SIZE, - .cra_ctxsize = sizeof(struct aesni_xts_ctx), - .cra_alignmask = 0, - .cra_type = &crypto_blkcipher_type, - .cra_module = THIS_MODULE, - .cra_u = { - .blkcipher = { - .min_keysize = 2 * AES_MIN_KEY_SIZE, - .max_keysize = 2 * AES_MAX_KEY_SIZE, - .ivsize = AES_BLOCK_SIZE, - .setkey = xts_aesni_setkey, - .encrypt = xts_encrypt, - .decrypt = xts_decrypt, - }, - }, -}, { - .cra_name = "lrw(aes)", - .cra_driver_name = "lrw-aes-aesni", + .cra_name = "pcbc(aes)", + .cra_driver_name = "pcbc-aes-aesni", .cra_priority = 400, .cra_flags = CRYPTO_ALG_TYPE_ABLKCIPHER | CRYPTO_ALG_ASYNC, .cra_blocksize = AES_BLOCK_SIZE, @@ -1256,18 +1070,20 @@ static struct crypto_alg aesni_algs[] = { { .cra_alignmask = 0, .cra_type = &crypto_ablkcipher_type, .cra_module = THIS_MODULE, - .cra_init = ablk_init, + .cra_init = ablk_pcbc_init, .cra_exit = ablk_exit, .cra_u = { .ablkcipher = { - .min_keysize = AES_MIN_KEY_SIZE + AES_BLOCK_SIZE, - .max_keysize = AES_MAX_KEY_SIZE + AES_BLOCK_SIZE, + .min_keysize = AES_MIN_KEY_SIZE, + .max_keysize = AES_MAX_KEY_SIZE, .ivsize = AES_BLOCK_SIZE, .setkey = ablk_set_key, .encrypt = ablk_encrypt, .decrypt = ablk_decrypt, }, }, +#endif +#ifdef HAS_XTS }, { .cra_name = "xts(aes)", .cra_driver_name = "xts-aes-aesni", @@ -1278,7 +1094,7 @@ static struct crypto_alg aesni_algs[] = { { .cra_alignmask = 0, .cra_type = &crypto_ablkcipher_type, .cra_module = THIS_MODULE, - .cra_init = ablk_init, + .cra_init = ablk_xts_init, .cra_exit = ablk_exit, .cra_u = { .ablkcipher = { @@ -1290,6 +1106,7 @@ static struct crypto_alg aesni_algs[] = { { .decrypt = ablk_decrypt, }, }, +#endif } }; @@ -1301,7 +1118,7 @@ MODULE_DEVICE_TABLE(x86cpu, aesni_cpu_id); static int __init aesni_init(void) { - int err; + int err, i; if (!x86_match_cpu(aesni_cpu_id)) return -ENODEV; @@ -1310,6 +1127,9 @@ static int __init aesni_init(void) if (err) return err; + for (i = 0; i < ARRAY_SIZE(aesni_algs); i++) + INIT_LIST_HEAD(&aesni_algs[i].cra_list); + return crypto_register_algs(aesni_algs, ARRAY_SIZE(aesni_algs)); } diff --git a/trunk/arch/x86/crypto/blowfish_glue.c b/trunk/arch/x86/crypto/blowfish_glue.c index 50ec333b70e6..7967474de8f7 100644 --- a/trunk/arch/x86/crypto/blowfish_glue.c +++ b/trunk/arch/x86/crypto/blowfish_glue.c @@ -367,6 +367,7 @@ static struct crypto_alg bf_algs[4] = { { .cra_ctxsize = sizeof(struct bf_ctx), .cra_alignmask = 0, .cra_module = THIS_MODULE, + .cra_list = LIST_HEAD_INIT(bf_algs[0].cra_list), .cra_u = { .cipher = { .cia_min_keysize = BF_MIN_KEY_SIZE, @@ -386,6 +387,7 @@ static struct crypto_alg bf_algs[4] = { { .cra_alignmask = 0, .cra_type = &crypto_blkcipher_type, .cra_module = THIS_MODULE, + .cra_list = LIST_HEAD_INIT(bf_algs[1].cra_list), .cra_u = { .blkcipher = { .min_keysize = BF_MIN_KEY_SIZE, @@ -405,6 +407,7 @@ static struct crypto_alg bf_algs[4] = { { .cra_alignmask = 0, .cra_type = &crypto_blkcipher_type, .cra_module = THIS_MODULE, + .cra_list = LIST_HEAD_INIT(bf_algs[2].cra_list), .cra_u = { .blkcipher = { .min_keysize = BF_MIN_KEY_SIZE, @@ -425,6 +428,7 @@ static struct crypto_alg bf_algs[4] = { { .cra_alignmask = 0, .cra_type = &crypto_blkcipher_type, .cra_module = THIS_MODULE, + .cra_list = LIST_HEAD_INIT(bf_algs[3].cra_list), .cra_u = { .blkcipher = { .min_keysize = BF_MIN_KEY_SIZE, diff --git a/trunk/arch/x86/crypto/camellia_glue.c b/trunk/arch/x86/crypto/camellia_glue.c index 42ffd2bbab5b..eeb2b3b743e9 100644 --- a/trunk/arch/x86/crypto/camellia_glue.c +++ b/trunk/arch/x86/crypto/camellia_glue.c @@ -92,715 +92,715 @@ static void camellia_decrypt(struct crypto_tfm *tfm, u8 *dst, const u8 *src) /* camellia sboxes */ const u64 camellia_sp10011110[256] = { - 0x7000007070707000ULL, 0x8200008282828200ULL, 0x2c00002c2c2c2c00ULL, - 0xec0000ecececec00ULL, 0xb30000b3b3b3b300ULL, 0x2700002727272700ULL, - 0xc00000c0c0c0c000ULL, 0xe50000e5e5e5e500ULL, 0xe40000e4e4e4e400ULL, - 0x8500008585858500ULL, 0x5700005757575700ULL, 0x3500003535353500ULL, - 0xea0000eaeaeaea00ULL, 0x0c00000c0c0c0c00ULL, 0xae0000aeaeaeae00ULL, - 0x4100004141414100ULL, 0x2300002323232300ULL, 0xef0000efefefef00ULL, - 0x6b00006b6b6b6b00ULL, 0x9300009393939300ULL, 0x4500004545454500ULL, - 0x1900001919191900ULL, 0xa50000a5a5a5a500ULL, 0x2100002121212100ULL, - 0xed0000edededed00ULL, 0x0e00000e0e0e0e00ULL, 0x4f00004f4f4f4f00ULL, - 0x4e00004e4e4e4e00ULL, 0x1d00001d1d1d1d00ULL, 0x6500006565656500ULL, - 0x9200009292929200ULL, 0xbd0000bdbdbdbd00ULL, 0x8600008686868600ULL, - 0xb80000b8b8b8b800ULL, 0xaf0000afafafaf00ULL, 0x8f00008f8f8f8f00ULL, - 0x7c00007c7c7c7c00ULL, 0xeb0000ebebebeb00ULL, 0x1f00001f1f1f1f00ULL, - 0xce0000cececece00ULL, 0x3e00003e3e3e3e00ULL, 0x3000003030303000ULL, - 0xdc0000dcdcdcdc00ULL, 0x5f00005f5f5f5f00ULL, 0x5e00005e5e5e5e00ULL, - 0xc50000c5c5c5c500ULL, 0x0b00000b0b0b0b00ULL, 0x1a00001a1a1a1a00ULL, - 0xa60000a6a6a6a600ULL, 0xe10000e1e1e1e100ULL, 0x3900003939393900ULL, - 0xca0000cacacaca00ULL, 0xd50000d5d5d5d500ULL, 0x4700004747474700ULL, - 0x5d00005d5d5d5d00ULL, 0x3d00003d3d3d3d00ULL, 0xd90000d9d9d9d900ULL, - 0x0100000101010100ULL, 0x5a00005a5a5a5a00ULL, 0xd60000d6d6d6d600ULL, - 0x5100005151515100ULL, 0x5600005656565600ULL, 0x6c00006c6c6c6c00ULL, - 0x4d00004d4d4d4d00ULL, 0x8b00008b8b8b8b00ULL, 0x0d00000d0d0d0d00ULL, - 0x9a00009a9a9a9a00ULL, 0x6600006666666600ULL, 0xfb0000fbfbfbfb00ULL, - 0xcc0000cccccccc00ULL, 0xb00000b0b0b0b000ULL, 0x2d00002d2d2d2d00ULL, - 0x7400007474747400ULL, 0x1200001212121200ULL, 0x2b00002b2b2b2b00ULL, - 0x2000002020202000ULL, 0xf00000f0f0f0f000ULL, 0xb10000b1b1b1b100ULL, - 0x8400008484848400ULL, 0x9900009999999900ULL, 0xdf0000dfdfdfdf00ULL, - 0x4c00004c4c4c4c00ULL, 0xcb0000cbcbcbcb00ULL, 0xc20000c2c2c2c200ULL, - 0x3400003434343400ULL, 0x7e00007e7e7e7e00ULL, 0x7600007676767600ULL, - 0x0500000505050500ULL, 0x6d00006d6d6d6d00ULL, 0xb70000b7b7b7b700ULL, - 0xa90000a9a9a9a900ULL, 0x3100003131313100ULL, 0xd10000d1d1d1d100ULL, - 0x1700001717171700ULL, 0x0400000404040400ULL, 0xd70000d7d7d7d700ULL, - 0x1400001414141400ULL, 0x5800005858585800ULL, 0x3a00003a3a3a3a00ULL, - 0x6100006161616100ULL, 0xde0000dededede00ULL, 0x1b00001b1b1b1b00ULL, - 0x1100001111111100ULL, 0x1c00001c1c1c1c00ULL, 0x3200003232323200ULL, - 0x0f00000f0f0f0f00ULL, 0x9c00009c9c9c9c00ULL, 0x1600001616161600ULL, - 0x5300005353535300ULL, 0x1800001818181800ULL, 0xf20000f2f2f2f200ULL, - 0x2200002222222200ULL, 0xfe0000fefefefe00ULL, 0x4400004444444400ULL, - 0xcf0000cfcfcfcf00ULL, 0xb20000b2b2b2b200ULL, 0xc30000c3c3c3c300ULL, - 0xb50000b5b5b5b500ULL, 0x7a00007a7a7a7a00ULL, 0x9100009191919100ULL, - 0x2400002424242400ULL, 0x0800000808080800ULL, 0xe80000e8e8e8e800ULL, - 0xa80000a8a8a8a800ULL, 0x6000006060606000ULL, 0xfc0000fcfcfcfc00ULL, - 0x6900006969696900ULL, 0x5000005050505000ULL, 0xaa0000aaaaaaaa00ULL, - 0xd00000d0d0d0d000ULL, 0xa00000a0a0a0a000ULL, 0x7d00007d7d7d7d00ULL, - 0xa10000a1a1a1a100ULL, 0x8900008989898900ULL, 0x6200006262626200ULL, - 0x9700009797979700ULL, 0x5400005454545400ULL, 0x5b00005b5b5b5b00ULL, - 0x1e00001e1e1e1e00ULL, 0x9500009595959500ULL, 0xe00000e0e0e0e000ULL, - 0xff0000ffffffff00ULL, 0x6400006464646400ULL, 0xd20000d2d2d2d200ULL, - 0x1000001010101000ULL, 0xc40000c4c4c4c400ULL, 0x0000000000000000ULL, - 0x4800004848484800ULL, 0xa30000a3a3a3a300ULL, 0xf70000f7f7f7f700ULL, - 0x7500007575757500ULL, 0xdb0000dbdbdbdb00ULL, 0x8a00008a8a8a8a00ULL, - 0x0300000303030300ULL, 0xe60000e6e6e6e600ULL, 0xda0000dadadada00ULL, - 0x0900000909090900ULL, 0x3f00003f3f3f3f00ULL, 0xdd0000dddddddd00ULL, - 0x9400009494949400ULL, 0x8700008787878700ULL, 0x5c00005c5c5c5c00ULL, - 0x8300008383838300ULL, 0x0200000202020200ULL, 0xcd0000cdcdcdcd00ULL, - 0x4a00004a4a4a4a00ULL, 0x9000009090909000ULL, 0x3300003333333300ULL, - 0x7300007373737300ULL, 0x6700006767676700ULL, 0xf60000f6f6f6f600ULL, - 0xf30000f3f3f3f300ULL, 0x9d00009d9d9d9d00ULL, 0x7f00007f7f7f7f00ULL, - 0xbf0000bfbfbfbf00ULL, 0xe20000e2e2e2e200ULL, 0x5200005252525200ULL, - 0x9b00009b9b9b9b00ULL, 0xd80000d8d8d8d800ULL, 0x2600002626262600ULL, - 0xc80000c8c8c8c800ULL, 0x3700003737373700ULL, 0xc60000c6c6c6c600ULL, - 0x3b00003b3b3b3b00ULL, 0x8100008181818100ULL, 0x9600009696969600ULL, - 0x6f00006f6f6f6f00ULL, 0x4b00004b4b4b4b00ULL, 0x1300001313131300ULL, - 0xbe0000bebebebe00ULL, 0x6300006363636300ULL, 0x2e00002e2e2e2e00ULL, - 0xe90000e9e9e9e900ULL, 0x7900007979797900ULL, 0xa70000a7a7a7a700ULL, - 0x8c00008c8c8c8c00ULL, 0x9f00009f9f9f9f00ULL, 0x6e00006e6e6e6e00ULL, - 0xbc0000bcbcbcbc00ULL, 0x8e00008e8e8e8e00ULL, 0x2900002929292900ULL, - 0xf50000f5f5f5f500ULL, 0xf90000f9f9f9f900ULL, 0xb60000b6b6b6b600ULL, - 0x2f00002f2f2f2f00ULL, 0xfd0000fdfdfdfd00ULL, 0xb40000b4b4b4b400ULL, - 0x5900005959595900ULL, 0x7800007878787800ULL, 0x9800009898989800ULL, - 0x0600000606060600ULL, 0x6a00006a6a6a6a00ULL, 0xe70000e7e7e7e700ULL, - 0x4600004646464600ULL, 0x7100007171717100ULL, 0xba0000babababa00ULL, - 0xd40000d4d4d4d400ULL, 0x2500002525252500ULL, 0xab0000abababab00ULL, - 0x4200004242424200ULL, 0x8800008888888800ULL, 0xa20000a2a2a2a200ULL, - 0x8d00008d8d8d8d00ULL, 0xfa0000fafafafa00ULL, 0x7200007272727200ULL, - 0x0700000707070700ULL, 0xb90000b9b9b9b900ULL, 0x5500005555555500ULL, - 0xf80000f8f8f8f800ULL, 0xee0000eeeeeeee00ULL, 0xac0000acacacac00ULL, - 0x0a00000a0a0a0a00ULL, 0x3600003636363600ULL, 0x4900004949494900ULL, - 0x2a00002a2a2a2a00ULL, 0x6800006868686800ULL, 0x3c00003c3c3c3c00ULL, - 0x3800003838383800ULL, 0xf10000f1f1f1f100ULL, 0xa40000a4a4a4a400ULL, - 0x4000004040404000ULL, 0x2800002828282800ULL, 0xd30000d3d3d3d300ULL, - 0x7b00007b7b7b7b00ULL, 0xbb0000bbbbbbbb00ULL, 0xc90000c9c9c9c900ULL, - 0x4300004343434300ULL, 0xc10000c1c1c1c100ULL, 0x1500001515151500ULL, - 0xe30000e3e3e3e300ULL, 0xad0000adadadad00ULL, 0xf40000f4f4f4f400ULL, - 0x7700007777777700ULL, 0xc70000c7c7c7c700ULL, 0x8000008080808000ULL, - 0x9e00009e9e9e9e00ULL, + 0x7000007070707000, 0x8200008282828200, 0x2c00002c2c2c2c00, + 0xec0000ecececec00, 0xb30000b3b3b3b300, 0x2700002727272700, + 0xc00000c0c0c0c000, 0xe50000e5e5e5e500, 0xe40000e4e4e4e400, + 0x8500008585858500, 0x5700005757575700, 0x3500003535353500, + 0xea0000eaeaeaea00, 0x0c00000c0c0c0c00, 0xae0000aeaeaeae00, + 0x4100004141414100, 0x2300002323232300, 0xef0000efefefef00, + 0x6b00006b6b6b6b00, 0x9300009393939300, 0x4500004545454500, + 0x1900001919191900, 0xa50000a5a5a5a500, 0x2100002121212100, + 0xed0000edededed00, 0x0e00000e0e0e0e00, 0x4f00004f4f4f4f00, + 0x4e00004e4e4e4e00, 0x1d00001d1d1d1d00, 0x6500006565656500, + 0x9200009292929200, 0xbd0000bdbdbdbd00, 0x8600008686868600, + 0xb80000b8b8b8b800, 0xaf0000afafafaf00, 0x8f00008f8f8f8f00, + 0x7c00007c7c7c7c00, 0xeb0000ebebebeb00, 0x1f00001f1f1f1f00, + 0xce0000cececece00, 0x3e00003e3e3e3e00, 0x3000003030303000, + 0xdc0000dcdcdcdc00, 0x5f00005f5f5f5f00, 0x5e00005e5e5e5e00, + 0xc50000c5c5c5c500, 0x0b00000b0b0b0b00, 0x1a00001a1a1a1a00, + 0xa60000a6a6a6a600, 0xe10000e1e1e1e100, 0x3900003939393900, + 0xca0000cacacaca00, 0xd50000d5d5d5d500, 0x4700004747474700, + 0x5d00005d5d5d5d00, 0x3d00003d3d3d3d00, 0xd90000d9d9d9d900, + 0x0100000101010100, 0x5a00005a5a5a5a00, 0xd60000d6d6d6d600, + 0x5100005151515100, 0x5600005656565600, 0x6c00006c6c6c6c00, + 0x4d00004d4d4d4d00, 0x8b00008b8b8b8b00, 0x0d00000d0d0d0d00, + 0x9a00009a9a9a9a00, 0x6600006666666600, 0xfb0000fbfbfbfb00, + 0xcc0000cccccccc00, 0xb00000b0b0b0b000, 0x2d00002d2d2d2d00, + 0x7400007474747400, 0x1200001212121200, 0x2b00002b2b2b2b00, + 0x2000002020202000, 0xf00000f0f0f0f000, 0xb10000b1b1b1b100, + 0x8400008484848400, 0x9900009999999900, 0xdf0000dfdfdfdf00, + 0x4c00004c4c4c4c00, 0xcb0000cbcbcbcb00, 0xc20000c2c2c2c200, + 0x3400003434343400, 0x7e00007e7e7e7e00, 0x7600007676767600, + 0x0500000505050500, 0x6d00006d6d6d6d00, 0xb70000b7b7b7b700, + 0xa90000a9a9a9a900, 0x3100003131313100, 0xd10000d1d1d1d100, + 0x1700001717171700, 0x0400000404040400, 0xd70000d7d7d7d700, + 0x1400001414141400, 0x5800005858585800, 0x3a00003a3a3a3a00, + 0x6100006161616100, 0xde0000dededede00, 0x1b00001b1b1b1b00, + 0x1100001111111100, 0x1c00001c1c1c1c00, 0x3200003232323200, + 0x0f00000f0f0f0f00, 0x9c00009c9c9c9c00, 0x1600001616161600, + 0x5300005353535300, 0x1800001818181800, 0xf20000f2f2f2f200, + 0x2200002222222200, 0xfe0000fefefefe00, 0x4400004444444400, + 0xcf0000cfcfcfcf00, 0xb20000b2b2b2b200, 0xc30000c3c3c3c300, + 0xb50000b5b5b5b500, 0x7a00007a7a7a7a00, 0x9100009191919100, + 0x2400002424242400, 0x0800000808080800, 0xe80000e8e8e8e800, + 0xa80000a8a8a8a800, 0x6000006060606000, 0xfc0000fcfcfcfc00, + 0x6900006969696900, 0x5000005050505000, 0xaa0000aaaaaaaa00, + 0xd00000d0d0d0d000, 0xa00000a0a0a0a000, 0x7d00007d7d7d7d00, + 0xa10000a1a1a1a100, 0x8900008989898900, 0x6200006262626200, + 0x9700009797979700, 0x5400005454545400, 0x5b00005b5b5b5b00, + 0x1e00001e1e1e1e00, 0x9500009595959500, 0xe00000e0e0e0e000, + 0xff0000ffffffff00, 0x6400006464646400, 0xd20000d2d2d2d200, + 0x1000001010101000, 0xc40000c4c4c4c400, 0x0000000000000000, + 0x4800004848484800, 0xa30000a3a3a3a300, 0xf70000f7f7f7f700, + 0x7500007575757500, 0xdb0000dbdbdbdb00, 0x8a00008a8a8a8a00, + 0x0300000303030300, 0xe60000e6e6e6e600, 0xda0000dadadada00, + 0x0900000909090900, 0x3f00003f3f3f3f00, 0xdd0000dddddddd00, + 0x9400009494949400, 0x8700008787878700, 0x5c00005c5c5c5c00, + 0x8300008383838300, 0x0200000202020200, 0xcd0000cdcdcdcd00, + 0x4a00004a4a4a4a00, 0x9000009090909000, 0x3300003333333300, + 0x7300007373737300, 0x6700006767676700, 0xf60000f6f6f6f600, + 0xf30000f3f3f3f300, 0x9d00009d9d9d9d00, 0x7f00007f7f7f7f00, + 0xbf0000bfbfbfbf00, 0xe20000e2e2e2e200, 0x5200005252525200, + 0x9b00009b9b9b9b00, 0xd80000d8d8d8d800, 0x2600002626262600, + 0xc80000c8c8c8c800, 0x3700003737373700, 0xc60000c6c6c6c600, + 0x3b00003b3b3b3b00, 0x8100008181818100, 0x9600009696969600, + 0x6f00006f6f6f6f00, 0x4b00004b4b4b4b00, 0x1300001313131300, + 0xbe0000bebebebe00, 0x6300006363636300, 0x2e00002e2e2e2e00, + 0xe90000e9e9e9e900, 0x7900007979797900, 0xa70000a7a7a7a700, + 0x8c00008c8c8c8c00, 0x9f00009f9f9f9f00, 0x6e00006e6e6e6e00, + 0xbc0000bcbcbcbc00, 0x8e00008e8e8e8e00, 0x2900002929292900, + 0xf50000f5f5f5f500, 0xf90000f9f9f9f900, 0xb60000b6b6b6b600, + 0x2f00002f2f2f2f00, 0xfd0000fdfdfdfd00, 0xb40000b4b4b4b400, + 0x5900005959595900, 0x7800007878787800, 0x9800009898989800, + 0x0600000606060600, 0x6a00006a6a6a6a00, 0xe70000e7e7e7e700, + 0x4600004646464600, 0x7100007171717100, 0xba0000babababa00, + 0xd40000d4d4d4d400, 0x2500002525252500, 0xab0000abababab00, + 0x4200004242424200, 0x8800008888888800, 0xa20000a2a2a2a200, + 0x8d00008d8d8d8d00, 0xfa0000fafafafa00, 0x7200007272727200, + 0x0700000707070700, 0xb90000b9b9b9b900, 0x5500005555555500, + 0xf80000f8f8f8f800, 0xee0000eeeeeeee00, 0xac0000acacacac00, + 0x0a00000a0a0a0a00, 0x3600003636363600, 0x4900004949494900, + 0x2a00002a2a2a2a00, 0x6800006868686800, 0x3c00003c3c3c3c00, + 0x3800003838383800, 0xf10000f1f1f1f100, 0xa40000a4a4a4a400, + 0x4000004040404000, 0x2800002828282800, 0xd30000d3d3d3d300, + 0x7b00007b7b7b7b00, 0xbb0000bbbbbbbb00, 0xc90000c9c9c9c900, + 0x4300004343434300, 0xc10000c1c1c1c100, 0x1500001515151500, + 0xe30000e3e3e3e300, 0xad0000adadadad00, 0xf40000f4f4f4f400, + 0x7700007777777700, 0xc70000c7c7c7c700, 0x8000008080808000, + 0x9e00009e9e9e9e00, }; const u64 camellia_sp22000222[256] = { - 0xe0e0000000e0e0e0ULL, 0x0505000000050505ULL, 0x5858000000585858ULL, - 0xd9d9000000d9d9d9ULL, 0x6767000000676767ULL, 0x4e4e0000004e4e4eULL, - 0x8181000000818181ULL, 0xcbcb000000cbcbcbULL, 0xc9c9000000c9c9c9ULL, - 0x0b0b0000000b0b0bULL, 0xaeae000000aeaeaeULL, 0x6a6a0000006a6a6aULL, - 0xd5d5000000d5d5d5ULL, 0x1818000000181818ULL, 0x5d5d0000005d5d5dULL, - 0x8282000000828282ULL, 0x4646000000464646ULL, 0xdfdf000000dfdfdfULL, - 0xd6d6000000d6d6d6ULL, 0x2727000000272727ULL, 0x8a8a0000008a8a8aULL, - 0x3232000000323232ULL, 0x4b4b0000004b4b4bULL, 0x4242000000424242ULL, - 0xdbdb000000dbdbdbULL, 0x1c1c0000001c1c1cULL, 0x9e9e0000009e9e9eULL, - 0x9c9c0000009c9c9cULL, 0x3a3a0000003a3a3aULL, 0xcaca000000cacacaULL, - 0x2525000000252525ULL, 0x7b7b0000007b7b7bULL, 0x0d0d0000000d0d0dULL, - 0x7171000000717171ULL, 0x5f5f0000005f5f5fULL, 0x1f1f0000001f1f1fULL, - 0xf8f8000000f8f8f8ULL, 0xd7d7000000d7d7d7ULL, 0x3e3e0000003e3e3eULL, - 0x9d9d0000009d9d9dULL, 0x7c7c0000007c7c7cULL, 0x6060000000606060ULL, - 0xb9b9000000b9b9b9ULL, 0xbebe000000bebebeULL, 0xbcbc000000bcbcbcULL, - 0x8b8b0000008b8b8bULL, 0x1616000000161616ULL, 0x3434000000343434ULL, - 0x4d4d0000004d4d4dULL, 0xc3c3000000c3c3c3ULL, 0x7272000000727272ULL, - 0x9595000000959595ULL, 0xabab000000abababULL, 0x8e8e0000008e8e8eULL, - 0xbaba000000bababaULL, 0x7a7a0000007a7a7aULL, 0xb3b3000000b3b3b3ULL, - 0x0202000000020202ULL, 0xb4b4000000b4b4b4ULL, 0xadad000000adadadULL, - 0xa2a2000000a2a2a2ULL, 0xacac000000acacacULL, 0xd8d8000000d8d8d8ULL, - 0x9a9a0000009a9a9aULL, 0x1717000000171717ULL, 0x1a1a0000001a1a1aULL, - 0x3535000000353535ULL, 0xcccc000000ccccccULL, 0xf7f7000000f7f7f7ULL, - 0x9999000000999999ULL, 0x6161000000616161ULL, 0x5a5a0000005a5a5aULL, - 0xe8e8000000e8e8e8ULL, 0x2424000000242424ULL, 0x5656000000565656ULL, - 0x4040000000404040ULL, 0xe1e1000000e1e1e1ULL, 0x6363000000636363ULL, - 0x0909000000090909ULL, 0x3333000000333333ULL, 0xbfbf000000bfbfbfULL, - 0x9898000000989898ULL, 0x9797000000979797ULL, 0x8585000000858585ULL, - 0x6868000000686868ULL, 0xfcfc000000fcfcfcULL, 0xecec000000ecececULL, - 0x0a0a0000000a0a0aULL, 0xdada000000dadadaULL, 0x6f6f0000006f6f6fULL, - 0x5353000000535353ULL, 0x6262000000626262ULL, 0xa3a3000000a3a3a3ULL, - 0x2e2e0000002e2e2eULL, 0x0808000000080808ULL, 0xafaf000000afafafULL, - 0x2828000000282828ULL, 0xb0b0000000b0b0b0ULL, 0x7474000000747474ULL, - 0xc2c2000000c2c2c2ULL, 0xbdbd000000bdbdbdULL, 0x3636000000363636ULL, - 0x2222000000222222ULL, 0x3838000000383838ULL, 0x6464000000646464ULL, - 0x1e1e0000001e1e1eULL, 0x3939000000393939ULL, 0x2c2c0000002c2c2cULL, - 0xa6a6000000a6a6a6ULL, 0x3030000000303030ULL, 0xe5e5000000e5e5e5ULL, - 0x4444000000444444ULL, 0xfdfd000000fdfdfdULL, 0x8888000000888888ULL, - 0x9f9f0000009f9f9fULL, 0x6565000000656565ULL, 0x8787000000878787ULL, - 0x6b6b0000006b6b6bULL, 0xf4f4000000f4f4f4ULL, 0x2323000000232323ULL, - 0x4848000000484848ULL, 0x1010000000101010ULL, 0xd1d1000000d1d1d1ULL, - 0x5151000000515151ULL, 0xc0c0000000c0c0c0ULL, 0xf9f9000000f9f9f9ULL, - 0xd2d2000000d2d2d2ULL, 0xa0a0000000a0a0a0ULL, 0x5555000000555555ULL, - 0xa1a1000000a1a1a1ULL, 0x4141000000414141ULL, 0xfafa000000fafafaULL, - 0x4343000000434343ULL, 0x1313000000131313ULL, 0xc4c4000000c4c4c4ULL, - 0x2f2f0000002f2f2fULL, 0xa8a8000000a8a8a8ULL, 0xb6b6000000b6b6b6ULL, - 0x3c3c0000003c3c3cULL, 0x2b2b0000002b2b2bULL, 0xc1c1000000c1c1c1ULL, - 0xffff000000ffffffULL, 0xc8c8000000c8c8c8ULL, 0xa5a5000000a5a5a5ULL, - 0x2020000000202020ULL, 0x8989000000898989ULL, 0x0000000000000000ULL, - 0x9090000000909090ULL, 0x4747000000474747ULL, 0xefef000000efefefULL, - 0xeaea000000eaeaeaULL, 0xb7b7000000b7b7b7ULL, 0x1515000000151515ULL, - 0x0606000000060606ULL, 0xcdcd000000cdcdcdULL, 0xb5b5000000b5b5b5ULL, - 0x1212000000121212ULL, 0x7e7e0000007e7e7eULL, 0xbbbb000000bbbbbbULL, - 0x2929000000292929ULL, 0x0f0f0000000f0f0fULL, 0xb8b8000000b8b8b8ULL, - 0x0707000000070707ULL, 0x0404000000040404ULL, 0x9b9b0000009b9b9bULL, - 0x9494000000949494ULL, 0x2121000000212121ULL, 0x6666000000666666ULL, - 0xe6e6000000e6e6e6ULL, 0xcece000000cececeULL, 0xeded000000edededULL, - 0xe7e7000000e7e7e7ULL, 0x3b3b0000003b3b3bULL, 0xfefe000000fefefeULL, - 0x7f7f0000007f7f7fULL, 0xc5c5000000c5c5c5ULL, 0xa4a4000000a4a4a4ULL, - 0x3737000000373737ULL, 0xb1b1000000b1b1b1ULL, 0x4c4c0000004c4c4cULL, - 0x9191000000919191ULL, 0x6e6e0000006e6e6eULL, 0x8d8d0000008d8d8dULL, - 0x7676000000767676ULL, 0x0303000000030303ULL, 0x2d2d0000002d2d2dULL, - 0xdede000000dededeULL, 0x9696000000969696ULL, 0x2626000000262626ULL, - 0x7d7d0000007d7d7dULL, 0xc6c6000000c6c6c6ULL, 0x5c5c0000005c5c5cULL, - 0xd3d3000000d3d3d3ULL, 0xf2f2000000f2f2f2ULL, 0x4f4f0000004f4f4fULL, - 0x1919000000191919ULL, 0x3f3f0000003f3f3fULL, 0xdcdc000000dcdcdcULL, - 0x7979000000797979ULL, 0x1d1d0000001d1d1dULL, 0x5252000000525252ULL, - 0xebeb000000ebebebULL, 0xf3f3000000f3f3f3ULL, 0x6d6d0000006d6d6dULL, - 0x5e5e0000005e5e5eULL, 0xfbfb000000fbfbfbULL, 0x6969000000696969ULL, - 0xb2b2000000b2b2b2ULL, 0xf0f0000000f0f0f0ULL, 0x3131000000313131ULL, - 0x0c0c0000000c0c0cULL, 0xd4d4000000d4d4d4ULL, 0xcfcf000000cfcfcfULL, - 0x8c8c0000008c8c8cULL, 0xe2e2000000e2e2e2ULL, 0x7575000000757575ULL, - 0xa9a9000000a9a9a9ULL, 0x4a4a0000004a4a4aULL, 0x5757000000575757ULL, - 0x8484000000848484ULL, 0x1111000000111111ULL, 0x4545000000454545ULL, - 0x1b1b0000001b1b1bULL, 0xf5f5000000f5f5f5ULL, 0xe4e4000000e4e4e4ULL, - 0x0e0e0000000e0e0eULL, 0x7373000000737373ULL, 0xaaaa000000aaaaaaULL, - 0xf1f1000000f1f1f1ULL, 0xdddd000000ddddddULL, 0x5959000000595959ULL, - 0x1414000000141414ULL, 0x6c6c0000006c6c6cULL, 0x9292000000929292ULL, - 0x5454000000545454ULL, 0xd0d0000000d0d0d0ULL, 0x7878000000787878ULL, - 0x7070000000707070ULL, 0xe3e3000000e3e3e3ULL, 0x4949000000494949ULL, - 0x8080000000808080ULL, 0x5050000000505050ULL, 0xa7a7000000a7a7a7ULL, - 0xf6f6000000f6f6f6ULL, 0x7777000000777777ULL, 0x9393000000939393ULL, - 0x8686000000868686ULL, 0x8383000000838383ULL, 0x2a2a0000002a2a2aULL, - 0xc7c7000000c7c7c7ULL, 0x5b5b0000005b5b5bULL, 0xe9e9000000e9e9e9ULL, - 0xeeee000000eeeeeeULL, 0x8f8f0000008f8f8fULL, 0x0101000000010101ULL, - 0x3d3d0000003d3d3dULL, + 0xe0e0000000e0e0e0, 0x0505000000050505, 0x5858000000585858, + 0xd9d9000000d9d9d9, 0x6767000000676767, 0x4e4e0000004e4e4e, + 0x8181000000818181, 0xcbcb000000cbcbcb, 0xc9c9000000c9c9c9, + 0x0b0b0000000b0b0b, 0xaeae000000aeaeae, 0x6a6a0000006a6a6a, + 0xd5d5000000d5d5d5, 0x1818000000181818, 0x5d5d0000005d5d5d, + 0x8282000000828282, 0x4646000000464646, 0xdfdf000000dfdfdf, + 0xd6d6000000d6d6d6, 0x2727000000272727, 0x8a8a0000008a8a8a, + 0x3232000000323232, 0x4b4b0000004b4b4b, 0x4242000000424242, + 0xdbdb000000dbdbdb, 0x1c1c0000001c1c1c, 0x9e9e0000009e9e9e, + 0x9c9c0000009c9c9c, 0x3a3a0000003a3a3a, 0xcaca000000cacaca, + 0x2525000000252525, 0x7b7b0000007b7b7b, 0x0d0d0000000d0d0d, + 0x7171000000717171, 0x5f5f0000005f5f5f, 0x1f1f0000001f1f1f, + 0xf8f8000000f8f8f8, 0xd7d7000000d7d7d7, 0x3e3e0000003e3e3e, + 0x9d9d0000009d9d9d, 0x7c7c0000007c7c7c, 0x6060000000606060, + 0xb9b9000000b9b9b9, 0xbebe000000bebebe, 0xbcbc000000bcbcbc, + 0x8b8b0000008b8b8b, 0x1616000000161616, 0x3434000000343434, + 0x4d4d0000004d4d4d, 0xc3c3000000c3c3c3, 0x7272000000727272, + 0x9595000000959595, 0xabab000000ababab, 0x8e8e0000008e8e8e, + 0xbaba000000bababa, 0x7a7a0000007a7a7a, 0xb3b3000000b3b3b3, + 0x0202000000020202, 0xb4b4000000b4b4b4, 0xadad000000adadad, + 0xa2a2000000a2a2a2, 0xacac000000acacac, 0xd8d8000000d8d8d8, + 0x9a9a0000009a9a9a, 0x1717000000171717, 0x1a1a0000001a1a1a, + 0x3535000000353535, 0xcccc000000cccccc, 0xf7f7000000f7f7f7, + 0x9999000000999999, 0x6161000000616161, 0x5a5a0000005a5a5a, + 0xe8e8000000e8e8e8, 0x2424000000242424, 0x5656000000565656, + 0x4040000000404040, 0xe1e1000000e1e1e1, 0x6363000000636363, + 0x0909000000090909, 0x3333000000333333, 0xbfbf000000bfbfbf, + 0x9898000000989898, 0x9797000000979797, 0x8585000000858585, + 0x6868000000686868, 0xfcfc000000fcfcfc, 0xecec000000ececec, + 0x0a0a0000000a0a0a, 0xdada000000dadada, 0x6f6f0000006f6f6f, + 0x5353000000535353, 0x6262000000626262, 0xa3a3000000a3a3a3, + 0x2e2e0000002e2e2e, 0x0808000000080808, 0xafaf000000afafaf, + 0x2828000000282828, 0xb0b0000000b0b0b0, 0x7474000000747474, + 0xc2c2000000c2c2c2, 0xbdbd000000bdbdbd, 0x3636000000363636, + 0x2222000000222222, 0x3838000000383838, 0x6464000000646464, + 0x1e1e0000001e1e1e, 0x3939000000393939, 0x2c2c0000002c2c2c, + 0xa6a6000000a6a6a6, 0x3030000000303030, 0xe5e5000000e5e5e5, + 0x4444000000444444, 0xfdfd000000fdfdfd, 0x8888000000888888, + 0x9f9f0000009f9f9f, 0x6565000000656565, 0x8787000000878787, + 0x6b6b0000006b6b6b, 0xf4f4000000f4f4f4, 0x2323000000232323, + 0x4848000000484848, 0x1010000000101010, 0xd1d1000000d1d1d1, + 0x5151000000515151, 0xc0c0000000c0c0c0, 0xf9f9000000f9f9f9, + 0xd2d2000000d2d2d2, 0xa0a0000000a0a0a0, 0x5555000000555555, + 0xa1a1000000a1a1a1, 0x4141000000414141, 0xfafa000000fafafa, + 0x4343000000434343, 0x1313000000131313, 0xc4c4000000c4c4c4, + 0x2f2f0000002f2f2f, 0xa8a8000000a8a8a8, 0xb6b6000000b6b6b6, + 0x3c3c0000003c3c3c, 0x2b2b0000002b2b2b, 0xc1c1000000c1c1c1, + 0xffff000000ffffff, 0xc8c8000000c8c8c8, 0xa5a5000000a5a5a5, + 0x2020000000202020, 0x8989000000898989, 0x0000000000000000, + 0x9090000000909090, 0x4747000000474747, 0xefef000000efefef, + 0xeaea000000eaeaea, 0xb7b7000000b7b7b7, 0x1515000000151515, + 0x0606000000060606, 0xcdcd000000cdcdcd, 0xb5b5000000b5b5b5, + 0x1212000000121212, 0x7e7e0000007e7e7e, 0xbbbb000000bbbbbb, + 0x2929000000292929, 0x0f0f0000000f0f0f, 0xb8b8000000b8b8b8, + 0x0707000000070707, 0x0404000000040404, 0x9b9b0000009b9b9b, + 0x9494000000949494, 0x2121000000212121, 0x6666000000666666, + 0xe6e6000000e6e6e6, 0xcece000000cecece, 0xeded000000ededed, + 0xe7e7000000e7e7e7, 0x3b3b0000003b3b3b, 0xfefe000000fefefe, + 0x7f7f0000007f7f7f, 0xc5c5000000c5c5c5, 0xa4a4000000a4a4a4, + 0x3737000000373737, 0xb1b1000000b1b1b1, 0x4c4c0000004c4c4c, + 0x9191000000919191, 0x6e6e0000006e6e6e, 0x8d8d0000008d8d8d, + 0x7676000000767676, 0x0303000000030303, 0x2d2d0000002d2d2d, + 0xdede000000dedede, 0x9696000000969696, 0x2626000000262626, + 0x7d7d0000007d7d7d, 0xc6c6000000c6c6c6, 0x5c5c0000005c5c5c, + 0xd3d3000000d3d3d3, 0xf2f2000000f2f2f2, 0x4f4f0000004f4f4f, + 0x1919000000191919, 0x3f3f0000003f3f3f, 0xdcdc000000dcdcdc, + 0x7979000000797979, 0x1d1d0000001d1d1d, 0x5252000000525252, + 0xebeb000000ebebeb, 0xf3f3000000f3f3f3, 0x6d6d0000006d6d6d, + 0x5e5e0000005e5e5e, 0xfbfb000000fbfbfb, 0x6969000000696969, + 0xb2b2000000b2b2b2, 0xf0f0000000f0f0f0, 0x3131000000313131, + 0x0c0c0000000c0c0c, 0xd4d4000000d4d4d4, 0xcfcf000000cfcfcf, + 0x8c8c0000008c8c8c, 0xe2e2000000e2e2e2, 0x7575000000757575, + 0xa9a9000000a9a9a9, 0x4a4a0000004a4a4a, 0x5757000000575757, + 0x8484000000848484, 0x1111000000111111, 0x4545000000454545, + 0x1b1b0000001b1b1b, 0xf5f5000000f5f5f5, 0xe4e4000000e4e4e4, + 0x0e0e0000000e0e0e, 0x7373000000737373, 0xaaaa000000aaaaaa, + 0xf1f1000000f1f1f1, 0xdddd000000dddddd, 0x5959000000595959, + 0x1414000000141414, 0x6c6c0000006c6c6c, 0x9292000000929292, + 0x5454000000545454, 0xd0d0000000d0d0d0, 0x7878000000787878, + 0x7070000000707070, 0xe3e3000000e3e3e3, 0x4949000000494949, + 0x8080000000808080, 0x5050000000505050, 0xa7a7000000a7a7a7, + 0xf6f6000000f6f6f6, 0x7777000000777777, 0x9393000000939393, + 0x8686000000868686, 0x8383000000838383, 0x2a2a0000002a2a2a, + 0xc7c7000000c7c7c7, 0x5b5b0000005b5b5b, 0xe9e9000000e9e9e9, + 0xeeee000000eeeeee, 0x8f8f0000008f8f8f, 0x0101000000010101, + 0x3d3d0000003d3d3d, }; const u64 camellia_sp03303033[256] = { - 0x0038380038003838ULL, 0x0041410041004141ULL, 0x0016160016001616ULL, - 0x0076760076007676ULL, 0x00d9d900d900d9d9ULL, 0x0093930093009393ULL, - 0x0060600060006060ULL, 0x00f2f200f200f2f2ULL, 0x0072720072007272ULL, - 0x00c2c200c200c2c2ULL, 0x00abab00ab00ababULL, 0x009a9a009a009a9aULL, - 0x0075750075007575ULL, 0x0006060006000606ULL, 0x0057570057005757ULL, - 0x00a0a000a000a0a0ULL, 0x0091910091009191ULL, 0x00f7f700f700f7f7ULL, - 0x00b5b500b500b5b5ULL, 0x00c9c900c900c9c9ULL, 0x00a2a200a200a2a2ULL, - 0x008c8c008c008c8cULL, 0x00d2d200d200d2d2ULL, 0x0090900090009090ULL, - 0x00f6f600f600f6f6ULL, 0x0007070007000707ULL, 0x00a7a700a700a7a7ULL, - 0x0027270027002727ULL, 0x008e8e008e008e8eULL, 0x00b2b200b200b2b2ULL, - 0x0049490049004949ULL, 0x00dede00de00dedeULL, 0x0043430043004343ULL, - 0x005c5c005c005c5cULL, 0x00d7d700d700d7d7ULL, 0x00c7c700c700c7c7ULL, - 0x003e3e003e003e3eULL, 0x00f5f500f500f5f5ULL, 0x008f8f008f008f8fULL, - 0x0067670067006767ULL, 0x001f1f001f001f1fULL, 0x0018180018001818ULL, - 0x006e6e006e006e6eULL, 0x00afaf00af00afafULL, 0x002f2f002f002f2fULL, - 0x00e2e200e200e2e2ULL, 0x0085850085008585ULL, 0x000d0d000d000d0dULL, - 0x0053530053005353ULL, 0x00f0f000f000f0f0ULL, 0x009c9c009c009c9cULL, - 0x0065650065006565ULL, 0x00eaea00ea00eaeaULL, 0x00a3a300a300a3a3ULL, - 0x00aeae00ae00aeaeULL, 0x009e9e009e009e9eULL, 0x00ecec00ec00ececULL, - 0x0080800080008080ULL, 0x002d2d002d002d2dULL, 0x006b6b006b006b6bULL, - 0x00a8a800a800a8a8ULL, 0x002b2b002b002b2bULL, 0x0036360036003636ULL, - 0x00a6a600a600a6a6ULL, 0x00c5c500c500c5c5ULL, 0x0086860086008686ULL, - 0x004d4d004d004d4dULL, 0x0033330033003333ULL, 0x00fdfd00fd00fdfdULL, - 0x0066660066006666ULL, 0x0058580058005858ULL, 0x0096960096009696ULL, - 0x003a3a003a003a3aULL, 0x0009090009000909ULL, 0x0095950095009595ULL, - 0x0010100010001010ULL, 0x0078780078007878ULL, 0x00d8d800d800d8d8ULL, - 0x0042420042004242ULL, 0x00cccc00cc00ccccULL, 0x00efef00ef00efefULL, - 0x0026260026002626ULL, 0x00e5e500e500e5e5ULL, 0x0061610061006161ULL, - 0x001a1a001a001a1aULL, 0x003f3f003f003f3fULL, 0x003b3b003b003b3bULL, - 0x0082820082008282ULL, 0x00b6b600b600b6b6ULL, 0x00dbdb00db00dbdbULL, - 0x00d4d400d400d4d4ULL, 0x0098980098009898ULL, 0x00e8e800e800e8e8ULL, - 0x008b8b008b008b8bULL, 0x0002020002000202ULL, 0x00ebeb00eb00ebebULL, - 0x000a0a000a000a0aULL, 0x002c2c002c002c2cULL, 0x001d1d001d001d1dULL, - 0x00b0b000b000b0b0ULL, 0x006f6f006f006f6fULL, 0x008d8d008d008d8dULL, - 0x0088880088008888ULL, 0x000e0e000e000e0eULL, 0x0019190019001919ULL, - 0x0087870087008787ULL, 0x004e4e004e004e4eULL, 0x000b0b000b000b0bULL, - 0x00a9a900a900a9a9ULL, 0x000c0c000c000c0cULL, 0x0079790079007979ULL, - 0x0011110011001111ULL, 0x007f7f007f007f7fULL, 0x0022220022002222ULL, - 0x00e7e700e700e7e7ULL, 0x0059590059005959ULL, 0x00e1e100e100e1e1ULL, - 0x00dada00da00dadaULL, 0x003d3d003d003d3dULL, 0x00c8c800c800c8c8ULL, - 0x0012120012001212ULL, 0x0004040004000404ULL, 0x0074740074007474ULL, - 0x0054540054005454ULL, 0x0030300030003030ULL, 0x007e7e007e007e7eULL, - 0x00b4b400b400b4b4ULL, 0x0028280028002828ULL, 0x0055550055005555ULL, - 0x0068680068006868ULL, 0x0050500050005050ULL, 0x00bebe00be00bebeULL, - 0x00d0d000d000d0d0ULL, 0x00c4c400c400c4c4ULL, 0x0031310031003131ULL, - 0x00cbcb00cb00cbcbULL, 0x002a2a002a002a2aULL, 0x00adad00ad00adadULL, - 0x000f0f000f000f0fULL, 0x00caca00ca00cacaULL, 0x0070700070007070ULL, - 0x00ffff00ff00ffffULL, 0x0032320032003232ULL, 0x0069690069006969ULL, - 0x0008080008000808ULL, 0x0062620062006262ULL, 0x0000000000000000ULL, - 0x0024240024002424ULL, 0x00d1d100d100d1d1ULL, 0x00fbfb00fb00fbfbULL, - 0x00baba00ba00babaULL, 0x00eded00ed00ededULL, 0x0045450045004545ULL, - 0x0081810081008181ULL, 0x0073730073007373ULL, 0x006d6d006d006d6dULL, - 0x0084840084008484ULL, 0x009f9f009f009f9fULL, 0x00eeee00ee00eeeeULL, - 0x004a4a004a004a4aULL, 0x00c3c300c300c3c3ULL, 0x002e2e002e002e2eULL, - 0x00c1c100c100c1c1ULL, 0x0001010001000101ULL, 0x00e6e600e600e6e6ULL, - 0x0025250025002525ULL, 0x0048480048004848ULL, 0x0099990099009999ULL, - 0x00b9b900b900b9b9ULL, 0x00b3b300b300b3b3ULL, 0x007b7b007b007b7bULL, - 0x00f9f900f900f9f9ULL, 0x00cece00ce00ceceULL, 0x00bfbf00bf00bfbfULL, - 0x00dfdf00df00dfdfULL, 0x0071710071007171ULL, 0x0029290029002929ULL, - 0x00cdcd00cd00cdcdULL, 0x006c6c006c006c6cULL, 0x0013130013001313ULL, - 0x0064640064006464ULL, 0x009b9b009b009b9bULL, 0x0063630063006363ULL, - 0x009d9d009d009d9dULL, 0x00c0c000c000c0c0ULL, 0x004b4b004b004b4bULL, - 0x00b7b700b700b7b7ULL, 0x00a5a500a500a5a5ULL, 0x0089890089008989ULL, - 0x005f5f005f005f5fULL, 0x00b1b100b100b1b1ULL, 0x0017170017001717ULL, - 0x00f4f400f400f4f4ULL, 0x00bcbc00bc00bcbcULL, 0x00d3d300d300d3d3ULL, - 0x0046460046004646ULL, 0x00cfcf00cf00cfcfULL, 0x0037370037003737ULL, - 0x005e5e005e005e5eULL, 0x0047470047004747ULL, 0x0094940094009494ULL, - 0x00fafa00fa00fafaULL, 0x00fcfc00fc00fcfcULL, 0x005b5b005b005b5bULL, - 0x0097970097009797ULL, 0x00fefe00fe00fefeULL, 0x005a5a005a005a5aULL, - 0x00acac00ac00acacULL, 0x003c3c003c003c3cULL, 0x004c4c004c004c4cULL, - 0x0003030003000303ULL, 0x0035350035003535ULL, 0x00f3f300f300f3f3ULL, - 0x0023230023002323ULL, 0x00b8b800b800b8b8ULL, 0x005d5d005d005d5dULL, - 0x006a6a006a006a6aULL, 0x0092920092009292ULL, 0x00d5d500d500d5d5ULL, - 0x0021210021002121ULL, 0x0044440044004444ULL, 0x0051510051005151ULL, - 0x00c6c600c600c6c6ULL, 0x007d7d007d007d7dULL, 0x0039390039003939ULL, - 0x0083830083008383ULL, 0x00dcdc00dc00dcdcULL, 0x00aaaa00aa00aaaaULL, - 0x007c7c007c007c7cULL, 0x0077770077007777ULL, 0x0056560056005656ULL, - 0x0005050005000505ULL, 0x001b1b001b001b1bULL, 0x00a4a400a400a4a4ULL, - 0x0015150015001515ULL, 0x0034340034003434ULL, 0x001e1e001e001e1eULL, - 0x001c1c001c001c1cULL, 0x00f8f800f800f8f8ULL, 0x0052520052005252ULL, - 0x0020200020002020ULL, 0x0014140014001414ULL, 0x00e9e900e900e9e9ULL, - 0x00bdbd00bd00bdbdULL, 0x00dddd00dd00ddddULL, 0x00e4e400e400e4e4ULL, - 0x00a1a100a100a1a1ULL, 0x00e0e000e000e0e0ULL, 0x008a8a008a008a8aULL, - 0x00f1f100f100f1f1ULL, 0x00d6d600d600d6d6ULL, 0x007a7a007a007a7aULL, - 0x00bbbb00bb00bbbbULL, 0x00e3e300e300e3e3ULL, 0x0040400040004040ULL, - 0x004f4f004f004f4fULL, + 0x0038380038003838, 0x0041410041004141, 0x0016160016001616, + 0x0076760076007676, 0x00d9d900d900d9d9, 0x0093930093009393, + 0x0060600060006060, 0x00f2f200f200f2f2, 0x0072720072007272, + 0x00c2c200c200c2c2, 0x00abab00ab00abab, 0x009a9a009a009a9a, + 0x0075750075007575, 0x0006060006000606, 0x0057570057005757, + 0x00a0a000a000a0a0, 0x0091910091009191, 0x00f7f700f700f7f7, + 0x00b5b500b500b5b5, 0x00c9c900c900c9c9, 0x00a2a200a200a2a2, + 0x008c8c008c008c8c, 0x00d2d200d200d2d2, 0x0090900090009090, + 0x00f6f600f600f6f6, 0x0007070007000707, 0x00a7a700a700a7a7, + 0x0027270027002727, 0x008e8e008e008e8e, 0x00b2b200b200b2b2, + 0x0049490049004949, 0x00dede00de00dede, 0x0043430043004343, + 0x005c5c005c005c5c, 0x00d7d700d700d7d7, 0x00c7c700c700c7c7, + 0x003e3e003e003e3e, 0x00f5f500f500f5f5, 0x008f8f008f008f8f, + 0x0067670067006767, 0x001f1f001f001f1f, 0x0018180018001818, + 0x006e6e006e006e6e, 0x00afaf00af00afaf, 0x002f2f002f002f2f, + 0x00e2e200e200e2e2, 0x0085850085008585, 0x000d0d000d000d0d, + 0x0053530053005353, 0x00f0f000f000f0f0, 0x009c9c009c009c9c, + 0x0065650065006565, 0x00eaea00ea00eaea, 0x00a3a300a300a3a3, + 0x00aeae00ae00aeae, 0x009e9e009e009e9e, 0x00ecec00ec00ecec, + 0x0080800080008080, 0x002d2d002d002d2d, 0x006b6b006b006b6b, + 0x00a8a800a800a8a8, 0x002b2b002b002b2b, 0x0036360036003636, + 0x00a6a600a600a6a6, 0x00c5c500c500c5c5, 0x0086860086008686, + 0x004d4d004d004d4d, 0x0033330033003333, 0x00fdfd00fd00fdfd, + 0x0066660066006666, 0x0058580058005858, 0x0096960096009696, + 0x003a3a003a003a3a, 0x0009090009000909, 0x0095950095009595, + 0x0010100010001010, 0x0078780078007878, 0x00d8d800d800d8d8, + 0x0042420042004242, 0x00cccc00cc00cccc, 0x00efef00ef00efef, + 0x0026260026002626, 0x00e5e500e500e5e5, 0x0061610061006161, + 0x001a1a001a001a1a, 0x003f3f003f003f3f, 0x003b3b003b003b3b, + 0x0082820082008282, 0x00b6b600b600b6b6, 0x00dbdb00db00dbdb, + 0x00d4d400d400d4d4, 0x0098980098009898, 0x00e8e800e800e8e8, + 0x008b8b008b008b8b, 0x0002020002000202, 0x00ebeb00eb00ebeb, + 0x000a0a000a000a0a, 0x002c2c002c002c2c, 0x001d1d001d001d1d, + 0x00b0b000b000b0b0, 0x006f6f006f006f6f, 0x008d8d008d008d8d, + 0x0088880088008888, 0x000e0e000e000e0e, 0x0019190019001919, + 0x0087870087008787, 0x004e4e004e004e4e, 0x000b0b000b000b0b, + 0x00a9a900a900a9a9, 0x000c0c000c000c0c, 0x0079790079007979, + 0x0011110011001111, 0x007f7f007f007f7f, 0x0022220022002222, + 0x00e7e700e700e7e7, 0x0059590059005959, 0x00e1e100e100e1e1, + 0x00dada00da00dada, 0x003d3d003d003d3d, 0x00c8c800c800c8c8, + 0x0012120012001212, 0x0004040004000404, 0x0074740074007474, + 0x0054540054005454, 0x0030300030003030, 0x007e7e007e007e7e, + 0x00b4b400b400b4b4, 0x0028280028002828, 0x0055550055005555, + 0x0068680068006868, 0x0050500050005050, 0x00bebe00be00bebe, + 0x00d0d000d000d0d0, 0x00c4c400c400c4c4, 0x0031310031003131, + 0x00cbcb00cb00cbcb, 0x002a2a002a002a2a, 0x00adad00ad00adad, + 0x000f0f000f000f0f, 0x00caca00ca00caca, 0x0070700070007070, + 0x00ffff00ff00ffff, 0x0032320032003232, 0x0069690069006969, + 0x0008080008000808, 0x0062620062006262, 0x0000000000000000, + 0x0024240024002424, 0x00d1d100d100d1d1, 0x00fbfb00fb00fbfb, + 0x00baba00ba00baba, 0x00eded00ed00eded, 0x0045450045004545, + 0x0081810081008181, 0x0073730073007373, 0x006d6d006d006d6d, + 0x0084840084008484, 0x009f9f009f009f9f, 0x00eeee00ee00eeee, + 0x004a4a004a004a4a, 0x00c3c300c300c3c3, 0x002e2e002e002e2e, + 0x00c1c100c100c1c1, 0x0001010001000101, 0x00e6e600e600e6e6, + 0x0025250025002525, 0x0048480048004848, 0x0099990099009999, + 0x00b9b900b900b9b9, 0x00b3b300b300b3b3, 0x007b7b007b007b7b, + 0x00f9f900f900f9f9, 0x00cece00ce00cece, 0x00bfbf00bf00bfbf, + 0x00dfdf00df00dfdf, 0x0071710071007171, 0x0029290029002929, + 0x00cdcd00cd00cdcd, 0x006c6c006c006c6c, 0x0013130013001313, + 0x0064640064006464, 0x009b9b009b009b9b, 0x0063630063006363, + 0x009d9d009d009d9d, 0x00c0c000c000c0c0, 0x004b4b004b004b4b, + 0x00b7b700b700b7b7, 0x00a5a500a500a5a5, 0x0089890089008989, + 0x005f5f005f005f5f, 0x00b1b100b100b1b1, 0x0017170017001717, + 0x00f4f400f400f4f4, 0x00bcbc00bc00bcbc, 0x00d3d300d300d3d3, + 0x0046460046004646, 0x00cfcf00cf00cfcf, 0x0037370037003737, + 0x005e5e005e005e5e, 0x0047470047004747, 0x0094940094009494, + 0x00fafa00fa00fafa, 0x00fcfc00fc00fcfc, 0x005b5b005b005b5b, + 0x0097970097009797, 0x00fefe00fe00fefe, 0x005a5a005a005a5a, + 0x00acac00ac00acac, 0x003c3c003c003c3c, 0x004c4c004c004c4c, + 0x0003030003000303, 0x0035350035003535, 0x00f3f300f300f3f3, + 0x0023230023002323, 0x00b8b800b800b8b8, 0x005d5d005d005d5d, + 0x006a6a006a006a6a, 0x0092920092009292, 0x00d5d500d500d5d5, + 0x0021210021002121, 0x0044440044004444, 0x0051510051005151, + 0x00c6c600c600c6c6, 0x007d7d007d007d7d, 0x0039390039003939, + 0x0083830083008383, 0x00dcdc00dc00dcdc, 0x00aaaa00aa00aaaa, + 0x007c7c007c007c7c, 0x0077770077007777, 0x0056560056005656, + 0x0005050005000505, 0x001b1b001b001b1b, 0x00a4a400a400a4a4, + 0x0015150015001515, 0x0034340034003434, 0x001e1e001e001e1e, + 0x001c1c001c001c1c, 0x00f8f800f800f8f8, 0x0052520052005252, + 0x0020200020002020, 0x0014140014001414, 0x00e9e900e900e9e9, + 0x00bdbd00bd00bdbd, 0x00dddd00dd00dddd, 0x00e4e400e400e4e4, + 0x00a1a100a100a1a1, 0x00e0e000e000e0e0, 0x008a8a008a008a8a, + 0x00f1f100f100f1f1, 0x00d6d600d600d6d6, 0x007a7a007a007a7a, + 0x00bbbb00bb00bbbb, 0x00e3e300e300e3e3, 0x0040400040004040, + 0x004f4f004f004f4f, }; const u64 camellia_sp00444404[256] = { - 0x0000707070700070ULL, 0x00002c2c2c2c002cULL, 0x0000b3b3b3b300b3ULL, - 0x0000c0c0c0c000c0ULL, 0x0000e4e4e4e400e4ULL, 0x0000575757570057ULL, - 0x0000eaeaeaea00eaULL, 0x0000aeaeaeae00aeULL, 0x0000232323230023ULL, - 0x00006b6b6b6b006bULL, 0x0000454545450045ULL, 0x0000a5a5a5a500a5ULL, - 0x0000edededed00edULL, 0x00004f4f4f4f004fULL, 0x00001d1d1d1d001dULL, - 0x0000929292920092ULL, 0x0000868686860086ULL, 0x0000afafafaf00afULL, - 0x00007c7c7c7c007cULL, 0x00001f1f1f1f001fULL, 0x00003e3e3e3e003eULL, - 0x0000dcdcdcdc00dcULL, 0x00005e5e5e5e005eULL, 0x00000b0b0b0b000bULL, - 0x0000a6a6a6a600a6ULL, 0x0000393939390039ULL, 0x0000d5d5d5d500d5ULL, - 0x00005d5d5d5d005dULL, 0x0000d9d9d9d900d9ULL, 0x00005a5a5a5a005aULL, - 0x0000515151510051ULL, 0x00006c6c6c6c006cULL, 0x00008b8b8b8b008bULL, - 0x00009a9a9a9a009aULL, 0x0000fbfbfbfb00fbULL, 0x0000b0b0b0b000b0ULL, - 0x0000747474740074ULL, 0x00002b2b2b2b002bULL, 0x0000f0f0f0f000f0ULL, - 0x0000848484840084ULL, 0x0000dfdfdfdf00dfULL, 0x0000cbcbcbcb00cbULL, - 0x0000343434340034ULL, 0x0000767676760076ULL, 0x00006d6d6d6d006dULL, - 0x0000a9a9a9a900a9ULL, 0x0000d1d1d1d100d1ULL, 0x0000040404040004ULL, - 0x0000141414140014ULL, 0x00003a3a3a3a003aULL, 0x0000dededede00deULL, - 0x0000111111110011ULL, 0x0000323232320032ULL, 0x00009c9c9c9c009cULL, - 0x0000535353530053ULL, 0x0000f2f2f2f200f2ULL, 0x0000fefefefe00feULL, - 0x0000cfcfcfcf00cfULL, 0x0000c3c3c3c300c3ULL, 0x00007a7a7a7a007aULL, - 0x0000242424240024ULL, 0x0000e8e8e8e800e8ULL, 0x0000606060600060ULL, - 0x0000696969690069ULL, 0x0000aaaaaaaa00aaULL, 0x0000a0a0a0a000a0ULL, - 0x0000a1a1a1a100a1ULL, 0x0000626262620062ULL, 0x0000545454540054ULL, - 0x00001e1e1e1e001eULL, 0x0000e0e0e0e000e0ULL, 0x0000646464640064ULL, - 0x0000101010100010ULL, 0x0000000000000000ULL, 0x0000a3a3a3a300a3ULL, - 0x0000757575750075ULL, 0x00008a8a8a8a008aULL, 0x0000e6e6e6e600e6ULL, - 0x0000090909090009ULL, 0x0000dddddddd00ddULL, 0x0000878787870087ULL, - 0x0000838383830083ULL, 0x0000cdcdcdcd00cdULL, 0x0000909090900090ULL, - 0x0000737373730073ULL, 0x0000f6f6f6f600f6ULL, 0x00009d9d9d9d009dULL, - 0x0000bfbfbfbf00bfULL, 0x0000525252520052ULL, 0x0000d8d8d8d800d8ULL, - 0x0000c8c8c8c800c8ULL, 0x0000c6c6c6c600c6ULL, 0x0000818181810081ULL, - 0x00006f6f6f6f006fULL, 0x0000131313130013ULL, 0x0000636363630063ULL, - 0x0000e9e9e9e900e9ULL, 0x0000a7a7a7a700a7ULL, 0x00009f9f9f9f009fULL, - 0x0000bcbcbcbc00bcULL, 0x0000292929290029ULL, 0x0000f9f9f9f900f9ULL, - 0x00002f2f2f2f002fULL, 0x0000b4b4b4b400b4ULL, 0x0000787878780078ULL, - 0x0000060606060006ULL, 0x0000e7e7e7e700e7ULL, 0x0000717171710071ULL, - 0x0000d4d4d4d400d4ULL, 0x0000abababab00abULL, 0x0000888888880088ULL, - 0x00008d8d8d8d008dULL, 0x0000727272720072ULL, 0x0000b9b9b9b900b9ULL, - 0x0000f8f8f8f800f8ULL, 0x0000acacacac00acULL, 0x0000363636360036ULL, - 0x00002a2a2a2a002aULL, 0x00003c3c3c3c003cULL, 0x0000f1f1f1f100f1ULL, - 0x0000404040400040ULL, 0x0000d3d3d3d300d3ULL, 0x0000bbbbbbbb00bbULL, - 0x0000434343430043ULL, 0x0000151515150015ULL, 0x0000adadadad00adULL, - 0x0000777777770077ULL, 0x0000808080800080ULL, 0x0000828282820082ULL, - 0x0000ecececec00ecULL, 0x0000272727270027ULL, 0x0000e5e5e5e500e5ULL, - 0x0000858585850085ULL, 0x0000353535350035ULL, 0x00000c0c0c0c000cULL, - 0x0000414141410041ULL, 0x0000efefefef00efULL, 0x0000939393930093ULL, - 0x0000191919190019ULL, 0x0000212121210021ULL, 0x00000e0e0e0e000eULL, - 0x00004e4e4e4e004eULL, 0x0000656565650065ULL, 0x0000bdbdbdbd00bdULL, - 0x0000b8b8b8b800b8ULL, 0x00008f8f8f8f008fULL, 0x0000ebebebeb00ebULL, - 0x0000cececece00ceULL, 0x0000303030300030ULL, 0x00005f5f5f5f005fULL, - 0x0000c5c5c5c500c5ULL, 0x00001a1a1a1a001aULL, 0x0000e1e1e1e100e1ULL, - 0x0000cacacaca00caULL, 0x0000474747470047ULL, 0x00003d3d3d3d003dULL, - 0x0000010101010001ULL, 0x0000d6d6d6d600d6ULL, 0x0000565656560056ULL, - 0x00004d4d4d4d004dULL, 0x00000d0d0d0d000dULL, 0x0000666666660066ULL, - 0x0000cccccccc00ccULL, 0x00002d2d2d2d002dULL, 0x0000121212120012ULL, - 0x0000202020200020ULL, 0x0000b1b1b1b100b1ULL, 0x0000999999990099ULL, - 0x00004c4c4c4c004cULL, 0x0000c2c2c2c200c2ULL, 0x00007e7e7e7e007eULL, - 0x0000050505050005ULL, 0x0000b7b7b7b700b7ULL, 0x0000313131310031ULL, - 0x0000171717170017ULL, 0x0000d7d7d7d700d7ULL, 0x0000585858580058ULL, - 0x0000616161610061ULL, 0x00001b1b1b1b001bULL, 0x00001c1c1c1c001cULL, - 0x00000f0f0f0f000fULL, 0x0000161616160016ULL, 0x0000181818180018ULL, - 0x0000222222220022ULL, 0x0000444444440044ULL, 0x0000b2b2b2b200b2ULL, - 0x0000b5b5b5b500b5ULL, 0x0000919191910091ULL, 0x0000080808080008ULL, - 0x0000a8a8a8a800a8ULL, 0x0000fcfcfcfc00fcULL, 0x0000505050500050ULL, - 0x0000d0d0d0d000d0ULL, 0x00007d7d7d7d007dULL, 0x0000898989890089ULL, - 0x0000979797970097ULL, 0x00005b5b5b5b005bULL, 0x0000959595950095ULL, - 0x0000ffffffff00ffULL, 0x0000d2d2d2d200d2ULL, 0x0000c4c4c4c400c4ULL, - 0x0000484848480048ULL, 0x0000f7f7f7f700f7ULL, 0x0000dbdbdbdb00dbULL, - 0x0000030303030003ULL, 0x0000dadadada00daULL, 0x00003f3f3f3f003fULL, - 0x0000949494940094ULL, 0x00005c5c5c5c005cULL, 0x0000020202020002ULL, - 0x00004a4a4a4a004aULL, 0x0000333333330033ULL, 0x0000676767670067ULL, - 0x0000f3f3f3f300f3ULL, 0x00007f7f7f7f007fULL, 0x0000e2e2e2e200e2ULL, - 0x00009b9b9b9b009bULL, 0x0000262626260026ULL, 0x0000373737370037ULL, - 0x00003b3b3b3b003bULL, 0x0000969696960096ULL, 0x00004b4b4b4b004bULL, - 0x0000bebebebe00beULL, 0x00002e2e2e2e002eULL, 0x0000797979790079ULL, - 0x00008c8c8c8c008cULL, 0x00006e6e6e6e006eULL, 0x00008e8e8e8e008eULL, - 0x0000f5f5f5f500f5ULL, 0x0000b6b6b6b600b6ULL, 0x0000fdfdfdfd00fdULL, - 0x0000595959590059ULL, 0x0000989898980098ULL, 0x00006a6a6a6a006aULL, - 0x0000464646460046ULL, 0x0000babababa00baULL, 0x0000252525250025ULL, - 0x0000424242420042ULL, 0x0000a2a2a2a200a2ULL, 0x0000fafafafa00faULL, - 0x0000070707070007ULL, 0x0000555555550055ULL, 0x0000eeeeeeee00eeULL, - 0x00000a0a0a0a000aULL, 0x0000494949490049ULL, 0x0000686868680068ULL, - 0x0000383838380038ULL, 0x0000a4a4a4a400a4ULL, 0x0000282828280028ULL, - 0x00007b7b7b7b007bULL, 0x0000c9c9c9c900c9ULL, 0x0000c1c1c1c100c1ULL, - 0x0000e3e3e3e300e3ULL, 0x0000f4f4f4f400f4ULL, 0x0000c7c7c7c700c7ULL, - 0x00009e9e9e9e009eULL, + 0x0000707070700070, 0x00002c2c2c2c002c, 0x0000b3b3b3b300b3, + 0x0000c0c0c0c000c0, 0x0000e4e4e4e400e4, 0x0000575757570057, + 0x0000eaeaeaea00ea, 0x0000aeaeaeae00ae, 0x0000232323230023, + 0x00006b6b6b6b006b, 0x0000454545450045, 0x0000a5a5a5a500a5, + 0x0000edededed00ed, 0x00004f4f4f4f004f, 0x00001d1d1d1d001d, + 0x0000929292920092, 0x0000868686860086, 0x0000afafafaf00af, + 0x00007c7c7c7c007c, 0x00001f1f1f1f001f, 0x00003e3e3e3e003e, + 0x0000dcdcdcdc00dc, 0x00005e5e5e5e005e, 0x00000b0b0b0b000b, + 0x0000a6a6a6a600a6, 0x0000393939390039, 0x0000d5d5d5d500d5, + 0x00005d5d5d5d005d, 0x0000d9d9d9d900d9, 0x00005a5a5a5a005a, + 0x0000515151510051, 0x00006c6c6c6c006c, 0x00008b8b8b8b008b, + 0x00009a9a9a9a009a, 0x0000fbfbfbfb00fb, 0x0000b0b0b0b000b0, + 0x0000747474740074, 0x00002b2b2b2b002b, 0x0000f0f0f0f000f0, + 0x0000848484840084, 0x0000dfdfdfdf00df, 0x0000cbcbcbcb00cb, + 0x0000343434340034, 0x0000767676760076, 0x00006d6d6d6d006d, + 0x0000a9a9a9a900a9, 0x0000d1d1d1d100d1, 0x0000040404040004, + 0x0000141414140014, 0x00003a3a3a3a003a, 0x0000dededede00de, + 0x0000111111110011, 0x0000323232320032, 0x00009c9c9c9c009c, + 0x0000535353530053, 0x0000f2f2f2f200f2, 0x0000fefefefe00fe, + 0x0000cfcfcfcf00cf, 0x0000c3c3c3c300c3, 0x00007a7a7a7a007a, + 0x0000242424240024, 0x0000e8e8e8e800e8, 0x0000606060600060, + 0x0000696969690069, 0x0000aaaaaaaa00aa, 0x0000a0a0a0a000a0, + 0x0000a1a1a1a100a1, 0x0000626262620062, 0x0000545454540054, + 0x00001e1e1e1e001e, 0x0000e0e0e0e000e0, 0x0000646464640064, + 0x0000101010100010, 0x0000000000000000, 0x0000a3a3a3a300a3, + 0x0000757575750075, 0x00008a8a8a8a008a, 0x0000e6e6e6e600e6, + 0x0000090909090009, 0x0000dddddddd00dd, 0x0000878787870087, + 0x0000838383830083, 0x0000cdcdcdcd00cd, 0x0000909090900090, + 0x0000737373730073, 0x0000f6f6f6f600f6, 0x00009d9d9d9d009d, + 0x0000bfbfbfbf00bf, 0x0000525252520052, 0x0000d8d8d8d800d8, + 0x0000c8c8c8c800c8, 0x0000c6c6c6c600c6, 0x0000818181810081, + 0x00006f6f6f6f006f, 0x0000131313130013, 0x0000636363630063, + 0x0000e9e9e9e900e9, 0x0000a7a7a7a700a7, 0x00009f9f9f9f009f, + 0x0000bcbcbcbc00bc, 0x0000292929290029, 0x0000f9f9f9f900f9, + 0x00002f2f2f2f002f, 0x0000b4b4b4b400b4, 0x0000787878780078, + 0x0000060606060006, 0x0000e7e7e7e700e7, 0x0000717171710071, + 0x0000d4d4d4d400d4, 0x0000abababab00ab, 0x0000888888880088, + 0x00008d8d8d8d008d, 0x0000727272720072, 0x0000b9b9b9b900b9, + 0x0000f8f8f8f800f8, 0x0000acacacac00ac, 0x0000363636360036, + 0x00002a2a2a2a002a, 0x00003c3c3c3c003c, 0x0000f1f1f1f100f1, + 0x0000404040400040, 0x0000d3d3d3d300d3, 0x0000bbbbbbbb00bb, + 0x0000434343430043, 0x0000151515150015, 0x0000adadadad00ad, + 0x0000777777770077, 0x0000808080800080, 0x0000828282820082, + 0x0000ecececec00ec, 0x0000272727270027, 0x0000e5e5e5e500e5, + 0x0000858585850085, 0x0000353535350035, 0x00000c0c0c0c000c, + 0x0000414141410041, 0x0000efefefef00ef, 0x0000939393930093, + 0x0000191919190019, 0x0000212121210021, 0x00000e0e0e0e000e, + 0x00004e4e4e4e004e, 0x0000656565650065, 0x0000bdbdbdbd00bd, + 0x0000b8b8b8b800b8, 0x00008f8f8f8f008f, 0x0000ebebebeb00eb, + 0x0000cececece00ce, 0x0000303030300030, 0x00005f5f5f5f005f, + 0x0000c5c5c5c500c5, 0x00001a1a1a1a001a, 0x0000e1e1e1e100e1, + 0x0000cacacaca00ca, 0x0000474747470047, 0x00003d3d3d3d003d, + 0x0000010101010001, 0x0000d6d6d6d600d6, 0x0000565656560056, + 0x00004d4d4d4d004d, 0x00000d0d0d0d000d, 0x0000666666660066, + 0x0000cccccccc00cc, 0x00002d2d2d2d002d, 0x0000121212120012, + 0x0000202020200020, 0x0000b1b1b1b100b1, 0x0000999999990099, + 0x00004c4c4c4c004c, 0x0000c2c2c2c200c2, 0x00007e7e7e7e007e, + 0x0000050505050005, 0x0000b7b7b7b700b7, 0x0000313131310031, + 0x0000171717170017, 0x0000d7d7d7d700d7, 0x0000585858580058, + 0x0000616161610061, 0x00001b1b1b1b001b, 0x00001c1c1c1c001c, + 0x00000f0f0f0f000f, 0x0000161616160016, 0x0000181818180018, + 0x0000222222220022, 0x0000444444440044, 0x0000b2b2b2b200b2, + 0x0000b5b5b5b500b5, 0x0000919191910091, 0x0000080808080008, + 0x0000a8a8a8a800a8, 0x0000fcfcfcfc00fc, 0x0000505050500050, + 0x0000d0d0d0d000d0, 0x00007d7d7d7d007d, 0x0000898989890089, + 0x0000979797970097, 0x00005b5b5b5b005b, 0x0000959595950095, + 0x0000ffffffff00ff, 0x0000d2d2d2d200d2, 0x0000c4c4c4c400c4, + 0x0000484848480048, 0x0000f7f7f7f700f7, 0x0000dbdbdbdb00db, + 0x0000030303030003, 0x0000dadadada00da, 0x00003f3f3f3f003f, + 0x0000949494940094, 0x00005c5c5c5c005c, 0x0000020202020002, + 0x00004a4a4a4a004a, 0x0000333333330033, 0x0000676767670067, + 0x0000f3f3f3f300f3, 0x00007f7f7f7f007f, 0x0000e2e2e2e200e2, + 0x00009b9b9b9b009b, 0x0000262626260026, 0x0000373737370037, + 0x00003b3b3b3b003b, 0x0000969696960096, 0x00004b4b4b4b004b, + 0x0000bebebebe00be, 0x00002e2e2e2e002e, 0x0000797979790079, + 0x00008c8c8c8c008c, 0x00006e6e6e6e006e, 0x00008e8e8e8e008e, + 0x0000f5f5f5f500f5, 0x0000b6b6b6b600b6, 0x0000fdfdfdfd00fd, + 0x0000595959590059, 0x0000989898980098, 0x00006a6a6a6a006a, + 0x0000464646460046, 0x0000babababa00ba, 0x0000252525250025, + 0x0000424242420042, 0x0000a2a2a2a200a2, 0x0000fafafafa00fa, + 0x0000070707070007, 0x0000555555550055, 0x0000eeeeeeee00ee, + 0x00000a0a0a0a000a, 0x0000494949490049, 0x0000686868680068, + 0x0000383838380038, 0x0000a4a4a4a400a4, 0x0000282828280028, + 0x00007b7b7b7b007b, 0x0000c9c9c9c900c9, 0x0000c1c1c1c100c1, + 0x0000e3e3e3e300e3, 0x0000f4f4f4f400f4, 0x0000c7c7c7c700c7, + 0x00009e9e9e9e009e, }; const u64 camellia_sp02220222[256] = { - 0x00e0e0e000e0e0e0ULL, 0x0005050500050505ULL, 0x0058585800585858ULL, - 0x00d9d9d900d9d9d9ULL, 0x0067676700676767ULL, 0x004e4e4e004e4e4eULL, - 0x0081818100818181ULL, 0x00cbcbcb00cbcbcbULL, 0x00c9c9c900c9c9c9ULL, - 0x000b0b0b000b0b0bULL, 0x00aeaeae00aeaeaeULL, 0x006a6a6a006a6a6aULL, - 0x00d5d5d500d5d5d5ULL, 0x0018181800181818ULL, 0x005d5d5d005d5d5dULL, - 0x0082828200828282ULL, 0x0046464600464646ULL, 0x00dfdfdf00dfdfdfULL, - 0x00d6d6d600d6d6d6ULL, 0x0027272700272727ULL, 0x008a8a8a008a8a8aULL, - 0x0032323200323232ULL, 0x004b4b4b004b4b4bULL, 0x0042424200424242ULL, - 0x00dbdbdb00dbdbdbULL, 0x001c1c1c001c1c1cULL, 0x009e9e9e009e9e9eULL, - 0x009c9c9c009c9c9cULL, 0x003a3a3a003a3a3aULL, 0x00cacaca00cacacaULL, - 0x0025252500252525ULL, 0x007b7b7b007b7b7bULL, 0x000d0d0d000d0d0dULL, - 0x0071717100717171ULL, 0x005f5f5f005f5f5fULL, 0x001f1f1f001f1f1fULL, - 0x00f8f8f800f8f8f8ULL, 0x00d7d7d700d7d7d7ULL, 0x003e3e3e003e3e3eULL, - 0x009d9d9d009d9d9dULL, 0x007c7c7c007c7c7cULL, 0x0060606000606060ULL, - 0x00b9b9b900b9b9b9ULL, 0x00bebebe00bebebeULL, 0x00bcbcbc00bcbcbcULL, - 0x008b8b8b008b8b8bULL, 0x0016161600161616ULL, 0x0034343400343434ULL, - 0x004d4d4d004d4d4dULL, 0x00c3c3c300c3c3c3ULL, 0x0072727200727272ULL, - 0x0095959500959595ULL, 0x00ababab00abababULL, 0x008e8e8e008e8e8eULL, - 0x00bababa00bababaULL, 0x007a7a7a007a7a7aULL, 0x00b3b3b300b3b3b3ULL, - 0x0002020200020202ULL, 0x00b4b4b400b4b4b4ULL, 0x00adadad00adadadULL, - 0x00a2a2a200a2a2a2ULL, 0x00acacac00acacacULL, 0x00d8d8d800d8d8d8ULL, - 0x009a9a9a009a9a9aULL, 0x0017171700171717ULL, 0x001a1a1a001a1a1aULL, - 0x0035353500353535ULL, 0x00cccccc00ccccccULL, 0x00f7f7f700f7f7f7ULL, - 0x0099999900999999ULL, 0x0061616100616161ULL, 0x005a5a5a005a5a5aULL, - 0x00e8e8e800e8e8e8ULL, 0x0024242400242424ULL, 0x0056565600565656ULL, - 0x0040404000404040ULL, 0x00e1e1e100e1e1e1ULL, 0x0063636300636363ULL, - 0x0009090900090909ULL, 0x0033333300333333ULL, 0x00bfbfbf00bfbfbfULL, - 0x0098989800989898ULL, 0x0097979700979797ULL, 0x0085858500858585ULL, - 0x0068686800686868ULL, 0x00fcfcfc00fcfcfcULL, 0x00ececec00ecececULL, - 0x000a0a0a000a0a0aULL, 0x00dadada00dadadaULL, 0x006f6f6f006f6f6fULL, - 0x0053535300535353ULL, 0x0062626200626262ULL, 0x00a3a3a300a3a3a3ULL, - 0x002e2e2e002e2e2eULL, 0x0008080800080808ULL, 0x00afafaf00afafafULL, - 0x0028282800282828ULL, 0x00b0b0b000b0b0b0ULL, 0x0074747400747474ULL, - 0x00c2c2c200c2c2c2ULL, 0x00bdbdbd00bdbdbdULL, 0x0036363600363636ULL, - 0x0022222200222222ULL, 0x0038383800383838ULL, 0x0064646400646464ULL, - 0x001e1e1e001e1e1eULL, 0x0039393900393939ULL, 0x002c2c2c002c2c2cULL, - 0x00a6a6a600a6a6a6ULL, 0x0030303000303030ULL, 0x00e5e5e500e5e5e5ULL, - 0x0044444400444444ULL, 0x00fdfdfd00fdfdfdULL, 0x0088888800888888ULL, - 0x009f9f9f009f9f9fULL, 0x0065656500656565ULL, 0x0087878700878787ULL, - 0x006b6b6b006b6b6bULL, 0x00f4f4f400f4f4f4ULL, 0x0023232300232323ULL, - 0x0048484800484848ULL, 0x0010101000101010ULL, 0x00d1d1d100d1d1d1ULL, - 0x0051515100515151ULL, 0x00c0c0c000c0c0c0ULL, 0x00f9f9f900f9f9f9ULL, - 0x00d2d2d200d2d2d2ULL, 0x00a0a0a000a0a0a0ULL, 0x0055555500555555ULL, - 0x00a1a1a100a1a1a1ULL, 0x0041414100414141ULL, 0x00fafafa00fafafaULL, - 0x0043434300434343ULL, 0x0013131300131313ULL, 0x00c4c4c400c4c4c4ULL, - 0x002f2f2f002f2f2fULL, 0x00a8a8a800a8a8a8ULL, 0x00b6b6b600b6b6b6ULL, - 0x003c3c3c003c3c3cULL, 0x002b2b2b002b2b2bULL, 0x00c1c1c100c1c1c1ULL, - 0x00ffffff00ffffffULL, 0x00c8c8c800c8c8c8ULL, 0x00a5a5a500a5a5a5ULL, - 0x0020202000202020ULL, 0x0089898900898989ULL, 0x0000000000000000ULL, - 0x0090909000909090ULL, 0x0047474700474747ULL, 0x00efefef00efefefULL, - 0x00eaeaea00eaeaeaULL, 0x00b7b7b700b7b7b7ULL, 0x0015151500151515ULL, - 0x0006060600060606ULL, 0x00cdcdcd00cdcdcdULL, 0x00b5b5b500b5b5b5ULL, - 0x0012121200121212ULL, 0x007e7e7e007e7e7eULL, 0x00bbbbbb00bbbbbbULL, - 0x0029292900292929ULL, 0x000f0f0f000f0f0fULL, 0x00b8b8b800b8b8b8ULL, - 0x0007070700070707ULL, 0x0004040400040404ULL, 0x009b9b9b009b9b9bULL, - 0x0094949400949494ULL, 0x0021212100212121ULL, 0x0066666600666666ULL, - 0x00e6e6e600e6e6e6ULL, 0x00cecece00cececeULL, 0x00ededed00edededULL, - 0x00e7e7e700e7e7e7ULL, 0x003b3b3b003b3b3bULL, 0x00fefefe00fefefeULL, - 0x007f7f7f007f7f7fULL, 0x00c5c5c500c5c5c5ULL, 0x00a4a4a400a4a4a4ULL, - 0x0037373700373737ULL, 0x00b1b1b100b1b1b1ULL, 0x004c4c4c004c4c4cULL, - 0x0091919100919191ULL, 0x006e6e6e006e6e6eULL, 0x008d8d8d008d8d8dULL, - 0x0076767600767676ULL, 0x0003030300030303ULL, 0x002d2d2d002d2d2dULL, - 0x00dedede00dededeULL, 0x0096969600969696ULL, 0x0026262600262626ULL, - 0x007d7d7d007d7d7dULL, 0x00c6c6c600c6c6c6ULL, 0x005c5c5c005c5c5cULL, - 0x00d3d3d300d3d3d3ULL, 0x00f2f2f200f2f2f2ULL, 0x004f4f4f004f4f4fULL, - 0x0019191900191919ULL, 0x003f3f3f003f3f3fULL, 0x00dcdcdc00dcdcdcULL, - 0x0079797900797979ULL, 0x001d1d1d001d1d1dULL, 0x0052525200525252ULL, - 0x00ebebeb00ebebebULL, 0x00f3f3f300f3f3f3ULL, 0x006d6d6d006d6d6dULL, - 0x005e5e5e005e5e5eULL, 0x00fbfbfb00fbfbfbULL, 0x0069696900696969ULL, - 0x00b2b2b200b2b2b2ULL, 0x00f0f0f000f0f0f0ULL, 0x0031313100313131ULL, - 0x000c0c0c000c0c0cULL, 0x00d4d4d400d4d4d4ULL, 0x00cfcfcf00cfcfcfULL, - 0x008c8c8c008c8c8cULL, 0x00e2e2e200e2e2e2ULL, 0x0075757500757575ULL, - 0x00a9a9a900a9a9a9ULL, 0x004a4a4a004a4a4aULL, 0x0057575700575757ULL, - 0x0084848400848484ULL, 0x0011111100111111ULL, 0x0045454500454545ULL, - 0x001b1b1b001b1b1bULL, 0x00f5f5f500f5f5f5ULL, 0x00e4e4e400e4e4e4ULL, - 0x000e0e0e000e0e0eULL, 0x0073737300737373ULL, 0x00aaaaaa00aaaaaaULL, - 0x00f1f1f100f1f1f1ULL, 0x00dddddd00ddddddULL, 0x0059595900595959ULL, - 0x0014141400141414ULL, 0x006c6c6c006c6c6cULL, 0x0092929200929292ULL, - 0x0054545400545454ULL, 0x00d0d0d000d0d0d0ULL, 0x0078787800787878ULL, - 0x0070707000707070ULL, 0x00e3e3e300e3e3e3ULL, 0x0049494900494949ULL, - 0x0080808000808080ULL, 0x0050505000505050ULL, 0x00a7a7a700a7a7a7ULL, - 0x00f6f6f600f6f6f6ULL, 0x0077777700777777ULL, 0x0093939300939393ULL, - 0x0086868600868686ULL, 0x0083838300838383ULL, 0x002a2a2a002a2a2aULL, - 0x00c7c7c700c7c7c7ULL, 0x005b5b5b005b5b5bULL, 0x00e9e9e900e9e9e9ULL, - 0x00eeeeee00eeeeeeULL, 0x008f8f8f008f8f8fULL, 0x0001010100010101ULL, - 0x003d3d3d003d3d3dULL, + 0x00e0e0e000e0e0e0, 0x0005050500050505, 0x0058585800585858, + 0x00d9d9d900d9d9d9, 0x0067676700676767, 0x004e4e4e004e4e4e, + 0x0081818100818181, 0x00cbcbcb00cbcbcb, 0x00c9c9c900c9c9c9, + 0x000b0b0b000b0b0b, 0x00aeaeae00aeaeae, 0x006a6a6a006a6a6a, + 0x00d5d5d500d5d5d5, 0x0018181800181818, 0x005d5d5d005d5d5d, + 0x0082828200828282, 0x0046464600464646, 0x00dfdfdf00dfdfdf, + 0x00d6d6d600d6d6d6, 0x0027272700272727, 0x008a8a8a008a8a8a, + 0x0032323200323232, 0x004b4b4b004b4b4b, 0x0042424200424242, + 0x00dbdbdb00dbdbdb, 0x001c1c1c001c1c1c, 0x009e9e9e009e9e9e, + 0x009c9c9c009c9c9c, 0x003a3a3a003a3a3a, 0x00cacaca00cacaca, + 0x0025252500252525, 0x007b7b7b007b7b7b, 0x000d0d0d000d0d0d, + 0x0071717100717171, 0x005f5f5f005f5f5f, 0x001f1f1f001f1f1f, + 0x00f8f8f800f8f8f8, 0x00d7d7d700d7d7d7, 0x003e3e3e003e3e3e, + 0x009d9d9d009d9d9d, 0x007c7c7c007c7c7c, 0x0060606000606060, + 0x00b9b9b900b9b9b9, 0x00bebebe00bebebe, 0x00bcbcbc00bcbcbc, + 0x008b8b8b008b8b8b, 0x0016161600161616, 0x0034343400343434, + 0x004d4d4d004d4d4d, 0x00c3c3c300c3c3c3, 0x0072727200727272, + 0x0095959500959595, 0x00ababab00ababab, 0x008e8e8e008e8e8e, + 0x00bababa00bababa, 0x007a7a7a007a7a7a, 0x00b3b3b300b3b3b3, + 0x0002020200020202, 0x00b4b4b400b4b4b4, 0x00adadad00adadad, + 0x00a2a2a200a2a2a2, 0x00acacac00acacac, 0x00d8d8d800d8d8d8, + 0x009a9a9a009a9a9a, 0x0017171700171717, 0x001a1a1a001a1a1a, + 0x0035353500353535, 0x00cccccc00cccccc, 0x00f7f7f700f7f7f7, + 0x0099999900999999, 0x0061616100616161, 0x005a5a5a005a5a5a, + 0x00e8e8e800e8e8e8, 0x0024242400242424, 0x0056565600565656, + 0x0040404000404040, 0x00e1e1e100e1e1e1, 0x0063636300636363, + 0x0009090900090909, 0x0033333300333333, 0x00bfbfbf00bfbfbf, + 0x0098989800989898, 0x0097979700979797, 0x0085858500858585, + 0x0068686800686868, 0x00fcfcfc00fcfcfc, 0x00ececec00ececec, + 0x000a0a0a000a0a0a, 0x00dadada00dadada, 0x006f6f6f006f6f6f, + 0x0053535300535353, 0x0062626200626262, 0x00a3a3a300a3a3a3, + 0x002e2e2e002e2e2e, 0x0008080800080808, 0x00afafaf00afafaf, + 0x0028282800282828, 0x00b0b0b000b0b0b0, 0x0074747400747474, + 0x00c2c2c200c2c2c2, 0x00bdbdbd00bdbdbd, 0x0036363600363636, + 0x0022222200222222, 0x0038383800383838, 0x0064646400646464, + 0x001e1e1e001e1e1e, 0x0039393900393939, 0x002c2c2c002c2c2c, + 0x00a6a6a600a6a6a6, 0x0030303000303030, 0x00e5e5e500e5e5e5, + 0x0044444400444444, 0x00fdfdfd00fdfdfd, 0x0088888800888888, + 0x009f9f9f009f9f9f, 0x0065656500656565, 0x0087878700878787, + 0x006b6b6b006b6b6b, 0x00f4f4f400f4f4f4, 0x0023232300232323, + 0x0048484800484848, 0x0010101000101010, 0x00d1d1d100d1d1d1, + 0x0051515100515151, 0x00c0c0c000c0c0c0, 0x00f9f9f900f9f9f9, + 0x00d2d2d200d2d2d2, 0x00a0a0a000a0a0a0, 0x0055555500555555, + 0x00a1a1a100a1a1a1, 0x0041414100414141, 0x00fafafa00fafafa, + 0x0043434300434343, 0x0013131300131313, 0x00c4c4c400c4c4c4, + 0x002f2f2f002f2f2f, 0x00a8a8a800a8a8a8, 0x00b6b6b600b6b6b6, + 0x003c3c3c003c3c3c, 0x002b2b2b002b2b2b, 0x00c1c1c100c1c1c1, + 0x00ffffff00ffffff, 0x00c8c8c800c8c8c8, 0x00a5a5a500a5a5a5, + 0x0020202000202020, 0x0089898900898989, 0x0000000000000000, + 0x0090909000909090, 0x0047474700474747, 0x00efefef00efefef, + 0x00eaeaea00eaeaea, 0x00b7b7b700b7b7b7, 0x0015151500151515, + 0x0006060600060606, 0x00cdcdcd00cdcdcd, 0x00b5b5b500b5b5b5, + 0x0012121200121212, 0x007e7e7e007e7e7e, 0x00bbbbbb00bbbbbb, + 0x0029292900292929, 0x000f0f0f000f0f0f, 0x00b8b8b800b8b8b8, + 0x0007070700070707, 0x0004040400040404, 0x009b9b9b009b9b9b, + 0x0094949400949494, 0x0021212100212121, 0x0066666600666666, + 0x00e6e6e600e6e6e6, 0x00cecece00cecece, 0x00ededed00ededed, + 0x00e7e7e700e7e7e7, 0x003b3b3b003b3b3b, 0x00fefefe00fefefe, + 0x007f7f7f007f7f7f, 0x00c5c5c500c5c5c5, 0x00a4a4a400a4a4a4, + 0x0037373700373737, 0x00b1b1b100b1b1b1, 0x004c4c4c004c4c4c, + 0x0091919100919191, 0x006e6e6e006e6e6e, 0x008d8d8d008d8d8d, + 0x0076767600767676, 0x0003030300030303, 0x002d2d2d002d2d2d, + 0x00dedede00dedede, 0x0096969600969696, 0x0026262600262626, + 0x007d7d7d007d7d7d, 0x00c6c6c600c6c6c6, 0x005c5c5c005c5c5c, + 0x00d3d3d300d3d3d3, 0x00f2f2f200f2f2f2, 0x004f4f4f004f4f4f, + 0x0019191900191919, 0x003f3f3f003f3f3f, 0x00dcdcdc00dcdcdc, + 0x0079797900797979, 0x001d1d1d001d1d1d, 0x0052525200525252, + 0x00ebebeb00ebebeb, 0x00f3f3f300f3f3f3, 0x006d6d6d006d6d6d, + 0x005e5e5e005e5e5e, 0x00fbfbfb00fbfbfb, 0x0069696900696969, + 0x00b2b2b200b2b2b2, 0x00f0f0f000f0f0f0, 0x0031313100313131, + 0x000c0c0c000c0c0c, 0x00d4d4d400d4d4d4, 0x00cfcfcf00cfcfcf, + 0x008c8c8c008c8c8c, 0x00e2e2e200e2e2e2, 0x0075757500757575, + 0x00a9a9a900a9a9a9, 0x004a4a4a004a4a4a, 0x0057575700575757, + 0x0084848400848484, 0x0011111100111111, 0x0045454500454545, + 0x001b1b1b001b1b1b, 0x00f5f5f500f5f5f5, 0x00e4e4e400e4e4e4, + 0x000e0e0e000e0e0e, 0x0073737300737373, 0x00aaaaaa00aaaaaa, + 0x00f1f1f100f1f1f1, 0x00dddddd00dddddd, 0x0059595900595959, + 0x0014141400141414, 0x006c6c6c006c6c6c, 0x0092929200929292, + 0x0054545400545454, 0x00d0d0d000d0d0d0, 0x0078787800787878, + 0x0070707000707070, 0x00e3e3e300e3e3e3, 0x0049494900494949, + 0x0080808000808080, 0x0050505000505050, 0x00a7a7a700a7a7a7, + 0x00f6f6f600f6f6f6, 0x0077777700777777, 0x0093939300939393, + 0x0086868600868686, 0x0083838300838383, 0x002a2a2a002a2a2a, + 0x00c7c7c700c7c7c7, 0x005b5b5b005b5b5b, 0x00e9e9e900e9e9e9, + 0x00eeeeee00eeeeee, 0x008f8f8f008f8f8f, 0x0001010100010101, + 0x003d3d3d003d3d3d, }; const u64 camellia_sp30333033[256] = { - 0x3800383838003838ULL, 0x4100414141004141ULL, 0x1600161616001616ULL, - 0x7600767676007676ULL, 0xd900d9d9d900d9d9ULL, 0x9300939393009393ULL, - 0x6000606060006060ULL, 0xf200f2f2f200f2f2ULL, 0x7200727272007272ULL, - 0xc200c2c2c200c2c2ULL, 0xab00ababab00ababULL, 0x9a009a9a9a009a9aULL, - 0x7500757575007575ULL, 0x0600060606000606ULL, 0x5700575757005757ULL, - 0xa000a0a0a000a0a0ULL, 0x9100919191009191ULL, 0xf700f7f7f700f7f7ULL, - 0xb500b5b5b500b5b5ULL, 0xc900c9c9c900c9c9ULL, 0xa200a2a2a200a2a2ULL, - 0x8c008c8c8c008c8cULL, 0xd200d2d2d200d2d2ULL, 0x9000909090009090ULL, - 0xf600f6f6f600f6f6ULL, 0x0700070707000707ULL, 0xa700a7a7a700a7a7ULL, - 0x2700272727002727ULL, 0x8e008e8e8e008e8eULL, 0xb200b2b2b200b2b2ULL, - 0x4900494949004949ULL, 0xde00dedede00dedeULL, 0x4300434343004343ULL, - 0x5c005c5c5c005c5cULL, 0xd700d7d7d700d7d7ULL, 0xc700c7c7c700c7c7ULL, - 0x3e003e3e3e003e3eULL, 0xf500f5f5f500f5f5ULL, 0x8f008f8f8f008f8fULL, - 0x6700676767006767ULL, 0x1f001f1f1f001f1fULL, 0x1800181818001818ULL, - 0x6e006e6e6e006e6eULL, 0xaf00afafaf00afafULL, 0x2f002f2f2f002f2fULL, - 0xe200e2e2e200e2e2ULL, 0x8500858585008585ULL, 0x0d000d0d0d000d0dULL, - 0x5300535353005353ULL, 0xf000f0f0f000f0f0ULL, 0x9c009c9c9c009c9cULL, - 0x6500656565006565ULL, 0xea00eaeaea00eaeaULL, 0xa300a3a3a300a3a3ULL, - 0xae00aeaeae00aeaeULL, 0x9e009e9e9e009e9eULL, 0xec00ececec00ececULL, - 0x8000808080008080ULL, 0x2d002d2d2d002d2dULL, 0x6b006b6b6b006b6bULL, - 0xa800a8a8a800a8a8ULL, 0x2b002b2b2b002b2bULL, 0x3600363636003636ULL, - 0xa600a6a6a600a6a6ULL, 0xc500c5c5c500c5c5ULL, 0x8600868686008686ULL, - 0x4d004d4d4d004d4dULL, 0x3300333333003333ULL, 0xfd00fdfdfd00fdfdULL, - 0x6600666666006666ULL, 0x5800585858005858ULL, 0x9600969696009696ULL, - 0x3a003a3a3a003a3aULL, 0x0900090909000909ULL, 0x9500959595009595ULL, - 0x1000101010001010ULL, 0x7800787878007878ULL, 0xd800d8d8d800d8d8ULL, - 0x4200424242004242ULL, 0xcc00cccccc00ccccULL, 0xef00efefef00efefULL, - 0x2600262626002626ULL, 0xe500e5e5e500e5e5ULL, 0x6100616161006161ULL, - 0x1a001a1a1a001a1aULL, 0x3f003f3f3f003f3fULL, 0x3b003b3b3b003b3bULL, - 0x8200828282008282ULL, 0xb600b6b6b600b6b6ULL, 0xdb00dbdbdb00dbdbULL, - 0xd400d4d4d400d4d4ULL, 0x9800989898009898ULL, 0xe800e8e8e800e8e8ULL, - 0x8b008b8b8b008b8bULL, 0x0200020202000202ULL, 0xeb00ebebeb00ebebULL, - 0x0a000a0a0a000a0aULL, 0x2c002c2c2c002c2cULL, 0x1d001d1d1d001d1dULL, - 0xb000b0b0b000b0b0ULL, 0x6f006f6f6f006f6fULL, 0x8d008d8d8d008d8dULL, - 0x8800888888008888ULL, 0x0e000e0e0e000e0eULL, 0x1900191919001919ULL, - 0x8700878787008787ULL, 0x4e004e4e4e004e4eULL, 0x0b000b0b0b000b0bULL, - 0xa900a9a9a900a9a9ULL, 0x0c000c0c0c000c0cULL, 0x7900797979007979ULL, - 0x1100111111001111ULL, 0x7f007f7f7f007f7fULL, 0x2200222222002222ULL, - 0xe700e7e7e700e7e7ULL, 0x5900595959005959ULL, 0xe100e1e1e100e1e1ULL, - 0xda00dadada00dadaULL, 0x3d003d3d3d003d3dULL, 0xc800c8c8c800c8c8ULL, - 0x1200121212001212ULL, 0x0400040404000404ULL, 0x7400747474007474ULL, - 0x5400545454005454ULL, 0x3000303030003030ULL, 0x7e007e7e7e007e7eULL, - 0xb400b4b4b400b4b4ULL, 0x2800282828002828ULL, 0x5500555555005555ULL, - 0x6800686868006868ULL, 0x5000505050005050ULL, 0xbe00bebebe00bebeULL, - 0xd000d0d0d000d0d0ULL, 0xc400c4c4c400c4c4ULL, 0x3100313131003131ULL, - 0xcb00cbcbcb00cbcbULL, 0x2a002a2a2a002a2aULL, 0xad00adadad00adadULL, - 0x0f000f0f0f000f0fULL, 0xca00cacaca00cacaULL, 0x7000707070007070ULL, - 0xff00ffffff00ffffULL, 0x3200323232003232ULL, 0x6900696969006969ULL, - 0x0800080808000808ULL, 0x6200626262006262ULL, 0x0000000000000000ULL, - 0x2400242424002424ULL, 0xd100d1d1d100d1d1ULL, 0xfb00fbfbfb00fbfbULL, - 0xba00bababa00babaULL, 0xed00ededed00ededULL, 0x4500454545004545ULL, - 0x8100818181008181ULL, 0x7300737373007373ULL, 0x6d006d6d6d006d6dULL, - 0x8400848484008484ULL, 0x9f009f9f9f009f9fULL, 0xee00eeeeee00eeeeULL, - 0x4a004a4a4a004a4aULL, 0xc300c3c3c300c3c3ULL, 0x2e002e2e2e002e2eULL, - 0xc100c1c1c100c1c1ULL, 0x0100010101000101ULL, 0xe600e6e6e600e6e6ULL, - 0x2500252525002525ULL, 0x4800484848004848ULL, 0x9900999999009999ULL, - 0xb900b9b9b900b9b9ULL, 0xb300b3b3b300b3b3ULL, 0x7b007b7b7b007b7bULL, - 0xf900f9f9f900f9f9ULL, 0xce00cecece00ceceULL, 0xbf00bfbfbf00bfbfULL, - 0xdf00dfdfdf00dfdfULL, 0x7100717171007171ULL, 0x2900292929002929ULL, - 0xcd00cdcdcd00cdcdULL, 0x6c006c6c6c006c6cULL, 0x1300131313001313ULL, - 0x6400646464006464ULL, 0x9b009b9b9b009b9bULL, 0x6300636363006363ULL, - 0x9d009d9d9d009d9dULL, 0xc000c0c0c000c0c0ULL, 0x4b004b4b4b004b4bULL, - 0xb700b7b7b700b7b7ULL, 0xa500a5a5a500a5a5ULL, 0x8900898989008989ULL, - 0x5f005f5f5f005f5fULL, 0xb100b1b1b100b1b1ULL, 0x1700171717001717ULL, - 0xf400f4f4f400f4f4ULL, 0xbc00bcbcbc00bcbcULL, 0xd300d3d3d300d3d3ULL, - 0x4600464646004646ULL, 0xcf00cfcfcf00cfcfULL, 0x3700373737003737ULL, - 0x5e005e5e5e005e5eULL, 0x4700474747004747ULL, 0x9400949494009494ULL, - 0xfa00fafafa00fafaULL, 0xfc00fcfcfc00fcfcULL, 0x5b005b5b5b005b5bULL, - 0x9700979797009797ULL, 0xfe00fefefe00fefeULL, 0x5a005a5a5a005a5aULL, - 0xac00acacac00acacULL, 0x3c003c3c3c003c3cULL, 0x4c004c4c4c004c4cULL, - 0x0300030303000303ULL, 0x3500353535003535ULL, 0xf300f3f3f300f3f3ULL, - 0x2300232323002323ULL, 0xb800b8b8b800b8b8ULL, 0x5d005d5d5d005d5dULL, - 0x6a006a6a6a006a6aULL, 0x9200929292009292ULL, 0xd500d5d5d500d5d5ULL, - 0x2100212121002121ULL, 0x4400444444004444ULL, 0x5100515151005151ULL, - 0xc600c6c6c600c6c6ULL, 0x7d007d7d7d007d7dULL, 0x3900393939003939ULL, - 0x8300838383008383ULL, 0xdc00dcdcdc00dcdcULL, 0xaa00aaaaaa00aaaaULL, - 0x7c007c7c7c007c7cULL, 0x7700777777007777ULL, 0x5600565656005656ULL, - 0x0500050505000505ULL, 0x1b001b1b1b001b1bULL, 0xa400a4a4a400a4a4ULL, - 0x1500151515001515ULL, 0x3400343434003434ULL, 0x1e001e1e1e001e1eULL, - 0x1c001c1c1c001c1cULL, 0xf800f8f8f800f8f8ULL, 0x5200525252005252ULL, - 0x2000202020002020ULL, 0x1400141414001414ULL, 0xe900e9e9e900e9e9ULL, - 0xbd00bdbdbd00bdbdULL, 0xdd00dddddd00ddddULL, 0xe400e4e4e400e4e4ULL, - 0xa100a1a1a100a1a1ULL, 0xe000e0e0e000e0e0ULL, 0x8a008a8a8a008a8aULL, - 0xf100f1f1f100f1f1ULL, 0xd600d6d6d600d6d6ULL, 0x7a007a7a7a007a7aULL, - 0xbb00bbbbbb00bbbbULL, 0xe300e3e3e300e3e3ULL, 0x4000404040004040ULL, - 0x4f004f4f4f004f4fULL, + 0x3800383838003838, 0x4100414141004141, 0x1600161616001616, + 0x7600767676007676, 0xd900d9d9d900d9d9, 0x9300939393009393, + 0x6000606060006060, 0xf200f2f2f200f2f2, 0x7200727272007272, + 0xc200c2c2c200c2c2, 0xab00ababab00abab, 0x9a009a9a9a009a9a, + 0x7500757575007575, 0x0600060606000606, 0x5700575757005757, + 0xa000a0a0a000a0a0, 0x9100919191009191, 0xf700f7f7f700f7f7, + 0xb500b5b5b500b5b5, 0xc900c9c9c900c9c9, 0xa200a2a2a200a2a2, + 0x8c008c8c8c008c8c, 0xd200d2d2d200d2d2, 0x9000909090009090, + 0xf600f6f6f600f6f6, 0x0700070707000707, 0xa700a7a7a700a7a7, + 0x2700272727002727, 0x8e008e8e8e008e8e, 0xb200b2b2b200b2b2, + 0x4900494949004949, 0xde00dedede00dede, 0x4300434343004343, + 0x5c005c5c5c005c5c, 0xd700d7d7d700d7d7, 0xc700c7c7c700c7c7, + 0x3e003e3e3e003e3e, 0xf500f5f5f500f5f5, 0x8f008f8f8f008f8f, + 0x6700676767006767, 0x1f001f1f1f001f1f, 0x1800181818001818, + 0x6e006e6e6e006e6e, 0xaf00afafaf00afaf, 0x2f002f2f2f002f2f, + 0xe200e2e2e200e2e2, 0x8500858585008585, 0x0d000d0d0d000d0d, + 0x5300535353005353, 0xf000f0f0f000f0f0, 0x9c009c9c9c009c9c, + 0x6500656565006565, 0xea00eaeaea00eaea, 0xa300a3a3a300a3a3, + 0xae00aeaeae00aeae, 0x9e009e9e9e009e9e, 0xec00ececec00ecec, + 0x8000808080008080, 0x2d002d2d2d002d2d, 0x6b006b6b6b006b6b, + 0xa800a8a8a800a8a8, 0x2b002b2b2b002b2b, 0x3600363636003636, + 0xa600a6a6a600a6a6, 0xc500c5c5c500c5c5, 0x8600868686008686, + 0x4d004d4d4d004d4d, 0x3300333333003333, 0xfd00fdfdfd00fdfd, + 0x6600666666006666, 0x5800585858005858, 0x9600969696009696, + 0x3a003a3a3a003a3a, 0x0900090909000909, 0x9500959595009595, + 0x1000101010001010, 0x7800787878007878, 0xd800d8d8d800d8d8, + 0x4200424242004242, 0xcc00cccccc00cccc, 0xef00efefef00efef, + 0x2600262626002626, 0xe500e5e5e500e5e5, 0x6100616161006161, + 0x1a001a1a1a001a1a, 0x3f003f3f3f003f3f, 0x3b003b3b3b003b3b, + 0x8200828282008282, 0xb600b6b6b600b6b6, 0xdb00dbdbdb00dbdb, + 0xd400d4d4d400d4d4, 0x9800989898009898, 0xe800e8e8e800e8e8, + 0x8b008b8b8b008b8b, 0x0200020202000202, 0xeb00ebebeb00ebeb, + 0x0a000a0a0a000a0a, 0x2c002c2c2c002c2c, 0x1d001d1d1d001d1d, + 0xb000b0b0b000b0b0, 0x6f006f6f6f006f6f, 0x8d008d8d8d008d8d, + 0x8800888888008888, 0x0e000e0e0e000e0e, 0x1900191919001919, + 0x8700878787008787, 0x4e004e4e4e004e4e, 0x0b000b0b0b000b0b, + 0xa900a9a9a900a9a9, 0x0c000c0c0c000c0c, 0x7900797979007979, + 0x1100111111001111, 0x7f007f7f7f007f7f, 0x2200222222002222, + 0xe700e7e7e700e7e7, 0x5900595959005959, 0xe100e1e1e100e1e1, + 0xda00dadada00dada, 0x3d003d3d3d003d3d, 0xc800c8c8c800c8c8, + 0x1200121212001212, 0x0400040404000404, 0x7400747474007474, + 0x5400545454005454, 0x3000303030003030, 0x7e007e7e7e007e7e, + 0xb400b4b4b400b4b4, 0x2800282828002828, 0x5500555555005555, + 0x6800686868006868, 0x5000505050005050, 0xbe00bebebe00bebe, + 0xd000d0d0d000d0d0, 0xc400c4c4c400c4c4, 0x3100313131003131, + 0xcb00cbcbcb00cbcb, 0x2a002a2a2a002a2a, 0xad00adadad00adad, + 0x0f000f0f0f000f0f, 0xca00cacaca00caca, 0x7000707070007070, + 0xff00ffffff00ffff, 0x3200323232003232, 0x6900696969006969, + 0x0800080808000808, 0x6200626262006262, 0x0000000000000000, + 0x2400242424002424, 0xd100d1d1d100d1d1, 0xfb00fbfbfb00fbfb, + 0xba00bababa00baba, 0xed00ededed00eded, 0x4500454545004545, + 0x8100818181008181, 0x7300737373007373, 0x6d006d6d6d006d6d, + 0x8400848484008484, 0x9f009f9f9f009f9f, 0xee00eeeeee00eeee, + 0x4a004a4a4a004a4a, 0xc300c3c3c300c3c3, 0x2e002e2e2e002e2e, + 0xc100c1c1c100c1c1, 0x0100010101000101, 0xe600e6e6e600e6e6, + 0x2500252525002525, 0x4800484848004848, 0x9900999999009999, + 0xb900b9b9b900b9b9, 0xb300b3b3b300b3b3, 0x7b007b7b7b007b7b, + 0xf900f9f9f900f9f9, 0xce00cecece00cece, 0xbf00bfbfbf00bfbf, + 0xdf00dfdfdf00dfdf, 0x7100717171007171, 0x2900292929002929, + 0xcd00cdcdcd00cdcd, 0x6c006c6c6c006c6c, 0x1300131313001313, + 0x6400646464006464, 0x9b009b9b9b009b9b, 0x6300636363006363, + 0x9d009d9d9d009d9d, 0xc000c0c0c000c0c0, 0x4b004b4b4b004b4b, + 0xb700b7b7b700b7b7, 0xa500a5a5a500a5a5, 0x8900898989008989, + 0x5f005f5f5f005f5f, 0xb100b1b1b100b1b1, 0x1700171717001717, + 0xf400f4f4f400f4f4, 0xbc00bcbcbc00bcbc, 0xd300d3d3d300d3d3, + 0x4600464646004646, 0xcf00cfcfcf00cfcf, 0x3700373737003737, + 0x5e005e5e5e005e5e, 0x4700474747004747, 0x9400949494009494, + 0xfa00fafafa00fafa, 0xfc00fcfcfc00fcfc, 0x5b005b5b5b005b5b, + 0x9700979797009797, 0xfe00fefefe00fefe, 0x5a005a5a5a005a5a, + 0xac00acacac00acac, 0x3c003c3c3c003c3c, 0x4c004c4c4c004c4c, + 0x0300030303000303, 0x3500353535003535, 0xf300f3f3f300f3f3, + 0x2300232323002323, 0xb800b8b8b800b8b8, 0x5d005d5d5d005d5d, + 0x6a006a6a6a006a6a, 0x9200929292009292, 0xd500d5d5d500d5d5, + 0x2100212121002121, 0x4400444444004444, 0x5100515151005151, + 0xc600c6c6c600c6c6, 0x7d007d7d7d007d7d, 0x3900393939003939, + 0x8300838383008383, 0xdc00dcdcdc00dcdc, 0xaa00aaaaaa00aaaa, + 0x7c007c7c7c007c7c, 0x7700777777007777, 0x5600565656005656, + 0x0500050505000505, 0x1b001b1b1b001b1b, 0xa400a4a4a400a4a4, + 0x1500151515001515, 0x3400343434003434, 0x1e001e1e1e001e1e, + 0x1c001c1c1c001c1c, 0xf800f8f8f800f8f8, 0x5200525252005252, + 0x2000202020002020, 0x1400141414001414, 0xe900e9e9e900e9e9, + 0xbd00bdbdbd00bdbd, 0xdd00dddddd00dddd, 0xe400e4e4e400e4e4, + 0xa100a1a1a100a1a1, 0xe000e0e0e000e0e0, 0x8a008a8a8a008a8a, + 0xf100f1f1f100f1f1, 0xd600d6d6d600d6d6, 0x7a007a7a7a007a7a, + 0xbb00bbbbbb00bbbb, 0xe300e3e3e300e3e3, 0x4000404040004040, + 0x4f004f4f4f004f4f, }; const u64 camellia_sp44044404[256] = { - 0x7070007070700070ULL, 0x2c2c002c2c2c002cULL, 0xb3b300b3b3b300b3ULL, - 0xc0c000c0c0c000c0ULL, 0xe4e400e4e4e400e4ULL, 0x5757005757570057ULL, - 0xeaea00eaeaea00eaULL, 0xaeae00aeaeae00aeULL, 0x2323002323230023ULL, - 0x6b6b006b6b6b006bULL, 0x4545004545450045ULL, 0xa5a500a5a5a500a5ULL, - 0xeded00ededed00edULL, 0x4f4f004f4f4f004fULL, 0x1d1d001d1d1d001dULL, - 0x9292009292920092ULL, 0x8686008686860086ULL, 0xafaf00afafaf00afULL, - 0x7c7c007c7c7c007cULL, 0x1f1f001f1f1f001fULL, 0x3e3e003e3e3e003eULL, - 0xdcdc00dcdcdc00dcULL, 0x5e5e005e5e5e005eULL, 0x0b0b000b0b0b000bULL, - 0xa6a600a6a6a600a6ULL, 0x3939003939390039ULL, 0xd5d500d5d5d500d5ULL, - 0x5d5d005d5d5d005dULL, 0xd9d900d9d9d900d9ULL, 0x5a5a005a5a5a005aULL, - 0x5151005151510051ULL, 0x6c6c006c6c6c006cULL, 0x8b8b008b8b8b008bULL, - 0x9a9a009a9a9a009aULL, 0xfbfb00fbfbfb00fbULL, 0xb0b000b0b0b000b0ULL, - 0x7474007474740074ULL, 0x2b2b002b2b2b002bULL, 0xf0f000f0f0f000f0ULL, - 0x8484008484840084ULL, 0xdfdf00dfdfdf00dfULL, 0xcbcb00cbcbcb00cbULL, - 0x3434003434340034ULL, 0x7676007676760076ULL, 0x6d6d006d6d6d006dULL, - 0xa9a900a9a9a900a9ULL, 0xd1d100d1d1d100d1ULL, 0x0404000404040004ULL, - 0x1414001414140014ULL, 0x3a3a003a3a3a003aULL, 0xdede00dedede00deULL, - 0x1111001111110011ULL, 0x3232003232320032ULL, 0x9c9c009c9c9c009cULL, - 0x5353005353530053ULL, 0xf2f200f2f2f200f2ULL, 0xfefe00fefefe00feULL, - 0xcfcf00cfcfcf00cfULL, 0xc3c300c3c3c300c3ULL, 0x7a7a007a7a7a007aULL, - 0x2424002424240024ULL, 0xe8e800e8e8e800e8ULL, 0x6060006060600060ULL, - 0x6969006969690069ULL, 0xaaaa00aaaaaa00aaULL, 0xa0a000a0a0a000a0ULL, - 0xa1a100a1a1a100a1ULL, 0x6262006262620062ULL, 0x5454005454540054ULL, - 0x1e1e001e1e1e001eULL, 0xe0e000e0e0e000e0ULL, 0x6464006464640064ULL, - 0x1010001010100010ULL, 0x0000000000000000ULL, 0xa3a300a3a3a300a3ULL, - 0x7575007575750075ULL, 0x8a8a008a8a8a008aULL, 0xe6e600e6e6e600e6ULL, - 0x0909000909090009ULL, 0xdddd00dddddd00ddULL, 0x8787008787870087ULL, - 0x8383008383830083ULL, 0xcdcd00cdcdcd00cdULL, 0x9090009090900090ULL, - 0x7373007373730073ULL, 0xf6f600f6f6f600f6ULL, 0x9d9d009d9d9d009dULL, - 0xbfbf00bfbfbf00bfULL, 0x5252005252520052ULL, 0xd8d800d8d8d800d8ULL, - 0xc8c800c8c8c800c8ULL, 0xc6c600c6c6c600c6ULL, 0x8181008181810081ULL, - 0x6f6f006f6f6f006fULL, 0x1313001313130013ULL, 0x6363006363630063ULL, - 0xe9e900e9e9e900e9ULL, 0xa7a700a7a7a700a7ULL, 0x9f9f009f9f9f009fULL, - 0xbcbc00bcbcbc00bcULL, 0x2929002929290029ULL, 0xf9f900f9f9f900f9ULL, - 0x2f2f002f2f2f002fULL, 0xb4b400b4b4b400b4ULL, 0x7878007878780078ULL, - 0x0606000606060006ULL, 0xe7e700e7e7e700e7ULL, 0x7171007171710071ULL, - 0xd4d400d4d4d400d4ULL, 0xabab00ababab00abULL, 0x8888008888880088ULL, - 0x8d8d008d8d8d008dULL, 0x7272007272720072ULL, 0xb9b900b9b9b900b9ULL, - 0xf8f800f8f8f800f8ULL, 0xacac00acacac00acULL, 0x3636003636360036ULL, - 0x2a2a002a2a2a002aULL, 0x3c3c003c3c3c003cULL, 0xf1f100f1f1f100f1ULL, - 0x4040004040400040ULL, 0xd3d300d3d3d300d3ULL, 0xbbbb00bbbbbb00bbULL, - 0x4343004343430043ULL, 0x1515001515150015ULL, 0xadad00adadad00adULL, - 0x7777007777770077ULL, 0x8080008080800080ULL, 0x8282008282820082ULL, - 0xecec00ececec00ecULL, 0x2727002727270027ULL, 0xe5e500e5e5e500e5ULL, - 0x8585008585850085ULL, 0x3535003535350035ULL, 0x0c0c000c0c0c000cULL, - 0x4141004141410041ULL, 0xefef00efefef00efULL, 0x9393009393930093ULL, - 0x1919001919190019ULL, 0x2121002121210021ULL, 0x0e0e000e0e0e000eULL, - 0x4e4e004e4e4e004eULL, 0x6565006565650065ULL, 0xbdbd00bdbdbd00bdULL, - 0xb8b800b8b8b800b8ULL, 0x8f8f008f8f8f008fULL, 0xebeb00ebebeb00ebULL, - 0xcece00cecece00ceULL, 0x3030003030300030ULL, 0x5f5f005f5f5f005fULL, - 0xc5c500c5c5c500c5ULL, 0x1a1a001a1a1a001aULL, 0xe1e100e1e1e100e1ULL, - 0xcaca00cacaca00caULL, 0x4747004747470047ULL, 0x3d3d003d3d3d003dULL, - 0x0101000101010001ULL, 0xd6d600d6d6d600d6ULL, 0x5656005656560056ULL, - 0x4d4d004d4d4d004dULL, 0x0d0d000d0d0d000dULL, 0x6666006666660066ULL, - 0xcccc00cccccc00ccULL, 0x2d2d002d2d2d002dULL, 0x1212001212120012ULL, - 0x2020002020200020ULL, 0xb1b100b1b1b100b1ULL, 0x9999009999990099ULL, - 0x4c4c004c4c4c004cULL, 0xc2c200c2c2c200c2ULL, 0x7e7e007e7e7e007eULL, - 0x0505000505050005ULL, 0xb7b700b7b7b700b7ULL, 0x3131003131310031ULL, - 0x1717001717170017ULL, 0xd7d700d7d7d700d7ULL, 0x5858005858580058ULL, - 0x6161006161610061ULL, 0x1b1b001b1b1b001bULL, 0x1c1c001c1c1c001cULL, - 0x0f0f000f0f0f000fULL, 0x1616001616160016ULL, 0x1818001818180018ULL, - 0x2222002222220022ULL, 0x4444004444440044ULL, 0xb2b200b2b2b200b2ULL, - 0xb5b500b5b5b500b5ULL, 0x9191009191910091ULL, 0x0808000808080008ULL, - 0xa8a800a8a8a800a8ULL, 0xfcfc00fcfcfc00fcULL, 0x5050005050500050ULL, - 0xd0d000d0d0d000d0ULL, 0x7d7d007d7d7d007dULL, 0x8989008989890089ULL, - 0x9797009797970097ULL, 0x5b5b005b5b5b005bULL, 0x9595009595950095ULL, - 0xffff00ffffff00ffULL, 0xd2d200d2d2d200d2ULL, 0xc4c400c4c4c400c4ULL, - 0x4848004848480048ULL, 0xf7f700f7f7f700f7ULL, 0xdbdb00dbdbdb00dbULL, - 0x0303000303030003ULL, 0xdada00dadada00daULL, 0x3f3f003f3f3f003fULL, - 0x9494009494940094ULL, 0x5c5c005c5c5c005cULL, 0x0202000202020002ULL, - 0x4a4a004a4a4a004aULL, 0x3333003333330033ULL, 0x6767006767670067ULL, - 0xf3f300f3f3f300f3ULL, 0x7f7f007f7f7f007fULL, 0xe2e200e2e2e200e2ULL, - 0x9b9b009b9b9b009bULL, 0x2626002626260026ULL, 0x3737003737370037ULL, - 0x3b3b003b3b3b003bULL, 0x9696009696960096ULL, 0x4b4b004b4b4b004bULL, - 0xbebe00bebebe00beULL, 0x2e2e002e2e2e002eULL, 0x7979007979790079ULL, - 0x8c8c008c8c8c008cULL, 0x6e6e006e6e6e006eULL, 0x8e8e008e8e8e008eULL, - 0xf5f500f5f5f500f5ULL, 0xb6b600b6b6b600b6ULL, 0xfdfd00fdfdfd00fdULL, - 0x5959005959590059ULL, 0x9898009898980098ULL, 0x6a6a006a6a6a006aULL, - 0x4646004646460046ULL, 0xbaba00bababa00baULL, 0x2525002525250025ULL, - 0x4242004242420042ULL, 0xa2a200a2a2a200a2ULL, 0xfafa00fafafa00faULL, - 0x0707000707070007ULL, 0x5555005555550055ULL, 0xeeee00eeeeee00eeULL, - 0x0a0a000a0a0a000aULL, 0x4949004949490049ULL, 0x6868006868680068ULL, - 0x3838003838380038ULL, 0xa4a400a4a4a400a4ULL, 0x2828002828280028ULL, - 0x7b7b007b7b7b007bULL, 0xc9c900c9c9c900c9ULL, 0xc1c100c1c1c100c1ULL, - 0xe3e300e3e3e300e3ULL, 0xf4f400f4f4f400f4ULL, 0xc7c700c7c7c700c7ULL, - 0x9e9e009e9e9e009eULL, + 0x7070007070700070, 0x2c2c002c2c2c002c, 0xb3b300b3b3b300b3, + 0xc0c000c0c0c000c0, 0xe4e400e4e4e400e4, 0x5757005757570057, + 0xeaea00eaeaea00ea, 0xaeae00aeaeae00ae, 0x2323002323230023, + 0x6b6b006b6b6b006b, 0x4545004545450045, 0xa5a500a5a5a500a5, + 0xeded00ededed00ed, 0x4f4f004f4f4f004f, 0x1d1d001d1d1d001d, + 0x9292009292920092, 0x8686008686860086, 0xafaf00afafaf00af, + 0x7c7c007c7c7c007c, 0x1f1f001f1f1f001f, 0x3e3e003e3e3e003e, + 0xdcdc00dcdcdc00dc, 0x5e5e005e5e5e005e, 0x0b0b000b0b0b000b, + 0xa6a600a6a6a600a6, 0x3939003939390039, 0xd5d500d5d5d500d5, + 0x5d5d005d5d5d005d, 0xd9d900d9d9d900d9, 0x5a5a005a5a5a005a, + 0x5151005151510051, 0x6c6c006c6c6c006c, 0x8b8b008b8b8b008b, + 0x9a9a009a9a9a009a, 0xfbfb00fbfbfb00fb, 0xb0b000b0b0b000b0, + 0x7474007474740074, 0x2b2b002b2b2b002b, 0xf0f000f0f0f000f0, + 0x8484008484840084, 0xdfdf00dfdfdf00df, 0xcbcb00cbcbcb00cb, + 0x3434003434340034, 0x7676007676760076, 0x6d6d006d6d6d006d, + 0xa9a900a9a9a900a9, 0xd1d100d1d1d100d1, 0x0404000404040004, + 0x1414001414140014, 0x3a3a003a3a3a003a, 0xdede00dedede00de, + 0x1111001111110011, 0x3232003232320032, 0x9c9c009c9c9c009c, + 0x5353005353530053, 0xf2f200f2f2f200f2, 0xfefe00fefefe00fe, + 0xcfcf00cfcfcf00cf, 0xc3c300c3c3c300c3, 0x7a7a007a7a7a007a, + 0x2424002424240024, 0xe8e800e8e8e800e8, 0x6060006060600060, + 0x6969006969690069, 0xaaaa00aaaaaa00aa, 0xa0a000a0a0a000a0, + 0xa1a100a1a1a100a1, 0x6262006262620062, 0x5454005454540054, + 0x1e1e001e1e1e001e, 0xe0e000e0e0e000e0, 0x6464006464640064, + 0x1010001010100010, 0x0000000000000000, 0xa3a300a3a3a300a3, + 0x7575007575750075, 0x8a8a008a8a8a008a, 0xe6e600e6e6e600e6, + 0x0909000909090009, 0xdddd00dddddd00dd, 0x8787008787870087, + 0x8383008383830083, 0xcdcd00cdcdcd00cd, 0x9090009090900090, + 0x7373007373730073, 0xf6f600f6f6f600f6, 0x9d9d009d9d9d009d, + 0xbfbf00bfbfbf00bf, 0x5252005252520052, 0xd8d800d8d8d800d8, + 0xc8c800c8c8c800c8, 0xc6c600c6c6c600c6, 0x8181008181810081, + 0x6f6f006f6f6f006f, 0x1313001313130013, 0x6363006363630063, + 0xe9e900e9e9e900e9, 0xa7a700a7a7a700a7, 0x9f9f009f9f9f009f, + 0xbcbc00bcbcbc00bc, 0x2929002929290029, 0xf9f900f9f9f900f9, + 0x2f2f002f2f2f002f, 0xb4b400b4b4b400b4, 0x7878007878780078, + 0x0606000606060006, 0xe7e700e7e7e700e7, 0x7171007171710071, + 0xd4d400d4d4d400d4, 0xabab00ababab00ab, 0x8888008888880088, + 0x8d8d008d8d8d008d, 0x7272007272720072, 0xb9b900b9b9b900b9, + 0xf8f800f8f8f800f8, 0xacac00acacac00ac, 0x3636003636360036, + 0x2a2a002a2a2a002a, 0x3c3c003c3c3c003c, 0xf1f100f1f1f100f1, + 0x4040004040400040, 0xd3d300d3d3d300d3, 0xbbbb00bbbbbb00bb, + 0x4343004343430043, 0x1515001515150015, 0xadad00adadad00ad, + 0x7777007777770077, 0x8080008080800080, 0x8282008282820082, + 0xecec00ececec00ec, 0x2727002727270027, 0xe5e500e5e5e500e5, + 0x8585008585850085, 0x3535003535350035, 0x0c0c000c0c0c000c, + 0x4141004141410041, 0xefef00efefef00ef, 0x9393009393930093, + 0x1919001919190019, 0x2121002121210021, 0x0e0e000e0e0e000e, + 0x4e4e004e4e4e004e, 0x6565006565650065, 0xbdbd00bdbdbd00bd, + 0xb8b800b8b8b800b8, 0x8f8f008f8f8f008f, 0xebeb00ebebeb00eb, + 0xcece00cecece00ce, 0x3030003030300030, 0x5f5f005f5f5f005f, + 0xc5c500c5c5c500c5, 0x1a1a001a1a1a001a, 0xe1e100e1e1e100e1, + 0xcaca00cacaca00ca, 0x4747004747470047, 0x3d3d003d3d3d003d, + 0x0101000101010001, 0xd6d600d6d6d600d6, 0x5656005656560056, + 0x4d4d004d4d4d004d, 0x0d0d000d0d0d000d, 0x6666006666660066, + 0xcccc00cccccc00cc, 0x2d2d002d2d2d002d, 0x1212001212120012, + 0x2020002020200020, 0xb1b100b1b1b100b1, 0x9999009999990099, + 0x4c4c004c4c4c004c, 0xc2c200c2c2c200c2, 0x7e7e007e7e7e007e, + 0x0505000505050005, 0xb7b700b7b7b700b7, 0x3131003131310031, + 0x1717001717170017, 0xd7d700d7d7d700d7, 0x5858005858580058, + 0x6161006161610061, 0x1b1b001b1b1b001b, 0x1c1c001c1c1c001c, + 0x0f0f000f0f0f000f, 0x1616001616160016, 0x1818001818180018, + 0x2222002222220022, 0x4444004444440044, 0xb2b200b2b2b200b2, + 0xb5b500b5b5b500b5, 0x9191009191910091, 0x0808000808080008, + 0xa8a800a8a8a800a8, 0xfcfc00fcfcfc00fc, 0x5050005050500050, + 0xd0d000d0d0d000d0, 0x7d7d007d7d7d007d, 0x8989008989890089, + 0x9797009797970097, 0x5b5b005b5b5b005b, 0x9595009595950095, + 0xffff00ffffff00ff, 0xd2d200d2d2d200d2, 0xc4c400c4c4c400c4, + 0x4848004848480048, 0xf7f700f7f7f700f7, 0xdbdb00dbdbdb00db, + 0x0303000303030003, 0xdada00dadada00da, 0x3f3f003f3f3f003f, + 0x9494009494940094, 0x5c5c005c5c5c005c, 0x0202000202020002, + 0x4a4a004a4a4a004a, 0x3333003333330033, 0x6767006767670067, + 0xf3f300f3f3f300f3, 0x7f7f007f7f7f007f, 0xe2e200e2e2e200e2, + 0x9b9b009b9b9b009b, 0x2626002626260026, 0x3737003737370037, + 0x3b3b003b3b3b003b, 0x9696009696960096, 0x4b4b004b4b4b004b, + 0xbebe00bebebe00be, 0x2e2e002e2e2e002e, 0x7979007979790079, + 0x8c8c008c8c8c008c, 0x6e6e006e6e6e006e, 0x8e8e008e8e8e008e, + 0xf5f500f5f5f500f5, 0xb6b600b6b6b600b6, 0xfdfd00fdfdfd00fd, + 0x5959005959590059, 0x9898009898980098, 0x6a6a006a6a6a006a, + 0x4646004646460046, 0xbaba00bababa00ba, 0x2525002525250025, + 0x4242004242420042, 0xa2a200a2a2a200a2, 0xfafa00fafafa00fa, + 0x0707000707070007, 0x5555005555550055, 0xeeee00eeeeee00ee, + 0x0a0a000a0a0a000a, 0x4949004949490049, 0x6868006868680068, + 0x3838003838380038, 0xa4a400a4a4a400a4, 0x2828002828280028, + 0x7b7b007b7b7b007b, 0xc9c900c9c9c900c9, 0xc1c100c1c1c100c1, + 0xe3e300e3e3e300e3, 0xf4f400f4f4f400f4, 0xc7c700c7c7c700c7, + 0x9e9e009e9e9e009e, }; const u64 camellia_sp11101110[256] = { - 0x7070700070707000ULL, 0x8282820082828200ULL, 0x2c2c2c002c2c2c00ULL, - 0xececec00ececec00ULL, 0xb3b3b300b3b3b300ULL, 0x2727270027272700ULL, - 0xc0c0c000c0c0c000ULL, 0xe5e5e500e5e5e500ULL, 0xe4e4e400e4e4e400ULL, - 0x8585850085858500ULL, 0x5757570057575700ULL, 0x3535350035353500ULL, - 0xeaeaea00eaeaea00ULL, 0x0c0c0c000c0c0c00ULL, 0xaeaeae00aeaeae00ULL, - 0x4141410041414100ULL, 0x2323230023232300ULL, 0xefefef00efefef00ULL, - 0x6b6b6b006b6b6b00ULL, 0x9393930093939300ULL, 0x4545450045454500ULL, - 0x1919190019191900ULL, 0xa5a5a500a5a5a500ULL, 0x2121210021212100ULL, - 0xededed00ededed00ULL, 0x0e0e0e000e0e0e00ULL, 0x4f4f4f004f4f4f00ULL, - 0x4e4e4e004e4e4e00ULL, 0x1d1d1d001d1d1d00ULL, 0x6565650065656500ULL, - 0x9292920092929200ULL, 0xbdbdbd00bdbdbd00ULL, 0x8686860086868600ULL, - 0xb8b8b800b8b8b800ULL, 0xafafaf00afafaf00ULL, 0x8f8f8f008f8f8f00ULL, - 0x7c7c7c007c7c7c00ULL, 0xebebeb00ebebeb00ULL, 0x1f1f1f001f1f1f00ULL, - 0xcecece00cecece00ULL, 0x3e3e3e003e3e3e00ULL, 0x3030300030303000ULL, - 0xdcdcdc00dcdcdc00ULL, 0x5f5f5f005f5f5f00ULL, 0x5e5e5e005e5e5e00ULL, - 0xc5c5c500c5c5c500ULL, 0x0b0b0b000b0b0b00ULL, 0x1a1a1a001a1a1a00ULL, - 0xa6a6a600a6a6a600ULL, 0xe1e1e100e1e1e100ULL, 0x3939390039393900ULL, - 0xcacaca00cacaca00ULL, 0xd5d5d500d5d5d500ULL, 0x4747470047474700ULL, - 0x5d5d5d005d5d5d00ULL, 0x3d3d3d003d3d3d00ULL, 0xd9d9d900d9d9d900ULL, - 0x0101010001010100ULL, 0x5a5a5a005a5a5a00ULL, 0xd6d6d600d6d6d600ULL, - 0x5151510051515100ULL, 0x5656560056565600ULL, 0x6c6c6c006c6c6c00ULL, - 0x4d4d4d004d4d4d00ULL, 0x8b8b8b008b8b8b00ULL, 0x0d0d0d000d0d0d00ULL, - 0x9a9a9a009a9a9a00ULL, 0x6666660066666600ULL, 0xfbfbfb00fbfbfb00ULL, - 0xcccccc00cccccc00ULL, 0xb0b0b000b0b0b000ULL, 0x2d2d2d002d2d2d00ULL, - 0x7474740074747400ULL, 0x1212120012121200ULL, 0x2b2b2b002b2b2b00ULL, - 0x2020200020202000ULL, 0xf0f0f000f0f0f000ULL, 0xb1b1b100b1b1b100ULL, - 0x8484840084848400ULL, 0x9999990099999900ULL, 0xdfdfdf00dfdfdf00ULL, - 0x4c4c4c004c4c4c00ULL, 0xcbcbcb00cbcbcb00ULL, 0xc2c2c200c2c2c200ULL, - 0x3434340034343400ULL, 0x7e7e7e007e7e7e00ULL, 0x7676760076767600ULL, - 0x0505050005050500ULL, 0x6d6d6d006d6d6d00ULL, 0xb7b7b700b7b7b700ULL, - 0xa9a9a900a9a9a900ULL, 0x3131310031313100ULL, 0xd1d1d100d1d1d100ULL, - 0x1717170017171700ULL, 0x0404040004040400ULL, 0xd7d7d700d7d7d700ULL, - 0x1414140014141400ULL, 0x5858580058585800ULL, 0x3a3a3a003a3a3a00ULL, - 0x6161610061616100ULL, 0xdedede00dedede00ULL, 0x1b1b1b001b1b1b00ULL, - 0x1111110011111100ULL, 0x1c1c1c001c1c1c00ULL, 0x3232320032323200ULL, - 0x0f0f0f000f0f0f00ULL, 0x9c9c9c009c9c9c00ULL, 0x1616160016161600ULL, - 0x5353530053535300ULL, 0x1818180018181800ULL, 0xf2f2f200f2f2f200ULL, - 0x2222220022222200ULL, 0xfefefe00fefefe00ULL, 0x4444440044444400ULL, - 0xcfcfcf00cfcfcf00ULL, 0xb2b2b200b2b2b200ULL, 0xc3c3c300c3c3c300ULL, - 0xb5b5b500b5b5b500ULL, 0x7a7a7a007a7a7a00ULL, 0x9191910091919100ULL, - 0x2424240024242400ULL, 0x0808080008080800ULL, 0xe8e8e800e8e8e800ULL, - 0xa8a8a800a8a8a800ULL, 0x6060600060606000ULL, 0xfcfcfc00fcfcfc00ULL, - 0x6969690069696900ULL, 0x5050500050505000ULL, 0xaaaaaa00aaaaaa00ULL, - 0xd0d0d000d0d0d000ULL, 0xa0a0a000a0a0a000ULL, 0x7d7d7d007d7d7d00ULL, - 0xa1a1a100a1a1a100ULL, 0x8989890089898900ULL, 0x6262620062626200ULL, - 0x9797970097979700ULL, 0x5454540054545400ULL, 0x5b5b5b005b5b5b00ULL, - 0x1e1e1e001e1e1e00ULL, 0x9595950095959500ULL, 0xe0e0e000e0e0e000ULL, - 0xffffff00ffffff00ULL, 0x6464640064646400ULL, 0xd2d2d200d2d2d200ULL, - 0x1010100010101000ULL, 0xc4c4c400c4c4c400ULL, 0x0000000000000000ULL, - 0x4848480048484800ULL, 0xa3a3a300a3a3a300ULL, 0xf7f7f700f7f7f700ULL, - 0x7575750075757500ULL, 0xdbdbdb00dbdbdb00ULL, 0x8a8a8a008a8a8a00ULL, - 0x0303030003030300ULL, 0xe6e6e600e6e6e600ULL, 0xdadada00dadada00ULL, - 0x0909090009090900ULL, 0x3f3f3f003f3f3f00ULL, 0xdddddd00dddddd00ULL, - 0x9494940094949400ULL, 0x8787870087878700ULL, 0x5c5c5c005c5c5c00ULL, - 0x8383830083838300ULL, 0x0202020002020200ULL, 0xcdcdcd00cdcdcd00ULL, - 0x4a4a4a004a4a4a00ULL, 0x9090900090909000ULL, 0x3333330033333300ULL, - 0x7373730073737300ULL, 0x6767670067676700ULL, 0xf6f6f600f6f6f600ULL, - 0xf3f3f300f3f3f300ULL, 0x9d9d9d009d9d9d00ULL, 0x7f7f7f007f7f7f00ULL, - 0xbfbfbf00bfbfbf00ULL, 0xe2e2e200e2e2e200ULL, 0x5252520052525200ULL, - 0x9b9b9b009b9b9b00ULL, 0xd8d8d800d8d8d800ULL, 0x2626260026262600ULL, - 0xc8c8c800c8c8c800ULL, 0x3737370037373700ULL, 0xc6c6c600c6c6c600ULL, - 0x3b3b3b003b3b3b00ULL, 0x8181810081818100ULL, 0x9696960096969600ULL, - 0x6f6f6f006f6f6f00ULL, 0x4b4b4b004b4b4b00ULL, 0x1313130013131300ULL, - 0xbebebe00bebebe00ULL, 0x6363630063636300ULL, 0x2e2e2e002e2e2e00ULL, - 0xe9e9e900e9e9e900ULL, 0x7979790079797900ULL, 0xa7a7a700a7a7a700ULL, - 0x8c8c8c008c8c8c00ULL, 0x9f9f9f009f9f9f00ULL, 0x6e6e6e006e6e6e00ULL, - 0xbcbcbc00bcbcbc00ULL, 0x8e8e8e008e8e8e00ULL, 0x2929290029292900ULL, - 0xf5f5f500f5f5f500ULL, 0xf9f9f900f9f9f900ULL, 0xb6b6b600b6b6b600ULL, - 0x2f2f2f002f2f2f00ULL, 0xfdfdfd00fdfdfd00ULL, 0xb4b4b400b4b4b400ULL, - 0x5959590059595900ULL, 0x7878780078787800ULL, 0x9898980098989800ULL, - 0x0606060006060600ULL, 0x6a6a6a006a6a6a00ULL, 0xe7e7e700e7e7e700ULL, - 0x4646460046464600ULL, 0x7171710071717100ULL, 0xbababa00bababa00ULL, - 0xd4d4d400d4d4d400ULL, 0x2525250025252500ULL, 0xababab00ababab00ULL, - 0x4242420042424200ULL, 0x8888880088888800ULL, 0xa2a2a200a2a2a200ULL, - 0x8d8d8d008d8d8d00ULL, 0xfafafa00fafafa00ULL, 0x7272720072727200ULL, - 0x0707070007070700ULL, 0xb9b9b900b9b9b900ULL, 0x5555550055555500ULL, - 0xf8f8f800f8f8f800ULL, 0xeeeeee00eeeeee00ULL, 0xacacac00acacac00ULL, - 0x0a0a0a000a0a0a00ULL, 0x3636360036363600ULL, 0x4949490049494900ULL, - 0x2a2a2a002a2a2a00ULL, 0x6868680068686800ULL, 0x3c3c3c003c3c3c00ULL, - 0x3838380038383800ULL, 0xf1f1f100f1f1f100ULL, 0xa4a4a400a4a4a400ULL, - 0x4040400040404000ULL, 0x2828280028282800ULL, 0xd3d3d300d3d3d300ULL, - 0x7b7b7b007b7b7b00ULL, 0xbbbbbb00bbbbbb00ULL, 0xc9c9c900c9c9c900ULL, - 0x4343430043434300ULL, 0xc1c1c100c1c1c100ULL, 0x1515150015151500ULL, - 0xe3e3e300e3e3e300ULL, 0xadadad00adadad00ULL, 0xf4f4f400f4f4f400ULL, - 0x7777770077777700ULL, 0xc7c7c700c7c7c700ULL, 0x8080800080808000ULL, - 0x9e9e9e009e9e9e00ULL, + 0x7070700070707000, 0x8282820082828200, 0x2c2c2c002c2c2c00, + 0xececec00ececec00, 0xb3b3b300b3b3b300, 0x2727270027272700, + 0xc0c0c000c0c0c000, 0xe5e5e500e5e5e500, 0xe4e4e400e4e4e400, + 0x8585850085858500, 0x5757570057575700, 0x3535350035353500, + 0xeaeaea00eaeaea00, 0x0c0c0c000c0c0c00, 0xaeaeae00aeaeae00, + 0x4141410041414100, 0x2323230023232300, 0xefefef00efefef00, + 0x6b6b6b006b6b6b00, 0x9393930093939300, 0x4545450045454500, + 0x1919190019191900, 0xa5a5a500a5a5a500, 0x2121210021212100, + 0xededed00ededed00, 0x0e0e0e000e0e0e00, 0x4f4f4f004f4f4f00, + 0x4e4e4e004e4e4e00, 0x1d1d1d001d1d1d00, 0x6565650065656500, + 0x9292920092929200, 0xbdbdbd00bdbdbd00, 0x8686860086868600, + 0xb8b8b800b8b8b800, 0xafafaf00afafaf00, 0x8f8f8f008f8f8f00, + 0x7c7c7c007c7c7c00, 0xebebeb00ebebeb00, 0x1f1f1f001f1f1f00, + 0xcecece00cecece00, 0x3e3e3e003e3e3e00, 0x3030300030303000, + 0xdcdcdc00dcdcdc00, 0x5f5f5f005f5f5f00, 0x5e5e5e005e5e5e00, + 0xc5c5c500c5c5c500, 0x0b0b0b000b0b0b00, 0x1a1a1a001a1a1a00, + 0xa6a6a600a6a6a600, 0xe1e1e100e1e1e100, 0x3939390039393900, + 0xcacaca00cacaca00, 0xd5d5d500d5d5d500, 0x4747470047474700, + 0x5d5d5d005d5d5d00, 0x3d3d3d003d3d3d00, 0xd9d9d900d9d9d900, + 0x0101010001010100, 0x5a5a5a005a5a5a00, 0xd6d6d600d6d6d600, + 0x5151510051515100, 0x5656560056565600, 0x6c6c6c006c6c6c00, + 0x4d4d4d004d4d4d00, 0x8b8b8b008b8b8b00, 0x0d0d0d000d0d0d00, + 0x9a9a9a009a9a9a00, 0x6666660066666600, 0xfbfbfb00fbfbfb00, + 0xcccccc00cccccc00, 0xb0b0b000b0b0b000, 0x2d2d2d002d2d2d00, + 0x7474740074747400, 0x1212120012121200, 0x2b2b2b002b2b2b00, + 0x2020200020202000, 0xf0f0f000f0f0f000, 0xb1b1b100b1b1b100, + 0x8484840084848400, 0x9999990099999900, 0xdfdfdf00dfdfdf00, + 0x4c4c4c004c4c4c00, 0xcbcbcb00cbcbcb00, 0xc2c2c200c2c2c200, + 0x3434340034343400, 0x7e7e7e007e7e7e00, 0x7676760076767600, + 0x0505050005050500, 0x6d6d6d006d6d6d00, 0xb7b7b700b7b7b700, + 0xa9a9a900a9a9a900, 0x3131310031313100, 0xd1d1d100d1d1d100, + 0x1717170017171700, 0x0404040004040400, 0xd7d7d700d7d7d700, + 0x1414140014141400, 0x5858580058585800, 0x3a3a3a003a3a3a00, + 0x6161610061616100, 0xdedede00dedede00, 0x1b1b1b001b1b1b00, + 0x1111110011111100, 0x1c1c1c001c1c1c00, 0x3232320032323200, + 0x0f0f0f000f0f0f00, 0x9c9c9c009c9c9c00, 0x1616160016161600, + 0x5353530053535300, 0x1818180018181800, 0xf2f2f200f2f2f200, + 0x2222220022222200, 0xfefefe00fefefe00, 0x4444440044444400, + 0xcfcfcf00cfcfcf00, 0xb2b2b200b2b2b200, 0xc3c3c300c3c3c300, + 0xb5b5b500b5b5b500, 0x7a7a7a007a7a7a00, 0x9191910091919100, + 0x2424240024242400, 0x0808080008080800, 0xe8e8e800e8e8e800, + 0xa8a8a800a8a8a800, 0x6060600060606000, 0xfcfcfc00fcfcfc00, + 0x6969690069696900, 0x5050500050505000, 0xaaaaaa00aaaaaa00, + 0xd0d0d000d0d0d000, 0xa0a0a000a0a0a000, 0x7d7d7d007d7d7d00, + 0xa1a1a100a1a1a100, 0x8989890089898900, 0x6262620062626200, + 0x9797970097979700, 0x5454540054545400, 0x5b5b5b005b5b5b00, + 0x1e1e1e001e1e1e00, 0x9595950095959500, 0xe0e0e000e0e0e000, + 0xffffff00ffffff00, 0x6464640064646400, 0xd2d2d200d2d2d200, + 0x1010100010101000, 0xc4c4c400c4c4c400, 0x0000000000000000, + 0x4848480048484800, 0xa3a3a300a3a3a300, 0xf7f7f700f7f7f700, + 0x7575750075757500, 0xdbdbdb00dbdbdb00, 0x8a8a8a008a8a8a00, + 0x0303030003030300, 0xe6e6e600e6e6e600, 0xdadada00dadada00, + 0x0909090009090900, 0x3f3f3f003f3f3f00, 0xdddddd00dddddd00, + 0x9494940094949400, 0x8787870087878700, 0x5c5c5c005c5c5c00, + 0x8383830083838300, 0x0202020002020200, 0xcdcdcd00cdcdcd00, + 0x4a4a4a004a4a4a00, 0x9090900090909000, 0x3333330033333300, + 0x7373730073737300, 0x6767670067676700, 0xf6f6f600f6f6f600, + 0xf3f3f300f3f3f300, 0x9d9d9d009d9d9d00, 0x7f7f7f007f7f7f00, + 0xbfbfbf00bfbfbf00, 0xe2e2e200e2e2e200, 0x5252520052525200, + 0x9b9b9b009b9b9b00, 0xd8d8d800d8d8d800, 0x2626260026262600, + 0xc8c8c800c8c8c800, 0x3737370037373700, 0xc6c6c600c6c6c600, + 0x3b3b3b003b3b3b00, 0x8181810081818100, 0x9696960096969600, + 0x6f6f6f006f6f6f00, 0x4b4b4b004b4b4b00, 0x1313130013131300, + 0xbebebe00bebebe00, 0x6363630063636300, 0x2e2e2e002e2e2e00, + 0xe9e9e900e9e9e900, 0x7979790079797900, 0xa7a7a700a7a7a700, + 0x8c8c8c008c8c8c00, 0x9f9f9f009f9f9f00, 0x6e6e6e006e6e6e00, + 0xbcbcbc00bcbcbc00, 0x8e8e8e008e8e8e00, 0x2929290029292900, + 0xf5f5f500f5f5f500, 0xf9f9f900f9f9f900, 0xb6b6b600b6b6b600, + 0x2f2f2f002f2f2f00, 0xfdfdfd00fdfdfd00, 0xb4b4b400b4b4b400, + 0x5959590059595900, 0x7878780078787800, 0x9898980098989800, + 0x0606060006060600, 0x6a6a6a006a6a6a00, 0xe7e7e700e7e7e700, + 0x4646460046464600, 0x7171710071717100, 0xbababa00bababa00, + 0xd4d4d400d4d4d400, 0x2525250025252500, 0xababab00ababab00, + 0x4242420042424200, 0x8888880088888800, 0xa2a2a200a2a2a200, + 0x8d8d8d008d8d8d00, 0xfafafa00fafafa00, 0x7272720072727200, + 0x0707070007070700, 0xb9b9b900b9b9b900, 0x5555550055555500, + 0xf8f8f800f8f8f800, 0xeeeeee00eeeeee00, 0xacacac00acacac00, + 0x0a0a0a000a0a0a00, 0x3636360036363600, 0x4949490049494900, + 0x2a2a2a002a2a2a00, 0x6868680068686800, 0x3c3c3c003c3c3c00, + 0x3838380038383800, 0xf1f1f100f1f1f100, 0xa4a4a400a4a4a400, + 0x4040400040404000, 0x2828280028282800, 0xd3d3d300d3d3d300, + 0x7b7b7b007b7b7b00, 0xbbbbbb00bbbbbb00, 0xc9c9c900c9c9c900, + 0x4343430043434300, 0xc1c1c100c1c1c100, 0x1515150015151500, + 0xe3e3e300e3e3e300, 0xadadad00adadad00, 0xf4f4f400f4f4f400, + 0x7777770077777700, 0xc7c7c700c7c7c700, 0x8080800080808000, + 0x9e9e9e009e9e9e00, }; /* key constants */ @@ -1601,6 +1601,7 @@ static struct crypto_alg camellia_algs[6] = { { .cra_ctxsize = sizeof(struct camellia_ctx), .cra_alignmask = 0, .cra_module = THIS_MODULE, + .cra_list = LIST_HEAD_INIT(camellia_algs[0].cra_list), .cra_u = { .cipher = { .cia_min_keysize = CAMELLIA_MIN_KEY_SIZE, @@ -1620,6 +1621,7 @@ static struct crypto_alg camellia_algs[6] = { { .cra_alignmask = 0, .cra_type = &crypto_blkcipher_type, .cra_module = THIS_MODULE, + .cra_list = LIST_HEAD_INIT(camellia_algs[1].cra_list), .cra_u = { .blkcipher = { .min_keysize = CAMELLIA_MIN_KEY_SIZE, @@ -1639,6 +1641,7 @@ static struct crypto_alg camellia_algs[6] = { { .cra_alignmask = 0, .cra_type = &crypto_blkcipher_type, .cra_module = THIS_MODULE, + .cra_list = LIST_HEAD_INIT(camellia_algs[2].cra_list), .cra_u = { .blkcipher = { .min_keysize = CAMELLIA_MIN_KEY_SIZE, @@ -1659,6 +1662,7 @@ static struct crypto_alg camellia_algs[6] = { { .cra_alignmask = 0, .cra_type = &crypto_blkcipher_type, .cra_module = THIS_MODULE, + .cra_list = LIST_HEAD_INIT(camellia_algs[3].cra_list), .cra_u = { .blkcipher = { .min_keysize = CAMELLIA_MIN_KEY_SIZE, @@ -1679,6 +1683,7 @@ static struct crypto_alg camellia_algs[6] = { { .cra_alignmask = 0, .cra_type = &crypto_blkcipher_type, .cra_module = THIS_MODULE, + .cra_list = LIST_HEAD_INIT(camellia_algs[4].cra_list), .cra_exit = lrw_exit_tfm, .cra_u = { .blkcipher = { @@ -1702,6 +1707,7 @@ static struct crypto_alg camellia_algs[6] = { { .cra_alignmask = 0, .cra_type = &crypto_blkcipher_type, .cra_module = THIS_MODULE, + .cra_list = LIST_HEAD_INIT(camellia_algs[5].cra_list), .cra_u = { .blkcipher = { .min_keysize = CAMELLIA_MIN_KEY_SIZE * 2, diff --git a/trunk/arch/x86/crypto/cast5-avx-x86_64-asm_64.S b/trunk/arch/x86/crypto/cast5-avx-x86_64-asm_64.S deleted file mode 100644 index a41a3aaba220..000000000000 --- a/trunk/arch/x86/crypto/cast5-avx-x86_64-asm_64.S +++ /dev/null @@ -1,376 +0,0 @@ -/* - * Cast5 Cipher 16-way parallel algorithm (AVX/x86_64) - * - * Copyright (C) 2012 Johannes Goetzfried - * - * - * Copyright © 2012 Jussi Kivilinna - * - * 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 - * - */ - -.file "cast5-avx-x86_64-asm_64.S" - -.extern cast5_s1 -.extern cast5_s2 -.extern cast5_s3 -.extern cast5_s4 - -/* structure of crypto context */ -#define km 0 -#define kr (16*4) -#define rr ((16*4)+16) - -/* s-boxes */ -#define s1 cast5_s1 -#define s2 cast5_s2 -#define s3 cast5_s3 -#define s4 cast5_s4 - -/********************************************************************** - 16-way AVX cast5 - **********************************************************************/ -#define CTX %rdi - -#define RL1 %xmm0 -#define RR1 %xmm1 -#define RL2 %xmm2 -#define RR2 %xmm3 -#define RL3 %xmm4 -#define RR3 %xmm5 -#define RL4 %xmm6 -#define RR4 %xmm7 - -#define RX %xmm8 - -#define RKM %xmm9 -#define RKR %xmm10 -#define RKRF %xmm11 -#define RKRR %xmm12 - -#define R32 %xmm13 -#define R1ST %xmm14 - -#define RTMP %xmm15 - -#define RID1 %rbp -#define RID1d %ebp -#define RID2 %rsi -#define RID2d %esi - -#define RGI1 %rdx -#define RGI1bl %dl -#define RGI1bh %dh -#define RGI2 %rcx -#define RGI2bl %cl -#define RGI2bh %ch - -#define RGI3 %rax -#define RGI3bl %al -#define RGI3bh %ah -#define RGI4 %rbx -#define RGI4bl %bl -#define RGI4bh %bh - -#define RFS1 %r8 -#define RFS1d %r8d -#define RFS2 %r9 -#define RFS2d %r9d -#define RFS3 %r10 -#define RFS3d %r10d - - -#define lookup_32bit(src, dst, op1, op2, op3, interleave_op, il_reg) \ - movzbl src ## bh, RID1d; \ - movzbl src ## bl, RID2d; \ - shrq $16, src; \ - movl s1(, RID1, 4), dst ## d; \ - op1 s2(, RID2, 4), dst ## d; \ - movzbl src ## bh, RID1d; \ - movzbl src ## bl, RID2d; \ - interleave_op(il_reg); \ - op2 s3(, RID1, 4), dst ## d; \ - op3 s4(, RID2, 4), dst ## d; - -#define dummy(d) /* do nothing */ - -#define shr_next(reg) \ - shrq $16, reg; - -#define F_head(a, x, gi1, gi2, op0) \ - op0 a, RKM, x; \ - vpslld RKRF, x, RTMP; \ - vpsrld RKRR, x, x; \ - vpor RTMP, x, x; \ - \ - vmovq x, gi1; \ - vpextrq $1, x, gi2; - -#define F_tail(a, x, gi1, gi2, op1, op2, op3) \ - lookup_32bit(##gi1, RFS1, op1, op2, op3, shr_next, ##gi1); \ - lookup_32bit(##gi2, RFS3, op1, op2, op3, shr_next, ##gi2); \ - \ - lookup_32bit(##gi1, RFS2, op1, op2, op3, dummy, none); \ - shlq $32, RFS2; \ - orq RFS1, RFS2; \ - lookup_32bit(##gi2, RFS1, op1, op2, op3, dummy, none); \ - shlq $32, RFS1; \ - orq RFS1, RFS3; \ - \ - vmovq RFS2, x; \ - vpinsrq $1, RFS3, x, x; - -#define F_2(a1, b1, a2, b2, op0, op1, op2, op3) \ - F_head(b1, RX, RGI1, RGI2, op0); \ - F_head(b2, RX, RGI3, RGI4, op0); \ - \ - F_tail(b1, RX, RGI1, RGI2, op1, op2, op3); \ - F_tail(b2, RTMP, RGI3, RGI4, op1, op2, op3); \ - \ - vpxor a1, RX, a1; \ - vpxor a2, RTMP, a2; - -#define F1_2(a1, b1, a2, b2) \ - F_2(a1, b1, a2, b2, vpaddd, xorl, subl, addl) -#define F2_2(a1, b1, a2, b2) \ - F_2(a1, b1, a2, b2, vpxor, subl, addl, xorl) -#define F3_2(a1, b1, a2, b2) \ - F_2(a1, b1, a2, b2, vpsubd, addl, xorl, subl) - -#define subround(a1, b1, a2, b2, f) \ - F ## f ## _2(a1, b1, a2, b2); - -#define round(l, r, n, f) \ - vbroadcastss (km+(4*n))(CTX), RKM; \ - vpand R1ST, RKR, RKRF; \ - vpsubq RKRF, R32, RKRR; \ - vpsrldq $1, RKR, RKR; \ - subround(l ## 1, r ## 1, l ## 2, r ## 2, f); \ - subround(l ## 3, r ## 3, l ## 4, r ## 4, f); - -#define enc_preload_rkr() \ - vbroadcastss .L16_mask, RKR; \ - /* add 16-bit rotation to key rotations (mod 32) */ \ - vpxor kr(CTX), RKR, RKR; - -#define dec_preload_rkr() \ - vbroadcastss .L16_mask, RKR; \ - /* add 16-bit rotation to key rotations (mod 32) */ \ - vpxor kr(CTX), RKR, RKR; \ - vpshufb .Lbswap128_mask, RKR, RKR; - -#define transpose_2x4(x0, x1, t0, t1) \ - vpunpckldq x1, x0, t0; \ - vpunpckhdq x1, x0, t1; \ - \ - vpunpcklqdq t1, t0, x0; \ - vpunpckhqdq t1, t0, x1; - -#define inpack_blocks(in, x0, x1, t0, t1, rmask) \ - vmovdqu (0*4*4)(in), x0; \ - vmovdqu (1*4*4)(in), x1; \ - vpshufb rmask, x0, x0; \ - vpshufb rmask, x1, x1; \ - \ - transpose_2x4(x0, x1, t0, t1) - -#define outunpack_blocks(out, x0, x1, t0, t1, rmask) \ - transpose_2x4(x0, x1, t0, t1) \ - \ - vpshufb rmask, x0, x0; \ - vpshufb rmask, x1, x1; \ - vmovdqu x0, (0*4*4)(out); \ - vmovdqu x1, (1*4*4)(out); - -#define outunpack_xor_blocks(out, x0, x1, t0, t1, rmask) \ - transpose_2x4(x0, x1, t0, t1) \ - \ - vpshufb rmask, x0, x0; \ - vpshufb rmask, x1, x1; \ - vpxor (0*4*4)(out), x0, x0; \ - vmovdqu x0, (0*4*4)(out); \ - vpxor (1*4*4)(out), x1, x1; \ - vmovdqu x1, (1*4*4)(out); - -.data - -.align 16 -.Lbswap_mask: - .byte 3, 2, 1, 0, 7, 6, 5, 4, 11, 10, 9, 8, 15, 14, 13, 12 -.Lbswap128_mask: - .byte 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0 -.L16_mask: - .byte 16, 16, 16, 16 -.L32_mask: - .byte 32, 0, 0, 0 -.Lfirst_mask: - .byte 0x1f, 0, 0, 0 - -.text - -.align 16 -.global __cast5_enc_blk_16way -.type __cast5_enc_blk_16way,@function; - -__cast5_enc_blk_16way: - /* input: - * %rdi: ctx, CTX - * %rsi: dst - * %rdx: src - * %rcx: bool, if true: xor output - */ - - pushq %rbp; - pushq %rbx; - pushq %rcx; - - vmovdqa .Lbswap_mask, RKM; - vmovd .Lfirst_mask, R1ST; - vmovd .L32_mask, R32; - enc_preload_rkr(); - - leaq 1*(2*4*4)(%rdx), %rax; - inpack_blocks(%rdx, RL1, RR1, RTMP, RX, RKM); - inpack_blocks(%rax, RL2, RR2, RTMP, RX, RKM); - leaq 2*(2*4*4)(%rdx), %rax; - inpack_blocks(%rax, RL3, RR3, RTMP, RX, RKM); - leaq 3*(2*4*4)(%rdx), %rax; - inpack_blocks(%rax, RL4, RR4, RTMP, RX, RKM); - - movq %rsi, %r11; - - round(RL, RR, 0, 1); - round(RR, RL, 1, 2); - round(RL, RR, 2, 3); - round(RR, RL, 3, 1); - round(RL, RR, 4, 2); - round(RR, RL, 5, 3); - round(RL, RR, 6, 1); - round(RR, RL, 7, 2); - round(RL, RR, 8, 3); - round(RR, RL, 9, 1); - round(RL, RR, 10, 2); - round(RR, RL, 11, 3); - - movzbl rr(CTX), %eax; - testl %eax, %eax; - jnz __skip_enc; - - round(RL, RR, 12, 1); - round(RR, RL, 13, 2); - round(RL, RR, 14, 3); - round(RR, RL, 15, 1); - -__skip_enc: - popq %rcx; - popq %rbx; - popq %rbp; - - vmovdqa .Lbswap_mask, RKM; - leaq 1*(2*4*4)(%r11), %rax; - - testb %cl, %cl; - jnz __enc_xor16; - - outunpack_blocks(%r11, RR1, RL1, RTMP, RX, RKM); - outunpack_blocks(%rax, RR2, RL2, RTMP, RX, RKM); - leaq 2*(2*4*4)(%r11), %rax; - outunpack_blocks(%rax, RR3, RL3, RTMP, RX, RKM); - leaq 3*(2*4*4)(%r11), %rax; - outunpack_blocks(%rax, RR4, RL4, RTMP, RX, RKM); - - ret; - -__enc_xor16: - outunpack_xor_blocks(%r11, RR1, RL1, RTMP, RX, RKM); - outunpack_xor_blocks(%rax, RR2, RL2, RTMP, RX, RKM); - leaq 2*(2*4*4)(%r11), %rax; - outunpack_xor_blocks(%rax, RR3, RL3, RTMP, RX, RKM); - leaq 3*(2*4*4)(%r11), %rax; - outunpack_xor_blocks(%rax, RR4, RL4, RTMP, RX, RKM); - - ret; - -.align 16 -.global cast5_dec_blk_16way -.type cast5_dec_blk_16way,@function; - -cast5_dec_blk_16way: - /* input: - * %rdi: ctx, CTX - * %rsi: dst - * %rdx: src - */ - - pushq %rbp; - pushq %rbx; - - vmovdqa .Lbswap_mask, RKM; - vmovd .Lfirst_mask, R1ST; - vmovd .L32_mask, R32; - dec_preload_rkr(); - - leaq 1*(2*4*4)(%rdx), %rax; - inpack_blocks(%rdx, RL1, RR1, RTMP, RX, RKM); - inpack_blocks(%rax, RL2, RR2, RTMP, RX, RKM); - leaq 2*(2*4*4)(%rdx), %rax; - inpack_blocks(%rax, RL3, RR3, RTMP, RX, RKM); - leaq 3*(2*4*4)(%rdx), %rax; - inpack_blocks(%rax, RL4, RR4, RTMP, RX, RKM); - - movq %rsi, %r11; - - movzbl rr(CTX), %eax; - testl %eax, %eax; - jnz __skip_dec; - - round(RL, RR, 15, 1); - round(RR, RL, 14, 3); - round(RL, RR, 13, 2); - round(RR, RL, 12, 1); - -__dec_tail: - round(RL, RR, 11, 3); - round(RR, RL, 10, 2); - round(RL, RR, 9, 1); - round(RR, RL, 8, 3); - round(RL, RR, 7, 2); - round(RR, RL, 6, 1); - round(RL, RR, 5, 3); - round(RR, RL, 4, 2); - round(RL, RR, 3, 1); - round(RR, RL, 2, 3); - round(RL, RR, 1, 2); - round(RR, RL, 0, 1); - - vmovdqa .Lbswap_mask, RKM; - popq %rbx; - popq %rbp; - - leaq 1*(2*4*4)(%r11), %rax; - outunpack_blocks(%r11, RR1, RL1, RTMP, RX, RKM); - outunpack_blocks(%rax, RR2, RL2, RTMP, RX, RKM); - leaq 2*(2*4*4)(%r11), %rax; - outunpack_blocks(%rax, RR3, RL3, RTMP, RX, RKM); - leaq 3*(2*4*4)(%r11), %rax; - outunpack_blocks(%rax, RR4, RL4, RTMP, RX, RKM); - - ret; - -__skip_dec: - vpsrldq $4, RKR, RKR; - jmp __dec_tail; diff --git a/trunk/arch/x86/crypto/cast5_avx_glue.c b/trunk/arch/x86/crypto/cast5_avx_glue.c deleted file mode 100644 index e0ea14f9547f..000000000000 --- a/trunk/arch/x86/crypto/cast5_avx_glue.c +++ /dev/null @@ -1,530 +0,0 @@ -/* - * Glue Code for the AVX assembler implemention of the Cast5 Cipher - * - * Copyright (C) 2012 Johannes Goetzfried - * - * - * 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 -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#define CAST5_PARALLEL_BLOCKS 16 - -asmlinkage void __cast5_enc_blk_16way(struct cast5_ctx *ctx, u8 *dst, - const u8 *src, bool xor); -asmlinkage void cast5_dec_blk_16way(struct cast5_ctx *ctx, u8 *dst, - const u8 *src); - -static inline void cast5_enc_blk_xway(struct cast5_ctx *ctx, u8 *dst, - const u8 *src) -{ - __cast5_enc_blk_16way(ctx, dst, src, false); -} - -static inline void cast5_enc_blk_xway_xor(struct cast5_ctx *ctx, u8 *dst, - const u8 *src) -{ - __cast5_enc_blk_16way(ctx, dst, src, true); -} - -static inline void cast5_dec_blk_xway(struct cast5_ctx *ctx, u8 *dst, - const u8 *src) -{ - cast5_dec_blk_16way(ctx, dst, src); -} - - -static inline bool cast5_fpu_begin(bool fpu_enabled, unsigned int nbytes) -{ - return glue_fpu_begin(CAST5_BLOCK_SIZE, CAST5_PARALLEL_BLOCKS, - NULL, fpu_enabled, nbytes); -} - -static inline void cast5_fpu_end(bool fpu_enabled) -{ - return glue_fpu_end(fpu_enabled); -} - -static int ecb_crypt(struct blkcipher_desc *desc, struct blkcipher_walk *walk, - bool enc) -{ - bool fpu_enabled = false; - struct cast5_ctx *ctx = crypto_blkcipher_ctx(desc->tfm); - const unsigned int bsize = CAST5_BLOCK_SIZE; - unsigned int nbytes; - int err; - - err = blkcipher_walk_virt(desc, walk); - desc->flags &= ~CRYPTO_TFM_REQ_MAY_SLEEP; - - while ((nbytes = walk->nbytes)) { - u8 *wsrc = walk->src.virt.addr; - u8 *wdst = walk->dst.virt.addr; - - fpu_enabled = cast5_fpu_begin(fpu_enabled, nbytes); - - /* Process multi-block batch */ - if (nbytes >= bsize * CAST5_PARALLEL_BLOCKS) { - do { - if (enc) - cast5_enc_blk_xway(ctx, wdst, wsrc); - else - cast5_dec_blk_xway(ctx, wdst, wsrc); - - wsrc += bsize * CAST5_PARALLEL_BLOCKS; - wdst += bsize * CAST5_PARALLEL_BLOCKS; - nbytes -= bsize * CAST5_PARALLEL_BLOCKS; - } while (nbytes >= bsize * CAST5_PARALLEL_BLOCKS); - - if (nbytes < bsize) - goto done; - } - - /* Handle leftovers */ - do { - if (enc) - __cast5_encrypt(ctx, wdst, wsrc); - else - __cast5_decrypt(ctx, wdst, wsrc); - - wsrc += bsize; - wdst += bsize; - nbytes -= bsize; - } while (nbytes >= bsize); - -done: - err = blkcipher_walk_done(desc, walk, nbytes); - } - - cast5_fpu_end(fpu_enabled); - return err; -} - -static int ecb_encrypt(struct blkcipher_desc *desc, struct scatterlist *dst, - struct scatterlist *src, unsigned int nbytes) -{ - struct blkcipher_walk walk; - - blkcipher_walk_init(&walk, dst, src, nbytes); - return ecb_crypt(desc, &walk, true); -} - -static int ecb_decrypt(struct blkcipher_desc *desc, struct scatterlist *dst, - struct scatterlist *src, unsigned int nbytes) -{ - struct blkcipher_walk walk; - - blkcipher_walk_init(&walk, dst, src, nbytes); - return ecb_crypt(desc, &walk, false); -} - -static unsigned int __cbc_encrypt(struct blkcipher_desc *desc, - struct blkcipher_walk *walk) -{ - struct cast5_ctx *ctx = crypto_blkcipher_ctx(desc->tfm); - const unsigned int bsize = CAST5_BLOCK_SIZE; - unsigned int nbytes = walk->nbytes; - u64 *src = (u64 *)walk->src.virt.addr; - u64 *dst = (u64 *)walk->dst.virt.addr; - u64 *iv = (u64 *)walk->iv; - - do { - *dst = *src ^ *iv; - __cast5_encrypt(ctx, (u8 *)dst, (u8 *)dst); - iv = dst; - - src += 1; - dst += 1; - nbytes -= bsize; - } while (nbytes >= bsize); - - *(u64 *)walk->iv = *iv; - return nbytes; -} - -static int cbc_encrypt(struct blkcipher_desc *desc, struct scatterlist *dst, - struct scatterlist *src, unsigned int nbytes) -{ - struct blkcipher_walk walk; - int err; - - blkcipher_walk_init(&walk, dst, src, nbytes); - err = blkcipher_walk_virt(desc, &walk); - - while ((nbytes = walk.nbytes)) { - nbytes = __cbc_encrypt(desc, &walk); - err = blkcipher_walk_done(desc, &walk, nbytes); - } - - return err; -} - -static unsigned int __cbc_decrypt(struct blkcipher_desc *desc, - struct blkcipher_walk *walk) -{ - struct cast5_ctx *ctx = crypto_blkcipher_ctx(desc->tfm); - const unsigned int bsize = CAST5_BLOCK_SIZE; - unsigned int nbytes = walk->nbytes; - u64 *src = (u64 *)walk->src.virt.addr; - u64 *dst = (u64 *)walk->dst.virt.addr; - u64 ivs[CAST5_PARALLEL_BLOCKS - 1]; - u64 last_iv; - int i; - - /* Start of the last block. */ - src += nbytes / bsize - 1; - dst += nbytes / bsize - 1; - - last_iv = *src; - - /* Process multi-block batch */ - if (nbytes >= bsize * CAST5_PARALLEL_BLOCKS) { - do { - nbytes -= bsize * (CAST5_PARALLEL_BLOCKS - 1); - src -= CAST5_PARALLEL_BLOCKS - 1; - dst -= CAST5_PARALLEL_BLOCKS - 1; - - for (i = 0; i < CAST5_PARALLEL_BLOCKS - 1; i++) - ivs[i] = src[i]; - - cast5_dec_blk_xway(ctx, (u8 *)dst, (u8 *)src); - - for (i = 0; i < CAST5_PARALLEL_BLOCKS - 1; i++) - *(dst + (i + 1)) ^= *(ivs + i); - - nbytes -= bsize; - if (nbytes < bsize) - goto done; - - *dst ^= *(src - 1); - src -= 1; - dst -= 1; - } while (nbytes >= bsize * CAST5_PARALLEL_BLOCKS); - - if (nbytes < bsize) - goto done; - } - - /* Handle leftovers */ - for (;;) { - __cast5_decrypt(ctx, (u8 *)dst, (u8 *)src); - - nbytes -= bsize; - if (nbytes < bsize) - break; - - *dst ^= *(src - 1); - src -= 1; - dst -= 1; - } - -done: - *dst ^= *(u64 *)walk->iv; - *(u64 *)walk->iv = last_iv; - - return nbytes; -} - -static int cbc_decrypt(struct blkcipher_desc *desc, struct scatterlist *dst, - struct scatterlist *src, unsigned int nbytes) -{ - bool fpu_enabled = false; - struct blkcipher_walk walk; - int err; - - blkcipher_walk_init(&walk, dst, src, nbytes); - err = blkcipher_walk_virt(desc, &walk); - desc->flags &= ~CRYPTO_TFM_REQ_MAY_SLEEP; - - while ((nbytes = walk.nbytes)) { - fpu_enabled = cast5_fpu_begin(fpu_enabled, nbytes); - nbytes = __cbc_decrypt(desc, &walk); - err = blkcipher_walk_done(desc, &walk, nbytes); - } - - cast5_fpu_end(fpu_enabled); - return err; -} - -static void ctr_crypt_final(struct blkcipher_desc *desc, - struct blkcipher_walk *walk) -{ - struct cast5_ctx *ctx = crypto_blkcipher_ctx(desc->tfm); - u8 *ctrblk = walk->iv; - u8 keystream[CAST5_BLOCK_SIZE]; - u8 *src = walk->src.virt.addr; - u8 *dst = walk->dst.virt.addr; - unsigned int nbytes = walk->nbytes; - - __cast5_encrypt(ctx, keystream, ctrblk); - crypto_xor(keystream, src, nbytes); - memcpy(dst, keystream, nbytes); - - crypto_inc(ctrblk, CAST5_BLOCK_SIZE); -} - -static unsigned int __ctr_crypt(struct blkcipher_desc *desc, - struct blkcipher_walk *walk) -{ - struct cast5_ctx *ctx = crypto_blkcipher_ctx(desc->tfm); - const unsigned int bsize = CAST5_BLOCK_SIZE; - unsigned int nbytes = walk->nbytes; - u64 *src = (u64 *)walk->src.virt.addr; - u64 *dst = (u64 *)walk->dst.virt.addr; - u64 ctrblk = be64_to_cpu(*(__be64 *)walk->iv); - __be64 ctrblocks[CAST5_PARALLEL_BLOCKS]; - int i; - - /* Process multi-block batch */ - if (nbytes >= bsize * CAST5_PARALLEL_BLOCKS) { - do { - /* create ctrblks for parallel encrypt */ - for (i = 0; i < CAST5_PARALLEL_BLOCKS; i++) { - if (dst != src) - dst[i] = src[i]; - - ctrblocks[i] = cpu_to_be64(ctrblk++); - } - - cast5_enc_blk_xway_xor(ctx, (u8 *)dst, - (u8 *)ctrblocks); - - src += CAST5_PARALLEL_BLOCKS; - dst += CAST5_PARALLEL_BLOCKS; - nbytes -= bsize * CAST5_PARALLEL_BLOCKS; - } while (nbytes >= bsize * CAST5_PARALLEL_BLOCKS); - - if (nbytes < bsize) - goto done; - } - - /* Handle leftovers */ - do { - if (dst != src) - *dst = *src; - - ctrblocks[0] = cpu_to_be64(ctrblk++); - - __cast5_encrypt(ctx, (u8 *)ctrblocks, (u8 *)ctrblocks); - *dst ^= ctrblocks[0]; - - src += 1; - dst += 1; - nbytes -= bsize; - } while (nbytes >= bsize); - -done: - *(__be64 *)walk->iv = cpu_to_be64(ctrblk); - return nbytes; -} - -static int ctr_crypt(struct blkcipher_desc *desc, struct scatterlist *dst, - struct scatterlist *src, unsigned int nbytes) -{ - bool fpu_enabled = false; - struct blkcipher_walk walk; - int err; - - blkcipher_walk_init(&walk, dst, src, nbytes); - err = blkcipher_walk_virt_block(desc, &walk, CAST5_BLOCK_SIZE); - desc->flags &= ~CRYPTO_TFM_REQ_MAY_SLEEP; - - while ((nbytes = walk.nbytes) >= CAST5_BLOCK_SIZE) { - fpu_enabled = cast5_fpu_begin(fpu_enabled, nbytes); - nbytes = __ctr_crypt(desc, &walk); - err = blkcipher_walk_done(desc, &walk, nbytes); - } - - cast5_fpu_end(fpu_enabled); - - if (walk.nbytes) { - ctr_crypt_final(desc, &walk); - err = blkcipher_walk_done(desc, &walk, 0); - } - - return err; -} - - -static struct crypto_alg cast5_algs[6] = { { - .cra_name = "__ecb-cast5-avx", - .cra_driver_name = "__driver-ecb-cast5-avx", - .cra_priority = 0, - .cra_flags = CRYPTO_ALG_TYPE_BLKCIPHER, - .cra_blocksize = CAST5_BLOCK_SIZE, - .cra_ctxsize = sizeof(struct cast5_ctx), - .cra_alignmask = 0, - .cra_type = &crypto_blkcipher_type, - .cra_module = THIS_MODULE, - .cra_u = { - .blkcipher = { - .min_keysize = CAST5_MIN_KEY_SIZE, - .max_keysize = CAST5_MAX_KEY_SIZE, - .setkey = cast5_setkey, - .encrypt = ecb_encrypt, - .decrypt = ecb_decrypt, - }, - }, -}, { - .cra_name = "__cbc-cast5-avx", - .cra_driver_name = "__driver-cbc-cast5-avx", - .cra_priority = 0, - .cra_flags = CRYPTO_ALG_TYPE_BLKCIPHER, - .cra_blocksize = CAST5_BLOCK_SIZE, - .cra_ctxsize = sizeof(struct cast5_ctx), - .cra_alignmask = 0, - .cra_type = &crypto_blkcipher_type, - .cra_module = THIS_MODULE, - .cra_u = { - .blkcipher = { - .min_keysize = CAST5_MIN_KEY_SIZE, - .max_keysize = CAST5_MAX_KEY_SIZE, - .setkey = cast5_setkey, - .encrypt = cbc_encrypt, - .decrypt = cbc_decrypt, - }, - }, -}, { - .cra_name = "__ctr-cast5-avx", - .cra_driver_name = "__driver-ctr-cast5-avx", - .cra_priority = 0, - .cra_flags = CRYPTO_ALG_TYPE_BLKCIPHER, - .cra_blocksize = 1, - .cra_ctxsize = sizeof(struct cast5_ctx), - .cra_alignmask = 0, - .cra_type = &crypto_blkcipher_type, - .cra_module = THIS_MODULE, - .cra_u = { - .blkcipher = { - .min_keysize = CAST5_MIN_KEY_SIZE, - .max_keysize = CAST5_MAX_KEY_SIZE, - .ivsize = CAST5_BLOCK_SIZE, - .setkey = cast5_setkey, - .encrypt = ctr_crypt, - .decrypt = ctr_crypt, - }, - }, -}, { - .cra_name = "ecb(cast5)", - .cra_driver_name = "ecb-cast5-avx", - .cra_priority = 200, - .cra_flags = CRYPTO_ALG_TYPE_ABLKCIPHER | CRYPTO_ALG_ASYNC, - .cra_blocksize = CAST5_BLOCK_SIZE, - .cra_ctxsize = sizeof(struct async_helper_ctx), - .cra_alignmask = 0, - .cra_type = &crypto_ablkcipher_type, - .cra_module = THIS_MODULE, - .cra_init = ablk_init, - .cra_exit = ablk_exit, - .cra_u = { - .ablkcipher = { - .min_keysize = CAST5_MIN_KEY_SIZE, - .max_keysize = CAST5_MAX_KEY_SIZE, - .setkey = ablk_set_key, - .encrypt = ablk_encrypt, - .decrypt = ablk_decrypt, - }, - }, -}, { - .cra_name = "cbc(cast5)", - .cra_driver_name = "cbc-cast5-avx", - .cra_priority = 200, - .cra_flags = CRYPTO_ALG_TYPE_ABLKCIPHER | CRYPTO_ALG_ASYNC, - .cra_blocksize = CAST5_BLOCK_SIZE, - .cra_ctxsize = sizeof(struct async_helper_ctx), - .cra_alignmask = 0, - .cra_type = &crypto_ablkcipher_type, - .cra_module = THIS_MODULE, - .cra_init = ablk_init, - .cra_exit = ablk_exit, - .cra_u = { - .ablkcipher = { - .min_keysize = CAST5_MIN_KEY_SIZE, - .max_keysize = CAST5_MAX_KEY_SIZE, - .ivsize = CAST5_BLOCK_SIZE, - .setkey = ablk_set_key, - .encrypt = __ablk_encrypt, - .decrypt = ablk_decrypt, - }, - }, -}, { - .cra_name = "ctr(cast5)", - .cra_driver_name = "ctr-cast5-avx", - .cra_priority = 200, - .cra_flags = CRYPTO_ALG_TYPE_ABLKCIPHER | CRYPTO_ALG_ASYNC, - .cra_blocksize = 1, - .cra_ctxsize = sizeof(struct async_helper_ctx), - .cra_alignmask = 0, - .cra_type = &crypto_ablkcipher_type, - .cra_module = THIS_MODULE, - .cra_init = ablk_init, - .cra_exit = ablk_exit, - .cra_u = { - .ablkcipher = { - .min_keysize = CAST5_MIN_KEY_SIZE, - .max_keysize = CAST5_MAX_KEY_SIZE, - .ivsize = CAST5_BLOCK_SIZE, - .setkey = ablk_set_key, - .encrypt = ablk_encrypt, - .decrypt = ablk_encrypt, - .geniv = "chainiv", - }, - }, -} }; - -static int __init cast5_init(void) -{ - u64 xcr0; - - if (!cpu_has_avx || !cpu_has_osxsave) { - pr_info("AVX instructions are not detected.\n"); - return -ENODEV; - } - - xcr0 = xgetbv(XCR_XFEATURE_ENABLED_MASK); - if ((xcr0 & (XSTATE_SSE | XSTATE_YMM)) != (XSTATE_SSE | XSTATE_YMM)) { - pr_info("AVX detected but unusable.\n"); - return -ENODEV; - } - - return crypto_register_algs(cast5_algs, ARRAY_SIZE(cast5_algs)); -} - -static void __exit cast5_exit(void) -{ - crypto_unregister_algs(cast5_algs, ARRAY_SIZE(cast5_algs)); -} - -module_init(cast5_init); -module_exit(cast5_exit); - -MODULE_DESCRIPTION("Cast5 Cipher Algorithm, AVX optimized"); -MODULE_LICENSE("GPL"); -MODULE_ALIAS("cast5"); diff --git a/trunk/arch/x86/crypto/cast6-avx-x86_64-asm_64.S b/trunk/arch/x86/crypto/cast6-avx-x86_64-asm_64.S deleted file mode 100644 index 218d283772f4..000000000000 --- a/trunk/arch/x86/crypto/cast6-avx-x86_64-asm_64.S +++ /dev/null @@ -1,383 +0,0 @@ -/* - * Cast6 Cipher 8-way parallel algorithm (AVX/x86_64) - * - * Copyright (C) 2012 Johannes Goetzfried - * - * - * Copyright © 2012 Jussi Kivilinna - * - * 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 - * - */ - -.file "cast6-avx-x86_64-asm_64.S" - -.extern cast6_s1 -.extern cast6_s2 -.extern cast6_s3 -.extern cast6_s4 - -/* structure of crypto context */ -#define km 0 -#define kr (12*4*4) - -/* s-boxes */ -#define s1 cast6_s1 -#define s2 cast6_s2 -#define s3 cast6_s3 -#define s4 cast6_s4 - -/********************************************************************** - 8-way AVX cast6 - **********************************************************************/ -#define CTX %rdi - -#define RA1 %xmm0 -#define RB1 %xmm1 -#define RC1 %xmm2 -#define RD1 %xmm3 - -#define RA2 %xmm4 -#define RB2 %xmm5 -#define RC2 %xmm6 -#define RD2 %xmm7 - -#define RX %xmm8 - -#define RKM %xmm9 -#define RKR %xmm10 -#define RKRF %xmm11 -#define RKRR %xmm12 -#define R32 %xmm13 -#define R1ST %xmm14 - -#define RTMP %xmm15 - -#define RID1 %rbp -#define RID1d %ebp -#define RID2 %rsi -#define RID2d %esi - -#define RGI1 %rdx -#define RGI1bl %dl -#define RGI1bh %dh -#define RGI2 %rcx -#define RGI2bl %cl -#define RGI2bh %ch - -#define RGI3 %rax -#define RGI3bl %al -#define RGI3bh %ah -#define RGI4 %rbx -#define RGI4bl %bl -#define RGI4bh %bh - -#define RFS1 %r8 -#define RFS1d %r8d -#define RFS2 %r9 -#define RFS2d %r9d -#define RFS3 %r10 -#define RFS3d %r10d - - -#define lookup_32bit(src, dst, op1, op2, op3, interleave_op, il_reg) \ - movzbl src ## bh, RID1d; \ - movzbl src ## bl, RID2d; \ - shrq $16, src; \ - movl s1(, RID1, 4), dst ## d; \ - op1 s2(, RID2, 4), dst ## d; \ - movzbl src ## bh, RID1d; \ - movzbl src ## bl, RID2d; \ - interleave_op(il_reg); \ - op2 s3(, RID1, 4), dst ## d; \ - op3 s4(, RID2, 4), dst ## d; - -#define dummy(d) /* do nothing */ - -#define shr_next(reg) \ - shrq $16, reg; - -#define F_head(a, x, gi1, gi2, op0) \ - op0 a, RKM, x; \ - vpslld RKRF, x, RTMP; \ - vpsrld RKRR, x, x; \ - vpor RTMP, x, x; \ - \ - vmovq x, gi1; \ - vpextrq $1, x, gi2; - -#define F_tail(a, x, gi1, gi2, op1, op2, op3) \ - lookup_32bit(##gi1, RFS1, op1, op2, op3, shr_next, ##gi1); \ - lookup_32bit(##gi2, RFS3, op1, op2, op3, shr_next, ##gi2); \ - \ - lookup_32bit(##gi1, RFS2, op1, op2, op3, dummy, none); \ - shlq $32, RFS2; \ - orq RFS1, RFS2; \ - lookup_32bit(##gi2, RFS1, op1, op2, op3, dummy, none); \ - shlq $32, RFS1; \ - orq RFS1, RFS3; \ - \ - vmovq RFS2, x; \ - vpinsrq $1, RFS3, x, x; - -#define F_2(a1, b1, a2, b2, op0, op1, op2, op3) \ - F_head(b1, RX, RGI1, RGI2, op0); \ - F_head(b2, RX, RGI3, RGI4, op0); \ - \ - F_tail(b1, RX, RGI1, RGI2, op1, op2, op3); \ - F_tail(b2, RTMP, RGI3, RGI4, op1, op2, op3); \ - \ - vpxor a1, RX, a1; \ - vpxor a2, RTMP, a2; - -#define F1_2(a1, b1, a2, b2) \ - F_2(a1, b1, a2, b2, vpaddd, xorl, subl, addl) -#define F2_2(a1, b1, a2, b2) \ - F_2(a1, b1, a2, b2, vpxor, subl, addl, xorl) -#define F3_2(a1, b1, a2, b2) \ - F_2(a1, b1, a2, b2, vpsubd, addl, xorl, subl) - -#define qop(in, out, f) \ - F ## f ## _2(out ## 1, in ## 1, out ## 2, in ## 2); - -#define get_round_keys(nn) \ - vbroadcastss (km+(4*(nn)))(CTX), RKM; \ - vpand R1ST, RKR, RKRF; \ - vpsubq RKRF, R32, RKRR; \ - vpsrldq $1, RKR, RKR; - -#define Q(n) \ - get_round_keys(4*n+0); \ - qop(RD, RC, 1); \ - \ - get_round_keys(4*n+1); \ - qop(RC, RB, 2); \ - \ - get_round_keys(4*n+2); \ - qop(RB, RA, 3); \ - \ - get_round_keys(4*n+3); \ - qop(RA, RD, 1); - -#define QBAR(n) \ - get_round_keys(4*n+3); \ - qop(RA, RD, 1); \ - \ - get_round_keys(4*n+2); \ - qop(RB, RA, 3); \ - \ - get_round_keys(4*n+1); \ - qop(RC, RB, 2); \ - \ - get_round_keys(4*n+0); \ - qop(RD, RC, 1); - -#define shuffle(mask) \ - vpshufb mask, RKR, RKR; - -#define preload_rkr(n, do_mask, mask) \ - vbroadcastss .L16_mask, RKR; \ - /* add 16-bit rotation to key rotations (mod 32) */ \ - vpxor (kr+n*16)(CTX), RKR, RKR; \ - do_mask(mask); - -#define transpose_4x4(x0, x1, x2, x3, t0, t1, t2) \ - vpunpckldq x1, x0, t0; \ - vpunpckhdq x1, x0, t2; \ - vpunpckldq x3, x2, t1; \ - vpunpckhdq x3, x2, x3; \ - \ - vpunpcklqdq t1, t0, x0; \ - vpunpckhqdq t1, t0, x1; \ - vpunpcklqdq x3, t2, x2; \ - vpunpckhqdq x3, t2, x3; - -#define inpack_blocks(in, x0, x1, x2, x3, t0, t1, t2, rmask) \ - vmovdqu (0*4*4)(in), x0; \ - vmovdqu (1*4*4)(in), x1; \ - vmovdqu (2*4*4)(in), x2; \ - vmovdqu (3*4*4)(in), x3; \ - vpshufb rmask, x0, x0; \ - vpshufb rmask, x1, x1; \ - vpshufb rmask, x2, x2; \ - vpshufb rmask, x3, x3; \ - \ - transpose_4x4(x0, x1, x2, x3, t0, t1, t2) - -#define outunpack_blocks(out, x0, x1, x2, x3, t0, t1, t2, rmask) \ - transpose_4x4(x0, x1, x2, x3, t0, t1, t2) \ - \ - vpshufb rmask, x0, x0; \ - vpshufb rmask, x1, x1; \ - vpshufb rmask, x2, x2; \ - vpshufb rmask, x3, x3; \ - vmovdqu x0, (0*4*4)(out); \ - vmovdqu x1, (1*4*4)(out); \ - vmovdqu x2, (2*4*4)(out); \ - vmovdqu x3, (3*4*4)(out); - -#define outunpack_xor_blocks(out, x0, x1, x2, x3, t0, t1, t2, rmask) \ - transpose_4x4(x0, x1, x2, x3, t0, t1, t2) \ - \ - vpshufb rmask, x0, x0; \ - vpshufb rmask, x1, x1; \ - vpshufb rmask, x2, x2; \ - vpshufb rmask, x3, x3; \ - vpxor (0*4*4)(out), x0, x0; \ - vmovdqu x0, (0*4*4)(out); \ - vpxor (1*4*4)(out), x1, x1; \ - vmovdqu x1, (1*4*4)(out); \ - vpxor (2*4*4)(out), x2, x2; \ - vmovdqu x2, (2*4*4)(out); \ - vpxor (3*4*4)(out), x3, x3; \ - vmovdqu x3, (3*4*4)(out); - -.data - -.align 16 -.Lbswap_mask: - .byte 3, 2, 1, 0, 7, 6, 5, 4, 11, 10, 9, 8, 15, 14, 13, 12 -.Lrkr_enc_Q_Q_QBAR_QBAR: - .byte 0, 1, 2, 3, 4, 5, 6, 7, 11, 10, 9, 8, 15, 14, 13, 12 -.Lrkr_enc_QBAR_QBAR_QBAR_QBAR: - .byte 3, 2, 1, 0, 7, 6, 5, 4, 11, 10, 9, 8, 15, 14, 13, 12 -.Lrkr_dec_Q_Q_Q_Q: - .byte 12, 13, 14, 15, 8, 9, 10, 11, 4, 5, 6, 7, 0, 1, 2, 3 -.Lrkr_dec_Q_Q_QBAR_QBAR: - .byte 12, 13, 14, 15, 8, 9, 10, 11, 7, 6, 5, 4, 3, 2, 1, 0 -.Lrkr_dec_QBAR_QBAR_QBAR_QBAR: - .byte 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0 -.L16_mask: - .byte 16, 16, 16, 16 -.L32_mask: - .byte 32, 0, 0, 0 -.Lfirst_mask: - .byte 0x1f, 0, 0, 0 - -.text - -.align 16 -.global __cast6_enc_blk_8way -.type __cast6_enc_blk_8way,@function; - -__cast6_enc_blk_8way: - /* input: - * %rdi: ctx, CTX - * %rsi: dst - * %rdx: src - * %rcx: bool, if true: xor output - */ - - pushq %rbp; - pushq %rbx; - pushq %rcx; - - vmovdqa .Lbswap_mask, RKM; - vmovd .Lfirst_mask, R1ST; - vmovd .L32_mask, R32; - - leaq (4*4*4)(%rdx), %rax; - inpack_blocks(%rdx, RA1, RB1, RC1, RD1, RTMP, RX, RKRF, RKM); - inpack_blocks(%rax, RA2, RB2, RC2, RD2, RTMP, RX, RKRF, RKM); - - movq %rsi, %r11; - - preload_rkr(0, dummy, none); - Q(0); - Q(1); - Q(2); - Q(3); - preload_rkr(1, shuffle, .Lrkr_enc_Q_Q_QBAR_QBAR); - Q(4); - Q(5); - QBAR(6); - QBAR(7); - preload_rkr(2, shuffle, .Lrkr_enc_QBAR_QBAR_QBAR_QBAR); - QBAR(8); - QBAR(9); - QBAR(10); - QBAR(11); - - popq %rcx; - popq %rbx; - popq %rbp; - - vmovdqa .Lbswap_mask, RKM; - leaq (4*4*4)(%r11), %rax; - - testb %cl, %cl; - jnz __enc_xor8; - - outunpack_blocks(%r11, RA1, RB1, RC1, RD1, RTMP, RX, RKRF, RKM); - outunpack_blocks(%rax, RA2, RB2, RC2, RD2, RTMP, RX, RKRF, RKM); - - ret; - -__enc_xor8: - outunpack_xor_blocks(%r11, RA1, RB1, RC1, RD1, RTMP, RX, RKRF, RKM); - outunpack_xor_blocks(%rax, RA2, RB2, RC2, RD2, RTMP, RX, RKRF, RKM); - - ret; - -.align 16 -.global cast6_dec_blk_8way -.type cast6_dec_blk_8way,@function; - -cast6_dec_blk_8way: - /* input: - * %rdi: ctx, CTX - * %rsi: dst - * %rdx: src - */ - - pushq %rbp; - pushq %rbx; - - vmovdqa .Lbswap_mask, RKM; - vmovd .Lfirst_mask, R1ST; - vmovd .L32_mask, R32; - - leaq (4*4*4)(%rdx), %rax; - inpack_blocks(%rdx, RA1, RB1, RC1, RD1, RTMP, RX, RKRF, RKM); - inpack_blocks(%rax, RA2, RB2, RC2, RD2, RTMP, RX, RKRF, RKM); - - movq %rsi, %r11; - - preload_rkr(2, shuffle, .Lrkr_dec_Q_Q_Q_Q); - Q(11); - Q(10); - Q(9); - Q(8); - preload_rkr(1, shuffle, .Lrkr_dec_Q_Q_QBAR_QBAR); - Q(7); - Q(6); - QBAR(5); - QBAR(4); - preload_rkr(0, shuffle, .Lrkr_dec_QBAR_QBAR_QBAR_QBAR); - QBAR(3); - QBAR(2); - QBAR(1); - QBAR(0); - - popq %rbx; - popq %rbp; - - vmovdqa .Lbswap_mask, RKM; - leaq (4*4*4)(%r11), %rax; - outunpack_blocks(%r11, RA1, RB1, RC1, RD1, RTMP, RX, RKRF, RKM); - outunpack_blocks(%rax, RA2, RB2, RC2, RD2, RTMP, RX, RKRF, RKM); - - ret; diff --git a/trunk/arch/x86/crypto/cast6_avx_glue.c b/trunk/arch/x86/crypto/cast6_avx_glue.c deleted file mode 100644 index 15e5f85a5011..000000000000 --- a/trunk/arch/x86/crypto/cast6_avx_glue.c +++ /dev/null @@ -1,648 +0,0 @@ -/* - * Glue Code for the AVX assembler implemention of the Cast6 Cipher - * - * Copyright (C) 2012 Johannes Goetzfried - * - * - * 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 -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#define CAST6_PARALLEL_BLOCKS 8 - -asmlinkage void __cast6_enc_blk_8way(struct cast6_ctx *ctx, u8 *dst, - const u8 *src, bool xor); -asmlinkage void cast6_dec_blk_8way(struct cast6_ctx *ctx, u8 *dst, - const u8 *src); - -static inline void cast6_enc_blk_xway(struct cast6_ctx *ctx, u8 *dst, - const u8 *src) -{ - __cast6_enc_blk_8way(ctx, dst, src, false); -} - -static inline void cast6_enc_blk_xway_xor(struct cast6_ctx *ctx, u8 *dst, - const u8 *src) -{ - __cast6_enc_blk_8way(ctx, dst, src, true); -} - -static inline void cast6_dec_blk_xway(struct cast6_ctx *ctx, u8 *dst, - const u8 *src) -{ - cast6_dec_blk_8way(ctx, dst, src); -} - - -static void cast6_decrypt_cbc_xway(void *ctx, u128 *dst, const u128 *src) -{ - u128 ivs[CAST6_PARALLEL_BLOCKS - 1]; - unsigned int j; - - for (j = 0; j < CAST6_PARALLEL_BLOCKS - 1; j++) - ivs[j] = src[j]; - - cast6_dec_blk_xway(ctx, (u8 *)dst, (u8 *)src); - - for (j = 0; j < CAST6_PARALLEL_BLOCKS - 1; j++) - u128_xor(dst + (j + 1), dst + (j + 1), ivs + j); -} - -static void cast6_crypt_ctr(void *ctx, u128 *dst, const u128 *src, u128 *iv) -{ - be128 ctrblk; - - u128_to_be128(&ctrblk, iv); - u128_inc(iv); - - __cast6_encrypt(ctx, (u8 *)&ctrblk, (u8 *)&ctrblk); - u128_xor(dst, src, (u128 *)&ctrblk); -} - -static void cast6_crypt_ctr_xway(void *ctx, u128 *dst, const u128 *src, - u128 *iv) -{ - be128 ctrblks[CAST6_PARALLEL_BLOCKS]; - unsigned int i; - - for (i = 0; i < CAST6_PARALLEL_BLOCKS; i++) { - if (dst != src) - dst[i] = src[i]; - - u128_to_be128(&ctrblks[i], iv); - u128_inc(iv); - } - - cast6_enc_blk_xway_xor(ctx, (u8 *)dst, (u8 *)ctrblks); -} - -static const struct common_glue_ctx cast6_enc = { - .num_funcs = 2, - .fpu_blocks_limit = CAST6_PARALLEL_BLOCKS, - - .funcs = { { - .num_blocks = CAST6_PARALLEL_BLOCKS, - .fn_u = { .ecb = GLUE_FUNC_CAST(cast6_enc_blk_xway) } - }, { - .num_blocks = 1, - .fn_u = { .ecb = GLUE_FUNC_CAST(__cast6_encrypt) } - } } -}; - -static const struct common_glue_ctx cast6_ctr = { - .num_funcs = 2, - .fpu_blocks_limit = CAST6_PARALLEL_BLOCKS, - - .funcs = { { - .num_blocks = CAST6_PARALLEL_BLOCKS, - .fn_u = { .ctr = GLUE_CTR_FUNC_CAST(cast6_crypt_ctr_xway) } - }, { - .num_blocks = 1, - .fn_u = { .ctr = GLUE_CTR_FUNC_CAST(cast6_crypt_ctr) } - } } -}; - -static const struct common_glue_ctx cast6_dec = { - .num_funcs = 2, - .fpu_blocks_limit = CAST6_PARALLEL_BLOCKS, - - .funcs = { { - .num_blocks = CAST6_PARALLEL_BLOCKS, - .fn_u = { .ecb = GLUE_FUNC_CAST(cast6_dec_blk_xway) } - }, { - .num_blocks = 1, - .fn_u = { .ecb = GLUE_FUNC_CAST(__cast6_decrypt) } - } } -}; - -static const struct common_glue_ctx cast6_dec_cbc = { - .num_funcs = 2, - .fpu_blocks_limit = CAST6_PARALLEL_BLOCKS, - - .funcs = { { - .num_blocks = CAST6_PARALLEL_BLOCKS, - .fn_u = { .cbc = GLUE_CBC_FUNC_CAST(cast6_decrypt_cbc_xway) } - }, { - .num_blocks = 1, - .fn_u = { .cbc = GLUE_CBC_FUNC_CAST(__cast6_decrypt) } - } } -}; - -static int ecb_encrypt(struct blkcipher_desc *desc, struct scatterlist *dst, - struct scatterlist *src, unsigned int nbytes) -{ - return glue_ecb_crypt_128bit(&cast6_enc, desc, dst, src, nbytes); -} - -static int ecb_decrypt(struct blkcipher_desc *desc, struct scatterlist *dst, - struct scatterlist *src, unsigned int nbytes) -{ - return glue_ecb_crypt_128bit(&cast6_dec, desc, dst, src, nbytes); -} - -static int cbc_encrypt(struct blkcipher_desc *desc, struct scatterlist *dst, - struct scatterlist *src, unsigned int nbytes) -{ - return glue_cbc_encrypt_128bit(GLUE_FUNC_CAST(__cast6_encrypt), desc, - dst, src, nbytes); -} - -static int cbc_decrypt(struct blkcipher_desc *desc, struct scatterlist *dst, - struct scatterlist *src, unsigned int nbytes) -{ - return glue_cbc_decrypt_128bit(&cast6_dec_cbc, desc, dst, src, - nbytes); -} - -static int ctr_crypt(struct blkcipher_desc *desc, struct scatterlist *dst, - struct scatterlist *src, unsigned int nbytes) -{ - return glue_ctr_crypt_128bit(&cast6_ctr, desc, dst, src, nbytes); -} - -static inline bool cast6_fpu_begin(bool fpu_enabled, unsigned int nbytes) -{ - return glue_fpu_begin(CAST6_BLOCK_SIZE, CAST6_PARALLEL_BLOCKS, - NULL, fpu_enabled, nbytes); -} - -static inline void cast6_fpu_end(bool fpu_enabled) -{ - glue_fpu_end(fpu_enabled); -} - -struct crypt_priv { - struct cast6_ctx *ctx; - bool fpu_enabled; -}; - -static void encrypt_callback(void *priv, u8 *srcdst, unsigned int nbytes) -{ - const unsigned int bsize = CAST6_BLOCK_SIZE; - struct crypt_priv *ctx = priv; - int i; - - ctx->fpu_enabled = cast6_fpu_begin(ctx->fpu_enabled, nbytes); - - if (nbytes == bsize * CAST6_PARALLEL_BLOCKS) { - cast6_enc_blk_xway(ctx->ctx, srcdst, srcdst); - return; - } - - for (i = 0; i < nbytes / bsize; i++, srcdst += bsize) - __cast6_encrypt(ctx->ctx, srcdst, srcdst); -} - -static void decrypt_callback(void *priv, u8 *srcdst, unsigned int nbytes) -{ - const unsigned int bsize = CAST6_BLOCK_SIZE; - struct crypt_priv *ctx = priv; - int i; - - ctx->fpu_enabled = cast6_fpu_begin(ctx->fpu_enabled, nbytes); - - if (nbytes == bsize * CAST6_PARALLEL_BLOCKS) { - cast6_dec_blk_xway(ctx->ctx, srcdst, srcdst); - return; - } - - for (i = 0; i < nbytes / bsize; i++, srcdst += bsize) - __cast6_decrypt(ctx->ctx, srcdst, srcdst); -} - -struct cast6_lrw_ctx { - struct lrw_table_ctx lrw_table; - struct cast6_ctx cast6_ctx; -}; - -static int lrw_cast6_setkey(struct crypto_tfm *tfm, const u8 *key, - unsigned int keylen) -{ - struct cast6_lrw_ctx *ctx = crypto_tfm_ctx(tfm); - int err; - - err = __cast6_setkey(&ctx->cast6_ctx, key, keylen - CAST6_BLOCK_SIZE, - &tfm->crt_flags); - if (err) - return err; - - return lrw_init_table(&ctx->lrw_table, key + keylen - CAST6_BLOCK_SIZE); -} - -static int lrw_encrypt(struct blkcipher_desc *desc, struct scatterlist *dst, - struct scatterlist *src, unsigned int nbytes) -{ - struct cast6_lrw_ctx *ctx = crypto_blkcipher_ctx(desc->tfm); - be128 buf[CAST6_PARALLEL_BLOCKS]; - struct crypt_priv crypt_ctx = { - .ctx = &ctx->cast6_ctx, - .fpu_enabled = false, - }; - struct lrw_crypt_req req = { - .tbuf = buf, - .tbuflen = sizeof(buf), - - .table_ctx = &ctx->lrw_table, - .crypt_ctx = &crypt_ctx, - .crypt_fn = encrypt_callback, - }; - int ret; - - desc->flags &= ~CRYPTO_TFM_REQ_MAY_SLEEP; - ret = lrw_crypt(desc, dst, src, nbytes, &req); - cast6_fpu_end(crypt_ctx.fpu_enabled); - - return ret; -} - -static int lrw_decrypt(struct blkcipher_desc *desc, struct scatterlist *dst, - struct scatterlist *src, unsigned int nbytes) -{ - struct cast6_lrw_ctx *ctx = crypto_blkcipher_ctx(desc->tfm); - be128 buf[CAST6_PARALLEL_BLOCKS]; - struct crypt_priv crypt_ctx = { - .ctx = &ctx->cast6_ctx, - .fpu_enabled = false, - }; - struct lrw_crypt_req req = { - .tbuf = buf, - .tbuflen = sizeof(buf), - - .table_ctx = &ctx->lrw_table, - .crypt_ctx = &crypt_ctx, - .crypt_fn = decrypt_callback, - }; - int ret; - - desc->flags &= ~CRYPTO_TFM_REQ_MAY_SLEEP; - ret = lrw_crypt(desc, dst, src, nbytes, &req); - cast6_fpu_end(crypt_ctx.fpu_enabled); - - return ret; -} - -static void lrw_exit_tfm(struct crypto_tfm *tfm) -{ - struct cast6_lrw_ctx *ctx = crypto_tfm_ctx(tfm); - - lrw_free_table(&ctx->lrw_table); -} - -struct cast6_xts_ctx { - struct cast6_ctx tweak_ctx; - struct cast6_ctx crypt_ctx; -}; - -static int xts_cast6_setkey(struct crypto_tfm *tfm, const u8 *key, - unsigned int keylen) -{ - struct cast6_xts_ctx *ctx = crypto_tfm_ctx(tfm); - u32 *flags = &tfm->crt_flags; - int err; - - /* key consists of keys of equal size concatenated, therefore - * the length must be even - */ - if (keylen % 2) { - *flags |= CRYPTO_TFM_RES_BAD_KEY_LEN; - return -EINVAL; - } - - /* first half of xts-key is for crypt */ - err = __cast6_setkey(&ctx->crypt_ctx, key, keylen / 2, flags); - if (err) - return err; - - /* second half of xts-key is for tweak */ - return __cast6_setkey(&ctx->tweak_ctx, key + keylen / 2, keylen / 2, - flags); -} - -static int xts_encrypt(struct blkcipher_desc *desc, struct scatterlist *dst, - struct scatterlist *src, unsigned int nbytes) -{ - struct cast6_xts_ctx *ctx = crypto_blkcipher_ctx(desc->tfm); - be128 buf[CAST6_PARALLEL_BLOCKS]; - struct crypt_priv crypt_ctx = { - .ctx = &ctx->crypt_ctx, - .fpu_enabled = false, - }; - struct xts_crypt_req req = { - .tbuf = buf, - .tbuflen = sizeof(buf), - - .tweak_ctx = &ctx->tweak_ctx, - .tweak_fn = XTS_TWEAK_CAST(__cast6_encrypt), - .crypt_ctx = &crypt_ctx, - .crypt_fn = encrypt_callback, - }; - int ret; - - desc->flags &= ~CRYPTO_TFM_REQ_MAY_SLEEP; - ret = xts_crypt(desc, dst, src, nbytes, &req); - cast6_fpu_end(crypt_ctx.fpu_enabled); - - return ret; -} - -static int xts_decrypt(struct blkcipher_desc *desc, struct scatterlist *dst, - struct scatterlist *src, unsigned int nbytes) -{ - struct cast6_xts_ctx *ctx = crypto_blkcipher_ctx(desc->tfm); - be128 buf[CAST6_PARALLEL_BLOCKS]; - struct crypt_priv crypt_ctx = { - .ctx = &ctx->crypt_ctx, - .fpu_enabled = false, - }; - struct xts_crypt_req req = { - .tbuf = buf, - .tbuflen = sizeof(buf), - - .tweak_ctx = &ctx->tweak_ctx, - .tweak_fn = XTS_TWEAK_CAST(__cast6_encrypt), - .crypt_ctx = &crypt_ctx, - .crypt_fn = decrypt_callback, - }; - int ret; - - desc->flags &= ~CRYPTO_TFM_REQ_MAY_SLEEP; - ret = xts_crypt(desc, dst, src, nbytes, &req); - cast6_fpu_end(crypt_ctx.fpu_enabled); - - return ret; -} - -static struct crypto_alg cast6_algs[10] = { { - .cra_name = "__ecb-cast6-avx", - .cra_driver_name = "__driver-ecb-cast6-avx", - .cra_priority = 0, - .cra_flags = CRYPTO_ALG_TYPE_BLKCIPHER, - .cra_blocksize = CAST6_BLOCK_SIZE, - .cra_ctxsize = sizeof(struct cast6_ctx), - .cra_alignmask = 0, - .cra_type = &crypto_blkcipher_type, - .cra_module = THIS_MODULE, - .cra_u = { - .blkcipher = { - .min_keysize = CAST6_MIN_KEY_SIZE, - .max_keysize = CAST6_MAX_KEY_SIZE, - .setkey = cast6_setkey, - .encrypt = ecb_encrypt, - .decrypt = ecb_decrypt, - }, - }, -}, { - .cra_name = "__cbc-cast6-avx", - .cra_driver_name = "__driver-cbc-cast6-avx", - .cra_priority = 0, - .cra_flags = CRYPTO_ALG_TYPE_BLKCIPHER, - .cra_blocksize = CAST6_BLOCK_SIZE, - .cra_ctxsize = sizeof(struct cast6_ctx), - .cra_alignmask = 0, - .cra_type = &crypto_blkcipher_type, - .cra_module = THIS_MODULE, - .cra_u = { - .blkcipher = { - .min_keysize = CAST6_MIN_KEY_SIZE, - .max_keysize = CAST6_MAX_KEY_SIZE, - .setkey = cast6_setkey, - .encrypt = cbc_encrypt, - .decrypt = cbc_decrypt, - }, - }, -}, { - .cra_name = "__ctr-cast6-avx", - .cra_driver_name = "__driver-ctr-cast6-avx", - .cra_priority = 0, - .cra_flags = CRYPTO_ALG_TYPE_BLKCIPHER, - .cra_blocksize = 1, - .cra_ctxsize = sizeof(struct cast6_ctx), - .cra_alignmask = 0, - .cra_type = &crypto_blkcipher_type, - .cra_module = THIS_MODULE, - .cra_u = { - .blkcipher = { - .min_keysize = CAST6_MIN_KEY_SIZE, - .max_keysize = CAST6_MAX_KEY_SIZE, - .ivsize = CAST6_BLOCK_SIZE, - .setkey = cast6_setkey, - .encrypt = ctr_crypt, - .decrypt = ctr_crypt, - }, - }, -}, { - .cra_name = "__lrw-cast6-avx", - .cra_driver_name = "__driver-lrw-cast6-avx", - .cra_priority = 0, - .cra_flags = CRYPTO_ALG_TYPE_BLKCIPHER, - .cra_blocksize = CAST6_BLOCK_SIZE, - .cra_ctxsize = sizeof(struct cast6_lrw_ctx), - .cra_alignmask = 0, - .cra_type = &crypto_blkcipher_type, - .cra_module = THIS_MODULE, - .cra_exit = lrw_exit_tfm, - .cra_u = { - .blkcipher = { - .min_keysize = CAST6_MIN_KEY_SIZE + - CAST6_BLOCK_SIZE, - .max_keysize = CAST6_MAX_KEY_SIZE + - CAST6_BLOCK_SIZE, - .ivsize = CAST6_BLOCK_SIZE, - .setkey = lrw_cast6_setkey, - .encrypt = lrw_encrypt, - .decrypt = lrw_decrypt, - }, - }, -}, { - .cra_name = "__xts-cast6-avx", - .cra_driver_name = "__driver-xts-cast6-avx", - .cra_priority = 0, - .cra_flags = CRYPTO_ALG_TYPE_BLKCIPHER, - .cra_blocksize = CAST6_BLOCK_SIZE, - .cra_ctxsize = sizeof(struct cast6_xts_ctx), - .cra_alignmask = 0, - .cra_type = &crypto_blkcipher_type, - .cra_module = THIS_MODULE, - .cra_u = { - .blkcipher = { - .min_keysize = CAST6_MIN_KEY_SIZE * 2, - .max_keysize = CAST6_MAX_KEY_SIZE * 2, - .ivsize = CAST6_BLOCK_SIZE, - .setkey = xts_cast6_setkey, - .encrypt = xts_encrypt, - .decrypt = xts_decrypt, - }, - }, -}, { - .cra_name = "ecb(cast6)", - .cra_driver_name = "ecb-cast6-avx", - .cra_priority = 200, - .cra_flags = CRYPTO_ALG_TYPE_ABLKCIPHER | CRYPTO_ALG_ASYNC, - .cra_blocksize = CAST6_BLOCK_SIZE, - .cra_ctxsize = sizeof(struct async_helper_ctx), - .cra_alignmask = 0, - .cra_type = &crypto_ablkcipher_type, - .cra_module = THIS_MODULE, - .cra_init = ablk_init, - .cra_exit = ablk_exit, - .cra_u = { - .ablkcipher = { - .min_keysize = CAST6_MIN_KEY_SIZE, - .max_keysize = CAST6_MAX_KEY_SIZE, - .setkey = ablk_set_key, - .encrypt = ablk_encrypt, - .decrypt = ablk_decrypt, - }, - }, -}, { - .cra_name = "cbc(cast6)", - .cra_driver_name = "cbc-cast6-avx", - .cra_priority = 200, - .cra_flags = CRYPTO_ALG_TYPE_ABLKCIPHER | CRYPTO_ALG_ASYNC, - .cra_blocksize = CAST6_BLOCK_SIZE, - .cra_ctxsize = sizeof(struct async_helper_ctx), - .cra_alignmask = 0, - .cra_type = &crypto_ablkcipher_type, - .cra_module = THIS_MODULE, - .cra_init = ablk_init, - .cra_exit = ablk_exit, - .cra_u = { - .ablkcipher = { - .min_keysize = CAST6_MIN_KEY_SIZE, - .max_keysize = CAST6_MAX_KEY_SIZE, - .ivsize = CAST6_BLOCK_SIZE, - .setkey = ablk_set_key, - .encrypt = __ablk_encrypt, - .decrypt = ablk_decrypt, - }, - }, -}, { - .cra_name = "ctr(cast6)", - .cra_driver_name = "ctr-cast6-avx", - .cra_priority = 200, - .cra_flags = CRYPTO_ALG_TYPE_ABLKCIPHER | CRYPTO_ALG_ASYNC, - .cra_blocksize = 1, - .cra_ctxsize = sizeof(struct async_helper_ctx), - .cra_alignmask = 0, - .cra_type = &crypto_ablkcipher_type, - .cra_module = THIS_MODULE, - .cra_init = ablk_init, - .cra_exit = ablk_exit, - .cra_u = { - .ablkcipher = { - .min_keysize = CAST6_MIN_KEY_SIZE, - .max_keysize = CAST6_MAX_KEY_SIZE, - .ivsize = CAST6_BLOCK_SIZE, - .setkey = ablk_set_key, - .encrypt = ablk_encrypt, - .decrypt = ablk_encrypt, - .geniv = "chainiv", - }, - }, -}, { - .cra_name = "lrw(cast6)", - .cra_driver_name = "lrw-cast6-avx", - .cra_priority = 200, - .cra_flags = CRYPTO_ALG_TYPE_ABLKCIPHER | CRYPTO_ALG_ASYNC, - .cra_blocksize = CAST6_BLOCK_SIZE, - .cra_ctxsize = sizeof(struct async_helper_ctx), - .cra_alignmask = 0, - .cra_type = &crypto_ablkcipher_type, - .cra_module = THIS_MODULE, - .cra_init = ablk_init, - .cra_exit = ablk_exit, - .cra_u = { - .ablkcipher = { - .min_keysize = CAST6_MIN_KEY_SIZE + - CAST6_BLOCK_SIZE, - .max_keysize = CAST6_MAX_KEY_SIZE + - CAST6_BLOCK_SIZE, - .ivsize = CAST6_BLOCK_SIZE, - .setkey = ablk_set_key, - .encrypt = ablk_encrypt, - .decrypt = ablk_decrypt, - }, - }, -}, { - .cra_name = "xts(cast6)", - .cra_driver_name = "xts-cast6-avx", - .cra_priority = 200, - .cra_flags = CRYPTO_ALG_TYPE_ABLKCIPHER | CRYPTO_ALG_ASYNC, - .cra_blocksize = CAST6_BLOCK_SIZE, - .cra_ctxsize = sizeof(struct async_helper_ctx), - .cra_alignmask = 0, - .cra_type = &crypto_ablkcipher_type, - .cra_module = THIS_MODULE, - .cra_init = ablk_init, - .cra_exit = ablk_exit, - .cra_u = { - .ablkcipher = { - .min_keysize = CAST6_MIN_KEY_SIZE * 2, - .max_keysize = CAST6_MAX_KEY_SIZE * 2, - .ivsize = CAST6_BLOCK_SIZE, - .setkey = ablk_set_key, - .encrypt = ablk_encrypt, - .decrypt = ablk_decrypt, - }, - }, -} }; - -static int __init cast6_init(void) -{ - u64 xcr0; - - if (!cpu_has_avx || !cpu_has_osxsave) { - pr_info("AVX instructions are not detected.\n"); - return -ENODEV; - } - - xcr0 = xgetbv(XCR_XFEATURE_ENABLED_MASK); - if ((xcr0 & (XSTATE_SSE | XSTATE_YMM)) != (XSTATE_SSE | XSTATE_YMM)) { - pr_info("AVX detected but unusable.\n"); - return -ENODEV; - } - - return crypto_register_algs(cast6_algs, ARRAY_SIZE(cast6_algs)); -} - -static void __exit cast6_exit(void) -{ - crypto_unregister_algs(cast6_algs, ARRAY_SIZE(cast6_algs)); -} - -module_init(cast6_init); -module_exit(cast6_exit); - -MODULE_DESCRIPTION("Cast6 Cipher Algorithm, AVX optimized"); -MODULE_LICENSE("GPL"); -MODULE_ALIAS("cast6"); diff --git a/trunk/arch/x86/crypto/ghash-clmulni-intel_glue.c b/trunk/arch/x86/crypto/ghash-clmulni-intel_glue.c index 6759dd1135be..b4bf0a63b520 100644 --- a/trunk/arch/x86/crypto/ghash-clmulni-intel_glue.c +++ b/trunk/arch/x86/crypto/ghash-clmulni-intel_glue.c @@ -150,6 +150,7 @@ static struct shash_alg ghash_alg = { .cra_blocksize = GHASH_BLOCK_SIZE, .cra_ctxsize = sizeof(struct ghash_ctx), .cra_module = THIS_MODULE, + .cra_list = LIST_HEAD_INIT(ghash_alg.base.cra_list), }, }; @@ -287,6 +288,7 @@ static struct ahash_alg ghash_async_alg = { .cra_blocksize = GHASH_BLOCK_SIZE, .cra_type = &crypto_ahash_type, .cra_module = THIS_MODULE, + .cra_list = LIST_HEAD_INIT(ghash_async_alg.halg.base.cra_list), .cra_init = ghash_async_init_tfm, .cra_exit = ghash_async_exit_tfm, }, diff --git a/trunk/arch/x86/crypto/glue_helper.c b/trunk/arch/x86/crypto/glue_helper.c index 30b3927bd733..4854f0f31e4f 100644 --- a/trunk/arch/x86/crypto/glue_helper.c +++ b/trunk/arch/x86/crypto/glue_helper.c @@ -110,7 +110,7 @@ static unsigned int __glue_cbc_encrypt_128bit(const common_glue_func_t fn, nbytes -= bsize; } while (nbytes >= bsize); - *(u128 *)walk->iv = *iv; + u128_xor((u128 *)walk->iv, (u128 *)walk->iv, iv); return nbytes; } diff --git a/trunk/arch/x86/crypto/salsa20_glue.c b/trunk/arch/x86/crypto/salsa20_glue.c index a3a3c0205c16..bccb76d80987 100644 --- a/trunk/arch/x86/crypto/salsa20_glue.c +++ b/trunk/arch/x86/crypto/salsa20_glue.c @@ -97,6 +97,7 @@ static struct crypto_alg alg = { .cra_ctxsize = sizeof(struct salsa20_ctx), .cra_alignmask = 3, .cra_module = THIS_MODULE, + .cra_list = LIST_HEAD_INIT(alg.cra_list), .cra_u = { .blkcipher = { .setkey = setkey, diff --git a/trunk/arch/x86/crypto/serpent_avx_glue.c b/trunk/arch/x86/crypto/serpent_avx_glue.c index 3f543a04cf1e..b36bdac237eb 100644 --- a/trunk/arch/x86/crypto/serpent_avx_glue.c +++ b/trunk/arch/x86/crypto/serpent_avx_glue.c @@ -390,6 +390,7 @@ static struct crypto_alg serpent_algs[10] = { { .cra_alignmask = 0, .cra_type = &crypto_blkcipher_type, .cra_module = THIS_MODULE, + .cra_list = LIST_HEAD_INIT(serpent_algs[0].cra_list), .cra_u = { .blkcipher = { .min_keysize = SERPENT_MIN_KEY_SIZE, @@ -409,6 +410,7 @@ static struct crypto_alg serpent_algs[10] = { { .cra_alignmask = 0, .cra_type = &crypto_blkcipher_type, .cra_module = THIS_MODULE, + .cra_list = LIST_HEAD_INIT(serpent_algs[1].cra_list), .cra_u = { .blkcipher = { .min_keysize = SERPENT_MIN_KEY_SIZE, @@ -428,6 +430,7 @@ static struct crypto_alg serpent_algs[10] = { { .cra_alignmask = 0, .cra_type = &crypto_blkcipher_type, .cra_module = THIS_MODULE, + .cra_list = LIST_HEAD_INIT(serpent_algs[2].cra_list), .cra_u = { .blkcipher = { .min_keysize = SERPENT_MIN_KEY_SIZE, @@ -448,6 +451,7 @@ static struct crypto_alg serpent_algs[10] = { { .cra_alignmask = 0, .cra_type = &crypto_blkcipher_type, .cra_module = THIS_MODULE, + .cra_list = LIST_HEAD_INIT(serpent_algs[3].cra_list), .cra_exit = lrw_exit_tfm, .cra_u = { .blkcipher = { @@ -471,6 +475,7 @@ static struct crypto_alg serpent_algs[10] = { { .cra_alignmask = 0, .cra_type = &crypto_blkcipher_type, .cra_module = THIS_MODULE, + .cra_list = LIST_HEAD_INIT(serpent_algs[4].cra_list), .cra_u = { .blkcipher = { .min_keysize = SERPENT_MIN_KEY_SIZE * 2, @@ -491,6 +496,7 @@ static struct crypto_alg serpent_algs[10] = { { .cra_alignmask = 0, .cra_type = &crypto_ablkcipher_type, .cra_module = THIS_MODULE, + .cra_list = LIST_HEAD_INIT(serpent_algs[5].cra_list), .cra_init = ablk_init, .cra_exit = ablk_exit, .cra_u = { @@ -512,6 +518,7 @@ static struct crypto_alg serpent_algs[10] = { { .cra_alignmask = 0, .cra_type = &crypto_ablkcipher_type, .cra_module = THIS_MODULE, + .cra_list = LIST_HEAD_INIT(serpent_algs[6].cra_list), .cra_init = ablk_init, .cra_exit = ablk_exit, .cra_u = { @@ -534,6 +541,7 @@ static struct crypto_alg serpent_algs[10] = { { .cra_alignmask = 0, .cra_type = &crypto_ablkcipher_type, .cra_module = THIS_MODULE, + .cra_list = LIST_HEAD_INIT(serpent_algs[7].cra_list), .cra_init = ablk_init, .cra_exit = ablk_exit, .cra_u = { @@ -557,6 +565,7 @@ static struct crypto_alg serpent_algs[10] = { { .cra_alignmask = 0, .cra_type = &crypto_ablkcipher_type, .cra_module = THIS_MODULE, + .cra_list = LIST_HEAD_INIT(serpent_algs[8].cra_list), .cra_init = ablk_init, .cra_exit = ablk_exit, .cra_u = { @@ -581,6 +590,7 @@ static struct crypto_alg serpent_algs[10] = { { .cra_alignmask = 0, .cra_type = &crypto_ablkcipher_type, .cra_module = THIS_MODULE, + .cra_list = LIST_HEAD_INIT(serpent_algs[9].cra_list), .cra_init = ablk_init, .cra_exit = ablk_exit, .cra_u = { diff --git a/trunk/arch/x86/crypto/serpent_sse2_glue.c b/trunk/arch/x86/crypto/serpent_sse2_glue.c index 9107a9908c41..d679c8675f4a 100644 --- a/trunk/arch/x86/crypto/serpent_sse2_glue.c +++ b/trunk/arch/x86/crypto/serpent_sse2_glue.c @@ -393,6 +393,7 @@ static struct crypto_alg serpent_algs[10] = { { .cra_alignmask = 0, .cra_type = &crypto_blkcipher_type, .cra_module = THIS_MODULE, + .cra_list = LIST_HEAD_INIT(serpent_algs[0].cra_list), .cra_u = { .blkcipher = { .min_keysize = SERPENT_MIN_KEY_SIZE, @@ -412,6 +413,7 @@ static struct crypto_alg serpent_algs[10] = { { .cra_alignmask = 0, .cra_type = &crypto_blkcipher_type, .cra_module = THIS_MODULE, + .cra_list = LIST_HEAD_INIT(serpent_algs[1].cra_list), .cra_u = { .blkcipher = { .min_keysize = SERPENT_MIN_KEY_SIZE, @@ -431,6 +433,7 @@ static struct crypto_alg serpent_algs[10] = { { .cra_alignmask = 0, .cra_type = &crypto_blkcipher_type, .cra_module = THIS_MODULE, + .cra_list = LIST_HEAD_INIT(serpent_algs[2].cra_list), .cra_u = { .blkcipher = { .min_keysize = SERPENT_MIN_KEY_SIZE, @@ -451,6 +454,7 @@ static struct crypto_alg serpent_algs[10] = { { .cra_alignmask = 0, .cra_type = &crypto_blkcipher_type, .cra_module = THIS_MODULE, + .cra_list = LIST_HEAD_INIT(serpent_algs[3].cra_list), .cra_exit = lrw_exit_tfm, .cra_u = { .blkcipher = { @@ -474,6 +478,7 @@ static struct crypto_alg serpent_algs[10] = { { .cra_alignmask = 0, .cra_type = &crypto_blkcipher_type, .cra_module = THIS_MODULE, + .cra_list = LIST_HEAD_INIT(serpent_algs[4].cra_list), .cra_u = { .blkcipher = { .min_keysize = SERPENT_MIN_KEY_SIZE * 2, @@ -494,6 +499,7 @@ static struct crypto_alg serpent_algs[10] = { { .cra_alignmask = 0, .cra_type = &crypto_ablkcipher_type, .cra_module = THIS_MODULE, + .cra_list = LIST_HEAD_INIT(serpent_algs[5].cra_list), .cra_init = ablk_init, .cra_exit = ablk_exit, .cra_u = { @@ -515,6 +521,7 @@ static struct crypto_alg serpent_algs[10] = { { .cra_alignmask = 0, .cra_type = &crypto_ablkcipher_type, .cra_module = THIS_MODULE, + .cra_list = LIST_HEAD_INIT(serpent_algs[6].cra_list), .cra_init = ablk_init, .cra_exit = ablk_exit, .cra_u = { @@ -537,6 +544,7 @@ static struct crypto_alg serpent_algs[10] = { { .cra_alignmask = 0, .cra_type = &crypto_ablkcipher_type, .cra_module = THIS_MODULE, + .cra_list = LIST_HEAD_INIT(serpent_algs[7].cra_list), .cra_init = ablk_init, .cra_exit = ablk_exit, .cra_u = { @@ -560,6 +568,7 @@ static struct crypto_alg serpent_algs[10] = { { .cra_alignmask = 0, .cra_type = &crypto_ablkcipher_type, .cra_module = THIS_MODULE, + .cra_list = LIST_HEAD_INIT(serpent_algs[8].cra_list), .cra_init = ablk_init, .cra_exit = ablk_exit, .cra_u = { @@ -584,6 +593,7 @@ static struct crypto_alg serpent_algs[10] = { { .cra_alignmask = 0, .cra_type = &crypto_ablkcipher_type, .cra_module = THIS_MODULE, + .cra_list = LIST_HEAD_INIT(serpent_algs[9].cra_list), .cra_init = ablk_init, .cra_exit = ablk_exit, .cra_u = { diff --git a/trunk/arch/x86/crypto/twofish-avx-x86_64-asm_64.S b/trunk/arch/x86/crypto/twofish-avx-x86_64-asm_64.S index 1585abb13dde..35f45574390d 100644 --- a/trunk/arch/x86/crypto/twofish-avx-x86_64-asm_64.S +++ b/trunk/arch/x86/crypto/twofish-avx-x86_64-asm_64.S @@ -4,8 +4,6 @@ * Copyright (C) 2012 Johannes Goetzfried * * - * Copyright © 2012 Jussi Kivilinna - * * 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 @@ -49,22 +47,16 @@ #define RC2 %xmm6 #define RD2 %xmm7 -#define RX0 %xmm8 -#define RY0 %xmm9 - -#define RX1 %xmm10 -#define RY1 %xmm11 +#define RX %xmm8 +#define RY %xmm9 -#define RK1 %xmm12 -#define RK2 %xmm13 +#define RK1 %xmm10 +#define RK2 %xmm11 -#define RT %xmm14 -#define RR %xmm15 - -#define RID1 %rbp -#define RID1d %ebp -#define RID2 %rsi -#define RID2d %esi +#define RID1 %rax +#define RID1b %al +#define RID2 %rbx +#define RID2b %bl #define RGI1 %rdx #define RGI1bl %dl @@ -73,13 +65,6 @@ #define RGI2bl %cl #define RGI2bh %ch -#define RGI3 %rax -#define RGI3bl %al -#define RGI3bh %ah -#define RGI4 %rbx -#define RGI4bl %bl -#define RGI4bh %bh - #define RGS1 %r8 #define RGS1d %r8d #define RGS2 %r9 @@ -88,123 +73,89 @@ #define RGS3d %r10d -#define lookup_32bit(t0, t1, t2, t3, src, dst, interleave_op, il_reg) \ - movzbl src ## bl, RID1d; \ - movzbl src ## bh, RID2d; \ - shrq $16, src; \ +#define lookup_32bit(t0, t1, t2, t3, src, dst) \ + movb src ## bl, RID1b; \ + movb src ## bh, RID2b; \ movl t0(CTX, RID1, 4), dst ## d; \ - movl t1(CTX, RID2, 4), RID2d; \ - movzbl src ## bl, RID1d; \ - xorl RID2d, dst ## d; \ - movzbl src ## bh, RID2d; \ - interleave_op(il_reg); \ + xorl t1(CTX, RID2, 4), dst ## d; \ + shrq $16, src; \ + movb src ## bl, RID1b; \ + movb src ## bh, RID2b; \ xorl t2(CTX, RID1, 4), dst ## d; \ xorl t3(CTX, RID2, 4), dst ## d; -#define dummy(d) /* do nothing */ - -#define shr_next(reg) \ - shrq $16, reg; - -#define G(gi1, gi2, x, t0, t1, t2, t3) \ - lookup_32bit(t0, t1, t2, t3, ##gi1, RGS1, shr_next, ##gi1); \ - lookup_32bit(t0, t1, t2, t3, ##gi2, RGS3, shr_next, ##gi2); \ - \ - lookup_32bit(t0, t1, t2, t3, ##gi1, RGS2, dummy, none); \ - shlq $32, RGS2; \ - orq RGS1, RGS2; \ - lookup_32bit(t0, t1, t2, t3, ##gi2, RGS1, dummy, none); \ - shlq $32, RGS1; \ - orq RGS1, RGS3; - -#define round_head_2(a, b, x1, y1, x2, y2) \ - vmovq b ## 1, RGI3; \ - vpextrq $1, b ## 1, RGI4; \ +#define G(a, x, t0, t1, t2, t3) \ + vmovq a, RGI1; \ + vpsrldq $8, a, x; \ + vmovq x, RGI2; \ \ - G(RGI1, RGI2, x1, s0, s1, s2, s3); \ - vmovq a ## 2, RGI1; \ - vpextrq $1, a ## 2, RGI2; \ - vmovq RGS2, x1; \ - vpinsrq $1, RGS3, x1, x1; \ + lookup_32bit(t0, t1, t2, t3, RGI1, RGS1); \ + shrq $16, RGI1; \ + lookup_32bit(t0, t1, t2, t3, RGI1, RGS2); \ + shlq $32, RGS2; \ + orq RGS1, RGS2; \ \ - G(RGI3, RGI4, y1, s1, s2, s3, s0); \ - vmovq b ## 2, RGI3; \ - vpextrq $1, b ## 2, RGI4; \ - vmovq RGS2, y1; \ - vpinsrq $1, RGS3, y1, y1; \ + lookup_32bit(t0, t1, t2, t3, RGI2, RGS1); \ + shrq $16, RGI2; \ + lookup_32bit(t0, t1, t2, t3, RGI2, RGS3); \ + shlq $32, RGS3; \ + orq RGS1, RGS3; \ \ - G(RGI1, RGI2, x2, s0, s1, s2, s3); \ - vmovq RGS2, x2; \ - vpinsrq $1, RGS3, x2, x2; \ - \ - G(RGI3, RGI4, y2, s1, s2, s3, s0); \ - vmovq RGS2, y2; \ - vpinsrq $1, RGS3, y2, y2; + vmovq RGS2, x; \ + vpinsrq $1, RGS3, x, x; -#define encround_tail(a, b, c, d, x, y, prerotate) \ +#define encround(a, b, c, d, x, y) \ + G(a, x, s0, s1, s2, s3); \ + G(b, y, s1, s2, s3, s0); \ vpaddd x, y, x; \ - vpaddd x, RK1, RT;\ - prerotate(b); \ - vpxor RT, c, c; \ vpaddd y, x, y; \ + vpaddd x, RK1, x; \ vpaddd y, RK2, y; \ - vpsrld $1, c, RT; \ + vpxor x, c, c; \ + vpsrld $1, c, x; \ vpslld $(32 - 1), c, c; \ - vpor c, RT, c; \ - vpxor d, y, d; \ - -#define decround_tail(a, b, c, d, x, y, prerotate) \ + vpor c, x, c; \ + vpslld $1, d, x; \ + vpsrld $(32 - 1), d, d; \ + vpor d, x, d; \ + vpxor d, y, d; + +#define decround(a, b, c, d, x, y) \ + G(a, x, s0, s1, s2, s3); \ + G(b, y, s1, s2, s3, s0); \ vpaddd x, y, x; \ - vpaddd x, RK1, RT;\ - prerotate(a); \ - vpxor RT, c, c; \ vpaddd y, x, y; \ vpaddd y, RK2, y; \ vpxor d, y, d; \ vpsrld $1, d, y; \ vpslld $(32 - 1), d, d; \ vpor d, y, d; \ - -#define rotate_1l(x) \ - vpslld $1, x, RR; \ - vpsrld $(32 - 1), x, x; \ - vpor x, RR, x; - -#define preload_rgi(c) \ - vmovq c, RGI1; \ - vpextrq $1, c, RGI2; - -#define encrypt_round(n, a, b, c, d, preload, prerotate) \ - vbroadcastss (k+4*(2*(n)))(CTX), RK1; \ - vbroadcastss (k+4*(2*(n)+1))(CTX), RK2; \ - round_head_2(a, b, RX0, RY0, RX1, RY1); \ - encround_tail(a ## 1, b ## 1, c ## 1, d ## 1, RX0, RY0, prerotate); \ - preload(c ## 1); \ - encround_tail(a ## 2, b ## 2, c ## 2, d ## 2, RX1, RY1, prerotate); - -#define decrypt_round(n, a, b, c, d, preload, prerotate) \ - vbroadcastss (k+4*(2*(n)))(CTX), RK1; \ - vbroadcastss (k+4*(2*(n)+1))(CTX), RK2; \ - round_head_2(a, b, RX0, RY0, RX1, RY1); \ - decround_tail(a ## 1, b ## 1, c ## 1, d ## 1, RX0, RY0, prerotate); \ - preload(c ## 1); \ - decround_tail(a ## 2, b ## 2, c ## 2, d ## 2, RX1, RY1, prerotate); + vpslld $1, c, y; \ + vpsrld $(32 - 1), c, c; \ + vpor c, y, c; \ + vpaddd x, RK1, x; \ + vpxor x, c, c; + +#define encrypt_round(n, a, b, c, d) \ + vbroadcastss (k+4*(2*(n)))(CTX), RK1; \ + vbroadcastss (k+4*(2*(n)+1))(CTX), RK2; \ + encround(a ## 1, b ## 1, c ## 1, d ## 1, RX, RY); \ + encround(a ## 2, b ## 2, c ## 2, d ## 2, RX, RY); + +#define decrypt_round(n, a, b, c, d) \ + vbroadcastss (k+4*(2*(n)))(CTX), RK1; \ + vbroadcastss (k+4*(2*(n)+1))(CTX), RK2; \ + decround(a ## 1, b ## 1, c ## 1, d ## 1, RX, RY); \ + decround(a ## 2, b ## 2, c ## 2, d ## 2, RX, RY); #define encrypt_cycle(n) \ - encrypt_round((2*n), RA, RB, RC, RD, preload_rgi, rotate_1l); \ - encrypt_round(((2*n) + 1), RC, RD, RA, RB, preload_rgi, rotate_1l); - -#define encrypt_cycle_last(n) \ - encrypt_round((2*n), RA, RB, RC, RD, preload_rgi, rotate_1l); \ - encrypt_round(((2*n) + 1), RC, RD, RA, RB, dummy, dummy); + encrypt_round((2*n), RA, RB, RC, RD); \ + encrypt_round(((2*n) + 1), RC, RD, RA, RB); #define decrypt_cycle(n) \ - decrypt_round(((2*n) + 1), RC, RD, RA, RB, preload_rgi, rotate_1l); \ - decrypt_round((2*n), RA, RB, RC, RD, preload_rgi, rotate_1l); + decrypt_round(((2*n) + 1), RC, RD, RA, RB); \ + decrypt_round((2*n), RA, RB, RC, RD); -#define decrypt_cycle_last(n) \ - decrypt_round(((2*n) + 1), RC, RD, RA, RB, preload_rgi, rotate_1l); \ - decrypt_round((2*n), RA, RB, RC, RD, dummy, dummy); #define transpose_4x4(x0, x1, x2, x3, t0, t1, t2) \ vpunpckldq x1, x0, t0; \ @@ -265,20 +216,17 @@ __twofish_enc_blk_8way: * %rcx: bool, if true: xor output */ - pushq %rbp; pushq %rbx; pushq %rcx; vmovdqu w(CTX), RK1; leaq (4*4*4)(%rdx), %rax; - inpack_blocks(%rdx, RA1, RB1, RC1, RD1, RK1, RX0, RY0, RK2); - preload_rgi(RA1); - rotate_1l(RD1); - inpack_blocks(%rax, RA2, RB2, RC2, RD2, RK1, RX0, RY0, RK2); - rotate_1l(RD2); + inpack_blocks(%rdx, RA1, RB1, RC1, RD1, RK1, RX, RY, RK2); + inpack_blocks(%rax, RA2, RB2, RC2, RD2, RK1, RX, RY, RK2); - movq %rsi, %r11; + xorq RID1, RID1; + xorq RID2, RID2; encrypt_cycle(0); encrypt_cycle(1); @@ -287,27 +235,26 @@ __twofish_enc_blk_8way: encrypt_cycle(4); encrypt_cycle(5); encrypt_cycle(6); - encrypt_cycle_last(7); + encrypt_cycle(7); vmovdqu (w+4*4)(CTX), RK1; popq %rcx; popq %rbx; - popq %rbp; - leaq (4*4*4)(%r11), %rax; + leaq (4*4*4)(%rsi), %rax; testb %cl, %cl; jnz __enc_xor8; - outunpack_blocks(%r11, RC1, RD1, RA1, RB1, RK1, RX0, RY0, RK2); - outunpack_blocks(%rax, RC2, RD2, RA2, RB2, RK1, RX0, RY0, RK2); + outunpack_blocks(%rsi, RC1, RD1, RA1, RB1, RK1, RX, RY, RK2); + outunpack_blocks(%rax, RC2, RD2, RA2, RB2, RK1, RX, RY, RK2); ret; __enc_xor8: - outunpack_xor_blocks(%r11, RC1, RD1, RA1, RB1, RK1, RX0, RY0, RK2); - outunpack_xor_blocks(%rax, RC2, RD2, RA2, RB2, RK1, RX0, RY0, RK2); + outunpack_xor_blocks(%rsi, RC1, RD1, RA1, RB1, RK1, RX, RY, RK2); + outunpack_xor_blocks(%rax, RC2, RD2, RA2, RB2, RK1, RX, RY, RK2); ret; @@ -322,19 +269,16 @@ twofish_dec_blk_8way: * %rdx: src */ - pushq %rbp; pushq %rbx; vmovdqu (w+4*4)(CTX), RK1; leaq (4*4*4)(%rdx), %rax; - inpack_blocks(%rdx, RC1, RD1, RA1, RB1, RK1, RX0, RY0, RK2); - preload_rgi(RC1); - rotate_1l(RA1); - inpack_blocks(%rax, RC2, RD2, RA2, RB2, RK1, RX0, RY0, RK2); - rotate_1l(RA2); + inpack_blocks(%rdx, RC1, RD1, RA1, RB1, RK1, RX, RY, RK2); + inpack_blocks(%rax, RC2, RD2, RA2, RB2, RK1, RX, RY, RK2); - movq %rsi, %r11; + xorq RID1, RID1; + xorq RID2, RID2; decrypt_cycle(7); decrypt_cycle(6); @@ -343,15 +287,14 @@ twofish_dec_blk_8way: decrypt_cycle(3); decrypt_cycle(2); decrypt_cycle(1); - decrypt_cycle_last(0); + decrypt_cycle(0); vmovdqu (w)(CTX), RK1; popq %rbx; - popq %rbp; - leaq (4*4*4)(%r11), %rax; - outunpack_blocks(%r11, RA1, RB1, RC1, RD1, RK1, RX0, RY0, RK2); - outunpack_blocks(%rax, RA2, RB2, RC2, RD2, RK1, RX0, RY0, RK2); + leaq (4*4*4)(%rsi), %rax; + outunpack_blocks(%rsi, RA1, RB1, RC1, RD1, RK1, RX, RY, RK2); + outunpack_blocks(%rax, RA2, RB2, RC2, RD2, RK1, RX, RY, RK2); ret; diff --git a/trunk/arch/x86/crypto/twofish_avx_glue.c b/trunk/arch/x86/crypto/twofish_avx_glue.c index e7708b5442e0..782b67ddaf6a 100644 --- a/trunk/arch/x86/crypto/twofish_avx_glue.c +++ b/trunk/arch/x86/crypto/twofish_avx_glue.c @@ -378,6 +378,7 @@ static struct crypto_alg twofish_algs[10] = { { .cra_alignmask = 0, .cra_type = &crypto_blkcipher_type, .cra_module = THIS_MODULE, + .cra_list = LIST_HEAD_INIT(twofish_algs[0].cra_list), .cra_u = { .blkcipher = { .min_keysize = TF_MIN_KEY_SIZE, @@ -397,6 +398,7 @@ static struct crypto_alg twofish_algs[10] = { { .cra_alignmask = 0, .cra_type = &crypto_blkcipher_type, .cra_module = THIS_MODULE, + .cra_list = LIST_HEAD_INIT(twofish_algs[1].cra_list), .cra_u = { .blkcipher = { .min_keysize = TF_MIN_KEY_SIZE, @@ -416,6 +418,7 @@ static struct crypto_alg twofish_algs[10] = { { .cra_alignmask = 0, .cra_type = &crypto_blkcipher_type, .cra_module = THIS_MODULE, + .cra_list = LIST_HEAD_INIT(twofish_algs[2].cra_list), .cra_u = { .blkcipher = { .min_keysize = TF_MIN_KEY_SIZE, @@ -436,6 +439,7 @@ static struct crypto_alg twofish_algs[10] = { { .cra_alignmask = 0, .cra_type = &crypto_blkcipher_type, .cra_module = THIS_MODULE, + .cra_list = LIST_HEAD_INIT(twofish_algs[3].cra_list), .cra_exit = lrw_twofish_exit_tfm, .cra_u = { .blkcipher = { @@ -459,6 +463,7 @@ static struct crypto_alg twofish_algs[10] = { { .cra_alignmask = 0, .cra_type = &crypto_blkcipher_type, .cra_module = THIS_MODULE, + .cra_list = LIST_HEAD_INIT(twofish_algs[4].cra_list), .cra_u = { .blkcipher = { .min_keysize = TF_MIN_KEY_SIZE * 2, @@ -479,6 +484,7 @@ static struct crypto_alg twofish_algs[10] = { { .cra_alignmask = 0, .cra_type = &crypto_ablkcipher_type, .cra_module = THIS_MODULE, + .cra_list = LIST_HEAD_INIT(twofish_algs[5].cra_list), .cra_init = ablk_init, .cra_exit = ablk_exit, .cra_u = { @@ -500,6 +506,7 @@ static struct crypto_alg twofish_algs[10] = { { .cra_alignmask = 0, .cra_type = &crypto_ablkcipher_type, .cra_module = THIS_MODULE, + .cra_list = LIST_HEAD_INIT(twofish_algs[6].cra_list), .cra_init = ablk_init, .cra_exit = ablk_exit, .cra_u = { @@ -522,6 +529,7 @@ static struct crypto_alg twofish_algs[10] = { { .cra_alignmask = 0, .cra_type = &crypto_ablkcipher_type, .cra_module = THIS_MODULE, + .cra_list = LIST_HEAD_INIT(twofish_algs[7].cra_list), .cra_init = ablk_init, .cra_exit = ablk_exit, .cra_u = { @@ -545,6 +553,7 @@ static struct crypto_alg twofish_algs[10] = { { .cra_alignmask = 0, .cra_type = &crypto_ablkcipher_type, .cra_module = THIS_MODULE, + .cra_list = LIST_HEAD_INIT(twofish_algs[8].cra_list), .cra_init = ablk_init, .cra_exit = ablk_exit, .cra_u = { @@ -569,6 +578,7 @@ static struct crypto_alg twofish_algs[10] = { { .cra_alignmask = 0, .cra_type = &crypto_ablkcipher_type, .cra_module = THIS_MODULE, + .cra_list = LIST_HEAD_INIT(twofish_algs[9].cra_list), .cra_init = ablk_init, .cra_exit = ablk_exit, .cra_u = { diff --git a/trunk/arch/x86/crypto/twofish_glue.c b/trunk/arch/x86/crypto/twofish_glue.c index 0a5202303501..359ae084275c 100644 --- a/trunk/arch/x86/crypto/twofish_glue.c +++ b/trunk/arch/x86/crypto/twofish_glue.c @@ -70,6 +70,7 @@ static struct crypto_alg alg = { .cra_ctxsize = sizeof(struct twofish_ctx), .cra_alignmask = 0, .cra_module = THIS_MODULE, + .cra_list = LIST_HEAD_INIT(alg.cra_list), .cra_u = { .cipher = { .cia_min_keysize = TF_MIN_KEY_SIZE, diff --git a/trunk/arch/x86/crypto/twofish_glue_3way.c b/trunk/arch/x86/crypto/twofish_glue_3way.c index aa3eb358b7e8..15f9347316c8 100644 --- a/trunk/arch/x86/crypto/twofish_glue_3way.c +++ b/trunk/arch/x86/crypto/twofish_glue_3way.c @@ -342,6 +342,7 @@ static struct crypto_alg tf_algs[5] = { { .cra_alignmask = 0, .cra_type = &crypto_blkcipher_type, .cra_module = THIS_MODULE, + .cra_list = LIST_HEAD_INIT(tf_algs[0].cra_list), .cra_u = { .blkcipher = { .min_keysize = TF_MIN_KEY_SIZE, @@ -361,6 +362,7 @@ static struct crypto_alg tf_algs[5] = { { .cra_alignmask = 0, .cra_type = &crypto_blkcipher_type, .cra_module = THIS_MODULE, + .cra_list = LIST_HEAD_INIT(tf_algs[1].cra_list), .cra_u = { .blkcipher = { .min_keysize = TF_MIN_KEY_SIZE, @@ -381,6 +383,7 @@ static struct crypto_alg tf_algs[5] = { { .cra_alignmask = 0, .cra_type = &crypto_blkcipher_type, .cra_module = THIS_MODULE, + .cra_list = LIST_HEAD_INIT(tf_algs[2].cra_list), .cra_u = { .blkcipher = { .min_keysize = TF_MIN_KEY_SIZE, @@ -401,6 +404,7 @@ static struct crypto_alg tf_algs[5] = { { .cra_alignmask = 0, .cra_type = &crypto_blkcipher_type, .cra_module = THIS_MODULE, + .cra_list = LIST_HEAD_INIT(tf_algs[3].cra_list), .cra_exit = lrw_twofish_exit_tfm, .cra_u = { .blkcipher = { @@ -422,6 +426,7 @@ static struct crypto_alg tf_algs[5] = { { .cra_alignmask = 0, .cra_type = &crypto_blkcipher_type, .cra_module = THIS_MODULE, + .cra_list = LIST_HEAD_INIT(tf_algs[4].cra_list), .cra_u = { .blkcipher = { .min_keysize = TF_MIN_KEY_SIZE * 2, diff --git a/trunk/arch/x86/include/asm/apic.h b/trunk/arch/x86/include/asm/apic.h index 338803422239..f34261296ffb 100644 --- a/trunk/arch/x86/include/asm/apic.h +++ b/trunk/arch/x86/include/asm/apic.h @@ -409,7 +409,7 @@ extern struct apic *apic; * to enforce the order with in them. */ #define apic_driver(sym) \ - static const struct apic *__apicdrivers_##sym __used \ + static struct apic *__apicdrivers_##sym __used \ __aligned(sizeof(struct apic *)) \ __section(.apicdrivers) = { &sym } diff --git a/trunk/arch/x86/include/asm/compat.h b/trunk/arch/x86/include/asm/compat.h index 59c6c401f79f..fedf32b73e65 100644 --- a/trunk/arch/x86/include/asm/compat.h +++ b/trunk/arch/x86/include/asm/compat.h @@ -41,7 +41,6 @@ typedef s64 __attribute__((aligned(4))) compat_s64; typedef u32 compat_uint_t; typedef u32 compat_ulong_t; typedef u64 __attribute__((aligned(4))) compat_u64; -typedef u32 compat_uptr_t; struct compat_timespec { compat_time_t tv_sec; @@ -125,78 +124,6 @@ typedef u32 compat_old_sigset_t; /* at least 32 bits */ typedef u32 compat_sigset_word; -typedef union compat_sigval { - compat_int_t sival_int; - compat_uptr_t sival_ptr; -} compat_sigval_t; - -typedef struct compat_siginfo { - int si_signo; - int si_errno; - int si_code; - - union { - int _pad[128/sizeof(int) - 3]; - - /* kill() */ - struct { - unsigned int _pid; /* sender's pid */ - unsigned int _uid; /* sender's uid */ - } _kill; - - /* POSIX.1b timers */ - struct { - compat_timer_t _tid; /* timer id */ - int _overrun; /* overrun count */ - compat_sigval_t _sigval; /* same as below */ - int _sys_private; /* not to be passed to user */ - int _overrun_incr; /* amount to add to overrun */ - } _timer; - - /* POSIX.1b signals */ - struct { - unsigned int _pid; /* sender's pid */ - unsigned int _uid; /* sender's uid */ - compat_sigval_t _sigval; - } _rt; - - /* SIGCHLD */ - struct { - unsigned int _pid; /* which child */ - unsigned int _uid; /* sender's uid */ - int _status; /* exit code */ - compat_clock_t _utime; - compat_clock_t _stime; - } _sigchld; - - /* SIGCHLD (x32 version) */ - struct { - unsigned int _pid; /* which child */ - unsigned int _uid; /* sender's uid */ - int _status; /* exit code */ - compat_s64 _utime; - compat_s64 _stime; - } _sigchld_x32; - - /* SIGILL, SIGFPE, SIGSEGV, SIGBUS */ - struct { - unsigned int _addr; /* faulting insn/memory ref. */ - } _sigfault; - - /* SIGPOLL */ - struct { - int _band; /* POLL_IN, POLL_OUT, POLL_MSG */ - int _fd; - } _sigpoll; - - struct { - unsigned int _call_addr; /* calling insn */ - int _syscall; /* triggering system call number */ - unsigned int _arch; /* AUDIT_ARCH_* of syscall */ - } _sigsys; - } _sifields; -} compat_siginfo_t; - #define COMPAT_OFF_T_MAX 0x7fffffff #define COMPAT_LOFF_T_MAX 0x7fffffffffffffffL @@ -282,6 +209,7 @@ typedef struct user_regs_struct32 compat_elf_gregset_t; * as pointers because the syscall entry code will have * appropriately converted them already. */ +typedef u32 compat_uptr_t; static inline void __user *compat_ptr(compat_uptr_t uptr) { diff --git a/trunk/arch/x86/include/asm/ia32.h b/trunk/arch/x86/include/asm/ia32.h index e6232773ce49..b04cbdb138cd 100644 --- a/trunk/arch/x86/include/asm/ia32.h +++ b/trunk/arch/x86/include/asm/ia32.h @@ -86,6 +86,73 @@ struct stat64 { unsigned long long st_ino; } __attribute__((packed)); +typedef struct compat_siginfo { + int si_signo; + int si_errno; + int si_code; + + union { + int _pad[((128 / sizeof(int)) - 3)]; + + /* kill() */ + struct { + unsigned int _pid; /* sender's pid */ + unsigned int _uid; /* sender's uid */ + } _kill; + + /* POSIX.1b timers */ + struct { + compat_timer_t _tid; /* timer id */ + int _overrun; /* overrun count */ + compat_sigval_t _sigval; /* same as below */ + int _sys_private; /* not to be passed to user */ + int _overrun_incr; /* amount to add to overrun */ + } _timer; + + /* POSIX.1b signals */ + struct { + unsigned int _pid; /* sender's pid */ + unsigned int _uid; /* sender's uid */ + compat_sigval_t _sigval; + } _rt; + + /* SIGCHLD */ + struct { + unsigned int _pid; /* which child */ + unsigned int _uid; /* sender's uid */ + int _status; /* exit code */ + compat_clock_t _utime; + compat_clock_t _stime; + } _sigchld; + + /* SIGCHLD (x32 version) */ + struct { + unsigned int _pid; /* which child */ + unsigned int _uid; /* sender's uid */ + int _status; /* exit code */ + compat_s64 _utime; + compat_s64 _stime; + } _sigchld_x32; + + /* SIGILL, SIGFPE, SIGSEGV, SIGBUS */ + struct { + unsigned int _addr; /* faulting insn/memory ref. */ + } _sigfault; + + /* SIGPOLL */ + struct { + int _band; /* POLL_IN, POLL_OUT, POLL_MSG */ + int _fd; + } _sigpoll; + + struct { + unsigned int _call_addr; /* calling insn */ + int _syscall; /* triggering system call number */ + unsigned int _arch; /* AUDIT_ARCH_* of syscall */ + } _sigsys; + } _sifields; +} compat_siginfo_t; + #define IA32_STACK_TOP IA32_PAGE_OFFSET #ifdef __KERNEL__ diff --git a/trunk/arch/x86/include/asm/kvm.h b/trunk/arch/x86/include/asm/kvm.h index a65ec29e6ffb..41e08cb6a092 100644 --- a/trunk/arch/x86/include/asm/kvm.h +++ b/trunk/arch/x86/include/asm/kvm.h @@ -41,7 +41,6 @@ #define __KVM_HAVE_DEBUGREGS #define __KVM_HAVE_XSAVE #define __KVM_HAVE_XCRS -#define __KVM_HAVE_READONLY_MEM /* Architectural interrupt line count. */ #define KVM_NR_INTERRUPTS 256 diff --git a/trunk/arch/x86/include/asm/kvm_emulate.h b/trunk/arch/x86/include/asm/kvm_emulate.h index 15f960c06ff7..c764f43b71c5 100644 --- a/trunk/arch/x86/include/asm/kvm_emulate.h +++ b/trunk/arch/x86/include/asm/kvm_emulate.h @@ -85,19 +85,6 @@ struct x86_instruction_info { #define X86EMUL_INTERCEPTED 6 /* Intercepted by nested VMCB/VMCS */ struct x86_emulate_ops { - /* - * read_gpr: read a general purpose register (rax - r15) - * - * @reg: gpr number. - */ - ulong (*read_gpr)(struct x86_emulate_ctxt *ctxt, unsigned reg); - /* - * write_gpr: write a general purpose register (rax - r15) - * - * @reg: gpr number. - * @val: value to write. - */ - void (*write_gpr)(struct x86_emulate_ctxt *ctxt, unsigned reg, ulong val); /* * read_std: Read bytes of standard (non-emulated/special) memory. * Used for descriptor reading. @@ -213,9 +200,8 @@ typedef u32 __attribute__((vector_size(16))) sse128_t; /* Type, address-of, and value of an instruction's operand. */ struct operand { - enum { OP_REG, OP_MEM, OP_MEM_STR, OP_IMM, OP_XMM, OP_MM, OP_NONE } type; + enum { OP_REG, OP_MEM, OP_IMM, OP_XMM, OP_MM, OP_NONE } type; unsigned int bytes; - unsigned int count; union { unsigned long orig_val; u64 orig_val64; @@ -235,7 +221,6 @@ struct operand { char valptr[sizeof(unsigned long) + 2]; sse128_t vec_val; u64 mm_val; - void *data; }; }; @@ -251,23 +236,14 @@ struct read_cache { unsigned long end; }; -/* Execution mode, passed to the emulator. */ -enum x86emul_mode { - X86EMUL_MODE_REAL, /* Real mode. */ - X86EMUL_MODE_VM86, /* Virtual 8086 mode. */ - X86EMUL_MODE_PROT16, /* 16-bit protected mode. */ - X86EMUL_MODE_PROT32, /* 32-bit protected mode. */ - X86EMUL_MODE_PROT64, /* 64-bit (long) mode. */ -}; - struct x86_emulate_ctxt { - const struct x86_emulate_ops *ops; + struct x86_emulate_ops *ops; /* Register state before/after emulation. */ unsigned long eflags; unsigned long eip; /* eip before instruction emulation */ /* Emulated execution mode, represented by an X86EMUL_MODE value. */ - enum x86emul_mode mode; + int mode; /* interruptibility state, as a result of execution of STI or MOV SS */ int interruptibility; @@ -305,10 +281,8 @@ struct x86_emulate_ctxt { bool rip_relative; unsigned long _eip; struct operand memop; - u32 regs_valid; /* bitmaps of registers in _regs[] that can be read */ - u32 regs_dirty; /* bitmaps of registers in _regs[] that have been written */ /* Fields above regs are cleared together. */ - unsigned long _regs[NR_VCPU_REGS]; + unsigned long regs[NR_VCPU_REGS]; struct operand *memopp; struct fetch_cache fetch; struct read_cache io_read; @@ -319,6 +293,17 @@ struct x86_emulate_ctxt { #define REPE_PREFIX 0xf3 #define REPNE_PREFIX 0xf2 +/* Execution mode, passed to the emulator. */ +#define X86EMUL_MODE_REAL 0 /* Real mode. */ +#define X86EMUL_MODE_VM86 1 /* Virtual 8086 mode. */ +#define X86EMUL_MODE_PROT16 2 /* 16-bit protected mode. */ +#define X86EMUL_MODE_PROT32 4 /* 32-bit protected mode. */ +#define X86EMUL_MODE_PROT64 8 /* 64-bit (long) mode. */ + +/* any protected mode */ +#define X86EMUL_MODE_PROT (X86EMUL_MODE_PROT16|X86EMUL_MODE_PROT32| \ + X86EMUL_MODE_PROT64) + /* CPUID vendors */ #define X86EMUL_CPUID_VENDOR_AuthenticAMD_ebx 0x68747541 #define X86EMUL_CPUID_VENDOR_AuthenticAMD_ecx 0x444d4163 @@ -409,7 +394,4 @@ int emulator_task_switch(struct x86_emulate_ctxt *ctxt, u16 tss_selector, int idt_index, int reason, bool has_error_code, u32 error_code); int emulate_int_real(struct x86_emulate_ctxt *ctxt, int irq); -void emulator_invalidate_register_cache(struct x86_emulate_ctxt *ctxt); -void emulator_writeback_register_cache(struct x86_emulate_ctxt *ctxt); - #endif /* _ASM_X86_KVM_X86_EMULATE_H */ diff --git a/trunk/arch/x86/include/asm/kvm_host.h b/trunk/arch/x86/include/asm/kvm_host.h index b2e11f452435..1eaa6b056670 100644 --- a/trunk/arch/x86/include/asm/kvm_host.h +++ b/trunk/arch/x86/include/asm/kvm_host.h @@ -271,24 +271,10 @@ struct kvm_mmu { union kvm_mmu_page_role base_role; bool direct_map; - /* - * Bitmap; bit set = permission fault - * Byte index: page fault error code [4:1] - * Bit index: pte permissions in ACC_* format - */ - u8 permissions[16]; - u64 *pae_root; u64 *lm_root; u64 rsvd_bits_mask[2][4]; - /* - * Bitmap: bit set = last pte in walk - * index[0:1]: level (zero-based) - * index[2]: pte.ps - */ - u8 last_pte_bitmap; - bool nx; u64 pdptrs[4]; /* pae */ @@ -412,15 +398,12 @@ struct kvm_vcpu_arch { struct x86_emulate_ctxt emulate_ctxt; bool emulate_regs_need_sync_to_vcpu; bool emulate_regs_need_sync_from_vcpu; - int (*complete_userspace_io)(struct kvm_vcpu *vcpu); gpa_t time; struct pvclock_vcpu_time_info hv_clock; unsigned int hw_tsc_khz; unsigned int time_offset; struct page *time_page; - /* set guest stopped flag in pvclock flags field */ - bool pvclock_set_guest_stopped_request; struct { u64 msr_val; @@ -455,7 +438,6 @@ struct kvm_vcpu_arch { unsigned long dr6; unsigned long dr7; unsigned long eff_db[KVM_NR_DB_REGS]; - unsigned long guest_debug_dr7; u64 mcg_cap; u64 mcg_status; @@ -502,24 +484,14 @@ struct kvm_vcpu_arch { }; struct kvm_lpage_info { + unsigned long rmap_pde; int write_count; }; struct kvm_arch_memory_slot { - unsigned long *rmap[KVM_NR_PAGE_SIZES]; struct kvm_lpage_info *lpage_info[KVM_NR_PAGE_SIZES - 1]; }; -struct kvm_apic_map { - struct rcu_head rcu; - u8 ldr_bits; - /* fields bellow are used to decode ldr values in different modes */ - u32 cid_shift, cid_mask, lid_mask; - struct kvm_lapic *phys_map[256]; - /* first index is cluster id second is cpu id in a cluster */ - struct kvm_lapic *logical_map[16][16]; -}; - struct kvm_arch { unsigned int n_used_mmu_pages; unsigned int n_requested_mmu_pages; @@ -537,8 +509,6 @@ struct kvm_arch { struct kvm_ioapic *vioapic; struct kvm_pit *vpit; int vapics_in_nmi_mode; - struct mutex apic_map_lock; - struct kvm_apic_map *apic_map; unsigned int tss_addr; struct page *apic_access_page; @@ -632,7 +602,8 @@ struct kvm_x86_ops { void (*vcpu_load)(struct kvm_vcpu *vcpu, int cpu); void (*vcpu_put)(struct kvm_vcpu *vcpu); - void (*update_db_bp_intercept)(struct kvm_vcpu *vcpu); + void (*set_guest_debug)(struct kvm_vcpu *vcpu, + struct kvm_guest_debug *dbg); int (*get_msr)(struct kvm_vcpu *vcpu, u32 msr_index, u64 *pdata); int (*set_msr)(struct kvm_vcpu *vcpu, u32 msr_index, u64 data); u64 (*get_segment_base)(struct kvm_vcpu *vcpu, int seg); @@ -970,7 +941,6 @@ extern bool kvm_rebooting; #define KVM_ARCH_WANT_MMU_NOTIFIER int kvm_unmap_hva(struct kvm *kvm, unsigned long hva); -int kvm_unmap_hva_range(struct kvm *kvm, unsigned long start, unsigned long end); int kvm_age_hva(struct kvm *kvm, unsigned long hva); int kvm_test_age_hva(struct kvm *kvm, unsigned long hva); void kvm_set_spte_hva(struct kvm *kvm, unsigned long hva, pte_t pte); diff --git a/trunk/arch/x86/include/asm/kvm_para.h b/trunk/arch/x86/include/asm/kvm_para.h index eb3e9d85e1f1..2f7712e08b1e 100644 --- a/trunk/arch/x86/include/asm/kvm_para.h +++ b/trunk/arch/x86/include/asm/kvm_para.h @@ -102,21 +102,21 @@ struct kvm_vcpu_pv_apf_data { extern void kvmclock_init(void); extern int kvm_register_clock(char *txt); -#ifdef CONFIG_KVM_GUEST +#ifdef CONFIG_KVM_CLOCK bool kvm_check_and_clear_guest_paused(void); #else static inline bool kvm_check_and_clear_guest_paused(void) { return false; } -#endif /* CONFIG_KVM_GUEST */ +#endif /* CONFIG_KVMCLOCK */ /* This instruction is vmcall. On non-VT architectures, it will generate a * trap that we will then rewrite to the appropriate instruction. */ #define KVM_HYPERCALL ".byte 0x0f,0x01,0xc1" -/* For KVM hypercalls, a three-byte sequence of either the vmcall or the vmmcall +/* For KVM hypercalls, a three-byte sequence of either the vmrun or the vmmrun * instruction. The hypervisor may replace it with something else but only the * instructions are guaranteed to be supported. * diff --git a/trunk/arch/x86/include/asm/xen/interface.h b/trunk/arch/x86/include/asm/xen/interface.h index 6d2f75a82a14..1707cfa928fb 100644 --- a/trunk/arch/x86/include/asm/xen/interface.h +++ b/trunk/arch/x86/include/asm/xen/interface.h @@ -51,7 +51,6 @@ * with Xen so that on ARM we can have one ABI that works for 32 and 64 * bit guests. */ typedef unsigned long xen_pfn_t; -typedef unsigned long xen_ulong_t; /* Guest handles for primitive C types. */ __DEFINE_GUEST_HANDLE(uchar, unsigned char); __DEFINE_GUEST_HANDLE(uint, unsigned int); diff --git a/trunk/arch/x86/kernel/Makefile b/trunk/arch/x86/kernel/Makefile index a48ea05157d3..8d7a619718b5 100644 --- a/trunk/arch/x86/kernel/Makefile +++ b/trunk/arch/x86/kernel/Makefile @@ -81,7 +81,8 @@ obj-$(CONFIG_DEBUG_RODATA_TEST) += test_rodata.o obj-$(CONFIG_DEBUG_NX_TEST) += test_nx.o obj-$(CONFIG_DEBUG_NMI_SELFTEST) += nmi_selftest.o -obj-$(CONFIG_KVM_GUEST) += kvm.o kvmclock.o +obj-$(CONFIG_KVM_GUEST) += kvm.o +obj-$(CONFIG_KVM_CLOCK) += kvmclock.o obj-$(CONFIG_PARAVIRT) += paravirt.o paravirt_patch_$(BITS).o obj-$(CONFIG_PARAVIRT_SPINLOCKS)+= paravirt-spinlocks.o obj-$(CONFIG_PARAVIRT_CLOCK) += pvclock.o diff --git a/trunk/arch/x86/kernel/apic/apic_numachip.c b/trunk/arch/x86/kernel/apic/apic_numachip.c index a65829ac2b9a..bc552cff2578 100644 --- a/trunk/arch/x86/kernel/apic/apic_numachip.c +++ b/trunk/arch/x86/kernel/apic/apic_numachip.c @@ -30,7 +30,7 @@ static int numachip_system __read_mostly; -static const struct apic apic_numachip __read_mostly; +static struct apic apic_numachip __read_mostly; static unsigned int get_apic_id(unsigned long x) { @@ -199,7 +199,7 @@ static int numachip_acpi_madt_oem_check(char *oem_id, char *oem_table_id) return 0; } -static const struct apic apic_numachip __refconst = { +static struct apic apic_numachip __refconst = { .name = "NumaConnect system", .probe = numachip_probe, diff --git a/trunk/arch/x86/kernel/kvm.c b/trunk/arch/x86/kernel/kvm.c index b3e5e51bc907..c1d61ee4b4f1 100644 --- a/trunk/arch/x86/kernel/kvm.c +++ b/trunk/arch/x86/kernel/kvm.c @@ -354,7 +354,6 @@ static void kvm_pv_guest_cpu_reboot(void *unused) if (kvm_para_has_feature(KVM_FEATURE_PV_EOI)) wrmsrl(MSR_KVM_PV_EOI_EN, 0); kvm_pv_disable_apf(); - kvm_disable_steal_time(); } static int kvm_pv_reboot_notify(struct notifier_block *nb, @@ -397,7 +396,9 @@ void kvm_disable_steal_time(void) #ifdef CONFIG_SMP static void __init kvm_smp_prepare_boot_cpu(void) { +#ifdef CONFIG_KVM_CLOCK WARN_ON(kvm_register_clock("primary cpu clock")); +#endif kvm_guest_cpu_init(); native_smp_prepare_boot_cpu(); } diff --git a/trunk/arch/x86/kernel/rtc.c b/trunk/arch/x86/kernel/rtc.c index 4929c1be0ac0..af6db6ec5b2a 100644 --- a/trunk/arch/x86/kernel/rtc.c +++ b/trunk/arch/x86/kernel/rtc.c @@ -225,7 +225,7 @@ static struct platform_device rtc_device = { static __init int add_rtc_cmos(void) { #ifdef CONFIG_PNP - static const char * const const ids[] __initconst = + static const char *ids[] __initconst = { "PNP0b00", "PNP0b01", "PNP0b02", }; struct pnp_dev *dev; struct pnp_id *id; diff --git a/trunk/arch/x86/kernel/setup.c b/trunk/arch/x86/kernel/setup.c index d609be046b57..4f165479c453 100644 --- a/trunk/arch/x86/kernel/setup.c +++ b/trunk/arch/x86/kernel/setup.c @@ -957,7 +957,7 @@ void __init setup_arch(char **cmdline_p) initmem_init(); memblock_find_dma_reserve(); -#ifdef CONFIG_KVM_GUEST +#ifdef CONFIG_KVM_CLOCK kvmclock_init(); #endif diff --git a/trunk/arch/x86/kvm/Kconfig b/trunk/arch/x86/kvm/Kconfig index 586f00059805..a28f338843ea 100644 --- a/trunk/arch/x86/kvm/Kconfig +++ b/trunk/arch/x86/kvm/Kconfig @@ -20,7 +20,6 @@ if VIRTUALIZATION config KVM tristate "Kernel-based Virtual Machine (KVM) support" depends on HAVE_KVM - depends on HIGH_RES_TIMERS # for device assignment: depends on PCI # for TASKSTATS/TASK_DELAY_ACCT: @@ -38,7 +37,6 @@ config KVM select TASK_DELAY_ACCT select PERF_EVENTS select HAVE_KVM_MSI - select HAVE_KVM_CPU_RELAX_INTERCEPT ---help--- Support hosting fully virtualized guest machines using hardware virtualization extensions. You will need a fairly recent diff --git a/trunk/arch/x86/kvm/Makefile b/trunk/arch/x86/kvm/Makefile index 04d30401c5cb..4f579e8dcacf 100644 --- a/trunk/arch/x86/kvm/Makefile +++ b/trunk/arch/x86/kvm/Makefile @@ -12,7 +12,7 @@ kvm-$(CONFIG_IOMMU_API) += $(addprefix ../../../virt/kvm/, iommu.o) kvm-$(CONFIG_KVM_ASYNC_PF) += $(addprefix ../../../virt/kvm/, async_pf.o) kvm-y += x86.o mmu.o emulate.o i8259.o irq.o lapic.o \ - i8254.o cpuid.o pmu.o + i8254.o timer.o cpuid.o pmu.o kvm-intel-y += vmx.o kvm-amd-y += svm.o diff --git a/trunk/arch/x86/kvm/cpuid.c b/trunk/arch/x86/kvm/cpuid.c index ec79e773342e..0595f1397b7c 100644 --- a/trunk/arch/x86/kvm/cpuid.c +++ b/trunk/arch/x86/kvm/cpuid.c @@ -316,7 +316,7 @@ static int do_cpuid_ent(struct kvm_cpuid_entry2 *entry, u32 function, } case 7: { entry->flags |= KVM_CPUID_FLAG_SIGNIFCANT_INDEX; - /* Mask ebx against host capability word 9 */ + /* Mask ebx against host capbability word 9 */ if (index == 0) { entry->ebx &= kvm_supported_word9_x86_features; cpuid_mask(&entry->ebx, 9); @@ -397,8 +397,8 @@ static int do_cpuid_ent(struct kvm_cpuid_entry2 *entry, u32 function, break; } case KVM_CPUID_SIGNATURE: { - static const char signature[12] = "KVMKVMKVM\0\0"; - const u32 *sigptr = (const u32 *)signature; + char signature[12] = "KVMKVMKVM\0\0"; + u32 *sigptr = (u32 *)signature; entry->eax = KVM_CPUID_FEATURES; entry->ebx = sigptr[0]; entry->ecx = sigptr[1]; @@ -484,10 +484,10 @@ struct kvm_cpuid_param { u32 func; u32 idx; bool has_leaf_count; - bool (*qualifier)(const struct kvm_cpuid_param *param); + bool (*qualifier)(struct kvm_cpuid_param *param); }; -static bool is_centaur_cpu(const struct kvm_cpuid_param *param) +static bool is_centaur_cpu(struct kvm_cpuid_param *param) { return boot_cpu_data.x86_vendor == X86_VENDOR_CENTAUR; } @@ -498,7 +498,7 @@ int kvm_dev_ioctl_get_supported_cpuid(struct kvm_cpuid2 *cpuid, struct kvm_cpuid_entry2 *cpuid_entries; int limit, nent = 0, r = -E2BIG, i; u32 func; - static const struct kvm_cpuid_param param[] = { + static struct kvm_cpuid_param param[] = { { .func = 0, .has_leaf_count = true }, { .func = 0x80000000, .has_leaf_count = true }, { .func = 0xC0000000, .qualifier = is_centaur_cpu, .has_leaf_count = true }, @@ -517,7 +517,7 @@ int kvm_dev_ioctl_get_supported_cpuid(struct kvm_cpuid2 *cpuid, r = 0; for (i = 0; i < ARRAY_SIZE(param); i++) { - const struct kvm_cpuid_param *ent = ¶m[i]; + struct kvm_cpuid_param *ent = ¶m[i]; if (ent->qualifier && !ent->qualifier(ent)) continue; diff --git a/trunk/arch/x86/kvm/emulate.c b/trunk/arch/x86/kvm/emulate.c index 39171cb307ea..a3b57a27be88 100644 --- a/trunk/arch/x86/kvm/emulate.c +++ b/trunk/arch/x86/kvm/emulate.c @@ -161,9 +161,9 @@ struct opcode { u64 intercept : 8; union { int (*execute)(struct x86_emulate_ctxt *ctxt); - const struct opcode *group; - const struct group_dual *gdual; - const struct gprefix *gprefix; + struct opcode *group; + struct group_dual *gdual; + struct gprefix *gprefix; } u; int (*check_perm)(struct x86_emulate_ctxt *ctxt); }; @@ -202,42 +202,6 @@ struct gprefix { #define EFLG_RESERVED_ZEROS_MASK 0xffc0802a #define EFLG_RESERVED_ONE_MASK 2 -static ulong reg_read(struct x86_emulate_ctxt *ctxt, unsigned nr) -{ - if (!(ctxt->regs_valid & (1 << nr))) { - ctxt->regs_valid |= 1 << nr; - ctxt->_regs[nr] = ctxt->ops->read_gpr(ctxt, nr); - } - return ctxt->_regs[nr]; -} - -static ulong *reg_write(struct x86_emulate_ctxt *ctxt, unsigned nr) -{ - ctxt->regs_valid |= 1 << nr; - ctxt->regs_dirty |= 1 << nr; - return &ctxt->_regs[nr]; -} - -static ulong *reg_rmw(struct x86_emulate_ctxt *ctxt, unsigned nr) -{ - reg_read(ctxt, nr); - return reg_write(ctxt, nr); -} - -static void writeback_registers(struct x86_emulate_ctxt *ctxt) -{ - unsigned reg; - - for_each_set_bit(reg, (ulong *)&ctxt->regs_dirty, 16) - ctxt->ops->write_gpr(ctxt, reg, ctxt->_regs[reg]); -} - -static void invalidate_registers(struct x86_emulate_ctxt *ctxt) -{ - ctxt->regs_dirty = 0; - ctxt->regs_valid = 0; -} - /* * Instruction emulation: * Most instructions are emulated directly via a fragment of inline assembly @@ -410,8 +374,8 @@ static void invalidate_registers(struct x86_emulate_ctxt *ctxt) #define __emulate_1op_rax_rdx(ctxt, _op, _suffix, _ex) \ do { \ unsigned long _tmp; \ - ulong *rax = reg_rmw((ctxt), VCPU_REGS_RAX); \ - ulong *rdx = reg_rmw((ctxt), VCPU_REGS_RDX); \ + ulong *rax = &(ctxt)->regs[VCPU_REGS_RAX]; \ + ulong *rdx = &(ctxt)->regs[VCPU_REGS_RDX]; \ \ __asm__ __volatile__ ( \ _PRE_EFLAGS("0", "5", "1") \ @@ -530,7 +494,7 @@ register_address_increment(struct x86_emulate_ctxt *ctxt, unsigned long *reg, in static void rsp_increment(struct x86_emulate_ctxt *ctxt, int inc) { - masked_increment(reg_rmw(ctxt, VCPU_REGS_RSP), stack_mask(ctxt), inc); + masked_increment(&ctxt->regs[VCPU_REGS_RSP], stack_mask(ctxt), inc); } static inline void jmp_rel(struct x86_emulate_ctxt *ctxt, int rel) @@ -668,6 +632,8 @@ static int __linearize(struct x86_emulate_ctxt *ctxt, la = seg_base(ctxt, addr.seg) + addr.ea; switch (ctxt->mode) { + case X86EMUL_MODE_REAL: + break; case X86EMUL_MODE_PROT64: if (((signed long)la << 16) >> 16 != la) return emulate_gp(ctxt, 0); @@ -689,7 +655,7 @@ static int __linearize(struct x86_emulate_ctxt *ctxt, if (addr.ea > lim || (u32)(addr.ea + size - 1) > lim) goto bad; } else { - /* expand-down segment */ + /* exapand-down segment */ if (addr.ea <= lim || (u32)(addr.ea + size - 1) <= lim) goto bad; lim = desc.d ? 0xffffffff : 0xffff; @@ -697,10 +663,7 @@ static int __linearize(struct x86_emulate_ctxt *ctxt, goto bad; } cpl = ctxt->ops->cpl(ctxt); - if (ctxt->mode == X86EMUL_MODE_REAL) - rpl = 0; - else - rpl = sel & 3; + rpl = sel & 3; cpl = max(cpl, rpl); if (!(desc.type & 8)) { /* data segment */ @@ -725,9 +688,9 @@ static int __linearize(struct x86_emulate_ctxt *ctxt, return X86EMUL_CONTINUE; bad: if (addr.seg == VCPU_SREG_SS) - return emulate_ss(ctxt, sel); + return emulate_ss(ctxt, addr.seg); else - return emulate_gp(ctxt, sel); + return emulate_gp(ctxt, addr.seg); } static int linearize(struct x86_emulate_ctxt *ctxt, @@ -823,15 +786,14 @@ static int do_insn_fetch(struct x86_emulate_ctxt *ctxt, * pointer into the block that addresses the relevant register. * @highbyte_regs specifies whether to decode AH,CH,DH,BH. */ -static void *decode_register(struct x86_emulate_ctxt *ctxt, u8 modrm_reg, +static void *decode_register(u8 modrm_reg, unsigned long *regs, int highbyte_regs) { void *p; + p = ®s[modrm_reg]; if (highbyte_regs && modrm_reg >= 4 && modrm_reg < 8) - p = (unsigned char *)reg_rmw(ctxt, modrm_reg & 3) + 1; - else - p = reg_rmw(ctxt, modrm_reg); + p = (unsigned char *)®s[modrm_reg & 3] + 1; return p; } @@ -909,23 +871,23 @@ static void read_sse_reg(struct x86_emulate_ctxt *ctxt, sse128_t *data, int reg) { ctxt->ops->get_fpu(ctxt); switch (reg) { - case 0: asm("movdqa %%xmm0, %0" : "=m"(*data)); break; - case 1: asm("movdqa %%xmm1, %0" : "=m"(*data)); break; - case 2: asm("movdqa %%xmm2, %0" : "=m"(*data)); break; - case 3: asm("movdqa %%xmm3, %0" : "=m"(*data)); break; - case 4: asm("movdqa %%xmm4, %0" : "=m"(*data)); break; - case 5: asm("movdqa %%xmm5, %0" : "=m"(*data)); break; - case 6: asm("movdqa %%xmm6, %0" : "=m"(*data)); break; - case 7: asm("movdqa %%xmm7, %0" : "=m"(*data)); break; + case 0: asm("movdqu %%xmm0, %0" : "=m"(*data)); break; + case 1: asm("movdqu %%xmm1, %0" : "=m"(*data)); break; + case 2: asm("movdqu %%xmm2, %0" : "=m"(*data)); break; + case 3: asm("movdqu %%xmm3, %0" : "=m"(*data)); break; + case 4: asm("movdqu %%xmm4, %0" : "=m"(*data)); break; + case 5: asm("movdqu %%xmm5, %0" : "=m"(*data)); break; + case 6: asm("movdqu %%xmm6, %0" : "=m"(*data)); break; + case 7: asm("movdqu %%xmm7, %0" : "=m"(*data)); break; #ifdef CONFIG_X86_64 - case 8: asm("movdqa %%xmm8, %0" : "=m"(*data)); break; - case 9: asm("movdqa %%xmm9, %0" : "=m"(*data)); break; - case 10: asm("movdqa %%xmm10, %0" : "=m"(*data)); break; - case 11: asm("movdqa %%xmm11, %0" : "=m"(*data)); break; - case 12: asm("movdqa %%xmm12, %0" : "=m"(*data)); break; - case 13: asm("movdqa %%xmm13, %0" : "=m"(*data)); break; - case 14: asm("movdqa %%xmm14, %0" : "=m"(*data)); break; - case 15: asm("movdqa %%xmm15, %0" : "=m"(*data)); break; + case 8: asm("movdqu %%xmm8, %0" : "=m"(*data)); break; + case 9: asm("movdqu %%xmm9, %0" : "=m"(*data)); break; + case 10: asm("movdqu %%xmm10, %0" : "=m"(*data)); break; + case 11: asm("movdqu %%xmm11, %0" : "=m"(*data)); break; + case 12: asm("movdqu %%xmm12, %0" : "=m"(*data)); break; + case 13: asm("movdqu %%xmm13, %0" : "=m"(*data)); break; + case 14: asm("movdqu %%xmm14, %0" : "=m"(*data)); break; + case 15: asm("movdqu %%xmm15, %0" : "=m"(*data)); break; #endif default: BUG(); } @@ -937,23 +899,23 @@ static void write_sse_reg(struct x86_emulate_ctxt *ctxt, sse128_t *data, { ctxt->ops->get_fpu(ctxt); switch (reg) { - case 0: asm("movdqa %0, %%xmm0" : : "m"(*data)); break; - case 1: asm("movdqa %0, %%xmm1" : : "m"(*data)); break; - case 2: asm("movdqa %0, %%xmm2" : : "m"(*data)); break; - case 3: asm("movdqa %0, %%xmm3" : : "m"(*data)); break; - case 4: asm("movdqa %0, %%xmm4" : : "m"(*data)); break; - case 5: asm("movdqa %0, %%xmm5" : : "m"(*data)); break; - case 6: asm("movdqa %0, %%xmm6" : : "m"(*data)); break; - case 7: asm("movdqa %0, %%xmm7" : : "m"(*data)); break; + case 0: asm("movdqu %0, %%xmm0" : : "m"(*data)); break; + case 1: asm("movdqu %0, %%xmm1" : : "m"(*data)); break; + case 2: asm("movdqu %0, %%xmm2" : : "m"(*data)); break; + case 3: asm("movdqu %0, %%xmm3" : : "m"(*data)); break; + case 4: asm("movdqu %0, %%xmm4" : : "m"(*data)); break; + case 5: asm("movdqu %0, %%xmm5" : : "m"(*data)); break; + case 6: asm("movdqu %0, %%xmm6" : : "m"(*data)); break; + case 7: asm("movdqu %0, %%xmm7" : : "m"(*data)); break; #ifdef CONFIG_X86_64 - case 8: asm("movdqa %0, %%xmm8" : : "m"(*data)); break; - case 9: asm("movdqa %0, %%xmm9" : : "m"(*data)); break; - case 10: asm("movdqa %0, %%xmm10" : : "m"(*data)); break; - case 11: asm("movdqa %0, %%xmm11" : : "m"(*data)); break; - case 12: asm("movdqa %0, %%xmm12" : : "m"(*data)); break; - case 13: asm("movdqa %0, %%xmm13" : : "m"(*data)); break; - case 14: asm("movdqa %0, %%xmm14" : : "m"(*data)); break; - case 15: asm("movdqa %0, %%xmm15" : : "m"(*data)); break; + case 8: asm("movdqu %0, %%xmm8" : : "m"(*data)); break; + case 9: asm("movdqu %0, %%xmm9" : : "m"(*data)); break; + case 10: asm("movdqu %0, %%xmm10" : : "m"(*data)); break; + case 11: asm("movdqu %0, %%xmm11" : : "m"(*data)); break; + case 12: asm("movdqu %0, %%xmm12" : : "m"(*data)); break; + case 13: asm("movdqu %0, %%xmm13" : : "m"(*data)); break; + case 14: asm("movdqu %0, %%xmm14" : : "m"(*data)); break; + case 15: asm("movdqu %0, %%xmm15" : : "m"(*data)); break; #endif default: BUG(); } @@ -1020,10 +982,10 @@ static void decode_register_operand(struct x86_emulate_ctxt *ctxt, op->type = OP_REG; if (ctxt->d & ByteOp) { - op->addr.reg = decode_register(ctxt, reg, highbyte_regs); + op->addr.reg = decode_register(reg, ctxt->regs, highbyte_regs); op->bytes = 1; } else { - op->addr.reg = decode_register(ctxt, reg, 0); + op->addr.reg = decode_register(reg, ctxt->regs, 0); op->bytes = ctxt->op_bytes; } fetch_register_operand(op); @@ -1058,7 +1020,8 @@ static int decode_modrm(struct x86_emulate_ctxt *ctxt, if (ctxt->modrm_mod == 3) { op->type = OP_REG; op->bytes = (ctxt->d & ByteOp) ? 1 : ctxt->op_bytes; - op->addr.reg = decode_register(ctxt, ctxt->modrm_rm, ctxt->d & ByteOp); + op->addr.reg = decode_register(ctxt->modrm_rm, + ctxt->regs, ctxt->d & ByteOp); if (ctxt->d & Sse) { op->type = OP_XMM; op->bytes = 16; @@ -1079,10 +1042,10 @@ static int decode_modrm(struct x86_emulate_ctxt *ctxt, op->type = OP_MEM; if (ctxt->ad_bytes == 2) { - unsigned bx = reg_read(ctxt, VCPU_REGS_RBX); - unsigned bp = reg_read(ctxt, VCPU_REGS_RBP); - unsigned si = reg_read(ctxt, VCPU_REGS_RSI); - unsigned di = reg_read(ctxt, VCPU_REGS_RDI); + unsigned bx = ctxt->regs[VCPU_REGS_RBX]; + unsigned bp = ctxt->regs[VCPU_REGS_RBP]; + unsigned si = ctxt->regs[VCPU_REGS_RSI]; + unsigned di = ctxt->regs[VCPU_REGS_RDI]; /* 16-bit ModR/M decode. */ switch (ctxt->modrm_mod) { @@ -1139,17 +1102,17 @@ static int decode_modrm(struct x86_emulate_ctxt *ctxt, if ((base_reg & 7) == 5 && ctxt->modrm_mod == 0) modrm_ea += insn_fetch(s32, ctxt); else { - modrm_ea += reg_read(ctxt, base_reg); + modrm_ea += ctxt->regs[base_reg]; adjust_modrm_seg(ctxt, base_reg); } if (index_reg != 4) - modrm_ea += reg_read(ctxt, index_reg) << scale; + modrm_ea += ctxt->regs[index_reg] << scale; } else if ((ctxt->modrm_rm & 7) == 5 && ctxt->modrm_mod == 0) { if (ctxt->mode == X86EMUL_MODE_PROT64) ctxt->rip_relative = 1; } else { base_reg = ctxt->modrm_rm; - modrm_ea += reg_read(ctxt, base_reg); + modrm_ea += ctxt->regs[base_reg]; adjust_modrm_seg(ctxt, base_reg); } switch (ctxt->modrm_mod) { @@ -1216,21 +1179,24 @@ static int read_emulated(struct x86_emulate_ctxt *ctxt, int rc; struct read_cache *mc = &ctxt->mem_read; - if (mc->pos < mc->end) - goto read_cached; - - WARN_ON((mc->end + size) >= sizeof(mc->data)); + while (size) { + int n = min(size, 8u); + size -= n; + if (mc->pos < mc->end) + goto read_cached; - rc = ctxt->ops->read_emulated(ctxt, addr, mc->data + mc->end, size, - &ctxt->exception); - if (rc != X86EMUL_CONTINUE) - return rc; - - mc->end += size; + rc = ctxt->ops->read_emulated(ctxt, addr, mc->data + mc->end, n, + &ctxt->exception); + if (rc != X86EMUL_CONTINUE) + return rc; + mc->end += n; -read_cached: - memcpy(dest, mc->data + mc->pos, size); - mc->pos += size; + read_cached: + memcpy(dest, mc->data + mc->pos, n); + mc->pos += n; + dest += n; + addr += n; + } return X86EMUL_CONTINUE; } @@ -1287,10 +1253,10 @@ static int pio_in_emulated(struct x86_emulate_ctxt *ctxt, if (rc->pos == rc->end) { /* refill pio read ahead */ unsigned int in_page, n; unsigned int count = ctxt->rep_prefix ? - address_mask(ctxt, reg_read(ctxt, VCPU_REGS_RCX)) : 1; + address_mask(ctxt, ctxt->regs[VCPU_REGS_RCX]) : 1; in_page = (ctxt->eflags & EFLG_DF) ? - offset_in_page(reg_read(ctxt, VCPU_REGS_RDI)) : - PAGE_SIZE - offset_in_page(reg_read(ctxt, VCPU_REGS_RDI)); + offset_in_page(ctxt->regs[VCPU_REGS_RDI]) : + PAGE_SIZE - offset_in_page(ctxt->regs[VCPU_REGS_RDI]); n = min(min(in_page, (unsigned int)sizeof(rc->data)) / size, count); if (n == 0) @@ -1301,15 +1267,8 @@ static int pio_in_emulated(struct x86_emulate_ctxt *ctxt, rc->end = n * size; } - if (ctxt->rep_prefix && !(ctxt->eflags & EFLG_DF)) { - ctxt->dst.data = rc->data + rc->pos; - ctxt->dst.type = OP_MEM_STR; - ctxt->dst.count = (rc->end - rc->pos) / size; - rc->pos = rc->end; - } else { - memcpy(dest, rc->data + rc->pos, size); - rc->pos += size; - } + memcpy(dest, rc->data + rc->pos, size); + rc->pos += size; return 1; } @@ -1332,7 +1291,7 @@ static int read_interrupt_descriptor(struct x86_emulate_ctxt *ctxt, static void get_descriptor_table_ptr(struct x86_emulate_ctxt *ctxt, u16 selector, struct desc_ptr *dt) { - const struct x86_emulate_ops *ops = ctxt->ops; + struct x86_emulate_ops *ops = ctxt->ops; if (selector & 1 << 2) { struct desc_struct desc; @@ -1396,15 +1355,19 @@ static int load_segment_descriptor(struct x86_emulate_ctxt *ctxt, bool null_selector = !(selector & ~0x3); /* 0000-0003 are null */ ulong desc_addr; int ret; - u16 dummy; memset(&seg_desc, 0, sizeof seg_desc); if ((seg <= VCPU_SREG_GS && ctxt->mode == X86EMUL_MODE_VM86) || ctxt->mode == X86EMUL_MODE_REAL) { /* set real mode segment descriptor */ - ctxt->ops->get_segment(ctxt, &dummy, &seg_desc, NULL, seg); set_desc_base(&seg_desc, selector << 4); + set_desc_limit(&seg_desc, 0xffff); + seg_desc.type = 3; + seg_desc.p = 1; + seg_desc.s = 1; + if (ctxt->mode == X86EMUL_MODE_VM86) + seg_desc.dpl = 3; goto load; } @@ -1433,7 +1396,7 @@ static int load_segment_descriptor(struct x86_emulate_ctxt *ctxt, err_code = selector & 0xfffc; err_vec = GP_VECTOR; - /* can't load system descriptor into segment selector */ + /* can't load system descriptor into segment selecor */ if (seg <= VCPU_SREG_GS && !seg_desc.s) goto exception; @@ -1553,14 +1516,6 @@ static int writeback(struct x86_emulate_ctxt *ctxt) if (rc != X86EMUL_CONTINUE) return rc; break; - case OP_MEM_STR: - rc = segmented_write(ctxt, - ctxt->dst.addr.mem, - ctxt->dst.data, - ctxt->dst.bytes * ctxt->dst.count); - if (rc != X86EMUL_CONTINUE) - return rc; - break; case OP_XMM: write_sse_reg(ctxt, &ctxt->dst.vec_val, ctxt->dst.addr.xmm); break; @@ -1581,7 +1536,7 @@ static int push(struct x86_emulate_ctxt *ctxt, void *data, int bytes) struct segmented_address addr; rsp_increment(ctxt, -bytes); - addr.ea = reg_read(ctxt, VCPU_REGS_RSP) & stack_mask(ctxt); + addr.ea = ctxt->regs[VCPU_REGS_RSP] & stack_mask(ctxt); addr.seg = VCPU_SREG_SS; return segmented_write(ctxt, addr, data, bytes); @@ -1600,7 +1555,7 @@ static int emulate_pop(struct x86_emulate_ctxt *ctxt, int rc; struct segmented_address addr; - addr.ea = reg_read(ctxt, VCPU_REGS_RSP) & stack_mask(ctxt); + addr.ea = ctxt->regs[VCPU_REGS_RSP] & stack_mask(ctxt); addr.seg = VCPU_SREG_SS; rc = segmented_read(ctxt, addr, dest, len); if (rc != X86EMUL_CONTINUE) @@ -1668,28 +1623,26 @@ static int em_enter(struct x86_emulate_ctxt *ctxt) int rc; unsigned frame_size = ctxt->src.val; unsigned nesting_level = ctxt->src2.val & 31; - ulong rbp; if (nesting_level) return X86EMUL_UNHANDLEABLE; - rbp = reg_read(ctxt, VCPU_REGS_RBP); - rc = push(ctxt, &rbp, stack_size(ctxt)); + rc = push(ctxt, &ctxt->regs[VCPU_REGS_RBP], stack_size(ctxt)); if (rc != X86EMUL_CONTINUE) return rc; - assign_masked(reg_rmw(ctxt, VCPU_REGS_RBP), reg_read(ctxt, VCPU_REGS_RSP), + assign_masked(&ctxt->regs[VCPU_REGS_RBP], ctxt->regs[VCPU_REGS_RSP], stack_mask(ctxt)); - assign_masked(reg_rmw(ctxt, VCPU_REGS_RSP), - reg_read(ctxt, VCPU_REGS_RSP) - frame_size, + assign_masked(&ctxt->regs[VCPU_REGS_RSP], + ctxt->regs[VCPU_REGS_RSP] - frame_size, stack_mask(ctxt)); return X86EMUL_CONTINUE; } static int em_leave(struct x86_emulate_ctxt *ctxt) { - assign_masked(reg_rmw(ctxt, VCPU_REGS_RSP), reg_read(ctxt, VCPU_REGS_RBP), + assign_masked(&ctxt->regs[VCPU_REGS_RSP], ctxt->regs[VCPU_REGS_RBP], stack_mask(ctxt)); - return emulate_pop(ctxt, reg_rmw(ctxt, VCPU_REGS_RBP), ctxt->op_bytes); + return emulate_pop(ctxt, &ctxt->regs[VCPU_REGS_RBP], ctxt->op_bytes); } static int em_push_sreg(struct x86_emulate_ctxt *ctxt) @@ -1717,13 +1670,13 @@ static int em_pop_sreg(struct x86_emulate_ctxt *ctxt) static int em_pusha(struct x86_emulate_ctxt *ctxt) { - unsigned long old_esp = reg_read(ctxt, VCPU_REGS_RSP); + unsigned long old_esp = ctxt->regs[VCPU_REGS_RSP]; int rc = X86EMUL_CONTINUE; int reg = VCPU_REGS_RAX; while (reg <= VCPU_REGS_RDI) { (reg == VCPU_REGS_RSP) ? - (ctxt->src.val = old_esp) : (ctxt->src.val = reg_read(ctxt, reg)); + (ctxt->src.val = old_esp) : (ctxt->src.val = ctxt->regs[reg]); rc = em_push(ctxt); if (rc != X86EMUL_CONTINUE) @@ -1752,7 +1705,7 @@ static int em_popa(struct x86_emulate_ctxt *ctxt) --reg; } - rc = emulate_pop(ctxt, reg_rmw(ctxt, reg), ctxt->op_bytes); + rc = emulate_pop(ctxt, &ctxt->regs[reg], ctxt->op_bytes); if (rc != X86EMUL_CONTINUE) break; --reg; @@ -1760,9 +1713,9 @@ static int em_popa(struct x86_emulate_ctxt *ctxt) return rc; } -static int __emulate_int_real(struct x86_emulate_ctxt *ctxt, int irq) +int emulate_int_real(struct x86_emulate_ctxt *ctxt, int irq) { - const struct x86_emulate_ops *ops = ctxt->ops; + struct x86_emulate_ops *ops = ctxt->ops; int rc; struct desc_ptr dt; gva_t cs_addr; @@ -1809,22 +1762,11 @@ static int __emulate_int_real(struct x86_emulate_ctxt *ctxt, int irq) return rc; } -int emulate_int_real(struct x86_emulate_ctxt *ctxt, int irq) -{ - int rc; - - invalidate_registers(ctxt); - rc = __emulate_int_real(ctxt, irq); - if (rc == X86EMUL_CONTINUE) - writeback_registers(ctxt); - return rc; -} - static int emulate_int(struct x86_emulate_ctxt *ctxt, int irq) { switch(ctxt->mode) { case X86EMUL_MODE_REAL: - return __emulate_int_real(ctxt, irq); + return emulate_int_real(ctxt, irq); case X86EMUL_MODE_VM86: case X86EMUL_MODE_PROT16: case X86EMUL_MODE_PROT32: @@ -2031,14 +1973,14 @@ static int em_cmpxchg8b(struct x86_emulate_ctxt *ctxt) { u64 old = ctxt->dst.orig_val64; - if (((u32) (old >> 0) != (u32) reg_read(ctxt, VCPU_REGS_RAX)) || - ((u32) (old >> 32) != (u32) reg_read(ctxt, VCPU_REGS_RDX))) { - *reg_write(ctxt, VCPU_REGS_RAX) = (u32) (old >> 0); - *reg_write(ctxt, VCPU_REGS_RDX) = (u32) (old >> 32); + if (((u32) (old >> 0) != (u32) ctxt->regs[VCPU_REGS_RAX]) || + ((u32) (old >> 32) != (u32) ctxt->regs[VCPU_REGS_RDX])) { + ctxt->regs[VCPU_REGS_RAX] = (u32) (old >> 0); + ctxt->regs[VCPU_REGS_RDX] = (u32) (old >> 32); ctxt->eflags &= ~EFLG_ZF; } else { - ctxt->dst.val64 = ((u64)reg_read(ctxt, VCPU_REGS_RCX) << 32) | - (u32) reg_read(ctxt, VCPU_REGS_RBX); + ctxt->dst.val64 = ((u64)ctxt->regs[VCPU_REGS_RCX] << 32) | + (u32) ctxt->regs[VCPU_REGS_RBX]; ctxt->eflags |= EFLG_ZF; } @@ -2074,7 +2016,7 @@ static int em_cmpxchg(struct x86_emulate_ctxt *ctxt) { /* Save real source value, then compare EAX against destination. */ ctxt->src.orig_val = ctxt->src.val; - ctxt->src.val = reg_read(ctxt, VCPU_REGS_RAX); + ctxt->src.val = ctxt->regs[VCPU_REGS_RAX]; emulate_2op_SrcV(ctxt, "cmp"); if (ctxt->eflags & EFLG_ZF) { @@ -2083,7 +2025,7 @@ static int em_cmpxchg(struct x86_emulate_ctxt *ctxt) } else { /* Failure: write the value we saw to EAX. */ ctxt->dst.type = OP_REG; - ctxt->dst.addr.reg = reg_rmw(ctxt, VCPU_REGS_RAX); + ctxt->dst.addr.reg = (unsigned long *)&ctxt->regs[VCPU_REGS_RAX]; } return X86EMUL_CONTINUE; } @@ -2108,6 +2050,12 @@ static void setup_syscalls_segments(struct x86_emulate_ctxt *ctxt, struct desc_struct *cs, struct desc_struct *ss) { + u16 selector; + + memset(cs, 0, sizeof(struct desc_struct)); + ctxt->ops->get_segment(ctxt, &selector, cs, NULL, VCPU_SREG_CS); + memset(ss, 0, sizeof(struct desc_struct)); + cs->l = 0; /* will be adjusted later */ set_desc_base(cs, 0); /* flat segment */ cs->g = 1; /* 4kb granularity */ @@ -2117,7 +2065,6 @@ setup_syscalls_segments(struct x86_emulate_ctxt *ctxt, cs->dpl = 0; /* will be adjusted later */ cs->p = 1; cs->d = 1; - cs->avl = 0; set_desc_base(ss, 0); /* flat segment */ set_desc_limit(ss, 0xfffff); /* 4GB limit */ @@ -2127,8 +2074,6 @@ setup_syscalls_segments(struct x86_emulate_ctxt *ctxt, ss->d = 1; /* 32bit stack segment */ ss->dpl = 0; ss->p = 1; - ss->l = 0; - ss->avl = 0; } static bool vendor_intel(struct x86_emulate_ctxt *ctxt) @@ -2144,7 +2089,7 @@ static bool vendor_intel(struct x86_emulate_ctxt *ctxt) static bool em_syscall_is_enabled(struct x86_emulate_ctxt *ctxt) { - const struct x86_emulate_ops *ops = ctxt->ops; + struct x86_emulate_ops *ops = ctxt->ops; u32 eax, ebx, ecx, edx; /* @@ -2188,7 +2133,7 @@ static bool em_syscall_is_enabled(struct x86_emulate_ctxt *ctxt) static int em_syscall(struct x86_emulate_ctxt *ctxt) { - const struct x86_emulate_ops *ops = ctxt->ops; + struct x86_emulate_ops *ops = ctxt->ops; struct desc_struct cs, ss; u64 msr_data; u16 cs_sel, ss_sel; @@ -2220,10 +2165,10 @@ static int em_syscall(struct x86_emulate_ctxt *ctxt) ops->set_segment(ctxt, cs_sel, &cs, 0, VCPU_SREG_CS); ops->set_segment(ctxt, ss_sel, &ss, 0, VCPU_SREG_SS); - *reg_write(ctxt, VCPU_REGS_RCX) = ctxt->_eip; + ctxt->regs[VCPU_REGS_RCX] = ctxt->_eip; if (efer & EFER_LMA) { #ifdef CONFIG_X86_64 - *reg_write(ctxt, VCPU_REGS_R11) = ctxt->eflags & ~EFLG_RF; + ctxt->regs[VCPU_REGS_R11] = ctxt->eflags & ~EFLG_RF; ops->get_msr(ctxt, ctxt->mode == X86EMUL_MODE_PROT64 ? @@ -2246,7 +2191,7 @@ static int em_syscall(struct x86_emulate_ctxt *ctxt) static int em_sysenter(struct x86_emulate_ctxt *ctxt) { - const struct x86_emulate_ops *ops = ctxt->ops; + struct x86_emulate_ops *ops = ctxt->ops; struct desc_struct cs, ss; u64 msr_data; u16 cs_sel, ss_sel; @@ -2283,8 +2228,6 @@ static int em_sysenter(struct x86_emulate_ctxt *ctxt) if (msr_data == 0x0) return emulate_gp(ctxt, 0); break; - default: - break; } ctxt->eflags &= ~(EFLG_VM | EFLG_IF | EFLG_RF); @@ -2304,14 +2247,14 @@ static int em_sysenter(struct x86_emulate_ctxt *ctxt) ctxt->_eip = msr_data; ops->get_msr(ctxt, MSR_IA32_SYSENTER_ESP, &msr_data); - *reg_write(ctxt, VCPU_REGS_RSP) = msr_data; + ctxt->regs[VCPU_REGS_RSP] = msr_data; return X86EMUL_CONTINUE; } static int em_sysexit(struct x86_emulate_ctxt *ctxt) { - const struct x86_emulate_ops *ops = ctxt->ops; + struct x86_emulate_ops *ops = ctxt->ops; struct desc_struct cs, ss; u64 msr_data; int usermode; @@ -2354,8 +2297,8 @@ static int em_sysexit(struct x86_emulate_ctxt *ctxt) ops->set_segment(ctxt, cs_sel, &cs, 0, VCPU_SREG_CS); ops->set_segment(ctxt, ss_sel, &ss, 0, VCPU_SREG_SS); - ctxt->_eip = reg_read(ctxt, VCPU_REGS_RDX); - *reg_write(ctxt, VCPU_REGS_RSP) = reg_read(ctxt, VCPU_REGS_RCX); + ctxt->_eip = ctxt->regs[VCPU_REGS_RDX]; + ctxt->regs[VCPU_REGS_RSP] = ctxt->regs[VCPU_REGS_RCX]; return X86EMUL_CONTINUE; } @@ -2374,7 +2317,7 @@ static bool emulator_bad_iopl(struct x86_emulate_ctxt *ctxt) static bool emulator_io_port_access_allowed(struct x86_emulate_ctxt *ctxt, u16 port, u16 len) { - const struct x86_emulate_ops *ops = ctxt->ops; + struct x86_emulate_ops *ops = ctxt->ops; struct desc_struct tr_seg; u32 base3; int r; @@ -2424,14 +2367,14 @@ static void save_state_to_tss16(struct x86_emulate_ctxt *ctxt, { tss->ip = ctxt->_eip; tss->flag = ctxt->eflags; - tss->ax = reg_read(ctxt, VCPU_REGS_RAX); - tss->cx = reg_read(ctxt, VCPU_REGS_RCX); - tss->dx = reg_read(ctxt, VCPU_REGS_RDX); - tss->bx = reg_read(ctxt, VCPU_REGS_RBX); - tss->sp = reg_read(ctxt, VCPU_REGS_RSP); - tss->bp = reg_read(ctxt, VCPU_REGS_RBP); - tss->si = reg_read(ctxt, VCPU_REGS_RSI); - tss->di = reg_read(ctxt, VCPU_REGS_RDI); + tss->ax = ctxt->regs[VCPU_REGS_RAX]; + tss->cx = ctxt->regs[VCPU_REGS_RCX]; + tss->dx = ctxt->regs[VCPU_REGS_RDX]; + tss->bx = ctxt->regs[VCPU_REGS_RBX]; + tss->sp = ctxt->regs[VCPU_REGS_RSP]; + tss->bp = ctxt->regs[VCPU_REGS_RBP]; + tss->si = ctxt->regs[VCPU_REGS_RSI]; + tss->di = ctxt->regs[VCPU_REGS_RDI]; tss->es = get_segment_selector(ctxt, VCPU_SREG_ES); tss->cs = get_segment_selector(ctxt, VCPU_SREG_CS); @@ -2447,14 +2390,14 @@ static int load_state_from_tss16(struct x86_emulate_ctxt *ctxt, ctxt->_eip = tss->ip; ctxt->eflags = tss->flag | 2; - *reg_write(ctxt, VCPU_REGS_RAX) = tss->ax; - *reg_write(ctxt, VCPU_REGS_RCX) = tss->cx; - *reg_write(ctxt, VCPU_REGS_RDX) = tss->dx; - *reg_write(ctxt, VCPU_REGS_RBX) = tss->bx; - *reg_write(ctxt, VCPU_REGS_RSP) = tss->sp; - *reg_write(ctxt, VCPU_REGS_RBP) = tss->bp; - *reg_write(ctxt, VCPU_REGS_RSI) = tss->si; - *reg_write(ctxt, VCPU_REGS_RDI) = tss->di; + ctxt->regs[VCPU_REGS_RAX] = tss->ax; + ctxt->regs[VCPU_REGS_RCX] = tss->cx; + ctxt->regs[VCPU_REGS_RDX] = tss->dx; + ctxt->regs[VCPU_REGS_RBX] = tss->bx; + ctxt->regs[VCPU_REGS_RSP] = tss->sp; + ctxt->regs[VCPU_REGS_RBP] = tss->bp; + ctxt->regs[VCPU_REGS_RSI] = tss->si; + ctxt->regs[VCPU_REGS_RDI] = tss->di; /* * SDM says that segment selectors are loaded before segment @@ -2467,7 +2410,7 @@ static int load_state_from_tss16(struct x86_emulate_ctxt *ctxt, set_segment_selector(ctxt, tss->ds, VCPU_SREG_DS); /* - * Now load segment descriptors. If fault happens at this stage + * Now load segment descriptors. If fault happenes at this stage * it is handled in a context of new task */ ret = load_segment_descriptor(ctxt, tss->ldt, VCPU_SREG_LDTR); @@ -2493,7 +2436,7 @@ static int task_switch_16(struct x86_emulate_ctxt *ctxt, u16 tss_selector, u16 old_tss_sel, ulong old_tss_base, struct desc_struct *new_desc) { - const struct x86_emulate_ops *ops = ctxt->ops; + struct x86_emulate_ops *ops = ctxt->ops; struct tss_segment_16 tss_seg; int ret; u32 new_tss_base = get_desc_base(new_desc); @@ -2539,14 +2482,14 @@ static void save_state_to_tss32(struct x86_emulate_ctxt *ctxt, tss->cr3 = ctxt->ops->get_cr(ctxt, 3); tss->eip = ctxt->_eip; tss->eflags = ctxt->eflags; - tss->eax = reg_read(ctxt, VCPU_REGS_RAX); - tss->ecx = reg_read(ctxt, VCPU_REGS_RCX); - tss->edx = reg_read(ctxt, VCPU_REGS_RDX); - tss->ebx = reg_read(ctxt, VCPU_REGS_RBX); - tss->esp = reg_read(ctxt, VCPU_REGS_RSP); - tss->ebp = reg_read(ctxt, VCPU_REGS_RBP); - tss->esi = reg_read(ctxt, VCPU_REGS_RSI); - tss->edi = reg_read(ctxt, VCPU_REGS_RDI); + tss->eax = ctxt->regs[VCPU_REGS_RAX]; + tss->ecx = ctxt->regs[VCPU_REGS_RCX]; + tss->edx = ctxt->regs[VCPU_REGS_RDX]; + tss->ebx = ctxt->regs[VCPU_REGS_RBX]; + tss->esp = ctxt->regs[VCPU_REGS_RSP]; + tss->ebp = ctxt->regs[VCPU_REGS_RBP]; + tss->esi = ctxt->regs[VCPU_REGS_RSI]; + tss->edi = ctxt->regs[VCPU_REGS_RDI]; tss->es = get_segment_selector(ctxt, VCPU_SREG_ES); tss->cs = get_segment_selector(ctxt, VCPU_SREG_CS); @@ -2568,14 +2511,14 @@ static int load_state_from_tss32(struct x86_emulate_ctxt *ctxt, ctxt->eflags = tss->eflags | 2; /* General purpose registers */ - *reg_write(ctxt, VCPU_REGS_RAX) = tss->eax; - *reg_write(ctxt, VCPU_REGS_RCX) = tss->ecx; - *reg_write(ctxt, VCPU_REGS_RDX) = tss->edx; - *reg_write(ctxt, VCPU_REGS_RBX) = tss->ebx; - *reg_write(ctxt, VCPU_REGS_RSP) = tss->esp; - *reg_write(ctxt, VCPU_REGS_RBP) = tss->ebp; - *reg_write(ctxt, VCPU_REGS_RSI) = tss->esi; - *reg_write(ctxt, VCPU_REGS_RDI) = tss->edi; + ctxt->regs[VCPU_REGS_RAX] = tss->eax; + ctxt->regs[VCPU_REGS_RCX] = tss->ecx; + ctxt->regs[VCPU_REGS_RDX] = tss->edx; + ctxt->regs[VCPU_REGS_RBX] = tss->ebx; + ctxt->regs[VCPU_REGS_RSP] = tss->esp; + ctxt->regs[VCPU_REGS_RBP] = tss->ebp; + ctxt->regs[VCPU_REGS_RSI] = tss->esi; + ctxt->regs[VCPU_REGS_RDI] = tss->edi; /* * SDM says that segment selectors are loaded before segment @@ -2640,7 +2583,7 @@ static int task_switch_32(struct x86_emulate_ctxt *ctxt, u16 tss_selector, u16 old_tss_sel, ulong old_tss_base, struct desc_struct *new_desc) { - const struct x86_emulate_ops *ops = ctxt->ops; + struct x86_emulate_ops *ops = ctxt->ops; struct tss_segment_32 tss_seg; int ret; u32 new_tss_base = get_desc_base(new_desc); @@ -2684,7 +2627,7 @@ static int emulator_do_task_switch(struct x86_emulate_ctxt *ctxt, u16 tss_selector, int idt_index, int reason, bool has_error_code, u32 error_code) { - const struct x86_emulate_ops *ops = ctxt->ops; + struct x86_emulate_ops *ops = ctxt->ops; struct desc_struct curr_tss_desc, next_tss_desc; int ret; u16 old_tss_sel = get_segment_selector(ctxt, VCPU_SREG_TR); @@ -2709,7 +2652,7 @@ static int emulator_do_task_switch(struct x86_emulate_ctxt *ctxt, * * 1. jmp/call/int to task gate: Check against DPL of the task gate * 2. Exception/IRQ/iret: No check is performed - * 3. jmp/call to TSS: Check against DPL of the TSS + * 3. jmp/call to TSS: Check agains DPL of the TSS */ if (reason == TASK_SWITCH_GATE) { if (idt_index != -1) { @@ -2750,7 +2693,7 @@ static int emulator_do_task_switch(struct x86_emulate_ctxt *ctxt, ctxt->eflags = ctxt->eflags & ~X86_EFLAGS_NT; /* set back link to prev task only if NT bit is set in eflags - note that old_tss_sel is not used after this point */ + note that old_tss_sel is not used afetr this point */ if (reason != TASK_SWITCH_CALL && reason != TASK_SWITCH_GATE) old_tss_sel = 0xffff; @@ -2790,28 +2733,26 @@ int emulator_task_switch(struct x86_emulate_ctxt *ctxt, { int rc; - invalidate_registers(ctxt); ctxt->_eip = ctxt->eip; ctxt->dst.type = OP_NONE; rc = emulator_do_task_switch(ctxt, tss_selector, idt_index, reason, has_error_code, error_code); - if (rc == X86EMUL_CONTINUE) { + if (rc == X86EMUL_CONTINUE) ctxt->eip = ctxt->_eip; - writeback_registers(ctxt); - } return (rc == X86EMUL_UNHANDLEABLE) ? EMULATION_FAILED : EMULATION_OK; } -static void string_addr_inc(struct x86_emulate_ctxt *ctxt, int reg, - struct operand *op) +static void string_addr_inc(struct x86_emulate_ctxt *ctxt, unsigned seg, + int reg, struct operand *op) { - int df = (ctxt->eflags & EFLG_DF) ? -op->count : op->count; + int df = (ctxt->eflags & EFLG_DF) ? -1 : 1; - register_address_increment(ctxt, reg_rmw(ctxt, reg), df * op->bytes); - op->addr.mem.ea = register_address(ctxt, reg_read(ctxt, reg)); + register_address_increment(ctxt, &ctxt->regs[reg], df * op->bytes); + op->addr.mem.ea = register_address(ctxt, ctxt->regs[reg]); + op->addr.mem.seg = seg; } static int em_das(struct x86_emulate_ctxt *ctxt) @@ -2986,7 +2927,7 @@ static int em_cwd(struct x86_emulate_ctxt *ctxt) { ctxt->dst.type = OP_REG; ctxt->dst.bytes = ctxt->src.bytes; - ctxt->dst.addr.reg = reg_rmw(ctxt, VCPU_REGS_RDX); + ctxt->dst.addr.reg = &ctxt->regs[VCPU_REGS_RDX]; ctxt->dst.val = ~((ctxt->src.val >> (ctxt->src.bytes * 8 - 1)) - 1); return X86EMUL_CONTINUE; @@ -2997,8 +2938,8 @@ static int em_rdtsc(struct x86_emulate_ctxt *ctxt) u64 tsc = 0; ctxt->ops->get_msr(ctxt, MSR_IA32_TSC, &tsc); - *reg_write(ctxt, VCPU_REGS_RAX) = (u32)tsc; - *reg_write(ctxt, VCPU_REGS_RDX) = tsc >> 32; + ctxt->regs[VCPU_REGS_RAX] = (u32)tsc; + ctxt->regs[VCPU_REGS_RDX] = tsc >> 32; return X86EMUL_CONTINUE; } @@ -3006,10 +2947,10 @@ static int em_rdpmc(struct x86_emulate_ctxt *ctxt) { u64 pmc; - if (ctxt->ops->read_pmc(ctxt, reg_read(ctxt, VCPU_REGS_RCX), &pmc)) + if (ctxt->ops->read_pmc(ctxt, ctxt->regs[VCPU_REGS_RCX], &pmc)) return emulate_gp(ctxt, 0); - *reg_write(ctxt, VCPU_REGS_RAX) = (u32)pmc; - *reg_write(ctxt, VCPU_REGS_RDX) = pmc >> 32; + ctxt->regs[VCPU_REGS_RAX] = (u32)pmc; + ctxt->regs[VCPU_REGS_RDX] = pmc >> 32; return X86EMUL_CONTINUE; } @@ -3051,9 +2992,9 @@ static int em_wrmsr(struct x86_emulate_ctxt *ctxt) { u64 msr_data; - msr_data = (u32)reg_read(ctxt, VCPU_REGS_RAX) - | ((u64)reg_read(ctxt, VCPU_REGS_RDX) << 32); - if (ctxt->ops->set_msr(ctxt, reg_read(ctxt, VCPU_REGS_RCX), msr_data)) + msr_data = (u32)ctxt->regs[VCPU_REGS_RAX] + | ((u64)ctxt->regs[VCPU_REGS_RDX] << 32); + if (ctxt->ops->set_msr(ctxt, ctxt->regs[VCPU_REGS_RCX], msr_data)) return emulate_gp(ctxt, 0); return X86EMUL_CONTINUE; @@ -3063,11 +3004,11 @@ static int em_rdmsr(struct x86_emulate_ctxt *ctxt) { u64 msr_data; - if (ctxt->ops->get_msr(ctxt, reg_read(ctxt, VCPU_REGS_RCX), &msr_data)) + if (ctxt->ops->get_msr(ctxt, ctxt->regs[VCPU_REGS_RCX], &msr_data)) return emulate_gp(ctxt, 0); - *reg_write(ctxt, VCPU_REGS_RAX) = (u32)msr_data; - *reg_write(ctxt, VCPU_REGS_RDX) = msr_data >> 32; + ctxt->regs[VCPU_REGS_RAX] = (u32)msr_data; + ctxt->regs[VCPU_REGS_RDX] = msr_data >> 32; return X86EMUL_CONTINUE; } @@ -3247,8 +3188,8 @@ static int em_lmsw(struct x86_emulate_ctxt *ctxt) static int em_loop(struct x86_emulate_ctxt *ctxt) { - register_address_increment(ctxt, reg_rmw(ctxt, VCPU_REGS_RCX), -1); - if ((address_mask(ctxt, reg_read(ctxt, VCPU_REGS_RCX)) != 0) && + register_address_increment(ctxt, &ctxt->regs[VCPU_REGS_RCX], -1); + if ((address_mask(ctxt, ctxt->regs[VCPU_REGS_RCX]) != 0) && (ctxt->b == 0xe2 || test_cc(ctxt->b ^ 0x5, ctxt->eflags))) jmp_rel(ctxt, ctxt->src.val); @@ -3257,7 +3198,7 @@ static int em_loop(struct x86_emulate_ctxt *ctxt) static int em_jcxz(struct x86_emulate_ctxt *ctxt) { - if (address_mask(ctxt, reg_read(ctxt, VCPU_REGS_RCX)) == 0) + if (address_mask(ctxt, ctxt->regs[VCPU_REGS_RCX]) == 0) jmp_rel(ctxt, ctxt->src.val); return X86EMUL_CONTINUE; @@ -3345,20 +3286,20 @@ static int em_cpuid(struct x86_emulate_ctxt *ctxt) { u32 eax, ebx, ecx, edx; - eax = reg_read(ctxt, VCPU_REGS_RAX); - ecx = reg_read(ctxt, VCPU_REGS_RCX); + eax = ctxt->regs[VCPU_REGS_RAX]; + ecx = ctxt->regs[VCPU_REGS_RCX]; ctxt->ops->get_cpuid(ctxt, &eax, &ebx, &ecx, &edx); - *reg_write(ctxt, VCPU_REGS_RAX) = eax; - *reg_write(ctxt, VCPU_REGS_RBX) = ebx; - *reg_write(ctxt, VCPU_REGS_RCX) = ecx; - *reg_write(ctxt, VCPU_REGS_RDX) = edx; + ctxt->regs[VCPU_REGS_RAX] = eax; + ctxt->regs[VCPU_REGS_RBX] = ebx; + ctxt->regs[VCPU_REGS_RCX] = ecx; + ctxt->regs[VCPU_REGS_RDX] = edx; return X86EMUL_CONTINUE; } static int em_lahf(struct x86_emulate_ctxt *ctxt) { - *reg_rmw(ctxt, VCPU_REGS_RAX) &= ~0xff00UL; - *reg_rmw(ctxt, VCPU_REGS_RAX) |= (ctxt->eflags & 0xff) << 8; + ctxt->regs[VCPU_REGS_RAX] &= ~0xff00UL; + ctxt->regs[VCPU_REGS_RAX] |= (ctxt->eflags & 0xff) << 8; return X86EMUL_CONTINUE; } @@ -3515,7 +3456,7 @@ static int check_svme(struct x86_emulate_ctxt *ctxt) static int check_svme_pa(struct x86_emulate_ctxt *ctxt) { - u64 rax = reg_read(ctxt, VCPU_REGS_RAX); + u64 rax = ctxt->regs[VCPU_REGS_RAX]; /* Valid physical address? */ if (rax & 0xffff000000000000ULL) @@ -3537,7 +3478,7 @@ static int check_rdtsc(struct x86_emulate_ctxt *ctxt) static int check_rdpmc(struct x86_emulate_ctxt *ctxt) { u64 cr4 = ctxt->ops->get_cr(ctxt, 4); - u64 rcx = reg_read(ctxt, VCPU_REGS_RCX); + u64 rcx = ctxt->regs[VCPU_REGS_RCX]; if ((!(cr4 & X86_CR4_PCE) && ctxt->ops->cpl(ctxt)) || (rcx > 3)) @@ -3590,13 +3531,13 @@ static int check_perm_out(struct x86_emulate_ctxt *ctxt) I2bv(((_f) | DstReg | SrcMem | ModRM) & ~Lock, _e), \ I2bv(((_f) & ~Lock) | DstAcc | SrcImm, _e) -static const struct opcode group7_rm1[] = { +static struct opcode group7_rm1[] = { DI(SrcNone | Priv, monitor), DI(SrcNone | Priv, mwait), N, N, N, N, N, N, }; -static const struct opcode group7_rm3[] = { +static struct opcode group7_rm3[] = { DIP(SrcNone | Prot | Priv, vmrun, check_svme_pa), II(SrcNone | Prot | VendorSpecific, em_vmmcall, vmmcall), DIP(SrcNone | Prot | Priv, vmload, check_svme_pa), @@ -3607,13 +3548,13 @@ static const struct opcode group7_rm3[] = { DIP(SrcNone | Prot | Priv, invlpga, check_svme), }; -static const struct opcode group7_rm7[] = { +static struct opcode group7_rm7[] = { N, DIP(SrcNone, rdtscp, check_rdtsc), N, N, N, N, N, N, }; -static const struct opcode group1[] = { +static struct opcode group1[] = { I(Lock, em_add), I(Lock | PageTable, em_or), I(Lock, em_adc), @@ -3624,11 +3565,11 @@ static const struct opcode group1[] = { I(0, em_cmp), }; -static const struct opcode group1A[] = { +static struct opcode group1A[] = { I(DstMem | SrcNone | Mov | Stack, em_pop), N, N, N, N, N, N, N, }; -static const struct opcode group3[] = { +static struct opcode group3[] = { I(DstMem | SrcImm, em_test), I(DstMem | SrcImm, em_test), I(DstMem | SrcNone | Lock, em_not), @@ -3639,13 +3580,13 @@ static const struct opcode group3[] = { I(SrcMem, em_idiv_ex), }; -static const struct opcode group4[] = { +static struct opcode group4[] = { I(ByteOp | DstMem | SrcNone | Lock, em_grp45), I(ByteOp | DstMem | SrcNone | Lock, em_grp45), N, N, N, N, N, N, }; -static const struct opcode group5[] = { +static struct opcode group5[] = { I(DstMem | SrcNone | Lock, em_grp45), I(DstMem | SrcNone | Lock, em_grp45), I(SrcMem | Stack, em_grp45), @@ -3655,7 +3596,7 @@ static const struct opcode group5[] = { I(SrcMem | Stack, em_grp45), N, }; -static const struct opcode group6[] = { +static struct opcode group6[] = { DI(Prot, sldt), DI(Prot, str), II(Prot | Priv | SrcMem16, em_lldt, lldt), @@ -3663,7 +3604,7 @@ static const struct opcode group6[] = { N, N, N, N, }; -static const struct group_dual group7 = { { +static struct group_dual group7 = { { II(Mov | DstMem | Priv, em_sgdt, sgdt), II(Mov | DstMem | Priv, em_sidt, sidt), II(SrcMem | Priv, em_lgdt, lgdt), @@ -3680,7 +3621,7 @@ static const struct group_dual group7 = { { EXT(0, group7_rm7), } }; -static const struct opcode group8[] = { +static struct opcode group8[] = { N, N, N, N, I(DstMem | SrcImmByte, em_bt), I(DstMem | SrcImmByte | Lock | PageTable, em_bts), @@ -3688,26 +3629,26 @@ static const struct opcode group8[] = { I(DstMem | SrcImmByte | Lock | PageTable, em_btc), }; -static const struct group_dual group9 = { { +static struct group_dual group9 = { { N, I(DstMem64 | Lock | PageTable, em_cmpxchg8b), N, N, N, N, N, N, }, { N, N, N, N, N, N, N, N, } }; -static const struct opcode group11[] = { +static struct opcode group11[] = { I(DstMem | SrcImm | Mov | PageTable, em_mov), X7(D(Undefined)), }; -static const struct gprefix pfx_0f_6f_0f_7f = { +static struct gprefix pfx_0f_6f_0f_7f = { I(Mmx, em_mov), I(Sse | Aligned, em_mov), N, I(Sse | Unaligned, em_mov), }; -static const struct gprefix pfx_vmovntpx = { +static struct gprefix pfx_vmovntpx = { I(0, em_mov), N, N, N, }; -static const struct opcode opcode_table[256] = { +static struct opcode opcode_table[256] = { /* 0x00 - 0x07 */ I6ALU(Lock, em_add), I(ImplicitOps | Stack | No64 | Src2ES, em_push_sreg), @@ -3748,7 +3689,7 @@ static const struct opcode opcode_table[256] = { I(DstReg | SrcMem | ModRM | Src2Imm, em_imul_3op), I(SrcImmByte | Mov | Stack, em_push), I(DstReg | SrcMem | ModRM | Src2ImmByte, em_imul_3op), - I2bvIP(DstDI | SrcDX | Mov | String | Unaligned, em_in, ins, check_perm_in), /* insb, insw/insd */ + I2bvIP(DstDI | SrcDX | Mov | String, em_in, ins, check_perm_in), /* insb, insw/insd */ I2bvIP(SrcSI | DstDX | String, em_out, outs, check_perm_out), /* outsb, outsw/outsd */ /* 0x70 - 0x7F */ X16(D(SrcImmByte)), @@ -3824,7 +3765,7 @@ static const struct opcode opcode_table[256] = { D(ImplicitOps), D(ImplicitOps), G(0, group4), G(0, group5), }; -static const struct opcode twobyte_table[256] = { +static struct opcode twobyte_table[256] = { /* 0x00 - 0x0F */ G(0, group6), GD(0, &group7), N, N, N, I(ImplicitOps | VendorSpecific, em_syscall), @@ -3995,7 +3936,7 @@ static int decode_operand(struct x86_emulate_ctxt *ctxt, struct operand *op, case OpAcc: op->type = OP_REG; op->bytes = (ctxt->d & ByteOp) ? 1 : ctxt->op_bytes; - op->addr.reg = reg_rmw(ctxt, VCPU_REGS_RAX); + op->addr.reg = &ctxt->regs[VCPU_REGS_RAX]; fetch_register_operand(op); op->orig_val = op->val; break; @@ -4003,20 +3944,19 @@ static int decode_operand(struct x86_emulate_ctxt *ctxt, struct operand *op, op->type = OP_MEM; op->bytes = (ctxt->d & ByteOp) ? 1 : ctxt->op_bytes; op->addr.mem.ea = - register_address(ctxt, reg_read(ctxt, VCPU_REGS_RDI)); + register_address(ctxt, ctxt->regs[VCPU_REGS_RDI]); op->addr.mem.seg = VCPU_SREG_ES; op->val = 0; - op->count = 1; break; case OpDX: op->type = OP_REG; op->bytes = 2; - op->addr.reg = reg_rmw(ctxt, VCPU_REGS_RDX); + op->addr.reg = &ctxt->regs[VCPU_REGS_RDX]; fetch_register_operand(op); break; case OpCL: op->bytes = 1; - op->val = reg_read(ctxt, VCPU_REGS_RCX) & 0xff; + op->val = ctxt->regs[VCPU_REGS_RCX] & 0xff; break; case OpImmByte: rc = decode_imm(ctxt, op, 1, true); @@ -4047,10 +3987,9 @@ static int decode_operand(struct x86_emulate_ctxt *ctxt, struct operand *op, op->type = OP_MEM; op->bytes = (ctxt->d & ByteOp) ? 1 : ctxt->op_bytes; op->addr.mem.ea = - register_address(ctxt, reg_read(ctxt, VCPU_REGS_RSI)); + register_address(ctxt, ctxt->regs[VCPU_REGS_RSI]); op->addr.mem.seg = seg_override(ctxt); op->val = 0; - op->count = 1; break; case OpImmFAddr: op->type = OP_IMM; @@ -4354,10 +4293,9 @@ static void fetch_possible_mmx_operand(struct x86_emulate_ctxt *ctxt, read_mmx_reg(ctxt, &op->mm_val, op->addr.mm); } - int x86_emulate_insn(struct x86_emulate_ctxt *ctxt) { - const struct x86_emulate_ops *ops = ctxt->ops; + struct x86_emulate_ops *ops = ctxt->ops; int rc = X86EMUL_CONTINUE; int saved_dst_type = ctxt->dst.type; @@ -4418,7 +4356,7 @@ int x86_emulate_insn(struct x86_emulate_ctxt *ctxt) } /* Instruction can only be executed in protected mode */ - if ((ctxt->d & Prot) && ctxt->mode < X86EMUL_MODE_PROT16) { + if ((ctxt->d & Prot) && !(ctxt->mode & X86EMUL_MODE_PROT)) { rc = emulate_ud(ctxt); goto done; } @@ -4439,7 +4377,7 @@ int x86_emulate_insn(struct x86_emulate_ctxt *ctxt) if (ctxt->rep_prefix && (ctxt->d & String)) { /* All REP prefixes have the same first termination condition */ - if (address_mask(ctxt, reg_read(ctxt, VCPU_REGS_RCX)) == 0) { + if (address_mask(ctxt, ctxt->regs[VCPU_REGS_RCX]) == 0) { ctxt->eip = ctxt->_eip; goto done; } @@ -4512,7 +4450,7 @@ int x86_emulate_insn(struct x86_emulate_ctxt *ctxt) ctxt->dst.val = ctxt->src.addr.mem.ea; break; case 0x90 ... 0x97: /* nop / xchg reg, rax */ - if (ctxt->dst.addr.reg == reg_rmw(ctxt, VCPU_REGS_RAX)) + if (ctxt->dst.addr.reg == &ctxt->regs[VCPU_REGS_RAX]) break; rc = em_xchg(ctxt); break; @@ -4540,7 +4478,7 @@ int x86_emulate_insn(struct x86_emulate_ctxt *ctxt) rc = em_grp2(ctxt); break; case 0xd2 ... 0xd3: /* Grp2 */ - ctxt->src.val = reg_read(ctxt, VCPU_REGS_RCX); + ctxt->src.val = ctxt->regs[VCPU_REGS_RCX]; rc = em_grp2(ctxt); break; case 0xe9: /* jmp rel */ @@ -4586,27 +4524,23 @@ int x86_emulate_insn(struct x86_emulate_ctxt *ctxt) ctxt->dst.type = saved_dst_type; if ((ctxt->d & SrcMask) == SrcSI) - string_addr_inc(ctxt, VCPU_REGS_RSI, &ctxt->src); + string_addr_inc(ctxt, seg_override(ctxt), + VCPU_REGS_RSI, &ctxt->src); if ((ctxt->d & DstMask) == DstDI) - string_addr_inc(ctxt, VCPU_REGS_RDI, &ctxt->dst); + string_addr_inc(ctxt, VCPU_SREG_ES, VCPU_REGS_RDI, + &ctxt->dst); if (ctxt->rep_prefix && (ctxt->d & String)) { - unsigned int count; struct read_cache *r = &ctxt->io_read; - if ((ctxt->d & SrcMask) == SrcSI) - count = ctxt->src.count; - else - count = ctxt->dst.count; - register_address_increment(ctxt, reg_rmw(ctxt, VCPU_REGS_RCX), - -count); + register_address_increment(ctxt, &ctxt->regs[VCPU_REGS_RCX], -1); if (!string_insn_completed(ctxt)) { /* * Re-enter guest when pio read ahead buffer is empty * or, if it is not used, after each 1024 iteration. */ - if ((r->end != 0 || reg_read(ctxt, VCPU_REGS_RCX) & 0x3ff) && + if ((r->end != 0 || ctxt->regs[VCPU_REGS_RCX] & 0x3ff) && (r->end == 0 || r->end != r->pos)) { /* * Reset read cache. Usually happens before @@ -4614,7 +4548,6 @@ int x86_emulate_insn(struct x86_emulate_ctxt *ctxt) * we have to do it here. */ ctxt->mem_read.end = 0; - writeback_registers(ctxt); return EMULATION_RESTART; } goto done; /* skip rip writeback */ @@ -4629,9 +4562,6 @@ int x86_emulate_insn(struct x86_emulate_ctxt *ctxt) if (rc == X86EMUL_INTERCEPTED) return EMULATION_INTERCEPTED; - if (rc == X86EMUL_CONTINUE) - writeback_registers(ctxt); - return (rc == X86EMUL_UNHANDLEABLE) ? EMULATION_FAILED : EMULATION_OK; twobyte_insn: @@ -4704,13 +4634,3 @@ int x86_emulate_insn(struct x86_emulate_ctxt *ctxt) cannot_emulate: return EMULATION_FAILED; } - -void emulator_invalidate_register_cache(struct x86_emulate_ctxt *ctxt) -{ - invalidate_registers(ctxt); -} - -void emulator_writeback_register_cache(struct x86_emulate_ctxt *ctxt) -{ - writeback_registers(ctxt); -} diff --git a/trunk/arch/x86/kvm/i8254.c b/trunk/arch/x86/kvm/i8254.c index 11300d2fa714..adba28f88d1a 100644 --- a/trunk/arch/x86/kvm/i8254.c +++ b/trunk/arch/x86/kvm/i8254.c @@ -108,7 +108,7 @@ static s64 __kpit_elapsed(struct kvm *kvm) ktime_t remaining; struct kvm_kpit_state *ps = &kvm->arch.vpit->pit_state; - if (!ps->period) + if (!ps->pit_timer.period) return 0; /* @@ -120,9 +120,9 @@ static s64 __kpit_elapsed(struct kvm *kvm) * itself with the initial count and continues counting * from there. */ - remaining = hrtimer_get_remaining(&ps->timer); - elapsed = ps->period - ktime_to_ns(remaining); - elapsed = mod_64(elapsed, ps->period); + remaining = hrtimer_get_remaining(&ps->pit_timer.timer); + elapsed = ps->pit_timer.period - ktime_to_ns(remaining); + elapsed = mod_64(elapsed, ps->pit_timer.period); return elapsed; } @@ -238,12 +238,12 @@ static void kvm_pit_ack_irq(struct kvm_irq_ack_notifier *kian) int value; spin_lock(&ps->inject_lock); - value = atomic_dec_return(&ps->pending); + value = atomic_dec_return(&ps->pit_timer.pending); if (value < 0) /* spurious acks can be generated if, for example, the * PIC is being reset. Handle it gracefully here */ - atomic_inc(&ps->pending); + atomic_inc(&ps->pit_timer.pending); else if (value > 0) /* in this case, we had multiple outstanding pit interrupts * that we needed to inject. Reinject @@ -261,17 +261,28 @@ void __kvm_migrate_pit_timer(struct kvm_vcpu *vcpu) if (!kvm_vcpu_is_bsp(vcpu) || !pit) return; - timer = &pit->pit_state.timer; + timer = &pit->pit_state.pit_timer.timer; if (hrtimer_cancel(timer)) hrtimer_start_expires(timer, HRTIMER_MODE_ABS); } static void destroy_pit_timer(struct kvm_pit *pit) { - hrtimer_cancel(&pit->pit_state.timer); + hrtimer_cancel(&pit->pit_state.pit_timer.timer); flush_kthread_work(&pit->expired); } +static bool kpit_is_periodic(struct kvm_timer *ktimer) +{ + struct kvm_kpit_state *ps = container_of(ktimer, struct kvm_kpit_state, + pit_timer); + return ps->is_periodic; +} + +static struct kvm_timer_ops kpit_ops = { + .is_periodic = kpit_is_periodic, +}; + static void pit_do_work(struct kthread_work *work) { struct kvm_pit *pit = container_of(work, struct kvm_pit, expired); @@ -311,16 +322,16 @@ static void pit_do_work(struct kthread_work *work) static enum hrtimer_restart pit_timer_fn(struct hrtimer *data) { - struct kvm_kpit_state *ps = container_of(data, struct kvm_kpit_state, timer); - struct kvm_pit *pt = ps->kvm->arch.vpit; + struct kvm_timer *ktimer = container_of(data, struct kvm_timer, timer); + struct kvm_pit *pt = ktimer->kvm->arch.vpit; - if (ps->reinject || !atomic_read(&ps->pending)) { - atomic_inc(&ps->pending); + if (ktimer->reinject || !atomic_read(&ktimer->pending)) { + atomic_inc(&ktimer->pending); queue_kthread_work(&pt->worker, &pt->expired); } - if (ps->is_periodic) { - hrtimer_add_expires_ns(&ps->timer, ps->period); + if (ktimer->t_ops->is_periodic(ktimer)) { + hrtimer_add_expires_ns(&ktimer->timer, ktimer->period); return HRTIMER_RESTART; } else return HRTIMER_NORESTART; @@ -329,6 +340,7 @@ static enum hrtimer_restart pit_timer_fn(struct hrtimer *data) static void create_pit_timer(struct kvm *kvm, u32 val, int is_period) { struct kvm_kpit_state *ps = &kvm->arch.vpit->pit_state; + struct kvm_timer *pt = &ps->pit_timer; s64 interval; if (!irqchip_in_kernel(kvm) || ps->flags & KVM_PIT_FLAGS_HPET_LEGACY) @@ -339,18 +351,19 @@ static void create_pit_timer(struct kvm *kvm, u32 val, int is_period) pr_debug("create pit timer, interval is %llu nsec\n", interval); /* TODO The new value only affected after the retriggered */ - hrtimer_cancel(&ps->timer); + hrtimer_cancel(&pt->timer); flush_kthread_work(&ps->pit->expired); - ps->period = interval; + pt->period = interval; ps->is_periodic = is_period; - ps->timer.function = pit_timer_fn; - ps->kvm = ps->pit->kvm; + pt->timer.function = pit_timer_fn; + pt->t_ops = &kpit_ops; + pt->kvm = ps->pit->kvm; - atomic_set(&ps->pending, 0); + atomic_set(&pt->pending, 0); ps->irq_ack = 1; - hrtimer_start(&ps->timer, ktime_add_ns(ktime_get(), interval), + hrtimer_start(&pt->timer, ktime_add_ns(ktime_get(), interval), HRTIMER_MODE_ABS); } @@ -626,7 +639,7 @@ void kvm_pit_reset(struct kvm_pit *pit) } mutex_unlock(&pit->pit_state.lock); - atomic_set(&pit->pit_state.pending, 0); + atomic_set(&pit->pit_state.pit_timer.pending, 0); pit->pit_state.irq_ack = 1; } @@ -635,7 +648,7 @@ static void pit_mask_notifer(struct kvm_irq_mask_notifier *kimn, bool mask) struct kvm_pit *pit = container_of(kimn, struct kvm_pit, mask_notifier); if (!mask) { - atomic_set(&pit->pit_state.pending, 0); + atomic_set(&pit->pit_state.pit_timer.pending, 0); pit->pit_state.irq_ack = 1; } } @@ -693,11 +706,12 @@ struct kvm_pit *kvm_create_pit(struct kvm *kvm, u32 flags) pit_state = &pit->pit_state; pit_state->pit = pit; - hrtimer_init(&pit_state->timer, CLOCK_MONOTONIC, HRTIMER_MODE_ABS); + hrtimer_init(&pit_state->pit_timer.timer, + CLOCK_MONOTONIC, HRTIMER_MODE_ABS); pit_state->irq_ack_notifier.gsi = 0; pit_state->irq_ack_notifier.irq_acked = kvm_pit_ack_irq; kvm_register_irq_ack_notifier(kvm, &pit_state->irq_ack_notifier); - pit_state->reinject = true; + pit_state->pit_timer.reinject = true; mutex_unlock(&pit->pit_state.lock); kvm_pit_reset(pit); @@ -747,7 +761,7 @@ void kvm_free_pit(struct kvm *kvm) kvm_unregister_irq_ack_notifier(kvm, &kvm->arch.vpit->pit_state.irq_ack_notifier); mutex_lock(&kvm->arch.vpit->pit_state.lock); - timer = &kvm->arch.vpit->pit_state.timer; + timer = &kvm->arch.vpit->pit_state.pit_timer.timer; hrtimer_cancel(timer); flush_kthread_work(&kvm->arch.vpit->expired); kthread_stop(kvm->arch.vpit->worker_task); diff --git a/trunk/arch/x86/kvm/i8254.h b/trunk/arch/x86/kvm/i8254.h index dd1b16b611b0..fdf40425ea1d 100644 --- a/trunk/arch/x86/kvm/i8254.h +++ b/trunk/arch/x86/kvm/i8254.h @@ -24,12 +24,8 @@ struct kvm_kpit_channel_state { struct kvm_kpit_state { struct kvm_kpit_channel_state channels[3]; u32 flags; + struct kvm_timer pit_timer; bool is_periodic; - s64 period; /* unit: ns */ - struct hrtimer timer; - atomic_t pending; /* accumulated triggered timers */ - bool reinject; - struct kvm *kvm; u32 speaker_data_on; struct mutex lock; struct kvm_pit *pit; diff --git a/trunk/arch/x86/kvm/i8259.c b/trunk/arch/x86/kvm/i8259.c index 848206df0967..9fc9aa7ac703 100644 --- a/trunk/arch/x86/kvm/i8259.c +++ b/trunk/arch/x86/kvm/i8259.c @@ -190,17 +190,17 @@ void kvm_pic_update_irq(struct kvm_pic *s) int kvm_pic_set_irq(struct kvm_pic *s, int irq, int irq_source_id, int level) { - int ret, irq_level; - - BUG_ON(irq < 0 || irq >= PIC_NUM_PINS); + int ret = -1; pic_lock(s); - irq_level = __kvm_irq_line_state(&s->irq_states[irq], - irq_source_id, level); - ret = pic_set_irq1(&s->pics[irq >> 3], irq & 7, irq_level); - pic_update_irq(s); - trace_kvm_pic_set_irq(irq >> 3, irq & 7, s->pics[irq >> 3].elcr, - s->pics[irq >> 3].imr, ret == 0); + if (irq >= 0 && irq < PIC_NUM_PINS) { + int irq_level = __kvm_irq_line_state(&s->irq_states[irq], + irq_source_id, level); + ret = pic_set_irq1(&s->pics[irq >> 3], irq & 7, irq_level); + pic_update_irq(s); + trace_kvm_pic_set_irq(irq >> 3, irq & 7, s->pics[irq >> 3].elcr, + s->pics[irq >> 3].imr, ret == 0); + } pic_unlock(s); return ret; @@ -275,20 +275,23 @@ void kvm_pic_reset(struct kvm_kpic_state *s) { int irq, i; struct kvm_vcpu *vcpu; - u8 edge_irr = s->irr & ~s->elcr; + u8 irr = s->irr, isr = s->imr; bool found = false; s->last_irr = 0; - s->irr &= s->elcr; + s->irr = 0; s->imr = 0; + s->isr = 0; s->priority_add = 0; - s->special_mask = 0; + s->irq_base = 0; s->read_reg_select = 0; - if (!s->init4) { - s->special_fully_nested_mode = 0; - s->auto_eoi = 0; - } - s->init_state = 1; + s->poll = 0; + s->special_mask = 0; + s->init_state = 0; + s->auto_eoi = 0; + s->rotate_on_auto_eoi = 0; + s->special_fully_nested_mode = 0; + s->init4 = 0; kvm_for_each_vcpu(i, vcpu, s->pics_state->kvm) if (kvm_apic_accept_pic_intr(vcpu)) { @@ -301,7 +304,7 @@ void kvm_pic_reset(struct kvm_kpic_state *s) return; for (irq = 0; irq < PIC_NUM_PINS/2; irq++) - if (edge_irr & (1 << irq)) + if (irr & (1 << irq) || isr & (1 << irq)) pic_clear_isr(s, irq); } @@ -313,13 +316,40 @@ static void pic_ioport_write(void *opaque, u32 addr, u32 val) addr &= 1; if (addr == 0) { if (val & 0x10) { + u8 edge_irr = s->irr & ~s->elcr; + int i; + bool found = false; + struct kvm_vcpu *vcpu; + s->init4 = val & 1; + s->last_irr = 0; + s->irr &= s->elcr; + s->imr = 0; + s->priority_add = 0; + s->special_mask = 0; + s->read_reg_select = 0; + if (!s->init4) { + s->special_fully_nested_mode = 0; + s->auto_eoi = 0; + } + s->init_state = 1; if (val & 0x02) pr_pic_unimpl("single mode not supported"); if (val & 0x08) pr_pic_unimpl( - "level sensitive irq not supported"); - kvm_pic_reset(s); + "level sensitive irq not supported"); + + kvm_for_each_vcpu(i, vcpu, s->pics_state->kvm) + if (kvm_apic_accept_pic_intr(vcpu)) { + found = true; + break; + } + + + if (found) + for (irq = 0; irq < PIC_NUM_PINS/2; irq++) + if (edge_irr & (1 << irq)) + pic_clear_isr(s, irq); } else if (val & 0x08) { if (val & 0x04) s->poll = 1; diff --git a/trunk/arch/x86/kvm/irq.h b/trunk/arch/x86/kvm/irq.h index 2d03568e9498..2086f2bfba33 100644 --- a/trunk/arch/x86/kvm/irq.h +++ b/trunk/arch/x86/kvm/irq.h @@ -70,7 +70,7 @@ struct kvm_pic { struct kvm_io_device dev_slave; struct kvm_io_device dev_eclr; void (*ack_notifier)(void *opaque, int irq); - unsigned long irq_states[PIC_NUM_PINS]; + unsigned long irq_states[16]; }; struct kvm_pic *kvm_create_pic(struct kvm *kvm); diff --git a/trunk/arch/x86/kvm/kvm_timer.h b/trunk/arch/x86/kvm/kvm_timer.h new file mode 100644 index 000000000000..497dbaa366d4 --- /dev/null +++ b/trunk/arch/x86/kvm/kvm_timer.h @@ -0,0 +1,18 @@ + +struct kvm_timer { + struct hrtimer timer; + s64 period; /* unit: ns */ + u32 timer_mode_mask; + u64 tscdeadline; + atomic_t pending; /* accumulated triggered timers */ + bool reinject; + struct kvm_timer_ops *t_ops; + struct kvm *kvm; + struct kvm_vcpu *vcpu; +}; + +struct kvm_timer_ops { + bool (*is_periodic)(struct kvm_timer *); +}; + +enum hrtimer_restart kvm_timer_fn(struct hrtimer *data); diff --git a/trunk/arch/x86/kvm/lapic.c b/trunk/arch/x86/kvm/lapic.c index c6e6b721b6ee..ce878788a39f 100644 --- a/trunk/arch/x86/kvm/lapic.c +++ b/trunk/arch/x86/kvm/lapic.c @@ -34,7 +34,6 @@ #include #include #include -#include #include "kvm_cache_regs.h" #include "irq.h" #include "trace.h" @@ -66,7 +65,6 @@ #define APIC_DEST_NOSHORT 0x0 #define APIC_DEST_MASK 0x800 #define MAX_APIC_VECTOR 256 -#define APIC_VECTORS_PER_REG 32 #define VEC_POS(v) ((v) & (32 - 1)) #define REG_POS(v) (((v) >> 5) << 4) @@ -74,6 +72,11 @@ static unsigned int min_timer_period_us = 500; module_param(min_timer_period_us, uint, S_IRUGO | S_IWUSR); +static inline u32 apic_get_reg(struct kvm_lapic *apic, int reg_off) +{ + return *((u32 *) (apic->regs + reg_off)); +} + static inline void apic_set_reg(struct kvm_lapic *apic, int reg_off, u32 val) { *((u32 *) (apic->regs + reg_off)) = val; @@ -114,23 +117,19 @@ static inline int __apic_test_and_clear_vector(int vec, void *bitmap) return __test_and_clear_bit(VEC_POS(vec), (bitmap) + REG_POS(vec)); } -struct static_key_deferred apic_hw_disabled __read_mostly; -struct static_key_deferred apic_sw_disabled __read_mostly; +static inline int apic_hw_enabled(struct kvm_lapic *apic) +{ + return (apic)->vcpu->arch.apic_base & MSR_IA32_APICBASE_ENABLE; +} -static inline void apic_set_spiv(struct kvm_lapic *apic, u32 val) +static inline int apic_sw_enabled(struct kvm_lapic *apic) { - if ((kvm_apic_get_reg(apic, APIC_SPIV) ^ val) & APIC_SPIV_APIC_ENABLED) { - if (val & APIC_SPIV_APIC_ENABLED) - static_key_slow_dec_deferred(&apic_sw_disabled); - else - static_key_slow_inc(&apic_sw_disabled.key); - } - apic_set_reg(apic, APIC_SPIV, val); + return apic_get_reg(apic, APIC_SPIV) & APIC_SPIV_APIC_ENABLED; } static inline int apic_enabled(struct kvm_lapic *apic) { - return kvm_apic_sw_enabled(apic) && kvm_apic_hw_enabled(apic); + return apic_sw_enabled(apic) && apic_hw_enabled(apic); } #define LVT_MASK \ @@ -140,135 +139,36 @@ static inline int apic_enabled(struct kvm_lapic *apic) (LVT_MASK | APIC_MODE_MASK | APIC_INPUT_POLARITY | \ APIC_LVT_REMOTE_IRR | APIC_LVT_LEVEL_TRIGGER) -static inline int apic_x2apic_mode(struct kvm_lapic *apic) -{ - return apic->vcpu->arch.apic_base & X2APIC_ENABLE; -} - static inline int kvm_apic_id(struct kvm_lapic *apic) { - return (kvm_apic_get_reg(apic, APIC_ID) >> 24) & 0xff; -} - -static inline u16 apic_cluster_id(struct kvm_apic_map *map, u32 ldr) -{ - u16 cid; - ldr >>= 32 - map->ldr_bits; - cid = (ldr >> map->cid_shift) & map->cid_mask; - - BUG_ON(cid >= ARRAY_SIZE(map->logical_map)); - - return cid; -} - -static inline u16 apic_logical_id(struct kvm_apic_map *map, u32 ldr) -{ - ldr >>= (32 - map->ldr_bits); - return ldr & map->lid_mask; -} - -static void recalculate_apic_map(struct kvm *kvm) -{ - struct kvm_apic_map *new, *old = NULL; - struct kvm_vcpu *vcpu; - int i; - - new = kzalloc(sizeof(struct kvm_apic_map), GFP_KERNEL); - - mutex_lock(&kvm->arch.apic_map_lock); - - if (!new) - goto out; - - new->ldr_bits = 8; - /* flat mode is default */ - new->cid_shift = 8; - new->cid_mask = 0; - new->lid_mask = 0xff; - - kvm_for_each_vcpu(i, vcpu, kvm) { - struct kvm_lapic *apic = vcpu->arch.apic; - u16 cid, lid; - u32 ldr; - - if (!kvm_apic_present(vcpu)) - continue; - - /* - * All APICs have to be configured in the same mode by an OS. - * We take advatage of this while building logical id loockup - * table. After reset APICs are in xapic/flat mode, so if we - * find apic with different setting we assume this is the mode - * OS wants all apics to be in; build lookup table accordingly. - */ - if (apic_x2apic_mode(apic)) { - new->ldr_bits = 32; - new->cid_shift = 16; - new->cid_mask = new->lid_mask = 0xffff; - } else if (kvm_apic_sw_enabled(apic) && - !new->cid_mask /* flat mode */ && - kvm_apic_get_reg(apic, APIC_DFR) == APIC_DFR_CLUSTER) { - new->cid_shift = 4; - new->cid_mask = 0xf; - new->lid_mask = 0xf; - } - - new->phys_map[kvm_apic_id(apic)] = apic; - - ldr = kvm_apic_get_reg(apic, APIC_LDR); - cid = apic_cluster_id(new, ldr); - lid = apic_logical_id(new, ldr); - - if (lid) - new->logical_map[cid][ffs(lid) - 1] = apic; - } -out: - old = rcu_dereference_protected(kvm->arch.apic_map, - lockdep_is_held(&kvm->arch.apic_map_lock)); - rcu_assign_pointer(kvm->arch.apic_map, new); - mutex_unlock(&kvm->arch.apic_map_lock); - - if (old) - kfree_rcu(old, rcu); -} - -static inline void kvm_apic_set_id(struct kvm_lapic *apic, u8 id) -{ - apic_set_reg(apic, APIC_ID, id << 24); - recalculate_apic_map(apic->vcpu->kvm); -} - -static inline void kvm_apic_set_ldr(struct kvm_lapic *apic, u32 id) -{ - apic_set_reg(apic, APIC_LDR, id); - recalculate_apic_map(apic->vcpu->kvm); + return (apic_get_reg(apic, APIC_ID) >> 24) & 0xff; } static inline int apic_lvt_enabled(struct kvm_lapic *apic, int lvt_type) { - return !(kvm_apic_get_reg(apic, lvt_type) & APIC_LVT_MASKED); + return !(apic_get_reg(apic, lvt_type) & APIC_LVT_MASKED); } static inline int apic_lvt_vector(struct kvm_lapic *apic, int lvt_type) { - return kvm_apic_get_reg(apic, lvt_type) & APIC_VECTOR_MASK; + return apic_get_reg(apic, lvt_type) & APIC_VECTOR_MASK; } static inline int apic_lvtt_oneshot(struct kvm_lapic *apic) { - return ((kvm_apic_get_reg(apic, APIC_LVTT) & + return ((apic_get_reg(apic, APIC_LVTT) & apic->lapic_timer.timer_mode_mask) == APIC_LVT_TIMER_ONESHOT); } static inline int apic_lvtt_period(struct kvm_lapic *apic) { - return ((kvm_apic_get_reg(apic, APIC_LVTT) & + return ((apic_get_reg(apic, APIC_LVTT) & apic->lapic_timer.timer_mode_mask) == APIC_LVT_TIMER_PERIODIC); } static inline int apic_lvtt_tscdeadline(struct kvm_lapic *apic) { - return ((kvm_apic_get_reg(apic, APIC_LVTT) & + return ((apic_get_reg(apic, APIC_LVTT) & apic->lapic_timer.timer_mode_mask) == APIC_LVT_TIMER_TSCDEADLINE); } @@ -284,7 +184,7 @@ void kvm_apic_set_version(struct kvm_vcpu *vcpu) struct kvm_cpuid_entry2 *feat; u32 v = APIC_VERSION; - if (!kvm_vcpu_has_lapic(vcpu)) + if (!irqchip_in_kernel(vcpu->kvm)) return; feat = kvm_find_cpuid_entry(apic->vcpu, 0x1, 0); @@ -293,7 +193,12 @@ void kvm_apic_set_version(struct kvm_vcpu *vcpu) apic_set_reg(apic, APIC_LVR, v); } -static const unsigned int apic_lvt_mask[APIC_LVT_NUM] = { +static inline int apic_x2apic_mode(struct kvm_lapic *apic) +{ + return apic->vcpu->arch.apic_base & X2APIC_ENABLE; +} + +static unsigned int apic_lvt_mask[APIC_LVT_NUM] = { LVT_MASK , /* part LVTT mask, timer mode mask added at runtime */ LVT_MASK | APIC_MODE_MASK, /* LVTTHMR */ LVT_MASK | APIC_MODE_MASK, /* LVTPC */ @@ -303,30 +208,25 @@ static const unsigned int apic_lvt_mask[APIC_LVT_NUM] = { static int find_highest_vector(void *bitmap) { - int vec; - u32 *reg; + u32 *word = bitmap; + int word_offset = MAX_APIC_VECTOR >> 5; - for (vec = MAX_APIC_VECTOR - APIC_VECTORS_PER_REG; - vec >= 0; vec -= APIC_VECTORS_PER_REG) { - reg = bitmap + REG_POS(vec); - if (*reg) - return fls(*reg) - 1 + vec; - } + while ((word_offset != 0) && (word[(--word_offset) << 2] == 0)) + continue; - return -1; + if (likely(!word_offset && !word[0])) + return -1; + else + return fls(word[word_offset << 2]) - 1 + (word_offset << 5); } static u8 count_vectors(void *bitmap) { - int vec; - u32 *reg; + u32 *word = bitmap; + int word_offset; u8 count = 0; - - for (vec = 0; vec < MAX_APIC_VECTOR; vec += APIC_VECTORS_PER_REG) { - reg = bitmap + REG_POS(vec); - count += hweight32(*reg); - } - + for (word_offset = 0; word_offset < MAX_APIC_VECTOR >> 5; ++word_offset) + count += hweight32(word[word_offset << 2]); return count; } @@ -385,6 +285,7 @@ static inline void apic_clear_isr(int vec, struct kvm_lapic *apic) int kvm_lapic_find_highest_irr(struct kvm_vcpu *vcpu) { + struct kvm_lapic *apic = vcpu->arch.apic; int highest_irr; /* This may race with setting of irr in __apic_accept_irq() and @@ -392,9 +293,9 @@ int kvm_lapic_find_highest_irr(struct kvm_vcpu *vcpu) * will cause vmexit immediately and the value will be recalculated * on the next vmentry. */ - if (!kvm_vcpu_has_lapic(vcpu)) + if (!apic) return 0; - highest_irr = apic_find_highest_irr(vcpu->arch.apic); + highest_irr = apic_find_highest_irr(apic); return highest_irr; } @@ -477,8 +378,8 @@ static void apic_update_ppr(struct kvm_lapic *apic) u32 tpr, isrv, ppr, old_ppr; int isr; - old_ppr = kvm_apic_get_reg(apic, APIC_PROCPRI); - tpr = kvm_apic_get_reg(apic, APIC_TASKPRI); + old_ppr = apic_get_reg(apic, APIC_PROCPRI); + tpr = apic_get_reg(apic, APIC_TASKPRI); isr = apic_find_highest_isr(apic); isrv = (isr != -1) ? isr : 0; @@ -514,13 +415,13 @@ int kvm_apic_match_logical_addr(struct kvm_lapic *apic, u8 mda) u32 logical_id; if (apic_x2apic_mode(apic)) { - logical_id = kvm_apic_get_reg(apic, APIC_LDR); + logical_id = apic_get_reg(apic, APIC_LDR); return logical_id & mda; } - logical_id = GET_APIC_LOGICAL_ID(kvm_apic_get_reg(apic, APIC_LDR)); + logical_id = GET_APIC_LOGICAL_ID(apic_get_reg(apic, APIC_LDR)); - switch (kvm_apic_get_reg(apic, APIC_DFR)) { + switch (apic_get_reg(apic, APIC_DFR)) { case APIC_DFR_FLAT: if (logical_id & mda) result = 1; @@ -532,7 +433,7 @@ int kvm_apic_match_logical_addr(struct kvm_lapic *apic, u8 mda) break; default: apic_debug("Bad DFR vcpu %d: %08x\n", - apic->vcpu->vcpu_id, kvm_apic_get_reg(apic, APIC_DFR)); + apic->vcpu->vcpu_id, apic_get_reg(apic, APIC_DFR)); break; } @@ -577,72 +478,6 @@ int kvm_apic_match_dest(struct kvm_vcpu *vcpu, struct kvm_lapic *source, return result; } -bool kvm_irq_delivery_to_apic_fast(struct kvm *kvm, struct kvm_lapic *src, - struct kvm_lapic_irq *irq, int *r) -{ - struct kvm_apic_map *map; - unsigned long bitmap = 1; - struct kvm_lapic **dst; - int i; - bool ret = false; - - *r = -1; - - if (irq->shorthand == APIC_DEST_SELF) { - *r = kvm_apic_set_irq(src->vcpu, irq); - return true; - } - - if (irq->shorthand) - return false; - - rcu_read_lock(); - map = rcu_dereference(kvm->arch.apic_map); - - if (!map) - goto out; - - if (irq->dest_mode == 0) { /* physical mode */ - if (irq->delivery_mode == APIC_DM_LOWEST || - irq->dest_id == 0xff) - goto out; - dst = &map->phys_map[irq->dest_id & 0xff]; - } else { - u32 mda = irq->dest_id << (32 - map->ldr_bits); - - dst = map->logical_map[apic_cluster_id(map, mda)]; - - bitmap = apic_logical_id(map, mda); - - if (irq->delivery_mode == APIC_DM_LOWEST) { - int l = -1; - for_each_set_bit(i, &bitmap, 16) { - if (!dst[i]) - continue; - if (l < 0) - l = i; - else if (kvm_apic_compare_prio(dst[i]->vcpu, dst[l]->vcpu) < 0) - l = i; - } - - bitmap = (l >= 0) ? 1 << l : 0; - } - } - - for_each_set_bit(i, &bitmap, 16) { - if (!dst[i]) - continue; - if (*r < 0) - *r = 0; - *r += kvm_apic_set_irq(dst[i]->vcpu, irq); - } - - ret = true; -out: - rcu_read_unlock(); - return ret; -} - /* * Add a pending IRQ into lapic. * Return 1 if successfully added and 0 if discarded. @@ -756,7 +591,7 @@ static int apic_set_eoi(struct kvm_lapic *apic) apic_clear_isr(vector, apic); apic_update_ppr(apic); - if (!(kvm_apic_get_reg(apic, APIC_SPIV) & APIC_SPIV_DIRECTED_EOI) && + if (!(apic_get_reg(apic, APIC_SPIV) & APIC_SPIV_DIRECTED_EOI) && kvm_ioapic_handles_vector(apic->vcpu->kvm, vector)) { int trigger_mode; if (apic_test_vector(vector, apic->regs + APIC_TMR)) @@ -771,8 +606,8 @@ static int apic_set_eoi(struct kvm_lapic *apic) static void apic_send_ipi(struct kvm_lapic *apic) { - u32 icr_low = kvm_apic_get_reg(apic, APIC_ICR); - u32 icr_high = kvm_apic_get_reg(apic, APIC_ICR2); + u32 icr_low = apic_get_reg(apic, APIC_ICR); + u32 icr_high = apic_get_reg(apic, APIC_ICR2); struct kvm_lapic_irq irq; irq.vector = icr_low & APIC_VECTOR_MASK; @@ -807,7 +642,7 @@ static u32 apic_get_tmcct(struct kvm_lapic *apic) ASSERT(apic != NULL); /* if initial count is 0, current count should also be 0 */ - if (kvm_apic_get_reg(apic, APIC_TMICT) == 0) + if (apic_get_reg(apic, APIC_TMICT) == 0) return 0; remaining = hrtimer_get_remaining(&apic->lapic_timer.timer); @@ -861,15 +696,13 @@ static u32 __apic_read(struct kvm_lapic *apic, unsigned int offset) val = apic_get_tmcct(apic); break; - case APIC_PROCPRI: - apic_update_ppr(apic); - val = kvm_apic_get_reg(apic, offset); - break; + case APIC_TASKPRI: report_tpr_access(apic, false); /* fall thru */ default: - val = kvm_apic_get_reg(apic, offset); + apic_update_ppr(apic); + val = apic_get_reg(apic, offset); break; } @@ -886,7 +719,7 @@ static int apic_reg_read(struct kvm_lapic *apic, u32 offset, int len, { unsigned char alignment = offset & 0xf; u32 result; - /* this bitmask has a bit cleared for each reserved register */ + /* this bitmask has a bit cleared for each reserver register */ static const u64 rmask = 0x43ff01ffffffe70cULL; if ((alignment + len) > 4) { @@ -921,7 +754,7 @@ static int apic_reg_read(struct kvm_lapic *apic, u32 offset, int len, static int apic_mmio_in_range(struct kvm_lapic *apic, gpa_t addr) { - return kvm_apic_hw_enabled(apic) && + return apic_hw_enabled(apic) && addr >= apic->base_address && addr < apic->base_address + LAPIC_MMIO_LENGTH; } @@ -944,7 +777,7 @@ static void update_divide_count(struct kvm_lapic *apic) { u32 tmp1, tmp2, tdcr; - tdcr = kvm_apic_get_reg(apic, APIC_TDCR); + tdcr = apic_get_reg(apic, APIC_TDCR); tmp1 = tdcr & 0xf; tmp2 = ((tmp1 & 0x3) | ((tmp1 & 0x8) >> 1)) + 1; apic->divide_count = 0x1 << (tmp2 & 0x7); @@ -959,9 +792,9 @@ static void start_apic_timer(struct kvm_lapic *apic) atomic_set(&apic->lapic_timer.pending, 0); if (apic_lvtt_period(apic) || apic_lvtt_oneshot(apic)) { - /* lapic timer in oneshot or periodic mode */ + /* lapic timer in oneshot or peroidic mode */ now = apic->lapic_timer.timer.base->get_time(); - apic->lapic_timer.period = (u64)kvm_apic_get_reg(apic, APIC_TMICT) + apic->lapic_timer.period = (u64)apic_get_reg(apic, APIC_TMICT) * APIC_BUS_CYCLE_NS * apic->divide_count; if (!apic->lapic_timer.period) @@ -993,7 +826,7 @@ static void start_apic_timer(struct kvm_lapic *apic) "timer initial count 0x%x, period %lldns, " "expire @ 0x%016" PRIx64 ".\n", __func__, APIC_BUS_CYCLE_NS, ktime_to_ns(now), - kvm_apic_get_reg(apic, APIC_TMICT), + apic_get_reg(apic, APIC_TMICT), apic->lapic_timer.period, ktime_to_ns(ktime_add_ns(now, apic->lapic_timer.period))); @@ -1025,7 +858,7 @@ static void start_apic_timer(struct kvm_lapic *apic) static void apic_manage_nmi_watchdog(struct kvm_lapic *apic, u32 lvt0_val) { - int nmi_wd_enabled = apic_lvt_nmi_mode(kvm_apic_get_reg(apic, APIC_LVT0)); + int nmi_wd_enabled = apic_lvt_nmi_mode(apic_get_reg(apic, APIC_LVT0)); if (apic_lvt_nmi_mode(lvt0_val)) { if (!nmi_wd_enabled) { @@ -1046,7 +879,7 @@ static int apic_reg_write(struct kvm_lapic *apic, u32 reg, u32 val) switch (reg) { case APIC_ID: /* Local APIC ID */ if (!apic_x2apic_mode(apic)) - kvm_apic_set_id(apic, val >> 24); + apic_set_reg(apic, APIC_ID, val); else ret = 1; break; @@ -1062,30 +895,29 @@ static int apic_reg_write(struct kvm_lapic *apic, u32 reg, u32 val) case APIC_LDR: if (!apic_x2apic_mode(apic)) - kvm_apic_set_ldr(apic, val & APIC_LDR_MASK); + apic_set_reg(apic, APIC_LDR, val & APIC_LDR_MASK); else ret = 1; break; case APIC_DFR: - if (!apic_x2apic_mode(apic)) { + if (!apic_x2apic_mode(apic)) apic_set_reg(apic, APIC_DFR, val | 0x0FFFFFFF); - recalculate_apic_map(apic->vcpu->kvm); - } else + else ret = 1; break; case APIC_SPIV: { u32 mask = 0x3ff; - if (kvm_apic_get_reg(apic, APIC_LVR) & APIC_LVR_DIRECTED_EOI) + if (apic_get_reg(apic, APIC_LVR) & APIC_LVR_DIRECTED_EOI) mask |= APIC_SPIV_DIRECTED_EOI; - apic_set_spiv(apic, val & mask); + apic_set_reg(apic, APIC_SPIV, val & mask); if (!(val & APIC_SPIV_APIC_ENABLED)) { int i; u32 lvt_val; for (i = 0; i < APIC_LVT_NUM; i++) { - lvt_val = kvm_apic_get_reg(apic, + lvt_val = apic_get_reg(apic, APIC_LVTT + 0x10 * i); apic_set_reg(apic, APIC_LVTT + 0x10 * i, lvt_val | APIC_LVT_MASKED); @@ -1114,7 +946,7 @@ static int apic_reg_write(struct kvm_lapic *apic, u32 reg, u32 val) case APIC_LVT1: case APIC_LVTERR: /* TODO: Check vector */ - if (!kvm_apic_sw_enabled(apic)) + if (!apic_sw_enabled(apic)) val |= APIC_LVT_MASKED; val &= apic_lvt_mask[(reg - APIC_LVTT) >> 4]; @@ -1123,12 +955,12 @@ static int apic_reg_write(struct kvm_lapic *apic, u32 reg, u32 val) break; case APIC_LVTT: - if ((kvm_apic_get_reg(apic, APIC_LVTT) & + if ((apic_get_reg(apic, APIC_LVTT) & apic->lapic_timer.timer_mode_mask) != (val & apic->lapic_timer.timer_mode_mask)) hrtimer_cancel(&apic->lapic_timer.timer); - if (!kvm_apic_sw_enabled(apic)) + if (!apic_sw_enabled(apic)) val |= APIC_LVT_MASKED; val &= (apic_lvt_mask[0] | apic->lapic_timer.timer_mode_mask); apic_set_reg(apic, APIC_LVTT, val); @@ -1207,30 +1039,24 @@ static int apic_mmio_write(struct kvm_io_device *this, void kvm_lapic_set_eoi(struct kvm_vcpu *vcpu) { - if (kvm_vcpu_has_lapic(vcpu)) + struct kvm_lapic *apic = vcpu->arch.apic; + + if (apic) apic_reg_write(vcpu->arch.apic, APIC_EOI, 0); } EXPORT_SYMBOL_GPL(kvm_lapic_set_eoi); void kvm_free_lapic(struct kvm_vcpu *vcpu) { - struct kvm_lapic *apic = vcpu->arch.apic; - if (!vcpu->arch.apic) return; - hrtimer_cancel(&apic->lapic_timer.timer); - - if (!(vcpu->arch.apic_base & MSR_IA32_APICBASE_ENABLE)) - static_key_slow_dec_deferred(&apic_hw_disabled); - - if (!(kvm_apic_get_reg(apic, APIC_SPIV) & APIC_SPIV_APIC_ENABLED)) - static_key_slow_dec_deferred(&apic_sw_disabled); + hrtimer_cancel(&vcpu->arch.apic->lapic_timer.timer); - if (apic->regs) - free_page((unsigned long)apic->regs); + if (vcpu->arch.apic->regs) + free_page((unsigned long)vcpu->arch.apic->regs); - kfree(apic); + kfree(vcpu->arch.apic); } /* @@ -1242,9 +1068,10 @@ void kvm_free_lapic(struct kvm_vcpu *vcpu) u64 kvm_get_lapic_tscdeadline_msr(struct kvm_vcpu *vcpu) { struct kvm_lapic *apic = vcpu->arch.apic; + if (!apic) + return 0; - if (!kvm_vcpu_has_lapic(vcpu) || apic_lvtt_oneshot(apic) || - apic_lvtt_period(apic)) + if (apic_lvtt_oneshot(apic) || apic_lvtt_period(apic)) return 0; return apic->lapic_timer.tscdeadline; @@ -1253,9 +1080,10 @@ u64 kvm_get_lapic_tscdeadline_msr(struct kvm_vcpu *vcpu) void kvm_set_lapic_tscdeadline_msr(struct kvm_vcpu *vcpu, u64 data) { struct kvm_lapic *apic = vcpu->arch.apic; + if (!apic) + return; - if (!kvm_vcpu_has_lapic(vcpu) || apic_lvtt_oneshot(apic) || - apic_lvtt_period(apic)) + if (apic_lvtt_oneshot(apic) || apic_lvtt_period(apic)) return; hrtimer_cancel(&apic->lapic_timer.timer); @@ -1267,21 +1095,20 @@ void kvm_lapic_set_tpr(struct kvm_vcpu *vcpu, unsigned long cr8) { struct kvm_lapic *apic = vcpu->arch.apic; - if (!kvm_vcpu_has_lapic(vcpu)) + if (!apic) return; - apic_set_tpr(apic, ((cr8 & 0x0f) << 4) - | (kvm_apic_get_reg(apic, APIC_TASKPRI) & 4)); + | (apic_get_reg(apic, APIC_TASKPRI) & 4)); } u64 kvm_lapic_get_cr8(struct kvm_vcpu *vcpu) { + struct kvm_lapic *apic = vcpu->arch.apic; u64 tpr; - if (!kvm_vcpu_has_lapic(vcpu)) + if (!apic) return 0; - - tpr = (u64) kvm_apic_get_reg(vcpu->arch.apic, APIC_TASKPRI); + tpr = (u64) apic_get_reg(apic, APIC_TASKPRI); return (tpr & 0xf0) >> 4; } @@ -1296,15 +1123,6 @@ void kvm_lapic_set_base(struct kvm_vcpu *vcpu, u64 value) return; } - /* update jump label if enable bit changes */ - if ((vcpu->arch.apic_base ^ value) & MSR_IA32_APICBASE_ENABLE) { - if (value & MSR_IA32_APICBASE_ENABLE) - static_key_slow_dec_deferred(&apic_hw_disabled); - else - static_key_slow_inc(&apic_hw_disabled.key); - recalculate_apic_map(vcpu->kvm); - } - if (!kvm_vcpu_is_bsp(apic->vcpu)) value &= ~MSR_IA32_APICBASE_BSP; @@ -1312,7 +1130,7 @@ void kvm_lapic_set_base(struct kvm_vcpu *vcpu, u64 value) if (apic_x2apic_mode(apic)) { u32 id = kvm_apic_id(apic); u32 ldr = ((id & ~0xf) << 16) | (1 << (id & 0xf)); - kvm_apic_set_ldr(apic, ldr); + apic_set_reg(apic, APIC_LDR, ldr); } apic->base_address = apic->vcpu->arch.apic_base & MSR_IA32_APICBASE_BASE; @@ -1337,7 +1155,7 @@ void kvm_lapic_reset(struct kvm_vcpu *vcpu) /* Stop the timer in case it's a reset to an active apic */ hrtimer_cancel(&apic->lapic_timer.timer); - kvm_apic_set_id(apic, vcpu->vcpu_id); + apic_set_reg(apic, APIC_ID, vcpu->vcpu_id << 24); kvm_apic_set_version(apic->vcpu); for (i = 0; i < APIC_LVT_NUM; i++) @@ -1346,9 +1164,9 @@ void kvm_lapic_reset(struct kvm_vcpu *vcpu) SET_APIC_DELIVERY_MODE(0, APIC_MODE_EXTINT)); apic_set_reg(apic, APIC_DFR, 0xffffffffU); - apic_set_spiv(apic, 0xff); + apic_set_reg(apic, APIC_SPIV, 0xff); apic_set_reg(apic, APIC_TASKPRI, 0); - kvm_apic_set_ldr(apic, 0); + apic_set_reg(apic, APIC_LDR, 0); apic_set_reg(apic, APIC_ESR, 0); apic_set_reg(apic, APIC_ICR, 0); apic_set_reg(apic, APIC_ICR2, 0); @@ -1365,8 +1183,7 @@ void kvm_lapic_reset(struct kvm_vcpu *vcpu) update_divide_count(apic); atomic_set(&apic->lapic_timer.pending, 0); if (kvm_vcpu_is_bsp(vcpu)) - kvm_lapic_set_base(vcpu, - vcpu->arch.apic_base | MSR_IA32_APICBASE_BSP); + vcpu->arch.apic_base |= MSR_IA32_APICBASE_BSP; vcpu->arch.pv_eoi.msr_val = 0; apic_update_ppr(apic); @@ -1379,34 +1196,45 @@ void kvm_lapic_reset(struct kvm_vcpu *vcpu) vcpu->arch.apic_base, apic->base_address); } +bool kvm_apic_present(struct kvm_vcpu *vcpu) +{ + return vcpu->arch.apic && apic_hw_enabled(vcpu->arch.apic); +} + +int kvm_lapic_enabled(struct kvm_vcpu *vcpu) +{ + return kvm_apic_present(vcpu) && apic_sw_enabled(vcpu->arch.apic); +} + /* *---------------------------------------------------------------------- * timer interface *---------------------------------------------------------------------- */ -static bool lapic_is_periodic(struct kvm_lapic *apic) +static bool lapic_is_periodic(struct kvm_timer *ktimer) { + struct kvm_lapic *apic = container_of(ktimer, struct kvm_lapic, + lapic_timer); return apic_lvtt_period(apic); } int apic_has_pending_timer(struct kvm_vcpu *vcpu) { - struct kvm_lapic *apic = vcpu->arch.apic; + struct kvm_lapic *lapic = vcpu->arch.apic; - if (kvm_vcpu_has_lapic(vcpu) && apic_enabled(apic) && - apic_lvt_enabled(apic, APIC_LVTT)) - return atomic_read(&apic->lapic_timer.pending); + if (lapic && apic_enabled(lapic) && apic_lvt_enabled(lapic, APIC_LVTT)) + return atomic_read(&lapic->lapic_timer.pending); return 0; } int kvm_apic_local_deliver(struct kvm_lapic *apic, int lvt_type) { - u32 reg = kvm_apic_get_reg(apic, lvt_type); + u32 reg = apic_get_reg(apic, lvt_type); int vector, mode, trig_mode; - if (kvm_apic_hw_enabled(apic) && !(reg & APIC_LVT_MASKED)) { + if (apic_hw_enabled(apic) && !(reg & APIC_LVT_MASKED)) { vector = reg & APIC_VECTOR_MASK; mode = reg & APIC_MODE_MASK; trig_mode = reg & APIC_LVT_LEVEL_TRIGGER; @@ -1423,40 +1251,15 @@ void kvm_apic_nmi_wd_deliver(struct kvm_vcpu *vcpu) kvm_apic_local_deliver(apic, APIC_LVT0); } +static struct kvm_timer_ops lapic_timer_ops = { + .is_periodic = lapic_is_periodic, +}; + static const struct kvm_io_device_ops apic_mmio_ops = { .read = apic_mmio_read, .write = apic_mmio_write, }; -static enum hrtimer_restart apic_timer_fn(struct hrtimer *data) -{ - struct kvm_timer *ktimer = container_of(data, struct kvm_timer, timer); - struct kvm_lapic *apic = container_of(ktimer, struct kvm_lapic, lapic_timer); - struct kvm_vcpu *vcpu = apic->vcpu; - wait_queue_head_t *q = &vcpu->wq; - - /* - * There is a race window between reading and incrementing, but we do - * not care about potentially losing timer events in the !reinject - * case anyway. Note: KVM_REQ_PENDING_TIMER is implicitly checked - * in vcpu_enter_guest. - */ - if (!atomic_read(&ktimer->pending)) { - atomic_inc(&ktimer->pending); - /* FIXME: this code should not know anything about vcpus */ - kvm_make_request(KVM_REQ_PENDING_TIMER, vcpu); - } - - if (waitqueue_active(q)) - wake_up_interruptible(q); - - if (lapic_is_periodic(apic)) { - hrtimer_add_expires_ns(&ktimer->timer, ktimer->period); - return HRTIMER_RESTART; - } else - return HRTIMER_NORESTART; -} - int kvm_create_lapic(struct kvm_vcpu *vcpu) { struct kvm_lapic *apic; @@ -1480,17 +1283,14 @@ int kvm_create_lapic(struct kvm_vcpu *vcpu) hrtimer_init(&apic->lapic_timer.timer, CLOCK_MONOTONIC, HRTIMER_MODE_ABS); - apic->lapic_timer.timer.function = apic_timer_fn; + apic->lapic_timer.timer.function = kvm_timer_fn; + apic->lapic_timer.t_ops = &lapic_timer_ops; + apic->lapic_timer.kvm = vcpu->kvm; + apic->lapic_timer.vcpu = vcpu; - /* - * APIC is created enabled. This will prevent kvm_lapic_set_base from - * thinking that APIC satet has changed. - */ - vcpu->arch.apic_base = MSR_IA32_APICBASE_ENABLE; - kvm_lapic_set_base(vcpu, - APIC_DEFAULT_PHYS_BASE | MSR_IA32_APICBASE_ENABLE); + apic->base_address = APIC_DEFAULT_PHYS_BASE; + vcpu->arch.apic_base = APIC_DEFAULT_PHYS_BASE; - static_key_slow_inc(&apic_sw_disabled.key); /* sw disabled at reset */ kvm_lapic_reset(vcpu); kvm_iodevice_init(&apic->dev, &apic_mmio_ops); @@ -1506,23 +1306,23 @@ int kvm_apic_has_interrupt(struct kvm_vcpu *vcpu) struct kvm_lapic *apic = vcpu->arch.apic; int highest_irr; - if (!kvm_vcpu_has_lapic(vcpu) || !apic_enabled(apic)) + if (!apic || !apic_enabled(apic)) return -1; apic_update_ppr(apic); highest_irr = apic_find_highest_irr(apic); if ((highest_irr == -1) || - ((highest_irr & 0xF0) <= kvm_apic_get_reg(apic, APIC_PROCPRI))) + ((highest_irr & 0xF0) <= apic_get_reg(apic, APIC_PROCPRI))) return -1; return highest_irr; } int kvm_apic_accept_pic_intr(struct kvm_vcpu *vcpu) { - u32 lvt0 = kvm_apic_get_reg(vcpu->arch.apic, APIC_LVT0); + u32 lvt0 = apic_get_reg(vcpu->arch.apic, APIC_LVT0); int r = 0; - if (!kvm_apic_hw_enabled(vcpu->arch.apic)) + if (!apic_hw_enabled(vcpu->arch.apic)) r = 1; if ((lvt0 & APIC_LVT_MASKED) == 0 && GET_APIC_DELIVERY_MODE(lvt0) == APIC_MODE_EXTINT) @@ -1534,10 +1334,7 @@ void kvm_inject_apic_timer_irqs(struct kvm_vcpu *vcpu) { struct kvm_lapic *apic = vcpu->arch.apic; - if (!kvm_vcpu_has_lapic(vcpu)) - return; - - if (atomic_read(&apic->lapic_timer.pending) > 0) { + if (apic && atomic_read(&apic->lapic_timer.pending) > 0) { if (kvm_apic_local_deliver(apic, APIC_LVTT)) atomic_dec(&apic->lapic_timer.pending); } @@ -1557,17 +1354,12 @@ int kvm_get_apic_interrupt(struct kvm_vcpu *vcpu) return vector; } -void kvm_apic_post_state_restore(struct kvm_vcpu *vcpu, - struct kvm_lapic_state *s) +void kvm_apic_post_state_restore(struct kvm_vcpu *vcpu) { struct kvm_lapic *apic = vcpu->arch.apic; - kvm_lapic_set_base(vcpu, vcpu->arch.apic_base); - /* set SPIV separately to get count of SW disabled APICs right */ - apic_set_spiv(apic, *((u32 *)(s->regs + APIC_SPIV))); - memcpy(vcpu->arch.apic->regs, s->regs, sizeof *s); - /* call kvm_apic_set_id() to put apic into apic_map */ - kvm_apic_set_id(apic, kvm_apic_id(apic)); + apic->base_address = vcpu->arch.apic_base & + MSR_IA32_APICBASE_BASE; kvm_apic_set_version(vcpu); apic_update_ppr(apic); @@ -1582,12 +1374,13 @@ void kvm_apic_post_state_restore(struct kvm_vcpu *vcpu, void __kvm_migrate_apic_timer(struct kvm_vcpu *vcpu) { + struct kvm_lapic *apic = vcpu->arch.apic; struct hrtimer *timer; - if (!kvm_vcpu_has_lapic(vcpu)) + if (!apic) return; - timer = &vcpu->arch.apic->lapic_timer.timer; + timer = &apic->lapic_timer.timer; if (hrtimer_cancel(timer)) hrtimer_start_expires(timer, HRTIMER_MODE_ABS); } @@ -1685,7 +1478,7 @@ void kvm_lapic_sync_to_vapic(struct kvm_vcpu *vcpu) if (!test_bit(KVM_APIC_CHECK_VAPIC, &vcpu->arch.apic_attention)) return; - tpr = kvm_apic_get_reg(apic, APIC_TASKPRI) & 0xff; + tpr = apic_get_reg(apic, APIC_TASKPRI) & 0xff; max_irr = apic_find_highest_irr(apic); if (max_irr < 0) max_irr = 0; @@ -1744,7 +1537,7 @@ int kvm_hv_vapic_msr_write(struct kvm_vcpu *vcpu, u32 reg, u64 data) { struct kvm_lapic *apic = vcpu->arch.apic; - if (!kvm_vcpu_has_lapic(vcpu)) + if (!irqchip_in_kernel(vcpu->kvm)) return 1; /* if this is ICR write vector before command */ @@ -1758,7 +1551,7 @@ int kvm_hv_vapic_msr_read(struct kvm_vcpu *vcpu, u32 reg, u64 *data) struct kvm_lapic *apic = vcpu->arch.apic; u32 low, high = 0; - if (!kvm_vcpu_has_lapic(vcpu)) + if (!irqchip_in_kernel(vcpu->kvm)) return 1; if (apic_reg_read(apic, reg, 4, &low)) @@ -1783,10 +1576,3 @@ int kvm_lapic_enable_pv_eoi(struct kvm_vcpu *vcpu, u64 data) return kvm_gfn_to_hva_cache_init(vcpu->kvm, &vcpu->arch.pv_eoi.data, addr); } - -void kvm_lapic_init(void) -{ - /* do not patch jump label more than once per second */ - jump_label_rate_limit(&apic_hw_disabled, HZ); - jump_label_rate_limit(&apic_sw_disabled, HZ); -} diff --git a/trunk/arch/x86/kvm/lapic.h b/trunk/arch/x86/kvm/lapic.h index e5ebf9f3571f..4af5405ae1e2 100644 --- a/trunk/arch/x86/kvm/lapic.h +++ b/trunk/arch/x86/kvm/lapic.h @@ -2,17 +2,10 @@ #define __KVM_X86_LAPIC_H #include "iodev.h" +#include "kvm_timer.h" #include -struct kvm_timer { - struct hrtimer timer; - s64 period; /* unit: ns */ - u32 timer_mode_mask; - u64 tscdeadline; - atomic_t pending; /* accumulated triggered timers */ -}; - struct kvm_lapic { unsigned long base_address; struct kvm_io_device dev; @@ -52,13 +45,11 @@ int kvm_apic_match_logical_addr(struct kvm_lapic *apic, u8 mda); int kvm_apic_set_irq(struct kvm_vcpu *vcpu, struct kvm_lapic_irq *irq); int kvm_apic_local_deliver(struct kvm_lapic *apic, int lvt_type); -bool kvm_irq_delivery_to_apic_fast(struct kvm *kvm, struct kvm_lapic *src, - struct kvm_lapic_irq *irq, int *r); - u64 kvm_get_apic_base(struct kvm_vcpu *vcpu); void kvm_set_apic_base(struct kvm_vcpu *vcpu, u64 data); -void kvm_apic_post_state_restore(struct kvm_vcpu *vcpu, - struct kvm_lapic_state *s); +void kvm_apic_post_state_restore(struct kvm_vcpu *vcpu); +int kvm_lapic_enabled(struct kvm_vcpu *vcpu); +bool kvm_apic_present(struct kvm_vcpu *vcpu); int kvm_lapic_find_highest_irr(struct kvm_vcpu *vcpu); u64 kvm_get_lapic_tscdeadline_msr(struct kvm_vcpu *vcpu); @@ -80,48 +71,4 @@ static inline bool kvm_hv_vapic_assist_page_enabled(struct kvm_vcpu *vcpu) } int kvm_lapic_enable_pv_eoi(struct kvm_vcpu *vcpu, u64 data); -void kvm_lapic_init(void); - -static inline u32 kvm_apic_get_reg(struct kvm_lapic *apic, int reg_off) -{ - return *((u32 *) (apic->regs + reg_off)); -} - -extern struct static_key kvm_no_apic_vcpu; - -static inline bool kvm_vcpu_has_lapic(struct kvm_vcpu *vcpu) -{ - if (static_key_false(&kvm_no_apic_vcpu)) - return vcpu->arch.apic; - return true; -} - -extern struct static_key_deferred apic_hw_disabled; - -static inline int kvm_apic_hw_enabled(struct kvm_lapic *apic) -{ - if (static_key_false(&apic_hw_disabled.key)) - return apic->vcpu->arch.apic_base & MSR_IA32_APICBASE_ENABLE; - return MSR_IA32_APICBASE_ENABLE; -} - -extern struct static_key_deferred apic_sw_disabled; - -static inline int kvm_apic_sw_enabled(struct kvm_lapic *apic) -{ - if (static_key_false(&apic_sw_disabled.key)) - return kvm_apic_get_reg(apic, APIC_SPIV) & APIC_SPIV_APIC_ENABLED; - return APIC_SPIV_APIC_ENABLED; -} - -static inline bool kvm_apic_present(struct kvm_vcpu *vcpu) -{ - return kvm_vcpu_has_lapic(vcpu) && kvm_apic_hw_enabled(vcpu->arch.apic); -} - -static inline int kvm_lapic_enabled(struct kvm_vcpu *vcpu) -{ - return kvm_apic_present(vcpu) && kvm_apic_sw_enabled(vcpu->arch.apic); -} - #endif diff --git a/trunk/arch/x86/kvm/mmu.c b/trunk/arch/x86/kvm/mmu.c index d289fee1ffb8..7fbd0d273ea8 100644 --- a/trunk/arch/x86/kvm/mmu.c +++ b/trunk/arch/x86/kvm/mmu.c @@ -556,14 +556,6 @@ static int mmu_spte_clear_track_bits(u64 *sptep) return 0; pfn = spte_to_pfn(old_spte); - - /* - * KVM does not hold the refcount of the page used by - * kvm mmu, before reclaiming the page, we should - * unmap it from mmu first. - */ - WARN_ON(!kvm_is_mmio_pfn(pfn) && !page_count(pfn_to_page(pfn))); - if (!shadow_accessed_mask || old_spte & shadow_accessed_mask) kvm_set_pfn_accessed(pfn); if (!shadow_dirty_mask || (old_spte & shadow_dirty_mask)) @@ -968,10 +960,13 @@ static void pte_list_walk(unsigned long *pte_list, pte_list_walk_fn fn) static unsigned long *__gfn_to_rmap(gfn_t gfn, int level, struct kvm_memory_slot *slot) { - unsigned long idx; + struct kvm_lpage_info *linfo; - idx = gfn_to_index(gfn, slot->base_gfn, level); - return &slot->arch.rmap[level - PT_PAGE_TABLE_LEVEL][idx]; + if (likely(level == PT_PAGE_TABLE_LEVEL)) + return &slot->rmap[gfn - slot->base_gfn]; + + linfo = lpage_info_slot(gfn, slot, level); + return &linfo->rmap_pde; } /* @@ -1178,8 +1173,7 @@ void kvm_mmu_write_protect_pt_masked(struct kvm *kvm, unsigned long *rmapp; while (mask) { - rmapp = __gfn_to_rmap(slot->base_gfn + gfn_offset + __ffs(mask), - PT_PAGE_TABLE_LEVEL, slot); + rmapp = &slot->rmap[gfn_offset + __ffs(mask)]; __rmap_write_protect(kvm, rmapp, PT_PAGE_TABLE_LEVEL, false); /* clear the first set bit */ @@ -1206,7 +1200,7 @@ static bool rmap_write_protect(struct kvm *kvm, u64 gfn) } static int kvm_unmap_rmapp(struct kvm *kvm, unsigned long *rmapp, - struct kvm_memory_slot *slot, unsigned long data) + unsigned long data) { u64 *sptep; struct rmap_iterator iter; @@ -1224,7 +1218,7 @@ static int kvm_unmap_rmapp(struct kvm *kvm, unsigned long *rmapp, } static int kvm_set_pte_rmapp(struct kvm *kvm, unsigned long *rmapp, - struct kvm_memory_slot *slot, unsigned long data) + unsigned long data) { u64 *sptep; struct rmap_iterator iter; @@ -1265,67 +1259,43 @@ static int kvm_set_pte_rmapp(struct kvm *kvm, unsigned long *rmapp, return 0; } -static int kvm_handle_hva_range(struct kvm *kvm, - unsigned long start, - unsigned long end, - unsigned long data, - int (*handler)(struct kvm *kvm, - unsigned long *rmapp, - struct kvm_memory_slot *slot, - unsigned long data)) +static int kvm_handle_hva(struct kvm *kvm, unsigned long hva, + unsigned long data, + int (*handler)(struct kvm *kvm, unsigned long *rmapp, + unsigned long data)) { int j; - int ret = 0; + int ret; + int retval = 0; struct kvm_memslots *slots; struct kvm_memory_slot *memslot; slots = kvm_memslots(kvm); kvm_for_each_memslot(memslot, slots) { - unsigned long hva_start, hva_end; - gfn_t gfn_start, gfn_end; + unsigned long start = memslot->userspace_addr; + unsigned long end; - hva_start = max(start, memslot->userspace_addr); - hva_end = min(end, memslot->userspace_addr + - (memslot->npages << PAGE_SHIFT)); - if (hva_start >= hva_end) - continue; - /* - * {gfn(page) | page intersects with [hva_start, hva_end)} = - * {gfn_start, gfn_start+1, ..., gfn_end-1}. - */ - gfn_start = hva_to_gfn_memslot(hva_start, memslot); - gfn_end = hva_to_gfn_memslot(hva_end + PAGE_SIZE - 1, memslot); + end = start + (memslot->npages << PAGE_SHIFT); + if (hva >= start && hva < end) { + gfn_t gfn_offset = (hva - start) >> PAGE_SHIFT; + gfn_t gfn = memslot->base_gfn + gfn_offset; - for (j = PT_PAGE_TABLE_LEVEL; - j < PT_PAGE_TABLE_LEVEL + KVM_NR_PAGE_SIZES; ++j) { - unsigned long idx, idx_end; - unsigned long *rmapp; + ret = handler(kvm, &memslot->rmap[gfn_offset], data); - /* - * {idx(page_j) | page_j intersects with - * [hva_start, hva_end)} = {idx, idx+1, ..., idx_end}. - */ - idx = gfn_to_index(gfn_start, memslot->base_gfn, j); - idx_end = gfn_to_index(gfn_end - 1, memslot->base_gfn, j); + for (j = 0; j < KVM_NR_PAGE_SIZES - 1; ++j) { + struct kvm_lpage_info *linfo; - rmapp = __gfn_to_rmap(gfn_start, j, memslot); - - for (; idx <= idx_end; ++idx) - ret |= handler(kvm, rmapp++, memslot, data); + linfo = lpage_info_slot(gfn, memslot, + PT_DIRECTORY_LEVEL + j); + ret |= handler(kvm, &linfo->rmap_pde, data); + } + trace_kvm_age_page(hva, memslot, ret); + retval |= ret; } } - return ret; -} - -static int kvm_handle_hva(struct kvm *kvm, unsigned long hva, - unsigned long data, - int (*handler)(struct kvm *kvm, unsigned long *rmapp, - struct kvm_memory_slot *slot, - unsigned long data)) -{ - return kvm_handle_hva_range(kvm, hva, hva + 1, data, handler); + return retval; } int kvm_unmap_hva(struct kvm *kvm, unsigned long hva) @@ -1333,18 +1303,13 @@ int kvm_unmap_hva(struct kvm *kvm, unsigned long hva) return kvm_handle_hva(kvm, hva, 0, kvm_unmap_rmapp); } -int kvm_unmap_hva_range(struct kvm *kvm, unsigned long start, unsigned long end) -{ - return kvm_handle_hva_range(kvm, start, end, 0, kvm_unmap_rmapp); -} - void kvm_set_spte_hva(struct kvm *kvm, unsigned long hva, pte_t pte) { kvm_handle_hva(kvm, hva, (unsigned long)&pte, kvm_set_pte_rmapp); } static int kvm_age_rmapp(struct kvm *kvm, unsigned long *rmapp, - struct kvm_memory_slot *slot, unsigned long data) + unsigned long data) { u64 *sptep; struct rmap_iterator uninitialized_var(iter); @@ -1358,10 +1323,8 @@ static int kvm_age_rmapp(struct kvm *kvm, unsigned long *rmapp, * This has some overhead, but not as much as the cost of swapping * out actively used pages or breaking up actively used hugepages. */ - if (!shadow_accessed_mask) { - young = kvm_unmap_rmapp(kvm, rmapp, slot, data); - goto out; - } + if (!shadow_accessed_mask) + return kvm_unmap_rmapp(kvm, rmapp, data); for (sptep = rmap_get_first(*rmapp, &iter); sptep; sptep = rmap_get_next(&iter)) { @@ -1373,14 +1336,12 @@ static int kvm_age_rmapp(struct kvm *kvm, unsigned long *rmapp, (unsigned long *)sptep); } } -out: - /* @data has hva passed to kvm_age_hva(). */ - trace_kvm_age_page(data, slot, young); + return young; } static int kvm_test_age_rmapp(struct kvm *kvm, unsigned long *rmapp, - struct kvm_memory_slot *slot, unsigned long data) + unsigned long data) { u64 *sptep; struct rmap_iterator iter; @@ -1418,13 +1379,13 @@ static void rmap_recycle(struct kvm_vcpu *vcpu, u64 *spte, gfn_t gfn) rmapp = gfn_to_rmap(vcpu->kvm, gfn, sp->role.level); - kvm_unmap_rmapp(vcpu->kvm, rmapp, NULL, 0); + kvm_unmap_rmapp(vcpu->kvm, rmapp, 0); kvm_flush_remote_tlbs(vcpu->kvm); } int kvm_age_hva(struct kvm *kvm, unsigned long hva) { - return kvm_handle_hva(kvm, hva, hva, kvm_age_rmapp); + return kvm_handle_hva(kvm, hva, 0, kvm_age_rmapp); } int kvm_test_age_hva(struct kvm *kvm, unsigned long hva) @@ -2496,9 +2457,7 @@ static void mmu_set_spte(struct kvm_vcpu *vcpu, u64 *sptep, rmap_recycle(vcpu, sptep, gfn); } } - - if (!is_error_pfn(pfn)) - kvm_release_pfn_clean(pfn); + kvm_release_pfn_clean(pfn); } static void nonpaging_new_cr3(struct kvm_vcpu *vcpu) @@ -2510,12 +2469,17 @@ static pfn_t pte_prefetch_gfn_to_pfn(struct kvm_vcpu *vcpu, gfn_t gfn, bool no_dirty_log) { struct kvm_memory_slot *slot; + unsigned long hva; slot = gfn_to_memslot_dirty_bitmap(vcpu, gfn, no_dirty_log); - if (!slot) - return KVM_PFN_ERR_FAULT; + if (!slot) { + get_page(fault_page); + return page_to_pfn(fault_page); + } - return gfn_to_pfn_memslot_atomic(slot, gfn); + hva = gfn_to_hva_memslot(slot, gfn); + + return hva_to_pfn_atomic(vcpu->kvm, hva); } static int direct_pte_prefetch_many(struct kvm_vcpu *vcpu, @@ -2616,6 +2580,11 @@ static int __direct_map(struct kvm_vcpu *vcpu, gpa_t v, int write, sp = kvm_mmu_get_page(vcpu, pseudo_gfn, iterator.addr, iterator.level - 1, 1, ACC_ALL, iterator.sptep); + if (!sp) { + pgprintk("nonpaging_map: ENOMEM\n"); + kvm_release_pfn_clean(pfn); + return -ENOMEM; + } mmu_spte_set(iterator.sptep, __pa(sp->spt) @@ -2642,16 +2611,8 @@ static void kvm_send_hwpoison_signal(unsigned long address, struct task_struct * static int kvm_handle_bad_page(struct kvm_vcpu *vcpu, gfn_t gfn, pfn_t pfn) { - /* - * Do not cache the mmio info caused by writing the readonly gfn - * into the spte otherwise read access on readonly gfn also can - * caused mmio page fault and treat it as mmio access. - * Return 1 to tell kvm to emulate it. - */ - if (pfn == KVM_PFN_ERR_RO_FAULT) - return 1; - - if (pfn == KVM_PFN_ERR_HWPOISON) { + kvm_release_pfn_clean(pfn); + if (is_hwpoison_pfn(pfn)) { kvm_send_hwpoison_signal(gfn_to_hva(vcpu->kvm, gfn), current); return 0; } @@ -3275,6 +3236,8 @@ static bool try_async_pf(struct kvm_vcpu *vcpu, bool prefault, gfn_t gfn, if (!async) return false; /* *pfn has correct page already */ + put_page(pfn_to_page(*pfn)); + if (!prefault && can_do_async_pf(vcpu)) { trace_kvm_try_async_get_page(gva, gfn); if (kvm_find_async_pf_gfn(vcpu, gfn)) { @@ -3408,18 +3371,6 @@ static bool is_rsvd_bits_set(struct kvm_mmu *mmu, u64 gpte, int level) return (gpte & mmu->rsvd_bits_mask[bit7][level-1]) != 0; } -static inline void protect_clean_gpte(unsigned *access, unsigned gpte) -{ - unsigned mask; - - BUILD_BUG_ON(PT_WRITABLE_MASK != ACC_WRITE_MASK); - - mask = (unsigned)~ACC_WRITE_MASK; - /* Allow write access to dirty gptes */ - mask |= (gpte >> (PT_DIRTY_SHIFT - PT_WRITABLE_SHIFT)) & PT_WRITABLE_MASK; - *access &= mask; -} - static bool sync_mmio_spte(u64 *sptep, gfn_t gfn, unsigned access, int *nr_present) { @@ -3437,25 +3388,6 @@ static bool sync_mmio_spte(u64 *sptep, gfn_t gfn, unsigned access, return false; } -static inline unsigned gpte_access(struct kvm_vcpu *vcpu, u64 gpte) -{ - unsigned access; - - access = (gpte & (PT_WRITABLE_MASK | PT_USER_MASK)) | ACC_EXEC_MASK; - access &= ~(gpte >> PT64_NX_SHIFT); - - return access; -} - -static inline bool is_last_gpte(struct kvm_mmu *mmu, unsigned level, unsigned gpte) -{ - unsigned index; - - index = level - 1; - index |= (gpte & PT_PAGE_SIZE_MASK) >> (PT_PAGE_SIZE_SHIFT - 2); - return mmu->last_pte_bitmap & (1 << index); -} - #define PTTYPE 64 #include "paging_tmpl.h" #undef PTTYPE @@ -3525,56 +3457,6 @@ static void reset_rsvds_bits_mask(struct kvm_vcpu *vcpu, } } -static void update_permission_bitmask(struct kvm_vcpu *vcpu, struct kvm_mmu *mmu) -{ - unsigned bit, byte, pfec; - u8 map; - bool fault, x, w, u, wf, uf, ff, smep; - - smep = kvm_read_cr4_bits(vcpu, X86_CR4_SMEP); - for (byte = 0; byte < ARRAY_SIZE(mmu->permissions); ++byte) { - pfec = byte << 1; - map = 0; - wf = pfec & PFERR_WRITE_MASK; - uf = pfec & PFERR_USER_MASK; - ff = pfec & PFERR_FETCH_MASK; - for (bit = 0; bit < 8; ++bit) { - x = bit & ACC_EXEC_MASK; - w = bit & ACC_WRITE_MASK; - u = bit & ACC_USER_MASK; - - /* Not really needed: !nx will cause pte.nx to fault */ - x |= !mmu->nx; - /* Allow supervisor writes if !cr0.wp */ - w |= !is_write_protection(vcpu) && !uf; - /* Disallow supervisor fetches of user code if cr4.smep */ - x &= !(smep && u && !uf); - - fault = (ff && !x) || (uf && !u) || (wf && !w); - map |= fault << bit; - } - mmu->permissions[byte] = map; - } -} - -static void update_last_pte_bitmap(struct kvm_vcpu *vcpu, struct kvm_mmu *mmu) -{ - u8 map; - unsigned level, root_level = mmu->root_level; - const unsigned ps_set_index = 1 << 2; /* bit 2 of index: ps */ - - if (root_level == PT32E_ROOT_LEVEL) - --root_level; - /* PT_PAGE_TABLE_LEVEL always terminates */ - map = 1 | (1 << ps_set_index); - for (level = PT_DIRECTORY_LEVEL; level <= root_level; ++level) { - if (level <= PT_PDPE_LEVEL - && (mmu->root_level >= PT32E_ROOT_LEVEL || is_pse(vcpu))) - map |= 1 << (ps_set_index | (level - 1)); - } - mmu->last_pte_bitmap = map; -} - static int paging64_init_context_common(struct kvm_vcpu *vcpu, struct kvm_mmu *context, int level) @@ -3583,8 +3465,6 @@ static int paging64_init_context_common(struct kvm_vcpu *vcpu, context->root_level = level; reset_rsvds_bits_mask(vcpu, context); - update_permission_bitmask(vcpu, context); - update_last_pte_bitmap(vcpu, context); ASSERT(is_pae(vcpu)); context->new_cr3 = paging_new_cr3; @@ -3613,8 +3493,6 @@ static int paging32_init_context(struct kvm_vcpu *vcpu, context->root_level = PT32_ROOT_LEVEL; reset_rsvds_bits_mask(vcpu, context); - update_permission_bitmask(vcpu, context); - update_last_pte_bitmap(vcpu, context); context->new_cr3 = paging_new_cr3; context->page_fault = paging32_page_fault; @@ -3675,9 +3553,6 @@ static int init_kvm_tdp_mmu(struct kvm_vcpu *vcpu) context->gva_to_gpa = paging32_gva_to_gpa; } - update_permission_bitmask(vcpu, context); - update_last_pte_bitmap(vcpu, context); - return 0; } @@ -3753,9 +3628,6 @@ static int init_kvm_nested_mmu(struct kvm_vcpu *vcpu) g_context->gva_to_gpa = paging32_gva_to_gpa_nested; } - update_permission_bitmask(vcpu, g_context); - update_last_pte_bitmap(vcpu, g_context); - return 0; } diff --git a/trunk/arch/x86/kvm/mmu.h b/trunk/arch/x86/kvm/mmu.h index 69871080e866..e374db9af021 100644 --- a/trunk/arch/x86/kvm/mmu.h +++ b/trunk/arch/x86/kvm/mmu.h @@ -18,10 +18,8 @@ #define PT_PCD_MASK (1ULL << 4) #define PT_ACCESSED_SHIFT 5 #define PT_ACCESSED_MASK (1ULL << PT_ACCESSED_SHIFT) -#define PT_DIRTY_SHIFT 6 -#define PT_DIRTY_MASK (1ULL << PT_DIRTY_SHIFT) -#define PT_PAGE_SIZE_SHIFT 7 -#define PT_PAGE_SIZE_MASK (1ULL << PT_PAGE_SIZE_SHIFT) +#define PT_DIRTY_MASK (1ULL << 6) +#define PT_PAGE_SIZE_MASK (1ULL << 7) #define PT_PAT_MASK (1ULL << 7) #define PT_GLOBAL_MASK (1ULL << 8) #define PT64_NX_SHIFT 63 @@ -90,14 +88,17 @@ static inline bool is_write_protection(struct kvm_vcpu *vcpu) return kvm_read_cr0_bits(vcpu, X86_CR0_WP); } -/* - * Will a fault with a given page-fault error code (pfec) cause a permission - * fault with the given access (in ACC_* format)? - */ -static inline bool permission_fault(struct kvm_mmu *mmu, unsigned pte_access, - unsigned pfec) +static inline bool check_write_user_access(struct kvm_vcpu *vcpu, + bool write_fault, bool user_fault, + unsigned long pte) { - return (mmu->permissions[pfec >> 1] >> pte_access) & 1; -} + if (unlikely(write_fault && !is_writable_pte(pte) + && (user_fault || is_write_protection(vcpu)))) + return false; + + if (unlikely(user_fault && !(pte & PT_USER_MASK))) + return false; + return true; +} #endif diff --git a/trunk/arch/x86/kvm/mmu_audit.c b/trunk/arch/x86/kvm/mmu_audit.c index daff69e21150..7d7d0b9e23eb 100644 --- a/trunk/arch/x86/kvm/mmu_audit.c +++ b/trunk/arch/x86/kvm/mmu_audit.c @@ -116,8 +116,10 @@ static void audit_mappings(struct kvm_vcpu *vcpu, u64 *sptep, int level) gfn = kvm_mmu_page_get_gfn(sp, sptep - sp->spt); pfn = gfn_to_pfn_atomic(vcpu->kvm, gfn); - if (is_error_pfn(pfn)) + if (is_error_pfn(pfn)) { + kvm_release_pfn_clean(pfn); return; + } hpa = pfn << PAGE_SHIFT; if ((*sptep & PT64_BASE_ADDR_MASK) != hpa) @@ -188,6 +190,7 @@ static void check_mappings_rmap(struct kvm *kvm, struct kvm_mmu_page *sp) static void audit_write_protection(struct kvm *kvm, struct kvm_mmu_page *sp) { + struct kvm_memory_slot *slot; unsigned long *rmapp; u64 *sptep; struct rmap_iterator iter; @@ -195,7 +198,8 @@ static void audit_write_protection(struct kvm *kvm, struct kvm_mmu_page *sp) if (sp->role.direct || sp->unsync || sp->role.invalid) return; - rmapp = gfn_to_rmap(kvm, sp->gfn, PT_PAGE_TABLE_LEVEL); + slot = gfn_to_memslot(kvm, sp->gfn); + rmapp = &slot->rmap[sp->gfn - slot->base_gfn]; for (sptep = rmap_get_first(*rmapp, &iter); sptep; sptep = rmap_get_next(&iter)) { diff --git a/trunk/arch/x86/kvm/paging_tmpl.h b/trunk/arch/x86/kvm/paging_tmpl.h index 714e2c01a6fe..bb7cf01cae76 100644 --- a/trunk/arch/x86/kvm/paging_tmpl.h +++ b/trunk/arch/x86/kvm/paging_tmpl.h @@ -63,12 +63,10 @@ */ struct guest_walker { int level; - unsigned max_level; gfn_t table_gfn[PT_MAX_FULL_LEVELS]; pt_element_t ptes[PT_MAX_FULL_LEVELS]; pt_element_t prefetch_ptes[PTE_PREFETCH_NUM]; gpa_t pte_gpa[PT_MAX_FULL_LEVELS]; - pt_element_t __user *ptep_user[PT_MAX_FULL_LEVELS]; unsigned pt_access; unsigned pte_access; gfn_t gfn; @@ -103,41 +101,38 @@ static int FNAME(cmpxchg_gpte)(struct kvm_vcpu *vcpu, struct kvm_mmu *mmu, return (ret != orig_pte); } -static int FNAME(update_accessed_dirty_bits)(struct kvm_vcpu *vcpu, - struct kvm_mmu *mmu, - struct guest_walker *walker, - int write_fault) +static unsigned FNAME(gpte_access)(struct kvm_vcpu *vcpu, pt_element_t gpte, + bool last) { - unsigned level, index; - pt_element_t pte, orig_pte; - pt_element_t __user *ptep_user; - gfn_t table_gfn; - int ret; - - for (level = walker->max_level; level >= walker->level; --level) { - pte = orig_pte = walker->ptes[level - 1]; - table_gfn = walker->table_gfn[level - 1]; - ptep_user = walker->ptep_user[level - 1]; - index = offset_in_page(ptep_user) / sizeof(pt_element_t); - if (!(pte & PT_ACCESSED_MASK)) { - trace_kvm_mmu_set_accessed_bit(table_gfn, index, sizeof(pte)); - pte |= PT_ACCESSED_MASK; - } - if (level == walker->level && write_fault && !is_dirty_gpte(pte)) { - trace_kvm_mmu_set_dirty_bit(table_gfn, index, sizeof(pte)); - pte |= PT_DIRTY_MASK; - } - if (pte == orig_pte) - continue; + unsigned access; - ret = FNAME(cmpxchg_gpte)(vcpu, mmu, ptep_user, index, orig_pte, pte); - if (ret) - return ret; + access = (gpte & (PT_WRITABLE_MASK | PT_USER_MASK)) | ACC_EXEC_MASK; + if (last && !is_dirty_gpte(gpte)) + access &= ~ACC_WRITE_MASK; - mark_page_dirty(vcpu->kvm, table_gfn); - walker->ptes[level] = pte; - } - return 0; +#if PTTYPE == 64 + if (vcpu->arch.mmu.nx) + access &= ~(gpte >> PT64_NX_SHIFT); +#endif + return access; +} + +static bool FNAME(is_last_gpte)(struct guest_walker *walker, + struct kvm_vcpu *vcpu, struct kvm_mmu *mmu, + pt_element_t gpte) +{ + if (walker->level == PT_PAGE_TABLE_LEVEL) + return true; + + if ((walker->level == PT_DIRECTORY_LEVEL) && is_large_pte(gpte) && + (PTTYPE == 64 || is_pse(vcpu))) + return true; + + if ((walker->level == PT_PDPE_LEVEL) && is_large_pte(gpte) && + (mmu->root_level == PT64_ROOT_LEVEL)) + return true; + + return false; } /* @@ -147,22 +142,21 @@ static int FNAME(walk_addr_generic)(struct guest_walker *walker, struct kvm_vcpu *vcpu, struct kvm_mmu *mmu, gva_t addr, u32 access) { - int ret; pt_element_t pte; pt_element_t __user *uninitialized_var(ptep_user); gfn_t table_gfn; - unsigned index, pt_access, pte_access, accessed_dirty, shift; + unsigned index, pt_access, uninitialized_var(pte_access); gpa_t pte_gpa; + bool eperm, last_gpte; int offset; const int write_fault = access & PFERR_WRITE_MASK; const int user_fault = access & PFERR_USER_MASK; const int fetch_fault = access & PFERR_FETCH_MASK; u16 errcode = 0; - gpa_t real_gpa; - gfn_t gfn; trace_kvm_mmu_pagetable_walk(addr, access); retry_walk: + eperm = false; walker->level = mmu->root_level; pte = mmu->get_cr3(vcpu); @@ -175,21 +169,15 @@ static int FNAME(walk_addr_generic)(struct guest_walker *walker, --walker->level; } #endif - walker->max_level = walker->level; ASSERT((!is_long_mode(vcpu) && is_pae(vcpu)) || (mmu->get_cr3(vcpu) & CR3_NONPAE_RESERVED_BITS) == 0); - accessed_dirty = PT_ACCESSED_MASK; - pt_access = pte_access = ACC_ALL; - ++walker->level; + pt_access = ACC_ALL; - do { + for (;;) { gfn_t real_gfn; unsigned long host_addr; - pt_access &= pte_access; - --walker->level; - index = PT_INDEX(addr, walker->level); table_gfn = gpte_to_gfn(pte); @@ -211,7 +199,6 @@ static int FNAME(walk_addr_generic)(struct guest_walker *walker, ptep_user = (pt_element_t __user *)((void *)host_addr + offset); if (unlikely(__copy_from_user(&pte, ptep_user, sizeof(pte)))) goto error; - walker->ptep_user[walker->level - 1] = ptep_user; trace_kvm_mmu_paging_element(pte, walker->level); @@ -224,48 +211,92 @@ static int FNAME(walk_addr_generic)(struct guest_walker *walker, goto error; } - accessed_dirty &= pte; - pte_access = pt_access & gpte_access(vcpu, pte); + if (!check_write_user_access(vcpu, write_fault, user_fault, + pte)) + eperm = true; + +#if PTTYPE == 64 + if (unlikely(fetch_fault && (pte & PT64_NX_MASK))) + eperm = true; +#endif + + last_gpte = FNAME(is_last_gpte)(walker, vcpu, mmu, pte); + if (last_gpte) { + pte_access = pt_access & + FNAME(gpte_access)(vcpu, pte, true); + /* check if the kernel is fetching from user page */ + if (unlikely(pte_access & PT_USER_MASK) && + kvm_read_cr4_bits(vcpu, X86_CR4_SMEP)) + if (fetch_fault && !user_fault) + eperm = true; + } + + if (!eperm && unlikely(!(pte & PT_ACCESSED_MASK))) { + int ret; + trace_kvm_mmu_set_accessed_bit(table_gfn, index, + sizeof(pte)); + ret = FNAME(cmpxchg_gpte)(vcpu, mmu, ptep_user, index, + pte, pte|PT_ACCESSED_MASK); + if (unlikely(ret < 0)) + goto error; + else if (ret) + goto retry_walk; + + mark_page_dirty(vcpu->kvm, table_gfn); + pte |= PT_ACCESSED_MASK; + } walker->ptes[walker->level - 1] = pte; - } while (!is_last_gpte(mmu, walker->level, pte)); - if (unlikely(permission_fault(mmu, pte_access, access))) { - errcode |= PFERR_PRESENT_MASK; - goto error; - } + if (last_gpte) { + int lvl = walker->level; + gpa_t real_gpa; + gfn_t gfn; + u32 ac; - gfn = gpte_to_gfn_lvl(pte, walker->level); - gfn += (addr & PT_LVL_OFFSET_MASK(walker->level)) >> PAGE_SHIFT; + gfn = gpte_to_gfn_lvl(pte, lvl); + gfn += (addr & PT_LVL_OFFSET_MASK(lvl)) >> PAGE_SHIFT; - if (PTTYPE == 32 && walker->level == PT_DIRECTORY_LEVEL && is_cpuid_PSE36()) - gfn += pse36_gfn_delta(pte); + if (PTTYPE == 32 && + walker->level == PT_DIRECTORY_LEVEL && + is_cpuid_PSE36()) + gfn += pse36_gfn_delta(pte); - real_gpa = mmu->translate_gpa(vcpu, gfn_to_gpa(gfn), access); - if (real_gpa == UNMAPPED_GVA) - return 0; + ac = write_fault | fetch_fault | user_fault; - walker->gfn = real_gpa >> PAGE_SHIFT; + real_gpa = mmu->translate_gpa(vcpu, gfn_to_gpa(gfn), + ac); + if (real_gpa == UNMAPPED_GVA) + return 0; - if (!write_fault) - protect_clean_gpte(&pte_access, pte); + walker->gfn = real_gpa >> PAGE_SHIFT; - /* - * On a write fault, fold the dirty bit into accessed_dirty by shifting it one - * place right. - * - * On a read fault, do nothing. - */ - shift = write_fault >> ilog2(PFERR_WRITE_MASK); - shift *= PT_DIRTY_SHIFT - PT_ACCESSED_SHIFT; - accessed_dirty &= pte >> shift; + break; + } + + pt_access &= FNAME(gpte_access)(vcpu, pte, false); + --walker->level; + } + + if (unlikely(eperm)) { + errcode |= PFERR_PRESENT_MASK; + goto error; + } - if (unlikely(!accessed_dirty)) { - ret = FNAME(update_accessed_dirty_bits)(vcpu, mmu, walker, write_fault); + if (write_fault && unlikely(!is_dirty_gpte(pte))) { + int ret; + + trace_kvm_mmu_set_dirty_bit(table_gfn, index, sizeof(pte)); + ret = FNAME(cmpxchg_gpte)(vcpu, mmu, ptep_user, index, + pte, pte|PT_DIRTY_MASK); if (unlikely(ret < 0)) goto error; else if (ret) goto retry_walk; + + mark_page_dirty(vcpu->kvm, table_gfn); + pte |= PT_DIRTY_MASK; + walker->ptes[walker->level - 1] = pte; } walker->pt_access = pt_access; @@ -337,11 +368,12 @@ static void FNAME(update_pte)(struct kvm_vcpu *vcpu, struct kvm_mmu_page *sp, return; pgprintk("%s: gpte %llx spte %p\n", __func__, (u64)gpte, spte); - pte_access = sp->role.access & gpte_access(vcpu, gpte); - protect_clean_gpte(&pte_access, gpte); + pte_access = sp->role.access & FNAME(gpte_access)(vcpu, gpte, true); pfn = gfn_to_pfn_atomic(vcpu->kvm, gpte_to_gfn(gpte)); - if (mmu_invalid_pfn(pfn)) + if (mmu_invalid_pfn(pfn)) { + kvm_release_pfn_clean(pfn); return; + } /* * we call mmu_set_spte() with host_writable = true because that @@ -411,13 +443,15 @@ static void FNAME(pte_prefetch)(struct kvm_vcpu *vcpu, struct guest_walker *gw, if (FNAME(prefetch_invalid_gpte)(vcpu, sp, spte, gpte)) continue; - pte_access = sp->role.access & gpte_access(vcpu, gpte); - protect_clean_gpte(&pte_access, gpte); + pte_access = sp->role.access & FNAME(gpte_access)(vcpu, gpte, + true); gfn = gpte_to_gfn(gpte); pfn = pte_prefetch_gfn_to_pfn(vcpu, gfn, pte_access & ACC_WRITE_MASK); - if (mmu_invalid_pfn(pfn)) + if (mmu_invalid_pfn(pfn)) { + kvm_release_pfn_clean(pfn); break; + } mmu_set_spte(vcpu, spte, sp->role.access, pte_access, 0, 0, NULL, PT_PAGE_TABLE_LEVEL, gfn, @@ -764,8 +798,7 @@ static int FNAME(sync_page)(struct kvm_vcpu *vcpu, struct kvm_mmu_page *sp) gfn = gpte_to_gfn(gpte); pte_access = sp->role.access; - pte_access &= gpte_access(vcpu, gpte); - protect_clean_gpte(&pte_access, gpte); + pte_access &= FNAME(gpte_access)(vcpu, gpte, true); if (sync_mmio_spte(&sp->spt[i], gfn, pte_access, &nr_present)) continue; diff --git a/trunk/arch/x86/kvm/pmu.c b/trunk/arch/x86/kvm/pmu.c index cfc258a6bf97..9b7ec1150ab0 100644 --- a/trunk/arch/x86/kvm/pmu.c +++ b/trunk/arch/x86/kvm/pmu.c @@ -1,5 +1,5 @@ /* - * Kernel-based Virtual Machine -- Performance Monitoring Unit support + * Kernel-based Virtual Machine -- Performane Monitoring Unit support * * Copyright 2011 Red Hat, Inc. and/or its affiliates. * diff --git a/trunk/arch/x86/kvm/svm.c b/trunk/arch/x86/kvm/svm.c index d017df3899ef..baead950d6c8 100644 --- a/trunk/arch/x86/kvm/svm.c +++ b/trunk/arch/x86/kvm/svm.c @@ -163,7 +163,7 @@ static DEFINE_PER_CPU(u64, current_tsc_ratio); #define MSR_INVALID 0xffffffffU -static const struct svm_direct_access_msrs { +static struct svm_direct_access_msrs { u32 index; /* Index of the MSR */ bool always; /* True if intercept is always on */ } direct_access_msrs[] = { @@ -400,7 +400,7 @@ struct svm_init_data { int r; }; -static const u32 msrpm_ranges[] = {0, 0xc0000000, 0xc0010000}; +static u32 msrpm_ranges[] = {0, 0xc0000000, 0xc0010000}; #define NUM_MSR_MAPS ARRAY_SIZE(msrpm_ranges) #define MSRS_RANGE_SIZE 2048 @@ -1146,6 +1146,7 @@ static void init_vmcb(struct vcpu_svm *svm) svm_set_efer(&svm->vcpu, 0); save->dr6 = 0xffff0ff0; + save->dr7 = 0x400; kvm_set_rflags(&svm->vcpu, 2); save->rip = 0x0000fff0; svm->vcpu.arch.regs[VCPU_REGS_RIP] = save->rip; @@ -1642,7 +1643,7 @@ static void svm_set_segment(struct kvm_vcpu *vcpu, mark_dirty(svm->vmcb, VMCB_SEG); } -static void update_db_bp_intercept(struct kvm_vcpu *vcpu) +static void update_db_intercept(struct kvm_vcpu *vcpu) { struct vcpu_svm *svm = to_svm(vcpu); @@ -1662,6 +1663,20 @@ static void update_db_bp_intercept(struct kvm_vcpu *vcpu) vcpu->guest_debug = 0; } +static void svm_guest_debug(struct kvm_vcpu *vcpu, struct kvm_guest_debug *dbg) +{ + struct vcpu_svm *svm = to_svm(vcpu); + + if (vcpu->guest_debug & KVM_GUESTDBG_USE_HW_BP) + svm->vmcb->save.dr7 = dbg->arch.debugreg[7]; + else + svm->vmcb->save.dr7 = vcpu->arch.dr7; + + mark_dirty(svm->vmcb, VMCB_DR); + + update_db_intercept(vcpu); +} + static void new_asid(struct vcpu_svm *svm, struct svm_cpu_data *sd) { if (sd->next_asid > sd->max_asid) { @@ -1733,7 +1748,7 @@ static int db_interception(struct vcpu_svm *svm) if (!(svm->vcpu.guest_debug & KVM_GUESTDBG_SINGLESTEP)) svm->vmcb->save.rflags &= ~(X86_EFLAGS_TF | X86_EFLAGS_RF); - update_db_bp_intercept(&svm->vcpu); + update_db_intercept(&svm->vcpu); } if (svm->vcpu.guest_debug & @@ -2048,7 +2063,7 @@ static inline bool nested_svm_intr(struct vcpu_svm *svm) if (svm->nested.intercept & 1ULL) { /* * The #vmexit can't be emulated here directly because this - * code path runs with irqs and preemption disabled. A + * code path runs with irqs and preemtion disabled. A * #vmexit emulation might sleep. Only signal request for * the #vmexit here. */ @@ -2090,6 +2105,7 @@ static void *nested_svm_map(struct vcpu_svm *svm, u64 gpa, struct page **_page) return kmap(page); error: + kvm_release_page_clean(page); kvm_inject_gp(&svm->vcpu, 0); return NULL; @@ -2393,7 +2409,7 @@ static bool nested_svm_vmrun_msrpm(struct vcpu_svm *svm) { /* * This function merges the msr permission bitmaps of kvm and the - * nested vmcb. It is optimized in that it only merges the parts where + * nested vmcb. It is omptimized in that it only merges the parts where * the kvm msr permission bitmap may contain zero bits */ int i; @@ -3252,7 +3268,7 @@ static int pause_interception(struct vcpu_svm *svm) return 1; } -static int (*const svm_exit_handlers[])(struct vcpu_svm *svm) = { +static int (*svm_exit_handlers[])(struct vcpu_svm *svm) = { [SVM_EXIT_READ_CR0] = cr_interception, [SVM_EXIT_READ_CR3] = cr_interception, [SVM_EXIT_READ_CR4] = cr_interception, @@ -3644,7 +3660,7 @@ static void enable_nmi_window(struct kvm_vcpu *vcpu) */ svm->nmi_singlestep = true; svm->vmcb->save.rflags |= (X86_EFLAGS_TF | X86_EFLAGS_RF); - update_db_bp_intercept(vcpu); + update_db_intercept(vcpu); } static int svm_set_tss_addr(struct kvm *kvm, unsigned int addr) @@ -3767,6 +3783,12 @@ static void svm_cancel_injection(struct kvm_vcpu *vcpu) svm_complete_interrupts(svm); } +#ifdef CONFIG_X86_64 +#define R "r" +#else +#define R "e" +#endif + static void svm_vcpu_run(struct kvm_vcpu *vcpu) { struct vcpu_svm *svm = to_svm(vcpu); @@ -3793,13 +3815,13 @@ static void svm_vcpu_run(struct kvm_vcpu *vcpu) local_irq_enable(); asm volatile ( - "push %%" _ASM_BP "; \n\t" - "mov %c[rbx](%[svm]), %%" _ASM_BX " \n\t" - "mov %c[rcx](%[svm]), %%" _ASM_CX " \n\t" - "mov %c[rdx](%[svm]), %%" _ASM_DX " \n\t" - "mov %c[rsi](%[svm]), %%" _ASM_SI " \n\t" - "mov %c[rdi](%[svm]), %%" _ASM_DI " \n\t" - "mov %c[rbp](%[svm]), %%" _ASM_BP " \n\t" + "push %%"R"bp; \n\t" + "mov %c[rbx](%[svm]), %%"R"bx \n\t" + "mov %c[rcx](%[svm]), %%"R"cx \n\t" + "mov %c[rdx](%[svm]), %%"R"dx \n\t" + "mov %c[rsi](%[svm]), %%"R"si \n\t" + "mov %c[rdi](%[svm]), %%"R"di \n\t" + "mov %c[rbp](%[svm]), %%"R"bp \n\t" #ifdef CONFIG_X86_64 "mov %c[r8](%[svm]), %%r8 \n\t" "mov %c[r9](%[svm]), %%r9 \n\t" @@ -3812,20 +3834,20 @@ static void svm_vcpu_run(struct kvm_vcpu *vcpu) #endif /* Enter guest mode */ - "push %%" _ASM_AX " \n\t" - "mov %c[vmcb](%[svm]), %%" _ASM_AX " \n\t" + "push %%"R"ax \n\t" + "mov %c[vmcb](%[svm]), %%"R"ax \n\t" __ex(SVM_VMLOAD) "\n\t" __ex(SVM_VMRUN) "\n\t" __ex(SVM_VMSAVE) "\n\t" - "pop %%" _ASM_AX " \n\t" + "pop %%"R"ax \n\t" /* Save guest registers, load host registers */ - "mov %%" _ASM_BX ", %c[rbx](%[svm]) \n\t" - "mov %%" _ASM_CX ", %c[rcx](%[svm]) \n\t" - "mov %%" _ASM_DX ", %c[rdx](%[svm]) \n\t" - "mov %%" _ASM_SI ", %c[rsi](%[svm]) \n\t" - "mov %%" _ASM_DI ", %c[rdi](%[svm]) \n\t" - "mov %%" _ASM_BP ", %c[rbp](%[svm]) \n\t" + "mov %%"R"bx, %c[rbx](%[svm]) \n\t" + "mov %%"R"cx, %c[rcx](%[svm]) \n\t" + "mov %%"R"dx, %c[rdx](%[svm]) \n\t" + "mov %%"R"si, %c[rsi](%[svm]) \n\t" + "mov %%"R"di, %c[rdi](%[svm]) \n\t" + "mov %%"R"bp, %c[rbp](%[svm]) \n\t" #ifdef CONFIG_X86_64 "mov %%r8, %c[r8](%[svm]) \n\t" "mov %%r9, %c[r9](%[svm]) \n\t" @@ -3836,7 +3858,7 @@ static void svm_vcpu_run(struct kvm_vcpu *vcpu) "mov %%r14, %c[r14](%[svm]) \n\t" "mov %%r15, %c[r15](%[svm]) \n\t" #endif - "pop %%" _ASM_BP + "pop %%"R"bp" : : [svm]"a"(svm), [vmcb]"i"(offsetof(struct vcpu_svm, vmcb_pa)), @@ -3857,11 +3879,9 @@ static void svm_vcpu_run(struct kvm_vcpu *vcpu) [r15]"i"(offsetof(struct vcpu_svm, vcpu.arch.regs[VCPU_REGS_R15])) #endif : "cc", "memory" + , R"bx", R"cx", R"dx", R"si", R"di" #ifdef CONFIG_X86_64 - , "rbx", "rcx", "rdx", "rsi", "rdi" , "r8", "r9", "r10", "r11" , "r12", "r13", "r14", "r15" -#else - , "ebx", "ecx", "edx", "esi", "edi" #endif ); @@ -3921,6 +3941,8 @@ static void svm_vcpu_run(struct kvm_vcpu *vcpu) mark_all_clean(svm->vmcb); } +#undef R + static void svm_set_cr3(struct kvm_vcpu *vcpu, unsigned long root) { struct vcpu_svm *svm = to_svm(vcpu); @@ -4047,7 +4069,7 @@ static void svm_fpu_deactivate(struct kvm_vcpu *vcpu) #define POST_MEM(exit) { .exit_code = (exit), \ .stage = X86_ICPT_POST_MEMACCESS, } -static const struct __x86_intercept { +static struct __x86_intercept { u32 exit_code; enum x86_intercept_stage stage; } x86_intercept_map[] = { @@ -4238,7 +4260,7 @@ static struct kvm_x86_ops svm_x86_ops = { .vcpu_load = svm_vcpu_load, .vcpu_put = svm_vcpu_put, - .update_db_bp_intercept = update_db_bp_intercept, + .set_guest_debug = svm_guest_debug, .get_msr = svm_get_msr, .set_msr = svm_set_msr, .get_segment_base = svm_get_segment_base, diff --git a/trunk/arch/x86/kvm/timer.c b/trunk/arch/x86/kvm/timer.c new file mode 100644 index 000000000000..6b85cc647f34 --- /dev/null +++ b/trunk/arch/x86/kvm/timer.c @@ -0,0 +1,47 @@ +/* + * Kernel-based Virtual Machine driver for Linux + * + * This module enables machines with Intel VT-x extensions to run virtual + * machines without emulation or binary translation. + * + * timer support + * + * Copyright 2010 Red Hat, Inc. and/or its affiliates. + * + * This work is licensed under the terms of the GNU GPL, version 2. See + * the COPYING file in the top-level directory. + */ + +#include +#include +#include +#include +#include "kvm_timer.h" + +enum hrtimer_restart kvm_timer_fn(struct hrtimer *data) +{ + struct kvm_timer *ktimer = container_of(data, struct kvm_timer, timer); + struct kvm_vcpu *vcpu = ktimer->vcpu; + wait_queue_head_t *q = &vcpu->wq; + + /* + * There is a race window between reading and incrementing, but we do + * not care about potentially losing timer events in the !reinject + * case anyway. Note: KVM_REQ_PENDING_TIMER is implicitly checked + * in vcpu_enter_guest. + */ + if (ktimer->reinject || !atomic_read(&ktimer->pending)) { + atomic_inc(&ktimer->pending); + /* FIXME: this code should not know anything about vcpus */ + kvm_make_request(KVM_REQ_PENDING_TIMER, vcpu); + } + + if (waitqueue_active(q)) + wake_up_interruptible(q); + + if (ktimer->t_ops->is_periodic(ktimer)) { + hrtimer_add_expires_ns(&ktimer->timer, ktimer->period); + return HRTIMER_RESTART; + } else + return HRTIMER_NORESTART; +} diff --git a/trunk/arch/x86/kvm/vmx.c b/trunk/arch/x86/kvm/vmx.c index ad6b1dd06f8b..851aa7c3b890 100644 --- a/trunk/arch/x86/kvm/vmx.c +++ b/trunk/arch/x86/kvm/vmx.c @@ -127,8 +127,6 @@ module_param(ple_gap, int, S_IRUGO); static int ple_window = KVM_VMX_DEFAULT_PLE_WINDOW; module_param(ple_window, int, S_IRUGO); -extern const ulong vmx_return; - #define NR_AUTOLOAD_MSRS 8 #define VMCS02_POOL_SIZE 1 @@ -407,16 +405,16 @@ struct vcpu_vmx { struct { int vm86_active; ulong save_rflags; - struct kvm_segment segs[8]; - } rmode; - struct { - u32 bitmask; /* 4 bits per segment (1 bit per field) */ struct kvm_save_segment { u16 selector; unsigned long base; u32 limit; u32 ar; - } seg[8]; + } tr, es, ds, fs, gs; + } rmode; + struct { + u32 bitmask; /* 4 bits per segment (1 bit per field) */ + struct kvm_save_segment seg[8]; } segment_cache; int vpid; bool emulation_required; @@ -452,7 +450,7 @@ static inline struct vcpu_vmx *to_vmx(struct kvm_vcpu *vcpu) #define FIELD64(number, name) [number] = VMCS12_OFFSET(name), \ [number##_HIGH] = VMCS12_OFFSET(name)+4 -static const unsigned short vmcs_field_to_offset_table[] = { +static unsigned short vmcs_field_to_offset_table[] = { FIELD(VIRTUAL_PROCESSOR_ID, virtual_processor_id), FIELD(GUEST_ES_SELECTOR, guest_es_selector), FIELD(GUEST_CS_SELECTOR, guest_cs_selector), @@ -598,9 +596,10 @@ static inline struct vmcs12 *get_vmcs12(struct kvm_vcpu *vcpu) static struct page *nested_get_page(struct kvm_vcpu *vcpu, gpa_t addr) { struct page *page = gfn_to_page(vcpu->kvm, addr >> PAGE_SHIFT); - if (is_error_page(page)) + if (is_error_page(page)) { + kvm_release_page_clean(page); return NULL; - + } return page; } @@ -668,7 +667,7 @@ static struct vmx_capability { .ar_bytes = GUEST_##seg##_AR_BYTES, \ } -static const struct kvm_vmx_segment_field { +static struct kvm_vmx_segment_field { unsigned selector; unsigned base; unsigned limit; @@ -1344,7 +1343,7 @@ static bool update_transition_efer(struct vcpu_vmx *vmx, int efer_offset) guest_efer = vmx->vcpu.arch.efer; /* - * NX is emulated; LMA and LME handled by hardware; SCE meaningless + * NX is emulated; LMA and LME handled by hardware; SCE meaninless * outside long mode */ ignore_bits = EFER_NX | EFER_SCE; @@ -1996,7 +1995,7 @@ static __init void nested_vmx_setup_ctls_msrs(void) #endif CPU_BASED_MOV_DR_EXITING | CPU_BASED_UNCOND_IO_EXITING | CPU_BASED_USE_IO_BITMAPS | CPU_BASED_MONITOR_EXITING | - CPU_BASED_RDPMC_EXITING | CPU_BASED_RDTSC_EXITING | + CPU_BASED_RDPMC_EXITING | CPU_BASED_ACTIVATE_SECONDARY_CONTROLS; /* * We can allow some features even when not supported by the @@ -2292,6 +2291,16 @@ static void vmx_cache_reg(struct kvm_vcpu *vcpu, enum kvm_reg reg) } } +static void set_guest_debug(struct kvm_vcpu *vcpu, struct kvm_guest_debug *dbg) +{ + if (vcpu->guest_debug & KVM_GUESTDBG_USE_HW_BP) + vmcs_writel(GUEST_DR7, dbg->arch.debugreg[7]); + else + vmcs_writel(GUEST_DR7, vcpu->arch.dr7); + + update_exception_bitmap(vcpu); +} + static __init int cpu_has_kvm_support(void) { return cpu_has_vmx(); @@ -2689,17 +2698,20 @@ static __exit void hardware_unsetup(void) free_kvm_area(); } -static void fix_pmode_dataseg(struct kvm_vcpu *vcpu, int seg, struct kvm_segment *save) +static void fix_pmode_dataseg(int seg, struct kvm_save_segment *save) { - const struct kvm_vmx_segment_field *sf = &kvm_vmx_segment_fields[seg]; - struct kvm_segment tmp = *save; + struct kvm_vmx_segment_field *sf = &kvm_vmx_segment_fields[seg]; - if (!(vmcs_readl(sf->base) == tmp.base && tmp.s)) { - tmp.base = vmcs_readl(sf->base); - tmp.selector = vmcs_read16(sf->selector); - tmp.s = 1; + if (vmcs_readl(sf->base) == save->base && (save->base & AR_S_MASK)) { + vmcs_write16(sf->selector, save->selector); + vmcs_writel(sf->base, save->base); + vmcs_write32(sf->limit, save->limit); + vmcs_write32(sf->ar_bytes, save->ar); + } else { + u32 dpl = (vmcs_read16(sf->selector) & SELECTOR_RPL_MASK) + << AR_DPL_SHIFT; + vmcs_write32(sf->ar_bytes, 0x93 | dpl); } - vmx_set_segment(vcpu, &tmp, seg); } static void enter_pmode(struct kvm_vcpu *vcpu) @@ -2712,7 +2724,10 @@ static void enter_pmode(struct kvm_vcpu *vcpu) vmx_segment_cache_clear(vmx); - vmx_set_segment(vcpu, &vmx->rmode.segs[VCPU_SREG_TR], VCPU_SREG_TR); + vmcs_write16(GUEST_TR_SELECTOR, vmx->rmode.tr.selector); + vmcs_writel(GUEST_TR_BASE, vmx->rmode.tr.base); + vmcs_write32(GUEST_TR_LIMIT, vmx->rmode.tr.limit); + vmcs_write32(GUEST_TR_AR_BYTES, vmx->rmode.tr.ar); flags = vmcs_readl(GUEST_RFLAGS); flags &= RMODE_GUEST_OWNED_EFLAGS_BITS; @@ -2727,10 +2742,10 @@ static void enter_pmode(struct kvm_vcpu *vcpu) if (emulate_invalid_guest_state) return; - fix_pmode_dataseg(vcpu, VCPU_SREG_ES, &vmx->rmode.segs[VCPU_SREG_ES]); - fix_pmode_dataseg(vcpu, VCPU_SREG_DS, &vmx->rmode.segs[VCPU_SREG_DS]); - fix_pmode_dataseg(vcpu, VCPU_SREG_FS, &vmx->rmode.segs[VCPU_SREG_FS]); - fix_pmode_dataseg(vcpu, VCPU_SREG_GS, &vmx->rmode.segs[VCPU_SREG_GS]); + fix_pmode_dataseg(VCPU_SREG_ES, &vmx->rmode.es); + fix_pmode_dataseg(VCPU_SREG_DS, &vmx->rmode.ds); + fix_pmode_dataseg(VCPU_SREG_GS, &vmx->rmode.gs); + fix_pmode_dataseg(VCPU_SREG_FS, &vmx->rmode.fs); vmx_segment_cache_clear(vmx); @@ -2758,10 +2773,14 @@ static gva_t rmode_tss_base(struct kvm *kvm) return kvm->arch.tss_addr; } -static void fix_rmode_seg(int seg, struct kvm_segment *save) +static void fix_rmode_seg(int seg, struct kvm_save_segment *save) { - const struct kvm_vmx_segment_field *sf = &kvm_vmx_segment_fields[seg]; + struct kvm_vmx_segment_field *sf = &kvm_vmx_segment_fields[seg]; + save->selector = vmcs_read16(sf->selector); + save->base = vmcs_readl(sf->base); + save->limit = vmcs_read32(sf->limit); + save->ar = vmcs_read32(sf->ar_bytes); vmcs_write16(sf->selector, save->base >> 4); vmcs_write32(sf->base, save->base & 0xffff0); vmcs_write32(sf->limit, 0xffff); @@ -2781,16 +2800,9 @@ static void enter_rmode(struct kvm_vcpu *vcpu) if (enable_unrestricted_guest) return; - vmx_get_segment(vcpu, &vmx->rmode.segs[VCPU_SREG_TR], VCPU_SREG_TR); - vmx_get_segment(vcpu, &vmx->rmode.segs[VCPU_SREG_ES], VCPU_SREG_ES); - vmx_get_segment(vcpu, &vmx->rmode.segs[VCPU_SREG_DS], VCPU_SREG_DS); - vmx_get_segment(vcpu, &vmx->rmode.segs[VCPU_SREG_FS], VCPU_SREG_FS); - vmx_get_segment(vcpu, &vmx->rmode.segs[VCPU_SREG_GS], VCPU_SREG_GS); - vmx->emulation_required = 1; vmx->rmode.vm86_active = 1; - /* * Very old userspace does not call KVM_SET_TSS_ADDR before entering * vcpu. Call it here with phys address pointing 16M below 4G. @@ -2805,8 +2817,14 @@ static void enter_rmode(struct kvm_vcpu *vcpu) vmx_segment_cache_clear(vmx); + vmx->rmode.tr.selector = vmcs_read16(GUEST_TR_SELECTOR); + vmx->rmode.tr.base = vmcs_readl(GUEST_TR_BASE); vmcs_writel(GUEST_TR_BASE, rmode_tss_base(vcpu->kvm)); + + vmx->rmode.tr.limit = vmcs_read32(GUEST_TR_LIMIT); vmcs_write32(GUEST_TR_LIMIT, RMODE_TSS_SIZE - 1); + + vmx->rmode.tr.ar = vmcs_read32(GUEST_TR_AR_BYTES); vmcs_write32(GUEST_TR_AR_BYTES, 0x008b); flags = vmcs_readl(GUEST_RFLAGS); @@ -3099,24 +3117,35 @@ static void vmx_get_segment(struct kvm_vcpu *vcpu, struct kvm_segment *var, int seg) { struct vcpu_vmx *vmx = to_vmx(vcpu); + struct kvm_save_segment *save; u32 ar; if (vmx->rmode.vm86_active && (seg == VCPU_SREG_TR || seg == VCPU_SREG_ES || seg == VCPU_SREG_DS || seg == VCPU_SREG_FS - || seg == VCPU_SREG_GS)) { - *var = vmx->rmode.segs[seg]; + || seg == VCPU_SREG_GS) + && !emulate_invalid_guest_state) { + switch (seg) { + case VCPU_SREG_TR: save = &vmx->rmode.tr; break; + case VCPU_SREG_ES: save = &vmx->rmode.es; break; + case VCPU_SREG_DS: save = &vmx->rmode.ds; break; + case VCPU_SREG_FS: save = &vmx->rmode.fs; break; + case VCPU_SREG_GS: save = &vmx->rmode.gs; break; + default: BUG(); + } + var->selector = save->selector; + var->base = save->base; + var->limit = save->limit; + ar = save->ar; if (seg == VCPU_SREG_TR || var->selector == vmx_read_guest_seg_selector(vmx, seg)) - return; - var->base = vmx_read_guest_seg_base(vmx, seg); - var->selector = vmx_read_guest_seg_selector(vmx, seg); - return; + goto use_saved_rmode_seg; } var->base = vmx_read_guest_seg_base(vmx, seg); var->limit = vmx_read_guest_seg_limit(vmx, seg); var->selector = vmx_read_guest_seg_selector(vmx, seg); ar = vmx_read_guest_seg_ar(vmx, seg); +use_saved_rmode_seg: if ((ar & AR_UNUSABLE_MASK) && !emulate_invalid_guest_state) ar = 0; var->type = ar & 15; @@ -3198,21 +3227,23 @@ static void vmx_set_segment(struct kvm_vcpu *vcpu, struct kvm_segment *var, int seg) { struct vcpu_vmx *vmx = to_vmx(vcpu); - const struct kvm_vmx_segment_field *sf = &kvm_vmx_segment_fields[seg]; + struct kvm_vmx_segment_field *sf = &kvm_vmx_segment_fields[seg]; u32 ar; vmx_segment_cache_clear(vmx); if (vmx->rmode.vm86_active && seg == VCPU_SREG_TR) { vmcs_write16(sf->selector, var->selector); - vmx->rmode.segs[VCPU_SREG_TR] = *var; + vmx->rmode.tr.selector = var->selector; + vmx->rmode.tr.base = var->base; + vmx->rmode.tr.limit = var->limit; + vmx->rmode.tr.ar = vmx_segment_access_rights(var); return; } vmcs_writel(sf->base, var->base); vmcs_write32(sf->limit, var->limit); vmcs_write16(sf->selector, var->selector); if (vmx->rmode.vm86_active && var->s) { - vmx->rmode.segs[seg] = *var; /* * Hack real-mode segments into vm86 compatibility. */ @@ -3227,7 +3258,7 @@ static void vmx_set_segment(struct kvm_vcpu *vcpu, * qemu binaries. * IA32 arch specifies that at the time of processor reset the * "Accessed" bit in the AR field of segment registers is 1. And qemu - * is setting it to 0 in the userland code. This causes invalid guest + * is setting it to 0 in the usedland code. This causes invalid guest * state vmexit when "unrestricted guest" mode is turned on. * Fix for this setup issue in cpu_reset is being pushed in the qemu * tree. Newer qemu binaries with that qemu fix would not need this @@ -3257,10 +3288,16 @@ static void vmx_set_segment(struct kvm_vcpu *vcpu, vmcs_readl(GUEST_CS_BASE) >> 4); break; case VCPU_SREG_ES: + fix_rmode_seg(VCPU_SREG_ES, &vmx->rmode.es); + break; case VCPU_SREG_DS: + fix_rmode_seg(VCPU_SREG_DS, &vmx->rmode.ds); + break; case VCPU_SREG_GS: + fix_rmode_seg(VCPU_SREG_GS, &vmx->rmode.gs); + break; case VCPU_SREG_FS: - fix_rmode_seg(seg, &vmx->rmode.segs[seg]); + fix_rmode_seg(VCPU_SREG_FS, &vmx->rmode.fs); break; case VCPU_SREG_SS: vmcs_write16(GUEST_SS_SELECTOR, @@ -3314,9 +3351,9 @@ static bool rmode_segment_valid(struct kvm_vcpu *vcpu, int seg) if (var.base != (var.selector << 4)) return false; - if (var.limit < 0xffff) + if (var.limit != 0xffff) return false; - if (((ar | (3 << AR_DPL_SHIFT)) & ~(AR_G_MASK | AR_DB_MASK)) != 0xf3) + if (ar != 0xf3) return false; return true; @@ -3568,7 +3605,7 @@ static int init_rmode_identity_map(struct kvm *kvm) static void seg_setup(int seg) { - const struct kvm_vmx_segment_field *sf = &kvm_vmx_segment_fields[seg]; + struct kvm_vmx_segment_field *sf = &kvm_vmx_segment_fields[seg]; unsigned int ar; vmcs_write16(sf->selector, 0); @@ -3733,7 +3770,8 @@ static void vmx_set_constant_host_state(void) native_store_idt(&dt); vmcs_writel(HOST_IDTR_BASE, dt.address); /* 22.2.4 */ - vmcs_writel(HOST_RIP, vmx_return); /* 22.2.5 */ + asm("mov $.Lkvm_vmx_return, %0" : "=r"(tmpl)); + vmcs_writel(HOST_RIP, tmpl); /* 22.2.5 */ rdmsr(MSR_IA32_SYSENTER_CS, low32, high32); vmcs_write32(HOST_IA32_SYSENTER_CS, low32); @@ -3967,6 +4005,8 @@ static int vmx_vcpu_reset(struct kvm_vcpu *vcpu) kvm_rip_write(vcpu, 0); kvm_register_write(vcpu, VCPU_REGS_RSP, 0); + vmcs_writel(GUEST_DR7, 0x400); + vmcs_writel(GUEST_GDTR_BASE, 0); vmcs_write32(GUEST_GDTR_LIMIT, 0xffff); @@ -4416,7 +4456,7 @@ vmx_patch_hypercall(struct kvm_vcpu *vcpu, unsigned char *hypercall) hypercall[2] = 0xc1; } -/* called to set cr0 as appropriate for a mov-to-cr0 exit. */ +/* called to set cr0 as approriate for a mov-to-cr0 exit. */ static int handle_set_cr0(struct kvm_vcpu *vcpu, unsigned long val) { if (to_vmx(vcpu)->nested.vmxon && @@ -5661,7 +5701,7 @@ static int handle_vmptrst(struct kvm_vcpu *vcpu) * may resume. Otherwise they set the kvm_run parameter to indicate what needs * to be done to userspace and return 0. */ -static int (*const kvm_vmx_exit_handlers[])(struct kvm_vcpu *vcpu) = { +static int (*kvm_vmx_exit_handlers[])(struct kvm_vcpu *vcpu) = { [EXIT_REASON_EXCEPTION_NMI] = handle_exception, [EXIT_REASON_EXTERNAL_INTERRUPT] = handle_external_interrupt, [EXIT_REASON_TRIPLE_FAULT] = handle_triple_fault, @@ -6189,10 +6229,17 @@ static void atomic_switch_perf_msrs(struct vcpu_vmx *vmx) msrs[i].host); } +#ifdef CONFIG_X86_64 +#define R "r" +#define Q "q" +#else +#define R "e" +#define Q "l" +#endif + static void __noclone vmx_vcpu_run(struct kvm_vcpu *vcpu) { struct vcpu_vmx *vmx = to_vmx(vcpu); - unsigned long debugctlmsr; if (is_guest_mode(vcpu) && !vmx->nested.nested_run_pending) { struct vmcs12 *vmcs12 = get_vmcs12(vcpu); @@ -6232,35 +6279,34 @@ static void __noclone vmx_vcpu_run(struct kvm_vcpu *vcpu) vmx_set_interrupt_shadow(vcpu, 0); atomic_switch_perf_msrs(vmx); - debugctlmsr = get_debugctlmsr(); vmx->__launched = vmx->loaded_vmcs->launched; asm( /* Store host registers */ - "push %%" _ASM_DX "; push %%" _ASM_BP ";" - "push %%" _ASM_CX " \n\t" /* placeholder for guest rcx */ - "push %%" _ASM_CX " \n\t" - "cmp %%" _ASM_SP ", %c[host_rsp](%0) \n\t" + "push %%"R"dx; push %%"R"bp;" + "push %%"R"cx \n\t" /* placeholder for guest rcx */ + "push %%"R"cx \n\t" + "cmp %%"R"sp, %c[host_rsp](%0) \n\t" "je 1f \n\t" - "mov %%" _ASM_SP ", %c[host_rsp](%0) \n\t" + "mov %%"R"sp, %c[host_rsp](%0) \n\t" __ex(ASM_VMX_VMWRITE_RSP_RDX) "\n\t" "1: \n\t" /* Reload cr2 if changed */ - "mov %c[cr2](%0), %%" _ASM_AX " \n\t" - "mov %%cr2, %%" _ASM_DX " \n\t" - "cmp %%" _ASM_AX ", %%" _ASM_DX " \n\t" + "mov %c[cr2](%0), %%"R"ax \n\t" + "mov %%cr2, %%"R"dx \n\t" + "cmp %%"R"ax, %%"R"dx \n\t" "je 2f \n\t" - "mov %%" _ASM_AX", %%cr2 \n\t" + "mov %%"R"ax, %%cr2 \n\t" "2: \n\t" /* Check if vmlaunch of vmresume is needed */ "cmpl $0, %c[launched](%0) \n\t" /* Load guest registers. Don't clobber flags. */ - "mov %c[rax](%0), %%" _ASM_AX " \n\t" - "mov %c[rbx](%0), %%" _ASM_BX " \n\t" - "mov %c[rdx](%0), %%" _ASM_DX " \n\t" - "mov %c[rsi](%0), %%" _ASM_SI " \n\t" - "mov %c[rdi](%0), %%" _ASM_DI " \n\t" - "mov %c[rbp](%0), %%" _ASM_BP " \n\t" + "mov %c[rax](%0), %%"R"ax \n\t" + "mov %c[rbx](%0), %%"R"bx \n\t" + "mov %c[rdx](%0), %%"R"dx \n\t" + "mov %c[rsi](%0), %%"R"si \n\t" + "mov %c[rdi](%0), %%"R"di \n\t" + "mov %c[rbp](%0), %%"R"bp \n\t" #ifdef CONFIG_X86_64 "mov %c[r8](%0), %%r8 \n\t" "mov %c[r9](%0), %%r9 \n\t" @@ -6271,24 +6317,24 @@ static void __noclone vmx_vcpu_run(struct kvm_vcpu *vcpu) "mov %c[r14](%0), %%r14 \n\t" "mov %c[r15](%0), %%r15 \n\t" #endif - "mov %c[rcx](%0), %%" _ASM_CX " \n\t" /* kills %0 (ecx) */ + "mov %c[rcx](%0), %%"R"cx \n\t" /* kills %0 (ecx) */ /* Enter guest mode */ - "jne 1f \n\t" + "jne .Llaunched \n\t" __ex(ASM_VMX_VMLAUNCH) "\n\t" - "jmp 2f \n\t" - "1: " __ex(ASM_VMX_VMRESUME) "\n\t" - "2: " + "jmp .Lkvm_vmx_return \n\t" + ".Llaunched: " __ex(ASM_VMX_VMRESUME) "\n\t" + ".Lkvm_vmx_return: " /* Save guest registers, load host registers, keep flags */ - "mov %0, %c[wordsize](%%" _ASM_SP ") \n\t" + "mov %0, %c[wordsize](%%"R"sp) \n\t" "pop %0 \n\t" - "mov %%" _ASM_AX ", %c[rax](%0) \n\t" - "mov %%" _ASM_BX ", %c[rbx](%0) \n\t" - __ASM_SIZE(pop) " %c[rcx](%0) \n\t" - "mov %%" _ASM_DX ", %c[rdx](%0) \n\t" - "mov %%" _ASM_SI ", %c[rsi](%0) \n\t" - "mov %%" _ASM_DI ", %c[rdi](%0) \n\t" - "mov %%" _ASM_BP ", %c[rbp](%0) \n\t" + "mov %%"R"ax, %c[rax](%0) \n\t" + "mov %%"R"bx, %c[rbx](%0) \n\t" + "pop"Q" %c[rcx](%0) \n\t" + "mov %%"R"dx, %c[rdx](%0) \n\t" + "mov %%"R"si, %c[rsi](%0) \n\t" + "mov %%"R"di, %c[rdi](%0) \n\t" + "mov %%"R"bp, %c[rbp](%0) \n\t" #ifdef CONFIG_X86_64 "mov %%r8, %c[r8](%0) \n\t" "mov %%r9, %c[r9](%0) \n\t" @@ -6299,15 +6345,11 @@ static void __noclone vmx_vcpu_run(struct kvm_vcpu *vcpu) "mov %%r14, %c[r14](%0) \n\t" "mov %%r15, %c[r15](%0) \n\t" #endif - "mov %%cr2, %%" _ASM_AX " \n\t" - "mov %%" _ASM_AX ", %c[cr2](%0) \n\t" + "mov %%cr2, %%"R"ax \n\t" + "mov %%"R"ax, %c[cr2](%0) \n\t" - "pop %%" _ASM_BP "; pop %%" _ASM_DX " \n\t" + "pop %%"R"bp; pop %%"R"dx \n\t" "setbe %c[fail](%0) \n\t" - ".pushsection .rodata \n\t" - ".global vmx_return \n\t" - "vmx_return: " _ASM_PTR " 2b \n\t" - ".popsection" : : "c"(vmx), "d"((unsigned long)HOST_RSP), [launched]"i"(offsetof(struct vcpu_vmx, __launched)), [fail]"i"(offsetof(struct vcpu_vmx, fail)), @@ -6332,18 +6374,12 @@ static void __noclone vmx_vcpu_run(struct kvm_vcpu *vcpu) [cr2]"i"(offsetof(struct vcpu_vmx, vcpu.arch.cr2)), [wordsize]"i"(sizeof(ulong)) : "cc", "memory" + , R"ax", R"bx", R"di", R"si" #ifdef CONFIG_X86_64 - , "rax", "rbx", "rdi", "rsi" , "r8", "r9", "r10", "r11", "r12", "r13", "r14", "r15" -#else - , "eax", "ebx", "edi", "esi" #endif ); - /* MSR_IA32_DEBUGCTLMSR is zeroed on vmexit. Restore it if needed */ - if (debugctlmsr) - update_debugctlmsr(debugctlmsr); - #ifndef CONFIG_X86_64 /* * The sysexit path does not restore ds/es, so we must set them to @@ -6388,6 +6424,9 @@ static void __noclone vmx_vcpu_run(struct kvm_vcpu *vcpu) vmx_complete_interrupts(vmx); } +#undef R +#undef Q + static void vmx_free_vcpu(struct kvm_vcpu *vcpu) { struct vcpu_vmx *vmx = to_vmx(vcpu); @@ -7242,7 +7281,7 @@ static struct kvm_x86_ops vmx_x86_ops = { .vcpu_load = vmx_vcpu_load, .vcpu_put = vmx_vcpu_put, - .update_db_bp_intercept = update_exception_bitmap, + .set_guest_debug = set_guest_debug, .get_msr = vmx_get_msr, .set_msr = vmx_set_msr, .get_segment_base = vmx_get_segment_base, diff --git a/trunk/arch/x86/kvm/x86.c b/trunk/arch/x86/kvm/x86.c index 1eefebe5d727..1f09552572fa 100644 --- a/trunk/arch/x86/kvm/x86.c +++ b/trunk/arch/x86/kvm/x86.c @@ -246,14 +246,20 @@ static void drop_user_return_notifiers(void *ignore) u64 kvm_get_apic_base(struct kvm_vcpu *vcpu) { - return vcpu->arch.apic_base; + if (irqchip_in_kernel(vcpu->kvm)) + return vcpu->arch.apic_base; + else + return vcpu->arch.apic_base; } EXPORT_SYMBOL_GPL(kvm_get_apic_base); void kvm_set_apic_base(struct kvm_vcpu *vcpu, u64 data) { /* TODO: reserve bits check */ - kvm_lapic_set_base(vcpu, data); + if (irqchip_in_kernel(vcpu->kvm)) + kvm_lapic_set_base(vcpu, data); + else + vcpu->arch.apic_base = data; } EXPORT_SYMBOL_GPL(kvm_set_apic_base); @@ -692,18 +698,6 @@ unsigned long kvm_get_cr8(struct kvm_vcpu *vcpu) } EXPORT_SYMBOL_GPL(kvm_get_cr8); -static void kvm_update_dr7(struct kvm_vcpu *vcpu) -{ - unsigned long dr7; - - if (vcpu->guest_debug & KVM_GUESTDBG_USE_HW_BP) - dr7 = vcpu->arch.guest_debug_dr7; - else - dr7 = vcpu->arch.dr7; - kvm_x86_ops->set_dr7(vcpu, dr7); - vcpu->arch.switch_db_regs = (dr7 & DR7_BP_EN_MASK); -} - static int __kvm_set_dr(struct kvm_vcpu *vcpu, int dr, unsigned long val) { switch (dr) { @@ -729,7 +723,10 @@ static int __kvm_set_dr(struct kvm_vcpu *vcpu, int dr, unsigned long val) if (val & 0xffffffff00000000ULL) return -1; /* #GP */ vcpu->arch.dr7 = (val & DR7_VOLATILE) | DR7_FIXED_1; - kvm_update_dr7(vcpu); + if (!(vcpu->guest_debug & KVM_GUESTDBG_USE_HW_BP)) { + kvm_x86_ops->set_dr7(vcpu, vcpu->arch.dr7); + vcpu->arch.switch_db_regs = (val & DR7_BP_EN_MASK); + } break; } @@ -826,7 +823,7 @@ static u32 msrs_to_save[] = { static unsigned num_msrs_to_save; -static const u32 emulated_msrs[] = { +static u32 emulated_msrs[] = { MSR_IA32_TSCDEADLINE, MSR_IA32_MISC_ENABLE, MSR_IA32_MCG_STATUS, @@ -1100,7 +1097,7 @@ void kvm_write_tsc(struct kvm_vcpu *vcpu, u64 data) * For each generation, we track the original measured * nanosecond time, offset, and write, so if TSCs are in * sync, we can match exact offset, and if not, we can match - * exact software computation in compute_guest_tsc() + * exact software computaion in compute_guest_tsc() * * These values are tracked in kvm->arch.cur_xxx variables. */ @@ -1143,7 +1140,6 @@ static int kvm_guest_time_update(struct kvm_vcpu *v) unsigned long this_tsc_khz; s64 kernel_ns, max_kernel_ns; u64 tsc_timestamp; - u8 pvclock_flags; /* Keep irq disabled to prevent changes to the clock */ local_irq_save(flags); @@ -1225,14 +1221,7 @@ static int kvm_guest_time_update(struct kvm_vcpu *v) vcpu->hv_clock.system_time = kernel_ns + v->kvm->arch.kvmclock_offset; vcpu->last_kernel_ns = kernel_ns; vcpu->last_guest_tsc = tsc_timestamp; - - pvclock_flags = 0; - if (vcpu->pvclock_set_guest_stopped_request) { - pvclock_flags |= PVCLOCK_GUEST_STOPPED; - vcpu->pvclock_set_guest_stopped_request = false; - } - - vcpu->hv_clock.flags = pvclock_flags; + vcpu->hv_clock.flags = 0; /* * The interface expects us to write an even number signaling that the @@ -1515,7 +1504,7 @@ static int kvm_pv_enable_async_pf(struct kvm_vcpu *vcpu, u64 data) { gpa_t gpa = data & ~0x3f; - /* Bits 2:5 are reserved, Should be zero */ + /* Bits 2:5 are resrved, Should be zero */ if (data & 0x3c) return 1; @@ -1650,9 +1639,10 @@ int kvm_set_msr_common(struct kvm_vcpu *vcpu, u32 msr, u64 data) vcpu->arch.time_page = gfn_to_page(vcpu->kvm, data >> PAGE_SHIFT); - if (is_error_page(vcpu->arch.time_page)) + if (is_error_page(vcpu->arch.time_page)) { + kvm_release_page_clean(vcpu->arch.time_page); vcpu->arch.time_page = NULL; - + } break; } case MSR_KVM_ASYNC_PF_EN: @@ -1737,7 +1727,7 @@ int kvm_set_msr_common(struct kvm_vcpu *vcpu, u32 msr, u64 data) * Ignore all writes to this no longer documented MSR. * Writes are only relevant for old K7 processors, * all pre-dating SVM, but a recommended workaround from - * AMD for these chips. It is possible to specify the + * AMD for these chips. It is possible to speicify the * affected processor models on the command line, hence * the need to ignore the workaround. */ @@ -2187,8 +2177,6 @@ int kvm_dev_ioctl_check_extension(long ext) case KVM_CAP_GET_TSC_KHZ: case KVM_CAP_PCI_2_3: case KVM_CAP_KVMCLOCK_CTRL: - case KVM_CAP_READONLY_MEM: - case KVM_CAP_IRQFD_RESAMPLE: r = 1; break; case KVM_CAP_COALESCED_MMIO: @@ -2370,7 +2358,8 @@ static int kvm_vcpu_ioctl_get_lapic(struct kvm_vcpu *vcpu, static int kvm_vcpu_ioctl_set_lapic(struct kvm_vcpu *vcpu, struct kvm_lapic_state *s) { - kvm_apic_post_state_restore(vcpu, s); + memcpy(vcpu->arch.apic->regs, s->regs, sizeof *s); + kvm_apic_post_state_restore(vcpu); update_cr8_intercept(vcpu); return 0; @@ -2379,7 +2368,7 @@ static int kvm_vcpu_ioctl_set_lapic(struct kvm_vcpu *vcpu, static int kvm_vcpu_ioctl_interrupt(struct kvm_vcpu *vcpu, struct kvm_interrupt *irq) { - if (irq->irq < 0 || irq->irq >= KVM_NR_INTERRUPTS) + if (irq->irq < 0 || irq->irq >= 256) return -EINVAL; if (irqchip_in_kernel(vcpu->kvm)) return -ENXIO; @@ -2646,9 +2635,11 @@ static int kvm_vcpu_ioctl_x86_set_xcrs(struct kvm_vcpu *vcpu, */ static int kvm_set_guest_paused(struct kvm_vcpu *vcpu) { + struct pvclock_vcpu_time_info *src = &vcpu->arch.hv_clock; if (!vcpu->arch.time_page) return -EINVAL; - vcpu->arch.pvclock_set_guest_stopped_request = true; + src->flags |= PVCLOCK_GUEST_STOPPED; + mark_page_dirty(vcpu->kvm, vcpu->arch.time >> PAGE_SHIFT); kvm_make_request(KVM_REQ_CLOCK_UPDATE, vcpu); return 0; } @@ -3099,7 +3090,7 @@ static int kvm_vm_ioctl_reinject(struct kvm *kvm, if (!kvm->arch.vpit) return -ENXIO; mutex_lock(&kvm->arch.vpit->pit_state.lock); - kvm->arch.vpit->pit_state.reinject = control->pit_reinject; + kvm->arch.vpit->pit_state.pit_timer.reinject = control->pit_reinject; mutex_unlock(&kvm->arch.vpit->pit_state.lock); return 0; } @@ -3182,16 +3173,6 @@ int kvm_vm_ioctl_get_dirty_log(struct kvm *kvm, struct kvm_dirty_log *log) return r; } -int kvm_vm_ioctl_irq_line(struct kvm *kvm, struct kvm_irq_level *irq_event) -{ - if (!irqchip_in_kernel(kvm)) - return -ENXIO; - - irq_event->status = kvm_set_irq(kvm, KVM_USERSPACE_IRQ_SOURCE_ID, - irq_event->irq, irq_event->level); - return 0; -} - long kvm_arch_vm_ioctl(struct file *filp, unsigned int ioctl, unsigned long arg) { @@ -3298,6 +3279,29 @@ long kvm_arch_vm_ioctl(struct file *filp, create_pit_unlock: mutex_unlock(&kvm->slots_lock); break; + case KVM_IRQ_LINE_STATUS: + case KVM_IRQ_LINE: { + struct kvm_irq_level irq_event; + + r = -EFAULT; + if (copy_from_user(&irq_event, argp, sizeof irq_event)) + goto out; + r = -ENXIO; + if (irqchip_in_kernel(kvm)) { + __s32 status; + status = kvm_set_irq(kvm, KVM_USERSPACE_IRQ_SOURCE_ID, + irq_event.irq, irq_event.level); + if (ioctl == KVM_IRQ_LINE_STATUS) { + r = -EFAULT; + irq_event.status = status; + if (copy_to_user(argp, &irq_event, + sizeof irq_event)) + goto out; + } + r = 0; + } + break; + } case KVM_GET_IRQCHIP: { /* 0: PIC master, 1: PIC slave, 2: IOAPIC */ struct kvm_irqchip *chip; @@ -3685,17 +3689,20 @@ static int vcpu_mmio_gva_to_gpa(struct kvm_vcpu *vcpu, unsigned long gva, gpa_t *gpa, struct x86_exception *exception, bool write) { - u32 access = ((kvm_x86_ops->get_cpl(vcpu) == 3) ? PFERR_USER_MASK : 0) - | (write ? PFERR_WRITE_MASK : 0); + u32 access = (kvm_x86_ops->get_cpl(vcpu) == 3) ? PFERR_USER_MASK : 0; - if (vcpu_match_mmio_gva(vcpu, gva) - && !permission_fault(vcpu->arch.walk_mmu, vcpu->arch.access, access)) { + if (vcpu_match_mmio_gva(vcpu, gva) && + check_write_user_access(vcpu, write, access, + vcpu->arch.access)) { *gpa = vcpu->arch.mmio_gfn << PAGE_SHIFT | (gva & (PAGE_SIZE - 1)); trace_vcpu_match_mmio(gva, *gpa, write, false); return 1; } + if (write) + access |= PFERR_WRITE_MASK; + *gpa = vcpu->arch.walk_mmu->gva_to_gpa(vcpu, gva, access, exception); if (*gpa == UNMAPPED_GVA) @@ -3783,14 +3790,14 @@ static int write_exit_mmio(struct kvm_vcpu *vcpu, gpa_t gpa, return X86EMUL_CONTINUE; } -static const struct read_write_emulator_ops read_emultor = { +static struct read_write_emulator_ops read_emultor = { .read_write_prepare = read_prepare, .read_write_emulate = read_emulate, .read_write_mmio = vcpu_mmio_read, .read_write_exit_mmio = read_exit_mmio, }; -static const struct read_write_emulator_ops write_emultor = { +static struct read_write_emulator_ops write_emultor = { .read_write_emulate = write_emulate, .read_write_mmio = write_mmio, .read_write_exit_mmio = write_exit_mmio, @@ -3801,7 +3808,7 @@ static int emulator_read_write_onepage(unsigned long addr, void *val, unsigned int bytes, struct x86_exception *exception, struct kvm_vcpu *vcpu, - const struct read_write_emulator_ops *ops) + struct read_write_emulator_ops *ops) { gpa_t gpa; int handled, ret; @@ -3850,7 +3857,7 @@ static int emulator_read_write_onepage(unsigned long addr, void *val, int emulator_read_write(struct x86_emulate_ctxt *ctxt, unsigned long addr, void *val, unsigned int bytes, struct x86_exception *exception, - const struct read_write_emulator_ops *ops) + struct read_write_emulator_ops *ops) { struct kvm_vcpu *vcpu = emul_to_vcpu(ctxt); gpa_t gpa; @@ -3955,8 +3962,10 @@ static int emulator_cmpxchg_emulated(struct x86_emulate_ctxt *ctxt, goto emul_write; page = gfn_to_page(vcpu->kvm, gpa >> PAGE_SHIFT); - if (is_error_page(page)) + if (is_error_page(page)) { + kvm_release_page_clean(page); goto emul_write; + } kaddr = kmap_atomic(page); kaddr += offset_in_page(gpa); @@ -4323,19 +4332,7 @@ static void emulator_get_cpuid(struct x86_emulate_ctxt *ctxt, kvm_cpuid(emul_to_vcpu(ctxt), eax, ebx, ecx, edx); } -static ulong emulator_read_gpr(struct x86_emulate_ctxt *ctxt, unsigned reg) -{ - return kvm_register_read(emul_to_vcpu(ctxt), reg); -} - -static void emulator_write_gpr(struct x86_emulate_ctxt *ctxt, unsigned reg, ulong val) -{ - kvm_register_write(emul_to_vcpu(ctxt), reg, val); -} - -static const struct x86_emulate_ops emulate_ops = { - .read_gpr = emulator_read_gpr, - .write_gpr = emulator_write_gpr, +static struct x86_emulate_ops emulate_ops = { .read_std = kvm_read_guest_virt_system, .write_std = kvm_write_guest_virt_system, .fetch = kvm_fetch_guest_virt, @@ -4370,6 +4367,14 @@ static const struct x86_emulate_ops emulate_ops = { .get_cpuid = emulator_get_cpuid, }; +static void cache_all_regs(struct kvm_vcpu *vcpu) +{ + kvm_register_read(vcpu, VCPU_REGS_RAX); + kvm_register_read(vcpu, VCPU_REGS_RSP); + kvm_register_read(vcpu, VCPU_REGS_RIP); + vcpu->arch.regs_dirty = ~0; +} + static void toggle_interruptibility(struct kvm_vcpu *vcpu, u32 mask) { u32 int_shadow = kvm_x86_ops->get_interrupt_shadow(vcpu, mask); @@ -4396,10 +4401,12 @@ static void inject_emulated_exception(struct kvm_vcpu *vcpu) kvm_queue_exception(vcpu, ctxt->exception.vector); } -static void init_decode_cache(struct x86_emulate_ctxt *ctxt) +static void init_decode_cache(struct x86_emulate_ctxt *ctxt, + const unsigned long *regs) { memset(&ctxt->twobyte, 0, - (void *)&ctxt->_regs - (void *)&ctxt->twobyte); + (void *)&ctxt->regs - (void *)&ctxt->twobyte); + memcpy(ctxt->regs, regs, sizeof(ctxt->regs)); ctxt->fetch.start = 0; ctxt->fetch.end = 0; @@ -4414,6 +4421,14 @@ static void init_emulate_ctxt(struct kvm_vcpu *vcpu) struct x86_emulate_ctxt *ctxt = &vcpu->arch.emulate_ctxt; int cs_db, cs_l; + /* + * TODO: fix emulate.c to use guest_read/write_register + * instead of direct ->regs accesses, can save hundred cycles + * on Intel for instructions that don't read/change RSP, for + * for example. + */ + cache_all_regs(vcpu); + kvm_x86_ops->get_cs_db_l_bits(vcpu, &cs_db, &cs_l); ctxt->eflags = kvm_get_rflags(vcpu); @@ -4425,7 +4440,7 @@ static void init_emulate_ctxt(struct kvm_vcpu *vcpu) X86EMUL_MODE_PROT16; ctxt->guest_mode = is_guest_mode(vcpu); - init_decode_cache(ctxt); + init_decode_cache(ctxt, vcpu->arch.regs); vcpu->arch.emulate_regs_need_sync_from_vcpu = false; } @@ -4445,6 +4460,7 @@ int kvm_inject_realmode_interrupt(struct kvm_vcpu *vcpu, int irq, int inc_eip) return EMULATE_FAIL; ctxt->eip = ctxt->_eip; + memcpy(vcpu->arch.regs, ctxt->regs, sizeof ctxt->regs); kvm_rip_write(vcpu, ctxt->eip); kvm_set_rflags(vcpu, ctxt->eflags); @@ -4477,14 +4493,13 @@ static int handle_emulation_failure(struct kvm_vcpu *vcpu) static bool reexecute_instruction(struct kvm_vcpu *vcpu, gva_t gva) { gpa_t gpa; - pfn_t pfn; if (tdp_enabled) return false; /* * if emulation was due to access to shadowed page table - * and it failed try to unshadow page and re-enter the + * and it failed try to unshadow page and re-entetr the * guest to let CPU execute the instruction. */ if (kvm_mmu_unprotect_page_virt(vcpu, gva)) @@ -4495,17 +4510,8 @@ static bool reexecute_instruction(struct kvm_vcpu *vcpu, gva_t gva) if (gpa == UNMAPPED_GVA) return true; /* let cpu generate fault */ - /* - * Do not retry the unhandleable instruction if it faults on the - * readonly host memory, otherwise it will goto a infinite loop: - * retry instruction -> write #PF -> emulation fail -> retry - * instruction -> ... - */ - pfn = gfn_to_pfn(vcpu->kvm, gpa_to_gfn(gpa)); - if (!is_error_pfn(pfn)) { - kvm_release_pfn_clean(pfn); + if (!kvm_is_error_hva(gfn_to_hva(vcpu->kvm, gpa >> PAGE_SHIFT))) return true; - } return false; } @@ -4554,9 +4560,6 @@ static bool retry_instruction(struct x86_emulate_ctxt *ctxt, return true; } -static int complete_emulated_mmio(struct kvm_vcpu *vcpu); -static int complete_emulated_pio(struct kvm_vcpu *vcpu); - int x86_emulate_instruction(struct kvm_vcpu *vcpu, unsigned long cr2, int emulation_type, @@ -4605,7 +4608,7 @@ int x86_emulate_instruction(struct kvm_vcpu *vcpu, changes registers values during IO operation */ if (vcpu->arch.emulate_regs_need_sync_from_vcpu) { vcpu->arch.emulate_regs_need_sync_from_vcpu = false; - emulator_invalidate_register_cache(ctxt); + memcpy(ctxt->regs, vcpu->arch.regs, sizeof ctxt->regs); } restart: @@ -4627,16 +4630,13 @@ int x86_emulate_instruction(struct kvm_vcpu *vcpu, } else if (vcpu->arch.pio.count) { if (!vcpu->arch.pio.in) vcpu->arch.pio.count = 0; - else { + else writeback = false; - vcpu->arch.complete_userspace_io = complete_emulated_pio; - } r = EMULATE_DO_MMIO; } else if (vcpu->mmio_needed) { if (!vcpu->mmio_is_write) writeback = false; r = EMULATE_DO_MMIO; - vcpu->arch.complete_userspace_io = complete_emulated_mmio; } else if (r == EMULATION_RESTART) goto restart; else @@ -4646,6 +4646,7 @@ int x86_emulate_instruction(struct kvm_vcpu *vcpu, toggle_interruptibility(vcpu, ctxt->interruptibility); kvm_set_rflags(vcpu, ctxt->eflags); kvm_make_request(KVM_REQ_EVENT, vcpu); + memcpy(vcpu->arch.regs, ctxt->regs, sizeof ctxt->regs); vcpu->arch.emulate_regs_need_sync_to_vcpu = false; kvm_rip_write(vcpu, ctxt->eip); } else @@ -4928,7 +4929,6 @@ int kvm_arch_init(void *opaque) if (cpu_has_xsave) host_xcr0 = xgetbv(XCR_XFEATURE_ENABLED_MASK); - kvm_lapic_init(); return 0; out: @@ -5499,24 +5499,6 @@ static int __vcpu_run(struct kvm_vcpu *vcpu) return r; } -static inline int complete_emulated_io(struct kvm_vcpu *vcpu) -{ - int r; - vcpu->srcu_idx = srcu_read_lock(&vcpu->kvm->srcu); - r = emulate_instruction(vcpu, EMULTYPE_NO_DECODE); - srcu_read_unlock(&vcpu->kvm->srcu, vcpu->srcu_idx); - if (r != EMULATE_DONE) - return 0; - return 1; -} - -static int complete_emulated_pio(struct kvm_vcpu *vcpu) -{ - BUG_ON(!vcpu->arch.pio.count); - - return complete_emulated_io(vcpu); -} - /* * Implements the following, as a state machine: * @@ -5533,36 +5515,46 @@ static int complete_emulated_pio(struct kvm_vcpu *vcpu) * copy data * exit */ -static int complete_emulated_mmio(struct kvm_vcpu *vcpu) +static int complete_mmio(struct kvm_vcpu *vcpu) { struct kvm_run *run = vcpu->run; struct kvm_mmio_fragment *frag; + int r; - BUG_ON(!vcpu->mmio_needed); + if (!(vcpu->arch.pio.count || vcpu->mmio_needed)) + return 1; - /* Complete previous fragment */ - frag = &vcpu->mmio_fragments[vcpu->mmio_cur_fragment++]; - if (!vcpu->mmio_is_write) - memcpy(frag->data, run->mmio.data, frag->len); - if (vcpu->mmio_cur_fragment == vcpu->mmio_nr_fragments) { - vcpu->mmio_needed = 0; + if (vcpu->mmio_needed) { + /* Complete previous fragment */ + frag = &vcpu->mmio_fragments[vcpu->mmio_cur_fragment++]; + if (!vcpu->mmio_is_write) + memcpy(frag->data, run->mmio.data, frag->len); + if (vcpu->mmio_cur_fragment == vcpu->mmio_nr_fragments) { + vcpu->mmio_needed = 0; + if (vcpu->mmio_is_write) + return 1; + vcpu->mmio_read_completed = 1; + goto done; + } + /* Initiate next fragment */ + ++frag; + run->exit_reason = KVM_EXIT_MMIO; + run->mmio.phys_addr = frag->gpa; if (vcpu->mmio_is_write) - return 1; - vcpu->mmio_read_completed = 1; - return complete_emulated_io(vcpu); - } - /* Initiate next fragment */ - ++frag; - run->exit_reason = KVM_EXIT_MMIO; - run->mmio.phys_addr = frag->gpa; - if (vcpu->mmio_is_write) - memcpy(run->mmio.data, frag->data, frag->len); - run->mmio.len = frag->len; - run->mmio.is_write = vcpu->mmio_is_write; - vcpu->arch.complete_userspace_io = complete_emulated_mmio; - return 0; -} + memcpy(run->mmio.data, frag->data, frag->len); + run->mmio.len = frag->len; + run->mmio.is_write = vcpu->mmio_is_write; + return 0; + } +done: + vcpu->srcu_idx = srcu_read_lock(&vcpu->kvm->srcu); + r = emulate_instruction(vcpu, EMULTYPE_NO_DECODE); + srcu_read_unlock(&vcpu->kvm->srcu, vcpu->srcu_idx); + if (r != EMULATE_DONE) + return 0; + return 1; +} int kvm_arch_vcpu_ioctl_run(struct kvm_vcpu *vcpu, struct kvm_run *kvm_run) { @@ -5590,14 +5582,9 @@ int kvm_arch_vcpu_ioctl_run(struct kvm_vcpu *vcpu, struct kvm_run *kvm_run) } } - if (unlikely(vcpu->arch.complete_userspace_io)) { - int (*cui)(struct kvm_vcpu *) = vcpu->arch.complete_userspace_io; - vcpu->arch.complete_userspace_io = NULL; - r = cui(vcpu); - if (r <= 0) - goto out; - } else - WARN_ON(vcpu->arch.pio.count || vcpu->mmio_needed); + r = complete_mmio(vcpu); + if (r <= 0) + goto out; r = __vcpu_run(vcpu); @@ -5615,11 +5602,12 @@ int kvm_arch_vcpu_ioctl_get_regs(struct kvm_vcpu *vcpu, struct kvm_regs *regs) /* * We are here if userspace calls get_regs() in the middle of * instruction emulation. Registers state needs to be copied - * back from emulation context to vcpu. Userspace shouldn't do + * back from emulation context to vcpu. Usrapace shouldn't do * that usually, but some bad designed PV devices (vmware * backdoor interface) need this to work */ - emulator_writeback_register_cache(&vcpu->arch.emulate_ctxt); + struct x86_emulate_ctxt *ctxt = &vcpu->arch.emulate_ctxt; + memcpy(vcpu->arch.regs, ctxt->regs, sizeof ctxt->regs); vcpu->arch.emulate_regs_need_sync_to_vcpu = false; } regs->rax = kvm_register_read(vcpu, VCPU_REGS_RAX); @@ -5759,6 +5747,7 @@ int kvm_task_switch(struct kvm_vcpu *vcpu, u16 tss_selector, int idt_index, if (ret) return EMULATE_FAIL; + memcpy(vcpu->arch.regs, ctxt->regs, sizeof ctxt->regs); kvm_rip_write(vcpu, ctxt->eip); kvm_set_rflags(vcpu, ctxt->eflags); kvm_make_request(KVM_REQ_EVENT, vcpu); @@ -5810,7 +5799,7 @@ int kvm_arch_vcpu_ioctl_set_sregs(struct kvm_vcpu *vcpu, if (mmu_reset_needed) kvm_mmu_reset_context(vcpu); - max_bits = KVM_NR_INTERRUPTS; + max_bits = (sizeof sregs->interrupt_bitmap) << 3; pending_vec = find_first_bit( (const unsigned long *)sregs->interrupt_bitmap, max_bits); if (pending_vec < max_bits) { @@ -5870,12 +5859,13 @@ int kvm_arch_vcpu_ioctl_set_guest_debug(struct kvm_vcpu *vcpu, if (vcpu->guest_debug & KVM_GUESTDBG_USE_HW_BP) { for (i = 0; i < KVM_NR_DB_REGS; ++i) vcpu->arch.eff_db[i] = dbg->arch.debugreg[i]; - vcpu->arch.guest_debug_dr7 = dbg->arch.debugreg[7]; + vcpu->arch.switch_db_regs = + (dbg->arch.debugreg[7] & DR7_BP_EN_MASK); } else { for (i = 0; i < KVM_NR_DB_REGS; i++) vcpu->arch.eff_db[i] = vcpu->arch.db[i]; + vcpu->arch.switch_db_regs = (vcpu->arch.dr7 & DR7_BP_EN_MASK); } - kvm_update_dr7(vcpu); if (vcpu->guest_debug & KVM_GUESTDBG_SINGLESTEP) vcpu->arch.singlestep_rip = kvm_rip_read(vcpu) + @@ -5887,7 +5877,7 @@ int kvm_arch_vcpu_ioctl_set_guest_debug(struct kvm_vcpu *vcpu, */ kvm_set_rflags(vcpu, rflags); - kvm_x86_ops->update_db_bp_intercept(vcpu); + kvm_x86_ops->set_guest_debug(vcpu, dbg); r = 0; @@ -6033,9 +6023,7 @@ int kvm_arch_vcpu_setup(struct kvm_vcpu *vcpu) int r; vcpu->arch.mtrr_state.have_fixed = 1; - r = vcpu_load(vcpu); - if (r) - return r; + vcpu_load(vcpu); r = kvm_arch_vcpu_reset(vcpu); if (r == 0) r = kvm_mmu_setup(vcpu); @@ -6046,11 +6034,9 @@ int kvm_arch_vcpu_setup(struct kvm_vcpu *vcpu) void kvm_arch_vcpu_destroy(struct kvm_vcpu *vcpu) { - int r; vcpu->arch.apf.msr_val = 0; - r = vcpu_load(vcpu); - BUG_ON(r); + vcpu_load(vcpu); kvm_mmu_unload(vcpu); vcpu_put(vcpu); @@ -6064,10 +6050,10 @@ int kvm_arch_vcpu_reset(struct kvm_vcpu *vcpu) vcpu->arch.nmi_pending = 0; vcpu->arch.nmi_injected = false; + vcpu->arch.switch_db_regs = 0; memset(vcpu->arch.db, 0, sizeof(vcpu->arch.db)); vcpu->arch.dr6 = DR6_FIXED_1; vcpu->arch.dr7 = DR7_FIXED_1; - kvm_update_dr7(vcpu); kvm_make_request(KVM_REQ_EVENT, vcpu); vcpu->arch.apf.msr_val = 0; @@ -6146,7 +6132,7 @@ int kvm_arch_hardware_enable(void *garbage) * as we reset last_host_tsc on all VCPUs to stop this from being * called multiple times (one for each physical CPU bringup). * - * Platforms with unreliable TSCs don't have to deal with this, they + * Platforms with unnreliable TSCs don't have to deal with this, they * will be compensated by the logic in vcpu_load, which sets the TSC to * catchup mode. This will catchup all VCPUs to real time, but cannot * guarantee that they stay in perfect synchronization. @@ -6199,8 +6185,6 @@ bool kvm_vcpu_compatible(struct kvm_vcpu *vcpu) return irqchip_in_kernel(vcpu->kvm) == (vcpu->arch.apic != NULL); } -struct static_key kvm_no_apic_vcpu __read_mostly; - int kvm_arch_vcpu_init(struct kvm_vcpu *vcpu) { struct page *page; @@ -6233,8 +6217,7 @@ int kvm_arch_vcpu_init(struct kvm_vcpu *vcpu) r = kvm_create_lapic(vcpu); if (r < 0) goto fail_mmu_destroy; - } else - static_key_slow_inc(&kvm_no_apic_vcpu); + } vcpu->arch.mce_banks = kzalloc(KVM_MAX_MCE_BANKS * sizeof(u64) * 4, GFP_KERNEL); @@ -6274,8 +6257,6 @@ void kvm_arch_vcpu_uninit(struct kvm_vcpu *vcpu) kvm_mmu_destroy(vcpu); srcu_read_unlock(&vcpu->kvm->srcu, idx); free_page((unsigned long)vcpu->arch.pio_data); - if (!irqchip_in_kernel(vcpu->kvm)) - static_key_slow_dec(&kvm_no_apic_vcpu); } int kvm_arch_init_vm(struct kvm *kvm, unsigned long type) @@ -6288,21 +6269,15 @@ int kvm_arch_init_vm(struct kvm *kvm, unsigned long type) /* Reserve bit 0 of irq_sources_bitmap for userspace irq source */ set_bit(KVM_USERSPACE_IRQ_SOURCE_ID, &kvm->arch.irq_sources_bitmap); - /* Reserve bit 1 of irq_sources_bitmap for irqfd-resampler */ - set_bit(KVM_IRQFD_RESAMPLE_IRQ_SOURCE_ID, - &kvm->arch.irq_sources_bitmap); raw_spin_lock_init(&kvm->arch.tsc_write_lock); - mutex_init(&kvm->arch.apic_map_lock); return 0; } static void kvm_unload_vcpu_mmu(struct kvm_vcpu *vcpu) { - int r; - r = vcpu_load(vcpu); - BUG_ON(r); + vcpu_load(vcpu); kvm_mmu_unload(vcpu); vcpu_put(vcpu); } @@ -6346,7 +6321,6 @@ void kvm_arch_destroy_vm(struct kvm *kvm) put_page(kvm->arch.apic_access_page); if (kvm->arch.ept_identity_pagetable) put_page(kvm->arch.ept_identity_pagetable); - kfree(rcu_dereference_check(kvm->arch.apic_map, 1)); } void kvm_arch_free_memslot(struct kvm_memory_slot *free, @@ -6354,18 +6328,10 @@ void kvm_arch_free_memslot(struct kvm_memory_slot *free, { int i; - for (i = 0; i < KVM_NR_PAGE_SIZES; ++i) { - if (!dont || free->arch.rmap[i] != dont->arch.rmap[i]) { - kvm_kvfree(free->arch.rmap[i]); - free->arch.rmap[i] = NULL; - } - if (i == 0) - continue; - - if (!dont || free->arch.lpage_info[i - 1] != - dont->arch.lpage_info[i - 1]) { - kvm_kvfree(free->arch.lpage_info[i - 1]); - free->arch.lpage_info[i - 1] = NULL; + for (i = 0; i < KVM_NR_PAGE_SIZES - 1; ++i) { + if (!dont || free->arch.lpage_info[i] != dont->arch.lpage_info[i]) { + kvm_kvfree(free->arch.lpage_info[i]); + free->arch.lpage_info[i] = NULL; } } } @@ -6374,30 +6340,23 @@ int kvm_arch_create_memslot(struct kvm_memory_slot *slot, unsigned long npages) { int i; - for (i = 0; i < KVM_NR_PAGE_SIZES; ++i) { + for (i = 0; i < KVM_NR_PAGE_SIZES - 1; ++i) { unsigned long ugfn; int lpages; - int level = i + 1; + int level = i + 2; lpages = gfn_to_index(slot->base_gfn + npages - 1, slot->base_gfn, level) + 1; - slot->arch.rmap[i] = - kvm_kvzalloc(lpages * sizeof(*slot->arch.rmap[i])); - if (!slot->arch.rmap[i]) - goto out_free; - if (i == 0) - continue; - - slot->arch.lpage_info[i - 1] = kvm_kvzalloc(lpages * - sizeof(*slot->arch.lpage_info[i - 1])); - if (!slot->arch.lpage_info[i - 1]) + slot->arch.lpage_info[i] = + kvm_kvzalloc(lpages * sizeof(*slot->arch.lpage_info[i])); + if (!slot->arch.lpage_info[i]) goto out_free; if (slot->base_gfn & (KVM_PAGES_PER_HPAGE(level) - 1)) - slot->arch.lpage_info[i - 1][0].write_count = 1; + slot->arch.lpage_info[i][0].write_count = 1; if ((slot->base_gfn + npages) & (KVM_PAGES_PER_HPAGE(level) - 1)) - slot->arch.lpage_info[i - 1][lpages - 1].write_count = 1; + slot->arch.lpage_info[i][lpages - 1].write_count = 1; ugfn = slot->userspace_addr >> PAGE_SHIFT; /* * If the gfn and userspace address are not aligned wrt each @@ -6409,21 +6368,16 @@ int kvm_arch_create_memslot(struct kvm_memory_slot *slot, unsigned long npages) unsigned long j; for (j = 0; j < lpages; ++j) - slot->arch.lpage_info[i - 1][j].write_count = 1; + slot->arch.lpage_info[i][j].write_count = 1; } } return 0; out_free: - for (i = 0; i < KVM_NR_PAGE_SIZES; ++i) { - kvm_kvfree(slot->arch.rmap[i]); - slot->arch.rmap[i] = NULL; - if (i == 0) - continue; - - kvm_kvfree(slot->arch.lpage_info[i - 1]); - slot->arch.lpage_info[i - 1] = NULL; + for (i = 0; i < KVM_NR_PAGE_SIZES - 1; ++i) { + kvm_kvfree(slot->arch.lpage_info[i]); + slot->arch.lpage_info[i] = NULL; } return -ENOMEM; } @@ -6442,10 +6396,10 @@ int kvm_arch_prepare_memory_region(struct kvm *kvm, map_flags = MAP_SHARED | MAP_ANONYMOUS; /*To keep backward compatibility with older userspace, - *x86 needs to handle !user_alloc case. + *x86 needs to hanlde !user_alloc case. */ if (!user_alloc) { - if (npages && !old.npages) { + if (npages && !old.rmap) { unsigned long userspace_addr; userspace_addr = vm_mmap(NULL, 0, @@ -6473,7 +6427,7 @@ void kvm_arch_commit_memory_region(struct kvm *kvm, int nr_mmu_pages = 0, npages = mem->memory_size >> PAGE_SHIFT; - if (!user_alloc && !old.user_alloc && old.npages && !npages) { + if (!user_alloc && !old.user_alloc && old.rmap && !npages) { int ret; ret = vm_munmap(old.userspace_addr, @@ -6492,28 +6446,14 @@ void kvm_arch_commit_memory_region(struct kvm *kvm, kvm_mmu_change_mmu_pages(kvm, nr_mmu_pages); kvm_mmu_slot_remove_write_access(kvm, mem->slot); spin_unlock(&kvm->mmu_lock); - /* - * If memory slot is created, or moved, we need to clear all - * mmio sptes. - */ - if (npages && old.base_gfn != mem->guest_phys_addr >> PAGE_SHIFT) { - kvm_mmu_zap_all(kvm); - kvm_reload_remote_mmus(kvm); - } } -void kvm_arch_flush_shadow_all(struct kvm *kvm) +void kvm_arch_flush_shadow(struct kvm *kvm) { kvm_mmu_zap_all(kvm); kvm_reload_remote_mmus(kvm); } -void kvm_arch_flush_shadow_memslot(struct kvm *kvm, - struct kvm_memory_slot *slot) -{ - kvm_arch_flush_shadow_all(kvm); -} - int kvm_arch_vcpu_runnable(struct kvm_vcpu *vcpu) { return (vcpu->arch.mp_state == KVM_MP_STATE_RUNNABLE && diff --git a/trunk/arch/x86/kvm/x86.h b/trunk/arch/x86/kvm/x86.h index 2b5219c12ac8..3d1134ddb885 100644 --- a/trunk/arch/x86/kvm/x86.h +++ b/trunk/arch/x86/kvm/x86.h @@ -124,5 +124,4 @@ int kvm_write_guest_virt_system(struct x86_emulate_ctxt *ctxt, extern u64 host_xcr0; -extern struct static_key kvm_no_apic_vcpu; #endif diff --git a/trunk/arch/x86/xen/enlighten.c b/trunk/arch/x86/xen/enlighten.c index bf788d34530d..2d932c351f91 100644 --- a/trunk/arch/x86/xen/enlighten.c +++ b/trunk/arch/x86/xen/enlighten.c @@ -33,7 +33,6 @@ #include #include -#include #include #include #include diff --git a/trunk/arch/x86/xen/irq.c b/trunk/arch/x86/xen/irq.c index 01a4dc015ae1..157337657971 100644 --- a/trunk/arch/x86/xen/irq.c +++ b/trunk/arch/x86/xen/irq.c @@ -5,7 +5,6 @@ #include #include #include -#include #include #include diff --git a/trunk/arch/x86/xen/xen-ops.h b/trunk/arch/x86/xen/xen-ops.h index a95b41744ad0..bb5a8105ea86 100644 --- a/trunk/arch/x86/xen/xen-ops.h +++ b/trunk/arch/x86/xen/xen-ops.h @@ -35,6 +35,7 @@ void xen_set_pat(u64); char * __init xen_memory_setup(void); void __init xen_arch_setup(void); +void __init xen_init_IRQ(void); void xen_enable_sysenter(void); void xen_enable_syscall(void); void xen_vcpu_restore(void); diff --git a/trunk/arch/xtensa/include/asm/elf.h b/trunk/arch/xtensa/include/asm/elf.h index 5293312bc6a4..6e65eadaae14 100644 --- a/trunk/arch/xtensa/include/asm/elf.h +++ b/trunk/arch/xtensa/include/asm/elf.h @@ -189,8 +189,7 @@ typedef struct { #endif } elf_xtregs_t; -#define SET_PERSONALITY(ex) \ - set_personality(PER_LINUX_32BIT | (current->personality & (~PER_MASK))) +#define SET_PERSONALITY(ex) set_personality(PER_LINUX_32BIT) struct task_struct; diff --git a/trunk/crypto/842.c b/trunk/crypto/842.c deleted file mode 100644 index 65c7a89cfa09..000000000000 --- a/trunk/crypto/842.c +++ /dev/null @@ -1,182 +0,0 @@ -/* - * Cryptographic API for the 842 compression algorithm. - * - * 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, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * Copyright (C) IBM Corporation, 2011 - * - * Authors: Robert Jennings - * Seth Jennings - */ - -#include -#include -#include -#include -#include -#include -#include - -static int nx842_uselzo; - -struct nx842_ctx { - void *nx842_wmem; /* working memory for 842/lzo */ -}; - -enum nx842_crypto_type { - NX842_CRYPTO_TYPE_842, - NX842_CRYPTO_TYPE_LZO -}; - -#define NX842_SENTINEL 0xdeadbeef - -struct nx842_crypto_header { - unsigned int sentinel; /* debug */ - enum nx842_crypto_type type; -}; - -static int nx842_init(struct crypto_tfm *tfm) -{ - struct nx842_ctx *ctx = crypto_tfm_ctx(tfm); - int wmemsize; - - wmemsize = max_t(int, nx842_get_workmem_size(), LZO1X_MEM_COMPRESS); - ctx->nx842_wmem = kmalloc(wmemsize, GFP_NOFS); - if (!ctx->nx842_wmem) - return -ENOMEM; - - return 0; -} - -static void nx842_exit(struct crypto_tfm *tfm) -{ - struct nx842_ctx *ctx = crypto_tfm_ctx(tfm); - - kfree(ctx->nx842_wmem); -} - -static void nx842_reset_uselzo(unsigned long data) -{ - nx842_uselzo = 0; -} - -static DEFINE_TIMER(failover_timer, nx842_reset_uselzo, 0, 0); - -static int nx842_crypto_compress(struct crypto_tfm *tfm, const u8 *src, - unsigned int slen, u8 *dst, unsigned int *dlen) -{ - struct nx842_ctx *ctx = crypto_tfm_ctx(tfm); - struct nx842_crypto_header *hdr; - unsigned int tmp_len = *dlen; - size_t lzodlen; /* needed for lzo */ - int err; - - *dlen = 0; - hdr = (struct nx842_crypto_header *)dst; - hdr->sentinel = NX842_SENTINEL; /* debug */ - dst += sizeof(struct nx842_crypto_header); - tmp_len -= sizeof(struct nx842_crypto_header); - lzodlen = tmp_len; - - if (likely(!nx842_uselzo)) { - err = nx842_compress(src, slen, dst, &tmp_len, ctx->nx842_wmem); - - if (likely(!err)) { - hdr->type = NX842_CRYPTO_TYPE_842; - *dlen = tmp_len + sizeof(struct nx842_crypto_header); - return 0; - } - - /* hardware failed */ - nx842_uselzo = 1; - - /* set timer to check for hardware again in 1 second */ - mod_timer(&failover_timer, jiffies + msecs_to_jiffies(1000)); - } - - /* no hardware, use lzo */ - err = lzo1x_1_compress(src, slen, dst, &lzodlen, ctx->nx842_wmem); - if (err != LZO_E_OK) - return -EINVAL; - - hdr->type = NX842_CRYPTO_TYPE_LZO; - *dlen = lzodlen + sizeof(struct nx842_crypto_header); - return 0; -} - -static int nx842_crypto_decompress(struct crypto_tfm *tfm, const u8 *src, - unsigned int slen, u8 *dst, unsigned int *dlen) -{ - struct nx842_ctx *ctx = crypto_tfm_ctx(tfm); - struct nx842_crypto_header *hdr; - unsigned int tmp_len = *dlen; - size_t lzodlen; /* needed for lzo */ - int err; - - *dlen = 0; - hdr = (struct nx842_crypto_header *)src; - - if (unlikely(hdr->sentinel != NX842_SENTINEL)) - return -EINVAL; - - src += sizeof(struct nx842_crypto_header); - slen -= sizeof(struct nx842_crypto_header); - - if (likely(hdr->type == NX842_CRYPTO_TYPE_842)) { - err = nx842_decompress(src, slen, dst, &tmp_len, - ctx->nx842_wmem); - if (err) - return -EINVAL; - *dlen = tmp_len; - } else if (hdr->type == NX842_CRYPTO_TYPE_LZO) { - lzodlen = tmp_len; - err = lzo1x_decompress_safe(src, slen, dst, &lzodlen); - if (err != LZO_E_OK) - return -EINVAL; - *dlen = lzodlen; - } else - return -EINVAL; - - return 0; -} - -static struct crypto_alg alg = { - .cra_name = "842", - .cra_flags = CRYPTO_ALG_TYPE_COMPRESS, - .cra_ctxsize = sizeof(struct nx842_ctx), - .cra_module = THIS_MODULE, - .cra_init = nx842_init, - .cra_exit = nx842_exit, - .cra_u = { .compress = { - .coa_compress = nx842_crypto_compress, - .coa_decompress = nx842_crypto_decompress } } -}; - -static int __init nx842_mod_init(void) -{ - del_timer(&failover_timer); - return crypto_register_alg(&alg); -} - -static void __exit nx842_mod_exit(void) -{ - crypto_unregister_alg(&alg); -} - -module_init(nx842_mod_init); -module_exit(nx842_mod_exit); - -MODULE_LICENSE("GPL"); -MODULE_DESCRIPTION("842 Compression Algorithm"); diff --git a/trunk/crypto/Kconfig b/trunk/crypto/Kconfig index 50402dc0ea35..957cc56ce4b9 100644 --- a/trunk/crypto/Kconfig +++ b/trunk/crypto/Kconfig @@ -460,15 +460,6 @@ config CRYPTO_SHA1_SPARC64 SHA-1 secure hash standard (FIPS 180-1/DFIPS 180-2) implemented using sparc64 crypto instructions, when available. -config CRYPTO_SHA1_ARM - tristate "SHA1 digest algorithm (ARM-asm)" - depends on ARM - select CRYPTO_SHA1 - select CRYPTO_HASH - help - SHA-1 secure hash standard (FIPS 180-1/DFIPS 180-2) implemented - using optimized ARM assembler. - config CRYPTO_SHA256 tristate "SHA224 and SHA256 digest algorithm" select CRYPTO_HASH @@ -618,8 +609,6 @@ config CRYPTO_AES_NI_INTEL select CRYPTO_CRYPTD select CRYPTO_ABLK_HELPER_X86 select CRYPTO_ALGAPI - select CRYPTO_LRW - select CRYPTO_XTS help Use Intel AES-NI instructions for AES algorithm. @@ -672,30 +661,6 @@ config CRYPTO_AES_SPARC64 for some popular block cipher mode is supported too, including ECB and CBC. -config CRYPTO_AES_ARM - tristate "AES cipher algorithms (ARM-asm)" - depends on ARM - select CRYPTO_ALGAPI - select CRYPTO_AES - help - Use optimized AES assembler routines for ARM platforms. - - AES cipher algorithms (FIPS-197). AES uses the Rijndael - algorithm. - - Rijndael appears to be consistently a very good performer in - both hardware and software across a wide range of computing - environments regardless of its use in feedback or non-feedback - modes. Its key setup time is excellent, and its key agility is - good. Rijndael's very low memory requirements make it very well - suited for restricted-space environments, in which it also - demonstrates excellent performance. Rijndael's operations are - among the easiest to defend against power and timing attacks. - - The AES specifies three key sizes: 128, 192 and 256 bits - - See for more information. - config CRYPTO_ANUBIS tristate "Anubis cipher algorithm" select CRYPTO_ALGAPI @@ -816,20 +781,6 @@ config CRYPTO_CAST5 The CAST5 encryption algorithm (synonymous with CAST-128) is described in RFC2144. -config CRYPTO_CAST5_AVX_X86_64 - tristate "CAST5 (CAST-128) cipher algorithm (x86_64/AVX)" - depends on X86 && 64BIT - select CRYPTO_ALGAPI - select CRYPTO_CRYPTD - select CRYPTO_ABLK_HELPER_X86 - select CRYPTO_CAST5 - help - The CAST5 encryption algorithm (synonymous with CAST-128) is - described in RFC2144. - - This module provides the Cast5 cipher algorithm that processes - sixteen blocks parallel using the AVX instruction set. - config CRYPTO_CAST6 tristate "CAST6 (CAST-256) cipher algorithm" select CRYPTO_ALGAPI @@ -837,23 +788,6 @@ config CRYPTO_CAST6 The CAST6 encryption algorithm (synonymous with CAST-256) is described in RFC2612. -config CRYPTO_CAST6_AVX_X86_64 - tristate "CAST6 (CAST-256) cipher algorithm (x86_64/AVX)" - depends on X86 && 64BIT - select CRYPTO_ALGAPI - select CRYPTO_CRYPTD - select CRYPTO_ABLK_HELPER_X86 - select CRYPTO_GLUE_HELPER_X86 - select CRYPTO_CAST6 - select CRYPTO_LRW - select CRYPTO_XTS - help - The CAST6 encryption algorithm (synonymous with CAST-256) is - described in RFC2612. - - This module provides the Cast6 cipher algorithm that processes - eight blocks parallel using the AVX instruction set. - config CRYPTO_DES tristate "DES and Triple DES EDE cipher algorithms" select CRYPTO_ALGAPI @@ -1172,15 +1106,6 @@ config CRYPTO_LZO help This is the LZO algorithm. -config CRYPTO_842 - tristate "842 compression algorithm" - depends on CRYPTO_DEV_NX_COMPRESS - # 842 uses lzo if the hardware becomes unavailable - select LZO_COMPRESS - select LZO_DECOMPRESS - help - This is the 842 algorithm. - comment "Random Number Generation" config CRYPTO_ANSI_CPRNG diff --git a/trunk/crypto/Makefile b/trunk/crypto/Makefile index a301ad2b258c..30f33d675330 100644 --- a/trunk/crypto/Makefile +++ b/trunk/crypto/Makefile @@ -68,8 +68,8 @@ obj-$(CONFIG_CRYPTO_TWOFISH_COMMON) += twofish_common.o obj-$(CONFIG_CRYPTO_SERPENT) += serpent_generic.o obj-$(CONFIG_CRYPTO_AES) += aes_generic.o obj-$(CONFIG_CRYPTO_CAMELLIA) += camellia_generic.o -obj-$(CONFIG_CRYPTO_CAST5) += cast5_generic.o -obj-$(CONFIG_CRYPTO_CAST6) += cast6_generic.o +obj-$(CONFIG_CRYPTO_CAST5) += cast5.o +obj-$(CONFIG_CRYPTO_CAST6) += cast6.o obj-$(CONFIG_CRYPTO_ARC4) += arc4.o obj-$(CONFIG_CRYPTO_TEA) += tea.o obj-$(CONFIG_CRYPTO_KHAZAD) += khazad.o @@ -82,7 +82,6 @@ obj-$(CONFIG_CRYPTO_MICHAEL_MIC) += michael_mic.o obj-$(CONFIG_CRYPTO_CRC32C) += crc32c.o obj-$(CONFIG_CRYPTO_AUTHENC) += authenc.o authencesn.o obj-$(CONFIG_CRYPTO_LZO) += lzo.o -obj-$(CONFIG_CRYPTO_842) += 842.o obj-$(CONFIG_CRYPTO_RNG2) += rng.o obj-$(CONFIG_CRYPTO_RNG2) += krng.o obj-$(CONFIG_CRYPTO_ANSI_CPRNG) += ansi_cprng.o diff --git a/trunk/crypto/aes_generic.c b/trunk/crypto/aes_generic.c index 47f2e5c71759..a68c73dae15a 100644 --- a/trunk/crypto/aes_generic.c +++ b/trunk/crypto/aes_generic.c @@ -1448,6 +1448,7 @@ static struct crypto_alg aes_alg = { .cra_ctxsize = sizeof(struct crypto_aes_ctx), .cra_alignmask = 3, .cra_module = THIS_MODULE, + .cra_list = LIST_HEAD_INIT(aes_alg.cra_list), .cra_u = { .cipher = { .cia_min_keysize = AES_MIN_KEY_SIZE, diff --git a/trunk/crypto/ansi_cprng.c b/trunk/crypto/ansi_cprng.c index c0bb3778f1ae..6ddd99e6114b 100644 --- a/trunk/crypto/ansi_cprng.c +++ b/trunk/crypto/ansi_cprng.c @@ -382,6 +382,26 @@ static int cprng_reset(struct crypto_rng *tfm, u8 *seed, unsigned int slen) return 0; } +static struct crypto_alg rng_alg = { + .cra_name = "stdrng", + .cra_driver_name = "ansi_cprng", + .cra_priority = 100, + .cra_flags = CRYPTO_ALG_TYPE_RNG, + .cra_ctxsize = sizeof(struct prng_context), + .cra_type = &crypto_rng_type, + .cra_module = THIS_MODULE, + .cra_list = LIST_HEAD_INIT(rng_alg.cra_list), + .cra_init = cprng_init, + .cra_exit = cprng_exit, + .cra_u = { + .rng = { + .rng_make_random = cprng_get_random, + .rng_reset = cprng_reset, + .seedsize = DEFAULT_PRNG_KSZ + 2*DEFAULT_BLK_SZ, + } + } +}; + #ifdef CONFIG_CRYPTO_FIPS static int fips_cprng_get_random(struct crypto_rng *tfm, u8 *rdata, unsigned int dlen) @@ -418,27 +438,8 @@ static int fips_cprng_reset(struct crypto_rng *tfm, u8 *seed, unsigned int slen) out: return rc; } -#endif -static struct crypto_alg rng_algs[] = { { - .cra_name = "stdrng", - .cra_driver_name = "ansi_cprng", - .cra_priority = 100, - .cra_flags = CRYPTO_ALG_TYPE_RNG, - .cra_ctxsize = sizeof(struct prng_context), - .cra_type = &crypto_rng_type, - .cra_module = THIS_MODULE, - .cra_init = cprng_init, - .cra_exit = cprng_exit, - .cra_u = { - .rng = { - .rng_make_random = cprng_get_random, - .rng_reset = cprng_reset, - .seedsize = DEFAULT_PRNG_KSZ + 2*DEFAULT_BLK_SZ, - } - } -#ifdef CONFIG_CRYPTO_FIPS -}, { +static struct crypto_alg fips_rng_alg = { .cra_name = "fips(ansi_cprng)", .cra_driver_name = "fips_ansi_cprng", .cra_priority = 300, @@ -446,6 +447,7 @@ static struct crypto_alg rng_algs[] = { { .cra_ctxsize = sizeof(struct prng_context), .cra_type = &crypto_rng_type, .cra_module = THIS_MODULE, + .cra_list = LIST_HEAD_INIT(rng_alg.cra_list), .cra_init = cprng_init, .cra_exit = cprng_exit, .cra_u = { @@ -455,18 +457,33 @@ static struct crypto_alg rng_algs[] = { { .seedsize = DEFAULT_PRNG_KSZ + 2*DEFAULT_BLK_SZ, } } +}; #endif -} }; /* Module initalization */ static int __init prng_mod_init(void) { - return crypto_register_algs(rng_algs, ARRAY_SIZE(rng_algs)); + int rc = 0; + + rc = crypto_register_alg(&rng_alg); +#ifdef CONFIG_CRYPTO_FIPS + if (rc) + goto out; + + rc = crypto_register_alg(&fips_rng_alg); + +out: +#endif + return rc; } static void __exit prng_mod_fini(void) { - crypto_unregister_algs(rng_algs, ARRAY_SIZE(rng_algs)); + crypto_unregister_alg(&rng_alg); +#ifdef CONFIG_CRYPTO_FIPS + crypto_unregister_alg(&fips_rng_alg); +#endif + return; } MODULE_LICENSE("GPL"); diff --git a/trunk/crypto/anubis.c b/trunk/crypto/anubis.c index 008c8a4fb67c..77530d571c96 100644 --- a/trunk/crypto/anubis.c +++ b/trunk/crypto/anubis.c @@ -678,6 +678,7 @@ static struct crypto_alg anubis_alg = { .cra_ctxsize = sizeof (struct anubis_ctx), .cra_alignmask = 3, .cra_module = THIS_MODULE, + .cra_list = LIST_HEAD_INIT(anubis_alg.cra_list), .cra_u = { .cipher = { .cia_min_keysize = ANUBIS_MIN_KEY_SIZE, .cia_max_keysize = ANUBIS_MAX_KEY_SIZE, diff --git a/trunk/crypto/blowfish_generic.c b/trunk/crypto/blowfish_generic.c index 8baf5447d35b..6f269b5cfa3b 100644 --- a/trunk/crypto/blowfish_generic.c +++ b/trunk/crypto/blowfish_generic.c @@ -115,6 +115,7 @@ static struct crypto_alg alg = { .cra_ctxsize = sizeof(struct bf_ctx), .cra_alignmask = 3, .cra_module = THIS_MODULE, + .cra_list = LIST_HEAD_INIT(alg.cra_list), .cra_u = { .cipher = { .cia_min_keysize = BF_MIN_KEY_SIZE, .cia_max_keysize = BF_MAX_KEY_SIZE, diff --git a/trunk/crypto/camellia_generic.c b/trunk/crypto/camellia_generic.c index 75efa2052305..f7aaaaf86982 100644 --- a/trunk/crypto/camellia_generic.c +++ b/trunk/crypto/camellia_generic.c @@ -1072,6 +1072,7 @@ static struct crypto_alg camellia_alg = { .cra_ctxsize = sizeof(struct camellia_ctx), .cra_alignmask = 3, .cra_module = THIS_MODULE, + .cra_list = LIST_HEAD_INIT(camellia_alg.cra_list), .cra_u = { .cipher = { .cia_min_keysize = CAMELLIA_MIN_KEY_SIZE, diff --git a/trunk/crypto/cast5_generic.c b/trunk/crypto/cast5.c similarity index 95% rename from trunk/crypto/cast5_generic.c rename to trunk/crypto/cast5.c index bc525dbd8a4b..4a230ddec877 100644 --- a/trunk/crypto/cast5_generic.c +++ b/trunk/crypto/cast5.c @@ -4,8 +4,8 @@ * Derived from GnuPG implementation of cast5. * * Major Changes. -* Complete conformance to rfc2144. -* Supports key size from 40 to 128 bits. +* Complete conformance to rfc2144. +* Supports key size from 40 to 128 bits. * * Copyright (C) 1998, 1999, 2000, 2001 Free Software Foundation, Inc. * Copyright (C) 2003 Kartikey Mahendra Bhatt . @@ -28,10 +28,19 @@ #include #include #include -#include +#define CAST5_BLOCK_SIZE 8 +#define CAST5_MIN_KEY_SIZE 5 +#define CAST5_MAX_KEY_SIZE 16 -const u32 cast5_s1[256] = { +struct cast5_ctx { + u32 Km[16]; + u8 Kr[16]; + int rr; /* rr?number of rounds = 16:number of rounds = 12; (rfc 2144) */ +}; + + +static const u32 s1[256] = { 0x30fb40d4, 0x9fa0ff0b, 0x6beccd2f, 0x3f258c7a, 0x1e213f2f, 0x9c004dd3, 0x6003e540, 0xcf9fc949, 0xbfd4af27, 0x88bbbdb5, 0xe2034090, 0x98d09675, 0x6e63a0e0, @@ -97,8 +106,7 @@ const u32 cast5_s1[256] = { 0x1a69e783, 0x02cc4843, 0xa2f7c579, 0x429ef47d, 0x427b169c, 0x5ac9f049, 0xdd8f0f00, 0x5c8165bf }; -EXPORT_SYMBOL_GPL(cast5_s1); -const u32 cast5_s2[256] = { +static const u32 s2[256] = { 0x1f201094, 0xef0ba75b, 0x69e3cf7e, 0x393f4380, 0xfe61cf7a, 0xeec5207a, 0x55889c94, 0x72fc0651, 0xada7ef79, 0x4e1d7235, 0xd55a63ce, 0xde0436ba, 0x99c430ef, @@ -164,8 +172,7 @@ const u32 cast5_s2[256] = { 0x43d79572, 0x7e6dd07c, 0x06dfdf1e, 0x6c6cc4ef, 0x7160a539, 0x73bfbe70, 0x83877605, 0x4523ecf1 }; -EXPORT_SYMBOL_GPL(cast5_s2); -const u32 cast5_s3[256] = { +static const u32 s3[256] = { 0x8defc240, 0x25fa5d9f, 0xeb903dbf, 0xe810c907, 0x47607fff, 0x369fe44b, 0x8c1fc644, 0xaececa90, 0xbeb1f9bf, 0xeefbcaea, 0xe8cf1950, 0x51df07ae, 0x920e8806, @@ -231,8 +238,7 @@ const u32 cast5_s3[256] = { 0xf7baefd5, 0x4142ed9c, 0xa4315c11, 0x83323ec5, 0xdfef4636, 0xa133c501, 0xe9d3531c, 0xee353783 }; -EXPORT_SYMBOL_GPL(cast5_s3); -const u32 cast5_s4[256] = { +static const u32 s4[256] = { 0x9db30420, 0x1fb6e9de, 0xa7be7bef, 0xd273a298, 0x4a4f7bdb, 0x64ad8c57, 0x85510443, 0xfa020ed1, 0x7e287aff, 0xe60fb663, 0x095f35a1, 0x79ebf120, 0xfd059d43, @@ -298,7 +304,6 @@ const u32 cast5_s4[256] = { 0x7ae5290c, 0x3cb9536b, 0x851e20fe, 0x9833557e, 0x13ecf0b0, 0xd3ffb372, 0x3f85c5c1, 0x0aef7ed2 }; -EXPORT_SYMBOL_GPL(cast5_s4); static const u32 s5[256] = { 0x7ec90c04, 0x2c6e74b9, 0x9b0e66df, 0xa6337911, 0xb86a7fff, 0x1dd358f5, 0x44dd9d44, 0x1731167f, @@ -564,21 +569,17 @@ static const u32 sb8[256] = { 0xeaee6801, 0x8db2a283, 0xea8bf59e }; -#define s1 cast5_s1 -#define s2 cast5_s2 -#define s3 cast5_s3 -#define s4 cast5_s4 - #define F1(D, m, r) ((I = ((m) + (D))), (I = rol32(I, (r))), \ - (((s1[I >> 24] ^ s2[(I>>16)&0xff]) - s3[(I>>8)&0xff]) + s4[I&0xff])) + (((s1[I >> 24] ^ s2[(I>>16)&0xff]) - s3[(I>>8)&0xff]) + s4[I&0xff])) #define F2(D, m, r) ((I = ((m) ^ (D))), (I = rol32(I, (r))), \ - (((s1[I >> 24] - s2[(I>>16)&0xff]) + s3[(I>>8)&0xff]) ^ s4[I&0xff])) + (((s1[I >> 24] - s2[(I>>16)&0xff]) + s3[(I>>8)&0xff]) ^ s4[I&0xff])) #define F3(D, m, r) ((I = ((m) - (D))), (I = rol32(I, (r))), \ - (((s1[I >> 24] + s2[(I>>16)&0xff]) ^ s3[(I>>8)&0xff]) - s4[I&0xff])) + (((s1[I >> 24] + s2[(I>>16)&0xff]) ^ s3[(I>>8)&0xff]) - s4[I&0xff])) -void __cast5_encrypt(struct cast5_ctx *c, u8 *outbuf, const u8 *inbuf) +static void cast5_encrypt(struct crypto_tfm *tfm, u8 *outbuf, const u8 *inbuf) { + struct cast5_ctx *c = crypto_tfm_ctx(tfm); const __be32 *src = (const __be32 *)inbuf; __be32 *dst = (__be32 *)outbuf; u32 l, r, t; @@ -627,15 +628,10 @@ void __cast5_encrypt(struct cast5_ctx *c, u8 *outbuf, const u8 *inbuf) dst[0] = cpu_to_be32(r); dst[1] = cpu_to_be32(l); } -EXPORT_SYMBOL_GPL(__cast5_encrypt); -static void cast5_encrypt(struct crypto_tfm *tfm, u8 *outbuf, const u8 *inbuf) -{ - __cast5_encrypt(crypto_tfm_ctx(tfm), outbuf, inbuf); -} - -void __cast5_decrypt(struct cast5_ctx *c, u8 *outbuf, const u8 *inbuf) +static void cast5_decrypt(struct crypto_tfm *tfm, u8 *outbuf, const u8 *inbuf) { + struct cast5_ctx *c = crypto_tfm_ctx(tfm); const __be32 *src = (const __be32 *)inbuf; __be32 *dst = (__be32 *)outbuf; u32 l, r, t; @@ -671,12 +667,6 @@ void __cast5_decrypt(struct cast5_ctx *c, u8 *outbuf, const u8 *inbuf) dst[0] = cpu_to_be32(r); dst[1] = cpu_to_be32(l); } -EXPORT_SYMBOL_GPL(__cast5_decrypt); - -static void cast5_decrypt(struct crypto_tfm *tfm, u8 *outbuf, const u8 *inbuf) -{ - __cast5_decrypt(crypto_tfm_ctx(tfm), outbuf, inbuf); -} static void key_schedule(u32 *x, u32 *z, u32 *k) { @@ -753,7 +743,7 @@ static void key_schedule(u32 *x, u32 *z, u32 *k) } -int cast5_setkey(struct crypto_tfm *tfm, const u8 *key, unsigned int key_len) +static int cast5_setkey(struct crypto_tfm *tfm, const u8 *key, unsigned key_len) { struct cast5_ctx *c = crypto_tfm_ctx(tfm); int i; @@ -781,22 +771,20 @@ int cast5_setkey(struct crypto_tfm *tfm, const u8 *key, unsigned int key_len) c->Kr[i] = k[i] & 0x1f; return 0; } -EXPORT_SYMBOL_GPL(cast5_setkey); static struct crypto_alg alg = { - .cra_name = "cast5", - .cra_driver_name = "cast5-generic", - .cra_priority = 100, - .cra_flags = CRYPTO_ALG_TYPE_CIPHER, - .cra_blocksize = CAST5_BLOCK_SIZE, - .cra_ctxsize = sizeof(struct cast5_ctx), - .cra_alignmask = 3, - .cra_module = THIS_MODULE, - .cra_u = { + .cra_name = "cast5", + .cra_flags = CRYPTO_ALG_TYPE_CIPHER, + .cra_blocksize = CAST5_BLOCK_SIZE, + .cra_ctxsize = sizeof(struct cast5_ctx), + .cra_alignmask = 3, + .cra_module = THIS_MODULE, + .cra_list = LIST_HEAD_INIT(alg.cra_list), + .cra_u = { .cipher = { .cia_min_keysize = CAST5_MIN_KEY_SIZE, .cia_max_keysize = CAST5_MAX_KEY_SIZE, - .cia_setkey = cast5_setkey, + .cia_setkey = cast5_setkey, .cia_encrypt = cast5_encrypt, .cia_decrypt = cast5_decrypt } @@ -818,4 +806,4 @@ module_exit(cast5_mod_fini); MODULE_LICENSE("GPL"); MODULE_DESCRIPTION("Cast5 Cipher Algorithm"); -MODULE_ALIAS("cast5"); + diff --git a/trunk/crypto/cast6_generic.c b/trunk/crypto/cast6.c similarity index 93% rename from trunk/crypto/cast6_generic.c rename to trunk/crypto/cast6.c index 1acd2f1c48fc..e0c15a6c7c34 100644 --- a/trunk/crypto/cast6_generic.c +++ b/trunk/crypto/cast6.c @@ -25,21 +25,24 @@ #include #include #include -#include -#define s1 cast6_s1 -#define s2 cast6_s2 -#define s3 cast6_s3 -#define s4 cast6_s4 +#define CAST6_BLOCK_SIZE 16 +#define CAST6_MIN_KEY_SIZE 16 +#define CAST6_MAX_KEY_SIZE 32 + +struct cast6_ctx { + u32 Km[12][4]; + u8 Kr[12][4]; +}; #define F1(D, r, m) ((I = ((m) + (D))), (I = rol32(I, (r))), \ - (((s1[I >> 24] ^ s2[(I>>16)&0xff]) - s3[(I>>8)&0xff]) + s4[I&0xff])) + (((s1[I >> 24] ^ s2[(I>>16)&0xff]) - s3[(I>>8)&0xff]) + s4[I&0xff])) #define F2(D, r, m) ((I = ((m) ^ (D))), (I = rol32(I, (r))), \ - (((s1[I >> 24] - s2[(I>>16)&0xff]) + s3[(I>>8)&0xff]) ^ s4[I&0xff])) + (((s1[I >> 24] - s2[(I>>16)&0xff]) + s3[(I>>8)&0xff]) ^ s4[I&0xff])) #define F3(D, r, m) ((I = ((m) - (D))), (I = rol32(I, (r))), \ - (((s1[I >> 24] + s2[(I>>16)&0xff]) ^ s3[(I>>8)&0xff]) - s4[I&0xff])) + (((s1[I >> 24] + s2[(I>>16)&0xff]) ^ s3[(I>>8)&0xff]) - s4[I&0xff])) -const u32 cast6_s1[256] = { +static const u32 s1[256] = { 0x30fb40d4, 0x9fa0ff0b, 0x6beccd2f, 0x3f258c7a, 0x1e213f2f, 0x9c004dd3, 0x6003e540, 0xcf9fc949, 0xbfd4af27, 0x88bbbdb5, 0xe2034090, 0x98d09675, 0x6e63a0e0, @@ -105,9 +108,8 @@ const u32 cast6_s1[256] = { 0x1a69e783, 0x02cc4843, 0xa2f7c579, 0x429ef47d, 0x427b169c, 0x5ac9f049, 0xdd8f0f00, 0x5c8165bf }; -EXPORT_SYMBOL_GPL(cast6_s1); -const u32 cast6_s2[256] = { +static const u32 s2[256] = { 0x1f201094, 0xef0ba75b, 0x69e3cf7e, 0x393f4380, 0xfe61cf7a, 0xeec5207a, 0x55889c94, 0x72fc0651, 0xada7ef79, 0x4e1d7235, 0xd55a63ce, 0xde0436ba, 0x99c430ef, @@ -173,9 +175,8 @@ const u32 cast6_s2[256] = { 0x43d79572, 0x7e6dd07c, 0x06dfdf1e, 0x6c6cc4ef, 0x7160a539, 0x73bfbe70, 0x83877605, 0x4523ecf1 }; -EXPORT_SYMBOL_GPL(cast6_s2); -const u32 cast6_s3[256] = { +static const u32 s3[256] = { 0x8defc240, 0x25fa5d9f, 0xeb903dbf, 0xe810c907, 0x47607fff, 0x369fe44b, 0x8c1fc644, 0xaececa90, 0xbeb1f9bf, 0xeefbcaea, 0xe8cf1950, 0x51df07ae, 0x920e8806, @@ -241,9 +242,8 @@ const u32 cast6_s3[256] = { 0xf7baefd5, 0x4142ed9c, 0xa4315c11, 0x83323ec5, 0xdfef4636, 0xa133c501, 0xe9d3531c, 0xee353783 }; -EXPORT_SYMBOL_GPL(cast6_s3); -const u32 cast6_s4[256] = { +static const u32 s4[256] = { 0x9db30420, 0x1fb6e9de, 0xa7be7bef, 0xd273a298, 0x4a4f7bdb, 0x64ad8c57, 0x85510443, 0xfa020ed1, 0x7e287aff, 0xe60fb663, 0x095f35a1, 0x79ebf120, 0xfd059d43, @@ -309,7 +309,6 @@ const u32 cast6_s4[256] = { 0x7ae5290c, 0x3cb9536b, 0x851e20fe, 0x9833557e, 0x13ecf0b0, 0xd3ffb372, 0x3f85c5c1, 0x0aef7ed2 }; -EXPORT_SYMBOL_GPL(cast6_s4); static const u32 Tm[24][8] = { { 0x5a827999, 0xc95c653a, 0x383650db, 0xa7103c7c, 0x15ea281d, @@ -370,7 +369,7 @@ static const u8 Tr[4][8] = { }; /* forward octave */ -static inline void W(u32 *key, unsigned int i) +static void W(u32 *key, unsigned int i) { u32 I; key[6] ^= F1(key[7], Tr[i % 4][0], Tm[i][0]); @@ -383,12 +382,14 @@ static inline void W(u32 *key, unsigned int i) key[7] ^= F2(key[0], Tr[i % 4][7], Tm[i][7]); } -int __cast6_setkey(struct cast6_ctx *c, const u8 *in_key, - unsigned key_len, u32 *flags) +static int cast6_setkey(struct crypto_tfm *tfm, const u8 *in_key, + unsigned key_len) { int i; u32 key[8]; __be32 p_key[8]; /* padded key */ + struct cast6_ctx *c = crypto_tfm_ctx(tfm); + u32 *flags = &tfm->crt_flags; if (key_len % 4 != 0) { *flags |= CRYPTO_TFM_RES_BAD_KEY_LEN; @@ -424,17 +425,9 @@ int __cast6_setkey(struct cast6_ctx *c, const u8 *in_key, return 0; } -EXPORT_SYMBOL_GPL(__cast6_setkey); - -int cast6_setkey(struct crypto_tfm *tfm, const u8 *key, unsigned int keylen) -{ - return __cast6_setkey(crypto_tfm_ctx(tfm), key, keylen, - &tfm->crt_flags); -} -EXPORT_SYMBOL_GPL(cast6_setkey); /*forward quad round*/ -static inline void Q(u32 *block, u8 *Kr, u32 *Km) +static void Q(u32 *block, u8 *Kr, u32 *Km) { u32 I; block[2] ^= F1(block[3], Kr[0], Km[0]); @@ -444,7 +437,7 @@ static inline void Q(u32 *block, u8 *Kr, u32 *Km) } /*reverse quad round*/ -static inline void QBAR(u32 *block, u8 *Kr, u32 *Km) +static void QBAR(u32 *block, u8 *Kr, u32 *Km) { u32 I; block[3] ^= F1(block[0], Kr[3], Km[3]); @@ -453,8 +446,9 @@ static inline void QBAR(u32 *block, u8 *Kr, u32 *Km) block[2] ^= F1(block[3], Kr[0], Km[0]); } -void __cast6_encrypt(struct cast6_ctx *c, u8 *outbuf, const u8 *inbuf) +static void cast6_encrypt(struct crypto_tfm *tfm, u8 *outbuf, const u8 *inbuf) { + struct cast6_ctx *c = crypto_tfm_ctx(tfm); const __be32 *src = (const __be32 *)inbuf; __be32 *dst = (__be32 *)outbuf; u32 block[4]; @@ -484,15 +478,10 @@ void __cast6_encrypt(struct cast6_ctx *c, u8 *outbuf, const u8 *inbuf) dst[2] = cpu_to_be32(block[2]); dst[3] = cpu_to_be32(block[3]); } -EXPORT_SYMBOL_GPL(__cast6_encrypt); -static void cast6_encrypt(struct crypto_tfm *tfm, u8 *outbuf, const u8 *inbuf) -{ - __cast6_encrypt(crypto_tfm_ctx(tfm), outbuf, inbuf); -} - -void __cast6_decrypt(struct cast6_ctx *c, u8 *outbuf, const u8 *inbuf) +static void cast6_decrypt(struct crypto_tfm *tfm, u8 *outbuf, const u8 *inbuf) { + struct cast6_ctx *c = crypto_tfm_ctx(tfm); const __be32 *src = (const __be32 *)inbuf; __be32 *dst = (__be32 *)outbuf; u32 block[4]; @@ -522,22 +511,15 @@ void __cast6_decrypt(struct cast6_ctx *c, u8 *outbuf, const u8 *inbuf) dst[2] = cpu_to_be32(block[2]); dst[3] = cpu_to_be32(block[3]); } -EXPORT_SYMBOL_GPL(__cast6_decrypt); - -static void cast6_decrypt(struct crypto_tfm *tfm, u8 *outbuf, const u8 *inbuf) -{ - __cast6_decrypt(crypto_tfm_ctx(tfm), outbuf, inbuf); -} static struct crypto_alg alg = { .cra_name = "cast6", - .cra_driver_name = "cast6-generic", - .cra_priority = 100, .cra_flags = CRYPTO_ALG_TYPE_CIPHER, .cra_blocksize = CAST6_BLOCK_SIZE, .cra_ctxsize = sizeof(struct cast6_ctx), .cra_alignmask = 3, .cra_module = THIS_MODULE, + .cra_list = LIST_HEAD_INIT(alg.cra_list), .cra_u = { .cipher = { .cia_min_keysize = CAST6_MIN_KEY_SIZE, @@ -563,4 +545,3 @@ module_exit(cast6_mod_fini); MODULE_LICENSE("GPL"); MODULE_DESCRIPTION("Cast6 Cipher Algorithm"); -MODULE_ALIAS("cast6"); diff --git a/trunk/crypto/crypto_null.c b/trunk/crypto/crypto_null.c index fee7265cd35d..07a8a96d46fc 100644 --- a/trunk/crypto/crypto_null.c +++ b/trunk/crypto/crypto_null.c @@ -94,6 +94,18 @@ static int skcipher_null_crypt(struct blkcipher_desc *desc, return err; } +static struct crypto_alg compress_null = { + .cra_name = "compress_null", + .cra_flags = CRYPTO_ALG_TYPE_COMPRESS, + .cra_blocksize = NULL_BLOCK_SIZE, + .cra_ctxsize = 0, + .cra_module = THIS_MODULE, + .cra_list = LIST_HEAD_INIT(compress_null.cra_list), + .cra_u = { .compress = { + .coa_compress = null_compress, + .coa_decompress = null_compress } } +}; + static struct shash_alg digest_null = { .digestsize = NULL_DIGEST_SIZE, .setkey = null_hash_setkey, @@ -110,19 +122,22 @@ static struct shash_alg digest_null = { } }; -static struct crypto_alg null_algs[3] = { { +static struct crypto_alg cipher_null = { .cra_name = "cipher_null", .cra_flags = CRYPTO_ALG_TYPE_CIPHER, .cra_blocksize = NULL_BLOCK_SIZE, .cra_ctxsize = 0, .cra_module = THIS_MODULE, + .cra_list = LIST_HEAD_INIT(cipher_null.cra_list), .cra_u = { .cipher = { .cia_min_keysize = NULL_KEY_SIZE, .cia_max_keysize = NULL_KEY_SIZE, .cia_setkey = null_setkey, .cia_encrypt = null_crypt, .cia_decrypt = null_crypt } } -}, { +}; + +static struct crypto_alg skcipher_null = { .cra_name = "ecb(cipher_null)", .cra_driver_name = "ecb-cipher_null", .cra_priority = 100, @@ -131,6 +146,7 @@ static struct crypto_alg null_algs[3] = { { .cra_type = &crypto_blkcipher_type, .cra_ctxsize = 0, .cra_module = THIS_MODULE, + .cra_list = LIST_HEAD_INIT(skcipher_null.cra_list), .cra_u = { .blkcipher = { .min_keysize = NULL_KEY_SIZE, .max_keysize = NULL_KEY_SIZE, @@ -138,16 +154,7 @@ static struct crypto_alg null_algs[3] = { { .setkey = null_setkey, .encrypt = skcipher_null_crypt, .decrypt = skcipher_null_crypt } } -}, { - .cra_name = "compress_null", - .cra_flags = CRYPTO_ALG_TYPE_COMPRESS, - .cra_blocksize = NULL_BLOCK_SIZE, - .cra_ctxsize = 0, - .cra_module = THIS_MODULE, - .cra_u = { .compress = { - .coa_compress = null_compress, - .coa_decompress = null_compress } } -} }; +}; MODULE_ALIAS("compress_null"); MODULE_ALIAS("digest_null"); @@ -157,26 +164,40 @@ static int __init crypto_null_mod_init(void) { int ret = 0; - ret = crypto_register_algs(null_algs, ARRAY_SIZE(null_algs)); + ret = crypto_register_alg(&cipher_null); if (ret < 0) goto out; + ret = crypto_register_alg(&skcipher_null); + if (ret < 0) + goto out_unregister_cipher; + ret = crypto_register_shash(&digest_null); if (ret < 0) - goto out_unregister_algs; + goto out_unregister_skcipher; - return 0; + ret = crypto_register_alg(&compress_null); + if (ret < 0) + goto out_unregister_digest; -out_unregister_algs: - crypto_unregister_algs(null_algs, ARRAY_SIZE(null_algs)); out: return ret; + +out_unregister_digest: + crypto_unregister_shash(&digest_null); +out_unregister_skcipher: + crypto_unregister_alg(&skcipher_null); +out_unregister_cipher: + crypto_unregister_alg(&cipher_null); + goto out; } static void __exit crypto_null_mod_fini(void) { + crypto_unregister_alg(&compress_null); crypto_unregister_shash(&digest_null); - crypto_unregister_algs(null_algs, ARRAY_SIZE(null_algs)); + crypto_unregister_alg(&skcipher_null); + crypto_unregister_alg(&cipher_null); } module_init(crypto_null_mod_init); diff --git a/trunk/crypto/crypto_user.c b/trunk/crypto/crypto_user.c index 35d700a97d79..6bba414d0c61 100644 --- a/trunk/crypto/crypto_user.c +++ b/trunk/crypto/crypto_user.c @@ -30,7 +30,7 @@ #include "internal.h" -static DEFINE_MUTEX(crypto_cfg_mutex); +DEFINE_MUTEX(crypto_cfg_mutex); /* The crypto netlink socket */ static struct sock *crypto_nlsk; diff --git a/trunk/crypto/deflate.c b/trunk/crypto/deflate.c index b57d70eb156b..b0165ecad0c5 100644 --- a/trunk/crypto/deflate.c +++ b/trunk/crypto/deflate.c @@ -199,6 +199,7 @@ static struct crypto_alg alg = { .cra_flags = CRYPTO_ALG_TYPE_COMPRESS, .cra_ctxsize = sizeof(struct deflate_ctx), .cra_module = THIS_MODULE, + .cra_list = LIST_HEAD_INIT(alg.cra_list), .cra_init = deflate_init, .cra_exit = deflate_exit, .cra_u = { .compress = { diff --git a/trunk/crypto/des_generic.c b/trunk/crypto/des_generic.c index f6cf63f88468..873818d48e86 100644 --- a/trunk/crypto/des_generic.c +++ b/trunk/crypto/des_generic.c @@ -943,44 +943,59 @@ static void des3_ede_decrypt(struct crypto_tfm *tfm, u8 *dst, const u8 *src) d[1] = cpu_to_le32(L); } -static struct crypto_alg des_algs[2] = { { +static struct crypto_alg des_alg = { .cra_name = "des", .cra_flags = CRYPTO_ALG_TYPE_CIPHER, .cra_blocksize = DES_BLOCK_SIZE, .cra_ctxsize = sizeof(struct des_ctx), .cra_module = THIS_MODULE, .cra_alignmask = 3, + .cra_list = LIST_HEAD_INIT(des_alg.cra_list), .cra_u = { .cipher = { .cia_min_keysize = DES_KEY_SIZE, .cia_max_keysize = DES_KEY_SIZE, .cia_setkey = des_setkey, .cia_encrypt = des_encrypt, .cia_decrypt = des_decrypt } } -}, { +}; + +static struct crypto_alg des3_ede_alg = { .cra_name = "des3_ede", .cra_flags = CRYPTO_ALG_TYPE_CIPHER, .cra_blocksize = DES3_EDE_BLOCK_SIZE, .cra_ctxsize = sizeof(struct des3_ede_ctx), .cra_module = THIS_MODULE, .cra_alignmask = 3, + .cra_list = LIST_HEAD_INIT(des3_ede_alg.cra_list), .cra_u = { .cipher = { .cia_min_keysize = DES3_EDE_KEY_SIZE, .cia_max_keysize = DES3_EDE_KEY_SIZE, .cia_setkey = des3_ede_setkey, .cia_encrypt = des3_ede_encrypt, .cia_decrypt = des3_ede_decrypt } } -} }; +}; MODULE_ALIAS("des3_ede"); static int __init des_generic_mod_init(void) { - return crypto_register_algs(des_algs, ARRAY_SIZE(des_algs)); + int ret = 0; + + ret = crypto_register_alg(&des_alg); + if (ret < 0) + goto out; + + ret = crypto_register_alg(&des3_ede_alg); + if (ret < 0) + crypto_unregister_alg(&des_alg); +out: + return ret; } static void __exit des_generic_mod_fini(void) { - crypto_unregister_algs(des_algs, ARRAY_SIZE(des_algs)); + crypto_unregister_alg(&des3_ede_alg); + crypto_unregister_alg(&des_alg); } module_init(des_generic_mod_init); diff --git a/trunk/crypto/fcrypt.c b/trunk/crypto/fcrypt.c index 3b2cf569c684..c33107e340b6 100644 --- a/trunk/crypto/fcrypt.c +++ b/trunk/crypto/fcrypt.c @@ -396,6 +396,7 @@ static struct crypto_alg fcrypt_alg = { .cra_ctxsize = sizeof(struct fcrypt_ctx), .cra_module = THIS_MODULE, .cra_alignmask = 3, + .cra_list = LIST_HEAD_INIT(fcrypt_alg.cra_list), .cra_u = { .cipher = { .cia_min_keysize = 8, .cia_max_keysize = 8, diff --git a/trunk/crypto/ghash-generic.c b/trunk/crypto/ghash-generic.c index 9d3f0c69a86f..7835b8fc94db 100644 --- a/trunk/crypto/ghash-generic.c +++ b/trunk/crypto/ghash-generic.c @@ -153,6 +153,7 @@ static struct shash_alg ghash_alg = { .cra_blocksize = GHASH_BLOCK_SIZE, .cra_ctxsize = sizeof(struct ghash_ctx), .cra_module = THIS_MODULE, + .cra_list = LIST_HEAD_INIT(ghash_alg.base.cra_list), .cra_exit = ghash_exit_tfm, }, }; diff --git a/trunk/crypto/khazad.c b/trunk/crypto/khazad.c index 60e7cd66facc..527e4e395fc3 100644 --- a/trunk/crypto/khazad.c +++ b/trunk/crypto/khazad.c @@ -853,6 +853,7 @@ static struct crypto_alg khazad_alg = { .cra_ctxsize = sizeof (struct khazad_ctx), .cra_alignmask = 7, .cra_module = THIS_MODULE, + .cra_list = LIST_HEAD_INIT(khazad_alg.cra_list), .cra_u = { .cipher = { .cia_min_keysize = KHAZAD_KEY_SIZE, .cia_max_keysize = KHAZAD_KEY_SIZE, diff --git a/trunk/crypto/krng.c b/trunk/crypto/krng.c index a2d2b72fc135..4328bb3430ed 100644 --- a/trunk/crypto/krng.c +++ b/trunk/crypto/krng.c @@ -35,6 +35,7 @@ static struct crypto_alg krng_alg = { .cra_ctxsize = 0, .cra_type = &crypto_rng_type, .cra_module = THIS_MODULE, + .cra_list = LIST_HEAD_INIT(krng_alg.cra_list), .cra_u = { .rng = { .rng_make_random = krng_get_random, diff --git a/trunk/crypto/lzo.c b/trunk/crypto/lzo.c index 1c2aa69c54b8..b5e77077d751 100644 --- a/trunk/crypto/lzo.c +++ b/trunk/crypto/lzo.c @@ -81,6 +81,7 @@ static struct crypto_alg alg = { .cra_flags = CRYPTO_ALG_TYPE_COMPRESS, .cra_ctxsize = sizeof(struct lzo_ctx), .cra_module = THIS_MODULE, + .cra_list = LIST_HEAD_INIT(alg.cra_list), .cra_init = lzo_init, .cra_exit = lzo_exit, .cra_u = { .compress = { diff --git a/trunk/crypto/salsa20_generic.c b/trunk/crypto/salsa20_generic.c index 9a4770c02284..eac10c11685c 100644 --- a/trunk/crypto/salsa20_generic.c +++ b/trunk/crypto/salsa20_generic.c @@ -221,6 +221,7 @@ static struct crypto_alg alg = { .cra_ctxsize = sizeof(struct salsa20_ctx), .cra_alignmask = 3, .cra_module = THIS_MODULE, + .cra_list = LIST_HEAD_INIT(alg.cra_list), .cra_u = { .blkcipher = { .setkey = setkey, diff --git a/trunk/crypto/seed.c b/trunk/crypto/seed.c index 9c904d6d2151..d3e422f60556 100644 --- a/trunk/crypto/seed.c +++ b/trunk/crypto/seed.c @@ -449,6 +449,7 @@ static struct crypto_alg seed_alg = { .cra_ctxsize = sizeof(struct seed_ctx), .cra_alignmask = 3, .cra_module = THIS_MODULE, + .cra_list = LIST_HEAD_INIT(seed_alg.cra_list), .cra_u = { .cipher = { .cia_min_keysize = SEED_KEY_SIZE, diff --git a/trunk/crypto/serpent_generic.c b/trunk/crypto/serpent_generic.c index 7ddbd7e88859..8f32cf35e5ce 100644 --- a/trunk/crypto/serpent_generic.c +++ b/trunk/crypto/serpent_generic.c @@ -567,6 +567,24 @@ static void serpent_decrypt(struct crypto_tfm *tfm, u8 *dst, const u8 *src) __serpent_decrypt(ctx, dst, src); } +static struct crypto_alg serpent_alg = { + .cra_name = "serpent", + .cra_driver_name = "serpent-generic", + .cra_priority = 100, + .cra_flags = CRYPTO_ALG_TYPE_CIPHER, + .cra_blocksize = SERPENT_BLOCK_SIZE, + .cra_ctxsize = sizeof(struct serpent_ctx), + .cra_alignmask = 3, + .cra_module = THIS_MODULE, + .cra_list = LIST_HEAD_INIT(serpent_alg.cra_list), + .cra_u = { .cipher = { + .cia_min_keysize = SERPENT_MIN_KEY_SIZE, + .cia_max_keysize = SERPENT_MAX_KEY_SIZE, + .cia_setkey = serpent_setkey, + .cia_encrypt = serpent_encrypt, + .cia_decrypt = serpent_decrypt } } +}; + static int tnepres_setkey(struct crypto_tfm *tfm, const u8 *key, unsigned int keylen) { @@ -619,44 +637,41 @@ static void tnepres_decrypt(struct crypto_tfm *tfm, u8 *dst, const u8 *src) d[3] = swab32(rd[0]); } -static struct crypto_alg srp_algs[2] = { { - .cra_name = "serpent", - .cra_driver_name = "serpent-generic", - .cra_priority = 100, - .cra_flags = CRYPTO_ALG_TYPE_CIPHER, - .cra_blocksize = SERPENT_BLOCK_SIZE, - .cra_ctxsize = sizeof(struct serpent_ctx), - .cra_alignmask = 3, - .cra_module = THIS_MODULE, - .cra_u = { .cipher = { - .cia_min_keysize = SERPENT_MIN_KEY_SIZE, - .cia_max_keysize = SERPENT_MAX_KEY_SIZE, - .cia_setkey = serpent_setkey, - .cia_encrypt = serpent_encrypt, - .cia_decrypt = serpent_decrypt } } -}, { +static struct crypto_alg tnepres_alg = { .cra_name = "tnepres", .cra_flags = CRYPTO_ALG_TYPE_CIPHER, .cra_blocksize = SERPENT_BLOCK_SIZE, .cra_ctxsize = sizeof(struct serpent_ctx), .cra_alignmask = 3, .cra_module = THIS_MODULE, + .cra_list = LIST_HEAD_INIT(serpent_alg.cra_list), .cra_u = { .cipher = { .cia_min_keysize = SERPENT_MIN_KEY_SIZE, .cia_max_keysize = SERPENT_MAX_KEY_SIZE, .cia_setkey = tnepres_setkey, .cia_encrypt = tnepres_encrypt, .cia_decrypt = tnepres_decrypt } } -} }; +}; static int __init serpent_mod_init(void) { - return crypto_register_algs(srp_algs, ARRAY_SIZE(srp_algs)); + int ret = crypto_register_alg(&serpent_alg); + + if (ret) + return ret; + + ret = crypto_register_alg(&tnepres_alg); + + if (ret) + crypto_unregister_alg(&serpent_alg); + + return ret; } static void __exit serpent_mod_fini(void) { - crypto_unregister_algs(srp_algs, ARRAY_SIZE(srp_algs)); + crypto_unregister_alg(&tnepres_alg); + crypto_unregister_alg(&serpent_alg); } module_init(serpent_mod_init); diff --git a/trunk/crypto/sha256_generic.c b/trunk/crypto/sha256_generic.c index c3ed4ec924e1..c48459ebf05b 100644 --- a/trunk/crypto/sha256_generic.c +++ b/trunk/crypto/sha256_generic.c @@ -336,7 +336,7 @@ static int sha256_import(struct shash_desc *desc, const void *in) return 0; } -static struct shash_alg sha256_algs[2] = { { +static struct shash_alg sha256 = { .digestsize = SHA256_DIGEST_SIZE, .init = sha256_init, .update = sha256_update, @@ -352,7 +352,9 @@ static struct shash_alg sha256_algs[2] = { { .cra_blocksize = SHA256_BLOCK_SIZE, .cra_module = THIS_MODULE, } -}, { +}; + +static struct shash_alg sha224 = { .digestsize = SHA224_DIGEST_SIZE, .init = sha224_init, .update = sha256_update, @@ -365,16 +367,29 @@ static struct shash_alg sha256_algs[2] = { { .cra_blocksize = SHA224_BLOCK_SIZE, .cra_module = THIS_MODULE, } -} }; +}; static int __init sha256_generic_mod_init(void) { - return crypto_register_shashes(sha256_algs, ARRAY_SIZE(sha256_algs)); + int ret = 0; + + ret = crypto_register_shash(&sha224); + + if (ret < 0) + return ret; + + ret = crypto_register_shash(&sha256); + + if (ret < 0) + crypto_unregister_shash(&sha224); + + return ret; } static void __exit sha256_generic_mod_fini(void) { - crypto_unregister_shashes(sha256_algs, ARRAY_SIZE(sha256_algs)); + crypto_unregister_shash(&sha224); + crypto_unregister_shash(&sha256); } module_init(sha256_generic_mod_init); diff --git a/trunk/crypto/sha512_generic.c b/trunk/crypto/sha512_generic.c index 71fcf361102d..dd30f40af9f5 100644 --- a/trunk/crypto/sha512_generic.c +++ b/trunk/crypto/sha512_generic.c @@ -242,7 +242,7 @@ static int sha384_final(struct shash_desc *desc, u8 *hash) return 0; } -static struct shash_alg sha512_algs[2] = { { +static struct shash_alg sha512 = { .digestsize = SHA512_DIGEST_SIZE, .init = sha512_init, .update = sha512_update, @@ -254,7 +254,9 @@ static struct shash_alg sha512_algs[2] = { { .cra_blocksize = SHA512_BLOCK_SIZE, .cra_module = THIS_MODULE, } -}, { +}; + +static struct shash_alg sha384 = { .digestsize = SHA384_DIGEST_SIZE, .init = sha384_init, .update = sha512_update, @@ -266,16 +268,24 @@ static struct shash_alg sha512_algs[2] = { { .cra_blocksize = SHA384_BLOCK_SIZE, .cra_module = THIS_MODULE, } -} }; +}; static int __init sha512_generic_mod_init(void) { - return crypto_register_shashes(sha512_algs, ARRAY_SIZE(sha512_algs)); + int ret = 0; + + if ((ret = crypto_register_shash(&sha384)) < 0) + goto out; + if ((ret = crypto_register_shash(&sha512)) < 0) + crypto_unregister_shash(&sha384); +out: + return ret; } static void __exit sha512_generic_mod_fini(void) { - crypto_unregister_shashes(sha512_algs, ARRAY_SIZE(sha512_algs)); + crypto_unregister_shash(&sha384); + crypto_unregister_shash(&sha512); } module_init(sha512_generic_mod_init); diff --git a/trunk/crypto/shash.c b/trunk/crypto/shash.c index f426330f1017..32067f47e6c7 100644 --- a/trunk/crypto/shash.c +++ b/trunk/crypto/shash.c @@ -629,42 +629,6 @@ int crypto_unregister_shash(struct shash_alg *alg) } EXPORT_SYMBOL_GPL(crypto_unregister_shash); -int crypto_register_shashes(struct shash_alg *algs, int count) -{ - int i, ret; - - for (i = 0; i < count; i++) { - ret = crypto_register_shash(&algs[i]); - if (ret) - goto err; - } - - return 0; - -err: - for (--i; i >= 0; --i) - crypto_unregister_shash(&algs[i]); - - return ret; -} -EXPORT_SYMBOL_GPL(crypto_register_shashes); - -int crypto_unregister_shashes(struct shash_alg *algs, int count) -{ - int i, ret; - - for (i = count - 1; i >= 0; --i) { - ret = crypto_unregister_shash(&algs[i]); - if (ret) - pr_err("Failed to unregister %s %s: %d\n", - algs[i].base.cra_driver_name, - algs[i].base.cra_name, ret); - } - - return 0; -} -EXPORT_SYMBOL_GPL(crypto_unregister_shashes); - int shash_register_instance(struct crypto_template *tmpl, struct shash_instance *inst) { diff --git a/trunk/crypto/tcrypt.c b/trunk/crypto/tcrypt.c index e87fa60f5831..5cf2ccb1540c 100644 --- a/trunk/crypto/tcrypt.c +++ b/trunk/crypto/tcrypt.c @@ -97,6 +97,7 @@ static int test_cipher_cycles(struct blkcipher_desc *desc, int enc, int ret = 0; int i; + local_bh_disable(); local_irq_disable(); /* Warm-up run. */ @@ -129,6 +130,7 @@ static int test_cipher_cycles(struct blkcipher_desc *desc, int enc, out: local_irq_enable(); + local_bh_enable(); if (ret == 0) printk("1 operation in %lu cycles (%d bytes)\n", @@ -298,6 +300,7 @@ static int test_hash_cycles_digest(struct hash_desc *desc, int i; int ret; + local_bh_disable(); local_irq_disable(); /* Warm-up run. */ @@ -324,6 +327,7 @@ static int test_hash_cycles_digest(struct hash_desc *desc, out: local_irq_enable(); + local_bh_enable(); if (ret) return ret; @@ -344,6 +348,7 @@ static int test_hash_cycles(struct hash_desc *desc, struct scatterlist *sg, if (plen == blen) return test_hash_cycles_digest(desc, sg, blen, out); + local_bh_disable(); local_irq_disable(); /* Warm-up run. */ @@ -386,6 +391,7 @@ static int test_hash_cycles(struct hash_desc *desc, struct scatterlist *sg, out: local_irq_enable(); + local_bh_enable(); if (ret) return ret; @@ -1031,16 +1037,10 @@ static int do_test(int m) case 14: ret += tcrypt_test("ecb(cast5)"); - ret += tcrypt_test("cbc(cast5)"); - ret += tcrypt_test("ctr(cast5)"); break; case 15: ret += tcrypt_test("ecb(cast6)"); - ret += tcrypt_test("cbc(cast6)"); - ret += tcrypt_test("ctr(cast6)"); - ret += tcrypt_test("lrw(cast6)"); - ret += tcrypt_test("xts(cast6)"); break; case 16: @@ -1112,9 +1112,6 @@ static int do_test(int m) case 32: ret += tcrypt_test("ecb(camellia)"); ret += tcrypt_test("cbc(camellia)"); - ret += tcrypt_test("ctr(camellia)"); - ret += tcrypt_test("lrw(camellia)"); - ret += tcrypt_test("xts(camellia)"); break; case 33: ret += tcrypt_test("sha224"); @@ -1168,10 +1165,6 @@ static int do_test(int m) ret += tcrypt_test("rfc4309(ccm(aes))"); break; - case 46: - ret += tcrypt_test("ghash"); - break; - case 100: ret += tcrypt_test("hmac(md5)"); break; @@ -1366,44 +1359,6 @@ static int do_test(int m) speed_template_8); break; - case 209: - test_cipher_speed("ecb(cast5)", ENCRYPT, sec, NULL, 0, - speed_template_8_16); - test_cipher_speed("ecb(cast5)", DECRYPT, sec, NULL, 0, - speed_template_8_16); - test_cipher_speed("cbc(cast5)", ENCRYPT, sec, NULL, 0, - speed_template_8_16); - test_cipher_speed("cbc(cast5)", DECRYPT, sec, NULL, 0, - speed_template_8_16); - test_cipher_speed("ctr(cast5)", ENCRYPT, sec, NULL, 0, - speed_template_8_16); - test_cipher_speed("ctr(cast5)", DECRYPT, sec, NULL, 0, - speed_template_8_16); - break; - - case 210: - test_cipher_speed("ecb(cast6)", ENCRYPT, sec, NULL, 0, - speed_template_16_32); - test_cipher_speed("ecb(cast6)", DECRYPT, sec, NULL, 0, - speed_template_16_32); - test_cipher_speed("cbc(cast6)", ENCRYPT, sec, NULL, 0, - speed_template_16_32); - test_cipher_speed("cbc(cast6)", DECRYPT, sec, NULL, 0, - speed_template_16_32); - test_cipher_speed("ctr(cast6)", ENCRYPT, sec, NULL, 0, - speed_template_16_32); - test_cipher_speed("ctr(cast6)", DECRYPT, sec, NULL, 0, - speed_template_16_32); - test_cipher_speed("lrw(cast6)", ENCRYPT, sec, NULL, 0, - speed_template_32_48); - test_cipher_speed("lrw(cast6)", DECRYPT, sec, NULL, 0, - speed_template_32_48); - test_cipher_speed("xts(cast6)", ENCRYPT, sec, NULL, 0, - speed_template_32_64); - test_cipher_speed("xts(cast6)", DECRYPT, sec, NULL, 0, - speed_template_32_64); - break; - case 300: /* fall through */ @@ -1684,44 +1639,6 @@ static int do_test(int m) speed_template_8); break; - case 506: - test_acipher_speed("ecb(cast5)", ENCRYPT, sec, NULL, 0, - speed_template_8_16); - test_acipher_speed("ecb(cast5)", DECRYPT, sec, NULL, 0, - speed_template_8_16); - test_acipher_speed("cbc(cast5)", ENCRYPT, sec, NULL, 0, - speed_template_8_16); - test_acipher_speed("cbc(cast5)", DECRYPT, sec, NULL, 0, - speed_template_8_16); - test_acipher_speed("ctr(cast5)", ENCRYPT, sec, NULL, 0, - speed_template_8_16); - test_acipher_speed("ctr(cast5)", DECRYPT, sec, NULL, 0, - speed_template_8_16); - break; - - case 507: - test_acipher_speed("ecb(cast6)", ENCRYPT, sec, NULL, 0, - speed_template_16_32); - test_acipher_speed("ecb(cast6)", DECRYPT, sec, NULL, 0, - speed_template_16_32); - test_acipher_speed("cbc(cast6)", ENCRYPT, sec, NULL, 0, - speed_template_16_32); - test_acipher_speed("cbc(cast6)", DECRYPT, sec, NULL, 0, - speed_template_16_32); - test_acipher_speed("ctr(cast6)", ENCRYPT, sec, NULL, 0, - speed_template_16_32); - test_acipher_speed("ctr(cast6)", DECRYPT, sec, NULL, 0, - speed_template_16_32); - test_acipher_speed("lrw(cast6)", ENCRYPT, sec, NULL, 0, - speed_template_32_48); - test_acipher_speed("lrw(cast6)", DECRYPT, sec, NULL, 0, - speed_template_32_48); - test_acipher_speed("xts(cast6)", ENCRYPT, sec, NULL, 0, - speed_template_32_64); - test_acipher_speed("xts(cast6)", DECRYPT, sec, NULL, 0, - speed_template_32_64); - break; - case 1000: test_available(); break; diff --git a/trunk/crypto/tcrypt.h b/trunk/crypto/tcrypt.h index cd2068524f3f..5be1fc8c1ab3 100644 --- a/trunk/crypto/tcrypt.h +++ b/trunk/crypto/tcrypt.h @@ -47,7 +47,6 @@ static struct cipher_speed_template des3_speed_template[] = { */ static u8 speed_template_8[] = {8, 0}; static u8 speed_template_24[] = {24, 0}; -static u8 speed_template_8_16[] = {8, 16, 0}; static u8 speed_template_8_32[] = {8, 32, 0}; static u8 speed_template_16_32[] = {16, 32, 0}; static u8 speed_template_16_24_32[] = {16, 24, 32, 0}; diff --git a/trunk/crypto/tea.c b/trunk/crypto/tea.c index 0a572323ee4a..412bc74f8179 100644 --- a/trunk/crypto/tea.c +++ b/trunk/crypto/tea.c @@ -219,55 +219,84 @@ static void xeta_decrypt(struct crypto_tfm *tfm, u8 *dst, const u8 *src) out[1] = cpu_to_le32(z); } -static struct crypto_alg tea_algs[3] = { { +static struct crypto_alg tea_alg = { .cra_name = "tea", .cra_flags = CRYPTO_ALG_TYPE_CIPHER, .cra_blocksize = TEA_BLOCK_SIZE, .cra_ctxsize = sizeof (struct tea_ctx), .cra_alignmask = 3, .cra_module = THIS_MODULE, + .cra_list = LIST_HEAD_INIT(tea_alg.cra_list), .cra_u = { .cipher = { .cia_min_keysize = TEA_KEY_SIZE, .cia_max_keysize = TEA_KEY_SIZE, .cia_setkey = tea_setkey, .cia_encrypt = tea_encrypt, .cia_decrypt = tea_decrypt } } -}, { +}; + +static struct crypto_alg xtea_alg = { .cra_name = "xtea", .cra_flags = CRYPTO_ALG_TYPE_CIPHER, .cra_blocksize = XTEA_BLOCK_SIZE, .cra_ctxsize = sizeof (struct xtea_ctx), .cra_alignmask = 3, .cra_module = THIS_MODULE, + .cra_list = LIST_HEAD_INIT(xtea_alg.cra_list), .cra_u = { .cipher = { .cia_min_keysize = XTEA_KEY_SIZE, .cia_max_keysize = XTEA_KEY_SIZE, .cia_setkey = xtea_setkey, .cia_encrypt = xtea_encrypt, .cia_decrypt = xtea_decrypt } } -}, { +}; + +static struct crypto_alg xeta_alg = { .cra_name = "xeta", .cra_flags = CRYPTO_ALG_TYPE_CIPHER, .cra_blocksize = XTEA_BLOCK_SIZE, .cra_ctxsize = sizeof (struct xtea_ctx), .cra_alignmask = 3, .cra_module = THIS_MODULE, + .cra_list = LIST_HEAD_INIT(xtea_alg.cra_list), .cra_u = { .cipher = { .cia_min_keysize = XTEA_KEY_SIZE, .cia_max_keysize = XTEA_KEY_SIZE, .cia_setkey = xtea_setkey, .cia_encrypt = xeta_encrypt, .cia_decrypt = xeta_decrypt } } -} }; +}; static int __init tea_mod_init(void) { - return crypto_register_algs(tea_algs, ARRAY_SIZE(tea_algs)); + int ret = 0; + + ret = crypto_register_alg(&tea_alg); + if (ret < 0) + goto out; + + ret = crypto_register_alg(&xtea_alg); + if (ret < 0) { + crypto_unregister_alg(&tea_alg); + goto out; + } + + ret = crypto_register_alg(&xeta_alg); + if (ret < 0) { + crypto_unregister_alg(&tea_alg); + crypto_unregister_alg(&xtea_alg); + goto out; + } + +out: + return ret; } static void __exit tea_mod_fini(void) { - crypto_unregister_algs(tea_algs, ARRAY_SIZE(tea_algs)); + crypto_unregister_alg(&tea_alg); + crypto_unregister_alg(&xtea_alg); + crypto_unregister_alg(&xeta_alg); } MODULE_ALIAS("xtea"); diff --git a/trunk/crypto/testmgr.c b/trunk/crypto/testmgr.c index 941d75cd1f7c..a2ca7431760a 100644 --- a/trunk/crypto/testmgr.c +++ b/trunk/crypto/testmgr.c @@ -358,9 +358,8 @@ static int test_hash(struct crypto_ahash *tfm, struct hash_testvec *template, return ret; } -static int __test_aead(struct crypto_aead *tfm, int enc, - struct aead_testvec *template, unsigned int tcount, - const bool diff_dst) +static int test_aead(struct crypto_aead *tfm, int enc, + struct aead_testvec *template, unsigned int tcount) { const char *algo = crypto_tfm_alg_driver_name(crypto_aead_tfm(tfm)); unsigned int i, j, k, n, temp; @@ -368,18 +367,15 @@ static int __test_aead(struct crypto_aead *tfm, int enc, char *q; char *key; struct aead_request *req; - struct scatterlist *sg; - struct scatterlist *asg; - struct scatterlist *sgout; - const char *e, *d; + struct scatterlist sg[8]; + struct scatterlist asg[8]; + const char *e; struct tcrypt_result result; unsigned int authsize; void *input; - void *output; void *assoc; char iv[MAX_IVLEN]; char *xbuf[XBUFSIZE]; - char *xoutbuf[XBUFSIZE]; char *axbuf[XBUFSIZE]; if (testmgr_alloc_buf(xbuf)) @@ -387,21 +383,6 @@ static int __test_aead(struct crypto_aead *tfm, int enc, if (testmgr_alloc_buf(axbuf)) goto out_noaxbuf; - if (diff_dst && testmgr_alloc_buf(xoutbuf)) - goto out_nooutbuf; - - /* avoid "the frame size is larger than 1024 bytes" compiler warning */ - sg = kmalloc(sizeof(*sg) * 8 * (diff_dst ? 3 : 2), GFP_KERNEL); - if (!sg) - goto out_nosg; - asg = &sg[8]; - sgout = &asg[8]; - - if (diff_dst) - d = "-ddst"; - else - d = ""; - if (enc == ENCRYPT) e = "encryption"; else @@ -411,8 +392,8 @@ static int __test_aead(struct crypto_aead *tfm, int enc, req = aead_request_alloc(tfm, GFP_KERNEL); if (!req) { - pr_err("alg: aead%s: Failed to allocate request for %s\n", - d, algo); + printk(KERN_ERR "alg: aead: Failed to allocate request for " + "%s\n", algo); goto out; } @@ -451,8 +432,9 @@ static int __test_aead(struct crypto_aead *tfm, int enc, ret = crypto_aead_setkey(tfm, key, template[i].klen); if (!ret == template[i].fail) { - pr_err("alg: aead%s: setkey failed on test %d for %s: flags=%x\n", - d, j, algo, crypto_aead_get_flags(tfm)); + printk(KERN_ERR "alg: aead: setkey failed on " + "test %d for %s: flags=%x\n", j, algo, + crypto_aead_get_flags(tfm)); goto out; } else if (ret) continue; @@ -460,26 +442,18 @@ static int __test_aead(struct crypto_aead *tfm, int enc, authsize = abs(template[i].rlen - template[i].ilen); ret = crypto_aead_setauthsize(tfm, authsize); if (ret) { - pr_err("alg: aead%s: Failed to set authsize to %u on test %d for %s\n", - d, authsize, j, algo); + printk(KERN_ERR "alg: aead: Failed to set " + "authsize to %u on test %d for %s\n", + authsize, j, algo); goto out; } sg_init_one(&sg[0], input, template[i].ilen + (enc ? authsize : 0)); - if (diff_dst) { - output = xoutbuf[0]; - sg_init_one(&sgout[0], output, - template[i].ilen + - (enc ? authsize : 0)); - } else { - output = input; - } - sg_init_one(&asg[0], assoc, template[i].alen); - aead_request_set_crypt(req, sg, (diff_dst) ? sgout : sg, + aead_request_set_crypt(req, sg, sg, template[i].ilen, iv); aead_request_set_assoc(req, asg, template[i].alen); @@ -492,8 +466,10 @@ static int __test_aead(struct crypto_aead *tfm, int enc, case 0: if (template[i].novrfy) { /* verification was supposed to fail */ - pr_err("alg: aead%s: %s failed on test %d for %s: ret was 0, expected -EBADMSG\n", - d, e, j, algo); + printk(KERN_ERR "alg: aead: %s failed " + "on test %d for %s: ret was 0, " + "expected -EBADMSG\n", + e, j, algo); /* so really, we got a bad message */ ret = -EBADMSG; goto out; @@ -513,15 +489,15 @@ static int __test_aead(struct crypto_aead *tfm, int enc, continue; /* fall through */ default: - pr_err("alg: aead%s: %s failed on test %d for %s: ret=%d\n", - d, e, j, algo, -ret); + printk(KERN_ERR "alg: aead: %s failed on test " + "%d for %s: ret=%d\n", e, j, algo, -ret); goto out; } - q = output; + q = input; if (memcmp(q, template[i].result, template[i].rlen)) { - pr_err("alg: aead%s: Test %d failed on %s for %s\n", - d, j, e, algo); + printk(KERN_ERR "alg: aead: Test %d failed on " + "%s for %s\n", j, e, algo); hexdump(q, template[i].rlen); ret = -EINVAL; goto out; @@ -546,8 +522,9 @@ static int __test_aead(struct crypto_aead *tfm, int enc, ret = crypto_aead_setkey(tfm, key, template[i].klen); if (!ret == template[i].fail) { - pr_err("alg: aead%s: setkey failed on chunk test %d for %s: flags=%x\n", - d, j, algo, crypto_aead_get_flags(tfm)); + printk(KERN_ERR "alg: aead: setkey failed on " + "chunk test %d for %s: flags=%x\n", j, + algo, crypto_aead_get_flags(tfm)); goto out; } else if (ret) continue; @@ -556,8 +533,6 @@ static int __test_aead(struct crypto_aead *tfm, int enc, ret = -EINVAL; sg_init_table(sg, template[i].np); - if (diff_dst) - sg_init_table(sgout, template[i].np); for (k = 0, temp = 0; k < template[i].np; k++) { if (WARN_ON(offset_in_page(IDX[k]) + template[i].tap[k] > PAGE_SIZE)) @@ -576,26 +551,14 @@ static int __test_aead(struct crypto_aead *tfm, int enc, q[n] = 0; sg_set_buf(&sg[k], q, template[i].tap[k]); - - if (diff_dst) { - q = xoutbuf[IDX[k] >> PAGE_SHIFT] + - offset_in_page(IDX[k]); - - memset(q, 0, template[i].tap[k]); - if (offset_in_page(q) + n < PAGE_SIZE) - q[n] = 0; - - sg_set_buf(&sgout[k], q, - template[i].tap[k]); - } - temp += template[i].tap[k]; } ret = crypto_aead_setauthsize(tfm, authsize); if (ret) { - pr_err("alg: aead%s: Failed to set authsize to %u on chunk test %d for %s\n", - d, authsize, j, algo); + printk(KERN_ERR "alg: aead: Failed to set " + "authsize to %u on chunk test %d for " + "%s\n", authsize, j, algo); goto out; } @@ -608,9 +571,6 @@ static int __test_aead(struct crypto_aead *tfm, int enc, } sg[k - 1].length += authsize; - - if (diff_dst) - sgout[k - 1].length += authsize; } sg_init_table(asg, template[i].anp); @@ -628,7 +588,7 @@ static int __test_aead(struct crypto_aead *tfm, int enc, temp += template[i].atap[k]; } - aead_request_set_crypt(req, sg, (diff_dst) ? sgout : sg, + aead_request_set_crypt(req, sg, sg, template[i].ilen, iv); @@ -642,8 +602,10 @@ static int __test_aead(struct crypto_aead *tfm, int enc, case 0: if (template[i].novrfy) { /* verification was supposed to fail */ - pr_err("alg: aead%s: %s failed on chunk test %d for %s: ret was 0, expected -EBADMSG\n", - d, e, j, algo); + printk(KERN_ERR "alg: aead: %s failed " + "on chunk test %d for %s: ret " + "was 0, expected -EBADMSG\n", + e, j, algo); /* so really, we got a bad message */ ret = -EBADMSG; goto out; @@ -663,35 +625,32 @@ static int __test_aead(struct crypto_aead *tfm, int enc, continue; /* fall through */ default: - pr_err("alg: aead%s: %s failed on chunk test %d for %s: ret=%d\n", - d, e, j, algo, -ret); + printk(KERN_ERR "alg: aead: %s failed on " + "chunk test %d for %s: ret=%d\n", e, j, + algo, -ret); goto out; } ret = -EINVAL; for (k = 0, temp = 0; k < template[i].np; k++) { - if (diff_dst) - q = xoutbuf[IDX[k] >> PAGE_SHIFT] + - offset_in_page(IDX[k]); - else - q = xbuf[IDX[k] >> PAGE_SHIFT] + - offset_in_page(IDX[k]); + q = xbuf[IDX[k] >> PAGE_SHIFT] + + offset_in_page(IDX[k]); n = template[i].tap[k]; if (k == template[i].np - 1) n += enc ? authsize : -authsize; if (memcmp(q, template[i].result + temp, n)) { - pr_err("alg: aead%s: Chunk test %d failed on %s at page %u for %s\n", - d, j, e, k, algo); + printk(KERN_ERR "alg: aead: Chunk " + "test %d failed on %s at page " + "%u for %s\n", j, e, k, algo); hexdump(q, n); goto out; } q += n; if (k == template[i].np - 1 && !enc) { - if (!diff_dst && - memcmp(q, template[i].input + + if (memcmp(q, template[i].input + temp + n, authsize)) n = authsize; else @@ -702,8 +661,11 @@ static int __test_aead(struct crypto_aead *tfm, int enc, ; } if (n) { - pr_err("alg: aead%s: Result buffer corruption in chunk test %d on %s at page %u for %s: %u bytes:\n", - d, j, e, k, algo, n); + printk(KERN_ERR "alg: aead: Result " + "buffer corruption in chunk " + "test %d on %s at page %u for " + "%s: %u bytes:\n", j, e, k, + algo, n); hexdump(q, n); goto out; } @@ -717,11 +679,6 @@ static int __test_aead(struct crypto_aead *tfm, int enc, out: aead_request_free(req); - kfree(sg); -out_nosg: - if (diff_dst) - testmgr_free_buf(xoutbuf); -out_nooutbuf: testmgr_free_buf(axbuf); out_noaxbuf: testmgr_free_buf(xbuf); @@ -729,20 +686,6 @@ static int __test_aead(struct crypto_aead *tfm, int enc, return ret; } -static int test_aead(struct crypto_aead *tfm, int enc, - struct aead_testvec *template, unsigned int tcount) -{ - int ret; - - /* test 'dst == src' case */ - ret = __test_aead(tfm, enc, template, tcount, false); - if (ret) - return ret; - - /* test 'dst != src' case */ - return __test_aead(tfm, enc, template, tcount, true); -} - static int test_cipher(struct crypto_cipher *tfm, int enc, struct cipher_testvec *template, unsigned int tcount) { @@ -818,9 +761,8 @@ static int test_cipher(struct crypto_cipher *tfm, int enc, return ret; } -static int __test_skcipher(struct crypto_ablkcipher *tfm, int enc, - struct cipher_testvec *template, unsigned int tcount, - const bool diff_dst) +static int test_skcipher(struct crypto_ablkcipher *tfm, int enc, + struct cipher_testvec *template, unsigned int tcount) { const char *algo = crypto_tfm_alg_driver_name(crypto_ablkcipher_tfm(tfm)); @@ -828,26 +770,16 @@ static int __test_skcipher(struct crypto_ablkcipher *tfm, int enc, char *q; struct ablkcipher_request *req; struct scatterlist sg[8]; - struct scatterlist sgout[8]; - const char *e, *d; + const char *e; struct tcrypt_result result; void *data; char iv[MAX_IVLEN]; char *xbuf[XBUFSIZE]; - char *xoutbuf[XBUFSIZE]; int ret = -ENOMEM; if (testmgr_alloc_buf(xbuf)) goto out_nobuf; - if (diff_dst && testmgr_alloc_buf(xoutbuf)) - goto out_nooutbuf; - - if (diff_dst) - d = "-ddst"; - else - d = ""; - if (enc == ENCRYPT) e = "encryption"; else @@ -857,8 +789,8 @@ static int __test_skcipher(struct crypto_ablkcipher *tfm, int enc, req = ablkcipher_request_alloc(tfm, GFP_KERNEL); if (!req) { - pr_err("alg: skcipher%s: Failed to allocate request for %s\n", - d, algo); + printk(KERN_ERR "alg: skcipher: Failed to allocate request " + "for %s\n", algo); goto out; } @@ -872,7 +804,7 @@ static int __test_skcipher(struct crypto_ablkcipher *tfm, int enc, else memset(iv, 0, MAX_IVLEN); - if (!(template[i].np) || (template[i].also_non_np)) { + if (!(template[i].np)) { j++; ret = -EINVAL; @@ -890,21 +822,16 @@ static int __test_skcipher(struct crypto_ablkcipher *tfm, int enc, ret = crypto_ablkcipher_setkey(tfm, template[i].key, template[i].klen); if (!ret == template[i].fail) { - pr_err("alg: skcipher%s: setkey failed on test %d for %s: flags=%x\n", - d, j, algo, - crypto_ablkcipher_get_flags(tfm)); + printk(KERN_ERR "alg: skcipher: setkey failed " + "on test %d for %s: flags=%x\n", j, + algo, crypto_ablkcipher_get_flags(tfm)); goto out; } else if (ret) continue; sg_init_one(&sg[0], data, template[i].ilen); - if (diff_dst) { - data = xoutbuf[0]; - sg_init_one(&sgout[0], data, template[i].ilen); - } - ablkcipher_request_set_crypt(req, sg, - (diff_dst) ? sgout : sg, + ablkcipher_request_set_crypt(req, sg, sg, template[i].ilen, iv); ret = enc ? crypto_ablkcipher_encrypt(req) : @@ -923,15 +850,16 @@ static int __test_skcipher(struct crypto_ablkcipher *tfm, int enc, } /* fall through */ default: - pr_err("alg: skcipher%s: %s failed on test %d for %s: ret=%d\n", - d, e, j, algo, -ret); + printk(KERN_ERR "alg: skcipher: %s failed on " + "test %d for %s: ret=%d\n", e, j, algo, + -ret); goto out; } q = data; if (memcmp(q, template[i].result, template[i].rlen)) { - pr_err("alg: skcipher%s: Test %d failed on %s for %s\n", - d, j, e, algo); + printk(KERN_ERR "alg: skcipher: Test %d " + "failed on %s for %s\n", j, e, algo); hexdump(q, template[i].rlen); ret = -EINVAL; goto out; @@ -958,8 +886,9 @@ static int __test_skcipher(struct crypto_ablkcipher *tfm, int enc, ret = crypto_ablkcipher_setkey(tfm, template[i].key, template[i].klen); if (!ret == template[i].fail) { - pr_err("alg: skcipher%s: setkey failed on chunk test %d for %s: flags=%x\n", - d, j, algo, + printk(KERN_ERR "alg: skcipher: setkey failed " + "on chunk test %d for %s: flags=%x\n", + j, algo, crypto_ablkcipher_get_flags(tfm)); goto out; } else if (ret) @@ -968,8 +897,6 @@ static int __test_skcipher(struct crypto_ablkcipher *tfm, int enc, temp = 0; ret = -EINVAL; sg_init_table(sg, template[i].np); - if (diff_dst) - sg_init_table(sgout, template[i].np); for (k = 0; k < template[i].np; k++) { if (WARN_ON(offset_in_page(IDX[k]) + template[i].tap[k] > PAGE_SIZE)) @@ -986,24 +913,11 @@ static int __test_skcipher(struct crypto_ablkcipher *tfm, int enc, q[template[i].tap[k]] = 0; sg_set_buf(&sg[k], q, template[i].tap[k]); - if (diff_dst) { - q = xoutbuf[IDX[k] >> PAGE_SHIFT] + - offset_in_page(IDX[k]); - - sg_set_buf(&sgout[k], q, - template[i].tap[k]); - - memset(q, 0, template[i].tap[k]); - if (offset_in_page(q) + - template[i].tap[k] < PAGE_SIZE) - q[template[i].tap[k]] = 0; - } temp += template[i].tap[k]; } - ablkcipher_request_set_crypt(req, sg, - (diff_dst) ? sgout : sg, + ablkcipher_request_set_crypt(req, sg, sg, template[i].ilen, iv); ret = enc ? @@ -1023,25 +937,23 @@ static int __test_skcipher(struct crypto_ablkcipher *tfm, int enc, } /* fall through */ default: - pr_err("alg: skcipher%s: %s failed on chunk test %d for %s: ret=%d\n", - d, e, j, algo, -ret); + printk(KERN_ERR "alg: skcipher: %s failed on " + "chunk test %d for %s: ret=%d\n", e, j, + algo, -ret); goto out; } temp = 0; ret = -EINVAL; for (k = 0; k < template[i].np; k++) { - if (diff_dst) - q = xoutbuf[IDX[k] >> PAGE_SHIFT] + - offset_in_page(IDX[k]); - else - q = xbuf[IDX[k] >> PAGE_SHIFT] + - offset_in_page(IDX[k]); + q = xbuf[IDX[k] >> PAGE_SHIFT] + + offset_in_page(IDX[k]); if (memcmp(q, template[i].result + temp, template[i].tap[k])) { - pr_err("alg: skcipher%s: Chunk test %d failed on %s at page %u for %s\n", - d, j, e, k, algo); + printk(KERN_ERR "alg: skcipher: Chunk " + "test %d failed on %s at page " + "%u for %s\n", j, e, k, algo); hexdump(q, template[i].tap[k]); goto out; } @@ -1050,8 +962,11 @@ static int __test_skcipher(struct crypto_ablkcipher *tfm, int enc, for (n = 0; offset_in_page(q + n) && q[n]; n++) ; if (n) { - pr_err("alg: skcipher%s: Result buffer corruption in chunk test %d on %s at page %u for %s: %u bytes:\n", - d, j, e, k, algo, n); + printk(KERN_ERR "alg: skcipher: " + "Result buffer corruption in " + "chunk test %d on %s at page " + "%u for %s: %u bytes:\n", j, e, + k, algo, n); hexdump(q, n); goto out; } @@ -1064,28 +979,11 @@ static int __test_skcipher(struct crypto_ablkcipher *tfm, int enc, out: ablkcipher_request_free(req); - if (diff_dst) - testmgr_free_buf(xoutbuf); -out_nooutbuf: testmgr_free_buf(xbuf); out_nobuf: return ret; } -static int test_skcipher(struct crypto_ablkcipher *tfm, int enc, - struct cipher_testvec *template, unsigned int tcount) -{ - int ret; - - /* test 'dst == src' case */ - ret = __test_skcipher(tfm, enc, template, tcount, false); - if (ret) - return ret; - - /* test 'dst != src' case */ - return __test_skcipher(tfm, enc, template, tcount, true); -} - static int test_comp(struct crypto_comp *tfm, struct comp_testvec *ctemplate, struct comp_testvec *dtemplate, int ctcount, int dtcount) { @@ -1636,36 +1534,6 @@ static int alg_test_null(const struct alg_test_desc *desc, /* Please keep this list sorted by algorithm name. */ static const struct alg_test_desc alg_test_descs[] = { { - .alg = "__cbc-cast5-avx", - .test = alg_test_null, - .suite = { - .cipher = { - .enc = { - .vecs = NULL, - .count = 0 - }, - .dec = { - .vecs = NULL, - .count = 0 - } - } - } - }, { - .alg = "__cbc-cast6-avx", - .test = alg_test_null, - .suite = { - .cipher = { - .enc = { - .vecs = NULL, - .count = 0 - }, - .dec = { - .vecs = NULL, - .count = 0 - } - } - } - }, { .alg = "__cbc-serpent-avx", .test = alg_test_null, .suite = { @@ -1726,36 +1594,6 @@ static const struct alg_test_desc alg_test_descs[] = { } } } - }, { - .alg = "__driver-cbc-cast5-avx", - .test = alg_test_null, - .suite = { - .cipher = { - .enc = { - .vecs = NULL, - .count = 0 - }, - .dec = { - .vecs = NULL, - .count = 0 - } - } - } - }, { - .alg = "__driver-cbc-cast6-avx", - .test = alg_test_null, - .suite = { - .cipher = { - .enc = { - .vecs = NULL, - .count = 0 - }, - .dec = { - .vecs = NULL, - .count = 0 - } - } - } }, { .alg = "__driver-cbc-serpent-avx", .test = alg_test_null, @@ -1817,36 +1655,6 @@ static const struct alg_test_desc alg_test_descs[] = { } } } - }, { - .alg = "__driver-ecb-cast5-avx", - .test = alg_test_null, - .suite = { - .cipher = { - .enc = { - .vecs = NULL, - .count = 0 - }, - .dec = { - .vecs = NULL, - .count = 0 - } - } - } - }, { - .alg = "__driver-ecb-cast6-avx", - .test = alg_test_null, - .suite = { - .cipher = { - .enc = { - .vecs = NULL, - .count = 0 - }, - .dec = { - .vecs = NULL, - .count = 0 - } - } - } }, { .alg = "__driver-ecb-serpent-avx", .test = alg_test_null, @@ -2009,36 +1817,6 @@ static const struct alg_test_desc alg_test_descs[] = { } } } - }, { - .alg = "cbc(cast5)", - .test = alg_test_skcipher, - .suite = { - .cipher = { - .enc = { - .vecs = cast5_cbc_enc_tv_template, - .count = CAST5_CBC_ENC_TEST_VECTORS - }, - .dec = { - .vecs = cast5_cbc_dec_tv_template, - .count = CAST5_CBC_DEC_TEST_VECTORS - } - } - } - }, { - .alg = "cbc(cast6)", - .test = alg_test_skcipher, - .suite = { - .cipher = { - .enc = { - .vecs = cast6_cbc_enc_tv_template, - .count = CAST6_CBC_ENC_TEST_VECTORS - }, - .dec = { - .vecs = cast6_cbc_dec_tv_template, - .count = CAST6_CBC_DEC_TEST_VECTORS - } - } - } }, { .alg = "cbc(des)", .test = alg_test_skcipher, @@ -2158,36 +1936,6 @@ static const struct alg_test_desc alg_test_descs[] = { } } } - }, { - .alg = "cryptd(__driver-ecb-cast5-avx)", - .test = alg_test_null, - .suite = { - .cipher = { - .enc = { - .vecs = NULL, - .count = 0 - }, - .dec = { - .vecs = NULL, - .count = 0 - } - } - } - }, { - .alg = "cryptd(__driver-ecb-cast6-avx)", - .test = alg_test_null, - .suite = { - .cipher = { - .enc = { - .vecs = NULL, - .count = 0 - }, - .dec = { - .vecs = NULL, - .count = 0 - } - } - } }, { .alg = "cryptd(__driver-ecb-serpent-avx)", .test = alg_test_null, @@ -2305,36 +2053,6 @@ static const struct alg_test_desc alg_test_descs[] = { } } } - }, { - .alg = "ctr(cast5)", - .test = alg_test_skcipher, - .suite = { - .cipher = { - .enc = { - .vecs = cast5_ctr_enc_tv_template, - .count = CAST5_CTR_ENC_TEST_VECTORS - }, - .dec = { - .vecs = cast5_ctr_dec_tv_template, - .count = CAST5_CTR_DEC_TEST_VECTORS - } - } - } - }, { - .alg = "ctr(cast6)", - .test = alg_test_skcipher, - .suite = { - .cipher = { - .enc = { - .vecs = cast6_ctr_enc_tv_template, - .count = CAST6_CTR_ENC_TEST_VECTORS - }, - .dec = { - .vecs = cast6_ctr_dec_tv_template, - .count = CAST6_CTR_DEC_TEST_VECTORS - } - } - } }, { .alg = "ctr(serpent)", .test = alg_test_skcipher, @@ -2811,21 +2529,6 @@ static const struct alg_test_desc alg_test_descs[] = { } } } - }, { - .alg = "lrw(cast6)", - .test = alg_test_skcipher, - .suite = { - .cipher = { - .enc = { - .vecs = cast6_lrw_enc_tv_template, - .count = CAST6_LRW_ENC_TEST_VECTORS - }, - .dec = { - .vecs = cast6_lrw_dec_tv_template, - .count = CAST6_LRW_DEC_TEST_VECTORS - } - } - } }, { .alg = "lrw(serpent)", .test = alg_test_skcipher, @@ -3178,21 +2881,6 @@ static const struct alg_test_desc alg_test_descs[] = { } } } - }, { - .alg = "xts(cast6)", - .test = alg_test_skcipher, - .suite = { - .cipher = { - .enc = { - .vecs = cast6_xts_enc_tv_template, - .count = CAST6_XTS_ENC_TEST_VECTORS - }, - .dec = { - .vecs = cast6_xts_dec_tv_template, - .count = CAST6_XTS_DEC_TEST_VECTORS - } - } - } }, { .alg = "xts(serpent)", .test = alg_test_skcipher, diff --git a/trunk/crypto/testmgr.h b/trunk/crypto/testmgr.h index 76d7f6cc82f5..f8179e0344ed 100644 --- a/trunk/crypto/testmgr.h +++ b/trunk/crypto/testmgr.h @@ -53,7 +53,6 @@ struct cipher_testvec { char *result; unsigned short tap[MAX_TAP]; int np; - unsigned char also_non_np; unsigned char fail; unsigned char wk; /* weak key flag */ unsigned char klen; @@ -2469,9 +2468,6 @@ static struct cipher_testvec bf_enc_tv_template[] = { "\xC2\xF4\x6D\xFF\xF6\xCD\x6B\x40" "\xE1\xB3\xBF\xD4\x38\x2B\xC8\x3B", .rlen = 40, - .also_non_np = 1, - .np = 2, - .tap = { 40 - 8, 8 }, }, }; @@ -2545,9 +2541,6 @@ static struct cipher_testvec bf_dec_tv_template[] = { "\xAC\x20\xB7\x4E\xE5\x59\xF0\x87" "\x1E\x92\x29\xC0\x34\xCB\x62\xF9", .rlen = 40, - .also_non_np = 1, - .np = 2, - .tap = { 40 - 8, 8 }, }, }; @@ -2586,9 +2579,6 @@ static struct cipher_testvec bf_cbc_enc_tv_template[] = { "\x1B\xD9\x02\xB6\x48\xB0\x87\x25" "\x01\x9C\x93\x63\x51\x60\x82\xD2", .rlen = 40, - .also_non_np = 1, - .np = 2, - .tap = { 40 - 8, 8 }, }, }; @@ -2627,9 +2617,6 @@ static struct cipher_testvec bf_cbc_dec_tv_template[] = { "\xAC\x20\xB7\x4E\xE5\x59\xF0\x87" "\x1E\x92\x29\xC0\x34\xCB\x62\xF9", .rlen = 40, - .also_non_np = 1, - .np = 2, - .tap = { 40 - 8, 8 }, }, }; @@ -2674,144 +2661,6 @@ static struct cipher_testvec bf_ctr_enc_tv_template[] = { "\xE4\x1F\x5E\xA5\x89\xAC\x32\xBC" "\x3D\xA7\xE9", .rlen = 43, - .also_non_np = 1, - .np = 2, - .tap = { 43 - 8, 8 }, - }, { /* Generated with Crypto++ */ - .key = "\x85\x62\x3F\x1C\xF9\xD6\x1C\xF9" - "\xD6\xB3\x90\x6D\x4A\x90\x6D\x4A" - "\x27\x04\xE1\x27\x04\xE1\xBE\x9B" - "\x78\xBE\x9B\x78\x55\x32\x0F\x55", - .klen = 32, - .iv = "\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFD", - .input = "\x56\xED\x84\x1B\x8F\x26\xBD\x31" - "\xC8\x5F\xF6\x6A\x01\x98\x0C\xA3" - "\x3A\xD1\x45\xDC\x73\x0A\x7E\x15" - "\xAC\x20\xB7\x4E\xE5\x59\xF0\x87" - "\x1E\x92\x29\xC0\x34\xCB\x62\xF9" - "\x6D\x04\x9B\x0F\xA6\x3D\xD4\x48" - "\xDF\x76\x0D\x81\x18\xAF\x23\xBA" - "\x51\xE8\x5C\xF3\x8A\x21\x95\x2C" - "\xC3\x37\xCE\x65\xFC\x70\x07\x9E" - "\x12\xA9\x40\xD7\x4B\xE2\x79\x10" - "\x84\x1B\xB2\x26\xBD\x54\xEB\x5F" - "\xF6\x8D\x01\x98\x2F\xC6\x3A\xD1" - "\x68\xFF\x73\x0A\xA1\x15\xAC\x43" - "\xDA\x4E\xE5\x7C\x13\x87\x1E\xB5" - "\x29\xC0\x57\xEE\x62\xF9\x90\x04" - "\x9B\x32\xC9\x3D\xD4\x6B\x02\x76" - "\x0D\xA4\x18\xAF\x46\xDD\x51\xE8" - "\x7F\x16\x8A\x21\xB8\x2C\xC3\x5A" - "\xF1\x65\xFC\x93\x07\x9E\x35\xCC" - "\x40\xD7\x6E\x05\x79\x10\xA7\x1B" - "\xB2\x49\xE0\x54\xEB\x82\x19\x8D" - "\x24\xBB\x2F\xC6\x5D\xF4\x68\xFF" - "\x96\x0A\xA1\x38\xCF\x43\xDA\x71" - "\x08\x7C\x13\xAA\x1E\xB5\x4C\xE3" - "\x57\xEE\x85\x1C\x90\x27\xBE\x32" - "\xC9\x60\xF7\x6B\x02\x99\x0D\xA4" - "\x3B\xD2\x46\xDD\x74\x0B\x7F\x16" - "\xAD\x21\xB8\x4F\xE6\x5A\xF1\x88" - "\x1F\x93\x2A\xC1\x35\xCC\x63\xFA" - "\x6E\x05\x9C\x10\xA7\x3E\xD5\x49" - "\xE0\x77\x0E\x82\x19\xB0\x24\xBB" - "\x52\xE9\x5D\xF4\x8B\x22\x96\x2D" - "\xC4\x38\xCF\x66\xFD\x71\x08\x9F" - "\x13\xAA\x41\xD8\x4C\xE3\x7A\x11" - "\x85\x1C\xB3\x27\xBE\x55\xEC\x60" - "\xF7\x8E\x02\x99\x30\xC7\x3B\xD2" - "\x69\x00\x74\x0B\xA2\x16\xAD\x44" - "\xDB\x4F\xE6\x7D\x14\x88\x1F\xB6" - "\x2A\xC1\x58\xEF\x63\xFA\x91\x05" - "\x9C\x33\xCA\x3E\xD5\x6C\x03\x77" - "\x0E\xA5\x19\xB0\x47\xDE\x52\xE9" - "\x80\x17\x8B\x22\xB9\x2D\xC4\x5B" - "\xF2\x66\xFD\x94\x08\x9F\x36\xCD" - "\x41\xD8\x6F\x06\x7A\x11\xA8\x1C" - "\xB3\x4A\xE1\x55\xEC\x83\x1A\x8E" - "\x25\xBC\x30\xC7\x5E\xF5\x69\x00" - "\x97\x0B\xA2\x39\xD0\x44\xDB\x72" - "\x09\x7D\x14\xAB\x1F\xB6\x4D\xE4" - "\x58\xEF\x86\x1D\x91\x28\xBF\x33" - "\xCA\x61\xF8\x6C\x03\x9A\x0E\xA5" - "\x3C\xD3\x47\xDE\x75\x0C\x80\x17" - "\xAE\x22\xB9\x50\xE7\x5B\xF2\x89" - "\x20\x94\x2B\xC2\x36\xCD\x64\xFB" - "\x6F\x06\x9D\x11\xA8\x3F\xD6\x4A" - "\xE1\x78\x0F\x83\x1A\xB1\x25\xBC" - "\x53\xEA\x5E\xF5\x8C\x00\x97\x2E" - "\xC5\x39\xD0\x67\xFE\x72\x09\xA0" - "\x14\xAB\x42\xD9\x4D\xE4\x7B\x12" - "\x86\x1D\xB4\x28\xBF\x56\xED\x61" - "\xF8\x8F\x03\x9A\x31\xC8\x3C\xD3" - "\x6A\x01\x75\x0C\xA3\x17\xAE\x45" - "\xDC\x50\xE7\x7E\x15\x89\x20\xB7" - "\x2B\xC2\x59\xF0\x64\xFB\x92\x06", - .ilen = 504, - .result = "\x5F\x58\x6E\x60\x51\x6E\xDC\x3D" - "\xD1\xBB\xF7\xB7\xFD\x04\x44\x82" - "\xDC\x9F\x4B\x02\xF1\xD2\x5A\x6F" - "\x25\xF9\x27\x21\xF2\xD2\x9A\x01" - "\xBD\xAD\x3D\x93\x87\xCA\x0D\xFE" - "\xB7\x2C\x17\x1F\x42\x8C\x13\xB2" - "\x62\x44\x72\xB9\x5D\xC0\xF8\x37" - "\xDF\xEA\x78\x81\x8F\xA6\x34\xB2" - "\x07\x09\x7C\xB9\x3A\xA0\x2B\x18" - "\x34\x6A\x9D\x3D\xA5\xEB\xF4\x60" - "\xF8\x98\xA2\x39\x81\x23\x6C\xA9" - "\x70\xCA\xCC\x45\xD8\x1F\xDF\x44" - "\x2A\x67\x7A\x88\x28\xDC\x36\x83" - "\x18\xD7\x48\x43\x17\x2B\x1B\xE6" - "\x0B\x82\x59\x14\x26\x67\x08\x09" - "\x5B\x5D\x38\xD0\x81\xCE\x54\x2A" - "\xCD\x22\x94\x42\xF5\xBA\x74\x7E" - "\xD9\x00\x40\xA9\x0D\x0B\xBD\x8E" - "\xC4\x8E\x5E\x17\x8F\x48\xE2\xB8" - "\xF4\xCC\x19\x76\xAB\x48\x29\xAA" - "\x81\xD5\xCE\xD5\x8A\x3B\xC9\x21" - "\xEF\x50\x4F\x04\x02\xBF\xE1\x1F" - "\x59\x28\x1A\xE4\x18\x16\xA0\x29" - "\xBF\x34\xA9\x2D\x28\x83\xC0\x5E" - "\xEA\x44\xC4\x6E\xAB\x24\x79\x9D" - "\x2D\xA1\xE8\x55\xCA\x74\xFC\xBD" - "\xFE\xDD\xDA\xA5\xFB\x34\x90\x31" - "\x0E\x62\x28\x9B\xDC\xD7\xA1\xBB" - "\xF0\x1A\xB3\xE2\xD0\xFA\xBD\xE8" - "\x5C\x5A\x10\x67\xF6\x6A\x17\x3F" - "\xC5\xE9\x09\x08\xDD\x22\x77\x42" - "\x26\x6A\x6A\x7A\x3F\x87\x80\x0C" - "\xF0\xFF\x15\x8E\x84\x86\xC0\x10" - "\x0F\x8D\x33\x06\xB8\x72\xA4\x47" - "\x6B\xED\x2E\x05\x94\x6C\x5C\x5B" - "\x13\xF6\x77\xEE\x3B\x16\xDF\xC2" - "\x63\x66\x07\x6D\x3F\x6C\x51\x7C" - "\x1C\xAC\x80\xB6\x58\x48\xB7\x9D" - "\xB4\x19\xD8\x19\x45\x66\x27\x02" - "\xA1\xA9\x99\xF3\x1F\xE5\xA7\x1D" - "\x31\xE7\x1B\x0D\xFF\xBB\xB5\xA1" - "\xF5\x9C\x45\x1E\x18\x19\xA1\xE7" - "\xC2\xF1\xBF\x68\xC3\xEC\xCF\x53" - "\x67\xA6\x2B\x7D\x3C\x6D\x24\xC3" - "\xE8\xE6\x07\x5A\x09\xE0\x32\xA8" - "\x52\xF6\xE9\xED\x0E\xC6\x0A\x6A" - "\xFC\x60\x2A\xE0\x93\xCE\xB8\x2E" - "\xA2\xA8\x0E\x79\x9E\x34\x5D\x37" - "\x6F\x12\xFE\x48\x7B\xE7\xB9\x22" - "\x29\xE8\xD7\xBE\x5D\xD1\x8B\xD9" - "\x91\x51\x4E\x71\xF2\x98\x85\x16" - "\x25\x7A\x76\x8A\x51\x0E\x65\x14" - "\x81\xB5\x3A\x37\xFD\xEC\xB5\x8A" - "\xE1\xCF\x41\x72\x14\x29\x4C\xF0" - "\x20\xD9\x9A\xC5\x66\xA4\x03\x76" - "\x5B\xA4\x15\x4F\x0E\x64\x39\x40" - "\x25\xF9\x20\x22\xF5\x88\xF5\xBA" - "\xE4\xDF\x45\x61\xBF\x8D\x7A\x24" - "\x4B\x92\x71\xD9\x2F\x77\xA7\x95" - "\xA8\x7F\x61\xD5\xA4\x57\xB0\xFB" - "\xB5\x77\xBA\x1C\xEE\x71\xFA\xB0" - "\x16\x4C\x18\x6B\xF2\x69\xA0\x07" - "\xEF\xBE\xEC\x69\xAC\xA8\x63\x9E", - .rlen = 504, }, }; @@ -2856,144 +2705,6 @@ static struct cipher_testvec bf_ctr_dec_tv_template[] = { "\x1E\x92\x29\xC0\x34\xCB\x62\xF9" "\x6D\x04\x9B", .rlen = 43, - .also_non_np = 1, - .np = 2, - .tap = { 43 - 8, 8 }, - }, { /* Generated with Crypto++ */ - .key = "\x85\x62\x3F\x1C\xF9\xD6\x1C\xF9" - "\xD6\xB3\x90\x6D\x4A\x90\x6D\x4A" - "\x27\x04\xE1\x27\x04\xE1\xBE\x9B" - "\x78\xBE\x9B\x78\x55\x32\x0F\x55", - .klen = 32, - .iv = "\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFD", - .input = "\x5F\x58\x6E\x60\x51\x6E\xDC\x3D" - "\xD1\xBB\xF7\xB7\xFD\x04\x44\x82" - "\xDC\x9F\x4B\x02\xF1\xD2\x5A\x6F" - "\x25\xF9\x27\x21\xF2\xD2\x9A\x01" - "\xBD\xAD\x3D\x93\x87\xCA\x0D\xFE" - "\xB7\x2C\x17\x1F\x42\x8C\x13\xB2" - "\x62\x44\x72\xB9\x5D\xC0\xF8\x37" - "\xDF\xEA\x78\x81\x8F\xA6\x34\xB2" - "\x07\x09\x7C\xB9\x3A\xA0\x2B\x18" - "\x34\x6A\x9D\x3D\xA5\xEB\xF4\x60" - "\xF8\x98\xA2\x39\x81\x23\x6C\xA9" - "\x70\xCA\xCC\x45\xD8\x1F\xDF\x44" - "\x2A\x67\x7A\x88\x28\xDC\x36\x83" - "\x18\xD7\x48\x43\x17\x2B\x1B\xE6" - "\x0B\x82\x59\x14\x26\x67\x08\x09" - "\x5B\x5D\x38\xD0\x81\xCE\x54\x2A" - "\xCD\x22\x94\x42\xF5\xBA\x74\x7E" - "\xD9\x00\x40\xA9\x0D\x0B\xBD\x8E" - "\xC4\x8E\x5E\x17\x8F\x48\xE2\xB8" - "\xF4\xCC\x19\x76\xAB\x48\x29\xAA" - "\x81\xD5\xCE\xD5\x8A\x3B\xC9\x21" - "\xEF\x50\x4F\x04\x02\xBF\xE1\x1F" - "\x59\x28\x1A\xE4\x18\x16\xA0\x29" - "\xBF\x34\xA9\x2D\x28\x83\xC0\x5E" - "\xEA\x44\xC4\x6E\xAB\x24\x79\x9D" - "\x2D\xA1\xE8\x55\xCA\x74\xFC\xBD" - "\xFE\xDD\xDA\xA5\xFB\x34\x90\x31" - "\x0E\x62\x28\x9B\xDC\xD7\xA1\xBB" - "\xF0\x1A\xB3\xE2\xD0\xFA\xBD\xE8" - "\x5C\x5A\x10\x67\xF6\x6A\x17\x3F" - "\xC5\xE9\x09\x08\xDD\x22\x77\x42" - "\x26\x6A\x6A\x7A\x3F\x87\x80\x0C" - "\xF0\xFF\x15\x8E\x84\x86\xC0\x10" - "\x0F\x8D\x33\x06\xB8\x72\xA4\x47" - "\x6B\xED\x2E\x05\x94\x6C\x5C\x5B" - "\x13\xF6\x77\xEE\x3B\x16\xDF\xC2" - "\x63\x66\x07\x6D\x3F\x6C\x51\x7C" - "\x1C\xAC\x80\xB6\x58\x48\xB7\x9D" - "\xB4\x19\xD8\x19\x45\x66\x27\x02" - "\xA1\xA9\x99\xF3\x1F\xE5\xA7\x1D" - "\x31\xE7\x1B\x0D\xFF\xBB\xB5\xA1" - "\xF5\x9C\x45\x1E\x18\x19\xA1\xE7" - "\xC2\xF1\xBF\x68\xC3\xEC\xCF\x53" - "\x67\xA6\x2B\x7D\x3C\x6D\x24\xC3" - "\xE8\xE6\x07\x5A\x09\xE0\x32\xA8" - "\x52\xF6\xE9\xED\x0E\xC6\x0A\x6A" - "\xFC\x60\x2A\xE0\x93\xCE\xB8\x2E" - "\xA2\xA8\x0E\x79\x9E\x34\x5D\x37" - "\x6F\x12\xFE\x48\x7B\xE7\xB9\x22" - "\x29\xE8\xD7\xBE\x5D\xD1\x8B\xD9" - "\x91\x51\x4E\x71\xF2\x98\x85\x16" - "\x25\x7A\x76\x8A\x51\x0E\x65\x14" - "\x81\xB5\x3A\x37\xFD\xEC\xB5\x8A" - "\xE1\xCF\x41\x72\x14\x29\x4C\xF0" - "\x20\xD9\x9A\xC5\x66\xA4\x03\x76" - "\x5B\xA4\x15\x4F\x0E\x64\x39\x40" - "\x25\xF9\x20\x22\xF5\x88\xF5\xBA" - "\xE4\xDF\x45\x61\xBF\x8D\x7A\x24" - "\x4B\x92\x71\xD9\x2F\x77\xA7\x95" - "\xA8\x7F\x61\xD5\xA4\x57\xB0\xFB" - "\xB5\x77\xBA\x1C\xEE\x71\xFA\xB0" - "\x16\x4C\x18\x6B\xF2\x69\xA0\x07" - "\xEF\xBE\xEC\x69\xAC\xA8\x63\x9E", - .ilen = 504, - .result = "\x56\xED\x84\x1B\x8F\x26\xBD\x31" - "\xC8\x5F\xF6\x6A\x01\x98\x0C\xA3" - "\x3A\xD1\x45\xDC\x73\x0A\x7E\x15" - "\xAC\x20\xB7\x4E\xE5\x59\xF0\x87" - "\x1E\x92\x29\xC0\x34\xCB\x62\xF9" - "\x6D\x04\x9B\x0F\xA6\x3D\xD4\x48" - "\xDF\x76\x0D\x81\x18\xAF\x23\xBA" - "\x51\xE8\x5C\xF3\x8A\x21\x95\x2C" - "\xC3\x37\xCE\x65\xFC\x70\x07\x9E" - "\x12\xA9\x40\xD7\x4B\xE2\x79\x10" - "\x84\x1B\xB2\x26\xBD\x54\xEB\x5F" - "\xF6\x8D\x01\x98\x2F\xC6\x3A\xD1" - "\x68\xFF\x73\x0A\xA1\x15\xAC\x43" - "\xDA\x4E\xE5\x7C\x13\x87\x1E\xB5" - "\x29\xC0\x57\xEE\x62\xF9\x90\x04" - "\x9B\x32\xC9\x3D\xD4\x6B\x02\x76" - "\x0D\xA4\x18\xAF\x46\xDD\x51\xE8" - "\x7F\x16\x8A\x21\xB8\x2C\xC3\x5A" - "\xF1\x65\xFC\x93\x07\x9E\x35\xCC" - "\x40\xD7\x6E\x05\x79\x10\xA7\x1B" - "\xB2\x49\xE0\x54\xEB\x82\x19\x8D" - "\x24\xBB\x2F\xC6\x5D\xF4\x68\xFF" - "\x96\x0A\xA1\x38\xCF\x43\xDA\x71" - "\x08\x7C\x13\xAA\x1E\xB5\x4C\xE3" - "\x57\xEE\x85\x1C\x90\x27\xBE\x32" - "\xC9\x60\xF7\x6B\x02\x99\x0D\xA4" - "\x3B\xD2\x46\xDD\x74\x0B\x7F\x16" - "\xAD\x21\xB8\x4F\xE6\x5A\xF1\x88" - "\x1F\x93\x2A\xC1\x35\xCC\x63\xFA" - "\x6E\x05\x9C\x10\xA7\x3E\xD5\x49" - "\xE0\x77\x0E\x82\x19\xB0\x24\xBB" - "\x52\xE9\x5D\xF4\x8B\x22\x96\x2D" - "\xC4\x38\xCF\x66\xFD\x71\x08\x9F" - "\x13\xAA\x41\xD8\x4C\xE3\x7A\x11" - "\x85\x1C\xB3\x27\xBE\x55\xEC\x60" - "\xF7\x8E\x02\x99\x30\xC7\x3B\xD2" - "\x69\x00\x74\x0B\xA2\x16\xAD\x44" - "\xDB\x4F\xE6\x7D\x14\x88\x1F\xB6" - "\x2A\xC1\x58\xEF\x63\xFA\x91\x05" - "\x9C\x33\xCA\x3E\xD5\x6C\x03\x77" - "\x0E\xA5\x19\xB0\x47\xDE\x52\xE9" - "\x80\x17\x8B\x22\xB9\x2D\xC4\x5B" - "\xF2\x66\xFD\x94\x08\x9F\x36\xCD" - "\x41\xD8\x6F\x06\x7A\x11\xA8\x1C" - "\xB3\x4A\xE1\x55\xEC\x83\x1A\x8E" - "\x25\xBC\x30\xC7\x5E\xF5\x69\x00" - "\x97\x0B\xA2\x39\xD0\x44\xDB\x72" - "\x09\x7D\x14\xAB\x1F\xB6\x4D\xE4" - "\x58\xEF\x86\x1D\x91\x28\xBF\x33" - "\xCA\x61\xF8\x6C\x03\x9A\x0E\xA5" - "\x3C\xD3\x47\xDE\x75\x0C\x80\x17" - "\xAE\x22\xB9\x50\xE7\x5B\xF2\x89" - "\x20\x94\x2B\xC2\x36\xCD\x64\xFB" - "\x6F\x06\x9D\x11\xA8\x3F\xD6\x4A" - "\xE1\x78\x0F\x83\x1A\xB1\x25\xBC" - "\x53\xEA\x5E\xF5\x8C\x00\x97\x2E" - "\xC5\x39\xD0\x67\xFE\x72\x09\xA0" - "\x14\xAB\x42\xD9\x4D\xE4\x7B\x12" - "\x86\x1D\xB4\x28\xBF\x56\xED\x61" - "\xF8\x8F\x03\x9A\x31\xC8\x3C\xD3" - "\x6A\x01\x75\x0C\xA3\x17\xAE\x45" - "\xDC\x50\xE7\x7E\x15\x89\x20\xB7" - "\x2B\xC2\x59\xF0\x64\xFB\x92\x06", - .rlen = 504, }, }; @@ -3173,9 +2884,6 @@ static struct cipher_testvec tf_enc_tv_template[] = { "\x58\x33\x9B\x78\xC7\x58\x48\x6B" "\x2C\x75\x64\xC4\xCA\xC1\x7E\xD5", .rlen = 496, - .also_non_np = 1, - .np = 2, - .tap = { 496 - 16, 16 }, }, }; @@ -3341,9 +3049,6 @@ static struct cipher_testvec tf_dec_tv_template[] = { "\x6A\x01\x75\x0C\xA3\x17\xAE\x45" "\xDC\x50\xE7\x7E\x15\x89\x20\xB7", .rlen = 496, - .also_non_np = 1, - .np = 2, - .tap = { 496 - 16, 16 }, }, }; @@ -3524,9 +3229,6 @@ static struct cipher_testvec tf_cbc_enc_tv_template[] = { "\x30\x70\x56\xA4\x37\xDD\x7C\xC0" "\x0A\xA3\x30\x10\x26\x25\x41\x2C", .rlen = 496, - .also_non_np = 1, - .np = 2, - .tap = { 496 - 16, 16 }, }, }; @@ -3707,9 +3409,6 @@ static struct cipher_testvec tf_cbc_dec_tv_template[] = { "\x6A\x01\x75\x0C\xA3\x17\xAE\x45" "\xDC\x50\xE7\x7E\x15\x89\x20\xB7", .rlen = 496, - .also_non_np = 1, - .np = 2, - .tap = { 496 - 16, 16 }, }, }; @@ -3848,140 +3547,6 @@ static struct cipher_testvec tf_ctr_enc_tv_template[] = { "\xB9\x32\xE2\xC1\x82\xAC\xFE\xCC" "\xC5\xC9\x7F\x9E\xCF\x33\x7A\xDF", .rlen = 496, - }, { /* Generated with Crypto++ */ - .key = "\x85\x62\x3F\x1C\xF9\xD6\x1C\xF9" - "\xD6\xB3\x90\x6D\x4A\x90\x6D\x4A" - "\x27\x04\xE1\x27\x04\xE1\xBE\x9B" - "\x78\xBE\x9B\x78\x55\x32\x0F\x55", - .klen = 32, - .iv = "\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF" - "\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFD", - .input = "\x56\xED\x84\x1B\x8F\x26\xBD\x31" - "\xC8\x5F\xF6\x6A\x01\x98\x0C\xA3" - "\x3A\xD1\x45\xDC\x73\x0A\x7E\x15" - "\xAC\x20\xB7\x4E\xE5\x59\xF0\x87" - "\x1E\x92\x29\xC0\x34\xCB\x62\xF9" - "\x6D\x04\x9B\x0F\xA6\x3D\xD4\x48" - "\xDF\x76\x0D\x81\x18\xAF\x23\xBA" - "\x51\xE8\x5C\xF3\x8A\x21\x95\x2C" - "\xC3\x37\xCE\x65\xFC\x70\x07\x9E" - "\x12\xA9\x40\xD7\x4B\xE2\x79\x10" - "\x84\x1B\xB2\x26\xBD\x54\xEB\x5F" - "\xF6\x8D\x01\x98\x2F\xC6\x3A\xD1" - "\x68\xFF\x73\x0A\xA1\x15\xAC\x43" - "\xDA\x4E\xE5\x7C\x13\x87\x1E\xB5" - "\x29\xC0\x57\xEE\x62\xF9\x90\x04" - "\x9B\x32\xC9\x3D\xD4\x6B\x02\x76" - "\x0D\xA4\x18\xAF\x46\xDD\x51\xE8" - "\x7F\x16\x8A\x21\xB8\x2C\xC3\x5A" - "\xF1\x65\xFC\x93\x07\x9E\x35\xCC" - "\x40\xD7\x6E\x05\x79\x10\xA7\x1B" - "\xB2\x49\xE0\x54\xEB\x82\x19\x8D" - "\x24\xBB\x2F\xC6\x5D\xF4\x68\xFF" - "\x96\x0A\xA1\x38\xCF\x43\xDA\x71" - "\x08\x7C\x13\xAA\x1E\xB5\x4C\xE3" - "\x57\xEE\x85\x1C\x90\x27\xBE\x32" - "\xC9\x60\xF7\x6B\x02\x99\x0D\xA4" - "\x3B\xD2\x46\xDD\x74\x0B\x7F\x16" - "\xAD\x21\xB8\x4F\xE6\x5A\xF1\x88" - "\x1F\x93\x2A\xC1\x35\xCC\x63\xFA" - "\x6E\x05\x9C\x10\xA7\x3E\xD5\x49" - "\xE0\x77\x0E\x82\x19\xB0\x24\xBB" - "\x52\xE9\x5D\xF4\x8B\x22\x96\x2D" - "\xC4\x38\xCF\x66\xFD\x71\x08\x9F" - "\x13\xAA\x41\xD8\x4C\xE3\x7A\x11" - "\x85\x1C\xB3\x27\xBE\x55\xEC\x60" - "\xF7\x8E\x02\x99\x30\xC7\x3B\xD2" - "\x69\x00\x74\x0B\xA2\x16\xAD\x44" - "\xDB\x4F\xE6\x7D\x14\x88\x1F\xB6" - "\x2A\xC1\x58\xEF\x63\xFA\x91\x05" - "\x9C\x33\xCA\x3E\xD5\x6C\x03\x77" - "\x0E\xA5\x19\xB0\x47\xDE\x52\xE9" - "\x80\x17\x8B\x22\xB9\x2D\xC4\x5B" - "\xF2\x66\xFD\x94\x08\x9F\x36\xCD" - "\x41\xD8\x6F\x06\x7A\x11\xA8\x1C" - "\xB3\x4A\xE1\x55\xEC\x83\x1A\x8E" - "\x25\xBC\x30\xC7\x5E\xF5\x69\x00" - "\x97\x0B\xA2\x39\xD0\x44\xDB\x72" - "\x09\x7D\x14\xAB\x1F\xB6\x4D\xE4" - "\x58\xEF\x86\x1D\x91\x28\xBF\x33" - "\xCA\x61\xF8\x6C\x03\x9A\x0E\xA5" - "\x3C\xD3\x47\xDE\x75\x0C\x80\x17" - "\xAE\x22\xB9\x50\xE7\x5B\xF2\x89" - "\x20\x94\x2B\xC2\x36\xCD\x64\xFB" - "\x6F\x06\x9D\x11\xA8\x3F\xD6\x4A" - "\xE1\x78\x0F\x83\x1A\xB1\x25\xBC" - "\x53\xEA\x5E\xF5\x8C\x00\x97\x2E" - "\xC5\x39\xD0\x67\xFE\x72\x09\xA0" - "\x14\xAB\x42\xD9\x4D\xE4\x7B\x12" - "\x86\x1D\xB4\x28\xBF\x56\xED\x61" - "\xF8\x8F\x03\x9A\x31\xC8\x3C\xD3" - "\x6A\x01\x75\x0C\xA3\x17\xAE\x45" - "\xDC\x50\xE7\x7E\x15\x89\x20\xB7", - .ilen = 496, - .result = "\xEB\x44\xAF\x49\x27\xB8\xFB\x44" - "\x4C\xA6\xC3\x0C\x8B\xD0\x01\x0C" - "\x53\xC8\x16\x38\xDE\x40\x4F\x91" - "\x25\x6D\x4C\xA0\x9A\x87\x1E\xDA" - "\x88\x7E\x89\xE9\x67\x2B\x83\xA2" - "\x5F\x2E\x23\x3E\x45\xB9\x77\x7B" - "\xA6\x7E\x47\x36\x81\x9F\x9B\xF3" - "\xE0\xF0\xD7\x47\xA9\xC8\xEF\x33" - "\x0C\x43\xFE\x67\x50\x0A\x2C\x3E" - "\xA0\xE1\x25\x8E\x80\x07\x4A\xC0" - "\x64\x89\x9F\x6A\x27\x96\x07\xA6" - "\x9B\xC8\x1B\x21\x60\xAE\x5D\x01" - "\xE2\xCD\xC8\xAA\x6C\x9D\x1C\x34" - "\x39\x18\x09\xA4\x82\x59\x78\xE7" - "\xFC\x59\x65\xF2\x94\xFF\xFB\xE2" - "\x3C\xDA\xB1\x90\x95\xBF\x91\xE3" - "\xE6\x87\x31\x9E\x16\x85\xAD\xB1" - "\x4C\xAE\x43\x4D\x19\x58\xB5\x5E" - "\x2E\xF5\x09\xAA\x39\xF4\xC0\xB3" - "\xD4\x4D\xDB\x73\x7A\xD4\xF1\xBF" - "\x89\x16\x4D\x2D\xA2\x26\x33\x72" - "\x18\x33\x7E\xD6\xD2\x16\xA4\x54" - "\xF4\x8C\xB3\x52\xDF\x21\x9C\xEB" - "\xBF\x49\xD3\xF9\x05\x06\xCB\xD2" - "\xA9\xD2\x3B\x6E\x19\x8C\xBC\x19" - "\xAB\x89\xD6\xD8\xCD\x56\x89\x5E" - "\xAC\x00\xE3\x50\x63\x4A\x80\x9A" - "\x05\xBC\x50\x39\xD3\x32\xD9\x0D" - "\xE3\x20\x0D\x75\x54\xEC\xE6\x31" - "\x14\xB9\x3A\x59\x00\x43\x37\x8E" - "\x8C\x5A\x79\x62\x14\x76\x8A\xAE" - "\x8F\xCC\xA1\x6C\x38\x78\xDD\x2D" - "\x8B\x6D\xEA\xBD\x7B\x25\xFF\x60" - "\xC9\x87\xB1\x79\x1E\xA5\x86\x68" - "\x81\xB4\xE2\xC1\x05\x7D\x3A\x73" - "\xD0\xDA\x75\x77\x9E\x05\x27\xF1" - "\x08\xA9\x66\x64\x6C\xBC\x82\x17" - "\x2C\x23\x5F\x62\x4D\x02\x1A\x58" - "\xE7\xB7\x23\x6D\xE2\x20\xDA\xEF" - "\xB4\xB3\x3F\xB2\x2B\x69\x98\x83" - "\x95\x87\x13\x57\x60\xD7\xB5\xB1" - "\xEE\x0A\x2F\x95\x36\x4C\x76\x5D" - "\x5F\xD9\x19\xED\xB9\xA5\x48\xBF" - "\xC8\xAB\x0F\x71\xCC\x61\x8E\x0A" - "\xD0\x29\x44\xA8\xB9\xC1\xE8\xC8" - "\xC9\xA8\x28\x81\xFB\x50\xF2\xF0" - "\x26\xAE\x39\xB8\x91\xCD\xA8\xAC" - "\xDE\x55\x1B\x50\x14\x53\x44\x17" - "\x54\x46\xFC\xB1\xE4\x07\x6B\x9A" - "\x01\x14\xF0\x2E\x2E\xDB\x46\x1B" - "\x1A\x09\x97\xA9\xB6\x97\x79\x06" - "\xFB\xCB\x85\xCF\xDD\xA1\x41\xB1" - "\x00\xAA\xF7\xE0\x89\x73\xFB\xE5" - "\xBF\x84\xDB\xC9\xCD\xC4\xA2\x0D" - "\x3B\xAC\xF9\xDF\x96\xBF\x88\x23" - "\x41\x67\xA1\x24\x99\x7E\xCC\x9B" - "\x02\x8F\x6A\x49\xF6\x25\xBA\x7A" - "\xF4\x78\xFD\x79\x62\x63\x4F\x14" - "\xD6\x11\x11\x04\x05\x5F\x7E\xEA" - "\x4C\xB6\xF8\xF4\x5F\x48\x52\x54" - "\x94\x63\xA8\x4E\xCF\xD2\x1B\x1B" - "\x22\x18\x6A\xAF\x6E\x3E\xE1\x0D", - .rlen = 496, }, { /* Generated with Crypto++ */ .key = "\x85\x62\x3F\x1C\xF9\xD6\x1C\xF9" "\xD6\xB3\x90\x6D\x4A\x90\x6D\x4A" @@ -4118,9 +3683,6 @@ static struct cipher_testvec tf_ctr_enc_tv_template[] = { "\xC5\xC9\x7F\x9E\xCF\x33\x7A\xDF" "\x6C\x82\x9D", .rlen = 499, - .also_non_np = 1, - .np = 2, - .tap = { 499 - 16, 16 }, }, }; @@ -4259,140 +3821,6 @@ static struct cipher_testvec tf_ctr_dec_tv_template[] = { "\x6A\x01\x75\x0C\xA3\x17\xAE\x45" "\xDC\x50\xE7\x7E\x15\x89\x20\xB7", .rlen = 496, - }, { /* Generated with Crypto++ */ - .key = "\x85\x62\x3F\x1C\xF9\xD6\x1C\xF9" - "\xD6\xB3\x90\x6D\x4A\x90\x6D\x4A" - "\x27\x04\xE1\x27\x04\xE1\xBE\x9B" - "\x78\xBE\x9B\x78\x55\x32\x0F\x55", - .klen = 32, - .iv = "\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF" - "\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFD", - .input = "\xEB\x44\xAF\x49\x27\xB8\xFB\x44" - "\x4C\xA6\xC3\x0C\x8B\xD0\x01\x0C" - "\x53\xC8\x16\x38\xDE\x40\x4F\x91" - "\x25\x6D\x4C\xA0\x9A\x87\x1E\xDA" - "\x88\x7E\x89\xE9\x67\x2B\x83\xA2" - "\x5F\x2E\x23\x3E\x45\xB9\x77\x7B" - "\xA6\x7E\x47\x36\x81\x9F\x9B\xF3" - "\xE0\xF0\xD7\x47\xA9\xC8\xEF\x33" - "\x0C\x43\xFE\x67\x50\x0A\x2C\x3E" - "\xA0\xE1\x25\x8E\x80\x07\x4A\xC0" - "\x64\x89\x9F\x6A\x27\x96\x07\xA6" - "\x9B\xC8\x1B\x21\x60\xAE\x5D\x01" - "\xE2\xCD\xC8\xAA\x6C\x9D\x1C\x34" - "\x39\x18\x09\xA4\x82\x59\x78\xE7" - "\xFC\x59\x65\xF2\x94\xFF\xFB\xE2" - "\x3C\xDA\xB1\x90\x95\xBF\x91\xE3" - "\xE6\x87\x31\x9E\x16\x85\xAD\xB1" - "\x4C\xAE\x43\x4D\x19\x58\xB5\x5E" - "\x2E\xF5\x09\xAA\x39\xF4\xC0\xB3" - "\xD4\x4D\xDB\x73\x7A\xD4\xF1\xBF" - "\x89\x16\x4D\x2D\xA2\x26\x33\x72" - "\x18\x33\x7E\xD6\xD2\x16\xA4\x54" - "\xF4\x8C\xB3\x52\xDF\x21\x9C\xEB" - "\xBF\x49\xD3\xF9\x05\x06\xCB\xD2" - "\xA9\xD2\x3B\x6E\x19\x8C\xBC\x19" - "\xAB\x89\xD6\xD8\xCD\x56\x89\x5E" - "\xAC\x00\xE3\x50\x63\x4A\x80\x9A" - "\x05\xBC\x50\x39\xD3\x32\xD9\x0D" - "\xE3\x20\x0D\x75\x54\xEC\xE6\x31" - "\x14\xB9\x3A\x59\x00\x43\x37\x8E" - "\x8C\x5A\x79\x62\x14\x76\x8A\xAE" - "\x8F\xCC\xA1\x6C\x38\x78\xDD\x2D" - "\x8B\x6D\xEA\xBD\x7B\x25\xFF\x60" - "\xC9\x87\xB1\x79\x1E\xA5\x86\x68" - "\x81\xB4\xE2\xC1\x05\x7D\x3A\x73" - "\xD0\xDA\x75\x77\x9E\x05\x27\xF1" - "\x08\xA9\x66\x64\x6C\xBC\x82\x17" - "\x2C\x23\x5F\x62\x4D\x02\x1A\x58" - "\xE7\xB7\x23\x6D\xE2\x20\xDA\xEF" - "\xB4\xB3\x3F\xB2\x2B\x69\x98\x83" - "\x95\x87\x13\x57\x60\xD7\xB5\xB1" - "\xEE\x0A\x2F\x95\x36\x4C\x76\x5D" - "\x5F\xD9\x19\xED\xB9\xA5\x48\xBF" - "\xC8\xAB\x0F\x71\xCC\x61\x8E\x0A" - "\xD0\x29\x44\xA8\xB9\xC1\xE8\xC8" - "\xC9\xA8\x28\x81\xFB\x50\xF2\xF0" - "\x26\xAE\x39\xB8\x91\xCD\xA8\xAC" - "\xDE\x55\x1B\x50\x14\x53\x44\x17" - "\x54\x46\xFC\xB1\xE4\x07\x6B\x9A" - "\x01\x14\xF0\x2E\x2E\xDB\x46\x1B" - "\x1A\x09\x97\xA9\xB6\x97\x79\x06" - "\xFB\xCB\x85\xCF\xDD\xA1\x41\xB1" - "\x00\xAA\xF7\xE0\x89\x73\xFB\xE5" - "\xBF\x84\xDB\xC9\xCD\xC4\xA2\x0D" - "\x3B\xAC\xF9\xDF\x96\xBF\x88\x23" - "\x41\x67\xA1\x24\x99\x7E\xCC\x9B" - "\x02\x8F\x6A\x49\xF6\x25\xBA\x7A" - "\xF4\x78\xFD\x79\x62\x63\x4F\x14" - "\xD6\x11\x11\x04\x05\x5F\x7E\xEA" - "\x4C\xB6\xF8\xF4\x5F\x48\x52\x54" - "\x94\x63\xA8\x4E\xCF\xD2\x1B\x1B" - "\x22\x18\x6A\xAF\x6E\x3E\xE1\x0D", - .ilen = 496, - .result = "\x56\xED\x84\x1B\x8F\x26\xBD\x31" - "\xC8\x5F\xF6\x6A\x01\x98\x0C\xA3" - "\x3A\xD1\x45\xDC\x73\x0A\x7E\x15" - "\xAC\x20\xB7\x4E\xE5\x59\xF0\x87" - "\x1E\x92\x29\xC0\x34\xCB\x62\xF9" - "\x6D\x04\x9B\x0F\xA6\x3D\xD4\x48" - "\xDF\x76\x0D\x81\x18\xAF\x23\xBA" - "\x51\xE8\x5C\xF3\x8A\x21\x95\x2C" - "\xC3\x37\xCE\x65\xFC\x70\x07\x9E" - "\x12\xA9\x40\xD7\x4B\xE2\x79\x10" - "\x84\x1B\xB2\x26\xBD\x54\xEB\x5F" - "\xF6\x8D\x01\x98\x2F\xC6\x3A\xD1" - "\x68\xFF\x73\x0A\xA1\x15\xAC\x43" - "\xDA\x4E\xE5\x7C\x13\x87\x1E\xB5" - "\x29\xC0\x57\xEE\x62\xF9\x90\x04" - "\x9B\x32\xC9\x3D\xD4\x6B\x02\x76" - "\x0D\xA4\x18\xAF\x46\xDD\x51\xE8" - "\x7F\x16\x8A\x21\xB8\x2C\xC3\x5A" - "\xF1\x65\xFC\x93\x07\x9E\x35\xCC" - "\x40\xD7\x6E\x05\x79\x10\xA7\x1B" - "\xB2\x49\xE0\x54\xEB\x82\x19\x8D" - "\x24\xBB\x2F\xC6\x5D\xF4\x68\xFF" - "\x96\x0A\xA1\x38\xCF\x43\xDA\x71" - "\x08\x7C\x13\xAA\x1E\xB5\x4C\xE3" - "\x57\xEE\x85\x1C\x90\x27\xBE\x32" - "\xC9\x60\xF7\x6B\x02\x99\x0D\xA4" - "\x3B\xD2\x46\xDD\x74\x0B\x7F\x16" - "\xAD\x21\xB8\x4F\xE6\x5A\xF1\x88" - "\x1F\x93\x2A\xC1\x35\xCC\x63\xFA" - "\x6E\x05\x9C\x10\xA7\x3E\xD5\x49" - "\xE0\x77\x0E\x82\x19\xB0\x24\xBB" - "\x52\xE9\x5D\xF4\x8B\x22\x96\x2D" - "\xC4\x38\xCF\x66\xFD\x71\x08\x9F" - "\x13\xAA\x41\xD8\x4C\xE3\x7A\x11" - "\x85\x1C\xB3\x27\xBE\x55\xEC\x60" - "\xF7\x8E\x02\x99\x30\xC7\x3B\xD2" - "\x69\x00\x74\x0B\xA2\x16\xAD\x44" - "\xDB\x4F\xE6\x7D\x14\x88\x1F\xB6" - "\x2A\xC1\x58\xEF\x63\xFA\x91\x05" - "\x9C\x33\xCA\x3E\xD5\x6C\x03\x77" - "\x0E\xA5\x19\xB0\x47\xDE\x52\xE9" - "\x80\x17\x8B\x22\xB9\x2D\xC4\x5B" - "\xF2\x66\xFD\x94\x08\x9F\x36\xCD" - "\x41\xD8\x6F\x06\x7A\x11\xA8\x1C" - "\xB3\x4A\xE1\x55\xEC\x83\x1A\x8E" - "\x25\xBC\x30\xC7\x5E\xF5\x69\x00" - "\x97\x0B\xA2\x39\xD0\x44\xDB\x72" - "\x09\x7D\x14\xAB\x1F\xB6\x4D\xE4" - "\x58\xEF\x86\x1D\x91\x28\xBF\x33" - "\xCA\x61\xF8\x6C\x03\x9A\x0E\xA5" - "\x3C\xD3\x47\xDE\x75\x0C\x80\x17" - "\xAE\x22\xB9\x50\xE7\x5B\xF2\x89" - "\x20\x94\x2B\xC2\x36\xCD\x64\xFB" - "\x6F\x06\x9D\x11\xA8\x3F\xD6\x4A" - "\xE1\x78\x0F\x83\x1A\xB1\x25\xBC" - "\x53\xEA\x5E\xF5\x8C\x00\x97\x2E" - "\xC5\x39\xD0\x67\xFE\x72\x09\xA0" - "\x14\xAB\x42\xD9\x4D\xE4\x7B\x12" - "\x86\x1D\xB4\x28\xBF\x56\xED\x61" - "\xF8\x8F\x03\x9A\x31\xC8\x3C\xD3" - "\x6A\x01\x75\x0C\xA3\x17\xAE\x45" - "\xDC\x50\xE7\x7E\x15\x89\x20\xB7", - .rlen = 496, }, { /* Generated with Crypto++ */ .key = "\x85\x62\x3F\x1C\xF9\xD6\x1C\xF9" "\xD6\xB3\x90\x6D\x4A\x90\x6D\x4A" @@ -4529,9 +3957,6 @@ static struct cipher_testvec tf_ctr_dec_tv_template[] = { "\xDC\x50\xE7\x7E\x15\x89\x20\xB7" "\x2B\xC2\x59", .rlen = 499, - .also_non_np = 1, - .np = 2, - .tap = { 499 - 16, 16 }, }, }; @@ -4781,9 +4206,6 @@ static struct cipher_testvec tf_lrw_enc_tv_template[] = { "\x80\x18\xc4\x6c\x03\xd3\xb7\xba" "\x11\xd7\xb8\x6e\xea\xe1\x80\x30", .rlen = 512, - .also_non_np = 1, - .np = 2, - .tap = { 512 - 16, 16 }, }, }; @@ -5034,9 +4456,6 @@ static struct cipher_testvec tf_lrw_dec_tv_template[] = { "\xe9\x2e\xc4\x29\x0f\x84\xdb\xc4" "\x21\xc4\xc2\x75\x67\x89\x37\x0a", .rlen = 512, - .also_non_np = 1, - .np = 2, - .tap = { 512 - 16, 16 }, }, }; @@ -5376,9 +4795,6 @@ static struct cipher_testvec tf_xts_enc_tv_template[] = { "\xa4\x05\x0b\xb2\xb3\xa8\x30\x97" "\x37\x30\xe1\x91\x8d\xb3\x2a\xff", .rlen = 512, - .also_non_np = 1, - .np = 2, - .tap = { 512 - 16, 16 }, }, }; @@ -5719,9 +5135,6 @@ static struct cipher_testvec tf_xts_dec_tv_template[] = { "\xf0\xf1\xf2\xf3\xf4\xf5\xf6\xf7" "\xf8\xf9\xfa\xfb\xfc\xfd\xfe\xff", .rlen = 512, - .also_non_np = 1, - .np = 2, - .tap = { 512 - 16, 16 }, }, }; @@ -5829,9 +5242,6 @@ static struct cipher_testvec serpent_enc_tv_template[] = { "\x30\xD4\x2C\xF2\x8E\x06\x4B\x39" "\xB3\x12\x1D\xB3\x17\x46\xE6\xD6", .rlen = 144, - .also_non_np = 1, - .np = 2, - .tap = { 144 - 16, 16 }, }, }; @@ -5967,9 +5377,6 @@ static struct cipher_testvec serpent_dec_tv_template[] = { "\x0D\xA4\x18\xAF\x46\xDD\x51\xE8" "\x7F\x16\x8A\x21\xB8\x2C\xC3\x5A", .rlen = 144, - .also_non_np = 1, - .np = 2, - .tap = { 144 - 16, 16 }, }, }; @@ -6061,9 +5468,6 @@ static struct cipher_testvec serpent_cbc_enc_tv_template[] = { "\x27\xDF\x89\x1D\x86\x3E\xF7\x5A" "\xF6\xE3\x0F\xC7\x6B\x4C\x96\x7C", .rlen = 144, - .also_non_np = 1, - .np = 2, - .tap = { 144 - 16, 16 }, }, }; @@ -6114,9 +5518,6 @@ static struct cipher_testvec serpent_cbc_dec_tv_template[] = { "\x0D\xA4\x18\xAF\x46\xDD\x51\xE8" "\x7F\x16\x8A\x21\xB8\x2C\xC3\x5A", .rlen = 144, - .also_non_np = 1, - .np = 2, - .tap = { 144 - 16, 16 }, }, }; @@ -6215,143 +5616,6 @@ static struct cipher_testvec serpent_ctr_enc_tv_template[] = { "\x5D\xE1\x4F\xA1\xEA\xB3\xCA\xB9" "\xE6\xD0\x97", .rlen = 147, - .also_non_np = 1, - .np = 2, - .tap = { 147 - 16, 16 }, - }, { /* Generated with Crypto++ */ - .key = "\x85\x62\x3F\x1C\xF9\xD6\x1C\xF9" - "\xD6\xB3\x90\x6D\x4A\x90\x6D\x4A" - "\x27\x04\xE1\x27\x04\xE1\xBE\x9B" - "\x78\xBE\x9B\x78\x55\x32\x0F\x55", - .klen = 32, - .iv = "\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF" - "\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFD", - .input = "\x56\xED\x84\x1B\x8F\x26\xBD\x31" - "\xC8\x5F\xF6\x6A\x01\x98\x0C\xA3" - "\x3A\xD1\x45\xDC\x73\x0A\x7E\x15" - "\xAC\x20\xB7\x4E\xE5\x59\xF0\x87" - "\x1E\x92\x29\xC0\x34\xCB\x62\xF9" - "\x6D\x04\x9B\x0F\xA6\x3D\xD4\x48" - "\xDF\x76\x0D\x81\x18\xAF\x23\xBA" - "\x51\xE8\x5C\xF3\x8A\x21\x95\x2C" - "\xC3\x37\xCE\x65\xFC\x70\x07\x9E" - "\x12\xA9\x40\xD7\x4B\xE2\x79\x10" - "\x84\x1B\xB2\x26\xBD\x54\xEB\x5F" - "\xF6\x8D\x01\x98\x2F\xC6\x3A\xD1" - "\x68\xFF\x73\x0A\xA1\x15\xAC\x43" - "\xDA\x4E\xE5\x7C\x13\x87\x1E\xB5" - "\x29\xC0\x57\xEE\x62\xF9\x90\x04" - "\x9B\x32\xC9\x3D\xD4\x6B\x02\x76" - "\x0D\xA4\x18\xAF\x46\xDD\x51\xE8" - "\x7F\x16\x8A\x21\xB8\x2C\xC3\x5A" - "\xF1\x65\xFC\x93\x07\x9E\x35\xCC" - "\x40\xD7\x6E\x05\x79\x10\xA7\x1B" - "\xB2\x49\xE0\x54\xEB\x82\x19\x8D" - "\x24\xBB\x2F\xC6\x5D\xF4\x68\xFF" - "\x96\x0A\xA1\x38\xCF\x43\xDA\x71" - "\x08\x7C\x13\xAA\x1E\xB5\x4C\xE3" - "\x57\xEE\x85\x1C\x90\x27\xBE\x32" - "\xC9\x60\xF7\x6B\x02\x99\x0D\xA4" - "\x3B\xD2\x46\xDD\x74\x0B\x7F\x16" - "\xAD\x21\xB8\x4F\xE6\x5A\xF1\x88" - "\x1F\x93\x2A\xC1\x35\xCC\x63\xFA" - "\x6E\x05\x9C\x10\xA7\x3E\xD5\x49" - "\xE0\x77\x0E\x82\x19\xB0\x24\xBB" - "\x52\xE9\x5D\xF4\x8B\x22\x96\x2D" - "\xC4\x38\xCF\x66\xFD\x71\x08\x9F" - "\x13\xAA\x41\xD8\x4C\xE3\x7A\x11" - "\x85\x1C\xB3\x27\xBE\x55\xEC\x60" - "\xF7\x8E\x02\x99\x30\xC7\x3B\xD2" - "\x69\x00\x74\x0B\xA2\x16\xAD\x44" - "\xDB\x4F\xE6\x7D\x14\x88\x1F\xB6" - "\x2A\xC1\x58\xEF\x63\xFA\x91\x05" - "\x9C\x33\xCA\x3E\xD5\x6C\x03\x77" - "\x0E\xA5\x19\xB0\x47\xDE\x52\xE9" - "\x80\x17\x8B\x22\xB9\x2D\xC4\x5B" - "\xF2\x66\xFD\x94\x08\x9F\x36\xCD" - "\x41\xD8\x6F\x06\x7A\x11\xA8\x1C" - "\xB3\x4A\xE1\x55\xEC\x83\x1A\x8E" - "\x25\xBC\x30\xC7\x5E\xF5\x69\x00" - "\x97\x0B\xA2\x39\xD0\x44\xDB\x72" - "\x09\x7D\x14\xAB\x1F\xB6\x4D\xE4" - "\x58\xEF\x86\x1D\x91\x28\xBF\x33" - "\xCA\x61\xF8\x6C\x03\x9A\x0E\xA5" - "\x3C\xD3\x47\xDE\x75\x0C\x80\x17" - "\xAE\x22\xB9\x50\xE7\x5B\xF2\x89" - "\x20\x94\x2B\xC2\x36\xCD\x64\xFB" - "\x6F\x06\x9D\x11\xA8\x3F\xD6\x4A" - "\xE1\x78\x0F\x83\x1A\xB1\x25\xBC" - "\x53\xEA\x5E\xF5\x8C\x00\x97\x2E" - "\xC5\x39\xD0\x67\xFE\x72\x09\xA0" - "\x14\xAB\x42\xD9\x4D\xE4\x7B\x12" - "\x86\x1D\xB4\x28\xBF\x56\xED\x61" - "\xF8\x8F\x03\x9A\x31\xC8\x3C\xD3" - "\x6A\x01\x75\x0C\xA3\x17\xAE\x45" - "\xDC\x50\xE7\x7E\x15\x89\x20\xB7", - .ilen = 496, - .result = "\x06\x9A\xF8\xB4\x53\x88\x62\xFC" - "\x68\xB8\x2E\xDF\xC1\x05\x0F\x3D" - "\xAF\x4D\x95\xAE\xC4\xE9\x1C\xDC" - "\xF6\x2B\x8F\x90\x89\xF6\x7E\x1A" - "\xA6\xB9\xE4\xF4\xFA\xCA\xE5\x7E" - "\x71\x28\x06\x4F\xE8\x08\x39\xDA" - "\xA5\x0E\xC8\xC0\xB8\x16\xE5\x69" - "\xE5\xCA\xEC\x4F\x63\x2C\xC0\x9B" - "\x9F\x3E\x39\x79\xF0\xCD\x64\x35" - "\x4A\xD3\xC8\xA9\x31\xCD\x48\x5B" - "\x92\x3D\x8F\x3F\x96\xBD\xB3\x18" - "\x74\x2A\x5D\x29\x3F\x57\x8F\xE2" - "\x67\x9A\xE0\xE5\xD4\x4A\xE2\x47" - "\xBC\xF6\xEB\x14\xF3\x8C\x20\xC2" - "\x7D\xE2\x43\x81\x86\x72\x2E\xB1" - "\x39\xF6\x95\xE1\x1F\xCB\x76\x33" - "\x5B\x7D\x23\x0F\x3A\x67\x2A\x2F" - "\xB9\x37\x9D\xDD\x1F\x16\xA1\x3C" - "\x70\xFE\x52\xAA\x93\x3C\xC4\x46" - "\xB1\xE5\xFF\xDA\xAF\xE2\x84\xFE" - "\x25\x92\xB2\x63\xBD\x49\x77\xB4" - "\x22\xA4\x6A\xD5\x04\xE0\x45\x58" - "\x1C\x34\x96\x7C\x03\x0C\x13\xA2" - "\x05\x22\xE2\xCB\x5A\x35\x03\x09" - "\x40\xD2\x82\x05\xCA\x58\x73\xF2" - "\x29\x5E\x01\x47\x13\x32\x78\xBE" - "\x06\xB0\x51\xDB\x6C\x31\xA0\x1C" - "\x74\xBC\x8D\x25\xDF\xF8\x65\xD1" - "\x38\x35\x11\x26\x4A\xB4\x06\x32" - "\xFA\xD2\x07\x77\xB3\x74\x98\x80" - "\x61\x59\xA8\x9F\xF3\x6F\x2A\xBF" - "\xE6\xA5\x9A\xC4\x6B\xA6\x49\x6F" - "\xBC\x47\xD9\xFB\xC6\xEF\x25\x65" - "\x96\xAC\x9F\xE4\x81\x4B\xD8\xBA" - "\xD6\x9B\xC9\x6D\x58\x40\x81\x02" - "\x73\x44\x4E\x43\x6E\x37\xBB\x11" - "\xE3\xF9\xB8\x2F\xEC\x76\x34\xEA" - "\x90\xCD\xB7\x2E\x0E\x32\x71\xE8" - "\xBB\x4E\x0B\x98\xA4\x17\x17\x5B" - "\x07\xB5\x82\x3A\xC4\xE8\x42\x51" - "\x5A\x4C\x4E\x7D\xBF\xC4\xC0\x4F" - "\x68\xB8\xC6\x4A\x32\x6F\x0B\xD7" - "\x85\xED\x6B\xFB\x72\xD2\xA5\x8F" - "\xBF\xF9\xAC\x59\x50\xA8\x08\x70" - "\xEC\xBD\x0A\xBF\xE5\x87\xA1\xC2" - "\x92\x14\x78\xAF\xE8\xEA\x2E\xDD" - "\xC1\x03\x9A\xAA\x89\x8B\x32\x46" - "\x5B\x18\x27\xBA\x46\xAA\x64\xDE" - "\xE3\xD5\xA3\xFC\x7B\x5B\x61\xDB" - "\x7E\xDA\xEC\x30\x17\x19\xF8\x80" - "\xB5\x5E\x27\xB5\x37\x3A\x1F\x28" - "\x07\x73\xC3\x63\xCE\xFF\x8C\xFE" - "\x81\x4E\xF8\x24\xF3\xB8\xC7\xE8" - "\x16\x9A\xCC\x58\x2F\x88\x1C\x4B" - "\xBB\x33\xA2\x73\xF0\x1C\x89\x0E" - "\xDC\x34\x27\x89\x98\xCE\x1C\xA2" - "\xD8\xB8\x90\xBE\xEC\x72\x28\x13" - "\xAC\x7B\xF1\xD0\x7F\x7A\x28\x50" - "\xB7\x99\x65\x8A\xC9\xC6\x21\x34" - "\x7F\x67\x9D\xB7\x2C\xCC\xF5\x17" - "\x2B\x89\xAC\xB0\xD7\x1E\x47\xB0" - "\x61\xAF\xD4\x63\x6D\xB8\x2D\x20", - .rlen = 496, }, }; @@ -6450,143 +5714,6 @@ static struct cipher_testvec serpent_ctr_dec_tv_template[] = { "\x7F\x16\x8A\x21\xB8\x2C\xC3\x5A" "\xF1\x65\xFC", .rlen = 147, - .also_non_np = 1, - .np = 2, - .tap = { 147 - 16, 16 }, - }, { /* Generated with Crypto++ */ - .key = "\x85\x62\x3F\x1C\xF9\xD6\x1C\xF9" - "\xD6\xB3\x90\x6D\x4A\x90\x6D\x4A" - "\x27\x04\xE1\x27\x04\xE1\xBE\x9B" - "\x78\xBE\x9B\x78\x55\x32\x0F\x55", - .klen = 32, - .iv = "\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF" - "\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFD", - .input = "\x06\x9A\xF8\xB4\x53\x88\x62\xFC" - "\x68\xB8\x2E\xDF\xC1\x05\x0F\x3D" - "\xAF\x4D\x95\xAE\xC4\xE9\x1C\xDC" - "\xF6\x2B\x8F\x90\x89\xF6\x7E\x1A" - "\xA6\xB9\xE4\xF4\xFA\xCA\xE5\x7E" - "\x71\x28\x06\x4F\xE8\x08\x39\xDA" - "\xA5\x0E\xC8\xC0\xB8\x16\xE5\x69" - "\xE5\xCA\xEC\x4F\x63\x2C\xC0\x9B" - "\x9F\x3E\x39\x79\xF0\xCD\x64\x35" - "\x4A\xD3\xC8\xA9\x31\xCD\x48\x5B" - "\x92\x3D\x8F\x3F\x96\xBD\xB3\x18" - "\x74\x2A\x5D\x29\x3F\x57\x8F\xE2" - "\x67\x9A\xE0\xE5\xD4\x4A\xE2\x47" - "\xBC\xF6\xEB\x14\xF3\x8C\x20\xC2" - "\x7D\xE2\x43\x81\x86\x72\x2E\xB1" - "\x39\xF6\x95\xE1\x1F\xCB\x76\x33" - "\x5B\x7D\x23\x0F\x3A\x67\x2A\x2F" - "\xB9\x37\x9D\xDD\x1F\x16\xA1\x3C" - "\x70\xFE\x52\xAA\x93\x3C\xC4\x46" - "\xB1\xE5\xFF\xDA\xAF\xE2\x84\xFE" - "\x25\x92\xB2\x63\xBD\x49\x77\xB4" - "\x22\xA4\x6A\xD5\x04\xE0\x45\x58" - "\x1C\x34\x96\x7C\x03\x0C\x13\xA2" - "\x05\x22\xE2\xCB\x5A\x35\x03\x09" - "\x40\xD2\x82\x05\xCA\x58\x73\xF2" - "\x29\x5E\x01\x47\x13\x32\x78\xBE" - "\x06\xB0\x51\xDB\x6C\x31\xA0\x1C" - "\x74\xBC\x8D\x25\xDF\xF8\x65\xD1" - "\x38\x35\x11\x26\x4A\xB4\x06\x32" - "\xFA\xD2\x07\x77\xB3\x74\x98\x80" - "\x61\x59\xA8\x9F\xF3\x6F\x2A\xBF" - "\xE6\xA5\x9A\xC4\x6B\xA6\x49\x6F" - "\xBC\x47\xD9\xFB\xC6\xEF\x25\x65" - "\x96\xAC\x9F\xE4\x81\x4B\xD8\xBA" - "\xD6\x9B\xC9\x6D\x58\x40\x81\x02" - "\x73\x44\x4E\x43\x6E\x37\xBB\x11" - "\xE3\xF9\xB8\x2F\xEC\x76\x34\xEA" - "\x90\xCD\xB7\x2E\x0E\x32\x71\xE8" - "\xBB\x4E\x0B\x98\xA4\x17\x17\x5B" - "\x07\xB5\x82\x3A\xC4\xE8\x42\x51" - "\x5A\x4C\x4E\x7D\xBF\xC4\xC0\x4F" - "\x68\xB8\xC6\x4A\x32\x6F\x0B\xD7" - "\x85\xED\x6B\xFB\x72\xD2\xA5\x8F" - "\xBF\xF9\xAC\x59\x50\xA8\x08\x70" - "\xEC\xBD\x0A\xBF\xE5\x87\xA1\xC2" - "\x92\x14\x78\xAF\xE8\xEA\x2E\xDD" - "\xC1\x03\x9A\xAA\x89\x8B\x32\x46" - "\x5B\x18\x27\xBA\x46\xAA\x64\xDE" - "\xE3\xD5\xA3\xFC\x7B\x5B\x61\xDB" - "\x7E\xDA\xEC\x30\x17\x19\xF8\x80" - "\xB5\x5E\x27\xB5\x37\x3A\x1F\x28" - "\x07\x73\xC3\x63\xCE\xFF\x8C\xFE" - "\x81\x4E\xF8\x24\xF3\xB8\xC7\xE8" - "\x16\x9A\xCC\x58\x2F\x88\x1C\x4B" - "\xBB\x33\xA2\x73\xF0\x1C\x89\x0E" - "\xDC\x34\x27\x89\x98\xCE\x1C\xA2" - "\xD8\xB8\x90\xBE\xEC\x72\x28\x13" - "\xAC\x7B\xF1\xD0\x7F\x7A\x28\x50" - "\xB7\x99\x65\x8A\xC9\xC6\x21\x34" - "\x7F\x67\x9D\xB7\x2C\xCC\xF5\x17" - "\x2B\x89\xAC\xB0\xD7\x1E\x47\xB0" - "\x61\xAF\xD4\x63\x6D\xB8\x2D\x20", - .ilen = 496, - .result = "\x56\xED\x84\x1B\x8F\x26\xBD\x31" - "\xC8\x5F\xF6\x6A\x01\x98\x0C\xA3" - "\x3A\xD1\x45\xDC\x73\x0A\x7E\x15" - "\xAC\x20\xB7\x4E\xE5\x59\xF0\x87" - "\x1E\x92\x29\xC0\x34\xCB\x62\xF9" - "\x6D\x04\x9B\x0F\xA6\x3D\xD4\x48" - "\xDF\x76\x0D\x81\x18\xAF\x23\xBA" - "\x51\xE8\x5C\xF3\x8A\x21\x95\x2C" - "\xC3\x37\xCE\x65\xFC\x70\x07\x9E" - "\x12\xA9\x40\xD7\x4B\xE2\x79\x10" - "\x84\x1B\xB2\x26\xBD\x54\xEB\x5F" - "\xF6\x8D\x01\x98\x2F\xC6\x3A\xD1" - "\x68\xFF\x73\x0A\xA1\x15\xAC\x43" - "\xDA\x4E\xE5\x7C\x13\x87\x1E\xB5" - "\x29\xC0\x57\xEE\x62\xF9\x90\x04" - "\x9B\x32\xC9\x3D\xD4\x6B\x02\x76" - "\x0D\xA4\x18\xAF\x46\xDD\x51\xE8" - "\x7F\x16\x8A\x21\xB8\x2C\xC3\x5A" - "\xF1\x65\xFC\x93\x07\x9E\x35\xCC" - "\x40\xD7\x6E\x05\x79\x10\xA7\x1B" - "\xB2\x49\xE0\x54\xEB\x82\x19\x8D" - "\x24\xBB\x2F\xC6\x5D\xF4\x68\xFF" - "\x96\x0A\xA1\x38\xCF\x43\xDA\x71" - "\x08\x7C\x13\xAA\x1E\xB5\x4C\xE3" - "\x57\xEE\x85\x1C\x90\x27\xBE\x32" - "\xC9\x60\xF7\x6B\x02\x99\x0D\xA4" - "\x3B\xD2\x46\xDD\x74\x0B\x7F\x16" - "\xAD\x21\xB8\x4F\xE6\x5A\xF1\x88" - "\x1F\x93\x2A\xC1\x35\xCC\x63\xFA" - "\x6E\x05\x9C\x10\xA7\x3E\xD5\x49" - "\xE0\x77\x0E\x82\x19\xB0\x24\xBB" - "\x52\xE9\x5D\xF4\x8B\x22\x96\x2D" - "\xC4\x38\xCF\x66\xFD\x71\x08\x9F" - "\x13\xAA\x41\xD8\x4C\xE3\x7A\x11" - "\x85\x1C\xB3\x27\xBE\x55\xEC\x60" - "\xF7\x8E\x02\x99\x30\xC7\x3B\xD2" - "\x69\x00\x74\x0B\xA2\x16\xAD\x44" - "\xDB\x4F\xE6\x7D\x14\x88\x1F\xB6" - "\x2A\xC1\x58\xEF\x63\xFA\x91\x05" - "\x9C\x33\xCA\x3E\xD5\x6C\x03\x77" - "\x0E\xA5\x19\xB0\x47\xDE\x52\xE9" - "\x80\x17\x8B\x22\xB9\x2D\xC4\x5B" - "\xF2\x66\xFD\x94\x08\x9F\x36\xCD" - "\x41\xD8\x6F\x06\x7A\x11\xA8\x1C" - "\xB3\x4A\xE1\x55\xEC\x83\x1A\x8E" - "\x25\xBC\x30\xC7\x5E\xF5\x69\x00" - "\x97\x0B\xA2\x39\xD0\x44\xDB\x72" - "\x09\x7D\x14\xAB\x1F\xB6\x4D\xE4" - "\x58\xEF\x86\x1D\x91\x28\xBF\x33" - "\xCA\x61\xF8\x6C\x03\x9A\x0E\xA5" - "\x3C\xD3\x47\xDE\x75\x0C\x80\x17" - "\xAE\x22\xB9\x50\xE7\x5B\xF2\x89" - "\x20\x94\x2B\xC2\x36\xCD\x64\xFB" - "\x6F\x06\x9D\x11\xA8\x3F\xD6\x4A" - "\xE1\x78\x0F\x83\x1A\xB1\x25\xBC" - "\x53\xEA\x5E\xF5\x8C\x00\x97\x2E" - "\xC5\x39\xD0\x67\xFE\x72\x09\xA0" - "\x14\xAB\x42\xD9\x4D\xE4\x7B\x12" - "\x86\x1D\xB4\x28\xBF\x56\xED\x61" - "\xF8\x8F\x03\x9A\x31\xC8\x3C\xD3" - "\x6A\x01\x75\x0C\xA3\x17\xAE\x45" - "\xDC\x50\xE7\x7E\x15\x89\x20\xB7", - .rlen = 496, }, }; @@ -6836,9 +5963,6 @@ static struct cipher_testvec serpent_lrw_enc_tv_template[] = { "\x5c\xc6\x84\xfe\x7c\xcb\x26\xfd" "\xd9\x51\x0f\xd7\x94\x2f\xc5\xa7", .rlen = 512, - .also_non_np = 1, - .np = 2, - .tap = { 512 - 16, 16 }, }, }; @@ -7089,9 +6213,6 @@ static struct cipher_testvec serpent_lrw_dec_tv_template[] = { "\xe9\x2e\xc4\x29\x0f\x84\xdb\xc4" "\x21\xc4\xc2\x75\x67\x89\x37\x0a", .rlen = 512, - .also_non_np = 1, - .np = 2, - .tap = { 512 - 16, 16 }, }, }; @@ -7431,9 +6552,6 @@ static struct cipher_testvec serpent_xts_enc_tv_template[] = { "\xaf\x43\x0b\xc5\x20\x41\x92\x20" "\xd4\xa0\x91\x98\x11\x5f\x4d\xb1", .rlen = 512, - .also_non_np = 1, - .np = 2, - .tap = { 512 - 16, 16 }, }, }; @@ -7774,23 +6892,12 @@ static struct cipher_testvec serpent_xts_dec_tv_template[] = { "\xf0\xf1\xf2\xf3\xf4\xf5\xf6\xf7" "\xf8\xf9\xfa\xfb\xfc\xfd\xfe\xff", .rlen = 512, - .also_non_np = 1, - .np = 2, - .tap = { 512 - 16, 16 }, }, }; /* Cast6 test vectors from RFC 2612 */ -#define CAST6_ENC_TEST_VECTORS 4 -#define CAST6_DEC_TEST_VECTORS 4 -#define CAST6_CBC_ENC_TEST_VECTORS 1 -#define CAST6_CBC_DEC_TEST_VECTORS 1 -#define CAST6_CTR_ENC_TEST_VECTORS 2 -#define CAST6_CTR_DEC_TEST_VECTORS 2 -#define CAST6_LRW_ENC_TEST_VECTORS 1 -#define CAST6_LRW_DEC_TEST_VECTORS 1 -#define CAST6_XTS_ENC_TEST_VECTORS 1 -#define CAST6_XTS_DEC_TEST_VECTORS 1 +#define CAST6_ENC_TEST_VECTORS 3 +#define CAST6_DEC_TEST_VECTORS 3 static struct cipher_testvec cast6_enc_tv_template[] = { { @@ -7823,1749 +6930,287 @@ static struct cipher_testvec cast6_enc_tv_template[] = { .result = "\x4f\x6a\x20\x38\x28\x68\x97\xb9" "\xc9\x87\x01\x36\x55\x33\x17\xfa", .rlen = 16, - }, { /* Generated from TF test vectors */ - .key = "\x85\x62\x3F\x1C\xF9\xD6\x1C\xF9" - "\xD6\xB3\x90\x6D\x4A\x90\x6D\x4A" - "\x27\x04\xE1\x27\x04\xE1\xBE\x9B" - "\x78\xBE\x9B\x78\x55\x32\x0F\x55", + }, +}; + +static struct cipher_testvec cast6_dec_tv_template[] = { + { + .key = "\x23\x42\xbb\x9e\xfa\x38\x54\x2c" + "\x0a\xf7\x56\x47\xf2\x9f\x61\x5d", + .klen = 16, + .input = "\xc8\x42\xa0\x89\x72\xb4\x3d\x20" + "\x83\x6c\x91\xd1\xb7\x53\x0f\x6b", + .ilen = 16, + .result = zeroed_string, + .rlen = 16, + }, { + .key = "\x23\x42\xbb\x9e\xfa\x38\x54\x2c" + "\xbe\xd0\xac\x83\x94\x0a\xc2\x98" + "\xba\xc7\x7a\x77\x17\x94\x28\x63", + .klen = 24, + .input = "\x1b\x38\x6c\x02\x10\xdc\xad\xcb" + "\xdd\x0e\x41\xaa\x08\xa7\xa7\xe8", + .ilen = 16, + .result = zeroed_string, + .rlen = 16, + }, { + .key = "\x23\x42\xbb\x9e\xfa\x38\x54\x2c" + "\xbe\xd0\xac\x83\x94\x0a\xc2\x98" + "\x8d\x7c\x47\xce\x26\x49\x08\x46" + "\x1c\xc1\xb5\x13\x7a\xe6\xb6\x04", .klen = 32, - .iv = "\xE2\x24\x89\xEE\x53\xB8\x1D\x5F" - "\xC4\x29\x8E\xF3\x35\x9A\xFF\x64", - .input = "\x56\xED\x84\x1B\x8F\x26\xBD\x31" - "\xC8\x5F\xF6\x6A\x01\x98\x0C\xA3" - "\x3A\xD1\x45\xDC\x73\x0A\x7E\x15" - "\xAC\x20\xB7\x4E\xE5\x59\xF0\x87" - "\x1E\x92\x29\xC0\x34\xCB\x62\xF9" - "\x6D\x04\x9B\x0F\xA6\x3D\xD4\x48" - "\xDF\x76\x0D\x81\x18\xAF\x23\xBA" - "\x51\xE8\x5C\xF3\x8A\x21\x95\x2C" - "\xC3\x37\xCE\x65\xFC\x70\x07\x9E" - "\x12\xA9\x40\xD7\x4B\xE2\x79\x10" - "\x84\x1B\xB2\x26\xBD\x54\xEB\x5F" - "\xF6\x8D\x01\x98\x2F\xC6\x3A\xD1" - "\x68\xFF\x73\x0A\xA1\x15\xAC\x43" - "\xDA\x4E\xE5\x7C\x13\x87\x1E\xB5" - "\x29\xC0\x57\xEE\x62\xF9\x90\x04" - "\x9B\x32\xC9\x3D\xD4\x6B\x02\x76" - "\x0D\xA4\x18\xAF\x46\xDD\x51\xE8" - "\x7F\x16\x8A\x21\xB8\x2C\xC3\x5A" - "\xF1\x65\xFC\x93\x07\x9E\x35\xCC" - "\x40\xD7\x6E\x05\x79\x10\xA7\x1B" - "\xB2\x49\xE0\x54\xEB\x82\x19\x8D" - "\x24\xBB\x2F\xC6\x5D\xF4\x68\xFF" - "\x96\x0A\xA1\x38\xCF\x43\xDA\x71" - "\x08\x7C\x13\xAA\x1E\xB5\x4C\xE3" - "\x57\xEE\x85\x1C\x90\x27\xBE\x32" - "\xC9\x60\xF7\x6B\x02\x99\x0D\xA4" - "\x3B\xD2\x46\xDD\x74\x0B\x7F\x16" - "\xAD\x21\xB8\x4F\xE6\x5A\xF1\x88" - "\x1F\x93\x2A\xC1\x35\xCC\x63\xFA" - "\x6E\x05\x9C\x10\xA7\x3E\xD5\x49" - "\xE0\x77\x0E\x82\x19\xB0\x24\xBB" - "\x52\xE9\x5D\xF4\x8B\x22\x96\x2D" - "\xC4\x38\xCF\x66\xFD\x71\x08\x9F" - "\x13\xAA\x41\xD8\x4C\xE3\x7A\x11" - "\x85\x1C\xB3\x27\xBE\x55\xEC\x60" - "\xF7\x8E\x02\x99\x30\xC7\x3B\xD2" - "\x69\x00\x74\x0B\xA2\x16\xAD\x44" - "\xDB\x4F\xE6\x7D\x14\x88\x1F\xB6" - "\x2A\xC1\x58\xEF\x63\xFA\x91\x05" - "\x9C\x33\xCA\x3E\xD5\x6C\x03\x77" - "\x0E\xA5\x19\xB0\x47\xDE\x52\xE9" - "\x80\x17\x8B\x22\xB9\x2D\xC4\x5B" - "\xF2\x66\xFD\x94\x08\x9F\x36\xCD" - "\x41\xD8\x6F\x06\x7A\x11\xA8\x1C" - "\xB3\x4A\xE1\x55\xEC\x83\x1A\x8E" - "\x25\xBC\x30\xC7\x5E\xF5\x69\x00" - "\x97\x0B\xA2\x39\xD0\x44\xDB\x72" - "\x09\x7D\x14\xAB\x1F\xB6\x4D\xE4" - "\x58\xEF\x86\x1D\x91\x28\xBF\x33" - "\xCA\x61\xF8\x6C\x03\x9A\x0E\xA5" - "\x3C\xD3\x47\xDE\x75\x0C\x80\x17" - "\xAE\x22\xB9\x50\xE7\x5B\xF2\x89" - "\x20\x94\x2B\xC2\x36\xCD\x64\xFB" - "\x6F\x06\x9D\x11\xA8\x3F\xD6\x4A" - "\xE1\x78\x0F\x83\x1A\xB1\x25\xBC" - "\x53\xEA\x5E\xF5\x8C\x00\x97\x2E" - "\xC5\x39\xD0\x67\xFE\x72\x09\xA0" - "\x14\xAB\x42\xD9\x4D\xE4\x7B\x12" - "\x86\x1D\xB4\x28\xBF\x56\xED\x61" - "\xF8\x8F\x03\x9A\x31\xC8\x3C\xD3" - "\x6A\x01\x75\x0C\xA3\x17\xAE\x45" - "\xDC\x50\xE7\x7E\x15\x89\x20\xB7", - .ilen = 496, - .result = "\xC3\x70\x22\x32\xF5\x80\xCB\x54" - "\xFC\x30\xE0\xF6\xEB\x39\x57\xA6" - "\xB6\xB9\xC5\xA4\x91\x55\x14\x97" - "\xC1\x20\xFF\x6C\x5C\xF0\x67\xEA" - "\x2F\xED\xD8\xC9\xFB\x38\x3F\xFE" - "\x93\xBE\xDC\x00\xD3\x7F\xAD\x4C" - "\x5A\x08\x92\xD1\x47\x0C\xFA\x6C" - "\xD0\x6A\x99\x10\x72\xF8\x47\x62" - "\x81\x42\xF8\xD8\xF5\xBB\x94\x08" - "\xAA\x97\xA2\x8B\x69\xB3\xD2\x7E" - "\xBC\xB5\x00\x0C\xE5\x44\x4B\x58" - "\xE8\x63\xDC\xB3\xC4\xE5\x23\x12" - "\x5A\x72\x85\x47\x8B\xEC\x9F\x26" - "\x84\xB6\xED\x10\x33\x63\x9B\x5F" - "\x4D\x53\xEE\x94\x45\x8B\x60\x58" - "\x86\x20\xF9\x1E\x82\x08\x3E\x58" - "\x60\x1B\x34\x19\x02\xBE\x4E\x09" - "\xBB\x7C\x15\xCC\x60\x27\x55\x7A" - "\x12\xB8\xD8\x08\x89\x3C\xA6\xF3" - "\xF1\xDD\xA7\x07\xA3\x12\x85\x28" - "\xE9\x57\xAC\x80\x0C\x5C\x0F\x3A" - "\x5D\xC2\x91\xC7\x90\xE4\x8C\x43" - "\x92\xE4\x7C\x26\x69\x4D\x83\x68" - "\x14\x96\x42\x47\xBD\xA9\xE4\x8A" - "\x33\x19\xEB\x54\x8E\x0D\x4B\x6E" - "\x91\x51\xB5\x36\x08\xDE\x1C\x06" - "\x03\xBD\xDE\x81\x26\xF7\x99\xC2" - "\xBA\xF7\x6D\x87\x0D\xE4\xA6\xCF" - "\xC1\xF5\x27\x05\xB8\x02\x57\x72" - "\xE6\x42\x13\x0B\xC6\x47\x05\x74" - "\x24\x15\xF7\x0D\xC2\x23\x9D\xB9" - "\x3C\x77\x18\x93\xBA\xB4\xFC\x8C" - "\x98\x82\x67\x67\xB4\xD7\xD3\x43" - "\x23\x08\x02\xB7\x9B\x99\x05\xFB" - "\xD3\xB5\x00\x0A\xA9\x9D\x66\xD6" - "\x2E\x49\x58\xD0\xA8\x57\x29\x7F" - "\x0A\x0E\x7D\xFC\x92\x83\xCC\x67" - "\xA2\xB1\x70\x3A\x8F\x87\x4A\x8D" - "\x17\xE2\x58\x2B\x88\x0D\x68\x62" - "\xBF\x35\xD1\x6F\xC0\xF0\x18\x62" - "\xB2\xC7\x2D\x58\xC7\x16\xDE\x08" - "\xEB\x84\x1D\x25\xA7\x38\x94\x06" - "\x93\x9D\xF8\xFE\x88\x71\xE7\x84" - "\x2C\xA0\x38\xA3\x1D\x48\xCF\x29" - "\x0B\xBC\xD8\x50\x99\x1A\x26\xFB" - "\x8E\x75\x3D\x73\xEB\x6A\xED\x29" - "\xE0\x8E\xED\xFC\xFE\x6F\xF6\xBA" - "\x41\xE2\x10\x4C\x01\x8B\x69\x2B" - "\x25\x3F\x4D\x70\x7B\x92\xD6\x3B" - "\xAC\xF9\x77\x18\xD9\x6A\x30\xA6" - "\x2E\xFA\x30\xFF\xC8\xD5\x1D\x06" - "\x59\x28\x1D\x86\x43\x04\x5D\x3B" - "\x99\x4C\x04\x5A\x21\x17\x8B\x76" - "\x8F\x72\xCB\xA1\x9C\x29\x4C\xC3" - "\x65\xA2\x58\x2A\xC5\x66\x24\xBF" - "\xBA\xE6\x0C\xDD\x34\x24\x74\xC8" - "\x84\x0A\x66\x2C\xBE\x8F\x32\xA9" - "\xE7\xE4\xA1\xD7\xDA\xAB\x23\x1E" - "\xEB\xEE\x6C\x94\x6F\x9C\x2E\xD1" - "\x49\x2C\xF3\xD4\x90\xCC\x93\x4C" - "\x84\x52\x6D\x68\xDE\xC6\x64\xB2" - "\x11\x74\x93\x57\xB4\x7E\xC6\x00", - .rlen = 496, - .also_non_np = 1, - .np = 2, - .tap = { 496 - 16, 16 }, + .input = "\x4f\x6a\x20\x38\x28\x68\x97\xb9" + "\xc9\x87\x01\x36\x55\x33\x17\xfa", + .ilen = 16, + .result = zeroed_string, + .rlen = 16, }, }; -static struct cipher_testvec cast6_dec_tv_template[] = { - { - .key = "\x23\x42\xbb\x9e\xfa\x38\x54\x2c" - "\x0a\xf7\x56\x47\xf2\x9f\x61\x5d", + +/* + * AES test vectors. + */ +#define AES_ENC_TEST_VECTORS 3 +#define AES_DEC_TEST_VECTORS 3 +#define AES_CBC_ENC_TEST_VECTORS 4 +#define AES_CBC_DEC_TEST_VECTORS 4 +#define HMAC_SHA1_AES_CBC_ENC_TEST_VECTORS 7 +#define HMAC_SHA256_AES_CBC_ENC_TEST_VECTORS 7 +#define HMAC_SHA512_AES_CBC_ENC_TEST_VECTORS 7 +#define AES_LRW_ENC_TEST_VECTORS 8 +#define AES_LRW_DEC_TEST_VECTORS 8 +#define AES_XTS_ENC_TEST_VECTORS 5 +#define AES_XTS_DEC_TEST_VECTORS 5 +#define AES_CTR_ENC_TEST_VECTORS 3 +#define AES_CTR_DEC_TEST_VECTORS 3 +#define AES_OFB_ENC_TEST_VECTORS 1 +#define AES_OFB_DEC_TEST_VECTORS 1 +#define AES_CTR_3686_ENC_TEST_VECTORS 7 +#define AES_CTR_3686_DEC_TEST_VECTORS 6 +#define AES_GCM_ENC_TEST_VECTORS 9 +#define AES_GCM_DEC_TEST_VECTORS 8 +#define AES_GCM_4106_ENC_TEST_VECTORS 7 +#define AES_GCM_4106_DEC_TEST_VECTORS 7 +#define AES_CCM_ENC_TEST_VECTORS 7 +#define AES_CCM_DEC_TEST_VECTORS 7 +#define AES_CCM_4309_ENC_TEST_VECTORS 7 +#define AES_CCM_4309_DEC_TEST_VECTORS 10 + +static struct cipher_testvec aes_enc_tv_template[] = { + { /* From FIPS-197 */ + .key = "\x00\x01\x02\x03\x04\x05\x06\x07" + "\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f", .klen = 16, - .input = "\xc8\x42\xa0\x89\x72\xb4\x3d\x20" - "\x83\x6c\x91\xd1\xb7\x53\x0f\x6b", + .input = "\x00\x11\x22\x33\x44\x55\x66\x77" + "\x88\x99\xaa\xbb\xcc\xdd\xee\xff", .ilen = 16, - .result = zeroed_string, + .result = "\x69\xc4\xe0\xd8\x6a\x7b\x04\x30" + "\xd8\xcd\xb7\x80\x70\xb4\xc5\x5a", .rlen = 16, }, { - .key = "\x23\x42\xbb\x9e\xfa\x38\x54\x2c" - "\xbe\xd0\xac\x83\x94\x0a\xc2\x98" - "\xba\xc7\x7a\x77\x17\x94\x28\x63", + .key = "\x00\x01\x02\x03\x04\x05\x06\x07" + "\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f" + "\x10\x11\x12\x13\x14\x15\x16\x17", .klen = 24, - .input = "\x1b\x38\x6c\x02\x10\xdc\xad\xcb" - "\xdd\x0e\x41\xaa\x08\xa7\xa7\xe8", + .input = "\x00\x11\x22\x33\x44\x55\x66\x77" + "\x88\x99\xaa\xbb\xcc\xdd\xee\xff", .ilen = 16, - .result = zeroed_string, + .result = "\xdd\xa9\x7c\xa4\x86\x4c\xdf\xe0" + "\x6e\xaf\x70\xa0\xec\x0d\x71\x91", .rlen = 16, }, { - .key = "\x23\x42\xbb\x9e\xfa\x38\x54\x2c" - "\xbe\xd0\xac\x83\x94\x0a\xc2\x98" - "\x8d\x7c\x47\xce\x26\x49\x08\x46" - "\x1c\xc1\xb5\x13\x7a\xe6\xb6\x04", + .key = "\x00\x01\x02\x03\x04\x05\x06\x07" + "\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f" + "\x10\x11\x12\x13\x14\x15\x16\x17" + "\x18\x19\x1a\x1b\x1c\x1d\x1e\x1f", .klen = 32, - .input = "\x4f\x6a\x20\x38\x28\x68\x97\xb9" - "\xc9\x87\x01\x36\x55\x33\x17\xfa", + .input = "\x00\x11\x22\x33\x44\x55\x66\x77" + "\x88\x99\xaa\xbb\xcc\xdd\xee\xff", .ilen = 16, - .result = zeroed_string, + .result = "\x8e\xa2\xb7\xca\x51\x67\x45\xbf" + "\xea\xfc\x49\x90\x4b\x49\x60\x89", .rlen = 16, - }, { /* Generated from TF test vectors */ - .key = "\x85\x62\x3F\x1C\xF9\xD6\x1C\xF9" - "\xD6\xB3\x90\x6D\x4A\x90\x6D\x4A" - "\x27\x04\xE1\x27\x04\xE1\xBE\x9B" - "\x78\xBE\x9B\x78\x55\x32\x0F\x55", - .klen = 32, - .iv = "\xE2\x24\x89\xEE\x53\xB8\x1D\x5F" - "\xC4\x29\x8E\xF3\x35\x9A\xFF\x64", - .input = "\xC3\x70\x22\x32\xF5\x80\xCB\x54" - "\xFC\x30\xE0\xF6\xEB\x39\x57\xA6" - "\xB6\xB9\xC5\xA4\x91\x55\x14\x97" - "\xC1\x20\xFF\x6C\x5C\xF0\x67\xEA" - "\x2F\xED\xD8\xC9\xFB\x38\x3F\xFE" - "\x93\xBE\xDC\x00\xD3\x7F\xAD\x4C" - "\x5A\x08\x92\xD1\x47\x0C\xFA\x6C" - "\xD0\x6A\x99\x10\x72\xF8\x47\x62" - "\x81\x42\xF8\xD8\xF5\xBB\x94\x08" - "\xAA\x97\xA2\x8B\x69\xB3\xD2\x7E" - "\xBC\xB5\x00\x0C\xE5\x44\x4B\x58" - "\xE8\x63\xDC\xB3\xC4\xE5\x23\x12" - "\x5A\x72\x85\x47\x8B\xEC\x9F\x26" - "\x84\xB6\xED\x10\x33\x63\x9B\x5F" - "\x4D\x53\xEE\x94\x45\x8B\x60\x58" - "\x86\x20\xF9\x1E\x82\x08\x3E\x58" - "\x60\x1B\x34\x19\x02\xBE\x4E\x09" - "\xBB\x7C\x15\xCC\x60\x27\x55\x7A" - "\x12\xB8\xD8\x08\x89\x3C\xA6\xF3" - "\xF1\xDD\xA7\x07\xA3\x12\x85\x28" - "\xE9\x57\xAC\x80\x0C\x5C\x0F\x3A" - "\x5D\xC2\x91\xC7\x90\xE4\x8C\x43" - "\x92\xE4\x7C\x26\x69\x4D\x83\x68" - "\x14\x96\x42\x47\xBD\xA9\xE4\x8A" - "\x33\x19\xEB\x54\x8E\x0D\x4B\x6E" - "\x91\x51\xB5\x36\x08\xDE\x1C\x06" - "\x03\xBD\xDE\x81\x26\xF7\x99\xC2" - "\xBA\xF7\x6D\x87\x0D\xE4\xA6\xCF" - "\xC1\xF5\x27\x05\xB8\x02\x57\x72" - "\xE6\x42\x13\x0B\xC6\x47\x05\x74" - "\x24\x15\xF7\x0D\xC2\x23\x9D\xB9" - "\x3C\x77\x18\x93\xBA\xB4\xFC\x8C" - "\x98\x82\x67\x67\xB4\xD7\xD3\x43" - "\x23\x08\x02\xB7\x9B\x99\x05\xFB" - "\xD3\xB5\x00\x0A\xA9\x9D\x66\xD6" - "\x2E\x49\x58\xD0\xA8\x57\x29\x7F" - "\x0A\x0E\x7D\xFC\x92\x83\xCC\x67" - "\xA2\xB1\x70\x3A\x8F\x87\x4A\x8D" - "\x17\xE2\x58\x2B\x88\x0D\x68\x62" - "\xBF\x35\xD1\x6F\xC0\xF0\x18\x62" - "\xB2\xC7\x2D\x58\xC7\x16\xDE\x08" - "\xEB\x84\x1D\x25\xA7\x38\x94\x06" - "\x93\x9D\xF8\xFE\x88\x71\xE7\x84" - "\x2C\xA0\x38\xA3\x1D\x48\xCF\x29" - "\x0B\xBC\xD8\x50\x99\x1A\x26\xFB" - "\x8E\x75\x3D\x73\xEB\x6A\xED\x29" - "\xE0\x8E\xED\xFC\xFE\x6F\xF6\xBA" - "\x41\xE2\x10\x4C\x01\x8B\x69\x2B" - "\x25\x3F\x4D\x70\x7B\x92\xD6\x3B" - "\xAC\xF9\x77\x18\xD9\x6A\x30\xA6" - "\x2E\xFA\x30\xFF\xC8\xD5\x1D\x06" - "\x59\x28\x1D\x86\x43\x04\x5D\x3B" - "\x99\x4C\x04\x5A\x21\x17\x8B\x76" - "\x8F\x72\xCB\xA1\x9C\x29\x4C\xC3" - "\x65\xA2\x58\x2A\xC5\x66\x24\xBF" - "\xBA\xE6\x0C\xDD\x34\x24\x74\xC8" - "\x84\x0A\x66\x2C\xBE\x8F\x32\xA9" - "\xE7\xE4\xA1\xD7\xDA\xAB\x23\x1E" - "\xEB\xEE\x6C\x94\x6F\x9C\x2E\xD1" - "\x49\x2C\xF3\xD4\x90\xCC\x93\x4C" - "\x84\x52\x6D\x68\xDE\xC6\x64\xB2" - "\x11\x74\x93\x57\xB4\x7E\xC6\x00", - .ilen = 496, - .result = "\x56\xED\x84\x1B\x8F\x26\xBD\x31" - "\xC8\x5F\xF6\x6A\x01\x98\x0C\xA3" - "\x3A\xD1\x45\xDC\x73\x0A\x7E\x15" - "\xAC\x20\xB7\x4E\xE5\x59\xF0\x87" - "\x1E\x92\x29\xC0\x34\xCB\x62\xF9" - "\x6D\x04\x9B\x0F\xA6\x3D\xD4\x48" - "\xDF\x76\x0D\x81\x18\xAF\x23\xBA" - "\x51\xE8\x5C\xF3\x8A\x21\x95\x2C" - "\xC3\x37\xCE\x65\xFC\x70\x07\x9E" - "\x12\xA9\x40\xD7\x4B\xE2\x79\x10" - "\x84\x1B\xB2\x26\xBD\x54\xEB\x5F" - "\xF6\x8D\x01\x98\x2F\xC6\x3A\xD1" - "\x68\xFF\x73\x0A\xA1\x15\xAC\x43" - "\xDA\x4E\xE5\x7C\x13\x87\x1E\xB5" - "\x29\xC0\x57\xEE\x62\xF9\x90\x04" - "\x9B\x32\xC9\x3D\xD4\x6B\x02\x76" - "\x0D\xA4\x18\xAF\x46\xDD\x51\xE8" - "\x7F\x16\x8A\x21\xB8\x2C\xC3\x5A" - "\xF1\x65\xFC\x93\x07\x9E\x35\xCC" - "\x40\xD7\x6E\x05\x79\x10\xA7\x1B" - "\xB2\x49\xE0\x54\xEB\x82\x19\x8D" - "\x24\xBB\x2F\xC6\x5D\xF4\x68\xFF" - "\x96\x0A\xA1\x38\xCF\x43\xDA\x71" - "\x08\x7C\x13\xAA\x1E\xB5\x4C\xE3" - "\x57\xEE\x85\x1C\x90\x27\xBE\x32" - "\xC9\x60\xF7\x6B\x02\x99\x0D\xA4" - "\x3B\xD2\x46\xDD\x74\x0B\x7F\x16" - "\xAD\x21\xB8\x4F\xE6\x5A\xF1\x88" - "\x1F\x93\x2A\xC1\x35\xCC\x63\xFA" - "\x6E\x05\x9C\x10\xA7\x3E\xD5\x49" - "\xE0\x77\x0E\x82\x19\xB0\x24\xBB" - "\x52\xE9\x5D\xF4\x8B\x22\x96\x2D" - "\xC4\x38\xCF\x66\xFD\x71\x08\x9F" - "\x13\xAA\x41\xD8\x4C\xE3\x7A\x11" - "\x85\x1C\xB3\x27\xBE\x55\xEC\x60" - "\xF7\x8E\x02\x99\x30\xC7\x3B\xD2" - "\x69\x00\x74\x0B\xA2\x16\xAD\x44" - "\xDB\x4F\xE6\x7D\x14\x88\x1F\xB6" - "\x2A\xC1\x58\xEF\x63\xFA\x91\x05" - "\x9C\x33\xCA\x3E\xD5\x6C\x03\x77" - "\x0E\xA5\x19\xB0\x47\xDE\x52\xE9" - "\x80\x17\x8B\x22\xB9\x2D\xC4\x5B" - "\xF2\x66\xFD\x94\x08\x9F\x36\xCD" - "\x41\xD8\x6F\x06\x7A\x11\xA8\x1C" - "\xB3\x4A\xE1\x55\xEC\x83\x1A\x8E" - "\x25\xBC\x30\xC7\x5E\xF5\x69\x00" - "\x97\x0B\xA2\x39\xD0\x44\xDB\x72" - "\x09\x7D\x14\xAB\x1F\xB6\x4D\xE4" - "\x58\xEF\x86\x1D\x91\x28\xBF\x33" - "\xCA\x61\xF8\x6C\x03\x9A\x0E\xA5" - "\x3C\xD3\x47\xDE\x75\x0C\x80\x17" - "\xAE\x22\xB9\x50\xE7\x5B\xF2\x89" - "\x20\x94\x2B\xC2\x36\xCD\x64\xFB" - "\x6F\x06\x9D\x11\xA8\x3F\xD6\x4A" - "\xE1\x78\x0F\x83\x1A\xB1\x25\xBC" - "\x53\xEA\x5E\xF5\x8C\x00\x97\x2E" - "\xC5\x39\xD0\x67\xFE\x72\x09\xA0" - "\x14\xAB\x42\xD9\x4D\xE4\x7B\x12" - "\x86\x1D\xB4\x28\xBF\x56\xED\x61" - "\xF8\x8F\x03\x9A\x31\xC8\x3C\xD3" - "\x6A\x01\x75\x0C\xA3\x17\xAE\x45" - "\xDC\x50\xE7\x7E\x15\x89\x20\xB7", - .rlen = 496, - .also_non_np = 1, - .np = 2, - .tap = { 496 - 16, 16 }, }, }; -static struct cipher_testvec cast6_cbc_enc_tv_template[] = { - { /* Generated from TF test vectors */ - .key = "\x85\x62\x3F\x1C\xF9\xD6\x1C\xF9" - "\xD6\xB3\x90\x6D\x4A\x90\x6D\x4A" - "\x27\x04\xE1\x27\x04\xE1\xBE\x9B" - "\x78\xBE\x9B\x78\x55\x32\x0F\x55", +static struct cipher_testvec aes_dec_tv_template[] = { + { /* From FIPS-197 */ + .key = "\x00\x01\x02\x03\x04\x05\x06\x07" + "\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f", + .klen = 16, + .input = "\x69\xc4\xe0\xd8\x6a\x7b\x04\x30" + "\xd8\xcd\xb7\x80\x70\xb4\xc5\x5a", + .ilen = 16, + .result = "\x00\x11\x22\x33\x44\x55\x66\x77" + "\x88\x99\xaa\xbb\xcc\xdd\xee\xff", + .rlen = 16, + }, { + .key = "\x00\x01\x02\x03\x04\x05\x06\x07" + "\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f" + "\x10\x11\x12\x13\x14\x15\x16\x17", + .klen = 24, + .input = "\xdd\xa9\x7c\xa4\x86\x4c\xdf\xe0" + "\x6e\xaf\x70\xa0\xec\x0d\x71\x91", + .ilen = 16, + .result = "\x00\x11\x22\x33\x44\x55\x66\x77" + "\x88\x99\xaa\xbb\xcc\xdd\xee\xff", + .rlen = 16, + }, { + .key = "\x00\x01\x02\x03\x04\x05\x06\x07" + "\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f" + "\x10\x11\x12\x13\x14\x15\x16\x17" + "\x18\x19\x1a\x1b\x1c\x1d\x1e\x1f", .klen = 32, - .iv = "\xE2\x24\x89\xEE\x53\xB8\x1D\x5F" - "\xC4\x29\x8E\xF3\x35\x9A\xFF\x64", - .input = "\x56\xED\x84\x1B\x8F\x26\xBD\x31" - "\xC8\x5F\xF6\x6A\x01\x98\x0C\xA3" - "\x3A\xD1\x45\xDC\x73\x0A\x7E\x15" - "\xAC\x20\xB7\x4E\xE5\x59\xF0\x87" - "\x1E\x92\x29\xC0\x34\xCB\x62\xF9" - "\x6D\x04\x9B\x0F\xA6\x3D\xD4\x48" - "\xDF\x76\x0D\x81\x18\xAF\x23\xBA" - "\x51\xE8\x5C\xF3\x8A\x21\x95\x2C" - "\xC3\x37\xCE\x65\xFC\x70\x07\x9E" - "\x12\xA9\x40\xD7\x4B\xE2\x79\x10" - "\x84\x1B\xB2\x26\xBD\x54\xEB\x5F" - "\xF6\x8D\x01\x98\x2F\xC6\x3A\xD1" - "\x68\xFF\x73\x0A\xA1\x15\xAC\x43" - "\xDA\x4E\xE5\x7C\x13\x87\x1E\xB5" - "\x29\xC0\x57\xEE\x62\xF9\x90\x04" - "\x9B\x32\xC9\x3D\xD4\x6B\x02\x76" - "\x0D\xA4\x18\xAF\x46\xDD\x51\xE8" - "\x7F\x16\x8A\x21\xB8\x2C\xC3\x5A" - "\xF1\x65\xFC\x93\x07\x9E\x35\xCC" - "\x40\xD7\x6E\x05\x79\x10\xA7\x1B" - "\xB2\x49\xE0\x54\xEB\x82\x19\x8D" - "\x24\xBB\x2F\xC6\x5D\xF4\x68\xFF" - "\x96\x0A\xA1\x38\xCF\x43\xDA\x71" - "\x08\x7C\x13\xAA\x1E\xB5\x4C\xE3" - "\x57\xEE\x85\x1C\x90\x27\xBE\x32" - "\xC9\x60\xF7\x6B\x02\x99\x0D\xA4" - "\x3B\xD2\x46\xDD\x74\x0B\x7F\x16" - "\xAD\x21\xB8\x4F\xE6\x5A\xF1\x88" - "\x1F\x93\x2A\xC1\x35\xCC\x63\xFA" - "\x6E\x05\x9C\x10\xA7\x3E\xD5\x49" - "\xE0\x77\x0E\x82\x19\xB0\x24\xBB" - "\x52\xE9\x5D\xF4\x8B\x22\x96\x2D" - "\xC4\x38\xCF\x66\xFD\x71\x08\x9F" - "\x13\xAA\x41\xD8\x4C\xE3\x7A\x11" - "\x85\x1C\xB3\x27\xBE\x55\xEC\x60" - "\xF7\x8E\x02\x99\x30\xC7\x3B\xD2" - "\x69\x00\x74\x0B\xA2\x16\xAD\x44" - "\xDB\x4F\xE6\x7D\x14\x88\x1F\xB6" - "\x2A\xC1\x58\xEF\x63\xFA\x91\x05" - "\x9C\x33\xCA\x3E\xD5\x6C\x03\x77" - "\x0E\xA5\x19\xB0\x47\xDE\x52\xE9" - "\x80\x17\x8B\x22\xB9\x2D\xC4\x5B" - "\xF2\x66\xFD\x94\x08\x9F\x36\xCD" - "\x41\xD8\x6F\x06\x7A\x11\xA8\x1C" - "\xB3\x4A\xE1\x55\xEC\x83\x1A\x8E" - "\x25\xBC\x30\xC7\x5E\xF5\x69\x00" - "\x97\x0B\xA2\x39\xD0\x44\xDB\x72" - "\x09\x7D\x14\xAB\x1F\xB6\x4D\xE4" - "\x58\xEF\x86\x1D\x91\x28\xBF\x33" - "\xCA\x61\xF8\x6C\x03\x9A\x0E\xA5" - "\x3C\xD3\x47\xDE\x75\x0C\x80\x17" - "\xAE\x22\xB9\x50\xE7\x5B\xF2\x89" - "\x20\x94\x2B\xC2\x36\xCD\x64\xFB" - "\x6F\x06\x9D\x11\xA8\x3F\xD6\x4A" - "\xE1\x78\x0F\x83\x1A\xB1\x25\xBC" - "\x53\xEA\x5E\xF5\x8C\x00\x97\x2E" - "\xC5\x39\xD0\x67\xFE\x72\x09\xA0" - "\x14\xAB\x42\xD9\x4D\xE4\x7B\x12" - "\x86\x1D\xB4\x28\xBF\x56\xED\x61" - "\xF8\x8F\x03\x9A\x31\xC8\x3C\xD3" - "\x6A\x01\x75\x0C\xA3\x17\xAE\x45" - "\xDC\x50\xE7\x7E\x15\x89\x20\xB7", - .ilen = 496, - .result = "\xDF\x77\x68\x96\xC7\xBA\xF8\xE2" - "\x0E\x24\x99\x1A\xAA\xF3\xC6\x9F" - "\xA0\x73\xB3\x70\xC3\x68\x64\x70" - "\xAD\x33\x02\xFB\x88\x74\xAA\x78" - "\xC7\x47\x1A\x18\x61\x2D\xAC\x9F" - "\x7E\x6F\xDF\x05\x13\x76\xA6\x72" - "\xB7\x13\x09\x0F\x7D\x38\xDF\x25" - "\x4E\xFD\x50\x45\xFA\x35\x6A\xC0" - "\x57\x95\xE1\x21\x26\x10\x9A\x21" - "\xA1\x8A\x51\x05\xD1\xB1\x78\x35" - "\x98\xF5\xAE\xC0\xC1\x8B\x94\xFF" - "\xD0\x69\x3F\x42\xC2\x01\xA7\x9B" - "\x23\x16\x47\x72\x81\x13\x3A\x72" - "\xEC\xD9\x40\x88\x00\x9C\xB0\xA8" - "\x9C\xAC\xCE\x11\x73\x7B\x63\x3E" - "\xA3\x63\x98\x7D\x35\xE4\xD9\x83" - "\xE2\xD0\x52\x87\x0C\x1F\xB0\xB3" - "\x41\x1A\x93\x8D\x76\x31\x9F\xF2" - "\xFE\x09\xA3\x8F\x22\x6A\x3B\xB9" - "\x6C\x9E\xE4\xA1\xA0\xC4\xE7\xA1" - "\x21\x9C\x1A\xCA\x65\xDE\x44\x03" - "\x99\xF2\xD2\x39\xE3\x3F\x0F\x37" - "\x53\x50\x23\xA4\x81\x6E\xDA\xFB" - "\xF8\x7B\x01\xD7\xB2\x32\x9C\xB8" - "\xB1\x0E\x99\x17\xB5\x38\xF9\xD7" - "\x86\x2D\x6E\x94\x5C\x99\x9D\xB3" - "\xD3\x63\x4B\x2A\x7D\x44\x6A\xB2" - "\xC1\x03\xE6\x5A\x37\xD8\x64\x18" - "\xAA\x32\xCE\x29\xED\xC0\xA2\xCB" - "\x8D\xAF\xCD\xBE\x8F\xB6\xEC\xB4" - "\x89\x05\x81\x6E\x71\x4F\xC3\x28" - "\x10\xC1\x62\xC4\x41\xE9\xD2\x39" - "\xF3\x22\x39\x12\x2C\xC2\x95\x2D" - "\xBF\x93\x58\x4B\x04\xD1\x8D\x57" - "\xAE\xEB\x60\x03\x56\x35\xAD\x5A" - "\xE9\xC3\xFF\x4E\x31\xE1\x37\xF8" - "\x7D\xEE\x65\x8A\xB6\x88\x1A\x3E" - "\x07\x09\x82\xBA\xF0\x80\x8A\xD0" - "\xA0\x3F\x6A\xE9\x24\x87\x19\x65" - "\x73\x3F\x12\x91\x47\x54\xBA\x39" - "\x30\x5B\x1E\xE5\xC2\xF9\x3F\xEF" - "\xD6\x75\xF9\xB8\x7C\x8B\x05\x76" - "\xEE\xB7\x08\x25\x4B\xB6\x7B\x47" - "\x72\xC0\x4C\xD4\xDA\xE0\x75\xF1" - "\x7C\xE8\x94\x9E\x16\x6E\xB8\x12" - "\xA1\xC1\x6E\x3B\x1C\x59\x41\x2D" - "\x23\xFA\x7D\x77\xB8\x46\x75\xFE" - "\x4F\x10\xD3\x09\x60\xA1\x36\x96" - "\x5B\xC2\xDC\x6E\x84\x7D\x9B\x14" - "\x80\x21\x83\x58\x3C\x76\xFD\x28" - "\x1D\xF9\x93\x13\xD7\x0E\x62\x14" - "\x5A\xC5\x4E\x08\xA5\x56\xA4\x3C" - "\x68\x93\x44\x70\xDF\xCF\x4A\x51" - "\x0B\x81\x29\x41\xE5\x62\x4D\x36" - "\xB3\xEA\x94\xA6\xB9\xDD\x3F\x09" - "\x62\x34\xA0\x6A\x7E\x7D\xF5\xF6" - "\x01\x91\xB4\x27\xDA\x59\xD6\x17" - "\x56\x4D\x82\x62\x37\xA3\x48\x01" - "\x99\x91\x77\xB2\x08\x6B\x2C\x37" - "\xC5\x5C\xAD\xB6\x07\xB6\x84\xF3" - "\x4D\x59\x7D\xC5\x28\x69\xFA\x92" - "\x22\x46\x89\x2D\x0F\x2B\x08\x24", - .rlen = 496, - .also_non_np = 1, - .np = 2, - .tap = { 496 - 16, 16 }, + .input = "\x8e\xa2\xb7\xca\x51\x67\x45\xbf" + "\xea\xfc\x49\x90\x4b\x49\x60\x89", + .ilen = 16, + .result = "\x00\x11\x22\x33\x44\x55\x66\x77" + "\x88\x99\xaa\xbb\xcc\xdd\xee\xff", + .rlen = 16, }, }; -static struct cipher_testvec cast6_cbc_dec_tv_template[] = { - { /* Generated from TF test vectors */ - .key = "\x85\x62\x3F\x1C\xF9\xD6\x1C\xF9" - "\xD6\xB3\x90\x6D\x4A\x90\x6D\x4A" - "\x27\x04\xE1\x27\x04\xE1\xBE\x9B" - "\x78\xBE\x9B\x78\x55\x32\x0F\x55", +static struct cipher_testvec aes_cbc_enc_tv_template[] = { + { /* From RFC 3602 */ + .key = "\x06\xa9\x21\x40\x36\xb8\xa1\x5b" + "\x51\x2e\x03\xd5\x34\x12\x00\x06", + .klen = 16, + .iv = "\x3d\xaf\xba\x42\x9d\x9e\xb4\x30" + "\xb4\x22\xda\x80\x2c\x9f\xac\x41", + .input = "Single block msg", + .ilen = 16, + .result = "\xe3\x53\x77\x9c\x10\x79\xae\xb8" + "\x27\x08\x94\x2d\xbe\x77\x18\x1a", + .rlen = 16, + }, { + .key = "\xc2\x86\x69\x6d\x88\x7c\x9a\xa0" + "\x61\x1b\xbb\x3e\x20\x25\xa4\x5a", + .klen = 16, + .iv = "\x56\x2e\x17\x99\x6d\x09\x3d\x28" + "\xdd\xb3\xba\x69\x5a\x2e\x6f\x58", + .input = "\x00\x01\x02\x03\x04\x05\x06\x07" + "\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f" + "\x10\x11\x12\x13\x14\x15\x16\x17" + "\x18\x19\x1a\x1b\x1c\x1d\x1e\x1f", + .ilen = 32, + .result = "\xd2\x96\xcd\x94\xc2\xcc\xcf\x8a" + "\x3a\x86\x30\x28\xb5\xe1\xdc\x0a" + "\x75\x86\x60\x2d\x25\x3c\xff\xf9" + "\x1b\x82\x66\xbe\xa6\xd6\x1a\xb1", + .rlen = 32, + }, { /* From NIST SP800-38A */ + .key = "\x8e\x73\xb0\xf7\xda\x0e\x64\x52" + "\xc8\x10\xf3\x2b\x80\x90\x79\xe5" + "\x62\xf8\xea\xd2\x52\x2c\x6b\x7b", + .klen = 24, + .iv = "\x00\x01\x02\x03\x04\x05\x06\x07" + "\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f", + .input = "\x6b\xc1\xbe\xe2\x2e\x40\x9f\x96" + "\xe9\x3d\x7e\x11\x73\x93\x17\x2a" + "\xae\x2d\x8a\x57\x1e\x03\xac\x9c" + "\x9e\xb7\x6f\xac\x45\xaf\x8e\x51" + "\x30\xc8\x1c\x46\xa3\x5c\xe4\x11" + "\xe5\xfb\xc1\x19\x1a\x0a\x52\xef" + "\xf6\x9f\x24\x45\xdf\x4f\x9b\x17" + "\xad\x2b\x41\x7b\xe6\x6c\x37\x10", + .ilen = 64, + .result = "\x4f\x02\x1d\xb2\x43\xbc\x63\x3d" + "\x71\x78\x18\x3a\x9f\xa0\x71\xe8" + "\xb4\xd9\xad\xa9\xad\x7d\xed\xf4" + "\xe5\xe7\x38\x76\x3f\x69\x14\x5a" + "\x57\x1b\x24\x20\x12\xfb\x7a\xe0" + "\x7f\xa9\xba\xac\x3d\xf1\x02\xe0" + "\x08\xb0\xe2\x79\x88\x59\x88\x81" + "\xd9\x20\xa9\xe6\x4f\x56\x15\xcd", + .rlen = 64, + }, { + .key = "\x60\x3d\xeb\x10\x15\xca\x71\xbe" + "\x2b\x73\xae\xf0\x85\x7d\x77\x81" + "\x1f\x35\x2c\x07\x3b\x61\x08\xd7" + "\x2d\x98\x10\xa3\x09\x14\xdf\xf4", .klen = 32, - .iv = "\xE2\x24\x89\xEE\x53\xB8\x1D\x5F" - "\xC4\x29\x8E\xF3\x35\x9A\xFF\x64", - .input = "\xDF\x77\x68\x96\xC7\xBA\xF8\xE2" - "\x0E\x24\x99\x1A\xAA\xF3\xC6\x9F" - "\xA0\x73\xB3\x70\xC3\x68\x64\x70" - "\xAD\x33\x02\xFB\x88\x74\xAA\x78" - "\xC7\x47\x1A\x18\x61\x2D\xAC\x9F" - "\x7E\x6F\xDF\x05\x13\x76\xA6\x72" - "\xB7\x13\x09\x0F\x7D\x38\xDF\x25" - "\x4E\xFD\x50\x45\xFA\x35\x6A\xC0" - "\x57\x95\xE1\x21\x26\x10\x9A\x21" - "\xA1\x8A\x51\x05\xD1\xB1\x78\x35" - "\x98\xF5\xAE\xC0\xC1\x8B\x94\xFF" - "\xD0\x69\x3F\x42\xC2\x01\xA7\x9B" - "\x23\x16\x47\x72\x81\x13\x3A\x72" - "\xEC\xD9\x40\x88\x00\x9C\xB0\xA8" - "\x9C\xAC\xCE\x11\x73\x7B\x63\x3E" - "\xA3\x63\x98\x7D\x35\xE4\xD9\x83" - "\xE2\xD0\x52\x87\x0C\x1F\xB0\xB3" - "\x41\x1A\x93\x8D\x76\x31\x9F\xF2" - "\xFE\x09\xA3\x8F\x22\x6A\x3B\xB9" - "\x6C\x9E\xE4\xA1\xA0\xC4\xE7\xA1" - "\x21\x9C\x1A\xCA\x65\xDE\x44\x03" - "\x99\xF2\xD2\x39\xE3\x3F\x0F\x37" - "\x53\x50\x23\xA4\x81\x6E\xDA\xFB" - "\xF8\x7B\x01\xD7\xB2\x32\x9C\xB8" - "\xB1\x0E\x99\x17\xB5\x38\xF9\xD7" - "\x86\x2D\x6E\x94\x5C\x99\x9D\xB3" - "\xD3\x63\x4B\x2A\x7D\x44\x6A\xB2" - "\xC1\x03\xE6\x5A\x37\xD8\x64\x18" - "\xAA\x32\xCE\x29\xED\xC0\xA2\xCB" - "\x8D\xAF\xCD\xBE\x8F\xB6\xEC\xB4" - "\x89\x05\x81\x6E\x71\x4F\xC3\x28" - "\x10\xC1\x62\xC4\x41\xE9\xD2\x39" - "\xF3\x22\x39\x12\x2C\xC2\x95\x2D" - "\xBF\x93\x58\x4B\x04\xD1\x8D\x57" - "\xAE\xEB\x60\x03\x56\x35\xAD\x5A" - "\xE9\xC3\xFF\x4E\x31\xE1\x37\xF8" - "\x7D\xEE\x65\x8A\xB6\x88\x1A\x3E" - "\x07\x09\x82\xBA\xF0\x80\x8A\xD0" - "\xA0\x3F\x6A\xE9\x24\x87\x19\x65" - "\x73\x3F\x12\x91\x47\x54\xBA\x39" - "\x30\x5B\x1E\xE5\xC2\xF9\x3F\xEF" - "\xD6\x75\xF9\xB8\x7C\x8B\x05\x76" - "\xEE\xB7\x08\x25\x4B\xB6\x7B\x47" - "\x72\xC0\x4C\xD4\xDA\xE0\x75\xF1" - "\x7C\xE8\x94\x9E\x16\x6E\xB8\x12" - "\xA1\xC1\x6E\x3B\x1C\x59\x41\x2D" - "\x23\xFA\x7D\x77\xB8\x46\x75\xFE" - "\x4F\x10\xD3\x09\x60\xA1\x36\x96" - "\x5B\xC2\xDC\x6E\x84\x7D\x9B\x14" - "\x80\x21\x83\x58\x3C\x76\xFD\x28" - "\x1D\xF9\x93\x13\xD7\x0E\x62\x14" - "\x5A\xC5\x4E\x08\xA5\x56\xA4\x3C" - "\x68\x93\x44\x70\xDF\xCF\x4A\x51" - "\x0B\x81\x29\x41\xE5\x62\x4D\x36" - "\xB3\xEA\x94\xA6\xB9\xDD\x3F\x09" - "\x62\x34\xA0\x6A\x7E\x7D\xF5\xF6" - "\x01\x91\xB4\x27\xDA\x59\xD6\x17" - "\x56\x4D\x82\x62\x37\xA3\x48\x01" - "\x99\x91\x77\xB2\x08\x6B\x2C\x37" - "\xC5\x5C\xAD\xB6\x07\xB6\x84\xF3" - "\x4D\x59\x7D\xC5\x28\x69\xFA\x92" - "\x22\x46\x89\x2D\x0F\x2B\x08\x24", - .ilen = 496, - .result = "\x56\xED\x84\x1B\x8F\x26\xBD\x31" - "\xC8\x5F\xF6\x6A\x01\x98\x0C\xA3" - "\x3A\xD1\x45\xDC\x73\x0A\x7E\x15" - "\xAC\x20\xB7\x4E\xE5\x59\xF0\x87" - "\x1E\x92\x29\xC0\x34\xCB\x62\xF9" - "\x6D\x04\x9B\x0F\xA6\x3D\xD4\x48" - "\xDF\x76\x0D\x81\x18\xAF\x23\xBA" - "\x51\xE8\x5C\xF3\x8A\x21\x95\x2C" - "\xC3\x37\xCE\x65\xFC\x70\x07\x9E" - "\x12\xA9\x40\xD7\x4B\xE2\x79\x10" - "\x84\x1B\xB2\x26\xBD\x54\xEB\x5F" - "\xF6\x8D\x01\x98\x2F\xC6\x3A\xD1" - "\x68\xFF\x73\x0A\xA1\x15\xAC\x43" - "\xDA\x4E\xE5\x7C\x13\x87\x1E\xB5" - "\x29\xC0\x57\xEE\x62\xF9\x90\x04" - "\x9B\x32\xC9\x3D\xD4\x6B\x02\x76" - "\x0D\xA4\x18\xAF\x46\xDD\x51\xE8" - "\x7F\x16\x8A\x21\xB8\x2C\xC3\x5A" - "\xF1\x65\xFC\x93\x07\x9E\x35\xCC" - "\x40\xD7\x6E\x05\x79\x10\xA7\x1B" - "\xB2\x49\xE0\x54\xEB\x82\x19\x8D" - "\x24\xBB\x2F\xC6\x5D\xF4\x68\xFF" - "\x96\x0A\xA1\x38\xCF\x43\xDA\x71" - "\x08\x7C\x13\xAA\x1E\xB5\x4C\xE3" - "\x57\xEE\x85\x1C\x90\x27\xBE\x32" - "\xC9\x60\xF7\x6B\x02\x99\x0D\xA4" - "\x3B\xD2\x46\xDD\x74\x0B\x7F\x16" - "\xAD\x21\xB8\x4F\xE6\x5A\xF1\x88" - "\x1F\x93\x2A\xC1\x35\xCC\x63\xFA" - "\x6E\x05\x9C\x10\xA7\x3E\xD5\x49" - "\xE0\x77\x0E\x82\x19\xB0\x24\xBB" - "\x52\xE9\x5D\xF4\x8B\x22\x96\x2D" - "\xC4\x38\xCF\x66\xFD\x71\x08\x9F" - "\x13\xAA\x41\xD8\x4C\xE3\x7A\x11" - "\x85\x1C\xB3\x27\xBE\x55\xEC\x60" - "\xF7\x8E\x02\x99\x30\xC7\x3B\xD2" - "\x69\x00\x74\x0B\xA2\x16\xAD\x44" - "\xDB\x4F\xE6\x7D\x14\x88\x1F\xB6" - "\x2A\xC1\x58\xEF\x63\xFA\x91\x05" - "\x9C\x33\xCA\x3E\xD5\x6C\x03\x77" - "\x0E\xA5\x19\xB0\x47\xDE\x52\xE9" - "\x80\x17\x8B\x22\xB9\x2D\xC4\x5B" - "\xF2\x66\xFD\x94\x08\x9F\x36\xCD" - "\x41\xD8\x6F\x06\x7A\x11\xA8\x1C" - "\xB3\x4A\xE1\x55\xEC\x83\x1A\x8E" - "\x25\xBC\x30\xC7\x5E\xF5\x69\x00" - "\x97\x0B\xA2\x39\xD0\x44\xDB\x72" - "\x09\x7D\x14\xAB\x1F\xB6\x4D\xE4" - "\x58\xEF\x86\x1D\x91\x28\xBF\x33" - "\xCA\x61\xF8\x6C\x03\x9A\x0E\xA5" - "\x3C\xD3\x47\xDE\x75\x0C\x80\x17" - "\xAE\x22\xB9\x50\xE7\x5B\xF2\x89" - "\x20\x94\x2B\xC2\x36\xCD\x64\xFB" - "\x6F\x06\x9D\x11\xA8\x3F\xD6\x4A" - "\xE1\x78\x0F\x83\x1A\xB1\x25\xBC" - "\x53\xEA\x5E\xF5\x8C\x00\x97\x2E" - "\xC5\x39\xD0\x67\xFE\x72\x09\xA0" - "\x14\xAB\x42\xD9\x4D\xE4\x7B\x12" - "\x86\x1D\xB4\x28\xBF\x56\xED\x61" - "\xF8\x8F\x03\x9A\x31\xC8\x3C\xD3" - "\x6A\x01\x75\x0C\xA3\x17\xAE\x45" - "\xDC\x50\xE7\x7E\x15\x89\x20\xB7", - .rlen = 496, - .also_non_np = 1, - .np = 2, - .tap = { 496 - 16, 16 }, + .iv = "\x00\x01\x02\x03\x04\x05\x06\x07" + "\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f", + .input = "\x6b\xc1\xbe\xe2\x2e\x40\x9f\x96" + "\xe9\x3d\x7e\x11\x73\x93\x17\x2a" + "\xae\x2d\x8a\x57\x1e\x03\xac\x9c" + "\x9e\xb7\x6f\xac\x45\xaf\x8e\x51" + "\x30\xc8\x1c\x46\xa3\x5c\xe4\x11" + "\xe5\xfb\xc1\x19\x1a\x0a\x52\xef" + "\xf6\x9f\x24\x45\xdf\x4f\x9b\x17" + "\xad\x2b\x41\x7b\xe6\x6c\x37\x10", + .ilen = 64, + .result = "\xf5\x8c\x4c\x04\xd6\xe5\xf1\xba" + "\x77\x9e\xab\xfb\x5f\x7b\xfb\xd6" + "\x9c\xfc\x4e\x96\x7e\xdb\x80\x8d" + "\x67\x9f\x77\x7b\xc6\x70\x2c\x7d" + "\x39\xf2\x33\x69\xa9\xd9\xba\xcf" + "\xa5\x30\xe2\x63\x04\x23\x14\x61" + "\xb2\xeb\x05\xe2\xc3\x9b\xe9\xfc" + "\xda\x6c\x19\x07\x8c\x6a\x9d\x1b", + .rlen = 64, }, }; -static struct cipher_testvec cast6_ctr_enc_tv_template[] = { - { /* Generated from TF test vectors */ - .key = "\x85\x62\x3F\x1C\xF9\xD6\x1C\xF9" - "\xD6\xB3\x90\x6D\x4A\x90\x6D\x4A" - "\x27\x04\xE1\x27\x04\xE1\xBE\x9B" - "\x78\xBE\x9B\x78\x55\x32\x0F\x55", - .klen = 32, - .iv = "\xE2\x24\x89\xEE\x53\xB8\x1D\x5F" - "\xC4\x29\x8E\xF3\x35\x9A\xFF\x64", - .input = "\x56\xED\x84\x1B\x8F\x26\xBD\x31" - "\xC8\x5F\xF6\x6A\x01\x98\x0C\xA3" - "\x3A", - .ilen = 17, - .result = "\x26\x0A\xF1\xE2\x3F\x8A\xEF\xA3" - "\x53\x9A\x5E\x1B\x2A\x1A\xC6\x0A" - "\x57", - .rlen = 17, - }, { /* Generated from TF test vectors */ - .key = "\x85\x62\x3F\x1C\xF9\xD6\x1C\xF9" - "\xD6\xB3\x90\x6D\x4A\x90\x6D\x4A" - "\x27\x04\xE1\x27\x04\xE1\xBE\x9B" - "\x78\xBE\x9B\x78\x55\x32\x0F\x55", - .klen = 32, - .iv = "\xE2\x24\x89\xEE\x53\xB8\x1D\x5F" - "\xC4\x29\x8E\xF3\x35\x9A\xFF\x64", - .input = "\x56\xED\x84\x1B\x8F\x26\xBD\x31" - "\xC8\x5F\xF6\x6A\x01\x98\x0C\xA3" - "\x3A\xD1\x45\xDC\x73\x0A\x7E\x15" - "\xAC\x20\xB7\x4E\xE5\x59\xF0\x87" - "\x1E\x92\x29\xC0\x34\xCB\x62\xF9" - "\x6D\x04\x9B\x0F\xA6\x3D\xD4\x48" - "\xDF\x76\x0D\x81\x18\xAF\x23\xBA" - "\x51\xE8\x5C\xF3\x8A\x21\x95\x2C" - "\xC3\x37\xCE\x65\xFC\x70\x07\x9E" - "\x12\xA9\x40\xD7\x4B\xE2\x79\x10" - "\x84\x1B\xB2\x26\xBD\x54\xEB\x5F" - "\xF6\x8D\x01\x98\x2F\xC6\x3A\xD1" - "\x68\xFF\x73\x0A\xA1\x15\xAC\x43" - "\xDA\x4E\xE5\x7C\x13\x87\x1E\xB5" - "\x29\xC0\x57\xEE\x62\xF9\x90\x04" - "\x9B\x32\xC9\x3D\xD4\x6B\x02\x76" - "\x0D\xA4\x18\xAF\x46\xDD\x51\xE8" - "\x7F\x16\x8A\x21\xB8\x2C\xC3\x5A" - "\xF1\x65\xFC\x93\x07\x9E\x35\xCC" - "\x40\xD7\x6E\x05\x79\x10\xA7\x1B" - "\xB2\x49\xE0\x54\xEB\x82\x19\x8D" - "\x24\xBB\x2F\xC6\x5D\xF4\x68\xFF" - "\x96\x0A\xA1\x38\xCF\x43\xDA\x71" - "\x08\x7C\x13\xAA\x1E\xB5\x4C\xE3" - "\x57\xEE\x85\x1C\x90\x27\xBE\x32" - "\xC9\x60\xF7\x6B\x02\x99\x0D\xA4" - "\x3B\xD2\x46\xDD\x74\x0B\x7F\x16" - "\xAD\x21\xB8\x4F\xE6\x5A\xF1\x88" - "\x1F\x93\x2A\xC1\x35\xCC\x63\xFA" - "\x6E\x05\x9C\x10\xA7\x3E\xD5\x49" - "\xE0\x77\x0E\x82\x19\xB0\x24\xBB" - "\x52\xE9\x5D\xF4\x8B\x22\x96\x2D" - "\xC4\x38\xCF\x66\xFD\x71\x08\x9F" - "\x13\xAA\x41\xD8\x4C\xE3\x7A\x11" - "\x85\x1C\xB3\x27\xBE\x55\xEC\x60" - "\xF7\x8E\x02\x99\x30\xC7\x3B\xD2" - "\x69\x00\x74\x0B\xA2\x16\xAD\x44" - "\xDB\x4F\xE6\x7D\x14\x88\x1F\xB6" - "\x2A\xC1\x58\xEF\x63\xFA\x91\x05" - "\x9C\x33\xCA\x3E\xD5\x6C\x03\x77" - "\x0E\xA5\x19\xB0\x47\xDE\x52\xE9" - "\x80\x17\x8B\x22\xB9\x2D\xC4\x5B" - "\xF2\x66\xFD\x94\x08\x9F\x36\xCD" - "\x41\xD8\x6F\x06\x7A\x11\xA8\x1C" - "\xB3\x4A\xE1\x55\xEC\x83\x1A\x8E" - "\x25\xBC\x30\xC7\x5E\xF5\x69\x00" - "\x97\x0B\xA2\x39\xD0\x44\xDB\x72" - "\x09\x7D\x14\xAB\x1F\xB6\x4D\xE4" - "\x58\xEF\x86\x1D\x91\x28\xBF\x33" - "\xCA\x61\xF8\x6C\x03\x9A\x0E\xA5" - "\x3C\xD3\x47\xDE\x75\x0C\x80\x17" - "\xAE\x22\xB9\x50\xE7\x5B\xF2\x89" - "\x20\x94\x2B\xC2\x36\xCD\x64\xFB" - "\x6F\x06\x9D\x11\xA8\x3F\xD6\x4A" - "\xE1\x78\x0F\x83\x1A\xB1\x25\xBC" - "\x53\xEA\x5E\xF5\x8C\x00\x97\x2E" - "\xC5\x39\xD0\x67\xFE\x72\x09\xA0" - "\x14\xAB\x42\xD9\x4D\xE4\x7B\x12" - "\x86\x1D\xB4\x28\xBF\x56\xED\x61" - "\xF8\x8F\x03\x9A\x31\xC8\x3C\xD3" - "\x6A\x01\x75\x0C\xA3\x17\xAE\x45" - "\xDC\x50\xE7\x7E\x15\x89\x20\xB7", - .ilen = 496, - .result = "\x26\x0A\xF1\xE2\x3F\x8A\xEF\xA3" - "\x53\x9A\x5E\x1B\x2A\x1A\xC6\x0A" - "\x57\xA3\xEF\x47\x2A\xE8\x88\xA7" - "\x3C\xD0\xEC\xB9\x94\x50\x7D\x56" - "\xBC\xE1\xC1\xF5\xE1\xEE\x12\xF8" - "\x4F\x03\x82\x3A\x93\x6B\x4C\xD3" - "\xE3\xF3\xFA\xC2\x23\x55\x98\x20" - "\x49\x76\x9B\x6B\xC1\x23\xBF\xE5" - "\xD4\xC4\x2F\x61\xE1\x67\x2A\x30" - "\x6F\x29\xCA\x54\xF8\x1B\xA6\x7D" - "\x66\x45\xEE\xC8\x19\xBE\x50\xF0" - "\x5F\x65\xF8\x1E\x4D\x07\x87\xD9" - "\xD3\xD9\x1B\x09\x89\xFD\x42\xC5" - "\xDB\xEB\x86\xF1\x67\x04\x0F\x5C" - "\x81\xDF\x82\x12\xC7\x4C\x1B\x07" - "\xDE\xE6\xFA\x29\x86\xD1\xB0\xBA" - "\x3D\x6A\x69\x76\xEC\x0F\xB4\xE6" - "\xCD\xA7\xF8\xA8\xB8\xE0\x33\xF5" - "\x49\x61\x22\x52\x64\x8C\x46\x41" - "\x1F\x48\x5F\x4F\xA2\x89\x36\x17" - "\x20\xF8\x2F\x8F\x4B\xFA\xF2\xC0" - "\x1E\x18\xA2\xF8\xB7\x6D\x98\xE3" - "\x00\x14\x15\x59\xC1\x30\x64\xAF" - "\xA8\x01\x38\xAB\xD4\x8B\xEC\x7C" - "\x44\x9A\xC6\x2C\x2E\x2B\x2B\xF4" - "\x02\x37\xC4\x69\xEF\x36\xC1\xF3" - "\xA0\xFB\xFE\x29\xAD\x39\xCF\xD0" - "\x51\x73\xA3\x22\x42\x41\xAB\xD2" - "\x0F\x50\x14\xB9\x54\xD3\xD4\xFA" - "\xBF\xC9\xBB\xCE\xC4\x1D\x2D\xAF" - "\xC9\x3F\x07\x87\x42\x4B\x3A\x54" - "\x34\x8E\x37\xA3\x03\x6F\x65\x66" - "\xDB\x44\xC3\xE8\xD7\xDD\x7D\xDD" - "\x61\xB4\x2B\x80\xA3\x98\x13\xF5" - "\x5A\xD3\x34\x58\xC3\x6E\xF6\xB8" - "\x0A\xC6\x50\x01\x8E\xD5\x6C\x7D" - "\xFE\x16\xB6\xCF\xFC\x51\x40\xAE" - "\xB3\x15\xAC\x90\x6F\x0B\x28\x3A" - "\x60\x40\x38\x90\x20\x46\xC7\xB3" - "\x0B\x12\x6D\x3B\x15\x14\xF9\xF4" - "\x11\x41\x76\x6B\xB3\x60\x82\x3C" - "\x84\xFB\x08\x2E\x92\x25\xCB\x79" - "\x6F\x58\xC5\x94\x00\x00\x47\xB6" - "\x9E\xDC\x0F\x29\x70\x46\x20\x76" - "\x65\x75\x66\x5C\x00\x96\xB3\xE1" - "\x0B\xA7\x11\x8B\x2E\x61\x4E\x45" - "\x73\xFC\x91\xAB\x79\x41\x23\x14" - "\x13\xB6\x72\x6C\x46\xB3\x03\x11" - "\xE4\xF1\xEE\xC9\x7A\xCF\x96\x32" - "\xB6\xF0\x8B\x97\xB4\xCF\x82\xB7" - "\x15\x48\x44\x99\x09\xF6\xE0\xD7" - "\xBC\xF1\x5B\x91\x4F\x30\x22\xA2" - "\x45\xC4\x68\x55\xC2\xBE\xA7\xD2" - "\x12\x53\x35\x9C\xF9\xE7\x35\x5D" - "\x81\xE4\x86\x42\xC3\x58\xFB\xF0" - "\x38\x9B\x8E\x5A\xEF\x83\x33\x0F" - "\x00\x4E\x3F\x9F\xF5\x84\x62\xC4" - "\x19\x35\x88\x22\x45\x59\x0E\x8F" - "\xEC\x27\xDD\x4A\xA4\x1F\xBC\x41" - "\x9B\x66\x8D\x32\xBA\x81\x34\x87" - "\x0E\x74\x33\x30\x62\xB9\x89\xDF" - "\xF9\xC5\xDD\x27\xB3\x39\xCB\xCB", - .rlen = 496, - .also_non_np = 1, - .np = 2, - .tap = { 496 - 16, 16 }, - }, -}; - -static struct cipher_testvec cast6_ctr_dec_tv_template[] = { - { /* Generated from TF test vectors */ - .key = "\x85\x62\x3F\x1C\xF9\xD6\x1C\xF9" - "\xD6\xB3\x90\x6D\x4A\x90\x6D\x4A" - "\x27\x04\xE1\x27\x04\xE1\xBE\x9B" - "\x78\xBE\x9B\x78\x55\x32\x0F\x55", - .klen = 32, - .iv = "\xE2\x24\x89\xEE\x53\xB8\x1D\x5F" - "\xC4\x29\x8E\xF3\x35\x9A\xFF\x64", - .input = "\x26\x0A\xF1\xE2\x3F\x8A\xEF\xA3" - "\x53\x9A\x5E\x1B\x2A\x1A\xC6\x0A" - "\x57", - .ilen = 17, - .result = "\x56\xED\x84\x1B\x8F\x26\xBD\x31" - "\xC8\x5F\xF6\x6A\x01\x98\x0C\xA3" - "\x3A", - .rlen = 17, - }, { /* Generated from TF test vectors */ - .key = "\x85\x62\x3F\x1C\xF9\xD6\x1C\xF9" - "\xD6\xB3\x90\x6D\x4A\x90\x6D\x4A" - "\x27\x04\xE1\x27\x04\xE1\xBE\x9B" - "\x78\xBE\x9B\x78\x55\x32\x0F\x55", - .klen = 32, - .iv = "\xE2\x24\x89\xEE\x53\xB8\x1D\x5F" - "\xC4\x29\x8E\xF3\x35\x9A\xFF\x64", - .input = "\x26\x0A\xF1\xE2\x3F\x8A\xEF\xA3" - "\x53\x9A\x5E\x1B\x2A\x1A\xC6\x0A" - "\x57\xA3\xEF\x47\x2A\xE8\x88\xA7" - "\x3C\xD0\xEC\xB9\x94\x50\x7D\x56" - "\xBC\xE1\xC1\xF5\xE1\xEE\x12\xF8" - "\x4F\x03\x82\x3A\x93\x6B\x4C\xD3" - "\xE3\xF3\xFA\xC2\x23\x55\x98\x20" - "\x49\x76\x9B\x6B\xC1\x23\xBF\xE5" - "\xD4\xC4\x2F\x61\xE1\x67\x2A\x30" - "\x6F\x29\xCA\x54\xF8\x1B\xA6\x7D" - "\x66\x45\xEE\xC8\x19\xBE\x50\xF0" - "\x5F\x65\xF8\x1E\x4D\x07\x87\xD9" - "\xD3\xD9\x1B\x09\x89\xFD\x42\xC5" - "\xDB\xEB\x86\xF1\x67\x04\x0F\x5C" - "\x81\xDF\x82\x12\xC7\x4C\x1B\x07" - "\xDE\xE6\xFA\x29\x86\xD1\xB0\xBA" - "\x3D\x6A\x69\x76\xEC\x0F\xB4\xE6" - "\xCD\xA7\xF8\xA8\xB8\xE0\x33\xF5" - "\x49\x61\x22\x52\x64\x8C\x46\x41" - "\x1F\x48\x5F\x4F\xA2\x89\x36\x17" - "\x20\xF8\x2F\x8F\x4B\xFA\xF2\xC0" - "\x1E\x18\xA2\xF8\xB7\x6D\x98\xE3" - "\x00\x14\x15\x59\xC1\x30\x64\xAF" - "\xA8\x01\x38\xAB\xD4\x8B\xEC\x7C" - "\x44\x9A\xC6\x2C\x2E\x2B\x2B\xF4" - "\x02\x37\xC4\x69\xEF\x36\xC1\xF3" - "\xA0\xFB\xFE\x29\xAD\x39\xCF\xD0" - "\x51\x73\xA3\x22\x42\x41\xAB\xD2" - "\x0F\x50\x14\xB9\x54\xD3\xD4\xFA" - "\xBF\xC9\xBB\xCE\xC4\x1D\x2D\xAF" - "\xC9\x3F\x07\x87\x42\x4B\x3A\x54" - "\x34\x8E\x37\xA3\x03\x6F\x65\x66" - "\xDB\x44\xC3\xE8\xD7\xDD\x7D\xDD" - "\x61\xB4\x2B\x80\xA3\x98\x13\xF5" - "\x5A\xD3\x34\x58\xC3\x6E\xF6\xB8" - "\x0A\xC6\x50\x01\x8E\xD5\x6C\x7D" - "\xFE\x16\xB6\xCF\xFC\x51\x40\xAE" - "\xB3\x15\xAC\x90\x6F\x0B\x28\x3A" - "\x60\x40\x38\x90\x20\x46\xC7\xB3" - "\x0B\x12\x6D\x3B\x15\x14\xF9\xF4" - "\x11\x41\x76\x6B\xB3\x60\x82\x3C" - "\x84\xFB\x08\x2E\x92\x25\xCB\x79" - "\x6F\x58\xC5\x94\x00\x00\x47\xB6" - "\x9E\xDC\x0F\x29\x70\x46\x20\x76" - "\x65\x75\x66\x5C\x00\x96\xB3\xE1" - "\x0B\xA7\x11\x8B\x2E\x61\x4E\x45" - "\x73\xFC\x91\xAB\x79\x41\x23\x14" - "\x13\xB6\x72\x6C\x46\xB3\x03\x11" - "\xE4\xF1\xEE\xC9\x7A\xCF\x96\x32" - "\xB6\xF0\x8B\x97\xB4\xCF\x82\xB7" - "\x15\x48\x44\x99\x09\xF6\xE0\xD7" - "\xBC\xF1\x5B\x91\x4F\x30\x22\xA2" - "\x45\xC4\x68\x55\xC2\xBE\xA7\xD2" - "\x12\x53\x35\x9C\xF9\xE7\x35\x5D" - "\x81\xE4\x86\x42\xC3\x58\xFB\xF0" - "\x38\x9B\x8E\x5A\xEF\x83\x33\x0F" - "\x00\x4E\x3F\x9F\xF5\x84\x62\xC4" - "\x19\x35\x88\x22\x45\x59\x0E\x8F" - "\xEC\x27\xDD\x4A\xA4\x1F\xBC\x41" - "\x9B\x66\x8D\x32\xBA\x81\x34\x87" - "\x0E\x74\x33\x30\x62\xB9\x89\xDF" - "\xF9\xC5\xDD\x27\xB3\x39\xCB\xCB", - .ilen = 496, - .result = "\x56\xED\x84\x1B\x8F\x26\xBD\x31" - "\xC8\x5F\xF6\x6A\x01\x98\x0C\xA3" - "\x3A\xD1\x45\xDC\x73\x0A\x7E\x15" - "\xAC\x20\xB7\x4E\xE5\x59\xF0\x87" - "\x1E\x92\x29\xC0\x34\xCB\x62\xF9" - "\x6D\x04\x9B\x0F\xA6\x3D\xD4\x48" - "\xDF\x76\x0D\x81\x18\xAF\x23\xBA" - "\x51\xE8\x5C\xF3\x8A\x21\x95\x2C" - "\xC3\x37\xCE\x65\xFC\x70\x07\x9E" - "\x12\xA9\x40\xD7\x4B\xE2\x79\x10" - "\x84\x1B\xB2\x26\xBD\x54\xEB\x5F" - "\xF6\x8D\x01\x98\x2F\xC6\x3A\xD1" - "\x68\xFF\x73\x0A\xA1\x15\xAC\x43" - "\xDA\x4E\xE5\x7C\x13\x87\x1E\xB5" - "\x29\xC0\x57\xEE\x62\xF9\x90\x04" - "\x9B\x32\xC9\x3D\xD4\x6B\x02\x76" - "\x0D\xA4\x18\xAF\x46\xDD\x51\xE8" - "\x7F\x16\x8A\x21\xB8\x2C\xC3\x5A" - "\xF1\x65\xFC\x93\x07\x9E\x35\xCC" - "\x40\xD7\x6E\x05\x79\x10\xA7\x1B" - "\xB2\x49\xE0\x54\xEB\x82\x19\x8D" - "\x24\xBB\x2F\xC6\x5D\xF4\x68\xFF" - "\x96\x0A\xA1\x38\xCF\x43\xDA\x71" - "\x08\x7C\x13\xAA\x1E\xB5\x4C\xE3" - "\x57\xEE\x85\x1C\x90\x27\xBE\x32" - "\xC9\x60\xF7\x6B\x02\x99\x0D\xA4" - "\x3B\xD2\x46\xDD\x74\x0B\x7F\x16" - "\xAD\x21\xB8\x4F\xE6\x5A\xF1\x88" - "\x1F\x93\x2A\xC1\x35\xCC\x63\xFA" - "\x6E\x05\x9C\x10\xA7\x3E\xD5\x49" - "\xE0\x77\x0E\x82\x19\xB0\x24\xBB" - "\x52\xE9\x5D\xF4\x8B\x22\x96\x2D" - "\xC4\x38\xCF\x66\xFD\x71\x08\x9F" - "\x13\xAA\x41\xD8\x4C\xE3\x7A\x11" - "\x85\x1C\xB3\x27\xBE\x55\xEC\x60" - "\xF7\x8E\x02\x99\x30\xC7\x3B\xD2" - "\x69\x00\x74\x0B\xA2\x16\xAD\x44" - "\xDB\x4F\xE6\x7D\x14\x88\x1F\xB6" - "\x2A\xC1\x58\xEF\x63\xFA\x91\x05" - "\x9C\x33\xCA\x3E\xD5\x6C\x03\x77" - "\x0E\xA5\x19\xB0\x47\xDE\x52\xE9" - "\x80\x17\x8B\x22\xB9\x2D\xC4\x5B" - "\xF2\x66\xFD\x94\x08\x9F\x36\xCD" - "\x41\xD8\x6F\x06\x7A\x11\xA8\x1C" - "\xB3\x4A\xE1\x55\xEC\x83\x1A\x8E" - "\x25\xBC\x30\xC7\x5E\xF5\x69\x00" - "\x97\x0B\xA2\x39\xD0\x44\xDB\x72" - "\x09\x7D\x14\xAB\x1F\xB6\x4D\xE4" - "\x58\xEF\x86\x1D\x91\x28\xBF\x33" - "\xCA\x61\xF8\x6C\x03\x9A\x0E\xA5" - "\x3C\xD3\x47\xDE\x75\x0C\x80\x17" - "\xAE\x22\xB9\x50\xE7\x5B\xF2\x89" - "\x20\x94\x2B\xC2\x36\xCD\x64\xFB" - "\x6F\x06\x9D\x11\xA8\x3F\xD6\x4A" - "\xE1\x78\x0F\x83\x1A\xB1\x25\xBC" - "\x53\xEA\x5E\xF5\x8C\x00\x97\x2E" - "\xC5\x39\xD0\x67\xFE\x72\x09\xA0" - "\x14\xAB\x42\xD9\x4D\xE4\x7B\x12" - "\x86\x1D\xB4\x28\xBF\x56\xED\x61" - "\xF8\x8F\x03\x9A\x31\xC8\x3C\xD3" - "\x6A\x01\x75\x0C\xA3\x17\xAE\x45" - "\xDC\x50\xE7\x7E\x15\x89\x20\xB7", - .rlen = 496, - .also_non_np = 1, - .np = 2, - .tap = { 496 - 16, 16 }, - }, -}; - -static struct cipher_testvec cast6_lrw_enc_tv_template[] = { - { /* Generated from TF test vectors */ - .key = "\xf8\xd4\x76\xff\xd6\x46\xee\x6c" - "\x23\x84\xcb\x1c\x77\xd6\x19\x5d" - "\xfe\xf1\xa9\xf3\x7b\xbc\x8d\x21" - "\xa7\x9c\x21\xf8\xcb\x90\x02\x89" - "\xa8\x45\x34\x8e\xc8\xc5\xb5\xf1" - "\x26\xf5\x0e\x76\xfe\xfd\x1b\x1e", - .klen = 48, - .iv = "\x00\x00\x00\x00\x00\x00\x00\x00" - "\x00\x00\x00\x00\x00\x00\x00\x01", - .input = "\x05\x11\xb7\x18\xab\xc6\x2d\xac" - "\x70\x5d\xf6\x22\x94\xcd\xe5\x6c" - "\x17\x6b\xf6\x1c\xf0\xf3\x6e\xf8" - "\x50\x38\x1f\x71\x49\xb6\x57\xd6" - "\x8f\xcb\x8d\x6b\xe3\xa6\x29\x90" - "\xfe\x2a\x62\x82\xae\x6d\x8b\xf6" - "\xad\x1e\x9e\x20\x5f\x38\xbe\x04" - "\xda\x10\x8e\xed\xa2\xa4\x87\xab" - "\xda\x6b\xb4\x0c\x75\xba\xd3\x7c" - "\xc9\xac\x42\x31\x95\x7c\xc9\x04" - "\xeb\xd5\x6e\x32\x69\x8a\xdb\xa6" - "\x15\xd7\x3f\x4f\x2f\x66\x69\x03" - "\x9c\x1f\x54\x0f\xde\x1f\xf3\x65" - "\x4c\x96\x12\xed\x7c\x92\x03\x01" - "\x6f\xbc\x35\x93\xac\xf1\x27\xf1" - "\xb4\x96\x82\x5a\x5f\xb0\xa0\x50" - "\x89\xa4\x8e\x66\x44\x85\xcc\xfd" - "\x33\x14\x70\xe3\x96\xb2\xc3\xd3" - "\xbb\x54\x5a\x1a\xf9\x74\xa2\xc5" - "\x2d\x64\x75\xdd\xb4\x54\xe6\x74" - "\x8c\xd3\x9d\x9e\x86\xab\x51\x53" - "\xb7\x93\x3e\x6f\xd0\x4e\x2c\x40" - "\xf6\xa8\x2e\x3e\x9d\xf4\x66\xa5" - "\x76\x12\x73\x44\x1a\x56\xd7\x72" - "\x88\xcd\x21\x8c\x4c\x0f\xfe\xda" - "\x95\xe0\x3a\xa6\xa5\x84\x46\xcd" - "\xd5\x3e\x9d\x3a\xe2\x67\xe6\x60" - "\x1a\xe2\x70\x85\x58\xc2\x1b\x09" - "\xe1\xd7\x2c\xca\xad\xa8\x8f\xf9" - "\xac\xb3\x0e\xdb\xca\x2e\xe2\xb8" - "\x51\x71\xd9\x3c\x6c\xf1\x56\xf8" - "\xea\x9c\xf1\xfb\x0c\xe6\xb7\x10" - "\x1c\xf8\xa9\x7c\xe8\x53\x35\xc1" - "\x90\x3e\x76\x4a\x74\xa4\x21\x2c" - "\xf6\x2c\x4e\x0f\x94\x3a\x88\x2e" - "\x41\x09\x6a\x33\x7d\xf6\xdd\x3f" - "\x8d\x23\x31\x74\x84\xeb\x88\x6e" - "\xcc\xb9\xbc\x22\x83\x19\x07\x22" - "\xa5\x2d\xdf\xa5\xf3\x80\x85\x78" - "\x84\x39\x6a\x6d\x6a\x99\x4f\xa5" - "\x15\xfe\x46\xb0\xe4\x6c\xa5\x41" - "\x3c\xce\x8f\x42\x60\x71\xa7\x75" - "\x08\x40\x65\x8a\x82\xbf\xf5\x43" - "\x71\x96\xa9\x4d\x44\x8a\x20\xbe" - "\xfa\x4d\xbb\xc0\x7d\x31\x96\x65" - "\xe7\x75\xe5\x3e\xfd\x92\x3b\xc9" - "\x55\xbb\x16\x7e\xf7\xc2\x8c\xa4" - "\x40\x1d\xe5\xef\x0e\xdf\xe4\x9a" - "\x62\x73\x65\xfd\x46\x63\x25\x3d" - "\x2b\xaf\xe5\x64\xfe\xa5\x5c\xcf" - "\x24\xf3\xb4\xac\x64\xba\xdf\x4b" - "\xc6\x96\x7d\x81\x2d\x8d\x97\xf7" - "\xc5\x68\x77\x84\x32\x2b\xcc\x85" - "\x74\x96\xf0\x12\x77\x61\xb9\xeb" - "\x71\xaa\x82\xcb\x1c\xdb\x89\xc8" - "\xc6\xb5\xe3\x5c\x7d\x39\x07\x24" - "\xda\x39\x87\x45\xc0\x2b\xbb\x01" - "\xac\xbc\x2a\x5c\x7f\xfc\xe8\xce" - "\x6d\x9c\x6f\xed\xd3\xc1\xa1\xd6" - "\xc5\x55\xa9\x66\x2f\xe1\xc8\x32" - "\xa6\x5d\xa4\x3a\x98\x73\xe8\x45" - "\xa4\xc7\xa8\xb4\xf6\x13\x03\xf6" - "\xe9\x2e\xc4\x29\x0f\x84\xdb\xc4" - "\x21\xc4\xc2\x75\x67\x89\x37\x0a", - .ilen = 512, - .result = "\x55\x25\x09\x8B\xB5\xD5\xF8\xBF" - "\x37\x4A\xFE\x3C\x47\xD8\xE6\xEB" - "\xCA\xA4\x9B\xB0\xAB\x6D\x64\xCA" - "\x58\xB6\x73\xF0\xD7\x52\x34\xEF" - "\xFB\x3E\x96\x81\xB7\x71\x34\xA4" - "\x55\x20\xBE\x39\x5A\x2B\xF9\xD1" - "\x65\x0B\xDA\xD3\x7E\xB3\xA6\xF7" - "\x2E\x0B\x5A\x52\xDB\x39\x8C\x9B" - "\x61\x17\x5F\xAF\xB6\x5A\xC8\x08" - "\xA7\xB7\x2A\x11\x7C\x97\x38\x9D" - "\x59\x0E\x66\x59\x5E\xD8\x8B\xCE" - "\x70\xE0\xC3\x42\xB0\x8C\x0F\xBA" - "\xB2\x0D\x81\xB6\xBE\x61\x1C\x2D" - "\x7E\xEA\x91\x25\xAC\xEC\xF8\x28" - "\x80\x1D\xF0\x30\xBA\x62\x77\x7D" - "\xDB\x15\x69\xDF\xFA\x2A\x81\x64" - "\x95\x5B\xA4\x7F\x3E\x4F\xE3\x30" - "\xB0\x5C\xC2\x05\xF8\xF0\x29\xE7" - "\x0A\xA0\x66\xB2\x5D\x0F\x39\x2B" - "\xB4\xB3\x00\xA9\xD0\xAB\x63\x61" - "\x5E\xDB\xFC\x11\x74\x25\x96\x65" - "\xE8\xE2\x34\x57\x77\x15\x5E\x70" - "\xFF\x10\x90\xC3\x64\xF0\x11\x0A" - "\x63\x3A\xD3\x55\x92\x15\x4B\x0C" - "\xC7\x08\x89\x17\x3B\x99\xAD\x63" - "\xE7\x06\xDF\x52\xBC\x15\x64\x45" - "\x9D\x7A\xFB\x69\xBC\x2D\x6E\xA9" - "\x35\xD9\xD8\xF5\x0C\xC4\xA2\x23" - "\x9C\x18\x8B\xA8\x8C\xFE\xF8\x0E" - "\xBD\xAB\x60\x1A\x51\x17\x54\x27" - "\xB6\xE8\xBE\x0F\xA9\xA5\x82\x19" - "\x2F\x6F\x20\xA7\x47\xED\x74\x6C" - "\x4E\xC1\xF8\x8C\x14\xF3\xBB\x1F" - "\xED\x4D\x8F\x7C\x37\xEF\x19\xA1" - "\x07\x16\xDE\x76\xCC\x5E\x94\x02" - "\xFB\xBF\xE4\x81\x50\xCE\xFC\x0F" - "\x9E\xCF\x3D\xF6\x67\x00\xBF\xA7" - "\x6E\x21\x58\x36\x06\xDE\xB3\xD4" - "\xA2\xFA\xD8\x4E\xE0\xB9\x7F\x23" - "\x51\x21\x2B\x32\x68\xAA\xF8\xA8" - "\x93\x08\xB5\x6D\xE6\x43\x2C\xB7" - "\x31\xB2\x0F\xD0\xA2\x51\xC0\x25" - "\x30\xC7\x10\x3F\x97\x27\x01\x8E" - "\xFA\xD8\x4F\x78\xD8\x2E\x1D\xEB" - "\xA1\x37\x52\x0F\x7B\x5E\x87\xA8" - "\x22\xE2\xE6\x92\xA7\x5F\x11\x32" - "\xCC\x93\x34\xFC\xD1\x7E\xAE\x54" - "\xBC\x6A\x1B\x91\xD1\x2E\x21\xEC" - "\x5D\xF1\xC4\xF1\x55\x20\xBF\xE5" - "\x96\x3D\x69\x91\x20\x4E\xF2\x61" - "\xDA\x77\xFE\xEE\xC3\x74\x57\x2A" - "\x78\x39\xB0\xE0\xCF\x12\x56\xD6" - "\x05\xDC\xF9\x19\x66\x44\x1D\xF9" - "\x82\x37\xD4\xC2\x60\xB6\x31\xDF" - "\x0C\xAF\xBC\x8B\x55\x9A\xC8\x2D" - "\xAB\xA7\x88\x7B\x41\xE8\x29\xC9" - "\x9B\x8D\xA7\x00\x86\x25\xB6\x14" - "\xF5\x13\x73\xD7\x4B\x6B\x83\xF3" - "\xAF\x96\x00\xE4\xB7\x3C\x65\xA6" - "\x15\xB7\x94\x7D\x4E\x70\x4C\x75" - "\xF3\xB4\x02\xA9\x17\x1C\x7A\x0A" - "\xC0\xD5\x33\x11\x56\xDE\xDC\xF5" - "\x8D\xD9\xCD\x3B\x22\x67\x18\xC7" - "\xC4\xF5\x99\x61\xBC\xBB\x5B\x46", - .rlen = 512, - .also_non_np = 1, - .np = 2, - .tap = { 512 - 16, 16 }, - }, -}; - -static struct cipher_testvec cast6_lrw_dec_tv_template[] = { - { /* Generated from TF test vectors */ - .key = "\xf8\xd4\x76\xff\xd6\x46\xee\x6c" - "\x23\x84\xcb\x1c\x77\xd6\x19\x5d" - "\xfe\xf1\xa9\xf3\x7b\xbc\x8d\x21" - "\xa7\x9c\x21\xf8\xcb\x90\x02\x89" - "\xa8\x45\x34\x8e\xc8\xc5\xb5\xf1" - "\x26\xf5\x0e\x76\xfe\xfd\x1b\x1e", - .klen = 48, - .iv = "\x00\x00\x00\x00\x00\x00\x00\x00" - "\x00\x00\x00\x00\x00\x00\x00\x01", - .input = "\x55\x25\x09\x8B\xB5\xD5\xF8\xBF" - "\x37\x4A\xFE\x3C\x47\xD8\xE6\xEB" - "\xCA\xA4\x9B\xB0\xAB\x6D\x64\xCA" - "\x58\xB6\x73\xF0\xD7\x52\x34\xEF" - "\xFB\x3E\x96\x81\xB7\x71\x34\xA4" - "\x55\x20\xBE\x39\x5A\x2B\xF9\xD1" - "\x65\x0B\xDA\xD3\x7E\xB3\xA6\xF7" - "\x2E\x0B\x5A\x52\xDB\x39\x8C\x9B" - "\x61\x17\x5F\xAF\xB6\x5A\xC8\x08" - "\xA7\xB7\x2A\x11\x7C\x97\x38\x9D" - "\x59\x0E\x66\x59\x5E\xD8\x8B\xCE" - "\x70\xE0\xC3\x42\xB0\x8C\x0F\xBA" - "\xB2\x0D\x81\xB6\xBE\x61\x1C\x2D" - "\x7E\xEA\x91\x25\xAC\xEC\xF8\x28" - "\x80\x1D\xF0\x30\xBA\x62\x77\x7D" - "\xDB\x15\x69\xDF\xFA\x2A\x81\x64" - "\x95\x5B\xA4\x7F\x3E\x4F\xE3\x30" - "\xB0\x5C\xC2\x05\xF8\xF0\x29\xE7" - "\x0A\xA0\x66\xB2\x5D\x0F\x39\x2B" - "\xB4\xB3\x00\xA9\xD0\xAB\x63\x61" - "\x5E\xDB\xFC\x11\x74\x25\x96\x65" - "\xE8\xE2\x34\x57\x77\x15\x5E\x70" - "\xFF\x10\x90\xC3\x64\xF0\x11\x0A" - "\x63\x3A\xD3\x55\x92\x15\x4B\x0C" - "\xC7\x08\x89\x17\x3B\x99\xAD\x63" - "\xE7\x06\xDF\x52\xBC\x15\x64\x45" - "\x9D\x7A\xFB\x69\xBC\x2D\x6E\xA9" - "\x35\xD9\xD8\xF5\x0C\xC4\xA2\x23" - "\x9C\x18\x8B\xA8\x8C\xFE\xF8\x0E" - "\xBD\xAB\x60\x1A\x51\x17\x54\x27" - "\xB6\xE8\xBE\x0F\xA9\xA5\x82\x19" - "\x2F\x6F\x20\xA7\x47\xED\x74\x6C" - "\x4E\xC1\xF8\x8C\x14\xF3\xBB\x1F" - "\xED\x4D\x8F\x7C\x37\xEF\x19\xA1" - "\x07\x16\xDE\x76\xCC\x5E\x94\x02" - "\xFB\xBF\xE4\x81\x50\xCE\xFC\x0F" - "\x9E\xCF\x3D\xF6\x67\x00\xBF\xA7" - "\x6E\x21\x58\x36\x06\xDE\xB3\xD4" - "\xA2\xFA\xD8\x4E\xE0\xB9\x7F\x23" - "\x51\x21\x2B\x32\x68\xAA\xF8\xA8" - "\x93\x08\xB5\x6D\xE6\x43\x2C\xB7" - "\x31\xB2\x0F\xD0\xA2\x51\xC0\x25" - "\x30\xC7\x10\x3F\x97\x27\x01\x8E" - "\xFA\xD8\x4F\x78\xD8\x2E\x1D\xEB" - "\xA1\x37\x52\x0F\x7B\x5E\x87\xA8" - "\x22\xE2\xE6\x92\xA7\x5F\x11\x32" - "\xCC\x93\x34\xFC\xD1\x7E\xAE\x54" - "\xBC\x6A\x1B\x91\xD1\x2E\x21\xEC" - "\x5D\xF1\xC4\xF1\x55\x20\xBF\xE5" - "\x96\x3D\x69\x91\x20\x4E\xF2\x61" - "\xDA\x77\xFE\xEE\xC3\x74\x57\x2A" - "\x78\x39\xB0\xE0\xCF\x12\x56\xD6" - "\x05\xDC\xF9\x19\x66\x44\x1D\xF9" - "\x82\x37\xD4\xC2\x60\xB6\x31\xDF" - "\x0C\xAF\xBC\x8B\x55\x9A\xC8\x2D" - "\xAB\xA7\x88\x7B\x41\xE8\x29\xC9" - "\x9B\x8D\xA7\x00\x86\x25\xB6\x14" - "\xF5\x13\x73\xD7\x4B\x6B\x83\xF3" - "\xAF\x96\x00\xE4\xB7\x3C\x65\xA6" - "\x15\xB7\x94\x7D\x4E\x70\x4C\x75" - "\xF3\xB4\x02\xA9\x17\x1C\x7A\x0A" - "\xC0\xD5\x33\x11\x56\xDE\xDC\xF5" - "\x8D\xD9\xCD\x3B\x22\x67\x18\xC7" - "\xC4\xF5\x99\x61\xBC\xBB\x5B\x46", - .ilen = 512, - .result = "\x05\x11\xb7\x18\xab\xc6\x2d\xac" - "\x70\x5d\xf6\x22\x94\xcd\xe5\x6c" - "\x17\x6b\xf6\x1c\xf0\xf3\x6e\xf8" - "\x50\x38\x1f\x71\x49\xb6\x57\xd6" - "\x8f\xcb\x8d\x6b\xe3\xa6\x29\x90" - "\xfe\x2a\x62\x82\xae\x6d\x8b\xf6" - "\xad\x1e\x9e\x20\x5f\x38\xbe\x04" - "\xda\x10\x8e\xed\xa2\xa4\x87\xab" - "\xda\x6b\xb4\x0c\x75\xba\xd3\x7c" - "\xc9\xac\x42\x31\x95\x7c\xc9\x04" - "\xeb\xd5\x6e\x32\x69\x8a\xdb\xa6" - "\x15\xd7\x3f\x4f\x2f\x66\x69\x03" - "\x9c\x1f\x54\x0f\xde\x1f\xf3\x65" - "\x4c\x96\x12\xed\x7c\x92\x03\x01" - "\x6f\xbc\x35\x93\xac\xf1\x27\xf1" - "\xb4\x96\x82\x5a\x5f\xb0\xa0\x50" - "\x89\xa4\x8e\x66\x44\x85\xcc\xfd" - "\x33\x14\x70\xe3\x96\xb2\xc3\xd3" - "\xbb\x54\x5a\x1a\xf9\x74\xa2\xc5" - "\x2d\x64\x75\xdd\xb4\x54\xe6\x74" - "\x8c\xd3\x9d\x9e\x86\xab\x51\x53" - "\xb7\x93\x3e\x6f\xd0\x4e\x2c\x40" - "\xf6\xa8\x2e\x3e\x9d\xf4\x66\xa5" - "\x76\x12\x73\x44\x1a\x56\xd7\x72" - "\x88\xcd\x21\x8c\x4c\x0f\xfe\xda" - "\x95\xe0\x3a\xa6\xa5\x84\x46\xcd" - "\xd5\x3e\x9d\x3a\xe2\x67\xe6\x60" - "\x1a\xe2\x70\x85\x58\xc2\x1b\x09" - "\xe1\xd7\x2c\xca\xad\xa8\x8f\xf9" - "\xac\xb3\x0e\xdb\xca\x2e\xe2\xb8" - "\x51\x71\xd9\x3c\x6c\xf1\x56\xf8" - "\xea\x9c\xf1\xfb\x0c\xe6\xb7\x10" - "\x1c\xf8\xa9\x7c\xe8\x53\x35\xc1" - "\x90\x3e\x76\x4a\x74\xa4\x21\x2c" - "\xf6\x2c\x4e\x0f\x94\x3a\x88\x2e" - "\x41\x09\x6a\x33\x7d\xf6\xdd\x3f" - "\x8d\x23\x31\x74\x84\xeb\x88\x6e" - "\xcc\xb9\xbc\x22\x83\x19\x07\x22" - "\xa5\x2d\xdf\xa5\xf3\x80\x85\x78" - "\x84\x39\x6a\x6d\x6a\x99\x4f\xa5" - "\x15\xfe\x46\xb0\xe4\x6c\xa5\x41" - "\x3c\xce\x8f\x42\x60\x71\xa7\x75" - "\x08\x40\x65\x8a\x82\xbf\xf5\x43" - "\x71\x96\xa9\x4d\x44\x8a\x20\xbe" - "\xfa\x4d\xbb\xc0\x7d\x31\x96\x65" - "\xe7\x75\xe5\x3e\xfd\x92\x3b\xc9" - "\x55\xbb\x16\x7e\xf7\xc2\x8c\xa4" - "\x40\x1d\xe5\xef\x0e\xdf\xe4\x9a" - "\x62\x73\x65\xfd\x46\x63\x25\x3d" - "\x2b\xaf\xe5\x64\xfe\xa5\x5c\xcf" - "\x24\xf3\xb4\xac\x64\xba\xdf\x4b" - "\xc6\x96\x7d\x81\x2d\x8d\x97\xf7" - "\xc5\x68\x77\x84\x32\x2b\xcc\x85" - "\x74\x96\xf0\x12\x77\x61\xb9\xeb" - "\x71\xaa\x82\xcb\x1c\xdb\x89\xc8" - "\xc6\xb5\xe3\x5c\x7d\x39\x07\x24" - "\xda\x39\x87\x45\xc0\x2b\xbb\x01" - "\xac\xbc\x2a\x5c\x7f\xfc\xe8\xce" - "\x6d\x9c\x6f\xed\xd3\xc1\xa1\xd6" - "\xc5\x55\xa9\x66\x2f\xe1\xc8\x32" - "\xa6\x5d\xa4\x3a\x98\x73\xe8\x45" - "\xa4\xc7\xa8\xb4\xf6\x13\x03\xf6" - "\xe9\x2e\xc4\x29\x0f\x84\xdb\xc4" - "\x21\xc4\xc2\x75\x67\x89\x37\x0a", - .rlen = 512, - .also_non_np = 1, - .np = 2, - .tap = { 512 - 16, 16 }, - }, -}; - -static struct cipher_testvec cast6_xts_enc_tv_template[] = { - { /* Generated from TF test vectors */ - .key = "\x27\x18\x28\x18\x28\x45\x90\x45" - "\x23\x53\x60\x28\x74\x71\x35\x26" - "\x62\x49\x77\x57\x24\x70\x93\x69" - "\x99\x59\x57\x49\x66\x96\x76\x27" - "\x31\x41\x59\x26\x53\x58\x97\x93" - "\x23\x84\x62\x64\x33\x83\x27\x95" - "\x02\x88\x41\x97\x16\x93\x99\x37" - "\x51\x05\x82\x09\x74\x94\x45\x92", - .klen = 64, - .iv = "\xff\x00\x00\x00\x00\x00\x00\x00" - "\x00\x00\x00\x00\x00\x00\x00\x00", - .input = "\x00\x01\x02\x03\x04\x05\x06\x07" - "\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f" - "\x10\x11\x12\x13\x14\x15\x16\x17" - "\x18\x19\x1a\x1b\x1c\x1d\x1e\x1f" - "\x20\x21\x22\x23\x24\x25\x26\x27" - "\x28\x29\x2a\x2b\x2c\x2d\x2e\x2f" - "\x30\x31\x32\x33\x34\x35\x36\x37" - "\x38\x39\x3a\x3b\x3c\x3d\x3e\x3f" - "\x40\x41\x42\x43\x44\x45\x46\x47" - "\x48\x49\x4a\x4b\x4c\x4d\x4e\x4f" - "\x50\x51\x52\x53\x54\x55\x56\x57" - "\x58\x59\x5a\x5b\x5c\x5d\x5e\x5f" - "\x60\x61\x62\x63\x64\x65\x66\x67" - "\x68\x69\x6a\x6b\x6c\x6d\x6e\x6f" - "\x70\x71\x72\x73\x74\x75\x76\x77" - "\x78\x79\x7a\x7b\x7c\x7d\x7e\x7f" - "\x80\x81\x82\x83\x84\x85\x86\x87" - "\x88\x89\x8a\x8b\x8c\x8d\x8e\x8f" - "\x90\x91\x92\x93\x94\x95\x96\x97" - "\x98\x99\x9a\x9b\x9c\x9d\x9e\x9f" - "\xa0\xa1\xa2\xa3\xa4\xa5\xa6\xa7" - "\xa8\xa9\xaa\xab\xac\xad\xae\xaf" - "\xb0\xb1\xb2\xb3\xb4\xb5\xb6\xb7" - "\xb8\xb9\xba\xbb\xbc\xbd\xbe\xbf" - "\xc0\xc1\xc2\xc3\xc4\xc5\xc6\xc7" - "\xc8\xc9\xca\xcb\xcc\xcd\xce\xcf" - "\xd0\xd1\xd2\xd3\xd4\xd5\xd6\xd7" - "\xd8\xd9\xda\xdb\xdc\xdd\xde\xdf" - "\xe0\xe1\xe2\xe3\xe4\xe5\xe6\xe7" - "\xe8\xe9\xea\xeb\xec\xed\xee\xef" - "\xf0\xf1\xf2\xf3\xf4\xf5\xf6\xf7" - "\xf8\xf9\xfa\xfb\xfc\xfd\xfe\xff" - "\x00\x01\x02\x03\x04\x05\x06\x07" - "\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f" - "\x10\x11\x12\x13\x14\x15\x16\x17" - "\x18\x19\x1a\x1b\x1c\x1d\x1e\x1f" - "\x20\x21\x22\x23\x24\x25\x26\x27" - "\x28\x29\x2a\x2b\x2c\x2d\x2e\x2f" - "\x30\x31\x32\x33\x34\x35\x36\x37" - "\x38\x39\x3a\x3b\x3c\x3d\x3e\x3f" - "\x40\x41\x42\x43\x44\x45\x46\x47" - "\x48\x49\x4a\x4b\x4c\x4d\x4e\x4f" - "\x50\x51\x52\x53\x54\x55\x56\x57" - "\x58\x59\x5a\x5b\x5c\x5d\x5e\x5f" - "\x60\x61\x62\x63\x64\x65\x66\x67" - "\x68\x69\x6a\x6b\x6c\x6d\x6e\x6f" - "\x70\x71\x72\x73\x74\x75\x76\x77" - "\x78\x79\x7a\x7b\x7c\x7d\x7e\x7f" - "\x80\x81\x82\x83\x84\x85\x86\x87" - "\x88\x89\x8a\x8b\x8c\x8d\x8e\x8f" - "\x90\x91\x92\x93\x94\x95\x96\x97" - "\x98\x99\x9a\x9b\x9c\x9d\x9e\x9f" - "\xa0\xa1\xa2\xa3\xa4\xa5\xa6\xa7" - "\xa8\xa9\xaa\xab\xac\xad\xae\xaf" - "\xb0\xb1\xb2\xb3\xb4\xb5\xb6\xb7" - "\xb8\xb9\xba\xbb\xbc\xbd\xbe\xbf" - "\xc0\xc1\xc2\xc3\xc4\xc5\xc6\xc7" - "\xc8\xc9\xca\xcb\xcc\xcd\xce\xcf" - "\xd0\xd1\xd2\xd3\xd4\xd5\xd6\xd7" - "\xd8\xd9\xda\xdb\xdc\xdd\xde\xdf" - "\xe0\xe1\xe2\xe3\xe4\xe5\xe6\xe7" - "\xe8\xe9\xea\xeb\xec\xed\xee\xef" - "\xf0\xf1\xf2\xf3\xf4\xf5\xf6\xf7" - "\xf8\xf9\xfa\xfb\xfc\xfd\xfe\xff", - .ilen = 512, - .result = "\xDE\x6F\x22\xA5\xE8\x39\xE8\x78" - "\x88\x5A\x4F\x8D\x82\x76\x52\x6D" - "\xB2\x41\x16\xF4\x2B\xA6\xEB\xF6" - "\xE2\xC5\x62\x8D\x61\xA1\x01\xED" - "\xD9\x38\x01\xC1\x43\x63\x4E\x88" - "\xC9\x4B\x5A\x88\x80\xB7\x5C\x71" - "\x47\xEE\x11\xD8\xB7\x2D\x5D\x13" - "\x1A\xB1\x68\x5B\x61\xA7\xA9\x81" - "\x8B\x83\xA1\x6A\xAA\x36\xD6\xB6" - "\x60\x54\x09\x32\xFE\x6A\x76\x2E" - "\x28\xFF\xD5\xD6\xDD\x1D\x45\x7D" - "\xF0\x8B\xF3\x32\x4E\x6C\x12\xCB" - "\xB8\x25\x70\xF8\x40\xBC\x90\x1B" - "\x11\xC3\x59\xAF\xF0\x2F\x92\xDD" - "\xD3\x3B\xCF\x60\xA1\x78\x94\x57" - "\xAF\x76\xC1\x67\xA6\x3C\xCD\x98" - "\xB1\xF7\x27\xB9\xA3\xBD\x10\xEA" - "\xCD\x8B\xC2\xF2\x14\xF2\xB2\x67" - "\x05\xDD\x1D\x58\x6E\x2F\x95\x08" - "\x3A\xF8\x78\x76\x82\x56\xA7\xEC" - "\x51\x4B\x85\x77\xC2\x4C\x4A\x34" - "\x71\x38\x17\x91\x44\xE8\xFC\x65" - "\x99\x0D\x52\x91\xEE\xF8\xEF\x27" - "\x2A\x9E\x6E\x78\xC4\x26\x87\xF4" - "\x8A\xF0\x2D\x04\xE8\x14\x92\x5D" - "\x59\x22\x9B\x29\x5C\x18\xF0\xC3" - "\x47\xF3\x76\xD8\xE4\xF3\x1B\xD1" - "\x70\xA3\x0D\xB5\x70\x02\x1D\xA3" - "\x91\x3B\x49\x73\x18\xAB\xD4\xC9" - "\xC3\x1E\xEF\x1F\xFE\xD5\x59\x8A" - "\xD7\xF6\xC9\x71\x67\x79\xD7\x0E" - "\xBE\x1F\x8E\xEC\x55\x7E\x4F\x24" - "\xE6\x87\xEA\xFE\x96\x25\x67\x8E" - "\x93\x03\xFA\xFF\xCE\xAF\xB2\x3C" - "\x6F\xEB\x57\xFB\xD3\x28\x87\xA9" - "\xCE\xC2\xF5\x9C\xC6\x67\xB5\x97" - "\x49\xF7\x04\xCB\xEF\x84\x98\x33" - "\xAF\x38\xD3\x04\x1C\x24\x71\x38" - "\xC7\x71\xDD\x43\x0D\x12\x4A\x18" - "\xBA\xC4\xAF\xBA\xB2\x5B\xEB\x95" - "\x02\x43\x5D\xCE\x19\xCC\xCD\x66" - "\x91\x0B\x8C\x7F\x51\xC4\xBF\x3C" - "\x8B\xF1\xCC\xAA\x29\xD7\x87\xCB" - "\x3E\xC5\xF3\xC9\x75\xE8\xA3\x5B" - "\x30\x45\xA9\xB7\xAF\x80\x64\x6F" - "\x75\x4A\xA7\xC0\x6D\x19\x6B\xDE" - "\x17\xDE\x6D\xEA\x87\x9F\x95\xAE" - "\xF5\x3C\xEE\x54\xB8\x27\x84\xF8" - "\x97\xA3\xE1\x6F\x38\x24\x34\x88" - "\xCE\xBD\x32\x52\xE0\x00\x6C\x94" - "\xC9\xD7\x5D\x37\x81\x33\x2E\x7F" - "\x4F\x7E\x2E\x0D\x94\xBD\xEA\x59" - "\x34\x39\xA8\x35\x12\xB7\xBC\xAC" - "\xEA\x52\x9C\x78\x02\x6D\x92\x36" - "\xFB\x59\x2B\xA4\xEA\x7B\x1B\x83" - "\xE1\x4D\x5E\x2A\x7E\x92\xB1\x64" - "\xDE\xE0\x27\x4B\x0A\x6F\x4C\xE3" - "\xB0\xEB\x31\xE4\x69\x95\xAB\x35" - "\x8B\x2C\xF5\x6B\x7F\xF1\xA2\x82" - "\xF8\xD9\x47\x82\xA9\x82\x03\x91" - "\x69\x1F\xBE\x4C\xE7\xC7\x34\x2F" - "\x45\x72\x80\x17\x81\xBD\x9D\x62" - "\xA1\xAC\xE8\xCF\xC6\x74\xCF\xDC" - "\x22\x60\x4E\xE8\xA4\x5D\x85\xB9", - .rlen = 512, - .also_non_np = 1, - .np = 2, - .tap = { 512 - 16, 16 }, - }, -}; - -static struct cipher_testvec cast6_xts_dec_tv_template[] = { - { /* Generated from TF test vectors */ - .key = "\x27\x18\x28\x18\x28\x45\x90\x45" - "\x23\x53\x60\x28\x74\x71\x35\x26" - "\x62\x49\x77\x57\x24\x70\x93\x69" - "\x99\x59\x57\x49\x66\x96\x76\x27" - "\x31\x41\x59\x26\x53\x58\x97\x93" - "\x23\x84\x62\x64\x33\x83\x27\x95" - "\x02\x88\x41\x97\x16\x93\x99\x37" - "\x51\x05\x82\x09\x74\x94\x45\x92", - .klen = 64, - .iv = "\xff\x00\x00\x00\x00\x00\x00\x00" - "\x00\x00\x00\x00\x00\x00\x00\x00", - .input = "\xDE\x6F\x22\xA5\xE8\x39\xE8\x78" - "\x88\x5A\x4F\x8D\x82\x76\x52\x6D" - "\xB2\x41\x16\xF4\x2B\xA6\xEB\xF6" - "\xE2\xC5\x62\x8D\x61\xA1\x01\xED" - "\xD9\x38\x01\xC1\x43\x63\x4E\x88" - "\xC9\x4B\x5A\x88\x80\xB7\x5C\x71" - "\x47\xEE\x11\xD8\xB7\x2D\x5D\x13" - "\x1A\xB1\x68\x5B\x61\xA7\xA9\x81" - "\x8B\x83\xA1\x6A\xAA\x36\xD6\xB6" - "\x60\x54\x09\x32\xFE\x6A\x76\x2E" - "\x28\xFF\xD5\xD6\xDD\x1D\x45\x7D" - "\xF0\x8B\xF3\x32\x4E\x6C\x12\xCB" - "\xB8\x25\x70\xF8\x40\xBC\x90\x1B" - "\x11\xC3\x59\xAF\xF0\x2F\x92\xDD" - "\xD3\x3B\xCF\x60\xA1\x78\x94\x57" - "\xAF\x76\xC1\x67\xA6\x3C\xCD\x98" - "\xB1\xF7\x27\xB9\xA3\xBD\x10\xEA" - "\xCD\x8B\xC2\xF2\x14\xF2\xB2\x67" - "\x05\xDD\x1D\x58\x6E\x2F\x95\x08" - "\x3A\xF8\x78\x76\x82\x56\xA7\xEC" - "\x51\x4B\x85\x77\xC2\x4C\x4A\x34" - "\x71\x38\x17\x91\x44\xE8\xFC\x65" - "\x99\x0D\x52\x91\xEE\xF8\xEF\x27" - "\x2A\x9E\x6E\x78\xC4\x26\x87\xF4" - "\x8A\xF0\x2D\x04\xE8\x14\x92\x5D" - "\x59\x22\x9B\x29\x5C\x18\xF0\xC3" - "\x47\xF3\x76\xD8\xE4\xF3\x1B\xD1" - "\x70\xA3\x0D\xB5\x70\x02\x1D\xA3" - "\x91\x3B\x49\x73\x18\xAB\xD4\xC9" - "\xC3\x1E\xEF\x1F\xFE\xD5\x59\x8A" - "\xD7\xF6\xC9\x71\x67\x79\xD7\x0E" - "\xBE\x1F\x8E\xEC\x55\x7E\x4F\x24" - "\xE6\x87\xEA\xFE\x96\x25\x67\x8E" - "\x93\x03\xFA\xFF\xCE\xAF\xB2\x3C" - "\x6F\xEB\x57\xFB\xD3\x28\x87\xA9" - "\xCE\xC2\xF5\x9C\xC6\x67\xB5\x97" - "\x49\xF7\x04\xCB\xEF\x84\x98\x33" - "\xAF\x38\xD3\x04\x1C\x24\x71\x38" - "\xC7\x71\xDD\x43\x0D\x12\x4A\x18" - "\xBA\xC4\xAF\xBA\xB2\x5B\xEB\x95" - "\x02\x43\x5D\xCE\x19\xCC\xCD\x66" - "\x91\x0B\x8C\x7F\x51\xC4\xBF\x3C" - "\x8B\xF1\xCC\xAA\x29\xD7\x87\xCB" - "\x3E\xC5\xF3\xC9\x75\xE8\xA3\x5B" - "\x30\x45\xA9\xB7\xAF\x80\x64\x6F" - "\x75\x4A\xA7\xC0\x6D\x19\x6B\xDE" - "\x17\xDE\x6D\xEA\x87\x9F\x95\xAE" - "\xF5\x3C\xEE\x54\xB8\x27\x84\xF8" - "\x97\xA3\xE1\x6F\x38\x24\x34\x88" - "\xCE\xBD\x32\x52\xE0\x00\x6C\x94" - "\xC9\xD7\x5D\x37\x81\x33\x2E\x7F" - "\x4F\x7E\x2E\x0D\x94\xBD\xEA\x59" - "\x34\x39\xA8\x35\x12\xB7\xBC\xAC" - "\xEA\x52\x9C\x78\x02\x6D\x92\x36" - "\xFB\x59\x2B\xA4\xEA\x7B\x1B\x83" - "\xE1\x4D\x5E\x2A\x7E\x92\xB1\x64" - "\xDE\xE0\x27\x4B\x0A\x6F\x4C\xE3" - "\xB0\xEB\x31\xE4\x69\x95\xAB\x35" - "\x8B\x2C\xF5\x6B\x7F\xF1\xA2\x82" - "\xF8\xD9\x47\x82\xA9\x82\x03\x91" - "\x69\x1F\xBE\x4C\xE7\xC7\x34\x2F" - "\x45\x72\x80\x17\x81\xBD\x9D\x62" - "\xA1\xAC\xE8\xCF\xC6\x74\xCF\xDC" - "\x22\x60\x4E\xE8\xA4\x5D\x85\xB9", - .ilen = 512, - .result = "\x00\x01\x02\x03\x04\x05\x06\x07" - "\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f" - "\x10\x11\x12\x13\x14\x15\x16\x17" - "\x18\x19\x1a\x1b\x1c\x1d\x1e\x1f" - "\x20\x21\x22\x23\x24\x25\x26\x27" - "\x28\x29\x2a\x2b\x2c\x2d\x2e\x2f" - "\x30\x31\x32\x33\x34\x35\x36\x37" - "\x38\x39\x3a\x3b\x3c\x3d\x3e\x3f" - "\x40\x41\x42\x43\x44\x45\x46\x47" - "\x48\x49\x4a\x4b\x4c\x4d\x4e\x4f" - "\x50\x51\x52\x53\x54\x55\x56\x57" - "\x58\x59\x5a\x5b\x5c\x5d\x5e\x5f" - "\x60\x61\x62\x63\x64\x65\x66\x67" - "\x68\x69\x6a\x6b\x6c\x6d\x6e\x6f" - "\x70\x71\x72\x73\x74\x75\x76\x77" - "\x78\x79\x7a\x7b\x7c\x7d\x7e\x7f" - "\x80\x81\x82\x83\x84\x85\x86\x87" - "\x88\x89\x8a\x8b\x8c\x8d\x8e\x8f" - "\x90\x91\x92\x93\x94\x95\x96\x97" - "\x98\x99\x9a\x9b\x9c\x9d\x9e\x9f" - "\xa0\xa1\xa2\xa3\xa4\xa5\xa6\xa7" - "\xa8\xa9\xaa\xab\xac\xad\xae\xaf" - "\xb0\xb1\xb2\xb3\xb4\xb5\xb6\xb7" - "\xb8\xb9\xba\xbb\xbc\xbd\xbe\xbf" - "\xc0\xc1\xc2\xc3\xc4\xc5\xc6\xc7" - "\xc8\xc9\xca\xcb\xcc\xcd\xce\xcf" - "\xd0\xd1\xd2\xd3\xd4\xd5\xd6\xd7" - "\xd8\xd9\xda\xdb\xdc\xdd\xde\xdf" - "\xe0\xe1\xe2\xe3\xe4\xe5\xe6\xe7" - "\xe8\xe9\xea\xeb\xec\xed\xee\xef" - "\xf0\xf1\xf2\xf3\xf4\xf5\xf6\xf7" - "\xf8\xf9\xfa\xfb\xfc\xfd\xfe\xff" - "\x00\x01\x02\x03\x04\x05\x06\x07" - "\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f" - "\x10\x11\x12\x13\x14\x15\x16\x17" - "\x18\x19\x1a\x1b\x1c\x1d\x1e\x1f" - "\x20\x21\x22\x23\x24\x25\x26\x27" - "\x28\x29\x2a\x2b\x2c\x2d\x2e\x2f" - "\x30\x31\x32\x33\x34\x35\x36\x37" - "\x38\x39\x3a\x3b\x3c\x3d\x3e\x3f" - "\x40\x41\x42\x43\x44\x45\x46\x47" - "\x48\x49\x4a\x4b\x4c\x4d\x4e\x4f" - "\x50\x51\x52\x53\x54\x55\x56\x57" - "\x58\x59\x5a\x5b\x5c\x5d\x5e\x5f" - "\x60\x61\x62\x63\x64\x65\x66\x67" - "\x68\x69\x6a\x6b\x6c\x6d\x6e\x6f" - "\x70\x71\x72\x73\x74\x75\x76\x77" - "\x78\x79\x7a\x7b\x7c\x7d\x7e\x7f" - "\x80\x81\x82\x83\x84\x85\x86\x87" - "\x88\x89\x8a\x8b\x8c\x8d\x8e\x8f" - "\x90\x91\x92\x93\x94\x95\x96\x97" - "\x98\x99\x9a\x9b\x9c\x9d\x9e\x9f" - "\xa0\xa1\xa2\xa3\xa4\xa5\xa6\xa7" - "\xa8\xa9\xaa\xab\xac\xad\xae\xaf" - "\xb0\xb1\xb2\xb3\xb4\xb5\xb6\xb7" - "\xb8\xb9\xba\xbb\xbc\xbd\xbe\xbf" - "\xc0\xc1\xc2\xc3\xc4\xc5\xc6\xc7" - "\xc8\xc9\xca\xcb\xcc\xcd\xce\xcf" - "\xd0\xd1\xd2\xd3\xd4\xd5\xd6\xd7" - "\xd8\xd9\xda\xdb\xdc\xdd\xde\xdf" - "\xe0\xe1\xe2\xe3\xe4\xe5\xe6\xe7" - "\xe8\xe9\xea\xeb\xec\xed\xee\xef" - "\xf0\xf1\xf2\xf3\xf4\xf5\xf6\xf7" - "\xf8\xf9\xfa\xfb\xfc\xfd\xfe\xff", - .rlen = 512, - .also_non_np = 1, - .np = 2, - .tap = { 512 - 16, 16 }, - }, -}; - - -/* - * AES test vectors. - */ -#define AES_ENC_TEST_VECTORS 3 -#define AES_DEC_TEST_VECTORS 3 -#define AES_CBC_ENC_TEST_VECTORS 4 -#define AES_CBC_DEC_TEST_VECTORS 4 -#define HMAC_SHA1_AES_CBC_ENC_TEST_VECTORS 7 -#define HMAC_SHA256_AES_CBC_ENC_TEST_VECTORS 7 -#define HMAC_SHA512_AES_CBC_ENC_TEST_VECTORS 7 -#define AES_LRW_ENC_TEST_VECTORS 8 -#define AES_LRW_DEC_TEST_VECTORS 8 -#define AES_XTS_ENC_TEST_VECTORS 5 -#define AES_XTS_DEC_TEST_VECTORS 5 -#define AES_CTR_ENC_TEST_VECTORS 3 -#define AES_CTR_DEC_TEST_VECTORS 3 -#define AES_OFB_ENC_TEST_VECTORS 1 -#define AES_OFB_DEC_TEST_VECTORS 1 -#define AES_CTR_3686_ENC_TEST_VECTORS 7 -#define AES_CTR_3686_DEC_TEST_VECTORS 6 -#define AES_GCM_ENC_TEST_VECTORS 9 -#define AES_GCM_DEC_TEST_VECTORS 8 -#define AES_GCM_4106_ENC_TEST_VECTORS 7 -#define AES_GCM_4106_DEC_TEST_VECTORS 7 -#define AES_CCM_ENC_TEST_VECTORS 7 -#define AES_CCM_DEC_TEST_VECTORS 7 -#define AES_CCM_4309_ENC_TEST_VECTORS 7 -#define AES_CCM_4309_DEC_TEST_VECTORS 10 - -static struct cipher_testvec aes_enc_tv_template[] = { - { /* From FIPS-197 */ - .key = "\x00\x01\x02\x03\x04\x05\x06\x07" - "\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f", - .klen = 16, - .input = "\x00\x11\x22\x33\x44\x55\x66\x77" - "\x88\x99\xaa\xbb\xcc\xdd\xee\xff", - .ilen = 16, - .result = "\x69\xc4\xe0\xd8\x6a\x7b\x04\x30" - "\xd8\xcd\xb7\x80\x70\xb4\xc5\x5a", - .rlen = 16, - }, { - .key = "\x00\x01\x02\x03\x04\x05\x06\x07" - "\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f" - "\x10\x11\x12\x13\x14\x15\x16\x17", - .klen = 24, - .input = "\x00\x11\x22\x33\x44\x55\x66\x77" - "\x88\x99\xaa\xbb\xcc\xdd\xee\xff", - .ilen = 16, - .result = "\xdd\xa9\x7c\xa4\x86\x4c\xdf\xe0" - "\x6e\xaf\x70\xa0\xec\x0d\x71\x91", - .rlen = 16, - }, { - .key = "\x00\x01\x02\x03\x04\x05\x06\x07" - "\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f" - "\x10\x11\x12\x13\x14\x15\x16\x17" - "\x18\x19\x1a\x1b\x1c\x1d\x1e\x1f", - .klen = 32, - .input = "\x00\x11\x22\x33\x44\x55\x66\x77" - "\x88\x99\xaa\xbb\xcc\xdd\xee\xff", - .ilen = 16, - .result = "\x8e\xa2\xb7\xca\x51\x67\x45\xbf" - "\xea\xfc\x49\x90\x4b\x49\x60\x89", - .rlen = 16, - }, -}; - -static struct cipher_testvec aes_dec_tv_template[] = { - { /* From FIPS-197 */ - .key = "\x00\x01\x02\x03\x04\x05\x06\x07" - "\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f", - .klen = 16, - .input = "\x69\xc4\xe0\xd8\x6a\x7b\x04\x30" - "\xd8\xcd\xb7\x80\x70\xb4\xc5\x5a", - .ilen = 16, - .result = "\x00\x11\x22\x33\x44\x55\x66\x77" - "\x88\x99\xaa\xbb\xcc\xdd\xee\xff", - .rlen = 16, - }, { - .key = "\x00\x01\x02\x03\x04\x05\x06\x07" - "\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f" - "\x10\x11\x12\x13\x14\x15\x16\x17", - .klen = 24, - .input = "\xdd\xa9\x7c\xa4\x86\x4c\xdf\xe0" - "\x6e\xaf\x70\xa0\xec\x0d\x71\x91", - .ilen = 16, - .result = "\x00\x11\x22\x33\x44\x55\x66\x77" - "\x88\x99\xaa\xbb\xcc\xdd\xee\xff", - .rlen = 16, - }, { - .key = "\x00\x01\x02\x03\x04\x05\x06\x07" - "\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f" - "\x10\x11\x12\x13\x14\x15\x16\x17" - "\x18\x19\x1a\x1b\x1c\x1d\x1e\x1f", - .klen = 32, - .input = "\x8e\xa2\xb7\xca\x51\x67\x45\xbf" - "\xea\xfc\x49\x90\x4b\x49\x60\x89", - .ilen = 16, - .result = "\x00\x11\x22\x33\x44\x55\x66\x77" - "\x88\x99\xaa\xbb\xcc\xdd\xee\xff", - .rlen = 16, - }, -}; - -static struct cipher_testvec aes_cbc_enc_tv_template[] = { - { /* From RFC 3602 */ - .key = "\x06\xa9\x21\x40\x36\xb8\xa1\x5b" - "\x51\x2e\x03\xd5\x34\x12\x00\x06", - .klen = 16, - .iv = "\x3d\xaf\xba\x42\x9d\x9e\xb4\x30" - "\xb4\x22\xda\x80\x2c\x9f\xac\x41", - .input = "Single block msg", - .ilen = 16, - .result = "\xe3\x53\x77\x9c\x10\x79\xae\xb8" - "\x27\x08\x94\x2d\xbe\x77\x18\x1a", - .rlen = 16, - }, { - .key = "\xc2\x86\x69\x6d\x88\x7c\x9a\xa0" - "\x61\x1b\xbb\x3e\x20\x25\xa4\x5a", - .klen = 16, - .iv = "\x56\x2e\x17\x99\x6d\x09\x3d\x28" - "\xdd\xb3\xba\x69\x5a\x2e\x6f\x58", - .input = "\x00\x01\x02\x03\x04\x05\x06\x07" - "\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f" - "\x10\x11\x12\x13\x14\x15\x16\x17" - "\x18\x19\x1a\x1b\x1c\x1d\x1e\x1f", - .ilen = 32, - .result = "\xd2\x96\xcd\x94\xc2\xcc\xcf\x8a" - "\x3a\x86\x30\x28\xb5\xe1\xdc\x0a" - "\x75\x86\x60\x2d\x25\x3c\xff\xf9" - "\x1b\x82\x66\xbe\xa6\xd6\x1a\xb1", - .rlen = 32, - }, { /* From NIST SP800-38A */ - .key = "\x8e\x73\xb0\xf7\xda\x0e\x64\x52" - "\xc8\x10\xf3\x2b\x80\x90\x79\xe5" - "\x62\xf8\xea\xd2\x52\x2c\x6b\x7b", - .klen = 24, - .iv = "\x00\x01\x02\x03\x04\x05\x06\x07" - "\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f", - .input = "\x6b\xc1\xbe\xe2\x2e\x40\x9f\x96" - "\xe9\x3d\x7e\x11\x73\x93\x17\x2a" - "\xae\x2d\x8a\x57\x1e\x03\xac\x9c" - "\x9e\xb7\x6f\xac\x45\xaf\x8e\x51" - "\x30\xc8\x1c\x46\xa3\x5c\xe4\x11" - "\xe5\xfb\xc1\x19\x1a\x0a\x52\xef" - "\xf6\x9f\x24\x45\xdf\x4f\x9b\x17" - "\xad\x2b\x41\x7b\xe6\x6c\x37\x10", - .ilen = 64, - .result = "\x4f\x02\x1d\xb2\x43\xbc\x63\x3d" - "\x71\x78\x18\x3a\x9f\xa0\x71\xe8" - "\xb4\xd9\xad\xa9\xad\x7d\xed\xf4" - "\xe5\xe7\x38\x76\x3f\x69\x14\x5a" - "\x57\x1b\x24\x20\x12\xfb\x7a\xe0" - "\x7f\xa9\xba\xac\x3d\xf1\x02\xe0" - "\x08\xb0\xe2\x79\x88\x59\x88\x81" - "\xd9\x20\xa9\xe6\x4f\x56\x15\xcd", - .rlen = 64, - }, { - .key = "\x60\x3d\xeb\x10\x15\xca\x71\xbe" - "\x2b\x73\xae\xf0\x85\x7d\x77\x81" - "\x1f\x35\x2c\x07\x3b\x61\x08\xd7" - "\x2d\x98\x10\xa3\x09\x14\xdf\xf4", - .klen = 32, - .iv = "\x00\x01\x02\x03\x04\x05\x06\x07" - "\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f", - .input = "\x6b\xc1\xbe\xe2\x2e\x40\x9f\x96" - "\xe9\x3d\x7e\x11\x73\x93\x17\x2a" - "\xae\x2d\x8a\x57\x1e\x03\xac\x9c" - "\x9e\xb7\x6f\xac\x45\xaf\x8e\x51" - "\x30\xc8\x1c\x46\xa3\x5c\xe4\x11" - "\xe5\xfb\xc1\x19\x1a\x0a\x52\xef" - "\xf6\x9f\x24\x45\xdf\x4f\x9b\x17" - "\xad\x2b\x41\x7b\xe6\x6c\x37\x10", - .ilen = 64, - .result = "\xf5\x8c\x4c\x04\xd6\xe5\xf1\xba" - "\x77\x9e\xab\xfb\x5f\x7b\xfb\xd6" - "\x9c\xfc\x4e\x96\x7e\xdb\x80\x8d" - "\x67\x9f\x77\x7b\xc6\x70\x2c\x7d" - "\x39\xf2\x33\x69\xa9\xd9\xba\xcf" - "\xa5\x30\xe2\x63\x04\x23\x14\x61" - "\xb2\xeb\x05\xe2\xc3\x9b\xe9\xfc" - "\xda\x6c\x19\x07\x8c\x6a\x9d\x1b", - .rlen = 64, - }, -}; - -static struct cipher_testvec aes_cbc_dec_tv_template[] = { - { /* From RFC 3602 */ - .key = "\x06\xa9\x21\x40\x36\xb8\xa1\x5b" - "\x51\x2e\x03\xd5\x34\x12\x00\x06", - .klen = 16, - .iv = "\x3d\xaf\xba\x42\x9d\x9e\xb4\x30" - "\xb4\x22\xda\x80\x2c\x9f\xac\x41", - .input = "\xe3\x53\x77\x9c\x10\x79\xae\xb8" - "\x27\x08\x94\x2d\xbe\x77\x18\x1a", - .ilen = 16, - .result = "Single block msg", - .rlen = 16, - }, { - .key = "\xc2\x86\x69\x6d\x88\x7c\x9a\xa0" - "\x61\x1b\xbb\x3e\x20\x25\xa4\x5a", - .klen = 16, - .iv = "\x56\x2e\x17\x99\x6d\x09\x3d\x28" - "\xdd\xb3\xba\x69\x5a\x2e\x6f\x58", - .input = "\xd2\x96\xcd\x94\xc2\xcc\xcf\x8a" - "\x3a\x86\x30\x28\xb5\xe1\xdc\x0a" - "\x75\x86\x60\x2d\x25\x3c\xff\xf9" - "\x1b\x82\x66\xbe\xa6\xd6\x1a\xb1", - .ilen = 32, - .result = "\x00\x01\x02\x03\x04\x05\x06\x07" - "\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f" - "\x10\x11\x12\x13\x14\x15\x16\x17" - "\x18\x19\x1a\x1b\x1c\x1d\x1e\x1f", - .rlen = 32, - }, { /* From NIST SP800-38A */ - .key = "\x8e\x73\xb0\xf7\xda\x0e\x64\x52" - "\xc8\x10\xf3\x2b\x80\x90\x79\xe5" - "\x62\xf8\xea\xd2\x52\x2c\x6b\x7b", - .klen = 24, - .iv = "\x00\x01\x02\x03\x04\x05\x06\x07" - "\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f", - .input = "\x4f\x02\x1d\xb2\x43\xbc\x63\x3d" - "\x71\x78\x18\x3a\x9f\xa0\x71\xe8" - "\xb4\xd9\xad\xa9\xad\x7d\xed\xf4" - "\xe5\xe7\x38\x76\x3f\x69\x14\x5a" - "\x57\x1b\x24\x20\x12\xfb\x7a\xe0" - "\x7f\xa9\xba\xac\x3d\xf1\x02\xe0" - "\x08\xb0\xe2\x79\x88\x59\x88\x81" - "\xd9\x20\xa9\xe6\x4f\x56\x15\xcd", - .ilen = 64, - .result = "\x6b\xc1\xbe\xe2\x2e\x40\x9f\x96" - "\xe9\x3d\x7e\x11\x73\x93\x17\x2a" - "\xae\x2d\x8a\x57\x1e\x03\xac\x9c" - "\x9e\xb7\x6f\xac\x45\xaf\x8e\x51" - "\x30\xc8\x1c\x46\xa3\x5c\xe4\x11" - "\xe5\xfb\xc1\x19\x1a\x0a\x52\xef" - "\xf6\x9f\x24\x45\xdf\x4f\x9b\x17" - "\xad\x2b\x41\x7b\xe6\x6c\x37\x10", - .rlen = 64, - }, { - .key = "\x60\x3d\xeb\x10\x15\xca\x71\xbe" - "\x2b\x73\xae\xf0\x85\x7d\x77\x81" - "\x1f\x35\x2c\x07\x3b\x61\x08\xd7" - "\x2d\x98\x10\xa3\x09\x14\xdf\xf4", +static struct cipher_testvec aes_cbc_dec_tv_template[] = { + { /* From RFC 3602 */ + .key = "\x06\xa9\x21\x40\x36\xb8\xa1\x5b" + "\x51\x2e\x03\xd5\x34\x12\x00\x06", + .klen = 16, + .iv = "\x3d\xaf\xba\x42\x9d\x9e\xb4\x30" + "\xb4\x22\xda\x80\x2c\x9f\xac\x41", + .input = "\xe3\x53\x77\x9c\x10\x79\xae\xb8" + "\x27\x08\x94\x2d\xbe\x77\x18\x1a", + .ilen = 16, + .result = "Single block msg", + .rlen = 16, + }, { + .key = "\xc2\x86\x69\x6d\x88\x7c\x9a\xa0" + "\x61\x1b\xbb\x3e\x20\x25\xa4\x5a", + .klen = 16, + .iv = "\x56\x2e\x17\x99\x6d\x09\x3d\x28" + "\xdd\xb3\xba\x69\x5a\x2e\x6f\x58", + .input = "\xd2\x96\xcd\x94\xc2\xcc\xcf\x8a" + "\x3a\x86\x30\x28\xb5\xe1\xdc\x0a" + "\x75\x86\x60\x2d\x25\x3c\xff\xf9" + "\x1b\x82\x66\xbe\xa6\xd6\x1a\xb1", + .ilen = 32, + .result = "\x00\x01\x02\x03\x04\x05\x06\x07" + "\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f" + "\x10\x11\x12\x13\x14\x15\x16\x17" + "\x18\x19\x1a\x1b\x1c\x1d\x1e\x1f", + .rlen = 32, + }, { /* From NIST SP800-38A */ + .key = "\x8e\x73\xb0\xf7\xda\x0e\x64\x52" + "\xc8\x10\xf3\x2b\x80\x90\x79\xe5" + "\x62\xf8\xea\xd2\x52\x2c\x6b\x7b", + .klen = 24, + .iv = "\x00\x01\x02\x03\x04\x05\x06\x07" + "\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f", + .input = "\x4f\x02\x1d\xb2\x43\xbc\x63\x3d" + "\x71\x78\x18\x3a\x9f\xa0\x71\xe8" + "\xb4\xd9\xad\xa9\xad\x7d\xed\xf4" + "\xe5\xe7\x38\x76\x3f\x69\x14\x5a" + "\x57\x1b\x24\x20\x12\xfb\x7a\xe0" + "\x7f\xa9\xba\xac\x3d\xf1\x02\xe0" + "\x08\xb0\xe2\x79\x88\x59\x88\x81" + "\xd9\x20\xa9\xe6\x4f\x56\x15\xcd", + .ilen = 64, + .result = "\x6b\xc1\xbe\xe2\x2e\x40\x9f\x96" + "\xe9\x3d\x7e\x11\x73\x93\x17\x2a" + "\xae\x2d\x8a\x57\x1e\x03\xac\x9c" + "\x9e\xb7\x6f\xac\x45\xaf\x8e\x51" + "\x30\xc8\x1c\x46\xa3\x5c\xe4\x11" + "\xe5\xfb\xc1\x19\x1a\x0a\x52\xef" + "\xf6\x9f\x24\x45\xdf\x4f\x9b\x17" + "\xad\x2b\x41\x7b\xe6\x6c\x37\x10", + .rlen = 64, + }, { + .key = "\x60\x3d\xeb\x10\x15\xca\x71\xbe" + "\x2b\x73\xae\xf0\x85\x7d\x77\x81" + "\x1f\x35\x2c\x07\x3b\x61\x08\xd7" + "\x2d\x98\x10\xa3\x09\x14\xdf\xf4", .klen = 32, .iv = "\x00\x01\x02\x03\x04\x05\x06\x07" "\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f", @@ -10668,9 +8313,6 @@ static struct cipher_testvec aes_lrw_enc_tv_template[] = { "\xcd\x7e\x2b\x5d\x43\xea\x42\xe7" "\x74\x3f\x7d\x58\x88\x75\xde\x3e", .rlen = 512, - .also_non_np = 1, - .np = 2, - .tap = { 512 - 16, 16 }, } }; @@ -10922,9 +8564,6 @@ static struct cipher_testvec aes_lrw_dec_tv_template[] = { "\xe9\x2e\xc4\x29\x0f\x84\xdb\xc4" "\x21\xc4\xc2\x75\x67\x89\x37\x0a", .rlen = 512, - .also_non_np = 1, - .np = 2, - .tap = { 512 - 16, 16 }, } }; @@ -11266,9 +8905,6 @@ static struct cipher_testvec aes_xts_enc_tv_template[] = { "\xc4\xf3\x6f\xfd\xa9\xfc\xea\x70" "\xb9\xc6\xe6\x93\xe1\x48\xc1\x51", .rlen = 512, - .also_non_np = 1, - .np = 2, - .tap = { 512 - 16, 16 }, } }; @@ -11610,9 +9246,7 @@ static struct cipher_testvec aes_xts_dec_tv_template[] = { "\xf0\xf1\xf2\xf3\xf4\xf5\xf6\xf7" "\xf8\xf9\xfa\xfb\xfc\xfd\xfe\xff", .rlen = 512, - .also_non_np = 1, - .np = 2, - .tap = { 512 - 16, 16 }, + } }; @@ -13790,1611 +11424,761 @@ static struct aead_testvec aes_ccm_enc_tv_template[] = { .key = "\xc0\xc1\xc2\xc3\xc4\xc5\xc6\xc7" "\xc8\xc9\xca\xcb\xcc\xcd\xce\xcf", .klen = 16, - .iv = "\x01\x00\x00\x00\x07\x06\x05\x04" - "\xa0\xa1\xa2\xa3\xa4\xa5\x00\x00", - .assoc = "\x00\x01\x02\x03\x04\x05\x06\x07" - "\x08\x09\x0a\x0b", - .alen = 12, - .input = "\x0c\x0d\x0e\x0f\x10\x11\x12\x13" - "\x14\x15\x16\x17\x18\x19\x1a\x1b" - "\x1c\x1d\x1e\x1f", - .ilen = 20, - .result = "\xdc\xf1\xfb\x7b\x5d\x9e\x23\xfb" - "\x9d\x4e\x13\x12\x53\x65\x8a\xd8" - "\x6e\xbd\xca\x3e\x51\xe8\x3f\x07" - "\x7d\x9c\x2d\x93", - .rlen = 28, - }, { - .key = "\xc0\xc1\xc2\xc3\xc4\xc5\xc6\xc7" - "\xc8\xc9\xca\xcb\xcc\xcd\xce\xcf", - .klen = 16, - .iv = "\x01\x00\x00\x00\x0b\x0a\x09\x08" - "\xa0\xa1\xa2\xa3\xa4\xa5\x00\x00", - .assoc = "\x00\x01\x02\x03\x04\x05\x06\x07", - .alen = 8, - .input = "\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f" - "\x10\x11\x12\x13\x14\x15\x16\x17" - "\x18\x19\x1a\x1b\x1c\x1d\x1e\x1f" - "\x20", - .ilen = 25, - .result = "\x82\x53\x1a\x60\xcc\x24\x94\x5a" - "\x4b\x82\x79\x18\x1a\xb5\xc8\x4d" - "\xf2\x1c\xe7\xf9\xb7\x3f\x42\xe1" - "\x97\xea\x9c\x07\xe5\x6b\x5e\xb1" - "\x7e\x5f\x4e", - .rlen = 35, - }, { - .key = "\xc0\xc1\xc2\xc3\xc4\xc5\xc6\xc7" - "\xc8\xc9\xca\xcb\xcc\xcd\xce\xcf", - .klen = 16, - .iv = "\x01\x00\x00\x00\x0c\x0b\x0a\x09" - "\xa0\xa1\xa2\xa3\xa4\xa5\x00\x00", - .assoc = "\x00\x01\x02\x03\x04\x05\x06\x07" - "\x08\x09\x0a\x0b", - .alen = 12, - .input = "\x0c\x0d\x0e\x0f\x10\x11\x12\x13" - "\x14\x15\x16\x17\x18\x19\x1a\x1b" - "\x1c\x1d\x1e", - .ilen = 19, - .result = "\x07\x34\x25\x94\x15\x77\x85\x15" - "\x2b\x07\x40\x98\x33\x0a\xbb\x14" - "\x1b\x94\x7b\x56\x6a\xa9\x40\x6b" - "\x4d\x99\x99\x88\xdd", - .rlen = 29, - }, { - .key = "\xd7\x82\x8d\x13\xb2\xb0\xbd\xc3" - "\x25\xa7\x62\x36\xdf\x93\xcc\x6b", - .klen = 16, - .iv = "\x01\x00\x33\x56\x8e\xf7\xb2\x63" - "\x3c\x96\x96\x76\x6c\xfa\x00\x00", - .assoc = "\x63\x01\x8f\x76\xdc\x8a\x1b\xcb", - .alen = 8, - .input = "\x90\x20\xea\x6f\x91\xbd\xd8\x5a" - "\xfa\x00\x39\xba\x4b\xaf\xf9\xbf" - "\xb7\x9c\x70\x28\x94\x9c\xd0\xec", - .ilen = 24, - .result = "\x4c\xcb\x1e\x7c\xa9\x81\xbe\xfa" - "\xa0\x72\x6c\x55\xd3\x78\x06\x12" - "\x98\xc8\x5c\x92\x81\x4a\xbc\x33" - "\xc5\x2e\xe8\x1d\x7d\x77\xc0\x8a", - .rlen = 32, - }, { - .key = "\xd7\x82\x8d\x13\xb2\xb0\xbd\xc3" - "\x25\xa7\x62\x36\xdf\x93\xcc\x6b", - .klen = 16, - .iv = "\x01\x00\xd5\x60\x91\x2d\x3f\x70" - "\x3c\x96\x96\x76\x6c\xfa\x00\x00", - .assoc = "\xcd\x90\x44\xd2\xb7\x1f\xdb\x81" - "\x20\xea\x60\xc0", - .alen = 12, - .input = "\x64\x35\xac\xba\xfb\x11\xa8\x2e" - "\x2f\x07\x1d\x7c\xa4\xa5\xeb\xd9" - "\x3a\x80\x3b\xa8\x7f", - .ilen = 21, - .result = "\x00\x97\x69\xec\xab\xdf\x48\x62" - "\x55\x94\xc5\x92\x51\xe6\x03\x57" - "\x22\x67\x5e\x04\xc8\x47\x09\x9e" - "\x5a\xe0\x70\x45\x51", - .rlen = 29, - }, { - .key = "\xd7\x82\x8d\x13\xb2\xb0\xbd\xc3" - "\x25\xa7\x62\x36\xdf\x93\xcc\x6b", - .klen = 16, - .iv = "\x01\x00\x42\xff\xf8\xf1\x95\x1c" - "\x3c\x96\x96\x76\x6c\xfa\x00\x00", - .assoc = "\xd8\x5b\xc7\xe6\x9f\x94\x4f\xb8", - .alen = 8, - .input = "\x8a\x19\xb9\x50\xbc\xf7\x1a\x01" - "\x8e\x5e\x67\x01\xc9\x17\x87\x65" - "\x98\x09\xd6\x7d\xbe\xdd\x18", - .ilen = 23, - .result = "\xbc\x21\x8d\xaa\x94\x74\x27\xb6" - "\xdb\x38\x6a\x99\xac\x1a\xef\x23" - "\xad\xe0\xb5\x29\x39\xcb\x6a\x63" - "\x7c\xf9\xbe\xc2\x40\x88\x97\xc6" - "\xba", - .rlen = 33, - }, -}; - -static struct aead_testvec aes_ccm_dec_tv_template[] = { - { /* From RFC 3610 */ - .key = "\xc0\xc1\xc2\xc3\xc4\xc5\xc6\xc7" - "\xc8\xc9\xca\xcb\xcc\xcd\xce\xcf", - .klen = 16, - .iv = "\x01\x00\x00\x00\x03\x02\x01\x00" - "\xa0\xa1\xa2\xa3\xa4\xa5\x00\x00", - .assoc = "\x00\x01\x02\x03\x04\x05\x06\x07", - .alen = 8, - .input = "\x58\x8c\x97\x9a\x61\xc6\x63\xd2" - "\xf0\x66\xd0\xc2\xc0\xf9\x89\x80" - "\x6d\x5f\x6b\x61\xda\xc3\x84\x17" - "\xe8\xd1\x2c\xfd\xf9\x26\xe0", - .ilen = 31, - .result = "\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f" - "\x10\x11\x12\x13\x14\x15\x16\x17" - "\x18\x19\x1a\x1b\x1c\x1d\x1e", - .rlen = 23, - }, { - .key = "\xc0\xc1\xc2\xc3\xc4\xc5\xc6\xc7" - "\xc8\xc9\xca\xcb\xcc\xcd\xce\xcf", - .klen = 16, - .iv = "\x01\x00\x00\x00\x07\x06\x05\x04" - "\xa0\xa1\xa2\xa3\xa4\xa5\x00\x00", - .assoc = "\x00\x01\x02\x03\x04\x05\x06\x07" - "\x08\x09\x0a\x0b", - .alen = 12, - .input = "\xdc\xf1\xfb\x7b\x5d\x9e\x23\xfb" - "\x9d\x4e\x13\x12\x53\x65\x8a\xd8" - "\x6e\xbd\xca\x3e\x51\xe8\x3f\x07" - "\x7d\x9c\x2d\x93", - .ilen = 28, - .result = "\x0c\x0d\x0e\x0f\x10\x11\x12\x13" - "\x14\x15\x16\x17\x18\x19\x1a\x1b" - "\x1c\x1d\x1e\x1f", - .rlen = 20, - }, { - .key = "\xc0\xc1\xc2\xc3\xc4\xc5\xc6\xc7" - "\xc8\xc9\xca\xcb\xcc\xcd\xce\xcf", - .klen = 16, - .iv = "\x01\x00\x00\x00\x0b\x0a\x09\x08" - "\xa0\xa1\xa2\xa3\xa4\xa5\x00\x00", - .assoc = "\x00\x01\x02\x03\x04\x05\x06\x07", - .alen = 8, - .input = "\x82\x53\x1a\x60\xcc\x24\x94\x5a" - "\x4b\x82\x79\x18\x1a\xb5\xc8\x4d" - "\xf2\x1c\xe7\xf9\xb7\x3f\x42\xe1" - "\x97\xea\x9c\x07\xe5\x6b\x5e\xb1" - "\x7e\x5f\x4e", - .ilen = 35, - .result = "\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f" - "\x10\x11\x12\x13\x14\x15\x16\x17" - "\x18\x19\x1a\x1b\x1c\x1d\x1e\x1f" - "\x20", - .rlen = 25, - }, { - .key = "\xc0\xc1\xc2\xc3\xc4\xc5\xc6\xc7" - "\xc8\xc9\xca\xcb\xcc\xcd\xce\xcf", - .klen = 16, - .iv = "\x01\x00\x00\x00\x0c\x0b\x0a\x09" - "\xa0\xa1\xa2\xa3\xa4\xa5\x00\x00", - .assoc = "\x00\x01\x02\x03\x04\x05\x06\x07" - "\x08\x09\x0a\x0b", - .alen = 12, - .input = "\x07\x34\x25\x94\x15\x77\x85\x15" - "\x2b\x07\x40\x98\x33\x0a\xbb\x14" - "\x1b\x94\x7b\x56\x6a\xa9\x40\x6b" - "\x4d\x99\x99\x88\xdd", - .ilen = 29, - .result = "\x0c\x0d\x0e\x0f\x10\x11\x12\x13" - "\x14\x15\x16\x17\x18\x19\x1a\x1b" - "\x1c\x1d\x1e", - .rlen = 19, - }, { - .key = "\xd7\x82\x8d\x13\xb2\xb0\xbd\xc3" - "\x25\xa7\x62\x36\xdf\x93\xcc\x6b", - .klen = 16, - .iv = "\x01\x00\x33\x56\x8e\xf7\xb2\x63" - "\x3c\x96\x96\x76\x6c\xfa\x00\x00", - .assoc = "\x63\x01\x8f\x76\xdc\x8a\x1b\xcb", - .alen = 8, - .input = "\x4c\xcb\x1e\x7c\xa9\x81\xbe\xfa" - "\xa0\x72\x6c\x55\xd3\x78\x06\x12" - "\x98\xc8\x5c\x92\x81\x4a\xbc\x33" - "\xc5\x2e\xe8\x1d\x7d\x77\xc0\x8a", - .ilen = 32, - .result = "\x90\x20\xea\x6f\x91\xbd\xd8\x5a" - "\xfa\x00\x39\xba\x4b\xaf\xf9\xbf" - "\xb7\x9c\x70\x28\x94\x9c\xd0\xec", - .rlen = 24, - }, { - .key = "\xd7\x82\x8d\x13\xb2\xb0\xbd\xc3" - "\x25\xa7\x62\x36\xdf\x93\xcc\x6b", - .klen = 16, - .iv = "\x01\x00\xd5\x60\x91\x2d\x3f\x70" - "\x3c\x96\x96\x76\x6c\xfa\x00\x00", - .assoc = "\xcd\x90\x44\xd2\xb7\x1f\xdb\x81" - "\x20\xea\x60\xc0", + .iv = "\x01\x00\x00\x00\x07\x06\x05\x04" + "\xa0\xa1\xa2\xa3\xa4\xa5\x00\x00", + .assoc = "\x00\x01\x02\x03\x04\x05\x06\x07" + "\x08\x09\x0a\x0b", .alen = 12, - .input = "\x00\x97\x69\xec\xab\xdf\x48\x62" - "\x55\x94\xc5\x92\x51\xe6\x03\x57" - "\x22\x67\x5e\x04\xc8\x47\x09\x9e" - "\x5a\xe0\x70\x45\x51", - .ilen = 29, - .result = "\x64\x35\xac\xba\xfb\x11\xa8\x2e" - "\x2f\x07\x1d\x7c\xa4\xa5\xeb\xd9" - "\x3a\x80\x3b\xa8\x7f", - .rlen = 21, + .input = "\x0c\x0d\x0e\x0f\x10\x11\x12\x13" + "\x14\x15\x16\x17\x18\x19\x1a\x1b" + "\x1c\x1d\x1e\x1f", + .ilen = 20, + .result = "\xdc\xf1\xfb\x7b\x5d\x9e\x23\xfb" + "\x9d\x4e\x13\x12\x53\x65\x8a\xd8" + "\x6e\xbd\xca\x3e\x51\xe8\x3f\x07" + "\x7d\x9c\x2d\x93", + .rlen = 28, }, { - .key = "\xd7\x82\x8d\x13\xb2\xb0\xbd\xc3" - "\x25\xa7\x62\x36\xdf\x93\xcc\x6b", + .key = "\xc0\xc1\xc2\xc3\xc4\xc5\xc6\xc7" + "\xc8\xc9\xca\xcb\xcc\xcd\xce\xcf", .klen = 16, - .iv = "\x01\x00\x42\xff\xf8\xf1\x95\x1c" - "\x3c\x96\x96\x76\x6c\xfa\x00\x00", - .assoc = "\xd8\x5b\xc7\xe6\x9f\x94\x4f\xb8", + .iv = "\x01\x00\x00\x00\x0b\x0a\x09\x08" + "\xa0\xa1\xa2\xa3\xa4\xa5\x00\x00", + .assoc = "\x00\x01\x02\x03\x04\x05\x06\x07", .alen = 8, - .input = "\xbc\x21\x8d\xaa\x94\x74\x27\xb6" - "\xdb\x38\x6a\x99\xac\x1a\xef\x23" - "\xad\xe0\xb5\x29\x39\xcb\x6a\x63" - "\x7c\xf9\xbe\xc2\x40\x88\x97\xc6" - "\xba", - .ilen = 33, - .result = "\x8a\x19\xb9\x50\xbc\xf7\x1a\x01" - "\x8e\x5e\x67\x01\xc9\x17\x87\x65" - "\x98\x09\xd6\x7d\xbe\xdd\x18", - .rlen = 23, - }, -}; - -/* - * rfc4309 refers to section 8 of rfc3610 for test vectors, but they all - * use a 13-byte nonce, we only support an 11-byte nonce. Similarly, all of - * Special Publication 800-38C's test vectors also use nonce lengths our - * implementation doesn't support. The following are taken from fips cavs - * fax files on hand at Red Hat. - * - * nb: actual key lengths are (klen - 3), the last 3 bytes are actually - * part of the nonce which combine w/the iv, but need to be input this way. - */ -static struct aead_testvec aes_ccm_rfc4309_enc_tv_template[] = { - { - .key = "\x83\xac\x54\x66\xc2\xeb\xe5\x05" - "\x2e\x01\xd1\xfc\x5d\x82\x66\x2e" - "\x96\xac\x59", - .klen = 19, - .iv = "\x30\x07\xa1\xe2\xa2\xc7\x55\x24", - .alen = 0, - .input = "\x19\xc8\x81\xf6\xe9\x86\xff\x93" - "\x0b\x78\x67\xe5\xbb\xb7\xfc\x6e" - "\x83\x77\xb3\xa6\x0c\x8c\x9f\x9c" - "\x35\x2e\xad\xe0\x62\xf9\x91\xa1", - .ilen = 32, - .result = "\xab\x6f\xe1\x69\x1d\x19\x99\xa8" - "\x92\xa0\xc4\x6f\x7e\xe2\x8b\xb1" - "\x70\xbb\x8c\xa6\x4c\x6e\x97\x8a" - "\x57\x2b\xbe\x5d\x98\xa6\xb1\x32" - "\xda\x24\xea\xd9\xa1\x39\x98\xfd" - "\xa4\xbe\xd9\xf2\x1a\x6d\x22\xa8", - .rlen = 48, - }, { - .key = "\x1e\x2c\x7e\x01\x41\x9a\xef\xc0" - "\x0d\x58\x96\x6e\x5c\xa2\x4b\xd3" - "\x4f\xa3\x19", - .klen = 19, - .iv = "\xd3\x01\x5a\xd8\x30\x60\x15\x56", - .assoc = "\xda\xe6\x28\x9c\x45\x2d\xfd\x63" - "\x5e\xda\x4c\xb6\xe6\xfc\xf9\xb7" - "\x0c\x56\xcb\xe4\xe0\x05\x7a\xe1" - "\x0a\x63\x09\x78\xbc\x2c\x55\xde", - .alen = 32, - .input = "\x87\xa3\x36\xfd\x96\xb3\x93\x78" - "\xa9\x28\x63\xba\x12\xa3\x14\x85" - "\x57\x1e\x06\xc9\x7b\x21\xef\x76" - "\x7f\x38\x7e\x8e\x29\xa4\x3e\x7e", - .ilen = 32, - .result = "\x8a\x1e\x11\xf0\x02\x6b\xe2\x19" - "\xfc\x70\xc4\x6d\x8e\xb7\x99\xab" - "\xc5\x4b\xa2\xac\xd3\xf3\x48\xff" - "\x3b\xb5\xce\x53\xef\xde\xbb\x02" - "\xa9\x86\x15\x6c\x13\xfe\xda\x0a" - "\x22\xb8\x29\x3d\xd8\x39\x9a\x23", - .rlen = 48, - }, { - .key = "\xf4\x6b\xc2\x75\x62\xfe\xb4\xe1" - "\xa3\xf0\xff\xdd\x4e\x4b\x12\x75" - "\x53\x14\x73\x66\x8d\x88\xf6\x80" - "\xa0\x20\x35", - .klen = 27, - .iv = "\x26\xf2\x21\x8d\x50\x20\xda\xe2", - .assoc = "\x5b\x9e\x13\x67\x02\x5e\xef\xc1" - "\x6c\xf9\xd7\x1e\x52\x8f\x7a\x47" - "\xe9\xd4\xcf\x20\x14\x6e\xf0\x2d" - "\xd8\x9e\x2b\x56\x10\x23\x56\xe7", - .alen = 32, - .ilen = 0, - .result = "\x36\xea\x7a\x70\x08\xdc\x6a\xbc" - "\xad\x0c\x7a\x63\xf6\x61\xfd\x9b", - .rlen = 16, - }, { - .key = "\x56\xdf\x5c\x8f\x26\x3f\x0e\x42" - "\xef\x7a\xd3\xce\xfc\x84\x60\x62" - "\xca\xb4\x40\xaf\x5f\xc9\xc9\x01" - "\xd6\x3c\x8c", - .klen = 27, - .iv = "\x86\x84\xb6\xcd\xef\x09\x2e\x94", - .assoc = "\x02\x65\x78\x3c\xe9\x21\x30\x91" - "\xb1\xb9\xda\x76\x9a\x78\x6d\x95" - "\xf2\x88\x32\xa3\xf2\x50\xcb\x4c" - "\xe3\x00\x73\x69\x84\x69\x87\x79", - .alen = 32, - .input = "\x9f\xd2\x02\x4b\x52\x49\x31\x3c" - "\x43\x69\x3a\x2d\x8e\x70\xad\x7e" - "\xe0\xe5\x46\x09\x80\x89\x13\xb2" - "\x8c\x8b\xd9\x3f\x86\xfb\xb5\x6b", - .ilen = 32, - .result = "\x39\xdf\x7c\x3c\x5a\x29\xb9\x62" - "\x5d\x51\xc2\x16\xd8\xbd\x06\x9f" - "\x9b\x6a\x09\x70\xc1\x51\x83\xc2" - "\x66\x88\x1d\x4f\x9a\xda\xe0\x1e" - "\xc7\x79\x11\x58\xe5\x6b\x20\x40" - "\x7a\xea\x46\x42\x8b\xe4\x6f\xe1", - .rlen = 48, - }, { - .key = "\xe0\x8d\x99\x71\x60\xd7\x97\x1a" - "\xbd\x01\x99\xd5\x8a\xdf\x71\x3a" - "\xd3\xdf\x24\x4b\x5e\x3d\x4b\x4e" - "\x30\x7a\xb9\xd8\x53\x0a\x5e\x2b" - "\x1e\x29\x91", - .klen = 35, - .iv = "\xad\x8e\xc1\x53\x0a\xcf\x2d\xbe", - .assoc = "\x19\xb6\x1f\x57\xc4\xf3\xf0\x8b" - "\x78\x2b\x94\x02\x29\x0f\x42\x27" - "\x6b\x75\xcb\x98\x34\x08\x7e\x79" - "\xe4\x3e\x49\x0d\x84\x8b\x22\x87", - .alen = 32, - .input = "\xe1\xd9\xd8\x13\xeb\x3a\x75\x3f" - "\x9d\xbd\x5f\x66\xbe\xdc\xbb\x66" - "\xbf\x17\x99\x62\x4a\x39\x27\x1f" - "\x1d\xdc\x24\xae\x19\x2f\x98\x4c", - .ilen = 32, - .result = "\x19\xb8\x61\x33\x45\x2b\x43\x96" - "\x6f\x51\xd0\x20\x30\x7d\x9b\xc6" - "\x26\x3d\xf8\xc9\x65\x16\xa8\x9f" - "\xf0\x62\x17\x34\xf2\x1e\x8d\x75" - "\x4e\x13\xcc\xc0\xc3\x2a\x54\x2d", - .rlen = 40, - }, { - .key = "\x7c\xc8\x18\x3b\x8d\x99\xe0\x7c" - "\x45\x41\xb8\xbd\x5c\xa7\xc2\x32" - "\x8a\xb8\x02\x59\xa4\xfe\xa9\x2c" - "\x09\x75\x9a\x9b\x3c\x9b\x27\x39" - "\xf9\xd9\x4e", - .klen = 35, - .iv = "\x63\xb5\x3d\x9d\x43\xf6\x1e\x50", - .assoc = "\x57\xf5\x6b\x8b\x57\x5c\x3d\x3b" - "\x13\x02\x01\x0c\x83\x4c\x96\x35" - "\x8e\xd6\x39\xcf\x7d\x14\x9b\x94" - "\xb0\x39\x36\xe6\x8f\x57\xe0\x13", - .alen = 32, - .input = "\x3b\x6c\x29\x36\xb6\xef\x07\xa6" - "\x83\x72\x07\x4f\xcf\xfa\x66\x89" - "\x5f\xca\xb1\xba\xd5\x8f\x2c\x27" - "\x30\xdb\x75\x09\x93\xd4\x65\xe4", - .ilen = 32, - .result = "\xb0\x88\x5a\x33\xaa\xe5\xc7\x1d" - "\x85\x23\xc7\xc6\x2f\xf4\x1e\x3d" - "\xcc\x63\x44\x25\x07\x78\x4f\x9e" - "\x96\xb8\x88\xeb\xbc\x48\x1f\x06" - "\x39\xaf\x39\xac\xd8\x4a\x80\x39" - "\x7b\x72\x8a\xf7", - .rlen = 44, - }, { - .key = "\xab\xd0\xe9\x33\x07\x26\xe5\x83" - "\x8c\x76\x95\xd4\xb6\xdc\xf3\x46" - "\xf9\x8f\xad\xe3\x02\x13\x83\x77" - "\x3f\xb0\xf1\xa1\xa1\x22\x0f\x2b" - "\x24\xa7\x8b", - .klen = 35, - .iv = "\x07\xcb\xcc\x0e\xe6\x33\xbf\xf5", - .assoc = "\xd4\xdb\x30\x1d\x03\xfe\xfd\x5f" - "\x87\xd4\x8c\xb6\xb6\xf1\x7a\x5d" - "\xab\x90\x65\x8d\x8e\xca\x4d\x4f" - "\x16\x0c\x40\x90\x4b\xc7\x36\x73", - .alen = 32, - .input = "\xf5\xc6\x7d\x48\xc1\xb7\xe6\x92" - "\x97\x5a\xca\xc4\xa9\x6d\xf9\x3d" - "\x6c\xde\xbc\xf1\x90\xea\x6a\xb2" - "\x35\x86\x36\xaf\x5c\xfe\x4b\x3a", - .ilen = 32, - .result = "\x83\x6f\x40\x87\x72\xcf\xc1\x13" - "\xef\xbb\x80\x21\x04\x6c\x58\x09" - "\x07\x1b\xfc\xdf\xc0\x3f\x5b\xc7" - "\xe0\x79\xa8\x6e\x71\x7c\x3f\xcf" - "\x5c\xda\xb2\x33\xe5\x13\xe2\x0d" - "\x74\xd1\xef\xb5\x0f\x3a\xb5\xf8", - .rlen = 48, - }, -}; - -static struct aead_testvec aes_ccm_rfc4309_dec_tv_template[] = { - { - .key = "\xab\x2f\x8a\x74\xb7\x1c\xd2\xb1" - "\xff\x80\x2e\x48\x7d\x82\xf8\xb9" - "\xc6\xfb\x7d", - .klen = 19, - .iv = "\x80\x0d\x13\xab\xd8\xa6\xb2\xd8", - .alen = 0, - .input = "\xd5\xe8\x93\x9f\xc7\x89\x2e\x2b", - .ilen = 8, - .result = "\x00", - .rlen = 0, - .novrfy = 1, + .input = "\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f" + "\x10\x11\x12\x13\x14\x15\x16\x17" + "\x18\x19\x1a\x1b\x1c\x1d\x1e\x1f" + "\x20", + .ilen = 25, + .result = "\x82\x53\x1a\x60\xcc\x24\x94\x5a" + "\x4b\x82\x79\x18\x1a\xb5\xc8\x4d" + "\xf2\x1c\xe7\xf9\xb7\x3f\x42\xe1" + "\x97\xea\x9c\x07\xe5\x6b\x5e\xb1" + "\x7e\x5f\x4e", + .rlen = 35, }, { - .key = "\xab\x2f\x8a\x74\xb7\x1c\xd2\xb1" - "\xff\x80\x2e\x48\x7d\x82\xf8\xb9" - "\xaf\x94\x87", - .klen = 19, - .iv = "\x78\x35\x82\x81\x7f\x88\x94\x68", - .alen = 0, - .input = "\x41\x3c\xb8\x87\x73\xcb\xf3\xf3", - .ilen = 8, - .result = "\x00", - .rlen = 0, + .key = "\xc0\xc1\xc2\xc3\xc4\xc5\xc6\xc7" + "\xc8\xc9\xca\xcb\xcc\xcd\xce\xcf", + .klen = 16, + .iv = "\x01\x00\x00\x00\x0c\x0b\x0a\x09" + "\xa0\xa1\xa2\xa3\xa4\xa5\x00\x00", + .assoc = "\x00\x01\x02\x03\x04\x05\x06\x07" + "\x08\x09\x0a\x0b", + .alen = 12, + .input = "\x0c\x0d\x0e\x0f\x10\x11\x12\x13" + "\x14\x15\x16\x17\x18\x19\x1a\x1b" + "\x1c\x1d\x1e", + .ilen = 19, + .result = "\x07\x34\x25\x94\x15\x77\x85\x15" + "\x2b\x07\x40\x98\x33\x0a\xbb\x14" + "\x1b\x94\x7b\x56\x6a\xa9\x40\x6b" + "\x4d\x99\x99\x88\xdd", + .rlen = 29, }, { - .key = "\x61\x0e\x8c\xae\xe3\x23\xb6\x38" - "\x76\x1c\xf6\x3a\x67\xa3\x9c\xd8" - "\xc6\xfb\x7d", - .klen = 19, - .iv = "\x80\x0d\x13\xab\xd8\xa6\xb2\xd8", - .assoc = "\xf3\x94\x87\x78\x35\x82\x81\x7f" - "\x88\x94\x68\xb1\x78\x6b\x2b\xd6" - "\x04\x1f\x4e\xed\x78\xd5\x33\x66" - "\xd8\x94\x99\x91\x81\x54\x62\x57", - .alen = 32, - .input = "\xf0\x7c\x29\x02\xae\x1c\x2f\x55" - "\xd0\xd1\x3d\x1a\xa3\x6d\xe4\x0a" - "\x86\xb0\x87\x6b\x62\x33\x8c\x34" - "\xce\xab\x57\xcc\x79\x0b\xe0\x6f" - "\x5c\x3e\x48\x1f\x6c\x46\xf7\x51" - "\x8b\x84\x83\x2a\xc1\x05\xb8\xc5", - .ilen = 48, - .result = "\x50\x82\x3e\x07\xe2\x1e\xb6\xfb" - "\x33\xe4\x73\xce\xd2\xfb\x95\x79" - "\xe8\xb4\xb5\x77\x11\x10\x62\x6f" - "\x6a\x82\xd1\x13\xec\xf5\xd0\x48", + .key = "\xd7\x82\x8d\x13\xb2\xb0\xbd\xc3" + "\x25\xa7\x62\x36\xdf\x93\xcc\x6b", + .klen = 16, + .iv = "\x01\x00\x33\x56\x8e\xf7\xb2\x63" + "\x3c\x96\x96\x76\x6c\xfa\x00\x00", + .assoc = "\x63\x01\x8f\x76\xdc\x8a\x1b\xcb", + .alen = 8, + .input = "\x90\x20\xea\x6f\x91\xbd\xd8\x5a" + "\xfa\x00\x39\xba\x4b\xaf\xf9\xbf" + "\xb7\x9c\x70\x28\x94\x9c\xd0\xec", + .ilen = 24, + .result = "\x4c\xcb\x1e\x7c\xa9\x81\xbe\xfa" + "\xa0\x72\x6c\x55\xd3\x78\x06\x12" + "\x98\xc8\x5c\x92\x81\x4a\xbc\x33" + "\xc5\x2e\xe8\x1d\x7d\x77\xc0\x8a", .rlen = 32, - .novrfy = 1, }, { - .key = "\x61\x0e\x8c\xae\xe3\x23\xb6\x38" - "\x76\x1c\xf6\x3a\x67\xa3\x9c\xd8" - "\x05\xe0\xc9", - .klen = 19, - .iv = "\x0f\xed\x34\xea\x97\xd4\x3b\xdf", - .assoc = "\x49\x5c\x50\x1f\x1d\x94\xcc\x81" - "\xba\xb7\xb6\x03\xaf\xa5\xc1\xa1" - "\xd8\x5c\x42\x68\xe0\x6c\xda\x89" - "\x05\xac\x56\xac\x1b\x2a\xd3\x86", - .alen = 32, - .input = "\x39\xbe\x7d\x15\x62\x77\xf3\x3c" - "\xad\x83\x52\x6d\x71\x03\x25\x1c" - "\xed\x81\x3a\x9a\x16\x7d\x19\x80" - "\x72\x04\x72\xd0\xf6\xff\x05\x0f" - "\xb7\x14\x30\x00\x32\x9e\xa0\xa6" - "\x9e\x5a\x18\xa1\xb8\xfe\xdb\xd3", - .ilen = 48, - .result = "\x75\x05\xbe\xc2\xd9\x1e\xde\x60" - "\x47\x3d\x8c\x7d\xbd\xb5\xd9\xb7" - "\xf2\xae\x61\x05\x8f\x82\x24\x3f" - "\x9c\x67\x91\xe1\x38\x4f\xe4\x0c", - .rlen = 32, + .key = "\xd7\x82\x8d\x13\xb2\xb0\xbd\xc3" + "\x25\xa7\x62\x36\xdf\x93\xcc\x6b", + .klen = 16, + .iv = "\x01\x00\xd5\x60\x91\x2d\x3f\x70" + "\x3c\x96\x96\x76\x6c\xfa\x00\x00", + .assoc = "\xcd\x90\x44\xd2\xb7\x1f\xdb\x81" + "\x20\xea\x60\xc0", + .alen = 12, + .input = "\x64\x35\xac\xba\xfb\x11\xa8\x2e" + "\x2f\x07\x1d\x7c\xa4\xa5\xeb\xd9" + "\x3a\x80\x3b\xa8\x7f", + .ilen = 21, + .result = "\x00\x97\x69\xec\xab\xdf\x48\x62" + "\x55\x94\xc5\x92\x51\xe6\x03\x57" + "\x22\x67\x5e\x04\xc8\x47\x09\x9e" + "\x5a\xe0\x70\x45\x51", + .rlen = 29, }, { - .key = "\x39\xbb\xa7\xbe\x59\x97\x9e\x73" - "\xa2\xbc\x6b\x98\xd7\x75\x7f\xe3" - "\xa4\x48\x93\x39\x26\x71\x4a\xc6" - "\xee\x49\x83", - .klen = 27, - .iv = "\xe9\xa9\xff\xe9\x57\xba\xfd\x9e", - .assoc = "\x44\xa6\x2c\x05\xe9\xe1\x43\xb1" - "\x58\x7c\xf2\x5c\x6d\x39\x0a\x64" - "\xa4\xf0\x13\x05\xd1\x77\x99\x67" - "\x11\xc4\xc6\xdb\x00\x56\x36\x61", - .alen = 32, - .input = "\x71\x99\xfa\xf4\x44\x12\x68\x9b", - .ilen = 8, - .result = "\x00", - .rlen = 0, + .key = "\xd7\x82\x8d\x13\xb2\xb0\xbd\xc3" + "\x25\xa7\x62\x36\xdf\x93\xcc\x6b", + .klen = 16, + .iv = "\x01\x00\x42\xff\xf8\xf1\x95\x1c" + "\x3c\x96\x96\x76\x6c\xfa\x00\x00", + .assoc = "\xd8\x5b\xc7\xe6\x9f\x94\x4f\xb8", + .alen = 8, + .input = "\x8a\x19\xb9\x50\xbc\xf7\x1a\x01" + "\x8e\x5e\x67\x01\xc9\x17\x87\x65" + "\x98\x09\xd6\x7d\xbe\xdd\x18", + .ilen = 23, + .result = "\xbc\x21\x8d\xaa\x94\x74\x27\xb6" + "\xdb\x38\x6a\x99\xac\x1a\xef\x23" + "\xad\xe0\xb5\x29\x39\xcb\x6a\x63" + "\x7c\xf9\xbe\xc2\x40\x88\x97\xc6" + "\xba", + .rlen = 33, + }, +}; + +static struct aead_testvec aes_ccm_dec_tv_template[] = { + { /* From RFC 3610 */ + .key = "\xc0\xc1\xc2\xc3\xc4\xc5\xc6\xc7" + "\xc8\xc9\xca\xcb\xcc\xcd\xce\xcf", + .klen = 16, + .iv = "\x01\x00\x00\x00\x03\x02\x01\x00" + "\xa0\xa1\xa2\xa3\xa4\xa5\x00\x00", + .assoc = "\x00\x01\x02\x03\x04\x05\x06\x07", + .alen = 8, + .input = "\x58\x8c\x97\x9a\x61\xc6\x63\xd2" + "\xf0\x66\xd0\xc2\xc0\xf9\x89\x80" + "\x6d\x5f\x6b\x61\xda\xc3\x84\x17" + "\xe8\xd1\x2c\xfd\xf9\x26\xe0", + .ilen = 31, + .result = "\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f" + "\x10\x11\x12\x13\x14\x15\x16\x17" + "\x18\x19\x1a\x1b\x1c\x1d\x1e", + .rlen = 23, }, { - .key = "\x58\x5d\xa0\x96\x65\x1a\x04\xd7" - "\x96\xe5\xc5\x68\xaa\x95\x35\xe0" - "\x29\xa0\xba\x9e\x48\x78\xd1\xba" - "\xee\x49\x83", - .klen = 27, - .iv = "\xe9\xa9\xff\xe9\x57\xba\xfd\x9e", - .assoc = "\x44\xa6\x2c\x05\xe9\xe1\x43\xb1" - "\x58\x7c\xf2\x5c\x6d\x39\x0a\x64" - "\xa4\xf0\x13\x05\xd1\x77\x99\x67" - "\x11\xc4\xc6\xdb\x00\x56\x36\x61", - .alen = 32, - .input = "\xfb\xe5\x5d\x34\xbe\xe5\xe8\xe7" - "\x5a\xef\x2f\xbf\x1f\x7f\xd4\xb2" - "\x66\xca\x61\x1e\x96\x7a\x61\xb3" - "\x1c\x16\x45\x52\xba\x04\x9c\x9f" - "\xb1\xd2\x40\xbc\x52\x7c\x6f\xb1", - .ilen = 40, - .result = "\x85\x34\x66\x42\xc8\x92\x0f\x36" - "\x58\xe0\x6b\x91\x3c\x98\x5c\xbb" - "\x0a\x85\xcc\x02\xad\x7a\x96\xe9" - "\x65\x43\xa4\xc3\x0f\xdc\x55\x81", - .rlen = 32, + .key = "\xc0\xc1\xc2\xc3\xc4\xc5\xc6\xc7" + "\xc8\xc9\xca\xcb\xcc\xcd\xce\xcf", + .klen = 16, + .iv = "\x01\x00\x00\x00\x07\x06\x05\x04" + "\xa0\xa1\xa2\xa3\xa4\xa5\x00\x00", + .assoc = "\x00\x01\x02\x03\x04\x05\x06\x07" + "\x08\x09\x0a\x0b", + .alen = 12, + .input = "\xdc\xf1\xfb\x7b\x5d\x9e\x23\xfb" + "\x9d\x4e\x13\x12\x53\x65\x8a\xd8" + "\x6e\xbd\xca\x3e\x51\xe8\x3f\x07" + "\x7d\x9c\x2d\x93", + .ilen = 28, + .result = "\x0c\x0d\x0e\x0f\x10\x11\x12\x13" + "\x14\x15\x16\x17\x18\x19\x1a\x1b" + "\x1c\x1d\x1e\x1f", + .rlen = 20, }, { - .key = "\x58\x5d\xa0\x96\x65\x1a\x04\xd7" - "\x96\xe5\xc5\x68\xaa\x95\x35\xe0" - "\x29\xa0\xba\x9e\x48\x78\xd1\xba" - "\xd1\xfc\x57", - .klen = 27, - .iv = "\x9c\xfe\xb8\x9c\xad\x71\xaa\x1f", - .assoc = "\x86\x67\xa5\xa9\x14\x5f\x0d\xc6" - "\xff\x14\xc7\x44\xbf\x6c\x3a\xc3" - "\xff\xb6\x81\xbd\xe2\xd5\x06\xc7" - "\x3c\xa1\x52\x13\x03\x8a\x23\x3a", - .alen = 32, - .input = "\x3f\x66\xb0\x9d\xe5\x4b\x38\x00" - "\xc6\x0e\x6e\xe5\xd6\x98\xa6\x37" - "\x8c\x26\x33\xc6\xb2\xa2\x17\xfa" - "\x64\x19\xc0\x30\xd7\xfc\x14\x6b" - "\xe3\x33\xc2\x04\xb0\x37\xbe\x3f" - "\xa9\xb4\x2d\x68\x03\xa3\x44\xef", - .ilen = 48, - .result = "\x02\x87\x4d\x28\x80\x6e\xb2\xed" - "\x99\x2a\xa8\xca\x04\x25\x45\x90" - "\x1d\xdd\x5a\xd9\xe4\xdb\x9c\x9c" - "\x49\xe9\x01\xfe\xa7\x80\x6d\x6b", - .rlen = 32, - .novrfy = 1, + .key = "\xc0\xc1\xc2\xc3\xc4\xc5\xc6\xc7" + "\xc8\xc9\xca\xcb\xcc\xcd\xce\xcf", + .klen = 16, + .iv = "\x01\x00\x00\x00\x0b\x0a\x09\x08" + "\xa0\xa1\xa2\xa3\xa4\xa5\x00\x00", + .assoc = "\x00\x01\x02\x03\x04\x05\x06\x07", + .alen = 8, + .input = "\x82\x53\x1a\x60\xcc\x24\x94\x5a" + "\x4b\x82\x79\x18\x1a\xb5\xc8\x4d" + "\xf2\x1c\xe7\xf9\xb7\x3f\x42\xe1" + "\x97\xea\x9c\x07\xe5\x6b\x5e\xb1" + "\x7e\x5f\x4e", + .ilen = 35, + .result = "\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f" + "\x10\x11\x12\x13\x14\x15\x16\x17" + "\x18\x19\x1a\x1b\x1c\x1d\x1e\x1f" + "\x20", + .rlen = 25, }, { - .key = "\xa4\x4b\x54\x29\x0a\xb8\x6d\x01" - "\x5b\x80\x2a\xcf\x25\xc4\xb7\x5c" - "\x20\x2c\xad\x30\xc2\x2b\x41\xfb" - "\x0e\x85\xbc\x33\xad\x0f\x2b\xff" - "\xee\x49\x83", - .klen = 35, - .iv = "\xe9\xa9\xff\xe9\x57\xba\xfd\x9e", - .alen = 0, - .input = "\x1f\xb8\x8f\xa3\xdd\x54\x00\xf2", - .ilen = 8, - .result = "\x00", - .rlen = 0, + .key = "\xc0\xc1\xc2\xc3\xc4\xc5\xc6\xc7" + "\xc8\xc9\xca\xcb\xcc\xcd\xce\xcf", + .klen = 16, + .iv = "\x01\x00\x00\x00\x0c\x0b\x0a\x09" + "\xa0\xa1\xa2\xa3\xa4\xa5\x00\x00", + .assoc = "\x00\x01\x02\x03\x04\x05\x06\x07" + "\x08\x09\x0a\x0b", + .alen = 12, + .input = "\x07\x34\x25\x94\x15\x77\x85\x15" + "\x2b\x07\x40\x98\x33\x0a\xbb\x14" + "\x1b\x94\x7b\x56\x6a\xa9\x40\x6b" + "\x4d\x99\x99\x88\xdd", + .ilen = 29, + .result = "\x0c\x0d\x0e\x0f\x10\x11\x12\x13" + "\x14\x15\x16\x17\x18\x19\x1a\x1b" + "\x1c\x1d\x1e", + .rlen = 19, + }, { + .key = "\xd7\x82\x8d\x13\xb2\xb0\xbd\xc3" + "\x25\xa7\x62\x36\xdf\x93\xcc\x6b", + .klen = 16, + .iv = "\x01\x00\x33\x56\x8e\xf7\xb2\x63" + "\x3c\x96\x96\x76\x6c\xfa\x00\x00", + .assoc = "\x63\x01\x8f\x76\xdc\x8a\x1b\xcb", + .alen = 8, + .input = "\x4c\xcb\x1e\x7c\xa9\x81\xbe\xfa" + "\xa0\x72\x6c\x55\xd3\x78\x06\x12" + "\x98\xc8\x5c\x92\x81\x4a\xbc\x33" + "\xc5\x2e\xe8\x1d\x7d\x77\xc0\x8a", + .ilen = 32, + .result = "\x90\x20\xea\x6f\x91\xbd\xd8\x5a" + "\xfa\x00\x39\xba\x4b\xaf\xf9\xbf" + "\xb7\x9c\x70\x28\x94\x9c\xd0\xec", + .rlen = 24, }, { - .key = "\x39\xbb\xa7\xbe\x59\x97\x9e\x73" - "\xa2\xbc\x6b\x98\xd7\x75\x7f\xe3" - "\xa4\x48\x93\x39\x26\x71\x4a\xc6" - "\xae\x8f\x11\x4c\xc2\x9c\x4a\xbb" - "\x85\x34\x66", - .klen = 35, - .iv = "\x42\xc8\x92\x0f\x36\x58\xe0\x6b", - .alen = 0, - .input = "\x48\x01\x5e\x02\x24\x04\x66\x47" - "\xa1\xea\x6f\xaf\xe8\xfc\xfb\xdd" - "\xa5\xa9\x87\x8d\x84\xee\x2e\x77" - "\xbb\x86\xb9\xf5\x5c\x6c\xff\xf6" - "\x72\xc3\x8e\xf7\x70\xb1\xb2\x07" - "\xbc\xa8\xa3\xbd\x83\x7c\x1d\x2a", - .ilen = 48, - .result = "\xdc\x56\xf2\x71\xb0\xb1\xa0\x6c" - "\xf0\x97\x3a\xfb\x6d\xe7\x32\x99" - "\x3e\xaf\x70\x5e\xb2\x4d\xea\x39" - "\x89\xd4\x75\x7a\x63\xb1\xda\x93", - .rlen = 32, - .novrfy = 1, + .key = "\xd7\x82\x8d\x13\xb2\xb0\xbd\xc3" + "\x25\xa7\x62\x36\xdf\x93\xcc\x6b", + .klen = 16, + .iv = "\x01\x00\xd5\x60\x91\x2d\x3f\x70" + "\x3c\x96\x96\x76\x6c\xfa\x00\x00", + .assoc = "\xcd\x90\x44\xd2\xb7\x1f\xdb\x81" + "\x20\xea\x60\xc0", + .alen = 12, + .input = "\x00\x97\x69\xec\xab\xdf\x48\x62" + "\x55\x94\xc5\x92\x51\xe6\x03\x57" + "\x22\x67\x5e\x04\xc8\x47\x09\x9e" + "\x5a\xe0\x70\x45\x51", + .ilen = 29, + .result = "\x64\x35\xac\xba\xfb\x11\xa8\x2e" + "\x2f\x07\x1d\x7c\xa4\xa5\xeb\xd9" + "\x3a\x80\x3b\xa8\x7f", + .rlen = 21, }, { - .key = "\x58\x5d\xa0\x96\x65\x1a\x04\xd7" - "\x96\xe5\xc5\x68\xaa\x95\x35\xe0" - "\x29\xa0\xba\x9e\x48\x78\xd1\xba" - "\x0d\x1a\x53\x3b\xb5\xe3\xf8\x8b" - "\xcf\x76\x3f", - .klen = 35, - .iv = "\xd9\x95\x75\x8f\x44\x89\x40\x7b", - .assoc = "\x8f\x86\x6c\x4d\x1d\xc5\x39\x88" - "\xc8\xf3\x5c\x52\x10\x63\x6f\x2b" - "\x8a\x2a\xc5\x6f\x30\x23\x58\x7b" - "\xfb\x36\x03\x11\xb4\xd9\xf2\xfe", - .alen = 32, - .input = "\x48\x58\xd6\xf3\xad\x63\x58\xbf" - "\xae\xc7\x5e\xae\x83\x8f\x7b\xe4" - "\x78\x5c\x4c\x67\x71\x89\x94\xbf" - "\x47\xf1\x63\x7e\x1c\x59\xbd\xc5" - "\x7f\x44\x0a\x0c\x01\x18\x07\x92" - "\xe1\xd3\x51\xce\x32\x6d\x0c\x5b", - .ilen = 48, - .result = "\xc2\x54\xc8\xde\x78\x87\x77\x40" - "\x49\x71\xe4\xb7\xe7\xcb\x76\x61" - "\x0a\x41\xb9\xe9\xc0\x76\x54\xab" - "\x04\x49\x3b\x19\x93\x57\x25\x5d", - .rlen = 32, + .key = "\xd7\x82\x8d\x13\xb2\xb0\xbd\xc3" + "\x25\xa7\x62\x36\xdf\x93\xcc\x6b", + .klen = 16, + .iv = "\x01\x00\x42\xff\xf8\xf1\x95\x1c" + "\x3c\x96\x96\x76\x6c\xfa\x00\x00", + .assoc = "\xd8\x5b\xc7\xe6\x9f\x94\x4f\xb8", + .alen = 8, + .input = "\xbc\x21\x8d\xaa\x94\x74\x27\xb6" + "\xdb\x38\x6a\x99\xac\x1a\xef\x23" + "\xad\xe0\xb5\x29\x39\xcb\x6a\x63" + "\x7c\xf9\xbe\xc2\x40\x88\x97\xc6" + "\xba", + .ilen = 33, + .result = "\x8a\x19\xb9\x50\xbc\xf7\x1a\x01" + "\x8e\x5e\x67\x01\xc9\x17\x87\x65" + "\x98\x09\xd6\x7d\xbe\xdd\x18", + .rlen = 23, }, }; /* - * ANSI X9.31 Continuous Pseudo-Random Number Generator (AES mode) - * test vectors, taken from Appendix B.2.9 and B.2.10: - * http://csrc.nist.gov/groups/STM/cavp/documents/rng/RNGVS.pdf - * Only AES-128 is supported at this time. + * rfc4309 refers to section 8 of rfc3610 for test vectors, but they all + * use a 13-byte nonce, we only support an 11-byte nonce. Similarly, all of + * Special Publication 800-38C's test vectors also use nonce lengths our + * implementation doesn't support. The following are taken from fips cavs + * fax files on hand at Red Hat. + * + * nb: actual key lengths are (klen - 3), the last 3 bytes are actually + * part of the nonce which combine w/the iv, but need to be input this way. */ -#define ANSI_CPRNG_AES_TEST_VECTORS 6 - -static struct cprng_testvec ansi_cprng_aes_tv_template[] = { +static struct aead_testvec aes_ccm_rfc4309_enc_tv_template[] = { { - .key = "\xf3\xb1\x66\x6d\x13\x60\x72\x42" - "\xed\x06\x1c\xab\xb8\xd4\x62\x02", - .klen = 16, - .dt = "\xe6\xb3\xbe\x78\x2a\x23\xfa\x62" - "\xd7\x1d\x4a\xfb\xb0\xe9\x22\xf9", - .dtlen = 16, - .v = "\x80\x00\x00\x00\x00\x00\x00\x00" - "\x00\x00\x00\x00\x00\x00\x00\x00", - .vlen = 16, - .result = "\x59\x53\x1e\xd1\x3b\xb0\xc0\x55" - "\x84\x79\x66\x85\xc1\x2f\x76\x41", - .rlen = 16, - .loops = 1, + .key = "\x83\xac\x54\x66\xc2\xeb\xe5\x05" + "\x2e\x01\xd1\xfc\x5d\x82\x66\x2e" + "\x96\xac\x59", + .klen = 19, + .iv = "\x30\x07\xa1\xe2\xa2\xc7\x55\x24", + .alen = 0, + .input = "\x19\xc8\x81\xf6\xe9\x86\xff\x93" + "\x0b\x78\x67\xe5\xbb\xb7\xfc\x6e" + "\x83\x77\xb3\xa6\x0c\x8c\x9f\x9c" + "\x35\x2e\xad\xe0\x62\xf9\x91\xa1", + .ilen = 32, + .result = "\xab\x6f\xe1\x69\x1d\x19\x99\xa8" + "\x92\xa0\xc4\x6f\x7e\xe2\x8b\xb1" + "\x70\xbb\x8c\xa6\x4c\x6e\x97\x8a" + "\x57\x2b\xbe\x5d\x98\xa6\xb1\x32" + "\xda\x24\xea\xd9\xa1\x39\x98\xfd" + "\xa4\xbe\xd9\xf2\x1a\x6d\x22\xa8", + .rlen = 48, }, { - .key = "\xf3\xb1\x66\x6d\x13\x60\x72\x42" - "\xed\x06\x1c\xab\xb8\xd4\x62\x02", - .klen = 16, - .dt = "\xe6\xb3\xbe\x78\x2a\x23\xfa\x62" - "\xd7\x1d\x4a\xfb\xb0\xe9\x22\xfa", - .dtlen = 16, - .v = "\xc0\x00\x00\x00\x00\x00\x00\x00" - "\x00\x00\x00\x00\x00\x00\x00\x00", - .vlen = 16, - .result = "\x7c\x22\x2c\xf4\xca\x8f\xa2\x4c" - "\x1c\x9c\xb6\x41\xa9\xf3\x22\x0d", - .rlen = 16, - .loops = 1, + .key = "\x1e\x2c\x7e\x01\x41\x9a\xef\xc0" + "\x0d\x58\x96\x6e\x5c\xa2\x4b\xd3" + "\x4f\xa3\x19", + .klen = 19, + .iv = "\xd3\x01\x5a\xd8\x30\x60\x15\x56", + .assoc = "\xda\xe6\x28\x9c\x45\x2d\xfd\x63" + "\x5e\xda\x4c\xb6\xe6\xfc\xf9\xb7" + "\x0c\x56\xcb\xe4\xe0\x05\x7a\xe1" + "\x0a\x63\x09\x78\xbc\x2c\x55\xde", + .alen = 32, + .input = "\x87\xa3\x36\xfd\x96\xb3\x93\x78" + "\xa9\x28\x63\xba\x12\xa3\x14\x85" + "\x57\x1e\x06\xc9\x7b\x21\xef\x76" + "\x7f\x38\x7e\x8e\x29\xa4\x3e\x7e", + .ilen = 32, + .result = "\x8a\x1e\x11\xf0\x02\x6b\xe2\x19" + "\xfc\x70\xc4\x6d\x8e\xb7\x99\xab" + "\xc5\x4b\xa2\xac\xd3\xf3\x48\xff" + "\x3b\xb5\xce\x53\xef\xde\xbb\x02" + "\xa9\x86\x15\x6c\x13\xfe\xda\x0a" + "\x22\xb8\x29\x3d\xd8\x39\x9a\x23", + .rlen = 48, }, { - .key = "\xf3\xb1\x66\x6d\x13\x60\x72\x42" - "\xed\x06\x1c\xab\xb8\xd4\x62\x02", - .klen = 16, - .dt = "\xe6\xb3\xbe\x78\x2a\x23\xfa\x62" - "\xd7\x1d\x4a\xfb\xb0\xe9\x22\xfb", - .dtlen = 16, - .v = "\xe0\x00\x00\x00\x00\x00\x00\x00" - "\x00\x00\x00\x00\x00\x00\x00\x00", - .vlen = 16, - .result = "\x8a\xaa\x00\x39\x66\x67\x5b\xe5" - "\x29\x14\x28\x81\xa9\x4d\x4e\xc7", + .key = "\xf4\x6b\xc2\x75\x62\xfe\xb4\xe1" + "\xa3\xf0\xff\xdd\x4e\x4b\x12\x75" + "\x53\x14\x73\x66\x8d\x88\xf6\x80" + "\xa0\x20\x35", + .klen = 27, + .iv = "\x26\xf2\x21\x8d\x50\x20\xda\xe2", + .assoc = "\x5b\x9e\x13\x67\x02\x5e\xef\xc1" + "\x6c\xf9\xd7\x1e\x52\x8f\x7a\x47" + "\xe9\xd4\xcf\x20\x14\x6e\xf0\x2d" + "\xd8\x9e\x2b\x56\x10\x23\x56\xe7", + .alen = 32, + .ilen = 0, + .result = "\x36\xea\x7a\x70\x08\xdc\x6a\xbc" + "\xad\x0c\x7a\x63\xf6\x61\xfd\x9b", .rlen = 16, - .loops = 1, }, { - .key = "\xf3\xb1\x66\x6d\x13\x60\x72\x42" - "\xed\x06\x1c\xab\xb8\xd4\x62\x02", - .klen = 16, - .dt = "\xe6\xb3\xbe\x78\x2a\x23\xfa\x62" - "\xd7\x1d\x4a\xfb\xb0\xe9\x22\xfc", - .dtlen = 16, - .v = "\xf0\x00\x00\x00\x00\x00\x00\x00" - "\x00\x00\x00\x00\x00\x00\x00\x00", - .vlen = 16, - .result = "\x88\xdd\xa4\x56\x30\x24\x23\xe5" - "\xf6\x9d\xa5\x7e\x7b\x95\xc7\x3a", - .rlen = 16, - .loops = 1, + .key = "\x56\xdf\x5c\x8f\x26\x3f\x0e\x42" + "\xef\x7a\xd3\xce\xfc\x84\x60\x62" + "\xca\xb4\x40\xaf\x5f\xc9\xc9\x01" + "\xd6\x3c\x8c", + .klen = 27, + .iv = "\x86\x84\xb6\xcd\xef\x09\x2e\x94", + .assoc = "\x02\x65\x78\x3c\xe9\x21\x30\x91" + "\xb1\xb9\xda\x76\x9a\x78\x6d\x95" + "\xf2\x88\x32\xa3\xf2\x50\xcb\x4c" + "\xe3\x00\x73\x69\x84\x69\x87\x79", + .alen = 32, + .input = "\x9f\xd2\x02\x4b\x52\x49\x31\x3c" + "\x43\x69\x3a\x2d\x8e\x70\xad\x7e" + "\xe0\xe5\x46\x09\x80\x89\x13\xb2" + "\x8c\x8b\xd9\x3f\x86\xfb\xb5\x6b", + .ilen = 32, + .result = "\x39\xdf\x7c\x3c\x5a\x29\xb9\x62" + "\x5d\x51\xc2\x16\xd8\xbd\x06\x9f" + "\x9b\x6a\x09\x70\xc1\x51\x83\xc2" + "\x66\x88\x1d\x4f\x9a\xda\xe0\x1e" + "\xc7\x79\x11\x58\xe5\x6b\x20\x40" + "\x7a\xea\x46\x42\x8b\xe4\x6f\xe1", + .rlen = 48, + }, { + .key = "\xe0\x8d\x99\x71\x60\xd7\x97\x1a" + "\xbd\x01\x99\xd5\x8a\xdf\x71\x3a" + "\xd3\xdf\x24\x4b\x5e\x3d\x4b\x4e" + "\x30\x7a\xb9\xd8\x53\x0a\x5e\x2b" + "\x1e\x29\x91", + .klen = 35, + .iv = "\xad\x8e\xc1\x53\x0a\xcf\x2d\xbe", + .assoc = "\x19\xb6\x1f\x57\xc4\xf3\xf0\x8b" + "\x78\x2b\x94\x02\x29\x0f\x42\x27" + "\x6b\x75\xcb\x98\x34\x08\x7e\x79" + "\xe4\x3e\x49\x0d\x84\x8b\x22\x87", + .alen = 32, + .input = "\xe1\xd9\xd8\x13\xeb\x3a\x75\x3f" + "\x9d\xbd\x5f\x66\xbe\xdc\xbb\x66" + "\xbf\x17\x99\x62\x4a\x39\x27\x1f" + "\x1d\xdc\x24\xae\x19\x2f\x98\x4c", + .ilen = 32, + .result = "\x19\xb8\x61\x33\x45\x2b\x43\x96" + "\x6f\x51\xd0\x20\x30\x7d\x9b\xc6" + "\x26\x3d\xf8\xc9\x65\x16\xa8\x9f" + "\xf0\x62\x17\x34\xf2\x1e\x8d\x75" + "\x4e\x13\xcc\xc0\xc3\x2a\x54\x2d", + .rlen = 40, }, { - .key = "\xf3\xb1\x66\x6d\x13\x60\x72\x42" - "\xed\x06\x1c\xab\xb8\xd4\x62\x02", - .klen = 16, - .dt = "\xe6\xb3\xbe\x78\x2a\x23\xfa\x62" - "\xd7\x1d\x4a\xfb\xb0\xe9\x22\xfd", - .dtlen = 16, - .v = "\xf8\x00\x00\x00\x00\x00\x00\x00" - "\x00\x00\x00\x00\x00\x00\x00\x00", - .vlen = 16, - .result = "\x05\x25\x92\x46\x61\x79\xd2\xcb" - "\x78\xc4\x0b\x14\x0a\x5a\x9a\xc8", - .rlen = 16, - .loops = 1, - }, { /* Monte Carlo Test */ - .key = "\x9f\x5b\x51\x20\x0b\xf3\x34\xb5" - "\xd8\x2b\xe8\xc3\x72\x55\xc8\x48", - .klen = 16, - .dt = "\x63\x76\xbb\xe5\x29\x02\xba\x3b" - "\x67\xc9\x25\xfa\x70\x1f\x11\xac", - .dtlen = 16, - .v = "\x57\x2c\x8e\x76\x87\x26\x47\x97" - "\x7e\x74\xfb\xdd\xc4\x95\x01\xd1", - .vlen = 16, - .result = "\x48\xe9\xbd\x0d\x06\xee\x18\xfb" - "\xe4\x57\x90\xd5\xc3\xfc\x9b\x73", - .rlen = 16, - .loops = 10000, + .key = "\x7c\xc8\x18\x3b\x8d\x99\xe0\x7c" + "\x45\x41\xb8\xbd\x5c\xa7\xc2\x32" + "\x8a\xb8\x02\x59\xa4\xfe\xa9\x2c" + "\x09\x75\x9a\x9b\x3c\x9b\x27\x39" + "\xf9\xd9\x4e", + .klen = 35, + .iv = "\x63\xb5\x3d\x9d\x43\xf6\x1e\x50", + .assoc = "\x57\xf5\x6b\x8b\x57\x5c\x3d\x3b" + "\x13\x02\x01\x0c\x83\x4c\x96\x35" + "\x8e\xd6\x39\xcf\x7d\x14\x9b\x94" + "\xb0\x39\x36\xe6\x8f\x57\xe0\x13", + .alen = 32, + .input = "\x3b\x6c\x29\x36\xb6\xef\x07\xa6" + "\x83\x72\x07\x4f\xcf\xfa\x66\x89" + "\x5f\xca\xb1\xba\xd5\x8f\x2c\x27" + "\x30\xdb\x75\x09\x93\xd4\x65\xe4", + .ilen = 32, + .result = "\xb0\x88\x5a\x33\xaa\xe5\xc7\x1d" + "\x85\x23\xc7\xc6\x2f\xf4\x1e\x3d" + "\xcc\x63\x44\x25\x07\x78\x4f\x9e" + "\x96\xb8\x88\xeb\xbc\x48\x1f\x06" + "\x39\xaf\x39\xac\xd8\x4a\x80\x39" + "\x7b\x72\x8a\xf7", + .rlen = 44, + }, { + .key = "\xab\xd0\xe9\x33\x07\x26\xe5\x83" + "\x8c\x76\x95\xd4\xb6\xdc\xf3\x46" + "\xf9\x8f\xad\xe3\x02\x13\x83\x77" + "\x3f\xb0\xf1\xa1\xa1\x22\x0f\x2b" + "\x24\xa7\x8b", + .klen = 35, + .iv = "\x07\xcb\xcc\x0e\xe6\x33\xbf\xf5", + .assoc = "\xd4\xdb\x30\x1d\x03\xfe\xfd\x5f" + "\x87\xd4\x8c\xb6\xb6\xf1\x7a\x5d" + "\xab\x90\x65\x8d\x8e\xca\x4d\x4f" + "\x16\x0c\x40\x90\x4b\xc7\x36\x73", + .alen = 32, + .input = "\xf5\xc6\x7d\x48\xc1\xb7\xe6\x92" + "\x97\x5a\xca\xc4\xa9\x6d\xf9\x3d" + "\x6c\xde\xbc\xf1\x90\xea\x6a\xb2" + "\x35\x86\x36\xaf\x5c\xfe\x4b\x3a", + .ilen = 32, + .result = "\x83\x6f\x40\x87\x72\xcf\xc1\x13" + "\xef\xbb\x80\x21\x04\x6c\x58\x09" + "\x07\x1b\xfc\xdf\xc0\x3f\x5b\xc7" + "\xe0\x79\xa8\x6e\x71\x7c\x3f\xcf" + "\x5c\xda\xb2\x33\xe5\x13\xe2\x0d" + "\x74\xd1\xef\xb5\x0f\x3a\xb5\xf8", + .rlen = 48, }, }; -/* Cast5 test vectors from RFC 2144 */ -#define CAST5_ENC_TEST_VECTORS 4 -#define CAST5_DEC_TEST_VECTORS 4 -#define CAST5_CBC_ENC_TEST_VECTORS 1 -#define CAST5_CBC_DEC_TEST_VECTORS 1 -#define CAST5_CTR_ENC_TEST_VECTORS 2 -#define CAST5_CTR_DEC_TEST_VECTORS 2 - -static struct cipher_testvec cast5_enc_tv_template[] = { +static struct aead_testvec aes_ccm_rfc4309_dec_tv_template[] = { { - .key = "\x01\x23\x45\x67\x12\x34\x56\x78" - "\x23\x45\x67\x89\x34\x56\x78\x9a", - .klen = 16, - .input = "\x01\x23\x45\x67\x89\xab\xcd\xef", + .key = "\xab\x2f\x8a\x74\xb7\x1c\xd2\xb1" + "\xff\x80\x2e\x48\x7d\x82\xf8\xb9" + "\xc6\xfb\x7d", + .klen = 19, + .iv = "\x80\x0d\x13\xab\xd8\xa6\xb2\xd8", + .alen = 0, + .input = "\xd5\xe8\x93\x9f\xc7\x89\x2e\x2b", .ilen = 8, - .result = "\x23\x8b\x4f\xe5\x84\x7e\x44\xb2", - .rlen = 8, + .result = "\x00", + .rlen = 0, + .novrfy = 1, }, { - .key = "\x01\x23\x45\x67\x12\x34\x56\x78" - "\x23\x45", - .klen = 10, - .input = "\x01\x23\x45\x67\x89\xab\xcd\xef", + .key = "\xab\x2f\x8a\x74\xb7\x1c\xd2\xb1" + "\xff\x80\x2e\x48\x7d\x82\xf8\xb9" + "\xaf\x94\x87", + .klen = 19, + .iv = "\x78\x35\x82\x81\x7f\x88\x94\x68", + .alen = 0, + .input = "\x41\x3c\xb8\x87\x73\xcb\xf3\xf3", .ilen = 8, - .result = "\xeb\x6a\x71\x1a\x2c\x02\x27\x1b", - .rlen = 8, + .result = "\x00", + .rlen = 0, }, { - .key = "\x01\x23\x45\x67\x12", - .klen = 5, - .input = "\x01\x23\x45\x67\x89\xab\xcd\xef", - .ilen = 8, - .result = "\x7a\xc8\x16\xd1\x6e\x9b\x30\x2e", - .rlen = 8, - }, { /* Generated from TF test vectors */ - .key = "\x85\x62\x3F\x1C\xF9\xD6\x1C\xF9" - "\xD6\xB3\x90\x6D\x4A\x90\x6D\x4A", - .klen = 16, - .iv = "\xE2\x24\x89\xEE\x53\xB8\x1D\x5F", - .input = "\x56\xED\x84\x1B\x8F\x26\xBD\x31" - "\xC8\x5F\xF6\x6A\x01\x98\x0C\xA3" - "\x3A\xD1\x45\xDC\x73\x0A\x7E\x15" - "\xAC\x20\xB7\x4E\xE5\x59\xF0\x87" - "\x1E\x92\x29\xC0\x34\xCB\x62\xF9" - "\x6D\x04\x9B\x0F\xA6\x3D\xD4\x48" - "\xDF\x76\x0D\x81\x18\xAF\x23\xBA" - "\x51\xE8\x5C\xF3\x8A\x21\x95\x2C" - "\xC3\x37\xCE\x65\xFC\x70\x07\x9E" - "\x12\xA9\x40\xD7\x4B\xE2\x79\x10" - "\x84\x1B\xB2\x26\xBD\x54\xEB\x5F" - "\xF6\x8D\x01\x98\x2F\xC6\x3A\xD1" - "\x68\xFF\x73\x0A\xA1\x15\xAC\x43" - "\xDA\x4E\xE5\x7C\x13\x87\x1E\xB5" - "\x29\xC0\x57\xEE\x62\xF9\x90\x04" - "\x9B\x32\xC9\x3D\xD4\x6B\x02\x76" - "\x0D\xA4\x18\xAF\x46\xDD\x51\xE8" - "\x7F\x16\x8A\x21\xB8\x2C\xC3\x5A" - "\xF1\x65\xFC\x93\x07\x9E\x35\xCC" - "\x40\xD7\x6E\x05\x79\x10\xA7\x1B" - "\xB2\x49\xE0\x54\xEB\x82\x19\x8D" - "\x24\xBB\x2F\xC6\x5D\xF4\x68\xFF" - "\x96\x0A\xA1\x38\xCF\x43\xDA\x71" - "\x08\x7C\x13\xAA\x1E\xB5\x4C\xE3" - "\x57\xEE\x85\x1C\x90\x27\xBE\x32" - "\xC9\x60\xF7\x6B\x02\x99\x0D\xA4" - "\x3B\xD2\x46\xDD\x74\x0B\x7F\x16" - "\xAD\x21\xB8\x4F\xE6\x5A\xF1\x88" - "\x1F\x93\x2A\xC1\x35\xCC\x63\xFA" - "\x6E\x05\x9C\x10\xA7\x3E\xD5\x49" - "\xE0\x77\x0E\x82\x19\xB0\x24\xBB" - "\x52\xE9\x5D\xF4\x8B\x22\x96\x2D" - "\xC4\x38\xCF\x66\xFD\x71\x08\x9F" - "\x13\xAA\x41\xD8\x4C\xE3\x7A\x11" - "\x85\x1C\xB3\x27\xBE\x55\xEC\x60" - "\xF7\x8E\x02\x99\x30\xC7\x3B\xD2" - "\x69\x00\x74\x0B\xA2\x16\xAD\x44" - "\xDB\x4F\xE6\x7D\x14\x88\x1F\xB6" - "\x2A\xC1\x58\xEF\x63\xFA\x91\x05" - "\x9C\x33\xCA\x3E\xD5\x6C\x03\x77" - "\x0E\xA5\x19\xB0\x47\xDE\x52\xE9" - "\x80\x17\x8B\x22\xB9\x2D\xC4\x5B" - "\xF2\x66\xFD\x94\x08\x9F\x36\xCD" - "\x41\xD8\x6F\x06\x7A\x11\xA8\x1C" - "\xB3\x4A\xE1\x55\xEC\x83\x1A\x8E" - "\x25\xBC\x30\xC7\x5E\xF5\x69\x00" - "\x97\x0B\xA2\x39\xD0\x44\xDB\x72" - "\x09\x7D\x14\xAB\x1F\xB6\x4D\xE4" - "\x58\xEF\x86\x1D\x91\x28\xBF\x33" - "\xCA\x61\xF8\x6C\x03\x9A\x0E\xA5" - "\x3C\xD3\x47\xDE\x75\x0C\x80\x17" - "\xAE\x22\xB9\x50\xE7\x5B\xF2\x89" - "\x20\x94\x2B\xC2\x36\xCD\x64\xFB" - "\x6F\x06\x9D\x11\xA8\x3F\xD6\x4A" - "\xE1\x78\x0F\x83\x1A\xB1\x25\xBC" - "\x53\xEA\x5E\xF5\x8C\x00\x97\x2E" - "\xC5\x39\xD0\x67\xFE\x72\x09\xA0" - "\x14\xAB\x42\xD9\x4D\xE4\x7B\x12" - "\x86\x1D\xB4\x28\xBF\x56\xED\x61" - "\xF8\x8F\x03\x9A\x31\xC8\x3C\xD3" - "\x6A\x01\x75\x0C\xA3\x17\xAE\x45" - "\xDC\x50\xE7\x7E\x15\x89\x20\xB7", - .ilen = 496, - .result = "\x8D\xFC\x81\x9C\xCB\xAA\x5A\x1C" - "\x7E\x95\xCF\x40\xAB\x4D\x6F\xEA" - "\xD3\xD9\xB0\x9A\xB7\xC7\xE0\x2E" - "\xD1\x39\x34\x92\x8F\xFA\x14\xF1" - "\xD5\xD2\x7B\x59\x1F\x35\x28\xC2" - "\x20\xD9\x42\x06\xC9\x0B\x10\x04" - "\xF8\x79\xCD\x32\x86\x75\x4C\xB6" - "\x7B\x1C\x52\xB1\x91\x64\x22\x4B" - "\x13\xC7\xAE\x98\x0E\xB5\xCF\x6F" - "\x3F\xF4\x43\x96\x73\x0D\xA2\x05" - "\xDB\xFD\x28\x90\x2C\x56\xB9\x37" - "\x5B\x69\x0C\xAD\x84\x67\xFF\x15" - "\x4A\xD4\xA7\xD3\xDD\x99\x47\x3A" - "\xED\x34\x35\x78\x6B\x91\xC9\x32" - "\xE1\xBF\xBC\xB4\x04\x85\x6A\x39" - "\xC0\xBA\x51\xD0\x0F\x4E\xD1\xE2" - "\x1C\xFD\x0E\x05\x07\xF4\x10\xED" - "\xA2\x17\xFF\xF5\x64\xC6\x1A\x22" - "\xAD\x78\xE7\xD7\x11\xE9\x99\xB9" - "\xAA\xEC\x6F\xF8\x3B\xBF\xCE\x77" - "\x93\xE8\xAD\x1D\x50\x6C\xAE\xBC" - "\xBA\x5C\x80\xD1\x91\x65\x51\x1B" - "\xE8\x0A\xCD\x99\x96\x71\x3D\xB6" - "\x78\x75\x37\x55\xC1\xF5\x90\x40" - "\x34\xF4\x7E\xC8\xCC\x3A\x5F\x6E" - "\x36\xA1\xA1\xC2\x3A\x72\x42\x8E" - "\x0E\x37\x88\xE8\xCE\x83\xCB\xAD" - "\xE0\x69\x77\x50\xC7\x0C\x99\xCA" - "\x19\x5B\x30\x25\x9A\xEF\x9B\x0C" - "\xEF\x8F\x74\x4C\xCF\x49\x4E\xB9" - "\xC5\xAE\x9E\x2E\x78\x9A\xB9\x48" - "\xD5\x81\xE4\x37\x1D\xBF\x27\xD9" - "\xC5\xD6\x65\x43\x45\x8C\xBB\xB6" - "\x55\xF4\x06\xBB\x49\x53\x8B\x1B" - "\x07\xA9\x96\x69\x5B\xCB\x0F\xBC" - "\x93\x85\x90\x0F\x0A\x68\x40\x2A" - "\x95\xED\x2D\x88\xBF\x71\xD0\xBB" - "\xEC\xB0\x77\x6C\x79\xFC\x3C\x05" - "\x49\x3F\xB8\x24\xEF\x8E\x09\xA2" - "\x1D\xEF\x92\x02\x96\xD4\x7F\xC8" - "\x03\xB2\xCA\xDB\x17\x5C\x52\xCF" - "\xDD\x70\x37\x63\xAA\xA5\x83\x20" - "\x52\x02\xF6\xB9\xE7\x6E\x0A\xB6" - "\x79\x03\xA0\xDA\xA3\x79\x21\xBD" - "\xE3\x37\x3A\xC0\xF7\x2C\x32\xBE" - "\x8B\xE8\xA6\x00\xC7\x32\xD5\x06" - "\xBB\xE3\xAB\x06\x21\x82\xB8\x32" - "\x31\x34\x2A\xA7\x1F\x64\x99\xBF" - "\xFA\xDA\x3D\x75\xF7\x48\xD5\x48" - "\x4B\x52\x7E\xF6\x7C\xAB\x67\x59" - "\xC5\xDC\xA8\xC6\x63\x85\x4A\xDF" - "\xF0\x40\x5F\xCF\xE3\x58\x52\x67" - "\x7A\x24\x32\xC5\xEC\x9E\xA9\x6F" - "\x58\x56\xDD\x94\x1F\x71\x8D\xF4" - "\x6E\xFF\x2C\xA7\xA5\xD8\xBA\xAF" - "\x1D\x8B\xA2\x46\xB5\xC4\x9F\x57" - "\x8D\xD8\xB3\x3C\x02\x0D\xBB\x84" - "\xC7\xBD\xB4\x9A\x6E\xBB\xB1\x37" - "\x95\x79\xC4\xA7\xEA\x1D\xDC\x33" - "\x5D\x0B\x3F\x03\x8F\x30\xF9\xAE" - "\x4F\xFE\x24\x9C\x9A\x02\xE5\x57" - "\xF5\xBC\x25\xD6\x02\x56\x57\x1C", - .rlen = 496, - .also_non_np = 1, - .np = 2, - .tap = { 496 - 16, 16 }, - }, -}; - -static struct cipher_testvec cast5_dec_tv_template[] = { - { - .key = "\x01\x23\x45\x67\x12\x34\x56\x78" - "\x23\x45\x67\x89\x34\x56\x78\x9a", - .klen = 16, - .input = "\x23\x8b\x4f\xe5\x84\x7e\x44\xb2", + .key = "\x61\x0e\x8c\xae\xe3\x23\xb6\x38" + "\x76\x1c\xf6\x3a\x67\xa3\x9c\xd8" + "\xc6\xfb\x7d", + .klen = 19, + .iv = "\x80\x0d\x13\xab\xd8\xa6\xb2\xd8", + .assoc = "\xf3\x94\x87\x78\x35\x82\x81\x7f" + "\x88\x94\x68\xb1\x78\x6b\x2b\xd6" + "\x04\x1f\x4e\xed\x78\xd5\x33\x66" + "\xd8\x94\x99\x91\x81\x54\x62\x57", + .alen = 32, + .input = "\xf0\x7c\x29\x02\xae\x1c\x2f\x55" + "\xd0\xd1\x3d\x1a\xa3\x6d\xe4\x0a" + "\x86\xb0\x87\x6b\x62\x33\x8c\x34" + "\xce\xab\x57\xcc\x79\x0b\xe0\x6f" + "\x5c\x3e\x48\x1f\x6c\x46\xf7\x51" + "\x8b\x84\x83\x2a\xc1\x05\xb8\xc5", + .ilen = 48, + .result = "\x50\x82\x3e\x07\xe2\x1e\xb6\xfb" + "\x33\xe4\x73\xce\xd2\xfb\x95\x79" + "\xe8\xb4\xb5\x77\x11\x10\x62\x6f" + "\x6a\x82\xd1\x13\xec\xf5\xd0\x48", + .rlen = 32, + .novrfy = 1, + }, { + .key = "\x61\x0e\x8c\xae\xe3\x23\xb6\x38" + "\x76\x1c\xf6\x3a\x67\xa3\x9c\xd8" + "\x05\xe0\xc9", + .klen = 19, + .iv = "\x0f\xed\x34\xea\x97\xd4\x3b\xdf", + .assoc = "\x49\x5c\x50\x1f\x1d\x94\xcc\x81" + "\xba\xb7\xb6\x03\xaf\xa5\xc1\xa1" + "\xd8\x5c\x42\x68\xe0\x6c\xda\x89" + "\x05\xac\x56\xac\x1b\x2a\xd3\x86", + .alen = 32, + .input = "\x39\xbe\x7d\x15\x62\x77\xf3\x3c" + "\xad\x83\x52\x6d\x71\x03\x25\x1c" + "\xed\x81\x3a\x9a\x16\x7d\x19\x80" + "\x72\x04\x72\xd0\xf6\xff\x05\x0f" + "\xb7\x14\x30\x00\x32\x9e\xa0\xa6" + "\x9e\x5a\x18\xa1\xb8\xfe\xdb\xd3", + .ilen = 48, + .result = "\x75\x05\xbe\xc2\xd9\x1e\xde\x60" + "\x47\x3d\x8c\x7d\xbd\xb5\xd9\xb7" + "\xf2\xae\x61\x05\x8f\x82\x24\x3f" + "\x9c\x67\x91\xe1\x38\x4f\xe4\x0c", + .rlen = 32, + }, { + .key = "\x39\xbb\xa7\xbe\x59\x97\x9e\x73" + "\xa2\xbc\x6b\x98\xd7\x75\x7f\xe3" + "\xa4\x48\x93\x39\x26\x71\x4a\xc6" + "\xee\x49\x83", + .klen = 27, + .iv = "\xe9\xa9\xff\xe9\x57\xba\xfd\x9e", + .assoc = "\x44\xa6\x2c\x05\xe9\xe1\x43\xb1" + "\x58\x7c\xf2\x5c\x6d\x39\x0a\x64" + "\xa4\xf0\x13\x05\xd1\x77\x99\x67" + "\x11\xc4\xc6\xdb\x00\x56\x36\x61", + .alen = 32, + .input = "\x71\x99\xfa\xf4\x44\x12\x68\x9b", .ilen = 8, - .result = "\x01\x23\x45\x67\x89\xab\xcd\xef", - .rlen = 8, + .result = "\x00", + .rlen = 0, }, { - .key = "\x01\x23\x45\x67\x12\x34\x56\x78" - "\x23\x45", - .klen = 10, - .input = "\xeb\x6a\x71\x1a\x2c\x02\x27\x1b", - .ilen = 8, - .result = "\x01\x23\x45\x67\x89\xab\xcd\xef", - .rlen = 8, + .key = "\x58\x5d\xa0\x96\x65\x1a\x04\xd7" + "\x96\xe5\xc5\x68\xaa\x95\x35\xe0" + "\x29\xa0\xba\x9e\x48\x78\xd1\xba" + "\xee\x49\x83", + .klen = 27, + .iv = "\xe9\xa9\xff\xe9\x57\xba\xfd\x9e", + .assoc = "\x44\xa6\x2c\x05\xe9\xe1\x43\xb1" + "\x58\x7c\xf2\x5c\x6d\x39\x0a\x64" + "\xa4\xf0\x13\x05\xd1\x77\x99\x67" + "\x11\xc4\xc6\xdb\x00\x56\x36\x61", + .alen = 32, + .input = "\xfb\xe5\x5d\x34\xbe\xe5\xe8\xe7" + "\x5a\xef\x2f\xbf\x1f\x7f\xd4\xb2" + "\x66\xca\x61\x1e\x96\x7a\x61\xb3" + "\x1c\x16\x45\x52\xba\x04\x9c\x9f" + "\xb1\xd2\x40\xbc\x52\x7c\x6f\xb1", + .ilen = 40, + .result = "\x85\x34\x66\x42\xc8\x92\x0f\x36" + "\x58\xe0\x6b\x91\x3c\x98\x5c\xbb" + "\x0a\x85\xcc\x02\xad\x7a\x96\xe9" + "\x65\x43\xa4\xc3\x0f\xdc\x55\x81", + .rlen = 32, }, { - .key = "\x01\x23\x45\x67\x12", - .klen = 5, - .input = "\x7a\xc8\x16\xd1\x6e\x9b\x30\x2e", + .key = "\x58\x5d\xa0\x96\x65\x1a\x04\xd7" + "\x96\xe5\xc5\x68\xaa\x95\x35\xe0" + "\x29\xa0\xba\x9e\x48\x78\xd1\xba" + "\xd1\xfc\x57", + .klen = 27, + .iv = "\x9c\xfe\xb8\x9c\xad\x71\xaa\x1f", + .assoc = "\x86\x67\xa5\xa9\x14\x5f\x0d\xc6" + "\xff\x14\xc7\x44\xbf\x6c\x3a\xc3" + "\xff\xb6\x81\xbd\xe2\xd5\x06\xc7" + "\x3c\xa1\x52\x13\x03\x8a\x23\x3a", + .alen = 32, + .input = "\x3f\x66\xb0\x9d\xe5\x4b\x38\x00" + "\xc6\x0e\x6e\xe5\xd6\x98\xa6\x37" + "\x8c\x26\x33\xc6\xb2\xa2\x17\xfa" + "\x64\x19\xc0\x30\xd7\xfc\x14\x6b" + "\xe3\x33\xc2\x04\xb0\x37\xbe\x3f" + "\xa9\xb4\x2d\x68\x03\xa3\x44\xef", + .ilen = 48, + .result = "\x02\x87\x4d\x28\x80\x6e\xb2\xed" + "\x99\x2a\xa8\xca\x04\x25\x45\x90" + "\x1d\xdd\x5a\xd9\xe4\xdb\x9c\x9c" + "\x49\xe9\x01\xfe\xa7\x80\x6d\x6b", + .rlen = 32, + .novrfy = 1, + }, { + .key = "\xa4\x4b\x54\x29\x0a\xb8\x6d\x01" + "\x5b\x80\x2a\xcf\x25\xc4\xb7\x5c" + "\x20\x2c\xad\x30\xc2\x2b\x41\xfb" + "\x0e\x85\xbc\x33\xad\x0f\x2b\xff" + "\xee\x49\x83", + .klen = 35, + .iv = "\xe9\xa9\xff\xe9\x57\xba\xfd\x9e", + .alen = 0, + .input = "\x1f\xb8\x8f\xa3\xdd\x54\x00\xf2", .ilen = 8, - .result = "\x01\x23\x45\x67\x89\xab\xcd\xef", - .rlen = 8, - }, { /* Generated from TF test vectors */ - .key = "\x85\x62\x3F\x1C\xF9\xD6\x1C\xF9" - "\xD6\xB3\x90\x6D\x4A\x90\x6D\x4A", - .klen = 16, - .iv = "\xE2\x24\x89\xEE\x53\xB8\x1D\x5F", - .input = "\x8D\xFC\x81\x9C\xCB\xAA\x5A\x1C" - "\x7E\x95\xCF\x40\xAB\x4D\x6F\xEA" - "\xD3\xD9\xB0\x9A\xB7\xC7\xE0\x2E" - "\xD1\x39\x34\x92\x8F\xFA\x14\xF1" - "\xD5\xD2\x7B\x59\x1F\x35\x28\xC2" - "\x20\xD9\x42\x06\xC9\x0B\x10\x04" - "\xF8\x79\xCD\x32\x86\x75\x4C\xB6" - "\x7B\x1C\x52\xB1\x91\x64\x22\x4B" - "\x13\xC7\xAE\x98\x0E\xB5\xCF\x6F" - "\x3F\xF4\x43\x96\x73\x0D\xA2\x05" - "\xDB\xFD\x28\x90\x2C\x56\xB9\x37" - "\x5B\x69\x0C\xAD\x84\x67\xFF\x15" - "\x4A\xD4\xA7\xD3\xDD\x99\x47\x3A" - "\xED\x34\x35\x78\x6B\x91\xC9\x32" - "\xE1\xBF\xBC\xB4\x04\x85\x6A\x39" - "\xC0\xBA\x51\xD0\x0F\x4E\xD1\xE2" - "\x1C\xFD\x0E\x05\x07\xF4\x10\xED" - "\xA2\x17\xFF\xF5\x64\xC6\x1A\x22" - "\xAD\x78\xE7\xD7\x11\xE9\x99\xB9" - "\xAA\xEC\x6F\xF8\x3B\xBF\xCE\x77" - "\x93\xE8\xAD\x1D\x50\x6C\xAE\xBC" - "\xBA\x5C\x80\xD1\x91\x65\x51\x1B" - "\xE8\x0A\xCD\x99\x96\x71\x3D\xB6" - "\x78\x75\x37\x55\xC1\xF5\x90\x40" - "\x34\xF4\x7E\xC8\xCC\x3A\x5F\x6E" - "\x36\xA1\xA1\xC2\x3A\x72\x42\x8E" - "\x0E\x37\x88\xE8\xCE\x83\xCB\xAD" - "\xE0\x69\x77\x50\xC7\x0C\x99\xCA" - "\x19\x5B\x30\x25\x9A\xEF\x9B\x0C" - "\xEF\x8F\x74\x4C\xCF\x49\x4E\xB9" - "\xC5\xAE\x9E\x2E\x78\x9A\xB9\x48" - "\xD5\x81\xE4\x37\x1D\xBF\x27\xD9" - "\xC5\xD6\x65\x43\x45\x8C\xBB\xB6" - "\x55\xF4\x06\xBB\x49\x53\x8B\x1B" - "\x07\xA9\x96\x69\x5B\xCB\x0F\xBC" - "\x93\x85\x90\x0F\x0A\x68\x40\x2A" - "\x95\xED\x2D\x88\xBF\x71\xD0\xBB" - "\xEC\xB0\x77\x6C\x79\xFC\x3C\x05" - "\x49\x3F\xB8\x24\xEF\x8E\x09\xA2" - "\x1D\xEF\x92\x02\x96\xD4\x7F\xC8" - "\x03\xB2\xCA\xDB\x17\x5C\x52\xCF" - "\xDD\x70\x37\x63\xAA\xA5\x83\x20" - "\x52\x02\xF6\xB9\xE7\x6E\x0A\xB6" - "\x79\x03\xA0\xDA\xA3\x79\x21\xBD" - "\xE3\x37\x3A\xC0\xF7\x2C\x32\xBE" - "\x8B\xE8\xA6\x00\xC7\x32\xD5\x06" - "\xBB\xE3\xAB\x06\x21\x82\xB8\x32" - "\x31\x34\x2A\xA7\x1F\x64\x99\xBF" - "\xFA\xDA\x3D\x75\xF7\x48\xD5\x48" - "\x4B\x52\x7E\xF6\x7C\xAB\x67\x59" - "\xC5\xDC\xA8\xC6\x63\x85\x4A\xDF" - "\xF0\x40\x5F\xCF\xE3\x58\x52\x67" - "\x7A\x24\x32\xC5\xEC\x9E\xA9\x6F" - "\x58\x56\xDD\x94\x1F\x71\x8D\xF4" - "\x6E\xFF\x2C\xA7\xA5\xD8\xBA\xAF" - "\x1D\x8B\xA2\x46\xB5\xC4\x9F\x57" - "\x8D\xD8\xB3\x3C\x02\x0D\xBB\x84" - "\xC7\xBD\xB4\x9A\x6E\xBB\xB1\x37" - "\x95\x79\xC4\xA7\xEA\x1D\xDC\x33" - "\x5D\x0B\x3F\x03\x8F\x30\xF9\xAE" - "\x4F\xFE\x24\x9C\x9A\x02\xE5\x57" - "\xF5\xBC\x25\xD6\x02\x56\x57\x1C", - .ilen = 496, - .result = "\x56\xED\x84\x1B\x8F\x26\xBD\x31" - "\xC8\x5F\xF6\x6A\x01\x98\x0C\xA3" - "\x3A\xD1\x45\xDC\x73\x0A\x7E\x15" - "\xAC\x20\xB7\x4E\xE5\x59\xF0\x87" - "\x1E\x92\x29\xC0\x34\xCB\x62\xF9" - "\x6D\x04\x9B\x0F\xA6\x3D\xD4\x48" - "\xDF\x76\x0D\x81\x18\xAF\x23\xBA" - "\x51\xE8\x5C\xF3\x8A\x21\x95\x2C" - "\xC3\x37\xCE\x65\xFC\x70\x07\x9E" - "\x12\xA9\x40\xD7\x4B\xE2\x79\x10" - "\x84\x1B\xB2\x26\xBD\x54\xEB\x5F" - "\xF6\x8D\x01\x98\x2F\xC6\x3A\xD1" - "\x68\xFF\x73\x0A\xA1\x15\xAC\x43" - "\xDA\x4E\xE5\x7C\x13\x87\x1E\xB5" - "\x29\xC0\x57\xEE\x62\xF9\x90\x04" - "\x9B\x32\xC9\x3D\xD4\x6B\x02\x76" - "\x0D\xA4\x18\xAF\x46\xDD\x51\xE8" - "\x7F\x16\x8A\x21\xB8\x2C\xC3\x5A" - "\xF1\x65\xFC\x93\x07\x9E\x35\xCC" - "\x40\xD7\x6E\x05\x79\x10\xA7\x1B" - "\xB2\x49\xE0\x54\xEB\x82\x19\x8D" - "\x24\xBB\x2F\xC6\x5D\xF4\x68\xFF" - "\x96\x0A\xA1\x38\xCF\x43\xDA\x71" - "\x08\x7C\x13\xAA\x1E\xB5\x4C\xE3" - "\x57\xEE\x85\x1C\x90\x27\xBE\x32" - "\xC9\x60\xF7\x6B\x02\x99\x0D\xA4" - "\x3B\xD2\x46\xDD\x74\x0B\x7F\x16" - "\xAD\x21\xB8\x4F\xE6\x5A\xF1\x88" - "\x1F\x93\x2A\xC1\x35\xCC\x63\xFA" - "\x6E\x05\x9C\x10\xA7\x3E\xD5\x49" - "\xE0\x77\x0E\x82\x19\xB0\x24\xBB" - "\x52\xE9\x5D\xF4\x8B\x22\x96\x2D" - "\xC4\x38\xCF\x66\xFD\x71\x08\x9F" - "\x13\xAA\x41\xD8\x4C\xE3\x7A\x11" - "\x85\x1C\xB3\x27\xBE\x55\xEC\x60" - "\xF7\x8E\x02\x99\x30\xC7\x3B\xD2" - "\x69\x00\x74\x0B\xA2\x16\xAD\x44" - "\xDB\x4F\xE6\x7D\x14\x88\x1F\xB6" - "\x2A\xC1\x58\xEF\x63\xFA\x91\x05" - "\x9C\x33\xCA\x3E\xD5\x6C\x03\x77" - "\x0E\xA5\x19\xB0\x47\xDE\x52\xE9" - "\x80\x17\x8B\x22\xB9\x2D\xC4\x5B" - "\xF2\x66\xFD\x94\x08\x9F\x36\xCD" - "\x41\xD8\x6F\x06\x7A\x11\xA8\x1C" - "\xB3\x4A\xE1\x55\xEC\x83\x1A\x8E" - "\x25\xBC\x30\xC7\x5E\xF5\x69\x00" - "\x97\x0B\xA2\x39\xD0\x44\xDB\x72" - "\x09\x7D\x14\xAB\x1F\xB6\x4D\xE4" - "\x58\xEF\x86\x1D\x91\x28\xBF\x33" - "\xCA\x61\xF8\x6C\x03\x9A\x0E\xA5" - "\x3C\xD3\x47\xDE\x75\x0C\x80\x17" - "\xAE\x22\xB9\x50\xE7\x5B\xF2\x89" - "\x20\x94\x2B\xC2\x36\xCD\x64\xFB" - "\x6F\x06\x9D\x11\xA8\x3F\xD6\x4A" - "\xE1\x78\x0F\x83\x1A\xB1\x25\xBC" - "\x53\xEA\x5E\xF5\x8C\x00\x97\x2E" - "\xC5\x39\xD0\x67\xFE\x72\x09\xA0" - "\x14\xAB\x42\xD9\x4D\xE4\x7B\x12" - "\x86\x1D\xB4\x28\xBF\x56\xED\x61" - "\xF8\x8F\x03\x9A\x31\xC8\x3C\xD3" - "\x6A\x01\x75\x0C\xA3\x17\xAE\x45" - "\xDC\x50\xE7\x7E\x15\x89\x20\xB7", - .rlen = 496, - .also_non_np = 1, - .np = 2, - .tap = { 496 - 16, 16 }, - }, -}; - -static struct cipher_testvec cast5_cbc_enc_tv_template[] = { - { /* Generated from TF test vectors */ - .key = "\x85\x62\x3F\x1C\xF9\xD6\x1C\xF9" - "\xD6\xB3\x90\x6D\x4A\x90\x6D\x4A", - .klen = 16, - .iv = "\xE2\x24\x89\xEE\x53\xB8\x1D\x5F", - .input = "\x56\xED\x84\x1B\x8F\x26\xBD\x31" - "\xC8\x5F\xF6\x6A\x01\x98\x0C\xA3" - "\x3A\xD1\x45\xDC\x73\x0A\x7E\x15" - "\xAC\x20\xB7\x4E\xE5\x59\xF0\x87" - "\x1E\x92\x29\xC0\x34\xCB\x62\xF9" - "\x6D\x04\x9B\x0F\xA6\x3D\xD4\x48" - "\xDF\x76\x0D\x81\x18\xAF\x23\xBA" - "\x51\xE8\x5C\xF3\x8A\x21\x95\x2C" - "\xC3\x37\xCE\x65\xFC\x70\x07\x9E" - "\x12\xA9\x40\xD7\x4B\xE2\x79\x10" - "\x84\x1B\xB2\x26\xBD\x54\xEB\x5F" - "\xF6\x8D\x01\x98\x2F\xC6\x3A\xD1" - "\x68\xFF\x73\x0A\xA1\x15\xAC\x43" - "\xDA\x4E\xE5\x7C\x13\x87\x1E\xB5" - "\x29\xC0\x57\xEE\x62\xF9\x90\x04" - "\x9B\x32\xC9\x3D\xD4\x6B\x02\x76" - "\x0D\xA4\x18\xAF\x46\xDD\x51\xE8" - "\x7F\x16\x8A\x21\xB8\x2C\xC3\x5A" - "\xF1\x65\xFC\x93\x07\x9E\x35\xCC" - "\x40\xD7\x6E\x05\x79\x10\xA7\x1B" - "\xB2\x49\xE0\x54\xEB\x82\x19\x8D" - "\x24\xBB\x2F\xC6\x5D\xF4\x68\xFF" - "\x96\x0A\xA1\x38\xCF\x43\xDA\x71" - "\x08\x7C\x13\xAA\x1E\xB5\x4C\xE3" - "\x57\xEE\x85\x1C\x90\x27\xBE\x32" - "\xC9\x60\xF7\x6B\x02\x99\x0D\xA4" - "\x3B\xD2\x46\xDD\x74\x0B\x7F\x16" - "\xAD\x21\xB8\x4F\xE6\x5A\xF1\x88" - "\x1F\x93\x2A\xC1\x35\xCC\x63\xFA" - "\x6E\x05\x9C\x10\xA7\x3E\xD5\x49" - "\xE0\x77\x0E\x82\x19\xB0\x24\xBB" - "\x52\xE9\x5D\xF4\x8B\x22\x96\x2D" - "\xC4\x38\xCF\x66\xFD\x71\x08\x9F" - "\x13\xAA\x41\xD8\x4C\xE3\x7A\x11" - "\x85\x1C\xB3\x27\xBE\x55\xEC\x60" - "\xF7\x8E\x02\x99\x30\xC7\x3B\xD2" - "\x69\x00\x74\x0B\xA2\x16\xAD\x44" - "\xDB\x4F\xE6\x7D\x14\x88\x1F\xB6" - "\x2A\xC1\x58\xEF\x63\xFA\x91\x05" - "\x9C\x33\xCA\x3E\xD5\x6C\x03\x77" - "\x0E\xA5\x19\xB0\x47\xDE\x52\xE9" - "\x80\x17\x8B\x22\xB9\x2D\xC4\x5B" - "\xF2\x66\xFD\x94\x08\x9F\x36\xCD" - "\x41\xD8\x6F\x06\x7A\x11\xA8\x1C" - "\xB3\x4A\xE1\x55\xEC\x83\x1A\x8E" - "\x25\xBC\x30\xC7\x5E\xF5\x69\x00" - "\x97\x0B\xA2\x39\xD0\x44\xDB\x72" - "\x09\x7D\x14\xAB\x1F\xB6\x4D\xE4" - "\x58\xEF\x86\x1D\x91\x28\xBF\x33" - "\xCA\x61\xF8\x6C\x03\x9A\x0E\xA5" - "\x3C\xD3\x47\xDE\x75\x0C\x80\x17" - "\xAE\x22\xB9\x50\xE7\x5B\xF2\x89" - "\x20\x94\x2B\xC2\x36\xCD\x64\xFB" - "\x6F\x06\x9D\x11\xA8\x3F\xD6\x4A" - "\xE1\x78\x0F\x83\x1A\xB1\x25\xBC" - "\x53\xEA\x5E\xF5\x8C\x00\x97\x2E" - "\xC5\x39\xD0\x67\xFE\x72\x09\xA0" - "\x14\xAB\x42\xD9\x4D\xE4\x7B\x12" - "\x86\x1D\xB4\x28\xBF\x56\xED\x61" - "\xF8\x8F\x03\x9A\x31\xC8\x3C\xD3" - "\x6A\x01\x75\x0C\xA3\x17\xAE\x45" - "\xDC\x50\xE7\x7E\x15\x89\x20\xB7", - .ilen = 496, - .result = "\x05\x28\xCE\x61\x90\x80\xE1\x78" - "\xB9\x2A\x97\x7C\xB0\x83\xD8\x1A" - "\xDE\x58\x7F\xD7\xFD\x72\xB8\xFB" - "\xDA\xF0\x6E\x77\x14\x47\x82\xBA" - "\x29\x0E\x25\x6E\xB4\x39\xD9\x7F" - "\x05\xA7\xA7\x3A\xC1\x5D\x9E\x39" - "\xA7\xFB\x0D\x05\x00\xF3\x58\x67" - "\x60\xEC\x73\x77\x46\x85\x9B\x6A" - "\x08\x3E\xBE\x59\xFB\xE4\x96\x34" - "\xB4\x05\x49\x1A\x97\x43\xAD\xA0" - "\xA9\x1E\x6E\x74\xF1\x94\xEC\xA8" - "\xB5\x8A\x20\xEA\x89\x6B\x19\xAA" - "\xA7\xF1\x33\x67\x90\x23\x0D\xEE" - "\x81\xD5\x78\x4F\xD3\x63\xEA\x46" - "\xB5\xB2\x6E\xBB\xCA\x76\x06\x10" - "\x96\x2A\x0A\xBA\xF9\x41\x5A\x1D" - "\x36\x7C\x56\x14\x54\x83\xFA\xA1" - "\x27\xDD\xBA\x8A\x90\x29\xD6\xA6" - "\xFA\x48\x3E\x1E\x23\x6E\x98\xA8" - "\xA7\xD9\x67\x92\x5C\x13\xB4\x71" - "\xA8\xAA\x89\x4A\xA4\xB3\x49\x7C" - "\x7D\x7F\xCE\x6F\x29\x2E\x7E\x37" - "\xC8\x52\x60\xD9\xE7\xCA\x60\x98" - "\xED\xCD\xE8\x60\x83\xAD\x34\x4D" - "\x96\x4A\x99\x2B\xB7\x14\x75\x66" - "\x6C\x2C\x1A\xBA\x4B\xBB\x49\x56" - "\xE1\x86\xA2\x0E\xD0\xF0\x07\xD3" - "\x18\x38\x09\x9C\x0E\x8B\x86\x07" - "\x90\x12\x37\x49\x27\x98\x69\x18" - "\xB0\xCC\xFB\xD3\xBD\x04\xA0\x85" - "\x4B\x22\x97\x07\xB6\x97\xE9\x95" - "\x0F\x88\x36\xA9\x44\x00\xC6\xE9" - "\x27\x53\x5C\x5B\x1F\xD3\xE2\xEE" - "\xD0\xCD\x63\x30\xA9\xC0\xDD\x49" - "\xFE\x16\xA4\x07\x0D\xE2\x5D\x97" - "\xDE\x89\xBA\x2E\xF3\xA9\x5E\xBE" - "\x03\x55\x0E\x02\x41\x4A\x45\x06" - "\xBE\xEA\x32\xF2\xDC\x91\x5C\x20" - "\x94\x02\x30\xD2\xFC\x29\xFA\x8E" - "\x34\xA0\x31\xB8\x34\xBA\xAE\x54" - "\xB5\x88\x1F\xDC\x43\xDC\x22\x9F" - "\xDC\xCE\xD3\xFA\xA4\xA8\xBC\x8A" - "\xC7\x5A\x43\x21\xA5\xB1\xDB\xC3" - "\x84\x3B\xB4\x9B\xB5\xA7\xF1\x0A" - "\xB6\x37\x21\x19\x55\xC2\xBD\x99" - "\x49\x24\xBB\x7C\xB3\x8E\xEF\xD2" - "\x3A\xCF\xA0\x31\x28\x0E\x25\xA2" - "\x11\xB4\x18\x17\x1A\x65\x92\x56" - "\xE8\xE0\x52\x9C\x61\x18\x2A\xB1" - "\x1A\x01\x22\x45\x17\x62\x52\x6C" - "\x91\x44\xCF\x98\xC7\xC0\x79\x26" - "\x32\x66\x6F\x23\x7F\x94\x36\x88" - "\x3C\xC9\xD0\xB7\x45\x30\x31\x86" - "\x3D\xC6\xA3\x98\x62\x84\x1A\x8B" - "\x16\x88\xC7\xA3\xE9\x4F\xE0\x86" - "\xA4\x93\xA8\x34\x5A\xCA\xDF\xCA" - "\x46\x38\xD2\xF4\xE0\x2D\x1E\xC9" - "\x7C\xEF\x53\xB7\x60\x72\x41\xBF" - "\x29\x00\x87\x02\xAF\x44\x4C\xB7" - "\x8C\xF5\x3F\x19\xF4\x80\x45\xA7" - "\x15\x5F\xDB\xE9\xB1\x83\xD2\xE6" - "\x1D\x18\x66\x44\x5B\x8F\x14\xEB", - .rlen = 496, - .also_non_np = 1, - .np = 2, - .tap = { 496 - 16, 16 }, + .result = "\x00", + .rlen = 0, + }, { + .key = "\x39\xbb\xa7\xbe\x59\x97\x9e\x73" + "\xa2\xbc\x6b\x98\xd7\x75\x7f\xe3" + "\xa4\x48\x93\x39\x26\x71\x4a\xc6" + "\xae\x8f\x11\x4c\xc2\x9c\x4a\xbb" + "\x85\x34\x66", + .klen = 35, + .iv = "\x42\xc8\x92\x0f\x36\x58\xe0\x6b", + .alen = 0, + .input = "\x48\x01\x5e\x02\x24\x04\x66\x47" + "\xa1\xea\x6f\xaf\xe8\xfc\xfb\xdd" + "\xa5\xa9\x87\x8d\x84\xee\x2e\x77" + "\xbb\x86\xb9\xf5\x5c\x6c\xff\xf6" + "\x72\xc3\x8e\xf7\x70\xb1\xb2\x07" + "\xbc\xa8\xa3\xbd\x83\x7c\x1d\x2a", + .ilen = 48, + .result = "\xdc\x56\xf2\x71\xb0\xb1\xa0\x6c" + "\xf0\x97\x3a\xfb\x6d\xe7\x32\x99" + "\x3e\xaf\x70\x5e\xb2\x4d\xea\x39" + "\x89\xd4\x75\x7a\x63\xb1\xda\x93", + .rlen = 32, + .novrfy = 1, + }, { + .key = "\x58\x5d\xa0\x96\x65\x1a\x04\xd7" + "\x96\xe5\xc5\x68\xaa\x95\x35\xe0" + "\x29\xa0\xba\x9e\x48\x78\xd1\xba" + "\x0d\x1a\x53\x3b\xb5\xe3\xf8\x8b" + "\xcf\x76\x3f", + .klen = 35, + .iv = "\xd9\x95\x75\x8f\x44\x89\x40\x7b", + .assoc = "\x8f\x86\x6c\x4d\x1d\xc5\x39\x88" + "\xc8\xf3\x5c\x52\x10\x63\x6f\x2b" + "\x8a\x2a\xc5\x6f\x30\x23\x58\x7b" + "\xfb\x36\x03\x11\xb4\xd9\xf2\xfe", + .alen = 32, + .input = "\x48\x58\xd6\xf3\xad\x63\x58\xbf" + "\xae\xc7\x5e\xae\x83\x8f\x7b\xe4" + "\x78\x5c\x4c\x67\x71\x89\x94\xbf" + "\x47\xf1\x63\x7e\x1c\x59\xbd\xc5" + "\x7f\x44\x0a\x0c\x01\x18\x07\x92" + "\xe1\xd3\x51\xce\x32\x6d\x0c\x5b", + .ilen = 48, + .result = "\xc2\x54\xc8\xde\x78\x87\x77\x40" + "\x49\x71\xe4\xb7\xe7\xcb\x76\x61" + "\x0a\x41\xb9\xe9\xc0\x76\x54\xab" + "\x04\x49\x3b\x19\x93\x57\x25\x5d", + .rlen = 32, }, }; -static struct cipher_testvec cast5_cbc_dec_tv_template[] = { - { /* Generated from TF test vectors */ - .key = "\x85\x62\x3F\x1C\xF9\xD6\x1C\xF9" - "\xD6\xB3\x90\x6D\x4A\x90\x6D\x4A", +/* + * ANSI X9.31 Continuous Pseudo-Random Number Generator (AES mode) + * test vectors, taken from Appendix B.2.9 and B.2.10: + * http://csrc.nist.gov/groups/STM/cavp/documents/rng/RNGVS.pdf + * Only AES-128 is supported at this time. + */ +#define ANSI_CPRNG_AES_TEST_VECTORS 6 + +static struct cprng_testvec ansi_cprng_aes_tv_template[] = { + { + .key = "\xf3\xb1\x66\x6d\x13\x60\x72\x42" + "\xed\x06\x1c\xab\xb8\xd4\x62\x02", .klen = 16, - .iv = "\xE2\x24\x89\xEE\x53\xB8\x1D\x5F", - .input = "\x05\x28\xCE\x61\x90\x80\xE1\x78" - "\xB9\x2A\x97\x7C\xB0\x83\xD8\x1A" - "\xDE\x58\x7F\xD7\xFD\x72\xB8\xFB" - "\xDA\xF0\x6E\x77\x14\x47\x82\xBA" - "\x29\x0E\x25\x6E\xB4\x39\xD9\x7F" - "\x05\xA7\xA7\x3A\xC1\x5D\x9E\x39" - "\xA7\xFB\x0D\x05\x00\xF3\x58\x67" - "\x60\xEC\x73\x77\x46\x85\x9B\x6A" - "\x08\x3E\xBE\x59\xFB\xE4\x96\x34" - "\xB4\x05\x49\x1A\x97\x43\xAD\xA0" - "\xA9\x1E\x6E\x74\xF1\x94\xEC\xA8" - "\xB5\x8A\x20\xEA\x89\x6B\x19\xAA" - "\xA7\xF1\x33\x67\x90\x23\x0D\xEE" - "\x81\xD5\x78\x4F\xD3\x63\xEA\x46" - "\xB5\xB2\x6E\xBB\xCA\x76\x06\x10" - "\x96\x2A\x0A\xBA\xF9\x41\x5A\x1D" - "\x36\x7C\x56\x14\x54\x83\xFA\xA1" - "\x27\xDD\xBA\x8A\x90\x29\xD6\xA6" - "\xFA\x48\x3E\x1E\x23\x6E\x98\xA8" - "\xA7\xD9\x67\x92\x5C\x13\xB4\x71" - "\xA8\xAA\x89\x4A\xA4\xB3\x49\x7C" - "\x7D\x7F\xCE\x6F\x29\x2E\x7E\x37" - "\xC8\x52\x60\xD9\xE7\xCA\x60\x98" - "\xED\xCD\xE8\x60\x83\xAD\x34\x4D" - "\x96\x4A\x99\x2B\xB7\x14\x75\x66" - "\x6C\x2C\x1A\xBA\x4B\xBB\x49\x56" - "\xE1\x86\xA2\x0E\xD0\xF0\x07\xD3" - "\x18\x38\x09\x9C\x0E\x8B\x86\x07" - "\x90\x12\x37\x49\x27\x98\x69\x18" - "\xB0\xCC\xFB\xD3\xBD\x04\xA0\x85" - "\x4B\x22\x97\x07\xB6\x97\xE9\x95" - "\x0F\x88\x36\xA9\x44\x00\xC6\xE9" - "\x27\x53\x5C\x5B\x1F\xD3\xE2\xEE" - "\xD0\xCD\x63\x30\xA9\xC0\xDD\x49" - "\xFE\x16\xA4\x07\x0D\xE2\x5D\x97" - "\xDE\x89\xBA\x2E\xF3\xA9\x5E\xBE" - "\x03\x55\x0E\x02\x41\x4A\x45\x06" - "\xBE\xEA\x32\xF2\xDC\x91\x5C\x20" - "\x94\x02\x30\xD2\xFC\x29\xFA\x8E" - "\x34\xA0\x31\xB8\x34\xBA\xAE\x54" - "\xB5\x88\x1F\xDC\x43\xDC\x22\x9F" - "\xDC\xCE\xD3\xFA\xA4\xA8\xBC\x8A" - "\xC7\x5A\x43\x21\xA5\xB1\xDB\xC3" - "\x84\x3B\xB4\x9B\xB5\xA7\xF1\x0A" - "\xB6\x37\x21\x19\x55\xC2\xBD\x99" - "\x49\x24\xBB\x7C\xB3\x8E\xEF\xD2" - "\x3A\xCF\xA0\x31\x28\x0E\x25\xA2" - "\x11\xB4\x18\x17\x1A\x65\x92\x56" - "\xE8\xE0\x52\x9C\x61\x18\x2A\xB1" - "\x1A\x01\x22\x45\x17\x62\x52\x6C" - "\x91\x44\xCF\x98\xC7\xC0\x79\x26" - "\x32\x66\x6F\x23\x7F\x94\x36\x88" - "\x3C\xC9\xD0\xB7\x45\x30\x31\x86" - "\x3D\xC6\xA3\x98\x62\x84\x1A\x8B" - "\x16\x88\xC7\xA3\xE9\x4F\xE0\x86" - "\xA4\x93\xA8\x34\x5A\xCA\xDF\xCA" - "\x46\x38\xD2\xF4\xE0\x2D\x1E\xC9" - "\x7C\xEF\x53\xB7\x60\x72\x41\xBF" - "\x29\x00\x87\x02\xAF\x44\x4C\xB7" - "\x8C\xF5\x3F\x19\xF4\x80\x45\xA7" - "\x15\x5F\xDB\xE9\xB1\x83\xD2\xE6" - "\x1D\x18\x66\x44\x5B\x8F\x14\xEB", - .ilen = 496, - .result = "\x56\xED\x84\x1B\x8F\x26\xBD\x31" - "\xC8\x5F\xF6\x6A\x01\x98\x0C\xA3" - "\x3A\xD1\x45\xDC\x73\x0A\x7E\x15" - "\xAC\x20\xB7\x4E\xE5\x59\xF0\x87" - "\x1E\x92\x29\xC0\x34\xCB\x62\xF9" - "\x6D\x04\x9B\x0F\xA6\x3D\xD4\x48" - "\xDF\x76\x0D\x81\x18\xAF\x23\xBA" - "\x51\xE8\x5C\xF3\x8A\x21\x95\x2C" - "\xC3\x37\xCE\x65\xFC\x70\x07\x9E" - "\x12\xA9\x40\xD7\x4B\xE2\x79\x10" - "\x84\x1B\xB2\x26\xBD\x54\xEB\x5F" - "\xF6\x8D\x01\x98\x2F\xC6\x3A\xD1" - "\x68\xFF\x73\x0A\xA1\x15\xAC\x43" - "\xDA\x4E\xE5\x7C\x13\x87\x1E\xB5" - "\x29\xC0\x57\xEE\x62\xF9\x90\x04" - "\x9B\x32\xC9\x3D\xD4\x6B\x02\x76" - "\x0D\xA4\x18\xAF\x46\xDD\x51\xE8" - "\x7F\x16\x8A\x21\xB8\x2C\xC3\x5A" - "\xF1\x65\xFC\x93\x07\x9E\x35\xCC" - "\x40\xD7\x6E\x05\x79\x10\xA7\x1B" - "\xB2\x49\xE0\x54\xEB\x82\x19\x8D" - "\x24\xBB\x2F\xC6\x5D\xF4\x68\xFF" - "\x96\x0A\xA1\x38\xCF\x43\xDA\x71" - "\x08\x7C\x13\xAA\x1E\xB5\x4C\xE3" - "\x57\xEE\x85\x1C\x90\x27\xBE\x32" - "\xC9\x60\xF7\x6B\x02\x99\x0D\xA4" - "\x3B\xD2\x46\xDD\x74\x0B\x7F\x16" - "\xAD\x21\xB8\x4F\xE6\x5A\xF1\x88" - "\x1F\x93\x2A\xC1\x35\xCC\x63\xFA" - "\x6E\x05\x9C\x10\xA7\x3E\xD5\x49" - "\xE0\x77\x0E\x82\x19\xB0\x24\xBB" - "\x52\xE9\x5D\xF4\x8B\x22\x96\x2D" - "\xC4\x38\xCF\x66\xFD\x71\x08\x9F" - "\x13\xAA\x41\xD8\x4C\xE3\x7A\x11" - "\x85\x1C\xB3\x27\xBE\x55\xEC\x60" - "\xF7\x8E\x02\x99\x30\xC7\x3B\xD2" - "\x69\x00\x74\x0B\xA2\x16\xAD\x44" - "\xDB\x4F\xE6\x7D\x14\x88\x1F\xB6" - "\x2A\xC1\x58\xEF\x63\xFA\x91\x05" - "\x9C\x33\xCA\x3E\xD5\x6C\x03\x77" - "\x0E\xA5\x19\xB0\x47\xDE\x52\xE9" - "\x80\x17\x8B\x22\xB9\x2D\xC4\x5B" - "\xF2\x66\xFD\x94\x08\x9F\x36\xCD" - "\x41\xD8\x6F\x06\x7A\x11\xA8\x1C" - "\xB3\x4A\xE1\x55\xEC\x83\x1A\x8E" - "\x25\xBC\x30\xC7\x5E\xF5\x69\x00" - "\x97\x0B\xA2\x39\xD0\x44\xDB\x72" - "\x09\x7D\x14\xAB\x1F\xB6\x4D\xE4" - "\x58\xEF\x86\x1D\x91\x28\xBF\x33" - "\xCA\x61\xF8\x6C\x03\x9A\x0E\xA5" - "\x3C\xD3\x47\xDE\x75\x0C\x80\x17" - "\xAE\x22\xB9\x50\xE7\x5B\xF2\x89" - "\x20\x94\x2B\xC2\x36\xCD\x64\xFB" - "\x6F\x06\x9D\x11\xA8\x3F\xD6\x4A" - "\xE1\x78\x0F\x83\x1A\xB1\x25\xBC" - "\x53\xEA\x5E\xF5\x8C\x00\x97\x2E" - "\xC5\x39\xD0\x67\xFE\x72\x09\xA0" - "\x14\xAB\x42\xD9\x4D\xE4\x7B\x12" - "\x86\x1D\xB4\x28\xBF\x56\xED\x61" - "\xF8\x8F\x03\x9A\x31\xC8\x3C\xD3" - "\x6A\x01\x75\x0C\xA3\x17\xAE\x45" - "\xDC\x50\xE7\x7E\x15\x89\x20\xB7", - .rlen = 496, - .also_non_np = 1, - .np = 2, - .tap = { 496 - 16, 16 }, + .dt = "\xe6\xb3\xbe\x78\x2a\x23\xfa\x62" + "\xd7\x1d\x4a\xfb\xb0\xe9\x22\xf9", + .dtlen = 16, + .v = "\x80\x00\x00\x00\x00\x00\x00\x00" + "\x00\x00\x00\x00\x00\x00\x00\x00", + .vlen = 16, + .result = "\x59\x53\x1e\xd1\x3b\xb0\xc0\x55" + "\x84\x79\x66\x85\xc1\x2f\x76\x41", + .rlen = 16, + .loops = 1, + }, { + .key = "\xf3\xb1\x66\x6d\x13\x60\x72\x42" + "\xed\x06\x1c\xab\xb8\xd4\x62\x02", + .klen = 16, + .dt = "\xe6\xb3\xbe\x78\x2a\x23\xfa\x62" + "\xd7\x1d\x4a\xfb\xb0\xe9\x22\xfa", + .dtlen = 16, + .v = "\xc0\x00\x00\x00\x00\x00\x00\x00" + "\x00\x00\x00\x00\x00\x00\x00\x00", + .vlen = 16, + .result = "\x7c\x22\x2c\xf4\xca\x8f\xa2\x4c" + "\x1c\x9c\xb6\x41\xa9\xf3\x22\x0d", + .rlen = 16, + .loops = 1, + }, { + .key = "\xf3\xb1\x66\x6d\x13\x60\x72\x42" + "\xed\x06\x1c\xab\xb8\xd4\x62\x02", + .klen = 16, + .dt = "\xe6\xb3\xbe\x78\x2a\x23\xfa\x62" + "\xd7\x1d\x4a\xfb\xb0\xe9\x22\xfb", + .dtlen = 16, + .v = "\xe0\x00\x00\x00\x00\x00\x00\x00" + "\x00\x00\x00\x00\x00\x00\x00\x00", + .vlen = 16, + .result = "\x8a\xaa\x00\x39\x66\x67\x5b\xe5" + "\x29\x14\x28\x81\xa9\x4d\x4e\xc7", + .rlen = 16, + .loops = 1, + }, { + .key = "\xf3\xb1\x66\x6d\x13\x60\x72\x42" + "\xed\x06\x1c\xab\xb8\xd4\x62\x02", + .klen = 16, + .dt = "\xe6\xb3\xbe\x78\x2a\x23\xfa\x62" + "\xd7\x1d\x4a\xfb\xb0\xe9\x22\xfc", + .dtlen = 16, + .v = "\xf0\x00\x00\x00\x00\x00\x00\x00" + "\x00\x00\x00\x00\x00\x00\x00\x00", + .vlen = 16, + .result = "\x88\xdd\xa4\x56\x30\x24\x23\xe5" + "\xf6\x9d\xa5\x7e\x7b\x95\xc7\x3a", + .rlen = 16, + .loops = 1, + }, { + .key = "\xf3\xb1\x66\x6d\x13\x60\x72\x42" + "\xed\x06\x1c\xab\xb8\xd4\x62\x02", + .klen = 16, + .dt = "\xe6\xb3\xbe\x78\x2a\x23\xfa\x62" + "\xd7\x1d\x4a\xfb\xb0\xe9\x22\xfd", + .dtlen = 16, + .v = "\xf8\x00\x00\x00\x00\x00\x00\x00" + "\x00\x00\x00\x00\x00\x00\x00\x00", + .vlen = 16, + .result = "\x05\x25\x92\x46\x61\x79\xd2\xcb" + "\x78\xc4\x0b\x14\x0a\x5a\x9a\xc8", + .rlen = 16, + .loops = 1, + }, { /* Monte Carlo Test */ + .key = "\x9f\x5b\x51\x20\x0b\xf3\x34\xb5" + "\xd8\x2b\xe8\xc3\x72\x55\xc8\x48", + .klen = 16, + .dt = "\x63\x76\xbb\xe5\x29\x02\xba\x3b" + "\x67\xc9\x25\xfa\x70\x1f\x11\xac", + .dtlen = 16, + .v = "\x57\x2c\x8e\x76\x87\x26\x47\x97" + "\x7e\x74\xfb\xdd\xc4\x95\x01\xd1", + .vlen = 16, + .result = "\x48\xe9\xbd\x0d\x06\xee\x18\xfb" + "\xe4\x57\x90\xd5\xc3\xfc\x9b\x73", + .rlen = 16, + .loops = 10000, }, }; -static struct cipher_testvec cast5_ctr_enc_tv_template[] = { - { /* Generated from TF test vectors */ - .key = "\x85\x62\x3F\x1C\xF9\xD6\x1C\xF9" - "\xD6\xB3\x90\x6D\x4A\x90\x6D\x4A", - .klen = 16, - .iv = "\xE2\x24\x89\xEE\x53\xB8\x1D\x5F", - .input = "\x56\xED\x84\x1B\x8F\x26\xBD\x31" - "\xC8\x5F\xF6\x6A\x01\x98\x0C\xA3" - "\x3A", - .ilen = 17, - .result = "\xFF\xC4\x2E\x82\x3D\xF8\xA8\x39" - "\x7C\x52\xC4\xD3\xBB\x62\xC6\xA8" - "\x0C", - .rlen = 17, - }, { /* Generated from TF test vectors */ - .key = "\x85\x62\x3F\x1C\xF9\xD6\x1C\xF9" - "\xD6\xB3\x90\x6D\x4A\x90\x6D\x4A", +/* Cast5 test vectors from RFC 2144 */ +#define CAST5_ENC_TEST_VECTORS 3 +#define CAST5_DEC_TEST_VECTORS 3 + +static struct cipher_testvec cast5_enc_tv_template[] = { + { + .key = "\x01\x23\x45\x67\x12\x34\x56\x78" + "\x23\x45\x67\x89\x34\x56\x78\x9a", .klen = 16, - .iv = "\xE2\x24\x89\xEE\x53\xB8\x1D\x5F", - .input = "\x56\xED\x84\x1B\x8F\x26\xBD\x31" - "\xC8\x5F\xF6\x6A\x01\x98\x0C\xA3" - "\x3A\xD1\x45\xDC\x73\x0A\x7E\x15" - "\xAC\x20\xB7\x4E\xE5\x59\xF0\x87" - "\x1E\x92\x29\xC0\x34\xCB\x62\xF9" - "\x6D\x04\x9B\x0F\xA6\x3D\xD4\x48" - "\xDF\x76\x0D\x81\x18\xAF\x23\xBA" - "\x51\xE8\x5C\xF3\x8A\x21\x95\x2C" - "\xC3\x37\xCE\x65\xFC\x70\x07\x9E" - "\x12\xA9\x40\xD7\x4B\xE2\x79\x10" - "\x84\x1B\xB2\x26\xBD\x54\xEB\x5F" - "\xF6\x8D\x01\x98\x2F\xC6\x3A\xD1" - "\x68\xFF\x73\x0A\xA1\x15\xAC\x43" - "\xDA\x4E\xE5\x7C\x13\x87\x1E\xB5" - "\x29\xC0\x57\xEE\x62\xF9\x90\x04" - "\x9B\x32\xC9\x3D\xD4\x6B\x02\x76" - "\x0D\xA4\x18\xAF\x46\xDD\x51\xE8" - "\x7F\x16\x8A\x21\xB8\x2C\xC3\x5A" - "\xF1\x65\xFC\x93\x07\x9E\x35\xCC" - "\x40\xD7\x6E\x05\x79\x10\xA7\x1B" - "\xB2\x49\xE0\x54\xEB\x82\x19\x8D" - "\x24\xBB\x2F\xC6\x5D\xF4\x68\xFF" - "\x96\x0A\xA1\x38\xCF\x43\xDA\x71" - "\x08\x7C\x13\xAA\x1E\xB5\x4C\xE3" - "\x57\xEE\x85\x1C\x90\x27\xBE\x32" - "\xC9\x60\xF7\x6B\x02\x99\x0D\xA4" - "\x3B\xD2\x46\xDD\x74\x0B\x7F\x16" - "\xAD\x21\xB8\x4F\xE6\x5A\xF1\x88" - "\x1F\x93\x2A\xC1\x35\xCC\x63\xFA" - "\x6E\x05\x9C\x10\xA7\x3E\xD5\x49" - "\xE0\x77\x0E\x82\x19\xB0\x24\xBB" - "\x52\xE9\x5D\xF4\x8B\x22\x96\x2D" - "\xC4\x38\xCF\x66\xFD\x71\x08\x9F" - "\x13\xAA\x41\xD8\x4C\xE3\x7A\x11" - "\x85\x1C\xB3\x27\xBE\x55\xEC\x60" - "\xF7\x8E\x02\x99\x30\xC7\x3B\xD2" - "\x69\x00\x74\x0B\xA2\x16\xAD\x44" - "\xDB\x4F\xE6\x7D\x14\x88\x1F\xB6" - "\x2A\xC1\x58\xEF\x63\xFA\x91\x05" - "\x9C\x33\xCA\x3E\xD5\x6C\x03\x77" - "\x0E\xA5\x19\xB0\x47\xDE\x52\xE9" - "\x80\x17\x8B\x22\xB9\x2D\xC4\x5B" - "\xF2\x66\xFD\x94\x08\x9F\x36\xCD" - "\x41\xD8\x6F\x06\x7A\x11\xA8\x1C" - "\xB3\x4A\xE1\x55\xEC\x83\x1A\x8E" - "\x25\xBC\x30\xC7\x5E\xF5\x69\x00" - "\x97\x0B\xA2\x39\xD0\x44\xDB\x72" - "\x09\x7D\x14\xAB\x1F\xB6\x4D\xE4" - "\x58\xEF\x86\x1D\x91\x28\xBF\x33" - "\xCA\x61\xF8\x6C\x03\x9A\x0E\xA5" - "\x3C\xD3\x47\xDE\x75\x0C\x80\x17" - "\xAE\x22\xB9\x50\xE7\x5B\xF2\x89" - "\x20\x94\x2B\xC2\x36\xCD\x64\xFB" - "\x6F\x06\x9D\x11\xA8\x3F\xD6\x4A" - "\xE1\x78\x0F\x83\x1A\xB1\x25\xBC" - "\x53\xEA\x5E\xF5\x8C\x00\x97\x2E" - "\xC5\x39\xD0\x67\xFE\x72\x09\xA0" - "\x14\xAB\x42\xD9\x4D\xE4\x7B\x12" - "\x86\x1D\xB4\x28\xBF\x56\xED\x61" - "\xF8\x8F\x03\x9A\x31\xC8\x3C\xD3" - "\x6A\x01\x75\x0C\xA3\x17\xAE\x45" - "\xDC\x50\xE7\x7E\x15\x89\x20\xB7", - .ilen = 496, - .result = "\xFF\xC4\x2E\x82\x3D\xF8\xA8\x39" - "\x7C\x52\xC4\xD3\xBB\x62\xC6\xA8" - "\x0C\x63\xA5\x55\xE3\xF8\x1C\x7F" - "\xDC\x59\xF9\xA0\x52\xAD\x83\xDF" - "\xD5\x3B\x53\x4A\xAA\x1F\x49\x44" - "\xE8\x20\xCC\xF8\x97\xE6\xE0\x3C" - "\x5A\xD2\x83\xEC\xEE\x25\x3F\xCF" - "\x0D\xC2\x79\x80\x99\x6E\xFF\x7B" - "\x64\xB0\x7B\x86\x29\x1D\x9F\x17" - "\x10\xA5\xA5\xEB\x16\x55\x9E\xE3" - "\x88\x18\x52\x56\x48\x58\xD1\x6B" - "\xE8\x74\x6E\x48\xB0\x2E\x69\x63" - "\x32\xAA\xAC\x26\x55\x45\x94\xDE" - "\x30\x26\x26\xE6\x08\x82\x2F\x5F" - "\xA7\x15\x94\x07\x75\x2D\xC6\x3A" - "\x1B\xA0\x39\xFB\xBA\xB9\x06\x56" - "\xF6\x9F\xF1\x2F\x9B\xF3\x89\x8B" - "\x08\xC8\x9D\x5E\x6B\x95\x09\xC7" - "\x98\xB7\x62\xA4\x1D\x25\xFA\xC5" - "\x62\xC8\x5D\x6B\xB4\x85\x88\x7F" - "\x3B\x29\xF9\xB4\x32\x62\x69\xBF" - "\x32\xB8\xEB\xFD\x0E\x26\xAA\xA3" - "\x44\x67\x90\x20\xAC\x41\xDF\x43" - "\xC6\xC7\x19\x9F\x2C\x28\x74\xEB" - "\x3E\x7F\x7A\x80\x5B\xE4\x08\x60" - "\xC7\xC9\x71\x34\x44\xCE\x05\xFD" - "\xA8\x91\xA8\x44\x5E\xD3\x89\x2C" - "\xAE\x59\x0F\x07\x88\x79\x53\x26" - "\xAF\xAC\xCB\x1D\x6F\x08\x25\x62" - "\xD0\x82\x65\x66\xE4\x2A\x29\x1C" - "\x9C\x64\x5F\x49\x9D\xF8\x62\xF9" - "\xED\xC4\x13\x52\x75\xDC\xE4\xF9" - "\x68\x0F\x8A\xCD\xA6\x8D\x75\xAA" - "\x49\xA1\x86\x86\x37\x5C\x6B\x3D" - "\x56\xE5\x6F\xBE\x27\xC0\x10\xF8" - "\x3C\x4D\x17\x35\x14\xDC\x1C\xA0" - "\x6E\xAE\xD1\x10\xDD\x83\x06\xC2" - "\x23\xD3\xC7\x27\x15\x04\x2C\x27" - "\xDD\x1F\x2E\x97\x09\x9C\x33\x7D" - "\xAC\x50\x1B\x2E\xC9\x52\x0C\x14" - "\x4B\x78\xC4\xDE\x07\x6A\x12\x02" - "\x6E\xD7\x4B\x91\xB9\x88\x4D\x02" - "\xC3\xB5\x04\xBC\xE0\x67\xCA\x18" - "\x22\xA1\xAE\x9A\x21\xEF\xB2\x06" - "\x35\xCD\xEC\x37\x70\x2D\xFC\x1E" - "\xA8\x31\xE7\xFC\xE5\x8E\x88\x66" - "\x16\xB5\xC8\x45\x21\x37\xBD\x24" - "\xA9\xD5\x36\x12\x9F\x6E\x67\x80" - "\x87\x54\xD5\xAF\x97\xE1\x15\xA7" - "\x11\xF0\x63\x7B\xE1\x44\x14\x1C" - "\x06\x32\x05\x8C\x6C\xDB\x9B\x36" - "\x6A\x6B\xAD\x3A\x27\x55\x20\x4C" - "\x76\x36\x43\xE8\x16\x60\xB5\xF3" - "\xDF\x5A\xC6\xA5\x69\x78\x59\x51" - "\x54\x68\x65\x06\x84\xDE\x3D\xAE" - "\x38\x91\xBD\xCC\xA2\x8A\xEC\xE6" - "\x9E\x83\xAE\x1E\x8E\x34\x5D\xDE" - "\x91\xCE\x8F\xED\x40\xF7\xC8\x8B" - "\x9A\x13\x4C\xAD\x89\x97\x9E\xD1" - "\x91\x01\xD7\x21\x23\x28\x1E\xCC" - "\x8C\x98\xDB\xDE\xFC\x72\x94\xAA" - "\xC0\x0D\x96\xAA\x23\xF8\xFE\x13", - .rlen = 496, - .also_non_np = 1, - .np = 2, - .tap = { 496 - 16, 16 }, + .input = "\x01\x23\x45\x67\x89\xab\xcd\xef", + .ilen = 8, + .result = "\x23\x8b\x4f\xe5\x84\x7e\x44\xb2", + .rlen = 8, + }, { + .key = "\x01\x23\x45\x67\x12\x34\x56\x78" + "\x23\x45", + .klen = 10, + .input = "\x01\x23\x45\x67\x89\xab\xcd\xef", + .ilen = 8, + .result = "\xeb\x6a\x71\x1a\x2c\x02\x27\x1b", + .rlen = 8, + }, { + .key = "\x01\x23\x45\x67\x12", + .klen = 5, + .input = "\x01\x23\x45\x67\x89\xab\xcd\xef", + .ilen = 8, + .result = "\x7a\xc8\x16\xd1\x6e\x9b\x30\x2e", + .rlen = 8, }, }; -static struct cipher_testvec cast5_ctr_dec_tv_template[] = { - { /* Generated from TF test vectors */ - .key = "\x85\x62\x3F\x1C\xF9\xD6\x1C\xF9" - "\xD6\xB3\x90\x6D\x4A\x90\x6D\x4A", - .klen = 16, - .iv = "\xE2\x24\x89\xEE\x53\xB8\x1D\x5F", - .input = "\xFF\xC4\x2E\x82\x3D\xF8\xA8\x39" - "\x7C\x52\xC4\xD3\xBB\x62\xC6\xA8" - "\x0C", - .ilen = 17, - .result = "\x56\xED\x84\x1B\x8F\x26\xBD\x31" - "\xC8\x5F\xF6\x6A\x01\x98\x0C\xA3" - "\x3A", - .rlen = 17, - }, { /* Generated from TF test vectors */ - .key = "\x85\x62\x3F\x1C\xF9\xD6\x1C\xF9" - "\xD6\xB3\x90\x6D\x4A\x90\x6D\x4A", +static struct cipher_testvec cast5_dec_tv_template[] = { + { + .key = "\x01\x23\x45\x67\x12\x34\x56\x78" + "\x23\x45\x67\x89\x34\x56\x78\x9a", .klen = 16, - .iv = "\xE2\x24\x89\xEE\x53\xB8\x1D\x5F", - .input = "\xFF\xC4\x2E\x82\x3D\xF8\xA8\x39" - "\x7C\x52\xC4\xD3\xBB\x62\xC6\xA8" - "\x0C\x63\xA5\x55\xE3\xF8\x1C\x7F" - "\xDC\x59\xF9\xA0\x52\xAD\x83\xDF" - "\xD5\x3B\x53\x4A\xAA\x1F\x49\x44" - "\xE8\x20\xCC\xF8\x97\xE6\xE0\x3C" - "\x5A\xD2\x83\xEC\xEE\x25\x3F\xCF" - "\x0D\xC2\x79\x80\x99\x6E\xFF\x7B" - "\x64\xB0\x7B\x86\x29\x1D\x9F\x17" - "\x10\xA5\xA5\xEB\x16\x55\x9E\xE3" - "\x88\x18\x52\x56\x48\x58\xD1\x6B" - "\xE8\x74\x6E\x48\xB0\x2E\x69\x63" - "\x32\xAA\xAC\x26\x55\x45\x94\xDE" - "\x30\x26\x26\xE6\x08\x82\x2F\x5F" - "\xA7\x15\x94\x07\x75\x2D\xC6\x3A" - "\x1B\xA0\x39\xFB\xBA\xB9\x06\x56" - "\xF6\x9F\xF1\x2F\x9B\xF3\x89\x8B" - "\x08\xC8\x9D\x5E\x6B\x95\x09\xC7" - "\x98\xB7\x62\xA4\x1D\x25\xFA\xC5" - "\x62\xC8\x5D\x6B\xB4\x85\x88\x7F" - "\x3B\x29\xF9\xB4\x32\x62\x69\xBF" - "\x32\xB8\xEB\xFD\x0E\x26\xAA\xA3" - "\x44\x67\x90\x20\xAC\x41\xDF\x43" - "\xC6\xC7\x19\x9F\x2C\x28\x74\xEB" - "\x3E\x7F\x7A\x80\x5B\xE4\x08\x60" - "\xC7\xC9\x71\x34\x44\xCE\x05\xFD" - "\xA8\x91\xA8\x44\x5E\xD3\x89\x2C" - "\xAE\x59\x0F\x07\x88\x79\x53\x26" - "\xAF\xAC\xCB\x1D\x6F\x08\x25\x62" - "\xD0\x82\x65\x66\xE4\x2A\x29\x1C" - "\x9C\x64\x5F\x49\x9D\xF8\x62\xF9" - "\xED\xC4\x13\x52\x75\xDC\xE4\xF9" - "\x68\x0F\x8A\xCD\xA6\x8D\x75\xAA" - "\x49\xA1\x86\x86\x37\x5C\x6B\x3D" - "\x56\xE5\x6F\xBE\x27\xC0\x10\xF8" - "\x3C\x4D\x17\x35\x14\xDC\x1C\xA0" - "\x6E\xAE\xD1\x10\xDD\x83\x06\xC2" - "\x23\xD3\xC7\x27\x15\x04\x2C\x27" - "\xDD\x1F\x2E\x97\x09\x9C\x33\x7D" - "\xAC\x50\x1B\x2E\xC9\x52\x0C\x14" - "\x4B\x78\xC4\xDE\x07\x6A\x12\x02" - "\x6E\xD7\x4B\x91\xB9\x88\x4D\x02" - "\xC3\xB5\x04\xBC\xE0\x67\xCA\x18" - "\x22\xA1\xAE\x9A\x21\xEF\xB2\x06" - "\x35\xCD\xEC\x37\x70\x2D\xFC\x1E" - "\xA8\x31\xE7\xFC\xE5\x8E\x88\x66" - "\x16\xB5\xC8\x45\x21\x37\xBD\x24" - "\xA9\xD5\x36\x12\x9F\x6E\x67\x80" - "\x87\x54\xD5\xAF\x97\xE1\x15\xA7" - "\x11\xF0\x63\x7B\xE1\x44\x14\x1C" - "\x06\x32\x05\x8C\x6C\xDB\x9B\x36" - "\x6A\x6B\xAD\x3A\x27\x55\x20\x4C" - "\x76\x36\x43\xE8\x16\x60\xB5\xF3" - "\xDF\x5A\xC6\xA5\x69\x78\x59\x51" - "\x54\x68\x65\x06\x84\xDE\x3D\xAE" - "\x38\x91\xBD\xCC\xA2\x8A\xEC\xE6" - "\x9E\x83\xAE\x1E\x8E\x34\x5D\xDE" - "\x91\xCE\x8F\xED\x40\xF7\xC8\x8B" - "\x9A\x13\x4C\xAD\x89\x97\x9E\xD1" - "\x91\x01\xD7\x21\x23\x28\x1E\xCC" - "\x8C\x98\xDB\xDE\xFC\x72\x94\xAA" - "\xC0\x0D\x96\xAA\x23\xF8\xFE\x13", - .ilen = 496, - .result = "\x56\xED\x84\x1B\x8F\x26\xBD\x31" - "\xC8\x5F\xF6\x6A\x01\x98\x0C\xA3" - "\x3A\xD1\x45\xDC\x73\x0A\x7E\x15" - "\xAC\x20\xB7\x4E\xE5\x59\xF0\x87" - "\x1E\x92\x29\xC0\x34\xCB\x62\xF9" - "\x6D\x04\x9B\x0F\xA6\x3D\xD4\x48" - "\xDF\x76\x0D\x81\x18\xAF\x23\xBA" - "\x51\xE8\x5C\xF3\x8A\x21\x95\x2C" - "\xC3\x37\xCE\x65\xFC\x70\x07\x9E" - "\x12\xA9\x40\xD7\x4B\xE2\x79\x10" - "\x84\x1B\xB2\x26\xBD\x54\xEB\x5F" - "\xF6\x8D\x01\x98\x2F\xC6\x3A\xD1" - "\x68\xFF\x73\x0A\xA1\x15\xAC\x43" - "\xDA\x4E\xE5\x7C\x13\x87\x1E\xB5" - "\x29\xC0\x57\xEE\x62\xF9\x90\x04" - "\x9B\x32\xC9\x3D\xD4\x6B\x02\x76" - "\x0D\xA4\x18\xAF\x46\xDD\x51\xE8" - "\x7F\x16\x8A\x21\xB8\x2C\xC3\x5A" - "\xF1\x65\xFC\x93\x07\x9E\x35\xCC" - "\x40\xD7\x6E\x05\x79\x10\xA7\x1B" - "\xB2\x49\xE0\x54\xEB\x82\x19\x8D" - "\x24\xBB\x2F\xC6\x5D\xF4\x68\xFF" - "\x96\x0A\xA1\x38\xCF\x43\xDA\x71" - "\x08\x7C\x13\xAA\x1E\xB5\x4C\xE3" - "\x57\xEE\x85\x1C\x90\x27\xBE\x32" - "\xC9\x60\xF7\x6B\x02\x99\x0D\xA4" - "\x3B\xD2\x46\xDD\x74\x0B\x7F\x16" - "\xAD\x21\xB8\x4F\xE6\x5A\xF1\x88" - "\x1F\x93\x2A\xC1\x35\xCC\x63\xFA" - "\x6E\x05\x9C\x10\xA7\x3E\xD5\x49" - "\xE0\x77\x0E\x82\x19\xB0\x24\xBB" - "\x52\xE9\x5D\xF4\x8B\x22\x96\x2D" - "\xC4\x38\xCF\x66\xFD\x71\x08\x9F" - "\x13\xAA\x41\xD8\x4C\xE3\x7A\x11" - "\x85\x1C\xB3\x27\xBE\x55\xEC\x60" - "\xF7\x8E\x02\x99\x30\xC7\x3B\xD2" - "\x69\x00\x74\x0B\xA2\x16\xAD\x44" - "\xDB\x4F\xE6\x7D\x14\x88\x1F\xB6" - "\x2A\xC1\x58\xEF\x63\xFA\x91\x05" - "\x9C\x33\xCA\x3E\xD5\x6C\x03\x77" - "\x0E\xA5\x19\xB0\x47\xDE\x52\xE9" - "\x80\x17\x8B\x22\xB9\x2D\xC4\x5B" - "\xF2\x66\xFD\x94\x08\x9F\x36\xCD" - "\x41\xD8\x6F\x06\x7A\x11\xA8\x1C" - "\xB3\x4A\xE1\x55\xEC\x83\x1A\x8E" - "\x25\xBC\x30\xC7\x5E\xF5\x69\x00" - "\x97\x0B\xA2\x39\xD0\x44\xDB\x72" - "\x09\x7D\x14\xAB\x1F\xB6\x4D\xE4" - "\x58\xEF\x86\x1D\x91\x28\xBF\x33" - "\xCA\x61\xF8\x6C\x03\x9A\x0E\xA5" - "\x3C\xD3\x47\xDE\x75\x0C\x80\x17" - "\xAE\x22\xB9\x50\xE7\x5B\xF2\x89" - "\x20\x94\x2B\xC2\x36\xCD\x64\xFB" - "\x6F\x06\x9D\x11\xA8\x3F\xD6\x4A" - "\xE1\x78\x0F\x83\x1A\xB1\x25\xBC" - "\x53\xEA\x5E\xF5\x8C\x00\x97\x2E" - "\xC5\x39\xD0\x67\xFE\x72\x09\xA0" - "\x14\xAB\x42\xD9\x4D\xE4\x7B\x12" - "\x86\x1D\xB4\x28\xBF\x56\xED\x61" - "\xF8\x8F\x03\x9A\x31\xC8\x3C\xD3" - "\x6A\x01\x75\x0C\xA3\x17\xAE\x45" - "\xDC\x50\xE7\x7E\x15\x89\x20\xB7", - .rlen = 496, - .also_non_np = 1, - .np = 2, - .tap = { 496 - 16, 16 }, + .input = "\x23\x8b\x4f\xe5\x84\x7e\x44\xb2", + .ilen = 8, + .result = "\x01\x23\x45\x67\x89\xab\xcd\xef", + .rlen = 8, + }, { + .key = "\x01\x23\x45\x67\x12\x34\x56\x78" + "\x23\x45", + .klen = 10, + .input = "\xeb\x6a\x71\x1a\x2c\x02\x27\x1b", + .ilen = 8, + .result = "\x01\x23\x45\x67\x89\xab\xcd\xef", + .rlen = 8, + }, { + .key = "\x01\x23\x45\x67\x12", + .klen = 5, + .input = "\x7a\xc8\x16\xd1\x6e\x9b\x30\x2e", + .ilen = 8, + .result = "\x01\x23\x45\x67\x89\xab\xcd\xef", + .rlen = 8, }, }; @@ -16312,9 +13096,6 @@ static struct cipher_testvec camellia_enc_tv_template[] = { "\x0D\xD0\xFD\xC4\x65\xA5\x69\xB9" "\xF1\xF6\xB1\xA5\xB2\x75\x4F\x8A", .rlen = 48, - .also_non_np = 1, - .np = 2, - .tap = { 48 - 16, 16 }, }, }; @@ -16373,9 +13154,6 @@ static struct cipher_testvec camellia_dec_tv_template[] = { "\x1E\x92\x29\xC0\x34\xCB\x62\xF9" "\x6D\x04\x9B\x0F\xA6\x3D\xD4\x48", .rlen = 48, - .also_non_np = 1, - .np = 2, - .tap = { 48 - 16, 16 }, }, }; @@ -16430,9 +13208,6 @@ static struct cipher_testvec camellia_cbc_enc_tv_template[] = { "\xB9\xF9\xC2\x27\x6A\xB6\x31\x27" "\xA6\xAD\xEF\xE5\x5D\xE4\x02\x01", .rlen = 48, - .also_non_np = 1, - .np = 2, - .tap = { 48 - 16, 16 }, }, }; @@ -16487,9 +13262,6 @@ static struct cipher_testvec camellia_cbc_dec_tv_template[] = { "\x1E\x92\x29\xC0\x34\xCB\x62\xF9" "\x6D\x04\x9B\x0F\xA6\x3D\xD4\x48", .rlen = 48, - .also_non_np = 1, - .np = 2, - .tap = { 48 - 16, 16 }, }, }; @@ -16541,143 +13313,6 @@ static struct cipher_testvec camellia_ctr_enc_tv_template[] = { "\x60\xFC\xE8\x94\xE8\xB5\x09\x2C" "\x1E\x43\xEF", .rlen = 51, - .also_non_np = 1, - .np = 2, - .tap = { 51 - 16, 16 }, - }, { /* Generated with Crypto++ */ - .key = "\x85\x62\x3F\x1C\xF9\xD6\x1C\xF9" - "\xD6\xB3\x90\x6D\x4A\x90\x6D\x4A" - "\x27\x04\xE1\x27\x04\xE1\xBE\x9B" - "\x78\xBE\x9B\x78\x55\x32\x0F\x55", - .klen = 32, - .iv = "\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF" - "\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFD", - .input = "\x56\xED\x84\x1B\x8F\x26\xBD\x31" - "\xC8\x5F\xF6\x6A\x01\x98\x0C\xA3" - "\x3A\xD1\x45\xDC\x73\x0A\x7E\x15" - "\xAC\x20\xB7\x4E\xE5\x59\xF0\x87" - "\x1E\x92\x29\xC0\x34\xCB\x62\xF9" - "\x6D\x04\x9B\x0F\xA6\x3D\xD4\x48" - "\xDF\x76\x0D\x81\x18\xAF\x23\xBA" - "\x51\xE8\x5C\xF3\x8A\x21\x95\x2C" - "\xC3\x37\xCE\x65\xFC\x70\x07\x9E" - "\x12\xA9\x40\xD7\x4B\xE2\x79\x10" - "\x84\x1B\xB2\x26\xBD\x54\xEB\x5F" - "\xF6\x8D\x01\x98\x2F\xC6\x3A\xD1" - "\x68\xFF\x73\x0A\xA1\x15\xAC\x43" - "\xDA\x4E\xE5\x7C\x13\x87\x1E\xB5" - "\x29\xC0\x57\xEE\x62\xF9\x90\x04" - "\x9B\x32\xC9\x3D\xD4\x6B\x02\x76" - "\x0D\xA4\x18\xAF\x46\xDD\x51\xE8" - "\x7F\x16\x8A\x21\xB8\x2C\xC3\x5A" - "\xF1\x65\xFC\x93\x07\x9E\x35\xCC" - "\x40\xD7\x6E\x05\x79\x10\xA7\x1B" - "\xB2\x49\xE0\x54\xEB\x82\x19\x8D" - "\x24\xBB\x2F\xC6\x5D\xF4\x68\xFF" - "\x96\x0A\xA1\x38\xCF\x43\xDA\x71" - "\x08\x7C\x13\xAA\x1E\xB5\x4C\xE3" - "\x57\xEE\x85\x1C\x90\x27\xBE\x32" - "\xC9\x60\xF7\x6B\x02\x99\x0D\xA4" - "\x3B\xD2\x46\xDD\x74\x0B\x7F\x16" - "\xAD\x21\xB8\x4F\xE6\x5A\xF1\x88" - "\x1F\x93\x2A\xC1\x35\xCC\x63\xFA" - "\x6E\x05\x9C\x10\xA7\x3E\xD5\x49" - "\xE0\x77\x0E\x82\x19\xB0\x24\xBB" - "\x52\xE9\x5D\xF4\x8B\x22\x96\x2D" - "\xC4\x38\xCF\x66\xFD\x71\x08\x9F" - "\x13\xAA\x41\xD8\x4C\xE3\x7A\x11" - "\x85\x1C\xB3\x27\xBE\x55\xEC\x60" - "\xF7\x8E\x02\x99\x30\xC7\x3B\xD2" - "\x69\x00\x74\x0B\xA2\x16\xAD\x44" - "\xDB\x4F\xE6\x7D\x14\x88\x1F\xB6" - "\x2A\xC1\x58\xEF\x63\xFA\x91\x05" - "\x9C\x33\xCA\x3E\xD5\x6C\x03\x77" - "\x0E\xA5\x19\xB0\x47\xDE\x52\xE9" - "\x80\x17\x8B\x22\xB9\x2D\xC4\x5B" - "\xF2\x66\xFD\x94\x08\x9F\x36\xCD" - "\x41\xD8\x6F\x06\x7A\x11\xA8\x1C" - "\xB3\x4A\xE1\x55\xEC\x83\x1A\x8E" - "\x25\xBC\x30\xC7\x5E\xF5\x69\x00" - "\x97\x0B\xA2\x39\xD0\x44\xDB\x72" - "\x09\x7D\x14\xAB\x1F\xB6\x4D\xE4" - "\x58\xEF\x86\x1D\x91\x28\xBF\x33" - "\xCA\x61\xF8\x6C\x03\x9A\x0E\xA5" - "\x3C\xD3\x47\xDE\x75\x0C\x80\x17" - "\xAE\x22\xB9\x50\xE7\x5B\xF2\x89" - "\x20\x94\x2B\xC2\x36\xCD\x64\xFB" - "\x6F\x06\x9D\x11\xA8\x3F\xD6\x4A" - "\xE1\x78\x0F\x83\x1A\xB1\x25\xBC" - "\x53\xEA\x5E\xF5\x8C\x00\x97\x2E" - "\xC5\x39\xD0\x67\xFE\x72\x09\xA0" - "\x14\xAB\x42\xD9\x4D\xE4\x7B\x12" - "\x86\x1D\xB4\x28\xBF\x56\xED\x61" - "\xF8\x8F\x03\x9A\x31\xC8\x3C\xD3" - "\x6A\x01\x75\x0C\xA3\x17\xAE\x45" - "\xDC\x50\xE7\x7E\x15\x89\x20\xB7", - .ilen = 496, - .result = "\x85\x79\x6C\x8B\x2B\x6D\x14\xF9" - "\xA6\x83\xB6\x80\x5B\x3A\xF3\x7E" - "\x30\x29\xEB\x1F\xDC\x19\x5F\xEB" - "\xF7\xC4\x27\x04\x51\x87\xD7\x6F" - "\xB8\x4E\x07\xFB\xAC\x3B\x08\xB4" - "\x4D\xCB\xE8\xE1\x71\x7D\x4F\x48" - "\xCD\x81\x64\xA5\xC4\x07\x1A\x9A" - "\x4B\x62\x90\x0E\xC8\xB3\x2B\x6B" - "\x8F\x9C\x6E\x72\x4B\xBA\xEF\x07" - "\x2C\x56\x07\x5E\x37\x30\x60\xA9" - "\xE3\xEF\xD6\x69\xE1\xA1\x77\x64" - "\x93\x75\x7A\xB7\x7A\x3B\xE9\x43" - "\x23\x35\x95\x91\x80\x8A\xC7\xCF" - "\xC3\xD5\xBF\xE7\xFE\x4C\x06\x6B" - "\x05\x19\x48\xE2\x62\xBA\x4F\xF2" - "\xFB\xEE\xE4\xCB\x79\x9D\xA3\x10" - "\x1D\x29\x8C\x1D\x7A\x88\x5A\xDD" - "\x4E\xB6\x18\xAA\xCD\xE6\x33\x96" - "\xD9\x0F\x90\x5A\x78\x76\x4D\x77" - "\x3C\x20\x89\x3B\xA3\xF9\x07\xFD" - "\xE4\xE8\x20\x2D\x15\x0A\x63\x49" - "\xF5\x4F\x89\xD8\xDE\xA1\x28\x78" - "\x28\x07\x09\x1B\x03\x94\x1D\x4B" - "\x82\x28\x1E\x1D\x95\xBA\xAC\x85" - "\x71\x6E\x3C\x18\x4B\x77\x74\x79" - "\xBF\x67\x0A\x53\x3C\x94\xD9\x60" - "\xE9\x6D\x40\x34\xA0\x2A\x53\x5D" - "\x27\xD5\x47\xF9\xC3\x4B\x27\x29" - "\xE4\x76\x9C\x3F\xA7\x1C\x87\xFC" - "\x6E\x0F\xCF\x9B\x60\xF0\xF0\x8B" - "\x70\x1C\x84\x81\x72\x4D\xB4\x98" - "\x23\x62\xE7\x6A\x2B\xFC\xA5\xB2" - "\xFF\xF5\x71\x07\xCD\x90\x23\x13" - "\x19\xD7\x79\x36\x6C\x9D\x55\x8B" - "\x93\x78\x86\x05\x69\x46\xD0\xC5" - "\x39\x09\xEB\x79\xEF\xFA\x9F\xAE" - "\xF3\xD5\x44\xC3\xFD\x86\xD2\x7C" - "\x83\x4B\xD8\x75\x9C\x18\x04\x7B" - "\x73\xAD\x72\xA4\xF6\xAB\xCF\x4B" - "\xCC\x01\x45\x90\xA6\x43\x05\x0C" - "\x6C\x4F\x62\x77\x57\x97\x9F\xEE" - "\x75\xA7\x3C\x38\xD1\x0F\x3D\x0E" - "\x2C\x43\x98\xFB\x13\x65\x73\xE4" - "\x3C\x1E\xD6\x90\x08\xF7\xE0\x99" - "\x3B\xF1\x9D\x6C\x48\xA9\x0E\x32" - "\x17\xC2\xCC\x20\xA1\x19\x26\xAA" - "\xE0\x75\x2F\xFB\x54\x66\x0A\xDF" - "\xB5\xF2\x1F\xC1\x34\x3C\x30\x56" - "\xE8\xDC\xF7\x92\x6B\xBF\x17\x24" - "\xEC\x94\xB5\x3B\xD6\xCE\xA2\x54" - "\x10\x7F\x50\xDE\x69\x77\xD5\x37" - "\xFE\x9C\x10\x83\xC5\xEB\xC9\x53" - "\xB7\xF3\xC4\x20\xAF\x0A\x7E\x57" - "\x3A\xE6\x75\xFE\x89\x00\x6E\x48" - "\xFB\x99\x17\x2C\xF6\x64\x40\x95" - "\x5E\xDC\x7A\xA6\x70\xC7\xF4\xDD" - "\x52\x05\x24\x34\xF9\x0E\xC8\x64" - "\x6D\xE2\xD8\x80\x53\x31\x4C\xFE" - "\xB4\x3A\x5F\x19\xCF\x42\x1B\x22" - "\x0B\x2D\x7B\xF1\xC5\x43\xF7\x5E" - "\x12\xA8\x01\x64\x16\x0B\x26\x5A" - "\x0C\x95\x0F\x40\xC5\x5A\x06\x7C", - .rlen = 496, }, }; @@ -16729,144 +13364,8 @@ static struct cipher_testvec camellia_ctr_dec_tv_template[] = { "\x6D\x04\x9B\x0F\xA6\x3D\xD4\x48" "\xDF\x76\x0D", .rlen = 51, - .also_non_np = 1, - .np = 2, - .tap = { 51 - 16, 16 }, - }, { /* Generated with Crypto++ */ - .key = "\x85\x62\x3F\x1C\xF9\xD6\x1C\xF9" - "\xD6\xB3\x90\x6D\x4A\x90\x6D\x4A" - "\x27\x04\xE1\x27\x04\xE1\xBE\x9B" - "\x78\xBE\x9B\x78\x55\x32\x0F\x55", - .klen = 32, - .iv = "\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF" - "\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFD", - .input = "\x85\x79\x6C\x8B\x2B\x6D\x14\xF9" - "\xA6\x83\xB6\x80\x5B\x3A\xF3\x7E" - "\x30\x29\xEB\x1F\xDC\x19\x5F\xEB" - "\xF7\xC4\x27\x04\x51\x87\xD7\x6F" - "\xB8\x4E\x07\xFB\xAC\x3B\x08\xB4" - "\x4D\xCB\xE8\xE1\x71\x7D\x4F\x48" - "\xCD\x81\x64\xA5\xC4\x07\x1A\x9A" - "\x4B\x62\x90\x0E\xC8\xB3\x2B\x6B" - "\x8F\x9C\x6E\x72\x4B\xBA\xEF\x07" - "\x2C\x56\x07\x5E\x37\x30\x60\xA9" - "\xE3\xEF\xD6\x69\xE1\xA1\x77\x64" - "\x93\x75\x7A\xB7\x7A\x3B\xE9\x43" - "\x23\x35\x95\x91\x80\x8A\xC7\xCF" - "\xC3\xD5\xBF\xE7\xFE\x4C\x06\x6B" - "\x05\x19\x48\xE2\x62\xBA\x4F\xF2" - "\xFB\xEE\xE4\xCB\x79\x9D\xA3\x10" - "\x1D\x29\x8C\x1D\x7A\x88\x5A\xDD" - "\x4E\xB6\x18\xAA\xCD\xE6\x33\x96" - "\xD9\x0F\x90\x5A\x78\x76\x4D\x77" - "\x3C\x20\x89\x3B\xA3\xF9\x07\xFD" - "\xE4\xE8\x20\x2D\x15\x0A\x63\x49" - "\xF5\x4F\x89\xD8\xDE\xA1\x28\x78" - "\x28\x07\x09\x1B\x03\x94\x1D\x4B" - "\x82\x28\x1E\x1D\x95\xBA\xAC\x85" - "\x71\x6E\x3C\x18\x4B\x77\x74\x79" - "\xBF\x67\x0A\x53\x3C\x94\xD9\x60" - "\xE9\x6D\x40\x34\xA0\x2A\x53\x5D" - "\x27\xD5\x47\xF9\xC3\x4B\x27\x29" - "\xE4\x76\x9C\x3F\xA7\x1C\x87\xFC" - "\x6E\x0F\xCF\x9B\x60\xF0\xF0\x8B" - "\x70\x1C\x84\x81\x72\x4D\xB4\x98" - "\x23\x62\xE7\x6A\x2B\xFC\xA5\xB2" - "\xFF\xF5\x71\x07\xCD\x90\x23\x13" - "\x19\xD7\x79\x36\x6C\x9D\x55\x8B" - "\x93\x78\x86\x05\x69\x46\xD0\xC5" - "\x39\x09\xEB\x79\xEF\xFA\x9F\xAE" - "\xF3\xD5\x44\xC3\xFD\x86\xD2\x7C" - "\x83\x4B\xD8\x75\x9C\x18\x04\x7B" - "\x73\xAD\x72\xA4\xF6\xAB\xCF\x4B" - "\xCC\x01\x45\x90\xA6\x43\x05\x0C" - "\x6C\x4F\x62\x77\x57\x97\x9F\xEE" - "\x75\xA7\x3C\x38\xD1\x0F\x3D\x0E" - "\x2C\x43\x98\xFB\x13\x65\x73\xE4" - "\x3C\x1E\xD6\x90\x08\xF7\xE0\x99" - "\x3B\xF1\x9D\x6C\x48\xA9\x0E\x32" - "\x17\xC2\xCC\x20\xA1\x19\x26\xAA" - "\xE0\x75\x2F\xFB\x54\x66\x0A\xDF" - "\xB5\xF2\x1F\xC1\x34\x3C\x30\x56" - "\xE8\xDC\xF7\x92\x6B\xBF\x17\x24" - "\xEC\x94\xB5\x3B\xD6\xCE\xA2\x54" - "\x10\x7F\x50\xDE\x69\x77\xD5\x37" - "\xFE\x9C\x10\x83\xC5\xEB\xC9\x53" - "\xB7\xF3\xC4\x20\xAF\x0A\x7E\x57" - "\x3A\xE6\x75\xFE\x89\x00\x6E\x48" - "\xFB\x99\x17\x2C\xF6\x64\x40\x95" - "\x5E\xDC\x7A\xA6\x70\xC7\xF4\xDD" - "\x52\x05\x24\x34\xF9\x0E\xC8\x64" - "\x6D\xE2\xD8\x80\x53\x31\x4C\xFE" - "\xB4\x3A\x5F\x19\xCF\x42\x1B\x22" - "\x0B\x2D\x7B\xF1\xC5\x43\xF7\x5E" - "\x12\xA8\x01\x64\x16\x0B\x26\x5A" - "\x0C\x95\x0F\x40\xC5\x5A\x06\x7C", - .ilen = 496, - .result = "\x56\xED\x84\x1B\x8F\x26\xBD\x31" - "\xC8\x5F\xF6\x6A\x01\x98\x0C\xA3" - "\x3A\xD1\x45\xDC\x73\x0A\x7E\x15" - "\xAC\x20\xB7\x4E\xE5\x59\xF0\x87" - "\x1E\x92\x29\xC0\x34\xCB\x62\xF9" - "\x6D\x04\x9B\x0F\xA6\x3D\xD4\x48" - "\xDF\x76\x0D\x81\x18\xAF\x23\xBA" - "\x51\xE8\x5C\xF3\x8A\x21\x95\x2C" - "\xC3\x37\xCE\x65\xFC\x70\x07\x9E" - "\x12\xA9\x40\xD7\x4B\xE2\x79\x10" - "\x84\x1B\xB2\x26\xBD\x54\xEB\x5F" - "\xF6\x8D\x01\x98\x2F\xC6\x3A\xD1" - "\x68\xFF\x73\x0A\xA1\x15\xAC\x43" - "\xDA\x4E\xE5\x7C\x13\x87\x1E\xB5" - "\x29\xC0\x57\xEE\x62\xF9\x90\x04" - "\x9B\x32\xC9\x3D\xD4\x6B\x02\x76" - "\x0D\xA4\x18\xAF\x46\xDD\x51\xE8" - "\x7F\x16\x8A\x21\xB8\x2C\xC3\x5A" - "\xF1\x65\xFC\x93\x07\x9E\x35\xCC" - "\x40\xD7\x6E\x05\x79\x10\xA7\x1B" - "\xB2\x49\xE0\x54\xEB\x82\x19\x8D" - "\x24\xBB\x2F\xC6\x5D\xF4\x68\xFF" - "\x96\x0A\xA1\x38\xCF\x43\xDA\x71" - "\x08\x7C\x13\xAA\x1E\xB5\x4C\xE3" - "\x57\xEE\x85\x1C\x90\x27\xBE\x32" - "\xC9\x60\xF7\x6B\x02\x99\x0D\xA4" - "\x3B\xD2\x46\xDD\x74\x0B\x7F\x16" - "\xAD\x21\xB8\x4F\xE6\x5A\xF1\x88" - "\x1F\x93\x2A\xC1\x35\xCC\x63\xFA" - "\x6E\x05\x9C\x10\xA7\x3E\xD5\x49" - "\xE0\x77\x0E\x82\x19\xB0\x24\xBB" - "\x52\xE9\x5D\xF4\x8B\x22\x96\x2D" - "\xC4\x38\xCF\x66\xFD\x71\x08\x9F" - "\x13\xAA\x41\xD8\x4C\xE3\x7A\x11" - "\x85\x1C\xB3\x27\xBE\x55\xEC\x60" - "\xF7\x8E\x02\x99\x30\xC7\x3B\xD2" - "\x69\x00\x74\x0B\xA2\x16\xAD\x44" - "\xDB\x4F\xE6\x7D\x14\x88\x1F\xB6" - "\x2A\xC1\x58\xEF\x63\xFA\x91\x05" - "\x9C\x33\xCA\x3E\xD5\x6C\x03\x77" - "\x0E\xA5\x19\xB0\x47\xDE\x52\xE9" - "\x80\x17\x8B\x22\xB9\x2D\xC4\x5B" - "\xF2\x66\xFD\x94\x08\x9F\x36\xCD" - "\x41\xD8\x6F\x06\x7A\x11\xA8\x1C" - "\xB3\x4A\xE1\x55\xEC\x83\x1A\x8E" - "\x25\xBC\x30\xC7\x5E\xF5\x69\x00" - "\x97\x0B\xA2\x39\xD0\x44\xDB\x72" - "\x09\x7D\x14\xAB\x1F\xB6\x4D\xE4" - "\x58\xEF\x86\x1D\x91\x28\xBF\x33" - "\xCA\x61\xF8\x6C\x03\x9A\x0E\xA5" - "\x3C\xD3\x47\xDE\x75\x0C\x80\x17" - "\xAE\x22\xB9\x50\xE7\x5B\xF2\x89" - "\x20\x94\x2B\xC2\x36\xCD\x64\xFB" - "\x6F\x06\x9D\x11\xA8\x3F\xD6\x4A" - "\xE1\x78\x0F\x83\x1A\xB1\x25\xBC" - "\x53\xEA\x5E\xF5\x8C\x00\x97\x2E" - "\xC5\x39\xD0\x67\xFE\x72\x09\xA0" - "\x14\xAB\x42\xD9\x4D\xE4\x7B\x12" - "\x86\x1D\xB4\x28\xBF\x56\xED\x61" - "\xF8\x8F\x03\x9A\x31\xC8\x3C\xD3" - "\x6A\x01\x75\x0C\xA3\x17\xAE\x45" - "\xDC\x50\xE7\x7E\x15\x89\x20\xB7", - .rlen = 496, }, + }; static struct cipher_testvec camellia_lrw_enc_tv_template[] = { @@ -17115,9 +13614,6 @@ static struct cipher_testvec camellia_lrw_enc_tv_template[] = { "\xb2\x1a\xd8\x4c\xbd\x1d\x10\xe9" "\x5a\xa8\x92\x7f\xba\xe6\x0c\x95", .rlen = 512, - .also_non_np = 1, - .np = 2, - .tap = { 512 - 16, 16 }, }, }; @@ -17368,9 +13864,6 @@ static struct cipher_testvec camellia_lrw_dec_tv_template[] = { "\xe9\x2e\xc4\x29\x0f\x84\xdb\xc4" "\x21\xc4\xc2\x75\x67\x89\x37\x0a", .rlen = 512, - .also_non_np = 1, - .np = 2, - .tap = { 512 - 16, 16 }, }, }; @@ -17710,9 +14203,6 @@ static struct cipher_testvec camellia_xts_enc_tv_template[] = { "\xb7\x16\xd8\x12\x5c\xcd\x7d\x4e" "\xd5\xc6\x99\xcc\x4e\x6c\x94\x95", .rlen = 512, - .also_non_np = 1, - .np = 2, - .tap = { 512 - 16, 16 }, }, }; @@ -18053,9 +14543,6 @@ static struct cipher_testvec camellia_xts_dec_tv_template[] = { "\xf0\xf1\xf2\xf3\xf4\xf5\xf6\xf7" "\xf8\xf9\xfa\xfb\xfc\xfd\xfe\xff", .rlen = 512, - .also_non_np = 1, - .np = 2, - .tap = { 512 - 16, 16 }, }, }; diff --git a/trunk/crypto/tgr192.c b/trunk/crypto/tgr192.c index 87403556fd0b..cbca4f208c9f 100644 --- a/trunk/crypto/tgr192.c +++ b/trunk/crypto/tgr192.c @@ -628,7 +628,7 @@ static int tgr128_final(struct shash_desc *desc, u8 * out) return 0; } -static struct shash_alg tgr_algs[3] = { { +static struct shash_alg tgr192 = { .digestsize = TGR192_DIGEST_SIZE, .init = tgr192_init, .update = tgr192_update, @@ -640,7 +640,9 @@ static struct shash_alg tgr_algs[3] = { { .cra_blocksize = TGR192_BLOCK_SIZE, .cra_module = THIS_MODULE, } -}, { +}; + +static struct shash_alg tgr160 = { .digestsize = TGR160_DIGEST_SIZE, .init = tgr192_init, .update = tgr192_update, @@ -652,7 +654,9 @@ static struct shash_alg tgr_algs[3] = { { .cra_blocksize = TGR192_BLOCK_SIZE, .cra_module = THIS_MODULE, } -}, { +}; + +static struct shash_alg tgr128 = { .digestsize = TGR128_DIGEST_SIZE, .init = tgr192_init, .update = tgr192_update, @@ -664,16 +668,38 @@ static struct shash_alg tgr_algs[3] = { { .cra_blocksize = TGR192_BLOCK_SIZE, .cra_module = THIS_MODULE, } -} }; +}; static int __init tgr192_mod_init(void) { - return crypto_register_shashes(tgr_algs, ARRAY_SIZE(tgr_algs)); + int ret = 0; + + ret = crypto_register_shash(&tgr192); + + if (ret < 0) { + goto out; + } + + ret = crypto_register_shash(&tgr160); + if (ret < 0) { + crypto_unregister_shash(&tgr192); + goto out; + } + + ret = crypto_register_shash(&tgr128); + if (ret < 0) { + crypto_unregister_shash(&tgr192); + crypto_unregister_shash(&tgr160); + } + out: + return ret; } static void __exit tgr192_mod_fini(void) { - crypto_unregister_shashes(tgr_algs, ARRAY_SIZE(tgr_algs)); + crypto_unregister_shash(&tgr192); + crypto_unregister_shash(&tgr160); + crypto_unregister_shash(&tgr128); } MODULE_ALIAS("tgr160"); diff --git a/trunk/crypto/twofish_generic.c b/trunk/crypto/twofish_generic.c index 2d5000552d0f..1f07b843e07c 100644 --- a/trunk/crypto/twofish_generic.c +++ b/trunk/crypto/twofish_generic.c @@ -188,6 +188,7 @@ static struct crypto_alg alg = { .cra_ctxsize = sizeof(struct twofish_ctx), .cra_alignmask = 3, .cra_module = THIS_MODULE, + .cra_list = LIST_HEAD_INIT(alg.cra_list), .cra_u = { .cipher = { .cia_min_keysize = TF_MIN_KEY_SIZE, .cia_max_keysize = TF_MAX_KEY_SIZE, diff --git a/trunk/crypto/vmac.c b/trunk/crypto/vmac.c index f2338ca98368..4243905ba135 100644 --- a/trunk/crypto/vmac.c +++ b/trunk/crypto/vmac.c @@ -38,11 +38,11 @@ * Constants and masks */ #define UINT64_C(x) x##ULL -static const u64 p64 = UINT64_C(0xfffffffffffffeff); /* 2^64 - 257 prime */ -static const u64 m62 = UINT64_C(0x3fffffffffffffff); /* 62-bit mask */ -static const u64 m63 = UINT64_C(0x7fffffffffffffff); /* 63-bit mask */ -static const u64 m64 = UINT64_C(0xffffffffffffffff); /* 64-bit mask */ -static const u64 mpoly = UINT64_C(0x1fffffff1fffffff); /* Poly key mask */ +const u64 p64 = UINT64_C(0xfffffffffffffeff); /* 2^64 - 257 prime */ +const u64 m62 = UINT64_C(0x3fffffffffffffff); /* 62-bit mask */ +const u64 m63 = UINT64_C(0x7fffffffffffffff); /* 63-bit mask */ +const u64 m64 = UINT64_C(0xffffffffffffffff); /* 64-bit mask */ +const u64 mpoly = UINT64_C(0x1fffffff1fffffff); /* Poly key mask */ #define pe64_to_cpup le64_to_cpup /* Prefer little endian */ diff --git a/trunk/crypto/wp512.c b/trunk/crypto/wp512.c index 180f1d6e03f4..71719a2be25a 100644 --- a/trunk/crypto/wp512.c +++ b/trunk/crypto/wp512.c @@ -1119,7 +1119,7 @@ static int wp256_final(struct shash_desc *desc, u8 *out) return 0; } -static struct shash_alg wp_algs[3] = { { +static struct shash_alg wp512 = { .digestsize = WP512_DIGEST_SIZE, .init = wp512_init, .update = wp512_update, @@ -1131,7 +1131,9 @@ static struct shash_alg wp_algs[3] = { { .cra_blocksize = WP512_BLOCK_SIZE, .cra_module = THIS_MODULE, } -}, { +}; + +static struct shash_alg wp384 = { .digestsize = WP384_DIGEST_SIZE, .init = wp512_init, .update = wp512_update, @@ -1143,7 +1145,9 @@ static struct shash_alg wp_algs[3] = { { .cra_blocksize = WP512_BLOCK_SIZE, .cra_module = THIS_MODULE, } -}, { +}; + +static struct shash_alg wp256 = { .digestsize = WP256_DIGEST_SIZE, .init = wp512_init, .update = wp512_update, @@ -1155,16 +1159,39 @@ static struct shash_alg wp_algs[3] = { { .cra_blocksize = WP512_BLOCK_SIZE, .cra_module = THIS_MODULE, } -} }; +}; static int __init wp512_mod_init(void) { - return crypto_register_shashes(wp_algs, ARRAY_SIZE(wp_algs)); + int ret = 0; + + ret = crypto_register_shash(&wp512); + + if (ret < 0) + goto out; + + ret = crypto_register_shash(&wp384); + if (ret < 0) + { + crypto_unregister_shash(&wp512); + goto out; + } + + ret = crypto_register_shash(&wp256); + if (ret < 0) + { + crypto_unregister_shash(&wp512); + crypto_unregister_shash(&wp384); + } +out: + return ret; } static void __exit wp512_mod_fini(void) { - crypto_unregister_shashes(wp_algs, ARRAY_SIZE(wp_algs)); + crypto_unregister_shash(&wp512); + crypto_unregister_shash(&wp384); + crypto_unregister_shash(&wp256); } MODULE_ALIAS("wp384"); diff --git a/trunk/drivers/atm/eni.c b/trunk/drivers/atm/eni.c index 81e44f7b0ab6..2059ee460b0c 100644 --- a/trunk/drivers/atm/eni.c +++ b/trunk/drivers/atm/eni.c @@ -1567,7 +1567,7 @@ tx_complete++; /*--------------------------------- entries ---------------------------------*/ -static char * const media_name[] __devinitconst = { +static const char *media_name[] __devinitdata = { "MMF", "SMF", "MMF", "03?", /* 0- 3 */ "UTP", "05?", "06?", "07?", /* 4- 7 */ "TAXI","09?", "10?", "11?", /* 8-11 */ diff --git a/trunk/drivers/base/firmware_class.c b/trunk/drivers/base/firmware_class.c index 81541452887b..e85763de928f 100644 --- a/trunk/drivers/base/firmware_class.c +++ b/trunk/drivers/base/firmware_class.c @@ -58,6 +58,7 @@ static noinline long fw_file_size(struct file *file) static bool fw_read_file_contents(struct file *file, struct firmware *fw) { + loff_t pos; long size; char *buf; @@ -67,7 +68,8 @@ static bool fw_read_file_contents(struct file *file, struct firmware *fw) buf = vmalloc(size); if (!buf) return false; - if (kernel_read(file, 0, buf, size) != size) { + pos = 0; + if (vfs_read(file, buf, size, &pos) != size) { vfree(buf); return false; } diff --git a/trunk/drivers/block/aoe/aoe.h b/trunk/drivers/block/aoe/aoe.h index d2ed7f18d1ac..db195abad698 100644 --- a/trunk/drivers/block/aoe/aoe.h +++ b/trunk/drivers/block/aoe/aoe.h @@ -1,5 +1,5 @@ -/* Copyright (c) 2012 Coraid, Inc. See COPYING for GPL terms. */ -#define VERSION "50" +/* Copyright (c) 2007 Coraid, Inc. See COPYING for GPL terms. */ +#define VERSION "47" #define AOE_MAJOR 152 #define DEVICE_NAME "aoe" @@ -10,6 +10,9 @@ #define AOE_PARTITIONS (16) #endif +#define SYSMINOR(aoemajor, aoeminor) ((aoemajor) * NPERSHELF + (aoeminor)) +#define AOEMAJOR(sysminor) ((sysminor) / NPERSHELF) +#define AOEMINOR(sysminor) ((sysminor) % NPERSHELF) #define WHITESPACE " \t\v\f\n" enum { @@ -72,67 +75,72 @@ enum { DEVFL_UP = 1, /* device is installed in system and ready for AoE->ATA commands */ DEVFL_TKILL = (1<<1), /* flag for timer to know when to kill self */ DEVFL_EXT = (1<<2), /* device accepts lba48 commands */ - DEVFL_GDALLOC = (1<<3), /* need to alloc gendisk */ - DEVFL_KICKME = (1<<4), /* slow polling network card catch */ - DEVFL_NEWSIZE = (1<<5), /* need to update dev size in block layer */ + DEVFL_CLOSEWAIT = (1<<3), /* device is waiting for all closes to revalidate */ + DEVFL_GDALLOC = (1<<4), /* need to alloc gendisk */ + DEVFL_KICKME = (1<<5), /* slow polling network card catch */ + DEVFL_NEWSIZE = (1<<6), /* need to update dev size in block layer */ + + BUFFL_FAIL = 1, }; enum { DEFAULTBCNT = 2 * 512, /* 2 sectors */ + NPERSHELF = 16, /* number of slots per shelf address */ + FREETAG = -1, MIN_BUFS = 16, NTARGETS = 8, NAOEIFS = 8, - NSKBPOOLMAX = 256, - NFACTIVE = 61, + NSKBPOOLMAX = 128, TIMERTICK = HZ / 10, MINTIMER = HZ >> 2, MAXTIMER = HZ << 1, + HELPWAIT = 20, }; struct buf { + struct list_head bufs; + ulong stime; /* for disk stats */ + ulong flags; ulong nframesout; ulong resid; ulong bv_resid; + ulong bv_off; sector_t sector; struct bio *bio; struct bio_vec *bv; - struct request *rq; }; struct frame { - struct list_head head; - u32 tag; + int tag; ulong waited; - struct aoetgt *t; /* parent target I belong to */ - sector_t lba; - struct sk_buff *skb; /* command skb freed on module exit */ - struct sk_buff *r_skb; /* response skb for async processing */ struct buf *buf; - struct bio_vec *bv; + char *bufaddr; ulong bcnt; - ulong bv_off; + sector_t lba; + struct sk_buff *skb; }; struct aoeif { struct net_device *nd; - ulong lost; - int bcnt; + unsigned char lost; + unsigned char lostjumbo; + ushort maxbcnt; }; struct aoetgt { unsigned char addr[6]; ushort nframes; - struct aoedev *d; /* parent device I belong to */ - struct list_head ffree; /* list of free frames */ + struct frame *frames; struct aoeif ifs[NAOEIFS]; struct aoeif *ifp; /* current aoeif in use */ ushort nout; ushort maxout; - ulong falloc; + u16 lasttag; /* last tag sent */ + u16 useme; ulong lastwadj; /* last window adjustment */ - int minbcnt; int wpkts, rpkts; + int dataref; }; struct aoedev { @@ -145,9 +153,6 @@ struct aoedev { u16 rttavg; /* round trip average of requests/responses */ u16 mintimer; u16 fw_ver; /* version of blade's firmware */ - u16 lasttag; /* last tag sent */ - u16 useme; - ulong ref; struct work_struct work;/* disk create work struct */ struct gendisk *gd; struct request_queue *blkq; @@ -155,31 +160,16 @@ struct aoedev { sector_t ssize; struct timer_list timer; spinlock_t lock; + struct sk_buff_head sendq; struct sk_buff_head skbpool; mempool_t *bufpool; /* for deadlock-free Buf allocation */ - struct { /* pointers to work in progress */ - struct buf *buf; - struct bio *nxbio; - struct request *rq; - } ip; - ulong maxbcnt; - struct list_head factive[NFACTIVE]; /* hash of active frames */ + struct list_head bufq; /* queue of bios to work on */ + struct buf *inprocess; /* the one we're currently working on */ struct aoetgt *targets[NTARGETS]; struct aoetgt **tgt; /* target in use when working */ - struct aoetgt *htgt; /* target needing rexmit assistance */ - ulong ntargets; - ulong kicked; + struct aoetgt **htgt; /* target needing rexmit assistance */ }; -/* kthread tracking */ -struct ktstate { - struct completion rendez; - struct task_struct *task; - wait_queue_head_t *waitq; - int (*fn) (void); - char *name; - spinlock_t *lock; -}; int aoeblk_init(void); void aoeblk_exit(void); @@ -192,29 +182,22 @@ void aoechr_error(char *); void aoecmd_work(struct aoedev *d); void aoecmd_cfg(ushort aoemajor, unsigned char aoeminor); -struct sk_buff *aoecmd_ata_rsp(struct sk_buff *); +void aoecmd_ata_rsp(struct sk_buff *); void aoecmd_cfg_rsp(struct sk_buff *); void aoecmd_sleepwork(struct work_struct *); void aoecmd_cleanslate(struct aoedev *); -void aoecmd_exit(void); -int aoecmd_init(void); struct sk_buff *aoecmd_ata_id(struct aoedev *); -void aoe_freetframe(struct frame *); -void aoe_flush_iocq(void); -void aoe_end_request(struct aoedev *, struct request *, int); -int aoe_ktstart(struct ktstate *k); -void aoe_ktstop(struct ktstate *k); int aoedev_init(void); void aoedev_exit(void); -struct aoedev *aoedev_by_aoeaddr(ulong maj, int min, int do_alloc); +struct aoedev *aoedev_by_aoeaddr(int maj, int min); +struct aoedev *aoedev_by_sysminor_m(ulong sysminor); void aoedev_downdev(struct aoedev *d); int aoedev_flush(const char __user *str, size_t size); -void aoe_failbuf(struct aoedev *, struct buf *); -void aoedev_put(struct aoedev *); int aoenet_init(void); void aoenet_exit(void); void aoenet_xmit(struct sk_buff_head *); int is_aoe_netif(struct net_device *ifp); int set_aoe_iflist(const char __user *str, size_t size); + diff --git a/trunk/drivers/block/aoe/aoeblk.c b/trunk/drivers/block/aoe/aoeblk.c index 00dfc5008ad4..321de7b6c442 100644 --- a/trunk/drivers/block/aoe/aoeblk.c +++ b/trunk/drivers/block/aoe/aoeblk.c @@ -1,4 +1,4 @@ -/* Copyright (c) 2012 Coraid, Inc. See COPYING for GPL terms. */ +/* Copyright (c) 2007 Coraid, Inc. See COPYING for GPL terms. */ /* * aoeblk.c * block device routines @@ -161,22 +161,68 @@ aoeblk_release(struct gendisk *disk, fmode_t mode) } static void -aoeblk_request(struct request_queue *q) +aoeblk_make_request(struct request_queue *q, struct bio *bio) { + struct sk_buff_head queue; struct aoedev *d; - struct request *rq; + struct buf *buf; + ulong flags; + + blk_queue_bounce(q, &bio); + + if (bio == NULL) { + printk(KERN_ERR "aoe: bio is NULL\n"); + BUG(); + return; + } + d = bio->bi_bdev->bd_disk->private_data; + if (d == NULL) { + printk(KERN_ERR "aoe: bd_disk->private_data is NULL\n"); + BUG(); + bio_endio(bio, -ENXIO); + return; + } else if (bio->bi_io_vec == NULL) { + printk(KERN_ERR "aoe: bi_io_vec is NULL\n"); + BUG(); + bio_endio(bio, -ENXIO); + return; + } + buf = mempool_alloc(d->bufpool, GFP_NOIO); + if (buf == NULL) { + printk(KERN_INFO "aoe: buf allocation failure\n"); + bio_endio(bio, -ENOMEM); + return; + } + memset(buf, 0, sizeof(*buf)); + INIT_LIST_HEAD(&buf->bufs); + buf->stime = jiffies; + buf->bio = bio; + buf->resid = bio->bi_size; + buf->sector = bio->bi_sector; + buf->bv = &bio->bi_io_vec[bio->bi_idx]; + buf->bv_resid = buf->bv->bv_len; + WARN_ON(buf->bv_resid == 0); + buf->bv_off = buf->bv->bv_offset; + + spin_lock_irqsave(&d->lock, flags); - d = q->queuedata; if ((d->flags & DEVFL_UP) == 0) { pr_info_ratelimited("aoe: device %ld.%d is not up\n", d->aoemajor, d->aoeminor); - while ((rq = blk_peek_request(q))) { - blk_start_request(rq); - aoe_end_request(d, rq, 1); - } + spin_unlock_irqrestore(&d->lock, flags); + mempool_free(buf, d->bufpool); + bio_endio(bio, -ENXIO); return; } + + list_add_tail(&buf->bufs, &d->bufq); + aoecmd_work(d); + __skb_queue_head_init(&queue); + skb_queue_splice_init(&d->sendq, &queue); + + spin_unlock_irqrestore(&d->lock, flags); + aoenet_xmit(&queue); } static int @@ -208,54 +254,41 @@ aoeblk_gdalloc(void *vp) { struct aoedev *d = vp; struct gendisk *gd; - mempool_t *mp; - struct request_queue *q; - enum { KB = 1024, MB = KB * KB, READ_AHEAD = 2 * MB, }; ulong flags; gd = alloc_disk(AOE_PARTITIONS); if (gd == NULL) { - pr_err("aoe: cannot allocate disk structure for %ld.%d\n", + printk(KERN_ERR + "aoe: cannot allocate disk structure for %ld.%d\n", d->aoemajor, d->aoeminor); goto err; } - mp = mempool_create(MIN_BUFS, mempool_alloc_slab, mempool_free_slab, - buf_pool_cache); - if (mp == NULL) { + d->bufpool = mempool_create_slab_pool(MIN_BUFS, buf_pool_cache); + if (d->bufpool == NULL) { printk(KERN_ERR "aoe: cannot allocate bufpool for %ld.%d\n", d->aoemajor, d->aoeminor); goto err_disk; } - q = blk_init_queue(aoeblk_request, &d->lock); - if (q == NULL) { - pr_err("aoe: cannot allocate block queue for %ld.%d\n", - d->aoemajor, d->aoeminor); - mempool_destroy(mp); - goto err_disk; - } d->blkq = blk_alloc_queue(GFP_KERNEL); if (!d->blkq) goto err_mempool; + blk_queue_make_request(d->blkq, aoeblk_make_request); d->blkq->backing_dev_info.name = "aoe"; if (bdi_init(&d->blkq->backing_dev_info)) goto err_blkq; spin_lock_irqsave(&d->lock, flags); - blk_queue_max_hw_sectors(d->blkq, BLK_DEF_MAX_SECTORS); - q->backing_dev_info.ra_pages = READ_AHEAD / PAGE_CACHE_SIZE; - d->bufpool = mp; - d->blkq = gd->queue = q; - q->queuedata = d; - d->gd = gd; gd->major = AOE_MAJOR; - gd->first_minor = d->sysminor; + gd->first_minor = d->sysminor * AOE_PARTITIONS; gd->fops = &aoe_bdops; gd->private_data = d; set_capacity(gd, d->ssize); snprintf(gd->disk_name, sizeof gd->disk_name, "etherd/e%ld.%d", d->aoemajor, d->aoeminor); + gd->queue = d->blkq; + d->gd = gd; d->flags &= ~DEVFL_GDALLOC; d->flags |= DEVFL_UP; diff --git a/trunk/drivers/block/aoe/aoechr.c b/trunk/drivers/block/aoe/aoechr.c index ed57a890c643..e86d2062a164 100644 --- a/trunk/drivers/block/aoe/aoechr.c +++ b/trunk/drivers/block/aoe/aoechr.c @@ -1,4 +1,4 @@ -/* Copyright (c) 2012 Coraid, Inc. See COPYING for GPL terms. */ +/* Copyright (c) 2007 Coraid, Inc. See COPYING for GPL terms. */ /* * aoechr.c * AoE character device driver @@ -86,34 +86,34 @@ revalidate(const char __user *str, size_t size) if (copy_from_user(buf, str, size)) return -EFAULT; + /* should be e%d.%d format */ n = sscanf(buf, "e%d.%d", &major, &minor); if (n != 2) { - pr_err("aoe: invalid device specification %s\n", buf); + printk(KERN_ERR "aoe: invalid device specification\n"); return -EINVAL; } - d = aoedev_by_aoeaddr(major, minor, 0); + d = aoedev_by_aoeaddr(major, minor); if (!d) return -EINVAL; spin_lock_irqsave(&d->lock, flags); aoecmd_cleanslate(d); - aoecmd_cfg(major, minor); loop: skb = aoecmd_ata_id(d); spin_unlock_irqrestore(&d->lock, flags); /* try again if we are able to sleep a bit, * otherwise give up this revalidation */ - if (!skb && !msleep_interruptible(250)) { + if (!skb && !msleep_interruptible(200)) { spin_lock_irqsave(&d->lock, flags); goto loop; } - aoedev_put(d); if (skb) { struct sk_buff_head queue; __skb_queue_head_init(&queue); __skb_queue_tail(&queue, skb); aoenet_xmit(&queue); } + aoecmd_cfg(major, minor); return 0; } @@ -174,7 +174,6 @@ aoechr_write(struct file *filp, const char __user *buf, size_t cnt, loff_t *offp break; case MINOR_FLUSH: ret = aoedev_flush(buf, cnt); - break; } if (ret == 0) ret = cnt; diff --git a/trunk/drivers/block/aoe/aoecmd.c b/trunk/drivers/block/aoe/aoecmd.c index 3804a0af3ef1..887f68f6d79a 100644 --- a/trunk/drivers/block/aoe/aoecmd.c +++ b/trunk/drivers/block/aoe/aoecmd.c @@ -1,4 +1,4 @@ -/* Copyright (c) 2012 Coraid, Inc. See COPYING for GPL terms. */ +/* Copyright (c) 2007 Coraid, Inc. See COPYING for GPL terms. */ /* * aoecmd.c * Filesystem request handling methods @@ -12,19 +12,10 @@ #include #include #include -#include -#include #include #include -#include #include "aoe.h" -#define MAXIOC (8192) /* default meant to avoid most soft lockups */ - -static void ktcomplete(struct frame *, struct sk_buff *); - -static struct buf *nextbuf(struct aoedev *); - static int aoe_deadsecs = 60 * 3; module_param(aoe_deadsecs, int, 0644); MODULE_PARM_DESC(aoe_deadsecs, "After aoe_deadsecs seconds, give up and fail dev."); @@ -34,15 +25,6 @@ module_param(aoe_maxout, int, 0644); MODULE_PARM_DESC(aoe_maxout, "Only aoe_maxout outstanding packets for every MAC on eX.Y."); -static wait_queue_head_t ktiowq; -static struct ktstate kts; - -/* io completion queue */ -static struct { - struct list_head head; - spinlock_t lock; -} iocq; - static struct sk_buff * new_skb(ulong len) { @@ -59,21 +41,15 @@ new_skb(ulong len) } static struct frame * -getframe(struct aoedev *d, u32 tag) +getframe(struct aoetgt *t, int tag) { - struct frame *f; - struct list_head *head, *pos, *nx; - u32 n; + struct frame *f, *e; - n = tag % NFACTIVE; - head = &d->factive[n]; - list_for_each_safe(pos, nx, head) { - f = list_entry(pos, struct frame, head); - if (f->tag == tag) { - list_del(pos); + f = t->frames; + e = f + t->nframes; + for (; ftag == tag) return f; - } - } return NULL; } @@ -83,18 +59,18 @@ getframe(struct aoedev *d, u32 tag) * This driver reserves tag -1 to mean "unused frame." */ static int -newtag(struct aoedev *d) +newtag(struct aoetgt *t) { register ulong n; n = jiffies & 0xffff; - return n |= (++d->lasttag & 0x7fff) << 16; + return n |= (++t->lasttag & 0x7fff) << 16; } -static u32 +static int aoehdr_atainit(struct aoedev *d, struct aoetgt *t, struct aoe_hdr *h) { - u32 host_tag = newtag(d); + u32 host_tag = newtag(t); memcpy(h->src, t->ifp->nd->dev_addr, sizeof h->src); memcpy(h->dst, t->addr, sizeof h->dst); @@ -119,18 +95,16 @@ put_lba(struct aoe_atahdr *ah, sector_t lba) ah->lba5 = lba >>= 8; } -static struct aoeif * +static void ifrotate(struct aoetgt *t) { - struct aoeif *ifp; - - ifp = t->ifp; - ifp++; - if (ifp >= &t->ifs[NAOEIFS] || ifp->nd == NULL) - ifp = t->ifs; - if (ifp->nd == NULL) - return NULL; - return t->ifp = ifp; + t->ifp++; + if (t->ifp >= &t->ifs[NAOEIFS] || t->ifp->nd == NULL) + t->ifp = t->ifs; + if (t->ifp->nd == NULL) { + printk(KERN_INFO "aoe: no interface to rotate to\n"); + BUG(); + } } static void @@ -155,128 +129,78 @@ skb_pool_get(struct aoedev *d) return NULL; } -void -aoe_freetframe(struct frame *f) -{ - struct aoetgt *t; - - t = f->t; - f->buf = NULL; - f->bv = NULL; - f->r_skb = NULL; - list_add(&f->head, &t->ffree); -} - +/* freeframe is where we do our load balancing so it's a little hairy. */ static struct frame * -newtframe(struct aoedev *d, struct aoetgt *t) +freeframe(struct aoedev *d) { - struct frame *f; + struct frame *f, *e, *rf; + struct aoetgt **t; struct sk_buff *skb; - struct list_head *pos; - - if (list_empty(&t->ffree)) { - if (t->falloc >= NSKBPOOLMAX*2) - return NULL; - f = kcalloc(1, sizeof(*f), GFP_ATOMIC); - if (f == NULL) - return NULL; - t->falloc++; - f->t = t; - } else { - pos = t->ffree.next; - list_del(pos); - f = list_entry(pos, struct frame, head); - } - - skb = f->skb; - if (skb == NULL) { - f->skb = skb = new_skb(ETH_ZLEN); - if (!skb) { -bail: aoe_freetframe(f); - return NULL; - } - } - - if (atomic_read(&skb_shinfo(skb)->dataref) != 1) { - skb = skb_pool_get(d); - if (skb == NULL) - goto bail; - skb_pool_put(d, f->skb); - f->skb = skb; - } - - skb->truesize -= skb->data_len; - skb_shinfo(skb)->nr_frags = skb->data_len = 0; - skb_trim(skb, 0); - return f; -} - -static struct frame * -newframe(struct aoedev *d) -{ - struct frame *f; - struct aoetgt *t, **tt; - int totout = 0; if (d->targets[0] == NULL) { /* shouldn't happen, but I'm paranoid */ printk(KERN_ERR "aoe: NULL TARGETS!\n"); return NULL; } - tt = d->tgt; /* last used target */ + t = d->tgt; + t++; + if (t >= &d->targets[NTARGETS] || !*t) + t = d->targets; for (;;) { - tt++; - if (tt >= &d->targets[NTARGETS] || !*tt) - tt = d->targets; - t = *tt; - totout += t->nout; - if (t->nout < t->maxout + if ((*t)->nout < (*t)->maxout && t != d->htgt - && t->ifp->nd) { - f = newtframe(d, t); - if (f) { - ifrotate(t); - d->tgt = tt; + && (*t)->ifp->nd) { + rf = NULL; + f = (*t)->frames; + e = f + (*t)->nframes; + for (; f < e; f++) { + if (f->tag != FREETAG) + continue; + skb = f->skb; + if (!skb + && !(f->skb = skb = new_skb(ETH_ZLEN))) + continue; + if (atomic_read(&skb_shinfo(skb)->dataref) + != 1) { + if (!rf) + rf = f; + continue; + } +gotone: skb_shinfo(skb)->nr_frags = skb->data_len = 0; + skb_trim(skb, 0); + d->tgt = t; + ifrotate(*t); return f; } + /* Work can be done, but the network layer is + holding our precious packets. Try to grab + one from the pool. */ + f = rf; + if (f == NULL) { /* more paranoia */ + printk(KERN_ERR + "aoe: freeframe: %s.\n", + "unexpected null rf"); + d->flags |= DEVFL_KICKME; + return NULL; + } + skb = skb_pool_get(d); + if (skb) { + skb_pool_put(d, f->skb); + f->skb = skb; + goto gotone; + } + (*t)->dataref++; + if ((*t)->nout == 0) + d->flags |= DEVFL_KICKME; } - if (tt == d->tgt) /* we've looped and found nada */ + if (t == d->tgt) /* we've looped and found nada */ break; - } - if (totout == 0) { - d->kicked++; - d->flags |= DEVFL_KICKME; + t++; + if (t >= &d->targets[NTARGETS] || !*t) + t = d->targets; } return NULL; } -static void -skb_fillup(struct sk_buff *skb, struct bio_vec *bv, ulong off, ulong cnt) -{ - int frag = 0; - ulong fcnt; -loop: - fcnt = bv->bv_len - (off - bv->bv_offset); - if (fcnt > cnt) - fcnt = cnt; - skb_fill_page_desc(skb, frag++, bv->bv_page, off, fcnt); - cnt -= fcnt; - if (cnt <= 0) - return; - bv++; - off = bv->bv_offset; - goto loop; -} - -static void -fhash(struct frame *f) -{ - struct aoedev *d = f->t->d; - u32 n; - - n = f->tag % NFACTIVE; - list_add_tail(&f->head, &d->factive[n]); -} - static int aoecmd_ata_rw(struct aoedev *d) { @@ -284,47 +208,26 @@ aoecmd_ata_rw(struct aoedev *d) struct aoe_hdr *h; struct aoe_atahdr *ah; struct buf *buf; + struct bio_vec *bv; struct aoetgt *t; struct sk_buff *skb; - struct sk_buff_head queue; - ulong bcnt, fbcnt; + ulong bcnt; char writebit, extbit; writebit = 0x10; extbit = 0x4; - buf = nextbuf(d); - if (buf == NULL) - return 0; - f = newframe(d); + f = freeframe(d); if (f == NULL) return 0; t = *d->tgt; - bcnt = d->maxbcnt; + buf = d->inprocess; + bv = buf->bv; + bcnt = t->ifp->maxbcnt; if (bcnt == 0) bcnt = DEFAULTBCNT; - if (bcnt > buf->resid) - bcnt = buf->resid; - fbcnt = bcnt; - f->bv = buf->bv; - f->bv_off = f->bv->bv_offset + (f->bv->bv_len - buf->bv_resid); - do { - if (fbcnt < buf->bv_resid) { - buf->bv_resid -= fbcnt; - buf->resid -= fbcnt; - break; - } - fbcnt -= buf->bv_resid; - buf->resid -= buf->bv_resid; - if (buf->resid == 0) { - d->ip.buf = NULL; - break; - } - buf->bv++; - buf->bv_resid = buf->bv->bv_len; - WARN_ON(buf->bv_resid == 0); - } while (fbcnt); - + if (bcnt > buf->bv_resid) + bcnt = buf->bv_resid; /* initialize the headers & frame */ skb = f->skb; h = (struct aoe_hdr *) skb_mac_header(skb); @@ -332,10 +235,10 @@ aoecmd_ata_rw(struct aoedev *d) skb_put(skb, sizeof *h + sizeof *ah); memset(h, 0, skb->len); f->tag = aoehdr_atainit(d, t, h); - fhash(f); t->nout++; f->waited = 0; f->buf = buf; + f->bufaddr = page_address(bv->bv_page) + buf->bv_off; f->bcnt = bcnt; f->lba = buf->sector; @@ -350,11 +253,10 @@ aoecmd_ata_rw(struct aoedev *d) ah->lba3 |= 0xe0; /* LBA bit + obsolete 0xa0 */ } if (bio_data_dir(buf->bio) == WRITE) { - skb_fillup(skb, f->bv, f->bv_off, bcnt); + skb_fill_page_desc(skb, 0, bv->bv_page, buf->bv_off, bcnt); ah->aflags |= AOEAFL_WRITE; skb->len += bcnt; skb->data_len = bcnt; - skb->truesize += bcnt; t->wpkts++; } else { t->rpkts++; @@ -365,15 +267,23 @@ aoecmd_ata_rw(struct aoedev *d) /* mark all tracking fields and load out */ buf->nframesout += 1; + buf->bv_off += bcnt; + buf->bv_resid -= bcnt; + buf->resid -= bcnt; buf->sector += bcnt >> 9; + if (buf->resid == 0) { + d->inprocess = NULL; + } else if (buf->bv_resid == 0) { + buf->bv = ++bv; + buf->bv_resid = bv->bv_len; + WARN_ON(buf->bv_resid == 0); + buf->bv_off = bv->bv_offset; + } skb->dev = t->ifp->nd; skb = skb_clone(skb, GFP_ATOMIC); - if (skb) { - __skb_queue_head_init(&queue); - __skb_queue_tail(&queue, skb); - aoenet_xmit(&queue); - } + if (skb) + __skb_queue_tail(&d->sendq, skb); return 1; } @@ -420,25 +330,17 @@ aoecmd_cfg_pkts(ushort aoemajor, unsigned char aoeminor, struct sk_buff_head *qu } static void -resend(struct aoedev *d, struct frame *f) +resend(struct aoedev *d, struct aoetgt *t, struct frame *f) { struct sk_buff *skb; - struct sk_buff_head queue; struct aoe_hdr *h; struct aoe_atahdr *ah; - struct aoetgt *t; char buf[128]; u32 n; - t = f->t; - n = newtag(d); + ifrotate(t); + n = newtag(t); skb = f->skb; - if (ifrotate(t) == NULL) { - /* probably can't happen, but set it up to fail anyway */ - pr_info("aoe: resend: no interfaces to rotate to.\n"); - ktcomplete(f, NULL); - return; - } h = (struct aoe_hdr *) skb_mac_header(skb); ah = (struct aoe_atahdr *) (h+1); @@ -449,22 +351,39 @@ resend(struct aoedev *d, struct frame *f) aoechr_error(buf); f->tag = n; - fhash(f); h->tag = cpu_to_be32(n); memcpy(h->dst, t->addr, sizeof h->dst); memcpy(h->src, t->ifp->nd->dev_addr, sizeof h->src); + switch (ah->cmdstat) { + default: + break; + case ATA_CMD_PIO_READ: + case ATA_CMD_PIO_READ_EXT: + case ATA_CMD_PIO_WRITE: + case ATA_CMD_PIO_WRITE_EXT: + put_lba(ah, f->lba); + + n = f->bcnt; + if (n > DEFAULTBCNT) + n = DEFAULTBCNT; + ah->scnt = n >> 9; + if (ah->aflags & AOEAFL_WRITE) { + skb_fill_page_desc(skb, 0, virt_to_page(f->bufaddr), + offset_in_page(f->bufaddr), n); + skb->len = sizeof *h + sizeof *ah + n; + skb->data_len = n; + } + } skb->dev = t->ifp->nd; skb = skb_clone(skb, GFP_ATOMIC); if (skb == NULL) return; - __skb_queue_head_init(&queue); - __skb_queue_tail(&queue, skb); - aoenet_xmit(&queue); + __skb_queue_tail(&d->sendq, skb); } static int -tsince(u32 tag) +tsince(int tag) { int n; @@ -488,65 +407,58 @@ getif(struct aoetgt *t, struct net_device *nd) return NULL; } +static struct aoeif * +addif(struct aoetgt *t, struct net_device *nd) +{ + struct aoeif *p; + + p = getif(t, NULL); + if (!p) + return NULL; + p->nd = nd; + p->maxbcnt = DEFAULTBCNT; + p->lost = 0; + p->lostjumbo = 0; + return p; +} + static void ejectif(struct aoetgt *t, struct aoeif *ifp) { struct aoeif *e; - struct net_device *nd; ulong n; - nd = ifp->nd; e = t->ifs + NAOEIFS - 1; n = (e - ifp) * sizeof *ifp; memmove(ifp, ifp+1, n); e->nd = NULL; - dev_put(nd); } static int sthtith(struct aoedev *d) { - struct frame *f, *nf; - struct list_head *nx, *pos, *head; + struct frame *f, *e, *nf; struct sk_buff *skb; - struct aoetgt *ht = d->htgt; - int i; - - for (i = 0; i < NFACTIVE; i++) { - head = &d->factive[i]; - list_for_each_safe(pos, nx, head) { - f = list_entry(pos, struct frame, head); - if (f->t != ht) - continue; - - nf = newframe(d); - if (!nf) - return 0; - - /* remove frame from active list */ - list_del(pos); - - /* reassign all pertinent bits to new outbound frame */ - skb = nf->skb; - nf->skb = f->skb; - nf->buf = f->buf; - nf->bcnt = f->bcnt; - nf->lba = f->lba; - nf->bv = f->bv; - nf->bv_off = f->bv_off; - nf->waited = 0; - f->skb = skb; - aoe_freetframe(f); - ht->nout--; - nf->t->nout++; - resend(d, nf); - } + struct aoetgt *ht = *d->htgt; + + f = ht->frames; + e = f + ht->nframes; + for (; f < e; f++) { + if (f->tag == FREETAG) + continue; + nf = freeframe(d); + if (!nf) + return 0; + skb = nf->skb; + *nf = *f; + f->skb = skb; + f->tag = FREETAG; + nf->waited = 0; + ht->nout--; + (*d->tgt)->nout++; + resend(d, *d->tgt, nf); } - /* We've cleaned up the outstanding so take away his - * interfaces so he won't be used. We should remove him from - * the target array here, but cleaning up a target is - * involved. PUNT! - */ + /* he's clean, he's useless. take away his interfaces */ memset(ht->ifs, 0, sizeof ht->ifs); d->htgt = NULL; return 1; @@ -565,15 +477,13 @@ ata_scnt(unsigned char *packet) { static void rexmit_timer(ulong vp) { + struct sk_buff_head queue; struct aoedev *d; struct aoetgt *t, **tt, **te; struct aoeif *ifp; - struct frame *f; - struct list_head *head, *pos, *nx; - LIST_HEAD(flist); + struct frame *f, *e; register long timeout; ulong flags, n; - int i; d = (struct aoedev *) vp; @@ -587,22 +497,58 @@ rexmit_timer(ulong vp) spin_unlock_irqrestore(&d->lock, flags); return; } + tt = d->targets; + te = tt + NTARGETS; + for (; tt < te && *tt; tt++) { + t = *tt; + f = t->frames; + e = f + t->nframes; + for (; f < e; f++) { + if (f->tag == FREETAG + || tsince(f->tag) < timeout) + continue; + n = f->waited += timeout; + n /= HZ; + if (n > aoe_deadsecs) { + /* waited too long. device failure. */ + aoedev_downdev(d); + break; + } + + if (n > HELPWAIT /* see if another target can help */ + && (tt != d->targets || d->targets[1])) + d->htgt = tt; + + if (t->nout == t->maxout) { + if (t->maxout > 1) + t->maxout--; + t->lastwadj = jiffies; + } + + ifp = getif(t, f->skb->dev); + if (ifp && ++ifp->lost > (t->nframes << 1) + && (ifp != t->ifs || t->ifs[1].nd)) { + ejectif(t, ifp); + ifp = NULL; + } - /* collect all frames to rexmit into flist */ - for (i = 0; i < NFACTIVE; i++) { - head = &d->factive[i]; - list_for_each_safe(pos, nx, head) { - f = list_entry(pos, struct frame, head); - if (tsince(f->tag) < timeout) - break; /* end of expired frames */ - /* move to flist for later processing */ - list_move_tail(pos, &flist); + if (ata_scnt(skb_mac_header(f->skb)) > DEFAULTBCNT / 512 + && ifp && ++ifp->lostjumbo > (t->nframes << 1) + && ifp->maxbcnt != DEFAULTBCNT) { + printk(KERN_INFO + "aoe: e%ld.%d: " + "too many lost jumbo on " + "%s:%pm - " + "falling back to %d frames.\n", + d->aoemajor, d->aoeminor, + ifp->nd->name, t->addr, + DEFAULTBCNT); + ifp->maxbcnt = 0; + } + resend(d, t, f); } - } - /* window check */ - tt = d->targets; - te = tt + d->ntargets; - for (; tt < te && (t = *tt); tt++) { + + /* window check */ if (t->nout == t->maxout && t->maxout < t->nframes && (jiffies - t->lastwadj)/HZ > 10) { @@ -611,173 +557,45 @@ rexmit_timer(ulong vp) } } - if (!list_empty(&flist)) { /* retransmissions necessary */ + if (!skb_queue_empty(&d->sendq)) { n = d->rttavg <<= 1; if (n > MAXTIMER) d->rttavg = MAXTIMER; } - /* process expired frames */ - while (!list_empty(&flist)) { - pos = flist.next; - f = list_entry(pos, struct frame, head); - n = f->waited += timeout; - n /= HZ; - if (n > aoe_deadsecs) { - /* Waited too long. Device failure. - * Hang all frames on first hash bucket for downdev - * to clean up. - */ - list_splice(&flist, &d->factive[0]); - aoedev_downdev(d); - break; - } - list_del(pos); - - t = f->t; - if (n > aoe_deadsecs/2) - d->htgt = t; /* see if another target can help */ - - if (t->nout == t->maxout) { - if (t->maxout > 1) - t->maxout--; - t->lastwadj = jiffies; - } - - ifp = getif(t, f->skb->dev); - if (ifp && ++ifp->lost > (t->nframes << 1) - && (ifp != t->ifs || t->ifs[1].nd)) { - ejectif(t, ifp); - ifp = NULL; - } - resend(d, f); - } - - if ((d->flags & DEVFL_KICKME || d->htgt) && d->blkq) { + if (d->flags & DEVFL_KICKME || d->htgt) { d->flags &= ~DEVFL_KICKME; - d->blkq->request_fn(d->blkq); + aoecmd_work(d); } + __skb_queue_head_init(&queue); + skb_queue_splice_init(&d->sendq, &queue); + d->timer.expires = jiffies + TIMERTICK; add_timer(&d->timer); spin_unlock_irqrestore(&d->lock, flags); -} - -static unsigned long -rqbiocnt(struct request *r) -{ - struct bio *bio; - unsigned long n = 0; - - __rq_for_each_bio(bio, r) - n++; - return n; -} - -/* This can be removed if we are certain that no users of the block - * layer will ever use zero-count pages in bios. Otherwise we have to - * protect against the put_page sometimes done by the network layer. - * - * See http://oss.sgi.com/archives/xfs/2007-01/msg00594.html for - * discussion. - * - * We cannot use get_page in the workaround, because it insists on a - * positive page count as a precondition. So we use _count directly. - */ -static void -bio_pageinc(struct bio *bio) -{ - struct bio_vec *bv; - struct page *page; - int i; - - bio_for_each_segment(bv, bio, i) { - page = bv->bv_page; - /* Non-zero page count for non-head members of - * compound pages is no longer allowed by the kernel, - * but this has never been seen here. - */ - if (unlikely(PageCompound(page))) - if (compound_trans_head(page) != page) { - pr_crit("page tail used for block I/O\n"); - BUG(); - } - atomic_inc(&page->_count); - } -} - -static void -bio_pagedec(struct bio *bio) -{ - struct bio_vec *bv; - int i; - - bio_for_each_segment(bv, bio, i) - atomic_dec(&bv->bv_page->_count); -} -static void -bufinit(struct buf *buf, struct request *rq, struct bio *bio) -{ - struct bio_vec *bv; - - memset(buf, 0, sizeof(*buf)); - buf->rq = rq; - buf->bio = bio; - buf->resid = bio->bi_size; - buf->sector = bio->bi_sector; - bio_pageinc(bio); - buf->bv = bv = &bio->bi_io_vec[bio->bi_idx]; - buf->bv_resid = bv->bv_len; - WARN_ON(buf->bv_resid == 0); -} - -static struct buf * -nextbuf(struct aoedev *d) -{ - struct request *rq; - struct request_queue *q; - struct buf *buf; - struct bio *bio; - - q = d->blkq; - if (q == NULL) - return NULL; /* initializing */ - if (d->ip.buf) - return d->ip.buf; - rq = d->ip.rq; - if (rq == NULL) { - rq = blk_peek_request(q); - if (rq == NULL) - return NULL; - blk_start_request(rq); - d->ip.rq = rq; - d->ip.nxbio = rq->bio; - rq->special = (void *) rqbiocnt(rq); - } - buf = mempool_alloc(d->bufpool, GFP_ATOMIC); - if (buf == NULL) { - pr_err("aoe: nextbuf: unable to mempool_alloc!\n"); - return NULL; - } - bio = d->ip.nxbio; - bufinit(buf, rq, bio); - bio = bio->bi_next; - d->ip.nxbio = bio; - if (bio == NULL) - d->ip.rq = NULL; - return d->ip.buf = buf; + aoenet_xmit(&queue); } /* enters with d->lock held */ void aoecmd_work(struct aoedev *d) { + struct buf *buf; +loop: if (d->htgt && !sthtith(d)) return; - while (aoecmd_ata_rw(d)) - ; + if (d->inprocess == NULL) { + if (list_empty(&d->bufq)) + return; + buf = container_of(d->bufq.next, struct buf, bufs); + list_del(d->bufq.next); + d->inprocess = buf; + } + if (aoecmd_ata_rw(d)) + goto loop; } /* this function performs work that has been deferred until sleeping is OK @@ -786,25 +604,28 @@ void aoecmd_sleepwork(struct work_struct *work) { struct aoedev *d = container_of(work, struct aoedev, work); - struct block_device *bd; - u64 ssize; if (d->flags & DEVFL_GDALLOC) aoeblk_gdalloc(d); if (d->flags & DEVFL_NEWSIZE) { + struct block_device *bd; + unsigned long flags; + u64 ssize; + ssize = get_capacity(d->gd); bd = bdget_disk(d->gd, 0); + if (bd) { mutex_lock(&bd->bd_inode->i_mutex); i_size_write(bd->bd_inode, (loff_t)ssize<<9); mutex_unlock(&bd->bd_inode->i_mutex); bdput(bd); } - spin_lock_irq(&d->lock); + spin_lock_irqsave(&d->lock, flags); d->flags |= DEVFL_UP; d->flags &= ~DEVFL_NEWSIZE; - spin_unlock_irq(&d->lock); + spin_unlock_irqrestore(&d->lock, flags); } } @@ -897,299 +718,163 @@ gettgt(struct aoedev *d, char *addr) return NULL; } -static void -bvcpy(struct bio_vec *bv, ulong off, struct sk_buff *skb, long cnt) -{ - ulong fcnt; - char *p; - int soff = 0; -loop: - fcnt = bv->bv_len - (off - bv->bv_offset); - if (fcnt > cnt) - fcnt = cnt; - p = page_address(bv->bv_page) + off; - skb_copy_bits(skb, soff, p, fcnt); - soff += fcnt; - cnt -= fcnt; - if (cnt <= 0) - return; - bv++; - off = bv->bv_offset; - goto loop; -} - -void -aoe_end_request(struct aoedev *d, struct request *rq, int fastfail) -{ - struct bio *bio; - int bok; - struct request_queue *q; - - q = d->blkq; - if (rq == d->ip.rq) - d->ip.rq = NULL; - do { - bio = rq->bio; - bok = !fastfail && test_bit(BIO_UPTODATE, &bio->bi_flags); - } while (__blk_end_request(rq, bok ? 0 : -EIO, bio->bi_size)); - - /* cf. http://lkml.org/lkml/2006/10/31/28 */ - if (!fastfail) - q->request_fn(q); -} - -static void -aoe_end_buf(struct aoedev *d, struct buf *buf) -{ - struct request *rq; - unsigned long n; - - if (buf == d->ip.buf) - d->ip.buf = NULL; - rq = buf->rq; - bio_pagedec(buf->bio); - mempool_free(buf, d->bufpool); - n = (unsigned long) rq->special; - rq->special = (void *) --n; - if (n == 0) - aoe_end_request(d, rq, 0); -} - -static void -ktiocomplete(struct frame *f) +static inline void +diskstats(struct gendisk *disk, struct bio *bio, ulong duration, sector_t sector) { - struct aoe_hdr *hin, *hout; - struct aoe_atahdr *ahin, *ahout; - struct buf *buf; - struct sk_buff *skb; - struct aoetgt *t; - struct aoeif *ifp; - struct aoedev *d; - long n; - - if (f == NULL) - return; - - t = f->t; - d = t->d; - - hout = (struct aoe_hdr *) skb_mac_header(f->skb); - ahout = (struct aoe_atahdr *) (hout+1); - buf = f->buf; - skb = f->r_skb; - if (skb == NULL) - goto noskb; /* just fail the buf. */ - - hin = (struct aoe_hdr *) skb->data; - skb_pull(skb, sizeof(*hin)); - ahin = (struct aoe_atahdr *) skb->data; - skb_pull(skb, sizeof(*ahin)); - if (ahin->cmdstat & 0xa9) { /* these bits cleared on success */ - pr_err("aoe: ata error cmd=%2.2Xh stat=%2.2Xh from e%ld.%d\n", - ahout->cmdstat, ahin->cmdstat, - d->aoemajor, d->aoeminor); -noskb: if (buf) - clear_bit(BIO_UPTODATE, &buf->bio->bi_flags); - goto badrsp; - } + unsigned long n_sect = bio->bi_size >> 9; + const int rw = bio_data_dir(bio); + struct hd_struct *part; + int cpu; - n = ahout->scnt << 9; - switch (ahout->cmdstat) { - case ATA_CMD_PIO_READ: - case ATA_CMD_PIO_READ_EXT: - if (skb->len < n) { - pr_err("aoe: runt data size in read. skb->len=%d need=%ld\n", - skb->len, n); - clear_bit(BIO_UPTODATE, &buf->bio->bi_flags); - break; - } - bvcpy(f->bv, f->bv_off, skb, n); - case ATA_CMD_PIO_WRITE: - case ATA_CMD_PIO_WRITE_EXT: - spin_lock_irq(&d->lock); - ifp = getif(t, skb->dev); - if (ifp) - ifp->lost = 0; - if (d->htgt == t) /* I'll help myself, thank you. */ - d->htgt = NULL; - spin_unlock_irq(&d->lock); - break; - case ATA_CMD_ID_ATA: - if (skb->len < 512) { - pr_info("aoe: runt data size in ataid. skb->len=%d\n", - skb->len); - break; - } - if (skb_linearize(skb)) - break; - spin_lock_irq(&d->lock); - ataid_complete(d, t, skb->data); - spin_unlock_irq(&d->lock); - break; - default: - pr_info("aoe: unrecognized ata command %2.2Xh for %d.%d\n", - ahout->cmdstat, - be16_to_cpu(get_unaligned(&hin->major)), - hin->minor); - } -badrsp: - spin_lock_irq(&d->lock); - - aoe_freetframe(f); - - if (buf && --buf->nframesout == 0 && buf->resid == 0) - aoe_end_buf(d, buf); - - aoecmd_work(d); - - spin_unlock_irq(&d->lock); - aoedev_put(d); - dev_kfree_skb(skb); -} - -/* Enters with iocq.lock held. - * Returns true iff responses needing processing remain. - */ -static int -ktio(void) -{ - struct frame *f; - struct list_head *pos; - int i; + cpu = part_stat_lock(); + part = disk_map_sector_rcu(disk, sector); - for (i = 0; ; ++i) { - if (i == MAXIOC) - return 1; - if (list_empty(&iocq.head)) - return 0; - pos = iocq.head.next; - list_del(pos); - spin_unlock_irq(&iocq.lock); - f = list_entry(pos, struct frame, head); - ktiocomplete(f); - spin_lock_irq(&iocq.lock); - } -} + part_stat_inc(cpu, part, ios[rw]); + part_stat_add(cpu, part, ticks[rw], duration); + part_stat_add(cpu, part, sectors[rw], n_sect); + part_stat_add(cpu, part, io_ticks, duration); -static int -kthread(void *vp) -{ - struct ktstate *k; - DECLARE_WAITQUEUE(wait, current); - int more; - - k = vp; - current->flags |= PF_NOFREEZE; - set_user_nice(current, -10); - complete(&k->rendez); /* tell spawner we're running */ - do { - spin_lock_irq(k->lock); - more = k->fn(); - if (!more) { - add_wait_queue(k->waitq, &wait); - __set_current_state(TASK_INTERRUPTIBLE); - } - spin_unlock_irq(k->lock); - if (!more) { - schedule(); - remove_wait_queue(k->waitq, &wait); - } else - cond_resched(); - } while (!kthread_should_stop()); - complete(&k->rendez); /* tell spawner we're stopping */ - return 0; + part_stat_unlock(); } void -aoe_ktstop(struct ktstate *k) -{ - kthread_stop(k->task); - wait_for_completion(&k->rendez); -} - -int -aoe_ktstart(struct ktstate *k) -{ - struct task_struct *task; - - init_completion(&k->rendez); - task = kthread_run(kthread, k, k->name); - if (task == NULL || IS_ERR(task)) - return -ENOMEM; - k->task = task; - wait_for_completion(&k->rendez); /* allow kthread to start */ - init_completion(&k->rendez); /* for waiting for exit later */ - return 0; -} - -/* pass it off to kthreads for processing */ -static void -ktcomplete(struct frame *f, struct sk_buff *skb) -{ - ulong flags; - - f->r_skb = skb; - spin_lock_irqsave(&iocq.lock, flags); - list_add_tail(&f->head, &iocq.head); - spin_unlock_irqrestore(&iocq.lock, flags); - wake_up(&ktiowq); -} - -struct sk_buff * aoecmd_ata_rsp(struct sk_buff *skb) { + struct sk_buff_head queue; struct aoedev *d; - struct aoe_hdr *h; + struct aoe_hdr *hin, *hout; + struct aoe_atahdr *ahin, *ahout; struct frame *f; + struct buf *buf; struct aoetgt *t; - u32 n; + struct aoeif *ifp; + register long n; ulong flags; char ebuf[128]; u16 aoemajor; - h = (struct aoe_hdr *) skb->data; - aoemajor = be16_to_cpu(get_unaligned(&h->major)); - d = aoedev_by_aoeaddr(aoemajor, h->minor, 0); + hin = (struct aoe_hdr *) skb_mac_header(skb); + aoemajor = get_unaligned_be16(&hin->major); + d = aoedev_by_aoeaddr(aoemajor, hin->minor); if (d == NULL) { snprintf(ebuf, sizeof ebuf, "aoecmd_ata_rsp: ata response " "for unknown device %d.%d\n", - aoemajor, h->minor); + aoemajor, hin->minor); aoechr_error(ebuf); - return skb; + return; } spin_lock_irqsave(&d->lock, flags); - n = be32_to_cpu(get_unaligned(&h->tag)); - f = getframe(d, n); + n = get_unaligned_be32(&hin->tag); + t = gettgt(d, hin->src); + if (t == NULL) { + printk(KERN_INFO "aoe: can't find target e%ld.%d:%pm\n", + d->aoemajor, d->aoeminor, hin->src); + spin_unlock_irqrestore(&d->lock, flags); + return; + } + f = getframe(t, n); if (f == NULL) { calc_rttavg(d, -tsince(n)); spin_unlock_irqrestore(&d->lock, flags); - aoedev_put(d); snprintf(ebuf, sizeof ebuf, "%15s e%d.%d tag=%08x@%08lx\n", "unexpected rsp", - get_unaligned_be16(&h->major), - h->minor, - get_unaligned_be32(&h->tag), + get_unaligned_be16(&hin->major), + hin->minor, + get_unaligned_be32(&hin->tag), jiffies); aoechr_error(ebuf); - return skb; + return; } - t = f->t; + calc_rttavg(d, tsince(f->tag)); + + ahin = (struct aoe_atahdr *) (hin+1); + hout = (struct aoe_hdr *) skb_mac_header(f->skb); + ahout = (struct aoe_atahdr *) (hout+1); + buf = f->buf; + + if (ahin->cmdstat & 0xa9) { /* these bits cleared on success */ + printk(KERN_ERR + "aoe: ata error cmd=%2.2Xh stat=%2.2Xh from e%ld.%d\n", + ahout->cmdstat, ahin->cmdstat, + d->aoemajor, d->aoeminor); + if (buf) + buf->flags |= BUFFL_FAIL; + } else { + if (d->htgt && t == *d->htgt) /* I'll help myself, thank you. */ + d->htgt = NULL; + n = ahout->scnt << 9; + switch (ahout->cmdstat) { + case ATA_CMD_PIO_READ: + case ATA_CMD_PIO_READ_EXT: + if (skb->len - sizeof *hin - sizeof *ahin < n) { + printk(KERN_ERR + "aoe: %s. skb->len=%d need=%ld\n", + "runt data size in read", skb->len, n); + /* fail frame f? just returning will rexmit. */ + spin_unlock_irqrestore(&d->lock, flags); + return; + } + memcpy(f->bufaddr, ahin+1, n); + case ATA_CMD_PIO_WRITE: + case ATA_CMD_PIO_WRITE_EXT: + ifp = getif(t, skb->dev); + if (ifp) { + ifp->lost = 0; + if (n > DEFAULTBCNT) + ifp->lostjumbo = 0; + } + if (f->bcnt -= n) { + f->lba += n >> 9; + f->bufaddr += n; + resend(d, t, f); + goto xmit; + } + break; + case ATA_CMD_ID_ATA: + if (skb->len - sizeof *hin - sizeof *ahin < 512) { + printk(KERN_INFO + "aoe: runt data size in ataid. skb->len=%d\n", + skb->len); + spin_unlock_irqrestore(&d->lock, flags); + return; + } + ataid_complete(d, t, (char *) (ahin+1)); + break; + default: + printk(KERN_INFO + "aoe: unrecognized ata command %2.2Xh for %d.%d\n", + ahout->cmdstat, + get_unaligned_be16(&hin->major), + hin->minor); + } + } + + if (buf && --buf->nframesout == 0 && buf->resid == 0) { + diskstats(d->gd, buf->bio, jiffies - buf->stime, buf->sector); + if (buf->flags & BUFFL_FAIL) + bio_endio(buf->bio, -EIO); + else { + bio_flush_dcache_pages(buf->bio); + bio_endio(buf->bio, 0); + } + mempool_free(buf, d->bufpool); + } + + f->buf = NULL; + f->tag = FREETAG; t->nout--; + aoecmd_work(d); +xmit: + __skb_queue_head_init(&queue); + skb_queue_splice_init(&d->sendq, &queue); spin_unlock_irqrestore(&d->lock, flags); - - ktcomplete(f, skb); - - /* - * Note here that we do not perform an aoedev_put, as we are - * leaving this reference for the ktio to release. - */ - return NULL; + aoenet_xmit(&queue); } void @@ -1211,7 +896,7 @@ aoecmd_ata_id(struct aoedev *d) struct sk_buff *skb; struct aoetgt *t; - f = newframe(d); + f = freeframe(d); if (f == NULL) return NULL; @@ -1224,7 +909,6 @@ aoecmd_ata_id(struct aoedev *d) skb_put(skb, sizeof *h + sizeof *ah); memset(h, 0, skb->len); f->tag = aoehdr_atainit(d, t, h); - fhash(f); t->nout++; f->waited = 0; @@ -1245,6 +929,7 @@ static struct aoetgt * addtgt(struct aoedev *d, char *addr, ulong nframes) { struct aoetgt *t, **tt, **te; + struct frame *f, *e; tt = d->targets; te = tt + NTARGETS; @@ -1256,73 +941,26 @@ addtgt(struct aoedev *d, char *addr, ulong nframes) "aoe: device addtgt failure; too many targets\n"); return NULL; } - t = kzalloc(sizeof(*t), GFP_ATOMIC); - if (!t) { + t = kcalloc(1, sizeof *t, GFP_ATOMIC); + f = kcalloc(nframes, sizeof *f, GFP_ATOMIC); + if (!t || !f) { + kfree(f); + kfree(t); printk(KERN_INFO "aoe: cannot allocate memory to add target\n"); return NULL; } - d->ntargets++; t->nframes = nframes; - t->d = d; + t->frames = f; + e = f + nframes; + for (; f < e; f++) + f->tag = FREETAG; memcpy(t->addr, addr, sizeof t->addr); t->ifp = t->ifs; t->maxout = t->nframes; - INIT_LIST_HEAD(&t->ffree); return *tt = t; } -static void -setdbcnt(struct aoedev *d) -{ - struct aoetgt **t, **e; - int bcnt = 0; - - t = d->targets; - e = t + NTARGETS; - for (; t < e && *t; t++) - if (bcnt == 0 || bcnt > (*t)->minbcnt) - bcnt = (*t)->minbcnt; - if (bcnt != d->maxbcnt) { - d->maxbcnt = bcnt; - pr_info("aoe: e%ld.%d: setting %d byte data frames\n", - d->aoemajor, d->aoeminor, bcnt); - } -} - -static void -setifbcnt(struct aoetgt *t, struct net_device *nd, int bcnt) -{ - struct aoedev *d; - struct aoeif *p, *e; - int minbcnt; - - d = t->d; - minbcnt = bcnt; - p = t->ifs; - e = p + NAOEIFS; - for (; p < e; p++) { - if (p->nd == NULL) - break; /* end of the valid interfaces */ - if (p->nd == nd) { - p->bcnt = bcnt; /* we're updating */ - nd = NULL; - } else if (minbcnt > p->bcnt) - minbcnt = p->bcnt; /* find the min interface */ - } - if (nd) { - if (p == e) { - pr_err("aoe: device setifbcnt failure; too many interfaces.\n"); - return; - } - dev_hold(nd); - p->nd = nd; - p->bcnt = bcnt; - } - t->minbcnt = minbcnt; - setdbcnt(d); -} - void aoecmd_cfg_rsp(struct sk_buff *skb) { @@ -1330,12 +968,11 @@ aoecmd_cfg_rsp(struct sk_buff *skb) struct aoe_hdr *h; struct aoe_cfghdr *ch; struct aoetgt *t; - ulong flags, aoemajor; + struct aoeif *ifp; + ulong flags, sysminor, aoemajor; struct sk_buff *sl; - struct sk_buff_head queue; u16 n; - sl = NULL; h = (struct aoe_hdr *) skb_mac_header(skb); ch = (struct aoe_cfghdr *) (h+1); @@ -1349,13 +986,10 @@ aoecmd_cfg_rsp(struct sk_buff *skb) "Check shelf dip switches.\n"); return; } - if (aoemajor == 0xffff) { - pr_info("aoe: e%ld.%d: broadcast shelf number invalid\n", - aoemajor, (int) h->minor); - return; - } - if (h->minor == 0xff) { - pr_info("aoe: e%ld.%d: broadcast slot number invalid\n", + + sysminor = SYSMINOR(aoemajor, h->minor); + if (sysminor * AOE_PARTITIONS + AOE_PARTITIONS > MINORMASK) { + printk(KERN_INFO "aoe: e%ld.%d: minor number too large\n", aoemajor, (int) h->minor); return; } @@ -1364,9 +998,9 @@ aoecmd_cfg_rsp(struct sk_buff *skb) if (n > aoe_maxout) /* keep it reasonable */ n = aoe_maxout; - d = aoedev_by_aoeaddr(aoemajor, h->minor, 1); + d = aoedev_by_sysminor_m(sysminor); if (d == NULL) { - pr_info("aoe: device allocation failure\n"); + printk(KERN_INFO "aoe: device sysminor_m failure\n"); return; } @@ -1375,26 +1009,52 @@ aoecmd_cfg_rsp(struct sk_buff *skb) t = gettgt(d, h->src); if (!t) { t = addtgt(d, h->src, n); - if (!t) - goto bail; + if (!t) { + spin_unlock_irqrestore(&d->lock, flags); + return; + } + } + ifp = getif(t, skb->dev); + if (!ifp) { + ifp = addif(t, skb->dev); + if (!ifp) { + printk(KERN_INFO + "aoe: device addif failure; " + "too many interfaces?\n"); + spin_unlock_irqrestore(&d->lock, flags); + return; + } + } + if (ifp->maxbcnt) { + n = ifp->nd->mtu; + n -= sizeof (struct aoe_hdr) + sizeof (struct aoe_atahdr); + n /= 512; + if (n > ch->scnt) + n = ch->scnt; + n = n ? n * 512 : DEFAULTBCNT; + if (n != ifp->maxbcnt) { + printk(KERN_INFO + "aoe: e%ld.%d: setting %d%s%s:%pm\n", + d->aoemajor, d->aoeminor, n, + " byte data frames on ", ifp->nd->name, + t->addr); + ifp->maxbcnt = n; + } } - n = skb->dev->mtu; - n -= sizeof(struct aoe_hdr) + sizeof(struct aoe_atahdr); - n /= 512; - if (n > ch->scnt) - n = ch->scnt; - n = n ? n * 512 : DEFAULTBCNT; - setifbcnt(t, skb->dev, n); /* don't change users' perspective */ - if (d->nopen == 0) { - d->fw_ver = be16_to_cpu(ch->fwver); - sl = aoecmd_ata_id(d); + if (d->nopen) { + spin_unlock_irqrestore(&d->lock, flags); + return; } -bail: + d->fw_ver = be16_to_cpu(ch->fwver); + + sl = aoecmd_ata_id(d); + spin_unlock_irqrestore(&d->lock, flags); - aoedev_put(d); + if (sl) { + struct sk_buff_head queue; __skb_queue_head_init(&queue); __skb_queue_tail(&queue, sl); aoenet_xmit(&queue); @@ -1405,74 +1065,20 @@ void aoecmd_cleanslate(struct aoedev *d) { struct aoetgt **t, **te; + struct aoeif *p, *e; d->mintimer = MINTIMER; - d->maxbcnt = 0; t = d->targets; te = t + NTARGETS; - for (; t < te && *t; t++) + for (; t < te && *t; t++) { (*t)->maxout = (*t)->nframes; -} - -void -aoe_failbuf(struct aoedev *d, struct buf *buf) -{ - if (buf == NULL) - return; - buf->resid = 0; - clear_bit(BIO_UPTODATE, &buf->bio->bi_flags); - if (buf->nframesout == 0) - aoe_end_buf(d, buf); -} - -void -aoe_flush_iocq(void) -{ - struct frame *f; - struct aoedev *d; - LIST_HEAD(flist); - struct list_head *pos; - struct sk_buff *skb; - ulong flags; - - spin_lock_irqsave(&iocq.lock, flags); - list_splice_init(&iocq.head, &flist); - spin_unlock_irqrestore(&iocq.lock, flags); - while (!list_empty(&flist)) { - pos = flist.next; - list_del(pos); - f = list_entry(pos, struct frame, head); - d = f->t->d; - skb = f->r_skb; - spin_lock_irqsave(&d->lock, flags); - if (f->buf) { - f->buf->nframesout--; - aoe_failbuf(d, f->buf); + p = (*t)->ifs; + e = p + NAOEIFS; + for (; p < e; p++) { + p->lostjumbo = 0; + p->lost = 0; + p->maxbcnt = DEFAULTBCNT; } - aoe_freetframe(f); - spin_unlock_irqrestore(&d->lock, flags); - dev_kfree_skb(skb); - aoedev_put(d); } } - -int __init -aoecmd_init(void) -{ - INIT_LIST_HEAD(&iocq.head); - spin_lock_init(&iocq.lock); - init_waitqueue_head(&ktiowq); - kts.name = "aoe_ktio"; - kts.fn = ktio; - kts.waitq = &ktiowq; - kts.lock = &iocq.lock; - return aoe_ktstart(&kts); -} - -void -aoecmd_exit(void) -{ - aoe_ktstop(&kts); - aoe_flush_iocq(); -} diff --git a/trunk/drivers/block/aoe/aoedev.c b/trunk/drivers/block/aoe/aoedev.c index 90e5b537f94b..6b5110a47458 100644 --- a/trunk/drivers/block/aoe/aoedev.c +++ b/trunk/drivers/block/aoe/aoedev.c @@ -1,4 +1,4 @@ -/* Copyright (c) 2012 Coraid, Inc. See COPYING for GPL terms. */ +/* Copyright (c) 2007 Coraid, Inc. See COPYING for GPL terms. */ /* * aoedev.c * AoE device utility functions; maintains device list. @@ -9,9 +9,6 @@ #include #include #include -#include -#include -#include #include "aoe.h" static void dummy_timer(ulong); @@ -19,121 +16,23 @@ static void aoedev_freedev(struct aoedev *); static void freetgt(struct aoedev *d, struct aoetgt *t); static void skbpoolfree(struct aoedev *d); -static int aoe_dyndevs = 1; -module_param(aoe_dyndevs, int, 0644); -MODULE_PARM_DESC(aoe_dyndevs, "Use dynamic minor numbers for devices."); - static struct aoedev *devlist; static DEFINE_SPINLOCK(devlist_lock); -/* Because some systems will have one, many, or no - * - partitions, - * - slots per shelf, - * - or shelves, - * we need some flexibility in the way the minor numbers - * are allocated. So they are dynamic. - */ -#define N_DEVS ((1U<= NPERSHELF || n >= N_DEVS) { - pr_err("aoe: %s with e%ld.%d\n", - "cannot use static minor device numbers", - aoemaj, aoemin); - error = -1; - } else { - spin_lock_irqsave(&used_minors_lock, flags); - if (test_bit(n, used_minors)) { - pr_err("aoe: %s %lu\n", - "existing device already has static minor number", - n); - error = -1; - } else - set_bit(n, used_minors); - spin_unlock_irqrestore(&used_minors_lock, flags); - } - - *sysminor = n; - return error; -} - -static int -minor_get(ulong *sysminor, ulong aoemaj, int aoemin) -{ - if (aoe_dyndevs) - return minor_get_dyn(sysminor); - else - return minor_get_static(sysminor, aoemaj, aoemin); -} - -static void -minor_free(ulong minor) +struct aoedev * +aoedev_by_aoeaddr(int maj, int min) { + struct aoedev *d; ulong flags; - minor /= AOE_PARTITIONS; - BUG_ON(minor >= N_DEVS); - - spin_lock_irqsave(&used_minors_lock, flags); - BUG_ON(!test_bit(minor, used_minors)); - clear_bit(minor, used_minors); - spin_unlock_irqrestore(&used_minors_lock, flags); -} - -/* - * Users who grab a pointer to the device with aoedev_by_aoeaddr - * automatically get a reference count and must be responsible - * for performing a aoedev_put. With the addition of async - * kthread processing I'm no longer confident that we can - * guarantee consistency in the face of device flushes. - * - * For the time being, we only bother to add extra references for - * frames sitting on the iocq. When the kthreads finish processing - * these frames, they will aoedev_put the device. - */ + spin_lock_irqsave(&devlist_lock, flags); -void -aoedev_put(struct aoedev *d) -{ - ulong flags; + for (d=devlist; d; d=d->next) + if (d->aoemajor == maj && d->aoeminor == min) + break; - spin_lock_irqsave(&devlist_lock, flags); - d->ref--; spin_unlock_irqrestore(&devlist_lock, flags); + return d; } static void @@ -148,74 +47,54 @@ dummy_timer(ulong vp) add_timer(&d->timer); } -static void -aoe_failip(struct aoedev *d) -{ - struct request *rq; - struct bio *bio; - unsigned long n; - - aoe_failbuf(d, d->ip.buf); - - rq = d->ip.rq; - if (rq == NULL) - return; - while ((bio = d->ip.nxbio)) { - clear_bit(BIO_UPTODATE, &bio->bi_flags); - d->ip.nxbio = bio->bi_next; - n = (unsigned long) rq->special; - rq->special = (void *) --n; - } - if ((unsigned long) rq->special == 0) - aoe_end_request(d, rq, 0); -} - void aoedev_downdev(struct aoedev *d) { - struct aoetgt *t, **tt, **te; - struct frame *f; - struct list_head *head, *pos, *nx; - struct request *rq; - int i; - - d->flags &= ~DEVFL_UP; + struct aoetgt **t, **te; + struct frame *f, *e; + struct buf *buf; + struct bio *bio; - /* clean out active buffers */ - for (i = 0; i < NFACTIVE; i++) { - head = &d->factive[i]; - list_for_each_safe(pos, nx, head) { - f = list_entry(pos, struct frame, head); - list_del(pos); - if (f->buf) { - f->buf->nframesout--; - aoe_failbuf(d, f->buf); + t = d->targets; + te = t + NTARGETS; + for (; t < te && *t; t++) { + f = (*t)->frames; + e = f + (*t)->nframes; + for (; f < e; f->tag = FREETAG, f->buf = NULL, f++) { + if (f->tag == FREETAG || f->buf == NULL) + continue; + buf = f->buf; + bio = buf->bio; + if (--buf->nframesout == 0 + && buf != d->inprocess) { + mempool_free(buf, d->bufpool); + bio_endio(bio, -EIO); } - aoe_freetframe(f); } + (*t)->maxout = (*t)->nframes; + (*t)->nout = 0; } - /* reset window dressings */ - tt = d->targets; - te = tt + NTARGETS; - for (; tt < te && (t = *tt); tt++) { - t->maxout = t->nframes; - t->nout = 0; + buf = d->inprocess; + if (buf) { + bio = buf->bio; + mempool_free(buf, d->bufpool); + bio_endio(bio, -EIO); } - - /* clean out the in-process request (if any) */ - aoe_failip(d); + d->inprocess = NULL; d->htgt = NULL; - /* fast fail all pending I/O */ - if (d->blkq) { - while ((rq = blk_peek_request(d->blkq))) { - blk_start_request(rq); - aoe_end_request(d, rq, 1); - } + while (!list_empty(&d->bufq)) { + buf = container_of(d->bufq.next, struct buf, bufs); + list_del(d->bufq.next); + bio = buf->bio; + mempool_free(buf, d->bufpool); + bio_endio(bio, -EIO); } if (d->gd) set_capacity(d->gd, 0); + + d->flags &= ~DEVFL_UP; } static void @@ -228,7 +107,6 @@ aoedev_freedev(struct aoedev *d) aoedisk_rm_sysfs(d); del_gendisk(d->gd); put_disk(d->gd); - blk_cleanup_queue(d->blkq); } t = d->targets; e = t + NTARGETS; @@ -237,7 +115,7 @@ aoedev_freedev(struct aoedev *d) if (d->bufpool) mempool_destroy(d->bufpool); skbpoolfree(d); - minor_free(d->sysminor); + blk_cleanup_queue(d->blkq); kfree(d); } @@ -264,8 +142,7 @@ aoedev_flush(const char __user *str, size_t cnt) spin_lock(&d->lock); if ((!all && (d->flags & DEVFL_UP)) || (d->flags & (DEVFL_GDALLOC|DEVFL_NEWSIZE)) - || d->nopen - || d->ref) { + || d->nopen) { spin_unlock(&d->lock); dd = &d->next; continue; @@ -286,15 +163,12 @@ aoedev_flush(const char __user *str, size_t cnt) return 0; } -/* This has been confirmed to occur once with Tms=3*1000 due to the - * driver changing link and not processing its transmit ring. The - * problem is hard enough to solve by returning an error that I'm - * still punting on "solving" this. - */ +/* I'm not really sure that this is a realistic problem, but if the +network driver goes gonzo let's just leak memory after complaining. */ static void skbfree(struct sk_buff *skb) { - enum { Sms = 250, Tms = 30 * 1000}; + enum { Sms = 100, Tms = 3*1000}; int i = Tms / Sms; if (skb == NULL) @@ -308,7 +182,6 @@ skbfree(struct sk_buff *skb) "cannot free skb -- memory leaked."); return; } - skb->truesize -= skb->data_len; skb_shinfo(skb)->nr_frags = skb->data_len = 0; skb_trim(skb, 0); dev_kfree_skb(skb); @@ -325,29 +198,26 @@ skbpoolfree(struct aoedev *d) __skb_queue_head_init(&d->skbpool); } -/* find it or allocate it */ +/* find it or malloc it */ struct aoedev * -aoedev_by_aoeaddr(ulong maj, int min, int do_alloc) +aoedev_by_sysminor_m(ulong sysminor) { struct aoedev *d; - int i; ulong flags; - ulong sysminor; spin_lock_irqsave(&devlist_lock, flags); for (d=devlist; d; d=d->next) - if (d->aoemajor == maj && d->aoeminor == min) { - d->ref++; + if (d->sysminor == sysminor) break; - } - if (d || !do_alloc || minor_get(&sysminor, maj, min) < 0) + if (d) goto out; d = kcalloc(1, sizeof *d, GFP_ATOMIC); if (!d) goto out; INIT_WORK(&d->work, aoecmd_sleepwork); spin_lock_init(&d->lock); + skb_queue_head_init(&d->sendq); skb_queue_head_init(&d->skbpool); init_timer(&d->timer); d->timer.data = (ulong) d; @@ -356,12 +226,10 @@ aoedev_by_aoeaddr(ulong maj, int min, int do_alloc) add_timer(&d->timer); d->bufpool = NULL; /* defer to aoeblk_gdalloc */ d->tgt = d->targets; - d->ref = 1; - for (i = 0; i < NFACTIVE; i++) - INIT_LIST_HEAD(&d->factive[i]); + INIT_LIST_HEAD(&d->bufq); d->sysminor = sysminor; - d->aoemajor = maj; - d->aoeminor = min; + d->aoemajor = AOEMAJOR(sysminor); + d->aoeminor = AOEMINOR(sysminor); d->mintimer = MINTIMER; d->next = devlist; devlist = d; @@ -373,23 +241,13 @@ aoedev_by_aoeaddr(ulong maj, int min, int do_alloc) static void freetgt(struct aoedev *d, struct aoetgt *t) { - struct frame *f; - struct list_head *pos, *nx, *head; - struct aoeif *ifp; + struct frame *f, *e; - for (ifp = t->ifs; ifp < &t->ifs[NAOEIFS]; ++ifp) { - if (!ifp->nd) - break; - dev_put(ifp->nd); - } - - head = &t->ffree; - list_for_each_safe(pos, nx, head) { - list_del(pos); - f = list_entry(pos, struct frame, head); + f = t->frames; + e = f + t->nframes; + for (; f < e; f++) skbfree(f->skb); - kfree(f); - } + kfree(t->frames); kfree(t); } @@ -399,7 +257,6 @@ aoedev_exit(void) struct aoedev *d; ulong flags; - aoe_flush_iocq(); while ((d = devlist)) { devlist = d->next; diff --git a/trunk/drivers/block/aoe/aoemain.c b/trunk/drivers/block/aoe/aoemain.c index 04793c2c701b..7f83ad90e76f 100644 --- a/trunk/drivers/block/aoe/aoemain.c +++ b/trunk/drivers/block/aoe/aoemain.c @@ -1,4 +1,4 @@ -/* Copyright (c) 2012 Coraid, Inc. See COPYING for GPL terms. */ +/* Copyright (c) 2007 Coraid, Inc. See COPYING for GPL terms. */ /* * aoemain.c * Module initialization routines, discover timer @@ -61,7 +61,6 @@ aoe_exit(void) aoenet_exit(); unregister_blkdev(AOE_MAJOR, DEVICE_NAME); - aoecmd_exit(); aoechr_exit(); aoedev_exit(); aoeblk_exit(); /* free cache after de-allocating bufs */ @@ -84,20 +83,17 @@ aoe_init(void) ret = aoenet_init(); if (ret) goto net_fail; - ret = aoecmd_init(); - if (ret) - goto cmd_fail; ret = register_blkdev(AOE_MAJOR, DEVICE_NAME); if (ret < 0) { printk(KERN_ERR "aoe: can't register major\n"); goto blkreg_fail; } + printk(KERN_INFO "aoe: AoE v%s initialised.\n", VERSION); discover_timer(TINIT); return 0; + blkreg_fail: - aoecmd_exit(); - cmd_fail: aoenet_exit(); net_fail: aoeblk_exit(); diff --git a/trunk/drivers/block/aoe/aoenet.c b/trunk/drivers/block/aoe/aoenet.c index 162c6471275c..4d3bc0d49df5 100644 --- a/trunk/drivers/block/aoe/aoenet.c +++ b/trunk/drivers/block/aoe/aoenet.c @@ -1,4 +1,4 @@ -/* Copyright (c) 2012 Coraid, Inc. See COPYING for GPL terms. */ +/* Copyright (c) 2007 Coraid, Inc. See COPYING for GPL terms. */ /* * aoenet.c * Ethernet portion of AoE driver @@ -33,9 +33,6 @@ static char aoe_iflist[IFLISTSZ]; module_param_string(aoe_iflist, aoe_iflist, IFLISTSZ, 0600); MODULE_PARM_DESC(aoe_iflist, "aoe_iflist=\"dev1 [dev2 ...]\""); -static wait_queue_head_t txwq; -static struct ktstate kts; - #ifndef MODULE static int __init aoe_iflist_setup(char *str) { @@ -47,23 +44,6 @@ static int __init aoe_iflist_setup(char *str) __setup("aoe_iflist=", aoe_iflist_setup); #endif -static spinlock_t txlock; -static struct sk_buff_head skbtxq; - -/* enters with txlock held */ -static int -tx(void) -{ - struct sk_buff *skb; - - while ((skb = skb_dequeue(&skbtxq))) { - spin_unlock_irq(&txlock); - dev_queue_xmit(skb); - spin_lock_irq(&txlock); - } - return 0; -} - int is_aoe_netif(struct net_device *ifp) { @@ -108,14 +88,10 @@ void aoenet_xmit(struct sk_buff_head *queue) { struct sk_buff *skb, *tmp; - ulong flags; skb_queue_walk_safe(queue, skb, tmp) { __skb_unlink(skb, queue); - spin_lock_irqsave(&txlock, flags); - skb_queue_tail(&skbtxq, skb); - spin_unlock_irqrestore(&txlock, flags); - wake_up(&txwq); + dev_queue_xmit(skb); } } @@ -126,9 +102,7 @@ static int aoenet_rcv(struct sk_buff *skb, struct net_device *ifp, struct packet_type *pt, struct net_device *orig_dev) { struct aoe_hdr *h; - struct aoe_atahdr *ah; u32 n; - int sn; if (dev_net(ifp) != &init_net) goto exit; @@ -136,16 +110,13 @@ aoenet_rcv(struct sk_buff *skb, struct net_device *ifp, struct packet_type *pt, skb = skb_share_check(skb, GFP_ATOMIC); if (skb == NULL) return 0; + if (skb_linearize(skb)) + goto exit; if (!is_aoe_netif(ifp)) goto exit; skb_push(skb, ETH_HLEN); /* (1) */ - sn = sizeof(*h) + sizeof(*ah); - if (skb->len >= sn) { - sn -= skb_headlen(skb); - if (sn > 0 && !__pskb_pull_tail(skb, sn)) - goto exit; - } - h = (struct aoe_hdr *) skb->data; + + h = (struct aoe_hdr *) skb_mac_header(skb); n = get_unaligned_be32(&h->tag); if ((h->verfl & AOEFL_RSP) == 0 || (n & 1<<31)) goto exit; @@ -166,8 +137,7 @@ aoenet_rcv(struct sk_buff *skb, struct net_device *ifp, struct packet_type *pt, switch (h->cmd) { case AOECMD_ATA: - /* ata_rsp may keep skb for later processing or give it back */ - skb = aoecmd_ata_rsp(skb); + aoecmd_ata_rsp(skb); break; case AOECMD_CFG: aoecmd_cfg_rsp(skb); @@ -175,12 +145,8 @@ aoenet_rcv(struct sk_buff *skb, struct net_device *ifp, struct packet_type *pt, default: if (h->cmd >= AOECMD_VEND_MIN) break; /* don't complain about vendor commands */ - pr_info("aoe: unknown AoE command type 0x%02x\n", h->cmd); - break; + printk(KERN_INFO "aoe: unknown cmd %d\n", h->cmd); } - - if (!skb) - return 0; exit: dev_kfree_skb(skb); return 0; @@ -194,15 +160,6 @@ static struct packet_type aoe_pt __read_mostly = { int __init aoenet_init(void) { - skb_queue_head_init(&skbtxq); - init_waitqueue_head(&txwq); - spin_lock_init(&txlock); - kts.lock = &txlock; - kts.fn = tx; - kts.waitq = &txwq; - kts.name = "aoe_tx"; - if (aoe_ktstart(&kts)) - return -EAGAIN; dev_add_pack(&aoe_pt); return 0; } @@ -210,8 +167,6 @@ aoenet_init(void) void aoenet_exit(void) { - aoe_ktstop(&kts); - skb_queue_purge(&skbtxq); dev_remove_pack(&aoe_pt); } diff --git a/trunk/drivers/block/nbd.c b/trunk/drivers/block/nbd.c index 043ddcca4abf..0c03411c59eb 100644 --- a/trunk/drivers/block/nbd.c +++ b/trunk/drivers/block/nbd.c @@ -78,8 +78,6 @@ static const char *ioctl_cmd_to_ascii(int cmd) case NBD_SET_SOCK: return "set-sock"; case NBD_SET_BLKSIZE: return "set-blksize"; case NBD_SET_SIZE: return "set-size"; - case NBD_SET_TIMEOUT: return "set-timeout"; - case NBD_SET_FLAGS: return "set-flags"; case NBD_DO_IT: return "do-it"; case NBD_CLEAR_SOCK: return "clear-sock"; case NBD_CLEAR_QUE: return "clear-que"; @@ -98,7 +96,6 @@ static const char *nbdcmd_to_ascii(int cmd) case NBD_CMD_READ: return "read"; case NBD_CMD_WRITE: return "write"; case NBD_CMD_DISC: return "disconnect"; - case NBD_CMD_TRIM: return "trim/discard"; } return "invalid"; } @@ -470,12 +467,8 @@ static void nbd_handle_req(struct nbd_device *nbd, struct request *req) nbd_cmd(req) = NBD_CMD_READ; if (rq_data_dir(req) == WRITE) { - if ((req->cmd_flags & REQ_DISCARD)) { - WARN_ON(!(nbd->flags & NBD_FLAG_SEND_TRIM)); - nbd_cmd(req) = NBD_CMD_TRIM; - } else - nbd_cmd(req) = NBD_CMD_WRITE; - if (nbd->flags & NBD_FLAG_READ_ONLY) { + nbd_cmd(req) = NBD_CMD_WRITE; + if (nbd->flags & NBD_READ_ONLY) { dev_err(disk_to_dev(nbd->disk), "Write on read-only\n"); goto error_out; @@ -658,10 +651,6 @@ static int __nbd_ioctl(struct block_device *bdev, struct nbd_device *nbd, nbd->xmit_timeout = arg * HZ; return 0; - case NBD_SET_FLAGS: - nbd->flags = arg; - return 0; - case NBD_SET_SIZE_BLOCKS: nbd->bytesize = ((u64) arg) * nbd->blksize; bdev->bd_inode->i_size = nbd->bytesize; @@ -681,10 +670,6 @@ static int __nbd_ioctl(struct block_device *bdev, struct nbd_device *nbd, mutex_unlock(&nbd->tx_lock); - if (nbd->flags & NBD_FLAG_SEND_TRIM) - queue_flag_set_unlocked(QUEUE_FLAG_DISCARD, - nbd->disk->queue); - thread = kthread_create(nbd_thread, nbd, nbd->disk->disk_name); if (IS_ERR(thread)) { mutex_lock(&nbd->tx_lock); @@ -702,7 +687,6 @@ static int __nbd_ioctl(struct block_device *bdev, struct nbd_device *nbd, nbd->file = NULL; nbd_clear_que(nbd); dev_warn(disk_to_dev(nbd->disk), "queue cleared\n"); - queue_flag_clear_unlocked(QUEUE_FLAG_DISCARD, nbd->disk->queue); if (file) fput(file); nbd->bytesize = 0; @@ -821,9 +805,6 @@ static int __init nbd_init(void) * Tell the block layer that we are not a rotational device */ queue_flag_set_unlocked(QUEUE_FLAG_NONROT, disk->queue); - disk->queue->limits.discard_granularity = 512; - disk->queue->limits.max_discard_sectors = UINT_MAX; - disk->queue->limits.discard_zeroes_data = 0; } if (register_blkdev(NBD_MAJOR, "nbd")) { diff --git a/trunk/drivers/block/xen-blkback/blkback.c b/trunk/drivers/block/xen-blkback/blkback.c index 280a13846e6c..c6decb901e5e 100644 --- a/trunk/drivers/block/xen-blkback/blkback.c +++ b/trunk/drivers/block/xen-blkback/blkback.c @@ -42,7 +42,6 @@ #include #include -#include #include #include #include "common.h" diff --git a/trunk/drivers/char/hw_random/mxc-rnga.c b/trunk/drivers/char/hw_random/mxc-rnga.c index f05d85713fd3..85074de5042e 100644 --- a/trunk/drivers/char/hw_random/mxc-rnga.c +++ b/trunk/drivers/char/hw_random/mxc-rnga.c @@ -59,21 +59,16 @@ #define RNGA_STATUS_LAST_READ_STATUS 0x00000002 #define RNGA_STATUS_SECURITY_VIOLATION 0x00000001 -struct mxc_rng { - struct device *dev; - struct hwrng rng; - void __iomem *mem; - struct clk *clk; -}; +static struct platform_device *rng_dev; static int mxc_rnga_data_present(struct hwrng *rng, int wait) { + void __iomem *rng_base = (void __iomem *)rng->priv; int i; - struct mxc_rng *mxc_rng = container_of(rng, struct mxc_rng, rng); for (i = 0; i < 20; i++) { /* how many random numbers are in FIFO? [0-16] */ - int level = (__raw_readl(mxc_rng->mem + RNGA_STATUS) & + int level = (__raw_readl(rng_base + RNGA_STATUS) & RNGA_STATUS_LEVEL_MASK) >> 8; if (level || !wait) return !!level; @@ -86,20 +81,20 @@ static int mxc_rnga_data_read(struct hwrng *rng, u32 * data) { int err; u32 ctrl; - struct mxc_rng *mxc_rng = container_of(rng, struct mxc_rng, rng); + void __iomem *rng_base = (void __iomem *)rng->priv; /* retrieve a random number from FIFO */ - *data = __raw_readl(mxc_rng->mem + RNGA_OUTPUT_FIFO); + *data = __raw_readl(rng_base + RNGA_OUTPUT_FIFO); /* some error while reading this random number? */ - err = __raw_readl(mxc_rng->mem + RNGA_STATUS) & RNGA_STATUS_ERROR_INT; + err = __raw_readl(rng_base + RNGA_STATUS) & RNGA_STATUS_ERROR_INT; /* if error: clear error interrupt, but doesn't return random number */ if (err) { - dev_dbg(mxc_rng->dev, "Error while reading random number!\n"); - ctrl = __raw_readl(mxc_rng->mem + RNGA_CONTROL); + dev_dbg(&rng_dev->dev, "Error while reading random number!\n"); + ctrl = __raw_readl(rng_base + RNGA_CONTROL); __raw_writel(ctrl | RNGA_CONTROL_CLEAR_INT, - mxc_rng->mem + RNGA_CONTROL); + rng_base + RNGA_CONTROL); return 0; } else return 4; @@ -108,22 +103,22 @@ static int mxc_rnga_data_read(struct hwrng *rng, u32 * data) static int mxc_rnga_init(struct hwrng *rng) { u32 ctrl, osc; - struct mxc_rng *mxc_rng = container_of(rng, struct mxc_rng, rng); + void __iomem *rng_base = (void __iomem *)rng->priv; /* wake up */ - ctrl = __raw_readl(mxc_rng->mem + RNGA_CONTROL); - __raw_writel(ctrl & ~RNGA_CONTROL_SLEEP, mxc_rng->mem + RNGA_CONTROL); + ctrl = __raw_readl(rng_base + RNGA_CONTROL); + __raw_writel(ctrl & ~RNGA_CONTROL_SLEEP, rng_base + RNGA_CONTROL); /* verify if oscillator is working */ - osc = __raw_readl(mxc_rng->mem + RNGA_STATUS); + osc = __raw_readl(rng_base + RNGA_STATUS); if (osc & RNGA_STATUS_OSC_DEAD) { - dev_err(mxc_rng->dev, "RNGA Oscillator is dead!\n"); + dev_err(&rng_dev->dev, "RNGA Oscillator is dead!\n"); return -ENODEV; } /* go running */ - ctrl = __raw_readl(mxc_rng->mem + RNGA_CONTROL); - __raw_writel(ctrl | RNGA_CONTROL_GO, mxc_rng->mem + RNGA_CONTROL); + ctrl = __raw_readl(rng_base + RNGA_CONTROL); + __raw_writel(ctrl | RNGA_CONTROL_GO, rng_base + RNGA_CONTROL); return 0; } @@ -131,40 +126,40 @@ static int mxc_rnga_init(struct hwrng *rng) static void mxc_rnga_cleanup(struct hwrng *rng) { u32 ctrl; - struct mxc_rng *mxc_rng = container_of(rng, struct mxc_rng, rng); + void __iomem *rng_base = (void __iomem *)rng->priv; - ctrl = __raw_readl(mxc_rng->mem + RNGA_CONTROL); + ctrl = __raw_readl(rng_base + RNGA_CONTROL); /* stop rnga */ - __raw_writel(ctrl & ~RNGA_CONTROL_GO, mxc_rng->mem + RNGA_CONTROL); + __raw_writel(ctrl & ~RNGA_CONTROL_GO, rng_base + RNGA_CONTROL); } +static struct hwrng mxc_rnga = { + .name = "mxc-rnga", + .init = mxc_rnga_init, + .cleanup = mxc_rnga_cleanup, + .data_present = mxc_rnga_data_present, + .data_read = mxc_rnga_data_read +}; + static int __init mxc_rnga_probe(struct platform_device *pdev) { int err = -ENODEV; + struct clk *clk; struct resource *res, *mem; - struct mxc_rng *mxc_rng; - - mxc_rng = devm_kzalloc(&pdev->dev, sizeof(struct mxc_rng), - GFP_KERNEL); - if (!mxc_rng) - return -ENOMEM; - - mxc_rng->dev = &pdev->dev; - mxc_rng->rng.name = "mxc-rnga"; - mxc_rng->rng.init = mxc_rnga_init; - mxc_rng->rng.cleanup = mxc_rnga_cleanup, - mxc_rng->rng.data_present = mxc_rnga_data_present, - mxc_rng->rng.data_read = mxc_rnga_data_read, - - mxc_rng->clk = devm_clk_get(&pdev->dev, NULL); - if (IS_ERR(mxc_rng->clk)) { + void __iomem *rng_base = NULL; + + if (rng_dev) + return -EBUSY; + + clk = clk_get(&pdev->dev, "rng"); + if (IS_ERR(clk)) { dev_err(&pdev->dev, "Could not get rng_clk!\n"); - err = PTR_ERR(mxc_rng->clk); + err = PTR_ERR(clk); goto out; } - clk_prepare_enable(mxc_rng->clk); + clk_enable(clk); res = platform_get_resource(pdev, IORESOURCE_MEM, 0); if (!res) { @@ -178,27 +173,36 @@ static int __init mxc_rnga_probe(struct platform_device *pdev) goto err_region; } - mxc_rng->mem = ioremap(res->start, resource_size(res)); - if (!mxc_rng->mem) { + rng_base = ioremap(res->start, resource_size(res)); + if (!rng_base) { err = -ENOMEM; goto err_ioremap; } - err = hwrng_register(&mxc_rng->rng); + mxc_rnga.priv = (unsigned long)rng_base; + + err = hwrng_register(&mxc_rnga); if (err) { dev_err(&pdev->dev, "MXC RNGA registering failed (%d)\n", err); - goto err_ioremap; + goto err_register; } + rng_dev = pdev; + dev_info(&pdev->dev, "MXC RNGA Registered.\n"); return 0; +err_register: + iounmap(rng_base); + rng_base = NULL; + err_ioremap: release_mem_region(res->start, resource_size(res)); err_region: - clk_disable_unprepare(mxc_rng->clk); + clk_disable(clk); + clk_put(clk); out: return err; @@ -207,15 +211,17 @@ static int __init mxc_rnga_probe(struct platform_device *pdev) static int __exit mxc_rnga_remove(struct platform_device *pdev) { struct resource *res = platform_get_resource(pdev, IORESOURCE_MEM, 0); - struct mxc_rng *mxc_rng = platform_get_drvdata(pdev); + void __iomem *rng_base = (void __iomem *)mxc_rnga.priv; + struct clk *clk = clk_get(&pdev->dev, "rng"); - hwrng_unregister(&mxc_rng->rng); + hwrng_unregister(&mxc_rnga); - iounmap(mxc_rng->mem); + iounmap(rng_base); release_mem_region(res->start, resource_size(res)); - clk_disable_unprepare(mxc_rng->clk); + clk_disable(clk); + clk_put(clk); return 0; } diff --git a/trunk/drivers/char/hw_random/octeon-rng.c b/trunk/drivers/char/hw_random/octeon-rng.c index 5c34c092af71..0943edc782a1 100644 --- a/trunk/drivers/char/hw_random/octeon-rng.c +++ b/trunk/drivers/char/hw_random/octeon-rng.c @@ -75,35 +75,42 @@ static int __devinit octeon_rng_probe(struct platform_device *pdev) res_ports = platform_get_resource(pdev, IORESOURCE_MEM, 0); if (!res_ports) - return -ENOENT; + goto err_ports; res_result = platform_get_resource(pdev, IORESOURCE_MEM, 1); if (!res_result) - return -ENOENT; + goto err_ports; rng->control_status = devm_ioremap_nocache(&pdev->dev, res_ports->start, sizeof(u64)); if (!rng->control_status) - return -ENOENT; + goto err_ports; rng->result = devm_ioremap_nocache(&pdev->dev, res_result->start, sizeof(u64)); if (!rng->result) - return -ENOENT; + goto err_r; rng->ops = ops; dev_set_drvdata(&pdev->dev, &rng->ops); ret = hwrng_register(&rng->ops); if (ret) - return -ENOENT; + goto err; dev_info(&pdev->dev, "Octeon Random Number Generator\n"); return 0; +err: + devm_iounmap(&pdev->dev, rng->control_status); +err_r: + devm_iounmap(&pdev->dev, rng->result); +err_ports: + devm_kfree(&pdev->dev, rng); + return -ENOENT; } static int __exit octeon_rng_remove(struct platform_device *pdev) diff --git a/trunk/drivers/char/mbcs.c b/trunk/drivers/char/mbcs.c index 0c7d340b9ab9..47ff7e470d87 100644 --- a/trunk/drivers/char/mbcs.c +++ b/trunk/drivers/char/mbcs.c @@ -799,7 +799,7 @@ static int mbcs_remove(struct cx_dev *dev) return 0; } -static const struct cx_device_id __devinitconst mbcs_id_table[] = { +static const struct cx_device_id __devinitdata mbcs_id_table[] = { { .part_num = MBCS_PART_NUM, .mfg_num = MBCS_MFG_NUM, diff --git a/trunk/drivers/crypto/Kconfig b/trunk/drivers/crypto/Kconfig index 308c7fb92a60..7d74d092aa8f 100644 --- a/trunk/drivers/crypto/Kconfig +++ b/trunk/drivers/crypto/Kconfig @@ -298,15 +298,21 @@ config CRYPTO_DEV_TEGRA_AES will be called tegra-aes. config CRYPTO_DEV_NX - bool "Support for IBM Power7+ in-Nest cryptographic acceleration" + tristate "Support for Power7+ in-Nest cryptographic acceleration" depends on PPC64 && IBMVIO - default n + select CRYPTO_AES + select CRYPTO_CBC + select CRYPTO_ECB + select CRYPTO_CCM + select CRYPTO_GCM + select CRYPTO_AUTHENC + select CRYPTO_XCBC + select CRYPTO_SHA256 + select CRYPTO_SHA512 help - Support for Power7+ in-Nest cryptographic acceleration. - -if CRYPTO_DEV_NX - source "drivers/crypto/nx/Kconfig" -endif + Support for Power7+ in-Nest cryptographic acceleration. This + module supports acceleration for AES and SHA2 algorithms. If you + choose 'M' here, this module will be called nx_crypto. config CRYPTO_DEV_UX500 tristate "Driver for ST-Ericsson UX500 crypto hardware acceleration" @@ -334,7 +340,7 @@ config CRYPTO_DEV_ATMEL_AES select CRYPTO_AES select CRYPTO_ALGAPI select CRYPTO_BLKCIPHER - select AT_HDMAC + select CONFIG_AT_HDMAC help Some Atmel processors have AES hw accelerator. Select this if you want to use the Atmel module for diff --git a/trunk/drivers/crypto/amcc/crypto4xx_core.c b/trunk/drivers/crypto/amcc/crypto4xx_core.c index f88e3d8f6b64..802e85102c32 100644 --- a/trunk/drivers/crypto/amcc/crypto4xx_core.c +++ b/trunk/drivers/crypto/amcc/crypto4xx_core.c @@ -1226,7 +1226,6 @@ static int __init crypto4xx_probe(struct platform_device *ofdev) core_dev->dev->ce_base = of_iomap(ofdev->dev.of_node, 0); if (!core_dev->dev->ce_base) { dev_err(dev, "failed to of_iomap\n"); - rc = -ENOMEM; goto err_iomap; } diff --git a/trunk/drivers/crypto/atmel-aes.c b/trunk/drivers/crypto/atmel-aes.c index 8061336e07e7..6bb20fffbf49 100644 --- a/trunk/drivers/crypto/atmel-aes.c +++ b/trunk/drivers/crypto/atmel-aes.c @@ -24,10 +24,15 @@ #include #include +#include #include #include #include +#include +#include #include +#include +#include #include #include #include @@ -1012,6 +1017,7 @@ static int atmel_aes_register_algs(struct atmel_aes_dev *dd) int err, i, j; for (i = 0; i < ARRAY_SIZE(aes_algs); i++) { + INIT_LIST_HEAD(&aes_algs[i].cra_list); err = crypto_register_alg(&aes_algs[i]); if (err) goto err_aes_algs; @@ -1020,6 +1026,7 @@ static int atmel_aes_register_algs(struct atmel_aes_dev *dd) atmel_aes_hw_version_init(dd); if (dd->hw_version >= 0x130) { + INIT_LIST_HEAD(&aes_cfb64_alg[0].cra_list); err = crypto_register_alg(&aes_cfb64_alg[0]); if (err) goto err_aes_cfb64_alg; diff --git a/trunk/drivers/crypto/atmel-sha.c b/trunk/drivers/crypto/atmel-sha.c index bcdf55fdc623..f938b9d79b66 100644 --- a/trunk/drivers/crypto/atmel-sha.c +++ b/trunk/drivers/crypto/atmel-sha.c @@ -24,10 +24,15 @@ #include #include +#include #include #include #include +#include +#include #include +#include +#include #include #include #include diff --git a/trunk/drivers/crypto/atmel-tdes.c b/trunk/drivers/crypto/atmel-tdes.c index 7495f98c7221..eb2b61e57e2d 100644 --- a/trunk/drivers/crypto/atmel-tdes.c +++ b/trunk/drivers/crypto/atmel-tdes.c @@ -24,10 +24,15 @@ #include #include +#include #include #include #include +#include +#include #include +#include +#include #include #include #include @@ -1039,6 +1044,7 @@ static int atmel_tdes_register_algs(struct atmel_tdes_dev *dd) int err, i, j; for (i = 0; i < ARRAY_SIZE(tdes_algs); i++) { + INIT_LIST_HEAD(&tdes_algs[i].cra_list); err = crypto_register_alg(&tdes_algs[i]); if (err) goto err_tdes_algs; diff --git a/trunk/drivers/crypto/caam/caamalg.c b/trunk/drivers/crypto/caam/caamalg.c index b2a0a0726a54..0c1ea8492eff 100644 --- a/trunk/drivers/crypto/caam/caamalg.c +++ b/trunk/drivers/crypto/caam/caamalg.c @@ -205,7 +205,7 @@ static void init_sh_desc_key_aead(u32 *desc, struct caam_ctx *ctx, { u32 *key_jump_cmd; - init_sh_desc(desc, HDR_SHARE_SERIAL); + init_sh_desc(desc, HDR_SHARE_WAIT); /* Skip if already shared */ key_jump_cmd = append_jump(desc, JUMP_JSL | JUMP_TEST_ALL | @@ -224,7 +224,7 @@ static int aead_set_sh_desc(struct crypto_aead *aead) struct aead_tfm *tfm = &aead->base.crt_aead; struct caam_ctx *ctx = crypto_aead_ctx(aead); struct device *jrdev = ctx->jrdev; - bool keys_fit_inline = false; + bool keys_fit_inline = 0; u32 *key_jump_cmd, *jump_cmd; u32 geniv, moveiv; u32 *desc; @@ -239,7 +239,7 @@ static int aead_set_sh_desc(struct crypto_aead *aead) if (DESC_AEAD_ENC_LEN + DESC_JOB_IO_LEN + ctx->split_key_pad_len + ctx->enckeylen <= CAAM_DESC_BYTES_MAX) - keys_fit_inline = true; + keys_fit_inline = 1; /* aead_encrypt shared descriptor */ desc = ctx->sh_desc_enc; @@ -297,12 +297,12 @@ static int aead_set_sh_desc(struct crypto_aead *aead) if (DESC_AEAD_DEC_LEN + DESC_JOB_IO_LEN + ctx->split_key_pad_len + ctx->enckeylen <= CAAM_DESC_BYTES_MAX) - keys_fit_inline = true; + keys_fit_inline = 1; desc = ctx->sh_desc_dec; /* aead_decrypt shared descriptor */ - init_sh_desc(desc, HDR_SHARE_SERIAL); + init_sh_desc(desc, HDR_SHARE_WAIT); /* Skip if already shared */ key_jump_cmd = append_jump(desc, JUMP_JSL | JUMP_TEST_ALL | @@ -365,7 +365,7 @@ static int aead_set_sh_desc(struct crypto_aead *aead) if (DESC_AEAD_GIVENC_LEN + DESC_JOB_IO_LEN + ctx->split_key_pad_len + ctx->enckeylen <= CAAM_DESC_BYTES_MAX) - keys_fit_inline = true; + keys_fit_inline = 1; /* aead_givencrypt shared descriptor */ desc = ctx->sh_desc_givenc; @@ -564,7 +564,7 @@ static int ablkcipher_setkey(struct crypto_ablkcipher *ablkcipher, /* ablkcipher_encrypt shared descriptor */ desc = ctx->sh_desc_enc; - init_sh_desc(desc, HDR_SHARE_SERIAL); + init_sh_desc(desc, HDR_SHARE_WAIT); /* Skip if already shared */ key_jump_cmd = append_jump(desc, JUMP_JSL | JUMP_TEST_ALL | JUMP_COND_SHRD); @@ -605,7 +605,7 @@ static int ablkcipher_setkey(struct crypto_ablkcipher *ablkcipher, /* ablkcipher_decrypt shared descriptor */ desc = ctx->sh_desc_dec; - init_sh_desc(desc, HDR_SHARE_SERIAL); + init_sh_desc(desc, HDR_SHARE_WAIT); /* Skip if already shared */ key_jump_cmd = append_jump(desc, JUMP_JSL | JUMP_TEST_ALL | JUMP_COND_SHRD); @@ -1354,10 +1354,10 @@ static struct aead_edesc *aead_giv_edesc_alloc(struct aead_givcrypt_request contig &= ~GIV_SRC_CONTIG; if (dst_nents || iv_dma + ivsize != sg_dma_address(req->dst)) contig &= ~GIV_DST_CONTIG; - if (unlikely(req->src != req->dst)) { - dst_nents = dst_nents ? : 1; - sec4_sg_len += 1; - } + if (unlikely(req->src != req->dst)) { + dst_nents = dst_nents ? : 1; + sec4_sg_len += 1; + } if (!(contig & GIV_SRC_CONTIG)) { assoc_nents = assoc_nents ? : 1; src_nents = src_nents ? : 1; @@ -1650,11 +1650,7 @@ struct caam_alg_template { }; static struct caam_alg_template driver_algs[] = { - /* - * single-pass ipsec_esp descriptor - * authencesn(*,*) is also registered, although not present - * explicitly here. - */ + /* single-pass ipsec_esp descriptor */ { .name = "authenc(hmac(md5),cbc(aes))", .driver_name = "authenc-hmac-md5-cbc-aes-caam", @@ -2217,9 +2213,7 @@ static int __init caam_algapi_init(void) for (i = 0; i < ARRAY_SIZE(driver_algs); i++) { /* TODO: check if h/w supports alg */ struct caam_crypto_alg *t_alg; - bool done = false; -authencesn: t_alg = caam_alg_alloc(ctrldev, &driver_algs[i]); if (IS_ERR(t_alg)) { err = PTR_ERR(t_alg); @@ -2233,25 +2227,8 @@ static int __init caam_algapi_init(void) dev_warn(ctrldev, "%s alg registration failed\n", t_alg->crypto_alg.cra_driver_name); kfree(t_alg); - } else { + } else list_add_tail(&t_alg->entry, &priv->alg_list); - if (driver_algs[i].type == CRYPTO_ALG_TYPE_AEAD && - !memcmp(driver_algs[i].name, "authenc", 7) && - !done) { - char *name; - - name = driver_algs[i].name; - memmove(name + 10, name + 7, strlen(name) - 7); - memcpy(name + 7, "esn", 3); - - name = driver_algs[i].driver_name; - memmove(name + 10, name + 7, strlen(name) - 7); - memcpy(name + 7, "esn", 3); - - done = true; - goto authencesn; - } - } } if (!list_empty(&priv->alg_list)) dev_info(ctrldev, "%s algorithms registered in /proc/crypto\n", diff --git a/trunk/drivers/crypto/caam/caamhash.c b/trunk/drivers/crypto/caam/caamhash.c index 32aba7a61503..895aaf2bca92 100644 --- a/trunk/drivers/crypto/caam/caamhash.c +++ b/trunk/drivers/crypto/caam/caamhash.c @@ -225,7 +225,7 @@ static inline void init_sh_desc_key_ahash(u32 *desc, struct caam_hash_ctx *ctx) { u32 *key_jump_cmd; - init_sh_desc(desc, HDR_SHARE_SERIAL); + init_sh_desc(desc, HDR_SHARE_WAIT); if (ctx->split_key_len) { /* Skip if already shared */ @@ -311,7 +311,7 @@ static int ahash_set_sh_desc(struct crypto_ahash *ahash) /* ahash_update shared descriptor */ desc = ctx->sh_desc_update; - init_sh_desc(desc, HDR_SHARE_SERIAL); + init_sh_desc(desc, HDR_SHARE_WAIT); /* Import context from software */ append_cmd(desc, CMD_SEQ_LOAD | LDST_SRCDST_BYTE_CONTEXT | @@ -430,10 +430,6 @@ static u32 hash_digest_key(struct caam_hash_ctx *ctx, const u8 *key_in, int ret = 0; desc = kmalloc(CAAM_CMD_SZ * 6 + CAAM_PTR_SZ * 2, GFP_KERNEL | GFP_DMA); - if (!desc) { - dev_err(jrdev, "unable to allocate key input memory\n"); - return -ENOMEM; - } init_job_desc(desc, 0); @@ -1740,11 +1736,8 @@ static void __exit caam_algapi_hash_exit(void) struct caam_hash_alg *t_alg, *n; dev_node = of_find_compatible_node(NULL, NULL, "fsl,sec-v4.0"); - if (!dev_node) { - dev_node = of_find_compatible_node(NULL, NULL, "fsl,sec4.0"); - if (!dev_node) - return; - } + if (!dev_node) + return; pdev = of_find_device_by_node(dev_node); if (!pdev) @@ -1819,11 +1812,8 @@ static int __init caam_algapi_hash_init(void) int i = 0, err = 0; dev_node = of_find_compatible_node(NULL, NULL, "fsl,sec-v4.0"); - if (!dev_node) { - dev_node = of_find_compatible_node(NULL, NULL, "fsl,sec4.0"); - if (!dev_node) - return -ENODEV; - } + if (!dev_node) + return -ENODEV; pdev = of_find_device_by_node(dev_node); if (!pdev) diff --git a/trunk/drivers/crypto/caam/caamrng.c b/trunk/drivers/crypto/caam/caamrng.c index d1939a9539c0..e2bfe161dece 100644 --- a/trunk/drivers/crypto/caam/caamrng.c +++ b/trunk/drivers/crypto/caam/caamrng.c @@ -193,7 +193,7 @@ static inline void rng_create_sh_desc(struct caam_rng_ctx *ctx) struct device *jrdev = ctx->jrdev; u32 *desc = ctx->sh_desc; - init_sh_desc(desc, HDR_SHARE_SERIAL); + init_sh_desc(desc, HDR_SHARE_WAIT); /* Propagate errors from shared to job descriptor */ append_cmd(desc, SET_OK_NO_PROP_ERRORS | CMD_LOAD); @@ -284,11 +284,8 @@ static int __init caam_rng_init(void) struct caam_drv_private *priv; dev_node = of_find_compatible_node(NULL, NULL, "fsl,sec-v4.0"); - if (!dev_node) { - dev_node = of_find_compatible_node(NULL, NULL, "fsl,sec4.0"); - if (!dev_node) - return -ENODEV; - } + if (!dev_node) + return -ENODEV; pdev = of_find_device_by_node(dev_node); if (!pdev) diff --git a/trunk/drivers/crypto/caam/compat.h b/trunk/drivers/crypto/caam/compat.h index cf15e7813801..762aeff626ac 100644 --- a/trunk/drivers/crypto/caam/compat.h +++ b/trunk/drivers/crypto/caam/compat.h @@ -23,7 +23,6 @@ #include #include #include -#include #include #include diff --git a/trunk/drivers/crypto/caam/ctrl.c b/trunk/drivers/crypto/caam/ctrl.c index bf20dd891705..414ba20c05a1 100644 --- a/trunk/drivers/crypto/caam/ctrl.c +++ b/trunk/drivers/crypto/caam/ctrl.c @@ -129,7 +129,7 @@ static int instantiate_rng(struct device *jrdev) /* * By default, the TRNG runs for 200 clocks per sample; - * 1600 clocks per sample generates better entropy. + * 800 clocks per sample generates better entropy. */ static void kick_trng(struct platform_device *pdev) { @@ -144,9 +144,9 @@ static void kick_trng(struct platform_device *pdev) /* put RNG4 into program mode */ setbits32(&r4tst->rtmctl, RTMCTL_PRGM); - /* 1600 clocks per sample */ + /* 800 clocks per sample */ val = rd_reg32(&r4tst->rtsdctl); - val = (val & ~RTSDCTL_ENT_DLY_MASK) | (1600 << RTSDCTL_ENT_DLY_SHIFT); + val = (val & ~RTSDCTL_ENT_DLY_MASK) | (800 << RTSDCTL_ENT_DLY_SHIFT); wr_reg32(&r4tst->rtsdctl, val); /* min. freq. count */ wr_reg32(&r4tst->rtfrqmin, 400); diff --git a/trunk/drivers/crypto/caam/error.c b/trunk/drivers/crypto/caam/error.c index 30b8f74833d4..9955ed9643e6 100644 --- a/trunk/drivers/crypto/caam/error.c +++ b/trunk/drivers/crypto/caam/error.c @@ -77,8 +77,10 @@ static void report_ccb_status(u32 status, char *outstr) "Not instantiated", "Test instantiate", "Prediction resistance", + "", "Prediction resistance and test request", "Uninstantiate", + "", "Secure key generation", }; u8 cha_id = (status & JRSTA_CCBERR_CHAID_MASK) >> diff --git a/trunk/drivers/crypto/caam/key_gen.c b/trunk/drivers/crypto/caam/key_gen.c index f6dba10246c3..d216cd3cc569 100644 --- a/trunk/drivers/crypto/caam/key_gen.c +++ b/trunk/drivers/crypto/caam/key_gen.c @@ -54,10 +54,6 @@ u32 gen_split_key(struct device *jrdev, u8 *key_out, int split_key_len, int ret = 0; desc = kmalloc(CAAM_CMD_SZ * 6 + CAAM_PTR_SZ * 2, GFP_KERNEL | GFP_DMA); - if (!desc) { - dev_err(jrdev, "unable to allocate key input memory\n"); - return -ENOMEM; - } init_job_desc(desc, 0); diff --git a/trunk/drivers/crypto/geode-aes.c b/trunk/drivers/crypto/geode-aes.c index 51f196d77f21..f3e36c86b6c3 100644 --- a/trunk/drivers/crypto/geode-aes.c +++ b/trunk/drivers/crypto/geode-aes.c @@ -289,6 +289,7 @@ static struct crypto_alg geode_alg = { .cra_blocksize = AES_MIN_BLOCK_SIZE, .cra_ctxsize = sizeof(struct geode_aes_op), .cra_module = THIS_MODULE, + .cra_list = LIST_HEAD_INIT(geode_alg.cra_list), .cra_u = { .cipher = { .cia_min_keysize = AES_MIN_KEY_SIZE, @@ -401,6 +402,7 @@ static struct crypto_alg geode_cbc_alg = { .cra_alignmask = 15, .cra_type = &crypto_blkcipher_type, .cra_module = THIS_MODULE, + .cra_list = LIST_HEAD_INIT(geode_cbc_alg.cra_list), .cra_u = { .blkcipher = { .min_keysize = AES_MIN_KEY_SIZE, @@ -487,6 +489,7 @@ static struct crypto_alg geode_ecb_alg = { .cra_alignmask = 15, .cra_type = &crypto_blkcipher_type, .cra_module = THIS_MODULE, + .cra_list = LIST_HEAD_INIT(geode_ecb_alg.cra_list), .cra_u = { .blkcipher = { .min_keysize = AES_MIN_KEY_SIZE, @@ -585,8 +588,21 @@ static struct pci_driver geode_aes_driver = { .remove = __devexit_p(geode_aes_remove) }; -module_pci_driver(geode_aes_driver); +static int __init +geode_aes_init(void) +{ + return pci_register_driver(&geode_aes_driver); +} + +static void __exit +geode_aes_exit(void) +{ + pci_unregister_driver(&geode_aes_driver); +} MODULE_AUTHOR("Advanced Micro Devices, Inc."); MODULE_DESCRIPTION("Geode LX Hardware AES driver"); MODULE_LICENSE("GPL"); + +module_init(geode_aes_init); +module_exit(geode_aes_exit); diff --git a/trunk/drivers/crypto/hifn_795x.c b/trunk/drivers/crypto/hifn_795x.c index fda32968a66b..df14358d7fa1 100644 --- a/trunk/drivers/crypto/hifn_795x.c +++ b/trunk/drivers/crypto/hifn_795x.c @@ -2611,17 +2611,14 @@ static int __devinit hifn_probe(struct pci_dev *pdev, const struct pci_device_id size = pci_resource_len(pdev, i); dev->bar[i] = ioremap_nocache(addr, size); - if (!dev->bar[i]) { - err = -ENOMEM; + if (!dev->bar[i]) goto err_out_unmap_bars; - } } dev->desc_virt = pci_alloc_consistent(pdev, sizeof(struct hifn_dma), &dev->desc_dma); if (!dev->desc_virt) { dprintk("Failed to allocate descriptor rings.\n"); - err = -ENOMEM; goto err_out_unmap_bars; } memset(dev->desc_virt, 0, sizeof(struct hifn_dma)); diff --git a/trunk/drivers/crypto/nx/Kconfig b/trunk/drivers/crypto/nx/Kconfig deleted file mode 100644 index f82616621ae1..000000000000 --- a/trunk/drivers/crypto/nx/Kconfig +++ /dev/null @@ -1,26 +0,0 @@ -config CRYPTO_DEV_NX_ENCRYPT - tristate "Encryption acceleration support" - depends on PPC64 && IBMVIO - default y - select CRYPTO_AES - select CRYPTO_CBC - select CRYPTO_ECB - select CRYPTO_CCM - select CRYPTO_GCM - select CRYPTO_AUTHENC - select CRYPTO_XCBC - select CRYPTO_SHA256 - select CRYPTO_SHA512 - help - Support for Power7+ in-Nest encryption acceleration. This - module supports acceleration for AES and SHA2 algorithms. If you - choose 'M' here, this module will be called nx_crypto. - -config CRYPTO_DEV_NX_COMPRESS - tristate "Compression acceleration support" - depends on PPC64 && IBMVIO - default y - help - Support for Power7+ in-Nest compression acceleration. This - module supports acceleration for AES and SHA2 algorithms. If you - choose 'M' here, this module will be called nx_compress. diff --git a/trunk/drivers/crypto/nx/Makefile b/trunk/drivers/crypto/nx/Makefile index bb770ea45ce9..411ce59c80d1 100644 --- a/trunk/drivers/crypto/nx/Makefile +++ b/trunk/drivers/crypto/nx/Makefile @@ -1,4 +1,4 @@ -obj-$(CONFIG_CRYPTO_DEV_NX_ENCRYPT) += nx-crypto.o +obj-$(CONFIG_CRYPTO_DEV_NX) += nx-crypto.o nx-crypto-objs := nx.o \ nx_debugfs.o \ nx-aes-cbc.o \ @@ -9,6 +9,3 @@ nx-crypto-objs := nx.o \ nx-aes-xcbc.o \ nx-sha256.o \ nx-sha512.o - -obj-$(CONFIG_CRYPTO_DEV_NX_COMPRESS) += nx-compress.o -nx-compress-objs := nx-842.o diff --git a/trunk/drivers/crypto/nx/nx-842.c b/trunk/drivers/crypto/nx/nx-842.c deleted file mode 100644 index 0ce625738677..000000000000 --- a/trunk/drivers/crypto/nx/nx-842.c +++ /dev/null @@ -1,1617 +0,0 @@ -/* - * Driver for IBM Power 842 compression accelerator - * - * 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, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * Copyright (C) IBM Corporation, 2012 - * - * Authors: Robert Jennings - * Seth Jennings - */ - -#include -#include -#include -#include -#include - -#include -#include -#include - -#include "nx_csbcpb.h" /* struct nx_csbcpb */ - -#define MODULE_NAME "nx-compress" -MODULE_LICENSE("GPL"); -MODULE_AUTHOR("Robert Jennings "); -MODULE_DESCRIPTION("842 H/W Compression driver for IBM Power processors"); - -#define SHIFT_4K 12 -#define SHIFT_64K 16 -#define SIZE_4K (1UL << SHIFT_4K) -#define SIZE_64K (1UL << SHIFT_64K) - -/* IO buffer must be 128 byte aligned */ -#define IO_BUFFER_ALIGN 128 - -struct nx842_header { - int blocks_nr; /* number of compressed blocks */ - int offset; /* offset of the first block (from beginning of header) */ - int sizes[0]; /* size of compressed blocks */ -}; - -static inline int nx842_header_size(const struct nx842_header *hdr) -{ - return sizeof(struct nx842_header) + - hdr->blocks_nr * sizeof(hdr->sizes[0]); -} - -/* Macros for fields within nx_csbcpb */ -/* Check the valid bit within the csbcpb valid field */ -#define NX842_CSBCBP_VALID_CHK(x) (x & BIT_MASK(7)) - -/* CE macros operate on the completion_extension field bits in the csbcpb. - * CE0 0=full completion, 1=partial completion - * CE1 0=CE0 indicates completion, 1=termination (output may be modified) - * CE2 0=processed_bytes is source bytes, 1=processed_bytes is target bytes */ -#define NX842_CSBCPB_CE0(x) (x & BIT_MASK(7)) -#define NX842_CSBCPB_CE1(x) (x & BIT_MASK(6)) -#define NX842_CSBCPB_CE2(x) (x & BIT_MASK(5)) - -/* The NX unit accepts data only on 4K page boundaries */ -#define NX842_HW_PAGE_SHIFT SHIFT_4K -#define NX842_HW_PAGE_SIZE (ASM_CONST(1) << NX842_HW_PAGE_SHIFT) -#define NX842_HW_PAGE_MASK (~(NX842_HW_PAGE_SIZE-1)) - -enum nx842_status { - UNAVAILABLE, - AVAILABLE -}; - -struct ibm_nx842_counters { - atomic64_t comp_complete; - atomic64_t comp_failed; - atomic64_t decomp_complete; - atomic64_t decomp_failed; - atomic64_t swdecomp; - atomic64_t comp_times[32]; - atomic64_t decomp_times[32]; -}; - -static struct nx842_devdata { - struct vio_dev *vdev; - struct device *dev; - struct ibm_nx842_counters *counters; - unsigned int max_sg_len; - unsigned int max_sync_size; - unsigned int max_sync_sg; - enum nx842_status status; -} __rcu *devdata; -static DEFINE_SPINLOCK(devdata_mutex); - -#define NX842_COUNTER_INC(_x) \ -static inline void nx842_inc_##_x( \ - const struct nx842_devdata *dev) { \ - if (dev) \ - atomic64_inc(&dev->counters->_x); \ -} -NX842_COUNTER_INC(comp_complete); -NX842_COUNTER_INC(comp_failed); -NX842_COUNTER_INC(decomp_complete); -NX842_COUNTER_INC(decomp_failed); -NX842_COUNTER_INC(swdecomp); - -#define NX842_HIST_SLOTS 16 - -static void ibm_nx842_incr_hist(atomic64_t *times, unsigned int time) -{ - int bucket = fls(time); - - if (bucket) - bucket = min((NX842_HIST_SLOTS - 1), bucket - 1); - - atomic64_inc(×[bucket]); -} - -/* NX unit operation flags */ -#define NX842_OP_COMPRESS 0x0 -#define NX842_OP_CRC 0x1 -#define NX842_OP_DECOMPRESS 0x2 -#define NX842_OP_COMPRESS_CRC (NX842_OP_COMPRESS | NX842_OP_CRC) -#define NX842_OP_DECOMPRESS_CRC (NX842_OP_DECOMPRESS | NX842_OP_CRC) -#define NX842_OP_ASYNC (1<<23) -#define NX842_OP_NOTIFY (1<<22) -#define NX842_OP_NOTIFY_INT(x) ((x & 0xff)<<8) - -static unsigned long nx842_get_desired_dma(struct vio_dev *viodev) -{ - /* No use of DMA mappings within the driver. */ - return 0; -} - -struct nx842_slentry { - unsigned long ptr; /* Real address (use __pa()) */ - unsigned long len; -}; - -/* pHyp scatterlist entry */ -struct nx842_scatterlist { - int entry_nr; /* number of slentries */ - struct nx842_slentry *entries; /* ptr to array of slentries */ -}; - -/* Does not include sizeof(entry_nr) in the size */ -static inline unsigned long nx842_get_scatterlist_size( - struct nx842_scatterlist *sl) -{ - return sl->entry_nr * sizeof(struct nx842_slentry); -} - -static int nx842_build_scatterlist(unsigned long buf, int len, - struct nx842_scatterlist *sl) -{ - unsigned long nextpage; - struct nx842_slentry *entry; - - sl->entry_nr = 0; - - entry = sl->entries; - while (len) { - entry->ptr = __pa(buf); - nextpage = ALIGN(buf + 1, NX842_HW_PAGE_SIZE); - if (nextpage < buf + len) { - /* we aren't at the end yet */ - if (IS_ALIGNED(buf, NX842_HW_PAGE_SIZE)) - /* we are in the middle (or beginning) */ - entry->len = NX842_HW_PAGE_SIZE; - else - /* we are at the beginning */ - entry->len = nextpage - buf; - } else { - /* at the end */ - entry->len = len; - } - - len -= entry->len; - buf += entry->len; - sl->entry_nr++; - entry++; - } - - return 0; -} - -/* - * Working memory for software decompression - */ -struct sw842_fifo { - union { - char f8[256][8]; - char f4[512][4]; - }; - char f2[256][2]; - unsigned char f84_full; - unsigned char f2_full; - unsigned char f8_count; - unsigned char f2_count; - unsigned int f4_count; -}; - -/* - * Working memory for crypto API - */ -struct nx842_workmem { - char bounce[PAGE_SIZE]; /* bounce buffer for decompression input */ - union { - /* hardware working memory */ - struct { - /* scatterlist */ - char slin[SIZE_4K]; - char slout[SIZE_4K]; - /* coprocessor status/parameter block */ - struct nx_csbcpb csbcpb; - }; - /* software working memory */ - struct sw842_fifo swfifo; /* software decompression fifo */ - }; -}; - -int nx842_get_workmem_size(void) -{ - return sizeof(struct nx842_workmem) + NX842_HW_PAGE_SIZE; -} -EXPORT_SYMBOL_GPL(nx842_get_workmem_size); - -int nx842_get_workmem_size_aligned(void) -{ - return sizeof(struct nx842_workmem); -} -EXPORT_SYMBOL_GPL(nx842_get_workmem_size_aligned); - -static int nx842_validate_result(struct device *dev, - struct cop_status_block *csb) -{ - /* The csb must be valid after returning from vio_h_cop_sync */ - if (!NX842_CSBCBP_VALID_CHK(csb->valid)) { - dev_err(dev, "%s: cspcbp not valid upon completion.\n", - __func__); - dev_dbg(dev, "valid:0x%02x cs:0x%02x cc:0x%02x ce:0x%02x\n", - csb->valid, - csb->crb_seq_number, - csb->completion_code, - csb->completion_extension); - dev_dbg(dev, "processed_bytes:%d address:0x%016lx\n", - csb->processed_byte_count, - (unsigned long)csb->address); - return -EIO; - } - - /* Check return values from the hardware in the CSB */ - switch (csb->completion_code) { - case 0: /* Completed without error */ - break; - case 64: /* Target bytes > Source bytes during compression */ - case 13: /* Output buffer too small */ - dev_dbg(dev, "%s: Compression output larger than input\n", - __func__); - return -ENOSPC; - case 66: /* Input data contains an illegal template field */ - case 67: /* Template indicates data past the end of the input stream */ - dev_dbg(dev, "%s: Bad data for decompression (code:%d)\n", - __func__, csb->completion_code); - return -EINVAL; - default: - dev_dbg(dev, "%s: Unspecified error (code:%d)\n", - __func__, csb->completion_code); - return -EIO; - } - - /* Hardware sanity check */ - if (!NX842_CSBCPB_CE2(csb->completion_extension)) { - dev_err(dev, "%s: No error returned by hardware, but " - "data returned is unusable, contact support.\n" - "(Additional info: csbcbp->processed bytes " - "does not specify processed bytes for the " - "target buffer.)\n", __func__); - return -EIO; - } - - return 0; -} - -/** - * nx842_compress - Compress data using the 842 algorithm - * - * Compression provide by the NX842 coprocessor on IBM Power systems. - * The input buffer is compressed and the result is stored in the - * provided output buffer. - * - * Upon return from this function @outlen contains the length of the - * compressed data. If there is an error then @outlen will be 0 and an - * error will be specified by the return code from this function. - * - * @in: Pointer to input buffer, must be page aligned - * @inlen: Length of input buffer, must be PAGE_SIZE - * @out: Pointer to output buffer - * @outlen: Length of output buffer - * @wrkmem: ptr to buffer for working memory, size determined by - * nx842_get_workmem_size() - * - * Returns: - * 0 Success, output of length @outlen stored in the buffer at @out - * -ENOMEM Unable to allocate internal buffers - * -ENOSPC Output buffer is to small - * -EMSGSIZE XXX Difficult to describe this limitation - * -EIO Internal error - * -ENODEV Hardware unavailable - */ -int nx842_compress(const unsigned char *in, unsigned int inlen, - unsigned char *out, unsigned int *outlen, void *wmem) -{ - struct nx842_header *hdr; - struct nx842_devdata *local_devdata; - struct device *dev = NULL; - struct nx842_workmem *workmem; - struct nx842_scatterlist slin, slout; - struct nx_csbcpb *csbcpb; - int ret = 0, max_sync_size, i, bytesleft, size, hdrsize; - unsigned long inbuf, outbuf, padding; - struct vio_pfo_op op = { - .done = NULL, - .handle = 0, - .timeout = 0, - }; - unsigned long start_time = get_tb(); - - /* - * Make sure input buffer is 64k page aligned. This is assumed since - * this driver is designed for page compression only (for now). This - * is very nice since we can now use direct DDE(s) for the input and - * the alignment is guaranteed. - */ - inbuf = (unsigned long)in; - if (!IS_ALIGNED(inbuf, PAGE_SIZE) || inlen != PAGE_SIZE) - return -EINVAL; - - rcu_read_lock(); - local_devdata = rcu_dereference(devdata); - if (!local_devdata || !local_devdata->dev) { - rcu_read_unlock(); - return -ENODEV; - } - max_sync_size = local_devdata->max_sync_size; - dev = local_devdata->dev; - - /* Create the header */ - hdr = (struct nx842_header *)out; - hdr->blocks_nr = PAGE_SIZE / max_sync_size; - hdrsize = nx842_header_size(hdr); - outbuf = (unsigned long)out + hdrsize; - bytesleft = *outlen - hdrsize; - - /* Init scatterlist */ - workmem = (struct nx842_workmem *)ALIGN((unsigned long)wmem, - NX842_HW_PAGE_SIZE); - slin.entries = (struct nx842_slentry *)workmem->slin; - slout.entries = (struct nx842_slentry *)workmem->slout; - - /* Init operation */ - op.flags = NX842_OP_COMPRESS; - csbcpb = &workmem->csbcpb; - memset(csbcpb, 0, sizeof(*csbcpb)); - op.csbcpb = __pa(csbcpb); - op.out = __pa(slout.entries); - - for (i = 0; i < hdr->blocks_nr; i++) { - /* - * Aligning the output blocks to 128 bytes does waste space, - * but it prevents the need for bounce buffers and memory - * copies. It also simplifies the code a lot. In the worst - * case (64k page, 4k max_sync_size), you lose up to - * (128*16)/64k = ~3% the compression factor. For 64k - * max_sync_size, the loss would be at most 128/64k = ~0.2%. - */ - padding = ALIGN(outbuf, IO_BUFFER_ALIGN) - outbuf; - outbuf += padding; - bytesleft -= padding; - if (i == 0) - /* save offset into first block in header */ - hdr->offset = padding + hdrsize; - - if (bytesleft <= 0) { - ret = -ENOSPC; - goto unlock; - } - - /* - * NOTE: If the default max_sync_size is changed from 4k - * to 64k, remove the "likely" case below, since a - * scatterlist will always be needed. - */ - if (likely(max_sync_size == NX842_HW_PAGE_SIZE)) { - /* Create direct DDE */ - op.in = __pa(inbuf); - op.inlen = max_sync_size; - - } else { - /* Create indirect DDE (scatterlist) */ - nx842_build_scatterlist(inbuf, max_sync_size, &slin); - op.in = __pa(slin.entries); - op.inlen = -nx842_get_scatterlist_size(&slin); - } - - /* - * If max_sync_size != NX842_HW_PAGE_SIZE, an indirect - * DDE is required for the outbuf. - * If max_sync_size == NX842_HW_PAGE_SIZE, outbuf must - * also be page aligned (1 in 128/4k=32 chance) in order - * to use a direct DDE. - * This is unlikely, just use an indirect DDE always. - */ - nx842_build_scatterlist(outbuf, - min(bytesleft, max_sync_size), &slout); - /* op.out set before loop */ - op.outlen = -nx842_get_scatterlist_size(&slout); - - /* Send request to pHyp */ - ret = vio_h_cop_sync(local_devdata->vdev, &op); - - /* Check for pHyp error */ - if (ret) { - dev_dbg(dev, "%s: vio_h_cop_sync error (ret=%d, hret=%ld)\n", - __func__, ret, op.hcall_err); - ret = -EIO; - goto unlock; - } - - /* Check for hardware error */ - ret = nx842_validate_result(dev, &csbcpb->csb); - if (ret && ret != -ENOSPC) - goto unlock; - - /* Handle incompressible data */ - if (unlikely(ret == -ENOSPC)) { - if (bytesleft < max_sync_size) { - /* - * Not enough space left in the output buffer - * to store uncompressed block - */ - goto unlock; - } else { - /* Store incompressible block */ - memcpy((void *)outbuf, (void *)inbuf, - max_sync_size); - hdr->sizes[i] = -max_sync_size; - outbuf += max_sync_size; - bytesleft -= max_sync_size; - /* Reset ret, incompressible data handled */ - ret = 0; - } - } else { - /* Normal case, compression was successful */ - size = csbcpb->csb.processed_byte_count; - dev_dbg(dev, "%s: processed_bytes=%d\n", - __func__, size); - hdr->sizes[i] = size; - outbuf += size; - bytesleft -= size; - } - - inbuf += max_sync_size; - } - - *outlen = (unsigned int)(outbuf - (unsigned long)out); - -unlock: - if (ret) - nx842_inc_comp_failed(local_devdata); - else { - nx842_inc_comp_complete(local_devdata); - ibm_nx842_incr_hist(local_devdata->counters->comp_times, - (get_tb() - start_time) / tb_ticks_per_usec); - } - rcu_read_unlock(); - return ret; -} -EXPORT_SYMBOL_GPL(nx842_compress); - -static int sw842_decompress(const unsigned char *, int, unsigned char *, int *, - const void *); - -/** - * nx842_decompress - Decompress data using the 842 algorithm - * - * Decompression provide by the NX842 coprocessor on IBM Power systems. - * The input buffer is decompressed and the result is stored in the - * provided output buffer. The size allocated to the output buffer is - * provided by the caller of this function in @outlen. Upon return from - * this function @outlen contains the length of the decompressed data. - * If there is an error then @outlen will be 0 and an error will be - * specified by the return code from this function. - * - * @in: Pointer to input buffer, will use bounce buffer if not 128 byte - * aligned - * @inlen: Length of input buffer - * @out: Pointer to output buffer, must be page aligned - * @outlen: Length of output buffer, must be PAGE_SIZE - * @wrkmem: ptr to buffer for working memory, size determined by - * nx842_get_workmem_size() - * - * Returns: - * 0 Success, output of length @outlen stored in the buffer at @out - * -ENODEV Hardware decompression device is unavailable - * -ENOMEM Unable to allocate internal buffers - * -ENOSPC Output buffer is to small - * -EINVAL Bad input data encountered when attempting decompress - * -EIO Internal error - */ -int nx842_decompress(const unsigned char *in, unsigned int inlen, - unsigned char *out, unsigned int *outlen, void *wmem) -{ - struct nx842_header *hdr; - struct nx842_devdata *local_devdata; - struct device *dev = NULL; - struct nx842_workmem *workmem; - struct nx842_scatterlist slin, slout; - struct nx_csbcpb *csbcpb; - int ret = 0, i, size, max_sync_size; - unsigned long inbuf, outbuf; - struct vio_pfo_op op = { - .done = NULL, - .handle = 0, - .timeout = 0, - }; - unsigned long start_time = get_tb(); - - /* Ensure page alignment and size */ - outbuf = (unsigned long)out; - if (!IS_ALIGNED(outbuf, PAGE_SIZE) || *outlen != PAGE_SIZE) - return -EINVAL; - - rcu_read_lock(); - local_devdata = rcu_dereference(devdata); - if (local_devdata) - dev = local_devdata->dev; - - /* Get header */ - hdr = (struct nx842_header *)in; - - workmem = (struct nx842_workmem *)ALIGN((unsigned long)wmem, - NX842_HW_PAGE_SIZE); - - inbuf = (unsigned long)in + hdr->offset; - if (likely(!IS_ALIGNED(inbuf, IO_BUFFER_ALIGN))) { - /* Copy block(s) into bounce buffer for alignment */ - memcpy(workmem->bounce, in + hdr->offset, inlen - hdr->offset); - inbuf = (unsigned long)workmem->bounce; - } - - /* Init scatterlist */ - slin.entries = (struct nx842_slentry *)workmem->slin; - slout.entries = (struct nx842_slentry *)workmem->slout; - - /* Init operation */ - op.flags = NX842_OP_DECOMPRESS; - csbcpb = &workmem->csbcpb; - memset(csbcpb, 0, sizeof(*csbcpb)); - op.csbcpb = __pa(csbcpb); - - /* - * max_sync_size may have changed since compression, - * so we can't read it from the device info. We need - * to derive it from hdr->blocks_nr. - */ - max_sync_size = PAGE_SIZE / hdr->blocks_nr; - - for (i = 0; i < hdr->blocks_nr; i++) { - /* Skip padding */ - inbuf = ALIGN(inbuf, IO_BUFFER_ALIGN); - - if (hdr->sizes[i] < 0) { - /* Negative sizes indicate uncompressed data blocks */ - size = abs(hdr->sizes[i]); - memcpy((void *)outbuf, (void *)inbuf, size); - outbuf += size; - inbuf += size; - continue; - } - - if (!dev) - goto sw; - - /* - * The better the compression, the more likely the "likely" - * case becomes. - */ - if (likely((inbuf & NX842_HW_PAGE_MASK) == - ((inbuf + hdr->sizes[i] - 1) & NX842_HW_PAGE_MASK))) { - /* Create direct DDE */ - op.in = __pa(inbuf); - op.inlen = hdr->sizes[i]; - } else { - /* Create indirect DDE (scatterlist) */ - nx842_build_scatterlist(inbuf, hdr->sizes[i] , &slin); - op.in = __pa(slin.entries); - op.inlen = -nx842_get_scatterlist_size(&slin); - } - - /* - * NOTE: If the default max_sync_size is changed from 4k - * to 64k, remove the "likely" case below, since a - * scatterlist will always be needed. - */ - if (likely(max_sync_size == NX842_HW_PAGE_SIZE)) { - /* Create direct DDE */ - op.out = __pa(outbuf); - op.outlen = max_sync_size; - } else { - /* Create indirect DDE (scatterlist) */ - nx842_build_scatterlist(outbuf, max_sync_size, &slout); - op.out = __pa(slout.entries); - op.outlen = -nx842_get_scatterlist_size(&slout); - } - - /* Send request to pHyp */ - ret = vio_h_cop_sync(local_devdata->vdev, &op); - - /* Check for pHyp error */ - if (ret) { - dev_dbg(dev, "%s: vio_h_cop_sync error (ret=%d, hret=%ld)\n", - __func__, ret, op.hcall_err); - dev = NULL; - goto sw; - } - - /* Check for hardware error */ - ret = nx842_validate_result(dev, &csbcpb->csb); - if (ret) { - dev = NULL; - goto sw; - } - - /* HW decompression success */ - inbuf += hdr->sizes[i]; - outbuf += csbcpb->csb.processed_byte_count; - continue; - -sw: - /* software decompression */ - size = max_sync_size; - ret = sw842_decompress( - (unsigned char *)inbuf, hdr->sizes[i], - (unsigned char *)outbuf, &size, wmem); - if (ret) - pr_debug("%s: sw842_decompress failed with %d\n", - __func__, ret); - - if (ret) { - if (ret != -ENOSPC && ret != -EINVAL && - ret != -EMSGSIZE) - ret = -EIO; - goto unlock; - } - - /* SW decompression success */ - inbuf += hdr->sizes[i]; - outbuf += size; - } - - *outlen = (unsigned int)(outbuf - (unsigned long)out); - -unlock: - if (ret) - /* decompress fail */ - nx842_inc_decomp_failed(local_devdata); - else { - if (!dev) - /* software decompress */ - nx842_inc_swdecomp(local_devdata); - nx842_inc_decomp_complete(local_devdata); - ibm_nx842_incr_hist(local_devdata->counters->decomp_times, - (get_tb() - start_time) / tb_ticks_per_usec); - } - - rcu_read_unlock(); - return ret; -} -EXPORT_SYMBOL_GPL(nx842_decompress); - -/** - * nx842_OF_set_defaults -- Set default (disabled) values for devdata - * - * @devdata - struct nx842_devdata to update - * - * Returns: - * 0 on success - * -ENOENT if @devdata ptr is NULL - */ -static int nx842_OF_set_defaults(struct nx842_devdata *devdata) -{ - if (devdata) { - devdata->max_sync_size = 0; - devdata->max_sync_sg = 0; - devdata->max_sg_len = 0; - devdata->status = UNAVAILABLE; - return 0; - } else - return -ENOENT; -} - -/** - * nx842_OF_upd_status -- Update the device info from OF status prop - * - * The status property indicates if the accelerator is enabled. If the - * device is in the OF tree it indicates that the hardware is present. - * The status field indicates if the device is enabled when the status - * is 'okay'. Otherwise the device driver will be disabled. - * - * @devdata - struct nx842_devdata to update - * @prop - struct property point containing the maxsyncop for the update - * - * Returns: - * 0 - Device is available - * -EINVAL - Device is not available - */ -static int nx842_OF_upd_status(struct nx842_devdata *devdata, - struct property *prop) { - int ret = 0; - const char *status = (const char *)prop->value; - - if (!strncmp(status, "okay", (size_t)prop->length)) { - devdata->status = AVAILABLE; - } else { - dev_info(devdata->dev, "%s: status '%s' is not 'okay'\n", - __func__, status); - devdata->status = UNAVAILABLE; - } - - return ret; -} - -/** - * nx842_OF_upd_maxsglen -- Update the device info from OF maxsglen prop - * - * Definition of the 'ibm,max-sg-len' OF property: - * This field indicates the maximum byte length of a scatter list - * for the platform facility. It is a single cell encoded as with encode-int. - * - * Example: - * # od -x ibm,max-sg-len - * 0000000 0000 0ff0 - * - * In this example, the maximum byte length of a scatter list is - * 0x0ff0 (4,080). - * - * @devdata - struct nx842_devdata to update - * @prop - struct property point containing the maxsyncop for the update - * - * Returns: - * 0 on success - * -EINVAL on failure - */ -static int nx842_OF_upd_maxsglen(struct nx842_devdata *devdata, - struct property *prop) { - int ret = 0; - const int *maxsglen = prop->value; - - if (prop->length != sizeof(*maxsglen)) { - dev_err(devdata->dev, "%s: unexpected format for ibm,max-sg-len property\n", __func__); - dev_dbg(devdata->dev, "%s: ibm,max-sg-len is %d bytes long, expected %lu bytes\n", __func__, - prop->length, sizeof(*maxsglen)); - ret = -EINVAL; - } else { - devdata->max_sg_len = (unsigned int)min(*maxsglen, - (int)NX842_HW_PAGE_SIZE); - } - - return ret; -} - -/** - * nx842_OF_upd_maxsyncop -- Update the device info from OF maxsyncop prop - * - * Definition of the 'ibm,max-sync-cop' OF property: - * Two series of cells. The first series of cells represents the maximums - * that can be synchronously compressed. The second series of cells - * represents the maximums that can be synchronously decompressed. - * 1. The first cell in each series contains the count of the number of - * data length, scatter list elements pairs that follow – each being - * of the form - * a. One cell data byte length - * b. One cell total number of scatter list elements - * - * Example: - * # od -x ibm,max-sync-cop - * 0000000 0000 0001 0000 1000 0000 01fe 0000 0001 - * 0000020 0000 1000 0000 01fe - * - * In this example, compression supports 0x1000 (4,096) data byte length - * and 0x1fe (510) total scatter list elements. Decompression supports - * 0x1000 (4,096) data byte length and 0x1f3 (510) total scatter list - * elements. - * - * @devdata - struct nx842_devdata to update - * @prop - struct property point containing the maxsyncop for the update - * - * Returns: - * 0 on success - * -EINVAL on failure - */ -static int nx842_OF_upd_maxsyncop(struct nx842_devdata *devdata, - struct property *prop) { - int ret = 0; - const struct maxsynccop_t { - int comp_elements; - int comp_data_limit; - int comp_sg_limit; - int decomp_elements; - int decomp_data_limit; - int decomp_sg_limit; - } *maxsynccop; - - if (prop->length != sizeof(*maxsynccop)) { - dev_err(devdata->dev, "%s: unexpected format for ibm,max-sync-cop property\n", __func__); - dev_dbg(devdata->dev, "%s: ibm,max-sync-cop is %d bytes long, expected %lu bytes\n", __func__, prop->length, - sizeof(*maxsynccop)); - ret = -EINVAL; - goto out; - } - - maxsynccop = (const struct maxsynccop_t *)prop->value; - - /* Use one limit rather than separate limits for compression and - * decompression. Set a maximum for this so as not to exceed the - * size that the header can support and round the value down to - * the hardware page size (4K) */ - devdata->max_sync_size = - (unsigned int)min(maxsynccop->comp_data_limit, - maxsynccop->decomp_data_limit); - - devdata->max_sync_size = min_t(unsigned int, devdata->max_sync_size, - SIZE_64K); - - if (devdata->max_sync_size < SIZE_4K) { - dev_err(devdata->dev, "%s: hardware max data size (%u) is " - "less than the driver minimum, unable to use " - "the hardware device\n", - __func__, devdata->max_sync_size); - ret = -EINVAL; - goto out; - } - - devdata->max_sync_sg = (unsigned int)min(maxsynccop->comp_sg_limit, - maxsynccop->decomp_sg_limit); - if (devdata->max_sync_sg < 1) { - dev_err(devdata->dev, "%s: hardware max sg size (%u) is " - "less than the driver minimum, unable to use " - "the hardware device\n", - __func__, devdata->max_sync_sg); - ret = -EINVAL; - goto out; - } - -out: - return ret; -} - -/** - * - * nx842_OF_upd -- Handle OF properties updates for the device. - * - * Set all properties from the OF tree. Optionally, a new property - * can be provided by the @new_prop pointer to overwrite an existing value. - * The device will remain disabled until all values are valid, this function - * will return an error for updates unless all values are valid. - * - * @new_prop: If not NULL, this property is being updated. If NULL, update - * all properties from the current values in the OF tree. - * - * Returns: - * 0 - Success - * -ENOMEM - Could not allocate memory for new devdata structure - * -EINVAL - property value not found, new_prop is not a recognized - * property for the device or property value is not valid. - * -ENODEV - Device is not available - */ -static int nx842_OF_upd(struct property *new_prop) -{ - struct nx842_devdata *old_devdata = NULL; - struct nx842_devdata *new_devdata = NULL; - struct device_node *of_node = NULL; - struct property *status = NULL; - struct property *maxsglen = NULL; - struct property *maxsyncop = NULL; - int ret = 0; - unsigned long flags; - - spin_lock_irqsave(&devdata_mutex, flags); - old_devdata = rcu_dereference_check(devdata, - lockdep_is_held(&devdata_mutex)); - if (old_devdata) - of_node = old_devdata->dev->of_node; - - if (!old_devdata || !of_node) { - pr_err("%s: device is not available\n", __func__); - spin_unlock_irqrestore(&devdata_mutex, flags); - return -ENODEV; - } - - new_devdata = kzalloc(sizeof(*new_devdata), GFP_NOFS); - if (!new_devdata) { - dev_err(old_devdata->dev, "%s: Could not allocate memory for device data\n", __func__); - ret = -ENOMEM; - goto error_out; - } - - memcpy(new_devdata, old_devdata, sizeof(*old_devdata)); - new_devdata->counters = old_devdata->counters; - - /* Set ptrs for existing properties */ - status = of_find_property(of_node, "status", NULL); - maxsglen = of_find_property(of_node, "ibm,max-sg-len", NULL); - maxsyncop = of_find_property(of_node, "ibm,max-sync-cop", NULL); - if (!status || !maxsglen || !maxsyncop) { - dev_err(old_devdata->dev, "%s: Could not locate device properties\n", __func__); - ret = -EINVAL; - goto error_out; - } - - /* Set ptr to new property if provided */ - if (new_prop) { - /* Single property */ - if (!strncmp(new_prop->name, "status", new_prop->length)) { - status = new_prop; - - } else if (!strncmp(new_prop->name, "ibm,max-sg-len", - new_prop->length)) { - maxsglen = new_prop; - - } else if (!strncmp(new_prop->name, "ibm,max-sync-cop", - new_prop->length)) { - maxsyncop = new_prop; - - } else { - /* - * Skip the update, the property being updated - * has no impact. - */ - goto out; - } - } - - /* Perform property updates */ - ret = nx842_OF_upd_status(new_devdata, status); - if (ret) - goto error_out; - - ret = nx842_OF_upd_maxsglen(new_devdata, maxsglen); - if (ret) - goto error_out; - - ret = nx842_OF_upd_maxsyncop(new_devdata, maxsyncop); - if (ret) - goto error_out; - -out: - dev_info(old_devdata->dev, "%s: max_sync_size new:%u old:%u\n", - __func__, new_devdata->max_sync_size, - old_devdata->max_sync_size); - dev_info(old_devdata->dev, "%s: max_sync_sg new:%u old:%u\n", - __func__, new_devdata->max_sync_sg, - old_devdata->max_sync_sg); - dev_info(old_devdata->dev, "%s: max_sg_len new:%u old:%u\n", - __func__, new_devdata->max_sg_len, - old_devdata->max_sg_len); - - rcu_assign_pointer(devdata, new_devdata); - spin_unlock_irqrestore(&devdata_mutex, flags); - synchronize_rcu(); - dev_set_drvdata(new_devdata->dev, new_devdata); - kfree(old_devdata); - return 0; - -error_out: - if (new_devdata) { - dev_info(old_devdata->dev, "%s: device disabled\n", __func__); - nx842_OF_set_defaults(new_devdata); - rcu_assign_pointer(devdata, new_devdata); - spin_unlock_irqrestore(&devdata_mutex, flags); - synchronize_rcu(); - dev_set_drvdata(new_devdata->dev, new_devdata); - kfree(old_devdata); - } else { - dev_err(old_devdata->dev, "%s: could not update driver from hardware\n", __func__); - spin_unlock_irqrestore(&devdata_mutex, flags); - } - - if (!ret) - ret = -EINVAL; - return ret; -} - -/** - * nx842_OF_notifier - Process updates to OF properties for the device - * - * @np: notifier block - * @action: notifier action - * @update: struct pSeries_reconfig_prop_update pointer if action is - * PSERIES_UPDATE_PROPERTY - * - * Returns: - * NOTIFY_OK on success - * NOTIFY_BAD encoded with error number on failure, use - * notifier_to_errno() to decode this value - */ -static int nx842_OF_notifier(struct notifier_block *np, - unsigned long action, - void *update) -{ - struct pSeries_reconfig_prop_update *upd; - struct nx842_devdata *local_devdata; - struct device_node *node = NULL; - - upd = (struct pSeries_reconfig_prop_update *)update; - - rcu_read_lock(); - local_devdata = rcu_dereference(devdata); - if (local_devdata) - node = local_devdata->dev->of_node; - - if (local_devdata && - action == PSERIES_UPDATE_PROPERTY && - !strcmp(upd->node->name, node->name)) { - rcu_read_unlock(); - nx842_OF_upd(upd->property); - } else - rcu_read_unlock(); - - return NOTIFY_OK; -} - -static struct notifier_block nx842_of_nb = { - .notifier_call = nx842_OF_notifier, -}; - -#define nx842_counter_read(_name) \ -static ssize_t nx842_##_name##_show(struct device *dev, \ - struct device_attribute *attr, \ - char *buf) { \ - struct nx842_devdata *local_devdata; \ - int p = 0; \ - rcu_read_lock(); \ - local_devdata = rcu_dereference(devdata); \ - if (local_devdata) \ - p = snprintf(buf, PAGE_SIZE, "%ld\n", \ - atomic64_read(&local_devdata->counters->_name)); \ - rcu_read_unlock(); \ - return p; \ -} - -#define NX842DEV_COUNTER_ATTR_RO(_name) \ - nx842_counter_read(_name); \ - static struct device_attribute dev_attr_##_name = __ATTR(_name, \ - 0444, \ - nx842_##_name##_show,\ - NULL); - -NX842DEV_COUNTER_ATTR_RO(comp_complete); -NX842DEV_COUNTER_ATTR_RO(comp_failed); -NX842DEV_COUNTER_ATTR_RO(decomp_complete); -NX842DEV_COUNTER_ATTR_RO(decomp_failed); -NX842DEV_COUNTER_ATTR_RO(swdecomp); - -static ssize_t nx842_timehist_show(struct device *, - struct device_attribute *, char *); - -static struct device_attribute dev_attr_comp_times = __ATTR(comp_times, 0444, - nx842_timehist_show, NULL); -static struct device_attribute dev_attr_decomp_times = __ATTR(decomp_times, - 0444, nx842_timehist_show, NULL); - -static ssize_t nx842_timehist_show(struct device *dev, - struct device_attribute *attr, char *buf) { - char *p = buf; - struct nx842_devdata *local_devdata; - atomic64_t *times; - int bytes_remain = PAGE_SIZE; - int bytes; - int i; - - rcu_read_lock(); - local_devdata = rcu_dereference(devdata); - if (!local_devdata) { - rcu_read_unlock(); - return 0; - } - - if (attr == &dev_attr_comp_times) - times = local_devdata->counters->comp_times; - else if (attr == &dev_attr_decomp_times) - times = local_devdata->counters->decomp_times; - else { - rcu_read_unlock(); - return 0; - } - - for (i = 0; i < (NX842_HIST_SLOTS - 2); i++) { - bytes = snprintf(p, bytes_remain, "%u-%uus:\t%ld\n", - i ? (2<<(i-1)) : 0, (2<vdev != NULL) { - dev_err(&viodev->dev, "%s: Attempt to register more than one instance of the hardware\n", __func__); - ret = -1; - goto error_unlock; - } - - dev_set_drvdata(&viodev->dev, NULL); - - new_devdata = kzalloc(sizeof(*new_devdata), GFP_NOFS); - if (!new_devdata) { - dev_err(&viodev->dev, "%s: Could not allocate memory for device data\n", __func__); - ret = -ENOMEM; - goto error_unlock; - } - - new_devdata->counters = kzalloc(sizeof(*new_devdata->counters), - GFP_NOFS); - if (!new_devdata->counters) { - dev_err(&viodev->dev, "%s: Could not allocate memory for performance counters\n", __func__); - ret = -ENOMEM; - goto error_unlock; - } - - new_devdata->vdev = viodev; - new_devdata->dev = &viodev->dev; - nx842_OF_set_defaults(new_devdata); - - rcu_assign_pointer(devdata, new_devdata); - spin_unlock_irqrestore(&devdata_mutex, flags); - synchronize_rcu(); - kfree(old_devdata); - - pSeries_reconfig_notifier_register(&nx842_of_nb); - - ret = nx842_OF_upd(NULL); - if (ret && ret != -ENODEV) { - dev_err(&viodev->dev, "could not parse device tree. %d\n", ret); - ret = -1; - goto error; - } - - rcu_read_lock(); - if (dev_set_drvdata(&viodev->dev, rcu_dereference(devdata))) { - rcu_read_unlock(); - dev_err(&viodev->dev, "failed to set driver data for device\n"); - ret = -1; - goto error; - } - rcu_read_unlock(); - - if (sysfs_create_group(&viodev->dev.kobj, &nx842_attribute_group)) { - dev_err(&viodev->dev, "could not create sysfs device attributes\n"); - ret = -1; - goto error; - } - - return 0; - -error_unlock: - spin_unlock_irqrestore(&devdata_mutex, flags); - if (new_devdata) - kfree(new_devdata->counters); - kfree(new_devdata); -error: - return ret; -} - -static int __exit nx842_remove(struct vio_dev *viodev) -{ - struct nx842_devdata *old_devdata; - unsigned long flags; - - pr_info("Removing IBM Power 842 compression device\n"); - sysfs_remove_group(&viodev->dev.kobj, &nx842_attribute_group); - - spin_lock_irqsave(&devdata_mutex, flags); - old_devdata = rcu_dereference_check(devdata, - lockdep_is_held(&devdata_mutex)); - pSeries_reconfig_notifier_unregister(&nx842_of_nb); - rcu_assign_pointer(devdata, NULL); - spin_unlock_irqrestore(&devdata_mutex, flags); - synchronize_rcu(); - dev_set_drvdata(&viodev->dev, NULL); - if (old_devdata) - kfree(old_devdata->counters); - kfree(old_devdata); - return 0; -} - -static struct vio_device_id nx842_driver_ids[] = { - {"ibm,compression-v1", "ibm,compression"}, - {"", ""}, -}; - -static struct vio_driver nx842_driver = { - .name = MODULE_NAME, - .probe = nx842_probe, - .remove = nx842_remove, - .get_desired_dma = nx842_get_desired_dma, - .id_table = nx842_driver_ids, -}; - -static int __init nx842_init(void) -{ - struct nx842_devdata *new_devdata; - pr_info("Registering IBM Power 842 compression driver\n"); - - RCU_INIT_POINTER(devdata, NULL); - new_devdata = kzalloc(sizeof(*new_devdata), GFP_KERNEL); - if (!new_devdata) { - pr_err("Could not allocate memory for device data\n"); - return -ENOMEM; - } - new_devdata->status = UNAVAILABLE; - RCU_INIT_POINTER(devdata, new_devdata); - - return vio_register_driver(&nx842_driver); -} - -module_init(nx842_init); - -static void __exit nx842_exit(void) -{ - struct nx842_devdata *old_devdata; - unsigned long flags; - - pr_info("Exiting IBM Power 842 compression driver\n"); - spin_lock_irqsave(&devdata_mutex, flags); - old_devdata = rcu_dereference_check(devdata, - lockdep_is_held(&devdata_mutex)); - rcu_assign_pointer(devdata, NULL); - spin_unlock_irqrestore(&devdata_mutex, flags); - synchronize_rcu(); - if (old_devdata) - dev_set_drvdata(old_devdata->dev, NULL); - kfree(old_devdata); - vio_unregister_driver(&nx842_driver); -} - -module_exit(nx842_exit); - -/********************************* - * 842 software decompressor -*********************************/ -typedef int (*sw842_template_op)(const char **, int *, unsigned char **, - struct sw842_fifo *); - -static int sw842_data8(const char **, int *, unsigned char **, - struct sw842_fifo *); -static int sw842_data4(const char **, int *, unsigned char **, - struct sw842_fifo *); -static int sw842_data2(const char **, int *, unsigned char **, - struct sw842_fifo *); -static int sw842_ptr8(const char **, int *, unsigned char **, - struct sw842_fifo *); -static int sw842_ptr4(const char **, int *, unsigned char **, - struct sw842_fifo *); -static int sw842_ptr2(const char **, int *, unsigned char **, - struct sw842_fifo *); - -/* special templates */ -#define SW842_TMPL_REPEAT 0x1B -#define SW842_TMPL_ZEROS 0x1C -#define SW842_TMPL_EOF 0x1E - -static sw842_template_op sw842_tmpl_ops[26][4] = { - { sw842_data8, NULL}, /* 0 (00000) */ - { sw842_data4, sw842_data2, sw842_ptr2, NULL}, - { sw842_data4, sw842_ptr2, sw842_data2, NULL}, - { sw842_data4, sw842_ptr2, sw842_ptr2, NULL}, - { sw842_data4, sw842_ptr4, NULL}, - { sw842_data2, sw842_ptr2, sw842_data4, NULL}, - { sw842_data2, sw842_ptr2, sw842_data2, sw842_ptr2}, - { sw842_data2, sw842_ptr2, sw842_ptr2, sw842_data2}, - { sw842_data2, sw842_ptr2, sw842_ptr2, sw842_ptr2,}, - { sw842_data2, sw842_ptr2, sw842_ptr4, NULL}, - { sw842_ptr2, sw842_data2, sw842_data4, NULL}, /* 10 (01010) */ - { sw842_ptr2, sw842_data4, sw842_ptr2, NULL}, - { sw842_ptr2, sw842_data2, sw842_ptr2, sw842_data2}, - { sw842_ptr2, sw842_data2, sw842_ptr2, sw842_ptr2}, - { sw842_ptr2, sw842_data2, sw842_ptr4, NULL}, - { sw842_ptr2, sw842_ptr2, sw842_data4, NULL}, - { sw842_ptr2, sw842_ptr2, sw842_data2, sw842_ptr2}, - { sw842_ptr2, sw842_ptr2, sw842_ptr2, sw842_data2}, - { sw842_ptr2, sw842_ptr2, sw842_ptr2, sw842_ptr2}, - { sw842_ptr2, sw842_ptr2, sw842_ptr4, NULL}, - { sw842_ptr4, sw842_data4, NULL}, /* 20 (10100) */ - { sw842_ptr4, sw842_data2, sw842_ptr2, NULL}, - { sw842_ptr4, sw842_ptr2, sw842_data2, NULL}, - { sw842_ptr4, sw842_ptr2, sw842_ptr2, NULL}, - { sw842_ptr4, sw842_ptr4, NULL}, - { sw842_ptr8, NULL} -}; - -/* Software decompress helpers */ - -static uint8_t sw842_get_byte(const char *buf, int bit) -{ - uint8_t tmpl; - uint16_t tmp; - tmp = htons(*(uint16_t *)(buf)); - tmp = (uint16_t)(tmp << bit); - tmp = ntohs(tmp); - memcpy(&tmpl, &tmp, 1); - return tmpl; -} - -static uint8_t sw842_get_template(const char **buf, int *bit) -{ - uint8_t byte; - byte = sw842_get_byte(*buf, *bit); - byte = byte >> 3; - byte &= 0x1F; - *buf += (*bit + 5) / 8; - *bit = (*bit + 5) % 8; - return byte; -} - -/* repeat_count happens to be 5-bit too (like the template) */ -static uint8_t sw842_get_repeat_count(const char **buf, int *bit) -{ - uint8_t byte; - byte = sw842_get_byte(*buf, *bit); - byte = byte >> 2; - byte &= 0x3F; - *buf += (*bit + 6) / 8; - *bit = (*bit + 6) % 8; - return byte; -} - -static uint8_t sw842_get_ptr2(const char **buf, int *bit) -{ - uint8_t ptr; - ptr = sw842_get_byte(*buf, *bit); - (*buf)++; - return ptr; -} - -static uint16_t sw842_get_ptr4(const char **buf, int *bit, - struct sw842_fifo *fifo) -{ - uint16_t ptr; - ptr = htons(*(uint16_t *)(*buf)); - ptr = (uint16_t)(ptr << *bit); - ptr = ptr >> 7; - ptr &= 0x01FF; - *buf += (*bit + 9) / 8; - *bit = (*bit + 9) % 8; - return ptr; -} - -static uint8_t sw842_get_ptr8(const char **buf, int *bit, - struct sw842_fifo *fifo) -{ - return sw842_get_ptr2(buf, bit); -} - -/* Software decompress template ops */ - -static int sw842_data8(const char **inbuf, int *inbit, - unsigned char **outbuf, struct sw842_fifo *fifo) -{ - int ret; - - ret = sw842_data4(inbuf, inbit, outbuf, fifo); - if (ret) - return ret; - ret = sw842_data4(inbuf, inbit, outbuf, fifo); - return ret; -} - -static int sw842_data4(const char **inbuf, int *inbit, - unsigned char **outbuf, struct sw842_fifo *fifo) -{ - int ret; - - ret = sw842_data2(inbuf, inbit, outbuf, fifo); - if (ret) - return ret; - ret = sw842_data2(inbuf, inbit, outbuf, fifo); - return ret; -} - -static int sw842_data2(const char **inbuf, int *inbit, - unsigned char **outbuf, struct sw842_fifo *fifo) -{ - **outbuf = sw842_get_byte(*inbuf, *inbit); - (*inbuf)++; - (*outbuf)++; - **outbuf = sw842_get_byte(*inbuf, *inbit); - (*inbuf)++; - (*outbuf)++; - return 0; -} - -static int sw842_ptr8(const char **inbuf, int *inbit, - unsigned char **outbuf, struct sw842_fifo *fifo) -{ - uint8_t ptr; - ptr = sw842_get_ptr8(inbuf, inbit, fifo); - if (!fifo->f84_full && (ptr >= fifo->f8_count)) - return 1; - memcpy(*outbuf, fifo->f8[ptr], 8); - *outbuf += 8; - return 0; -} - -static int sw842_ptr4(const char **inbuf, int *inbit, - unsigned char **outbuf, struct sw842_fifo *fifo) -{ - uint16_t ptr; - ptr = sw842_get_ptr4(inbuf, inbit, fifo); - if (!fifo->f84_full && (ptr >= fifo->f4_count)) - return 1; - memcpy(*outbuf, fifo->f4[ptr], 4); - *outbuf += 4; - return 0; -} - -static int sw842_ptr2(const char **inbuf, int *inbit, - unsigned char **outbuf, struct sw842_fifo *fifo) -{ - uint8_t ptr; - ptr = sw842_get_ptr2(inbuf, inbit); - if (!fifo->f2_full && (ptr >= fifo->f2_count)) - return 1; - memcpy(*outbuf, fifo->f2[ptr], 2); - *outbuf += 2; - return 0; -} - -static void sw842_copy_to_fifo(const char *buf, struct sw842_fifo *fifo) -{ - unsigned char initial_f2count = fifo->f2_count; - - memcpy(fifo->f8[fifo->f8_count], buf, 8); - fifo->f4_count += 2; - fifo->f8_count += 1; - - if (!fifo->f84_full && fifo->f4_count >= 512) { - fifo->f84_full = 1; - fifo->f4_count /= 512; - } - - memcpy(fifo->f2[fifo->f2_count++], buf, 2); - memcpy(fifo->f2[fifo->f2_count++], buf + 2, 2); - memcpy(fifo->f2[fifo->f2_count++], buf + 4, 2); - memcpy(fifo->f2[fifo->f2_count++], buf + 6, 2); - if (fifo->f2_count < initial_f2count) - fifo->f2_full = 1; -} - -static int sw842_decompress(const unsigned char *src, int srclen, - unsigned char *dst, int *destlen, - const void *wrkmem) -{ - uint8_t tmpl; - const char *inbuf; - int inbit = 0; - unsigned char *outbuf, *outbuf_end, *origbuf, *prevbuf; - const char *inbuf_end; - sw842_template_op op; - int opindex; - int i, repeat_count; - struct sw842_fifo *fifo; - int ret = 0; - - fifo = &((struct nx842_workmem *)(wrkmem))->swfifo; - memset(fifo, 0, sizeof(*fifo)); - - origbuf = NULL; - inbuf = src; - inbuf_end = src + srclen; - outbuf = dst; - outbuf_end = dst + *destlen; - - while ((tmpl = sw842_get_template(&inbuf, &inbit)) != SW842_TMPL_EOF) { - if (inbuf >= inbuf_end) { - ret = -EINVAL; - goto out; - } - - opindex = 0; - prevbuf = origbuf; - origbuf = outbuf; - switch (tmpl) { - case SW842_TMPL_REPEAT: - if (prevbuf == NULL) { - ret = -EINVAL; - goto out; - } - - repeat_count = sw842_get_repeat_count(&inbuf, - &inbit) + 1; - - /* Did the repeat count advance past the end of input */ - if (inbuf > inbuf_end) { - ret = -EINVAL; - goto out; - } - - for (i = 0; i < repeat_count; i++) { - /* Would this overflow the output buffer */ - if ((outbuf + 8) > outbuf_end) { - ret = -ENOSPC; - goto out; - } - - memcpy(outbuf, prevbuf, 8); - sw842_copy_to_fifo(outbuf, fifo); - outbuf += 8; - } - break; - - case SW842_TMPL_ZEROS: - /* Would this overflow the output buffer */ - if ((outbuf + 8) > outbuf_end) { - ret = -ENOSPC; - goto out; - } - - memset(outbuf, 0, 8); - sw842_copy_to_fifo(outbuf, fifo); - outbuf += 8; - break; - - default: - if (tmpl > 25) { - ret = -EINVAL; - goto out; - } - - /* Does this go past the end of the input buffer */ - if ((inbuf + 2) > inbuf_end) { - ret = -EINVAL; - goto out; - } - - /* Would this overflow the output buffer */ - if ((outbuf + 8) > outbuf_end) { - ret = -ENOSPC; - goto out; - } - - while (opindex < 4 && - (op = sw842_tmpl_ops[tmpl][opindex++]) - != NULL) { - ret = (*op)(&inbuf, &inbit, &outbuf, fifo); - if (ret) { - ret = -EINVAL; - goto out; - } - sw842_copy_to_fifo(origbuf, fifo); - } - } - } - -out: - if (!ret) - *destlen = (unsigned int)(outbuf - dst); - else - *destlen = 0; - - return ret; -} diff --git a/trunk/drivers/crypto/nx/nx-aes-cbc.c b/trunk/drivers/crypto/nx/nx-aes-cbc.c index a76d4c4f29f5..69ed796ee327 100644 --- a/trunk/drivers/crypto/nx/nx-aes-cbc.c +++ b/trunk/drivers/crypto/nx/nx-aes-cbc.c @@ -127,6 +127,7 @@ struct crypto_alg nx_cbc_aes_alg = { .cra_ctxsize = sizeof(struct nx_crypto_ctx), .cra_type = &crypto_blkcipher_type, .cra_module = THIS_MODULE, + .cra_list = LIST_HEAD_INIT(nx_cbc_aes_alg.cra_list), .cra_init = nx_crypto_ctx_aes_cbc_init, .cra_exit = nx_crypto_ctx_exit, .cra_blkcipher = { diff --git a/trunk/drivers/crypto/nx/nx-aes-ccm.c b/trunk/drivers/crypto/nx/nx-aes-ccm.c index ef5eae6d1400..7aeac678b9c0 100644 --- a/trunk/drivers/crypto/nx/nx-aes-ccm.c +++ b/trunk/drivers/crypto/nx/nx-aes-ccm.c @@ -430,6 +430,7 @@ struct crypto_alg nx_ccm_aes_alg = { .cra_ctxsize = sizeof(struct nx_crypto_ctx), .cra_type = &crypto_aead_type, .cra_module = THIS_MODULE, + .cra_list = LIST_HEAD_INIT(nx_ccm_aes_alg.cra_list), .cra_init = nx_crypto_ctx_aes_ccm_init, .cra_exit = nx_crypto_ctx_exit, .cra_aead = { @@ -452,6 +453,7 @@ struct crypto_alg nx_ccm4309_aes_alg = { .cra_ctxsize = sizeof(struct nx_crypto_ctx), .cra_type = &crypto_nivaead_type, .cra_module = THIS_MODULE, + .cra_list = LIST_HEAD_INIT(nx_ccm4309_aes_alg.cra_list), .cra_init = nx_crypto_ctx_aes_ccm_init, .cra_exit = nx_crypto_ctx_exit, .cra_aead = { diff --git a/trunk/drivers/crypto/nx/nx-aes-ctr.c b/trunk/drivers/crypto/nx/nx-aes-ctr.c index b6286f14680b..52d4eb05e8f7 100644 --- a/trunk/drivers/crypto/nx/nx-aes-ctr.c +++ b/trunk/drivers/crypto/nx/nx-aes-ctr.c @@ -141,6 +141,7 @@ struct crypto_alg nx_ctr_aes_alg = { .cra_ctxsize = sizeof(struct nx_crypto_ctx), .cra_type = &crypto_blkcipher_type, .cra_module = THIS_MODULE, + .cra_list = LIST_HEAD_INIT(nx_ctr_aes_alg.cra_list), .cra_init = nx_crypto_ctx_aes_ctr_init, .cra_exit = nx_crypto_ctx_exit, .cra_blkcipher = { @@ -162,6 +163,7 @@ struct crypto_alg nx_ctr3686_aes_alg = { .cra_ctxsize = sizeof(struct nx_crypto_ctx), .cra_type = &crypto_blkcipher_type, .cra_module = THIS_MODULE, + .cra_list = LIST_HEAD_INIT(nx_ctr3686_aes_alg.cra_list), .cra_init = nx_crypto_ctx_aes_ctr_init, .cra_exit = nx_crypto_ctx_exit, .cra_blkcipher = { diff --git a/trunk/drivers/crypto/nx/nx-aes-ecb.c b/trunk/drivers/crypto/nx/nx-aes-ecb.c index ba5f1611336f..7b77bc2d1df4 100644 --- a/trunk/drivers/crypto/nx/nx-aes-ecb.c +++ b/trunk/drivers/crypto/nx/nx-aes-ecb.c @@ -126,6 +126,7 @@ struct crypto_alg nx_ecb_aes_alg = { .cra_ctxsize = sizeof(struct nx_crypto_ctx), .cra_type = &crypto_blkcipher_type, .cra_module = THIS_MODULE, + .cra_list = LIST_HEAD_INIT(nx_ecb_aes_alg.cra_list), .cra_init = nx_crypto_ctx_aes_ecb_init, .cra_exit = nx_crypto_ctx_exit, .cra_blkcipher = { diff --git a/trunk/drivers/crypto/nx/nx-aes-gcm.c b/trunk/drivers/crypto/nx/nx-aes-gcm.c index c8109edc5cfb..9ab1c7341dac 100644 --- a/trunk/drivers/crypto/nx/nx-aes-gcm.c +++ b/trunk/drivers/crypto/nx/nx-aes-gcm.c @@ -316,6 +316,7 @@ struct crypto_alg nx_gcm_aes_alg = { .cra_ctxsize = sizeof(struct nx_crypto_ctx), .cra_type = &crypto_aead_type, .cra_module = THIS_MODULE, + .cra_list = LIST_HEAD_INIT(nx_gcm_aes_alg.cra_list), .cra_init = nx_crypto_ctx_aes_gcm_init, .cra_exit = nx_crypto_ctx_exit, .cra_aead = { @@ -337,6 +338,7 @@ struct crypto_alg nx_gcm4106_aes_alg = { .cra_ctxsize = sizeof(struct nx_crypto_ctx), .cra_type = &crypto_nivaead_type, .cra_module = THIS_MODULE, + .cra_list = LIST_HEAD_INIT(nx_gcm4106_aes_alg.cra_list), .cra_init = nx_crypto_ctx_aes_gcm_init, .cra_exit = nx_crypto_ctx_exit, .cra_aead = { diff --git a/trunk/drivers/crypto/nx/nx.c b/trunk/drivers/crypto/nx/nx.c index 638110efae9b..d7f179cc2e98 100644 --- a/trunk/drivers/crypto/nx/nx.c +++ b/trunk/drivers/crypto/nx/nx.c @@ -34,6 +34,7 @@ #include #include #include +#include #include #include @@ -103,10 +104,10 @@ struct nx_sg *nx_build_sg_list(struct nx_sg *sg_head, /* determine the start and end for this address range - slightly * different if this is in VMALLOC_REGION */ if (is_vmalloc_addr(start_addr)) - sg_addr = page_to_phys(vmalloc_to_page(start_addr)) + sg_addr = phys_to_abs(page_to_phys(vmalloc_to_page(start_addr))) + offset_in_page(sg_addr); else - sg_addr = __pa(sg_addr); + sg_addr = virt_to_abs(sg_addr); end_addr = sg_addr + len; @@ -264,17 +265,17 @@ void nx_ctx_init(struct nx_crypto_ctx *nx_ctx, unsigned int function) nx_ctx->csbcpb->csb.valid |= NX_CSB_VALID_BIT; nx_ctx->op.flags = function; - nx_ctx->op.csbcpb = __pa(nx_ctx->csbcpb); - nx_ctx->op.in = __pa(nx_ctx->in_sg); - nx_ctx->op.out = __pa(nx_ctx->out_sg); + nx_ctx->op.csbcpb = virt_to_abs(nx_ctx->csbcpb); + nx_ctx->op.in = virt_to_abs(nx_ctx->in_sg); + nx_ctx->op.out = virt_to_abs(nx_ctx->out_sg); if (nx_ctx->csbcpb_aead) { nx_ctx->csbcpb_aead->csb.valid |= NX_CSB_VALID_BIT; nx_ctx->op_aead.flags = function; - nx_ctx->op_aead.csbcpb = __pa(nx_ctx->csbcpb_aead); - nx_ctx->op_aead.in = __pa(nx_ctx->in_sg); - nx_ctx->op_aead.out = __pa(nx_ctx->out_sg); + nx_ctx->op_aead.csbcpb = virt_to_abs(nx_ctx->csbcpb_aead); + nx_ctx->op_aead.in = virt_to_abs(nx_ctx->in_sg); + nx_ctx->op_aead.out = virt_to_abs(nx_ctx->out_sg); } } diff --git a/trunk/drivers/crypto/omap-aes.c b/trunk/drivers/crypto/omap-aes.c index 093a8af59cbe..63e57b57a12c 100644 --- a/trunk/drivers/crypto/omap-aes.c +++ b/trunk/drivers/crypto/omap-aes.c @@ -876,6 +876,7 @@ static int omap_aes_probe(struct platform_device *pdev) for (i = 0; i < ARRAY_SIZE(algs); i++) { pr_debug("i: %d\n", i); + INIT_LIST_HEAD(&algs[i].cra_list); err = crypto_register_alg(&algs[i]); if (err) goto err_algs; diff --git a/trunk/drivers/crypto/padlock-aes.c b/trunk/drivers/crypto/padlock-aes.c index 633ba945e153..37b2e9406af6 100644 --- a/trunk/drivers/crypto/padlock-aes.c +++ b/trunk/drivers/crypto/padlock-aes.c @@ -328,6 +328,7 @@ static struct crypto_alg aes_alg = { .cra_ctxsize = sizeof(struct aes_ctx), .cra_alignmask = PADLOCK_ALIGNMENT - 1, .cra_module = THIS_MODULE, + .cra_list = LIST_HEAD_INIT(aes_alg.cra_list), .cra_u = { .cipher = { .cia_min_keysize = AES_MIN_KEY_SIZE, @@ -407,6 +408,7 @@ static struct crypto_alg ecb_aes_alg = { .cra_alignmask = PADLOCK_ALIGNMENT - 1, .cra_type = &crypto_blkcipher_type, .cra_module = THIS_MODULE, + .cra_list = LIST_HEAD_INIT(ecb_aes_alg.cra_list), .cra_u = { .blkcipher = { .min_keysize = AES_MIN_KEY_SIZE, @@ -489,6 +491,7 @@ static struct crypto_alg cbc_aes_alg = { .cra_alignmask = PADLOCK_ALIGNMENT - 1, .cra_type = &crypto_blkcipher_type, .cra_module = THIS_MODULE, + .cra_list = LIST_HEAD_INIT(cbc_aes_alg.cra_list), .cra_u = { .blkcipher = { .min_keysize = AES_MIN_KEY_SIZE, diff --git a/trunk/drivers/crypto/s5p-sss.c b/trunk/drivers/crypto/s5p-sss.c index a22714412cda..bc986f806086 100644 --- a/trunk/drivers/crypto/s5p-sss.c +++ b/trunk/drivers/crypto/s5p-sss.c @@ -626,6 +626,7 @@ static int s5p_aes_probe(struct platform_device *pdev) crypto_init_queue(&pdata->queue, CRYPTO_QUEUE_LEN); for (i = 0; i < ARRAY_SIZE(algs); i++) { + INIT_LIST_HEAD(&algs[i].cra_list); err = crypto_register_alg(&algs[i]); if (err) goto err_algs; diff --git a/trunk/drivers/crypto/talitos.c b/trunk/drivers/crypto/talitos.c index da1112765a44..efff788d2f1d 100644 --- a/trunk/drivers/crypto/talitos.c +++ b/trunk/drivers/crypto/talitos.c @@ -38,7 +38,6 @@ #include #include #include -#include #include #include @@ -715,13 +714,8 @@ static int aead_setkey(struct crypto_aead *authenc, /* * talitos_edesc - s/w-extended descriptor - * @assoc_nents: number of segments in associated data scatterlist * @src_nents: number of segments in input scatterlist * @dst_nents: number of segments in output scatterlist - * @assoc_chained: whether assoc is chained or not - * @src_chained: whether src is chained or not - * @dst_chained: whether dst is chained or not - * @iv_dma: dma address of iv for checking continuity and link table * @dma_len: length of dma mapped link_tbl space * @dma_link_tbl: bus physical address of link_tbl * @desc: h/w descriptor @@ -732,13 +726,10 @@ static int aead_setkey(struct crypto_aead *authenc, * of link_tbl data */ struct talitos_edesc { - int assoc_nents; int src_nents; int dst_nents; - bool assoc_chained; - bool src_chained; - bool dst_chained; - dma_addr_t iv_dma; + int src_is_chained; + int dst_is_chained; int dma_len; dma_addr_t dma_link_tbl; struct talitos_desc desc; @@ -747,7 +738,7 @@ struct talitos_edesc { static int talitos_map_sg(struct device *dev, struct scatterlist *sg, unsigned int nents, enum dma_data_direction dir, - bool chained) + int chained) { if (unlikely(chained)) while (sg) { @@ -777,13 +768,13 @@ static void talitos_sg_unmap(struct device *dev, unsigned int dst_nents = edesc->dst_nents ? : 1; if (src != dst) { - if (edesc->src_chained) + if (edesc->src_is_chained) talitos_unmap_sg_chain(dev, src, DMA_TO_DEVICE); else dma_unmap_sg(dev, src, src_nents, DMA_TO_DEVICE); if (dst) { - if (edesc->dst_chained) + if (edesc->dst_is_chained) talitos_unmap_sg_chain(dev, dst, DMA_FROM_DEVICE); else @@ -791,7 +782,7 @@ static void talitos_sg_unmap(struct device *dev, DMA_FROM_DEVICE); } } else - if (edesc->src_chained) + if (edesc->src_is_chained) talitos_unmap_sg_chain(dev, src, DMA_BIDIRECTIONAL); else dma_unmap_sg(dev, src, src_nents, DMA_BIDIRECTIONAL); @@ -806,13 +797,7 @@ static void ipsec_esp_unmap(struct device *dev, unmap_single_talitos_ptr(dev, &edesc->desc.ptr[2], DMA_TO_DEVICE); unmap_single_talitos_ptr(dev, &edesc->desc.ptr[0], DMA_TO_DEVICE); - if (edesc->assoc_chained) - talitos_unmap_sg_chain(dev, areq->assoc, DMA_TO_DEVICE); - else - /* assoc_nents counts also for IV in non-contiguous cases */ - dma_unmap_sg(dev, areq->assoc, - edesc->assoc_nents ? edesc->assoc_nents - 1 : 1, - DMA_TO_DEVICE); + dma_unmap_sg(dev, areq->assoc, 1, DMA_TO_DEVICE); talitos_sg_unmap(dev, edesc, areq->src, areq->dst); @@ -840,10 +825,9 @@ static void ipsec_esp_encrypt_done(struct device *dev, ipsec_esp_unmap(dev, edesc, areq); /* copy the generated ICV to dst */ - if (edesc->dst_nents) { + if (edesc->dma_len) { icvdata = &edesc->link_tbl[edesc->src_nents + - edesc->dst_nents + 2 + - edesc->assoc_nents]; + edesc->dst_nents + 2]; sg = sg_last(areq->dst, edesc->dst_nents); memcpy((char *)sg_virt(sg) + sg->length - ctx->authsize, icvdata, ctx->authsize); @@ -873,8 +857,7 @@ static void ipsec_esp_decrypt_swauth_done(struct device *dev, /* auth check */ if (edesc->dma_len) icvdata = &edesc->link_tbl[edesc->src_nents + - edesc->dst_nents + 2 + - edesc->assoc_nents]; + edesc->dst_nents + 2]; else icvdata = &edesc->link_tbl[0]; @@ -949,9 +932,10 @@ static int sg_to_link_tbl(struct scatterlist *sg, int sg_count, * fill in and submit ipsec_esp descriptor */ static int ipsec_esp(struct talitos_edesc *edesc, struct aead_request *areq, - u64 seq, void (*callback) (struct device *dev, - struct talitos_desc *desc, - void *context, int error)) + u8 *giv, u64 seq, + void (*callback) (struct device *dev, + struct talitos_desc *desc, + void *context, int error)) { struct crypto_aead *aead = crypto_aead_reqtfm(areq); struct talitos_ctx *ctx = crypto_aead_ctx(aead); @@ -966,42 +950,12 @@ static int ipsec_esp(struct talitos_edesc *edesc, struct aead_request *areq, /* hmac key */ map_single_talitos_ptr(dev, &desc->ptr[0], ctx->authkeylen, &ctx->key, 0, DMA_TO_DEVICE); - /* hmac data */ - desc->ptr[1].len = cpu_to_be16(areq->assoclen + ivsize); - if (edesc->assoc_nents) { - int tbl_off = edesc->src_nents + edesc->dst_nents + 2; - struct talitos_ptr *tbl_ptr = &edesc->link_tbl[tbl_off]; - - to_talitos_ptr(&desc->ptr[1], edesc->dma_link_tbl + tbl_off * - sizeof(struct talitos_ptr)); - desc->ptr[1].j_extent = DESC_PTR_LNKTBL_JUMP; - - /* assoc_nents - 1 entries for assoc, 1 for IV */ - sg_count = sg_to_link_tbl(areq->assoc, edesc->assoc_nents - 1, - areq->assoclen, tbl_ptr); - - /* add IV to link table */ - tbl_ptr += sg_count - 1; - tbl_ptr->j_extent = 0; - tbl_ptr++; - to_talitos_ptr(tbl_ptr, edesc->iv_dma); - tbl_ptr->len = cpu_to_be16(ivsize); - tbl_ptr->j_extent = DESC_PTR_LNKTBL_RETURN; - - dma_sync_single_for_device(dev, edesc->dma_link_tbl, - edesc->dma_len, DMA_BIDIRECTIONAL); - } else { - to_talitos_ptr(&desc->ptr[1], sg_dma_address(areq->assoc)); - desc->ptr[1].j_extent = 0; - } - + map_single_talitos_ptr(dev, &desc->ptr[1], areq->assoclen + ivsize, + sg_virt(areq->assoc), 0, DMA_TO_DEVICE); /* cipher iv */ - to_talitos_ptr(&desc->ptr[2], edesc->iv_dma); - desc->ptr[2].len = cpu_to_be16(ivsize); - desc->ptr[2].j_extent = 0; - /* Sync needed for the aead_givencrypt case */ - dma_sync_single_for_device(dev, edesc->iv_dma, ivsize, DMA_TO_DEVICE); + map_single_talitos_ptr(dev, &desc->ptr[2], ivsize, giv ?: areq->iv, 0, + DMA_TO_DEVICE); /* cipher key */ map_single_talitos_ptr(dev, &desc->ptr[3], ctx->enckeylen, @@ -1020,7 +974,7 @@ static int ipsec_esp(struct talitos_edesc *edesc, struct aead_request *areq, sg_count = talitos_map_sg(dev, areq->src, edesc->src_nents ? : 1, (areq->src == areq->dst) ? DMA_BIDIRECTIONAL : DMA_TO_DEVICE, - edesc->src_chained); + edesc->src_is_chained); if (sg_count == 1) { to_talitos_ptr(&desc->ptr[4], sg_dma_address(areq->src)); @@ -1052,30 +1006,32 @@ static int ipsec_esp(struct talitos_edesc *edesc, struct aead_request *areq, if (areq->src != areq->dst) sg_count = talitos_map_sg(dev, areq->dst, edesc->dst_nents ? : 1, - DMA_FROM_DEVICE, edesc->dst_chained); + DMA_FROM_DEVICE, + edesc->dst_is_chained); if (sg_count == 1) { to_talitos_ptr(&desc->ptr[5], sg_dma_address(areq->dst)); } else { - int tbl_off = edesc->src_nents + 1; - struct talitos_ptr *tbl_ptr = &edesc->link_tbl[tbl_off]; + struct talitos_ptr *link_tbl_ptr = + &edesc->link_tbl[edesc->src_nents + 1]; to_talitos_ptr(&desc->ptr[5], edesc->dma_link_tbl + - tbl_off * sizeof(struct talitos_ptr)); + (edesc->src_nents + 1) * + sizeof(struct talitos_ptr)); sg_count = sg_to_link_tbl(areq->dst, sg_count, cryptlen, - tbl_ptr); + link_tbl_ptr); /* Add an entry to the link table for ICV data */ - tbl_ptr += sg_count - 1; - tbl_ptr->j_extent = 0; - tbl_ptr++; - tbl_ptr->j_extent = DESC_PTR_LNKTBL_RETURN; - tbl_ptr->len = cpu_to_be16(authsize); + link_tbl_ptr += sg_count - 1; + link_tbl_ptr->j_extent = 0; + sg_count++; + link_tbl_ptr++; + link_tbl_ptr->j_extent = DESC_PTR_LNKTBL_RETURN; + link_tbl_ptr->len = cpu_to_be16(authsize); /* icv data follows link tables */ - to_talitos_ptr(tbl_ptr, edesc->dma_link_tbl + - (tbl_off + edesc->dst_nents + 1 + - edesc->assoc_nents) * + to_talitos_ptr(link_tbl_ptr, edesc->dma_link_tbl + + (edesc->src_nents + edesc->dst_nents + 2) * sizeof(struct talitos_ptr)); desc->ptr[5].j_extent |= DESC_PTR_LNKTBL_JUMP; dma_sync_single_for_device(ctx->dev, edesc->dma_link_tbl, @@ -1097,17 +1053,17 @@ static int ipsec_esp(struct talitos_edesc *edesc, struct aead_request *areq, /* * derive number of elements in scatterlist */ -static int sg_count(struct scatterlist *sg_list, int nbytes, bool *chained) +static int sg_count(struct scatterlist *sg_list, int nbytes, int *chained) { struct scatterlist *sg = sg_list; int sg_nents = 0; - *chained = false; + *chained = 0; while (nbytes > 0) { sg_nents++; nbytes -= sg->length; if (!sg_is_last(sg) && (sg + 1)->length == 0) - *chained = true; + *chained = 1; sg = scatterwalk_sg_next(sg); } @@ -1176,21 +1132,17 @@ static size_t sg_copy_end_to_buffer(struct scatterlist *sgl, unsigned int nents, * allocate and map the extended descriptor */ static struct talitos_edesc *talitos_edesc_alloc(struct device *dev, - struct scatterlist *assoc, struct scatterlist *src, struct scatterlist *dst, - u8 *iv, - unsigned int assoclen, + int hash_result, unsigned int cryptlen, unsigned int authsize, - unsigned int ivsize, int icv_stashing, u32 cryptoflags) { struct talitos_edesc *edesc; - int assoc_nents = 0, src_nents, dst_nents, alloc_len, dma_len; - bool assoc_chained = false, src_chained = false, dst_chained = false; - dma_addr_t iv_dma = 0; + int src_nents, dst_nents, alloc_len, dma_len; + int src_chained, dst_chained = 0; gfp_t flags = cryptoflags & CRYPTO_TFM_REQ_MAY_SLEEP ? GFP_KERNEL : GFP_ATOMIC; @@ -1199,29 +1151,10 @@ static struct talitos_edesc *talitos_edesc_alloc(struct device *dev, return ERR_PTR(-EINVAL); } - if (iv) - iv_dma = dma_map_single(dev, iv, ivsize, DMA_TO_DEVICE); - - if (assoc) { - /* - * Currently it is assumed that iv is provided whenever assoc - * is. - */ - BUG_ON(!iv); - - assoc_nents = sg_count(assoc, assoclen, &assoc_chained); - talitos_map_sg(dev, assoc, assoc_nents, DMA_TO_DEVICE, - assoc_chained); - assoc_nents = (assoc_nents == 1) ? 0 : assoc_nents; - - if (assoc_nents || sg_dma_address(assoc) + assoclen != iv_dma) - assoc_nents = assoc_nents ? assoc_nents + 1 : 2; - } - src_nents = sg_count(src, cryptlen + authsize, &src_chained); src_nents = (src_nents == 1) ? 0 : src_nents; - if (!dst) { + if (hash_result) { dst_nents = 0; } else { if (dst == src) { @@ -1239,9 +1172,9 @@ static struct talitos_edesc *talitos_edesc_alloc(struct device *dev, * and the ICV data itself */ alloc_len = sizeof(struct talitos_edesc); - if (assoc_nents || src_nents || dst_nents) { - dma_len = (src_nents + dst_nents + 2 + assoc_nents) * - sizeof(struct talitos_ptr) + authsize; + if (src_nents || dst_nents) { + dma_len = (src_nents + dst_nents + 2) * + sizeof(struct talitos_ptr) + authsize; alloc_len += dma_len; } else { dma_len = 0; @@ -1250,20 +1183,14 @@ static struct talitos_edesc *talitos_edesc_alloc(struct device *dev, edesc = kmalloc(alloc_len, GFP_DMA | flags); if (!edesc) { - talitos_unmap_sg_chain(dev, assoc, DMA_TO_DEVICE); - if (iv_dma) - dma_unmap_single(dev, iv_dma, ivsize, DMA_TO_DEVICE); dev_err(dev, "could not allocate edescriptor\n"); return ERR_PTR(-ENOMEM); } - edesc->assoc_nents = assoc_nents; edesc->src_nents = src_nents; edesc->dst_nents = dst_nents; - edesc->assoc_chained = assoc_chained; - edesc->src_chained = src_chained; - edesc->dst_chained = dst_chained; - edesc->iv_dma = iv_dma; + edesc->src_is_chained = src_chained; + edesc->dst_is_chained = dst_chained; edesc->dma_len = dma_len; if (dma_len) edesc->dma_link_tbl = dma_map_single(dev, &edesc->link_tbl[0], @@ -1273,16 +1200,14 @@ static struct talitos_edesc *talitos_edesc_alloc(struct device *dev, return edesc; } -static struct talitos_edesc *aead_edesc_alloc(struct aead_request *areq, u8 *iv, +static struct talitos_edesc *aead_edesc_alloc(struct aead_request *areq, int icv_stashing) { struct crypto_aead *authenc = crypto_aead_reqtfm(areq); struct talitos_ctx *ctx = crypto_aead_ctx(authenc); - unsigned int ivsize = crypto_aead_ivsize(authenc); - return talitos_edesc_alloc(ctx->dev, areq->assoc, areq->src, areq->dst, - iv, areq->assoclen, areq->cryptlen, - ctx->authsize, ivsize, icv_stashing, + return talitos_edesc_alloc(ctx->dev, areq->src, areq->dst, 0, + areq->cryptlen, ctx->authsize, icv_stashing, areq->base.flags); } @@ -1293,14 +1218,14 @@ static int aead_encrypt(struct aead_request *req) struct talitos_edesc *edesc; /* allocate extended descriptor */ - edesc = aead_edesc_alloc(req, req->iv, 0); + edesc = aead_edesc_alloc(req, 0); if (IS_ERR(edesc)) return PTR_ERR(edesc); /* set encrypt */ edesc->desc.hdr = ctx->desc_hdr_template | DESC_HDR_MODE0_ENCRYPT; - return ipsec_esp(edesc, req, 0, ipsec_esp_encrypt_done); + return ipsec_esp(edesc, req, NULL, 0, ipsec_esp_encrypt_done); } static int aead_decrypt(struct aead_request *req) @@ -1316,7 +1241,7 @@ static int aead_decrypt(struct aead_request *req) req->cryptlen -= authsize; /* allocate extended descriptor */ - edesc = aead_edesc_alloc(req, req->iv, 1); + edesc = aead_edesc_alloc(req, 1); if (IS_ERR(edesc)) return PTR_ERR(edesc); @@ -1332,7 +1257,9 @@ static int aead_decrypt(struct aead_request *req) /* reset integrity check result bits */ edesc->desc.hdr_lo = 0; - return ipsec_esp(edesc, req, 0, ipsec_esp_decrypt_hwauth_done); + return ipsec_esp(edesc, req, NULL, 0, + ipsec_esp_decrypt_hwauth_done); + } /* Have to check the ICV with software */ @@ -1341,8 +1268,7 @@ static int aead_decrypt(struct aead_request *req) /* stash incoming ICV for later cmp with ICV generated by the h/w */ if (edesc->dma_len) icvdata = &edesc->link_tbl[edesc->src_nents + - edesc->dst_nents + 2 + - edesc->assoc_nents]; + edesc->dst_nents + 2]; else icvdata = &edesc->link_tbl[0]; @@ -1351,7 +1277,7 @@ static int aead_decrypt(struct aead_request *req) memcpy(icvdata, (char *)sg_virt(sg) + sg->length - ctx->authsize, ctx->authsize); - return ipsec_esp(edesc, req, 0, ipsec_esp_decrypt_swauth_done); + return ipsec_esp(edesc, req, NULL, 0, ipsec_esp_decrypt_swauth_done); } static int aead_givencrypt(struct aead_givcrypt_request *req) @@ -1362,7 +1288,7 @@ static int aead_givencrypt(struct aead_givcrypt_request *req) struct talitos_edesc *edesc; /* allocate extended descriptor */ - edesc = aead_edesc_alloc(areq, req->giv, 0); + edesc = aead_edesc_alloc(areq, 0); if (IS_ERR(edesc)) return PTR_ERR(edesc); @@ -1373,7 +1299,8 @@ static int aead_givencrypt(struct aead_givcrypt_request *req) /* avoid consecutive packets going out with same IV */ *(__be64 *)req->giv ^= cpu_to_be64(req->seq); - return ipsec_esp(edesc, areq, req->seq, ipsec_esp_encrypt_done); + return ipsec_esp(edesc, areq, req->giv, req->seq, + ipsec_esp_encrypt_done); } static int ablkcipher_setkey(struct crypto_ablkcipher *cipher, @@ -1429,7 +1356,7 @@ static int common_nonsnoop(struct talitos_edesc *edesc, struct device *dev = ctx->dev; struct talitos_desc *desc = &edesc->desc; unsigned int cryptlen = areq->nbytes; - unsigned int ivsize = crypto_ablkcipher_ivsize(cipher); + unsigned int ivsize; int sg_count, ret; /* first DWORD empty */ @@ -1438,9 +1365,9 @@ static int common_nonsnoop(struct talitos_edesc *edesc, desc->ptr[0].j_extent = 0; /* cipher iv */ - to_talitos_ptr(&desc->ptr[1], edesc->iv_dma); - desc->ptr[1].len = cpu_to_be16(ivsize); - desc->ptr[1].j_extent = 0; + ivsize = crypto_ablkcipher_ivsize(cipher); + map_single_talitos_ptr(dev, &desc->ptr[1], ivsize, areq->info, 0, + DMA_TO_DEVICE); /* cipher key */ map_single_talitos_ptr(dev, &desc->ptr[2], ctx->keylen, @@ -1455,7 +1382,7 @@ static int common_nonsnoop(struct talitos_edesc *edesc, sg_count = talitos_map_sg(dev, areq->src, edesc->src_nents ? : 1, (areq->src == areq->dst) ? DMA_BIDIRECTIONAL : DMA_TO_DEVICE, - edesc->src_chained); + edesc->src_is_chained); if (sg_count == 1) { to_talitos_ptr(&desc->ptr[3], sg_dma_address(areq->src)); @@ -1482,7 +1409,8 @@ static int common_nonsnoop(struct talitos_edesc *edesc, if (areq->src != areq->dst) sg_count = talitos_map_sg(dev, areq->dst, edesc->dst_nents ? : 1, - DMA_FROM_DEVICE, edesc->dst_chained); + DMA_FROM_DEVICE, + edesc->dst_is_chained); if (sg_count == 1) { to_talitos_ptr(&desc->ptr[4], sg_dma_address(areq->dst)); @@ -1522,11 +1450,9 @@ static struct talitos_edesc *ablkcipher_edesc_alloc(struct ablkcipher_request * { struct crypto_ablkcipher *cipher = crypto_ablkcipher_reqtfm(areq); struct talitos_ctx *ctx = crypto_ablkcipher_ctx(cipher); - unsigned int ivsize = crypto_ablkcipher_ivsize(cipher); - return talitos_edesc_alloc(ctx->dev, NULL, areq->src, areq->dst, - areq->info, 0, areq->nbytes, 0, ivsize, 0, - areq->base.flags); + return talitos_edesc_alloc(ctx->dev, areq->src, areq->dst, 0, + areq->nbytes, 0, 0, areq->base.flags); } static int ablkcipher_encrypt(struct ablkcipher_request *areq) @@ -1652,7 +1578,8 @@ static int common_nonsnoop_hash(struct talitos_edesc *edesc, sg_count = talitos_map_sg(dev, req_ctx->psrc, edesc->src_nents ? : 1, - DMA_TO_DEVICE, edesc->src_chained); + DMA_TO_DEVICE, + edesc->src_is_chained); if (sg_count == 1) { to_talitos_ptr(&desc->ptr[3], sg_dma_address(req_ctx->psrc)); @@ -1704,8 +1631,8 @@ static struct talitos_edesc *ahash_edesc_alloc(struct ahash_request *areq, struct talitos_ctx *ctx = crypto_ahash_ctx(tfm); struct talitos_ahash_req_ctx *req_ctx = ahash_request_ctx(areq); - return talitos_edesc_alloc(ctx->dev, NULL, req_ctx->psrc, NULL, NULL, 0, - nbytes, 0, 0, 0, areq->base.flags); + return talitos_edesc_alloc(ctx->dev, req_ctx->psrc, NULL, 1, + nbytes, 0, 0, areq->base.flags); } static int ahash_init(struct ahash_request *areq) @@ -1763,7 +1690,7 @@ static int ahash_process_req(struct ahash_request *areq, unsigned int nbytes) unsigned int nbytes_to_hash; unsigned int to_hash_later; unsigned int nsg; - bool chained; + int chained; if (!req_ctx->last && (nbytes + req_ctx->nbuf <= blocksize)) { /* Buffer up to one whole block */ @@ -1975,18 +1902,21 @@ struct talitos_alg_template { }; static struct talitos_alg_template driver_algs[] = { - /* - * AEAD algorithms. These use a single-pass ipsec_esp descriptor. - * authencesn(*,*) is also registered, although not present - * explicitly here. - */ + /* AEAD algorithms. These use a single-pass ipsec_esp descriptor */ { .type = CRYPTO_ALG_TYPE_AEAD, .alg.crypto = { .cra_name = "authenc(hmac(sha1),cbc(aes))", .cra_driver_name = "authenc-hmac-sha1-cbc-aes-talitos", .cra_blocksize = AES_BLOCK_SIZE, .cra_flags = CRYPTO_ALG_TYPE_AEAD | CRYPTO_ALG_ASYNC, + .cra_type = &crypto_aead_type, .cra_aead = { + .setkey = aead_setkey, + .setauthsize = aead_setauthsize, + .encrypt = aead_encrypt, + .decrypt = aead_decrypt, + .givencrypt = aead_givencrypt, + .geniv = "", .ivsize = AES_BLOCK_SIZE, .maxauthsize = SHA1_DIGEST_SIZE, } @@ -2005,7 +1935,14 @@ static struct talitos_alg_template driver_algs[] = { .cra_driver_name = "authenc-hmac-sha1-cbc-3des-talitos", .cra_blocksize = DES3_EDE_BLOCK_SIZE, .cra_flags = CRYPTO_ALG_TYPE_AEAD | CRYPTO_ALG_ASYNC, + .cra_type = &crypto_aead_type, .cra_aead = { + .setkey = aead_setkey, + .setauthsize = aead_setauthsize, + .encrypt = aead_encrypt, + .decrypt = aead_decrypt, + .givencrypt = aead_givencrypt, + .geniv = "", .ivsize = DES3_EDE_BLOCK_SIZE, .maxauthsize = SHA1_DIGEST_SIZE, } @@ -2025,7 +1962,14 @@ static struct talitos_alg_template driver_algs[] = { .cra_driver_name = "authenc-hmac-sha224-cbc-aes-talitos", .cra_blocksize = AES_BLOCK_SIZE, .cra_flags = CRYPTO_ALG_TYPE_AEAD | CRYPTO_ALG_ASYNC, + .cra_type = &crypto_aead_type, .cra_aead = { + .setkey = aead_setkey, + .setauthsize = aead_setauthsize, + .encrypt = aead_encrypt, + .decrypt = aead_decrypt, + .givencrypt = aead_givencrypt, + .geniv = "", .ivsize = AES_BLOCK_SIZE, .maxauthsize = SHA224_DIGEST_SIZE, } @@ -2044,7 +1988,14 @@ static struct talitos_alg_template driver_algs[] = { .cra_driver_name = "authenc-hmac-sha224-cbc-3des-talitos", .cra_blocksize = DES3_EDE_BLOCK_SIZE, .cra_flags = CRYPTO_ALG_TYPE_AEAD | CRYPTO_ALG_ASYNC, + .cra_type = &crypto_aead_type, .cra_aead = { + .setkey = aead_setkey, + .setauthsize = aead_setauthsize, + .encrypt = aead_encrypt, + .decrypt = aead_decrypt, + .givencrypt = aead_givencrypt, + .geniv = "", .ivsize = DES3_EDE_BLOCK_SIZE, .maxauthsize = SHA224_DIGEST_SIZE, } @@ -2064,7 +2015,14 @@ static struct talitos_alg_template driver_algs[] = { .cra_driver_name = "authenc-hmac-sha256-cbc-aes-talitos", .cra_blocksize = AES_BLOCK_SIZE, .cra_flags = CRYPTO_ALG_TYPE_AEAD | CRYPTO_ALG_ASYNC, + .cra_type = &crypto_aead_type, .cra_aead = { + .setkey = aead_setkey, + .setauthsize = aead_setauthsize, + .encrypt = aead_encrypt, + .decrypt = aead_decrypt, + .givencrypt = aead_givencrypt, + .geniv = "", .ivsize = AES_BLOCK_SIZE, .maxauthsize = SHA256_DIGEST_SIZE, } @@ -2083,7 +2041,14 @@ static struct talitos_alg_template driver_algs[] = { .cra_driver_name = "authenc-hmac-sha256-cbc-3des-talitos", .cra_blocksize = DES3_EDE_BLOCK_SIZE, .cra_flags = CRYPTO_ALG_TYPE_AEAD | CRYPTO_ALG_ASYNC, + .cra_type = &crypto_aead_type, .cra_aead = { + .setkey = aead_setkey, + .setauthsize = aead_setauthsize, + .encrypt = aead_encrypt, + .decrypt = aead_decrypt, + .givencrypt = aead_givencrypt, + .geniv = "", .ivsize = DES3_EDE_BLOCK_SIZE, .maxauthsize = SHA256_DIGEST_SIZE, } @@ -2103,7 +2068,14 @@ static struct talitos_alg_template driver_algs[] = { .cra_driver_name = "authenc-hmac-sha384-cbc-aes-talitos", .cra_blocksize = AES_BLOCK_SIZE, .cra_flags = CRYPTO_ALG_TYPE_AEAD | CRYPTO_ALG_ASYNC, + .cra_type = &crypto_aead_type, .cra_aead = { + .setkey = aead_setkey, + .setauthsize = aead_setauthsize, + .encrypt = aead_encrypt, + .decrypt = aead_decrypt, + .givencrypt = aead_givencrypt, + .geniv = "", .ivsize = AES_BLOCK_SIZE, .maxauthsize = SHA384_DIGEST_SIZE, } @@ -2122,7 +2094,14 @@ static struct talitos_alg_template driver_algs[] = { .cra_driver_name = "authenc-hmac-sha384-cbc-3des-talitos", .cra_blocksize = DES3_EDE_BLOCK_SIZE, .cra_flags = CRYPTO_ALG_TYPE_AEAD | CRYPTO_ALG_ASYNC, + .cra_type = &crypto_aead_type, .cra_aead = { + .setkey = aead_setkey, + .setauthsize = aead_setauthsize, + .encrypt = aead_encrypt, + .decrypt = aead_decrypt, + .givencrypt = aead_givencrypt, + .geniv = "", .ivsize = DES3_EDE_BLOCK_SIZE, .maxauthsize = SHA384_DIGEST_SIZE, } @@ -2142,7 +2121,14 @@ static struct talitos_alg_template driver_algs[] = { .cra_driver_name = "authenc-hmac-sha512-cbc-aes-talitos", .cra_blocksize = AES_BLOCK_SIZE, .cra_flags = CRYPTO_ALG_TYPE_AEAD | CRYPTO_ALG_ASYNC, + .cra_type = &crypto_aead_type, .cra_aead = { + .setkey = aead_setkey, + .setauthsize = aead_setauthsize, + .encrypt = aead_encrypt, + .decrypt = aead_decrypt, + .givencrypt = aead_givencrypt, + .geniv = "", .ivsize = AES_BLOCK_SIZE, .maxauthsize = SHA512_DIGEST_SIZE, } @@ -2161,7 +2147,14 @@ static struct talitos_alg_template driver_algs[] = { .cra_driver_name = "authenc-hmac-sha512-cbc-3des-talitos", .cra_blocksize = DES3_EDE_BLOCK_SIZE, .cra_flags = CRYPTO_ALG_TYPE_AEAD | CRYPTO_ALG_ASYNC, + .cra_type = &crypto_aead_type, .cra_aead = { + .setkey = aead_setkey, + .setauthsize = aead_setauthsize, + .encrypt = aead_encrypt, + .decrypt = aead_decrypt, + .givencrypt = aead_givencrypt, + .geniv = "", .ivsize = DES3_EDE_BLOCK_SIZE, .maxauthsize = SHA512_DIGEST_SIZE, } @@ -2181,7 +2174,14 @@ static struct talitos_alg_template driver_algs[] = { .cra_driver_name = "authenc-hmac-md5-cbc-aes-talitos", .cra_blocksize = AES_BLOCK_SIZE, .cra_flags = CRYPTO_ALG_TYPE_AEAD | CRYPTO_ALG_ASYNC, + .cra_type = &crypto_aead_type, .cra_aead = { + .setkey = aead_setkey, + .setauthsize = aead_setauthsize, + .encrypt = aead_encrypt, + .decrypt = aead_decrypt, + .givencrypt = aead_givencrypt, + .geniv = "", .ivsize = AES_BLOCK_SIZE, .maxauthsize = MD5_DIGEST_SIZE, } @@ -2200,7 +2200,14 @@ static struct talitos_alg_template driver_algs[] = { .cra_driver_name = "authenc-hmac-md5-cbc-3des-talitos", .cra_blocksize = DES3_EDE_BLOCK_SIZE, .cra_flags = CRYPTO_ALG_TYPE_AEAD | CRYPTO_ALG_ASYNC, + .cra_type = &crypto_aead_type, .cra_aead = { + .setkey = aead_setkey, + .setauthsize = aead_setauthsize, + .encrypt = aead_encrypt, + .decrypt = aead_decrypt, + .givencrypt = aead_givencrypt, + .geniv = "", .ivsize = DES3_EDE_BLOCK_SIZE, .maxauthsize = MD5_DIGEST_SIZE, } @@ -2222,7 +2229,12 @@ static struct talitos_alg_template driver_algs[] = { .cra_blocksize = AES_BLOCK_SIZE, .cra_flags = CRYPTO_ALG_TYPE_ABLKCIPHER | CRYPTO_ALG_ASYNC, + .cra_type = &crypto_ablkcipher_type, .cra_ablkcipher = { + .setkey = ablkcipher_setkey, + .encrypt = ablkcipher_encrypt, + .decrypt = ablkcipher_decrypt, + .geniv = "eseqiv", .min_keysize = AES_MIN_KEY_SIZE, .max_keysize = AES_MAX_KEY_SIZE, .ivsize = AES_BLOCK_SIZE, @@ -2239,7 +2251,12 @@ static struct talitos_alg_template driver_algs[] = { .cra_blocksize = DES3_EDE_BLOCK_SIZE, .cra_flags = CRYPTO_ALG_TYPE_ABLKCIPHER | CRYPTO_ALG_ASYNC, + .cra_type = &crypto_ablkcipher_type, .cra_ablkcipher = { + .setkey = ablkcipher_setkey, + .encrypt = ablkcipher_encrypt, + .decrypt = ablkcipher_decrypt, + .geniv = "eseqiv", .min_keysize = DES3_EDE_KEY_SIZE, .max_keysize = DES3_EDE_KEY_SIZE, .ivsize = DES3_EDE_BLOCK_SIZE, @@ -2253,6 +2270,11 @@ static struct talitos_alg_template driver_algs[] = { /* AHASH algorithms. */ { .type = CRYPTO_ALG_TYPE_AHASH, .alg.hash = { + .init = ahash_init, + .update = ahash_update, + .final = ahash_final, + .finup = ahash_finup, + .digest = ahash_digest, .halg.digestsize = MD5_DIGEST_SIZE, .halg.base = { .cra_name = "md5", @@ -2260,6 +2282,7 @@ static struct talitos_alg_template driver_algs[] = { .cra_blocksize = MD5_BLOCK_SIZE, .cra_flags = CRYPTO_ALG_TYPE_AHASH | CRYPTO_ALG_ASYNC, + .cra_type = &crypto_ahash_type } }, .desc_hdr_template = DESC_HDR_TYPE_COMMON_NONSNOOP_NO_AFEU | @@ -2268,6 +2291,11 @@ static struct talitos_alg_template driver_algs[] = { }, { .type = CRYPTO_ALG_TYPE_AHASH, .alg.hash = { + .init = ahash_init, + .update = ahash_update, + .final = ahash_final, + .finup = ahash_finup, + .digest = ahash_digest, .halg.digestsize = SHA1_DIGEST_SIZE, .halg.base = { .cra_name = "sha1", @@ -2275,6 +2303,7 @@ static struct talitos_alg_template driver_algs[] = { .cra_blocksize = SHA1_BLOCK_SIZE, .cra_flags = CRYPTO_ALG_TYPE_AHASH | CRYPTO_ALG_ASYNC, + .cra_type = &crypto_ahash_type } }, .desc_hdr_template = DESC_HDR_TYPE_COMMON_NONSNOOP_NO_AFEU | @@ -2283,6 +2312,11 @@ static struct talitos_alg_template driver_algs[] = { }, { .type = CRYPTO_ALG_TYPE_AHASH, .alg.hash = { + .init = ahash_init, + .update = ahash_update, + .final = ahash_final, + .finup = ahash_finup, + .digest = ahash_digest, .halg.digestsize = SHA224_DIGEST_SIZE, .halg.base = { .cra_name = "sha224", @@ -2290,6 +2324,7 @@ static struct talitos_alg_template driver_algs[] = { .cra_blocksize = SHA224_BLOCK_SIZE, .cra_flags = CRYPTO_ALG_TYPE_AHASH | CRYPTO_ALG_ASYNC, + .cra_type = &crypto_ahash_type } }, .desc_hdr_template = DESC_HDR_TYPE_COMMON_NONSNOOP_NO_AFEU | @@ -2298,6 +2333,11 @@ static struct talitos_alg_template driver_algs[] = { }, { .type = CRYPTO_ALG_TYPE_AHASH, .alg.hash = { + .init = ahash_init, + .update = ahash_update, + .final = ahash_final, + .finup = ahash_finup, + .digest = ahash_digest, .halg.digestsize = SHA256_DIGEST_SIZE, .halg.base = { .cra_name = "sha256", @@ -2305,6 +2345,7 @@ static struct talitos_alg_template driver_algs[] = { .cra_blocksize = SHA256_BLOCK_SIZE, .cra_flags = CRYPTO_ALG_TYPE_AHASH | CRYPTO_ALG_ASYNC, + .cra_type = &crypto_ahash_type } }, .desc_hdr_template = DESC_HDR_TYPE_COMMON_NONSNOOP_NO_AFEU | @@ -2313,6 +2354,11 @@ static struct talitos_alg_template driver_algs[] = { }, { .type = CRYPTO_ALG_TYPE_AHASH, .alg.hash = { + .init = ahash_init, + .update = ahash_update, + .final = ahash_final, + .finup = ahash_finup, + .digest = ahash_digest, .halg.digestsize = SHA384_DIGEST_SIZE, .halg.base = { .cra_name = "sha384", @@ -2320,6 +2366,7 @@ static struct talitos_alg_template driver_algs[] = { .cra_blocksize = SHA384_BLOCK_SIZE, .cra_flags = CRYPTO_ALG_TYPE_AHASH | CRYPTO_ALG_ASYNC, + .cra_type = &crypto_ahash_type } }, .desc_hdr_template = DESC_HDR_TYPE_COMMON_NONSNOOP_NO_AFEU | @@ -2328,6 +2375,11 @@ static struct talitos_alg_template driver_algs[] = { }, { .type = CRYPTO_ALG_TYPE_AHASH, .alg.hash = { + .init = ahash_init, + .update = ahash_update, + .final = ahash_final, + .finup = ahash_finup, + .digest = ahash_digest, .halg.digestsize = SHA512_DIGEST_SIZE, .halg.base = { .cra_name = "sha512", @@ -2335,6 +2387,7 @@ static struct talitos_alg_template driver_algs[] = { .cra_blocksize = SHA512_BLOCK_SIZE, .cra_flags = CRYPTO_ALG_TYPE_AHASH | CRYPTO_ALG_ASYNC, + .cra_type = &crypto_ahash_type } }, .desc_hdr_template = DESC_HDR_TYPE_COMMON_NONSNOOP_NO_AFEU | @@ -2343,6 +2396,12 @@ static struct talitos_alg_template driver_algs[] = { }, { .type = CRYPTO_ALG_TYPE_AHASH, .alg.hash = { + .init = ahash_init, + .update = ahash_update, + .final = ahash_final, + .finup = ahash_finup, + .digest = ahash_digest, + .setkey = ahash_setkey, .halg.digestsize = MD5_DIGEST_SIZE, .halg.base = { .cra_name = "hmac(md5)", @@ -2350,6 +2409,7 @@ static struct talitos_alg_template driver_algs[] = { .cra_blocksize = MD5_BLOCK_SIZE, .cra_flags = CRYPTO_ALG_TYPE_AHASH | CRYPTO_ALG_ASYNC, + .cra_type = &crypto_ahash_type } }, .desc_hdr_template = DESC_HDR_TYPE_COMMON_NONSNOOP_NO_AFEU | @@ -2358,6 +2418,12 @@ static struct talitos_alg_template driver_algs[] = { }, { .type = CRYPTO_ALG_TYPE_AHASH, .alg.hash = { + .init = ahash_init, + .update = ahash_update, + .final = ahash_final, + .finup = ahash_finup, + .digest = ahash_digest, + .setkey = ahash_setkey, .halg.digestsize = SHA1_DIGEST_SIZE, .halg.base = { .cra_name = "hmac(sha1)", @@ -2365,6 +2431,7 @@ static struct talitos_alg_template driver_algs[] = { .cra_blocksize = SHA1_BLOCK_SIZE, .cra_flags = CRYPTO_ALG_TYPE_AHASH | CRYPTO_ALG_ASYNC, + .cra_type = &crypto_ahash_type } }, .desc_hdr_template = DESC_HDR_TYPE_COMMON_NONSNOOP_NO_AFEU | @@ -2373,6 +2440,12 @@ static struct talitos_alg_template driver_algs[] = { }, { .type = CRYPTO_ALG_TYPE_AHASH, .alg.hash = { + .init = ahash_init, + .update = ahash_update, + .final = ahash_final, + .finup = ahash_finup, + .digest = ahash_digest, + .setkey = ahash_setkey, .halg.digestsize = SHA224_DIGEST_SIZE, .halg.base = { .cra_name = "hmac(sha224)", @@ -2380,6 +2453,7 @@ static struct talitos_alg_template driver_algs[] = { .cra_blocksize = SHA224_BLOCK_SIZE, .cra_flags = CRYPTO_ALG_TYPE_AHASH | CRYPTO_ALG_ASYNC, + .cra_type = &crypto_ahash_type } }, .desc_hdr_template = DESC_HDR_TYPE_COMMON_NONSNOOP_NO_AFEU | @@ -2388,6 +2462,12 @@ static struct talitos_alg_template driver_algs[] = { }, { .type = CRYPTO_ALG_TYPE_AHASH, .alg.hash = { + .init = ahash_init, + .update = ahash_update, + .final = ahash_final, + .finup = ahash_finup, + .digest = ahash_digest, + .setkey = ahash_setkey, .halg.digestsize = SHA256_DIGEST_SIZE, .halg.base = { .cra_name = "hmac(sha256)", @@ -2395,6 +2475,7 @@ static struct talitos_alg_template driver_algs[] = { .cra_blocksize = SHA256_BLOCK_SIZE, .cra_flags = CRYPTO_ALG_TYPE_AHASH | CRYPTO_ALG_ASYNC, + .cra_type = &crypto_ahash_type } }, .desc_hdr_template = DESC_HDR_TYPE_COMMON_NONSNOOP_NO_AFEU | @@ -2403,6 +2484,12 @@ static struct talitos_alg_template driver_algs[] = { }, { .type = CRYPTO_ALG_TYPE_AHASH, .alg.hash = { + .init = ahash_init, + .update = ahash_update, + .final = ahash_final, + .finup = ahash_finup, + .digest = ahash_digest, + .setkey = ahash_setkey, .halg.digestsize = SHA384_DIGEST_SIZE, .halg.base = { .cra_name = "hmac(sha384)", @@ -2410,6 +2497,7 @@ static struct talitos_alg_template driver_algs[] = { .cra_blocksize = SHA384_BLOCK_SIZE, .cra_flags = CRYPTO_ALG_TYPE_AHASH | CRYPTO_ALG_ASYNC, + .cra_type = &crypto_ahash_type } }, .desc_hdr_template = DESC_HDR_TYPE_COMMON_NONSNOOP_NO_AFEU | @@ -2418,6 +2506,12 @@ static struct talitos_alg_template driver_algs[] = { }, { .type = CRYPTO_ALG_TYPE_AHASH, .alg.hash = { + .init = ahash_init, + .update = ahash_update, + .final = ahash_final, + .finup = ahash_finup, + .digest = ahash_digest, + .setkey = ahash_setkey, .halg.digestsize = SHA512_DIGEST_SIZE, .halg.base = { .cra_name = "hmac(sha512)", @@ -2425,6 +2519,7 @@ static struct talitos_alg_template driver_algs[] = { .cra_blocksize = SHA512_BLOCK_SIZE, .cra_flags = CRYPTO_ALG_TYPE_AHASH | CRYPTO_ALG_ASYNC, + .cra_type = &crypto_ahash_type } }, .desc_hdr_template = DESC_HDR_TYPE_COMMON_NONSNOOP_NO_AFEU | @@ -2582,34 +2677,14 @@ static struct talitos_crypto_alg *talitos_alg_alloc(struct device *dev, case CRYPTO_ALG_TYPE_ABLKCIPHER: alg = &t_alg->algt.alg.crypto; alg->cra_init = talitos_cra_init; - alg->cra_type = &crypto_ablkcipher_type; - alg->cra_ablkcipher.setkey = ablkcipher_setkey; - alg->cra_ablkcipher.encrypt = ablkcipher_encrypt; - alg->cra_ablkcipher.decrypt = ablkcipher_decrypt; - alg->cra_ablkcipher.geniv = "eseqiv"; break; case CRYPTO_ALG_TYPE_AEAD: alg = &t_alg->algt.alg.crypto; alg->cra_init = talitos_cra_init_aead; - alg->cra_type = &crypto_aead_type; - alg->cra_aead.setkey = aead_setkey; - alg->cra_aead.setauthsize = aead_setauthsize; - alg->cra_aead.encrypt = aead_encrypt; - alg->cra_aead.decrypt = aead_decrypt; - alg->cra_aead.givencrypt = aead_givencrypt; - alg->cra_aead.geniv = ""; break; case CRYPTO_ALG_TYPE_AHASH: alg = &t_alg->algt.alg.hash.halg.base; alg->cra_init = talitos_cra_init_ahash; - alg->cra_type = &crypto_ahash_type; - t_alg->algt.alg.hash.init = ahash_init; - t_alg->algt.alg.hash.update = ahash_update; - t_alg->algt.alg.hash.final = ahash_final; - t_alg->algt.alg.hash.finup = ahash_finup; - t_alg->algt.alg.hash.digest = ahash_digest; - t_alg->algt.alg.hash.setkey = ahash_setkey; - if (!(priv->features & TALITOS_FTR_HMAC_OK) && !strncmp(alg->cra_name, "hmac", 4)) { kfree(t_alg); @@ -2821,9 +2896,7 @@ static int talitos_probe(struct platform_device *ofdev) if (hw_supports(dev, driver_algs[i].desc_hdr_template)) { struct talitos_crypto_alg *t_alg; char *name = NULL; - bool authenc = false; -authencesn: t_alg = talitos_alg_alloc(dev, &driver_algs[i]); if (IS_ERR(t_alg)) { err = PTR_ERR(t_alg); @@ -2838,8 +2911,6 @@ static int talitos_probe(struct platform_device *ofdev) err = crypto_register_alg( &t_alg->algt.alg.crypto); name = t_alg->algt.alg.crypto.cra_driver_name; - authenc = authenc ? !authenc : - !(bool)memcmp(name, "authenc", 7); break; case CRYPTO_ALG_TYPE_AHASH: err = crypto_register_ahash( @@ -2852,25 +2923,8 @@ static int talitos_probe(struct platform_device *ofdev) dev_err(dev, "%s alg registration failed\n", name); kfree(t_alg); - } else { + } else list_add_tail(&t_alg->entry, &priv->alg_list); - if (authenc) { - struct crypto_alg *alg = - &driver_algs[i].alg.crypto; - - name = alg->cra_name; - memmove(name + 10, name + 7, - strlen(name) - 7); - memcpy(name + 7, "esn", 3); - - name = alg->cra_driver_name; - memmove(name + 10, name + 7, - strlen(name) - 7); - memcpy(name + 7, "esn", 3); - - goto authencesn; - } - } } } if (!list_empty(&priv->alg_list)) diff --git a/trunk/drivers/crypto/tegra-aes.c b/trunk/drivers/crypto/tegra-aes.c index 37185e6630cd..ac236f6724f4 100644 --- a/trunk/drivers/crypto/tegra-aes.c +++ b/trunk/drivers/crypto/tegra-aes.c @@ -969,7 +969,6 @@ static int tegra_aes_probe(struct platform_device *pdev) aes_wq = alloc_workqueue("tegra_aes_wq", WQ_HIGHPRI | WQ_UNBOUND, 1); if (!aes_wq) { dev_err(dev, "alloc_workqueue failed\n"); - err = -ENOMEM; goto out; } @@ -1005,6 +1004,8 @@ static int tegra_aes_probe(struct platform_device *pdev) aes_dev = dd; for (i = 0; i < ARRAY_SIZE(algs); i++) { + INIT_LIST_HEAD(&algs[i].cra_list); + algs[i].cra_priority = 300; algs[i].cra_ctxsize = sizeof(struct tegra_aes_ctx); algs[i].cra_module = THIS_MODULE; diff --git a/trunk/drivers/crypto/ux500/cryp/cryp_core.c b/trunk/drivers/crypto/ux500/cryp/cryp_core.c index bc615cc56266..ef17e3871c71 100644 --- a/trunk/drivers/crypto/ux500/cryp/cryp_core.c +++ b/trunk/drivers/crypto/ux500/cryp/cryp_core.c @@ -1486,7 +1486,6 @@ static int ux500_cryp_probe(struct platform_device *pdev) if (!res_irq) { dev_err(dev, "[%s]: IORESOURCE_IRQ unavailable", __func__); - ret = -ENODEV; goto out_power; } diff --git a/trunk/drivers/crypto/ux500/hash/hash_core.c b/trunk/drivers/crypto/ux500/hash/hash_core.c index 632c3339895f..08765072a2b3 100644 --- a/trunk/drivers/crypto/ux500/hash/hash_core.c +++ b/trunk/drivers/crypto/ux500/hash/hash_core.c @@ -1991,6 +1991,7 @@ static int __init ux500_hash_mod_init(void) static void __exit ux500_hash_mod_fini(void) { platform_driver_unregister(&hash_driver); + return; } module_init(ux500_hash_mod_init); diff --git a/trunk/drivers/dma/dmaengine.c b/trunk/drivers/dma/dmaengine.c index a815d44c70a4..3491654cdf7b 100644 --- a/trunk/drivers/dma/dmaengine.c +++ b/trunk/drivers/dma/dmaengine.c @@ -582,7 +582,7 @@ void dmaengine_get(void) list_del_rcu(&device->global_node); break; } else if (err) - pr_debug("%s: failed to get %s: (%d)\n", + pr_err("%s: failed to get %s: (%d)\n", __func__, dma_chan_name(chan), err); } } diff --git a/trunk/drivers/edac/mpc85xx_edac.c b/trunk/drivers/edac/mpc85xx_edac.c index 4fe66fa183ec..a1e791ec25d3 100644 --- a/trunk/drivers/edac/mpc85xx_edac.c +++ b/trunk/drivers/edac/mpc85xx_edac.c @@ -212,7 +212,7 @@ static irqreturn_t mpc85xx_pci_isr(int irq, void *dev_id) return IRQ_HANDLED; } -int __devinit mpc85xx_pci_err_probe(struct platform_device *op) +static int __devinit mpc85xx_pci_err_probe(struct platform_device *op) { struct edac_pci_ctl_info *pci; struct mpc85xx_pci_pdata *pdata; @@ -226,16 +226,6 @@ int __devinit mpc85xx_pci_err_probe(struct platform_device *op) if (!pci) return -ENOMEM; - /* make sure error reporting method is sane */ - switch (edac_op_state) { - case EDAC_OPSTATE_POLL: - case EDAC_OPSTATE_INT: - break; - default: - edac_op_state = EDAC_OPSTATE_INT; - break; - } - pdata = pci->pvt_info; pdata->name = "mpc85xx_pci_err"; pdata->irq = NO_IRQ; @@ -325,7 +315,6 @@ int __devinit mpc85xx_pci_err_probe(struct platform_device *op) devres_release_group(&op->dev, mpc85xx_pci_err_probe); return res; } -EXPORT_SYMBOL(mpc85xx_pci_err_probe); static int mpc85xx_pci_err_remove(struct platform_device *op) { @@ -349,6 +338,27 @@ static int mpc85xx_pci_err_remove(struct platform_device *op) return 0; } +static struct of_device_id mpc85xx_pci_err_of_match[] = { + { + .compatible = "fsl,mpc8540-pcix", + }, + { + .compatible = "fsl,mpc8540-pci", + }, + {}, +}; +MODULE_DEVICE_TABLE(of, mpc85xx_pci_err_of_match); + +static struct platform_driver mpc85xx_pci_err_driver = { + .probe = mpc85xx_pci_err_probe, + .remove = __devexit_p(mpc85xx_pci_err_remove), + .driver = { + .name = "mpc85xx_pci_err", + .owner = THIS_MODULE, + .of_match_table = mpc85xx_pci_err_of_match, + }, +}; + #endif /* CONFIG_PCI */ /**************************** L2 Err device ***************************/ @@ -1200,6 +1210,12 @@ static int __init mpc85xx_mc_init(void) if (res) printk(KERN_WARNING EDAC_MOD_STR "L2 fails to register\n"); +#ifdef CONFIG_PCI + res = platform_driver_register(&mpc85xx_pci_err_driver); + if (res) + printk(KERN_WARNING EDAC_MOD_STR "PCI fails to register\n"); +#endif + #ifdef CONFIG_FSL_SOC_BOOKE pvr = mfspr(SPRN_PVR); @@ -1235,6 +1251,9 @@ static void __exit mpc85xx_mc_exit(void) (PVR_VER(pvr) == PVR_VER_E500V2)) { on_each_cpu(mpc85xx_mc_restore_hid1, NULL, 0); } +#endif +#ifdef CONFIG_PCI + platform_driver_unregister(&mpc85xx_pci_err_driver); #endif platform_driver_unregister(&mpc85xx_l2_err_driver); platform_driver_unregister(&mpc85xx_mc_err_driver); diff --git a/trunk/drivers/gpio/Kconfig b/trunk/drivers/gpio/Kconfig index aa73ef3233b8..8382dc832929 100644 --- a/trunk/drivers/gpio/Kconfig +++ b/trunk/drivers/gpio/Kconfig @@ -409,13 +409,6 @@ config GPIO_TWL4030 Say yes here to access the GPIO signals of various multi-function power management chips from Texas Instruments. -config GPIO_TWL6040 - tristate "TWL6040 GPO" - depends on TWL6040_CORE - help - Say yes here to access the GPO signals of twl6040 - audio chip from Texas Instruments. - config GPIO_WM831X tristate "WM831x GPIOs" depends on MFD_WM831X diff --git a/trunk/drivers/gpio/Makefile b/trunk/drivers/gpio/Makefile index b2c109d1303d..0ffaa8423e87 100644 --- a/trunk/drivers/gpio/Makefile +++ b/trunk/drivers/gpio/Makefile @@ -68,7 +68,6 @@ obj-$(CONFIG_GPIO_TPS6586X) += gpio-tps6586x.o obj-$(CONFIG_GPIO_TPS65910) += gpio-tps65910.o obj-$(CONFIG_GPIO_TPS65912) += gpio-tps65912.o obj-$(CONFIG_GPIO_TWL4030) += gpio-twl4030.o -obj-$(CONFIG_GPIO_TWL6040) += gpio-twl6040.o obj-$(CONFIG_GPIO_UCB1400) += gpio-ucb1400.o obj-$(CONFIG_GPIO_VR41XX) += gpio-vr41xx.o obj-$(CONFIG_GPIO_VT8500) += gpio-vt8500.o diff --git a/trunk/drivers/gpio/gpio-ich.c b/trunk/drivers/gpio/gpio-ich.c index d4d617966696..b7c06517403d 100644 --- a/trunk/drivers/gpio/gpio-ich.c +++ b/trunk/drivers/gpio/gpio-ich.c @@ -49,10 +49,6 @@ static const u8 ichx_regs[3][3] = { {0x0c, 0x38, 0x48}, /* LVL[1-3] offsets */ }; -static const u8 ichx_reglen[3] = { - 0x30, 0x10, 0x10, -}; - #define ICHX_WRITE(val, reg, base_res) outl(val, (reg) + (base_res)->start) #define ICHX_READ(reg, base_res) inl((reg) + (base_res)->start) @@ -79,7 +75,6 @@ static struct { struct resource *pm_base; /* Power Mangagment IO base */ struct ichx_desc *desc; /* Pointer to chipset-specific description */ u32 orig_gpio_ctrl; /* Orig CTRL value, used to restore on exit */ - u8 use_gpio; /* Which GPIO groups are usable */ } ichx_priv; static int modparam_gpiobase = -1; /* dynamic */ @@ -128,16 +123,8 @@ static int ichx_read_bit(int reg, unsigned nr) return data & (1 << bit) ? 1 : 0; } -static int ichx_gpio_check_available(struct gpio_chip *gpio, unsigned nr) -{ - return (ichx_priv.use_gpio & (1 << (nr / 32))) ? 0 : -ENXIO; -} - static int ichx_gpio_direction_input(struct gpio_chip *gpio, unsigned nr) { - if (!ichx_gpio_check_available(gpio, nr)) - return -ENXIO; - /* * Try setting pin as an input and verify it worked since many pins * are output-only. @@ -151,9 +138,6 @@ static int ichx_gpio_direction_input(struct gpio_chip *gpio, unsigned nr) static int ichx_gpio_direction_output(struct gpio_chip *gpio, unsigned nr, int val) { - if (!ichx_gpio_check_available(gpio, nr)) - return -ENXIO; - /* Set GPIO output value. */ ichx_write_bit(GPIO_LVL, nr, val, 0); @@ -169,9 +153,6 @@ static int ichx_gpio_direction_output(struct gpio_chip *gpio, unsigned nr, static int ichx_gpio_get(struct gpio_chip *chip, unsigned nr) { - if (!ichx_gpio_check_available(chip, nr)) - return -ENXIO; - return ichx_read_bit(GPIO_LVL, nr); } @@ -180,9 +161,6 @@ static int ich6_gpio_get(struct gpio_chip *chip, unsigned nr) unsigned long flags; u32 data; - if (!ichx_gpio_check_available(chip, nr)) - return -ENXIO; - /* * GPI 0 - 15 need to be read from the power management registers on * a ICH6/3100 bridge. @@ -313,46 +291,6 @@ static struct ichx_desc intel5_desc = { .ngpio = 76, }; -static int __devinit ichx_gpio_request_regions(struct resource *res_base, - const char *name, u8 use_gpio) -{ - int i; - - if (!res_base || !res_base->start || !res_base->end) - return -ENODEV; - - for (i = 0; i < ARRAY_SIZE(ichx_regs[0]); i++) { - if (!(use_gpio & (1 << i))) - continue; - if (!request_region(res_base->start + ichx_regs[0][i], - ichx_reglen[i], name)) - goto request_err; - } - return 0; - -request_err: - /* Clean up: release already requested regions, if any */ - for (i--; i >= 0; i--) { - if (!(use_gpio & (1 << i))) - continue; - release_region(res_base->start + ichx_regs[0][i], - ichx_reglen[i]); - } - return -EBUSY; -} - -static void ichx_gpio_release_regions(struct resource *res_base, u8 use_gpio) -{ - int i; - - for (i = 0; i < ARRAY_SIZE(ichx_regs[0]); i++) { - if (!(use_gpio & (1 << i))) - continue; - release_region(res_base->start + ichx_regs[0][i], - ichx_reglen[i]); - } -} - static int __devinit ichx_gpio_probe(struct platform_device *pdev) { struct resource *res_base, *res_pm; @@ -391,11 +329,12 @@ static int __devinit ichx_gpio_probe(struct platform_device *pdev) } res_base = platform_get_resource(pdev, IORESOURCE_IO, ICH_RES_GPIO); - ichx_priv.use_gpio = ich_info->use_gpio; - err = ichx_gpio_request_regions(res_base, pdev->name, - ichx_priv.use_gpio); - if (err) - return err; + if (!res_base || !res_base->start || !res_base->end) + return -ENODEV; + + if (!request_region(res_base->start, resource_size(res_base), + pdev->name)) + return -EBUSY; ichx_priv.gpio_base = res_base; @@ -435,7 +374,8 @@ static int __devinit ichx_gpio_probe(struct platform_device *pdev) return 0; add_err: - ichx_gpio_release_regions(ichx_priv.gpio_base, ichx_priv.use_gpio); + release_region(ichx_priv.gpio_base->start, + resource_size(ichx_priv.gpio_base)); if (ichx_priv.pm_base) release_region(ichx_priv.pm_base->start, resource_size(ichx_priv.pm_base)); @@ -453,7 +393,8 @@ static int __devexit ichx_gpio_remove(struct platform_device *pdev) return err; } - ichx_gpio_release_regions(ichx_priv.gpio_base, ichx_priv.use_gpio); + release_region(ichx_priv.gpio_base->start, + resource_size(ichx_priv.gpio_base)); if (ichx_priv.pm_base) release_region(ichx_priv.pm_base->start, resource_size(ichx_priv.pm_base)); diff --git a/trunk/drivers/gpio/gpio-twl6040.c b/trunk/drivers/gpio/gpio-twl6040.c deleted file mode 100644 index dd58e8b25043..000000000000 --- a/trunk/drivers/gpio/gpio-twl6040.c +++ /dev/null @@ -1,137 +0,0 @@ -/* - * Access to GPOs on TWL6040 chip - * - * Copyright (C) 2012 Texas Instruments, Inc. - * - * Authors: - * Sergio Aguirre - * Peter Ujfalusi - * - * 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 -#include -#include -#include -#include -#include -#include - -#include - -static struct gpio_chip twl6040gpo_chip; - -static int twl6040gpo_get(struct gpio_chip *chip, unsigned offset) -{ - struct twl6040 *twl6040 = dev_get_drvdata(chip->dev->parent); - int ret = 0; - - ret = twl6040_reg_read(twl6040, TWL6040_REG_GPOCTL); - if (ret < 0) - return ret; - - return (ret >> offset) & 1; -} - -static int twl6040gpo_direction_out(struct gpio_chip *chip, unsigned offset, - int value) -{ - /* This only drives GPOs, and can't change direction */ - return 0; -} - -static void twl6040gpo_set(struct gpio_chip *chip, unsigned offset, int value) -{ - struct twl6040 *twl6040 = dev_get_drvdata(chip->dev->parent); - int ret; - u8 gpoctl; - - ret = twl6040_reg_read(twl6040, TWL6040_REG_GPOCTL); - if (ret < 0) - return; - - if (value) - gpoctl = ret | (1 << offset); - else - gpoctl = ret & ~(1 << offset); - - twl6040_reg_write(twl6040, TWL6040_REG_GPOCTL, gpoctl); -} - -static struct gpio_chip twl6040gpo_chip = { - .label = "twl6040", - .owner = THIS_MODULE, - .get = twl6040gpo_get, - .direction_output = twl6040gpo_direction_out, - .set = twl6040gpo_set, - .can_sleep = 1, -}; - -/*----------------------------------------------------------------------*/ - -static int __devinit gpo_twl6040_probe(struct platform_device *pdev) -{ - struct twl6040_gpo_data *pdata = pdev->dev.platform_data; - struct device *twl6040_core_dev = pdev->dev.parent; - struct twl6040 *twl6040 = dev_get_drvdata(twl6040_core_dev); - int ret; - - if (pdata) - twl6040gpo_chip.base = pdata->gpio_base; - else - twl6040gpo_chip.base = -1; - - if (twl6040_get_revid(twl6040) < TWL6041_REV_ES2_0) - twl6040gpo_chip.ngpio = 3; /* twl6040 have 3 GPO */ - else - twl6040gpo_chip.ngpio = 1; /* twl6041 have 1 GPO */ - - twl6040gpo_chip.dev = &pdev->dev; -#ifdef CONFIG_OF_GPIO - twl6040gpo_chip.of_node = twl6040_core_dev->of_node; -#endif - - ret = gpiochip_add(&twl6040gpo_chip); - if (ret < 0) { - dev_err(&pdev->dev, "could not register gpiochip, %d\n", ret); - twl6040gpo_chip.ngpio = 0; - } - - return ret; -} - -static int __devexit gpo_twl6040_remove(struct platform_device *pdev) -{ - return gpiochip_remove(&twl6040gpo_chip); -} - -/* Note: this hardware lives inside an I2C-based multi-function device. */ -MODULE_ALIAS("platform:twl6040-gpo"); - -static struct platform_driver gpo_twl6040_driver = { - .driver = { - .name = "twl6040-gpo", - .owner = THIS_MODULE, - }, - .probe = gpo_twl6040_probe, - .remove = gpo_twl6040_remove, -}; - -module_platform_driver(gpo_twl6040_driver); - -MODULE_AUTHOR("Texas Instruments, Inc."); -MODULE_DESCRIPTION("GPO interface for TWL6040"); -MODULE_LICENSE("GPL"); diff --git a/trunk/drivers/i2c/i2c-core.c b/trunk/drivers/i2c/i2c-core.c index 2421d95130d4..2091ae8f539a 100644 --- a/trunk/drivers/i2c/i2c-core.c +++ b/trunk/drivers/i2c/i2c-core.c @@ -982,7 +982,7 @@ int i2c_add_numbered_adapter(struct i2c_adapter *adap) if (adap->nr == -1) /* -1 means dynamically assign bus id */ return i2c_add_adapter(adap); - if (adap->nr & ~MAX_IDR_MASK) + if (adap->nr & ~MAX_ID_MASK) return -EINVAL; retry: diff --git a/trunk/drivers/ide/aec62xx.c b/trunk/drivers/ide/aec62xx.c index 01451940393b..57d00caefc86 100644 --- a/trunk/drivers/ide/aec62xx.c +++ b/trunk/drivers/ide/aec62xx.c @@ -181,7 +181,7 @@ static const struct ide_port_ops atp86x_port_ops = { .cable_detect = atp86x_cable_detect, }; -static const struct ide_port_info aec62xx_chipsets[] __devinitconst = { +static const struct ide_port_info aec62xx_chipsets[] __devinitdata = { { /* 0: AEC6210 */ .name = DRV_NAME, .init_chipset = init_chipset_aec62xx, diff --git a/trunk/drivers/ide/ali14xx.c b/trunk/drivers/ide/ali14xx.c index 8f3570ee64c3..d3be99fb4154 100644 --- a/trunk/drivers/ide/ali14xx.c +++ b/trunk/drivers/ide/ali14xx.c @@ -52,13 +52,13 @@ /* port addresses for auto-detection */ #define ALI_NUM_PORTS 4 -static const int ports[ALI_NUM_PORTS] __initconst = +static const int ports[ALI_NUM_PORTS] __initdata = { 0x074, 0x0f4, 0x034, 0x0e4 }; /* register initialization data */ typedef struct { u8 reg, data; } RegInitializer; -static const RegInitializer initData[] __initconst = { +static const RegInitializer initData[] __initdata = { {0x01, 0x0f}, {0x02, 0x00}, {0x03, 0x00}, {0x04, 0x00}, {0x05, 0x00}, {0x06, 0x00}, {0x07, 0x2b}, {0x0a, 0x0f}, {0x25, 0x00}, {0x26, 0x00}, {0x27, 0x00}, {0x28, 0x00}, diff --git a/trunk/drivers/ide/alim15x3.c b/trunk/drivers/ide/alim15x3.c index 911a27ca356b..2c8016ad0e26 100644 --- a/trunk/drivers/ide/alim15x3.c +++ b/trunk/drivers/ide/alim15x3.c @@ -512,7 +512,7 @@ static const struct ide_dma_ops ali_dma_ops = { .dma_sff_read_status = ide_dma_sff_read_status, }; -static const struct ide_port_info ali15x3_chipset __devinitconst = { +static const struct ide_port_info ali15x3_chipset __devinitdata = { .name = DRV_NAME, .init_chipset = init_chipset_ali15x3, .init_hwif = init_hwif_ali15x3, diff --git a/trunk/drivers/ide/amd74xx.c b/trunk/drivers/ide/amd74xx.c index 56fc99557ba2..3747b2561f09 100644 --- a/trunk/drivers/ide/amd74xx.c +++ b/trunk/drivers/ide/amd74xx.c @@ -223,7 +223,7 @@ static const struct ide_port_ops amd_port_ops = { .udma_mask = udma, \ } -static const struct ide_port_info amd74xx_chipsets[] __devinitconst = { +static const struct ide_port_info amd74xx_chipsets[] __devinitdata = { /* 0: AMD7401 */ DECLARE_AMD_DEV(0x00, ATA_UDMA2), /* 1: AMD7409 */ DECLARE_AMD_DEV(ATA_SWDMA2, ATA_UDMA4), /* 2: AMD7411/7441 */ DECLARE_AMD_DEV(ATA_SWDMA2, ATA_UDMA5), diff --git a/trunk/drivers/ide/atiixp.c b/trunk/drivers/ide/atiixp.c index cb43480b1bd5..15f0ead89f5c 100644 --- a/trunk/drivers/ide/atiixp.c +++ b/trunk/drivers/ide/atiixp.c @@ -139,7 +139,7 @@ static const struct ide_port_ops atiixp_port_ops = { .cable_detect = atiixp_cable_detect, }; -static const struct ide_port_info atiixp_pci_info[] __devinitconst = { +static const struct ide_port_info atiixp_pci_info[] __devinitdata = { { /* 0: IXP200/300/400/700 */ .name = DRV_NAME, .enablebits = {{0x48,0x01,0x00}, {0x48,0x08,0x00}}, diff --git a/trunk/drivers/ide/cmd640.c b/trunk/drivers/ide/cmd640.c index 70f0a2754c13..14717304b388 100644 --- a/trunk/drivers/ide/cmd640.c +++ b/trunk/drivers/ide/cmd640.c @@ -685,7 +685,7 @@ static int pci_conf2(void) return 0; } -static const struct ide_port_info cmd640_port_info __initconst = { +static const struct ide_port_info cmd640_port_info __initdata = { .chipset = ide_cmd640, .host_flags = IDE_HFLAG_SERIALIZE | IDE_HFLAG_NO_DMA | diff --git a/trunk/drivers/ide/cmd64x.c b/trunk/drivers/ide/cmd64x.c index d1fc43802f5d..5f80312e636b 100644 --- a/trunk/drivers/ide/cmd64x.c +++ b/trunk/drivers/ide/cmd64x.c @@ -327,7 +327,7 @@ static const struct ide_dma_ops cmd646_rev1_dma_ops = { .dma_sff_read_status = ide_dma_sff_read_status, }; -static const struct ide_port_info cmd64x_chipsets[] __devinitconst = { +static const struct ide_port_info cmd64x_chipsets[] __devinitdata = { { /* 0: CMD643 */ .name = DRV_NAME, .init_chipset = init_chipset_cmd64x, diff --git a/trunk/drivers/ide/cs5520.c b/trunk/drivers/ide/cs5520.c index 14447621e60b..2c1e5f7cd261 100644 --- a/trunk/drivers/ide/cs5520.c +++ b/trunk/drivers/ide/cs5520.c @@ -94,7 +94,7 @@ static const struct ide_port_ops cs5520_port_ops = { .set_dma_mode = cs5520_set_dma_mode, }; -static const struct ide_port_info cyrix_chipset __devinitconst = { +static const struct ide_port_info cyrix_chipset __devinitdata = { .name = DRV_NAME, .enablebits = { { 0x60, 0x01, 0x01 }, { 0x60, 0x02, 0x02 } }, .port_ops = &cs5520_port_ops, diff --git a/trunk/drivers/ide/cs5530.c b/trunk/drivers/ide/cs5530.c index 49b40ad59d1a..4dc4eb92b076 100644 --- a/trunk/drivers/ide/cs5530.c +++ b/trunk/drivers/ide/cs5530.c @@ -245,7 +245,7 @@ static const struct ide_port_ops cs5530_port_ops = { .udma_filter = cs5530_udma_filter, }; -static const struct ide_port_info cs5530_chipset __devinitconst = { +static const struct ide_port_info cs5530_chipset __devinitdata = { .name = DRV_NAME, .init_chipset = init_chipset_cs5530, .init_hwif = init_hwif_cs5530, diff --git a/trunk/drivers/ide/cs5535.c b/trunk/drivers/ide/cs5535.c index 18d4c852602b..5059fafadf29 100644 --- a/trunk/drivers/ide/cs5535.c +++ b/trunk/drivers/ide/cs5535.c @@ -170,7 +170,7 @@ static const struct ide_port_ops cs5535_port_ops = { .cable_detect = cs5535_cable_detect, }; -static const struct ide_port_info cs5535_chipset __devinitconst = { +static const struct ide_port_info cs5535_chipset __devinitdata = { .name = DRV_NAME, .port_ops = &cs5535_port_ops, .host_flags = IDE_HFLAG_SINGLE | IDE_HFLAG_POST_SET_MODE, diff --git a/trunk/drivers/ide/cy82c693.c b/trunk/drivers/ide/cy82c693.c index 3ffb49dab574..847553fd8b96 100644 --- a/trunk/drivers/ide/cy82c693.c +++ b/trunk/drivers/ide/cy82c693.c @@ -163,7 +163,7 @@ static const struct ide_port_ops cy82c693_port_ops = { .set_dma_mode = cy82c693_set_dma_mode, }; -static const struct ide_port_info cy82c693_chipset __devinitconst = { +static const struct ide_port_info cy82c693_chipset __devinitdata = { .name = DRV_NAME, .init_iops = init_iops_cy82c693, .port_ops = &cy82c693_port_ops, diff --git a/trunk/drivers/ide/dtc2278.c b/trunk/drivers/ide/dtc2278.c index 8722df329cbe..46af4743b3e6 100644 --- a/trunk/drivers/ide/dtc2278.c +++ b/trunk/drivers/ide/dtc2278.c @@ -91,7 +91,7 @@ static const struct ide_port_ops dtc2278_port_ops = { .set_pio_mode = dtc2278_set_pio_mode, }; -static const struct ide_port_info dtc2278_port_info __initconst = { +static const struct ide_port_info dtc2278_port_info __initdata = { .name = DRV_NAME, .chipset = ide_dtc2278, .port_ops = &dtc2278_port_ops, diff --git a/trunk/drivers/ide/hpt366.c b/trunk/drivers/ide/hpt366.c index 4aec3b87ff91..58c51cddc100 100644 --- a/trunk/drivers/ide/hpt366.c +++ b/trunk/drivers/ide/hpt366.c @@ -443,7 +443,7 @@ static struct hpt_timings hpt37x_timings = { } }; -static const struct hpt_info hpt36x __devinitconst = { +static const struct hpt_info hpt36x __devinitdata = { .chip_name = "HPT36x", .chip_type = HPT36x, .udma_mask = HPT366_ALLOW_ATA66_3 ? (HPT366_ALLOW_ATA66_4 ? ATA_UDMA4 : ATA_UDMA3) : ATA_UDMA2, @@ -451,7 +451,7 @@ static const struct hpt_info hpt36x __devinitconst = { .timings = &hpt36x_timings }; -static const struct hpt_info hpt370 __devinitconst = { +static const struct hpt_info hpt370 __devinitdata = { .chip_name = "HPT370", .chip_type = HPT370, .udma_mask = HPT370_ALLOW_ATA100_5 ? ATA_UDMA5 : ATA_UDMA4, @@ -459,7 +459,7 @@ static const struct hpt_info hpt370 __devinitconst = { .timings = &hpt37x_timings }; -static const struct hpt_info hpt370a __devinitconst = { +static const struct hpt_info hpt370a __devinitdata = { .chip_name = "HPT370A", .chip_type = HPT370A, .udma_mask = HPT370_ALLOW_ATA100_5 ? ATA_UDMA5 : ATA_UDMA4, @@ -467,7 +467,7 @@ static const struct hpt_info hpt370a __devinitconst = { .timings = &hpt37x_timings }; -static const struct hpt_info hpt374 __devinitconst = { +static const struct hpt_info hpt374 __devinitdata = { .chip_name = "HPT374", .chip_type = HPT374, .udma_mask = ATA_UDMA5, @@ -475,7 +475,7 @@ static const struct hpt_info hpt374 __devinitconst = { .timings = &hpt37x_timings }; -static const struct hpt_info hpt372 __devinitconst = { +static const struct hpt_info hpt372 __devinitdata = { .chip_name = "HPT372", .chip_type = HPT372, .udma_mask = HPT372_ALLOW_ATA133_6 ? ATA_UDMA6 : ATA_UDMA5, @@ -483,7 +483,7 @@ static const struct hpt_info hpt372 __devinitconst = { .timings = &hpt37x_timings }; -static const struct hpt_info hpt372a __devinitconst = { +static const struct hpt_info hpt372a __devinitdata = { .chip_name = "HPT372A", .chip_type = HPT372A, .udma_mask = HPT372_ALLOW_ATA133_6 ? ATA_UDMA6 : ATA_UDMA5, @@ -491,7 +491,7 @@ static const struct hpt_info hpt372a __devinitconst = { .timings = &hpt37x_timings }; -static const struct hpt_info hpt302 __devinitconst = { +static const struct hpt_info hpt302 __devinitdata = { .chip_name = "HPT302", .chip_type = HPT302, .udma_mask = HPT302_ALLOW_ATA133_6 ? ATA_UDMA6 : ATA_UDMA5, @@ -499,7 +499,7 @@ static const struct hpt_info hpt302 __devinitconst = { .timings = &hpt37x_timings }; -static const struct hpt_info hpt371 __devinitconst = { +static const struct hpt_info hpt371 __devinitdata = { .chip_name = "HPT371", .chip_type = HPT371, .udma_mask = HPT371_ALLOW_ATA133_6 ? ATA_UDMA6 : ATA_UDMA5, @@ -507,7 +507,7 @@ static const struct hpt_info hpt371 __devinitconst = { .timings = &hpt37x_timings }; -static const struct hpt_info hpt372n __devinitconst = { +static const struct hpt_info hpt372n __devinitdata = { .chip_name = "HPT372N", .chip_type = HPT372N, .udma_mask = HPT372_ALLOW_ATA133_6 ? ATA_UDMA6 : ATA_UDMA5, @@ -515,7 +515,7 @@ static const struct hpt_info hpt372n __devinitconst = { .timings = &hpt37x_timings }; -static const struct hpt_info hpt302n __devinitconst = { +static const struct hpt_info hpt302n __devinitdata = { .chip_name = "HPT302N", .chip_type = HPT302N, .udma_mask = HPT302_ALLOW_ATA133_6 ? ATA_UDMA6 : ATA_UDMA5, @@ -523,7 +523,7 @@ static const struct hpt_info hpt302n __devinitconst = { .timings = &hpt37x_timings }; -static const struct hpt_info hpt371n __devinitconst = { +static const struct hpt_info hpt371n __devinitdata = { .chip_name = "HPT371N", .chip_type = HPT371N, .udma_mask = HPT371_ALLOW_ATA133_6 ? ATA_UDMA6 : ATA_UDMA5, @@ -1361,7 +1361,7 @@ static const struct ide_dma_ops hpt36x_dma_ops = { .dma_sff_read_status = ide_dma_sff_read_status, }; -static const struct ide_port_info hpt366_chipsets[] __devinitconst = { +static const struct ide_port_info hpt366_chipsets[] __devinitdata = { { /* 0: HPT36x */ .name = DRV_NAME, .init_chipset = init_chipset_hpt366, diff --git a/trunk/drivers/ide/ht6560b.c b/trunk/drivers/ide/ht6560b.c index 1e0fd3aa962d..986f2513eab4 100644 --- a/trunk/drivers/ide/ht6560b.c +++ b/trunk/drivers/ide/ht6560b.c @@ -341,7 +341,7 @@ static const struct ide_port_ops ht6560b_port_ops = { .set_pio_mode = ht6560b_set_pio_mode, }; -static const struct ide_port_info ht6560b_port_info __initconst = { +static const struct ide_port_info ht6560b_port_info __initdata = { .name = DRV_NAME, .chipset = ide_ht6560b, .tp_ops = &ht6560b_tp_ops, diff --git a/trunk/drivers/ide/icside.c b/trunk/drivers/ide/icside.c index e640d0ac3af6..bcb507b0cfd4 100644 --- a/trunk/drivers/ide/icside.c +++ b/trunk/drivers/ide/icside.c @@ -451,7 +451,7 @@ icside_register_v5(struct icside_state *state, struct expansion_card *ec) return ret; } -static const struct ide_port_info icside_v6_port_info __initconst = { +static const struct ide_port_info icside_v6_port_info __initdata = { .init_dma = icside_dma_off_init, .port_ops = &icside_v6_no_dma_port_ops, .host_flags = IDE_HFLAG_SERIALIZE | IDE_HFLAG_MMIO, diff --git a/trunk/drivers/ide/ide-pci-generic.c b/trunk/drivers/ide/ide-pci-generic.c index dab5b670bfbf..7f56b738d762 100644 --- a/trunk/drivers/ide/ide-pci-generic.c +++ b/trunk/drivers/ide/ide-pci-generic.c @@ -53,7 +53,7 @@ static const struct ide_port_ops netcell_port_ops = { .udma_mask = ATA_UDMA6, \ } -static const struct ide_port_info generic_chipsets[] __devinitconst = { +static const struct ide_port_info generic_chipsets[] __devinitdata = { /* 0: Unknown */ DECLARE_GENERIC_PCI_DEV(0), diff --git a/trunk/drivers/ide/it8172.c b/trunk/drivers/ide/it8172.c index d5dd180c4b85..560e66d07659 100644 --- a/trunk/drivers/ide/it8172.c +++ b/trunk/drivers/ide/it8172.c @@ -115,7 +115,7 @@ static const struct ide_port_ops it8172_port_ops = { .set_dma_mode = it8172_set_dma_mode, }; -static const struct ide_port_info it8172_port_info __devinitconst = { +static const struct ide_port_info it8172_port_info __devinitdata = { .name = DRV_NAME, .port_ops = &it8172_port_ops, .enablebits = { {0x41, 0x80, 0x80}, {0x00, 0x00, 0x00} }, diff --git a/trunk/drivers/ide/it8213.c b/trunk/drivers/ide/it8213.c index 1847aeb5450a..46816ba26416 100644 --- a/trunk/drivers/ide/it8213.c +++ b/trunk/drivers/ide/it8213.c @@ -156,7 +156,7 @@ static const struct ide_port_ops it8213_port_ops = { .cable_detect = it8213_cable_detect, }; -static const struct ide_port_info it8213_chipset __devinitconst = { +static const struct ide_port_info it8213_chipset __devinitdata = { .name = DRV_NAME, .enablebits = { {0x41, 0x80, 0x80} }, .port_ops = &it8213_port_ops, diff --git a/trunk/drivers/ide/it821x.c b/trunk/drivers/ide/it821x.c index c5611dbca342..2e3169f2acda 100644 --- a/trunk/drivers/ide/it821x.c +++ b/trunk/drivers/ide/it821x.c @@ -630,7 +630,7 @@ static const struct ide_port_ops it821x_port_ops = { .cable_detect = it821x_cable_detect, }; -static const struct ide_port_info it821x_chipset __devinitconst = { +static const struct ide_port_info it821x_chipset __devinitdata = { .name = DRV_NAME, .init_chipset = init_chipset_it821x, .init_hwif = init_hwif_it821x, diff --git a/trunk/drivers/ide/jmicron.c b/trunk/drivers/ide/jmicron.c index efddd7d9f92d..74c2c4a6d909 100644 --- a/trunk/drivers/ide/jmicron.c +++ b/trunk/drivers/ide/jmicron.c @@ -102,7 +102,7 @@ static const struct ide_port_ops jmicron_port_ops = { .cable_detect = jmicron_cable_detect, }; -static const struct ide_port_info jmicron_chipset __devinitconst = { +static const struct ide_port_info jmicron_chipset __devinitdata = { .name = DRV_NAME, .enablebits = { { 0x40, 0x01, 0x01 }, { 0x40, 0x10, 0x10 } }, .port_ops = &jmicron_port_ops, diff --git a/trunk/drivers/ide/ns87415.c b/trunk/drivers/ide/ns87415.c index 73f78d872d55..95327a2c2422 100644 --- a/trunk/drivers/ide/ns87415.c +++ b/trunk/drivers/ide/ns87415.c @@ -293,7 +293,7 @@ static const struct ide_dma_ops ns87415_dma_ops = { .dma_sff_read_status = superio_dma_sff_read_status, }; -static const struct ide_port_info ns87415_chipset __devinitconst = { +static const struct ide_port_info ns87415_chipset __devinitdata = { .name = DRV_NAME, .init_hwif = init_hwif_ns87415, .tp_ops = &ns87415_tp_ops, diff --git a/trunk/drivers/ide/opti621.c b/trunk/drivers/ide/opti621.c index 39edc66cb96c..1a53a4c375ed 100644 --- a/trunk/drivers/ide/opti621.c +++ b/trunk/drivers/ide/opti621.c @@ -131,7 +131,7 @@ static const struct ide_port_ops opti621_port_ops = { .set_pio_mode = opti621_set_pio_mode, }; -static const struct ide_port_info opti621_chipset __devinitconst = { +static const struct ide_port_info opti621_chipset __devinitdata = { .name = DRV_NAME, .enablebits = { {0x45, 0x80, 0x00}, {0x40, 0x08, 0x00} }, .port_ops = &opti621_port_ops, diff --git a/trunk/drivers/ide/pdc202xx_new.c b/trunk/drivers/ide/pdc202xx_new.c index 2e5ceb62fb3b..9546fe2a93f7 100644 --- a/trunk/drivers/ide/pdc202xx_new.c +++ b/trunk/drivers/ide/pdc202xx_new.c @@ -465,7 +465,7 @@ static const struct ide_port_ops pdcnew_port_ops = { .udma_mask = udma, \ } -static const struct ide_port_info pdcnew_chipsets[] __devinitconst = { +static const struct ide_port_info pdcnew_chipsets[] __devinitdata = { /* 0: PDC202{68,70} */ DECLARE_PDCNEW_DEV(ATA_UDMA5), /* 1: PDC202{69,71,75,76,77} */ DECLARE_PDCNEW_DEV(ATA_UDMA6), }; diff --git a/trunk/drivers/ide/pdc202xx_old.c b/trunk/drivers/ide/pdc202xx_old.c index 563451096812..3a35ec6193d2 100644 --- a/trunk/drivers/ide/pdc202xx_old.c +++ b/trunk/drivers/ide/pdc202xx_old.c @@ -270,7 +270,7 @@ static const struct ide_dma_ops pdc2026x_dma_ops = { .max_sectors = sectors, \ } -static const struct ide_port_info pdc202xx_chipsets[] __devinitconst = { +static const struct ide_port_info pdc202xx_chipsets[] __devinitdata = { { /* 0: PDC20246 */ .name = DRV_NAME, .init_chipset = init_chipset_pdc202xx, diff --git a/trunk/drivers/ide/piix.c b/trunk/drivers/ide/piix.c index fe0fd60cfc09..1892e81fb00f 100644 --- a/trunk/drivers/ide/piix.c +++ b/trunk/drivers/ide/piix.c @@ -344,7 +344,7 @@ static const struct ide_port_ops ich_port_ops = { .udma_mask = udma, \ } -static const struct ide_port_info piix_pci_info[] __devinitconst = { +static const struct ide_port_info piix_pci_info[] __devinitdata = { /* 0: MPIIX */ { /* * MPIIX actually has only a single IDE channel mapped to diff --git a/trunk/drivers/ide/qd65xx.c b/trunk/drivers/ide/qd65xx.c index a6fb6a894c7b..e03f4f19c1d6 100644 --- a/trunk/drivers/ide/qd65xx.c +++ b/trunk/drivers/ide/qd65xx.c @@ -335,7 +335,7 @@ static const struct ide_port_ops qd6580_port_ops = { .set_pio_mode = qd6580_set_pio_mode, }; -static const struct ide_port_info qd65xx_port_info __initconst = { +static const struct ide_port_info qd65xx_port_info __initdata = { .name = DRV_NAME, .tp_ops = &qd65xx_tp_ops, .chipset = ide_qd65xx, diff --git a/trunk/drivers/ide/rz1000.c b/trunk/drivers/ide/rz1000.c index c04173e9fc38..a6414a884eb1 100644 --- a/trunk/drivers/ide/rz1000.c +++ b/trunk/drivers/ide/rz1000.c @@ -38,7 +38,7 @@ static int __devinit rz1000_disable_readahead(struct pci_dev *dev) } } -static const struct ide_port_info rz1000_chipset __devinitconst = { +static const struct ide_port_info rz1000_chipset __devinitdata = { .name = DRV_NAME, .host_flags = IDE_HFLAG_NO_DMA, }; diff --git a/trunk/drivers/ide/sc1200.c b/trunk/drivers/ide/sc1200.c index d4758ebe77da..356b9b504ffd 100644 --- a/trunk/drivers/ide/sc1200.c +++ b/trunk/drivers/ide/sc1200.c @@ -291,7 +291,7 @@ static const struct ide_dma_ops sc1200_dma_ops = { .dma_sff_read_status = ide_dma_sff_read_status, }; -static const struct ide_port_info sc1200_chipset __devinitconst = { +static const struct ide_port_info sc1200_chipset __devinitdata = { .name = DRV_NAME, .port_ops = &sc1200_port_ops, .dma_ops = &sc1200_dma_ops, diff --git a/trunk/drivers/ide/scc_pata.c b/trunk/drivers/ide/scc_pata.c index 970103810021..b7f5b0c4310c 100644 --- a/trunk/drivers/ide/scc_pata.c +++ b/trunk/drivers/ide/scc_pata.c @@ -811,7 +811,7 @@ static const struct ide_dma_ops scc_dma_ops = { .dma_sff_read_status = scc_dma_sff_read_status, }; -static const struct ide_port_info scc_chipset __devinitconst = { +static const struct ide_port_info scc_chipset __devinitdata = { .name = "sccIDE", .init_iops = init_iops_scc, .init_dma = scc_init_dma, diff --git a/trunk/drivers/ide/serverworks.c b/trunk/drivers/ide/serverworks.c index 24d72ef23df7..35fb8dabb55d 100644 --- a/trunk/drivers/ide/serverworks.c +++ b/trunk/drivers/ide/serverworks.c @@ -337,7 +337,7 @@ static const struct ide_port_ops svwks_port_ops = { .cable_detect = svwks_cable_detect, }; -static const struct ide_port_info serverworks_chipsets[] __devinitconst = { +static const struct ide_port_info serverworks_chipsets[] __devinitdata = { { /* 0: OSB4 */ .name = DRV_NAME, .init_chipset = init_chipset_svwks, diff --git a/trunk/drivers/ide/siimage.c b/trunk/drivers/ide/siimage.c index 46f7e30d3790..ddeda444a27a 100644 --- a/trunk/drivers/ide/siimage.c +++ b/trunk/drivers/ide/siimage.c @@ -719,7 +719,7 @@ static const struct ide_dma_ops sil_dma_ops = { .udma_mask = ATA_UDMA6, \ } -static const struct ide_port_info siimage_chipsets[] __devinitconst = { +static const struct ide_port_info siimage_chipsets[] __devinitdata = { /* 0: SiI680 */ DECLARE_SII_DEV(&sil_pata_port_ops), /* 1: SiI3112 */ DECLARE_SII_DEV(&sil_sata_port_ops) }; diff --git a/trunk/drivers/ide/sis5513.c b/trunk/drivers/ide/sis5513.c index 09e61b4c5e94..4a0022567758 100644 --- a/trunk/drivers/ide/sis5513.c +++ b/trunk/drivers/ide/sis5513.c @@ -563,7 +563,7 @@ static const struct ide_port_ops sis_ata133_port_ops = { .cable_detect = sis_cable_detect, }; -static const struct ide_port_info sis5513_chipset __devinitconst = { +static const struct ide_port_info sis5513_chipset __devinitdata = { .name = DRV_NAME, .init_chipset = init_chipset_sis5513, .enablebits = { {0x4a, 0x02, 0x02}, {0x4a, 0x04, 0x04} }, diff --git a/trunk/drivers/ide/sl82c105.c b/trunk/drivers/ide/sl82c105.c index d051cd224bdb..f21dc2ad7682 100644 --- a/trunk/drivers/ide/sl82c105.c +++ b/trunk/drivers/ide/sl82c105.c @@ -299,7 +299,7 @@ static const struct ide_dma_ops sl82c105_dma_ops = { .dma_sff_read_status = ide_dma_sff_read_status, }; -static const struct ide_port_info sl82c105_chipset __devinitconst = { +static const struct ide_port_info sl82c105_chipset __devinitdata = { .name = DRV_NAME, .init_chipset = init_chipset_sl82c105, .enablebits = {{0x40,0x01,0x01}, {0x40,0x10,0x10}}, diff --git a/trunk/drivers/ide/slc90e66.c b/trunk/drivers/ide/slc90e66.c index 863a5e9283ca..864ffe0e26d9 100644 --- a/trunk/drivers/ide/slc90e66.c +++ b/trunk/drivers/ide/slc90e66.c @@ -132,7 +132,7 @@ static const struct ide_port_ops slc90e66_port_ops = { .cable_detect = slc90e66_cable_detect, }; -static const struct ide_port_info slc90e66_chipset __devinitconst = { +static const struct ide_port_info slc90e66_chipset __devinitdata = { .name = DRV_NAME, .enablebits = { {0x41, 0x80, 0x80}, {0x43, 0x80, 0x80} }, .port_ops = &slc90e66_port_ops, diff --git a/trunk/drivers/ide/tc86c001.c b/trunk/drivers/ide/tc86c001.c index 17946785ebf6..4799d5c384e7 100644 --- a/trunk/drivers/ide/tc86c001.c +++ b/trunk/drivers/ide/tc86c001.c @@ -192,7 +192,7 @@ static const struct ide_dma_ops tc86c001_dma_ops = { .dma_sff_read_status = ide_dma_sff_read_status, }; -static const struct ide_port_info tc86c001_chipset __devinitconst = { +static const struct ide_port_info tc86c001_chipset __devinitdata = { .name = DRV_NAME, .init_hwif = init_hwif_tc86c001, .port_ops = &tc86c001_port_ops, diff --git a/trunk/drivers/ide/triflex.c b/trunk/drivers/ide/triflex.c index 55ce1b80efcb..281c91426345 100644 --- a/trunk/drivers/ide/triflex.c +++ b/trunk/drivers/ide/triflex.c @@ -92,7 +92,7 @@ static const struct ide_port_ops triflex_port_ops = { .set_dma_mode = triflex_set_mode, }; -static const struct ide_port_info triflex_device __devinitconst = { +static const struct ide_port_info triflex_device __devinitdata = { .name = DRV_NAME, .enablebits = {{0x80, 0x01, 0x01}, {0x80, 0x02, 0x02}}, .port_ops = &triflex_port_ops, diff --git a/trunk/drivers/ide/trm290.c b/trunk/drivers/ide/trm290.c index e494a98a43a9..4b42ca091534 100644 --- a/trunk/drivers/ide/trm290.c +++ b/trunk/drivers/ide/trm290.c @@ -324,7 +324,7 @@ static struct ide_dma_ops trm290_dma_ops = { .dma_check = trm290_dma_check, }; -static const struct ide_port_info trm290_chipset __devinitconst = { +static const struct ide_port_info trm290_chipset __devinitdata = { .name = DRV_NAME, .init_hwif = init_hwif_trm290, .tp_ops = &trm290_tp_ops, diff --git a/trunk/drivers/ide/tx4938ide.c b/trunk/drivers/ide/tx4938ide.c index 91d49dd957ef..7002765b593c 100644 --- a/trunk/drivers/ide/tx4938ide.c +++ b/trunk/drivers/ide/tx4938ide.c @@ -117,7 +117,7 @@ static const struct ide_port_ops tx4938ide_port_ops = { .set_pio_mode = tx4938ide_set_pio_mode, }; -static const struct ide_port_info tx4938ide_port_info __initconst = { +static const struct ide_port_info tx4938ide_port_info __initdata = { .port_ops = &tx4938ide_port_ops, #ifdef __BIG_ENDIAN .tp_ops = &tx4938ide_tp_ops, diff --git a/trunk/drivers/ide/tx4939ide.c b/trunk/drivers/ide/tx4939ide.c index c0ab800b7bb3..71c231954972 100644 --- a/trunk/drivers/ide/tx4939ide.c +++ b/trunk/drivers/ide/tx4939ide.c @@ -522,7 +522,7 @@ static const struct ide_dma_ops tx4939ide_dma_ops = { .dma_sff_read_status = tx4939ide_dma_sff_read_status, }; -static const struct ide_port_info tx4939ide_port_info __initconst = { +static const struct ide_port_info tx4939ide_port_info __initdata = { .init_hwif = tx4939ide_init_hwif, .init_dma = tx4939ide_init_dma, .port_ops = &tx4939ide_port_ops, diff --git a/trunk/drivers/ide/umc8672.c b/trunk/drivers/ide/umc8672.c index 3aa0fea0f3d9..5cfb78120669 100644 --- a/trunk/drivers/ide/umc8672.c +++ b/trunk/drivers/ide/umc8672.c @@ -128,7 +128,7 @@ static const struct ide_port_ops umc8672_port_ops = { .set_pio_mode = umc_set_pio_mode, }; -static const struct ide_port_info umc8672_port_info __initconst = { +static const struct ide_port_info umc8672_port_info __initdata = { .name = DRV_NAME, .chipset = ide_umc8672, .port_ops = &umc8672_port_ops, diff --git a/trunk/drivers/ide/via82cxxx.c b/trunk/drivers/ide/via82cxxx.c index eb7767864d10..f46f49cfcc28 100644 --- a/trunk/drivers/ide/via82cxxx.c +++ b/trunk/drivers/ide/via82cxxx.c @@ -403,7 +403,7 @@ static const struct ide_port_ops via_port_ops = { .cable_detect = via82cxxx_cable_detect, }; -static const struct ide_port_info via82cxxx_chipset __devinitconst = { +static const struct ide_port_info via82cxxx_chipset __devinitdata = { .name = DRV_NAME, .init_chipset = init_chipset_via82cxxx, .enablebits = { { 0x40, 0x02, 0x02 }, { 0x40, 0x01, 0x01 } }, diff --git a/trunk/drivers/infiniband/core/cm.c b/trunk/drivers/infiniband/core/cm.c index 394fea2ba1bc..d67999f6e34a 100644 --- a/trunk/drivers/infiniband/core/cm.c +++ b/trunk/drivers/infiniband/core/cm.c @@ -390,7 +390,7 @@ static int cm_alloc_id(struct cm_id_private *cm_id_priv) ret = idr_get_new_above(&cm.local_id_table, cm_id_priv, next_id, &id); if (!ret) - next_id = ((unsigned) id + 1) & MAX_IDR_MASK; + next_id = ((unsigned) id + 1) & MAX_ID_MASK; spin_unlock_irqrestore(&cm.lock, flags); } while( (ret == -EAGAIN) && idr_pre_get(&cm.local_id_table, GFP_KERNEL) ); diff --git a/trunk/drivers/infiniband/hw/ehca/ehca_cq.c b/trunk/drivers/infiniband/hw/ehca/ehca_cq.c index 8f5290147e8a..d9b0ebcb67d7 100644 --- a/trunk/drivers/infiniband/hw/ehca/ehca_cq.c +++ b/trunk/drivers/infiniband/hw/ehca/ehca_cq.c @@ -220,7 +220,7 @@ struct ib_cq *ehca_create_cq(struct ib_device *device, int cqe, int comp_vector, cq = ERR_PTR(-EAGAIN); goto create_cq_exit4; } - rpage = __pa(vpage); + rpage = virt_to_abs(vpage); h_ret = hipz_h_register_rpage_cq(adapter_handle, my_cq->ipz_cq_handle, diff --git a/trunk/drivers/infiniband/hw/ehca/ehca_eq.c b/trunk/drivers/infiniband/hw/ehca/ehca_eq.c index 90da6747d395..818d721fc448 100644 --- a/trunk/drivers/infiniband/hw/ehca/ehca_eq.c +++ b/trunk/drivers/infiniband/hw/ehca/ehca_eq.c @@ -101,7 +101,7 @@ int ehca_create_eq(struct ehca_shca *shca, if (!vpage) goto create_eq_exit2; - rpage = __pa(vpage); + rpage = virt_to_abs(vpage); h_ret = hipz_h_register_rpage_eq(shca->ipz_hca_handle, eq->ipz_eq_handle, &eq->pf, diff --git a/trunk/drivers/infiniband/hw/ehca/ehca_mrmw.c b/trunk/drivers/infiniband/hw/ehca/ehca_mrmw.c index 87844869dcc2..b781b2cb0624 100644 --- a/trunk/drivers/infiniband/hw/ehca/ehca_mrmw.c +++ b/trunk/drivers/infiniband/hw/ehca/ehca_mrmw.c @@ -1136,7 +1136,7 @@ int ehca_reg_mr_rpages(struct ehca_shca *shca, } if (rnum > 1) { - rpage = __pa(kpage); + rpage = virt_to_abs(kpage); if (!rpage) { ehca_err(&shca->ib_device, "kpage=%p i=%x", kpage, i); @@ -1231,7 +1231,7 @@ inline int ehca_rereg_mr_rereg1(struct ehca_shca *shca, pginfo->num_kpages, pginfo->num_hwpages, kpage); goto ehca_rereg_mr_rereg1_exit1; } - rpage = __pa(kpage); + rpage = virt_to_abs(kpage); if (!rpage) { ehca_err(&shca->ib_device, "kpage=%p", kpage); ret = -EFAULT; @@ -1525,7 +1525,7 @@ static inline void *ehca_calc_sectbase(int top, int dir, int idx) unsigned long ret = idx; ret |= dir << EHCA_DIR_INDEX_SHIFT; ret |= top << EHCA_TOP_INDEX_SHIFT; - return __va(ret << SECTION_SIZE_BITS); + return abs_to_virt(ret << SECTION_SIZE_BITS); } #define ehca_bmap_valid(entry) \ @@ -1537,7 +1537,7 @@ static u64 ehca_reg_mr_section(int top, int dir, int idx, u64 *kpage, { u64 h_ret = 0; unsigned long page = 0; - u64 rpage = __pa(kpage); + u64 rpage = virt_to_abs(kpage); int page_count; void *sectbase = ehca_calc_sectbase(top, dir, idx); @@ -1553,7 +1553,7 @@ static u64 ehca_reg_mr_section(int top, int dir, int idx, u64 *kpage, for (rnum = 0; (rnum < MAX_RPAGES) && (page < page_count); rnum++) { void *pg = sectbase + ((page++) * pginfo->hwpage_size); - kpage[rnum] = __pa(pg); + kpage[rnum] = virt_to_abs(pg); } h_ret = hipz_h_register_rpage_mr(shca->ipz_hca_handle, mr, @@ -1870,8 +1870,9 @@ static int ehca_set_pagebuf_user1(struct ehca_mr_pginfo *pginfo, for (i = pginfo->u.usr.next_nmap; i < chunk->nmap; ) { pgaddr = page_to_pfn(sg_page(&chunk->page_list[i])) << PAGE_SHIFT ; - *kpage = pgaddr + (pginfo->next_hwpage * - pginfo->hwpage_size); + *kpage = phys_to_abs(pgaddr + + (pginfo->next_hwpage * + pginfo->hwpage_size)); if ( !(*kpage) ) { ehca_gen_err("pgaddr=%llx " "chunk->page_list[i]=%llx " @@ -1926,7 +1927,7 @@ static int ehca_check_kpages_per_ate(struct scatterlist *page_list, u64 pgaddr = page_to_pfn(sg_page(&page_list[t])) << PAGE_SHIFT; if (ehca_debug_level >= 3) ehca_gen_dbg("chunk_page=%llx value=%016llx", pgaddr, - *(u64 *)__va(pgaddr)); + *(u64 *)abs_to_virt(phys_to_abs(pgaddr))); if (pgaddr - PAGE_SIZE != *prev_pgaddr) { ehca_gen_err("uncontiguous page found pgaddr=%llx " "prev_pgaddr=%llx page_list_i=%x", @@ -1961,7 +1962,7 @@ static int ehca_set_pagebuf_user2(struct ehca_mr_pginfo *pginfo, if (nr_kpages == kpages_per_hwpage) { pgaddr = ( page_to_pfn(sg_page(&chunk->page_list[i])) << PAGE_SHIFT ); - *kpage = pgaddr; + *kpage = phys_to_abs(pgaddr); if ( !(*kpage) ) { ehca_gen_err("pgaddr=%llx i=%x", pgaddr, i); @@ -1989,11 +1990,13 @@ static int ehca_set_pagebuf_user2(struct ehca_mr_pginfo *pginfo, (pginfo->hwpage_size - 1)) >> PAGE_SHIFT; nr_kpages -= pginfo->kpage_cnt; - *kpage = pgaddr & - ~(pginfo->hwpage_size - 1); + *kpage = phys_to_abs( + pgaddr & + ~(pginfo->hwpage_size - 1)); } if (ehca_debug_level >= 3) { - u64 val = *(u64 *)__va(pgaddr); + u64 val = *(u64 *)abs_to_virt( + phys_to_abs(pgaddr)); ehca_gen_dbg("kpage=%llx chunk_page=%llx " "value=%016llx", *kpage, pgaddr, val); @@ -2081,8 +2084,9 @@ static int ehca_set_pagebuf_phys(struct ehca_mr_pginfo *pginfo, pginfo->num_hwpages, i); return -EFAULT; } - *kpage = (pbuf->addr & ~(pginfo->hwpage_size - 1)) + - (pginfo->next_hwpage * pginfo->hwpage_size); + *kpage = phys_to_abs( + (pbuf->addr & ~(pginfo->hwpage_size - 1)) + + (pginfo->next_hwpage * pginfo->hwpage_size)); if ( !(*kpage) && pbuf->addr ) { ehca_gen_err("pbuf->addr=%llx pbuf->size=%llx " "next_hwpage=%llx", pbuf->addr, @@ -2120,8 +2124,8 @@ static int ehca_set_pagebuf_fmr(struct ehca_mr_pginfo *pginfo, /* loop over desired page_list entries */ fmrlist = pginfo->u.fmr.page_list + pginfo->u.fmr.next_listelem; for (i = 0; i < number; i++) { - *kpage = (*fmrlist & ~(pginfo->hwpage_size - 1)) + - pginfo->next_hwpage * pginfo->hwpage_size; + *kpage = phys_to_abs((*fmrlist & ~(pginfo->hwpage_size - 1)) + + pginfo->next_hwpage * pginfo->hwpage_size); if ( !(*kpage) ) { ehca_gen_err("*fmrlist=%llx fmrlist=%p " "next_listelem=%llx next_hwpage=%llx", @@ -2148,7 +2152,8 @@ static int ehca_set_pagebuf_fmr(struct ehca_mr_pginfo *pginfo, u64 prev = *kpage; /* check if adrs are contiguous */ for (j = 1; j < cnt_per_hwpage; j++) { - u64 p = fmrlist[j] & ~(pginfo->hwpage_size - 1); + u64 p = phys_to_abs(fmrlist[j] & + ~(pginfo->hwpage_size - 1)); if (prev + pginfo->u.fmr.fmr_pgsize != p) { ehca_gen_err("uncontiguous fmr pages " "found prev=%llx p=%llx " @@ -2383,8 +2388,8 @@ static int ehca_update_busmap(unsigned long pfn, unsigned long nr_pages) memset(ehca_bmap, 0xFF, EHCA_TOP_MAP_SIZE); } - start_section = (pfn * PAGE_SIZE) / EHCA_SECTSIZE; - end_section = ((pfn + nr_pages) * PAGE_SIZE) / EHCA_SECTSIZE; + start_section = phys_to_abs(pfn * PAGE_SIZE) / EHCA_SECTSIZE; + end_section = phys_to_abs((pfn + nr_pages) * PAGE_SIZE) / EHCA_SECTSIZE; for (i = start_section; i < end_section; i++) { int ret; top = ehca_calc_index(i, EHCA_TOP_INDEX_SHIFT); @@ -2503,7 +2508,7 @@ static u64 ehca_map_vaddr(void *caddr) if (!ehca_bmap) return EHCA_INVAL_ADDR; - abs_addr = __pa(caddr); + abs_addr = virt_to_abs(caddr); top = ehca_calc_index(abs_addr, EHCA_TOP_INDEX_SHIFT + EHCA_SECTSHIFT); if (!ehca_bmap_valid(ehca_bmap->top[top])) return EHCA_INVAL_ADDR; diff --git a/trunk/drivers/infiniband/hw/ehca/ehca_qp.c b/trunk/drivers/infiniband/hw/ehca/ehca_qp.c index 149393915ae5..964f85520798 100644 --- a/trunk/drivers/infiniband/hw/ehca/ehca_qp.c +++ b/trunk/drivers/infiniband/hw/ehca/ehca_qp.c @@ -321,7 +321,7 @@ static inline int init_qp_queue(struct ehca_shca *shca, ret = -EINVAL; goto init_qp_queue1; } - rpage = __pa(vpage); + rpage = virt_to_abs(vpage); h_ret = hipz_h_register_rpage_qp(ipz_hca_handle, my_qp->ipz_qp_handle, @@ -1094,7 +1094,7 @@ static int prepare_sqe_rts(struct ehca_qp *my_qp, struct ehca_shca *shca, ehca_dbg(&shca->ib_device, "qp_num=%x bad_send_wqe_p=%p", qp_num, bad_send_wqe_p); /* convert wqe pointer to vadr */ - bad_send_wqe_v = __va((u64)bad_send_wqe_p); + bad_send_wqe_v = abs_to_virt((u64)bad_send_wqe_p); if (ehca_debug_level >= 2) ehca_dmp(bad_send_wqe_v, 32, "qp_num=%x bad_wqe", qp_num); squeue = &my_qp->ipz_squeue; @@ -1138,7 +1138,7 @@ static int calc_left_cqes(u64 wqe_p, struct ipz_queue *ipz_queue, /* convert real to abs address */ wqe_p = wqe_p & (~(1UL << 63)); - wqe_v = __va(wqe_p); + wqe_v = abs_to_virt(wqe_p); if (ipz_queue_abs_to_offset(ipz_queue, wqe_p, &q_ofs)) { ehca_gen_err("Invalid offset for calculating left cqes " diff --git a/trunk/drivers/infiniband/hw/ehca/ehca_reqs.c b/trunk/drivers/infiniband/hw/ehca/ehca_reqs.c index 47f94984353d..fd05f48f6b0b 100644 --- a/trunk/drivers/infiniband/hw/ehca/ehca_reqs.c +++ b/trunk/drivers/infiniband/hw/ehca/ehca_reqs.c @@ -135,7 +135,7 @@ static void trace_send_wr_ud(const struct ib_send_wr *send_wr) mad_hdr->attr_mod); } for (j = 0; j < send_wr->num_sge; j++) { - u8 *data = __va(sge->addr); + u8 *data = (u8 *)abs_to_virt(sge->addr); ehca_gen_dbg("send_wr#%x sge#%x addr=%p length=%x " "lkey=%x", idx, j, data, sge->length, sge->lkey); diff --git a/trunk/drivers/infiniband/hw/ehca/ehca_tools.h b/trunk/drivers/infiniband/hw/ehca/ehca_tools.h index d280b12aae64..54c0d23bad92 100644 --- a/trunk/drivers/infiniband/hw/ehca/ehca_tools.h +++ b/trunk/drivers/infiniband/hw/ehca/ehca_tools.h @@ -59,6 +59,7 @@ #include #include +#include #include #include #include diff --git a/trunk/drivers/infiniband/hw/ehca/hcp_if.c b/trunk/drivers/infiniband/hw/ehca/hcp_if.c index 2d41d04fd959..e6f9cdd94c7a 100644 --- a/trunk/drivers/infiniband/hw/ehca/hcp_if.c +++ b/trunk/drivers/infiniband/hw/ehca/hcp_if.c @@ -396,7 +396,7 @@ u64 hipz_h_query_port(const struct ipz_adapter_handle adapter_handle, struct hipz_query_port *query_port_response_block) { u64 ret; - u64 r_cb = __pa(query_port_response_block); + u64 r_cb = virt_to_abs(query_port_response_block); if (r_cb & (EHCA_PAGESIZE-1)) { ehca_gen_err("response block not page aligned"); @@ -438,7 +438,7 @@ u64 hipz_h_modify_port(const struct ipz_adapter_handle adapter_handle, u64 hipz_h_query_hca(const struct ipz_adapter_handle adapter_handle, struct hipz_query_hca *query_hca_rblock) { - u64 r_cb = __pa(query_hca_rblock); + u64 r_cb = virt_to_abs(query_hca_rblock); if (r_cb & (EHCA_PAGESIZE-1)) { ehca_gen_err("response_block=%p not page aligned", @@ -577,7 +577,7 @@ u64 hipz_h_modify_qp(const struct ipz_adapter_handle adapter_handle, adapter_handle.handle, /* r4 */ qp_handle.handle, /* r5 */ update_mask, /* r6 */ - __pa(mqpcb), /* r7 */ + virt_to_abs(mqpcb), /* r7 */ 0, 0, 0, 0, 0); if (ret == H_NOT_ENOUGH_RESOURCES) @@ -595,7 +595,7 @@ u64 hipz_h_query_qp(const struct ipz_adapter_handle adapter_handle, return ehca_plpar_hcall_norets(H_QUERY_QP, adapter_handle.handle, /* r4 */ qp_handle.handle, /* r5 */ - __pa(qqpcb), /* r6 */ + virt_to_abs(qqpcb), /* r6 */ 0, 0, 0, 0); } @@ -787,7 +787,7 @@ u64 hipz_h_register_rpage_mr(const struct ipz_adapter_handle adapter_handle, if (count > 1) { u64 *kpage; int i; - kpage = __va(logical_address_of_page); + kpage = (u64 *)abs_to_virt(logical_address_of_page); for (i = 0; i < count; i++) ehca_gen_dbg("kpage[%d]=%p", i, (void *)kpage[i]); @@ -944,7 +944,7 @@ u64 hipz_h_error_data(const struct ipz_adapter_handle adapter_handle, void *rblock, unsigned long *byte_count) { - u64 r_cb = __pa(rblock); + u64 r_cb = virt_to_abs(rblock); if (r_cb & (EHCA_PAGESIZE-1)) { ehca_gen_err("rblock not page aligned."); diff --git a/trunk/drivers/infiniband/hw/ehca/ipz_pt_fn.c b/trunk/drivers/infiniband/hw/ehca/ipz_pt_fn.c index 62c71fadb4d9..1898d6e7cce5 100644 --- a/trunk/drivers/infiniband/hw/ehca/ipz_pt_fn.c +++ b/trunk/drivers/infiniband/hw/ehca/ipz_pt_fn.c @@ -81,7 +81,7 @@ int ipz_queue_abs_to_offset(struct ipz_queue *queue, u64 addr, u64 *q_offset) { int i; for (i = 0; i < queue->queue_length / queue->pagesize; i++) { - u64 page = __pa(queue->queue_pages[i]); + u64 page = (u64)virt_to_abs(queue->queue_pages[i]); if (addr >= page && addr < page + queue->pagesize) { *q_offset = addr - page + i * queue->pagesize; return 0; diff --git a/trunk/drivers/infiniband/hw/mlx4/cm.c b/trunk/drivers/infiniband/hw/mlx4/cm.c index 80079e5a2e30..e25e4dafb8a8 100644 --- a/trunk/drivers/infiniband/hw/mlx4/cm.c +++ b/trunk/drivers/infiniband/hw/mlx4/cm.c @@ -225,7 +225,7 @@ id_map_alloc(struct ib_device *ibdev, int slave_id, u32 sl_cm_id) ret = idr_get_new_above(&sriov->pv_id_table, ent, next_id, &id); if (!ret) { - next_id = ((unsigned) id + 1) & MAX_IDR_MASK; + next_id = ((unsigned) id + 1) & MAX_ID_MASK; ent->pv_cm_id = (u32)id; sl_id_map_add(ibdev, ent); } diff --git a/trunk/drivers/input/misc/twl4030-vibra.c b/trunk/drivers/input/misc/twl4030-vibra.c index 2194a3c7236a..fc0ed9b43424 100644 --- a/trunk/drivers/input/misc/twl4030-vibra.c +++ b/trunk/drivers/input/misc/twl4030-vibra.c @@ -26,7 +26,6 @@ #include #include #include -#include #include #include #include @@ -195,26 +194,13 @@ static int twl4030_vibra_resume(struct device *dev) static SIMPLE_DEV_PM_OPS(twl4030_vibra_pm_ops, twl4030_vibra_suspend, twl4030_vibra_resume); -static bool twl4030_vibra_check_coexist(struct twl4030_vibra_data *pdata, - struct device_node *node) -{ - if (pdata && pdata->coexist) - return true; - - if (of_find_node_by_name(node, "codec")) - return true; - - return false; -} - static int __devinit twl4030_vibra_probe(struct platform_device *pdev) { struct twl4030_vibra_data *pdata = pdev->dev.platform_data; - struct device_node *twl4030_core_node = pdev->dev.parent->of_node; struct vibra_info *info; int ret; - if (!pdata && !twl4030_core_node) { + if (!pdata) { dev_dbg(&pdev->dev, "platform_data not available\n"); return -EINVAL; } @@ -224,7 +210,7 @@ static int __devinit twl4030_vibra_probe(struct platform_device *pdev) return -ENOMEM; info->dev = &pdev->dev; - info->coexist = twl4030_vibra_check_coexist(pdata, twl4030_core_node); + info->coexist = pdata->coexist; INIT_WORK(&info->play_work, vibra_play_work); info->input_dev = input_allocate_device(); diff --git a/trunk/drivers/input/touchscreen/88pm860x-ts.c b/trunk/drivers/input/touchscreen/88pm860x-ts.c index 326218dbd6e6..05f30b73c3c3 100644 --- a/trunk/drivers/input/touchscreen/88pm860x-ts.c +++ b/trunk/drivers/input/touchscreen/88pm860x-ts.c @@ -10,7 +10,6 @@ */ #include #include -#include #include #include #include @@ -114,69 +113,14 @@ static void pm860x_touch_close(struct input_dev *dev) pm860x_set_bits(touch->i2c, MEAS_EN3, data, 0); } -#ifdef CONFIG_OF -static int __devinit pm860x_touch_dt_init(struct platform_device *pdev, - struct pm860x_chip *chip, - int *res_x) -{ - struct device_node *np = pdev->dev.parent->of_node; - struct i2c_client *i2c = (chip->id == CHIP_PM8607) ? chip->client \ - : chip->companion; - int data, n, ret; - if (!np) - return -ENODEV; - np = of_find_node_by_name(np, "touch"); - if (!np) { - dev_err(&pdev->dev, "Can't find touch node\n"); - return -EINVAL; - } - /* set GPADC MISC1 register */ - data = 0; - if (!of_property_read_u32(np, "marvell,88pm860x-gpadc-prebias", &n)) - data |= (n << 1) & PM8607_GPADC_PREBIAS_MASK; - if (!of_property_read_u32(np, "marvell,88pm860x-gpadc-slot-cycle", &n)) - data |= (n << 3) & PM8607_GPADC_SLOT_CYCLE_MASK; - if (!of_property_read_u32(np, "marvell,88pm860x-gpadc-off-scale", &n)) - data |= (n << 5) & PM8607_GPADC_OFF_SCALE_MASK; - if (!of_property_read_u32(np, "marvell,88pm860x-gpadc-sw-cal", &n)) - data |= (n << 7) & PM8607_GPADC_SW_CAL_MASK; - if (data) { - ret = pm860x_reg_write(i2c, PM8607_GPADC_MISC1, data); - if (ret < 0) - return -EINVAL; - } - /* set tsi prebias time */ - if (!of_property_read_u32(np, "marvell,88pm860x-tsi-prebias", &data)) { - ret = pm860x_reg_write(i2c, PM8607_TSI_PREBIAS, data); - if (ret < 0) - return -EINVAL; - } - /* set prebias & prechg time of pen detect */ - data = 0; - if (!of_property_read_u32(np, "marvell,88pm860x-pen-prebias", &n)) - data |= n & PM8607_PD_PREBIAS_MASK; - if (!of_property_read_u32(np, "marvell,88pm860x-pen-prechg", &n)) - data |= n & PM8607_PD_PRECHG_MASK; - if (data) { - ret = pm860x_reg_write(i2c, PM8607_PD_PREBIAS, data); - if (ret < 0) - return -EINVAL; - } - of_property_read_u32(np, "marvell,88pm860x-resistor-X", res_x); - return 0; -} -#else -#define pm860x_touch_dt_init(x, y, z) (-1) -#endif - static int __devinit pm860x_touch_probe(struct platform_device *pdev) { struct pm860x_chip *chip = dev_get_drvdata(pdev->dev.parent); - struct pm860x_touch_pdata *pdata = pdev->dev.platform_data; + struct pm860x_platform_data *pm860x_pdata = \ + pdev->dev.parent->platform_data; + struct pm860x_touch_pdata *pdata = NULL; struct pm860x_touch *touch; - struct i2c_client *i2c = (chip->id == CHIP_PM8607) ? chip->client \ - : chip->companion; - int irq, ret, res_x = 0, data = 0; + int irq, ret; irq = platform_get_irq(pdev, 0); if (irq < 0) { @@ -184,55 +128,16 @@ static int __devinit pm860x_touch_probe(struct platform_device *pdev) return -EINVAL; } - if (pm860x_touch_dt_init(pdev, chip, &res_x)) { - if (pdata) { - /* set GPADC MISC1 register */ - data = 0; - data |= (pdata->gpadc_prebias << 1) - & PM8607_GPADC_PREBIAS_MASK; - data |= (pdata->slot_cycle << 3) - & PM8607_GPADC_SLOT_CYCLE_MASK; - data |= (pdata->off_scale << 5) - & PM8607_GPADC_OFF_SCALE_MASK; - data |= (pdata->sw_cal << 7) - & PM8607_GPADC_SW_CAL_MASK; - if (data) { - ret = pm860x_reg_write(i2c, - PM8607_GPADC_MISC1, data); - if (ret < 0) - return -EINVAL; - } - /* set tsi prebias time */ - if (pdata->tsi_prebias) { - data = pdata->tsi_prebias; - ret = pm860x_reg_write(i2c, - PM8607_TSI_PREBIAS, data); - if (ret < 0) - return -EINVAL; - } - /* set prebias & prechg time of pen detect */ - data = 0; - data |= pdata->pen_prebias - & PM8607_PD_PREBIAS_MASK; - data |= (pdata->pen_prechg << 5) - & PM8607_PD_PRECHG_MASK; - if (data) { - ret = pm860x_reg_write(i2c, - PM8607_PD_PREBIAS, data); - if (ret < 0) - return -EINVAL; - } - res_x = pdata->res_x; - } else { - dev_err(&pdev->dev, "failed to get platform data\n"); - return -EINVAL; - } + if (!pm860x_pdata) { + dev_err(&pdev->dev, "platform data is missing\n"); + return -EINVAL; + } + + pdata = pm860x_pdata->touch; + if (!pdata) { + dev_err(&pdev->dev, "touchscreen data is missing\n"); + return -EINVAL; } - /* enable GPADC */ - ret = pm860x_set_bits(i2c, PM8607_GPADC_MISC1, PM8607_GPADC_EN, - PM8607_GPADC_EN); - if (ret) - return ret; touch = kzalloc(sizeof(struct pm860x_touch), GFP_KERNEL); if (touch == NULL) @@ -253,9 +158,9 @@ static int __devinit pm860x_touch_probe(struct platform_device *pdev) touch->idev->open = pm860x_touch_open; touch->idev->close = pm860x_touch_close; touch->chip = chip; - touch->i2c = i2c; - touch->irq = irq; - touch->res_x = res_x; + touch->i2c = (chip->id == CHIP_PM8607) ? chip->client : chip->companion; + touch->irq = irq + chip->irq_base; + touch->res_x = pdata->res_x; input_set_drvdata(touch->idev, touch); ret = request_threaded_irq(touch->irq, NULL, pm860x_touch_handler, diff --git a/trunk/drivers/leds/leds-88pm860x.c b/trunk/drivers/leds/leds-88pm860x.c index b7e8cc0957fc..61897cfeeda6 100644 --- a/trunk/drivers/leds/leds-88pm860x.c +++ b/trunk/drivers/leds/leds-88pm860x.c @@ -12,7 +12,6 @@ #include #include -#include #include #include #include @@ -21,12 +20,18 @@ #include #include +#define LED_PWM_SHIFT (3) #define LED_PWM_MASK (0x1F) #define LED_CURRENT_MASK (0x07 << 5) +#define LED_BLINK_ON_MASK (0x07) #define LED_BLINK_MASK (0x7F) +#define LED_BLINK_ON(x) ((x & 0x7) * 66 + 66) +#define LED_BLINK_ON_MIN LED_BLINK_ON(0) +#define LED_BLINK_ON_MAX LED_BLINK_ON(0x7) #define LED_ON_CONTINUOUS (0x0F << 3) +#define LED_TO_ON(x) ((x - 66) / 66) #define LED1_BLINK_EN (1 << 1) #define LED2_BLINK_EN (1 << 2) @@ -44,25 +49,85 @@ struct pm860x_led { unsigned char brightness; unsigned char current_brightness; - int reg_control; - int reg_blink; - int blink_mask; + int blink_data; + int blink_time; + int blink_on; + int blink_off; }; +/* return offset of color register */ +static inline int __led_off(int port) +{ + int ret = -EINVAL; + + switch (port) { + case PM8606_LED1_RED: + case PM8606_LED1_GREEN: + case PM8606_LED1_BLUE: + ret = port - PM8606_LED1_RED + PM8606_RGB1B; + break; + case PM8606_LED2_RED: + case PM8606_LED2_GREEN: + case PM8606_LED2_BLUE: + ret = port - PM8606_LED2_RED + PM8606_RGB2B; + break; + } + return ret; +} + +/* return offset of blink register */ +static inline int __blink_off(int port) +{ + int ret = -EINVAL; + + switch (port) { + case PM8606_LED1_RED: + case PM8606_LED1_GREEN: + case PM8606_LED1_BLUE: + ret = PM8606_RGB1A; + break; + case PM8606_LED2_RED: + case PM8606_LED2_GREEN: + case PM8606_LED2_BLUE: + ret = PM8606_RGB2A; + break; + } + return ret; +} + +static inline int __blink_ctl_mask(int port) +{ + int ret = -EINVAL; + + switch (port) { + case PM8606_LED1_RED: + case PM8606_LED1_GREEN: + case PM8606_LED1_BLUE: + ret = LED1_BLINK_EN; + break; + case PM8606_LED2_RED: + case PM8606_LED2_GREEN: + case PM8606_LED2_BLUE: + ret = LED2_BLINK_EN; + break; + } + return ret; +} + static int led_power_set(struct pm860x_chip *chip, int port, int on) { int ret = -EINVAL; switch (port) { - case 0: - case 1: - case 2: + case PM8606_LED1_RED: + case PM8606_LED1_GREEN: + case PM8606_LED1_BLUE: ret = on ? pm8606_osc_enable(chip, RGB1_ENABLE) : pm8606_osc_disable(chip, RGB1_ENABLE); break; - case 3: - case 4: - case 5: + case PM8606_LED2_RED: + case PM8606_LED2_GREEN: + case PM8606_LED2_BLUE: ret = on ? pm8606_osc_enable(chip, RGB2_ENABLE) : pm8606_osc_disable(chip, RGB2_ENABLE); break; @@ -76,7 +141,7 @@ static void pm860x_led_work(struct work_struct *work) struct pm860x_led *led; struct pm860x_chip *chip; unsigned char buf[3]; - int ret; + int mask, ret; led = container_of(work, struct pm860x_led, work); chip = led->chip; @@ -84,34 +149,34 @@ static void pm860x_led_work(struct work_struct *work) if ((led->current_brightness == 0) && led->brightness) { led_power_set(chip, led->port, 1); if (led->iset) { - pm860x_set_bits(led->i2c, led->reg_control, + pm860x_set_bits(led->i2c, __led_off(led->port), LED_CURRENT_MASK, led->iset); } - pm860x_set_bits(led->i2c, led->reg_blink, + pm860x_set_bits(led->i2c, __blink_off(led->port), LED_BLINK_MASK, LED_ON_CONTINUOUS); - pm860x_set_bits(led->i2c, PM8606_WLED3B, led->blink_mask, - led->blink_mask); + mask = __blink_ctl_mask(led->port); + pm860x_set_bits(led->i2c, PM8606_WLED3B, mask, mask); } - pm860x_set_bits(led->i2c, led->reg_control, LED_PWM_MASK, + pm860x_set_bits(led->i2c, __led_off(led->port), LED_PWM_MASK, led->brightness); if (led->brightness == 0) { - pm860x_bulk_read(led->i2c, led->reg_control, 3, buf); + pm860x_bulk_read(led->i2c, __led_off(led->port), 3, buf); ret = buf[0] & LED_PWM_MASK; ret |= buf[1] & LED_PWM_MASK; ret |= buf[2] & LED_PWM_MASK; if (ret == 0) { /* unset current since no led is lighting */ - pm860x_set_bits(led->i2c, led->reg_control, + pm860x_set_bits(led->i2c, __led_off(led->port), LED_CURRENT_MASK, 0); - pm860x_set_bits(led->i2c, PM8606_WLED3B, - led->blink_mask, 0); + mask = __blink_ctl_mask(led->port); + pm860x_set_bits(led->i2c, PM8606_WLED3B, mask, 0); led_power_set(chip, led->port, 0); } } led->current_brightness = led->brightness; dev_dbg(chip->dev, "Update LED. (reg:%d, brightness:%d)\n", - led->reg_control, led->brightness); + __led_off(led->port), led->brightness); mutex_unlock(&led->lock); } @@ -124,92 +189,39 @@ static void pm860x_led_set(struct led_classdev *cdev, schedule_work(&data->work); } -#ifdef CONFIG_OF -static int pm860x_led_dt_init(struct platform_device *pdev, - struct pm860x_led *data) -{ - struct device_node *nproot = pdev->dev.parent->of_node, *np; - int iset = 0; - if (!nproot) - return -ENODEV; - nproot = of_find_node_by_name(nproot, "leds"); - if (!nproot) { - dev_err(&pdev->dev, "failed to find leds node\n"); - return -ENODEV; - } - for_each_child_of_node(nproot, np) { - if (!of_node_cmp(np->name, data->name)) { - of_property_read_u32(np, "marvell,88pm860x-iset", - &iset); - data->iset = PM8606_LED_CURRENT(iset); - break; - } - } - return 0; -} -#else -#define pm860x_led_dt_init(x, y) (-1) -#endif - static int pm860x_led_probe(struct platform_device *pdev) { struct pm860x_chip *chip = dev_get_drvdata(pdev->dev.parent); - struct pm860x_led_pdata *pdata = pdev->dev.platform_data; + struct pm860x_led_pdata *pdata; struct pm860x_led *data; struct resource *res; - int ret = 0; + int ret; + + res = platform_get_resource(pdev, IORESOURCE_IO, 0); + if (res == NULL) { + dev_err(&pdev->dev, "No I/O resource!\n"); + return -EINVAL; + } + + pdata = pdev->dev.platform_data; + if (pdata == NULL) { + dev_err(&pdev->dev, "No platform data!\n"); + return -EINVAL; + } data = devm_kzalloc(&pdev->dev, sizeof(struct pm860x_led), GFP_KERNEL); if (data == NULL) return -ENOMEM; - res = platform_get_resource_byname(pdev, IORESOURCE_REG, "control"); - if (!res) { - dev_err(&pdev->dev, "No REG resource for control\n"); - ret = -ENXIO; - goto out; - } - data->reg_control = res->start; - res = platform_get_resource_byname(pdev, IORESOURCE_REG, "blink"); - if (!res) { - dev_err(&pdev->dev, "No REG resource for blink\n"); - ret = -ENXIO; - goto out; - } - data->reg_blink = res->start; - memset(data->name, 0, MFD_NAME_SIZE); - switch (pdev->id) { - case 0: - data->blink_mask = LED1_BLINK_EN; - sprintf(data->name, "led0-red"); - break; - case 1: - data->blink_mask = LED1_BLINK_EN; - sprintf(data->name, "led0-green"); - break; - case 2: - data->blink_mask = LED1_BLINK_EN; - sprintf(data->name, "led0-blue"); - break; - case 3: - data->blink_mask = LED2_BLINK_EN; - sprintf(data->name, "led1-red"); - break; - case 4: - data->blink_mask = LED2_BLINK_EN; - sprintf(data->name, "led1-green"); - break; - case 5: - data->blink_mask = LED2_BLINK_EN; - sprintf(data->name, "led1-blue"); - break; - } + strncpy(data->name, res->name, MFD_NAME_SIZE - 1); dev_set_drvdata(&pdev->dev, data); data->chip = chip; data->i2c = (chip->id == CHIP_PM8606) ? chip->client : chip->companion; - data->port = pdev->id; - if (pm860x_led_dt_init(pdev, data)) - if (pdata) - data->iset = pdata->iset; + data->iset = pdata->iset; + data->port = pdata->flags; + if (data->port < 0) { + dev_err(&pdev->dev, "check device failed\n"); + return -EINVAL; + } data->current_brightness = 0; data->cdev.name = data->name; @@ -224,9 +236,6 @@ static int pm860x_led_probe(struct platform_device *pdev) } pm860x_led_set(&data->cdev, 0); return 0; -out: - devm_kfree(&pdev->dev, data); - return ret; } static int pm860x_led_remove(struct platform_device *pdev) diff --git a/trunk/drivers/macintosh/macio_asic.c b/trunk/drivers/macintosh/macio_asic.c index ef87310b7662..20e5c2cda430 100644 --- a/trunk/drivers/macintosh/macio_asic.c +++ b/trunk/drivers/macintosh/macio_asic.c @@ -748,7 +748,7 @@ static void __devexit macio_pci_remove(struct pci_dev* pdev) * MacIO is matched against any Apple ID, it's probe() function * will then decide wether it applies or not */ -static const struct pci_device_id __devinitconst pci_ids[] = { { +static const struct pci_device_id __devinitdata pci_ids [] = { { .vendor = PCI_VENDOR_ID_APPLE, .device = PCI_ANY_ID, .subvendor = PCI_ANY_ID, diff --git a/trunk/drivers/macintosh/smu.c b/trunk/drivers/macintosh/smu.c index 7d5a6b40b31c..54ac7ffacb40 100644 --- a/trunk/drivers/macintosh/smu.c +++ b/trunk/drivers/macintosh/smu.c @@ -45,6 +45,7 @@ #include #include #include +#include #include #define VERSION "0.7" @@ -501,7 +502,7 @@ int __init smu_init (void) * 32 bits value safely */ smu->cmd_buf_abs = (u32)smu_cmdbuf_abs; - smu->cmd_buf = __va(smu_cmdbuf_abs); + smu->cmd_buf = (struct smu_cmd_buf *)abs_to_virt(smu_cmdbuf_abs); smu->db_node = of_find_node_by_name(NULL, "smu-doorbell"); if (smu->db_node == NULL) { diff --git a/trunk/drivers/mfd/88pm860x-core.c b/trunk/drivers/mfd/88pm860x-core.c index 59d117e9fa31..b73f033b2c60 100644 --- a/trunk/drivers/mfd/88pm860x-core.c +++ b/trunk/drivers/mfd/88pm860x-core.c @@ -11,116 +11,50 @@ #include #include -#include #include #include #include -#include -#include -#include #include -#include -#include #include #include #include #define INT_STATUS_NUM 3 -static struct resource bk0_resources[] __devinitdata = { - {2, 2, "duty cycle", IORESOURCE_REG, }, - {3, 3, "always on", IORESOURCE_REG, }, - {3, 3, "current", IORESOURCE_REG, }, -}; -static struct resource bk1_resources[] __devinitdata = { - {4, 4, "duty cycle", IORESOURCE_REG, }, - {5, 5, "always on", IORESOURCE_REG, }, - {5, 5, "current", IORESOURCE_REG, }, -}; -static struct resource bk2_resources[] __devinitdata = { - {6, 6, "duty cycle", IORESOURCE_REG, }, - {7, 7, "always on", IORESOURCE_REG, }, - {5, 5, "current", IORESOURCE_REG, }, -}; - -static struct resource led0_resources[] __devinitdata = { - /* RGB1 Red LED */ - {0xd, 0xd, "control", IORESOURCE_REG, }, - {0xc, 0xc, "blink", IORESOURCE_REG, }, -}; -static struct resource led1_resources[] __devinitdata = { - /* RGB1 Green LED */ - {0xe, 0xe, "control", IORESOURCE_REG, }, - {0xc, 0xc, "blink", IORESOURCE_REG, }, -}; -static struct resource led2_resources[] __devinitdata = { - /* RGB1 Blue LED */ - {0xf, 0xf, "control", IORESOURCE_REG, }, - {0xc, 0xc, "blink", IORESOURCE_REG, }, -}; -static struct resource led3_resources[] __devinitdata = { - /* RGB2 Red LED */ - {0x9, 0x9, "control", IORESOURCE_REG, }, - {0x8, 0x8, "blink", IORESOURCE_REG, }, -}; -static struct resource led4_resources[] __devinitdata = { - /* RGB2 Green LED */ - {0xa, 0xa, "control", IORESOURCE_REG, }, - {0x8, 0x8, "blink", IORESOURCE_REG, }, -}; -static struct resource led5_resources[] __devinitdata = { - /* RGB2 Blue LED */ - {0xb, 0xb, "control", IORESOURCE_REG, }, - {0x8, 0x8, "blink", IORESOURCE_REG, }, -}; - -static struct resource buck1_resources[] __devinitdata = { - {0x24, 0x24, "buck set", IORESOURCE_REG, }, -}; -static struct resource buck2_resources[] __devinitdata = { - {0x25, 0x25, "buck set", IORESOURCE_REG, }, -}; -static struct resource buck3_resources[] __devinitdata = { - {0x26, 0x26, "buck set", IORESOURCE_REG, }, -}; -static struct resource ldo1_resources[] __devinitdata = { - {0x10, 0x10, "ldo set", IORESOURCE_REG, }, -}; -static struct resource ldo2_resources[] __devinitdata = { - {0x11, 0x11, "ldo set", IORESOURCE_REG, }, -}; -static struct resource ldo3_resources[] __devinitdata = { - {0x12, 0x12, "ldo set", IORESOURCE_REG, }, -}; -static struct resource ldo4_resources[] __devinitdata = { - {0x13, 0x13, "ldo set", IORESOURCE_REG, }, -}; -static struct resource ldo5_resources[] __devinitdata = { - {0x14, 0x14, "ldo set", IORESOURCE_REG, }, -}; -static struct resource ldo6_resources[] __devinitdata = { - {0x15, 0x15, "ldo set", IORESOURCE_REG, }, -}; -static struct resource ldo7_resources[] __devinitdata = { - {0x16, 0x16, "ldo set", IORESOURCE_REG, }, -}; -static struct resource ldo8_resources[] __devinitdata = { - {0x17, 0x17, "ldo set", IORESOURCE_REG, }, -}; -static struct resource ldo9_resources[] __devinitdata = { - {0x18, 0x18, "ldo set", IORESOURCE_REG, }, -}; -static struct resource ldo10_resources[] __devinitdata = { - {0x19, 0x19, "ldo set", IORESOURCE_REG, }, -}; -static struct resource ldo12_resources[] __devinitdata = { - {0x1a, 0x1a, "ldo set", IORESOURCE_REG, }, -}; -static struct resource ldo_vibrator_resources[] __devinitdata = { - {0x28, 0x28, "ldo set", IORESOURCE_REG, }, -}; -static struct resource ldo14_resources[] __devinitdata = { - {0x1b, 0x1b, "ldo set", IORESOURCE_REG, }, +static struct resource bk_resources[] __devinitdata = { + {PM8606_BACKLIGHT1, PM8606_BACKLIGHT1, "backlight-0", IORESOURCE_IO,}, + {PM8606_BACKLIGHT2, PM8606_BACKLIGHT2, "backlight-1", IORESOURCE_IO,}, + {PM8606_BACKLIGHT3, PM8606_BACKLIGHT3, "backlight-2", IORESOURCE_IO,}, +}; + +static struct resource led_resources[] __devinitdata = { + {PM8606_LED1_RED, PM8606_LED1_RED, "led0-red", IORESOURCE_IO,}, + {PM8606_LED1_GREEN, PM8606_LED1_GREEN, "led0-green", IORESOURCE_IO,}, + {PM8606_LED1_BLUE, PM8606_LED1_BLUE, "led0-blue", IORESOURCE_IO,}, + {PM8606_LED2_RED, PM8606_LED2_RED, "led1-red", IORESOURCE_IO,}, + {PM8606_LED2_GREEN, PM8606_LED2_GREEN, "led1-green", IORESOURCE_IO,}, + {PM8606_LED2_BLUE, PM8606_LED2_BLUE, "led1-blue", IORESOURCE_IO,}, +}; + +static struct resource regulator_resources[] __devinitdata = { + {PM8607_ID_BUCK1, PM8607_ID_BUCK1, "buck-1", IORESOURCE_IO,}, + {PM8607_ID_BUCK2, PM8607_ID_BUCK2, "buck-2", IORESOURCE_IO,}, + {PM8607_ID_BUCK3, PM8607_ID_BUCK3, "buck-3", IORESOURCE_IO,}, + {PM8607_ID_LDO1, PM8607_ID_LDO1, "ldo-01", IORESOURCE_IO,}, + {PM8607_ID_LDO2, PM8607_ID_LDO2, "ldo-02", IORESOURCE_IO,}, + {PM8607_ID_LDO3, PM8607_ID_LDO3, "ldo-03", IORESOURCE_IO,}, + {PM8607_ID_LDO4, PM8607_ID_LDO4, "ldo-04", IORESOURCE_IO,}, + {PM8607_ID_LDO5, PM8607_ID_LDO5, "ldo-05", IORESOURCE_IO,}, + {PM8607_ID_LDO6, PM8607_ID_LDO6, "ldo-06", IORESOURCE_IO,}, + {PM8607_ID_LDO7, PM8607_ID_LDO7, "ldo-07", IORESOURCE_IO,}, + {PM8607_ID_LDO8, PM8607_ID_LDO8, "ldo-08", IORESOURCE_IO,}, + {PM8607_ID_LDO9, PM8607_ID_LDO9, "ldo-09", IORESOURCE_IO,}, + {PM8607_ID_LDO10, PM8607_ID_LDO10, "ldo-10", IORESOURCE_IO,}, + {PM8607_ID_LDO11, PM8607_ID_LDO11, "ldo-11", IORESOURCE_IO,}, + {PM8607_ID_LDO12, PM8607_ID_LDO12, "ldo-12", IORESOURCE_IO,}, + {PM8607_ID_LDO13, PM8607_ID_LDO13, "ldo-13", IORESOURCE_IO,}, + {PM8607_ID_LDO14, PM8607_ID_LDO14, "ldo-14", IORESOURCE_IO,}, + {PM8607_ID_LDO15, PM8607_ID_LDO15, "ldo-15", IORESOURCE_IO,}, }; static struct resource touch_resources[] __devinitdata = { @@ -156,145 +90,48 @@ static struct resource charger_resources[] __devinitdata = { {PM8607_IRQ_VCHG, PM8607_IRQ_VCHG, "vchg voltage", IORESOURCE_IRQ,}, }; -static struct resource rtc_resources[] __devinitdata = { - {PM8607_IRQ_RTC, PM8607_IRQ_RTC, "rtc", IORESOURCE_IRQ,}, -}; - -static struct mfd_cell bk_devs[] __devinitdata = { - { - .name = "88pm860x-backlight", - .id = 0, - .num_resources = ARRAY_SIZE(bk0_resources), - .resources = bk0_resources, - }, { - .name = "88pm860x-backlight", - .id = 1, - .num_resources = ARRAY_SIZE(bk1_resources), - .resources = bk1_resources, - }, { - .name = "88pm860x-backlight", - .id = 2, - .num_resources = ARRAY_SIZE(bk2_resources), - .resources = bk2_resources, - }, +static struct resource preg_resources[] __devinitdata = { + {PM8606_ID_PREG, PM8606_ID_PREG, "preg", IORESOURCE_IO,}, }; -static struct mfd_cell led_devs[] __devinitdata = { - { - .name = "88pm860x-led", - .id = 0, - .num_resources = ARRAY_SIZE(led0_resources), - .resources = led0_resources, - }, { - .name = "88pm860x-led", - .id = 1, - .num_resources = ARRAY_SIZE(led1_resources), - .resources = led1_resources, - }, { - .name = "88pm860x-led", - .id = 2, - .num_resources = ARRAY_SIZE(led2_resources), - .resources = led2_resources, - }, { - .name = "88pm860x-led", - .id = 3, - .num_resources = ARRAY_SIZE(led3_resources), - .resources = led3_resources, - }, { - .name = "88pm860x-led", - .id = 4, - .num_resources = ARRAY_SIZE(led4_resources), - .resources = led4_resources, - }, { - .name = "88pm860x-led", - .id = 5, - .num_resources = ARRAY_SIZE(led5_resources), - .resources = led5_resources, - }, +static struct resource rtc_resources[] __devinitdata = { + {PM8607_IRQ_RTC, PM8607_IRQ_RTC, "rtc", IORESOURCE_IRQ,}, }; -static struct mfd_cell reg_devs[] __devinitdata = { - { - .name = "88pm860x-regulator", - .id = 0, - .num_resources = ARRAY_SIZE(buck1_resources), - .resources = buck1_resources, - }, { - .name = "88pm860x-regulator", - .id = 1, - .num_resources = ARRAY_SIZE(buck2_resources), - .resources = buck2_resources, - }, { - .name = "88pm860x-regulator", - .id = 2, - .num_resources = ARRAY_SIZE(buck3_resources), - .resources = buck3_resources, - }, { - .name = "88pm860x-regulator", - .id = 3, - .num_resources = ARRAY_SIZE(ldo1_resources), - .resources = ldo1_resources, - }, { - .name = "88pm860x-regulator", - .id = 4, - .num_resources = ARRAY_SIZE(ldo2_resources), - .resources = ldo2_resources, - }, { - .name = "88pm860x-regulator", - .id = 5, - .num_resources = ARRAY_SIZE(ldo3_resources), - .resources = ldo3_resources, - }, { - .name = "88pm860x-regulator", - .id = 6, - .num_resources = ARRAY_SIZE(ldo4_resources), - .resources = ldo4_resources, - }, { - .name = "88pm860x-regulator", - .id = 7, - .num_resources = ARRAY_SIZE(ldo5_resources), - .resources = ldo5_resources, - }, { - .name = "88pm860x-regulator", - .id = 8, - .num_resources = ARRAY_SIZE(ldo6_resources), - .resources = ldo6_resources, - }, { - .name = "88pm860x-regulator", - .id = 9, - .num_resources = ARRAY_SIZE(ldo7_resources), - .resources = ldo7_resources, - }, { - .name = "88pm860x-regulator", - .id = 10, - .num_resources = ARRAY_SIZE(ldo8_resources), - .resources = ldo8_resources, - }, { - .name = "88pm860x-regulator", - .id = 11, - .num_resources = ARRAY_SIZE(ldo9_resources), - .resources = ldo9_resources, - }, { - .name = "88pm860x-regulator", - .id = 12, - .num_resources = ARRAY_SIZE(ldo10_resources), - .resources = ldo10_resources, - }, { - .name = "88pm860x-regulator", - .id = 13, - .num_resources = ARRAY_SIZE(ldo12_resources), - .resources = ldo12_resources, - }, { - .name = "88pm860x-regulator", - .id = 14, - .num_resources = ARRAY_SIZE(ldo_vibrator_resources), - .resources = ldo_vibrator_resources, - }, { - .name = "88pm860x-regulator", - .id = 15, - .num_resources = ARRAY_SIZE(ldo14_resources), - .resources = ldo14_resources, - }, +static struct mfd_cell bk_devs[] = { + {"88pm860x-backlight", 0,}, + {"88pm860x-backlight", 1,}, + {"88pm860x-backlight", 2,}, +}; + +static struct mfd_cell led_devs[] = { + {"88pm860x-led", 0,}, + {"88pm860x-led", 1,}, + {"88pm860x-led", 2,}, + {"88pm860x-led", 3,}, + {"88pm860x-led", 4,}, + {"88pm860x-led", 5,}, +}; + +static struct mfd_cell regulator_devs[] = { + {"88pm860x-regulator", 0,}, + {"88pm860x-regulator", 1,}, + {"88pm860x-regulator", 2,}, + {"88pm860x-regulator", 3,}, + {"88pm860x-regulator", 4,}, + {"88pm860x-regulator", 5,}, + {"88pm860x-regulator", 6,}, + {"88pm860x-regulator", 7,}, + {"88pm860x-regulator", 8,}, + {"88pm860x-regulator", 9,}, + {"88pm860x-regulator", 10,}, + {"88pm860x-regulator", 11,}, + {"88pm860x-regulator", 12,}, + {"88pm860x-regulator", 13,}, + {"88pm860x-regulator", 14,}, + {"88pm860x-regulator", 15,}, + {"88pm860x-regulator", 16,}, + {"88pm860x-regulator", 17,}, }; static struct mfd_cell touch_devs[] = { @@ -523,12 +360,15 @@ static void pm860x_irq_sync_unlock(struct irq_data *data) static void pm860x_irq_enable(struct irq_data *data) { - pm860x_irqs[data->hwirq].enable = pm860x_irqs[data->hwirq].offs; + struct pm860x_chip *chip = irq_data_get_irq_chip_data(data); + pm860x_irqs[data->irq - chip->irq_base].enable + = pm860x_irqs[data->irq - chip->irq_base].offs; } static void pm860x_irq_disable(struct irq_data *data) { - pm860x_irqs[data->hwirq].enable = 0; + struct pm860x_chip *chip = irq_data_get_irq_chip_data(data); + pm860x_irqs[data->irq - chip->irq_base].enable = 0; } static struct irq_chip pm860x_irq_chip = { @@ -539,24 +379,52 @@ static struct irq_chip pm860x_irq_chip = { .irq_disable = pm860x_irq_disable, }; -static int pm860x_irq_domain_map(struct irq_domain *d, unsigned int virq, - irq_hw_number_t hw) +static int __devinit device_gpadc_init(struct pm860x_chip *chip, + struct pm860x_platform_data *pdata) { - irq_set_chip_data(virq, d->host_data); - irq_set_chip_and_handler(virq, &pm860x_irq_chip, handle_edge_irq); - irq_set_nested_thread(virq, 1); -#ifdef CONFIG_ARM - set_irq_flags(virq, IRQF_VALID); -#else - irq_set_noprobe(virq); -#endif - return 0; -} + struct i2c_client *i2c = (chip->id == CHIP_PM8607) ? chip->client \ + : chip->companion; + int data; + int ret; -static struct irq_domain_ops pm860x_irq_domain_ops = { - .map = pm860x_irq_domain_map, - .xlate = irq_domain_xlate_onetwocell, -}; + /* initialize GPADC without activating it */ + + if (!pdata || !pdata->touch) + return -EINVAL; + + /* set GPADC MISC1 register */ + data = 0; + data |= (pdata->touch->gpadc_prebias << 1) & PM8607_GPADC_PREBIAS_MASK; + data |= (pdata->touch->slot_cycle << 3) & PM8607_GPADC_SLOT_CYCLE_MASK; + data |= (pdata->touch->off_scale << 5) & PM8607_GPADC_OFF_SCALE_MASK; + data |= (pdata->touch->sw_cal << 7) & PM8607_GPADC_SW_CAL_MASK; + if (data) { + ret = pm860x_reg_write(i2c, PM8607_GPADC_MISC1, data); + if (ret < 0) + goto out; + } + /* set tsi prebias time */ + if (pdata->touch->tsi_prebias) { + data = pdata->touch->tsi_prebias; + ret = pm860x_reg_write(i2c, PM8607_TSI_PREBIAS, data); + if (ret < 0) + goto out; + } + /* set prebias & prechg time of pen detect */ + data = 0; + data |= pdata->touch->pen_prebias & PM8607_PD_PREBIAS_MASK; + data |= (pdata->touch->pen_prechg << 5) & PM8607_PD_PRECHG_MASK; + if (data) { + ret = pm860x_reg_write(i2c, PM8607_PD_PREBIAS, data); + if (ret < 0) + goto out; + } + + ret = pm860x_set_bits(i2c, PM8607_GPADC_MISC1, + PM8607_GPADC_EN, PM8607_GPADC_EN); +out: + return ret; +} static int __devinit device_irq_init(struct pm860x_chip *chip, struct pm860x_platform_data *pdata) @@ -565,9 +433,13 @@ static int __devinit device_irq_init(struct pm860x_chip *chip, : chip->companion; unsigned char status_buf[INT_STATUS_NUM]; unsigned long flags = IRQF_TRIGGER_FALLING | IRQF_ONESHOT; - int data, mask, ret = -EINVAL; - int nr_irqs, irq_base = -1; - struct device_node *node = i2c->dev.of_node; + int i, data, mask, ret = -EINVAL; + int __irq; + + if (!pdata || !pdata->irq_base) { + dev_warn(chip->dev, "No interrupt support on IRQ base\n"); + return -EINVAL; + } mask = PM8607_B0_MISC1_INV_INT | PM8607_B0_MISC1_INT_CLEAR | PM8607_B0_MISC1_INT_MASK; @@ -607,24 +479,26 @@ static int __devinit device_irq_init(struct pm860x_chip *chip, goto out; mutex_init(&chip->irq_lock); - - if (pdata && pdata->irq_base) - irq_base = pdata->irq_base; - nr_irqs = ARRAY_SIZE(pm860x_irqs); - chip->irq_base = irq_alloc_descs(irq_base, 0, nr_irqs, 0); - if (chip->irq_base < 0) { - dev_err(&i2c->dev, "Failed to allocate interrupts, ret:%d\n", - chip->irq_base); - ret = -EBUSY; - goto out; - } - irq_domain_add_legacy(node, nr_irqs, chip->irq_base, 0, - &pm860x_irq_domain_ops, chip); + chip->irq_base = pdata->irq_base; chip->core_irq = i2c->irq; if (!chip->core_irq) goto out; - ret = request_threaded_irq(chip->core_irq, NULL, pm860x_irq, flags | IRQF_ONESHOT, + /* register IRQ by genirq */ + for (i = 0; i < ARRAY_SIZE(pm860x_irqs); i++) { + __irq = i + chip->irq_base; + irq_set_chip_data(__irq, chip); + irq_set_chip_and_handler(__irq, &pm860x_irq_chip, + handle_edge_irq); + irq_set_nested_thread(__irq, 1); +#ifdef CONFIG_ARM + set_irq_flags(__irq, IRQF_VALID); +#else + irq_set_noprobe(__irq); +#endif + } + + ret = request_threaded_irq(chip->core_irq, NULL, pm860x_irq, flags, "88pm860x", chip); if (ret) { dev_err(chip->dev, "Failed to request IRQ: %d\n", ret); @@ -741,122 +615,108 @@ static void __devinit device_osc_init(struct i2c_client *i2c) static void __devinit device_bk_init(struct pm860x_chip *chip, struct pm860x_platform_data *pdata) { - int ret, i; - - if (pdata && pdata->backlight) { - if (pdata->num_backlights > ARRAY_SIZE(bk_devs)) - pdata->num_backlights = ARRAY_SIZE(bk_devs); - for (i = 0; i < pdata->num_backlights; i++) { - bk_devs[i].platform_data = &pdata->backlight[i]; - bk_devs[i].pdata_size = - sizeof(struct pm860x_backlight_pdata); + int ret; + int i, j, id; + + if ((pdata == NULL) || (pdata->backlight == NULL)) + return; + + if (pdata->num_backlights > ARRAY_SIZE(bk_devs)) + pdata->num_backlights = ARRAY_SIZE(bk_devs); + + for (i = 0; i < pdata->num_backlights; i++) { + bk_devs[i].platform_data = &pdata->backlight[i]; + bk_devs[i].pdata_size = sizeof(struct pm860x_backlight_pdata); + + for (j = 0; j < ARRAY_SIZE(bk_devs); j++) { + id = bk_resources[j].start; + if (pdata->backlight[i].flags != id) + continue; + + bk_devs[i].num_resources = 1; + bk_devs[i].resources = &bk_resources[j]; + ret = mfd_add_devices(chip->dev, 0, + &bk_devs[i], 1, + &bk_resources[j], 0, NULL); + if (ret < 0) { + dev_err(chip->dev, "Failed to add " + "backlight subdev\n"); + return; + } } } - ret = mfd_add_devices(chip->dev, 0, bk_devs, - ARRAY_SIZE(bk_devs), NULL, 0, NULL); - if (ret < 0) - dev_err(chip->dev, "Failed to add backlight subdev\n"); } static void __devinit device_led_init(struct pm860x_chip *chip, struct pm860x_platform_data *pdata) { - int ret, i; - - if (pdata && pdata->led) { - if (pdata->num_leds > ARRAY_SIZE(led_devs)) - pdata->num_leds = ARRAY_SIZE(led_devs); - for (i = 0; i < pdata->num_leds; i++) { - led_devs[i].platform_data = &pdata->led[i]; - led_devs[i].pdata_size = - sizeof(struct pm860x_led_pdata); - } - } - ret = mfd_add_devices(chip->dev, 0, led_devs, - ARRAY_SIZE(led_devs), NULL, 0, NULL); - if (ret < 0) { - dev_err(chip->dev, "Failed to add led subdev\n"); + int ret; + int i, j, id; + + if ((pdata == NULL) || (pdata->led == NULL)) return; + + if (pdata->num_leds > ARRAY_SIZE(led_devs)) + pdata->num_leds = ARRAY_SIZE(led_devs); + + for (i = 0; i < pdata->num_leds; i++) { + led_devs[i].platform_data = &pdata->led[i]; + led_devs[i].pdata_size = sizeof(struct pm860x_led_pdata); + + for (j = 0; j < ARRAY_SIZE(led_devs); j++) { + id = led_resources[j].start; + if (pdata->led[i].flags != id) + continue; + + led_devs[i].num_resources = 1; + led_devs[i].resources = &led_resources[j], + ret = mfd_add_devices(chip->dev, 0, + &led_devs[i], 1, + &led_resources[j], 0, NULL); + if (ret < 0) { + dev_err(chip->dev, "Failed to add " + "led subdev\n"); + return; + } + } } } static void __devinit device_regulator_init(struct pm860x_chip *chip, struct pm860x_platform_data *pdata) { + struct regulator_init_data *initdata; int ret; + int i, seq; - if (pdata == NULL) - return; - if (pdata->buck1) { - reg_devs[0].platform_data = pdata->buck1; - reg_devs[0].pdata_size = sizeof(struct regulator_init_data); - } - if (pdata->buck2) { - reg_devs[1].platform_data = pdata->buck2; - reg_devs[1].pdata_size = sizeof(struct regulator_init_data); - } - if (pdata->buck3) { - reg_devs[2].platform_data = pdata->buck3; - reg_devs[2].pdata_size = sizeof(struct regulator_init_data); - } - if (pdata->ldo1) { - reg_devs[3].platform_data = pdata->ldo1; - reg_devs[3].pdata_size = sizeof(struct regulator_init_data); - } - if (pdata->ldo2) { - reg_devs[4].platform_data = pdata->ldo2; - reg_devs[4].pdata_size = sizeof(struct regulator_init_data); - } - if (pdata->ldo3) { - reg_devs[5].platform_data = pdata->ldo3; - reg_devs[5].pdata_size = sizeof(struct regulator_init_data); - } - if (pdata->ldo4) { - reg_devs[6].platform_data = pdata->ldo4; - reg_devs[6].pdata_size = sizeof(struct regulator_init_data); - } - if (pdata->ldo5) { - reg_devs[7].platform_data = pdata->ldo5; - reg_devs[7].pdata_size = sizeof(struct regulator_init_data); - } - if (pdata->ldo6) { - reg_devs[8].platform_data = pdata->ldo6; - reg_devs[8].pdata_size = sizeof(struct regulator_init_data); - } - if (pdata->ldo7) { - reg_devs[9].platform_data = pdata->ldo7; - reg_devs[9].pdata_size = sizeof(struct regulator_init_data); - } - if (pdata->ldo8) { - reg_devs[10].platform_data = pdata->ldo8; - reg_devs[10].pdata_size = sizeof(struct regulator_init_data); - } - if (pdata->ldo9) { - reg_devs[11].platform_data = pdata->ldo9; - reg_devs[11].pdata_size = sizeof(struct regulator_init_data); - } - if (pdata->ldo10) { - reg_devs[12].platform_data = pdata->ldo10; - reg_devs[12].pdata_size = sizeof(struct regulator_init_data); - } - if (pdata->ldo12) { - reg_devs[13].platform_data = pdata->ldo12; - reg_devs[13].pdata_size = sizeof(struct regulator_init_data); - } - if (pdata->ldo_vibrator) { - reg_devs[14].platform_data = pdata->ldo_vibrator; - reg_devs[14].pdata_size = sizeof(struct regulator_init_data); - } - if (pdata->ldo14) { - reg_devs[15].platform_data = pdata->ldo14; - reg_devs[15].pdata_size = sizeof(struct regulator_init_data); - } - ret = mfd_add_devices(chip->dev, 0, reg_devs, - ARRAY_SIZE(reg_devs), NULL, 0, NULL); - if (ret < 0) { - dev_err(chip->dev, "Failed to add regulator subdev\n"); + if ((pdata == NULL) || (pdata->regulator == NULL)) return; + + if (pdata->num_regulators > ARRAY_SIZE(regulator_devs)) + pdata->num_regulators = ARRAY_SIZE(regulator_devs); + + for (i = 0, seq = -1; i < pdata->num_regulators; i++) { + initdata = &pdata->regulator[i]; + seq = *(unsigned int *)initdata->driver_data; + if ((seq < 0) || (seq > PM8607_ID_RG_MAX)) { + dev_err(chip->dev, "Wrong ID(%d) on regulator(%s)\n", + seq, initdata->constraints.name); + goto out; + } + regulator_devs[i].platform_data = &pdata->regulator[i]; + regulator_devs[i].pdata_size = sizeof(struct regulator_init_data); + regulator_devs[i].num_resources = 1; + regulator_devs[i].resources = ®ulator_resources[seq]; + + ret = mfd_add_devices(chip->dev, 0, ®ulator_devs[i], 1, + ®ulator_resources[seq], 0, NULL); + if (ret < 0) { + dev_err(chip->dev, "Failed to add regulator subdev\n"); + goto out; + } } +out: + return; } static void __devinit device_rtc_init(struct pm860x_chip *chip, @@ -925,8 +785,10 @@ static void __devinit device_power_init(struct pm860x_chip *chip, power_devs[2].platform_data = &preg_init_data; power_devs[2].pdata_size = sizeof(struct regulator_init_data); + power_devs[2].num_resources = ARRAY_SIZE(preg_resources); + power_devs[2].resources = &preg_resources[0], ret = mfd_add_devices(chip->dev, 0, &power_devs[2], 1, - NULL, chip->irq_base, NULL); + &preg_resources[0], chip->irq_base, NULL); if (ret < 0) dev_err(chip->dev, "Failed to add preg subdev\n"); } @@ -1006,6 +868,10 @@ static void __devinit device_8607_init(struct pm860x_chip *chip, goto out; } + ret = device_gpadc_init(chip, pdata); + if (ret < 0) + goto out; + ret = device_irq_init(chip, pdata); if (ret < 0) goto out; @@ -1029,8 +895,8 @@ static void __devinit device_8606_init(struct pm860x_chip *chip, device_led_init(chip, pdata); } -static int __devinit pm860x_device_init(struct pm860x_chip *chip, - struct pm860x_platform_data *pdata) +int __devinit pm860x_device_init(struct pm860x_chip *chip, + struct pm860x_platform_data *pdata) { chip->core_irq = 0; @@ -1057,207 +923,12 @@ static int __devinit pm860x_device_init(struct pm860x_chip *chip, return 0; } -static void __devexit pm860x_device_exit(struct pm860x_chip *chip) +void __devexit pm860x_device_exit(struct pm860x_chip *chip) { device_irq_exit(chip); mfd_remove_devices(chip->dev); } -static int verify_addr(struct i2c_client *i2c) -{ - unsigned short addr_8607[] = {0x30, 0x34}; - unsigned short addr_8606[] = {0x10, 0x11}; - int size, i; - - if (i2c == NULL) - return 0; - size = ARRAY_SIZE(addr_8606); - for (i = 0; i < size; i++) { - if (i2c->addr == *(addr_8606 + i)) - return CHIP_PM8606; - } - size = ARRAY_SIZE(addr_8607); - for (i = 0; i < size; i++) { - if (i2c->addr == *(addr_8607 + i)) - return CHIP_PM8607; - } - return 0; -} - -static struct regmap_config pm860x_regmap_config = { - .reg_bits = 8, - .val_bits = 8, -}; - -static int __devinit pm860x_dt_init(struct device_node *np, - struct device *dev, - struct pm860x_platform_data *pdata) -{ - int ret; - - if (of_get_property(np, "marvell,88pm860x-irq-read-clr", NULL)) - pdata->irq_mode = 1; - ret = of_property_read_u32(np, "marvell,88pm860x-slave-addr", - &pdata->companion_addr); - if (ret) { - dev_err(dev, "Not found \"marvell,88pm860x-slave-addr\" " - "property\n"); - pdata->companion_addr = 0; - } - return 0; -} - -static int __devinit pm860x_probe(struct i2c_client *client, - const struct i2c_device_id *id) -{ - struct pm860x_platform_data *pdata = client->dev.platform_data; - struct device_node *node = client->dev.of_node; - struct pm860x_chip *chip; - int ret; - - if (node && !pdata) { - /* parse DT to get platform data */ - pdata = devm_kzalloc(&client->dev, - sizeof(struct pm860x_platform_data), - GFP_KERNEL); - if (!pdata) - return -ENOMEM; - ret = pm860x_dt_init(node, &client->dev, pdata); - if (ret) - goto err; - } else if (!pdata) { - pr_info("No platform data in %s!\n", __func__); - return -EINVAL; - } - - chip = kzalloc(sizeof(struct pm860x_chip), GFP_KERNEL); - if (chip == NULL) { - ret = -ENOMEM; - goto err; - } - - chip->id = verify_addr(client); - chip->regmap = regmap_init_i2c(client, &pm860x_regmap_config); - if (IS_ERR(chip->regmap)) { - ret = PTR_ERR(chip->regmap); - dev_err(&client->dev, "Failed to allocate register map: %d\n", - ret); - kfree(chip); - return ret; - } - chip->client = client; - i2c_set_clientdata(client, chip); - chip->dev = &client->dev; - dev_set_drvdata(chip->dev, chip); - - /* - * Both client and companion client shares same platform driver. - * Driver distinguishes them by pdata->companion_addr. - * pdata->companion_addr is only assigned if companion chip exists. - * At the same time, the companion_addr shouldn't equal to client - * address. - */ - if (pdata->companion_addr && (pdata->companion_addr != client->addr)) { - chip->companion_addr = pdata->companion_addr; - chip->companion = i2c_new_dummy(chip->client->adapter, - chip->companion_addr); - chip->regmap_companion = regmap_init_i2c(chip->companion, - &pm860x_regmap_config); - if (IS_ERR(chip->regmap_companion)) { - ret = PTR_ERR(chip->regmap_companion); - dev_err(&chip->companion->dev, - "Failed to allocate register map: %d\n", ret); - return ret; - } - i2c_set_clientdata(chip->companion, chip); - } - - pm860x_device_init(chip, pdata); - return 0; -err: - if (node) - devm_kfree(&client->dev, pdata); - return ret; -} - -static int __devexit pm860x_remove(struct i2c_client *client) -{ - struct pm860x_chip *chip = i2c_get_clientdata(client); - - pm860x_device_exit(chip); - if (chip->companion) { - regmap_exit(chip->regmap_companion); - i2c_unregister_device(chip->companion); - } - regmap_exit(chip->regmap); - kfree(chip); - return 0; -} - -#ifdef CONFIG_PM_SLEEP -static int pm860x_suspend(struct device *dev) -{ - struct i2c_client *client = container_of(dev, struct i2c_client, dev); - struct pm860x_chip *chip = i2c_get_clientdata(client); - - if (device_may_wakeup(dev) && chip->wakeup_flag) - enable_irq_wake(chip->core_irq); - return 0; -} - -static int pm860x_resume(struct device *dev) -{ - struct i2c_client *client = container_of(dev, struct i2c_client, dev); - struct pm860x_chip *chip = i2c_get_clientdata(client); - - if (device_may_wakeup(dev) && chip->wakeup_flag) - disable_irq_wake(chip->core_irq); - return 0; -} -#endif - -static SIMPLE_DEV_PM_OPS(pm860x_pm_ops, pm860x_suspend, pm860x_resume); - -static const struct i2c_device_id pm860x_id_table[] = { - { "88PM860x", 0 }, - {} -}; -MODULE_DEVICE_TABLE(i2c, pm860x_id_table); - -static const struct of_device_id pm860x_dt_ids[] = { - { .compatible = "marvell,88pm860x", }, - {}, -}; -MODULE_DEVICE_TABLE(of, pm860x_dt_ids); - -static struct i2c_driver pm860x_driver = { - .driver = { - .name = "88PM860x", - .owner = THIS_MODULE, - .pm = &pm860x_pm_ops, - .of_match_table = of_match_ptr(pm860x_dt_ids), - }, - .probe = pm860x_probe, - .remove = __devexit_p(pm860x_remove), - .id_table = pm860x_id_table, -}; - -static int __init pm860x_i2c_init(void) -{ - int ret; - ret = i2c_add_driver(&pm860x_driver); - if (ret != 0) - pr_err("Failed to register 88PM860x I2C driver: %d\n", ret); - return ret; -} -subsys_initcall(pm860x_i2c_init); - -static void __exit pm860x_i2c_exit(void) -{ - i2c_del_driver(&pm860x_driver); -} -module_exit(pm860x_i2c_exit); - MODULE_DESCRIPTION("PMIC Driver for Marvell 88PM860x"); MODULE_AUTHOR("Haojian Zhuang "); MODULE_LICENSE("GPL"); diff --git a/trunk/drivers/mfd/88pm860x-i2c.c b/trunk/drivers/mfd/88pm860x-i2c.c index ff8f803ce833..b2cfdc458561 100644 --- a/trunk/drivers/mfd/88pm860x-i2c.c +++ b/trunk/drivers/mfd/88pm860x-i2c.c @@ -10,9 +10,12 @@ */ #include #include +#include #include +#include #include #include +#include int pm860x_reg_read(struct i2c_client *i2c, int reg) { @@ -88,18 +91,8 @@ static int read_device(struct i2c_client *i2c, int reg, unsigned char msgbuf0[I2C_SMBUS_BLOCK_MAX + 3]; unsigned char msgbuf1[I2C_SMBUS_BLOCK_MAX + 2]; struct i2c_adapter *adap = i2c->adapter; - struct i2c_msg msg[2] = { - { - .addr = i2c->addr, - .flags = 0, - .len = 1, - .buf = msgbuf0 - }, - { .addr = i2c->addr, - .flags = I2C_M_RD, - .len = 0, - .buf = msgbuf1 - }, + struct i2c_msg msg[2] = {{i2c->addr, 0, 1, msgbuf0}, + {i2c->addr, I2C_M_RD, 0, msgbuf1}, }; int num = 1, ret = 0; @@ -238,3 +231,160 @@ int pm860x_page_set_bits(struct i2c_client *i2c, int reg, return ret; } EXPORT_SYMBOL(pm860x_page_set_bits); + +static const struct i2c_device_id pm860x_id_table[] = { + { "88PM860x", 0 }, + {} +}; +MODULE_DEVICE_TABLE(i2c, pm860x_id_table); + +static int verify_addr(struct i2c_client *i2c) +{ + unsigned short addr_8607[] = {0x30, 0x34}; + unsigned short addr_8606[] = {0x10, 0x11}; + int size, i; + + if (i2c == NULL) + return 0; + size = ARRAY_SIZE(addr_8606); + for (i = 0; i < size; i++) { + if (i2c->addr == *(addr_8606 + i)) + return CHIP_PM8606; + } + size = ARRAY_SIZE(addr_8607); + for (i = 0; i < size; i++) { + if (i2c->addr == *(addr_8607 + i)) + return CHIP_PM8607; + } + return 0; +} + +static struct regmap_config pm860x_regmap_config = { + .reg_bits = 8, + .val_bits = 8, +}; + +static int __devinit pm860x_probe(struct i2c_client *client, + const struct i2c_device_id *id) +{ + struct pm860x_platform_data *pdata = client->dev.platform_data; + struct pm860x_chip *chip; + int ret; + + if (!pdata) { + pr_info("No platform data in %s!\n", __func__); + return -EINVAL; + } + + chip = kzalloc(sizeof(struct pm860x_chip), GFP_KERNEL); + if (chip == NULL) + return -ENOMEM; + + chip->id = verify_addr(client); + chip->regmap = regmap_init_i2c(client, &pm860x_regmap_config); + if (IS_ERR(chip->regmap)) { + ret = PTR_ERR(chip->regmap); + dev_err(&client->dev, "Failed to allocate register map: %d\n", + ret); + kfree(chip); + return ret; + } + chip->client = client; + i2c_set_clientdata(client, chip); + chip->dev = &client->dev; + dev_set_drvdata(chip->dev, chip); + + /* + * Both client and companion client shares same platform driver. + * Driver distinguishes them by pdata->companion_addr. + * pdata->companion_addr is only assigned if companion chip exists. + * At the same time, the companion_addr shouldn't equal to client + * address. + */ + if (pdata->companion_addr && (pdata->companion_addr != client->addr)) { + chip->companion_addr = pdata->companion_addr; + chip->companion = i2c_new_dummy(chip->client->adapter, + chip->companion_addr); + chip->regmap_companion = regmap_init_i2c(chip->companion, + &pm860x_regmap_config); + if (IS_ERR(chip->regmap_companion)) { + ret = PTR_ERR(chip->regmap_companion); + dev_err(&chip->companion->dev, + "Failed to allocate register map: %d\n", ret); + return ret; + } + i2c_set_clientdata(chip->companion, chip); + } + + pm860x_device_init(chip, pdata); + return 0; +} + +static int __devexit pm860x_remove(struct i2c_client *client) +{ + struct pm860x_chip *chip = i2c_get_clientdata(client); + + pm860x_device_exit(chip); + if (chip->companion) { + regmap_exit(chip->regmap_companion); + i2c_unregister_device(chip->companion); + } + regmap_exit(chip->regmap); + kfree(chip); + return 0; +} + +#ifdef CONFIG_PM_SLEEP +static int pm860x_suspend(struct device *dev) +{ + struct i2c_client *client = container_of(dev, struct i2c_client, dev); + struct pm860x_chip *chip = i2c_get_clientdata(client); + + if (device_may_wakeup(dev) && chip->wakeup_flag) + enable_irq_wake(chip->core_irq); + return 0; +} + +static int pm860x_resume(struct device *dev) +{ + struct i2c_client *client = container_of(dev, struct i2c_client, dev); + struct pm860x_chip *chip = i2c_get_clientdata(client); + + if (device_may_wakeup(dev) && chip->wakeup_flag) + disable_irq_wake(chip->core_irq); + return 0; +} +#endif + +static SIMPLE_DEV_PM_OPS(pm860x_pm_ops, pm860x_suspend, pm860x_resume); + +static struct i2c_driver pm860x_driver = { + .driver = { + .name = "88PM860x", + .owner = THIS_MODULE, + .pm = &pm860x_pm_ops, + }, + .probe = pm860x_probe, + .remove = __devexit_p(pm860x_remove), + .id_table = pm860x_id_table, +}; + +static int __init pm860x_i2c_init(void) +{ + int ret; + ret = i2c_add_driver(&pm860x_driver); + if (ret != 0) + pr_err("Failed to register 88PM860x I2C driver: %d\n", ret); + return ret; +} +subsys_initcall(pm860x_i2c_init); + +static void __exit pm860x_i2c_exit(void) +{ + i2c_del_driver(&pm860x_driver); +} +module_exit(pm860x_i2c_exit); + +MODULE_DESCRIPTION("I2C Driver for Marvell 88PM860x"); +MODULE_AUTHOR("Haojian Zhuang "); +MODULE_LICENSE("GPL"); diff --git a/trunk/drivers/mfd/Kconfig b/trunk/drivers/mfd/Kconfig index acab3ef8a310..b1a146205c08 100644 --- a/trunk/drivers/mfd/Kconfig +++ b/trunk/drivers/mfd/Kconfig @@ -298,6 +298,16 @@ config MFD_TWL4030_AUDIO select MFD_CORE default n +config TWL6030_PWM + tristate "TWL6030 PWM (Pulse Width Modulator) Support" + depends on TWL4030_CORE + select HAVE_PWM + depends on !PWM + default n + help + Say yes here if you want support for TWL6030 PWM. + This is used to control charging LED brightness. + config TWL6040_CORE bool "Support for TWL6040 audio codec" depends on I2C=y && GENERIC_HARDIRQS @@ -375,18 +385,6 @@ config MFD_T7L66XB help Support for Toshiba Mobile IO Controller T7L66XB -config MFD_SMSC - bool "Support for the SMSC ECE1099 series chips" - depends on I2C=y - select MFD_CORE - select REGMAP_I2C - help - If you say yes here you get support for the - ece1099 chips from SMSC. - - To compile this driver as a module, choose M here: the - module will be called smsc. - config MFD_TC6387XB bool "Support Toshiba TC6387XB" depends on ARM && HAVE_CLK @@ -443,23 +441,6 @@ config MFD_DA9052_I2C for accessing the device, additional drivers must be enabled in order to use the functionality of the device. -config MFD_DA9055 - bool "Dialog Semiconductor DA9055 PMIC Support" - select REGMAP_I2C - select REGMAP_IRQ - select PMIC_DA9055 - select MFD_CORE - depends on I2C=y - help - Say yes here for support of Dialog Semiconductor DA9055. This is - a Power Management IC. This driver provides common support for - accessing the device as well as the I2C interface to the chip itself. - Additional drivers must be enabled in order to use the functionality - of the device. - - This driver can be built as a module. If built as a module it will be - called "da9055" - config PMIC_ADP5520 bool "Analog Devices ADP5520/01 MFD PMIC Core Support" depends on I2C=y @@ -470,16 +451,6 @@ config PMIC_ADP5520 individual components like LCD backlight, LEDs, GPIOs and Kepad under the corresponding menus. -config MFD_LP8788 - bool "Texas Instruments LP8788 Power Management Unit Driver" - depends on I2C=y - select MFD_CORE - select REGMAP_I2C - select IRQ_DOMAIN - help - TI LP8788 PMU supports regulators, battery charger, RTC, - ADC, backlight driver and current sinks. - config MFD_MAX77686 bool "Maxim Semiconductor MAX77686 PMIC Support" depends on I2C=y && GENERIC_HARDIRQS @@ -506,18 +477,6 @@ config MFD_MAX77693 additional drivers must be enabled in order to use the functionality of the device. -config MFD_MAX8907 - tristate "Maxim Semiconductor MAX8907 PMIC Support" - select MFD_CORE - depends on I2C=y && GENERIC_HARDIRQS - select REGMAP_I2C - select REGMAP_IRQ - help - Say yes here to support for Maxim Semiconductor MAX8907. This is - a Power Management IC. This driver provides common support for - accessing the device; additional drivers must be enabled in order - to use the functionality of the device. - config MFD_MAX8925 bool "Maxim Semiconductor MAX8925 PMIC Support" depends on I2C=y && GENERIC_HARDIRQS @@ -937,7 +896,7 @@ config MFD_WL1273_CORE audio codec. config MFD_OMAP_USB_HOST - bool "Support OMAP USBHS core and TLL driver" + bool "Support OMAP USBHS core driver" depends on USB_EHCI_HCD_OMAP || USB_OHCI_HCD_OMAP3 default y help @@ -1026,13 +985,13 @@ config MFD_STA2X11 depends on STA2X11 select MFD_CORE -config MFD_SYSCON - bool "System Controller Register R/W Based on Regmap" - depends on OF - select REGMAP_MMIO +config MFD_ANATOP + bool "Support for Freescale i.MX on-chip ANATOP controller" + depends on SOC_IMX6Q help - Select this option to enable accessing system control registers - via regmap. + Select this option to enable Freescale i.MX on-chip ANATOP + MFD controller. This controller embeds regulator and + thermal devices for Freescale i.MX platforms. config MFD_PALMAS bool "Support for the TI Palmas series chips" diff --git a/trunk/drivers/mfd/Makefile b/trunk/drivers/mfd/Makefile index d8ccb630ddb0..79dd22d1dc3d 100644 --- a/trunk/drivers/mfd/Makefile +++ b/trunk/drivers/mfd/Makefile @@ -63,6 +63,7 @@ obj-$(CONFIG_TWL4030_CORE) += twl-core.o twl4030-irq.o twl6030-irq.o obj-$(CONFIG_TWL4030_MADC) += twl4030-madc.o obj-$(CONFIG_TWL4030_POWER) += twl4030-power.o obj-$(CONFIG_MFD_TWL4030_AUDIO) += twl4030-audio.o +obj-$(CONFIG_TWL6030_PWM) += twl6030-pwm.o obj-$(CONFIG_TWL6040_CORE) += twl6040-core.o twl6040-irq.o obj-$(CONFIG_MFD_MC13XXX) += mc13xxx-core.o @@ -76,7 +77,6 @@ obj-$(CONFIG_EZX_PCAP) += ezx-pcap.o obj-$(CONFIG_MCP) += mcp-core.o obj-$(CONFIG_MCP_SA11X0) += mcp-sa11x0.o obj-$(CONFIG_MCP_UCB1200) += ucb1x00-core.o -obj-$(CONFIG_MFD_SMSC) += smsc-ece1099.o obj-$(CONFIG_MCP_UCB1200_TS) += ucb1x00-ts.o ifeq ($(CONFIG_SA1100_ASSABET),y) @@ -90,14 +90,8 @@ obj-$(CONFIG_PMIC_DA9052) += da9052-core.o obj-$(CONFIG_MFD_DA9052_SPI) += da9052-spi.o obj-$(CONFIG_MFD_DA9052_I2C) += da9052-i2c.o -obj-$(CONFIG_MFD_LP8788) += lp8788.o lp8788-irq.o - -da9055-objs := da9055-core.o da9055-i2c.o -obj-$(CONFIG_MFD_DA9055) += da9055.o - obj-$(CONFIG_MFD_MAX77686) += max77686.o max77686-irq.o obj-$(CONFIG_MFD_MAX77693) += max77693.o max77693-irq.o -obj-$(CONFIG_MFD_MAX8907) += max8907.o max8925-objs := max8925-core.o max8925-i2c.o obj-$(CONFIG_MFD_MAX8925) += max8925.o obj-$(CONFIG_MFD_MAX8997) += max8997.o max8997-irq.o @@ -126,7 +120,7 @@ obj-$(CONFIG_MFD_TPS6586X) += tps6586x.o obj-$(CONFIG_MFD_VX855) += vx855.o obj-$(CONFIG_MFD_WL1273_CORE) += wl1273-core.o obj-$(CONFIG_MFD_CS5535) += cs5535-mfd.o -obj-$(CONFIG_MFD_OMAP_USB_HOST) += omap-usb-host.o omap-usb-tll.o +obj-$(CONFIG_MFD_OMAP_USB_HOST) += omap-usb-host.o obj-$(CONFIG_MFD_PM8921_CORE) += pm8921-core.o obj-$(CONFIG_MFD_PM8XXX_IRQ) += pm8xxx-irq.o obj-$(CONFIG_TPS65911_COMPARATOR) += tps65911-comparator.o @@ -136,5 +130,5 @@ obj-$(CONFIG_MFD_INTEL_MSIC) += intel_msic.o obj-$(CONFIG_MFD_PALMAS) += palmas.o obj-$(CONFIG_MFD_RC5T583) += rc5t583.o rc5t583-irq.o obj-$(CONFIG_MFD_SEC_CORE) += sec-core.o sec-irq.o -obj-$(CONFIG_MFD_SYSCON) += syscon.o +obj-$(CONFIG_MFD_ANATOP) += anatop-mfd.o obj-$(CONFIG_MFD_LM3533) += lm3533-core.o lm3533-ctrlbank.o diff --git a/trunk/drivers/mfd/ab3100-core.c b/trunk/drivers/mfd/ab3100-core.c index 2b3dde571a50..01781ae5d0d7 100644 --- a/trunk/drivers/mfd/ab3100-core.c +++ b/trunk/drivers/mfd/ab3100-core.c @@ -21,7 +21,6 @@ #include #include #include -#include #include /* These are the only registers inside AB3100 used in this main file */ diff --git a/trunk/drivers/mfd/ab8500-core.c b/trunk/drivers/mfd/ab8500-core.c index 1667c77b5cde..47adf800024e 100644 --- a/trunk/drivers/mfd/ab8500-core.c +++ b/trunk/drivers/mfd/ab8500-core.c @@ -472,22 +472,6 @@ static irqreturn_t ab8500_hierarchical_irq(int irq, void *dev) return IRQ_HANDLED; } -/** - * ab8500_irq_get_virq(): Map an interrupt on a chip to a virtual IRQ - * - * @ab8500: ab8500_irq controller to operate on. - * @irq: index of the interrupt requested in the chip IRQs - * - * Useful for drivers to request their own IRQs. - */ -static int ab8500_irq_get_virq(struct ab8500 *ab8500, int irq) -{ - if (!ab8500) - return -EINVAL; - - return irq_create_mapping(ab8500->domain, irq); -} - static irqreturn_t ab8500_irq(int irq, void *dev) { struct ab8500 *ab8500 = dev; @@ -517,9 +501,8 @@ static irqreturn_t ab8500_irq(int irq, void *dev) do { int bit = __ffs(value); int line = i * 8 + bit; - int virq = ab8500_irq_get_virq(ab8500, line); - handle_nested_irq(virq); + handle_nested_irq(ab8500->irq_base + line); value &= ~(1 << bit); } while (value); @@ -528,6 +511,23 @@ static irqreturn_t ab8500_irq(int irq, void *dev) return IRQ_HANDLED; } +/** + * ab8500_irq_get_virq(): Map an interrupt on a chip to a virtual IRQ + * + * @ab8500: ab8500_irq controller to operate on. + * @irq: index of the interrupt requested in the chip IRQs + * + * Useful for drivers to request their own IRQs. + */ +int ab8500_irq_get_virq(struct ab8500 *ab8500, int irq) +{ + if (!ab8500) + return -EINVAL; + + return irq_create_mapping(ab8500->domain, irq); +} +EXPORT_SYMBOL_GPL(ab8500_irq_get_virq); + static int ab8500_irq_map(struct irq_domain *d, unsigned int virq, irq_hw_number_t hwirq) { @@ -1076,7 +1076,6 @@ static struct mfd_cell __devinitdata ab8500_devs[] = { }, { .name = "ab8500-codec", - .of_compatible = "stericsson,ab8500-codec", }, }; diff --git a/trunk/drivers/mfd/anatop-mfd.c b/trunk/drivers/mfd/anatop-mfd.c new file mode 100644 index 000000000000..5576e07576de --- /dev/null +++ b/trunk/drivers/mfd/anatop-mfd.c @@ -0,0 +1,124 @@ +/* + * Anatop MFD driver + * + * Copyright (C) 2012 Ying-Chun Liu (PaulLiu) + * Copyright (C) 2012 Linaro + * + * 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. + * 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 +#include +#include +#include +#include +#include +#include + +u32 anatop_read_reg(struct anatop *adata, u32 addr) +{ + return readl(adata->ioreg + addr); +} +EXPORT_SYMBOL_GPL(anatop_read_reg); + +void anatop_write_reg(struct anatop *adata, u32 addr, u32 data, u32 mask) +{ + u32 val; + + data &= mask; + + spin_lock(&adata->reglock); + val = readl(adata->ioreg + addr); + val &= ~mask; + val |= data; + writel(val, adata->ioreg + addr); + spin_unlock(&adata->reglock); +} +EXPORT_SYMBOL_GPL(anatop_write_reg); + +static const struct of_device_id of_anatop_match[] = { + { .compatible = "fsl,imx6q-anatop", }, + { }, +}; + +static int __devinit of_anatop_probe(struct platform_device *pdev) +{ + struct device *dev = &pdev->dev; + struct device_node *np = dev->of_node; + void *ioreg; + struct anatop *drvdata; + + ioreg = of_iomap(np, 0); + if (!ioreg) + return -EADDRNOTAVAIL; + drvdata = devm_kzalloc(dev, sizeof(*drvdata), GFP_KERNEL); + if (!drvdata) + return -ENOMEM; + drvdata->ioreg = ioreg; + spin_lock_init(&drvdata->reglock); + platform_set_drvdata(pdev, drvdata); + of_platform_populate(np, NULL, NULL, dev); + + return 0; +} + +static int __devexit of_anatop_remove(struct platform_device *pdev) +{ + struct anatop *drvdata; + drvdata = platform_get_drvdata(pdev); + iounmap(drvdata->ioreg); + + return 0; +} + +static struct platform_driver anatop_of_driver = { + .driver = { + .name = "anatop-mfd", + .owner = THIS_MODULE, + .of_match_table = of_anatop_match, + }, + .probe = of_anatop_probe, + .remove = of_anatop_remove, +}; + +static int __init anatop_init(void) +{ + return platform_driver_register(&anatop_of_driver); +} +postcore_initcall(anatop_init); + +static void __exit anatop_exit(void) +{ + platform_driver_unregister(&anatop_of_driver); +} +module_exit(anatop_exit); + +MODULE_AUTHOR("Ying-Chun Liu (PaulLiu) "); +MODULE_DESCRIPTION("ANATOP MFD driver"); +MODULE_LICENSE("GPL v2"); diff --git a/trunk/drivers/mfd/arizona-irq.c b/trunk/drivers/mfd/arizona-irq.c index ef0f2d001df2..98ac345f468e 100644 --- a/trunk/drivers/mfd/arizona-irq.c +++ b/trunk/drivers/mfd/arizona-irq.c @@ -94,8 +94,7 @@ static irqreturn_t arizona_ctrlif_err(int irq, void *data) static irqreturn_t arizona_irq_thread(int irq, void *data) { struct arizona *arizona = data; - unsigned int val; - int ret; + int i, ret; ret = pm_runtime_get_sync(arizona->dev); if (ret < 0) { @@ -103,20 +102,9 @@ static irqreturn_t arizona_irq_thread(int irq, void *data) return IRQ_NONE; } - /* Always handle the AoD domain */ - handle_nested_irq(irq_find_mapping(arizona->virq, 0)); - - /* - * Check if one of the main interrupts is asserted and only - * check that domain if it is. - */ - ret = regmap_read(arizona->regmap, ARIZONA_IRQ_PIN_STATUS, &val); - if (ret == 0 && val & ARIZONA_IRQ1_STS) { - handle_nested_irq(irq_find_mapping(arizona->virq, 1)); - } else if (ret != 0) { - dev_err(arizona->dev, "Failed to read main IRQ status: %d\n", - ret); - } + /* Check both domains */ + for (i = 0; i < 2; i++) + handle_nested_irq(irq_find_mapping(arizona->virq, i)); pm_runtime_mark_last_busy(arizona->dev); pm_runtime_put_autosuspend(arizona->dev); @@ -168,36 +156,18 @@ int arizona_irq_init(struct arizona *arizona) int flags = IRQF_ONESHOT; int ret, i; const struct regmap_irq_chip *aod, *irq; - bool ctrlif_error = true; switch (arizona->type) { #ifdef CONFIG_MFD_WM5102 case WM5102: aod = &wm5102_aod; irq = &wm5102_irq; - - switch (arizona->rev) { - case 0: - ctrlif_error = false; - break; - default: - break; - } break; #endif #ifdef CONFIG_MFD_WM5110 case WM5110: aod = &wm5110_aod; irq = &wm5110_irq; - - switch (arizona->rev) { - case 0: - case 1: - ctrlif_error = false; - break; - default: - break; - } break; #endif default: @@ -256,17 +226,13 @@ int arizona_irq_init(struct arizona *arizona) } /* Handle control interface errors in the core */ - if (ctrlif_error) { - i = arizona_map_irq(arizona, ARIZONA_IRQ_CTRLIF_ERR); - ret = request_threaded_irq(i, NULL, arizona_ctrlif_err, - IRQF_ONESHOT, - "Control interface error", arizona); - if (ret != 0) { - dev_err(arizona->dev, - "Failed to request CTRLIF_ERR %d: %d\n", - arizona->irq, ret); - goto err_ctrlif; - } + i = arizona_map_irq(arizona, ARIZONA_IRQ_CTRLIF_ERR); + ret = request_threaded_irq(i, NULL, arizona_ctrlif_err, IRQF_ONESHOT, + "Control interface error", arizona); + if (ret != 0) { + dev_err(arizona->dev, "Failed to request boot done %d: %d\n", + arizona->irq, ret); + goto err_ctrlif; } ret = request_threaded_irq(arizona->irq, NULL, arizona_irq_thread, diff --git a/trunk/drivers/mfd/da9055-core.c b/trunk/drivers/mfd/da9055-core.c deleted file mode 100644 index ff6c77f392bd..000000000000 --- a/trunk/drivers/mfd/da9055-core.c +++ /dev/null @@ -1,423 +0,0 @@ -/* - * Device access for Dialog DA9055 PMICs. - * - * Copyright(c) 2012 Dialog Semiconductor Ltd. - * - * Author: David Dajun Chen - * - * 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 -#include -#include -#include -#include - -#include -#include -#include -#include - -#define DA9055_IRQ_NONKEY_MASK 0x01 -#define DA9055_IRQ_ALM_MASK 0x02 -#define DA9055_IRQ_TICK_MASK 0x04 -#define DA9055_IRQ_ADC_MASK 0x08 -#define DA9055_IRQ_BUCK_ILIM_MASK 0x08 - -static bool da9055_register_readable(struct device *dev, unsigned int reg) -{ - switch (reg) { - case DA9055_REG_STATUS_A: - case DA9055_REG_STATUS_B: - case DA9055_REG_EVENT_A: - case DA9055_REG_EVENT_B: - case DA9055_REG_EVENT_C: - case DA9055_REG_IRQ_MASK_A: - case DA9055_REG_IRQ_MASK_B: - case DA9055_REG_IRQ_MASK_C: - - case DA9055_REG_CONTROL_A: - case DA9055_REG_CONTROL_B: - case DA9055_REG_CONTROL_C: - case DA9055_REG_CONTROL_D: - case DA9055_REG_CONTROL_E: - - case DA9055_REG_ADC_MAN: - case DA9055_REG_ADC_CONT: - case DA9055_REG_VSYS_MON: - case DA9055_REG_ADC_RES_L: - case DA9055_REG_ADC_RES_H: - case DA9055_REG_VSYS_RES: - case DA9055_REG_ADCIN1_RES: - case DA9055_REG_ADCIN2_RES: - case DA9055_REG_ADCIN3_RES: - - case DA9055_REG_COUNT_S: - case DA9055_REG_COUNT_MI: - case DA9055_REG_COUNT_H: - case DA9055_REG_COUNT_D: - case DA9055_REG_COUNT_MO: - case DA9055_REG_COUNT_Y: - case DA9055_REG_ALARM_H: - case DA9055_REG_ALARM_D: - case DA9055_REG_ALARM_MI: - case DA9055_REG_ALARM_MO: - case DA9055_REG_ALARM_Y: - - case DA9055_REG_GPIO0_1: - case DA9055_REG_GPIO2: - case DA9055_REG_GPIO_MODE0_2: - - case DA9055_REG_BCORE_CONT: - case DA9055_REG_BMEM_CONT: - case DA9055_REG_LDO1_CONT: - case DA9055_REG_LDO2_CONT: - case DA9055_REG_LDO3_CONT: - case DA9055_REG_LDO4_CONT: - case DA9055_REG_LDO5_CONT: - case DA9055_REG_LDO6_CONT: - case DA9055_REG_BUCK_LIM: - case DA9055_REG_BCORE_MODE: - case DA9055_REG_VBCORE_A: - case DA9055_REG_VBMEM_A: - case DA9055_REG_VLDO1_A: - case DA9055_REG_VLDO2_A: - case DA9055_REG_VLDO3_A: - case DA9055_REG_VLDO4_A: - case DA9055_REG_VLDO5_A: - case DA9055_REG_VLDO6_A: - case DA9055_REG_VBCORE_B: - case DA9055_REG_VBMEM_B: - case DA9055_REG_VLDO1_B: - case DA9055_REG_VLDO2_B: - case DA9055_REG_VLDO3_B: - case DA9055_REG_VLDO4_B: - case DA9055_REG_VLDO5_B: - case DA9055_REG_VLDO6_B: - return true; - default: - return false; - } -} - -static bool da9055_register_writeable(struct device *dev, unsigned int reg) -{ - switch (reg) { - case DA9055_REG_STATUS_A: - case DA9055_REG_STATUS_B: - case DA9055_REG_EVENT_A: - case DA9055_REG_EVENT_B: - case DA9055_REG_EVENT_C: - case DA9055_REG_IRQ_MASK_A: - case DA9055_REG_IRQ_MASK_B: - case DA9055_REG_IRQ_MASK_C: - - case DA9055_REG_CONTROL_A: - case DA9055_REG_CONTROL_B: - case DA9055_REG_CONTROL_C: - case DA9055_REG_CONTROL_D: - case DA9055_REG_CONTROL_E: - - case DA9055_REG_ADC_MAN: - case DA9055_REG_ADC_CONT: - case DA9055_REG_VSYS_MON: - case DA9055_REG_ADC_RES_L: - case DA9055_REG_ADC_RES_H: - case DA9055_REG_VSYS_RES: - case DA9055_REG_ADCIN1_RES: - case DA9055_REG_ADCIN2_RES: - case DA9055_REG_ADCIN3_RES: - - case DA9055_REG_COUNT_S: - case DA9055_REG_COUNT_MI: - case DA9055_REG_COUNT_H: - case DA9055_REG_COUNT_D: - case DA9055_REG_COUNT_MO: - case DA9055_REG_COUNT_Y: - case DA9055_REG_ALARM_H: - case DA9055_REG_ALARM_D: - case DA9055_REG_ALARM_MI: - case DA9055_REG_ALARM_MO: - case DA9055_REG_ALARM_Y: - - case DA9055_REG_GPIO0_1: - case DA9055_REG_GPIO2: - case DA9055_REG_GPIO_MODE0_2: - - case DA9055_REG_BCORE_CONT: - case DA9055_REG_BMEM_CONT: - case DA9055_REG_LDO1_CONT: - case DA9055_REG_LDO2_CONT: - case DA9055_REG_LDO3_CONT: - case DA9055_REG_LDO4_CONT: - case DA9055_REG_LDO5_CONT: - case DA9055_REG_LDO6_CONT: - case DA9055_REG_BUCK_LIM: - case DA9055_REG_BCORE_MODE: - case DA9055_REG_VBCORE_A: - case DA9055_REG_VBMEM_A: - case DA9055_REG_VLDO1_A: - case DA9055_REG_VLDO2_A: - case DA9055_REG_VLDO3_A: - case DA9055_REG_VLDO4_A: - case DA9055_REG_VLDO5_A: - case DA9055_REG_VLDO6_A: - case DA9055_REG_VBCORE_B: - case DA9055_REG_VBMEM_B: - case DA9055_REG_VLDO1_B: - case DA9055_REG_VLDO2_B: - case DA9055_REG_VLDO3_B: - case DA9055_REG_VLDO4_B: - case DA9055_REG_VLDO5_B: - case DA9055_REG_VLDO6_B: - return true; - default: - return false; - } -} - -static bool da9055_register_volatile(struct device *dev, unsigned int reg) -{ - switch (reg) { - case DA9055_REG_STATUS_A: - case DA9055_REG_STATUS_B: - case DA9055_REG_EVENT_A: - case DA9055_REG_EVENT_B: - case DA9055_REG_EVENT_C: - - case DA9055_REG_CONTROL_A: - case DA9055_REG_CONTROL_E: - - case DA9055_REG_ADC_MAN: - case DA9055_REG_ADC_RES_L: - case DA9055_REG_ADC_RES_H: - case DA9055_REG_VSYS_RES: - case DA9055_REG_ADCIN1_RES: - case DA9055_REG_ADCIN2_RES: - case DA9055_REG_ADCIN3_RES: - - case DA9055_REG_COUNT_S: - case DA9055_REG_COUNT_MI: - case DA9055_REG_COUNT_H: - case DA9055_REG_COUNT_D: - case DA9055_REG_COUNT_MO: - case DA9055_REG_COUNT_Y: - case DA9055_REG_ALARM_MI: - - case DA9055_REG_BCORE_CONT: - case DA9055_REG_BMEM_CONT: - case DA9055_REG_LDO1_CONT: - case DA9055_REG_LDO2_CONT: - case DA9055_REG_LDO3_CONT: - case DA9055_REG_LDO4_CONT: - case DA9055_REG_LDO5_CONT: - case DA9055_REG_LDO6_CONT: - return true; - default: - return false; - } -} - -static struct regmap_irq da9055_irqs[] = { - [DA9055_IRQ_NONKEY] = { - .reg_offset = 0, - .mask = DA9055_IRQ_NONKEY_MASK, - }, - [DA9055_IRQ_ALARM] = { - .reg_offset = 0, - .mask = DA9055_IRQ_ALM_MASK, - }, - [DA9055_IRQ_TICK] = { - .reg_offset = 0, - .mask = DA9055_IRQ_TICK_MASK, - }, - [DA9055_IRQ_HWMON] = { - .reg_offset = 0, - .mask = DA9055_IRQ_ADC_MASK, - }, - [DA9055_IRQ_REGULATOR] = { - .reg_offset = 1, - .mask = DA9055_IRQ_BUCK_ILIM_MASK, - }, -}; - -struct regmap_config da9055_regmap_config = { - .reg_bits = 8, - .val_bits = 8, - - .cache_type = REGCACHE_RBTREE, - - .max_register = DA9055_MAX_REGISTER_CNT, - .readable_reg = da9055_register_readable, - .writeable_reg = da9055_register_writeable, - .volatile_reg = da9055_register_volatile, -}; -EXPORT_SYMBOL_GPL(da9055_regmap_config); - -static struct resource da9055_onkey_resource = { - .name = "ONKEY", - .start = DA9055_IRQ_NONKEY, - .end = DA9055_IRQ_NONKEY, - .flags = IORESOURCE_IRQ, -}; - -static struct resource da9055_rtc_resource[] = { - { - .name = "ALM", - .start = DA9055_IRQ_ALARM, - .end = DA9055_IRQ_ALARM, - .flags = IORESOURCE_IRQ, - }, - { - .name = "TICK", - .start = DA9055_IRQ_TICK, - .end = DA9055_IRQ_TICK, - .flags = IORESOURCE_IRQ, - }, -}; - -static struct resource da9055_hwmon_resource = { - .name = "HWMON", - .start = DA9055_IRQ_HWMON, - .end = DA9055_IRQ_HWMON, - .flags = IORESOURCE_IRQ, -}; - -static struct resource da9055_ld05_6_resource = { - .name = "REGULATOR", - .start = DA9055_IRQ_REGULATOR, - .end = DA9055_IRQ_REGULATOR, - .flags = IORESOURCE_IRQ, -}; - -static struct mfd_cell da9055_devs[] = { - { - .of_compatible = "dialog,da9055-gpio", - .name = "da9055-gpio", - }, - { - .of_compatible = "dialog,da9055-regulator", - .name = "da9055-regulator", - .id = 1, - }, - { - .of_compatible = "dialog,da9055-regulator", - .name = "da9055-regulator", - .id = 2, - }, - { - .of_compatible = "dialog,da9055-regulator", - .name = "da9055-regulator", - .id = 3, - }, - { - .of_compatible = "dialog,da9055-regulator", - .name = "da9055-regulator", - .id = 4, - }, - { - .of_compatible = "dialog,da9055-regulator", - .name = "da9055-regulator", - .id = 5, - }, - { - .of_compatible = "dialog,da9055-regulator", - .name = "da9055-regulator", - .id = 6, - }, - { - .of_compatible = "dialog,da9055-regulator", - .name = "da9055-regulator", - .id = 7, - .resources = &da9055_ld05_6_resource, - .num_resources = 1, - }, - { - .of_compatible = "dialog,da9055-regulator", - .name = "da9055-regulator", - .resources = &da9055_ld05_6_resource, - .num_resources = 1, - .id = 8, - }, - { - .of_compatible = "dialog,da9055-onkey", - .name = "da9055-onkey", - .resources = &da9055_onkey_resource, - .num_resources = 1, - }, - { - .of_compatible = "dialog,da9055-rtc", - .name = "da9055-rtc", - .resources = da9055_rtc_resource, - .num_resources = ARRAY_SIZE(da9055_rtc_resource), - }, - { - .of_compatible = "dialog,da9055-hwmon", - .name = "da9055-hwmon", - .resources = &da9055_hwmon_resource, - .num_resources = 1, - }, - { - .of_compatible = "dialog,da9055-watchdog", - .name = "da9055-watchdog", - }, -}; - -static struct regmap_irq_chip da9055_regmap_irq_chip = { - .name = "da9055_irq", - .status_base = DA9055_REG_EVENT_A, - .mask_base = DA9055_REG_IRQ_MASK_A, - .ack_base = DA9055_REG_EVENT_A, - .num_regs = 3, - .irqs = da9055_irqs, - .num_irqs = ARRAY_SIZE(da9055_irqs), -}; - -int __devinit da9055_device_init(struct da9055 *da9055) -{ - struct da9055_pdata *pdata = da9055->dev->platform_data; - int ret; - - if (pdata && pdata->init != NULL) - pdata->init(da9055); - - if (!pdata || !pdata->irq_base) - da9055->irq_base = -1; - else - da9055->irq_base = pdata->irq_base; - - ret = regmap_add_irq_chip(da9055->regmap, da9055->chip_irq, - IRQF_TRIGGER_HIGH | IRQF_ONESHOT, - da9055->irq_base, &da9055_regmap_irq_chip, - &da9055->irq_data); - if (ret < 0) - return ret; - - da9055->irq_base = regmap_irq_chip_get_base(da9055->irq_data); - - ret = mfd_add_devices(da9055->dev, -1, - da9055_devs, ARRAY_SIZE(da9055_devs), - NULL, da9055->irq_base, NULL); - if (ret) - goto err; - - return 0; - -err: - mfd_remove_devices(da9055->dev); - return ret; -} - -void __devexit da9055_device_exit(struct da9055 *da9055) -{ - regmap_del_irq_chip(da9055->chip_irq, da9055->irq_data); - mfd_remove_devices(da9055->dev); -} - -MODULE_DESCRIPTION("Core support for the DA9055 PMIC"); -MODULE_LICENSE("GPL"); -MODULE_AUTHOR("David Dajun Chen "); diff --git a/trunk/drivers/mfd/da9055-i2c.c b/trunk/drivers/mfd/da9055-i2c.c deleted file mode 100644 index 88f6dca53bac..000000000000 --- a/trunk/drivers/mfd/da9055-i2c.c +++ /dev/null @@ -1,93 +0,0 @@ - /* I2C access for DA9055 PMICs. - * - * Copyright(c) 2012 Dialog Semiconductor Ltd. - * - * Author: David Dajun Chen - * - * 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 -#include -#include -#include - -#include - -static int __devinit da9055_i2c_probe(struct i2c_client *i2c, - const struct i2c_device_id *id) -{ - struct da9055 *da9055; - int ret; - - da9055 = devm_kzalloc(&i2c->dev, sizeof(struct da9055), GFP_KERNEL); - if (!da9055) - return -ENOMEM; - - da9055->regmap = devm_regmap_init_i2c(i2c, &da9055_regmap_config); - if (IS_ERR(da9055->regmap)) { - ret = PTR_ERR(da9055->regmap); - dev_err(&i2c->dev, "Failed to allocate register map: %d\n", - ret); - return ret; - } - - da9055->dev = &i2c->dev; - da9055->chip_irq = i2c->irq; - - i2c_set_clientdata(i2c, da9055); - - return da9055_device_init(da9055); -} - -static int __devexit da9055_i2c_remove(struct i2c_client *i2c) -{ - struct da9055 *da9055 = i2c_get_clientdata(i2c); - - da9055_device_exit(da9055); - - return 0; -} - -static struct i2c_device_id da9055_i2c_id[] = { - {"da9055-pmic", 0}, - { } -}; - -static struct i2c_driver da9055_i2c_driver = { - .probe = da9055_i2c_probe, - .remove = __devexit_p(da9055_i2c_remove), - .id_table = da9055_i2c_id, - .driver = { - .name = "da9055", - .owner = THIS_MODULE, - }, -}; - -static int __init da9055_i2c_init(void) -{ - int ret; - - ret = i2c_add_driver(&da9055_i2c_driver); - if (ret != 0) { - pr_err("DA9055 I2C registration failed %d\n", ret); - return ret; - } - - return 0; -} -subsys_initcall(da9055_i2c_init); - -static void __exit da9055_i2c_exit(void) -{ - i2c_del_driver(&da9055_i2c_driver); -} -module_exit(da9055_i2c_exit); - -MODULE_AUTHOR("David Dajun Chen "); -MODULE_DESCRIPTION("I2C driver for Dialog DA9055 PMIC"); -MODULE_LICENSE("GPL"); diff --git a/trunk/drivers/mfd/db8500-prcmu.c b/trunk/drivers/mfd/db8500-prcmu.c index 00b8b0f3dfb6..6b67edbdbd01 100644 --- a/trunk/drivers/mfd/db8500-prcmu.c +++ b/trunk/drivers/mfd/db8500-prcmu.c @@ -270,8 +270,6 @@ static struct { struct prcmu_fw_version version; } fw_info; -static struct irq_domain *db8500_irq_domain; - /* * This vector maps irq numbers to the bits in the bit field used in * communication with the PRCMU firmware. @@ -2626,7 +2624,7 @@ static void prcmu_irq_mask(struct irq_data *d) spin_lock_irqsave(&mb0_transfer.dbb_irqs_lock, flags); - mb0_transfer.req.dbb_irqs &= ~prcmu_irq_bit[d->hwirq]; + mb0_transfer.req.dbb_irqs &= ~prcmu_irq_bit[d->irq - IRQ_PRCMU_BASE]; spin_unlock_irqrestore(&mb0_transfer.dbb_irqs_lock, flags); @@ -2640,7 +2638,7 @@ static void prcmu_irq_unmask(struct irq_data *d) spin_lock_irqsave(&mb0_transfer.dbb_irqs_lock, flags); - mb0_transfer.req.dbb_irqs |= prcmu_irq_bit[d->hwirq]; + mb0_transfer.req.dbb_irqs |= prcmu_irq_bit[d->irq - IRQ_PRCMU_BASE]; spin_unlock_irqrestore(&mb0_transfer.dbb_irqs_lock, flags); @@ -2680,37 +2678,9 @@ static char *fw_project_name(u8 project) } } -static int db8500_irq_map(struct irq_domain *d, unsigned int virq, - irq_hw_number_t hwirq) -{ - irq_set_chip_and_handler(virq, &prcmu_irq_chip, - handle_simple_irq); - set_irq_flags(virq, IRQF_VALID); - - return 0; -} - -static struct irq_domain_ops db8500_irq_ops = { - .map = db8500_irq_map, - .xlate = irq_domain_xlate_twocell, -}; - -static int db8500_irq_init(struct device_node *np) -{ - db8500_irq_domain = irq_domain_add_legacy( - np, NUM_PRCMU_WAKEUPS, IRQ_PRCMU_BASE, - 0, &db8500_irq_ops, NULL); - - if (!db8500_irq_domain) { - pr_err("Failed to create irqdomain\n"); - return -ENOSYS; - } - - return 0; -} - void __init db8500_prcmu_early_init(void) { + unsigned int i; if (cpu_is_u8500v2()) { void *tcpm_base = ioremap_nocache(U8500_PRCMU_TCPM_BASE, SZ_4K); @@ -2755,6 +2725,15 @@ void __init db8500_prcmu_early_init(void) INIT_WORK(&mb0_transfer.mask_work, prcmu_mask_work); + /* Initalize irqs. */ + for (i = 0; i < NUM_PRCMU_WAKEUPS; i++) { + unsigned int irq; + + irq = IRQ_PRCMU_BASE + i; + irq_set_chip_and_handler(irq, &prcmu_irq_chip, + handle_simple_irq); + set_irq_flags(irq, IRQF_VALID); + } compute_armss_rate(); } @@ -3062,8 +3041,6 @@ static int __devinit db8500_prcmu_probe(struct platform_device *pdev) goto no_irq_return; } - db8500_irq_init(np); - for (i = 0; i < ARRAY_SIZE(db8500_prcmu_devs); i++) { if (!strcmp(db8500_prcmu_devs[i].name, "ab8500-core")) { db8500_prcmu_devs[i].platform_data = ab8500_platdata; diff --git a/trunk/drivers/mfd/lp8788-irq.c b/trunk/drivers/mfd/lp8788-irq.c deleted file mode 100644 index c84ded5f8ece..000000000000 --- a/trunk/drivers/mfd/lp8788-irq.c +++ /dev/null @@ -1,198 +0,0 @@ -/* - * TI LP8788 MFD - interrupt handler - * - * Copyright 2012 Texas Instruments - * - * Author: Milo(Woogyom) Kim - * - * 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 -#include -#include -#include -#include -#include -#include -#include -#include - -/* register address */ -#define LP8788_INT_1 0x00 -#define LP8788_INTEN_1 0x03 - -#define BASE_INTEN_ADDR LP8788_INTEN_1 -#define SIZE_REG 8 -#define NUM_REGS 3 - -/* - * struct lp8788_irq_data - * @lp : used for accessing to lp8788 registers - * @irq_lock : mutex for enabling/disabling the interrupt - * @domain : IRQ domain for handling nested interrupt - * @enabled : status of enabled interrupt - */ -struct lp8788_irq_data { - struct lp8788 *lp; - struct mutex irq_lock; - struct irq_domain *domain; - int enabled[LP8788_INT_MAX]; -}; - -static inline u8 _irq_to_addr(enum lp8788_int_id id) -{ - return id / SIZE_REG; -} - -static inline u8 _irq_to_enable_addr(enum lp8788_int_id id) -{ - return _irq_to_addr(id) + BASE_INTEN_ADDR; -} - -static inline u8 _irq_to_mask(enum lp8788_int_id id) -{ - return 1 << (id % SIZE_REG); -} - -static inline u8 _irq_to_val(enum lp8788_int_id id, int enable) -{ - return enable << (id % SIZE_REG); -} - -static void lp8788_irq_enable(struct irq_data *data) -{ - struct lp8788_irq_data *irqd = irq_data_get_irq_chip_data(data); - irqd->enabled[data->hwirq] = 1; -} - -static void lp8788_irq_disable(struct irq_data *data) -{ - struct lp8788_irq_data *irqd = irq_data_get_irq_chip_data(data); - irqd->enabled[data->hwirq] = 0; -} - -static void lp8788_irq_bus_lock(struct irq_data *data) -{ - struct lp8788_irq_data *irqd = irq_data_get_irq_chip_data(data); - - mutex_lock(&irqd->irq_lock); -} - -static void lp8788_irq_bus_sync_unlock(struct irq_data *data) -{ - struct lp8788_irq_data *irqd = irq_data_get_irq_chip_data(data); - enum lp8788_int_id irq = data->hwirq; - u8 addr, mask, val; - - addr = _irq_to_enable_addr(irq); - mask = _irq_to_mask(irq); - val = _irq_to_val(irq, irqd->enabled[irq]); - - lp8788_update_bits(irqd->lp, addr, mask, val); - - mutex_unlock(&irqd->irq_lock); -} - -static struct irq_chip lp8788_irq_chip = { - .name = "lp8788", - .irq_enable = lp8788_irq_enable, - .irq_disable = lp8788_irq_disable, - .irq_bus_lock = lp8788_irq_bus_lock, - .irq_bus_sync_unlock = lp8788_irq_bus_sync_unlock, -}; - -static irqreturn_t lp8788_irq_handler(int irq, void *ptr) -{ - struct lp8788_irq_data *irqd = ptr; - struct lp8788 *lp = irqd->lp; - u8 status[NUM_REGS], addr, mask; - bool handled; - int i; - - if (lp8788_read_multi_bytes(lp, LP8788_INT_1, status, NUM_REGS)) - return IRQ_NONE; - - for (i = 0 ; i < LP8788_INT_MAX ; i++) { - addr = _irq_to_addr(i); - mask = _irq_to_mask(i); - - /* reporting only if the irq is enabled */ - if (status[addr] & mask) { - handle_nested_irq(irq_find_mapping(irqd->domain, i)); - handled = true; - } - } - - return handled ? IRQ_HANDLED : IRQ_NONE; -} - -static int lp8788_irq_map(struct irq_domain *d, unsigned int virq, - irq_hw_number_t hwirq) -{ - struct lp8788_irq_data *irqd = d->host_data; - struct irq_chip *chip = &lp8788_irq_chip; - - irq_set_chip_data(virq, irqd); - irq_set_chip_and_handler(virq, chip, handle_edge_irq); - irq_set_nested_thread(virq, 1); - -#ifdef CONFIG_ARM - set_irq_flags(virq, IRQF_VALID); -#else - irq_set_noprobe(virq); -#endif - - return 0; -} - -static struct irq_domain_ops lp8788_domain_ops = { - .map = lp8788_irq_map, -}; - -int lp8788_irq_init(struct lp8788 *lp, int irq) -{ - struct lp8788_irq_data *irqd; - int ret; - - if (irq <= 0) { - dev_warn(lp->dev, "invalid irq number: %d\n", irq); - return 0; - } - - irqd = devm_kzalloc(lp->dev, sizeof(*irqd), GFP_KERNEL); - if (!irqd) - return -ENOMEM; - - irqd->lp = lp; - irqd->domain = irq_domain_add_linear(lp->dev->of_node, LP8788_INT_MAX, - &lp8788_domain_ops, irqd); - if (!irqd->domain) { - dev_err(lp->dev, "failed to add irq domain err\n"); - return -EINVAL; - } - - lp->irqdm = irqd->domain; - mutex_init(&irqd->irq_lock); - - ret = request_threaded_irq(irq, NULL, lp8788_irq_handler, - IRQF_TRIGGER_FALLING | IRQF_ONESHOT, - "lp8788-irq", irqd); - if (ret) { - dev_err(lp->dev, "failed to create a thread for IRQ_N\n"); - return ret; - } - - lp->irq = irq; - - return 0; -} - -void lp8788_irq_exit(struct lp8788 *lp) -{ - if (lp->irq) - free_irq(lp->irq, lp->irqdm); -} diff --git a/trunk/drivers/mfd/lp8788.c b/trunk/drivers/mfd/lp8788.c deleted file mode 100644 index 3e94a699833c..000000000000 --- a/trunk/drivers/mfd/lp8788.c +++ /dev/null @@ -1,245 +0,0 @@ -/* - * TI LP8788 MFD - core interface - * - * Copyright 2012 Texas Instruments - * - * Author: Milo(Woogyom) Kim - * - * 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 -#include -#include -#include -#include -#include - -#define MAX_LP8788_REGISTERS 0xA2 - -#define MFD_DEV_SIMPLE(_name) \ -{ \ - .name = LP8788_DEV_##_name, \ -} - -#define MFD_DEV_WITH_ID(_name, _id) \ -{ \ - .name = LP8788_DEV_##_name, \ - .id = _id, \ -} - -#define MFD_DEV_WITH_RESOURCE(_name, _resource, num_resource) \ -{ \ - .name = LP8788_DEV_##_name, \ - .resources = _resource, \ - .num_resources = num_resource, \ -} - -static struct resource chg_irqs[] = { - /* Charger Interrupts */ - { - .start = LP8788_INT_CHG_INPUT_STATE, - .end = LP8788_INT_PRECHG_TIMEOUT, - .name = LP8788_CHG_IRQ, - .flags = IORESOURCE_IRQ, - }, - /* Power Routing Switch Interrupts */ - { - .start = LP8788_INT_ENTER_SYS_SUPPORT, - .end = LP8788_INT_EXIT_SYS_SUPPORT, - .name = LP8788_PRSW_IRQ, - .flags = IORESOURCE_IRQ, - }, - /* Battery Interrupts */ - { - .start = LP8788_INT_BATT_LOW, - .end = LP8788_INT_NO_BATT, - .name = LP8788_BATT_IRQ, - .flags = IORESOURCE_IRQ, - }, -}; - -static struct resource rtc_irqs[] = { - { - .start = LP8788_INT_RTC_ALARM1, - .end = LP8788_INT_RTC_ALARM2, - .name = LP8788_ALM_IRQ, - .flags = IORESOURCE_IRQ, - }, -}; - -static struct mfd_cell lp8788_devs[] = { - /* 4 bucks */ - MFD_DEV_WITH_ID(BUCK, 1), - MFD_DEV_WITH_ID(BUCK, 2), - MFD_DEV_WITH_ID(BUCK, 3), - MFD_DEV_WITH_ID(BUCK, 4), - - /* 12 digital ldos */ - MFD_DEV_WITH_ID(DLDO, 1), - MFD_DEV_WITH_ID(DLDO, 2), - MFD_DEV_WITH_ID(DLDO, 3), - MFD_DEV_WITH_ID(DLDO, 4), - MFD_DEV_WITH_ID(DLDO, 5), - MFD_DEV_WITH_ID(DLDO, 6), - MFD_DEV_WITH_ID(DLDO, 7), - MFD_DEV_WITH_ID(DLDO, 8), - MFD_DEV_WITH_ID(DLDO, 9), - MFD_DEV_WITH_ID(DLDO, 10), - MFD_DEV_WITH_ID(DLDO, 11), - MFD_DEV_WITH_ID(DLDO, 12), - - /* 10 analog ldos */ - MFD_DEV_WITH_ID(ALDO, 1), - MFD_DEV_WITH_ID(ALDO, 2), - MFD_DEV_WITH_ID(ALDO, 3), - MFD_DEV_WITH_ID(ALDO, 4), - MFD_DEV_WITH_ID(ALDO, 5), - MFD_DEV_WITH_ID(ALDO, 6), - MFD_DEV_WITH_ID(ALDO, 7), - MFD_DEV_WITH_ID(ALDO, 8), - MFD_DEV_WITH_ID(ALDO, 9), - MFD_DEV_WITH_ID(ALDO, 10), - - /* ADC */ - MFD_DEV_SIMPLE(ADC), - - /* battery charger */ - MFD_DEV_WITH_RESOURCE(CHARGER, chg_irqs, ARRAY_SIZE(chg_irqs)), - - /* rtc */ - MFD_DEV_WITH_RESOURCE(RTC, rtc_irqs, ARRAY_SIZE(rtc_irqs)), - - /* backlight */ - MFD_DEV_SIMPLE(BACKLIGHT), - - /* current sink for vibrator */ - MFD_DEV_SIMPLE(VIBRATOR), - - /* current sink for keypad LED */ - MFD_DEV_SIMPLE(KEYLED), -}; - -int lp8788_read_byte(struct lp8788 *lp, u8 reg, u8 *data) -{ - int ret; - unsigned int val; - - ret = regmap_read(lp->regmap, reg, &val); - if (ret < 0) { - dev_err(lp->dev, "failed to read 0x%.2x\n", reg); - return ret; - } - - *data = (u8)val; - return 0; -} -EXPORT_SYMBOL_GPL(lp8788_read_byte); - -int lp8788_read_multi_bytes(struct lp8788 *lp, u8 reg, u8 *data, size_t count) -{ - return regmap_bulk_read(lp->regmap, reg, data, count); -} -EXPORT_SYMBOL_GPL(lp8788_read_multi_bytes); - -int lp8788_write_byte(struct lp8788 *lp, u8 reg, u8 data) -{ - return regmap_write(lp->regmap, reg, data); -} -EXPORT_SYMBOL_GPL(lp8788_write_byte); - -int lp8788_update_bits(struct lp8788 *lp, u8 reg, u8 mask, u8 data) -{ - return regmap_update_bits(lp->regmap, reg, mask, data); -} -EXPORT_SYMBOL_GPL(lp8788_update_bits); - -static int lp8788_platform_init(struct lp8788 *lp) -{ - struct lp8788_platform_data *pdata = lp->pdata; - - return (pdata && pdata->init_func) ? pdata->init_func(lp) : 0; -} - -static const struct regmap_config lp8788_regmap_config = { - .reg_bits = 8, - .val_bits = 8, - .max_register = MAX_LP8788_REGISTERS, -}; - -static int lp8788_probe(struct i2c_client *cl, const struct i2c_device_id *id) -{ - struct lp8788 *lp; - struct lp8788_platform_data *pdata = cl->dev.platform_data; - int ret; - - lp = devm_kzalloc(&cl->dev, sizeof(struct lp8788), GFP_KERNEL); - if (!lp) - return -ENOMEM; - - lp->regmap = devm_regmap_init_i2c(cl, &lp8788_regmap_config); - if (IS_ERR(lp->regmap)) { - ret = PTR_ERR(lp->regmap); - dev_err(&cl->dev, "regmap init i2c err: %d\n", ret); - return ret; - } - - lp->pdata = pdata; - lp->dev = &cl->dev; - i2c_set_clientdata(cl, lp); - - ret = lp8788_platform_init(lp); - if (ret) - return ret; - - ret = lp8788_irq_init(lp, cl->irq); - if (ret) - return ret; - - return mfd_add_devices(lp->dev, -1, lp8788_devs, - ARRAY_SIZE(lp8788_devs), NULL, 0, NULL); -} - -static int __devexit lp8788_remove(struct i2c_client *cl) -{ - struct lp8788 *lp = i2c_get_clientdata(cl); - - mfd_remove_devices(lp->dev); - lp8788_irq_exit(lp); - return 0; -} - -static const struct i2c_device_id lp8788_ids[] = { - {"lp8788", 0}, - { } -}; -MODULE_DEVICE_TABLE(i2c, lp8788_ids); - -static struct i2c_driver lp8788_driver = { - .driver = { - .name = "lp8788", - .owner = THIS_MODULE, - }, - .probe = lp8788_probe, - .remove = __devexit_p(lp8788_remove), - .id_table = lp8788_ids, -}; - -static int __init lp8788_init(void) -{ - return i2c_add_driver(&lp8788_driver); -} -subsys_initcall(lp8788_init); - -static void __exit lp8788_exit(void) -{ - i2c_del_driver(&lp8788_driver); -} -module_exit(lp8788_exit); - -MODULE_DESCRIPTION("TI LP8788 MFD Driver"); -MODULE_AUTHOR("Milo Kim"); -MODULE_LICENSE("GPL"); diff --git a/trunk/drivers/mfd/lpc_ich.c b/trunk/drivers/mfd/lpc_ich.c index a22544fe5319..092ad4b44b6d 100644 --- a/trunk/drivers/mfd/lpc_ich.c +++ b/trunk/drivers/mfd/lpc_ich.c @@ -49,7 +49,6 @@ * document number TBD : DH89xxCC * document number TBD : Panther Point * document number TBD : Lynx Point - * document number TBD : Lynx Point-LP */ #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt @@ -193,7 +192,6 @@ enum lpc_chipsets { LPC_DH89XXCC, /* DH89xxCC */ LPC_PPT, /* Panther Point */ LPC_LPT, /* Lynx Point */ - LPC_LPT_LP, /* Lynx Point-LP */ }; struct lpc_ich_info lpc_chipset_info[] __devinitdata = { @@ -470,10 +468,6 @@ struct lpc_ich_info lpc_chipset_info[] __devinitdata = { .name = "Lynx Point", .iTCO_version = 2, }, - [LPC_LPT_LP] = { - .name = "Lynx Point_LP", - .iTCO_version = 2, - }, }; /* @@ -647,14 +641,6 @@ static DEFINE_PCI_DEVICE_TABLE(lpc_ich_ids) = { { PCI_VDEVICE(INTEL, 0x8c5d), LPC_LPT}, { PCI_VDEVICE(INTEL, 0x8c5e), LPC_LPT}, { PCI_VDEVICE(INTEL, 0x8c5f), LPC_LPT}, - { PCI_VDEVICE(INTEL, 0x9c40), LPC_LPT_LP}, - { PCI_VDEVICE(INTEL, 0x9c41), LPC_LPT_LP}, - { PCI_VDEVICE(INTEL, 0x9c42), LPC_LPT_LP}, - { PCI_VDEVICE(INTEL, 0x9c43), LPC_LPT_LP}, - { PCI_VDEVICE(INTEL, 0x9c44), LPC_LPT_LP}, - { PCI_VDEVICE(INTEL, 0x9c45), LPC_LPT_LP}, - { PCI_VDEVICE(INTEL, 0x9c46), LPC_LPT_LP}, - { PCI_VDEVICE(INTEL, 0x9c47), LPC_LPT_LP}, { 0, }, /* End of list */ }; MODULE_DEVICE_TABLE(pci, lpc_ich_ids); @@ -697,30 +683,6 @@ static void __devinit lpc_ich_finalize_cell(struct mfd_cell *cell, cell->pdata_size = sizeof(struct lpc_ich_info); } -/* - * We don't check for resource conflict globally. There are 2 or 3 independent - * GPIO groups and it's enough to have access to one of these to instantiate - * the device. - */ -static int __devinit lpc_ich_check_conflict_gpio(struct resource *res) -{ - int ret; - u8 use_gpio = 0; - - if (resource_size(res) >= 0x50 && - !acpi_check_region(res->start + 0x40, 0x10, "LPC ICH GPIO3")) - use_gpio |= 1 << 2; - - if (!acpi_check_region(res->start + 0x30, 0x10, "LPC ICH GPIO2")) - use_gpio |= 1 << 1; - - ret = acpi_check_region(res->start + 0x00, 0x30, "LPC ICH GPIO1"); - if (!ret) - use_gpio |= 1 << 0; - - return use_gpio ? use_gpio : ret; -} - static int __devinit lpc_ich_init_gpio(struct pci_dev *dev, const struct pci_device_id *id) { @@ -778,13 +740,12 @@ static int __devinit lpc_ich_init_gpio(struct pci_dev *dev, break; } - ret = lpc_ich_check_conflict_gpio(res); - if (ret < 0) { + ret = acpi_check_resource_conflict(res); + if (ret) { /* this isn't necessarily fatal for the GPIO */ acpi_conflict = true; goto gpio_done; } - lpc_chipset_info[id->driver_data].use_gpio = ret; lpc_ich_enable_gpio_space(dev); lpc_ich_finalize_cell(&lpc_ich_cells[LPC_GPIO], id); diff --git a/trunk/drivers/mfd/max8907.c b/trunk/drivers/mfd/max8907.c deleted file mode 100644 index 17f2593d82b8..000000000000 --- a/trunk/drivers/mfd/max8907.c +++ /dev/null @@ -1,351 +0,0 @@ -/* - * max8907.c - mfd driver for MAX8907 - * - * Copyright (C) 2010 Gyungoh Yoo - * Copyright (C) 2010-2012, NVIDIA CORPORATION. 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 version 2 as - * published by the Free Software Foundation. - */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -static struct mfd_cell max8907_cells[] = { - { .name = "max8907-regulator", }, - { .name = "max8907-rtc", }, -}; - -static bool max8907_gen_is_volatile_reg(struct device *dev, unsigned int reg) -{ - switch (reg) { - case MAX8907_REG_ON_OFF_IRQ1: - case MAX8907_REG_ON_OFF_STAT: - case MAX8907_REG_ON_OFF_IRQ2: - case MAX8907_REG_CHG_IRQ1: - case MAX8907_REG_CHG_IRQ2: - case MAX8907_REG_CHG_STAT: - return true; - default: - return false; - } -} - -static bool max8907_gen_is_precious_reg(struct device *dev, unsigned int reg) -{ - switch (reg) { - case MAX8907_REG_ON_OFF_IRQ1: - case MAX8907_REG_ON_OFF_IRQ2: - case MAX8907_REG_CHG_IRQ1: - case MAX8907_REG_CHG_IRQ2: - return true; - default: - return false; - } -} - -static bool max8907_gen_is_writeable_reg(struct device *dev, unsigned int reg) -{ - return !max8907_gen_is_volatile_reg(dev, reg); -} - -static const struct regmap_config max8907_regmap_gen_config = { - .reg_bits = 8, - .val_bits = 8, - .volatile_reg = max8907_gen_is_volatile_reg, - .precious_reg = max8907_gen_is_precious_reg, - .writeable_reg = max8907_gen_is_writeable_reg, - .max_register = MAX8907_REG_LDO20VOUT, - .cache_type = REGCACHE_RBTREE, -}; - -static bool max8907_rtc_is_volatile_reg(struct device *dev, unsigned int reg) -{ - if (reg <= MAX8907_REG_RTC_YEAR2) - return true; - - switch (reg) { - case MAX8907_REG_RTC_STATUS: - case MAX8907_REG_RTC_IRQ: - return true; - default: - return false; - } -} - -static bool max8907_rtc_is_precious_reg(struct device *dev, unsigned int reg) -{ - switch (reg) { - case MAX8907_REG_RTC_IRQ: - return true; - default: - return false; - } -} - -static bool max8907_rtc_is_writeable_reg(struct device *dev, unsigned int reg) -{ - switch (reg) { - case MAX8907_REG_RTC_STATUS: - case MAX8907_REG_RTC_IRQ: - return false; - default: - return true; - } -} - -static const struct regmap_config max8907_regmap_rtc_config = { - .reg_bits = 8, - .val_bits = 8, - .volatile_reg = max8907_rtc_is_volatile_reg, - .precious_reg = max8907_rtc_is_precious_reg, - .writeable_reg = max8907_rtc_is_writeable_reg, - .max_register = MAX8907_REG_MPL_CNTL, - .cache_type = REGCACHE_RBTREE, -}; - -static const struct regmap_irq max8907_chg_irqs[] = { - { .reg_offset = 0, .mask = 1 << 0, }, - { .reg_offset = 0, .mask = 1 << 1, }, - { .reg_offset = 0, .mask = 1 << 2, }, - { .reg_offset = 1, .mask = 1 << 0, }, - { .reg_offset = 1, .mask = 1 << 1, }, - { .reg_offset = 1, .mask = 1 << 2, }, - { .reg_offset = 1, .mask = 1 << 3, }, - { .reg_offset = 1, .mask = 1 << 4, }, - { .reg_offset = 1, .mask = 1 << 5, }, - { .reg_offset = 1, .mask = 1 << 6, }, - { .reg_offset = 1, .mask = 1 << 7, }, -}; - -static const struct regmap_irq_chip max8907_chg_irq_chip = { - .name = "max8907 chg", - .status_base = MAX8907_REG_CHG_IRQ1, - .mask_base = MAX8907_REG_CHG_IRQ1_MASK, - .wake_base = MAX8907_REG_CHG_IRQ1_MASK, - .irq_reg_stride = MAX8907_REG_CHG_IRQ2 - MAX8907_REG_CHG_IRQ1, - .num_regs = 2, - .irqs = max8907_chg_irqs, - .num_irqs = ARRAY_SIZE(max8907_chg_irqs), -}; - -static const struct regmap_irq max8907_on_off_irqs[] = { - { .reg_offset = 0, .mask = 1 << 0, }, - { .reg_offset = 0, .mask = 1 << 1, }, - { .reg_offset = 0, .mask = 1 << 2, }, - { .reg_offset = 0, .mask = 1 << 3, }, - { .reg_offset = 0, .mask = 1 << 4, }, - { .reg_offset = 0, .mask = 1 << 5, }, - { .reg_offset = 0, .mask = 1 << 6, }, - { .reg_offset = 0, .mask = 1 << 7, }, - { .reg_offset = 1, .mask = 1 << 0, }, - { .reg_offset = 1, .mask = 1 << 1, }, -}; - -static const struct regmap_irq_chip max8907_on_off_irq_chip = { - .name = "max8907 on_off", - .status_base = MAX8907_REG_ON_OFF_IRQ1, - .mask_base = MAX8907_REG_ON_OFF_IRQ1_MASK, - .irq_reg_stride = MAX8907_REG_ON_OFF_IRQ2 - MAX8907_REG_ON_OFF_IRQ1, - .num_regs = 2, - .irqs = max8907_on_off_irqs, - .num_irqs = ARRAY_SIZE(max8907_on_off_irqs), -}; - -static const struct regmap_irq max8907_rtc_irqs[] = { - { .reg_offset = 0, .mask = 1 << 2, }, - { .reg_offset = 0, .mask = 1 << 3, }, -}; - -static const struct regmap_irq_chip max8907_rtc_irq_chip = { - .name = "max8907 rtc", - .status_base = MAX8907_REG_RTC_IRQ, - .mask_base = MAX8907_REG_RTC_IRQ_MASK, - .num_regs = 1, - .irqs = max8907_rtc_irqs, - .num_irqs = ARRAY_SIZE(max8907_rtc_irqs), -}; - -static struct max8907 *max8907_pm_off; -static void max8907_power_off(void) -{ - regmap_update_bits(max8907_pm_off->regmap_gen, MAX8907_REG_RESET_CNFG, - MAX8907_MASK_POWER_OFF, MAX8907_MASK_POWER_OFF); -} - -static __devinit int max8907_i2c_probe(struct i2c_client *i2c, - const struct i2c_device_id *id) -{ - struct max8907 *max8907; - int ret; - struct max8907_platform_data *pdata = dev_get_platdata(&i2c->dev); - bool pm_off = false; - - if (pdata) - pm_off = pdata->pm_off; - else if (i2c->dev.of_node) - pm_off = of_property_read_bool(i2c->dev.of_node, - "maxim,system-power-controller"); - - max8907 = devm_kzalloc(&i2c->dev, sizeof(struct max8907), GFP_KERNEL); - if (!max8907) { - ret = -ENOMEM; - goto err_alloc_drvdata; - } - - max8907->dev = &i2c->dev; - dev_set_drvdata(max8907->dev, max8907); - - max8907->i2c_gen = i2c; - i2c_set_clientdata(i2c, max8907); - max8907->regmap_gen = devm_regmap_init_i2c(i2c, - &max8907_regmap_gen_config); - if (IS_ERR(max8907->regmap_gen)) { - ret = PTR_ERR(max8907->regmap_gen); - dev_err(&i2c->dev, "gen regmap init failed: %d\n", ret); - goto err_regmap_gen; - } - - max8907->i2c_rtc = i2c_new_dummy(i2c->adapter, MAX8907_RTC_I2C_ADDR); - if (!max8907->i2c_rtc) { - ret = -ENOMEM; - goto err_dummy_rtc; - } - i2c_set_clientdata(max8907->i2c_rtc, max8907); - max8907->regmap_rtc = devm_regmap_init_i2c(max8907->i2c_rtc, - &max8907_regmap_rtc_config); - if (IS_ERR(max8907->regmap_rtc)) { - ret = PTR_ERR(max8907->regmap_rtc); - dev_err(&i2c->dev, "rtc regmap init failed: %d\n", ret); - goto err_regmap_rtc; - } - - irq_set_status_flags(max8907->i2c_gen->irq, IRQ_NOAUTOEN); - - ret = regmap_add_irq_chip(max8907->regmap_gen, max8907->i2c_gen->irq, - IRQF_ONESHOT | IRQF_SHARED, -1, - &max8907_chg_irq_chip, - &max8907->irqc_chg); - if (ret != 0) { - dev_err(&i2c->dev, "failed to add chg irq chip: %d\n", ret); - goto err_irqc_chg; - } - ret = regmap_add_irq_chip(max8907->regmap_gen, max8907->i2c_gen->irq, - IRQF_ONESHOT | IRQF_SHARED, -1, - &max8907_on_off_irq_chip, - &max8907->irqc_on_off); - if (ret != 0) { - dev_err(&i2c->dev, "failed to add on off irq chip: %d\n", ret); - goto err_irqc_on_off; - } - ret = regmap_add_irq_chip(max8907->regmap_rtc, max8907->i2c_gen->irq, - IRQF_ONESHOT | IRQF_SHARED, -1, - &max8907_rtc_irq_chip, - &max8907->irqc_rtc); - if (ret != 0) { - dev_err(&i2c->dev, "failed to add rtc irq chip: %d\n", ret); - goto err_irqc_rtc; - } - - enable_irq(max8907->i2c_gen->irq); - - ret = mfd_add_devices(max8907->dev, -1, max8907_cells, - ARRAY_SIZE(max8907_cells), NULL, 0, NULL); - if (ret != 0) { - dev_err(&i2c->dev, "failed to add MFD devices %d\n", ret); - goto err_add_devices; - } - - if (pm_off && !pm_power_off) { - max8907_pm_off = max8907; - pm_power_off = max8907_power_off; - } - - return 0; - -err_add_devices: - regmap_del_irq_chip(max8907->i2c_gen->irq, max8907->irqc_rtc); -err_irqc_rtc: - regmap_del_irq_chip(max8907->i2c_gen->irq, max8907->irqc_on_off); -err_irqc_on_off: - regmap_del_irq_chip(max8907->i2c_gen->irq, max8907->irqc_chg); -err_irqc_chg: -err_regmap_rtc: - i2c_unregister_device(max8907->i2c_rtc); -err_dummy_rtc: -err_regmap_gen: -err_alloc_drvdata: - return ret; -} - -static __devexit int max8907_i2c_remove(struct i2c_client *i2c) -{ - struct max8907 *max8907 = i2c_get_clientdata(i2c); - - mfd_remove_devices(max8907->dev); - - regmap_del_irq_chip(max8907->i2c_gen->irq, max8907->irqc_rtc); - regmap_del_irq_chip(max8907->i2c_gen->irq, max8907->irqc_on_off); - regmap_del_irq_chip(max8907->i2c_gen->irq, max8907->irqc_chg); - - i2c_unregister_device(max8907->i2c_rtc); - - return 0; -} - -#ifdef CONFIG_OF -static struct of_device_id max8907_of_match[] = { - { .compatible = "maxim,max8907" }, - { }, -}; -MODULE_DEVICE_TABLE(of, max8907_of_match); -#endif - -static const struct i2c_device_id max8907_i2c_id[] = { - {"max8907", 0}, - {} -}; -MODULE_DEVICE_TABLE(i2c, max8907_i2c_id); - -static struct i2c_driver max8907_i2c_driver = { - .driver = { - .name = "max8907", - .owner = THIS_MODULE, - .of_match_table = of_match_ptr(max8907_of_match), - }, - .probe = max8907_i2c_probe, - .remove = max8907_i2c_remove, - .id_table = max8907_i2c_id, -}; - -static int __init max8907_i2c_init(void) -{ - int ret = -ENODEV; - - ret = i2c_add_driver(&max8907_i2c_driver); - if (ret != 0) - pr_err("Failed to register I2C driver: %d\n", ret); - - return ret; -} -subsys_initcall(max8907_i2c_init); - -static void __exit max8907_i2c_exit(void) -{ - i2c_del_driver(&max8907_i2c_driver); -} -module_exit(max8907_i2c_exit); - -MODULE_DESCRIPTION("MAX8907 multi-function core driver"); -MODULE_AUTHOR("Gyungoh Yoo "); -MODULE_LICENSE("GPL v2"); diff --git a/trunk/drivers/mfd/max8925-core.c b/trunk/drivers/mfd/max8925-core.c index 9f54c04912f2..ee53757beca7 100644 --- a/trunk/drivers/mfd/max8925-core.c +++ b/trunk/drivers/mfd/max8925-core.c @@ -15,20 +15,23 @@ #include #include #include -#include #include #include -static struct resource bk_resources[] __devinitdata = { - { 0x84, 0x84, "mode control", IORESOURCE_REG, }, - { 0x85, 0x85, "control", IORESOURCE_REG, }, +static struct resource backlight_resources[] = { + { + .name = "max8925-backlight", + .start = MAX8925_WLED_MODE_CNTL, + .end = MAX8925_WLED_CNTL, + .flags = IORESOURCE_IO, + }, }; -static struct mfd_cell bk_devs[] __devinitdata = { +static struct mfd_cell backlight_devs[] = { { .name = "max8925-backlight", - .num_resources = ARRAY_SIZE(bk_resources), - .resources = &bk_resources[0], + .num_resources = 1, + .resources = &backlight_resources[0], .id = -1, }, }; @@ -38,7 +41,7 @@ static struct resource touch_resources[] = { .name = "max8925-tsc", .start = MAX8925_TSC_IRQ, .end = MAX8925_ADC_RES_END, - .flags = IORESOURCE_REG, + .flags = IORESOURCE_IO, }, }; @@ -56,7 +59,7 @@ static struct resource power_supply_resources[] = { .name = "max8925-power", .start = MAX8925_CHG_IRQ1, .end = MAX8925_CHG_IRQ1_MASK, - .flags = IORESOURCE_REG, + .flags = IORESOURCE_IO, }, }; @@ -110,215 +113,71 @@ static struct mfd_cell onkey_devs[] = { }, }; -static struct resource sd1_resources[] __devinitdata = { - {0x06, 0x06, "sdv", IORESOURCE_REG, }, -}; - -static struct resource sd2_resources[] __devinitdata = { - {0x09, 0x09, "sdv", IORESOURCE_REG, }, -}; - -static struct resource sd3_resources[] __devinitdata = { - {0x0c, 0x0c, "sdv", IORESOURCE_REG, }, -}; - -static struct resource ldo1_resources[] __devinitdata = { - {0x1a, 0x1a, "ldov", IORESOURCE_REG, }, -}; - -static struct resource ldo2_resources[] __devinitdata = { - {0x1e, 0x1e, "ldov", IORESOURCE_REG, }, -}; - -static struct resource ldo3_resources[] __devinitdata = { - {0x22, 0x22, "ldov", IORESOURCE_REG, }, -}; - -static struct resource ldo4_resources[] __devinitdata = { - {0x26, 0x26, "ldov", IORESOURCE_REG, }, -}; - -static struct resource ldo5_resources[] __devinitdata = { - {0x2a, 0x2a, "ldov", IORESOURCE_REG, }, -}; - -static struct resource ldo6_resources[] __devinitdata = { - {0x2e, 0x2e, "ldov", IORESOURCE_REG, }, -}; - -static struct resource ldo7_resources[] __devinitdata = { - {0x32, 0x32, "ldov", IORESOURCE_REG, }, -}; - -static struct resource ldo8_resources[] __devinitdata = { - {0x36, 0x36, "ldov", IORESOURCE_REG, }, -}; - -static struct resource ldo9_resources[] __devinitdata = { - {0x3a, 0x3a, "ldov", IORESOURCE_REG, }, -}; - -static struct resource ldo10_resources[] __devinitdata = { - {0x3e, 0x3e, "ldov", IORESOURCE_REG, }, -}; - -static struct resource ldo11_resources[] __devinitdata = { - {0x42, 0x42, "ldov", IORESOURCE_REG, }, -}; - -static struct resource ldo12_resources[] __devinitdata = { - {0x46, 0x46, "ldov", IORESOURCE_REG, }, -}; - -static struct resource ldo13_resources[] __devinitdata = { - {0x4a, 0x4a, "ldov", IORESOURCE_REG, }, -}; - -static struct resource ldo14_resources[] __devinitdata = { - {0x4e, 0x4e, "ldov", IORESOURCE_REG, }, -}; - -static struct resource ldo15_resources[] __devinitdata = { - {0x52, 0x52, "ldov", IORESOURCE_REG, }, -}; - -static struct resource ldo16_resources[] __devinitdata = { - {0x12, 0x12, "ldov", IORESOURCE_REG, }, -}; - -static struct resource ldo17_resources[] __devinitdata = { - {0x16, 0x16, "ldov", IORESOURCE_REG, }, -}; - -static struct resource ldo18_resources[] __devinitdata = { - {0x74, 0x74, "ldov", IORESOURCE_REG, }, -}; +#define MAX8925_REG_RESOURCE(_start, _end) \ +{ \ + .start = MAX8925_##_start, \ + .end = MAX8925_##_end, \ + .flags = IORESOURCE_IO, \ +} -static struct resource ldo19_resources[] __devinitdata = { - {0x5e, 0x5e, "ldov", IORESOURCE_REG, }, -}; +static struct resource regulator_resources[] = { + MAX8925_REG_RESOURCE(SDCTL1, SDCTL1), + MAX8925_REG_RESOURCE(SDCTL2, SDCTL2), + MAX8925_REG_RESOURCE(SDCTL3, SDCTL3), + MAX8925_REG_RESOURCE(LDOCTL1, LDOCTL1), + MAX8925_REG_RESOURCE(LDOCTL2, LDOCTL2), + MAX8925_REG_RESOURCE(LDOCTL3, LDOCTL3), + MAX8925_REG_RESOURCE(LDOCTL4, LDOCTL4), + MAX8925_REG_RESOURCE(LDOCTL5, LDOCTL5), + MAX8925_REG_RESOURCE(LDOCTL6, LDOCTL6), + MAX8925_REG_RESOURCE(LDOCTL7, LDOCTL7), + MAX8925_REG_RESOURCE(LDOCTL8, LDOCTL8), + MAX8925_REG_RESOURCE(LDOCTL9, LDOCTL9), + MAX8925_REG_RESOURCE(LDOCTL10, LDOCTL10), + MAX8925_REG_RESOURCE(LDOCTL11, LDOCTL11), + MAX8925_REG_RESOURCE(LDOCTL12, LDOCTL12), + MAX8925_REG_RESOURCE(LDOCTL13, LDOCTL13), + MAX8925_REG_RESOURCE(LDOCTL14, LDOCTL14), + MAX8925_REG_RESOURCE(LDOCTL15, LDOCTL15), + MAX8925_REG_RESOURCE(LDOCTL16, LDOCTL16), + MAX8925_REG_RESOURCE(LDOCTL17, LDOCTL17), + MAX8925_REG_RESOURCE(LDOCTL18, LDOCTL18), + MAX8925_REG_RESOURCE(LDOCTL19, LDOCTL19), + MAX8925_REG_RESOURCE(LDOCTL20, LDOCTL20), +}; + +#define MAX8925_REG_DEVS(_id) \ +{ \ + .name = "max8925-regulator", \ + .num_resources = 1, \ + .resources = ®ulator_resources[MAX8925_ID_##_id], \ + .id = MAX8925_ID_##_id, \ +} -static struct resource ldo20_resources[] __devinitdata = { - {0x9e, 0x9e, "ldov", IORESOURCE_REG, }, -}; - -static struct mfd_cell reg_devs[] __devinitdata = { - { - .name = "max8925-regulator", - .id = 0, - .num_resources = ARRAY_SIZE(sd1_resources), - .resources = sd1_resources, - }, { - .name = "max8925-regulator", - .id = 1, - .num_resources = ARRAY_SIZE(sd2_resources), - .resources = sd2_resources, - }, { - .name = "max8925-regulator", - .id = 2, - .num_resources = ARRAY_SIZE(sd3_resources), - .resources = sd3_resources, - }, { - .name = "max8925-regulator", - .id = 3, - .num_resources = ARRAY_SIZE(ldo1_resources), - .resources = ldo1_resources, - }, { - .name = "max8925-regulator", - .id = 4, - .num_resources = ARRAY_SIZE(ldo2_resources), - .resources = ldo2_resources, - }, { - .name = "max8925-regulator", - .id = 5, - .num_resources = ARRAY_SIZE(ldo3_resources), - .resources = ldo3_resources, - }, { - .name = "max8925-regulator", - .id = 6, - .num_resources = ARRAY_SIZE(ldo4_resources), - .resources = ldo4_resources, - }, { - .name = "max8925-regulator", - .id = 7, - .num_resources = ARRAY_SIZE(ldo5_resources), - .resources = ldo5_resources, - }, { - .name = "max8925-regulator", - .id = 8, - .num_resources = ARRAY_SIZE(ldo6_resources), - .resources = ldo6_resources, - }, { - .name = "max8925-regulator", - .id = 9, - .num_resources = ARRAY_SIZE(ldo7_resources), - .resources = ldo7_resources, - }, { - .name = "max8925-regulator", - .id = 10, - .num_resources = ARRAY_SIZE(ldo8_resources), - .resources = ldo8_resources, - }, { - .name = "max8925-regulator", - .id = 11, - .num_resources = ARRAY_SIZE(ldo9_resources), - .resources = ldo9_resources, - }, { - .name = "max8925-regulator", - .id = 12, - .num_resources = ARRAY_SIZE(ldo10_resources), - .resources = ldo10_resources, - }, { - .name = "max8925-regulator", - .id = 13, - .num_resources = ARRAY_SIZE(ldo11_resources), - .resources = ldo11_resources, - }, { - .name = "max8925-regulator", - .id = 14, - .num_resources = ARRAY_SIZE(ldo12_resources), - .resources = ldo12_resources, - }, { - .name = "max8925-regulator", - .id = 15, - .num_resources = ARRAY_SIZE(ldo13_resources), - .resources = ldo13_resources, - }, { - .name = "max8925-regulator", - .id = 16, - .num_resources = ARRAY_SIZE(ldo14_resources), - .resources = ldo14_resources, - }, { - .name = "max8925-regulator", - .id = 17, - .num_resources = ARRAY_SIZE(ldo15_resources), - .resources = ldo15_resources, - }, { - .name = "max8925-regulator", - .id = 18, - .num_resources = ARRAY_SIZE(ldo16_resources), - .resources = ldo16_resources, - }, { - .name = "max8925-regulator", - .id = 19, - .num_resources = ARRAY_SIZE(ldo17_resources), - .resources = ldo17_resources, - }, { - .name = "max8925-regulator", - .id = 20, - .num_resources = ARRAY_SIZE(ldo18_resources), - .resources = ldo18_resources, - }, { - .name = "max8925-regulator", - .id = 21, - .num_resources = ARRAY_SIZE(ldo19_resources), - .resources = ldo19_resources, - }, { - .name = "max8925-regulator", - .id = 22, - .num_resources = ARRAY_SIZE(ldo20_resources), - .resources = ldo20_resources, - }, +static struct mfd_cell regulator_devs[] = { + MAX8925_REG_DEVS(SD1), + MAX8925_REG_DEVS(SD2), + MAX8925_REG_DEVS(SD3), + MAX8925_REG_DEVS(LDO1), + MAX8925_REG_DEVS(LDO2), + MAX8925_REG_DEVS(LDO3), + MAX8925_REG_DEVS(LDO4), + MAX8925_REG_DEVS(LDO5), + MAX8925_REG_DEVS(LDO6), + MAX8925_REG_DEVS(LDO7), + MAX8925_REG_DEVS(LDO8), + MAX8925_REG_DEVS(LDO9), + MAX8925_REG_DEVS(LDO10), + MAX8925_REG_DEVS(LDO11), + MAX8925_REG_DEVS(LDO12), + MAX8925_REG_DEVS(LDO13), + MAX8925_REG_DEVS(LDO14), + MAX8925_REG_DEVS(LDO15), + MAX8925_REG_DEVS(LDO16), + MAX8925_REG_DEVS(LDO17), + MAX8925_REG_DEVS(LDO18), + MAX8925_REG_DEVS(LDO19), + MAX8925_REG_DEVS(LDO20), }; enum { @@ -688,7 +547,7 @@ static int max8925_irq_init(struct max8925_chip *chip, int irq, goto tsc_irq; } - ret = request_threaded_irq(irq, NULL, max8925_irq, flags | IRQF_ONESHOT, + ret = request_threaded_irq(irq, NULL, max8925_irq, flags, "max8925", chip); if (ret) { dev_err(chip->dev, "Failed to request core IRQ: %d\n", ret); @@ -706,7 +565,7 @@ static int max8925_irq_init(struct max8925_chip *chip, int irq, chip->tsc_irq = pdata->tsc_irq; ret = request_threaded_irq(chip->tsc_irq, NULL, max8925_tsc_irq, - flags | IRQF_ONESHOT, "max8925-tsc", chip); + flags, "max8925-tsc", chip); if (ret) { dev_err(chip->dev, "Failed to request TSC IRQ: %d\n", ret); chip->tsc_irq = 0; @@ -714,113 +573,6 @@ static int max8925_irq_init(struct max8925_chip *chip, int irq, return 0; } -static void __devinit init_regulator(struct max8925_chip *chip, - struct max8925_platform_data *pdata) -{ - int ret; - - if (!pdata) - return; - if (pdata->sd1) { - reg_devs[0].platform_data = pdata->sd1; - reg_devs[0].pdata_size = sizeof(struct regulator_init_data); - } - if (pdata->sd2) { - reg_devs[1].platform_data = pdata->sd2; - reg_devs[1].pdata_size = sizeof(struct regulator_init_data); - } - if (pdata->sd3) { - reg_devs[2].platform_data = pdata->sd3; - reg_devs[2].pdata_size = sizeof(struct regulator_init_data); - } - if (pdata->ldo1) { - reg_devs[3].platform_data = pdata->ldo1; - reg_devs[3].pdata_size = sizeof(struct regulator_init_data); - } - if (pdata->ldo2) { - reg_devs[4].platform_data = pdata->ldo2; - reg_devs[4].pdata_size = sizeof(struct regulator_init_data); - } - if (pdata->ldo3) { - reg_devs[5].platform_data = pdata->ldo3; - reg_devs[5].pdata_size = sizeof(struct regulator_init_data); - } - if (pdata->ldo4) { - reg_devs[6].platform_data = pdata->ldo4; - reg_devs[6].pdata_size = sizeof(struct regulator_init_data); - } - if (pdata->ldo5) { - reg_devs[7].platform_data = pdata->ldo5; - reg_devs[7].pdata_size = sizeof(struct regulator_init_data); - } - if (pdata->ldo6) { - reg_devs[8].platform_data = pdata->ldo6; - reg_devs[8].pdata_size = sizeof(struct regulator_init_data); - } - if (pdata->ldo7) { - reg_devs[9].platform_data = pdata->ldo7; - reg_devs[9].pdata_size = sizeof(struct regulator_init_data); - } - if (pdata->ldo8) { - reg_devs[10].platform_data = pdata->ldo8; - reg_devs[10].pdata_size = sizeof(struct regulator_init_data); - } - if (pdata->ldo9) { - reg_devs[11].platform_data = pdata->ldo9; - reg_devs[11].pdata_size = sizeof(struct regulator_init_data); - } - if (pdata->ldo10) { - reg_devs[12].platform_data = pdata->ldo10; - reg_devs[12].pdata_size = sizeof(struct regulator_init_data); - } - if (pdata->ldo11) { - reg_devs[13].platform_data = pdata->ldo11; - reg_devs[13].pdata_size = sizeof(struct regulator_init_data); - } - if (pdata->ldo12) { - reg_devs[14].platform_data = pdata->ldo12; - reg_devs[14].pdata_size = sizeof(struct regulator_init_data); - } - if (pdata->ldo13) { - reg_devs[15].platform_data = pdata->ldo13; - reg_devs[15].pdata_size = sizeof(struct regulator_init_data); - } - if (pdata->ldo14) { - reg_devs[16].platform_data = pdata->ldo14; - reg_devs[16].pdata_size = sizeof(struct regulator_init_data); - } - if (pdata->ldo15) { - reg_devs[17].platform_data = pdata->ldo15; - reg_devs[17].pdata_size = sizeof(struct regulator_init_data); - } - if (pdata->ldo16) { - reg_devs[18].platform_data = pdata->ldo16; - reg_devs[18].pdata_size = sizeof(struct regulator_init_data); - } - if (pdata->ldo17) { - reg_devs[19].platform_data = pdata->ldo17; - reg_devs[19].pdata_size = sizeof(struct regulator_init_data); - } - if (pdata->ldo18) { - reg_devs[20].platform_data = pdata->ldo18; - reg_devs[20].pdata_size = sizeof(struct regulator_init_data); - } - if (pdata->ldo19) { - reg_devs[21].platform_data = pdata->ldo19; - reg_devs[21].pdata_size = sizeof(struct regulator_init_data); - } - if (pdata->ldo20) { - reg_devs[22].platform_data = pdata->ldo20; - reg_devs[22].pdata_size = sizeof(struct regulator_init_data); - } - ret = mfd_add_devices(chip->dev, 0, reg_devs, ARRAY_SIZE(reg_devs), - NULL, 0, NULL); - if (ret < 0) { - dev_err(chip->dev, "Failed to add regulator subdev\n"); - return; - } -} - int __devinit max8925_device_init(struct max8925_chip *chip, struct max8925_platform_data *pdata) { @@ -860,17 +612,24 @@ int __devinit max8925_device_init(struct max8925_chip *chip, goto out_dev; } - init_regulator(chip, pdata); + if (pdata) { + ret = mfd_add_devices(chip->dev, 0, ®ulator_devs[0], + ARRAY_SIZE(regulator_devs), + ®ulator_resources[0], 0, NULL); + if (ret < 0) { + dev_err(chip->dev, "Failed to add regulator subdev\n"); + goto out_dev; + } + } if (pdata && pdata->backlight) { - bk_devs[0].platform_data = &pdata->backlight; - bk_devs[0].pdata_size = sizeof(struct max8925_backlight_pdata); - } - ret = mfd_add_devices(chip->dev, 0, bk_devs, ARRAY_SIZE(bk_devs), - NULL, 0, NULL); - if (ret < 0) { - dev_err(chip->dev, "Failed to add backlight subdev\n"); - goto out_dev; + ret = mfd_add_devices(chip->dev, 0, &backlight_devs[0], + ARRAY_SIZE(backlight_devs), + &backlight_resources[0], 0, NULL); + if (ret < 0) { + dev_err(chip->dev, "Failed to add backlight subdev\n"); + goto out_dev; + } } if (pdata && pdata->power) { diff --git a/trunk/drivers/mfd/mc13xxx-core.c b/trunk/drivers/mfd/mc13xxx-core.c index 1aba0238f426..1ec79b54bd2f 100644 --- a/trunk/drivers/mfd/mc13xxx-core.c +++ b/trunk/drivers/mfd/mc13xxx-core.c @@ -676,6 +676,7 @@ int mc13xxx_common_init(struct mc13xxx *mc13xxx, err_mask: err_revision: mc13xxx_unlock(mc13xxx); + kfree(mc13xxx); return ret; } diff --git a/trunk/drivers/mfd/omap-usb-host.c b/trunk/drivers/mfd/omap-usb-host.c index 23cec57c02ba..41088ecbb2a9 100644 --- a/trunk/drivers/mfd/omap-usb-host.c +++ b/trunk/drivers/mfd/omap-usb-host.c @@ -21,6 +21,7 @@ #include #include #include +#include #include #include #include @@ -35,6 +36,63 @@ /* OMAP USBHOST Register addresses */ +/* TLL Register Set */ +#define OMAP_USBTLL_REVISION (0x00) +#define OMAP_USBTLL_SYSCONFIG (0x10) +#define OMAP_USBTLL_SYSCONFIG_CACTIVITY (1 << 8) +#define OMAP_USBTLL_SYSCONFIG_SIDLEMODE (1 << 3) +#define OMAP_USBTLL_SYSCONFIG_ENAWAKEUP (1 << 2) +#define OMAP_USBTLL_SYSCONFIG_SOFTRESET (1 << 1) +#define OMAP_USBTLL_SYSCONFIG_AUTOIDLE (1 << 0) + +#define OMAP_USBTLL_SYSSTATUS (0x14) +#define OMAP_USBTLL_SYSSTATUS_RESETDONE (1 << 0) + +#define OMAP_USBTLL_IRQSTATUS (0x18) +#define OMAP_USBTLL_IRQENABLE (0x1C) + +#define OMAP_TLL_SHARED_CONF (0x30) +#define OMAP_TLL_SHARED_CONF_USB_90D_DDR_EN (1 << 6) +#define OMAP_TLL_SHARED_CONF_USB_180D_SDR_EN (1 << 5) +#define OMAP_TLL_SHARED_CONF_USB_DIVRATION (1 << 2) +#define OMAP_TLL_SHARED_CONF_FCLK_REQ (1 << 1) +#define OMAP_TLL_SHARED_CONF_FCLK_IS_ON (1 << 0) + +#define OMAP_TLL_CHANNEL_CONF(num) (0x040 + 0x004 * num) +#define OMAP_TLL_CHANNEL_CONF_FSLSMODE_SHIFT 24 +#define OMAP_TLL_CHANNEL_CONF_ULPINOBITSTUFF (1 << 11) +#define OMAP_TLL_CHANNEL_CONF_ULPI_ULPIAUTOIDLE (1 << 10) +#define OMAP_TLL_CHANNEL_CONF_UTMIAUTOIDLE (1 << 9) +#define OMAP_TLL_CHANNEL_CONF_ULPIDDRMODE (1 << 8) +#define OMAP_TLL_CHANNEL_CONF_CHANMODE_FSLS (1 << 1) +#define OMAP_TLL_CHANNEL_CONF_CHANEN (1 << 0) + +#define OMAP_TLL_FSLSMODE_6PIN_PHY_DAT_SE0 0x0 +#define OMAP_TLL_FSLSMODE_6PIN_PHY_DP_DM 0x1 +#define OMAP_TLL_FSLSMODE_3PIN_PHY 0x2 +#define OMAP_TLL_FSLSMODE_4PIN_PHY 0x3 +#define OMAP_TLL_FSLSMODE_6PIN_TLL_DAT_SE0 0x4 +#define OMAP_TLL_FSLSMODE_6PIN_TLL_DP_DM 0x5 +#define OMAP_TLL_FSLSMODE_3PIN_TLL 0x6 +#define OMAP_TLL_FSLSMODE_4PIN_TLL 0x7 +#define OMAP_TLL_FSLSMODE_2PIN_TLL_DAT_SE0 0xA +#define OMAP_TLL_FSLSMODE_2PIN_DAT_DP_DM 0xB + +#define OMAP_TLL_ULPI_FUNCTION_CTRL(num) (0x804 + 0x100 * num) +#define OMAP_TLL_ULPI_INTERFACE_CTRL(num) (0x807 + 0x100 * num) +#define OMAP_TLL_ULPI_OTG_CTRL(num) (0x80A + 0x100 * num) +#define OMAP_TLL_ULPI_INT_EN_RISE(num) (0x80D + 0x100 * num) +#define OMAP_TLL_ULPI_INT_EN_FALL(num) (0x810 + 0x100 * num) +#define OMAP_TLL_ULPI_INT_STATUS(num) (0x813 + 0x100 * num) +#define OMAP_TLL_ULPI_INT_LATCH(num) (0x814 + 0x100 * num) +#define OMAP_TLL_ULPI_DEBUG(num) (0x815 + 0x100 * num) +#define OMAP_TLL_ULPI_SCRATCH_REGISTER(num) (0x816 + 0x100 * num) + +#define OMAP_TLL_CHANNEL_COUNT 3 +#define OMAP_TLL_CHANNEL_1_EN_MASK (1 << 0) +#define OMAP_TLL_CHANNEL_2_EN_MASK (1 << 1) +#define OMAP_TLL_CHANNEL_3_EN_MASK (1 << 2) + /* UHH Register Set */ #define OMAP_UHH_REVISION (0x00) #define OMAP_UHH_SYSCONFIG (0x10) @@ -74,6 +132,8 @@ #define OMAP4_P2_MODE_TLL (1 << 18) #define OMAP4_P2_MODE_HSIC (3 << 18) +#define OMAP_REV2_TLL_CHANNEL_COUNT 2 + #define OMAP_UHH_DEBUG_CSR (0x44) /* Values of UHH_REVISION - Note: these are not given in the TRM */ @@ -93,12 +153,15 @@ struct usbhs_hcd_omap { struct clk *xclk60mhsp2_ck; struct clk *utmi_p1_fck; struct clk *usbhost_p1_fck; + struct clk *usbtll_p1_fck; struct clk *utmi_p2_fck; struct clk *usbhost_p2_fck; + struct clk *usbtll_p2_fck; struct clk *init_60m_fclk; struct clk *ehci_logic_fck; void __iomem *uhh_base; + void __iomem *tll_base; struct usbhs_omap_platform_data platdata; @@ -273,6 +336,93 @@ static bool is_ohci_port(enum usbhs_omap_port_mode pmode) } } +/* + * convert the port-mode enum to a value we can use in the FSLSMODE + * field of USBTLL_CHANNEL_CONF + */ +static unsigned ohci_omap3_fslsmode(enum usbhs_omap_port_mode mode) +{ + switch (mode) { + case OMAP_USBHS_PORT_MODE_UNUSED: + case OMAP_OHCI_PORT_MODE_PHY_6PIN_DATSE0: + return OMAP_TLL_FSLSMODE_6PIN_PHY_DAT_SE0; + + case OMAP_OHCI_PORT_MODE_PHY_6PIN_DPDM: + return OMAP_TLL_FSLSMODE_6PIN_PHY_DP_DM; + + case OMAP_OHCI_PORT_MODE_PHY_3PIN_DATSE0: + return OMAP_TLL_FSLSMODE_3PIN_PHY; + + case OMAP_OHCI_PORT_MODE_PHY_4PIN_DPDM: + return OMAP_TLL_FSLSMODE_4PIN_PHY; + + case OMAP_OHCI_PORT_MODE_TLL_6PIN_DATSE0: + return OMAP_TLL_FSLSMODE_6PIN_TLL_DAT_SE0; + + case OMAP_OHCI_PORT_MODE_TLL_6PIN_DPDM: + return OMAP_TLL_FSLSMODE_6PIN_TLL_DP_DM; + + case OMAP_OHCI_PORT_MODE_TLL_3PIN_DATSE0: + return OMAP_TLL_FSLSMODE_3PIN_TLL; + + case OMAP_OHCI_PORT_MODE_TLL_4PIN_DPDM: + return OMAP_TLL_FSLSMODE_4PIN_TLL; + + case OMAP_OHCI_PORT_MODE_TLL_2PIN_DATSE0: + return OMAP_TLL_FSLSMODE_2PIN_TLL_DAT_SE0; + + case OMAP_OHCI_PORT_MODE_TLL_2PIN_DPDM: + return OMAP_TLL_FSLSMODE_2PIN_DAT_DP_DM; + default: + pr_warning("Invalid port mode, using default\n"); + return OMAP_TLL_FSLSMODE_6PIN_PHY_DAT_SE0; + } +} + +static void usbhs_omap_tll_init(struct device *dev, u8 tll_channel_count) +{ + struct usbhs_hcd_omap *omap = dev_get_drvdata(dev); + struct usbhs_omap_platform_data *pdata = dev->platform_data; + unsigned reg; + int i; + + /* Program Common TLL register */ + reg = usbhs_read(omap->tll_base, OMAP_TLL_SHARED_CONF); + reg |= (OMAP_TLL_SHARED_CONF_FCLK_IS_ON + | OMAP_TLL_SHARED_CONF_USB_DIVRATION); + reg &= ~OMAP_TLL_SHARED_CONF_USB_90D_DDR_EN; + reg &= ~OMAP_TLL_SHARED_CONF_USB_180D_SDR_EN; + + usbhs_write(omap->tll_base, OMAP_TLL_SHARED_CONF, reg); + + /* Enable channels now */ + for (i = 0; i < tll_channel_count; i++) { + reg = usbhs_read(omap->tll_base, + OMAP_TLL_CHANNEL_CONF(i)); + + if (is_ohci_port(pdata->port_mode[i])) { + reg |= ohci_omap3_fslsmode(pdata->port_mode[i]) + << OMAP_TLL_CHANNEL_CONF_FSLSMODE_SHIFT; + reg |= OMAP_TLL_CHANNEL_CONF_CHANMODE_FSLS; + } else if (pdata->port_mode[i] == OMAP_EHCI_PORT_MODE_TLL) { + + /* Disable AutoIdle, BitStuffing and use SDR Mode */ + reg &= ~(OMAP_TLL_CHANNEL_CONF_UTMIAUTOIDLE + | OMAP_TLL_CHANNEL_CONF_ULPINOBITSTUFF + | OMAP_TLL_CHANNEL_CONF_ULPIDDRMODE); + + } else + continue; + + reg |= OMAP_TLL_CHANNEL_CONF_CHANEN; + usbhs_write(omap->tll_base, + OMAP_TLL_CHANNEL_CONF(i), reg); + + usbhs_writeb(omap->tll_base, + OMAP_TLL_ULPI_SCRATCH_REGISTER(i), 0xbe); + } +} + static int usbhs_runtime_resume(struct device *dev) { struct usbhs_hcd_omap *omap = dev_get_drvdata(dev); @@ -286,17 +436,19 @@ static int usbhs_runtime_resume(struct device *dev) return -ENODEV; } - omap_tll_enable(); spin_lock_irqsave(&omap->lock, flags); if (omap->ehci_logic_fck && !IS_ERR(omap->ehci_logic_fck)) clk_enable(omap->ehci_logic_fck); - if (is_ehci_tll_mode(pdata->port_mode[0])) + if (is_ehci_tll_mode(pdata->port_mode[0])) { clk_enable(omap->usbhost_p1_fck); - if (is_ehci_tll_mode(pdata->port_mode[1])) + clk_enable(omap->usbtll_p1_fck); + } + if (is_ehci_tll_mode(pdata->port_mode[1])) { clk_enable(omap->usbhost_p2_fck); - + clk_enable(omap->usbtll_p2_fck); + } clk_enable(omap->utmi_p1_fck); clk_enable(omap->utmi_p2_fck); @@ -320,11 +472,14 @@ static int usbhs_runtime_suspend(struct device *dev) spin_lock_irqsave(&omap->lock, flags); - if (is_ehci_tll_mode(pdata->port_mode[0])) + if (is_ehci_tll_mode(pdata->port_mode[0])) { clk_disable(omap->usbhost_p1_fck); - if (is_ehci_tll_mode(pdata->port_mode[1])) + clk_disable(omap->usbtll_p1_fck); + } + if (is_ehci_tll_mode(pdata->port_mode[1])) { clk_disable(omap->usbhost_p2_fck); - + clk_disable(omap->usbtll_p2_fck); + } clk_disable(omap->utmi_p2_fck); clk_disable(omap->utmi_p1_fck); @@ -332,7 +487,6 @@ static int usbhs_runtime_suspend(struct device *dev) clk_disable(omap->ehci_logic_fck); spin_unlock_irqrestore(&omap->lock, flags); - omap_tll_disable(); return 0; } @@ -346,6 +500,8 @@ static void omap_usbhs_init(struct device *dev) dev_dbg(dev, "starting TI HSUSB Controller\n"); + pm_runtime_get_sync(dev); + if (pdata->ehci_data->phy_reset) { if (gpio_is_valid(pdata->ehci_data->reset_gpio_port[0])) gpio_request_one(pdata->ehci_data->reset_gpio_port[0], @@ -359,7 +515,6 @@ static void omap_usbhs_init(struct device *dev) udelay(10); } - pm_runtime_get_sync(dev); spin_lock_irqsave(&omap->lock, flags); omap->usbhs_rev = usbhs_read(omap->uhh_base, OMAP_UHH_REVISION); dev_dbg(dev, "OMAP UHH_REVISION 0x%x\n", omap->usbhs_rev); @@ -425,9 +580,22 @@ static void omap_usbhs_init(struct device *dev) usbhs_write(omap->uhh_base, OMAP_UHH_HOSTCONFIG, reg); dev_dbg(dev, "UHH setup done, uhh_hostconfig=%x\n", reg); + if (is_ehci_tll_mode(pdata->port_mode[0]) || + is_ehci_tll_mode(pdata->port_mode[1]) || + is_ehci_tll_mode(pdata->port_mode[2]) || + (is_ohci_port(pdata->port_mode[0])) || + (is_ohci_port(pdata->port_mode[1])) || + (is_ohci_port(pdata->port_mode[2]))) { + + /* Enable UTMI mode for required TLL channels */ + if (is_omap_usbhs_rev2(omap)) + usbhs_omap_tll_init(dev, OMAP_REV2_TLL_CHANNEL_COUNT); + else + usbhs_omap_tll_init(dev, OMAP_TLL_CHANNEL_COUNT); + } + spin_unlock_irqrestore(&omap->lock, flags); - pm_runtime_put_sync(dev); if (pdata->ehci_data->phy_reset) { /* Hold the PHY in RESET for enough time till * PHY is settled and ready @@ -442,6 +610,8 @@ static void omap_usbhs_init(struct device *dev) gpio_set_value_cansleep (pdata->ehci_data->reset_gpio_port[1], 1); } + + pm_runtime_put_sync(dev); } static void omap_usbhs_deinit(struct device *dev) @@ -544,18 +714,32 @@ static int __devinit usbhs_omap_probe(struct platform_device *pdev) goto err_xclk60mhsp2_ck; } + omap->usbtll_p1_fck = clk_get(dev, "usb_tll_hs_usb_ch0_clk"); + if (IS_ERR(omap->usbtll_p1_fck)) { + ret = PTR_ERR(omap->usbtll_p1_fck); + dev_err(dev, "usbtll_p1_fck failed error:%d\n", ret); + goto err_usbhost_p1_fck; + } + omap->usbhost_p2_fck = clk_get(dev, "usb_host_hs_utmi_p2_clk"); if (IS_ERR(omap->usbhost_p2_fck)) { ret = PTR_ERR(omap->usbhost_p2_fck); dev_err(dev, "usbhost_p2_fck failed error:%d\n", ret); - goto err_usbhost_p1_fck; + goto err_usbtll_p1_fck; + } + + omap->usbtll_p2_fck = clk_get(dev, "usb_tll_hs_usb_ch1_clk"); + if (IS_ERR(omap->usbtll_p2_fck)) { + ret = PTR_ERR(omap->usbtll_p2_fck); + dev_err(dev, "usbtll_p2_fck failed error:%d\n", ret); + goto err_usbhost_p2_fck; } omap->init_60m_fclk = clk_get(dev, "init_60m_fclk"); if (IS_ERR(omap->init_60m_fclk)) { ret = PTR_ERR(omap->init_60m_fclk); dev_err(dev, "init_60m_fclk failed error:%d\n", ret); - goto err_usbhost_p2_fck; + goto err_usbtll_p2_fck; } if (is_ehci_phy_mode(pdata->port_mode[0])) { @@ -601,6 +785,20 @@ static int __devinit usbhs_omap_probe(struct platform_device *pdev) goto err_init_60m_fclk; } + res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "tll"); + if (!res) { + dev_err(dev, "UHH EHCI get resource failed\n"); + ret = -ENODEV; + goto err_tll; + } + + omap->tll_base = ioremap(res->start, resource_size(res)); + if (!omap->tll_base) { + dev_err(dev, "TLL ioremap failed\n"); + ret = -ENOMEM; + goto err_tll; + } + platform_set_drvdata(pdev, omap); omap_usbhs_init(dev); @@ -614,14 +812,23 @@ static int __devinit usbhs_omap_probe(struct platform_device *pdev) err_alloc: omap_usbhs_deinit(&pdev->dev); + iounmap(omap->tll_base); + +err_tll: iounmap(omap->uhh_base); err_init_60m_fclk: clk_put(omap->init_60m_fclk); +err_usbtll_p2_fck: + clk_put(omap->usbtll_p2_fck); + err_usbhost_p2_fck: clk_put(omap->usbhost_p2_fck); +err_usbtll_p1_fck: + clk_put(omap->usbtll_p1_fck); + err_usbhost_p1_fck: clk_put(omap->usbhost_p1_fck); @@ -657,9 +864,12 @@ static int __devexit usbhs_omap_remove(struct platform_device *pdev) struct usbhs_hcd_omap *omap = platform_get_drvdata(pdev); omap_usbhs_deinit(&pdev->dev); + iounmap(omap->tll_base); iounmap(omap->uhh_base); clk_put(omap->init_60m_fclk); + clk_put(omap->usbtll_p2_fck); clk_put(omap->usbhost_p2_fck); + clk_put(omap->usbtll_p1_fck); clk_put(omap->usbhost_p1_fck); clk_put(omap->xclk60mhsp2_ck); clk_put(omap->utmi_p2_fck); @@ -700,10 +910,8 @@ static int __init omap_usbhs_drvinit(void) * init before ehci and ohci drivers; * The usbhs core driver should be initialized much before * the omap ehci and ohci probe functions are called. - * This usbhs core driver should be initialized after - * usb tll driver */ -fs_initcall_sync(omap_usbhs_drvinit); +fs_initcall(omap_usbhs_drvinit); static void __exit omap_usbhs_drvexit(void) { diff --git a/trunk/drivers/mfd/omap-usb-tll.c b/trunk/drivers/mfd/omap-usb-tll.c deleted file mode 100644 index 4b7757b84301..000000000000 --- a/trunk/drivers/mfd/omap-usb-tll.c +++ /dev/null @@ -1,471 +0,0 @@ -/** - * omap-usb-tll.c - The USB TLL driver for OMAP EHCI & OHCI - * - * Copyright (C) 2012 Texas Instruments Incorporated - http://www.ti.com - * Author: Keshava Munegowda - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2 of - * the License 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, see . - */ -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#define USBTLL_DRIVER_NAME "usbhs_tll" - -/* TLL Register Set */ -#define OMAP_USBTLL_REVISION (0x00) -#define OMAP_USBTLL_SYSCONFIG (0x10) -#define OMAP_USBTLL_SYSCONFIG_CACTIVITY (1 << 8) -#define OMAP_USBTLL_SYSCONFIG_SIDLEMODE (1 << 3) -#define OMAP_USBTLL_SYSCONFIG_ENAWAKEUP (1 << 2) -#define OMAP_USBTLL_SYSCONFIG_SOFTRESET (1 << 1) -#define OMAP_USBTLL_SYSCONFIG_AUTOIDLE (1 << 0) - -#define OMAP_USBTLL_SYSSTATUS (0x14) -#define OMAP_USBTLL_SYSSTATUS_RESETDONE (1 << 0) - -#define OMAP_USBTLL_IRQSTATUS (0x18) -#define OMAP_USBTLL_IRQENABLE (0x1C) - -#define OMAP_TLL_SHARED_CONF (0x30) -#define OMAP_TLL_SHARED_CONF_USB_90D_DDR_EN (1 << 6) -#define OMAP_TLL_SHARED_CONF_USB_180D_SDR_EN (1 << 5) -#define OMAP_TLL_SHARED_CONF_USB_DIVRATION (1 << 2) -#define OMAP_TLL_SHARED_CONF_FCLK_REQ (1 << 1) -#define OMAP_TLL_SHARED_CONF_FCLK_IS_ON (1 << 0) - -#define OMAP_TLL_CHANNEL_CONF(num) (0x040 + 0x004 * num) -#define OMAP_TLL_CHANNEL_CONF_FSLSMODE_SHIFT 24 -#define OMAP_TLL_CHANNEL_CONF_ULPINOBITSTUFF (1 << 11) -#define OMAP_TLL_CHANNEL_CONF_ULPI_ULPIAUTOIDLE (1 << 10) -#define OMAP_TLL_CHANNEL_CONF_UTMIAUTOIDLE (1 << 9) -#define OMAP_TLL_CHANNEL_CONF_ULPIDDRMODE (1 << 8) -#define OMAP_TLL_CHANNEL_CONF_CHANMODE_FSLS (1 << 1) -#define OMAP_TLL_CHANNEL_CONF_CHANEN (1 << 0) - -#define OMAP_TLL_FSLSMODE_6PIN_PHY_DAT_SE0 0x0 -#define OMAP_TLL_FSLSMODE_6PIN_PHY_DP_DM 0x1 -#define OMAP_TLL_FSLSMODE_3PIN_PHY 0x2 -#define OMAP_TLL_FSLSMODE_4PIN_PHY 0x3 -#define OMAP_TLL_FSLSMODE_6PIN_TLL_DAT_SE0 0x4 -#define OMAP_TLL_FSLSMODE_6PIN_TLL_DP_DM 0x5 -#define OMAP_TLL_FSLSMODE_3PIN_TLL 0x6 -#define OMAP_TLL_FSLSMODE_4PIN_TLL 0x7 -#define OMAP_TLL_FSLSMODE_2PIN_TLL_DAT_SE0 0xA -#define OMAP_TLL_FSLSMODE_2PIN_DAT_DP_DM 0xB - -#define OMAP_TLL_ULPI_FUNCTION_CTRL(num) (0x804 + 0x100 * num) -#define OMAP_TLL_ULPI_INTERFACE_CTRL(num) (0x807 + 0x100 * num) -#define OMAP_TLL_ULPI_OTG_CTRL(num) (0x80A + 0x100 * num) -#define OMAP_TLL_ULPI_INT_EN_RISE(num) (0x80D + 0x100 * num) -#define OMAP_TLL_ULPI_INT_EN_FALL(num) (0x810 + 0x100 * num) -#define OMAP_TLL_ULPI_INT_STATUS(num) (0x813 + 0x100 * num) -#define OMAP_TLL_ULPI_INT_LATCH(num) (0x814 + 0x100 * num) -#define OMAP_TLL_ULPI_DEBUG(num) (0x815 + 0x100 * num) -#define OMAP_TLL_ULPI_SCRATCH_REGISTER(num) (0x816 + 0x100 * num) - -#define OMAP_REV2_TLL_CHANNEL_COUNT 2 -#define OMAP_TLL_CHANNEL_COUNT 3 -#define OMAP_TLL_CHANNEL_1_EN_MASK (1 << 0) -#define OMAP_TLL_CHANNEL_2_EN_MASK (1 << 1) -#define OMAP_TLL_CHANNEL_3_EN_MASK (1 << 2) - -/* Values of USBTLL_REVISION - Note: these are not given in the TRM */ -#define OMAP_USBTLL_REV1 0x00000015 /* OMAP3 */ -#define OMAP_USBTLL_REV2 0x00000018 /* OMAP 3630 */ -#define OMAP_USBTLL_REV3 0x00000004 /* OMAP4 */ - -#define is_ehci_tll_mode(x) (x == OMAP_EHCI_PORT_MODE_TLL) - -struct usbtll_omap { - struct clk *usbtll_p1_fck; - struct clk *usbtll_p2_fck; - struct usbtll_omap_platform_data platdata; - /* secure the register updates */ - spinlock_t lock; -}; - -/*-------------------------------------------------------------------------*/ - -const char usbtll_driver_name[] = USBTLL_DRIVER_NAME; -struct platform_device *tll_pdev; - -/*-------------------------------------------------------------------------*/ - -static inline void usbtll_write(void __iomem *base, u32 reg, u32 val) -{ - __raw_writel(val, base + reg); -} - -static inline u32 usbtll_read(void __iomem *base, u32 reg) -{ - return __raw_readl(base + reg); -} - -static inline void usbtll_writeb(void __iomem *base, u8 reg, u8 val) -{ - __raw_writeb(val, base + reg); -} - -static inline u8 usbtll_readb(void __iomem *base, u8 reg) -{ - return __raw_readb(base + reg); -} - -/*-------------------------------------------------------------------------*/ - -static bool is_ohci_port(enum usbhs_omap_port_mode pmode) -{ - switch (pmode) { - case OMAP_OHCI_PORT_MODE_PHY_6PIN_DATSE0: - case OMAP_OHCI_PORT_MODE_PHY_6PIN_DPDM: - case OMAP_OHCI_PORT_MODE_PHY_3PIN_DATSE0: - case OMAP_OHCI_PORT_MODE_PHY_4PIN_DPDM: - case OMAP_OHCI_PORT_MODE_TLL_6PIN_DATSE0: - case OMAP_OHCI_PORT_MODE_TLL_6PIN_DPDM: - case OMAP_OHCI_PORT_MODE_TLL_3PIN_DATSE0: - case OMAP_OHCI_PORT_MODE_TLL_4PIN_DPDM: - case OMAP_OHCI_PORT_MODE_TLL_2PIN_DATSE0: - case OMAP_OHCI_PORT_MODE_TLL_2PIN_DPDM: - return true; - - default: - return false; - } -} - -/* - * convert the port-mode enum to a value we can use in the FSLSMODE - * field of USBTLL_CHANNEL_CONF - */ -static unsigned ohci_omap3_fslsmode(enum usbhs_omap_port_mode mode) -{ - switch (mode) { - case OMAP_USBHS_PORT_MODE_UNUSED: - case OMAP_OHCI_PORT_MODE_PHY_6PIN_DATSE0: - return OMAP_TLL_FSLSMODE_6PIN_PHY_DAT_SE0; - - case OMAP_OHCI_PORT_MODE_PHY_6PIN_DPDM: - return OMAP_TLL_FSLSMODE_6PIN_PHY_DP_DM; - - case OMAP_OHCI_PORT_MODE_PHY_3PIN_DATSE0: - return OMAP_TLL_FSLSMODE_3PIN_PHY; - - case OMAP_OHCI_PORT_MODE_PHY_4PIN_DPDM: - return OMAP_TLL_FSLSMODE_4PIN_PHY; - - case OMAP_OHCI_PORT_MODE_TLL_6PIN_DATSE0: - return OMAP_TLL_FSLSMODE_6PIN_TLL_DAT_SE0; - - case OMAP_OHCI_PORT_MODE_TLL_6PIN_DPDM: - return OMAP_TLL_FSLSMODE_6PIN_TLL_DP_DM; - - case OMAP_OHCI_PORT_MODE_TLL_3PIN_DATSE0: - return OMAP_TLL_FSLSMODE_3PIN_TLL; - - case OMAP_OHCI_PORT_MODE_TLL_4PIN_DPDM: - return OMAP_TLL_FSLSMODE_4PIN_TLL; - - case OMAP_OHCI_PORT_MODE_TLL_2PIN_DATSE0: - return OMAP_TLL_FSLSMODE_2PIN_TLL_DAT_SE0; - - case OMAP_OHCI_PORT_MODE_TLL_2PIN_DPDM: - return OMAP_TLL_FSLSMODE_2PIN_DAT_DP_DM; - default: - pr_warn("Invalid port mode, using default\n"); - return OMAP_TLL_FSLSMODE_6PIN_PHY_DAT_SE0; - } -} - -/** - * usbtll_omap_probe - initialize TI-based HCDs - * - * Allocates basic resources for this USB host controller. - */ -static int __devinit usbtll_omap_probe(struct platform_device *pdev) -{ - struct device *dev = &pdev->dev; - struct usbtll_omap_platform_data *pdata = dev->platform_data; - void __iomem *base; - struct resource *res; - struct usbtll_omap *tll; - unsigned reg; - unsigned long flags; - int ret = 0; - int i, ver, count; - - dev_dbg(dev, "starting TI HSUSB TLL Controller\n"); - - tll = kzalloc(sizeof(struct usbtll_omap), GFP_KERNEL); - if (!tll) { - dev_err(dev, "Memory allocation failed\n"); - ret = -ENOMEM; - goto end; - } - - spin_lock_init(&tll->lock); - - for (i = 0; i < OMAP3_HS_USB_PORTS; i++) - tll->platdata.port_mode[i] = pdata->port_mode[i]; - - tll->usbtll_p1_fck = clk_get(dev, "usb_tll_hs_usb_ch0_clk"); - if (IS_ERR(tll->usbtll_p1_fck)) { - ret = PTR_ERR(tll->usbtll_p1_fck); - dev_err(dev, "usbtll_p1_fck failed error:%d\n", ret); - goto err_tll; - } - - tll->usbtll_p2_fck = clk_get(dev, "usb_tll_hs_usb_ch1_clk"); - if (IS_ERR(tll->usbtll_p2_fck)) { - ret = PTR_ERR(tll->usbtll_p2_fck); - dev_err(dev, "usbtll_p2_fck failed error:%d\n", ret); - goto err_usbtll_p1_fck; - } - - res = platform_get_resource(pdev, IORESOURCE_MEM, 0); - if (!res) { - dev_err(dev, "usb tll get resource failed\n"); - ret = -ENODEV; - goto err_usbtll_p2_fck; - } - - base = ioremap(res->start, resource_size(res)); - if (!base) { - dev_err(dev, "TLL ioremap failed\n"); - ret = -ENOMEM; - goto err_usbtll_p2_fck; - } - - platform_set_drvdata(pdev, tll); - pm_runtime_enable(dev); - pm_runtime_get_sync(dev); - - spin_lock_irqsave(&tll->lock, flags); - - ver = usbtll_read(base, OMAP_USBTLL_REVISION); - switch (ver) { - case OMAP_USBTLL_REV1: - case OMAP_USBTLL_REV2: - count = OMAP_TLL_CHANNEL_COUNT; - break; - case OMAP_USBTLL_REV3: - count = OMAP_REV2_TLL_CHANNEL_COUNT; - break; - default: - dev_err(dev, "TLL version failed\n"); - ret = -ENODEV; - goto err_ioremap; - } - - if (is_ehci_tll_mode(pdata->port_mode[0]) || - is_ehci_tll_mode(pdata->port_mode[1]) || - is_ehci_tll_mode(pdata->port_mode[2]) || - is_ohci_port(pdata->port_mode[0]) || - is_ohci_port(pdata->port_mode[1]) || - is_ohci_port(pdata->port_mode[2])) { - - /* Program Common TLL register */ - reg = usbtll_read(base, OMAP_TLL_SHARED_CONF); - reg |= (OMAP_TLL_SHARED_CONF_FCLK_IS_ON - | OMAP_TLL_SHARED_CONF_USB_DIVRATION); - reg &= ~OMAP_TLL_SHARED_CONF_USB_90D_DDR_EN; - reg &= ~OMAP_TLL_SHARED_CONF_USB_180D_SDR_EN; - - usbtll_write(base, OMAP_TLL_SHARED_CONF, reg); - - /* Enable channels now */ - for (i = 0; i < count; i++) { - reg = usbtll_read(base, OMAP_TLL_CHANNEL_CONF(i)); - - if (is_ohci_port(pdata->port_mode[i])) { - reg |= ohci_omap3_fslsmode(pdata->port_mode[i]) - << OMAP_TLL_CHANNEL_CONF_FSLSMODE_SHIFT; - reg |= OMAP_TLL_CHANNEL_CONF_CHANMODE_FSLS; - } else if (pdata->port_mode[i] == - OMAP_EHCI_PORT_MODE_TLL) { - /* - * Disable AutoIdle, BitStuffing - * and use SDR Mode - */ - reg &= ~(OMAP_TLL_CHANNEL_CONF_UTMIAUTOIDLE - | OMAP_TLL_CHANNEL_CONF_ULPINOBITSTUFF - | OMAP_TLL_CHANNEL_CONF_ULPIDDRMODE); - } else { - continue; - } - reg |= OMAP_TLL_CHANNEL_CONF_CHANEN; - usbtll_write(base, OMAP_TLL_CHANNEL_CONF(i), reg); - - usbtll_writeb(base, - OMAP_TLL_ULPI_SCRATCH_REGISTER(i), - 0xbe); - } - } - -err_ioremap: - spin_unlock_irqrestore(&tll->lock, flags); - iounmap(base); - pm_runtime_put_sync(dev); - tll_pdev = pdev; - if (!ret) - goto end; - pm_runtime_disable(dev); - -err_usbtll_p2_fck: - clk_put(tll->usbtll_p2_fck); - -err_usbtll_p1_fck: - clk_put(tll->usbtll_p1_fck); - -err_tll: - kfree(tll); - -end: - return ret; -} - -/** - * usbtll_omap_remove - shutdown processing for UHH & TLL HCDs - * @pdev: USB Host Controller being removed - * - * Reverses the effect of usbtll_omap_probe(). - */ -static int __devexit usbtll_omap_remove(struct platform_device *pdev) -{ - struct usbtll_omap *tll = platform_get_drvdata(pdev); - - clk_put(tll->usbtll_p2_fck); - clk_put(tll->usbtll_p1_fck); - pm_runtime_disable(&pdev->dev); - kfree(tll); - return 0; -} - -static int usbtll_runtime_resume(struct device *dev) -{ - struct usbtll_omap *tll = dev_get_drvdata(dev); - struct usbtll_omap_platform_data *pdata = &tll->platdata; - unsigned long flags; - - dev_dbg(dev, "usbtll_runtime_resume\n"); - - if (!pdata) { - dev_dbg(dev, "missing platform_data\n"); - return -ENODEV; - } - - spin_lock_irqsave(&tll->lock, flags); - - if (is_ehci_tll_mode(pdata->port_mode[0])) - clk_enable(tll->usbtll_p1_fck); - - if (is_ehci_tll_mode(pdata->port_mode[1])) - clk_enable(tll->usbtll_p2_fck); - - spin_unlock_irqrestore(&tll->lock, flags); - - return 0; -} - -static int usbtll_runtime_suspend(struct device *dev) -{ - struct usbtll_omap *tll = dev_get_drvdata(dev); - struct usbtll_omap_platform_data *pdata = &tll->platdata; - unsigned long flags; - - dev_dbg(dev, "usbtll_runtime_suspend\n"); - - if (!pdata) { - dev_dbg(dev, "missing platform_data\n"); - return -ENODEV; - } - - spin_lock_irqsave(&tll->lock, flags); - - if (is_ehci_tll_mode(pdata->port_mode[0])) - clk_disable(tll->usbtll_p1_fck); - - if (is_ehci_tll_mode(pdata->port_mode[1])) - clk_disable(tll->usbtll_p2_fck); - - spin_unlock_irqrestore(&tll->lock, flags); - - return 0; -} - -static const struct dev_pm_ops usbtllomap_dev_pm_ops = { - SET_RUNTIME_PM_OPS(usbtll_runtime_suspend, - usbtll_runtime_resume, - NULL) -}; - -static struct platform_driver usbtll_omap_driver = { - .driver = { - .name = (char *)usbtll_driver_name, - .owner = THIS_MODULE, - .pm = &usbtllomap_dev_pm_ops, - }, - .probe = usbtll_omap_probe, - .remove = __devexit_p(usbtll_omap_remove), -}; - -int omap_tll_enable(void) -{ - if (!tll_pdev) { - pr_err("missing omap usbhs tll platform_data\n"); - return -ENODEV; - } - return pm_runtime_get_sync(&tll_pdev->dev); -} -EXPORT_SYMBOL_GPL(omap_tll_enable); - -int omap_tll_disable(void) -{ - if (!tll_pdev) { - pr_err("missing omap usbhs tll platform_data\n"); - return -ENODEV; - } - return pm_runtime_put_sync(&tll_pdev->dev); -} -EXPORT_SYMBOL_GPL(omap_tll_disable); - -MODULE_AUTHOR("Keshava Munegowda "); -MODULE_ALIAS("platform:" USBHS_DRIVER_NAME); -MODULE_LICENSE("GPL v2"); -MODULE_DESCRIPTION("usb tll driver for TI OMAP EHCI and OHCI controllers"); - -static int __init omap_usbtll_drvinit(void) -{ - return platform_driver_register(&usbtll_omap_driver); -} - -/* - * init before usbhs core driver; - * The usbtll driver should be initialized before - * the usbhs core driver probe function is called. - */ -fs_initcall(omap_usbtll_drvinit); - -static void __exit omap_usbtll_drvexit(void) -{ - platform_driver_unregister(&usbtll_omap_driver); -} -module_exit(omap_usbtll_drvexit); diff --git a/trunk/drivers/mfd/palmas.c b/trunk/drivers/mfd/palmas.c index 4f8d6e6b19aa..a345f9bb7b47 100644 --- a/trunk/drivers/mfd/palmas.c +++ b/trunk/drivers/mfd/palmas.c @@ -23,7 +23,60 @@ #include #include #include -#include + +static const struct resource gpadc_resource[] = { + { + .name = "EOC_SW", + .start = PALMAS_GPADC_EOC_SW_IRQ, + .end = PALMAS_GPADC_EOC_SW_IRQ, + .flags = IORESOURCE_IRQ, + } +}; + +static const struct resource usb_resource[] = { + { + .name = "ID", + .start = PALMAS_ID_OTG_IRQ, + .end = PALMAS_ID_OTG_IRQ, + .flags = IORESOURCE_IRQ, + }, + { + .name = "ID_WAKEUP", + .start = PALMAS_ID_IRQ, + .end = PALMAS_ID_IRQ, + .flags = IORESOURCE_IRQ, + }, + { + .name = "VBUS", + .start = PALMAS_VBUS_OTG_IRQ, + .end = PALMAS_VBUS_OTG_IRQ, + .flags = IORESOURCE_IRQ, + }, + { + .name = "VBUS_WAKEUP", + .start = PALMAS_VBUS_IRQ, + .end = PALMAS_VBUS_IRQ, + .flags = IORESOURCE_IRQ, + }, +}; + +static const struct resource rtc_resource[] = { + { + .name = "RTC_ALARM", + .start = PALMAS_RTC_ALARM_IRQ, + .end = PALMAS_RTC_ALARM_IRQ, + .flags = IORESOURCE_IRQ, + }, +}; + +static const struct resource pwron_resource[] = { + { + .name = "PWRON_BUTTON", + .start = PALMAS_PWRON_IRQ, + .end = PALMAS_PWRON_IRQ, + .flags = IORESOURCE_IRQ, + }, +}; enum palmas_ids { PALMAS_PMIC_ID, @@ -58,14 +111,20 @@ static const struct mfd_cell palmas_children[] = { }, { .name = "palmas-rtc", + .num_resources = ARRAY_SIZE(rtc_resource), + .resources = rtc_resource, .id = PALMAS_RTC_ID, }, { .name = "palmas-pwrbutton", + .num_resources = ARRAY_SIZE(pwron_resource), + .resources = pwron_resource, .id = PALMAS_PWRBUTTON_ID, }, { .name = "palmas-gpadc", + .num_resources = ARRAY_SIZE(gpadc_resource), + .resources = gpadc_resource, .id = PALMAS_GPADC_ID, }, { @@ -82,6 +141,8 @@ static const struct mfd_cell palmas_children[] = { }, { .name = "palmas-usb", + .num_resources = ARRAY_SIZE(usb_resource), + .resources = usb_resource, .id = PALMAS_USB_ID, } }; @@ -247,56 +308,17 @@ static struct regmap_irq_chip palmas_irq_chip = { PALMAS_INT1_MASK), }; -static void __devinit palmas_dt_to_pdata(struct device_node *node, - struct palmas_platform_data *pdata) -{ - int ret; - u32 prop; - - ret = of_property_read_u32(node, "ti,mux_pad1", &prop); - if (!ret) { - pdata->mux_from_pdata = 1; - pdata->pad1 = prop; - } - - ret = of_property_read_u32(node, "ti,mux_pad2", &prop); - if (!ret) { - pdata->mux_from_pdata = 1; - pdata->pad2 = prop; - } - - /* The default for this register is all masked */ - ret = of_property_read_u32(node, "ti,power_ctrl", &prop); - if (!ret) - pdata->power_ctrl = prop; - else - pdata->power_ctrl = PALMAS_POWER_CTRL_NSLEEP_MASK | - PALMAS_POWER_CTRL_ENABLE1_MASK | - PALMAS_POWER_CTRL_ENABLE2_MASK; -} - static int __devinit palmas_i2c_probe(struct i2c_client *i2c, const struct i2c_device_id *id) { struct palmas *palmas; struct palmas_platform_data *pdata; - struct device_node *node = i2c->dev.of_node; int ret = 0, i; unsigned int reg, addr; int slave; struct mfd_cell *children; pdata = dev_get_platdata(&i2c->dev); - - if (node && !pdata) { - pdata = devm_kzalloc(&i2c->dev, sizeof(*pdata), GFP_KERNEL); - - if (!pdata) - return -ENOMEM; - - palmas_dt_to_pdata(node, pdata); - } - if (!pdata) return -EINVAL; @@ -342,7 +364,7 @@ static int __devinit palmas_i2c_probe(struct i2c_client *i2c, regmap_write(palmas->regmap[slave], addr, reg); ret = regmap_add_irq_chip(palmas->regmap[slave], palmas->irq, - IRQF_ONESHOT | IRQF_TRIGGER_LOW, 0, &palmas_irq_chip, + IRQF_ONESHOT | IRQF_TRIGGER_LOW, -1, &palmas_irq_chip, &palmas->irq_data); if (ret < 0) goto err; @@ -355,11 +377,11 @@ static int __devinit palmas_i2c_probe(struct i2c_client *i2c, reg = pdata->pad1; ret = regmap_write(palmas->regmap[slave], addr, reg); if (ret) - goto err_irq; + goto err; } else { ret = regmap_read(palmas->regmap[slave], addr, ®); if (ret) - goto err_irq; + goto err; } if (!(reg & PALMAS_PRIMARY_SECONDARY_PAD1_GPIO_0)) @@ -390,11 +412,11 @@ static int __devinit palmas_i2c_probe(struct i2c_client *i2c, reg = pdata->pad2; ret = regmap_write(palmas->regmap[slave], addr, reg); if (ret) - goto err_irq; + goto err; } else { ret = regmap_read(palmas->regmap[slave], addr, ®); if (ret) - goto err_irq; + goto err; } if (!(reg & PALMAS_PRIMARY_SECONDARY_PAD2_GPIO_4)) @@ -417,43 +439,18 @@ static int __devinit palmas_i2c_probe(struct i2c_client *i2c, ret = regmap_write(palmas->regmap[slave], addr, reg); if (ret) - goto err_irq; - - /* - * If we are probing with DT do this the DT way and return here - * otherwise continue and add devices using mfd helpers. - */ - if (node) { - ret = of_platform_populate(node, NULL, NULL, &i2c->dev); - if (ret < 0) - goto err_irq; - else - return ret; - } + goto err; children = kmemdup(palmas_children, sizeof(palmas_children), GFP_KERNEL); if (!children) { ret = -ENOMEM; - goto err_irq; + goto err; } children[PALMAS_PMIC_ID].platform_data = pdata->pmic_pdata; children[PALMAS_PMIC_ID].pdata_size = sizeof(*pdata->pmic_pdata); - children[PALMAS_GPADC_ID].platform_data = pdata->gpadc_pdata; - children[PALMAS_GPADC_ID].pdata_size = sizeof(*pdata->gpadc_pdata); - - children[PALMAS_RESOURCE_ID].platform_data = pdata->resource_pdata; - children[PALMAS_RESOURCE_ID].pdata_size = - sizeof(*pdata->resource_pdata); - - children[PALMAS_USB_ID].platform_data = pdata->usb_pdata; - children[PALMAS_USB_ID].pdata_size = sizeof(*pdata->usb_pdata); - - children[PALMAS_CLK_ID].platform_data = pdata->clk_pdata; - children[PALMAS_CLK_ID].pdata_size = sizeof(*pdata->clk_pdata); - ret = mfd_add_devices(palmas->dev, -1, children, ARRAY_SIZE(palmas_children), NULL, regmap_irq_chip_get_base(palmas->irq_data), @@ -461,15 +458,13 @@ static int __devinit palmas_i2c_probe(struct i2c_client *i2c, kfree(children); if (ret < 0) - goto err_devices; + goto err; return ret; -err_devices: - mfd_remove_devices(palmas->dev); -err_irq: - regmap_del_irq_chip(palmas->irq, palmas->irq_data); err: + mfd_remove_devices(palmas->dev); + kfree(palmas); return ret; } diff --git a/trunk/drivers/mfd/rc5t583-irq.c b/trunk/drivers/mfd/rc5t583-irq.c index fe00cdd6f83d..fa6f80fad5f1 100644 --- a/trunk/drivers/mfd/rc5t583-irq.c +++ b/trunk/drivers/mfd/rc5t583-irq.c @@ -255,7 +255,7 @@ static irqreturn_t rc5t583_irq(int irq, void *data) { struct rc5t583 *rc5t583 = data; uint8_t int_sts[RC5T583_MAX_INTERRUPT_MASK_REGS]; - uint8_t master_int = 0; + uint8_t master_int; int i; int ret; unsigned int rtc_int_sts = 0; diff --git a/trunk/drivers/mfd/rc5t583.c b/trunk/drivers/mfd/rc5t583.c index f1a024ecdb1e..ff61efc76ce2 100644 --- a/trunk/drivers/mfd/rc5t583.c +++ b/trunk/drivers/mfd/rc5t583.c @@ -85,7 +85,7 @@ static int __rc5t583_set_ext_pwrreq1_control(struct device *dev, int id, int ext_pwr, int slots) { int ret; - uint8_t sleepseq_val = 0; + uint8_t sleepseq_val; unsigned int en_bit; unsigned int slot_bit; diff --git a/trunk/drivers/mfd/smsc-ece1099.c b/trunk/drivers/mfd/smsc-ece1099.c deleted file mode 100644 index 24ae3d8421c5..000000000000 --- a/trunk/drivers/mfd/smsc-ece1099.c +++ /dev/null @@ -1,113 +0,0 @@ -/* - * TI SMSC MFD Driver - * - * Copyright (C) 2012 Texas Instruments Incorporated - http://www.ti.com - * - * Author: Sourav Poddar - * - * 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; GPL v2. - * - */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -static struct regmap_config smsc_regmap_config = { - .reg_bits = 8, - .val_bits = 8, - .max_register = SMSC_VEN_ID_H, - .cache_type = REGCACHE_RBTREE, -}; - -static int smsc_i2c_probe(struct i2c_client *i2c, - const struct i2c_device_id *id) -{ - struct smsc *smsc; - int devid, rev, venid_l, venid_h; - int ret = 0; - - smsc = devm_kzalloc(&i2c->dev, sizeof(struct smsc), - GFP_KERNEL); - if (!smsc) { - dev_err(&i2c->dev, "smsc mfd driver memory allocation failed\n"); - return -ENOMEM; - } - - smsc->regmap = devm_regmap_init_i2c(i2c, &smsc_regmap_config); - if (IS_ERR(smsc->regmap)) { - ret = PTR_ERR(smsc->regmap); - goto err; - } - - i2c_set_clientdata(i2c, smsc); - smsc->dev = &i2c->dev; - -#ifdef CONFIG_OF - of_property_read_u32(i2c->dev.of_node, "clock", &smsc->clk); -#endif - - regmap_read(smsc->regmap, SMSC_DEV_ID, &devid); - regmap_read(smsc->regmap, SMSC_DEV_REV, &rev); - regmap_read(smsc->regmap, SMSC_VEN_ID_L, &venid_l); - regmap_read(smsc->regmap, SMSC_VEN_ID_H, &venid_h); - - dev_info(&i2c->dev, "SMSCxxx devid: %02x rev: %02x venid: %02x\n", - devid, rev, (venid_h << 8) | venid_l); - - ret = regmap_write(smsc->regmap, SMSC_CLK_CTRL, smsc->clk); - if (ret) - goto err; - -#ifdef CONFIG_OF - if (i2c->dev.of_node) - ret = of_platform_populate(i2c->dev.of_node, - NULL, NULL, &i2c->dev); -#endif - -err: - return ret; -} - -static int smsc_i2c_remove(struct i2c_client *i2c) -{ - struct smsc *smsc = i2c_get_clientdata(i2c); - - mfd_remove_devices(smsc->dev); - - return 0; -} - -static const struct i2c_device_id smsc_i2c_id[] = { - { "smscece1099", 0}, - {}, -}; -MODULE_DEVICE_TABLE(i2c, smsc_i2c_id); - -static struct i2c_driver smsc_i2c_driver = { - .driver = { - .name = "smsc", - .owner = THIS_MODULE, - }, - .probe = smsc_i2c_probe, - .remove = smsc_i2c_remove, - .id_table = smsc_i2c_id, -}; - -module_i2c_driver(smsc_i2c_driver); - -MODULE_AUTHOR("Sourav Poddar "); -MODULE_DESCRIPTION("SMSC chip multi-function driver"); -MODULE_LICENSE("GPL v2"); diff --git a/trunk/drivers/mfd/syscon.c b/trunk/drivers/mfd/syscon.c deleted file mode 100644 index 65fe609026cc..000000000000 --- a/trunk/drivers/mfd/syscon.c +++ /dev/null @@ -1,176 +0,0 @@ -/* - * System Control Driver - * - * Copyright (C) 2012 Freescale Semiconductor, Inc. - * Copyright (C) 2012 Linaro Ltd. - * - * Author: Dong Aisheng - * - * 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 -#include -#include -#include -#include -#include -#include -#include - -static struct platform_driver syscon_driver; - -struct syscon { - struct device *dev; - void __iomem *base; - struct regmap *regmap; -}; - -static int syscon_match(struct device *dev, void *data) -{ - struct syscon *syscon = dev_get_drvdata(dev); - struct device_node *dn = data; - - return (syscon->dev->of_node == dn) ? 1 : 0; -} - -struct regmap *syscon_node_to_regmap(struct device_node *np) -{ - struct syscon *syscon; - struct device *dev; - - dev = driver_find_device(&syscon_driver.driver, NULL, np, - syscon_match); - if (!dev) - return ERR_PTR(-EPROBE_DEFER); - - syscon = dev_get_drvdata(dev); - - return syscon->regmap; -} -EXPORT_SYMBOL_GPL(syscon_node_to_regmap); - -struct regmap *syscon_regmap_lookup_by_compatible(const char *s) -{ - struct device_node *syscon_np; - struct regmap *regmap; - - syscon_np = of_find_compatible_node(NULL, NULL, s); - if (!syscon_np) - return ERR_PTR(-ENODEV); - - regmap = syscon_node_to_regmap(syscon_np); - of_node_put(syscon_np); - - return regmap; -} -EXPORT_SYMBOL_GPL(syscon_regmap_lookup_by_compatible); - -struct regmap *syscon_regmap_lookup_by_phandle(struct device_node *np, - const char *property) -{ - struct device_node *syscon_np; - struct regmap *regmap; - - syscon_np = of_parse_phandle(np, property, 0); - if (!syscon_np) - return ERR_PTR(-ENODEV); - - regmap = syscon_node_to_regmap(syscon_np); - of_node_put(syscon_np); - - return regmap; -} -EXPORT_SYMBOL_GPL(syscon_regmap_lookup_by_phandle); - -static const struct of_device_id of_syscon_match[] = { - { .compatible = "syscon", }, - { }, -}; - -static struct regmap_config syscon_regmap_config = { - .reg_bits = 32, - .val_bits = 32, - .reg_stride = 4, -}; - -static int __devinit syscon_probe(struct platform_device *pdev) -{ - struct device *dev = &pdev->dev; - struct device_node *np = dev->of_node; - struct syscon *syscon; - struct resource res; - int ret; - - if (!np) - return -ENOENT; - - syscon = devm_kzalloc(dev, sizeof(struct syscon), - GFP_KERNEL); - if (!syscon) - return -ENOMEM; - - syscon->base = of_iomap(np, 0); - if (!syscon->base) - return -EADDRNOTAVAIL; - - ret = of_address_to_resource(np, 0, &res); - if (ret) - return ret; - - syscon_regmap_config.max_register = res.end - res.start - 3; - syscon->regmap = devm_regmap_init_mmio(dev, syscon->base, - &syscon_regmap_config); - if (IS_ERR(syscon->regmap)) { - dev_err(dev, "regmap init failed\n"); - return PTR_ERR(syscon->regmap); - } - - syscon->dev = dev; - platform_set_drvdata(pdev, syscon); - - dev_info(dev, "syscon regmap start 0x%x end 0x%x registered\n", - res.start, res.end); - - return 0; -} - -static int __devexit syscon_remove(struct platform_device *pdev) -{ - struct syscon *syscon; - - syscon = platform_get_drvdata(pdev); - iounmap(syscon->base); - platform_set_drvdata(pdev, NULL); - - return 0; -} - -static struct platform_driver syscon_driver = { - .driver = { - .name = "syscon", - .owner = THIS_MODULE, - .of_match_table = of_syscon_match, - }, - .probe = syscon_probe, - .remove = __devexit_p(syscon_remove), -}; - -static int __init syscon_init(void) -{ - return platform_driver_register(&syscon_driver); -} -postcore_initcall(syscon_init); - -static void __exit syscon_exit(void) -{ - platform_driver_unregister(&syscon_driver); -} -module_exit(syscon_exit); - -MODULE_AUTHOR("Dong Aisheng "); -MODULE_DESCRIPTION("System Control driver"); -MODULE_LICENSE("GPL v2"); diff --git a/trunk/drivers/mfd/tc3589x.c b/trunk/drivers/mfd/tc3589x.c index 8f4c853ca116..b56ba6b43294 100644 --- a/trunk/drivers/mfd/tc3589x.c +++ b/trunk/drivers/mfd/tc3589x.c @@ -9,10 +9,8 @@ #include #include #include -#include #include #include -#include #include #include @@ -147,7 +145,6 @@ static struct mfd_cell tc3589x_dev_gpio[] = { .name = "tc3589x-gpio", .num_resources = ARRAY_SIZE(gpio_resources), .resources = &gpio_resources[0], - .of_compatible = "tc3589x-gpio", }, }; @@ -156,7 +153,6 @@ static struct mfd_cell tc3589x_dev_keypad[] = { .name = "tc3589x-keypad", .num_resources = ARRAY_SIZE(keypad_resources), .resources = &keypad_resources[0], - .of_compatible = "tc3589x-keypad", }, }; @@ -172,9 +168,8 @@ static irqreturn_t tc3589x_irq(int irq, void *data) while (status) { int bit = __ffs(status); - int virq = irq_create_mapping(tc3589x->domain, bit); - handle_nested_irq(virq); + handle_nested_irq(tc3589x->irq_base + bit); status &= ~(1 << bit); } @@ -191,60 +186,38 @@ static irqreturn_t tc3589x_irq(int irq, void *data) return IRQ_HANDLED; } -static int tc3589x_irq_map(struct irq_domain *d, unsigned int virq, - irq_hw_number_t hwirq) +static int tc3589x_irq_init(struct tc3589x *tc3589x) { - struct tc3589x *tc3589x = d->host_data; + int base = tc3589x->irq_base; + int irq; - irq_set_chip_data(virq, tc3589x); - irq_set_chip_and_handler(virq, &dummy_irq_chip, - handle_edge_irq); - irq_set_nested_thread(virq, 1); + for (irq = base; irq < base + TC3589x_NR_INTERNAL_IRQS; irq++) { + irq_set_chip_data(irq, tc3589x); + irq_set_chip_and_handler(irq, &dummy_irq_chip, + handle_edge_irq); + irq_set_nested_thread(irq, 1); #ifdef CONFIG_ARM - set_irq_flags(virq, IRQF_VALID); + set_irq_flags(irq, IRQF_VALID); #else - irq_set_noprobe(virq); + irq_set_noprobe(irq); #endif + } return 0; } -static void tc3589x_irq_unmap(struct irq_domain *d, unsigned int virq) -{ -#ifdef CONFIG_ARM - set_irq_flags(virq, 0); -#endif - irq_set_chip_and_handler(virq, NULL, NULL); - irq_set_chip_data(virq, NULL); -} - -static struct irq_domain_ops tc3589x_irq_ops = { - .map = tc3589x_irq_map, - .unmap = tc3589x_irq_unmap, - .xlate = irq_domain_xlate_twocell, -}; - -static int tc3589x_irq_init(struct tc3589x *tc3589x, struct device_node *np) +static void tc3589x_irq_remove(struct tc3589x *tc3589x) { int base = tc3589x->irq_base; + int irq; - if (base) { - tc3589x->domain = irq_domain_add_legacy( - NULL, TC3589x_NR_INTERNAL_IRQS, base, - 0, &tc3589x_irq_ops, tc3589x); - } - else { - tc3589x->domain = irq_domain_add_linear( - np, TC3589x_NR_INTERNAL_IRQS, - &tc3589x_irq_ops, tc3589x); - } - - if (!tc3589x->domain) { - dev_err(tc3589x->dev, "Failed to create irqdomain\n"); - return -ENOSYS; + for (irq = base; irq < base + TC3589x_NR_INTERNAL_IRQS; irq++) { +#ifdef CONFIG_ARM + set_irq_flags(irq, 0); +#endif + irq_set_chip_and_handler(irq, NULL, NULL); + irq_set_chip_data(irq, NULL); } - - return 0; } static int tc3589x_chip_init(struct tc3589x *tc3589x) @@ -290,7 +263,7 @@ static int __devinit tc3589x_device_init(struct tc3589x *tc3589x) if (blocks & TC3589x_BLOCK_GPIO) { ret = mfd_add_devices(tc3589x->dev, -1, tc3589x_dev_gpio, ARRAY_SIZE(tc3589x_dev_gpio), NULL, - tc3589x->irq_base, tc3589x->domain); + tc3589x->irq_base, NULL); if (ret) { dev_err(tc3589x->dev, "failed to add gpio child\n"); return ret; @@ -301,7 +274,7 @@ static int __devinit tc3589x_device_init(struct tc3589x *tc3589x) if (blocks & TC3589x_BLOCK_KEYPAD) { ret = mfd_add_devices(tc3589x->dev, -1, tc3589x_dev_keypad, ARRAY_SIZE(tc3589x_dev_keypad), NULL, - tc3589x->irq_base, tc3589x->domain); + tc3589x->irq_base, NULL); if (ret) { dev_err(tc3589x->dev, "failed to keypad child\n"); return ret; @@ -312,47 +285,13 @@ static int __devinit tc3589x_device_init(struct tc3589x *tc3589x) return ret; } -static int tc3589x_of_probe(struct device_node *np, - struct tc3589x_platform_data *pdata) -{ - struct device_node *child; - - for_each_child_of_node(np, child) { - if (!strcmp(child->name, "tc3589x_gpio")) { - pdata->block |= TC3589x_BLOCK_GPIO; - } - if (!strcmp(child->name, "tc3589x_keypad")) { - pdata->block |= TC3589x_BLOCK_KEYPAD; - } - } - - return 0; -} - static int __devinit tc3589x_probe(struct i2c_client *i2c, const struct i2c_device_id *id) { struct tc3589x_platform_data *pdata = i2c->dev.platform_data; - struct device_node *np = i2c->dev.of_node; struct tc3589x *tc3589x; int ret; - if (!pdata) { - if (np) { - pdata = devm_kzalloc(&i2c->dev, sizeof(*pdata), GFP_KERNEL); - if (!pdata) - return -ENOMEM; - - ret = tc3589x_of_probe(np, pdata); - if (ret) - return ret; - } - else { - dev_err(&i2c->dev, "No platform data or DT found\n"); - return -EINVAL; - } - } - if (!i2c_check_functionality(i2c->adapter, I2C_FUNC_SMBUS_BYTE_DATA | I2C_FUNC_SMBUS_I2C_BLOCK)) return -EIO; @@ -375,7 +314,7 @@ static int __devinit tc3589x_probe(struct i2c_client *i2c, if (ret) goto out_free; - ret = tc3589x_irq_init(tc3589x, np); + ret = tc3589x_irq_init(tc3589x); if (ret) goto out_free; @@ -384,7 +323,7 @@ static int __devinit tc3589x_probe(struct i2c_client *i2c, "tc3589x", tc3589x); if (ret) { dev_err(tc3589x->dev, "failed to request IRQ: %d\n", ret); - goto out_free; + goto out_removeirq; } ret = tc3589x_device_init(tc3589x); @@ -397,6 +336,8 @@ static int __devinit tc3589x_probe(struct i2c_client *i2c, out_freeirq: free_irq(tc3589x->i2c->irq, tc3589x); +out_removeirq: + tc3589x_irq_remove(tc3589x); out_free: kfree(tc3589x); return ret; @@ -409,6 +350,7 @@ static int __devexit tc3589x_remove(struct i2c_client *client) mfd_remove_devices(tc3589x->dev); free_irq(tc3589x->i2c->irq, tc3589x); + tc3589x_irq_remove(tc3589x); kfree(tc3589x); diff --git a/trunk/drivers/mfd/tps65090.c b/trunk/drivers/mfd/tps65090.c index 074ae32b0d2a..50fd87c87a1c 100644 --- a/trunk/drivers/mfd/tps65090.c +++ b/trunk/drivers/mfd/tps65090.c @@ -236,7 +236,7 @@ static int __devinit tps65090_irq_init(struct tps65090 *tps65090, int irq, static bool is_volatile_reg(struct device *dev, unsigned int reg) { - if (reg == TPS65090_INT_STS) + if ((reg == TPS65090_INT_STS) || (reg == TPS65090_INT_STS)) return true; else return false; diff --git a/trunk/drivers/mfd/tps65217.c b/trunk/drivers/mfd/tps65217.c index 3fb32e655254..a95e9421b735 100644 --- a/trunk/drivers/mfd/tps65217.c +++ b/trunk/drivers/mfd/tps65217.c @@ -34,9 +34,6 @@ static struct mfd_cell tps65217s[] = { { .name = "tps65217-pmic", }, - { - .name = "tps65217-bl", - }, }; /** diff --git a/trunk/drivers/mfd/tps6586x.c b/trunk/drivers/mfd/tps6586x.c index 467464368773..345960ca2fd8 100644 --- a/trunk/drivers/mfd/tps6586x.c +++ b/trunk/drivers/mfd/tps6586x.c @@ -30,10 +30,6 @@ #include #include -#define TPS6586X_SUPPLYENE 0x14 -#define EXITSLREQ_BIT BIT(1) -#define SLEEP_MODE_BIT BIT(3) - /* interrupt control registers */ #define TPS6586X_INT_ACK1 0xb5 #define TPS6586X_INT_ACK2 0xb6 @@ -426,7 +422,6 @@ static struct tps6586x_platform_data *tps6586x_parse_dt(struct i2c_client *clien pdata->subdevs = devs; pdata->gpio_base = -1; pdata->irq_base = -1; - pdata->pm_off = of_property_read_bool(np, "ti,system-power-controller"); return pdata; } @@ -459,15 +454,6 @@ static const struct regmap_config tps6586x_regmap_config = { .cache_type = REGCACHE_RBTREE, }; -static struct device *tps6586x_dev; -static void tps6586x_power_off(void) -{ - if (tps6586x_clr_bits(tps6586x_dev, TPS6586X_SUPPLYENE, EXITSLREQ_BIT)) - return; - - tps6586x_set_bits(tps6586x_dev, TPS6586X_SUPPLYENE, SLEEP_MODE_BIT); -} - static int __devinit tps6586x_i2c_probe(struct i2c_client *client, const struct i2c_device_id *id) { @@ -533,11 +519,6 @@ static int __devinit tps6586x_i2c_probe(struct i2c_client *client, goto err_add_devs; } - if (pdata->pm_off && !pm_power_off) { - tps6586x_dev = &client->dev; - pm_power_off = tps6586x_power_off; - } - return 0; err_add_devs: diff --git a/trunk/drivers/mfd/tps65910.c b/trunk/drivers/mfd/tps65910.c index 0d79ce2b5014..d3ce4d569deb 100644 --- a/trunk/drivers/mfd/tps65910.c +++ b/trunk/drivers/mfd/tps65910.c @@ -24,14 +24,6 @@ #include #include -static struct resource rtc_resources[] = { - { - .start = TPS65910_IRQ_RTC_ALARM, - .end = TPS65910_IRQ_RTC_ALARM, - .flags = IORESOURCE_IRQ, - } -}; - static struct mfd_cell tps65910s[] = { { .name = "tps65910-gpio", @@ -41,8 +33,6 @@ static struct mfd_cell tps65910s[] = { }, { .name = "tps65910-rtc", - .num_resources = ARRAY_SIZE(rtc_resources), - .resources = &rtc_resources[0], }, { .name = "tps65910-power", @@ -208,8 +198,6 @@ static struct tps65910_board *tps65910_parse_dt(struct i2c_client *client, board_info->irq = client->irq; board_info->irq_base = -1; - board_info->pm_off = of_property_read_bool(np, - "ti,system-power-controller"); return board_info; } @@ -222,21 +210,6 @@ struct tps65910_board *tps65910_parse_dt(struct i2c_client *client, } #endif -static struct i2c_client *tps65910_i2c_client; -static void tps65910_power_off(void) -{ - struct tps65910 *tps65910; - - tps65910 = dev_get_drvdata(&tps65910_i2c_client->dev); - - if (tps65910_reg_set_bits(tps65910, TPS65910_DEVCTRL, - DEVCTRL_PWR_OFF_MASK) < 0) - return; - - tps65910_reg_clear_bits(tps65910, TPS65910_DEVCTRL, - DEVCTRL_DEV_ON_MASK); -} - static __devinit int tps65910_i2c_probe(struct i2c_client *i2c, const struct i2c_device_id *id) { @@ -294,11 +267,6 @@ static __devinit int tps65910_i2c_probe(struct i2c_client *i2c, tps65910_ck32k_init(tps65910, pmic_plat_data); tps65910_sleepinit(tps65910, pmic_plat_data); - if (pmic_plat_data->pm_off && !pm_power_off) { - tps65910_i2c_client = i2c; - pm_power_off = tps65910_power_off; - } - return ret; } diff --git a/trunk/drivers/mfd/twl-core.c b/trunk/drivers/mfd/twl-core.c index 4ae642320205..9d3a0bc1a65f 100644 --- a/trunk/drivers/mfd/twl-core.c +++ b/trunk/drivers/mfd/twl-core.c @@ -63,6 +63,70 @@ #define DRIVER_NAME "twl" +#if defined(CONFIG_KEYBOARD_TWL4030) || defined(CONFIG_KEYBOARD_TWL4030_MODULE) +#define twl_has_keypad() true +#else +#define twl_has_keypad() false +#endif + +#if defined(CONFIG_GPIO_TWL4030) || defined(CONFIG_GPIO_TWL4030_MODULE) +#define twl_has_gpio() true +#else +#define twl_has_gpio() false +#endif + +#if defined(CONFIG_REGULATOR_TWL4030) \ + || defined(CONFIG_REGULATOR_TWL4030_MODULE) +#define twl_has_regulator() true +#else +#define twl_has_regulator() false +#endif + +#if defined(CONFIG_TWL4030_MADC) || defined(CONFIG_TWL4030_MADC_MODULE) +#define twl_has_madc() true +#else +#define twl_has_madc() false +#endif + +#ifdef CONFIG_TWL4030_POWER +#define twl_has_power() true +#else +#define twl_has_power() false +#endif + +#if defined(CONFIG_RTC_DRV_TWL4030) || defined(CONFIG_RTC_DRV_TWL4030_MODULE) +#define twl_has_rtc() true +#else +#define twl_has_rtc() false +#endif + +#if defined(CONFIG_TWL4030_USB) || defined(CONFIG_TWL4030_USB_MODULE) ||\ + defined(CONFIG_TWL6030_USB) || defined(CONFIG_TWL6030_USB_MODULE) +#define twl_has_usb() true +#else +#define twl_has_usb() false +#endif + +#if defined(CONFIG_TWL4030_WATCHDOG) || \ + defined(CONFIG_TWL4030_WATCHDOG_MODULE) +#define twl_has_watchdog() true +#else +#define twl_has_watchdog() false +#endif + +#if defined(CONFIG_MFD_TWL4030_AUDIO) || \ + defined(CONFIG_MFD_TWL4030_AUDIO_MODULE) +#define twl_has_codec() true +#else +#define twl_has_codec() false +#endif + +#if defined(CONFIG_CHARGER_TWL4030) || defined(CONFIG_CHARGER_TWL4030_MODULE) +#define twl_has_bci() true +#else +#define twl_has_bci() false +#endif + /* Triton Core internal information (BEGIN) */ /* Last - for index max*/ @@ -70,6 +134,13 @@ #define TWL_NUM_SLAVES 4 +#if defined(CONFIG_INPUT_TWL4030_PWRBUTTON) \ + || defined(CONFIG_INPUT_TWL4030_PWRBUTTON_MODULE) +#define twl_has_pwrbutton() true +#else +#define twl_has_pwrbutton() false +#endif + #define SUB_CHIP_ID0 0 #define SUB_CHIP_ID1 1 #define SUB_CHIP_ID2 2 @@ -481,38 +552,6 @@ int twl_get_version(void) } EXPORT_SYMBOL_GPL(twl_get_version); -/** - * twl_get_hfclk_rate - API to get TWL external HFCLK clock rate. - * - * Api to get the TWL HFCLK rate based on BOOT_CFG register. - */ -int twl_get_hfclk_rate(void) -{ - u8 ctrl; - int rate; - - twl_i2c_read_u8(TWL_MODULE_PM_MASTER, &ctrl, R_CFG_BOOT); - - switch (ctrl & 0x3) { - case HFCLK_FREQ_19p2_MHZ: - rate = 19200000; - break; - case HFCLK_FREQ_26_MHZ: - rate = 26000000; - break; - case HFCLK_FREQ_38p4_MHZ: - rate = 38400000; - break; - default: - pr_err("TWL4030: HFCLK is not configured\n"); - rate = -EINVAL; - break; - } - - return rate; -} -EXPORT_SYMBOL_GPL(twl_get_hfclk_rate); - static struct device * add_numbered_child(unsigned chip, const char *name, int num, void *pdata, unsigned pdata_len, @@ -630,7 +669,7 @@ add_children(struct twl4030_platform_data *pdata, unsigned irq_base, struct device *child; unsigned sub_chip_id; - if (IS_ENABLED(CONFIG_GPIO_TWL4030) && pdata->gpio) { + if (twl_has_gpio() && pdata->gpio) { child = add_child(SUB_CHIP_ID1, "twl4030_gpio", pdata->gpio, sizeof(*pdata->gpio), false, irq_base + GPIO_INTR_OFFSET, 0); @@ -638,7 +677,7 @@ add_children(struct twl4030_platform_data *pdata, unsigned irq_base, return PTR_ERR(child); } - if (IS_ENABLED(CONFIG_KEYBOARD_TWL4030) && pdata->keypad) { + if (twl_has_keypad() && pdata->keypad) { child = add_child(SUB_CHIP_ID2, "twl4030_keypad", pdata->keypad, sizeof(*pdata->keypad), true, irq_base + KEYPAD_INTR_OFFSET, 0); @@ -646,7 +685,7 @@ add_children(struct twl4030_platform_data *pdata, unsigned irq_base, return PTR_ERR(child); } - if (IS_ENABLED(CONFIG_TWL4030_MADC) && pdata->madc) { + if (twl_has_madc() && pdata->madc) { child = add_child(2, "twl4030_madc", pdata->madc, sizeof(*pdata->madc), true, irq_base + MADC_INTR_OFFSET, 0); @@ -654,7 +693,7 @@ add_children(struct twl4030_platform_data *pdata, unsigned irq_base, return PTR_ERR(child); } - if (IS_ENABLED(CONFIG_RTC_DRV_TWL4030)) { + if (twl_has_rtc()) { /* * REVISIT platform_data here currently might expose the * "msecure" line ... but for now we just expect board @@ -670,15 +709,7 @@ add_children(struct twl4030_platform_data *pdata, unsigned irq_base, return PTR_ERR(child); } - if (IS_ENABLED(CONFIG_PWM_TWL6030) && twl_class_is_6030()) { - child = add_child(TWL6030_MODULE_ID1, "twl6030-pwm", NULL, 0, - false, 0, 0); - if (IS_ERR(child)) - return PTR_ERR(child); - } - - if (IS_ENABLED(CONFIG_TWL4030_USB) && pdata->usb && - twl_class_is_4030()) { + if (twl_has_usb() && pdata->usb && twl_class_is_4030()) { static struct regulator_consumer_supply usb1v5 = { .supply = "usb1v5", @@ -692,7 +723,7 @@ add_children(struct twl4030_platform_data *pdata, unsigned irq_base, }; /* First add the regulators so that they can be used by transceiver */ - if (IS_ENABLED(CONFIG_REGULATOR_TWL4030)) { + if (twl_has_regulator()) { /* this is a template that gets copied */ struct regulator_init_data usb_fixed = { .constraints.valid_modes_mask = @@ -734,19 +765,18 @@ add_children(struct twl4030_platform_data *pdata, unsigned irq_base, return PTR_ERR(child); /* we need to connect regulators to this transceiver */ - if (IS_ENABLED(CONFIG_REGULATOR_TWL4030) && child) { + if (twl_has_regulator() && child) { usb1v5.dev_name = dev_name(child); usb1v8.dev_name = dev_name(child); usb3v1[0].dev_name = dev_name(child); } } - if (IS_ENABLED(CONFIG_TWL6030_USB) && pdata->usb && - twl_class_is_6030()) { + if (twl_has_usb() && pdata->usb && twl_class_is_6030()) { static struct regulator_consumer_supply usb3v3; int regulator; - if (IS_ENABLED(CONFIG_REGULATOR_TWL4030)) { + if (twl_has_regulator()) { /* this is a template that gets copied */ struct regulator_init_data usb_fixed = { .constraints.valid_modes_mask = @@ -783,10 +813,9 @@ add_children(struct twl4030_platform_data *pdata, unsigned irq_base, if (IS_ERR(child)) return PTR_ERR(child); /* we need to connect regulators to this transceiver */ - if (IS_ENABLED(CONFIG_REGULATOR_TWL4030) && child) + if (twl_has_regulator() && child) usb3v3.dev_name = dev_name(child); - } else if (IS_ENABLED(CONFIG_REGULATOR_TWL4030) && - twl_class_is_6030()) { + } else if (twl_has_regulator() && twl_class_is_6030()) { if (features & TWL6025_SUBCLASS) child = add_regulator(TWL6025_REG_LDOUSB, pdata->ldousb, features); @@ -798,21 +827,20 @@ add_children(struct twl4030_platform_data *pdata, unsigned irq_base, return PTR_ERR(child); } - if (IS_ENABLED(CONFIG_TWL4030_WATCHDOG) && twl_class_is_4030()) { + if (twl_has_watchdog() && twl_class_is_4030()) { child = add_child(0, "twl4030_wdt", NULL, 0, false, 0, 0); if (IS_ERR(child)) return PTR_ERR(child); } - if (IS_ENABLED(CONFIG_INPUT_TWL4030_PWRBUTTON) && twl_class_is_4030()) { + if (twl_has_pwrbutton() && twl_class_is_4030()) { child = add_child(1, "twl4030_pwrbutton", NULL, 0, true, irq_base + 8 + 0, 0); if (IS_ERR(child)) return PTR_ERR(child); } - if (IS_ENABLED(CONFIG_MFD_TWL4030_AUDIO) && pdata->audio && - twl_class_is_4030()) { + if (twl_has_codec() && pdata->audio && twl_class_is_4030()) { sub_chip_id = twl_map[TWL_MODULE_AUDIO_VOICE].sid; child = add_child(sub_chip_id, "twl4030-audio", pdata->audio, sizeof(*pdata->audio), @@ -822,7 +850,7 @@ add_children(struct twl4030_platform_data *pdata, unsigned irq_base, } /* twl4030 regulators */ - if (IS_ENABLED(CONFIG_REGULATOR_TWL4030) && twl_class_is_4030()) { + if (twl_has_regulator() && twl_class_is_4030()) { child = add_regulator(TWL4030_REG_VPLL1, pdata->vpll1, features); if (IS_ERR(child)) @@ -877,7 +905,7 @@ add_children(struct twl4030_platform_data *pdata, unsigned irq_base, } /* maybe add LDOs that are omitted on cost-reduced parts */ - if (IS_ENABLED(CONFIG_REGULATOR_TWL4030) && !(features & TPS_SUBSET) + if (twl_has_regulator() && !(features & TPS_SUBSET) && twl_class_is_4030()) { child = add_regulator(TWL4030_REG_VPLL2, pdata->vpll2, features); @@ -911,7 +939,7 @@ add_children(struct twl4030_platform_data *pdata, unsigned irq_base, } /* twl6030 regulators */ - if (IS_ENABLED(CONFIG_REGULATOR_TWL4030) && twl_class_is_6030() && + if (twl_has_regulator() && twl_class_is_6030() && !(features & TWL6025_SUBCLASS)) { child = add_regulator(TWL6030_REG_VDD1, pdata->vdd1, features); @@ -985,7 +1013,7 @@ add_children(struct twl4030_platform_data *pdata, unsigned irq_base, } /* 6030 and 6025 share this regulator */ - if (IS_ENABLED(CONFIG_REGULATOR_TWL4030) && twl_class_is_6030()) { + if (twl_has_regulator() && twl_class_is_6030()) { child = add_regulator(TWL6030_REG_VANA, pdata->vana, features); if (IS_ERR(child)) @@ -993,7 +1021,7 @@ add_children(struct twl4030_platform_data *pdata, unsigned irq_base, } /* twl6025 regulators */ - if (IS_ENABLED(CONFIG_REGULATOR_TWL4030) && twl_class_is_6030() && + if (twl_has_regulator() && twl_class_is_6030() && (features & TWL6025_SUBCLASS)) { child = add_regulator(TWL6025_REG_LDO5, pdata->ldo5, features); @@ -1052,7 +1080,7 @@ add_children(struct twl4030_platform_data *pdata, unsigned irq_base, } - if (IS_ENABLED(CONFIG_CHARGER_TWL4030) && pdata->bci && + if (twl_has_bci() && pdata->bci && !(features & (TPS_SUBSET | TWL5031))) { child = add_child(3, "twl4030_bci", pdata->bci, sizeof(*pdata->bci), false, @@ -1267,7 +1295,7 @@ twl_probe(struct i2c_client *client, const struct i2c_device_id *id) } /* load power event scripts */ - if (IS_ENABLED(CONFIG_TWL4030_POWER) && pdata->power) + if (twl_has_power() && pdata->power) twl4030_power_init(pdata->power); /* Maybe init the T2 Interrupt subsystem */ diff --git a/trunk/drivers/mfd/twl4030-audio.c b/trunk/drivers/mfd/twl4030-audio.c index 5c11acf9e0fd..77c9acb14583 100644 --- a/trunk/drivers/mfd/twl4030-audio.c +++ b/trunk/drivers/mfd/twl4030-audio.c @@ -28,8 +28,6 @@ #include #include #include -#include -#include #include #include #include @@ -158,70 +156,47 @@ unsigned int twl4030_audio_get_mclk(void) } EXPORT_SYMBOL_GPL(twl4030_audio_get_mclk); -static bool twl4030_audio_has_codec(struct twl4030_audio_data *pdata, - struct device_node *node) -{ - if (pdata && pdata->codec) - return true; - - if (of_find_node_by_name(node, "codec")) - return true; - - return false; -} - -static bool twl4030_audio_has_vibra(struct twl4030_audio_data *pdata, - struct device_node *node) -{ - int vibra; - - if (pdata && pdata->vibra) - return true; - - if (!of_property_read_u32(node, "ti,enable-vibra", &vibra) && vibra) - return true; - - return false; -} - static int __devinit twl4030_audio_probe(struct platform_device *pdev) { struct twl4030_audio *audio; struct twl4030_audio_data *pdata = pdev->dev.platform_data; - struct device_node *node = pdev->dev.of_node; struct mfd_cell *cell = NULL; int ret, childs = 0; u8 val; - if (!pdata && !node) { + if (!pdata) { dev_err(&pdev->dev, "Platform data is missing\n"); return -EINVAL; } - audio = devm_kzalloc(&pdev->dev, sizeof(struct twl4030_audio), - GFP_KERNEL); - if (!audio) - return -ENOMEM; - - mutex_init(&audio->mutex); - audio->audio_mclk = twl_get_hfclk_rate(); - /* Configure APLL_INFREQ and disable APLL if enabled */ - switch (audio->audio_mclk) { + val = 0; + switch (pdata->audio_mclk) { case 19200000: - val = TWL4030_APLL_INFREQ_19200KHZ; + val |= TWL4030_APLL_INFREQ_19200KHZ; break; case 26000000: - val = TWL4030_APLL_INFREQ_26000KHZ; + val |= TWL4030_APLL_INFREQ_26000KHZ; break; case 38400000: - val = TWL4030_APLL_INFREQ_38400KHZ; + val |= TWL4030_APLL_INFREQ_38400KHZ; break; default: dev_err(&pdev->dev, "Invalid audio_mclk\n"); return -EINVAL; } - twl_i2c_write_u8(TWL4030_MODULE_AUDIO_VOICE, val, TWL4030_REG_APLL_CTL); + twl_i2c_write_u8(TWL4030_MODULE_AUDIO_VOICE, + val, TWL4030_REG_APLL_CTL); + + audio = kzalloc(sizeof(struct twl4030_audio), GFP_KERNEL); + if (!audio) + return -ENOMEM; + + platform_set_drvdata(pdev, audio); + + twl4030_audio_dev = pdev; + mutex_init(&audio->mutex); + audio->audio_mclk = pdata->audio_mclk; /* Codec power */ audio->resource[TWL4030_AUDIO_RES_POWER].reg = TWL4030_REG_CODEC_MODE; @@ -231,28 +206,21 @@ static int __devinit twl4030_audio_probe(struct platform_device *pdev) audio->resource[TWL4030_AUDIO_RES_APLL].reg = TWL4030_REG_APLL_CTL; audio->resource[TWL4030_AUDIO_RES_APLL].mask = TWL4030_APLL_EN; - if (twl4030_audio_has_codec(pdata, node)) { + if (pdata->codec) { cell = &audio->cells[childs]; cell->name = "twl4030-codec"; - if (pdata) { - cell->platform_data = pdata->codec; - cell->pdata_size = sizeof(*pdata->codec); - } + cell->platform_data = pdata->codec; + cell->pdata_size = sizeof(*pdata->codec); childs++; } - if (twl4030_audio_has_vibra(pdata, node)) { + if (pdata->vibra) { cell = &audio->cells[childs]; cell->name = "twl4030-vibra"; - if (pdata) { - cell->platform_data = pdata->vibra; - cell->pdata_size = sizeof(*pdata->vibra); - } + cell->platform_data = pdata->vibra; + cell->pdata_size = sizeof(*pdata->vibra); childs++; } - platform_set_drvdata(pdev, audio); - twl4030_audio_dev = pdev; - if (childs) ret = mfd_add_devices(&pdev->dev, pdev->id, audio->cells, childs, NULL, 0, NULL); @@ -261,42 +229,39 @@ static int __devinit twl4030_audio_probe(struct platform_device *pdev) ret = -ENODEV; } - if (ret) { - platform_set_drvdata(pdev, NULL); - twl4030_audio_dev = NULL; - } + if (!ret) + return 0; + platform_set_drvdata(pdev, NULL); + kfree(audio); + twl4030_audio_dev = NULL; return ret; } static int __devexit twl4030_audio_remove(struct platform_device *pdev) { + struct twl4030_audio *audio = platform_get_drvdata(pdev); + mfd_remove_devices(&pdev->dev); platform_set_drvdata(pdev, NULL); + kfree(audio); twl4030_audio_dev = NULL; return 0; } -static const struct of_device_id twl4030_audio_of_match[] = { - {.compatible = "ti,twl4030-audio", }, - { }, -}; -MODULE_DEVICE_TABLE(of, twl4030_audio_of_match); +MODULE_ALIAS("platform:twl4030-audio"); static struct platform_driver twl4030_audio_driver = { + .probe = twl4030_audio_probe, + .remove = __devexit_p(twl4030_audio_remove), .driver = { .owner = THIS_MODULE, .name = "twl4030-audio", - .of_match_table = twl4030_audio_of_match, }, - .probe = twl4030_audio_probe, - .remove = __devexit_p(twl4030_audio_remove), }; module_platform_driver(twl4030_audio_driver); MODULE_AUTHOR("Peter Ujfalusi "); -MODULE_DESCRIPTION("TWL4030 audio block MFD driver"); MODULE_LICENSE("GPL"); -MODULE_ALIAS("platform:twl4030-audio"); diff --git a/trunk/drivers/pwm/pwm-twl6030.c b/trunk/drivers/mfd/twl6030-pwm.c similarity index 55% rename from trunk/drivers/pwm/pwm-twl6030.c rename to trunk/drivers/mfd/twl6030-pwm.c index 8e6387864ca2..e8fee147678d 100644 --- a/trunk/drivers/pwm/pwm-twl6030.c +++ b/trunk/drivers/mfd/twl6030-pwm.c @@ -20,7 +20,6 @@ #include #include -#include #include #include @@ -46,54 +45,40 @@ #define PWM_CTRL2_MODE_MASK 0x3 -struct twl6030_pwm_chip { - struct pwm_chip chip; +struct pwm_device { + const char *label; + unsigned int pwm_id; }; -static int twl6030_pwm_request(struct pwm_chip *chip, struct pwm_device *pwm) +int pwm_config(struct pwm_device *pwm, int duty_ns, int period_ns) { + u8 duty_cycle; int ret; - u8 val; - - /* Configure PWM */ - val = PWM_CTRL2_DIS_PD | PWM_CTRL2_CURR_02 | PWM_CTRL2_SRC_VAC | - PWM_CTRL2_MODE_HW; - - ret = twl_i2c_write_u8(TWL6030_MODULE_ID1, val, LED_PWM_CTRL2); - if (ret < 0) { - dev_err(chip->dev, "%s: Failed to configure PWM, Error %d\n", - pwm->label, ret); - return ret; - } - return 0; -} + if (pwm == NULL || period_ns == 0 || duty_ns > period_ns) + return -EINVAL; -static int twl6030_pwm_config(struct pwm_chip *chip, struct pwm_device *pwm, - int duty_ns, int period_ns) -{ - u8 duty_cycle = (duty_ns * PWM_CTRL1_MAX) / period_ns; - int ret; + duty_cycle = (duty_ns * PWM_CTRL1_MAX) / period_ns; ret = twl_i2c_write_u8(TWL6030_MODULE_ID1, duty_cycle, LED_PWM_CTRL1); + if (ret < 0) { pr_err("%s: Failed to configure PWM, Error %d\n", pwm->label, ret); return ret; } - return 0; } +EXPORT_SYMBOL(pwm_config); -static int twl6030_pwm_enable(struct pwm_chip *chip, struct pwm_device *pwm) +int pwm_enable(struct pwm_device *pwm) { - int ret; u8 val; + int ret; ret = twl_i2c_read_u8(TWL6030_MODULE_ID1, &val, LED_PWM_CTRL2); if (ret < 0) { - dev_err(chip->dev, "%s: Failed to enable PWM, Error %d\n", - pwm->label, ret); + pr_err("%s: Failed to enable PWM, Error %d\n", pwm->label, ret); return ret; } @@ -103,23 +88,23 @@ static int twl6030_pwm_enable(struct pwm_chip *chip, struct pwm_device *pwm) ret = twl_i2c_write_u8(TWL6030_MODULE_ID1, val, LED_PWM_CTRL2); if (ret < 0) { - dev_err(chip->dev, "%s: Failed to enable PWM, Error %d\n", - pwm->label, ret); + pr_err("%s: Failed to enable PWM, Error %d\n", pwm->label, ret); return ret; } twl_i2c_read_u8(TWL6030_MODULE_ID1, &val, LED_PWM_CTRL2); return 0; } +EXPORT_SYMBOL(pwm_enable); -static void twl6030_pwm_disable(struct pwm_chip *chip, struct pwm_device *pwm) +void pwm_disable(struct pwm_device *pwm) { - int ret; u8 val; + int ret; ret = twl_i2c_read_u8(TWL6030_MODULE_ID1, &val, LED_PWM_CTRL2); if (ret < 0) { - dev_err(chip->dev, "%s: Failed to disable PWM, Error %d\n", + pr_err("%s: Failed to disable PWM, Error %d\n", pwm->label, ret); return; } @@ -129,56 +114,52 @@ static void twl6030_pwm_disable(struct pwm_chip *chip, struct pwm_device *pwm) ret = twl_i2c_write_u8(TWL6030_MODULE_ID1, val, LED_PWM_CTRL2); if (ret < 0) { - dev_err(chip->dev, "%s: Failed to disable PWM, Error %d\n", + pr_err("%s: Failed to disable PWM, Error %d\n", pwm->label, ret); + return; } + return; } +EXPORT_SYMBOL(pwm_disable); -static const struct pwm_ops twl6030_pwm_ops = { - .request = twl6030_pwm_request, - .config = twl6030_pwm_config, - .enable = twl6030_pwm_enable, - .disable = twl6030_pwm_disable, -}; - -static int twl6030_pwm_probe(struct platform_device *pdev) +struct pwm_device *pwm_request(int pwm_id, const char *label) { - struct twl6030_pwm_chip *twl6030; + u8 val; int ret; + struct pwm_device *pwm; - twl6030 = devm_kzalloc(&pdev->dev, sizeof(*twl6030), GFP_KERNEL); - if (!twl6030) - return -ENOMEM; + pwm = kzalloc(sizeof(struct pwm_device), GFP_KERNEL); + if (pwm == NULL) { + pr_err("%s: failed to allocate memory\n", label); + return NULL; + } - twl6030->chip.dev = &pdev->dev; - twl6030->chip.ops = &twl6030_pwm_ops; - twl6030->chip.base = -1; - twl6030->chip.npwm = 1; + pwm->label = label; + pwm->pwm_id = pwm_id; - ret = pwmchip_add(&twl6030->chip); - if (ret < 0) - return ret; + /* Configure PWM */ + val = PWM_CTRL2_DIS_PD | PWM_CTRL2_CURR_02 | PWM_CTRL2_SRC_VAC | + PWM_CTRL2_MODE_HW; - platform_set_drvdata(pdev, twl6030); + ret = twl_i2c_write_u8(TWL6030_MODULE_ID1, val, LED_PWM_CTRL2); - return 0; -} + if (ret < 0) { + pr_err("%s: Failed to configure PWM, Error %d\n", + pwm->label, ret); -static int twl6030_pwm_remove(struct platform_device *pdev) -{ - struct twl6030_pwm_chip *twl6030 = platform_get_drvdata(pdev); + kfree(pwm); + return NULL; + } - return pwmchip_remove(&twl6030->chip); + return pwm; } +EXPORT_SYMBOL(pwm_request); -static struct platform_driver twl6030_pwm_driver = { - .driver = { - .name = "twl6030-pwm", - }, - .probe = twl6030_pwm_probe, - .remove = __devexit_p(twl6030_pwm_remove), -}; -module_platform_driver(twl6030_pwm_driver); +void pwm_free(struct pwm_device *pwm) +{ + pwm_disable(pwm); + kfree(pwm); +} +EXPORT_SYMBOL(pwm_free); -MODULE_ALIAS("platform:twl6030-pwm"); MODULE_LICENSE("GPL"); diff --git a/trunk/drivers/mfd/twl6040-core.c b/trunk/drivers/mfd/twl6040-core.c index 3f2a1cf02fc0..3dca5c195a20 100644 --- a/trunk/drivers/mfd/twl6040-core.c +++ b/trunk/drivers/mfd/twl6040-core.c @@ -584,7 +584,7 @@ static int __devinit twl6040_probe(struct i2c_client *client, goto irq_init_err; ret = request_threaded_irq(twl6040->irq_base + TWL6040_IRQ_READY, - NULL, twl6040_naudint_handler, IRQF_ONESHOT, + NULL, twl6040_naudint_handler, 0, "twl6040_irq_ready", twl6040); if (ret) { dev_err(twl6040->dev, "READY IRQ request failed: %d\n", @@ -631,21 +631,6 @@ static int __devinit twl6040_probe(struct i2c_client *client, children++; } - /* - * Enable the GPO driver in the following cases: - * DT booted kernel or legacy boot with valid gpo platform_data - */ - if (!pdata || (pdata && pdata->gpo)) { - cell = &twl6040->cells[children]; - cell->name = "twl6040-gpo"; - - if (pdata) { - cell->platform_data = pdata->gpo; - cell->pdata_size = sizeof(*pdata->gpo); - } - children++; - } - ret = mfd_add_devices(&client->dev, -1, twl6040->cells, children, NULL, 0, NULL); if (ret) diff --git a/trunk/drivers/mfd/wm5110-tables.c b/trunk/drivers/mfd/wm5110-tables.c index adda6b10b90d..bd8782c8896b 100644 --- a/trunk/drivers/mfd/wm5110-tables.c +++ b/trunk/drivers/mfd/wm5110-tables.c @@ -133,109 +133,15 @@ static const struct reg_default wm5110_reva_patch[] = { { 0x209, 0x002A }, }; -static const struct reg_default wm5110_revb_patch[] = { - { 0x80, 0x3 }, - { 0x36e, 0x0210 }, - { 0x370, 0x0210 }, - { 0x372, 0x0210 }, - { 0x374, 0x0210 }, - { 0x376, 0x0210 }, - { 0x378, 0x0210 }, - { 0x36d, 0x0028 }, - { 0x36f, 0x0028 }, - { 0x371, 0x0028 }, - { 0x373, 0x0028 }, - { 0x375, 0x0028 }, - { 0x377, 0x0028 }, - { 0x280, 0x2002 }, - { 0x44, 0x20 }, - { 0x45, 0x40 }, - { 0x46, 0x60 }, - { 0x47, 0x80 }, - { 0x48, 0xa0 }, - { 0x51, 0x13 }, - { 0x52, 0x33 }, - { 0x53, 0x53 }, - { 0x54, 0x73 }, - { 0x55, 0x93 }, - { 0x56, 0xb3 }, - { 0xc30, 0x3e3e }, - { 0xc31, 0x3e }, - { 0xc32, 0x3e3e }, - { 0xc33, 0x3e3e }, - { 0xc34, 0x3e3e }, - { 0xc35, 0x3e3e }, - { 0xc36, 0x3e3e }, - { 0xc37, 0x3e3e }, - { 0xc38, 0x3e3e }, - { 0xc39, 0x3e3e }, - { 0xc3a, 0x3e3e }, - { 0xc3b, 0x3e3e }, - { 0xc3c, 0x3e }, - { 0x201, 0x18a5 }, - { 0x202, 0x4100 }, - { 0x460, 0x0c40 }, - { 0x461, 0x8000 }, - { 0x462, 0x0c41 }, - { 0x463, 0x4820 }, - { 0x464, 0x0c41 }, - { 0x465, 0x4040 }, - { 0x466, 0x0841 }, - { 0x467, 0x3940 }, - { 0x468, 0x0841 }, - { 0x469, 0x2030 }, - { 0x46a, 0x0842 }, - { 0x46b, 0x1990 }, - { 0x46c, 0x08c2 }, - { 0x46d, 0x1450 }, - { 0x46e, 0x08c6 }, - { 0x46f, 0x1020 }, - { 0x470, 0x08c6 }, - { 0x471, 0x0cd0 }, - { 0x472, 0x08c6 }, - { 0x473, 0x0a30 }, - { 0x474, 0x0442 }, - { 0x475, 0x0660 }, - { 0x476, 0x0446 }, - { 0x477, 0x0510 }, - { 0x478, 0x04c6 }, - { 0x479, 0x0400 }, - { 0x47a, 0x04ce }, - { 0x47b, 0x0330 }, - { 0x47c, 0x05df }, - { 0x47d, 0x0001 }, - { 0x47e, 0x07ff }, - { 0x2db, 0x0a00 }, - { 0x2dd, 0x0023 }, - { 0x2df, 0x0102 }, - { 0x2ef, 0x924 }, - { 0x2f0, 0x924 }, - { 0x2f1, 0x924 }, - { 0x2f2, 0x924 }, - { 0x2f3, 0x924 }, - { 0x2f4, 0x924 }, - { 0x2eb, 0x60 }, - { 0x2ec, 0x60 }, - { 0x2ed, 0x60 }, - { 0x4f2, 0x33e }, - { 0x458, 0x0000 }, - { 0x15a, 0x0003 }, - { 0x80, 0x0 }, -}; - /* We use a function so we can use ARRAY_SIZE() */ int wm5110_patch(struct arizona *arizona) { switch (arizona->rev) { case 0: + case 1: return regmap_register_patch(arizona->regmap, wm5110_reva_patch, ARRAY_SIZE(wm5110_reva_patch)); - case 1: - return regmap_register_patch(arizona->regmap, - wm5110_revb_patch, - ARRAY_SIZE(wm5110_revb_patch)); - default: return 0; } diff --git a/trunk/drivers/mfd/wm831x-core.c b/trunk/drivers/mfd/wm831x-core.c index 521340a708d3..301731035940 100644 --- a/trunk/drivers/mfd/wm831x-core.c +++ b/trunk/drivers/mfd/wm831x-core.c @@ -614,11 +614,18 @@ int wm831x_set_bits(struct wm831x *wm831x, unsigned short reg, } EXPORT_SYMBOL_GPL(wm831x_set_bits); +static struct resource wm831x_io_parent = { + .start = 0, + .end = 0xffffffff, + .flags = IORESOURCE_IO, +}; + static struct resource wm831x_dcdc1_resources[] = { { + .parent = &wm831x_io_parent, .start = WM831X_DC1_CONTROL_1, .end = WM831X_DC1_DVS_CONTROL, - .flags = IORESOURCE_REG, + .flags = IORESOURCE_IO, }, { .name = "UV", @@ -637,9 +644,10 @@ static struct resource wm831x_dcdc1_resources[] = { static struct resource wm831x_dcdc2_resources[] = { { + .parent = &wm831x_io_parent, .start = WM831X_DC2_CONTROL_1, .end = WM831X_DC2_DVS_CONTROL, - .flags = IORESOURCE_REG, + .flags = IORESOURCE_IO, }, { .name = "UV", @@ -657,9 +665,10 @@ static struct resource wm831x_dcdc2_resources[] = { static struct resource wm831x_dcdc3_resources[] = { { + .parent = &wm831x_io_parent, .start = WM831X_DC3_CONTROL_1, .end = WM831X_DC3_SLEEP_CONTROL, - .flags = IORESOURCE_REG, + .flags = IORESOURCE_IO, }, { .name = "UV", @@ -671,9 +680,10 @@ static struct resource wm831x_dcdc3_resources[] = { static struct resource wm831x_dcdc4_resources[] = { { + .parent = &wm831x_io_parent, .start = WM831X_DC4_CONTROL, .end = WM831X_DC4_SLEEP_CONTROL, - .flags = IORESOURCE_REG, + .flags = IORESOURCE_IO, }, { .name = "UV", @@ -685,9 +695,10 @@ static struct resource wm831x_dcdc4_resources[] = { static struct resource wm8320_dcdc4_buck_resources[] = { { + .parent = &wm831x_io_parent, .start = WM831X_DC4_CONTROL, .end = WM832X_DC4_SLEEP_CONTROL, - .flags = IORESOURCE_REG, + .flags = IORESOURCE_IO, }, { .name = "UV", @@ -707,9 +718,10 @@ static struct resource wm831x_gpio_resources[] = { static struct resource wm831x_isink1_resources[] = { { + .parent = &wm831x_io_parent, .start = WM831X_CURRENT_SINK_1, .end = WM831X_CURRENT_SINK_1, - .flags = IORESOURCE_REG, + .flags = IORESOURCE_IO, }, { .start = WM831X_IRQ_CS1, @@ -720,9 +732,10 @@ static struct resource wm831x_isink1_resources[] = { static struct resource wm831x_isink2_resources[] = { { + .parent = &wm831x_io_parent, .start = WM831X_CURRENT_SINK_2, .end = WM831X_CURRENT_SINK_2, - .flags = IORESOURCE_REG, + .flags = IORESOURCE_IO, }, { .start = WM831X_IRQ_CS2, @@ -733,9 +746,10 @@ static struct resource wm831x_isink2_resources[] = { static struct resource wm831x_ldo1_resources[] = { { + .parent = &wm831x_io_parent, .start = WM831X_LDO1_CONTROL, .end = WM831X_LDO1_SLEEP_CONTROL, - .flags = IORESOURCE_REG, + .flags = IORESOURCE_IO, }, { .name = "UV", @@ -747,9 +761,10 @@ static struct resource wm831x_ldo1_resources[] = { static struct resource wm831x_ldo2_resources[] = { { + .parent = &wm831x_io_parent, .start = WM831X_LDO2_CONTROL, .end = WM831X_LDO2_SLEEP_CONTROL, - .flags = IORESOURCE_REG, + .flags = IORESOURCE_IO, }, { .name = "UV", @@ -761,9 +776,10 @@ static struct resource wm831x_ldo2_resources[] = { static struct resource wm831x_ldo3_resources[] = { { + .parent = &wm831x_io_parent, .start = WM831X_LDO3_CONTROL, .end = WM831X_LDO3_SLEEP_CONTROL, - .flags = IORESOURCE_REG, + .flags = IORESOURCE_IO, }, { .name = "UV", @@ -775,9 +791,10 @@ static struct resource wm831x_ldo3_resources[] = { static struct resource wm831x_ldo4_resources[] = { { + .parent = &wm831x_io_parent, .start = WM831X_LDO4_CONTROL, .end = WM831X_LDO4_SLEEP_CONTROL, - .flags = IORESOURCE_REG, + .flags = IORESOURCE_IO, }, { .name = "UV", @@ -789,9 +806,10 @@ static struct resource wm831x_ldo4_resources[] = { static struct resource wm831x_ldo5_resources[] = { { + .parent = &wm831x_io_parent, .start = WM831X_LDO5_CONTROL, .end = WM831X_LDO5_SLEEP_CONTROL, - .flags = IORESOURCE_REG, + .flags = IORESOURCE_IO, }, { .name = "UV", @@ -803,9 +821,10 @@ static struct resource wm831x_ldo5_resources[] = { static struct resource wm831x_ldo6_resources[] = { { + .parent = &wm831x_io_parent, .start = WM831X_LDO6_CONTROL, .end = WM831X_LDO6_SLEEP_CONTROL, - .flags = IORESOURCE_REG, + .flags = IORESOURCE_IO, }, { .name = "UV", @@ -817,9 +836,10 @@ static struct resource wm831x_ldo6_resources[] = { static struct resource wm831x_ldo7_resources[] = { { + .parent = &wm831x_io_parent, .start = WM831X_LDO7_CONTROL, .end = WM831X_LDO7_SLEEP_CONTROL, - .flags = IORESOURCE_REG, + .flags = IORESOURCE_IO, }, { .name = "UV", @@ -831,9 +851,10 @@ static struct resource wm831x_ldo7_resources[] = { static struct resource wm831x_ldo8_resources[] = { { + .parent = &wm831x_io_parent, .start = WM831X_LDO8_CONTROL, .end = WM831X_LDO8_SLEEP_CONTROL, - .flags = IORESOURCE_REG, + .flags = IORESOURCE_IO, }, { .name = "UV", @@ -845,9 +866,10 @@ static struct resource wm831x_ldo8_resources[] = { static struct resource wm831x_ldo9_resources[] = { { + .parent = &wm831x_io_parent, .start = WM831X_LDO9_CONTROL, .end = WM831X_LDO9_SLEEP_CONTROL, - .flags = IORESOURCE_REG, + .flags = IORESOURCE_IO, }, { .name = "UV", @@ -859,9 +881,10 @@ static struct resource wm831x_ldo9_resources[] = { static struct resource wm831x_ldo10_resources[] = { { + .parent = &wm831x_io_parent, .start = WM831X_LDO10_CONTROL, .end = WM831X_LDO10_SLEEP_CONTROL, - .flags = IORESOURCE_REG, + .flags = IORESOURCE_IO, }, { .name = "UV", @@ -873,9 +896,10 @@ static struct resource wm831x_ldo10_resources[] = { static struct resource wm831x_ldo11_resources[] = { { + .parent = &wm831x_io_parent, .start = WM831X_LDO11_ON_CONTROL, .end = WM831X_LDO11_SLEEP_CONTROL, - .flags = IORESOURCE_REG, + .flags = IORESOURCE_IO, }, }; @@ -974,17 +998,19 @@ static struct resource wm831x_rtc_resources[] = { static struct resource wm831x_status1_resources[] = { { + .parent = &wm831x_io_parent, .start = WM831X_STATUS_LED_1, .end = WM831X_STATUS_LED_1, - .flags = IORESOURCE_REG, + .flags = IORESOURCE_IO, }, }; static struct resource wm831x_status2_resources[] = { { + .parent = &wm831x_io_parent, .start = WM831X_STATUS_LED_2, .end = WM831X_STATUS_LED_2, - .flags = IORESOURCE_REG, + .flags = IORESOURCE_IO, }, }; diff --git a/trunk/drivers/mfd/wm8994-core.c b/trunk/drivers/mfd/wm8994-core.c index 8fefc961ec06..2febf88cfce8 100644 --- a/trunk/drivers/mfd/wm8994-core.c +++ b/trunk/drivers/mfd/wm8994-core.c @@ -374,23 +374,23 @@ static int wm8994_ldo_in_use(struct wm8994_pdata *pdata, int ldo) } #endif -static const __devinitconst struct reg_default wm8994_revc_patch[] = { +static const __devinitdata struct reg_default wm8994_revc_patch[] = { { 0x102, 0x3 }, { 0x56, 0x3 }, { 0x817, 0x0 }, { 0x102, 0x0 }, }; -static const __devinitconst struct reg_default wm8958_reva_patch[] = { +static const __devinitdata struct reg_default wm8958_reva_patch[] = { { 0x102, 0x3 }, { 0xcb, 0x81 }, { 0x817, 0x0 }, { 0x102, 0x0 }, }; -static const __devinitconst struct reg_default wm1811_reva_patch[] = { +static const __devinitdata struct reg_default wm1811_reva_patch[] = { { 0x102, 0x3 }, - { 0x56, 0xc07 }, + { 0x56, 0x7 }, { 0x5d, 0x7e }, { 0x5e, 0x0 }, { 0x102, 0x0 }, diff --git a/trunk/drivers/mfd/wm8994-regmap.c b/trunk/drivers/mfd/wm8994-regmap.c index 2fbce9c5950b..52e9e2944940 100644 --- a/trunk/drivers/mfd/wm8994-regmap.c +++ b/trunk/drivers/mfd/wm8994-regmap.c @@ -1136,7 +1136,7 @@ static bool wm1811_volatile_register(struct device *dev, unsigned int reg) switch (reg) { case WM8994_GPIO_6: - if (wm8994->cust_id > 1 || wm8994->revision > 1) + if (wm8994->revision > 1) return true; else return false; diff --git a/trunk/drivers/mmc/host/sdhci-pci.c b/trunk/drivers/mmc/host/sdhci-pci.c index 9722d43d6140..504da715a41a 100644 --- a/trunk/drivers/mmc/host/sdhci-pci.c +++ b/trunk/drivers/mmc/host/sdhci-pci.c @@ -653,7 +653,7 @@ static const struct sdhci_pci_fixes sdhci_via = { .probe = via_probe, }; -static const struct pci_device_id pci_ids[] __devinitconst = { +static const struct pci_device_id pci_ids[] __devinitdata = { { .vendor = PCI_VENDOR_ID_RICOH, .device = PCI_DEVICE_ID_RICOH_R5C822, diff --git a/trunk/drivers/mtd/nand/fsl_ifc_nand.c b/trunk/drivers/mtd/nand/fsl_ifc_nand.c index 01e2f2e87d8c..9602c1b7e27e 100644 --- a/trunk/drivers/mtd/nand/fsl_ifc_nand.c +++ b/trunk/drivers/mtd/nand/fsl_ifc_nand.c @@ -31,7 +31,6 @@ #include #include -#define FSL_IFC_V1_1_0 0x01010000 #define ERR_BYTE 0xFF /* Value returned for read bytes when read failed */ #define IFC_TIMEOUT_MSECS 500 /* Maximum number of mSecs to wait @@ -774,62 +773,13 @@ static int fsl_ifc_chip_init_tail(struct mtd_info *mtd) return 0; } -static void fsl_ifc_sram_init(struct fsl_ifc_mtd *priv) -{ - struct fsl_ifc_ctrl *ctrl = priv->ctrl; - struct fsl_ifc_regs __iomem *ifc = ctrl->regs; - uint32_t csor = 0, csor_8k = 0, csor_ext = 0; - uint32_t cs = priv->bank; - - /* Save CSOR and CSOR_ext */ - csor = in_be32(&ifc->csor_cs[cs].csor); - csor_ext = in_be32(&ifc->csor_cs[cs].csor_ext); - - /* chage PageSize 8K and SpareSize 1K*/ - csor_8k = (csor & ~(CSOR_NAND_PGS_MASK)) | 0x0018C000; - out_be32(&ifc->csor_cs[cs].csor, csor_8k); - out_be32(&ifc->csor_cs[cs].csor_ext, 0x0000400); - - /* READID */ - out_be32(&ifc->ifc_nand.nand_fir0, - (IFC_FIR_OP_CMD0 << IFC_NAND_FIR0_OP0_SHIFT) | - (IFC_FIR_OP_UA << IFC_NAND_FIR0_OP1_SHIFT) | - (IFC_FIR_OP_RB << IFC_NAND_FIR0_OP2_SHIFT)); - out_be32(&ifc->ifc_nand.nand_fcr0, - NAND_CMD_READID << IFC_NAND_FCR0_CMD0_SHIFT); - out_be32(&ifc->ifc_nand.row3, 0x0); - - out_be32(&ifc->ifc_nand.nand_fbcr, 0x0); - - /* Program ROW0/COL0 */ - out_be32(&ifc->ifc_nand.row0, 0x0); - out_be32(&ifc->ifc_nand.col0, 0x0); - - /* set the chip select for NAND Transaction */ - out_be32(&ifc->ifc_nand.nand_csel, cs << IFC_NAND_CSEL_SHIFT); - - /* start read seq */ - out_be32(&ifc->ifc_nand.nandseq_strt, IFC_NAND_SEQ_STRT_FIR_STRT); - - /* wait for command complete flag or timeout */ - wait_event_timeout(ctrl->nand_wait, ctrl->nand_stat, - IFC_TIMEOUT_MSECS * HZ/1000); - - if (ctrl->nand_stat != IFC_NAND_EVTER_STAT_OPC) - printk(KERN_ERR "fsl-ifc: Failed to Initialise SRAM\n"); - - /* Restore CSOR and CSOR_ext */ - out_be32(&ifc->csor_cs[cs].csor, csor); - out_be32(&ifc->csor_cs[cs].csor_ext, csor_ext); -} - static int fsl_ifc_chip_init(struct fsl_ifc_mtd *priv) { struct fsl_ifc_ctrl *ctrl = priv->ctrl; struct fsl_ifc_regs __iomem *ifc = ctrl->regs; struct nand_chip *chip = &priv->chip; struct nand_ecclayout *layout; - u32 csor, ver; + u32 csor; /* Fill in fsl_ifc_mtd structure */ priv->mtd.priv = chip; @@ -924,10 +874,6 @@ static int fsl_ifc_chip_init(struct fsl_ifc_mtd *priv) chip->ecc.mode = NAND_ECC_SOFT; } - ver = in_be32(&ifc->ifc_rev); - if (ver == FSL_IFC_V1_1_0) - fsl_ifc_sram_init(priv); - return 0; } diff --git a/trunk/drivers/net/bonding/bond_main.c b/trunk/drivers/net/bonding/bond_main.c index b721902bb6b4..7858c58df4a3 100644 --- a/trunk/drivers/net/bonding/bond_main.c +++ b/trunk/drivers/net/bonding/bond_main.c @@ -4826,7 +4826,6 @@ static int bond_check_params(struct bond_params *params) static struct lock_class_key bonding_netdev_xmit_lock_key; static struct lock_class_key bonding_netdev_addr_lock_key; -static struct lock_class_key bonding_tx_busylock_key; static void bond_set_lockdep_class_one(struct net_device *dev, struct netdev_queue *txq, @@ -4841,7 +4840,6 @@ static void bond_set_lockdep_class(struct net_device *dev) lockdep_set_class(&dev->addr_list_lock, &bonding_netdev_addr_lock_key); netdev_for_each_tx_queue(dev, bond_set_lockdep_class_one, NULL); - dev->qdisc_tx_busylock = &bonding_tx_busylock_key; } /* diff --git a/trunk/drivers/net/can/mscan/mpc5xxx_can.c b/trunk/drivers/net/can/mscan/mpc5xxx_can.c index 799c354083c4..c975999bb055 100644 --- a/trunk/drivers/net/can/mscan/mpc5xxx_can.c +++ b/trunk/drivers/net/can/mscan/mpc5xxx_can.c @@ -247,7 +247,7 @@ static u32 __devinit mpc512x_can_get_clock(struct platform_device *ofdev, } #endif /* CONFIG_PPC_MPC512x */ -static const struct of_device_id mpc5xxx_can_table[]; +static struct of_device_id mpc5xxx_can_table[]; static int __devinit mpc5xxx_can_probe(struct platform_device *ofdev) { const struct of_device_id *match; @@ -380,17 +380,17 @@ static int mpc5xxx_can_resume(struct platform_device *ofdev) } #endif -static const struct mpc5xxx_can_data __devinitconst mpc5200_can_data = { +static const struct mpc5xxx_can_data __devinitdata mpc5200_can_data = { .type = MSCAN_TYPE_MPC5200, .get_clock = mpc52xx_can_get_clock, }; -static const struct mpc5xxx_can_data __devinitconst mpc5121_can_data = { +static const struct mpc5xxx_can_data __devinitdata mpc5121_can_data = { .type = MSCAN_TYPE_MPC5121, .get_clock = mpc512x_can_get_clock, }; -static const struct of_device_id __devinitconst mpc5xxx_can_table[] = { +static struct of_device_id __devinitdata mpc5xxx_can_table[] = { { .compatible = "fsl,mpc5200-mscan", .data = &mpc5200_can_data, }, /* Note that only MPC5121 Rev. 2 (and later) is supported */ { .compatible = "fsl,mpc5121-mscan", .data = &mpc5121_can_data, }, diff --git a/trunk/drivers/net/can/sja1000/peak_pci.c b/trunk/drivers/net/can/sja1000/peak_pci.c index f5b82aeb2540..f0a12962f7b6 100644 --- a/trunk/drivers/net/can/sja1000/peak_pci.c +++ b/trunk/drivers/net/can/sja1000/peak_pci.c @@ -583,14 +583,12 @@ static int __devinit peak_pci_probe(struct pci_dev *pdev, cfg_base = pci_iomap(pdev, 0, PEAK_PCI_CFG_SIZE); if (!cfg_base) { dev_err(&pdev->dev, "failed to map PCI resource #0\n"); - err = -ENOMEM; goto failure_release_regions; } reg_base = pci_iomap(pdev, 1, PEAK_PCI_CHAN_SIZE * channels); if (!reg_base) { dev_err(&pdev->dev, "failed to map PCI resource #1\n"); - err = -ENOMEM; goto failure_unmap_cfg_base; } diff --git a/trunk/drivers/net/can/sja1000/peak_pcmcia.c b/trunk/drivers/net/can/sja1000/peak_pcmcia.c index 272a85f32b14..ec6bd9d1b2af 100644 --- a/trunk/drivers/net/can/sja1000/peak_pcmcia.c +++ b/trunk/drivers/net/can/sja1000/peak_pcmcia.c @@ -686,10 +686,8 @@ static int __devinit pcan_probe(struct pcmcia_device *pdev) /* detect available channels */ pcan_add_channels(card); - if (!card->chan_count) { - err = -ENOMEM; + if (!card->chan_count) goto probe_err_4; - } /* init the timer which controls the leds */ init_timer(&card->led_timer); diff --git a/trunk/drivers/net/can/slcan.c b/trunk/drivers/net/can/slcan.c index adc3708d8829..034c16b60e96 100644 --- a/trunk/drivers/net/can/slcan.c +++ b/trunk/drivers/net/can/slcan.c @@ -56,7 +56,7 @@ #include #include -static __initconst const char banner[] = +static __initdata const char banner[] = KERN_INFO "slcan: serial line CAN interface driver\n"; MODULE_ALIAS_LDISC(N_SLCAN); diff --git a/trunk/drivers/net/can/vcan.c b/trunk/drivers/net/can/vcan.c index 0a2a5ee79a17..4f93c0be0053 100644 --- a/trunk/drivers/net/can/vcan.c +++ b/trunk/drivers/net/can/vcan.c @@ -49,7 +49,7 @@ #include #include -static __initconst const char banner[] = +static __initdata const char banner[] = KERN_INFO "vcan: Virtual CAN interface driver\n"; MODULE_DESCRIPTION("virtual CAN interface"); diff --git a/trunk/drivers/net/ethernet/8390/ne3210.c b/trunk/drivers/net/ethernet/8390/ne3210.c index e3f57427d5c5..a2f8b2b8e27c 100644 --- a/trunk/drivers/net/ethernet/8390/ne3210.c +++ b/trunk/drivers/net/ethernet/8390/ne3210.c @@ -81,7 +81,7 @@ static void ne3210_block_output(struct net_device *dev, int count, const unsigne static unsigned char irq_map[] __initdata = {15, 12, 11, 10, 9, 7, 5, 3}; static unsigned int shmem_map[] __initdata = {0xff0, 0xfe0, 0xfff0, 0xd8, 0xffe0, 0xffc0, 0xd0, 0x0}; -static const char * const ifmap[] __initconst = {"UTP", "?", "BNC", "AUI"}; +static const char *ifmap[] __initdata = {"UTP", "?", "BNC", "AUI"}; static int ifmap_val[] __initdata = { IF_PORT_10BASET, IF_PORT_UNKNOWN, diff --git a/trunk/drivers/net/ethernet/adaptec/starfire.c b/trunk/drivers/net/ethernet/adaptec/starfire.c index 5b65992c2a0a..d920a529ba22 100644 --- a/trunk/drivers/net/ethernet/adaptec/starfire.c +++ b/trunk/drivers/net/ethernet/adaptec/starfire.c @@ -295,7 +295,7 @@ MODULE_DEVICE_TABLE(pci, starfire_pci_tbl); static const struct chip_info { const char *name; int drv_flags; -} netdrv_tbl[] __devinitconst = { +} netdrv_tbl[] __devinitdata = { { "Adaptec Starfire 6915", CanHaveMII }, }; diff --git a/trunk/drivers/net/ethernet/atheros/atl1c/atl1c_main.c b/trunk/drivers/net/ethernet/atheros/atl1c/atl1c_main.c index d19f82f7597a..55a2e3795055 100644 --- a/trunk/drivers/net/ethernet/atheros/atl1c/atl1c_main.c +++ b/trunk/drivers/net/ethernet/atheros/atl1c/atl1c_main.c @@ -702,7 +702,7 @@ struct atl1c_platform_patch { u32 patch_flag; #define ATL1C_LINK_PATCH 0x1 }; -static const struct atl1c_platform_patch plats[] __devinitconst = { +static const struct atl1c_platform_patch plats[] __devinitdata = { {0x2060, 0xC1, 0x1019, 0x8152, 0x1}, {0x2060, 0xC1, 0x1019, 0x2060, 0x1}, {0x2060, 0xC1, 0x1019, 0xE000, 0x1}, diff --git a/trunk/drivers/net/ethernet/atheros/atlx/atl2.c b/trunk/drivers/net/ethernet/atheros/atlx/atl2.c index 623dd8635c46..57d64b80fd72 100644 --- a/trunk/drivers/net/ethernet/atheros/atlx/atl2.c +++ b/trunk/drivers/net/ethernet/atheros/atlx/atl2.c @@ -2845,7 +2845,7 @@ static void atl2_force_ps(struct atl2_hw *hw) */ #define ATL2_PARAM(X, desc) \ - static const int __devinitconst X[ATL2_MAX_NIC + 1] = ATL2_PARAM_INIT; \ + static const int __devinitdata X[ATL2_MAX_NIC + 1] = ATL2_PARAM_INIT; \ MODULE_PARM(X, "1-" __MODULE_STRING(ATL2_MAX_NIC) "i"); \ MODULE_PARM_DESC(X, desc); #else diff --git a/trunk/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.c b/trunk/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.c index 24220992413f..30f04a389227 100644 --- a/trunk/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.c +++ b/trunk/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.c @@ -3523,18 +3523,15 @@ static int bnx2x_alloc_fp_mem_at(struct bnx2x *bp, int index) } else #endif if (!bp->rx_ring_size) { - rx_ring_size = MAX_RX_AVAIL/BNX2X_NUM_RX_QUEUES(bp); + u32 cfg = SHMEM_RD(bp, + dev_info.port_hw_config[BP_PORT(bp)].default_cfg); - if (CHIP_IS_E3(bp)) { - u32 cfg = SHMEM_RD(bp, - dev_info.port_hw_config[BP_PORT(bp)]. - default_cfg); + rx_ring_size = MAX_RX_AVAIL/BNX2X_NUM_RX_QUEUES(bp); - /* Decrease ring size for 1G functions */ - if ((cfg & PORT_HW_CFG_NET_SERDES_IF_MASK) == - PORT_HW_CFG_NET_SERDES_IF_SGMII) - rx_ring_size /= 10; - } + /* Dercease ring size for 1G functions */ + if ((cfg & PORT_HW_CFG_NET_SERDES_IF_MASK) == + PORT_HW_CFG_NET_SERDES_IF_SGMII) + rx_ring_size /= 10; /* allocate at least number of buffers required by FW */ rx_ring_size = max_t(int, bp->disable_tpa ? MIN_RX_SIZE_NONTPA : diff --git a/trunk/drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c b/trunk/drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c index d5648fc666bd..f7ed122f4071 100644 --- a/trunk/drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c +++ b/trunk/drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c @@ -3052,8 +3052,9 @@ static void bnx2x_drv_info_ether_stat(struct bnx2x *bp) struct eth_stats_info *ether_stat = &bp->slowpath->drv_info_to_mcp.ether_stat; - strlcpy(ether_stat->version, DRV_MODULE_VERSION, - ETH_STAT_INFO_VERSION_LEN); + /* leave last char as NULL */ + memcpy(ether_stat->version, DRV_MODULE_VERSION, + ETH_STAT_INFO_VERSION_LEN - 1); bp->sp_objs[0].mac_obj.get_n_elements(bp, &bp->sp_objs[0].mac_obj, DRV_INFO_ETH_STAT_NUM_MACS_REQUIRED, diff --git a/trunk/drivers/net/ethernet/broadcom/tg3.c b/trunk/drivers/net/ethernet/broadcom/tg3.c index a8800ac10df9..46280ba4c5d4 100644 --- a/trunk/drivers/net/ethernet/broadcom/tg3.c +++ b/trunk/drivers/net/ethernet/broadcom/tg3.c @@ -782,8 +782,7 @@ static int tg3_ape_wait_for_event(struct tg3 *tp, u32 timeout_us) return i == timeout_us / 10; } -static int tg3_ape_scratchpad_read(struct tg3 *tp, u32 *data, u32 base_off, - u32 len) +int tg3_ape_scratchpad_read(struct tg3 *tp, u32 *data, u32 base_off, u32 len) { int err; u32 i, bufoff, msgoff, maxlen, apedata; @@ -7764,7 +7763,7 @@ static int tg3_alloc_consistent(struct tg3 *tp) sblk = tnapi->hw_status; if (tg3_flag(tp, ENABLE_RSS)) { - u16 *prodptr = NULL; + u16 *prodptr = 0; /* * When RSS is enabled, the status block format changes @@ -8104,11 +8103,11 @@ static int tg3_chip_reset(struct tg3 *tp) u16 val16; if (tp->pci_chip_rev_id == CHIPREV_ID_5750_A0) { - int j; + int i; u32 cfg_val; /* Wait for link training to complete. */ - for (j = 0; j < 5000; j++) + for (i = 0; i < 5000; i++) udelay(100); pci_read_config_dword(tp->pdev, 0xc4, &cfg_val); @@ -10207,7 +10206,7 @@ static u32 tg3_irq_count(struct tg3 *tp) static bool tg3_enable_msix(struct tg3 *tp) { int i, rc; - struct msix_entry msix_ent[TG3_IRQ_MAX_VECS]; + struct msix_entry msix_ent[tp->irq_max]; tp->txq_cnt = tp->txq_req; tp->rxq_cnt = tp->rxq_req; diff --git a/trunk/drivers/net/ethernet/chelsio/cxgb4/cxgb4.h b/trunk/drivers/net/ethernet/chelsio/cxgb4/cxgb4.h index 31752b24434e..745a1f53361f 100644 --- a/trunk/drivers/net/ethernet/chelsio/cxgb4/cxgb4.h +++ b/trunk/drivers/net/ethernet/chelsio/cxgb4/cxgb4.h @@ -43,7 +43,6 @@ #include #include #include -#include #include #include "cxgb4_uld.h" #include "t4_hw.h" diff --git a/trunk/drivers/net/ethernet/chelsio/cxgb4/t4_hw.c b/trunk/drivers/net/ethernet/chelsio/cxgb4/t4_hw.c index 137a24438d9c..35b81d8b59e9 100644 --- a/trunk/drivers/net/ethernet/chelsio/cxgb4/t4_hw.c +++ b/trunk/drivers/net/ethernet/chelsio/cxgb4/t4_hw.c @@ -408,8 +408,7 @@ static int t4_memory_rw(struct adapter *adap, int mtype, u32 addr, u32 len, __be32 *buf, int dir) { u32 pos, start, end, offset, memoffset; - int ret = 0; - __be32 *data; + int ret; /* * Argument sanity checks ... @@ -417,10 +416,6 @@ static int t4_memory_rw(struct adapter *adap, int mtype, u32 addr, u32 len, if ((addr & 0x3) || (len & 0x3)) return -EINVAL; - data = vmalloc(MEMWIN0_APERTURE/sizeof(__be32)); - if (!data) - return -ENOMEM; - /* * Offset into the region of memory which is being accessed * MEM_EDC0 = 0 @@ -443,6 +438,7 @@ static int t4_memory_rw(struct adapter *adap, int mtype, u32 addr, u32 len, offset = (addr - start)/sizeof(__be32); for (pos = start; pos < end; pos += MEMWIN0_APERTURE, offset = 0) { + __be32 data[MEMWIN0_APERTURE/sizeof(__be32)]; /* * If we're writing, copy the data from the caller's memory @@ -456,7 +452,7 @@ static int t4_memory_rw(struct adapter *adap, int mtype, u32 addr, u32 len, if (offset || len < MEMWIN0_APERTURE) { ret = t4_mem_win_rw(adap, pos, data, 1); if (ret) - break; + return ret; } while (offset < (MEMWIN0_APERTURE/sizeof(__be32)) && len > 0) { @@ -470,7 +466,7 @@ static int t4_memory_rw(struct adapter *adap, int mtype, u32 addr, u32 len, */ ret = t4_mem_win_rw(adap, pos, data, dir); if (ret) - break; + return ret; /* * If we're reading, copy the data into the caller's memory @@ -484,8 +480,7 @@ static int t4_memory_rw(struct adapter *adap, int mtype, u32 addr, u32 len, } } - vfree(data); - return ret; + return 0; } int t4_memory_write(struct adapter *adap, int mtype, u32 addr, u32 len, @@ -524,21 +519,16 @@ int get_vpd_params(struct adapter *adapter, struct vpd_params *p) u32 cclk_param, cclk_val; int i, ret; int ec, sn; - u8 *vpd, csum; + u8 vpd[VPD_LEN], csum; unsigned int vpdr_len, kw_offset, id_len; - vpd = vmalloc(VPD_LEN); - if (!vpd) - return -ENOMEM; - - ret = pci_read_vpd(adapter->pdev, VPD_BASE, VPD_LEN, vpd); + ret = pci_read_vpd(adapter->pdev, VPD_BASE, sizeof(vpd), vpd); if (ret < 0) - goto out; + return ret; if (vpd[0] != PCI_VPD_LRDT_ID_STRING) { dev_err(adapter->pdev_dev, "missing VPD ID string\n"); - ret = -EINVAL; - goto out; + return -EINVAL; } id_len = pci_vpd_lrdt_size(vpd); @@ -548,24 +538,21 @@ int get_vpd_params(struct adapter *adapter, struct vpd_params *p) i = pci_vpd_find_tag(vpd, 0, VPD_LEN, PCI_VPD_LRDT_RO_DATA); if (i < 0) { dev_err(adapter->pdev_dev, "missing VPD-R section\n"); - ret = -EINVAL; - goto out; + return -EINVAL; } vpdr_len = pci_vpd_lrdt_size(&vpd[i]); kw_offset = i + PCI_VPD_LRDT_TAG_SIZE; if (vpdr_len + kw_offset > VPD_LEN) { dev_err(adapter->pdev_dev, "bad VPD-R length %u\n", vpdr_len); - ret = -EINVAL; - goto out; + return -EINVAL; } #define FIND_VPD_KW(var, name) do { \ var = pci_vpd_find_info_keyword(vpd, kw_offset, vpdr_len, name); \ if (var < 0) { \ dev_err(adapter->pdev_dev, "missing VPD keyword " name "\n"); \ - ret = -EINVAL; \ - goto out; \ + return -EINVAL; \ } \ var += PCI_VPD_INFO_FLD_HDR_SIZE; \ } while (0) @@ -577,8 +564,7 @@ int get_vpd_params(struct adapter *adapter, struct vpd_params *p) if (csum) { dev_err(adapter->pdev_dev, "corrupted VPD EEPROM, actual csum %u\n", csum); - ret = -EINVAL; - goto out; + return -EINVAL; } FIND_VPD_KW(ec, "EC"); @@ -601,9 +587,6 @@ int get_vpd_params(struct adapter *adapter, struct vpd_params *p) FW_PARAMS_PARAM_X(FW_PARAMS_PARAM_DEV_CCLK)); ret = t4_query_params(adapter, adapter->mbox, 0, 0, 1, &cclk_param, &cclk_val); - -out: - vfree(vpd); if (ret) return ret; p->cclk = cclk_val; diff --git a/trunk/drivers/net/ethernet/dec/tulip/de2104x.c b/trunk/drivers/net/ethernet/dec/tulip/de2104x.c index 77335853ac36..61cc09342865 100644 --- a/trunk/drivers/net/ethernet/dec/tulip/de2104x.c +++ b/trunk/drivers/net/ethernet/dec/tulip/de2104x.c @@ -661,6 +661,9 @@ static netdev_tx_t de_start_xmit (struct sk_buff *skb, new frame, not around filling de->setup_frame. This is non-deterministic when re-entered but still correct. */ +#undef set_bit_le +#define set_bit_le(i,p) do { ((char *)(p))[(i)/8] |= (1<<((i)%8)); } while(0) + static void build_setup_frame_hash(u16 *setup_frm, struct net_device *dev) { struct de_private *de = netdev_priv(dev); @@ -670,12 +673,12 @@ static void build_setup_frame_hash(u16 *setup_frm, struct net_device *dev) u16 *eaddrs; memset(hash_table, 0, sizeof(hash_table)); - __set_bit_le(255, hash_table); /* Broadcast entry */ + set_bit_le(255, hash_table); /* Broadcast entry */ /* This should work on big-endian machines as well. */ netdev_for_each_mc_addr(ha, dev) { int index = ether_crc_le(ETH_ALEN, ha->addr) & 0x1ff; - __set_bit_le(index, hash_table); + set_bit_le(index, hash_table); } for (i = 0; i < 32; i++) { diff --git a/trunk/drivers/net/ethernet/dec/tulip/eeprom.c b/trunk/drivers/net/ethernet/dec/tulip/eeprom.c index 44f7e8e82d85..ed7d1dcd9566 100644 --- a/trunk/drivers/net/ethernet/dec/tulip/eeprom.c +++ b/trunk/drivers/net/ethernet/dec/tulip/eeprom.c @@ -79,7 +79,7 @@ static struct eeprom_fixup eeprom_fixups[] __devinitdata = { {NULL}}; -static const char *const block_name[] __devinitconst = { +static const char *block_name[] __devinitdata = { "21140 non-MII", "21140 MII PHY", "21142 Serial PHY", diff --git a/trunk/drivers/net/ethernet/dec/tulip/tulip_core.c b/trunk/drivers/net/ethernet/dec/tulip/tulip_core.c index 885700a19978..c4f37aca2269 100644 --- a/trunk/drivers/net/ethernet/dec/tulip/tulip_core.c +++ b/trunk/drivers/net/ethernet/dec/tulip/tulip_core.c @@ -1010,6 +1010,9 @@ static int private_ioctl (struct net_device *dev, struct ifreq *rq, int cmd) new frame, not around filling tp->setup_frame. This is non-deterministic when re-entered but still correct. */ +#undef set_bit_le +#define set_bit_le(i,p) do { ((char *)(p))[(i)/8] |= (1<<((i)%8)); } while(0) + static void build_setup_frame_hash(u16 *setup_frm, struct net_device *dev) { struct tulip_private *tp = netdev_priv(dev); @@ -1019,12 +1022,12 @@ static void build_setup_frame_hash(u16 *setup_frm, struct net_device *dev) u16 *eaddrs; memset(hash_table, 0, sizeof(hash_table)); - __set_bit_le(255, hash_table); /* Broadcast entry */ + set_bit_le(255, hash_table); /* Broadcast entry */ /* This should work on big-endian machines as well. */ netdev_for_each_mc_addr(ha, dev) { int index = ether_crc_le(ETH_ALEN, ha->addr) & 0x1ff; - __set_bit_le(index, hash_table); + set_bit_le(index, hash_table); } for (i = 0; i < 32; i++) { *setup_frm++ = hash_table[i]; diff --git a/trunk/drivers/net/ethernet/dec/tulip/winbond-840.c b/trunk/drivers/net/ethernet/dec/tulip/winbond-840.c index 7c1ec4d7920b..4d1ffca83c82 100644 --- a/trunk/drivers/net/ethernet/dec/tulip/winbond-840.c +++ b/trunk/drivers/net/ethernet/dec/tulip/winbond-840.c @@ -236,7 +236,7 @@ struct pci_id_info { int drv_flags; /* Driver use, intended as capability flags. */ }; -static const struct pci_id_info pci_id_tbl[] __devinitconst = { +static const struct pci_id_info pci_id_tbl[] __devinitdata = { { /* Sometime a Level-One switch card. */ "Winbond W89c840", CanHaveMII | HasBrokenTx | FDXOnNoMII}, { "Winbond W89c840", CanHaveMII | HasBrokenTx}, diff --git a/trunk/drivers/net/ethernet/dlink/sundance.c b/trunk/drivers/net/ethernet/dlink/sundance.c index 3b83588e51f6..d7bb52a7bda1 100644 --- a/trunk/drivers/net/ethernet/dlink/sundance.c +++ b/trunk/drivers/net/ethernet/dlink/sundance.c @@ -218,7 +218,7 @@ enum { struct pci_id_info { const char *name; }; -static const struct pci_id_info pci_id_tbl[] __devinitconst = { +static const struct pci_id_info pci_id_tbl[] __devinitdata = { {"D-Link DFE-550TX FAST Ethernet Adapter"}, {"D-Link DFE-550FX 100Mbps Fiber-optics Adapter"}, {"D-Link DFE-580TX 4 port Server Adapter"}, diff --git a/trunk/drivers/net/ethernet/fealnx.c b/trunk/drivers/net/ethernet/fealnx.c index 0e4a0ac86aa8..9d71c9cc300b 100644 --- a/trunk/drivers/net/ethernet/fealnx.c +++ b/trunk/drivers/net/ethernet/fealnx.c @@ -150,7 +150,7 @@ struct chip_info { int flags; }; -static const struct chip_info skel_netdrv_tbl[] __devinitconst = { +static const struct chip_info skel_netdrv_tbl[] __devinitdata = { { "100/10M Ethernet PCI Adapter", HAS_MII_XCVR }, { "100/10M Ethernet PCI Adapter", HAS_CHIP_XCVR }, { "1000/100/10M Ethernet PCI Adapter", HAS_MII_XCVR }, diff --git a/trunk/drivers/net/ethernet/ibm/ehea/ehea.h b/trunk/drivers/net/ethernet/ibm/ehea/ehea.h index 6be7b9839f35..b8e46cc31e53 100644 --- a/trunk/drivers/net/ethernet/ibm/ehea/ehea.h +++ b/trunk/drivers/net/ethernet/ibm/ehea/ehea.h @@ -35,6 +35,7 @@ #include #include +#include #include #define DRV_NAME "ehea" diff --git a/trunk/drivers/net/ethernet/ibm/ehea/ehea_phyp.c b/trunk/drivers/net/ethernet/ibm/ehea/ehea_phyp.c index d3a130ccdcc8..30f903332e92 100644 --- a/trunk/drivers/net/ethernet/ibm/ehea/ehea_phyp.c +++ b/trunk/drivers/net/ethernet/ibm/ehea/ehea_phyp.c @@ -141,7 +141,7 @@ u64 ehea_h_query_ehea_qp(const u64 adapter_handle, const u8 qp_category, qp_category, /* R5 */ qp_handle, /* R6 */ sel_mask, /* R7 */ - __pa(cb_addr), /* R8 */ + virt_to_abs(cb_addr), /* R8 */ 0, 0); } @@ -415,7 +415,7 @@ u64 ehea_h_modify_ehea_qp(const u64 adapter_handle, const u8 cat, (u64) cat, /* R5 */ qp_handle, /* R6 */ sel_mask, /* R7 */ - __pa(cb_addr), /* R8 */ + virt_to_abs(cb_addr), /* R8 */ 0, 0, 0, 0); /* R9-R12 */ *inv_attr_id = outs[0]; @@ -528,7 +528,7 @@ u64 ehea_h_query_ehea(const u64 adapter_handle, void *cb_addr) { u64 hret, cb_logaddr; - cb_logaddr = __pa(cb_addr); + cb_logaddr = virt_to_abs(cb_addr); hret = ehea_plpar_hcall_norets(H_QUERY_HEA, adapter_handle, /* R4 */ @@ -545,7 +545,7 @@ u64 ehea_h_query_ehea_port(const u64 adapter_handle, const u16 port_num, void *cb_addr) { u64 port_info; - u64 cb_logaddr = __pa(cb_addr); + u64 cb_logaddr = virt_to_abs(cb_addr); u64 arr_index = 0; port_info = EHEA_BMASK_SET(H_MEHEAPORT_CAT, cb_cat) @@ -567,7 +567,7 @@ u64 ehea_h_modify_ehea_port(const u64 adapter_handle, const u16 port_num, unsigned long outs[PLPAR_HCALL9_BUFSIZE]; u64 port_info; u64 arr_index = 0; - u64 cb_logaddr = __pa(cb_addr); + u64 cb_logaddr = virt_to_abs(cb_addr); port_info = EHEA_BMASK_SET(H_MEHEAPORT_CAT, cb_cat) | EHEA_BMASK_SET(H_MEHEAPORT_PN, port_num); @@ -621,6 +621,6 @@ u64 ehea_h_error_data(const u64 adapter_handle, const u64 ressource_handle, return ehea_plpar_hcall_norets(H_ERROR_DATA, adapter_handle, /* R4 */ ressource_handle, /* R5 */ - __pa(rblock), /* R6 */ + virt_to_abs(rblock), /* R6 */ 0, 0, 0, 0); /* R7-R12 */ } diff --git a/trunk/drivers/net/ethernet/ibm/ehea/ehea_qmr.c b/trunk/drivers/net/ethernet/ibm/ehea/ehea_qmr.c index 27f881758d16..cb66f574dc97 100644 --- a/trunk/drivers/net/ethernet/ibm/ehea/ehea_qmr.c +++ b/trunk/drivers/net/ethernet/ibm/ehea/ehea_qmr.c @@ -163,7 +163,7 @@ struct ehea_cq *ehea_create_cq(struct ehea_adapter *adapter, goto out_kill_hwq; } - rpage = __pa(vpage); + rpage = virt_to_abs(vpage); hret = ehea_h_register_rpage(adapter->handle, 0, EHEA_CQ_REGISTER_ORIG, cq->fw_handle, rpage, 1); @@ -290,7 +290,7 @@ struct ehea_eq *ehea_create_eq(struct ehea_adapter *adapter, goto out_kill_hwq; } - rpage = __pa(vpage); + rpage = virt_to_abs(vpage); hret = ehea_h_register_rpage(adapter->handle, 0, EHEA_EQ_REGISTER_ORIG, @@ -395,7 +395,7 @@ static int ehea_qp_alloc_register(struct ehea_qp *qp, struct hw_queue *hw_queue, pr_err("hw_qpageit_get_inc failed\n"); goto out_kill_hwq; } - rpage = __pa(vpage); + rpage = virt_to_abs(vpage); hret = ehea_h_register_rpage(adapter->handle, 0, h_call_q_selector, qp->fw_handle, rpage, 1); @@ -790,7 +790,7 @@ u64 ehea_map_vaddr(void *caddr) if (!ehea_bmap) return EHEA_INVAL_ADDR; - index = __pa(caddr) >> SECTION_SIZE_BITS; + index = virt_to_abs(caddr) >> SECTION_SIZE_BITS; top = (index >> EHEA_TOP_INDEX_SHIFT) & EHEA_INDEX_MASK; if (!ehea_bmap->top[top]) return EHEA_INVAL_ADDR; @@ -812,7 +812,7 @@ static inline void *ehea_calc_sectbase(int top, int dir, int idx) unsigned long ret = idx; ret |= dir << EHEA_DIR_INDEX_SHIFT; ret |= top << EHEA_TOP_INDEX_SHIFT; - return __va(ret << SECTION_SIZE_BITS); + return abs_to_virt(ret << SECTION_SIZE_BITS); } static u64 ehea_reg_mr_section(int top, int dir, int idx, u64 *pt, @@ -822,7 +822,7 @@ static u64 ehea_reg_mr_section(int top, int dir, int idx, u64 *pt, void *pg; u64 j, m, hret; unsigned long k = 0; - u64 pt_abs = __pa(pt); + u64 pt_abs = virt_to_abs(pt); void *sectbase = ehea_calc_sectbase(top, dir, idx); @@ -830,7 +830,7 @@ static u64 ehea_reg_mr_section(int top, int dir, int idx, u64 *pt, for (m = 0; m < EHEA_MAX_RPAGE; m++) { pg = sectbase + ((k++) * EHEA_PAGESIZE); - pt[m] = __pa(pg); + pt[m] = virt_to_abs(pg); } hret = ehea_h_register_rpage_mr(adapter->handle, mr->handle, 0, 0, pt_abs, EHEA_MAX_RPAGE); diff --git a/trunk/drivers/net/ethernet/intel/ixgbe/ixgbe_82599.c b/trunk/drivers/net/ethernet/intel/ixgbe/ixgbe_82599.c index 1077cb2b38db..18bf08c9d7a4 100644 --- a/trunk/drivers/net/ethernet/intel/ixgbe/ixgbe_82599.c +++ b/trunk/drivers/net/ethernet/intel/ixgbe/ixgbe_82599.c @@ -1099,7 +1099,7 @@ s32 ixgbe_reinit_fdir_tables_82599(struct ixgbe_hw *hw) if (IXGBE_READ_REG(hw, IXGBE_FDIRCTRL) & IXGBE_FDIRCTRL_INIT_DONE) break; - usleep_range(1000, 2000); + udelay(10); } if (i >= IXGBE_FDIR_INIT_DONE_POLL) { hw_dbg(hw, "Flow Director Signature poll time exceeded!\n"); diff --git a/trunk/drivers/net/ethernet/intel/ixgbe/ixgbe_common.c b/trunk/drivers/net/ethernet/intel/ixgbe/ixgbe_common.c index dbf37e4a45fd..90e41db3cb69 100644 --- a/trunk/drivers/net/ethernet/intel/ixgbe/ixgbe_common.c +++ b/trunk/drivers/net/ethernet/intel/ixgbe/ixgbe_common.c @@ -70,7 +70,6 @@ static s32 ixgbe_device_supports_autoneg_fc(struct ixgbe_hw *hw) switch (hw->device_id) { case IXGBE_DEV_ID_X540T: - case IXGBE_DEV_ID_X540T1: return 0; case IXGBE_DEV_ID_82599_T3_LOM: return 0; diff --git a/trunk/drivers/net/ethernet/intel/ixgbe/ixgbe_ethtool.c b/trunk/drivers/net/ethernet/intel/ixgbe/ixgbe_ethtool.c index 56b20d17d0e4..4104ea25d818 100644 --- a/trunk/drivers/net/ethernet/intel/ixgbe/ixgbe_ethtool.c +++ b/trunk/drivers/net/ethernet/intel/ixgbe/ixgbe_ethtool.c @@ -2690,7 +2690,10 @@ static int ixgbe_get_ts_info(struct net_device *dev, (1 << HWTSTAMP_FILTER_NONE) | (1 << HWTSTAMP_FILTER_PTP_V1_L4_SYNC) | (1 << HWTSTAMP_FILTER_PTP_V1_L4_DELAY_REQ) | - (1 << HWTSTAMP_FILTER_PTP_V2_EVENT); + (1 << HWTSTAMP_FILTER_PTP_V2_SYNC) | + (1 << HWTSTAMP_FILTER_PTP_V2_DELAY_REQ) | + (1 << HWTSTAMP_FILTER_PTP_V2_EVENT) | + (1 << HWTSTAMP_FILTER_SOME); break; #endif /* CONFIG_IXGBE_PTP */ default: diff --git a/trunk/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c b/trunk/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c index fa3d552e1f4a..868af6938219 100644 --- a/trunk/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c +++ b/trunk/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c @@ -114,7 +114,6 @@ static DEFINE_PCI_DEVICE_TABLE(ixgbe_pci_tbl) = { {PCI_VDEVICE(INTEL, IXGBE_DEV_ID_82599_LS), board_82599 }, {PCI_VDEVICE(INTEL, IXGBE_DEV_ID_82599EN_SFP), board_82599 }, {PCI_VDEVICE(INTEL, IXGBE_DEV_ID_82599_SFP_SF_QP), board_82599 }, - {PCI_VDEVICE(INTEL, IXGBE_DEV_ID_X540T1), board_X540 }, /* required last entry */ {0, } }; @@ -2323,12 +2322,6 @@ static inline void ixgbe_irq_enable(struct ixgbe_adapter *adapter, bool queues, default: break; } - -#ifdef CONFIG_IXGBE_PTP - if (adapter->hw.mac.type == ixgbe_mac_X540) - mask |= IXGBE_EIMS_TIMESYNC; -#endif - if ((adapter->flags & IXGBE_FLAG_FDIR_HASH_CAPABLE) && !(adapter->flags2 & IXGBE_FLAG2_FDIR_REQUIRES_REINIT)) mask |= IXGBE_EIMS_FLOW_DIR; @@ -2392,10 +2385,8 @@ static irqreturn_t ixgbe_msix_other(int irq, void *data) } ixgbe_check_fan_failure(adapter, eicr); - #ifdef CONFIG_IXGBE_PTP - if (unlikely(eicr & IXGBE_EICR_TIMESYNC)) - ixgbe_ptp_check_pps_event(adapter, eicr); + ixgbe_ptp_check_pps_event(adapter, eicr); #endif /* re-enable the original interrupt state, no lsc, no queues */ @@ -2589,8 +2580,7 @@ static irqreturn_t ixgbe_intr(int irq, void *data) ixgbe_check_fan_failure(adapter, eicr); #ifdef CONFIG_IXGBE_PTP - if (unlikely(eicr & IXGBE_EICR_TIMESYNC)) - ixgbe_ptp_check_pps_event(adapter, eicr); + ixgbe_ptp_check_pps_event(adapter, eicr); #endif /* would disable interrupts here but EIAM disabled it */ @@ -7055,7 +7045,6 @@ int ixgbe_wol_supported(struct ixgbe_adapter *adapter, u16 device_id, is_wol_supported = 1; break; case IXGBE_DEV_ID_X540T: - case IXGBE_DEV_ID_X540T1: /* check eeprom to see if enabled wol */ if ((wol_cap == IXGBE_DEVICE_CAPS_WOL_PORT0_1) || ((wol_cap == IXGBE_DEVICE_CAPS_WOL_PORT0) && diff --git a/trunk/drivers/net/ethernet/intel/ixgbe/ixgbe_ptp.c b/trunk/drivers/net/ethernet/intel/ixgbe/ixgbe_ptp.c index d9291316ee9f..39881cb17a4b 100644 --- a/trunk/drivers/net/ethernet/intel/ixgbe/ixgbe_ptp.c +++ b/trunk/drivers/net/ethernet/intel/ixgbe/ixgbe_ptp.c @@ -105,83 +105,6 @@ static struct sock_filter ptp_filter[] = { PTP_FILTER }; -/** - * ixgbe_ptp_setup_sdp - * @hw: the hardware private structure - * - * this function enables or disables the clock out feature on SDP0 for - * the X540 device. It will create a 1second periodic output that can - * be used as the PPS (via an interrupt). - * - * It calculates when the systime will be on an exact second, and then - * aligns the start of the PPS signal to that value. The shift is - * necessary because it can change based on the link speed. - */ -static void ixgbe_ptp_setup_sdp(struct ixgbe_adapter *adapter) -{ - struct ixgbe_hw *hw = &adapter->hw; - int shift = adapter->cc.shift; - u32 esdp, tsauxc, clktiml, clktimh, trgttiml, trgttimh, rem; - u64 ns = 0, clock_edge = 0; - - if ((adapter->flags2 & IXGBE_FLAG2_PTP_PPS_ENABLED) && - (hw->mac.type == ixgbe_mac_X540)) { - - /* disable the pin first */ - IXGBE_WRITE_REG(hw, IXGBE_TSAUXC, 0x0); - IXGBE_WRITE_FLUSH(hw); - - esdp = IXGBE_READ_REG(hw, IXGBE_ESDP); - - /* - * enable the SDP0 pin as output, and connected to the - * native function for Timesync (ClockOut) - */ - esdp |= (IXGBE_ESDP_SDP0_DIR | - IXGBE_ESDP_SDP0_NATIVE); - - /* - * enable the Clock Out feature on SDP0, and allow - * interrupts to occur when the pin changes - */ - tsauxc = (IXGBE_TSAUXC_EN_CLK | - IXGBE_TSAUXC_SYNCLK | - IXGBE_TSAUXC_SDP0_INT); - - /* clock period (or pulse length) */ - clktiml = (u32)(NSECS_PER_SEC << shift); - clktimh = (u32)((NSECS_PER_SEC << shift) >> 32); - - /* - * Account for the cyclecounter wrap-around value by - * using the converted ns value of the current time to - * check for when the next aligned second would occur. - */ - clock_edge |= (u64)IXGBE_READ_REG(hw, IXGBE_SYSTIML); - clock_edge |= (u64)IXGBE_READ_REG(hw, IXGBE_SYSTIMH) << 32; - ns = timecounter_cyc2time(&adapter->tc, clock_edge); - - div_u64_rem(ns, NSECS_PER_SEC, &rem); - clock_edge += ((NSECS_PER_SEC - (u64)rem) << shift); - - /* specify the initial clock start time */ - trgttiml = (u32)clock_edge; - trgttimh = (u32)(clock_edge >> 32); - - IXGBE_WRITE_REG(hw, IXGBE_CLKTIML, clktiml); - IXGBE_WRITE_REG(hw, IXGBE_CLKTIMH, clktimh); - IXGBE_WRITE_REG(hw, IXGBE_TRGTTIML0, trgttiml); - IXGBE_WRITE_REG(hw, IXGBE_TRGTTIMH0, trgttimh); - - IXGBE_WRITE_REG(hw, IXGBE_ESDP, esdp); - IXGBE_WRITE_REG(hw, IXGBE_TSAUXC, tsauxc); - } else { - IXGBE_WRITE_REG(hw, IXGBE_TSAUXC, 0x0); - } - - IXGBE_WRITE_FLUSH(hw); -} - /** * ixgbe_ptp_read - read raw cycle counter (to be used by time counter) * @cc: the cyclecounter structure @@ -275,9 +198,6 @@ static int ixgbe_ptp_adjtime(struct ptp_clock_info *ptp, s64 delta) now); spin_unlock_irqrestore(&adapter->tmreg_lock, flags); - - ixgbe_ptp_setup_sdp(adapter); - return 0; } @@ -331,7 +251,6 @@ static int ixgbe_ptp_settime(struct ptp_clock_info *ptp, timecounter_init(&adapter->tc, &adapter->cc, ns); spin_unlock_irqrestore(&adapter->tmreg_lock, flags); - ixgbe_ptp_setup_sdp(adapter); return 0; } @@ -362,9 +281,8 @@ static int ixgbe_ptp_enable(struct ptp_clock_info *ptp, if (on) adapter->flags2 |= IXGBE_FLAG2_PTP_PPS_ENABLED; else - adapter->flags2 &= ~IXGBE_FLAG2_PTP_PPS_ENABLED; - - ixgbe_ptp_setup_sdp(adapter); + adapter->flags2 &= + ~IXGBE_FLAG2_PTP_PPS_ENABLED; return 0; default: break; @@ -387,15 +305,109 @@ void ixgbe_ptp_check_pps_event(struct ixgbe_adapter *adapter, u32 eicr) struct ixgbe_hw *hw = &adapter->hw; struct ptp_clock_event event; + event.type = PTP_CLOCK_PPS; + + /* Make sure ptp clock is valid, and PPS event enabled */ + if (!adapter->ptp_clock || + !(adapter->flags2 & IXGBE_FLAG2_PTP_PPS_ENABLED)) + return; + + if (unlikely(eicr & IXGBE_EICR_TIMESYNC)) { + switch (hw->mac.type) { + case ixgbe_mac_X540: + ptp_clock_event(adapter->ptp_clock, &event); + break; + default: + break; + } + } +} + +/** + * ixgbe_ptp_enable_sdp + * @hw: the hardware private structure + * @shift: the clock shift for calculating nanoseconds + * + * this function enables the clock out feature on the sdp0 for the + * X540 device. It will create a 1second periodic output that can be + * used as the PPS (via an interrupt). + * + * It calculates when the systime will be on an exact second, and then + * aligns the start of the PPS signal to that value. The shift is + * necessary because it can change based on the link speed. + */ +static void ixgbe_ptp_enable_sdp(struct ixgbe_hw *hw, int shift) +{ + u32 esdp, tsauxc, clktiml, clktimh, trgttiml, trgttimh; + u64 clock_edge = 0; + u32 rem; + switch (hw->mac.type) { case ixgbe_mac_X540: - ptp_clock_event(adapter->ptp_clock, &event); + esdp = IXGBE_READ_REG(hw, IXGBE_ESDP); + + /* + * enable the SDP0 pin as output, and connected to the native + * function for Timesync (ClockOut) + */ + esdp |= (IXGBE_ESDP_SDP0_DIR | + IXGBE_ESDP_SDP0_NATIVE); + + /* + * enable the Clock Out feature on SDP0, and allow interrupts + * to occur when the pin changes + */ + tsauxc = (IXGBE_TSAUXC_EN_CLK | + IXGBE_TSAUXC_SYNCLK | + IXGBE_TSAUXC_SDP0_INT); + + /* clock period (or pulse length) */ + clktiml = (u32)(NSECS_PER_SEC << shift); + clktimh = (u32)((NSECS_PER_SEC << shift) >> 32); + + clock_edge |= (u64)IXGBE_READ_REG(hw, IXGBE_SYSTIML); + clock_edge |= (u64)IXGBE_READ_REG(hw, IXGBE_SYSTIMH) << 32; + + /* + * account for the fact that we can't do u64 division + * with remainder, by converting the clock values into + * nanoseconds first + */ + clock_edge >>= shift; + div_u64_rem(clock_edge, NSECS_PER_SEC, &rem); + clock_edge += (NSECS_PER_SEC - rem); + clock_edge <<= shift; + + /* specify the initial clock start time */ + trgttiml = (u32)clock_edge; + trgttimh = (u32)(clock_edge >> 32); + + IXGBE_WRITE_REG(hw, IXGBE_CLKTIML, clktiml); + IXGBE_WRITE_REG(hw, IXGBE_CLKTIMH, clktimh); + IXGBE_WRITE_REG(hw, IXGBE_TRGTTIML0, trgttiml); + IXGBE_WRITE_REG(hw, IXGBE_TRGTTIMH0, trgttimh); + + IXGBE_WRITE_REG(hw, IXGBE_ESDP, esdp); + IXGBE_WRITE_REG(hw, IXGBE_TSAUXC, tsauxc); + + IXGBE_WRITE_REG(hw, IXGBE_EIMS, IXGBE_EICR_TIMESYNC); break; default: break; } } +/** + * ixgbe_ptp_disable_sdp + * @hw: the private hardware structure + * + * this function disables the auxiliary SDP clock out feature + */ +static void ixgbe_ptp_disable_sdp(struct ixgbe_hw *hw) +{ + IXGBE_WRITE_REG(hw, IXGBE_EIMC, IXGBE_EICR_TIMESYNC); + IXGBE_WRITE_REG(hw, IXGBE_TSAUXC, 0); +} /** * ixgbe_ptp_overflow_check - delayed work to detect SYSTIME overflow @@ -810,6 +822,9 @@ void ixgbe_ptp_start_cyclecounter(struct ixgbe_adapter *adapter) if (adapter->cycle_speed == cycle_speed && timinca) return; + /* disable the SDP clock out */ + ixgbe_ptp_disable_sdp(hw); + /** * Scale the NIC cycle counter by a large factor so that * relatively small corrections to the frequency can be added @@ -862,6 +877,10 @@ void ixgbe_ptp_start_cyclecounter(struct ixgbe_adapter *adapter) IXGBE_WRITE_REG(hw, IXGBE_SYSTIMH, 0x00000000); IXGBE_WRITE_FLUSH(hw); + /* now that the shift has been calculated and the systime + * registers reset, (re-)enable the Clock out feature*/ + ixgbe_ptp_enable_sdp(hw, shift); + /* store the new cycle speed */ adapter->cycle_speed = cycle_speed; @@ -882,12 +901,6 @@ void ixgbe_ptp_start_cyclecounter(struct ixgbe_adapter *adapter) ktime_to_ns(ktime_get_real())); spin_unlock_irqrestore(&adapter->tmreg_lock, flags); - - /* - * Now that the shift has been calculated and the systime - * registers reset, (re-)enable the Clock out feature - */ - ixgbe_ptp_setup_sdp(adapter); } /** @@ -966,11 +979,10 @@ void ixgbe_ptp_init(struct ixgbe_adapter *adapter) */ void ixgbe_ptp_stop(struct ixgbe_adapter *adapter) { - /* stop the overflow check task */ - adapter->flags2 &= ~(IXGBE_FLAG2_OVERFLOW_CHECK_ENABLED | - IXGBE_FLAG2_PTP_PPS_ENABLED); + ixgbe_ptp_disable_sdp(&adapter->hw); - ixgbe_ptp_setup_sdp(adapter); + /* stop the overflow check task */ + adapter->flags2 &= ~IXGBE_FLAG2_OVERFLOW_CHECK_ENABLED; if (adapter->ptp_clock) { ptp_clock_unregister(adapter->ptp_clock); diff --git a/trunk/drivers/net/ethernet/intel/ixgbe/ixgbe_type.h b/trunk/drivers/net/ethernet/intel/ixgbe/ixgbe_type.h index 0722f3368092..400f86a31174 100644 --- a/trunk/drivers/net/ethernet/intel/ixgbe/ixgbe_type.h +++ b/trunk/drivers/net/ethernet/intel/ixgbe/ixgbe_type.h @@ -65,7 +65,6 @@ #define IXGBE_DEV_ID_82599_LS 0x154F #define IXGBE_DEV_ID_X540T 0x1528 #define IXGBE_DEV_ID_82599_SFP_SF_QP 0x154A -#define IXGBE_DEV_ID_X540T1 0x1560 /* VF Device IDs */ #define IXGBE_DEV_ID_82599_VF 0x10ED diff --git a/trunk/drivers/net/ethernet/oki-semi/pch_gbe/Kconfig b/trunk/drivers/net/ethernet/oki-semi/pch_gbe/Kconfig index 97302419a377..bce01641ee6b 100644 --- a/trunk/drivers/net/ethernet/oki-semi/pch_gbe/Kconfig +++ b/trunk/drivers/net/ethernet/oki-semi/pch_gbe/Kconfig @@ -26,7 +26,7 @@ if PCH_GBE config PCH_PTP bool "PCH PTP clock support" default n - select PTP_1588_CLOCK_PCH + depends on PTP_1588_CLOCK_PCH ---help--- Say Y here if you want to use Precision Time Protocol (PTP) in the driver. PTP is a method to precisely synchronize distributed clocks diff --git a/trunk/drivers/net/ethernet/qlogic/qlcnic/qlcnic_hw.c b/trunk/drivers/net/ethernet/qlogic/qlcnic/qlcnic_hw.c index 2a0c9dc48eb3..b528e52a8ee1 100644 --- a/trunk/drivers/net/ethernet/qlogic/qlcnic/qlcnic_hw.c +++ b/trunk/drivers/net/ethernet/qlogic/qlcnic/qlcnic_hw.c @@ -38,7 +38,7 @@ static inline void writeq(u64 val, void __iomem *addr) } #endif -static struct crb_128M_2M_block_map +static const struct crb_128M_2M_block_map crb_128M_2M_map[64] __cacheline_aligned_in_smp = { {{{0, 0, 0, 0} } }, /* 0: PCI */ {{{1, 0x0100000, 0x0102000, 0x120000}, /* 1: PCIE */ diff --git a/trunk/drivers/net/ethernet/realtek/8139too.c b/trunk/drivers/net/ethernet/realtek/8139too.c index 3ed7add23c12..1d83565cc6af 100644 --- a/trunk/drivers/net/ethernet/realtek/8139too.c +++ b/trunk/drivers/net/ethernet/realtek/8139too.c @@ -228,7 +228,7 @@ typedef enum { static const struct { const char *name; u32 hw_flags; -} board_info[] __devinitconst = { +} board_info[] __devinitdata = { { "RealTek RTL8139", RTL8139_CAPS }, { "RealTek RTL8129", RTL8129_CAPS }, }; diff --git a/trunk/drivers/net/ethernet/sfc/efx.c b/trunk/drivers/net/ethernet/sfc/efx.c index 4f86d0cd516a..96bd980e828d 100644 --- a/trunk/drivers/net/ethernet/sfc/efx.c +++ b/trunk/drivers/net/ethernet/sfc/efx.c @@ -2019,14 +2019,14 @@ static void efx_set_rx_mode(struct net_device *net_dev) netdev_for_each_mc_addr(ha, net_dev) { crc = ether_crc_le(ETH_ALEN, ha->addr); bit = crc & (EFX_MCAST_HASH_ENTRIES - 1); - __set_bit_le(bit, mc_hash); + set_bit_le(bit, mc_hash->byte); } /* Broadcast packets go through the multicast hash filter. * ether_crc_le() of the broadcast address is 0xbe2612ff * so we always add bit 0xff to the mask. */ - __set_bit_le(0xff, mc_hash); + set_bit_le(0xff, mc_hash->byte); } if (efx->port_enabled) diff --git a/trunk/drivers/net/ethernet/sfc/net_driver.h b/trunk/drivers/net/ethernet/sfc/net_driver.h index 576a31091165..c1a010cda89b 100644 --- a/trunk/drivers/net/ethernet/sfc/net_driver.h +++ b/trunk/drivers/net/ethernet/sfc/net_driver.h @@ -1101,6 +1101,18 @@ static inline struct efx_rx_buffer *efx_rx_buffer(struct efx_rx_queue *rx_queue, return &rx_queue->buffer[index]; } +/* Set bit in a little-endian bitfield */ +static inline void set_bit_le(unsigned nr, unsigned char *addr) +{ + addr[nr / 8] |= (1 << (nr % 8)); +} + +/* Clear bit in a little-endian bitfield */ +static inline void clear_bit_le(unsigned nr, unsigned char *addr) +{ + addr[nr / 8] &= ~(1 << (nr % 8)); +} + /** * EFX_MAX_FRAME_LEN - calculate maximum frame length diff --git a/trunk/drivers/net/ethernet/sfc/nic.c b/trunk/drivers/net/ethernet/sfc/nic.c index aab7cacb2e34..cdff40b65729 100644 --- a/trunk/drivers/net/ethernet/sfc/nic.c +++ b/trunk/drivers/net/ethernet/sfc/nic.c @@ -472,9 +472,9 @@ void efx_nic_init_tx(struct efx_tx_queue *tx_queue) efx_reado(efx, ®, FR_AA_TX_CHKSM_CFG); if (tx_queue->queue & EFX_TXQ_TYPE_OFFLOAD) - __clear_bit_le(tx_queue->queue, ®); + clear_bit_le(tx_queue->queue, (void *)®); else - __set_bit_le(tx_queue->queue, ®); + set_bit_le(tx_queue->queue, (void *)®); efx_writeo(efx, ®, FR_AA_TX_CHKSM_CFG); } diff --git a/trunk/drivers/net/ethernet/sis/sis190.c b/trunk/drivers/net/ethernet/sis/sis190.c index d8166012b7d4..4613591b43e7 100644 --- a/trunk/drivers/net/ethernet/sis/sis190.c +++ b/trunk/drivers/net/ethernet/sis/sis190.c @@ -1618,7 +1618,7 @@ static int __devinit sis190_get_mac_addr_from_eeprom(struct pci_dev *pdev, static int __devinit sis190_get_mac_addr_from_apc(struct pci_dev *pdev, struct net_device *dev) { - static const u16 __devinitconst ids[] = { 0x0965, 0x0966, 0x0968 }; + static const u16 __devinitdata ids[] = { 0x0965, 0x0966, 0x0968 }; struct sis190_private *tp = netdev_priv(dev); struct pci_dev *isa_bridge; u8 reg, tmp8; diff --git a/trunk/drivers/net/ethernet/ti/davinci_cpdma.c b/trunk/drivers/net/ethernet/ti/davinci_cpdma.c index 49956730cd8d..d15c888e9df8 100644 --- a/trunk/drivers/net/ethernet/ti/davinci_cpdma.c +++ b/trunk/drivers/net/ethernet/ti/davinci_cpdma.c @@ -863,7 +863,6 @@ int cpdma_chan_stop(struct cpdma_chan *chan) next_dma = desc_read(desc, hw_next); chan->head = desc_from_phys(pool, next_dma); - chan->count--; chan->stats.teardown_dequeue++; /* issue callback without locks held */ diff --git a/trunk/drivers/net/hamradio/6pack.c b/trunk/drivers/net/hamradio/6pack.c index 1450e33fc250..64783a0d545a 100644 --- a/trunk/drivers/net/hamradio/6pack.c +++ b/trunk/drivers/net/hamradio/6pack.c @@ -811,9 +811,9 @@ static struct tty_ldisc_ops sp_ldisc = { /* Initialize 6pack control device -- register 6pack line discipline */ -static const char msg_banner[] __initconst = KERN_INFO \ +static const char msg_banner[] __initdata = KERN_INFO \ "AX.25: 6pack driver, " SIXPACK_VERSION "\n"; -static const char msg_regfail[] __initconst = KERN_ERR \ +static const char msg_regfail[] __initdata = KERN_ERR \ "6pack: can't register line discipline (err = %d)\n"; static int __init sixpack_init_driver(void) @@ -829,7 +829,7 @@ static int __init sixpack_init_driver(void) return status; } -static const char msg_unregfail[] = KERN_ERR \ +static const char msg_unregfail[] __exitdata = KERN_ERR \ "6pack: can't unregister line discipline (err = %d)\n"; static void __exit sixpack_exit_driver(void) diff --git a/trunk/drivers/net/hamradio/bpqether.c b/trunk/drivers/net/hamradio/bpqether.c index c2e5497397d5..76d54774ba82 100644 --- a/trunk/drivers/net/hamradio/bpqether.c +++ b/trunk/drivers/net/hamradio/bpqether.c @@ -87,7 +87,7 @@ #include -static const char banner[] __initconst = KERN_INFO \ +static const char banner[] __initdata = KERN_INFO \ "AX.25: bpqether driver version 004\n"; static char bcast_addr[6]={0xFF,0xFF,0xFF,0xFF,0xFF,0xFF}; diff --git a/trunk/drivers/net/hamradio/mkiss.c b/trunk/drivers/net/hamradio/mkiss.c index 8e01c457015b..2c0894a92abd 100644 --- a/trunk/drivers/net/hamradio/mkiss.c +++ b/trunk/drivers/net/hamradio/mkiss.c @@ -997,9 +997,9 @@ static struct tty_ldisc_ops ax_ldisc = { .write_wakeup = mkiss_write_wakeup }; -static const char banner[] __initconst = KERN_INFO \ +static const char banner[] __initdata = KERN_INFO \ "mkiss: AX.25 Multikiss, Hans Albas PE1AYX\n"; -static const char msg_regfail[] __initconst = KERN_ERR \ +static const char msg_regfail[] __initdata = KERN_ERR \ "mkiss: can't register line discipline (err = %d)\n"; static int __init mkiss_init_driver(void) @@ -1015,7 +1015,7 @@ static int __init mkiss_init_driver(void) return status; } -static const char msg_unregfail[] = KERN_ERR \ +static const char msg_unregfail[] __exitdata = KERN_ERR \ "mkiss: can't unregister line discipline (err = %d)\n"; static void __exit mkiss_exit_driver(void) diff --git a/trunk/drivers/net/hamradio/scc.c b/trunk/drivers/net/hamradio/scc.c index 1b4a47bd32b7..efc6c97163a7 100644 --- a/trunk/drivers/net/hamradio/scc.c +++ b/trunk/drivers/net/hamradio/scc.c @@ -182,7 +182,7 @@ #include "z8530.h" -static const char banner[] __initconst = KERN_INFO \ +static const char banner[] __initdata = KERN_INFO \ "AX.25: Z8530 SCC driver version "VERSION".dl1bke\n"; static void t_dwait(unsigned long); diff --git a/trunk/drivers/net/hamradio/yam.c b/trunk/drivers/net/hamradio/yam.c index c6645f1017af..5a6412ecce73 100644 --- a/trunk/drivers/net/hamradio/yam.c +++ b/trunk/drivers/net/hamradio/yam.c @@ -76,7 +76,7 @@ /* --------------------------------------------------------------------- */ static const char yam_drvname[] = "yam"; -static const char yam_drvinfo[] __initconst = KERN_INFO \ +static const char yam_drvinfo[] __initdata = KERN_INFO \ "YAM driver version 0.8 by F1OAT/F6FBB\n"; /* --------------------------------------------------------------------- */ diff --git a/trunk/drivers/net/rionet.c b/trunk/drivers/net/rionet.c index d8b9b1e8ee02..91d25888a1b9 100644 --- a/trunk/drivers/net/rionet.c +++ b/trunk/drivers/net/rionet.c @@ -26,7 +26,7 @@ #include #define DRV_NAME "rionet" -#define DRV_VERSION "0.3" +#define DRV_VERSION "0.2" #define DRV_AUTHOR "Matt Porter " #define DRV_DESC "Ethernet over RapidIO" @@ -47,7 +47,8 @@ MODULE_LICENSE("GPL"); #define RIONET_TX_RING_SIZE CONFIG_RIONET_TX_SIZE #define RIONET_RX_RING_SIZE CONFIG_RIONET_RX_SIZE -#define RIONET_MAX_NETS 8 + +static LIST_HEAD(rionet_peers); struct rionet_private { struct rio_mport *mport; @@ -68,14 +69,16 @@ struct rionet_peer { struct resource *res; }; -struct rionet_net { - struct net_device *ndev; - struct list_head peers; - struct rio_dev **active; - int nact; /* number of active peers */ -}; +static int rionet_check = 0; +static int rionet_capable = 1; -static struct rionet_net nets[RIONET_MAX_NETS]; +/* + * This is a fast lookup table for translating TX + * Ethernet packets into a destination RIO device. It + * could be made into a hash table to save memory depending + * on system trade-offs. + */ +static struct rio_dev **rionet_active; #define is_rionet_capable(src_ops, dst_ops) \ ((src_ops & RIO_SRC_OPS_DATA_MSG) && \ @@ -172,7 +175,6 @@ static int rionet_start_xmit(struct sk_buff *skb, struct net_device *ndev) struct ethhdr *eth = (struct ethhdr *)skb->data; u16 destid; unsigned long flags; - int add_num = 1; local_irq_save(flags); if (!spin_trylock(&rnet->tx_lock)) { @@ -180,10 +182,7 @@ static int rionet_start_xmit(struct sk_buff *skb, struct net_device *ndev) return NETDEV_TX_LOCKED; } - if (is_multicast_ether_addr(eth->h_dest)) - add_num = nets[rnet->mport->id].nact; - - if ((rnet->tx_cnt + add_num) > RIONET_TX_RING_SIZE) { + if ((rnet->tx_cnt + 1) > RIONET_TX_RING_SIZE) { netif_stop_queue(ndev); spin_unlock_irqrestore(&rnet->tx_lock, flags); printk(KERN_ERR "%s: BUG! Tx Ring full when queue awake!\n", @@ -192,22 +191,15 @@ static int rionet_start_xmit(struct sk_buff *skb, struct net_device *ndev) } if (is_multicast_ether_addr(eth->h_dest)) { - int count = 0; - for (i = 0; i < RIO_MAX_ROUTE_ENTRIES(rnet->mport->sys_size); i++) - if (nets[rnet->mport->id].active[i]) { + if (rionet_active[i]) rionet_queue_tx_msg(skb, ndev, - nets[rnet->mport->id].active[i]); - if (count) - atomic_inc(&skb->users); - count++; - } + rionet_active[i]); } else if (RIONET_MAC_MATCH(eth->h_dest)) { destid = RIONET_GET_DESTID(eth->h_dest); - if (nets[rnet->mport->id].active[destid]) - rionet_queue_tx_msg(skb, ndev, - nets[rnet->mport->id].active[destid]); + if (rionet_active[destid]) + rionet_queue_tx_msg(skb, ndev, rionet_active[destid]); } spin_unlock_irqrestore(&rnet->tx_lock, flags); @@ -226,21 +218,16 @@ static void rionet_dbell_event(struct rio_mport *mport, void *dev_id, u16 sid, u printk(KERN_INFO "%s: doorbell sid %4.4x tid %4.4x info %4.4x", DRV_NAME, sid, tid, info); if (info == RIONET_DOORBELL_JOIN) { - if (!nets[rnet->mport->id].active[sid]) { - list_for_each_entry(peer, - &nets[rnet->mport->id].peers, node) { - if (peer->rdev->destid == sid) { - nets[rnet->mport->id].active[sid] = - peer->rdev; - nets[rnet->mport->id].nact++; - } + if (!rionet_active[sid]) { + list_for_each_entry(peer, &rionet_peers, node) { + if (peer->rdev->destid == sid) + rionet_active[sid] = peer->rdev; } rio_mport_send_doorbell(mport, sid, RIONET_DOORBELL_JOIN); } } else if (info == RIONET_DOORBELL_LEAVE) { - nets[rnet->mport->id].active[sid] = NULL; - nets[rnet->mport->id].nact--; + rionet_active[sid] = NULL; } else { if (netif_msg_intr(rnet)) printk(KERN_WARNING "%s: unhandled doorbell\n", @@ -334,8 +321,7 @@ static int rionet_open(struct net_device *ndev) netif_carrier_on(ndev); netif_start_queue(ndev); - list_for_each_entry_safe(peer, tmp, - &nets[rnet->mport->id].peers, node) { + list_for_each_entry_safe(peer, tmp, &rionet_peers, node) { if (!(peer->res = rio_request_outb_dbell(peer->rdev, RIONET_DOORBELL_JOIN, RIONET_DOORBELL_LEAVE))) @@ -360,7 +346,7 @@ static int rionet_close(struct net_device *ndev) int i; if (netif_msg_ifup(rnet)) - printk(KERN_INFO "%s: close %s\n", DRV_NAME, ndev->name); + printk(KERN_INFO "%s: close\n", DRV_NAME); netif_stop_queue(ndev); netif_carrier_off(ndev); @@ -368,11 +354,10 @@ static int rionet_close(struct net_device *ndev) for (i = 0; i < RIONET_RX_RING_SIZE; i++) kfree_skb(rnet->rx_skb[i]); - list_for_each_entry_safe(peer, tmp, - &nets[rnet->mport->id].peers, node) { - if (nets[rnet->mport->id].active[peer->rdev->destid]) { + list_for_each_entry_safe(peer, tmp, &rionet_peers, node) { + if (rionet_active[peer->rdev->destid]) { rio_send_doorbell(peer->rdev, RIONET_DOORBELL_LEAVE); - nets[rnet->mport->id].active[peer->rdev->destid] = NULL; + rionet_active[peer->rdev->destid] = NULL; } rio_release_outb_dbell(peer->rdev, peer->res); } @@ -388,21 +373,17 @@ static int rionet_close(struct net_device *ndev) static void rionet_remove(struct rio_dev *rdev) { struct net_device *ndev = rio_get_drvdata(rdev); - unsigned char netid = rdev->net->hport->id; struct rionet_peer *peer, *tmp; - unregister_netdev(ndev); - - free_pages((unsigned long)nets[netid].active, get_order(sizeof(void *) * + free_pages((unsigned long)rionet_active, get_order(sizeof(void *) * RIO_MAX_ROUTE_ENTRIES(rdev->net->hport->sys_size))); - nets[netid].active = NULL; + unregister_netdev(ndev); + free_netdev(ndev); - list_for_each_entry_safe(peer, tmp, &nets[netid].peers, node) { + list_for_each_entry_safe(peer, tmp, &rionet_peers, node) { list_del(&peer->node); kfree(peer); } - - free_netdev(ndev); } static void rionet_get_drvinfo(struct net_device *ndev, @@ -454,13 +435,13 @@ static int rionet_setup_netdev(struct rio_mport *mport, struct net_device *ndev) const size_t rionet_active_bytes = sizeof(void *) * RIO_MAX_ROUTE_ENTRIES(mport->sys_size); - nets[mport->id].active = (struct rio_dev **)__get_free_pages(GFP_KERNEL, - get_order(rionet_active_bytes)); - if (!nets[mport->id].active) { + rionet_active = (struct rio_dev **)__get_free_pages(GFP_KERNEL, + get_order(rionet_active_bytes)); + if (!rionet_active) { rc = -ENOMEM; goto out; } - memset((void *)nets[mport->id].active, 0, rionet_active_bytes); + memset((void *)rionet_active, 0, rionet_active_bytes); /* Set up private area */ rnet = netdev_priv(ndev); @@ -489,62 +470,60 @@ static int rionet_setup_netdev(struct rio_mport *mport, struct net_device *ndev) if (rc != 0) goto out; - printk(KERN_INFO "%s: %s %s Version %s, MAC %pM, %s\n", + printk("%s: %s %s Version %s, MAC %pM\n", ndev->name, DRV_NAME, DRV_DESC, DRV_VERSION, - ndev->dev_addr, - mport->name); + ndev->dev_addr); out: return rc; } -static unsigned long net_table[RIONET_MAX_NETS/sizeof(unsigned long) + 1]; - +/* + * XXX Make multi-net safe + */ static int rionet_probe(struct rio_dev *rdev, const struct rio_device_id *id) { int rc = -ENODEV; u32 lsrc_ops, ldst_ops; struct rionet_peer *peer; struct net_device *ndev = NULL; - unsigned char netid = rdev->net->hport->id; - int oldnet; - if (netid >= RIONET_MAX_NETS) - return rc; + /* If local device is not rionet capable, give up quickly */ + if (!rionet_capable) + goto out; - oldnet = test_and_set_bit(netid, net_table); + /* Allocate our net_device structure */ + ndev = alloc_etherdev(sizeof(struct rionet_private)); + if (ndev == NULL) { + rc = -ENOMEM; + goto out; + } /* * First time through, make sure local device is rionet - * capable, setup netdev (will be skipped on later probes) + * capable, setup netdev, and set flags so this is skipped + * on later probes */ - if (!oldnet) { + if (!rionet_check) { rio_local_read_config_32(rdev->net->hport, RIO_SRC_OPS_CAR, &lsrc_ops); rio_local_read_config_32(rdev->net->hport, RIO_DST_OPS_CAR, &ldst_ops); if (!is_rionet_capable(lsrc_ops, ldst_ops)) { printk(KERN_ERR - "%s: local device %s is not network capable\n", - DRV_NAME, rdev->net->hport->name); + "%s: local device is not network capable\n", + DRV_NAME); + rionet_check = 1; + rionet_capable = 0; goto out; } - /* Allocate our net_device structure */ - ndev = alloc_etherdev(sizeof(struct rionet_private)); - if (ndev == NULL) { - rc = -ENOMEM; - goto out; - } - nets[netid].ndev = ndev; rc = rionet_setup_netdev(rdev->net->hport, ndev); - INIT_LIST_HEAD(&nets[netid].peers); - nets[netid].nact = 0; - } else if (nets[netid].ndev == NULL) - goto out; + rionet_check = 1; + } /* * If the remote device has mailbox/doorbell capabilities, @@ -556,10 +535,10 @@ static int rionet_probe(struct rio_dev *rdev, const struct rio_device_id *id) goto out; } peer->rdev = rdev; - list_add_tail(&peer->node, &nets[netid].peers); + list_add_tail(&peer->node, &rionet_peers); } - rio_set_drvdata(rdev, nets[netid].ndev); + rio_set_drvdata(rdev, ndev); out: return rc; diff --git a/trunk/drivers/net/team/team.c b/trunk/drivers/net/team/team.c index d44cca327588..5c7547c4f802 100644 --- a/trunk/drivers/net/team/team.c +++ b/trunk/drivers/net/team/team.c @@ -1315,7 +1315,6 @@ static const struct team_option team_options[] = { static struct lock_class_key team_netdev_xmit_lock_key; static struct lock_class_key team_netdev_addr_lock_key; -static struct lock_class_key team_tx_busylock_key; static void team_set_lockdep_class_one(struct net_device *dev, struct netdev_queue *txq, @@ -1328,7 +1327,6 @@ static void team_set_lockdep_class(struct net_device *dev) { lockdep_set_class(&dev->addr_list_lock, &team_netdev_addr_lock_key); netdev_for_each_tx_queue(dev, team_set_lockdep_class_one, NULL); - dev->qdisc_tx_busylock = &team_tx_busylock_key; } static int team_init(struct net_device *dev) diff --git a/trunk/drivers/net/wan/z85230.c b/trunk/drivers/net/wan/z85230.c index feacc3b994b7..0e5769061702 100644 --- a/trunk/drivers/net/wan/z85230.c +++ b/trunk/drivers/net/wan/z85230.c @@ -1775,7 +1775,7 @@ EXPORT_SYMBOL(z8530_queue_xmit); /* * Module support */ -static const char banner[] __initconst = +static const char banner[] __initdata = KERN_INFO "Generic Z85C30/Z85230 interface driver v0.02\n"; static int __init z85230_init_driver(void) diff --git a/trunk/drivers/net/xen-netback/netback.c b/trunk/drivers/net/xen-netback/netback.c index 4ebfcf3d8a3b..05593d882023 100644 --- a/trunk/drivers/net/xen-netback/netback.c +++ b/trunk/drivers/net/xen-netback/netback.c @@ -40,7 +40,6 @@ #include -#include #include #include diff --git a/trunk/drivers/net/xen-netfront.c b/trunk/drivers/net/xen-netfront.c index caa011008cd0..c934fe8583f5 100644 --- a/trunk/drivers/net/xen-netfront.c +++ b/trunk/drivers/net/xen-netfront.c @@ -43,7 +43,6 @@ #include #include -#include #include #include #include diff --git a/trunk/drivers/pci/hotplug/rpadlpar_core.c b/trunk/drivers/pci/hotplug/rpadlpar_core.c index b29e20b7862f..1e117c2a3cad 100644 --- a/trunk/drivers/pci/hotplug/rpadlpar_core.c +++ b/trunk/drivers/pci/hotplug/rpadlpar_core.c @@ -388,7 +388,7 @@ int dlpar_remove_pci_slot(char *drc_name, struct device_node *dn) /* Remove the EADS bridge device itself */ BUG_ON(!bus->self); pr_debug("PCI: Now removing bridge device %s\n", pci_name(bus->self)); - eeh_remove_bus_device(bus->self, true); + eeh_remove_bus_device(bus->self); pci_stop_and_remove_bus_device(bus->self); return 0; diff --git a/trunk/drivers/platform/x86/amilo-rfkill.c b/trunk/drivers/platform/x86/amilo-rfkill.c index 1deca7f6c4ea..a514bf66fdd7 100644 --- a/trunk/drivers/platform/x86/amilo-rfkill.c +++ b/trunk/drivers/platform/x86/amilo-rfkill.c @@ -74,7 +74,7 @@ static const struct rfkill_ops amilo_m7440_rfkill_ops = { .set_block = amilo_m7440_rfkill_set_block }; -static const struct dmi_system_id __devinitconst amilo_rfkill_id_table[] = { +static const struct dmi_system_id __devinitdata amilo_rfkill_id_table[] = { { .matches = { DMI_MATCH(DMI_SYS_VENDOR, "FUJITSU SIEMENS"), diff --git a/trunk/drivers/platform/x86/fujitsu-tablet.c b/trunk/drivers/platform/x86/fujitsu-tablet.c index f77484528b1b..7acae3f85f3b 100644 --- a/trunk/drivers/platform/x86/fujitsu-tablet.c +++ b/trunk/drivers/platform/x86/fujitsu-tablet.c @@ -52,7 +52,7 @@ struct fujitsu_config { unsigned int quirks; }; -static unsigned short keymap_Lifebook_Tseries[KEYMAP_LEN] __initdata = { +static unsigned short keymap_Lifebook_Tseries[KEYMAP_LEN] __initconst = { KEY_RESERVED, KEY_RESERVED, KEY_RESERVED, @@ -71,7 +71,7 @@ static unsigned short keymap_Lifebook_Tseries[KEYMAP_LEN] __initdata = { KEY_LEFTALT }; -static unsigned short keymap_Lifebook_U810[KEYMAP_LEN] __initdata = { +static unsigned short keymap_Lifebook_U810[KEYMAP_LEN] __initconst = { KEY_RESERVED, KEY_RESERVED, KEY_RESERVED, @@ -90,7 +90,7 @@ static unsigned short keymap_Lifebook_U810[KEYMAP_LEN] __initdata = { KEY_LEFTALT }; -static unsigned short keymap_Stylistic_Tseries[KEYMAP_LEN] __initdata = { +static unsigned short keymap_Stylistic_Tseries[KEYMAP_LEN] __initconst = { KEY_RESERVED, KEY_RESERVED, KEY_RESERVED, @@ -109,7 +109,7 @@ static unsigned short keymap_Stylistic_Tseries[KEYMAP_LEN] __initdata = { KEY_LEFTALT }; -static unsigned short keymap_Stylistic_ST5xxx[KEYMAP_LEN] __initdata = { +static unsigned short keymap_Stylistic_ST5xxx[KEYMAP_LEN] __initconst = { KEY_RESERVED, KEY_RESERVED, KEY_RESERVED, @@ -299,7 +299,7 @@ static int __devinit fujitsu_dmi_stylistic(const struct dmi_system_id *dmi) return 1; } -static const struct dmi_system_id dmi_ids[] __initconst = { +static struct dmi_system_id dmi_ids[] __initconst = { { .callback = fujitsu_dmi_lifebook, .ident = "Fujitsu Siemens P/T Series", diff --git a/trunk/drivers/platform/x86/thinkpad_acpi.c b/trunk/drivers/platform/x86/thinkpad_acpi.c index 75dd651664ae..9da5fe715e6a 100644 --- a/trunk/drivers/platform/x86/thinkpad_acpi.c +++ b/trunk/drivers/platform/x86/thinkpad_acpi.c @@ -522,7 +522,7 @@ static acpi_handle ec_handle; #define TPACPI_HANDLE(object, parent, paths...) \ static acpi_handle object##_handle; \ - static const acpi_handle * const object##_parent __initconst = \ + static const acpi_handle *object##_parent __initdata = \ &parent##_handle; \ static char *object##_paths[] __initdata = { paths } diff --git a/trunk/drivers/pps/pps.c b/trunk/drivers/pps/pps.c index 2420d5af0583..e771487132f7 100644 --- a/trunk/drivers/pps/pps.c +++ b/trunk/drivers/pps/pps.c @@ -306,7 +306,7 @@ int pps_register_cdev(struct pps_device *pps) if (err < 0) return err; - pps->id &= MAX_IDR_MASK; + pps->id &= MAX_ID_MASK; if (pps->id >= PPS_MAX_SOURCES) { pr_err("%s: too many PPS sources in the system\n", pps->info.name); diff --git a/trunk/drivers/pwm/Kconfig b/trunk/drivers/pwm/Kconfig index d7c6b83097c1..90c5c7357a50 100644 --- a/trunk/drivers/pwm/Kconfig +++ b/trunk/drivers/pwm/Kconfig @@ -115,15 +115,6 @@ config PWM_TIEHRPWM To compile this driver as a module, choose M here: the module will be called pwm-tiehrpwm. -config PWM_TWL6030 - tristate "TWL6030 PWM support" - depends on TWL4030_CORE - help - Generic PWM framework driver for TWL6030. - - To compile this driver as a module, choose M here: the module - will be called pwm-twl6030. - config PWM_VT8500 tristate "vt8500 pwm support" depends on ARCH_VT8500 diff --git a/trunk/drivers/pwm/Makefile b/trunk/drivers/pwm/Makefile index 78f123dca30d..e4b2c898964d 100644 --- a/trunk/drivers/pwm/Makefile +++ b/trunk/drivers/pwm/Makefile @@ -8,5 +8,4 @@ obj-$(CONFIG_PWM_SAMSUNG) += pwm-samsung.o obj-$(CONFIG_PWM_TEGRA) += pwm-tegra.o obj-$(CONFIG_PWM_TIECAP) += pwm-tiecap.o obj-$(CONFIG_PWM_TIEHRPWM) += pwm-tiehrpwm.o -obj-$(CONFIG_PWM_TWL6030) += pwm-twl6030.o obj-$(CONFIG_PWM_VT8500) += pwm-vt8500.o diff --git a/trunk/drivers/rapidio/devices/tsi721.c b/trunk/drivers/rapidio/devices/tsi721.c index 38ecd8f4d60e..d5e1625bbac2 100644 --- a/trunk/drivers/rapidio/devices/tsi721.c +++ b/trunk/drivers/rapidio/devices/tsi721.c @@ -861,90 +861,6 @@ static void tsi721_init_pc2sr_mapping(struct tsi721_device *priv) iowrite32(0, priv->regs + TSI721_OBWINLB(i)); } -/** - * tsi721_rio_map_inb_mem -- Mapping inbound memory region. - * @mport: RapidIO master port - * @lstart: Local memory space start address. - * @rstart: RapidIO space start address. - * @size: The mapping region size. - * @flags: Flags for mapping. 0 for using default flags. - * - * Return: 0 -- Success. - * - * This function will create the inbound mapping - * from rstart to lstart. - */ -static int tsi721_rio_map_inb_mem(struct rio_mport *mport, dma_addr_t lstart, - u64 rstart, u32 size, u32 flags) -{ - struct tsi721_device *priv = mport->priv; - int i; - u32 regval; - - if (!is_power_of_2(size) || size < 0x1000 || - ((u64)lstart & (size - 1)) || (rstart & (size - 1))) - return -EINVAL; - - /* Search for free inbound translation window */ - for (i = 0; i < TSI721_IBWIN_NUM; i++) { - regval = ioread32(priv->regs + TSI721_IBWIN_LB(i)); - if (!(regval & TSI721_IBWIN_LB_WEN)) - break; - } - - if (i >= TSI721_IBWIN_NUM) { - dev_err(&priv->pdev->dev, - "Unable to find free inbound window\n"); - return -EBUSY; - } - - iowrite32(TSI721_IBWIN_SIZE(size) << 8, - priv->regs + TSI721_IBWIN_SZ(i)); - - iowrite32(((u64)lstart >> 32), priv->regs + TSI721_IBWIN_TUA(i)); - iowrite32(((u64)lstart & TSI721_IBWIN_TLA_ADD), - priv->regs + TSI721_IBWIN_TLA(i)); - - iowrite32(rstart >> 32, priv->regs + TSI721_IBWIN_UB(i)); - iowrite32((rstart & TSI721_IBWIN_LB_BA) | TSI721_IBWIN_LB_WEN, - priv->regs + TSI721_IBWIN_LB(i)); - dev_dbg(&priv->pdev->dev, - "Configured IBWIN%d mapping (RIO_0x%llx -> PCIe_0x%llx)\n", - i, rstart, (unsigned long long)lstart); - - return 0; -} - -/** - * fsl_rio_unmap_inb_mem -- Unmapping inbound memory region. - * @mport: RapidIO master port - * @lstart: Local memory space start address. - */ -static void tsi721_rio_unmap_inb_mem(struct rio_mport *mport, - dma_addr_t lstart) -{ - struct tsi721_device *priv = mport->priv; - int i; - u64 addr; - u32 regval; - - /* Search for matching active inbound translation window */ - for (i = 0; i < TSI721_IBWIN_NUM; i++) { - regval = ioread32(priv->regs + TSI721_IBWIN_LB(i)); - if (regval & TSI721_IBWIN_LB_WEN) { - regval = ioread32(priv->regs + TSI721_IBWIN_TUA(i)); - addr = (u64)regval << 32; - regval = ioread32(priv->regs + TSI721_IBWIN_TLA(i)); - addr |= regval & TSI721_IBWIN_TLA_ADD; - - if (addr == (u64)lstart) { - iowrite32(0, priv->regs + TSI721_IBWIN_LB(i)); - break; - } - } - } -} - /** * tsi721_init_sr2pc_mapping - initializes inbound (SRIO->PCIe) * translation regions. @@ -958,7 +874,7 @@ static void tsi721_init_sr2pc_mapping(struct tsi721_device *priv) /* Disable all SR2PC inbound windows */ for (i = 0; i < TSI721_IBWIN_NUM; i++) - iowrite32(0, priv->regs + TSI721_IBWIN_LB(i)); + iowrite32(0, priv->regs + TSI721_IBWINLB(i)); } /** @@ -2228,8 +2144,6 @@ static int __devinit tsi721_setup_mport(struct tsi721_device *priv) ops->add_outb_message = tsi721_add_outb_message; ops->add_inb_buffer = tsi721_add_inb_buffer; ops->get_inb_message = tsi721_get_inb_message; - ops->map_inb = tsi721_rio_map_inb_mem; - ops->unmap_inb = tsi721_rio_unmap_inb_mem; mport = kzalloc(sizeof(struct rio_mport), GFP_KERNEL); if (!mport) { @@ -2251,8 +2165,7 @@ static int __devinit tsi721_setup_mport(struct tsi721_device *priv) rio_init_dbell_res(&mport->riores[RIO_DOORBELL_RESOURCE], 0, 0xffff); rio_init_mbox_res(&mport->riores[RIO_INB_MBOX_RESOURCE], 0, 3); rio_init_mbox_res(&mport->riores[RIO_OUTB_MBOX_RESOURCE], 0, 3); - snprintf(mport->name, RIO_MAX_MPORT_NAME, "%s(%s)", - dev_driver_string(&pdev->dev), dev_name(&pdev->dev)); + strcpy(mport->name, "Tsi721 mport"); /* Hook up interrupt handler */ @@ -2402,8 +2315,7 @@ static int __devinit tsi721_probe(struct pci_dev *pdev, /* Configure DMA attributes. */ if (pci_set_dma_mask(pdev, DMA_BIT_MASK(64))) { - err = pci_set_dma_mask(pdev, DMA_BIT_MASK(32)); - if (err) { + if (pci_set_dma_mask(pdev, DMA_BIT_MASK(32))) { dev_info(&pdev->dev, "Unable to set DMA mask\n"); goto err_unmap_bars; } diff --git a/trunk/drivers/rapidio/devices/tsi721.h b/trunk/drivers/rapidio/devices/tsi721.h index 7d5b13ba8d4f..59de9d7be346 100644 --- a/trunk/drivers/rapidio/devices/tsi721.h +++ b/trunk/drivers/rapidio/devices/tsi721.h @@ -156,18 +156,9 @@ #define TSI721_IBWIN_NUM 8 -#define TSI721_IBWIN_LB(x) (0x29000 + (x) * 0x20) -#define TSI721_IBWIN_LB_BA 0xfffff000 -#define TSI721_IBWIN_LB_WEN 0x00000001 - -#define TSI721_IBWIN_UB(x) (0x29004 + (x) * 0x20) -#define TSI721_IBWIN_SZ(x) (0x29008 + (x) * 0x20) -#define TSI721_IBWIN_SZ_SIZE 0x00001f00 -#define TSI721_IBWIN_SIZE(size) (__fls(size) - 12) - -#define TSI721_IBWIN_TLA(x) (0x2900c + (x) * 0x20) -#define TSI721_IBWIN_TLA_ADD 0xfffff000 -#define TSI721_IBWIN_TUA(x) (0x29010 + (x) * 0x20) +#define TSI721_IBWINLB(x) (0x29000 + (x) * 0x20) +#define TSI721_IBWINLB_BA 0xfffff000 +#define TSI721_IBWINLB_WEN 0x00000001 #define TSI721_SR2PC_GEN_INTE 0x29800 #define TSI721_SR2PC_PWE 0x29804 diff --git a/trunk/drivers/rapidio/rio-scan.c b/trunk/drivers/rapidio/rio-scan.c index 48e9041dd1e2..2bebd791a092 100644 --- a/trunk/drivers/rapidio/rio-scan.c +++ b/trunk/drivers/rapidio/rio-scan.c @@ -31,21 +31,27 @@ #include #include #include -#include #include #include #include "rio.h" LIST_HEAD(rio_devices); +static LIST_HEAD(rio_switches); + +static void rio_enum_timeout(unsigned long); static void rio_init_em(struct rio_dev *rdev); DEFINE_SPINLOCK(rio_global_list_lock); static int next_destid = 0; +static int next_net = 0; static int next_comptag = 1; +static struct timer_list rio_enum_timer = +TIMER_INITIALIZER(rio_enum_timeout, 0, 0); + static int rio_mport_phys_table[] = { RIO_EFB_PAR_EP_ID, RIO_EFB_PAR_EP_REC_ID, @@ -54,114 +60,6 @@ static int rio_mport_phys_table[] = { -1, }; - -/* - * rio_destid_alloc - Allocate next available destID for given network - * net: RIO network - * - * Returns next available device destination ID for the specified RIO network. - * Marks allocated ID as one in use. - * Returns RIO_INVALID_DESTID if new destID is not available. - */ -static u16 rio_destid_alloc(struct rio_net *net) -{ - int destid; - struct rio_id_table *idtab = &net->destid_table; - - spin_lock(&idtab->lock); - destid = find_next_zero_bit(idtab->table, idtab->max, idtab->next); - if (destid >= idtab->max) - destid = find_first_zero_bit(idtab->table, idtab->max); - - if (destid < idtab->max) { - idtab->next = destid + 1; - if (idtab->next >= idtab->max) - idtab->next = 0; - set_bit(destid, idtab->table); - destid += idtab->start; - } else - destid = RIO_INVALID_DESTID; - - spin_unlock(&idtab->lock); - return (u16)destid; -} - -/* - * rio_destid_reserve - Reserve the specivied destID - * net: RIO network - * destid: destID to reserve - * - * Tries to reserve the specified destID. - * Returns 0 if successfull. - */ -static int rio_destid_reserve(struct rio_net *net, u16 destid) -{ - int oldbit; - struct rio_id_table *idtab = &net->destid_table; - - destid -= idtab->start; - spin_lock(&idtab->lock); - oldbit = test_and_set_bit(destid, idtab->table); - spin_unlock(&idtab->lock); - return oldbit; -} - -/* - * rio_destid_free - free a previously allocated destID - * net: RIO network - * destid: destID to free - * - * Makes the specified destID available for use. - */ -static void rio_destid_free(struct rio_net *net, u16 destid) -{ - struct rio_id_table *idtab = &net->destid_table; - - destid -= idtab->start; - spin_lock(&idtab->lock); - clear_bit(destid, idtab->table); - spin_unlock(&idtab->lock); -} - -/* - * rio_destid_first - return first destID in use - * net: RIO network - */ -static u16 rio_destid_first(struct rio_net *net) -{ - int destid; - struct rio_id_table *idtab = &net->destid_table; - - spin_lock(&idtab->lock); - destid = find_first_bit(idtab->table, idtab->max); - if (destid >= idtab->max) - destid = RIO_INVALID_DESTID; - else - destid += idtab->start; - spin_unlock(&idtab->lock); - return (u16)destid; -} - -/* - * rio_destid_next - return next destID in use - * net: RIO network - * from: destination ID from which search shall continue - */ -static u16 rio_destid_next(struct rio_net *net, u16 from) -{ - int destid; - struct rio_id_table *idtab = &net->destid_table; - - spin_lock(&idtab->lock); - destid = find_next_bit(idtab->table, idtab->max, from); - if (destid >= idtab->max) - destid = RIO_INVALID_DESTID; - else - destid += idtab->start; - spin_unlock(&idtab->lock); - return (u16)destid; -} - /** * rio_get_device_id - Get the base/extended device id for a device * @port: RIO master port @@ -210,15 +108,14 @@ static void rio_local_set_device_id(struct rio_mport *port, u16 did) /** * rio_clear_locks- Release all host locks and signal enumeration complete - * @net: RIO network to run on + * @port: Master port to issue transaction * * Marks the component tag CSR on each device with the enumeration * complete flag. When complete, it then release the host locks on * each device. Returns 0 on success or %-EINVAL on failure. */ -static int rio_clear_locks(struct rio_net *net) +static int rio_clear_locks(struct rio_mport *port) { - struct rio_mport *port = net->hport; struct rio_dev *rdev; u32 result; int ret = 0; @@ -233,7 +130,7 @@ static int rio_clear_locks(struct rio_net *net) result); ret = -EINVAL; } - list_for_each_entry(rdev, &net->devices, net_list) { + list_for_each_entry(rdev, &rio_devices, global_list) { rio_write_config_32(rdev, RIO_HOST_DID_LOCK_CSR, port->host_deviceid); rio_read_config_32(rdev, RIO_HOST_DID_LOCK_CSR, &result); @@ -279,6 +176,10 @@ static int rio_enum_host(struct rio_mport *port) /* Set master port destid and init destid ctr */ rio_local_set_device_id(port, port->host_deviceid); + + if (next_destid == port->host_deviceid) + next_destid++; + return 0; } @@ -545,8 +446,9 @@ static struct rio_dev __devinit *rio_setup_device(struct rio_net *net, if (rio_device_has_destid(port, rdev->src_ops, rdev->dst_ops)) { if (do_enum) { rio_set_device_id(port, destid, hopcount, next_destid); - rdev->destid = next_destid; - next_destid = rio_destid_alloc(net); + rdev->destid = next_destid++; + if (next_destid == port->host_deviceid) + next_destid++; } else rdev->destid = rio_get_device_id(port, destid, hopcount); @@ -581,7 +483,7 @@ static struct rio_dev __devinit *rio_setup_device(struct rio_net *net, rswitch->clr_table(port, destid, hopcount, RIO_GLOBAL_TABLE); - list_add_tail(&rswitch->node, &net->switches); + list_add_tail(&rswitch->node, &rio_switches); } else { if (do_enum) @@ -845,7 +747,12 @@ static u16 rio_get_host_deviceid_lock(struct rio_mport *port, u8 hopcount) static int __devinit rio_enum_peer(struct rio_net *net, struct rio_mport *port, u8 hopcount, struct rio_dev *prev, int prev_port) { + int port_num; + int cur_destid; + int sw_destid; + int sw_inport; struct rio_dev *rdev; + u16 destid; u32 regval; int tmp; @@ -911,26 +818,19 @@ static int __devinit rio_enum_peer(struct rio_net *net, struct rio_mport *port, return -1; if (rio_is_switch(rdev)) { - int sw_destid; - int cur_destid; - int sw_inport; - u16 destid; - int port_num; - sw_inport = RIO_GET_PORT_NUM(rdev->swpinfo); rio_route_add_entry(rdev, RIO_GLOBAL_TABLE, port->host_deviceid, sw_inport, 0); rdev->rswitch->route_table[port->host_deviceid] = sw_inport; - destid = rio_destid_first(net); - while (destid != RIO_INVALID_DESTID && destid < next_destid) { - if (destid != port->host_deviceid) { - rio_route_add_entry(rdev, RIO_GLOBAL_TABLE, - destid, sw_inport, 0); - rdev->rswitch->route_table[destid] = sw_inport; - } - destid = rio_destid_next(net, destid + 1); + for (destid = 0; destid < next_destid; destid++) { + if (destid == port->host_deviceid) + continue; + rio_route_add_entry(rdev, RIO_GLOBAL_TABLE, + destid, sw_inport, 0); + rdev->rswitch->route_table[destid] = sw_inport; } + pr_debug( "RIO: found %s (vid %4.4x did %4.4x) with %d ports\n", rio_name(rdev), rdev->vid, rdev->did, @@ -939,10 +839,12 @@ static int __devinit rio_enum_peer(struct rio_net *net, struct rio_mport *port, for (port_num = 0; port_num < RIO_GET_TOTAL_PORTS(rdev->swpinfo); port_num++) { - if (sw_inport == port_num) { - rio_enable_rx_tx_port(port, 0, + /*Enable Input Output Port (transmitter reviever)*/ + rio_enable_rx_tx_port(port, 0, RIO_ANY_DESTID(port->sys_size), hopcount, port_num); + + if (sw_inport == port_num) { rdev->rswitch->port_ok |= (1 << port_num); continue; } @@ -955,9 +857,6 @@ static int __devinit rio_enum_peer(struct rio_net *net, struct rio_mport *port, pr_debug( "RIO: scanning device on port %d\n", port_num); - rio_enable_rx_tx_port(port, 0, - RIO_ANY_DESTID(port->sys_size), - hopcount, port_num); rdev->rswitch->port_ok |= (1 << port_num); rio_route_add_entry(rdev, RIO_GLOBAL_TABLE, RIO_ANY_DESTID(port->sys_size), @@ -968,22 +867,19 @@ static int __devinit rio_enum_peer(struct rio_net *net, struct rio_mport *port, return -1; /* Update routing tables */ - destid = rio_destid_next(net, cur_destid + 1); - if (destid != RIO_INVALID_DESTID) { + if (next_destid > cur_destid) { for (destid = cur_destid; - destid < next_destid;) { - if (destid != port->host_deviceid) { - rio_route_add_entry(rdev, + destid < next_destid; destid++) { + if (destid == port->host_deviceid) + continue; + rio_route_add_entry(rdev, RIO_GLOBAL_TABLE, destid, port_num, 0); - rdev->rswitch-> - route_table[destid] = - port_num; - } - destid = rio_destid_next(net, - destid + 1); + rdev->rswitch-> + route_table[destid] = + port_num; } } } else { @@ -1009,8 +905,11 @@ static int __devinit rio_enum_peer(struct rio_net *net, struct rio_mport *port, rio_init_em(rdev); /* Check for empty switch */ - if (next_destid == sw_destid) - next_destid = rio_destid_alloc(net); + if (next_destid == sw_destid) { + next_destid++; + if (next_destid == port->host_deviceid) + next_destid++; + } rdev->destid = sw_destid; } else @@ -1148,71 +1047,48 @@ static int rio_mport_is_active(struct rio_mport *port) /** * rio_alloc_net- Allocate and configure a new RIO network * @port: Master port associated with the RIO network - * @do_enum: Enumeration/Discovery mode flag - * @start: logical minimal start id for new net * * Allocates a RIO network structure, initializes per-network * list heads, and adds the associated master port to the * network list of associated master ports. Returns a * RIO network pointer on success or %NULL on failure. */ -static struct rio_net __devinit *rio_alloc_net(struct rio_mport *port, - int do_enum, u16 start) +static struct rio_net __devinit *rio_alloc_net(struct rio_mport *port) { struct rio_net *net; net = kzalloc(sizeof(struct rio_net), GFP_KERNEL); - if (net && do_enum) { - net->destid_table.table = kzalloc( - BITS_TO_LONGS(RIO_MAX_ROUTE_ENTRIES(port->sys_size)) * - sizeof(long), - GFP_KERNEL); - - if (net->destid_table.table == NULL) { - pr_err("RIO: failed to allocate destID table\n"); - kfree(net); - net = NULL; - } else { - net->destid_table.start = start; - net->destid_table.next = 0; - net->destid_table.max = - RIO_MAX_ROUTE_ENTRIES(port->sys_size); - spin_lock_init(&net->destid_table.lock); - } - } - if (net) { INIT_LIST_HEAD(&net->node); INIT_LIST_HEAD(&net->devices); - INIT_LIST_HEAD(&net->switches); INIT_LIST_HEAD(&net->mports); list_add_tail(&port->nnode, &net->mports); net->hport = port; - net->id = port->id; + net->id = next_net++; } return net; } /** * rio_update_route_tables- Updates route tables in switches - * @net: RIO network to run update on + * @port: Master port associated with the RIO network * * For each enumerated device, ensure that each switch in a system * has correct routing entries. Add routes for devices that where * unknown dirung the first enumeration pass through the switch. */ -static void rio_update_route_tables(struct rio_net *net) +static void rio_update_route_tables(struct rio_mport *port) { struct rio_dev *rdev, *swrdev; struct rio_switch *rswitch; u8 sport; u16 destid; - list_for_each_entry(rdev, &net->devices, net_list) { + list_for_each_entry(rdev, &rio_devices, global_list) { destid = rdev->destid; - list_for_each_entry(rswitch, &net->switches, node) { + list_for_each_entry(rswitch, &rio_switches, node) { if (rio_is_switch(rdev) && (rdev->rswitch == rswitch)) continue; @@ -1290,16 +1166,12 @@ int __devinit rio_enum_mport(struct rio_mport *mport) /* If master port has an active link, allocate net and enum peers */ if (rio_mport_is_active(mport)) { - net = rio_alloc_net(mport, 1, 0); - if (!net) { + if (!(net = rio_alloc_net(mport))) { printk(KERN_ERR "RIO: failed to allocate new net\n"); rc = -ENOMEM; goto out; } - /* reserve mport destID in new net */ - rio_destid_reserve(net, mport->host_deviceid); - /* Enable Input Output Port (transmitter reviever) */ rio_enable_rx_tx_port(mport, 1, 0, 0, 0); @@ -1307,21 +1179,17 @@ int __devinit rio_enum_mport(struct rio_mport *mport) rio_local_write_config_32(mport, RIO_COMPONENT_TAG_CSR, next_comptag++); - next_destid = rio_destid_alloc(net); - if (rio_enum_peer(net, mport, 0, NULL, 0) < 0) { /* A higher priority host won enumeration, bail. */ printk(KERN_INFO "RIO: master port %d device has lost enumeration to a remote host\n", mport->id); - rio_clear_locks(net); + rio_clear_locks(mport); rc = -EBUSY; goto out; } - /* free the last allocated destID (unused) */ - rio_destid_free(net, next_destid); - rio_update_route_tables(net); - rio_clear_locks(net); + rio_update_route_tables(mport); + rio_clear_locks(mport); rio_pw_enable(mport, 1); } else { printk(KERN_INFO "RIO: master port %d link inactive\n", @@ -1335,34 +1203,47 @@ int __devinit rio_enum_mport(struct rio_mport *mport) /** * rio_build_route_tables- Generate route tables from switch route entries - * @net: RIO network to run route tables scan on * * For each switch device, generate a route table by copying existing * route entries from the switch. */ -static void rio_build_route_tables(struct rio_net *net) +static void rio_build_route_tables(void) { - struct rio_switch *rswitch; struct rio_dev *rdev; int i; u8 sport; - list_for_each_entry(rswitch, &net->switches, node) { - rdev = sw_to_rio_dev(rswitch); + list_for_each_entry(rdev, &rio_devices, global_list) + if (rio_is_switch(rdev)) { + rio_lock_device(rdev->net->hport, rdev->destid, + rdev->hopcount, 1000); + for (i = 0; + i < RIO_MAX_ROUTE_ENTRIES(rdev->net->hport->sys_size); + i++) { + if (rio_route_get_entry(rdev, + RIO_GLOBAL_TABLE, i, &sport, 0) < 0) + continue; + rdev->rswitch->route_table[i] = sport; + } - rio_lock_device(net->hport, rdev->destid, - rdev->hopcount, 1000); - for (i = 0; - i < RIO_MAX_ROUTE_ENTRIES(net->hport->sys_size); - i++) { - if (rio_route_get_entry(rdev, RIO_GLOBAL_TABLE, - i, &sport, 0) < 0) - continue; - rswitch->route_table[i] = sport; + rio_unlock_device(rdev->net->hport, + rdev->destid, + rdev->hopcount); } +} - rio_unlock_device(net->hport, rdev->destid, rdev->hopcount); - } +/** + * rio_enum_timeout- Signal that enumeration timed out + * @data: Address of timeout flag. + * + * When the enumeration complete timer expires, set a flag that + * signals to the discovery process that enumeration did not + * complete in a sane amount of time. + */ +static void rio_enum_timeout(unsigned long data) +{ + /* Enumeration timed out, set flag */ + *(int *)data = 1; } /** @@ -1378,34 +1259,35 @@ static void rio_build_route_tables(struct rio_net *net) int __devinit rio_disc_mport(struct rio_mport *mport) { struct rio_net *net = NULL; - unsigned long to_end; + int enum_timeout_flag = 0; printk(KERN_INFO "RIO: discover master port %d, %s\n", mport->id, mport->name); /* If master port has an active link, allocate net and discover peers */ if (rio_mport_is_active(mport)) { - pr_debug("RIO: wait for enumeration to complete...\n"); - - to_end = jiffies + CONFIG_RAPIDIO_DISC_TIMEOUT * HZ; - while (time_before(jiffies, to_end)) { - if (rio_enum_complete(mport)) - goto enum_done; - schedule_timeout_uninterruptible(msecs_to_jiffies(10)); - } - - pr_debug("RIO: discovery timeout on mport %d %s\n", - mport->id, mport->name); - goto bail; -enum_done: - pr_debug("RIO: ... enumeration done\n"); - - net = rio_alloc_net(mport, 0, 0); - if (!net) { + if (!(net = rio_alloc_net(mport))) { printk(KERN_ERR "RIO: Failed to allocate new net\n"); goto bail; } + pr_debug("RIO: wait for enumeration complete..."); + + rio_enum_timer.expires = + jiffies + CONFIG_RAPIDIO_DISC_TIMEOUT * HZ; + rio_enum_timer.data = (unsigned long)&enum_timeout_flag; + add_timer(&rio_enum_timer); + while (!rio_enum_complete(mport)) { + mdelay(1); + if (enum_timeout_flag) { + del_timer_sync(&rio_enum_timer); + goto timeout; + } + } + del_timer_sync(&rio_enum_timer); + + pr_debug("done\n"); + /* Read DestID assigned by enumerator */ rio_local_read_config_32(mport, RIO_DID_CSR, &mport->host_deviceid); @@ -1420,10 +1302,13 @@ int __devinit rio_disc_mport(struct rio_mport *mport) goto bail; } - rio_build_route_tables(net); + rio_build_route_tables(); } return 0; -bail: + + timeout: + pr_debug("timeout\n"); + bail: return -EBUSY; } diff --git a/trunk/drivers/rapidio/rio.c b/trunk/drivers/rapidio/rio.c index d4bd69013c50..c40665a4fa33 100644 --- a/trunk/drivers/rapidio/rio.c +++ b/trunk/drivers/rapidio/rio.c @@ -33,7 +33,6 @@ static LIST_HEAD(rio_mports); static unsigned char next_portid; -static DEFINE_SPINLOCK(rio_mmap_lock); /** * rio_local_get_device_id - Get the base/extended device id for a port @@ -398,49 +397,6 @@ int rio_release_inb_pwrite(struct rio_dev *rdev) } EXPORT_SYMBOL_GPL(rio_release_inb_pwrite); -/** - * rio_map_inb_region -- Map inbound memory region. - * @mport: Master port. - * @lstart: physical address of memory region to be mapped - * @rbase: RIO base address assigned to this window - * @size: Size of the memory region - * @rflags: Flags for mapping. - * - * Return: 0 -- Success. - * - * This function will create the mapping from RIO space to local memory. - */ -int rio_map_inb_region(struct rio_mport *mport, dma_addr_t local, - u64 rbase, u32 size, u32 rflags) -{ - int rc = 0; - unsigned long flags; - - if (!mport->ops->map_inb) - return -1; - spin_lock_irqsave(&rio_mmap_lock, flags); - rc = mport->ops->map_inb(mport, local, rbase, size, rflags); - spin_unlock_irqrestore(&rio_mmap_lock, flags); - return rc; -} -EXPORT_SYMBOL_GPL(rio_map_inb_region); - -/** - * rio_unmap_inb_region -- Unmap the inbound memory region - * @mport: Master port - * @lstart: physical address of memory region to be unmapped - */ -void rio_unmap_inb_region(struct rio_mport *mport, dma_addr_t lstart) -{ - unsigned long flags; - if (!mport->ops->unmap_inb) - return; - spin_lock_irqsave(&rio_mmap_lock, flags); - mport->ops->unmap_inb(mport, lstart); - spin_unlock_irqrestore(&rio_mmap_lock, flags); -} -EXPORT_SYMBOL_GPL(rio_unmap_inb_region); - /** * rio_mport_get_physefb - Helper function that returns register offset * for Physical Layer Extended Features Block. @@ -1260,62 +1216,15 @@ static int __devinit rio_init(void) return 0; } -static struct workqueue_struct *rio_wq; - -struct rio_disc_work { - struct work_struct work; - struct rio_mport *mport; -}; - -static void __devinit disc_work_handler(struct work_struct *_work) -{ - struct rio_disc_work *work; - - work = container_of(_work, struct rio_disc_work, work); - pr_debug("RIO: discovery work for mport %d %s\n", - work->mport->id, work->mport->name); - rio_disc_mport(work->mport); - - kfree(work); -} - int __devinit rio_init_mports(void) { struct rio_mport *port; - struct rio_disc_work *work; - int no_disc = 0; list_for_each_entry(port, &rio_mports, node) { if (port->host_deviceid >= 0) rio_enum_mport(port); - else if (!no_disc) { - if (!rio_wq) { - rio_wq = alloc_workqueue("riodisc", 0, 0); - if (!rio_wq) { - pr_err("RIO: unable allocate rio_wq\n"); - no_disc = 1; - continue; - } - } - - work = kzalloc(sizeof *work, GFP_KERNEL); - if (!work) { - pr_err("RIO: no memory for work struct\n"); - no_disc = 1; - continue; - } - - work->mport = port; - INIT_WORK(&work->work, disc_work_handler); - queue_work(rio_wq, &work->work); - } - } - - if (rio_wq) { - pr_debug("RIO: flush discovery workqueue\n"); - flush_workqueue(rio_wq); - pr_debug("RIO: flush discovery workqueue finished\n"); - destroy_workqueue(rio_wq); + else + rio_disc_mport(port); } rio_init(); diff --git a/trunk/drivers/regulator/88pm8607.c b/trunk/drivers/regulator/88pm8607.c index 1c5ab0172ea2..c3482b954cb7 100644 --- a/trunk/drivers/regulator/88pm8607.c +++ b/trunk/drivers/regulator/88pm8607.c @@ -12,8 +12,6 @@ #include #include #include -#include -#include #include #include #include @@ -25,7 +23,6 @@ struct pm8607_regulator_info { struct pm860x_chip *chip; struct regulator_dev *regulator; struct i2c_client *i2c; - struct i2c_client *i2c_8606; unsigned int *vol_table; unsigned int *vol_suspend; @@ -245,35 +242,6 @@ static int pm8607_set_voltage_sel(struct regulator_dev *rdev, unsigned selector) return ret; } -static int pm8606_preg_enable(struct regulator_dev *rdev) -{ - struct pm8607_regulator_info *info = rdev_get_drvdata(rdev); - - return pm860x_set_bits(info->i2c, rdev->desc->enable_reg, - 1 << rdev->desc->enable_mask, 0); -} - -static int pm8606_preg_disable(struct regulator_dev *rdev) -{ - struct pm8607_regulator_info *info = rdev_get_drvdata(rdev); - - return pm860x_set_bits(info->i2c, rdev->desc->enable_reg, - 1 << rdev->desc->enable_mask, - 1 << rdev->desc->enable_mask); -} - -static int pm8606_preg_is_enabled(struct regulator_dev *rdev) -{ - struct pm8607_regulator_info *info = rdev_get_drvdata(rdev); - int ret; - - ret = pm860x_reg_read(info->i2c, rdev->desc->enable_reg); - if (ret < 0) - return ret; - - return !((unsigned char)ret & (1 << rdev->desc->enable_mask)); -} - static struct regulator_ops pm8607_regulator_ops = { .list_voltage = pm8607_list_voltage, .set_voltage_sel = pm8607_set_voltage_sel, @@ -283,25 +251,6 @@ static struct regulator_ops pm8607_regulator_ops = { .is_enabled = regulator_is_enabled_regmap, }; -static struct regulator_ops pm8606_preg_ops = { - .enable = pm8606_preg_enable, - .disable = pm8606_preg_disable, - .is_enabled = pm8606_preg_is_enabled, -}; - -#define PM8606_PREG(ereg, ebit) \ -{ \ - .desc = { \ - .name = "PREG", \ - .ops = &pm8606_preg_ops, \ - .type = REGULATOR_CURRENT, \ - .id = PM8606_ID_PREG, \ - .owner = THIS_MODULE, \ - .enable_reg = PM8606_##ereg, \ - .enable_mask = (ebit), \ - }, \ -} - #define PM8607_DVC(vreg, ureg, ubit, ereg, ebit) \ { \ .desc = { \ @@ -362,38 +311,6 @@ static struct pm8607_regulator_info pm8607_regulator_info[] = { PM8607_LDO(14, LDO14, 0, SUPPLIES_EN12, 6), }; -static struct pm8607_regulator_info pm8606_regulator_info[] = { - PM8606_PREG(PREREGULATORB, 5), -}; - -#ifdef CONFIG_OF -static int pm8607_regulator_dt_init(struct platform_device *pdev, - struct pm8607_regulator_info *info, - struct regulator_config *config) -{ - struct device_node *nproot, *np; - nproot = pdev->dev.parent->of_node; - if (!nproot) - return -ENODEV; - nproot = of_find_node_by_name(nproot, "regulators"); - if (!nproot) { - dev_err(&pdev->dev, "failed to find regulators node\n"); - return -ENODEV; - } - for_each_child_of_node(nproot, np) { - if (!of_node_cmp(np->name, info->desc.name)) { - config->init_data = - of_get_regulator_init_data(&pdev->dev, np); - config->of_node = np; - break; - } - } - return 0; -} -#else -#define pm8607_regulator_dt_init(x, y, z) (-1) -#endif - static int __devinit pm8607_regulator_probe(struct platform_device *pdev) { struct pm860x_chip *chip = dev_get_drvdata(pdev->dev.parent); @@ -403,28 +320,22 @@ static int __devinit pm8607_regulator_probe(struct platform_device *pdev) struct resource *res; int i; - res = platform_get_resource(pdev, IORESOURCE_REG, 0); - if (res) { - /* There're resources in 88PM8607 regulator driver */ - for (i = 0; i < ARRAY_SIZE(pm8607_regulator_info); i++) { - info = &pm8607_regulator_info[i]; - if (info->desc.vsel_reg == res->start) - break; - } - if (i == ARRAY_SIZE(pm8607_regulator_info)) { - dev_err(&pdev->dev, "Failed to find regulator %llu\n", - (unsigned long long)res->start); - return -EINVAL; - } - } else { - /* There's no resource in 88PM8606 PREG regulator driver */ - info = &pm8606_regulator_info[0]; - /* i is used to check regulator ID */ - i = -1; + res = platform_get_resource(pdev, IORESOURCE_IO, 0); + if (res == NULL) { + dev_err(&pdev->dev, "No I/O resource!\n"); + return -EINVAL; + } + for (i = 0; i < ARRAY_SIZE(pm8607_regulator_info); i++) { + info = &pm8607_regulator_info[i]; + if (info->desc.id == res->start) + break; + } + if (i == ARRAY_SIZE(pm8607_regulator_info)) { + dev_err(&pdev->dev, "Failed to find regulator %llu\n", + (unsigned long long)res->start); + return -EINVAL; } info->i2c = (chip->id == CHIP_PM8607) ? chip->client : chip->companion; - info->i2c_8606 = (chip->id == CHIP_PM8607) ? chip->companion : - chip->client; info->chip = chip; /* check DVC ramp slope double */ @@ -432,17 +343,15 @@ static int __devinit pm8607_regulator_probe(struct platform_device *pdev) info->slope_double = 1; config.dev = &pdev->dev; + config.init_data = pdata; config.driver_data = info; - if (pm8607_regulator_dt_init(pdev, info, &config)) - if (pdata) - config.init_data = pdata; - if (chip->id == CHIP_PM8607) config.regmap = chip->regmap; else config.regmap = chip->regmap_companion; + /* replace driver_data with info */ info->regulator = regulator_register(&info->desc, &config); if (IS_ERR(info->regulator)) { dev_err(&pdev->dev, "failed to register regulator %s\n", @@ -463,18 +372,6 @@ static int __devexit pm8607_regulator_remove(struct platform_device *pdev) return 0; } -static struct platform_device_id pm8607_regulator_driver_ids[] = { - { - .name = "88pm860x-regulator", - .driver_data = 0, - }, { - .name = "88pm860x-preg", - .driver_data = 0, - }, - { }, -}; -MODULE_DEVICE_TABLE(platform, pm8607_regulator_driver_ids); - static struct platform_driver pm8607_regulator_driver = { .driver = { .name = "88pm860x-regulator", @@ -482,7 +379,6 @@ static struct platform_driver pm8607_regulator_driver = { }, .probe = pm8607_regulator_probe, .remove = __devexit_p(pm8607_regulator_remove), - .id_table = pm8607_regulator_driver_ids, }; static int __init pm8607_regulator_init(void) diff --git a/trunk/drivers/regulator/Kconfig b/trunk/drivers/regulator/Kconfig index 67d47b59a66d..e98a5e7827df 100644 --- a/trunk/drivers/regulator/Kconfig +++ b/trunk/drivers/regulator/Kconfig @@ -122,7 +122,7 @@ config REGULATOR_FAN53555 config REGULATOR_ANATOP tristate "Freescale i.MX on-chip ANATOP LDO regulators" - depends on MFD_SYSCON + depends on MFD_ANATOP help Say y here to support Freescale i.MX on-chip ANATOP LDOs regulators. It is recommended that this option be diff --git a/trunk/drivers/regulator/ab3100.c b/trunk/drivers/regulator/ab3100.c index df4ad8927f0c..65ad2b36ce36 100644 --- a/trunk/drivers/regulator/ab3100.c +++ b/trunk/drivers/regulator/ab3100.c @@ -15,7 +15,6 @@ #include #include #include -#include #include /* LDO registers and some handy masking definitions for AB3100 */ diff --git a/trunk/drivers/regulator/anatop-regulator.c b/trunk/drivers/regulator/anatop-regulator.c index 1af97686f444..ce0fe72a428e 100644 --- a/trunk/drivers/regulator/anatop-regulator.c +++ b/trunk/drivers/regulator/anatop-regulator.c @@ -21,20 +21,19 @@ #include #include #include -#include #include #include #include #include #include -#include +#include #include #include struct anatop_regulator { const char *name; u32 control_reg; - struct regmap *anatop; + struct anatop *mfd; int vol_bit_shift; int vol_bit_width; int min_bit_val; @@ -44,8 +43,7 @@ struct anatop_regulator { struct regulator_init_data *initdata; }; -static int anatop_regmap_set_voltage_sel(struct regulator_dev *reg, - unsigned selector) +static int anatop_set_voltage_sel(struct regulator_dev *reg, unsigned selector) { struct anatop_regulator *anatop_reg = rdev_get_drvdata(reg); u32 val, mask; @@ -58,13 +56,12 @@ static int anatop_regmap_set_voltage_sel(struct regulator_dev *reg, mask = ((1 << anatop_reg->vol_bit_width) - 1) << anatop_reg->vol_bit_shift; val <<= anatop_reg->vol_bit_shift; - regmap_update_bits(anatop_reg->anatop, anatop_reg->control_reg, - mask, val); + anatop_write_reg(anatop_reg->mfd, anatop_reg->control_reg, val, mask); return 0; } -static int anatop_regmap_get_voltage_sel(struct regulator_dev *reg) +static int anatop_get_voltage_sel(struct regulator_dev *reg) { struct anatop_regulator *anatop_reg = rdev_get_drvdata(reg); u32 val, mask; @@ -72,7 +69,7 @@ static int anatop_regmap_get_voltage_sel(struct regulator_dev *reg) if (!anatop_reg->control_reg) return -ENOTSUPP; - regmap_read(anatop_reg->anatop, anatop_reg->control_reg, &val); + val = anatop_read_reg(anatop_reg->mfd, anatop_reg->control_reg); mask = ((1 << anatop_reg->vol_bit_width) - 1) << anatop_reg->vol_bit_shift; val = (val & mask) >> anatop_reg->vol_bit_shift; @@ -81,8 +78,8 @@ static int anatop_regmap_get_voltage_sel(struct regulator_dev *reg) } static struct regulator_ops anatop_rops = { - .set_voltage_sel = anatop_regmap_set_voltage_sel, - .get_voltage_sel = anatop_regmap_get_voltage_sel, + .set_voltage_sel = anatop_set_voltage_sel, + .get_voltage_sel = anatop_get_voltage_sel, .list_voltage = regulator_list_voltage_linear, .map_voltage = regulator_map_voltage_linear, }; @@ -91,11 +88,11 @@ static int __devinit anatop_regulator_probe(struct platform_device *pdev) { struct device *dev = &pdev->dev; struct device_node *np = dev->of_node; - struct device_node *anatop_np; struct regulator_desc *rdesc; struct regulator_dev *rdev; struct anatop_regulator *sreg; struct regulator_init_data *initdata; + struct anatop *anatopmfd = dev_get_drvdata(pdev->dev.parent); struct regulator_config config = { }; int ret = 0; @@ -112,15 +109,7 @@ static int __devinit anatop_regulator_probe(struct platform_device *pdev) rdesc->ops = &anatop_rops; rdesc->type = REGULATOR_VOLTAGE; rdesc->owner = THIS_MODULE; - - anatop_np = of_get_parent(np); - if (!anatop_np) - return -ENODEV; - sreg->anatop = syscon_node_to_regmap(anatop_np); - of_node_put(anatop_np); - if (IS_ERR(sreg->anatop)) - return PTR_ERR(sreg->anatop); - + sreg->mfd = anatopmfd; ret = of_property_read_u32(np, "anatop-reg-offset", &sreg->control_reg); if (ret) { diff --git a/trunk/drivers/regulator/max8925-regulator.c b/trunk/drivers/regulator/max8925-regulator.c index 9bb0be37495f..43dc97ec3932 100644 --- a/trunk/drivers/regulator/max8925-regulator.c +++ b/trunk/drivers/regulator/max8925-regulator.c @@ -214,36 +214,37 @@ static struct max8925_regulator_info max8925_regulator_info[] = { MAX8925_LDO(20, 750, 3900, 50), }; -static int __devinit max8925_regulator_probe(struct platform_device *pdev) +static struct max8925_regulator_info * __devinit find_regulator_info(int id) { - struct max8925_chip *chip = dev_get_drvdata(pdev->dev.parent); - struct regulator_init_data *pdata = pdev->dev.platform_data; - struct regulator_config config = { }; struct max8925_regulator_info *ri; - struct resource *res; - struct regulator_dev *rdev; int i; - res = platform_get_resource(pdev, IORESOURCE_REG, 0); - if (!res) { - dev_err(&pdev->dev, "No REG resource!\n"); - return -EINVAL; - } for (i = 0; i < ARRAY_SIZE(max8925_regulator_info); i++) { ri = &max8925_regulator_info[i]; - if (ri->vol_reg == res->start) - break; + if (ri->desc.id == id) + return ri; } - if (i == ARRAY_SIZE(max8925_regulator_info)) { - dev_err(&pdev->dev, "Failed to find regulator %llu\n", - (unsigned long long)res->start); + return NULL; +} + +static int __devinit max8925_regulator_probe(struct platform_device *pdev) +{ + struct max8925_chip *chip = dev_get_drvdata(pdev->dev.parent); + struct max8925_platform_data *pdata = chip->dev->platform_data; + struct regulator_config config = { }; + struct max8925_regulator_info *ri; + struct regulator_dev *rdev; + + ri = find_regulator_info(pdev->id); + if (ri == NULL) { + dev_err(&pdev->dev, "invalid regulator ID specified\n"); return -EINVAL; } ri->i2c = chip->i2c; ri->chip = chip; config.dev = &pdev->dev; - config.init_data = pdata; + config.init_data = pdata->regulator[pdev->id]; config.driver_data = ri; rdev = regulator_register(&ri->desc, &config); diff --git a/trunk/drivers/regulator/palmas-regulator.c b/trunk/drivers/regulator/palmas-regulator.c index 07aee694ba92..2ba7502fa3b2 100644 --- a/trunk/drivers/regulator/palmas-regulator.c +++ b/trunk/drivers/regulator/palmas-regulator.c @@ -22,9 +22,6 @@ #include #include #include -#include -#include -#include struct regs_info { char *name; @@ -571,103 +568,10 @@ static int palmas_ldo_init(struct palmas *palmas, int id, return 0; } -static struct of_regulator_match palmas_matches[] = { - { .name = "smps12", }, - { .name = "smps123", }, - { .name = "smps3", }, - { .name = "smps45", }, - { .name = "smps457", }, - { .name = "smps6", }, - { .name = "smps7", }, - { .name = "smps8", }, - { .name = "smps9", }, - { .name = "smps10", }, - { .name = "ldo1", }, - { .name = "ldo2", }, - { .name = "ldo3", }, - { .name = "ldo4", }, - { .name = "ldo5", }, - { .name = "ldo6", }, - { .name = "ldo7", }, - { .name = "ldo8", }, - { .name = "ldo9", }, - { .name = "ldoln", }, - { .name = "ldousb", }, -}; - -static void __devinit palmas_dt_to_pdata(struct device *dev, - struct device_node *node, - struct palmas_pmic_platform_data *pdata) -{ - struct device_node *regulators; - u32 prop; - int idx, ret; - - regulators = of_find_node_by_name(node, "regulators"); - if (!regulators) { - dev_info(dev, "regulator node not found\n"); - return; - } - - ret = of_regulator_match(dev, regulators, palmas_matches, - PALMAS_NUM_REGS); - if (ret < 0) { - dev_err(dev, "Error parsing regulator init data: %d\n", ret); - return; - } - - for (idx = 0; idx < PALMAS_NUM_REGS; idx++) { - if (!palmas_matches[idx].init_data || - !palmas_matches[idx].of_node) - continue; - - pdata->reg_data[idx] = palmas_matches[idx].init_data; - - pdata->reg_init[idx] = devm_kzalloc(dev, - sizeof(struct palmas_reg_init), GFP_KERNEL); - - ret = of_property_read_u32(palmas_matches[idx].of_node, - "ti,warm_reset", &prop); - if (!ret) - pdata->reg_init[idx]->warm_reset = prop; - - ret = of_property_read_u32(palmas_matches[idx].of_node, - "ti,roof_floor", &prop); - if (!ret) - pdata->reg_init[idx]->roof_floor = prop; - - ret = of_property_read_u32(palmas_matches[idx].of_node, - "ti,mode_sleep", &prop); - if (!ret) - pdata->reg_init[idx]->mode_sleep = prop; - - ret = of_property_read_u32(palmas_matches[idx].of_node, - "ti,warm_reset", &prop); - if (!ret) - pdata->reg_init[idx]->warm_reset = prop; - - ret = of_property_read_u32(palmas_matches[idx].of_node, - "ti,tstep", &prop); - if (!ret) - pdata->reg_init[idx]->tstep = prop; - - ret = of_property_read_u32(palmas_matches[idx].of_node, - "ti,vsel", &prop); - if (!ret) - pdata->reg_init[idx]->vsel = prop; - } - - ret = of_property_read_u32(node, "ti,ldo6_vibrator", &prop); - if (!ret) - pdata->ldo6_vibrator = prop; -} - - static __devinit int palmas_probe(struct platform_device *pdev) { struct palmas *palmas = dev_get_drvdata(pdev->dev.parent); struct palmas_pmic_platform_data *pdata = pdev->dev.platform_data; - struct device_node *node = pdev->dev.of_node; struct regulator_dev *rdev; struct regulator_config config = { }; struct palmas_pmic *pmic; @@ -675,14 +579,10 @@ static __devinit int palmas_probe(struct platform_device *pdev) int id = 0, ret; unsigned int addr, reg; - if (node && !pdata) { - pdata = devm_kzalloc(&pdev->dev, sizeof(*pdata), GFP_KERNEL); - - if (!pdata) - return -ENOMEM; - - palmas_dt_to_pdata(&pdev->dev, node, pdata); - } + if (!pdata) + return -EINVAL; + if (!pdata->reg_data) + return -EINVAL; pmic = devm_kzalloc(&pdev->dev, sizeof(*pmic), GFP_KERNEL); if (!pmic) @@ -761,7 +661,7 @@ static __devinit int palmas_probe(struct platform_device *pdev) pmic->desc[id].owner = THIS_MODULE; /* Initialise sleep/init values from platform data */ - if (pdata) { + if (pdata && pdata->reg_init) { reg_init = pdata->reg_init[id]; if (reg_init) { ret = palmas_smps_init(palmas, id, reg_init); @@ -785,13 +685,11 @@ static __devinit int palmas_probe(struct platform_device *pdev) pmic->range[id] = 1; } - if (pdata) + if (pdata && pdata->reg_data) config.init_data = pdata->reg_data[id]; else config.init_data = NULL; - config.of_node = palmas_matches[id].of_node; - rdev = regulator_register(&pmic->desc[id], &config); if (IS_ERR(rdev)) { dev_err(&pdev->dev, @@ -828,13 +726,11 @@ static __devinit int palmas_probe(struct platform_device *pdev) palmas_regs_info[id].ctrl_addr); pmic->desc[id].enable_mask = PALMAS_LDO1_CTRL_MODE_ACTIVE; - if (pdata) + if (pdata && pdata->reg_data) config.init_data = pdata->reg_data[id]; else config.init_data = NULL; - config.of_node = palmas_matches[id].of_node; - rdev = regulator_register(&pmic->desc[id], &config); if (IS_ERR(rdev)) { dev_err(&pdev->dev, @@ -848,7 +744,7 @@ static __devinit int palmas_probe(struct platform_device *pdev) pmic->rdev[id] = rdev; /* Initialise sleep/init values from platform data */ - if (pdata) { + if (pdata->reg_init) { reg_init = pdata->reg_init[id]; if (reg_init) { ret = palmas_ldo_init(palmas, id, reg_init); @@ -878,15 +774,9 @@ static int __devexit palmas_remove(struct platform_device *pdev) return 0; } -static struct of_device_id __devinitdata of_palmas_match_tbl[] = { - { .compatible = "ti,palmas-pmic", }, - { /* end */ } -}; - static struct platform_driver palmas_driver = { .driver = { .name = "palmas-pmic", - .of_match_table = of_palmas_match_tbl, .owner = THIS_MODULE, }, .probe = palmas_probe, @@ -909,4 +799,3 @@ MODULE_AUTHOR("Graeme Gregory "); MODULE_DESCRIPTION("Palmas voltage regulator driver"); MODULE_LICENSE("GPL"); MODULE_ALIAS("platform:palmas-pmic"); -MODULE_DEVICE_TABLE(of, of_palmas_match_tbl); diff --git a/trunk/drivers/regulator/wm831x-dcdc.c b/trunk/drivers/regulator/wm831x-dcdc.c index 782c228a19bd..90cbcc683704 100644 --- a/trunk/drivers/regulator/wm831x-dcdc.c +++ b/trunk/drivers/regulator/wm831x-dcdc.c @@ -475,9 +475,9 @@ static __devinit int wm831x_buckv_probe(struct platform_device *pdev) dcdc->wm831x = wm831x; - res = platform_get_resource(pdev, IORESOURCE_REG, 0); + res = platform_get_resource(pdev, IORESOURCE_IO, 0); if (res == NULL) { - dev_err(&pdev->dev, "No REG resource\n"); + dev_err(&pdev->dev, "No I/O resource\n"); ret = -EINVAL; goto err; } @@ -650,9 +650,9 @@ static __devinit int wm831x_buckp_probe(struct platform_device *pdev) dcdc->wm831x = wm831x; - res = platform_get_resource(pdev, IORESOURCE_REG, 0); + res = platform_get_resource(pdev, IORESOURCE_IO, 0); if (res == NULL) { - dev_err(&pdev->dev, "No REG resource\n"); + dev_err(&pdev->dev, "No I/O resource\n"); ret = -EINVAL; goto err; } @@ -794,9 +794,9 @@ static __devinit int wm831x_boostp_probe(struct platform_device *pdev) dcdc->wm831x = wm831x; - res = platform_get_resource(pdev, IORESOURCE_REG, 0); + res = platform_get_resource(pdev, IORESOURCE_IO, 0); if (res == NULL) { - dev_err(&pdev->dev, "No REG resource\n"); + dev_err(&pdev->dev, "No I/O resource\n"); ret = -EINVAL; goto err; } diff --git a/trunk/drivers/regulator/wm831x-isink.c b/trunk/drivers/regulator/wm831x-isink.c index 2646a1902b33..0d207c297714 100644 --- a/trunk/drivers/regulator/wm831x-isink.c +++ b/trunk/drivers/regulator/wm831x-isink.c @@ -172,9 +172,9 @@ static __devinit int wm831x_isink_probe(struct platform_device *pdev) isink->wm831x = wm831x; - res = platform_get_resource(pdev, IORESOURCE_REG, 0); + res = platform_get_resource(pdev, IORESOURCE_IO, 0); if (res == NULL) { - dev_err(&pdev->dev, "No REG resource\n"); + dev_err(&pdev->dev, "No I/O resource\n"); ret = -EINVAL; goto err; } diff --git a/trunk/drivers/regulator/wm831x-ldo.c b/trunk/drivers/regulator/wm831x-ldo.c index c2dc03993dc7..9af512672be1 100644 --- a/trunk/drivers/regulator/wm831x-ldo.c +++ b/trunk/drivers/regulator/wm831x-ldo.c @@ -273,9 +273,9 @@ static __devinit int wm831x_gp_ldo_probe(struct platform_device *pdev) ldo->wm831x = wm831x; - res = platform_get_resource(pdev, IORESOURCE_REG, 0); + res = platform_get_resource(pdev, IORESOURCE_IO, 0); if (res == NULL) { - dev_err(&pdev->dev, "No REG resource\n"); + dev_err(&pdev->dev, "No I/O resource\n"); ret = -EINVAL; goto err; } @@ -530,9 +530,9 @@ static __devinit int wm831x_aldo_probe(struct platform_device *pdev) ldo->wm831x = wm831x; - res = platform_get_resource(pdev, IORESOURCE_REG, 0); + res = platform_get_resource(pdev, IORESOURCE_IO, 0); if (res == NULL) { - dev_err(&pdev->dev, "No REG resource\n"); + dev_err(&pdev->dev, "No I/O resource\n"); ret = -EINVAL; goto err; } @@ -687,9 +687,9 @@ static __devinit int wm831x_alive_ldo_probe(struct platform_device *pdev) ldo->wm831x = wm831x; - res = platform_get_resource(pdev, IORESOURCE_REG, 0); + res = platform_get_resource(pdev, IORESOURCE_IO, 0); if (res == NULL) { - dev_err(&pdev->dev, "No REG resource\n"); + dev_err(&pdev->dev, "No I/O resource\n"); ret = -EINVAL; goto err; } diff --git a/trunk/drivers/remoteproc/Kconfig b/trunk/drivers/remoteproc/Kconfig index 96ce101b9067..f8d818abf98c 100644 --- a/trunk/drivers/remoteproc/Kconfig +++ b/trunk/drivers/remoteproc/Kconfig @@ -4,14 +4,11 @@ menu "Remoteproc drivers (EXPERIMENTAL)" config REMOTEPROC tristate depends on EXPERIMENTAL - depends on HAS_DMA select FW_CONFIG - select VIRTIO config OMAP_REMOTEPROC tristate "OMAP remoteproc support" depends on EXPERIMENTAL - depends on HAS_DMA depends on ARCH_OMAP4 depends on OMAP_IOMMU select REMOTEPROC @@ -30,15 +27,4 @@ config OMAP_REMOTEPROC It's safe to say n here if you're not interested in multimedia offloading or just want a bare minimum kernel. -config STE_MODEM_RPROC - tristate "STE-Modem remoteproc support" - depends on EXPERIMENTAL - depends on HAS_DMA - select REMOTEPROC - default n - help - Say y or m here to support STE-Modem shared memory driver. - This can be either built-in or a loadable module. - If unsure say N. - endmenu diff --git a/trunk/drivers/remoteproc/Makefile b/trunk/drivers/remoteproc/Makefile index 391b65181c05..934ce6e2c66b 100644 --- a/trunk/drivers/remoteproc/Makefile +++ b/trunk/drivers/remoteproc/Makefile @@ -8,4 +8,3 @@ remoteproc-y += remoteproc_debugfs.o remoteproc-y += remoteproc_virtio.o remoteproc-y += remoteproc_elf_loader.o obj-$(CONFIG_OMAP_REMOTEPROC) += omap_remoteproc.o -obj-$(CONFIG_STE_MODEM_RPROC) += ste_modem_rproc.o diff --git a/trunk/drivers/remoteproc/omap_remoteproc.c b/trunk/drivers/remoteproc/omap_remoteproc.c index 32c289c2ba13..b54504ee61f1 100644 --- a/trunk/drivers/remoteproc/omap_remoteproc.c +++ b/trunk/drivers/remoteproc/omap_remoteproc.c @@ -116,9 +116,6 @@ static int omap_rproc_start(struct rproc *rproc) struct omap_rproc_pdata *pdata = pdev->dev.platform_data; int ret; - if (pdata->set_bootaddr) - pdata->set_bootaddr(rproc->bootaddr); - oproc->nb.notifier_call = omap_rproc_mbox_callback; /* every omap rproc is assigned a mailbox instance for messaging */ diff --git a/trunk/drivers/remoteproc/remoteproc_core.c b/trunk/drivers/remoteproc/remoteproc_core.c index dd3bfaf1ad40..d5c2dbfc7443 100644 --- a/trunk/drivers/remoteproc/remoteproc_core.c +++ b/trunk/drivers/remoteproc/remoteproc_core.c @@ -50,18 +50,6 @@ typedef int (*rproc_handle_resource_t)(struct rproc *rproc, void *, int avail); /* Unique indices for remoteproc devices */ static DEFINE_IDA(rproc_dev_index); -static const char * const rproc_crash_names[] = { - [RPROC_MMUFAULT] = "mmufault", -}; - -/* translate rproc_crash_type to string */ -static const char *rproc_crash_to_string(enum rproc_crash_type type) -{ - if (type < ARRAY_SIZE(rproc_crash_names)) - return rproc_crash_names[type]; - return "unkown"; -} - /* * This is the IOMMU fault handler we register with the IOMMU API * (when relevant; not all remote processors access memory through @@ -69,19 +57,18 @@ static const char *rproc_crash_to_string(enum rproc_crash_type type) * * IOMMU core will invoke this handler whenever the remote processor * will try to access an unmapped device address. + * + * Currently this is mostly a stub, but it will be later used to trigger + * the recovery of the remote processor. */ static int rproc_iommu_fault(struct iommu_domain *domain, struct device *dev, unsigned long iova, int flags, void *token) { - struct rproc *rproc = token; - dev_err(dev, "iommu fault: da 0x%lx flags 0x%x\n", iova, flags); - rproc_report_crash(rproc, RPROC_MMUFAULT); - /* * Let the iommu core know we're not really handling this fault; - * we just used it as a recovery trigger. + * we just plan to use this as a recovery trigger. */ return -ENOSYS; } @@ -228,11 +215,8 @@ int rproc_alloc_vring(struct rproc_vdev *rvdev, int i) return ret; } - /* Store largest notifyid */ - rproc->max_notifyid = max(rproc->max_notifyid, notifyid); - - dev_dbg(dev, "vring%d: va %p dma %llx size %x idr %d\n", i, va, - (unsigned long long)dma, size, notifyid); + dev_dbg(dev, "vring%d: va %p dma %x size %x idr %d\n", i, va, + dma, size, notifyid); rvring->va = va; rvring->dma = dma; @@ -272,25 +256,13 @@ rproc_parse_vring(struct rproc_vdev *rvdev, struct fw_rsc_vdev *rsc, int i) return 0; } -static int rproc_max_notifyid(int id, void *p, void *data) -{ - int *maxid = data; - *maxid = max(*maxid, id); - return 0; -} - void rproc_free_vring(struct rproc_vring *rvring) { int size = PAGE_ALIGN(vring_size(rvring->len, rvring->align)); struct rproc *rproc = rvring->rvdev->rproc; - int maxid = 0; dma_free_coherent(rproc->dev.parent, size, rvring->va, rvring->dma); idr_remove(&rproc->notifyids, rvring->notifyid); - - /* Find the largest remaining notifyid */ - idr_for_each(&rproc->notifyids, rproc_max_notifyid, &maxid); - rproc->max_notifyid = maxid; } /** @@ -573,10 +545,17 @@ static int rproc_handle_carveout(struct rproc *rproc, dev_dbg(dev, "carveout rsc: da %x, pa %x, len %x, flags %x\n", rsc->da, rsc->pa, rsc->len, rsc->flags); + mapping = kzalloc(sizeof(*mapping), GFP_KERNEL); + if (!mapping) { + dev_err(dev, "kzalloc mapping failed\n"); + return -ENOMEM; + } + carveout = kzalloc(sizeof(*carveout), GFP_KERNEL); if (!carveout) { dev_err(dev, "kzalloc carveout failed\n"); - return -ENOMEM; + ret = -ENOMEM; + goto free_mapping; } va = dma_alloc_coherent(dev->parent, rsc->len, &dma, GFP_KERNEL); @@ -586,8 +565,7 @@ static int rproc_handle_carveout(struct rproc *rproc, goto free_carv; } - dev_dbg(dev, "carveout va %p, dma %llx, len 0x%x\n", va, - (unsigned long long)dma, rsc->len); + dev_dbg(dev, "carveout va %p, dma %x, len 0x%x\n", va, dma, rsc->len); /* * Ok, this is non-standard. @@ -607,18 +585,11 @@ static int rproc_handle_carveout(struct rproc *rproc, * physical address in this case. */ if (rproc->domain) { - mapping = kzalloc(sizeof(*mapping), GFP_KERNEL); - if (!mapping) { - dev_err(dev, "kzalloc mapping failed\n"); - ret = -ENOMEM; - goto dma_free; - } - ret = iommu_map(rproc->domain, rsc->da, dma, rsc->len, rsc->flags); if (ret) { dev_err(dev, "iommu_map failed: %d\n", ret); - goto free_mapping; + goto dma_free; } /* @@ -632,8 +603,7 @@ static int rproc_handle_carveout(struct rproc *rproc, mapping->len = rsc->len; list_add_tail(&mapping->node, &rproc->mappings); - dev_dbg(dev, "carveout mapped 0x%x to 0x%llx\n", - rsc->da, (unsigned long long)dma); + dev_dbg(dev, "carveout mapped 0x%x to 0x%x\n", rsc->da, dma); } /* @@ -664,12 +634,12 @@ static int rproc_handle_carveout(struct rproc *rproc, return 0; -free_mapping: - kfree(mapping); dma_free: dma_free_coherent(dev->parent, rsc->len, va, dma); free_carv: kfree(carveout); +free_mapping: + kfree(mapping); return ret; } @@ -901,91 +871,6 @@ static void rproc_fw_config_virtio(const struct firmware *fw, void *context) complete_all(&rproc->firmware_loading_complete); } -static int rproc_add_virtio_devices(struct rproc *rproc) -{ - int ret; - - /* rproc_del() calls must wait until async loader completes */ - init_completion(&rproc->firmware_loading_complete); - - /* - * We must retrieve early virtio configuration info from - * the firmware (e.g. whether to register a virtio device, - * what virtio features does it support, ...). - * - * We're initiating an asynchronous firmware loading, so we can - * be built-in kernel code, without hanging the boot process. - */ - ret = request_firmware_nowait(THIS_MODULE, FW_ACTION_HOTPLUG, - rproc->firmware, &rproc->dev, GFP_KERNEL, - rproc, rproc_fw_config_virtio); - if (ret < 0) { - dev_err(&rproc->dev, "request_firmware_nowait err: %d\n", ret); - complete_all(&rproc->firmware_loading_complete); - } - - return ret; -} - -/** - * rproc_trigger_recovery() - recover a remoteproc - * @rproc: the remote processor - * - * The recovery is done by reseting all the virtio devices, that way all the - * rpmsg drivers will be reseted along with the remote processor making the - * remoteproc functional again. - * - * This function can sleep, so it cannot be called from atomic context. - */ -int rproc_trigger_recovery(struct rproc *rproc) -{ - struct rproc_vdev *rvdev, *rvtmp; - - dev_err(&rproc->dev, "recovering %s\n", rproc->name); - - init_completion(&rproc->crash_comp); - - /* clean up remote vdev entries */ - list_for_each_entry_safe(rvdev, rvtmp, &rproc->rvdevs, node) - rproc_remove_virtio_dev(rvdev); - - /* wait until there is no more rproc users */ - wait_for_completion(&rproc->crash_comp); - - return rproc_add_virtio_devices(rproc); -} - -/** - * rproc_crash_handler_work() - handle a crash - * - * This function needs to handle everything related to a crash, like cpu - * registers and stack dump, information to help to debug the fatal error, etc. - */ -static void rproc_crash_handler_work(struct work_struct *work) -{ - struct rproc *rproc = container_of(work, struct rproc, crash_handler); - struct device *dev = &rproc->dev; - - dev_dbg(dev, "enter %s\n", __func__); - - mutex_lock(&rproc->lock); - - if (rproc->state == RPROC_CRASHED || rproc->state == RPROC_OFFLINE) { - /* handle only the first crash detected */ - mutex_unlock(&rproc->lock); - return; - } - - rproc->state = RPROC_CRASHED; - dev_err(dev, "handling crash #%u in %s\n", ++rproc->crash_cnt, - rproc->name); - - mutex_unlock(&rproc->lock); - - if (!rproc->recovery_disabled) - rproc_trigger_recovery(rproc); -} - /** * rproc_boot() - boot a remote processor * @rproc: handle of a remote processor @@ -1107,10 +992,6 @@ void rproc_shutdown(struct rproc *rproc) rproc_disable_iommu(rproc); - /* if in crash state, unlock crash handler */ - if (rproc->state == RPROC_CRASHED) - complete_all(&rproc->crash_comp); - rproc->state = RPROC_OFFLINE; dev_info(dev, "stopped remote processor %s\n", rproc->name); @@ -1145,7 +1026,7 @@ EXPORT_SYMBOL(rproc_shutdown); int rproc_add(struct rproc *rproc) { struct device *dev = &rproc->dev; - int ret; + int ret = 0; ret = device_add(dev); if (ret < 0) @@ -1159,7 +1040,26 @@ int rproc_add(struct rproc *rproc) /* create debugfs entries */ rproc_create_debug_dir(rproc); - return rproc_add_virtio_devices(rproc); + /* rproc_del() calls must wait until async loader completes */ + init_completion(&rproc->firmware_loading_complete); + + /* + * We must retrieve early virtio configuration info from + * the firmware (e.g. whether to register a virtio device, + * what virtio features does it support, ...). + * + * We're initiating an asynchronous firmware loading, so we can + * be built-in kernel code, without hanging the boot process. + */ + ret = request_firmware_nowait(THIS_MODULE, FW_ACTION_HOTPLUG, + rproc->firmware, dev, GFP_KERNEL, + rproc, rproc_fw_config_virtio); + if (ret < 0) { + dev_err(dev, "request_firmware_nowait failed: %d\n", ret); + complete_all(&rproc->firmware_loading_complete); + } + + return ret; } EXPORT_SYMBOL(rproc_add); @@ -1265,9 +1165,6 @@ struct rproc *rproc_alloc(struct device *dev, const char *name, INIT_LIST_HEAD(&rproc->traces); INIT_LIST_HEAD(&rproc->rvdevs); - INIT_WORK(&rproc->crash_handler, rproc_crash_handler_work); - init_completion(&rproc->crash_comp); - rproc->state = RPROC_OFFLINE; return rproc; @@ -1324,32 +1221,6 @@ int rproc_del(struct rproc *rproc) } EXPORT_SYMBOL(rproc_del); -/** - * rproc_report_crash() - rproc crash reporter function - * @rproc: remote processor - * @type: crash type - * - * This function must be called every time a crash is detected by the low-level - * drivers implementing a specific remoteproc. This should not be called from a - * non-remoteproc driver. - * - * This function can be called from atomic/interrupt context. - */ -void rproc_report_crash(struct rproc *rproc, enum rproc_crash_type type) -{ - if (!rproc) { - pr_err("NULL rproc pointer\n"); - return; - } - - dev_err(&rproc->dev, "crash detected in %s: type %s\n", - rproc->name, rproc_crash_to_string(type)); - - /* create a new task to handle the error */ - schedule_work(&rproc->crash_handler); -} -EXPORT_SYMBOL(rproc_report_crash); - static int __init remoteproc_init(void) { rproc_init_debugfs(); diff --git a/trunk/drivers/remoteproc/remoteproc_debugfs.c b/trunk/drivers/remoteproc/remoteproc_debugfs.c index 157a57309601..03833850f214 100644 --- a/trunk/drivers/remoteproc/remoteproc_debugfs.c +++ b/trunk/drivers/remoteproc/remoteproc_debugfs.c @@ -28,9 +28,6 @@ #include #include #include -#include - -#include "remoteproc_internal.h" /* remoteproc debugfs parent dir */ static struct dentry *rproc_dbg; @@ -82,7 +79,7 @@ static ssize_t rproc_state_read(struct file *filp, char __user *userbuf, state = rproc->state > RPROC_LAST ? RPROC_LAST : rproc->state; - i = scnprintf(buf, 30, "%.28s (%d)\n", rproc_state_string[state], + i = snprintf(buf, 30, "%.28s (%d)\n", rproc_state_string[state], rproc->state); return simple_read_from_buffer(userbuf, count, ppos, buf, i); @@ -103,7 +100,7 @@ static ssize_t rproc_name_read(struct file *filp, char __user *userbuf, char buf[100]; int i; - i = scnprintf(buf, sizeof(buf), "%.98s\n", rproc->name); + i = snprintf(buf, sizeof(buf), "%.98s\n", rproc->name); return simple_read_from_buffer(userbuf, count, ppos, buf, i); } @@ -114,82 +111,6 @@ static const struct file_operations rproc_name_ops = { .llseek = generic_file_llseek, }; -/* expose recovery flag via debugfs */ -static ssize_t rproc_recovery_read(struct file *filp, char __user *userbuf, - size_t count, loff_t *ppos) -{ - struct rproc *rproc = filp->private_data; - char *buf = rproc->recovery_disabled ? "disabled\n" : "enabled\n"; - - return simple_read_from_buffer(userbuf, count, ppos, buf, strlen(buf)); -} - -/* - * By writing to the 'recovery' debugfs entry, we control the behavior of the - * recovery mechanism dynamically. The default value of this entry is "enabled". - * - * The 'recovery' debugfs entry supports these commands: - * - * enabled: When enabled, the remote processor will be automatically - * recovered whenever it crashes. Moreover, if the remote - * processor crashes while recovery is disabled, it will - * be automatically recovered too as soon as recovery is enabled. - * - * disabled: When disabled, a remote processor will remain in a crashed - * state if it crashes. This is useful for debugging purposes; - * without it, debugging a crash is substantially harder. - * - * recover: This function will trigger an immediate recovery if the - * remote processor is in a crashed state, without changing - * or checking the recovery state (enabled/disabled). - * This is useful during debugging sessions, when one expects - * additional crashes to happen after enabling recovery. In this - * case, enabling recovery will make it hard to debug subsequent - * crashes, so it's recommended to keep recovery disabled, and - * instead use the "recover" command as needed. - */ -static ssize_t -rproc_recovery_write(struct file *filp, const char __user *user_buf, - size_t count, loff_t *ppos) -{ - struct rproc *rproc = filp->private_data; - char buf[10]; - int ret; - - if (count > sizeof(buf)) - return count; - - ret = copy_from_user(buf, user_buf, count); - if (ret) - return -EFAULT; - - /* remove end of line */ - if (buf[count - 1] == '\n') - buf[count - 1] = '\0'; - - if (!strncmp(buf, "enabled", count)) { - rproc->recovery_disabled = false; - /* if rproc has crashed, trigger recovery */ - if (rproc->state == RPROC_CRASHED) - rproc_trigger_recovery(rproc); - } else if (!strncmp(buf, "disabled", count)) { - rproc->recovery_disabled = true; - } else if (!strncmp(buf, "recover", count)) { - /* if rproc has crashed, trigger recovery */ - if (rproc->state == RPROC_CRASHED) - rproc_trigger_recovery(rproc); - } - - return count; -} - -static const struct file_operations rproc_recovery_ops = { - .read = rproc_recovery_read, - .write = rproc_recovery_write, - .open = simple_open, - .llseek = generic_file_llseek, -}; - void rproc_remove_trace_file(struct dentry *tfile) { debugfs_remove(tfile); @@ -233,8 +154,6 @@ void rproc_create_debug_dir(struct rproc *rproc) rproc, &rproc_name_ops); debugfs_create_file("state", 0400, rproc->dbg_dir, rproc, &rproc_state_ops); - debugfs_create_file("recovery", 0400, rproc->dbg_dir, - rproc, &rproc_recovery_ops); } void __init rproc_init_debugfs(void) diff --git a/trunk/drivers/remoteproc/remoteproc_internal.h b/trunk/drivers/remoteproc/remoteproc_internal.h index 7bb66482d061..a690ebe7aa51 100644 --- a/trunk/drivers/remoteproc/remoteproc_internal.h +++ b/trunk/drivers/remoteproc/remoteproc_internal.h @@ -63,7 +63,6 @@ void rproc_free_vring(struct rproc_vring *rvring); int rproc_alloc_vring(struct rproc_vdev *rvdev, int i); void *rproc_da_to_va(struct rproc *rproc, u64 da, int len); -int rproc_trigger_recovery(struct rproc *rproc); static inline int rproc_fw_sanity_check(struct rproc *rproc, const struct firmware *fw) diff --git a/trunk/drivers/remoteproc/ste_modem_rproc.c b/trunk/drivers/remoteproc/ste_modem_rproc.c deleted file mode 100644 index a7743c069339..000000000000 --- a/trunk/drivers/remoteproc/ste_modem_rproc.c +++ /dev/null @@ -1,322 +0,0 @@ -/* - * Copyright (C) ST-Ericsson AB 2012 - * Author: Sjur Brændeland - * License terms: GNU General Public License (GPL), version 2 - */ - -#include -#include -#include -#include -#include "remoteproc_internal.h" - -#define SPROC_FW_SIZE (50 * 4096) -#define SPROC_MAX_TOC_ENTRIES 32 -#define SPROC_MAX_NOTIFY_ID 14 -#define SPROC_RESOURCE_NAME "rsc-table" -#define SPROC_MODEM_NAME "ste-modem" -#define SPROC_MODEM_FIRMWARE SPROC_MODEM_NAME "-fw.bin" - -#define sproc_dbg(sproc, fmt, ...) \ - dev_dbg(&sproc->mdev->pdev.dev, fmt, ##__VA_ARGS__) -#define sproc_err(sproc, fmt, ...) \ - dev_err(&sproc->mdev->pdev.dev, fmt, ##__VA_ARGS__) - -/* STE-modem control structure */ -struct sproc { - struct rproc *rproc; - struct ste_modem_device *mdev; - int error; - void *fw_addr; - size_t fw_size; - dma_addr_t fw_dma_addr; -}; - -/* STE-Modem firmware entry */ -struct ste_toc_entry { - __le32 start; - __le32 size; - __le32 flags; - __le32 entry_point; - __le32 load_addr; - char name[12]; -}; - -/* - * The Table Of Content is located at the start of the firmware image and - * at offset zero in the shared memory region. The resource table typically - * contains the initial boot image (boot strap) and other information elements - * such as remoteproc resource table. Each entry is identified by a unique - * name. - */ -struct ste_toc { - struct ste_toc_entry table[SPROC_MAX_TOC_ENTRIES]; -}; - -/* Loads the firmware to shared memory. */ -static int sproc_load_segments(struct rproc *rproc, const struct firmware *fw) -{ - struct sproc *sproc = rproc->priv; - - memcpy(sproc->fw_addr, fw->data, fw->size); - - return 0; -} - -/* Find the entry for resource table in the Table of Content */ -static struct ste_toc_entry *sproc_find_rsc_entry(const struct firmware *fw) -{ - int i; - struct ste_toc *toc; - - if (!fw) - return NULL; - - toc = (void *)fw->data; - - /* Search the table for the resource table */ - for (i = 0; i < SPROC_MAX_TOC_ENTRIES && - toc->table[i].start != 0xffffffff; i++) { - - if (!strncmp(toc->table[i].name, SPROC_RESOURCE_NAME, - sizeof(toc->table[i].name))) { - if (toc->table[i].start > fw->size) - return NULL; - return &toc->table[i]; - } - } - - return NULL; -} - -/* Find the resource table inside the remote processor's firmware. */ -static struct resource_table * -sproc_find_rsc_table(struct rproc *rproc, const struct firmware *fw, - int *tablesz) -{ - struct sproc *sproc = rproc->priv; - struct resource_table *table; - struct ste_toc_entry *entry; - - entry = sproc_find_rsc_entry(fw); - if (!entry) { - sproc_err(sproc, "resource table not found in fw\n"); - return NULL; - } - - table = (void *)(fw->data + entry->start); - - /* sanity check size and offset of resource table */ - if (entry->start > SPROC_FW_SIZE || - entry->size > SPROC_FW_SIZE || - fw->size > SPROC_FW_SIZE || - entry->start + entry->size > fw->size || - sizeof(struct resource_table) > entry->size) { - sproc_err(sproc, "bad size of fw or resource table\n"); - return NULL; - } - - /* we don't support any version beyond the first */ - if (table->ver != 1) { - sproc_err(sproc, "unsupported fw ver: %d\n", table->ver); - return NULL; - } - - /* make sure reserved bytes are zeroes */ - if (table->reserved[0] || table->reserved[1]) { - sproc_err(sproc, "non zero reserved bytes\n"); - return NULL; - } - - /* make sure the offsets array isn't truncated */ - if (table->num > SPROC_MAX_TOC_ENTRIES || - table->num * sizeof(table->offset[0]) + - sizeof(struct resource_table) > entry->size) { - sproc_err(sproc, "resource table incomplete\n"); - return NULL; - } - - /* If the fw size has grown, release the previous fw allocation */ - if (SPROC_FW_SIZE < fw->size) { - sproc_err(sproc, "Insufficient space for fw (%d < %zd)\n", - SPROC_FW_SIZE, fw->size); - return NULL; - } - - sproc->fw_size = fw->size; - *tablesz = entry->size; - - return table; -} - -/* STE modem firmware handler operations */ -const struct rproc_fw_ops sproc_fw_ops = { - .load = sproc_load_segments, - .find_rsc_table = sproc_find_rsc_table, -}; - -/* Kick the modem with specified notification id */ -static void sproc_kick(struct rproc *rproc, int vqid) -{ - struct sproc *sproc = rproc->priv; - - sproc_dbg(sproc, "kick vqid:%d\n", vqid); - - /* - * We need different notification IDs for RX and TX so add - * an offset on TX notification IDs. - */ - sproc->mdev->ops.kick(sproc->mdev, vqid + SPROC_MAX_NOTIFY_ID); -} - -/* Received a kick from a modem, kick the virtqueue */ -static void sproc_kick_callback(struct ste_modem_device *mdev, int vqid) -{ - struct sproc *sproc = mdev->drv_data; - - if (rproc_vq_interrupt(sproc->rproc, vqid) == IRQ_NONE) - sproc_dbg(sproc, "no message was found in vqid %d\n", vqid); -} - -struct ste_modem_dev_cb sproc_dev_cb = { - .kick = sproc_kick_callback, -}; - -/* Start the STE modem */ -static int sproc_start(struct rproc *rproc) -{ - struct sproc *sproc = rproc->priv; - int i, err; - - sproc_dbg(sproc, "start ste-modem\n"); - - /* Sanity test the max_notifyid */ - if (rproc->max_notifyid > SPROC_MAX_NOTIFY_ID) { - sproc_err(sproc, "Notification IDs too high:%d\n", - rproc->max_notifyid); - return -EINVAL; - } - - /* Subscribe to notifications */ - for (i = 0; i < rproc->max_notifyid; i++) { - err = sproc->mdev->ops.kick_subscribe(sproc->mdev, i); - if (err) { - sproc_err(sproc, - "subscription of kicks failed:%d\n", err); - return err; - } - } - - /* Request modem start-up*/ - return sproc->mdev->ops.power(sproc->mdev, true); -} - -/* Stop the STE modem */ -static int sproc_stop(struct rproc *rproc) -{ - struct sproc *sproc = rproc->priv; - sproc_dbg(sproc, "stop ste-modem\n"); - - return sproc->mdev->ops.power(sproc->mdev, false); -} - -static struct rproc_ops sproc_ops = { - .start = sproc_start, - .stop = sproc_stop, - .kick = sproc_kick, -}; - -/* STE modem device is unregistered */ -static int sproc_drv_remove(struct platform_device *pdev) -{ - struct ste_modem_device *mdev = - container_of(pdev, struct ste_modem_device, pdev); - struct sproc *sproc = mdev->drv_data; - - sproc_dbg(sproc, "remove ste-modem\n"); - - /* Reset device callback functions */ - sproc->mdev->ops.setup(sproc->mdev, NULL); - - /* Unregister as remoteproc device */ - rproc_del(sproc->rproc); - rproc_put(sproc->rproc); - - mdev->drv_data = NULL; - - return 0; -} - -/* Handle probe of a modem device */ -static int sproc_probe(struct platform_device *pdev) -{ - struct ste_modem_device *mdev = - container_of(pdev, struct ste_modem_device, pdev); - struct sproc *sproc; - struct rproc *rproc; - int err; - - dev_dbg(&mdev->pdev.dev, "probe ste-modem\n"); - - if (!mdev->ops.setup || !mdev->ops.kick || !mdev->ops.kick_subscribe || - !mdev->ops.power) { - dev_err(&mdev->pdev.dev, "invalid mdev ops\n"); - return -EINVAL; - } - - rproc = rproc_alloc(&mdev->pdev.dev, mdev->pdev.name, &sproc_ops, - SPROC_MODEM_FIRMWARE, sizeof(*sproc)); - if (!rproc) - return -ENOMEM; - - sproc = rproc->priv; - sproc->mdev = mdev; - sproc->rproc = rproc; - mdev->drv_data = sproc; - - /* Provide callback functions to modem device */ - sproc->mdev->ops.setup(sproc->mdev, &sproc_dev_cb); - - /* Set the STE-modem specific firmware handler */ - rproc->fw_ops = &sproc_fw_ops; - - /* - * STE-modem requires the firmware to be located - * at the start of the shared memory region. So we need to - * reserve space for firmware at the start. - */ - sproc->fw_addr = dma_alloc_coherent(rproc->dev.parent, SPROC_FW_SIZE, - &sproc->fw_dma_addr, - GFP_KERNEL); - if (!sproc->fw_addr) { - sproc_err(sproc, "Cannot allocate memory for fw\n"); - err = -ENOMEM; - goto free_rproc; - } - - /* Register as a remoteproc device */ - err = rproc_add(rproc); - if (err) - goto free_rproc; - - return 0; - -free_rproc: - /* Reset device data upon error */ - mdev->drv_data = NULL; - rproc_put(rproc); - return err; -} - -static struct platform_driver sproc_driver = { - .driver = { - .name = SPROC_MODEM_NAME, - .owner = THIS_MODULE, - }, - .probe = sproc_probe, - .remove = sproc_drv_remove, -}; - -module_platform_driver(sproc_driver); -MODULE_LICENSE("GPL v2"); -MODULE_DESCRIPTION("STE Modem driver using the Remote Processor Framework"); diff --git a/trunk/drivers/rtc/Kconfig b/trunk/drivers/rtc/Kconfig index e069f176a82d..fabc99a75c65 100644 --- a/trunk/drivers/rtc/Kconfig +++ b/trunk/drivers/rtc/Kconfig @@ -19,6 +19,7 @@ if RTC_CLASS config RTC_HCTOSYS bool "Set system time from RTC on startup and resume" + depends on RTC_CLASS = y default y help If you say yes here, the system time (wall clock) will be set using @@ -50,6 +51,7 @@ config RTC_HCTOSYS_DEVICE config RTC_DEBUG bool "RTC debug support" + depends on RTC_CLASS = y help Say yes here to enable debugging support in the RTC framework and individual RTC drivers. @@ -59,6 +61,7 @@ comment "RTC interfaces" config RTC_INTF_SYSFS boolean "/sys/class/rtc/rtcN (sysfs)" depends on SYSFS + default RTC_CLASS help Say yes here if you want to use your RTCs using sysfs interfaces, /sys/class/rtc/rtc0 through /sys/.../rtcN. @@ -66,19 +69,19 @@ config RTC_INTF_SYSFS If unsure, say Y. config RTC_INTF_PROC - boolean "/proc/driver/rtc (procfs for rtcN)" + boolean "/proc/driver/rtc (procfs for rtc0)" depends on PROC_FS + default RTC_CLASS help - Say yes here if you want to use your system clock RTC through - the proc interface, /proc/driver/rtc. - Other RTCs will not be available through that API. - If there is no RTC for the system clock, then the first RTC(rtc0) - is used by default. + Say yes here if you want to use your first RTC through the proc + interface, /proc/driver/rtc. Other RTCs will not be available + through that API. If unsure, say Y. config RTC_INTF_DEV boolean "/dev/rtcN (character devices)" + default RTC_CLASS help Say yes here if you want to use your RTCs using the /dev interfaces, which "udev" sets up as /dev/rtc0 through @@ -124,7 +127,7 @@ if I2C config RTC_DRV_88PM860X tristate "Marvell 88PM860x" - depends on I2C && MFD_88PM860X + depends on RTC_CLASS && I2C && MFD_88PM860X help If you say yes here you get support for RTC function in Marvell 88PM860x chips. @@ -134,7 +137,7 @@ config RTC_DRV_88PM860X config RTC_DRV_88PM80X tristate "Marvell 88PM80x" - depends on I2C && MFD_88PM800 + depends on RTC_CLASS && I2C && MFD_88PM800 help If you say yes here you get support for RTC function in Marvell 88PM80x chips. @@ -162,7 +165,7 @@ config RTC_DRV_DS1307 config RTC_DRV_DS1374 tristate "Dallas/Maxim DS1374" - depends on I2C + depends on RTC_CLASS && I2C help If you say yes here you get support for Dallas Semiconductor DS1374 real-time clock chips. If an interrupt is associated @@ -182,7 +185,7 @@ config RTC_DRV_DS1672 config RTC_DRV_DS3232 tristate "Dallas/Maxim DS3232" - depends on I2C + depends on RTC_CLASS && I2C help If you say yes here you get support for Dallas Semiconductor DS3232 real-time clock chips. If an interrupt is associated @@ -200,16 +203,6 @@ config RTC_DRV_MAX6900 This driver can also be built as a module. If so, the module will be called rtc-max6900. -config RTC_DRV_MAX8907 - tristate "Maxim MAX8907" - depends on MFD_MAX8907 - help - If you say yes here you will get support for the - RTC of Maxim MAX8907 PMIC. - - This driver can also be built as a module. If so, the module - will be called rtc-max8907. - config RTC_DRV_MAX8925 tristate "Maxim MAX8925" depends on MFD_MAX8925 @@ -332,7 +325,7 @@ config RTC_DRV_TWL92330 config RTC_DRV_TWL4030 tristate "TI TWL4030/TWL5030/TWL6030/TPS659x0" - depends on TWL4030_CORE + depends on RTC_CLASS && TWL4030_CORE help If you say yes here you get support for the RTC on the TWL4030/TWL5030/TWL6030 family chips, used mostly with OMAP3 platforms. @@ -340,26 +333,6 @@ config RTC_DRV_TWL4030 This driver can also be built as a module. If so, the module will be called rtc-twl. -config RTC_DRV_TPS65910 - tristate "TI TPS65910 RTC driver" - depends on RTC_CLASS && MFD_TPS65910 - help - If you say yes here you get support for the RTC on the - TPS65910 chips. - - This driver can also be built as a module. If so, the module - will be called rtc-tps65910. - -config RTC_DRV_RC5T583 - tristate "RICOH 5T583 RTC driver" - depends on MFD_RC5T583 - help - If you say yes here you get support for the RTC on the - RICOH 5T583 chips. - - This driver can also be built as a module. If so, the module - will be called rtc-rc5t583. - config RTC_DRV_S35390A tristate "Seiko Instruments S-35390A" select BITREVERSE @@ -565,6 +538,7 @@ config RTC_DRV_DS1302 config RTC_DRV_DS1511 tristate "Dallas DS1511" + depends on RTC_CLASS help If you say yes here you get support for the Dallas DS1511 timekeeping/watchdog chip. @@ -609,6 +583,7 @@ config RTC_DRV_EFI config RTC_DRV_STK17TA8 tristate "Simtek STK17TA8" + depends on RTC_CLASS help If you say yes here you get support for the Simtek STK17TA8 timekeeping chip. @@ -683,15 +658,6 @@ config RTC_DRV_V3020 This driver can also be built as a module. If so, the module will be called rtc-v3020. -config RTC_DRV_DS2404 - tristate "Dallas DS2404" - help - If you say yes here you get support for the - Dallas DS2404 RTC chip. - - This driver can also be built as a module. If so, the module - will be called rtc-ds2404. - config RTC_DRV_WM831X tristate "Wolfson Microelectronics WM831x RTC" depends on MFD_WM831X @@ -738,7 +704,6 @@ config RTC_DRV_AB3100 config RTC_DRV_AB8500 tristate "ST-Ericsson AB8500 RTC" depends on AB8500_CORE - select RTC_INTF_DEV select RTC_INTF_DEV_UIE_EMUL help Select this to enable the ST-Ericsson AB8500 power management IC RTC @@ -746,7 +711,7 @@ config RTC_DRV_AB8500 config RTC_DRV_NUC900 tristate "NUC910/NUC920 RTC driver" - depends on ARCH_W90X900 + 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. @@ -766,6 +731,7 @@ config RTC_DRV_DAVINCI config RTC_DRV_IMXDI tristate "Freescale IMX DryIce Real Time Clock" depends on SOC_IMX25 + depends on RTC_CLASS help Support for Freescale IMX DryIce RTC @@ -825,7 +791,7 @@ config RTC_DRV_SA1100 config RTC_DRV_SH tristate "SuperH On-Chip RTC" - depends on SUPERH && HAVE_CLK + depends on RTC_CLASS && SUPERH && HAVE_CLK help Say Y here to enable support for the on-chip RTC found in most SuperH processors. @@ -1057,6 +1023,7 @@ config RTC_DRV_MPC5121 config RTC_DRV_JZ4740 tristate "Ingenic JZ4740 SoC" + depends on RTC_CLASS depends on MACH_JZ4740 help If you say yes here you get support for the Ingenic JZ4740 SoC RTC @@ -1086,7 +1053,7 @@ config RTC_DRV_PM8XXX config RTC_DRV_TEGRA tristate "NVIDIA Tegra Internal RTC driver" - depends on ARCH_TEGRA + depends on RTC_CLASS && ARCH_TEGRA help If you say yes here you get support for the Tegra 200 series internal RTC module. @@ -1123,6 +1090,7 @@ config RTC_DRV_LOONGSON1 config RTC_DRV_MXC tristate "Freescale MXC Real Time Clock" depends on ARCH_MXC + depends on RTC_CLASS help If you say yes here you get support for the Freescale MXC RTC module. @@ -1130,15 +1098,4 @@ config RTC_DRV_MXC This driver can also be built as a module, if so, the module will be called "rtc-mxc". -config RTC_DRV_SNVS - tristate "Freescale SNVS RTC support" - depends on HAS_IOMEM - depends on OF - help - If you say yes here you get support for the Freescale SNVS - Low Power (LP) RTC module. - - This driver can also be built as a module, if so, the module - will be called "rtc-snvs". - endif # RTC_CLASS diff --git a/trunk/drivers/rtc/Makefile b/trunk/drivers/rtc/Makefile index 56297f0fd388..0d5b2b66f90d 100644 --- a/trunk/drivers/rtc/Makefile +++ b/trunk/drivers/rtc/Makefile @@ -43,7 +43,6 @@ obj-$(CONFIG_RTC_DRV_DS1511) += rtc-ds1511.o obj-$(CONFIG_RTC_DRV_DS1553) += rtc-ds1553.o obj-$(CONFIG_RTC_DRV_DS1672) += rtc-ds1672.o obj-$(CONFIG_RTC_DRV_DS1742) += rtc-ds1742.o -obj-$(CONFIG_RTC_DRV_DS2404) += rtc-ds2404.o obj-$(CONFIG_RTC_DRV_DS3232) += rtc-ds3232.o obj-$(CONFIG_RTC_DRV_DS3234) += rtc-ds3234.o obj-$(CONFIG_RTC_DRV_EFI) += rtc-efi.o @@ -65,7 +64,6 @@ obj-$(CONFIG_RTC_DRV_M48T59) += rtc-m48t59.o obj-$(CONFIG_RTC_DRV_M48T86) += rtc-m48t86.o obj-$(CONFIG_RTC_DRV_MXC) += rtc-mxc.o obj-$(CONFIG_RTC_DRV_MAX6900) += rtc-max6900.o -obj-$(CONFIG_RTC_DRV_MAX8907) += rtc-max8907.o obj-$(CONFIG_RTC_DRV_MAX8925) += rtc-max8925.o obj-$(CONFIG_RTC_DRV_MAX8998) += rtc-max8998.o obj-$(CONFIG_RTC_DRV_MAX6902) += rtc-max6902.o @@ -87,7 +85,6 @@ obj-$(CONFIG_RTC_DRV_PS3) += rtc-ps3.o obj-$(CONFIG_RTC_DRV_PUV3) += rtc-puv3.o obj-$(CONFIG_RTC_DRV_PXA) += rtc-pxa.o obj-$(CONFIG_RTC_DRV_R9701) += rtc-r9701.o -obj-$(CONFIG_RTC_DRV_RC5T583) += rtc-rc5t583.o obj-$(CONFIG_RTC_DRV_RP5C01) += rtc-rp5c01.o obj-$(CONFIG_RTC_DRV_RS5C313) += rtc-rs5c313.o obj-$(CONFIG_RTC_DRV_RS5C348) += rtc-rs5c348.o @@ -99,7 +96,6 @@ obj-$(CONFIG_RTC_DRV_S35390A) += rtc-s35390a.o obj-$(CONFIG_RTC_DRV_S3C) += rtc-s3c.o obj-$(CONFIG_RTC_DRV_SA1100) += rtc-sa1100.o obj-$(CONFIG_RTC_DRV_SH) += rtc-sh.o -obj-$(CONFIG_RTC_DRV_SNVS) += rtc-snvs.o obj-$(CONFIG_RTC_DRV_SPEAR) += rtc-spear.o obj-$(CONFIG_RTC_DRV_STARFIRE) += rtc-starfire.o obj-$(CONFIG_RTC_DRV_STK17TA8) += rtc-stk17ta8.o @@ -109,7 +105,6 @@ obj-$(CONFIG_RTC_DRV_TEGRA) += rtc-tegra.o obj-$(CONFIG_RTC_DRV_TEST) += rtc-test.o obj-$(CONFIG_RTC_DRV_TILE) += rtc-tile.o obj-$(CONFIG_RTC_DRV_TWL4030) += rtc-twl.o -obj-$(CONFIG_RTC_DRV_TPS65910) += rtc-tps65910.o obj-$(CONFIG_RTC_DRV_TX4939) += rtc-tx4939.o obj-$(CONFIG_RTC_DRV_V3020) += rtc-v3020.o obj-$(CONFIG_RTC_DRV_VR41XX) += rtc-vr41xx.o diff --git a/trunk/drivers/rtc/class.c b/trunk/drivers/rtc/class.c index f8a0aab218cb..dc4c2748bbc3 100644 --- a/trunk/drivers/rtc/class.c +++ b/trunk/drivers/rtc/class.c @@ -31,12 +31,8 @@ static void rtc_device_release(struct device *dev) kfree(rtc); } -#ifdef CONFIG_RTC_HCTOSYS_DEVICE -/* Result of the last RTC to system clock attempt. */ -int rtc_hctosys_ret = -ENODEV; -#endif - #if defined(CONFIG_PM) && defined(CONFIG_RTC_HCTOSYS_DEVICE) + /* * On suspend(), measure the delta between one RTC and the * system's wall clock; restore it on resume(). @@ -88,7 +84,6 @@ static int rtc_resume(struct device *dev) struct timespec new_system, new_rtc; struct timespec sleep_time; - rtc_hctosys_ret = -ENODEV; if (strcmp(dev_name(&rtc->dev), CONFIG_RTC_HCTOSYS_DEVICE) != 0) return 0; @@ -122,7 +117,6 @@ static int rtc_resume(struct device *dev) if (sleep_time.tv_sec >= 0) timekeeping_inject_sleeptime(&sleep_time); - rtc_hctosys_ret = 0; return 0; } @@ -244,7 +238,6 @@ void rtc_device_unregister(struct rtc_device *rtc) rtc_proc_del_device(rtc); device_unregister(&rtc->dev); rtc->ops = NULL; - ida_simple_remove(&rtc_ida, rtc->id); mutex_unlock(&rtc->ops_lock); put_device(&rtc->dev); } diff --git a/trunk/drivers/rtc/hctosys.c b/trunk/drivers/rtc/hctosys.c index 4aa60d74004e..bc90b091f195 100644 --- a/trunk/drivers/rtc/hctosys.c +++ b/trunk/drivers/rtc/hctosys.c @@ -22,6 +22,8 @@ * the best guess is to add 0.5s. */ +int rtc_hctosys_ret = -ENODEV; + static int __init rtc_hctosys(void) { int err = -ENODEV; @@ -54,7 +56,7 @@ static int __init rtc_hctosys(void) rtc_tm_to_time(&tm, &tv.tv_sec); - err = do_settimeofday(&tv); + do_settimeofday(&tv); dev_info(rtc->dev.parent, "setting system clock to " diff --git a/trunk/drivers/rtc/rtc-88pm860x.c b/trunk/drivers/rtc/rtc-88pm860x.c index de9e854b326a..feddefc42109 100644 --- a/trunk/drivers/rtc/rtc-88pm860x.c +++ b/trunk/drivers/rtc/rtc-88pm860x.c @@ -11,7 +11,6 @@ #include #include -#include #include #include #include @@ -285,28 +284,6 @@ static void calibrate_vrtc_work(struct work_struct *work) } #endif -#ifdef CONFIG_OF -static int __devinit pm860x_rtc_dt_init(struct platform_device *pdev, - struct pm860x_rtc_info *info) -{ - struct device_node *np = pdev->dev.parent->of_node; - int ret; - if (!np) - return -ENODEV; - np = of_find_node_by_name(np, "rtc"); - if (!np) { - dev_err(&pdev->dev, "failed to find rtc node\n"); - return -ENODEV; - } - ret = of_property_read_u32(np, "marvell,88pm860x-vrtc", &info->vrtc); - if (ret) - info->vrtc = 0; - return 0; -} -#else -#define pm860x_rtc_dt_init(x, y) (-1) -#endif - static int __devinit pm860x_rtc_probe(struct platform_device *pdev) { struct pm860x_chip *chip = dev_get_drvdata(pdev->dev.parent); @@ -317,6 +294,8 @@ static int __devinit pm860x_rtc_probe(struct platform_device *pdev) int ret; pdata = pdev->dev.platform_data; + if (pdata == NULL) + dev_warn(&pdev->dev, "No platform data!\n"); info = kzalloc(sizeof(struct pm860x_rtc_info), GFP_KERNEL); if (!info) @@ -366,11 +345,9 @@ static int __devinit pm860x_rtc_probe(struct platform_device *pdev) } } rtc_tm_to_time(&tm, &ticks); - if (pm860x_rtc_dt_init(pdev, info)) { - if (pdata && pdata->sync) { - pdata->sync(ticks); - info->sync = pdata->sync; - } + if (pdata && pdata->sync) { + pdata->sync(ticks); + info->sync = pdata->sync; } info->rtc_dev = rtc_device_register("88pm860x-rtc", &pdev->dev, @@ -389,12 +366,10 @@ static int __devinit pm860x_rtc_probe(struct platform_device *pdev) #ifdef VRTC_CALIBRATION /* <00> -- 2.7V, <01> -- 2.9V, <10> -- 3.1V, <11> -- 3.3V */ - if (pm860x_rtc_dt_init(pdev, info)) { - if (pdata && pdata->vrtc) - info->vrtc = pdata->vrtc & 0x3; - else - info->vrtc = 1; - } + if (pdata && pdata->vrtc) + info->vrtc = pdata->vrtc & 0x3; + else + info->vrtc = 1; pm860x_set_bits(info->i2c, PM8607_MEAS_EN2, MEAS2_VRTC, MEAS2_VRTC); /* calibrate VRTC */ diff --git a/trunk/drivers/rtc/rtc-at91sam9.c b/trunk/drivers/rtc/rtc-at91sam9.c index 2dfe7a2fb998..1dd61f402b04 100644 --- a/trunk/drivers/rtc/rtc-at91sam9.c +++ b/trunk/drivers/rtc/rtc-at91sam9.c @@ -473,7 +473,18 @@ static struct platform_driver at91_rtc_driver = { }, }; -module_platform_driver(at91_rtc_driver); +static int __init at91_rtc_init(void) +{ + return platform_driver_register(&at91_rtc_driver); +} +module_init(at91_rtc_init); + +static void __exit at91_rtc_exit(void) +{ + platform_driver_unregister(&at91_rtc_driver); +} +module_exit(at91_rtc_exit); + MODULE_AUTHOR("Michel Benoit"); MODULE_DESCRIPTION("RTC driver for Atmel AT91SAM9x"); diff --git a/trunk/drivers/rtc/rtc-coh901331.c b/trunk/drivers/rtc/rtc-coh901331.c index c8115b83e5ab..76b2156d3c62 100644 --- a/trunk/drivers/rtc/rtc-coh901331.c +++ b/trunk/drivers/rtc/rtc-coh901331.c @@ -276,7 +276,8 @@ static void coh901331_shutdown(struct platform_device *pdev) clk_enable(rtap->clk); writel(0, rtap->virtbase + COH901331_IRQ_MASK); - clk_disable_unprepare(rtap->clk); + clk_disable(rtap->clk); + clk_unprepare(rtap->clk); } static struct platform_driver coh901331_driver = { diff --git a/trunk/drivers/rtc/rtc-ds1672.c b/trunk/drivers/rtc/rtc-ds1672.c index 45d65c0b3a85..7fa67d0df172 100644 --- a/trunk/drivers/rtc/rtc-ds1672.c +++ b/trunk/drivers/rtc/rtc-ds1672.c @@ -37,17 +37,8 @@ static int ds1672_get_datetime(struct i2c_client *client, struct rtc_time *tm) unsigned char buf[4]; struct i2c_msg msgs[] = { - {/* setup read ptr */ - .addr = client->addr, - .len = 1, - .buf = &addr - }, - {/* read date */ - .addr = client->addr, - .flags = I2C_M_RD, - .len = 4, - .buf = buf - }, + {client->addr, 0, 1, &addr}, /* setup read ptr */ + {client->addr, I2C_M_RD, 4, buf}, /* read date */ }; /* read date registers */ @@ -108,17 +99,8 @@ static int ds1672_get_control(struct i2c_client *client, u8 *status) unsigned char addr = DS1672_REG_CONTROL; struct i2c_msg msgs[] = { - {/* setup read ptr */ - .addr = client->addr, - .len = 1, - .buf = &addr - }, - {/* read control */ - .addr = client->addr, - .flags = I2C_M_RD, - .len = 1, - .buf = status - }, + {client->addr, 0, 1, &addr}, /* setup read ptr */ + {client->addr, I2C_M_RD, 1, status}, /* read control */ }; /* read control register */ diff --git a/trunk/drivers/rtc/rtc-ds2404.c b/trunk/drivers/rtc/rtc-ds2404.c deleted file mode 100644 index 5ea9df7c8c31..000000000000 --- a/trunk/drivers/rtc/rtc-ds2404.c +++ /dev/null @@ -1,303 +0,0 @@ -/* - * Copyright (C) 2012 Sven Schnelle - * - * 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 -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include - -#define DS2404_STATUS_REG 0x200 -#define DS2404_CONTROL_REG 0x201 -#define DS2404_RTC_REG 0x202 - -#define DS2404_WRITE_SCRATCHPAD_CMD 0x0f -#define DS2404_READ_SCRATCHPAD_CMD 0xaa -#define DS2404_COPY_SCRATCHPAD_CMD 0x55 -#define DS2404_READ_MEMORY_CMD 0xf0 - -struct ds2404; - -struct ds2404_chip_ops { - int (*map_io)(struct ds2404 *chip, struct platform_device *pdev, - struct ds2404_platform_data *pdata); - void (*unmap_io)(struct ds2404 *chip); -}; - -#define DS2404_RST 0 -#define DS2404_CLK 1 -#define DS2404_DQ 2 - -struct ds2404_gpio { - const char *name; - unsigned int gpio; -}; - -struct ds2404 { - struct ds2404_gpio *gpio; - struct ds2404_chip_ops *ops; - struct rtc_device *rtc; -}; - -static struct ds2404_gpio ds2404_gpio[] = { - { "RTC RST", 0 }, - { "RTC CLK", 0 }, - { "RTC DQ", 0 }, -}; - -static int ds2404_gpio_map(struct ds2404 *chip, struct platform_device *pdev, - struct ds2404_platform_data *pdata) -{ - int i, err; - - ds2404_gpio[DS2404_RST].gpio = pdata->gpio_rst; - ds2404_gpio[DS2404_CLK].gpio = pdata->gpio_clk; - ds2404_gpio[DS2404_DQ].gpio = pdata->gpio_dq; - - for (i = 0; i < ARRAY_SIZE(ds2404_gpio); i++) { - err = gpio_request(ds2404_gpio[i].gpio, ds2404_gpio[i].name); - if (err) { - printk(KERN_ERR "error mapping gpio %s: %d\n", - ds2404_gpio[i].name, err); - goto err_request; - } - if (i != DS2404_DQ) - gpio_direction_output(ds2404_gpio[i].gpio, 1); - } - - chip->gpio = ds2404_gpio; - return 0; - -err_request: - while (--i >= 0) - gpio_free(ds2404_gpio[i].gpio); - return err; -} - -static void ds2404_gpio_unmap(struct ds2404 *chip) -{ - int i; - - for (i = 0; i < ARRAY_SIZE(ds2404_gpio); i++) - gpio_free(ds2404_gpio[i].gpio); -} - -static struct ds2404_chip_ops ds2404_gpio_ops = { - .map_io = ds2404_gpio_map, - .unmap_io = ds2404_gpio_unmap, -}; - -static void ds2404_reset(struct device *dev) -{ - gpio_set_value(ds2404_gpio[DS2404_RST].gpio, 0); - udelay(1000); - gpio_set_value(ds2404_gpio[DS2404_RST].gpio, 1); - gpio_set_value(ds2404_gpio[DS2404_CLK].gpio, 0); - gpio_direction_output(ds2404_gpio[DS2404_DQ].gpio, 0); - udelay(10); -} - -static void ds2404_write_byte(struct device *dev, u8 byte) -{ - int i; - - gpio_direction_output(ds2404_gpio[DS2404_DQ].gpio, 1); - for (i = 0; i < 8; i++) { - gpio_set_value(ds2404_gpio[DS2404_DQ].gpio, byte & (1 << i)); - udelay(10); - gpio_set_value(ds2404_gpio[DS2404_CLK].gpio, 1); - udelay(10); - gpio_set_value(ds2404_gpio[DS2404_CLK].gpio, 0); - udelay(10); - } -} - -static u8 ds2404_read_byte(struct device *dev) -{ - int i; - u8 ret = 0; - - gpio_direction_input(ds2404_gpio[DS2404_DQ].gpio); - - for (i = 0; i < 8; i++) { - gpio_set_value(ds2404_gpio[DS2404_CLK].gpio, 0); - udelay(10); - if (gpio_get_value(ds2404_gpio[DS2404_DQ].gpio)) - ret |= 1 << i; - gpio_set_value(ds2404_gpio[DS2404_CLK].gpio, 1); - udelay(10); - } - return ret; -} - -static void ds2404_read_memory(struct device *dev, u16 offset, - int length, u8 *out) -{ - ds2404_reset(dev); - ds2404_write_byte(dev, DS2404_READ_MEMORY_CMD); - ds2404_write_byte(dev, offset & 0xff); - ds2404_write_byte(dev, (offset >> 8) & 0xff); - while (length--) - *out++ = ds2404_read_byte(dev); -} - -static void ds2404_write_memory(struct device *dev, u16 offset, - int length, u8 *out) -{ - int i; - u8 ta01, ta02, es; - - ds2404_reset(dev); - ds2404_write_byte(dev, DS2404_WRITE_SCRATCHPAD_CMD); - ds2404_write_byte(dev, offset & 0xff); - ds2404_write_byte(dev, (offset >> 8) & 0xff); - - for (i = 0; i < length; i++) - ds2404_write_byte(dev, out[i]); - - ds2404_reset(dev); - ds2404_write_byte(dev, DS2404_READ_SCRATCHPAD_CMD); - - ta01 = ds2404_read_byte(dev); - ta02 = ds2404_read_byte(dev); - es = ds2404_read_byte(dev); - - for (i = 0; i < length; i++) { - if (out[i] != ds2404_read_byte(dev)) { - printk(KERN_ERR "read invalid data\n"); - return; - } - } - - ds2404_reset(dev); - ds2404_write_byte(dev, DS2404_COPY_SCRATCHPAD_CMD); - ds2404_write_byte(dev, ta01); - ds2404_write_byte(dev, ta02); - ds2404_write_byte(dev, es); - - gpio_direction_input(ds2404_gpio[DS2404_DQ].gpio); - while (gpio_get_value(ds2404_gpio[DS2404_DQ].gpio)) - ; -} - -static void ds2404_enable_osc(struct device *dev) -{ - u8 in[1] = { 0x10 }; /* enable oscillator */ - ds2404_write_memory(dev, 0x201, 1, in); -} - -static int ds2404_read_time(struct device *dev, struct rtc_time *dt) -{ - unsigned long time = 0; - - ds2404_read_memory(dev, 0x203, 4, (u8 *)&time); - time = le32_to_cpu(time); - - rtc_time_to_tm(time, dt); - return rtc_valid_tm(dt); -} - -static int ds2404_set_mmss(struct device *dev, unsigned long secs) -{ - u32 time = cpu_to_le32(secs); - ds2404_write_memory(dev, 0x203, 4, (u8 *)&time); - return 0; -} - -static const struct rtc_class_ops ds2404_rtc_ops = { - .read_time = ds2404_read_time, - .set_mmss = ds2404_set_mmss, -}; - -static int rtc_probe(struct platform_device *pdev) -{ - struct ds2404_platform_data *pdata = pdev->dev.platform_data; - struct ds2404 *chip; - int retval = -EBUSY; - - chip = kzalloc(sizeof(struct ds2404), GFP_KERNEL); - if (!chip) - return -ENOMEM; - - chip->ops = &ds2404_gpio_ops; - - retval = chip->ops->map_io(chip, pdev, pdata); - if (retval) - goto err_chip; - - dev_info(&pdev->dev, "using GPIOs RST:%d, CLK:%d, DQ:%d\n", - chip->gpio[DS2404_RST].gpio, chip->gpio[DS2404_CLK].gpio, - chip->gpio[DS2404_DQ].gpio); - - platform_set_drvdata(pdev, chip); - - chip->rtc = rtc_device_register("ds2404", - &pdev->dev, &ds2404_rtc_ops, THIS_MODULE); - if (IS_ERR(chip->rtc)) { - retval = PTR_ERR(chip->rtc); - goto err_io; - } - - ds2404_enable_osc(&pdev->dev); - return 0; - -err_io: - chip->ops->unmap_io(chip); -err_chip: - kfree(chip); - return retval; -} - -static int rtc_remove(struct platform_device *dev) -{ - struct ds2404 *chip = platform_get_drvdata(dev); - struct rtc_device *rtc = chip->rtc; - - if (rtc) - rtc_device_unregister(rtc); - - chip->ops->unmap_io(chip); - kfree(chip); - - return 0; -} - -static struct platform_driver rtc_device_driver = { - .probe = rtc_probe, - .remove = rtc_remove, - .driver = { - .name = "ds2404", - .owner = THIS_MODULE, - }, -}; - -static __init int ds2404_init(void) -{ - return platform_driver_register(&rtc_device_driver); -} - -static __exit void ds2404_exit(void) -{ - platform_driver_unregister(&rtc_device_driver); -} - -module_init(ds2404_init); -module_exit(ds2404_exit); - -MODULE_DESCRIPTION("DS2404 RTC"); -MODULE_AUTHOR("Sven Schnelle"); -MODULE_LICENSE("GPL"); -MODULE_ALIAS("platform:ds2404"); diff --git a/trunk/drivers/rtc/rtc-em3027.c b/trunk/drivers/rtc/rtc-em3027.c index f6c24ce35d36..0104ea7ebe50 100644 --- a/trunk/drivers/rtc/rtc-em3027.c +++ b/trunk/drivers/rtc/rtc-em3027.c @@ -49,17 +49,8 @@ static int em3027_get_time(struct device *dev, struct rtc_time *tm) unsigned char buf[7]; struct i2c_msg msgs[] = { - {/* setup read addr */ - .addr = client->addr, - .len = 1, - .buf = &addr - }, - {/* read time/date */ - .addr = client->addr, - .flags = I2C_M_RD, - .len = 7, - .buf = buf - }, + {client->addr, 0, 1, &addr}, /* setup read addr */ + {client->addr, I2C_M_RD, 7, buf}, /* read time/date */ }; /* read time/date registers */ @@ -85,9 +76,7 @@ static int em3027_set_time(struct device *dev, struct rtc_time *tm) unsigned char buf[8]; struct i2c_msg msg = { - .addr = client->addr, - .len = 8, - .buf = buf, /* write time/date */ + client->addr, 0, 8, buf, /* write time/date */ }; buf[0] = EM3027_REG_WATCH_SEC; diff --git a/trunk/drivers/rtc/rtc-isl1208.c b/trunk/drivers/rtc/rtc-isl1208.c index 26c81f233606..dd2aeee6c66a 100644 --- a/trunk/drivers/rtc/rtc-isl1208.c +++ b/trunk/drivers/rtc/rtc-isl1208.c @@ -68,17 +68,9 @@ isl1208_i2c_read_regs(struct i2c_client *client, u8 reg, u8 buf[], { u8 reg_addr[1] = { reg }; struct i2c_msg msgs[2] = { - { - .addr = client->addr, - .len = sizeof(reg_addr), - .buf = reg_addr - }, - { - .addr = client->addr, - .flags = I2C_M_RD, - .len = len, - .buf = buf - } + {client->addr, 0, sizeof(reg_addr), reg_addr} + , + {client->addr, I2C_M_RD, len, buf} }; int ret; @@ -98,11 +90,7 @@ isl1208_i2c_set_regs(struct i2c_client *client, u8 reg, u8 const buf[], { u8 i2c_buf[ISL1208_REG_USR2 + 2]; struct i2c_msg msgs[1] = { - { - .addr = client->addr, - .len = len + 1, - .buf = i2c_buf - } + {client->addr, 0, len + 1, i2c_buf} }; int ret; @@ -709,7 +697,6 @@ isl1208_remove(struct i2c_client *client) static const struct i2c_device_id isl1208_id[] = { { "isl1208", 0 }, - { "isl1218", 0 }, { } }; MODULE_DEVICE_TABLE(i2c, isl1208_id); diff --git a/trunk/drivers/rtc/rtc-jz4740.c b/trunk/drivers/rtc/rtc-jz4740.c index 1224182d3eab..05ab227eeff7 100644 --- a/trunk/drivers/rtc/rtc-jz4740.c +++ b/trunk/drivers/rtc/rtc-jz4740.c @@ -42,7 +42,7 @@ struct jz4740_rtc { struct rtc_device *rtc; - int irq; + unsigned int irq; spinlock_t lock; }; diff --git a/trunk/drivers/rtc/rtc-m41t80.c b/trunk/drivers/rtc/rtc-m41t80.c index b885bcd08908..4e0f84af99a7 100644 --- a/trunk/drivers/rtc/rtc-m41t80.c +++ b/trunk/drivers/rtc/rtc-m41t80.c @@ -213,14 +213,163 @@ static int m41t80_rtc_set_time(struct device *dev, struct rtc_time *tm) return m41t80_set_datetime(to_i2c_client(dev), tm); } -/* - * XXX - m41t80 alarm functionality is reported broken. - * until it is fixed, don't register alarm functions. - */ +static int m41t80_rtc_alarm_irq_enable(struct device *dev, unsigned int enabled) +{ + struct i2c_client *client = to_i2c_client(dev); + int rc; + + rc = i2c_smbus_read_byte_data(client, M41T80_REG_ALARM_MON); + if (rc < 0) + goto err; + + if (enabled) + rc |= M41T80_ALMON_AFE; + else + rc &= ~M41T80_ALMON_AFE; + + if (i2c_smbus_write_byte_data(client, M41T80_REG_ALARM_MON, rc) < 0) + goto err; + + return 0; +err: + return -EIO; +} + +static int m41t80_rtc_set_alarm(struct device *dev, struct rtc_wkalrm *t) +{ + struct i2c_client *client = to_i2c_client(dev); + u8 wbuf[1 + M41T80_ALARM_REG_SIZE]; + u8 *buf = &wbuf[1]; + u8 *reg = buf - M41T80_REG_ALARM_MON; + u8 dt_addr[1] = { M41T80_REG_ALARM_MON }; + struct i2c_msg msgs_in[] = { + { + .addr = client->addr, + .flags = 0, + .len = 1, + .buf = dt_addr, + }, + { + .addr = client->addr, + .flags = I2C_M_RD, + .len = M41T80_ALARM_REG_SIZE, + .buf = buf, + }, + }; + struct i2c_msg msgs[] = { + { + .addr = client->addr, + .flags = 0, + .len = 1 + M41T80_ALARM_REG_SIZE, + .buf = wbuf, + }, + }; + + if (i2c_transfer(client->adapter, msgs_in, 2) < 0) { + dev_err(&client->dev, "read error\n"); + return -EIO; + } + reg[M41T80_REG_ALARM_MON] &= ~(0x1f | M41T80_ALMON_AFE); + reg[M41T80_REG_ALARM_DAY] = 0; + reg[M41T80_REG_ALARM_HOUR] &= ~(0x3f | 0x80); + reg[M41T80_REG_ALARM_MIN] = 0; + reg[M41T80_REG_ALARM_SEC] = 0; + + wbuf[0] = M41T80_REG_ALARM_MON; /* offset into rtc's regs */ + reg[M41T80_REG_ALARM_SEC] |= t->time.tm_sec >= 0 ? + bin2bcd(t->time.tm_sec) : 0x80; + reg[M41T80_REG_ALARM_MIN] |= t->time.tm_min >= 0 ? + bin2bcd(t->time.tm_min) : 0x80; + reg[M41T80_REG_ALARM_HOUR] |= t->time.tm_hour >= 0 ? + bin2bcd(t->time.tm_hour) : 0x80; + reg[M41T80_REG_ALARM_DAY] |= t->time.tm_mday >= 0 ? + bin2bcd(t->time.tm_mday) : 0x80; + if (t->time.tm_mon >= 0) + reg[M41T80_REG_ALARM_MON] |= bin2bcd(t->time.tm_mon + 1); + else + reg[M41T80_REG_ALARM_DAY] |= 0x40; + + if (i2c_transfer(client->adapter, msgs, 1) != 1) { + dev_err(&client->dev, "write error\n"); + return -EIO; + } + + if (t->enabled) { + reg[M41T80_REG_ALARM_MON] |= M41T80_ALMON_AFE; + if (i2c_smbus_write_byte_data(client, M41T80_REG_ALARM_MON, + reg[M41T80_REG_ALARM_MON]) < 0) { + dev_err(&client->dev, "write error\n"); + return -EIO; + } + } + return 0; +} + +static int m41t80_rtc_read_alarm(struct device *dev, struct rtc_wkalrm *t) +{ + struct i2c_client *client = to_i2c_client(dev); + u8 buf[M41T80_ALARM_REG_SIZE + 1]; /* all alarm regs and flags */ + u8 dt_addr[1] = { M41T80_REG_ALARM_MON }; + u8 *reg = buf - M41T80_REG_ALARM_MON; + struct i2c_msg msgs[] = { + { + .addr = client->addr, + .flags = 0, + .len = 1, + .buf = dt_addr, + }, + { + .addr = client->addr, + .flags = I2C_M_RD, + .len = M41T80_ALARM_REG_SIZE + 1, + .buf = buf, + }, + }; + + if (i2c_transfer(client->adapter, msgs, 2) < 0) { + dev_err(&client->dev, "read error\n"); + return -EIO; + } + t->time.tm_sec = -1; + t->time.tm_min = -1; + t->time.tm_hour = -1; + t->time.tm_mday = -1; + t->time.tm_mon = -1; + if (!(reg[M41T80_REG_ALARM_SEC] & 0x80)) + t->time.tm_sec = bcd2bin(reg[M41T80_REG_ALARM_SEC] & 0x7f); + if (!(reg[M41T80_REG_ALARM_MIN] & 0x80)) + t->time.tm_min = bcd2bin(reg[M41T80_REG_ALARM_MIN] & 0x7f); + if (!(reg[M41T80_REG_ALARM_HOUR] & 0x80)) + t->time.tm_hour = bcd2bin(reg[M41T80_REG_ALARM_HOUR] & 0x3f); + if (!(reg[M41T80_REG_ALARM_DAY] & 0x80)) + t->time.tm_mday = bcd2bin(reg[M41T80_REG_ALARM_DAY] & 0x3f); + if (!(reg[M41T80_REG_ALARM_DAY] & 0x40)) + t->time.tm_mon = bcd2bin(reg[M41T80_REG_ALARM_MON] & 0x1f) - 1; + t->time.tm_year = -1; + t->time.tm_wday = -1; + t->time.tm_yday = -1; + t->time.tm_isdst = -1; + t->enabled = !!(reg[M41T80_REG_ALARM_MON] & M41T80_ALMON_AFE); + t->pending = !!(reg[M41T80_REG_FLAGS] & M41T80_FLAGS_AF); + return 0; +} + static struct rtc_class_ops m41t80_rtc_ops = { .read_time = m41t80_rtc_read_time, .set_time = m41t80_rtc_set_time, + /* + * XXX - m41t80 alarm functionality is reported broken. + * until it is fixed, don't register alarm functions. + * + .read_alarm = m41t80_rtc_read_alarm, + .set_alarm = m41t80_rtc_set_alarm, + */ .proc = m41t80_rtc_proc, + /* + * See above comment on broken alarm + * + .alarm_irq_enable = m41t80_rtc_alarm_irq_enable, + */ }; #if defined(CONFIG_RTC_INTF_SYSFS) || defined(CONFIG_RTC_INTF_SYSFS_MODULE) diff --git a/trunk/drivers/rtc/rtc-max8907.c b/trunk/drivers/rtc/rtc-max8907.c deleted file mode 100644 index e094ffa434f8..000000000000 --- a/trunk/drivers/rtc/rtc-max8907.c +++ /dev/null @@ -1,244 +0,0 @@ -/* - * RTC driver for Maxim MAX8907 - * - * Copyright (c) 2011-2012, NVIDIA Corporation. - * - * Based on drivers/rtc/rtc-max8925.c, - * Copyright (C) 2009-2010 Marvell International Ltd. - * - * 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 -#include -#include -#include -#include -#include -#include -#include - -enum { - RTC_SEC = 0, - RTC_MIN, - RTC_HOUR, - RTC_WEEKDAY, - RTC_DATE, - RTC_MONTH, - RTC_YEAR1, - RTC_YEAR2, -}; - -#define TIME_NUM 8 -#define ALARM_1SEC (1 << 7) -#define HOUR_12 (1 << 7) -#define HOUR_AM_PM (1 << 5) -#define ALARM0_IRQ (1 << 3) -#define ALARM1_IRQ (1 << 2) -#define ALARM0_STATUS (1 << 2) -#define ALARM1_STATUS (1 << 1) - -struct max8907_rtc { - struct max8907 *max8907; - struct regmap *regmap; - struct rtc_device *rtc_dev; - int irq; -}; - -static irqreturn_t max8907_irq_handler(int irq, void *data) -{ - struct max8907_rtc *rtc = data; - - regmap_update_bits(rtc->regmap, MAX8907_REG_ALARM0_CNTL, 0x7f, 0); - - rtc_update_irq(rtc->rtc_dev, 1, RTC_IRQF | RTC_AF); - - return IRQ_HANDLED; -} - -static void regs_to_tm(u8 *regs, struct rtc_time *tm) -{ - tm->tm_year = bcd2bin(regs[RTC_YEAR2]) * 100 + - bcd2bin(regs[RTC_YEAR1]) - 1900; - tm->tm_mon = bcd2bin(regs[RTC_MONTH] & 0x1f) - 1; - tm->tm_mday = bcd2bin(regs[RTC_DATE] & 0x3f); - tm->tm_wday = (regs[RTC_WEEKDAY] & 0x07) - 1; - if (regs[RTC_HOUR] & HOUR_12) { - tm->tm_hour = bcd2bin(regs[RTC_HOUR] & 0x01f); - if (tm->tm_hour == 12) - tm->tm_hour = 0; - if (regs[RTC_HOUR] & HOUR_AM_PM) - tm->tm_hour += 12; - } else { - tm->tm_hour = bcd2bin(regs[RTC_HOUR] & 0x03f); - } - tm->tm_min = bcd2bin(regs[RTC_MIN] & 0x7f); - tm->tm_sec = bcd2bin(regs[RTC_SEC] & 0x7f); -} - -static void tm_to_regs(struct rtc_time *tm, u8 *regs) -{ - u8 high, low; - - high = (tm->tm_year + 1900) / 100; - low = tm->tm_year % 100; - regs[RTC_YEAR2] = bin2bcd(high); - regs[RTC_YEAR1] = bin2bcd(low); - regs[RTC_MONTH] = bin2bcd(tm->tm_mon + 1); - regs[RTC_DATE] = bin2bcd(tm->tm_mday); - regs[RTC_WEEKDAY] = tm->tm_wday + 1; - regs[RTC_HOUR] = bin2bcd(tm->tm_hour); - regs[RTC_MIN] = bin2bcd(tm->tm_min); - regs[RTC_SEC] = bin2bcd(tm->tm_sec); -} - -static int max8907_rtc_read_time(struct device *dev, struct rtc_time *tm) -{ - struct max8907_rtc *rtc = dev_get_drvdata(dev); - u8 regs[TIME_NUM]; - int ret; - - ret = regmap_bulk_read(rtc->regmap, MAX8907_REG_RTC_SEC, regs, - TIME_NUM); - if (ret < 0) - return ret; - - regs_to_tm(regs, tm); - - return 0; -} - -static int max8907_rtc_set_time(struct device *dev, struct rtc_time *tm) -{ - struct max8907_rtc *rtc = dev_get_drvdata(dev); - u8 regs[TIME_NUM]; - - tm_to_regs(tm, regs); - - return regmap_bulk_write(rtc->regmap, MAX8907_REG_RTC_SEC, regs, - TIME_NUM); -} - -static int max8907_rtc_read_alarm(struct device *dev, struct rtc_wkalrm *alrm) -{ - struct max8907_rtc *rtc = dev_get_drvdata(dev); - u8 regs[TIME_NUM]; - unsigned int val; - int ret; - - ret = regmap_bulk_read(rtc->regmap, MAX8907_REG_ALARM0_SEC, regs, - TIME_NUM); - if (ret < 0) - return ret; - - regs_to_tm(regs, &alrm->time); - - ret = regmap_read(rtc->regmap, MAX8907_REG_ALARM0_CNTL, &val); - if (ret < 0) - return ret; - - alrm->enabled = !!(val & 0x7f); - - return 0; -} - -static int max8907_rtc_set_alarm(struct device *dev, struct rtc_wkalrm *alrm) -{ - struct max8907_rtc *rtc = dev_get_drvdata(dev); - u8 regs[TIME_NUM]; - int ret; - - tm_to_regs(&alrm->time, regs); - - /* Disable alarm while we update the target time */ - ret = regmap_update_bits(rtc->regmap, MAX8907_REG_ALARM0_CNTL, 0x7f, 0); - if (ret < 0) - return ret; - - ret = regmap_bulk_write(rtc->regmap, MAX8907_REG_ALARM0_SEC, regs, - TIME_NUM); - if (ret < 0) - return ret; - - if (alrm->enabled) - ret = regmap_update_bits(rtc->regmap, MAX8907_REG_ALARM0_CNTL, - 0x7f, 0x7f); - - return ret; -} - -static const struct rtc_class_ops max8907_rtc_ops = { - .read_time = max8907_rtc_read_time, - .set_time = max8907_rtc_set_time, - .read_alarm = max8907_rtc_read_alarm, - .set_alarm = max8907_rtc_set_alarm, -}; - -static int __devinit max8907_rtc_probe(struct platform_device *pdev) -{ - struct max8907 *max8907 = dev_get_drvdata(pdev->dev.parent); - struct max8907_rtc *rtc; - int ret; - - rtc = devm_kzalloc(&pdev->dev, sizeof(*rtc), GFP_KERNEL); - if (!rtc) - return -ENOMEM; - platform_set_drvdata(pdev, rtc); - - rtc->max8907 = max8907; - rtc->regmap = max8907->regmap_rtc; - - rtc->rtc_dev = rtc_device_register("max8907-rtc", &pdev->dev, - &max8907_rtc_ops, THIS_MODULE); - if (IS_ERR(rtc->rtc_dev)) { - ret = PTR_ERR(rtc->rtc_dev); - dev_err(&pdev->dev, "Failed to register RTC device: %d\n", ret); - return ret; - } - - rtc->irq = regmap_irq_get_virq(max8907->irqc_rtc, - MAX8907_IRQ_RTC_ALARM0); - if (rtc->irq < 0) { - ret = rtc->irq; - goto err_unregister; - } - - ret = request_threaded_irq(rtc->irq, NULL, max8907_irq_handler, - IRQF_ONESHOT, "max8907-alarm0", rtc); - if (ret < 0) { - dev_err(&pdev->dev, "Failed to request IRQ%d: %d\n", - rtc->irq, ret); - goto err_unregister; - } - - return 0; - -err_unregister: - rtc_device_unregister(rtc->rtc_dev); - return ret; -} - -static int __devexit max8907_rtc_remove(struct platform_device *pdev) -{ - struct max8907_rtc *rtc = platform_get_drvdata(pdev); - - free_irq(rtc->irq, rtc); - rtc_device_unregister(rtc->rtc_dev); - - return 0; -} - -static struct platform_driver max8907_rtc_driver = { - .driver = { - .name = "max8907-rtc", - .owner = THIS_MODULE, - }, - .probe = max8907_rtc_probe, - .remove = __devexit_p(max8907_rtc_remove), -}; -module_platform_driver(max8907_rtc_driver); - -MODULE_DESCRIPTION("Maxim MAX8907 RTC driver"); -MODULE_LICENSE("GPL v2"); diff --git a/trunk/drivers/rtc/rtc-mxc.c b/trunk/drivers/rtc/rtc-mxc.c index cd0106293a49..e3e50d69baf8 100644 --- a/trunk/drivers/rtc/rtc-mxc.c +++ b/trunk/drivers/rtc/rtc-mxc.c @@ -343,7 +343,7 @@ static struct rtc_class_ops mxc_rtc_ops = { .alarm_irq_enable = mxc_rtc_alarm_irq_enable, }; -static int __devinit mxc_rtc_probe(struct platform_device *pdev) +static int __init mxc_rtc_probe(struct platform_device *pdev) { struct resource *res; struct rtc_device *rtc; @@ -367,14 +367,14 @@ static int __devinit mxc_rtc_probe(struct platform_device *pdev) pdata->ioaddr = devm_ioremap(&pdev->dev, res->start, resource_size(res)); - pdata->clk = devm_clk_get(&pdev->dev, NULL); + pdata->clk = clk_get(&pdev->dev, "rtc"); if (IS_ERR(pdata->clk)) { dev_err(&pdev->dev, "unable to get clock!\n"); ret = PTR_ERR(pdata->clk); goto exit_free_pdata; } - clk_prepare_enable(pdata->clk); + clk_enable(pdata->clk); rate = clk_get_rate(pdata->clk); if (rate == 32768) @@ -426,20 +426,22 @@ static int __devinit mxc_rtc_probe(struct platform_device *pdev) exit_clr_drvdata: platform_set_drvdata(pdev, NULL); exit_put_clk: - clk_disable_unprepare(pdata->clk); + clk_disable(pdata->clk); + clk_put(pdata->clk); exit_free_pdata: return ret; } -static int __devexit mxc_rtc_remove(struct platform_device *pdev) +static int __exit mxc_rtc_remove(struct platform_device *pdev) { struct rtc_plat_data *pdata = platform_get_drvdata(pdev); rtc_device_unregister(pdata->rtc); - clk_disable_unprepare(pdata->clk); + clk_disable(pdata->clk); + clk_put(pdata->clk); platform_set_drvdata(pdev, NULL); return 0; @@ -480,11 +482,21 @@ static struct platform_driver mxc_rtc_driver = { #endif .owner = THIS_MODULE, }, - .probe = mxc_rtc_probe, - .remove = __devexit_p(mxc_rtc_remove), + .remove = __exit_p(mxc_rtc_remove), }; -module_platform_driver(mxc_rtc_driver) +static int __init mxc_rtc_init(void) +{ + return platform_driver_probe(&mxc_rtc_driver, mxc_rtc_probe); +} + +static void __exit mxc_rtc_exit(void) +{ + platform_driver_unregister(&mxc_rtc_driver); +} + +module_init(mxc_rtc_init); +module_exit(mxc_rtc_exit); MODULE_AUTHOR("Daniel Mack "); MODULE_DESCRIPTION("RTC driver for Freescale MXC"); diff --git a/trunk/drivers/rtc/rtc-pcf8563.c b/trunk/drivers/rtc/rtc-pcf8563.c index 98e3a2b681e6..c2fe426a6ef2 100644 --- a/trunk/drivers/rtc/rtc-pcf8563.c +++ b/trunk/drivers/rtc/rtc-pcf8563.c @@ -78,17 +78,8 @@ static int pcf8563_get_datetime(struct i2c_client *client, struct rtc_time *tm) unsigned char buf[13] = { PCF8563_REG_ST1 }; struct i2c_msg msgs[] = { - {/* setup read ptr */ - .addr = client->addr, - .len = 1, - .buf = buf - }, - {/* read status + date */ - .addr = client->addr, - .flags = I2C_M_RD, - .len = 13, - .buf = buf - }, + { client->addr, 0, 1, buf }, /* setup read ptr */ + { client->addr, I2C_M_RD, 13, buf }, /* read status + date */ }; /* read registers */ diff --git a/trunk/drivers/rtc/rtc-proc.c b/trunk/drivers/rtc/rtc-proc.c index e96236ac2e78..0a59fda5c09d 100644 --- a/trunk/drivers/rtc/rtc-proc.c +++ b/trunk/drivers/rtc/rtc-proc.c @@ -18,26 +18,6 @@ #include "rtc-core.h" -#define NAME_SIZE 10 - -#if defined(CONFIG_RTC_HCTOSYS_DEVICE) -static bool is_rtc_hctosys(struct rtc_device *rtc) -{ - int size; - char name[NAME_SIZE]; - - size = scnprintf(name, NAME_SIZE, "rtc%d", rtc->id); - if (size > NAME_SIZE) - return false; - - return !strncmp(name, CONFIG_RTC_HCTOSYS_DEVICE, NAME_SIZE); -} -#else -static bool is_rtc_hctosys(struct rtc_device *rtc) -{ - return (rtc->id == 0); -} -#endif static int rtc_proc_show(struct seq_file *seq, void *offset) { @@ -137,12 +117,12 @@ static const struct file_operations rtc_proc_fops = { void rtc_proc_add_device(struct rtc_device *rtc) { - if (is_rtc_hctosys(rtc)) + if (rtc->id == 0) proc_create_data("driver/rtc", 0, NULL, &rtc_proc_fops, rtc); } void rtc_proc_del_device(struct rtc_device *rtc) { - if (is_rtc_hctosys(rtc)) + if (rtc->id == 0) remove_proc_entry("driver/rtc", NULL); } diff --git a/trunk/drivers/rtc/rtc-rc5t583.c b/trunk/drivers/rtc/rtc-rc5t583.c deleted file mode 100644 index cdb140c29c56..000000000000 --- a/trunk/drivers/rtc/rtc-rc5t583.c +++ /dev/null @@ -1,331 +0,0 @@ -/* - * rtc-rc5t583.c -- RICOH RC5T583 Real Time Clock - * - * Copyright (c) 2012, NVIDIA CORPORATION. All rights reserved. - * Author: Venu Byravarasu - * - * 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, see . */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -struct rc5t583_rtc { - struct rtc_device *rtc; - /* To store the list of enabled interrupts, during system suspend */ - u32 irqen; -}; - -/* Total number of RTC registers needed to set time*/ -#define NUM_TIME_REGS (RC5T583_RTC_YEAR - RC5T583_RTC_SEC + 1) - -/* Total number of RTC registers needed to set Y-Alarm*/ -#define NUM_YAL_REGS (RC5T583_RTC_AY_YEAR - RC5T583_RTC_AY_MIN + 1) - -/* Set Y-Alarm interrupt */ -#define SET_YAL BIT(5) - -/* Get Y-Alarm interrupt status*/ -#define GET_YAL_STATUS BIT(3) - -static int rc5t583_rtc_alarm_irq_enable(struct device *dev, unsigned enabled) -{ - struct rc5t583 *rc5t583 = dev_get_drvdata(dev->parent); - u8 val; - - /* Set Y-Alarm, based on 'enabled' */ - val = enabled ? SET_YAL : 0; - - return regmap_update_bits(rc5t583->regmap, RC5T583_RTC_CTL1, SET_YAL, - val); -} - -/* - * Gets current rc5t583 RTC time and date parameters. - * - * The RTC's time/alarm representation is not what gmtime(3) requires - * Linux to use: - * - * - Months are 1..12 vs Linux 0-11 - * - Years are 0..99 vs Linux 1900..N (we assume 21st century) - */ -static int rc5t583_rtc_read_time(struct device *dev, struct rtc_time *tm) -{ - struct rc5t583 *rc5t583 = dev_get_drvdata(dev->parent); - u8 rtc_data[NUM_TIME_REGS]; - int ret; - - ret = regmap_bulk_read(rc5t583->regmap, RC5T583_RTC_SEC, rtc_data, - NUM_TIME_REGS); - if (ret < 0) { - dev_err(dev, "RTC read time failed with err:%d\n", ret); - return ret; - } - - tm->tm_sec = bcd2bin(rtc_data[0]); - tm->tm_min = bcd2bin(rtc_data[1]); - tm->tm_hour = bcd2bin(rtc_data[2]); - tm->tm_wday = bcd2bin(rtc_data[3]); - tm->tm_mday = bcd2bin(rtc_data[4]); - tm->tm_mon = bcd2bin(rtc_data[5]) - 1; - tm->tm_year = bcd2bin(rtc_data[6]) + 100; - - return ret; -} - -static int rc5t583_rtc_set_time(struct device *dev, struct rtc_time *tm) -{ - struct rc5t583 *rc5t583 = dev_get_drvdata(dev->parent); - unsigned char rtc_data[NUM_TIME_REGS]; - int ret; - - rtc_data[0] = bin2bcd(tm->tm_sec); - rtc_data[1] = bin2bcd(tm->tm_min); - rtc_data[2] = bin2bcd(tm->tm_hour); - rtc_data[3] = bin2bcd(tm->tm_wday); - rtc_data[4] = bin2bcd(tm->tm_mday); - rtc_data[5] = bin2bcd(tm->tm_mon + 1); - rtc_data[6] = bin2bcd(tm->tm_year - 100); - - ret = regmap_bulk_write(rc5t583->regmap, RC5T583_RTC_SEC, rtc_data, - NUM_TIME_REGS); - if (ret < 0) { - dev_err(dev, "RTC set time failed with error %d\n", ret); - return ret; - } - - return ret; -} - -static int rc5t583_rtc_read_alarm(struct device *dev, struct rtc_wkalrm *alm) -{ - struct rc5t583 *rc5t583 = dev_get_drvdata(dev->parent); - unsigned char alarm_data[NUM_YAL_REGS]; - u32 interrupt_enable; - int ret; - - ret = regmap_bulk_read(rc5t583->regmap, RC5T583_RTC_AY_MIN, alarm_data, - NUM_YAL_REGS); - if (ret < 0) { - dev_err(dev, "rtc_read_alarm error %d\n", ret); - return ret; - } - - alm->time.tm_min = bcd2bin(alarm_data[0]); - alm->time.tm_hour = bcd2bin(alarm_data[1]); - alm->time.tm_mday = bcd2bin(alarm_data[2]); - alm->time.tm_mon = bcd2bin(alarm_data[3]) - 1; - alm->time.tm_year = bcd2bin(alarm_data[4]) + 100; - - ret = regmap_read(rc5t583->regmap, RC5T583_RTC_CTL1, &interrupt_enable); - if (ret < 0) - return ret; - - /* check if YALE is set */ - if (interrupt_enable & SET_YAL) - alm->enabled = 1; - - return ret; -} - -static int rc5t583_rtc_set_alarm(struct device *dev, struct rtc_wkalrm *alm) -{ - struct rc5t583 *rc5t583 = dev_get_drvdata(dev->parent); - unsigned char alarm_data[NUM_YAL_REGS]; - int ret; - - ret = rc5t583_rtc_alarm_irq_enable(dev, 0); - if (ret) - return ret; - - alarm_data[0] = bin2bcd(alm->time.tm_min); - alarm_data[1] = bin2bcd(alm->time.tm_hour); - alarm_data[2] = bin2bcd(alm->time.tm_mday); - alarm_data[3] = bin2bcd(alm->time.tm_mon + 1); - alarm_data[4] = bin2bcd(alm->time.tm_year - 100); - - ret = regmap_bulk_write(rc5t583->regmap, RC5T583_RTC_AY_MIN, alarm_data, - NUM_YAL_REGS); - if (ret) { - dev_err(dev, "rtc_set_alarm error %d\n", ret); - return ret; - } - - if (alm->enabled) - ret = rc5t583_rtc_alarm_irq_enable(dev, 1); - - return ret; -} - -static irqreturn_t rc5t583_rtc_interrupt(int irq, void *rtc) -{ - struct device *dev = rtc; - struct rc5t583 *rc5t583 = dev_get_drvdata(dev->parent); - struct rc5t583_rtc *rc5t583_rtc = dev_get_drvdata(dev); - unsigned long events = 0; - int ret; - u32 rtc_reg; - - ret = regmap_read(rc5t583->regmap, RC5T583_RTC_CTL2, &rtc_reg); - if (ret < 0) - return IRQ_NONE; - - if (rtc_reg & GET_YAL_STATUS) { - events = RTC_IRQF | RTC_AF; - /* clear pending Y-alarm interrupt bit */ - rtc_reg &= ~GET_YAL_STATUS; - } - - ret = regmap_write(rc5t583->regmap, RC5T583_RTC_CTL2, rtc_reg); - if (ret) - return IRQ_NONE; - - /* Notify RTC core on event */ - rtc_update_irq(rc5t583_rtc->rtc, 1, events); - - return IRQ_HANDLED; -} - -static const struct rtc_class_ops rc5t583_rtc_ops = { - .read_time = rc5t583_rtc_read_time, - .set_time = rc5t583_rtc_set_time, - .read_alarm = rc5t583_rtc_read_alarm, - .set_alarm = rc5t583_rtc_set_alarm, - .alarm_irq_enable = rc5t583_rtc_alarm_irq_enable, -}; - -static int __devinit rc5t583_rtc_probe(struct platform_device *pdev) -{ - struct rc5t583 *rc5t583 = dev_get_drvdata(pdev->dev.parent); - struct rc5t583_rtc *ricoh_rtc; - struct rc5t583_platform_data *pmic_plat_data; - int ret; - int irq; - - ricoh_rtc = devm_kzalloc(&pdev->dev, sizeof(struct rc5t583_rtc), - GFP_KERNEL); - if (!ricoh_rtc) - return -ENOMEM; - - platform_set_drvdata(pdev, ricoh_rtc); - - /* Clear pending interrupts */ - ret = regmap_write(rc5t583->regmap, RC5T583_RTC_CTL2, 0); - if (ret < 0) - return ret; - - /* clear RTC Adjust register */ - ret = regmap_write(rc5t583->regmap, RC5T583_RTC_ADJ, 0); - if (ret < 0) { - dev_err(&pdev->dev, "unable to program rtc_adjust reg\n"); - return -EBUSY; - } - - pmic_plat_data = dev_get_platdata(rc5t583->dev); - irq = pmic_plat_data->irq_base; - if (irq <= 0) { - dev_warn(&pdev->dev, "Wake up is not possible as irq = %d\n", - irq); - return ret; - } - - irq += RC5T583_IRQ_YALE; - ret = devm_request_threaded_irq(&pdev->dev, irq, NULL, - rc5t583_rtc_interrupt, IRQF_TRIGGER_LOW, - "rtc-rc5t583", &pdev->dev); - if (ret < 0) { - dev_err(&pdev->dev, "IRQ is not free.\n"); - return ret; - } - device_init_wakeup(&pdev->dev, 1); - - ricoh_rtc->rtc = rtc_device_register(pdev->name, &pdev->dev, - &rc5t583_rtc_ops, THIS_MODULE); - if (IS_ERR(ricoh_rtc->rtc)) { - ret = PTR_ERR(ricoh_rtc->rtc); - dev_err(&pdev->dev, "RTC device register: err %d\n", ret); - return ret; - } - - return 0; -} - -/* - * Disable rc5t583 RTC interrupts. - * Sets status flag to free. - */ -static int __devexit rc5t583_rtc_remove(struct platform_device *pdev) -{ - struct rc5t583_rtc *rc5t583_rtc = dev_get_drvdata(&pdev->dev); - - rc5t583_rtc_alarm_irq_enable(&rc5t583_rtc->rtc->dev, 0); - - rtc_device_unregister(rc5t583_rtc->rtc); - return 0; -} - -#ifdef CONFIG_PM_SLEEP - -static int rc5t583_rtc_suspend(struct device *dev) -{ - struct rc5t583 *rc5t583 = dev_get_drvdata(dev->parent); - struct rc5t583_rtc *rc5t583_rtc = dev_get_drvdata(dev); - int ret; - - /* Store current list of enabled interrupts*/ - ret = regmap_read(rc5t583->regmap, RC5T583_RTC_CTL1, - &rc5t583_rtc->irqen); - return ret; -} - -static int rc5t583_rtc_resume(struct device *dev) -{ - struct rc5t583 *rc5t583 = dev_get_drvdata(dev->parent); - struct rc5t583_rtc *rc5t583_rtc = dev_get_drvdata(dev); - - /* Restore list of enabled interrupts before suspend */ - return regmap_write(rc5t583->regmap, RC5T583_RTC_CTL1, - rc5t583_rtc->irqen); -} - -static const struct dev_pm_ops rc5t583_rtc_pm_ops = { - .suspend = rc5t583_rtc_suspend, - .resume = rc5t583_rtc_resume, -}; - -#define DEV_PM_OPS (&rc5t583_rtc_pm_ops) -#else -#define DEV_PM_OPS NULL -#endif - -static struct platform_driver rc5t583_rtc_driver = { - .probe = rc5t583_rtc_probe, - .remove = __devexit_p(rc5t583_rtc_remove), - .driver = { - .owner = THIS_MODULE, - .name = "rtc-rc5t583", - .pm = DEV_PM_OPS, - }, -}; - -module_platform_driver(rc5t583_rtc_driver); -MODULE_ALIAS("platform:rtc-rc5t583"); -MODULE_AUTHOR("Venu Byravarasu "); -MODULE_LICENSE("GPL v2"); diff --git a/trunk/drivers/rtc/rtc-rs5c372.c b/trunk/drivers/rtc/rtc-rs5c372.c index 76f565ae384d..fb4842c3544e 100644 --- a/trunk/drivers/rtc/rtc-rs5c372.c +++ b/trunk/drivers/rtc/rtc-rs5c372.c @@ -104,12 +104,7 @@ static int rs5c_get_regs(struct rs5c372 *rs5c) { struct i2c_client *client = rs5c->client; struct i2c_msg msgs[] = { - { - .addr = client->addr, - .flags = I2C_M_RD, - .len = sizeof(rs5c->buf), - .buf = rs5c->buf - }, + { client->addr, I2C_M_RD, sizeof rs5c->buf, rs5c->buf }, }; /* This implements the third reading method from the datasheet, using diff --git a/trunk/drivers/rtc/rtc-s35390a.c b/trunk/drivers/rtc/rtc-s35390a.c index 8a092325188d..c9562ceedef3 100644 --- a/trunk/drivers/rtc/rtc-s35390a.c +++ b/trunk/drivers/rtc/rtc-s35390a.c @@ -19,8 +19,6 @@ #define S35390A_CMD_STATUS1 0 #define S35390A_CMD_STATUS2 1 #define S35390A_CMD_TIME1 2 -#define S35390A_CMD_TIME2 3 -#define S35390A_CMD_INT2_REG1 5 #define S35390A_BYTE_YEAR 0 #define S35390A_BYTE_MONTH 1 @@ -30,23 +28,12 @@ #define S35390A_BYTE_MINS 5 #define S35390A_BYTE_SECS 6 -#define S35390A_ALRM_BYTE_WDAY 0 -#define S35390A_ALRM_BYTE_HOURS 1 -#define S35390A_ALRM_BYTE_MINS 2 - #define S35390A_FLAG_POC 0x01 #define S35390A_FLAG_BLD 0x02 #define S35390A_FLAG_24H 0x40 #define S35390A_FLAG_RESET 0x80 #define S35390A_FLAG_TEST 0x01 -#define S35390A_INT2_MODE_MASK 0xF0 - -#define S35390A_INT2_MODE_NOINTR 0x00 -#define S35390A_INT2_MODE_FREQ 0x10 -#define S35390A_INT2_MODE_ALARM 0x40 -#define S35390A_INT2_MODE_PMIN_EDG 0x20 - static const struct i2c_device_id s35390a_id[] = { { "s35390a", 0 }, { } @@ -63,11 +50,7 @@ static int s35390a_set_reg(struct s35390a *s35390a, int reg, char *buf, int len) { struct i2c_client *client = s35390a->client[reg]; struct i2c_msg msg[] = { - { - .addr = client->addr, - .len = len, - .buf = buf - }, + { client->addr, 0, len, buf }, }; if ((i2c_transfer(client->adapter, msg, 1)) != 1) @@ -80,12 +63,7 @@ static int s35390a_get_reg(struct s35390a *s35390a, int reg, char *buf, int len) { struct i2c_client *client = s35390a->client[reg]; struct i2c_msg msg[] = { - { - .addr = client->addr, - .flags = I2C_M_RD, - .len = len, - .buf = buf - }, + { client->addr, I2C_M_RD, len, buf }, }; if ((i2c_transfer(client->adapter, msg, 1)) != 1) @@ -206,104 +184,6 @@ static int s35390a_get_datetime(struct i2c_client *client, struct rtc_time *tm) return rtc_valid_tm(tm); } -static int s35390a_set_alarm(struct i2c_client *client, struct rtc_wkalrm *alm) -{ - struct s35390a *s35390a = i2c_get_clientdata(client); - char buf[3], sts = 0; - int err, i; - - dev_dbg(&client->dev, "%s: alm is secs=%d, mins=%d, hours=%d mday=%d, "\ - "mon=%d, year=%d, wday=%d\n", __func__, alm->time.tm_sec, - alm->time.tm_min, alm->time.tm_hour, alm->time.tm_mday, - alm->time.tm_mon, alm->time.tm_year, alm->time.tm_wday); - - /* disable interrupt */ - err = s35390a_set_reg(s35390a, S35390A_CMD_STATUS2, &sts, sizeof(sts)); - if (err < 0) - return err; - - /* clear pending interrupt, if any */ - err = s35390a_get_reg(s35390a, S35390A_CMD_STATUS1, &sts, sizeof(sts)); - if (err < 0) - return err; - - if (alm->enabled) - sts = S35390A_INT2_MODE_ALARM; - else - sts = S35390A_INT2_MODE_NOINTR; - - /* This chip expects the bits of each byte to be in reverse order */ - sts = bitrev8(sts); - - /* set interupt mode*/ - err = s35390a_set_reg(s35390a, S35390A_CMD_STATUS2, &sts, sizeof(sts)); - if (err < 0) - return err; - - if (alm->time.tm_wday != -1) - buf[S35390A_ALRM_BYTE_WDAY] = bin2bcd(alm->time.tm_wday) | 0x80; - - buf[S35390A_ALRM_BYTE_HOURS] = s35390a_hr2reg(s35390a, - alm->time.tm_hour) | 0x80; - buf[S35390A_ALRM_BYTE_MINS] = bin2bcd(alm->time.tm_min) | 0x80; - - if (alm->time.tm_hour >= 12) - buf[S35390A_ALRM_BYTE_HOURS] |= 0x40; - - for (i = 0; i < 3; ++i) - buf[i] = bitrev8(buf[i]); - - err = s35390a_set_reg(s35390a, S35390A_CMD_INT2_REG1, buf, - sizeof(buf)); - - return err; -} - -static int s35390a_read_alarm(struct i2c_client *client, struct rtc_wkalrm *alm) -{ - struct s35390a *s35390a = i2c_get_clientdata(client); - char buf[3], sts; - int i, err; - - err = s35390a_get_reg(s35390a, S35390A_CMD_STATUS2, &sts, sizeof(sts)); - if (err < 0) - return err; - - if (bitrev8(sts) != S35390A_INT2_MODE_ALARM) - return -EINVAL; - - err = s35390a_get_reg(s35390a, S35390A_CMD_INT2_REG1, buf, sizeof(buf)); - if (err < 0) - return err; - - /* This chip returns the bits of each byte in reverse order */ - for (i = 0; i < 3; ++i) { - buf[i] = bitrev8(buf[i]); - buf[i] &= ~0x80; - } - - alm->time.tm_wday = bcd2bin(buf[S35390A_ALRM_BYTE_WDAY]); - alm->time.tm_hour = s35390a_reg2hr(s35390a, - buf[S35390A_ALRM_BYTE_HOURS]); - alm->time.tm_min = bcd2bin(buf[S35390A_ALRM_BYTE_MINS]); - - dev_dbg(&client->dev, "%s: alm is mins=%d, hours=%d, wday=%d\n", - __func__, alm->time.tm_min, alm->time.tm_hour, - alm->time.tm_wday); - - return 0; -} - -static int s35390a_rtc_read_alarm(struct device *dev, struct rtc_wkalrm *alm) -{ - return s35390a_read_alarm(to_i2c_client(dev), alm); -} - -static int s35390a_rtc_set_alarm(struct device *dev, struct rtc_wkalrm *alm) -{ - return s35390a_set_alarm(to_i2c_client(dev), alm); -} - static int s35390a_rtc_read_time(struct device *dev, struct rtc_time *tm) { return s35390a_get_datetime(to_i2c_client(dev), tm); @@ -317,9 +197,6 @@ static int s35390a_rtc_set_time(struct device *dev, struct rtc_time *tm) static const struct rtc_class_ops s35390a_rtc_ops = { .read_time = s35390a_rtc_read_time, .set_time = s35390a_rtc_set_time, - .set_alarm = s35390a_rtc_set_alarm, - .read_alarm = s35390a_rtc_read_alarm, - }; static struct i2c_driver s35390a_driver; @@ -384,8 +261,6 @@ static int s35390a_probe(struct i2c_client *client, if (s35390a_get_datetime(client, &tm) < 0) dev_warn(&client->dev, "clock needs to be set\n"); - device_set_wakeup_capable(&client->dev, 1); - s35390a->rtc = rtc_device_register(s35390a_driver.driver.name, &client->dev, &s35390a_rtc_ops, THIS_MODULE); diff --git a/trunk/drivers/rtc/rtc-s3c.c b/trunk/drivers/rtc/rtc-s3c.c index 77823d21d314..bfbd92c8d1c9 100644 --- a/trunk/drivers/rtc/rtc-s3c.c +++ b/trunk/drivers/rtc/rtc-s3c.c @@ -476,13 +476,13 @@ static int __devinit s3c_rtc_probe(struct platform_device *pdev) s3c_rtc_tickno = platform_get_irq(pdev, 1); if (s3c_rtc_tickno < 0) { dev_err(&pdev->dev, "no irq for rtc tick\n"); - return s3c_rtc_tickno; + return -ENOENT; } s3c_rtc_alarmno = platform_get_irq(pdev, 0); if (s3c_rtc_alarmno < 0) { dev_err(&pdev->dev, "no irq for alarm\n"); - return s3c_rtc_alarmno; + return -ENOENT; } pr_debug("s3c2410_rtc: tick irq %d, alarm irq %d\n", diff --git a/trunk/drivers/rtc/rtc-snvs.c b/trunk/drivers/rtc/rtc-snvs.c deleted file mode 100644 index 3c0da333f465..000000000000 --- a/trunk/drivers/rtc/rtc-snvs.c +++ /dev/null @@ -1,350 +0,0 @@ -/* - * Copyright (C) 2011-2012 Freescale Semiconductor, Inc. - * - * The code contained herein is licensed under the GNU General Public - * License. You may obtain a copy of the GNU General Public License - * Version 2 or later at the following locations: - * - * http://www.opensource.org/licenses/gpl-license.html - * http://www.gnu.org/copyleft/gpl.html - */ - -#include -#include -#include -#include -#include -#include -#include -#include - -/* These register offsets are relative to LP (Low Power) range */ -#define SNVS_LPCR 0x04 -#define SNVS_LPSR 0x18 -#define SNVS_LPSRTCMR 0x1c -#define SNVS_LPSRTCLR 0x20 -#define SNVS_LPTAR 0x24 -#define SNVS_LPPGDR 0x30 - -#define SNVS_LPCR_SRTC_ENV (1 << 0) -#define SNVS_LPCR_LPTA_EN (1 << 1) -#define SNVS_LPCR_LPWUI_EN (1 << 3) -#define SNVS_LPSR_LPTA (1 << 0) - -#define SNVS_LPPGDR_INIT 0x41736166 -#define CNTR_TO_SECS_SH 15 - -struct snvs_rtc_data { - struct rtc_device *rtc; - void __iomem *ioaddr; - int irq; - spinlock_t lock; -}; - -static u32 rtc_read_lp_counter(void __iomem *ioaddr) -{ - u64 read1, read2; - - do { - read1 = readl(ioaddr + SNVS_LPSRTCMR); - read1 <<= 32; - read1 |= readl(ioaddr + SNVS_LPSRTCLR); - - read2 = readl(ioaddr + SNVS_LPSRTCMR); - read2 <<= 32; - read2 |= readl(ioaddr + SNVS_LPSRTCLR); - } while (read1 != read2); - - /* Convert 47-bit counter to 32-bit raw second count */ - return (u32) (read1 >> CNTR_TO_SECS_SH); -} - -static void rtc_write_sync_lp(void __iomem *ioaddr) -{ - u32 count1, count2, count3; - int i; - - /* Wait for 3 CKIL cycles */ - for (i = 0; i < 3; i++) { - do { - count1 = readl(ioaddr + SNVS_LPSRTCLR); - count2 = readl(ioaddr + SNVS_LPSRTCLR); - } while (count1 != count2); - - /* Now wait until counter value changes */ - do { - do { - count2 = readl(ioaddr + SNVS_LPSRTCLR); - count3 = readl(ioaddr + SNVS_LPSRTCLR); - } while (count2 != count3); - } while (count3 == count1); - } -} - -static int snvs_rtc_enable(struct snvs_rtc_data *data, bool enable) -{ - unsigned long flags; - int timeout = 1000; - u32 lpcr; - - spin_lock_irqsave(&data->lock, flags); - - lpcr = readl(data->ioaddr + SNVS_LPCR); - if (enable) - lpcr |= SNVS_LPCR_SRTC_ENV; - else - lpcr &= ~SNVS_LPCR_SRTC_ENV; - writel(lpcr, data->ioaddr + SNVS_LPCR); - - spin_unlock_irqrestore(&data->lock, flags); - - while (--timeout) { - lpcr = readl(data->ioaddr + SNVS_LPCR); - - if (enable) { - if (lpcr & SNVS_LPCR_SRTC_ENV) - break; - } else { - if (!(lpcr & SNVS_LPCR_SRTC_ENV)) - break; - } - } - - if (!timeout) - return -ETIMEDOUT; - - return 0; -} - -static int snvs_rtc_read_time(struct device *dev, struct rtc_time *tm) -{ - struct snvs_rtc_data *data = dev_get_drvdata(dev); - unsigned long time = rtc_read_lp_counter(data->ioaddr); - - rtc_time_to_tm(time, tm); - - return 0; -} - -static int snvs_rtc_set_time(struct device *dev, struct rtc_time *tm) -{ - struct snvs_rtc_data *data = dev_get_drvdata(dev); - unsigned long time; - - rtc_tm_to_time(tm, &time); - - /* Disable RTC first */ - snvs_rtc_enable(data, false); - - /* Write 32-bit time to 47-bit timer, leaving 15 LSBs blank */ - writel(time << CNTR_TO_SECS_SH, data->ioaddr + SNVS_LPSRTCLR); - writel(time >> (32 - CNTR_TO_SECS_SH), data->ioaddr + SNVS_LPSRTCMR); - - /* Enable RTC again */ - snvs_rtc_enable(data, true); - - return 0; -} - -static int snvs_rtc_read_alarm(struct device *dev, struct rtc_wkalrm *alrm) -{ - struct snvs_rtc_data *data = dev_get_drvdata(dev); - u32 lptar, lpsr; - - lptar = readl(data->ioaddr + SNVS_LPTAR); - rtc_time_to_tm(lptar, &alrm->time); - - lpsr = readl(data->ioaddr + SNVS_LPSR); - alrm->pending = (lpsr & SNVS_LPSR_LPTA) ? 1 : 0; - - return 0; -} - -static int snvs_rtc_alarm_irq_enable(struct device *dev, unsigned int enable) -{ - struct snvs_rtc_data *data = dev_get_drvdata(dev); - u32 lpcr; - unsigned long flags; - - spin_lock_irqsave(&data->lock, flags); - - lpcr = readl(data->ioaddr + SNVS_LPCR); - if (enable) - lpcr |= (SNVS_LPCR_LPTA_EN | SNVS_LPCR_LPWUI_EN); - else - lpcr &= ~(SNVS_LPCR_LPTA_EN | SNVS_LPCR_LPWUI_EN); - writel(lpcr, data->ioaddr + SNVS_LPCR); - - spin_unlock_irqrestore(&data->lock, flags); - - rtc_write_sync_lp(data->ioaddr); - - return 0; -} - -static int snvs_rtc_set_alarm(struct device *dev, struct rtc_wkalrm *alrm) -{ - struct snvs_rtc_data *data = dev_get_drvdata(dev); - struct rtc_time *alrm_tm = &alrm->time; - unsigned long time; - unsigned long flags; - u32 lpcr; - - rtc_tm_to_time(alrm_tm, &time); - - spin_lock_irqsave(&data->lock, flags); - - /* Have to clear LPTA_EN before programming new alarm time in LPTAR */ - lpcr = readl(data->ioaddr + SNVS_LPCR); - lpcr &= ~SNVS_LPCR_LPTA_EN; - writel(lpcr, data->ioaddr + SNVS_LPCR); - - spin_unlock_irqrestore(&data->lock, flags); - - writel(time, data->ioaddr + SNVS_LPTAR); - - /* Clear alarm interrupt status bit */ - writel(SNVS_LPSR_LPTA, data->ioaddr + SNVS_LPSR); - - return snvs_rtc_alarm_irq_enable(dev, alrm->enabled); -} - -static const struct rtc_class_ops snvs_rtc_ops = { - .read_time = snvs_rtc_read_time, - .set_time = snvs_rtc_set_time, - .read_alarm = snvs_rtc_read_alarm, - .set_alarm = snvs_rtc_set_alarm, - .alarm_irq_enable = snvs_rtc_alarm_irq_enable, -}; - -static irqreturn_t snvs_rtc_irq_handler(int irq, void *dev_id) -{ - struct device *dev = dev_id; - struct snvs_rtc_data *data = dev_get_drvdata(dev); - u32 lpsr; - u32 events = 0; - - lpsr = readl(data->ioaddr + SNVS_LPSR); - - if (lpsr & SNVS_LPSR_LPTA) { - events |= (RTC_AF | RTC_IRQF); - - /* RTC alarm should be one-shot */ - snvs_rtc_alarm_irq_enable(dev, 0); - - rtc_update_irq(data->rtc, 1, events); - } - - /* clear interrupt status */ - writel(lpsr, data->ioaddr + SNVS_LPSR); - - return events ? IRQ_HANDLED : IRQ_NONE; -} - -static int __devinit snvs_rtc_probe(struct platform_device *pdev) -{ - struct snvs_rtc_data *data; - struct resource *res; - int ret; - - data = devm_kzalloc(&pdev->dev, sizeof(*data), GFP_KERNEL); - if (!data) - return -ENOMEM; - - res = platform_get_resource(pdev, IORESOURCE_MEM, 0); - data->ioaddr = devm_request_and_ioremap(&pdev->dev, res); - if (!data->ioaddr) - return -EADDRNOTAVAIL; - - data->irq = platform_get_irq(pdev, 0); - if (data->irq < 0) - return data->irq; - - platform_set_drvdata(pdev, data); - - spin_lock_init(&data->lock); - - /* Initialize glitch detect */ - writel(SNVS_LPPGDR_INIT, data->ioaddr + SNVS_LPPGDR); - - /* Clear interrupt status */ - writel(0xffffffff, data->ioaddr + SNVS_LPSR); - - /* Enable RTC */ - snvs_rtc_enable(data, true); - - device_init_wakeup(&pdev->dev, true); - - ret = devm_request_irq(&pdev->dev, data->irq, snvs_rtc_irq_handler, - IRQF_SHARED, "rtc alarm", &pdev->dev); - if (ret) { - dev_err(&pdev->dev, "failed to request irq %d: %d\n", - data->irq, ret); - return ret; - } - - data->rtc = rtc_device_register(pdev->name, &pdev->dev, - &snvs_rtc_ops, THIS_MODULE); - if (IS_ERR(data->rtc)) { - ret = PTR_ERR(data->rtc); - dev_err(&pdev->dev, "failed to register rtc: %d\n", ret); - return ret; - } - - return 0; -} - -static int __devexit snvs_rtc_remove(struct platform_device *pdev) -{ - struct snvs_rtc_data *data = platform_get_drvdata(pdev); - - rtc_device_unregister(data->rtc); - - return 0; -} - -#ifdef CONFIG_PM_SLEEP -static int snvs_rtc_suspend(struct device *dev) -{ - struct snvs_rtc_data *data = dev_get_drvdata(dev); - - if (device_may_wakeup(dev)) - enable_irq_wake(data->irq); - - return 0; -} - -static int snvs_rtc_resume(struct device *dev) -{ - struct snvs_rtc_data *data = dev_get_drvdata(dev); - - if (device_may_wakeup(dev)) - disable_irq_wake(data->irq); - - return 0; -} -#endif - -static SIMPLE_DEV_PM_OPS(snvs_rtc_pm_ops, snvs_rtc_suspend, snvs_rtc_resume); - -static const struct of_device_id __devinitconst snvs_dt_ids[] = { - { .compatible = "fsl,sec-v4.0-mon-rtc-lp", }, - { /* sentinel */ } -}; -MODULE_DEVICE_TABLE(of, snvs_dt_ids); - -static struct platform_driver snvs_rtc_driver = { - .driver = { - .name = "snvs_rtc", - .owner = THIS_MODULE, - .pm = &snvs_rtc_pm_ops, - .of_match_table = snvs_dt_ids, - }, - .probe = snvs_rtc_probe, - .remove = __devexit_p(snvs_rtc_remove), -}; -module_platform_driver(snvs_rtc_driver); - -MODULE_AUTHOR("Freescale Semiconductor, Inc."); -MODULE_DESCRIPTION("Freescale SNVS RTC Driver"); -MODULE_LICENSE("GPL"); diff --git a/trunk/drivers/rtc/rtc-spear.c b/trunk/drivers/rtc/rtc-spear.c index bb507d23f6ce..e2785479113c 100644 --- a/trunk/drivers/rtc/rtc-spear.c +++ b/trunk/drivers/rtc/rtc-spear.c @@ -235,7 +235,7 @@ static int spear_rtc_read_time(struct device *dev, struct rtc_time *tm) static int spear_rtc_set_time(struct device *dev, struct rtc_time *tm) { struct spear_rtc_config *config = dev_get_drvdata(dev); - unsigned int time, date; + unsigned int time, date, err = 0; if (tm2bcd(tm) < 0) return -EINVAL; @@ -247,8 +247,11 @@ static int spear_rtc_set_time(struct device *dev, struct rtc_time *tm) (tm->tm_year << YEAR_SHIFT); writel(time, config->ioaddr + TIME_REG); writel(date, config->ioaddr + DATE_REG); + err = is_write_complete(config); + if (err < 0) + return err; - return is_write_complete(config); + return 0; } /* @@ -292,8 +295,7 @@ static int spear_rtc_read_alarm(struct device *dev, struct rtc_wkalrm *alm) static int spear_rtc_set_alarm(struct device *dev, struct rtc_wkalrm *alm) { struct spear_rtc_config *config = dev_get_drvdata(dev); - unsigned int time, date; - int err; + unsigned int time, date, err = 0; if (tm2bcd(&alm->time) < 0) return -EINVAL; @@ -355,7 +357,7 @@ static int __devinit spear_rtc_probe(struct platform_device *pdev) { struct resource *res; struct spear_rtc_config *config; - int status = 0; + unsigned int status = 0; int irq; res = platform_get_resource(pdev, IORESOURCE_MEM, 0); diff --git a/trunk/drivers/rtc/rtc-sysfs.c b/trunk/drivers/rtc/rtc-sysfs.c index b70e2bb63645..380083ca572f 100644 --- a/trunk/drivers/rtc/rtc-sysfs.c +++ b/trunk/drivers/rtc/rtc-sysfs.c @@ -102,12 +102,6 @@ rtc_sysfs_set_max_user_freq(struct device *dev, struct device_attribute *attr, return n; } -/** - * rtc_sysfs_show_hctosys - indicate if the given RTC set the system time - * - * Returns 1 if the system clock was set by this RTC at the last - * boot or resume event. - */ static ssize_t rtc_sysfs_show_hctosys(struct device *dev, struct device_attribute *attr, char *buf) diff --git a/trunk/drivers/rtc/rtc-tps65910.c b/trunk/drivers/rtc/rtc-tps65910.c deleted file mode 100644 index 7a82337e4dee..000000000000 --- a/trunk/drivers/rtc/rtc-tps65910.c +++ /dev/null @@ -1,349 +0,0 @@ -/* - * rtc-tps65910.c -- TPS65910 Real Time Clock interface - * - * Copyright (c) 2012, NVIDIA CORPORATION. All rights reserved. - * Author: Venu Byravarasu - * - * Based on original TI driver rtc-twl.c - * Copyright (C) 2007 MontaVista Software, Inc - * Author: Alexandre Rusev - * - * 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 -#include -#include -#include -#include -#include -#include -#include -#include -#include - -struct tps65910_rtc { - struct rtc_device *rtc; - /* To store the list of enabled interrupts */ - u32 irqstat; -}; - -/* Total number of RTC registers needed to set time*/ -#define NUM_TIME_REGS (TPS65910_YEARS - TPS65910_SECONDS + 1) - -static int tps65910_rtc_alarm_irq_enable(struct device *dev, unsigned enabled) -{ - struct tps65910 *tps = dev_get_drvdata(dev->parent); - u8 val = 0; - - if (enabled) - val = TPS65910_RTC_INTERRUPTS_IT_ALARM; - - return regmap_write(tps->regmap, TPS65910_RTC_INTERRUPTS, val); -} - -/* - * Gets current tps65910 RTC time and date parameters. - * - * The RTC's time/alarm representation is not what gmtime(3) requires - * Linux to use: - * - * - Months are 1..12 vs Linux 0-11 - * - Years are 0..99 vs Linux 1900..N (we assume 21st century) - */ -static int tps65910_rtc_read_time(struct device *dev, struct rtc_time *tm) -{ - unsigned char rtc_data[NUM_TIME_REGS]; - struct tps65910 *tps = dev_get_drvdata(dev->parent); - int ret; - - /* Copy RTC counting registers to static registers or latches */ - ret = regmap_update_bits(tps->regmap, TPS65910_RTC_CTRL, - TPS65910_RTC_CTRL_GET_TIME, TPS65910_RTC_CTRL_GET_TIME); - if (ret < 0) { - dev_err(dev, "RTC CTRL reg update failed with err:%d\n", ret); - return ret; - } - - ret = regmap_bulk_read(tps->regmap, TPS65910_SECONDS, rtc_data, - NUM_TIME_REGS); - if (ret < 0) { - dev_err(dev, "reading from RTC failed with err:%d\n", ret); - return ret; - } - - tm->tm_sec = bcd2bin(rtc_data[0]); - tm->tm_min = bcd2bin(rtc_data[1]); - tm->tm_hour = bcd2bin(rtc_data[2]); - tm->tm_mday = bcd2bin(rtc_data[3]); - tm->tm_mon = bcd2bin(rtc_data[4]) - 1; - tm->tm_year = bcd2bin(rtc_data[5]) + 100; - - return ret; -} - -static int tps65910_rtc_set_time(struct device *dev, struct rtc_time *tm) -{ - unsigned char rtc_data[NUM_TIME_REGS]; - struct tps65910 *tps = dev_get_drvdata(dev->parent); - int ret; - - rtc_data[0] = bin2bcd(tm->tm_sec); - rtc_data[1] = bin2bcd(tm->tm_min); - rtc_data[2] = bin2bcd(tm->tm_hour); - rtc_data[3] = bin2bcd(tm->tm_mday); - rtc_data[4] = bin2bcd(tm->tm_mon + 1); - rtc_data[5] = bin2bcd(tm->tm_year - 100); - - /* Stop RTC while updating the RTC time registers */ - ret = regmap_update_bits(tps->regmap, TPS65910_RTC_CTRL, - TPS65910_RTC_CTRL_STOP_RTC, 0); - if (ret < 0) { - dev_err(dev, "RTC stop failed with err:%d\n", ret); - return ret; - } - - /* update all the time registers in one shot */ - ret = regmap_bulk_write(tps->regmap, TPS65910_SECONDS, rtc_data, - NUM_TIME_REGS); - if (ret < 0) { - dev_err(dev, "rtc_set_time error %d\n", ret); - return ret; - } - - /* Start back RTC */ - ret = regmap_update_bits(tps->regmap, TPS65910_RTC_CTRL, - TPS65910_RTC_CTRL_STOP_RTC, 1); - if (ret < 0) - dev_err(dev, "RTC start failed with err:%d\n", ret); - - return ret; -} - -/* - * Gets current tps65910 RTC alarm time. - */ -static int tps65910_rtc_read_alarm(struct device *dev, struct rtc_wkalrm *alm) -{ - unsigned char alarm_data[NUM_TIME_REGS]; - u32 int_val; - struct tps65910 *tps = dev_get_drvdata(dev->parent); - int ret; - - ret = regmap_bulk_read(tps->regmap, TPS65910_SECONDS, alarm_data, - NUM_TIME_REGS); - if (ret < 0) { - dev_err(dev, "rtc_read_alarm error %d\n", ret); - return ret; - } - - alm->time.tm_sec = bcd2bin(alarm_data[0]); - alm->time.tm_min = bcd2bin(alarm_data[1]); - alm->time.tm_hour = bcd2bin(alarm_data[2]); - alm->time.tm_mday = bcd2bin(alarm_data[3]); - alm->time.tm_mon = bcd2bin(alarm_data[4]) - 1; - alm->time.tm_year = bcd2bin(alarm_data[5]) + 100; - - ret = regmap_read(tps->regmap, TPS65910_RTC_INTERRUPTS, &int_val); - if (ret < 0) - return ret; - - if (int_val & TPS65910_RTC_INTERRUPTS_IT_ALARM) - alm->enabled = 1; - - return ret; -} - -static int tps65910_rtc_set_alarm(struct device *dev, struct rtc_wkalrm *alm) -{ - unsigned char alarm_data[NUM_TIME_REGS]; - struct tps65910 *tps = dev_get_drvdata(dev->parent); - int ret; - - ret = tps65910_rtc_alarm_irq_enable(dev, 0); - if (ret) - return ret; - - alarm_data[0] = bin2bcd(alm->time.tm_sec); - alarm_data[1] = bin2bcd(alm->time.tm_min); - alarm_data[2] = bin2bcd(alm->time.tm_hour); - alarm_data[3] = bin2bcd(alm->time.tm_mday); - alarm_data[4] = bin2bcd(alm->time.tm_mon + 1); - alarm_data[5] = bin2bcd(alm->time.tm_year - 100); - - /* update all the alarm registers in one shot */ - ret = regmap_bulk_write(tps->regmap, TPS65910_ALARM_SECONDS, - alarm_data, NUM_TIME_REGS); - if (ret) { - dev_err(dev, "rtc_set_alarm error %d\n", ret); - return ret; - } - - if (alm->enabled) - ret = tps65910_rtc_alarm_irq_enable(dev, 1); - - return ret; -} - -static irqreturn_t tps65910_rtc_interrupt(int irq, void *rtc) -{ - struct device *dev = rtc; - unsigned long events = 0; - struct tps65910 *tps = dev_get_drvdata(dev->parent); - struct tps65910_rtc *tps_rtc = dev_get_drvdata(dev); - int ret; - u32 rtc_reg; - - ret = regmap_read(tps->regmap, TPS65910_RTC_STATUS, &rtc_reg); - if (ret) - return IRQ_NONE; - - if (rtc_reg & TPS65910_RTC_STATUS_ALARM) - events = RTC_IRQF | RTC_AF; - - ret = regmap_write(tps->regmap, TPS65910_RTC_STATUS, rtc_reg); - if (ret) - return IRQ_NONE; - - /* Notify RTC core on event */ - rtc_update_irq(tps_rtc->rtc, 1, events); - - return IRQ_HANDLED; -} - -static const struct rtc_class_ops tps65910_rtc_ops = { - .read_time = tps65910_rtc_read_time, - .set_time = tps65910_rtc_set_time, - .read_alarm = tps65910_rtc_read_alarm, - .set_alarm = tps65910_rtc_set_alarm, - .alarm_irq_enable = tps65910_rtc_alarm_irq_enable, -}; - -static int __devinit tps65910_rtc_probe(struct platform_device *pdev) -{ - struct tps65910 *tps65910 = NULL; - struct tps65910_rtc *tps_rtc = NULL; - int ret; - int irq; - u32 rtc_reg; - - tps65910 = dev_get_drvdata(pdev->dev.parent); - - tps_rtc = devm_kzalloc(&pdev->dev, sizeof(struct tps65910_rtc), - GFP_KERNEL); - if (!tps_rtc) - return -ENOMEM; - - /* Clear pending interrupts */ - ret = regmap_read(tps65910->regmap, TPS65910_RTC_STATUS, &rtc_reg); - if (ret < 0) - return ret; - - ret = regmap_write(tps65910->regmap, TPS65910_RTC_STATUS, rtc_reg); - if (ret < 0) - return ret; - - dev_dbg(&pdev->dev, "Enabling rtc-tps65910.\n"); - rtc_reg = TPS65910_RTC_CTRL_STOP_RTC; - ret = regmap_write(tps65910->regmap, TPS65910_RTC_CTRL, rtc_reg); - if (ret < 0) - return ret; - - irq = platform_get_irq(pdev, 0); - if (irq <= 0) { - dev_warn(&pdev->dev, "Wake up is not possible as irq = %d\n", - irq); - return ret; - } - - ret = devm_request_threaded_irq(&pdev->dev, irq, NULL, - tps65910_rtc_interrupt, IRQF_TRIGGER_LOW, - "rtc-tps65910", &pdev->dev); - if (ret < 0) { - dev_err(&pdev->dev, "IRQ is not free.\n"); - return ret; - } - device_init_wakeup(&pdev->dev, 1); - - tps_rtc->rtc = rtc_device_register(pdev->name, &pdev->dev, - &tps65910_rtc_ops, THIS_MODULE); - if (IS_ERR(tps_rtc->rtc)) { - ret = PTR_ERR(tps_rtc->rtc); - dev_err(&pdev->dev, "RTC device register: err %d\n", ret); - return ret; - } - - platform_set_drvdata(pdev, tps_rtc); - - return 0; -} - -/* - * Disable tps65910 RTC interrupts. - * Sets status flag to free. - */ -static int __devexit tps65910_rtc_remove(struct platform_device *pdev) -{ - /* leave rtc running, but disable irqs */ - struct rtc_device *rtc = platform_get_drvdata(pdev); - - tps65910_rtc_alarm_irq_enable(&rtc->dev, 0); - - rtc_device_unregister(rtc); - return 0; -} - -#ifdef CONFIG_PM_SLEEP - -static int tps65910_rtc_suspend(struct device *dev) -{ - struct tps65910 *tps = dev_get_drvdata(dev->parent); - u8 alarm = TPS65910_RTC_INTERRUPTS_IT_ALARM; - int ret; - - /* Store current list of enabled interrupts*/ - ret = regmap_read(tps->regmap, TPS65910_RTC_INTERRUPTS, - &tps->rtc->irqstat); - if (ret < 0) - return ret; - - /* Enable RTC ALARM interrupt only */ - return regmap_write(tps->regmap, TPS65910_RTC_INTERRUPTS, alarm); -} - -static int tps65910_rtc_resume(struct device *dev) -{ - struct tps65910 *tps = dev_get_drvdata(dev->parent); - - /* Restore list of enabled interrupts before suspend */ - return regmap_write(tps->regmap, TPS65910_RTC_INTERRUPTS, - tps->rtc->irqstat); -} - -static const struct dev_pm_ops tps65910_rtc_pm_ops = { - .suspend = tps65910_rtc_suspend, - .resume = tps65910_rtc_resume, -}; - -#define DEV_PM_OPS (&tps65910_rtc_pm_ops) -#else -#define DEV_PM_OPS NULL -#endif - -static struct platform_driver tps65910_rtc_driver = { - .probe = tps65910_rtc_probe, - .remove = __devexit_p(tps65910_rtc_remove), - .driver = { - .owner = THIS_MODULE, - .name = "tps65910-rtc", - .pm = DEV_PM_OPS, - }, -}; - -module_platform_driver(tps65910_rtc_driver); -MODULE_ALIAS("platform:rtc-tps65910"); -MODULE_AUTHOR("Venu Byravarasu "); -MODULE_LICENSE("GPL"); diff --git a/trunk/drivers/rtc/rtc-x1205.c b/trunk/drivers/rtc/rtc-x1205.c index f36e59c6bc01..403b3d41d101 100644 --- a/trunk/drivers/rtc/rtc-x1205.c +++ b/trunk/drivers/rtc/rtc-x1205.c @@ -97,17 +97,8 @@ static int x1205_get_datetime(struct i2c_client *client, struct rtc_time *tm, int i; struct i2c_msg msgs[] = { - {/* setup read ptr */ - .addr = client->addr, - .len = 2, - .buf = dt_addr - }, - {/* read date */ - .addr = client->addr, - .flags = I2C_M_RD, - .len = 8, - .buf = buf - }, + { client->addr, 0, 2, dt_addr }, /* setup read ptr */ + { client->addr, I2C_M_RD, 8, buf }, /* read date */ }; /* read date registers */ @@ -151,17 +142,8 @@ static int x1205_get_status(struct i2c_client *client, unsigned char *sr) static unsigned char sr_addr[2] = { 0, X1205_REG_SR }; struct i2c_msg msgs[] = { - { /* setup read ptr */ - .addr = client->addr, - .len = 2, - .buf = sr_addr - }, - { /* read status */ - .addr = client->addr, - .flags = I2C_M_RD, - .len = 1, - .buf = sr - }, + { client->addr, 0, 2, sr_addr }, /* setup read ptr */ + { client->addr, I2C_M_RD, 1, sr }, /* read status */ }; /* read status register */ @@ -297,17 +279,8 @@ static int x1205_get_dtrim(struct i2c_client *client, int *trim) static unsigned char dtr_addr[2] = { 0, X1205_REG_DTR }; struct i2c_msg msgs[] = { - { /* setup read ptr */ - .addr = client->addr, - .len = 2, - .buf = dtr_addr - }, - { /* read dtr */ - .addr = client->addr, - .flags = I2C_M_RD, - .len = 1, - .buf = &dtr - }, + { client->addr, 0, 2, dtr_addr }, /* setup read ptr */ + { client->addr, I2C_M_RD, 1, &dtr }, /* read dtr */ }; /* read dtr register */ @@ -338,17 +311,8 @@ static int x1205_get_atrim(struct i2c_client *client, int *trim) static unsigned char atr_addr[2] = { 0, X1205_REG_ATR }; struct i2c_msg msgs[] = { - {/* setup read ptr */ - .addr = client->addr, - .len = 2, - .buf = atr_addr - }, - {/* read atr */ - .addr = client->addr, - .flags = I2C_M_RD, - .len = 1, - .buf = &atr - }, + { client->addr, 0, 2, atr_addr }, /* setup read ptr */ + { client->addr, I2C_M_RD, 1, &atr }, /* read atr */ }; /* read atr register */ @@ -417,17 +381,8 @@ static int x1205_validate_client(struct i2c_client *client) unsigned char addr[2] = { 0, probe_zero_pattern[i] }; struct i2c_msg msgs[2] = { - { - .addr = client->addr, - .len = 2, - .buf = addr - }, - { - .addr = client->addr, - .flags = I2C_M_RD, - .len = 1, - .buf = &buf - }, + { client->addr, 0, 2, addr }, + { client->addr, I2C_M_RD, 1, &buf }, }; if ((xfer = i2c_transfer(client->adapter, msgs, 2)) != 2) { @@ -454,17 +409,8 @@ static int x1205_validate_client(struct i2c_client *client) unsigned char addr[2] = { 0, probe_limits_pattern[i].reg }; struct i2c_msg msgs[2] = { - { - .addr = client->addr, - .len = 2, - .buf = addr - }, - { - .addr = client->addr, - .flags = I2C_M_RD, - .len = 1, - .buf = ® - }, + { client->addr, 0, 2, addr }, + { client->addr, I2C_M_RD, 1, ® }, }; if ((xfer = i2c_transfer(client->adapter, msgs, 2)) != 2) { @@ -498,18 +444,8 @@ static int x1205_rtc_read_alarm(struct device *dev, struct rtc_wkalrm *alrm) static unsigned char int_addr[2] = { 0, X1205_REG_INT }; struct i2c_client *client = to_i2c_client(dev); struct i2c_msg msgs[] = { - { /* setup read ptr */ - .addr = client->addr, - .len = 2, - .buf = int_addr - }, - {/* read INT register */ - - .addr = client->addr, - .flags = I2C_M_RD, - .len = 1, - .buf = &intreg - }, + { client->addr, 0, 2, int_addr }, /* setup read ptr */ + { client->addr, I2C_M_RD, 1, &intreg }, /* read INT register */ }; /* read interrupt register and status register */ diff --git a/trunk/drivers/scsi/aacraid/linit.c b/trunk/drivers/scsi/aacraid/linit.c index cb7f1582a6d1..7199534cd07d 100644 --- a/trunk/drivers/scsi/aacraid/linit.c +++ b/trunk/drivers/scsi/aacraid/linit.c @@ -93,7 +93,7 @@ static DECLARE_PCI_DEVICE_TABLE(aac_pci_tbl) = { #elif defined(__devinitconst) static const struct pci_device_id aac_pci_tbl[] __devinitconst = { #else -static const struct pci_device_id aac_pci_tbl[] __devinitconst = { +static const struct pci_device_id aac_pci_tbl[] __devinitdata = { #endif { 0x1028, 0x0001, 0x1028, 0x0001, 0, 0, 0 }, /* PERC 2/Si (Iguana/PERC2Si) */ { 0x1028, 0x0002, 0x1028, 0x0002, 0, 0, 1 }, /* PERC 3/Di (Opal/PERC3Di) */ diff --git a/trunk/drivers/scsi/aic94xx/aic94xx_init.c b/trunk/drivers/scsi/aic94xx/aic94xx_init.c index 1c4120c3db41..ff80552ead84 100644 --- a/trunk/drivers/scsi/aic94xx/aic94xx_init.c +++ b/trunk/drivers/scsi/aic94xx/aic94xx_init.c @@ -1012,7 +1012,7 @@ static struct sas_domain_function_template aic94xx_transport_functions = { .lldd_ata_set_dmamode = asd_set_dmamode, }; -static const struct pci_device_id aic94xx_pci_table[] __devinitconst = { +static const struct pci_device_id aic94xx_pci_table[] __devinitdata = { {PCI_DEVICE(PCI_VENDOR_ID_ADAPTEC2, 0x410),0, 0, 1}, {PCI_DEVICE(PCI_VENDOR_ID_ADAPTEC2, 0x412),0, 0, 1}, {PCI_DEVICE(PCI_VENDOR_ID_ADAPTEC2, 0x416),0, 0, 1}, diff --git a/trunk/drivers/scsi/atp870u.c b/trunk/drivers/scsi/atp870u.c index a540162ac59c..68ce08552f69 100644 --- a/trunk/drivers/scsi/atp870u.c +++ b/trunk/drivers/scsi/atp870u.c @@ -1173,16 +1173,7 @@ static void tscam(struct Scsi_Host *host) outw(val, tmport); outb(2, 0x80); TCM_SYNC: - /* - * The funny division into multiple delays is to accomodate - * arches like ARM where udelay() multiplies its argument by - * a large number to initialize a loop counter. To avoid - * overflow, the maximum supported udelay is 2000 microseconds. - * - * XXX it would be more polite to find a way to use msleep() - */ - mdelay(2); - udelay(48); + udelay(0x800); if ((inb(tmport) & 0x80) == 0x00) { /* bsy ? */ outw(0, tmport--); outb(0, tmport); diff --git a/trunk/drivers/scsi/ipr.c b/trunk/drivers/scsi/ipr.c index fe6029f4df16..e3f29f61cbc3 100644 --- a/trunk/drivers/scsi/ipr.c +++ b/trunk/drivers/scsi/ipr.c @@ -6373,14 +6373,14 @@ static struct ata_port_info sata_port_info = { #ifdef CONFIG_PPC_PSERIES static const u16 ipr_blocked_processors[] = { - PVR_NORTHSTAR, - PVR_PULSAR, - PVR_POWER4, - PVR_ICESTAR, - PVR_SSTAR, - PVR_POWER4p, - PVR_630, - PVR_630p + PV_NORTHSTAR, + PV_PULSAR, + PV_POWER4, + PV_ICESTAR, + PV_SSTAR, + PV_POWER4p, + PV_630, + PV_630p }; /** @@ -6400,7 +6400,7 @@ static int ipr_invalid_adapter(struct ipr_ioa_cfg *ioa_cfg) if ((ioa_cfg->type == 0x5702) && (ioa_cfg->pdev->revision < 4)) { for (i = 0; i < ARRAY_SIZE(ipr_blocked_processors); i++) { - if (pvr_version_is(ipr_blocked_processors[i])) + if (__is_processor(ipr_blocked_processors[i])) return 1; } } diff --git a/trunk/drivers/thermal/thermal_sys.c b/trunk/drivers/thermal/thermal_sys.c index efd81bb25e01..67789b8345d2 100644 --- a/trunk/drivers/thermal/thermal_sys.c +++ b/trunk/drivers/thermal/thermal_sys.c @@ -78,7 +78,7 @@ static int get_idr(struct idr *idr, struct mutex *lock, int *id) else if (unlikely(err)) return err; - *id = *id & MAX_IDR_MASK; + *id = *id & MAX_ID_MASK; return 0; } diff --git a/trunk/drivers/tty/hvc/hvc_console.c b/trunk/drivers/tty/hvc/hvc_console.c index a5dec1ca1b82..4a652999380f 100644 --- a/trunk/drivers/tty/hvc/hvc_console.c +++ b/trunk/drivers/tty/hvc/hvc_console.c @@ -245,20 +245,6 @@ static void hvc_port_destruct(struct tty_port *port) kfree(hp); } -static void hvc_check_console(int index) -{ - /* Already enabled, bail out */ - if (hvc_console.flags & CON_ENABLED) - return; - - /* If this index is what the user requested, then register - * now (setup won't fail at this point). It's ok to just - * call register again if previously .setup failed. - */ - if (index == hvc_console.index) - register_console(&hvc_console); -} - /* * hvc_instantiate() is an early console discovery method which locates * consoles * prior to the vio subsystem discovering them. Hotplugged @@ -289,8 +275,12 @@ int hvc_instantiate(uint32_t vtermno, int index, const struct hv_ops *ops) if (last_hvc < index) last_hvc = index; - /* check if we need to re-register the kernel console */ - hvc_check_console(index); + /* if this index is what the user requested, then register + * now (setup won't fail at this point). It's ok to just + * call register again if previously .setup failed. + */ + if (index == hvc_console.index) + register_console(&hvc_console); return 0; } @@ -887,15 +877,10 @@ struct hvc_struct *hvc_alloc(uint32_t vtermno, int data, i = ++last_hvc; hp->index = i; - cons_ops[i] = ops; - vtermnos[i] = vtermno; list_add_tail(&(hp->next), &hvc_structs); spin_unlock(&hvc_structs_lock); - /* check if we need to re-register the kernel console */ - hvc_check_console(i); - return hp; } EXPORT_SYMBOL_GPL(hvc_alloc); @@ -908,12 +893,8 @@ int hvc_remove(struct hvc_struct *hp) tty = tty_port_tty_get(&hp->port); spin_lock_irqsave(&hp->lock, flags); - if (hp->index < MAX_NR_HVC_CONSOLES) { - console_lock(); + if (hp->index < MAX_NR_HVC_CONSOLES) vtermnos[hp->index] = -1; - cons_ops[hp->index] = NULL; - console_unlock(); - } /* Don't whack hp->irq because tty_hangup() will need to free the irq. */ diff --git a/trunk/drivers/tty/hvc/hvc_vio.c b/trunk/drivers/tty/hvc/hvc_vio.c index 070c0ee68642..ee307799271a 100644 --- a/trunk/drivers/tty/hvc/hvc_vio.c +++ b/trunk/drivers/tty/hvc/hvc_vio.c @@ -230,69 +230,6 @@ static const struct hv_ops hvterm_hvsi_ops = { .tiocmset = hvterm_hvsi_tiocmset, }; -static void udbg_hvc_putc(char c) -{ - int count = -1; - - if (!hvterm_privs[0]) - return; - - if (c == '\n') - udbg_hvc_putc('\r'); - - do { - switch(hvterm_privs[0]->proto) { - case HV_PROTOCOL_RAW: - count = hvterm_raw_put_chars(0, &c, 1); - break; - case HV_PROTOCOL_HVSI: - count = hvterm_hvsi_put_chars(0, &c, 1); - break; - } - } while(count == 0); -} - -static int udbg_hvc_getc_poll(void) -{ - int rc = 0; - char c; - - if (!hvterm_privs[0]) - return -1; - - switch(hvterm_privs[0]->proto) { - case HV_PROTOCOL_RAW: - rc = hvterm_raw_get_chars(0, &c, 1); - break; - case HV_PROTOCOL_HVSI: - rc = hvterm_hvsi_get_chars(0, &c, 1); - break; - } - if (!rc) - return -1; - return c; -} - -static int udbg_hvc_getc(void) -{ - int ch; - - if (!hvterm_privs[0]) - return -1; - - for (;;) { - ch = udbg_hvc_getc_poll(); - if (ch == -1) { - /* This shouldn't be needed...but... */ - volatile unsigned long delay; - for (delay=0; delay < 2000000; delay++) - ; - } else { - return ch; - } - } -} - static int __devinit hvc_vio_probe(struct vio_dev *vdev, const struct vio_device_id *id) { @@ -352,13 +289,6 @@ static int __devinit hvc_vio_probe(struct vio_dev *vdev, return PTR_ERR(hp); dev_set_drvdata(&vdev->dev, hp); - /* register udbg if it's not there already for console 0 */ - if (hp->index == 0 && !udbg_putc) { - udbg_putc = udbg_hvc_putc; - udbg_getc = udbg_hvc_getc; - udbg_getc_poll = udbg_hvc_getc_poll; - } - return 0; } @@ -401,6 +331,59 @@ static void __exit hvc_vio_exit(void) } module_exit(hvc_vio_exit); +static void udbg_hvc_putc(char c) +{ + int count = -1; + + if (c == '\n') + udbg_hvc_putc('\r'); + + do { + switch(hvterm_priv0.proto) { + case HV_PROTOCOL_RAW: + count = hvterm_raw_put_chars(0, &c, 1); + break; + case HV_PROTOCOL_HVSI: + count = hvterm_hvsi_put_chars(0, &c, 1); + break; + } + } while(count == 0); +} + +static int udbg_hvc_getc_poll(void) +{ + int rc = 0; + char c; + + switch(hvterm_priv0.proto) { + case HV_PROTOCOL_RAW: + rc = hvterm_raw_get_chars(0, &c, 1); + break; + case HV_PROTOCOL_HVSI: + rc = hvterm_hvsi_get_chars(0, &c, 1); + break; + } + if (!rc) + return -1; + return c; +} + +static int udbg_hvc_getc(void) +{ + int ch; + for (;;) { + ch = udbg_hvc_getc_poll(); + if (ch == -1) { + /* This shouldn't be needed...but... */ + volatile unsigned long delay; + for (delay=0; delay < 2000000; delay++) + ; + } else { + return ch; + } + } +} + void __init hvc_vio_init_early(void) { struct device_node *stdout_node; diff --git a/trunk/drivers/video/aty/aty128fb.c b/trunk/drivers/video/aty/aty128fb.c index 0fefa84ed9ae..747442d2c0f6 100644 --- a/trunk/drivers/video/aty/aty128fb.c +++ b/trunk/drivers/video/aty/aty128fb.c @@ -149,7 +149,7 @@ enum { }; /* Must match above enum */ -static char * const r128_family[] __devinitconst = { +static const char *r128_family[] __devinitdata = { "AGP", "PCI", "PRO AGP", diff --git a/trunk/drivers/video/backlight/88pm860x_bl.c b/trunk/drivers/video/backlight/88pm860x_bl.c index b7ec34c57f46..f49181c73113 100644 --- a/trunk/drivers/video/backlight/88pm860x_bl.c +++ b/trunk/drivers/video/backlight/88pm860x_bl.c @@ -11,7 +11,6 @@ #include #include -#include #include #include #include @@ -32,26 +31,57 @@ struct pm860x_backlight_data { int port; int pwm; int iset; - int reg_duty_cycle; - int reg_always_on; - int reg_current; }; +static inline int wled_a(int port) +{ + int ret; + + ret = ((port - PM8606_BACKLIGHT1) << 1) + 2; + return ret; +} + +static inline int wled_b(int port) +{ + int ret; + + ret = ((port - PM8606_BACKLIGHT1) << 1) + 3; + return ret; +} + +/* WLED2 & WLED3 share the same IDC */ +static inline int wled_idc(int port) +{ + int ret; + + switch (port) { + case PM8606_BACKLIGHT1: + case PM8606_BACKLIGHT2: + ret = ((port - PM8606_BACKLIGHT1) << 1) + 3; + break; + case PM8606_BACKLIGHT3: + default: + ret = ((port - PM8606_BACKLIGHT2) << 1) + 3; + break; + } + return ret; +} + static int backlight_power_set(struct pm860x_chip *chip, int port, int on) { int ret = -EINVAL; switch (port) { - case 0: + case PM8606_BACKLIGHT1: ret = on ? pm8606_osc_enable(chip, WLED1_DUTY) : pm8606_osc_disable(chip, WLED1_DUTY); break; - case 1: + case PM8606_BACKLIGHT2: ret = on ? pm8606_osc_enable(chip, WLED2_DUTY) : pm8606_osc_disable(chip, WLED2_DUTY); break; - case 2: + case PM8606_BACKLIGHT3: ret = on ? pm8606_osc_enable(chip, WLED3_DUTY) : pm8606_osc_disable(chip, WLED3_DUTY); break; @@ -74,13 +104,13 @@ static int pm860x_backlight_set(struct backlight_device *bl, int brightness) if (brightness) backlight_power_set(chip, data->port, 1); - ret = pm860x_reg_write(data->i2c, data->reg_duty_cycle, value); + ret = pm860x_reg_write(data->i2c, wled_a(data->port), value); if (ret < 0) goto out; if ((data->current_brightness == 0) && brightness) { if (data->iset) { - ret = pm860x_set_bits(data->i2c, data->reg_current, + ret = pm860x_set_bits(data->i2c, wled_idc(data->port), CURRENT_BITMASK, data->iset); if (ret < 0) goto out; @@ -93,17 +123,17 @@ static int pm860x_backlight_set(struct backlight_device *bl, int brightness) } if (brightness == MAX_BRIGHTNESS) { /* set WLED_ON bit as 100% */ - ret = pm860x_set_bits(data->i2c, data->reg_always_on, + ret = pm860x_set_bits(data->i2c, wled_b(data->port), PM8606_WLED_ON, PM8606_WLED_ON); } } else { if (brightness == MAX_BRIGHTNESS) { /* set WLED_ON bit as 100% */ - ret = pm860x_set_bits(data->i2c, data->reg_always_on, + ret = pm860x_set_bits(data->i2c, wled_b(data->port), PM8606_WLED_ON, PM8606_WLED_ON); } else { /* clear WLED_ON bit since it's not 100% */ - ret = pm860x_set_bits(data->i2c, data->reg_always_on, + ret = pm860x_set_bits(data->i2c, wled_b(data->port), PM8606_WLED_ON, 0); } } @@ -144,7 +174,7 @@ static int pm860x_backlight_get_brightness(struct backlight_device *bl) struct pm860x_chip *chip = data->chip; int ret; - ret = pm860x_reg_read(data->i2c, data->reg_duty_cycle); + ret = pm860x_reg_read(data->i2c, wled_a(data->port)); if (ret < 0) goto out; data->current_brightness = ret; @@ -160,85 +190,45 @@ static const struct backlight_ops pm860x_backlight_ops = { .get_brightness = pm860x_backlight_get_brightness, }; -#ifdef CONFIG_OF -static int pm860x_backlight_dt_init(struct platform_device *pdev, - struct pm860x_backlight_data *data, - char *name) -{ - struct device_node *nproot = pdev->dev.parent->of_node, *np; - int iset = 0; - if (!nproot) - return -ENODEV; - nproot = of_find_node_by_name(nproot, "backlights"); - if (!nproot) { - dev_err(&pdev->dev, "failed to find backlights node\n"); - return -ENODEV; - } - for_each_child_of_node(nproot, np) { - if (!of_node_cmp(np->name, name)) { - of_property_read_u32(np, "marvell,88pm860x-iset", - &iset); - data->iset = PM8606_WLED_CURRENT(iset); - of_property_read_u32(np, "marvell,88pm860x-pwm", - &data->pwm); - break; - } - } - return 0; -} -#else -#define pm860x_backlight_dt_init(x, y, z) (-1) -#endif - static int pm860x_backlight_probe(struct platform_device *pdev) { struct pm860x_chip *chip = dev_get_drvdata(pdev->dev.parent); - struct pm860x_backlight_pdata *pdata = pdev->dev.platform_data; + struct pm860x_backlight_pdata *pdata = NULL; struct pm860x_backlight_data *data; struct backlight_device *bl; struct resource *res; struct backlight_properties props; char name[MFD_NAME_SIZE]; - int ret = 0; + int ret; + + res = platform_get_resource(pdev, IORESOURCE_IO, 0); + if (res == NULL) { + dev_err(&pdev->dev, "No I/O resource!\n"); + return -EINVAL; + } + + pdata = pdev->dev.platform_data; + if (pdata == NULL) { + dev_err(&pdev->dev, "platform data isn't assigned to " + "backlight\n"); + return -EINVAL; + } data = devm_kzalloc(&pdev->dev, sizeof(struct pm860x_backlight_data), GFP_KERNEL); if (data == NULL) return -ENOMEM; - res = platform_get_resource_byname(pdev, IORESOURCE_REG, "duty cycle"); - if (!res) { - dev_err(&pdev->dev, "No REG resource for duty cycle\n"); - ret = -ENXIO; - goto out; - } - data->reg_duty_cycle = res->start; - res = platform_get_resource_byname(pdev, IORESOURCE_REG, "always on"); - if (!res) { - dev_err(&pdev->dev, "No REG resorce for always on\n"); - ret = -ENXIO; - goto out; - } - data->reg_always_on = res->start; - res = platform_get_resource_byname(pdev, IORESOURCE_REG, "current"); - if (!res) { - dev_err(&pdev->dev, "No REG resource for current\n"); - ret = -ENXIO; - goto out; - } - data->reg_current = res->start; - - memset(name, 0, MFD_NAME_SIZE); - sprintf(name, "backlight-%d", pdev->id); - data->port = pdev->id; + strncpy(name, res->name, MFD_NAME_SIZE); data->chip = chip; data->i2c = (chip->id == CHIP_PM8606) ? chip->client \ : chip->companion; data->current_brightness = MAX_BRIGHTNESS; - if (pm860x_backlight_dt_init(pdev, data, name)) { - if (pdata) { - data->pwm = pdata->pwm; - data->iset = pdata->iset; - } + data->pwm = pdata->pwm; + data->iset = pdata->iset; + data->port = pdata->flags; + if (data->port < 0) { + dev_err(&pdev->dev, "wrong platform data is assigned"); + return -EINVAL; } memset(&props, 0, sizeof(struct backlight_properties)); @@ -257,14 +247,12 @@ static int pm860x_backlight_probe(struct platform_device *pdev) /* read current backlight */ ret = pm860x_backlight_get_brightness(bl); if (ret < 0) - goto out_brt; + goto out; backlight_update_status(bl); return 0; -out_brt: - backlight_device_unregister(bl); out: - devm_kfree(&pdev->dev, data); + backlight_device_unregister(bl); return ret; } diff --git a/trunk/drivers/video/backlight/Kconfig b/trunk/drivers/video/backlight/Kconfig index c101697a4ba7..cf282763a8dc 100644 --- a/trunk/drivers/video/backlight/Kconfig +++ b/trunk/drivers/video/backlight/Kconfig @@ -229,6 +229,13 @@ config BACKLIGHT_HP700 If you have an HP Jornada 700 series, say Y to include backlight control driver. +config BACKLIGHT_PROGEAR + tristate "Frontpath ProGear Backlight Driver" + depends on PCI && X86 + help + If you have a Frontpath ProGear say Y to enable the + backlight driver. + config BACKLIGHT_CARILLO_RANCH tristate "Intel Carillo Ranch Backlight Driver" depends on LCD_CLASS_DEVICE && PCI && X86 && FB_LE80578 @@ -345,22 +352,6 @@ config BACKLIGHT_AAT2870 If you have a AnalogicTech AAT2870 say Y to enable the backlight driver. -config BACKLIGHT_LM3630 - tristate "Backlight Driver for LM3630" - depends on BACKLIGHT_CLASS_DEVICE && I2C - select REGMAP_I2C - help - This supports TI LM3630 Backlight Driver - -config BACKLIGHT_LM3639 - tristate "Backlight Driver for LM3639" - depends on BACKLIGHT_CLASS_DEVICE && I2C - select REGMAP_I2C - select NEW_LEDS - select LEDS_CLASS - help - This supports TI LM3639 Backlight + 1.5A Flash LED Driver - config BACKLIGHT_LP855X tristate "Backlight driver for TI LP855X" depends on BACKLIGHT_CLASS_DEVICE && I2C @@ -382,13 +373,6 @@ config BACKLIGHT_PANDORA If you have a Pandora console, say Y to enable the backlight driver. -config BACKLIGHT_TPS65217 - tristate "TPS65217 Backlight" - depends on BACKLIGHT_CLASS_DEVICE && MFD_TPS65217 - help - If you have a Texas Instruments TPS65217 say Y to enable the - backlight driver. - endif # BACKLIGHT_CLASS_DEVICE endif # BACKLIGHT_LCD_SUPPORT diff --git a/trunk/drivers/video/backlight/Makefile b/trunk/drivers/video/backlight/Makefile index e7ce7291635d..a2ac9cfbaf6b 100644 --- a/trunk/drivers/video/backlight/Makefile +++ b/trunk/drivers/video/backlight/Makefile @@ -23,11 +23,10 @@ obj-$(CONFIG_BACKLIGHT_HP700) += jornada720_bl.o obj-$(CONFIG_BACKLIGHT_HP680) += hp680_bl.o obj-$(CONFIG_BACKLIGHT_LM3533) += lm3533_bl.o obj-$(CONFIG_BACKLIGHT_LOCOMO) += locomolcd.o -obj-$(CONFIG_BACKLIGHT_LM3630) += lm3630_bl.o -obj-$(CONFIG_BACKLIGHT_LM3639) += lm3639_bl.o obj-$(CONFIG_BACKLIGHT_LP855X) += lp855x_bl.o obj-$(CONFIG_BACKLIGHT_OMAP1) += omap1_bl.o obj-$(CONFIG_BACKLIGHT_PANDORA) += pandora_bl.o +obj-$(CONFIG_BACKLIGHT_PROGEAR) += progear_bl.o obj-$(CONFIG_BACKLIGHT_CARILLO_RANCH) += cr_bllcd.o obj-$(CONFIG_BACKLIGHT_PWM) += pwm_bl.o obj-$(CONFIG_BACKLIGHT_DA903X) += da903x_bl.o @@ -44,4 +43,3 @@ obj-$(CONFIG_BACKLIGHT_88PM860X) += 88pm860x_bl.o obj-$(CONFIG_BACKLIGHT_PCF50633) += pcf50633-backlight.o obj-$(CONFIG_BACKLIGHT_AAT2870) += aat2870_bl.o obj-$(CONFIG_BACKLIGHT_OT200) += ot200_bl.o -obj-$(CONFIG_BACKLIGHT_TPS65217) += tps65217_bl.o diff --git a/trunk/drivers/video/backlight/da9052_bl.c b/trunk/drivers/video/backlight/da9052_bl.c index ac196181fe45..b628d68f5162 100644 --- a/trunk/drivers/video/backlight/da9052_bl.c +++ b/trunk/drivers/video/backlight/da9052_bl.c @@ -72,7 +72,7 @@ static int da9052_adjust_wled_brightness(struct da9052_bl *wleds) if (ret < 0) return ret; - usleep_range(10000, 11000); + msleep(10); if (wleds->brightness) { ret = da9052_reg_write(wleds->da9052, wled_bank[wleds->led_reg], @@ -129,6 +129,7 @@ static int da9052_backlight_probe(struct platform_device *pdev) &da9052_backlight_ops, &props); if (IS_ERR(bl)) { dev_err(&pdev->dev, "Failed to register backlight\n"); + devm_kfree(&pdev->dev, wleds); return PTR_ERR(bl); } @@ -148,6 +149,7 @@ static int da9052_backlight_remove(struct platform_device *pdev) wleds->state = DA9052_WLEDS_OFF; da9052_adjust_wled_brightness(wleds); backlight_device_unregister(bl); + devm_kfree(&pdev->dev, wleds); return 0; } diff --git a/trunk/drivers/video/backlight/kb3886_bl.c b/trunk/drivers/video/backlight/kb3886_bl.c index 6c5ed6b242cc..72dd5556a35b 100644 --- a/trunk/drivers/video/backlight/kb3886_bl.c +++ b/trunk/drivers/video/backlight/kb3886_bl.c @@ -34,9 +34,9 @@ static void kb3886_bl_set_intensity(int intensity) mutex_lock(&bl_mutex); intensity = intensity&0xff; outb(KB3886_ADC_DAC_PWM, KB3886_PARENT); - usleep_range(10000, 11000); + msleep(10); outb(KB3886_PWM0_WRITE, KB3886_IO); - usleep_range(10000, 11000); + msleep(10); outb(intensity, KB3886_IO); mutex_unlock(&bl_mutex); } diff --git a/trunk/drivers/video/backlight/lm3630_bl.c b/trunk/drivers/video/backlight/lm3630_bl.c deleted file mode 100644 index dc191441796f..000000000000 --- a/trunk/drivers/video/backlight/lm3630_bl.c +++ /dev/null @@ -1,475 +0,0 @@ -/* -* Simple driver for Texas Instruments LM3630 Backlight driver chip -* Copyright (C) 2012 Texas Instruments -* -* 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 -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#define REG_CTRL 0x00 -#define REG_CONFIG 0x01 -#define REG_BRT_A 0x03 -#define REG_BRT_B 0x04 -#define REG_INT_STATUS 0x09 -#define REG_INT_EN 0x0A -#define REG_FAULT 0x0B -#define REG_PWM_OUTLOW 0x12 -#define REG_PWM_OUTHIGH 0x13 -#define REG_MAX 0x1F - -#define INT_DEBOUNCE_MSEC 10 - -enum lm3630_leds { - BLED_ALL = 0, - BLED_1, - BLED_2 -}; - -static const char *bled_name[] = { - [BLED_ALL] = "lm3630_bled", /*Bank1 controls all string */ - [BLED_1] = "lm3630_bled1", /*Bank1 controls bled1 */ - [BLED_2] = "lm3630_bled2", /*Bank1 or 2 controls bled2 */ -}; - -struct lm3630_chip_data { - struct device *dev; - struct delayed_work work; - int irq; - struct workqueue_struct *irqthread; - struct lm3630_platform_data *pdata; - struct backlight_device *bled1; - struct backlight_device *bled2; - struct regmap *regmap; -}; - -/* initialize chip */ -static int __devinit lm3630_chip_init(struct lm3630_chip_data *pchip) -{ - int ret; - unsigned int reg_val; - struct lm3630_platform_data *pdata = pchip->pdata; - - /*pwm control */ - reg_val = ((pdata->pwm_active & 0x01) << 2) | (pdata->pwm_ctrl & 0x03); - ret = regmap_update_bits(pchip->regmap, REG_CONFIG, 0x07, reg_val); - if (ret < 0) - goto out; - - /* bank control */ - reg_val = ((pdata->bank_b_ctrl & 0x01) << 1) | - (pdata->bank_a_ctrl & 0x07); - ret = regmap_update_bits(pchip->regmap, REG_CTRL, 0x07, reg_val); - if (ret < 0) - goto out; - - ret = regmap_update_bits(pchip->regmap, REG_CTRL, 0x80, 0x00); - if (ret < 0) - goto out; - - /* set initial brightness */ - if (pdata->bank_a_ctrl != BANK_A_CTRL_DISABLE) { - ret = regmap_write(pchip->regmap, - REG_BRT_A, pdata->init_brt_led1); - if (ret < 0) - goto out; - } - - if (pdata->bank_b_ctrl != BANK_B_CTRL_DISABLE) { - ret = regmap_write(pchip->regmap, - REG_BRT_B, pdata->init_brt_led2); - if (ret < 0) - goto out; - } - return ret; - -out: - dev_err(pchip->dev, "i2c failed to access register\n"); - return ret; -} - -/* interrupt handling */ -static void lm3630_delayed_func(struct work_struct *work) -{ - int ret; - unsigned int reg_val; - struct lm3630_chip_data *pchip; - - pchip = container_of(work, struct lm3630_chip_data, work.work); - - ret = regmap_read(pchip->regmap, REG_INT_STATUS, ®_val); - if (ret < 0) { - dev_err(pchip->dev, - "i2c failed to access REG_INT_STATUS Register\n"); - return; - } - - dev_info(pchip->dev, "REG_INT_STATUS Register is 0x%x\n", reg_val); -} - -static irqreturn_t lm3630_isr_func(int irq, void *chip) -{ - int ret; - struct lm3630_chip_data *pchip = chip; - unsigned long delay = msecs_to_jiffies(INT_DEBOUNCE_MSEC); - - queue_delayed_work(pchip->irqthread, &pchip->work, delay); - - ret = regmap_update_bits(pchip->regmap, REG_CTRL, 0x80, 0x00); - if (ret < 0) - goto out; - - return IRQ_HANDLED; -out: - dev_err(pchip->dev, "i2c failed to access register\n"); - return IRQ_HANDLED; -} - -static int lm3630_intr_config(struct lm3630_chip_data *pchip) -{ - INIT_DELAYED_WORK(&pchip->work, lm3630_delayed_func); - pchip->irqthread = create_singlethread_workqueue("lm3630-irqthd"); - if (!pchip->irqthread) { - dev_err(pchip->dev, "create irq thread fail...\n"); - return -1; - } - if (request_threaded_irq - (pchip->irq, NULL, lm3630_isr_func, - IRQF_TRIGGER_FALLING | IRQF_ONESHOT, "lm3630_irq", pchip)) { - dev_err(pchip->dev, "request threaded irq fail..\n"); - return -1; - } - return 0; -} - -static bool -set_intensity(struct backlight_device *bl, struct lm3630_chip_data *pchip) -{ - if (!pchip->pdata->pwm_set_intensity) - return false; - pchip->pdata->pwm_set_intensity(bl->props.brightness - 1, - pchip->pdata->pwm_period); - return true; -} - -/* update and get brightness */ -static int lm3630_bank_a_update_status(struct backlight_device *bl) -{ - int ret; - struct lm3630_chip_data *pchip = bl_get_data(bl); - enum lm3630_pwm_ctrl pwm_ctrl = pchip->pdata->pwm_ctrl; - - /* brightness 0 means disable */ - if (!bl->props.brightness) { - ret = regmap_update_bits(pchip->regmap, REG_CTRL, 0x04, 0x00); - if (ret < 0) - goto out; - return bl->props.brightness; - } - - /* pwm control */ - if (pwm_ctrl == PWM_CTRL_BANK_A || pwm_ctrl == PWM_CTRL_BANK_ALL) { - if (!set_intensity(bl, pchip)) - dev_err(pchip->dev, "No pwm control func. in plat-data\n"); - } else { - - /* i2c control */ - ret = regmap_update_bits(pchip->regmap, REG_CTRL, 0x80, 0x00); - if (ret < 0) - goto out; - mdelay(1); - ret = regmap_write(pchip->regmap, - REG_BRT_A, bl->props.brightness - 1); - if (ret < 0) - goto out; - } - return bl->props.brightness; -out: - dev_err(pchip->dev, "i2c failed to access REG_CTRL\n"); - return bl->props.brightness; -} - -static int lm3630_bank_a_get_brightness(struct backlight_device *bl) -{ - unsigned int reg_val; - int brightness, ret; - struct lm3630_chip_data *pchip = bl_get_data(bl); - enum lm3630_pwm_ctrl pwm_ctrl = pchip->pdata->pwm_ctrl; - - if (pwm_ctrl == PWM_CTRL_BANK_A || pwm_ctrl == PWM_CTRL_BANK_ALL) { - ret = regmap_read(pchip->regmap, REG_PWM_OUTHIGH, ®_val); - if (ret < 0) - goto out; - brightness = reg_val & 0x01; - ret = regmap_read(pchip->regmap, REG_PWM_OUTLOW, ®_val); - if (ret < 0) - goto out; - brightness = ((brightness << 8) | reg_val) + 1; - } else { - ret = regmap_update_bits(pchip->regmap, REG_CTRL, 0x80, 0x00); - if (ret < 0) - goto out; - mdelay(1); - ret = regmap_read(pchip->regmap, REG_BRT_A, ®_val); - if (ret < 0) - goto out; - brightness = reg_val + 1; - } - bl->props.brightness = brightness; - return bl->props.brightness; -out: - dev_err(pchip->dev, "i2c failed to access register\n"); - return 0; -} - -static const struct backlight_ops lm3630_bank_a_ops = { - .options = BL_CORE_SUSPENDRESUME, - .update_status = lm3630_bank_a_update_status, - .get_brightness = lm3630_bank_a_get_brightness, -}; - -static int lm3630_bank_b_update_status(struct backlight_device *bl) -{ - int ret; - struct lm3630_chip_data *pchip = bl_get_data(bl); - enum lm3630_pwm_ctrl pwm_ctrl = pchip->pdata->pwm_ctrl; - - if (pwm_ctrl == PWM_CTRL_BANK_B || pwm_ctrl == PWM_CTRL_BANK_ALL) { - if (!set_intensity(bl, pchip)) - dev_err(pchip->dev, - "no pwm control func. in plat-data\n"); - } else { - ret = regmap_update_bits(pchip->regmap, REG_CTRL, 0x80, 0x00); - if (ret < 0) - goto out; - mdelay(1); - ret = regmap_write(pchip->regmap, - REG_BRT_B, bl->props.brightness - 1); - } - return bl->props.brightness; -out: - dev_err(pchip->dev, "i2c failed to access register\n"); - return bl->props.brightness; -} - -static int lm3630_bank_b_get_brightness(struct backlight_device *bl) -{ - unsigned int reg_val; - int brightness, ret; - struct lm3630_chip_data *pchip = bl_get_data(bl); - enum lm3630_pwm_ctrl pwm_ctrl = pchip->pdata->pwm_ctrl; - - if (pwm_ctrl == PWM_CTRL_BANK_B || pwm_ctrl == PWM_CTRL_BANK_ALL) { - ret = regmap_read(pchip->regmap, REG_PWM_OUTHIGH, ®_val); - if (ret < 0) - goto out; - brightness = reg_val & 0x01; - ret = regmap_read(pchip->regmap, REG_PWM_OUTLOW, ®_val); - if (ret < 0) - goto out; - brightness = ((brightness << 8) | reg_val) + 1; - } else { - ret = regmap_update_bits(pchip->regmap, REG_CTRL, 0x80, 0x00); - if (ret < 0) - goto out; - mdelay(1); - ret = regmap_read(pchip->regmap, REG_BRT_B, ®_val); - if (ret < 0) - goto out; - brightness = reg_val + 1; - } - bl->props.brightness = brightness; - - return bl->props.brightness; -out: - dev_err(pchip->dev, "i2c failed to access register\n"); - return bl->props.brightness; -} - -static const struct backlight_ops lm3630_bank_b_ops = { - .options = BL_CORE_SUSPENDRESUME, - .update_status = lm3630_bank_b_update_status, - .get_brightness = lm3630_bank_b_get_brightness, -}; - -static int lm3630_backlight_register(struct lm3630_chip_data *pchip, - enum lm3630_leds ledno) -{ - const char *name = bled_name[ledno]; - struct backlight_properties props; - struct lm3630_platform_data *pdata = pchip->pdata; - - props.type = BACKLIGHT_RAW; - switch (ledno) { - case BLED_1: - case BLED_ALL: - props.brightness = pdata->init_brt_led1; - props.max_brightness = pdata->max_brt_led1; - pchip->bled1 = - backlight_device_register(name, pchip->dev, pchip, - &lm3630_bank_a_ops, &props); - if (IS_ERR(pchip->bled1)) - return -EIO; - break; - case BLED_2: - props.brightness = pdata->init_brt_led2; - props.max_brightness = pdata->max_brt_led2; - pchip->bled2 = - backlight_device_register(name, pchip->dev, pchip, - &lm3630_bank_b_ops, &props); - if (IS_ERR(pchip->bled2)) - return -EIO; - break; - } - return 0; -} - -static void lm3630_backlight_unregister(struct lm3630_chip_data *pchip) -{ - if (pchip->bled1) - backlight_device_unregister(pchip->bled1); - if (pchip->bled2) - backlight_device_unregister(pchip->bled2); -} - -static const struct regmap_config lm3630_regmap = { - .reg_bits = 8, - .val_bits = 8, - .max_register = REG_MAX, -}; - -static int __devinit lm3630_probe(struct i2c_client *client, - const struct i2c_device_id *id) -{ - struct lm3630_platform_data *pdata = client->dev.platform_data; - struct lm3630_chip_data *pchip; - int ret; - - if (!i2c_check_functionality(client->adapter, I2C_FUNC_I2C)) { - dev_err(&client->dev, "fail : i2c functionality check...\n"); - return -EOPNOTSUPP; - } - - if (pdata == NULL) { - dev_err(&client->dev, "fail : no platform data.\n"); - return -ENODATA; - } - - pchip = devm_kzalloc(&client->dev, sizeof(struct lm3630_chip_data), - GFP_KERNEL); - if (!pchip) - return -ENOMEM; - pchip->pdata = pdata; - pchip->dev = &client->dev; - - pchip->regmap = devm_regmap_init_i2c(client, &lm3630_regmap); - if (IS_ERR(pchip->regmap)) { - ret = PTR_ERR(pchip->regmap); - dev_err(&client->dev, "fail : allocate register map: %d\n", - ret); - return ret; - } - i2c_set_clientdata(client, pchip); - - /* chip initialize */ - ret = lm3630_chip_init(pchip); - if (ret < 0) { - dev_err(&client->dev, "fail : init chip\n"); - goto err_chip_init; - } - - switch (pdata->bank_a_ctrl) { - case BANK_A_CTRL_ALL: - ret = lm3630_backlight_register(pchip, BLED_ALL); - pdata->bank_b_ctrl = BANK_B_CTRL_DISABLE; - break; - case BANK_A_CTRL_LED1: - ret = lm3630_backlight_register(pchip, BLED_1); - break; - case BANK_A_CTRL_LED2: - ret = lm3630_backlight_register(pchip, BLED_2); - pdata->bank_b_ctrl = BANK_B_CTRL_DISABLE; - break; - default: - break; - } - - if (ret < 0) - goto err_bl_reg; - - if (pdata->bank_b_ctrl && pchip->bled2 == NULL) { - ret = lm3630_backlight_register(pchip, BLED_2); - if (ret < 0) - goto err_bl_reg; - } - - /* interrupt enable : irq 0 is not allowed for lm3630 */ - pchip->irq = client->irq; - if (pchip->irq) - lm3630_intr_config(pchip); - - dev_info(&client->dev, "LM3630 backlight register OK.\n"); - return 0; - -err_bl_reg: - dev_err(&client->dev, "fail : backlight register.\n"); - lm3630_backlight_unregister(pchip); -err_chip_init: - return ret; -} - -static int __devexit lm3630_remove(struct i2c_client *client) -{ - int ret; - struct lm3630_chip_data *pchip = i2c_get_clientdata(client); - - ret = regmap_write(pchip->regmap, REG_BRT_A, 0); - if (ret < 0) - dev_err(pchip->dev, "i2c failed to access register\n"); - - ret = regmap_write(pchip->regmap, REG_BRT_B, 0); - if (ret < 0) - dev_err(pchip->dev, "i2c failed to access register\n"); - - lm3630_backlight_unregister(pchip); - if (pchip->irq) { - free_irq(pchip->irq, pchip); - flush_workqueue(pchip->irqthread); - destroy_workqueue(pchip->irqthread); - } - return 0; -} - -static const struct i2c_device_id lm3630_id[] = { - {LM3630_NAME, 0}, - {} -}; - -MODULE_DEVICE_TABLE(i2c, lm3630_id); - -static struct i2c_driver lm3630_i2c_driver = { - .driver = { - .name = LM3630_NAME, - }, - .probe = lm3630_probe, - .remove = __devexit_p(lm3630_remove), - .id_table = lm3630_id, -}; - -module_i2c_driver(lm3630_i2c_driver); - -MODULE_DESCRIPTION("Texas Instruments Backlight driver for LM3630"); -MODULE_AUTHOR("G.Shark Jeong "); -MODULE_AUTHOR("Daniel Jeong "); -MODULE_LICENSE("GPL v2"); diff --git a/trunk/drivers/video/backlight/lm3639_bl.c b/trunk/drivers/video/backlight/lm3639_bl.c deleted file mode 100644 index c6915c6c3cd1..000000000000 --- a/trunk/drivers/video/backlight/lm3639_bl.c +++ /dev/null @@ -1,437 +0,0 @@ -/* -* Simple driver for Texas Instruments LM3639 Backlight + Flash LED driver chip -* Copyright (C) 2012 Texas Instruments -* -* 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 -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#define REG_DEV_ID 0x00 -#define REG_CHECKSUM 0x01 -#define REG_BL_CONF_1 0x02 -#define REG_BL_CONF_2 0x03 -#define REG_BL_CONF_3 0x04 -#define REG_BL_CONF_4 0x05 -#define REG_FL_CONF_1 0x06 -#define REG_FL_CONF_2 0x07 -#define REG_FL_CONF_3 0x08 -#define REG_IO_CTRL 0x09 -#define REG_ENABLE 0x0A -#define REG_FLAG 0x0B -#define REG_MAX REG_FLAG - -struct lm3639_chip_data { - struct device *dev; - struct lm3639_platform_data *pdata; - - struct backlight_device *bled; - struct led_classdev cdev_flash; - struct led_classdev cdev_torch; - struct regmap *regmap; - - unsigned int bled_mode; - unsigned int bled_map; - unsigned int last_flag; -}; - -/* initialize chip */ -static int __devinit lm3639_chip_init(struct lm3639_chip_data *pchip) -{ - int ret; - unsigned int reg_val; - struct lm3639_platform_data *pdata = pchip->pdata; - - /* input pins config. */ - ret = - regmap_update_bits(pchip->regmap, REG_BL_CONF_1, 0x08, - pdata->pin_pwm); - if (ret < 0) - goto out; - - reg_val = (pdata->pin_pwm & 0x40) | pdata->pin_strobe | pdata->pin_tx; - ret = regmap_update_bits(pchip->regmap, REG_IO_CTRL, 0x7C, reg_val); - if (ret < 0) - goto out; - - /* init brightness */ - ret = regmap_write(pchip->regmap, REG_BL_CONF_4, pdata->init_brt_led); - if (ret < 0) - goto out; - - ret = regmap_write(pchip->regmap, REG_BL_CONF_3, pdata->init_brt_led); - if (ret < 0) - goto out; - - /* output pins config. */ - if (!pdata->init_brt_led) - reg_val = pdata->fled_pins | pdata->bled_pins; - else - reg_val = pdata->fled_pins | pdata->bled_pins | 0x01; - - ret = regmap_update_bits(pchip->regmap, REG_ENABLE, 0x79, reg_val); - if (ret < 0) - goto out; - - return ret; -out: - dev_err(pchip->dev, "i2c failed to access register\n"); - return ret; -} - -/* update and get brightness */ -static int lm3639_bled_update_status(struct backlight_device *bl) -{ - int ret; - unsigned int reg_val; - struct lm3639_chip_data *pchip = bl_get_data(bl); - struct lm3639_platform_data *pdata = pchip->pdata; - - ret = regmap_read(pchip->regmap, REG_FLAG, ®_val); - if (ret < 0) - goto out; - - if (reg_val != 0) - dev_info(pchip->dev, "last flag is 0x%x\n", reg_val); - - /* pwm control */ - if (pdata->pin_pwm) { - if (pdata->pwm_set_intensity) - pdata->pwm_set_intensity(bl->props.brightness, - pdata->max_brt_led); - else - dev_err(pchip->dev, - "No pwm control func. in plat-data\n"); - return bl->props.brightness; - } - - /* i2c control and set brigtness */ - ret = regmap_write(pchip->regmap, REG_BL_CONF_4, bl->props.brightness); - if (ret < 0) - goto out; - ret = regmap_write(pchip->regmap, REG_BL_CONF_3, bl->props.brightness); - if (ret < 0) - goto out; - - if (!bl->props.brightness) - ret = regmap_update_bits(pchip->regmap, REG_ENABLE, 0x01, 0x00); - else - ret = regmap_update_bits(pchip->regmap, REG_ENABLE, 0x01, 0x01); - if (ret < 0) - goto out; - - return bl->props.brightness; -out: - dev_err(pchip->dev, "i2c failed to access registers\n"); - return bl->props.brightness; -} - -static int lm3639_bled_get_brightness(struct backlight_device *bl) -{ - int ret; - unsigned int reg_val; - struct lm3639_chip_data *pchip = bl_get_data(bl); - struct lm3639_platform_data *pdata = pchip->pdata; - - if (pdata->pin_pwm) { - if (pdata->pwm_get_intensity) - bl->props.brightness = pdata->pwm_get_intensity(); - else - dev_err(pchip->dev, - "No pwm control func. in plat-data\n"); - return bl->props.brightness; - } - - ret = regmap_read(pchip->regmap, REG_BL_CONF_1, ®_val); - if (ret < 0) - goto out; - if (reg_val & 0x10) - ret = regmap_read(pchip->regmap, REG_BL_CONF_4, ®_val); - else - ret = regmap_read(pchip->regmap, REG_BL_CONF_3, ®_val); - if (ret < 0) - goto out; - bl->props.brightness = reg_val; - - return bl->props.brightness; -out: - dev_err(pchip->dev, "i2c failed to access register\n"); - return bl->props.brightness; -} - -static const struct backlight_ops lm3639_bled_ops = { - .options = BL_CORE_SUSPENDRESUME, - .update_status = lm3639_bled_update_status, - .get_brightness = lm3639_bled_get_brightness, -}; - -/* backlight mapping mode */ -static ssize_t lm3639_bled_mode_store(struct device *dev, - struct device_attribute *devAttr, - const char *buf, size_t size) -{ - ssize_t ret; - struct lm3639_chip_data *pchip = dev_get_drvdata(dev); - unsigned int state; - - ret = kstrtouint(buf, 10, &state); - if (ret) - goto out_input; - - if (!state) - ret = - regmap_update_bits(pchip->regmap, REG_BL_CONF_1, 0x10, - 0x00); - else - ret = - regmap_update_bits(pchip->regmap, REG_BL_CONF_1, 0x10, - 0x10); - - if (ret < 0) - goto out; - - return size; - -out: - dev_err(pchip->dev, "%s:i2c access fail to register\n", __func__); - return size; - -out_input: - dev_err(pchip->dev, "%s:input conversion fail\n", __func__); - return size; - -} - -static DEVICE_ATTR(bled_mode, 0666, NULL, lm3639_bled_mode_store); - -/* torch */ -static void lm3639_torch_brightness_set(struct led_classdev *cdev, - enum led_brightness brightness) -{ - int ret; - unsigned int reg_val; - struct lm3639_chip_data *pchip; - - pchip = container_of(cdev, struct lm3639_chip_data, cdev_torch); - - ret = regmap_read(pchip->regmap, REG_FLAG, ®_val); - if (ret < 0) - goto out; - if (reg_val != 0) - dev_info(pchip->dev, "last flag is 0x%x\n", reg_val); - - /* brightness 0 means off state */ - if (!brightness) { - ret = regmap_update_bits(pchip->regmap, REG_ENABLE, 0x06, 0x00); - if (ret < 0) - goto out; - return; - } - - ret = regmap_update_bits(pchip->regmap, - REG_FL_CONF_1, 0x70, (brightness - 1) << 4); - if (ret < 0) - goto out; - ret = regmap_update_bits(pchip->regmap, REG_ENABLE, 0x06, 0x02); - if (ret < 0) - goto out; - - return; -out: - dev_err(pchip->dev, "i2c failed to access register\n"); - return; -} - -/* flash */ -static void lm3639_flash_brightness_set(struct led_classdev *cdev, - enum led_brightness brightness) -{ - int ret; - unsigned int reg_val; - struct lm3639_chip_data *pchip; - - pchip = container_of(cdev, struct lm3639_chip_data, cdev_flash); - - ret = regmap_read(pchip->regmap, REG_FLAG, ®_val); - if (ret < 0) - goto out; - if (reg_val != 0) - dev_info(pchip->dev, "last flag is 0x%x\n", reg_val); - - /* torch off before flash control */ - ret = regmap_update_bits(pchip->regmap, REG_ENABLE, 0x06, 0x00); - if (ret < 0) - goto out; - - /* brightness 0 means off state */ - if (!brightness) - return; - - ret = regmap_update_bits(pchip->regmap, - REG_FL_CONF_1, 0x0F, brightness - 1); - if (ret < 0) - goto out; - ret = regmap_update_bits(pchip->regmap, REG_ENABLE, 0x06, 0x06); - if (ret < 0) - goto out; - - return; -out: - dev_err(pchip->dev, "i2c failed to access register\n"); - return; -} - -static const struct regmap_config lm3639_regmap = { - .reg_bits = 8, - .val_bits = 8, - .max_register = REG_MAX, -}; - -static int __devinit lm3639_probe(struct i2c_client *client, - const struct i2c_device_id *id) -{ - int ret; - struct lm3639_chip_data *pchip; - struct lm3639_platform_data *pdata = client->dev.platform_data; - struct backlight_properties props; - - if (!i2c_check_functionality(client->adapter, I2C_FUNC_I2C)) { - dev_err(&client->dev, "i2c functionality check fail.\n"); - return -EOPNOTSUPP; - } - - if (pdata == NULL) { - dev_err(&client->dev, "Needs Platform Data.\n"); - return -ENODATA; - } - - pchip = devm_kzalloc(&client->dev, - sizeof(struct lm3639_chip_data), GFP_KERNEL); - if (!pchip) - return -ENOMEM; - - pchip->pdata = pdata; - pchip->dev = &client->dev; - - pchip->regmap = devm_regmap_init_i2c(client, &lm3639_regmap); - if (IS_ERR(pchip->regmap)) { - ret = PTR_ERR(pchip->regmap); - dev_err(&client->dev, "fail : allocate register map: %d\n", - ret); - return ret; - } - i2c_set_clientdata(client, pchip); - - /* chip initialize */ - ret = lm3639_chip_init(pchip); - if (ret < 0) { - dev_err(&client->dev, "fail : chip init\n"); - goto err_out; - } - - /* backlight */ - props.type = BACKLIGHT_RAW; - props.brightness = pdata->init_brt_led; - props.max_brightness = pdata->max_brt_led; - pchip->bled = - backlight_device_register("lm3639_bled", pchip->dev, pchip, - &lm3639_bled_ops, &props); - if (IS_ERR(pchip->bled)) { - dev_err(&client->dev, "fail : backlight register\n"); - ret = -EIO; - goto err_out; - } - - ret = device_create_file(&(pchip->bled->dev), &dev_attr_bled_mode); - if (ret < 0) { - dev_err(&client->dev, "failed : add sysfs entries\n"); - ret = -EIO; - goto err_bled_mode; - } - - /* flash */ - pchip->cdev_flash.name = "lm3639_flash"; - pchip->cdev_flash.max_brightness = 16; - pchip->cdev_flash.brightness_set = lm3639_flash_brightness_set; - ret = led_classdev_register((struct device *) - &client->dev, &pchip->cdev_flash); - if (ret < 0) { - dev_err(&client->dev, "fail : flash register\n"); - ret = -EIO; - goto err_flash; - } - - /* torch */ - pchip->cdev_torch.name = "lm3639_torch"; - pchip->cdev_torch.max_brightness = 8; - pchip->cdev_torch.brightness_set = lm3639_torch_brightness_set; - ret = led_classdev_register((struct device *) - &client->dev, &pchip->cdev_torch); - if (ret < 0) { - dev_err(&client->dev, "fail : torch register\n"); - ret = -EIO; - goto err_torch; - } - - return 0; - -err_torch: - led_classdev_unregister(&pchip->cdev_flash); -err_flash: - device_remove_file(&(pchip->bled->dev), &dev_attr_bled_mode); -err_bled_mode: - backlight_device_unregister(pchip->bled); -err_out: - return ret; -} - -static int __devexit lm3639_remove(struct i2c_client *client) -{ - struct lm3639_chip_data *pchip = i2c_get_clientdata(client); - - regmap_write(pchip->regmap, REG_ENABLE, 0x00); - - if (&pchip->cdev_torch) - led_classdev_unregister(&pchip->cdev_torch); - if (&pchip->cdev_flash) - led_classdev_unregister(&pchip->cdev_flash); - if (pchip->bled) { - device_remove_file(&(pchip->bled->dev), &dev_attr_bled_mode); - backlight_device_unregister(pchip->bled); - } - return 0; -} - -static const struct i2c_device_id lm3639_id[] = { - {LM3639_NAME, 0}, - {} -}; - -MODULE_DEVICE_TABLE(i2c, lm3639_id); -static struct i2c_driver lm3639_i2c_driver = { - .driver = { - .name = LM3639_NAME, - }, - .probe = lm3639_probe, - .remove = __devexit_p(lm3639_remove), - .id_table = lm3639_id, -}; - -module_i2c_driver(lm3639_i2c_driver); - -MODULE_DESCRIPTION("Texas Instruments Backlight+Flash LED driver for LM3639"); -MODULE_AUTHOR("Daniel Jeong "); -MODULE_AUTHOR("G.Shark Jeong "); -MODULE_LICENSE("GPL v2"); diff --git a/trunk/drivers/video/backlight/ltv350qv.c b/trunk/drivers/video/backlight/ltv350qv.c index 4066a5bbd826..6c0f1ac0d32a 100644 --- a/trunk/drivers/video/backlight/ltv350qv.c +++ b/trunk/drivers/video/backlight/ltv350qv.c @@ -75,7 +75,7 @@ static int ltv350qv_power_on(struct ltv350qv *lcd) /* Power On Reset Display off State */ if (ltv350qv_write_reg(lcd, LTV_PWRCTL1, 0x0000)) goto err; - usleep_range(15000, 16000); + msleep(15); /* Power Setting Function 1 */ if (ltv350qv_write_reg(lcd, LTV_PWRCTL1, LTV_VCOM_DISABLE)) @@ -153,7 +153,7 @@ static int ltv350qv_power_on(struct ltv350qv *lcd) err_power2: err_power1: ltv350qv_write_reg(lcd, LTV_PWRCTL2, 0x0000); - usleep_range(1000, 1100); + msleep(1); err: ltv350qv_write_reg(lcd, LTV_PWRCTL1, LTV_VCOM_DISABLE); return -EIO; @@ -175,7 +175,7 @@ static int ltv350qv_power_off(struct ltv350qv *lcd) ret |= ltv350qv_write_reg(lcd, LTV_PWRCTL2, 0x0000); /* Wait at least 1 ms */ - usleep_range(1000, 1100); + msleep(1); /* Power down setting 2 */ ret |= ltv350qv_write_reg(lcd, LTV_PWRCTL1, LTV_VCOM_DISABLE); diff --git a/trunk/drivers/video/backlight/max8925_bl.c b/trunk/drivers/video/backlight/max8925_bl.c index f72ba54f364e..e833ac72e063 100644 --- a/trunk/drivers/video/backlight/max8925_bl.c +++ b/trunk/drivers/video/backlight/max8925_bl.c @@ -27,9 +27,7 @@ struct max8925_backlight_data { struct max8925_chip *chip; - int current_brightness; - int reg_mode_cntl; - int reg_cntl; + int current_brightness; }; static int max8925_backlight_set(struct backlight_device *bl, int brightness) @@ -44,16 +42,16 @@ static int max8925_backlight_set(struct backlight_device *bl, int brightness) else value = brightness; - ret = max8925_reg_write(chip->i2c, data->reg_cntl, value); + ret = max8925_reg_write(chip->i2c, MAX8925_WLED_CNTL, value); if (ret < 0) goto out; if (!data->current_brightness && brightness) /* enable WLED output */ - ret = max8925_set_bits(chip->i2c, data->reg_mode_cntl, 1, 1); + ret = max8925_set_bits(chip->i2c, MAX8925_WLED_MODE_CNTL, 1, 1); else if (!brightness) /* disable WLED output */ - ret = max8925_set_bits(chip->i2c, data->reg_mode_cntl, 1, 0); + ret = max8925_set_bits(chip->i2c, MAX8925_WLED_MODE_CNTL, 1, 0); if (ret < 0) goto out; dev_dbg(chip->dev, "set brightness %d\n", value); @@ -87,7 +85,7 @@ static int max8925_backlight_get_brightness(struct backlight_device *bl) struct max8925_chip *chip = data->chip; int ret; - ret = max8925_reg_read(chip->i2c, data->reg_cntl); + ret = max8925_reg_read(chip->i2c, MAX8925_WLED_CNTL); if (ret < 0) return -EINVAL; data->current_brightness = ret; @@ -104,70 +102,69 @@ static const struct backlight_ops max8925_backlight_ops = { static int __devinit max8925_backlight_probe(struct platform_device *pdev) { struct max8925_chip *chip = dev_get_drvdata(pdev->dev.parent); - struct max8925_backlight_pdata *pdata = pdev->dev.platform_data; + struct max8925_platform_data *max8925_pdata; + struct max8925_backlight_pdata *pdata = NULL; struct max8925_backlight_data *data; struct backlight_device *bl; struct backlight_properties props; struct resource *res; + char name[MAX8925_NAME_SIZE]; unsigned char value; - int ret = 0; + int ret; - data = devm_kzalloc(&pdev->dev, sizeof(struct max8925_backlight_data), - GFP_KERNEL); - if (data == NULL) - return -ENOMEM; + res = platform_get_resource(pdev, IORESOURCE_IO, 0); + if (res == NULL) { + dev_err(&pdev->dev, "No I/O resource!\n"); + return -EINVAL; + } - res = platform_get_resource(pdev, IORESOURCE_REG, 0); - if (!res) { - dev_err(&pdev->dev, "No REG resource for mode control!\n"); - ret = -ENXIO; - goto out; + if (pdev->dev.parent->platform_data) { + max8925_pdata = pdev->dev.parent->platform_data; + pdata = max8925_pdata->backlight; } - data->reg_mode_cntl = res->start; - res = platform_get_resource(pdev, IORESOURCE_REG, 1); - if (!res) { - dev_err(&pdev->dev, "No REG resource for control!\n"); - ret = -ENXIO; - goto out; + + if (!pdata) { + dev_err(&pdev->dev, "platform data isn't assigned to " + "backlight\n"); + return -EINVAL; } - data->reg_cntl = res->start; + data = devm_kzalloc(&pdev->dev, sizeof(struct max8925_backlight_data), + GFP_KERNEL); + if (data == NULL) + return -ENOMEM; + strncpy(name, res->name, MAX8925_NAME_SIZE); data->chip = chip; data->current_brightness = 0; memset(&props, 0, sizeof(struct backlight_properties)); props.type = BACKLIGHT_RAW; props.max_brightness = MAX_BRIGHTNESS; - bl = backlight_device_register("max8925-backlight", &pdev->dev, data, + bl = backlight_device_register(name, &pdev->dev, data, &max8925_backlight_ops, &props); if (IS_ERR(bl)) { dev_err(&pdev->dev, "failed to register backlight\n"); - ret = PTR_ERR(bl); - goto out; + return PTR_ERR(bl); } bl->props.brightness = MAX_BRIGHTNESS; platform_set_drvdata(pdev, bl); value = 0; - if (pdata) { - if (pdata->lxw_scl) - value |= (1 << 7); - if (pdata->lxw_freq) - value |= (LWX_FREQ(pdata->lxw_freq) << 4); - if (pdata->dual_string) - value |= (1 << 1); - } - ret = max8925_set_bits(chip->i2c, data->reg_mode_cntl, 0xfe, value); + if (pdata->lxw_scl) + value |= (1 << 7); + if (pdata->lxw_freq) + value |= (LWX_FREQ(pdata->lxw_freq) << 4); + if (pdata->dual_string) + value |= (1 << 1); + ret = max8925_set_bits(chip->i2c, MAX8925_WLED_MODE_CNTL, 0xfe, value); if (ret < 0) - goto out_brt; + goto out; backlight_update_status(bl); return 0; -out_brt: - backlight_device_unregister(bl); out: - devm_kfree(&pdev->dev, data); + backlight_device_unregister(bl); return ret; } diff --git a/trunk/drivers/video/backlight/platform_lcd.c b/trunk/drivers/video/backlight/platform_lcd.c index ca4f5d70fe10..b6672340d6c7 100644 --- a/trunk/drivers/video/backlight/platform_lcd.c +++ b/trunk/drivers/video/backlight/platform_lcd.c @@ -16,7 +16,6 @@ #include #include #include -#include #include #include