Merge tag 'v3.14.25' into backport/v3.14.24-ltsi-rc1+v3.14.25/snapshot-merge.wip
authorSimon Horman <horms+renesas@verge.net.au>
Fri, 5 Dec 2014 08:48:48 +0000 (17:48 +0900)
committerSimon Horman <horms+renesas@verge.net.au>
Fri, 5 Dec 2014 08:48:48 +0000 (17:48 +0900)
This is the 3.14.25 stable release

Conflicts:
Makefile

1239 files changed:
Documentation/.gitignore [deleted file]
Documentation/DocBook/media/Makefile
Documentation/DocBook/media/v4l/controls.xml
Documentation/DocBook/media/v4l/pixfmt.xml
Documentation/arm/SH-Mobile/.gitignore [new file with mode: 0644]
Documentation/arm/SH-Mobile/vrl4.c
Documentation/cpu-freq/core.txt
Documentation/cpu-freq/cpu-drivers.txt
Documentation/devicetree/bindings/clock/clock-bindings.txt
Documentation/devicetree/bindings/clock/renesas,cpg-mstp-clocks.txt
Documentation/devicetree/bindings/clock/renesas,r8a7740-cpg-clocks.txt [new file with mode: 0644]
Documentation/devicetree/bindings/clock/renesas,r8a7779-cpg-clocks.txt [new file with mode: 0644]
Documentation/devicetree/bindings/clock/renesas,rz-cpg-clocks.txt [new file with mode: 0644]
Documentation/devicetree/bindings/gpio/renesas,gpio-rcar.txt
Documentation/devicetree/bindings/i2c/i2c-rcar.txt
Documentation/devicetree/bindings/i2c/trivial-devices.txt
Documentation/devicetree/bindings/media/rcar_vin.txt [new file with mode: 0644]
Documentation/devicetree/bindings/media/renesas,vsp1.txt [new file with mode: 0644]
Documentation/devicetree/bindings/mmc/tmio_mmc.txt
Documentation/devicetree/bindings/net/sh_eth.txt [new file with mode: 0644]
Documentation/devicetree/bindings/pci/rcar-pci.txt [new file with mode: 0644]
Documentation/devicetree/bindings/pinctrl/pinctrl-bindings.txt
Documentation/devicetree/bindings/pinctrl/renesas,pfc-pinctrl.txt
Documentation/devicetree/bindings/regulator/da9210.txt
Documentation/devicetree/bindings/regulator/gpio-regulator.txt
Documentation/devicetree/bindings/serial/renesas,sci-serial.txt
Documentation/devicetree/bindings/sound/renesas,rsnd.txt [new file with mode: 0644]
Documentation/devicetree/bindings/sound/simple-card.txt
Documentation/devicetree/bindings/spi/sh-msiof.txt
Documentation/devicetree/bindings/spi/spi-rspi.txt [new file with mode: 0644]
Documentation/devicetree/bindings/thermal/rcar-thermal.txt
Documentation/devicetree/bindings/timer/renesas,cmt.txt [new file with mode: 0644]
Documentation/devicetree/bindings/timer/renesas,mtu2.txt [new file with mode: 0644]
Documentation/devicetree/bindings/timer/renesas,tmu.txt [new file with mode: 0644]
Documentation/devicetree/bindings/usb/usb-xhci.txt
Documentation/devicetree/bindings/vendor-prefixes.txt
Documentation/driver-model/devres.txt
Documentation/filesystems/.gitignore [new file with mode: 0644]
Documentation/i2c/busses/i2c-i801
Documentation/laptops/.gitignore [new file with mode: 0644]
Documentation/networking/timestamping/.gitignore
Documentation/prctl/.gitignore [new file with mode: 0644]
Documentation/prctl/disable-tsc-ctxt-sw-stress-test.c
Documentation/prctl/disable-tsc-on-off-stress-test.c
Documentation/prctl/disable-tsc-test.c
Documentation/ptp/.gitignore [new file with mode: 0644]
Documentation/pwm.txt
Documentation/timers/.gitignore [new file with mode: 0644]
Documentation/vDSO/.gitignore [new file with mode: 0644]
Documentation/video4linux/.gitignore [deleted file]
MAINTAINERS
Makefile
arch/arc/Kconfig
arch/arc/kernel/devtree.c
arch/arm/Kconfig
arch/arm/boot/dts/Makefile
arch/arm/boot/dts/emev2.dtsi
arch/arm/boot/dts/imx53-smd.dts
arch/arm/boot/dts/imx6qdl-phytec-pfla02.dtsi [new file with mode: 0644]
arch/arm/boot/dts/r7s72100-genmai-reference.dts [deleted file]
arch/arm/boot/dts/r7s72100-genmai.dts
arch/arm/boot/dts/r7s72100.dtsi
arch/arm/boot/dts/r8a73a4-ape6evm-reference.dts
arch/arm/boot/dts/r8a73a4.dtsi
arch/arm/boot/dts/r8a7740-armadillo800eva-reference.dts [deleted file]
arch/arm/boot/dts/r8a7740-armadillo800eva.dts
arch/arm/boot/dts/r8a7740.dtsi
arch/arm/boot/dts/r8a7778-bockw-reference.dts
arch/arm/boot/dts/r8a7778.dtsi
arch/arm/boot/dts/r8a7779-marzen-reference.dts [deleted file]
arch/arm/boot/dts/r8a7779-marzen.dts
arch/arm/boot/dts/r8a7779.dtsi
arch/arm/boot/dts/r8a7790-lager.dts
arch/arm/boot/dts/r8a7790.dtsi
arch/arm/boot/dts/r8a7791-henninger.dts [new file with mode: 0644]
arch/arm/boot/dts/r8a7791-koelsch-reference.dts [deleted file]
arch/arm/boot/dts/r8a7791-koelsch.dts
arch/arm/boot/dts/r8a7791.dtsi
arch/arm/boot/dts/r8a7794-alt.dts [new file with mode: 0644]
arch/arm/boot/dts/r8a7794.dtsi [new file with mode: 0644]
arch/arm/boot/dts/sh7372.dtsi
arch/arm/boot/dts/sh73a0-kzm9g-reference.dts
arch/arm/boot/dts/sh73a0.dtsi
arch/arm/configs/ape6evm_defconfig
arch/arm/configs/armadillo800eva_defconfig
arch/arm/configs/badge4_defconfig
arch/arm/configs/bockw_defconfig
arch/arm/configs/cm_x2xx_defconfig
arch/arm/configs/cm_x300_defconfig
arch/arm/configs/colibri_pxa270_defconfig
arch/arm/configs/colibri_pxa300_defconfig
arch/arm/configs/corgi_defconfig
arch/arm/configs/davinci_all_defconfig
arch/arm/configs/em_x270_defconfig
arch/arm/configs/footbridge_defconfig
arch/arm/configs/genmai_defconfig [deleted file]
arch/arm/configs/ixp4xx_defconfig
arch/arm/configs/koelsch_defconfig
arch/arm/configs/kzm9d_defconfig [deleted file]
arch/arm/configs/kzm9g_defconfig
arch/arm/configs/lager_defconfig
arch/arm/configs/mackerel_defconfig
arch/arm/configs/marzen_defconfig
arch/arm/configs/mini2440_defconfig
arch/arm/configs/mv78xx0_defconfig
arch/arm/configs/neponset_defconfig
arch/arm/configs/omap1_defconfig
arch/arm/configs/pcm027_defconfig
arch/arm/configs/s3c2410_defconfig
arch/arm/configs/s3c6400_defconfig
arch/arm/configs/shmobile_defconfig [new file with mode: 0644]
arch/arm/configs/spitz_defconfig
arch/arm/configs/trizeps4_defconfig
arch/arm/configs/viper_defconfig
arch/arm/configs/zeus_defconfig
arch/arm/include/asm/arch_timer.h
arch/arm/kernel/devtree.c
arch/arm/kernel/smp.c
arch/arm/kernel/smp_twd.c
arch/arm/mach-bcm/Kconfig
arch/arm/mach-bcm2835/Kconfig
arch/arm/mach-berlin/Kconfig
arch/arm/mach-cns3xxx/Kconfig
arch/arm/mach-exynos/Kconfig
arch/arm/mach-exynos/common.c
arch/arm/mach-highbank/Kconfig
arch/arm/mach-hisi/Kconfig
arch/arm/mach-imx/Kconfig
arch/arm/mach-keystone/Kconfig
arch/arm/mach-moxart/Kconfig
arch/arm/mach-mvebu/Kconfig
arch/arm/mach-mxs/Kconfig
arch/arm/mach-nomadik/Kconfig
arch/arm/mach-nspire/Kconfig
arch/arm/mach-omap2/Kconfig
arch/arm/mach-omap2/board-omap3beagle.c
arch/arm/mach-picoxcell/Kconfig
arch/arm/mach-prima2/Kconfig
arch/arm/mach-pxa/hx4700.c
arch/arm/mach-pxa/viper.c
arch/arm/mach-rockchip/Kconfig
arch/arm/mach-s3c24xx/Kconfig
arch/arm/mach-shmobile/Kconfig
arch/arm/mach-shmobile/Makefile
arch/arm/mach-shmobile/Makefile.boot
arch/arm/mach-shmobile/board-ape6evm-reference.c
arch/arm/mach-shmobile/board-ape6evm.c
arch/arm/mach-shmobile/board-armadillo800eva-reference.c [deleted file]
arch/arm/mach-shmobile/board-armadillo800eva.c
arch/arm/mach-shmobile/board-bockw-reference.c
arch/arm/mach-shmobile/board-bockw.c
arch/arm/mach-shmobile/board-genmai-reference.c [deleted file]
arch/arm/mach-shmobile/board-genmai.c [deleted file]
arch/arm/mach-shmobile/board-koelsch-reference.c
arch/arm/mach-shmobile/board-koelsch.c
arch/arm/mach-shmobile/board-kzm9d-reference.c [deleted file]
arch/arm/mach-shmobile/board-kzm9g-reference.c
arch/arm/mach-shmobile/board-kzm9g.c
arch/arm/mach-shmobile/board-lager-reference.c
arch/arm/mach-shmobile/board-lager.c
arch/arm/mach-shmobile/board-mackerel.c
arch/arm/mach-shmobile/board-marzen-reference.c
arch/arm/mach-shmobile/board-marzen.c
arch/arm/mach-shmobile/clock-emev2.c [deleted file]
arch/arm/mach-shmobile/clock-r7s72100.c [deleted file]
arch/arm/mach-shmobile/clock-r8a73a4.c
arch/arm/mach-shmobile/clock-r8a7740.c
arch/arm/mach-shmobile/clock-r8a7778.c
arch/arm/mach-shmobile/clock-r8a7779.c
arch/arm/mach-shmobile/clock-r8a7790.c
arch/arm/mach-shmobile/clock-r8a7791.c
arch/arm/mach-shmobile/clock-sh7372.c
arch/arm/mach-shmobile/clock-sh73a0.c
arch/arm/mach-shmobile/clock.c
arch/arm/mach-shmobile/clock.h [moved from arch/arm/mach-shmobile/include/mach/clock.h with 67% similarity]
arch/arm/mach-shmobile/common.h [moved from arch/arm/mach-shmobile/include/mach/common.h with 85% similarity]
arch/arm/mach-shmobile/console.c
arch/arm/mach-shmobile/cpufreq.c [new file with mode: 0644]
arch/arm/mach-shmobile/dma-register.h [moved from arch/arm/mach-shmobile/include/mach/dma-register.h with 92% similarity]
arch/arm/mach-shmobile/headsmp.S
arch/arm/mach-shmobile/include/mach/emev2.h [deleted file]
arch/arm/mach-shmobile/include/mach/head-kzm9g.txt [new file with mode: 0644]
arch/arm/mach-shmobile/include/mach/irqs.h
arch/arm/mach-shmobile/include/mach/r7s72100.h [deleted file]
arch/arm/mach-shmobile/include/mach/r8a7790.h [deleted file]
arch/arm/mach-shmobile/include/mach/zboot.h
arch/arm/mach-shmobile/include/mach/zboot_macros.h
arch/arm/mach-shmobile/intc-sh7372.c
arch/arm/mach-shmobile/intc-sh73a0.c
arch/arm/mach-shmobile/intc.h [moved from arch/arm/mach-shmobile/include/mach/intc.h with 98% similarity]
arch/arm/mach-shmobile/irqs.h [new file with mode: 0644]
arch/arm/mach-shmobile/platsmp-apmu.c
arch/arm/mach-shmobile/platsmp-scu.c
arch/arm/mach-shmobile/platsmp.c
arch/arm/mach-shmobile/pm-r8a7740.c
arch/arm/mach-shmobile/pm-r8a7779.c
arch/arm/mach-shmobile/pm-r8a7790.c [new file with mode: 0644]
arch/arm/mach-shmobile/pm-r8a7791.c [new file with mode: 0644]
arch/arm/mach-shmobile/pm-rcar.c [new file with mode: 0644]
arch/arm/mach-shmobile/pm-rcar.h [new file with mode: 0644]
arch/arm/mach-shmobile/pm-rmobile.c
arch/arm/mach-shmobile/pm-rmobile.h [moved from arch/arm/mach-shmobile/include/mach/pm-rmobile.h with 96% similarity]
arch/arm/mach-shmobile/pm-sh7372.c
arch/arm/mach-shmobile/pm-sh73a0.c
arch/arm/mach-shmobile/r8a73a4.h [moved from arch/arm/mach-shmobile/include/mach/r8a73a4.h with 92% similarity]
arch/arm/mach-shmobile/r8a7740.h [moved from arch/arm/mach-shmobile/include/mach/r8a7740.h with 91% similarity]
arch/arm/mach-shmobile/r8a7778.h [moved from arch/arm/mach-shmobile/include/mach/r8a7778.h with 100% similarity]
arch/arm/mach-shmobile/r8a7779.h [moved from arch/arm/mach-shmobile/include/mach/r8a7779.h with 60% similarity]
arch/arm/mach-shmobile/r8a7790.h [new file with mode: 0644]
arch/arm/mach-shmobile/r8a7791.h [moved from arch/arm/mach-shmobile/include/mach/r8a7791.h with 78% similarity]
arch/arm/mach-shmobile/rcar-gen2.h [moved from arch/arm/mach-shmobile/include/mach/rcar-gen2.h with 85% similarity]
arch/arm/mach-shmobile/setup-emev2.c
arch/arm/mach-shmobile/setup-r7s72100.c
arch/arm/mach-shmobile/setup-r8a73a4.c
arch/arm/mach-shmobile/setup-r8a7740.c
arch/arm/mach-shmobile/setup-r8a7778.c
arch/arm/mach-shmobile/setup-r8a7779.c
arch/arm/mach-shmobile/setup-r8a7790.c
arch/arm/mach-shmobile/setup-r8a7791.c
arch/arm/mach-shmobile/setup-r8a7794.c [new file with mode: 0644]
arch/arm/mach-shmobile/setup-rcar-gen2.c
arch/arm/mach-shmobile/setup-sh7372.c
arch/arm/mach-shmobile/setup-sh73a0.c
arch/arm/mach-shmobile/sh7372.h [moved from arch/arm/mach-shmobile/include/mach/sh7372.h with 96% similarity]
arch/arm/mach-shmobile/sh73a0.h [moved from arch/arm/mach-shmobile/include/mach/sh73a0.h with 100% similarity]
arch/arm/mach-shmobile/smp-emev2.c
arch/arm/mach-shmobile/smp-r8a7779.c
arch/arm/mach-shmobile/smp-r8a7790.c
arch/arm/mach-shmobile/smp-r8a7791.c
arch/arm/mach-shmobile/smp-sh73a0.c
arch/arm/mach-shmobile/timer.c
arch/arm/mach-socfpga/Kconfig
arch/arm/mach-spear/Kconfig
arch/arm/mach-sti/Kconfig
arch/arm/mach-sunxi/Kconfig
arch/arm/mach-tegra/Kconfig
arch/arm/mach-u300/Kconfig
arch/arm/mach-ux500/Kconfig
arch/arm/mach-vexpress/Kconfig
arch/arm/mach-vexpress/platsmp.c
arch/arm/mach-virt/Kconfig
arch/arm/mach-vt8500/Kconfig
arch/arm/mach-zynq/Kconfig
arch/arm/plat-samsung/Kconfig
arch/arm/plat-samsung/Makefile
arch/arm/plat-samsung/s5p-dev-mfc.c
arch/arm64/Kconfig
arch/arm64/include/asm/arch_timer.h
arch/avr32/configs/hammerhead_defconfig
arch/blackfin/configs/BF526-EZBRD_defconfig
arch/blackfin/configs/BF527-EZKIT-V2_defconfig
arch/blackfin/configs/BF527-EZKIT_defconfig
arch/blackfin/configs/BF548-EZKIT_defconfig
arch/blackfin/configs/CM-BF527_defconfig
arch/blackfin/configs/CM-BF548_defconfig
arch/blackfin/configs/IP0X_defconfig
arch/cris/Kconfig
arch/hexagon/Kconfig
arch/ia64/configs/bigsur_defconfig
arch/ia64/configs/generic_defconfig
arch/ia64/configs/gensparse_defconfig
arch/ia64/configs/tiger_defconfig
arch/m32r/Kconfig
arch/m68k/Kconfig
arch/metag/Kconfig
arch/microblaze/kernel/prom.c
arch/mips/Kconfig
arch/mips/ath79/Kconfig
arch/mips/configs/fuloong2e_defconfig
arch/mips/configs/lemote2f_defconfig
arch/mips/configs/mpc30x_defconfig
arch/mips/configs/msp71xx_defconfig
arch/mips/configs/mtx1_defconfig
arch/mips/configs/rm200_defconfig
arch/mips/configs/sb1250_swarm_defconfig
arch/mips/configs/tb0219_defconfig
arch/mips/configs/tb0226_defconfig
arch/mips/ralink/Kconfig
arch/openrisc/Kconfig
arch/parisc/configs/c3000_defconfig
arch/parisc/configs/default_defconfig
arch/powerpc/configs/40x/ep405_defconfig
arch/powerpc/configs/44x/canyonlands_defconfig
arch/powerpc/configs/44x/sam440ep_defconfig
arch/powerpc/configs/52xx/cm5200_defconfig
arch/powerpc/configs/52xx/pcm030_defconfig
arch/powerpc/configs/52xx/tqm5200_defconfig
arch/powerpc/configs/83xx/mpc8313_rdb_defconfig
arch/powerpc/configs/83xx/mpc8315_rdb_defconfig
arch/powerpc/configs/83xx/mpc832x_rdb_defconfig
arch/powerpc/configs/83xx/mpc834x_itx_defconfig
arch/powerpc/configs/83xx/sbc834x_defconfig
arch/powerpc/configs/85xx/ge_imp3a_defconfig
arch/powerpc/configs/85xx/socrates_defconfig
arch/powerpc/configs/85xx/xes_mpc85xx_defconfig
arch/powerpc/configs/86xx/mpc8641_hpcn_defconfig
arch/powerpc/configs/amigaone_defconfig
arch/powerpc/configs/c2k_defconfig
arch/powerpc/configs/cell_defconfig
arch/powerpc/configs/celleb_defconfig
arch/powerpc/configs/chrp32_defconfig
arch/powerpc/configs/g5_defconfig
arch/powerpc/configs/linkstation_defconfig
arch/powerpc/configs/maple_defconfig
arch/powerpc/configs/mpc5200_defconfig
arch/powerpc/configs/mpc86xx_defconfig
arch/powerpc/configs/pmac32_defconfig
arch/powerpc/configs/ppc6xx_defconfig
arch/powerpc/configs/storcenter_defconfig
arch/powerpc/kernel/epapr_paravirt.c
arch/powerpc/kernel/fadump.c
arch/powerpc/kernel/prom.c
arch/powerpc/kernel/rtas.c
arch/powerpc/mm/hash_utils_64.c
arch/powerpc/oprofile/op_model_cell.c
arch/powerpc/platforms/44x/Kconfig
arch/powerpc/platforms/52xx/efika.c
arch/powerpc/platforms/chrp/setup.c
arch/powerpc/platforms/powernv/opal.c
arch/powerpc/platforms/ps3/Kconfig
arch/powerpc/platforms/pseries/setup.c
arch/s390/Kconfig
arch/sh/Kconfig
arch/sh/boards/Kconfig
arch/sh/boards/mach-ecovec24/setup.c
arch/sh/boards/mach-se/7724/setup.c
arch/sh/configs/ecovec24_defconfig
arch/sh/configs/landisk_defconfig
arch/sh/configs/rsk7203_defconfig
arch/sh/configs/sdk7780_defconfig
arch/sh/configs/se7343_defconfig
arch/sh/configs/se7780_defconfig
arch/sh/configs/sh2007_defconfig
arch/sh/configs/sh7785lcr_defconfig
arch/sh/configs/titan_defconfig
arch/sh/configs/urquell_defconfig
arch/sh/include/asm/dma-register.h
arch/sh/include/asm/io.h
arch/sh/include/asm/io_trapped.h
arch/sh/include/asm/machvec.h
arch/sh/kernel/Makefile
arch/sh/kernel/cpu/clock-cpg.c
arch/sh/kernel/cpu/sh2/setup-sh7619.c
arch/sh/kernel/cpu/sh2a/clock-sh7264.c
arch/sh/kernel/cpu/sh2a/clock-sh7269.c
arch/sh/kernel/cpu/sh2a/setup-mxg.c
arch/sh/kernel/cpu/sh2a/setup-sh7201.c
arch/sh/kernel/cpu/sh2a/setup-sh7203.c
arch/sh/kernel/cpu/sh2a/setup-sh7206.c
arch/sh/kernel/cpu/sh2a/setup-sh7264.c
arch/sh/kernel/cpu/sh2a/setup-sh7269.c
arch/sh/kernel/cpu/sh3/setup-sh7705.c
arch/sh/kernel/cpu/sh3/setup-sh770x.c
arch/sh/kernel/cpu/sh3/setup-sh7710.c
arch/sh/kernel/cpu/sh3/setup-sh7720.c
arch/sh/kernel/cpu/sh4/setup-sh4-202.c
arch/sh/kernel/cpu/sh4/setup-sh7750.c
arch/sh/kernel/cpu/sh4/setup-sh7760.c
arch/sh/kernel/cpu/sh4a/clock-sh7343.c
arch/sh/kernel/cpu/sh4a/clock-sh7366.c
arch/sh/kernel/cpu/sh4a/clock-sh7722.c
arch/sh/kernel/cpu/sh4a/clock-sh7723.c
arch/sh/kernel/cpu/sh4a/clock-sh7724.c
arch/sh/kernel/cpu/sh4a/clock-sh7734.c
arch/sh/kernel/cpu/sh4a/clock-sh7757.c
arch/sh/kernel/cpu/sh4a/clock-sh7785.c
arch/sh/kernel/cpu/sh4a/clock-sh7786.c
arch/sh/kernel/cpu/sh4a/clock-shx3.c
arch/sh/kernel/cpu/sh4a/setup-sh7343.c
arch/sh/kernel/cpu/sh4a/setup-sh7366.c
arch/sh/kernel/cpu/sh4a/setup-sh7722.c
arch/sh/kernel/cpu/sh4a/setup-sh7723.c
arch/sh/kernel/cpu/sh4a/setup-sh7724.c
arch/sh/kernel/cpu/sh4a/setup-sh7734.c
arch/sh/kernel/cpu/sh4a/setup-sh7757.c
arch/sh/kernel/cpu/sh4a/setup-sh7763.c
arch/sh/kernel/cpu/sh4a/setup-sh7770.c
arch/sh/kernel/cpu/sh4a/setup-sh7780.c
arch/sh/kernel/cpu/sh4a/setup-sh7785.c
arch/sh/kernel/cpu/sh4a/setup-sh7786.c
arch/sh/kernel/cpu/sh4a/setup-shx3.c
arch/sh/kernel/cpu/sh5/setup-sh5.c
arch/sh/kernel/io_trapped.c
arch/sparc/kernel/time_64.c
arch/tile/Kconfig
arch/unicore32/Kconfig
arch/unicore32/configs/unicore32_defconfig
arch/x86/kernel/tsc.c
arch/xtensa/Kconfig
arch/xtensa/configs/iss_defconfig
arch/xtensa/configs/s6105_defconfig
arch/xtensa/kernel/setup.c
drivers/Makefile
drivers/ata/acard-ahci.c
drivers/ata/ata_generic.c
drivers/ata/ata_piix.c
drivers/ata/pata_acpi.c
drivers/ata/pata_ali.c
drivers/ata/pata_amd.c
drivers/ata/pata_artop.c
drivers/ata/pata_atiixp.c
drivers/ata/pata_atp867x.c
drivers/ata/pata_bf54x.c
drivers/ata/pata_cmd640.c
drivers/ata/pata_cmd64x.c
drivers/ata/pata_cs5520.c
drivers/ata/pata_cs5530.c
drivers/ata/pata_cs5535.c
drivers/ata/pata_cs5536.c
drivers/ata/pata_cypress.c
drivers/ata/pata_efar.c
drivers/ata/pata_hpt366.c
drivers/ata/pata_hpt3x3.c
drivers/ata/pata_imx.c
drivers/ata/pata_it8213.c
drivers/ata/pata_it821x.c
drivers/ata/pata_jmicron.c
drivers/ata/pata_macio.c
drivers/ata/pata_marvell.c
drivers/ata/pata_mpc52xx.c
drivers/ata/pata_mpiix.c
drivers/ata/pata_netcell.c
drivers/ata/pata_ninja32.c
drivers/ata/pata_ns87410.c
drivers/ata/pata_ns87415.c
drivers/ata/pata_oldpiix.c
drivers/ata/pata_opti.c
drivers/ata/pata_optidma.c
drivers/ata/pata_pdc2027x.c
drivers/ata/pata_pdc202xx_old.c
drivers/ata/pata_piccolo.c
drivers/ata/pata_radisys.c
drivers/ata/pata_rdc.c
drivers/ata/pata_rz1000.c
drivers/ata/pata_samsung_cf.c
drivers/ata/pata_sc1200.c
drivers/ata/pata_scc.c
drivers/ata/pata_sch.c
drivers/ata/pata_serverworks.c
drivers/ata/pata_sil680.c
drivers/ata/pata_sis.c
drivers/ata/pata_sl82c105.c
drivers/ata/pata_triflex.c
drivers/ata/pata_via.c
drivers/ata/sata_fsl.c
drivers/ata/sata_inic162x.c
drivers/ata/sata_mv.c
drivers/ata/sata_nv.c
drivers/ata/sata_rcar.c
drivers/ata/sata_sil.c
drivers/ata/sata_sil24.c
drivers/ata/sata_sis.c
drivers/ata/sata_via.c
drivers/base/devres.c
drivers/base/power/Makefile
drivers/base/power/runtime.c
drivers/char/tpm/Kconfig
drivers/clk/clk.c
drivers/clk/shmobile/Makefile
drivers/clk/shmobile/clk-div6.c
drivers/clk/shmobile/clk-mstp.c
drivers/clk/shmobile/clk-r8a7740.c [new file with mode: 0644]
drivers/clk/shmobile/clk-r8a7779.c [new file with mode: 0644]
drivers/clk/shmobile/clk-rcar-gen2.c
drivers/clk/shmobile/clk-rz.c [new file with mode: 0644]
drivers/clocksource/Kconfig
drivers/clocksource/arm_arch_timer.c
drivers/clocksource/sh_cmt.c
drivers/clocksource/sh_mtu2.c
drivers/clocksource/sh_tmu.c
drivers/cpufreq/cpufreq.c
drivers/dma/sh/Kconfig
drivers/dma/sh/Makefile
drivers/dma/sh/rcar-audmapp.c [new file with mode: 0644]
drivers/dma/sh/shdma-arm.h
drivers/dma/sh/shdma-base.c
drivers/dma/sh/shdma-of.c
drivers/dma/sh/shdma.h
drivers/dma/sh/shdmac.c
drivers/dma/sh/sudmac.c
drivers/gpio/gpio-rcar.c
drivers/gpu/drm/rcar-du/Kconfig
drivers/gpu/drm/rcar-du/rcar_du_crtc.c
drivers/gpu/drm/rcar-du/rcar_du_crtc.h
drivers/gpu/drm/rcar-du/rcar_du_drv.c
drivers/gpu/drm/rcar-du/rcar_du_drv.h
drivers/gpu/drm/rcar-du/rcar_du_encoder.c
drivers/gpu/drm/rcar-du/rcar_du_encoder.h
drivers/gpu/drm/rcar-du/rcar_du_group.c
drivers/gpu/drm/rcar-du/rcar_du_group.h
drivers/gpu/drm/rcar-du/rcar_du_kms.c
drivers/gpu/drm/rcar-du/rcar_du_kms.h
drivers/gpu/drm/rcar-du/rcar_du_lvdscon.c
drivers/gpu/drm/rcar-du/rcar_du_lvdscon.h
drivers/gpu/drm/rcar-du/rcar_du_lvdsenc.c
drivers/gpu/drm/rcar-du/rcar_du_lvdsenc.h
drivers/gpu/drm/rcar-du/rcar_du_plane.c
drivers/gpu/drm/rcar-du/rcar_du_plane.h
drivers/gpu/drm/rcar-du/rcar_du_vgacon.c
drivers/gpu/drm/rcar-du/rcar_du_vgacon.h
drivers/i2c/algos/i2c-algo-bit.c
drivers/i2c/algos/i2c-algo-pca.c
drivers/i2c/algos/i2c-algo-pcf.c
drivers/i2c/algos/i2c-algo-pcf.h
drivers/i2c/busses/Kconfig
drivers/i2c/busses/i2c-ali1535.c
drivers/i2c/busses/i2c-ali1563.c
drivers/i2c/busses/i2c-ali15x3.c
drivers/i2c/busses/i2c-amd756-s4882.c
drivers/i2c/busses/i2c-amd756.c
drivers/i2c/busses/i2c-amd8111.c
drivers/i2c/busses/i2c-au1550.c
drivers/i2c/busses/i2c-bcm2835.c
drivers/i2c/busses/i2c-cpm.c
drivers/i2c/busses/i2c-davinci.c
drivers/i2c/busses/i2c-designware-core.c
drivers/i2c/busses/i2c-designware-core.h
drivers/i2c/busses/i2c-designware-pcidrv.c
drivers/i2c/busses/i2c-designware-platdrv.c
drivers/i2c/busses/i2c-diolan-u2c.c
drivers/i2c/busses/i2c-eg20t.c
drivers/i2c/busses/i2c-elektor.c
drivers/i2c/busses/i2c-exynos5.c
drivers/i2c/busses/i2c-hydra.c
drivers/i2c/busses/i2c-i801.c
drivers/i2c/busses/i2c-imx.c
drivers/i2c/busses/i2c-iop3xx.h
drivers/i2c/busses/i2c-isch.c
drivers/i2c/busses/i2c-ismt.c
drivers/i2c/busses/i2c-nforce2-s4985.c
drivers/i2c/busses/i2c-nforce2.c
drivers/i2c/busses/i2c-omap.c
drivers/i2c/busses/i2c-parport-light.c
drivers/i2c/busses/i2c-parport.c
drivers/i2c/busses/i2c-parport.h
drivers/i2c/busses/i2c-pasemi.c
drivers/i2c/busses/i2c-pca-isa.c
drivers/i2c/busses/i2c-piix4.c
drivers/i2c/busses/i2c-pmcmsp.c
drivers/i2c/busses/i2c-powermac.c
drivers/i2c/busses/i2c-pxa-pci.c
drivers/i2c/busses/i2c-rcar.c
drivers/i2c/busses/i2c-s3c2410.c
drivers/i2c/busses/i2c-sh_mobile.c
drivers/i2c/busses/i2c-sibyte.c
drivers/i2c/busses/i2c-simtec.c
drivers/i2c/busses/i2c-sirf.c
drivers/i2c/busses/i2c-sis5595.c
drivers/i2c/busses/i2c-sis630.c
drivers/i2c/busses/i2c-sis96x.c
drivers/i2c/busses/i2c-stu300.c
drivers/i2c/busses/i2c-taos-evm.c
drivers/i2c/busses/i2c-tegra.c
drivers/i2c/busses/i2c-via.c
drivers/i2c/busses/i2c-viapro.c
drivers/i2c/busses/i2c-wmt.c
drivers/i2c/busses/i2c-xiic.c
drivers/i2c/busses/scx200_acb.c
drivers/i2c/i2c-boardinfo.c
drivers/i2c/i2c-core.c
drivers/i2c/i2c-core.h
drivers/i2c/i2c-dev.c
drivers/i2c/i2c-smbus.c
drivers/i2c/i2c-stub.c
drivers/media/i2c/adv7343.c
drivers/media/i2c/mt9p031.c
drivers/media/i2c/s5k5baf.c
drivers/media/i2c/tvp514x.c
drivers/media/i2c/tvp7002.c
drivers/media/parport/bw-qcam.c
drivers/media/pci/cx18/cx18-ioctl.c
drivers/media/pci/cx25821/cx25821-video.c
drivers/media/pci/ivtv/ivtv-ioctl.c
drivers/media/pci/meye/meye.c
drivers/media/pci/saa7134/saa7134-empress.c
drivers/media/pci/saa7134/saa7134-video.c
drivers/media/pci/sta2x11/sta2x11_vip.c
drivers/media/platform/coda.c
drivers/media/platform/davinci/vpbe_display.c
drivers/media/platform/davinci/vpif_capture.c
drivers/media/platform/davinci/vpif_display.c
drivers/media/platform/exynos4-is/fimc-is.c
drivers/media/platform/exynos4-is/media-dev.c
drivers/media/platform/exynos4-is/mipi-csis.c
drivers/media/platform/omap/omap_vout.c
drivers/media/platform/s5p-tv/mixer_video.c
drivers/media/platform/sh_veu.c
drivers/media/platform/soc_camera/rcar_vin.c
drivers/media/platform/vino.c
drivers/media/platform/vivi.c
drivers/media/platform/vsp1/Makefile
drivers/media/platform/vsp1/vsp1.h
drivers/media/platform/vsp1/vsp1_bru.c [new file with mode: 0644]
drivers/media/platform/vsp1/vsp1_bru.h [new file with mode: 0644]
drivers/media/platform/vsp1/vsp1_drv.c
drivers/media/platform/vsp1/vsp1_entity.c
drivers/media/platform/vsp1/vsp1_entity.h
drivers/media/platform/vsp1/vsp1_hsit.c
drivers/media/platform/vsp1/vsp1_lif.c
drivers/media/platform/vsp1/vsp1_lif.h
drivers/media/platform/vsp1/vsp1_lut.c
drivers/media/platform/vsp1/vsp1_regs.h
drivers/media/platform/vsp1/vsp1_rpf.c
drivers/media/platform/vsp1/vsp1_rwpf.c
drivers/media/platform/vsp1/vsp1_rwpf.h
drivers/media/platform/vsp1/vsp1_sru.c
drivers/media/platform/vsp1/vsp1_sru.h
drivers/media/platform/vsp1/vsp1_uds.c
drivers/media/platform/vsp1/vsp1_uds.h
drivers/media/platform/vsp1/vsp1_video.c
drivers/media/platform/vsp1/vsp1_video.h
drivers/media/platform/vsp1/vsp1_wpf.c
drivers/media/usb/cx231xx/cx231xx-417.c
drivers/media/usb/cx231xx/cx231xx-video.c
drivers/media/usb/gspca/gspca.c
drivers/media/usb/hdpvr/hdpvr-video.c
drivers/media/usb/stkwebcam/stk-webcam.c
drivers/media/usb/tlg2300/pd-video.c
drivers/media/usb/tm6000/tm6000-video.c
drivers/media/usb/zr364xx/zr364xx.c
drivers/media/v4l2-core/v4l2-compat-ioctl32.c
drivers/media/v4l2-core/v4l2-ioctl.c
drivers/media/v4l2-core/v4l2-of.c
drivers/media/v4l2-core/videobuf2-core.c
drivers/mfd/adp5520.c
drivers/mfd/cs5535-mfd.c
drivers/mfd/da9055-core.c
drivers/mfd/janz-cmodio.c
drivers/mfd/lpc_ich.c
drivers/mfd/lpc_sch.c
drivers/mfd/mcp-sa11x0.c
drivers/mfd/pcf50633-adc.c
drivers/mfd/rc5t583-irq.c
drivers/mfd/rdc321x-southbridge.c
drivers/mfd/retu-mfd.c
drivers/mfd/smsc-ece1099.c
drivers/mfd/ti-ssp.c
drivers/mfd/ti_am335x_tscadc.c
drivers/mfd/tps65912-core.c
drivers/mfd/tps65912-irq.c
drivers/mfd/twl4030-irq.c
drivers/mfd/twl4030-madc.c
drivers/mfd/twl6030-irq.c
drivers/mfd/vexpress-config.c
drivers/mfd/wm8350-core.c
drivers/mfd/wm8350-irq.c
drivers/mmc/card/block.c
drivers/mmc/core/debugfs.c
drivers/mmc/core/mmc.c
drivers/mmc/host/sh_mmcif.c
drivers/mmc/host/sh_mobile_sdhi.c
drivers/mmc/host/tmio_mmc.c
drivers/mmc/host/tmio_mmc.h
drivers/mmc/host/tmio_mmc_dma.c
drivers/mmc/host/tmio_mmc_pio.c
drivers/mtd/chips/cfi_cmdset_0001.c
drivers/mtd/chips/cfi_cmdset_0002.c
drivers/mtd/chips/cfi_cmdset_0020.c
drivers/mtd/devices/m25p80.c
drivers/mtd/devices/mtd_dataflash.c
drivers/mtd/devices/sst25l.c
drivers/mtd/inftlmount.c
drivers/mtd/maps/bfin-async-flash.c
drivers/mtd/maps/gpio-addr-flash.c
drivers/mtd/maps/intel_vr_nor.c
drivers/mtd/maps/ixp4xx.c
drivers/mtd/maps/lantiq-flash.c
drivers/mtd/maps/latch-addr-flash.c
drivers/mtd/maps/pci.c
drivers/mtd/maps/physmap_of.c
drivers/mtd/maps/plat-ram.c
drivers/mtd/maps/pxa2xx-flash.c
drivers/mtd/maps/rbtx4939-flash.c
drivers/mtd/maps/scb2_flash.c
drivers/mtd/maps/sun_uflash.c
drivers/mtd/mtd_blkdevs.c
drivers/mtd/nand/ams-delta.c
drivers/mtd/nand/au1550nd.c
drivers/mtd/nand/bf5xx_nand.c
drivers/mtd/nand/davinci_nand.c
drivers/mtd/nand/fsl_elbc_nand.c
drivers/mtd/nand/fsl_ifc_nand.c
drivers/mtd/nand/gpio.c
drivers/mtd/nand/mpc5121_nfc.c
drivers/mtd/nand/nuc900_nand.c
drivers/mtd/nand/pasemi_nand.c
drivers/mtd/nand/s3c2410.c
drivers/mtd/onenand/generic.c
drivers/mtd/onenand/omap2.c
drivers/mtd/onenand/onenand_base.c
drivers/mtd/tests/mtd_test.c
drivers/mtd/ubi/ubi.h
drivers/net/can/sja1000/Kconfig
drivers/net/ethernet/3com/Kconfig
drivers/net/ethernet/renesas/Kconfig
drivers/net/ethernet/renesas/sh_eth.c
drivers/net/ethernet/renesas/sh_eth.h
drivers/net/wimax/Makefile
drivers/of/base.c
drivers/of/fdt.c
drivers/pci/host/Kconfig
drivers/pci/host/Makefile
drivers/pci/host/pcie-rcar.c [new file with mode: 0644]
drivers/pcmcia/sa11xx_base.c
drivers/pinctrl/core.c
drivers/pinctrl/devicetree.c
drivers/pinctrl/pinconf-generic.c
drivers/pinctrl/pinmux.c
drivers/pinctrl/sh-pfc/core.c
drivers/pinctrl/sh-pfc/core.h
drivers/pinctrl/sh-pfc/pfc-r8a73a4.c
drivers/pinctrl/sh-pfc/pfc-r8a7740.c
drivers/pinctrl/sh-pfc/pfc-r8a7790.c
drivers/pinctrl/sh-pfc/pfc-r8a7791.c
drivers/pinctrl/sh-pfc/pfc-sh7372.c
drivers/pinctrl/sh-pfc/pfc-sh73a0.c
drivers/pinctrl/sh-pfc/sh_pfc.h
drivers/pwm/Kconfig
drivers/pwm/Makefile
drivers/pwm/core.c
drivers/pwm/pwm-lpss-pci.c [new file with mode: 0644]
drivers/pwm/pwm-lpss-platform.c [new file with mode: 0644]
drivers/pwm/pwm-lpss.c [new file with mode: 0644]
drivers/pwm/pwm-lpss.h [new file with mode: 0644]
drivers/regulator/core.c
drivers/regulator/da9210-regulator.c
drivers/regulator/gpio-regulator.c
drivers/sh/Makefile
drivers/sh/clk/core.c
drivers/sh/clk/cpg.c
drivers/sh/intc/Kconfig
drivers/sh/intc/core.c
drivers/sh/pm_runtime.c
drivers/spi/Kconfig
drivers/spi/spi-altera.c
drivers/spi/spi-ath79.c
drivers/spi/spi-atmel.c
drivers/spi/spi-bcm63xx.c
drivers/spi/spi-bfin-sport.c
drivers/spi/spi-bitbang.c
drivers/spi/spi-clps711x.c
drivers/spi/spi-gpio.c
drivers/spi/spi-imx.c
drivers/spi/spi-mpc512x-psc.c
drivers/spi/spi-mpc52xx-psc.c
drivers/spi/spi-mpc52xx.c
drivers/spi/spi-mxs.c
drivers/spi/spi-nuc900.c
drivers/spi/spi-oc-tiny.c
drivers/spi/spi-octeon.c
drivers/spi/spi-omap2-mcspi.c
drivers/spi/spi-orion.c
drivers/spi/spi-ppc4xx.c
drivers/spi/spi-pxa2xx-dma.c
drivers/spi/spi-pxa2xx-pxadma.c
drivers/spi/spi-rspi.c
drivers/spi/spi-s3c24xx.c
drivers/spi/spi-s3c64xx.c
drivers/spi/spi-sh-msiof.c
drivers/spi/spi-sh-sci.c
drivers/spi/spi-tegra114.c
drivers/spi/spi-tegra20-sflash.c
drivers/spi/spi-tegra20-slink.c
drivers/spi/spi-xcomm.c
drivers/spi/spi-xilinx.c
drivers/spi/spi.c
drivers/staging/Kconfig
drivers/staging/Makefile
drivers/staging/ktap/Kconfig [new file with mode: 0644]
drivers/staging/ktap/Makefile [new file with mode: 0644]
drivers/staging/ktap/README.md [new file with mode: 0644]
drivers/staging/ktap/RELEASES.txt [new file with mode: 0644]
drivers/staging/ktap/doc/tutorial.md [new file with mode: 0644]
drivers/staging/ktap/include/ktap_ffi.h [new file with mode: 0644]
drivers/staging/ktap/include/ktap_opcodes.h [new file with mode: 0644]
drivers/staging/ktap/include/ktap_types.h [new file with mode: 0644]
drivers/staging/ktap/runtime/ffi/call_x86_64.S [new file with mode: 0644]
drivers/staging/ktap/runtime/ffi/cdata.c [new file with mode: 0644]
drivers/staging/ktap/runtime/ffi/ffi_call.c [new file with mode: 0644]
drivers/staging/ktap/runtime/ffi/ffi_symbol.c [new file with mode: 0644]
drivers/staging/ktap/runtime/ffi/ffi_type.c [new file with mode: 0644]
drivers/staging/ktap/runtime/ffi/ffi_util.c [new file with mode: 0644]
drivers/staging/ktap/runtime/kp_amalg.c [new file with mode: 0644]
drivers/staging/ktap/runtime/kp_load.c [new file with mode: 0644]
drivers/staging/ktap/runtime/kp_load.h [new file with mode: 0644]
drivers/staging/ktap/runtime/kp_obj.c [new file with mode: 0644]
drivers/staging/ktap/runtime/kp_obj.h [new file with mode: 0644]
drivers/staging/ktap/runtime/kp_opcode.c [new file with mode: 0644]
drivers/staging/ktap/runtime/kp_str.c [new file with mode: 0644]
drivers/staging/ktap/runtime/kp_str.h [new file with mode: 0644]
drivers/staging/ktap/runtime/kp_tab.c [new file with mode: 0644]
drivers/staging/ktap/runtime/kp_tab.h [new file with mode: 0644]
drivers/staging/ktap/runtime/kp_transport.c [new file with mode: 0644]
drivers/staging/ktap/runtime/kp_transport.h [new file with mode: 0644]
drivers/staging/ktap/runtime/kp_vm.c [new file with mode: 0644]
drivers/staging/ktap/runtime/kp_vm.h [new file with mode: 0644]
drivers/staging/ktap/runtime/ktap.c [new file with mode: 0644]
drivers/staging/ktap/runtime/ktap.h [new file with mode: 0644]
drivers/staging/ktap/runtime/lib_ansi.c [new file with mode: 0644]
drivers/staging/ktap/runtime/lib_base.c [new file with mode: 0644]
drivers/staging/ktap/runtime/lib_ffi.c [new file with mode: 0644]
drivers/staging/ktap/runtime/lib_kdebug.c [new file with mode: 0644]
drivers/staging/ktap/runtime/lib_timer.c [new file with mode: 0644]
drivers/staging/ktap/samples/ansi/ansi_color_demo.kp [new file with mode: 0644]
drivers/staging/ktap/samples/basic/backtrace.kp [new file with mode: 0644]
drivers/staging/ktap/samples/basic/event_trigger.kp [new file with mode: 0644]
drivers/staging/ktap/samples/basic/event_trigger_ftrace.kp [new file with mode: 0644]
drivers/staging/ktap/samples/basic/ftrace.kp [new file with mode: 0644]
drivers/staging/ktap/samples/basic/function_time.kp [new file with mode: 0644]
drivers/staging/ktap/samples/basic/kretprobe.kp [new file with mode: 0644]
drivers/staging/ktap/samples/ffi/ffi_kmalloc.kp [new file with mode: 0644]
drivers/staging/ktap/samples/ffi/printk.kp [new file with mode: 0644]
drivers/staging/ktap/samples/ffi/sched_clock.kp [new file with mode: 0644]
drivers/staging/ktap/samples/game/tetris.kp [new file with mode: 0644]
drivers/staging/ktap/samples/helloworld.kp [new file with mode: 0644]
drivers/staging/ktap/samples/interrupt/hardirq_time.kp [new file with mode: 0644]
drivers/staging/ktap/samples/interrupt/softirq_time.kp [new file with mode: 0644]
drivers/staging/ktap/samples/io/kprobes-do-sys-open.kp [new file with mode: 0644]
drivers/staging/ktap/samples/io/traceio.kp [new file with mode: 0644]
drivers/staging/ktap/samples/mem/kmalloc-top.kp [new file with mode: 0644]
drivers/staging/ktap/samples/mem/kmem.kp [new file with mode: 0644]
drivers/staging/ktap/samples/profiling/function_profiler.kp [new file with mode: 0644]
drivers/staging/ktap/samples/profiling/stack_profile.kp [new file with mode: 0644]
drivers/staging/ktap/samples/schedule/sched_transition.kp [new file with mode: 0644]
drivers/staging/ktap/samples/schedule/schedtimes.kp [new file with mode: 0644]
drivers/staging/ktap/samples/syscalls/errinfo.kp [new file with mode: 0644]
drivers/staging/ktap/samples/syscalls/execve.kp [new file with mode: 0644]
drivers/staging/ktap/samples/syscalls/opensnoop.kp [new file with mode: 0644]
drivers/staging/ktap/samples/syscalls/sctop.kp [new file with mode: 0644]
drivers/staging/ktap/samples/syscalls/syscalls.kp [new file with mode: 0644]
drivers/staging/ktap/samples/syscalls/syscalls_count.kp [new file with mode: 0644]
drivers/staging/ktap/samples/syscalls/syscalls_count_by_proc.kp [new file with mode: 0644]
drivers/staging/ktap/samples/syscalls/syslatl.kp [new file with mode: 0644]
drivers/staging/ktap/samples/syscalls/syslist.kp [new file with mode: 0644]
drivers/staging/ktap/samples/tracepoints/eventcount.kp [new file with mode: 0644]
drivers/staging/ktap/samples/tracepoints/eventcount_by_proc.kp [new file with mode: 0644]
drivers/staging/ktap/samples/tracepoints/tracepoints.kp [new file with mode: 0644]
drivers/staging/ktap/samples/userspace/gcc_unwind.kp [new file with mode: 0644]
drivers/staging/ktap/samples/userspace/glibc_func_hist.kp [new file with mode: 0644]
drivers/staging/ktap/samples/userspace/glibc_sdt.kp [new file with mode: 0644]
drivers/staging/ktap/samples/userspace/glibc_trace.kp [new file with mode: 0644]
drivers/staging/ktap/samples/userspace/malloc_free.kp [new file with mode: 0644]
drivers/staging/ktap/samples/userspace/malloc_size_hist.kp [new file with mode: 0644]
drivers/staging/ktap/test/arg.kp [new file with mode: 0644]
drivers/staging/ktap/test/arithmetic.kp [new file with mode: 0644]
drivers/staging/ktap/test/benchmark/sembench.c [new file with mode: 0644]
drivers/staging/ktap/test/benchmark/test.sh [new file with mode: 0644]
drivers/staging/ktap/test/concat.kp [new file with mode: 0644]
drivers/staging/ktap/test/count.kp [new file with mode: 0644]
drivers/staging/ktap/test/ffi/.gitignore [new file with mode: 0644]
drivers/staging/ktap/test/ffi/Makefile [new file with mode: 0644]
drivers/staging/ktap/test/ffi/cparser_test.c [new file with mode: 0644]
drivers/staging/ktap/test/ffi/ffi_test.kp [new file with mode: 0644]
drivers/staging/ktap/test/ffi/ktap_ffi_test.c [new file with mode: 0644]
drivers/staging/ktap/test/fibonacci.kp [new file with mode: 0644]
drivers/staging/ktap/test/function.kp [new file with mode: 0644]
drivers/staging/ktap/test/if.kp [new file with mode: 0644]
drivers/staging/ktap/test/kprobe.kp [new file with mode: 0644]
drivers/staging/ktap/test/kretprobe.kp [new file with mode: 0644]
drivers/staging/ktap/test/ksym.kp [new file with mode: 0644]
drivers/staging/ktap/test/len.kp [new file with mode: 0644]
drivers/staging/ktap/test/looping.kp [new file with mode: 0644]
drivers/staging/ktap/test/pairs.kp [new file with mode: 0644]
drivers/staging/ktap/test/ptable.kp [new file with mode: 0644]
drivers/staging/ktap/test/run_test.sh [new file with mode: 0644]
drivers/staging/ktap/test/stack_overflow.kp [new file with mode: 0644]
drivers/staging/ktap/test/table.kp [new file with mode: 0644]
drivers/staging/ktap/test/timer.kp [new file with mode: 0644]
drivers/staging/ktap/test/tracepoint.kp [new file with mode: 0644]
drivers/staging/ktap/test/zerodivide.kp [new file with mode: 0644]
drivers/staging/ktap/userspace/code.c [new file with mode: 0644]
drivers/staging/ktap/userspace/cparser.h [new file with mode: 0644]
drivers/staging/ktap/userspace/dump.c [new file with mode: 0644]
drivers/staging/ktap/userspace/eventdef.c [new file with mode: 0644]
drivers/staging/ktap/userspace/ffi/cparser.c [new file with mode: 0644]
drivers/staging/ktap/userspace/ffi/ctype.c [new file with mode: 0644]
drivers/staging/ktap/userspace/ktapc.h [new file with mode: 0644]
drivers/staging/ktap/userspace/ktapio.c [new file with mode: 0644]
drivers/staging/ktap/userspace/lex.c [new file with mode: 0644]
drivers/staging/ktap/userspace/main.c [new file with mode: 0644]
drivers/staging/ktap/userspace/parser.c [new file with mode: 0644]
drivers/staging/ktap/userspace/symbol.c [new file with mode: 0644]
drivers/staging/ktap/userspace/symbol.h [new file with mode: 0644]
drivers/staging/ktap/userspace/util.c [new file with mode: 0644]
drivers/staging/lttng/Kconfig [new file with mode: 0644]
drivers/staging/lttng/LICENSE [new file with mode: 0644]
drivers/staging/lttng/Makefile [new file with mode: 0644]
drivers/staging/lttng/README [new file with mode: 0644]
drivers/staging/lttng/TODO [new file with mode: 0644]
drivers/staging/lttng/instrumentation/events/README [new file with mode: 0644]
drivers/staging/lttng/instrumentation/events/lttng-module/arch/x86/kvm/mmutrace.h [new file with mode: 0644]
drivers/staging/lttng/instrumentation/events/lttng-module/arch/x86/kvm/trace.h [new file with mode: 0644]
drivers/staging/lttng/instrumentation/events/lttng-module/asoc.h [new file with mode: 0644]
drivers/staging/lttng/instrumentation/events/lttng-module/block.h [new file with mode: 0644]
drivers/staging/lttng/instrumentation/events/lttng-module/btrfs.h [new file with mode: 0644]
drivers/staging/lttng/instrumentation/events/lttng-module/compaction.h [new file with mode: 0644]
drivers/staging/lttng/instrumentation/events/lttng-module/ext3.h [new file with mode: 0644]
drivers/staging/lttng/instrumentation/events/lttng-module/ext4.h [new file with mode: 0644]
drivers/staging/lttng/instrumentation/events/lttng-module/gpio.h [new file with mode: 0644]
drivers/staging/lttng/instrumentation/events/lttng-module/irq.h [new file with mode: 0644]
drivers/staging/lttng/instrumentation/events/lttng-module/jbd.h [new file with mode: 0644]
drivers/staging/lttng/instrumentation/events/lttng-module/jbd2.h [new file with mode: 0644]
drivers/staging/lttng/instrumentation/events/lttng-module/kmem.h [new file with mode: 0644]
drivers/staging/lttng/instrumentation/events/lttng-module/kvm.h [new file with mode: 0644]
drivers/staging/lttng/instrumentation/events/lttng-module/lock.h [new file with mode: 0644]
drivers/staging/lttng/instrumentation/events/lttng-module/lttng-statedump.h [new file with mode: 0644]
drivers/staging/lttng/instrumentation/events/lttng-module/module.h [new file with mode: 0644]
drivers/staging/lttng/instrumentation/events/lttng-module/napi.h [new file with mode: 0644]
drivers/staging/lttng/instrumentation/events/lttng-module/net.h [new file with mode: 0644]
drivers/staging/lttng/instrumentation/events/lttng-module/power.h [new file with mode: 0644]
drivers/staging/lttng/instrumentation/events/lttng-module/printk.h [new file with mode: 0644]
drivers/staging/lttng/instrumentation/events/lttng-module/random.h [new file with mode: 0644]
drivers/staging/lttng/instrumentation/events/lttng-module/rcu.h [new file with mode: 0644]
drivers/staging/lttng/instrumentation/events/lttng-module/regmap.h [new file with mode: 0644]
drivers/staging/lttng/instrumentation/events/lttng-module/regulator.h [new file with mode: 0644]
drivers/staging/lttng/instrumentation/events/lttng-module/rpm.h [new file with mode: 0644]
drivers/staging/lttng/instrumentation/events/lttng-module/sched.h [new file with mode: 0644]
drivers/staging/lttng/instrumentation/events/lttng-module/scsi.h [new file with mode: 0644]
drivers/staging/lttng/instrumentation/events/lttng-module/signal.h [new file with mode: 0644]
drivers/staging/lttng/instrumentation/events/lttng-module/skb.h [new file with mode: 0644]
drivers/staging/lttng/instrumentation/events/lttng-module/sock.h [new file with mode: 0644]
drivers/staging/lttng/instrumentation/events/lttng-module/sunrpc.h [new file with mode: 0644]
drivers/staging/lttng/instrumentation/events/lttng-module/syscalls.h [new file with mode: 0644]
drivers/staging/lttng/instrumentation/events/lttng-module/timer.h [new file with mode: 0644]
drivers/staging/lttng/instrumentation/events/lttng-module/udp.h [new file with mode: 0644]
drivers/staging/lttng/instrumentation/events/lttng-module/vmscan.h [new file with mode: 0644]
drivers/staging/lttng/instrumentation/events/lttng-module/workqueue.h [new file with mode: 0644]
drivers/staging/lttng/instrumentation/events/lttng-module/writeback.h [new file with mode: 0644]
drivers/staging/lttng/instrumentation/events/mainline/arch/x86/kvm/mmutrace.h [new file with mode: 0644]
drivers/staging/lttng/instrumentation/events/mainline/arch/x86/kvm/trace.h [new file with mode: 0644]
drivers/staging/lttng/instrumentation/events/mainline/asoc.h [new file with mode: 0644]
drivers/staging/lttng/instrumentation/events/mainline/block.h [new file with mode: 0644]
drivers/staging/lttng/instrumentation/events/mainline/btrfs.h [new file with mode: 0644]
drivers/staging/lttng/instrumentation/events/mainline/compaction.h [new file with mode: 0644]
drivers/staging/lttng/instrumentation/events/mainline/ext3.h [new file with mode: 0644]
drivers/staging/lttng/instrumentation/events/mainline/ext4.h [new file with mode: 0644]
drivers/staging/lttng/instrumentation/events/mainline/gpio.h [new file with mode: 0644]
drivers/staging/lttng/instrumentation/events/mainline/irq.h [new file with mode: 0644]
drivers/staging/lttng/instrumentation/events/mainline/jbd.h [new file with mode: 0644]
drivers/staging/lttng/instrumentation/events/mainline/jbd2.h [new file with mode: 0644]
drivers/staging/lttng/instrumentation/events/mainline/kmem.h [new file with mode: 0644]
drivers/staging/lttng/instrumentation/events/mainline/kvm.h [new file with mode: 0644]
drivers/staging/lttng/instrumentation/events/mainline/lock.h [new file with mode: 0644]
drivers/staging/lttng/instrumentation/events/mainline/module.h [new file with mode: 0644]
drivers/staging/lttng/instrumentation/events/mainline/napi.h [new file with mode: 0644]
drivers/staging/lttng/instrumentation/events/mainline/net.h [new file with mode: 0644]
drivers/staging/lttng/instrumentation/events/mainline/power.h [new file with mode: 0644]
drivers/staging/lttng/instrumentation/events/mainline/printk.h [new file with mode: 0644]
drivers/staging/lttng/instrumentation/events/mainline/random.h [new file with mode: 0644]
drivers/staging/lttng/instrumentation/events/mainline/rcu.h [new file with mode: 0644]
drivers/staging/lttng/instrumentation/events/mainline/regmap.h [new file with mode: 0644]
drivers/staging/lttng/instrumentation/events/mainline/regulator.h [new file with mode: 0644]
drivers/staging/lttng/instrumentation/events/mainline/rpm.h [new file with mode: 0644]
drivers/staging/lttng/instrumentation/events/mainline/sched.h [new file with mode: 0644]
drivers/staging/lttng/instrumentation/events/mainline/scsi.h [new file with mode: 0644]
drivers/staging/lttng/instrumentation/events/mainline/signal.h [new file with mode: 0644]
drivers/staging/lttng/instrumentation/events/mainline/skb.h [new file with mode: 0644]
drivers/staging/lttng/instrumentation/events/mainline/sock.h [new file with mode: 0644]
drivers/staging/lttng/instrumentation/events/mainline/sunrpc.h [new file with mode: 0644]
drivers/staging/lttng/instrumentation/events/mainline/syscalls.h [new file with mode: 0644]
drivers/staging/lttng/instrumentation/events/mainline/timer.h [new file with mode: 0644]
drivers/staging/lttng/instrumentation/events/mainline/udp.h [new file with mode: 0644]
drivers/staging/lttng/instrumentation/events/mainline/vmscan.h [new file with mode: 0644]
drivers/staging/lttng/instrumentation/events/mainline/workqueue.h [new file with mode: 0644]
drivers/staging/lttng/instrumentation/events/mainline/writeback.h [new file with mode: 0644]
drivers/staging/lttng/instrumentation/syscalls/3.0.34/powerpc-32-syscalls-3.0.34 [new file with mode: 0644]
drivers/staging/lttng/instrumentation/syscalls/3.1.0-rc6/x86-32-syscalls-3.1.0-rc6 [new file with mode: 0644]
drivers/staging/lttng/instrumentation/syscalls/3.10.0-rc7/x86-64-syscalls-3.10.0-rc7 [new file with mode: 0644]
drivers/staging/lttng/instrumentation/syscalls/3.4.25/arm-32-syscalls-3.4.25 [new file with mode: 0644]
drivers/staging/lttng/instrumentation/syscalls/3.5.0/mips-32-syscalls-3.5.0 [new file with mode: 0644]
drivers/staging/lttng/instrumentation/syscalls/3.5.0/mips-64-syscalls-3.5.0 [new file with mode: 0644]
drivers/staging/lttng/instrumentation/syscalls/README [new file with mode: 0644]
drivers/staging/lttng/instrumentation/syscalls/headers/arm-32-syscalls-3.4.25_integers.h [new file with mode: 0644]
drivers/staging/lttng/instrumentation/syscalls/headers/arm-32-syscalls-3.4.25_integers_override.h [new file with mode: 0644]
drivers/staging/lttng/instrumentation/syscalls/headers/arm-32-syscalls-3.4.25_pointers.h [new file with mode: 0644]
drivers/staging/lttng/instrumentation/syscalls/headers/arm-32-syscalls-3.4.25_pointers_override.h [new file with mode: 0644]
drivers/staging/lttng/instrumentation/syscalls/headers/compat_syscalls_integers.h [new file with mode: 0644]
drivers/staging/lttng/instrumentation/syscalls/headers/compat_syscalls_pointers.h [new file with mode: 0644]
drivers/staging/lttng/instrumentation/syscalls/headers/mips-32-syscalls-3.5.0_integers.h [new file with mode: 0644]
drivers/staging/lttng/instrumentation/syscalls/headers/mips-32-syscalls-3.5.0_integers_override.h [new file with mode: 0644]
drivers/staging/lttng/instrumentation/syscalls/headers/mips-32-syscalls-3.5.0_pointers.h [new file with mode: 0644]
drivers/staging/lttng/instrumentation/syscalls/headers/mips-32-syscalls-3.5.0_pointers_override.h [new file with mode: 0644]
drivers/staging/lttng/instrumentation/syscalls/headers/mips-64-syscalls-3.5.0_integers.h [new file with mode: 0644]
drivers/staging/lttng/instrumentation/syscalls/headers/mips-64-syscalls-3.5.0_integers_override.h [new file with mode: 0644]
drivers/staging/lttng/instrumentation/syscalls/headers/mips-64-syscalls-3.5.0_pointers.h [new file with mode: 0644]
drivers/staging/lttng/instrumentation/syscalls/headers/mips-64-syscalls-3.5.0_pointers_override.h [new file with mode: 0644]
drivers/staging/lttng/instrumentation/syscalls/headers/powerpc-32-syscalls-3.0.34_integers.h [new file with mode: 0644]
drivers/staging/lttng/instrumentation/syscalls/headers/powerpc-32-syscalls-3.0.34_integers_override.h [new file with mode: 0644]
drivers/staging/lttng/instrumentation/syscalls/headers/powerpc-32-syscalls-3.0.34_pointers.h [new file with mode: 0644]
drivers/staging/lttng/instrumentation/syscalls/headers/powerpc-32-syscalls-3.0.34_pointers_override.h [new file with mode: 0644]
drivers/staging/lttng/instrumentation/syscalls/headers/syscalls_integers.h [new file with mode: 0644]
drivers/staging/lttng/instrumentation/syscalls/headers/syscalls_integers_override.h [new file with mode: 0644]
drivers/staging/lttng/instrumentation/syscalls/headers/syscalls_pointers.h [new file with mode: 0644]
drivers/staging/lttng/instrumentation/syscalls/headers/syscalls_pointers_override.h [new file with mode: 0644]
drivers/staging/lttng/instrumentation/syscalls/headers/syscalls_unknown.h [new file with mode: 0644]
drivers/staging/lttng/instrumentation/syscalls/headers/x86-32-syscalls-3.1.0-rc6_integers.h [new file with mode: 0644]
drivers/staging/lttng/instrumentation/syscalls/headers/x86-32-syscalls-3.1.0-rc6_integers_override.h [new file with mode: 0644]
drivers/staging/lttng/instrumentation/syscalls/headers/x86-32-syscalls-3.1.0-rc6_pointers.h [new file with mode: 0644]
drivers/staging/lttng/instrumentation/syscalls/headers/x86-32-syscalls-3.1.0-rc6_pointers_override.h [new file with mode: 0644]
drivers/staging/lttng/instrumentation/syscalls/headers/x86-64-syscalls-3.10.0-rc7_integers.h [new file with mode: 0644]
drivers/staging/lttng/instrumentation/syscalls/headers/x86-64-syscalls-3.10.0-rc7_integers_override.h [new file with mode: 0644]
drivers/staging/lttng/instrumentation/syscalls/headers/x86-64-syscalls-3.10.0-rc7_pointers.h [new file with mode: 0644]
drivers/staging/lttng/instrumentation/syscalls/headers/x86-64-syscalls-3.10.0-rc7_pointers_override.h [new file with mode: 0644]
drivers/staging/lttng/instrumentation/syscalls/lttng-syscalls-extractor/Makefile [new file with mode: 0644]
drivers/staging/lttng/instrumentation/syscalls/lttng-syscalls-extractor/lttng-syscalls-extractor.c [new file with mode: 0644]
drivers/staging/lttng/instrumentation/syscalls/lttng-syscalls-generate-headers.sh [new file with mode: 0644]
drivers/staging/lttng/lib/Makefile [new file with mode: 0644]
drivers/staging/lttng/lib/align.h [new file with mode: 0644]
drivers/staging/lttng/lib/bitfield.h [new file with mode: 0644]
drivers/staging/lttng/lib/bug.h [new file with mode: 0644]
drivers/staging/lttng/lib/prio_heap/lttng_prio_heap.c [new file with mode: 0644]
drivers/staging/lttng/lib/prio_heap/lttng_prio_heap.h [new file with mode: 0644]
drivers/staging/lttng/lib/ringbuffer/api.h [new file with mode: 0644]
drivers/staging/lttng/lib/ringbuffer/backend.h [new file with mode: 0644]
drivers/staging/lttng/lib/ringbuffer/backend_internal.h [new file with mode: 0644]
drivers/staging/lttng/lib/ringbuffer/backend_types.h [new file with mode: 0644]
drivers/staging/lttng/lib/ringbuffer/config.h [new file with mode: 0644]
drivers/staging/lttng/lib/ringbuffer/frontend.h [new file with mode: 0644]
drivers/staging/lttng/lib/ringbuffer/frontend_api.h [new file with mode: 0644]
drivers/staging/lttng/lib/ringbuffer/frontend_internal.h [new file with mode: 0644]
drivers/staging/lttng/lib/ringbuffer/frontend_types.h [new file with mode: 0644]
drivers/staging/lttng/lib/ringbuffer/iterator.h [new file with mode: 0644]
drivers/staging/lttng/lib/ringbuffer/nohz.h [new file with mode: 0644]
drivers/staging/lttng/lib/ringbuffer/ring_buffer_backend.c [new file with mode: 0644]
drivers/staging/lttng/lib/ringbuffer/ring_buffer_frontend.c [new file with mode: 0644]
drivers/staging/lttng/lib/ringbuffer/ring_buffer_iterator.c [new file with mode: 0644]
drivers/staging/lttng/lib/ringbuffer/ring_buffer_mmap.c [new file with mode: 0644]
drivers/staging/lttng/lib/ringbuffer/ring_buffer_splice.c [new file with mode: 0644]
drivers/staging/lttng/lib/ringbuffer/ring_buffer_vfs.c [new file with mode: 0644]
drivers/staging/lttng/lib/ringbuffer/vatomic.h [new file with mode: 0644]
drivers/staging/lttng/lib/ringbuffer/vfs.h [new file with mode: 0644]
drivers/staging/lttng/lttng-abi-old.h [new file with mode: 0644]
drivers/staging/lttng/lttng-abi.c [new file with mode: 0644]
drivers/staging/lttng/lttng-abi.h [new file with mode: 0644]
drivers/staging/lttng/lttng-calibrate.c [new file with mode: 0644]
drivers/staging/lttng/lttng-context-hostname.c [new file with mode: 0644]
drivers/staging/lttng/lttng-context-nice.c [new file with mode: 0644]
drivers/staging/lttng/lttng-context-perf-counters.c [new file with mode: 0644]
drivers/staging/lttng/lttng-context-pid.c [new file with mode: 0644]
drivers/staging/lttng/lttng-context-ppid.c [new file with mode: 0644]
drivers/staging/lttng/lttng-context-prio.c [new file with mode: 0644]
drivers/staging/lttng/lttng-context-procname.c [new file with mode: 0644]
drivers/staging/lttng/lttng-context-tid.c [new file with mode: 0644]
drivers/staging/lttng/lttng-context-vpid.c [new file with mode: 0644]
drivers/staging/lttng/lttng-context-vppid.c [new file with mode: 0644]
drivers/staging/lttng/lttng-context-vtid.c [new file with mode: 0644]
drivers/staging/lttng/lttng-context.c [new file with mode: 0644]
drivers/staging/lttng/lttng-endian.h [new file with mode: 0644]
drivers/staging/lttng/lttng-events.c [new file with mode: 0644]
drivers/staging/lttng/lttng-events.h [new file with mode: 0644]
drivers/staging/lttng/lttng-kernel-version.h [new file with mode: 0644]
drivers/staging/lttng/lttng-probes.c [new file with mode: 0644]
drivers/staging/lttng/lttng-ring-buffer-client-discard.c [new file with mode: 0644]
drivers/staging/lttng/lttng-ring-buffer-client-mmap-discard.c [new file with mode: 0644]
drivers/staging/lttng/lttng-ring-buffer-client-mmap-overwrite.c [new file with mode: 0644]
drivers/staging/lttng/lttng-ring-buffer-client-overwrite.c [new file with mode: 0644]
drivers/staging/lttng/lttng-ring-buffer-client.h [new file with mode: 0644]
drivers/staging/lttng/lttng-ring-buffer-metadata-client.c [new file with mode: 0644]
drivers/staging/lttng/lttng-ring-buffer-metadata-client.h [new file with mode: 0644]
drivers/staging/lttng/lttng-ring-buffer-metadata-mmap-client.c [new file with mode: 0644]
drivers/staging/lttng/lttng-statedump-impl.c [new file with mode: 0644]
drivers/staging/lttng/lttng-syscalls.c [new file with mode: 0644]
drivers/staging/lttng/lttng-tracer-core.h [new file with mode: 0644]
drivers/staging/lttng/lttng-tracer.h [new file with mode: 0644]
drivers/staging/lttng/probes/Makefile [new file with mode: 0644]
drivers/staging/lttng/probes/define_trace.h [new file with mode: 0644]
drivers/staging/lttng/probes/lttng-events-reset.h [new file with mode: 0644]
drivers/staging/lttng/probes/lttng-events.h [new file with mode: 0644]
drivers/staging/lttng/probes/lttng-ftrace.c [new file with mode: 0644]
drivers/staging/lttng/probes/lttng-kprobes.c [new file with mode: 0644]
drivers/staging/lttng/probes/lttng-kretprobes.c [new file with mode: 0644]
drivers/staging/lttng/probes/lttng-probe-asoc.c [new file with mode: 0644]
drivers/staging/lttng/probes/lttng-probe-block.c [new file with mode: 0644]
drivers/staging/lttng/probes/lttng-probe-btrfs.c [new file with mode: 0644]
drivers/staging/lttng/probes/lttng-probe-compaction.c [new file with mode: 0644]
drivers/staging/lttng/probes/lttng-probe-ext3.c [new file with mode: 0644]
drivers/staging/lttng/probes/lttng-probe-ext4.c [new file with mode: 0644]
drivers/staging/lttng/probes/lttng-probe-gpio.c [new file with mode: 0644]
drivers/staging/lttng/probes/lttng-probe-irq.c [new file with mode: 0644]
drivers/staging/lttng/probes/lttng-probe-jbd.c [new file with mode: 0644]
drivers/staging/lttng/probes/lttng-probe-jbd2.c [new file with mode: 0644]
drivers/staging/lttng/probes/lttng-probe-kmem.c [new file with mode: 0644]
drivers/staging/lttng/probes/lttng-probe-kvm-x86-mmu.c [new file with mode: 0644]
drivers/staging/lttng/probes/lttng-probe-kvm-x86.c [new file with mode: 0644]
drivers/staging/lttng/probes/lttng-probe-kvm.c [new file with mode: 0644]
drivers/staging/lttng/probes/lttng-probe-lock.c [new file with mode: 0644]
drivers/staging/lttng/probes/lttng-probe-module.c [new file with mode: 0644]
drivers/staging/lttng/probes/lttng-probe-napi.c [new file with mode: 0644]
drivers/staging/lttng/probes/lttng-probe-net.c [new file with mode: 0644]
drivers/staging/lttng/probes/lttng-probe-power.c [new file with mode: 0644]
drivers/staging/lttng/probes/lttng-probe-printk.c [new file with mode: 0644]
drivers/staging/lttng/probes/lttng-probe-random.c [new file with mode: 0644]
drivers/staging/lttng/probes/lttng-probe-rcu.c [new file with mode: 0644]
drivers/staging/lttng/probes/lttng-probe-regmap.c [new file with mode: 0644]
drivers/staging/lttng/probes/lttng-probe-regulator.c [new file with mode: 0644]
drivers/staging/lttng/probes/lttng-probe-rpm.c [new file with mode: 0644]
drivers/staging/lttng/probes/lttng-probe-sched.c [new file with mode: 0644]
drivers/staging/lttng/probes/lttng-probe-scsi.c [new file with mode: 0644]
drivers/staging/lttng/probes/lttng-probe-signal.c [new file with mode: 0644]
drivers/staging/lttng/probes/lttng-probe-skb.c [new file with mode: 0644]
drivers/staging/lttng/probes/lttng-probe-sock.c [new file with mode: 0644]
drivers/staging/lttng/probes/lttng-probe-statedump.c [new file with mode: 0644]
drivers/staging/lttng/probes/lttng-probe-sunrpc.c [new file with mode: 0644]
drivers/staging/lttng/probes/lttng-probe-timer.c [new file with mode: 0644]
drivers/staging/lttng/probes/lttng-probe-udp.c [new file with mode: 0644]
drivers/staging/lttng/probes/lttng-probe-user.c [new file with mode: 0644]
drivers/staging/lttng/probes/lttng-probe-user.h [new file with mode: 0644]
drivers/staging/lttng/probes/lttng-probe-vmscan.c [new file with mode: 0644]
drivers/staging/lttng/probes/lttng-probe-workqueue.c [new file with mode: 0644]
drivers/staging/lttng/probes/lttng-probe-writeback.c [new file with mode: 0644]
drivers/staging/lttng/probes/lttng-type-list.h [new file with mode: 0644]
drivers/staging/lttng/probes/lttng-types.c [new file with mode: 0644]
drivers/staging/lttng/probes/lttng-types.h [new file with mode: 0644]
drivers/staging/lttng/probes/lttng.h [new file with mode: 0644]
drivers/staging/lttng/wrapper/compiler.h [new file with mode: 0644]
drivers/staging/lttng/wrapper/fdtable.c [new file with mode: 0644]
drivers/staging/lttng/wrapper/fdtable.h [new file with mode: 0644]
drivers/staging/lttng/wrapper/ftrace.h [new file with mode: 0644]
drivers/staging/lttng/wrapper/inline_memcpy.h [new file with mode: 0644]
drivers/staging/lttng/wrapper/irq.h [new file with mode: 0644]
drivers/staging/lttng/wrapper/irqdesc.c [new file with mode: 0644]
drivers/staging/lttng/wrapper/irqdesc.h [new file with mode: 0644]
drivers/staging/lttng/wrapper/kallsyms.h [new file with mode: 0644]
drivers/staging/lttng/wrapper/nsproxy.h [new file with mode: 0644]
drivers/staging/lttng/wrapper/perf.h [new file with mode: 0644]
drivers/staging/lttng/wrapper/poll.h [new file with mode: 0644]
drivers/staging/lttng/wrapper/random.c [new file with mode: 0644]
drivers/staging/lttng/wrapper/random.h [new file with mode: 0644]
drivers/staging/lttng/wrapper/ringbuffer/api.h [new file with mode: 0644]
drivers/staging/lttng/wrapper/ringbuffer/backend.h [new file with mode: 0644]
drivers/staging/lttng/wrapper/ringbuffer/backend_internal.h [new file with mode: 0644]
drivers/staging/lttng/wrapper/ringbuffer/backend_types.h [new file with mode: 0644]
drivers/staging/lttng/wrapper/ringbuffer/config.h [new file with mode: 0644]
drivers/staging/lttng/wrapper/ringbuffer/frontend.h [new file with mode: 0644]
drivers/staging/lttng/wrapper/ringbuffer/frontend_api.h [new file with mode: 0644]
drivers/staging/lttng/wrapper/ringbuffer/frontend_internal.h [new file with mode: 0644]
drivers/staging/lttng/wrapper/ringbuffer/frontend_types.h [new file with mode: 0644]
drivers/staging/lttng/wrapper/ringbuffer/iterator.h [new file with mode: 0644]
drivers/staging/lttng/wrapper/ringbuffer/nohz.h [new file with mode: 0644]
drivers/staging/lttng/wrapper/ringbuffer/vatomic.h [new file with mode: 0644]
drivers/staging/lttng/wrapper/ringbuffer/vfs.h [new file with mode: 0644]
drivers/staging/lttng/wrapper/spinlock.h [new file with mode: 0644]
drivers/staging/lttng/wrapper/splice.c [new file with mode: 0644]
drivers/staging/lttng/wrapper/splice.h [new file with mode: 0644]
drivers/staging/lttng/wrapper/trace-clock.h [new file with mode: 0644]
drivers/staging/lttng/wrapper/tracepoint.h [new file with mode: 0644]
drivers/staging/lttng/wrapper/uuid.h [new file with mode: 0644]
drivers/staging/lttng/wrapper/vmalloc.h [new file with mode: 0644]
drivers/staging/lttng/wrapper/writeback.h [new file with mode: 0644]
drivers/staging/media/davinci_vpfe/vpfe_video.c
drivers/thermal/rcar_thermal.c
drivers/tty/serial/sh-sci.c
drivers/usb/host/Kconfig
drivers/usb/host/Makefile
drivers/usb/host/xhci-mvebu.c [new file with mode: 0644]
drivers/usb/host/xhci-mvebu.h [new file with mode: 0644]
drivers/usb/host/xhci-pci.c
drivers/usb/host/xhci-plat.c
drivers/usb/host/xhci-rcar.c [new file with mode: 0644]
drivers/usb/host/xhci-rcar.h [new file with mode: 0644]
drivers/usb/host/xhci.c
drivers/usb/host/xhci.h
drivers/usb/renesas_usbhs/Kconfig
drivers/usb/renesas_usbhs/Makefile
drivers/usb/renesas_usbhs/common.c
drivers/usb/renesas_usbhs/common.h
drivers/usb/renesas_usbhs/fifo.c
drivers/usb/renesas_usbhs/mod.c
drivers/usb/renesas_usbhs/mod_gadget.c
drivers/usb/renesas_usbhs/pipe.c
drivers/usb/renesas_usbhs/pipe.h
drivers/usb/renesas_usbhs/rcar2.c [new file with mode: 0644]
drivers/usb/renesas_usbhs/rcar2.h [new file with mode: 0644]
drivers/watchdog/ep93xx_wdt.c
drivers/watchdog/iTCO_wdt.c
drivers/watchdog/ibmasr.c
drivers/watchdog/pc87413_wdt.c
drivers/watchdog/softdog.c
drivers/watchdog/w83697hf_wdt.c
include/asm-generic/io.h
include/asm-generic/iomap.h
include/dt-bindings/clock/r7s72100-clock.h [new file with mode: 0644]
include/dt-bindings/clock/r8a7740-clock.h [new file with mode: 0644]
include/dt-bindings/clock/r8a7779-clock.h [new file with mode: 0644]
include/dt-bindings/clock/r8a7790-clock.h
include/dt-bindings/clock/r8a7791-clock.h
include/dt-bindings/clock/r8a7794-clock.h [new file with mode: 0644]
include/linux/clk/shmobile.h
include/linux/cpufreq.h
include/linux/device.h
include/linux/i2c.h
include/linux/io.h
include/linux/mfd/lpc_ich.h
include/linux/mfd/tmio.h
include/linux/mmc/host.h
include/linux/of.h
include/linux/of_fdt.h
include/linux/of_graph.h [new file with mode: 0644]
include/linux/pinctrl/pinconf-generic.h
include/linux/platform_data/dma-rcar-audmapp.h [new file with mode: 0644]
include/linux/platform_data/rcar-du.h
include/linux/pm_runtime.h
include/linux/pwm.h
include/linux/serial_sci.h
include/linux/sh_clk.h
include/linux/sh_dma.h
include/linux/sh_timer.h
include/linux/shdma-base.h
include/linux/spi/rspi.h
include/linux/spi/sh_msiof.h
include/linux/spi/spi.h
include/linux/usb/renesas_usbhs.h
include/linux/usb/xhci_pdriver.h [new file with mode: 0644]
include/media/v4l2-of.h
include/media/videobuf2-core.h
include/sound/rcar_snd.h
include/sound/simple_card.h
include/sound/soc-dai.h
include/sound/soc.h
include/uapi/linux/videodev2.h
lib/Kconfig
lib/devres.c
lib/iomap.c
sound/isa/Kconfig
sound/pci/Kconfig
sound/soc/codecs/ak4642.c
sound/soc/generic/simple-card.c
sound/soc/sh/Kconfig
sound/soc/sh/fsi.c
sound/soc/sh/rcar/Makefile
sound/soc/sh/rcar/adg.c
sound/soc/sh/rcar/core.c
sound/soc/sh/rcar/dvc.c [new file with mode: 0644]
sound/soc/sh/rcar/gen.c
sound/soc/sh/rcar/rsnd.h
sound/soc/sh/rcar/scu.c [deleted file]
sound/soc/sh/rcar/src.c [new file with mode: 0644]
sound/soc/sh/rcar/ssi.c
sound/soc/soc-core.c

diff --git a/Documentation/.gitignore b/Documentation/.gitignore
deleted file mode 100644 (file)
index bcd907b..0000000
+++ /dev/null
@@ -1,7 +0,0 @@
-filesystems/dnotify_test
-laptops/dslm
-timers/hpet_example
-vm/hugepage-mmap
-vm/hugepage-shm
-vm/map_hugetlb
-
index 1d27f0a..494da94 100644 (file)
@@ -174,7 +174,7 @@ FILENAME = \
 DOCUMENTED = \
        -e "s/\(enum *\)v4l2_mpeg_cx2341x_video_\([a-z]*_spatial_filter_type\)/\1<link linkend=\"\2\">v4l2_mpeg_cx2341x_video_\2<\/link>/g" \
        -e "s/\(\(enum\|struct\) *\)\(v4l2_[a-zA-Z0-9_]*\)/\1<link linkend=\"\3\">\3<\/link>/g" \
-       -e "s/\(V4L2_PIX_FMT_[A-Z0-9_]\+\) /<link linkend=\"\1\">\1<\/link> /g" \
+       -e "s/\(V4L2_PIX_FMT_[A-Z0-9_]\+\)\(\s\+v4l2_fourcc\)/<link linkend=\"\1\">\1<\/link>\2/g" \
        -e ":a;s/\(linkend=\".*\)_\(.*\">\)/\1-\2/;ta" \
        -e "s/v4l2\-mpeg\-vbi\-ITV0/v4l2-mpeg-vbi-itv0-1/g"
 
index a5a3188..066800d 100644 (file)
@@ -398,14 +398,17 @@ to work.</entry>
          <row id="v4l2-alpha-component">
            <entry><constant>V4L2_CID_ALPHA_COMPONENT</constant></entry>
            <entry>integer</entry>
-           <entry> Sets the alpha color component on the capture device or on
-           the capture buffer queue of a mem-to-mem device. When a mem-to-mem
-           device produces frame format that includes an alpha component
+           <entry>Sets the alpha color component. When a capture device (or
+           capture queue of a mem-to-mem device) produces a frame format that
+           includes an alpha component
            (e.g. <link linkend="rgb-formats">packed RGB image formats</link>)
-           and the alpha value is not defined by the mem-to-mem input data
-           this control lets you select the alpha component value of all
-           pixels. It is applicable to any pixel format that contains an alpha
-           component.
+           and the alpha value is not defined by the device or the mem-to-mem
+           input data this control lets you select the alpha component value of
+           all pixels. When an output device (or output queue of a mem-to-mem
+           device) consumes a frame format that doesn't include an alpha
+           component and the device supports alpha channel processing this
+           control lets you set the alpha component value of all pixels for
+           further processing in the device.
            </entry>
          </row>
          <row>
index 72d72bd..75882a4 100644 (file)
@@ -103,9 +103,34 @@ see <xref linkend="colorspaces" />.</entry>
        <row>
          <entry>__u32</entry>
          <entry><structfield>priv</structfield></entry>
-         <entry>Reserved for custom (driver defined) additional
-information about formats. When not used drivers and applications must
-set this field to zero.</entry>
+         <entry><para>This field indicates whether the remaining fields of the
+<structname>v4l2_pix_format</structname> structure, also called the extended
+fields, are valid. When set to <constant>V4L2_PIX_FMT_PRIV_MAGIC</constant>, it
+indicates that the extended fields have been correctly initialized. When set to
+any other value it indicates that the extended fields contain undefined values.
+</para>
+<para>Applications that wish to use the pixel format extended fields must first
+ensure that the feature is supported by querying the device for the
+<link linkend="querycap"><constant>V4L2_CAP_EXT_PIX_FORMAT</constant></link>
+capability. If the capability isn't set the pixel format extended fields are not
+supported and using the extended fields will lead to undefined results.</para>
+<para>To use the extended fields, applications must set the
+<structfield>priv</structfield> field to
+<constant>V4L2_PIX_FMT_PRIV_MAGIC</constant>, initialize all the extended fields
+and zero the unused bytes of the <structname>v4l2_format</structname>
+<structfield>raw_data</structfield> field.</para>
+<para>When the <structfield>priv</structfield> field isn't set to
+<constant>V4L2_PIX_FMT_PRIV_MAGIC</constant> drivers must act as if all the
+extended fields were set to zero. On return drivers must set the
+<structfield>priv</structfield> field to
+<constant>V4L2_PIX_FMT_PRIV_MAGIC</constant> and all the extended field to
+applicable values.</para></entry>
+       </row>
+       <row>
+         <entry>__u32</entry>
+         <entry><structfield>flags</structfield></entry>
+           <entry>Flags set by the application or driver, see <xref
+linkend="format-flags" />.</entry>
        </row>
       </tbody>
     </tgroup>
@@ -192,9 +217,15 @@ codes can be used.</entry>
           and the number of valid entries in the
           <structfield>plane_fmt</structfield> array.</entry>
         </row>
+       <row>
+         <entry>__u8</entry>
+         <entry><structfield>flags</structfield></entry>
+         <entry>Flags set by the application or driver, see <xref
+linkend="format-flags" />.</entry>
+       </row>
         <row>
           <entry>__u8</entry>
-          <entry><structfield>reserved[11]</structfield></entry>
+          <entry><structfield>reserved[10]</structfield></entry>
           <entry>Reserved for future extensions. Should be zeroed by the
            application.</entry>
         </row>
@@ -1040,4 +1071,18 @@ concatenated to form the JPEG stream. </para>
        </tbody>
       </tgroup>
     </table>
+
+    <table frame="none" pgwide="1" id="format-flags">
+      <title>Format Flags</title>
+      <tgroup cols="3">
+       &cs-def;
+       <tbody valign="top">
+         <row>
+           <entry><constant>V4L2_PIX_FMT_FLAG_PREMUL_ALPHA</constant></entry>
+           <entry>0x00000001</entry>
+           <entry>The pixel values are premultiplied by the alpha channel value.</entry>
+         </row>
+       </tbody>
+      </tgroup>
+    </table>
   </section>
diff --git a/Documentation/arm/SH-Mobile/.gitignore b/Documentation/arm/SH-Mobile/.gitignore
new file mode 100644 (file)
index 0000000..c928dbf
--- /dev/null
@@ -0,0 +1 @@
+vrl4
index e8a1913..4cbbba5 100644 (file)
@@ -77,7 +77,7 @@ struct hdr {
 
 #define ROUND_UP(x)    ((x + ALIGN - 1) & ~(ALIGN - 1))
 
-ssize_t do_read(int fd, void *buf, size_t count)
+static ssize_t do_read(int fd, void *buf, size_t count)
 {
        size_t offset = 0;
        ssize_t l;
@@ -98,7 +98,7 @@ ssize_t do_read(int fd, void *buf, size_t count)
        return offset;
 }
 
-ssize_t do_write(int fd, const void *buf, size_t count)
+static ssize_t do_write(int fd, const void *buf, size_t count)
 {
        size_t offset = 0;
        ssize_t l;
@@ -117,7 +117,7 @@ ssize_t do_write(int fd, const void *buf, size_t count)
        return offset;
 }
 
-ssize_t write_zero(int fd, size_t len)
+static ssize_t write_zero(int fd, size_t len)
 {
        size_t i = len;
 
index ce0666e..0060d76 100644 (file)
@@ -92,7 +92,3 @@ values:
 cpu    - number of the affected CPU
 old    - old frequency
 new    - new frequency
-
-If the cpufreq core detects the frequency has changed while the system
-was suspended, these notifiers are called with CPUFREQ_RESUMECHANGE as
-second argument.
index 8b1a445..d3cb4d3 100644 (file)
@@ -222,3 +222,22 @@ is the corresponding frequency table helper for the ->target
 stage. Just pass the values to this function, and the unsigned int
 index returns the number of the frequency table entry which contains
 the frequency the CPU shall be set to.
+
+The following macros can be used as iterators over cpufreq_frequency_table:
+
+cpufreq_for_each_entry(pos, table) - iterates over all entries of frequency
+table.
+
+cpufreq-for_each_valid_entry(pos, table) - iterates over all entries,
+excluding CPUFREQ_ENTRY_INVALID frequencies.
+Use arguments "pos" - a cpufreq_frequency_table * as a loop cursor and
+"table" - the cpufreq_frequency_table * you want to iterate over.
+
+For example:
+
+       struct cpufreq_frequency_table *pos, *driver_freq_table;
+
+       cpufreq_for_each_entry(pos, driver_freq_table) {
+               /* Do something with pos */
+               pos->frequency = ...
+       }
index 7c52c29..700e7aa 100644 (file)
@@ -44,6 +44,23 @@ For example:
   clocks by index. The names should reflect the clock output signal
   names for the device.
 
+clock-indices:    If the identifyng number for the clocks in the node
+                  is not linear from zero, then the this mapping allows
+                  the mapping of identifiers into the clock-output-names
+                  array.
+
+For example, if we have two clocks <&oscillator 1> and <&oscillator 3>:
+
+       oscillator {
+               compatible = "myclocktype";
+               #clock-cells = <1>;
+               clock-indices = <1>, <3>;
+               clock-output-names = "clka", "clkb";
+       }
+
+       This ensures we do not have any empty nodes in clock-output-names
+
+
 ==Clock consumers==
 
 Required properties:
index 5992dce..a5f5223 100644 (file)
@@ -10,8 +10,13 @@ index in the group, from 0 to 31.
 Required Properties:
 
   - compatible: Must be one of the following
+    - "renesas,r7s72100-mstp-clocks" for R7S72100 (RZ) MSTP gate clocks
+    - "renesas,r8a7740-mstp-clocks" for R8A7740 (R-Mobile A1) MSTP gate clocks
+    - "renesas,r8a7779-mstp-clocks" for R8A7779 (R-Car H1) MSTP gate clocks
     - "renesas,r8a7790-mstp-clocks" for R8A7790 (R-Car H2) MSTP gate clocks
     - "renesas,r8a7791-mstp-clocks" for R8A7791 (R-Car M2) MSTP gate clocks
+    - "renesas,r8a7794-mstp-clocks" for R8A7794 (R-Car E2) MSTP gate clocks
+    - "renesas,sh73a0-mstp-clocks" for SH73A0 (SH-MobileAG5) MSTP gate clocks
     - "renesas,cpg-mstp-clock" for generic MSTP gate clocks
   - reg: Base address and length of the I/O mapped registers used by the MSTP
     clocks. The first register is the clock control register and is mandatory.
@@ -43,7 +48,7 @@ Example
                clock-output-names =
                        "tpu0", "mmcif1", "sdhi3", "sdhi2",
                         "sdhi1", "sdhi0", "mmcif0";
-               renesas,clock-indices = <
+               clock-indices = <
                        R8A7790_CLK_TPU0 R8A7790_CLK_MMCIF1 R8A7790_CLK_SDHI3
                        R8A7790_CLK_SDHI2 R8A7790_CLK_SDHI1 R8A7790_CLK_SDHI0
                        R8A7790_CLK_MMCIF0
diff --git a/Documentation/devicetree/bindings/clock/renesas,r8a7740-cpg-clocks.txt b/Documentation/devicetree/bindings/clock/renesas,r8a7740-cpg-clocks.txt
new file mode 100644 (file)
index 0000000..2c03302
--- /dev/null
@@ -0,0 +1,41 @@
+These bindings should be considered EXPERIMENTAL for now.
+
+* Renesas R8A7740  Clock Pulse Generator (CPG)
+
+The CPG generates core clocks for the R8A7740 SoC. It includes three PLLs
+and several fixed ratio and variable ratio dividers.
+
+Required Properties:
+
+  - compatible: Must be "renesas,r8a7740-cpg-clocks"
+
+  - reg: Base address and length of the memory resource used by the CPG
+
+  - clocks: Reference to the three parent clocks
+  - #clock-cells: Must be 1
+  - clock-output-names: The names of the clocks. Supported clocks are
+    "system", "pllc0", "pllc1", "pllc2", "r", "usb24s", "i", "zg", "b",
+    "m1", "hp", "hpp", "usbp", "s", "zb", "m3", and "cp".
+
+  - renesas,mode: board-specific settings of the MD_CK* bits
+
+
+Example
+-------
+
+cpg_clocks: cpg_clocks@e6150000 {
+        compatible = "renesas,r8a7740-cpg-clocks";
+        reg = <0xe6150000 0x10000>;
+        clocks = <&extal1_clk>, <&extal2_clk>, <&extalr_clk>;
+        #clock-cells = <1>;
+        clock-output-names = "system", "pllc0", "pllc1",
+                             "pllc2", "r",
+                             "usb24s",
+                             "i", "zg", "b", "m1", "hp",
+                             "hpp", "usbp", "s", "zb", "m3",
+                             "cp";
+};
+
+&cpg_clocks {
+       renesas,mode = <0x05>;
+};
diff --git a/Documentation/devicetree/bindings/clock/renesas,r8a7779-cpg-clocks.txt b/Documentation/devicetree/bindings/clock/renesas,r8a7779-cpg-clocks.txt
new file mode 100644 (file)
index 0000000..ed3c8cb
--- /dev/null
@@ -0,0 +1,27 @@
+* Renesas R8A7779 Clock Pulse Generator (CPG)
+
+The CPG generates core clocks for the R8A7779. It includes one PLL and
+several fixed ratio dividers
+
+Required Properties:
+
+  - compatible: Must be "renesas,r8a7779-cpg-clocks"
+  - reg: Base address and length of the memory resource used by the CPG
+
+  - clocks: Reference to the parent clock
+  - #clock-cells: Must be 1
+  - clock-output-names: The names of the clocks. Supported clocks are "plla",
+    "z", "zs", "s", "s1", "p", "b", "out".
+
+
+Example
+-------
+
+       cpg_clocks: cpg_clocks@ffc80000 {
+               compatible = "renesas,r8a7779-cpg-clocks";
+               reg = <0 0xffc80000 0 0x30>;
+               clocks = <&extal_clk>;
+               #clock-cells = <1>;
+               clock-output-names = "plla", "z", "zs", "s", "s1", "p",
+                                    "b", "out";
+       };
diff --git a/Documentation/devicetree/bindings/clock/renesas,rz-cpg-clocks.txt b/Documentation/devicetree/bindings/clock/renesas,rz-cpg-clocks.txt
new file mode 100644 (file)
index 0000000..98a2574
--- /dev/null
@@ -0,0 +1,29 @@
+* Renesas RZ Clock Pulse Generator (CPG)
+
+The CPG generates core clocks for the RZ SoCs. It includes the PLL, variable
+CPU and GPU clocks, and several fixed ratio dividers.
+
+Required Properties:
+
+  - compatible: Must be one of
+    - "renesas,r7s72100-cpg-clocks" for the r7s72100 CPG
+    - "renesas,rz-cpg-clocks" for the generic RZ CPG
+  - reg: Base address and length of the memory resource used by the CPG
+  - clocks: References to possible parent clocks. Order must match clock modes
+    in the datasheet. For the r7s72100, this is extal, usb_x1.
+  - #clock-cells: Must be 1
+  - clock-output-names: The names of the clocks. Supported clocks are "pll",
+    "i", and "g"
+
+
+Example
+-------
+
+       cpg_clocks: cpg_clocks@fcfe0000 {
+               #clock-cells = <1>;
+               compatible = "renesas,r7s72100-cpg-clocks",
+                            "renesas,rz-cpg-clocks";
+               reg = <0xfcfe0000 0x18>;
+               clocks = <&extal_clk>, <&usb_x1_clk>;
+               clock-output-names = "pll", "i", "g";
+       };
index f61cef7..941a26a 100644 (file)
@@ -21,6 +21,12 @@ Required Properties:
     GPIO_ACTIVE_HIGH and GPIO_ACTIVE_LOW flags are supported.
   - gpio-ranges: Range of pins managed by the GPIO controller.
 
+Optional properties:
+
+  - clocks: Must contain a reference to the functional clock.  The property is
+    mandatory if the hardware implements a controllable functional clock for
+    the GPIO instance.
+
 Please refer to gpio.txt in this directory for details of gpio-ranges property
 and the common GPIO bindings used by client devices.
 
index 897cfcd..16b3e07 100644 (file)
@@ -6,6 +6,10 @@ Required properties:
        "renesas,i2c-r8a7778"
        "renesas,i2c-r8a7779"
        "renesas,i2c-r8a7790"
+       "renesas,i2c-r8a7791"
+       "renesas,i2c-r8a7792"
+       "renesas,i2c-r8a7793"
+       "renesas,i2c-r8a7794"
 - reg: physical base address of the controller and length of memory mapped
   region.
 - interrupts: interrupt specifier.
@@ -13,11 +17,16 @@ Required properties:
 Optional properties:
 - clock-frequency: desired I2C bus clock frequency in Hz. The absence of this
   propoerty indicates the default frequency 100 kHz.
+- clocks: clock specifier.
 
 Examples :
 
-i2c0: i2c@e6500000 {
-       compatible = "renesas,i2c-rcar-h2";
-       reg = <0 0xe6500000 0 0x428>;
-       interrupts = <0 174 0x4>;
+i2c0: i2c@e6508000 {
+       #address-cells = <1>;
+       #size-cells = <0>;
+       compatible = "renesas,i2c-r8a7791";
+       reg = <0 0xe6508000 0 0x40>;
+       interrupts = <0 287 IRQ_TYPE_LEVEL_HIGH>;
+       clocks = <&mstp9_clks R8A7791_CLK_I2C0>;
+       clock-frequency = <400000>;
 };
index 1a1ac2e..858267c 100644 (file)
@@ -29,7 +29,7 @@ dallas,ds1775         Tiny Digital Thermometer and Thermostat
 dallas,ds3232          Extremely Accurate I²C RTC with Integrated Crystal and SRAM
 dallas,ds4510          CPU Supervisor with Nonvolatile Memory and Programmable I/O
 dallas,ds75            Digital Thermometer and Thermostat
-dialog,da9053          DA9053: flexible system level PMIC with multicore support
+dlg,da9053             DA9053: flexible system level PMIC with multicore support
 epson,rx8025           High-Stability. I2C-Bus INTERFACE REAL TIME CLOCK MODULE
 epson,rx8581           I2C-BUS INTERFACE REAL TIME CLOCK MODULE
 fsl,mag3110            MAG3110: Xtrinsic High Accuracy, 3D Magnetometer
diff --git a/Documentation/devicetree/bindings/media/rcar_vin.txt b/Documentation/devicetree/bindings/media/rcar_vin.txt
new file mode 100644 (file)
index 0000000..ba61782
--- /dev/null
@@ -0,0 +1,86 @@
+Renesas RCar Video Input driver (rcar_vin)
+------------------------------------------
+
+The rcar_vin device provides video input capabilities for the Renesas R-Car
+family of devices. The current blocks are always slaves and suppot one input
+channel which can be either RGB, YUYV or BT656.
+
+ - compatible: Must be one of the following
+   - "renesas,vin-r8a7791" for the R8A7791 device
+   - "renesas,vin-r8a7790" for the R8A7790 device
+   - "renesas,vin-r8a7779" for the R8A7779 device
+   - "renesas,vin-r8a7778" for the R8A7778 device
+ - reg: the register base and size for the device registers
+ - interrupts: the interrupt for the device
+ - clocks: Reference to the parent clock
+
+Additionally, an alias named vinX will need to be created to specify
+which video input device this is.
+
+The per-board settings:
+ - port sub-node describing a single endpoint connected to the vin
+   as described in video-interfaces.txt[1]. Only the first one will
+   be considered as each vin interface has one input port.
+
+   These settings are used to work out video input format and widths
+   into the system.
+
+
+Device node example
+-------------------
+
+       aliases {
+              vin0 = &vin0;
+       };
+
+        vin0: vin@0xe6ef0000 {
+                compatible = "renesas,vin-r8a7790";
+                clocks = <&mstp8_clks R8A7790_CLK_VIN0>;
+                reg = <0 0xe6ef0000 0 0x1000>;
+                interrupts = <0 188 IRQ_TYPE_LEVEL_HIGH>;
+                status = "disabled";
+        };
+
+Board setup example (vin1 composite video input)
+------------------------------------------------
+
+&i2c2   {
+        status = "ok";
+        pinctrl-0 = <&i2c2_pins>;
+        pinctrl-names = "default";
+
+        adv7180@20 {
+                compatible = "adi,adv7180";
+                reg = <0x20>;
+                remote = <&vin1>;
+
+                port {
+                        adv7180: endpoint {
+                                bus-width = <8>;
+                                remote-endpoint = <&vin1ep0>;
+                        };
+                };
+        };
+};
+
+/* composite video input */
+&vin1 {
+        pinctrl-0 = <&vin1_pins>;
+        pinctrl-names = "default";
+
+        status = "ok";
+
+        port {
+                #address-cells = <1>;
+                #size-cells = <0>;
+
+                vin1ep0: endpoint {
+                        remote-endpoint = <&adv7180>;
+                        bus-width = <8>;
+                };
+        };
+};
+
+
+
+[1] video-interfaces.txt common video media interface
diff --git a/Documentation/devicetree/bindings/media/renesas,vsp1.txt b/Documentation/devicetree/bindings/media/renesas,vsp1.txt
new file mode 100644 (file)
index 0000000..87fe08a
--- /dev/null
@@ -0,0 +1,43 @@
+* Renesas VSP1 Video Processing Engine
+
+The VSP1 is a video processing engine that supports up-/down-scaling, alpha
+blending, color space conversion and various other image processing features.
+It can be found in the Renesas R-Car second generation SoCs.
+
+Required properties:
+
+  - compatible: Must contain "renesas,vsp1"
+
+  - reg: Base address and length of the registers block for the VSP1.
+  - interrupts: VSP1 interrupt specifier.
+  - clocks: A phandle + clock-specifier pair for the VSP1 functional clock.
+
+  - renesas,#rpf: Number of Read Pixel Formatter (RPF) modules in the VSP1.
+  - renesas,#uds: Number of Up Down Scaler (UDS) modules in the VSP1.
+  - renesas,#wpf: Number of Write Pixel Formatter (WPF) modules in the VSP1.
+
+
+Optional properties:
+
+  - renesas,has-lif: Boolean, indicates that the LCD Interface (LIF) module is
+    available.
+  - renesas,has-lut: Boolean, indicates that the Look Up Table (LUT) module is
+    available.
+  - renesas,has-sru: Boolean, indicates that the Super Resolution Unit (SRU)
+    module is available.
+
+
+Example: R8A7790 (R-Car H2) VSP1-S node
+
+       vsp1@fe928000 {
+               compatible = "renesas,vsp1";
+               reg = <0 0xfe928000 0 0x8000>;
+               interrupts = <0 267 IRQ_TYPE_LEVEL_HIGH>;
+               clocks = <&mstp1_clks R8A7790_CLK_VSP1_S>;
+
+               renesas,has-lut;
+               renesas,has-sru;
+               renesas,#rpf = <5>;
+               renesas,#uds = <3>;
+               renesas,#wpf = <4>;
+       };
index 6a2a116..400b640 100644 (file)
@@ -18,6 +18,10 @@ Required properties:
                "renesas,sdhi-r8a7778" - SDHI IP on R8A7778 SoC
                "renesas,sdhi-r8a7779" - SDHI IP on R8A7779 SoC
                "renesas,sdhi-r8a7790" - SDHI IP on R8A7790 SoC
+               "renesas,sdhi-r8a7791" - SDHI IP on R8A7791 SoC
+               "renesas,sdhi-r8a7792" - SDHI IP on R8A7792 SoC
+               "renesas,sdhi-r8a7793" - SDHI IP on R8A7793 SoC
+               "renesas,sdhi-r8a7794" - SDHI IP on R8A7794 SoC
 
 Optional properties:
 - toshiba,mmc-wrprotect-disable: write-protect detection is unavailable
diff --git a/Documentation/devicetree/bindings/net/sh_eth.txt b/Documentation/devicetree/bindings/net/sh_eth.txt
new file mode 100644 (file)
index 0000000..34d4db1
--- /dev/null
@@ -0,0 +1,56 @@
+* Renesas Electronics SH EtherMAC
+
+This file provides information on what the device node for the SH EtherMAC
+interface contains.
+
+Required properties:
+- compatible: "renesas,gether-r8a7740" if the device is a part of R8A7740 SoC.
+             "renesas,ether-r8a7778"  if the device is a part of R8A7778 SoC.
+             "renesas,ether-r8a7779"  if the device is a part of R8A7779 SoC.
+             "renesas,ether-r8a7790"  if the device is a part of R8A7790 SoC.
+             "renesas,ether-r8a7791"  if the device is a part of R8A7791 SoC.
+             "renesas,ether-r8a7794"  if the device is a part of R8A7794 SoC.
+             "renesas,ether-r7s72100" if the device is a part of R7S72100 SoC.
+- reg: offset and length of (1) the E-DMAC/feLic register block (required),
+       (2) the TSU register block (optional).
+- interrupts: interrupt specifier for the sole interrupt.
+- phy-mode: see ethernet.txt file in the same directory.
+- phy-handle: see ethernet.txt file in the same directory.
+- #address-cells: number of address cells for the MDIO bus, must be equal to 1.
+- #size-cells: number of size cells on the MDIO bus, must be equal to 0.
+- clocks: clock phandle and specifier pair.
+- pinctrl-0: phandle, referring to a default pin configuration node.
+
+Optional properties:
+- interrupt-parent: the phandle for the interrupt controller that services
+                   interrupts for this device.
+- pinctrl-names: pin configuration state name ("default").
+- renesas,no-ether-link: boolean, specify when a board does not provide a proper
+                        Ether LINK signal.
+- renesas,ether-link-active-low: boolean, specify when the Ether LINK signal is
+                                active-low instead of normal active-high.
+
+Example (Lager board):
+
+       ethernet@ee700000 {
+               compatible = "renesas,ether-r8a7790";
+               reg = <0 0xee700000 0 0x400>;
+               interrupt-parent = <&gic>;
+               interrupts = <0 162 IRQ_TYPE_LEVEL_HIGH>;
+               clocks = <&mstp8_clks R8A7790_CLK_ETHER>;
+               phy-mode = "rmii";
+               phy-handle = <&phy1>;
+               pinctrl-0 = <&ether_pins>;
+               pinctrl-names = "default";
+               renesas,ether-link-active-low;
+               #address-cells = <1>;
+               #size-cells = <0>;
+
+               phy1: ethernet-phy@1 {
+                       reg = <1>;
+                       interrupt-parent = <&irqc0>;
+                       interrupts = <0 IRQ_TYPE_LEVEL_LOW>;
+                       pinctrl-0 = <&phy1_pins>;
+                       pinctrl-names = "default";
+               };
+       };
diff --git a/Documentation/devicetree/bindings/pci/rcar-pci.txt b/Documentation/devicetree/bindings/pci/rcar-pci.txt
new file mode 100644 (file)
index 0000000..29d3b98
--- /dev/null
@@ -0,0 +1,47 @@
+* Renesas RCar PCIe interface
+
+Required properties:
+- compatible: should contain one of the following
+       "renesas,pcie-r8a7779", "renesas,pcie-r8a7790", "renesas,pcie-r8a7791"
+- reg: base address and length of the pcie controller registers.
+- #address-cells: set to <3>
+- #size-cells: set to <2>
+- bus-range: PCI bus numbers covered
+- device_type: set to "pci"
+- ranges: ranges for the PCI memory and I/O regions.
+- dma-ranges: ranges for the inbound memory regions.
+- interrupts: two interrupt sources for MSI interrupts, followed by interrupt
+       source for hardware related interrupts (e.g. link speed change).
+- #interrupt-cells: set to <1>
+- interrupt-map-mask and interrupt-map: standard PCI properties
+       to define the mapping of the PCIe interface to interrupt
+       numbers.
+- clocks: from common clock binding: clock specifiers for the PCIe controller
+       and PCIe bus clocks.
+- clock-names: from common clock binding: should be "pcie" and "pcie_bus".
+
+Example:
+
+SoC specific DT Entry:
+
+       pcie: pcie@fe000000 {
+               compatible = "renesas,pcie-r8a7791";
+               reg = <0 0xfe000000 0 0x80000>;
+               #address-cells = <3>;
+               #size-cells = <2>;
+               bus-range = <0x00 0xff>;
+               device_type = "pci";
+               ranges = <0x01000000 0 0x00000000 0 0xfe100000 0 0x00100000
+                         0x02000000 0 0xfe200000 0 0xfe200000 0 0x00200000
+                         0x02000000 0 0x30000000 0 0x30000000 0 0x08000000
+                         0x42000000 0 0x38000000 0 0x38000000 0 0x08000000>;
+               dma-ranges = <0x42000000 0 0x40000000 0 0x40000000 0 0x40000000
+                             0x42000000 2 0x00000000 2 0x00000000 0 0x40000000>;
+               interrupts = <0 116 4>, <0 117 4>, <0 118 4>;
+               #interrupt-cells = <1>;
+               interrupt-map-mask = <0 0 0 0>;
+               interrupt-map = <0 0 0 0 &gic 0 116 4>;
+               clocks = <&mstp3_clks R8A7791_CLK_PCIE>, <&pcie_bus_clk>;
+               clock-names = "pcie", "pcie_bus";
+               status = "disabled";
+       };
index 4414163..fa40a17 100644 (file)
@@ -156,6 +156,7 @@ input-disable               - disable input on pin (no effect on output)
 input-schmitt-enable   - enable schmitt-trigger mode
 input-schmitt-disable  - disable schmitt-trigger mode
 input-debounce         - debounce mode with debound time X
+power-source           - select between different power supplies
 low-power-enable       - enable low power mode
 low-power-disable      - disable low power mode
 output-low             - set the pin to output mode with low level
index 35d2e1f..daef6fa 100644 (file)
@@ -15,6 +15,7 @@ Required Properties:
     - "renesas,pfc-r8a7778": for R8A7778 (R-Mobile M1) compatible pin-controller.
     - "renesas,pfc-r8a7779": for R8A7779 (R-Car H1) compatible pin-controller.
     - "renesas,pfc-r8a7790": for R8A7790 (R-Car H2) compatible pin-controller.
+    - "renesas,pfc-r8a7791": for R8A7791 (R-Car M2) compatible pin-controller.
     - "renesas,pfc-sh7372": for SH7372 (SH-Mobile AP4) compatible pin-controller.
     - "renesas,pfc-sh73a0": for SH73A0 (SH-Mobile AG5) compatible pin-controller.
 
index f120f22..3297c53 100644 (file)
@@ -2,7 +2,7 @@
 
 Required properties:
 
-- compatible:  must be "diasemi,da9210"
+- compatible:  must be "dlg,da9210"
 - reg:         the i2c slave address of the regulator. It should be 0x68.
 
 Any standard regulator properties can be used to configure the single da9210
@@ -11,7 +11,7 @@ DCDC.
 Example:
 
        da9210@68 {
-               compatible = "diasemi,da9210";
+               compatible = "dlg,da9210";
                reg = <0x68>;
 
                regulator-min-microvolt = <900000>;
index 63c6598..e5cac1e 100644 (file)
@@ -8,8 +8,12 @@ Required properties:
 Optional properties:
 - enable-gpio          : GPIO to use to enable/disable the regulator.
 - gpios                        : GPIO group used to control voltage.
+- gpios-states         : gpios pin's initial states array. 0: LOW, 1: HIGH.
+                         defualt is LOW if nothing is specified.
 - startup-delay-us     : Startup time in microseconds.
 - enable-active-high   : Polarity of GPIO is active high (default is low).
+- regulator-type       : Specifies what is being regulated, must be either
+                         "voltage" or "current", defaults to current.
 
 Any property defined as part of the core regulator binding defined in
 regulator.txt can also be used.
index f372cf2..b355660 100644 (file)
@@ -4,6 +4,14 @@ Required properties:
 
   - compatible: Must contain one of the following:
 
+    - "renesas,scifa-sh73a0" for SH73A0 (SH-Mobile AG5) SCIFA compatible UART.
+    - "renesas,scifb-sh73a0" for SH73A0 (SH-Mobile AG5) SCIFB compatible UART.
+    - "renesas,scifa-r8a73a4" for R8A73A4 (R-Mobile APE6) SCIFA compatible UART.
+    - "renesas,scifb-r8a73a4" for R8A73A4 (R-Mobile APE6) SCIFB compatible UART.
+    - "renesas,scifa-r8a7740" for R8A7740 (R-Mobile A1) SCIFA compatible UART.
+    - "renesas,scifb-r8a7740" for R8A7740 (R-Mobile A1) SCIFB compatible UART.
+    - "renesas,scif-r8a7778" for R8A7778 (R-Car M1) SCIF compatible UART.
+    - "renesas,scif-r8a7779" for R8A7779 (R-Car H1) SCIF compatible UART.
     - "renesas,scif-r8a7790" for R8A7790 (R-Car H2) SCIF compatible UART.
     - "renesas,scifa-r8a7790" for R8A7790 (R-Car H2) SCIFA compatible UART.
     - "renesas,scifb-r8a7790" for R8A7790 (R-Car H2) SCIFB compatible UART.
@@ -37,7 +45,7 @@ Example:
        };
 
        scifa0: serial@e6c40000 {
-               compatible = "renesas,scifa-r8a7790", "renesas,scifa-generic";
+               compatible = "renesas,scifa-r8a7790", "renesas,scifa";
                reg = <0 0xe6c40000 0 64>;
                interrupt-parent = <&gic>;
                interrupts = <0 144 IRQ_TYPE_LEVEL_HIGH>;
diff --git a/Documentation/devicetree/bindings/sound/renesas,rsnd.txt b/Documentation/devicetree/bindings/sound/renesas,rsnd.txt
new file mode 100644 (file)
index 0000000..aa697ab
--- /dev/null
@@ -0,0 +1,115 @@
+Renesas R-Car sound
+
+Required properties:
+- compatible                   : "renesas,rcar_sound-gen1" if generation1
+                                 "renesas,rcar_sound-gen2" if generation2
+- reg                          : Should contain the register physical address.
+                                 required register is
+                                  SRU/ADG/SSI      if generation1
+                                  SRU/ADG/SSIU/SSI if generation2
+- rcar_sound,ssi               : Should contain SSI feature.
+                                 The number of SSI subnode should be same as HW.
+                                 see below for detail.
+- rcar_sound,src               : Should contain SRC feature.
+                                 The number of SRC subnode should be same as HW.
+                                 see below for detail.
+- rcar_sound,dvc               : Should contain DVC feature.
+                                 The number of DVC subnode should be same as HW.
+                                 see below for detail.
+- rcar_sound,dai               : DAI contents.
+                                 The number of DAI subnode should be same as HW.
+                                 see below for detail.
+
+SSI subnode properties:
+- interrupts                   : Should contain SSI interrupt for PIO transfer
+- shared-pin                   : if shared clock pin
+- pio-transfer                 : use PIO transfer mode
+- no-busif                     : BUSIF is not ussed when [mem -> SSI] via DMA case
+
+SRC subnode properties:
+no properties at this point
+
+DAI subnode properties:
+- playback                     : list of playback modules
+- capture                      : list of capture  modules
+
+Example:
+
+rcar_sound: rcar_sound@0xffd90000 {
+       #sound-dai-cells = <1>;
+       compatible = "renesas,rcar_sound-gen2";
+       reg =   <0 0xec500000 0 0x1000>, /* SCU */
+               <0 0xec5a0000 0 0x100>,  /* ADG */
+               <0 0xec540000 0 0x1000>, /* SSIU */
+               <0 0xec541000 0 0x1280>; /* SSI */
+
+       rcar_sound,dvc {
+               dvc0: dvc@0 { };
+               dvc1: dvc@1 { };
+       };
+
+       rcar_sound,src {
+               src0: src@0 { };
+               src1: src@1 { };
+               src2: src@2 { };
+               src3: src@3 { };
+               src4: src@4 { };
+               src5: src@5 { };
+               src6: src@6 { };
+               src7: src@7 { };
+               src8: src@8 { };
+               src9: src@9 { };
+       };
+
+       rcar_sound,ssi {
+               ssi0: ssi@0 {
+                       interrupts = <0 370 IRQ_TYPE_LEVEL_HIGH>;
+               };
+               ssi1: ssi@1 {
+                       interrupts = <0 371 IRQ_TYPE_LEVEL_HIGH>;
+               };
+               ssi2: ssi@2 {
+                       interrupts = <0 372 IRQ_TYPE_LEVEL_HIGH>;
+               };
+               ssi3: ssi@3 {
+                       interrupts = <0 373 IRQ_TYPE_LEVEL_HIGH>;
+               };
+               ssi4: ssi@4 {
+                       interrupts = <0 374 IRQ_TYPE_LEVEL_HIGH>;
+               };
+               ssi5: ssi@5 {
+                       interrupts = <0 375 IRQ_TYPE_LEVEL_HIGH>;
+               };
+               ssi6: ssi@6 {
+                       interrupts = <0 376 IRQ_TYPE_LEVEL_HIGH>;
+               };
+               ssi7: ssi@7 {
+                       interrupts = <0 377 IRQ_TYPE_LEVEL_HIGH>;
+               };
+               ssi8: ssi@8 {
+                       interrupts = <0 378 IRQ_TYPE_LEVEL_HIGH>;
+               };
+               ssi9: ssi@9 {
+                       interrupts = <0 379 IRQ_TYPE_LEVEL_HIGH>;
+               };
+       };
+
+       rcar_sound,dai {
+               dai0 {
+                       playback = <&ssi5 &src5>;
+                       capture  = <&ssi6>;
+               };
+               dai1 {
+                       playback = <&ssi3>;
+               };
+               dai2 {
+                       capture  = <&ssi4>;
+               };
+               dai3 {
+                       playback = <&ssi7>;
+               };
+               dai4 {
+                       capture  = <&ssi8>;
+               };
+       };
+};
index 19c84df..c2e9841 100644 (file)
@@ -1,6 +1,6 @@
 Simple-Card:
 
-Simple-Card specifies audio DAI connection of SoC <-> codec.
+Simple-Card specifies audio DAI connections of SoC <-> codec.
 
 Required properties:
 
@@ -8,18 +8,56 @@ Required properties:
 
 Optional properties:
 
-- simple-audio-card,format             : CPU/CODEC common audio format.
-                                         "i2s", "right_j", "left_j" , "dsp_a"
-                                         "dsp_b", "ac97", "pdm", "msb", "lsb"
+- simple-audio-card,name               : User specified audio sound card name, one string
+                                         property.
+- simple-audio-card,widgets            : Please refer to widgets.txt.
 - simple-audio-card,routing            : A list of the connections between audio components.
                                          Each entry is a pair of strings, the first being the
                                          connection's sink, the second being the connection's
                                          source.
+- simple-audio-card,mclk-fs             : Multiplication factor between stream rate and codec
+                                         mclk.
+
+Optional subnodes:
+
+- simple-audio-card,dai-link           : Container for dai-link level
+                                         properties and the CPU and CODEC
+                                         sub-nodes. This container may be
+                                         omitted when the card has only one
+                                         DAI link. See the examples and the
+                                         section bellow.
+
+Dai-link subnode properties and subnodes:
 
-Required subnodes:
+If dai-link subnode is omitted and the subnode properties are directly
+under "sound"-node the subnode property and subnode names have to be
+prefixed with "simple-audio-card,"-prefix.
 
-- simple-audio-card,cpu                        : CPU   sub-node
-- simple-audio-card,codec              : CODEC sub-node
+Required dai-link subnodes:
+
+- cpu                                  : CPU   sub-node
+- codec                                        : CODEC sub-node
+
+Optional dai-link subnode properties:
+
+- format                               : CPU/CODEC common audio format.
+                                         "i2s", "right_j", "left_j" , "dsp_a"
+                                         "dsp_b", "ac97", "pdm", "msb", "lsb"
+- frame-master                         : Indicates dai-link frame master.
+                                         phandle to a cpu or codec subnode.
+- bitclock-master                      : Indicates dai-link bit clock master.
+                                         phandle to a cpu or codec subnode.
+- bitclock-inversion                   : bool property. Add this if the
+                                         dai-link uses bit clock inversion.
+- frame-inversion                      : bool property. Add this if the
+                                         dai-link uses frame clock inversion.
+
+For backward compatibility the frame-master and bitclock-master
+properties can be used as booleans in codec subnode to indicate if the
+codec is the dai-link frame or bit clock master. In this case there
+should be no dai-link node, the same properties should not be present
+at sound-node level, and the bitclock-inversion and frame-inversion
+properties should also be placed in the codec node if needed.
 
 Required CPU/CODEC subnodes properties:
 
@@ -27,35 +65,36 @@ Required CPU/CODEC subnodes properties:
 
 Optional CPU/CODEC subnodes properties:
 
-- format                               : CPU/CODEC specific audio format if needed.
-                                         see simple-audio-card,format
-- frame-master                         : bool property. add this if subnode is frame master
-- bitclock-master                      : bool property. add this if subnode is bitclock master
-- bitclock-inversion                   : bool property. add this if subnode has clock inversion
-- frame-inversion                      : bool property. add this if subnode has frame inversion
+- dai-tdm-slot-num                     : Please refer to tdm-slot.txt.
+- dai-tdm-slot-width                   : Please refer to tdm-slot.txt.
 - clocks / system-clock-frequency      : specify subnode's clock if needed.
                                          it can be specified via "clocks" if system has
                                          clock node (= common clock), or "system-clock-frequency"
                                          (if system doens't support common clock)
 
-Example:
+Example 1 - single DAI link:
 
 sound {
        compatible = "simple-audio-card";
+       simple-audio-card,name = "VF610-Tower-Sound-Card";
        simple-audio-card,format = "left_j";
+       simple-audio-card,bitclock-master = <&dailink0_master>;
+       simple-audio-card,frame-master = <&dailink0_master>;
+       simple-audio-card,widgets =
+               "Microphone", "Microphone Jack",
+               "Headphone", "Headphone Jack",
+               "Speaker", "External Speaker";
        simple-audio-card,routing =
-               "MIC_IN", "Mic Jack",
+               "MIC_IN", "Microphone Jack",
                "Headphone Jack", "HP_OUT",
-               "Ext Spk", "LINE_OUT";
+               "External Speaker", "LINE_OUT";
 
        simple-audio-card,cpu {
                sound-dai = <&sh_fsi2 0>;
        };
 
-       simple-audio-card,codec {
+       dailink0_master: simple-audio-card,codec {
                sound-dai = <&ak4648>;
-               bitclock-master;
-               frame-master;
                clocks = <&osc>;
        };
 };
@@ -75,3 +114,38 @@ sh_fsi2: sh_fsi2@ec230000 {
        interrupt-parent = <&gic>;
        interrupts = <0 146 0x4>;
 };
+
+Example 2 - many DAI links:
+
+sound {
+       compatible = "simple-audio-card";
+       simple-audio-card,name = "Cubox Audio";
+
+       simple-audio-card,dai-link@0 {          /* I2S - HDMI */
+               format = "i2s";
+               cpu {
+                       sound-dai = <&audio1 0>;
+               };
+               codec {
+                       sound-dai = <&tda998x 0>;
+               };
+       };
+
+       simple-audio-card,dai-link@1 {          /* S/PDIF - HDMI */
+               cpu {
+                       sound-dai = <&audio1 1>;
+               };
+               codec {
+                       sound-dai = <&tda998x 1>;
+               };
+       };
+
+       simple-audio-card,dai-link@2 {          /* S/PDIF - S/PDIF */
+               cpu {
+                       sound-dai = <&audio1 1>;
+               };
+               codec {
+                       sound-dai = <&spdif_codec>;
+               };
+       };
+};
index e622210..d11c372 100644 (file)
@@ -1,12 +1,55 @@
 Renesas MSIOF spi controller
 
 Required properties:
-- compatible :         "renesas,sh-msiof" for SuperH or
-               "renesas,sh-mobile-msiof" for SH Mobile series
-- reg : Offset and length of the register set for the device
-- interrupts : interrupt line used by MSIOF
+- compatible           : "renesas,msiof-<soctype>" for SoCs,
+                        "renesas,sh-msiof" for SuperH, or
+                        "renesas,sh-mobile-msiof" for SH Mobile series.
+                        Examples with soctypes are:
+                        "renesas,msiof-r8a7790" (R-Car H2)
+                        "renesas,msiof-r8a7791" (R-Car M2-W)
+                        "renesas,msiof-r8a7792" (R-Car V2H)
+                        "renesas,msiof-r8a7793" (R-Car M2-N)
+                        "renesas,msiof-r8a7794" (R-Car E2)
+- reg                  : A list of offsets and lengths of the register sets for
+                        the device.
+                        If only one register set is present, it is to be used
+                        by both the CPU and the DMA engine.
+                        If two register sets are present, the first is to be
+                        used by the CPU, and the second is to be used by the
+                        DMA engine.
+- interrupt-parent     : The phandle for the interrupt controller that
+                        services interrupts for this device
+- interrupts           : Interrupt specifier
+- #address-cells       : Must be <1>
+- #size-cells          : Must be <0>
 
 Optional properties:
-- num-cs               : total number of chip-selects
-- renesas,tx-fifo-size : Overrides the default tx fifo size given in words
-- renesas,rx-fifo-size : Overrides the default rx fifo size given in words
+- clocks               : Must contain a reference to the functional clock.
+- num-cs               : Total number of chip-selects (default is 1)
+- dmas                 : Must contain a list of two references to DMA
+                        specifiers, one for transmission, and one for
+                        reception.
+- dma-names            : Must contain a list of two DMA names, "tx" and "rx".
+
+Optional properties, deprecated for soctype-specific bindings:
+- renesas,tx-fifo-size : Overrides the default tx fifo size given in words
+                        (default is 64)
+- renesas,rx-fifo-size : Overrides the default rx fifo size given in words
+                        (default is 64, or 256 on R-Car Gen2)
+
+Pinctrl properties might be needed, too.  See
+Documentation/devicetree/bindings/pinctrl/renesas,*.
+
+Example:
+
+       msiof0: spi@e6e20000 {
+               compatible = "renesas,msiof-r8a7791";
+               reg = <0 0xe6e20000 0 0x0064>, <0 0xe7e20000 0 0x0064>;
+               interrupts = <0 156 IRQ_TYPE_LEVEL_HIGH>;
+               clocks = <&mstp0_clks R8A7791_CLK_MSIOF0>;
+               dmas = <&dmac0 0x51>, <&dmac0 0x52>;
+               dma-names = "tx", "rx";
+               #address-cells = <1>;
+               #size-cells = <0>;
+               status = "disabled";
+       };
diff --git a/Documentation/devicetree/bindings/spi/spi-rspi.txt b/Documentation/devicetree/bindings/spi/spi-rspi.txt
new file mode 100644 (file)
index 0000000..8f4169f
--- /dev/null
@@ -0,0 +1,69 @@
+Device tree configuration for Renesas RSPI/QSPI driver
+
+Required properties:
+- compatible       : For Renesas Serial Peripheral Interface on legacy SH:
+                    "renesas,rspi-<soctype>", "renesas,rspi" as fallback.
+                    For Renesas Serial Peripheral Interface on RZ/A1H:
+                    "renesas,rspi-<soctype>", "renesas,rspi-rz" as fallback.
+                    For Quad Serial Peripheral Interface on R-Car Gen2:
+                    "renesas,qspi-<soctype>", "renesas,qspi" as fallback.
+                    Examples with soctypes are:
+                       - "renesas,rspi-sh7757" (SH)
+                       - "renesas,rspi-r7s72100" (RZ/A1H)
+                       - "renesas,qspi-r8a7790" (R-Car H2)
+                       - "renesas,qspi-r8a7791" (R-Car M2-W)
+                       - "renesas,qspi-r8a7792" (R-Car V2H)
+                       - "renesas,qspi-r8a7793" (R-Car M2-N)
+                       - "renesas,qspi-r8a7794" (R-Car E2)
+- reg              : Address start and address range size of the device
+- interrupts       : A list of interrupt-specifiers, one for each entry in
+                    interrupt-names.
+                    If interrupt-names is not present, an interrupt specifier
+                    for a single muxed interrupt.
+- interrupt-names  : A list of interrupt names. Should contain (if present):
+                      - "error" for SPEI,
+                      - "rx" for SPRI,
+                      - "tx" to SPTI,
+                      - "mux" for a single muxed interrupt.
+- interrupt-parent : The phandle for the interrupt controller that
+                    services interrupts for this device.
+- num-cs          : Number of chip selects. Some RSPI cores have more than 1.
+- #address-cells   : Must be <1>
+- #size-cells      : Must be <0>
+
+Optional properties:
+- clocks           : Must contain a reference to the functional clock.
+- dmas             : Must contain a list of two references to DMA specifiers,
+                    one for transmission, and one for reception.
+- dma-names        : Must contain a list of two DMA names, "tx" and "rx".
+
+Pinctrl properties might be needed, too.  See
+Documentation/devicetree/bindings/pinctrl/renesas,*.
+
+Examples:
+
+       spi0: spi@e800c800 {
+               compatible = "renesas,rspi-r7s72100", "renesas,rspi-rz";
+               reg = <0xe800c800 0x24>;
+               interrupts = <0 238 IRQ_TYPE_LEVEL_HIGH>,
+                            <0 239 IRQ_TYPE_LEVEL_HIGH>,
+                            <0 240 IRQ_TYPE_LEVEL_HIGH>;
+               interrupt-names = "error", "rx", "tx";
+               interrupt-parent = <&gic>;
+               num-cs = <1>;
+               #address-cells = <1>;
+               #size-cells = <0>;
+       };
+
+       spi: spi@e6b10000 {
+               compatible = "renesas,qspi-r8a7791", "renesas,qspi";
+               reg = <0 0xe6b10000 0 0x2c>;
+               interrupt-parent = <&gic>;
+               interrupts = <0 184 IRQ_TYPE_LEVEL_HIGH>;
+               clocks = <&mstp9_clks R8A7791_CLK_QSPI_MOD>;
+               num-cs = <1>;
+               #address-cells = <1>;
+               #size-cells = <0>;
+               dmas = <&dmac0 0x17>, <&dmac0 0x18>;
+               dma-names = "tx", "rx";
+       };
index 28ef498..43404b1 100644 (file)
@@ -1,7 +1,16 @@
 * Renesas R-Car Thermal
 
 Required properties:
-- compatible           : "renesas,rcar-thermal"
+- compatible           : "renesas,thermal-<soctype>", "renesas,rcar-thermal"
+                         as fallback.
+                         Examples with soctypes are:
+                           - "renesas,thermal-r8a73a4" (R-Mobile AP6)
+                           - "renesas,thermal-r8a7779" (R-Car H1)
+                           - "renesas,thermal-r8a7790" (R-Car H2)
+                           - "renesas,thermal-r8a7791" (R-Car M2-W)
+                           - "renesas,thermal-r8a7792" (R-Car V2H)
+                           - "renesas,thermal-r8a7793" (R-Car M2-N)
+                           - "renesas,thermal-r8a7794" (R-Car E2)
 - reg                  : Address range of the thermal registers.
                          The 1st reg will be recognized as common register
                          if it has "interrupts".
@@ -12,18 +21,18 @@ Option properties:
 
 Example (non interrupt support):
 
-thermal@e61f0100 {
-       compatible = "renesas,rcar-thermal";
-       reg = <0xe61f0100 0x38>;
+thermal@ffc48000 {
+       compatible = "renesas,thermal-r8a7779", "renesas,rcar-thermal";
+       reg = <0xffc48000 0x38>;
 };
 
 Example (interrupt support):
 
 thermal@e61f0000 {
-       compatible = "renesas,rcar-thermal";
+       compatible = "renesas,thermal-r8a73a4", "renesas,rcar-thermal";
        reg = <0xe61f0000 0x14
                0xe61f0100 0x38
                0xe61f0200 0x38
                0xe61f0300 0x38>;
-       interrupts = <0 69 4>;
+       interrupts = <0 69 IRQ_TYPE_LEVEL_HIGH>;
 };
diff --git a/Documentation/devicetree/bindings/timer/renesas,cmt.txt b/Documentation/devicetree/bindings/timer/renesas,cmt.txt
new file mode 100644 (file)
index 0000000..1a05c1b
--- /dev/null
@@ -0,0 +1,79 @@
+* Renesas R-Car Compare Match Timer (CMT)
+
+The CMT is a multi-channel 16/32/48-bit timer/counter with configurable clock
+inputs and programmable compare match.
+
+Channels share hardware resources but their counter and compare match value
+are independent. A particular CMT instance can implement only a subset of the
+channels supported by the CMT model. Channel indices represent the hardware
+position of the channel in the CMT and don't match the channel numbers in the
+datasheets.
+
+Required Properties:
+
+  - compatible: must contain one or more of the following:
+    - "renesas,cmt-32-r8a7740" for the r8a7740 32-bit CMT
+               (CMT0)
+    - "renesas,cmt-32-sh7372" for the sh7372 32-bit CMT
+               (CMT0)
+    - "renesas,cmt-32-sh73a0" for the sh73a0 32-bit CMT
+               (CMT0)
+    - "renesas,cmt-32" for all 32-bit CMT without fast clock support
+               (CMT0 on sh7372, sh73a0 and r8a7740)
+               This is a fallback for the above renesas,cmt-32-* entries.
+
+    - "renesas,cmt-32-fast-r8a7740" for the r8a7740 32-bit CMT with fast
+               clock support (CMT[234])
+    - "renesas,cmt-32-fast-sh7372" for the sh7372 32-bit CMT with fast
+               clock support (CMT[234])
+    - "renesas,cmt-32-fast-sh73a0" for the sh73A0 32-bit CMT with fast
+               clock support (CMT[234])
+    - "renesas,cmt-32-fast" for all 32-bit CMT with fast clock support
+               (CMT[234] on sh7372, sh73a0 and r8a7740)
+               This is a fallback for the above renesas,cmt-32-fast-* entries.
+
+    - "renesas,cmt-48-sh7372" for the sh7372 48-bit CMT
+               (CMT1)
+    - "renesas,cmt-48-sh73a0" for the sh73A0 48-bit CMT
+               (CMT1)
+    - "renesas,cmt-48-r8a7740" for the r8a7740 48-bit CMT
+               (CMT1)
+    - "renesas,cmt-48" for all non-second generation 48-bit CMT
+               (CMT1 on sh7372, sh73a0 and r8a7740)
+               This is a fallback for the above renesas,cmt-48-* entries.
+
+    - "renesas,cmt-48-r8a73a4" for the r8a73a4 48-bit CMT
+               (CMT[01])
+    - "renesas,cmt-48-r8a7790" for the r8a7790 48-bit CMT
+               (CMT[01])
+    - "renesas,cmt-48-r8a7791" for the r8a7791 48-bit CMT
+               (CMT[01])
+    - "renesas,cmt-48-gen2" for all second generation 48-bit CMT
+               (CMT[01] on r8a73a4, r8a7790 and r8a7791)
+               This is a fallback for the renesas,cmt-48-r8a73a4,
+               renesas,cmt-48-r8a7790 and renesas,cmt-48-r8a7791 entries.
+
+  - reg: base address and length of the registers block for the timer module.
+  - interrupts: interrupt-specifier for the timer, one per channel.
+  - clocks: a list of phandle + clock-specifier pairs, one for each entry
+    in clock-names.
+  - clock-names: must contain "fck" for the functional clock.
+
+  - renesas,channels-mask: bitmask of the available channels.
+
+
+Example: R8A7790 (R-Car H2) CMT0 node
+
+       CMT0 on R8A7790 implements hardware channels 5 and 6 only and names
+       them channels 0 and 1 in the documentation.
+
+       cmt0: timer@ffca0000 {
+               compatible = "renesas,cmt-48-r8a7790", "renesas,cmt-48-gen2";
+               reg = <0 0xffca0000 0 0x1004>;
+               interrupts = <0 142 IRQ_TYPE_LEVEL_HIGH>,
+                            <0 142 IRQ_TYPE_LEVEL_HIGH>;
+               clocks = <&mstp1_clks R8A7790_CLK_CMT0>;
+               clock-names = "fck";
+
+               renesas,channels-mask = <0x60>;
+       };
diff --git a/Documentation/devicetree/bindings/timer/renesas,mtu2.txt b/Documentation/devicetree/bindings/timer/renesas,mtu2.txt
new file mode 100644 (file)
index 0000000..d9a8d5a
--- /dev/null
@@ -0,0 +1,42 @@
+* Renesas R-Car Multi-Function Timer Pulse Unit 2 (MTU2)
+
+The MTU2 is a multi-purpose, multi-channel timer/counter with configurable
+clock inputs and programmable compare match.
+
+Channels share hardware resources but their counter and compare match value
+are independent. The MTU2 hardware supports five channels indexed from 0 to 4.
+
+Required Properties:
+
+  - compatible: must be one or more of the following:
+    - "renesas,mtu2-r7s72100" for the r7s72100 MTU2
+    - "renesas,mtu2" for any MTU2
+      This is a fallback for the above renesas,mtu2-* entries
+
+  - reg: base address and length of the registers block for the timer module.
+
+  - interrupts: interrupt specifiers for the timer, one for each entry in
+    interrupt-names.
+  - interrupt-names: must contain one entry named "tgi?a" for each enabled
+    channel, where "?" is the channel index expressed as one digit from "0" to
+    "4".
+
+  - clocks: a list of phandle + clock-specifier pairs, one for each entry
+    in clock-names.
+  - clock-names: must contain "fck" for the functional clock.
+
+
+Example: R7S72100 (RZ/A1H) MTU2 node
+
+       mtu2: timer@fcff0000 {
+               compatible = "renesas,mtu2-r7s72100", "renesas,mtu2";
+               reg = <0xfcff0000 0x400>;
+               interrupts = <0 139 IRQ_TYPE_LEVEL_HIGH>,
+                            <0 146 IRQ_TYPE_LEVEL_HIGH>,
+                            <0 150 IRQ_TYPE_LEVEL_HIGH>,
+                            <0 154 IRQ_TYPE_LEVEL_HIGH>,
+                            <0 159 IRQ_TYPE_LEVEL_HIGH>;
+               interrupt-names = "tgi0a", "tgi1a", "tgi2a", "tgi3a", "tgi4a";
+               clocks = <&mstp3_clks R7S72100_CLK_MTU2>;
+               clock-names = "fck";
+       };
diff --git a/Documentation/devicetree/bindings/timer/renesas,tmu.txt b/Documentation/devicetree/bindings/timer/renesas,tmu.txt
new file mode 100644 (file)
index 0000000..7db89fb
--- /dev/null
@@ -0,0 +1,42 @@
+* Renesas R-Car Timer Unit (TMU)
+
+The TMU is a 32-bit timer/counter with configurable clock inputs and
+programmable compare match.
+
+Channels share hardware resources but their counter and compare match value
+are independent. The TMU hardware supports up to three channels.
+
+Required Properties:
+
+  - compatible: must contain one or more of the following:
+    - "renesas,tmu-r8a7779" for the r8a7779 TMU
+    - "renesas,tmu" for any TMU.
+      This is a fallback for the above renesas,tmu-* entries
+
+  - reg: base address and length of the registers block for the timer module.
+
+  - interrupts: interrupt-specifier for the timer, one per channel.
+
+  - clocks: a list of phandle + clock-specifier pairs, one for each entry
+    in clock-names.
+  - clock-names: must contain "fck" for the functional clock.
+
+Optional Properties:
+
+  - #renesas,channels: number of channels implemented by the timer, must be 2
+    or 3 (if not specified the value defaults to 3).
+
+
+Example: R8A7779 (R-Car H1) TMU0 node
+
+       tmu0: timer@ffd80000 {
+               compatible = "renesas,tmu-r8a7779", "renesas,tmu";
+               reg = <0xffd80000 0x30>;
+               interrupts = <0 32 IRQ_TYPE_LEVEL_HIGH>,
+                            <0 33 IRQ_TYPE_LEVEL_HIGH>,
+                            <0 34 IRQ_TYPE_LEVEL_HIGH>;
+               clocks = <&mstp0_clks R8A7779_CLK_TMU0>;
+               clock-names = "fck";
+
+               #renesas,channels = <3>;
+       };
index 5752df0..86f67f0 100644 (file)
@@ -1,14 +1,21 @@
 USB xHCI controllers
 
 Required properties:
-  - compatible: should be "xhci-platform".
+  - compatible: should be one of "generic-xhci",
+    "marvell,armada-375-xhci", "marvell,armada-380-xhci",
+    "renesas,xhci-r8a7790", "renesas,xhci-r8a7791" (deprecated:
+    "xhci-platform").
   - reg: should contain address and length of the standard XHCI
     register set for the device.
   - interrupts: one XHCI interrupt should be described here.
 
+Optional properties:
+  - clocks: reference to a clock
+  - usb3-lpm-capable: determines if platform is USB3 LPM capable
+
 Example:
        usb@f0931000 {
-               compatible = "xhci-platform";
+               compatible = "generic-xhci";
                reg = <0xf0931000 0x8c8>;
                interrupts = <0x0 0x4e 0x0>;
        };
index 40ce2df..644f547 100644 (file)
@@ -1,6 +1,4 @@
-Device tree binding vendor prefix registry.  Keep list in alphabetical order.
-
-This isn't an exhaustive list, but you should add new prefixes to it before
+Device tree binding vendor prefix registry.  Keep list in alphabetical order.  This isn't an exhaustive list, but you should add new prefixes to it before
 using them to avoid name-space collisions.
 
 active-semi    Active-Semi International Inc
@@ -29,6 +27,7 @@ cortina       Cortina Systems, Inc.
 dallas Maxim Integrated Products (formerly Dallas Semiconductor)
 davicom        DAVICOM Semiconductor, Inc.
 denx   Denx Software Engineering
+dlg    Dialog Semiconductor
 edt    Emerging Display Technologies
 emmicro        EM Microelectronic
 epfl   Ecole Polytechnique Fédérale de Lausanne
index 4f7897e..1fd8a2a 100644 (file)
@@ -287,6 +287,12 @@ REGULATOR
   devm_regulator_bulk_get()
   devm_regulator_register()
 
+  devm_mdiobus_free()
+
+MEM
+  devm_kasprintf()
+  devm_kvasprintf()
+
 CLOCK
   devm_clk_get()
   devm_clk_put()
diff --git a/Documentation/filesystems/.gitignore b/Documentation/filesystems/.gitignore
new file mode 100644 (file)
index 0000000..31d6e42
--- /dev/null
@@ -0,0 +1 @@
+dnotify_test
index adf5e33..e9c803e 100644 (file)
@@ -25,6 +25,7 @@ Supported adapters:
   * Intel Avoton (SOC)
   * Intel Wellsburg (PCH)
   * Intel Coleto Creek (PCH)
+  * Intel Wildcat Point (PCH)
   * Intel Wildcat Point-LP (PCH)
   * Intel BayTrail (SOC)
    Datasheets: Publicly available at the Intel website
diff --git a/Documentation/laptops/.gitignore b/Documentation/laptops/.gitignore
new file mode 100644 (file)
index 0000000..da2bd06
--- /dev/null
@@ -0,0 +1,2 @@
+dslm
+freefall
diff --git a/Documentation/prctl/.gitignore b/Documentation/prctl/.gitignore
new file mode 100644 (file)
index 0000000..0b5c274
--- /dev/null
@@ -0,0 +1,3 @@
+disable-tsc-ctxt-sw-stress-test
+disable-tsc-on-off-stress-test
+disable-tsc-test
index f8e8e95..81fdd42 100644 (file)
 # define PR_TSC_SIGSEGV                2   /* throw a SIGSEGV instead of reading the TSC */
 #endif
 
-uint64_t rdtsc() {
+static uint64_t rdtsc(void)
+{
 uint32_t lo, hi;
 /* We cannot use "=A", since this would use %rax on x86_64 */
 __asm__ __volatile__ ("rdtsc" : "=a" (lo), "=d" (hi));
 return (uint64_t)hi << 32 | lo;
 }
 
-void sigsegv_expect(int sig)
+static void sigsegv_expect(int sig)
 {
        /* */
 }
 
-void segvtask(void)
+static void segvtask(void)
 {
        if (prctl(PR_SET_TSC, PR_TSC_SIGSEGV) < 0)
        {
@@ -54,13 +55,13 @@ void segvtask(void)
 }
 
 
-void sigsegv_fail(int sig)
+static void sigsegv_fail(int sig)
 {
        fprintf(stderr, "FATAL ERROR, rdtsc() failed while enabled\n");
        exit(0);
 }
 
-void rdtsctask(void)
+static void rdtsctask(void)
 {
        if (prctl(PR_SET_TSC, PR_TSC_ENABLE) < 0)
        {
index 1fcd914..4d83a27 100644 (file)
@@ -29,7 +29,8 @@
 
 /* snippet from wikipedia :-) */
 
-uint64_t rdtsc() {
+static uint64_t rdtsc(void)
+{
 uint32_t lo, hi;
 /* We cannot use "=A", since this would use %rax on x86_64 */
 __asm__ __volatile__ ("rdtsc" : "=a" (lo), "=d" (hi));
@@ -38,7 +39,7 @@ return (uint64_t)hi << 32 | lo;
 
 int should_segv = 0;
 
-void sigsegv_cb(int sig)
+static void sigsegv_cb(int sig)
 {
        if (!should_segv)
        {
@@ -55,7 +56,7 @@ void sigsegv_cb(int sig)
        rdtsc();
 }
 
-void task(void)
+static void task(void)
 {
        signal(SIGSEGV, sigsegv_cb);
        alarm(10);
index 843c81e..2541e65 100644 (file)
@@ -29,14 +29,15 @@ const char *tsc_names[] =
        [PR_TSC_SIGSEGV] = "PR_TSC_SIGSEGV",
 };
 
-uint64_t rdtsc() {
+static uint64_t rdtsc(void)
+{
 uint32_t lo, hi;
 /* We cannot use "=A", since this would use %rax on x86_64 */
 __asm__ __volatile__ ("rdtsc" : "=a" (lo), "=d" (hi));
 return (uint64_t)hi << 32 | lo;
 }
 
-void sigsegv_cb(int sig)
+static void sigsegv_cb(int sig)
 {
        int tsc_val = 0;
 
diff --git a/Documentation/ptp/.gitignore b/Documentation/ptp/.gitignore
new file mode 100644 (file)
index 0000000..f562e49
--- /dev/null
@@ -0,0 +1 @@
+testptp
index 93cb979..f38f99c 100644 (file)
@@ -19,7 +19,8 @@ should instead register a static mapping that can be used to match PWM
 consumers to providers, as given in the following example:
 
        static struct pwm_lookup board_pwm_lookup[] = {
-               PWM_LOOKUP("tegra-pwm", 0, "pwm-backlight", NULL),
+               PWM_LOOKUP("tegra-pwm", 0, "pwm-backlight", NULL,
+                          50000, PWM_POLARITY_NORMAL),
        };
 
        static void __init board_init(void)
diff --git a/Documentation/timers/.gitignore b/Documentation/timers/.gitignore
new file mode 100644 (file)
index 0000000..c5c45d7
--- /dev/null
@@ -0,0 +1 @@
+hpet_example
diff --git a/Documentation/vDSO/.gitignore b/Documentation/vDSO/.gitignore
new file mode 100644 (file)
index 0000000..133bf9e
--- /dev/null
@@ -0,0 +1,2 @@
+vdso_test
+vdso_standalone_test_x86
diff --git a/Documentation/video4linux/.gitignore b/Documentation/video4linux/.gitignore
deleted file mode 100644 (file)
index 9527039..0000000
+++ /dev/null
@@ -1 +0,0 @@
-v4lgrab
index 900d98e..8cea0d2 100644 (file)
@@ -5418,6 +5418,13 @@ T:       git git://github.com/linux-test-project/ltp.git
 T:     git git://ltp.git.sourceforge.net/gitroot/ltp/ltp-dev
 S:     Maintained
 
+LTTng (Linux Trace Toolkit Next Generation)
+M:     Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
+L:     lttng-dev@lists.lttng.org (moderated for non-subscribers)
+W:     http://lttng.org
+S:     Maintained
+F:     drivers/staging/lttng/
+
 M32R ARCHITECTURE
 M:     Hirokazu Takata <takata@linux-m32r.org>
 L:     linux-m32r@ml.linux-m32r.org (moderated for non-subscribers)
index eb96e40..216e47a 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -1,7 +1,7 @@
 VERSION = 3
 PATCHLEVEL = 14
 SUBLEVEL = 25
-EXTRAVERSION =
+EXTRAVERSION = -ltsi
 NAME = Remembering Coco
 
 # *DOCUMENTATION*
index 9be30c8..0434a89 100644 (file)
@@ -57,7 +57,7 @@ config ARCH_FLATMEM_ENABLE
 config MMU
        def_bool y
 
-config NO_IOPORT
+config NO_IOPORT_MAP
        def_bool y
 
 config GENERIC_CALIBRATE_DELAY
index b6dc4e2..0b3ef40 100644 (file)
@@ -42,7 +42,7 @@ const struct machine_desc * __init setup_machine_fdt(void *dt)
        const struct machine_desc *mdesc;
        unsigned long dt_root;
        void *clk;
-       unsigned long len;
+       int len;
 
        if (!early_init_dt_scan(dt))
                return NULL;
index 4733d32..9542b56 100644 (file)
@@ -130,7 +130,7 @@ config HAVE_TCM
 config HAVE_PROC_CPU
        bool
 
-config NO_IOPORT
+config NO_IOPORT_MAP
        bool
 
 config EISA
@@ -307,9 +307,12 @@ choice
 config ARCH_MULTIPLATFORM
        bool "Allow multiple platforms to be selected"
        depends on MMU
+       select ARCH_WANT_OPTIONAL_GPIOLIB
        select ARM_PATCH_PHYS_VIRT
        select AUTO_ZRELADDR
        select COMMON_CLK
+       select GENERIC_CLOCKEVENTS
+       select MIGHT_HAVE_PCI
        select MULTI_IRQ_HANDLER
        select SPARSE_IRQ
        select USE_OF
@@ -410,7 +413,7 @@ config ARCH_EBSA110
        select ISA
        select NEED_MACH_IO_H
        select NEED_MACH_MEMORY_H
-       select NO_IOPORT
+       select NO_IOPORT_MAP
        help
          This is an evaluation board for the StrongARM processor available
          from Digital. It has limited hardware on-board, including an
@@ -430,7 +433,7 @@ config ARCH_EFM32
        select CPU_V7M
        select GENERIC_CLOCKEVENTS
        select NO_DMA
-       select NO_IOPORT
+       select NO_IOPORT_MAP
        select SPARSE_IRQ
        select USE_OF
        help
@@ -535,7 +538,6 @@ config ARCH_DOVE
        select PINCTRL
        select PINCTRL_DOVE
        select PLAT_ORION_LEGACY
-       select USB_ARCH_HAS_EHCI
        help
          Support for the Marvell Dove SoC 88AP510
 
@@ -634,7 +636,6 @@ config ARCH_LPC32XX
        select GENERIC_CLOCKEVENTS
        select HAVE_IDE
        select HAVE_PWM
-       select USB_ARCH_HAS_OHCI
        select USE_OF
        help
          Support for the NXP LPC32XX family of processors
@@ -676,6 +677,7 @@ config ARCH_SHMOBILE_LEGACY
        select ARCH_SHMOBILE
        select ARM_PATCH_PHYS_VIRT
        select CLKDEV_LOOKUP
+       select CPU_V7
        select GENERIC_CLOCKEVENTS
        select HAVE_ARM_SCU if SMP
        select HAVE_ARM_TWD if SMP
@@ -683,9 +685,10 @@ config ARCH_SHMOBILE_LEGACY
        select HAVE_SMP
        select MIGHT_HAVE_CACHE_L2X0
        select MULTI_IRQ_HANDLER
-       select NO_IOPORT
+       select NO_IOPORT_MAP
        select PINCTRL
        select PM_GENERIC_DOMAINS if PM
+       select SH_CLK_CPG
        select SPARSE_IRQ
        help
          Support for Renesas ARM SoC platforms using a non-multiplatform
@@ -704,7 +707,7 @@ config ARCH_RPC
        select ISA_DMA_API
        select NEED_MACH_IO_H
        select NEED_MACH_MEMORY_H
-       select NO_IOPORT
+       select NO_IOPORT_MAP
        select VIRT_TO_BUS
        help
          On the Acorn Risc-PC, Linux can support the internal IDE disk and
@@ -763,7 +766,7 @@ config ARCH_S3C64XX
        select HAVE_S3C2410_I2C if I2C
        select HAVE_S3C2410_WATCHDOG if WATCHDOG
        select HAVE_TCM
-       select NO_IOPORT
+       select NO_IOPORT_MAP
        select PLAT_SAMSUNG
        select PM_GENERIC_DOMAINS
        select S3C_DEV_NAND
@@ -771,7 +774,6 @@ config ARCH_S3C64XX
        select SAMSUNG_ATAGS
        select SAMSUNG_WAKEMASK
        select SAMSUNG_WDT_RESET
-       select USB_ARCH_HAS_OHCI
        help
          Samsung S3C64XX series based systems
 
@@ -916,9 +918,11 @@ config ARCH_MULTI_V7
        default y
        select ARCH_MULTI_V6_V7
        select CPU_V7
+       select HAVE_SMP
 
 config ARCH_MULTI_V6_V7
        bool
+       select MIGHT_HAVE_CACHE_L2X0
 
 config ARCH_MULTI_CPU_AUTO
        def_bool !(ARCH_MULTI_V4 || ARCH_MULTI_V4T || ARCH_MULTI_V6_V7)
index 0320303..e744f93 100644 (file)
@@ -244,15 +244,11 @@ dtb-$(CONFIG_ARCH_U8500) += ste-snowball.dtb \
 dtb-$(CONFIG_ARCH_S3C24XX) += s3c2416-smdk2416.dtb
 dtb-$(CONFIG_ARCH_S3C64XX) += s3c6410-mini6410.dtb \
        s3c6410-smdk6410.dtb
-dtb-$(CONFIG_ARCH_SHMOBILE_LEGACY) += emev2-kzm9d.dtb \
-       r7s72100-genmai.dtb \
-       r7s72100-genmai-reference.dtb \
+dtb-$(CONFIG_ARCH_SHMOBILE_LEGACY) += r7s72100-genmai.dtb \
        r8a7740-armadillo800eva.dtb \
        r8a7778-bockw.dtb \
        r8a7778-bockw-reference.dtb \
-       r8a7740-armadillo800eva-reference.dtb \
        r8a7779-marzen.dtb \
-       r8a7779-marzen-reference.dtb \
        r8a7791-koelsch.dtb \
        r8a7790-lager.dtb \
        sh73a0-kzm9g.dtb \
@@ -261,9 +257,12 @@ dtb-$(CONFIG_ARCH_SHMOBILE_LEGACY) += emev2-kzm9d.dtb \
        r8a73a4-ape6evm-reference.dtb \
        sh7372-mackerel.dtb
 dtb-$(CONFIG_ARCH_SHMOBILE_MULTI) += emev2-kzm9d.dtb \
-       r7s72100-genmai-reference.dtb \
+       r7s72100-genmai.dtb \
+       r8a7791-henninger.dtb \
        r8a7791-koelsch.dtb \
-       r8a7790-lager.dtb
+       r8a7790-lager.dtb \
+       r8a7779-marzen.dtb \
+       r8a7794-alt.dtb
 dtb-$(CONFIG_ARCH_SOCFPGA) += socfpga_arria5_socdk.dtb \
        socfpga_cyclone5_socdk.dtb \
        socfpga_cyclone5_sockit.dtb \
index e37985f..00eeed3 100644 (file)
                        device_type = "cpu";
                        compatible = "arm,cortex-a9";
                        reg = <0>;
+                       clock-frequency = <533000000>;
                };
                cpu@1 {
                        device_type = "cpu";
                        compatible = "arm,cortex-a9";
                        reg = <1>;
+                       clock-frequency = <533000000>;
                };
        };
 
index a9b6e10..fb85ba9 100644 (file)
        };
 
        pmic: dialog@48 {
-               compatible = "dialog,da9053", "dialog,da9052";
+               compatible = "dlg,da9053", "dlg,da9052";
                reg = <0x48>;
        };
 };
diff --git a/arch/arm/boot/dts/imx6qdl-phytec-pfla02.dtsi b/arch/arm/boot/dts/imx6qdl-phytec-pfla02.dtsi
new file mode 100644 (file)
index 0000000..0e50bb0
--- /dev/null
@@ -0,0 +1,357 @@
+/*
+ * Copyright 2013 Christian Hemp, Phytec Messtechnik GmbH
+ *
+ * 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 <dt-bindings/gpio/gpio.h>
+
+/ {
+       model = "Phytec phyFLEX-i.MX6 Ouad";
+       compatible = "phytec,imx6q-pfla02", "fsl,imx6q";
+
+       memory {
+               reg = <0x10000000 0x80000000>;
+       };
+
+       regulators {
+               compatible = "simple-bus";
+               #address-cells = <1>;
+               #size-cells = <0>;
+
+               reg_usb_otg_vbus: regulator@0 {
+                       compatible = "regulator-fixed";
+                       reg = <0>;
+                       regulator-name = "usb_otg_vbus";
+                       regulator-min-microvolt = <5000000>;
+                       regulator-max-microvolt = <5000000>;
+                       gpio = <&gpio4 15 0>;
+               };
+
+               reg_usb_h1_vbus: regulator@1 {
+                       compatible = "regulator-fixed";
+                       reg = <1>;
+                       regulator-name = "usb_h1_vbus";
+                       regulator-min-microvolt = <5000000>;
+                       regulator-max-microvolt = <5000000>;
+                       gpio = <&gpio1 0 0>;
+               };
+       };
+
+       gpio_leds: leds {
+               compatible = "gpio-leds";
+
+               green {
+                       label = "phyflex:green";
+                       gpios = <&gpio1 30 0>;
+               };
+
+               red {
+                       label = "phyflex:red";
+                       gpios = <&gpio2 31 0>;
+               };
+       };
+};
+
+&ecspi3 {
+       pinctrl-names = "default";
+       pinctrl-0 = <&pinctrl_ecspi3>;
+       status = "okay";
+       fsl,spi-num-chipselects = <1>;
+       cs-gpios = <&gpio4 24 0>;
+
+       flash@0 {
+               compatible = "m25p80";
+               spi-max-frequency = <20000000>;
+               reg = <0>;
+       };
+};
+
+&i2c1 {
+       pinctrl-names = "default";
+       pinctrl-0 = <&pinctrl_i2c1>;
+       status = "okay";
+
+       eeprom@50 {
+               compatible = "atmel,24c32";
+               reg = <0x50>;
+       };
+
+       pmic@58 {
+               compatible = "dlg,da9063";
+               reg = <0x58>;
+               interrupt-parent = <&gpio4>;
+               interrupts = <17 0x8>; /* active-low GPIO4_17 */
+
+               regulators {
+                       vddcore_reg: bcore1 {
+                               regulator-min-microvolt = <730000>;
+                               regulator-max-microvolt = <1380000>;
+                               regulator-always-on;
+                       };
+
+                       vddsoc_reg: bcore2 {
+                               regulator-min-microvolt = <730000>;
+                               regulator-max-microvolt = <1380000>;
+                               regulator-always-on;
+                       };
+
+                       vdd_ddr3_reg: bpro {
+                               regulator-min-microvolt = <1500000>;
+                               regulator-max-microvolt = <1500000>;
+                               regulator-always-on;
+                       };
+
+                       vdd_3v3_reg: bperi {
+                               regulator-min-microvolt = <3300000>;
+                               regulator-max-microvolt = <3300000>;
+                               regulator-always-on;
+                       };
+
+                       vdd_buckmem_reg: bmem {
+                               regulator-min-microvolt = <3300000>;
+                               regulator-max-microvolt = <3300000>;
+                               regulator-always-on;
+                       };
+
+                       vdd_eth_reg: bio {
+                               regulator-min-microvolt = <1200000>;
+                               regulator-max-microvolt = <1200000>;
+                               regulator-always-on;
+                       };
+
+                       vdd_eth_io_reg: ldo4 {
+                               regulator-min-microvolt = <2500000>;
+                               regulator-max-microvolt = <2500000>;
+                               regulator-always-on;
+                       };
+
+                       vdd_mx6_snvs_reg: ldo5 {
+                               regulator-min-microvolt = <3000000>;
+                               regulator-max-microvolt = <3000000>;
+                               regulator-always-on;
+                       };
+
+                       vdd_3v3_pmic_io_reg: ldo6 {
+                               regulator-min-microvolt = <3300000>;
+                               regulator-max-microvolt = <3300000>;
+                               regulator-always-on;
+                       };
+
+                       vdd_sd0_reg: ldo9 {
+                               regulator-min-microvolt = <3300000>;
+                               regulator-max-microvolt = <3300000>;
+                       };
+
+                       vdd_sd1_reg: ldo10 {
+                               regulator-min-microvolt = <3300000>;
+                               regulator-max-microvolt = <3300000>;
+                       };
+
+                       vdd_mx6_high_reg: ldo11 {
+                               regulator-min-microvolt = <3000000>;
+                               regulator-max-microvolt = <3000000>;
+                               regulator-always-on;
+                       };
+               };
+       };
+};
+
+&iomuxc {
+       pinctrl-names = "default";
+       pinctrl-0 = <&pinctrl_hog>;
+
+       imx6q-phytec-pfla02 {
+               pinctrl_hog: hoggrp {
+                       fsl,pins = <
+                               MX6QDL_PAD_EIM_D23__GPIO3_IO23 0x80000000
+                               MX6QDL_PAD_DISP0_DAT3__GPIO4_IO24 0x80000000 /* SPI NOR chipselect */
+                               MX6QDL_PAD_DI0_PIN15__GPIO4_IO17  0x80000000 /* PMIC interrupt */
+                               MX6QDL_PAD_ENET_TXD0__GPIO1_IO30 0x80000000 /* Green LED */
+                               MX6QDL_PAD_EIM_EB3__GPIO2_IO31 0x80000000 /* Red LED */
+                       >;
+               };
+
+               pinctrl_ecspi3: ecspi3grp {
+                       fsl,pins = <
+                               MX6QDL_PAD_DISP0_DAT2__ECSPI3_MISO      0x100b1
+                               MX6QDL_PAD_DISP0_DAT1__ECSPI3_MOSI      0x100b1
+                               MX6QDL_PAD_DISP0_DAT0__ECSPI3_SCLK      0x100b1
+                       >;
+               };
+
+               pinctrl_enet: enetgrp {
+                       fsl,pins = <
+                               MX6QDL_PAD_ENET_MDIO__ENET_MDIO         0x1b0b0
+                               MX6QDL_PAD_ENET_MDC__ENET_MDC           0x1b0b0
+                               MX6QDL_PAD_RGMII_TXC__RGMII_TXC         0x1b0b0
+                               MX6QDL_PAD_RGMII_TD0__RGMII_TD0         0x1b0b0
+                               MX6QDL_PAD_RGMII_TD1__RGMII_TD1         0x1b0b0
+                               MX6QDL_PAD_RGMII_TD2__RGMII_TD2         0x1b0b0
+                               MX6QDL_PAD_RGMII_TD3__RGMII_TD3         0x1b0b0
+                               MX6QDL_PAD_RGMII_TX_CTL__RGMII_TX_CTL   0x1b0b0
+                               MX6QDL_PAD_ENET_REF_CLK__ENET_TX_CLK    0x1b0b0
+                               MX6QDL_PAD_RGMII_RXC__RGMII_RXC         0x1b0b0
+                               MX6QDL_PAD_RGMII_RD0__RGMII_RD0         0x1b0b0
+                               MX6QDL_PAD_RGMII_RD1__RGMII_RD1         0x1b0b0
+                               MX6QDL_PAD_RGMII_RD2__RGMII_RD2         0x1b0b0
+                               MX6QDL_PAD_RGMII_RD3__RGMII_RD3         0x1b0b0
+                               MX6QDL_PAD_RGMII_RX_CTL__RGMII_RX_CTL   0x1b0b0
+                               MX6QDL_PAD_ENET_TX_EN__ENET_TX_EN       0x1b0b0
+                       >;
+               };
+
+               pinctrl_gpmi_nand: gpminandgrp {
+                       fsl,pins = <
+                               MX6QDL_PAD_NANDF_CLE__NAND_CLE          0xb0b1
+                               MX6QDL_PAD_NANDF_ALE__NAND_ALE          0xb0b1
+                               MX6QDL_PAD_NANDF_WP_B__NAND_WP_B        0xb0b1
+                               MX6QDL_PAD_NANDF_RB0__NAND_READY_B      0xb000
+                               MX6QDL_PAD_NANDF_CS0__NAND_CE0_B        0xb0b1
+                               MX6QDL_PAD_NANDF_CS1__NAND_CE1_B        0xb0b1
+                               MX6QDL_PAD_SD4_CMD__NAND_RE_B           0xb0b1
+                               MX6QDL_PAD_SD4_CLK__NAND_WE_B           0xb0b1
+                               MX6QDL_PAD_NANDF_D0__NAND_DATA00        0xb0b1
+                               MX6QDL_PAD_NANDF_D1__NAND_DATA01        0xb0b1
+                               MX6QDL_PAD_NANDF_D2__NAND_DATA02        0xb0b1
+                               MX6QDL_PAD_NANDF_D3__NAND_DATA03        0xb0b1
+                               MX6QDL_PAD_NANDF_D4__NAND_DATA04        0xb0b1
+                               MX6QDL_PAD_NANDF_D5__NAND_DATA05        0xb0b1
+                               MX6QDL_PAD_NANDF_D6__NAND_DATA06        0xb0b1
+                               MX6QDL_PAD_NANDF_D7__NAND_DATA07        0xb0b1
+                               MX6QDL_PAD_SD4_DAT0__NAND_DQS           0x00b1
+                       >;
+               };
+
+               pinctrl_i2c1: i2c1grp {
+                       fsl,pins = <
+                               MX6QDL_PAD_EIM_D21__I2C1_SCL            0x4001b8b1
+                               MX6QDL_PAD_EIM_D28__I2C1_SDA            0x4001b8b1
+                       >;
+               };
+
+               pinctrl_uart3: uart3grp {
+                       fsl,pins = <
+                               MX6QDL_PAD_EIM_D24__UART3_TX_DATA       0x1b0b1
+                               MX6QDL_PAD_EIM_D25__UART3_RX_DATA       0x1b0b1
+                               MX6QDL_PAD_EIM_D30__UART3_RTS_B         0x1b0b1
+                               MX6QDL_PAD_EIM_D31__UART3_CTS_B         0x1b0b1
+                       >;
+               };
+
+               pinctrl_uart4: uart4grp {
+                       fsl,pins = <
+                               MX6QDL_PAD_KEY_COL0__UART4_TX_DATA      0x1b0b1
+                               MX6QDL_PAD_KEY_ROW0__UART4_RX_DATA      0x1b0b1
+                       >;
+               };
+
+               pinctrl_usbh1: usbh1grp {
+                       fsl,pins = <
+                               MX6QDL_PAD_GPIO_0__USB_H1_PWR           0x80000000
+                       >;
+               };
+
+               pinctrl_usbotg: usbotggrp {
+                       fsl,pins = <
+                               MX6QDL_PAD_GPIO_1__USB_OTG_ID           0x17059
+                               MX6QDL_PAD_KEY_COL4__USB_OTG_OC         0x1b0b0
+                               MX6QDL_PAD_KEY_ROW4__GPIO4_IO15         0x80000000
+                       >;
+               };
+
+               pinctrl_usdhc2: usdhc2grp {
+                       fsl,pins = <
+                               MX6QDL_PAD_SD2_CMD__SD2_CMD             0x17059
+                               MX6QDL_PAD_SD2_CLK__SD2_CLK             0x10059
+                               MX6QDL_PAD_SD2_DAT0__SD2_DATA0          0x17059
+                               MX6QDL_PAD_SD2_DAT1__SD2_DATA1          0x17059
+                               MX6QDL_PAD_SD2_DAT2__SD2_DATA2          0x17059
+                               MX6QDL_PAD_SD2_DAT3__SD2_DATA3          0x17059
+                       >;
+               };
+
+               pinctrl_usdhc3: usdhc3grp {
+                       fsl,pins = <
+                               MX6QDL_PAD_SD3_CMD__SD3_CMD             0x17059
+                               MX6QDL_PAD_SD3_CLK__SD3_CLK             0x10059
+                               MX6QDL_PAD_SD3_DAT0__SD3_DATA0          0x17059
+                               MX6QDL_PAD_SD3_DAT1__SD3_DATA1          0x17059
+                               MX6QDL_PAD_SD3_DAT2__SD3_DATA2          0x17059
+                               MX6QDL_PAD_SD3_DAT3__SD3_DATA3          0x17059
+                       >;
+               };
+
+               pinctrl_usdhc3_cdwp: usdhc3cdwp {
+                       fsl,pins = <
+                               MX6QDL_PAD_ENET_RXD0__GPIO1_IO27 0x80000000
+                               MX6QDL_PAD_ENET_TXD1__GPIO1_IO29 0x80000000
+                       >;
+               };
+       };
+};
+
+&fec {
+       pinctrl-names = "default";
+       pinctrl-0 = <&pinctrl_enet>;
+       phy-mode = "rgmii";
+       phy-reset-gpios = <&gpio3 23 GPIO_ACTIVE_LOW>;
+       phy-supply = <&vdd_eth_io_reg>;
+       status = "disabled";
+};
+
+&gpmi {
+       pinctrl-names = "default";
+       pinctrl-0 = <&pinctrl_gpmi_nand>;
+       nand-on-flash-bbt;
+       status = "disabled";
+};
+
+&uart3 {
+       pinctrl-names = "default";
+       pinctrl-0 = <&pinctrl_uart3>;
+       status = "disabled";
+};
+
+&uart4 {
+       pinctrl-names = "default";
+       pinctrl-0 = <&pinctrl_uart4>;
+       status = "disabled";
+};
+
+&usbh1 {
+       vbus-supply = <&reg_usb_h1_vbus>;
+       pinctrl-names = "default";
+       pinctrl-0 = <&pinctrl_usbh1>;
+       status = "disabled";
+};
+
+&usbotg {
+       vbus-supply = <&reg_usb_otg_vbus>;
+       pinctrl-names = "default";
+       pinctrl-0 = <&pinctrl_usbotg>;
+       disable-over-current;
+       status = "disabled";
+};
+
+&usdhc2 {
+       pinctrl-names = "default";
+       pinctrl-0 = <&pinctrl_usdhc2>;
+       cd-gpios = <&gpio1 4 0>;
+       wp-gpios = <&gpio1 2 0>;
+       status = "disabled";
+};
+
+&usdhc3 {
+        pinctrl-names = "default";
+        pinctrl-0 = <&pinctrl_usdhc3
+                    &pinctrl_usdhc3_cdwp>;
+        cd-gpios = <&gpio1 27 0>;
+        wp-gpios = <&gpio1 29 0>;
+        status = "disabled";
+};
diff --git a/arch/arm/boot/dts/r7s72100-genmai-reference.dts b/arch/arm/boot/dts/r7s72100-genmai-reference.dts
deleted file mode 100644 (file)
index da19c70..0000000
+++ /dev/null
@@ -1,31 +0,0 @@
-/*
- * Device Tree Source for the Genmai board
- *
- * Copyright (C) 2013 Renesas Solutions Corp.
- *
- * 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.
- */
-
-/dts-v1/;
-/include/ "r7s72100.dtsi"
-
-/ {
-       model = "Genmai";
-       compatible = "renesas,genmai-reference", "renesas,r7s72100";
-
-       chosen {
-               bootargs = "console=ttySC2,115200 ignore_loglevel rw root=/dev/nfs ip=dhcp";
-       };
-
-       memory {
-               device_type = "memory";
-               reg = <0x08000000 0x08000000>;
-       };
-
-       lbsc {
-               #address-cells = <1>;
-               #size-cells = <1>;
-       };
-};
index b1deaf7..a3ed23c 100644 (file)
@@ -1,7 +1,8 @@
 /*
  * Device Tree Source for the Genmai board
  *
- * Copyright (C) 2013 Renesas Solutions Corp.
+ * Copyright (C) 2013-14 Renesas Solutions Corp.
+ * Copyright (C) 2014 Wolfram Sang, Sang Engineering <wsa@sang-engineering.com>
  *
  * This file is licensed under the terms of the GNU General Public License
  * version 2.  This program is licensed "as is" without any warranty of any
        model = "Genmai";
        compatible = "renesas,genmai", "renesas,r7s72100";
 
+       aliases {
+               serial2 = &scif2;
+       };
+
        chosen {
                bootargs = "console=ttySC2,115200 ignore_loglevel rw root=/dev/nfs ip=dhcp";
        };
                #size-cells = <1>;
        };
 };
+
+&extal_clk {
+       clock-frequency = <13330000>;
+};
+
+&usb_x1_clk {
+       clock-frequency = <48000000>;
+};
+
+&mtu2 {
+       status = "ok";
+};
+
+&i2c2 {
+       status = "okay";
+       clock-frequency = <400000>;
+
+       eeprom@50 {
+               compatible = "renesas,24c128";
+               reg = <0x50>;
+               pagesize = <64>;
+       };
+};
+
+&scif2 {
+       status = "okay";
+};
+
+&spi4 {
+       status = "okay";
+
+       codec: codec@0 {
+               compatible = "wlf,wm8978";
+               reg = <0>;
+               spi-max-frequency = <5000000>;
+       };
+};
index 46b82aa..801a556 100644 (file)
 /*
  * Device Tree Source for the r7s72100 SoC
  *
- * Copyright (C) 2013 Renesas Solutions Corp.
+ * Copyright (C) 2013-14 Renesas Solutions Corp.
+ * Copyright (C) 2014 Wolfram Sang, Sang Engineering <wsa@sang-engineering.com>
  *
  * This file is licensed under the terms of the GNU General Public License
  * version 2.  This program is licensed "as is" without any warranty of any
  * kind, whether express or implied.
  */
 
+#include <dt-bindings/clock/r7s72100-clock.h>
+#include <dt-bindings/interrupt-controller/irq.h>
+
 / {
        compatible = "renesas,r7s72100";
        interrupt-parent = <&gic>;
        #address-cells = <1>;
        #size-cells = <1>;
 
+       aliases {
+               i2c0 = &i2c0;
+               i2c1 = &i2c1;
+               i2c2 = &i2c2;
+               i2c3 = &i2c3;
+               spi0 = &spi0;
+               spi1 = &spi1;
+               spi2 = &spi2;
+               spi3 = &spi3;
+               spi4 = &spi4;
+       };
+
+       clocks {
+               ranges;
+               #address-cells = <1>;
+               #size-cells = <1>;
+
+               /* External clocks */
+               extal_clk: extal_clk {
+                       #clock-cells = <0>;
+                       compatible = "fixed-clock";
+                       /* If clk present, value must be set by board */
+                       clock-frequency = <0>;
+                       clock-output-names = "extal";
+               };
+
+               usb_x1_clk: usb_x1_clk {
+                       #clock-cells = <0>;
+                       compatible = "fixed-clock";
+                       /* If clk present, value must be set by board */
+                       clock-frequency = <0>;
+                       clock-output-names = "usb_x1";
+               };
+
+               /* Special CPG clocks */
+               cpg_clocks: cpg_clocks@fcfe0000 {
+                       #clock-cells = <1>;
+                       compatible = "renesas,r7s72100-cpg-clocks",
+                                    "renesas,rz-cpg-clocks";
+                       reg = <0xfcfe0000 0x18>;
+                       clocks = <&extal_clk>, <&usb_x1_clk>;
+                       clock-output-names = "pll", "i", "g";
+               };
+
+               /* Fixed factor clocks */
+               b_clk: b_clk {
+                       #clock-cells = <0>;
+                       compatible = "fixed-factor-clock";
+                       clocks = <&cpg_clocks R7S72100_CLK_PLL>;
+                       clock-mult = <1>;
+                       clock-div = <3>;
+                       clock-output-names = "b";
+               };
+               p1_clk: p1_clk {
+                       #clock-cells = <0>;
+                       compatible = "fixed-factor-clock";
+                       clocks = <&cpg_clocks R7S72100_CLK_PLL>;
+                       clock-mult = <1>;
+                       clock-div = <6>;
+                       clock-output-names = "p1";
+               };
+               p0_clk: p0_clk {
+                       #clock-cells = <0>;
+                       compatible = "fixed-factor-clock";
+                       clocks = <&cpg_clocks R7S72100_CLK_PLL>;
+                       clock-mult = <1>;
+                       clock-div = <12>;
+                       clock-output-names = "p0";
+               };
+
+               /* MSTP clocks */
+               mstp3_clks: mstp3_clks@fcfe0420 {
+                       #clock-cells = <1>;
+                       compatible = "renesas,r7s72100-mstp-clocks", "renesas,cpg-mstp-clocks";
+                       reg = <0xfcfe0420 4>;
+                       clocks = <&p0_clk>;
+                       clock-indices = <R7S72100_CLK_MTU2>;
+                       clock-output-names = "mtu2";
+               };
+
+               mstp4_clks: mstp4_clks@fcfe0424 {
+                       #clock-cells = <1>;
+                       compatible = "renesas,r7s72100-mstp-clocks", "renesas,cpg-mstp-clocks";
+                       reg = <0xfcfe0424 4>;
+                       clocks = <&p1_clk>, <&p1_clk>, <&p1_clk>, <&p1_clk>,
+                                <&p1_clk>, <&p1_clk>, <&p1_clk>, <&p1_clk>;
+                       clock-indices = <
+                               R7S72100_CLK_SCIF0 R7S72100_CLK_SCIF1 R7S72100_CLK_SCIF2 R7S72100_CLK_SCIF3
+                               R7S72100_CLK_SCIF4 R7S72100_CLK_SCIF5 R7S72100_CLK_SCIF6 R7S72100_CLK_SCIF7
+                       >;
+                       clock-output-names = "scif0", "scif1", "scif2", "scif3", "scif4", "scif5", "scif6", "scif7";
+               };
+
+               mstp9_clks: mstp9_clks@fcfe0438 {
+                       #clock-cells = <1>;
+                       compatible = "renesas,r7s72100-mstp-clocks", "renesas,cpg-mstp-clocks";
+                       reg = <0xfcfe0438 4>;
+                       clocks = <&p0_clk>, <&p0_clk>, <&p0_clk>, <&p0_clk>;
+                       clock-indices = <
+                               R7S72100_CLK_I2C0 R7S72100_CLK_I2C1 R7S72100_CLK_I2C2 R7S72100_CLK_I2C3
+                       >;
+                       clock-output-names = "i2c0", "i2c1", "i2c2", "i2c3";
+               };
+
+               mstp10_clks: mstp10_clks@fcfe043c {
+                       #clock-cells = <1>;
+                       compatible = "renesas,r7s72100-mstp-clocks", "renesas,cpg-mstp-clocks";
+                       reg = <0xfcfe043c 4>;
+                       clocks = <&p1_clk>, <&p1_clk>, <&p1_clk>, <&p1_clk>,
+                                <&p1_clk>;
+                       clock-indices = <
+                               R7S72100_CLK_SPI0 R7S72100_CLK_SPI1 R7S72100_CLK_SPI2 R7S72100_CLK_SPI3
+                               R7S72100_CLK_SPI4
+                       >;
+                       clock-output-names = "spi0", "spi1", "spi2", "spi3", "spi4";
+               };
+       };
+
        cpus {
                #address-cells = <1>;
                #size-cells = <0>;
                        device_type = "cpu";
                        compatible = "arm,cortex-a9";
                        reg = <0>;
+                       clock-frequency = <400000000>;
                };
        };
 
                reg = <0xe8201000 0x1000>,
                        <0xe8202000 0x1000>;
        };
+
+       i2c0: i2c@fcfee000 {
+               #address-cells = <1>;
+               #size-cells = <0>;
+               compatible = "renesas,riic-r7s72100", "renesas,riic-rz";
+               reg = <0xfcfee000 0x44>;
+               interrupts = <0 157 IRQ_TYPE_LEVEL_HIGH>,
+                            <0 158 IRQ_TYPE_EDGE_RISING>,
+                            <0 159 IRQ_TYPE_EDGE_RISING>,
+                            <0 160 IRQ_TYPE_LEVEL_HIGH>,
+                            <0 161 IRQ_TYPE_LEVEL_HIGH>,
+                            <0 162 IRQ_TYPE_LEVEL_HIGH>,
+                            <0 163 IRQ_TYPE_LEVEL_HIGH>,
+                            <0 164 IRQ_TYPE_LEVEL_HIGH>;
+               clocks = <&mstp9_clks R7S72100_CLK_I2C0>;
+               clock-frequency = <100000>;
+               status = "disabled";
+       };
+
+       i2c1: i2c@fcfee400 {
+               #address-cells = <1>;
+               #size-cells = <0>;
+               compatible = "renesas,riic-r7s72100", "renesas,riic-rz";
+               reg = <0xfcfee400 0x44>;
+               interrupts = <0 165 IRQ_TYPE_LEVEL_HIGH>,
+                            <0 166 IRQ_TYPE_EDGE_RISING>,
+                            <0 167 IRQ_TYPE_EDGE_RISING>,
+                            <0 168 IRQ_TYPE_LEVEL_HIGH>,
+                            <0 169 IRQ_TYPE_LEVEL_HIGH>,
+                            <0 170 IRQ_TYPE_LEVEL_HIGH>,
+                            <0 171 IRQ_TYPE_LEVEL_HIGH>,
+                            <0 172 IRQ_TYPE_LEVEL_HIGH>;
+               clocks = <&mstp9_clks R7S72100_CLK_I2C1>;
+               clock-frequency = <100000>;
+               status = "disabled";
+       };
+
+       i2c2: i2c@fcfee800 {
+               #address-cells = <1>;
+               #size-cells = <0>;
+               compatible = "renesas,riic-r7s72100", "renesas,riic-rz";
+               reg = <0xfcfee800 0x44>;
+               interrupts = <0 173 IRQ_TYPE_LEVEL_HIGH>,
+                            <0 174 IRQ_TYPE_EDGE_RISING>,
+                            <0 175 IRQ_TYPE_EDGE_RISING>,
+                            <0 176 IRQ_TYPE_LEVEL_HIGH>,
+                            <0 177 IRQ_TYPE_LEVEL_HIGH>,
+                            <0 178 IRQ_TYPE_LEVEL_HIGH>,
+                            <0 179 IRQ_TYPE_LEVEL_HIGH>,
+                            <0 180 IRQ_TYPE_LEVEL_HIGH>;
+               clocks = <&mstp9_clks R7S72100_CLK_I2C2>;
+               clock-frequency = <100000>;
+               status = "disabled";
+       };
+
+       i2c3: i2c@fcfeec00 {
+               #address-cells = <1>;
+               #size-cells = <0>;
+               compatible = "renesas,riic-r7s72100", "renesas,riic-rz";
+               reg = <0xfcfeec00 0x44>;
+               interrupts = <0 181 IRQ_TYPE_LEVEL_HIGH>,
+                            <0 182 IRQ_TYPE_EDGE_RISING>,
+                            <0 183 IRQ_TYPE_EDGE_RISING>,
+                            <0 184 IRQ_TYPE_LEVEL_HIGH>,
+                            <0 185 IRQ_TYPE_LEVEL_HIGH>,
+                            <0 186 IRQ_TYPE_LEVEL_HIGH>,
+                            <0 187 IRQ_TYPE_LEVEL_HIGH>,
+                            <0 188 IRQ_TYPE_LEVEL_HIGH>;
+               clocks = <&mstp9_clks R7S72100_CLK_I2C3>;
+               clock-frequency = <100000>;
+               status = "disabled";
+       };
+
+       mtu2: timer@fcff0000 {
+               compatible = "renesas,mtu2-r7s72100", "renesas,mtu2";
+               reg = <0xfcff0000 0x400>;
+               interrupts = <0 107 IRQ_TYPE_LEVEL_HIGH>;
+               interrupt-names = "tgi0a";
+               clocks = <&mstp3_clks R7S72100_CLK_MTU2>;
+               clock-names = "fck";
+               status = "disabled";
+       };
+
+       scif0: serial@e8007000 {
+               compatible = "renesas,scif-r7s72100", "renesas,scif";
+               reg = <0xe8007000 64>;
+               interrupts = <0 190 IRQ_TYPE_LEVEL_HIGH>,
+                            <0 191 IRQ_TYPE_LEVEL_HIGH>,
+                            <0 192 IRQ_TYPE_LEVEL_HIGH>,
+                            <0 189 IRQ_TYPE_LEVEL_HIGH>;
+               clocks = <&mstp4_clks R7S72100_CLK_SCIF0>;
+               clock-names = "sci_ick";
+               status = "disabled";
+       };
+
+       scif1: serial@e8007800 {
+               compatible = "renesas,scif-r7s72100", "renesas,scif";
+               reg = <0xe8007800 64>;
+               interrupts = <0 194 IRQ_TYPE_LEVEL_HIGH>,
+                            <0 195 IRQ_TYPE_LEVEL_HIGH>,
+                            <0 196 IRQ_TYPE_LEVEL_HIGH>,
+                            <0 193 IRQ_TYPE_LEVEL_HIGH>;
+               clocks = <&mstp4_clks R7S72100_CLK_SCIF1>;
+               clock-names = "sci_ick";
+               status = "disabled";
+       };
+
+       scif2: serial@e8008000 {
+               compatible = "renesas,scif-r7s72100", "renesas,scif";
+               reg = <0xe8008000 64>;
+               interrupts = <0 198 IRQ_TYPE_LEVEL_HIGH>,
+                            <0 199 IRQ_TYPE_LEVEL_HIGH>,
+                            <0 200 IRQ_TYPE_LEVEL_HIGH>,
+                            <0 197 IRQ_TYPE_LEVEL_HIGH>;
+               clocks = <&mstp4_clks R7S72100_CLK_SCIF2>;
+               clock-names = "sci_ick";
+               status = "disabled";
+       };
+
+       scif3: serial@e8008800 {
+               compatible = "renesas,scif-r7s72100", "renesas,scif";
+               reg = <0xe8008800 64>;
+               interrupts = <0 202 IRQ_TYPE_LEVEL_HIGH>,
+                            <0 203 IRQ_TYPE_LEVEL_HIGH>,
+                            <0 204 IRQ_TYPE_LEVEL_HIGH>,
+                            <0 201 IRQ_TYPE_LEVEL_HIGH>;
+               clocks = <&mstp4_clks R7S72100_CLK_SCIF3>;
+               clock-names = "sci_ick";
+               status = "disabled";
+       };
+
+       scif4: serial@e8009000 {
+               compatible = "renesas,scif-r7s72100", "renesas,scif";
+               reg = <0xe8009000 64>;
+               interrupts = <0 206 IRQ_TYPE_LEVEL_HIGH>,
+                            <0 207 IRQ_TYPE_LEVEL_HIGH>,
+                            <0 208 IRQ_TYPE_LEVEL_HIGH>,
+                            <0 205 IRQ_TYPE_LEVEL_HIGH>;
+               clocks = <&mstp4_clks R7S72100_CLK_SCIF4>;
+               clock-names = "sci_ick";
+               status = "disabled";
+       };
+
+       scif5: serial@e8009800 {
+               compatible = "renesas,scif-r7s72100", "renesas,scif";
+               reg = <0xe8009800 64>;
+               interrupts = <0 210 IRQ_TYPE_LEVEL_HIGH>,
+                            <0 211 IRQ_TYPE_LEVEL_HIGH>,
+                            <0 212 IRQ_TYPE_LEVEL_HIGH>,
+                            <0 209 IRQ_TYPE_LEVEL_HIGH>;
+               clocks = <&mstp4_clks R7S72100_CLK_SCIF5>;
+               clock-names = "sci_ick";
+               status = "disabled";
+       };
+
+       scif6: serial@e800a000 {
+               compatible = "renesas,scif-r7s72100", "renesas,scif";
+               reg = <0xe800a000 64>;
+               interrupts = <0 214 IRQ_TYPE_LEVEL_HIGH>,
+                            <0 215 IRQ_TYPE_LEVEL_HIGH>,
+                            <0 216 IRQ_TYPE_LEVEL_HIGH>,
+                            <0 213 IRQ_TYPE_LEVEL_HIGH>;
+               clocks = <&mstp4_clks R7S72100_CLK_SCIF6>;
+               clock-names = "sci_ick";
+               status = "disabled";
+       };
+
+       scif7: serial@e800a800 {
+               compatible = "renesas,scif-r7s72100", "renesas,scif";
+               reg = <0xe800a800 64>;
+               interrupts = <0 218 IRQ_TYPE_LEVEL_HIGH>,
+                            <0 219 IRQ_TYPE_LEVEL_HIGH>,
+                            <0 220 IRQ_TYPE_LEVEL_HIGH>,
+                            <0 217 IRQ_TYPE_LEVEL_HIGH>;
+               clocks = <&mstp4_clks R7S72100_CLK_SCIF7>;
+               clock-names = "sci_ick";
+               status = "disabled";
+       };
+
+       spi0: spi@e800c800 {
+               compatible = "renesas,rspi-r7s72100", "renesas,rspi-rz";
+               reg = <0xe800c800 0x24>;
+               interrupts = <0 238 IRQ_TYPE_LEVEL_HIGH>,
+                            <0 239 IRQ_TYPE_LEVEL_HIGH>,
+                            <0 240 IRQ_TYPE_LEVEL_HIGH>;
+               interrupt-names = "error", "rx", "tx";
+               clocks = <&mstp10_clks R7S72100_CLK_SPI0>;
+               num-cs = <1>;
+               #address-cells = <1>;
+               #size-cells = <0>;
+               status = "disabled";
+       };
+
+       spi1: spi@e800d000 {
+               compatible = "renesas,rspi-r7s72100", "renesas,rspi-rz";
+               reg = <0xe800d000 0x24>;
+               interrupts = <0 241 IRQ_TYPE_LEVEL_HIGH>,
+                            <0 242 IRQ_TYPE_LEVEL_HIGH>,
+                            <0 243 IRQ_TYPE_LEVEL_HIGH>;
+               interrupt-names = "error", "rx", "tx";
+               clocks = <&mstp10_clks R7S72100_CLK_SPI1>;
+               num-cs = <1>;
+               #address-cells = <1>;
+               #size-cells = <0>;
+               status = "disabled";
+       };
+
+       spi2: spi@e800d800 {
+               compatible = "renesas,rspi-r7s72100", "renesas,rspi-rz";
+               reg = <0xe800d800 0x24>;
+               interrupts = <0 244 IRQ_TYPE_LEVEL_HIGH>,
+                            <0 245 IRQ_TYPE_LEVEL_HIGH>,
+                            <0 246 IRQ_TYPE_LEVEL_HIGH>;
+               interrupt-names = "error", "rx", "tx";
+               clocks = <&mstp10_clks R7S72100_CLK_SPI2>;
+               num-cs = <1>;
+               #address-cells = <1>;
+               #size-cells = <0>;
+               status = "disabled";
+       };
+
+       spi3: spi@e800e000 {
+               compatible = "renesas,rspi-r7s72100", "renesas,rspi-rz";
+               reg = <0xe800e000 0x24>;
+               interrupts = <0 247 IRQ_TYPE_LEVEL_HIGH>,
+                            <0 248 IRQ_TYPE_LEVEL_HIGH>,
+                            <0 249 IRQ_TYPE_LEVEL_HIGH>;
+               interrupt-names = "error", "rx", "tx";
+               clocks = <&mstp10_clks R7S72100_CLK_SPI3>;
+               num-cs = <1>;
+               #address-cells = <1>;
+               #size-cells = <0>;
+               status = "disabled";
+       };
+
+       spi4: spi@e800e800 {
+               compatible = "renesas,rspi-r7s72100", "renesas,rspi-rz";
+               reg = <0xe800e800 0x24>;
+               interrupts = <0 250 IRQ_TYPE_LEVEL_HIGH>,
+                            <0 251 IRQ_TYPE_LEVEL_HIGH>,
+                            <0 252 IRQ_TYPE_LEVEL_HIGH>;
+               interrupt-names = "error", "rx", "tx";
+               clocks = <&mstp10_clks R7S72100_CLK_SPI4>;
+               num-cs = <1>;
+               #address-cells = <1>;
+               #size-cells = <0>;
+               status = "disabled";
+       };
 };
index 70b1fff..a860f32 100644 (file)
        model = "APE6EVM";
        compatible = "renesas,ape6evm-reference", "renesas,r8a73a4";
 
+       aliases {
+               serial0 = &scifa0;
+       };
+
        chosen {
                bootargs = "console=ttySC0,115200 ignore_loglevel rw";
        };
@@ -90,9 +94,6 @@
 };
 
 &pfc {
-       pinctrl-0 = <&scifa0_pins>;
-       pinctrl-names = "default";
-
        scifa0_pins: serial0 {
                renesas,groups = "scifa0_data";
                renesas,function = "scifa0";
        status = "okay";
 };
 
+&scifa0 {
+       pinctrl-0 = <&scifa0_pins>;
+       pinctrl-names = "default";
+
+       status = "okay";
+};
+
 &sdhi0 {
        vmmc-supply = <&vcc_sdhi0>;
        bus-width = <4>;
index 62d0211..ef152e3 100644 (file)
        };
 
        irqc0: interrupt-controller@e61c0000 {
-               compatible = "renesas,irqc";
+               compatible = "renesas,irqc-r8a73a4", "renesas,irqc";
                #interrupt-cells = <2>;
                interrupt-controller;
                reg = <0 0xe61c0000 0 0x200>;
-               interrupt-parent = <&gic>;
                interrupts = <0 0 IRQ_TYPE_LEVEL_HIGH>,
                             <0 1 IRQ_TYPE_LEVEL_HIGH>,
                             <0 2 IRQ_TYPE_LEVEL_HIGH>,
        };
 
        irqc1: interrupt-controller@e61c0200 {
-               compatible = "renesas,irqc";
+               compatible = "renesas,irqc-r8a73a4", "renesas,irqc";
                #interrupt-cells = <2>;
                interrupt-controller;
                reg = <0 0xe61c0200 0 0x200>;
-               interrupt-parent = <&gic>;
                interrupts = <0 32 IRQ_TYPE_LEVEL_HIGH>,
                             <0 33 IRQ_TYPE_LEVEL_HIGH>,
                             <0 34 IRQ_TYPE_LEVEL_HIGH>,
                dma0: dma-controller@e6700020 {
                        compatible = "renesas,shdma-r8a73a4";
                        reg = <0 0xe6700020 0 0x89e0>;
-                       interrupt-parent = <&gic>;
                        interrupts = <0 220 IRQ_TYPE_LEVEL_HIGH
                                        0 200 IRQ_TYPE_LEVEL_HIGH
                                        0 201 IRQ_TYPE_LEVEL_HIGH
        };
 
        thermal@e61f0000 {
-               compatible = "renesas,rcar-thermal";
+               compatible = "renesas,thermal-r8a73a4", "renesas,rcar-thermal";
                reg = <0 0xe61f0000 0 0x14>, <0 0xe61f0100 0 0x38>,
                         <0 0xe61f0200 0 0x38>, <0 0xe61f0300 0 0x38>;
-               interrupt-parent = <&gic>;
                interrupts = <0 69 IRQ_TYPE_LEVEL_HIGH>;
        };
 
                #size-cells = <0>;
                compatible = "renesas,rmobile-iic";
                reg = <0 0xe6500000 0 0x428>;
-               interrupt-parent = <&gic>;
                interrupts = <0 174 IRQ_TYPE_LEVEL_HIGH>;
                status = "disabled";
        };
                #size-cells = <0>;
                compatible = "renesas,rmobile-iic";
                reg = <0 0xe6510000 0 0x428>;
-               interrupt-parent = <&gic>;
                interrupts = <0 175 IRQ_TYPE_LEVEL_HIGH>;
                status = "disabled";
        };
                #size-cells = <0>;
                compatible = "renesas,rmobile-iic";
                reg = <0 0xe6520000 0 0x428>;
-               interrupt-parent = <&gic>;
                interrupts = <0 176 IRQ_TYPE_LEVEL_HIGH>;
                status = "disabled";
        };
                #size-cells = <0>;
                compatible = "renesas,rmobile-iic";
                reg = <0 0xe6530000 0 0x428>;
-               interrupt-parent = <&gic>;
                interrupts = <0 177 IRQ_TYPE_LEVEL_HIGH>;
                status = "disabled";
        };
                #size-cells = <0>;
                compatible = "renesas,rmobile-iic";
                reg = <0 0xe6540000 0 0x428>;
-               interrupt-parent = <&gic>;
                interrupts = <0 178 IRQ_TYPE_LEVEL_HIGH>;
                status = "disabled";
        };
                #size-cells = <0>;
                compatible = "renesas,rmobile-iic";
                reg = <0 0xe60b0000 0 0x428>;
-               interrupt-parent = <&gic>;
                interrupts = <0 179 IRQ_TYPE_LEVEL_HIGH>;
                status = "disabled";
        };
                #size-cells = <0>;
                compatible = "renesas,rmobile-iic";
                reg = <0 0xe6550000 0 0x428>;
-               interrupt-parent = <&gic>;
                interrupts = <0 184 IRQ_TYPE_LEVEL_HIGH>;
                status = "disabled";
        };
                #size-cells = <0>;
                compatible = "renesas,rmobile-iic";
                reg = <0 0xe6560000 0 0x428>;
-               interrupt-parent = <&gic>;
                interrupts = <0 185 IRQ_TYPE_LEVEL_HIGH>;
                status = "disabled";
        };
                #size-cells = <0>;
                compatible = "renesas,rmobile-iic";
                reg = <0 0xe6570000 0 0x428>;
-               interrupt-parent = <&gic>;
                interrupts = <0 173 IRQ_TYPE_LEVEL_HIGH>;
                status = "disabled";
        };
 
+       scifa0: serial@e6c40000 {
+               compatible = "renesas,scifa-r8a73a4", "renesas,scifa";
+               reg = <0 0xe6c40000 0 0x100>;
+               interrupts = <0 144 IRQ_TYPE_LEVEL_HIGH>;
+               status = "disabled";
+       };
+
+       scifa1: serial@e6c50000 {
+               compatible = "renesas,scifa-r8a73a4", "renesas,scifa";
+               reg = <0 0xe6c50000 0 0x100>;
+               interrupts = <0 145 IRQ_TYPE_LEVEL_HIGH>;
+               status = "disabled";
+       };
+
+       scifb2: serial@e6c20000 {
+               compatible = "renesas,scifb-r8a73a4", "renesas,scifb";
+               reg = <0 0xe6c20000 0 0x100>;
+               interrupts = <0 148 IRQ_TYPE_LEVEL_HIGH>;
+               status = "disabled";
+       };
+
+       scifb3: serial@e6c30000 {
+               compatible = "renesas,scifb-r8a73a4", "renesas,scifb";
+               reg = <0 0xe6c30000 0 0x100>;
+               interrupts = <0 149 IRQ_TYPE_LEVEL_HIGH>;
+               status = "disabled";
+       };
+
+       scifb4: serial@e6ce0000 {
+               compatible = "renesas,scifb-r8a73a4", "renesas,scifb";
+               reg = <0 0xe6ce0000 0 0x100>;
+               interrupts = <0 150 IRQ_TYPE_LEVEL_HIGH>;
+               status = "disabled";
+       };
+
+       scifb5: serial@e6cf0000 {
+               compatible = "renesas,scifb-r8a73a4", "renesas,scifb";
+               reg = <0 0xe6cf0000 0 0x100>;
+               interrupts = <0 151 IRQ_TYPE_LEVEL_HIGH>;
+               status = "disabled";
+       };
+
        mmcif0: mmc@ee200000 {
                compatible = "renesas,sh-mmcif";
                reg = <0 0xee200000 0 0x80>;
-               interrupt-parent = <&gic>;
                interrupts = <0 169 IRQ_TYPE_LEVEL_HIGH>;
                reg-io-width = <4>;
                status = "disabled";
        mmcif1: mmc@ee220000 {
                compatible = "renesas,sh-mmcif";
                reg = <0 0xee220000 0 0x80>;
-               interrupt-parent = <&gic>;
                interrupts = <0 170 IRQ_TYPE_LEVEL_HIGH>;
                reg-io-width = <4>;
                status = "disabled";
        sdhi0: sd@ee100000 {
                compatible = "renesas,sdhi-r8a73a4";
                reg = <0 0xee100000 0 0x100>;
-               interrupt-parent = <&gic>;
                interrupts = <0 165 IRQ_TYPE_LEVEL_HIGH>;
                cap-sd-highspeed;
                status = "disabled";
        sdhi1: sd@ee120000 {
                compatible = "renesas,sdhi-r8a73a4";
                reg = <0 0xee120000 0 0x100>;
-               interrupt-parent = <&gic>;
                interrupts = <0 166 IRQ_TYPE_LEVEL_HIGH>;
                cap-sd-highspeed;
                status = "disabled";
        sdhi2: sd@ee140000 {
                compatible = "renesas,sdhi-r8a73a4";
                reg = <0 0xee140000 0 0x100>;
-               interrupt-parent = <&gic>;
                interrupts = <0 167 IRQ_TYPE_LEVEL_HIGH>;
                cap-sd-highspeed;
                status = "disabled";
diff --git a/arch/arm/boot/dts/r8a7740-armadillo800eva-reference.dts b/arch/arm/boot/dts/r8a7740-armadillo800eva-reference.dts
deleted file mode 100644 (file)
index 95a849b..0000000
+++ /dev/null
@@ -1,235 +0,0 @@
-/*
- * Reference Device Tree Source for the armadillo 800 eva board
- *
- * Copyright (C) 2012 Renesas Solutions Corp.
- *
- * 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.
- */
-
-/dts-v1/;
-#include "r8a7740.dtsi"
-#include <dt-bindings/gpio/gpio.h>
-#include <dt-bindings/interrupt-controller/irq.h>
-#include <dt-bindings/pwm/pwm.h>
-
-/ {
-       model = "armadillo 800 eva reference";
-       compatible = "renesas,armadillo800eva-reference", "renesas,r8a7740";
-
-       chosen {
-               bootargs = "console=tty0 console=ttySC1,115200 earlyprintk=sh-sci.1,115200 ignore_loglevel root=/dev/nfs ip=dhcp rw";
-       };
-
-       memory {
-               device_type = "memory";
-               reg = <0x40000000 0x20000000>;
-       };
-
-       reg_3p3v: regulator@0 {
-               compatible = "regulator-fixed";
-               regulator-name = "fixed-3.3V";
-               regulator-min-microvolt = <3300000>;
-               regulator-max-microvolt = <3300000>;
-               regulator-always-on;
-               regulator-boot-on;
-       };
-
-       vcc_sdhi0: regulator@1 {
-               compatible = "regulator-fixed";
-
-               regulator-name = "SDHI0 Vcc";
-               regulator-min-microvolt = <3300000>;
-               regulator-max-microvolt = <3300000>;
-
-               gpio = <&pfc 75 GPIO_ACTIVE_HIGH>;
-               enable-active-high;
-       };
-
-       vccq_sdhi0: regulator@2 {
-               compatible = "regulator-gpio";
-
-               regulator-name = "SDHI0 VccQ";
-               regulator-min-microvolt = <1800000>;
-               regulator-max-microvolt = <3300000>;
-               vin-supply = <&vcc_sdhi0>;
-
-               enable-gpio = <&pfc 74 GPIO_ACTIVE_HIGH>;
-               gpios = <&pfc 17 GPIO_ACTIVE_HIGH>;
-               states = <3300000 0
-                         1800000 1>;
-
-               enable-active-high;
-       };
-
-       reg_5p0v: regulator@3 {
-               compatible = "regulator-fixed";
-               regulator-name = "fixed-5.0V";
-               regulator-min-microvolt = <5000000>;
-               regulator-max-microvolt = <5000000>;
-               regulator-always-on;
-               regulator-boot-on;
-       };
-
-       gpio-keys {
-               compatible = "gpio-keys";
-
-               power-key {
-                       gpios = <&pfc 99 GPIO_ACTIVE_LOW>;
-                       linux,code = <116>;
-                       label = "SW3";
-                       gpio-key,wakeup;
-               };
-
-               back-key {
-                       gpios = <&pfc 100 GPIO_ACTIVE_LOW>;
-                       linux,code = <158>;
-                       label = "SW4";
-               };
-
-               menu-key {
-                       gpios = <&pfc 97 GPIO_ACTIVE_LOW>;
-                       linux,code = <139>;
-                       label = "SW5";
-               };
-
-               home-key {
-                       gpios = <&pfc 98 GPIO_ACTIVE_LOW>;
-                       linux,code = <102>;
-                       label = "SW6";
-               };
-       };
-
-       leds {
-               compatible = "gpio-leds";
-               led1 {
-                       gpios = <&pfc 102 GPIO_ACTIVE_HIGH>;
-               };
-               led2 {
-                       gpios = <&pfc 111 GPIO_ACTIVE_HIGH>;
-               };
-               led3 {
-                       gpios = <&pfc 110 GPIO_ACTIVE_HIGH>;
-               };
-               led4 {
-                       gpios = <&pfc 177 GPIO_ACTIVE_HIGH>;
-               };
-       };
-
-       backlight {
-               compatible = "pwm-backlight";
-               pwms = <&tpu 2 33333 PWM_POLARITY_INVERTED>;
-               brightness-levels = <0 1 2 4 8 16 32 64 128 255>;
-               default-brightness-level = <9>;
-               pinctrl-0 = <&backlight_pins>;
-               pinctrl-names = "default";
-               power-supply = <&reg_5p0v>;
-               enable-gpios = <&pfc 61 GPIO_ACTIVE_HIGH>;
-       };
-
-       sound {
-               compatible = "simple-audio-card";
-
-               simple-audio-card,format = "i2s";
-
-               simple-audio-card,cpu {
-                       sound-dai = <&sh_fsi2 0>;
-                       bitclock-inversion;
-               };
-
-               simple-audio-card,codec {
-                       sound-dai = <&wm8978>;
-                       bitclock-master;
-                       frame-master;
-                       system-clock-frequency = <12288000>;
-               };
-       };
-};
-
-&i2c0 {
-       status = "okay";
-       touchscreen@55 {
-               compatible = "sitronix,st1232";
-               reg = <0x55>;
-               interrupt-parent = <&irqpin1>;
-               interrupts = <2 IRQ_TYPE_LEVEL_LOW>;
-               pinctrl-0 = <&st1232_pins>;
-               pinctrl-names = "default";
-               gpios = <&pfc 166 GPIO_ACTIVE_LOW>;
-       };
-
-       wm8978: wm8978@1a {
-               #sound-dai-cells = <0>;
-               compatible = "wlf,wm8978";
-               reg = <0x1a>;
-       };
-};
-
-&pfc {
-       pinctrl-0 = <&scifa1_pins>;
-       pinctrl-names = "default";
-
-       scifa1_pins: serial1 {
-               renesas,groups = "scifa1_data";
-               renesas,function = "scifa1";
-       };
-
-       st1232_pins: touchscreen {
-               renesas,groups = "intc_irq10";
-               renesas,function = "intc";
-       };
-
-       backlight_pins: backlight {
-               renesas,groups = "tpu0_to2_1";
-               renesas,function = "tpu0";
-       };
-
-       mmc0_pins: mmc0 {
-               renesas,groups = "mmc0_data8_1", "mmc0_ctrl_1";
-               renesas,function = "mmc0";
-       };
-
-       sdhi0_pins: sd0 {
-               renesas,groups = "sdhi0_data4", "sdhi0_ctrl", "sdhi0_wp";
-               renesas,function = "sdhi0";
-       };
-
-       fsia_pins: sounda {
-               renesas,groups = "fsia_sclk_in", "fsia_mclk_out",
-                                "fsia_data_in_1", "fsia_data_out_0";
-               renesas,function = "fsia";
-       };
-};
-
-&tpu {
-       status = "okay";
-};
-
-&mmcif0 {
-       pinctrl-0 = <&mmc0_pins>;
-       pinctrl-names = "default";
-
-       vmmc-supply = <&reg_3p3v>;
-       bus-width = <8>;
-       non-removable;
-       status = "okay";
-};
-
-&sdhi0 {
-       pinctrl-0 = <&sdhi0_pins>;
-       pinctrl-names = "default";
-
-       vmmc-supply = <&vcc_sdhi0>;
-       vqmmc-supply = <&vccq_sdhi0>;
-       bus-width = <4>;
-       cd-gpios = <&pfc 167 GPIO_ACTIVE_LOW>;
-       status = "okay";
-};
-
-&sh_fsi2 {
-       pinctrl-0 = <&fsia_pins>;
-       pinctrl-names = "default";
-
-       status = "okay";
-};
index a06a11e..effb7b4 100644 (file)
 
 /dts-v1/;
 #include "r8a7740.dtsi"
+#include <dt-bindings/gpio/gpio.h>
+#include <dt-bindings/input/input.h>
+#include <dt-bindings/interrupt-controller/irq.h>
+#include <dt-bindings/pwm/pwm.h>
 
 / {
        model = "armadillo 800 eva";
-       compatible = "renesas,armadillo800eva";
+       compatible = "renesas,armadillo800eva", "renesas,r8a7740";
+
+       aliases {
+               serial1 = &scifa1;
+       };
 
        chosen {
                bootargs = "console=tty0 console=ttySC1,115200 earlyprintk=sh-sci.1,115200 ignore_loglevel root=/dev/nfs ip=dhcp rw";
                device_type = "memory";
                reg = <0x40000000 0x20000000>;
        };
+
+       reg_3p3v: regulator@0 {
+               compatible = "regulator-fixed";
+               regulator-name = "fixed-3.3V";
+               regulator-min-microvolt = <3300000>;
+               regulator-max-microvolt = <3300000>;
+               regulator-always-on;
+               regulator-boot-on;
+       };
+
+       vcc_sdhi0: regulator@1 {
+               compatible = "regulator-fixed";
+
+               regulator-name = "SDHI0 Vcc";
+               regulator-min-microvolt = <3300000>;
+               regulator-max-microvolt = <3300000>;
+
+               gpio = <&pfc 75 GPIO_ACTIVE_HIGH>;
+               enable-active-high;
+       };
+
+       vccq_sdhi0: regulator@2 {
+               compatible = "regulator-gpio";
+
+               regulator-name = "SDHI0 VccQ";
+               regulator-min-microvolt = <1800000>;
+               regulator-max-microvolt = <3300000>;
+               vin-supply = <&vcc_sdhi0>;
+
+               enable-gpio = <&pfc 74 GPIO_ACTIVE_HIGH>;
+               gpios = <&pfc 17 GPIO_ACTIVE_HIGH>;
+               states = <3300000 0
+                         1800000 1>;
+
+               enable-active-high;
+       };
+
+       reg_5p0v: regulator@3 {
+               compatible = "regulator-fixed";
+               regulator-name = "fixed-5.0V";
+               regulator-min-microvolt = <5000000>;
+               regulator-max-microvolt = <5000000>;
+               regulator-always-on;
+               regulator-boot-on;
+       };
+
+       gpio-keys {
+               compatible = "gpio-keys";
+
+               power-key {
+                       gpios = <&pfc 99 GPIO_ACTIVE_LOW>;
+                       linux,code = <KEY_POWER>;
+                       label = "SW3";
+                       gpio-key,wakeup;
+               };
+
+               back-key {
+                       gpios = <&pfc 100 GPIO_ACTIVE_LOW>;
+                       linux,code = <KEY_BACK>;
+                       label = "SW4";
+               };
+
+               menu-key {
+                       gpios = <&pfc 97 GPIO_ACTIVE_LOW>;
+                       linux,code = <KEY_MENU>;
+                       label = "SW5";
+               };
+
+               home-key {
+                       gpios = <&pfc 98 GPIO_ACTIVE_LOW>;
+                       linux,code = <KEY_HOME>;
+                       label = "SW6";
+               };
+       };
+
+       leds {
+               compatible = "gpio-leds";
+               led3 {
+                       gpios = <&pfc 102 GPIO_ACTIVE_HIGH>;
+                       label = "LED3";
+               };
+               led4 {
+                       gpios = <&pfc 111 GPIO_ACTIVE_HIGH>;
+                       label = "LED4";
+               };
+               led5 {
+                       gpios = <&pfc 110 GPIO_ACTIVE_HIGH>;
+                       label = "LED5";
+               };
+               led6 {
+                       gpios = <&pfc 177 GPIO_ACTIVE_HIGH>;
+                       label = "LED6";
+               };
+       };
+
+       i2c2: i2c@2 {
+               #address-cells = <1>;
+               #size-cells = <0>;
+               compatible = "i2c-gpio";
+               gpios = <&pfc 208 GPIO_ACTIVE_HIGH /* sda */
+                        &pfc 91 GPIO_ACTIVE_HIGH /* scl */
+                       >;
+               i2c-gpio,delay-us = <5>;
+       };
+
+       backlight {
+               compatible = "pwm-backlight";
+               pwms = <&tpu 2 33333 PWM_POLARITY_INVERTED>;
+               brightness-levels = <0 1 2 4 8 16 32 64 128 255>;
+               default-brightness-level = <9>;
+               pinctrl-0 = <&backlight_pins>;
+               pinctrl-names = "default";
+               power-supply = <&reg_5p0v>;
+               enable-gpios = <&pfc 61 GPIO_ACTIVE_HIGH>;
+       };
+
+       sound {
+               compatible = "simple-audio-card";
+
+               simple-audio-card,format = "i2s";
+
+               simple-audio-card,cpu {
+                       sound-dai = <&sh_fsi2 0>;
+                       bitclock-inversion;
+               };
+
+               simple-audio-card,codec {
+                       sound-dai = <&wm8978>;
+                       bitclock-master;
+                       frame-master;
+                       system-clock-frequency = <12288000>;
+               };
+       };
+};
+
+&ether {
+       pinctrl-0 = <&ether_pins>;
+       pinctrl-names = "default";
+
+       phy-handle = <&phy0>;
+       status = "ok";
+
+       phy0: ethernet-phy@0 {
+               reg = <0>;
+       };
+};
+
+&extal1_clk {
+       clock-frequency = <25000000>;
+};
+&extal2_clk {
+       clock-frequency = <48000000>;
+};
+&fsibck_clk {
+       clock-frequency = <12288000>;
+};
+&cpg_clocks {
+       renesas,mode = <0x05>; /* MD_CK0 | MD_CK2 */
+};
+
+&cmt1 {
+       status = "ok";
+};
+
+&i2c0 {
+       status = "okay";
+       touchscreen@55 {
+               compatible = "sitronix,st1232";
+               reg = <0x55>;
+               interrupt-parent = <&irqpin1>;
+               interrupts = <2 IRQ_TYPE_LEVEL_LOW>;
+               pinctrl-0 = <&st1232_pins>;
+               pinctrl-names = "default";
+               gpios = <&pfc 166 GPIO_ACTIVE_LOW>;
+       };
+
+       wm8978: wm8978@1a {
+               #sound-dai-cells = <0>;
+               compatible = "wlf,wm8978";
+               reg = <0x1a>;
+       };
+};
+
+&i2c2 {
+       status = "okay";
+       rtc@30 {
+               compatible = "sii,s35390a";
+               reg = <0x30>;
+       };
+};
+
+&pfc {
+       ether_pins: ether {
+               renesas,groups = "gether_mii", "gether_int";
+               renesas,function = "gether";
+       };
+
+       scifa1_pins: serial1 {
+               renesas,groups = "scifa1_data";
+               renesas,function = "scifa1";
+       };
+
+       st1232_pins: touchscreen {
+               renesas,groups = "intc_irq10";
+               renesas,function = "intc";
+       };
+
+       backlight_pins: backlight {
+               renesas,groups = "tpu0_to2_1";
+               renesas,function = "tpu0";
+       };
+
+       mmc0_pins: mmc0 {
+               renesas,groups = "mmc0_data8_1", "mmc0_ctrl_1";
+               renesas,function = "mmc0";
+       };
+
+       sdhi0_pins: sd0 {
+               renesas,groups = "sdhi0_data4", "sdhi0_ctrl", "sdhi0_wp";
+               renesas,function = "sdhi0";
+       };
+
+       fsia_pins: sounda {
+               renesas,groups = "fsia_sclk_in", "fsia_mclk_out",
+                                "fsia_data_in_1", "fsia_data_out_0";
+               renesas,function = "fsia";
+       };
+};
+
+&tpu {
+       status = "okay";
+};
+
+&mmcif0 {
+       pinctrl-0 = <&mmc0_pins>;
+       pinctrl-names = "default";
+
+       vmmc-supply = <&reg_3p3v>;
+       bus-width = <8>;
+       non-removable;
+       status = "okay";
+};
+
+&scifa1 {
+       pinctrl-0 = <&scifa1_pins>;
+       pinctrl-names = "default";
+
+       status = "okay";
+};
+
+&sdhi0 {
+       pinctrl-0 = <&sdhi0_pins>;
+       pinctrl-names = "default";
+
+       vmmc-supply = <&vcc_sdhi0>;
+       vqmmc-supply = <&vccq_sdhi0>;
+       bus-width = <4>;
+       cd-gpios = <&pfc 167 GPIO_ACTIVE_LOW>;
+       status = "okay";
+};
+
+&sh_fsi2 {
+       pinctrl-0 = <&fsia_pins>;
+       pinctrl-names = "default";
+
+       status = "okay";
 };
index 8280884..d46c213 100644 (file)
 
 /include/ "skeleton.dtsi"
 
+#include <dt-bindings/clock/r8a7740-clock.h>
 #include <dt-bindings/interrupt-controller/irq.h>
 
 / {
        compatible = "renesas,r8a7740";
+       interrupt-parent = <&gic>;
 
        cpus {
                #address-cells = <1>;
                        compatible = "arm,cortex-a9";
                        device_type = "cpu";
                        reg = <0x0>;
+                       clock-frequency = <800000000>;
                };
        };
 
        gic: interrupt-controller@c2800000 {
                compatible = "arm,cortex-a9-gic";
                #interrupt-cells = <3>;
-               #address-cells = <1>;
                interrupt-controller;
                reg = <0xc2800000 0x1000>,
                      <0xc2000000 0x1000>;
                interrupts = <0 83 IRQ_TYPE_LEVEL_HIGH>;
        };
 
+       cmt1: timer@e6138000 {
+               compatible = "renesas,cmt-48-r8a7740", "renesas,cmt-48";
+               reg = <0xe6138000 0x170>;
+               interrupts = <0 58 IRQ_TYPE_LEVEL_HIGH>;
+               clocks = <&mstp3_clks R8A7740_CLK_CMT1>;
+               clock-names = "fck";
+
+               renesas,channels-mask = <0x3f>;
+
+               status = "disabled";
+       };
+
        /* irqpin0: IRQ0 - IRQ7 */
        irqpin0: irqpin@e6900000 {
                compatible = "renesas,intc-irqpin-r8a7740", "renesas,intc-irqpin";
@@ -49,7 +63,6 @@
                        <0xe6900020 1>,
                        <0xe6900040 1>,
                        <0xe6900060 1>;
-               interrupt-parent = <&gic>;
                interrupts = <0 149 IRQ_TYPE_LEVEL_HIGH
                              0 149 IRQ_TYPE_LEVEL_HIGH
                              0 149 IRQ_TYPE_LEVEL_HIGH
@@ -70,7 +83,6 @@
                        <0xe6900024 1>,
                        <0xe6900044 1>,
                        <0xe6900064 1>;
-               interrupt-parent = <&gic>;
                interrupts = <0 149 IRQ_TYPE_LEVEL_HIGH
                              0 149 IRQ_TYPE_LEVEL_HIGH
                              0 149 IRQ_TYPE_LEVEL_HIGH
                        <0xe6900028 1>,
                        <0xe6900048 1>,
                        <0xe6900068 1>;
-               interrupt-parent = <&gic>;
                interrupts = <0 149 IRQ_TYPE_LEVEL_HIGH
                              0 149 IRQ_TYPE_LEVEL_HIGH
                              0 149 IRQ_TYPE_LEVEL_HIGH
                        <0xe690002c 1>,
                        <0xe690004c 1>,
                        <0xe690006c 1>;
-               interrupt-parent = <&gic>;
                interrupts = <0 149 IRQ_TYPE_LEVEL_HIGH
                              0 149 IRQ_TYPE_LEVEL_HIGH
                              0 149 IRQ_TYPE_LEVEL_HIGH
                              0 149 IRQ_TYPE_LEVEL_HIGH>;
        };
 
+       ether: ethernet@e9a00000 {
+               compatible = "renesas,gether-r8a7740";
+               reg = <0xe9a00000 0x800>,
+                     <0xe9a01800 0x800>;
+               interrupts = <0 110 IRQ_TYPE_LEVEL_HIGH>;
+               clocks = <&mstp3_clks R8A7740_CLK_GETHER>;
+               phy-mode = "mii";
+               #address-cells = <1>;
+               #size-cells = <0>;
+               status = "disabled";
+       };
+
        i2c0: i2c@fff20000 {
                #address-cells = <1>;
                #size-cells = <0>;
-               compatible = "renesas,rmobile-iic";
+               compatible = "renesas,iic-r8a7740", "renesas,rmobile-iic";
                reg = <0xfff20000 0x425>;
-               interrupt-parent = <&gic>;
                interrupts = <0 201 IRQ_TYPE_LEVEL_HIGH
                              0 202 IRQ_TYPE_LEVEL_HIGH
                              0 203 IRQ_TYPE_LEVEL_HIGH
                              0 204 IRQ_TYPE_LEVEL_HIGH>;
+               clocks = <&mstp1_clks R8A7740_CLK_IIC0>;
                status = "disabled";
        };
 
        i2c1: i2c@e6c20000 {
                #address-cells = <1>;
                #size-cells = <0>;
-               compatible = "renesas,rmobile-iic";
+               compatible = "renesas,iic-r8a7740", "renesas,rmobile-iic";
                reg = <0xe6c20000 0x425>;
-               interrupt-parent = <&gic>;
                interrupts = <0 70 IRQ_TYPE_LEVEL_HIGH
                              0 71 IRQ_TYPE_LEVEL_HIGH
                              0 72 IRQ_TYPE_LEVEL_HIGH
                              0 73 IRQ_TYPE_LEVEL_HIGH>;
+               clocks = <&mstp3_clks R8A7740_CLK_IIC1>;
+               status = "disabled";
+       };
+
+       scifa0: serial@e6c40000 {
+               compatible = "renesas,scifa-r8a7740", "renesas,scifa";
+               reg = <0xe6c40000 0x100>;
+               interrupts = <0 100 IRQ_TYPE_LEVEL_HIGH>;
+               clocks = <&mstp2_clks R8A7740_CLK_SCIFA0>;
+               clock-names = "sci_ick";
+               status = "disabled";
+       };
+
+       scifa1: serial@e6c50000 {
+               compatible = "renesas,scifa-r8a7740", "renesas,scifa";
+               reg = <0xe6c50000 0x100>;
+               interrupts = <0 101 IRQ_TYPE_LEVEL_HIGH>;
+               clocks = <&mstp2_clks R8A7740_CLK_SCIFA1>;
+               clock-names = "sci_ick";
+               status = "disabled";
+       };
+
+       scifa2: serial@e6c60000 {
+               compatible = "renesas,scifa-r8a7740", "renesas,scifa";
+               reg = <0xe6c60000 0x100>;
+               interrupts = <0 102 IRQ_TYPE_LEVEL_HIGH>;
+               clocks = <&mstp2_clks R8A7740_CLK_SCIFA0>;
+               clock-names = "sci_ick";
+               status = "disabled";
+       };
+
+       scifa3: serial@e6c70000 {
+               compatible = "renesas,scifa-r8a7740", "renesas,scifa";
+               reg = <0xe6c70000 0x100>;
+               interrupts = <0 103 IRQ_TYPE_LEVEL_HIGH>;
+               clocks = <&mstp2_clks R8A7740_CLK_SCIFA3>;
+               clock-names = "sci_ick";
+               status = "disabled";
+       };
+
+       scifa4: serial@e6c80000 {
+               compatible = "renesas,scifa-r8a7740", "renesas,scifa";
+               reg = <0xe6c80000 0x100>;
+               interrupts = <0 104 IRQ_TYPE_LEVEL_HIGH>;
+               clocks = <&mstp2_clks R8A7740_CLK_SCIFA4>;
+               clock-names = "sci_ick";
+               status = "disabled";
+       };
+
+       scifa5: serial@e6cb0000 {
+               compatible = "renesas,scifa-r8a7740", "renesas,scifa";
+               reg = <0xe6cb0000 0x100>;
+               interrupts = <0 105 IRQ_TYPE_LEVEL_HIGH>;
+               clocks = <&mstp2_clks R8A7740_CLK_SCIFA5>;
+               clock-names = "sci_ick";
+               status = "disabled";
+       };
+
+       scifa6: serial@e6cc0000 {
+               compatible = "renesas,scifa-r8a7740", "renesas,scifa";
+               reg = <0xe6cc0000 0x100>;
+               interrupts = <0 106 IRQ_TYPE_LEVEL_HIGH>;
+               clocks = <&mstp2_clks R8A7740_CLK_SCIFA6>;
+               clock-names = "sci_ick";
+               status = "disabled";
+       };
+
+       scifa7: serial@e6cd0000 {
+               compatible = "renesas,scifa-r8a7740", "renesas,scifa";
+               reg = <0xe6cd0000 0x100>;
+               interrupts = <0 107 IRQ_TYPE_LEVEL_HIGH>;
+               clocks = <&mstp2_clks R8A7740_CLK_SCIFA7>;
+               clock-names = "sci_ick";
+               status = "disabled";
+       };
+
+       scifb8: serial@e6c30000 {
+               compatible = "renesas,scifb-r8a7740", "renesas,scifb";
+               reg = <0xe6c30000 0x100>;
+               interrupts = <0 108 IRQ_TYPE_LEVEL_HIGH>;
+               clocks = <&mstp2_clks R8A7740_CLK_SCIFB>;
+               clock-names = "sci_ick";
                status = "disabled";
        };
 
        tpu: pwm@e6600000 {
                compatible = "renesas,tpu-r8a7740", "renesas,tpu";
                reg = <0xe6600000 0x100>;
+               clocks = <&mstp3_clks R8A7740_CLK_TPU0>;
                status = "disabled";
                #pwm-cells = <3>;
        };
 
        mmcif0: mmc@e6bd0000 {
-               compatible = "renesas,sh-mmcif";
+               compatible = "renesas,mmcif-r8a7740", "renesas,sh-mmcif";
                reg = <0xe6bd0000 0x100>;
-               interrupt-parent = <&gic>;
                interrupts = <0 56 IRQ_TYPE_LEVEL_HIGH
                              0 57 IRQ_TYPE_LEVEL_HIGH>;
+               clocks = <&mstp3_clks R8A7740_CLK_MMC>;
                status = "disabled";
        };
 
        sdhi0: sd@e6850000 {
                compatible = "renesas,sdhi-r8a7740";
                reg = <0xe6850000 0x100>;
-               interrupt-parent = <&gic>;
                interrupts = <0 117 IRQ_TYPE_LEVEL_HIGH
                              0 118 IRQ_TYPE_LEVEL_HIGH
                              0 119 IRQ_TYPE_LEVEL_HIGH>;
+               clocks = <&mstp3_clks R8A7740_CLK_SDHI0>;
                cap-sd-highspeed;
                cap-sdio-irq;
                status = "disabled";
        sdhi1: sd@e6860000 {
                compatible = "renesas,sdhi-r8a7740";
                reg = <0xe6860000 0x100>;
-               interrupt-parent = <&gic>;
                interrupts = <0 121 IRQ_TYPE_LEVEL_HIGH
                              0 122 IRQ_TYPE_LEVEL_HIGH
                              0 123 IRQ_TYPE_LEVEL_HIGH>;
+               clocks = <&mstp3_clks R8A7740_CLK_SDHI1>;
                cap-sd-highspeed;
                cap-sdio-irq;
                status = "disabled";
        sdhi2: sd@e6870000 {
                compatible = "renesas,sdhi-r8a7740";
                reg = <0xe6870000 0x100>;
-               interrupt-parent = <&gic>;
                interrupts = <0 125 IRQ_TYPE_LEVEL_HIGH
                              0 126 IRQ_TYPE_LEVEL_HIGH
                              0 127 IRQ_TYPE_LEVEL_HIGH>;
+               clocks = <&mstp4_clks R8A7740_CLK_SDHI2>;
                cap-sd-highspeed;
                cap-sdio-irq;
                status = "disabled";
 
        sh_fsi2: sound@fe1f0000 {
                #sound-dai-cells = <1>;
-               compatible = "renesas,sh_fsi2";
+               compatible = "renesas,fsi2-r8a7740", "renesas,sh_fsi2";
                reg = <0xfe1f0000 0x400>;
-               interrupt-parent = <&gic>;
                interrupts = <0 9 0x4>;
+               clocks = <&mstp3_clks R8A7740_CLK_FSI>;
                status = "disabled";
        };
+
+       clocks {
+               #address-cells = <1>;
+               #size-cells = <1>;
+               ranges;
+
+               /* External root clock */
+               extalr_clk: extalr_clk {
+                       compatible = "fixed-clock";
+                       #clock-cells = <0>;
+                       clock-frequency = <32768>;
+                       clock-output-names = "extalr";
+               };
+               extal1_clk: extal1_clk {
+                       compatible = "fixed-clock";
+                       #clock-cells = <0>;
+                       clock-frequency = <0>;
+                       clock-output-names = "extal1";
+               };
+               extal2_clk: extal2_clk {
+                       compatible = "fixed-clock";
+                       #clock-cells = <0>;
+                       clock-frequency = <0>;
+                       clock-output-names = "extal2";
+               };
+               dv_clk: dv_clk {
+                       compatible = "fixed-clock";
+                       #clock-cells = <0>;
+                       clock-frequency = <27000000>;
+                       clock-output-names = "dv";
+               };
+               fsiack_clk: fsiack_clk {
+                       compatible = "fixed-clock";
+                       #clock-cells = <0>;
+                       clock-frequency = <0>;
+                       clock-output-names = "fsiack";
+               };
+               fsibck_clk: fsibck_clk {
+                       compatible = "fixed-clock";
+                       #clock-cells = <0>;
+                       clock-frequency = <0>;
+                       clock-output-names = "fsibck";
+               };
+
+               /* Special CPG clocks */
+               cpg_clocks: cpg_clocks@e6150000 {
+                       compatible = "renesas,r8a7740-cpg-clocks";
+                       reg = <0xe6150000 0x10000>;
+                       clocks = <&extal1_clk>, <&extalr_clk>;
+                       #clock-cells = <1>;
+                       clock-output-names = "system", "pllc0", "pllc1",
+                                            "pllc2", "r",
+                                            "usb24s",
+                                            "i", "zg", "b", "m1", "hp",
+                                            "hpp", "usbp", "s", "zb", "m3",
+                                            "cp";
+               };
+
+               /* Variable factor clocks (DIV6) */
+               sub_clk: sub_clk@e6150080 {
+                       compatible = "renesas,r8a7740-div6-clock", "renesas,cpg-div6-clock";
+                       reg = <0xe6150080 4>;
+                       clocks = <&pllc1_div2_clk>;
+                       #clock-cells = <0>;
+                       clock-output-names = "sub";
+               };
+
+               /* Fixed factor clocks */
+               pllc1_div2_clk: pllc1_div2_clk {
+                       compatible = "fixed-factor-clock";
+                       clocks = <&cpg_clocks R8A7740_CLK_PLLC1>;
+                       #clock-cells = <0>;
+                       clock-div = <2>;
+                       clock-mult = <1>;
+                       clock-output-names = "pllc1_div2";
+               };
+               extal1_div2_clk: extal1_div2_clk {
+                       compatible = "fixed-factor-clock";
+                       clocks = <&extal1_clk>;
+                       #clock-cells = <0>;
+                       clock-div = <2>;
+                       clock-mult = <1>;
+                       clock-output-names = "extal1_div2";
+               };
+
+               /* Gate clocks */
+               subck_clks: subck_clks@e6150080 {
+                       compatible = "renesas,r8a7740-mstp-clocks", "renesas,cpg-mstp-clocks";
+                       reg = <0xe6150080 4>;
+                       clocks = <&sub_clk>, <&sub_clk>;
+                       #clock-cells = <1>;
+                       renesas,clock-indices = <
+                               R8A7740_CLK_SUBCK R8A7740_CLK_SUBCK2
+                       >;
+                       clock-output-names =
+                               "subck", "subck2";
+               };
+               mstp1_clks: mstp1_clks@e6150134 {
+                       compatible = "renesas,r8a7740-mstp-clocks", "renesas,cpg-mstp-clocks";
+                       reg = <0xe6150134 4>, <0xe6150038 4>;
+                       clocks = <&cpg_clocks R8A7740_CLK_S>,
+                                <&cpg_clocks R8A7740_CLK_S>, <&sub_clk>,
+                                <&cpg_clocks R8A7740_CLK_B>,
+                                <&sub_clk>, <&sub_clk>,
+                                <&cpg_clocks R8A7740_CLK_B>;
+                       #clock-cells = <1>;
+                       renesas,clock-indices = <
+                               R8A7740_CLK_CEU21 R8A7740_CLK_CEU20 R8A7740_CLK_TMU0
+                               R8A7740_CLK_LCDC1 R8A7740_CLK_IIC0 R8A7740_CLK_TMU1
+                               R8A7740_CLK_LCDC0
+                       >;
+                       clock-output-names =
+                               "ceu21", "ceu20", "tmu0", "lcdc1", "iic0",
+                               "tmu1", "lcdc0";
+               };
+               mstp2_clks: mstp2_clks@e6150138 {
+                       compatible = "renesas,r8a7740-mstp-clocks", "renesas,cpg-mstp-clocks";
+                       reg = <0xe6150138 4>, <0xe6150040 4>;
+                       clocks = <&sub_clk>, <&sub_clk>,
+                                <&cpg_clocks R8A7740_CLK_HP>,
+                                <&cpg_clocks R8A7740_CLK_HP>,
+                                <&cpg_clocks R8A7740_CLK_HP>,
+                                <&cpg_clocks R8A7740_CLK_HP>,
+                                <&sub_clk>, <&sub_clk>, <&sub_clk>,
+                                <&sub_clk>, <&sub_clk>, <&sub_clk>,
+                                <&sub_clk>;
+                       #clock-cells = <1>;
+                       renesas,clock-indices = <
+                               R8A7740_CLK_SCIFA6 R8A7740_CLK_SCIFA7
+                               R8A7740_CLK_DMAC1 R8A7740_CLK_DMAC2
+                               R8A7740_CLK_DMAC3 R8A7740_CLK_USBDMAC
+                               R8A7740_CLK_SCIFA5 R8A7740_CLK_SCIFB
+                               R8A7740_CLK_SCIFA0 R8A7740_CLK_SCIFA1
+                               R8A7740_CLK_SCIFA2 R8A7740_CLK_SCIFA3
+                               R8A7740_CLK_SCIFA4
+                       >;
+                       clock-output-names =
+                               "scifa6", "scifa7", "dmac1", "dmac2", "dmac3",
+                               "usbdmac", "scifa5", "scifb", "scifa0", "scifa1",
+                               "scifa2", "scifa3", "scifa4";
+               };
+               mstp3_clks: mstp3_clks@e615013c {
+                       compatible = "renesas,r8a7740-mstp-clocks", "renesas,cpg-mstp-clocks";
+                       reg = <0xe615013c 4>, <0xe6150048 4>;
+                       clocks = <&cpg_clocks R8A7740_CLK_R>,
+                                <&cpg_clocks R8A7740_CLK_HP>,
+                                <&sub_clk>,
+                                <&cpg_clocks R8A7740_CLK_HP>,
+                                <&cpg_clocks R8A7740_CLK_HP>,
+                                <&cpg_clocks R8A7740_CLK_HP>,
+                                <&cpg_clocks R8A7740_CLK_HP>,
+                                <&cpg_clocks R8A7740_CLK_HP>,
+                                <&cpg_clocks R8A7740_CLK_HP>;
+                       #clock-cells = <1>;
+                       renesas,clock-indices = <
+                               R8A7740_CLK_CMT1 R8A7740_CLK_FSI R8A7740_CLK_IIC1
+                               R8A7740_CLK_USBF R8A7740_CLK_SDHI0 R8A7740_CLK_SDHI1
+                               R8A7740_CLK_MMC R8A7740_CLK_GETHER R8A7740_CLK_TPU0
+                       >;
+                       clock-output-names =
+                               "cmt1", "fsi", "iic1", "usbf", "sdhi0", "sdhi1",
+                               "mmc", "gether", "tpu0";
+               };
+               mstp4_clks: mstp4_clks@e6150140 {
+                       compatible = "renesas,r8a7740-mstp-clocks", "renesas,cpg-mstp-clocks";
+                       reg = <0xe6150140 4>, <0xe615004c 4>;
+                       clocks = <&cpg_clocks R8A7740_CLK_HP>,
+                                <&cpg_clocks R8A7740_CLK_HP>,
+                                <&cpg_clocks R8A7740_CLK_HP>,
+                                <&cpg_clocks R8A7740_CLK_HP>;
+                       #clock-cells = <1>;
+                       renesas,clock-indices = <
+                               R8A7740_CLK_USBH R8A7740_CLK_SDHI2
+                               R8A7740_CLK_USBFUNC R8A7740_CLK_USBPHY
+                       >;
+                       clock-output-names =
+                               "usbhost", "sdhi2", "usbfunc", "usphy";
+               };
+       };
 };
index bb62c7a..3342c74 100644 (file)
 /dts-v1/;
 #include "r8a7778.dtsi"
 #include <dt-bindings/interrupt-controller/irq.h>
+#include <dt-bindings/gpio/gpio.h>
 
 / {
        model = "bockw";
        compatible = "renesas,bockw-reference", "renesas,r8a7778";
 
+       aliases {
+               serial0 = &scif0;
+       };
+
        chosen {
                bootargs = "console=ttySC0,115200 ignore_loglevel root=/dev/nfs ip=dhcp rw";
        };
@@ -69,9 +74,6 @@
 };
 
 &pfc {
-       pinctrl-0 = <&scif0_pins>;
-       pinctrl-names = "default";
-
        scif0_pins: serial0 {
                renesas,groups = "scif0_data_a", "scif0_ctrl";
                renesas,function = "scif0";
@@ -84,7 +86,7 @@
 
        sdhi0_pins: sd0 {
                renesas,groups = "sdhi0_data4", "sdhi0_ctrl",
-                                 "sdhi0_cd", "sdhi0_wp";
+                                 "sdhi0_cd";
                renesas,function = "sdhi0";
        };
 
        vmmc-supply = <&fixedregulator3v3>;
        bus-width = <4>;
        status = "okay";
+       wp-gpios = <&gpio3 18 GPIO_ACTIVE_HIGH>;
 };
 
 &hspi0 {
        pinctrl-0 = <&hspi0_pins>;
        pinctrl-names = "default";
        status = "okay";
+
+       flash: flash@0 {
+               #address-cells = <1>;
+               #size-cells = <1>;
+               compatible = "spansion,s25fl008k";
+               reg = <0>;
+               spi-max-frequency = <104000000>;
+               m25p,fast-read;
+
+               partition@0 {
+                       label = "data(spi)";
+                       reg = <0x00000000 0x00100000>;
+               };
+       };
+};
+
+&scif0 {
+       pinctrl-0 = <&scif0_pins>;
+       pinctrl-names = "default";
+
+       status = "okay";
 };
index ddb3bd7..315ec62 100644 (file)
 
 / {
        compatible = "renesas,r8a7778";
+       interrupt-parent = <&gic>;
 
        cpus {
+               #address-cells = <1>;
+               #size-cells = <0>;
+
                cpu@0 {
+                       device_type = "cpu";
                        compatible = "arm,cortex-a9";
+                       reg = <0>;
+                       clock-frequency = <800000000>;
                };
        };
 
@@ -52,7 +59,6 @@
                        <0xfe780024 4>,
                        <0xfe780044 4>,
                        <0xfe780064 4>;
-               interrupt-parent = <&gic>;
                interrupts =   <0 27 IRQ_TYPE_LEVEL_HIGH
                                0 28 IRQ_TYPE_LEVEL_HIGH
                                0 29 IRQ_TYPE_LEVEL_HIGH
@@ -63,7 +69,6 @@
        gpio0: gpio@ffc40000 {
                compatible = "renesas,gpio-r8a7778", "renesas,gpio-rcar";
                reg = <0xffc40000 0x2c>;
-               interrupt-parent = <&gic>;
                interrupts = <0 103 IRQ_TYPE_LEVEL_HIGH>;
                #gpio-cells = <2>;
                gpio-controller;
@@ -75,7 +80,6 @@
        gpio1: gpio@ffc41000 {
                compatible = "renesas,gpio-r8a7778", "renesas,gpio-rcar";
                reg = <0xffc41000 0x2c>;
-               interrupt-parent = <&gic>;
                interrupts = <0 103 IRQ_TYPE_LEVEL_HIGH>;
                #gpio-cells = <2>;
                gpio-controller;
@@ -87,7 +91,6 @@
        gpio2: gpio@ffc42000 {
                compatible = "renesas,gpio-r8a7778", "renesas,gpio-rcar";
                reg = <0xffc42000 0x2c>;
-               interrupt-parent = <&gic>;
                interrupts = <0 103 IRQ_TYPE_LEVEL_HIGH>;
                #gpio-cells = <2>;
                gpio-controller;
        gpio3: gpio@ffc43000 {
                compatible = "renesas,gpio-r8a7778", "renesas,gpio-rcar";
                reg = <0xffc43000 0x2c>;
-               interrupt-parent = <&gic>;
                interrupts = <0 103 IRQ_TYPE_LEVEL_HIGH>;
                #gpio-cells = <2>;
                gpio-controller;
        gpio4: gpio@ffc44000 {
                compatible = "renesas,gpio-r8a7778", "renesas,gpio-rcar";
                reg = <0xffc44000 0x2c>;
-               interrupt-parent = <&gic>;
                interrupts = <0 103 IRQ_TYPE_LEVEL_HIGH>;
                #gpio-cells = <2>;
                gpio-controller;
                #size-cells = <0>;
                compatible = "renesas,i2c-r8a7778";
                reg = <0xffc70000 0x1000>;
-               interrupt-parent = <&gic>;
                interrupts = <0 67 IRQ_TYPE_LEVEL_HIGH>;
                status = "disabled";
        };
                #size-cells = <0>;
                compatible = "renesas,i2c-r8a7778";
                reg = <0xffc71000 0x1000>;
-               interrupt-parent = <&gic>;
                interrupts = <0 78 IRQ_TYPE_LEVEL_HIGH>;
                status = "disabled";
        };
                #size-cells = <0>;
                compatible = "renesas,i2c-r8a7778";
                reg = <0xffc72000 0x1000>;
-               interrupt-parent = <&gic>;
                interrupts = <0 76 IRQ_TYPE_LEVEL_HIGH>;
                status = "disabled";
        };
                #size-cells = <0>;
                compatible = "renesas,i2c-r8a7778";
                reg = <0xffc73000 0x1000>;
-               interrupt-parent = <&gic>;
                interrupts = <0 77 IRQ_TYPE_LEVEL_HIGH>;
                status = "disabled";
        };
 
+       scif0: serial@ffe40000 {
+               compatible = "renesas,scif-r8a7778", "renesas,scif";
+               reg = <0xffe40000 0x100>;
+               interrupts = <0 70 IRQ_TYPE_LEVEL_HIGH>;
+               status = "disabled";
+       };
+
+       scif1: serial@ffe41000 {
+               compatible = "renesas,scif-r8a7778", "renesas,scif";
+               reg = <0xffe41000 0x100>;
+               interrupts = <0 71 IRQ_TYPE_LEVEL_HIGH>;
+               status = "disabled";
+       };
+
+       scif2: serial@ffe42000 {
+               compatible = "renesas,scif-r8a7778", "renesas,scif";
+               reg = <0xffe42000 0x100>;
+               interrupts = <0 72 IRQ_TYPE_LEVEL_HIGH>;
+               status = "disabled";
+       };
+
+       scif3: serial@ffe43000 {
+               compatible = "renesas,scif-r8a7778", "renesas,scif";
+               reg = <0xffe43000 0x100>;
+               interrupts = <0 73 IRQ_TYPE_LEVEL_HIGH>;
+               status = "disabled";
+       };
+
+       scif4: serial@ffe44000 {
+               compatible = "renesas,scif-r8a7778", "renesas,scif";
+               reg = <0xffe44000 0x100>;
+               interrupts = <0 74 IRQ_TYPE_LEVEL_HIGH>;
+               status = "disabled";
+       };
+
+       scif5: serial@ffe45000 {
+               compatible = "renesas,scif-r8a7778", "renesas,scif";
+               reg = <0xffe45000 0x100>;
+               interrupts = <0 75 IRQ_TYPE_LEVEL_HIGH>;
+               status = "disabled";
+       };
+
        mmcif: mmc@ffe4e000 {
                compatible = "renesas,sh-mmcif";
                reg = <0xffe4e000 0x100>;
-               interrupt-parent = <&gic>;
                interrupts = <0 61 IRQ_TYPE_LEVEL_HIGH>;
                status = "disabled";
        };
        sdhi0: sd@ffe4c000 {
                compatible = "renesas,sdhi-r8a7778";
                reg = <0xffe4c000 0x100>;
-               interrupt-parent = <&gic>;
                interrupts = <0 87 IRQ_TYPE_LEVEL_HIGH>;
                cap-sd-highspeed;
                cap-sdio-irq;
        sdhi1: sd@ffe4d000 {
                compatible = "renesas,sdhi-r8a7778";
                reg = <0xffe4d000 0x100>;
-               interrupt-parent = <&gic>;
                interrupts = <0 88 IRQ_TYPE_LEVEL_HIGH>;
                cap-sd-highspeed;
                cap-sdio-irq;
        sdhi2: sd@ffe4f000 {
                compatible = "renesas,sdhi-r8a7778";
                reg = <0xffe4f000 0x100>;
-               interrupt-parent = <&gic>;
                interrupts = <0 86 IRQ_TYPE_LEVEL_HIGH>;
                cap-sd-highspeed;
                cap-sdio-irq;
                status = "disabled";
        };
 
-       i2c0: i2c@ffc70000 {
-               #address-cells = <1>;
-               #size-cells = <0>;
-               compatible = "renesas,i2c-r8a7778";
-               reg = <0xffc70000 0x1000>;
-               interrupt-parent = <&gic>;
-               interrupts = <0 67 IRQ_TYPE_LEVEL_HIGH>;
-               status = "disabled";
-       };
-
-       i2c1: i2c@ffc71000 {
-               #address-cells = <1>;
-               #size-cells = <0>;
-               compatible = "renesas,i2c-r8a7778";
-               reg = <0xffc71000 0x1000>;
-               interrupt-parent = <&gic>;
-               interrupts = <0 78 IRQ_TYPE_LEVEL_HIGH>;
-               status = "disabled";
-       };
-
-       i2c2: i2c@ffc72000 {
-               #address-cells = <1>;
-               #size-cells = <0>;
-               compatible = "renesas,i2c-r8a7778";
-               reg = <0xffc72000 0x1000>;
-               interrupt-parent = <&gic>;
-               interrupts = <0 76 IRQ_TYPE_LEVEL_HIGH>;
-               status = "disabled";
-       };
-
-       i2c3: i2c@ffc73000 {
-               #address-cells = <1>;
-               #size-cells = <0>;
-               compatible = "renesas,i2c-r8a7778";
-               reg = <0xffc73000 0x1000>;
-               interrupt-parent = <&gic>;
-               interrupts = <0 77 IRQ_TYPE_LEVEL_HIGH>;
-               status = "disabled";
-       };
-
        hspi0: spi@fffc7000 {
-               compatible = "renesas,hspi";
+               compatible = "renesas,hspi-r8a7778", "renesas,hspi";
                reg = <0xfffc7000 0x18>;
-               interrupt-controller = <&gic>;
                interrupts = <0 63 IRQ_TYPE_LEVEL_HIGH>;
+               #address-cells = <1>;
+               #size-cells = <0>;
                status = "disabled";
        };
 
        hspi1: spi@fffc8000 {
-               compatible = "renesas,hspi";
+               compatible = "renesas,hspi-r8a7778", "renesas,hspi";
                reg = <0xfffc8000 0x18>;
-               interrupt-controller = <&gic>;
                interrupts = <0 84 IRQ_TYPE_LEVEL_HIGH>;
+               #address-cells = <1>;
+               #size-cells = <0>;
                status = "disabled";
        };
 
        hspi2: spi@fffc6000 {
-               compatible = "renesas,hspi";
+               compatible = "renesas,hspi-r8a7778", "renesas,hspi";
                reg = <0xfffc6000 0x18>;
-               interrupt-controller = <&gic>;
                interrupts = <0 85 IRQ_TYPE_LEVEL_HIGH>;
+               #address-cells = <1>;
+               #size-cells = <0>;
                status = "disabled";
        };
 };
diff --git a/arch/arm/boot/dts/r8a7779-marzen-reference.dts b/arch/arm/boot/dts/r8a7779-marzen-reference.dts
deleted file mode 100644 (file)
index 76f5eef..0000000
+++ /dev/null
@@ -1,120 +0,0 @@
-/*
- * Reference Device Tree Source for the Marzen board
- *
- * Copyright (C) 2013 Renesas Solutions Corp.
- * Copyright (C) 2013 Simon Horman
- *
- * 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.
- */
-
-/dts-v1/;
-#include "r8a7779.dtsi"
-#include <dt-bindings/gpio/gpio.h>
-#include <dt-bindings/interrupt-controller/irq.h>
-
-/ {
-       model = "marzen";
-       compatible = "renesas,marzen-reference", "renesas,r8a7779";
-
-       chosen {
-               bootargs = "console=ttySC2,115200 earlyprintk=sh-sci.2,115200 ignore_loglevel root=/dev/nfs ip=on rw";
-       };
-
-       memory {
-               device_type = "memory";
-               reg = <0x60000000 0x40000000>;
-       };
-
-       fixedregulator3v3: fixedregulator@0 {
-               compatible = "regulator-fixed";
-               regulator-name = "fixed-3.3V";
-               regulator-min-microvolt = <3300000>;
-               regulator-max-microvolt = <3300000>;
-               regulator-boot-on;
-               regulator-always-on;
-       };
-
-       lan0@18000000 {
-               compatible = "smsc,lan9220", "smsc,lan9115";
-               reg = <0x18000000 0x100>;
-               pinctrl-0 = <&lan0_pins>;
-               pinctrl-names = "default";
-
-               phy-mode = "mii";
-               interrupt-parent = <&irqpin0>;
-               interrupts = <1 IRQ_TYPE_EDGE_FALLING>;
-               reg-io-width = <4>;
-               vddvario-supply = <&fixedregulator3v3>;
-               vdd33a-supply = <&fixedregulator3v3>;
-       };
-
-       leds {
-               compatible = "gpio-leds";
-               led2 {
-                       gpios = <&gpio4 29 GPIO_ACTIVE_HIGH>;
-               };
-               led3 {
-                       gpios = <&gpio4 30 GPIO_ACTIVE_HIGH>;
-               };
-               led4 {
-                       gpios = <&gpio4 31 GPIO_ACTIVE_HIGH>;
-               };
-       };
-};
-
-&irqpin0 {
-       status = "okay";
-};
-
-&pfc {
-       pinctrl-0 = <&scif2_pins &scif4_pins>;
-       pinctrl-names = "default";
-
-       lan0_pins: lan0 {
-               intc {
-                       renesas,groups = "intc_irq1_b";
-                       renesas,function = "intc";
-               };
-               lbsc {
-                       renesas,groups = "lbsc_ex_cs0";
-                       renesas,function = "lbsc";
-               };
-       };
-
-       scif2_pins: serial2 {
-               renesas,groups = "scif2_data_c";
-               renesas,function = "scif2";
-       };
-
-       scif4_pins: serial4 {
-               renesas,groups = "scif4_data";
-               renesas,function = "scif4";
-       };
-
-       sdhi0_pins: sd0 {
-               renesas,groups = "sdhi0_data4", "sdhi0_ctrl", "sdhi0_cd";
-               renesas,function = "sdhi0";
-       };
-
-       hspi0_pins: hspi0 {
-               renesas,groups = "hspi0";
-               renesas,function = "hspi0";
-       };
-};
-
-&sdhi0 {
-       pinctrl-0 = <&sdhi0_pins>;
-       pinctrl-names = "default";
-
-       vmmc-supply = <&fixedregulator3v3>;
-       bus-width = <4>;
-       status = "okay";
-};
-
-&hspi0 {
-       pinctrl-0 = <&hspi0_pins>;
-       pinctrl-names = "default";
-       status = "okay";
-};
index a7af2c2..c160404 100644 (file)
 
 /dts-v1/;
 #include "r8a7779.dtsi"
+#include <dt-bindings/gpio/gpio.h>
+#include <dt-bindings/interrupt-controller/irq.h>
 
 / {
        model = "marzen";
        compatible = "renesas,marzen", "renesas,r8a7779";
 
+       aliases {
+               serial2 = &scif2;
+               serial4 = &scif4;
+       };
+
        chosen {
-               bootargs = "console=ttySC2,115200 earlyprintk=sh-sci.2,115200 ignore_loglevel root=/dev/nfs ip=on";
+               bootargs = "console=ttySC2,115200 ignore_loglevel root=/dev/nfs ip=on";
        };
 
        memory {
                device_type = "memory";
                reg = <0x60000000 0x40000000>;
        };
+
+       fixedregulator3v3: fixedregulator@0 {
+               compatible = "regulator-fixed";
+               regulator-name = "fixed-3.3V";
+               regulator-min-microvolt = <3300000>;
+               regulator-max-microvolt = <3300000>;
+               regulator-boot-on;
+               regulator-always-on;
+       };
+
+       lan0@18000000 {
+               compatible = "smsc,lan9220", "smsc,lan9115";
+               reg = <0x18000000 0x100>;
+               pinctrl-0 = <&lan0_pins>;
+               pinctrl-names = "default";
+
+               phy-mode = "mii";
+               interrupt-parent = <&irqpin0>;
+               interrupts = <1 IRQ_TYPE_EDGE_FALLING>;
+               smsc,irq-push-pull;
+               reg-io-width = <4>;
+               vddvario-supply = <&fixedregulator3v3>;
+               vdd33a-supply = <&fixedregulator3v3>;
+       };
+
+       leds {
+               compatible = "gpio-leds";
+               led2 {
+                       gpios = <&gpio4 29 GPIO_ACTIVE_HIGH>;
+               };
+               led3 {
+                       gpios = <&gpio4 30 GPIO_ACTIVE_HIGH>;
+               };
+               led4 {
+                       gpios = <&gpio4 31 GPIO_ACTIVE_HIGH>;
+               };
+       };
+};
+
+&irqpin0 {
+       status = "okay";
+};
+
+&extal_clk {
+       clock-frequency = <31250000>;
+};
+
+&tmu0 {
+       status = "okay";
+};
+
+&pfc {
+       lan0_pins: lan0 {
+               intc {
+                       renesas,groups = "intc_irq1_b";
+                       renesas,function = "intc";
+               };
+               lbsc {
+                       renesas,groups = "lbsc_ex_cs0";
+                       renesas,function = "lbsc";
+               };
+       };
+
+       scif2_pins: serial2 {
+               renesas,groups = "scif2_data_c";
+               renesas,function = "scif2";
+       };
+
+       scif4_pins: serial4 {
+               renesas,groups = "scif4_data";
+               renesas,function = "scif4";
+       };
+
+       sdhi0_pins: sd0 {
+               renesas,groups = "sdhi0_data4", "sdhi0_ctrl", "sdhi0_cd";
+               renesas,function = "sdhi0";
+       };
+
+       hspi0_pins: hspi0 {
+               renesas,groups = "hspi0";
+               renesas,function = "hspi0";
+       };
+};
+
+&scif2 {
+       pinctrl-0 = <&scif2_pins>;
+       pinctrl-names = "default";
+
+       status = "okay";
+};
+
+&scif4 {
+       pinctrl-0 = <&scif4_pins>;
+       pinctrl-names = "default";
+
+       status = "okay";
+};
+
+&sdhi0 {
+       pinctrl-0 = <&sdhi0_pins>;
+       pinctrl-names = "default";
+
+       vmmc-supply = <&fixedregulator3v3>;
+       bus-width = <4>;
+       status = "okay";
+};
+
+&hspi0 {
+       pinctrl-0 = <&hspi0_pins>;
+       pinctrl-names = "default";
+       status = "okay";
 };
index d0561d4..7cfba9a 100644 (file)
 
 /include/ "skeleton.dtsi"
 
+#include <dt-bindings/clock/r8a7779-clock.h>
 #include <dt-bindings/interrupt-controller/irq.h>
 
 / {
        compatible = "renesas,r8a7779";
+       interrupt-parent = <&gic>;
 
        cpus {
                #address-cells = <1>;
                        device_type = "cpu";
                        compatible = "arm,cortex-a9";
                        reg = <0>;
+                       clock-frequency = <1000000000>;
                };
                cpu@1 {
                        device_type = "cpu";
                        compatible = "arm,cortex-a9";
                        reg = <1>;
+                       clock-frequency = <1000000000>;
                };
                cpu@2 {
                        device_type = "cpu";
                        compatible = "arm,cortex-a9";
                        reg = <2>;
+                       clock-frequency = <1000000000>;
                };
                cpu@3 {
                        device_type = "cpu";
                        compatible = "arm,cortex-a9";
                        reg = <3>;
+                       clock-frequency = <1000000000>;
                };
        };
 
                spi2 = &hspi2;
        };
 
-        gic: interrupt-controller@f0001000 {
-                compatible = "arm,cortex-a9-gic";
-                #interrupt-cells = <3>;
-                interrupt-controller;
-                reg = <0xf0001000 0x1000>,
-                      <0xf0000100 0x100>;
-        };
+       gic: interrupt-controller@f0001000 {
+               compatible = "arm,cortex-a9-gic";
+               #interrupt-cells = <3>;
+               interrupt-controller;
+               reg = <0xf0001000 0x1000>,
+                     <0xf0000100 0x100>;
+       };
 
        gpio0: gpio@ffc40000 {
                compatible = "renesas,gpio-r8a7779", "renesas,gpio-rcar";
                reg = <0xffc40000 0x2c>;
-               interrupt-parent = <&gic>;
                interrupts = <0 141 IRQ_TYPE_LEVEL_HIGH>;
                #gpio-cells = <2>;
                gpio-controller;
@@ -71,7 +76,6 @@
        gpio1: gpio@ffc41000 {
                compatible = "renesas,gpio-r8a7779", "renesas,gpio-rcar";
                reg = <0xffc41000 0x2c>;
-               interrupt-parent = <&gic>;
                interrupts = <0 142 IRQ_TYPE_LEVEL_HIGH>;
                #gpio-cells = <2>;
                gpio-controller;
@@ -83,7 +87,6 @@
        gpio2: gpio@ffc42000 {
                compatible = "renesas,gpio-r8a7779", "renesas,gpio-rcar";
                reg = <0xffc42000 0x2c>;
-               interrupt-parent = <&gic>;
                interrupts = <0 143 IRQ_TYPE_LEVEL_HIGH>;
                #gpio-cells = <2>;
                gpio-controller;
@@ -95,7 +98,6 @@
        gpio3: gpio@ffc43000 {
                compatible = "renesas,gpio-r8a7779", "renesas,gpio-rcar";
                reg = <0xffc43000 0x2c>;
-               interrupt-parent = <&gic>;
                interrupts = <0 144 IRQ_TYPE_LEVEL_HIGH>;
                #gpio-cells = <2>;
                gpio-controller;
        gpio4: gpio@ffc44000 {
                compatible = "renesas,gpio-r8a7779", "renesas,gpio-rcar";
                reg = <0xffc44000 0x2c>;
-               interrupt-parent = <&gic>;
                interrupts = <0 145 IRQ_TYPE_LEVEL_HIGH>;
                #gpio-cells = <2>;
                gpio-controller;
        gpio5: gpio@ffc45000 {
                compatible = "renesas,gpio-r8a7779", "renesas,gpio-rcar";
                reg = <0xffc45000 0x2c>;
-               interrupt-parent = <&gic>;
                interrupts = <0 146 IRQ_TYPE_LEVEL_HIGH>;
                #gpio-cells = <2>;
                gpio-controller;
        gpio6: gpio@ffc46000 {
                compatible = "renesas,gpio-r8a7779", "renesas,gpio-rcar";
                reg = <0xffc46000 0x2c>;
-               interrupt-parent = <&gic>;
                interrupts = <0 147 IRQ_TYPE_LEVEL_HIGH>;
                #gpio-cells = <2>;
                gpio-controller;
                        <0xfe780024 4>,
                        <0xfe780044 4>,
                        <0xfe780064 4>;
-               interrupt-parent = <&gic>;
                interrupts = <0 27 IRQ_TYPE_LEVEL_HIGH
                              0 28 IRQ_TYPE_LEVEL_HIGH
                              0 29 IRQ_TYPE_LEVEL_HIGH
                #size-cells = <0>;
                compatible = "renesas,i2c-r8a7779";
                reg = <0xffc70000 0x1000>;
-               interrupt-parent = <&gic>;
                interrupts = <0 79 IRQ_TYPE_LEVEL_HIGH>;
+               clocks = <&mstp0_clks R8A7779_CLK_I2C0>;
                status = "disabled";
        };
 
                #size-cells = <0>;
                compatible = "renesas,i2c-r8a7779";
                reg = <0xffc71000 0x1000>;
-               interrupt-parent = <&gic>;
                interrupts = <0 82 IRQ_TYPE_LEVEL_HIGH>;
+               clocks = <&mstp0_clks R8A7779_CLK_I2C1>;
                status = "disabled";
        };
 
                #size-cells = <0>;
                compatible = "renesas,i2c-r8a7779";
                reg = <0xffc72000 0x1000>;
-               interrupt-parent = <&gic>;
                interrupts = <0 80 IRQ_TYPE_LEVEL_HIGH>;
+               clocks = <&mstp0_clks R8A7779_CLK_I2C2>;
                status = "disabled";
        };
 
                #size-cells = <0>;
                compatible = "renesas,i2c-r8a7779";
                reg = <0xffc73000 0x1000>;
-               interrupt-parent = <&gic>;
                interrupts = <0 81 IRQ_TYPE_LEVEL_HIGH>;
+               clocks = <&mstp0_clks R8A7779_CLK_I2C3>;
+               status = "disabled";
+       };
+
+       scif0: serial@ffe40000 {
+               compatible = "renesas,scif-r8a7779", "renesas,scif";
+               reg = <0xffe40000 0x100>;
+               interrupts = <0 88 IRQ_TYPE_LEVEL_HIGH>;
+               clocks = <&cpg_clocks R8A7779_CLK_P>;
+               clock-names = "sci_ick";
+               status = "disabled";
+       };
+
+       scif1: serial@ffe41000 {
+               compatible = "renesas,scif-r8a7779", "renesas,scif";
+               reg = <0xffe41000 0x100>;
+               interrupts = <0 89 IRQ_TYPE_LEVEL_HIGH>;
+               clocks = <&cpg_clocks R8A7779_CLK_P>;
+               clock-names = "sci_ick";
+               status = "disabled";
+       };
+
+       scif2: serial@ffe42000 {
+               compatible = "renesas,scif-r8a7779", "renesas,scif";
+               reg = <0xffe42000 0x100>;
+               interrupts = <0 90 IRQ_TYPE_LEVEL_HIGH>;
+               clocks = <&cpg_clocks R8A7779_CLK_P>;
+               clock-names = "sci_ick";
+               status = "disabled";
+       };
+
+       scif3: serial@ffe43000 {
+               compatible = "renesas,scif-r8a7779", "renesas,scif";
+               reg = <0xffe43000 0x100>;
+               interrupts = <0 91 IRQ_TYPE_LEVEL_HIGH>;
+               clocks = <&cpg_clocks R8A7779_CLK_P>;
+               clock-names = "sci_ick";
+               status = "disabled";
+       };
+
+       scif4: serial@ffe44000 {
+               compatible = "renesas,scif-r8a7779", "renesas,scif";
+               reg = <0xffe44000 0x100>;
+               interrupts = <0 92 IRQ_TYPE_LEVEL_HIGH>;
+               clocks = <&cpg_clocks R8A7779_CLK_P>;
+               clock-names = "sci_ick";
+               status = "disabled";
+       };
+
+       scif5: serial@ffe45000 {
+               compatible = "renesas,scif-r8a7779", "renesas,scif";
+               reg = <0xffe45000 0x100>;
+               interrupts = <0 93 IRQ_TYPE_LEVEL_HIGH>;
+               clocks = <&cpg_clocks R8A7779_CLK_P>;
+               clock-names = "sci_ick";
                status = "disabled";
        };
 
        };
 
        thermal@ffc48000 {
-               compatible = "renesas,rcar-thermal";
+               compatible = "renesas,thermal-r8a7779", "renesas,rcar-thermal";
                reg = <0xffc48000 0x38>;
        };
 
+       tmu0: timer@ffd80000 {
+               compatible = "renesas,tmu-r8a7779", "renesas,tmu";
+               reg = <0xffd80000 0x30>;
+               interrupts = <0 32 IRQ_TYPE_LEVEL_HIGH>,
+                            <0 33 IRQ_TYPE_LEVEL_HIGH>,
+                            <0 34 IRQ_TYPE_LEVEL_HIGH>;
+               clocks = <&mstp0_clks R8A7779_CLK_TMU0>;
+               clock-names = "fck";
+
+               #renesas,channels = <3>;
+
+               status = "disabled";
+       };
+
+       tmu1: timer@ffd81000 {
+               compatible = "renesas,tmu-r8a7779", "renesas,tmu";
+               reg = <0xffd81000 0x30>;
+               interrupts = <0 36 IRQ_TYPE_LEVEL_HIGH>,
+                            <0 37 IRQ_TYPE_LEVEL_HIGH>,
+                            <0 38 IRQ_TYPE_LEVEL_HIGH>;
+               clocks = <&mstp0_clks R8A7779_CLK_TMU1>;
+               clock-names = "fck";
+
+               #renesas,channels = <3>;
+
+               status = "disabled";
+       };
+
+       tmu2: timer@ffd82000 {
+               compatible = "renesas,tmu-r8a7779", "renesas,tmu";
+               reg = <0xffd82000 0x30>;
+               interrupts = <0 40 IRQ_TYPE_LEVEL_HIGH>,
+                            <0 41 IRQ_TYPE_LEVEL_HIGH>,
+                            <0 42 IRQ_TYPE_LEVEL_HIGH>;
+               clocks = <&mstp0_clks R8A7779_CLK_TMU2>;
+               clock-names = "fck";
+
+               #renesas,channels = <3>;
+
+               status = "disabled";
+       };
+
        sata: sata@fc600000 {
                compatible = "renesas,rcar-sata";
                reg = <0xfc600000 0x2000>;
-               interrupt-parent = <&gic>;
                interrupts = <0 100 IRQ_TYPE_LEVEL_HIGH>;
+               clocks = <&mstp1_clks R8A7779_CLK_SATA>;
        };
 
        sdhi0: sd@ffe4c000 {
                compatible = "renesas,sdhi-r8a7779";
                reg = <0xffe4c000 0x100>;
-               interrupt-parent = <&gic>;
                interrupts = <0 104 IRQ_TYPE_LEVEL_HIGH>;
+               clocks = <&mstp3_clks R8A7779_CLK_SDHI0>;
                cap-sd-highspeed;
                cap-sdio-irq;
                status = "disabled";
        sdhi1: sd@ffe4d000 {
                compatible = "renesas,sdhi-r8a7779";
                reg = <0xffe4d000 0x100>;
-               interrupt-parent = <&gic>;
                interrupts = <0 105 IRQ_TYPE_LEVEL_HIGH>;
+               clocks = <&mstp3_clks R8A7779_CLK_SDHI1>;
                cap-sd-highspeed;
                cap-sdio-irq;
                status = "disabled";
        sdhi2: sd@ffe4e000 {
                compatible = "renesas,sdhi-r8a7779";
                reg = <0xffe4e000 0x100>;
-               interrupt-parent = <&gic>;
                interrupts = <0 107 IRQ_TYPE_LEVEL_HIGH>;
+               clocks = <&mstp3_clks R8A7779_CLK_SDHI2>;
                cap-sd-highspeed;
                cap-sdio-irq;
                status = "disabled";
        sdhi3: sd@ffe4f000 {
                compatible = "renesas,sdhi-r8a7779";
                reg = <0xffe4f000 0x100>;
-               interrupt-parent = <&gic>;
                interrupts = <0 106 IRQ_TYPE_LEVEL_HIGH>;
+               clocks = <&mstp3_clks R8A7779_CLK_SDHI3>;
                cap-sd-highspeed;
                cap-sdio-irq;
                status = "disabled";
        };
 
        hspi0: spi@fffc7000 {
-               compatible = "renesas,hspi";
+               compatible = "renesas,hspi-r8a7779", "renesas,hspi";
                reg = <0xfffc7000 0x18>;
-               interrupt-controller = <&gic>;
                interrupts = <0 73 IRQ_TYPE_LEVEL_HIGH>;
+               #address-cells = <1>;
+               #size-cells = <0>;
+               clocks = <&mstp0_clks R8A7779_CLK_HSPI>;
                status = "disabled";
        };
 
        hspi1: spi@fffc8000 {
-               compatible = "renesas,hspi";
+               compatible = "renesas,hspi-r8a7779", "renesas,hspi";
                reg = <0xfffc8000 0x18>;
-               interrupt-controller = <&gic>;
                interrupts = <0 74 IRQ_TYPE_LEVEL_HIGH>;
+               #address-cells = <1>;
+               #size-cells = <0>;
+               clocks = <&mstp0_clks R8A7779_CLK_HSPI>;
                status = "disabled";
        };
 
        hspi2: spi@fffc6000 {
-               compatible = "renesas,hspi";
+               compatible = "renesas,hspi-r8a7779", "renesas,hspi";
                reg = <0xfffc6000 0x18>;
-               interrupt-controller = <&gic>;
                interrupts = <0 75 IRQ_TYPE_LEVEL_HIGH>;
+               #address-cells = <1>;
+               #size-cells = <0>;
+               clocks = <&mstp0_clks R8A7779_CLK_HSPI>;
                status = "disabled";
        };
+
+       clocks {
+               #address-cells = <1>;
+               #size-cells = <1>;
+               ranges;
+
+               /* External root clock */
+               extal_clk: extal_clk {
+                       compatible = "fixed-clock";
+                       #clock-cells = <0>;
+                       /* This value must be overriden by the board. */
+                       clock-frequency = <0>;
+                       clock-output-names = "extal";
+               };
+
+               /* Special CPG clocks */
+               cpg_clocks: clocks@ffc80000 {
+                       compatible = "renesas,r8a7779-cpg-clocks";
+                       reg = <0xffc80000 0x30>;
+                       clocks = <&extal_clk>;
+                       #clock-cells = <1>;
+                       clock-output-names = "plla", "z", "zs", "s",
+                                            "s1", "p", "b", "out";
+               };
+
+               /* Fixed factor clocks */
+               i_clk: i_clk {
+                       compatible = "fixed-factor-clock";
+                       clocks = <&cpg_clocks R8A7779_CLK_PLLA>;
+                       #clock-cells = <0>;
+                       clock-div = <2>;
+                       clock-mult = <1>;
+                       clock-output-names = "i";
+               };
+               s3_clk: s3_clk {
+                       compatible = "fixed-factor-clock";
+                       clocks = <&cpg_clocks R8A7779_CLK_PLLA>;
+                       #clock-cells = <0>;
+                       clock-div = <8>;
+                       clock-mult = <1>;
+                       clock-output-names = "s3";
+               };
+               s4_clk: s4_clk {
+                       compatible = "fixed-factor-clock";
+                       clocks = <&cpg_clocks R8A7779_CLK_PLLA>;
+                       #clock-cells = <0>;
+                       clock-div = <16>;
+                       clock-mult = <1>;
+                       clock-output-names = "s4";
+               };
+               g_clk: g_clk {
+                       compatible = "fixed-factor-clock";
+                       clocks = <&cpg_clocks R8A7779_CLK_PLLA>;
+                       #clock-cells = <0>;
+                       clock-div = <24>;
+                       clock-mult = <1>;
+                       clock-output-names = "g";
+               };
+
+               /* Gate clocks */
+               mstp0_clks: clocks@ffc80030 {
+                       compatible = "renesas,r8a7779-mstp-clocks",
+                                    "renesas,cpg-mstp-clocks";
+                       reg = <0xffc80030 4>;
+                       clocks = <&cpg_clocks R8A7779_CLK_S>,
+                                <&cpg_clocks R8A7779_CLK_P>,
+                                <&cpg_clocks R8A7779_CLK_P>,
+                                <&cpg_clocks R8A7779_CLK_P>,
+                                <&cpg_clocks R8A7779_CLK_S>,
+                                <&cpg_clocks R8A7779_CLK_S>,
+                                <&cpg_clocks R8A7779_CLK_S1>,
+                                <&cpg_clocks R8A7779_CLK_S1>,
+                                <&cpg_clocks R8A7779_CLK_S1>,
+                                <&cpg_clocks R8A7779_CLK_S1>,
+                                <&cpg_clocks R8A7779_CLK_S1>,
+                                <&cpg_clocks R8A7779_CLK_S1>,
+                                <&cpg_clocks R8A7779_CLK_P>,
+                                <&cpg_clocks R8A7779_CLK_P>,
+                                <&cpg_clocks R8A7779_CLK_P>,
+                                <&cpg_clocks R8A7779_CLK_P>;
+                       #clock-cells = <1>;
+                       renesas,clock-indices = <
+                               R8A7779_CLK_HSPI R8A7779_CLK_TMU2
+                               R8A7779_CLK_TMU1 R8A7779_CLK_TMU0
+                               R8A7779_CLK_HSCIF1 R8A7779_CLK_HSCIF0
+                               R8A7779_CLK_SCIF5 R8A7779_CLK_SCIF4
+                               R8A7779_CLK_SCIF3 R8A7779_CLK_SCIF2
+                               R8A7779_CLK_SCIF1 R8A7779_CLK_SCIF0
+                               R8A7779_CLK_I2C3 R8A7779_CLK_I2C2
+                               R8A7779_CLK_I2C1 R8A7779_CLK_I2C0
+                       >;
+                       clock-output-names =
+                               "hspi", "tmu2", "tmu1", "tmu0", "hscif1",
+                               "hscif0", "scif5", "scif4", "scif3", "scif2",
+                               "scif1", "scif0", "i2c3", "i2c2", "i2c1",
+                               "i2c0";
+               };
+               mstp1_clks: clocks@ffc80034 {
+                       compatible = "renesas,r8a7779-mstp-clocks",
+                                    "renesas,cpg-mstp-clocks";
+                       reg = <0xffc80034 4>, <0xffc80044 4>;
+                       clocks = <&cpg_clocks R8A7779_CLK_P>,
+                                <&cpg_clocks R8A7779_CLK_P>,
+                                <&cpg_clocks R8A7779_CLK_S>,
+                                <&cpg_clocks R8A7779_CLK_S>,
+                                <&cpg_clocks R8A7779_CLK_S>,
+                                <&cpg_clocks R8A7779_CLK_S>,
+                                <&cpg_clocks R8A7779_CLK_P>,
+                                <&cpg_clocks R8A7779_CLK_P>,
+                                <&cpg_clocks R8A7779_CLK_P>,
+                                <&cpg_clocks R8A7779_CLK_S>;
+                       #clock-cells = <1>;
+                       renesas,clock-indices = <
+                               R8A7779_CLK_USB01 R8A7779_CLK_USB2
+                               R8A7779_CLK_DU R8A7779_CLK_VIN2
+                               R8A7779_CLK_VIN1 R8A7779_CLK_VIN0
+                               R8A7779_CLK_ETHER R8A7779_CLK_SATA
+                               R8A7779_CLK_PCIE R8A7779_CLK_VIN3
+                       >;
+                       clock-output-names =
+                               "usb01", "usb2",
+                               "du", "vin2",
+                               "vin1", "vin0",
+                               "ether", "sata",
+                               "pcie", "vin3";
+               };
+               mstp3_clks: clocks@ffc8003c {
+                       compatible = "renesas,r8a7779-mstp-clocks",
+                                    "renesas,cpg-mstp-clocks";
+                       reg = <0xffc8003c 4>;
+                       clocks = <&s4_clk>, <&s4_clk>, <&s4_clk>, <&s4_clk>,
+                                <&s4_clk>, <&s4_clk>;
+                       #clock-cells = <1>;
+                       renesas,clock-indices = <
+                               R8A7779_CLK_SDHI3 R8A7779_CLK_SDHI2
+                               R8A7779_CLK_SDHI1 R8A7779_CLK_SDHI0
+                               R8A7779_CLK_MMC1 R8A7779_CLK_MMC0
+                       >;
+                       clock-output-names =
+                               "sdhi3", "sdhi2", "sdhi1", "sdhi0",
+                               "mmc1", "mmc0";
+               };
+       };
 };
index 57569cb..a2473b9 100644 (file)
@@ -1,7 +1,8 @@
 /*
  * Device Tree Source for the Lager board
  *
- * Copyright (C) 2013 Renesas Solutions Corp.
+ * Copyright (C) 2013-2014 Renesas Solutions Corp.
+ * Copyright (C) 2014 Cogent Embedded, Inc.
  *
  * 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
 /dts-v1/;
 #include "r8a7790.dtsi"
 #include <dt-bindings/gpio/gpio.h>
+#include <dt-bindings/input/input.h>
 
 / {
        model = "Lager";
        compatible = "renesas,lager", "renesas,r8a7790";
 
+       aliases {
+               serial6 = &scif0;
+               serial7 = &scif1;
+       };
+
        chosen {
                bootargs = "console=ttySC6,115200 ignore_loglevel rw root=/dev/nfs ip=dhcp";
        };
 
        memory@40000000 {
                device_type = "memory";
-               reg = <0 0x40000000 0 0x80000000>;
+               reg = <0 0x40000000 0 0x40000000>;
        };
 
-       memory@180000000 {
+       memory@140000000 {
                device_type = "memory";
-               reg = <1 0x80000000 0 0x80000000>;
+               reg = <1 0x40000000 0 0xc0000000>;
        };
 
        lbsc {
                #size-cells = <1>;
        };
 
+       gpio_keys {
+               compatible = "gpio-keys";
+
+               button@1 {
+                       linux,code = <KEY_1>;
+                       label = "SW2-1";
+                       gpio-key,wakeup;
+                       debounce-interval = <20>;
+                       gpios = <&gpio1 14 GPIO_ACTIVE_LOW>;
+               };
+               button@2 {
+                       linux,code = <KEY_2>;
+                       label = "SW2-2";
+                       gpio-key,wakeup;
+                       debounce-interval = <20>;
+                       gpios = <&gpio1 24 GPIO_ACTIVE_LOW>;
+               };
+               button@3 {
+                       linux,code = <KEY_3>;
+                       label = "SW2-3";
+                       gpio-key,wakeup;
+                       debounce-interval = <20>;
+                       gpios = <&gpio1 26 GPIO_ACTIVE_LOW>;
+               };
+               button@4 {
+                       linux,code = <KEY_4>;
+                       label = "SW2-4";
+                       gpio-key,wakeup;
+                       debounce-interval = <20>;
+                       gpios = <&gpio1 28 GPIO_ACTIVE_LOW>;
+               };
+       };
+
        leds {
                compatible = "gpio-leds";
                led6 {
                regulator-boot-on;
                regulator-always-on;
        };
+
+       vcc_sdhi0: regulator@1 {
+               compatible = "regulator-fixed";
+
+               regulator-name = "SDHI0 Vcc";
+               regulator-min-microvolt = <3300000>;
+               regulator-max-microvolt = <3300000>;
+
+               gpio = <&gpio5 24 GPIO_ACTIVE_HIGH>;
+               enable-active-high;
+       };
+
+       vccq_sdhi0: regulator@2 {
+               compatible = "regulator-gpio";
+
+               regulator-name = "SDHI0 VccQ";
+               regulator-min-microvolt = <1800000>;
+               regulator-max-microvolt = <3300000>;
+
+               gpios = <&gpio5 29 GPIO_ACTIVE_HIGH>;
+               gpios-states = <1>;
+               states = <3300000 1
+                         1800000 0>;
+       };
+
+       vcc_sdhi2: regulator@3 {
+               compatible = "regulator-fixed";
+
+               regulator-name = "SDHI2 Vcc";
+               regulator-min-microvolt = <3300000>;
+               regulator-max-microvolt = <3300000>;
+
+               gpio = <&gpio5 25 GPIO_ACTIVE_HIGH>;
+               enable-active-high;
+       };
+
+       vccq_sdhi2: regulator@4 {
+               compatible = "regulator-gpio";
+
+               regulator-name = "SDHI2 VccQ";
+               regulator-min-microvolt = <1800000>;
+               regulator-max-microvolt = <3300000>;
+
+               gpios = <&gpio5 30 GPIO_ACTIVE_HIGH>;
+               gpios-states = <1>;
+               states = <3300000 1
+                         1800000 0>;
+       };
 };
 
 &extal_clk {
 };
 
 &pfc {
-       pinctrl-0 = <&scif0_pins &scif1_pins>;
+       pinctrl-0 = <&du_pins>;
        pinctrl-names = "default";
 
+       du_pins: du {
+               renesas,groups = "du_rgb666", "du_sync_1", "du_clk_out_0";
+               renesas,function = "du";
+       };
+
        scif0_pins: serial0 {
                renesas,groups = "scif0_data";
                renesas,function = "scif0";
        };
 
+       ether_pins: ether {
+               renesas,groups = "eth_link", "eth_mdio", "eth_rmii";
+               renesas,function = "eth";
+       };
+
+       phy1_pins: phy1 {
+               renesas,groups = "intc_irq0";
+               renesas,function = "intc";
+       };
+
        scif1_pins: serial1 {
                renesas,groups = "scif1_data";
                renesas,function = "scif1";
        };
 
+       sdhi0_pins: sd0 {
+               renesas,groups = "sdhi0_data4", "sdhi0_ctrl";
+               renesas,function = "sdhi0";
+       };
+
+       sdhi2_pins: sd2 {
+               renesas,groups = "sdhi2_data4", "sdhi2_ctrl";
+               renesas,function = "sdhi2";
+       };
+
        mmc1_pins: mmc1 {
                renesas,groups = "mmc1_data8", "mmc1_ctrl";
                renesas,function = "mmc1";
        };
+
+       qspi_pins: spi0 {
+               renesas,groups = "qspi_ctrl", "qspi_data4";
+               renesas,function = "qspi";
+       };
+
+       msiof1_pins: spi2 {
+               renesas,groups = "msiof1_clk", "msiof1_sync", "msiof1_rx",
+                                "msiof1_tx";
+               renesas,function = "msiof1";
+       };
+
+       iic1_pins: iic1 {
+               renesas,groups = "iic1";
+               renesas,function = "iic1";
+       };
+
+       iic2_pins: iic2 {
+               renesas,groups = "iic2";
+               renesas,function = "iic2";
+       };
+
+       iic3_pins: iic3 {
+               renesas,groups = "iic3";
+               renesas,function = "iic3";
+       };
+
+       usb0_pins: usb0 {
+               renesas,groups = "usb0";
+               renesas,function = "usb0";
+       };
+
+       usb1_pins: usb1 {
+               renesas,groups = "usb1";
+               renesas,function = "usb1";
+       };
+
+       usb2_pins: usb2 {
+               renesas,groups = "usb2";
+               renesas,function = "usb2";
+       };
+
+       vin1_pins: vin {
+               renesas,groups = "vin1_data8", "vin1_clk";
+               renesas,function = "vin1";
+       };
+};
+
+&ether {
+       pinctrl-0 = <&ether_pins &phy1_pins>;
+       pinctrl-names = "default";
+
+       phy-handle = <&phy1>;
+       renesas,ether-link-active-low;
+       status = "ok";
+
+       phy1: ethernet-phy@1 {
+               reg = <1>;
+               interrupt-parent = <&irqc0>;
+               interrupts = <0 IRQ_TYPE_LEVEL_LOW>;
+               micrel,led-mode = <1>;
+       };
+};
+
+&cmt0 {
+       status = "ok";
 };
 
 &mmcif1 {
        non-removable;
        status = "okay";
 };
+
+&sata1 {
+       status = "okay";
+};
+
+&qspi {
+       pinctrl-0 = <&qspi_pins>;
+       pinctrl-names = "default";
+
+       status = "okay";
+
+       flash: flash@0 {
+               #address-cells = <1>;
+               #size-cells = <1>;
+               compatible = "spansion,s25fl512s";
+               reg = <0>;
+               spi-max-frequency = <30000000>;
+               spi-tx-bus-width = <4>;
+               spi-rx-bus-width = <4>;
+               m25p,fast-read;
+
+               partition@0 {
+                       label = "loader";
+                       reg = <0x00000000 0x00040000>;
+                       read-only;
+               };
+               partition@40000 {
+                       label = "user";
+                       reg = <0x00040000 0x00400000>;
+                       read-only;
+               };
+               partition@440000 {
+                       label = "flash";
+                       reg = <0x00440000 0x03bc0000>;
+               };
+       };
+};
+
+&msiof1 {
+       pinctrl-0 = <&msiof1_pins>;
+       pinctrl-names = "default";
+
+       status = "okay";
+
+       pmic: pmic@0 {
+               compatible = "renesas,r2a11302ft";
+               reg = <0>;
+               spi-max-frequency = <6000000>;
+               spi-cpol;
+               spi-cpha;
+       };
+};
+
+&scif0 {
+       pinctrl-0 = <&scif0_pins>;
+       pinctrl-names = "default";
+
+       status = "okay";
+};
+
+&scif1 {
+       pinctrl-0 = <&scif1_pins>;
+       pinctrl-names = "default";
+
+       status = "okay";
+};
+
+&sdhi0 {
+       pinctrl-0 = <&sdhi0_pins>;
+       pinctrl-names = "default";
+
+       vmmc-supply = <&vcc_sdhi0>;
+       vqmmc-supply = <&vccq_sdhi0>;
+       cd-gpios = <&gpio3 6 GPIO_ACTIVE_LOW>;
+       status = "okay";
+};
+
+&sdhi2 {
+       pinctrl-0 = <&sdhi2_pins>;
+       pinctrl-names = "default";
+
+       vmmc-supply = <&vcc_sdhi2>;
+       vqmmc-supply = <&vccq_sdhi2>;
+       cd-gpios = <&gpio3 22 GPIO_ACTIVE_LOW>;
+       status = "okay";
+};
+
+&cpu0 {
+       cpu0-supply = <&vdd_dvfs>;
+};
+
+&iic0  {
+       status = "ok";
+};
+
+&iic1  {
+       status = "ok";
+       pinctrl-0 = <&iic1_pins>;
+       pinctrl-names = "default";
+};
+
+&iic2  {
+       status = "ok";
+       pinctrl-0 = <&iic2_pins>;
+       pinctrl-names = "default";
+
+       composite-in@20 {
+               compatible = "adi,adv7180";
+               reg = <0x20>;
+               remote = <&vin1>;
+
+               port {
+                       adv7180: endpoint {
+                               bus-width = <8>;
+                               remote-endpoint = <&vin1ep0>;
+                       };
+               };
+       };
+};
+
+&iic3 {
+       pinctrl-names = "default";
+       pinctrl-0 = <&iic3_pins>;
+       status = "okay";
+
+       vdd_dvfs: regulator@68 {
+               compatible = "dlg,da9210";
+               reg = <0x68>;
+
+               regulator-min-microvolt = <1000000>;
+               regulator-max-microvolt = <1000000>;
+               regulator-boot-on;
+               regulator-always-on;
+       };
+};
+
+&pci0 {
+       status = "okay";
+       pinctrl-0 = <&usb0_pins>;
+       pinctrl-names = "default";
+};
+
+&pci1 {
+       status = "okay";
+       pinctrl-0 = <&usb1_pins>;
+       pinctrl-names = "default";
+};
+
+&pci2 {
+       status = "okay";
+       pinctrl-0 = <&usb2_pins>;
+       pinctrl-names = "default";
+};
+
+/* composite video input */
+&vin1 {
+       pinctrl-0 = <&vin1_pins>;
+       pinctrl-names = "default";
+
+       status = "ok";
+
+       port {
+               #address-cells = <1>;
+               #size-cells = <0>;
+
+               vin1ep0: endpoint {
+                       remote-endpoint = <&adv7180>;
+                       bus-width = <8>;
+               };
+       };
+};
index 71b1251..d0e1773 100644 (file)
@@ -1,7 +1,8 @@
 /*
  * Device Tree Source for the r8a7790 SoC
  *
- * Copyright (C) 2013 Renesas Solutions Corp.
+ * Copyright (C) 2013-2014 Renesas Solutions Corp.
+ * Copyright (C) 2014 Cogent Embedded Inc.
  *
  * 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
        #address-cells = <2>;
        #size-cells = <2>;
 
+       aliases {
+               i2c0 = &i2c0;
+               i2c1 = &i2c1;
+               i2c2 = &i2c2;
+               i2c3 = &i2c3;
+               i2c4 = &iic0;
+               i2c5 = &iic1;
+               i2c6 = &iic2;
+               i2c7 = &iic3;
+               spi0 = &qspi;
+               spi1 = &msiof0;
+               spi2 = &msiof1;
+               spi3 = &msiof2;
+               spi4 = &msiof3;
+               vin0 = &vin0;
+               vin1 = &vin1;
+               vin2 = &vin2;
+               vin3 = &vin3;
+       };
+
        cpus {
                #address-cells = <1>;
                #size-cells = <0>;
                        compatible = "arm,cortex-a15";
                        reg = <0>;
                        clock-frequency = <1300000000>;
+                       voltage-tolerance = <1>; /* 1% */
+                       clocks = <&cpg_clocks R8A7790_CLK_Z>;
+                       clock-latency = <300000>; /* 300 us */
+
+                       /* kHz - uV - OPPs unknown yet */
+                       operating-points = <1400000 1000000>,
+                                          <1225000 1000000>,
+                                          <1050000 1000000>,
+                                          < 875000 1000000>,
+                                          < 700000 1000000>,
+                                          < 350000 1000000>;
                };
 
                cpu1: cpu@1 {
        gpio0: gpio@e6050000 {
                compatible = "renesas,gpio-r8a7790", "renesas,gpio-rcar";
                reg = <0 0xe6050000 0 0x50>;
-               interrupt-parent = <&gic>;
                interrupts = <0 4 IRQ_TYPE_LEVEL_HIGH>;
                #gpio-cells = <2>;
                gpio-controller;
                gpio-ranges = <&pfc 0 0 32>;
                #interrupt-cells = <2>;
                interrupt-controller;
+               clocks = <&mstp9_clks R8A7790_CLK_GPIO0>;
        };
 
        gpio1: gpio@e6051000 {
                compatible = "renesas,gpio-r8a7790", "renesas,gpio-rcar";
                reg = <0 0xe6051000 0 0x50>;
-               interrupt-parent = <&gic>;
                interrupts = <0 5 IRQ_TYPE_LEVEL_HIGH>;
                #gpio-cells = <2>;
                gpio-controller;
                gpio-ranges = <&pfc 0 32 32>;
                #interrupt-cells = <2>;
                interrupt-controller;
+               clocks = <&mstp9_clks R8A7790_CLK_GPIO1>;
        };
 
        gpio2: gpio@e6052000 {
                compatible = "renesas,gpio-r8a7790", "renesas,gpio-rcar";
                reg = <0 0xe6052000 0 0x50>;
-               interrupt-parent = <&gic>;
                interrupts = <0 6 IRQ_TYPE_LEVEL_HIGH>;
                #gpio-cells = <2>;
                gpio-controller;
                gpio-ranges = <&pfc 0 64 32>;
                #interrupt-cells = <2>;
                interrupt-controller;
+               clocks = <&mstp9_clks R8A7790_CLK_GPIO2>;
        };
 
        gpio3: gpio@e6053000 {
                compatible = "renesas,gpio-r8a7790", "renesas,gpio-rcar";
                reg = <0 0xe6053000 0 0x50>;
-               interrupt-parent = <&gic>;
                interrupts = <0 7 IRQ_TYPE_LEVEL_HIGH>;
                #gpio-cells = <2>;
                gpio-controller;
                gpio-ranges = <&pfc 0 96 32>;
                #interrupt-cells = <2>;
                interrupt-controller;
+               clocks = <&mstp9_clks R8A7790_CLK_GPIO3>;
        };
 
        gpio4: gpio@e6054000 {
                compatible = "renesas,gpio-r8a7790", "renesas,gpio-rcar";
                reg = <0 0xe6054000 0 0x50>;
-               interrupt-parent = <&gic>;
                interrupts = <0 8 IRQ_TYPE_LEVEL_HIGH>;
                #gpio-cells = <2>;
                gpio-controller;
                gpio-ranges = <&pfc 0 128 32>;
                #interrupt-cells = <2>;
                interrupt-controller;
+               clocks = <&mstp9_clks R8A7790_CLK_GPIO4>;
        };
 
        gpio5: gpio@e6055000 {
                compatible = "renesas,gpio-r8a7790", "renesas,gpio-rcar";
                reg = <0 0xe6055000 0 0x50>;
-               interrupt-parent = <&gic>;
                interrupts = <0 9 IRQ_TYPE_LEVEL_HIGH>;
                #gpio-cells = <2>;
                gpio-controller;
                gpio-ranges = <&pfc 0 160 32>;
                #interrupt-cells = <2>;
                interrupt-controller;
+               clocks = <&mstp9_clks R8A7790_CLK_GPIO5>;
        };
 
        thermal@e61f0000 {
                compatible = "renesas,thermal-r8a7790", "renesas,rcar-thermal";
                reg = <0 0xe61f0000 0 0x14>, <0 0xe61f0100 0 0x38>;
-               interrupt-parent = <&gic>;
                interrupts = <0 69 IRQ_TYPE_LEVEL_HIGH>;
+               clocks = <&mstp5_clks R8A7790_CLK_THERMAL>;
        };
 
        timer {
                             <1 10 (GIC_CPU_MASK_SIMPLE(4) | IRQ_TYPE_LEVEL_LOW)>;
        };
 
+       cmt0: timer@ffca0000 {
+               compatible = "renesas,cmt-48-r8a7790", "renesas,cmt-48-gen2";
+               reg = <0 0xffca0000 0 0x1004>;
+               interrupts = <0 142 IRQ_TYPE_LEVEL_HIGH>,
+                            <0 143 IRQ_TYPE_LEVEL_HIGH>;
+               clocks = <&mstp1_clks R8A7790_CLK_CMT0>;
+               clock-names = "fck";
+
+               renesas,channels-mask = <0x60>;
+
+               status = "disabled";
+       };
+
+       cmt1: timer@e6130000 {
+               compatible = "renesas,cmt-48-r8a7790", "renesas,cmt-48-gen2";
+               reg = <0 0xe6130000 0 0x1004>;
+               interrupts = <0 120 IRQ_TYPE_LEVEL_HIGH>,
+                            <0 121 IRQ_TYPE_LEVEL_HIGH>,
+                            <0 122 IRQ_TYPE_LEVEL_HIGH>,
+                            <0 123 IRQ_TYPE_LEVEL_HIGH>,
+                            <0 124 IRQ_TYPE_LEVEL_HIGH>,
+                            <0 125 IRQ_TYPE_LEVEL_HIGH>,
+                            <0 126 IRQ_TYPE_LEVEL_HIGH>,
+                            <0 127 IRQ_TYPE_LEVEL_HIGH>;
+               clocks = <&mstp3_clks R8A7790_CLK_CMT1>;
+               clock-names = "fck";
+
+               renesas,channels-mask = <0xff>;
+
+               status = "disabled";
+       };
+
        irqc0: interrupt-controller@e61c0000 {
                compatible = "renesas,irqc-r8a7790", "renesas,irqc";
                #interrupt-cells = <2>;
                interrupt-controller;
                reg = <0 0xe61c0000 0 0x200>;
-               interrupt-parent = <&gic>;
                interrupts = <0 0 IRQ_TYPE_LEVEL_HIGH>,
                             <0 1 IRQ_TYPE_LEVEL_HIGH>,
                             <0 2 IRQ_TYPE_LEVEL_HIGH>,
                             <0 3 IRQ_TYPE_LEVEL_HIGH>;
        };
 
+       dmac0: dma-controller@e6700000 {
+               compatible = "renesas,rcar-dmac";
+               reg = <0 0xe6700000 0 0x20000>;
+               interrupts = <0 197 IRQ_TYPE_LEVEL_HIGH
+                             0 200 IRQ_TYPE_LEVEL_HIGH
+                             0 201 IRQ_TYPE_LEVEL_HIGH
+                             0 202 IRQ_TYPE_LEVEL_HIGH
+                             0 203 IRQ_TYPE_LEVEL_HIGH
+                             0 204 IRQ_TYPE_LEVEL_HIGH
+                             0 205 IRQ_TYPE_LEVEL_HIGH
+                             0 206 IRQ_TYPE_LEVEL_HIGH
+                             0 207 IRQ_TYPE_LEVEL_HIGH
+                             0 208 IRQ_TYPE_LEVEL_HIGH
+                             0 209 IRQ_TYPE_LEVEL_HIGH
+                             0 210 IRQ_TYPE_LEVEL_HIGH
+                             0 211 IRQ_TYPE_LEVEL_HIGH
+                             0 212 IRQ_TYPE_LEVEL_HIGH
+                             0 213 IRQ_TYPE_LEVEL_HIGH
+                             0 214 IRQ_TYPE_LEVEL_HIGH>;
+               interrupt-names = "error",
+                               "ch0", "ch1", "ch2", "ch3",
+                               "ch4", "ch5", "ch6", "ch7",
+                               "ch8", "ch9", "ch10", "ch11",
+                               "ch12", "ch13", "ch14";
+               clocks = <&mstp2_clks R8A7790_CLK_SYS_DMAC0>;
+               clock-names = "fck";
+               #dma-cells = <1>;
+               dma-channels = <15>;
+       };
+
+       dmac1: dma-controller@e6720000 {
+               compatible = "renesas,rcar-dmac";
+               reg = <0 0xe6720000 0 0x20000>;
+               interrupts = <0 220 IRQ_TYPE_LEVEL_HIGH
+                             0 216 IRQ_TYPE_LEVEL_HIGH
+                             0 217 IRQ_TYPE_LEVEL_HIGH
+                             0 218 IRQ_TYPE_LEVEL_HIGH
+                             0 219 IRQ_TYPE_LEVEL_HIGH
+                             0 308 IRQ_TYPE_LEVEL_HIGH
+                             0 309 IRQ_TYPE_LEVEL_HIGH
+                             0 310 IRQ_TYPE_LEVEL_HIGH
+                             0 311 IRQ_TYPE_LEVEL_HIGH
+                             0 312 IRQ_TYPE_LEVEL_HIGH
+                             0 313 IRQ_TYPE_LEVEL_HIGH
+                             0 314 IRQ_TYPE_LEVEL_HIGH
+                             0 315 IRQ_TYPE_LEVEL_HIGH
+                             0 316 IRQ_TYPE_LEVEL_HIGH
+                             0 317 IRQ_TYPE_LEVEL_HIGH
+                             0 318 IRQ_TYPE_LEVEL_HIGH>;
+               interrupt-names = "error",
+                               "ch0", "ch1", "ch2", "ch3",
+                               "ch4", "ch5", "ch6", "ch7",
+                               "ch8", "ch9", "ch10", "ch11",
+                               "ch12", "ch13", "ch14";
+               clocks = <&mstp2_clks R8A7790_CLK_SYS_DMAC1>;
+               clock-names = "fck";
+               #dma-cells = <1>;
+               dma-channels = <15>;
+       };
        i2c0: i2c@e6508000 {
                #address-cells = <1>;
                #size-cells = <0>;
                compatible = "renesas,i2c-r8a7790";
                reg = <0 0xe6508000 0 0x40>;
-               interrupt-parent = <&gic>;
                interrupts = <0 287 IRQ_TYPE_LEVEL_HIGH>;
                clocks = <&mstp9_clks R8A7790_CLK_I2C0>;
                status = "disabled";
                #size-cells = <0>;
                compatible = "renesas,i2c-r8a7790";
                reg = <0 0xe6518000 0 0x40>;
-               interrupt-parent = <&gic>;
                interrupts = <0 288 IRQ_TYPE_LEVEL_HIGH>;
                clocks = <&mstp9_clks R8A7790_CLK_I2C1>;
                status = "disabled";
                #size-cells = <0>;
                compatible = "renesas,i2c-r8a7790";
                reg = <0 0xe6530000 0 0x40>;
-               interrupt-parent = <&gic>;
                interrupts = <0 286 IRQ_TYPE_LEVEL_HIGH>;
                clocks = <&mstp9_clks R8A7790_CLK_I2C2>;
                status = "disabled";
                #size-cells = <0>;
                compatible = "renesas,i2c-r8a7790";
                reg = <0 0xe6540000 0 0x40>;
-               interrupt-parent = <&gic>;
                interrupts = <0 290 IRQ_TYPE_LEVEL_HIGH>;
                clocks = <&mstp9_clks R8A7790_CLK_I2C3>;
                status = "disabled";
        };
 
+       iic0: i2c@e6500000 {
+               #address-cells = <1>;
+               #size-cells = <0>;
+               compatible = "renesas,iic-r8a7790", "renesas,rmobile-iic";
+               reg = <0 0xe6500000 0 0x425>;
+               interrupts = <0 174 IRQ_TYPE_LEVEL_HIGH>;
+               clocks = <&mstp3_clks R8A7790_CLK_IIC0>;
+               status = "disabled";
+       };
+
+       iic1: i2c@e6510000 {
+               #address-cells = <1>;
+               #size-cells = <0>;
+               compatible = "renesas,iic-r8a7790", "renesas,rmobile-iic";
+               reg = <0 0xe6510000 0 0x425>;
+               interrupts = <0 175 IRQ_TYPE_LEVEL_HIGH>;
+               clocks = <&mstp3_clks R8A7790_CLK_IIC1>;
+               status = "disabled";
+       };
+
+       iic2: i2c@e6520000 {
+               #address-cells = <1>;
+               #size-cells = <0>;
+               compatible = "renesas,iic-r8a7790", "renesas,rmobile-iic";
+               reg = <0 0xe6520000 0 0x425>;
+               interrupts = <0 176 IRQ_TYPE_LEVEL_HIGH>;
+               clocks = <&mstp3_clks R8A7790_CLK_IIC2>;
+               status = "disabled";
+       };
+
+       iic3: i2c@e60b0000 {
+               #address-cells = <1>;
+               #size-cells = <0>;
+               compatible = "renesas,iic-r8a7790", "renesas,rmobile-iic";
+               reg = <0 0xe60b0000 0 0x425>;
+               interrupts = <0 173 IRQ_TYPE_LEVEL_HIGH>;
+               clocks = <&mstp9_clks R8A7790_CLK_IICDVFS>;
+               status = "disabled";
+       };
+
        mmcif0: mmcif@ee200000 {
                compatible = "renesas,mmcif-r8a7790", "renesas,sh-mmcif";
                reg = <0 0xee200000 0 0x80>;
-               interrupt-parent = <&gic>;
                interrupts = <0 169 IRQ_TYPE_LEVEL_HIGH>;
                clocks = <&mstp3_clks R8A7790_CLK_MMCIF0>;
                reg-io-width = <4>;
        mmcif1: mmc@ee220000 {
                compatible = "renesas,mmcif-r8a7790", "renesas,sh-mmcif";
                reg = <0 0xee220000 0 0x80>;
-               interrupt-parent = <&gic>;
                interrupts = <0 170 IRQ_TYPE_LEVEL_HIGH>;
                clocks = <&mstp3_clks R8A7790_CLK_MMCIF1>;
                reg-io-width = <4>;
        sdhi0: sd@ee100000 {
                compatible = "renesas,sdhi-r8a7790";
                reg = <0 0xee100000 0 0x200>;
-               interrupt-parent = <&gic>;
                interrupts = <0 165 IRQ_TYPE_LEVEL_HIGH>;
                clocks = <&mstp3_clks R8A7790_CLK_SDHI0>;
                cap-sd-highspeed;
        sdhi1: sd@ee120000 {
                compatible = "renesas,sdhi-r8a7790";
                reg = <0 0xee120000 0 0x200>;
-               interrupt-parent = <&gic>;
                interrupts = <0 166 IRQ_TYPE_LEVEL_HIGH>;
                clocks = <&mstp3_clks R8A7790_CLK_SDHI1>;
                cap-sd-highspeed;
        sdhi2: sd@ee140000 {
                compatible = "renesas,sdhi-r8a7790";
                reg = <0 0xee140000 0 0x100>;
-               interrupt-parent = <&gic>;
                interrupts = <0 167 IRQ_TYPE_LEVEL_HIGH>;
                clocks = <&mstp3_clks R8A7790_CLK_SDHI2>;
                cap-sd-highspeed;
        sdhi3: sd@ee160000 {
                compatible = "renesas,sdhi-r8a7790";
                reg = <0 0xee160000 0 0x100>;
-               interrupt-parent = <&gic>;
                interrupts = <0 168 IRQ_TYPE_LEVEL_HIGH>;
                clocks = <&mstp3_clks R8A7790_CLK_SDHI3>;
                cap-sd-highspeed;
                status = "disabled";
        };
 
+       scifa0: serial@e6c40000 {
+               compatible = "renesas,scifa-r8a7790", "renesas,scifa";
+               reg = <0 0xe6c40000 0 64>;
+               interrupts = <0 144 IRQ_TYPE_LEVEL_HIGH>;
+               clocks = <&mstp2_clks R8A7790_CLK_SCIFA0>;
+               clock-names = "sci_ick";
+               status = "disabled";
+       };
+
+       scifa1: serial@e6c50000 {
+               compatible = "renesas,scifa-r8a7790", "renesas,scifa";
+               reg = <0 0xe6c50000 0 64>;
+               interrupts = <0 145 IRQ_TYPE_LEVEL_HIGH>;
+               clocks = <&mstp2_clks R8A7790_CLK_SCIFA1>;
+               clock-names = "sci_ick";
+               status = "disabled";
+       };
+
+       scifa2: serial@e6c60000 {
+               compatible = "renesas,scifa-r8a7790", "renesas,scifa";
+               reg = <0 0xe6c60000 0 64>;
+               interrupts = <0 151 IRQ_TYPE_LEVEL_HIGH>;
+               clocks = <&mstp2_clks R8A7790_CLK_SCIFA2>;
+               clock-names = "sci_ick";
+               status = "disabled";
+       };
+
+       scifb0: serial@e6c20000 {
+               compatible = "renesas,scifb-r8a7790", "renesas,scifb";
+               reg = <0 0xe6c20000 0 64>;
+               interrupts = <0 148 IRQ_TYPE_LEVEL_HIGH>;
+               clocks = <&mstp2_clks R8A7790_CLK_SCIFB0>;
+               clock-names = "sci_ick";
+               status = "disabled";
+       };
+
+       scifb1: serial@e6c30000 {
+               compatible = "renesas,scifb-r8a7790", "renesas,scifb";
+               reg = <0 0xe6c30000 0 64>;
+               interrupts = <0 149 IRQ_TYPE_LEVEL_HIGH>;
+               clocks = <&mstp2_clks R8A7790_CLK_SCIFB1>;
+               clock-names = "sci_ick";
+               status = "disabled";
+       };
+
+       scifb2: serial@e6ce0000 {
+               compatible = "renesas,scifb-r8a7790", "renesas,scifb";
+               reg = <0 0xe6ce0000 0 64>;
+               interrupts = <0 150 IRQ_TYPE_LEVEL_HIGH>;
+               clocks = <&mstp2_clks R8A7790_CLK_SCIFB2>;
+               clock-names = "sci_ick";
+               status = "disabled";
+       };
+
+       scif0: serial@e6e60000 {
+               compatible = "renesas,scif-r8a7790", "renesas,scif";
+               reg = <0 0xe6e60000 0 64>;
+               interrupts = <0 152 IRQ_TYPE_LEVEL_HIGH>;
+               clocks = <&mstp7_clks R8A7790_CLK_SCIF0>;
+               clock-names = "sci_ick";
+               status = "disabled";
+       };
+
+       scif1: serial@e6e68000 {
+               compatible = "renesas,scif-r8a7790", "renesas,scif";
+               reg = <0 0xe6e68000 0 64>;
+               interrupts = <0 153 IRQ_TYPE_LEVEL_HIGH>;
+               clocks = <&mstp7_clks R8A7790_CLK_SCIF1>;
+               clock-names = "sci_ick";
+               status = "disabled";
+       };
+
+       hscif0: serial@e62c0000 {
+               compatible = "renesas,hscif-r8a7790", "renesas,hscif";
+               reg = <0 0xe62c0000 0 96>;
+               interrupts = <0 154 IRQ_TYPE_LEVEL_HIGH>;
+               clocks = <&mstp7_clks R8A7790_CLK_HSCIF0>;
+               clock-names = "sci_ick";
+               status = "disabled";
+       };
+
+       hscif1: serial@e62c8000 {
+               compatible = "renesas,hscif-r8a7790", "renesas,hscif";
+               reg = <0 0xe62c8000 0 96>;
+               interrupts = <0 155 IRQ_TYPE_LEVEL_HIGH>;
+               clocks = <&mstp7_clks R8A7790_CLK_HSCIF1>;
+               clock-names = "sci_ick";
+               status = "disabled";
+       };
+
+       ether: ethernet@ee700000 {
+               compatible = "renesas,ether-r8a7790";
+               reg = <0 0xee700000 0 0x400>;
+               interrupts = <0 162 IRQ_TYPE_LEVEL_HIGH>;
+               clocks = <&mstp8_clks R8A7790_CLK_ETHER>;
+               phy-mode = "rmii";
+               #address-cells = <1>;
+               #size-cells = <0>;
+               status = "disabled";
+       };
+
+       sata0: sata@ee300000 {
+               compatible = "renesas,sata-r8a7790";
+               reg = <0 0xee300000 0 0x2000>;
+               interrupts = <0 105 IRQ_TYPE_LEVEL_HIGH>;
+               clocks = <&mstp8_clks R8A7790_CLK_SATA0>;
+               status = "disabled";
+       };
+
+       sata1: sata@ee500000 {
+               compatible = "renesas,sata-r8a7790";
+               reg = <0 0xee500000 0 0x2000>;
+               interrupts = <0 106 IRQ_TYPE_LEVEL_HIGH>;
+               clocks = <&mstp8_clks R8A7790_CLK_SATA1>;
+               status = "disabled";
+       };
+
+       vin0: video@e6ef0000 {
+               compatible = "renesas,vin-r8a7790";
+               clocks = <&mstp8_clks R8A7790_CLK_VIN0>;
+               reg = <0 0xe6ef0000 0 0x1000>;
+               interrupts = <0 188 IRQ_TYPE_LEVEL_HIGH>;
+               status = "disabled";
+       };
+
+       vin1: video@e6ef1000 {
+               compatible = "renesas,vin-r8a7790";
+               clocks = <&mstp8_clks R8A7790_CLK_VIN1>;
+               reg = <0 0xe6ef1000 0 0x1000>;
+               interrupts = <0 189 IRQ_TYPE_LEVEL_HIGH>;
+               status = "disabled";
+       };
+
+       vin2: video@e6ef2000 {
+               compatible = "renesas,vin-r8a7790";
+               clocks = <&mstp8_clks R8A7790_CLK_VIN2>;
+               reg = <0 0xe6ef2000 0 0x1000>;
+               interrupts = <0 190 IRQ_TYPE_LEVEL_HIGH>;
+               status = "disabled";
+       };
+
+       vin3: video@e6ef3000 {
+               compatible = "renesas,vin-r8a7790";
+               clocks = <&mstp8_clks R8A7790_CLK_VIN3>;
+               reg = <0 0xe6ef3000 0 0x1000>;
+               interrupts = <0 191 IRQ_TYPE_LEVEL_HIGH>;
+               status = "disabled";
+       };
+
        clocks {
                #address-cells = <2>;
                #size-cells = <2>;
                        clock-output-names = "extal";
                };
 
+               /* External PCIe clock - can be overridden by the board */
+               pcie_bus_clk: pcie_bus_clk {
+                       compatible = "fixed-clock";
+                       #clock-cells = <0>;
+                       clock-frequency = <100000000>;
+                       clock-output-names = "pcie_bus";
+                       status = "disabled";
+               };
+
+               /*
+                * The external audio clocks are configured as 0 Hz fixed frequency clocks by
+                * default. Boards that provide audio clocks should override them.
+                */
+               audio_clk_a: audio_clk_a {
+                       compatible = "fixed-clock";
+                       #clock-cells = <0>;
+                       clock-frequency = <0>;
+                       clock-output-names = "audio_clk_a";
+               };
+               audio_clk_b: audio_clk_b {
+                       compatible = "fixed-clock";
+                       #clock-cells = <0>;
+                       clock-frequency = <0>;
+                       clock-output-names = "audio_clk_b";
+               };
+               audio_clk_c: audio_clk_c {
+                       compatible = "fixed-clock";
+                       #clock-cells = <0>;
+                       clock-frequency = <0>;
+                       clock-output-names = "audio_clk_c";
+               };
+
                /* Special CPG clocks */
                cpg_clocks: cpg_clocks@e6150000 {
                        compatible = "renesas,r8a7790-cpg-clocks",
                mstp1_clks: mstp1_clks@e6150134 {
                        compatible = "renesas,r8a7790-mstp-clocks", "renesas,cpg-mstp-clocks";
                        reg = <0 0xe6150134 0 4>, <0 0xe6150038 0 4>;
-                       clocks = <&p_clk>, <&p_clk>, <&p_clk>, <&rclk_clk>,
+                       clocks = <&m2_clk>, <&p_clk>, <&p_clk>, <&p_clk>, <&rclk_clk>,
                                 <&cp_clk>, <&zs_clk>, <&zs_clk>, <&zs_clk>,
                                 <&zs_clk>;
                        #clock-cells = <1>;
                        renesas,clock-indices = <
-                               R8A7790_CLK_TMU1 R8A7790_CLK_TMU3 R8A7790_CLK_TMU2
+                               R8A7790_CLK_JPU R8A7790_CLK_TMU1 R8A7790_CLK_TMU3 R8A7790_CLK_TMU2
                                R8A7790_CLK_CMT0 R8A7790_CLK_TMU0 R8A7790_CLK_VSP1_DU1
-                               R8A7790_CLK_VSP1_DU0 R8A7790_CLK_VSP1_RT R8A7790_CLK_VSP1_SY
+                               R8A7790_CLK_VSP1_DU0 R8A7790_CLK_VSP1_R R8A7790_CLK_VSP1_S
                        >;
                        clock-output-names =
-                               "tmu1", "tmu3", "tmu2", "cmt0", "tmu0", "vsp1-du1",
+                               "jpu", "tmu1", "tmu3", "tmu2", "cmt0", "tmu0", "vsp1-du1",
                                "vsp1-du0", "vsp1-rt", "vsp1-sy";
                };
                mstp2_clks: mstp2_clks@e6150138 {
                        compatible = "renesas,r8a7790-mstp-clocks", "renesas,cpg-mstp-clocks";
                        reg = <0 0xe6150138 0 4>, <0 0xe6150040 0 4>;
                        clocks = <&mp_clk>, <&mp_clk>, <&mp_clk>, <&mp_clk>, <&mp_clk>,
-                                <&mp_clk>, <&mp_clk>, <&mp_clk>, <&mp_clk>;
+                                <&mp_clk>, <&mp_clk>, <&mp_clk>, <&mp_clk>, <&zs_clk>,
+                                <&zs_clk>;
                        #clock-cells = <1>;
                        renesas,clock-indices = <
                                R8A7790_CLK_SCIFA2 R8A7790_CLK_SCIFA1 R8A7790_CLK_SCIFA0
                                R8A7790_CLK_MSIOF2 R8A7790_CLK_SCIFB0 R8A7790_CLK_SCIFB1
                                R8A7790_CLK_MSIOF1 R8A7790_CLK_MSIOF3 R8A7790_CLK_SCIFB2
+                               R8A7790_CLK_SYS_DMAC1 R8A7790_CLK_SYS_DMAC0
                        >;
                        clock-output-names =
                                "scifa2", "scifa1", "scifa0", "msiof2", "scifb0",
-                               "scifb1", "msiof1", "msiof3", "scifb2";
+                               "scifb1", "msiof1", "msiof3", "scifb2",
+                               "sys-dmac1", "sys-dmac0";
                };
                mstp3_clks: mstp3_clks@e615013c {
                        compatible = "renesas,r8a7790-mstp-clocks", "renesas,cpg-mstp-clocks";
                        reg = <0 0xe615013c 0 4>, <0 0xe6150048 0 4>;
-                       clocks = <&cp_clk>, <&mmc1_clk>, <&sd3_clk>, <&sd2_clk>,
-                                <&cpg_clocks R8A7790_CLK_SD1>, <&cpg_clocks R8A7790_CLK_SD0>,
-                                <&mmc0_clk>, <&rclk_clk>;
+                       clocks = <&hp_clk>, <&cp_clk>, <&mmc1_clk>, <&sd3_clk>,
+                                <&sd2_clk>, <&cpg_clocks R8A7790_CLK_SD1>, <&cpg_clocks R8A7790_CLK_SD0>, <&mmc0_clk>,
+                                <&hp_clk>, <&mp_clk>, <&hp_clk>, <&mp_clk>, <&rclk_clk>;
                        #clock-cells = <1>;
                        renesas,clock-indices = <
-                               R8A7790_CLK_TPU0 R8A7790_CLK_MMCIF1 R8A7790_CLK_SDHI3
-                               R8A7790_CLK_SDHI2 R8A7790_CLK_SDHI1 R8A7790_CLK_SDHI0
-                               R8A7790_CLK_MMCIF0 R8A7790_CLK_CMT1
+                               R8A7790_CLK_IIC2 R8A7790_CLK_TPU0 R8A7790_CLK_MMCIF1 R8A7790_CLK_SDHI3
+                               R8A7790_CLK_SDHI2 R8A7790_CLK_SDHI1 R8A7790_CLK_SDHI0 R8A7790_CLK_MMCIF0
+                               R8A7790_CLK_IIC0 R8A7790_CLK_PCIEC R8A7790_CLK_IIC1 R8A7790_CLK_SSUSB R8A7790_CLK_CMT1
                        >;
                        clock-output-names =
-                               "tpu0", "mmcif1", "sdhi3", "sdhi2",
-                               "sdhi1", "sdhi0", "mmcif0", "cmt1";
+                               "iic2", "tpu0", "mmcif1", "sdhi3",
+                               "sdhi2", "sdhi1", "sdhi0", "mmcif0",
+                               "iic0", "pciec", "iic1", "ssusb", "cmt1";
                };
                mstp5_clks: mstp5_clks@e6150144 {
                        compatible = "renesas,r8a7790-mstp-clocks", "renesas,cpg-mstp-clocks";
                mstp8_clks: mstp8_clks@e6150990 {
                        compatible = "renesas,r8a7790-mstp-clocks", "renesas,cpg-mstp-clocks";
                        reg = <0 0xe6150990 0 4>, <0 0xe61509a0 0 4>;
-                       clocks = <&p_clk>;
+                       clocks = <&zg_clk>, <&zg_clk>, <&zg_clk>, <&zg_clk>, <&p_clk>,
+                                <&zs_clk>, <&zs_clk>;
                        #clock-cells = <1>;
-                       renesas,clock-indices = <R8A7790_CLK_ETHER>;
-                       clock-output-names = "ether";
+                       renesas,clock-indices = <
+                               R8A7790_CLK_VIN3 R8A7790_CLK_VIN2 R8A7790_CLK_VIN1
+                               R8A7790_CLK_VIN0 R8A7790_CLK_ETHER R8A7790_CLK_SATA1
+                               R8A7790_CLK_SATA0
+                       >;
+                       clock-output-names =
+                               "vin3", "vin2", "vin1", "vin0", "ether", "sata1", "sata0";
                };
                mstp9_clks: mstp9_clks@e6150994 {
                        compatible = "renesas,r8a7790-mstp-clocks", "renesas,cpg-mstp-clocks";
                        reg = <0 0xe6150994 0 4>, <0 0xe61509a4 0 4>;
-                       clocks = <&p_clk>, <&p_clk>, <&cpg_clocks R8A7790_CLK_QSPI>,
-                                <&p_clk>, <&p_clk>, <&p_clk>, <&p_clk>;
+                       clocks = <&cp_clk>, <&cp_clk>, <&cp_clk>,
+                                <&cp_clk>, <&cp_clk>, <&cp_clk>,
+                                <&p_clk>, <&p_clk>, <&cpg_clocks R8A7790_CLK_QSPI>, <&cp_clk>,
+                                <&hp_clk>, <&hp_clk>, <&hp_clk>, <&hp_clk>;
                        #clock-cells = <1>;
                        renesas,clock-indices = <
-                               R8A7790_CLK_RCAN1 R8A7790_CLK_RCAN0 R8A7790_CLK_QSPI_MOD
-                               R8A7790_CLK_I2C3 R8A7790_CLK_I2C2 R8A7790_CLK_I2C1
-                               R8A7790_CLK_I2C0
+                               R8A7790_CLK_GPIO5 R8A7790_CLK_GPIO4 R8A7790_CLK_GPIO3
+                               R8A7790_CLK_GPIO2 R8A7790_CLK_GPIO1 R8A7790_CLK_GPIO0
+                               R8A7790_CLK_RCAN1 R8A7790_CLK_RCAN0 R8A7790_CLK_QSPI_MOD R8A7790_CLK_IICDVFS
+                               R8A7790_CLK_I2C3 R8A7790_CLK_I2C2 R8A7790_CLK_I2C1 R8A7790_CLK_I2C0
                        >;
                        clock-output-names =
-                               "rcan1", "rcan0", "qspi_mod", "i2c3", "i2c2", "i2c1", "i2c0";
+                               "gpio5", "gpio4", "gpio3", "gpio2", "gpio1", "gpio0",
+                               "rcan1", "rcan0", "qspi_mod", "iic3",
+                               "i2c3", "i2c2", "i2c1", "i2c0";
+               };
+               mstp10_clks: mstp10_clks@e6150998 {
+                       compatible = "renesas,r8a7790-mstp-clocks", "renesas,cpg-mstp-clocks";
+                       reg = <0 0xe6150998 0 4>, <0 0xe61509a8 0 4>;
+                       clocks = <&p_clk>,
+                               <&p_clk>, <&p_clk>, <&p_clk>, <&p_clk>, <&p_clk>,
+                               <&p_clk>, <&p_clk>, <&p_clk>, <&p_clk>, <&p_clk>,
+                               <&p_clk>,
+                               <&mstp10_clks R8A7790_CLK_SCU_ALL>, <&mstp10_clks R8A7790_CLK_SCU_ALL>,
+                               <&mstp10_clks R8A7790_CLK_SCU_ALL>, <&mstp10_clks R8A7790_CLK_SCU_ALL>,
+                               <&mstp10_clks R8A7790_CLK_SCU_ALL>, <&mstp10_clks R8A7790_CLK_SCU_ALL>,
+                               <&mstp10_clks R8A7790_CLK_SCU_ALL>, <&mstp10_clks R8A7790_CLK_SCU_ALL>,
+                               <&mstp10_clks R8A7790_CLK_SCU_ALL>, <&mstp10_clks R8A7790_CLK_SCU_ALL>,
+                               <&mstp10_clks R8A7790_CLK_SCU_ALL>, <&mstp10_clks R8A7790_CLK_SCU_ALL>;
+
+                       #clock-cells = <1>;
+                       clock-indices = <
+                               R8A7790_CLK_SSI_ALL
+                               R8A7790_CLK_SSI9 R8A7790_CLK_SSI8 R8A7790_CLK_SSI7 R8A7790_CLK_SSI6 R8A7790_CLK_SSI5
+                               R8A7790_CLK_SSI4 R8A7790_CLK_SSI3 R8A7790_CLK_SSI2 R8A7790_CLK_SSI1 R8A7790_CLK_SSI0
+                               R8A7790_CLK_SCU_ALL
+                               R8A7790_CLK_SCU_DVC1 R8A7790_CLK_SCU_DVC0
+                               R8A7790_CLK_SCU_SRC9 R8A7790_CLK_SCU_SRC8 R8A7790_CLK_SCU_SRC7 R8A7790_CLK_SCU_SRC6 R8A7790_CLK_SCU_SRC5
+                               R8A7790_CLK_SCU_SRC4 R8A7790_CLK_SCU_SRC3 R8A7790_CLK_SCU_SRC2 R8A7790_CLK_SCU_SRC1 R8A7790_CLK_SCU_SRC0
+                       >;
+                       clock-output-names =
+                               "ssi-all",
+                               "ssi9", "ssi8", "ssi7", "ssi6", "ssi5",
+                               "ssi4", "ssi3", "ssi2", "ssi1", "ssi0",
+                               "scu-all",
+                               "scu-dvc1", "scu-dvc0",
+                               "scu-src9", "scu-src8", "scu-src7", "scu-src6", "scu-src5",
+                               "scu-src4", "scu-src3", "scu-src2", "scu-src1", "scu-src0";
+               };
+       };
+
+       qspi: spi@e6b10000 {
+               compatible = "renesas,qspi-r8a7790", "renesas,qspi";
+               reg = <0 0xe6b10000 0 0x2c>;
+               interrupts = <0 184 IRQ_TYPE_LEVEL_HIGH>;
+               clocks = <&mstp9_clks R8A7790_CLK_QSPI_MOD>;
+               dmas = <&dmac0 0x17>, <&dmac0 0x18>;
+               dma-names = "tx", "rx";
+               num-cs = <1>;
+               #address-cells = <1>;
+               #size-cells = <0>;
+               status = "disabled";
+       };
+
+       msiof0: spi@e6e20000 {
+               compatible = "renesas,msiof-r8a7790";
+               reg = <0 0xe6e20000 0 0x0064>, <0 0xe7e20000 0 0x0064>;
+               interrupts = <0 156 IRQ_TYPE_LEVEL_HIGH>;
+               clocks = <&mstp0_clks R8A7790_CLK_MSIOF0>;
+               dmas = <&dmac0 0x51>, <&dmac0 0x52>;
+               dma-names = "tx", "rx";
+               #address-cells = <1>;
+               #size-cells = <0>;
+               status = "disabled";
+       };
+
+       msiof1: spi@e6e10000 {
+               compatible = "renesas,msiof-r8a7790";
+               reg = <0 0xe6e10000 0 0x0064>, <0 0xe7e10000 0 0x0064>;
+               interrupts = <0 157 IRQ_TYPE_LEVEL_HIGH>;
+               clocks = <&mstp2_clks R8A7790_CLK_MSIOF1>;
+               dmas = <&dmac0 0x55>, <&dmac0 0x56>;
+               dma-names = "tx", "rx";
+               #address-cells = <1>;
+               #size-cells = <0>;
+               status = "disabled";
+       };
+
+       msiof2: spi@e6e00000 {
+               compatible = "renesas,msiof-r8a7790";
+               reg = <0 0xe6e00000 0 0x0064>, <0 0xe7e00000 0 0x0064>;
+               interrupts = <0 158 IRQ_TYPE_LEVEL_HIGH>;
+               clocks = <&mstp2_clks R8A7790_CLK_MSIOF2>;
+               dmas = <&dmac0 0x41>, <&dmac0 0x42>;
+               dma-names = "tx", "rx";
+               #address-cells = <1>;
+               #size-cells = <0>;
+               status = "disabled";
+       };
+
+       msiof3: spi@e6c90000 {
+               compatible = "renesas,msiof-r8a7790";
+               reg = <0 0xe6c90000 0 0x0064>, <0 0xe7c90000 0 0x0064>;
+               interrupts = <0 159 IRQ_TYPE_LEVEL_HIGH>;
+               clocks = <&mstp2_clks R8A7790_CLK_MSIOF3>;
+               dmas = <&dmac0 0x45>, <&dmac0 0x46>;
+               dma-names = "tx", "rx";
+               #address-cells = <1>;
+               #size-cells = <0>;
+               status = "disabled";
+       };
+
+       pci0: pci@ee090000 {
+               compatible = "renesas,pci-r8a7790";
+               device_type = "pci";
+               clocks = <&mstp7_clks R8A7790_CLK_EHCI>;
+               reg = <0 0xee090000 0 0xc00>,
+                     <0 0xee080000 0 0x1100>;
+               interrupts = <0 108 IRQ_TYPE_LEVEL_HIGH>;
+               status = "disabled";
+
+               bus-range = <0 0>;
+               #address-cells = <3>;
+               #size-cells = <2>;
+               #interrupt-cells = <1>;
+               ranges = <0x02000000 0 0xee080000 0 0xee080000 0 0x00010000>;
+               interrupt-map-mask = <0xff00 0 0 0x7>;
+               interrupt-map = <0x0000 0 0 1 &gic 0 108 IRQ_TYPE_LEVEL_HIGH
+                                0x0800 0 0 1 &gic 0 108 IRQ_TYPE_LEVEL_HIGH
+                                0x1000 0 0 2 &gic 0 108 IRQ_TYPE_LEVEL_HIGH>;
+       };
+
+       pci1: pci@ee0b0000 {
+               compatible = "renesas,pci-r8a7790";
+               device_type = "pci";
+               clocks = <&mstp7_clks R8A7790_CLK_EHCI>;
+               reg = <0 0xee0b0000 0 0xc00>,
+                     <0 0xee0a0000 0 0x1100>;
+               interrupts = <0 112 IRQ_TYPE_LEVEL_HIGH>;
+               status = "disabled";
+
+               bus-range = <1 1>;
+               #address-cells = <3>;
+               #size-cells = <2>;
+               #interrupt-cells = <1>;
+               ranges = <0x02000000 0 0xee0a0000 0 0xee0a0000 0 0x00010000>;
+               interrupt-map-mask = <0xff00 0 0 0x7>;
+               interrupt-map = <0x0000 0 0 1 &gic 0 112 IRQ_TYPE_LEVEL_HIGH
+                                0x0800 0 0 1 &gic 0 112 IRQ_TYPE_LEVEL_HIGH
+                                0x1000 0 0 2 &gic 0 112 IRQ_TYPE_LEVEL_HIGH>;
+       };
+
+       pci2: pci@ee0d0000 {
+               compatible = "renesas,pci-r8a7790";
+               device_type = "pci";
+               clocks = <&mstp7_clks R8A7790_CLK_EHCI>;
+               reg = <0 0xee0d0000 0 0xc00>,
+                     <0 0xee0c0000 0 0x1100>;
+               interrupts = <0 113 IRQ_TYPE_LEVEL_HIGH>;
+               status = "disabled";
+
+               bus-range = <2 2>;
+               #address-cells = <3>;
+               #size-cells = <2>;
+               #interrupt-cells = <1>;
+               ranges = <0x02000000 0 0xee0c0000 0 0xee0c0000 0 0x00010000>;
+               interrupt-map-mask = <0xff00 0 0 0x7>;
+               interrupt-map = <0x0000 0 0 1 &gic 0 113 IRQ_TYPE_LEVEL_HIGH
+                                0x0800 0 0 1 &gic 0 113 IRQ_TYPE_LEVEL_HIGH
+                                0x1000 0 0 2 &gic 0 113 IRQ_TYPE_LEVEL_HIGH>;
+       };
+
+       pciec: pcie@fe000000 {
+               compatible = "renesas,pcie-r8a7790";
+               reg = <0 0xfe000000 0 0x80000>;
+               #address-cells = <3>;
+               #size-cells = <2>;
+               bus-range = <0x00 0xff>;
+               device_type = "pci";
+               ranges = <0x01000000 0 0x00000000 0 0xfe100000 0 0x00100000
+                         0x02000000 0 0xfe200000 0 0xfe200000 0 0x00200000
+                         0x02000000 0 0x30000000 0 0x30000000 0 0x08000000
+                         0x42000000 0 0x38000000 0 0x38000000 0 0x08000000>;
+               /* Map all possible DDR as inbound ranges */
+               dma-ranges = <0x42000000 0 0x40000000 0 0x40000000 0 0x80000000
+                             0x43000000 1 0x80000000 1 0x80000000 0 0x80000000>;
+               interrupts = <0 116 IRQ_TYPE_LEVEL_HIGH>,
+                            <0 117 IRQ_TYPE_LEVEL_HIGH>,
+                            <0 118 IRQ_TYPE_LEVEL_HIGH>;
+               #interrupt-cells = <1>;
+               interrupt-map-mask = <0 0 0 0>;
+               interrupt-map = <0 0 0 0 &gic 0 116 IRQ_TYPE_LEVEL_HIGH>;
+               clocks = <&mstp3_clks R8A7790_CLK_PCIEC>, <&pcie_bus_clk>;
+               clock-names = "pcie", "pcie_bus";
+               status = "disabled";
+       };
+
+       rcar_sound: rcar_sound@0xec500000 {
+               #sound-dai-cells = <1>;
+               compatible =  "renesas,rcar_sound-r8a7790", "renesas,rcar_sound-gen2", "renesas,rcar_sound";
+               reg =   <0 0xec500000 0 0x1000>, /* SCU */
+                       <0 0xec5a0000 0 0x100>,  /* ADG */
+                       <0 0xec540000 0 0x1000>, /* SSIU */
+                       <0 0xec541000 0 0x1280>; /* SSI */
+               clocks = <&mstp10_clks R8A7790_CLK_SSI_ALL>,
+                       <&mstp10_clks R8A7790_CLK_SSI9>, <&mstp10_clks R8A7790_CLK_SSI8>,
+                       <&mstp10_clks R8A7790_CLK_SSI7>, <&mstp10_clks R8A7790_CLK_SSI6>,
+                       <&mstp10_clks R8A7790_CLK_SSI5>, <&mstp10_clks R8A7790_CLK_SSI4>,
+                       <&mstp10_clks R8A7790_CLK_SSI3>, <&mstp10_clks R8A7790_CLK_SSI2>,
+                       <&mstp10_clks R8A7790_CLK_SSI1>, <&mstp10_clks R8A7790_CLK_SSI0>,
+                       <&mstp10_clks R8A7790_CLK_SCU_SRC9>, <&mstp10_clks R8A7790_CLK_SCU_SRC8>,
+                       <&mstp10_clks R8A7790_CLK_SCU_SRC7>, <&mstp10_clks R8A7790_CLK_SCU_SRC6>,
+                       <&mstp10_clks R8A7790_CLK_SCU_SRC5>, <&mstp10_clks R8A7790_CLK_SCU_SRC4>,
+                       <&mstp10_clks R8A7790_CLK_SCU_SRC3>, <&mstp10_clks R8A7790_CLK_SCU_SRC2>,
+                       <&mstp10_clks R8A7790_CLK_SCU_SRC1>, <&mstp10_clks R8A7790_CLK_SCU_SRC0>,
+                       <&mstp10_clks R8A7790_CLK_SCU_DVC0>, <&mstp10_clks R8A7790_CLK_SCU_DVC1>,
+                       <&audio_clk_a>, <&audio_clk_b>, <&audio_clk_c>, <&m2_clk>;
+               clock-names = "ssi-all",
+                               "ssi.9", "ssi.8", "ssi.7", "ssi.6", "ssi.5",
+                               "ssi.4", "ssi.3", "ssi.2", "ssi.1", "ssi.0",
+                               "src.9", "src.8", "src.7", "src.6", "src.5",
+                               "src.4", "src.3", "src.2", "src.1", "src.0",
+                               "dvc.0", "dvc.1",
+                               "clk_a", "clk_b", "clk_c", "clk_i";
+
+               status = "disabled";
+
+               rcar_sound,dvc {
+                       dvc0: dvc@0 { };
+                       dvc1: dvc@1 { };
+               };
+
+               rcar_sound,src {
+                       src0: src@0 { };
+                       src1: src@1 { };
+                       src2: src@2 { };
+                       src3: src@3 { };
+                       src4: src@4 { };
+                       src5: src@5 { };
+                       src6: src@6 { };
+                       src7: src@7 { };
+                       src8: src@8 { };
+                       src9: src@9 { };
+               };
+
+               rcar_sound,ssi {
+                       ssi0: ssi@0 { interrupts = <0 370 IRQ_TYPE_LEVEL_HIGH>; };
+                       ssi1: ssi@1 { interrupts = <0 371 IRQ_TYPE_LEVEL_HIGH>; };
+                       ssi2: ssi@2 { interrupts = <0 372 IRQ_TYPE_LEVEL_HIGH>; };
+                       ssi3: ssi@3 { interrupts = <0 373 IRQ_TYPE_LEVEL_HIGH>; };
+                       ssi4: ssi@4 { interrupts = <0 374 IRQ_TYPE_LEVEL_HIGH>; };
+                       ssi5: ssi@5 { interrupts = <0 375 IRQ_TYPE_LEVEL_HIGH>; };
+                       ssi6: ssi@6 { interrupts = <0 376 IRQ_TYPE_LEVEL_HIGH>; };
+                       ssi7: ssi@7 { interrupts = <0 377 IRQ_TYPE_LEVEL_HIGH>; };
+                       ssi8: ssi@8 { interrupts = <0 378 IRQ_TYPE_LEVEL_HIGH>; };
+                       ssi9: ssi@9 { interrupts = <0 379 IRQ_TYPE_LEVEL_HIGH>; };
                };
        };
 };
diff --git a/arch/arm/boot/dts/r8a7791-henninger.dts b/arch/arm/boot/dts/r8a7791-henninger.dts
new file mode 100644 (file)
index 0000000..f1b56de
--- /dev/null
@@ -0,0 +1,297 @@
+/*
+ * Device Tree Source for the Henninger board
+ *
+ * Copyright (C) 2014 Renesas Solutions Corp.
+ * Copyright (C) 2014 Cogent Embedded, Inc.
+ *
+ * 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.
+ */
+
+/dts-v1/;
+#include "r8a7791.dtsi"
+#include <dt-bindings/gpio/gpio.h>
+
+/ {
+       model = "Henninger";
+       compatible = "renesas,henninger", "renesas,r8a7791";
+
+       aliases {
+               serial0 = &scif0;
+       };
+
+       chosen {
+               bootargs = "console=ttySC0,38400 ignore_loglevel rw root=/dev/nfs ip=dhcp";
+       };
+
+       memory@40000000 {
+               device_type = "memory";
+               reg = <0 0x40000000 0 0x40000000>;
+       };
+
+       memory@200000000 {
+               device_type = "memory";
+               reg = <2 0x00000000 0 0x40000000>;
+       };
+
+       vcc_sdhi0: regulator@0 {
+               compatible = "regulator-fixed";
+
+               regulator-name = "SDHI0 Vcc";
+               regulator-min-microvolt = <3300000>;
+               regulator-max-microvolt = <3300000>;
+               regulator-always-on;
+       };
+
+       vccq_sdhi0: regulator@1 {
+               compatible = "regulator-gpio";
+
+               regulator-name = "SDHI0 VccQ";
+               regulator-min-microvolt = <1800000>;
+               regulator-max-microvolt = <3300000>;
+
+               gpios = <&gpio2 12 GPIO_ACTIVE_HIGH>;
+               gpios-states = <1>;
+               states = <3300000 1
+                         1800000 0>;
+       };
+
+       vcc_sdhi2: regulator@2 {
+               compatible = "regulator-fixed";
+
+               regulator-name = "SDHI2 Vcc";
+               regulator-min-microvolt = <3300000>;
+               regulator-max-microvolt = <3300000>;
+               regulator-always-on;
+       };
+
+       vccq_sdhi2: regulator@3 {
+               compatible = "regulator-gpio";
+
+               regulator-name = "SDHI2 VccQ";
+               regulator-min-microvolt = <1800000>;
+               regulator-max-microvolt = <3300000>;
+
+               gpios = <&gpio2 26 GPIO_ACTIVE_HIGH>;
+               gpios-states = <1>;
+               states = <3300000 1
+                         1800000 0>;
+       };
+};
+
+&extal_clk {
+       clock-frequency = <20000000>;
+};
+
+&pfc {
+       scif0_pins: serial0 {
+               renesas,groups = "scif0_data_d";
+               renesas,function = "scif0";
+       };
+
+       ether_pins: ether {
+               renesas,groups = "eth_link", "eth_mdio", "eth_rmii";
+               renesas,function = "eth";
+       };
+
+       phy1_pins: phy1 {
+               renesas,groups = "intc_irq0";
+               renesas,function = "intc";
+       };
+
+       sdhi0_pins: sd0 {
+               renesas,groups = "sdhi0_data4", "sdhi0_ctrl";
+               renesas,function = "sdhi0";
+       };
+
+       sdhi2_pins: sd2 {
+               renesas,groups = "sdhi2_data4", "sdhi2_ctrl";
+               renesas,function = "sdhi2";
+       };
+
+       i2c2_pins: i2c2 {
+               renesas,groups = "i2c2";
+               renesas,function = "i2c2";
+       };
+
+       qspi_pins: spi0 {
+               renesas,groups = "qspi_ctrl", "qspi_data4";
+               renesas,function = "qspi";
+       };
+
+       msiof0_pins: spi1 {
+               renesas,groups = "msiof0_clk", "msiof0_sync", "msiof0_rx",
+                                "msiof0_tx";
+               renesas,function = "msiof0";
+       };
+
+       usb0_pins: usb0 {
+               renesas,groups = "usb0";
+               renesas,function = "usb0";
+       };
+
+       usb1_pins: usb1 {
+               renesas,groups = "usb1";
+               renesas,function = "usb1";
+       };
+
+       vin0_pins: vin0 {
+               renesas,groups = "vin0_data8", "vin0_clk";
+               renesas,function = "vin0";
+       };
+};
+
+&scif0 {
+       pinctrl-0 = <&scif0_pins>;
+       pinctrl-names = "default";
+
+       status = "okay";
+};
+
+&ether {
+       pinctrl-0 = <&ether_pins &phy1_pins>;
+       pinctrl-names = "default";
+
+       phy-handle = <&phy1>;
+       renesas,ether-link-active-low;
+       status = "ok";
+
+       phy1: ethernet-phy@1 {
+               reg = <1>;
+               interrupt-parent = <&irqc0>;
+               interrupts = <0 IRQ_TYPE_LEVEL_LOW>;
+               micrel,led-mode = <1>;
+       };
+};
+
+&sata0 {
+       status = "okay";
+};
+
+&sdhi0 {
+       pinctrl-0 = <&sdhi0_pins>;
+       pinctrl-names = "default";
+
+       vmmc-supply = <&vcc_sdhi0>;
+       vqmmc-supply = <&vccq_sdhi0>;
+       cd-gpios = <&gpio6 6 GPIO_ACTIVE_LOW>;
+       wp-gpios = <&gpio6 7 GPIO_ACTIVE_HIGH>;
+       status = "okay";
+};
+
+&sdhi2 {
+       pinctrl-0 = <&sdhi2_pins>;
+       pinctrl-names = "default";
+
+       vmmc-supply = <&vcc_sdhi2>;
+       vqmmc-supply = <&vccq_sdhi2>;
+       cd-gpios = <&gpio6 22 GPIO_ACTIVE_LOW>;
+       status = "okay";
+};
+
+&i2c2 {
+       pinctrl-0 = <&i2c2_pins>;
+       pinctrl-names = "default";
+
+       status = "okay";
+       clock-frequency = <400000>;
+
+       composite-in@20 {
+               compatible = "adi,adv7180";
+               reg = <0x20>;
+               remote = <&vin0>;
+
+               port {
+                       adv7180: endpoint {
+                               bus-width = <8>;
+                               remote-endpoint = <&vin0ep>;
+                       };
+               };
+       };
+};
+
+&qspi {
+       pinctrl-0 = <&qspi_pins>;
+       pinctrl-names = "default";
+
+       status = "okay";
+
+       flash@0 {
+               #address-cells = <1>;
+               #size-cells = <1>;
+               compatible = "spansion,s25fl512s";
+               reg = <0>;
+               spi-max-frequency = <30000000>;
+               spi-tx-bus-width = <4>;
+               spi-rx-bus-width = <4>;
+               m25p,fast-read;
+
+               partition@0 {
+                       label = "loader_prg";
+                       reg = <0x00000000 0x00040000>;
+                       read-only;
+               };
+               partition@40000 {
+                       label = "user_prg";
+                       reg = <0x00040000 0x00400000>;
+                       read-only;
+               };
+               partition@440000 {
+                       label = "flash_fs";
+                       reg = <0x00440000 0x03bc0000>;
+               };
+       };
+};
+
+&msiof0 {
+       pinctrl-0 = <&msiof0_pins>;
+       pinctrl-names = "default";
+
+       status = "okay";
+
+       pmic@0 {
+               compatible = "renesas,r2a11302ft";
+               reg = <0>;
+               spi-max-frequency = <6000000>;
+               spi-cpol;
+               spi-cpha;
+       };
+};
+
+&pci0 {
+       status = "okay";
+       pinctrl-0 = <&usb0_pins>;
+       pinctrl-names = "default";
+};
+
+&pci1 {
+       status = "okay";
+       pinctrl-0 = <&usb1_pins>;
+       pinctrl-names = "default";
+};
+
+&pcie_bus_clk {
+       status = "okay";
+};
+
+&pciec {
+       status = "okay";
+};
+
+/* composite video input */
+&vin0 {
+       status = "ok";
+       pinctrl-0 = <&vin0_pins>;
+       pinctrl-names = "default";
+
+       port {
+               #address-cells = <1>;
+               #size-cells = <0>;
+
+               vin0ep: endpoint {
+                       remote-endpoint = <&adv7180>;
+                       bus-width = <8>;
+               };
+       };
+};
diff --git a/arch/arm/boot/dts/r8a7791-koelsch-reference.dts b/arch/arm/boot/dts/r8a7791-koelsch-reference.dts
deleted file mode 100644 (file)
index 588ca17..0000000
+++ /dev/null
@@ -1,115 +0,0 @@
-/*
- * Device Tree Source for the Koelsch board
- *
- * Copyright (C) 2013 Renesas Electronics Corporation
- * Copyright (C) 2013 Renesas Solutions Corp.
- *
- * 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.
- */
-
-/dts-v1/;
-#include "r8a7791.dtsi"
-#include <dt-bindings/gpio/gpio.h>
-
-/ {
-       model = "Koelsch";
-       compatible = "renesas,koelsch-reference", "renesas,r8a7791";
-
-       chosen {
-               bootargs = "console=ttySC6,115200 ignore_loglevel rw root=/dev/nfs ip=dhcp";
-       };
-
-       memory@40000000 {
-               device_type = "memory";
-               reg = <0 0x40000000 0 0x80000000>;
-       };
-
-       lbsc {
-               #address-cells = <1>;
-               #size-cells = <1>;
-       };
-
-       gpio-keys {
-               compatible = "gpio-keys";
-
-               key-a {
-                       gpios = <&gpio7 0 GPIO_ACTIVE_LOW>;
-                       linux,code = <30>;
-                       label = "SW30";
-                       gpio-key,wakeup;
-                       debounce-interval = <20>;
-               };
-               key-b {
-                       gpios = <&gpio7 1 GPIO_ACTIVE_LOW>;
-                       linux,code = <48>;
-                       label = "SW31";
-                       gpio-key,wakeup;
-                       debounce-interval = <20>;
-               };
-               key-c {
-                       gpios = <&gpio7 2 GPIO_ACTIVE_LOW>;
-                       linux,code = <46>;
-                       label = "SW32";
-                       gpio-key,wakeup;
-                       debounce-interval = <20>;
-               };
-               key-d {
-                       gpios = <&gpio7 3 GPIO_ACTIVE_LOW>;
-                       linux,code = <32>;
-                       label = "SW33";
-                       gpio-key,wakeup;
-                       debounce-interval = <20>;
-               };
-               key-e {
-                       gpios = <&gpio7 4 GPIO_ACTIVE_LOW>;
-                       linux,code = <18>;
-                       label = "SW34";
-                       gpio-key,wakeup;
-                       debounce-interval = <20>;
-               };
-               key-f {
-                       gpios = <&gpio7 5 GPIO_ACTIVE_LOW>;
-                       linux,code = <33>;
-                       label = "SW35";
-                       gpio-key,wakeup;
-                       debounce-interval = <20>;
-               };
-               key-g {
-                       gpios = <&gpio7 6 GPIO_ACTIVE_LOW>;
-                       linux,code = <34>;
-                       label = "SW36";
-                       gpio-key,wakeup;
-                       debounce-interval = <20>;
-               };
-       };
-
-       leds {
-               compatible = "gpio-leds";
-               led6 {
-                       gpios = <&gpio2 19 GPIO_ACTIVE_HIGH>;
-               };
-               led7 {
-                       gpios = <&gpio2 20 GPIO_ACTIVE_HIGH>;
-               };
-               led8 {
-                       gpios = <&gpio2 21 GPIO_ACTIVE_HIGH>;
-               };
-       };
-};
-
-&pfc {
-       pinctrl-0 = <&scif0_pins &scif1_pins>;
-       pinctrl-names = "default";
-
-       scif0_pins: serial0 {
-               renesas,groups = "scif0_data_d";
-               renesas,function = "scif0";
-       };
-
-       scif1_pins: serial1 {
-               renesas,groups = "scif1_data_d";
-               renesas,function = "scif1";
-       };
-};
index fd556c3..07550e7 100644 (file)
@@ -2,7 +2,8 @@
  * Device Tree Source for the Koelsch board
  *
  * Copyright (C) 2013 Renesas Electronics Corporation
- * Copyright (C) 2013 Renesas Solutions Corp.
+ * Copyright (C) 2013-2014 Renesas Solutions Corp.
+ * Copyright (C) 2014 Cogent Embedded, Inc.
  *
  * 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
 /dts-v1/;
 #include "r8a7791.dtsi"
 #include <dt-bindings/gpio/gpio.h>
+#include <dt-bindings/input/input.h>
 
 / {
        model = "Koelsch";
        compatible = "renesas,koelsch", "renesas,r8a7791";
 
+       aliases {
+               serial6 = &scif0;
+               serial7 = &scif1;
+       };
+
        chosen {
                bootargs = "console=ttySC6,115200 ignore_loglevel rw root=/dev/nfs ip=dhcp";
        };
 
        memory@40000000 {
                device_type = "memory";
-               reg = <0 0x40000000 0 0x80000000>;
+               reg = <0 0x40000000 0 0x40000000>;
+       };
+
+       memory@200000000 {
+               device_type = "memory";
+               reg = <2 0x00000000 0 0x40000000>;
        };
 
        lbsc {
                #size-cells = <1>;
        };
 
+       gpio-keys {
+               compatible = "gpio-keys";
+
+               key-1 {
+                       gpios = <&gpio5 0 GPIO_ACTIVE_LOW>;
+                       linux,code = <KEY_1>;
+                       label = "SW2-1";
+                       gpio-key,wakeup;
+                       debounce-interval = <20>;
+               };
+               key-2 {
+                       gpios = <&gpio5 1 GPIO_ACTIVE_LOW>;
+                       linux,code = <KEY_2>;
+                       label = "SW2-2";
+                       gpio-key,wakeup;
+                       debounce-interval = <20>;
+               };
+               key-3 {
+                       gpios = <&gpio5 2 GPIO_ACTIVE_LOW>;
+                       linux,code = <KEY_3>;
+                       label = "SW2-3";
+                       gpio-key,wakeup;
+                       debounce-interval = <20>;
+               };
+               key-4 {
+                       gpios = <&gpio5 3 GPIO_ACTIVE_LOW>;
+                       linux,code = <KEY_4>;
+                       label = "SW2-4";
+                       gpio-key,wakeup;
+                       debounce-interval = <20>;
+               };
+               key-a {
+                       gpios = <&gpio7 0 GPIO_ACTIVE_LOW>;
+                       linux,code = <KEY_A>;
+                       label = "SW30";
+                       gpio-key,wakeup;
+                       debounce-interval = <20>;
+               };
+               key-b {
+                       gpios = <&gpio7 1 GPIO_ACTIVE_LOW>;
+                       linux,code = <KEY_B>;
+                       label = "SW31";
+                       gpio-key,wakeup;
+                       debounce-interval = <20>;
+               };
+               key-c {
+                       gpios = <&gpio7 2 GPIO_ACTIVE_LOW>;
+                       linux,code = <KEY_C>;
+                       label = "SW32";
+                       gpio-key,wakeup;
+                       debounce-interval = <20>;
+               };
+               key-d {
+                       gpios = <&gpio7 3 GPIO_ACTIVE_LOW>;
+                       linux,code = <KEY_D>;
+                       label = "SW33";
+                       gpio-key,wakeup;
+                       debounce-interval = <20>;
+               };
+               key-e {
+                       gpios = <&gpio7 4 GPIO_ACTIVE_LOW>;
+                       linux,code = <KEY_E>;
+                       label = "SW34";
+                       gpio-key,wakeup;
+                       debounce-interval = <20>;
+               };
+               key-f {
+                       gpios = <&gpio7 5 GPIO_ACTIVE_LOW>;
+                       linux,code = <KEY_F>;
+                       label = "SW35";
+                       gpio-key,wakeup;
+                       debounce-interval = <20>;
+               };
+               key-g {
+                       gpios = <&gpio7 6 GPIO_ACTIVE_LOW>;
+                       linux,code = <KEY_G>;
+                       label = "SW36";
+                       gpio-key,wakeup;
+                       debounce-interval = <20>;
+               };
+       };
+
        leds {
                compatible = "gpio-leds";
                led6 {
                        gpios = <&gpio2 21 GPIO_ACTIVE_HIGH>;
                };
        };
+
+       vcc_sdhi0: regulator@0 {
+               compatible = "regulator-fixed";
+
+               regulator-name = "SDHI0 Vcc";
+               regulator-min-microvolt = <3300000>;
+               regulator-max-microvolt = <3300000>;
+
+               gpio = <&gpio7 17 GPIO_ACTIVE_HIGH>;
+               enable-active-high;
+       };
+
+       vccq_sdhi0: regulator@1 {
+               compatible = "regulator-gpio";
+
+               regulator-name = "SDHI0 VccQ";
+               regulator-min-microvolt = <1800000>;
+               regulator-max-microvolt = <3300000>;
+
+               gpios = <&gpio2 12 GPIO_ACTIVE_HIGH>;
+               gpios-states = <1>;
+               states = <3300000 1
+                         1800000 0>;
+       };
+
+       vcc_sdhi1: regulator@2 {
+               compatible = "regulator-fixed";
+
+               regulator-name = "SDHI1 Vcc";
+               regulator-min-microvolt = <3300000>;
+               regulator-max-microvolt = <3300000>;
+
+               gpio = <&gpio7 18 GPIO_ACTIVE_HIGH>;
+               enable-active-high;
+       };
+
+       vccq_sdhi1: regulator@3 {
+               compatible = "regulator-gpio";
+
+               regulator-name = "SDHI1 VccQ";
+               regulator-min-microvolt = <1800000>;
+               regulator-max-microvolt = <3300000>;
+
+               gpios = <&gpio2 13 GPIO_ACTIVE_HIGH>;
+               gpios-states = <1>;
+               states = <3300000 1
+                         1800000 0>;
+       };
+
+       vcc_sdhi2: regulator@4 {
+               compatible = "regulator-fixed";
+
+               regulator-name = "SDHI2 Vcc";
+               regulator-min-microvolt = <3300000>;
+               regulator-max-microvolt = <3300000>;
+
+               gpio = <&gpio7 19 GPIO_ACTIVE_HIGH>;
+               enable-active-high;
+       };
+
+       vccq_sdhi2: regulator@5 {
+               compatible = "regulator-gpio";
+
+               regulator-name = "SDHI2 VccQ";
+               regulator-min-microvolt = <1800000>;
+               regulator-max-microvolt = <3300000>;
+
+               gpios = <&gpio2 26 GPIO_ACTIVE_HIGH>;
+               gpios-states = <1>;
+               states = <3300000 1
+                         1800000 0>;
+       };
 };
 
 &extal_clk {
 };
 
 &pfc {
-       pinctrl-0 = <&scif0_pins &scif1_pins>;
+       pinctrl-0 = <&du_pins>;
        pinctrl-names = "default";
 
+       i2c2_pins: i2c2 {
+               renesas,groups = "i2c2";
+               renesas,function = "i2c2";
+       };
+
+       du_pins: du {
+               renesas,groups = "du_rgb666", "du_sync", "du_clk_out_0";
+               renesas,function = "du";
+       };
+
        scif0_pins: serial0 {
                renesas,groups = "scif0_data_d";
                renesas,function = "scif0";
                renesas,groups = "scif1_data_d";
                renesas,function = "scif1";
        };
+
+       ether_pins: ether {
+               renesas,groups = "eth_link", "eth_mdio", "eth_rmii";
+               renesas,function = "eth";
+       };
+
+       phy1_pins: phy1 {
+               renesas,groups = "intc_irq0";
+               renesas,function = "intc";
+       };
+
+       sdhi0_pins: sd0 {
+               renesas,groups = "sdhi0_data4", "sdhi0_ctrl";
+               renesas,function = "sdhi0";
+       };
+
+       sdhi1_pins: sd1 {
+               renesas,groups = "sdhi1_data4", "sdhi1_ctrl";
+               renesas,function = "sdhi1";
+       };
+
+       sdhi2_pins: sd2 {
+               renesas,groups = "sdhi2_data4", "sdhi2_ctrl";
+               renesas,function = "sdhi2";
+       };
+
+       qspi_pins: spi0 {
+               renesas,groups = "qspi_ctrl", "qspi_data4";
+               renesas,function = "qspi";
+       };
+
+       msiof0_pins: spi1 {
+               renesas,groups = "msiof0_clk", "msiof0_sync", "msiof0_rx",
+                                "msiof0_tx";
+               renesas,function = "msiof0";
+       };
+
+       usb0_pins: usb0 {
+               renesas,groups = "usb0";
+               renesas,function = "usb0";
+       };
+
+       usb1_pins: usb1 {
+               renesas,groups = "usb1";
+               renesas,function = "usb1";
+       };
+
+       vin1_pins: vin1 {
+               renesas,groups = "vin1_data8", "vin1_clk";
+               renesas,function = "vin1";
+       };
+};
+
+&ether {
+       pinctrl-0 = <&ether_pins &phy1_pins>;
+       pinctrl-names = "default";
+
+       phy-handle = <&phy1>;
+       renesas,ether-link-active-low;
+       status = "ok";
+
+       phy1: ethernet-phy@1 {
+               reg = <1>;
+               interrupt-parent = <&irqc0>;
+               interrupts = <0 IRQ_TYPE_LEVEL_LOW>;
+               micrel,led-mode = <1>;
+       };
+};
+
+&cmt0 {
+       status = "ok";
+};
+
+&sata0 {
+       status = "okay";
+};
+
+&scif0 {
+       pinctrl-0 = <&scif0_pins>;
+       pinctrl-names = "default";
+
+       status = "okay";
+};
+
+&scif1 {
+       pinctrl-0 = <&scif1_pins>;
+       pinctrl-names = "default";
+
+       status = "okay";
+};
+
+&sdhi0 {
+       pinctrl-0 = <&sdhi0_pins>;
+       pinctrl-names = "default";
+
+       vmmc-supply = <&vcc_sdhi0>;
+       vqmmc-supply = <&vccq_sdhi0>;
+       cd-gpios = <&gpio6 6 GPIO_ACTIVE_LOW>;
+       wp-gpios = <&gpio6 7 GPIO_ACTIVE_HIGH>;
+       status = "okay";
+};
+
+&sdhi1 {
+       pinctrl-0 = <&sdhi1_pins>;
+       pinctrl-names = "default";
+
+       vmmc-supply = <&vcc_sdhi1>;
+       vqmmc-supply = <&vccq_sdhi1>;
+       cd-gpios = <&gpio6 14 GPIO_ACTIVE_LOW>;
+       wp-gpios = <&gpio6 15 GPIO_ACTIVE_HIGH>;
+       status = "okay";
+};
+
+&sdhi2 {
+       pinctrl-0 = <&sdhi2_pins>;
+       pinctrl-names = "default";
+
+       vmmc-supply = <&vcc_sdhi2>;
+       vqmmc-supply = <&vccq_sdhi2>;
+       cd-gpios = <&gpio6 22 GPIO_ACTIVE_LOW>;
+       status = "okay";
+};
+
+&qspi {
+       pinctrl-0 = <&qspi_pins>;
+       pinctrl-names = "default";
+
+       status = "okay";
+
+       flash: flash@0 {
+               #address-cells = <1>;
+               #size-cells = <1>;
+               compatible = "spansion,s25fl512s";
+               reg = <0>;
+               spi-max-frequency = <30000000>;
+               spi-tx-bus-width = <4>;
+               spi-rx-bus-width = <4>;
+               m25p,fast-read;
+
+               partition@0 {
+                       label = "loader";
+                       reg = <0x00000000 0x00080000>;
+                       read-only;
+               };
+               partition@80000 {
+                       label = "bootenv";
+                       reg = <0x00080000 0x00080000>;
+                       read-only;
+               };
+               partition@100000 {
+                       label = "data";
+                       reg = <0x00100000 0x03f00000>;
+               };
+       };
+};
+
+&msiof0 {
+       pinctrl-0 = <&msiof0_pins>;
+       pinctrl-names = "default";
+
+       status = "okay";
+
+       pmic: pmic@0 {
+               compatible = "renesas,r2a11302ft";
+               reg = <0>;
+               spi-max-frequency = <6000000>;
+               spi-cpol;
+               spi-cpha;
+       };
+};
+
+&i2c2 {
+       pinctrl-0 = <&i2c2_pins>;
+       pinctrl-names = "default";
+
+       status = "okay";
+       clock-frequency = <400000>;
+
+       composite-in@20 {
+               compatible = "adi,adv7180";
+               reg = <0x20>;
+               remote = <&vin1>;
+
+               port {
+                       adv7180: endpoint {
+                               bus-width = <8>;
+                               remote-endpoint = <&vin1ep>;
+                       };
+               };
+       };
+
+       eeprom@50 {
+               compatible = "renesas,24c02";
+               reg = <0x50>;
+               pagesize = <16>;
+       };
+};
+
+&i2c6 {
+       status = "okay";
+       clock-frequency = <100000>;
+
+       vdd_dvfs: regulator@68 {
+               compatible = "dlg,da9210";
+               reg = <0x68>;
+
+               regulator-min-microvolt = <1000000>;
+               regulator-max-microvolt = <1000000>;
+               regulator-boot-on;
+               regulator-always-on;
+       };
+};
+
+&pci0 {
+       status = "okay";
+       pinctrl-0 = <&usb0_pins>;
+       pinctrl-names = "default";
+};
+
+&pci1 {
+       status = "okay";
+       pinctrl-0 = <&usb1_pins>;
+       pinctrl-names = "default";
+};
+
+&pcie_bus_clk {
+       status = "okay";
+};
+
+&pciec {
+       status = "okay";
+};
+
+&cpu0 {
+       cpu0-supply = <&vdd_dvfs>;
+};
+
+/* composite video input */
+&vin1 {
+       status = "ok";
+       pinctrl-0 = <&vin1_pins>;
+       pinctrl-names = "default";
+
+       port {
+               #address-cells = <1>;
+               #size-cells = <0>;
+
+               vin1ep: endpoint {
+                       remote-endpoint = <&adv7180>;
+                       bus-width = <8>;
+               };
+       };
 };
index 19c6550..e06c11f 100644 (file)
@@ -2,7 +2,8 @@
  * Device Tree Source for the r8a7791 SoC
  *
  * Copyright (C) 2013 Renesas Electronics Corporation
- * Copyright (C) 2013 Renesas Solutions Corp.
+ * Copyright (C) 2013-2014 Renesas Solutions Corp.
+ * Copyright (C) 2014 Cogent Embedded Inc.
  *
  * 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
        #address-cells = <2>;
        #size-cells = <2>;
 
+       aliases {
+               i2c0 = &i2c0;
+               i2c1 = &i2c1;
+               i2c2 = &i2c2;
+               i2c3 = &i2c3;
+               i2c4 = &i2c4;
+               i2c5 = &i2c5;
+               i2c6 = &i2c6;
+               i2c7 = &i2c7;
+               i2c8 = &i2c8;
+               spi0 = &qspi;
+               spi1 = &msiof0;
+               spi2 = &msiof1;
+               spi3 = &msiof2;
+               vin0 = &vin0;
+               vin1 = &vin1;
+               vin2 = &vin2;
+       };
+
        cpus {
                #address-cells = <1>;
                #size-cells = <0>;
                        device_type = "cpu";
                        compatible = "arm,cortex-a15";
                        reg = <0>;
-                       clock-frequency = <1300000000>;
+                       clock-frequency = <1500000000>;
+                       voltage-tolerance = <1>; /* 1% */
+                       clocks = <&cpg_clocks R8A7791_CLK_Z>;
+                       clock-latency = <300000>; /* 300 us */
+
+                       /* kHz - uV - OPPs unknown yet */
+                       operating-points = <1500000 1000000>,
+                                          <1312500 1000000>,
+                                          <1125000 1000000>,
+                                          < 937500 1000000>,
+                                          < 750000 1000000>,
+                                          < 375000 1000000>;
                };
 
                cpu1: cpu@1 {
                        device_type = "cpu";
                        compatible = "arm,cortex-a15";
                        reg = <1>;
-                       clock-frequency = <1300000000>;
+                       clock-frequency = <1500000000>;
                };
        };
 
        gpio0: gpio@e6050000 {
                compatible = "renesas,gpio-r8a7791", "renesas,gpio-rcar";
                reg = <0 0xe6050000 0 0x50>;
-               interrupt-parent = <&gic>;
                interrupts = <0 4 IRQ_TYPE_LEVEL_HIGH>;
                #gpio-cells = <2>;
                gpio-controller;
                gpio-ranges = <&pfc 0 0 32>;
                #interrupt-cells = <2>;
                interrupt-controller;
+               clocks = <&mstp9_clks R8A7791_CLK_GPIO0>;
        };
 
        gpio1: gpio@e6051000 {
                compatible = "renesas,gpio-r8a7791", "renesas,gpio-rcar";
                reg = <0 0xe6051000 0 0x50>;
-               interrupt-parent = <&gic>;
                interrupts = <0 5 IRQ_TYPE_LEVEL_HIGH>;
                #gpio-cells = <2>;
                gpio-controller;
                gpio-ranges = <&pfc 0 32 32>;
                #interrupt-cells = <2>;
                interrupt-controller;
+               clocks = <&mstp9_clks R8A7791_CLK_GPIO1>;
        };
 
        gpio2: gpio@e6052000 {
                compatible = "renesas,gpio-r8a7791", "renesas,gpio-rcar";
                reg = <0 0xe6052000 0 0x50>;
-               interrupt-parent = <&gic>;
                interrupts = <0 6 IRQ_TYPE_LEVEL_HIGH>;
                #gpio-cells = <2>;
                gpio-controller;
                gpio-ranges = <&pfc 0 64 32>;
                #interrupt-cells = <2>;
                interrupt-controller;
+               clocks = <&mstp9_clks R8A7791_CLK_GPIO2>;
        };
 
        gpio3: gpio@e6053000 {
                compatible = "renesas,gpio-r8a7791", "renesas,gpio-rcar";
                reg = <0 0xe6053000 0 0x50>;
-               interrupt-parent = <&gic>;
                interrupts = <0 7 IRQ_TYPE_LEVEL_HIGH>;
                #gpio-cells = <2>;
                gpio-controller;
                gpio-ranges = <&pfc 0 96 32>;
                #interrupt-cells = <2>;
                interrupt-controller;
+               clocks = <&mstp9_clks R8A7791_CLK_GPIO3>;
        };
 
        gpio4: gpio@e6054000 {
                compatible = "renesas,gpio-r8a7791", "renesas,gpio-rcar";
                reg = <0 0xe6054000 0 0x50>;
-               interrupt-parent = <&gic>;
                interrupts = <0 8 IRQ_TYPE_LEVEL_HIGH>;
                #gpio-cells = <2>;
                gpio-controller;
                gpio-ranges = <&pfc 0 128 32>;
                #interrupt-cells = <2>;
                interrupt-controller;
+               clocks = <&mstp9_clks R8A7791_CLK_GPIO4>;
        };
 
        gpio5: gpio@e6055000 {
                compatible = "renesas,gpio-r8a7791", "renesas,gpio-rcar";
                reg = <0 0xe6055000 0 0x50>;
-               interrupt-parent = <&gic>;
                interrupts = <0 9 IRQ_TYPE_LEVEL_HIGH>;
                #gpio-cells = <2>;
                gpio-controller;
                gpio-ranges = <&pfc 0 160 32>;
                #interrupt-cells = <2>;
                interrupt-controller;
+               clocks = <&mstp9_clks R8A7791_CLK_GPIO5>;
        };
 
        gpio6: gpio@e6055400 {
                compatible = "renesas,gpio-r8a7791", "renesas,gpio-rcar";
                reg = <0 0xe6055400 0 0x50>;
-               interrupt-parent = <&gic>;
                interrupts = <0 10 IRQ_TYPE_LEVEL_HIGH>;
                #gpio-cells = <2>;
                gpio-controller;
                gpio-ranges = <&pfc 0 192 32>;
                #interrupt-cells = <2>;
                interrupt-controller;
+               clocks = <&mstp9_clks R8A7791_CLK_GPIO6>;
        };
 
        gpio7: gpio@e6055800 {
                compatible = "renesas,gpio-r8a7791", "renesas,gpio-rcar";
                reg = <0 0xe6055800 0 0x50>;
-               interrupt-parent = <&gic>;
                interrupts = <0 11 IRQ_TYPE_LEVEL_HIGH>;
                #gpio-cells = <2>;
                gpio-controller;
                gpio-ranges = <&pfc 0 224 26>;
                #interrupt-cells = <2>;
                interrupt-controller;
+               clocks = <&mstp9_clks R8A7791_CLK_GPIO7>;
        };
 
        thermal@e61f0000 {
                compatible = "renesas,thermal-r8a7791", "renesas,rcar-thermal";
                reg = <0 0xe61f0000 0 0x14>, <0 0xe61f0100 0 0x38>;
-               interrupt-parent = <&gic>;
                interrupts = <0 69 IRQ_TYPE_LEVEL_HIGH>;
+               clocks = <&mstp5_clks R8A7791_CLK_THERMAL>;
        };
 
        timer {
                             <1 10 (GIC_CPU_MASK_SIMPLE(4) | IRQ_TYPE_LEVEL_LOW)>;
        };
 
+       cmt0: timer@ffca0000 {
+               compatible = "renesas,cmt-48-r8a7791", "renesas,cmt-48-gen2";
+               reg = <0 0xffca0000 0 0x1004>;
+               interrupts = <0 142 IRQ_TYPE_LEVEL_HIGH>,
+                            <0 143 IRQ_TYPE_LEVEL_HIGH>;
+               clocks = <&mstp1_clks R8A7791_CLK_CMT0>;
+               clock-names = "fck";
+
+               renesas,channels-mask = <0x60>;
+
+               status = "disabled";
+       };
+
+       cmt1: timer@e6130000 {
+               compatible = "renesas,cmt-48-r8a7791", "renesas,cmt-48-gen2";
+               reg = <0 0xe6130000 0 0x1004>;
+               interrupts = <0 120 IRQ_TYPE_LEVEL_HIGH>,
+                            <0 121 IRQ_TYPE_LEVEL_HIGH>,
+                            <0 122 IRQ_TYPE_LEVEL_HIGH>,
+                            <0 123 IRQ_TYPE_LEVEL_HIGH>,
+                            <0 124 IRQ_TYPE_LEVEL_HIGH>,
+                            <0 125 IRQ_TYPE_LEVEL_HIGH>,
+                            <0 126 IRQ_TYPE_LEVEL_HIGH>,
+                            <0 127 IRQ_TYPE_LEVEL_HIGH>;
+               clocks = <&mstp3_clks R8A7791_CLK_CMT1>;
+               clock-names = "fck";
+
+               renesas,channels-mask = <0xff>;
+
+               status = "disabled";
+       };
+
        irqc0: interrupt-controller@e61c0000 {
                compatible = "renesas,irqc-r8a7791", "renesas,irqc";
                #interrupt-cells = <2>;
                interrupt-controller;
                reg = <0 0xe61c0000 0 0x200>;
-               interrupt-parent = <&gic>;
                interrupts = <0 0 IRQ_TYPE_LEVEL_HIGH>,
                             <0 1 IRQ_TYPE_LEVEL_HIGH>,
                             <0 2 IRQ_TYPE_LEVEL_HIGH>,
                             <0 17 IRQ_TYPE_LEVEL_HIGH>;
        };
 
+       dmac0: dma-controller@e6700000 {
+               compatible = "renesas,rcar-dmac";
+               reg = <0 0xe6700000 0 0x20000>;
+               interrupts = <0 197 IRQ_TYPE_LEVEL_HIGH
+                             0 200 IRQ_TYPE_LEVEL_HIGH
+                             0 201 IRQ_TYPE_LEVEL_HIGH
+                             0 202 IRQ_TYPE_LEVEL_HIGH
+                             0 203 IRQ_TYPE_LEVEL_HIGH
+                             0 204 IRQ_TYPE_LEVEL_HIGH
+                             0 205 IRQ_TYPE_LEVEL_HIGH
+                             0 206 IRQ_TYPE_LEVEL_HIGH
+                             0 207 IRQ_TYPE_LEVEL_HIGH
+                             0 208 IRQ_TYPE_LEVEL_HIGH
+                             0 209 IRQ_TYPE_LEVEL_HIGH
+                             0 210 IRQ_TYPE_LEVEL_HIGH
+                             0 211 IRQ_TYPE_LEVEL_HIGH
+                             0 212 IRQ_TYPE_LEVEL_HIGH
+                             0 213 IRQ_TYPE_LEVEL_HIGH
+                             0 214 IRQ_TYPE_LEVEL_HIGH>;
+               interrupt-names = "error",
+                               "ch0", "ch1", "ch2", "ch3",
+                               "ch4", "ch5", "ch6", "ch7",
+                               "ch8", "ch9", "ch10", "ch11",
+                               "ch12", "ch13", "ch14";
+               clocks = <&mstp2_clks R8A7791_CLK_SYS_DMAC0>;
+               clock-names = "fck";
+               #dma-cells = <1>;
+               dma-channels = <15>;
+       };
+
+       dmac1: dma-controller@e6720000 {
+               compatible = "renesas,rcar-dmac";
+               reg = <0 0xe6720000 0 0x20000>;
+               interrupts = <0 220 IRQ_TYPE_LEVEL_HIGH
+                             0 216 IRQ_TYPE_LEVEL_HIGH
+                             0 217 IRQ_TYPE_LEVEL_HIGH
+                             0 218 IRQ_TYPE_LEVEL_HIGH
+                             0 219 IRQ_TYPE_LEVEL_HIGH
+                             0 308 IRQ_TYPE_LEVEL_HIGH
+                             0 309 IRQ_TYPE_LEVEL_HIGH
+                             0 310 IRQ_TYPE_LEVEL_HIGH
+                             0 311 IRQ_TYPE_LEVEL_HIGH
+                             0 312 IRQ_TYPE_LEVEL_HIGH
+                             0 313 IRQ_TYPE_LEVEL_HIGH
+                             0 314 IRQ_TYPE_LEVEL_HIGH
+                             0 315 IRQ_TYPE_LEVEL_HIGH
+                             0 316 IRQ_TYPE_LEVEL_HIGH
+                             0 317 IRQ_TYPE_LEVEL_HIGH
+                             0 318 IRQ_TYPE_LEVEL_HIGH>;
+               interrupt-names = "error",
+                               "ch0", "ch1", "ch2", "ch3",
+                               "ch4", "ch5", "ch6", "ch7",
+                               "ch8", "ch9", "ch10", "ch11",
+                               "ch12", "ch13", "ch14";
+               clocks = <&mstp2_clks R8A7791_CLK_SYS_DMAC1>;
+               clock-names = "fck";
+               #dma-cells = <1>;
+               dma-channels = <15>;
+       };
+
+       /* The memory map in the User's Manual maps the cores to bus numbers */
+       i2c0: i2c@e6508000 {
+               #address-cells = <1>;
+               #size-cells = <0>;
+               compatible = "renesas,i2c-r8a7791";
+               reg = <0 0xe6508000 0 0x40>;
+               interrupts = <0 287 IRQ_TYPE_LEVEL_HIGH>;
+               clocks = <&mstp9_clks R8A7791_CLK_I2C0>;
+               status = "disabled";
+       };
+
+       i2c1: i2c@e6518000 {
+               #address-cells = <1>;
+               #size-cells = <0>;
+               compatible = "renesas,i2c-r8a7791";
+               reg = <0 0xe6518000 0 0x40>;
+               interrupts = <0 288 IRQ_TYPE_LEVEL_HIGH>;
+               clocks = <&mstp9_clks R8A7791_CLK_I2C1>;
+               status = "disabled";
+       };
+
+       i2c2: i2c@e6530000 {
+               #address-cells = <1>;
+               #size-cells = <0>;
+               compatible = "renesas,i2c-r8a7791";
+               reg = <0 0xe6530000 0 0x40>;
+               interrupts = <0 286 IRQ_TYPE_LEVEL_HIGH>;
+               clocks = <&mstp9_clks R8A7791_CLK_I2C2>;
+               status = "disabled";
+       };
+
+       i2c3: i2c@e6540000 {
+               #address-cells = <1>;
+               #size-cells = <0>;
+               compatible = "renesas,i2c-r8a7791";
+               reg = <0 0xe6540000 0 0x40>;
+               interrupts = <0 290 IRQ_TYPE_LEVEL_HIGH>;
+               clocks = <&mstp9_clks R8A7791_CLK_I2C3>;
+               status = "disabled";
+       };
+
+       i2c4: i2c@e6520000 {
+               #address-cells = <1>;
+               #size-cells = <0>;
+               compatible = "renesas,i2c-r8a7791";
+               reg = <0 0xe6520000 0 0x40>;
+               interrupts = <0 19 IRQ_TYPE_LEVEL_HIGH>;
+               clocks = <&mstp9_clks R8A7791_CLK_I2C4>;
+               status = "disabled";
+       };
+
+       i2c5: i2c@e6528000 {
+               /* doesn't need pinmux */
+               #address-cells = <1>;
+               #size-cells = <0>;
+               compatible = "renesas,i2c-r8a7791";
+               reg = <0 0xe6528000 0 0x40>;
+               interrupts = <0 20 IRQ_TYPE_LEVEL_HIGH>;
+               clocks = <&mstp9_clks R8A7791_CLK_I2C5>;
+               status = "disabled";
+       };
+
+       i2c6: i2c@e60b0000 {
+               /* doesn't need pinmux */
+               #address-cells = <1>;
+               #size-cells = <0>;
+               compatible = "renesas,iic-r8a7791", "renesas,rmobile-iic";
+               reg = <0 0xe60b0000 0 0x425>;
+               interrupts = <0 173 IRQ_TYPE_LEVEL_HIGH>;
+               clocks = <&mstp9_clks R8A7791_CLK_IICDVFS>;
+               status = "disabled";
+       };
+
+       i2c7: i2c@e6500000 {
+               #address-cells = <1>;
+               #size-cells = <0>;
+               compatible = "renesas,iic-r8a7791", "renesas,rmobile-iic";
+               reg = <0 0xe6500000 0 0x425>;
+               interrupts = <0 174 IRQ_TYPE_LEVEL_HIGH>;
+               clocks = <&mstp3_clks R8A7791_CLK_IIC0>;
+               status = "disabled";
+       };
+
+       i2c8: i2c@e6510000 {
+               #address-cells = <1>;
+               #size-cells = <0>;
+               compatible = "renesas,iic-r8a7791", "renesas,rmobile-iic";
+               reg = <0 0xe6510000 0 0x425>;
+               interrupts = <0 175 IRQ_TYPE_LEVEL_HIGH>;
+               clocks = <&mstp3_clks R8A7791_CLK_IIC1>;
+               status = "disabled";
+       };
+
        pfc: pfc@e6060000 {
                compatible = "renesas,pfc-r8a7791";
                reg = <0 0xe6060000 0 0x250>;
                #gpio-range-cells = <3>;
        };
 
+       sdhi0: sd@ee100000 {
+               compatible = "renesas,sdhi-r8a7791";
+               reg = <0 0xee100000 0 0x200>;
+               interrupts = <0 165 IRQ_TYPE_LEVEL_HIGH>;
+               clocks = <&mstp3_clks R8A7791_CLK_SDHI0>;
+               status = "disabled";
+       };
+
+       sdhi1: sd@ee140000 {
+               compatible = "renesas,sdhi-r8a7791";
+               reg = <0 0xee140000 0 0x100>;
+               interrupts = <0 167 IRQ_TYPE_LEVEL_HIGH>;
+               clocks = <&mstp3_clks R8A7791_CLK_SDHI1>;
+               status = "disabled";
+       };
+
+       sdhi2: sd@ee160000 {
+               compatible = "renesas,sdhi-r8a7791";
+               reg = <0 0xee160000 0 0x100>;
+               interrupts = <0 168 IRQ_TYPE_LEVEL_HIGH>;
+               clocks = <&mstp3_clks R8A7791_CLK_SDHI2>;
+               status = "disabled";
+       };
+
+       scifa0: serial@e6c40000 {
+               compatible = "renesas,scifa-r8a7791", "renesas,scifa";
+               reg = <0 0xe6c40000 0 64>;
+               interrupts = <0 144 IRQ_TYPE_LEVEL_HIGH>;
+               clocks = <&mstp2_clks R8A7791_CLK_SCIFA0>;
+               clock-names = "sci_ick";
+               status = "disabled";
+       };
+
+       scifa1: serial@e6c50000 {
+               compatible = "renesas,scifa-r8a7791", "renesas,scifa";
+               reg = <0 0xe6c50000 0 64>;
+               interrupts = <0 145 IRQ_TYPE_LEVEL_HIGH>;
+               clocks = <&mstp2_clks R8A7791_CLK_SCIFA1>;
+               clock-names = "sci_ick";
+               status = "disabled";
+       };
+
+       scifa2: serial@e6c60000 {
+               compatible = "renesas,scifa-r8a7791", "renesas,scifa";
+               reg = <0 0xe6c60000 0 64>;
+               interrupts = <0 151 IRQ_TYPE_LEVEL_HIGH>;
+               clocks = <&mstp2_clks R8A7791_CLK_SCIFA2>;
+               clock-names = "sci_ick";
+               status = "disabled";
+       };
+
+       scifa3: serial@e6c70000 {
+               compatible = "renesas,scifa-r8a7791", "renesas,scifa";
+               reg = <0 0xe6c70000 0 64>;
+               interrupts = <0 29 IRQ_TYPE_LEVEL_HIGH>;
+               clocks = <&mstp11_clks R8A7791_CLK_SCIFA3>;
+               clock-names = "sci_ick";
+               status = "disabled";
+       };
+
+       scifa4: serial@e6c78000 {
+               compatible = "renesas,scifa-r8a7791", "renesas,scifa";
+               reg = <0 0xe6c78000 0 64>;
+               interrupts = <0 30 IRQ_TYPE_LEVEL_HIGH>;
+               clocks = <&mstp11_clks R8A7791_CLK_SCIFA4>;
+               clock-names = "sci_ick";
+               status = "disabled";
+       };
+
+       scifa5: serial@e6c80000 {
+               compatible = "renesas,scifa-r8a7791", "renesas,scifa";
+               reg = <0 0xe6c80000 0 64>;
+               interrupts = <0 31 IRQ_TYPE_LEVEL_HIGH>;
+               clocks = <&mstp11_clks R8A7791_CLK_SCIFA5>;
+               clock-names = "sci_ick";
+               status = "disabled";
+       };
+
+       scifb0: serial@e6c20000 {
+               compatible = "renesas,scifb-r8a7791", "renesas,scifb";
+               reg = <0 0xe6c20000 0 64>;
+               interrupts = <0 148 IRQ_TYPE_LEVEL_HIGH>;
+               clocks = <&mstp2_clks R8A7791_CLK_SCIFB0>;
+               clock-names = "sci_ick";
+               status = "disabled";
+       };
+
+       scifb1: serial@e6c30000 {
+               compatible = "renesas,scifb-r8a7791", "renesas,scifb";
+               reg = <0 0xe6c30000 0 64>;
+               interrupts = <0 149 IRQ_TYPE_LEVEL_HIGH>;
+               clocks = <&mstp2_clks R8A7791_CLK_SCIFB1>;
+               clock-names = "sci_ick";
+               status = "disabled";
+       };
+
+       scifb2: serial@e6ce0000 {
+               compatible = "renesas,scifb-r8a7791", "renesas,scifb";
+               reg = <0 0xe6ce0000 0 64>;
+               interrupts = <0 150 IRQ_TYPE_LEVEL_HIGH>;
+               clocks = <&mstp2_clks R8A7791_CLK_SCIFB2>;
+               clock-names = "sci_ick";
+               status = "disabled";
+       };
+
+       scif0: serial@e6e60000 {
+               compatible = "renesas,scif-r8a7791", "renesas,scif";
+               reg = <0 0xe6e60000 0 64>;
+               interrupts = <0 152 IRQ_TYPE_LEVEL_HIGH>;
+               clocks = <&mstp7_clks R8A7791_CLK_SCIF0>;
+               clock-names = "sci_ick";
+               status = "disabled";
+       };
+
+       scif1: serial@e6e68000 {
+               compatible = "renesas,scif-r8a7791", "renesas,scif";
+               reg = <0 0xe6e68000 0 64>;
+               interrupts = <0 153 IRQ_TYPE_LEVEL_HIGH>;
+               clocks = <&mstp7_clks R8A7791_CLK_SCIF1>;
+               clock-names = "sci_ick";
+               status = "disabled";
+       };
+
+       scif2: serial@e6e58000 {
+               compatible = "renesas,scif-r8a7791", "renesas,scif";
+               reg = <0 0xe6e58000 0 64>;
+               interrupts = <0 22 IRQ_TYPE_LEVEL_HIGH>;
+               clocks = <&mstp7_clks R8A7791_CLK_SCIF2>;
+               clock-names = "sci_ick";
+               status = "disabled";
+       };
+
+       scif3: serial@e6ea8000 {
+               compatible = "renesas,scif-r8a7791", "renesas,scif";
+               reg = <0 0xe6ea8000 0 64>;
+               interrupts = <0 23 IRQ_TYPE_LEVEL_HIGH>;
+               clocks = <&mstp7_clks R8A7791_CLK_SCIF3>;
+               clock-names = "sci_ick";
+               status = "disabled";
+       };
+
+       scif4: serial@e6ee0000 {
+               compatible = "renesas,scif-r8a7791", "renesas,scif";
+               reg = <0 0xe6ee0000 0 64>;
+               interrupts = <0 24 IRQ_TYPE_LEVEL_HIGH>;
+               clocks = <&mstp7_clks R8A7791_CLK_SCIF4>;
+               clock-names = "sci_ick";
+               status = "disabled";
+       };
+
+       scif5: serial@e6ee8000 {
+               compatible = "renesas,scif-r8a7791", "renesas,scif";
+               reg = <0 0xe6ee8000 0 64>;
+               interrupts = <0 25 IRQ_TYPE_LEVEL_HIGH>;
+               clocks = <&mstp7_clks R8A7791_CLK_SCIF5>;
+               clock-names = "sci_ick";
+               status = "disabled";
+       };
+
+       hscif0: serial@e62c0000 {
+               compatible = "renesas,hscif-r8a7791", "renesas,hscif";
+               reg = <0 0xe62c0000 0 96>;
+               interrupts = <0 154 IRQ_TYPE_LEVEL_HIGH>;
+               clocks = <&mstp7_clks R8A7791_CLK_HSCIF0>;
+               clock-names = "sci_ick";
+               status = "disabled";
+       };
+
+       hscif1: serial@e62c8000 {
+               compatible = "renesas,hscif-r8a7791", "renesas,hscif";
+               reg = <0 0xe62c8000 0 96>;
+               interrupts = <0 155 IRQ_TYPE_LEVEL_HIGH>;
+               clocks = <&mstp7_clks R8A7791_CLK_HSCIF1>;
+               clock-names = "sci_ick";
+               status = "disabled";
+       };
+
+       hscif2: serial@e62d0000 {
+               compatible = "renesas,hscif-r8a7791", "renesas,hscif";
+               reg = <0 0xe62d0000 0 96>;
+               interrupts = <0 21 IRQ_TYPE_LEVEL_HIGH>;
+               clocks = <&mstp7_clks R8A7791_CLK_HSCIF2>;
+               clock-names = "sci_ick";
+               status = "disabled";
+       };
+
+       ether: ethernet@ee700000 {
+               compatible = "renesas,ether-r8a7791";
+               reg = <0 0xee700000 0 0x400>;
+               interrupts = <0 162 IRQ_TYPE_LEVEL_HIGH>;
+               clocks = <&mstp8_clks R8A7791_CLK_ETHER>;
+               phy-mode = "rmii";
+               #address-cells = <1>;
+               #size-cells = <0>;
+               status = "disabled";
+       };
+
+       sata0: sata@ee300000 {
+               compatible = "renesas,sata-r8a7791";
+               reg = <0 0xee300000 0 0x2000>;
+               interrupts = <0 105 IRQ_TYPE_LEVEL_HIGH>;
+               clocks = <&mstp8_clks R8A7791_CLK_SATA0>;
+               status = "disabled";
+       };
+
+       sata1: sata@ee500000 {
+               compatible = "renesas,sata-r8a7791";
+               reg = <0 0xee500000 0 0x2000>;
+               interrupts = <0 106 IRQ_TYPE_LEVEL_HIGH>;
+               clocks = <&mstp8_clks R8A7791_CLK_SATA1>;
+               status = "disabled";
+       };
+
+       vin0: video@e6ef0000 {
+               compatible = "renesas,vin-r8a7791";
+               clocks = <&mstp8_clks R8A7791_CLK_VIN0>;
+               reg = <0 0xe6ef0000 0 0x1000>;
+               interrupts = <0 188 IRQ_TYPE_LEVEL_HIGH>;
+               status = "disabled";
+       };
+
+       vin1: video@e6ef1000 {
+               compatible = "renesas,vin-r8a7791";
+               clocks = <&mstp8_clks R8A7791_CLK_VIN1>;
+               reg = <0 0xe6ef1000 0 0x1000>;
+               interrupts = <0 189 IRQ_TYPE_LEVEL_HIGH>;
+               status = "disabled";
+       };
+
+       vin2: video@e6ef2000 {
+               compatible = "renesas,vin-r8a7791";
+               clocks = <&mstp8_clks R8A7791_CLK_VIN2>;
+               reg = <0 0xe6ef2000 0 0x1000>;
+               interrupts = <0 190 IRQ_TYPE_LEVEL_HIGH>;
+               status = "disabled";
+       };
+
        clocks {
                #address-cells = <2>;
                #size-cells = <2>;
                        clock-output-names = "extal";
                };
 
+               /*
+                * The external audio clocks are configured as 0 Hz fixed frequency clocks by
+                * default. Boards that provide audio clocks should override them.
+                */
+               audio_clk_a: audio_clk_a {
+                       compatible = "fixed-clock";
+                       #clock-cells = <0>;
+                       clock-frequency = <0>;
+                       clock-output-names = "audio_clk_a";
+               };
+               audio_clk_b: audio_clk_b {
+                       compatible = "fixed-clock";
+                       #clock-cells = <0>;
+                       clock-frequency = <0>;
+                       clock-output-names = "audio_clk_b";
+               };
+               audio_clk_c: audio_clk_c {
+                       compatible = "fixed-clock";
+                       #clock-cells = <0>;
+                       clock-frequency = <0>;
+                       clock-output-names = "audio_clk_c";
+               };
+
+               /* External PCIe clock - can be overridden by the board */
+               pcie_bus_clk: pcie_bus_clk {
+                       compatible = "fixed-clock";
+                       #clock-cells = <0>;
+                       clock-frequency = <100000000>;
+                       clock-output-names = "pcie_bus";
+                       status = "disabled";
+               };
+
                /* Special CPG clocks */
                cpg_clocks: cpg_clocks@e6150000 {
                        compatible = "renesas,r8a7791-cpg-clocks",
                        #clock-cells = <0>;
                        clock-output-names = "sd1";
                };
-               sd2_clk: sd3_clk@e615007c {
+               sd2_clk: sd3_clk@e615026c {
                        compatible = "renesas,r8a7791-div6-clock", "renesas,cpg-div6-clock";
-                       reg = <0 0xe615007c 0 4>;
+                       reg = <0 0xe615026c 0 4>;
                        clocks = <&pll1_div2_clk>;
                        #clock-cells = <0>;
                        clock-output-names = "sd2";
                mstp1_clks: mstp1_clks@e6150134 {
                        compatible = "renesas,r8a7791-mstp-clocks", "renesas,cpg-mstp-clocks";
                        reg = <0 0xe6150134 0 4>, <0 0xe6150038 0 4>;
-                       clocks = <&p_clk>, <&p_clk>, <&p_clk>, <&rclk_clk>,
+                       clocks = <&m2_clk>, <&p_clk>, <&p_clk>, <&p_clk>, <&rclk_clk>,
                                 <&cp_clk>, <&zs_clk>, <&zs_clk>, <&zs_clk>;
                        #clock-cells = <1>;
                        renesas,clock-indices = <
-                               R8A7791_CLK_TMU1 R8A7791_CLK_TMU3 R8A7791_CLK_TMU2
+                               R8A7791_CLK_JPU R8A7791_CLK_TMU1 R8A7791_CLK_TMU3 R8A7791_CLK_TMU2
                                R8A7791_CLK_CMT0 R8A7791_CLK_TMU0 R8A7791_CLK_VSP1_DU1
-                               R8A7791_CLK_VSP1_DU0 R8A7791_CLK_VSP1_SY
+                               R8A7791_CLK_VSP1_DU0 R8A7791_CLK_VSP1_S
                        >;
                        clock-output-names =
-                               "tmu1", "tmu3", "tmu2", "cmt0", "tmu0", "vsp1-du1",
+                               "jpu", "tmu1", "tmu3", "tmu2", "cmt0", "tmu0", "vsp1-du1",
                                "vsp1-du0", "vsp1-sy";
                };
                mstp2_clks: mstp2_clks@e6150138 {
                        compatible = "renesas,r8a7791-mstp-clocks", "renesas,cpg-mstp-clocks";
                        reg = <0 0xe6150138 0 4>, <0 0xe6150040 0 4>;
                        clocks = <&mp_clk>, <&mp_clk>, <&mp_clk>, <&mp_clk>, <&mp_clk>,
-                                <&mp_clk>, <&mp_clk>, <&mp_clk>;
+                                <&mp_clk>, <&mp_clk>, <&mp_clk>,
+                                <&zs_clk>, <&zs_clk>;
                        #clock-cells = <1>;
                        renesas,clock-indices = <
                                R8A7791_CLK_SCIFA2 R8A7791_CLK_SCIFA1 R8A7791_CLK_SCIFA0
                                R8A7791_CLK_MSIOF2 R8A7791_CLK_SCIFB0 R8A7791_CLK_SCIFB1
                                R8A7791_CLK_MSIOF1 R8A7791_CLK_SCIFB2
+                               R8A7791_CLK_SYS_DMAC1 R8A7791_CLK_SYS_DMAC0
                        >;
                        clock-output-names =
-                               "scifa2", "scifa1", "scifa0", "misof2", "scifb0",
-                               "scifb1", "msiof1", "scifb2";
+                               "scifa2", "scifa1", "scifa0", "msiof2", "scifb0",
+                               "scifb1", "msiof1", "scifb2",
+                               "sys-dmac1", "sys-dmac0";
                };
                mstp3_clks: mstp3_clks@e615013c {
                        compatible = "renesas,r8a7791-mstp-clocks", "renesas,cpg-mstp-clocks";
                        reg = <0 0xe615013c 0 4>, <0 0xe6150048 0 4>;
-                       clocks = <&cp_clk>, <&sd2_clk>, <&sd1_clk>,
-                               <&cpg_clocks R8A7791_CLK_SD0>, <&mmc0_clk>, <&rclk_clk>;
+                       clocks = <&cp_clk>, <&sd2_clk>, <&sd1_clk>, <&cpg_clocks R8A7791_CLK_SD0>,
+                                <&mmc0_clk>, <&hp_clk>, <&mp_clk>, <&hp_clk>, <&mp_clk>, <&rclk_clk>;
                        #clock-cells = <1>;
                        renesas,clock-indices = <
-                               R8A7791_CLK_TPU0 R8A7791_CLK_SDHI2 R8A7791_CLK_SDHI1
-                               R8A7791_CLK_SDHI0 R8A7791_CLK_MMCIF0 R8A7791_CLK_CMT1
+                               R8A7791_CLK_TPU0 R8A7791_CLK_SDHI2 R8A7791_CLK_SDHI1 R8A7791_CLK_SDHI0
+                               R8A7791_CLK_MMCIF0 R8A7791_CLK_IIC0 R8A7791_CLK_PCIEC R8A7791_CLK_IIC1
+                               R8A7791_CLK_SSUSB R8A7791_CLK_CMT1
                        >;
                        clock-output-names =
-                               "tpu0", "sdhi2", "sdhi1", "sdhi0", "mmcif0", "cmt1";
+                               "tpu0", "sdhi2", "sdhi1", "sdhi0",
+                               "mmcif0", "i2c7", "pciec", "i2c8", "ssusb", "cmt1";
                };
                mstp5_clks: mstp5_clks@e6150144 {
                        compatible = "renesas,r8a7791-mstp-clocks", "renesas,cpg-mstp-clocks";
                mstp7_clks: mstp7_clks@e615014c {
                        compatible = "renesas,r8a7791-mstp-clocks", "renesas,cpg-mstp-clocks";
                        reg = <0 0xe615014c 0 4>, <0 0xe61501c4 0 4>;
-                       clocks = <&mp_clk>, <&zs_clk>, <&p_clk>, <&p_clk>, <&zs_clk>,
+                       clocks = <&mp_clk>,  <&mp_clk>, <&zs_clk>, <&p_clk>, <&p_clk>, <&zs_clk>,
                                 <&zs_clk>, <&p_clk>, <&p_clk>, <&p_clk>, <&p_clk>,
                                 <&zx_clk>, <&zx_clk>, <&zx_clk>;
                        #clock-cells = <1>;
                        renesas,clock-indices = <
-                               R8A7791_CLK_HSUSB R8A7791_CLK_HSCIF2 R8A7791_CLK_SCIF5
+                               R8A7791_CLK_EHCI R8A7791_CLK_HSUSB R8A7791_CLK_HSCIF2 R8A7791_CLK_SCIF5
                                R8A7791_CLK_SCIF4 R8A7791_CLK_HSCIF1 R8A7791_CLK_HSCIF0
                                R8A7791_CLK_SCIF3 R8A7791_CLK_SCIF2 R8A7791_CLK_SCIF1
                                R8A7791_CLK_SCIF0 R8A7791_CLK_DU1 R8A7791_CLK_DU0
                                R8A7791_CLK_LVDS0
                        >;
                        clock-output-names =
-                               "hsusb", "hscif2", "scif5", "scif4", "hscif1", "hscif0",
+                               "ehci", "hsusb", "hscif2", "scif5", "scif4", "hscif1", "hscif0",
                                "scif3", "scif2", "scif1", "scif0", "du1", "du0", "lvds0";
                };
                mstp8_clks: mstp8_clks@e6150990 {
                        compatible = "renesas,r8a7791-mstp-clocks", "renesas,cpg-mstp-clocks";
                        reg = <0 0xe6150990 0 4>, <0 0xe61509a0 0 4>;
-                       clocks = <&p_clk>;
+                       clocks = <&zg_clk>, <&zg_clk>, <&zg_clk>, <&p_clk>, <&zs_clk>,
+                                <&zs_clk>;
                        #clock-cells = <1>;
-                       renesas,clock-indices = <R8A7791_CLK_ETHER>;
-                       clock-output-names = "ether";
+                       renesas,clock-indices = <
+                               R8A7791_CLK_VIN2 R8A7791_CLK_VIN1 R8A7791_CLK_VIN0
+                               R8A7791_CLK_ETHER R8A7791_CLK_SATA1 R8A7791_CLK_SATA0
+                       >;
+                       clock-output-names =
+                               "vin2", "vin1", "vin0", "ether", "sata1", "sata0";
                };
                mstp9_clks: mstp9_clks@e6150994 {
                        compatible = "renesas,r8a7791-mstp-clocks", "renesas,cpg-mstp-clocks";
                        reg = <0 0xe6150994 0 4>, <0 0xe61509a4 0 4>;
-                       clocks = <&p_clk>, <&p_clk>, <&cpg_clocks R8A7791_CLK_QSPI>,
-                                <&p_clk>, <&p_clk>, <&p_clk>, <&p_clk>, <&p_clk>,
-                                <&p_clk>;
+                       clocks = <&cp_clk>, <&cp_clk>, <&cp_clk>, <&cp_clk>,
+                                <&cp_clk>, <&cp_clk>, <&cp_clk>, <&cp_clk>,
+                                <&p_clk>, <&p_clk>, <&cpg_clocks R8A7791_CLK_QSPI>, <&hp_clk>,
+                                <&cp_clk>, <&hp_clk>, <&hp_clk>, <&hp_clk>,
+                                <&hp_clk>, <&hp_clk>;
                        #clock-cells = <1>;
                        renesas,clock-indices = <
-                               R8A7791_CLK_RCAN1 R8A7791_CLK_RCAN0 R8A7791_CLK_QSPI_MOD
-                               R8A7791_CLK_I2C4 R8A7791_CLK_I2C4 R8A7791_CLK_I2C3
-                               R8A7791_CLK_I2C2 R8A7791_CLK_I2C1 R8A7791_CLK_I2C0
+                               R8A7791_CLK_GPIO7 R8A7791_CLK_GPIO6 R8A7791_CLK_GPIO5 R8A7791_CLK_GPIO4
+                               R8A7791_CLK_GPIO3 R8A7791_CLK_GPIO2 R8A7791_CLK_GPIO1 R8A7791_CLK_GPIO0
+                               R8A7791_CLK_RCAN1 R8A7791_CLK_RCAN0 R8A7791_CLK_QSPI_MOD R8A7791_CLK_I2C5
+                               R8A7791_CLK_IICDVFS R8A7791_CLK_I2C4 R8A7791_CLK_I2C3 R8A7791_CLK_I2C2
+                               R8A7791_CLK_I2C1 R8A7791_CLK_I2C0
                        >;
                        clock-output-names =
-                               "rcan1", "rcan0", "qspi_mod", "i2c5", "i2c4", "i2c3",
-                               "i2c2", "i2c1", "i2c0";
+                               "gpio7", "gpio6", "gpio5", "gpio4", "gpio3", "gpio2", "gpio1", "gpio0",
+                               "rcan1", "rcan0", "qspi_mod", "i2c5", "i2c6", "i2c4", "i2c3", "i2c2",
+                               "i2c1", "i2c0";
+               };
+               mstp10_clks: mstp10_clks@e6150998 {
+                       compatible = "renesas,r8a7791-mstp-clocks", "renesas,cpg-mstp-clocks";
+                       reg = <0 0xe6150998 0 4>, <0 0xe61509a8 0 4>;
+                       clocks = <&p_clk>,
+                               <&p_clk>, <&p_clk>, <&p_clk>, <&p_clk>, <&p_clk>,
+                               <&p_clk>, <&p_clk>, <&p_clk>, <&p_clk>, <&p_clk>,
+                               <&p_clk>,
+                               <&mstp10_clks R8A7791_CLK_SCU_ALL>, <&mstp10_clks R8A7791_CLK_SCU_ALL>,
+                               <&mstp10_clks R8A7791_CLK_SCU_ALL>, <&mstp10_clks R8A7791_CLK_SCU_ALL>,
+                               <&mstp10_clks R8A7791_CLK_SCU_ALL>, <&mstp10_clks R8A7791_CLK_SCU_ALL>,
+                               <&mstp10_clks R8A7791_CLK_SCU_ALL>, <&mstp10_clks R8A7791_CLK_SCU_ALL>,
+                               <&mstp10_clks R8A7791_CLK_SCU_ALL>, <&mstp10_clks R8A7791_CLK_SCU_ALL>,
+                               <&mstp10_clks R8A7791_CLK_SCU_ALL>, <&mstp10_clks R8A7791_CLK_SCU_ALL>;
+
+                       #clock-cells = <1>;
+                       clock-indices = <
+                               R8A7791_CLK_SSI_ALL
+                               R8A7791_CLK_SSI9 R8A7791_CLK_SSI8 R8A7791_CLK_SSI7 R8A7791_CLK_SSI6 R8A7791_CLK_SSI5
+                               R8A7791_CLK_SSI4 R8A7791_CLK_SSI3 R8A7791_CLK_SSI2 R8A7791_CLK_SSI1 R8A7791_CLK_SSI0
+                               R8A7791_CLK_SCU_ALL
+                               R8A7791_CLK_SCU_DVC1 R8A7791_CLK_SCU_DVC0
+                               R8A7791_CLK_SCU_SRC9 R8A7791_CLK_SCU_SRC8 R8A7791_CLK_SCU_SRC7 R8A7791_CLK_SCU_SRC6 R8A7791_CLK_SCU_SRC5
+                               R8A7791_CLK_SCU_SRC4 R8A7791_CLK_SCU_SRC3 R8A7791_CLK_SCU_SRC2 R8A7791_CLK_SCU_SRC1 R8A7791_CLK_SCU_SRC0
+                       >;
+                       clock-output-names =
+                               "ssi-all",
+                               "ssi9", "ssi8", "ssi7", "ssi6", "ssi5",
+                               "ssi4", "ssi3", "ssi2", "ssi1", "ssi0",
+                               "scu-all",
+                               "scu-dvc1", "scu-dvc0",
+                               "scu-src9", "scu-src8", "scu-src7", "scu-src6", "scu-src5",
+                               "scu-src4", "scu-src3", "scu-src2", "scu-src1", "scu-src0";
                };
                mstp11_clks: mstp11_clks@e615099c {
                        compatible = "renesas,r8a7791-mstp-clocks", "renesas,cpg-mstp-clocks";
                        clock-output-names = "scifa3", "scifa4", "scifa5";
                };
        };
+
+       qspi: spi@e6b10000 {
+               compatible = "renesas,qspi-r8a7791", "renesas,qspi";
+               reg = <0 0xe6b10000 0 0x2c>;
+               interrupts = <0 184 IRQ_TYPE_LEVEL_HIGH>;
+               clocks = <&mstp9_clks R8A7791_CLK_QSPI_MOD>;
+               dmas = <&dmac0 0x17>, <&dmac0 0x18>;
+               dma-names = "tx", "rx";
+               num-cs = <1>;
+               #address-cells = <1>;
+               #size-cells = <0>;
+               status = "disabled";
+       };
+
+       msiof0: spi@e6e20000 {
+               compatible = "renesas,msiof-r8a7791";
+               reg = <0 0xe6e20000 0 0x0064>, <0 0xe7e20000 0 0x0064>;
+               interrupts = <0 156 IRQ_TYPE_LEVEL_HIGH>;
+               clocks = <&mstp0_clks R8A7791_CLK_MSIOF0>;
+               dmas = <&dmac0 0x51>, <&dmac0 0x52>;
+               dma-names = "tx", "rx";
+               #address-cells = <1>;
+               #size-cells = <0>;
+               status = "disabled";
+       };
+
+       msiof1: spi@e6e10000 {
+               compatible = "renesas,msiof-r8a7791";
+               reg = <0 0xe6e10000 0 0x0064>, <0 0xe7e10000 0 0x0064>;
+               interrupts = <0 157 IRQ_TYPE_LEVEL_HIGH>;
+               clocks = <&mstp2_clks R8A7791_CLK_MSIOF1>;
+               dmas = <&dmac0 0x55>, <&dmac0 0x56>;
+               dma-names = "tx", "rx";
+               #address-cells = <1>;
+               #size-cells = <0>;
+               status = "disabled";
+       };
+
+       msiof2: spi@e6e00000 {
+               compatible = "renesas,msiof-r8a7791";
+               reg = <0 0xe6e00000 0 0x0064>, <0 0xe7e00000 0 0x0064>;
+               interrupts = <0 158 IRQ_TYPE_LEVEL_HIGH>;
+               clocks = <&mstp2_clks R8A7791_CLK_MSIOF2>;
+               dmas = <&dmac0 0x41>, <&dmac0 0x42>;
+               dma-names = "tx", "rx";
+               #address-cells = <1>;
+               #size-cells = <0>;
+               status = "disabled";
+       };
+
+       pci0: pci@ee090000 {
+               compatible = "renesas,pci-r8a7791";
+               device_type = "pci";
+               clocks = <&mstp7_clks R8A7791_CLK_EHCI>;
+               reg = <0 0xee090000 0 0xc00>,
+                     <0 0xee080000 0 0x1100>;
+               interrupts = <0 108 IRQ_TYPE_LEVEL_HIGH>;
+               status = "disabled";
+
+               bus-range = <0 0>;
+               #address-cells = <3>;
+               #size-cells = <2>;
+               #interrupt-cells = <1>;
+               ranges = <0x02000000 0 0xee080000 0 0xee080000 0 0x00010000>;
+               interrupt-map-mask = <0xff00 0 0 0x7>;
+               interrupt-map = <0x0000 0 0 1 &gic 0 108 IRQ_TYPE_LEVEL_HIGH
+                                0x0800 0 0 1 &gic 0 108 IRQ_TYPE_LEVEL_HIGH
+                                0x1000 0 0 2 &gic 0 108 IRQ_TYPE_LEVEL_HIGH>;
+       };
+
+       pci1: pci@ee0d0000 {
+               compatible = "renesas,pci-r8a7791";
+               device_type = "pci";
+               clocks = <&mstp7_clks R8A7791_CLK_EHCI>;
+               reg = <0 0xee0d0000 0 0xc00>,
+                     <0 0xee0c0000 0 0x1100>;
+               interrupts = <0 113 IRQ_TYPE_LEVEL_HIGH>;
+               status = "disabled";
+
+               bus-range = <1 1>;
+               #address-cells = <3>;
+               #size-cells = <2>;
+               #interrupt-cells = <1>;
+               ranges = <0x02000000 0 0xee0c0000 0 0xee0c0000 0 0x00010000>;
+               interrupt-map-mask = <0xff00 0 0 0x7>;
+               interrupt-map = <0x0000 0 0 1 &gic 0 113 IRQ_TYPE_LEVEL_HIGH
+                                0x0800 0 0 1 &gic 0 113 IRQ_TYPE_LEVEL_HIGH
+                                0x1000 0 0 2 &gic 0 113 IRQ_TYPE_LEVEL_HIGH>;
+       };
+
+       pciec: pcie@fe000000 {
+               compatible = "renesas,pcie-r8a7791";
+               reg = <0 0xfe000000 0 0x80000>;
+               #address-cells = <3>;
+               #size-cells = <2>;
+               bus-range = <0x00 0xff>;
+               device_type = "pci";
+               ranges = <0x01000000 0 0x00000000 0 0xfe100000 0 0x00100000
+                         0x02000000 0 0xfe200000 0 0xfe200000 0 0x00200000
+                         0x02000000 0 0x30000000 0 0x30000000 0 0x08000000
+                         0x42000000 0 0x38000000 0 0x38000000 0 0x08000000>;
+               /* Map all possible DDR as inbound ranges */
+               dma-ranges = <0x42000000 0 0x40000000 0 0x40000000 0 0x80000000
+                             0x43000000 2 0x00000000 2 0x00000000 1 0x00000000>;
+               interrupts = <0 116 IRQ_TYPE_LEVEL_HIGH>,
+                            <0 117 IRQ_TYPE_LEVEL_HIGH>,
+                            <0 118 IRQ_TYPE_LEVEL_HIGH>;
+               #interrupt-cells = <1>;
+               interrupt-map-mask = <0 0 0 0>;
+               interrupt-map = <0 0 0 0 &gic 0 116 IRQ_TYPE_LEVEL_HIGH>;
+               clocks = <&mstp3_clks R8A7791_CLK_PCIEC>, <&pcie_bus_clk>;
+               clock-names = "pcie", "pcie_bus";
+               status = "disabled";
+       };
+
+       rcar_sound: rcar_sound@0xec500000 {
+               #sound-dai-cells = <1>;
+               compatible =  "renesas,rcar_sound-r8a7791", "renesas,rcar_sound-gen2", "renesas,rcar_sound";
+               reg =   <0 0xec500000 0 0x1000>, /* SCU */
+                       <0 0xec5a0000 0 0x100>,  /* ADG */
+                       <0 0xec540000 0 0x1000>, /* SSIU */
+                       <0 0xec541000 0 0x1280>; /* SSI */
+               clocks = <&mstp10_clks R8A7791_CLK_SSI_ALL>,
+                       <&mstp10_clks R8A7791_CLK_SSI9>, <&mstp10_clks R8A7791_CLK_SSI8>,
+                       <&mstp10_clks R8A7791_CLK_SSI7>, <&mstp10_clks R8A7791_CLK_SSI6>,
+                       <&mstp10_clks R8A7791_CLK_SSI5>, <&mstp10_clks R8A7791_CLK_SSI4>,
+                       <&mstp10_clks R8A7791_CLK_SSI3>, <&mstp10_clks R8A7791_CLK_SSI2>,
+                       <&mstp10_clks R8A7791_CLK_SSI1>, <&mstp10_clks R8A7791_CLK_SSI0>,
+                       <&mstp10_clks R8A7791_CLK_SCU_SRC9>, <&mstp10_clks R8A7791_CLK_SCU_SRC8>,
+                       <&mstp10_clks R8A7791_CLK_SCU_SRC7>, <&mstp10_clks R8A7791_CLK_SCU_SRC6>,
+                       <&mstp10_clks R8A7791_CLK_SCU_SRC5>, <&mstp10_clks R8A7791_CLK_SCU_SRC4>,
+                       <&mstp10_clks R8A7791_CLK_SCU_SRC3>, <&mstp10_clks R8A7791_CLK_SCU_SRC2>,
+                       <&mstp10_clks R8A7791_CLK_SCU_SRC1>, <&mstp10_clks R8A7791_CLK_SCU_SRC0>,
+                       <&mstp10_clks R8A7791_CLK_SCU_DVC0>, <&mstp10_clks R8A7791_CLK_SCU_DVC1>,
+                       <&audio_clk_a>, <&audio_clk_b>, <&audio_clk_c>, <&m2_clk>;
+               clock-names = "ssi-all",
+                               "ssi.9", "ssi.8", "ssi.7", "ssi.6", "ssi.5",
+                               "ssi.4", "ssi.3", "ssi.2", "ssi.1", "ssi.0",
+                               "src.9", "src.8", "src.7", "src.6", "src.5",
+                               "src.4", "src.3", "src.2", "src.1", "src.0",
+                               "dvc.0", "dvc.1",
+                               "clk_a", "clk_b", "clk_c", "clk_i";
+
+               status = "disabled";
+
+               rcar_sound,dvc {
+                       dvc0: dvc@0 { };
+                       dvc1: dvc@1 { };
+               };
+
+               rcar_sound,src {
+                       src0: src@0 { };
+                       src1: src@1 { };
+                       src2: src@2 { };
+                       src3: src@3 { };
+                       src4: src@4 { };
+                       src5: src@5 { };
+                       src6: src@6 { };
+                       src7: src@7 { };
+                       src8: src@8 { };
+                       src9: src@9 { };
+               };
+
+               rcar_sound,ssi {
+                       ssi0: ssi@0 { interrupts = <0 370 IRQ_TYPE_LEVEL_HIGH>; };
+                       ssi1: ssi@1 { interrupts = <0 371 IRQ_TYPE_LEVEL_HIGH>; };
+                       ssi2: ssi@2 { interrupts = <0 372 IRQ_TYPE_LEVEL_HIGH>; };
+                       ssi3: ssi@3 { interrupts = <0 373 IRQ_TYPE_LEVEL_HIGH>; };
+                       ssi4: ssi@4 { interrupts = <0 374 IRQ_TYPE_LEVEL_HIGH>; };
+                       ssi5: ssi@5 { interrupts = <0 375 IRQ_TYPE_LEVEL_HIGH>; };
+                       ssi6: ssi@6 { interrupts = <0 376 IRQ_TYPE_LEVEL_HIGH>; };
+                       ssi7: ssi@7 { interrupts = <0 377 IRQ_TYPE_LEVEL_HIGH>; };
+                       ssi8: ssi@8 { interrupts = <0 378 IRQ_TYPE_LEVEL_HIGH>; };
+                       ssi9: ssi@9 { interrupts = <0 379 IRQ_TYPE_LEVEL_HIGH>; };
+               };
+       };
 };
diff --git a/arch/arm/boot/dts/r8a7794-alt.dts b/arch/arm/boot/dts/r8a7794-alt.dts
new file mode 100644 (file)
index 0000000..79d06ef
--- /dev/null
@@ -0,0 +1,47 @@
+/*
+ * Device Tree Source for the Alt board
+ *
+ * Copyright (C) 2014 Renesas Electronics Corporation
+ *
+ * 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.
+ */
+
+/dts-v1/;
+#include "r8a7794.dtsi"
+
+/ {
+       model = "Alt";
+       compatible = "renesas,alt", "renesas,r8a7794";
+
+       aliases {
+               serial0 = &scif2;
+       };
+
+       chosen {
+               bootargs = "console=ttySC0,38400 ignore_loglevel rw root=/dev/nfs ip=dhcp";
+       };
+
+       memory@40000000 {
+               device_type = "memory";
+               reg = <0 0x40000000 0 0x40000000>;
+       };
+
+       lbsc {
+               #address-cells = <1>;
+               #size-cells = <1>;
+       };
+};
+
+&extal_clk {
+       clock-frequency = <20000000>;
+};
+
+&cmt0 {
+       status = "ok";
+};
+
+&scif2 {
+       status = "ok";
+};
diff --git a/arch/arm/boot/dts/r8a7794.dtsi b/arch/arm/boot/dts/r8a7794.dtsi
new file mode 100644 (file)
index 0000000..d4e8bce
--- /dev/null
@@ -0,0 +1,531 @@
+/*
+ * Device Tree Source for the r8a7794 SoC
+ *
+ * Copyright (C) 2014 Renesas Electronics Corporation
+ * Copyright (C) 2014 Ulrich Hecht
+ *
+ * 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 <dt-bindings/clock/r8a7794-clock.h>
+#include <dt-bindings/interrupt-controller/arm-gic.h>
+#include <dt-bindings/interrupt-controller/irq.h>
+
+/ {
+       compatible = "renesas,r8a7794";
+       interrupt-parent = <&gic>;
+       #address-cells = <2>;
+       #size-cells = <2>;
+
+       cpus {
+               #address-cells = <1>;
+               #size-cells = <0>;
+
+               cpu0: cpu@0 {
+                       device_type = "cpu";
+                       compatible = "arm,cortex-a7";
+                       reg = <0>;
+                       clock-frequency = <1000000000>;
+               };
+
+               cpu1: cpu@1 {
+                       device_type = "cpu";
+                       compatible = "arm,cortex-a7";
+                       reg = <1>;
+                       clock-frequency = <1000000000>;
+               };
+       };
+
+       gic: interrupt-controller@f1001000 {
+               compatible = "arm,cortex-a7-gic";
+               #interrupt-cells = <3>;
+               #address-cells = <0>;
+               interrupt-controller;
+               reg = <0 0xf1001000 0 0x1000>,
+                       <0 0xf1002000 0 0x1000>,
+                       <0 0xf1004000 0 0x2000>,
+                       <0 0xf1006000 0 0x2000>;
+               interrupts = <1 9 (GIC_CPU_MASK_SIMPLE(4) | IRQ_TYPE_LEVEL_HIGH)>;
+       };
+
+       cmt0: timer@ffca0000 {
+               compatible = "renesas,cmt-48-gen2";
+               reg = <0 0xffca0000 0 0x1004>;
+               interrupts = <0 142 IRQ_TYPE_LEVEL_HIGH>,
+                            <0 143 IRQ_TYPE_LEVEL_HIGH>;
+               clocks = <&mstp1_clks R8A7794_CLK_CMT0>;
+               clock-names = "fck";
+
+               renesas,channels-mask = <0x60>;
+
+               status = "disabled";
+       };
+
+       cmt1: timer@e6130000 {
+               compatible = "renesas,cmt-48-gen2";
+               reg = <0 0xe6130000 0 0x1004>;
+               interrupts = <0 120 IRQ_TYPE_LEVEL_HIGH>,
+                            <0 121 IRQ_TYPE_LEVEL_HIGH>,
+                            <0 122 IRQ_TYPE_LEVEL_HIGH>,
+                            <0 123 IRQ_TYPE_LEVEL_HIGH>,
+                            <0 124 IRQ_TYPE_LEVEL_HIGH>,
+                            <0 125 IRQ_TYPE_LEVEL_HIGH>,
+                            <0 126 IRQ_TYPE_LEVEL_HIGH>,
+                            <0 127 IRQ_TYPE_LEVEL_HIGH>;
+               clocks = <&mstp3_clks R8A7794_CLK_CMT1>;
+               clock-names = "fck";
+
+               renesas,channels-mask = <0xff>;
+
+               status = "disabled";
+       };
+
+       irqc0: interrupt-controller@e61c0000 {
+               compatible = "renesas,irqc-r8a7794", "renesas,irqc";
+               #interrupt-cells = <2>;
+               interrupt-controller;
+               reg = <0 0xe61c0000 0 0x200>;
+               interrupts = <0 0 IRQ_TYPE_LEVEL_HIGH>,
+                            <0 1 IRQ_TYPE_LEVEL_HIGH>,
+                            <0 2 IRQ_TYPE_LEVEL_HIGH>,
+                            <0 3 IRQ_TYPE_LEVEL_HIGH>,
+                            <0 12 IRQ_TYPE_LEVEL_HIGH>,
+                            <0 13 IRQ_TYPE_LEVEL_HIGH>,
+                            <0 14 IRQ_TYPE_LEVEL_HIGH>,
+                            <0 15 IRQ_TYPE_LEVEL_HIGH>,
+                            <0 16 IRQ_TYPE_LEVEL_HIGH>,
+                            <0 17 IRQ_TYPE_LEVEL_HIGH>;
+       };
+
+       scifa0: serial@e6c40000 {
+               compatible = "renesas,scifa-r8a7794", "renesas,scifa";
+               reg = <0 0xe6c40000 0 64>;
+               interrupts = <0 144 IRQ_TYPE_LEVEL_HIGH>;
+               clocks = <&mstp2_clks R8A7794_CLK_SCIFA0>;
+               clock-names = "sci_ick";
+               status = "disabled";
+       };
+
+       scifa1: serial@e6c50000 {
+               compatible = "renesas,scifa-r8a7794", "renesas,scifa";
+               reg = <0 0xe6c50000 0 64>;
+               interrupts = <0 145 IRQ_TYPE_LEVEL_HIGH>;
+               clocks = <&mstp2_clks R8A7794_CLK_SCIFA1>;
+               clock-names = "sci_ick";
+               status = "disabled";
+       };
+
+       scifa2: serial@e6c60000 {
+               compatible = "renesas,scifa-r8a7794", "renesas,scifa";
+               reg = <0 0xe6c60000 0 64>;
+               interrupts = <0 151 IRQ_TYPE_LEVEL_HIGH>;
+               clocks = <&mstp2_clks R8A7794_CLK_SCIFA2>;
+               clock-names = "sci_ick";
+               status = "disabled";
+       };
+
+       scifa3: serial@e6c70000 {
+               compatible = "renesas,scifa-r8a7794", "renesas,scifa";
+               reg = <0 0xe6c70000 0 64>;
+               interrupts = <0 29 IRQ_TYPE_LEVEL_HIGH>;
+               clocks = <&mstp11_clks R8A7794_CLK_SCIFA3>;
+               clock-names = "sci_ick";
+               status = "disabled";
+       };
+
+       scifa4: serial@e6c78000 {
+               compatible = "renesas,scifa-r8a7794", "renesas,scifa";
+               reg = <0 0xe6c78000 0 64>;
+               interrupts = <0 30 IRQ_TYPE_LEVEL_HIGH>;
+               clocks = <&mstp11_clks R8A7794_CLK_SCIFA4>;
+               clock-names = "sci_ick";
+               status = "disabled";
+       };
+
+       scifa5: serial@e6c80000 {
+               compatible = "renesas,scifa-r8a7794", "renesas,scifa";
+               reg = <0 0xe6c80000 0 64>;
+               interrupts = <0 31 IRQ_TYPE_LEVEL_HIGH>;
+               clocks = <&mstp11_clks R8A7794_CLK_SCIFA5>;
+               clock-names = "sci_ick";
+               status = "disabled";
+       };
+
+       scifb0: serial@e6c20000 {
+               compatible = "renesas,scifb-r8a7794", "renesas,scifb";
+               reg = <0 0xe6c20000 0 64>;
+               interrupts = <0 148 IRQ_TYPE_LEVEL_HIGH>;
+               clocks = <&mstp2_clks R8A7794_CLK_SCIFB0>;
+               clock-names = "sci_ick";
+               status = "disabled";
+       };
+
+       scifb1: serial@e6c30000 {
+               compatible = "renesas,scifb-r8a7794", "renesas,scifb";
+               reg = <0 0xe6c30000 0 64>;
+               interrupts = <0 149 IRQ_TYPE_LEVEL_HIGH>;
+               clocks = <&mstp2_clks R8A7794_CLK_SCIFB1>;
+               clock-names = "sci_ick";
+               status = "disabled";
+       };
+
+       scifb2: serial@e6ce0000 {
+               compatible = "renesas,scifb-r8a7794", "renesas,scifb";
+               reg = <0 0xe6ce0000 0 64>;
+               interrupts = <0 150 IRQ_TYPE_LEVEL_HIGH>;
+               clocks = <&mstp2_clks R8A7794_CLK_SCIFB2>;
+               clock-names = "sci_ick";
+               status = "disabled";
+       };
+
+       scif0: serial@e6e60000 {
+               compatible = "renesas,scif-r8a7794", "renesas,scif";
+               reg = <0 0xe6e60000 0 64>;
+               interrupts = <0 152 IRQ_TYPE_LEVEL_HIGH>;
+               clocks = <&mstp7_clks R8A7794_CLK_SCIF0>;
+               clock-names = "sci_ick";
+               status = "disabled";
+       };
+
+       scif1: serial@e6e68000 {
+               compatible = "renesas,scif-r8a7794", "renesas,scif";
+               reg = <0 0xe6e68000 0 64>;
+               interrupts = <0 153 IRQ_TYPE_LEVEL_HIGH>;
+               clocks = <&mstp7_clks R8A7794_CLK_SCIF1>;
+               clock-names = "sci_ick";
+               status = "disabled";
+       };
+
+       scif2: serial@e6e58000 {
+               compatible = "renesas,scif-r8a7794", "renesas,scif";
+               reg = <0 0xe6e58000 0 64>;
+               interrupts = <0 22 IRQ_TYPE_LEVEL_HIGH>;
+               clocks = <&mstp7_clks R8A7794_CLK_SCIF2>;
+               clock-names = "sci_ick";
+               status = "disabled";
+       };
+
+       scif3: serial@e6ea8000 {
+               compatible = "renesas,scif-r8a7794", "renesas,scif";
+               reg = <0 0xe6ea8000 0 64>;
+               interrupts = <0 23 IRQ_TYPE_LEVEL_HIGH>;
+               clocks = <&mstp7_clks R8A7794_CLK_SCIF3>;
+               clock-names = "sci_ick";
+               status = "disabled";
+       };
+
+       scif4: serial@e6ee0000 {
+               compatible = "renesas,scif-r8a7794", "renesas,scif";
+               reg = <0 0xe6ee0000 0 64>;
+               interrupts = <0 24 IRQ_TYPE_LEVEL_HIGH>;
+               clocks = <&mstp7_clks R8A7794_CLK_SCIF4>;
+               clock-names = "sci_ick";
+               status = "disabled";
+       };
+
+       scif5: serial@e6ee8000 {
+               compatible = "renesas,scif-r8a7794", "renesas,scif";
+               reg = <0 0xe6ee8000 0 64>;
+               interrupts = <0 25 IRQ_TYPE_LEVEL_HIGH>;
+               clocks = <&mstp7_clks R8A7794_CLK_SCIF5>;
+               clock-names = "sci_ick";
+               status = "disabled";
+       };
+
+       hscif0: serial@e62c0000 {
+               compatible = "renesas,hscif-r8a7794", "renesas,hscif";
+               reg = <0 0xe62c0000 0 96>;
+               interrupts = <0 154 IRQ_TYPE_LEVEL_HIGH>;
+               clocks = <&mstp7_clks R8A7794_CLK_HSCIF0>;
+               clock-names = "sci_ick";
+               status = "disabled";
+       };
+
+       hscif1: serial@e62c8000 {
+               compatible = "renesas,hscif-r8a7794", "renesas,hscif";
+               reg = <0 0xe62c8000 0 96>;
+               interrupts = <0 155 IRQ_TYPE_LEVEL_HIGH>;
+               clocks = <&mstp7_clks R8A7794_CLK_HSCIF1>;
+               clock-names = "sci_ick";
+               status = "disabled";
+       };
+
+       hscif2: serial@e62d0000 {
+               compatible = "renesas,hscif-r8a7794", "renesas,hscif";
+               reg = <0 0xe62d0000 0 96>;
+               interrupts = <0 21 IRQ_TYPE_LEVEL_HIGH>;
+               clocks = <&mstp7_clks R8A7794_CLK_HSCIF2>;
+               clock-names = "sci_ick";
+               status = "disabled";
+       };
+
+       clocks {
+               #address-cells = <2>;
+               #size-cells = <2>;
+               ranges;
+
+               /* External root clock */
+               extal_clk: extal_clk {
+                       compatible = "fixed-clock";
+                       #clock-cells = <0>;
+                       /* This value must be overriden by the board. */
+                       clock-frequency = <0>;
+                       clock-output-names = "extal";
+               };
+
+               /* Special CPG clocks */
+               cpg_clocks: cpg_clocks@e6150000 {
+                       compatible = "renesas,r8a7794-cpg-clocks",
+                                    "renesas,rcar-gen2-cpg-clocks";
+                       reg = <0 0xe6150000 0 0x1000>;
+                       clocks = <&extal_clk>;
+                       #clock-cells = <1>;
+                       clock-output-names = "main", "pll0", "pll1", "pll3",
+                                            "lb", "qspi", "sdh", "sd0", "z";
+               };
+
+               /* Fixed factor clocks */
+               pll1_div2_clk: pll1_div2_clk {
+                       compatible = "fixed-factor-clock";
+                       clocks = <&cpg_clocks R8A7794_CLK_PLL1>;
+                       #clock-cells = <0>;
+                       clock-div = <2>;
+                       clock-mult = <1>;
+                       clock-output-names = "pll1_div2";
+               };
+               zg_clk: zg_clk {
+                       compatible = "fixed-factor-clock";
+                       clocks = <&cpg_clocks R8A7794_CLK_PLL1>;
+                       #clock-cells = <0>;
+                       clock-div = <6>;
+                       clock-mult = <1>;
+                       clock-output-names = "zg";
+               };
+               zx_clk: zx_clk {
+                       compatible = "fixed-factor-clock";
+                       clocks = <&cpg_clocks R8A7794_CLK_PLL1>;
+                       #clock-cells = <0>;
+                       clock-div = <3>;
+                       clock-mult = <1>;
+                       clock-output-names = "zx";
+               };
+               zs_clk: zs_clk {
+                       compatible = "fixed-factor-clock";
+                       clocks = <&cpg_clocks R8A7794_CLK_PLL1>;
+                       #clock-cells = <0>;
+                       clock-div = <6>;
+                       clock-mult = <1>;
+                       clock-output-names = "zs";
+               };
+               hp_clk: hp_clk {
+                       compatible = "fixed-factor-clock";
+                       clocks = <&cpg_clocks R8A7794_CLK_PLL1>;
+                       #clock-cells = <0>;
+                       clock-div = <12>;
+                       clock-mult = <1>;
+                       clock-output-names = "hp";
+               };
+               i_clk: i_clk {
+                       compatible = "fixed-factor-clock";
+                       clocks = <&cpg_clocks R8A7794_CLK_PLL1>;
+                       #clock-cells = <0>;
+                       clock-div = <2>;
+                       clock-mult = <1>;
+                       clock-output-names = "i";
+               };
+               b_clk: b_clk {
+                       compatible = "fixed-factor-clock";
+                       clocks = <&cpg_clocks R8A7794_CLK_PLL1>;
+                       #clock-cells = <0>;
+                       clock-div = <12>;
+                       clock-mult = <1>;
+                       clock-output-names = "b";
+               };
+               p_clk: p_clk {
+                       compatible = "fixed-factor-clock";
+                       clocks = <&cpg_clocks R8A7794_CLK_PLL1>;
+                       #clock-cells = <0>;
+                       clock-div = <24>;
+                       clock-mult = <1>;
+                       clock-output-names = "p";
+               };
+               cl_clk: cl_clk {
+                       compatible = "fixed-factor-clock";
+                       clocks = <&cpg_clocks R8A7794_CLK_PLL1>;
+                       #clock-cells = <0>;
+                       clock-div = <48>;
+                       clock-mult = <1>;
+                       clock-output-names = "cl";
+               };
+               m2_clk: m2_clk {
+                       compatible = "fixed-factor-clock";
+                       clocks = <&cpg_clocks R8A7794_CLK_PLL1>;
+                       #clock-cells = <0>;
+                       clock-div = <8>;
+                       clock-mult = <1>;
+                       clock-output-names = "m2";
+               };
+               imp_clk: imp_clk {
+                       compatible = "fixed-factor-clock";
+                       clocks = <&cpg_clocks R8A7794_CLK_PLL1>;
+                       #clock-cells = <0>;
+                       clock-div = <4>;
+                       clock-mult = <1>;
+                       clock-output-names = "imp";
+               };
+               rclk_clk: rclk_clk {
+                       compatible = "fixed-factor-clock";
+                       clocks = <&cpg_clocks R8A7794_CLK_PLL1>;
+                       #clock-cells = <0>;
+                       clock-div = <(48 * 1024)>;
+                       clock-mult = <1>;
+                       clock-output-names = "rclk";
+               };
+               oscclk_clk: oscclk_clk {
+                       compatible = "fixed-factor-clock";
+                       clocks = <&cpg_clocks R8A7794_CLK_PLL1>;
+                       #clock-cells = <0>;
+                       clock-div = <(12 * 1024)>;
+                       clock-mult = <1>;
+                       clock-output-names = "oscclk";
+               };
+               zb3_clk: zb3_clk {
+                       compatible = "fixed-factor-clock";
+                       clocks = <&cpg_clocks R8A7794_CLK_PLL3>;
+                       #clock-cells = <0>;
+                       clock-div = <4>;
+                       clock-mult = <1>;
+                       clock-output-names = "zb3";
+               };
+               zb3d2_clk: zb3d2_clk {
+                       compatible = "fixed-factor-clock";
+                       clocks = <&cpg_clocks R8A7794_CLK_PLL3>;
+                       #clock-cells = <0>;
+                       clock-div = <8>;
+                       clock-mult = <1>;
+                       clock-output-names = "zb3d2";
+               };
+               ddr_clk: ddr_clk {
+                       compatible = "fixed-factor-clock";
+                       clocks = <&cpg_clocks R8A7794_CLK_PLL3>;
+                       #clock-cells = <0>;
+                       clock-div = <8>;
+                       clock-mult = <1>;
+                       clock-output-names = "ddr";
+               };
+               mp_clk: mp_clk {
+                       compatible = "fixed-factor-clock";
+                       clocks = <&pll1_div2_clk>;
+                       #clock-cells = <0>;
+                       clock-div = <15>;
+                       clock-mult = <1>;
+                       clock-output-names = "mp";
+               };
+               cp_clk: cp_clk {
+                       compatible = "fixed-factor-clock";
+                       clocks = <&cpg_clocks R8A7794_CLK_PLL1>;
+                       #clock-cells = <0>;
+                       clock-div = <48>;
+                       clock-mult = <1>;
+                       clock-output-names = "cp";
+               };
+
+               acp_clk: acp_clk {
+                       compatible = "fixed-factor-clock";
+                       clocks = <&extal_clk>;
+                       #clock-cells = <0>;
+                       clock-div = <2>;
+                       clock-mult = <1>;
+                       clock-output-names = "acp";
+               };
+
+               /* Gate clocks */
+               mstp0_clks: mstp0_clks@e6150130 {
+                       compatible = "renesas,r8a7794-mstp-clocks", "renesas,cpg-mstp-clocks";
+                       reg = <0 0xe6150130 0 4>, <0 0xe6150030 0 4>;
+                       clocks = <&mp_clk>;
+                       #clock-cells = <1>;
+                       renesas,clock-indices = <R8A7794_CLK_MSIOF0>;
+                       clock-output-names = "msiof0";
+               };
+               mstp1_clks: mstp1_clks@e6150134 {
+                       compatible = "renesas,r8a7794-mstp-clocks", "renesas,cpg-mstp-clocks";
+                       reg = <0 0xe6150134 0 4>, <0 0xe6150038 0 4>;
+                       clocks = <&p_clk>, <&p_clk>, <&p_clk>, <&rclk_clk>,
+                                <&cp_clk>,
+                                <&zs_clk>, <&zs_clk>, <&zs_clk>;
+                       #clock-cells = <1>;
+                       renesas,clock-indices = <
+                               R8A7794_CLK_TMU1 R8A7794_CLK_TMU3 R8A7794_CLK_TMU2
+                               R8A7794_CLK_CMT0 R8A7794_CLK_TMU0
+                       >;
+                       clock-output-names =
+                               "tmu1", "tmu3", "tmu2", "cmt0", "tmu0";
+               };
+               mstp2_clks: mstp2_clks@e6150138 {
+                       compatible = "renesas,r8a7794-mstp-clocks", "renesas,cpg-mstp-clocks";
+                       reg = <0 0xe6150138 0 4>, <0 0xe6150040 0 4>;
+                       clocks = <&mp_clk>, <&mp_clk>, <&mp_clk>, <&mp_clk>, <&mp_clk>,
+                                <&mp_clk>, <&mp_clk>, <&mp_clk>;
+                       #clock-cells = <1>;
+                       renesas,clock-indices = <
+                               R8A7794_CLK_SCIFA2 R8A7794_CLK_SCIFA1 R8A7794_CLK_SCIFA0
+                               R8A7794_CLK_MSIOF2 R8A7794_CLK_SCIFB0 R8A7794_CLK_SCIFB1
+                               R8A7794_CLK_MSIOF1 R8A7794_CLK_SCIFB2
+                       >;
+                       clock-output-names =
+                               "scifa2", "scifa1", "scifa0", "msiof2", "scifb0",
+                               "scifb1", "msiof1", "scifb2";
+               };
+               mstp3_clks: mstp3_clks@e615013c {
+                       compatible = "renesas,r8a7794-mstp-clocks", "renesas,cpg-mstp-clocks";
+                       reg = <0 0xe615013c 0 4>, <0 0xe6150048 0 4>;
+                       clocks = <&rclk_clk>;
+                       #clock-cells = <1>;
+                       renesas,clock-indices = <
+                               R8A7794_CLK_CMT1
+                       >;
+                       clock-output-names =
+                               "cmt1";
+               };
+               mstp7_clks: mstp7_clks@e615014c {
+                       compatible = "renesas,r8a7794-mstp-clocks", "renesas,cpg-mstp-clocks";
+                       reg = <0 0xe615014c 0 4>, <0 0xe61501c4 0 4>;
+                       clocks = <&zs_clk>, <&p_clk>, <&p_clk>, <&zs_clk>,
+                                <&zs_clk>, <&p_clk>, <&p_clk>, <&p_clk>, <&p_clk>;
+                       #clock-cells = <1>;
+                       renesas,clock-indices = <
+                               R8A7794_CLK_HSCIF2 R8A7794_CLK_SCIF5
+                               R8A7794_CLK_SCIF4 R8A7794_CLK_HSCIF1 R8A7794_CLK_HSCIF0
+                               R8A7794_CLK_SCIF3 R8A7794_CLK_SCIF2 R8A7794_CLK_SCIF1
+                               R8A7794_CLK_SCIF0
+                       >;
+                       clock-output-names =
+                               "hscif2", "scif5", "scif4", "hscif1", "hscif0",
+                               "scif3", "scif2", "scif1", "scif0";
+               };
+               mstp8_clks: mstp8_clks@e6150990 {
+                       compatible = "renesas,r8a7794-mstp-clocks", "renesas,cpg-mstp-clocks";
+                       reg = <0 0xe6150990 0 4>, <0 0xe61509a0 0 4>;
+                       clocks = <&p_clk>;
+                       #clock-cells = <1>;
+                       renesas,clock-indices = <
+                               R8A7794_CLK_ETHER
+                       >;
+                       clock-output-names =
+                               "ether";
+               };
+               mstp11_clks: mstp11_clks@e615099c {
+                       compatible = "renesas,r8a7794-mstp-clocks", "renesas,cpg-mstp-clocks";
+                       reg = <0 0xe615099c 0 4>, <0 0xe61509ac 0 4>;
+                       clocks = <&mp_clk>, <&mp_clk>, <&mp_clk>;
+                       #clock-cells = <1>;
+                       renesas,clock-indices = <
+                               R8A7794_CLK_SCIFA3 R8A7794_CLK_SCIFA4 R8A7794_CLK_SCIFA5
+                       >;
+                       clock-output-names = "scifa3", "scifa4", "scifa5";
+               };
+       };
+};
index 249f65b..f863a10 100644 (file)
@@ -21,6 +21,7 @@
                        compatible = "arm,cortex-a8";
                        device_type = "cpu";
                        reg = <0x0>;
+                       clock-frequency = <800000000>;
                };
        };
 
index eb8886b..30ef97e 100644 (file)
 /dts-v1/;
 #include "sh73a0.dtsi"
 #include <dt-bindings/gpio/gpio.h>
+#include <dt-bindings/input/input.h>
 #include <dt-bindings/interrupt-controller/irq.h>
 
 / {
        model = "KZM-A9-GT";
        compatible = "renesas,kzm9g-reference", "renesas,sh73a0";
 
+       aliases {
+               serial4 = &scifa4;
+       };
+
        cpus {
                cpu@0 {
                        cpu0-supply = <&vdd_dvfs>;
@@ -34,7 +39,7 @@
        };
 
        chosen {
-               bootargs = "console=tty0 console=ttySC4,115200 root=/dev/nfs ip=dhcp ignore_loglevel earlyprintk=sh-sci.4,115200 rw";
+               bootargs = "console=tty0 console=ttySC4,115200 root=/dev/nfs ip=dhcp ignore_loglevel rw";
        };
 
        memory {
@@ -61,7 +66,7 @@
        };
 
        vmmc_sdhi0: regulator@2 {
-               compatible = "regulator-fixed";
+               compatible = "regulator-fixed";
                regulator-name = "SDHI0 Vcc";
                regulator-min-microvolt = <3300000>;
                regulator-max-microvolt = <3300000>;
@@ -70,7 +75,7 @@
        };
 
        vmmc_sdhi2: regulator@3 {
-               compatible = "regulator-fixed";
+               compatible = "regulator-fixed";
                regulator-name = "SDHI2 Vcc";
                regulator-min-microvolt = <3300000>;
                regulator-max-microvolt = <3300000>;
 
                back-key {
                        gpios = <&pcf8575 8 GPIO_ACTIVE_LOW>;
-                       linux,code = <158>;
+                       linux,code = <KEY_BACK>;
                        label = "SW3";
                };
 
                right-key {
                        gpios = <&pcf8575 9 GPIO_ACTIVE_LOW>;
-                       linux,code = <106>;
+                       linux,code = <KEY_RIGHT>;
                        label = "SW2-R";
                };
 
                left-key {
                        gpios = <&pcf8575 10 GPIO_ACTIVE_LOW>;
-                       linux,code = <105>;
+                       linux,code = <KEY_LEFT>;
                        label = "SW2-L";
                };
 
                enter-key {
                        gpios = <&pcf8575 11 GPIO_ACTIVE_LOW>;
-                       linux,code = <28>;
+                       linux,code = <KEY_ENTER>;
                        label = "SW2-P";
                };
 
                up-key {
                        gpios = <&pcf8575 12 GPIO_ACTIVE_LOW>;
-                       linux,code = <103>;
+                       linux,code = <KEY_UP>;
                        label = "SW2-U";
                };
 
                down-key {
                        gpios = <&pcf8575 13 GPIO_ACTIVE_LOW>;
-                       linux,code = <108>;
+                       linux,code = <KEY_DOWN>;
                        label = "SW2-D";
                };
 
                home-key {
                        gpios = <&pcf8575 14 GPIO_ACTIVE_LOW>;
-                       linux,code = <102>;
+                       linux,code = <KEY_HOME>;
                        label = "SW1";
                };
        };
        };
 };
 
+&cmt1 {
+       status = "ok";
+};
+
 &i2c0 {
        status = "okay";
        as3711@40 {
 };
 
 &pfc {
-       pinctrl-0 = <&scifa4_pins>;
-       pinctrl-names = "default";
-
        i2c3_pins: i2c3 {
                renesas,groups = "i2c3_1";
                renesas,function = "i2c3";
        };
 };
 
+&scifa4 {
+       pinctrl-0 = <&scifa4_pins>;
+       pinctrl-names = "default";
+
+       status = "okay";
+};
+
 &sdhi0 {
        pinctrl-0 = <&sdhi0_pins>;
        pinctrl-names = "default";
index b7bd3b9..030a592 100644 (file)
@@ -14,6 +14,7 @@
 
 / {
        compatible = "renesas,sh73a0";
+       interrupt-parent = <&gic>;
 
        cpus {
                #address-cells = <1>;
                        device_type = "cpu";
                        compatible = "arm,cortex-a9";
                        reg = <0>;
+                       clock-frequency = <1196000000>;
                };
                cpu@1 {
                        device_type = "cpu";
                        compatible = "arm,cortex-a9";
                        reg = <1>;
+                       clock-frequency = <1196000000>;
                };
        };
 
        gic: interrupt-controller@f0001000 {
                compatible = "arm,cortex-a9-gic";
                #interrupt-cells = <3>;
-               #address-cells = <1>;
                interrupt-controller;
                reg = <0xf0001000 0x1000>,
                      <0xf0000100 0x100>;
                             <0 56 IRQ_TYPE_LEVEL_HIGH>;
        };
 
+       cmt1: timer@e6138000 {
+               compatible = "renesas,cmt-48-sh73a0", "renesas,cmt-48";
+               reg = <0xe6138000 0x200>;
+               interrupts = <0 65 IRQ_TYPE_LEVEL_HIGH>;
+
+               renesas,channels-mask = <0x3f>;
+
+               status = "disabled";
+       };
+
        irqpin0: irqpin@e6900000 {
                compatible = "renesas,intc-irqpin-sh73a0", "renesas,intc-irqpin";
                #interrupt-cells = <2>;
@@ -55,7 +67,6 @@
                        <0xe6900020 1>,
                        <0xe6900040 1>,
                        <0xe6900060 1>;
-               interrupt-parent = <&gic>;
                interrupts = <0 1 IRQ_TYPE_LEVEL_HIGH
                              0 2 IRQ_TYPE_LEVEL_HIGH
                              0 3 IRQ_TYPE_LEVEL_HIGH
@@ -75,7 +86,6 @@
                        <0xe6900024 1>,
                        <0xe6900044 1>,
                        <0xe6900064 1>;
-               interrupt-parent = <&gic>;
                interrupts = <0 9 IRQ_TYPE_LEVEL_HIGH
                              0 10 IRQ_TYPE_LEVEL_HIGH
                              0 11 IRQ_TYPE_LEVEL_HIGH
                        <0xe6900028 1>,
                        <0xe6900048 1>,
                        <0xe6900068 1>;
-               interrupt-parent = <&gic>;
                interrupts = <0 17 IRQ_TYPE_LEVEL_HIGH
                              0 18 IRQ_TYPE_LEVEL_HIGH
                              0 19 IRQ_TYPE_LEVEL_HIGH
                        <0xe690002c 1>,
                        <0xe690004c 1>,
                        <0xe690006c 1>;
-               interrupt-parent = <&gic>;
                interrupts = <0 25 IRQ_TYPE_LEVEL_HIGH
                              0 26 IRQ_TYPE_LEVEL_HIGH
                              0 27 IRQ_TYPE_LEVEL_HIGH
                #size-cells = <0>;
                compatible = "renesas,rmobile-iic";
                reg = <0xe6820000 0x425>;
-               interrupt-parent = <&gic>;
                interrupts = <0 167 IRQ_TYPE_LEVEL_HIGH
                              0 168 IRQ_TYPE_LEVEL_HIGH
                              0 169 IRQ_TYPE_LEVEL_HIGH
                #size-cells = <0>;
                compatible = "renesas,rmobile-iic";
                reg = <0xe6822000 0x425>;
-               interrupt-parent = <&gic>;
                interrupts = <0 51 IRQ_TYPE_LEVEL_HIGH
                              0 52 IRQ_TYPE_LEVEL_HIGH
                              0 53 IRQ_TYPE_LEVEL_HIGH
                #size-cells = <0>;
                compatible = "renesas,rmobile-iic";
                reg = <0xe6824000 0x425>;
-               interrupt-parent = <&gic>;
                interrupts = <0 171 IRQ_TYPE_LEVEL_HIGH
                              0 172 IRQ_TYPE_LEVEL_HIGH
                              0 173 IRQ_TYPE_LEVEL_HIGH
                #size-cells = <0>;
                compatible = "renesas,rmobile-iic";
                reg = <0xe6826000 0x425>;
-               interrupt-parent = <&gic>;
                interrupts = <0 183 IRQ_TYPE_LEVEL_HIGH
                              0 184 IRQ_TYPE_LEVEL_HIGH
                              0 185 IRQ_TYPE_LEVEL_HIGH
                #size-cells = <0>;
                compatible = "renesas,rmobile-iic";
                reg = <0xe6828000 0x425>;
-               interrupt-parent = <&gic>;
                interrupts = <0 187 IRQ_TYPE_LEVEL_HIGH
                              0 188 IRQ_TYPE_LEVEL_HIGH
                              0 189 IRQ_TYPE_LEVEL_HIGH
        mmcif: mmc@e6bd0000 {
                compatible = "renesas,sh-mmcif";
                reg = <0xe6bd0000 0x100>;
-               interrupt-parent = <&gic>;
                interrupts = <0 140 IRQ_TYPE_LEVEL_HIGH
                              0 141 IRQ_TYPE_LEVEL_HIGH>;
                reg-io-width = <4>;
        sdhi0: sd@ee100000 {
                compatible = "renesas,sdhi-sh73a0";
                reg = <0xee100000 0x100>;
-               interrupt-parent = <&gic>;
                interrupts = <0 83 IRQ_TYPE_LEVEL_HIGH
                              0 84 IRQ_TYPE_LEVEL_HIGH
                              0 85 IRQ_TYPE_LEVEL_HIGH>;
        sdhi1: sd@ee120000 {
                compatible = "renesas,sdhi-sh73a0";
                reg = <0xee120000 0x100>;
-               interrupt-parent = <&gic>;
                interrupts = <0 88 IRQ_TYPE_LEVEL_HIGH
                              0 89 IRQ_TYPE_LEVEL_HIGH>;
                toshiba,mmc-wrprotect-disable;
        sdhi2: sd@ee140000 {
                compatible = "renesas,sdhi-sh73a0";
                reg = <0xee140000 0x100>;
-               interrupt-parent = <&gic>;
                interrupts = <0 104 IRQ_TYPE_LEVEL_HIGH
                              0 105 IRQ_TYPE_LEVEL_HIGH>;
                toshiba,mmc-wrprotect-disable;
                status = "disabled";
        };
 
+       scifa0: serial@e6c40000 {
+               compatible = "renesas,scifa-sh73a0", "renesas,scifa";
+               reg = <0xe6c40000 0x100>;
+               interrupts = <0 72 IRQ_TYPE_LEVEL_HIGH>;
+               status = "disabled";
+       };
+
+       scifa1: serial@e6c50000 {
+               compatible = "renesas,scifa-sh73a0", "renesas,scifa";
+               reg = <0xe6c50000 0x100>;
+               interrupts = <0 73 IRQ_TYPE_LEVEL_HIGH>;
+               status = "disabled";
+       };
+
+       scifa2: serial@e6c60000 {
+               compatible = "renesas,scifa-sh73a0", "renesas,scifa";
+               reg = <0xe6c60000 0x100>;
+               interrupts = <0 74 IRQ_TYPE_LEVEL_HIGH>;
+               status = "disabled";
+       };
+
+       scifa3: serial@e6c70000 {
+               compatible = "renesas,scifa-sh73a0", "renesas,scifa";
+               reg = <0xe6c70000 0x100>;
+               interrupts = <0 75 IRQ_TYPE_LEVEL_HIGH>;
+               status = "disabled";
+       };
+
+       scifa4: serial@e6c80000 {
+               compatible = "renesas,scifa-sh73a0", "renesas,scifa";
+               reg = <0xe6c80000 0x100>;
+               interrupts = <0 78 IRQ_TYPE_LEVEL_HIGH>;
+               status = "disabled";
+       };
+
+       scifa5: serial@e6cb0000 {
+               compatible = "renesas,scifa-sh73a0", "renesas,scifa";
+               reg = <0xe6cb0000 0x100>;
+               interrupts = <0 79 IRQ_TYPE_LEVEL_HIGH>;
+               status = "disabled";
+       };
+
+       scifa6: serial@e6cc0000 {
+               compatible = "renesas,scifa-sh73a0", "renesas,scifa";
+               reg = <0xe6cc0000 0x100>;
+               interrupts = <0 156 IRQ_TYPE_LEVEL_HIGH>;
+               status = "disabled";
+       };
+
+       scifa7: serial@e6cd0000 {
+               compatible = "renesas,scifa-sh73a0", "renesas,scifa";
+               reg = <0xe6cd0000 0x100>;
+               interrupts = <0 143 IRQ_TYPE_LEVEL_HIGH>;
+               status = "disabled";
+       };
+
+       scifb8: serial@e6c30000 {
+               compatible = "renesas,scifb-sh73a0", "renesas,scifb";
+               reg = <0xe6c30000 0x100>;
+               interrupts = <0 80 IRQ_TYPE_LEVEL_HIGH>;
+               status = "disabled";
+       };
+
        pfc: pfc@e6050000 {
                compatible = "renesas,pfc-sh73a0";
                reg = <0xe6050000 0x8000>,
                #sound-dai-cells = <1>;
                compatible = "renesas,sh_fsi2";
                reg = <0xec230000 0x400>;
-               interrupt-parent = <&gic>;
                interrupts = <0 146 0x4>;
                status = "disabled";
        };
index cb26c62..b54b28f 100644 (file)
@@ -12,7 +12,6 @@ CONFIG_KALLSYMS_ALL=y
 CONFIG_EMBEDDED=y
 CONFIG_PERF_EVENTS=y
 CONFIG_SLAB=y
-# CONFIG_BLOCK is not set
 CONFIG_ARCH_SHMOBILE_LEGACY=y
 CONFIG_ARCH_R8A73A4=y
 CONFIG_MACH_APE6EVM=y
@@ -48,6 +47,8 @@ CONFIG_IP_PNP_DHCP=y
 # CONFIG_IPV6_SIT is not set
 CONFIG_NETFILTER=y
 CONFIG_UEVENT_HELPER_PATH="/sbin/hotplug"
+CONFIG_DEVTMPFS=y
+CONFIG_DEVTMPFS_MOUNT=y
 # CONFIG_FW_LOADER_USER_HELPER is not set
 CONFIG_NETDEVICES=y
 # CONFIG_NET_CADENCE is not set
@@ -62,6 +63,8 @@ CONFIG_SERIAL_NONSTANDARD=y
 CONFIG_SERIAL_SH_SCI=y
 CONFIG_SERIAL_SH_SCI_NR_UARTS=12
 CONFIG_SERIAL_SH_SCI_CONSOLE=y
+CONFIG_I2C=y
+CONFIG_I2C_SH_MOBILE=y
 CONFIG_GPIO_SH_PFC=y
 CONFIG_GPIOLIB=y
 # CONFIG_HWMON is not set
@@ -70,11 +73,17 @@ CONFIG_RCAR_THERMAL=y
 CONFIG_REGULATOR=y
 CONFIG_REGULATOR_FIXED_VOLTAGE=y
 CONFIG_REGULATOR_GPIO=y
+CONFIG_REGULATOR_MAX8973=y
 # CONFIG_HID is not set
 # CONFIG_USB_SUPPORT is not set
+CONFIG_MMC=y
+CONFIG_MMC_SDHI=y
+CONFIG_MMC_SH_MMCIF=y
 CONFIG_NEW_LEDS=y
 CONFIG_LEDS_CLASS=y
 CONFIG_LEDS_GPIO=y
+CONFIG_DMADEVICES=y
+CONFIG_SH_DMAE=y
 # CONFIG_IOMMU_SUPPORT is not set
 # CONFIG_DNOTIFY is not set
 CONFIG_TMPFS=y
index 9287a62..d9675c6 100644 (file)
@@ -58,6 +58,8 @@ CONFIG_IP_PNP_DHCP=y
 # CONFIG_IPV6 is not set
 # CONFIG_WIRELESS is not set
 CONFIG_UEVENT_HELPER_PATH="/sbin/hotplug"
+CONFIG_DEVTMPFS=y
+CONFIG_DEVTMPFS_MOUNT=y
 CONFIG_SCSI=y
 CONFIG_BLK_DEV_SD=y
 CONFIG_MD=y
@@ -94,6 +96,7 @@ CONFIG_I2C_GPIO=y
 CONFIG_I2C_SH_MOBILE=y
 # CONFIG_HWMON is not set
 CONFIG_REGULATOR=y
+CONFIG_REGULATOR_GPIO=y
 CONFIG_MEDIA_SUPPORT=y
 CONFIG_VIDEO_DEV=y
 CONFIG_MEDIA_CAMERA_SUPPORT=y
@@ -125,6 +128,9 @@ CONFIG_USB_ETH=m
 CONFIG_MMC=y
 CONFIG_MMC_SDHI=y
 CONFIG_MMC_SH_MMCIF=y
+CONFIG_NEW_LEDS=y
+CONFIG_LEDS_CLASS=y
+CONFIG_LEDS_GPIO=y
 CONFIG_RTC_CLASS=y
 CONFIG_RTC_DRV_S35390A=y
 CONFIG_DMADEVICES=y
index 5b54abb..60b0b93 100644 (file)
@@ -74,7 +74,6 @@ CONFIG_SOUND=y
 CONFIG_SOUND_PRIME=y
 CONFIG_USB=y
 CONFIG_USB_DEBUG=y
-CONFIG_USB_DEVICEFS=y
 CONFIG_USB_MON=y
 CONFIG_USB_ACM=m
 CONFIG_USB_PRINTER=m
index 80cff50..1dde5da 100644 (file)
@@ -29,7 +29,6 @@ CONFIG_ZBOOT_ROM_BSS=0x0
 CONFIG_ARM_APPENDED_DTB=y
 CONFIG_VFP=y
 # CONFIG_CORE_DUMP_DEFAULT_ELF_HEADERS is not set
-# CONFIG_SUSPEND is not set
 CONFIG_PM_RUNTIME=y
 CONFIG_NET=y
 CONFIG_PACKET=y
@@ -44,6 +43,8 @@ CONFIG_IP_PNP_DHCP=y
 # CONFIG_INET_DIAG is not set
 # CONFIG_IPV6 is not set
 CONFIG_UEVENT_HELPER_PATH="/sbin/hotplug"
+CONFIG_DEVTMPFS=y
+CONFIG_DEVTMPFS_MOUNT=y
 # CONFIG_STANDALONE is not set
 # CONFIG_PREVENT_FIRMWARE_BUILD is not set
 # CONFIG_FW_LOADER is not set
@@ -53,6 +54,7 @@ CONFIG_MTD_BLOCK=y
 CONFIG_MTD_CFI=y
 CONFIG_MTD_CFI_AMDSTD=y
 CONFIG_MTD_M25P80=y
+CONFIG_MTD_SPI_NOR=y
 CONFIG_SCSI=y
 CONFIG_BLK_DEV_SD=y
 CONFIG_NETDEVICES=y
@@ -80,6 +82,7 @@ CONFIG_SERIAL_SH_SCI_CONSOLE=y
 # CONFIG_HWMON is not set
 CONFIG_I2C=y
 CONFIG_I2C_RCAR=y
+CONFIG_GPIO_RCAR=y
 CONFIG_REGULATOR=y
 CONFIG_MEDIA_SUPPORT=y
 CONFIG_MEDIA_CAMERA_SUPPORT=y
index a93ff8d..dc01c04 100644 (file)
@@ -144,7 +144,6 @@ CONFIG_HID_SAMSUNG=y
 CONFIG_HID_SONY=y
 CONFIG_HID_SUNPLUS=y
 CONFIG_USB=y
-CONFIG_USB_DEVICEFS=y
 # CONFIG_USB_DEVICE_CLASS is not set
 CONFIG_USB_MON=y
 CONFIG_USB_OHCI_HCD=y
index f4b7672..7df040e 100644 (file)
@@ -129,7 +129,6 @@ CONFIG_HID_TOPSEED=y
 CONFIG_HID_THRUSTMASTER=y
 CONFIG_HID_ZEROPLUS=y
 CONFIG_USB=y
-CONFIG_USB_DEVICEFS=y
 # CONFIG_USB_DEVICE_CLASS is not set
 CONFIG_USB_MON=y
 CONFIG_USB_OHCI_HCD=y
index 2ef2c5e..18c311a 100644 (file)
@@ -124,7 +124,6 @@ CONFIG_FONT_8x16=y
 CONFIG_LOGO=y
 # CONFIG_USB_HID is not set
 CONFIG_USB=y
-CONFIG_USB_DEVICEFS=y
 # CONFIG_USB_DEVICE_CLASS is not set
 CONFIG_USB_SERIAL=m
 CONFIG_USB_GADGET=m
index b985334..2641dd6 100644 (file)
@@ -49,7 +49,6 @@ CONFIG_LOGO=y
 CONFIG_USB=y
 CONFIG_USB_DEBUG=y
 CONFIG_USB_ANNOUNCE_NEW_DEVICES=y
-CONFIG_USB_DEVICEFS=y
 CONFIG_USB_MON=y
 CONFIG_USB_STORAGE=y
 CONFIG_MMC=y
index 1fd1d1d..c1470a0 100644 (file)
@@ -172,7 +172,6 @@ CONFIG_HID_SAMSUNG=m
 CONFIG_HID_SONY=m
 CONFIG_HID_SUNPLUS=m
 CONFIG_USB=m
-CONFIG_USB_DEVICEFS=y
 CONFIG_USB_MON=m
 CONFIG_USB_SL811_HCD=m
 CONFIG_USB_SL811_CS=m
index ab2f737..24fb7a6 100644 (file)
@@ -134,7 +134,6 @@ CONFIG_HID_SAMSUNG=m
 CONFIG_HID_SONY=m
 CONFIG_HID_SUNPLUS=m
 CONFIG_USB=m
-CONFIG_USB_DEVICEFS=y
 CONFIG_USB_MON=m
 CONFIG_USB_MUSB_HDRC=m
 CONFIG_USB_MUSB_PERIPHERAL=y
index 60a21e0..4560c9c 100644 (file)
@@ -144,7 +144,6 @@ CONFIG_HID_SAMSUNG=y
 CONFIG_HID_SONY=y
 CONFIG_HID_SUNPLUS=y
 CONFIG_USB=y
-CONFIG_USB_DEVICEFS=y
 # CONFIG_USB_DEVICE_CLASS is not set
 CONFIG_USB_MON=y
 CONFIG_USB_OHCI_HCD=y
index 038518a..17bb3f7 100644 (file)
@@ -101,7 +101,6 @@ CONFIG_SOUND=m
 # CONFIG_USB_HID is not set
 CONFIG_USB=m
 CONFIG_USB_DEBUG=y
-CONFIG_USB_DEVICEFS=y
 CONFIG_USB_MON=m
 CONFIG_USB_PRINTER=m
 CONFIG_EXT2_FS=y
diff --git a/arch/arm/configs/genmai_defconfig b/arch/arm/configs/genmai_defconfig
deleted file mode 100644 (file)
index aa0b704..0000000
+++ /dev/null
@@ -1,116 +0,0 @@
-CONFIG_SYSVIPC=y
-CONFIG_NO_HZ=y
-CONFIG_IKCONFIG=y
-CONFIG_IKCONFIG_PROC=y
-CONFIG_LOG_BUF_SHIFT=16
-CONFIG_CC_OPTIMIZE_FOR_SIZE=y
-CONFIG_SYSCTL_SYSCALL=y
-CONFIG_EMBEDDED=y
-CONFIG_PERF_EVENTS=y
-CONFIG_SLAB=y
-# CONFIG_LBDAF is not set
-# CONFIG_BLK_DEV_BSG is not set
-# CONFIG_IOSCHED_DEADLINE is not set
-# CONFIG_IOSCHED_CFQ is not set
-CONFIG_ARCH_SHMOBILE_LEGACY=y
-CONFIG_ARCH_R7S72100=y
-CONFIG_MACH_GENMAI=y
-# CONFIG_SH_TIMER_CMT is not set
-# CONFIG_SH_TIMER_MTU2 is not set
-# CONFIG_SH_TIMER_TMU is not set
-# CONFIG_EM_TIMER_STI is not set
-CONFIG_ARM_ERRATA_430973=y
-CONFIG_ARM_ERRATA_458693=y
-CONFIG_ARM_ERRATA_460075=y
-CONFIG_ARM_ERRATA_743622=y
-CONFIG_ARM_ERRATA_754322=y
-CONFIG_AEABI=y
-# CONFIG_OABI_COMPAT is not set
-CONFIG_FORCE_MAX_ZONEORDER=13
-CONFIG_ZBOOT_ROM_TEXT=0x0
-CONFIG_ZBOOT_ROM_BSS=0x0
-CONFIG_ARM_APPENDED_DTB=y
-CONFIG_KEXEC=y
-CONFIG_AUTO_ZRELADDR=y
-CONFIG_VFP=y
-CONFIG_NEON=y
-# CONFIG_CORE_DUMP_DEFAULT_ELF_HEADERS is not set
-CONFIG_PM_RUNTIME=y
-CONFIG_NET=y
-CONFIG_PACKET=y
-CONFIG_UNIX=y
-CONFIG_INET=y
-CONFIG_IP_PNP=y
-CONFIG_IP_PNP_DHCP=y
-# CONFIG_INET_XFRM_MODE_TRANSPORT is not set
-# CONFIG_INET_XFRM_MODE_TUNNEL is not set
-# CONFIG_INET_XFRM_MODE_BEET is not set
-# CONFIG_INET_LRO is not set
-# CONFIG_INET_DIAG is not set
-# CONFIG_IPV6 is not set
-# CONFIG_WIRELESS is not set
-CONFIG_UEVENT_HELPER_PATH="/sbin/hotplug"
-CONFIG_NETDEVICES=y
-# CONFIG_NET_CORE is not set
-# CONFIG_NET_VENDOR_ARC is not set
-# CONFIG_NET_CADENCE is not set
-# CONFIG_NET_VENDOR_BROADCOM is not set
-# CONFIG_NET_VENDOR_CIRRUS is not set
-# CONFIG_NET_VENDOR_FARADAY is not set
-# CONFIG_NET_VENDOR_INTEL is not set
-# CONFIG_NET_VENDOR_MARVELL is not set
-# CONFIG_NET_VENDOR_MICREL is not set
-# CONFIG_NET_VENDOR_NATSEMI is not set
-CONFIG_SH_ETH=y
-# CONFIG_NET_VENDOR_SEEQ is not set
-# CONFIG_NET_VENDOR_SMSC is not set
-# CONFIG_NET_VENDOR_STMICRO is not set
-# CONFIG_NET_VENDOR_VIA is not set
-# CONFIG_NET_VENDOR_WIZNET is not set
-# CONFIG_WLAN is not set
-# CONFIG_INPUT_MOUSEDEV_PSAUX is not set
-CONFIG_INPUT_EVDEV=y
-# CONFIG_KEYBOARD_ATKBD is not set
-# CONFIG_INPUT_MOUSE is not set
-# CONFIG_SERIO is not set
-# CONFIG_LEGACY_PTYS is not set
-CONFIG_SERIAL_SH_SCI=y
-CONFIG_SERIAL_SH_SCI_NR_UARTS=10
-CONFIG_SERIAL_SH_SCI_CONSOLE=y
-# CONFIG_HW_RANDOM is not set
-CONFIG_I2C_SH_MOBILE=y
-# CONFIG_HWMON is not set
-CONFIG_THERMAL=y
-CONFIG_RCAR_THERMAL=y
-CONFIG_REGULATOR=y
-CONFIG_REGULATOR_FIXED_VOLTAGE=y
-CONFIG_DRM=y
-CONFIG_DRM_RCAR_DU=y
-# CONFIG_USB_SUPPORT is not set
-CONFIG_MMC=y
-CONFIG_MMC_SDHI=y
-CONFIG_MMC_SH_MMCIF=y
-CONFIG_NEW_LEDS=y
-CONFIG_LEDS_CLASS=y
-CONFIG_RTC_CLASS=y
-CONFIG_DMADEVICES=y
-CONFIG_SH_DMAE=y
-# CONFIG_IOMMU_SUPPORT is not set
-# CONFIG_DNOTIFY is not set
-CONFIG_MSDOS_FS=y
-CONFIG_VFAT_FS=y
-CONFIG_TMPFS=y
-CONFIG_CONFIGFS_FS=y
-# CONFIG_MISC_FILESYSTEMS is not set
-CONFIG_NFS_FS=y
-CONFIG_NFS_V3_ACL=y
-CONFIG_NFS_V4=y
-CONFIG_NFS_V4_1=y
-CONFIG_ROOT_NFS=y
-CONFIG_NLS_CODEPAGE_437=y
-CONFIG_NLS_ISO8859_1=y
-# CONFIG_ENABLE_WARN_DEPRECATED is not set
-# CONFIG_ENABLE_MUST_CHECK is not set
-# CONFIG_ARM_UNWIND is not set
-# CONFIG_CRYPTO_ANSI_CPRNG is not set
-# CONFIG_CRYPTO_HW is not set
index 063e2ab..1af665e 100644 (file)
@@ -169,7 +169,6 @@ CONFIG_SENSORS_W83781D=y
 CONFIG_WATCHDOG=y
 CONFIG_IXP4XX_WATCHDOG=y
 CONFIG_USB=y
-CONFIG_USB_DEVICEFS=y
 # CONFIG_USB_DEVICE_CLASS is not set
 CONFIG_USB_EHCI_HCD=y
 CONFIG_USB_OHCI_HCD=y
index e248f49..b33d19b 100644 (file)
@@ -8,7 +8,6 @@ CONFIG_SYSCTL_SYSCALL=y
 CONFIG_EMBEDDED=y
 CONFIG_PERF_EVENTS=y
 CONFIG_SLAB=y
-# CONFIG_BLOCK is not set
 CONFIG_ARCH_SHMOBILE_LEGACY=y
 CONFIG_ARCH_R8A7791=y
 CONFIG_MACH_KOELSCH=y
@@ -16,6 +15,9 @@ CONFIG_MACH_KOELSCH=y
 CONFIG_CPU_BPREDICT_DISABLE=y
 CONFIG_PL310_ERRATA_588369=y
 CONFIG_ARM_ERRATA_754322=y
+CONFIG_PCI=y
+CONFIG_PCI_RCAR_GEN2=y
+CONFIG_PCI_RCAR_GEN2_PCIE=y
 CONFIG_SMP=y
 CONFIG_SCHED_MC=y
 CONFIG_NR_CPUS=8
@@ -35,7 +37,16 @@ CONFIG_UNIX=y
 CONFIG_INET=y
 CONFIG_IP_PNP=y
 CONFIG_IP_PNP_DHCP=y
+CONFIG_DEVTMPFS=y
+CONFIG_DEVTMPFS_MOUNT=y
 CONFIG_UEVENT_HELPER_PATH="/sbin/hotplug"
+CONFIG_BLK_DEV_SD=y
+CONFIG_ATA=y
+CONFIG_SATA_RCAR=y
+CONFIG_MTD=y
+CONFIG_MTD_M25P80=y
+CONFIG_MTD_SPI_NOR=y
+CONFIG_EEPROM_AT24=y
 CONFIG_NETDEVICES=y
 # CONFIG_NET_VENDOR_ARC is not set
 # CONFIG_NET_CADENCE is not set
@@ -53,18 +64,43 @@ CONFIG_SH_ETH=y
 # CONFIG_NET_VENDOR_VIA is not set
 # CONFIG_NET_VENDOR_WIZNET is not set
 # CONFIG_INPUT_MOUSEDEV_PSAUX is not set
+CONFIG_KEYBOARD_GPIO=y
 # CONFIG_INPUT_MOUSE is not set
 # CONFIG_LEGACY_PTYS is not set
 CONFIG_SERIAL_SH_SCI=y
 CONFIG_SERIAL_SH_SCI_NR_UARTS=20
 CONFIG_SERIAL_SH_SCI_CONSOLE=y
+CONFIG_I2C=y
+CONFIG_I2C_MUX=y
+CONFIG_I2C_SH_MOBILE=y
+CONFIG_I2C_RCAR=y
+CONFIG_SPI=y
+CONFIG_SPI_RSPI=y
+CONFIG_SPI_SH_MSIOF=y
+CONFIG_GPIOLIB=y
+CONFIG_GPIO_RCAR=y
 # CONFIG_HWMON is not set
 CONFIG_THERMAL=y
 CONFIG_RCAR_THERMAL=y
+CONFIG_REGULATOR=y
+CONFIG_REGULATOR_FIXED_VOLTAGE=y
+CONFIG_REGULATOR_DA9210=y
+CONFIG_REGULATOR_GPIO=y
+CONFIG_MEDIA_SUPPORT=y
+CONFIG_MEDIA_CAMERA_SUPPORT=y
+CONFIG_V4L_PLATFORM_DRIVERS=y
+CONFIG_SOC_CAMERA=y
+CONFIG_SOC_CAMERA_PLATFORM=y
+CONFIG_VIDEO_RCAR_VIN=y
+# CONFIG_MEDIA_SUBDRV_AUTOSELECT is not set
+CONFIG_VIDEO_ADV7180=y
 # CONFIG_HID is not set
 # CONFIG_USB_SUPPORT is not set
+CONFIG_MMC=y
+CONFIG_MMC_SDHI=y
 CONFIG_NEW_LEDS=y
 CONFIG_LEDS_CLASS=y
+CONFIG_LEDS_GPIO=y
 # CONFIG_IOMMU_SUPPORT is not set
 # CONFIG_DNOTIFY is not set
 CONFIG_TMPFS=y
diff --git a/arch/arm/configs/kzm9d_defconfig b/arch/arm/configs/kzm9d_defconfig
deleted file mode 100644 (file)
index e42ce37..0000000
+++ /dev/null
@@ -1,89 +0,0 @@
-# CONFIG_ARM_PATCH_PHYS_VIRT is not set
-CONFIG_EXPERIMENTAL=y
-CONFIG_SYSVIPC=y
-CONFIG_NO_HZ=y
-CONFIG_IKCONFIG=y
-CONFIG_IKCONFIG_PROC=y
-CONFIG_LOG_BUF_SHIFT=16
-CONFIG_CC_OPTIMIZE_FOR_SIZE=y
-CONFIG_SYSCTL_SYSCALL=y
-CONFIG_EMBEDDED=y
-CONFIG_PERF_EVENTS=y
-CONFIG_SLAB=y
-# CONFIG_BLK_DEV_BSG is not set
-# CONFIG_IOSCHED_DEADLINE is not set
-# CONFIG_IOSCHED_CFQ is not set
-CONFIG_ARCH_SHMOBILE_LEGACY=y
-CONFIG_ARCH_EMEV2=y
-CONFIG_MACH_KZM9D=y
-CONFIG_MEMORY_START=0x40000000
-CONFIG_MEMORY_SIZE=0x10000000
-# CONFIG_SH_TIMER_TMU is not set
-# CONFIG_SWP_EMULATE is not set
-# CONFIG_CACHE_L2X0 is not set
-CONFIG_SMP=y
-CONFIG_NR_CPUS=2
-CONFIG_HOTPLUG_CPU=y
-# CONFIG_LOCAL_TIMERS is not set
-CONFIG_AEABI=y
-# CONFIG_OABI_COMPAT is not set
-# CONFIG_CROSS_MEMORY_ATTACH is not set
-CONFIG_FORCE_MAX_ZONEORDER=13
-CONFIG_ZBOOT_ROM_TEXT=0x0
-CONFIG_ZBOOT_ROM_BSS=0x0
-CONFIG_ARM_APPENDED_DTB=y
-CONFIG_AUTO_ZRELADDR=y
-CONFIG_VFP=y
-# CONFIG_CORE_DUMP_DEFAULT_ELF_HEADERS is not set
-CONFIG_PM_RUNTIME=y
-CONFIG_NET=y
-CONFIG_PACKET=y
-CONFIG_UNIX=y
-CONFIG_INET=y
-CONFIG_IP_PNP=y
-CONFIG_IP_PNP_DHCP=y
-# CONFIG_INET_XFRM_MODE_TRANSPORT is not set
-# CONFIG_INET_XFRM_MODE_TUNNEL is not set
-# CONFIG_INET_XFRM_MODE_BEET is not set
-# CONFIG_INET_LRO is not set
-# CONFIG_INET_DIAG is not set
-# CONFIG_IPV6 is not set
-# CONFIG_WIRELESS is not set
-CONFIG_UEVENT_HELPER_PATH="/sbin/hotplug"
-# CONFIG_BLK_DEV is not set
-CONFIG_NETDEVICES=y
-# CONFIG_NET_VENDOR_BROADCOM is not set
-# CONFIG_NET_VENDOR_CHELSIO is not set
-# CONFIG_NET_VENDOR_CIRRUS is not set
-# CONFIG_NET_VENDOR_FARADAY is not set
-# CONFIG_NET_VENDOR_INTEL is not set
-# CONFIG_NET_VENDOR_MARVELL is not set
-# CONFIG_NET_VENDOR_MICREL is not set
-# CONFIG_NET_VENDOR_NATSEMI is not set
-# CONFIG_NET_VENDOR_SEEQ is not set
-CONFIG_SMSC911X=y
-# CONFIG_NET_VENDOR_STMICRO is not set
-# CONFIG_NET_VENDOR_WIZNET is not set
-# CONFIG_WLAN is not set
-# CONFIG_INPUT_MOUSEDEV is not set
-# CONFIG_INPUT_KEYBOARD is not set
-# CONFIG_INPUT_MOUSE is not set
-# CONFIG_SERIO is not set
-# CONFIG_LEGACY_PTYS is not set
-# CONFIG_DEVKMEM is not set
-CONFIG_SERIAL_8250=y
-CONFIG_SERIAL_8250_CONSOLE=y
-CONFIG_SERIAL_8250_EM=y
-# CONFIG_HW_RANDOM is not set
-CONFIG_GPIOLIB=y
-CONFIG_GPIO_EM=y
-# CONFIG_HWMON is not set
-# CONFIG_HID_SUPPORT is not set
-# CONFIG_USB_SUPPORT is not set
-# CONFIG_IOMMU_SUPPORT is not set
-# CONFIG_DNOTIFY is not set
-CONFIG_TMPFS=y
-# CONFIG_MISC_FILESYSTEMS is not set
-CONFIG_NFS_FS=y
-CONFIG_ROOT_NFS=y
-# CONFIG_FTRACE is not set
index 9934dbc..8cb115d 100644 (file)
@@ -60,6 +60,8 @@ CONFIG_IRDA=y
 CONFIG_SH_IRDA=y
 # CONFIG_WIRELESS is not set
 CONFIG_UEVENT_HELPER_PATH="/sbin/hotplug"
+CONFIG_DEVTMPFS=y
+CONFIG_DEVTMPFS_MOUNT=y
 CONFIG_SCSI=y
 CONFIG_BLK_DEV_SD=y
 CONFIG_NETDEVICES=y
@@ -104,7 +106,6 @@ CONFIG_SND_SOC=y
 CONFIG_SND_SOC_SH4_FSI=y
 # CONFIG_HID_SUPPORT is not set
 CONFIG_USB=y
-CONFIG_USB_DEVICEFS=y
 CONFIG_USB_R8A66597_HCD=y
 CONFIG_USB_RENESAS_USBHS=y
 CONFIG_USB_STORAGE=y
@@ -118,6 +119,7 @@ CONFIG_MMC_SDHI=y
 CONFIG_MMC_SH_MMCIF=y
 CONFIG_NEW_LEDS=y
 CONFIG_LEDS_CLASS=y
+CONFIG_LEDS_GPIO=y
 CONFIG_RTC_CLASS=y
 CONFIG_RTC_DRV_RS5C372=y
 CONFIG_DMADEVICES=y
index 883443f..929c571 100644 (file)
@@ -22,6 +22,9 @@ CONFIG_ARM_ERRATA_458693=y
 CONFIG_ARM_ERRATA_460075=y
 CONFIG_ARM_ERRATA_743622=y
 CONFIG_ARM_ERRATA_754322=y
+CONFIG_PCI=y
+CONFIG_PCI_RCAR_GEN2=y
+CONFIG_PCI_RCAR_GEN2_PCIE=y
 CONFIG_HAVE_ARM_ARCH_TIMER=y
 CONFIG_AEABI=y
 # CONFIG_OABI_COMPAT is not set
@@ -49,6 +52,14 @@ CONFIG_IP_PNP_DHCP=y
 # CONFIG_IPV6 is not set
 # CONFIG_WIRELESS is not set
 CONFIG_UEVENT_HELPER_PATH="/sbin/hotplug"
+CONFIG_DEVTMPFS=y
+CONFIG_DEVTMPFS_MOUNT=y
+CONFIG_MTD=y
+CONFIG_MTD_M25P80=y
+CONFIG_MTD_SPI_NOR=y
+CONFIG_BLK_DEV_SD=y
+CONFIG_ATA=y
+CONFIG_SATA_RCAR=y
 CONFIG_NETDEVICES=y
 # CONFIG_NET_CORE is not set
 # CONFIG_NET_VENDOR_ARC is not set
@@ -78,9 +89,12 @@ CONFIG_SERIAL_SH_SCI=y
 CONFIG_SERIAL_SH_SCI_NR_UARTS=10
 CONFIG_SERIAL_SH_SCI_CONSOLE=y
 # CONFIG_HW_RANDOM is not set
-CONFIG_I2C=y
 CONFIG_I2C_GPIO=y
+CONFIG_I2C_SH_MOBILE=y
 CONFIG_I2C_RCAR=y
+CONFIG_SPI=y
+CONFIG_SPI_RSPI=y
+CONFIG_SPI_SH_MSIOF=y
 CONFIG_GPIO_SH_PFC=y
 CONFIG_GPIOLIB=y
 CONFIG_GPIO_RCAR=y
@@ -89,9 +103,22 @@ CONFIG_THERMAL=y
 CONFIG_RCAR_THERMAL=y
 CONFIG_REGULATOR=y
 CONFIG_REGULATOR_FIXED_VOLTAGE=y
+CONFIG_REGULATOR_DA9210=y
 CONFIG_REGULATOR_GPIO=y
+CONFIG_MEDIA_SUPPORT=y
+CONFIG_MEDIA_CAMERA_SUPPORT=y
+CONFIG_V4L_PLATFORM_DRIVERS=y
+CONFIG_SOC_CAMERA=y
+CONFIG_SOC_CAMERA_PLATFORM=y
+CONFIG_VIDEO_RCAR_VIN=y
+# CONFIG_MEDIA_SUBDRV_AUTOSELECT is not set
+CONFIG_VIDEO_ADV7180=y
 CONFIG_DRM=y
 CONFIG_DRM_RCAR_DU=y
+CONFIG_SOUND=y
+CONFIG_SND=y
+CONFIG_SND_SOC=y
+CONFIG_SND_SOC_RCAR=y
 # CONFIG_USB_SUPPORT is not set
 CONFIG_MMC=y
 CONFIG_MMC_SDHI=y
index a61e165..57ececb 100644 (file)
@@ -42,6 +42,8 @@ CONFIG_IP_PNP_DHCP=y
 # CONFIG_IPV6 is not set
 # CONFIG_WIRELESS is not set
 CONFIG_UEVENT_HELPER_PATH="/sbin/hotplug"
+CONFIG_DEVTMPFS=y
+CONFIG_DEVTMPFS_MOUNT=y
 # CONFIG_FIRMWARE_IN_KERNEL is not set
 CONFIG_MTD=y
 CONFIG_MTD_CONCAT=y
index f21bd40..ff91630 100644 (file)
@@ -43,6 +43,8 @@ CONFIG_IP_PNP_DHCP=y
 # CONFIG_IPV6 is not set
 # CONFIG_WIRELESS is not set
 CONFIG_UEVENT_HELPER_PATH="/sbin/hotplug"
+CONFIG_DEVTMPFS=y
+CONFIG_DEVTMPFS_MOUNT=y
 # CONFIG_STANDALONE is not set
 # CONFIG_PREVENT_FIRMWARE_BUILD is not set
 # CONFIG_FW_LOADER is not set
@@ -82,6 +84,7 @@ CONFIG_GPIO_RCAR=y
 CONFIG_THERMAL=y
 CONFIG_RCAR_THERMAL=y
 CONFIG_SSB=y
+CONFIG_REGULATOR=y
 CONFIG_MEDIA_SUPPORT=y
 CONFIG_MEDIA_CAMERA_SUPPORT=y
 CONFIG_V4L_PLATFORM_DRIVERS=y
index a07948a..9c93f56 100644 (file)
@@ -217,7 +217,6 @@ CONFIG_HID_SONY=y
 CONFIG_HID_SUNPLUS=y
 CONFIG_HID_TOPSEED=y
 CONFIG_USB=y
-CONFIG_USB_DEVICEFS=y
 # CONFIG_USB_DEVICE_CLASS is not set
 CONFIG_USB_OHCI_HCD=y
 CONFIG_USB_ACM=m
index 1f08219..0dae1c1 100644 (file)
@@ -80,7 +80,6 @@ CONFIG_I2C=y
 CONFIG_I2C_CHARDEV=y
 CONFIG_I2C_MV64XXX=y
 CONFIG_USB=y
-CONFIG_USB_DEVICEFS=y
 CONFIG_USB_EHCI_HCD=y
 CONFIG_USB_EHCI_ROOT_HUB_TT=y
 CONFIG_USB_EHCI_TT_NEWSCHED=y
index d7dc992..63aa319 100644 (file)
@@ -69,7 +69,6 @@ CONFIG_SOUND_PRIME=y
 # CONFIG_USB_HID is not set
 CONFIG_USB=m
 CONFIG_USB_DEBUG=y
-CONFIG_USB_DEVICEFS=y
 CONFIG_USB_MON=m
 CONFIG_USB_OHCI_HCD=m
 CONFIG_USB_STORAGE=m
index d74edba..0f258d5 100644 (file)
@@ -198,7 +198,6 @@ CONFIG_SND_OMAP_SOC=y
 CONFIG_USB=y
 CONFIG_USB_PHY=y
 CONFIG_USB_DEBUG=y
-CONFIG_USB_DEVICEFS=y
 # CONFIG_USB_DEVICE_CLASS is not set
 CONFIG_USB_MON=y
 CONFIG_USB_OHCI_HCD=y
index 2f136c3..0a847d0 100644 (file)
@@ -76,7 +76,6 @@ CONFIG_SND_PCM_OSS=y
 CONFIG_SND_PXA2XX_AC97=y
 # CONFIG_HID_SUPPORT is not set
 CONFIG_USB=y
-CONFIG_USB_DEVICEFS=y
 CONFIG_USB_OHCI_HCD=y
 CONFIG_USB_STORAGE=y
 CONFIG_MMC=y
index 193448f..eb4d204 100644 (file)
@@ -324,7 +324,6 @@ CONFIG_SND_USB_CAIAQ=m
 CONFIG_SND_SOC=y
 # CONFIG_USB_HID is not set
 CONFIG_USB=y
-CONFIG_USB_DEVICEFS=y
 CONFIG_USB_MON=y
 CONFIG_USB_OHCI_HCD=y
 CONFIG_USB_ACM=m
index 3a186d6..e2f9fa5 100644 (file)
@@ -56,7 +56,6 @@ CONFIG_SND_S3C24XX_SOC=m
 CONFIG_SND_SOC_SMDK_WM9713=m
 CONFIG_USB=y
 CONFIG_USB_ANNOUNCE_NEW_DEVICES=y
-CONFIG_USB_DEVICEFS=y
 CONFIG_USB_OHCI_HCD=y
 CONFIG_USB_ACM=m
 CONFIG_USB_PRINTER=m
diff --git a/arch/arm/configs/shmobile_defconfig b/arch/arm/configs/shmobile_defconfig
new file mode 100644 (file)
index 0000000..d7346ad
--- /dev/null
@@ -0,0 +1,180 @@
+CONFIG_SYSVIPC=y
+CONFIG_NO_HZ=y
+CONFIG_IKCONFIG=y
+CONFIG_IKCONFIG_PROC=y
+CONFIG_LOG_BUF_SHIFT=16
+CONFIG_BLK_DEV_INITRD=y
+CONFIG_CC_OPTIMIZE_FOR_SIZE=y
+CONFIG_SYSCTL_SYSCALL=y
+CONFIG_EMBEDDED=y
+CONFIG_PERF_EVENTS=y
+CONFIG_SLAB=y
+CONFIG_ARCH_SHMOBILE_MULTI=y
+CONFIG_ARCH_EMEV2=y
+CONFIG_ARCH_R7S72100=y
+CONFIG_ARCH_R8A7740=y
+CONFIG_ARCH_R8A7779=y
+CONFIG_ARCH_R8A7790=y
+CONFIG_ARCH_R8A7791=y
+CONFIG_ARCH_R8A7794=y
+CONFIG_MACH_KOELSCH=y
+CONFIG_MACH_LAGER=y
+CONFIG_MACH_MARZEN=y
+# CONFIG_SWP_EMULATE is not set
+CONFIG_CPU_BPREDICT_DISABLE=y
+CONFIG_PL310_ERRATA_588369=y
+CONFIG_ARM_ERRATA_754322=y
+CONFIG_PCI=y
+CONFIG_PCI_RCAR_GEN2=y
+CONFIG_PCI_RCAR_GEN2_PCIE=y
+CONFIG_SMP=y
+CONFIG_SCHED_MC=y
+CONFIG_HAVE_ARM_ARCH_TIMER=y
+CONFIG_NR_CPUS=8
+CONFIG_AEABI=y
+CONFIG_HIGHMEM=y
+CONFIG_ZBOOT_ROM_TEXT=0x0
+CONFIG_ZBOOT_ROM_BSS=0x0
+CONFIG_ARM_APPENDED_DTB=y
+CONFIG_KEXEC=y
+CONFIG_VFP=y
+CONFIG_NEON=y
+# CONFIG_CORE_DUMP_DEFAULT_ELF_HEADERS is not set
+CONFIG_PM_RUNTIME=y
+CONFIG_NET=y
+CONFIG_PACKET=y
+CONFIG_UNIX=y
+CONFIG_INET=y
+CONFIG_IP_PNP=y
+CONFIG_IP_PNP_DHCP=y
+CONFIG_UEVENT_HELPER_PATH="/sbin/hotplug"
+CONFIG_DEVTMPFS=y
+CONFIG_DEVTMPFS_MOUNT=y
+CONFIG_MTD=y
+CONFIG_MTD_M25P80=y
+CONFIG_MTD_SPI_NOR=y
+CONFIG_EEPROM_AT24=y
+CONFIG_BLK_DEV_SD=y
+CONFIG_ATA=y
+CONFIG_SATA_RCAR=y
+CONFIG_NETDEVICES=y
+# CONFIG_NET_VENDOR_ARC is not set
+# CONFIG_NET_CADENCE is not set
+# CONFIG_NET_VENDOR_BROADCOM is not set
+# CONFIG_NET_VENDOR_CIRRUS is not set
+# CONFIG_NET_VENDOR_FARADAY is not set
+# CONFIG_NET_VENDOR_INTEL is not set
+# CONFIG_NET_VENDOR_MARVELL is not set
+# CONFIG_NET_VENDOR_MICREL is not set
+# CONFIG_NET_VENDOR_NATSEMI is not set
+CONFIG_SH_ETH=y
+# CONFIG_NET_VENDOR_SEEQ is not set
+CONFIG_SMSC911X=y
+# CONFIG_NET_VENDOR_STMICRO is not set
+# CONFIG_NET_VENDOR_VIA is not set
+# CONFIG_NET_VENDOR_WIZNET is not set
+CONFIG_SMSC_PHY=y
+# CONFIG_INPUT_MOUSEDEV_PSAUX is not set
+CONFIG_KEYBOARD_GPIO=y
+# CONFIG_INPUT_MOUSE is not set
+CONFIG_INPUT_TOUCHSCREEN=y
+CONFIG_TOUCHSCREEN_ST1232=y
+# CONFIG_LEGACY_PTYS is not set
+CONFIG_SERIAL_8250=y
+CONFIG_SERIAL_8250_CONSOLE=y
+CONFIG_SERIAL_8250_EXTENDED=y
+CONFIG_SERIAL_8250_EM=y
+CONFIG_SERIAL_SH_SCI=y
+CONFIG_SERIAL_SH_SCI_NR_UARTS=20
+CONFIG_SERIAL_SH_SCI_CONSOLE=y
+CONFIG_I2C_GPIO=y
+CONFIG_I2C_RIIC=y
+CONFIG_I2C_SH_MOBILE=y
+CONFIG_I2C_RCAR=y
+CONFIG_SPI=y
+CONFIG_SPI_RSPI=y
+CONFIG_SPI_SH_MSIOF=y
+CONFIG_SPI_SH_HSPI=y
+CONFIG_GPIO_EM=y
+CONFIG_GPIO_RCAR=y
+# CONFIG_HWMON is not set
+CONFIG_THERMAL=y
+CONFIG_RCAR_THERMAL=y
+CONFIG_REGULATOR=y
+CONFIG_REGULATOR_FIXED_VOLTAGE=y
+CONFIG_REGULATOR_GPIO=y
+CONFIG_MEDIA_SUPPORT=y
+CONFIG_MEDIA_CAMERA_SUPPORT=y
+CONFIG_MEDIA_CONTROLLER=y
+CONFIG_VIDEO_V4L2_SUBDEV_API=y
+CONFIG_V4L_PLATFORM_DRIVERS=y
+CONFIG_SOC_CAMERA=y
+CONFIG_SOC_CAMERA_PLATFORM=y
+CONFIG_VIDEO_RCAR_VIN=y
+CONFIG_V4L_MEM2MEM_DRIVERS=y
+CONFIG_VIDEO_RENESAS_VSP1=y
+# CONFIG_MEDIA_SUBDRV_AUTOSELECT is not set
+CONFIG_VIDEO_ADV7180=y
+CONFIG_DRM=y
+CONFIG_DRM_RCAR_DU=y
+CONFIG_BACKLIGHT_LCD_SUPPORT=y
+# CONFIG_LCD_CLASS_DEVICE is not set
+# CONFIG_BACKLIGHT_GENERIC is not set
+CONFIG_BACKLIGHT_PWM=y
+CONFIG_SOUND=y
+CONFIG_SND=y
+CONFIG_SND_SOC=y
+CONFIG_SND_SOC_SH4_FSI=y
+CONFIG_SND_SOC_RCAR=y
+CONFIG_SND_SOC_WM8978=y
+CONFIG_USB=y
+CONFIG_USB_EHCI_HCD=y
+CONFIG_USB_OHCI_HCD=y
+CONFIG_USB_RENESAS_USBHS=y
+CONFIG_USB_RCAR_PHY=y
+CONFIG_USB_RCAR_GEN2_PHY=y
+CONFIG_USB_GADGET=y
+CONFIG_USB_RENESAS_USBHS_UDC=y
+CONFIG_USB_ETH=y
+CONFIG_MMC=y
+CONFIG_MMC_SDHI=y
+CONFIG_MMC_SH_MMCIF=y
+CONFIG_NEW_LEDS=y
+CONFIG_LEDS_CLASS=y
+CONFIG_LEDS_GPIO=y
+CONFIG_RTC_CLASS=y
+CONFIG_RTC_DRV_S35390A=y
+CONFIG_DMADEVICES=y
+CONFIG_SH_DMAE=y
+# CONFIG_IOMMU_SUPPORT is not set
+CONFIG_PWM=y
+CONFIG_PWM_RENESAS_TPU=y
+# CONFIG_DNOTIFY is not set
+CONFIG_MSDOS_FS=y
+CONFIG_VFAT_FS=y
+CONFIG_TMPFS=y
+CONFIG_CONFIGFS_FS=y
+# CONFIG_MISC_FILESYSTEMS is not set
+CONFIG_NFS_FS=y
+CONFIG_NFS_V3_ACL=y
+CONFIG_NFS_V4=y
+CONFIG_NFS_V4_1=y
+CONFIG_ROOT_NFS=y
+CONFIG_NLS_CODEPAGE_437=y
+CONFIG_NLS_ISO8859_1=y
+# CONFIG_ENABLE_WARN_DEPRECATED is not set
+# CONFIG_ENABLE_MUST_CHECK is not set
+# CONFIG_ARM_UNWIND is not set
+CONFIG_CPU_FREQ=y
+CONFIG_CPU_FREQ_GOV_COMMON=y
+CONFIG_CPU_FREQ_STAT=y
+CONFIG_CPU_FREQ_STAT_DETAILS=y
+CONFIG_CPU_FREQ_DEFAULT_GOV_PERFORMANCE=y
+CONFIG_CPU_FREQ_GOV_PERFORMANCE=y
+CONFIG_CPU_FREQ_GOV_POWERSAVE=y
+CONFIG_CPU_FREQ_GOV_USERSPACE=y
+CONFIG_CPU_FREQ_GOV_ONDEMAND=y
+CONFIG_CPU_FREQ_GOV_CONSERVATIVE=y
+CONFIG_CPU_THERMAL=y
+CONFIG_GENERIC_CPUFREQ_CPU0=y
+CONFIG_REGULATOR_DA9210=y
index 2e0419d..a1ede19 100644 (file)
@@ -166,7 +166,6 @@ CONFIG_HID_SAMSUNG=m
 CONFIG_HID_SONY=m
 CONFIG_HID_SUNPLUS=m
 CONFIG_USB=m
-CONFIG_USB_DEVICEFS=y
 CONFIG_USB_MON=m
 CONFIG_USB_OHCI_HCD=m
 CONFIG_USB_SL811_HCD=m
index 3162173..932ee4e 100644 (file)
@@ -165,7 +165,6 @@ CONFIG_SND_PXA2XX_AC97=y
 CONFIG_SND_USB_AUDIO=m
 # CONFIG_USB_HID is not set
 CONFIG_USB=y
-CONFIG_USB_DEVICEFS=y
 # CONFIG_USB_DEVICE_CLASS is not set
 CONFIG_USB_OHCI_HCD=y
 CONFIG_USB_STORAGE=m
index d36e0d3..0d717a5 100644 (file)
@@ -127,7 +127,6 @@ CONFIG_SND_MIXER_OSS=m
 CONFIG_SND_PCM_OSS=m
 CONFIG_SND_PXA2XX_AC97=m
 CONFIG_USB=m
-CONFIG_USB_DEVICEFS=y
 CONFIG_USB_ISP116X_HCD=m
 CONFIG_USB_SL811_HCD=m
 CONFIG_USB_R8A66597_HCD=m
index 731d4f9..cd11da8 100644 (file)
@@ -132,7 +132,6 @@ CONFIG_SND_SOC=m
 CONFIG_SND_PXA2XX_SOC=m
 # CONFIG_HID_SUPPORT is not set
 CONFIG_USB=m
-CONFIG_USB_DEVICEFS=y
 CONFIG_USB_OHCI_HCD=m
 CONFIG_USB_ACM=m
 CONFIG_USB_STORAGE=m
index 0704e0c..92793ba 100644 (file)
@@ -99,31 +99,6 @@ static inline void arch_timer_set_cntkctl(u32 cntkctl)
        asm volatile("mcr p15, 0, %0, c14, c1, 0" : : "r" (cntkctl));
 }
 
-static inline void arch_counter_set_user_access(void)
-{
-       u32 cntkctl = arch_timer_get_cntkctl();
-
-       /* Disable user access to both physical/virtual counters/timers */
-       /* Also disable virtual event stream */
-       cntkctl &= ~(ARCH_TIMER_USR_PT_ACCESS_EN
-                       | ARCH_TIMER_USR_VT_ACCESS_EN
-                       | ARCH_TIMER_VIRT_EVT_EN
-                       | ARCH_TIMER_USR_VCT_ACCESS_EN
-                       | ARCH_TIMER_USR_PCT_ACCESS_EN);
-       arch_timer_set_cntkctl(cntkctl);
-}
-
-static inline void arch_timer_evtstrm_enable(int divider)
-{
-       u32 cntkctl = arch_timer_get_cntkctl();
-       cntkctl &= ~ARCH_TIMER_EVT_TRIGGER_MASK;
-       /* Set the divider and enable virtual event stream */
-       cntkctl |= (divider << ARCH_TIMER_EVT_TRIGGER_SHIFT)
-                       | ARCH_TIMER_VIRT_EVT_EN;
-       arch_timer_set_cntkctl(cntkctl);
-       elf_hwcap |= HWCAP_EVTSTRM;
-}
-
 #endif
 
 #endif
index f751714..9770797 100644 (file)
@@ -212,7 +212,7 @@ const struct machine_desc * __init setup_machine_fdt(unsigned int dt_phys)
 
        if (!mdesc) {
                const char *prop;
-               long size;
+               int size;
                unsigned long dt_root;
 
                early_print("\nError: unrecognized/unsupported "
index b7b4c86..7c4fada 100644 (file)
@@ -674,8 +674,7 @@ static int cpufreq_callback(struct notifier_block *nb,
        }
 
        if ((val == CPUFREQ_PRECHANGE  && freq->old < freq->new) ||
-           (val == CPUFREQ_POSTCHANGE && freq->old > freq->new) ||
-           (val == CPUFREQ_RESUMECHANGE || val == CPUFREQ_SUSPENDCHANGE)) {
+           (val == CPUFREQ_POSTCHANGE && freq->old > freq->new)) {
                loops_per_jiffy = cpufreq_scale(global_l_p_j_ref,
                                                global_l_p_j_ref_freq,
                                                freq->new);
index 6591e26..dfc3213 100644 (file)
@@ -166,7 +166,7 @@ static int twd_cpufreq_transition(struct notifier_block *nb,
         * frequency.  The timer is local to a cpu, so cross-call to the
         * changing cpu.
         */
-       if (state == CPUFREQ_POSTCHANGE || state == CPUFREQ_RESUMECHANGE)
+       if (state == CPUFREQ_POSTCHANGE)
                smp_call_function_single(freqs->cpu, twd_update_frequency,
                        NULL, 1);
 
index b1aa6a9..af4f2df 100644 (file)
@@ -16,12 +16,7 @@ config ARCH_BCM_MOBILE
        select ARM_ERRATA_754322
        select ARM_ERRATA_764369 if SMP
        select ARM_GIC
-       select CPU_V7
-       select CLKSRC_OF
-       select GENERIC_CLOCKEVENTS
-       select GENERIC_TIME
        select GPIO_BCM_KONA
-       select SPARSE_IRQ
        select TICK_ONESHOT
        select CACHE_L2X0
        select HAVE_ARM_ARCH_TIMER
index d1f9612..1c0decd 100644 (file)
@@ -4,10 +4,7 @@ config ARCH_BCM2835
        select ARM_AMBA
        select ARM_ERRATA_411920
        select ARM_TIMER_SP804
-       select CLKDEV_LOOKUP
-       select CLKSRC_OF
        select CPU_V6
-       select GENERIC_CLOCKEVENTS
        select PINCTRL
        select PINCTRL_BCM2835
        help
index 7a02d22..b0cb072 100644 (file)
@@ -1,9 +1,7 @@
 config ARCH_BERLIN
        bool "Marvell Berlin SoCs" if ARCH_MULTI_V7
        select ARM_GIC
-       select GENERIC_CLOCKEVENTS
        select GENERIC_IRQ_CHIP
-       select COMMON_CLK
        select DW_APB_ICTL
        select DW_APB_TIMER_OF
 
@@ -16,12 +14,10 @@ config MACH_BERLIN_BG2
        select CACHE_L2X0
        select CPU_PJ4B
        select HAVE_ARM_TWD if SMP
-       select HAVE_SMP
 
 config MACH_BERLIN_BG2CD
        bool "Marvell Armada 1500-mini (BG2CD)"
        select CACHE_L2X0
-       select CPU_V7
        select HAVE_ARM_TWD if SMP
 
 endmenu
index dbf0df8..5191e10 100644 (file)
@@ -2,9 +2,6 @@ config ARCH_CNS3XXX
        bool "Cavium Networks CNS3XXX family" if ARCH_MULTI_V6
        select ARM_GIC
        select CPU_V6K
-       select GENERIC_CLOCKEVENTS
-       select MIGHT_HAVE_CACHE_L2X0
-       select MIGHT_HAVE_PCI
        select PCI_DOMAINS if PCI
        help
          Support for Cavium Networks CNS3XXX platform.
index 4c414af..8d197dc 100644 (file)
@@ -36,7 +36,6 @@ config ARCH_EXYNOS5
        select HAVE_ARM_SCU if SMP
        select HAVE_SMP
        select PINCTRL
-       select USB_ARCH_HAS_XHCI
        help
          Samsung EXYNOS5 (Cortex-A15) SoC based systems
 
index f18be40..1bf303f 100644 (file)
@@ -322,7 +322,7 @@ static int __init exynos_fdt_map_chipid(unsigned long node, const char *uname,
 {
        struct map_desc iodesc;
        __be32 *reg;
-       unsigned long len;
+       int len;
 
        if (!of_flat_dt_is_compatible(node, "samsung,exynos4210-chipid") &&
                !of_flat_dt_is_compatible(node, "samsung,exynos5440-clock"))
index 0aded64..830b76e 100644 (file)
@@ -5,7 +5,6 @@ config ARCH_HIGHBANK
        select ARCH_HAS_HOLES_MEMORYMODEL
        select ARCH_HAS_OPP
        select ARCH_SUPPORTS_BIG_ENDIAN
-       select ARCH_WANT_OPTIONAL_GPIOLIB
        select ARM_AMBA
        select ARM_ERRATA_764369 if SMP
        select ARM_ERRATA_775420
@@ -14,14 +13,8 @@ config ARCH_HIGHBANK
        select ARM_PSCI
        select ARM_TIMER_SP804
        select CACHE_L2X0
-       select COMMON_CLK
-       select CPU_V7
-       select GENERIC_CLOCKEVENTS
        select HAVE_ARM_SCU
        select HAVE_ARM_TWD if SMP
-       select HAVE_SMP
        select MAILBOX
        select PL320_MBOX
-       select SPARSE_IRQ
-       select USE_OF
        select ZONE_DMA if ARM_LPAE
index 1abae5f..9d0a87b 100644 (file)
@@ -3,13 +3,9 @@ config ARCH_HI3xxx
        select ARM_AMBA
        select ARM_GIC
        select ARM_TIMER_SP804
-       select ARCH_WANT_OPTIONAL_GPIOLIB
        select CACHE_L2X0
-       select CLKSRC_OF
-       select GENERIC_CLOCKEVENTS
        select HAVE_ARM_SCU
        select HAVE_ARM_TWD if SMP
-       select HAVE_SMP
        select PINCTRL
        select PINCTRL_SINGLE
        help
index 33567aa..54fc3c5 100644 (file)
@@ -2,18 +2,11 @@ config ARCH_MXC
        bool "Freescale i.MX family" if ARCH_MULTI_V4_V5 || ARCH_MULTI_V6_V7
        select ARCH_REQUIRE_GPIOLIB
        select ARM_CPU_SUSPEND if PM
-       select ARM_PATCH_PHYS_VIRT
        select CLKSRC_MMIO
-       select COMMON_CLK
        select GENERIC_ALLOCATOR
-       select GENERIC_CLOCKEVENTS
        select GENERIC_IRQ_CHIP
-       select MIGHT_HAVE_CACHE_L2X0 if ARCH_MULTI_V6_V7
-       select MULTI_IRQ_HANDLER
        select PINCTRL
        select SOC_BUS
-       select SPARSE_IRQ
-       select USE_OF
        help
          Support for Freescale MXC/iMX-based family of processors
 
@@ -103,7 +96,6 @@ config SOC_IMX25
 
 config SOC_IMX27
        bool
-       select ARCH_HAS_CPUFREQ
        select ARCH_HAS_OPP
        select CPU_ARM926T
        select IMX_HAVE_IOMUX_V1
@@ -129,10 +121,8 @@ config SOC_IMX35
 
 config SOC_IMX5
        bool
-       select ARCH_HAS_CPUFREQ
        select ARCH_HAS_OPP
        select ARCH_MXC_IOMUX_V3
-       select CPU_V7
        select MXC_TZIC
 
 config SOC_IMX51
@@ -792,16 +782,13 @@ config SOC_IMX6Q
        select ARM_ERRATA_764369 if SMP
        select ARM_ERRATA_775420
        select ARM_GIC
-       select CPU_V7
        select HAVE_ARM_SCU if SMP
        select HAVE_ARM_TWD if SMP
        select HAVE_IMX_ANATOP
        select HAVE_IMX_GPC
        select HAVE_IMX_MMDC
        select HAVE_IMX_SRC
-       select HAVE_SMP
        select MFD_SYSCON
-       select MIGHT_HAVE_PCI
        select PCI_DOMAINS if PCI
        select PINCTRL_IMX6Q
        select PL310_ERRATA_588369 if CACHE_PL310
@@ -817,7 +804,6 @@ config SOC_IMX6SL
        select ARM_ERRATA_754322
        select ARM_ERRATA_775420
        select ARM_GIC
-       select CPU_V7
        select HAVE_IMX_ANATOP
        select HAVE_IMX_GPC
        select HAVE_IMX_MMDC
@@ -833,9 +819,7 @@ config SOC_IMX6SL
 
 config SOC_VF610
        bool "Vybrid Family VF610 support"
-       select CPU_V7
        select ARM_GIC
-       select CLKSRC_OF
        select PINCTRL_VF610
        select VF_PIT_TIMER
        select PL310_ERRATA_588369 if CACHE_PL310
index 90a708f..f50bc93 100644 (file)
@@ -1,13 +1,9 @@
 config ARCH_KEYSTONE
        bool "Texas Instruments Keystone Devices"
        depends on ARCH_MULTI_V7
-       select CPU_V7
        select ARM_GIC
        select HAVE_ARM_ARCH_TIMER
-       select HAVE_SMP
        select CLKSRC_MMIO
-       select GENERIC_CLOCKEVENTS
-       select ARCH_WANT_OPTIONAL_GPIOLIB
        select ARM_ERRATA_798181 if SMP
        select COMMON_CLK_KEYSTONE
        select ARCH_SUPPORTS_BIG_ENDIAN
index 3795ae2..95a6a4b 100644 (file)
@@ -2,14 +2,9 @@ config ARCH_MOXART
        bool "MOXA ART SoC" if ARCH_MULTI_V4T
        select CPU_FA526
        select ARM_DMA_MEM_BUFFERABLE
-       select USE_OF
-       select CLKSRC_OF
        select CLKSRC_MMIO
-       select HAVE_CLK
-       select COMMON_CLK
        select GENERIC_IRQ_CHIP
        select ARCH_REQUIRE_GPIOLIB
-       select GENERIC_CLOCKEVENTS
        select PHYLIB if NETDEVICES
        help
          Say Y here if you want to run your kernel on hardware with a
index 5e269d7..0451caf 100644 (file)
@@ -2,19 +2,13 @@ config ARCH_MVEBU
        bool "Marvell SOCs with Device Tree support" if ARCH_MULTI_V7
        select ARCH_SUPPORTS_BIG_ENDIAN
        select CLKSRC_MMIO
-       select COMMON_CLK
-       select GENERIC_CLOCKEVENTS
        select GENERIC_IRQ_CHIP
        select IRQ_DOMAIN
-       select MULTI_IRQ_HANDLER
        select PINCTRL
        select PLAT_ORION
-       select SPARSE_IRQ
-       select CLKDEV_LOOKUP
        select MVEBU_MBUS
        select ZONE_DMA if ARM_LPAE
        select ARCH_REQUIRE_GPIOLIB
-       select MIGHT_HAVE_PCI
        select PCI_QUIRKS if PCI
 
 if ARCH_MVEBU
@@ -24,7 +18,6 @@ menu "Marvell SOC with device tree"
 config MACH_ARMADA_370_XP
        bool
        select ARMADA_370_XP_TIMER
-       select HAVE_SMP
        select CACHE_L2X0
        select CPU_PJ4B
 
index 8cde9e0..8479413 100644 (file)
@@ -16,11 +16,7 @@ config ARCH_MXS
        bool "Freescale MXS (i.MX23, i.MX28) support"
        depends on ARCH_MULTI_V5
        select ARCH_REQUIRE_GPIOLIB
-       select CLKDEV_LOOKUP
        select CLKSRC_MMIO
-       select CLKSRC_OF
-       select GENERIC_CLOCKEVENTS
-       select HAVE_CLK_PREPARE
        select PINCTRL
        select SOC_BUS
        select SOC_IMX23
index 4d42da4..486d301 100644 (file)
@@ -6,16 +6,11 @@ config ARCH_NOMADIK
        select ARM_VIC
        select CLKSRC_NOMADIK_MTU
        select CLKSRC_NOMADIK_MTU_SCHED_CLOCK
-       select CLKSRC_OF
-       select COMMON_CLK
        select CPU_ARM926T
-       select GENERIC_CLOCKEVENTS
        select MIGHT_HAVE_CACHE_L2X0
        select PINCTRL
        select PINCTRL_NOMADIK
        select PINCTRL_STN8815
-       select SPARSE_IRQ
-       select USE_OF
        help
          Support for the Nomadik platform by ST-Ericsson
 
index 59d8f0a..bc41f26 100644 (file)
@@ -3,14 +3,9 @@ config ARCH_NSPIRE
        depends on ARCH_MULTI_V4_V5
        depends on MMU
        select CPU_ARM926T
-       select COMMON_CLK
-       select GENERIC_CLOCKEVENTS
        select GENERIC_IRQ_CHIP
-       select SPARSE_IRQ
        select ARM_AMBA
        select ARM_VIC
        select ARM_TIMER_SP804
-       select USE_OF
-       select CLKSRC_OF
        help
          This enables support for systems using the TI-NSPIRE CPU
index 0af7ca0..0dc337d 100644 (file)
@@ -6,7 +6,6 @@ config ARCH_OMAP2
        depends on ARCH_MULTI_V6
        select ARCH_OMAP2PLUS
        select CPU_V6
-       select MULTI_IRQ_HANDLER
        select SOC_HAS_OMAP2_SDRC
 
 config ARCH_OMAP3
@@ -15,13 +14,10 @@ config ARCH_OMAP3
        select ARCH_OMAP2PLUS
        select ARCH_HAS_OPP
        select ARM_CPU_SUSPEND if PM
-       select CPU_V7
-       select MULTI_IRQ_HANDLER
        select OMAP_INTERCONNECT
        select PM_OPP if PM
        select PM_RUNTIME if CPU_IDLE
        select SOC_HAS_OMAP2_SDRC
-       select USB_ARCH_HAS_EHCI if USB_SUPPORT
 
 config ARCH_OMAP4
        bool "TI OMAP4"
@@ -33,16 +29,13 @@ config ARCH_OMAP4
        select ARM_ERRATA_720789
        select ARM_GIC
        select CACHE_L2X0
-       select CPU_V7
        select HAVE_ARM_SCU if SMP
        select HAVE_ARM_TWD if SMP
-       select HAVE_SMP
        select OMAP_INTERCONNECT
        select PL310_ERRATA_588369
        select PL310_ERRATA_727915
        select PM_OPP if PM
        select PM_RUNTIME if CPU_IDLE
-       select USB_ARCH_HAS_EHCI if USB_SUPPORT
        select ARM_ERRATA_754322
        select ARM_ERRATA_775420
 
@@ -53,10 +46,8 @@ config SOC_OMAP5
        select ARCH_HAS_OPP
        select ARM_CPU_SUSPEND if PM
        select ARM_GIC
-       select CPU_V7
        select HAVE_ARM_SCU if SMP
        select HAVE_ARM_TWD if SMP
-       select HAVE_SMP
        select HAVE_ARM_ARCH_TIMER
        select ARM_ERRATA_798181 if SMP
 
@@ -66,16 +57,12 @@ config SOC_AM33XX
        select ARCH_OMAP2PLUS
        select ARCH_HAS_OPP
        select ARM_CPU_SUSPEND if PM
-       select CPU_V7
-       select MULTI_IRQ_HANDLER
 
 config SOC_AM43XX
        bool "TI AM43x"
        depends on ARCH_MULTI_V7
-       select CPU_V7
        select ARCH_OMAP2PLUS
        select ARCH_HAS_OPP
-       select MULTI_IRQ_HANDLER
        select ARM_GIC
        select MACH_OMAP_GENERIC
 
@@ -86,8 +73,6 @@ config SOC_DRA7XX
        select ARCH_HAS_OPP
        select ARM_CPU_SUSPEND if PM
        select ARM_GIC
-       select CPU_V7
-       select HAVE_SMP
        select HAVE_ARM_ARCH_TIMER
 
 config ARCH_OMAP2PLUS
@@ -98,17 +83,13 @@ config ARCH_OMAP2PLUS
        select ARCH_OMAP
        select ARCH_REQUIRE_GPIOLIB
        select CLKSRC_MMIO
-       select COMMON_CLK
-       select GENERIC_CLOCKEVENTS
        select GENERIC_IRQ_CHIP
        select MACH_OMAP_GENERIC
        select OMAP_DM_TIMER
        select PINCTRL
        select PROC_DEVICETREE if PROC_FS
        select SOC_BUS
-       select SPARSE_IRQ
        select TI_PRIV_EDMA
-       select USE_OF
        help
          Systems based on OMAP2, OMAP3, OMAP4 or OMAP5
 
index d6ed819..54c135a 100644 (file)
@@ -61,7 +61,8 @@
 
 static struct pwm_lookup pwm_lookup[] = {
        /* LEDB -> PMU_STAT */
-       PWM_LOOKUP("twl-pwmled", 1, "leds_pwm", "beagleboard::pmu_stat"),
+       PWM_LOOKUP("twl-pwmled", 1, "leds_pwm", "beagleboard::pmu_stat",
+                  7812500, PWM_POLARITY_NORMAL),
 };
 
 static struct led_pwm pwm_leds[] = {
index b1022f4..fd81b5c 100644 (file)
@@ -1,12 +1,8 @@
 config ARCH_PICOXCELL
        bool "Picochip PicoXcell" if ARCH_MULTI_V6
        select ARCH_REQUIRE_GPIOLIB
-       select ARM_PATCH_PHYS_VIRT
        select ARM_VIC
        select CPU_V6K
        select DW_APB_TIMER_OF
-       select GENERIC_CLOCKEVENTS
        select HAVE_TCM
-       select NO_IOPORT
-       select SPARSE_IRQ
-       select USE_OF
+       select NO_IOPORT_MAP
index 6988b11..82482cd 100644 (file)
@@ -1,10 +1,8 @@
 config ARCH_SIRF
        bool "CSR SiRF" if ARCH_MULTI_V7
        select ARCH_REQUIRE_GPIOLIB
-       select GENERIC_CLOCKEVENTS
        select GENERIC_IRQ_CHIP
-       select MIGHT_HAVE_CACHE_L2X0
-       select NO_IOPORT
+       select NO_IOPORT_MAP
        select PINCTRL
        select PINCTRL_SIRF
        help
@@ -17,7 +15,6 @@ menu "CSR SiRF atlas6/primaII/Marco/Polo Specific Features"
 config ARCH_ATLAS6
        bool "CSR SiRFSoC ATLAS6 ARM Cortex A9 Platform"
        default y
-       select CPU_V7
        select SIRF_IRQ
        help
           Support for CSR SiRFSoC ARM Cortex A9 Platform
@@ -25,7 +22,6 @@ config ARCH_ATLAS6
 config ARCH_PRIMA2
        bool "CSR SiRFSoC PRIMA2 ARM Cortex A9 Platform"
        default y
-       select CPU_V7
        select SIRF_IRQ
        select ZONE_DMA
        help
@@ -35,9 +31,7 @@ config ARCH_MARCO
        bool "CSR SiRFSoC MARCO ARM Cortex A9 Platform"
        default y
        select ARM_GIC
-       select CPU_V7
        select HAVE_ARM_SCU if SMP
-       select HAVE_SMP
        select SMP_ON_UP if SMP
        help
           Support for CSR SiRFSoC ARM Cortex A9 Platform
index a7c30eb..c66ad4e 100644 (file)
@@ -574,7 +574,8 @@ static struct platform_device backlight = {
 };
 
 static struct pwm_lookup hx4700_pwm_lookup[] = {
-       PWM_LOOKUP("pxa27x-pwm.1", 0, "pwm-backlight", NULL),
+       PWM_LOOKUP("pxa27x-pwm.1", 0, "pwm-backlight", NULL,
+                  30923, PWM_POLARITY_NORMAL),
 };
 
 /*
index 29905b1..41f27f6 100644 (file)
@@ -885,9 +885,6 @@ static int viper_cpufreq_notifier(struct notifier_block *nb,
                        viper_set_core_cpu_voltage(freq->new, 0);
                }
                break;
-       case CPUFREQ_RESUMECHANGE:
-               viper_set_core_cpu_voltage(freq->new, 0);
-               break;
        default:
                /* ignore */
                break;
index cf073de..6b2f586 100644 (file)
@@ -6,9 +6,6 @@ config ARCH_ROCKCHIP
        select ARM_GIC
        select CACHE_L2X0
        select HAVE_ARM_TWD if SMP
-       select HAVE_SMP
-       select COMMON_CLK
-       select GENERIC_CLOCKEVENTS
        select DW_APB_TIMER_OF
        select ARM_GLOBAL_TIMER
        select CLKSRC_ARM_GLOBAL_TIMER_SCHED_CLOCK
index d876431..de2529d 100644 (file)
@@ -12,7 +12,7 @@ if ARCH_S3C24XX
 config PLAT_S3C24XX
        def_bool y
        select ARCH_REQUIRE_GPIOLIB
-       select NO_IOPORT
+       select NO_IOPORT_MAP
        select S3C_DEV_NAND
        select IRQ_DOMAIN
        help
index 05fa505..d58f19d 100644 (file)
@@ -1,22 +1,43 @@
 config ARCH_SHMOBILE
        bool
 
+config PM_RCAR
+       bool
+
+config PM_RMOBILE
+       bool
+
+config ARCH_RCAR_GEN1
+       bool
+       select PM_RCAR if PM || SMP
+       select RENESAS_INTC_IRQPIN
+       select SYS_SUPPORTS_SH_TMU
+
+config ARCH_RCAR_GEN2
+       bool
+       select PM_RCAR if PM || SMP
+       select RENESAS_IRQC
+       select SYS_SUPPORTS_SH_CMT
+
+config ARCH_RMOBILE
+       bool
+       select PM_RMOBILE if PM && !ARCH_SHMOBILE_MULTI
+       select SYS_SUPPORTS_SH_CMT
+       select SYS_SUPPORTS_SH_TMU
+
 config ARCH_SHMOBILE_MULTI
        bool "Renesas ARM SoCs" if ARCH_MULTI_V7
        depends on MMU
        select ARCH_SHMOBILE
-       select CPU_V7
-       select GENERIC_CLOCKEVENTS
        select HAVE_ARM_SCU if SMP
        select HAVE_ARM_TWD if SMP
-       select HAVE_SMP
        select ARM_GIC
-       select MIGHT_HAVE_CACHE_L2X0
-       select MIGHT_HAVE_PCI
-       select NO_IOPORT
+       select ARCH_DMA_ADDR_T_64BIT if ARM_LPAE
+       select NO_IOPORT_MAP
        select PINCTRL
        select ARCH_REQUIRE_GPIOLIB
-       select CLKDEV_LOOKUP
+       select ARCH_HAS_CPUFREQ
+       select ARCH_HAS_OPP
 
 if ARCH_SHMOBILE_MULTI
 
@@ -24,36 +45,49 @@ comment "Renesas ARM SoCs System Type"
 
 config ARCH_EMEV2
        bool "Emma Mobile EV2"
+       select SYS_SUPPORTS_EM_STI
 
 config ARCH_R7S72100
        bool "RZ/A1H (R7S72100)"
+       select SYS_SUPPORTS_SH_MTU2
+
+config ARCH_R8A7740
+       bool "R-Mobile A1 (R8A77400)"
+       select ARCH_RMOBILE
+       select RENESAS_INTC_IRQPIN
+
+config ARCH_R8A7779
+       bool "R-Car H1 (R8A77790)"
+       select ARCH_RCAR_GEN1
 
 config ARCH_R8A7790
        bool "R-Car H2 (R8A77900)"
-       select RENESAS_IRQC
+       select ARCH_RCAR_GEN2
 
 config ARCH_R8A7791
-       bool "R-Car M2 (R8A77910)"
-       select RENESAS_IRQC
+       bool "R-Car M2-W (R8A77910)"
+       select ARCH_RCAR_GEN2
 
-comment "Renesas ARM SoCs Board Type"
+config ARCH_R8A7794
+       bool "R-Car E2 (R8A77940)"
+       select ARCH_RCAR_GEN2
 
-config MACH_GENMAI
-       bool "Genmai board"
-       depends on ARCH_R7S72100
+comment "Renesas ARM SoCs Board Type"
 
 config MACH_KOELSCH
        bool "Koelsch board"
        depends on ARCH_R8A7791
-
-config MACH_KZM9D
-       bool "KZM9D board"
-       depends on ARCH_EMEV2
-       select REGULATOR_FIXED_VOLTAGE if REGULATOR
+       select MICREL_PHY if SH_ETH
 
 config MACH_LAGER
        bool "Lager board"
        depends on ARCH_R8A7790
+       select MICREL_PHY if SH_ETH
+
+config MACH_MARZEN
+       bool "MARZEN board"
+       depends on ARCH_R8A7779
+       select REGULATOR_FIXED_VOLTAGE if REGULATOR
 
 comment "Renesas ARM SoCs System Configuration"
 endif
@@ -64,101 +98,76 @@ comment "Renesas ARM SoCs System Type"
 
 config ARCH_SH7372
        bool "SH-Mobile AP4 (SH7372)"
+       select ARCH_RMOBILE
        select ARCH_WANT_OPTIONAL_GPIOLIB
        select ARM_CPU_SUSPEND if PM || CPU_IDLE
-       select CPU_V7
-       select SH_CLK_CPG
+       select SH_INTC
 
 config ARCH_SH73A0
        bool "SH-Mobile AG5 (R8A73A00)"
+       select ARCH_RMOBILE
        select ARCH_WANT_OPTIONAL_GPIOLIB
        select ARM_GIC
-       select CPU_V7
        select I2C
-       select SH_CLK_CPG
+       select SH_INTC
        select RENESAS_INTC_IRQPIN
 
 config ARCH_R8A73A4
        bool "R-Mobile APE6 (R8A73A40)"
+       select ARCH_RMOBILE
        select ARCH_WANT_OPTIONAL_GPIOLIB
        select ARM_GIC
-       select CPU_V7
-       select SH_CLK_CPG
        select RENESAS_IRQC
        select ARCH_HAS_CPUFREQ
        select ARCH_HAS_OPP
 
 config ARCH_R8A7740
        bool "R-Mobile A1 (R8A77400)"
+       select ARCH_RMOBILE
        select ARCH_WANT_OPTIONAL_GPIOLIB
        select ARM_GIC
-       select CPU_V7
-       select SH_CLK_CPG
        select RENESAS_INTC_IRQPIN
 
 config ARCH_R8A7778
        bool "R-Car M1A (R8A77781)"
+       select ARCH_RCAR_GEN1
        select ARCH_WANT_OPTIONAL_GPIOLIB
-       select CPU_V7
-       select SH_CLK_CPG
        select ARM_GIC
-       select USB_ARCH_HAS_EHCI
-       select USB_ARCH_HAS_OHCI
 
 config ARCH_R8A7779
        bool "R-Car H1 (R8A77790)"
+       select ARCH_RCAR_GEN1
        select ARCH_WANT_OPTIONAL_GPIOLIB
        select ARM_GIC
-       select CPU_V7
-       select SH_CLK_CPG
-       select USB_ARCH_HAS_EHCI
-       select USB_ARCH_HAS_OHCI
-       select RENESAS_INTC_IRQPIN
 
 config ARCH_R8A7790
        bool "R-Car H2 (R8A77900)"
+       select ARCH_RCAR_GEN2
        select ARCH_WANT_OPTIONAL_GPIOLIB
        select ARM_GIC
-       select CPU_V7
        select MIGHT_HAVE_PCI
-       select SH_CLK_CPG
-       select RENESAS_IRQC
+       select ARCH_DMA_ADDR_T_64BIT if ARM_LPAE
 
 config ARCH_R8A7791
-       bool "R-Car M2 (R8A77910)"
-       select ARCH_WANT_OPTIONAL_GPIOLIB
-       select ARM_GIC
-       select CPU_V7
-       select MIGHT_HAVE_PCI
-       select SH_CLK_CPG
-       select RENESAS_IRQC
-
-config ARCH_EMEV2
-       bool "Emma Mobile EV2"
+       bool "R-Car M2-W (R8A77910)"
+       select ARCH_RCAR_GEN2
        select ARCH_WANT_OPTIONAL_GPIOLIB
        select ARM_GIC
-       select CPU_V7
        select MIGHT_HAVE_PCI
-       select USE_OF
-       select AUTO_ZRELADDR
-
-config ARCH_R7S72100
-       bool "RZ/A1H (R7S72100)"
-       select ARCH_WANT_OPTIONAL_GPIOLIB
-       select ARM_GIC
-       select CPU_V7
-       select SH_CLK_CPG
+       select ARCH_DMA_ADDR_T_64BIT if ARM_LPAE
 
 comment "Renesas ARM SoCs Board Type"
 
 config MACH_APE6EVM
        bool "APE6EVM board"
        depends on ARCH_R8A73A4
+       select SMSC_PHY if SMSC911X
        select USE_OF
 
 config MACH_APE6EVM_REFERENCE
        bool "APE6EVM board - Reference Device Tree Implementation"
        depends on ARCH_R8A73A4
+       select SMSC_PHY if SMSC911X
        select USE_OF
        ---help---
           Use reference implementation of APE6EVM board support
@@ -172,6 +181,7 @@ config MACH_MACKEREL
        depends on ARCH_SH7372
        select ARCH_REQUIRE_GPIOLIB
        select REGULATOR_FIXED_VOLTAGE if REGULATOR
+       select SMSC_PHY if SMSC911X
        select SND_SOC_AK4642 if SND_SIMPLE_CARD
        select USE_OF
 
@@ -180,38 +190,23 @@ config MACH_ARMADILLO800EVA
        depends on ARCH_R8A7740
        select ARCH_REQUIRE_GPIOLIB
        select REGULATOR_FIXED_VOLTAGE if REGULATOR
+       select SMSC_PHY if SH_ETH
        select SND_SOC_WM8978 if SND_SIMPLE_CARD
        select USE_OF
 
-config MACH_ARMADILLO800EVA_REFERENCE
-       bool "Armadillo-800 EVA board - Reference Device Tree Implementation"
-       depends on ARCH_R8A7740
-       select ARCH_REQUIRE_GPIOLIB
-       select REGULATOR_FIXED_VOLTAGE if REGULATOR
-       select SND_SOC_WM8978 if SND_SIMPLE_CARD
-       select USE_OF
-       ---help---
-          Use reference implementation of Aramdillo800 EVA board support
-          which makes a greater use of device tree at the expense
-          of not supporting a number of devices.
-
-          This is intended to aid developers
-
 config MACH_BOCKW
        bool "BOCK-W platform"
        depends on ARCH_R8A7778
        select ARCH_REQUIRE_GPIOLIB
-       select RENESAS_INTC_IRQPIN
        select REGULATOR_FIXED_VOLTAGE if REGULATOR
-       select USE_OF
        select SND_SOC_AK4554 if SND_SIMPLE_CARD
        select SND_SOC_AK4642 if SND_SIMPLE_CARD
+       select USE_OF
 
 config MACH_BOCKW_REFERENCE
        bool "BOCK-W  - Reference Device Tree Implementation"
        depends on ARCH_R8A7778
        select ARCH_REQUIRE_GPIOLIB
-       select RENESAS_INTC_IRQPIN
        select REGULATOR_FIXED_VOLTAGE if REGULATOR
        select USE_OF
        ---help---
@@ -221,22 +216,6 @@ config MACH_BOCKW_REFERENCE
 
           This is intended to aid developers
 
-config MACH_GENMAI
-       bool "Genmai board"
-       depends on ARCH_R7S72100
-       select USE_OF
-
-config MACH_GENMAI_REFERENCE
-       bool "Genmai board - Reference Device Tree Implementation"
-       depends on ARCH_R7S72100
-       select USE_OF
-       ---help---
-          Use reference implementation of Genmai board support
-          which makes use of device tree at the expense
-          of not supporting a number of devices.
-
-          This is intended to aid developers
-
 config MACH_MARZEN
        bool "MARZEN board"
        depends on ARCH_R8A7779
@@ -244,23 +223,12 @@ config MACH_MARZEN
        select REGULATOR_FIXED_VOLTAGE if REGULATOR
        select USE_OF
 
-config MACH_MARZEN_REFERENCE
-       bool "MARZEN board - Reference Device Tree Implementation"
-       depends on ARCH_R8A7779
-       select ARCH_REQUIRE_GPIOLIB
-       select REGULATOR_FIXED_VOLTAGE if REGULATOR
-       select USE_OF
-       ---help---
-          Use reference implementation of Marzen board support
-          which makes use of device tree at the expense
-          of not supporting a number of devices.
-
-          This is intended to aid developers
-
 config MACH_LAGER
        bool "Lager board"
        depends on ARCH_R8A7790
        select USE_OF
+       select MICREL_PHY if SH_ETH
+       select SND_SOC_AK4642 if SND_SIMPLE_CARD
 
 config MACH_KOELSCH
        bool "Koelsch board"
@@ -321,24 +289,6 @@ config SHMOBILE_TIMER_HZ
          want to select a HZ value such as 128 that can evenly divide RCLK.
          A HZ value that does not divide evenly may cause timer drift.
 
-config SH_TIMER_CMT
-       bool "CMT timer driver"
-       default y
-       help
-         This enables build of the CMT timer driver.
-
-config SH_TIMER_TMU
-       bool "TMU timer driver"
-       default y
-       help
-         This enables build of the TMU timer driver.
-
-config EM_TIMER_STI
-       bool "STI timer driver"
-       default y
-       help
-         This enables build of the STI timer driver.
-
 endmenu
 
 endif
index fe7d4ff..e20f278 100644 (file)
@@ -2,27 +2,25 @@
 # Makefile for the linux kernel.
 #
 
-ccflags-$(CONFIG_ARCH_MULTIPLATFORM) := -I$(srctree)/arch/arm/mach-shmobile/include
-
 # Common objects
 obj-y                          := timer.o console.o
 
 # CPU objects
-obj-$(CONFIG_ARCH_SH7372)      += setup-sh7372.o intc-sh7372.o
-obj-$(CONFIG_ARCH_SH73A0)      += setup-sh73a0.o intc-sh73a0.o
+obj-$(CONFIG_ARCH_SH7372)      += setup-sh7372.o intc-sh7372.o pm-sh7372.o
+obj-$(CONFIG_ARCH_SH73A0)      += setup-sh73a0.o intc-sh73a0.o pm-sh73a0.o
 obj-$(CONFIG_ARCH_R8A73A4)     += setup-r8a73a4.o
-obj-$(CONFIG_ARCH_R8A7740)     += setup-r8a7740.o
+obj-$(CONFIG_ARCH_R8A7740)     += setup-r8a7740.o pm-r8a7740.o
 obj-$(CONFIG_ARCH_R8A7778)     += setup-r8a7778.o
-obj-$(CONFIG_ARCH_R8A7779)     += setup-r8a7779.o
-obj-$(CONFIG_ARCH_R8A7790)     += setup-r8a7790.o
-obj-$(CONFIG_ARCH_R8A7790)     += setup-r8a7790.o setup-rcar-gen2.o
-obj-$(CONFIG_ARCH_R8A7791)     += setup-r8a7791.o setup-rcar-gen2.o
+obj-$(CONFIG_ARCH_R8A7779)     += setup-r8a7779.o pm-r8a7779.o
+obj-$(CONFIG_ARCH_R8A7790)     += setup-r8a7790.o pm-r8a7790.o
+obj-$(CONFIG_ARCH_R8A7791)     += setup-r8a7791.o pm-r8a7791.o
+obj-$(CONFIG_ARCH_R8A7794)     += setup-r8a7794.o
 obj-$(CONFIG_ARCH_EMEV2)       += setup-emev2.o
 obj-$(CONFIG_ARCH_R7S72100)    += setup-r7s72100.o
 
 # Clock objects
-ifndef CONFIG_COMMON_CLK
 obj-y                          += clock.o
+ifndef CONFIG_COMMON_CLK
 obj-$(CONFIG_ARCH_SH7372)      += clock-sh7372.o
 obj-$(CONFIG_ARCH_SH73A0)      += clock-sh73a0.o
 obj-$(CONFIG_ARCH_R8A73A4)     += clock-r8a73a4.o
@@ -31,48 +29,46 @@ obj-$(CONFIG_ARCH_R8A7778)  += clock-r8a7778.o
 obj-$(CONFIG_ARCH_R8A7779)     += clock-r8a7779.o
 obj-$(CONFIG_ARCH_R8A7790)     += clock-r8a7790.o
 obj-$(CONFIG_ARCH_R8A7791)     += clock-r8a7791.o
-obj-$(CONFIG_ARCH_EMEV2)       += clock-emev2.o
-obj-$(CONFIG_ARCH_R7S72100)    += clock-r7s72100.o
 endif
 
+# CPU reset vector handling objects
+cpu-y                          := platsmp.o headsmp.o
+
+# Shared SoC family objects
+obj-$(CONFIG_ARCH_RCAR_GEN2)   += setup-rcar-gen2.o platsmp-apmu.o $(cpu-y)
+
 # SMP objects
-smp-y                          := platsmp.o headsmp.o
+smp-y                          := $(cpu-y)
 smp-$(CONFIG_ARCH_SH73A0)      += smp-sh73a0.o headsmp-scu.o platsmp-scu.o
 smp-$(CONFIG_ARCH_R8A7779)     += smp-r8a7779.o headsmp-scu.o platsmp-scu.o
-smp-$(CONFIG_ARCH_R8A7790)     += smp-r8a7790.o platsmp-apmu.o
-smp-$(CONFIG_ARCH_R8A7791)     += smp-r8a7791.o platsmp-apmu.o
+smp-$(CONFIG_ARCH_R8A7790)     += smp-r8a7790.o
+smp-$(CONFIG_ARCH_R8A7791)     += smp-r8a7791.o
 smp-$(CONFIG_ARCH_EMEV2)       += smp-emev2.o headsmp-scu.o platsmp-scu.o
 
-# IRQ objects
-obj-$(CONFIG_ARCH_SH7372)      += entry-intc.o
-
 # PM objects
 obj-$(CONFIG_SUSPEND)          += suspend.o
 obj-$(CONFIG_CPU_IDLE)         += cpuidle.o
-obj-$(CONFIG_ARCH_SH7372)      += pm-sh7372.o sleep-sh7372.o pm-rmobile.o
-obj-$(CONFIG_ARCH_SH73A0)      += pm-sh73a0.o
-obj-$(CONFIG_ARCH_R8A7740)     += pm-r8a7740.o pm-rmobile.o
-obj-$(CONFIG_ARCH_R8A7779)     += pm-r8a7779.o
+obj-$(CONFIG_CPU_FREQ)         += cpufreq.o
+obj-$(CONFIG_PM_RCAR)          += pm-rcar.o
+obj-$(CONFIG_PM_RMOBILE)       += pm-rmobile.o
+
+# special sh7372 handling for IRQ objects and low level sleep code
+obj-$(CONFIG_ARCH_SH7372)      += entry-intc.o sleep-sh7372.o
 
 # Board objects
 ifdef CONFIG_ARCH_SHMOBILE_MULTI
-obj-$(CONFIG_MACH_GENMAI)      += board-genmai-reference.o
 obj-$(CONFIG_MACH_KOELSCH)     += board-koelsch-reference.o
-obj-$(CONFIG_MACH_KZM9D)       += board-kzm9d-reference.o
 obj-$(CONFIG_MACH_LAGER)       += board-lager-reference.o
+obj-$(CONFIG_MACH_MARZEN)      += board-marzen-reference.o
 else
 obj-$(CONFIG_MACH_APE6EVM)     += board-ape6evm.o
 obj-$(CONFIG_MACH_APE6EVM_REFERENCE)   += board-ape6evm-reference.o
 obj-$(CONFIG_MACH_MACKEREL)    += board-mackerel.o
 obj-$(CONFIG_MACH_BOCKW)       += board-bockw.o
 obj-$(CONFIG_MACH_BOCKW_REFERENCE)     += board-bockw-reference.o
-obj-$(CONFIG_MACH_GENMAI)      += board-genmai.o
-obj-$(CONFIG_MACH_GENMAI_REFERENCE)    += board-genmai-reference.o
 obj-$(CONFIG_MACH_MARZEN)      += board-marzen.o
-obj-$(CONFIG_MACH_MARZEN_REFERENCE)    += board-marzen-reference.o
 obj-$(CONFIG_MACH_LAGER)       += board-lager.o
 obj-$(CONFIG_MACH_ARMADILLO800EVA)     += board-armadillo800eva.o
-obj-$(CONFIG_MACH_ARMADILLO800EVA_REFERENCE)   += board-armadillo800eva-reference.o
 obj-$(CONFIG_MACH_KOELSCH)     += board-koelsch.o
 obj-$(CONFIG_MACH_KZM9G)       += board-kzm9g.o
 obj-$(CONFIG_MACH_KZM9G_REFERENCE)     += board-kzm9g-reference.o
index 99455ec..de9a238 100644 (file)
@@ -3,18 +3,14 @@ loadaddr-y    :=
 loadaddr-$(CONFIG_MACH_APE6EVM) += 0x40008000
 loadaddr-$(CONFIG_MACH_APE6EVM_REFERENCE) += 0x40008000
 loadaddr-$(CONFIG_MACH_ARMADILLO800EVA) += 0x40008000
-loadaddr-$(CONFIG_MACH_ARMADILLO800EVA_REFERENCE) += 0x40008000
 loadaddr-$(CONFIG_MACH_BOCKW) += 0x60008000
 loadaddr-$(CONFIG_MACH_BOCKW_REFERENCE) += 0x60008000
-loadaddr-$(CONFIG_MACH_GENMAI) += 0x08008000
-loadaddr-$(CONFIG_MACH_GENMAI_REFERENCE) += 0x08008000
 loadaddr-$(CONFIG_MACH_KOELSCH) += 0x40008000
 loadaddr-$(CONFIG_MACH_KZM9G) += 0x41008000
 loadaddr-$(CONFIG_MACH_KZM9G_REFERENCE) += 0x41008000
 loadaddr-$(CONFIG_MACH_LAGER) += 0x40008000
 loadaddr-$(CONFIG_MACH_MACKEREL) += 0x40008000
 loadaddr-$(CONFIG_MACH_MARZEN) += 0x60008000
-loadaddr-$(CONFIG_MACH_MARZEN_REFERENCE) += 0x60008000
 
 __ZRELADDR     := $(sort $(loadaddr-y))
    zreladdr-y   += $(__ZRELADDR)
index 3276afc..a6503d8 100644 (file)
 #include <linux/pinctrl/machine.h>
 #include <linux/platform_device.h>
 #include <linux/sh_clk.h>
-#include <mach/common.h>
-#include <mach/r8a73a4.h>
+
 #include <asm/mach-types.h>
 #include <asm/mach/arch.h>
 
+#include "common.h"
+#include "r8a73a4.h"
+
 static void __init ape6evm_add_standard_devices(void)
 {
 
@@ -48,7 +50,6 @@ static void __init ape6evm_add_standard_devices(void)
 
        r8a73a4_add_dt_devices();
        of_platform_populate(NULL, of_default_bus_match_table, NULL, NULL);
-       platform_device_register_simple("cpufreq-cpu0", -1, NULL, 0);
 }
 
 static const char *ape6evm_boards_compat_dt[] __initdata = {
@@ -57,7 +58,8 @@ static const char *ape6evm_boards_compat_dt[] __initdata = {
 };
 
 DT_MACHINE_START(APE6EVM_DT, "ape6evm")
-       .init_early     = r8a73a4_init_early,
+       .init_early     = shmobile_init_delay,
        .init_machine   = ape6evm_add_standard_devices,
+       .init_late      = shmobile_init_late,
        .dt_compat      = ape6evm_boards_compat_dt,
 MACHINE_END
index fe071a9..3b3bc7d 100644 (file)
 #include <linux/regulator/machine.h>
 #include <linux/sh_clk.h>
 #include <linux/smsc911x.h>
-#include <mach/common.h>
-#include <mach/irqs.h>
-#include <mach/r8a73a4.h>
+
 #include <asm/mach-types.h>
 #include <asm/mach/arch.h>
 
+#include "common.h"
+#include "irqs.h"
+#include "r8a73a4.h"
+
 /* LEDS */
 static struct gpio_led ape6evm_leds[] = {
        {
@@ -281,7 +283,8 @@ static const char *ape6evm_boards_compat_dt[] __initdata = {
 };
 
 DT_MACHINE_START(APE6EVM_DT, "ape6evm")
-       .init_early     = r8a73a4_init_early,
+       .init_early     = shmobile_init_delay,
        .init_machine   = ape6evm_add_standard_devices,
+       .init_late      = shmobile_init_late,
        .dt_compat      = ape6evm_boards_compat_dt,
 MACHINE_END
diff --git a/arch/arm/mach-shmobile/board-armadillo800eva-reference.c b/arch/arm/mach-shmobile/board-armadillo800eva-reference.c
deleted file mode 100644 (file)
index 57d1a78..0000000
+++ /dev/null
@@ -1,196 +0,0 @@
-/*
- * armadillo 800 eva board support
- *
- * Copyright (C) 2012 Renesas Solutions Corp.
- * Copyright (C) 2012 Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; version 2 of the License.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
- *
- */
-
-#include <linux/clk.h>
-#include <linux/err.h>
-#include <linux/kernel.h>
-#include <linux/gpio.h>
-#include <linux/io.h>
-#include <mach/common.h>
-#include <mach/r8a7740.h>
-#include <asm/mach/arch.h>
-#include <asm/hardware/cache-l2x0.h>
-
-/*
- * CON1                Camera Module
- * CON2                Extension Bus
- * CON3                HDMI Output
- * CON4                Composite Video Output
- * CON5                H-UDI JTAG
- * CON6                ARM JTAG
- * CON7                SD1
- * CON8                SD2
- * CON9                RTC BackUp
- * CON10       Monaural Mic Input
- * CON11       Stereo Headphone Output
- * CON12       Audio Line Output(L)
- * CON13       Audio Line Output(R)
- * CON14       AWL13 Module
- * CON15       Extension
- * CON16       LCD1
- * CON17       LCD2
- * CON19       Power Input
- * CON20       USB1
- * CON21       USB2
- * CON22       Serial
- * CON23       LAN
- * CON24       USB3
- * LED1                Camera LED(Yellow)
- * LED2                Power LED (Green)
- * ED3-LED6    User LED(Yellow)
- * LED7                LAN link LED(Green)
- * LED8                LAN activity LED(Yellow)
- */
-
-/*
- * DipSwitch
- *
- *                    SW1
- *
- * -12345678-+---------------+----------------------------
- *  1        | boot          | hermit
- *  0        | boot          | OS auto boot
- * -12345678-+---------------+----------------------------
- *   00      | boot device   | eMMC
- *   10      | boot device   | SDHI0 (CON7)
- *   01      | boot device   | -
- *   11      | boot device   | Extension Buss (CS0)
- * -12345678-+---------------+----------------------------
- *     0     | Extension Bus | D8-D15 disable, eMMC enable
- *     1     | Extension Bus | D8-D15 enable,  eMMC disable
- * -12345678-+---------------+----------------------------
- *      0    | SDHI1         | COM8 disable, COM14 enable
- *      1    | SDHI1         | COM8 enable,  COM14 disable
- * -12345678-+---------------+----------------------------
- *       0   | USB0          | COM20 enable,  COM24 disable
- *       1   | USB0          | COM20 disable, COM24 enable
- * -12345678-+---------------+----------------------------
- *        00 | JTAG          | SH-X2
- *        10 | JTAG          | ARM
- *        01 | JTAG          | -
- *        11 | JTAG          | Boundary Scan
- *-----------+---------------+----------------------------
- */
-
-/*
- * FSI-WM8978
- *
- * this command is required when playback.
- *
- * # amixer set "Headphone" 50
- *
- * this command is required when capture.
- *
- * # amixer set "Input PGA" 15
- * # amixer set "Left Input Mixer MicP" on
- * # amixer set "Left Input Mixer MicN" on
- * # amixer set "Right Input Mixer MicN" on
- * # amixer set "Right Input Mixer MicP" on
- */
-
-/*
- * USB function
- *
- * When you use USB Function,
- * set SW1.6 ON, and connect cable to CN24.
- *
- * USBF needs workaround on R8A7740 chip.
- * These are a little bit complex.
- * see
- *     usbhsf_power_ctrl()
- */
-
-static void __init eva_clock_init(void)
-{
-       struct clk *system      = clk_get(NULL, "system_clk");
-       struct clk *xtal1       = clk_get(NULL, "extal1");
-       struct clk *usb24s      = clk_get(NULL, "usb24s");
-       struct clk *fsibck      = clk_get(NULL, "fsibck");
-
-       if (IS_ERR(system)      ||
-           IS_ERR(xtal1)       ||
-           IS_ERR(usb24s)      ||
-           IS_ERR(fsibck)) {
-               pr_err("armadillo800eva board clock init failed\n");
-               goto clock_error;
-       }
-
-       /* armadillo 800 eva extal1 is 24MHz */
-       clk_set_rate(xtal1, 24000000);
-
-       /* usb24s use extal1 (= system) clock (= 24MHz) */
-       clk_set_parent(usb24s, system);
-
-       /* FSIBCK is 12.288MHz, and it is parent of FSI-B */
-       clk_set_rate(fsibck, 12288000);
-
-clock_error:
-       if (!IS_ERR(system))
-               clk_put(system);
-       if (!IS_ERR(xtal1))
-               clk_put(xtal1);
-       if (!IS_ERR(usb24s))
-               clk_put(usb24s);
-       if (!IS_ERR(fsibck))
-               clk_put(fsibck);
-}
-
-/*
- * board init
- */
-static void __init eva_init(void)
-{
-       r8a7740_clock_init(MD_CK0 | MD_CK2);
-       eva_clock_init();
-
-       r8a7740_meram_workaround();
-
-#ifdef CONFIG_CACHE_L2X0
-       /* Early BRESP enable, Shared attribute override enable, 32K*8way */
-       l2x0_init(IOMEM(0xf0002000), 0x40440000, 0x82000fff);
-#endif
-
-       r8a7740_add_standard_devices_dt();
-
-       r8a7740_pm_init();
-}
-
-#define RESCNT2 IOMEM(0xe6188020)
-static void eva_restart(enum reboot_mode mode, const char *cmd)
-{
-       /* Do soft power on reset */
-       writel(1 << 31, RESCNT2);
-}
-
-static const char *eva_boards_compat_dt[] __initdata = {
-       "renesas,armadillo800eva-reference",
-       NULL,
-};
-
-DT_MACHINE_START(ARMADILLO800EVA_DT, "armadillo800eva-reference")
-       .map_io         = r8a7740_map_io,
-       .init_early     = r8a7740_init_delay,
-       .init_irq       = r8a7740_init_irq_of,
-       .init_machine   = eva_init,
-       .init_late      = shmobile_init_late,
-       .dt_compat      = eva_boards_compat_dt,
-       .restart        = eva_restart,
-MACHINE_END
index 93533e2..74ee955 100644 (file)
@@ -31,7 +31,7 @@
 #include <linux/gpio_keys.h>
 #include <linux/regulator/driver.h>
 #include <linux/pinctrl/machine.h>
-#include <linux/platform_data/pwm-renesas-tpu.h>
+#include <linux/pwm.h>
 #include <linux/pwm_backlight.h>
 #include <linux/regulator/fixed.h>
 #include <linux/regulator/gpio-regulator.h>
@@ -45,9 +45,7 @@
 #include <linux/mmc/sh_mobile_sdhi.h>
 #include <linux/i2c-gpio.h>
 #include <linux/reboot.h>
-#include <mach/common.h>
-#include <mach/irqs.h>
-#include <mach/r8a7740.h>
+
 #include <media/mt9t112.h>
 #include <media/sh_mobile_ceu.h>
 #include <media/soc_camera.h>
 #include <sound/sh_fsi.h>
 #include <sound/simple_card.h>
 
+#include "common.h"
+#include "irqs.h"
+#include "pm-rmobile.h"
+#include "r8a7740.h"
 #include "sh-gpio.h"
 
 /*
@@ -383,6 +385,8 @@ static struct platform_device sh_eth_device = {
        .id = -1,
        .dev = {
                .platform_data = &sh_eth_platdata,
+               .dma_mask = &sh_eth_device.dev.coherent_dma_mask,
+               .coherent_dma_mask = DMA_BIT_MASK(32),
        },
        .resource = sh_eth_resources,
        .num_resources = ARRAY_SIZE(sh_eth_resources),
@@ -397,24 +401,16 @@ static struct resource pwm_resources[] = {
        },
 };
 
-static struct tpu_pwm_platform_data pwm_device_data = {
-       .channels[2] = {
-               .polarity = PWM_POLARITY_INVERSED,
-       }
-};
-
 static struct platform_device pwm_device = {
        .name = "renesas-tpu-pwm",
        .id = -1,
-       .dev = {
-               .platform_data = &pwm_device_data,
-       },
        .num_resources = ARRAY_SIZE(pwm_resources),
        .resource = pwm_resources,
 };
 
 static struct pwm_lookup pwm_lookup[] = {
-       PWM_LOOKUP("renesas-tpu-pwm", 2, "pwm-backlight.0", NULL),
+       PWM_LOOKUP("renesas-tpu-pwm", 2, "pwm-backlight.0", NULL,
+                  33333, PWM_POLARITY_INVERSED),
 };
 
 /* LCDC and backlight */
@@ -584,6 +580,40 @@ static struct platform_device hdmi_lcdc_device = {
        },
 };
 
+/* LEDS */
+static struct gpio_led gpio_leds[] = {
+       {
+               .name           = "LED3",
+               .gpio           = 102,
+               .default_state  = LEDS_GPIO_DEFSTATE_ON,
+       }, {
+               .name           = "LED4",
+               .gpio           = 111,
+               .default_state  = LEDS_GPIO_DEFSTATE_ON,
+       }, {
+               .name           = "LED5",
+               .gpio           = 110,
+               .default_state  = LEDS_GPIO_DEFSTATE_ON,
+       }, {
+               .name           = "LED6",
+               .gpio           = 177,
+               .default_state  = LEDS_GPIO_DEFSTATE_ON,
+       },
+};
+
+static struct gpio_led_platform_data leds_gpio_info = {
+       .leds           = gpio_leds,
+       .num_leds       = ARRAY_SIZE(gpio_leds),
+};
+
+static struct platform_device leds_gpio_device = {
+       .name   = "leds-gpio",
+       .id     = -1,
+       .dev    = {
+               .platform_data  = &leds_gpio_info,
+       },
+};
+
 /* GPIO KEY */
 #define GPIO_KEY(c, g, d, ...) \
        { .code = c, .gpio = g, .desc = d, .active_low = 1, __VA_ARGS__ }
@@ -988,14 +1018,13 @@ static struct asoc_simple_card_info fsi_wm8978_info = {
        .card           = "FSI2A-WM8978",
        .codec          = "wm8978.0-001a",
        .platform       = "sh_fsi2",
-       .daifmt         = SND_SOC_DAIFMT_I2S,
+       .daifmt         = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_CBM_CFM,
        .cpu_dai = {
+               .fmt    = SND_SOC_DAIFMT_IB_NF,
                .name   = "fsia-dai",
-               .fmt    = SND_SOC_DAIFMT_CBS_CFS | SND_SOC_DAIFMT_IB_NF,
        },
        .codec_dai = {
                .name   = "wm8978-hifi",
-               .fmt    = SND_SOC_DAIFMT_CBM_CFM | SND_SOC_DAIFMT_NB_NF,
                .sysclk = 12288000,
        },
 };
@@ -1005,6 +1034,8 @@ static struct platform_device fsi_wm8978_device = {
        .id     = 0,
        .dev    = {
                .platform_data  = &fsi_wm8978_info,
+               .coherent_dma_mask = DMA_BIT_MASK(32),
+               .dma_mask = &fsi_wm8978_device.dev.coherent_dma_mask,
        },
 };
 
@@ -1016,7 +1047,7 @@ static struct asoc_simple_card_info fsi2_hdmi_info = {
        .platform       = "sh_fsi2",
        .cpu_dai = {
                .name   = "fsib-dai",
-               .fmt    = SND_SOC_DAIFMT_CBM_CFM,
+               .fmt    = SND_SOC_DAIFMT_CBS_CFS,
        },
        .codec_dai = {
                .name = "sh_mobile_hdmi-hifi",
@@ -1028,6 +1059,8 @@ static struct platform_device fsi_hdmi_device = {
        .id     = 1,
        .dev    = {
                .platform_data  = &fsi2_hdmi_info,
+               .coherent_dma_mask = DMA_BIT_MASK(32),
+               .dma_mask = &fsi_hdmi_device.dev.coherent_dma_mask,
        },
 };
 
@@ -1076,6 +1109,7 @@ static struct platform_device *eva_devices[] __initdata = {
        &lcdc0_device,
        &pwm_device,
        &pwm_backlight_device,
+       &leds_gpio_device,
        &gpio_keys_device,
        &sh_eth_device,
        &vcc_sdhi0,
@@ -1197,6 +1231,10 @@ clock_error:
 #define GPIO_PORT8CR   IOMEM(0xe6050008)
 static void __init eva_init(void)
 {
+       static struct pm_domain_device domain_devices[] __initdata = {
+               { "A4LC", &lcdc0_device },
+               { "A4LC", &hdmi_lcdc_device },
+       };
        struct platform_device *usb = NULL;
 
        regulator_register_always_on(0, "fixed-3.3V", fixed3v3_power_consumers,
@@ -1282,8 +1320,8 @@ static void __init eva_init(void)
        platform_add_devices(eva_devices,
                             ARRAY_SIZE(eva_devices));
 
-       rmobile_add_device_to_domain("A4LC", &lcdc0_device);
-       rmobile_add_device_to_domain("A4LC", &hdmi_lcdc_device);
+       rmobile_add_devices_to_domains(domain_devices,
+                                      ARRAY_SIZE(domain_devices));
        if (usb)
                rmobile_add_device_to_domain("A3SP", usb);
 
@@ -1299,11 +1337,6 @@ static void __init eva_earlytimer_init(void)
        eva_clock_init();
 }
 
-static void __init eva_add_early_devices(void)
-{
-       r8a7740_add_early_devices();
-}
-
 #define RESCNT2 IOMEM(0xe6188020)
 static void eva_restart(enum reboot_mode mode, const char *cmd)
 {
@@ -1318,7 +1351,7 @@ static const char *eva_boards_compat_dt[] __initdata = {
 
 DT_MACHINE_START(ARMADILLO800EVA_DT, "armadillo800eva")
        .map_io         = r8a7740_map_io,
-       .init_early     = eva_add_early_devices,
+       .init_early     = r8a7740_add_early_devices,
        .init_irq       = r8a7740_init_irq_of,
        .init_machine   = eva_init,
        .init_late      = shmobile_init_late,
index 027373f..79c4784 100644 (file)
  */
 
 #include <linux/of_platform.h>
-#include <mach/common.h>
-#include <mach/r8a7778.h>
+
 #include <asm/mach/arch.h>
 
+#include "common.h"
+#include "r8a7778.h"
+
 /*
  *     see board-bock.c for checking detail of dip-switch
  */
@@ -78,8 +80,9 @@ static const char *bockw_boards_compat_dt[] __initdata = {
 };
 
 DT_MACHINE_START(BOCKW_DT, "bockw")
-       .init_early     = r8a7778_init_delay,
+       .init_early     = shmobile_init_delay,
        .init_irq       = r8a7778_init_irq_dt,
        .init_machine   = bockw_init,
+       .init_late      = shmobile_init_late,
        .dt_compat      = bockw_boards_compat_dt,
 MACHINE_END
index c475220..eada12e 100644 (file)
@@ -1,9 +1,9 @@
 /*
  * Bock-W board support
  *
- * Copyright (C) 2013  Renesas Solutions Corp.
+ * Copyright (C) 2013-2014  Renesas Solutions Corp.
  * Copyright (C) 2013  Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
- * Copyright (C) 2013  Cogent Embedded, Inc.
+ * Copyright (C) 2013-2014  Cogent Embedded, 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
 #include <linux/spi/spi.h>
 #include <linux/spi/flash.h>
 #include <linux/usb/renesas_usbhs.h>
+
 #include <media/soc_camera.h>
-#include <mach/common.h>
-#include <mach/irqs.h>
-#include <mach/r8a7778.h>
 #include <asm/mach/arch.h>
 #include <sound/rcar_snd.h>
 #include <sound/simple_card.h>
 
+#include "common.h"
+#include "irqs.h"
+#include "r8a7778.h"
+
 #define FPGA   0x18200000
 #define IRQ0MR 0x30
 #define COMCTLR        0x101c
@@ -168,6 +170,8 @@ static struct renesas_usbhs_platform_info usbhs_info __initdata = {
        },
        .driver_param = {
                .buswait_bwait  = 4,
+               .d0_tx_id       = HPBDMA_SLAVE_USBFUNC_TX,
+               .d1_rx_id       = HPBDMA_SLAVE_USBFUNC_RX,
        },
 };
 
@@ -233,6 +237,17 @@ static struct sh_eth_plat_data ether_platform_data __initdata = {
        .no_ether_link  = 1,
 };
 
+static struct platform_device_info ether_info __initdata = {
+       .parent         = &platform_bus,
+       .name           = "r8a777x-ether",
+       .id             = -1,
+       .res            = ether_resources,
+       .num_res        = ARRAY_SIZE(ether_resources),
+       .data           = &ether_platform_data,
+       .size_data      = sizeof(ether_platform_data),
+       .dma_mask       = DMA_BIT_MASK(32),
+};
+
 /* I2C */
 static struct i2c_board_info i2c0_devices[] = {
        {
@@ -332,16 +347,39 @@ static struct rsnd_ssi_platform_info rsnd_ssi[] = {
        RSND_SSI_UNUSED, /* SSI 0 */
        RSND_SSI_UNUSED, /* SSI 1 */
        RSND_SSI_UNUSED, /* SSI 2 */
-       RSND_SSI_SET(1, 0, gic_iid(0x85), RSND_SSI_PLAY),
-       RSND_SSI_SET(2, 0, gic_iid(0x85), RSND_SSI_CLK_PIN_SHARE),
-       RSND_SSI_SET(0, 0, gic_iid(0x86), RSND_SSI_PLAY),
-       RSND_SSI_SET(0, 0, gic_iid(0x86), 0),
-       RSND_SSI_SET(3, 0, gic_iid(0x86), RSND_SSI_PLAY),
-       RSND_SSI_SET(4, 0, gic_iid(0x86), RSND_SSI_CLK_PIN_SHARE),
+       RSND_SSI(HPBDMA_SLAVE_HPBIF3_TX, gic_iid(0x85), 0),
+       RSND_SSI(HPBDMA_SLAVE_HPBIF4_RX, gic_iid(0x85), RSND_SSI_CLK_PIN_SHARE),
+       RSND_SSI(HPBDMA_SLAVE_HPBIF5_TX, gic_iid(0x86), 0),
+       RSND_SSI(HPBDMA_SLAVE_HPBIF6_RX, gic_iid(0x86), 0),
+       RSND_SSI(HPBDMA_SLAVE_HPBIF7_TX, gic_iid(0x86), 0),
+       RSND_SSI(HPBDMA_SLAVE_HPBIF8_RX, gic_iid(0x86), RSND_SSI_CLK_PIN_SHARE),
 };
 
-static struct rsnd_scu_platform_info rsnd_scu[9] = {
-       /* no member at this point */
+static struct rsnd_src_platform_info rsnd_src[9] = {
+       RSND_SRC_UNUSED, /* SRU 0 */
+       RSND_SRC_UNUSED, /* SRU 1 */
+       RSND_SRC_UNUSED, /* SRU 2 */
+       RSND_SRC(0, 0),
+       RSND_SRC(0, 0),
+       RSND_SRC(0, 0),
+       RSND_SRC(0, 0),
+       RSND_SRC(0, 0),
+       RSND_SRC(0, 0),
+};
+
+static struct rsnd_dai_platform_info rsnd_dai[] = {
+       {
+               .playback = { .ssi = &rsnd_ssi[5], .src = &rsnd_src[5] },
+               .capture  = { .ssi = &rsnd_ssi[6], .src = &rsnd_src[6] },
+       }, {
+               .playback = { .ssi = &rsnd_ssi[3], .src = &rsnd_src[3] },
+       }, {
+               .capture  = { .ssi = &rsnd_ssi[4], .src = &rsnd_src[4] },
+       }, {
+               .playback = { .ssi = &rsnd_ssi[7], .src = &rsnd_src[7] },
+       }, {
+               .capture  = { .ssi = &rsnd_ssi[8], .src = &rsnd_src[8] },
+       },
 };
 
 enum {
@@ -416,8 +454,10 @@ static struct rcar_snd_info rsnd_info = {
        .flags          = RSND_GEN1,
        .ssi_info       = rsnd_ssi,
        .ssi_info_nr    = ARRAY_SIZE(rsnd_ssi),
-       .scu_info       = rsnd_scu,
-       .scu_info_nr    = ARRAY_SIZE(rsnd_scu),
+       .src_info       = rsnd_src,
+       .src_info_nr    = ARRAY_SIZE(rsnd_src),
+       .dai_info       = rsnd_dai,
+       .dai_info_nr    = ARRAY_SIZE(rsnd_dai),
        .start          = rsnd_start,
        .stop           = rsnd_stop,
 };
@@ -429,14 +469,12 @@ static struct asoc_simple_card_info rsnd_card_info[] = {
                .card           = "SSI56-AK4643",
                .codec          = "ak4642-codec.0-0012",
                .platform       = "rcar_sound",
-               .daifmt         = SND_SOC_DAIFMT_LEFT_J,
+               .daifmt         = SND_SOC_DAIFMT_LEFT_J | SND_SOC_DAIFMT_CBM_CFM,
                .cpu_dai = {
                        .name   = "rsnd-dai.0",
-                       .fmt    = SND_SOC_DAIFMT_CBS_CFS,
                },
                .codec_dai = {
                        .name   = "ak4642-hifi",
-                       .fmt    = SND_SOC_DAIFMT_CBM_CFM,
                        .sysclk = 11289600,
                },
        },
@@ -446,10 +484,9 @@ static struct asoc_simple_card_info rsnd_card_info[] = {
                .card           = "SSI3-AK4554(playback)",
                .codec          = "ak4554-adc-dac.0",
                .platform       = "rcar_sound",
+               .daifmt         = SND_SOC_DAIFMT_CBS_CFS | SND_SOC_DAIFMT_RIGHT_J,
                .cpu_dai = {
                        .name   = "rsnd-dai.1",
-                       .fmt    = SND_SOC_DAIFMT_CBM_CFM |
-                                 SND_SOC_DAIFMT_RIGHT_J,
                },
                .codec_dai = {
                        .name   = "ak4554-hifi",
@@ -461,10 +498,9 @@ static struct asoc_simple_card_info rsnd_card_info[] = {
                .card           = "SSI4-AK4554(capture)",
                .codec          = "ak4554-adc-dac.0",
                .platform       = "rcar_sound",
+               .daifmt         = SND_SOC_DAIFMT_CBS_CFS | SND_SOC_DAIFMT_LEFT_J,
                .cpu_dai = {
                        .name   = "rsnd-dai.2",
-                       .fmt    = SND_SOC_DAIFMT_CBM_CFM |
-                                 SND_SOC_DAIFMT_LEFT_J,
                },
                .codec_dai = {
                        .name   = "ak4554-hifi",
@@ -476,10 +512,9 @@ static struct asoc_simple_card_info rsnd_card_info[] = {
                .card           = "SSI7-AK4554(playback)",
                .codec          = "ak4554-adc-dac.1",
                .platform       = "rcar_sound",
+               .daifmt         = SND_SOC_DAIFMT_CBS_CFS | SND_SOC_DAIFMT_RIGHT_J,
                .cpu_dai = {
                        .name   = "rsnd-dai.3",
-                       .fmt    = SND_SOC_DAIFMT_CBM_CFM |
-                                 SND_SOC_DAIFMT_RIGHT_J,
                },
                .codec_dai = {
                        .name   = "ak4554-hifi",
@@ -491,10 +526,9 @@ static struct asoc_simple_card_info rsnd_card_info[] = {
                .card           = "SSI8-AK4554(capture)",
                .codec          = "ak4554-adc-dac.1",
                .platform       = "rcar_sound",
+               .daifmt         = SND_SOC_DAIFMT_CBS_CFS | SND_SOC_DAIFMT_LEFT_J,
                .cpu_dai = {
                        .name   = "rsnd-dai.4",
-                       .fmt    = SND_SOC_DAIFMT_CBM_CFM |
-                                 SND_SOC_DAIFMT_LEFT_J,
                },
                .codec_dai = {
                        .name   = "ak4554-hifi",
@@ -576,17 +610,14 @@ static void __init bockw_init(void)
 {
        void __iomem *base;
        struct clk *clk;
+       struct platform_device *pdev;
        int i;
 
        r8a7778_clock_init();
        r8a7778_init_irq_extpin(1);
        r8a7778_add_standard_devices();
 
-       platform_device_register_resndata(&platform_bus, "r8a777x-ether", -1,
-                                         ether_resources,
-                                         ARRAY_SIZE(ether_resources),
-                                         &ether_platform_data,
-                                         sizeof(ether_platform_data));
+       platform_device_register_full(&ether_info);
 
        platform_device_register_full(&vin0_info);
        /* VIN1 has a pin conflict with Ether */
@@ -662,9 +693,6 @@ static void __init bockw_init(void)
        }
 
        /* for Audio */
-       clk = clk_get(NULL, "audio_clk_b");
-       clk_set_rate(clk, 24576000);
-       clk_put(clk);
        rsnd_codec_power(5, 1); /* enable ak4642 */
 
        platform_device_register_simple(
@@ -673,11 +701,15 @@ static void __init bockw_init(void)
        platform_device_register_simple(
                "ak4554-adc-dac", 1, NULL, 0);
 
-       platform_device_register_resndata(
+       pdev = platform_device_register_resndata(
                &platform_bus, "rcar_sound", -1,
                rsnd_resources, ARRAY_SIZE(rsnd_resources),
                &rsnd_info, sizeof(rsnd_info));
 
+       clk = clk_get(&pdev->dev, "clk_b");
+       clk_set_rate(clk, 24576000);
+       clk_put(clk);
+
        for (i = 0; i < ARRAY_SIZE(rsnd_card_info); i++) {
                struct platform_device_info cardinfo = {
                        .parent         = &platform_bus,
@@ -704,7 +736,7 @@ static const char *bockw_boards_compat_dt[] __initdata = {
 };
 
 DT_MACHINE_START(BOCKW_DT, "bockw")
-       .init_early     = r8a7778_init_delay,
+       .init_early     = shmobile_init_delay,
        .init_irq       = r8a7778_init_irq_dt,
        .init_machine   = bockw_init,
        .dt_compat      = bockw_boards_compat_dt,
diff --git a/arch/arm/mach-shmobile/board-genmai-reference.c b/arch/arm/mach-shmobile/board-genmai-reference.c
deleted file mode 100644 (file)
index 7630c10..0000000
+++ /dev/null
@@ -1,49 +0,0 @@
-/*
- * Genmai board support
- *
- * Copyright (C) 2013  Renesas Solutions Corp.
- * Copyright (C) 2013  Magnus Damm
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; version 2 of the License.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
- */
-
-#include <linux/clk-provider.h>
-#include <linux/kernel.h>
-#include <linux/of_platform.h>
-#include <mach/common.h>
-#include <mach/r7s72100.h>
-#include <asm/mach-types.h>
-#include <asm/mach/arch.h>
-
-static void __init genmai_add_standard_devices(void)
-{
-#ifdef CONFIG_COMMON_CLK
-       of_clk_init(NULL);
-#else
-       r7s72100_clock_init();
-#endif
-       r7s72100_add_dt_devices();
-       of_platform_populate(NULL, of_default_bus_match_table, NULL, NULL);
-}
-
-static const char * const genmai_boards_compat_dt[] __initconst = {
-       "renesas,genmai-reference",
-       NULL,
-};
-
-DT_MACHINE_START(GENMAI_DT, "genmai")
-       .init_early     = r7s72100_init_early,
-       .init_machine   = genmai_add_standard_devices,
-       .dt_compat      = genmai_boards_compat_dt,
-MACHINE_END
diff --git a/arch/arm/mach-shmobile/board-genmai.c b/arch/arm/mach-shmobile/board-genmai.c
deleted file mode 100644 (file)
index 3e92e3c..0000000
+++ /dev/null
@@ -1,43 +0,0 @@
-/*
- * Genmai board support
- *
- * Copyright (C) 2013  Renesas Solutions Corp.
- * Copyright (C) 2013  Magnus Damm
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; version 2 of the License.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
- */
-
-#include <linux/kernel.h>
-#include <linux/platform_device.h>
-#include <mach/common.h>
-#include <mach/r7s72100.h>
-#include <asm/mach-types.h>
-#include <asm/mach/arch.h>
-
-static void __init genmai_add_standard_devices(void)
-{
-       r7s72100_clock_init();
-       r7s72100_add_dt_devices();
-}
-
-static const char * const genmai_boards_compat_dt[] __initconst = {
-       "renesas,genmai",
-       NULL,
-};
-
-DT_MACHINE_START(GENMAI_DT, "genmai")
-       .init_early     = r7s72100_init_early,
-       .init_machine   = genmai_add_standard_devices,
-       .dt_compat      = genmai_boards_compat_dt,
-MACHINE_END
index 652b592..46aa540 100644 (file)
  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
  */
 
-#include <linux/clk.h>
-#include <linux/clkdev.h>
+#include <linux/dma-mapping.h>
 #include <linux/kernel.h>
 #include <linux/of_platform.h>
-#include <mach/common.h>
-#include <mach/rcar-gen2.h>
-#include <mach/r8a7791.h>
+#include <linux/platform_data/rcar-du.h>
+
 #include <asm/mach/arch.h>
 
-static void __init koelsch_add_standard_devices(void)
+#include "clock.h"
+#include "common.h"
+#include "irqs.h"
+#include "r8a7791.h"
+#include "rcar-gen2.h"
+
+/* DU */
+static struct rcar_du_encoder_data koelsch_du_encoders[] = {
+       {
+               .type = RCAR_DU_ENCODER_NONE,
+               .output = RCAR_DU_OUTPUT_LVDS0,
+               .connector.lvds.panel = {
+                       .width_mm = 210,
+                       .height_mm = 158,
+                       .mode = {
+                               .pixelclock = 65000000,
+                               .hactive = 1024,
+                               .hfront_porch = 20,
+                               .hback_porch = 160,
+                               .hsync_len = 136,
+                               .vactive = 768,
+                               .vfront_porch = 3,
+                               .vback_porch = 29,
+                               .vsync_len = 6,
+                       },
+               },
+       },
+};
+
+static struct rcar_du_platform_data koelsch_du_pdata = {
+       .encoders = koelsch_du_encoders,
+       .num_encoders = ARRAY_SIZE(koelsch_du_encoders),
+};
+
+static const struct resource du_resources[] __initconst = {
+       DEFINE_RES_MEM(0xfeb00000, 0x40000),
+       DEFINE_RES_MEM_NAMED(0xfeb90000, 0x1c, "lvds.0"),
+       DEFINE_RES_IRQ(gic_spi(256)),
+       DEFINE_RES_IRQ(gic_spi(268)),
+};
+
+static void __init koelsch_add_du_device(void)
 {
-#ifdef CONFIG_COMMON_CLK
-       /*
-        * This is a really crude hack to provide clkdev support to the SCIF
-        * and CMT devices until they get moved to DT.
-        */
-       static const char * const scif_names[] = {
-               "scifa0", "scifa1", "scifb0", "scifb1", "scifb2", "scifa2",
-               "scif0", "scif1", "scif2", "scif3", "scif4", "scif5", "scifa3",
-               "scifa4", "scifa5",
+       struct platform_device_info info = {
+               .name = "rcar-du-r8a7791",
+               .id = -1,
+               .res = du_resources,
+               .num_res = ARRAY_SIZE(du_resources),
+               .data = &koelsch_du_pdata,
+               .size_data = sizeof(koelsch_du_pdata),
+               .dma_mask = DMA_BIT_MASK(32),
        };
-       struct clk *clk;
-       unsigned int i;
 
-       for (i = 0; i < ARRAY_SIZE(scif_names); ++i) {
-               clk = clk_get(NULL, scif_names[i]);
-               if (clk) {
-                       clk_register_clkdev(clk, NULL, "sh-sci.%u", i);
-                       clk_put(clk);
-               }
-       }
+       platform_device_register_full(&info);
+}
+
+/*
+ * This is a really crude hack to provide clkdev support to platform
+ * devices until they get moved to DT.
+ */
+static const struct clk_name clk_names[] __initconst = {
+       { "du0", "du.0", "rcar-du-r8a7791" },
+       { "du1", "du.1", "rcar-du-r8a7791" },
+       { "lvds0", "lvds.0", "rcar-du-r8a7791" },
+};
 
-       clk = clk_get(NULL, "cmt0");
-       if (clk) {
-               clk_register_clkdev(clk, NULL, "sh_cmt.0");
-               clk_put(clk);
-       }
-#else
-       r8a7791_clock_init();
-#endif
-       r8a7791_add_dt_devices();
+static void __init koelsch_add_standard_devices(void)
+{
+       shmobile_clk_workaround(clk_names, ARRAY_SIZE(clk_names), false);
        of_platform_populate(NULL, of_default_bus_match_table, NULL, NULL);
+
+       koelsch_add_du_device();
 }
 
 static const char * const koelsch_boards_compat_dt[] __initconst = {
@@ -71,9 +108,10 @@ static const char * const koelsch_boards_compat_dt[] __initconst = {
 
 DT_MACHINE_START(KOELSCH_DT, "koelsch")
        .smp            = smp_ops(r8a7791_smp_ops),
-       .init_early     = r8a7791_init_early,
+       .init_early     = shmobile_init_delay,
        .init_time      = rcar_gen2_timer_init,
        .init_machine   = koelsch_add_standard_devices,
        .init_late      = shmobile_init_late,
+       .reserve        = rcar_gen2_reserve,
        .dt_compat      = koelsch_boards_compat_dt,
 MACHINE_END
index de7cc64..7eb006e 100644 (file)
@@ -2,8 +2,9 @@
  * Koelsch board support
  *
  * Copyright (C) 2013  Renesas Electronics Corporation
- * Copyright (C) 2013  Renesas Solutions Corp.
+ * Copyright (C) 2013-2014  Renesas Solutions Corp.
  * Copyright (C) 2013  Magnus Damm
+ * Copyright (C) 2014  Cogent Embedded, 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
 #include <linux/gpio.h>
 #include <linux/gpio_keys.h>
 #include <linux/input.h>
+#include <linux/irq.h>
 #include <linux/kernel.h>
 #include <linux/leds.h>
+#include <linux/mfd/tmio.h>
+#include <linux/mmc/host.h>
+#include <linux/mmc/sh_mobile_sdhi.h>
+#include <linux/mtd/mtd.h>
+#include <linux/mtd/partitions.h>
 #include <linux/phy.h>
 #include <linux/pinctrl/machine.h>
 #include <linux/platform_data/gpio-rcar.h>
 #include <linux/platform_data/rcar-du.h>
 #include <linux/platform_device.h>
+#include <linux/regulator/driver.h>
+#include <linux/regulator/fixed.h>
+#include <linux/regulator/gpio-regulator.h>
+#include <linux/regulator/machine.h>
 #include <linux/sh_eth.h>
-#include <mach/common.h>
-#include <mach/irqs.h>
-#include <mach/r8a7791.h>
-#include <mach/rcar-gen2.h>
+#include <linux/spi/flash.h>
+#include <linux/spi/rspi.h>
+#include <linux/spi/spi.h>
+
 #include <asm/mach-types.h>
 #include <asm/mach/arch.h>
 
+#include "common.h"
+#include "irqs.h"
+#include "r8a7791.h"
+#include "rcar-gen2.h"
+
 /* DU */
 static struct rcar_du_encoder_data koelsch_du_encoders[] = {
        {
@@ -47,16 +63,15 @@ static struct rcar_du_encoder_data koelsch_du_encoders[] = {
                        .width_mm = 210,
                        .height_mm = 158,
                        .mode = {
-                               .clock = 65000,
-                               .hdisplay = 1024,
-                               .hsync_start = 1048,
-                               .hsync_end = 1184,
-                               .htotal = 1344,
-                               .vdisplay = 768,
-                               .vsync_start = 771,
-                               .vsync_end = 777,
-                               .vtotal = 806,
-                               .flags = 0,
+                               .pixelclock = 65000000,
+                               .hactive = 1024,
+                               .hfront_porch = 20,
+                               .hback_porch = 160,
+                               .hsync_len = 136,
+                               .vactive = 768,
+                               .vfront_porch = 3,
+                               .vback_porch = 29,
+                               .vsync_len = 6,
                        },
                },
        },
@@ -92,6 +107,7 @@ static void __init koelsch_add_du_device(void)
 /* Ether */
 static const struct sh_eth_plat_data ether_pdata __initconst = {
        .phy                    = 0x1,
+       .phy_irq                = irq_pin(0),
        .edmac_endian           = EDMAC_LITTLE_ENDIAN,
        .phy_interface          = PHY_INTERFACE_MODE_RMII,
        .ether_link_active_low  = 1,
@@ -102,6 +118,17 @@ static const struct resource ether_resources[] __initconst = {
        DEFINE_RES_IRQ(gic_spi(162)),
 };
 
+static const struct platform_device_info ether_info __initconst = {
+       .parent         = &platform_bus,
+       .name           = "r8a7791-ether",
+       .id             = -1,
+       .res            = ether_resources,
+       .num_res        = ARRAY_SIZE(ether_resources),
+       .data           = &ether_pdata,
+       .size_data      = sizeof(ether_pdata),
+       .dma_mask       = DMA_BIT_MASK(32),
+};
+
 /* LEDS */
 static struct gpio_led koelsch_leds[] = {
        {
@@ -148,6 +175,196 @@ static const struct gpio_keys_platform_data koelsch_keys_pdata __initconst = {
        .nbuttons       = ARRAY_SIZE(gpio_buttons),
 };
 
+/* QSPI */
+static const struct resource qspi_resources[] __initconst = {
+       DEFINE_RES_MEM(0xe6b10000, 0x1000),
+       DEFINE_RES_IRQ_NAMED(gic_spi(184), "mux"),
+};
+
+static const struct rspi_plat_data qspi_pdata __initconst = {
+       .num_chipselect = 1,
+};
+
+/* SPI Flash memory (Spansion S25FL512SAGMFIG11 64 MiB) */
+static struct mtd_partition spi_flash_part[] = {
+       {
+               .name           = "loader",
+               .offset         = 0x00000000,
+               .size           = 512 * 1024,
+               .mask_flags     = MTD_WRITEABLE,
+       },
+       {
+               .name           = "bootenv",
+               .offset         = MTDPART_OFS_APPEND,
+               .size           = 512 * 1024,
+               .mask_flags     = MTD_WRITEABLE,
+       },
+       {
+               .name           = "data",
+               .offset         = MTDPART_OFS_APPEND,
+               .size           = MTDPART_SIZ_FULL,
+       },
+};
+
+static const struct flash_platform_data spi_flash_data = {
+       .name           = "m25p80",
+       .parts          = spi_flash_part,
+       .nr_parts       = ARRAY_SIZE(spi_flash_part),
+       .type           = "s25fl512s",
+};
+
+static const struct spi_board_info spi_info[] __initconst = {
+       {
+               .modalias       = "m25p80",
+               .platform_data  = &spi_flash_data,
+               .mode           = SPI_MODE_0 | SPI_TX_QUAD | SPI_RX_QUAD,
+               .max_speed_hz   = 30000000,
+               .bus_num        = 0,
+               .chip_select    = 0,
+       },
+};
+
+/* SATA0 */
+static const struct resource sata0_resources[] __initconst = {
+       DEFINE_RES_MEM(0xee300000, 0x2000),
+       DEFINE_RES_IRQ(gic_spi(105)),
+};
+
+static const struct platform_device_info sata0_info __initconst = {
+       .parent         = &platform_bus,
+       .name           = "sata-r8a7791",
+       .id             = 0,
+       .res            = sata0_resources,
+       .num_res        = ARRAY_SIZE(sata0_resources),
+       .dma_mask       = DMA_BIT_MASK(32),
+};
+
+/* I2C */
+static const struct resource i2c_resources[] __initconst = {
+       /* I2C0 */
+       DEFINE_RES_MEM(0xE6508000, 0x40),
+       DEFINE_RES_IRQ(gic_spi(287)),
+       /* I2C1 */
+       DEFINE_RES_MEM(0xE6518000, 0x40),
+       DEFINE_RES_IRQ(gic_spi(288)),
+       /* I2C2 */
+       DEFINE_RES_MEM(0xE6530000, 0x40),
+       DEFINE_RES_IRQ(gic_spi(286)),
+       /* I2C3 */
+       DEFINE_RES_MEM(0xE6540000, 0x40),
+       DEFINE_RES_IRQ(gic_spi(290)),
+       /* I2C4 */
+       DEFINE_RES_MEM(0xE6520000, 0x40),
+       DEFINE_RES_IRQ(gic_spi(19)),
+       /* I2C5 */
+       DEFINE_RES_MEM(0xE6528000, 0x40),
+       DEFINE_RES_IRQ(gic_spi(20)),
+};
+
+static void __init koelsch_add_i2c(unsigned idx)
+{
+       unsigned res_idx = idx * 2;
+
+       BUG_ON(res_idx >= ARRAY_SIZE(i2c_resources));
+
+       platform_device_register_simple("i2c-rcar_gen2", idx,
+                                       i2c_resources + res_idx, 2);
+}
+
+#define SDHI_REGULATOR(idx, vdd_pin, vccq_pin)                         \
+static struct regulator_consumer_supply vcc_sdhi##idx##_consumer =     \
+       REGULATOR_SUPPLY("vmmc", "sh_mobile_sdhi." #idx);               \
+                                                                       \
+static struct regulator_init_data vcc_sdhi##idx##_init_data = {                \
+       .constraints = {                                                \
+               .valid_ops_mask = REGULATOR_CHANGE_STATUS,              \
+       },                                                              \
+       .consumer_supplies      = &vcc_sdhi##idx##_consumer,            \
+       .num_consumer_supplies  = 1,                                    \
+};                                                                     \
+                                                                       \
+static const struct fixed_voltage_config vcc_sdhi##idx##_info __initconst = {\
+       .supply_name    = "SDHI" #idx "Vcc",                            \
+       .microvolts     = 3300000,                                      \
+       .gpio           = vdd_pin,                                      \
+       .enable_high    = 1,                                            \
+       .init_data      = &vcc_sdhi##idx##_init_data,                   \
+};                                                                     \
+                                                                       \
+static struct regulator_consumer_supply vccq_sdhi##idx##_consumer =    \
+       REGULATOR_SUPPLY("vqmmc", "sh_mobile_sdhi." #idx);              \
+                                                                       \
+static struct regulator_init_data vccq_sdhi##idx##_init_data = {       \
+       .constraints = {                                                \
+               .input_uV       = 3300000,                              \
+               .min_uV         = 1800000,                              \
+               .max_uV         = 3300000,                              \
+               .valid_ops_mask = REGULATOR_CHANGE_VOLTAGE |            \
+                                 REGULATOR_CHANGE_STATUS,              \
+       },                                                              \
+       .consumer_supplies      = &vccq_sdhi##idx##_consumer,           \
+       .num_consumer_supplies  = 1,                                    \
+};                                                                     \
+                                                                       \
+static struct gpio vccq_sdhi##idx##_gpio =                             \
+       { vccq_pin, GPIOF_OUT_INIT_HIGH, "vccq-sdhi" #idx };            \
+                                                                       \
+static struct gpio_regulator_state vccq_sdhi##idx##_states[] = {       \
+       { .value = 1800000, .gpios = 0 },                               \
+       { .value = 3300000, .gpios = 1 },                               \
+};                                                                     \
+                                                                       \
+static const struct gpio_regulator_config vccq_sdhi##idx##_info __initconst = {\
+       .supply_name    = "vqmmc",                                      \
+       .gpios          = &vccq_sdhi##idx##_gpio,                       \
+       .nr_gpios       = 1,                                            \
+       .states         = vccq_sdhi##idx##_states,                      \
+       .nr_states      = ARRAY_SIZE(vccq_sdhi##idx##_states),          \
+       .type           = REGULATOR_VOLTAGE,                            \
+       .init_data      = &vccq_sdhi##idx##_init_data,                  \
+};
+
+SDHI_REGULATOR(0, RCAR_GP_PIN(7, 17), RCAR_GP_PIN(2, 12));
+SDHI_REGULATOR(1, RCAR_GP_PIN(7, 18), RCAR_GP_PIN(2, 13));
+SDHI_REGULATOR(2, RCAR_GP_PIN(7, 19), RCAR_GP_PIN(2, 26));
+
+/* SDHI0 */
+static struct sh_mobile_sdhi_info sdhi0_info __initdata = {
+       .tmio_caps      = MMC_CAP_SD_HIGHSPEED | MMC_CAP_SDIO_IRQ |
+                         MMC_CAP_POWER_OFF_CARD,
+       .tmio_flags     = TMIO_MMC_HAS_IDLE_WAIT,
+};
+
+static struct resource sdhi0_resources[] __initdata = {
+       DEFINE_RES_MEM(0xee100000, 0x200),
+       DEFINE_RES_IRQ(gic_spi(165)),
+};
+
+/* SDHI1 */
+static struct sh_mobile_sdhi_info sdhi1_info __initdata = {
+       .tmio_caps      = MMC_CAP_SD_HIGHSPEED | MMC_CAP_SDIO_IRQ |
+                         MMC_CAP_POWER_OFF_CARD,
+       .tmio_flags     = TMIO_MMC_HAS_IDLE_WAIT,
+};
+
+static struct resource sdhi1_resources[] __initdata = {
+       DEFINE_RES_MEM(0xee140000, 0x100),
+       DEFINE_RES_IRQ(gic_spi(167)),
+};
+
+/* SDHI2 */
+static struct sh_mobile_sdhi_info sdhi2_info __initdata = {
+       .tmio_caps      = MMC_CAP_SD_HIGHSPEED | MMC_CAP_SDIO_IRQ |
+                         MMC_CAP_POWER_OFF_CARD,
+       .tmio_flags     = TMIO_MMC_HAS_IDLE_WAIT |
+                         TMIO_MMC_WRPROTECT_DISABLE,
+};
+
+static struct resource sdhi2_resources[] __initdata = {
+       DEFINE_RES_MEM(0xee160000, 0x100),
+       DEFINE_RES_IRQ(gic_spi(168)),
+};
+
 static const struct pinctrl_map koelsch_pinctrl_map[] = {
        /* DU */
        PIN_MAP_MUX_GROUP_DEFAULT("rcar-du-r8a7791", "pfc-r8a7791",
@@ -165,12 +382,51 @@ static const struct pinctrl_map koelsch_pinctrl_map[] = {
                                  "eth_rmii", "eth"),
        PIN_MAP_MUX_GROUP_DEFAULT("r8a7791-ether", "pfc-r8a7791",
                                  "intc_irq0", "intc"),
+       /* QSPI */
+       PIN_MAP_MUX_GROUP_DEFAULT("qspi.0", "pfc-r8a7791",
+                                 "qspi_ctrl", "qspi"),
+       PIN_MAP_MUX_GROUP_DEFAULT("qspi.0", "pfc-r8a7791",
+                                 "qspi_data4", "qspi"),
        /* SCIF0 (CN19: DEBUG SERIAL0) */
        PIN_MAP_MUX_GROUP_DEFAULT("sh-sci.6", "pfc-r8a7791",
                                  "scif0_data_d", "scif0"),
        /* SCIF1 (CN20: DEBUG SERIAL1) */
        PIN_MAP_MUX_GROUP_DEFAULT("sh-sci.7", "pfc-r8a7791",
                                  "scif1_data_d", "scif1"),
+       /* I2C1 */
+       PIN_MAP_MUX_GROUP_DEFAULT("i2c-rcar_gen2.1", "pfc-r8a7791",
+                                 "i2c1_e", "i2c1"),
+       /* I2C2 */
+       PIN_MAP_MUX_GROUP_DEFAULT("i2c-rcar_gen2.2", "pfc-r8a7791",
+                                 "i2c2", "i2c2"),
+       /* I2C4 */
+       PIN_MAP_MUX_GROUP_DEFAULT("i2c-rcar_gen2.4", "pfc-r8a7791",
+                                 "i2c4_c", "i2c4"),
+       /* SDHI0 */
+       PIN_MAP_MUX_GROUP_DEFAULT("sh_mobile_sdhi.0", "pfc-r8a7791",
+                                 "sdhi0_data4", "sdhi0"),
+       PIN_MAP_MUX_GROUP_DEFAULT("sh_mobile_sdhi.0", "pfc-r8a7791",
+                                 "sdhi0_ctrl", "sdhi0"),
+       PIN_MAP_MUX_GROUP_DEFAULT("sh_mobile_sdhi.0", "pfc-r8a7791",
+                                 "sdhi0_cd", "sdhi0"),
+       PIN_MAP_MUX_GROUP_DEFAULT("sh_mobile_sdhi.0", "pfc-r8a7791",
+                                 "sdhi0_wp", "sdhi0"),
+       /* SDHI2 */
+       PIN_MAP_MUX_GROUP_DEFAULT("sh_mobile_sdhi.1", "pfc-r8a7791",
+                                 "sdhi1_data4", "sdhi1"),
+       PIN_MAP_MUX_GROUP_DEFAULT("sh_mobile_sdhi.1", "pfc-r8a7791",
+                                 "sdhi1_ctrl", "sdhi1"),
+       PIN_MAP_MUX_GROUP_DEFAULT("sh_mobile_sdhi.1", "pfc-r8a7791",
+                                 "sdhi1_cd", "sdhi1"),
+       PIN_MAP_MUX_GROUP_DEFAULT("sh_mobile_sdhi.1", "pfc-r8a7791",
+                                 "sdhi1_wp", "sdhi1"),
+       /* SDHI2 */
+       PIN_MAP_MUX_GROUP_DEFAULT("sh_mobile_sdhi.2", "pfc-r8a7791",
+                                 "sdhi2_data4", "sdhi2"),
+       PIN_MAP_MUX_GROUP_DEFAULT("sh_mobile_sdhi.2", "pfc-r8a7791",
+                                 "sdhi2_ctrl", "sdhi2"),
+       PIN_MAP_MUX_GROUP_DEFAULT("sh_mobile_sdhi.2", "pfc-r8a7791",
+                                 "sdhi2_cd", "sdhi2"),
 };
 
 static void __init koelsch_add_standard_devices(void)
@@ -180,18 +436,53 @@ static void __init koelsch_add_standard_devices(void)
                                  ARRAY_SIZE(koelsch_pinctrl_map));
        r8a7791_pinmux_init();
        r8a7791_add_standard_devices();
-       platform_device_register_resndata(&platform_bus, "r8a7791-ether", -1,
-                                         ether_resources,
-                                         ARRAY_SIZE(ether_resources),
-                                         &ether_pdata, sizeof(ether_pdata));
+       platform_device_register_full(&ether_info);
        platform_device_register_data(&platform_bus, "leds-gpio", -1,
                                      &koelsch_leds_pdata,
                                      sizeof(koelsch_leds_pdata));
        platform_device_register_data(&platform_bus, "gpio-keys", -1,
                                      &koelsch_keys_pdata,
                                      sizeof(koelsch_keys_pdata));
+       platform_device_register_resndata(&platform_bus, "qspi", 0,
+                                         qspi_resources,
+                                         ARRAY_SIZE(qspi_resources),
+                                         &qspi_pdata, sizeof(qspi_pdata));
+       spi_register_board_info(spi_info, ARRAY_SIZE(spi_info));
 
        koelsch_add_du_device();
+
+       platform_device_register_full(&sata0_info);
+
+       koelsch_add_i2c(1);
+       koelsch_add_i2c(2);
+       koelsch_add_i2c(4);
+       koelsch_add_i2c(5);
+
+       platform_device_register_data(&platform_bus, "reg-fixed-voltage", 0,
+                                     &vcc_sdhi0_info, sizeof(struct fixed_voltage_config));
+       platform_device_register_data(&platform_bus, "reg-fixed-voltage", 1,
+                                     &vcc_sdhi1_info, sizeof(struct fixed_voltage_config));
+       platform_device_register_data(&platform_bus, "reg-fixed-voltage", 2,
+                                     &vcc_sdhi2_info, sizeof(struct fixed_voltage_config));
+       platform_device_register_data(&platform_bus, "gpio-regulator", 0,
+                                     &vccq_sdhi0_info, sizeof(struct gpio_regulator_config));
+       platform_device_register_data(&platform_bus, "gpio-regulator", 1,
+                                     &vccq_sdhi1_info, sizeof(struct gpio_regulator_config));
+       platform_device_register_data(&platform_bus, "gpio-regulator", 2,
+                                     &vccq_sdhi2_info, sizeof(struct gpio_regulator_config));
+
+       platform_device_register_resndata(&platform_bus, "sh_mobile_sdhi", 0,
+                                         sdhi0_resources, ARRAY_SIZE(sdhi0_resources),
+                                         &sdhi0_info, sizeof(struct sh_mobile_sdhi_info));
+
+       platform_device_register_resndata(&platform_bus, "sh_mobile_sdhi", 1,
+                                         sdhi1_resources, ARRAY_SIZE(sdhi1_resources),
+                                         &sdhi1_info, sizeof(struct sh_mobile_sdhi_info));
+
+       platform_device_register_resndata(&platform_bus, "sh_mobile_sdhi", 2,
+                                         sdhi2_resources, ARRAY_SIZE(sdhi2_resources),
+                                         &sdhi2_info, sizeof(struct sh_mobile_sdhi_info));
+
 }
 
 /*
@@ -215,6 +506,8 @@ static void __init koelsch_init(void)
 {
        koelsch_add_standard_devices();
 
+       irq_set_irq_type(irq_pin(0), IRQ_TYPE_LEVEL_LOW);
+
        if (IS_ENABLED(CONFIG_PHYLIB))
                phy_register_fixup_for_id("r8a7791-ether-ff:01",
                                          koelsch_ksz8041_fixup);
@@ -227,9 +520,10 @@ static const char * const koelsch_boards_compat_dt[] __initconst = {
 
 DT_MACHINE_START(KOELSCH_DT, "koelsch")
        .smp            = smp_ops(r8a7791_smp_ops),
-       .init_early     = r8a7791_init_early,
+       .init_early     = shmobile_init_delay,
        .init_time      = rcar_gen2_timer_init,
        .init_machine   = koelsch_init,
        .init_late      = shmobile_init_late,
+       .reserve        = rcar_gen2_reserve,
        .dt_compat      = koelsch_boards_compat_dt,
 MACHINE_END
diff --git a/arch/arm/mach-shmobile/board-kzm9d-reference.c b/arch/arm/mach-shmobile/board-kzm9d-reference.c
deleted file mode 100644 (file)
index 054d8d5..0000000
+++ /dev/null
@@ -1,48 +0,0 @@
-/*
- * kzm9d board support - Reference DT implementation
- *
- * Copyright (C) 2013  Renesas Solutions Corp.
- * Copyright (C) 2013  Magnus Damm
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; version 2 of the License.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
- */
-
-#include <linux/init.h>
-#include <linux/of_platform.h>
-#include <mach/emev2.h>
-#include <mach/common.h>
-#include <asm/mach/arch.h>
-
-static void __init kzm9d_add_standard_devices(void)
-{
-       if (!IS_ENABLED(CONFIG_COMMON_CLK))
-               emev2_clock_init();
-
-       of_platform_populate(NULL, of_default_bus_match_table, NULL, NULL);
-}
-
-static const char *kzm9d_boards_compat_dt[] __initdata = {
-       "renesas,kzm9d",
-       "renesas,kzm9d-reference",
-       NULL,
-};
-
-DT_MACHINE_START(KZM9D_DT, "kzm9d")
-       .smp            = smp_ops(emev2_smp_ops),
-       .map_io         = emev2_map_io,
-       .init_early     = emev2_init_delay,
-       .init_machine   = kzm9d_add_standard_devices,
-       .init_late      = shmobile_init_late,
-       .dt_compat      = kzm9d_boards_compat_dt,
-MACHINE_END
index 598e324..aa9c3e6 100644 (file)
 #include <linux/irq.h>
 #include <linux/input.h>
 #include <linux/of_platform.h>
-#include <mach/sh73a0.h>
-#include <mach/common.h>
+
 #include <asm/hardware/cache-l2x0.h>
 #include <asm/mach-types.h>
 #include <asm/mach/arch.h>
 
+#include "common.h"
+#include "sh73a0.h"
+
 static void __init kzm_init(void)
 {
        sh73a0_add_standard_devices_dt();
@@ -49,8 +51,8 @@ static const char *kzm9g_boards_compat_dt[] __initdata = {
 DT_MACHINE_START(KZM9G_DT, "kzm9g-reference")
        .smp            = smp_ops(sh73a0_smp_ops),
        .map_io         = sh73a0_map_io,
-       .init_early     = sh73a0_init_delay,
-       .nr_irqs        = NR_IRQS_LEGACY,
+       .init_early     = shmobile_init_delay,
        .init_machine   = kzm_init,
+       .init_late      = shmobile_init_late,
        .dt_compat      = kzm9g_boards_compat_dt,
 MACHINE_END
index bc40b85..573cef2 100644 (file)
 #include <linux/usb/r8a66597.h>
 #include <linux/usb/renesas_usbhs.h>
 #include <linux/videodev2.h>
+
 #include <sound/sh_fsi.h>
 #include <sound/simple_card.h>
-#include <mach/irqs.h>
-#include <mach/sh73a0.h>
-#include <mach/common.h>
 #include <asm/hardware/cache-l2x0.h>
 #include <asm/mach-types.h>
 #include <asm/mach/arch.h>
 #include <video/sh_mobile_lcdc.h>
 
+#include "common.h"
+#include "intc.h"
+#include "irqs.h"
+#include "sh73a0.h"
+
 /*
  * external GPIO
  */
@@ -589,14 +592,12 @@ static struct asoc_simple_card_info fsi2_ak4648_info = {
        .card           = "FSI2A-AK4648",
        .codec          = "ak4642-codec.0-0012",
        .platform       = "sh_fsi2",
-       .daifmt         = SND_SOC_DAIFMT_LEFT_J,
+       .daifmt         = SND_SOC_DAIFMT_LEFT_J | SND_SOC_DAIFMT_CBM_CFM,
        .cpu_dai = {
                .name   = "fsia-dai",
-               .fmt    = SND_SOC_DAIFMT_CBS_CFS,
        },
        .codec_dai = {
                .name   = "ak4642-hifi",
-               .fmt    = SND_SOC_DAIFMT_CBM_CFM,
                .sysclk = 11289600,
        },
 };
@@ -605,6 +606,8 @@ static struct platform_device fsi_ak4648_device = {
        .name   = "asoc-simple-card",
        .dev    = {
                .platform_data  = &fsi2_ak4648_info,
+               .coherent_dma_mask = DMA_BIT_MASK(32),
+               .dma_mask = &fsi_ak4648_device.dev.coherent_dma_mask,
        },
 };
 
@@ -908,7 +911,6 @@ DT_MACHINE_START(KZM9G_DT, "kzm9g")
        .smp            = smp_ops(sh73a0_smp_ops),
        .map_io         = sh73a0_map_io,
        .init_early     = sh73a0_add_early_devices,
-       .nr_irqs        = NR_IRQS_LEGACY,
        .init_irq       = sh73a0_init_irq,
        .init_machine   = kzm_init,
        .init_late      = shmobile_init_late,
index a6e271d..bc4b483 100644 (file)
  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
  */
 
-#include <linux/clk.h>
-#include <linux/clkdev.h>
+#include <linux/dma-mapping.h>
 #include <linux/init.h>
 #include <linux/of_platform.h>
-#include <mach/common.h>
-#include <mach/rcar-gen2.h>
-#include <mach/r8a7790.h>
+#include <linux/platform_data/rcar-du.h>
+
 #include <asm/mach/arch.h>
 
-static void __init lager_add_standard_devices(void)
+#include "clock.h"
+#include "common.h"
+#include "irqs.h"
+#include "r8a7790.h"
+#include "rcar-gen2.h"
+
+/* DU */
+static struct rcar_du_encoder_data lager_du_encoders[] = {
+       {
+               .type = RCAR_DU_ENCODER_VGA,
+               .output = RCAR_DU_OUTPUT_DPAD0,
+       }, {
+               .type = RCAR_DU_ENCODER_NONE,
+               .output = RCAR_DU_OUTPUT_LVDS1,
+               .connector.lvds.panel = {
+                       .width_mm = 210,
+                       .height_mm = 158,
+                       .mode = {
+                               .pixelclock = 65000000,
+                               .hactive = 1024,
+                               .hfront_porch = 20,
+                               .hback_porch = 160,
+                               .hsync_len = 136,
+                               .vactive = 768,
+                               .vfront_porch = 3,
+                               .vback_porch = 29,
+                               .vsync_len = 6,
+                       },
+               },
+       },
+};
+
+static struct rcar_du_platform_data lager_du_pdata = {
+       .encoders = lager_du_encoders,
+       .num_encoders = ARRAY_SIZE(lager_du_encoders),
+};
+
+static const struct resource du_resources[] __initconst = {
+       DEFINE_RES_MEM(0xfeb00000, 0x70000),
+       DEFINE_RES_MEM_NAMED(0xfeb90000, 0x1c, "lvds.0"),
+       DEFINE_RES_MEM_NAMED(0xfeb94000, 0x1c, "lvds.1"),
+       DEFINE_RES_IRQ(gic_spi(256)),
+       DEFINE_RES_IRQ(gic_spi(268)),
+       DEFINE_RES_IRQ(gic_spi(269)),
+};
+
+static void __init lager_add_du_device(void)
 {
-#ifdef CONFIG_COMMON_CLK
-       /*
-        * This is a really crude hack to provide clkdev support to the SCIF
-        * and CMT devices until they get moved to DT.
-        */
-       static const char * const scif_names[] = {
-               "scifa0", "scifa1", "scifb0", "scifb1",
-               "scifb2", "scifa2", "scif0", "scif1",
-               "hscif0", "hscif1",
+       struct platform_device_info info = {
+               .name = "rcar-du-r8a7790",
+               .id = -1,
+               .res = du_resources,
+               .num_res = ARRAY_SIZE(du_resources),
+               .data = &lager_du_pdata,
+               .size_data = sizeof(lager_du_pdata),
+               .dma_mask = DMA_BIT_MASK(32),
        };
-       struct clk *clk;
-       unsigned int i;
 
-       for (i = 0; i < ARRAY_SIZE(scif_names); ++i) {
-               clk = clk_get(NULL, scif_names[i]);
-               if (clk) {
-                       clk_register_clkdev(clk, NULL, "sh-sci.%u", i);
-                       clk_put(clk);
-               }
-       }
+       platform_device_register_full(&info);
+}
 
-       clk = clk_get(NULL, "cmt0");
-       if (clk) {
-               clk_register_clkdev(clk, NULL, "sh_cmt.0");
-               clk_put(clk);
-       }
-#else
-       r8a7790_clock_init();
-#endif
+/*
+ * This is a really crude hack to provide clkdev support to platform
+ * devices until they get moved to DT.
+ */
+static const struct clk_name clk_names[] __initconst = {
+       { "du0", "du.0", "rcar-du-r8a7790" },
+       { "du1", "du.1", "rcar-du-r8a7790" },
+       { "du2", "du.2", "rcar-du-r8a7790" },
+       { "lvds0", "lvds.0", "rcar-du-r8a7790" },
+       { "lvds1", "lvds.1", "rcar-du-r8a7790" },
+};
 
-       r8a7790_add_dt_devices();
+static void __init lager_add_standard_devices(void)
+{
+       shmobile_clk_workaround(clk_names, ARRAY_SIZE(clk_names), false);
        of_platform_populate(NULL, of_default_bus_match_table, NULL, NULL);
+
+       lager_add_du_device();
 }
 
 static const char *lager_boards_compat_dt[] __initdata = {
@@ -71,9 +114,10 @@ static const char *lager_boards_compat_dt[] __initdata = {
 
 DT_MACHINE_START(LAGER_DT, "lager")
        .smp            = smp_ops(r8a7790_smp_ops),
-       .init_early     = r8a7790_init_early,
+       .init_early     = shmobile_init_delay,
        .init_time      = rcar_gen2_timer_init,
        .init_machine   = lager_add_standard_devices,
        .init_late      = shmobile_init_late,
+       .reserve        = rcar_gen2_reserve,
        .dt_compat      = lager_boards_compat_dt,
 MACHINE_END
index f20c10a..ac0ece4 100644 (file)
@@ -1,8 +1,9 @@
 /*
  * Lager board support
  *
- * Copyright (C) 2013  Renesas Solutions Corp.
+ * Copyright (C) 2013-2014  Renesas Solutions Corp.
  * Copyright (C) 2013  Magnus Damm
+ * Copyright (C) 2014  Cogent Embedded, 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
 
 #include <linux/gpio.h>
 #include <linux/gpio_keys.h>
+#include <linux/i2c.h>
 #include <linux/input.h>
 #include <linux/interrupt.h>
+#include <linux/irq.h>
 #include <linux/kernel.h>
 #include <linux/leds.h>
+#include <linux/mfd/tmio.h>
 #include <linux/mmc/host.h>
 #include <linux/mmc/sh_mmcif.h>
+#include <linux/mmc/sh_mobile_sdhi.h>
+#include <linux/mtd/partitions.h>
+#include <linux/mtd/mtd.h>
 #include <linux/pinctrl/machine.h>
+#include <linux/platform_data/camera-rcar.h>
 #include <linux/platform_data/gpio-rcar.h>
 #include <linux/platform_data/rcar-du.h>
+#include <linux/platform_data/usb-rcar-gen2-phy.h>
 #include <linux/platform_device.h>
 #include <linux/phy.h>
 #include <linux/regulator/driver.h>
 #include <linux/regulator/gpio-regulator.h>
 #include <linux/regulator/machine.h>
 #include <linux/sh_eth.h>
-#include <mach/common.h>
-#include <mach/irqs.h>
-#include <mach/r8a7790.h>
-#include <asm/mach-types.h>
-#include <asm/mach/arch.h>
-#include <linux/mtd/partitions.h>
-#include <linux/mtd/mtd.h>
 #include <linux/spi/flash.h>
 #include <linux/spi/rspi.h>
 #include <linux/spi/spi.h>
+#include <linux/usb/phy.h>
+#include <linux/usb/renesas_usbhs.h>
+
+#include <media/soc_camera.h>
+#include <asm/mach-types.h>
+#include <asm/mach/arch.h>
+#include <sound/rcar_snd.h>
+#include <sound/simple_card.h>
+
+#include "common.h"
+#include "irqs.h"
+#include "r8a7790.h"
+#include "rcar-gen2.h"
+
+/*
+ * SSI-AK4643
+ *
+ * SW1: 1: AK4643
+ *      2: CN22
+ *      3: ADV7511
+ *
+ * this command is required when playback.
+ *
+ * # amixer set "LINEOUT Mixer DACL" on
+ */
+
+/*
+ * SDHI0 (CN8)
+ *
+ * JP3:  pin1
+ * SW20: pin1
+
+ * GP5_24:     1:  VDD  3.3V (defult)
+ *             0:  VDD  0.0V
+ * GP5_29:     1:  VccQ 3.3V (defult)
+ *             0:  VccQ 1.8V
+ *
+ */
 
 /* DU */
 static struct rcar_du_encoder_data lager_du_encoders[] = {
@@ -59,16 +99,15 @@ static struct rcar_du_encoder_data lager_du_encoders[] = {
                        .width_mm = 210,
                        .height_mm = 158,
                        .mode = {
-                               .clock = 65000,
-                               .hdisplay = 1024,
-                               .hsync_start = 1048,
-                               .hsync_end = 1184,
-                               .htotal = 1344,
-                               .vdisplay = 768,
-                               .vsync_start = 771,
-                               .vsync_end = 777,
-                               .vtotal = 806,
-                               .flags = 0,
+                               .pixelclock = 65000000,
+                               .hactive = 1024,
+                               .hfront_porch = 20,
+                               .hback_porch = 160,
+                               .hsync_len = 136,
+                               .vactive = 768,
+                               .vfront_porch = 3,
+                               .vback_porch = 29,
+                               .vsync_len = 6,
                        },
                },
        },
@@ -228,6 +267,7 @@ static const struct resource mmcif1_resources[] __initconst = {
 /* Ether */
 static const struct sh_eth_plat_data ether_pdata __initconst = {
        .phy                    = 0x1,
+       .phy_irq                = irq_pin(0),
        .edmac_endian           = EDMAC_LITTLE_ENDIAN,
        .phy_interface          = PHY_INTERFACE_MODE_RMII,
        .ether_link_active_low  = 1,
@@ -238,6 +278,17 @@ static const struct resource ether_resources[] __initconst = {
        DEFINE_RES_IRQ(gic_spi(162)),
 };
 
+static const struct platform_device_info ether_info __initconst = {
+       .parent         = &platform_bus,
+       .name           = "r8a7790-ether",
+       .id             = -1,
+       .res            = ether_resources,
+       .num_res        = ARRAY_SIZE(ether_resources),
+       .data           = &ether_pdata,
+       .size_data      = sizeof(ether_pdata),
+       .dma_mask       = DMA_BIT_MASK(32),
+};
+
 /* SPI Flash memory (Spansion S25FL512SAGMFIG11 64Mb) */
 static struct mtd_partition spi_flash_part[] = {
        /* Reserved for user loader program, read-only */
@@ -263,7 +314,7 @@ static struct mtd_partition spi_flash_part[] = {
        },
 };
 
-static struct flash_platform_data spi_flash_data = {
+static const struct flash_platform_data spi_flash_data = {
        .name           = "m25p80",
        .parts          = spi_flash_part,
        .nr_parts       = ARRAY_SIZE(spi_flash_part),
@@ -276,21 +327,376 @@ static const struct rspi_plat_data qspi_pdata __initconst = {
 
 static const struct spi_board_info spi_info[] __initconst = {
        {
-               .modalias               = "m25p80",
-               .platform_data          = &spi_flash_data,
-               .mode                   = SPI_MODE_0,
-               .max_speed_hz           = 30000000,
-               .bus_num                = 0,
-               .chip_select            = 0,
+               .modalias       = "m25p80",
+               .platform_data  = &spi_flash_data,
+               .mode           = SPI_MODE_0 | SPI_TX_QUAD | SPI_RX_QUAD,
+               .max_speed_hz   = 30000000,
+               .bus_num        = 0,
+               .chip_select    = 0,
        },
 };
 
 /* QSPI resource */
 static const struct resource qspi_resources[] __initconst = {
        DEFINE_RES_MEM(0xe6b10000, 0x1000),
-       DEFINE_RES_IRQ(gic_spi(184)),
+       DEFINE_RES_IRQ_NAMED(gic_spi(184), "mux"),
+};
+
+/* VIN */
+static const struct resource vin_resources[] __initconst = {
+       /* VIN0 */
+       DEFINE_RES_MEM(0xe6ef0000, 0x1000),
+       DEFINE_RES_IRQ(gic_spi(188)),
+       /* VIN1 */
+       DEFINE_RES_MEM(0xe6ef1000, 0x1000),
+       DEFINE_RES_IRQ(gic_spi(189)),
+};
+
+static void __init lager_add_vin_device(unsigned idx,
+                                       struct rcar_vin_platform_data *pdata)
+{
+       struct platform_device_info vin_info = {
+               .parent         = &platform_bus,
+               .name           = "r8a7790-vin",
+               .id             = idx,
+               .res            = &vin_resources[idx * 2],
+               .num_res        = 2,
+               .dma_mask       = DMA_BIT_MASK(32),
+               .data           = pdata,
+               .size_data      = sizeof(*pdata),
+       };
+
+       BUG_ON(idx > 1);
+
+       platform_device_register_full(&vin_info);
+}
+
+#define LAGER_CAMERA(idx, name, addr, pdata, flag)                     \
+static struct i2c_board_info i2c_cam##idx##_device = {                 \
+       I2C_BOARD_INFO(name, addr),                                     \
+};                                                                     \
+                                                                       \
+static struct rcar_vin_platform_data vin##idx##_pdata = {              \
+       .flags = flag,                                                  \
+};                                                                     \
+                                                                       \
+static struct soc_camera_link cam##idx##_link = {                      \
+       .bus_id = idx,                                                  \
+       .board_info = &i2c_cam##idx##_device,                           \
+       .i2c_adapter_id = 2,                                            \
+       .module_name = name,                                            \
+       .priv = pdata,                                                  \
+}
+
+/* Camera 0 is not currently supported due to adv7612 support missing */
+LAGER_CAMERA(1, "adv7180", 0x20, NULL, RCAR_VIN_BT656);
+
+static void __init lager_add_camera1_device(void)
+{
+       platform_device_register_data(&platform_bus, "soc-camera-pdrv", 1,
+                                     &cam1_link, sizeof(cam1_link));
+       lager_add_vin_device(1, &vin1_pdata);
+}
+
+/* SATA1 */
+static const struct resource sata1_resources[] __initconst = {
+       DEFINE_RES_MEM(0xee500000, 0x2000),
+       DEFINE_RES_IRQ(gic_spi(106)),
+};
+
+static const struct platform_device_info sata1_info __initconst = {
+       .parent         = &platform_bus,
+       .name           = "sata-r8a7790",
+       .id             = 1,
+       .res            = sata1_resources,
+       .num_res        = ARRAY_SIZE(sata1_resources),
+       .dma_mask       = DMA_BIT_MASK(32),
+};
+
+/* USBHS */
+static const struct resource usbhs_resources[] __initconst = {
+       DEFINE_RES_MEM(0xe6590000, 0x100),
+       DEFINE_RES_IRQ(gic_spi(107)),
+};
+
+struct usbhs_private {
+       struct renesas_usbhs_platform_info info;
+       struct usb_phy *phy;
 };
 
+#define usbhs_get_priv(pdev) \
+       container_of(renesas_usbhs_get_info(pdev), struct usbhs_private, info)
+
+static int usbhs_power_ctrl(struct platform_device *pdev,
+                               void __iomem *base, int enable)
+{
+       struct usbhs_private *priv = usbhs_get_priv(pdev);
+
+       if (!priv->phy)
+               return -ENODEV;
+
+       if (enable) {
+               int retval = usb_phy_init(priv->phy);
+
+               if (!retval)
+                       retval = usb_phy_set_suspend(priv->phy, 0);
+               return retval;
+       }
+
+       usb_phy_set_suspend(priv->phy, 1);
+       usb_phy_shutdown(priv->phy);
+       return 0;
+}
+
+static int usbhs_hardware_init(struct platform_device *pdev)
+{
+       struct usbhs_private *priv = usbhs_get_priv(pdev);
+       struct usb_phy *phy;
+       int ret;
+
+       /* USB0 Function - use PWEN as GPIO input to detect DIP Switch SW5
+        * setting to avoid VBUS short circuit due to wrong cable.
+        * PWEN should be pulled up high if USB Function is selected by SW5
+        */
+       gpio_request_one(RCAR_GP_PIN(5, 18), GPIOF_IN, NULL); /* USB0_PWEN */
+       if (!gpio_get_value(RCAR_GP_PIN(5, 18))) {
+               pr_warn("Error: USB Function not selected - check SW5 + SW6\n");
+               ret = -ENOTSUPP;
+               goto error;
+       }
+
+       phy = usb_get_phy_dev(&pdev->dev, 0);
+       if (IS_ERR(phy)) {
+               ret = PTR_ERR(phy);
+               goto error;
+       }
+
+       priv->phy = phy;
+       return 0;
+ error:
+       gpio_free(RCAR_GP_PIN(5, 18));
+       return ret;
+}
+
+static int usbhs_hardware_exit(struct platform_device *pdev)
+{
+       struct usbhs_private *priv = usbhs_get_priv(pdev);
+
+       if (!priv->phy)
+               return 0;
+
+       usb_put_phy(priv->phy);
+       priv->phy = NULL;
+
+       gpio_free(RCAR_GP_PIN(5, 18));
+       return 0;
+}
+
+static int usbhs_get_id(struct platform_device *pdev)
+{
+       return USBHS_GADGET;
+}
+
+static u32 lager_usbhs_pipe_type[] = {
+       USB_ENDPOINT_XFER_CONTROL,
+       USB_ENDPOINT_XFER_ISOC,
+       USB_ENDPOINT_XFER_ISOC,
+       USB_ENDPOINT_XFER_BULK,
+       USB_ENDPOINT_XFER_BULK,
+       USB_ENDPOINT_XFER_BULK,
+       USB_ENDPOINT_XFER_INT,
+       USB_ENDPOINT_XFER_INT,
+       USB_ENDPOINT_XFER_INT,
+       USB_ENDPOINT_XFER_BULK,
+       USB_ENDPOINT_XFER_BULK,
+       USB_ENDPOINT_XFER_BULK,
+       USB_ENDPOINT_XFER_BULK,
+       USB_ENDPOINT_XFER_BULK,
+       USB_ENDPOINT_XFER_BULK,
+       USB_ENDPOINT_XFER_BULK,
+};
+
+static struct usbhs_private usbhs_priv __initdata = {
+       .info = {
+               .platform_callback = {
+                       .power_ctrl     = usbhs_power_ctrl,
+                       .hardware_init  = usbhs_hardware_init,
+                       .hardware_exit  = usbhs_hardware_exit,
+                       .get_id         = usbhs_get_id,
+               },
+               .driver_param = {
+                       .buswait_bwait  = 4,
+                       .pipe_type = lager_usbhs_pipe_type,
+                       .pipe_size = ARRAY_SIZE(lager_usbhs_pipe_type),
+               },
+       }
+};
+
+static void __init lager_register_usbhs(void)
+{
+       usb_bind_phy("renesas_usbhs", 0, "usb_phy_rcar_gen2");
+       platform_device_register_resndata(&platform_bus,
+                                         "renesas_usbhs", -1,
+                                         usbhs_resources,
+                                         ARRAY_SIZE(usbhs_resources),
+                                         &usbhs_priv.info,
+                                         sizeof(usbhs_priv.info));
+}
+
+/* USBHS PHY */
+static const struct rcar_gen2_phy_platform_data usbhs_phy_pdata __initconst = {
+       .chan0_pci = 0, /* Channel 0 is USBHS */
+       .chan2_pci = 1, /* Channel 2 is PCI USB */
+};
+
+static const struct resource usbhs_phy_resources[] __initconst = {
+       DEFINE_RES_MEM(0xe6590100, 0x100),
+};
+
+/* I2C */
+static struct i2c_board_info i2c2_devices[] = {
+       {
+               I2C_BOARD_INFO("ak4643", 0x12),
+       }
+};
+
+/* Sound */
+static struct resource rsnd_resources[] __initdata = {
+       [RSND_GEN2_SCU]  = DEFINE_RES_MEM(0xec500000, 0x1000),
+       [RSND_GEN2_ADG]  = DEFINE_RES_MEM(0xec5a0000, 0x100),
+       [RSND_GEN2_SSIU] = DEFINE_RES_MEM(0xec540000, 0x1000),
+       [RSND_GEN2_SSI]  = DEFINE_RES_MEM(0xec541000, 0x1280),
+};
+
+static struct rsnd_ssi_platform_info rsnd_ssi[] = {
+       RSND_SSI(0, gic_spi(370), 0),
+       RSND_SSI(0, gic_spi(371), RSND_SSI_CLK_PIN_SHARE),
+};
+
+static struct rsnd_src_platform_info rsnd_src[2] = {
+       /* no member at this point */
+};
+
+static struct rsnd_dai_platform_info rsnd_dai = {
+       .playback = { .ssi = &rsnd_ssi[0], },
+       .capture  = { .ssi = &rsnd_ssi[1], },
+};
+
+static struct rcar_snd_info rsnd_info = {
+       .flags          = RSND_GEN2,
+       .ssi_info       = rsnd_ssi,
+       .ssi_info_nr    = ARRAY_SIZE(rsnd_ssi),
+       .src_info       = rsnd_src,
+       .src_info_nr    = ARRAY_SIZE(rsnd_src),
+       .dai_info       = &rsnd_dai,
+       .dai_info_nr    = 1,
+};
+
+static struct asoc_simple_card_info rsnd_card_info = {
+       .name           = "AK4643",
+       .card           = "SSI01-AK4643",
+       .codec          = "ak4642-codec.2-0012",
+       .platform       = "rcar_sound",
+       .daifmt         = SND_SOC_DAIFMT_LEFT_J | SND_SOC_DAIFMT_CBM_CFM,
+       .cpu_dai = {
+               .name   = "rcar_sound",
+       },
+       .codec_dai = {
+               .name   = "ak4642-hifi",
+               .sysclk = 11289600,
+       },
+};
+
+static void __init lager_add_rsnd_device(void)
+{
+       struct platform_device_info cardinfo = {
+               .parent         = &platform_bus,
+               .name           = "asoc-simple-card",
+               .id             = -1,
+               .data           = &rsnd_card_info,
+               .size_data      = sizeof(struct asoc_simple_card_info),
+               .dma_mask       = DMA_BIT_MASK(32),
+       };
+
+       i2c_register_board_info(2, i2c2_devices,
+                               ARRAY_SIZE(i2c2_devices));
+
+       platform_device_register_resndata(
+               &platform_bus, "rcar_sound", -1,
+               rsnd_resources, ARRAY_SIZE(rsnd_resources),
+               &rsnd_info, sizeof(rsnd_info));
+
+       platform_device_register_full(&cardinfo);
+}
+
+/* SDHI0 */
+static struct sh_mobile_sdhi_info sdhi0_info __initdata = {
+       .tmio_caps      = MMC_CAP_SD_HIGHSPEED | MMC_CAP_SDIO_IRQ |
+                         MMC_CAP_POWER_OFF_CARD,
+       .tmio_flags     = TMIO_MMC_HAS_IDLE_WAIT |
+                         TMIO_MMC_WRPROTECT_DISABLE,
+};
+
+static struct resource sdhi0_resources[] __initdata = {
+       DEFINE_RES_MEM(0xee100000, 0x200),
+       DEFINE_RES_IRQ(gic_spi(165)),
+};
+
+/* SDHI2 */
+static struct sh_mobile_sdhi_info sdhi2_info __initdata = {
+       .tmio_caps      = MMC_CAP_SD_HIGHSPEED | MMC_CAP_SDIO_IRQ |
+                         MMC_CAP_POWER_OFF_CARD,
+       .tmio_flags     = TMIO_MMC_HAS_IDLE_WAIT |
+                         TMIO_MMC_WRPROTECT_DISABLE,
+};
+
+static struct resource sdhi2_resources[] __initdata = {
+       DEFINE_RES_MEM(0xee140000, 0x100),
+       DEFINE_RES_IRQ(gic_spi(167)),
+};
+
+/* Internal PCI1 */
+static const struct resource pci1_resources[] __initconst = {
+       DEFINE_RES_MEM(0xee0b0000, 0x10000),    /* CFG */
+       DEFINE_RES_MEM(0xee0a0000, 0x10000),    /* MEM */
+       DEFINE_RES_IRQ(gic_spi(112)),
+};
+
+static const struct platform_device_info pci1_info __initconst = {
+       .parent         = &platform_bus,
+       .name           = "pci-rcar-gen2",
+       .id             = 1,
+       .res            = pci1_resources,
+       .num_res        = ARRAY_SIZE(pci1_resources),
+       .dma_mask       = DMA_BIT_MASK(32),
+};
+
+static void __init lager_add_usb1_device(void)
+{
+       platform_device_register_full(&pci1_info);
+}
+
+/* Internal PCI2 */
+static const struct resource pci2_resources[] __initconst = {
+       DEFINE_RES_MEM(0xee0d0000, 0x10000),    /* CFG */
+       DEFINE_RES_MEM(0xee0c0000, 0x10000),    /* MEM */
+       DEFINE_RES_IRQ(gic_spi(113)),
+};
+
+static const struct platform_device_info pci2_info __initconst = {
+       .parent         = &platform_bus,
+       .name           = "pci-rcar-gen2",
+       .id             = 2,
+       .res            = pci2_resources,
+       .num_res        = ARRAY_SIZE(pci2_resources),
+       .dma_mask       = DMA_BIT_MASK(32),
+};
+
+static void __init lager_add_usb2_device(void)
+{
+       platform_device_register_full(&pci2_info);
+}
+
 static const struct pinctrl_map lager_pinctrl_map[] = {
        /* DU (CN10: ARGB0, CN13: LVDS) */
        PIN_MAP_MUX_GROUP_DEFAULT("rcar-du-r8a7790", "pfc-r8a7790",
@@ -299,12 +705,43 @@ static const struct pinctrl_map lager_pinctrl_map[] = {
                                  "du_sync_1", "du"),
        PIN_MAP_MUX_GROUP_DEFAULT("rcar-du-r8a7790", "pfc-r8a7790",
                                  "du_clk_out_0", "du"),
+       /* I2C2 */
+       PIN_MAP_MUX_GROUP_DEFAULT("i2c-rcar.2", "pfc-r8a7790",
+                                 "i2c2", "i2c2"),
+       /* QSPI */
+       PIN_MAP_MUX_GROUP_DEFAULT("qspi.0", "pfc-r8a7790",
+                                 "qspi_ctrl", "qspi"),
+       PIN_MAP_MUX_GROUP_DEFAULT("qspi.0", "pfc-r8a7790",
+                                 "qspi_data4", "qspi"),
        /* SCIF0 (CN19: DEBUG SERIAL0) */
        PIN_MAP_MUX_GROUP_DEFAULT("sh-sci.6", "pfc-r8a7790",
                                  "scif0_data", "scif0"),
        /* SCIF1 (CN20: DEBUG SERIAL1) */
        PIN_MAP_MUX_GROUP_DEFAULT("sh-sci.7", "pfc-r8a7790",
                                  "scif1_data", "scif1"),
+       /* SDHI0 */
+       PIN_MAP_MUX_GROUP_DEFAULT("sh_mobile_sdhi.0", "pfc-r8a7790",
+                                 "sdhi0_data4", "sdhi0"),
+       PIN_MAP_MUX_GROUP_DEFAULT("sh_mobile_sdhi.0", "pfc-r8a7790",
+                                 "sdhi0_ctrl", "sdhi0"),
+       PIN_MAP_MUX_GROUP_DEFAULT("sh_mobile_sdhi.0", "pfc-r8a7790",
+                                 "sdhi0_cd", "sdhi0"),
+       /* SDHI2 */
+       PIN_MAP_MUX_GROUP_DEFAULT("sh_mobile_sdhi.2", "pfc-r8a7790",
+                                 "sdhi2_data4", "sdhi2"),
+       PIN_MAP_MUX_GROUP_DEFAULT("sh_mobile_sdhi.2", "pfc-r8a7790",
+                                 "sdhi2_ctrl", "sdhi2"),
+       PIN_MAP_MUX_GROUP_DEFAULT("sh_mobile_sdhi.2", "pfc-r8a7790",
+                                 "sdhi2_cd", "sdhi2"),
+       /* SSI (CN17: sound) */
+       PIN_MAP_MUX_GROUP_DEFAULT("rcar_sound", "pfc-r8a7790",
+                                 "ssi0129_ctrl", "ssi"),
+       PIN_MAP_MUX_GROUP_DEFAULT("rcar_sound", "pfc-r8a7790",
+                                 "ssi0_data", "ssi"),
+       PIN_MAP_MUX_GROUP_DEFAULT("rcar_sound", "pfc-r8a7790",
+                                 "ssi1_data", "ssi"),
+       PIN_MAP_MUX_GROUP_DEFAULT("rcar_sound", "pfc-r8a7790",
+                                 "audio_clk_a", "audio_clk"),
        /* MMCIF1 */
        PIN_MAP_MUX_GROUP_DEFAULT("sh_mmcif.1", "pfc-r8a7790",
                                  "mmc1_data8", "mmc1"),
@@ -319,6 +756,31 @@ static const struct pinctrl_map lager_pinctrl_map[] = {
                                  "eth_rmii", "eth"),
        PIN_MAP_MUX_GROUP_DEFAULT("r8a7790-ether", "pfc-r8a7790",
                                  "intc_irq0", "intc"),
+       /* VIN0 */
+       PIN_MAP_MUX_GROUP_DEFAULT("r8a7790-vin.0", "pfc-r8a7790",
+                                 "vin0_data24", "vin0"),
+       PIN_MAP_MUX_GROUP_DEFAULT("r8a7790-vin.0", "pfc-r8a7790",
+                                 "vin0_sync", "vin0"),
+       PIN_MAP_MUX_GROUP_DEFAULT("r8a7790-vin.0", "pfc-r8a7790",
+                                 "vin0_field", "vin0"),
+       PIN_MAP_MUX_GROUP_DEFAULT("r8a7790-vin.0", "pfc-r8a7790",
+                                 "vin0_clkenb", "vin0"),
+       PIN_MAP_MUX_GROUP_DEFAULT("r8a7790-vin.0", "pfc-r8a7790",
+                                 "vin0_clk", "vin0"),
+       /* VIN1 */
+       PIN_MAP_MUX_GROUP_DEFAULT("r8a7790-vin.1", "pfc-r8a7790",
+                                 "vin1_data8", "vin1"),
+       PIN_MAP_MUX_GROUP_DEFAULT("r8a7790-vin.1", "pfc-r8a7790",
+                                 "vin1_clk", "vin1"),
+       /* USB0 */
+       PIN_MAP_MUX_GROUP_DEFAULT("renesas_usbhs", "pfc-r8a7790",
+                                 "usb0_ovc_vbus", "usb0"),
+       /* USB1 */
+       PIN_MAP_MUX_GROUP_DEFAULT("pci-rcar-gen2.1", "pfc-r8a7790",
+                                 "usb1", "usb1"),
+       /* USB2 */
+       PIN_MAP_MUX_GROUP_DEFAULT("pci-rcar-gen2.2", "pfc-r8a7790",
+                                 "usb2", "usb2"),
 };
 
 static void __init lager_add_standard_devices(void)
@@ -346,10 +808,7 @@ static void __init lager_add_standard_devices(void)
                                          mmcif1_resources, ARRAY_SIZE(mmcif1_resources),
                                          &mmcif1_pdata, sizeof(mmcif1_pdata));
 
-       platform_device_register_resndata(&platform_bus, "r8a7790-ether", -1,
-                                         ether_resources,
-                                         ARRAY_SIZE(ether_resources),
-                                         &ether_pdata, sizeof(ether_pdata));
+       platform_device_register_full(&ether_info);
 
        lager_add_du_device();
 
@@ -368,6 +827,28 @@ static void __init lager_add_standard_devices(void)
                                      &vccq_sdhi0_info, sizeof(struct gpio_regulator_config));
        platform_device_register_data(&platform_bus, "gpio-regulator", gpio_regulator_idx++,
                                      &vccq_sdhi2_info, sizeof(struct gpio_regulator_config));
+
+       lager_add_camera1_device();
+
+       platform_device_register_full(&sata1_info);
+
+       platform_device_register_resndata(&platform_bus, "usb_phy_rcar_gen2",
+                                         -1, usbhs_phy_resources,
+                                         ARRAY_SIZE(usbhs_phy_resources),
+                                         &usbhs_phy_pdata,
+                                         sizeof(usbhs_phy_pdata));
+       lager_register_usbhs();
+       lager_add_usb1_device();
+       lager_add_usb2_device();
+
+       lager_add_rsnd_device();
+
+       platform_device_register_resndata(&platform_bus, "sh_mobile_sdhi", 0,
+                                         sdhi0_resources, ARRAY_SIZE(sdhi0_resources),
+                                         &sdhi0_info, sizeof(struct sh_mobile_sdhi_info));
+       platform_device_register_resndata(&platform_bus, "sh_mobile_sdhi", 2,
+                                         sdhi2_resources, ARRAY_SIZE(sdhi2_resources),
+                                         &sdhi2_info, sizeof(struct sh_mobile_sdhi_info));
 }
 
 /*
@@ -391,6 +872,8 @@ static void __init lager_init(void)
 {
        lager_add_standard_devices();
 
+       irq_set_irq_type(irq_pin(0), IRQ_TYPE_LEVEL_LOW);
+
        if (IS_ENABLED(CONFIG_PHYLIB))
                phy_register_fixup_for_id("r8a7790-ether-ff:01",
                                          lager_ksz8041_fixup);
@@ -403,9 +886,10 @@ static const char * const lager_boards_compat_dt[] __initconst = {
 
 DT_MACHINE_START(LAGER_DT, "lager")
        .smp            = smp_ops(r8a7790_smp_ops),
-       .init_early     = r8a7790_init_early,
+       .init_early     = shmobile_init_delay,
        .init_time      = rcar_gen2_timer_init,
        .init_machine   = lager_init,
        .init_late      = shmobile_init_late,
+       .reserve        = rcar_gen2_reserve,
        .dt_compat      = lager_boards_compat_dt,
 MACHINE_END
index 3aba037..ca5d34b 100644 (file)
 #include <linux/regulator/fixed.h>
 #include <linux/regulator/machine.h>
 #include <linux/smsc911x.h>
-#include <linux/sh_intc.h>
+#include <linux/sh_clk.h>
 #include <linux/tca6416_keypad.h>
 #include <linux/usb/renesas_usbhs.h>
 #include <linux/dma-mapping.h>
+
 #include <video/sh_mobile_hdmi.h>
 #include <video/sh_mobile_lcdc.h>
 #include <media/sh_mobile_ceu.h>
 #include <media/soc_camera_platform.h>
 #include <sound/sh_fsi.h>
 #include <sound/simple_card.h>
-
-#include <mach/common.h>
-#include <mach/irqs.h>
-#include <mach/sh7372.h>
-
 #include <asm/mach/arch.h>
 #include <asm/mach-types.h>
 
+#include "common.h"
+#include "intc.h"
+#include "irqs.h"
+#include "pm-rmobile.h"
 #include "sh-gpio.h"
+#include "sh7372.h"
 
 /*
  * Address     Interface               BusWidth        note
@@ -509,9 +510,9 @@ static struct asoc_simple_card_info fsi2_hdmi_info = {
        .card           = "FSI2B-HDMI",
        .codec          = "sh-mobile-hdmi",
        .platform       = "sh_fsi2",
+       .daifmt         = SND_SOC_DAIFMT_CBS_CFS,
        .cpu_dai = {
                .name   = "fsib-dai",
-               .fmt    = SND_SOC_DAIFMT_CBM_CFM | SND_SOC_DAIFMT_IB_NF,
        },
        .codec_dai = {
                .name   = "sh_mobile_hdmi-hifi",
@@ -523,6 +524,8 @@ static struct platform_device fsi_hdmi_device = {
        .id     = 1,
        .dev    = {
                .platform_data  = &fsi2_hdmi_info,
+               .coherent_dma_mask = DMA_BIT_MASK(32),
+               .dma_mask = &fsi_hdmi_device.dev.coherent_dma_mask,
        },
 };
 
@@ -905,14 +908,12 @@ static struct asoc_simple_card_info fsi2_ak4643_info = {
        .card           = "FSI2A-AK4643",
        .codec          = "ak4642-codec.0-0013",
        .platform       = "sh_fsi2",
-       .daifmt         = SND_SOC_DAIFMT_LEFT_J,
+       .daifmt         = SND_SOC_DAIFMT_LEFT_J | SND_SOC_DAIFMT_CBM_CFM,
        .cpu_dai = {
                .name   = "fsia-dai",
-               .fmt    = SND_SOC_DAIFMT_CBS_CFS,
        },
        .codec_dai = {
                .name   = "ak4642-hifi",
-               .fmt    = SND_SOC_DAIFMT_CBM_CFM,
                .sysclk = 11289600,
        },
 };
@@ -921,6 +922,8 @@ static struct platform_device fsi_ak4643_device = {
        .name   = "asoc-simple-card",
        .dev    = {
                .platform_data  = &fsi2_ak4643_info,
+               .coherent_dma_mask = DMA_BIT_MASK(32),
+               .dma_mask = &fsi_ak4643_device.dev.coherent_dma_mask,
        },
 };
 
@@ -1418,7 +1421,7 @@ static const struct pinctrl_map mackerel_pinctrl_map[] = {
 #define USCCR1         IOMEM(0xE6058144)
 static void __init mackerel_init(void)
 {
-       struct pm_domain_device domain_devices[] = {
+       static struct pm_domain_device domain_devices[] __initdata = {
                { "A4LC", &lcdc_device, },
                { "A4LC", &hdmi_lcdc_device, },
                { "A4LC", &meram_device, },
index 2773936..38d9cdd 100644 (file)
  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
  */
 
-#include <mach/r8a7779.h>
-#include <mach/common.h>
-#include <mach/irqs.h>
+#include <linux/clk/shmobile.h>
+#include <linux/clocksource.h>
+#include <linux/of_platform.h>
+
 #include <asm/irq.h>
 #include <asm/mach/arch.h>
 
+#include "clock.h"
+#include "common.h"
+#include "irqs.h"
+#include "r8a7779.h"
+
+static void __init marzen_init_timer(void)
+{
+       r8a7779_clocks_init(r8a7779_read_mode_pins());
+       clocksource_of_init();
+}
+
 static void __init marzen_init(void)
 {
-       r8a7779_add_standard_devices_dt();
+       of_platform_populate(NULL, of_default_bus_match_table, NULL, NULL);
        r8a7779_init_irq_extpin_dt(1); /* IRQ1 as individual interrupt */
 }
 
 static const char *marzen_boards_compat_dt[] __initdata = {
+       "renesas,marzen",
        "renesas,marzen-reference",
        NULL,
 };
@@ -39,9 +52,10 @@ static const char *marzen_boards_compat_dt[] __initdata = {
 DT_MACHINE_START(MARZEN, "marzen")
        .smp            = smp_ops(r8a7779_smp_ops),
        .map_io         = r8a7779_map_io,
-       .init_early     = r8a7779_init_delay,
-       .nr_irqs        = NR_IRQS_LEGACY,
+       .init_early     = shmobile_init_delay,
+       .init_time      = marzen_init_timer,
        .init_irq       = r8a7779_init_irq_dt,
        .init_machine   = marzen_init,
+       .init_late      = shmobile_init_late,
        .dt_compat      = marzen_boards_compat_dt,
 MACHINE_END
index d832a44..2d44b2a 100644 (file)
 #include <linux/mmc/host.h>
 #include <linux/mmc/sh_mobile_sdhi.h>
 #include <linux/mfd/tmio.h>
+
 #include <media/soc_camera.h>
-#include <mach/r8a7779.h>
-#include <mach/common.h>
-#include <mach/irqs.h>
 #include <asm/mach-types.h>
 #include <asm/mach/arch.h>
 #include <asm/traps.h>
 
+#include "common.h"
+#include "irqs.h"
+#include "r8a7779.h"
+
 /* Fixed 3.3V regulator to be used by SDHI0 */
 static struct regulator_consumer_supply fixed3v3_power_consumers[] = {
        REGULATOR_SUPPLY("vmmc", "sh_mobile_sdhi.0"),
@@ -190,16 +192,15 @@ static struct rcar_du_encoder_data du_encoders[] = {
                        .width_mm = 210,
                        .height_mm = 158,
                        .mode = {
-                               .clock = 65000,
-                               .hdisplay = 1024,
-                               .hsync_start = 1048,
-                               .hsync_end = 1184,
-                               .htotal = 1344,
-                               .vdisplay = 768,
-                               .vsync_start = 771,
-                               .vsync_end = 777,
-                               .vtotal = 806,
-                               .flags = 0,
+                               .pixelclock = 65000000,
+                               .hactive = 1024,
+                               .hfront_porch = 20,
+                               .hback_porch = 160,
+                               .hsync_len = 136,
+                               .vactive = 768,
+                               .vfront_porch = 3,
+                               .vback_porch = 29,
+                               .vsync_len = 6,
                        },
                },
        },
diff --git a/arch/arm/mach-shmobile/clock-emev2.c b/arch/arm/mach-shmobile/clock-emev2.c
deleted file mode 100644 (file)
index 5ac13ba..0000000
+++ /dev/null
@@ -1,231 +0,0 @@
-/*
- * Emma Mobile EV2 clock framework support
- *
- * Copyright (C) 2012  Magnus Damm
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; version 2 of the License.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
- */
-#include <linux/init.h>
-#include <linux/kernel.h>
-#include <linux/io.h>
-#include <linux/sh_clk.h>
-#include <linux/clkdev.h>
-#include <mach/common.h>
-
-#define EMEV2_SMU_BASE 0xe0110000
-
-/* EMEV2 SMU registers */
-#define USIAU0_RSTCTRL 0x094
-#define USIBU1_RSTCTRL 0x0ac
-#define USIBU2_RSTCTRL 0x0b0
-#define USIBU3_RSTCTRL 0x0b4
-#define STI_RSTCTRL 0x124
-#define USIAU0GCLKCTRL 0x4a0
-#define USIBU1GCLKCTRL 0x4b8
-#define USIBU2GCLKCTRL 0x4bc
-#define USIBU3GCLKCTRL 0x04c0
-#define STIGCLKCTRL 0x528
-#define USIAU0SCLKDIV 0x61c
-#define USIB2SCLKDIV 0x65c
-#define USIB3SCLKDIV 0x660
-#define STI_CLKSEL 0x688
-
-/* not pretty, but hey */
-static void __iomem *smu_base;
-
-static void emev2_smu_write(unsigned long value, int offs)
-{
-       BUG_ON(!smu_base || (offs >= PAGE_SIZE));
-       iowrite32(value, smu_base + offs);
-}
-
-static struct clk_mapping smu_mapping = {
-       .phys   = EMEV2_SMU_BASE,
-       .len    = PAGE_SIZE,
-};
-
-/* Fixed 32 KHz root clock from C32K pin */
-static struct clk c32k_clk = {
-       .rate           = 32768,
-       .mapping        = &smu_mapping,
-};
-
-/* PLL3 multiplies C32K with 7000 */
-static unsigned long pll3_recalc(struct clk *clk)
-{
-       return clk->parent->rate * 7000;
-}
-
-static struct sh_clk_ops pll3_clk_ops = {
-       .recalc         = pll3_recalc,
-};
-
-static struct clk pll3_clk = {
-       .ops            = &pll3_clk_ops,
-       .parent         = &c32k_clk,
-};
-
-static struct clk *main_clks[] = {
-       &c32k_clk,
-       &pll3_clk,
-};
-
-enum { SCLKDIV_USIAU0, SCLKDIV_USIBU2, SCLKDIV_USIBU1, SCLKDIV_USIBU3,
-       SCLKDIV_NR };
-
-#define SCLKDIV(_reg, _shift)                  \
-{                                                              \
-       .parent         = &pll3_clk,                            \
-       .enable_reg     = IOMEM(EMEV2_SMU_BASE + (_reg)),       \
-       .enable_bit     = _shift,                               \
-}
-
-static struct clk sclkdiv_clks[SCLKDIV_NR] = {
-       [SCLKDIV_USIAU0] = SCLKDIV(USIAU0SCLKDIV, 0),
-       [SCLKDIV_USIBU2] = SCLKDIV(USIB2SCLKDIV, 16),
-       [SCLKDIV_USIBU1] = SCLKDIV(USIB2SCLKDIV, 0),
-       [SCLKDIV_USIBU3] = SCLKDIV(USIB3SCLKDIV, 0),
-};
-
-enum { GCLK_USIAU0_SCLK, GCLK_USIBU1_SCLK, GCLK_USIBU2_SCLK, GCLK_USIBU3_SCLK,
-       GCLK_STI_SCLK,
-       GCLK_NR };
-
-#define GCLK_SCLK(_parent, _reg) \
-{                                                              \
-       .parent         = _parent,                              \
-       .enable_reg     = IOMEM(EMEV2_SMU_BASE + (_reg)),       \
-       .enable_bit     = 1, /* SCLK_GCC */                     \
-}
-
-static struct clk gclk_clks[GCLK_NR] = {
-       [GCLK_USIAU0_SCLK] = GCLK_SCLK(&sclkdiv_clks[SCLKDIV_USIAU0],
-                                      USIAU0GCLKCTRL),
-       [GCLK_USIBU1_SCLK] = GCLK_SCLK(&sclkdiv_clks[SCLKDIV_USIBU1],
-                                      USIBU1GCLKCTRL),
-       [GCLK_USIBU2_SCLK] = GCLK_SCLK(&sclkdiv_clks[SCLKDIV_USIBU2],
-                                      USIBU2GCLKCTRL),
-       [GCLK_USIBU3_SCLK] = GCLK_SCLK(&sclkdiv_clks[SCLKDIV_USIBU3],
-                                      USIBU3GCLKCTRL),
-       [GCLK_STI_SCLK] = GCLK_SCLK(&c32k_clk, STIGCLKCTRL),
-};
-
-static int emev2_gclk_enable(struct clk *clk)
-{
-       iowrite32(ioread32(clk->mapped_reg) | (1 << clk->enable_bit),
-                 clk->mapped_reg);
-       return 0;
-}
-
-static void emev2_gclk_disable(struct clk *clk)
-{
-       iowrite32(ioread32(clk->mapped_reg) & ~(1 << clk->enable_bit),
-                 clk->mapped_reg);
-}
-
-static struct sh_clk_ops emev2_gclk_clk_ops = {
-       .enable         = emev2_gclk_enable,
-       .disable        = emev2_gclk_disable,
-       .recalc         = followparent_recalc,
-};
-
-static int __init emev2_gclk_register(struct clk *clks, int nr)
-{
-       struct clk *clkp;
-       int ret = 0;
-       int k;
-
-       for (k = 0; !ret && (k < nr); k++) {
-               clkp = clks + k;
-               clkp->ops = &emev2_gclk_clk_ops;
-               ret |= clk_register(clkp);
-       }
-
-       return ret;
-}
-
-static unsigned long emev2_sclkdiv_recalc(struct clk *clk)
-{
-       unsigned int sclk_div;
-
-       sclk_div = (ioread32(clk->mapped_reg) >> clk->enable_bit) & 0xff;
-
-       return clk->parent->rate / (sclk_div + 1);
-}
-
-static struct sh_clk_ops emev2_sclkdiv_clk_ops = {
-       .recalc         = emev2_sclkdiv_recalc,
-};
-
-static int __init emev2_sclkdiv_register(struct clk *clks, int nr)
-{
-       struct clk *clkp;
-       int ret = 0;
-       int k;
-
-       for (k = 0; !ret && (k < nr); k++) {
-               clkp = clks + k;
-               clkp->ops = &emev2_sclkdiv_clk_ops;
-               ret |= clk_register(clkp);
-       }
-
-       return ret;
-}
-
-static struct clk_lookup lookups[] = {
-       CLKDEV_DEV_ID("serial8250-em.0", &gclk_clks[GCLK_USIAU0_SCLK]),
-       CLKDEV_DEV_ID("e1020000.uart", &gclk_clks[GCLK_USIAU0_SCLK]),
-       CLKDEV_DEV_ID("serial8250-em.1", &gclk_clks[GCLK_USIBU1_SCLK]),
-       CLKDEV_DEV_ID("e1030000.uart", &gclk_clks[GCLK_USIBU1_SCLK]),
-       CLKDEV_DEV_ID("serial8250-em.2", &gclk_clks[GCLK_USIBU2_SCLK]),
-       CLKDEV_DEV_ID("e1040000.uart", &gclk_clks[GCLK_USIBU2_SCLK]),
-       CLKDEV_DEV_ID("serial8250-em.3", &gclk_clks[GCLK_USIBU3_SCLK]),
-       CLKDEV_DEV_ID("e1050000.uart", &gclk_clks[GCLK_USIBU3_SCLK]),
-       CLKDEV_DEV_ID("em_sti.0", &gclk_clks[GCLK_STI_SCLK]),
-       CLKDEV_DEV_ID("e0180000.sti", &gclk_clks[GCLK_STI_SCLK]),
-};
-
-void __init emev2_clock_init(void)
-{
-       int k, ret = 0;
-
-       smu_base = ioremap(EMEV2_SMU_BASE, PAGE_SIZE);
-       BUG_ON(!smu_base);
-
-       /* setup STI timer to run on 32.768 kHz and deassert reset */
-       emev2_smu_write(0, STI_CLKSEL);
-       emev2_smu_write(1, STI_RSTCTRL);
-
-       /* deassert reset for UART0->UART3 */
-       emev2_smu_write(2, USIAU0_RSTCTRL);
-       emev2_smu_write(2, USIBU1_RSTCTRL);
-       emev2_smu_write(2, USIBU2_RSTCTRL);
-       emev2_smu_write(2, USIBU3_RSTCTRL);
-
-       for (k = 0; !ret && (k < ARRAY_SIZE(main_clks)); k++)
-               ret = clk_register(main_clks[k]);
-
-       if (!ret)
-               ret = emev2_sclkdiv_register(sclkdiv_clks, SCLKDIV_NR);
-
-       if (!ret)
-               ret = emev2_gclk_register(gclk_clks, GCLK_NR);
-
-       clkdev_add_table(lookups, ARRAY_SIZE(lookups));
-
-       if (!ret)
-               shmobile_clk_init();
-       else
-               panic("failed to setup emev2 clocks\n");
-}
diff --git a/arch/arm/mach-shmobile/clock-r7s72100.c b/arch/arm/mach-shmobile/clock-r7s72100.c
deleted file mode 100644 (file)
index e6ab0cd..0000000
+++ /dev/null
@@ -1,211 +0,0 @@
-/*
- * r7a72100 clock framework support
- *
- * Copyright (C) 2013  Renesas Solutions Corp.
- * Copyright (C) 2012  Phil Edworthy
- * Copyright (C) 2011  Magnus Damm
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; version 2 of the License.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- */
-#include <linux/init.h>
-#include <linux/kernel.h>
-#include <linux/io.h>
-#include <linux/sh_clk.h>
-#include <linux/clkdev.h>
-#include <mach/common.h>
-#include <mach/r7s72100.h>
-
-/* registers */
-#define FRQCR          0xfcfe0010
-#define FRQCR2         0xfcfe0014
-#define STBCR3         0xfcfe0420
-#define STBCR4         0xfcfe0424
-#define STBCR9         0xfcfe0438
-
-#define PLL_RATE 30
-
-static struct clk_mapping cpg_mapping = {
-       .phys   = 0xfcfe0000,
-       .len    = 0x1000,
-};
-
-/* Fixed 32 KHz root clock for RTC */
-static struct clk r_clk = {
-       .rate           = 32768,
-};
-
-/*
- * Default rate for the root input clock, reset this with clk_set_rate()
- * from the platform code.
- */
-static struct clk extal_clk = {
-       .rate           = 13330000,
-       .mapping        = &cpg_mapping,
-};
-
-static unsigned long pll_recalc(struct clk *clk)
-{
-       return clk->parent->rate * PLL_RATE;
-}
-
-static struct sh_clk_ops pll_clk_ops = {
-       .recalc         = pll_recalc,
-};
-
-static struct clk pll_clk = {
-       .ops            = &pll_clk_ops,
-       .parent         = &extal_clk,
-       .flags          = CLK_ENABLE_ON_INIT,
-};
-
-static unsigned long bus_recalc(struct clk *clk)
-{
-       return clk->parent->rate * 2 / 3;
-}
-
-static struct sh_clk_ops bus_clk_ops = {
-       .recalc         = bus_recalc,
-};
-
-static struct clk bus_clk = {
-       .ops            = &bus_clk_ops,
-       .parent         = &pll_clk,
-       .flags          = CLK_ENABLE_ON_INIT,
-};
-
-static unsigned long peripheral0_recalc(struct clk *clk)
-{
-       return clk->parent->rate / 12;
-}
-
-static struct sh_clk_ops peripheral0_clk_ops = {
-       .recalc         = peripheral0_recalc,
-};
-
-static struct clk peripheral0_clk = {
-       .ops            = &peripheral0_clk_ops,
-       .parent         = &pll_clk,
-       .flags          = CLK_ENABLE_ON_INIT,
-};
-
-static unsigned long peripheral1_recalc(struct clk *clk)
-{
-       return clk->parent->rate / 6;
-}
-
-static struct sh_clk_ops peripheral1_clk_ops = {
-       .recalc         = peripheral1_recalc,
-};
-
-static struct clk peripheral1_clk = {
-       .ops            = &peripheral1_clk_ops,
-       .parent         = &pll_clk,
-       .flags          = CLK_ENABLE_ON_INIT,
-};
-
-struct clk *main_clks[] = {
-       &r_clk,
-       &extal_clk,
-       &pll_clk,
-       &bus_clk,
-       &peripheral0_clk,
-       &peripheral1_clk,
-};
-
-static int div2[] = { 1, 3, 0, 3 }; /* 1, 2/3, reserve, 1/3 */
-static int multipliers[] = { 1, 2, 1, 1 };
-
-static struct clk_div_mult_table div4_div_mult_table = {
-       .divisors = div2,
-       .nr_divisors = ARRAY_SIZE(div2),
-       .multipliers = multipliers,
-       .nr_multipliers = ARRAY_SIZE(multipliers),
-};
-
-static struct clk_div4_table div4_table = {
-       .div_mult_table = &div4_div_mult_table,
-};
-
-enum { DIV4_I,
-       DIV4_NR };
-
-#define DIV4(_reg, _bit, _mask, _flags) \
-       SH_CLK_DIV4(&pll_clk, _reg, _bit, _mask, _flags)
-
-/* The mask field specifies the div2 entries that are valid */
-struct clk div4_clks[DIV4_NR] = {
-       [DIV4_I]  = DIV4(FRQCR, 8, 0xB, CLK_ENABLE_REG_16BIT
-                                       | CLK_ENABLE_ON_INIT),
-};
-
-enum { MSTP97, MSTP96, MSTP95, MSTP94,
-       MSTP47, MSTP46, MSTP45, MSTP44, MSTP43, MSTP42, MSTP41, MSTP40,
-       MSTP33, MSTP_NR };
-
-static struct clk mstp_clks[MSTP_NR] = {
-       [MSTP97] = SH_CLK_MSTP8(&peripheral0_clk, STBCR9, 7, 0), /* RIIC0 */
-       [MSTP96] = SH_CLK_MSTP8(&peripheral0_clk, STBCR9, 6, 0), /* RIIC1 */
-       [MSTP95] = SH_CLK_MSTP8(&peripheral0_clk, STBCR9, 5, 0), /* RIIC2 */
-       [MSTP94] = SH_CLK_MSTP8(&peripheral0_clk, STBCR9, 4, 0), /* RIIC3 */
-       [MSTP47] = SH_CLK_MSTP8(&peripheral1_clk, STBCR4, 7, 0), /* SCIF0 */
-       [MSTP46] = SH_CLK_MSTP8(&peripheral1_clk, STBCR4, 6, 0), /* SCIF1 */
-       [MSTP45] = SH_CLK_MSTP8(&peripheral1_clk, STBCR4, 5, 0), /* SCIF2 */
-       [MSTP44] = SH_CLK_MSTP8(&peripheral1_clk, STBCR4, 4, 0), /* SCIF3 */
-       [MSTP43] = SH_CLK_MSTP8(&peripheral1_clk, STBCR4, 3, 0), /* SCIF4 */
-       [MSTP42] = SH_CLK_MSTP8(&peripheral1_clk, STBCR4, 2, 0), /* SCIF5 */
-       [MSTP41] = SH_CLK_MSTP8(&peripheral1_clk, STBCR4, 1, 0), /* SCIF6 */
-       [MSTP40] = SH_CLK_MSTP8(&peripheral1_clk, STBCR4, 0, 0), /* SCIF7 */
-       [MSTP33] = SH_CLK_MSTP8(&peripheral0_clk, STBCR3, 3, 0), /* MTU2 */
-};
-
-static struct clk_lookup lookups[] = {
-       /* main clocks */
-       CLKDEV_CON_ID("rclk", &r_clk),
-       CLKDEV_CON_ID("extal", &extal_clk),
-       CLKDEV_CON_ID("pll_clk", &pll_clk),
-       CLKDEV_CON_ID("peripheral_clk", &peripheral1_clk),
-
-       /* DIV4 clocks */
-       CLKDEV_CON_ID("cpu_clk", &div4_clks[DIV4_I]),
-
-       /* MSTP clocks */
-       CLKDEV_CON_ID("mtu2_fck", &mstp_clks[MSTP33]),
-
-       /* ICK */
-       CLKDEV_ICK_ID("sci_fck", "sh-sci.0", &mstp_clks[MSTP47]),
-       CLKDEV_ICK_ID("sci_fck", "sh-sci.1", &mstp_clks[MSTP46]),
-       CLKDEV_ICK_ID("sci_fck", "sh-sci.2", &mstp_clks[MSTP45]),
-       CLKDEV_ICK_ID("sci_fck", "sh-sci.3", &mstp_clks[MSTP44]),
-       CLKDEV_ICK_ID("sci_fck", "sh-sci.4", &mstp_clks[MSTP43]),
-       CLKDEV_ICK_ID("sci_fck", "sh-sci.5", &mstp_clks[MSTP42]),
-       CLKDEV_ICK_ID("sci_fck", "sh-sci.6", &mstp_clks[MSTP41]),
-       CLKDEV_ICK_ID("sci_fck", "sh-sci.7", &mstp_clks[MSTP40]),
-};
-
-void __init r7s72100_clock_init(void)
-{
-       int k, ret = 0;
-
-       for (k = 0; !ret && (k < ARRAY_SIZE(main_clks)); k++)
-               ret = clk_register(main_clks[k]);
-
-       clkdev_add_table(lookups, ARRAY_SIZE(lookups));
-
-       if (!ret)
-               ret = sh_clk_div4_register(div4_clks, DIV4_NR, &div4_table);
-
-       if (!ret)
-               ret = sh_clk_mstp_register(mstp_clks, MSTP_NR);
-
-       if (!ret)
-               shmobile_clk_init();
-       else
-               panic("failed to setup rza1 clocks\n");
-}
index 7348d58..c2330ea 100644 (file)
@@ -22,8 +22,8 @@
 #include <linux/kernel.h>
 #include <linux/sh_clk.h>
 #include <linux/clkdev.h>
-#include <mach/clock.h>
-#include <mach/common.h>
+#include "common.h"
+#include "clock.h"
 
 #define CPG_BASE 0xe6150000
 #define CPG_LEN 0x270
@@ -574,11 +574,17 @@ static struct clk_lookup lookups[] = {
 
        /* MSTP */
        CLKDEV_DEV_ID("sh-sci.0", &mstp_clks[MSTP204]),
+       CLKDEV_DEV_ID("e6c40000.serial", &mstp_clks[MSTP204]),
        CLKDEV_DEV_ID("sh-sci.1", &mstp_clks[MSTP203]),
+       CLKDEV_DEV_ID("e6c50000.serial", &mstp_clks[MSTP203]),
        CLKDEV_DEV_ID("sh-sci.2", &mstp_clks[MSTP206]),
+       CLKDEV_DEV_ID("e6c20000.serial", &mstp_clks[MSTP206]),
        CLKDEV_DEV_ID("sh-sci.3", &mstp_clks[MSTP207]),
+       CLKDEV_DEV_ID("e6c30000.serial", &mstp_clks[MSTP207]),
        CLKDEV_DEV_ID("sh-sci.4", &mstp_clks[MSTP216]),
+       CLKDEV_DEV_ID("e6ce0000.serial", &mstp_clks[MSTP216]),
        CLKDEV_DEV_ID("sh-sci.5", &mstp_clks[MSTP217]),
+       CLKDEV_DEV_ID("e6cf0000.serial", &mstp_clks[MSTP217]),
        CLKDEV_DEV_ID("sh-dma-engine.0", &mstp_clks[MSTP218]),
        CLKDEV_DEV_ID("e6700020.dma-controller", &mstp_clks[MSTP218]),
        CLKDEV_DEV_ID("rcar_thermal", &mstp_clks[MSTP522]),
@@ -597,7 +603,8 @@ static struct clk_lookup lookups[] = {
        CLKDEV_DEV_ID("e6560000.i2c", &mstp_clks[MSTP317]),
        CLKDEV_DEV_ID("e6500000.i2c", &mstp_clks[MSTP318]),
        CLKDEV_DEV_ID("e6510000.i2c", &mstp_clks[MSTP323]),
-       CLKDEV_DEV_ID("sh_cmt.10", &mstp_clks[MSTP329]),
+       CLKDEV_ICK_ID("fck", "sh-cmt-48-gen2.1", &mstp_clks[MSTP329]),
+       CLKDEV_ICK_ID("fck", "e6130000.timer", &mstp_clks[MSTP329]),
        CLKDEV_DEV_ID("e60b0000.i2c", &mstp_clks[MSTP409]),
        CLKDEV_DEV_ID("e6540000.i2c", &mstp_clks[MSTP410]),
        CLKDEV_DEV_ID("e6530000.i2c", &mstp_clks[MSTP411]),
index dd989f9..0794f04 100644 (file)
 #include <linux/io.h>
 #include <linux/sh_clk.h>
 #include <linux/clkdev.h>
-#include <mach/clock.h>
-#include <mach/common.h>
-#include <mach/r8a7740.h>
+
+#include "clock.h"
+#include "common.h"
+#include "r8a7740.h"
 
 /*
  *        |  MDx  |  XTAL1/EXTAL1   |  System   | EXTALR |
@@ -548,42 +549,35 @@ static struct clk_lookup lookups[] = {
 
        /* MSTP32 clocks */
        CLKDEV_DEV_ID("sh_mobile_lcdc_fb.0",    &mstp_clks[MSTP100]),
-       CLKDEV_DEV_ID("sh_tmu.3",               &mstp_clks[MSTP111]),
-       CLKDEV_DEV_ID("sh_tmu.4",               &mstp_clks[MSTP111]),
-       CLKDEV_DEV_ID("sh_tmu.5",               &mstp_clks[MSTP111]),
        CLKDEV_DEV_ID("i2c-sh_mobile.0",        &mstp_clks[MSTP116]),
        CLKDEV_DEV_ID("fff20000.i2c",           &mstp_clks[MSTP116]),
        CLKDEV_DEV_ID("sh_mobile_lcdc_fb.1",    &mstp_clks[MSTP117]),
-       CLKDEV_DEV_ID("sh_tmu.0",               &mstp_clks[MSTP125]),
-       CLKDEV_DEV_ID("sh_tmu.1",               &mstp_clks[MSTP125]),
-       CLKDEV_DEV_ID("sh_tmu.2",               &mstp_clks[MSTP125]),
        CLKDEV_DEV_ID("sh_mobile_ceu.0",        &mstp_clks[MSTP127]),
        CLKDEV_DEV_ID("sh_mobile_ceu.1",        &mstp_clks[MSTP128]),
 
        CLKDEV_DEV_ID("sh-sci.4",               &mstp_clks[MSTP200]),
-       CLKDEV_DEV_ID("e6c80000.sci",           &mstp_clks[MSTP200]),
+       CLKDEV_DEV_ID("e6c80000.serial",        &mstp_clks[MSTP200]),
        CLKDEV_DEV_ID("sh-sci.3",               &mstp_clks[MSTP201]),
-       CLKDEV_DEV_ID("e6c70000.sci",           &mstp_clks[MSTP201]),
+       CLKDEV_DEV_ID("e6c70000.serial",        &mstp_clks[MSTP201]),
        CLKDEV_DEV_ID("sh-sci.2",               &mstp_clks[MSTP202]),
-       CLKDEV_DEV_ID("e6c60000.sci",           &mstp_clks[MSTP202]),
+       CLKDEV_DEV_ID("e6c60000.serial",        &mstp_clks[MSTP202]),
        CLKDEV_DEV_ID("sh-sci.1",               &mstp_clks[MSTP203]),
-       CLKDEV_DEV_ID("e6c50000.sci",           &mstp_clks[MSTP203]),
+       CLKDEV_DEV_ID("e6c50000.serial",        &mstp_clks[MSTP203]),
        CLKDEV_DEV_ID("sh-sci.0",               &mstp_clks[MSTP204]),
-       CLKDEV_DEV_ID("e6c40000.sci",           &mstp_clks[MSTP204]),
+       CLKDEV_DEV_ID("e6c40000.serial",        &mstp_clks[MSTP204]),
        CLKDEV_DEV_ID("sh-sci.8",               &mstp_clks[MSTP206]),
-       CLKDEV_DEV_ID("e6c30000.sci",           &mstp_clks[MSTP206]),
+       CLKDEV_DEV_ID("e6c30000.serial",        &mstp_clks[MSTP206]),
        CLKDEV_DEV_ID("sh-sci.5",               &mstp_clks[MSTP207]),
-       CLKDEV_DEV_ID("e6cb0000.sci",           &mstp_clks[MSTP207]),
+       CLKDEV_DEV_ID("e6cb0000.serial",        &mstp_clks[MSTP207]),
        CLKDEV_DEV_ID("sh-dma-engine.3",        &mstp_clks[MSTP214]),
        CLKDEV_DEV_ID("sh-dma-engine.2",        &mstp_clks[MSTP216]),
        CLKDEV_DEV_ID("sh-dma-engine.1",        &mstp_clks[MSTP217]),
        CLKDEV_DEV_ID("sh-dma-engine.0",        &mstp_clks[MSTP218]),
        CLKDEV_DEV_ID("sh-sci.7",               &mstp_clks[MSTP222]),
-       CLKDEV_DEV_ID("e6cd0000.sci",           &mstp_clks[MSTP222]),
+       CLKDEV_DEV_ID("e6cd0000.serial",        &mstp_clks[MSTP222]),
        CLKDEV_DEV_ID("sh-sci.6",               &mstp_clks[MSTP230]),
-       CLKDEV_DEV_ID("e6cc0000.sci",           &mstp_clks[MSTP230]),
+       CLKDEV_DEV_ID("e6cc0000.serial",        &mstp_clks[MSTP230]),
 
-       CLKDEV_DEV_ID("sh_cmt.10",              &mstp_clks[MSTP329]),
        CLKDEV_DEV_ID("sh_fsi2",                &mstp_clks[MSTP328]),
        CLKDEV_DEV_ID("fe1f0000.sound",         &mstp_clks[MSTP328]),
        CLKDEV_DEV_ID("i2c-sh_mobile.1",        &mstp_clks[MSTP323]),
@@ -596,7 +590,7 @@ static struct clk_lookup lookups[] = {
        CLKDEV_DEV_ID("sh_mmcif",               &mstp_clks[MSTP312]),
        CLKDEV_DEV_ID("e6bd0000.mmc",           &mstp_clks[MSTP312]),
        CLKDEV_DEV_ID("r8a7740-gether",         &mstp_clks[MSTP309]),
-       CLKDEV_DEV_ID("e9a00000.sh-eth",        &mstp_clks[MSTP309]),
+       CLKDEV_DEV_ID("e9a00000.ethernet",      &mstp_clks[MSTP309]),
        CLKDEV_DEV_ID("renesas-tpu-pwm",        &mstp_clks[MSTP304]),
        CLKDEV_DEV_ID("e6600000.pwm",           &mstp_clks[MSTP304]),
 
@@ -604,6 +598,12 @@ static struct clk_lookup lookups[] = {
        CLKDEV_DEV_ID("e6870000.sd",            &mstp_clks[MSTP415]),
 
        /* ICK */
+       CLKDEV_ICK_ID("fck",    "sh-tmu.1",             &mstp_clks[MSTP111]),
+       CLKDEV_ICK_ID("fck",    "fff90000.timer",       &mstp_clks[MSTP111]),
+       CLKDEV_ICK_ID("fck",    "sh-tmu.0",             &mstp_clks[MSTP125]),
+       CLKDEV_ICK_ID("fck",    "fff80000.timer",       &mstp_clks[MSTP125]),
+       CLKDEV_ICK_ID("fck",    "sh-cmt-48.1",          &mstp_clks[MSTP329]),
+       CLKDEV_ICK_ID("fck",    "e6138000.timer",       &mstp_clks[MSTP329]),
        CLKDEV_ICK_ID("host",   "renesas_usbhs",        &mstp_clks[MSTP416]),
        CLKDEV_ICK_ID("func",   "renesas_usbhs",        &mstp_clks[MSTP407]),
        CLKDEV_ICK_ID("phy",    "renesas_usbhs",        &mstp_clks[MSTP406]),
index 9783945..67980a0 100644 (file)
@@ -39,8 +39,8 @@
 #include <linux/io.h>
 #include <linux/sh_clk.h>
 #include <linux/clkdev.h>
-#include <mach/clock.h>
-#include <mach/common.h>
+#include "clock.h"
+#include "common.h"
 
 #define MSTPCR0                IOMEM(0xffc80030)
 #define MSTPCR1                IOMEM(0xffc80034)
@@ -170,15 +170,11 @@ static struct clk mstp_clks[MSTP_NR] = {
        [MSTP010] = SH_CLK_MSTP32(&p_clk, MSTPCR0, 10, 0), /* SSI2 */
        [MSTP009] = SH_CLK_MSTP32(&p_clk, MSTPCR0,  9, 0), /* SSI3 */
        [MSTP008] = SH_CLK_MSTP32(&p_clk, MSTPCR0,  8, 0), /* SRU */
-       [MSTP007] = SH_CLK_MSTP32(&p_clk, MSTPCR0,  7, 0), /* HSPI */
+       [MSTP007] = SH_CLK_MSTP32(&s_clk, MSTPCR0,  7, 0), /* HSPI */
 };
 
 static struct clk_lookup lookups[] = {
        /* main */
-       CLKDEV_CON_ID("audio_clk_a",    &audio_clk_a),
-       CLKDEV_CON_ID("audio_clk_b",    &audio_clk_b),
-       CLKDEV_CON_ID("audio_clk_c",    &audio_clk_c),
-       CLKDEV_CON_ID("audio_clk_internal",     &s1_clk),
        CLKDEV_CON_ID("shyway_clk",     &s_clk),
        CLKDEV_CON_ID("peripheral_clk", &p_clk),
 
@@ -206,13 +202,17 @@ static struct clk_lookup lookups[] = {
        CLKDEV_DEV_ID("i2c-rcar.3", &mstp_clks[MSTP027]), /* I2C3 */
        CLKDEV_DEV_ID("ffc73000.i2c", &mstp_clks[MSTP027]), /* I2C3 */
        CLKDEV_DEV_ID("sh-sci.0", &mstp_clks[MSTP026]), /* SCIF0 */
+       CLKDEV_DEV_ID("ffe40000.serial", &mstp_clks[MSTP026]), /* SCIF0 */
        CLKDEV_DEV_ID("sh-sci.1", &mstp_clks[MSTP025]), /* SCIF1 */
+       CLKDEV_DEV_ID("ffe41000.serial", &mstp_clks[MSTP025]), /* SCIF1 */
        CLKDEV_DEV_ID("sh-sci.2", &mstp_clks[MSTP024]), /* SCIF2 */
+       CLKDEV_DEV_ID("ffe42000.serial", &mstp_clks[MSTP024]), /* SCIF2 */
        CLKDEV_DEV_ID("sh-sci.3", &mstp_clks[MSTP023]), /* SCIF3 */
+       CLKDEV_DEV_ID("ffe43000.serial", &mstp_clks[MSTP023]), /* SCIF3 */
        CLKDEV_DEV_ID("sh-sci.4", &mstp_clks[MSTP022]), /* SCIF4 */
+       CLKDEV_DEV_ID("ffe44000.serial", &mstp_clks[MSTP022]), /* SCIF4 */
        CLKDEV_DEV_ID("sh-sci.5", &mstp_clks[MSTP021]), /* SCIF6 */
-       CLKDEV_DEV_ID("sh_tmu.0", &mstp_clks[MSTP016]), /* TMU00 */
-       CLKDEV_DEV_ID("sh_tmu.1", &mstp_clks[MSTP015]), /* TMU01 */
+       CLKDEV_DEV_ID("ffe45000.serial", &mstp_clks[MSTP021]), /* SCIF5 */
        CLKDEV_DEV_ID("sh-hspi.0", &mstp_clks[MSTP007]), /* HSPI0 */
        CLKDEV_DEV_ID("fffc7000.spi", &mstp_clks[MSTP007]), /* HSPI0 */
        CLKDEV_DEV_ID("sh-hspi.1", &mstp_clks[MSTP007]), /* HSPI1 */
@@ -221,6 +221,10 @@ static struct clk_lookup lookups[] = {
        CLKDEV_DEV_ID("fffc6000.spi", &mstp_clks[MSTP007]), /* HSPI2 */
        CLKDEV_DEV_ID("rcar_sound", &mstp_clks[MSTP008]), /* SRU */
 
+       CLKDEV_ICK_ID("clk_a", "rcar_sound", &audio_clk_a),
+       CLKDEV_ICK_ID("clk_b", "rcar_sound", &audio_clk_b),
+       CLKDEV_ICK_ID("clk_c", "rcar_sound", &audio_clk_c),
+       CLKDEV_ICK_ID("clk_i", "rcar_sound", &s1_clk),
        CLKDEV_ICK_ID("ssi.0", "rcar_sound", &mstp_clks[MSTP012]),
        CLKDEV_ICK_ID("ssi.1", "rcar_sound", &mstp_clks[MSTP011]),
        CLKDEV_ICK_ID("ssi.2", "rcar_sound", &mstp_clks[MSTP010]),
@@ -230,15 +234,19 @@ static struct clk_lookup lookups[] = {
        CLKDEV_ICK_ID("ssi.6", "rcar_sound", &mstp_clks[MSTP309]),
        CLKDEV_ICK_ID("ssi.7", "rcar_sound", &mstp_clks[MSTP308]),
        CLKDEV_ICK_ID("ssi.8", "rcar_sound", &mstp_clks[MSTP307]),
-       CLKDEV_ICK_ID("scu.0", "rcar_sound", &mstp_clks[MSTP531]),
-       CLKDEV_ICK_ID("scu.1", "rcar_sound", &mstp_clks[MSTP530]),
-       CLKDEV_ICK_ID("scu.2", "rcar_sound", &mstp_clks[MSTP529]),
-       CLKDEV_ICK_ID("scu.3", "rcar_sound", &mstp_clks[MSTP528]),
-       CLKDEV_ICK_ID("scu.4", "rcar_sound", &mstp_clks[MSTP527]),
-       CLKDEV_ICK_ID("scu.5", "rcar_sound", &mstp_clks[MSTP526]),
-       CLKDEV_ICK_ID("scu.6", "rcar_sound", &mstp_clks[MSTP525]),
-       CLKDEV_ICK_ID("scu.7", "rcar_sound", &mstp_clks[MSTP524]),
-       CLKDEV_ICK_ID("scu.8", "rcar_sound", &mstp_clks[MSTP523]),
+       CLKDEV_ICK_ID("src.0", "rcar_sound", &mstp_clks[MSTP531]),
+       CLKDEV_ICK_ID("src.1", "rcar_sound", &mstp_clks[MSTP530]),
+       CLKDEV_ICK_ID("src.2", "rcar_sound", &mstp_clks[MSTP529]),
+       CLKDEV_ICK_ID("src.3", "rcar_sound", &mstp_clks[MSTP528]),
+       CLKDEV_ICK_ID("src.4", "rcar_sound", &mstp_clks[MSTP527]),
+       CLKDEV_ICK_ID("src.5", "rcar_sound", &mstp_clks[MSTP526]),
+       CLKDEV_ICK_ID("src.6", "rcar_sound", &mstp_clks[MSTP525]),
+       CLKDEV_ICK_ID("src.7", "rcar_sound", &mstp_clks[MSTP524]),
+       CLKDEV_ICK_ID("src.8", "rcar_sound", &mstp_clks[MSTP523]),
+       CLKDEV_ICK_ID("fck", "sh-tmu.0", &mstp_clks[MSTP016]),
+       CLKDEV_ICK_ID("fck", "ffd80000.timer", &mstp_clks[MSTP016]),
+       CLKDEV_ICK_ID("fck", "sh-tmu.1", &mstp_clks[MSTP015]),
+       CLKDEV_ICK_ID("fck", "ffd81000.timer", &mstp_clks[MSTP015]),
 };
 
 void __init r8a7778_clock_init(void)
index f1fb89b..c51f9db 100644 (file)
 #include <linux/io.h>
 #include <linux/sh_clk.h>
 #include <linux/clkdev.h>
-#include <mach/clock.h>
-#include <mach/common.h>
+#include <linux/sh_timer.h>
+
+#include "clock.h"
+#include "common.h"
+#include "r8a7779.h"
 
 /*
  *             MD1 = 1                 MD1 = 0
 
 #define MD(nr) BIT(nr)
 
-#define FRQMR          IOMEM(0xffc80014)
 #define MSTPCR0                IOMEM(0xffc80030)
 #define MSTPCR1                IOMEM(0xffc80034)
 #define MSTPCR3                IOMEM(0xffc8003c)
 #define MSTPSR1                IOMEM(0xffc80044)
-#define MSTPSR4                IOMEM(0xffc80048)
-#define MSTPSR6                IOMEM(0xffc8004c)
-#define MSTPCR4                IOMEM(0xffc80050)
-#define MSTPCR5                IOMEM(0xffc80054)
-#define MSTPCR6                IOMEM(0xffc80058)
-#define MSTPCR7                IOMEM(0xffc80040)
-
-#define MODEMR         0xffcc0020
-
 
 /* ioremap() through clock mapping mandatory to avoid
  * collision with ARM coherent DMA virtual memory range.
@@ -127,16 +120,16 @@ static struct clk mstp_clks[MSTP_NR] = {
        [MSTP322] = SH_CLK_MSTP32(&clkp_clk, MSTPCR3, 22, 0), /* SDHI1 */
        [MSTP321] = SH_CLK_MSTP32(&clkp_clk, MSTPCR3, 21, 0), /* SDHI2 */
        [MSTP320] = SH_CLK_MSTP32(&clkp_clk, MSTPCR3, 20, 0), /* SDHI3 */
-       [MSTP120] = SH_CLK_MSTP32(&clks_clk, MSTPCR1, 20, 0), /* VIN3 */
-       [MSTP116] = SH_CLK_MSTP32(&clkp_clk, MSTPCR1, 16, 0), /* PCIe */
-       [MSTP115] = SH_CLK_MSTP32(&clkp_clk, MSTPCR1, 15, 0), /* SATA */
-       [MSTP114] = SH_CLK_MSTP32(&clkp_clk, MSTPCR1, 14, 0), /* Ether */
-       [MSTP110] = SH_CLK_MSTP32(&clks_clk, MSTPCR1, 10, 0), /* VIN0 */
-       [MSTP109] = SH_CLK_MSTP32(&clks_clk, MSTPCR1,  9, 0), /* VIN1 */
-       [MSTP108] = SH_CLK_MSTP32(&clks_clk, MSTPCR1,  8, 0), /* VIN2 */
-       [MSTP103] = SH_CLK_MSTP32(&clks_clk, MSTPCR1,  3, 0), /* DU */
-       [MSTP101] = SH_CLK_MSTP32(&clkp_clk, MSTPCR1,  1, 0), /* USB2 */
-       [MSTP100] = SH_CLK_MSTP32(&clkp_clk, MSTPCR1,  0, 0), /* USB0/1 */
+       [MSTP120] = SH_CLK_MSTP32_STS(&clks_clk, MSTPCR1, 20, MSTPSR1, 0), /* VIN3 */
+       [MSTP116] = SH_CLK_MSTP32_STS(&clkp_clk, MSTPCR1, 16, MSTPSR1, 0), /* PCIe */
+       [MSTP115] = SH_CLK_MSTP32_STS(&clkp_clk, MSTPCR1, 15, MSTPSR1, 0), /* SATA */
+       [MSTP114] = SH_CLK_MSTP32_STS(&clkp_clk, MSTPCR1, 14, MSTPSR1, 0), /* Ether */
+       [MSTP110] = SH_CLK_MSTP32_STS(&clks_clk, MSTPCR1, 10, MSTPSR1, 0), /* VIN0 */
+       [MSTP109] = SH_CLK_MSTP32_STS(&clks_clk, MSTPCR1,  9, MSTPSR1, 0), /* VIN1 */
+       [MSTP108] = SH_CLK_MSTP32_STS(&clks_clk, MSTPCR1,  8, MSTPSR1, 0), /* VIN2 */
+       [MSTP103] = SH_CLK_MSTP32_STS(&clks_clk, MSTPCR1,  3, MSTPSR1, 0), /* DU */
+       [MSTP101] = SH_CLK_MSTP32_STS(&clkp_clk, MSTPCR1,  1, MSTPSR1, 0), /* USB2 */
+       [MSTP100] = SH_CLK_MSTP32_STS(&clkp_clk, MSTPCR1,  0, MSTPSR1, 0), /* USB0/1 */
        [MSTP030] = SH_CLK_MSTP32(&clkp_clk, MSTPCR0, 30, 0), /* I2C0 */
        [MSTP029] = SH_CLK_MSTP32(&clkp_clk, MSTPCR0, 29, 0), /* I2C1 */
        [MSTP028] = SH_CLK_MSTP32(&clkp_clk, MSTPCR0, 28, 0), /* I2C2 */
@@ -180,9 +173,7 @@ static struct clk_lookup lookups[] = {
        CLKDEV_DEV_ID("ohci-platform.1", &mstp_clks[MSTP101]), /* USB OHCI port2 */
        CLKDEV_DEV_ID("ehci-platform.0", &mstp_clks[MSTP100]), /* USB EHCI port0/1 */
        CLKDEV_DEV_ID("ohci-platform.0", &mstp_clks[MSTP100]), /* USB OHCI port0/1 */
-       CLKDEV_DEV_ID("sh_tmu.0", &mstp_clks[MSTP016]), /* TMU00 */
-       CLKDEV_DEV_ID("sh_tmu.1", &mstp_clks[MSTP016]), /* TMU01 */
-       CLKDEV_DEV_ID("sh_tmu.2", &mstp_clks[MSTP016]), /* TMU02 */
+       CLKDEV_ICK_ID("fck", "sh-tmu.0", &mstp_clks[MSTP016]), /* TMU0 */
        CLKDEV_DEV_ID("i2c-rcar.0", &mstp_clks[MSTP030]), /* I2C0 */
        CLKDEV_DEV_ID("ffc70000.i2c", &mstp_clks[MSTP030]), /* I2C0 */
        CLKDEV_DEV_ID("i2c-rcar.1", &mstp_clks[MSTP029]), /* I2C1 */
@@ -216,14 +207,9 @@ static struct clk_lookup lookups[] = {
 
 void __init r8a7779_clock_init(void)
 {
-       void __iomem *modemr = ioremap_nocache(MODEMR, PAGE_SIZE);
-       u32 mode;
+       u32 mode = r8a7779_read_mode_pins();
        int k, ret = 0;
 
-       BUG_ON(!modemr);
-       mode = ioread32(modemr);
-       iounmap(modemr);
-
        if (mode & MD(1)) {
                plla_clk.rate = 1500000000;
 
@@ -277,3 +263,13 @@ void __init r8a7779_clock_init(void)
        else
                panic("failed to setup r8a7779 clocks\n");
 }
+
+/* do nothing for !CONFIG_SMP or !CONFIG_HAVE_TWD */
+void __init __weak r8a7779_register_twd(void) { }
+
+void __init r8a7779_earlytimer_init(void)
+{
+       r8a7779_clock_init();
+       r8a7779_register_twd();
+       shmobile_earlytimer_init();
+}
index f44987a..126ddaf 100644 (file)
 #include <linux/kernel.h>
 #include <linux/sh_clk.h>
 #include <linux/clkdev.h>
-#include <mach/clock.h>
-#include <mach/common.h>
-#include <mach/r8a7790.h>
+
+#include "clock.h"
+#include "common.h"
+#include "r8a7790.h"
+#include "rcar-gen2.h"
 
 /*
  *   MD                EXTAL           PLL0    PLL1    PLL3
  *     see "p1 / 2" on R8A7790_CLOCK_ROOT() below
  */
 
-#define CPG_BASE 0xe6150000
-#define CPG_LEN 0x1000
-
-#define SMSTPCR1 0xe6150134
-#define SMSTPCR2 0xe6150138
-#define SMSTPCR3 0xe615013c
-#define SMSTPCR5 0xe6150144
-#define SMSTPCR7 0xe615014c
-#define SMSTPCR8 0xe6150990
-#define SMSTPCR9 0xe6150994
-#define SMSTPCR10 0xe6150998
+#define CPG_BASE       0xe6150000
+#define CPG_LEN                0x1000
+
+#define SMSTPCR1       0xe6150134
+#define SMSTPCR2       0xe6150138
+#define SMSTPCR3       0xe615013c
+#define SMSTPCR5       0xe6150144
+#define SMSTPCR7       0xe615014c
+#define SMSTPCR8       0xe6150990
+#define SMSTPCR9       0xe6150994
+#define SMSTPCR10      0xe6150998
+
+#define MSTPSR1                IOMEM(0xe6150038)
+#define MSTPSR2                IOMEM(0xe6150040)
+#define MSTPSR3                IOMEM(0xe6150048)
+#define MSTPSR5                IOMEM(0xe615003c)
+#define MSTPSR7                IOMEM(0xe61501c4)
+#define MSTPSR8                IOMEM(0xe61509a0)
+#define MSTPSR9                IOMEM(0xe61509a4)
+#define MSTPSR10       IOMEM(0xe61509a8)
 
 #define SDCKCR         0xE6150074
 #define SD2CKCR                0xE6150078
@@ -82,6 +93,15 @@ static struct clk main_clk = {
        .ops    = &followparent_clk_ops,
 };
 
+static struct clk audio_clk_a = {
+};
+
+static struct clk audio_clk_b = {
+};
+
+static struct clk audio_clk_c = {
+};
+
 /*
  * clock ratio of these clock will be updated
  * on r8a7790_clock_init()
@@ -115,6 +135,9 @@ SH_FIXED_RATIO_CLK_SET(ddr_clk,                     pll3_clk,       1, 8);
 SH_FIXED_RATIO_CLK_SET(mp_clk,                 pll1_div2_clk,  1, 15);
 
 static struct clk *main_clks[] = {
+       &audio_clk_a,
+       &audio_clk_b,
+       &audio_clk_c,
        &extal_clk,
        &extal_div2_clk,
        &main_clk,
@@ -160,8 +183,8 @@ enum {
 
 static struct clk div4_clks[DIV4_NR] = {
        [DIV4_SDH] = SH_CLK_DIV4(&pll1_clk, SDCKCR, 8, 0x0dff, CLK_ENABLE_ON_INIT),
-       [DIV4_SD0] = SH_CLK_DIV4(&pll1_clk, SDCKCR, 4, 0x1de0, CLK_ENABLE_ON_INIT),
-       [DIV4_SD1] = SH_CLK_DIV4(&pll1_clk, SDCKCR, 0, 0x1de0, CLK_ENABLE_ON_INIT),
+       [DIV4_SD0] = SH_CLK_DIV4(&pll1_clk, SDCKCR, 4, 0x1df0, CLK_ENABLE_ON_INIT),
+       [DIV4_SD1] = SH_CLK_DIV4(&pll1_clk, SDCKCR, 0, 0x1df0, CLK_ENABLE_ON_INIT),
 };
 
 /* DIV6 clocks */
@@ -183,15 +206,22 @@ static struct clk div6_clks[DIV6_NR] = {
 
 /* MSTP */
 enum {
+       MSTP1017, /* parent of SCU */
+
+       MSTP1031, MSTP1030,
+       MSTP1029, MSTP1028, MSTP1027, MSTP1026, MSTP1025, MSTP1024, MSTP1023, MSTP1022,
        MSTP1015, MSTP1014, MSTP1013, MSTP1012, MSTP1011, MSTP1010,
        MSTP1009, MSTP1008, MSTP1007, MSTP1006, MSTP1005,
        MSTP931, MSTP930, MSTP929, MSTP928,
        MSTP917,
+       MSTP815, MSTP814,
        MSTP813,
+       MSTP811, MSTP810, MSTP809, MSTP808,
        MSTP726, MSTP725, MSTP724, MSTP723, MSTP722, MSTP721, MSTP720,
        MSTP717, MSTP716,
-       MSTP704,
+       MSTP704, MSTP703,
        MSTP522,
+       MSTP502, MSTP501,
        MSTP315, MSTP314, MSTP313, MSTP312, MSTP311, MSTP305, MSTP304,
        MSTP216, MSTP207, MSTP206, MSTP204, MSTP203, MSTP202,
        MSTP124,
@@ -199,48 +229,68 @@ enum {
 };
 
 static struct clk mstp_clks[MSTP_NR] = {
-       [MSTP1015] = SH_CLK_MSTP32(&p_clk, SMSTPCR10, 15, 0), /* SSI0 */
-       [MSTP1014] = SH_CLK_MSTP32(&p_clk, SMSTPCR10, 14, 0), /* SSI1 */
-       [MSTP1013] = SH_CLK_MSTP32(&p_clk, SMSTPCR10, 13, 0), /* SSI2 */
-       [MSTP1012] = SH_CLK_MSTP32(&p_clk, SMSTPCR10, 12, 0), /* SSI3 */
-       [MSTP1011] = SH_CLK_MSTP32(&p_clk, SMSTPCR10, 11, 0), /* SSI4 */
-       [MSTP1010] = SH_CLK_MSTP32(&p_clk, SMSTPCR10, 10, 0), /* SSI5 */
-       [MSTP1009] = SH_CLK_MSTP32(&p_clk, SMSTPCR10,  9, 0), /* SSI6 */
-       [MSTP1008] = SH_CLK_MSTP32(&p_clk, SMSTPCR10,  8, 0), /* SSI7 */
-       [MSTP1007] = SH_CLK_MSTP32(&p_clk, SMSTPCR10,  7, 0), /* SSI8 */
-       [MSTP1006] = SH_CLK_MSTP32(&p_clk, SMSTPCR10,  6, 0), /* SSI9 */
-       [MSTP1005] = SH_CLK_MSTP32(&p_clk, SMSTPCR10,  5, 0), /* SSI ALL */
-       [MSTP931] = SH_CLK_MSTP32(&p_clk, SMSTPCR9, 31, 0), /* I2C0 */
-       [MSTP930] = SH_CLK_MSTP32(&p_clk, SMSTPCR9, 30, 0), /* I2C1 */
-       [MSTP929] = SH_CLK_MSTP32(&p_clk, SMSTPCR9, 29, 0), /* I2C2 */
-       [MSTP928] = SH_CLK_MSTP32(&p_clk, SMSTPCR9, 28, 0), /* I2C3 */
-       [MSTP917] = SH_CLK_MSTP32(&qspi_clk, SMSTPCR9, 17, 0), /* QSPI */
-       [MSTP813] = SH_CLK_MSTP32(&p_clk, SMSTPCR8, 13, 0), /* Ether */
-       [MSTP726] = SH_CLK_MSTP32(&zx_clk, SMSTPCR7, 26, 0), /* LVDS0 */
-       [MSTP725] = SH_CLK_MSTP32(&zx_clk, SMSTPCR7, 25, 0), /* LVDS1 */
-       [MSTP724] = SH_CLK_MSTP32(&zx_clk, SMSTPCR7, 24, 0), /* DU0 */
-       [MSTP723] = SH_CLK_MSTP32(&zx_clk, SMSTPCR7, 23, 0), /* DU1 */
-       [MSTP722] = SH_CLK_MSTP32(&zx_clk, SMSTPCR7, 22, 0), /* DU2 */
-       [MSTP721] = SH_CLK_MSTP32(&p_clk, SMSTPCR7, 21, 0), /* SCIF0 */
-       [MSTP720] = SH_CLK_MSTP32(&p_clk, SMSTPCR7, 20, 0), /* SCIF1 */
-       [MSTP717] = SH_CLK_MSTP32(&zs_clk, SMSTPCR7, 17, 0), /* HSCIF0 */
-       [MSTP716] = SH_CLK_MSTP32(&zs_clk, SMSTPCR7, 16, 0), /* HSCIF1 */
-       [MSTP704] = SH_CLK_MSTP32(&mp_clk, SMSTPCR7, 4, 0), /* HSUSB */
-       [MSTP522] = SH_CLK_MSTP32(&extal_clk, SMSTPCR5, 22, 0), /* Thermal */
-       [MSTP315] = SH_CLK_MSTP32(&div6_clks[DIV6_MMC0], SMSTPCR3, 15, 0), /* MMC0 */
-       [MSTP314] = SH_CLK_MSTP32(&div4_clks[DIV4_SD0], SMSTPCR3, 14, 0), /* SDHI0 */
-       [MSTP313] = SH_CLK_MSTP32(&div4_clks[DIV4_SD1], SMSTPCR3, 13, 0), /* SDHI1 */
-       [MSTP312] = SH_CLK_MSTP32(&div6_clks[DIV6_SD2], SMSTPCR3, 12, 0), /* SDHI2 */
-       [MSTP311] = SH_CLK_MSTP32(&div6_clks[DIV6_SD3], SMSTPCR3, 11, 0), /* SDHI3 */
-       [MSTP305] = SH_CLK_MSTP32(&div6_clks[DIV6_MMC1], SMSTPCR3, 5, 0), /* MMC1 */
-       [MSTP304] = SH_CLK_MSTP32(&cp_clk, SMSTPCR3, 4, 0), /* TPU0 */
-       [MSTP216] = SH_CLK_MSTP32(&mp_clk, SMSTPCR2, 16, 0), /* SCIFB2 */
-       [MSTP207] = SH_CLK_MSTP32(&mp_clk, SMSTPCR2, 7, 0), /* SCIFB1 */
-       [MSTP206] = SH_CLK_MSTP32(&mp_clk, SMSTPCR2, 6, 0), /* SCIFB0 */
-       [MSTP204] = SH_CLK_MSTP32(&mp_clk, SMSTPCR2, 4, 0), /* SCIFA0 */
-       [MSTP203] = SH_CLK_MSTP32(&mp_clk, SMSTPCR2, 3, 0), /* SCIFA1 */
-       [MSTP202] = SH_CLK_MSTP32(&mp_clk, SMSTPCR2, 2, 0), /* SCIFA2 */
-       [MSTP124] = SH_CLK_MSTP32(&rclk_clk, SMSTPCR1, 24, 0), /* CMT0 */
+       [MSTP1031] = SH_CLK_MSTP32_STS(&mstp_clks[MSTP1017], SMSTPCR10, 31, MSTPSR10, 0), /* SCU0 */
+       [MSTP1030] = SH_CLK_MSTP32_STS(&mstp_clks[MSTP1017], SMSTPCR10, 30, MSTPSR10, 0), /* SCU1 */
+       [MSTP1029] = SH_CLK_MSTP32_STS(&mstp_clks[MSTP1017], SMSTPCR10, 29, MSTPSR10, 0), /* SCU2 */
+       [MSTP1028] = SH_CLK_MSTP32_STS(&mstp_clks[MSTP1017], SMSTPCR10, 28, MSTPSR10, 0), /* SCU3 */
+       [MSTP1027] = SH_CLK_MSTP32_STS(&mstp_clks[MSTP1017], SMSTPCR10, 27, MSTPSR10, 0), /* SCU4 */
+       [MSTP1026] = SH_CLK_MSTP32_STS(&mstp_clks[MSTP1017], SMSTPCR10, 26, MSTPSR10, 0), /* SCU5 */
+       [MSTP1025] = SH_CLK_MSTP32_STS(&mstp_clks[MSTP1017], SMSTPCR10, 25, MSTPSR10, 0), /* SCU6 */
+       [MSTP1024] = SH_CLK_MSTP32_STS(&mstp_clks[MSTP1017], SMSTPCR10, 24, MSTPSR10, 0), /* SCU7 */
+       [MSTP1023] = SH_CLK_MSTP32_STS(&mstp_clks[MSTP1017], SMSTPCR10, 23, MSTPSR10, 0), /* SCU8 */
+       [MSTP1022] = SH_CLK_MSTP32_STS(&mstp_clks[MSTP1017], SMSTPCR10, 22, MSTPSR10, 0), /* SCU9 */
+       [MSTP1017] = SH_CLK_MSTP32_STS(&p_clk, SMSTPCR10, 17, MSTPSR10, 0), /* SCU */
+       [MSTP1015] = SH_CLK_MSTP32_STS(&p_clk, SMSTPCR10, 15, MSTPSR10, 0), /* SSI0 */
+       [MSTP1014] = SH_CLK_MSTP32_STS(&p_clk, SMSTPCR10, 14, MSTPSR10, 0), /* SSI1 */
+       [MSTP1013] = SH_CLK_MSTP32_STS(&p_clk, SMSTPCR10, 13, MSTPSR10, 0), /* SSI2 */
+       [MSTP1012] = SH_CLK_MSTP32_STS(&p_clk, SMSTPCR10, 12, MSTPSR10, 0), /* SSI3 */
+       [MSTP1011] = SH_CLK_MSTP32_STS(&p_clk, SMSTPCR10, 11, MSTPSR10, 0), /* SSI4 */
+       [MSTP1010] = SH_CLK_MSTP32_STS(&p_clk, SMSTPCR10, 10, MSTPSR10, 0), /* SSI5 */
+       [MSTP1009] = SH_CLK_MSTP32_STS(&p_clk, SMSTPCR10, 9, MSTPSR10, 0), /* SSI6 */
+       [MSTP1008] = SH_CLK_MSTP32_STS(&p_clk, SMSTPCR10, 8, MSTPSR10, 0), /* SSI7 */
+       [MSTP1007] = SH_CLK_MSTP32_STS(&p_clk, SMSTPCR10, 7, MSTPSR10, 0), /* SSI8 */
+       [MSTP1006] = SH_CLK_MSTP32_STS(&p_clk, SMSTPCR10, 6, MSTPSR10, 0), /* SSI9 */
+       [MSTP1005] = SH_CLK_MSTP32_STS(&p_clk, SMSTPCR10, 5, MSTPSR10, 0), /* SSI ALL */
+       [MSTP931] = SH_CLK_MSTP32_STS(&hp_clk, SMSTPCR9, 31, MSTPSR9, 0), /* I2C0 */
+       [MSTP930] = SH_CLK_MSTP32_STS(&hp_clk, SMSTPCR9, 30, MSTPSR9, 0), /* I2C1 */
+       [MSTP929] = SH_CLK_MSTP32_STS(&hp_clk, SMSTPCR9, 29, MSTPSR9, 0), /* I2C2 */
+       [MSTP928] = SH_CLK_MSTP32_STS(&hp_clk, SMSTPCR9, 28, MSTPSR9, 0), /* I2C3 */
+       [MSTP917] = SH_CLK_MSTP32_STS(&qspi_clk, SMSTPCR9, 17, MSTPSR9, 0), /* QSPI */
+       [MSTP815] = SH_CLK_MSTP32_STS(&zs_clk, SMSTPCR8, 15, MSTPSR8, 0), /* SATA0 */
+       [MSTP814] = SH_CLK_MSTP32_STS(&zs_clk, SMSTPCR8, 14, MSTPSR8, 0), /* SATA1 */
+       [MSTP813] = SH_CLK_MSTP32_STS(&p_clk, SMSTPCR8, 13, MSTPSR8, 0), /* Ether */
+       [MSTP811] = SH_CLK_MSTP32_STS(&zg_clk, SMSTPCR8, 11, MSTPSR8, 0), /* VIN0 */
+       [MSTP810] = SH_CLK_MSTP32_STS(&zg_clk, SMSTPCR8, 10, MSTPSR8, 0), /* VIN1 */
+       [MSTP809] = SH_CLK_MSTP32_STS(&zg_clk, SMSTPCR8,  9, MSTPSR8, 0), /* VIN2 */
+       [MSTP808] = SH_CLK_MSTP32_STS(&zg_clk, SMSTPCR8,  8, MSTPSR8, 0), /* VIN3 */
+       [MSTP726] = SH_CLK_MSTP32_STS(&zx_clk, SMSTPCR7, 26, MSTPSR7, 0), /* LVDS0 */
+       [MSTP725] = SH_CLK_MSTP32_STS(&zx_clk, SMSTPCR7, 25, MSTPSR7, 0), /* LVDS1 */
+       [MSTP724] = SH_CLK_MSTP32_STS(&zx_clk, SMSTPCR7, 24, MSTPSR7, 0), /* DU0 */
+       [MSTP723] = SH_CLK_MSTP32_STS(&zx_clk, SMSTPCR7, 23, MSTPSR7, 0), /* DU1 */
+       [MSTP722] = SH_CLK_MSTP32_STS(&zx_clk, SMSTPCR7, 22, MSTPSR7, 0), /* DU2 */
+       [MSTP721] = SH_CLK_MSTP32_STS(&p_clk, SMSTPCR7, 21, MSTPSR7, 0), /* SCIF0 */
+       [MSTP720] = SH_CLK_MSTP32_STS(&p_clk, SMSTPCR7, 20, MSTPSR7, 0), /* SCIF1 */
+       [MSTP717] = SH_CLK_MSTP32_STS(&zs_clk, SMSTPCR7, 17, MSTPSR7, 0), /* HSCIF0 */
+       [MSTP716] = SH_CLK_MSTP32_STS(&zs_clk, SMSTPCR7, 16, MSTPSR7, 0), /* HSCIF1 */
+       [MSTP704] = SH_CLK_MSTP32_STS(&mp_clk, SMSTPCR7, 4, MSTPSR7, 0), /* HSUSB */
+       [MSTP703] = SH_CLK_MSTP32_STS(&mp_clk, SMSTPCR7, 3, MSTPSR7, 0), /* EHCI */
+       [MSTP522] = SH_CLK_MSTP32_STS(&extal_clk, SMSTPCR5, 22, MSTPSR5, 0), /* Thermal */
+       [MSTP502] = SH_CLK_MSTP32_STS(&zs_clk, SMSTPCR5, 2, MSTPSR5, 0), /* Audio-DMAC low */
+       [MSTP501] = SH_CLK_MSTP32_STS(&zs_clk, SMSTPCR5, 1, MSTPSR5, 0), /* Audio-DMAC hi */
+       [MSTP315] = SH_CLK_MSTP32_STS(&div6_clks[DIV6_MMC0], SMSTPCR3, 15, MSTPSR3, 0), /* MMC0 */
+       [MSTP314] = SH_CLK_MSTP32_STS(&div4_clks[DIV4_SD0], SMSTPCR3, 14, MSTPSR3, 0), /* SDHI0 */
+       [MSTP313] = SH_CLK_MSTP32_STS(&div4_clks[DIV4_SD1], SMSTPCR3, 13, MSTPSR3, 0), /* SDHI1 */
+       [MSTP312] = SH_CLK_MSTP32_STS(&div6_clks[DIV6_SD2], SMSTPCR3, 12, MSTPSR3, 0), /* SDHI2 */
+       [MSTP311] = SH_CLK_MSTP32_STS(&div6_clks[DIV6_SD3], SMSTPCR3, 11, MSTPSR3, 0), /* SDHI3 */
+       [MSTP305] = SH_CLK_MSTP32_STS(&div6_clks[DIV6_MMC1], SMSTPCR3, 5, MSTPSR3, 0), /* MMC1 */
+       [MSTP304] = SH_CLK_MSTP32_STS(&cp_clk, SMSTPCR3, 4, MSTPSR3, 0), /* TPU0 */
+       [MSTP216] = SH_CLK_MSTP32_STS(&mp_clk, SMSTPCR2, 16, MSTPSR2, 0), /* SCIFB2 */
+       [MSTP207] = SH_CLK_MSTP32_STS(&mp_clk, SMSTPCR2, 7, MSTPSR2, 0), /* SCIFB1 */
+       [MSTP206] = SH_CLK_MSTP32_STS(&mp_clk, SMSTPCR2, 6, MSTPSR2, 0), /* SCIFB0 */
+       [MSTP204] = SH_CLK_MSTP32_STS(&mp_clk, SMSTPCR2, 4, MSTPSR2, 0), /* SCIFA0 */
+       [MSTP203] = SH_CLK_MSTP32_STS(&mp_clk, SMSTPCR2, 3, MSTPSR2, 0), /* SCIFA1 */
+       [MSTP202] = SH_CLK_MSTP32_STS(&mp_clk, SMSTPCR2, 2, MSTPSR2, 0), /* SCIFA2 */
+       [MSTP124] = SH_CLK_MSTP32_STS(&rclk_clk, SMSTPCR1, 24, MSTPSR1, 0), /* CMT0 */
 };
 
 static struct clk_lookup lookups[] = {
@@ -291,40 +341,54 @@ static struct clk_lookup lookups[] = {
        CLKDEV_DEV_ID("sh-sci.7", &mstp_clks[MSTP720]),
        CLKDEV_DEV_ID("sh-sci.8", &mstp_clks[MSTP717]),
        CLKDEV_DEV_ID("sh-sci.9", &mstp_clks[MSTP716]),
-       CLKDEV_DEV_ID("e6508000.i2c", &mstp_clks[MSTP931]),
        CLKDEV_DEV_ID("i2c-rcar_gen2.0", &mstp_clks[MSTP931]),
-       CLKDEV_DEV_ID("e6518000.i2c", &mstp_clks[MSTP930]),
        CLKDEV_DEV_ID("i2c-rcar_gen2.1", &mstp_clks[MSTP930]),
-       CLKDEV_DEV_ID("e6530000.i2c", &mstp_clks[MSTP929]),
        CLKDEV_DEV_ID("i2c-rcar_gen2.2", &mstp_clks[MSTP929]),
-       CLKDEV_DEV_ID("e6540000.i2c", &mstp_clks[MSTP928]),
        CLKDEV_DEV_ID("i2c-rcar_gen2.3", &mstp_clks[MSTP928]),
        CLKDEV_DEV_ID("r8a7790-ether", &mstp_clks[MSTP813]),
-       CLKDEV_DEV_ID("e61f0000.thermal", &mstp_clks[MSTP522]),
+       CLKDEV_DEV_ID("r8a7790-vin.0", &mstp_clks[MSTP811]),
+       CLKDEV_DEV_ID("r8a7790-vin.1", &mstp_clks[MSTP810]),
+       CLKDEV_DEV_ID("r8a7790-vin.2", &mstp_clks[MSTP809]),
+       CLKDEV_DEV_ID("r8a7790-vin.3", &mstp_clks[MSTP808]),
        CLKDEV_DEV_ID("rcar_thermal", &mstp_clks[MSTP522]),
-       CLKDEV_DEV_ID("ee200000.mmc", &mstp_clks[MSTP315]),
+       CLKDEV_DEV_ID("sh-dma-engine.0", &mstp_clks[MSTP502]),
+       CLKDEV_DEV_ID("sh-dma-engine.1", &mstp_clks[MSTP501]),
        CLKDEV_DEV_ID("sh_mmcif.0", &mstp_clks[MSTP315]),
-       CLKDEV_DEV_ID("ee100000.sd", &mstp_clks[MSTP314]),
        CLKDEV_DEV_ID("sh_mobile_sdhi.0", &mstp_clks[MSTP314]),
-       CLKDEV_DEV_ID("ee120000.sd", &mstp_clks[MSTP313]),
        CLKDEV_DEV_ID("sh_mobile_sdhi.1", &mstp_clks[MSTP313]),
-       CLKDEV_DEV_ID("ee140000.sd", &mstp_clks[MSTP312]),
        CLKDEV_DEV_ID("sh_mobile_sdhi.2", &mstp_clks[MSTP312]),
-       CLKDEV_DEV_ID("ee160000.sd", &mstp_clks[MSTP311]),
        CLKDEV_DEV_ID("sh_mobile_sdhi.3", &mstp_clks[MSTP311]),
-       CLKDEV_DEV_ID("ee220000.mmc", &mstp_clks[MSTP305]),
        CLKDEV_DEV_ID("sh_mmcif.1", &mstp_clks[MSTP305]),
-       CLKDEV_DEV_ID("sh_cmt.0", &mstp_clks[MSTP124]),
        CLKDEV_DEV_ID("qspi.0", &mstp_clks[MSTP917]),
        CLKDEV_DEV_ID("renesas_usbhs", &mstp_clks[MSTP704]),
+       CLKDEV_DEV_ID("pci-rcar-gen2.0", &mstp_clks[MSTP703]),
+       CLKDEV_DEV_ID("pci-rcar-gen2.1", &mstp_clks[MSTP703]),
+       CLKDEV_DEV_ID("pci-rcar-gen2.2", &mstp_clks[MSTP703]),
+       CLKDEV_DEV_ID("sata-r8a7790.0", &mstp_clks[MSTP815]),
+       CLKDEV_DEV_ID("sata-r8a7790.1", &mstp_clks[MSTP814]),
 
        /* ICK */
+       CLKDEV_ICK_ID("fck", "sh-cmt-48-gen2.0", &mstp_clks[MSTP124]),
        CLKDEV_ICK_ID("usbhs", "usb_phy_rcar_gen2", &mstp_clks[MSTP704]),
        CLKDEV_ICK_ID("lvds.0", "rcar-du-r8a7790", &mstp_clks[MSTP726]),
        CLKDEV_ICK_ID("lvds.1", "rcar-du-r8a7790", &mstp_clks[MSTP725]),
        CLKDEV_ICK_ID("du.0", "rcar-du-r8a7790", &mstp_clks[MSTP724]),
        CLKDEV_ICK_ID("du.1", "rcar-du-r8a7790", &mstp_clks[MSTP723]),
        CLKDEV_ICK_ID("du.2", "rcar-du-r8a7790", &mstp_clks[MSTP722]),
+       CLKDEV_ICK_ID("clk_a", "rcar_sound", &audio_clk_a),
+       CLKDEV_ICK_ID("clk_b", "rcar_sound", &audio_clk_b),
+       CLKDEV_ICK_ID("clk_c", "rcar_sound", &audio_clk_c),
+       CLKDEV_ICK_ID("clk_i", "rcar_sound", &m2_clk),
+       CLKDEV_ICK_ID("src.0", "rcar_sound", &mstp_clks[MSTP1031]),
+       CLKDEV_ICK_ID("src.1", "rcar_sound", &mstp_clks[MSTP1030]),
+       CLKDEV_ICK_ID("src.2", "rcar_sound", &mstp_clks[MSTP1029]),
+       CLKDEV_ICK_ID("src.3", "rcar_sound", &mstp_clks[MSTP1028]),
+       CLKDEV_ICK_ID("src.4", "rcar_sound", &mstp_clks[MSTP1027]),
+       CLKDEV_ICK_ID("src.5", "rcar_sound", &mstp_clks[MSTP1026]),
+       CLKDEV_ICK_ID("src.6", "rcar_sound", &mstp_clks[MSTP1025]),
+       CLKDEV_ICK_ID("src.7", "rcar_sound", &mstp_clks[MSTP1024]),
+       CLKDEV_ICK_ID("src.8", "rcar_sound", &mstp_clks[MSTP1023]),
+       CLKDEV_ICK_ID("src.9", "rcar_sound", &mstp_clks[MSTP1022]),
        CLKDEV_ICK_ID("ssi.0", "rcar_sound", &mstp_clks[MSTP1015]),
        CLKDEV_ICK_ID("ssi.1", "rcar_sound", &mstp_clks[MSTP1014]),
        CLKDEV_ICK_ID("ssi.2", "rcar_sound", &mstp_clks[MSTP1013]),
index f546126..453b231 100644 (file)
@@ -23,8 +23,9 @@
 #include <linux/kernel.h>
 #include <linux/sh_clk.h>
 #include <linux/clkdev.h>
-#include <mach/clock.h>
-#include <mach/common.h>
+#include "clock.h"
+#include "common.h"
+#include "rcar-gen2.h"
 
 /*
  *   MD                EXTAL           PLL0    PLL1    PLL3
@@ -43,8 +44,6 @@
  *     see "p1 / 2" on R8A7791_CLOCK_ROOT() below
  */
 
-#define MD(nr) (1 << nr)
-
 #define CPG_BASE 0xe6150000
 #define CPG_LEN 0x1000
 
 #define SMSTPCR10      0xE6150998
 #define SMSTPCR11      0xE615099C
 
-#define MODEMR         0xE6160060
+#define MSTPSR1                IOMEM(0xe6150038)
+#define MSTPSR2                IOMEM(0xe6150040)
+#define MSTPSR3                IOMEM(0xe6150048)
+#define MSTPSR5                IOMEM(0xe615003c)
+#define MSTPSR7                IOMEM(0xe61501c4)
+#define MSTPSR8                IOMEM(0xe61509a0)
+#define MSTPSR9                IOMEM(0xe61509a4)
+#define MSTPSR11       IOMEM(0xe61509ac)
+
 #define SDCKCR         0xE6150074
-#define SD2CKCR                0xE6150078
-#define SD3CKCR                0xE615007C
+#define SD1CKCR                0xE6150078
+#define SD2CKCR                0xE615026c
 #define MMC0CKCR       0xE6150240
 #define MMC1CKCR       0xE6150244
 #define SSPCKCR                0xE6150248
@@ -93,6 +100,7 @@ static struct clk main_clk = {
  */
 SH_FIXED_RATIO_CLK_SET(pll1_clk,               main_clk,       1, 1);
 SH_FIXED_RATIO_CLK_SET(pll3_clk,               main_clk,       1, 1);
+SH_FIXED_RATIO_CLK_SET(qspi_clk,               pll1_clk,       1, 1);
 
 /* fixed ratio clock */
 SH_FIXED_RATIO_CLK_SET(extal_div2_clk,         extal_clk,      1, 2);
@@ -103,7 +111,9 @@ SH_FIXED_RATIO_CLK_SET(hp_clk,                      pll1_clk,       1, 12);
 SH_FIXED_RATIO_CLK_SET(p_clk,                  pll1_clk,       1, 24);
 SH_FIXED_RATIO_CLK_SET(rclk_clk,               pll1_clk,       1, (48 * 1024));
 SH_FIXED_RATIO_CLK_SET(mp_clk,                 pll1_div2_clk,  1, 15);
+SH_FIXED_RATIO_CLK_SET(zg_clk,                 pll1_clk,       1, 3);
 SH_FIXED_RATIO_CLK_SET(zx_clk,                 pll1_clk,       1, 3);
+SH_FIXED_RATIO_CLK_SET(zs_clk,                 pll1_clk,       1, 6);
 
 static struct clk *main_clks[] = {
        &extal_clk,
@@ -114,46 +124,103 @@ static struct clk *main_clks[] = {
        &pll3_clk,
        &hp_clk,
        &p_clk,
+       &qspi_clk,
        &rclk_clk,
        &mp_clk,
        &cp_clk,
+       &zg_clk,
        &zx_clk,
+       &zs_clk,
+};
+
+/* SDHI (DIV4) clock */
+static int divisors[] = { 2, 3, 4, 6, 8, 12, 16, 18, 24, 0, 36, 48, 10 };
+
+static struct clk_div_mult_table div4_div_mult_table = {
+       .divisors = divisors,
+       .nr_divisors = ARRAY_SIZE(divisors),
+};
+
+static struct clk_div4_table div4_table = {
+       .div_mult_table = &div4_div_mult_table,
+};
+
+enum {
+       DIV4_SDH, DIV4_SD0,
+       DIV4_NR
+};
+
+static struct clk div4_clks[DIV4_NR] = {
+       [DIV4_SDH] = SH_CLK_DIV4(&pll1_clk, SDCKCR, 8, 0x0dff, CLK_ENABLE_ON_INIT),
+       [DIV4_SD0] = SH_CLK_DIV4(&pll1_clk, SDCKCR, 4, 0x1df0, CLK_ENABLE_ON_INIT),
+};
+
+/* DIV6 clocks */
+enum {
+       DIV6_SD1, DIV6_SD2,
+       DIV6_NR
+};
+
+static struct clk div6_clks[DIV6_NR] = {
+       [DIV6_SD1]      = SH_CLK_DIV6(&pll1_div2_clk, SD1CKCR, 0),
+       [DIV6_SD2]      = SH_CLK_DIV6(&pll1_div2_clk, SD2CKCR, 0),
 };
 
 /* MSTP */
 enum {
+       MSTP1108, MSTP1107, MSTP1106,
+       MSTP931, MSTP930, MSTP929, MSTP928, MSTP927, MSTP925,
+       MSTP917,
+       MSTP815, MSTP814,
        MSTP813,
+       MSTP811, MSTP810, MSTP809,
        MSTP726, MSTP724, MSTP723, MSTP721, MSTP720,
        MSTP719, MSTP718, MSTP715, MSTP714,
        MSTP522,
+       MSTP314, MSTP312, MSTP311,
        MSTP216, MSTP207, MSTP206,
-       MSTP204, MSTP203, MSTP202, MSTP1105, MSTP1106, MSTP1107,
+       MSTP204, MSTP203, MSTP202,
        MSTP124,
        MSTP_NR
 };
 
 static struct clk mstp_clks[MSTP_NR] = {
-       [MSTP813] = SH_CLK_MSTP32(&p_clk, SMSTPCR8, 13, 0), /* Ether */
-       [MSTP726] = SH_CLK_MSTP32(&zx_clk, SMSTPCR7, 26, 0), /* LVDS0 */
-       [MSTP724] = SH_CLK_MSTP32(&zx_clk, SMSTPCR7, 24, 0), /* DU0 */
-       [MSTP723] = SH_CLK_MSTP32(&zx_clk, SMSTPCR7, 23, 0), /* DU1 */
-       [MSTP721] = SH_CLK_MSTP32(&p_clk, SMSTPCR7, 21, 0), /* SCIF0 */
-       [MSTP720] = SH_CLK_MSTP32(&p_clk, SMSTPCR7, 20, 0), /* SCIF1 */
-       [MSTP719] = SH_CLK_MSTP32(&p_clk, SMSTPCR7, 19, 0), /* SCIF2 */
-       [MSTP718] = SH_CLK_MSTP32(&p_clk, SMSTPCR7, 18, 0), /* SCIF3 */
-       [MSTP715] = SH_CLK_MSTP32(&p_clk, SMSTPCR7, 15, 0), /* SCIF4 */
-       [MSTP714] = SH_CLK_MSTP32(&p_clk, SMSTPCR7, 14, 0), /* SCIF5 */
-       [MSTP522] = SH_CLK_MSTP32(&extal_clk, SMSTPCR5, 22, 0), /* Thermal */
-       [MSTP216] = SH_CLK_MSTP32(&mp_clk, SMSTPCR2, 16, 0), /* SCIFB2 */
-       [MSTP207] = SH_CLK_MSTP32(&mp_clk, SMSTPCR2, 7, 0), /* SCIFB1 */
-       [MSTP206] = SH_CLK_MSTP32(&mp_clk, SMSTPCR2, 6, 0), /* SCIFB0 */
-       [MSTP204] = SH_CLK_MSTP32(&mp_clk, SMSTPCR2, 4, 0), /* SCIFA0 */
-       [MSTP203] = SH_CLK_MSTP32(&mp_clk, SMSTPCR2, 3, 0), /* SCIFA1 */
-       [MSTP202] = SH_CLK_MSTP32(&mp_clk, SMSTPCR2, 2, 0), /* SCIFA2 */
-       [MSTP1105] = SH_CLK_MSTP32(&mp_clk, SMSTPCR11, 5, 0), /* SCIFA3 */
-       [MSTP1106] = SH_CLK_MSTP32(&mp_clk, SMSTPCR11, 6, 0), /* SCIFA4 */
-       [MSTP1107] = SH_CLK_MSTP32(&mp_clk, SMSTPCR11, 7, 0), /* SCIFA5 */
-       [MSTP124] = SH_CLK_MSTP32(&rclk_clk, SMSTPCR1, 24, 0), /* CMT0 */
+       [MSTP1108] = SH_CLK_MSTP32_STS(&mp_clk, SMSTPCR11, 8, MSTPSR11, 0), /* SCIFA5 */
+       [MSTP1107] = SH_CLK_MSTP32_STS(&mp_clk, SMSTPCR11, 7, MSTPSR11, 0), /* SCIFA4 */
+       [MSTP1106] = SH_CLK_MSTP32_STS(&mp_clk, SMSTPCR11, 6, MSTPSR11, 0), /* SCIFA3 */
+       [MSTP931] = SH_CLK_MSTP32_STS(&hp_clk, SMSTPCR9, 31, MSTPSR9, 0), /* I2C0 */
+       [MSTP930] = SH_CLK_MSTP32_STS(&hp_clk, SMSTPCR9, 30, MSTPSR9, 0), /* I2C1 */
+       [MSTP929] = SH_CLK_MSTP32_STS(&hp_clk, SMSTPCR9, 29, MSTPSR9, 0), /* I2C2 */
+       [MSTP928] = SH_CLK_MSTP32_STS(&hp_clk, SMSTPCR9, 28, MSTPSR9, 0), /* I2C3 */
+       [MSTP927] = SH_CLK_MSTP32_STS(&hp_clk, SMSTPCR9, 27, MSTPSR9, 0), /* I2C4 */
+       [MSTP925] = SH_CLK_MSTP32_STS(&hp_clk, SMSTPCR9, 25, MSTPSR9, 0), /* I2C5 */
+       [MSTP917] = SH_CLK_MSTP32_STS(&qspi_clk, SMSTPCR9, 17, MSTPSR9, 0), /* QSPI */
+       [MSTP815] = SH_CLK_MSTP32_STS(&zs_clk, SMSTPCR8, 15, MSTPSR8, 0), /* SATA0 */
+       [MSTP814] = SH_CLK_MSTP32_STS(&zs_clk, SMSTPCR8, 14, MSTPSR8, 0), /* SATA1 */
+       [MSTP813] = SH_CLK_MSTP32_STS(&p_clk, SMSTPCR8, 13, MSTPSR8, 0), /* Ether */
+       [MSTP811] = SH_CLK_MSTP32_STS(&zg_clk, SMSTPCR8, 11, MSTPSR8, 0), /* VIN0 */
+       [MSTP810] = SH_CLK_MSTP32_STS(&zg_clk, SMSTPCR8, 10, MSTPSR8, 0), /* VIN1 */
+       [MSTP809] = SH_CLK_MSTP32_STS(&zg_clk, SMSTPCR8, 9, MSTPSR8, 0), /* VIN2 */
+       [MSTP726] = SH_CLK_MSTP32_STS(&zx_clk, SMSTPCR7, 26, MSTPSR7, 0), /* LVDS0 */
+       [MSTP724] = SH_CLK_MSTP32_STS(&zx_clk, SMSTPCR7, 24, MSTPSR7, 0), /* DU0 */
+       [MSTP723] = SH_CLK_MSTP32_STS(&zx_clk, SMSTPCR7, 23, MSTPSR7, 0), /* DU1 */
+       [MSTP721] = SH_CLK_MSTP32_STS(&p_clk, SMSTPCR7, 21, MSTPSR7, 0), /* SCIF0 */
+       [MSTP720] = SH_CLK_MSTP32_STS(&p_clk, SMSTPCR7, 20, MSTPSR7, 0), /* SCIF1 */
+       [MSTP719] = SH_CLK_MSTP32_STS(&p_clk, SMSTPCR7, 19, MSTPSR7, 0), /* SCIF2 */
+       [MSTP718] = SH_CLK_MSTP32_STS(&p_clk, SMSTPCR7, 18, MSTPSR7, 0), /* SCIF3 */
+       [MSTP715] = SH_CLK_MSTP32_STS(&p_clk, SMSTPCR7, 15, MSTPSR7, 0), /* SCIF4 */
+       [MSTP714] = SH_CLK_MSTP32_STS(&p_clk, SMSTPCR7, 14, MSTPSR7, 0), /* SCIF5 */
+       [MSTP522] = SH_CLK_MSTP32_STS(&extal_clk, SMSTPCR5, 22, MSTPSR5, 0), /* Thermal */
+       [MSTP314] = SH_CLK_MSTP32_STS(&div4_clks[DIV4_SD0], SMSTPCR3, 14, MSTPSR3, 0), /* SDHI0 */
+       [MSTP312] = SH_CLK_MSTP32_STS(&div6_clks[DIV6_SD1], SMSTPCR3, 12, MSTPSR3, 0), /* SDHI1 */
+       [MSTP311] = SH_CLK_MSTP32_STS(&div6_clks[DIV6_SD2], SMSTPCR3, 11, MSTPSR3, 0), /* SDHI2 */
+       [MSTP216] = SH_CLK_MSTP32_STS(&mp_clk, SMSTPCR2, 16, MSTPSR2, 0), /* SCIFB2 */
+       [MSTP207] = SH_CLK_MSTP32_STS(&mp_clk, SMSTPCR2, 7, MSTPSR2, 0), /* SCIFB1 */
+       [MSTP206] = SH_CLK_MSTP32_STS(&mp_clk, SMSTPCR2, 6, MSTPSR2, 0), /* SCIFB0 */
+       [MSTP204] = SH_CLK_MSTP32_STS(&mp_clk, SMSTPCR2, 4, MSTPSR2, 0), /* SCIFA0 */
+       [MSTP203] = SH_CLK_MSTP32_STS(&mp_clk, SMSTPCR2, 3, MSTPSR2, 0), /* SCIFA1 */
+       [MSTP202] = SH_CLK_MSTP32_STS(&mp_clk, SMSTPCR2, 2, MSTPSR2, 0), /* SCIFA2 */
+       [MSTP124] = SH_CLK_MSTP32_STS(&rclk_clk, SMSTPCR1, 24, MSTPSR1, 0), /* CMT0 */
 };
 
 static struct clk_lookup lookups[] = {
@@ -165,8 +232,11 @@ static struct clk_lookup lookups[] = {
        CLKDEV_CON_ID("pll1",           &pll1_clk),
        CLKDEV_CON_ID("pll1_div2",      &pll1_div2_clk),
        CLKDEV_CON_ID("pll3",           &pll3_clk),
+       CLKDEV_CON_ID("zg",             &zg_clk),
+       CLKDEV_CON_ID("zs",             &zs_clk),
        CLKDEV_CON_ID("hp",             &hp_clk),
        CLKDEV_CON_ID("p",              &p_clk),
+       CLKDEV_CON_ID("qspi",           &qspi_clk),
        CLKDEV_CON_ID("rclk",           &rclk_clk),
        CLKDEV_CON_ID("mp",             &mp_clk),
        CLKDEV_CON_ID("cp",             &cp_clk),
@@ -188,13 +258,27 @@ static struct clk_lookup lookups[] = {
        CLKDEV_DEV_ID("sh-sci.9", &mstp_clks[MSTP718]), /* SCIF3 */
        CLKDEV_DEV_ID("sh-sci.10", &mstp_clks[MSTP715]), /* SCIF4 */
        CLKDEV_DEV_ID("sh-sci.11", &mstp_clks[MSTP714]), /* SCIF5 */
-       CLKDEV_DEV_ID("sh-sci.12", &mstp_clks[MSTP1105]), /* SCIFA3 */
-       CLKDEV_DEV_ID("sh-sci.13", &mstp_clks[MSTP1106]), /* SCIFA4 */
-       CLKDEV_DEV_ID("sh-sci.14", &mstp_clks[MSTP1107]), /* SCIFA5 */
-       CLKDEV_DEV_ID("sh_cmt.0", &mstp_clks[MSTP124]),
-       CLKDEV_DEV_ID("e61f0000.thermal", &mstp_clks[MSTP522]),
+       CLKDEV_DEV_ID("sh-sci.12", &mstp_clks[MSTP1106]), /* SCIFA3 */
+       CLKDEV_DEV_ID("sh-sci.13", &mstp_clks[MSTP1107]), /* SCIFA4 */
+       CLKDEV_DEV_ID("sh-sci.14", &mstp_clks[MSTP1108]), /* SCIFA5 */
+       CLKDEV_DEV_ID("sh_mobile_sdhi.0", &mstp_clks[MSTP314]),
+       CLKDEV_DEV_ID("sh_mobile_sdhi.1", &mstp_clks[MSTP312]),
+       CLKDEV_DEV_ID("sh_mobile_sdhi.2", &mstp_clks[MSTP311]),
+       CLKDEV_ICK_ID("fck", "sh-cmt-48-gen2.0", &mstp_clks[MSTP124]),
+       CLKDEV_DEV_ID("qspi.0", &mstp_clks[MSTP917]),
        CLKDEV_DEV_ID("rcar_thermal", &mstp_clks[MSTP522]),
+       CLKDEV_DEV_ID("i2c-rcar_gen2.0", &mstp_clks[MSTP931]),
+       CLKDEV_DEV_ID("i2c-rcar_gen2.1", &mstp_clks[MSTP930]),
+       CLKDEV_DEV_ID("i2c-rcar_gen2.2", &mstp_clks[MSTP929]),
+       CLKDEV_DEV_ID("i2c-rcar_gen2.3", &mstp_clks[MSTP928]),
+       CLKDEV_DEV_ID("i2c-rcar_gen2.4", &mstp_clks[MSTP927]),
+       CLKDEV_DEV_ID("i2c-rcar_gen2.5", &mstp_clks[MSTP925]),
        CLKDEV_DEV_ID("r8a7791-ether", &mstp_clks[MSTP813]), /* Ether */
+       CLKDEV_DEV_ID("r8a7791-vin.0", &mstp_clks[MSTP811]),
+       CLKDEV_DEV_ID("r8a7791-vin.1", &mstp_clks[MSTP810]),
+       CLKDEV_DEV_ID("r8a7791-vin.2", &mstp_clks[MSTP809]),
+       CLKDEV_DEV_ID("sata-r8a7791.0", &mstp_clks[MSTP815]),
+       CLKDEV_DEV_ID("sata-r8a7791.1", &mstp_clks[MSTP814]),
 };
 
 #define R8A7791_CLOCK_ROOT(e, m, p0, p1, p30, p31)             \
@@ -209,14 +293,9 @@ static struct clk_lookup lookups[] = {
 
 void __init r8a7791_clock_init(void)
 {
-       void __iomem *modemr = ioremap_nocache(MODEMR, PAGE_SIZE);
-       u32 mode;
+       u32 mode = rcar_gen2_read_mode_pins();
        int k, ret = 0;
 
-       BUG_ON(!modemr);
-       mode = ioread32(modemr);
-       iounmap(modemr);
-
        switch (mode & (MD(14) | MD(13))) {
        case 0:
                R8A7791_CLOCK_ROOT(15, &extal_clk, 172, 208, 106, 88);
@@ -232,10 +311,21 @@ void __init r8a7791_clock_init(void)
                break;
        }
 
+       if ((mode & (MD(3) | MD(2) | MD(1))) == MD(2))
+               SH_CLK_SET_RATIO(&qspi_clk_ratio, 1, 16);
+       else
+               SH_CLK_SET_RATIO(&qspi_clk_ratio, 1, 20);
+
        for (k = 0; !ret && (k < ARRAY_SIZE(main_clks)); k++)
                ret = clk_register(main_clks[k]);
 
        if (!ret)
+               ret = sh_clk_div4_register(div4_clks, DIV4_NR, &div4_table);
+
+       if (!ret)
+               ret = sh_clk_div6_register(div6_clks, DIV6_NR);
+
+       if (!ret)
                ret = sh_clk_mstp_register(mstp_clks, MSTP_NR);
 
        clkdev_add_table(lookups, ARRAY_SIZE(lookups));
index 2848997..7071676 100644 (file)
@@ -21,8 +21,8 @@
 #include <linux/io.h>
 #include <linux/sh_clk.h>
 #include <linux/clkdev.h>
-#include <mach/clock.h>
-#include <mach/common.h>
+#include "clock.h"
+#include "common.h"
 
 /* SH7372 registers */
 #define FRQCRA         IOMEM(0xe6150000)
@@ -515,8 +515,6 @@ static struct clk_lookup lookups[] = {
        CLKDEV_DEV_ID("uio_pdrv_genirq.1", &mstp_clks[MSTP128]), /* VEU0 */
        CLKDEV_DEV_ID("sh_mobile_ceu.0", &mstp_clks[MSTP127]), /* CEU */
        CLKDEV_DEV_ID("sh-mobile-csi2.0", &mstp_clks[MSTP126]), /* CSI2 */
-       CLKDEV_DEV_ID("sh_tmu.0", &mstp_clks[MSTP125]), /* TMU00 */
-       CLKDEV_DEV_ID("sh_tmu.1", &mstp_clks[MSTP125]), /* TMU01 */
        CLKDEV_DEV_ID("sh-mipi-dsi.0", &mstp_clks[MSTP118]), /* DSITX0 */
        CLKDEV_DEV_ID("sh_mobile_lcdc_fb.1", &mstp_clks[MSTP117]), /* LCDC1 */
        CLKDEV_DEV_ID("i2c-sh_mobile.0", &mstp_clks[MSTP116]), /* IIC0 */
@@ -565,10 +563,7 @@ static struct clk_lookup lookups[] = {
        CLKDEV_DEV_ID("r8a66597_hcd.1", &mstp_clks[MSTP406]), /* USB1 */
        CLKDEV_DEV_ID("r8a66597_udc.1", &mstp_clks[MSTP406]), /* USB1 */
        CLKDEV_DEV_ID("renesas_usbhs.1", &mstp_clks[MSTP406]), /* USB1 */
-       CLKDEV_DEV_ID("sh_cmt.4", &mstp_clks[MSTP405]), /* CMT4 */
-       CLKDEV_DEV_ID("sh_cmt.3", &mstp_clks[MSTP404]), /* CMT3 */
        CLKDEV_DEV_ID("sh_keysc.0", &mstp_clks[MSTP403]), /* KEYSC */
-       CLKDEV_DEV_ID("sh_cmt.2", &mstp_clks[MSTP400]), /* CMT2 */
 
        /* ICK */
        CLKDEV_ICK_ID("dsit_clk", "sh-mipi-dsi.0", &div6_clks[DIV6_DSIT]),
@@ -580,7 +575,11 @@ static struct clk_lookup lookups[] = {
        CLKDEV_ICK_ID("ick", "sh-mobile-hdmi", &div6_reparent_clks[DIV6_HDMI]),
        CLKDEV_ICK_ID("icka", "sh_fsi2", &div6_reparent_clks[DIV6_FSIA]),
        CLKDEV_ICK_ID("ickb", "sh_fsi2", &div6_reparent_clks[DIV6_FSIB]),
+       CLKDEV_ICK_ID("fck", "sh-tmu.0", &mstp_clks[MSTP125]), /* TMU0 */
        CLKDEV_ICK_ID("spu2", "sh_fsi2", &mstp_clks[MSTP223]),
+       CLKDEV_ICK_ID("fck", "sh-cmt-32-fast.4", &mstp_clks[MSTP405]), /* CMT4 */
+       CLKDEV_ICK_ID("fck", "sh-cmt-32-fast.3", &mstp_clks[MSTP404]), /* CMT3 */
+       CLKDEV_ICK_ID("fck", "sh-cmt-32-fast.2", &mstp_clks[MSTP400]), /* CMT2 */
        CLKDEV_ICK_ID("diva", "sh_fsi2", &fsidivs[FSIDIV_A]),
        CLKDEV_ICK_ID("divb", "sh_fsi2", &fsidivs[FSIDIV_B]),
        CLKDEV_ICK_ID("xcka", "sh_fsi2", &fsiack_clk),
index 23edf83..02a6f45 100644 (file)
@@ -22,8 +22,8 @@
 #include <linux/sh_clk.h>
 #include <linux/clkdev.h>
 #include <asm/processor.h>
-#include <mach/clock.h>
-#include <mach/common.h>
+#include "clock.h"
+#include "common.h"
 
 #define FRQCRA         IOMEM(0xe6150000)
 #define FRQCRB         IOMEM(0xe6150004)
@@ -633,24 +633,30 @@ static struct clk_lookup lookups[] = {
        CLKDEV_DEV_ID("sh-mobile-csi2.1", &mstp_clks[MSTP128]), /* CSI2-RX1 */
        CLKDEV_DEV_ID("sh_mobile_ceu.0", &mstp_clks[MSTP127]), /* CEU0 */
        CLKDEV_DEV_ID("sh-mobile-csi2.0", &mstp_clks[MSTP126]), /* CSI2-RX0 */
-       CLKDEV_DEV_ID("sh_tmu.0", &mstp_clks[MSTP125]), /* TMU00 */
-       CLKDEV_DEV_ID("sh_tmu.1", &mstp_clks[MSTP125]), /* TMU01 */
        CLKDEV_DEV_ID("sh-mipi-dsi.0", &mstp_clks[MSTP118]), /* DSITX */
        CLKDEV_DEV_ID("i2c-sh_mobile.0", &mstp_clks[MSTP116]), /* I2C0 */
        CLKDEV_DEV_ID("e6820000.i2c", &mstp_clks[MSTP116]), /* I2C0 */
        CLKDEV_DEV_ID("sh_mobile_lcdc_fb.0", &mstp_clks[MSTP100]), /* LCDC0 */
        CLKDEV_DEV_ID("sh-sci.7", &mstp_clks[MSTP219]), /* SCIFA7 */
+       CLKDEV_DEV_ID("e6cd0000.serial", &mstp_clks[MSTP219]), /* SCIFA7 */
        CLKDEV_DEV_ID("sh-dma-engine.0", &mstp_clks[MSTP218]), /* SY-DMAC */
        CLKDEV_DEV_ID("sh-dma-engine.1", &mstp_clks[MSTP217]), /* MP-DMAC */
        CLKDEV_DEV_ID("sh-sci.5", &mstp_clks[MSTP207]), /* SCIFA5 */
+       CLKDEV_DEV_ID("e6cb0000.serial", &mstp_clks[MSTP207]), /* SCIFA5 */
        CLKDEV_DEV_ID("sh-sci.8", &mstp_clks[MSTP206]), /* SCIFB */
+       CLKDEV_DEV_ID("e6c3000.serial", &mstp_clks[MSTP206]), /* SCIFB */
        CLKDEV_DEV_ID("sh-sci.0", &mstp_clks[MSTP204]), /* SCIFA0 */
+       CLKDEV_DEV_ID("e6c40000.serial", &mstp_clks[MSTP204]), /* SCIFA0 */
        CLKDEV_DEV_ID("sh-sci.1", &mstp_clks[MSTP203]), /* SCIFA1 */
+       CLKDEV_DEV_ID("e6c50000.serial", &mstp_clks[MSTP203]), /* SCIFA1 */
        CLKDEV_DEV_ID("sh-sci.2", &mstp_clks[MSTP202]), /* SCIFA2 */
+       CLKDEV_DEV_ID("e6c60000.serial", &mstp_clks[MSTP202]), /* SCIFA2 */
        CLKDEV_DEV_ID("sh-sci.3", &mstp_clks[MSTP201]), /* SCIFA3 */
+       CLKDEV_DEV_ID("e6c70000.serial", &mstp_clks[MSTP201]), /* SCIFA3 */
        CLKDEV_DEV_ID("sh-sci.4", &mstp_clks[MSTP200]), /* SCIFA4 */
+       CLKDEV_DEV_ID("e6c80000.serial", &mstp_clks[MSTP200]), /* SCIFA4 */
        CLKDEV_DEV_ID("sh-sci.6", &mstp_clks[MSTP331]), /* SCIFA6 */
-       CLKDEV_DEV_ID("sh_cmt.10", &mstp_clks[MSTP329]), /* CMT10 */
+       CLKDEV_DEV_ID("e6cc0000.serial", &mstp_clks[MSTP331]), /* SCIFA6 */
        CLKDEV_DEV_ID("sh_fsi2", &mstp_clks[MSTP328]), /* FSI */
        CLKDEV_DEV_ID("ec230000.sound", &mstp_clks[MSTP328]), /* FSI */
        CLKDEV_DEV_ID("sh_irda.0", &mstp_clks[MSTP325]), /* IrDA */
@@ -683,6 +689,9 @@ static struct clk_lookup lookups[] = {
        CLKDEV_ICK_ID("dsip_clk", "sh-mipi-dsi.1", &div6_clks[DIV6_DSI1P]),
        CLKDEV_ICK_ID("dsiphy_clk", "sh-mipi-dsi.0", &dsi0phy_clk),
        CLKDEV_ICK_ID("dsiphy_clk", "sh-mipi-dsi.1", &dsi1phy_clk),
+       CLKDEV_ICK_ID("fck", "sh-cmt-48.1", &mstp_clks[MSTP329]), /* CMT1 */
+       CLKDEV_ICK_ID("fck", "e6138000.timer", &mstp_clks[MSTP329]), /* CMT1 */
+       CLKDEV_ICK_ID("fck", "sh-tmu.0", &mstp_clks[MSTP125]), /* TMU0 */
 };
 
 void __init sh73a0_clock_init(void)
index ad7df62..806f940 100644 (file)
  */
 #include <linux/kernel.h>
 #include <linux/init.h>
+
+#ifdef CONFIG_COMMON_CLK
+#include <linux/clk.h>
+#include <linux/clkdev.h>
+#include "clock.h"
+
+void __init shmobile_clk_workaround(const struct clk_name *clks,
+                                   int nr_clks, bool enable)
+{
+       const struct clk_name *clkn;
+       struct clk *clk;
+       unsigned int i;
+
+       for (i = 0; i < nr_clks; ++i) {
+               clkn = clks + i;
+               clk = clk_get(NULL, clkn->clk);
+               if (!IS_ERR(clk)) {
+                       clk_register_clkdev(clk, clkn->con_id, clkn->dev_id);
+                       if (enable)
+                               clk_prepare_enable(clk);
+                       clk_put(clk);
+               }
+       }
+}
+
+#else /* CONFIG_COMMON_CLK */
 #include <linux/sh_clk.h>
 #include <linux/export.h>
-#include <mach/clock.h>
-#include <mach/common.h>
+#include "clock.h"
+#include "common.h"
 
 unsigned long shmobile_fixed_ratio_clk_recalc(struct clk *clk)
 {
@@ -58,3 +84,5 @@ void __clk_put(struct clk *clk)
 {
 }
 EXPORT_SYMBOL(__clk_put);
+
+#endif /* CONFIG_COMMON_CLK */
similarity index 67%
rename from arch/arm/mach-shmobile/include/mach/clock.h
rename to arch/arm/mach-shmobile/clock.h
index 03e5607..31b6417 100644 (file)
@@ -1,6 +1,22 @@
 #ifndef CLOCK_H
 #define CLOCK_H
 
+#ifdef CONFIG_COMMON_CLK
+/* temporary clock configuration helper for platform devices */
+
+struct clk_name {
+       const char *clk;
+       const char *con_id;
+       const char *dev_id;
+};
+
+void shmobile_clk_workaround(const struct clk_name *clks, int nr_clks,
+                            bool enable);
+
+#else /* CONFIG_COMMON_CLK */
+/* legacy clock implementation */
+
+struct clk;
 unsigned long shmobile_fixed_ratio_clk_recalc(struct clk *clk);
 extern struct sh_clk_ops shmobile_fixed_ratio_clk_ops;
 
@@ -36,4 +52,5 @@ do {                  \
        (p)->div = d;   \
 } while (0)
 
+#endif /* CONFIG_COMMON_CLK */
 #endif
similarity index 85%
rename from arch/arm/mach-shmobile/include/mach/common.h
rename to arch/arm/mach-shmobile/common.h
index e319805..72087c7 100644 (file)
@@ -2,8 +2,7 @@
 #define __ARCH_MACH_COMMON_H
 
 extern void shmobile_earlytimer_init(void);
-extern void shmobile_setup_delay(unsigned int max_cpu_core_mhz,
-                        unsigned int mult, unsigned int div);
+extern void shmobile_init_delay(void);
 struct twd_local_timer;
 extern void shmobile_setup_console(void);
 extern void shmobile_boot_vector(void);
@@ -25,7 +24,6 @@ extern int shmobile_smp_apmu_boot_secondary(unsigned int cpu,
                                            struct task_struct *idle);
 extern void shmobile_smp_apmu_cpu_die(unsigned int cpu);
 extern int shmobile_smp_apmu_cpu_kill(unsigned int cpu);
-extern void shmobile_invalidate_start(void);
 struct clk;
 extern int shmobile_clk_init(void);
 extern void shmobile_handle_irq_intc(struct pt_regs *);
@@ -35,8 +33,10 @@ extern void shmobile_cpuidle_set_driver(struct cpuidle_driver *drv);
 
 #ifdef CONFIG_SUSPEND
 int shmobile_suspend_init(void);
+void shmobile_smp_apmu_suspend_init(void);
 #else
 static inline int shmobile_suspend_init(void) { return 0; }
+static inline void shmobile_smp_apmu_suspend_init(void) { }
 #endif
 
 #ifdef CONFIG_CPU_IDLE
@@ -45,12 +45,19 @@ int shmobile_cpuidle_init(void);
 static inline int shmobile_cpuidle_init(void) { return 0; }
 #endif
 
+#ifdef CONFIG_CPU_FREQ
+int shmobile_cpufreq_init(void);
+#else
+static inline int shmobile_cpufreq_init(void) { return 0; }
+#endif
+
 extern void __iomem *shmobile_scu_base;
 
 static inline void __init shmobile_init_late(void)
 {
        shmobile_suspend_init();
        shmobile_cpuidle_init();
+       shmobile_cpufreq_init();
 }
 
 #endif /* __ARCH_MACH_COMMON_H */
index 9411a5b..f2e79f2 100644 (file)
@@ -19,8 +19,8 @@
 #include <linux/kernel.h>
 #include <linux/init.h>
 #include <linux/platform_device.h>
-#include <mach/common.h>
 #include <asm/mach/map.h>
+#include "common.h"
 
 void __init shmobile_setup_console(void)
 {
diff --git a/arch/arm/mach-shmobile/cpufreq.c b/arch/arm/mach-shmobile/cpufreq.c
new file mode 100644 (file)
index 0000000..8a24b2b
--- /dev/null
@@ -0,0 +1,17 @@
+/*
+ * CPUFreq support code for SH-Mobile ARM
+ *
+ *  Copyright (C) 2014 Gaku Inami
+ *
+ * This file is subject to the terms and conditions of the GNU General Public
+ * License.  See the file "COPYING" in the main directory of this archive
+ * for more details.
+ */
+
+#include <linux/platform_device.h>
+
+int __init shmobile_cpufreq_init(void)
+{
+       platform_device_register_simple("cpufreq-cpu0", -1, NULL, 0);
+       return 0;
+}
similarity index 92%
rename from arch/arm/mach-shmobile/include/mach/dma-register.h
rename to arch/arm/mach-shmobile/dma-register.h
index 97c40bd..52a2f66 100644 (file)
@@ -52,8 +52,8 @@ static const unsigned int dma_ts_shift[] = {
        ((((i) & TS_LOW_BIT) << TS_LOW_SHIFT) |\
         (((i) & TS_HI_BIT)  << TS_HI_SHIFT))
 
-#define CHCR_TX(xmit_sz) (DM_FIX | SM_INC | 0x800 | TS_INDEX2VAL((xmit_sz)))
-#define CHCR_RX(xmit_sz) (DM_INC | SM_FIX | 0x800 | TS_INDEX2VAL((xmit_sz)))
+#define CHCR_TX(xmit_sz) (DM_FIX | SM_INC | RS_ERS | TS_INDEX2VAL((xmit_sz)))
+#define CHCR_RX(xmit_sz) (DM_INC | SM_FIX | RS_ERS | TS_INDEX2VAL((xmit_sz)))
 
 
 /*
index e5be5c8..faf8214 100644 (file)
  * it under the terms of the GNU General Public License version 2 as
  * published by the Free Software Foundation.
  */
-#include <linux/linkage.h>
 #include <linux/init.h>
+#include <linux/linkage.h>
+#include <linux/threads.h>
 #include <asm/memory.h>
 
+#ifdef CONFIG_SMP
 ENTRY(shmobile_invalidate_start)
        bl      v7_invalidate_l1
        b       secondary_startup
 ENDPROC(shmobile_invalidate_start)
+#endif
 
 /*
  * Reset vector for secondary CPUs.
@@ -68,7 +71,7 @@ shmobile_smp_boot_find_mpidr:
 
 shmobile_smp_boot_next:
        add     r1, r1, #1
-       cmp     r1, #CONFIG_NR_CPUS
+       cmp     r1, #NR_CPUS
        blo     shmobile_smp_boot_find_mpidr
 
        b       shmobile_smp_sleep
@@ -85,10 +88,10 @@ ENDPROC(shmobile_smp_sleep)
 
        .globl  shmobile_smp_mpidr
 shmobile_smp_mpidr:
-1:     .space  CONFIG_NR_CPUS * 4
+1:     .space  NR_CPUS * 4
        .globl  shmobile_smp_fn
 shmobile_smp_fn:
-2:     .space  CONFIG_NR_CPUS * 4
+2:     .space  NR_CPUS * 4
        .globl  shmobile_smp_arg
 shmobile_smp_arg:
-3:     .space  CONFIG_NR_CPUS * 4
+3:     .space  NR_CPUS * 4
diff --git a/arch/arm/mach-shmobile/include/mach/emev2.h b/arch/arm/mach-shmobile/include/mach/emev2.h
deleted file mode 100644 (file)
index fcb142a..0000000
+++ /dev/null
@@ -1,9 +0,0 @@
-#ifndef __ASM_EMEV2_H__
-#define __ASM_EMEV2_H__
-
-extern void emev2_map_io(void);
-extern void emev2_init_delay(void);
-extern void emev2_clock_init(void);
-extern struct smp_operations emev2_smp_ops;
-
-#endif /* __ASM_EMEV2_H__ */
diff --git a/arch/arm/mach-shmobile/include/mach/head-kzm9g.txt b/arch/arm/mach-shmobile/include/mach/head-kzm9g.txt
new file mode 100644 (file)
index 0000000..9531f46
--- /dev/null
@@ -0,0 +1,410 @@
+LIST "KZM9G low-level initialization routine."
+LIST "Adapted from u-boot KZM9G support code."
+
+LIST "Copyright (C) 2013 Ulrich Hecht"
+
+LIST "This program is free software; you can redistribute it and/or modify"
+LIST "it under the terms of the GNU General Public License version 2 as"
+LIST "published by the Free Software Foundation."
+
+LIST "This program is distributed in the hope that it will be useful,"
+LIST "but WITHOUT ANY WARRANTY; without even the implied warranty of"
+LIST "MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the"
+LIST "GNU General Public License for more details."
+
+
+LIST "Register definitions:"
+
+LIST "Secure control register"
+#define LIFEC_SEC_SRC (0xE6110008)
+
+LIST "RWDT"
+#define RWDT_BASE   (0xE6020000)
+#define RWTCSRA0 (RWDT_BASE + 0x04)
+
+LIST "HPB Semaphore Control Registers"
+#define HPBSCR_BASE (0xE6000000)
+#define HPBCTRL6 (HPBSCR_BASE + 0x1030)
+
+#define SBSC1_BASE  (0xFE400000)
+#define SDCR0A         (SBSC1_BASE + 0x0008)
+#define SDCR1A         (SBSC1_BASE + 0x000C)
+#define SDPCRA         (SBSC1_BASE + 0x0010)
+#define SDCR0SA                (SBSC1_BASE + 0x0018)
+#define SDCR1SA                (SBSC1_BASE + 0x001C)
+#define RTCSRA         (SBSC1_BASE + 0x0020)
+#define RTCORA         (SBSC1_BASE + 0x0028)
+#define RTCORHA                (SBSC1_BASE + 0x002C)
+#define SDWCRC0A       (SBSC1_BASE + 0x0040)
+#define SDWCRC1A       (SBSC1_BASE + 0x0044)
+#define SDWCR00A       (SBSC1_BASE + 0x0048)
+#define SDWCR01A       (SBSC1_BASE + 0x004C)
+#define SDWCR10A       (SBSC1_BASE + 0x0050)
+#define SDWCR11A       (SBSC1_BASE + 0x0054)
+#define SDWCR2A                (SBSC1_BASE + 0x0060)
+#define SDWCRC2A       (SBSC1_BASE + 0x0064)
+#define ZQCCRA         (SBSC1_BASE + 0x0068)
+#define SDMRACR0A      (SBSC1_BASE + 0x0084)
+#define SDMRTMPCRA     (SBSC1_BASE + 0x008C)
+#define SDMRTMPMSKA    (SBSC1_BASE + 0x0094)
+#define SDGENCNTA      (SBSC1_BASE + 0x009C)
+#define SDDRVCR0A      (SBSC1_BASE + 0x00B4)
+#define DLLCNT0A       (SBSC1_BASE + 0x0354)
+
+#define SDMRA1  (0xFE500000)
+#define SDMRA2  (0xFE5C0000)
+#define SDMRA3  (0xFE504000)
+
+#define SBSC2_BASE  (0xFB400000)
+#define SDCR0B         (SBSC2_BASE + 0x0008)
+#define SDCR1B         (SBSC2_BASE + 0x000C)
+#define SDPCRB         (SBSC2_BASE + 0x0010)
+#define SDCR0SB                (SBSC2_BASE + 0x0018)
+#define SDCR1SB                (SBSC2_BASE + 0x001C)
+#define RTCSRB         (SBSC2_BASE + 0x0020)
+#define RTCORB         (SBSC2_BASE + 0x0028)
+#define RTCORHB                (SBSC2_BASE + 0x002C)
+#define SDWCRC0B       (SBSC2_BASE + 0x0040)
+#define SDWCRC1B       (SBSC2_BASE + 0x0044)
+#define SDWCR00B       (SBSC2_BASE + 0x0048)
+#define SDWCR01B       (SBSC2_BASE + 0x004C)
+#define SDWCR10B       (SBSC2_BASE + 0x0050)
+#define SDWCR11B       (SBSC2_BASE + 0x0054)
+#define SDPDCR0B       (SBSC2_BASE + 0x0058)
+#define SDWCR2B                (SBSC2_BASE + 0x0060)
+#define SDWCRC2B       (SBSC2_BASE + 0x0064)
+#define ZQCCRB         (SBSC2_BASE + 0x0068)
+#define SDMRACR0B      (SBSC2_BASE + 0x0084)
+#define SDMRTMPCRB     (SBSC2_BASE + 0x008C)
+#define SDMRTMPMSKB    (SBSC2_BASE + 0x0094)
+#define SDGENCNTB      (SBSC2_BASE + 0x009C)
+#define DPHYCNT0B      (SBSC2_BASE + 0x00A0)
+#define DPHYCNT1B      (SBSC2_BASE + 0x00A4)
+#define DPHYCNT2B      (SBSC2_BASE + 0x00A8)
+#define SDDRVCR0B      (SBSC2_BASE + 0x00B4)
+#define DLLCNT0B       (SBSC2_BASE + 0x0354)
+
+#define SDMRB1  (0xFB500000)
+#define SDMRB2  (0xFB5C0000)
+#define SDMRB3  (0xFB504000)
+
+#define CPG_BASE   (0xE6150000)
+#define FRQCRA         (CPG_BASE + 0x0000)
+#define FRQCRB         (CPG_BASE + 0x0004)
+#define FRQCRD         (CPG_BASE + 0x00E4)
+#define VCLKCR1                (CPG_BASE + 0x0008)
+#define VCLKCR2                (CPG_BASE + 0x000C)
+#define VCLKCR3                (CPG_BASE + 0x001C)
+#define ZBCKCR         (CPG_BASE + 0x0010)
+#define FLCKCR         (CPG_BASE + 0x0014)
+#define SD0CKCR                (CPG_BASE + 0x0074)
+#define SD1CKCR                (CPG_BASE + 0x0078)
+#define SD2CKCR                (CPG_BASE + 0x007C)
+#define FSIACKCR       (CPG_BASE + 0x0018)
+#define SUBCKCR                (CPG_BASE + 0x0080)
+#define SPUACKCR       (CPG_BASE + 0x0084)
+#define SPUVCKCR       (CPG_BASE + 0x0094)
+#define MSUCKCR                (CPG_BASE + 0x0088)
+#define HSICKCR                (CPG_BASE + 0x008C)
+#define FSIBCKCR       (CPG_BASE + 0x0090)
+#define MFCK1CR                (CPG_BASE + 0x0098)
+#define MFCK2CR                (CPG_BASE + 0x009C)
+#define DSITCKCR       (CPG_BASE + 0x0060)
+#define DSI0PCKCR      (CPG_BASE + 0x0064)
+#define DSI1PCKCR      (CPG_BASE + 0x0068)
+#define DSI0PHYCR      (CPG_BASE + 0x006C)
+#define DVFSCR3                (CPG_BASE + 0x0174)
+#define DVFSCR4                (CPG_BASE + 0x0178)
+#define DVFSCR5                (CPG_BASE + 0x017C)
+#define MPMODE         (CPG_BASE + 0x00CC)
+
+#define PLLECR         (CPG_BASE + 0x00D0)
+#define PLL0CR         (CPG_BASE + 0x00D8)
+#define PLL1CR         (CPG_BASE + 0x0028)
+#define PLL2CR         (CPG_BASE + 0x002C)
+#define PLL3CR         (CPG_BASE + 0x00DC)
+#define PLL0STPCR      (CPG_BASE + 0x00F0)
+#define PLL1STPCR      (CPG_BASE + 0x00C8)
+#define PLL2STPCR      (CPG_BASE + 0x00F8)
+#define PLL3STPCR      (CPG_BASE + 0x00FC)
+#define RMSTPCR0       (CPG_BASE + 0x0110)
+#define RMSTPCR1       (CPG_BASE + 0x0114)
+#define RMSTPCR2       (CPG_BASE + 0x0118)
+#define RMSTPCR3       (CPG_BASE + 0x011C)
+#define RMSTPCR4       (CPG_BASE + 0x0120)
+#define RMSTPCR5       (CPG_BASE + 0x0124)
+#define SMSTPCR0       (CPG_BASE + 0x0130)
+#define SMSTPCR2       (CPG_BASE + 0x0138)
+#define SMSTPCR3       (CPG_BASE + 0x013C)
+#define CPGXXCR4       (CPG_BASE + 0x0150)
+#define SRCR0          (CPG_BASE + 0x80A0)
+#define SRCR2          (CPG_BASE + 0x80B0)
+#define SRCR3          (CPG_BASE + 0x80A8)
+#define VREFCR         (CPG_BASE + 0x00EC)
+#define PCLKCR         (CPG_BASE + 0x1020)
+
+#define PORT32CR (0xE6051020)
+#define PORT33CR (0xE6051021)
+#define PORT34CR (0xE6051022)
+#define PORT35CR (0xE6051023)
+
+LIST "DRAM initialization code:"
+
+EW RWTCSRA0, 0xA507
+
+ED_AND LIFEC_SEC_SRC, 0xFFFF7FFF
+
+ED_AND SMSTPCR3,0xFFFF7FFF
+ED_AND SRCR3, 0xFFFF7FFF
+ED_AND SMSTPCR2,0xFFFBFFFF
+ED_AND SRCR2, 0xFFFBFFFF
+ED PLLECR, 0x00000000
+
+WAIT_MASK PLLECR, 0x00000F00, 0x00000000
+WAIT_MASK FRQCRB, 0x80000000, 0x00000000
+
+ED PLL0CR, 0x2D000000
+ED PLL1CR, 0x17100000
+ED FRQCRB, 0x96235880
+WAIT_MASK FRQCRB, 0x80000000, 0x00000000
+
+ED FLCKCR, 0x0000000B
+ED_AND SMSTPCR0, 0xFFFFFFFD
+
+ED_AND SRCR0, 0xFFFFFFFD
+ED 0xE6001628, 0x514
+ED 0xE6001648, 0x514
+ED 0xE6001658, 0x514
+ED 0xE6001678, 0x514
+
+ED DVFSCR4, 0x00092000
+ED DVFSCR5, 0x000000DC
+ED PLLECR, 0x00000000
+WAIT_MASK PLLECR, 0x00000F00, 0x00000000
+
+ED FRQCRA, 0x0012453C
+ED FRQCRB, 0x80431350
+WAIT_MASK FRQCRB, 0x80000000, 0x00000000
+ED FRQCRD, 0x00000B0B
+WAIT_MASK FRQCRD, 0x80000000, 0x00000000
+
+ED PCLKCR, 0x00000003
+ED VCLKCR1, 0x0000012F
+ED VCLKCR2, 0x00000119
+ED VCLKCR3, 0x00000119
+ED ZBCKCR, 0x00000002
+ED FLCKCR, 0x00000005
+ED SD0CKCR, 0x00000080
+ED SD1CKCR, 0x00000080
+ED SD2CKCR, 0x00000080
+ED FSIACKCR, 0x0000003F
+ED FSIBCKCR, 0x0000003F
+ED SUBCKCR, 0x00000080
+ED SPUACKCR, 0x0000000B
+ED SPUVCKCR, 0x0000000B
+ED MSUCKCR, 0x0000013F
+ED HSICKCR, 0x00000080
+ED MFCK1CR, 0x0000003F
+ED MFCK2CR, 0x0000003F
+ED DSITCKCR, 0x00000107
+ED DSI0PCKCR, 0x00000313
+ED DSI1PCKCR, 0x0000130D
+ED DSI0PHYCR, 0x2A800E0E
+ED PLL0CR, 0x1E000000
+ED PLL0CR, 0x2D000000
+ED PLL1CR, 0x17100000
+ED PLL2CR, 0x27000080
+ED PLL3CR, 0x1D000000
+ED PLL0STPCR, 0x00080000
+ED PLL1STPCR, 0x000120C0
+ED PLL2STPCR, 0x00012000
+ED PLL3STPCR, 0x00000030
+ED PLLECR, 0x0000000B
+WAIT_MASK PLLECR, 0x00000B00, 0x00000B00
+
+ED DVFSCR3, 0x000120F0
+ED MPMODE, 0x00000020
+ED VREFCR, 0x0000028A
+ED RMSTPCR0, 0xE4628087
+ED RMSTPCR1, 0xFFFFFFFF
+ED RMSTPCR2, 0x53FFFFFF
+ED RMSTPCR3, 0xFFFFFFFF
+ED RMSTPCR4, 0x00800D3D
+ED RMSTPCR5, 0xFFFFF3FF
+ED SMSTPCR2, 0x00000000
+ED SRCR2,  0x00040000
+ED_AND PLLECR, 0xFFFFFFF7
+WAIT_MASK PLLECR, 0x00000800, 0x00000000
+
+LIST "set SBSC operational"
+ED HPBCTRL6, 0x00000001
+WAIT_MASK HPBCTRL6, 0x00000001, 0x00000001
+
+LIST "set SBSC operating frequency"
+ED FRQCRD, 0x00001414
+WAIT_MASK FRQCRD, 0x80000000, 0x00000000
+ED PLL3CR, 0x1D000000
+ED_OR PLLECR, 0x00000008
+WAIT_MASK PLLECR, 0x00000800, 0x00000800
+
+LIST "enable DLL oscillation in DDRPHY"
+ED_OR DLLCNT0A, 0x00000002
+
+LIST "wait >= 100 ns"
+ED SDGENCNTA, 0x00000005
+WAIT_MASK SDGENCNTA, 0xFFFFFFFF, 0x00000000
+
+LIST "target LPDDR2 device settings"
+ED SDCR0A, 0xACC90159
+ED SDCR1A, 0x00010059
+ED SDWCRC0A, 0x50874114
+ED SDWCRC1A, 0x33199B37
+ED SDWCRC2A, 0x008F2313
+ED SDWCR00A, 0x31020707
+ED SDWCR01A, 0x0017040A
+ED SDWCR10A, 0x31020707
+ED SDWCR11A, 0x0017040A
+
+ED SDDRVCR0A, 0x055557ff
+
+ED SDWCR2A, 0x30000000
+
+LIST "drive CKE high"
+ED_OR SDPCRA, 0x00000080
+WAIT_MASK SDPCRA, 0x00000080, 0x00000080
+
+LIST "wait >= 200 us"
+ED SDGENCNTA, 0x00002710
+WAIT_MASK SDGENCNTA, 0xFFFFFFFF, 0x00000000
+
+LIST "issue reset command to LPDDR2 device"
+ED SDMRACR0A, 0x0000003F
+ED SDMRA1, 0x00000000
+
+LIST "wait >= 10 (or 1) us (docs inconsistent)"
+ED SDGENCNTA, 0x000001F4
+WAIT_MASK SDGENCNTA, 0xFFFFFFFF, 0x00000000
+
+LIST "MRW ZS initialization calibration command"
+ED SDMRACR0A, 0x0000FF0A
+ED SDMRA3, 0x00000000
+
+LIST "wait >= 1 us"
+ED SDGENCNTA, 0x00000032
+WAIT_MASK SDGENCNTA, 0xFFFFFFFF, 0x00000000
+
+LIST "specify operating mode in LPDDR2"
+ED SDMRACR0A, 0x00002201
+ED SDMRA1, 0x00000000
+ED SDMRACR0A, 0x00000402
+ED SDMRA1, 0x00000000
+ED SDMRACR0A, 0x00000203
+ED SDMRA1, 0x00000000
+
+LIST "initialize DDR interface"
+ED SDMRA2, 0x00000000
+
+LIST "temperature sensor control"
+ED SDMRTMPCRA, 0x88800004
+ED SDMRTMPMSKA,0x00000004
+
+LIST "auto-refreshing control"
+ED RTCORA, 0xA55A0032
+ED RTCORHA, 0xA55A000C
+ED RTCSRA, 0xA55A2048
+
+ED_OR SDCR0A, 0x00000800
+ED_OR SDCR1A, 0x00000400
+
+LIST "auto ZQ calibration control"
+ED ZQCCRA, 0xFFF20000
+
+ED_OR DLLCNT0B, 0x00000002
+ED SDGENCNTB, 0x00000005
+WAIT_MASK SDGENCNTB, 0xFFFFFFFF, 0x00000000
+
+ED SDCR0B, 0xACC90159
+ED SDCR1B, 0x00010059
+ED SDWCRC0B, 0x50874114
+ED SDWCRC1B, 0x33199B37
+ED SDWCRC2B, 0x008F2313
+ED SDWCR00B, 0x31020707
+ED SDWCR01B, 0x0017040A
+ED SDWCR10B, 0x31020707
+ED SDWCR11B, 0x0017040A
+ED SDDRVCR0B, 0x055557ff
+ED SDWCR2B, 0x30000000
+ED_OR SDPCRB, 0x00000080
+WAIT_MASK SDPCRB, 0x00000080, 0x00000080
+
+ED SDGENCNTB, 0x00002710
+WAIT_MASK SDGENCNTB, 0xFFFFFFFF, 0x00000000
+ED SDMRACR0B, 0x0000003F
+
+LIST "upstream u-boot writes to SDMRA1A for both SBSC 1 and 2, which does"
+LIST "not seem to make a lot of sense..."
+ED SDMRB1, 0x00000000
+
+ED SDGENCNTB, 0x000001F4
+WAIT_MASK SDGENCNTB, 0xFFFFFFFF, 0x00000000
+
+ED SDMRACR0B, 0x0000FF0A
+ED SDMRB3, 0x00000000
+ED SDGENCNTB, 0x00000032
+WAIT_MASK SDGENCNTB, 0xFFFFFFFF, 0x00000000
+
+ED SDMRACR0B, 0x00002201
+ED SDMRB1, 0x00000000
+ED SDMRACR0B, 0x00000402
+ED SDMRB1, 0x00000000
+ED SDMRACR0B, 0x00000203
+ED SDMRB1, 0x00000000
+ED SDMRB2, 0x00000000
+ED SDMRTMPCRB, 0x88800004
+ED SDMRTMPMSKB, 0x00000004
+ED RTCORB,  0xA55A0032
+ED RTCORHB, 0xA55A000C
+ED RTCSRB,  0xA55A2048
+ED_OR SDCR0B, 0x00000800
+ED_OR SDCR1B, 0x00000400
+ED ZQCCRB, 0xFFF20000
+ED_OR SDPDCR0B, 0x00030000
+ED DPHYCNT1B, 0xA5390000
+ED DPHYCNT0B, 0x00001200
+ED DPHYCNT1B, 0x07CE0000
+ED DPHYCNT0B, 0x00001247
+WAIT_MASK DPHYCNT2B, 0xFFFFFFFF, 0x07CE0000
+
+ED_AND SDPDCR0B, 0xFFFCFFFF
+
+ED FRQCRD, 0x00000B0B
+WAIT_MASK FRQCRD, 0x80000000, 0x00000000
+
+ED CPGXXCR4, 0xfffffffc
+
+LIST "Setup SCIF4 / workaround"
+EB PORT32CR, 0x12
+EB PORT33CR, 0x22
+EB PORT34CR, 0x12
+EB PORT35CR, 0x22
+
+EW 0xE6C80000, 0
+EB 0xE6C80004, 0x19
+EW 0xE6C80008, 0x0030
+EW 0xE6C80018, 0
+EW 0xE6C80030, 0x0014
+
+LIST "Magic to avoid hangs and corruption on DRAM writes."
+
+LIST "It has been observed that the system would most often hang while"
+LIST "decompressing the kernel, and if it didn't it would always write"
+LIST "a corrupt image to DRAM."
+LIST "This problem does not occur in u-boot, and the reason is that"
+LIST "u-boot performs an additional cache invalidation after setting up"
+LIST "the DRAM controller. Such an invalidation should not be necessary at"
+LIST "this point, and attempts at removing parts of the routine to arrive"
+LIST "at the minimal snippet of code necessary to avoid the DRAM stability"
+LIST "problem yielded the following:"
+
+MRC p15, 0, r0, c1, c0, 0
+MCR p15, 0, r0, c1, c0, 0
index d241bfd..5aee83f 100644 (file)
@@ -1,24 +1,10 @@
 #ifndef __ASM_MACH_IRQS_H
 #define __ASM_MACH_IRQS_H
 
-#include <linux/sh_intc.h>
-
-/* GIC */
-#define gic_spi(nr)            ((nr) + 32)
-#define gic_iid(nr)            (nr) /* ICCIAR / interrupt ID */
-
-/* INTCS */
-#define INTCS_VECT_BASE                0x3400
-#define INTCS_VECT(n, vect)    INTC_VECT((n), INTCS_VECT_BASE + (vect))
-#define intcs_evt2irq(evt)     evt2irq(INTCS_VECT_BASE + (evt))
+/* Stuck here until drivers/pinctl/sh-pfc gets rid of legacy code */
 
 /* External IRQ pins */
 #define IRQPIN_BASE            2000
 #define irq_pin(nr)            ((nr) + IRQPIN_BASE)
 
-/* GPIO IRQ */
-#define _GPIO_IRQ_BASE         2500
-#define GPIO_IRQ_BASE(x)       (_GPIO_IRQ_BASE + (32 * x))
-#define GPIO_IRQ(x, y)         (_GPIO_IRQ_BASE + (32 * x) + y)
-
 #endif /* __ASM_MACH_IRQS_H */
diff --git a/arch/arm/mach-shmobile/include/mach/r7s72100.h b/arch/arm/mach-shmobile/include/mach/r7s72100.h
deleted file mode 100644 (file)
index 5f34b20..0000000
+++ /dev/null
@@ -1,8 +0,0 @@
-#ifndef __ASM_R7S72100_H__
-#define __ASM_R7S72100_H__
-
-void r7s72100_add_dt_devices(void);
-void r7s72100_clock_init(void);
-void r7s72100_init_early(void);
-
-#endif /* __ASM_R7S72100_H__ */
diff --git a/arch/arm/mach-shmobile/include/mach/r8a7790.h b/arch/arm/mach-shmobile/include/mach/r8a7790.h
deleted file mode 100644 (file)
index 5fbfa28..0000000
+++ /dev/null
@@ -1,13 +0,0 @@
-#ifndef __ASM_R8A7790_H__
-#define __ASM_R8A7790_H__
-
-#include <mach/rcar-gen2.h>
-
-void r8a7790_add_standard_devices(void);
-void r8a7790_add_dt_devices(void);
-void r8a7790_clock_init(void);
-void r8a7790_pinmux_init(void);
-void r8a7790_init_early(void);
-extern struct smp_operations r8a7790_smp_ops;
-
-#endif /* __ASM_R8A7790_H__ */
index c3c4669..727cc78 100644 (file)
@@ -12,6 +12,9 @@
 #ifdef CONFIG_MACH_MACKEREL
 #define MEMORY_START   0x40000000
 #include "mach/head-mackerel.txt"
+#elif defined(CONFIG_MACH_KZM9G) || defined(CONFIG_MACH_KZM9G_REFERENCE)
+#define MEMORY_START   0x43000000
+#include "mach/head-kzm9g.txt"
 #else
 #error "unsupported board."
 #endif
index aa6111f..14fd3d5 100644 (file)
 2 :
 .endm
 
+/* loop until a given value has been read (with mask) */
+.macro WAIT_MASK, addr, data, cmp
+       LDR     r0, 2f
+       LDR     r1, 3f
+       LDR     r2, 4f
+1:
+       LDR     r3, [r0, #0]
+       AND     r3, r1, r3
+       CMP     r2, r3
+       BNE     1b
+       B       5f
+2:     .long   \addr
+3:     .long   \data
+4:     .long   \cmp
+5:
+.endm
+
+/* read 32-bit value from addr, "or" an immediate and write back */
+.macro ED_OR, addr, data
+       LDR r4, 1f
+       LDR r5, 2f
+       LDR r6, [r4]
+       ORR r5, r6, r5
+       STR r5, [r4]
+       B       3f
+1:     .long   \addr
+2:     .long   \data
+3:
+.endm
+
+/* read 32-bit value from addr, "and" an immediate and write back */
+.macro ED_AND, addr, data
+       LDR r4, 1f
+       LDR r5, 2f
+       LDR r6, [r4]
+       AND r5, r6, r5
+       STR r5, [r4]
+       B       3f
+1:     .long \addr
+2:     .long \data
+3:
+.endm
+
 #endif /* __ZBOOT_MACRO_H */
index a91caad..e2af00b 100644 (file)
 #include <linux/module.h>
 #include <linux/irq.h>
 #include <linux/io.h>
-#include <linux/sh_intc.h>
-#include <mach/intc.h>
-#include <mach/irqs.h>
 #include <asm/mach-types.h>
 #include <asm/mach/arch.h>
+#include "intc.h"
+#include "irqs.h"
 
 enum {
        UNUSED_INTCA = 0,
index 19a26f4..44457a9 100644 (file)
 #include <linux/module.h>
 #include <linux/irq.h>
 #include <linux/io.h>
-#include <linux/sh_intc.h>
 #include <linux/irqchip.h>
 #include <linux/irqchip/arm-gic.h>
-#include <mach/intc.h>
-#include <mach/irqs.h>
-#include <mach/sh73a0.h>
+
 #include <asm/mach-types.h>
 #include <asm/mach/arch.h>
 
+#include "intc.h"
+#include "irqs.h"
+#include "sh73a0.h"
+
 enum {
        UNUSED = 0,
 
similarity index 98%
rename from arch/arm/mach-shmobile/include/mach/intc.h
rename to arch/arm/mach-shmobile/intc.h
index a5603c7..40b2ad4 100644 (file)
@@ -287,4 +287,9 @@ static struct intc_desc p ## _desc __initdata = {                   \
                             p ## _sense_registers, NULL),              \
 }
 
+/* INTCS */
+#define INTCS_VECT_BASE                0x3400
+#define INTCS_VECT(n, vect)    INTC_VECT((n), INTCS_VECT_BASE + (vect))
+#define intcs_evt2irq(evt)     evt2irq(INTCS_VECT_BASE + (evt))
+
 #endif  /* __ASM_MACH_INTC_H */
diff --git a/arch/arm/mach-shmobile/irqs.h b/arch/arm/mach-shmobile/irqs.h
new file mode 100644 (file)
index 0000000..3070f6d
--- /dev/null
@@ -0,0 +1,15 @@
+#ifndef __SHMOBILE_IRQS_H
+#define __SHMOBILE_IRQS_H
+
+#include "include/mach/irqs.h"
+
+/* GIC */
+#define gic_spi(nr)            ((nr) + 32)
+#define gic_iid(nr)            (nr) /* ICCIAR / interrupt ID */
+
+/* GPIO IRQ */
+#define _GPIO_IRQ_BASE         2500
+#define GPIO_IRQ_BASE(x)       (_GPIO_IRQ_BASE + (32 * x))
+#define GPIO_IRQ(x, y)         (_GPIO_IRQ_BASE + (32 * x) + y)
+
+#endif /* __SHMOBILE_IRQS_H */
index 1da5a72..2c06810 100644 (file)
@@ -7,27 +7,32 @@
  * it under the terms of the GNU General Public License version 2 as
  * published by the Free Software Foundation.
  */
+#include <linux/cpu_pm.h>
 #include <linux/delay.h>
 #include <linux/init.h>
 #include <linux/io.h>
 #include <linux/ioport.h>
 #include <linux/of_address.h>
 #include <linux/smp.h>
+#include <linux/suspend.h>
+#include <linux/threads.h>
 #include <asm/cacheflush.h>
 #include <asm/cp15.h>
+#include <asm/proc-fns.h>
 #include <asm/smp_plat.h>
-#include <mach/common.h>
+#include <asm/suspend.h>
+#include "common.h"
 
 static struct {
        void __iomem *iomem;
        int bit;
-} apmu_cpus[CONFIG_NR_CPUS];
+} apmu_cpus[NR_CPUS];
 
 #define WUPCR_OFFS 0x10
 #define PSTR_OFFS 0x40
 #define CPUNCR_OFFS(n) (0x100 + (0x10 * (n)))
 
-static int apmu_power_on(void __iomem *p, int bit)
+static int __maybe_unused apmu_power_on(void __iomem *p, int bit)
 {
        /* request power on */
        writel_relaxed(BIT(bit), p + WUPCR_OFFS);
@@ -46,7 +51,7 @@ static int apmu_power_off(void __iomem *p, int bit)
        return 0;
 }
 
-static int apmu_power_off_poll(void __iomem *p, int bit)
+static int __maybe_unused apmu_power_off_poll(void __iomem *p, int bit)
 {
        int k;
 
@@ -69,14 +74,13 @@ static int apmu_wrap(int cpu, int (*fn)(void __iomem *p, int cpu))
 
 static void apmu_init_cpu(struct resource *res, int cpu, int bit)
 {
-       if (apmu_cpus[cpu].iomem)
+       if ((cpu >= ARRAY_SIZE(apmu_cpus)) || apmu_cpus[cpu].iomem)
                return;
 
        apmu_cpus[cpu].iomem = ioremap_nocache(res->start, resource_size(res));
        apmu_cpus[cpu].bit = bit;
 
-       pr_debug("apmu ioremap %d %d 0x%08x 0x%08x\n", cpu, bit,
-                res->start, resource_size(res));
+       pr_debug("apmu ioremap %d %d %pr\n", cpu, bit, res);
 }
 
 static struct {
@@ -134,6 +138,7 @@ void __init shmobile_smp_apmu_prepare_cpus(unsigned int max_cpus)
        apmu_parse_cfg(apmu_init_cpu);
 }
 
+#ifdef CONFIG_SMP
 int shmobile_smp_apmu_boot_secondary(unsigned int cpu, struct task_struct *idle)
 {
        /* For this particular CPU register boot vector */
@@ -141,8 +146,9 @@ int shmobile_smp_apmu_boot_secondary(unsigned int cpu, struct task_struct *idle)
 
        return apmu_wrap(cpu, apmu_power_on);
 }
+#endif
 
-#ifdef CONFIG_HOTPLUG_CPU
+#if defined(CONFIG_HOTPLUG_CPU) || defined(CONFIG_SUSPEND)
 /* nicked from arch/arm/mach-exynos/hotplug.c */
 static inline void cpu_enter_lowpower_a15(void)
 {
@@ -173,16 +179,40 @@ static inline void cpu_enter_lowpower_a15(void)
        dsb();
 }
 
-void shmobile_smp_apmu_cpu_die(unsigned int cpu)
+void shmobile_smp_apmu_cpu_shutdown(unsigned int cpu)
 {
-       /* For this particular CPU deregister boot vector */
-       shmobile_smp_hook(cpu, 0, 0);
 
        /* Select next sleep mode using the APMU */
        apmu_wrap(cpu, apmu_power_off);
 
        /* Do ARM specific CPU shutdown */
        cpu_enter_lowpower_a15();
+}
+
+static inline void cpu_leave_lowpower(void)
+{
+       unsigned int v;
+
+       asm volatile("mrc    p15, 0, %0, c1, c0, 0\n"
+                    "       orr     %0, %0, %1\n"
+                    "       mcr     p15, 0, %0, c1, c0, 0\n"
+                    "       mrc     p15, 0, %0, c1, c0, 1\n"
+                    "       orr     %0, %0, %2\n"
+                    "       mcr     p15, 0, %0, c1, c0, 1\n"
+                    : "=&r" (v)
+                    : "Ir" (CR_C), "Ir" (0x40)
+                    : "cc");
+}
+#endif
+
+#if defined(CONFIG_HOTPLUG_CPU)
+void shmobile_smp_apmu_cpu_die(unsigned int cpu)
+{
+       /* For this particular CPU deregister boot vector */
+       shmobile_smp_hook(cpu, 0, 0);
+
+       /* Shutdown CPU core */
+       shmobile_smp_apmu_cpu_shutdown(cpu);
 
        /* jump to shared mach-shmobile sleep / reset code */
        shmobile_smp_sleep();
@@ -193,3 +223,25 @@ int shmobile_smp_apmu_cpu_kill(unsigned int cpu)
        return apmu_wrap(cpu, apmu_power_off_poll);
 }
 #endif
+
+#if defined(CONFIG_SUSPEND)
+static int shmobile_smp_apmu_do_suspend(unsigned long cpu)
+{
+       shmobile_smp_hook(cpu, virt_to_phys(cpu_resume), 0);
+       shmobile_smp_apmu_cpu_shutdown(cpu);
+       cpu_do_idle(); /* WFI selects Core Standby */
+       return 1;
+}
+
+static int shmobile_smp_apmu_enter_suspend(suspend_state_t state)
+{
+       cpu_suspend(smp_processor_id(), shmobile_smp_apmu_do_suspend);
+       cpu_leave_lowpower();
+       return 0;
+}
+
+void __init shmobile_smp_apmu_suspend_init(void)
+{
+       shmobile_suspend_ops.enter = shmobile_smp_apmu_enter_suspend;
+}
+#endif
index 673ad6e..6466311 100644 (file)
@@ -15,7 +15,7 @@
 #include <asm/cacheflush.h>
 #include <asm/smp_plat.h>
 #include <asm/smp_scu.h>
-#include <mach/common.h>
+#include "common.h"
 
 static int shmobile_smp_scu_notifier_call(struct notifier_block *nfb,
                                          unsigned long action, void *hcpu)
index 9ebc246..3923e09 100644 (file)
@@ -13,7 +13,7 @@
 #include <linux/init.h>
 #include <asm/cacheflush.h>
 #include <asm/smp_plat.h>
-#include <mach/common.h>
+#include "common.h"
 
 extern unsigned long shmobile_smp_fn[];
 extern unsigned long shmobile_smp_arg[];
index 40b87aa..e3f1464 100644 (file)
  */
 #include <linux/console.h>
 #include <linux/suspend.h>
-#include <mach/pm-rmobile.h>
-#include <mach/common.h>
+#include "common.h"
+#include "pm-rmobile.h"
 
-#ifdef CONFIG_PM
+#if defined(CONFIG_PM) && !defined(CONFIG_ARCH_MULTIPLATFORM)
 static int r8a7740_pd_a4s_suspend(void)
 {
        /*
         * The A4S domain contains the CPU core and therefore it should
-        * only be turned off if the CPU is in use.
+        * only be turned off if the CPU is not in use.
         */
        return -EBUSY;
 }
@@ -34,23 +34,21 @@ static int r8a7740_pd_a3sp_suspend(void)
 
 static struct rmobile_pm_domain r8a7740_pm_domains[] = {
        {
+               .genpd.name     = "A4LC",
+               .bit_shift      = 1,
+       }, {
                .genpd.name     = "A4S",
                .bit_shift      = 10,
                .gov            = &pm_domain_always_on_gov,
                .no_debug       = true,
                .suspend        = r8a7740_pd_a4s_suspend,
-       },
-       {
+       }, {
                .genpd.name     = "A3SP",
                .bit_shift      = 11,
                .gov            = &pm_domain_always_on_gov,
                .no_debug       = true,
                .suspend        = r8a7740_pd_a3sp_suspend,
        },
-       {
-               .genpd.name     = "A4LC",
-               .bit_shift      = 1,
-       },
 };
 
 void __init r8a7740_init_pm_domains(void)
@@ -58,8 +56,7 @@ void __init r8a7740_init_pm_domains(void)
        rmobile_init_domains(r8a7740_pm_domains, ARRAY_SIZE(r8a7740_pm_domains));
        pm_genpd_add_subdomain_names("A4S", "A3SP");
 }
-
-#endif /* CONFIG_PM */
+#endif /* CONFIG_PM && !CONFIG_ARCH_MULTIPLATFORM */
 
 #ifdef CONFIG_SUSPEND
 static int r8a7740_enter_suspend(suspend_state_t suspend_state)
index d50a8e9..82fe3d7 100644 (file)
 #include <linux/suspend.h>
 #include <linux/err.h>
 #include <linux/pm_clock.h>
+#include <linux/pm_domain.h>
 #include <linux/platform_device.h>
 #include <linux/delay.h>
 #include <linux/irq.h>
 #include <linux/interrupt.h>
 #include <linux/console.h>
+
 #include <asm/io.h>
-#include <mach/common.h>
-#include <mach/r8a7779.h>
 
-static void __iomem *r8a7779_sysc_base;
+#include "common.h"
+#include "pm-rcar.h"
+#include "r8a7779.h"
 
 /* SYSC */
-#define SYSCSR 0x00
-#define SYSCISR 0x04
-#define SYSCISCR 0x08
 #define SYSCIER 0x0c
 #define SYSCIMR 0x10
-#define PWRSR0 0x40
-#define PWRSR1 0x80
-#define PWRSR2 0xc0
-#define PWRSR3 0x100
-#define PWRSR4 0x140
-
-#define PWRSR_OFFS 0x00
-#define PWROFFCR_OFFS 0x04
-#define PWRONCR_OFFS 0x0c
-#define PWRER_OFFS 0x14
-
-#define SYSCSR_RETRIES 100
-#define SYSCSR_DELAY_US 1
-
-#define SYSCISR_RETRIES 1000
-#define SYSCISR_DELAY_US 1
-
-#if defined(CONFIG_PM) || defined(CONFIG_SMP)
-
-static DEFINE_SPINLOCK(r8a7779_sysc_lock); /* SMP CPUs + I/O devices */
-
-static int r8a7779_sysc_pwr_on_off(struct r8a7779_pm_ch *r8a7779_ch,
-                                  int sr_bit, int reg_offs)
-{
-       int k;
-
-       for (k = 0; k < SYSCSR_RETRIES; k++) {
-               if (ioread32(r8a7779_sysc_base + SYSCSR) & (1 << sr_bit))
-                       break;
-               udelay(SYSCSR_DELAY_US);
-       }
-
-       if (k == SYSCSR_RETRIES)
-               return -EAGAIN;
-
-       iowrite32(1 << r8a7779_ch->chan_bit,
-                 r8a7779_sysc_base + r8a7779_ch->chan_offs + reg_offs);
-
-       return 0;
-}
 
-static int r8a7779_sysc_pwr_off(struct r8a7779_pm_ch *r8a7779_ch)
-{
-       return r8a7779_sysc_pwr_on_off(r8a7779_ch, 0, PWROFFCR_OFFS);
-}
-
-static int r8a7779_sysc_pwr_on(struct r8a7779_pm_ch *r8a7779_ch)
-{
-       return r8a7779_sysc_pwr_on_off(r8a7779_ch, 1, PWRONCR_OFFS);
-}
-
-static int r8a7779_sysc_update(struct r8a7779_pm_ch *r8a7779_ch,
-                              int (*on_off_fn)(struct r8a7779_pm_ch *))
-{
-       unsigned int isr_mask = 1 << r8a7779_ch->isr_bit;
-       unsigned int chan_mask = 1 << r8a7779_ch->chan_bit;
-       unsigned int status;
-       unsigned long flags;
-       int ret = 0;
-       int k;
-
-       spin_lock_irqsave(&r8a7779_sysc_lock, flags);
-
-       iowrite32(isr_mask, r8a7779_sysc_base + SYSCISCR);
-
-       do {
-               ret = on_off_fn(r8a7779_ch);
-               if (ret)
-                       goto out;
-
-               status = ioread32(r8a7779_sysc_base +
-                                 r8a7779_ch->chan_offs + PWRER_OFFS);
-       } while (status & chan_mask);
-
-       for (k = 0; k < SYSCISR_RETRIES; k++) {
-               if (ioread32(r8a7779_sysc_base + SYSCISR) & isr_mask)
-                       break;
-               udelay(SYSCISR_DELAY_US);
-       }
-
-       if (k == SYSCISR_RETRIES)
-               ret = -EIO;
-
-       iowrite32(isr_mask, r8a7779_sysc_base + SYSCISCR);
-
- out:
-       spin_unlock_irqrestore(&r8a7779_sysc_lock, flags);
-
-       pr_debug("r8a7779 power domain %d: %02x %02x %02x %02x %02x -> %d\n",
-                r8a7779_ch->isr_bit, ioread32(r8a7779_sysc_base + PWRSR0),
-                ioread32(r8a7779_sysc_base + PWRSR1),
-                ioread32(r8a7779_sysc_base + PWRSR2),
-                ioread32(r8a7779_sysc_base + PWRSR3),
-                ioread32(r8a7779_sysc_base + PWRSR4), ret);
-       return ret;
-}
+struct r8a7779_pm_domain {
+       struct generic_pm_domain genpd;
+       struct rcar_sysc_ch ch;
+};
 
-int r8a7779_sysc_power_down(struct r8a7779_pm_ch *r8a7779_ch)
+static inline struct rcar_sysc_ch *to_r8a7779_ch(struct generic_pm_domain *d)
 {
-       return r8a7779_sysc_update(r8a7779_ch, r8a7779_sysc_pwr_off);
+       return &container_of(d, struct r8a7779_pm_domain, genpd)->ch;
 }
 
-int r8a7779_sysc_power_up(struct r8a7779_pm_ch *r8a7779_ch)
-{
-       return r8a7779_sysc_update(r8a7779_ch, r8a7779_sysc_pwr_on);
-}
+#if defined(CONFIG_PM) || defined(CONFIG_SMP)
 
 static void __init r8a7779_sysc_init(void)
 {
-       r8a7779_sysc_base = ioremap_nocache(0xffd85000, PAGE_SIZE);
-       if (!r8a7779_sysc_base)
-               panic("unable to ioremap r8a7779 SYSC hardware block\n");
+       void __iomem *base = rcar_sysc_init(0xffd85000);
 
        /* enable all interrupt sources, but do not use interrupt handler */
-       iowrite32(0x0131000e, r8a7779_sysc_base + SYSCIER);
-       iowrite32(0, r8a7779_sysc_base + SYSCIMR);
+       iowrite32(0x0131000e, base + SYSCIER);
+       iowrite32(0, base + SYSCIMR);
 }
 
 #else /* CONFIG_PM || CONFIG_SMP */
@@ -158,24 +61,17 @@ static inline void r8a7779_sysc_init(void) {}
 
 static int pd_power_down(struct generic_pm_domain *genpd)
 {
-       return r8a7779_sysc_power_down(to_r8a7779_ch(genpd));
+       return rcar_sysc_power_down(to_r8a7779_ch(genpd));
 }
 
 static int pd_power_up(struct generic_pm_domain *genpd)
 {
-       return r8a7779_sysc_power_up(to_r8a7779_ch(genpd));
+       return rcar_sysc_power_up(to_r8a7779_ch(genpd));
 }
 
 static bool pd_is_off(struct generic_pm_domain *genpd)
 {
-       struct r8a7779_pm_ch *r8a7779_ch = to_r8a7779_ch(genpd);
-       unsigned int st;
-
-       st = ioread32(r8a7779_sysc_base + r8a7779_ch->chan_offs + PWRSR_OFFS);
-       if (st & (1 << r8a7779_ch->chan_bit))
-               return true;
-
-       return false;
+       return rcar_sysc_power_is_off(to_r8a7779_ch(genpd));
 }
 
 static bool pd_active_wakeup(struct device *dev)
@@ -191,7 +87,6 @@ static void r8a7779_init_pm_domain(struct r8a7779_pm_domain *r8a7779_pd)
        genpd->dev_ops.stop = pm_clk_suspend;
        genpd->dev_ops.start = pm_clk_resume;
        genpd->dev_ops.active_wakeup = pd_active_wakeup;
-       genpd->dev_irq_safe = true;
        genpd->power_off = pd_power_down;
        genpd->power_on = pd_power_up;
 
diff --git a/arch/arm/mach-shmobile/pm-r8a7790.c b/arch/arm/mach-shmobile/pm-r8a7790.c
new file mode 100644 (file)
index 0000000..f7912d1
--- /dev/null
@@ -0,0 +1,84 @@
+/*
+ * r8a7790 Power management support
+ *
+ * Copyright (C) 2013  Renesas Electronics Corporation
+ * Copyright (C) 2011  Renesas Solutions Corp.
+ * Copyright (C) 2011  Magnus Damm
+ *
+ * This file is subject to the terms and conditions of the GNU General Public
+ * License.  See the file "COPYING" in the main directory of this archive
+ * for more details.
+ */
+
+#include <linux/kernel.h>
+
+#include <linux/smp.h>
+#include <asm/io.h>
+
+#include "common.h"
+#include "pm-rcar.h"
+#include "r8a7790.h"
+
+/* RST */
+#define RST            0xe6160000
+#define CA15BAR                0x0020
+#define CA7BAR         0x0030
+#define CA15RESCNT     0x0040
+#define CA7RESCNT      0x0044
+
+/* On-chip RAM */
+#define MERAM          0xe8080000
+
+/* SYSC */
+#define SYSCIER 0x0c
+#define SYSCIMR 0x10
+
+#if defined(CONFIG_SMP)
+
+static void __init r8a7790_sysc_init(void)
+{
+       void __iomem *base = rcar_sysc_init(0xe6180000);
+
+       /* enable all interrupt sources, but do not use interrupt handler */
+       iowrite32(0x0131000e, base + SYSCIER);
+       iowrite32(0, base + SYSCIMR);
+}
+
+#else /* CONFIG_SMP */
+
+static inline void r8a7790_sysc_init(void) {}
+
+#endif /* CONFIG_SMP */
+
+void __init r8a7790_pm_init(void)
+{
+       void __iomem *p;
+       u32 bar;
+       static int once;
+
+       if (once++)
+               return;
+
+       /* MERAM for jump stub, because BAR requires 256KB aligned address */
+       p = ioremap_nocache(MERAM, shmobile_boot_size);
+       memcpy_toio(p, shmobile_boot_vector, shmobile_boot_size);
+       iounmap(p);
+
+       /* setup reset vectors */
+       p = ioremap_nocache(RST, 0x63);
+       bar = (MERAM >> 8) & 0xfffffc00;
+       writel_relaxed(bar, p + CA15BAR);
+       writel_relaxed(bar, p + CA7BAR);
+       writel_relaxed(bar | 0x10, p + CA15BAR);
+       writel_relaxed(bar | 0x10, p + CA7BAR);
+
+       /* de-assert reset for all CPUs */
+       writel_relaxed((readl_relaxed(p + CA15RESCNT) & ~0x0f) | 0xa5a50000,
+                      p + CA15RESCNT);
+       writel_relaxed((readl_relaxed(p + CA7RESCNT) & ~0x0f) | 0x5a5a0000,
+                      p + CA7RESCNT);
+       iounmap(p);
+
+       r8a7790_sysc_init();
+       shmobile_smp_apmu_suspend_init();
+}
diff --git a/arch/arm/mach-shmobile/pm-r8a7791.c b/arch/arm/mach-shmobile/pm-r8a7791.c
new file mode 100644 (file)
index 0000000..25f107b
--- /dev/null
@@ -0,0 +1,73 @@
+/*
+ * r8a7791 Power management support
+ *
+ * Copyright (C) 2014  Renesas Electronics Corporation
+ * Copyright (C) 2011  Renesas Solutions Corp.
+ * Copyright (C) 2011  Magnus Damm
+ *
+ * This file is subject to the terms and conditions of the GNU General Public
+ * License.  See the file "COPYING" in the main directory of this archive
+ * for more details.
+ */
+
+#include <linux/kernel.h>
+#include <linux/smp.h>
+#include <asm/io.h>
+#include "common.h"
+#include "pm-rcar.h"
+#include "r8a7791.h"
+
+#define RST            0xe6160000
+#define CA15BAR                0x0020
+#define CA15RESCNT     0x0040
+#define RAM            0xe6300000
+
+/* SYSC */
+#define SYSCIER 0x0c
+#define SYSCIMR 0x10
+
+#if defined(CONFIG_SMP)
+
+static void __init r8a7791_sysc_init(void)
+{
+       void __iomem *base = rcar_sysc_init(0xe6180000);
+
+       /* enable all interrupt sources, but do not use interrupt handler */
+       iowrite32(0x0131000e, base + SYSCIER);
+       iowrite32(0, base + SYSCIMR);
+}
+
+#else /* CONFIG_SMP */
+
+static inline void r8a7791_sysc_init(void) {}
+
+#endif /* CONFIG_SMP */
+
+void __init r8a7791_pm_init(void)
+{
+       void __iomem *p;
+       u32 bar;
+       static int once;
+
+       if (once++)
+               return;
+
+       /* RAM for jump stub, because BAR requires 256KB aligned address */
+       p = ioremap_nocache(RAM, shmobile_boot_size);
+       memcpy_toio(p, shmobile_boot_vector, shmobile_boot_size);
+       iounmap(p);
+
+       /* setup reset vectors */
+       p = ioremap_nocache(RST, 0x63);
+       bar = (RAM >> 8) & 0xfffffc00;
+       writel_relaxed(bar, p + CA15BAR);
+       writel_relaxed(bar | 0x10, p + CA15BAR);
+
+       /* enable clocks to all CPUs */
+       writel_relaxed((readl_relaxed(p + CA15RESCNT) & ~0x0f) | 0xa5a50000,
+                      p + CA15RESCNT);
+       iounmap(p);
+
+       r8a7791_sysc_init();
+       shmobile_smp_apmu_suspend_init();
+}
diff --git a/arch/arm/mach-shmobile/pm-rcar.c b/arch/arm/mach-shmobile/pm-rcar.c
new file mode 100644 (file)
index 0000000..00022ee
--- /dev/null
@@ -0,0 +1,137 @@
+/*
+ * R-Car SYSC Power management support
+ *
+ * Copyright (C) 2014  Magnus Damm
+ *
+ * This file is subject to the terms and conditions of the GNU General Public
+ * License.  See the file "COPYING" in the main directory of this archive
+ * for more details.
+ */
+
+#include <linux/delay.h>
+#include <linux/err.h>
+#include <linux/mm.h>
+#include <linux/spinlock.h>
+#include <asm/io.h>
+#include "pm-rcar.h"
+
+/* SYSC */
+#define SYSCSR 0x00
+#define SYSCISR 0x04
+#define SYSCISCR 0x08
+
+#define PWRSR_OFFS 0x00
+#define PWROFFCR_OFFS 0x04
+#define PWRONCR_OFFS 0x0c
+#define PWRER_OFFS 0x14
+
+#define SYSCSR_RETRIES 100
+#define SYSCSR_DELAY_US 1
+
+#define SYSCISR_RETRIES 1000
+#define SYSCISR_DELAY_US 1
+
+static void __iomem *rcar_sysc_base;
+static DEFINE_SPINLOCK(rcar_sysc_lock); /* SMP CPUs + I/O devices */
+
+static int rcar_sysc_pwr_on_off(struct rcar_sysc_ch *sysc_ch,
+                               int sr_bit, int reg_offs)
+{
+       int k;
+
+       for (k = 0; k < SYSCSR_RETRIES; k++) {
+               if (ioread32(rcar_sysc_base + SYSCSR) & (1 << sr_bit))
+                       break;
+               udelay(SYSCSR_DELAY_US);
+       }
+
+       if (k == SYSCSR_RETRIES)
+               return -EAGAIN;
+
+       iowrite32(1 << sysc_ch->chan_bit,
+                 rcar_sysc_base + sysc_ch->chan_offs + reg_offs);
+
+       return 0;
+}
+
+static int rcar_sysc_pwr_off(struct rcar_sysc_ch *sysc_ch)
+{
+       return rcar_sysc_pwr_on_off(sysc_ch, 0, PWROFFCR_OFFS);
+}
+
+static int rcar_sysc_pwr_on(struct rcar_sysc_ch *sysc_ch)
+{
+       return rcar_sysc_pwr_on_off(sysc_ch, 1, PWRONCR_OFFS);
+}
+
+static int rcar_sysc_update(struct rcar_sysc_ch *sysc_ch,
+                           int (*on_off_fn)(struct rcar_sysc_ch *))
+{
+       unsigned int isr_mask = 1 << sysc_ch->isr_bit;
+       unsigned int chan_mask = 1 << sysc_ch->chan_bit;
+       unsigned int status;
+       unsigned long flags;
+       int ret = 0;
+       int k;
+
+       spin_lock_irqsave(&rcar_sysc_lock, flags);
+
+       iowrite32(isr_mask, rcar_sysc_base + SYSCISCR);
+
+       do {
+               ret = on_off_fn(sysc_ch);
+               if (ret)
+                       goto out;
+
+               status = ioread32(rcar_sysc_base +
+                                 sysc_ch->chan_offs + PWRER_OFFS);
+       } while (status & chan_mask);
+
+       for (k = 0; k < SYSCISR_RETRIES; k++) {
+               if (ioread32(rcar_sysc_base + SYSCISR) & isr_mask)
+                       break;
+               udelay(SYSCISR_DELAY_US);
+       }
+
+       if (k == SYSCISR_RETRIES)
+               ret = -EIO;
+
+       iowrite32(isr_mask, rcar_sysc_base + SYSCISCR);
+
+ out:
+       spin_unlock_irqrestore(&rcar_sysc_lock, flags);
+
+       pr_debug("sysc power domain %d: %08x -> %d\n",
+                sysc_ch->isr_bit, ioread32(rcar_sysc_base + SYSCISR), ret);
+       return ret;
+}
+
+int rcar_sysc_power_down(struct rcar_sysc_ch *sysc_ch)
+{
+       return rcar_sysc_update(sysc_ch, rcar_sysc_pwr_off);
+}
+
+int rcar_sysc_power_up(struct rcar_sysc_ch *sysc_ch)
+{
+       return rcar_sysc_update(sysc_ch, rcar_sysc_pwr_on);
+}
+
+bool rcar_sysc_power_is_off(struct rcar_sysc_ch *sysc_ch)
+{
+       unsigned int st;
+
+       st = ioread32(rcar_sysc_base + sysc_ch->chan_offs + PWRSR_OFFS);
+       if (st & (1 << sysc_ch->chan_bit))
+               return true;
+
+       return false;
+}
+
+void __iomem *rcar_sysc_init(phys_addr_t base)
+{
+       rcar_sysc_base = ioremap_nocache(base, PAGE_SIZE);
+       if (!rcar_sysc_base)
+               panic("unable to ioremap R-Car SYSC hardware block\n");
+
+       return rcar_sysc_base;
+}
diff --git a/arch/arm/mach-shmobile/pm-rcar.h b/arch/arm/mach-shmobile/pm-rcar.h
new file mode 100644 (file)
index 0000000..ef3a1ef
--- /dev/null
@@ -0,0 +1,15 @@
+#ifndef PM_RCAR_H
+#define PM_RCAR_H
+
+struct rcar_sysc_ch {
+       unsigned long chan_offs;
+       unsigned int chan_bit;
+       unsigned int isr_bit;
+};
+
+int rcar_sysc_power_down(struct rcar_sysc_ch *sysc_ch);
+int rcar_sysc_power_up(struct rcar_sysc_ch *sysc_ch);
+bool rcar_sysc_power_is_off(struct rcar_sysc_ch *sysc_ch);
+void __iomem *rcar_sysc_init(phys_addr_t base);
+
+#endif /* PM_RCAR_H */
index 1fc05d9..717e641 100644 (file)
@@ -17,7 +17,7 @@
 #include <linux/pm.h>
 #include <linux/pm_clock.h>
 #include <asm/io.h>
-#include <mach/pm-rmobile.h>
+#include "pm-rmobile.h"
 
 /* SYSC */
 #define SPDCR          IOMEM(0xe6180008)
@@ -27,7 +27,6 @@
 #define PSTR_RETRIES   100
 #define PSTR_DELAY_US  10
 
-#ifdef CONFIG_PM
 static int rmobile_pd_power_down(struct generic_pm_domain *genpd)
 {
        struct rmobile_pm_domain *rmobile_pd = to_rmobile_pd(genpd);
@@ -99,39 +98,7 @@ static int rmobile_pd_power_up(struct generic_pm_domain *genpd)
 
 static bool rmobile_pd_active_wakeup(struct device *dev)
 {
-       bool (*active_wakeup)(struct device *dev);
-
-       active_wakeup = dev_gpd_data(dev)->ops.active_wakeup;
-       return active_wakeup ? active_wakeup(dev) : true;
-}
-
-static int rmobile_pd_stop_dev(struct device *dev)
-{
-       int (*stop)(struct device *dev);
-
-       stop = dev_gpd_data(dev)->ops.stop;
-       if (stop) {
-               int ret = stop(dev);
-               if (ret)
-                       return ret;
-       }
-       return pm_clk_suspend(dev);
-}
-
-static int rmobile_pd_start_dev(struct device *dev)
-{
-       int (*start)(struct device *dev);
-       int ret;
-
-       ret = pm_clk_resume(dev);
-       if (ret)
-               return ret;
-
-       start = dev_gpd_data(dev)->ops.start;
-       if (start)
-               ret = start(dev);
-
-       return ret;
+       return true;
 }
 
 static void rmobile_init_pm_domain(struct rmobile_pm_domain *rmobile_pd)
@@ -140,10 +107,9 @@ static void rmobile_init_pm_domain(struct rmobile_pm_domain *rmobile_pd)
        struct dev_power_governor *gov = rmobile_pd->gov;
 
        pm_genpd_init(genpd, gov ? : &simple_qos_governor, false);
-       genpd->dev_ops.stop             = rmobile_pd_stop_dev;
-       genpd->dev_ops.start            = rmobile_pd_start_dev;
+       genpd->dev_ops.stop             = pm_clk_suspend;
+       genpd->dev_ops.start            = pm_clk_resume;
        genpd->dev_ops.active_wakeup    = rmobile_pd_active_wakeup;
-       genpd->dev_irq_safe             = true;
        genpd->power_off                = rmobile_pd_power_down;
        genpd->power_on                 = rmobile_pd_power_up;
        __rmobile_pd_power_up(rmobile_pd, false);
@@ -183,4 +149,3 @@ void rmobile_add_devices_to_domains(struct pm_domain_device data[],
                rmobile_add_device_to_domain_td(data[j].domain_name,
                                                data[j].pdev, &latencies);
 }
-#endif /* CONFIG_PM */
similarity index 96%
rename from arch/arm/mach-shmobile/include/mach/pm-rmobile.h
rename to arch/arm/mach-shmobile/pm-rmobile.h
index 690553a..8f66b34 100644 (file)
@@ -36,7 +36,7 @@ struct pm_domain_device {
        struct platform_device *pdev;
 };
 
-#ifdef CONFIG_PM
+#ifdef CONFIG_PM_RMOBILE
 extern void rmobile_init_domains(struct rmobile_pm_domain domains[], int num);
 extern void rmobile_add_device_to_domain_td(const char *domain_name,
                                            struct platform_device *pdev,
@@ -58,6 +58,6 @@ extern void rmobile_add_devices_to_domains(struct pm_domain_device data[],
 
 static inline void rmobile_add_devices_to_domains(struct pm_domain_device d[],
                                                  int size) {}
-#endif /* CONFIG_PM */
+#endif /* CONFIG_PM_RMOBILE */
 
 #endif /* PM_RMOBILE_H */
index 0de75fd..7e5c267 100644 (file)
 #include <linux/irq.h>
 #include <linux/bitrev.h>
 #include <linux/console.h>
+
 #include <asm/cpuidle.h>
 #include <asm/io.h>
 #include <asm/tlbflush.h>
 #include <asm/suspend.h>
-#include <mach/common.h>
-#include <mach/sh7372.h>
-#include <mach/pm-rmobile.h>
+
+#include "common.h"
+#include "pm-rmobile.h"
+#include "sh7372.h"
 
 /* DBG */
 #define DBGREG1 IOMEM(0xe6100020)
index 99086e9..a7e4668 100644 (file)
@@ -9,7 +9,7 @@
  */
 
 #include <linux/suspend.h>
-#include <mach/common.h>
+#include "common.h"
 
 #ifdef CONFIG_SUSPEND
 static int sh73a0_enter_suspend(suspend_state_t suspend_state)
similarity index 92%
rename from arch/arm/mach-shmobile/include/mach/r8a73a4.h
rename to arch/arm/mach-shmobile/r8a73a4.h
index ce8bdd1..5fafd6f 100644 (file)
@@ -14,6 +14,5 @@ void r8a73a4_add_standard_devices(void);
 void r8a73a4_add_dt_devices(void);
 void r8a73a4_clock_init(void);
 void r8a73a4_pinmux_init(void);
-void r8a73a4_init_early(void);
 
 #endif /* __ASM_R8A73A4_H__ */
similarity index 91%
rename from arch/arm/mach-shmobile/include/mach/r8a7740.h
rename to arch/arm/mach-shmobile/r8a7740.h
index d07932f..f369b4b 100644 (file)
@@ -19,8 +19,6 @@
 #ifndef __ASM_R8A7740_H__
 #define __ASM_R8A7740_H__
 
-#include <mach/pm-rmobile.h>
-
 /*
  * MD_CKx pin
  */
@@ -47,20 +45,18 @@ enum {
 };
 
 extern void r8a7740_meram_workaround(void);
-extern void r8a7740_init_delay(void);
 extern void r8a7740_init_irq_of(void);
 extern void r8a7740_map_io(void);
 extern void r8a7740_add_early_devices(void);
 extern void r8a7740_add_standard_devices(void);
-extern void r8a7740_add_standard_devices_dt(void);
 extern void r8a7740_clock_init(u8 md_ck);
 extern void r8a7740_pinmux_init(void);
 extern void r8a7740_pm_init(void);
 
-#ifdef CONFIG_PM
+#if defined(CONFIG_PM) && !defined(CONFIG_ARCH_MULTIPLATFORM)
 extern void __init r8a7740_init_pm_domains(void);
 #else
 static inline void r8a7740_init_pm_domains(void) {}
-#endif /* CONFIG_PM */
+#endif /* CONFIG_PM && !CONFIG_ARCH_MULTIPLATFORM */
 
 #endif /* __ASM_R8A7740_H__ */
similarity index 60%
rename from arch/arm/mach-shmobile/include/mach/r8a7779.h
rename to arch/arm/mach-shmobile/r8a7779.h
index b40e136..19f9704 100644 (file)
@@ -2,7 +2,6 @@
 #define __ASM_R8A7779_H__
 
 #include <linux/sh_clk.h>
-#include <linux/pm_domain.h>
 
 /* HPB-DMA slave IDs */
 enum {
@@ -11,23 +10,6 @@ enum {
        HPBDMA_SLAVE_SDHI0_RX,
 };
 
-struct r8a7779_pm_ch {
-       unsigned long chan_offs;
-       unsigned int chan_bit;
-       unsigned int isr_bit;
-};
-
-struct r8a7779_pm_domain {
-       struct generic_pm_domain genpd;
-       struct r8a7779_pm_ch ch;
-};
-
-static inline struct r8a7779_pm_ch *to_r8a7779_ch(struct generic_pm_domain *d)
-{
-       return &container_of(d, struct r8a7779_pm_domain, genpd)->ch;
-}
-
-extern void r8a7779_init_delay(void);
 extern void r8a7779_init_irq_extpin(int irlm);
 extern void r8a7779_init_irq_extpin_dt(int irlm);
 extern void r8a7779_init_irq_dt(void);
@@ -35,14 +17,12 @@ extern void r8a7779_map_io(void);
 extern void r8a7779_earlytimer_init(void);
 extern void r8a7779_add_early_devices(void);
 extern void r8a7779_add_standard_devices(void);
-extern void r8a7779_add_standard_devices_dt(void);
 extern void r8a7779_init_late(void);
+extern u32 r8a7779_read_mode_pins(void);
 extern void r8a7779_clock_init(void);
 extern void r8a7779_pinmux_init(void);
 extern void r8a7779_pm_init(void);
 extern void r8a7779_register_twd(void);
-extern int r8a7779_sysc_power_down(struct r8a7779_pm_ch *r8a7779_ch);
-extern int r8a7779_sysc_power_up(struct r8a7779_pm_ch *r8a7779_ch);
 
 #ifdef CONFIG_PM
 extern void __init r8a7779_init_pm_domains(void);
diff --git a/arch/arm/mach-shmobile/r8a7790.h b/arch/arm/mach-shmobile/r8a7790.h
new file mode 100644 (file)
index 0000000..388f051
--- /dev/null
@@ -0,0 +1,35 @@
+#ifndef __ASM_R8A7790_H__
+#define __ASM_R8A7790_H__
+
+/* DMA slave IDs */
+enum {
+       RCAR_DMA_SLAVE_INVALID,
+       AUDIO_DMAC_SLAVE_SSI0_TX,
+       AUDIO_DMAC_SLAVE_SSI0_RX,
+       AUDIO_DMAC_SLAVE_SSI1_TX,
+       AUDIO_DMAC_SLAVE_SSI1_RX,
+       AUDIO_DMAC_SLAVE_SSI2_TX,
+       AUDIO_DMAC_SLAVE_SSI2_RX,
+       AUDIO_DMAC_SLAVE_SSI3_TX,
+       AUDIO_DMAC_SLAVE_SSI3_RX,
+       AUDIO_DMAC_SLAVE_SSI4_TX,
+       AUDIO_DMAC_SLAVE_SSI4_RX,
+       AUDIO_DMAC_SLAVE_SSI5_TX,
+       AUDIO_DMAC_SLAVE_SSI5_RX,
+       AUDIO_DMAC_SLAVE_SSI6_TX,
+       AUDIO_DMAC_SLAVE_SSI6_RX,
+       AUDIO_DMAC_SLAVE_SSI7_TX,
+       AUDIO_DMAC_SLAVE_SSI7_RX,
+       AUDIO_DMAC_SLAVE_SSI8_TX,
+       AUDIO_DMAC_SLAVE_SSI8_RX,
+       AUDIO_DMAC_SLAVE_SSI9_TX,
+       AUDIO_DMAC_SLAVE_SSI9_RX,
+};
+
+void r8a7790_add_standard_devices(void);
+void r8a7790_clock_init(void);
+void r8a7790_pinmux_init(void);
+void r8a7790_pm_init(void);
+extern struct smp_operations r8a7790_smp_ops;
+
+#endif /* __ASM_R8A7790_H__ */
similarity index 78%
rename from arch/arm/mach-shmobile/include/mach/r8a7791.h
rename to arch/arm/mach-shmobile/r8a7791.h
index 200fa69..c1bf7ab 100644 (file)
@@ -2,10 +2,9 @@
 #define __ASM_R8A7791_H__
 
 void r8a7791_add_standard_devices(void);
-void r8a7791_add_dt_devices(void);
 void r8a7791_clock_init(void);
 void r8a7791_pinmux_init(void);
-void r8a7791_init_early(void);
+void r8a7791_pm_init(void);
 extern struct smp_operations r8a7791_smp_ops;
 
 #endif /* __ASM_R8A7791_H__ */
similarity index 85%
rename from arch/arm/mach-shmobile/include/mach/rcar-gen2.h
rename to arch/arm/mach-shmobile/rcar-gen2.h
index 43f606e..ce53cb5 100644 (file)
@@ -4,5 +4,6 @@
 void rcar_gen2_timer_init(void);
 #define MD(nr) BIT(nr)
 u32 rcar_gen2_read_mode_pins(void);
+void rcar_gen2_reserve(void);
 
 #endif /* __ASM_RCAR_GEN2_H__ */
index c8f2a1a..b06a9e8 100644 (file)
  * along with this program; if not, write to the Free Software
  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
  */
-#include <linux/clk-provider.h>
 #include <linux/kernel.h>
 #include <linux/init.h>
-#include <linux/of_platform.h>
-#include <mach/common.h>
-#include <mach/emev2.h>
+#include <linux/mm.h>
 #include <asm/mach-types.h>
 #include <asm/mach/arch.h>
 #include <asm/mach/map.h>
+#include "common.h"
 
 static struct map_desc emev2_io_desc[] __initdata = {
 #ifdef CONFIG_SMP
@@ -38,36 +36,22 @@ static struct map_desc emev2_io_desc[] __initdata = {
 #endif
 };
 
-void __init emev2_map_io(void)
+static void __init emev2_map_io(void)
 {
        iotable_init(emev2_io_desc, ARRAY_SIZE(emev2_io_desc));
 }
 
-void __init emev2_init_delay(void)
-{
-       shmobile_setup_delay(533, 1, 3); /* Cortex-A9 @ 533MHz */
-}
-
-static void __init emev2_add_standard_devices_dt(void)
-{
-#ifdef CONFIG_COMMON_CLK
-       of_clk_init(NULL);
-#else
-       emev2_clock_init();
-#endif
-       of_platform_populate(NULL, of_default_bus_match_table, NULL, NULL);
-}
-
-static const char *emev2_boards_compat_dt[] __initdata = {
+static const char *emev2_boards_compat_dt[] __initconst = {
        "renesas,emev2",
        NULL,
 };
 
+extern struct smp_operations emev2_smp_ops;
+
 DT_MACHINE_START(EMEV2_DT, "Generic Emma Mobile EV2 (Flattened Device Tree)")
        .smp            = smp_ops(emev2_smp_ops),
        .map_io         = emev2_map_io,
-       .init_early     = emev2_init_delay,
-       .init_machine   = emev2_add_standard_devices_dt,
+       .init_early     = shmobile_init_delay,
        .init_late      = shmobile_init_late,
        .dt_compat      = emev2_boards_compat_dt,
 MACHINE_END
index 9c0b3a9..4122104 100644 (file)
  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
  */
 
-#include <linux/irq.h>
 #include <linux/kernel.h>
-#include <linux/of_platform.h>
-#include <linux/serial_sci.h>
-#include <linux/sh_timer.h>
-#include <mach/common.h>
-#include <mach/irqs.h>
-#include <mach/r7s72100.h>
-#include <asm/mach/arch.h>
-
-#define R7S72100_SCIF(index, baseaddr, irq)                            \
-static const struct plat_sci_port scif##index##_platform_data = {      \
-       .type           = PORT_SCIF,                                    \
-       .regtype        = SCIx_SH2_SCIF_FIFODATA_REGTYPE,               \
-       .flags          = UPF_BOOT_AUTOCONF | UPF_IOREMAP,              \
-       .scscr          = SCSCR_RIE | SCSCR_TIE | SCSCR_RE | SCSCR_TE | \
-                         SCSCR_REIE,                                   \
-};                                                                     \
-                                                                       \
-static struct resource scif##index##_resources[] = {                   \
-       DEFINE_RES_MEM(baseaddr, 0x100),                                \
-       DEFINE_RES_IRQ(irq + 1),                                        \
-       DEFINE_RES_IRQ(irq + 2),                                        \
-       DEFINE_RES_IRQ(irq + 3),                                        \
-       DEFINE_RES_IRQ(irq),                                            \
-}                                                                      \
-
-R7S72100_SCIF(0, 0xe8007000, gic_iid(221));
-R7S72100_SCIF(1, 0xe8007800, gic_iid(225));
-R7S72100_SCIF(2, 0xe8008000, gic_iid(229));
-R7S72100_SCIF(3, 0xe8008800, gic_iid(233));
-R7S72100_SCIF(4, 0xe8009000, gic_iid(237));
-R7S72100_SCIF(5, 0xe8009800, gic_iid(241));
-R7S72100_SCIF(6, 0xe800a000, gic_iid(245));
-R7S72100_SCIF(7, 0xe800a800, gic_iid(249));
 
-#define r7s72100_register_scif(index)                                         \
-       platform_device_register_resndata(&platform_bus, "sh-sci", index,      \
-                                         scif##index##_resources,             \
-                                         ARRAY_SIZE(scif##index##_resources), \
-                                         &scif##index##_platform_data,        \
-                                         sizeof(scif##index##_platform_data))
-
-
-static struct sh_timer_config mtu2_0_platform_data __initdata = {
-       .name = "MTU2_0",
-       .timer_bit = 0,
-       .channel_offset = -0x80,
-       .clockevent_rating = 200,
-};
-
-static struct resource mtu2_0_resources[] __initdata = {
-       DEFINE_RES_MEM(0xfcff0300, 0x27),
-       DEFINE_RES_IRQ(gic_iid(139)), /* MTU2 TGI0A */
-};
-
-#define r7s72100_register_mtu2(idx)                                    \
-       platform_device_register_resndata(&platform_bus, "sh_mtu2",     \
-                                         idx, mtu2_##idx##_resources,  \
-                                         ARRAY_SIZE(mtu2_##idx##_resources), \
-                                         &mtu2_##idx##_platform_data,  \
-                                         sizeof(struct sh_timer_config))
-
-void __init r7s72100_add_dt_devices(void)
-{
-       r7s72100_register_scif(0);
-       r7s72100_register_scif(1);
-       r7s72100_register_scif(2);
-       r7s72100_register_scif(3);
-       r7s72100_register_scif(4);
-       r7s72100_register_scif(5);
-       r7s72100_register_scif(6);
-       r7s72100_register_scif(7);
-       r7s72100_register_mtu2(0);
-}
+#include <asm/mach/arch.h>
 
-void __init r7s72100_init_early(void)
-{
-       shmobile_setup_delay(400, 1, 3); /* Cortex-A9 @ 400MHz */
-}
+#include "common.h"
 
-#ifdef CONFIG_USE_OF
 static const char *r7s72100_boards_compat_dt[] __initdata = {
        "renesas,r7s72100",
        NULL,
 };
 
 DT_MACHINE_START(R7S72100_DT, "Generic R7S72100 (Flattened Device Tree)")
-       .init_early     = r7s72100_init_early,
+       .init_early     = shmobile_init_delay,
+       .init_late      = shmobile_init_late,
        .dt_compat      = r7s72100_boards_compat_dt,
 MACHINE_END
-#endif /* CONFIG_USE_OF */
index cd36f80..eab6296 100644 (file)
 #include <linux/serial_sci.h>
 #include <linux/sh_dma.h>
 #include <linux/sh_timer.h>
-#include <mach/common.h>
-#include <mach/dma-register.h>
-#include <mach/irqs.h>
-#include <mach/r8a73a4.h>
+
 #include <asm/mach/arch.h>
 
+#include "common.h"
+#include "dma-register.h"
+#include "irqs.h"
+#include "r8a73a4.h"
+
 static const struct resource pfc_resources[] = {
        DEFINE_RES_MEM(0xe6050000, 0x9000),
 };
@@ -169,20 +171,17 @@ static const struct resource thermal0_resources[] = {
                                        thermal0_resources,             \
                                        ARRAY_SIZE(thermal0_resources))
 
-static struct sh_timer_config cmt10_platform_data = {
-       .name = "CMT10",
-       .timer_bit = 0,
-       .clockevent_rating = 80,
+static struct sh_timer_config cmt1_platform_data = {
+       .channels_mask = 0xff,
 };
 
-static struct resource cmt10_resources[] = {
-       DEFINE_RES_MEM(0xe6130010, 0x0c),
-       DEFINE_RES_MEM(0xe6130000, 0x04),
-       DEFINE_RES_IRQ(gic_spi(120)), /* CMT1_0 */
+static struct resource cmt1_resources[] = {
+       DEFINE_RES_MEM(0xe6130000, 0x1004),
+       DEFINE_RES_IRQ(gic_spi(120)),
 };
 
 #define r8a7790_register_cmt(idx)                                      \
-       platform_device_register_resndata(&platform_bus, "sh_cmt",      \
+       platform_device_register_resndata(&platform_bus, "sh-cmt-48-gen2", \
                                          idx, cmt##idx##_resources,    \
                                          ARRAY_SIZE(cmt##idx##_resources), \
                                          &cmt##idx##_platform_data,    \
@@ -190,13 +189,7 @@ static struct resource cmt10_resources[] = {
 
 void __init r8a73a4_add_dt_devices(void)
 {
-       r8a73a4_register_scif(0);
-       r8a73a4_register_scif(1);
-       r8a73a4_register_scif(2);
-       r8a73a4_register_scif(3);
-       r8a73a4_register_scif(4);
-       r8a73a4_register_scif(5);
-       r8a7790_register_cmt(10);
+       r8a7790_register_cmt(1);
 }
 
 /* DMA */
@@ -290,19 +283,18 @@ static struct resource dma_resources[] = {
 void __init r8a73a4_add_standard_devices(void)
 {
        r8a73a4_add_dt_devices();
+       r8a73a4_register_scif(0);
+       r8a73a4_register_scif(1);
+       r8a73a4_register_scif(2);
+       r8a73a4_register_scif(3);
+       r8a73a4_register_scif(4);
+       r8a73a4_register_scif(5);
        r8a73a4_register_irqc(0);
        r8a73a4_register_irqc(1);
        r8a73a4_register_thermal();
        r8a73a4_register_dmac();
 }
 
-void __init r8a73a4_init_early(void)
-{
-#ifndef CONFIG_ARM_ARCH_TIMER
-       shmobile_setup_delay(1500, 2, 4); /* Cortex-A15 @ 1500MHz */
-#endif
-}
-
 #ifdef CONFIG_USE_OF
 
 static const char *r8a73a4_boards_compat_dt[] __initdata = {
@@ -311,7 +303,8 @@ static const char *r8a73a4_boards_compat_dt[] __initdata = {
 };
 
 DT_MACHINE_START(R8A73A4_DT, "Generic R8A73A4 (Flattened Device Tree)")
-       .init_early     = r8a73a4_init_early,
+       .init_early     = shmobile_init_delay,
+       .init_late      = shmobile_init_late,
        .dt_compat      = r8a73a4_boards_compat_dt,
 MACHINE_END
 #endif /* CONFIG_USE_OF */
index 8f3c681..8894e1b 100644 (file)
 #include <linux/sh_dma.h>
 #include <linux/sh_timer.h>
 #include <linux/platform_data/sh_ipmmu.h>
-#include <mach/dma-register.h>
-#include <mach/r8a7740.h>
-#include <mach/pm-rmobile.h>
-#include <mach/common.h>
-#include <mach/irqs.h>
+
 #include <asm/mach-types.h>
 #include <asm/mach/map.h>
 #include <asm/mach/arch.h>
 #include <asm/mach/time.h>
+#include <asm/hardware/cache-l2x0.h>
+
+#include "common.h"
+#include "dma-register.h"
+#include "irqs.h"
+#include "pm-rmobile.h"
+#include "r8a7740.h"
 
 static struct map_desc r8a7740_io_desc[] __initdata = {
         /*
@@ -237,126 +240,45 @@ R8A7740_SCIF(PORT_SCIFA, 7, 0xe6cd0000, gic_spi(107));
 R8A7740_SCIF(PORT_SCIFB, 8, 0xe6c30000, gic_spi(108));
 
 /* CMT */
-static struct sh_timer_config cmt10_platform_data = {
-       .name = "CMT10",
-       .channel_offset = 0x10,
-       .timer_bit = 0,
-       .clockevent_rating = 125,
-       .clocksource_rating = 125,
+static struct sh_timer_config cmt1_platform_data = {
+       .channels_mask = 0x3f,
 };
 
-static struct resource cmt10_resources[] = {
-       [0] = {
-               .name   = "CMT10",
-               .start  = 0xe6138010,
-               .end    = 0xe613801b,
-               .flags  = IORESOURCE_MEM,
-       },
-       [1] = {
-               .start  = gic_spi(58),
-               .flags  = IORESOURCE_IRQ,
-       },
+static struct resource cmt1_resources[] = {
+       DEFINE_RES_MEM(0xe6138000, 0x170),
+       DEFINE_RES_IRQ(gic_spi(58)),
 };
 
-static struct platform_device cmt10_device = {
-       .name           = "sh_cmt",
-       .id             = 10,
+static struct platform_device cmt1_device = {
+       .name           = "sh-cmt-48",
+       .id             = 1,
        .dev = {
-               .platform_data  = &cmt10_platform_data,
+               .platform_data  = &cmt1_platform_data,
        },
-       .resource       = cmt10_resources,
-       .num_resources  = ARRAY_SIZE(cmt10_resources),
+       .resource       = cmt1_resources,
+       .num_resources  = ARRAY_SIZE(cmt1_resources),
 };
 
 /* TMU */
-static struct sh_timer_config tmu00_platform_data = {
-       .name = "TMU00",
-       .channel_offset = 0x4,
-       .timer_bit = 0,
-       .clockevent_rating = 200,
+static struct sh_timer_config tmu0_platform_data = {
+       .channels_mask = 7,
 };
 
-static struct resource tmu00_resources[] = {
-       [0] = {
-               .name   = "TMU00",
-               .start  = 0xfff80008,
-               .end    = 0xfff80014 - 1,
-               .flags  = IORESOURCE_MEM,
-       },
-       [1] = {
-               .start  = gic_spi(198),
-               .flags  = IORESOURCE_IRQ,
-       },
+static struct resource tmu0_resources[] = {
+       DEFINE_RES_MEM(0xfff80000, 0x2c),
+       DEFINE_RES_IRQ(gic_spi(198)),
+       DEFINE_RES_IRQ(gic_spi(199)),
+       DEFINE_RES_IRQ(gic_spi(200)),
 };
 
-static struct platform_device tmu00_device = {
-       .name           = "sh_tmu",
+static struct platform_device tmu0_device = {
+       .name           = "sh-tmu",
        .id             = 0,
        .dev = {
-               .platform_data  = &tmu00_platform_data,
-       },
-       .resource       = tmu00_resources,
-       .num_resources  = ARRAY_SIZE(tmu00_resources),
-};
-
-static struct sh_timer_config tmu01_platform_data = {
-       .name = "TMU01",
-       .channel_offset = 0x10,
-       .timer_bit = 1,
-       .clocksource_rating = 200,
-};
-
-static struct resource tmu01_resources[] = {
-       [0] = {
-               .name   = "TMU01",
-               .start  = 0xfff80014,
-               .end    = 0xfff80020 - 1,
-               .flags  = IORESOURCE_MEM,
-       },
-       [1] = {
-               .start  = gic_spi(199),
-               .flags  = IORESOURCE_IRQ,
-       },
-};
-
-static struct platform_device tmu01_device = {
-       .name           = "sh_tmu",
-       .id             = 1,
-       .dev = {
-               .platform_data  = &tmu01_platform_data,
-       },
-       .resource       = tmu01_resources,
-       .num_resources  = ARRAY_SIZE(tmu01_resources),
-};
-
-static struct sh_timer_config tmu02_platform_data = {
-       .name = "TMU02",
-       .channel_offset = 0x1C,
-       .timer_bit = 2,
-       .clocksource_rating = 200,
-};
-
-static struct resource tmu02_resources[] = {
-       [0] = {
-               .name   = "TMU02",
-               .start  = 0xfff80020,
-               .end    = 0xfff8002C - 1,
-               .flags  = IORESOURCE_MEM,
-       },
-       [1] = {
-               .start  = gic_spi(200),
-               .flags  = IORESOURCE_IRQ,
-       },
-};
-
-static struct platform_device tmu02_device = {
-       .name           = "sh_tmu",
-       .id             = 2,
-       .dev = {
-               .platform_data  = &tmu02_platform_data,
+               .platform_data  = &tmu0_platform_data,
        },
-       .resource       = tmu02_resources,
-       .num_resources  = ARRAY_SIZE(tmu02_resources),
+       .resource       = tmu0_resources,
+       .num_resources  = ARRAY_SIZE(tmu0_resources),
 };
 
 /* IPMMUI (an IPMMU module for ICB/LMB) */
@@ -390,7 +312,7 @@ static struct platform_device ipmmu_device = {
        .num_resources  = ARRAY_SIZE(ipmmu_resources),
 };
 
-static struct platform_device *r8a7740_devices_dt[] __initdata = {
+static struct platform_device *r8a7740_early_devices[] __initdata = {
        &scif0_device,
        &scif1_device,
        &scif2_device,
@@ -400,18 +322,13 @@ static struct platform_device *r8a7740_devices_dt[] __initdata = {
        &scif6_device,
        &scif7_device,
        &scif8_device,
-       &cmt10_device,
-};
-
-static struct platform_device *r8a7740_early_devices[] __initdata = {
        &irqpin0_device,
        &irqpin1_device,
        &irqpin2_device,
        &irqpin3_device,
-       &tmu00_device,
-       &tmu01_device,
-       &tmu02_device,
+       &tmu0_device,
        &ipmmu_device,
+       &cmt1_device,
 };
 
 /* DMA */
@@ -765,7 +682,7 @@ static struct platform_device *r8a7740_late_devices[] __initdata = {
  *     "Media RAM (MERAM)" on r8a7740 documentation
  */
 #define MEBUFCNTR      0xFE950098
-void r8a7740_meram_workaround(void)
+void __init r8a7740_meram_workaround(void)
 {
        void __iomem *reg;
 
@@ -828,6 +745,19 @@ static void r8a7740_i2c_workaround(struct platform_device *pdev)
 
 void __init r8a7740_add_standard_devices(void)
 {
+       static struct pm_domain_device domain_devices[] __initdata = {
+               { "A3SP", &scif0_device },
+               { "A3SP", &scif1_device },
+               { "A3SP", &scif2_device },
+               { "A3SP", &scif3_device },
+               { "A3SP", &scif4_device },
+               { "A3SP", &scif5_device },
+               { "A3SP", &scif6_device },
+               { "A3SP", &scif7_device },
+               { "A3SP", &scif8_device },
+               { "A3SP", &i2c1_device },
+       };
+
        /* I2C work-around */
        r8a7740_i2c_workaround(&i2c0_device);
        r8a7740_i2c_workaround(&i2c1_device);
@@ -837,31 +767,18 @@ void __init r8a7740_add_standard_devices(void)
        /* add devices */
        platform_add_devices(r8a7740_early_devices,
                            ARRAY_SIZE(r8a7740_early_devices));
-       platform_add_devices(r8a7740_devices_dt,
-                           ARRAY_SIZE(r8a7740_devices_dt));
        platform_add_devices(r8a7740_late_devices,
                             ARRAY_SIZE(r8a7740_late_devices));
 
        /* add devices to PM domain  */
-
-       rmobile_add_device_to_domain("A3SP",    &scif0_device);
-       rmobile_add_device_to_domain("A3SP",    &scif1_device);
-       rmobile_add_device_to_domain("A3SP",    &scif2_device);
-       rmobile_add_device_to_domain("A3SP",    &scif3_device);
-       rmobile_add_device_to_domain("A3SP",    &scif4_device);
-       rmobile_add_device_to_domain("A3SP",    &scif5_device);
-       rmobile_add_device_to_domain("A3SP",    &scif6_device);
-       rmobile_add_device_to_domain("A3SP",    &scif7_device);
-       rmobile_add_device_to_domain("A3SP",    &scif8_device);
-       rmobile_add_device_to_domain("A3SP",    &i2c1_device);
+       rmobile_add_devices_to_domains(domain_devices,
+                                      ARRAY_SIZE(domain_devices));
 }
 
 void __init r8a7740_add_early_devices(void)
 {
        early_platform_add_devices(r8a7740_early_devices,
                                   ARRAY_SIZE(r8a7740_early_devices));
-       early_platform_add_devices(r8a7740_devices_dt,
-                                  ARRAY_SIZE(r8a7740_devices_dt));
 
        /* setup early console here as well */
        shmobile_setup_console();
@@ -869,29 +786,6 @@ void __init r8a7740_add_early_devices(void)
 
 #ifdef CONFIG_USE_OF
 
-void __init r8a7740_add_early_devices_dt(void)
-{
-       shmobile_setup_delay(800, 1, 3); /* Cortex-A9 @ 800MHz */
-
-       early_platform_add_devices(r8a7740_early_devices,
-                                  ARRAY_SIZE(r8a7740_early_devices));
-
-       /* setup early console here as well */
-       shmobile_setup_console();
-}
-
-void __init r8a7740_add_standard_devices_dt(void)
-{
-       platform_add_devices(r8a7740_devices_dt,
-                           ARRAY_SIZE(r8a7740_devices_dt));
-       of_platform_populate(NULL, of_default_bus_match_table, NULL, NULL);
-}
-
-void __init r8a7740_init_delay(void)
-{
-       shmobile_setup_delay(800, 1, 3); /* Cortex-A9 @ 800MHz */
-};
-
 void __init r8a7740_init_irq_of(void)
 {
        void __iomem *intc_prio_base = ioremap_nocache(0xe6900010, 0x10);
@@ -924,8 +818,20 @@ void __init r8a7740_init_irq_of(void)
 
 static void __init r8a7740_generic_init(void)
 {
-       r8a7740_clock_init(0);
-       r8a7740_add_standard_devices_dt();
+       r8a7740_meram_workaround();
+
+#ifdef CONFIG_CACHE_L2X0
+       /* Shared attribute override enable, 32K*8way */
+       l2x0_init(IOMEM(0xf0002000), 0x00400000, 0xc20f0fff);
+#endif
+       of_platform_populate(NULL, of_default_bus_match_table, NULL, NULL);
+}
+
+#define RESCNT2 IOMEM(0xe6188020)
+static void r8a7740_restart(enum reboot_mode mode, const char *cmd)
+{
+       /* Do soft power on reset */
+       writel(1 << 31, RESCNT2);
 }
 
 static const char *r8a7740_boards_compat_dt[] __initdata = {
@@ -935,10 +841,12 @@ static const char *r8a7740_boards_compat_dt[] __initdata = {
 
 DT_MACHINE_START(R8A7740_DT, "Generic R8A7740 (Flattened Device Tree)")
        .map_io         = r8a7740_map_io,
-       .init_early     = r8a7740_init_delay,
+       .init_early     = shmobile_init_delay,
        .init_irq       = r8a7740_init_irq_of,
        .init_machine   = r8a7740_generic_init,
+       .init_late      = shmobile_init_late,
        .dt_compat      = r8a7740_boards_compat_dt,
+       .restart        = r8a7740_restart,
 MACHINE_END
 
 #endif /* CONFIG_USE_OF */
index 6d69452..7bba455 100644 (file)
 #include <linux/usb/ehci_pdriver.h>
 #include <linux/usb/ohci_pdriver.h>
 #include <linux/dma-mapping.h>
-#include <mach/irqs.h>
-#include <mach/r8a7778.h>
-#include <mach/common.h>
+
 #include <asm/mach/arch.h>
 #include <asm/hardware/cache-l2x0.h>
 
+#include "common.h"
+#include "irqs.h"
+#include "r8a7778.h"
+
 /* SCIF */
 #define R8A7778_SCIF(index, baseaddr, irq)                     \
 static struct plat_sci_port scif##index##_platform_data = {    \
@@ -71,33 +73,20 @@ R8A7778_SCIF(5, 0xffe45000, gic_iid(0x6b));
                                          sizeof(scif##index##_platform_data))
 
 /* TMU */
-static struct resource sh_tmu0_resources[] __initdata = {
-       DEFINE_RES_MEM(0xffd80008, 12),
-       DEFINE_RES_IRQ(gic_iid(0x40)),
-};
-
-static struct sh_timer_config sh_tmu0_platform_data __initdata = {
-       .name                   = "TMU00",
-       .channel_offset         = 0x4,
-       .timer_bit              = 0,
-       .clockevent_rating      = 200,
+static struct sh_timer_config sh_tmu0_platform_data = {
+       .channels_mask = 7,
 };
 
-static struct resource sh_tmu1_resources[] __initdata = {
-       DEFINE_RES_MEM(0xffd80014, 12),
+static struct resource sh_tmu0_resources[] = {
+       DEFINE_RES_MEM(0xffd80000, 0x30),
+       DEFINE_RES_IRQ(gic_iid(0x40)),
        DEFINE_RES_IRQ(gic_iid(0x41)),
-};
-
-static struct sh_timer_config sh_tmu1_platform_data __initdata = {
-       .name                   = "TMU01",
-       .channel_offset         = 0x10,
-       .timer_bit              = 1,
-       .clocksource_rating     = 200,
+       DEFINE_RES_IRQ(gic_iid(0x42)),
 };
 
 #define r8a7778_register_tmu(idx)                      \
        platform_device_register_resndata(              \
-               &platform_bus, "sh_tmu", idx,           \
+               &platform_bus, "sh-tmu", idx,           \
                sh_tmu##idx##_resources,                \
                ARRAY_SIZE(sh_tmu##idx##_resources),    \
                &sh_tmu##idx##_platform_data,           \
@@ -305,14 +294,7 @@ void __init r8a7778_add_dt_devices(void)
        }
 #endif
 
-       r8a7778_register_scif(0);
-       r8a7778_register_scif(1);
-       r8a7778_register_scif(2);
-       r8a7778_register_scif(3);
-       r8a7778_register_scif(4);
-       r8a7778_register_scif(5);
        r8a7778_register_tmu(0);
-       r8a7778_register_tmu(1);
 }
 
 /* HPB-DMA */
@@ -520,6 +502,12 @@ static void __init r8a7778_register_hpb_dmae(void)
 void __init r8a7778_add_standard_devices(void)
 {
        r8a7778_add_dt_devices();
+       r8a7778_register_scif(0);
+       r8a7778_register_scif(1);
+       r8a7778_register_scif(2);
+       r8a7778_register_scif(3);
+       r8a7778_register_scif(4);
+       r8a7778_register_scif(5);
        r8a7778_register_i2c(0);
        r8a7778_register_i2c(1);
        r8a7778_register_i2c(2);
@@ -533,6 +521,7 @@ void __init r8a7778_add_standard_devices(void)
 
 void __init r8a7778_init_late(void)
 {
+       shmobile_init_late();
        platform_device_register_full(&ehci_info);
        platform_device_register_full(&ohci_info);
 }
@@ -586,7 +575,7 @@ void __init r8a7778_init_irq_extpin(int irlm)
 
 void __init r8a7778_init_delay(void)
 {
-       shmobile_setup_delay(800, 1, 3); /* Cortex-A9 @ 800MHz */
+       shmobile_init_delay();
 }
 
 #ifdef CONFIG_USE_OF
@@ -622,8 +611,8 @@ static const char *r8a7778_compat_dt[] __initdata = {
 DT_MACHINE_START(R8A7778_DT, "Generic R8A7778 (Flattened Device Tree)")
        .init_early     = r8a7778_init_delay,
        .init_irq       = r8a7778_init_irq_dt,
+       .init_late      = shmobile_init_late,
        .dt_compat      = r8a7778_compat_dt,
-       .init_late      = r8a7778_init_late,
 MACHINE_END
 
 #endif /* CONFIG_USE_OF */
index 8e860b3..e20fcf3 100644 (file)
 #include <linux/usb/ehci_pdriver.h>
 #include <linux/usb/ohci_pdriver.h>
 #include <linux/pm_runtime.h>
-#include <mach/irqs.h>
-#include <mach/r8a7779.h>
-#include <mach/common.h>
+
 #include <asm/mach-types.h>
 #include <asm/mach/arch.h>
 #include <asm/mach/time.h>
 #include <asm/mach/map.h>
 #include <asm/hardware/cache-l2x0.h>
 
+#include "common.h"
+#include "irqs.h"
+#include "r8a7779.h"
+
 static struct map_desc r8a7779_io_desc[] __initdata = {
        /* 2M entity map for 0xf0000000 (MPCORE) */
        {
@@ -219,64 +221,25 @@ R8A7779_SCIF(4, 0xffe44000, gic_iid(0x7c));
 R8A7779_SCIF(5, 0xffe45000, gic_iid(0x7d));
 
 /* TMU */
-static struct sh_timer_config tmu00_platform_data = {
-       .name = "TMU00",
-       .channel_offset = 0x4,
-       .timer_bit = 0,
-       .clockevent_rating = 200,
+static struct sh_timer_config tmu0_platform_data = {
+       .channels_mask = 7,
 };
 
-static struct resource tmu00_resources[] = {
-       [0] = {
-               .name   = "TMU00",
-               .start  = 0xffd80008,
-               .end    = 0xffd80013,
-               .flags  = IORESOURCE_MEM,
-       },
-       [1] = {
-               .start  = gic_iid(0x40),
-               .flags  = IORESOURCE_IRQ,
-       },
+static struct resource tmu0_resources[] = {
+       DEFINE_RES_MEM(0xffd80000, 0x30),
+       DEFINE_RES_IRQ(gic_iid(0x40)),
+       DEFINE_RES_IRQ(gic_iid(0x41)),
+       DEFINE_RES_IRQ(gic_iid(0x42)),
 };
 
-static struct platform_device tmu00_device = {
-       .name           = "sh_tmu",
+static struct platform_device tmu0_device = {
+       .name           = "sh-tmu",
        .id             = 0,
        .dev = {
-               .platform_data  = &tmu00_platform_data,
-       },
-       .resource       = tmu00_resources,
-       .num_resources  = ARRAY_SIZE(tmu00_resources),
-};
-
-static struct sh_timer_config tmu01_platform_data = {
-       .name = "TMU01",
-       .channel_offset = 0x10,
-       .timer_bit = 1,
-       .clocksource_rating = 200,
-};
-
-static struct resource tmu01_resources[] = {
-       [0] = {
-               .name   = "TMU01",
-               .start  = 0xffd80014,
-               .end    = 0xffd8001f,
-               .flags  = IORESOURCE_MEM,
-       },
-       [1] = {
-               .start  = gic_iid(0x41),
-               .flags  = IORESOURCE_IRQ,
-       },
-};
-
-static struct platform_device tmu01_device = {
-       .name           = "sh_tmu",
-       .id             = 1,
-       .dev = {
-               .platform_data  = &tmu01_platform_data,
+               .platform_data  = &tmu0_platform_data,
        },
-       .resource       = tmu01_resources,
-       .num_resources  = ARRAY_SIZE(tmu01_resources),
+       .resource       = tmu0_resources,
+       .num_resources  = ARRAY_SIZE(tmu0_resources),
 };
 
 /* I2C */
@@ -678,18 +641,17 @@ static void __init r8a7779_register_hpb_dmae(void)
                                          sizeof(dma_platform_data));
 }
 
-static struct platform_device *r8a7779_devices_dt[] __initdata = {
+static struct platform_device *r8a7779_early_devices[] __initdata = {
+       &tmu0_device,
+};
+
+static struct platform_device *r8a7779_standard_devices[] __initdata = {
        &scif0_device,
        &scif1_device,
        &scif2_device,
        &scif3_device,
        &scif4_device,
        &scif5_device,
-       &tmu00_device,
-       &tmu01_device,
-};
-
-static struct platform_device *r8a7779_standard_devices[] __initdata = {
        &i2c0_device,
        &i2c1_device,
        &i2c2_device,
@@ -707,27 +669,17 @@ void __init r8a7779_add_standard_devices(void)
 
        r8a7779_init_pm_domains();
 
-       platform_add_devices(r8a7779_devices_dt,
-                           ARRAY_SIZE(r8a7779_devices_dt));
+       platform_add_devices(r8a7779_early_devices,
+                           ARRAY_SIZE(r8a7779_early_devices));
        platform_add_devices(r8a7779_standard_devices,
                            ARRAY_SIZE(r8a7779_standard_devices));
        r8a7779_register_hpb_dmae();
 }
 
-/* do nothing for !CONFIG_SMP or !CONFIG_HAVE_TWD */
-void __init __weak r8a7779_register_twd(void) { }
-
-void __init r8a7779_earlytimer_init(void)
-{
-       r8a7779_clock_init();
-       r8a7779_register_twd();
-       shmobile_earlytimer_init();
-}
-
 void __init r8a7779_add_early_devices(void)
 {
-       early_platform_add_devices(r8a7779_devices_dt,
-                                  ARRAY_SIZE(r8a7779_devices_dt));
+       early_platform_add_devices(r8a7779_early_devices,
+                                  ARRAY_SIZE(r8a7779_early_devices));
 
        /* Early serial console setup is not included here due to
         * memory map collisions. The SCIF serial ports in r8a7779
@@ -787,19 +739,22 @@ void __init r8a7779_init_irq_dt(void)
        __raw_writel(0x003fee3f, INT2SMSKCR4);
 }
 
-void __init r8a7779_init_delay(void)
-{
-       shmobile_setup_delay(1000, 2, 4); /* Cortex-A9 @ 1000MHz */
-}
+#define MODEMR         0xffcc0020
 
-void __init r8a7779_add_standard_devices_dt(void)
+u32 __init r8a7779_read_mode_pins(void)
 {
-       /* clocks are setup late during boot in the case of DT */
-       r8a7779_clock_init();
+       static u32 mode;
+       static bool mode_valid;
+
+       if (!mode_valid) {
+               void __iomem *modemr = ioremap_nocache(MODEMR, PAGE_SIZE);
+               BUG_ON(!modemr);
+               mode = ioread32(modemr);
+               iounmap(modemr);
+               mode_valid = true;
+       }
 
-       platform_add_devices(r8a7779_devices_dt,
-                            ARRAY_SIZE(r8a7779_devices_dt));
-       of_platform_populate(NULL, of_default_bus_match_table, NULL, NULL);
+       return mode;
 }
 
 static const char *r8a7779_compat_dt[] __initdata = {
@@ -809,11 +764,9 @@ static const char *r8a7779_compat_dt[] __initdata = {
 
 DT_MACHINE_START(R8A7779_DT, "Generic R8A7779 (Flattened Device Tree)")
        .map_io         = r8a7779_map_io,
-       .init_early     = r8a7779_init_delay,
-       .nr_irqs        = NR_IRQS_LEGACY,
+       .init_early     = shmobile_init_delay,
        .init_irq       = r8a7779_init_irq_dt,
-       .init_machine   = r8a7779_add_standard_devices_dt,
-       .init_late      = r8a7779_init_late,
+       .init_late      = shmobile_init_late,
        .dt_compat      = r8a7779_compat_dt,
 MACHINE_END
 #endif /* CONFIG_USE_OF */
index 6ab37aa..4795c98 100644 (file)
 #include <linux/platform_data/gpio-rcar.h>
 #include <linux/platform_data/irq-renesas-irqc.h>
 #include <linux/serial_sci.h>
+#include <linux/sh_dma.h>
 #include <linux/sh_timer.h>
-#include <mach/common.h>
-#include <mach/irqs.h>
-#include <mach/r8a7790.h>
+
 #include <asm/mach/arch.h>
 
+#include "common.h"
+#include "dma-register.h"
+#include "irqs.h"
+#include "r8a7790.h"
+#include "rcar-gen2.h"
+
+/* Audio-DMAC */
+#define AUDIO_DMAC_SLAVE(_id, _addr, t, r)                     \
+{                                                              \
+       .slave_id       = AUDIO_DMAC_SLAVE_## _id ##_TX,        \
+       .addr           = _addr + 0x8,                          \
+       .chcr           = CHCR_TX(XMIT_SZ_32BIT),               \
+       .mid_rid        = t,                                    \
+}, {                                                           \
+       .slave_id       = AUDIO_DMAC_SLAVE_## _id ##_RX,        \
+       .addr           = _addr + 0xc,                          \
+       .chcr           = CHCR_RX(XMIT_SZ_32BIT),               \
+       .mid_rid        = r,                                    \
+}
+
+static const struct sh_dmae_slave_config r8a7790_audio_dmac_slaves[] = {
+       AUDIO_DMAC_SLAVE(SSI0, 0xec241000, 0x01, 0x02),
+       AUDIO_DMAC_SLAVE(SSI1, 0xec241040, 0x03, 0x04),
+       AUDIO_DMAC_SLAVE(SSI2, 0xec241080, 0x05, 0x06),
+       AUDIO_DMAC_SLAVE(SSI3, 0xec2410c0, 0x07, 0x08),
+       AUDIO_DMAC_SLAVE(SSI4, 0xec241100, 0x09, 0x0a),
+       AUDIO_DMAC_SLAVE(SSI5, 0xec241140, 0x0b, 0x0c),
+       AUDIO_DMAC_SLAVE(SSI6, 0xec241180, 0x0d, 0x0e),
+       AUDIO_DMAC_SLAVE(SSI7, 0xec2411c0, 0x0f, 0x10),
+       AUDIO_DMAC_SLAVE(SSI8, 0xec241200, 0x11, 0x12),
+       AUDIO_DMAC_SLAVE(SSI9, 0xec241240, 0x13, 0x14),
+};
+
+#define DMAE_CHANNEL(a, b)                     \
+{                                              \
+       .offset         = (a) - 0x20,           \
+       .dmars          = (a) - 0x20 + 0x40,    \
+       .chclr_bit      = (b),                  \
+       .chclr_offset   = 0x80 - 0x20,          \
+}
+
+static const struct sh_dmae_channel r8a7790_audio_dmac_channels[] = {
+       DMAE_CHANNEL(0x8000, 0),
+       DMAE_CHANNEL(0x8080, 1),
+       DMAE_CHANNEL(0x8100, 2),
+       DMAE_CHANNEL(0x8180, 3),
+       DMAE_CHANNEL(0x8200, 4),
+       DMAE_CHANNEL(0x8280, 5),
+       DMAE_CHANNEL(0x8300, 6),
+       DMAE_CHANNEL(0x8380, 7),
+       DMAE_CHANNEL(0x8400, 8),
+       DMAE_CHANNEL(0x8480, 9),
+       DMAE_CHANNEL(0x8500, 10),
+       DMAE_CHANNEL(0x8580, 11),
+       DMAE_CHANNEL(0x8600, 12),
+};
+
+static struct sh_dmae_pdata r8a7790_audio_dmac_platform_data = {
+       .slave          = r8a7790_audio_dmac_slaves,
+       .slave_num      = ARRAY_SIZE(r8a7790_audio_dmac_slaves),
+       .channel        = r8a7790_audio_dmac_channels,
+       .channel_num    = ARRAY_SIZE(r8a7790_audio_dmac_channels),
+       .ts_low_shift   = TS_LOW_SHIFT,
+       .ts_low_mask    = TS_LOW_BIT << TS_LOW_SHIFT,
+       .ts_high_shift  = TS_HI_SHIFT,
+       .ts_high_mask   = TS_HI_BIT << TS_HI_SHIFT,
+       .ts_shift       = dma_ts_shift,
+       .ts_shift_num   = ARRAY_SIZE(dma_ts_shift),
+       .dmaor_init     = DMAOR_DME,
+       .chclr_present  = 1,
+       .chclr_bitwise  = 1,
+};
+
+static struct resource r8a7790_audio_dmac_resources[] = {
+       /* Channel registers and DMAOR for low */
+       DEFINE_RES_MEM(0xec700020, 0x8663 - 0x20),
+       DEFINE_RES_IRQ(gic_spi(346)),
+       DEFINE_RES_NAMED(gic_spi(320), 13, NULL, IORESOURCE_IRQ),
+
+       /* Channel registers and DMAOR for hi */
+       DEFINE_RES_MEM(0xec720020, 0x8663 - 0x20), /* hi */
+       DEFINE_RES_IRQ(gic_spi(347)),
+       DEFINE_RES_NAMED(gic_spi(333), 13, NULL, IORESOURCE_IRQ),
+};
+
+#define r8a7790_register_audio_dmac(id)                                \
+       platform_device_register_resndata(                      \
+               &platform_bus, "sh-dma-engine", id,             \
+               &r8a7790_audio_dmac_resources[id * 3],  3,      \
+               &r8a7790_audio_dmac_platform_data,              \
+               sizeof(r8a7790_audio_dmac_platform_data))
+
 static const struct resource pfc_resources[] __initconst = {
        DEFINE_RES_MEM(0xe6060000, 0x250),
 };
@@ -97,10 +188,6 @@ void __init r8a7790_pinmux_init(void)
        r8a7790_register_gpio(3);
        r8a7790_register_gpio(4);
        r8a7790_register_gpio(5);
-       r8a7790_register_i2c(0);
-       r8a7790_register_i2c(1);
-       r8a7790_register_i2c(2);
-       r8a7790_register_i2c(3);
 }
 
 #define __R8A7790_SCIF(scif_type, _scscr, index, baseaddr, irq)                \
@@ -179,26 +266,23 @@ static const struct resource thermal_resources[] __initconst = {
                                        thermal_resources,              \
                                        ARRAY_SIZE(thermal_resources))
 
-static const struct sh_timer_config cmt00_platform_data __initconst = {
-       .name = "CMT00",
-       .timer_bit = 0,
-       .clockevent_rating = 80,
+static struct sh_timer_config cmt0_platform_data = {
+       .channels_mask = 0x60,
 };
 
-static const struct resource cmt00_resources[] __initconst = {
-       DEFINE_RES_MEM(0xffca0510, 0x0c),
-       DEFINE_RES_MEM(0xffca0500, 0x04),
-       DEFINE_RES_IRQ(gic_spi(142)), /* CMT0_0 */
+static struct resource cmt0_resources[] = {
+       DEFINE_RES_MEM(0xffca0000, 0x1004),
+       DEFINE_RES_IRQ(gic_spi(142)),
 };
 
 #define r8a7790_register_cmt(idx)                                      \
-       platform_device_register_resndata(&platform_bus, "sh_cmt",      \
+       platform_device_register_resndata(&platform_bus, "sh-cmt-48-gen2", \
                                          idx, cmt##idx##_resources,    \
                                          ARRAY_SIZE(cmt##idx##_resources), \
                                          &cmt##idx##_platform_data,    \
                                          sizeof(struct sh_timer_config))
 
-void __init r8a7790_add_dt_devices(void)
+void __init r8a7790_add_standard_devices(void)
 {
        r8a7790_register_scif(0);
        r8a7790_register_scif(1);
@@ -210,21 +294,15 @@ void __init r8a7790_add_dt_devices(void)
        r8a7790_register_scif(7);
        r8a7790_register_scif(8);
        r8a7790_register_scif(9);
-       r8a7790_register_cmt(00);
-}
-
-void __init r8a7790_add_standard_devices(void)
-{
-       r8a7790_add_dt_devices();
+       r8a7790_register_cmt(0);
        r8a7790_register_irqc(0);
        r8a7790_register_thermal();
-}
-
-void __init r8a7790_init_early(void)
-{
-#ifndef CONFIG_ARM_ARCH_TIMER
-       shmobile_setup_delay(1300, 2, 4); /* Cortex-A15 @ 1300MHz */
-#endif
+       r8a7790_register_i2c(0);
+       r8a7790_register_i2c(1);
+       r8a7790_register_i2c(2);
+       r8a7790_register_i2c(3);
+       r8a7790_register_audio_dmac(0);
+       r8a7790_register_audio_dmac(1);
 }
 
 #ifdef CONFIG_USE_OF
@@ -236,8 +314,10 @@ static const char * const r8a7790_boards_compat_dt[] __initconst = {
 
 DT_MACHINE_START(R8A7790_DT, "Generic R8A7790 (Flattened Device Tree)")
        .smp            = smp_ops(r8a7790_smp_ops),
-       .init_early     = r8a7790_init_early,
+       .init_early     = shmobile_init_delay,
        .init_time      = rcar_gen2_timer_init,
+       .init_late      = shmobile_init_late,
+       .reserve        = rcar_gen2_reserve,
        .dt_compat      = r8a7790_boards_compat_dt,
 MACHINE_END
 #endif /* CONFIG_USE_OF */
index e28404e..64cb1d7 100644 (file)
 #include <linux/platform_data/irq-renesas-irqc.h>
 #include <linux/serial_sci.h>
 #include <linux/sh_timer.h>
-#include <mach/common.h>
-#include <mach/irqs.h>
-#include <mach/r8a7791.h>
-#include <mach/rcar-gen2.h>
+
 #include <asm/mach/arch.h>
 
+#include "common.h"
+#include "irqs.h"
+#include "r8a7791.h"
+#include "rcar-gen2.h"
+
 static const struct resource pfc_resources[] __initconst = {
        DEFINE_RES_MEM(0xe6060000, 0x250),
 };
@@ -128,20 +130,17 @@ R8A7791_SCIFA(14, 0xe6c80000, gic_spi(31)); /* SCIFA5 */
                                          &scif##index##_platform_data,        \
                                          sizeof(scif##index##_platform_data))
 
-static const struct sh_timer_config cmt00_platform_data __initconst = {
-       .name = "CMT00",
-       .timer_bit = 0,
-       .clockevent_rating = 80,
+static struct sh_timer_config cmt0_platform_data = {
+       .channels_mask = 0x60,
 };
 
-static const struct resource cmt00_resources[] __initconst = {
-       DEFINE_RES_MEM(0xffca0510, 0x0c),
-       DEFINE_RES_MEM(0xffca0500, 0x04),
-       DEFINE_RES_IRQ(gic_spi(142)), /* CMT0_0 */
+static struct resource cmt0_resources[] = {
+       DEFINE_RES_MEM(0xffca0000, 0x1004),
+       DEFINE_RES_IRQ(gic_spi(142)),
 };
 
 #define r8a7791_register_cmt(idx)                                      \
-       platform_device_register_resndata(&platform_bus, "sh_cmt",      \
+       platform_device_register_resndata(&platform_bus, "sh-cmt-48-gen2", \
                                          idx, cmt##idx##_resources,    \
                                          ARRAY_SIZE(cmt##idx##_resources), \
                                          &cmt##idx##_platform_data,    \
@@ -183,7 +182,7 @@ static const struct resource thermal_resources[] __initconst = {
                                        thermal_resources,              \
                                        ARRAY_SIZE(thermal_resources))
 
-void __init r8a7791_add_dt_devices(void)
+void __init r8a7791_add_standard_devices(void)
 {
        r8a7791_register_scif(0);
        r8a7791_register_scif(1);
@@ -200,23 +199,11 @@ void __init r8a7791_add_dt_devices(void)
        r8a7791_register_scif(12);
        r8a7791_register_scif(13);
        r8a7791_register_scif(14);
-       r8a7791_register_cmt(00);
-}
-
-void __init r8a7791_add_standard_devices(void)
-{
-       r8a7791_add_dt_devices();
+       r8a7791_register_cmt(0);
        r8a7791_register_irqc(0);
        r8a7791_register_thermal();
 }
 
-void __init r8a7791_init_early(void)
-{
-#ifndef CONFIG_ARM_ARCH_TIMER
-       shmobile_setup_delay(1300, 2, 4); /* Cortex-A15 @ 1300MHz */
-#endif
-}
-
 #ifdef CONFIG_USE_OF
 static const char *r8a7791_boards_compat_dt[] __initdata = {
        "renesas,r8a7791",
@@ -225,8 +212,10 @@ static const char *r8a7791_boards_compat_dt[] __initdata = {
 
 DT_MACHINE_START(R8A7791_DT, "Generic R8A7791 (Flattened Device Tree)")
        .smp            = smp_ops(r8a7791_smp_ops),
-       .init_early     = r8a7791_init_early,
+       .init_early     = shmobile_init_delay,
        .init_time      = rcar_gen2_timer_init,
+       .init_late      = shmobile_init_late,
+       .reserve        = rcar_gen2_reserve,
        .dt_compat      = r8a7791_boards_compat_dt,
 MACHINE_END
 #endif /* CONFIG_USE_OF */
diff --git a/arch/arm/mach-shmobile/setup-r8a7794.c b/arch/arm/mach-shmobile/setup-r8a7794.c
new file mode 100644 (file)
index 0000000..d2b0930
--- /dev/null
@@ -0,0 +1,33 @@
+/*
+ * r8a7794 processor support
+ *
+ * Copyright (C) 2014  Renesas Electronics Corporation
+ * Copyright (C) 2014  Ulrich Hecht
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; version 2 of the License.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ */
+
+#include <linux/of_platform.h>
+#include "common.h"
+#include "rcar-gen2.h"
+#include <asm/mach/arch.h>
+
+static const char * const r8a7794_boards_compat_dt[] __initconst = {
+       "renesas,r8a7794",
+       NULL,
+};
+
+DT_MACHINE_START(R8A7794_DT, "Generic R8A7794 (Flattened Device Tree)")
+       .init_early     = shmobile_init_delay,
+       .init_late      = shmobile_init_late,
+       .init_time      = rcar_gen2_timer_init,
+       .reserve        = rcar_gen2_reserve,
+       .dt_compat      = r8a7794_boards_compat_dt,
+MACHINE_END
index 69ccc6c..73fb2a6 100644 (file)
 
 #include <linux/clk/shmobile.h>
 #include <linux/clocksource.h>
+#include <linux/device.h>
+#include <linux/dma-contiguous.h>
 #include <linux/io.h>
 #include <linux/kernel.h>
-#include <mach/common.h>
-#include <mach/rcar-gen2.h>
+#include <linux/of_fdt.h>
 #include <asm/mach/arch.h>
+#include "common.h"
+#include "rcar-gen2.h"
 
 #define MODEMR 0xe6160060
 
-u32 __init rcar_gen2_read_mode_pins(void)
+u32 rcar_gen2_read_mode_pins(void)
 {
-       void __iomem *modemr = ioremap_nocache(MODEMR, 4);
-       u32 mode;
-
-       BUG_ON(!modemr);
-       mode = ioread32(modemr);
-       iounmap(modemr);
+       static u32 mode;
+       static bool mode_valid;
+
+       if (!mode_valid) {
+               void __iomem *modemr = ioremap_nocache(MODEMR, 4);
+               BUG_ON(!modemr);
+               mode = ioread32(modemr);
+               iounmap(modemr);
+               mode_valid = true;
+       }
 
        return mode;
 }
@@ -106,3 +113,72 @@ void __init rcar_gen2_timer_init(void)
 #endif
        clocksource_of_init();
 }
+
+struct memory_reserve_config {
+       u64 reserved;
+       u64 base, size;
+};
+
+static int __init rcar_gen2_scan_mem(unsigned long node, const char *uname,
+                                    int depth, void *data)
+{
+       const char *type = of_get_flat_dt_prop(node, "device_type", NULL);
+       const __be32 *reg, *endp;
+       int l;
+       struct memory_reserve_config *mrc = data;
+       u64 lpae_start = 1ULL << 32;
+
+       /* We are scanning "memory" nodes only */
+       if (type == NULL || strcmp(type, "memory"))
+               return 0;
+
+       reg = of_get_flat_dt_prop(node, "linux,usable-memory", &l);
+       if (reg == NULL)
+               reg = of_get_flat_dt_prop(node, "reg", &l);
+       if (reg == NULL)
+               return 0;
+
+       endp = reg + (l / sizeof(__be32));
+       while ((endp - reg) >= (dt_root_addr_cells + dt_root_size_cells)) {
+               u64 base, size;
+
+               base = dt_mem_next_cell(dt_root_addr_cells, &reg);
+               size = dt_mem_next_cell(dt_root_size_cells, &reg);
+
+               if (base >= lpae_start)
+                       continue;
+
+               if ((base + size) >= lpae_start)
+                       size = lpae_start - base;
+
+               if (size < mrc->reserved)
+                       continue;
+
+               if (base < mrc->base)
+                       continue;
+
+               /* keep the area at top near the 32-bit legacy limit */
+               mrc->base = base + size - mrc->reserved;
+               mrc->size = mrc->reserved;
+       }
+
+       return 0;
+}
+
+struct cma *rcar_gen2_dma_contiguous;
+
+void __init rcar_gen2_reserve(void)
+{
+       struct memory_reserve_config mrc;
+
+       /* reserve 256 MiB at the top of the physical legacy 32-bit space */
+       memset(&mrc, 0, sizeof(mrc));
+       mrc.reserved = SZ_256M;
+
+       of_scan_flat_dt(rcar_gen2_scan_mem, &mrc);
+#ifdef CONFIG_DMA_CMA
+       if (mrc.size)
+               dma_contiguous_reserve_area(mrc.size, mrc.base, 0,
+                                           &rcar_gen2_dma_contiguous);
+#endif
+}
index 2730127..d646c8d 100644 (file)
 #include <linux/io.h>
 #include <linux/serial_sci.h>
 #include <linux/sh_dma.h>
-#include <linux/sh_intc.h>
 #include <linux/sh_timer.h>
 #include <linux/pm_domain.h>
 #include <linux/dma-mapping.h>
 #include <linux/platform_data/sh_ipmmu.h>
-#include <mach/dma-register.h>
-#include <mach/irqs.h>
-#include <mach/sh7372.h>
-#include <mach/common.h>
+
 #include <asm/mach/map.h>
 #include <asm/mach-types.h>
 #include <asm/mach/arch.h>
 #include <asm/mach/time.h>
 
+#include "common.h"
+#include "dma-register.h"
+#include "intc.h"
+#include "irqs.h"
+#include "pm-rmobile.h"
+#include "sh7372.h"
+
 static struct map_desc sh7372_io_desc[] __initdata = {
        /* create a 1:1 entity map for 0xe6xxxxxx
         * used by CPGA, INTC and PFC.
@@ -119,28 +122,16 @@ SH7372_SCIF(PORT_SCIFB, 6, 0xe6c30000, evt2irq(0x0d60));
 
 /* CMT */
 static struct sh_timer_config cmt2_platform_data = {
-       .name = "CMT2",
-       .channel_offset = 0x40,
-       .timer_bit = 5,
-       .clockevent_rating = 125,
-       .clocksource_rating = 125,
+       .channels_mask = 0x20,
 };
 
 static struct resource cmt2_resources[] = {
-       [0] = {
-               .name   = "CMT2",
-               .start  = 0xe6130040,
-               .end    = 0xe613004b,
-               .flags  = IORESOURCE_MEM,
-       },
-       [1] = {
-               .start  = evt2irq(0x0b80), /* CMT2 */
-               .flags  = IORESOURCE_IRQ,
-       },
+       DEFINE_RES_MEM(0xe6130000, 0x50),
+       DEFINE_RES_IRQ(evt2irq(0x0b80)),
 };
 
 static struct platform_device cmt2_device = {
-       .name           = "sh_cmt",
+       .name           = "sh-cmt-32-fast",
        .id             = 2,
        .dev = {
                .platform_data  = &cmt2_platform_data,
@@ -150,64 +141,25 @@ static struct platform_device cmt2_device = {
 };
 
 /* TMU */
-static struct sh_timer_config tmu00_platform_data = {
-       .name = "TMU00",
-       .channel_offset = 0x4,
-       .timer_bit = 0,
-       .clockevent_rating = 200,
+static struct sh_timer_config tmu0_platform_data = {
+       .channels_mask = 7,
 };
 
-static struct resource tmu00_resources[] = {
-       [0] = {
-               .name   = "TMU00",
-               .start  = 0xfff60008,
-               .end    = 0xfff60013,
-               .flags  = IORESOURCE_MEM,
-       },
-       [1] = {
-               .start  = intcs_evt2irq(0xe80), /* TMU_TUNI0 */
-               .flags  = IORESOURCE_IRQ,
-       },
+static struct resource tmu0_resources[] = {
+       DEFINE_RES_MEM(0xfff60000, 0x2c),
+       DEFINE_RES_IRQ(intcs_evt2irq(0xe80)),
+       DEFINE_RES_IRQ(intcs_evt2irq(0xea0)),
+       DEFINE_RES_IRQ(intcs_evt2irq(0xec0)),
 };
 
-static struct platform_device tmu00_device = {
-       .name           = "sh_tmu",
+static struct platform_device tmu0_device = {
+       .name           = "sh-tmu",
        .id             = 0,
        .dev = {
-               .platform_data  = &tmu00_platform_data,
-       },
-       .resource       = tmu00_resources,
-       .num_resources  = ARRAY_SIZE(tmu00_resources),
-};
-
-static struct sh_timer_config tmu01_platform_data = {
-       .name = "TMU01",
-       .channel_offset = 0x10,
-       .timer_bit = 1,
-       .clocksource_rating = 200,
-};
-
-static struct resource tmu01_resources[] = {
-       [0] = {
-               .name   = "TMU01",
-               .start  = 0xfff60014,
-               .end    = 0xfff6001f,
-               .flags  = IORESOURCE_MEM,
-       },
-       [1] = {
-               .start  = intcs_evt2irq(0xea0), /* TMU_TUNI1 */
-               .flags  = IORESOURCE_IRQ,
-       },
-};
-
-static struct platform_device tmu01_device = {
-       .name           = "sh_tmu",
-       .id             = 1,
-       .dev = {
-               .platform_data  = &tmu01_platform_data,
+               .platform_data  = &tmu0_platform_data,
        },
-       .resource       = tmu01_resources,
-       .num_resources  = ARRAY_SIZE(tmu01_resources),
+       .resource       = tmu0_resources,
+       .num_resources  = ARRAY_SIZE(tmu0_resources),
 };
 
 /* I2C */
@@ -952,8 +904,7 @@ static struct platform_device *sh7372_early_devices[] __initdata = {
        &scif5_device,
        &scif6_device,
        &cmt2_device,
-       &tmu00_device,
-       &tmu01_device,
+       &tmu0_device,
        &ipmmu_device,
 };
 
@@ -977,7 +928,7 @@ static struct platform_device *sh7372_late_devices[] __initdata = {
 
 void __init sh7372_add_standard_devices(void)
 {
-       struct pm_domain_device domain_devices[] = {
+       static struct pm_domain_device domain_devices[] __initdata = {
                { "A3RV", &vpu_device, },
                { "A4MP", &spu0_device, },
                { "A4MP", &spu1_device, },
@@ -1000,8 +951,7 @@ void __init sh7372_add_standard_devices(void)
                { "A4R", &veu2_device, },
                { "A4R", &veu3_device, },
                { "A4R", &jpu_device, },
-               { "A4R", &tmu00_device, },
-               { "A4R", &tmu01_device, },
+               { "A4R", &tmu0_device, },
        };
 
        sh7372_init_pm_domains();
@@ -1035,13 +985,9 @@ void __init sh7372_add_early_devices(void)
 
 void __init sh7372_add_early_devices_dt(void)
 {
-       shmobile_setup_delay(800, 1, 3); /* Cortex-A8 @ 800MHz */
-
-       early_platform_add_devices(sh7372_early_devices,
-                                  ARRAY_SIZE(sh7372_early_devices));
+       shmobile_init_delay();
 
-       /* setup early console here as well */
-       shmobile_setup_console();
+       sh7372_add_early_devices();
 }
 
 void __init sh7372_add_standard_devices_dt(void)
@@ -1063,7 +1009,6 @@ static const char *sh7372_boards_compat_dt[] __initdata = {
 DT_MACHINE_START(SH7372_DT, "Generic SH7372 (Flattened Device Tree)")
        .map_io         = sh7372_map_io,
        .init_early     = sh7372_add_early_devices_dt,
-       .nr_irqs        = NR_IRQS_LEGACY,
        .init_irq       = sh7372_init_irq,
        .handle_irq     = shmobile_handle_irq_intc,
        .init_machine   = sh7372_add_standard_devices_dt,
index f74ab53..b7bd8e5 100644 (file)
 #include <linux/io.h>
 #include <linux/serial_sci.h>
 #include <linux/sh_dma.h>
-#include <linux/sh_intc.h>
 #include <linux/sh_timer.h>
 #include <linux/platform_data/sh_ipmmu.h>
 #include <linux/platform_data/irq-renesas-intc-irqpin.h>
-#include <mach/dma-register.h>
-#include <mach/irqs.h>
-#include <mach/sh73a0.h>
-#include <mach/common.h>
+
 #include <asm/mach-types.h>
 #include <asm/mach/map.h>
 #include <asm/mach/arch.h>
 #include <asm/mach/time.h>
 
+#include "common.h"
+#include "dma-register.h"
+#include "intc.h"
+#include "irqs.h"
+#include "sh73a0.h"
+
 static struct map_desc sh73a0_io_desc[] __initdata = {
        /* create a 1:1 entity map for 0xe6xxxxxx
         * used by CPGA, INTC and PFC.
@@ -104,86 +106,45 @@ SH73A0_SCIF(PORT_SCIFA, 6, 0xe6cc0000, gic_spi(156));
 SH73A0_SCIF(PORT_SCIFA, 7, 0xe6cd0000, gic_spi(143));
 SH73A0_SCIF(PORT_SCIFB, 8, 0xe6c30000, gic_spi(80));
 
-static struct sh_timer_config cmt10_platform_data = {
-       .name = "CMT10",
-       .channel_offset = 0x10,
-       .timer_bit = 0,
-       .clockevent_rating = 80,
-       .clocksource_rating = 125,
+static struct sh_timer_config cmt1_platform_data = {
+       .channels_mask = 0x3f,
 };
 
-static struct resource cmt10_resources[] = {
-       [0] = {
-               .name   = "CMT10",
-               .start  = 0xe6138010,
-               .end    = 0xe613801b,
-               .flags  = IORESOURCE_MEM,
-       },
-       [1] = {
-               .start  = gic_spi(65),
-               .flags  = IORESOURCE_IRQ,
-       },
+static struct resource cmt1_resources[] = {
+       DEFINE_RES_MEM(0xe6138000, 0x200),
+       DEFINE_RES_IRQ(gic_spi(65)),
 };
 
-static struct platform_device cmt10_device = {
-       .name           = "sh_cmt",
-       .id             = 10,
+static struct platform_device cmt1_device = {
+       .name           = "sh-cmt-48",
+       .id             = 1,
        .dev = {
-               .platform_data  = &cmt10_platform_data,
+               .platform_data  = &cmt1_platform_data,
        },
-       .resource       = cmt10_resources,
-       .num_resources  = ARRAY_SIZE(cmt10_resources),
+       .resource       = cmt1_resources,
+       .num_resources  = ARRAY_SIZE(cmt1_resources),
 };
 
 /* TMU */
-static struct sh_timer_config tmu00_platform_data = {
-       .name = "TMU00",
-       .channel_offset = 0x4,
-       .timer_bit = 0,
-       .clockevent_rating = 200,
+static struct sh_timer_config tmu0_platform_data = {
+       .channels_mask = 7,
 };
 
-static struct resource tmu00_resources[] = {
-       [0] = DEFINE_RES_MEM(0xfff60008, 0xc),
-       [1] = {
-               .start  = intcs_evt2irq(0x0e80), /* TMU0_TUNI00 */
-               .flags  = IORESOURCE_IRQ,
-       },
+static struct resource tmu0_resources[] = {
+       DEFINE_RES_MEM(0xfff60000, 0x2c),
+       DEFINE_RES_IRQ(intcs_evt2irq(0xe80)),
+       DEFINE_RES_IRQ(intcs_evt2irq(0xea0)),
+       DEFINE_RES_IRQ(intcs_evt2irq(0xec0)),
 };
 
-static struct platform_device tmu00_device = {
-       .name           = "sh_tmu",
+static struct platform_device tmu0_device = {
+       .name           = "sh-tmu",
        .id             = 0,
        .dev = {
-               .platform_data  = &tmu00_platform_data,
+               .platform_data  = &tmu0_platform_data,
        },
-       .resource       = tmu00_resources,
-       .num_resources  = ARRAY_SIZE(tmu00_resources),
-};
-
-static struct sh_timer_config tmu01_platform_data = {
-       .name = "TMU01",
-       .channel_offset = 0x10,
-       .timer_bit = 1,
-       .clocksource_rating = 200,
-};
-
-static struct resource tmu01_resources[] = {
-       [0] = DEFINE_RES_MEM(0xfff60014, 0xc),
-       [1] = {
-               .start  = intcs_evt2irq(0x0ea0), /* TMU0_TUNI01 */
-               .flags  = IORESOURCE_IRQ,
-       },
-};
-
-static struct platform_device tmu01_device = {
-       .name           = "sh_tmu",
-       .id             = 1,
-       .dev = {
-               .platform_data  = &tmu01_platform_data,
-       },
-       .resource       = tmu01_resources,
-       .num_resources  = ARRAY_SIZE(tmu01_resources),
+       .resource       = tmu0_resources,
+       .num_resources  = ARRAY_SIZE(tmu0_resources),
 };
 
 static struct resource i2c0_resources[] = {
@@ -736,7 +697,7 @@ static struct platform_device irqpin3_device = {
        },
 };
 
-static struct platform_device *sh73a0_devices_dt[] __initdata = {
+static struct platform_device *sh73a0_early_devices[] __initdata = {
        &scif0_device,
        &scif1_device,
        &scif2_device,
@@ -746,13 +707,9 @@ static struct platform_device *sh73a0_devices_dt[] __initdata = {
        &scif6_device,
        &scif7_device,
        &scif8_device,
-       &cmt10_device,
-};
-
-static struct platform_device *sh73a0_early_devices[] __initdata = {
-       &tmu00_device,
-       &tmu01_device,
+       &tmu0_device,
        &ipmmu_device,
+       &cmt1_device,
 };
 
 static struct platform_device *sh73a0_late_devices[] __initdata = {
@@ -777,8 +734,6 @@ void __init sh73a0_add_standard_devices(void)
        /* Clear software reset bit on SY-DMAC module */
        __raw_writel(__raw_readl(SRCR2) & ~(1 << 18), SRCR2);
 
-       platform_add_devices(sh73a0_devices_dt,
-                           ARRAY_SIZE(sh73a0_devices_dt));
        platform_add_devices(sh73a0_early_devices,
                            ARRAY_SIZE(sh73a0_early_devices));
        platform_add_devices(sh73a0_late_devices,
@@ -787,7 +742,7 @@ void __init sh73a0_add_standard_devices(void)
 
 void __init sh73a0_init_delay(void)
 {
-       shmobile_setup_delay(1196, 44, 46); /* Cortex-A9 @ 1196MHz */
+       shmobile_init_delay();
 }
 
 /* do nothing for !CONFIG_SMP or !CONFIG_HAVE_TWD */
@@ -803,8 +758,6 @@ void __init sh73a0_earlytimer_init(void)
 
 void __init sh73a0_add_early_devices(void)
 {
-       early_platform_add_devices(sh73a0_devices_dt,
-                                  ARRAY_SIZE(sh73a0_devices_dt));
        early_platform_add_devices(sh73a0_early_devices,
                                   ARRAY_SIZE(sh73a0_early_devices));
 
@@ -816,17 +769,10 @@ void __init sh73a0_add_early_devices(void)
 
 void __init sh73a0_add_standard_devices_dt(void)
 {
-       struct platform_device_info devinfo = { .name = "cpufreq-cpu0", .id = -1, };
-
        /* clocks are setup late during boot in the case of DT */
        sh73a0_clock_init();
 
-       platform_add_devices(sh73a0_devices_dt,
-                            ARRAY_SIZE(sh73a0_devices_dt));
        of_platform_populate(NULL, of_default_bus_match_table, NULL, NULL);
-
-       /* Instantiate cpufreq-cpu0 */
-       platform_device_register_full(&devinfo);
 }
 
 static const char *sh73a0_boards_compat_dt[] __initdata = {
@@ -838,8 +784,8 @@ DT_MACHINE_START(SH73A0_DT, "Generic SH73A0 (Flattened Device Tree)")
        .smp            = smp_ops(sh73a0_smp_ops),
        .map_io         = sh73a0_map_io,
        .init_early     = sh73a0_init_delay,
-       .nr_irqs        = NR_IRQS_LEGACY,
        .init_machine   = sh73a0_add_standard_devices_dt,
+       .init_late      = shmobile_init_late,
        .dt_compat      = sh73a0_boards_compat_dt,
 MACHINE_END
 #endif /* CONFIG_USE_OF */
similarity index 96%
rename from arch/arm/mach-shmobile/include/mach/sh7372.h
rename to arch/arm/mach-shmobile/sh7372.h
index 854a9f0..4ad960d 100644 (file)
 #ifndef __ASM_SH7372_H__
 #define __ASM_SH7372_H__
 
-#include <linux/sh_clk.h>
-#include <linux/pm_domain.h>
-#include <mach/pm-rmobile.h>
-
 /* DMA slave IDs */
 enum {
        SHDMA_SLAVE_INVALID,
index f2ca923..6ff1df1 100644 (file)
 #include <linux/spinlock.h>
 #include <linux/io.h>
 #include <linux/delay.h>
-#include <mach/common.h>
-#include <mach/emev2.h>
 #include <asm/smp_plat.h>
 #include <asm/smp_scu.h>
+#include "common.h"
 
 #define EMEV2_SCU_BASE 0x1e000000
 #define EMEV2_SMU_BASE 0xe0110000
index 627c1f0..3100e35 100644 (file)
 #include <linux/spinlock.h>
 #include <linux/io.h>
 #include <linux/delay.h>
-#include <mach/common.h>
-#include <mach/r8a7779.h>
+
 #include <asm/cacheflush.h>
 #include <asm/smp_plat.h>
 #include <asm/smp_scu.h>
 #include <asm/smp_twd.h>
 
+#include "common.h"
+#include "pm-rcar.h"
+#include "r8a7779.h"
+
 #define AVECR IOMEM(0xfe700040)
 #define R8A7779_SCU_BASE 0xf0000000
 
-static struct r8a7779_pm_ch r8a7779_ch_cpu1 = {
+static struct rcar_sysc_ch r8a7779_ch_cpu1 = {
        .chan_offs = 0x40, /* PWRSR0 .. PWRER0 */
        .chan_bit = 1, /* ARM1 */
        .isr_bit = 1, /* ARM1 */
 };
 
-static struct r8a7779_pm_ch r8a7779_ch_cpu2 = {
+static struct rcar_sysc_ch r8a7779_ch_cpu2 = {
        .chan_offs = 0x40, /* PWRSR0 .. PWRER0 */
        .chan_bit = 2, /* ARM2 */
        .isr_bit = 2, /* ARM2 */
 };
 
-static struct r8a7779_pm_ch r8a7779_ch_cpu3 = {
+static struct rcar_sysc_ch r8a7779_ch_cpu3 = {
        .chan_offs = 0x40, /* PWRSR0 .. PWRER0 */
        .chan_bit = 3, /* ARM3 */
        .isr_bit = 3, /* ARM3 */
 };
 
-static struct r8a7779_pm_ch *r8a7779_ch_cpu[4] = {
+static struct rcar_sysc_ch *r8a7779_ch_cpu[4] = {
        [1] = &r8a7779_ch_cpu1,
        [2] = &r8a7779_ch_cpu2,
        [3] = &r8a7779_ch_cpu3,
@@ -67,7 +70,7 @@ void __init r8a7779_register_twd(void)
 
 static int r8a7779_platform_cpu_kill(unsigned int cpu)
 {
-       struct r8a7779_pm_ch *ch = NULL;
+       struct rcar_sysc_ch *ch = NULL;
        int ret = -EIO;
 
        cpu = cpu_logical_map(cpu);
@@ -76,14 +79,14 @@ static int r8a7779_platform_cpu_kill(unsigned int cpu)
                ch = r8a7779_ch_cpu[cpu];
 
        if (ch)
-               ret = r8a7779_sysc_power_down(ch);
+               ret = rcar_sysc_power_down(ch);
 
        return ret ? ret : 1;
 }
 
 static int r8a7779_boot_secondary(unsigned int cpu, struct task_struct *idle)
 {
-       struct r8a7779_pm_ch *ch = NULL;
+       struct rcar_sysc_ch *ch = NULL;
        unsigned int lcpu = cpu_logical_map(cpu);
        int ret;
 
@@ -91,7 +94,7 @@ static int r8a7779_boot_secondary(unsigned int cpu, struct task_struct *idle)
                ch = r8a7779_ch_cpu[lcpu];
 
        if (ch)
-               ret = r8a7779_sysc_power_up(ch);
+               ret = rcar_sysc_power_up(ch);
        else
                ret = -EIO;
 
index 015e275..2311694 100644 (file)
 #include <linux/init.h>
 #include <linux/smp.h>
 #include <linux/io.h>
+
 #include <asm/smp_plat.h>
-#include <mach/common.h>
 
-#define RST            0xe6160000
-#define CA15BAR                0x0020
-#define CA7BAR         0x0030
-#define CA15RESCNT     0x0040
-#define CA7RESCNT      0x0044
-#define MERAM          0xe8080000
+#include "common.h"
+#include "pm-rcar.h"
+#include "r8a7790.h"
+
+static struct rcar_sysc_ch r8a7790_ca15_scu = {
+       .chan_offs = 0x180, /* PWRSR5 .. PWRER5 */
+       .isr_bit = 12, /* CA15-SCU */
+};
+
+static struct rcar_sysc_ch r8a7790_ca7_scu = {
+       .chan_offs = 0x100, /* PWRSR3 .. PWRER3 */
+       .isr_bit = 21, /* CA7-SCU */
+};
 
 static void __init r8a7790_smp_prepare_cpus(unsigned int max_cpus)
 {
-       void __iomem *p;
-       u32 bar;
-
        /* let APMU code install data related to shmobile_boot_vector */
        shmobile_smp_apmu_prepare_cpus(max_cpus);
 
-       /* MERAM for jump stub, because BAR requires 256KB aligned address */
-       p = ioremap_nocache(MERAM, shmobile_boot_size);
-       memcpy_toio(p, shmobile_boot_vector, shmobile_boot_size);
-       iounmap(p);
-
-       /* setup reset vectors */
-       p = ioremap_nocache(RST, 0x63);
-       bar = (MERAM >> 8) & 0xfffffc00;
-       writel_relaxed(bar, p + CA15BAR);
-       writel_relaxed(bar, p + CA7BAR);
-       writel_relaxed(bar | 0x10, p + CA15BAR);
-       writel_relaxed(bar | 0x10, p + CA7BAR);
-
-       /* enable clocks to all CPUs */
-       writel_relaxed((readl_relaxed(p + CA15RESCNT) & ~0x0f) | 0xa5a50000,
-                      p + CA15RESCNT);
-       writel_relaxed((readl_relaxed(p + CA7RESCNT) & ~0x0f) | 0x5a5a0000,
-                      p + CA7RESCNT);
-       iounmap(p);
+       /* turn on power to SCU */
+       r8a7790_pm_init();
+       rcar_sysc_power_up(&r8a7790_ca15_scu);
+       rcar_sysc_power_up(&r8a7790_ca7_scu);
 }
 
 struct smp_operations r8a7790_smp_ops __initdata = {
index 2df5bd1..f743386 100644 (file)
 #include <linux/init.h>
 #include <linux/smp.h>
 #include <linux/io.h>
+
 #include <asm/smp_plat.h>
-#include <mach/common.h>
-#include <mach/r8a7791.h>
 
-#define RST            0xe6160000
-#define CA15BAR                0x0020
-#define CA15RESCNT     0x0040
-#define RAM            0xe6300000
+#include "common.h"
+#include "r8a7791.h"
+#include "rcar-gen2.h"
 
 static void __init r8a7791_smp_prepare_cpus(unsigned int max_cpus)
 {
-       void __iomem *p;
-       u32 bar;
-
        /* let APMU code install data related to shmobile_boot_vector */
        shmobile_smp_apmu_prepare_cpus(max_cpus);
 
-       /* RAM for jump stub, because BAR requires 256KB aligned address */
-       p = ioremap_nocache(RAM, shmobile_boot_size);
-       memcpy_toio(p, shmobile_boot_vector, shmobile_boot_size);
-       iounmap(p);
+       r8a7791_pm_init();
+}
 
-       /* setup reset vectors */
-       p = ioremap_nocache(RST, 0x63);
-       bar = (RAM >> 8) & 0xfffffc00;
-       writel_relaxed(bar, p + CA15BAR);
-       writel_relaxed(bar | 0x10, p + CA15BAR);
+static int r8a7791_smp_boot_secondary(unsigned int cpu,
+                                     struct task_struct *idle)
+{
+       /* Error out when hardware debug mode is enabled */
+       if (rcar_gen2_read_mode_pins() & BIT(21)) {
+               pr_warn("Unable to boot CPU%u when MD21 is set\n", cpu);
+               return -ENOTSUPP;
+       }
 
-       /* enable clocks to all CPUs */
-       writel_relaxed((readl_relaxed(p + CA15RESCNT) & ~0x0f) | 0xa5a50000,
-                      p + CA15RESCNT);
-       iounmap(p);
+       return shmobile_smp_apmu_boot_secondary(cpu, idle);
 }
 
 struct smp_operations r8a7791_smp_ops __initdata = {
        .smp_prepare_cpus       = r8a7791_smp_prepare_cpus,
-       .smp_boot_secondary     = shmobile_smp_apmu_boot_secondary,
+       .smp_boot_secondary     = r8a7791_smp_boot_secondary,
 #ifdef CONFIG_HOTPLUG_CPU
        .cpu_disable            = shmobile_smp_cpu_disable,
        .cpu_die                = shmobile_smp_apmu_cpu_die,
index 13ba36a..22d8f87 100644 (file)
 #include <linux/smp.h>
 #include <linux/io.h>
 #include <linux/delay.h>
-#include <mach/common.h>
-#include <mach/sh73a0.h>
+
 #include <asm/smp_plat.h>
 #include <asm/smp_twd.h>
 
+#include "common.h"
+#include "sh73a0.h"
+
 #define WUPCR          IOMEM(0xe6151010)
 #define SRESCR         IOMEM(0xe6151018)
 #define PSTR           IOMEM(0xe6151040)
index 62d7052..87c6be1 100644 (file)
 #include <linux/platform_device.h>
 #include <linux/clocksource.h>
 #include <linux/delay.h>
+#include <linux/of_address.h>
 
-void __init shmobile_setup_delay(unsigned int max_cpu_core_mhz,
-                                unsigned int mult, unsigned int div)
+static void __init shmobile_setup_delay_hz(unsigned int max_cpu_core_hz,
+                                          unsigned int mult, unsigned int div)
 {
        /* calculate a worst-case loops-per-jiffy value
-        * based on maximum cpu core mhz setting and the
+        * based on maximum cpu core hz setting and the
         * __delay() implementation in arch/arm/lib/delay.S
         *
         * this will result in a longer delay than expected
         * when the cpu core runs on lower frequencies.
         */
 
-       unsigned int value = (1000000 * mult) / (HZ * div);
+       unsigned int value = HZ * div / mult;
 
        if (!preset_lpj)
-               preset_lpj = max_cpu_core_mhz * value;
+               preset_lpj = max_cpu_core_hz / value;
+}
+
+void __init shmobile_init_delay(void)
+{
+       struct device_node *np, *cpus;
+       bool is_a7_a8_a9 = false;
+       bool is_a15 = false;
+       u32 max_freq = 0;
+
+       cpus = of_find_node_by_path("/cpus");
+       if (!cpus)
+               return;
+
+       for_each_child_of_node(cpus, np) {
+               u32 freq;
+
+               if (!of_property_read_u32(np, "clock-frequency", &freq))
+                       max_freq = max(max_freq, freq);
+
+               if (of_device_is_compatible(np, "arm,cortex-a7") ||
+                   of_device_is_compatible(np, "arm,cortex-a8") ||
+                   of_device_is_compatible(np, "arm,cortex-a9"))
+                       is_a7_a8_a9 = true;
+               else if (of_device_is_compatible(np, "arm,cortex-a15"))
+                       is_a15 = true;
+       }
+
+       of_node_put(cpus);
+
+       if (!max_freq)
+               return;
+
+       if (is_a7_a8_a9)
+               shmobile_setup_delay_hz(max_freq, 1, 3);
+       else if (is_a15 && !IS_ENABLED(CONFIG_ARM_ARCH_TIMER))
+               shmobile_setup_delay_hz(max_freq, 2, 4);
 }
 
 static void __init shmobile_late_time_init(void)
index aee77f0..b5f8d75 100644 (file)
@@ -1,17 +1,10 @@
 config ARCH_SOCFPGA
        bool "Altera SOCFPGA family" if ARCH_MULTI_V7
-       select ARCH_WANT_OPTIONAL_GPIOLIB
        select ARM_AMBA
        select ARM_GIC
        select CACHE_L2X0
-       select COMMON_CLK
-       select CPU_V7
        select DW_APB_TIMER_OF
-       select GENERIC_CLOCKEVENTS
        select GPIO_PL061 if GPIOLIB
        select HAVE_ARM_SCU
        select HAVE_ARM_TWD if SMP
-       select HAVE_SMP
        select MFD_SYSCON
-       select SPARSE_IRQ
-       select USE_OF
index ac1710e..5c57262 100644 (file)
@@ -8,8 +8,6 @@ menuconfig PLAT_SPEAR
        select ARCH_REQUIRE_GPIOLIB
        select ARM_AMBA
        select CLKSRC_MMIO
-       select COMMON_CLK
-       select GENERIC_CLOCKEVENTS
 
 if PLAT_SPEAR
 
@@ -18,14 +16,10 @@ config ARCH_SPEAR13XX
        depends on ARCH_MULTI_V7 || PLAT_SPEAR_SINGLE
        select ARCH_HAS_CPUFREQ
        select ARM_GIC
-       select CPU_V7
        select GPIO_SPEAR_SPICS
        select HAVE_ARM_SCU if SMP
        select HAVE_ARM_TWD if SMP
-       select HAVE_SMP
-       select MIGHT_HAVE_CACHE_L2X0
        select PINCTRL
-       select USE_OF
        help
          Supports for ARM's SPEAR13XX family
 
@@ -50,9 +44,7 @@ config ARCH_SPEAR3XX
        depends on ARCH_MULTI_V5 || PLAT_SPEAR_SINGLE
        depends on !ARCH_SPEAR13XX
        select ARM_VIC
-       select CPU_ARM926T
        select PINCTRL
-       select USE_OF
        help
          Supports for ARM's SPEAR3XX family
 
@@ -83,14 +75,12 @@ config ARCH_SPEAR6XX
        depends on ARCH_MULTI_V5 || PLAT_SPEAR_SINGLE
        depends on !ARCH_SPEAR13XX
        select ARM_VIC
-       select CPU_ARM926T
        help
          Supports for ARM's SPEAR6XX family
 
 config MACH_SPEAR600
        def_bool y
        depends on ARCH_SPEAR6XX
-       select USE_OF
        help
          Supports ST SPEAr600 boards configured via the device-treesource "arch/arm/mach-spear6xx/Kconfig"
 
index d71654b..d2c13ba 100644 (file)
@@ -1,14 +1,10 @@
 menuconfig ARCH_STI
        bool "STMicroelectronics Consumer Electronics SOCs with Device Trees" if ARCH_MULTI_V7
-       select GENERIC_CLOCKEVENTS
-       select CLKDEV_LOOKUP
        select ARM_GIC
        select ARM_GLOBAL_TIMER
        select PINCTRL
        select PINCTRL_ST
        select MFD_SYSCON
-       select MIGHT_HAVE_CACHE_L2X0
-       select HAVE_SMP
        select HAVE_ARM_SCU if SMP
        select ARCH_REQUIRE_GPIOLIB
        select ARM_ERRATA_754322
index b9d6cad..9de27cf 100644 (file)
@@ -5,14 +5,9 @@ config ARCH_SUNXI
        select ARM_GIC
        select ARM_PSCI
        select CLKSRC_MMIO
-       select CLKSRC_OF
-       select COMMON_CLK
-       select GENERIC_CLOCKEVENTS
        select GENERIC_IRQ_CHIP
-       select HAVE_SMP
        select PINCTRL
        select PINCTRL_SUNXI
        select RESET_CONTROLLER
-       select SPARSE_IRQ
        select SUN4I_TIMER
        select SUN5I_HSTIMER
index b1232d8..b3c521e 100644 (file)
@@ -5,24 +5,14 @@ config ARCH_TEGRA
        select ARCH_SUPPORTS_TRUSTED_FOUNDATIONS
        select ARM_GIC
        select CLKSRC_MMIO
-       select CLKSRC_OF
-       select COMMON_CLK
-       select CPU_V7
-       select GENERIC_CLOCKEVENTS
        select HAVE_ARM_SCU if SMP
        select HAVE_ARM_TWD if SMP
-       select HAVE_SMP
-       select MIGHT_HAVE_CACHE_L2X0
-       select MIGHT_HAVE_PCI
        select PINCTRL
        select ARCH_HAS_RESET_CONTROLLER
        select RESET_CONTROLLER
        select SOC_BUS
-       select SPARSE_IRQ
-       select USB_ARCH_HAS_EHCI if USB_SUPPORT
        select USB_ULPI if USB_PHY
        select USB_ULPI_VIEWPORT if USB_PHY
-       select USE_OF
        help
          This enables support for NVIDIA Tegra based systems.
 
index 8e23071..e3a96d7 100644 (file)
@@ -3,20 +3,14 @@ config ARCH_U300
        depends on MMU
        select ARCH_REQUIRE_GPIOLIB
        select ARM_AMBA
-       select ARM_PATCH_PHYS_VIRT
        select ARM_VIC
        select CLKSRC_MMIO
-       select CLKSRC_OF
-       select COMMON_CLK
        select CPU_ARM926T
-       select GENERIC_CLOCKEVENTS
        select HAVE_TCM
        select PINCTRL
        select PINCTRL_COH901
        select PINCTRL_U300
-       select SPARSE_IRQ
        select MFD_SYSCON
-       select USE_OF
        help
          Support for ST-Ericsson U300 series mobile platforms.
 
index 0034d2c..8052bd5 100644 (file)
@@ -11,13 +11,8 @@ config ARCH_U8500
        select ARM_GIC
        select CACHE_L2X0
        select CLKSRC_NOMADIK_MTU
-       select COMMON_CLK
-       select CPU_V7
-       select GENERIC_CLOCKEVENTS
        select HAVE_ARM_SCU if SMP
        select HAVE_ARM_TWD if SMP
-       select HAVE_SMP
-       select MIGHT_HAVE_CACHE_L2X0
        select PINCTRL
        select PINCTRL_ABX500
        select PINCTRL_NOMADIK
@@ -76,7 +71,6 @@ config UX500_AUTO_PLATFORM
 config MACH_UX500_DT
        bool "Generic U8500 support using device tree"
        depends on MACH_MOP500
-       select USE_OF
 
 endmenu
 
index 4a70be4..657d52d 100644 (file)
@@ -5,17 +5,12 @@ config ARCH_VEXPRESS
        select ARM_AMBA
        select ARM_GIC
        select ARM_TIMER_SP804
-       select COMMON_CLK
        select COMMON_CLK_VERSATILE
-       select CPU_V7
-       select GENERIC_CLOCKEVENTS
        select HAVE_ARM_SCU if SMP
        select HAVE_ARM_TWD if SMP
        select HAVE_PATA_PLATFORM
-       select HAVE_SMP
        select ICST
-       select MIGHT_HAVE_CACHE_L2X0
-       select NO_IOPORT
+       select NO_IOPORT_MAP
        select PLAT_VERSATILE
        select PLAT_VERSATILE_CLCD
        select POWER_RESET
index 993c9ae..b4a5f0d 100644 (file)
@@ -53,7 +53,7 @@ static int __init vexpress_dt_find_scu(unsigned long node,
 {
        if (of_flat_dt_match(node, vexpress_dt_cortex_a9_match)) {
                phys_addr_t phys_addr;
-               __be32 *reg = of_get_flat_dt_prop(node, "reg", NULL);
+               const __be32 *reg = of_get_flat_dt_prop(node, "reg", NULL);
 
                if (WARN_ON(!reg))
                        return -EINVAL;
index 081d469..eaad072 100644 (file)
@@ -1,10 +1,6 @@
 config ARCH_VIRT
        bool "Dummy Virtual Machine" if ARCH_MULTI_V7
-       select ARCH_WANT_OPTIONAL_GPIOLIB
        select ARM_GIC
        select HAVE_ARM_ARCH_TIMER
        select ARM_PSCI
        select HAVE_SMP
-       select CPU_V7
-       select SPARSE_IRQ
-       select USE_OF
index 927be93..c581ed2 100644 (file)
@@ -3,8 +3,6 @@ config ARCH_VT8500
        select ARCH_HAS_CPUFREQ
        select ARCH_REQUIRE_GPIOLIB
        select CLKDEV_LOOKUP
-       select CLKSRC_OF
-       select GENERIC_CLOCKEVENTS
        select VT8500_TIMER
        select PINCTRL
        help
@@ -29,6 +27,5 @@ config ARCH_WM8850
        bool "WonderMedia WM8850"
        depends on ARCH_MULTI_V7
        select ARCH_VT8500
-       select CPU_V7
        help
          Support for WonderMedia WM8850 System-on-Chip.
index 6b04260..105d39b 100644 (file)
@@ -2,16 +2,9 @@ config ARCH_ZYNQ
        bool "Xilinx Zynq ARM Cortex A9 Platform" if ARCH_MULTI_V7
        select ARM_AMBA
        select ARM_GIC
-       select COMMON_CLK
-       select CPU_V7
-       select GENERIC_CLOCKEVENTS
        select HAVE_ARM_SCU if SMP
        select HAVE_ARM_TWD if SMP
        select ICST
-       select MIGHT_HAVE_CACHE_L2X0
-       select USE_OF
-       select HAVE_SMP
-       select SPARSE_IRQ
        select CADENCE_TTC_TIMER
        select ARM_GLOBAL_TIMER
        help
index 58645a5..ac03668 100644 (file)
@@ -9,7 +9,7 @@ config PLAT_SAMSUNG
        depends on PLAT_S3C24XX || ARCH_S3C64XX || PLAT_S5P || ARCH_EXYNOS
        default y
        select GENERIC_IRQ_CHIP
-       select NO_IOPORT
+       select NO_IOPORT_MAP
        help
          Base platform code for all Samsung SoC based systems
 
@@ -19,7 +19,7 @@ config PLAT_S5P
        default y
        select ARCH_REQUIRE_GPIOLIB
        select ARM_VIC
-       select NO_IOPORT
+       select NO_IOPORT_MAP
        select PLAT_SAMSUNG
        select S3C_GPIO_TRACK
        select S5P_GPIO_DRVSTR
index 9267d29..65f758b 100644 (file)
@@ -6,7 +6,6 @@
 
 obj-y                          :=
 obj-m                          :=
-obj-n                          := dummy.o
 obj-                           :=
 
 # Objects we always build independent of SoC choice
index ad51f85..a292728 100644 (file)
@@ -125,8 +125,8 @@ device_initcall(s5p_mfc_memory_init);
 int __init s5p_fdt_find_mfc_mem(unsigned long node, const char *uname,
                                int depth, void *data)
 {
-       __be32 *prop;
-       unsigned long len;
+       const __be32 *prop;
+       int len;
        struct s5p_mfc_dt_meminfo *mfc_mem = data;
 
        if (!data)
index 65b7884..2190e6c 100644 (file)
@@ -62,7 +62,7 @@ config ARCH_PHYS_ADDR_T_64BIT
 config MMU
        def_bool y
 
-config NO_IOPORT
+config NO_IOPORT_MAP
        def_bool y
 
 config STACKTRACE_SUPPORT
index 9400596..f190971 100644 (file)
@@ -104,37 +104,6 @@ static inline void arch_timer_set_cntkctl(u32 cntkctl)
        asm volatile("msr       cntkctl_el1, %0" : : "r" (cntkctl));
 }
 
-static inline void arch_counter_set_user_access(void)
-{
-       u32 cntkctl = arch_timer_get_cntkctl();
-
-       /* Disable user access to the timers and the physical counter */
-       /* Also disable virtual event stream */
-       cntkctl &= ~(ARCH_TIMER_USR_PT_ACCESS_EN
-                       | ARCH_TIMER_USR_VT_ACCESS_EN
-                       | ARCH_TIMER_VIRT_EVT_EN
-                       | ARCH_TIMER_USR_PCT_ACCESS_EN);
-
-       /* Enable user access to the virtual counter */
-       cntkctl |= ARCH_TIMER_USR_VCT_ACCESS_EN;
-
-       arch_timer_set_cntkctl(cntkctl);
-}
-
-static inline void arch_timer_evtstrm_enable(int divider)
-{
-       u32 cntkctl = arch_timer_get_cntkctl();
-       cntkctl &= ~ARCH_TIMER_EVT_TRIGGER_MASK;
-       /* Set the divider and enable virtual event stream */
-       cntkctl |= (divider << ARCH_TIMER_EVT_TRIGGER_SHIFT)
-                       | ARCH_TIMER_VIRT_EVT_EN;
-       arch_timer_set_cntkctl(cntkctl);
-       elf_hwcap |= HWCAP_EVTSTRM;
-#ifdef CONFIG_COMPAT
-       compat_elf_hwcap |= COMPAT_HWCAP_EVTSTRM;
-#endif
-}
-
 static inline u64 arch_counter_get_cntvct(void)
 {
        u64 cval;
index 18db853..4912f0a 100644 (file)
@@ -117,7 +117,6 @@ CONFIG_HID_SAMSUNG=m
 CONFIG_HID_SONY=m
 CONFIG_HID_SUNPLUS=m
 CONFIG_USB=m
-CONFIG_USB_DEVICEFS=y
 # CONFIG_USB_DEVICE_CLASS is not set
 CONFIG_USB_MON=m
 CONFIG_USB_ISP116X_HCD=m
index 2f2c6ac..1759fad 100644 (file)
@@ -123,7 +123,6 @@ CONFIG_HID_SAMSUNG=y
 CONFIG_HID_SONY=y
 CONFIG_HID_SUNPLUS=y
 CONFIG_USB=y
-CONFIG_USB_DEVICEFS=y
 # CONFIG_USB_DEVICE_CLASS is not set
 CONFIG_USB_OTG_BLACKLIST_HUB=y
 CONFIG_USB_MON=y
index 91535c3..3577296 100644 (file)
@@ -147,7 +147,6 @@ CONFIG_HID_SAMSUNG=y
 CONFIG_HID_SONY=y
 CONFIG_HID_SUNPLUS=y
 CONFIG_USB=y
-CONFIG_USB_DEVICEFS=y
 # CONFIG_USB_DEVICE_CLASS is not set
 CONFIG_USB_OTG_BLACKLIST_HUB=y
 CONFIG_USB_MON=y
index af2738c..2e73a5d 100644 (file)
@@ -141,7 +141,6 @@ CONFIG_HID_SAMSUNG=y
 CONFIG_HID_SONY=y
 CONFIG_HID_SUNPLUS=y
 CONFIG_USB=y
-CONFIG_USB_DEVICEFS=y
 # CONFIG_USB_DEVICE_CLASS is not set
 CONFIG_USB_OTG_BLACKLIST_HUB=y
 CONFIG_USB_MON=y
index e716fdf..f0a2ddf 100644 (file)
@@ -159,7 +159,6 @@ CONFIG_HID_SAMSUNG=y
 CONFIG_HID_SONY=y
 CONFIG_HID_SUNPLUS=y
 CONFIG_USB=y
-CONFIG_USB_DEVICEFS=y
 # CONFIG_USB_DEVICE_CLASS is not set
 CONFIG_USB_OTG_BLACKLIST_HUB=y
 CONFIG_USB_MON=y
index f59c80e..05108b8 100644 (file)
@@ -95,7 +95,6 @@ CONFIG_WATCHDOG=y
 CONFIG_BFIN_WDT=y
 CONFIG_USB=m
 CONFIG_USB_ANNOUNCE_NEW_DEVICES=y
-CONFIG_USB_DEVICEFS=y
 # CONFIG_USB_DEVICE_CLASS is not set
 CONFIG_USB_OTG_BLACKLIST_HUB=y
 CONFIG_USB_MON=m
index b9af4fa..9ff79df 100644 (file)
@@ -94,7 +94,6 @@ CONFIG_WATCHDOG=y
 CONFIG_BFIN_WDT=y
 # CONFIG_HID_SUPPORT is not set
 CONFIG_USB=m
-CONFIG_USB_DEVICEFS=y
 # CONFIG_USB_DEVICE_CLASS is not set
 CONFIG_USB_MON=m
 CONFIG_USB_MUSB_HDRC=m
index 6295165..5adf0da 100644 (file)
@@ -73,7 +73,6 @@ CONFIG_SPI_BFIN5XX=y
 # CONFIG_HWMON is not set
 CONFIG_WATCHDOG=y
 CONFIG_USB=y
-CONFIG_USB_DEVICEFS=y
 CONFIG_USB_OTG_WHITELIST=y
 CONFIG_USB_MON=y
 CONFIG_USB_ISP1362_HCD=y
index ed0fcdf..4a60aa3 100644 (file)
@@ -29,7 +29,7 @@ config GENERIC_CALIBRATE_DELAY
        bool
        default y
 
-config NO_IOPORT
+config NO_IOPORT_MAP
        def_bool y
 
 config FORCE_MAX_ZONEORDER
index 09df260..9bb54b9 100644 (file)
@@ -19,7 +19,7 @@ config HEXAGON
        select GENERIC_IRQ_SHOW
        select HAVE_ARCH_KGDB
        select HAVE_ARCH_TRACEHOOK
-       select NO_IOPORT
+       select NO_IOPORT_MAP
        select GENERIC_IOMAP
        select GENERIC_SMP_IDLE_THREAD
        select STACKTRACE_SUPPORT
index cf5993f..4c4ac16 100644 (file)
@@ -75,7 +75,6 @@ CONFIG_SND_PCM_OSS=m
 CONFIG_SND_CS4281=m
 CONFIG_USB_HIDDEV=y
 CONFIG_USB=m
-CONFIG_USB_DEVICEFS=y
 CONFIG_USB_MON=m
 CONFIG_USB_UHCI_HCD=m
 CONFIG_USB_ACM=m
index efbd292..8f4d051 100644 (file)
@@ -144,7 +144,6 @@ CONFIG_HID_SAMSUNG=m
 CONFIG_HID_SONY=m
 CONFIG_HID_SUNPLUS=m
 CONFIG_USB=m
-CONFIG_USB_DEVICEFS=y
 CONFIG_USB_MON=m
 CONFIG_USB_EHCI_HCD=m
 CONFIG_USB_OHCI_HCD=m
index f64980d..d663efd 100644 (file)
@@ -126,7 +126,6 @@ CONFIG_SND_CS46XX=m
 CONFIG_SND_EMU10K1=m
 CONFIG_SND_FM801=m
 CONFIG_USB=m
-CONFIG_USB_DEVICEFS=y
 CONFIG_USB_MON=m
 CONFIG_USB_EHCI_HCD=m
 CONFIG_USB_OHCI_HCD=m
index 0f4e9e4..2f4bc3e 100644 (file)
@@ -103,7 +103,6 @@ CONFIG_DRM_RADEON=m
 CONFIG_DRM_MGA=m
 CONFIG_DRM_SIS=m
 CONFIG_USB=y
-CONFIG_USB_DEVICEFS=y
 CONFIG_USB_EHCI_HCD=m
 CONFIG_USB_OHCI_HCD=m
 CONFIG_USB_UHCI_HCD=y
index ca45044..9e44bbd 100644 (file)
@@ -28,7 +28,7 @@ config ZONE_DMA
        bool
        default y
 
-config NO_IOPORT
+config NO_IOPORT_MAP
        def_bool y
 
 config NO_DMA
index b2e3229..87b7c75 100644 (file)
@@ -52,7 +52,7 @@ config TIME_LOW_RES
        bool
        default y
 
-config NO_IOPORT
+config NO_IOPORT_MAP
        def_bool y
 
 config NO_DMA
index e56abd2..4e53a6d 100644 (file)
@@ -52,7 +52,7 @@ config GENERIC_HWEIGHT
 config GENERIC_CALIBRATE_DELAY
        def_bool y
 
-config NO_IOPORT
+config NO_IOPORT_MAP
        def_bool y
 
 source "init/Kconfig"
index abdfb10..c766306 100644 (file)
 #include <asm/pci-bridge.h>
 
 #ifdef CONFIG_EARLY_PRINTK
-static char *stdout;
+static const char *stdout;
 
 static int __init early_init_dt_scan_chosen_serial(unsigned long node,
                                const char *uname, int depth, void *data)
 {
-       unsigned long l;
-       char *p;
+       int l;
+       const char *p;
 
        pr_debug("%s: depth: %d, uname: %s\n", __func__, depth, uname);
 
@@ -80,7 +80,7 @@ static int __init early_init_dt_scan_chosen_serial(unsigned long node,
                                (strncmp(p, "xlnx,opb-uartlite", 17) == 0) ||
                                (strncmp(p, "xlnx,axi-uartlite", 17) == 0) ||
                                (strncmp(p, "xlnx,mdm", 8) == 0)) {
-                       unsigned int *addrp;
+                       const unsigned int *addrp;
 
                        *(u32 *)data = UARTLITE;
 
index 95fa1f1..d50da16 100644 (file)
@@ -67,8 +67,6 @@ config MIPS_ALCHEMY
        select SYS_SUPPORTS_APM_EMULATION
        select ARCH_REQUIRE_GPIOLIB
        select SYS_SUPPORTS_ZBOOT
-       select USB_ARCH_HAS_OHCI
-       select USB_ARCH_HAS_EHCI
 
 config AR7
        bool "Texas Instruments AR7"
@@ -175,7 +173,7 @@ config MACH_DECSTATION
        select CPU_R4000_WORKAROUNDS if 64BIT
        select CPU_R4400_WORKAROUNDS if 64BIT
        select DMA_NONCOHERENT
-       select NO_IOPORT
+       select NO_IOPORT_MAP
        select IRQ_CPU
        select SYS_HAS_CPU_R3000
        select SYS_HAS_CPU_R4X00
@@ -360,7 +358,6 @@ config MIPS_SEAD3
        select SYS_SUPPORTS_LITTLE_ENDIAN
        select SYS_SUPPORTS_SMARTMIPS
        select SYS_SUPPORTS_MICROMIPS
-       select USB_ARCH_HAS_EHCI
        select USB_EHCI_BIG_ENDIAN_DESC
        select USB_EHCI_BIG_ENDIAN_MMIO
        select USE_OF
@@ -718,8 +715,6 @@ config CAVIUM_OCTEON_SOC
        select SWAP_IO_SPACE
        select HW_HAS_PCI
        select ZONE_DMA32
-       select USB_ARCH_HAS_OHCI
-       select USB_ARCH_HAS_EHCI
        select HOLES_IN_ZONE
        select ARCH_REQUIRE_GPIOLIB
        help
@@ -756,8 +751,6 @@ config NLM_XLR_BOARD
        select ZONE_DMA32 if 64BIT
        select SYNC_R4K
        select SYS_HAS_EARLY_PRINTK
-       select USB_ARCH_HAS_OHCI if USB_SUPPORT
-       select USB_ARCH_HAS_EHCI if USB_SUPPORT
        select SYS_SUPPORTS_ZBOOT
        select SYS_SUPPORTS_ZBOOT_UART16550
        help
@@ -949,7 +942,7 @@ config SYNC_R4K
 config MIPS_MACHINE
        def_bool n
 
-config NO_IOPORT
+config NO_IOPORT_MAP
        def_bool n
 
 config GENERIC_ISA_DMA
index 3995e31..dfc6020 100644 (file)
@@ -74,34 +74,26 @@ config ATH79_MACH_UBNT_XM
 endmenu
 
 config SOC_AR71XX
-       select USB_ARCH_HAS_EHCI
-       select USB_ARCH_HAS_OHCI
        select HW_HAS_PCI
        def_bool n
 
 config SOC_AR724X
-       select USB_ARCH_HAS_EHCI
-       select USB_ARCH_HAS_OHCI
        select HW_HAS_PCI
        select PCI_AR724X if PCI
        def_bool n
 
 config SOC_AR913X
-       select USB_ARCH_HAS_EHCI
        def_bool n
 
 config SOC_AR933X
-       select USB_ARCH_HAS_EHCI
        def_bool n
 
 config SOC_AR934X
-       select USB_ARCH_HAS_EHCI
        select HW_HAS_PCI
        select PCI_AR724X if PCI
        def_bool n
 
 config SOC_QCA955X
-       select USB_ARCH_HAS_EHCI
        select HW_HAS_PCI
        select PCI_AR724X if PCI
        def_bool n
index e5b73de..0026806 100644 (file)
@@ -188,7 +188,6 @@ CONFIG_USB_KBD=y
 CONFIG_USB_MOUSE=y
 CONFIG_USB=y
 CONFIG_USB_ANNOUNCE_NEW_DEVICES=y
-CONFIG_USB_DEVICEFS=y
 # CONFIG_USB_DEVICE_CLASS is not set
 CONFIG_USB_OTG_WHITELIST=y
 CONFIG_USB_WUSB_CBAF=m
index 343bebc..227a9de 100644 (file)
@@ -297,7 +297,6 @@ CONFIG_HID_WACOM=m
 CONFIG_HID_ZEROPLUS=m
 CONFIG_ZEROPLUS_FF=y
 CONFIG_USB=y
-CONFIG_USB_DEVICEFS=y
 # CONFIG_USB_DEVICE_CLASS is not set
 CONFIG_USB_DYNAMIC_MINORS=y
 CONFIG_USB_OTG_WHITELIST=y
index c16de98..7a34660 100644 (file)
@@ -47,7 +47,6 @@ CONFIG_GPIO_VR41XX=y
 # CONFIG_VGA_CONSOLE is not set
 # CONFIG_HID_SUPPORT is not set
 CONFIG_USB=m
-CONFIG_USB_DEVICEFS=y
 CONFIG_USB_OHCI_HCD=m
 CONFIG_RTC_CLASS=y
 CONFIG_RTC_DRV_VR41XX=y
index d1142e9..201edfb 100644 (file)
@@ -67,7 +67,6 @@ CONFIG_I2C_CHARDEV=y
 CONFIG_I2C_PMCMSP=y
 # CONFIG_USB_HID is not set
 CONFIG_USB=y
-CONFIG_USB_DEVICEFS=y
 CONFIG_USB_MON=y
 CONFIG_USB_EHCI_HCD=y
 CONFIG_USB_EHCI_ROOT_HUB_TT=y
index 593946a..d269a53 100644 (file)
@@ -575,7 +575,6 @@ CONFIG_USB_HIDDEV=y
 CONFIG_USB_KBD=m
 CONFIG_USB_MOUSE=m
 CONFIG_USB=m
-CONFIG_USB_DEVICEFS=y
 CONFIG_USB_MON=m
 CONFIG_USB_EHCI_HCD=m
 CONFIG_USB_EHCI_ROOT_HUB_TT=y
index 59d9d2f..73e7bf4 100644 (file)
@@ -301,7 +301,6 @@ CONFIG_USB_HIDDEV=y
 CONFIG_USB_KBD=m
 CONFIG_USB_MOUSE=m
 CONFIG_USB=m
-CONFIG_USB_DEVICEFS=y
 CONFIG_USB_MON=m
 CONFIG_USB_EHCI_HCD=m
 # CONFIG_USB_EHCI_TT_NEWSCHED is not set
index 5b0463e..51bab13 100644 (file)
@@ -72,7 +72,6 @@ CONFIG_SERIO_RAW=m
 # CONFIG_HW_RANDOM is not set
 # CONFIG_HWMON is not set
 CONFIG_USB=y
-CONFIG_USB_DEVICEFS=y
 CONFIG_USB_MON=y
 CONFIG_USB_OHCI_HCD=y
 CONFIG_EXT2_FS=y
index 30036b4..11f5150 100644 (file)
@@ -72,7 +72,6 @@ CONFIG_GPIO_TB0219=y
 # CONFIG_VGA_CONSOLE is not set
 # CONFIG_HID_SUPPORT is not set
 CONFIG_USB=m
-CONFIG_USB_DEVICEFS=y
 CONFIG_USB_MON=m
 CONFIG_USB_EHCI_HCD=m
 # CONFIG_USB_EHCI_TT_NEWSCHED is not set
index 81bfa1d..d99b190 100644 (file)
@@ -69,7 +69,6 @@ CONFIG_SERIAL_VR41XX_CONSOLE=y
 # CONFIG_VGA_CONSOLE is not set
 # CONFIG_HID_SUPPORT is not set
 CONFIG_USB=y
-CONFIG_USB_DEVICEFS=y
 CONFIG_USB_EHCI_HCD=y
 # CONFIG_USB_EHCI_TT_NEWSCHED is not set
 CONFIG_USB_OHCI_HCD=y
index 1bfd1c1..4a29665 100644 (file)
@@ -20,19 +20,13 @@ choice
        config SOC_RT305X
                bool "RT305x"
                select USB_ARCH_HAS_HCD
-               select USB_ARCH_HAS_OHCI
-               select USB_ARCH_HAS_EHCI
 
        config SOC_RT3883
                bool "RT3883"
-               select USB_ARCH_HAS_OHCI
-               select USB_ARCH_HAS_EHCI
                select HW_HAS_PCI
 
        config SOC_MT7620
                bool "MT7620"
-               select USB_ARCH_HAS_OHCI
-               select USB_ARCH_HAS_EHCI
 
 endchoice
 
index 9488209..e71d712 100644 (file)
@@ -41,7 +41,7 @@ config RWSEM_XCHGADD_ALGORITHM
 config GENERIC_HWEIGHT
        def_bool y
 
-config NO_IOPORT
+config NO_IOPORT_MAP
        def_bool y
 
 config TRACE_IRQFLAGS_SUPPORT
index acacd34..b2c3905 100644 (file)
@@ -128,7 +128,6 @@ CONFIG_SND_AD1889=y
 CONFIG_USB_HIDDEV=y
 CONFIG_USB=y
 CONFIG_USB_DEBUG=y
-CONFIG_USB_DEVICEFS=y
 CONFIG_USB_OHCI_HCD=y
 CONFIG_USB_PRINTER=m
 CONFIG_USB_STORAGE=m
index ba61495..4d8127e 100644 (file)
@@ -145,7 +145,6 @@ CONFIG_HID_SONY=y
 CONFIG_HID_SUNPLUS=y
 CONFIG_HID_TOPSEED=y
 CONFIG_USB=y
-CONFIG_USB_DEVICEFS=y
 CONFIG_USB_MON=y
 CONFIG_USB_OHCI_HCD=y
 CONFIG_USB_UHCI_HCD=y
index 17582a3..09e078a 100644 (file)
@@ -58,7 +58,6 @@ CONFIG_SERIAL_OF_PLATFORM=y
 CONFIG_THERMAL=y
 CONFIG_VIDEO_OUTPUT_CONTROL=m
 CONFIG_USB=y
-CONFIG_USB_DEVICEFS=y
 CONFIG_USB_MON=y
 CONFIG_USB_OHCI_HCD=y
 CONFIG_USB_OHCI_HCD_PPC_OF_BE=y
index d5be93e..47aefd0 100644 (file)
@@ -72,7 +72,6 @@ CONFIG_I2C_IBM_IIC=y
 CONFIG_SENSORS_AD7414=y
 CONFIG_USB=y
 CONFIG_USB_ANNOUNCE_NEW_DEVICES=y
-CONFIG_USB_DEVICEFS=y
 CONFIG_USB_MON=y
 CONFIG_USB_EHCI_HCD=m
 CONFIG_USB_OHCI_HCD=y
index ca088cd..9622eb2 100644 (file)
@@ -83,7 +83,6 @@ CONFIG_HID_SAMSUNG=y
 CONFIG_HID_SONY=y
 CONFIG_HID_SUNPLUS=y
 CONFIG_USB=y
-CONFIG_USB_DEVICEFS=y
 # CONFIG_USB_DEVICE_CLASS is not set
 CONFIG_USB_EHCI_HCD=m
 CONFIG_USB_OHCI_HCD=y
index 0b88c7b..7f979fb 100644 (file)
@@ -65,7 +65,6 @@ CONFIG_I2C_MPC=y
 # CONFIG_HWMON is not set
 CONFIG_WATCHDOG=y
 CONFIG_USB=y
-CONFIG_USB_DEVICEFS=y
 # CONFIG_USB_DEVICE_CLASS is not set
 CONFIG_USB_OHCI_HCD=y
 CONFIG_USB_OHCI_HCD_PPC_OF_BE=y
index 430aa18..279686d 100644 (file)
@@ -77,7 +77,6 @@ CONFIG_I2C_CHARDEV=y
 CONFIG_I2C_MPC=y
 # CONFIG_HWMON is not set
 CONFIG_USB=y
-CONFIG_USB_DEVICEFS=y
 # CONFIG_USB_DEVICE_CLASS is not set
 CONFIG_USB_OHCI_HCD=m
 # CONFIG_USB_OHCI_HCD_PPC_SOC is not set
index 7af4c5b..39a686e 100644 (file)
@@ -76,7 +76,6 @@ CONFIG_FB_FOREIGN_ENDIAN=y
 CONFIG_FB_SM501=y
 CONFIG_FRAMEBUFFER_CONSOLE=y
 CONFIG_USB=y
-CONFIG_USB_DEVICEFS=y
 # CONFIG_USB_DEVICE_CLASS is not set
 CONFIG_USB_MON=y
 CONFIG_USB_OHCI_HCD=y
index e4ad2e2..e4a43fe 100644 (file)
@@ -75,7 +75,6 @@ CONFIG_WATCHDOG=y
 CONFIG_VIDEO_OUTPUT_CONTROL=m
 # CONFIG_USB_HID is not set
 CONFIG_USB=y
-CONFIG_USB_DEVICEFS=y
 CONFIG_USB_MON=y
 CONFIG_USB_EHCI_HCD=y
 CONFIG_USB_EHCI_FSL=y
index 34ff568..4e5e4bc 100644 (file)
@@ -72,7 +72,6 @@ CONFIG_WATCHDOG=y
 CONFIG_VIDEO_OUTPUT_CONTROL=m
 # CONFIG_USB_HID is not set
 CONFIG_USB=y
-CONFIG_USB_DEVICEFS=y
 CONFIG_USB_MON=y
 CONFIG_USB_EHCI_HCD=y
 CONFIG_USB_EHCI_FSL=y
index b4da1a7..5adc4ce 100644 (file)
@@ -61,7 +61,6 @@ CONFIG_WATCHDOG=y
 CONFIG_VIDEO_OUTPUT_CONTROL=m
 # CONFIG_USB_HID is not set
 CONFIG_USB=y
-CONFIG_USB_DEVICEFS=y
 CONFIG_USB_MON=y
 CONFIG_USB_EHCI_HCD=y
 CONFIG_USB_OHCI_HCD=y
index 291f822..82b6b6c 100644 (file)
@@ -71,7 +71,6 @@ CONFIG_SPI_BITBANG=y
 CONFIG_WATCHDOG=y
 CONFIG_VIDEO_OUTPUT_CONTROL=m
 CONFIG_USB=y
-CONFIG_USB_DEVICEFS=y
 CONFIG_USB_MON=y
 CONFIG_USB_EHCI_HCD=y
 CONFIG_USB_EHCI_FSL=y
index 6d6463f..f859fb1 100644 (file)
@@ -71,7 +71,6 @@ CONFIG_I2C_MPC=y
 CONFIG_WATCHDOG=y
 # CONFIG_USB_HID is not set
 CONFIG_USB=y
-CONFIG_USB_DEVICEFS=y
 CONFIG_USB_MON=y
 CONFIG_USB_EHCI_HCD=y
 CONFIG_USB_EHCI_FSL=y
index c9765b5..dc939de 100644 (file)
@@ -158,7 +158,6 @@ CONFIG_HID_TOPSEED=y
 CONFIG_HID_THRUSTMASTER=y
 CONFIG_HID_ZEROPLUS=y
 CONFIG_USB=y
-CONFIG_USB_DEVICEFS=y
 CONFIG_USB_EHCI_HCD=y
 # CONFIG_USB_EHCI_TT_NEWSCHED is not set
 CONFIG_USB_EHCI_FSL=y
index 77506b5..0eb5954 100644 (file)
@@ -87,7 +87,6 @@ CONFIG_FONTS=y
 CONFIG_FONT_8x16=y
 CONFIG_USB=y
 CONFIG_USB_ANNOUNCE_NEW_DEVICES=y
-CONFIG_USB_DEVICEFS=y
 CONFIG_USB_MON=y
 CONFIG_USB_EHCI_HCD=y
 CONFIG_USB_OHCI_HCD=y
index 1cd6fcb..98bd50c 100644 (file)
@@ -126,7 +126,6 @@ CONFIG_SENSORS_LM90=y
 CONFIG_WATCHDOG=y
 CONFIG_VIDEO_OUTPUT_CONTROL=y
 CONFIG_USB=y
-CONFIG_USB_DEVICEFS=y
 # CONFIG_USB_DEVICE_CLASS is not set
 CONFIG_USB_MON=y
 CONFIG_USB_ISP1760_HCD=y
index f51c7eb..76f43df 100644 (file)
@@ -123,7 +123,6 @@ CONFIG_HID_SAMSUNG=y
 CONFIG_HID_SONY=y
 CONFIG_HID_SUNPLUS=y
 CONFIG_USB=y
-CONFIG_USB_DEVICEFS=y
 CONFIG_USB_MON=y
 CONFIG_USB_EHCI_HCD=y
 CONFIG_USB_OHCI_HCD=y
index b6d49da..8c66b13 100644 (file)
@@ -108,7 +108,6 @@ CONFIG_HID_SONY=y
 CONFIG_HID_SUNPLUS=y
 CONFIG_HID_TOPSEED=y
 CONFIG_USB=y
-CONFIG_USB_DEVICEFS=y
 CONFIG_USB_MON=y
 CONFIG_USB_OHCI_HCD=y
 CONFIG_USB_UHCI_HCD=y
index 671a8f9..3d091b5 100644 (file)
@@ -262,7 +262,6 @@ CONFIG_USBPCWATCHDOG=m
 # CONFIG_VGA_CONSOLE is not set
 # CONFIG_HID_SUPPORT is not set
 CONFIG_USB=m
-CONFIG_USB_DEVICEFS=y
 # CONFIG_USB_DEVICE_CLASS is not set
 CONFIG_USB_MON=m
 CONFIG_USB_EHCI_HCD=m
index 22a403d..4bee1a6 100644 (file)
@@ -179,7 +179,6 @@ CONFIG_VIDEO_OUTPUT_CONTROL=m
 CONFIG_HID=m
 # CONFIG_USB_HID is not set
 CONFIG_USB=m
-CONFIG_USB_DEVICEFS=y
 CONFIG_USB_MON=m
 CONFIG_USB_EHCI_HCD=m
 # CONFIG_USB_EHCI_HCD_PPC_OF is not set
index 895449e..6d7b22f 100644 (file)
@@ -87,7 +87,6 @@ CONFIG_WATCHDOG=y
 # CONFIG_VGA_CONSOLE is not set
 CONFIG_USB_HIDDEV=y
 CONFIG_USB=y
-CONFIG_USB_DEVICEFS=y
 # CONFIG_USB_DEVICE_CLASS is not set
 CONFIG_USB_MON=y
 CONFIG_USB_EHCI_HCD=m
index b20554e..db5b308 100644 (file)
@@ -111,7 +111,6 @@ CONFIG_HID_SAMSUNG=y
 CONFIG_HID_SONY=y
 CONFIG_HID_SUNPLUS=y
 CONFIG_USB=y
-CONFIG_USB_DEVICEFS=y
 CONFIG_USB_MON=y
 CONFIG_USB_EHCI_HCD=m
 # CONFIG_USB_EHCI_HCD_PPC_OF is not set
index 1ea22fc..3c72fa6 100644 (file)
@@ -175,7 +175,6 @@ CONFIG_HID_SAMSUNG=y
 CONFIG_HID_SONY=y
 CONFIG_HID_SUNPLUS=y
 CONFIG_USB=y
-CONFIG_USB_DEVICEFS=y
 CONFIG_USB_MON=y
 CONFIG_USB_EHCI_HCD=y
 # CONFIG_USB_EHCI_HCD_PPC_OF is not set
index 8a874b9..67389b9 100644 (file)
@@ -112,7 +112,6 @@ CONFIG_VIDEO_OUTPUT_CONTROL=m
 CONFIG_HID=m
 # CONFIG_USB_HID is not set
 CONFIG_USB=y
-CONFIG_USB_DEVICEFS=y
 CONFIG_USB_MON=y
 CONFIG_USB_EHCI_HCD=y
 CONFIG_USB_OHCI_HCD=y
index 2a5afac..95e545d 100644 (file)
@@ -79,7 +79,6 @@ CONFIG_HID_SAMSUNG=y
 CONFIG_HID_SONY=y
 CONFIG_HID_SUNPLUS=y
 CONFIG_USB=y
-CONFIG_USB_DEVICEFS=y
 CONFIG_USB_MON=y
 CONFIG_USB_EHCI_HCD=y
 CONFIG_USB_EHCI_ROOT_HUB_TT=y
index 8b682d1..530601e 100644 (file)
@@ -113,7 +113,6 @@ CONFIG_HID_TOPSEED=y
 CONFIG_HID_THRUSTMASTER=y
 CONFIG_HID_ZEROPLUS=y
 CONFIG_USB=y
-CONFIG_USB_DEVICEFS=y
 # CONFIG_USB_DEVICE_CLASS is not set
 CONFIG_USB_MON=y
 CONFIG_USB_OHCI_HCD=y
index a1cc817..35595ea 100644 (file)
@@ -126,7 +126,6 @@ CONFIG_HID_SAMSUNG=y
 CONFIG_HID_SONY=y
 CONFIG_HID_SUNPLUS=y
 CONFIG_USB=y
-CONFIG_USB_DEVICEFS=y
 CONFIG_USB_MON=y
 CONFIG_USB_EHCI_HCD=y
 CONFIG_USB_OHCI_HCD=y
index a73626b..553e662 100644 (file)
@@ -279,7 +279,6 @@ CONFIG_HID_SAMSUNG=y
 CONFIG_HID_SONY=y
 CONFIG_HID_SUNPLUS=y
 CONFIG_HID_TOPSEED=y
-CONFIG_USB_DEVICEFS=y
 CONFIG_USB_DYNAMIC_MINORS=y
 CONFIG_USB_MON=y
 CONFIG_USB_EHCI_HCD=m
index c2353bf..8098458 100644 (file)
@@ -966,7 +966,6 @@ CONFIG_HID_SUNPLUS=y
 CONFIG_USB=y
 CONFIG_USB_DEBUG=y
 CONFIG_USB_ANNOUNCE_NEW_DEVICES=y
-CONFIG_USB_DEVICEFS=y
 # CONFIG_USB_DEVICE_CLASS is not set
 CONFIG_USB_MON=y
 CONFIG_USB_EHCI_HCD=m
index ebb2a66..7687f4d 100644 (file)
@@ -73,7 +73,6 @@ CONFIG_I2C_CHARDEV=y
 CONFIG_I2C_MPC=y
 # CONFIG_HWMON is not set
 CONFIG_USB=y
-CONFIG_USB_DEVICEFS=y
 CONFIG_USB_EHCI_HCD=y
 CONFIG_USB_OHCI_HCD=y
 CONFIG_USB_STORAGE=y
index 7898be9..d64e92b 100644 (file)
@@ -36,7 +36,7 @@ static int __init early_init_dt_scan_epapr(unsigned long node,
                                           int depth, void *data)
 {
        const u32 *insts;
-       unsigned long len;
+       int len;
        int i;
 
        insts = of_get_flat_dt_prop(node, "hcall-instructions", &len);
index 2230fd0..7213d93 100644 (file)
@@ -55,9 +55,9 @@ int crash_mem_ranges;
 int __init early_init_dt_scan_fw_dump(unsigned long node,
                        const char *uname, int depth, void *data)
 {
-       __be32 *sections;
+       const __be32 *sections;
        int i, num_sections;
-       unsigned long size;
+       int size;
        const int *token;
 
        if (depth != 1 || strcmp(uname, "rtas") != 0)
index f58c0d3..8dd5a09 100644 (file)
@@ -162,7 +162,7 @@ static struct ibm_pa_feature {
        {CPU_FTR_REAL_LE, PPC_FEATURE_TRUE_LE, 5, 0, 0},
 };
 
-static void __init scan_features(unsigned long node, unsigned char *ftrs,
+static void __init scan_features(unsigned long node, const unsigned char *ftrs,
                                 unsigned long tablelen,
                                 struct ibm_pa_feature *fp,
                                 unsigned long ft_size)
@@ -201,8 +201,8 @@ static void __init scan_features(unsigned long node, unsigned char *ftrs,
 
 static void __init check_cpu_pa_features(unsigned long node)
 {
-       unsigned char *pa_ftrs;
-       unsigned long tablelen;
+       const unsigned char *pa_ftrs;
+       int tablelen;
 
        pa_ftrs = of_get_flat_dt_prop(node, "ibm,pa-features", &tablelen);
        if (pa_ftrs == NULL)
@@ -215,7 +215,7 @@ static void __init check_cpu_pa_features(unsigned long node)
 #ifdef CONFIG_PPC_STD_MMU_64
 static void __init check_cpu_slb_size(unsigned long node)
 {
-       __be32 *slb_size_ptr;
+       const __be32 *slb_size_ptr;
 
        slb_size_ptr = of_get_flat_dt_prop(node, "slb-size", NULL);
        if (slb_size_ptr != NULL) {
@@ -256,7 +256,7 @@ static struct feature_property {
 static inline void identical_pvr_fixup(unsigned long node)
 {
        unsigned int pvr;
-       char *model = of_get_flat_dt_prop(node, "model", NULL);
+       const char *model = of_get_flat_dt_prop(node, "model", NULL);
 
        /*
         * Since 440GR(x)/440EP(x) processors have the same pvr,
@@ -294,11 +294,11 @@ static int __init early_init_dt_scan_cpus(unsigned long node,
                                          const char *uname, int depth,
                                          void *data)
 {
-       char *type = of_get_flat_dt_prop(node, "device_type", NULL);
+       const char *type = of_get_flat_dt_prop(node, "device_type", NULL);
        const __be32 *prop;
        const __be32 *intserv;
        int i, nthreads;
-       unsigned long len;
+       int len;
        int found = -1;
        int found_thread = 0;
 
@@ -391,7 +391,7 @@ static int __init early_init_dt_scan_cpus(unsigned long node,
 int __init early_init_dt_scan_chosen_ppc(unsigned long node, const char *uname,
                                         int depth, void *data)
 {
-       unsigned long *lprop; /* All these set by kernel, so no need to convert endian */
+       const unsigned long *lprop; /* All these set by kernel, so no need to convert endian */
 
        /* Use common scan routine to determine if this is the chosen node */
        if (early_init_dt_scan_chosen(node, uname, depth, data) == 0)
@@ -442,8 +442,9 @@ int __init early_init_dt_scan_chosen_ppc(unsigned long node, const char *uname,
  */
 static int __init early_init_dt_scan_drconf_memory(unsigned long node)
 {
-       __be32 *dm, *ls, *usm;
-       unsigned long l, n, flags;
+       const __be32 *dm, *ls, *usm;
+       int l;
+       unsigned long n, flags;
        u64 base, size, memblock_size;
        unsigned int is_kexec_kdump = 0, rngs;
 
@@ -563,7 +564,8 @@ void __init early_init_dt_add_memory_arch(u64 base, u64 size)
 
 static void __init early_reserve_mem_dt(void)
 {
-       unsigned long i, len, dt_root;
+       unsigned long i, dt_root;
+       int len;
        const __be32 *prop;
 
        dt_root = of_get_flat_dt_root();
index 4cf674d..8c923ba 100644 (file)
@@ -1135,7 +1135,7 @@ void __init rtas_initialize(void)
 int __init early_init_dt_scan_rtas(unsigned long node,
                const char *uname, int depth, void *data)
 {
-       u32 *basep, *entryp, *sizep;
+       const u32 *basep, *entryp, *sizep;
 
        if (depth != 1 || strcmp(uname, "rtas") != 0)
                return 0;
index 6650699..ff27d16 100644 (file)
@@ -265,9 +265,9 @@ static int __init htab_dt_scan_seg_sizes(unsigned long node,
                                         const char *uname, int depth,
                                         void *data)
 {
-       char *type = of_get_flat_dt_prop(node, "device_type", NULL);
-       __be32 *prop;
-       unsigned long size = 0;
+       const char *type = of_get_flat_dt_prop(node, "device_type", NULL);
+       const __be32 *prop;
+       int size = 0;
 
        /* We are scanning "cpu" nodes only */
        if (type == NULL || strcmp(type, "cpu") != 0)
@@ -320,9 +320,9 @@ static int __init htab_dt_scan_page_sizes(unsigned long node,
                                          const char *uname, int depth,
                                          void *data)
 {
-       char *type = of_get_flat_dt_prop(node, "device_type", NULL);
-       __be32 *prop;
-       unsigned long size = 0;
+       const char *type = of_get_flat_dt_prop(node, "device_type", NULL);
+       const __be32 *prop;
+       int size = 0;
 
        /* We are scanning "cpu" nodes only */
        if (type == NULL || strcmp(type, "cpu") != 0)
@@ -402,9 +402,9 @@ static int __init htab_dt_scan_page_sizes(unsigned long node,
 static int __init htab_dt_scan_hugepage_blocks(unsigned long node,
                                        const char *uname, int depth,
                                        void *data) {
-       char *type = of_get_flat_dt_prop(node, "device_type", NULL);
-       __be64 *addr_prop;
-       __be32 *page_count_prop;
+       const char *type = of_get_flat_dt_prop(node, "device_type", NULL);
+       const __be64 *addr_prop;
+       const __be32 *page_count_prop;
        unsigned int expected_pages;
        long unsigned int phys_addr;
        long unsigned int block_size;
@@ -546,8 +546,8 @@ static int __init htab_dt_scan_pftsize(unsigned long node,
                                       const char *uname, int depth,
                                       void *data)
 {
-       char *type = of_get_flat_dt_prop(node, "device_type", NULL);
-       __be32 *prop;
+       const char *type = of_get_flat_dt_prop(node, "device_type", NULL);
+       const __be32 *prop;
 
        /* We are scanning "cpu" nodes only */
        if (type == NULL || strcmp(type, "cpu") != 0)
index 1f0ebde..863d893 100644 (file)
@@ -1121,8 +1121,7 @@ oprof_cpufreq_notify(struct notifier_block *nb, unsigned long val, void *data)
        int ret = 0;
        struct cpufreq_freqs *frq = data;
        if ((val == CPUFREQ_PRECHANGE && frq->old < frq->new) ||
-           (val == CPUFREQ_POSTCHANGE && frq->old > frq->new) ||
-           (val == CPUFREQ_RESUMECHANGE || val == CPUFREQ_SUSPENDCHANGE))
+           (val == CPUFREQ_POSTCHANGE && frq->old > frq->new))
                set_spu_profiling_frequency(frq->new, spu_cycle_reset);
        return ret;
 }
index d6c7506..dc1a264 100644 (file)
@@ -265,7 +265,6 @@ config 440EP
        select PPC_FPU
        select IBM440EP_ERR42
        select IBM_EMAC_ZMII
-       select USB_ARCH_HAS_OHCI
 
 config 440EPX
        bool
index 18c1048..6e19b0a 100644 (file)
@@ -199,8 +199,8 @@ static void __init efika_setup_arch(void)
 
 static int __init efika_probe(void)
 {
-       char *model = of_get_flat_dt_prop(of_get_flat_dt_root(),
-                                         "model", NULL);
+       const char *model = of_get_flat_dt_prop(of_get_flat_dt_root(),
+                                               "model", NULL);
 
        if (model == NULL)
                return 0;
index c665d7d..7044fd3 100644 (file)
@@ -574,8 +574,8 @@ chrp_init2(void)
 
 static int __init chrp_probe(void)
 {
-       char *dtype = of_get_flat_dt_prop(of_get_flat_dt_root(),
-                                         "device_type", NULL);
+       const char *dtype = of_get_flat_dt_prop(of_get_flat_dt_root(),
+                                               "device_type", NULL);
        if (dtype == NULL)
                return 0;
        if (strcmp(dtype, "chrp"))
index 65499ad..f51b64c 100644 (file)
@@ -50,7 +50,7 @@ int __init early_init_dt_scan_opal(unsigned long node,
                                   const char *uname, int depth, void *data)
 {
        const void *basep, *entryp;
-       unsigned long basesz, entrysz;
+       int basesz, entrysz;
 
        if (depth != 1 || strcmp(uname, "ibm,opal") != 0)
                return 0;
@@ -64,9 +64,9 @@ int __init early_init_dt_scan_opal(unsigned long node,
        opal.base = of_read_number(basep, basesz/4);
        opal.entry = of_read_number(entryp, entrysz/4);
 
-       pr_debug("OPAL Base  = 0x%llx (basep=%p basesz=%ld)\n",
+       pr_debug("OPAL Base  = 0x%llx (basep=%p basesz=%d)\n",
                 opal.base, basep, basesz);
-       pr_debug("OPAL Entry = 0x%llx (entryp=%p basesz=%ld)\n",
+       pr_debug("OPAL Entry = 0x%llx (entryp=%p basesz=%d)\n",
                 opal.entry, entryp, entrysz);
 
        powerpc_firmware_features |= FW_FEATURE_OPAL;
@@ -269,7 +269,7 @@ int opal_get_chars(uint32_t vtermno, char *buf, int count)
        if ((be64_to_cpu(evt) & OPAL_EVENT_CONSOLE_INPUT) == 0)
                return 0;
        len = cpu_to_be64(count);
-       rc = opal_console_read(vtermno, &len, buf);     
+       rc = opal_console_read(vtermno, &len, buf);
        if (rc == OPAL_SUCCESS)
                return be64_to_cpu(len);
        return 0;
index e87c194..56f2740 100644 (file)
@@ -2,10 +2,8 @@ config PPC_PS3
        bool "Sony PS3"
        depends on PPC64 && PPC_BOOK3S
        select PPC_CELL
-       select USB_ARCH_HAS_OHCI
        select USB_OHCI_LITTLE_ENDIAN
        select USB_OHCI_BIG_ENDIAN_MMIO
-       select USB_ARCH_HAS_EHCI
        select USB_EHCI_BIG_ENDIAN_MMIO
        select PPC_PCI_CHOICE
        help
index 972df0f..0b84df9 100644 (file)
@@ -671,7 +671,7 @@ static int __init pseries_probe_fw_features(unsigned long node,
                                            void *data)
 {
        const char *prop;
-       unsigned long len;
+       int len;
        static int hypertas_found;
        static int vec5_found;
 
@@ -704,7 +704,7 @@ static int __init pseries_probe_fw_features(unsigned long node,
 static int __init pSeries_probe(void)
 {
        unsigned long root = of_get_flat_dt_root();
-       char *dtype = of_get_flat_dt_prop(root, "device_type", NULL);
+       const char *dtype = of_get_flat_dt_prop(root, "device_type", NULL);
 
        if (dtype == NULL)
                return 0;
index a0a3bed..f9d89eb 100644 (file)
@@ -52,7 +52,7 @@ config KEXEC
 config AUDIT_ARCH
        def_bool y
 
-config NO_IOPORT
+config NO_IOPORT_MAP
        def_bool y
 
 config PCI_QUIRKS
index 6357710..8356f39 100644 (file)
@@ -3,7 +3,7 @@ config SUPERH
        select ARCH_MIGHT_HAVE_PC_PARPORT
        select EXPERT
        select CLKDEV_LOOKUP
-       select HAVE_IDE if HAS_IOPORT
+       select HAVE_IDE if HAS_IOPORT_MAP
        select HAVE_MEMBLOCK
        select HAVE_MEMBLOCK_NODE_MAP
        select ARCH_DISCARD_MEMBLOCK
@@ -147,7 +147,7 @@ config ARCH_HAS_ILOG2_U32
 config ARCH_HAS_ILOG2_U64
        def_bool n
 
-config NO_IOPORT
+config NO_IOPORT_MAP
        def_bool !PCI
        depends on !SH_CAYMAN && !SH_SH4202_MICRODEV && !SH_SHMIN && \
                   !SH_HP6XX && !SH_SOLUTION_ENGINE
@@ -181,6 +181,7 @@ menu "System type"
 #
 config CPU_SH2
        bool
+       select SH_INTC
 
 config CPU_SH2A
        bool
@@ -191,6 +192,7 @@ config CPU_SH3
        bool
        select CPU_HAS_INTEVT
        select CPU_HAS_SR_RB
+       select SH_INTC
        select SYS_SUPPORTS_TMU
 
 config CPU_SH4
@@ -198,6 +200,7 @@ config CPU_SH4
        select CPU_HAS_INTEVT
        select CPU_HAS_SR_RB
        select CPU_HAS_FPU if !CPU_SH4AL_DSP
+       select SH_INTC
        select SYS_SUPPORTS_TMU
        select SYS_SUPPORTS_HUGETLBFS if MMU
 
@@ -356,7 +359,6 @@ config CPU_SUBTYPE_SH7720
        select CPU_HAS_DSP
        select SYS_SUPPORTS_CMT
        select ARCH_WANT_OPTIONAL_GPIOLIB
-       select USB_ARCH_HAS_OHCI
        select USB_OHCI_SH if USB_OHCI_HCD
        select PINCTRL
        help
@@ -367,7 +369,6 @@ config CPU_SUBTYPE_SH7721
        select CPU_SH3
        select CPU_HAS_DSP
        select SYS_SUPPORTS_CMT
-       select USB_ARCH_HAS_OHCI
        select USB_OHCI_SH if USB_OHCI_HCD
        help
          Select SH7721 if you have a SH3-DSP SH7721 CPU.
@@ -445,8 +446,6 @@ config CPU_SUBTYPE_SH7734
        select CPU_SH4A
        select CPU_SHX2
        select ARCH_WANT_OPTIONAL_GPIOLIB
-       select USB_ARCH_HAS_OHCI
-       select USB_ARCH_HAS_EHCI
        select PINCTRL
        help
          Select SH7734 if you have a SH4A SH7734 CPU.
@@ -456,8 +455,6 @@ config CPU_SUBTYPE_SH7757
        select CPU_SH4A
        select CPU_SHX2
        select ARCH_WANT_OPTIONAL_GPIOLIB
-       select USB_ARCH_HAS_OHCI
-       select USB_ARCH_HAS_EHCI
        select PINCTRL
        help
          Select SH7757 if you have a SH4A SH7757 CPU.
@@ -465,7 +462,6 @@ config CPU_SUBTYPE_SH7757
 config CPU_SUBTYPE_SH7763
        bool "Support SH7763 processor"
        select CPU_SH4A
-       select USB_ARCH_HAS_OHCI
        select USB_OHCI_SH if USB_OHCI_HCD
        help
          Select SH7763 if you have a SH4A SH7763(R5S77631) CPU.
@@ -494,9 +490,7 @@ config CPU_SUBTYPE_SH7786
        select CPU_HAS_PTEAEX
        select GENERIC_CLOCKEVENTS_BROADCAST if SMP
        select ARCH_WANT_OPTIONAL_GPIOLIB
-       select USB_ARCH_HAS_OHCI
        select USB_OHCI_SH if USB_OHCI_HCD
-       select USB_ARCH_HAS_EHCI
        select USB_EHCI_SH if USB_EHCI_HCD
        select PINCTRL
 
index eb1cf84..e331e53 100644 (file)
@@ -158,7 +158,7 @@ config SH_SDK7786
        bool "SDK7786"
        depends on CPU_SUBTYPE_SH7786
        select SYS_SUPPORTS_PCI
-       select NO_IOPORT if !PCI
+       select NO_IOPORT_MAP if !PCI
        select ARCH_WANT_OPTIONAL_GPIOLIB
        select HAVE_SRAM_POOL
        select REGULATOR_FIXED_VOLTAGE if REGULATOR
@@ -204,7 +204,7 @@ config SH_URQUELL
        depends on CPU_SUBTYPE_SH7786
        select ARCH_REQUIRE_GPIOLIB
        select SYS_SUPPORTS_PCI
-       select NO_IOPORT if !PCI
+       select NO_IOPORT_MAP if !PCI
 
 config SH_MIGOR
        bool "Migo-R"
@@ -306,7 +306,7 @@ config SH_LBOX_RE2
 config SH_X3PROTO
        bool "SH-X3 Prototype board"
        depends on CPU_SUBTYPE_SHX3
-       select NO_IOPORT if !PCI
+       select NO_IOPORT_MAP if !PCI
        select IRQ_DOMAIN
 
 config SH_MAGIC_PANEL_R2
@@ -333,7 +333,7 @@ config SH_POLARIS
 
 config SH_SH2007
        bool "SH-2007 board"
-       select NO_IOPORT
+       select NO_IOPORT_MAP
        select REGULATOR_FIXED_VOLTAGE if REGULATOR
        depends on CPU_SUBTYPE_SH7780
        help
index 5bc3a15..0d30492 100644 (file)
@@ -861,14 +861,12 @@ static struct asoc_simple_card_info fsi_da7210_info = {
        .card           = "FSIB-DA7210",
        .codec          = "da7210.0-001a",
        .platform       = "sh_fsi.0",
-       .daifmt         = SND_SOC_DAIFMT_I2S,
+       .daifmt         = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_CBM_CFM,
        .cpu_dai = {
                .name   = "fsib-dai",
-               .fmt    = SND_SOC_DAIFMT_CBS_CFS | SND_SOC_DAIFMT_IB_NF,
        },
        .codec_dai = {
                .name   = "da7210-hifi",
-               .fmt    = SND_SOC_DAIFMT_CBM_CFM,
        },
 };
 
@@ -876,6 +874,8 @@ static struct platform_device fsi_da7210_device = {
        .name   = "asoc-simple-card",
        .dev    = {
                .platform_data  = &fsi_da7210_info,
+               .coherent_dma_mask = DMA_BIT_MASK(32),
+               .dma_mask = &fsi_da7210_device.dev.coherent_dma_mask,
        },
 };
 
index 21e4230..1162bc6 100644 (file)
@@ -304,14 +304,12 @@ static struct asoc_simple_card_info fsi_ak4642_info = {
        .card           = "FSIA-AK4642",
        .codec          = "ak4642-codec.0-0012",
        .platform       = "sh_fsi.0",
-       .daifmt         = SND_SOC_DAIFMT_LEFT_J,
+       .daifmt         = SND_SOC_DAIFMT_LEFT_J | SND_SOC_DAIFMT_CBM_CFM,
        .cpu_dai = {
                .name   = "fsia-dai",
-               .fmt    = SND_SOC_DAIFMT_CBS_CFS | SND_SOC_DAIFMT_IB_NF,
        },
        .codec_dai = {
                .name   = "ak4642-hifi",
-               .fmt    = SND_SOC_DAIFMT_CBM_CFM,
                .sysclk = 11289600,
        },
 };
index c6c2bec..0b364e3 100644 (file)
@@ -107,7 +107,6 @@ CONFIG_SND_SOC=y
 CONFIG_SND_SOC_SH4_FSI=y
 CONFIG_SND_FSI_DA7210=y
 CONFIG_USB=y
-CONFIG_USB_DEVICEFS=y
 CONFIG_USB_MON=y
 CONFIG_USB_R8A66597_HCD=y
 CONFIG_USB_STORAGE=y
index 3670e93..6783f31 100644 (file)
@@ -80,7 +80,6 @@ CONFIG_HID_SAMSUNG=m
 CONFIG_HID_SONY=m
 CONFIG_HID_SUNPLUS=m
 CONFIG_USB=y
-CONFIG_USB_DEVICEFS=y
 CONFIG_USB_MON=y
 CONFIG_USB_EHCI_HCD=y
 # CONFIG_USB_EHCI_TT_NEWSCHED is not set
index 4e5229b..549412d 100644 (file)
@@ -100,7 +100,6 @@ CONFIG_HID_SONY=y
 CONFIG_HID_SUNPLUS=y
 CONFIG_USB=y
 CONFIG_USB_ANNOUNCE_NEW_DEVICES=y
-CONFIG_USB_DEVICEFS=y
 CONFIG_USB_MON=y
 CONFIG_USB_R8A66597_HCD=y
 CONFIG_NEW_LEDS=y
index ae11158..fa37e89 100644 (file)
@@ -101,7 +101,6 @@ CONFIG_HID_SONY=y
 CONFIG_HID_SUNPLUS=y
 CONFIG_USB=y
 CONFIG_USB_DEBUG=y
-CONFIG_USB_DEVICEFS=y
 # CONFIG_USB_DEVICE_CLASS is not set
 CONFIG_USB_MON=y
 CONFIG_USB_EHCI_HCD=y
index be9c474..af3fe73 100644 (file)
@@ -94,7 +94,6 @@ CONFIG_HID_SUNPLUS=y
 CONFIG_USB=y
 CONFIG_USB_DEBUG=y
 CONFIG_USB_ANNOUNCE_NEW_DEVICES=y
-CONFIG_USB_DEVICEFS=y
 CONFIG_USB_ISP116X_HCD=y
 CONFIG_UIO=y
 CONFIG_EXT2_FS=y
index c8c5e7f..b0ef63c 100644 (file)
@@ -94,7 +94,6 @@ CONFIG_HID_SAMSUNG=y
 CONFIG_HID_SONY=y
 CONFIG_HID_SUNPLUS=y
 CONFIG_USB=y
-CONFIG_USB_DEVICEFS=y
 # CONFIG_USB_DEVICE_CLASS is not set
 CONFIG_USB_MON=y
 CONFIG_USB_EHCI_HCD=y
index 0d2f414..0c08d92 100644 (file)
@@ -97,7 +97,6 @@ CONFIG_FRAMEBUFFER_CONSOLE_DETECT_PRIMARY=y
 CONFIG_LOGO=y
 # CONFIG_HID_SUPPORT is not set
 CONFIG_USB=y
-CONFIG_USB_DEVICEFS=y
 # CONFIG_USB_DEVICE_CLASS is not set
 CONFIG_USB_MON=y
 CONFIG_NEW_LEDS=y
index 51561f5..d29da4a 100644 (file)
@@ -88,7 +88,6 @@ CONFIG_HID_SAMSUNG=y
 CONFIG_HID_SONY=y
 CONFIG_HID_SUNPLUS=y
 CONFIG_USB=y
-CONFIG_USB_DEVICEFS=y
 CONFIG_USB_MON=y
 CONFIG_USB_EHCI_HCD=m
 # CONFIG_USB_EHCI_TT_NEWSCHED is not set
index e2cbd92..a77b778 100644 (file)
@@ -215,7 +215,6 @@ CONFIG_WATCHDOG=y
 CONFIG_SH_WDT=m
 # CONFIG_USB_HID is not set
 CONFIG_USB=y
-CONFIG_USB_DEVICEFS=y
 CONFIG_USB_MON=y
 CONFIG_USB_EHCI_HCD=y
 CONFIG_USB_EHCI_ROOT_HUB_TT=y
index d7f89be..1e843db 100644 (file)
@@ -117,7 +117,6 @@ CONFIG_HID_SONY=y
 CONFIG_HID_SUNPLUS=y
 CONFIG_USB=y
 CONFIG_USB_ANNOUNCE_NEW_DEVICES=y
-CONFIG_USB_DEVICEFS=y
 CONFIG_USB_MON=y
 CONFIG_USB_OHCI_HCD=y
 CONFIG_USB_STORAGE=y
index 51cd78f..c757b47 100644 (file)
 #ifndef DMA_REGISTER_H
 #define DMA_REGISTER_H
 
-/* DMA register */
-#define SAR    0x00
-#define DAR    0x04
-#define TCR    0x08
-#define CHCR   0x0C
-#define DMAOR  0x40
+/* DMA registers */
+#define SAR    0x00    /* Source Address Register */
+#define DAR    0x04    /* Destination Address Register */
+#define TCR    0x08    /* Transfer Count Register */
+#define CHCR   0x0C    /* Channel Control Register */
+#define DMAOR  0x40    /* DMA Operation Register */
 
 /* DMAOR definitions */
-#define DMAOR_AE       0x00000004
+#define DMAOR_AE       0x00000004      /* Address Error Flag */
 #define DMAOR_NMIF     0x00000002
-#define DMAOR_DME      0x00000001
+#define DMAOR_DME      0x00000001      /* DMA Master Enable */
 
 /* Definitions for the SuperH DMAC */
 #define REQ_L  0x00000000
 #define ACK_W  0x00020000
 #define ACK_H  0x00000000
 #define ACK_L  0x00010000
-#define DM_INC 0x00004000
-#define DM_DEC 0x00008000
-#define DM_FIX 0x0000c000
-#define SM_INC 0x00001000
-#define SM_DEC 0x00002000
-#define SM_FIX 0x00003000
+#define DM_INC 0x00004000      /* Destination addresses are incremented */
+#define DM_DEC 0x00008000      /* Destination addresses are decremented */
+#define DM_FIX 0x0000c000      /* Destination address is fixed */
+#define SM_INC 0x00001000      /* Source addresses are incremented */
+#define SM_DEC 0x00002000      /* Source addresses are decremented */
+#define SM_FIX 0x00003000      /* Source address is fixed */
 #define RS_IN  0x00000200
 #define RS_OUT 0x00000300
+#define RS_AUTO        0x00000400      /* Auto Request */
+#define RS_ERS 0x00000800      /* DMA extended resource selector */
 #define TS_BLK 0x00000040
 #define TM_BUR 0x00000020
-#define CHCR_DE        0x00000001
-#define CHCR_TE        0x00000002
-#define CHCR_IE        0x00000004
+#define CHCR_DE        0x00000001      /* DMA Enable */
+#define CHCR_TE        0x00000002      /* Transfer End Flag */
+#define CHCR_IE        0x00000004      /* Interrupt Enable */
 
 #endif
index 629db2a..728c4c5 100644 (file)
@@ -122,7 +122,7 @@ __BUILD_MEMORY_STRING(__raw_, l, u32)
 
 __BUILD_MEMORY_STRING(__raw_, q, u64)
 
-#ifdef CONFIG_HAS_IOPORT
+#ifdef CONFIG_HAS_IOPORT_MAP
 
 /*
  * Slowdown I/O port space accesses for antique hardware.
@@ -218,7 +218,7 @@ __BUILD_IOPORT_STRING(w, u16)
 __BUILD_IOPORT_STRING(l, u32)
 __BUILD_IOPORT_STRING(q, u64)
 
-#else /* !CONFIG_HAS_IOPORT */
+#else /* !CONFIG_HAS_IOPORT_MAP */
 
 #include <asm/io_noioport.h>
 
index f1251d4..4ab94ef 100644 (file)
@@ -36,7 +36,7 @@ __ioremap_trapped(unsigned long offset, unsigned long size)
 #define __ioremap_trapped(offset, size) NULL
 #endif
 
-#ifdef CONFIG_HAS_IOPORT
+#ifdef CONFIG_HAS_IOPORT_MAP
 extern struct list_head trapped_io;
 
 static inline void __iomem *
index eb9c20d..d3324e4 100644 (file)
@@ -21,7 +21,7 @@ struct sh_machine_vector {
        int (*mv_irq_demux)(int irq);
        void (*mv_init_irq)(void);
 
-#ifdef CONFIG_HAS_IOPORT
+#ifdef CONFIG_HAS_IOPORT_MAP
        void __iomem *(*mv_ioport_map)(unsigned long port, unsigned int size);
        void (*mv_ioport_unmap)(void __iomem *);
 #endif
index 261c8bf..2ccf36c 100644 (file)
@@ -22,7 +22,7 @@ obj-y := debugtraps.o dma-nommu.o dumpstack.o                 \
 
 ifndef CONFIG_GENERIC_IOMAP
 obj-y                          += iomap.o
-obj-$(CONFIG_HAS_IOPORT)       += ioport.o
+obj-$(CONFIG_HAS_IOPORT_MAP)   += ioport.o
 endif
 
 obj-$(CONFIG_SUPERH32)         += sys_sh32.o
index f59b1f3..8525a67 100644 (file)
@@ -56,9 +56,13 @@ int __init __deprecated cpg_clk_init(void)
 
        clkdev_add_table(lookups, ARRAY_SIZE(lookups));
 
-       clk_add_alias("tmu_fck", NULL, "peripheral_clk", NULL);
-       clk_add_alias("mtu2_fck", NULL, "peripheral_clk", NULL);
-       clk_add_alias("cmt_fck", NULL, "peripheral_clk", NULL);
+       clk_add_alias("fck", "sh-tmu-sh3.0", "peripheral_clk", NULL);
+       clk_add_alias("fck", "sh-tmu.0", "peripheral_clk", NULL);
+       clk_add_alias("fck", "sh-tmu.1", "peripheral_clk", NULL);
+       clk_add_alias("fck", "sh-tmu.2", "peripheral_clk", NULL);
+       clk_add_alias("fck", "sh-mtu2", "peripheral_clk", NULL);
+       clk_add_alias("fck", "sh-cmt-16.0", "peripheral_clk", NULL);
+       clk_add_alias("fck", "sh-cmt-32.0", "peripheral_clk", NULL);
        clk_add_alias("sci_ick", NULL, "peripheral_clk", NULL);
 
        return ret;
index 3860b0b..58c19ad 100644 (file)
@@ -152,62 +152,24 @@ static struct platform_device eth_device = {
        .resource = eth_resources,
 };
 
-static struct sh_timer_config cmt0_platform_data = {
-       .channel_offset = 0x02,
-       .timer_bit = 0,
-       .clockevent_rating = 125,
-       .clocksource_rating = 0, /* disabled due to code generation issues */
+static struct sh_timer_config cmt_platform_data = {
+       .channels_mask = 3,
 };
 
-static struct resource cmt0_resources[] = {
-       [0] = {
-               .start  = 0xf84a0072,
-               .end    = 0xf84a0077,
-               .flags  = IORESOURCE_MEM,
-       },
-       [1] = {
-               .start  = 86,
-               .flags  = IORESOURCE_IRQ,
-       },
+static struct resource cmt_resources[] = {
+       DEFINE_RES_MEM(0xf84a0070, 0x10),
+       DEFINE_RES_IRQ(86),
+       DEFINE_RES_IRQ(87),
 };
 
-static struct platform_device cmt0_device = {
-       .name           = "sh_cmt",
+static struct platform_device cmt_device = {
+       .name           = "sh-cmt-16",
        .id             = 0,
        .dev = {
-               .platform_data  = &cmt0_platform_data,
-       },
-       .resource       = cmt0_resources,
-       .num_resources  = ARRAY_SIZE(cmt0_resources),
-};
-
-static struct sh_timer_config cmt1_platform_data = {
-       .channel_offset = 0x08,
-       .timer_bit = 1,
-       .clockevent_rating = 125,
-       .clocksource_rating = 0, /* disabled due to code generation issues */
-};
-
-static struct resource cmt1_resources[] = {
-       [0] = {
-               .start  = 0xf84a0078,
-               .end    = 0xf84a007d,
-               .flags  = IORESOURCE_MEM,
-       },
-       [1] = {
-               .start  = 87,
-               .flags  = IORESOURCE_IRQ,
-       },
-};
-
-static struct platform_device cmt1_device = {
-       .name           = "sh_cmt",
-       .id             = 1,
-       .dev = {
-               .platform_data  = &cmt1_platform_data,
+               .platform_data  = &cmt_platform_data,
        },
-       .resource       = cmt1_resources,
-       .num_resources  = ARRAY_SIZE(cmt1_resources),
+       .resource       = cmt_resources,
+       .num_resources  = ARRAY_SIZE(cmt_resources),
 };
 
 static struct platform_device *sh7619_devices[] __initdata = {
@@ -215,8 +177,7 @@ static struct platform_device *sh7619_devices[] __initdata = {
        &scif1_device,
        &scif2_device,
        &eth_device,
-       &cmt0_device,
-       &cmt1_device,
+       &cmt_device,
 };
 
 static int __init sh7619_devices_setup(void)
@@ -235,8 +196,7 @@ static struct platform_device *sh7619_early_devices[] __initdata = {
        &scif0_device,
        &scif1_device,
        &scif2_device,
-       &cmt0_device,
-       &cmt1_device,
+       &cmt_device,
 };
 
 #define STBCR3 0xf80a0000
index fdf585c..8638fba 100644 (file)
@@ -117,9 +117,9 @@ static struct clk_lookup lookups[] = {
        /* MSTP clocks */
        CLKDEV_CON_ID("sci_ick", &mstp_clks[MSTP77]),
        CLKDEV_CON_ID("vdc3", &mstp_clks[MSTP74]),
-       CLKDEV_CON_ID("cmt_fck", &mstp_clks[MSTP72]),
+       CLKDEV_ICK_ID("fck", "sh-cmt-16.0", &mstp_clks[MSTP72]),
        CLKDEV_CON_ID("usb0", &mstp_clks[MSTP60]),
-       CLKDEV_CON_ID("mtu2_fck", &mstp_clks[MSTP35]),
+       CLKDEV_ICK_ID("fck", "sh-mtu2", &mstp_clks[MSTP35]),
        CLKDEV_CON_ID("sdhi0", &mstp_clks[MSTP34]),
        CLKDEV_CON_ID("sdhi1", &mstp_clks[MSTP33]),
        CLKDEV_CON_ID("adc0", &mstp_clks[MSTP32]),
index 6b78762..f8a5c2a 100644 (file)
@@ -158,9 +158,9 @@ static struct clk_lookup lookups[] = {
        CLKDEV_ICK_ID("sci_fck", "sh-sci.5", &mstp_clks[MSTP42]),
        CLKDEV_ICK_ID("sci_fck", "sh-sci.6", &mstp_clks[MSTP41]),
        CLKDEV_ICK_ID("sci_fck", "sh-sci.7", &mstp_clks[MSTP40]),
-       CLKDEV_CON_ID("cmt_fck", &mstp_clks[MSTP72]),
+       CLKDEV_ICK_ID("fck", "sh-cmt-16.0", &mstp_clks[MSTP72]),
        CLKDEV_CON_ID("usb0", &mstp_clks[MSTP60]),
-       CLKDEV_CON_ID("mtu2_fck", &mstp_clks[MSTP35]),
+       CLKDEV_ICK_ID("fck", "sh-mtu2", &mstp_clks[MSTP35]),
        CLKDEV_CON_ID("adc0", &mstp_clks[MSTP32]),
        CLKDEV_CON_ID("rtc0", &mstp_clks[MSTP30]),
 };
index 63e996f..26fcdbd 100644 (file)
@@ -114,88 +114,18 @@ static struct intc_mask_reg mask_registers[] __initdata = {
 static DECLARE_INTC_DESC(intc_desc, "mxg", vectors, groups,
                         mask_registers, prio_registers, NULL);
 
-static struct sh_timer_config mtu2_0_platform_data = {
-       .channel_offset = -0x80,
-       .timer_bit = 0,
-       .clockevent_rating = 200,
+static struct resource mtu2_resources[] = {
+       DEFINE_RES_MEM(0xff801000, 0x400),
+       DEFINE_RES_IRQ_NAMED(228, "tgi0a"),
+       DEFINE_RES_IRQ_NAMED(234, "tgi1a"),
+       DEFINE_RES_IRQ_NAMED(240, "tgi2a"),
 };
 
-static struct resource mtu2_0_resources[] = {
-       [0] = {
-               .start  = 0xff801300,
-               .end    = 0xff801326,
-               .flags  = IORESOURCE_MEM,
-       },
-       [1] = {
-               .start  = 228,
-               .flags  = IORESOURCE_IRQ,
-       },
-};
-
-static struct platform_device mtu2_0_device = {
-       .name           = "sh_mtu2",
-       .id             = 0,
-       .dev = {
-               .platform_data  = &mtu2_0_platform_data,
-       },
-       .resource       = mtu2_0_resources,
-       .num_resources  = ARRAY_SIZE(mtu2_0_resources),
-};
-
-static struct sh_timer_config mtu2_1_platform_data = {
-       .channel_offset = -0x100,
-       .timer_bit = 1,
-       .clockevent_rating = 200,
-};
-
-static struct resource mtu2_1_resources[] = {
-       [0] = {
-               .start  = 0xff801380,
-               .end    = 0xff801390,
-               .flags  = IORESOURCE_MEM,
-       },
-       [1] = {
-               .start  = 234,
-               .flags  = IORESOURCE_IRQ,
-       },
-};
-
-static struct platform_device mtu2_1_device = {
-       .name           = "sh_mtu2",
-       .id             = 1,
-       .dev = {
-               .platform_data  = &mtu2_1_platform_data,
-       },
-       .resource       = mtu2_1_resources,
-       .num_resources  = ARRAY_SIZE(mtu2_1_resources),
-};
-
-static struct sh_timer_config mtu2_2_platform_data = {
-       .channel_offset = 0x80,
-       .timer_bit = 2,
-       .clockevent_rating = 200,
-};
-
-static struct resource mtu2_2_resources[] = {
-       [0] = {
-               .start  = 0xff801000,
-               .end    = 0xff80100a,
-               .flags  = IORESOURCE_MEM,
-       },
-       [1] = {
-               .start  = 240,
-               .flags  = IORESOURCE_IRQ,
-       },
-};
-
-static struct platform_device mtu2_2_device = {
-       .name           = "sh_mtu2",
-       .id             = 2,
-       .dev = {
-               .platform_data  = &mtu2_2_platform_data,
-       },
-       .resource       = mtu2_2_resources,
-       .num_resources  = ARRAY_SIZE(mtu2_2_resources),
+static struct platform_device mtu2_device = {
+       .name           = "sh-mtu2",
+       .id             = -1,
+       .resource       = mtu2_resources,
+       .num_resources  = ARRAY_SIZE(mtu2_resources),
 };
 
 static struct plat_sci_port scif0_platform_data = {
@@ -221,9 +151,7 @@ static struct platform_device scif0_device = {
 
 static struct platform_device *mxg_devices[] __initdata = {
        &scif0_device,
-       &mtu2_0_device,
-       &mtu2_1_device,
-       &mtu2_2_device,
+       &mtu2_device,
 };
 
 static int __init mxg_devices_setup(void)
@@ -240,9 +168,7 @@ void __init plat_irq_setup(void)
 
 static struct platform_device *mxg_early_devices[] __initdata = {
        &scif0_device,
-       &mtu2_0_device,
-       &mtu2_1_device,
-       &mtu2_2_device,
+       &mtu2_device,
 };
 
 void __init plat_early_device_setup(void)
index 2c68744..abc0ce9 100644 (file)
@@ -365,88 +365,18 @@ static struct platform_device rtc_device = {
        .resource       = rtc_resources,
 };
 
-static struct sh_timer_config mtu2_0_platform_data = {
-       .channel_offset = -0x80,
-       .timer_bit = 0,
-       .clockevent_rating = 200,
+static struct resource mtu2_resources[] = {
+       DEFINE_RES_MEM(0xfffe4000, 0x400),
+       DEFINE_RES_IRQ_NAMED(108, "tgi0a"),
+       DEFINE_RES_IRQ_NAMED(116, "tgi1a"),
+       DEFINE_RES_IRQ_NAMED(124, "tgi1b"),
 };
 
-static struct resource mtu2_0_resources[] = {
-       [0] = {
-               .start  = 0xfffe4300,
-               .end    = 0xfffe4326,
-               .flags  = IORESOURCE_MEM,
-       },
-       [1] = {
-               .start  = 108,
-               .flags  = IORESOURCE_IRQ,
-       },
-};
-
-static struct platform_device mtu2_0_device = {
-       .name           = "sh_mtu2",
-       .id             = 0,
-       .dev = {
-               .platform_data  = &mtu2_0_platform_data,
-       },
-       .resource       = mtu2_0_resources,
-       .num_resources  = ARRAY_SIZE(mtu2_0_resources),
-};
-
-static struct sh_timer_config mtu2_1_platform_data = {
-       .channel_offset = -0x100,
-       .timer_bit = 1,
-       .clockevent_rating = 200,
-};
-
-static struct resource mtu2_1_resources[] = {
-       [0] = {
-               .start  = 0xfffe4380,
-               .end    = 0xfffe4390,
-               .flags  = IORESOURCE_MEM,
-       },
-       [1] = {
-               .start  = 116,
-               .flags  = IORESOURCE_IRQ,
-       },
-};
-
-static struct platform_device mtu2_1_device = {
-       .name           = "sh_mtu2",
-       .id             = 1,
-       .dev = {
-               .platform_data  = &mtu2_1_platform_data,
-       },
-       .resource       = mtu2_1_resources,
-       .num_resources  = ARRAY_SIZE(mtu2_1_resources),
-};
-
-static struct sh_timer_config mtu2_2_platform_data = {
-       .channel_offset = 0x80,
-       .timer_bit = 2,
-       .clockevent_rating = 200,
-};
-
-static struct resource mtu2_2_resources[] = {
-       [0] = {
-               .start  = 0xfffe4000,
-               .end    = 0xfffe400a,
-               .flags  = IORESOURCE_MEM,
-       },
-       [1] = {
-               .start  = 124,
-               .flags  = IORESOURCE_IRQ,
-       },
-};
-
-static struct platform_device mtu2_2_device = {
-       .name           = "sh_mtu2",
-       .id             = 2,
-       .dev = {
-               .platform_data  = &mtu2_2_platform_data,
-       },
-       .resource       = mtu2_2_resources,
-       .num_resources  = ARRAY_SIZE(mtu2_2_resources),
+static struct platform_device mtu2_device = {
+       .name           = "sh-mtu2",
+       .id             = -1,
+       .resource       = mtu2_resources,
+       .num_resources  = ARRAY_SIZE(mtu2_resources),
 };
 
 static struct platform_device *sh7201_devices[] __initdata = {
@@ -459,9 +389,7 @@ static struct platform_device *sh7201_devices[] __initdata = {
        &scif6_device,
        &scif7_device,
        &rtc_device,
-       &mtu2_0_device,
-       &mtu2_1_device,
-       &mtu2_2_device,
+       &mtu2_device,
 };
 
 static int __init sh7201_devices_setup(void)
@@ -485,9 +413,7 @@ static struct platform_device *sh7201_early_devices[] __initdata = {
        &scif5_device,
        &scif6_device,
        &scif7_device,
-       &mtu2_0_device,
-       &mtu2_1_device,
-       &mtu2_2_device,
+       &mtu2_device,
 };
 
 #define STBCR3 0xfffe0408
index d55a0f3..3b4894c 100644 (file)
@@ -265,118 +265,37 @@ static struct platform_device scif3_device = {
        },
 };
 
-static struct sh_timer_config cmt0_platform_data = {
-       .channel_offset = 0x02,
-       .timer_bit = 0,
-       .clockevent_rating = 125,
-       .clocksource_rating = 0, /* disabled due to code generation issues */
+static struct sh_timer_config cmt_platform_data = {
+       .channels_mask = 3,
 };
 
-static struct resource cmt0_resources[] = {
-       [0] = {
-               .start  = 0xfffec002,
-               .end    = 0xfffec007,
-               .flags  = IORESOURCE_MEM,
-       },
-       [1] = {
-               .start  = 142,
-               .flags  = IORESOURCE_IRQ,
-       },
-};
-
-static struct platform_device cmt0_device = {
-       .name           = "sh_cmt",
-       .id             = 0,
-       .dev = {
-               .platform_data  = &cmt0_platform_data,
-       },
-       .resource       = cmt0_resources,
-       .num_resources  = ARRAY_SIZE(cmt0_resources),
-};
-
-static struct sh_timer_config cmt1_platform_data = {
-       .channel_offset = 0x08,
-       .timer_bit = 1,
-       .clockevent_rating = 125,
-       .clocksource_rating = 0, /* disabled due to code generation issues */
-};
-
-static struct resource cmt1_resources[] = {
-       [0] = {
-               .start  = 0xfffec008,
-               .end    = 0xfffec00d,
-               .flags  = IORESOURCE_MEM,
-       },
-       [1] = {
-               .start  = 143,
-               .flags  = IORESOURCE_IRQ,
-       },
-};
-
-static struct platform_device cmt1_device = {
-       .name           = "sh_cmt",
-       .id             = 1,
-       .dev = {
-               .platform_data  = &cmt1_platform_data,
-       },
-       .resource       = cmt1_resources,
-       .num_resources  = ARRAY_SIZE(cmt1_resources),
-};
-
-static struct sh_timer_config mtu2_0_platform_data = {
-       .channel_offset = -0x80,
-       .timer_bit = 0,
-       .clockevent_rating = 200,
-};
-
-static struct resource mtu2_0_resources[] = {
-       [0] = {
-               .start  = 0xfffe4300,
-               .end    = 0xfffe4326,
-               .flags  = IORESOURCE_MEM,
-       },
-       [1] = {
-               .start  = 146,
-               .flags  = IORESOURCE_IRQ,
-       },
+static struct resource cmt_resources[] = {
+       DEFINE_RES_MEM(0xfffec000, 0x10),
+       DEFINE_RES_IRQ(142),
+       DEFINE_RES_IRQ(143),
 };
 
-static struct platform_device mtu2_0_device = {
-       .name           = "sh_mtu2",
+static struct platform_device cmt_device = {
+       .name           = "sh-cmt-16",
        .id             = 0,
        .dev = {
-               .platform_data  = &mtu2_0_platform_data,
+               .platform_data  = &cmt_platform_data,
        },
-       .resource       = mtu2_0_resources,
-       .num_resources  = ARRAY_SIZE(mtu2_0_resources),
+       .resource       = cmt_resources,
+       .num_resources  = ARRAY_SIZE(cmt_resources),
 };
 
-static struct sh_timer_config mtu2_1_platform_data = {
-       .channel_offset = -0x100,
-       .timer_bit = 1,
-       .clockevent_rating = 200,
+static struct resource mtu2_resources[] = {
+       DEFINE_RES_MEM(0xfffe4000, 0x400),
+       DEFINE_RES_IRQ_NAMED(146, "tgi0a"),
+       DEFINE_RES_IRQ_NAMED(153, "tgi1a"),
 };
 
-static struct resource mtu2_1_resources[] = {
-       [0] = {
-               .start  = 0xfffe4380,
-               .end    = 0xfffe4390,
-               .flags  = IORESOURCE_MEM,
-       },
-       [1] = {
-               .start  = 153,
-               .flags  = IORESOURCE_IRQ,
-       },
-};
-
-static struct platform_device mtu2_1_device = {
-       .name           = "sh_mtu2",
-       .id             = 1,
-       .dev = {
-               .platform_data  = &mtu2_1_platform_data,
-       },
-       .resource       = mtu2_1_resources,
-       .num_resources  = ARRAY_SIZE(mtu2_1_resources),
+static struct platform_device mtu2_device = {
+       .name           = "sh-mtu2",
+       .id             = -1,
+       .resource       = mtu2_resources,
+       .num_resources  = ARRAY_SIZE(mtu2_resources),
 };
 
 static struct resource rtc_resources[] = {
@@ -404,10 +323,8 @@ static struct platform_device *sh7203_devices[] __initdata = {
        &scif1_device,
        &scif2_device,
        &scif3_device,
-       &cmt0_device,
-       &cmt1_device,
-       &mtu2_0_device,
-       &mtu2_1_device,
+       &cmt_device,
+       &mtu2_device,
        &rtc_device,
 };
 
@@ -428,10 +345,8 @@ static struct platform_device *sh7203_early_devices[] __initdata = {
        &scif1_device,
        &scif2_device,
        &scif3_device,
-       &cmt0_device,
-       &cmt1_device,
-       &mtu2_0_device,
-       &mtu2_1_device,
+       &cmt_device,
+       &mtu2_device,
 };
 
 #define STBCR3 0xfffe0408
index 241e745..49bc5a3 100644 (file)
@@ -217,146 +217,38 @@ static struct platform_device scif3_device = {
        },
 };
 
-static struct sh_timer_config cmt0_platform_data = {
-       .channel_offset = 0x02,
-       .timer_bit = 0,
-       .clockevent_rating = 125,
-       .clocksource_rating = 0, /* disabled due to code generation issues */
+static struct sh_timer_config cmt_platform_data = {
+       .channels_mask = 3,
 };
 
-static struct resource cmt0_resources[] = {
-       [0] = {
-               .start  = 0xfffec002,
-               .end    = 0xfffec007,
-               .flags  = IORESOURCE_MEM,
-       },
-       [1] = {
-               .start  = 140,
-               .flags  = IORESOURCE_IRQ,
-       },
-};
-
-static struct platform_device cmt0_device = {
-       .name           = "sh_cmt",
-       .id             = 0,
-       .dev = {
-               .platform_data  = &cmt0_platform_data,
-       },
-       .resource       = cmt0_resources,
-       .num_resources  = ARRAY_SIZE(cmt0_resources),
-};
-
-static struct sh_timer_config cmt1_platform_data = {
-       .channel_offset = 0x08,
-       .timer_bit = 1,
-       .clockevent_rating = 125,
-       .clocksource_rating = 0, /* disabled due to code generation issues */
-};
-
-static struct resource cmt1_resources[] = {
-       [0] = {
-               .start  = 0xfffec008,
-               .end    = 0xfffec00d,
-               .flags  = IORESOURCE_MEM,
-       },
-       [1] = {
-               .start  = 144,
-               .flags  = IORESOURCE_IRQ,
-       },
-};
-
-static struct platform_device cmt1_device = {
-       .name           = "sh_cmt",
-       .id             = 1,
-       .dev = {
-               .platform_data  = &cmt1_platform_data,
-       },
-       .resource       = cmt1_resources,
-       .num_resources  = ARRAY_SIZE(cmt1_resources),
-};
-
-static struct sh_timer_config mtu2_0_platform_data = {
-       .channel_offset = -0x80,
-       .timer_bit = 0,
-       .clockevent_rating = 200,
-};
-
-static struct resource mtu2_0_resources[] = {
-       [0] = {
-               .start  = 0xfffe4300,
-               .end    = 0xfffe4326,
-               .flags  = IORESOURCE_MEM,
-       },
-       [1] = {
-               .start  = 156,
-               .flags  = IORESOURCE_IRQ,
-       },
+static struct resource cmt_resources[] = {
+       DEFINE_RES_MEM(0xfffec000, 0x10),
+       DEFINE_RES_IRQ(140),
+       DEFINE_RES_IRQ(144),
 };
 
-static struct platform_device mtu2_0_device = {
-       .name           = "sh_mtu2",
+static struct platform_device cmt_device = {
+       .name           = "sh-cmt-16",
        .id             = 0,
        .dev = {
-               .platform_data  = &mtu2_0_platform_data,
+               .platform_data  = &cmt_platform_data,
        },
-       .resource       = mtu2_0_resources,
-       .num_resources  = ARRAY_SIZE(mtu2_0_resources),
+       .resource       = cmt_resources,
+       .num_resources  = ARRAY_SIZE(cmt_resources),
 };
 
-static struct sh_timer_config mtu2_1_platform_data = {
-       .channel_offset = -0x100,
-       .timer_bit = 1,
-       .clockevent_rating = 200,
+static struct resource mtu2_resources[] = {
+       DEFINE_RES_MEM(0xfffe4000, 0x400),
+       DEFINE_RES_IRQ_NAMED(156, "tgi0a"),
+       DEFINE_RES_IRQ_NAMED(164, "tgi1a"),
+       DEFINE_RES_IRQ_NAMED(180, "tgi2a"),
 };
 
-static struct resource mtu2_1_resources[] = {
-       [0] = {
-               .start  = 0xfffe4380,
-               .end    = 0xfffe4390,
-               .flags  = IORESOURCE_MEM,
-       },
-       [1] = {
-               .start  = 164,
-               .flags  = IORESOURCE_IRQ,
-       },
-};
-
-static struct platform_device mtu2_1_device = {
-       .name           = "sh_mtu2",
-       .id             = 1,
-       .dev = {
-               .platform_data  = &mtu2_1_platform_data,
-       },
-       .resource       = mtu2_1_resources,
-       .num_resources  = ARRAY_SIZE(mtu2_1_resources),
-};
-
-static struct sh_timer_config mtu2_2_platform_data = {
-       .channel_offset = 0x80,
-       .timer_bit = 2,
-       .clockevent_rating = 200,
-};
-
-static struct resource mtu2_2_resources[] = {
-       [0] = {
-               .start  = 0xfffe4000,
-               .end    = 0xfffe400a,
-               .flags  = IORESOURCE_MEM,
-       },
-       [1] = {
-               .start  = 180,
-               .flags  = IORESOURCE_IRQ,
-       },
-};
-
-static struct platform_device mtu2_2_device = {
-       .name           = "sh_mtu2",
-       .id             = 2,
-       .dev = {
-               .platform_data  = &mtu2_2_platform_data,
-       },
-       .resource       = mtu2_2_resources,
-       .num_resources  = ARRAY_SIZE(mtu2_2_resources),
+static struct platform_device mtu2_device = {
+       .name           = "sh-mtu2s",
+       .id             = -1,
+       .resource       = mtu2_resources,
+       .num_resources  = ARRAY_SIZE(mtu2_resources),
 };
 
 static struct platform_device *sh7206_devices[] __initdata = {
@@ -364,11 +256,8 @@ static struct platform_device *sh7206_devices[] __initdata = {
        &scif1_device,
        &scif2_device,
        &scif3_device,
-       &cmt0_device,
-       &cmt1_device,
-       &mtu2_0_device,
-       &mtu2_1_device,
-       &mtu2_2_device,
+       &cmt_device,
+       &mtu2_device,
 };
 
 static int __init sh7206_devices_setup(void)
@@ -388,11 +277,8 @@ static struct platform_device *sh7206_early_devices[] __initdata = {
        &scif1_device,
        &scif2_device,
        &scif3_device,
-       &cmt0_device,
-       &cmt1_device,
-       &mtu2_0_device,
-       &mtu2_1_device,
-       &mtu2_2_device,
+       &cmt_device,
+       &mtu2_device,
 };
 
 #define STBCR3 0xfffe0408
index ad5b0f4..6081464 100644 (file)
@@ -433,125 +433,37 @@ static struct platform_device scif7_device = {
        },
 };
 
-static struct sh_timer_config cmt0_platform_data = {
-       .channel_offset = 0x02,
-       .timer_bit = 0,
-       .clockevent_rating = 125,
-       .clocksource_rating = 0, /* disabled due to code generation issues */
+static struct sh_timer_config cmt_platform_data = {
+       .channels_mask = 3,
 };
 
-static struct resource cmt0_resources[] = {
-       [0] = {
-               .name   = "CMT0",
-               .start  = 0xfffec002,
-               .end    = 0xfffec007,
-               .flags  = IORESOURCE_MEM,
-       },
-       [1] = {
-               .start  = 175,
-               .flags  = IORESOURCE_IRQ,
-       },
-};
-
-static struct platform_device cmt0_device = {
-       .name           = "sh_cmt",
-       .id             = 0,
-       .dev = {
-               .platform_data  = &cmt0_platform_data,
-       },
-       .resource       = cmt0_resources,
-       .num_resources  = ARRAY_SIZE(cmt0_resources),
-};
-
-static struct sh_timer_config cmt1_platform_data = {
-       .name = "CMT1",
-       .channel_offset = 0x08,
-       .timer_bit = 1,
-       .clockevent_rating = 125,
-       .clocksource_rating = 0, /* disabled due to code generation issues */
-};
-
-static struct resource cmt1_resources[] = {
-       [0] = {
-               .name   = "CMT1",
-               .start  = 0xfffec008,
-               .end    = 0xfffec00d,
-               .flags  = IORESOURCE_MEM,
-       },
-       [1] = {
-               .start  = 176,
-               .flags  = IORESOURCE_IRQ,
-       },
-};
-
-static struct platform_device cmt1_device = {
-       .name           = "sh_cmt",
-       .id             = 1,
-       .dev = {
-               .platform_data  = &cmt1_platform_data,
-       },
-       .resource       = cmt1_resources,
-       .num_resources  = ARRAY_SIZE(cmt1_resources),
-};
-
-static struct sh_timer_config mtu2_0_platform_data = {
-       .name = "MTU2_0",
-       .channel_offset = -0x80,
-       .timer_bit = 0,
-       .clockevent_rating = 200,
-};
-
-static struct resource mtu2_0_resources[] = {
-       [0] = {
-               .name   = "MTU2_0",
-               .start  = 0xfffe4300,
-               .end    = 0xfffe4326,
-               .flags  = IORESOURCE_MEM,
-       },
-       [1] = {
-               .start  = 179,
-               .flags  = IORESOURCE_IRQ,
-       },
+static struct resource cmt_resources[] = {
+       DEFINE_RES_MEM(0xfffec000, 0x10),
+       DEFINE_RES_IRQ(175),
+       DEFINE_RES_IRQ(176),
 };
 
-static struct platform_device mtu2_0_device = {
-       .name           = "sh_mtu2",
+static struct platform_device cmt_device = {
+       .name           = "sh-cmt-16",
        .id             = 0,
        .dev = {
-               .platform_data  = &mtu2_0_platform_data,
+               .platform_data  = &cmt_platform_data,
        },
-       .resource       = mtu2_0_resources,
-       .num_resources  = ARRAY_SIZE(mtu2_0_resources),
+       .resource       = cmt_resources,
+       .num_resources  = ARRAY_SIZE(cmt_resources),
 };
 
-static struct sh_timer_config mtu2_1_platform_data = {
-       .name = "MTU2_1",
-       .channel_offset = -0x100,
-       .timer_bit = 1,
-       .clockevent_rating = 200,
+static struct resource mtu2_resources[] = {
+       DEFINE_RES_MEM(0xfffe4000, 0x400),
+       DEFINE_RES_IRQ_NAMED(179, "tgi0a"),
+       DEFINE_RES_IRQ_NAMED(186, "tgi1a"),
 };
 
-static struct resource mtu2_1_resources[] = {
-       [0] = {
-               .name   = "MTU2_1",
-               .start  = 0xfffe4380,
-               .end    = 0xfffe4390,
-               .flags  = IORESOURCE_MEM,
-       },
-       [1] = {
-               .start  = 186,
-               .flags  = IORESOURCE_IRQ,
-       },
-};
-
-static struct platform_device mtu2_1_device = {
-       .name           = "sh_mtu2",
-       .id             = 1,
-       .dev = {
-               .platform_data  = &mtu2_1_platform_data,
-       },
-       .resource       = mtu2_1_resources,
-       .num_resources  = ARRAY_SIZE(mtu2_1_resources),
+static struct platform_device mtu2_device = {
+       .name           = "sh-mtu2",
+       .id             = -1,
+       .resource       = mtu2_resources,
+       .num_resources  = ARRAY_SIZE(mtu2_resources),
 };
 
 static struct resource rtc_resources[] = {
@@ -620,10 +532,8 @@ static struct platform_device *sh7264_devices[] __initdata = {
        &scif5_device,
        &scif6_device,
        &scif7_device,
-       &cmt0_device,
-       &cmt1_device,
-       &mtu2_0_device,
-       &mtu2_1_device,
+       &cmt_device,
+       &mtu2_device,
        &rtc_device,
        &r8a66597_usb_host_device,
 };
@@ -649,10 +559,8 @@ static struct platform_device *sh7264_early_devices[] __initdata = {
        &scif5_device,
        &scif6_device,
        &scif7_device,
-       &cmt0_device,
-       &cmt1_device,
-       &mtu2_0_device,
-       &mtu2_1_device,
+       &cmt_device,
+       &mtu2_device,
 };
 
 void __init plat_early_device_setup(void)
index 3995119..16ce5aa 100644 (file)
@@ -455,118 +455,37 @@ static struct platform_device scif7_device = {
        },
 };
 
-static struct sh_timer_config cmt0_platform_data = {
-       .channel_offset = 0x02,
-       .timer_bit = 0,
-       .clockevent_rating = 125,
-       .clocksource_rating = 0, /* disabled due to code generation issues */
+static struct sh_timer_config cmt_platform_data = {
+       .channels_mask = 3,
 };
 
-static struct resource cmt0_resources[] = {
-       [0] = {
-               .start  = 0xfffec002,
-               .end    = 0xfffec007,
-               .flags  = IORESOURCE_MEM,
-       },
-       [1] = {
-               .start  = 188,
-               .flags  = IORESOURCE_IRQ,
-       },
-};
-
-static struct platform_device cmt0_device = {
-       .name           = "sh_cmt",
-       .id             = 0,
-       .dev = {
-               .platform_data  = &cmt0_platform_data,
-       },
-       .resource       = cmt0_resources,
-       .num_resources  = ARRAY_SIZE(cmt0_resources),
-};
-
-static struct sh_timer_config cmt1_platform_data = {
-       .channel_offset = 0x08,
-       .timer_bit = 1,
-       .clockevent_rating = 125,
-       .clocksource_rating = 0, /* disabled due to code generation issues */
-};
-
-static struct resource cmt1_resources[] = {
-       [0] = {
-               .start  = 0xfffec008,
-               .end    = 0xfffec00d,
-               .flags  = IORESOURCE_MEM,
-       },
-       [1] = {
-               .start  = 189,
-               .flags  = IORESOURCE_IRQ,
-       },
-};
-
-static struct platform_device cmt1_device = {
-       .name           = "sh_cmt",
-       .id             = 1,
-       .dev = {
-               .platform_data  = &cmt1_platform_data,
-       },
-       .resource       = cmt1_resources,
-       .num_resources  = ARRAY_SIZE(cmt1_resources),
-};
-
-static struct sh_timer_config mtu2_0_platform_data = {
-       .channel_offset = -0x80,
-       .timer_bit = 0,
-       .clockevent_rating = 200,
-};
-
-static struct resource mtu2_0_resources[] = {
-       [0] = {
-               .start  = 0xfffe4300,
-               .end    = 0xfffe4326,
-               .flags  = IORESOURCE_MEM,
-       },
-       [1] = {
-               .start  = 192,
-               .flags  = IORESOURCE_IRQ,
-       },
+static struct resource cmt_resources[] = {
+       DEFINE_RES_MEM(0xfffec000, 0x10),
+       DEFINE_RES_IRQ(188),
+       DEFINE_RES_IRQ(189),
 };
 
-static struct platform_device mtu2_0_device = {
-       .name           = "sh_mtu2",
+static struct platform_device cmt_device = {
+       .name           = "sh-cmt-16",
        .id             = 0,
        .dev = {
-               .platform_data  = &mtu2_0_platform_data,
+               .platform_data  = &cmt_platform_data,
        },
-       .resource       = mtu2_0_resources,
-       .num_resources  = ARRAY_SIZE(mtu2_0_resources),
+       .resource       = cmt_resources,
+       .num_resources  = ARRAY_SIZE(cmt_resources),
 };
 
-static struct sh_timer_config mtu2_1_platform_data = {
-       .channel_offset = -0x100,
-       .timer_bit = 1,
-       .clockevent_rating = 200,
+static struct resource mtu2_resources[] = {
+       DEFINE_RES_MEM(0xfffe4000, 0x400),
+       DEFINE_RES_IRQ_NAMED(192, "tgi0a"),
+       DEFINE_RES_IRQ_NAMED(203, "tgi1a"),
 };
 
-static struct resource mtu2_1_resources[] = {
-       [0] = {
-               .start  = 0xfffe4380,
-               .end    = 0xfffe4390,
-               .flags  = IORESOURCE_MEM,
-       },
-       [1] = {
-               .start  = 203,
-               .flags  = IORESOURCE_IRQ,
-       },
-};
-
-static struct platform_device mtu2_1_device = {
-       .name           = "sh_mtu2",
-       .id             = 1,
-       .dev = {
-               .platform_data  = &mtu2_1_platform_data,
-       },
-       .resource       = mtu2_1_resources,
-       .num_resources  = ARRAY_SIZE(mtu2_1_resources),
+static struct platform_device mtu2_device = {
+       .name           = "sh-mtu2",
+       .id             = -1,
+       .resource       = mtu2_resources,
+       .num_resources  = ARRAY_SIZE(mtu2_resources),
 };
 
 static struct resource rtc_resources[] = {
@@ -629,10 +548,8 @@ static struct platform_device *sh7269_devices[] __initdata = {
        &scif5_device,
        &scif6_device,
        &scif7_device,
-       &cmt0_device,
-       &cmt1_device,
-       &mtu2_0_device,
-       &mtu2_1_device,
+       &cmt_device,
+       &mtu2_device,
        &rtc_device,
        &r8a66597_usb_host_device,
 };
@@ -658,10 +575,8 @@ static struct platform_device *sh7269_early_devices[] __initdata = {
        &scif5_device,
        &scif6_device,
        &scif7_device,
-       &cmt0_device,
-       &cmt1_device,
-       &mtu2_0_device,
-       &mtu2_1_device,
+       &cmt_device,
+       &mtu2_device,
 };
 
 void __init plat_early_device_setup(void)
index c76b254..6a72fd1 100644 (file)
@@ -143,25 +143,18 @@ static struct platform_device rtc_device = {
 };
 
 static struct sh_timer_config tmu0_platform_data = {
-       .channel_offset = 0x02,
-       .timer_bit = 0,
-       .clockevent_rating = 200,
+       .channels_mask = 7,
 };
 
 static struct resource tmu0_resources[] = {
-       [0] = {
-               .start  = 0xfffffe94,
-               .end    = 0xfffffe9f,
-               .flags  = IORESOURCE_MEM,
-       },
-       [1] = {
-               .start  = evt2irq(0x400),
-               .flags  = IORESOURCE_IRQ,
-       },
+       DEFINE_RES_MEM(0xfffffe90, 0x2c),
+       DEFINE_RES_IRQ(evt2irq(0x400)),
+       DEFINE_RES_IRQ(evt2irq(0x420)),
+       DEFINE_RES_IRQ(evt2irq(0x440)),
 };
 
 static struct platform_device tmu0_device = {
-       .name           = "sh_tmu",
+       .name           = "sh-tmu-sh3",
        .id             = 0,
        .dev = {
                .platform_data  = &tmu0_platform_data,
@@ -170,67 +163,10 @@ static struct platform_device tmu0_device = {
        .num_resources  = ARRAY_SIZE(tmu0_resources),
 };
 
-static struct sh_timer_config tmu1_platform_data = {
-       .channel_offset = 0xe,
-       .timer_bit = 1,
-       .clocksource_rating = 200,
-};
-
-static struct resource tmu1_resources[] = {
-       [0] = {
-               .start  = 0xfffffea0,
-               .end    = 0xfffffeab,
-               .flags  = IORESOURCE_MEM,
-       },
-       [1] = {
-               .start  = evt2irq(0x420),
-               .flags  = IORESOURCE_IRQ,
-       },
-};
-
-static struct platform_device tmu1_device = {
-       .name           = "sh_tmu",
-       .id             = 1,
-       .dev = {
-               .platform_data  = &tmu1_platform_data,
-       },
-       .resource       = tmu1_resources,
-       .num_resources  = ARRAY_SIZE(tmu1_resources),
-};
-
-static struct sh_timer_config tmu2_platform_data = {
-       .channel_offset = 0x1a,
-       .timer_bit = 2,
-};
-
-static struct resource tmu2_resources[] = {
-       [0] = {
-               .start  = 0xfffffeac,
-               .end    = 0xfffffebb,
-               .flags  = IORESOURCE_MEM,
-       },
-       [1] = {
-               .start  = evt2irq(0x440),
-               .flags  = IORESOURCE_IRQ,
-       },
-};
-
-static struct platform_device tmu2_device = {
-       .name           = "sh_tmu",
-       .id             = 2,
-       .dev = {
-               .platform_data  = &tmu2_platform_data,
-       },
-       .resource       = tmu2_resources,
-       .num_resources  = ARRAY_SIZE(tmu2_resources),
-};
-
 static struct platform_device *sh7705_devices[] __initdata = {
        &scif0_device,
        &scif1_device,
        &tmu0_device,
-       &tmu1_device,
-       &tmu2_device,
        &rtc_device,
 };
 
@@ -245,8 +181,6 @@ static struct platform_device *sh7705_early_devices[] __initdata = {
        &scif0_device,
        &scif1_device,
        &tmu0_device,
-       &tmu1_device,
-       &tmu2_device,
 };
 
 void __init plat_early_device_setup(void)
index 5acf89c..538c10d 100644 (file)
@@ -185,25 +185,18 @@ static struct platform_device scif2_device = {
 #endif
 
 static struct sh_timer_config tmu0_platform_data = {
-       .channel_offset = 0x02,
-       .timer_bit = 0,
-       .clockevent_rating = 200,
+       .channels_mask = 7,
 };
 
 static struct resource tmu0_resources[] = {
-       [0] = {
-               .start  = 0xfffffe94,
-               .end    = 0xfffffe9f,
-               .flags  = IORESOURCE_MEM,
-       },
-       [1] = {
-               .start  = evt2irq(0x400),
-               .flags  = IORESOURCE_IRQ,
-       },
+       DEFINE_RES_MEM(0xfffffe90, 0x2c),
+       DEFINE_RES_IRQ(evt2irq(0x400)),
+       DEFINE_RES_IRQ(evt2irq(0x420)),
+       DEFINE_RES_IRQ(evt2irq(0x440)),
 };
 
 static struct platform_device tmu0_device = {
-       .name           = "sh_tmu",
+       .name           = "sh-tmu-sh3",
        .id             = 0,
        .dev = {
                .platform_data  = &tmu0_platform_data,
@@ -212,61 +205,6 @@ static struct platform_device tmu0_device = {
        .num_resources  = ARRAY_SIZE(tmu0_resources),
 };
 
-static struct sh_timer_config tmu1_platform_data = {
-       .channel_offset = 0xe,
-       .timer_bit = 1,
-       .clocksource_rating = 200,
-};
-
-static struct resource tmu1_resources[] = {
-       [0] = {
-               .start  = 0xfffffea0,
-               .end    = 0xfffffeab,
-               .flags  = IORESOURCE_MEM,
-       },
-       [1] = {
-               .start  = evt2irq(0x420),
-               .flags  = IORESOURCE_IRQ,
-       },
-};
-
-static struct platform_device tmu1_device = {
-       .name           = "sh_tmu",
-       .id             = 1,
-       .dev = {
-               .platform_data  = &tmu1_platform_data,
-       },
-       .resource       = tmu1_resources,
-       .num_resources  = ARRAY_SIZE(tmu1_resources),
-};
-
-static struct sh_timer_config tmu2_platform_data = {
-       .channel_offset = 0x1a,
-       .timer_bit = 2,
-};
-
-static struct resource tmu2_resources[] = {
-       [0] = {
-               .start  = 0xfffffeac,
-               .end    = 0xfffffebb,
-               .flags  = IORESOURCE_MEM,
-       },
-       [1] = {
-               .start  = evt2irq(0x440),
-               .flags  = IORESOURCE_IRQ,
-       },
-};
-
-static struct platform_device tmu2_device = {
-       .name           = "sh_tmu",
-       .id             = 2,
-       .dev = {
-               .platform_data  = &tmu2_platform_data,
-       },
-       .resource       = tmu2_resources,
-       .num_resources  = ARRAY_SIZE(tmu2_resources),
-};
-
 static struct platform_device *sh770x_devices[] __initdata = {
        &scif0_device,
 #if defined(CONFIG_CPU_SUBTYPE_SH7706) || \
@@ -279,8 +217,6 @@ static struct platform_device *sh770x_devices[] __initdata = {
        &scif2_device,
 #endif
        &tmu0_device,
-       &tmu1_device,
-       &tmu2_device,
        &rtc_device,
 };
 
@@ -303,8 +239,6 @@ static struct platform_device *sh770x_early_devices[] __initdata = {
        &scif2_device,
 #endif
        &tmu0_device,
-       &tmu1_device,
-       &tmu2_device,
 };
 
 void __init plat_early_device_setup(void)
index e2ce936..e9ed300 100644 (file)
@@ -142,25 +142,18 @@ static struct platform_device scif1_device = {
 };
 
 static struct sh_timer_config tmu0_platform_data = {
-       .channel_offset = 0x02,
-       .timer_bit = 0,
-       .clockevent_rating = 200,
+       .channels_mask = 7,
 };
 
 static struct resource tmu0_resources[] = {
-       [0] = {
-               .start  = 0xa412fe94,
-               .end    = 0xa412fe9f,
-               .flags  = IORESOURCE_MEM,
-       },
-       [1] = {
-               .start  = evt2irq(0x400),
-               .flags  = IORESOURCE_IRQ,
-       },
+       DEFINE_RES_MEM(0xa412fe90, 0x28),
+       DEFINE_RES_IRQ(evt2irq(0x400)),
+       DEFINE_RES_IRQ(evt2irq(0x420)),
+       DEFINE_RES_IRQ(evt2irq(0x440)),
 };
 
 static struct platform_device tmu0_device = {
-       .name           = "sh_tmu",
+       .name           = "sh-tmu-sh3",
        .id             = 0,
        .dev = {
                .platform_data  = &tmu0_platform_data,
@@ -169,67 +162,10 @@ static struct platform_device tmu0_device = {
        .num_resources  = ARRAY_SIZE(tmu0_resources),
 };
 
-static struct sh_timer_config tmu1_platform_data = {
-       .channel_offset = 0xe,
-       .timer_bit = 1,
-       .clocksource_rating = 200,
-};
-
-static struct resource tmu1_resources[] = {
-       [0] = {
-               .start  = 0xa412fea0,
-               .end    = 0xa412feab,
-               .flags  = IORESOURCE_MEM,
-       },
-       [1] = {
-               .start  = evt2irq(0x420),
-               .flags  = IORESOURCE_IRQ,
-       },
-};
-
-static struct platform_device tmu1_device = {
-       .name           = "sh_tmu",
-       .id             = 1,
-       .dev = {
-               .platform_data  = &tmu1_platform_data,
-       },
-       .resource       = tmu1_resources,
-       .num_resources  = ARRAY_SIZE(tmu1_resources),
-};
-
-static struct sh_timer_config tmu2_platform_data = {
-       .channel_offset = 0x1a,
-       .timer_bit = 2,
-};
-
-static struct resource tmu2_resources[] = {
-       [0] = {
-               .start  = 0xa412feac,
-               .end    = 0xa412feb5,
-               .flags  = IORESOURCE_MEM,
-       },
-       [1] = {
-               .start  = evt2irq(0x440),
-               .flags  = IORESOURCE_IRQ,
-       },
-};
-
-static struct platform_device tmu2_device = {
-       .name           = "sh_tmu",
-       .id             = 2,
-       .dev = {
-               .platform_data  = &tmu2_platform_data,
-       },
-       .resource       = tmu2_resources,
-       .num_resources  = ARRAY_SIZE(tmu2_resources),
-};
-
 static struct platform_device *sh7710_devices[] __initdata = {
        &scif0_device,
        &scif1_device,
        &tmu0_device,
-       &tmu1_device,
-       &tmu2_device,
        &rtc_device,
 };
 
@@ -244,8 +180,6 @@ static struct platform_device *sh7710_early_devices[] __initdata = {
        &scif0_device,
        &scif1_device,
        &tmu0_device,
-       &tmu1_device,
-       &tmu2_device,
 };
 
 void __init plat_early_device_setup(void)
index 1d5729d..84df85a 100644 (file)
@@ -152,163 +152,38 @@ static struct platform_device usbf_device = {
        .resource       = usbf_resources,
 };
 
-static struct sh_timer_config cmt0_platform_data = {
-       .channel_offset = 0x10,
-       .timer_bit = 0,
-       .clockevent_rating = 125,
-       .clocksource_rating = 125,
+static struct sh_timer_config cmt_platform_data = {
+       .channels_mask = 0x1f,
 };
 
-static struct resource cmt0_resources[] = {
-       [0] = {
-               .start  = 0x044a0010,
-               .end    = 0x044a001b,
-               .flags  = IORESOURCE_MEM,
-       },
-       [1] = {
-               .start  = evt2irq(0xf00),
-               .flags  = IORESOURCE_IRQ,
-       },
+static struct resource cmt_resources[] = {
+       DEFINE_RES_MEM(0x044a0000, 0x60),
+       DEFINE_RES_IRQ(evt2irq(0xf00)),
 };
 
-static struct platform_device cmt0_device = {
-       .name           = "sh_cmt",
+static struct platform_device cmt_device = {
+       .name           = "sh-cmt-32",
        .id             = 0,
        .dev = {
-               .platform_data  = &cmt0_platform_data,
-       },
-       .resource       = cmt0_resources,
-       .num_resources  = ARRAY_SIZE(cmt0_resources),
-};
-
-static struct sh_timer_config cmt1_platform_data = {
-       .channel_offset = 0x20,
-       .timer_bit = 1,
-};
-
-static struct resource cmt1_resources[] = {
-       [0] = {
-               .start  = 0x044a0020,
-               .end    = 0x044a002b,
-               .flags  = IORESOURCE_MEM,
-       },
-       [1] = {
-               .start  = evt2irq(0xf00),
-               .flags  = IORESOURCE_IRQ,
-       },
-};
-
-static struct platform_device cmt1_device = {
-       .name           = "sh_cmt",
-       .id             = 1,
-       .dev = {
-               .platform_data  = &cmt1_platform_data,
-       },
-       .resource       = cmt1_resources,
-       .num_resources  = ARRAY_SIZE(cmt1_resources),
-};
-
-static struct sh_timer_config cmt2_platform_data = {
-       .channel_offset = 0x30,
-       .timer_bit = 2,
-};
-
-static struct resource cmt2_resources[] = {
-       [0] = {
-               .start  = 0x044a0030,
-               .end    = 0x044a003b,
-               .flags  = IORESOURCE_MEM,
-       },
-       [1] = {
-               .start  = evt2irq(0xf00),
-               .flags  = IORESOURCE_IRQ,
-       },
-};
-
-static struct platform_device cmt2_device = {
-       .name           = "sh_cmt",
-       .id             = 2,
-       .dev = {
-               .platform_data  = &cmt2_platform_data,
-       },
-       .resource       = cmt2_resources,
-       .num_resources  = ARRAY_SIZE(cmt2_resources),
-};
-
-static struct sh_timer_config cmt3_platform_data = {
-       .channel_offset = 0x40,
-       .timer_bit = 3,
-};
-
-static struct resource cmt3_resources[] = {
-       [0] = {
-               .start  = 0x044a0040,
-               .end    = 0x044a004b,
-               .flags  = IORESOURCE_MEM,
-       },
-       [1] = {
-               .start  = evt2irq(0xf00),
-               .flags  = IORESOURCE_IRQ,
-       },
-};
-
-static struct platform_device cmt3_device = {
-       .name           = "sh_cmt",
-       .id             = 3,
-       .dev = {
-               .platform_data  = &cmt3_platform_data,
+               .platform_data  = &cmt_platform_data,
        },
-       .resource       = cmt3_resources,
-       .num_resources  = ARRAY_SIZE(cmt3_resources),
-};
-
-static struct sh_timer_config cmt4_platform_data = {
-       .channel_offset = 0x50,
-       .timer_bit = 4,
-};
-
-static struct resource cmt4_resources[] = {
-       [0] = {
-               .start  = 0x044a0050,
-               .end    = 0x044a005b,
-               .flags  = IORESOURCE_MEM,
-       },
-       [1] = {
-               .start  = evt2irq(0xf00),
-               .flags  = IORESOURCE_IRQ,
-       },
-};
-
-static struct platform_device cmt4_device = {
-       .name           = "sh_cmt",
-       .id             = 4,
-       .dev = {
-               .platform_data  = &cmt4_platform_data,
-       },
-       .resource       = cmt4_resources,
-       .num_resources  = ARRAY_SIZE(cmt4_resources),
+       .resource       = cmt_resources,
+       .num_resources  = ARRAY_SIZE(cmt_resources),
 };
 
 static struct sh_timer_config tmu0_platform_data = {
-       .channel_offset = 0x02,
-       .timer_bit = 0,
-       .clockevent_rating = 200,
+       .channels_mask = 7,
 };
 
 static struct resource tmu0_resources[] = {
-       [0] = {
-               .start  = 0xa412fe94,
-               .end    = 0xa412fe9f,
-               .flags  = IORESOURCE_MEM,
-       },
-       [1] = {
-               .start  = evt2irq(0x400),
-               .flags  = IORESOURCE_IRQ,
-       },
+       DEFINE_RES_MEM(0xa412fe90, 0x28),
+       DEFINE_RES_IRQ(evt2irq(0x400)),
+       DEFINE_RES_IRQ(evt2irq(0x420)),
+       DEFINE_RES_IRQ(evt2irq(0x440)),
 };
 
 static struct platform_device tmu0_device = {
-       .name           = "sh_tmu",
+       .name           = "sh-tmu-sh3",
        .id             = 0,
        .dev = {
                .platform_data  = &tmu0_platform_data,
@@ -317,72 +192,11 @@ static struct platform_device tmu0_device = {
        .num_resources  = ARRAY_SIZE(tmu0_resources),
 };
 
-static struct sh_timer_config tmu1_platform_data = {
-       .channel_offset = 0xe,
-       .timer_bit = 1,
-       .clocksource_rating = 200,
-};
-
-static struct resource tmu1_resources[] = {
-       [0] = {
-               .start  = 0xa412fea0,
-               .end    = 0xa412feab,
-               .flags  = IORESOURCE_MEM,
-       },
-       [1] = {
-               .start  = evt2irq(0x420),
-               .flags  = IORESOURCE_IRQ,
-       },
-};
-
-static struct platform_device tmu1_device = {
-       .name           = "sh_tmu",
-       .id             = 1,
-       .dev = {
-               .platform_data  = &tmu1_platform_data,
-       },
-       .resource       = tmu1_resources,
-       .num_resources  = ARRAY_SIZE(tmu1_resources),
-};
-
-static struct sh_timer_config tmu2_platform_data = {
-       .channel_offset = 0x1a,
-       .timer_bit = 2,
-};
-
-static struct resource tmu2_resources[] = {
-       [0] = {
-               .start  = 0xa412feac,
-               .end    = 0xa412feb5,
-               .flags  = IORESOURCE_MEM,
-       },
-       [1] = {
-               .start  = evt2irq(0x440),
-               .flags  = IORESOURCE_IRQ,
-       },
-};
-
-static struct platform_device tmu2_device = {
-       .name           = "sh_tmu",
-       .id             = 2,
-       .dev = {
-               .platform_data  = &tmu2_platform_data,
-       },
-       .resource       = tmu2_resources,
-       .num_resources  = ARRAY_SIZE(tmu2_resources),
-};
-
 static struct platform_device *sh7720_devices[] __initdata = {
        &scif0_device,
        &scif1_device,
-       &cmt0_device,
-       &cmt1_device,
-       &cmt2_device,
-       &cmt3_device,
-       &cmt4_device,
+       &cmt_device,
        &tmu0_device,
-       &tmu1_device,
-       &tmu2_device,
        &rtc_device,
        &usb_ohci_device,
        &usbf_device,
@@ -398,14 +212,8 @@ arch_initcall(sh7720_devices_setup);
 static struct platform_device *sh7720_early_devices[] __initdata = {
        &scif0_device,
        &scif1_device,
-       &cmt0_device,
-       &cmt1_device,
-       &cmt2_device,
-       &cmt3_device,
-       &cmt4_device,
+       &cmt_device,
        &tmu0_device,
-       &tmu1_device,
-       &tmu2_device,
 };
 
 void __init plat_early_device_setup(void)
index a8bd778..e7a7b3c 100644 (file)
@@ -41,25 +41,18 @@ static struct platform_device scif0_device = {
 };
 
 static struct sh_timer_config tmu0_platform_data = {
-       .channel_offset = 0x04,
-       .timer_bit = 0,
-       .clockevent_rating = 200,
+       .channels_mask = 7,
 };
 
 static struct resource tmu0_resources[] = {
-       [0] = {
-               .start  = 0xffd80008,
-               .end    = 0xffd80013,
-               .flags  = IORESOURCE_MEM,
-       },
-       [1] = {
-               .start  = evt2irq(0x400),
-               .flags  = IORESOURCE_IRQ,
-       },
+       DEFINE_RES_MEM(0xffd80000, 0x30),
+       DEFINE_RES_IRQ(evt2irq(0x400)),
+       DEFINE_RES_IRQ(evt2irq(0x420)),
+       DEFINE_RES_IRQ(evt2irq(0x440)),
 };
 
 static struct platform_device tmu0_device = {
-       .name           = "sh_tmu",
+       .name           = "sh-tmu",
        .id             = 0,
        .dev = {
                .platform_data  = &tmu0_platform_data,
@@ -68,66 +61,9 @@ static struct platform_device tmu0_device = {
        .num_resources  = ARRAY_SIZE(tmu0_resources),
 };
 
-static struct sh_timer_config tmu1_platform_data = {
-       .channel_offset = 0x10,
-       .timer_bit = 1,
-       .clocksource_rating = 200,
-};
-
-static struct resource tmu1_resources[] = {
-       [0] = {
-               .start  = 0xffd80014,
-               .end    = 0xffd8001f,
-               .flags  = IORESOURCE_MEM,
-       },
-       [1] = {
-               .start  = evt2irq(0x420),
-               .flags  = IORESOURCE_IRQ,
-       },
-};
-
-static struct platform_device tmu1_device = {
-       .name           = "sh_tmu",
-       .id             = 1,
-       .dev = {
-               .platform_data  = &tmu1_platform_data,
-       },
-       .resource       = tmu1_resources,
-       .num_resources  = ARRAY_SIZE(tmu1_resources),
-};
-
-static struct sh_timer_config tmu2_platform_data = {
-       .channel_offset = 0x1c,
-       .timer_bit = 2,
-};
-
-static struct resource tmu2_resources[] = {
-       [0] = {
-               .start  = 0xffd80020,
-               .end    = 0xffd8002f,
-               .flags  = IORESOURCE_MEM,
-       },
-       [1] = {
-               .start  = evt2irq(0x440),
-               .flags  = IORESOURCE_IRQ,
-       },
-};
-
-static struct platform_device tmu2_device = {
-       .name           = "sh_tmu",
-       .id             = 2,
-       .dev = {
-               .platform_data  = &tmu2_platform_data,
-       },
-       .resource       = tmu2_resources,
-       .num_resources  = ARRAY_SIZE(tmu2_resources),
-};
-
 static struct platform_device *sh4202_devices[] __initdata = {
        &scif0_device,
        &tmu0_device,
-       &tmu1_device,
-       &tmu2_device,
 };
 
 static int __init sh4202_devices_setup(void)
@@ -140,8 +76,6 @@ arch_initcall(sh4202_devices_setup);
 static struct platform_device *sh4202_early_devices[] __initdata = {
        &scif0_device,
        &tmu0_device,
-       &tmu1_device,
-       &tmu2_device,
 };
 
 void __init plat_early_device_setup(void)
index a447a24..5f08c59 100644 (file)
@@ -82,25 +82,18 @@ static struct platform_device scif_device = {
 };
 
 static struct sh_timer_config tmu0_platform_data = {
-       .channel_offset = 0x04,
-       .timer_bit = 0,
-       .clockevent_rating = 200,
+       .channels_mask = 7,
 };
 
 static struct resource tmu0_resources[] = {
-       [0] = {
-               .start  = 0xffd80008,
-               .end    = 0xffd80013,
-               .flags  = IORESOURCE_MEM,
-       },
-       [1] = {
-               .start  = evt2irq(0x400),
-               .flags  = IORESOURCE_IRQ,
-       },
+       DEFINE_RES_MEM(0xffd80000, 0x30),
+       DEFINE_RES_IRQ(evt2irq(0x400)),
+       DEFINE_RES_IRQ(evt2irq(0x420)),
+       DEFINE_RES_IRQ(evt2irq(0x440)),
 };
 
 static struct platform_device tmu0_device = {
-       .name           = "sh_tmu",
+       .name           = "sh-tmu",
        .id             = 0,
        .dev = {
                .platform_data  = &tmu0_platform_data,
@@ -109,26 +102,23 @@ static struct platform_device tmu0_device = {
        .num_resources  = ARRAY_SIZE(tmu0_resources),
 };
 
+/* SH7750R, SH7751 and SH7751R all have two extra timer channels */
+#if defined(CONFIG_CPU_SUBTYPE_SH7750R) || \
+       defined(CONFIG_CPU_SUBTYPE_SH7751) || \
+       defined(CONFIG_CPU_SUBTYPE_SH7751R)
+
 static struct sh_timer_config tmu1_platform_data = {
-       .channel_offset = 0x10,
-       .timer_bit = 1,
-       .clocksource_rating = 200,
+       .channels_mask = 3,
 };
 
 static struct resource tmu1_resources[] = {
-       [0] = {
-               .start  = 0xffd80014,
-               .end    = 0xffd8001f,
-               .flags  = IORESOURCE_MEM,
-       },
-       [1] = {
-               .start  = evt2irq(0x420),
-               .flags  = IORESOURCE_IRQ,
-       },
+       DEFINE_RES_MEM(0xfe100000, 0x20),
+       DEFINE_RES_IRQ(evt2irq(0xb00)),
+       DEFINE_RES_IRQ(evt2irq(0xb80)),
 };
 
 static struct platform_device tmu1_device = {
-       .name           = "sh_tmu",
+       .name           = "sh-tmu",
        .id             = 1,
        .dev = {
                .platform_data  = &tmu1_platform_data,
@@ -137,104 +127,15 @@ static struct platform_device tmu1_device = {
        .num_resources  = ARRAY_SIZE(tmu1_resources),
 };
 
-static struct sh_timer_config tmu2_platform_data = {
-       .channel_offset = 0x1c,
-       .timer_bit = 2,
-};
-
-static struct resource tmu2_resources[] = {
-       [0] = {
-               .start  = 0xffd80020,
-               .end    = 0xffd8002f,
-               .flags  = IORESOURCE_MEM,
-       },
-       [1] = {
-               .start  = evt2irq(0x440),
-               .flags  = IORESOURCE_IRQ,
-       },
-};
-
-static struct platform_device tmu2_device = {
-       .name           = "sh_tmu",
-       .id             = 2,
-       .dev = {
-               .platform_data  = &tmu2_platform_data,
-       },
-       .resource       = tmu2_resources,
-       .num_resources  = ARRAY_SIZE(tmu2_resources),
-};
-
-/* SH7750R, SH7751 and SH7751R all have two extra timer channels */
-#if defined(CONFIG_CPU_SUBTYPE_SH7750R) || \
-       defined(CONFIG_CPU_SUBTYPE_SH7751) || \
-       defined(CONFIG_CPU_SUBTYPE_SH7751R)
-
-static struct sh_timer_config tmu3_platform_data = {
-       .channel_offset = 0x04,
-       .timer_bit = 0,
-};
-
-static struct resource tmu3_resources[] = {
-       [0] = {
-               .start  = 0xfe100008,
-               .end    = 0xfe100013,
-               .flags  = IORESOURCE_MEM,
-       },
-       [1] = {
-               .start  = evt2irq(0xb00),
-               .flags  = IORESOURCE_IRQ,
-       },
-};
-
-static struct platform_device tmu3_device = {
-       .name           = "sh_tmu",
-       .id             = 3,
-       .dev = {
-               .platform_data  = &tmu3_platform_data,
-       },
-       .resource       = tmu3_resources,
-       .num_resources  = ARRAY_SIZE(tmu3_resources),
-};
-
-static struct sh_timer_config tmu4_platform_data = {
-       .channel_offset = 0x10,
-       .timer_bit = 1,
-};
-
-static struct resource tmu4_resources[] = {
-       [0] = {
-               .start  = 0xfe100014,
-               .end    = 0xfe10001f,
-               .flags  = IORESOURCE_MEM,
-       },
-       [1] = {
-               .start  = evt2irq(0xb80),
-               .flags  = IORESOURCE_IRQ,
-       },
-};
-
-static struct platform_device tmu4_device = {
-       .name           = "sh_tmu",
-       .id             = 4,
-       .dev = {
-               .platform_data  = &tmu4_platform_data,
-       },
-       .resource       = tmu4_resources,
-       .num_resources  = ARRAY_SIZE(tmu4_resources),
-};
-
 #endif
 
 static struct platform_device *sh7750_devices[] __initdata = {
        &rtc_device,
        &tmu0_device,
-       &tmu1_device,
-       &tmu2_device,
 #if defined(CONFIG_CPU_SUBTYPE_SH7750R) || \
        defined(CONFIG_CPU_SUBTYPE_SH7751) || \
        defined(CONFIG_CPU_SUBTYPE_SH7751R)
-       &tmu3_device,
-       &tmu4_device,
+       &tmu1_device,
 #endif
 };
 
@@ -254,13 +155,10 @@ arch_initcall(sh7750_devices_setup);
 
 static struct platform_device *sh7750_early_devices[] __initdata = {
        &tmu0_device,
-       &tmu1_device,
-       &tmu2_device,
 #if defined(CONFIG_CPU_SUBTYPE_SH7750R) || \
        defined(CONFIG_CPU_SUBTYPE_SH7751) || \
        defined(CONFIG_CPU_SUBTYPE_SH7751R)
-       &tmu3_device,
-       &tmu4_device,
+       &tmu1_device,
 #endif
 };
 
index 1abd9fb..973b736 100644 (file)
@@ -227,25 +227,18 @@ static struct platform_device scif3_device = {
 };
 
 static struct sh_timer_config tmu0_platform_data = {
-       .channel_offset = 0x04,
-       .timer_bit = 0,
-       .clockevent_rating = 200,
+       .channels_mask = 7,
 };
 
 static struct resource tmu0_resources[] = {
-       [0] = {
-               .start  = 0xffd80008,
-               .end    = 0xffd80013,
-               .flags  = IORESOURCE_MEM,
-       },
-       [1] = {
-               .start  = evt2irq(0x400),
-               .flags  = IORESOURCE_IRQ,
-       },
+       DEFINE_RES_MEM(0xffd80000, 0x30),
+       DEFINE_RES_IRQ(evt2irq(0x400)),
+       DEFINE_RES_IRQ(evt2irq(0x420)),
+       DEFINE_RES_IRQ(evt2irq(0x440)),
 };
 
 static struct platform_device tmu0_device = {
-       .name           = "sh_tmu",
+       .name           = "sh-tmu",
        .id             = 0,
        .dev = {
                .platform_data  = &tmu0_platform_data,
@@ -254,61 +247,6 @@ static struct platform_device tmu0_device = {
        .num_resources  = ARRAY_SIZE(tmu0_resources),
 };
 
-static struct sh_timer_config tmu1_platform_data = {
-       .channel_offset = 0x10,
-       .timer_bit = 1,
-       .clocksource_rating = 200,
-};
-
-static struct resource tmu1_resources[] = {
-       [0] = {
-               .start  = 0xffd80014,
-               .end    = 0xffd8001f,
-               .flags  = IORESOURCE_MEM,
-       },
-       [1] = {
-               .start  = evt2irq(0x420),
-               .flags  = IORESOURCE_IRQ,
-       },
-};
-
-static struct platform_device tmu1_device = {
-       .name           = "sh_tmu",
-       .id             = 1,
-       .dev = {
-               .platform_data  = &tmu1_platform_data,
-       },
-       .resource       = tmu1_resources,
-       .num_resources  = ARRAY_SIZE(tmu1_resources),
-};
-
-static struct sh_timer_config tmu2_platform_data = {
-       .channel_offset = 0x1c,
-       .timer_bit = 2,
-};
-
-static struct resource tmu2_resources[] = {
-       [0] = {
-               .start  = 0xffd80020,
-               .end    = 0xffd8002f,
-               .flags  = IORESOURCE_MEM,
-       },
-       [1] = {
-               .start  = evt2irq(0x440),
-               .flags  = IORESOURCE_IRQ,
-       },
-};
-
-static struct platform_device tmu2_device = {
-       .name           = "sh_tmu",
-       .id             = 2,
-       .dev = {
-               .platform_data  = &tmu2_platform_data,
-       },
-       .resource       = tmu2_resources,
-       .num_resources  = ARRAY_SIZE(tmu2_resources),
-};
-
 
 static struct platform_device *sh7760_devices[] __initdata = {
        &scif0_device,
@@ -316,8 +254,6 @@ static struct platform_device *sh7760_devices[] __initdata = {
        &scif2_device,
        &scif3_device,
        &tmu0_device,
-       &tmu1_device,
-       &tmu2_device,
 };
 
 static int __init sh7760_devices_setup(void)
@@ -333,8 +269,6 @@ static struct platform_device *sh7760_early_devices[] __initdata = {
        &scif2_device,
        &scif3_device,
        &tmu0_device,
-       &tmu1_device,
-       &tmu2_device,
 };
 
 void __init plat_early_device_setup(void)
index 53638e2..9edc06c 100644 (file)
@@ -227,7 +227,7 @@ static struct clk_lookup lookups[] = {
        CLKDEV_CON_ID("hudi0", &mstp_clks[MSTP019]),
        CLKDEV_CON_ID("ubc0", &mstp_clks[MSTP017]),
        CLKDEV_CON_ID("tmu_fck", &mstp_clks[MSTP015]),
-       CLKDEV_CON_ID("cmt_fck", &mstp_clks[MSTP014]),
+       CLKDEV_ICK_ID("fck", "sh-cmt-32.0", &mstp_clks[MSTP014]),
        CLKDEV_CON_ID("rwdt0", &mstp_clks[MSTP013]),
        CLKDEV_CON_ID("mfi0", &mstp_clks[MSTP011]),
        CLKDEV_CON_ID("flctl0", &mstp_clks[MSTP010]),
index 22e485d..955b9ad 100644 (file)
@@ -225,7 +225,7 @@ static struct clk_lookup lookups[] = {
        CLKDEV_CON_ID("hudi0", &mstp_clks[MSTP019]),
        CLKDEV_CON_ID("ubc0", &mstp_clks[MSTP017]),
        CLKDEV_CON_ID("tmu_fck", &mstp_clks[MSTP015]),
-       CLKDEV_CON_ID("cmt_fck", &mstp_clks[MSTP014]),
+       CLKDEV_ICK_ID("fck", "sh-cmt-32.0", &mstp_clks[MSTP014]),
        CLKDEV_CON_ID("rwdt0", &mstp_clks[MSTP013]),
        CLKDEV_CON_ID("mfi0", &mstp_clks[MSTP011]),
        CLKDEV_CON_ID("flctl0", &mstp_clks[MSTP010]),
index c4cb740..8f07a1a 100644 (file)
@@ -203,11 +203,9 @@ static struct clk_lookup lookups[] = {
        CLKDEV_CON_ID("uram0", &mstp_clks[HWBLK_URAM]),
        CLKDEV_CON_ID("xymem0", &mstp_clks[HWBLK_XYMEM]),
 
-       CLKDEV_ICK_ID("tmu_fck", "sh_tmu.0", &mstp_clks[HWBLK_TMU]),
-       CLKDEV_ICK_ID("tmu_fck", "sh_tmu.1", &mstp_clks[HWBLK_TMU]),
-       CLKDEV_ICK_ID("tmu_fck", "sh_tmu.2", &mstp_clks[HWBLK_TMU]),
+       CLKDEV_ICK_ID("fck", "sh-tmu.0", &mstp_clks[HWBLK_TMU]),
 
-       CLKDEV_CON_ID("cmt_fck", &mstp_clks[HWBLK_CMT]),
+       CLKDEV_ICK_ID("fck", "sh-cmt-32.0", &mstp_clks[HWBLK_CMT]),
        CLKDEV_DEV_ID("sh-wdt.0", &mstp_clks[HWBLK_RWDT]),
        CLKDEV_CON_ID("flctl0", &mstp_clks[HWBLK_FLCTL]),
 
index 37c41c7..ccbcab5 100644 (file)
@@ -236,7 +236,7 @@ static struct clk_lookup lookups[] = {
        CLKDEV_CON_ID("sh0", &mstp_clks[HWBLK_SHYWAY]),
        CLKDEV_CON_ID("hudi0", &mstp_clks[HWBLK_HUDI]),
        CLKDEV_CON_ID("ubc0", &mstp_clks[HWBLK_UBC]),
-       CLKDEV_CON_ID("cmt_fck", &mstp_clks[HWBLK_CMT]),
+       CLKDEV_ICK_ID("fck", "sh-cmt-32.0", &mstp_clks[HWBLK_CMT]),
        CLKDEV_DEV_ID("sh-wdt.0", &mstp_clks[HWBLK_RWDT]),
        CLKDEV_DEV_ID("sh-dma-engine.1", &mstp_clks[HWBLK_DMAC1]),
        CLKDEV_CON_ID("flctl0", &mstp_clks[HWBLK_FLCTL]),
@@ -264,12 +264,8 @@ static struct clk_lookup lookups[] = {
        CLKDEV_CON_ID("veu0", &mstp_clks[HWBLK_VEU2H0]),
        CLKDEV_CON_ID("vpu0", &mstp_clks[HWBLK_VPU]),
 
-       CLKDEV_ICK_ID("tmu_fck", "sh_tmu.0", &mstp_clks[HWBLK_TMU0]),
-       CLKDEV_ICK_ID("tmu_fck", "sh_tmu.1", &mstp_clks[HWBLK_TMU0]),
-       CLKDEV_ICK_ID("tmu_fck", "sh_tmu.2", &mstp_clks[HWBLK_TMU0]),
-       CLKDEV_ICK_ID("tmu_fck", "sh_tmu.3", &mstp_clks[HWBLK_TMU1]),
-       CLKDEV_ICK_ID("tmu_fck", "sh_tmu.4", &mstp_clks[HWBLK_TMU1]),
-       CLKDEV_ICK_ID("tmu_fck", "sh_tmu.5", &mstp_clks[HWBLK_TMU1]),
+       CLKDEV_ICK_ID("fck", "sh-tmu.0", &mstp_clks[HWBLK_TMU0]),
+       CLKDEV_ICK_ID("fck", "sh-tmu.1", &mstp_clks[HWBLK_TMU1]),
 
        CLKDEV_ICK_ID("sci_fck", "sh-sci.0", &mstp_clks[HWBLK_SCIF0]),
        CLKDEV_ICK_ID("sci_fck", "sh-sci.1", &mstp_clks[HWBLK_SCIF1]),
index 0128af3..f579dd5 100644 (file)
@@ -304,17 +304,13 @@ static struct clk_lookup lookups[] = {
        CLKDEV_CON_ID("hudi0", &mstp_clks[HWBLK_HUDI]),
        CLKDEV_CON_ID("ubc0", &mstp_clks[HWBLK_UBC]),
 
-       CLKDEV_ICK_ID("tmu_fck", "sh_tmu.0", &mstp_clks[HWBLK_TMU0]),
-       CLKDEV_ICK_ID("tmu_fck", "sh_tmu.1", &mstp_clks[HWBLK_TMU0]),
-       CLKDEV_ICK_ID("tmu_fck", "sh_tmu.2", &mstp_clks[HWBLK_TMU0]),
-       CLKDEV_ICK_ID("tmu_fck", "sh_tmu.3", &mstp_clks[HWBLK_TMU1]),
+       CLKDEV_ICK_ID("fck", "sh-tmu.0", &mstp_clks[HWBLK_TMU0]),
+       CLKDEV_ICK_ID("fck", "sh-tmu.1", &mstp_clks[HWBLK_TMU1]),
 
-       CLKDEV_CON_ID("cmt_fck", &mstp_clks[HWBLK_CMT]),
+       CLKDEV_ICK_ID("fck", "sh-cmt-16.0", &mstp_clks[HWBLK_CMT]),
        CLKDEV_DEV_ID("sh-wdt.0", &mstp_clks[HWBLK_RWDT]),
        CLKDEV_DEV_ID("sh-dma-engine.1", &mstp_clks[HWBLK_DMAC1]),
 
-       CLKDEV_ICK_ID("tmu_fck", "sh_tmu.4", &mstp_clks[HWBLK_TMU1]),
-       CLKDEV_ICK_ID("tmu_fck", "sh_tmu.5", &mstp_clks[HWBLK_TMU1]),
        CLKDEV_DEV_ID("sh-sci.0", &mstp_clks[HWBLK_SCIF0]),
        CLKDEV_DEV_ID("sh-sci.1", &mstp_clks[HWBLK_SCIF1]),
        CLKDEV_DEV_ID("sh-sci.2", &mstp_clks[HWBLK_SCIF2]),
index ed95015..1fdf1ee 100644 (file)
@@ -201,15 +201,9 @@ static struct clk_lookup lookups[] = {
        CLKDEV_ICK_ID("sci_fck", "sh-sci.4", &mstp_clks[MSTP022]),
        CLKDEV_ICK_ID("sci_fck", "sh-sci.5", &mstp_clks[MSTP021]),
        CLKDEV_CON_ID("hscif", &mstp_clks[MSTP019]),
-       CLKDEV_ICK_ID("tmu_fck", "sh_tmu.0", &mstp_clks[MSTP016]),
-       CLKDEV_ICK_ID("tmu_fck", "sh_tmu.1", &mstp_clks[MSTP016]),
-       CLKDEV_ICK_ID("tmu_fck", "sh_tmu.2", &mstp_clks[MSTP016]),
-       CLKDEV_ICK_ID("tmu_fck", "sh_tmu.3", &mstp_clks[MSTP015]),
-       CLKDEV_ICK_ID("tmu_fck", "sh_tmu.4", &mstp_clks[MSTP015]),
-       CLKDEV_ICK_ID("tmu_fck", "sh_tmu.5", &mstp_clks[MSTP015]),
-       CLKDEV_ICK_ID("tmu_fck", "sh_tmu.6", &mstp_clks[MSTP014]),
-       CLKDEV_ICK_ID("tmu_fck", "sh_tmu.7", &mstp_clks[MSTP014]),
-       CLKDEV_ICK_ID("tmu_fck", "sh_tmu.8", &mstp_clks[MSTP014]),
+       CLKDEV_ICK_ID("fck", "sh-tmu.0", &mstp_clks[MSTP016]),
+       CLKDEV_ICK_ID("fck", "sh-tmu.1", &mstp_clks[MSTP015]),
+       CLKDEV_ICK_ID("fck", "sh-tmu.2", &mstp_clks[MSTP014]),
        CLKDEV_CON_ID("ssi0", &mstp_clks[MSTP012]),
        CLKDEV_CON_ID("ssi1", &mstp_clks[MSTP011]),
        CLKDEV_CON_ID("ssi2", &mstp_clks[MSTP010]),
index e84a432..10939f9 100644 (file)
@@ -123,8 +123,8 @@ static struct clk_lookup lookups[] = {
        CLKDEV_CON_ID("riic6", &mstp_clks[MSTP000]),
        CLKDEV_CON_ID("riic7", &mstp_clks[MSTP000]),
 
-       CLKDEV_ICK_ID("tmu_fck", "sh_tmu.0", &mstp_clks[MSTP113]),
-       CLKDEV_ICK_ID("tmu_fck", "sh_tmu.1", &mstp_clks[MSTP114]),
+       CLKDEV_ICK_ID("fck", "sh-tmu.0", &mstp_clks[MSTP113]),
+       CLKDEV_ICK_ID("fck", "sh-tmu.1", &mstp_clks[MSTP114]),
        CLKDEV_ICK_ID("sci_fck", "sh-sci.2", &mstp_clks[MSTP112]),
        CLKDEV_ICK_ID("sci_fck", "sh-sci.1", &mstp_clks[MSTP111]),
        CLKDEV_ICK_ID("sci_fck", "sh-sci.0", &mstp_clks[MSTP110]),
index 1c83788..17d0ea5 100644 (file)
@@ -146,12 +146,8 @@ static struct clk_lookup lookups[] = {
        CLKDEV_CON_ID("mmcif_fck", &mstp_clks[MSTP013]),
        CLKDEV_CON_ID("flctl_fck", &mstp_clks[MSTP012]),
 
-       CLKDEV_ICK_ID("tmu_fck", "sh_tmu.0", &mstp_clks[MSTP008]),
-       CLKDEV_ICK_ID("tmu_fck", "sh_tmu.1", &mstp_clks[MSTP008]),
-       CLKDEV_ICK_ID("tmu_fck", "sh_tmu.2", &mstp_clks[MSTP008]),
-       CLKDEV_ICK_ID("tmu_fck", "sh_tmu.3", &mstp_clks[MSTP009]),
-       CLKDEV_ICK_ID("tmu_fck", "sh_tmu.4", &mstp_clks[MSTP009]),
-       CLKDEV_ICK_ID("tmu_fck", "sh_tmu.5", &mstp_clks[MSTP009]),
+       CLKDEV_ICK_ID("fck", "sh-tmu.0", &mstp_clks[MSTP008]),
+       CLKDEV_ICK_ID("fck", "sh-tmu.1", &mstp_clks[MSTP009]),
 
        CLKDEV_CON_ID("siof_fck", &mstp_clks[MSTP003]),
        CLKDEV_CON_ID("hspi_fck", &mstp_clks[MSTP002]),
index 8bba6f1..bec2a83 100644 (file)
@@ -155,18 +155,10 @@ static struct clk_lookup lookups[] = {
        CLKDEV_CON_ID("i2c1_fck", &mstp_clks[MSTP015]),
        CLKDEV_CON_ID("i2c0_fck", &mstp_clks[MSTP014]),
 
-       CLKDEV_ICK_ID("tmu_fck", "sh_tmu.0", &mstp_clks[MSTP008]),
-       CLKDEV_ICK_ID("tmu_fck", "sh_tmu.1", &mstp_clks[MSTP008]),
-       CLKDEV_ICK_ID("tmu_fck", "sh_tmu.2", &mstp_clks[MSTP008]),
-       CLKDEV_ICK_ID("tmu_fck", "sh_tmu.3", &mstp_clks[MSTP009]),
-       CLKDEV_ICK_ID("tmu_fck", "sh_tmu.4", &mstp_clks[MSTP009]),
-       CLKDEV_ICK_ID("tmu_fck", "sh_tmu.5", &mstp_clks[MSTP009]),
-       CLKDEV_ICK_ID("tmu_fck", "sh_tmu.6", &mstp_clks[MSTP010]),
-       CLKDEV_ICK_ID("tmu_fck", "sh_tmu.7", &mstp_clks[MSTP010]),
-       CLKDEV_ICK_ID("tmu_fck", "sh_tmu.8", &mstp_clks[MSTP010]),
-       CLKDEV_ICK_ID("tmu_fck", "sh_tmu.9", &mstp_clks[MSTP011]),
-       CLKDEV_ICK_ID("tmu_fck", "sh_tmu.10", &mstp_clks[MSTP011]),
-       CLKDEV_ICK_ID("tmu_fck", "sh_tmu.11", &mstp_clks[MSTP011]),
+       CLKDEV_ICK_ID("fck", "sh-tmu.0", &mstp_clks[MSTP008]),
+       CLKDEV_ICK_ID("fck", "sh-tmu.1", &mstp_clks[MSTP009]),
+       CLKDEV_ICK_ID("fck", "sh-tmu.2", &mstp_clks[MSTP010]),
+       CLKDEV_ICK_ID("fck", "sh-tmu.3", &mstp_clks[MSTP011]),
 
        CLKDEV_CON_ID("sdif1_fck", &mstp_clks[MSTP005]),
        CLKDEV_CON_ID("sdif0_fck", &mstp_clks[MSTP004]),
index a9422da..9a49a44 100644 (file)
@@ -124,12 +124,8 @@ static struct clk_lookup lookups[] = {
        CLKDEV_CON_ID("fe1_fck", &mstp_clks[MSTP001]),
        CLKDEV_CON_ID("fe0_fck", &mstp_clks[MSTP000]),
 
-       CLKDEV_ICK_ID("tmu_fck", "sh_tmu.0", &mstp_clks[MSTP008]),
-       CLKDEV_ICK_ID("tmu_fck", "sh_tmu.1", &mstp_clks[MSTP008]),
-       CLKDEV_ICK_ID("tmu_fck", "sh_tmu.2", &mstp_clks[MSTP008]),
-       CLKDEV_ICK_ID("tmu_fck", "sh_tmu.3", &mstp_clks[MSTP009]),
-       CLKDEV_ICK_ID("tmu_fck", "sh_tmu.4", &mstp_clks[MSTP009]),
-       CLKDEV_ICK_ID("tmu_fck", "sh_tmu.5", &mstp_clks[MSTP009]),
+       CLKDEV_ICK_ID("fck", "sh-tmu.0", &mstp_clks[MSTP008]),
+       CLKDEV_ICK_ID("fck", "sh-tmu.1", &mstp_clks[MSTP009]),
 
        CLKDEV_CON_ID("hudi_fck", &mstp_clks[MSTP119]),
        CLKDEV_CON_ID("dmac_11_6_fck", &mstp_clks[MSTP105]),
index 245d192..ceb3ded 100644 (file)
@@ -228,26 +228,16 @@ static struct platform_device jpu_device = {
 };
 
 static struct sh_timer_config cmt_platform_data = {
-       .channel_offset = 0x60,
-       .timer_bit = 5,
-       .clockevent_rating = 125,
-       .clocksource_rating = 200,
+       .channels_mask = 0x20,
 };
 
 static struct resource cmt_resources[] = {
-       [0] = {
-               .start  = 0x044a0060,
-               .end    = 0x044a006b,
-               .flags  = IORESOURCE_MEM,
-       },
-       [1] = {
-               .start  = evt2irq(0xf00),
-               .flags  = IORESOURCE_IRQ,
-       },
+       DEFINE_RES_MEM(0x044a0000, 0x70),
+       DEFINE_RES_IRQ(evt2irq(0xf00)),
 };
 
 static struct platform_device cmt_device = {
-       .name           = "sh_cmt",
+       .name           = "sh-cmt-32",
        .id             = 0,
        .dev = {
                .platform_data  = &cmt_platform_data,
@@ -257,25 +247,18 @@ static struct platform_device cmt_device = {
 };
 
 static struct sh_timer_config tmu0_platform_data = {
-       .channel_offset = 0x04,
-       .timer_bit = 0,
-       .clockevent_rating = 200,
+       .channels_mask = 7,
 };
 
 static struct resource tmu0_resources[] = {
-       [0] = {
-               .start  = 0xffd80008,
-               .end    = 0xffd80013,
-               .flags  = IORESOURCE_MEM,
-       },
-       [1] = {
-               .start  = evt2irq(0x400),
-               .flags  = IORESOURCE_IRQ,
-       },
+       DEFINE_RES_MEM(0xffd80000, 0x2c),
+       DEFINE_RES_IRQ(evt2irq(0x400)),
+       DEFINE_RES_IRQ(evt2irq(0x420)),
+       DEFINE_RES_IRQ(evt2irq(0x440)),
 };
 
 static struct platform_device tmu0_device = {
-       .name           = "sh_tmu",
+       .name           = "sh-tmu",
        .id             = 0,
        .dev = {
                .platform_data  = &tmu0_platform_data,
@@ -284,61 +267,6 @@ static struct platform_device tmu0_device = {
        .num_resources  = ARRAY_SIZE(tmu0_resources),
 };
 
-static struct sh_timer_config tmu1_platform_data = {
-       .channel_offset = 0x10,
-       .timer_bit = 1,
-       .clocksource_rating = 200,
-};
-
-static struct resource tmu1_resources[] = {
-       [0] = {
-               .start  = 0xffd80014,
-               .end    = 0xffd8001f,
-               .flags  = IORESOURCE_MEM,
-       },
-       [1] = {
-               .start  = evt2irq(0x420),
-               .flags  = IORESOURCE_IRQ,
-       },
-};
-
-static struct platform_device tmu1_device = {
-       .name           = "sh_tmu",
-       .id             = 1,
-       .dev = {
-               .platform_data  = &tmu1_platform_data,
-       },
-       .resource       = tmu1_resources,
-       .num_resources  = ARRAY_SIZE(tmu1_resources),
-};
-
-static struct sh_timer_config tmu2_platform_data = {
-       .channel_offset = 0x1c,
-       .timer_bit = 2,
-};
-
-static struct resource tmu2_resources[] = {
-       [0] = {
-               .start  = 0xffd80020,
-               .end    = 0xffd8002b,
-               .flags  = IORESOURCE_MEM,
-       },
-       [1] = {
-               .start  = evt2irq(0x440),
-               .flags  = IORESOURCE_IRQ,
-       },
-};
-
-static struct platform_device tmu2_device = {
-       .name           = "sh_tmu",
-       .id             = 2,
-       .dev = {
-               .platform_data  = &tmu2_platform_data,
-       },
-       .resource       = tmu2_resources,
-       .num_resources  = ARRAY_SIZE(tmu2_resources),
-};
-
 static struct platform_device *sh7343_devices[] __initdata = {
        &scif0_device,
        &scif1_device,
@@ -346,8 +274,6 @@ static struct platform_device *sh7343_devices[] __initdata = {
        &scif3_device,
        &cmt_device,
        &tmu0_device,
-       &tmu1_device,
-       &tmu2_device,
        &iic0_device,
        &iic1_device,
        &vpu_device,
@@ -373,8 +299,6 @@ static struct platform_device *sh7343_early_devices[] __initdata = {
        &scif3_device,
        &cmt_device,
        &tmu0_device,
-       &tmu1_device,
-       &tmu2_device,
 };
 
 void __init plat_early_device_setup(void)
index 6f56cbd..f75f673 100644 (file)
@@ -176,26 +176,16 @@ static struct platform_device veu1_device = {
 };
 
 static struct sh_timer_config cmt_platform_data = {
-       .channel_offset = 0x60,
-       .timer_bit = 5,
-       .clockevent_rating = 125,
-       .clocksource_rating = 200,
+       .channels_mask = 0x20,
 };
 
 static struct resource cmt_resources[] = {
-       [0] = {
-               .start  = 0x044a0060,
-               .end    = 0x044a006b,
-               .flags  = IORESOURCE_MEM,
-       },
-       [1] = {
-               .start  = evt2irq(0xf00),
-               .flags  = IORESOURCE_IRQ,
-       },
+       DEFINE_RES_MEM(0x044a0000, 0x70),
+       DEFINE_RES_IRQ(evt2irq(0xf00)),
 };
 
 static struct platform_device cmt_device = {
-       .name           = "sh_cmt",
+       .name           = "sh-cmt-32",
        .id             = 0,
        .dev = {
                .platform_data  = &cmt_platform_data,
@@ -205,25 +195,18 @@ static struct platform_device cmt_device = {
 };
 
 static struct sh_timer_config tmu0_platform_data = {
-       .channel_offset = 0x04,
-       .timer_bit = 0,
-       .clockevent_rating = 200,
+       .channels_mask = 7,
 };
 
 static struct resource tmu0_resources[] = {
-       [0] = {
-               .start  = 0xffd80008,
-               .end    = 0xffd80013,
-               .flags  = IORESOURCE_MEM,
-       },
-       [1] = {
-               .start  = 16,
-               .flags  = IORESOURCE_IRQ,
-       },
+       DEFINE_RES_MEM(0xffd80000, 0x2c),
+       DEFINE_RES_IRQ(evt2irq(0x400)),
+       DEFINE_RES_IRQ(evt2irq(0x420)),
+       DEFINE_RES_IRQ(evt2irq(0x440)),
 };
 
 static struct platform_device tmu0_device = {
-       .name           = "sh_tmu",
+       .name           = "sh-tmu",
        .id             = 0,
        .dev = {
                .platform_data  = &tmu0_platform_data,
@@ -232,67 +215,10 @@ static struct platform_device tmu0_device = {
        .num_resources  = ARRAY_SIZE(tmu0_resources),
 };
 
-static struct sh_timer_config tmu1_platform_data = {
-       .channel_offset = 0x10,
-       .timer_bit = 1,
-       .clocksource_rating = 200,
-};
-
-static struct resource tmu1_resources[] = {
-       [0] = {
-               .start  = 0xffd80014,
-               .end    = 0xffd8001f,
-               .flags  = IORESOURCE_MEM,
-       },
-       [1] = {
-               .start  = evt2irq(0x420),
-               .flags  = IORESOURCE_IRQ,
-       },
-};
-
-static struct platform_device tmu1_device = {
-       .name           = "sh_tmu",
-       .id             = 1,
-       .dev = {
-               .platform_data  = &tmu1_platform_data,
-       },
-       .resource       = tmu1_resources,
-       .num_resources  = ARRAY_SIZE(tmu1_resources),
-};
-
-static struct sh_timer_config tmu2_platform_data = {
-       .channel_offset = 0x1c,
-       .timer_bit = 2,
-};
-
-static struct resource tmu2_resources[] = {
-       [0] = {
-               .start  = 0xffd80020,
-               .end    = 0xffd8002b,
-               .flags  = IORESOURCE_MEM,
-       },
-       [1] = {
-               .start  = evt2irq(0x440),
-               .flags  = IORESOURCE_IRQ,
-       },
-};
-
-static struct platform_device tmu2_device = {
-       .name           = "sh_tmu",
-       .id             = 2,
-       .dev = {
-               .platform_data  = &tmu2_platform_data,
-       },
-       .resource       = tmu2_resources,
-       .num_resources  = ARRAY_SIZE(tmu2_resources),
-};
-
 static struct platform_device *sh7366_devices[] __initdata = {
        &scif0_device,
        &cmt_device,
        &tmu0_device,
-       &tmu1_device,
-       &tmu2_device,
        &iic_device,
        &usb_host_device,
        &vpu_device,
@@ -315,8 +241,6 @@ static struct platform_device *sh7366_early_devices[] __initdata = {
        &scif0_device,
        &cmt_device,
        &tmu0_device,
-       &tmu1_device,
-       &tmu2_device,
 };
 
 void __init plat_early_device_setup(void)
index 5a94efc..57f83a9 100644 (file)
@@ -413,26 +413,16 @@ static struct platform_device jpu_device = {
 };
 
 static struct sh_timer_config cmt_platform_data = {
-       .channel_offset = 0x60,
-       .timer_bit = 5,
-       .clockevent_rating = 125,
-       .clocksource_rating = 125,
+       .channels_mask = 0x20,
 };
 
 static struct resource cmt_resources[] = {
-       [0] = {
-               .start  = 0x044a0060,
-               .end    = 0x044a006b,
-               .flags  = IORESOURCE_MEM,
-       },
-       [1] = {
-               .start  = evt2irq(0xf00),
-               .flags  = IORESOURCE_IRQ,
-       },
+       DEFINE_RES_MEM(0x044a0000, 0x70),
+       DEFINE_RES_IRQ(evt2irq(0xf00)),
 };
 
 static struct platform_device cmt_device = {
-       .name           = "sh_cmt",
+       .name           = "sh-cmt-32",
        .id             = 0,
        .dev = {
                .platform_data  = &cmt_platform_data,
@@ -442,25 +432,18 @@ static struct platform_device cmt_device = {
 };
 
 static struct sh_timer_config tmu0_platform_data = {
-       .channel_offset = 0x04,
-       .timer_bit = 0,
-       .clockevent_rating = 200,
+       .channels_mask = 7,
 };
 
 static struct resource tmu0_resources[] = {
-       [0] = {
-               .start  = 0xffd80008,
-               .end    = 0xffd80013,
-               .flags  = IORESOURCE_MEM,
-       },
-       [1] = {
-               .start  = evt2irq(0x400),
-               .flags  = IORESOURCE_IRQ,
-       },
+       DEFINE_RES_MEM(0xffd80000, 0x2c),
+       DEFINE_RES_IRQ(evt2irq(0x400)),
+       DEFINE_RES_IRQ(evt2irq(0x420)),
+       DEFINE_RES_IRQ(evt2irq(0x440)),
 };
 
 static struct platform_device tmu0_device = {
-       .name           = "sh_tmu",
+       .name           = "sh-tmu",
        .id             = 0,
        .dev = {
                .platform_data  = &tmu0_platform_data,
@@ -469,61 +452,6 @@ static struct platform_device tmu0_device = {
        .num_resources  = ARRAY_SIZE(tmu0_resources),
 };
 
-static struct sh_timer_config tmu1_platform_data = {
-       .channel_offset = 0x10,
-       .timer_bit = 1,
-       .clocksource_rating = 200,
-};
-
-static struct resource tmu1_resources[] = {
-       [0] = {
-               .start  = 0xffd80014,
-               .end    = 0xffd8001f,
-               .flags  = IORESOURCE_MEM,
-       },
-       [1] = {
-               .start  = evt2irq(0x420),
-               .flags  = IORESOURCE_IRQ,
-       },
-};
-
-static struct platform_device tmu1_device = {
-       .name           = "sh_tmu",
-       .id             = 1,
-       .dev = {
-               .platform_data  = &tmu1_platform_data,
-       },
-       .resource       = tmu1_resources,
-       .num_resources  = ARRAY_SIZE(tmu1_resources),
-};
-
-static struct sh_timer_config tmu2_platform_data = {
-       .channel_offset = 0x1c,
-       .timer_bit = 2,
-};
-
-static struct resource tmu2_resources[] = {
-       [0] = {
-               .start  = 0xffd80020,
-               .end    = 0xffd8002b,
-               .flags  = IORESOURCE_MEM,
-       },
-       [1] = {
-               .start  = 18,
-               .flags  = IORESOURCE_IRQ,
-       },
-};
-
-static struct platform_device tmu2_device = {
-       .name           = "sh_tmu",
-       .id             = 2,
-       .dev = {
-               .platform_data  = &tmu2_platform_data,
-       },
-       .resource       = tmu2_resources,
-       .num_resources  = ARRAY_SIZE(tmu2_resources),
-};
-
 static struct siu_platform siu_platform_data = {
        .dma_slave_tx_a = SHDMA_SLAVE_SIUA_TX,
        .dma_slave_rx_a = SHDMA_SLAVE_SIUA_RX,
@@ -559,8 +487,6 @@ static struct platform_device *sh7722_devices[] __initdata = {
        &scif2_device,
        &cmt_device,
        &tmu0_device,
-       &tmu1_device,
-       &tmu2_device,
        &rtc_device,
        &usbf_device,
        &iic_device,
@@ -588,8 +514,6 @@ static struct platform_device *sh7722_early_devices[] __initdata = {
        &scif2_device,
        &cmt_device,
        &tmu0_device,
-       &tmu1_device,
-       &tmu2_device,
 };
 
 void __init plat_early_device_setup(void)
index 3c5eb09..3533b56 100644 (file)
@@ -245,26 +245,16 @@ static struct platform_device veu1_device = {
 };
 
 static struct sh_timer_config cmt_platform_data = {
-       .channel_offset = 0x60,
-       .timer_bit = 5,
-       .clockevent_rating = 125,
-       .clocksource_rating = 125,
+       .channels_mask = 0x20,
 };
 
 static struct resource cmt_resources[] = {
-       [0] = {
-               .start  = 0x044a0060,
-               .end    = 0x044a006b,
-               .flags  = IORESOURCE_MEM,
-       },
-       [1] = {
-               .start  = evt2irq(0xf00),
-               .flags  = IORESOURCE_IRQ,
-       },
+       DEFINE_RES_MEM(0x044a0000, 0x70),
+       DEFINE_RES_IRQ(evt2irq(0xf00)),
 };
 
 static struct platform_device cmt_device = {
-       .name           = "sh_cmt",
+       .name           = "sh-cmt-32",
        .id             = 0,
        .dev = {
                .platform_data  = &cmt_platform_data,
@@ -274,25 +264,18 @@ static struct platform_device cmt_device = {
 };
 
 static struct sh_timer_config tmu0_platform_data = {
-       .channel_offset = 0x04,
-       .timer_bit = 0,
-       .clockevent_rating = 200,
+       .channels_mask = 7,
 };
 
 static struct resource tmu0_resources[] = {
-       [0] = {
-               .start  = 0xffd80008,
-               .end    = 0xffd80013,
-               .flags  = IORESOURCE_MEM,
-       },
-       [1] = {
-               .start  = evt2irq(0x400),
-               .flags  = IORESOURCE_IRQ,
-       },
+       DEFINE_RES_MEM(0xffd80000, 0x2c),
+       DEFINE_RES_IRQ(evt2irq(0x400)),
+       DEFINE_RES_IRQ(evt2irq(0x420)),
+       DEFINE_RES_IRQ(evt2irq(0x440)),
 };
 
 static struct platform_device tmu0_device = {
-       .name           = "sh_tmu",
+       .name           = "sh-tmu",
        .id             = 0,
        .dev = {
                .platform_data  = &tmu0_platform_data,
@@ -302,25 +285,18 @@ static struct platform_device tmu0_device = {
 };
 
 static struct sh_timer_config tmu1_platform_data = {
-       .channel_offset = 0x10,
-       .timer_bit = 1,
-       .clocksource_rating = 200,
+       .channels_mask = 7,
 };
 
 static struct resource tmu1_resources[] = {
-       [0] = {
-               .start  = 0xffd80014,
-               .end    = 0xffd8001f,
-               .flags  = IORESOURCE_MEM,
-       },
-       [1] = {
-               .start  = evt2irq(0x420),
-               .flags  = IORESOURCE_IRQ,
-       },
+       DEFINE_RES_MEM(0xffd90000, 0x2c),
+       DEFINE_RES_IRQ(evt2irq(0x920)),
+       DEFINE_RES_IRQ(evt2irq(0x940)),
+       DEFINE_RES_IRQ(evt2irq(0x960)),
 };
 
 static struct platform_device tmu1_device = {
-       .name           = "sh_tmu",
+       .name           = "sh-tmu",
        .id             = 1,
        .dev = {
                .platform_data  = &tmu1_platform_data,
@@ -329,114 +305,6 @@ static struct platform_device tmu1_device = {
        .num_resources  = ARRAY_SIZE(tmu1_resources),
 };
 
-static struct sh_timer_config tmu2_platform_data = {
-       .channel_offset = 0x1c,
-       .timer_bit = 2,
-};
-
-static struct resource tmu2_resources[] = {
-       [0] = {
-               .start  = 0xffd80020,
-               .end    = 0xffd8002b,
-               .flags  = IORESOURCE_MEM,
-       },
-       [1] = {
-               .start  = evt2irq(0x440),
-               .flags  = IORESOURCE_IRQ,
-       },
-};
-
-static struct platform_device tmu2_device = {
-       .name           = "sh_tmu",
-       .id             = 2,
-       .dev = {
-               .platform_data  = &tmu2_platform_data,
-       },
-       .resource       = tmu2_resources,
-       .num_resources  = ARRAY_SIZE(tmu2_resources),
-};
-
-static struct sh_timer_config tmu3_platform_data = {
-       .channel_offset = 0x04,
-       .timer_bit = 0,
-};
-
-static struct resource tmu3_resources[] = {
-       [0] = {
-               .start  = 0xffd90008,
-               .end    = 0xffd90013,
-               .flags  = IORESOURCE_MEM,
-       },
-       [1] = {
-               .start  = evt2irq(0x920),
-               .flags  = IORESOURCE_IRQ,
-       },
-};
-
-static struct platform_device tmu3_device = {
-       .name           = "sh_tmu",
-       .id             = 3,
-       .dev = {
-               .platform_data  = &tmu3_platform_data,
-       },
-       .resource       = tmu3_resources,
-       .num_resources  = ARRAY_SIZE(tmu3_resources),
-};
-
-static struct sh_timer_config tmu4_platform_data = {
-       .channel_offset = 0x10,
-       .timer_bit = 1,
-};
-
-static struct resource tmu4_resources[] = {
-       [0] = {
-               .start  = 0xffd90014,
-               .end    = 0xffd9001f,
-               .flags  = IORESOURCE_MEM,
-       },
-       [1] = {
-               .start  = evt2irq(0x940),
-               .flags  = IORESOURCE_IRQ,
-       },
-};
-
-static struct platform_device tmu4_device = {
-       .name           = "sh_tmu",
-       .id             = 4,
-       .dev = {
-               .platform_data  = &tmu4_platform_data,
-       },
-       .resource       = tmu4_resources,
-       .num_resources  = ARRAY_SIZE(tmu4_resources),
-};
-
-static struct sh_timer_config tmu5_platform_data = {
-       .channel_offset = 0x1c,
-       .timer_bit = 2,
-};
-
-static struct resource tmu5_resources[] = {
-       [0] = {
-               .start  = 0xffd90020,
-               .end    = 0xffd9002b,
-               .flags  = IORESOURCE_MEM,
-       },
-       [1] = {
-               .start  = evt2irq(0x920),
-               .flags  = IORESOURCE_IRQ,
-       },
-};
-
-static struct platform_device tmu5_device = {
-       .name           = "sh_tmu",
-       .id             = 5,
-       .dev = {
-               .platform_data  = &tmu5_platform_data,
-       },
-       .resource       = tmu5_resources,
-       .num_resources  = ARRAY_SIZE(tmu5_resources),
-};
-
 static struct resource rtc_resources[] = {
        [0] = {
                .start  = 0xa465fec0,
@@ -527,10 +395,6 @@ static struct platform_device *sh7723_devices[] __initdata = {
        &cmt_device,
        &tmu0_device,
        &tmu1_device,
-       &tmu2_device,
-       &tmu3_device,
-       &tmu4_device,
-       &tmu5_device,
        &rtc_device,
        &iic_device,
        &sh7723_usb_host_device,
@@ -560,10 +424,6 @@ static struct platform_device *sh7723_early_devices[] __initdata = {
        &cmt_device,
        &tmu0_device,
        &tmu1_device,
-       &tmu2_device,
-       &tmu3_device,
-       &tmu4_device,
-       &tmu5_device,
 };
 
 void __init plat_early_device_setup(void)
index 60ebbc6..b9e84b1 100644 (file)
@@ -648,26 +648,16 @@ static struct platform_device beu1_device = {
 };
 
 static struct sh_timer_config cmt_platform_data = {
-       .channel_offset = 0x60,
-       .timer_bit = 5,
-       .clockevent_rating = 125,
-       .clocksource_rating = 200,
+       .channels_mask = 0x20,
 };
 
 static struct resource cmt_resources[] = {
-       [0] = {
-               .start  = 0x044a0060,
-               .end    = 0x044a006b,
-               .flags  = IORESOURCE_MEM,
-       },
-       [1] = {
-               .start  = evt2irq(0xf00),
-               .flags  = IORESOURCE_IRQ,
-       },
+       DEFINE_RES_MEM(0x044a0000, 0x70),
+       DEFINE_RES_IRQ(evt2irq(0xf00)),
 };
 
 static struct platform_device cmt_device = {
-       .name           = "sh_cmt",
+       .name           = "sh-cmt-32",
        .id             = 0,
        .dev = {
                .platform_data  = &cmt_platform_data,
@@ -677,25 +667,18 @@ static struct platform_device cmt_device = {
 };
 
 static struct sh_timer_config tmu0_platform_data = {
-       .channel_offset = 0x04,
-       .timer_bit = 0,
-       .clockevent_rating = 200,
+       .channels_mask = 7,
 };
 
 static struct resource tmu0_resources[] = {
-       [0] = {
-               .start  = 0xffd80008,
-               .end    = 0xffd80013,
-               .flags  = IORESOURCE_MEM,
-       },
-       [1] = {
-               .start  = evt2irq(0x400),
-               .flags  = IORESOURCE_IRQ,
-       },
+       DEFINE_RES_MEM(0xffd80000, 0x2c),
+       DEFINE_RES_IRQ(evt2irq(0x400)),
+       DEFINE_RES_IRQ(evt2irq(0x420)),
+       DEFINE_RES_IRQ(evt2irq(0x440)),
 };
 
 static struct platform_device tmu0_device = {
-       .name           = "sh_tmu",
+       .name           = "sh-tmu",
        .id             = 0,
        .dev = {
                .platform_data  = &tmu0_platform_data,
@@ -705,25 +688,18 @@ static struct platform_device tmu0_device = {
 };
 
 static struct sh_timer_config tmu1_platform_data = {
-       .channel_offset = 0x10,
-       .timer_bit = 1,
-       .clocksource_rating = 200,
+       .channels_mask = 7,
 };
 
 static struct resource tmu1_resources[] = {
-       [0] = {
-               .start  = 0xffd80014,
-               .end    = 0xffd8001f,
-               .flags  = IORESOURCE_MEM,
-       },
-       [1] = {
-               .start  = evt2irq(0x420),
-               .flags  = IORESOURCE_IRQ,
-       },
+       DEFINE_RES_MEM(0xffd90000, 0x2c),
+       DEFINE_RES_IRQ(evt2irq(0x920)),
+       DEFINE_RES_IRQ(evt2irq(0x940)),
+       DEFINE_RES_IRQ(evt2irq(0x960)),
 };
 
 static struct platform_device tmu1_device = {
-       .name           = "sh_tmu",
+       .name           = "sh-tmu",
        .id             = 1,
        .dev = {
                .platform_data  = &tmu1_platform_data,
@@ -732,115 +708,6 @@ static struct platform_device tmu1_device = {
        .num_resources  = ARRAY_SIZE(tmu1_resources),
 };
 
-static struct sh_timer_config tmu2_platform_data = {
-       .channel_offset = 0x1c,
-       .timer_bit = 2,
-};
-
-static struct resource tmu2_resources[] = {
-       [0] = {
-               .start  = 0xffd80020,
-               .end    = 0xffd8002b,
-               .flags  = IORESOURCE_MEM,
-       },
-       [1] = {
-               .start  = evt2irq(0x440),
-               .flags  = IORESOURCE_IRQ,
-       },
-};
-
-static struct platform_device tmu2_device = {
-       .name           = "sh_tmu",
-       .id             = 2,
-       .dev = {
-               .platform_data  = &tmu2_platform_data,
-       },
-       .resource       = tmu2_resources,
-       .num_resources  = ARRAY_SIZE(tmu2_resources),
-};
-
-
-static struct sh_timer_config tmu3_platform_data = {
-       .channel_offset = 0x04,
-       .timer_bit = 0,
-};
-
-static struct resource tmu3_resources[] = {
-       [0] = {
-               .start  = 0xffd90008,
-               .end    = 0xffd90013,
-               .flags  = IORESOURCE_MEM,
-       },
-       [1] = {
-               .start  = evt2irq(0x920),
-               .flags  = IORESOURCE_IRQ,
-       },
-};
-
-static struct platform_device tmu3_device = {
-       .name           = "sh_tmu",
-       .id             = 3,
-       .dev = {
-               .platform_data  = &tmu3_platform_data,
-       },
-       .resource       = tmu3_resources,
-       .num_resources  = ARRAY_SIZE(tmu3_resources),
-};
-
-static struct sh_timer_config tmu4_platform_data = {
-       .channel_offset = 0x10,
-       .timer_bit = 1,
-};
-
-static struct resource tmu4_resources[] = {
-       [0] = {
-               .start  = 0xffd90014,
-               .end    = 0xffd9001f,
-               .flags  = IORESOURCE_MEM,
-       },
-       [1] = {
-               .start  = evt2irq(0x940),
-               .flags  = IORESOURCE_IRQ,
-       },
-};
-
-static struct platform_device tmu4_device = {
-       .name           = "sh_tmu",
-       .id             = 4,
-       .dev = {
-               .platform_data  = &tmu4_platform_data,
-       },
-       .resource       = tmu4_resources,
-       .num_resources  = ARRAY_SIZE(tmu4_resources),
-};
-
-static struct sh_timer_config tmu5_platform_data = {
-       .channel_offset = 0x1c,
-       .timer_bit = 2,
-};
-
-static struct resource tmu5_resources[] = {
-       [0] = {
-               .start  = 0xffd90020,
-               .end    = 0xffd9002b,
-               .flags  = IORESOURCE_MEM,
-       },
-       [1] = {
-               .start  = evt2irq(0x920),
-               .flags  = IORESOURCE_IRQ,
-       },
-};
-
-static struct platform_device tmu5_device = {
-       .name           = "sh_tmu",
-       .id             = 5,
-       .dev = {
-               .platform_data  = &tmu5_platform_data,
-       },
-       .resource       = tmu5_resources,
-       .num_resources  = ARRAY_SIZE(tmu5_resources),
-};
-
 /* JPU */
 static struct uio_info jpu_platform_data = {
        .name = "JPU",
@@ -938,10 +805,6 @@ static struct platform_device *sh7724_devices[] __initdata = {
        &cmt_device,
        &tmu0_device,
        &tmu1_device,
-       &tmu2_device,
-       &tmu3_device,
-       &tmu4_device,
-       &tmu5_device,
        &dma0_device,
        &dma1_device,
        &rtc_device,
@@ -981,10 +844,6 @@ static struct platform_device *sh7724_early_devices[] __initdata = {
        &cmt_device,
        &tmu0_device,
        &tmu1_device,
-       &tmu2_device,
-       &tmu3_device,
-       &tmu4_device,
-       &tmu5_device,
 };
 
 void __init plat_early_device_setup(void)
index dad4ed1..f617bcb 100644 (file)
@@ -200,25 +200,18 @@ static struct platform_device i2c0_device = {
 
 /* TMU */
 static struct sh_timer_config tmu0_platform_data = {
-       .channel_offset = 0x04,
-       .timer_bit = 0,
-       .clockevent_rating = 200,
+       .channels_mask = 7,
 };
 
 static struct resource tmu0_resources[] = {
-       [0] = {
-               .start  = 0xFFD80008,
-               .end    = 0xFFD80014 - 1,
-               .flags  = IORESOURCE_MEM,
-       },
-       [1] = {
-               .start  = evt2irq(0x400),
-               .flags  = IORESOURCE_IRQ,
-       },
+       DEFINE_RES_MEM(0xffd80000, 0x30),
+       DEFINE_RES_IRQ(evt2irq(0x400)),
+       DEFINE_RES_IRQ(evt2irq(0x420)),
+       DEFINE_RES_IRQ(evt2irq(0x440)),
 };
 
 static struct platform_device tmu0_device = {
-       .name   = "sh_tmu",
+       .name           = "sh-tmu",
        .id             = 0,
        .dev = {
                .platform_data  = &tmu0_platform_data,
@@ -228,26 +221,19 @@ static struct platform_device tmu0_device = {
 };
 
 static struct sh_timer_config tmu1_platform_data = {
-       .channel_offset = 0x10,
-       .timer_bit = 1,
-       .clocksource_rating = 200,
+       .channels_mask = 7,
 };
 
 static struct resource tmu1_resources[] = {
-       [0] = {
-               .start  = 0xFFD80014,
-               .end    = 0xFFD80020 - 1,
-               .flags  = IORESOURCE_MEM,
-       },
-       [1] = {
-               .start  = evt2irq(0x420),
-               .flags  = IORESOURCE_IRQ,
-       },
+       DEFINE_RES_MEM(0xffd81000, 0x30),
+       DEFINE_RES_IRQ(evt2irq(0x480)),
+       DEFINE_RES_IRQ(evt2irq(0x4a0)),
+       DEFINE_RES_IRQ(evt2irq(0x4c0)),
 };
 
 static struct platform_device tmu1_device = {
-       .name           = "sh_tmu",
-       .id                     = 1,
+       .name           = "sh-tmu",
+       .id             = 1,
        .dev = {
                .platform_data  = &tmu1_platform_data,
        },
@@ -256,25 +242,19 @@ static struct platform_device tmu1_device = {
 };
 
 static struct sh_timer_config tmu2_platform_data = {
-       .channel_offset = 0x1c,
-       .timer_bit = 2,
+       .channels_mask = 7,
 };
 
 static struct resource tmu2_resources[] = {
-       [0] = {
-               .start  = 0xFFD80020,
-               .end    = 0xFFD80030 - 1,
-               .flags  = IORESOURCE_MEM,
-       },
-       [1] = {
-               .start  = evt2irq(0x440),
-               .flags  = IORESOURCE_IRQ,
-       },
+       DEFINE_RES_MEM(0xffd82000, 0x30),
+       DEFINE_RES_IRQ(evt2irq(0x500)),
+       DEFINE_RES_IRQ(evt2irq(0x520)),
+       DEFINE_RES_IRQ(evt2irq(0x540)),
 };
 
 static struct platform_device tmu2_device = {
-       .name           = "sh_tmu",
-       .id                     = 2,
+       .name           = "sh-tmu",
+       .id             = 2,
        .dev = {
                .platform_data  = &tmu2_platform_data,
        },
@@ -282,169 +262,6 @@ static struct platform_device tmu2_device = {
        .num_resources  = ARRAY_SIZE(tmu2_resources),
 };
 
-
-static struct sh_timer_config tmu3_platform_data = {
-       .channel_offset = 0x04,
-       .timer_bit = 0,
-};
-
-static struct resource tmu3_resources[] = {
-       [0] = {
-               .start  = 0xFFD81008,
-               .end    = 0xFFD81014 - 1,
-               .flags  = IORESOURCE_MEM,
-       },
-       [1] = {
-               .start  = evt2irq(0x480),
-               .flags  = IORESOURCE_IRQ,
-       },
-};
-
-static struct platform_device tmu3_device = {
-       .name           = "sh_tmu",
-       .id                     = 3,
-       .dev = {
-               .platform_data  = &tmu3_platform_data,
-       },
-       .resource       = tmu3_resources,
-       .num_resources  = ARRAY_SIZE(tmu3_resources),
-};
-
-static struct sh_timer_config tmu4_platform_data = {
-       .channel_offset = 0x10,
-       .timer_bit = 1,
-};
-
-static struct resource tmu4_resources[] = {
-       [0] = {
-               .start  = 0xFFD81014,
-               .end    = 0xFFD81020 - 1,
-               .flags  = IORESOURCE_MEM,
-       },
-       [1] = {
-               .start  = evt2irq(0x4A0),
-               .flags  = IORESOURCE_IRQ,
-       },
-};
-
-static struct platform_device tmu4_device = {
-       .name           = "sh_tmu",
-       .id                     = 4,
-       .dev = {
-               .platform_data  = &tmu4_platform_data,
-       },
-       .resource       = tmu4_resources,
-       .num_resources  = ARRAY_SIZE(tmu4_resources),
-};
-
-static struct sh_timer_config tmu5_platform_data = {
-       .channel_offset = 0x1c,
-       .timer_bit = 2,
-};
-
-static struct resource tmu5_resources[] = {
-       [0] = {
-               .start  = 0xFFD81020,
-               .end    = 0xFFD81030 - 1,
-               .flags  = IORESOURCE_MEM,
-       },
-       [1] = {
-               .start  = evt2irq(0x4C0),
-               .flags  = IORESOURCE_IRQ,
-       },
-};
-
-static struct platform_device tmu5_device = {
-       .name           = "sh_tmu",
-       .id                     = 5,
-       .dev = {
-               .platform_data  = &tmu5_platform_data,
-       },
-       .resource       = tmu5_resources,
-       .num_resources  = ARRAY_SIZE(tmu5_resources),
-};
-
-static struct sh_timer_config tmu6_platform_data = {
-       .channel_offset = 0x4,
-       .timer_bit = 0,
-};
-
-static struct resource tmu6_resources[] = {
-       [0] = {
-               .start  = 0xFFD82008,
-               .end    = 0xFFD82014 - 1,
-               .flags  = IORESOURCE_MEM,
-       },
-       [1] = {
-               .start  = evt2irq(0x500),
-               .flags  = IORESOURCE_IRQ,
-       },
-};
-
-static struct platform_device tmu6_device = {
-       .name           = "sh_tmu",
-       .id                     = 6,
-       .dev = {
-               .platform_data  = &tmu6_platform_data,
-       },
-       .resource       = tmu6_resources,
-       .num_resources  = ARRAY_SIZE(tmu6_resources),
-};
-
-static struct sh_timer_config tmu7_platform_data = {
-       .channel_offset = 0x10,
-       .timer_bit = 1,
-};
-
-static struct resource tmu7_resources[] = {
-       [0] = {
-               .start  = 0xFFD82014,
-               .end    = 0xFFD82020 - 1,
-               .flags  = IORESOURCE_MEM,
-       },
-       [1] = {
-               .start  = evt2irq(0x520),
-               .flags  = IORESOURCE_IRQ,
-       },
-};
-
-static struct platform_device tmu7_device = {
-       .name           = "sh_tmu",
-       .id                     = 7,
-       .dev = {
-               .platform_data  = &tmu7_platform_data,
-       },
-       .resource       = tmu7_resources,
-       .num_resources  = ARRAY_SIZE(tmu7_resources),
-};
-
-static struct sh_timer_config tmu8_platform_data = {
-       .channel_offset = 0x1c,
-       .timer_bit = 2,
-};
-
-static struct resource tmu8_resources[] = {
-       [0] = {
-               .start  = 0xFFD82020,
-               .end    = 0xFFD82030 - 1,
-               .flags  = IORESOURCE_MEM,
-       },
-       [1] = {
-               .start  = evt2irq(0x540),
-               .flags  = IORESOURCE_IRQ,
-       },
-};
-
-static struct platform_device tmu8_device = {
-       .name           = "sh_tmu",
-       .id                     = 8,
-       .dev = {
-               .platform_data  = &tmu8_platform_data,
-       },
-       .resource       = tmu8_resources,
-       .num_resources  = ARRAY_SIZE(tmu8_resources),
-};
-
 static struct platform_device *sh7734_devices[] __initdata = {
        &scif0_device,
        &scif1_device,
@@ -455,12 +272,6 @@ static struct platform_device *sh7734_devices[] __initdata = {
        &tmu0_device,
        &tmu1_device,
        &tmu2_device,
-       &tmu3_device,
-       &tmu4_device,
-       &tmu5_device,
-       &tmu6_device,
-       &tmu7_device,
-       &tmu8_device,
        &rtc_device,
 };
 
@@ -474,12 +285,6 @@ static struct platform_device *sh7734_early_devices[] __initdata = {
        &tmu0_device,
        &tmu1_device,
        &tmu2_device,
-       &tmu3_device,
-       &tmu4_device,
-       &tmu5_device,
-       &tmu6_device,
-       &tmu7_device,
-       &tmu8_device,
 };
 
 void __init plat_early_device_setup(void)
index e43e5db..7b24ec4 100644 (file)
@@ -87,25 +87,17 @@ static struct platform_device scif4_device = {
 };
 
 static struct sh_timer_config tmu0_platform_data = {
-       .channel_offset = 0x04,
-       .timer_bit = 0,
-       .clockevent_rating = 200,
+       .channels_mask = 3,
 };
 
 static struct resource tmu0_resources[] = {
-       [0] = {
-               .start  = 0xfe430008,
-               .end    = 0xfe430013,
-               .flags  = IORESOURCE_MEM,
-       },
-       [1] = {
-               .start  = evt2irq(0x580),
-               .flags  = IORESOURCE_IRQ,
-       },
+       DEFINE_RES_MEM(0xfe430000, 0x20),
+       DEFINE_RES_IRQ(evt2irq(0x580)),
+       DEFINE_RES_IRQ(evt2irq(0x5a0)),
 };
 
 static struct platform_device tmu0_device = {
-       .name           = "sh_tmu",
+       .name           = "sh-tmu",
        .id             = 0,
        .dev = {
                .platform_data  = &tmu0_platform_data,
@@ -114,34 +106,6 @@ static struct platform_device tmu0_device = {
        .num_resources  = ARRAY_SIZE(tmu0_resources),
 };
 
-static struct sh_timer_config tmu1_platform_data = {
-       .channel_offset = 0x10,
-       .timer_bit = 1,
-       .clocksource_rating = 200,
-};
-
-static struct resource tmu1_resources[] = {
-       [0] = {
-               .start  = 0xfe430014,
-               .end    = 0xfe43001f,
-               .flags  = IORESOURCE_MEM,
-       },
-       [1] = {
-               .start  = evt2irq(0x5a0),
-               .flags  = IORESOURCE_IRQ,
-       },
-};
-
-static struct platform_device tmu1_device = {
-       .name           = "sh_tmu",
-       .id             = 1,
-       .dev = {
-               .platform_data  = &tmu1_platform_data,
-       },
-       .resource       = tmu1_resources,
-       .num_resources  = ARRAY_SIZE(tmu1_resources),
-};
-
 static struct resource spi0_resources[] = {
        [0] = {
                .start  = 0xfe002000,
@@ -782,7 +746,6 @@ static struct platform_device *sh7757_devices[] __initdata = {
        &scif3_device,
        &scif4_device,
        &tmu0_device,
-       &tmu1_device,
        &dma0_device,
        &dma1_device,
        &dma2_device,
@@ -806,7 +769,6 @@ static struct platform_device *sh7757_early_devices[] __initdata = {
        &scif3_device,
        &scif4_device,
        &tmu0_device,
-       &tmu1_device,
 };
 
 void __init plat_early_device_setup(void)
index 5eebbd7..5a47d67 100644 (file)
@@ -158,25 +158,18 @@ static struct platform_device usbf_device = {
 };
 
 static struct sh_timer_config tmu0_platform_data = {
-       .channel_offset = 0x04,
-       .timer_bit = 0,
-       .clockevent_rating = 200,
+       .channels_mask = 7,
 };
 
 static struct resource tmu0_resources[] = {
-       [0] = {
-               .start  = 0xffd80008,
-               .end    = 0xffd80013,
-               .flags  = IORESOURCE_MEM,
-       },
-       [1] = {
-               .start  = evt2irq(0x580),
-               .flags  = IORESOURCE_IRQ,
-       },
+       DEFINE_RES_MEM(0xffd80000, 0x30),
+       DEFINE_RES_IRQ(evt2irq(0x580)),
+       DEFINE_RES_IRQ(evt2irq(0x5a0)),
+       DEFINE_RES_IRQ(evt2irq(0x5c0)),
 };
 
 static struct platform_device tmu0_device = {
-       .name           = "sh_tmu",
+       .name           = "sh-tmu",
        .id             = 0,
        .dev = {
                .platform_data  = &tmu0_platform_data,
@@ -186,25 +179,18 @@ static struct platform_device tmu0_device = {
 };
 
 static struct sh_timer_config tmu1_platform_data = {
-       .channel_offset = 0x10,
-       .timer_bit = 1,
-       .clocksource_rating = 200,
+       .channels_mask = 7,
 };
 
 static struct resource tmu1_resources[] = {
-       [0] = {
-               .start  = 0xffd80014,
-               .end    = 0xffd8001f,
-               .flags  = IORESOURCE_MEM,
-       },
-       [1] = {
-               .start  = evt2irq(0x5a0),
-               .flags  = IORESOURCE_IRQ,
-       },
+       DEFINE_RES_MEM(0xffd88000, 0x2c),
+       DEFINE_RES_IRQ(evt2irq(0xe00)),
+       DEFINE_RES_IRQ(evt2irq(0xe20)),
+       DEFINE_RES_IRQ(evt2irq(0xe40)),
 };
 
 static struct platform_device tmu1_device = {
-       .name           = "sh_tmu",
+       .name           = "sh-tmu",
        .id             = 1,
        .dev = {
                .platform_data  = &tmu1_platform_data,
@@ -213,124 +199,12 @@ static struct platform_device tmu1_device = {
        .num_resources  = ARRAY_SIZE(tmu1_resources),
 };
 
-static struct sh_timer_config tmu2_platform_data = {
-       .channel_offset = 0x1c,
-       .timer_bit = 2,
-};
-
-static struct resource tmu2_resources[] = {
-       [0] = {
-               .start  = 0xffd80020,
-               .end    = 0xffd8002f,
-               .flags  = IORESOURCE_MEM,
-       },
-       [1] = {
-               .start  = evt2irq(0x5c0),
-               .flags  = IORESOURCE_IRQ,
-       },
-};
-
-static struct platform_device tmu2_device = {
-       .name           = "sh_tmu",
-       .id             = 2,
-       .dev = {
-               .platform_data  = &tmu2_platform_data,
-       },
-       .resource       = tmu2_resources,
-       .num_resources  = ARRAY_SIZE(tmu2_resources),
-};
-
-static struct sh_timer_config tmu3_platform_data = {
-       .channel_offset = 0x04,
-       .timer_bit = 0,
-};
-
-static struct resource tmu3_resources[] = {
-       [0] = {
-               .start  = 0xffd88008,
-               .end    = 0xffd88013,
-               .flags  = IORESOURCE_MEM,
-       },
-       [1] = {
-               .start  = evt2irq(0xe00),
-               .flags  = IORESOURCE_IRQ,
-       },
-};
-
-static struct platform_device tmu3_device = {
-       .name           = "sh_tmu",
-       .id             = 3,
-       .dev = {
-               .platform_data  = &tmu3_platform_data,
-       },
-       .resource       = tmu3_resources,
-       .num_resources  = ARRAY_SIZE(tmu3_resources),
-};
-
-static struct sh_timer_config tmu4_platform_data = {
-       .channel_offset = 0x10,
-       .timer_bit = 1,
-};
-
-static struct resource tmu4_resources[] = {
-       [0] = {
-               .start  = 0xffd88014,
-               .end    = 0xffd8801f,
-               .flags  = IORESOURCE_MEM,
-       },
-       [1] = {
-               .start  = evt2irq(0xe20),
-               .flags  = IORESOURCE_IRQ,
-       },
-};
-
-static struct platform_device tmu4_device = {
-       .name           = "sh_tmu",
-       .id             = 4,
-       .dev = {
-               .platform_data  = &tmu4_platform_data,
-       },
-       .resource       = tmu4_resources,
-       .num_resources  = ARRAY_SIZE(tmu4_resources),
-};
-
-static struct sh_timer_config tmu5_platform_data = {
-       .channel_offset = 0x1c,
-       .timer_bit = 2,
-};
-
-static struct resource tmu5_resources[] = {
-       [0] = {
-               .start  = 0xffd88020,
-               .end    = 0xffd8802b,
-               .flags  = IORESOURCE_MEM,
-       },
-       [1] = {
-               .start  = evt2irq(0xe40),
-               .flags  = IORESOURCE_IRQ,
-       },
-};
-
-static struct platform_device tmu5_device = {
-       .name           = "sh_tmu",
-       .id             = 5,
-       .dev = {
-               .platform_data  = &tmu5_platform_data,
-       },
-       .resource       = tmu5_resources,
-       .num_resources  = ARRAY_SIZE(tmu5_resources),
-};
-
 static struct platform_device *sh7763_devices[] __initdata = {
        &scif0_device,
        &scif1_device,
        &scif2_device,
        &tmu0_device,
        &tmu1_device,
-       &tmu2_device,
-       &tmu3_device,
-       &tmu4_device,
-       &tmu5_device,
        &rtc_device,
        &usb_ohci_device,
        &usbf_device,
@@ -349,10 +223,6 @@ static struct platform_device *sh7763_early_devices[] __initdata = {
        &scif2_device,
        &tmu0_device,
        &tmu1_device,
-       &tmu2_device,
-       &tmu3_device,
-       &tmu4_device,
-       &tmu5_device,
 };
 
 void __init plat_early_device_setup(void)
index e1ba8cb..e9b532a 100644 (file)
@@ -226,25 +226,18 @@ static struct platform_device scif9_device = {
 };
 
 static struct sh_timer_config tmu0_platform_data = {
-       .channel_offset = 0x04,
-       .timer_bit = 0,
-       .clockevent_rating = 200,
+       .channels_mask = 7,
 };
 
 static struct resource tmu0_resources[] = {
-       [0] = {
-               .start  = 0xffd80008,
-               .end    = 0xffd80013,
-               .flags  = IORESOURCE_MEM,
-       },
-       [1] = {
-               .start  = evt2irq(0x400),
-               .flags  = IORESOURCE_IRQ,
-       },
+       DEFINE_RES_MEM(0xffd80000, 0x30),
+       DEFINE_RES_IRQ(evt2irq(0x400)),
+       DEFINE_RES_IRQ(evt2irq(0x420)),
+       DEFINE_RES_IRQ(evt2irq(0x440)),
 };
 
 static struct platform_device tmu0_device = {
-       .name           = "sh_tmu",
+       .name           = "sh-tmu",
        .id             = 0,
        .dev = {
                .platform_data  = &tmu0_platform_data,
@@ -254,25 +247,18 @@ static struct platform_device tmu0_device = {
 };
 
 static struct sh_timer_config tmu1_platform_data = {
-       .channel_offset = 0x10,
-       .timer_bit = 1,
-       .clocksource_rating = 200,
+       .channels_mask = 7,
 };
 
 static struct resource tmu1_resources[] = {
-       [0] = {
-               .start  = 0xffd80014,
-               .end    = 0xffd8001f,
-               .flags  = IORESOURCE_MEM,
-       },
-       [1] = {
-               .start  = evt2irq(0x420),
-               .flags  = IORESOURCE_IRQ,
-       },
+       DEFINE_RES_MEM(0xffd81000, 0x30),
+       DEFINE_RES_IRQ(evt2irq(0x460)),
+       DEFINE_RES_IRQ(evt2irq(0x480)),
+       DEFINE_RES_IRQ(evt2irq(0x4a0)),
 };
 
 static struct platform_device tmu1_device = {
-       .name           = "sh_tmu",
+       .name           = "sh-tmu",
        .id             = 1,
        .dev = {
                .platform_data  = &tmu1_platform_data,
@@ -282,24 +268,18 @@ static struct platform_device tmu1_device = {
 };
 
 static struct sh_timer_config tmu2_platform_data = {
-       .channel_offset = 0x1c,
-       .timer_bit = 2,
+       .channels_mask = 7,
 };
 
 static struct resource tmu2_resources[] = {
-       [0] = {
-               .start  = 0xffd80020,
-               .end    = 0xffd8002f,
-               .flags  = IORESOURCE_MEM,
-       },
-       [1] = {
-               .start  = evt2irq(0x440),
-               .flags  = IORESOURCE_IRQ,
-       },
+       DEFINE_RES_MEM(0xffd82000, 0x2c),
+       DEFINE_RES_IRQ(evt2irq(0x4c0)),
+       DEFINE_RES_IRQ(evt2irq(0x4e0)),
+       DEFINE_RES_IRQ(evt2irq(0x500)),
 };
 
 static struct platform_device tmu2_device = {
-       .name           = "sh_tmu",
+       .name           = "sh-tmu",
        .id             = 2,
        .dev = {
                .platform_data  = &tmu2_platform_data,
@@ -308,168 +288,6 @@ static struct platform_device tmu2_device = {
        .num_resources  = ARRAY_SIZE(tmu2_resources),
 };
 
-static struct sh_timer_config tmu3_platform_data = {
-       .channel_offset = 0x04,
-       .timer_bit = 0,
-};
-
-static struct resource tmu3_resources[] = {
-       [0] = {
-               .start  = 0xffd81008,
-               .end    = 0xffd81013,
-               .flags  = IORESOURCE_MEM,
-       },
-       [1] = {
-               .start  = evt2irq(0x460),
-               .flags  = IORESOURCE_IRQ,
-       },
-};
-
-static struct platform_device tmu3_device = {
-       .name           = "sh_tmu",
-       .id             = 3,
-       .dev = {
-               .platform_data  = &tmu3_platform_data,
-       },
-       .resource       = tmu3_resources,
-       .num_resources  = ARRAY_SIZE(tmu3_resources),
-};
-
-static struct sh_timer_config tmu4_platform_data = {
-       .channel_offset = 0x10,
-       .timer_bit = 1,
-};
-
-static struct resource tmu4_resources[] = {
-       [0] = {
-               .start  = 0xffd81014,
-               .end    = 0xffd8101f,
-               .flags  = IORESOURCE_MEM,
-       },
-       [1] = {
-               .start  = evt2irq(0x480),
-               .flags  = IORESOURCE_IRQ,
-       },
-};
-
-static struct platform_device tmu4_device = {
-       .name           = "sh_tmu",
-       .id             = 4,
-       .dev = {
-               .platform_data  = &tmu4_platform_data,
-       },
-       .resource       = tmu4_resources,
-       .num_resources  = ARRAY_SIZE(tmu4_resources),
-};
-
-static struct sh_timer_config tmu5_platform_data = {
-       .channel_offset = 0x1c,
-       .timer_bit = 2,
-};
-
-static struct resource tmu5_resources[] = {
-       [0] = {
-               .start  = 0xffd81020,
-               .end    = 0xffd8102f,
-               .flags  = IORESOURCE_MEM,
-       },
-       [1] = {
-               .start  = evt2irq(0x4a0),
-               .flags  = IORESOURCE_IRQ,
-       },
-};
-
-static struct platform_device tmu5_device = {
-       .name           = "sh_tmu",
-       .id             = 5,
-       .dev = {
-               .platform_data  = &tmu5_platform_data,
-       },
-       .resource       = tmu5_resources,
-       .num_resources  = ARRAY_SIZE(tmu5_resources),
-};
-
-static struct sh_timer_config tmu6_platform_data = {
-       .channel_offset = 0x04,
-       .timer_bit = 0,
-};
-
-static struct resource tmu6_resources[] = {
-       [0] = {
-               .start  = 0xffd82008,
-               .end    = 0xffd82013,
-               .flags  = IORESOURCE_MEM,
-       },
-       [1] = {
-               .start  = evt2irq(0x4c0),
-               .flags  = IORESOURCE_IRQ,
-       },
-};
-
-static struct platform_device tmu6_device = {
-       .name           = "sh_tmu",
-       .id             = 6,
-       .dev = {
-               .platform_data  = &tmu6_platform_data,
-       },
-       .resource       = tmu6_resources,
-       .num_resources  = ARRAY_SIZE(tmu6_resources),
-};
-
-static struct sh_timer_config tmu7_platform_data = {
-       .channel_offset = 0x10,
-       .timer_bit = 1,
-};
-
-static struct resource tmu7_resources[] = {
-       [0] = {
-               .start  = 0xffd82014,
-               .end    = 0xffd8201f,
-               .flags  = IORESOURCE_MEM,
-       },
-       [1] = {
-               .start  = evt2irq(0x4e0),
-               .flags  = IORESOURCE_IRQ,
-       },
-};
-
-static struct platform_device tmu7_device = {
-       .name           = "sh_tmu",
-       .id             = 7,
-       .dev = {
-               .platform_data  = &tmu7_platform_data,
-       },
-       .resource       = tmu7_resources,
-       .num_resources  = ARRAY_SIZE(tmu7_resources),
-};
-
-static struct sh_timer_config tmu8_platform_data = {
-       .channel_offset = 0x1c,
-       .timer_bit = 2,
-};
-
-static struct resource tmu8_resources[] = {
-       [0] = {
-               .start  = 0xffd82020,
-               .end    = 0xffd8202b,
-               .flags  = IORESOURCE_MEM,
-       },
-       [1] = {
-               .start  = evt2irq(0x500),
-               .flags  = IORESOURCE_IRQ,
-       },
-};
-
-static struct platform_device tmu8_device = {
-       .name           = "sh_tmu",
-       .id             = 8,
-       .dev = {
-               .platform_data  = &tmu8_platform_data,
-       },
-       .resource       = tmu8_resources,
-       .num_resources  = ARRAY_SIZE(tmu8_resources),
-};
-
 static struct platform_device *sh7770_devices[] __initdata = {
        &scif0_device,
        &scif1_device,
@@ -484,12 +302,6 @@ static struct platform_device *sh7770_devices[] __initdata = {
        &tmu0_device,
        &tmu1_device,
        &tmu2_device,
-       &tmu3_device,
-       &tmu4_device,
-       &tmu5_device,
-       &tmu6_device,
-       &tmu7_device,
-       &tmu8_device,
 };
 
 static int __init sh7770_devices_setup(void)
@@ -513,12 +325,6 @@ static struct platform_device *sh7770_early_devices[] __initdata = {
        &tmu0_device,
        &tmu1_device,
        &tmu2_device,
-       &tmu3_device,
-       &tmu4_device,
-       &tmu5_device,
-       &tmu6_device,
-       &tmu7_device,
-       &tmu8_device,
 };
 
 void __init plat_early_device_setup(void)
index 668e54b..3ee7dd9 100644 (file)
@@ -62,25 +62,18 @@ static struct platform_device scif1_device = {
 };
 
 static struct sh_timer_config tmu0_platform_data = {
-       .channel_offset = 0x04,
-       .timer_bit = 0,
-       .clockevent_rating = 200,
+       .channels_mask = 7,
 };
 
 static struct resource tmu0_resources[] = {
-       [0] = {
-               .start  = 0xffd80008,
-               .end    = 0xffd80013,
-               .flags  = IORESOURCE_MEM,
-       },
-       [1] = {
-               .start  = evt2irq(0x580),
-               .flags  = IORESOURCE_IRQ,
-       },
+       DEFINE_RES_MEM(0xffd80000, 0x30),
+       DEFINE_RES_IRQ(evt2irq(0x580)),
+       DEFINE_RES_IRQ(evt2irq(0x5a0)),
+       DEFINE_RES_IRQ(evt2irq(0x5c0)),
 };
 
 static struct platform_device tmu0_device = {
-       .name           = "sh_tmu",
+       .name           = "sh-tmu",
        .id             = 0,
        .dev = {
                .platform_data  = &tmu0_platform_data,
@@ -90,25 +83,18 @@ static struct platform_device tmu0_device = {
 };
 
 static struct sh_timer_config tmu1_platform_data = {
-       .channel_offset = 0x10,
-       .timer_bit = 1,
-       .clocksource_rating = 200,
+       .channels_mask = 7,
 };
 
 static struct resource tmu1_resources[] = {
-       [0] = {
-               .start  = 0xffd80014,
-               .end    = 0xffd8001f,
-               .flags  = IORESOURCE_MEM,
-       },
-       [1] = {
-               .start  = evt2irq(0x5a0),
-               .flags  = IORESOURCE_IRQ,
-       },
+       DEFINE_RES_MEM(0xffdc0000, 0x2c),
+       DEFINE_RES_IRQ(evt2irq(0xe00)),
+       DEFINE_RES_IRQ(evt2irq(0xe20)),
+       DEFINE_RES_IRQ(evt2irq(0xe40)),
 };
 
 static struct platform_device tmu1_device = {
-       .name           = "sh_tmu",
+       .name           = "sh-tmu",
        .id             = 1,
        .dev = {
                .platform_data  = &tmu1_platform_data,
@@ -117,114 +103,6 @@ static struct platform_device tmu1_device = {
        .num_resources  = ARRAY_SIZE(tmu1_resources),
 };
 
-static struct sh_timer_config tmu2_platform_data = {
-       .channel_offset = 0x1c,
-       .timer_bit = 2,
-};
-
-static struct resource tmu2_resources[] = {
-       [0] = {
-               .start  = 0xffd80020,
-               .end    = 0xffd8002f,
-               .flags  = IORESOURCE_MEM,
-       },
-       [1] = {
-               .start  = evt2irq(0x5c0),
-               .flags  = IORESOURCE_IRQ,
-       },
-};
-
-static struct platform_device tmu2_device = {
-       .name           = "sh_tmu",
-       .id             = 2,
-       .dev = {
-               .platform_data  = &tmu2_platform_data,
-       },
-       .resource       = tmu2_resources,
-       .num_resources  = ARRAY_SIZE(tmu2_resources),
-};
-
-static struct sh_timer_config tmu3_platform_data = {
-       .channel_offset = 0x04,
-       .timer_bit = 0,
-};
-
-static struct resource tmu3_resources[] = {
-       [0] = {
-               .start  = 0xffdc0008,
-               .end    = 0xffdc0013,
-               .flags  = IORESOURCE_MEM,
-       },
-       [1] = {
-               .start  = evt2irq(0xe00),
-               .flags  = IORESOURCE_IRQ,
-       },
-};
-
-static struct platform_device tmu3_device = {
-       .name           = "sh_tmu",
-       .id             = 3,
-       .dev = {
-               .platform_data  = &tmu3_platform_data,
-       },
-       .resource       = tmu3_resources,
-       .num_resources  = ARRAY_SIZE(tmu3_resources),
-};
-
-static struct sh_timer_config tmu4_platform_data = {
-       .channel_offset = 0x10,
-       .timer_bit = 1,
-};
-
-static struct resource tmu4_resources[] = {
-       [0] = {
-               .start  = 0xffdc0014,
-               .end    = 0xffdc001f,
-               .flags  = IORESOURCE_MEM,
-       },
-       [1] = {
-               .start  = evt2irq(0xe20),
-               .flags  = IORESOURCE_IRQ,
-       },
-};
-
-static struct platform_device tmu4_device = {
-       .name           = "sh_tmu",
-       .id             = 4,
-       .dev = {
-               .platform_data  = &tmu4_platform_data,
-       },
-       .resource       = tmu4_resources,
-       .num_resources  = ARRAY_SIZE(tmu4_resources),
-};
-
-static struct sh_timer_config tmu5_platform_data = {
-       .channel_offset = 0x1c,
-       .timer_bit = 2,
-};
-
-static struct resource tmu5_resources[] = {
-       [0] = {
-               .start  = 0xffdc0020,
-               .end    = 0xffdc002b,
-               .flags  = IORESOURCE_MEM,
-       },
-       [1] = {
-               .start  = evt2irq(0xe40),
-               .flags  = IORESOURCE_IRQ,
-       },
-};
-
-static struct platform_device tmu5_device = {
-       .name           = "sh_tmu",
-       .id             = 5,
-       .dev = {
-               .platform_data  = &tmu5_platform_data,
-       },
-       .resource       = tmu5_resources,
-       .num_resources  = ARRAY_SIZE(tmu5_resources),
-};
-
 static struct resource rtc_resources[] = {
        [0] = {
                .start  = 0xffe80000,
@@ -386,10 +264,6 @@ static struct platform_device *sh7780_devices[] __initdata = {
        &scif1_device,
        &tmu0_device,
        &tmu1_device,
-       &tmu2_device,
-       &tmu3_device,
-       &tmu4_device,
-       &tmu5_device,
        &rtc_device,
        &dma0_device,
        &dma1_device,
@@ -407,10 +281,6 @@ static struct platform_device *sh7780_early_devices[] __initdata = {
        &scif1_device,
        &tmu0_device,
        &tmu1_device,
-       &tmu2_device,
-       &tmu3_device,
-       &tmu4_device,
-       &tmu5_device,
 };
 
 void __init plat_early_device_setup(void)
index 4aa6791..c72d5a5 100644 (file)
@@ -152,25 +152,18 @@ static struct platform_device scif5_device = {
 };
 
 static struct sh_timer_config tmu0_platform_data = {
-       .channel_offset = 0x04,
-       .timer_bit = 0,
-       .clockevent_rating = 200,
+       .channels_mask = 7,
 };
 
 static struct resource tmu0_resources[] = {
-       [0] = {
-               .start  = 0xffd80008,
-               .end    = 0xffd80013,
-               .flags  = IORESOURCE_MEM,
-       },
-       [1] = {
-               .start  = evt2irq(0x580),
-               .flags  = IORESOURCE_IRQ,
-       },
+       DEFINE_RES_MEM(0xffd80000, 0x30),
+       DEFINE_RES_IRQ(evt2irq(0x580)),
+       DEFINE_RES_IRQ(evt2irq(0x5a0)),
+       DEFINE_RES_IRQ(evt2irq(0x5c0)),
 };
 
 static struct platform_device tmu0_device = {
-       .name           = "sh_tmu",
+       .name           = "sh-tmu",
        .id             = 0,
        .dev = {
                .platform_data  = &tmu0_platform_data,
@@ -180,25 +173,18 @@ static struct platform_device tmu0_device = {
 };
 
 static struct sh_timer_config tmu1_platform_data = {
-       .channel_offset = 0x10,
-       .timer_bit = 1,
-       .clocksource_rating = 200,
+       .channels_mask = 7,
 };
 
 static struct resource tmu1_resources[] = {
-       [0] = {
-               .start  = 0xffd80014,
-               .end    = 0xffd8001f,
-               .flags  = IORESOURCE_MEM,
-       },
-       [1] = {
-               .start  = evt2irq(0x5a0),
-               .flags  = IORESOURCE_IRQ,
-       },
+       DEFINE_RES_MEM(0xffdc0000, 0x2c),
+       DEFINE_RES_IRQ(evt2irq(0xe00)),
+       DEFINE_RES_IRQ(evt2irq(0xe20)),
+       DEFINE_RES_IRQ(evt2irq(0xe40)),
 };
 
 static struct platform_device tmu1_device = {
-       .name           = "sh_tmu",
+       .name           = "sh-tmu",
        .id             = 1,
        .dev = {
                .platform_data  = &tmu1_platform_data,
@@ -207,114 +193,6 @@ static struct platform_device tmu1_device = {
        .num_resources  = ARRAY_SIZE(tmu1_resources),
 };
 
-static struct sh_timer_config tmu2_platform_data = {
-       .channel_offset = 0x1c,
-       .timer_bit = 2,
-};
-
-static struct resource tmu2_resources[] = {
-       [0] = {
-               .start  = 0xffd80020,
-               .end    = 0xffd8002f,
-               .flags  = IORESOURCE_MEM,
-       },
-       [1] = {
-               .start  = evt2irq(0x5c0),
-               .flags  = IORESOURCE_IRQ,
-       },
-};
-
-static struct platform_device tmu2_device = {
-       .name           = "sh_tmu",
-       .id             = 2,
-       .dev = {
-               .platform_data  = &tmu2_platform_data,
-       },
-       .resource       = tmu2_resources,
-       .num_resources  = ARRAY_SIZE(tmu2_resources),
-};
-
-static struct sh_timer_config tmu3_platform_data = {
-       .channel_offset = 0x04,
-       .timer_bit = 0,
-};
-
-static struct resource tmu3_resources[] = {
-       [0] = {
-               .start  = 0xffdc0008,
-               .end    = 0xffdc0013,
-               .flags  = IORESOURCE_MEM,
-       },
-       [1] = {
-               .start  = evt2irq(0xe00),
-               .flags  = IORESOURCE_IRQ,
-       },
-};
-
-static struct platform_device tmu3_device = {
-       .name           = "sh_tmu",
-       .id             = 3,
-       .dev = {
-               .platform_data  = &tmu3_platform_data,
-       },
-       .resource       = tmu3_resources,
-       .num_resources  = ARRAY_SIZE(tmu3_resources),
-};
-
-static struct sh_timer_config tmu4_platform_data = {
-       .channel_offset = 0x10,
-       .timer_bit = 1,
-};
-
-static struct resource tmu4_resources[] = {
-       [0] = {
-               .start  = 0xffdc0014,
-               .end    = 0xffdc001f,
-               .flags  = IORESOURCE_MEM,
-       },
-       [1] = {
-               .start  = evt2irq(0xe20),
-               .flags  = IORESOURCE_IRQ,
-       },
-};
-
-static struct platform_device tmu4_device = {
-       .name           = "sh_tmu",
-       .id             = 4,
-       .dev = {
-               .platform_data  = &tmu4_platform_data,
-       },
-       .resource       = tmu4_resources,
-       .num_resources  = ARRAY_SIZE(tmu4_resources),
-};
-
-static struct sh_timer_config tmu5_platform_data = {
-       .channel_offset = 0x1c,
-       .timer_bit = 2,
-};
-
-static struct resource tmu5_resources[] = {
-       [0] = {
-               .start  = 0xffdc0020,
-               .end    = 0xffdc002b,
-               .flags  = IORESOURCE_MEM,
-       },
-       [1] = {
-               .start  = evt2irq(0xe40),
-               .flags  = IORESOURCE_IRQ,
-       },
-};
-
-static struct platform_device tmu5_device = {
-       .name           = "sh_tmu",
-       .id             = 5,
-       .dev = {
-               .platform_data  = &tmu5_platform_data,
-       },
-       .resource       = tmu5_resources,
-       .num_resources  = ARRAY_SIZE(tmu5_resources),
-};
-
 /* DMA */
 static const struct sh_dmae_channel sh7785_dmae0_channels[] = {
        {
@@ -460,10 +338,6 @@ static struct platform_device *sh7785_devices[] __initdata = {
        &scif5_device,
        &tmu0_device,
        &tmu1_device,
-       &tmu2_device,
-       &tmu3_device,
-       &tmu4_device,
-       &tmu5_device,
        &dma0_device,
        &dma1_device,
 };
@@ -484,10 +358,6 @@ static struct platform_device *sh7785_early_devices[] __initdata = {
        &scif5_device,
        &tmu0_device,
        &tmu1_device,
-       &tmu2_device,
-       &tmu3_device,
-       &tmu4_device,
-       &tmu5_device,
 };
 
 void __init plat_early_device_setup(void)
index 5d619a5..479e79b 100644 (file)
@@ -175,25 +175,18 @@ static struct platform_device scif5_device = {
 };
 
 static struct sh_timer_config tmu0_platform_data = {
-       .channel_offset = 0x04,
-       .timer_bit = 0,
-       .clockevent_rating = 200,
+       .channels_mask = 7,
 };
 
 static struct resource tmu0_resources[] = {
-       [0] = {
-               .start  = 0xffd80008,
-               .end    = 0xffd80013,
-               .flags  = IORESOURCE_MEM,
-       },
-       [1] = {
-               .start  = evt2irq(0x400),
-               .flags  = IORESOURCE_IRQ,
-       },
+       DEFINE_RES_MEM(0xffd80000, 0x30),
+       DEFINE_RES_IRQ(evt2irq(0x400)),
+       DEFINE_RES_IRQ(evt2irq(0x420)),
+       DEFINE_RES_IRQ(evt2irq(0x440)),
 };
 
 static struct platform_device tmu0_device = {
-       .name           = "sh_tmu",
+       .name           = "sh-tmu",
        .id             = 0,
        .dev = {
                .platform_data  = &tmu0_platform_data,
@@ -203,25 +196,18 @@ static struct platform_device tmu0_device = {
 };
 
 static struct sh_timer_config tmu1_platform_data = {
-       .channel_offset = 0x10,
-       .timer_bit = 1,
-       .clocksource_rating = 200,
+       .channels_mask = 7,
 };
 
 static struct resource tmu1_resources[] = {
-       [0] = {
-               .start  = 0xffd80014,
-               .end    = 0xffd8001f,
-               .flags  = IORESOURCE_MEM,
-       },
-       [1] = {
-               .start  = evt2irq(0x420),
-               .flags  = IORESOURCE_IRQ,
-       },
+       DEFINE_RES_MEM(0xffda0000, 0x2c),
+       DEFINE_RES_IRQ(evt2irq(0x480)),
+       DEFINE_RES_IRQ(evt2irq(0x4a0)),
+       DEFINE_RES_IRQ(evt2irq(0x4c0)),
 };
 
 static struct platform_device tmu1_device = {
-       .name           = "sh_tmu",
+       .name           = "sh-tmu",
        .id             = 1,
        .dev = {
                .platform_data  = &tmu1_platform_data,
@@ -231,24 +217,18 @@ static struct platform_device tmu1_device = {
 };
 
 static struct sh_timer_config tmu2_platform_data = {
-       .channel_offset = 0x1c,
-       .timer_bit = 2,
+       .channels_mask = 7,
 };
 
 static struct resource tmu2_resources[] = {
-       [0] = {
-               .start  = 0xffd80020,
-               .end    = 0xffd8002f,
-               .flags  = IORESOURCE_MEM,
-       },
-       [1] = {
-               .start  = evt2irq(0x440),
-               .flags  = IORESOURCE_IRQ,
-       },
+       DEFINE_RES_MEM(0xffdc0000, 0x2c),
+       DEFINE_RES_IRQ(evt2irq(0x7a0)),
+       DEFINE_RES_IRQ(evt2irq(0x7a0)),
+       DEFINE_RES_IRQ(evt2irq(0x7a0)),
 };
 
 static struct platform_device tmu2_device = {
-       .name           = "sh_tmu",
+       .name           = "sh-tmu",
        .id             = 2,
        .dev = {
                .platform_data  = &tmu2_platform_data,
@@ -258,24 +238,18 @@ static struct platform_device tmu2_device = {
 };
 
 static struct sh_timer_config tmu3_platform_data = {
-       .channel_offset = 0x04,
-       .timer_bit = 0,
+       .channels_mask = 7,
 };
 
 static struct resource tmu3_resources[] = {
-       [0] = {
-               .start  = 0xffda0008,
-               .end    = 0xffda0013,
-               .flags  = IORESOURCE_MEM,
-       },
-       [1] = {
-               .start  = evt2irq(0x480),
-               .flags  = IORESOURCE_IRQ,
-       },
+       DEFINE_RES_MEM(0xffde0000, 0x2c),
+       DEFINE_RES_IRQ(evt2irq(0x7c0)),
+       DEFINE_RES_IRQ(evt2irq(0x7c0)),
+       DEFINE_RES_IRQ(evt2irq(0x7c0)),
 };
 
 static struct platform_device tmu3_device = {
-       .name           = "sh_tmu",
+       .name           = "sh-tmu",
        .id             = 3,
        .dev = {
                .platform_data  = &tmu3_platform_data,
@@ -284,222 +258,6 @@ static struct platform_device tmu3_device = {
        .num_resources  = ARRAY_SIZE(tmu3_resources),
 };
 
-static struct sh_timer_config tmu4_platform_data = {
-       .channel_offset = 0x10,
-       .timer_bit = 1,
-};
-
-static struct resource tmu4_resources[] = {
-       [0] = {
-               .start  = 0xffda0014,
-               .end    = 0xffda001f,
-               .flags  = IORESOURCE_MEM,
-       },
-       [1] = {
-               .start  = evt2irq(0x4a0),
-               .flags  = IORESOURCE_IRQ,
-       },
-};
-
-static struct platform_device tmu4_device = {
-       .name           = "sh_tmu",
-       .id             = 4,
-       .dev = {
-               .platform_data  = &tmu4_platform_data,
-       },
-       .resource       = tmu4_resources,
-       .num_resources  = ARRAY_SIZE(tmu4_resources),
-};
-
-static struct sh_timer_config tmu5_platform_data = {
-       .channel_offset = 0x1c,
-       .timer_bit = 2,
-};
-
-static struct resource tmu5_resources[] = {
-       [0] = {
-               .start  = 0xffda0020,
-               .end    = 0xffda002b,
-               .flags  = IORESOURCE_MEM,
-       },
-       [1] = {
-               .start  = evt2irq(0x4c0),
-               .flags  = IORESOURCE_IRQ,
-       },
-};
-
-static struct platform_device tmu5_device = {
-       .name           = "sh_tmu",
-       .id             = 5,
-       .dev = {
-               .platform_data  = &tmu5_platform_data,
-       },
-       .resource       = tmu5_resources,
-       .num_resources  = ARRAY_SIZE(tmu5_resources),
-};
-
-static struct sh_timer_config tmu6_platform_data = {
-       .channel_offset = 0x04,
-       .timer_bit = 0,
-};
-
-static struct resource tmu6_resources[] = {
-       [0] = {
-               .start  = 0xffdc0008,
-               .end    = 0xffdc0013,
-               .flags  = IORESOURCE_MEM,
-       },
-       [1] = {
-               .start  = evt2irq(0x7a0),
-               .flags  = IORESOURCE_IRQ,
-       },
-};
-
-static struct platform_device tmu6_device = {
-       .name           = "sh_tmu",
-       .id             = 6,
-       .dev = {
-               .platform_data  = &tmu6_platform_data,
-       },
-       .resource       = tmu6_resources,
-       .num_resources  = ARRAY_SIZE(tmu6_resources),
-};
-
-static struct sh_timer_config tmu7_platform_data = {
-       .channel_offset = 0x10,
-       .timer_bit = 1,
-};
-
-static struct resource tmu7_resources[] = {
-       [0] = {
-               .start  = 0xffdc0014,
-               .end    = 0xffdc001f,
-               .flags  = IORESOURCE_MEM,
-       },
-       [1] = {
-               .start  = evt2irq(0x7a0),
-               .flags  = IORESOURCE_IRQ,
-       },
-};
-
-static struct platform_device tmu7_device = {
-       .name           = "sh_tmu",
-       .id             = 7,
-       .dev = {
-               .platform_data  = &tmu7_platform_data,
-       },
-       .resource       = tmu7_resources,
-       .num_resources  = ARRAY_SIZE(tmu7_resources),
-};
-
-static struct sh_timer_config tmu8_platform_data = {
-       .channel_offset = 0x1c,
-       .timer_bit = 2,
-};
-
-static struct resource tmu8_resources[] = {
-       [0] = {
-               .start  = 0xffdc0020,
-               .end    = 0xffdc002b,
-               .flags  = IORESOURCE_MEM,
-       },
-       [1] = {
-               .start  = evt2irq(0x7a0),
-               .flags  = IORESOURCE_IRQ,
-       },
-};
-
-static struct platform_device tmu8_device = {
-       .name           = "sh_tmu",
-       .id             = 8,
-       .dev = {
-               .platform_data  = &tmu8_platform_data,
-       },
-       .resource       = tmu8_resources,
-       .num_resources  = ARRAY_SIZE(tmu8_resources),
-};
-
-static struct sh_timer_config tmu9_platform_data = {
-       .channel_offset = 0x04,
-       .timer_bit = 0,
-};
-
-static struct resource tmu9_resources[] = {
-       [0] = {
-               .start  = 0xffde0008,
-               .end    = 0xffde0013,
-               .flags  = IORESOURCE_MEM,
-       },
-       [1] = {
-               .start  = evt2irq(0x7c0),
-               .flags  = IORESOURCE_IRQ,
-       },
-};
-
-static struct platform_device tmu9_device = {
-       .name           = "sh_tmu",
-       .id             = 9,
-       .dev = {
-               .platform_data  = &tmu9_platform_data,
-       },
-       .resource       = tmu9_resources,
-       .num_resources  = ARRAY_SIZE(tmu9_resources),
-};
-
-static struct sh_timer_config tmu10_platform_data = {
-       .channel_offset = 0x10,
-       .timer_bit = 1,
-};
-
-static struct resource tmu10_resources[] = {
-       [0] = {
-               .start  = 0xffde0014,
-               .end    = 0xffde001f,
-               .flags  = IORESOURCE_MEM,
-       },
-       [1] = {
-               .start  = evt2irq(0x7c0),
-               .flags  = IORESOURCE_IRQ,
-       },
-};
-
-static struct platform_device tmu10_device = {
-       .name           = "sh_tmu",
-       .id             = 10,
-       .dev = {
-               .platform_data  = &tmu10_platform_data,
-       },
-       .resource       = tmu10_resources,
-       .num_resources  = ARRAY_SIZE(tmu10_resources),
-};
-
-static struct sh_timer_config tmu11_platform_data = {
-       .channel_offset = 0x1c,
-       .timer_bit = 2,
-};
-
-static struct resource tmu11_resources[] = {
-       [0] = {
-               .start  = 0xffde0020,
-               .end    = 0xffde002b,
-               .flags  = IORESOURCE_MEM,
-       },
-       [1] = {
-               .start  = evt2irq(0x7c0),
-               .flags  = IORESOURCE_IRQ,
-       },
-};
-
-static struct platform_device tmu11_device = {
-       .name           = "sh_tmu",
-       .id             = 11,
-       .dev = {
-               .platform_data  = &tmu11_platform_data,
-       },
-       .resource       = tmu11_resources,
-       .num_resources  = ARRAY_SIZE(tmu11_resources),
-};
-
 static const struct sh_dmae_channel dmac0_channels[] = {
        {
                .offset = 0,
@@ -641,15 +399,6 @@ static struct platform_device *sh7786_early_devices[] __initdata = {
        &tmu0_device,
        &tmu1_device,
        &tmu2_device,
-       &tmu3_device,
-       &tmu4_device,
-       &tmu5_device,
-       &tmu6_device,
-       &tmu7_device,
-       &tmu8_device,
-       &tmu9_device,
-       &tmu10_device,
-       &tmu11_device,
 };
 
 static struct platform_device *sh7786_devices[] __initdata = {
index 0856bcb..a78c5fe 100644 (file)
@@ -100,25 +100,18 @@ static struct platform_device scif2_device = {
 };
 
 static struct sh_timer_config tmu0_platform_data = {
-       .channel_offset = 0x04,
-       .timer_bit = 0,
-       .clockevent_rating = 200,
+       .channels_mask = 7,
 };
 
 static struct resource tmu0_resources[] = {
-       [0] = {
-               .start  = 0xffc10008,
-               .end    = 0xffc10013,
-               .flags  = IORESOURCE_MEM,
-       },
-       [1] = {
-               .start  = evt2irq(0x400),
-               .flags  = IORESOURCE_IRQ,
-       },
+       DEFINE_RES_MEM(0xffc10000, 0x30),
+       DEFINE_RES_IRQ(evt2irq(0x400)),
+       DEFINE_RES_IRQ(evt2irq(0x420)),
+       DEFINE_RES_IRQ(evt2irq(0x440)),
 };
 
 static struct platform_device tmu0_device = {
-       .name           = "sh_tmu",
+       .name           = "sh-tmu",
        .id             = 0,
        .dev = {
                .platform_data  = &tmu0_platform_data,
@@ -128,25 +121,18 @@ static struct platform_device tmu0_device = {
 };
 
 static struct sh_timer_config tmu1_platform_data = {
-       .channel_offset = 0x10,
-       .timer_bit = 1,
-       .clocksource_rating = 200,
+       .channels_mask = 7,
 };
 
 static struct resource tmu1_resources[] = {
-       [0] = {
-               .start  = 0xffc10014,
-               .end    = 0xffc1001f,
-               .flags  = IORESOURCE_MEM,
-       },
-       [1] = {
-               .start  = evt2irq(0x420),
-               .flags  = IORESOURCE_IRQ,
-       },
+       DEFINE_RES_MEM(0xffc20000, 0x2c),
+       DEFINE_RES_IRQ(evt2irq(0x460)),
+       DEFINE_RES_IRQ(evt2irq(0x480)),
+       DEFINE_RES_IRQ(evt2irq(0x4a0)),
 };
 
 static struct platform_device tmu1_device = {
-       .name           = "sh_tmu",
+       .name           = "sh-tmu",
        .id             = 1,
        .dev = {
                .platform_data  = &tmu1_platform_data,
@@ -155,124 +141,12 @@ static struct platform_device tmu1_device = {
        .num_resources  = ARRAY_SIZE(tmu1_resources),
 };
 
-static struct sh_timer_config tmu2_platform_data = {
-       .channel_offset = 0x1c,
-       .timer_bit = 2,
-};
-
-static struct resource tmu2_resources[] = {
-       [0] = {
-               .start  = 0xffc10020,
-               .end    = 0xffc1002f,
-               .flags  = IORESOURCE_MEM,
-       },
-       [1] = {
-               .start  = evt2irq(0x440),
-               .flags  = IORESOURCE_IRQ,
-       },
-};
-
-static struct platform_device tmu2_device = {
-       .name           = "sh_tmu",
-       .id             = 2,
-       .dev = {
-               .platform_data  = &tmu2_platform_data,
-       },
-       .resource       = tmu2_resources,
-       .num_resources  = ARRAY_SIZE(tmu2_resources),
-};
-
-static struct sh_timer_config tmu3_platform_data = {
-       .channel_offset = 0x04,
-       .timer_bit = 0,
-};
-
-static struct resource tmu3_resources[] = {
-       [0] = {
-               .start  = 0xffc20008,
-               .end    = 0xffc20013,
-               .flags  = IORESOURCE_MEM,
-       },
-       [1] = {
-               .start  = evt2irq(0x460),
-               .flags  = IORESOURCE_IRQ,
-       },
-};
-
-static struct platform_device tmu3_device = {
-       .name           = "sh_tmu",
-       .id             = 3,
-       .dev = {
-               .platform_data  = &tmu3_platform_data,
-       },
-       .resource       = tmu3_resources,
-       .num_resources  = ARRAY_SIZE(tmu3_resources),
-};
-
-static struct sh_timer_config tmu4_platform_data = {
-       .channel_offset = 0x10,
-       .timer_bit = 1,
-};
-
-static struct resource tmu4_resources[] = {
-       [0] = {
-               .start  = 0xffc20014,
-               .end    = 0xffc2001f,
-               .flags  = IORESOURCE_MEM,
-       },
-       [1] = {
-               .start  = evt2irq(0x480),
-               .flags  = IORESOURCE_IRQ,
-       },
-};
-
-static struct platform_device tmu4_device = {
-       .name           = "sh_tmu",
-       .id             = 4,
-       .dev = {
-               .platform_data  = &tmu4_platform_data,
-       },
-       .resource       = tmu4_resources,
-       .num_resources  = ARRAY_SIZE(tmu4_resources),
-};
-
-static struct sh_timer_config tmu5_platform_data = {
-       .channel_offset = 0x1c,
-       .timer_bit = 2,
-};
-
-static struct resource tmu5_resources[] = {
-       [0] = {
-               .start  = 0xffc20020,
-               .end    = 0xffc2002b,
-               .flags  = IORESOURCE_MEM,
-       },
-       [1] = {
-               .start  = evt2irq(0x4a0),
-               .flags  = IORESOURCE_IRQ,
-       },
-};
-
-static struct platform_device tmu5_device = {
-       .name           = "sh_tmu",
-       .id             = 5,
-       .dev = {
-               .platform_data  = &tmu5_platform_data,
-       },
-       .resource       = tmu5_resources,
-       .num_resources  = ARRAY_SIZE(tmu5_resources),
-};
-
 static struct platform_device *shx3_early_devices[] __initdata = {
        &scif0_device,
        &scif1_device,
        &scif2_device,
        &tmu0_device,
        &tmu1_device,
-       &tmu2_device,
-       &tmu3_device,
-       &tmu4_device,
-       &tmu5_device,
 };
 
 static int __init shx3_devices_setup(void)
index 14d6821..1bf0b2c 100644 (file)
@@ -71,30 +71,20 @@ static struct platform_device rtc_device = {
 
 #define        TMU_BLOCK_OFF   0x01020000
 #define TMU_BASE       PHYS_PERIPHERAL_BLOCK + TMU_BLOCK_OFF
-#define TMU0_BASE      (TMU_BASE + 0x8 + (0xc * 0x0))
-#define TMU1_BASE      (TMU_BASE + 0x8 + (0xc * 0x1))
-#define TMU2_BASE      (TMU_BASE + 0x8 + (0xc * 0x2))
 
 static struct sh_timer_config tmu0_platform_data = {
-       .channel_offset = 0x04,
-       .timer_bit = 0,
-       .clockevent_rating = 200,
+       .channels_mask = 7,
 };
 
 static struct resource tmu0_resources[] = {
-       [0] = {
-               .start  = TMU0_BASE,
-               .end    = TMU0_BASE + 0xc - 1,
-               .flags  = IORESOURCE_MEM,
-       },
-       [1] = {
-               .start  = IRQ_TUNI0,
-               .flags  = IORESOURCE_IRQ,
-       },
+       DEFINE_RES_MEM(TMU_BASE, 0x30),
+       DEFINE_RES_IRQ(IRQ_TUNI0),
+       DEFINE_RES_IRQ(IRQ_TUNI1),
+       DEFINE_RES_IRQ(IRQ_TUNI2),
 };
 
 static struct platform_device tmu0_device = {
-       .name           = "sh_tmu",
+       .name           = "sh-tmu",
        .id             = 0,
        .dev = {
                .platform_data  = &tmu0_platform_data,
@@ -103,66 +93,9 @@ static struct platform_device tmu0_device = {
        .num_resources  = ARRAY_SIZE(tmu0_resources),
 };
 
-static struct sh_timer_config tmu1_platform_data = {
-       .channel_offset = 0x10,
-       .timer_bit = 1,
-       .clocksource_rating = 200,
-};
-
-static struct resource tmu1_resources[] = {
-       [0] = {
-               .start  = TMU1_BASE,
-               .end    = TMU1_BASE + 0xc - 1,
-               .flags  = IORESOURCE_MEM,
-       },
-       [1] = {
-               .start  = IRQ_TUNI1,
-               .flags  = IORESOURCE_IRQ,
-       },
-};
-
-static struct platform_device tmu1_device = {
-       .name           = "sh_tmu",
-       .id             = 1,
-       .dev = {
-               .platform_data  = &tmu1_platform_data,
-       },
-       .resource       = tmu1_resources,
-       .num_resources  = ARRAY_SIZE(tmu1_resources),
-};
-
-static struct sh_timer_config tmu2_platform_data = {
-       .channel_offset = 0x1c,
-       .timer_bit = 2,
-};
-
-static struct resource tmu2_resources[] = {
-       [0] = {
-               .start  = TMU2_BASE,
-               .end    = TMU2_BASE + 0xc - 1,
-               .flags  = IORESOURCE_MEM,
-       },
-       [1] = {
-               .start  = IRQ_TUNI2,
-               .flags  = IORESOURCE_IRQ,
-       },
-};
-
-static struct platform_device tmu2_device = {
-       .name           = "sh_tmu",
-       .id             = 2,
-       .dev = {
-               .platform_data  = &tmu2_platform_data,
-       },
-       .resource       = tmu2_resources,
-       .num_resources  = ARRAY_SIZE(tmu2_resources),
-};
-
 static struct platform_device *sh5_early_devices[] __initdata = {
        &scif0_device,
        &tmu0_device,
-       &tmu1_device,
-       &tmu2_device,
 };
 
 static struct platform_device *sh5_devices[] __initdata = {
index c0a9761..f8ce362 100644 (file)
@@ -22,7 +22,7 @@
 
 #define TRAPPED_PAGES_MAX 16
 
-#ifdef CONFIG_HAS_IOPORT
+#ifdef CONFIG_HAS_IOPORT_MAP
 LIST_HEAD(trapped_io);
 EXPORT_SYMBOL_GPL(trapped_io);
 #endif
@@ -90,7 +90,7 @@ int register_trapped_io(struct trapped_io *tiop)
        tiop->magic = IO_TRAPPED_MAGIC;
        INIT_LIST_HEAD(&tiop->list);
        spin_lock_irq(&trapped_lock);
-#ifdef CONFIG_HAS_IOPORT
+#ifdef CONFIG_HAS_IOPORT_MAP
        if (flags & IORESOURCE_IO)
                list_add(&tiop->list, &trapped_io);
 #endif
index c3d82b5..b397e05 100644 (file)
@@ -659,8 +659,7 @@ static int sparc64_cpufreq_notifier(struct notifier_block *nb, unsigned long val
                ft->clock_tick_ref = cpu_data(cpu).clock_tick;
        }
        if ((val == CPUFREQ_PRECHANGE  && freq->old < freq->new) ||
-           (val == CPUFREQ_POSTCHANGE && freq->old > freq->new) ||
-           (val == CPUFREQ_RESUMECHANGE)) {
+           (val == CPUFREQ_POSTCHANGE && freq->old > freq->new)) {
                cpu_data(cpu).clock_tick =
                        cpufreq_scale(ft->clock_tick_ref,
                                      ft->ref_freq,
index b3692ce..0b0290e 100644 (file)
@@ -405,7 +405,7 @@ config PCI_DOMAINS
 config NO_IOMEM
        def_bool !PCI
 
-config NO_IOPORT
+config NO_IOPORT_MAP
        def_bool !PCI
 
 config TILE_PCI_IO
index 25c0dba..aafad6f 100644 (file)
@@ -27,7 +27,7 @@ config UNICORE32
 config GENERIC_CSUM
        def_bool y
 
-config NO_IOPORT
+config NO_IOPORT_MAP
        bool
 
 config STACKTRACE_SUPPORT
index c9dd319..45f47f8 100644 (file)
@@ -149,7 +149,6 @@ CONFIG_SND_PCM_OSS=m
 #      USB support
 CONFIG_USB_ARCH_HAS_HCD=n
 CONFIG_USB=n
-CONFIG_USB_DEVICEFS=n
 CONFIG_USB_PRINTER=n
 CONFIG_USB_STORAGE=n
 #      Inventra Highspeed Dual Role Controller
index de02906..3594fea 100644 (file)
@@ -914,8 +914,7 @@ static int time_cpufreq_notifier(struct notifier_block *nb, unsigned long val,
                tsc_khz_ref = tsc_khz;
        }
        if ((val == CPUFREQ_PRECHANGE  && freq->old < freq->new) ||
-                       (val == CPUFREQ_POSTCHANGE && freq->old > freq->new) ||
-                       (val == CPUFREQ_RESUMECHANGE)) {
+                       (val == CPUFREQ_POSTCHANGE && freq->old > freq->new)) {
                *lpj = cpufreq_scale(loops_per_jiffy_ref, ref_freq, freq->new);
 
                tsc_khz = cpufreq_scale(tsc_khz_ref, ref_freq, freq->new);
index c87ae7c..02d6d29 100644 (file)
@@ -41,7 +41,7 @@ config ARCH_HAS_ILOG2_U32
 config ARCH_HAS_ILOG2_U64
        def_bool n
 
-config NO_IOPORT
+config NO_IOPORT_MAP
        def_bool n
 
 config HZ
@@ -239,7 +239,7 @@ config XTENSA_PLATFORM_XT2000
 config XTENSA_PLATFORM_S6105
        bool "S6105"
        select SERIAL_CONSOLE
-       select NO_IOPORT
+       select NO_IOPORT_MAP
 
 config XTENSA_PLATFORM_XTFPGA
        bool "XTFPGA"
index 4f23320..d57d917 100644 (file)
@@ -11,7 +11,7 @@ CONFIG_GENERIC_FIND_NEXT_BIT=y
 CONFIG_GENERIC_HWEIGHT=y
 # CONFIG_ARCH_HAS_ILOG2_U32 is not set
 # CONFIG_ARCH_HAS_ILOG2_U64 is not set
-CONFIG_NO_IOPORT=y
+CONFIG_NO_IOPORT_MAP=y
 CONFIG_HZ=100
 CONFIG_DEFCONFIG_LIST="/lib/modules/$UNAME_RELEASE/.config"
 CONFIG_CONSTRUCTORS=y
index d929f77..583c2b0 100644 (file)
@@ -11,7 +11,7 @@ CONFIG_GENERIC_FIND_NEXT_BIT=y
 CONFIG_GENERIC_HWEIGHT=y
 # CONFIG_ARCH_HAS_ILOG2_U32 is not set
 # CONFIG_ARCH_HAS_ILOG2_U64 is not set
-CONFIG_NO_IOPORT=y
+CONFIG_NO_IOPORT_MAP=y
 CONFIG_HZ=100
 CONFIG_DEFCONFIG_LIST="/lib/modules/$UNAME_RELEASE/.config"
 
index 84fe931..555f75c 100644 (file)
@@ -221,7 +221,7 @@ static int __init xtensa_dt_io_area(unsigned long node, const char *uname,
                int depth, void *data)
 {
        const __be32 *ranges;
-       unsigned long len;
+       int len;
 
        if (depth > 1)
                return 0;
index 8e3b8b0..3cc8214 100644 (file)
@@ -118,7 +118,7 @@ obj-$(CONFIG_SGI_SN)                += sn/
 obj-y                          += firmware/
 obj-$(CONFIG_CRYPTO)           += crypto/
 obj-$(CONFIG_SUPERH)           += sh/
-obj-$(CONFIG_ARCH_SHMOBILE_LEGACY)     += sh/
+obj-$(CONFIG_ARCH_SHMOBILE)    += sh/
 ifndef CONFIG_ARCH_USES_GETTIMEOFFSET
 obj-y                          += clocksource/
 endif
index fd665d9..f0f050b 100644 (file)
@@ -78,7 +78,7 @@ static bool acard_ahci_qc_fill_rtf(struct ata_queued_cmd *qc);
 static int acard_ahci_port_start(struct ata_port *ap);
 static int acard_ahci_init_one(struct pci_dev *pdev, const struct pci_device_id *ent);
 
-#ifdef CONFIG_PM
+#ifdef CONFIG_PM_SLEEP
 static int acard_ahci_pci_device_suspend(struct pci_dev *pdev, pm_message_t mesg);
 static int acard_ahci_pci_device_resume(struct pci_dev *pdev);
 #endif
@@ -119,13 +119,13 @@ static struct pci_driver acard_ahci_pci_driver = {
        .id_table               = acard_ahci_pci_tbl,
        .probe                  = acard_ahci_init_one,
        .remove                 = ata_pci_remove_one,
-#ifdef CONFIG_PM
+#ifdef CONFIG_PM_SLEEP
        .suspend                = acard_ahci_pci_device_suspend,
        .resume                 = acard_ahci_pci_device_resume,
 #endif
 };
 
-#ifdef CONFIG_PM
+#ifdef CONFIG_PM_SLEEP
 static int acard_ahci_pci_device_suspend(struct pci_dev *pdev, pm_message_t mesg)
 {
        struct ata_host *host = pci_get_drvdata(pdev);
index 7d19665..f99b01c 100644 (file)
@@ -242,7 +242,7 @@ static struct pci_driver ata_generic_pci_driver = {
        .id_table       = ata_generic,
        .probe          = ata_generic_init_one,
        .remove         = ata_pci_remove_one,
-#ifdef CONFIG_PM
+#ifdef CONFIG_PM_SLEEP
        .suspend        = ata_pci_device_suspend,
        .resume         = ata_pci_device_resume,
 #endif
index 39f76b9..ffbe625 100644 (file)
@@ -838,7 +838,7 @@ static bool piix_irq_check(struct ata_port *ap)
        return ap->ops->bmdma_status(ap) & ATA_DMA_INTR;
 }
 
-#ifdef CONFIG_PM
+#ifdef CONFIG_PM_SLEEP
 static int piix_broken_suspend(void)
 {
        static const struct dmi_system_id sysids[] = {
@@ -1775,7 +1775,7 @@ static struct pci_driver piix_pci_driver = {
        .id_table               = piix_pci_tbl,
        .probe                  = piix_init_one,
        .remove                 = piix_remove_one,
-#ifdef CONFIG_PM
+#ifdef CONFIG_PM_SLEEP
        .suspend                = piix_pci_device_suspend,
        .resume                 = piix_pci_device_resume,
 #endif
index 62c9ac8..5446d40 100644 (file)
@@ -266,7 +266,7 @@ static struct pci_driver pacpi_pci_driver = {
        .id_table               = pacpi_pci_tbl,
        .probe                  = pacpi_init_one,
        .remove                 = ata_pci_remove_one,
-#ifdef CONFIG_PM
+#ifdef CONFIG_PM_SLEEP
        .suspend                = ata_pci_device_suspend,
        .resume                 = ata_pci_device_resume,
 #endif
index 1b7b2cc..d19cd88 100644 (file)
@@ -589,7 +589,7 @@ static int ali_init_one(struct pci_dev *pdev, const struct pci_device_id *id)
                return ata_pci_bmdma_init_one(pdev, ppi, &ali_sht, NULL, 0);
 }
 
-#ifdef CONFIG_PM
+#ifdef CONFIG_PM_SLEEP
 static int ali_reinit_one(struct pci_dev *pdev)
 {
        struct ata_host *host = pci_get_drvdata(pdev);
@@ -616,7 +616,7 @@ static struct pci_driver ali_pci_driver = {
        .id_table       = ali,
        .probe          = ali_init_one,
        .remove         = ata_pci_remove_one,
-#ifdef CONFIG_PM
+#ifdef CONFIG_PM_SLEEP
        .suspend        = ata_pci_device_suspend,
        .resume         = ali_reinit_one,
 #endif
index d23e2b3..db10e6c 100644 (file)
@@ -575,7 +575,7 @@ static int amd_init_one(struct pci_dev *pdev, const struct pci_device_id *id)
        return ata_pci_bmdma_init_one(pdev, ppi, &amd_sht, hpriv, 0);
 }
 
-#ifdef CONFIG_PM
+#ifdef CONFIG_PM_SLEEP
 static int amd_reinit_one(struct pci_dev *pdev)
 {
        struct ata_host *host = pci_get_drvdata(pdev);
@@ -626,7 +626,7 @@ static struct pci_driver amd_pci_driver = {
        .id_table       = amd,
        .probe          = amd_init_one,
        .remove         = ata_pci_remove_one,
-#ifdef CONFIG_PM
+#ifdef CONFIG_PM_SLEEP
        .suspend        = ata_pci_device_suspend,
        .resume         = amd_reinit_one,
 #endif
index 1581dee..7a89aca 100644 (file)
@@ -423,7 +423,7 @@ static const struct pci_device_id artop_pci_tbl[] = {
        { }     /* terminate list */
 };
 
-#ifdef CONFIG_PM
+#ifdef CONFIG_PM_SLEEP
 static int atp8xx_reinit_one(struct pci_dev *pdev)
 {
        struct ata_host *host = pci_get_drvdata(pdev);
@@ -445,7 +445,7 @@ static struct pci_driver artop_pci_driver = {
        .id_table               = artop_pci_tbl,
        .probe                  = artop_init_one,
        .remove                 = ata_pci_remove_one,
-#ifdef CONFIG_PM
+#ifdef CONFIG_PM_SLEEP
        .suspend                = ata_pci_device_suspend,
        .resume                 = atp8xx_reinit_one,
 #endif
index 24e5105..5cf40f4 100644 (file)
@@ -299,7 +299,7 @@ static struct pci_driver atiixp_pci_driver = {
        .id_table       = atiixp,
        .probe          = atiixp_init_one,
        .remove         = ata_pci_remove_one,
-#ifdef CONFIG_PM
+#ifdef CONFIG_PM_SLEEP
        .resume         = ata_pci_device_resume,
        .suspend        = ata_pci_device_suspend,
 #endif
index 2ca5026..755db9e 100644 (file)
@@ -531,7 +531,7 @@ err_out:
        return rc;
 }
 
-#ifdef CONFIG_PM
+#ifdef CONFIG_PM_SLEEP
 static int atp867x_reinit_one(struct pci_dev *pdev)
 {
        struct ata_host *host = pci_get_drvdata(pdev);
@@ -559,7 +559,7 @@ static struct pci_driver atp867x_driver = {
        .id_table       = atp867x_pci_tbl,
        .probe          = atp867x_init_one,
        .remove         = ata_pci_remove_one,
-#ifdef CONFIG_PM
+#ifdef CONFIG_PM_SLEEP
        .suspend        = ata_pci_device_suspend,
        .resume         = atp867x_reinit_one,
 #endif
index ba0d8a2..03f2f2b 100644 (file)
@@ -1619,7 +1619,7 @@ static int bfin_atapi_remove(struct platform_device *pdev)
        return 0;
 }
 
-#ifdef CONFIG_PM
+#ifdef CONFIG_PM_SLEEP
 static int bfin_atapi_suspend(struct platform_device *pdev, pm_message_t state)
 {
        struct ata_host *host = platform_get_drvdata(pdev);
index 8fb69e5..f003359 100644 (file)
@@ -232,7 +232,7 @@ static int cmd640_init_one(struct pci_dev *pdev, const struct pci_device_id *id)
        return ata_pci_sff_init_one(pdev, ppi, &cmd640_sht, NULL, 0);
 }
 
-#ifdef CONFIG_PM
+#ifdef CONFIG_PM_SLEEP
 static int cmd640_reinit_one(struct pci_dev *pdev)
 {
        struct ata_host *host = pci_get_drvdata(pdev);
@@ -257,7 +257,7 @@ static struct pci_driver cmd640_pci_driver = {
        .id_table       = cmd640,
        .probe          = cmd640_init_one,
        .remove         = ata_pci_remove_one,
-#ifdef CONFIG_PM
+#ifdef CONFIG_PM_SLEEP
        .suspend        = ata_pci_device_suspend,
        .resume         = cmd640_reinit_one,
 #endif
index 1275a8d..da6fc05 100644 (file)
@@ -488,7 +488,7 @@ static int cmd64x_init_one(struct pci_dev *pdev, const struct pci_device_id *id)
        return ata_pci_bmdma_init_one(pdev, ppi, &cmd64x_sht, NULL, 0);
 }
 
-#ifdef CONFIG_PM
+#ifdef CONFIG_PM_SLEEP
 static int cmd64x_reinit_one(struct pci_dev *pdev)
 {
        struct ata_host *host = pci_get_drvdata(pdev);
@@ -519,7 +519,7 @@ static struct pci_driver cmd64x_pci_driver = {
        .id_table       = cmd64x,
        .probe          = cmd64x_init_one,
        .remove         = ata_pci_remove_one,
-#ifdef CONFIG_PM
+#ifdef CONFIG_PM_SLEEP
        .suspend        = ata_pci_device_suspend,
        .resume         = cmd64x_reinit_one,
 #endif
index f10baab..c6115be 100644 (file)
@@ -230,7 +230,7 @@ static int cs5520_init_one(struct pci_dev *pdev, const struct pci_device_id *id)
        return ata_host_register(host, &cs5520_sht);
 }
 
-#ifdef CONFIG_PM
+#ifdef CONFIG_PM_SLEEP
 /**
  *     cs5520_reinit_one       -       device resume
  *     @pdev: PCI device
@@ -279,7 +279,7 @@ static int cs5520_pci_device_suspend(struct pci_dev *pdev, pm_message_t mesg)
        pci_save_state(pdev);
        return 0;
 }
-#endif /* CONFIG_PM */
+#endif /* CONFIG_PM_SLEEP */
 
 /* For now keep DMA off. We can set it for all but A rev CS5510 once the
    core ATA code can handle it */
@@ -296,7 +296,7 @@ static struct pci_driver cs5520_pci_driver = {
        .id_table       = pata_cs5520,
        .probe          = cs5520_init_one,
        .remove         = ata_pci_remove_one,
-#ifdef CONFIG_PM
+#ifdef CONFIG_PM_SLEEP
        .suspend        = cs5520_pci_device_suspend,
        .resume         = cs5520_reinit_one,
 #endif
index f07f229..054b599 100644 (file)
@@ -327,7 +327,7 @@ static int cs5530_init_one(struct pci_dev *pdev, const struct pci_device_id *id)
        return ata_pci_bmdma_init_one(pdev, ppi, &cs5530_sht, NULL, 0);
 }
 
-#ifdef CONFIG_PM
+#ifdef CONFIG_PM_SLEEP
 static int cs5530_reinit_one(struct pci_dev *pdev)
 {
        struct ata_host *host = pci_get_drvdata(pdev);
@@ -344,7 +344,7 @@ static int cs5530_reinit_one(struct pci_dev *pdev)
        ata_host_resume(host);
        return 0;
 }
-#endif /* CONFIG_PM */
+#endif /* CONFIG_PM_SLEEP */
 
 static const struct pci_device_id cs5530[] = {
        { PCI_VDEVICE(CYRIX, PCI_DEVICE_ID_CYRIX_5530_IDE), },
@@ -357,7 +357,7 @@ static struct pci_driver cs5530_pci_driver = {
        .id_table       = cs5530,
        .probe          = cs5530_init_one,
        .remove         = ata_pci_remove_one,
-#ifdef CONFIG_PM
+#ifdef CONFIG_PM_SLEEP
        .suspend        = ata_pci_device_suspend,
        .resume         = cs5530_reinit_one,
 #endif
index 997e16a..d4c7b23 100644 (file)
@@ -201,7 +201,7 @@ static struct pci_driver cs5535_pci_driver = {
        .id_table       = cs5535,
        .probe          = cs5535_init_one,
        .remove         = ata_pci_remove_one,
-#ifdef CONFIG_PM
+#ifdef CONFIG_PM_SLEEP
        .suspend        = ata_pci_device_suspend,
        .resume         = ata_pci_device_resume,
 #endif
index 0448860..dc25369 100644 (file)
@@ -298,7 +298,7 @@ static struct pci_driver cs5536_pci_driver = {
        .id_table       = cs5536,
        .probe          = cs5536_init_one,
        .remove         = ata_pci_remove_one,
-#ifdef CONFIG_PM
+#ifdef CONFIG_PM_SLEEP
        .suspend        = ata_pci_device_suspend,
        .resume         = ata_pci_device_resume,
 #endif
index 810bc99..dee7ea0 100644 (file)
@@ -152,7 +152,7 @@ static struct pci_driver cy82c693_pci_driver = {
        .id_table       = cy82c693,
        .probe          = cy82c693_init_one,
        .remove         = ata_pci_remove_one,
-#ifdef CONFIG_PM
+#ifdef CONFIG_PM_SLEEP
        .suspend        = ata_pci_device_suspend,
        .resume         = ata_pci_device_resume,
 #endif
index 3c12fd7..e287b95 100644 (file)
@@ -289,7 +289,7 @@ static struct pci_driver efar_pci_driver = {
        .id_table               = efar_pci_tbl,
        .probe                  = efar_init_one,
        .remove                 = ata_pci_remove_one,
-#ifdef CONFIG_PM
+#ifdef CONFIG_PM_SLEEP
        .suspend                = ata_pci_device_suspend,
        .resume                 = ata_pci_device_resume,
 #endif
index 35b5213..9b2030c 100644 (file)
@@ -387,7 +387,7 @@ static int hpt36x_init_one(struct pci_dev *dev, const struct pci_device_id *id)
        return ata_pci_bmdma_init_one(dev, ppi, &hpt36x_sht, hpriv, 0);
 }
 
-#ifdef CONFIG_PM
+#ifdef CONFIG_PM_SLEEP
 static int hpt36x_reinit_one(struct pci_dev *dev)
 {
        struct ata_host *host = pci_get_drvdata(dev);
@@ -412,7 +412,7 @@ static struct pci_driver hpt36x_pci_driver = {
        .id_table       = hpt36x,
        .probe          = hpt36x_init_one,
        .remove         = ata_pci_remove_one,
-#ifdef CONFIG_PM
+#ifdef CONFIG_PM_SLEEP
        .suspend        = ata_pci_device_suspend,
        .resume         = hpt36x_reinit_one,
 #endif
index 85cf286..ecebe7e 100644 (file)
@@ -250,7 +250,7 @@ static int hpt3x3_init_one(struct pci_dev *pdev, const struct pci_device_id *id)
                                 IRQF_SHARED, &hpt3x3_sht);
 }
 
-#ifdef CONFIG_PM
+#ifdef CONFIG_PM_SLEEP
 static int hpt3x3_reinit_one(struct pci_dev *dev)
 {
        struct ata_host *host = pci_get_drvdata(dev);
@@ -278,7 +278,7 @@ static struct pci_driver hpt3x3_pci_driver = {
        .id_table       = hpt3x3,
        .probe          = hpt3x3_init_one,
        .remove         = ata_pci_remove_one,
-#ifdef CONFIG_PM
+#ifdef CONFIG_PM_SLEEP
        .suspend        = ata_pci_device_suspend,
        .resume         = hpt3x3_reinit_one,
 #endif
index b0b18ec..76b6f48 100644 (file)
@@ -191,7 +191,7 @@ static int pata_imx_remove(struct platform_device *pdev)
        return 0;
 }
 
-#ifdef CONFIG_PM
+#ifdef CONFIG_PM_SLEEP
 static int pata_imx_suspend(struct device *dev)
 {
        struct ata_host *host = dev_get_drvdata(dev);
@@ -250,7 +250,7 @@ static struct platform_driver pata_imx_driver = {
                .name           = DRV_NAME,
                .of_match_table = imx_pata_dt_ids,
                .owner          = THIS_MODULE,
-#ifdef CONFIG_PM
+#ifdef CONFIG_PM_SLEEP
                .pm             = &pata_imx_pm_ops,
 #endif
        },
index 2a8dd95..f62ad39 100644 (file)
@@ -284,7 +284,7 @@ static struct pci_driver it8213_pci_driver = {
        .id_table               = it8213_pci_tbl,
        .probe                  = it8213_init_one,
        .remove                 = ata_pci_remove_one,
-#ifdef CONFIG_PM
+#ifdef CONFIG_PM_SLEEP
        .suspend                = ata_pci_device_suspend,
        .resume                 = ata_pci_device_resume,
 #endif
index 581e04d..d7458b6 100644 (file)
@@ -936,7 +936,7 @@ static int it821x_init_one(struct pci_dev *pdev, const struct pci_device_id *id)
        return ata_pci_bmdma_init_one(pdev, ppi, &it821x_sht, NULL, 0);
 }
 
-#ifdef CONFIG_PM
+#ifdef CONFIG_PM_SLEEP
 static int it821x_reinit_one(struct pci_dev *pdev)
 {
        struct ata_host *host = pci_get_drvdata(pdev);
@@ -966,7 +966,7 @@ static struct pci_driver it821x_pci_driver = {
        .id_table       = it821x,
        .probe          = it821x_init_one,
        .remove         = ata_pci_remove_one,
-#ifdef CONFIG_PM
+#ifdef CONFIG_PM_SLEEP
        .suspend        = ata_pci_device_suspend,
        .resume         = it821x_reinit_one,
 #endif
index 76e739b..16983b8 100644 (file)
@@ -158,7 +158,7 @@ static struct pci_driver jmicron_pci_driver = {
        .id_table               = jmicron_pci_tbl,
        .probe                  = jmicron_init_one,
        .remove                 = ata_pci_remove_one,
-#ifdef CONFIG_PM
+#ifdef CONFIG_PM_SLEEP
        .suspend                = ata_pci_device_suspend,
        .resume                 = ata_pci_device_resume,
 #endif
index c28d064..a02f76f 100644 (file)
@@ -845,8 +845,7 @@ static int pata_macio_slave_config(struct scsi_device *sdev)
        return 0;
 }
 
-#ifdef CONFIG_PM
-
+#ifdef CONFIG_PM_SLEEP
 static int pata_macio_do_suspend(struct pata_macio_priv *priv, pm_message_t mesg)
 {
        int rc;
@@ -907,8 +906,7 @@ static int pata_macio_do_resume(struct pata_macio_priv *priv)
 
        return 0;
 }
-
-#endif /* CONFIG_PM */
+#endif /* CONFIG_PM_SLEEP */
 
 static struct scsi_host_template pata_macio_sht = {
        ATA_BASE_SHT(DRV_NAME),
@@ -1208,8 +1206,7 @@ static int pata_macio_detach(struct macio_dev *mdev)
        return 0;
 }
 
-#ifdef CONFIG_PM
-
+#ifdef CONFIG_PM_SLEEP
 static int pata_macio_suspend(struct macio_dev *mdev, pm_message_t mesg)
 {
        struct ata_host *host = macio_get_drvdata(mdev);
@@ -1223,8 +1220,7 @@ static int pata_macio_resume(struct macio_dev *mdev)
 
        return pata_macio_do_resume(host->private_data);
 }
-
-#endif /* CONFIG_PM */
+#endif /* CONFIG_PM_SLEEP */
 
 #ifdef CONFIG_PMAC_MEDIABAY
 static void pata_macio_mb_event(struct macio_dev* mdev, int mb_state)
@@ -1316,8 +1312,7 @@ static void pata_macio_pci_detach(struct pci_dev *pdev)
        ata_host_detach(host);
 }
 
-#ifdef CONFIG_PM
-
+#ifdef CONFIG_PM_SLEEP
 static int pata_macio_pci_suspend(struct pci_dev *pdev, pm_message_t mesg)
 {
        struct ata_host *host = pci_get_drvdata(pdev);
@@ -1331,8 +1326,7 @@ static int pata_macio_pci_resume(struct pci_dev *pdev)
 
        return pata_macio_do_resume(host->private_data);
 }
-
-#endif /* CONFIG_PM */
+#endif /* CONFIG_PM_SLEEP */
 
 static struct of_device_id pata_macio_match[] =
 {
@@ -1360,7 +1354,7 @@ static struct macio_driver pata_macio_driver =
        },
        .probe          = pata_macio_attach,
        .remove         = pata_macio_detach,
-#ifdef CONFIG_PM
+#ifdef CONFIG_PM_SLEEP
        .suspend        = pata_macio_suspend,
        .resume         = pata_macio_resume,
 #endif
@@ -1383,7 +1377,7 @@ static struct pci_driver pata_macio_pci_driver = {
        .id_table       = pata_macio_pci_match,
        .probe          = pata_macio_pci_attach,
        .remove         = pata_macio_pci_detach,
-#ifdef CONFIG_PM
+#ifdef CONFIG_PM_SLEEP
        .suspend        = pata_macio_pci_suspend,
        .resume         = pata_macio_pci_resume,
 #endif
index a4f5e78..7764a26 100644 (file)
@@ -172,7 +172,7 @@ static struct pci_driver marvell_pci_driver = {
        .id_table               = marvell_pci_tbl,
        .probe                  = marvell_init_one,
        .remove                 = ata_pci_remove_one,
-#ifdef CONFIG_PM
+#ifdef CONFIG_PM_SLEEP
        .suspend                = ata_pci_device_suspend,
        .resume                 = ata_pci_device_resume,
 #endif
index 0024ced..ccd1c83 100644 (file)
@@ -819,9 +819,7 @@ mpc52xx_ata_remove(struct platform_device *op)
        return 0;
 }
 
-
-#ifdef CONFIG_PM
-
+#ifdef CONFIG_PM_SLEEP
 static int
 mpc52xx_ata_suspend(struct platform_device *op, pm_message_t state)
 {
@@ -847,10 +845,8 @@ mpc52xx_ata_resume(struct platform_device *op)
 
        return 0;
 }
-
 #endif
 
-
 static struct of_device_id mpc52xx_ata_of_match[] = {
        { .compatible = "fsl,mpc5200-ata", },
        { .compatible = "mpc5200-ata", },
@@ -861,7 +857,7 @@ static struct of_device_id mpc52xx_ata_of_match[] = {
 static struct platform_driver mpc52xx_ata_of_platform_driver = {
        .probe          = mpc52xx_ata_probe,
        .remove         = mpc52xx_ata_remove,
-#ifdef CONFIG_PM
+#ifdef CONFIG_PM_SLEEP
        .suspend        = mpc52xx_ata_suspend,
        .resume         = mpc52xx_ata_resume,
 #endif
index 1f5f28b..e43680b 100644 (file)
@@ -224,7 +224,7 @@ static struct pci_driver mpiix_pci_driver = {
        .id_table       = mpiix,
        .probe          = mpiix_init_one,
        .remove         = ata_pci_remove_one,
-#ifdef CONFIG_PM
+#ifdef CONFIG_PM_SLEEP
        .suspend        = ata_pci_device_suspend,
        .resume         = ata_pci_device_resume,
 #endif
index ad1a0fe..60d2ea5 100644 (file)
@@ -93,7 +93,7 @@ static struct pci_driver netcell_pci_driver = {
        .id_table               = netcell_pci_tbl,
        .probe                  = netcell_init_one,
        .remove                 = ata_pci_remove_one,
-#ifdef CONFIG_PM
+#ifdef CONFIG_PM_SLEEP
        .suspend                = ata_pci_device_suspend,
        .resume                 = ata_pci_device_resume,
 #endif
index 9513e07..c8713d0 100644 (file)
@@ -153,8 +153,7 @@ static int ninja32_init_one(struct pci_dev *dev, const struct pci_device_id *id)
                                 IRQF_SHARED, &ninja32_sht);
 }
 
-#ifdef CONFIG_PM
-
+#ifdef CONFIG_PM_SLEEP
 static int ninja32_reinit_one(struct pci_dev *pdev)
 {
        struct ata_host *host = pci_get_drvdata(pdev);
@@ -184,7 +183,7 @@ static struct pci_driver ninja32_pci_driver = {
        .id_table       = ninja32,
        .probe          = ninja32_init_one,
        .remove         = ata_pci_remove_one,
-#ifdef CONFIG_PM
+#ifdef CONFIG_PM_SLEEP
        .suspend        = ata_pci_device_suspend,
        .resume         = ninja32_reinit_one,
 #endif
index 0c424da..25b04a3 100644 (file)
@@ -162,7 +162,7 @@ static struct pci_driver ns87410_pci_driver = {
        .id_table       = ns87410,
        .probe          = ns87410_init_one,
        .remove         = ata_pci_remove_one,
-#ifdef CONFIG_PM
+#ifdef CONFIG_PM_SLEEP
        .suspend        = ata_pci_device_suspend,
        .resume         = ata_pci_device_resume,
 #endif
index 16dc3a6..8e7f37e 100644 (file)
@@ -386,7 +386,7 @@ static const struct pci_device_id ns87415_pci_tbl[] = {
        { }     /* terminate list */
 };
 
-#ifdef CONFIG_PM
+#ifdef CONFIG_PM_SLEEP
 static int ns87415_reinit_one(struct pci_dev *pdev)
 {
        struct ata_host *host = pci_get_drvdata(pdev);
@@ -408,7 +408,7 @@ static struct pci_driver ns87415_pci_driver = {
        .id_table               = ns87415_pci_tbl,
        .probe                  = ns87415_init_one,
        .remove                 = ata_pci_remove_one,
-#ifdef CONFIG_PM
+#ifdef CONFIG_PM_SLEEP
        .suspend                = ata_pci_device_suspend,
        .resume                 = ns87415_reinit_one,
 #endif
index d77b2e1..91b172b 100644 (file)
@@ -259,7 +259,7 @@ static struct pci_driver oldpiix_pci_driver = {
        .id_table               = oldpiix_pci_tbl,
        .probe                  = oldpiix_init_one,
        .remove                 = ata_pci_remove_one,
-#ifdef CONFIG_PM
+#ifdef CONFIG_PM_SLEEP
        .suspend                = ata_pci_device_suspend,
        .resume                 = ata_pci_device_resume,
 #endif
index 4ea70cd..f5a7e85 100644 (file)
@@ -185,7 +185,7 @@ static struct pci_driver opti_pci_driver = {
        .id_table       = opti,
        .probe          = opti_init_one,
        .remove         = ata_pci_remove_one,
-#ifdef CONFIG_PM
+#ifdef CONFIG_PM_SLEEP
        .suspend        = ata_pci_device_suspend,
        .resume         = ata_pci_device_resume,
 #endif
index 78ede3f..c8bd4da 100644 (file)
@@ -441,7 +441,7 @@ static struct pci_driver optidma_pci_driver = {
        .id_table       = optidma,
        .probe          = optidma_init_one,
        .remove         = ata_pci_remove_one,
-#ifdef CONFIG_PM
+#ifdef CONFIG_PM_SLEEP
        .suspend        = ata_pci_device_suspend,
        .resume         = ata_pci_device_resume,
 #endif
index 9d874c8..84ec76d 100644 (file)
@@ -63,7 +63,7 @@ enum {
 };
 
 static int pdc2027x_init_one(struct pci_dev *pdev, const struct pci_device_id *ent);
-#ifdef CONFIG_PM
+#ifdef CONFIG_PM_SLEEP
 static int pdc2027x_reinit_one(struct pci_dev *pdev);
 #endif
 static int pdc2027x_prereset(struct ata_link *link, unsigned long deadline);
@@ -129,7 +129,7 @@ static struct pci_driver pdc2027x_pci_driver = {
        .id_table               = pdc2027x_pci_tbl,
        .probe                  = pdc2027x_init_one,
        .remove                 = ata_pci_remove_one,
-#ifdef CONFIG_PM
+#ifdef CONFIG_PM_SLEEP
        .suspend                = ata_pci_device_suspend,
        .resume                 = pdc2027x_reinit_one,
 #endif
@@ -762,7 +762,7 @@ static int pdc2027x_init_one(struct pci_dev *pdev,
                                 IRQF_SHARED, &pdc2027x_sht);
 }
 
-#ifdef CONFIG_PM
+#ifdef CONFIG_PM_SLEEP
 static int pdc2027x_reinit_one(struct pci_dev *pdev)
 {
        struct ata_host *host = pci_get_drvdata(pdev);
index c34fc50..658083b 100644 (file)
@@ -378,7 +378,7 @@ static struct pci_driver pdc202xx_pci_driver = {
        .id_table       = pdc202xx,
        .probe          = pdc202xx_init_one,
        .remove         = ata_pci_remove_one,
-#ifdef CONFIG_PM
+#ifdef CONFIG_PM_SLEEP
        .suspend        = ata_pci_device_suspend,
        .resume         = ata_pci_device_resume,
 #endif
index 2beb6b5..ffe7b43 100644 (file)
@@ -111,7 +111,7 @@ static struct pci_driver ata_tosh_pci_driver = {
        .id_table       = ata_tosh,
        .probe          = ata_tosh_init_one,
        .remove         = ata_pci_remove_one,
-#ifdef CONFIG_PM
+#ifdef CONFIG_PM_SLEEP
        .suspend        = ata_pci_device_suspend,
        .resume         = ata_pci_device_resume,
 #endif
index f582ba1..91ddd53 100644 (file)
@@ -238,7 +238,7 @@ static struct pci_driver radisys_pci_driver = {
        .id_table               = radisys_pci_tbl,
        .probe                  = radisys_init_one,
        .remove                 = ata_pci_remove_one,
-#ifdef CONFIG_PM
+#ifdef CONFIG_PM_SLEEP
        .suspend                = ata_pci_device_suspend,
        .resume                 = ata_pci_device_resume,
 #endif
index 79a970f..5c5184f 100644 (file)
@@ -383,7 +383,7 @@ static struct pci_driver rdc_pci_driver = {
        .id_table               = rdc_pci_tbl,
        .probe                  = rdc_init_one,
        .remove                 = rdc_remove_one,
-#ifdef CONFIG_PM
+#ifdef CONFIG_PM_SLEEP
        .suspend                = ata_pci_device_suspend,
        .resume                 = ata_pci_device_resume,
 #endif
index 040b093..f12adde 100644 (file)
@@ -102,7 +102,7 @@ static int rz1000_init_one (struct pci_dev *pdev, const struct pci_device_id *en
        return -ENODEV;
 }
 
-#ifdef CONFIG_PM
+#ifdef CONFIG_PM_SLEEP
 static int rz1000_reinit_one(struct pci_dev *pdev)
 {
        struct ata_host *host = pci_get_drvdata(pdev);
@@ -134,7 +134,7 @@ static struct pci_driver rz1000_pci_driver = {
        .id_table       = pata_rz1000,
        .probe          = rz1000_init_one,
        .remove         = ata_pci_remove_one,
-#ifdef CONFIG_PM
+#ifdef CONFIG_PM_SLEEP
        .suspend        = ata_pci_device_suspend,
        .resume         = rz1000_reinit_one,
 #endif
index a79566d..cab8e60 100644 (file)
@@ -615,7 +615,7 @@ static int __exit pata_s3c_remove(struct platform_device *pdev)
        return 0;
 }
 
-#ifdef CONFIG_PM
+#ifdef CONFIG_PM_SLEEP
 static int pata_s3c_suspend(struct device *dev)
 {
        struct platform_device *pdev = to_platform_device(dev);
@@ -666,7 +666,7 @@ static struct platform_driver pata_s3c_driver = {
        .driver         = {
                .name   = DRV_NAME,
                .owner  = THIS_MODULE,
-#ifdef CONFIG_PM
+#ifdef CONFIG_PM_SLEEP
                .pm     = &pata_s3c_pm_ops,
 #endif
        },
index ce2f828..c0e92e7 100644 (file)
@@ -255,7 +255,7 @@ static struct pci_driver sc1200_pci_driver = {
        .id_table       = sc1200,
        .probe          = sc1200_init_one,
        .remove         = ata_pci_remove_one,
-#ifdef CONFIG_PM
+#ifdef CONFIG_PM_SLEEP
        .suspend        = ata_pci_device_suspend,
        .resume         = ata_pci_device_resume,
 #endif
index f7badaa..33f6cf2 100644 (file)
@@ -1096,7 +1096,7 @@ static struct pci_driver scc_pci_driver = {
        .id_table               = scc_pci_tbl,
        .probe                  = scc_init_one,
        .remove                 = ata_pci_remove_one,
-#ifdef CONFIG_PM
+#ifdef CONFIG_PM_SLEEP
        .suspend                = ata_pci_device_suspend,
        .resume                 = ata_pci_device_resume,
 #endif
index d3830c4..721f0e8 100644 (file)
@@ -65,7 +65,7 @@ static struct pci_driver sch_pci_driver = {
        .id_table               = sch_pci_tbl,
        .probe                  = sch_init_one,
        .remove                 = ata_pci_remove_one,
-#ifdef CONFIG_PM
+#ifdef CONFIG_PM_SLEEP
        .suspend                = ata_pci_device_suspend,
        .resume                 = ata_pci_device_resume,
 #endif
index 79dedba..88142c7 100644 (file)
@@ -446,7 +446,7 @@ static int serverworks_init_one(struct pci_dev *pdev, const struct pci_device_id
        return ata_pci_bmdma_init_one(pdev, ppi, sht, NULL, 0);
 }
 
-#ifdef CONFIG_PM
+#ifdef CONFIG_PM_SLEEP
 static int serverworks_reinit_one(struct pci_dev *pdev)
 {
        struct ata_host *host = pci_get_drvdata(pdev);
@@ -478,7 +478,7 @@ static struct pci_driver serverworks_pci_driver = {
        .id_table       = serverworks,
        .probe          = serverworks_init_one,
        .remove         = ata_pci_remove_one,
-#ifdef CONFIG_PM
+#ifdef CONFIG_PM_SLEEP
        .suspend        = ata_pci_device_suspend,
        .resume         = serverworks_reinit_one,
 #endif
index c4b0b07..45b2a4d 100644 (file)
@@ -404,7 +404,7 @@ use_ioports:
        return ata_pci_bmdma_init_one(pdev, ppi, &sil680_sht, NULL, 0);
 }
 
-#ifdef CONFIG_PM
+#ifdef CONFIG_PM_SLEEP
 static int sil680_reinit_one(struct pci_dev *pdev)
 {
        struct ata_host *host = pci_get_drvdata(pdev);
@@ -430,7 +430,7 @@ static struct pci_driver sil680_pci_driver = {
        .id_table       = sil680,
        .probe          = sil680_init_one,
        .remove         = ata_pci_remove_one,
-#ifdef CONFIG_PM
+#ifdef CONFIG_PM_SLEEP
        .suspend        = ata_pci_device_suspend,
        .resume         = sil680_reinit_one,
 #endif
index 1e83636..55e3f93 100644 (file)
@@ -870,7 +870,7 @@ static int sis_init_one (struct pci_dev *pdev, const struct pci_device_id *ent)
        return ata_pci_bmdma_init_one(pdev, ppi, &sis_sht, chipset, 0);
 }
 
-#ifdef CONFIG_PM
+#ifdef CONFIG_PM_SLEEP
 static int sis_reinit_one(struct pci_dev *pdev)
 {
        struct ata_host *host = pci_get_drvdata(pdev);
@@ -900,7 +900,7 @@ static struct pci_driver sis_pci_driver = {
        .id_table               = sis_pci_tbl,
        .probe                  = sis_init_one,
        .remove                 = ata_pci_remove_one,
-#ifdef CONFIG_PM
+#ifdef CONFIG_PM_SLEEP
        .suspend                = ata_pci_device_suspend,
        .resume                 = sis_reinit_one,
 #endif
index 6816911..bca55ee 100644 (file)
@@ -338,7 +338,7 @@ static int sl82c105_init_one(struct pci_dev *dev, const struct pci_device_id *id
        return ata_pci_bmdma_init_one(dev, ppi, &sl82c105_sht, NULL, 0);
 }
 
-#ifdef CONFIG_PM
+#ifdef CONFIG_PM_SLEEP
 static int sl82c105_reinit_one(struct pci_dev *pdev)
 {
        struct ata_host *host = pci_get_drvdata(pdev);
@@ -366,7 +366,7 @@ static struct pci_driver sl82c105_pci_driver = {
        .id_table       = sl82c105,
        .probe          = sl82c105_init_one,
        .remove         = ata_pci_remove_one,
-#ifdef CONFIG_PM
+#ifdef CONFIG_PM_SLEEP
        .suspend        = ata_pci_device_suspend,
        .resume         = sl82c105_reinit_one,
 #endif
index 94473da..20b4dd7 100644 (file)
@@ -208,7 +208,7 @@ static const struct pci_device_id triflex[] = {
        { },
 };
 
-#ifdef CONFIG_PM
+#ifdef CONFIG_PM_SLEEP
 static int triflex_ata_pci_device_suspend(struct pci_dev *pdev, pm_message_t mesg)
 {
        struct ata_host *host = pci_get_drvdata(pdev);
@@ -234,7 +234,7 @@ static struct pci_driver triflex_pci_driver = {
        .id_table       = triflex,
        .probe          = triflex_init_one,
        .remove         = ata_pci_remove_one,
-#ifdef CONFIG_PM
+#ifdef CONFIG_PM_SLEEP
        .suspend        = triflex_ata_pci_device_suspend,
        .resume         = ata_pci_device_resume,
 #endif
index c3ab9a6..08df26d 100644 (file)
@@ -660,7 +660,7 @@ static int via_init_one(struct pci_dev *pdev, const struct pci_device_id *id)
        return ata_pci_bmdma_init_one(pdev, ppi, &via_sht, (void *)config, 0);
 }
 
-#ifdef CONFIG_PM
+#ifdef CONFIG_PM_SLEEP
 /**
  *     via_reinit_one          -       reinit after resume
  *     @pdev; PCI device
@@ -705,7 +705,7 @@ static struct pci_driver via_pci_driver = {
        .id_table       = via,
        .probe          = via_init_one,
        .remove         = ata_pci_remove_one,
-#ifdef CONFIG_PM
+#ifdef CONFIG_PM_SLEEP
        .suspend        = ata_pci_device_suspend,
        .resume         = via_reinit_one,
 #endif
index fb0b40a..e8f150e 100644 (file)
@@ -1588,7 +1588,7 @@ static int sata_fsl_remove(struct platform_device *ofdev)
        return 0;
 }
 
-#ifdef CONFIG_PM
+#ifdef CONFIG_PM_SLEEP
 static int sata_fsl_suspend(struct platform_device *op, pm_message_t state)
 {
        struct ata_host *host = platform_get_drvdata(op);
@@ -1644,7 +1644,7 @@ static struct platform_driver fsl_sata_driver = {
        },
        .probe          = sata_fsl_probe,
        .remove         = sata_fsl_remove,
-#ifdef CONFIG_PM
+#ifdef CONFIG_PM_SLEEP
        .suspend        = sata_fsl_suspend,
        .resume         = sata_fsl_resume,
 #endif
index 5c54d95..0698278 100644 (file)
@@ -785,7 +785,7 @@ static int init_controller(void __iomem *mmio_base, u16 hctl)
        return 0;
 }
 
-#ifdef CONFIG_PM
+#ifdef CONFIG_PM_SLEEP
 static int inic_pci_device_resume(struct pci_dev *pdev)
 {
        struct ata_host *host = pci_get_drvdata(pdev);
@@ -898,7 +898,7 @@ static const struct pci_device_id inic_pci_tbl[] = {
 static struct pci_driver inic_pci_driver = {
        .name           = DRV_NAME,
        .id_table       = inic_pci_tbl,
-#ifdef CONFIG_PM
+#ifdef CONFIG_PM_SLEEP
        .suspend        = ata_pci_device_suspend,
        .resume         = inic_pci_device_resume,
 #endif
index 05c8a44..391cfda 100644 (file)
@@ -4222,7 +4222,7 @@ static int mv_platform_remove(struct platform_device *pdev)
        return 0;
 }
 
-#ifdef CONFIG_PM
+#ifdef CONFIG_PM_SLEEP
 static int mv_platform_suspend(struct platform_device *pdev, pm_message_t state)
 {
        struct ata_host *host = platform_get_drvdata(pdev);
@@ -4289,7 +4289,7 @@ static struct platform_driver mv_platform_driver = {
 #ifdef CONFIG_PCI
 static int mv_pci_init_one(struct pci_dev *pdev,
                           const struct pci_device_id *ent);
-#ifdef CONFIG_PM
+#ifdef CONFIG_PM_SLEEP
 static int mv_pci_device_resume(struct pci_dev *pdev);
 #endif
 
@@ -4299,7 +4299,7 @@ static struct pci_driver mv_pci_driver = {
        .id_table               = mv_pci_tbl,
        .probe                  = mv_pci_init_one,
        .remove                 = ata_pci_remove_one,
-#ifdef CONFIG_PM
+#ifdef CONFIG_PM_SLEEP
        .suspend                = ata_pci_device_suspend,
        .resume                 = mv_pci_device_resume,
 #endif
@@ -4457,7 +4457,7 @@ static int mv_pci_init_one(struct pci_dev *pdev,
                                 IS_GEN_I(hpriv) ? &mv5_sht : &mv6_sht);
 }
 
-#ifdef CONFIG_PM
+#ifdef CONFIG_PM_SLEEP
 static int mv_pci_device_resume(struct pci_dev *pdev)
 {
        struct ata_host *host = pci_get_drvdata(pdev);
index d74def8..4036012 100644 (file)
@@ -296,7 +296,7 @@ struct nv_swncq_port_priv {
 #define NV_ADMA_CHECK_INTR(GCTL, PORT) ((GCTL) & (1 << (19 + (12 * (PORT)))))
 
 static int nv_init_one(struct pci_dev *pdev, const struct pci_device_id *ent);
-#ifdef CONFIG_PM
+#ifdef CONFIG_PM_SLEEP
 static int nv_pci_device_resume(struct pci_dev *pdev);
 #endif
 static void nv_ck804_host_stop(struct ata_host *host);
@@ -380,7 +380,7 @@ static struct pci_driver nv_pci_driver = {
        .name                   = DRV_NAME,
        .id_table               = nv_pci_tbl,
        .probe                  = nv_init_one,
-#ifdef CONFIG_PM
+#ifdef CONFIG_PM_SLEEP
        .suspend                = ata_pci_device_suspend,
        .resume                 = nv_pci_device_resume,
 #endif
@@ -2432,7 +2432,7 @@ static int nv_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
        return ata_pci_sff_activate_host(host, ipriv->irq_handler, ipriv->sht);
 }
 
-#ifdef CONFIG_PM
+#ifdef CONFIG_PM_SLEEP
 static int nv_pci_device_resume(struct pci_dev *pdev)
 {
        struct ata_host *host = pci_get_drvdata(pdev);
index c1ea780..8732e42 100644 (file)
@@ -947,7 +947,7 @@ static int sata_rcar_remove(struct platform_device *pdev)
        return 0;
 }
 
-#ifdef CONFIG_PM
+#ifdef CONFIG_PM_SLEEP
 static int sata_rcar_suspend(struct device *dev)
 {
        struct ata_host *host = dev_get_drvdata(dev);
@@ -1001,7 +1001,7 @@ static struct platform_driver sata_rcar_driver = {
                .name           = DRV_NAME,
                .owner          = THIS_MODULE,
                .of_match_table = sata_rcar_match,
-#ifdef CONFIG_PM
+#ifdef CONFIG_PM_SLEEP
                .pm             = &sata_rcar_pm_ops,
 #endif
        },
index b7695e8..b15b776 100644 (file)
@@ -113,7 +113,7 @@ enum {
 };
 
 static int sil_init_one(struct pci_dev *pdev, const struct pci_device_id *ent);
-#ifdef CONFIG_PM
+#ifdef CONFIG_PM_SLEEP
 static int sil_pci_device_resume(struct pci_dev *pdev);
 #endif
 static void sil_dev_config(struct ata_device *dev);
@@ -167,7 +167,7 @@ static struct pci_driver sil_pci_driver = {
        .id_table               = sil_pci_tbl,
        .probe                  = sil_init_one,
        .remove                 = ata_pci_remove_one,
-#ifdef CONFIG_PM
+#ifdef CONFIG_PM_SLEEP
        .suspend                = ata_pci_device_suspend,
        .resume                 = sil_pci_device_resume,
 #endif
@@ -803,7 +803,7 @@ static int sil_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
                                 &sil_sht);
 }
 
-#ifdef CONFIG_PM
+#ifdef CONFIG_PM_SLEEP
 static int sil_pci_device_resume(struct pci_dev *pdev)
 {
        struct ata_host *host = pci_get_drvdata(pdev);
index aa1051b..0534890 100644 (file)
@@ -353,8 +353,10 @@ static void sil24_error_handler(struct ata_port *ap);
 static void sil24_post_internal_cmd(struct ata_queued_cmd *qc);
 static int sil24_port_start(struct ata_port *ap);
 static int sil24_init_one(struct pci_dev *pdev, const struct pci_device_id *ent);
-#ifdef CONFIG_PM
+#ifdef CONFIG_PM_SLEEP
 static int sil24_pci_device_resume(struct pci_dev *pdev);
+#endif
+#ifdef CONFIG_PM
 static int sil24_port_resume(struct ata_port *ap);
 #endif
 
@@ -375,7 +377,7 @@ static struct pci_driver sil24_pci_driver = {
        .id_table               = sil24_pci_tbl,
        .probe                  = sil24_init_one,
        .remove                 = ata_pci_remove_one,
-#ifdef CONFIG_PM
+#ifdef CONFIG_PM_SLEEP
        .suspend                = ata_pci_device_suspend,
        .resume                 = sil24_pci_device_resume,
 #endif
@@ -1350,7 +1352,7 @@ static int sil24_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
                                 &sil24_sht);
 }
 
-#ifdef CONFIG_PM
+#ifdef CONFIG_PM_SLEEP
 static int sil24_pci_device_resume(struct pci_dev *pdev)
 {
        struct ata_host *host = pci_get_drvdata(pdev);
@@ -1370,7 +1372,9 @@ static int sil24_pci_device_resume(struct pci_dev *pdev)
 
        return 0;
 }
+#endif
 
+#ifdef CONFIG_PM
 static int sil24_port_resume(struct ata_port *ap)
 {
        sil24_config_pmp(ap, ap->nr_pmp_links);
index 1ad2f62..9c8f2f0 100644 (file)
@@ -83,7 +83,7 @@ static struct pci_driver sis_pci_driver = {
        .id_table               = sis_pci_tbl,
        .probe                  = sis_init_one,
        .remove                 = ata_pci_remove_one,
-#ifdef CONFIG_PM
+#ifdef CONFIG_PM_SLEEP
        .suspend                = ata_pci_device_suspend,
        .resume                 = ata_pci_device_resume,
 #endif
index 87f056e..78c6ead 100644 (file)
@@ -104,7 +104,7 @@ static struct pci_driver svia_pci_driver = {
        .name                   = DRV_NAME,
        .id_table               = svia_pci_tbl,
        .probe                  = svia_init_one,
-#ifdef CONFIG_PM
+#ifdef CONFIG_PM_SLEEP
        .suspend                = ata_pci_device_suspend,
        .resume                 = ata_pci_device_resume,
 #endif
index 545c4de..c8d295a 100644 (file)
@@ -791,6 +791,62 @@ void * devm_kmalloc(struct device *dev, size_t size, gfp_t gfp)
 EXPORT_SYMBOL_GPL(devm_kmalloc);
 
 /**
+ * devm_kvasprintf - Allocate resource managed space and format a string
+ *                  into that.
+ * @dev: Device to allocate memory for
+ * @gfp: the GFP mask used in the devm_kmalloc() call when
+ *       allocating memory
+ * @fmt: The printf()-style format string
+ * @ap: Arguments for the format string
+ * RETURNS:
+ * Pointer to allocated string on success, NULL on failure.
+ */
+char *devm_kvasprintf(struct device *dev, gfp_t gfp, const char *fmt,
+                     va_list ap)
+{
+       unsigned int len;
+       char *p;
+       va_list aq;
+
+       va_copy(aq, ap);
+       len = vsnprintf(NULL, 0, fmt, aq);
+       va_end(aq);
+
+       p = devm_kmalloc(dev, len+1, gfp);
+       if (!p)
+               return NULL;
+
+       vsnprintf(p, len+1, fmt, ap);
+
+       return p;
+}
+EXPORT_SYMBOL(devm_kvasprintf);
+
+/**
+ * devm_kasprintf - Allocate resource managed space and format a string
+ *                 into that.
+ * @dev: Device to allocate memory for
+ * @gfp: the GFP mask used in the devm_kmalloc() call when
+ *       allocating memory
+ * @fmt: The printf()-style format string
+ * @...: Arguments for the format string
+ * RETURNS:
+ * Pointer to allocated string on success, NULL on failure.
+ */
+char *devm_kasprintf(struct device *dev, gfp_t gfp, const char *fmt, ...)
+{
+       va_list ap;
+       char *p;
+
+       va_start(ap, fmt);
+       p = devm_kvasprintf(dev, gfp, fmt, ap);
+       va_end(ap);
+
+       return p;
+}
+EXPORT_SYMBOL_GPL(devm_kasprintf);
+
+/**
  * devm_kfree - Resource-managed kfree
  * @dev: Device this memory belongs to
  * @p: Memory to free
index 2e58ebb..1cb8544 100644 (file)
@@ -1,6 +1,5 @@
-obj-$(CONFIG_PM)       += sysfs.o generic_ops.o common.o qos.o
+obj-$(CONFIG_PM)       += sysfs.o generic_ops.o common.o qos.o runtime.o
 obj-$(CONFIG_PM_SLEEP) += main.o wakeup.o
-obj-$(CONFIG_PM_RUNTIME)       += runtime.o
 obj-$(CONFIG_PM_TRACE_RTC)     += trace.o
 obj-$(CONFIG_PM_OPP)   += opp.o
 obj-$(CONFIG_PM_GENERIC_DOMAINS)       +=  domain.o domain_governor.o
index 72e00e6..4776cf5 100644 (file)
 #include <trace/events/rpm.h>
 #include "power.h"
 
+#define RPM_GET_CALLBACK(dev, cb)                              \
+({                                                             \
+       int (*__rpm_cb)(struct device *__d);                    \
+                                                               \
+       if (dev->pm_domain)                                     \
+               __rpm_cb = dev->pm_domain->ops.cb;              \
+       else if (dev->type && dev->type->pm)                    \
+               __rpm_cb = dev->type->pm->cb;                   \
+       else if (dev->class && dev->class->pm)                  \
+               __rpm_cb = dev->class->pm->cb;                  \
+       else if (dev->bus && dev->bus->pm)                      \
+               __rpm_cb = dev->bus->pm->cb;                    \
+       else                                                    \
+               __rpm_cb = NULL;                                \
+                                                               \
+       if (!__rpm_cb && dev->driver && dev->driver->pm)        \
+               __rpm_cb = dev->driver->pm->cb;                 \
+                                                               \
+       __rpm_cb;                                               \
+})
+
+static int (*rpm_get_suspend_cb(struct device *dev))(struct device *)
+{
+       return RPM_GET_CALLBACK(dev, runtime_suspend);
+}
+
+static int (*rpm_get_resume_cb(struct device *dev))(struct device *)
+{
+       return RPM_GET_CALLBACK(dev, runtime_resume);
+}
+
+#ifdef CONFIG_PM_RUNTIME
+static int (*rpm_get_idle_cb(struct device *dev))(struct device *)
+{
+       return RPM_GET_CALLBACK(dev, runtime_idle);
+}
+
 static int rpm_resume(struct device *dev, int rpmflags);
 static int rpm_suspend(struct device *dev, int rpmflags);
 
@@ -310,19 +347,7 @@ static int rpm_idle(struct device *dev, int rpmflags)
 
        dev->power.idle_notification = true;
 
-       if (dev->pm_domain)
-               callback = dev->pm_domain->ops.runtime_idle;
-       else if (dev->type && dev->type->pm)
-               callback = dev->type->pm->runtime_idle;
-       else if (dev->class && dev->class->pm)
-               callback = dev->class->pm->runtime_idle;
-       else if (dev->bus && dev->bus->pm)
-               callback = dev->bus->pm->runtime_idle;
-       else
-               callback = NULL;
-
-       if (!callback && dev->driver && dev->driver->pm)
-               callback = dev->driver->pm->runtime_idle;
+       callback = rpm_get_idle_cb(dev);
 
        if (callback)
                retval = __rpm_callback(callback, dev);
@@ -492,19 +517,7 @@ static int rpm_suspend(struct device *dev, int rpmflags)
 
        __update_runtime_status(dev, RPM_SUSPENDING);
 
-       if (dev->pm_domain)
-               callback = dev->pm_domain->ops.runtime_suspend;
-       else if (dev->type && dev->type->pm)
-               callback = dev->type->pm->runtime_suspend;
-       else if (dev->class && dev->class->pm)
-               callback = dev->class->pm->runtime_suspend;
-       else if (dev->bus && dev->bus->pm)
-               callback = dev->bus->pm->runtime_suspend;
-       else
-               callback = NULL;
-
-       if (!callback && dev->driver && dev->driver->pm)
-               callback = dev->driver->pm->runtime_suspend;
+       callback = rpm_get_suspend_cb(dev);
 
        retval = rpm_callback(callback, dev);
        if (retval)
@@ -724,19 +737,7 @@ static int rpm_resume(struct device *dev, int rpmflags)
 
        __update_runtime_status(dev, RPM_RESUMING);
 
-       if (dev->pm_domain)
-               callback = dev->pm_domain->ops.runtime_resume;
-       else if (dev->type && dev->type->pm)
-               callback = dev->type->pm->runtime_resume;
-       else if (dev->class && dev->class->pm)
-               callback = dev->class->pm->runtime_resume;
-       else if (dev->bus && dev->bus->pm)
-               callback = dev->bus->pm->runtime_resume;
-       else
-               callback = NULL;
-
-       if (!callback && dev->driver && dev->driver->pm)
-               callback = dev->driver->pm->runtime_resume;
+       callback = rpm_get_resume_cb(dev);
 
        retval = rpm_callback(callback, dev);
        if (retval) {
@@ -1401,3 +1402,86 @@ void pm_runtime_remove(struct device *dev)
        if (dev->power.irq_safe && dev->parent)
                pm_runtime_put(dev->parent);
 }
+#endif
+
+/**
+ * pm_runtime_force_suspend - Force a device into suspend state if needed.
+ * @dev: Device to suspend.
+ *
+ * Disable runtime PM so we safely can check the device's runtime PM status and
+ * if it is active, invoke it's .runtime_suspend callback to bring it into
+ * suspend state. Keep runtime PM disabled to preserve the state unless we
+ * encounter errors.
+ *
+ * Typically this function may be invoked from a system suspend callback to make
+ * sure the device is put into low power state.
+ */
+int pm_runtime_force_suspend(struct device *dev)
+{
+       int (*callback)(struct device *);
+       int ret = 0;
+
+       pm_runtime_disable(dev);
+
+       /*
+        * Note that pm_runtime_status_suspended() returns false while
+        * !CONFIG_PM_RUNTIME, which means the device will be put into low
+        * power state.
+        */
+       if (pm_runtime_status_suspended(dev))
+               return 0;
+
+       callback = rpm_get_suspend_cb(dev);
+
+       if (!callback) {
+               ret = -ENOSYS;
+               goto err;
+       }
+
+       ret = callback(dev);
+       if (ret)
+               goto err;
+
+       pm_runtime_set_suspended(dev);
+       return 0;
+err:
+       pm_runtime_enable(dev);
+       return ret;
+}
+EXPORT_SYMBOL_GPL(pm_runtime_force_suspend);
+
+/**
+ * pm_runtime_force_resume - Force a device into resume state.
+ * @dev: Device to resume.
+ *
+ * Prior invoking this function we expect the user to have brought the device
+ * into low power state by a call to pm_runtime_force_suspend(). Here we reverse
+ * those actions and brings the device into full power. We update the runtime PM
+ * status and re-enables runtime PM.
+ *
+ * Typically this function may be invoked from a system resume callback to make
+ * sure the device is put into full power state.
+ */
+int pm_runtime_force_resume(struct device *dev)
+{
+       int (*callback)(struct device *);
+       int ret = 0;
+
+       callback = rpm_get_resume_cb(dev);
+
+       if (!callback) {
+               ret = -ENOSYS;
+               goto out;
+       }
+
+       ret = callback(dev);
+       if (ret)
+               goto out;
+
+       pm_runtime_set_active(dev);
+       pm_runtime_mark_last_busy(dev);
+out:
+       pm_runtime_enable(dev);
+       return ret;
+}
+EXPORT_SYMBOL_GPL(pm_runtime_force_resume);
index 1a65838..c54cac3 100644 (file)
@@ -74,7 +74,7 @@ config TCG_NSC
 
 config TCG_ATMEL
        tristate "Atmel TPM Interface"
-       depends on PPC64 || HAS_IOPORT
+       depends on PPC64 || HAS_IOPORT_MAP
        ---help---
          If you have a TPM security chip from Atmel say Yes and it 
          will be accessible from within Linux.  To compile this driver 
index f9c4632..4ea3c06 100644 (file)
@@ -2501,8 +2501,12 @@ EXPORT_SYMBOL_GPL(of_clk_get_parent_count);
 const char *of_clk_get_parent_name(struct device_node *np, int index)
 {
        struct of_phandle_args clkspec;
+       struct property *prop;
        const char *clk_name;
+       const __be32 *vp;
+       u32 pv;
        int rc;
+       int count;
 
        if (index < 0)
                return NULL;
@@ -2512,8 +2516,22 @@ const char *of_clk_get_parent_name(struct device_node *np, int index)
        if (rc)
                return NULL;
 
+       index = clkspec.args_count ? clkspec.args[0] : 0;
+       count = 0;
+
+       /* if there is an indices property, use it to transfer the index
+        * specified into an array offset for the clock-output-names property.
+        */
+       of_property_for_each_u32(clkspec.np, "clock-indices", prop, vp, pv) {
+               if (index == pv) {
+                       index = count;
+                       break;
+               }
+               count++;
+       }
+
        if (of_property_read_string_index(clkspec.np, "clock-output-names",
-                                         clkspec.args_count ? clkspec.args[0] : 0,
+                                         index,
                                          &clk_name) < 0)
                clk_name = clkspec.np->name;
 
index 9ecef14..960bf22 100644 (file)
@@ -1,7 +1,9 @@
 obj-$(CONFIG_ARCH_EMEV2)               += clk-emev2.o
+obj-$(CONFIG_ARCH_R7S72100)            += clk-rz.o
+obj-$(CONFIG_ARCH_R8A7740)             += clk-r8a7740.o
+obj-$(CONFIG_ARCH_R8A7779)             += clk-r8a7779.o
 obj-$(CONFIG_ARCH_R8A7790)             += clk-rcar-gen2.o
 obj-$(CONFIG_ARCH_R8A7791)             += clk-rcar-gen2.o
+obj-$(CONFIG_ARCH_R8A7794)             += clk-rcar-gen2.o
 obj-$(CONFIG_ARCH_SHMOBILE_MULTI)      += clk-div6.o
 obj-$(CONFIG_ARCH_SHMOBILE_MULTI)      += clk-mstp.o
-# for emply built-in.o
-obj-n  := dummy
index aac4756..f065f69 100644 (file)
@@ -23,7 +23,7 @@
 #define CPG_DIV6_DIV_MASK      0x3f
 
 /**
- * struct div6_clock - MSTP gating clock
+ * struct div6_clock - CPG 6 bit divider clock
  * @hw: handle between common and hardware-specific interfaces
  * @reg: IO-remapped register
  * @div: divisor value (1-64)
index 42d5912..2d2fe77 100644 (file)
@@ -112,7 +112,7 @@ static int cpg_mstp_clock_is_enabled(struct clk_hw *hw)
        else
                value = clk_readl(group->smstpcr);
 
-       return !!(value & BIT(clock->bit_index));
+       return !(value & BIT(clock->bit_index));
 }
 
 static const struct clk_ops cpg_mstp_clock_ops = {
@@ -137,7 +137,7 @@ cpg_mstp_clock_register(const char *name, const char *parent_name,
 
        init.name = name;
        init.ops = &cpg_mstp_clock_ops;
-       init.flags = CLK_IS_BASIC;
+       init.flags = CLK_IS_BASIC | CLK_SET_RATE_PARENT;
        init.parent_names = &parent_name;
        init.num_parents = 1;
 
@@ -156,6 +156,7 @@ cpg_mstp_clock_register(const char *name, const char *parent_name,
 static void __init cpg_mstp_clocks_init(struct device_node *np)
 {
        struct mstp_clock_group *group;
+       const char *idxname;
        struct clk **clks;
        unsigned int i;
 
@@ -184,6 +185,11 @@ static void __init cpg_mstp_clocks_init(struct device_node *np)
        for (i = 0; i < MSTP_MAX_CLOCKS; ++i)
                clks[i] = ERR_PTR(-ENOENT);
 
+       if (of_find_property(np, "clock-indices", &i))
+               idxname = "clock-indices";
+       else
+               idxname = "renesas,clock-indices";
+
        for (i = 0; i < MSTP_MAX_CLOCKS; ++i) {
                const char *parent_name;
                const char *name;
@@ -197,8 +203,7 @@ static void __init cpg_mstp_clocks_init(struct device_node *np)
                        continue;
 
                parent_name = of_clk_get_parent_name(np, i);
-               ret = of_property_read_u32_index(np, "renesas,clock-indices", i,
-                                                &clkidx);
+               ret = of_property_read_u32_index(np, idxname, i, &clkidx);
                if (parent_name == NULL || ret < 0)
                        break;
 
diff --git a/drivers/clk/shmobile/clk-r8a7740.c b/drivers/clk/shmobile/clk-r8a7740.c
new file mode 100644 (file)
index 0000000..1e2eaae
--- /dev/null
@@ -0,0 +1,199 @@
+/*
+ * r8a7740 Core CPG Clocks
+ *
+ * Copyright (C) 2014  Ulrich Hecht
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; version 2 of the License.
+ */
+
+#include <linux/clk-provider.h>
+#include <linux/clkdev.h>
+#include <linux/clk/shmobile.h>
+#include <linux/init.h>
+#include <linux/kernel.h>
+#include <linux/of.h>
+#include <linux/of_address.h>
+#include <linux/spinlock.h>
+
+struct r8a7740_cpg {
+       struct clk_onecell_data data;
+       spinlock_t lock;
+       void __iomem *reg;
+};
+
+#define CPG_FRQCRA     0x00
+#define CPG_FRQCRB     0x04
+#define CPG_PLLC2CR    0x2c
+#define CPG_USBCKCR    0x8c
+#define CPG_FRQCRC     0xe0
+
+#define CLK_ENABLE_ON_INIT BIT(0)
+
+struct div4_clk {
+       const char *name;
+       unsigned int reg;
+       unsigned int shift;
+       int flags;
+};
+
+static struct div4_clk div4_clks[] = {
+       { "i", CPG_FRQCRA, 20, CLK_ENABLE_ON_INIT },
+       { "zg", CPG_FRQCRA, 16, CLK_ENABLE_ON_INIT },
+       { "b", CPG_FRQCRA,  8, CLK_ENABLE_ON_INIT },
+       { "m1", CPG_FRQCRA,  4, CLK_ENABLE_ON_INIT },
+       { "hp", CPG_FRQCRB,  4, 0 },
+       { "hpp", CPG_FRQCRC, 20, 0 },
+       { "usbp", CPG_FRQCRC, 16, 0 },
+       { "s", CPG_FRQCRC, 12, 0 },
+       { "zb", CPG_FRQCRC,  8, 0 },
+       { "m3", CPG_FRQCRC,  4, 0 },
+       { "cp", CPG_FRQCRC,  0, 0 },
+       { NULL, 0, 0, 0 },
+};
+
+static const struct clk_div_table div4_div_table[] = {
+       { 0, 2 }, { 1, 3 }, { 2, 4 }, { 3, 6 }, { 4, 8 }, { 5, 12 },
+       { 6, 16 }, { 7, 18 }, { 8, 24 }, { 9, 32 }, { 10, 36 }, { 11, 48 },
+       { 13, 72 }, { 14, 96 }, { 0, 0 }
+};
+
+static u32 cpg_mode __initdata;
+
+static struct clk * __init
+r8a7740_cpg_register_clock(struct device_node *np, struct r8a7740_cpg *cpg,
+                            const char *name)
+{
+       const struct clk_div_table *table = NULL;
+       const char *parent_name;
+       unsigned int shift, reg;
+       unsigned int mult = 1;
+       unsigned int div = 1;
+
+       if (!strcmp(name, "r")) {
+               switch (cpg_mode & (BIT(2) | BIT(1))) {
+               case BIT(1) | BIT(2):
+                       /* extal1 */
+                       parent_name = of_clk_get_parent_name(np, 0);
+                       div = 2048;
+                       break;
+               case BIT(2):
+                       /* extal1 */
+                       parent_name = of_clk_get_parent_name(np, 0);
+                       div = 1024;
+                       break;
+               default:
+                       /* extalr */
+                       parent_name = of_clk_get_parent_name(np, 2);
+                       break;
+               }
+       } else if (!strcmp(name, "system")) {
+               parent_name = of_clk_get_parent_name(np, 0);
+               if (cpg_mode & BIT(1))
+                       div = 2;
+       } else if (!strcmp(name, "pllc0")) {
+               /* PLLC0/1 are configurable multiplier clocks. Register them as
+                * fixed factor clocks for now as there's no generic multiplier
+                * clock implementation and we currently have no need to change
+                * the multiplier value.
+                */
+               u32 value = clk_readl(cpg->reg + CPG_FRQCRC);
+               parent_name = "system";
+               mult = ((value >> 24) & 0x7f) + 1;
+       } else if (!strcmp(name, "pllc1")) {
+               u32 value = clk_readl(cpg->reg + CPG_FRQCRA);
+               parent_name = "system";
+               mult = ((value >> 24) & 0x7f) + 1;
+               div = 2;
+       } else if (!strcmp(name, "pllc2")) {
+               u32 value = clk_readl(cpg->reg + CPG_PLLC2CR);
+               parent_name = "system";
+               mult = ((value >> 24) & 0x3f) + 1;
+       } else if (!strcmp(name, "usb24s")) {
+               u32 value = clk_readl(cpg->reg + CPG_USBCKCR);
+               if (value & BIT(7))
+                       /* extal2 */
+                       parent_name = of_clk_get_parent_name(np, 1);
+               else
+                       parent_name = "system";
+               if (!(value & BIT(6)))
+                       div = 2;
+       } else {
+               struct div4_clk *c;
+               for (c = div4_clks; c->name; c++) {
+                       if (!strcmp(name, c->name)) {
+                               parent_name = "pllc1";
+                               table = div4_div_table;
+                               reg = c->reg;
+                               shift = c->shift;
+                               break;
+                       }
+               }
+               if (!c->name)
+                       return ERR_PTR(-EINVAL);
+       }
+
+       if (!table) {
+               return clk_register_fixed_factor(NULL, name, parent_name, 0,
+                                                mult, div);
+       } else {
+               return clk_register_divider_table(NULL, name, parent_name, 0,
+                                                 cpg->reg + reg, shift, 4, 0,
+                                                 table, &cpg->lock);
+       }
+}
+
+static void __init r8a7740_cpg_clocks_init(struct device_node *np)
+{
+       struct r8a7740_cpg *cpg;
+       struct clk **clks;
+       unsigned int i;
+       int num_clks;
+
+       if (of_property_read_u32(np, "renesas,mode", &cpg_mode))
+               pr_warn("%s: missing renesas,mode property\n", __func__);
+
+       num_clks = of_property_count_strings(np, "clock-output-names");
+       if (num_clks < 0) {
+               pr_err("%s: failed to count clocks\n", __func__);
+               return;
+       }
+
+       cpg = kzalloc(sizeof(*cpg), GFP_KERNEL);
+       clks = kzalloc(num_clks * sizeof(*clks), GFP_KERNEL);
+       if (cpg == NULL || clks == NULL) {
+               /* We're leaking memory on purpose, there's no point in cleaning
+                * up as the system won't boot anyway.
+                */
+               return;
+       }
+
+       spin_lock_init(&cpg->lock);
+
+       cpg->data.clks = clks;
+       cpg->data.clk_num = num_clks;
+
+       cpg->reg = of_iomap(np, 0);
+       if (WARN_ON(cpg->reg == NULL))
+               return;
+
+       for (i = 0; i < num_clks; ++i) {
+               const char *name;
+               struct clk *clk;
+
+               of_property_read_string_index(np, "clock-output-names", i,
+                                             &name);
+
+               clk = r8a7740_cpg_register_clock(np, cpg, name);
+               if (IS_ERR(clk))
+                       pr_err("%s: failed to register %s %s clock (%ld)\n",
+                              __func__, np->name, name, PTR_ERR(clk));
+               else
+                       cpg->data.clks[i] = clk;
+       }
+
+       of_clk_add_provider(np, of_clk_src_onecell_get, &cpg->data);
+}
+CLK_OF_DECLARE(r8a7740_cpg_clks, "renesas,r8a7740-cpg-clocks",
+              r8a7740_cpg_clocks_init);
diff --git a/drivers/clk/shmobile/clk-r8a7779.c b/drivers/clk/shmobile/clk-r8a7779.c
new file mode 100644 (file)
index 0000000..652ecac
--- /dev/null
@@ -0,0 +1,180 @@
+/*
+ * r8a7779 Core CPG Clocks
+ *
+ * Copyright (C) 2013, 2014 Horms Solutions Ltd.
+ *
+ * Contact: Simon Horman <horms@verge.net.au>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; version 2 of the License.
+ */
+
+#include <linux/clk-provider.h>
+#include <linux/clkdev.h>
+#include <linux/clk/shmobile.h>
+#include <linux/init.h>
+#include <linux/kernel.h>
+#include <linux/of.h>
+#include <linux/of_address.h>
+#include <linux/spinlock.h>
+
+#include <dt-bindings/clock/r8a7779-clock.h>
+
+#define CPG_NUM_CLOCKS                 (R8A7779_CLK_OUT + 1)
+
+struct r8a7779_cpg {
+       struct clk_onecell_data data;
+       spinlock_t lock;
+       void __iomem *reg;
+};
+
+/* -----------------------------------------------------------------------------
+ * CPG Clock Data
+ */
+
+/*
+ *             MD1 = 1                 MD1 = 0
+ *             (PLLA = 1500)           (PLLA = 1600)
+ *             (MHz)                   (MHz)
+ *------------------------------------------------+--------------------
+ * clkz                1000   (2/3)            800   (1/2)
+ * clkzs        250   (1/6)            200   (1/8)
+ * clki                 750   (1/2)            800   (1/2)
+ * clks                 250   (1/6)            200   (1/8)
+ * clks1        125   (1/12)           100   (1/16)
+ * clks3        187.5 (1/8)            200   (1/8)
+ * clks4         93.7 (1/16)           100   (1/16)
+ * clkp                  62.5 (1/24)            50   (1/32)
+ * clkg                  62.5 (1/24)            66.6 (1/24)
+ * clkb, CLKOUT
+ * (MD2 = 0)     62.5 (1/24)            66.6 (1/24)
+ * (MD2 = 1)     41.6 (1/36)            50   (1/32)
+ */
+
+#define CPG_CLK_CONFIG_INDEX(md)       (((md) & (BIT(2)|BIT(1))) >> 1)
+
+struct cpg_clk_config {
+       unsigned int z_mult;
+       unsigned int z_div;
+       unsigned int zs_and_s_div;
+       unsigned int s1_div;
+       unsigned int p_div;
+       unsigned int b_and_out_div;
+};
+
+static const struct cpg_clk_config cpg_clk_configs[4] __initconst = {
+       { 1, 2, 8, 16, 32, 24 },
+       { 2, 3, 6, 12, 24, 24 },
+       { 1, 2, 8, 16, 32, 32 },
+       { 2, 3, 6, 12, 24, 36 },
+};
+
+/*
+ *   MD                PLLA Ratio
+ * 12 11
+ *------------------------
+ * 0  0                x42
+ * 0  1                x48
+ * 1  0                x56
+ * 1  1                x64
+ */
+
+#define CPG_PLLA_MULT_INDEX(md)        (((md) & (BIT(12)|BIT(11))) >> 11)
+
+static const unsigned int cpg_plla_mult[4] __initconst = { 42, 48, 56, 64 };
+
+/* -----------------------------------------------------------------------------
+ * Initialization
+ */
+
+static u32 cpg_mode __initdata;
+
+static struct clk * __init
+r8a7779_cpg_register_clock(struct device_node *np, struct r8a7779_cpg *cpg,
+                          const struct cpg_clk_config *config,
+                          unsigned int plla_mult, const char *name)
+{
+       const char *parent_name = "plla";
+       unsigned int mult = 1;
+       unsigned int div = 1;
+
+       if (!strcmp(name, "plla")) {
+               parent_name = of_clk_get_parent_name(np, 0);
+               mult = plla_mult;
+       } else if (!strcmp(name, "z")) {
+               div = config->z_div;
+               mult = config->z_mult;
+       } else if (!strcmp(name, "zs") || !strcmp(name, "s")) {
+               div = config->zs_and_s_div;
+       } else if (!strcmp(name, "s1")) {
+               div = config->s1_div;
+       } else if (!strcmp(name, "p")) {
+               div = config->p_div;
+       } else if (!strcmp(name, "b") || !strcmp(name, "out")) {
+               div = config->b_and_out_div;
+       } else {
+               return ERR_PTR(-EINVAL);
+       }
+
+       return clk_register_fixed_factor(NULL, name, parent_name, 0, mult, div);
+}
+
+static void __init r8a7779_cpg_clocks_init(struct device_node *np)
+{
+       const struct cpg_clk_config *config;
+       struct r8a7779_cpg *cpg;
+       struct clk **clks;
+       unsigned int i, plla_mult;
+       int num_clks;
+
+       num_clks = of_property_count_strings(np, "clock-output-names");
+       if (num_clks < 0) {
+               pr_err("%s: failed to count clocks\n", __func__);
+               return;
+       }
+
+       cpg = kzalloc(sizeof(*cpg), GFP_KERNEL);
+       clks = kzalloc(CPG_NUM_CLOCKS * sizeof(*clks), GFP_KERNEL);
+       if (cpg == NULL || clks == NULL) {
+               /* We're leaking memory on purpose, there's no point in cleaning
+                * up as the system won't boot anyway.
+                */
+               return;
+       }
+
+       spin_lock_init(&cpg->lock);
+
+       cpg->data.clks = clks;
+       cpg->data.clk_num = num_clks;
+
+       config = &cpg_clk_configs[CPG_CLK_CONFIG_INDEX(cpg_mode)];
+       plla_mult = cpg_plla_mult[CPG_PLLA_MULT_INDEX(cpg_mode)];
+
+       for (i = 0; i < num_clks; ++i) {
+               const char *name;
+               struct clk *clk;
+
+               of_property_read_string_index(np, "clock-output-names", i,
+                                             &name);
+
+               clk = r8a7779_cpg_register_clock(np, cpg, config,
+                                                plla_mult, name);
+               if (IS_ERR(clk))
+                       pr_err("%s: failed to register %s %s clock (%ld)\n",
+                              __func__, np->name, name, PTR_ERR(clk));
+               else
+                       cpg->data.clks[i] = clk;
+       }
+
+       of_clk_add_provider(np, of_clk_src_onecell_get, &cpg->data);
+}
+CLK_OF_DECLARE(r8a7779_cpg_clks, "renesas,r8a7779-cpg-clocks",
+              r8a7779_cpg_clocks_init);
+
+void __init r8a7779_clocks_init(u32 mode)
+{
+       cpg_mode = mode;
+
+       of_clk_init(NULL);
+}
index 99c27b1..e996425 100644 (file)
@@ -202,6 +202,7 @@ static const struct clk_div_table cpg_sdh_div_table[] = {
 };
 
 static const struct clk_div_table cpg_sd01_div_table[] = {
+       {  4,  8 },
        {  5, 12 }, {  6, 16 }, {  7, 18 }, {  8, 24 },
        { 10, 36 }, { 11, 48 }, { 12, 10 }, {  0,  0 },
 };
@@ -242,22 +243,22 @@ rcar_gen2_cpg_register_clock(struct device_node *np, struct rcar_gen2_cpg *cpg,
                parent_name = "main";
                mult = config->pll3_mult;
        } else if (!strcmp(name, "lb")) {
-               parent_name = "pll1_div2";
+               parent_name = "pll1";
                div = cpg_mode & BIT(18) ? 36 : 24;
        } else if (!strcmp(name, "qspi")) {
                parent_name = "pll1_div2";
                div = (cpg_mode & (BIT(3) | BIT(2) | BIT(1))) == BIT(2)
                    ? 8 : 10;
        } else if (!strcmp(name, "sdh")) {
-               parent_name = "pll1_div2";
+               parent_name = "pll1";
                table = cpg_sdh_div_table;
                shift = 8;
        } else if (!strcmp(name, "sd0")) {
-               parent_name = "pll1_div2";
+               parent_name = "pll1";
                table = cpg_sd01_div_table;
                shift = 4;
        } else if (!strcmp(name, "sd1")) {
-               parent_name = "pll1_div2";
+               parent_name = "pll1";
                table = cpg_sd01_div_table;
                shift = 0;
        } else if (!strcmp(name, "z")) {
diff --git a/drivers/clk/shmobile/clk-rz.c b/drivers/clk/shmobile/clk-rz.c
new file mode 100644 (file)
index 0000000..7e68e86
--- /dev/null
@@ -0,0 +1,103 @@
+/*
+ * rz Core CPG Clocks
+ *
+ * Copyright (C) 2013 Ideas On Board SPRL
+ * Copyright (C) 2014 Wolfram Sang, Sang Engineering <wsa@sang-engineering.com>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; version 2 of the License.
+ */
+
+#include <linux/clk-provider.h>
+#include <linux/init.h>
+#include <linux/kernel.h>
+#include <linux/of.h>
+#include <linux/of_address.h>
+#include <linux/slab.h>
+
+struct rz_cpg {
+       struct clk_onecell_data data;
+       void __iomem *reg;
+};
+
+#define CPG_FRQCR      0x10
+#define CPG_FRQCR2     0x14
+
+/* -----------------------------------------------------------------------------
+ * Initialization
+ */
+
+static struct clk * __init
+rz_cpg_register_clock(struct device_node *np, struct rz_cpg *cpg, const char *name)
+{
+       u32 val;
+       unsigned mult;
+       static const unsigned frqcr_tab[4] = { 3, 2, 0, 1 };
+
+       if (strcmp(name, "pll") == 0) {
+               /* FIXME: cpg_mode should be read from GPIO. But no GPIO support yet */
+               unsigned cpg_mode = 0; /* hardcoded to EXTAL for now */
+               const char *parent_name = of_clk_get_parent_name(np, cpg_mode);
+
+               mult = cpg_mode ? (32 / 4) : 30;
+
+               return clk_register_fixed_factor(NULL, name, parent_name, 0, mult, 1);
+       }
+
+       /* If mapping regs failed, skip non-pll clocks. System will boot anyhow */
+       if (!cpg->reg)
+               return ERR_PTR(-ENXIO);
+
+       /* FIXME:"i" and "g" are variable clocks with non-integer dividers (e.g. 2/3)
+        * and the constraint that always g <= i. To get the rz platform started,
+        * let them run at fixed current speed and implement the details later.
+        */
+       if (strcmp(name, "i") == 0)
+               val = (clk_readl(cpg->reg + CPG_FRQCR) >> 8) & 3;
+       else if (strcmp(name, "g") == 0)
+               val = clk_readl(cpg->reg + CPG_FRQCR2) & 3;
+       else
+               return ERR_PTR(-EINVAL);
+
+       mult = frqcr_tab[val];
+       return clk_register_fixed_factor(NULL, name, "pll", 0, mult, 3);
+}
+
+static void __init rz_cpg_clocks_init(struct device_node *np)
+{
+       struct rz_cpg *cpg;
+       struct clk **clks;
+       unsigned i;
+       int num_clks;
+
+       num_clks = of_property_count_strings(np, "clock-output-names");
+       if (WARN(num_clks <= 0, "can't count CPG clocks\n"))
+               return;
+
+       cpg = kzalloc(sizeof(*cpg), GFP_KERNEL);
+       clks = kzalloc(num_clks * sizeof(*clks), GFP_KERNEL);
+       BUG_ON(!cpg || !clks);
+
+       cpg->data.clks = clks;
+       cpg->data.clk_num = num_clks;
+
+       cpg->reg = of_iomap(np, 0);
+
+       for (i = 0; i < num_clks; ++i) {
+               const char *name;
+               struct clk *clk;
+
+               of_property_read_string_index(np, "clock-output-names", i, &name);
+
+               clk = rz_cpg_register_clock(np, cpg, name);
+               if (IS_ERR(clk))
+                       pr_err("%s: failed to register %s %s clock (%ld)\n",
+                              __func__, np->name, name, PTR_ERR(clk));
+               else
+                       cpg->data.clks[i] = clk;
+       }
+
+       of_clk_add_provider(np, of_clk_src_onecell_get, &cpg->data);
+}
+CLK_OF_DECLARE(rz_cpg_clks, "renesas,rz-cpg-clocks", rz_cpg_clocks_init);
index cd6950f..52e9329 100644 (file)
@@ -140,3 +140,51 @@ config VF_PIT_TIMER
        bool
        help
          Support for Period Interrupt Timer on Freescale Vybrid Family SoCs.
+
+config SYS_SUPPORTS_SH_CMT
+        bool
+
+config SYS_SUPPORTS_SH_MTU2
+        bool
+
+config SYS_SUPPORTS_SH_TMU
+        bool
+
+config SYS_SUPPORTS_EM_STI
+        bool
+
+config SH_TIMER_CMT
+       bool "Renesas CMT timer driver" if COMPILE_TEST
+       depends on GENERIC_CLOCKEVENTS
+       default SYS_SUPPORTS_SH_CMT
+       help
+         This enables build of a clocksource and clockevent driver for
+         the Compare Match Timer (CMT) hardware available in 16/32/48-bit
+         variants on a wide range of Mobile and Automotive SoCs from Renesas.
+
+config SH_TIMER_MTU2
+       bool "Renesas MTU2 timer driver" if COMPILE_TEST
+       depends on GENERIC_CLOCKEVENTS
+       default SYS_SUPPORTS_SH_MTU2
+       help
+         This enables build of a clockevent driver for the Multi-Function
+         Timer Pulse Unit 2 (TMU2) hardware available on SoCs from Renesas.
+         This hardware comes with 16 bit-timer registers.
+
+config SH_TIMER_TMU
+       bool "Renesas TMU timer driver" if COMPILE_TEST
+       depends on GENERIC_CLOCKEVENTS
+       default SYS_SUPPORTS_SH_TMU
+       help
+         This enables build of a clocksource and clockevent driver for
+         the 32-bit Timer Unit (TMU) hardware available on a wide range
+         SoCs from Renesas.
+
+config EM_TIMER_STI
+       bool "Renesas STI timer driver" if COMPILE_TEST
+       depends on GENERIC_CLOCKEVENTS
+       default SYS_SUPPORTS_EM_STI
+       help
+         This enables build of a clocksource and clockevent driver for
+         the 48-bit System Timer (STI) hardware available on a SoCs
+         such as EMEV2 from former NEC Electronics.
index 95fb944..01469a4 100644 (file)
@@ -296,6 +296,21 @@ static void __arch_timer_setup(unsigned type,
        clockevents_config_and_register(clk, arch_timer_rate, 0xf, 0x7fffffff);
 }
 
+static void arch_timer_evtstrm_enable(int divider)
+{
+       u32 cntkctl = arch_timer_get_cntkctl();
+
+       cntkctl &= ~ARCH_TIMER_EVT_TRIGGER_MASK;
+       /* Set the divider and enable virtual event stream */
+       cntkctl |= (divider << ARCH_TIMER_EVT_TRIGGER_SHIFT)
+                       | ARCH_TIMER_VIRT_EVT_EN;
+       arch_timer_set_cntkctl(cntkctl);
+       elf_hwcap |= HWCAP_EVTSTRM;
+#ifdef CONFIG_COMPAT
+       compat_elf_hwcap |= COMPAT_HWCAP_EVTSTRM;
+#endif
+}
+
 static void arch_timer_configure_evtstream(void)
 {
        int evt_stream_div, pos;
@@ -309,6 +324,23 @@ static void arch_timer_configure_evtstream(void)
        arch_timer_evtstrm_enable(min(pos, 15));
 }
 
+static void arch_counter_set_user_access(void)
+{
+       u32 cntkctl = arch_timer_get_cntkctl();
+
+       /* Disable user access to the timers and the physical counter */
+       /* Also disable virtual event stream */
+       cntkctl &= ~(ARCH_TIMER_USR_PT_ACCESS_EN
+                       | ARCH_TIMER_USR_VT_ACCESS_EN
+                       | ARCH_TIMER_VIRT_EVT_EN
+                       | ARCH_TIMER_USR_PCT_ACCESS_EN);
+
+       /* Enable user access to the virtual counter */
+       cntkctl |= ARCH_TIMER_USR_VCT_ACCESS_EN;
+
+       arch_timer_set_cntkctl(cntkctl);
+}
+
 static int arch_timer_setup(struct clock_event_device *clk)
 {
        __arch_timer_setup(ARCH_CP15_TIMER, clk);
index 0b1836a..2bd13b5 100644 (file)
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  */
 
+#include <linux/clk.h>
+#include <linux/clockchips.h>
+#include <linux/clocksource.h>
+#include <linux/delay.h>
+#include <linux/err.h>
 #include <linux/init.h>
-#include <linux/platform_device.h>
-#include <linux/spinlock.h>
 #include <linux/interrupt.h>
-#include <linux/ioport.h>
 #include <linux/io.h>
-#include <linux/clk.h>
+#include <linux/ioport.h>
 #include <linux/irq.h>
-#include <linux/err.h>
-#include <linux/delay.h>
-#include <linux/clocksource.h>
-#include <linux/clockchips.h>
-#include <linux/sh_timer.h>
-#include <linux/slab.h>
 #include <linux/module.h>
+#include <linux/of.h>
+#include <linux/platform_device.h>
 #include <linux/pm_domain.h>
 #include <linux/pm_runtime.h>
+#include <linux/sh_timer.h>
+#include <linux/slab.h>
+#include <linux/spinlock.h>
+
+struct sh_cmt_device;
+
+/*
+ * The CMT comes in 5 different identified flavours, depending not only on the
+ * SoC but also on the particular instance. The following table lists the main
+ * characteristics of those flavours.
+ *
+ *                     16B     32B     32B-F   48B     48B-2
+ * -----------------------------------------------------------------------------
+ * Channels            2       1/4     1       6       2/8
+ * Control Width       16      16      16      16      32
+ * Counter Width       16      32      32      32/48   32/48
+ * Shared Start/Stop   Y       Y       Y       Y       N
+ *
+ * The 48-bit gen2 version has a per-channel start/stop register located in the
+ * channel registers block. All other versions have a shared start/stop register
+ * located in the global space.
+ *
+ * Channels are indexed from 0 to N-1 in the documentation. The channel index
+ * infers the start/stop bit position in the control register and the channel
+ * registers block address. Some CMT instances have a subset of channels
+ * available, in which case the index in the documentation doesn't match the
+ * "real" index as implemented in hardware. This is for instance the case with
+ * CMT0 on r8a7740, which is a 32-bit variant with a single channel numbered 0
+ * in the documentation but using start/stop bit 5 and having its registers
+ * block at 0x60.
+ *
+ * Similarly CMT0 on r8a73a4, r8a7790 and r8a7791, while implementing 32-bit
+ * channels only, is a 48-bit gen2 CMT with the 48-bit channels unavailable.
+ */
+
+enum sh_cmt_model {
+       SH_CMT_16BIT,
+       SH_CMT_32BIT,
+       SH_CMT_32BIT_FAST,
+       SH_CMT_48BIT,
+       SH_CMT_48BIT_GEN2,
+};
+
+struct sh_cmt_info {
+       enum sh_cmt_model model;
 
-struct sh_cmt_priv {
-       void __iomem *mapbase;
-       void __iomem *mapbase_str;
-       struct clk *clk;
        unsigned long width; /* 16 or 32 bit version of hardware block */
        unsigned long overflow_bit;
        unsigned long clear_bits;
-       struct irqaction irqaction;
-       struct platform_device *pdev;
 
+       /* callbacks for CMSTR and CMCSR access */
+       unsigned long (*read_control)(void __iomem *base, unsigned long offs);
+       void (*write_control)(void __iomem *base, unsigned long offs,
+                             unsigned long value);
+
+       /* callbacks for CMCNT and CMCOR access */
+       unsigned long (*read_count)(void __iomem *base, unsigned long offs);
+       void (*write_count)(void __iomem *base, unsigned long offs,
+                           unsigned long value);
+};
+
+struct sh_cmt_channel {
+       struct sh_cmt_device *cmt;
+
+       unsigned int index;     /* Index in the documentation */
+       unsigned int hwidx;     /* Real hardware index */
+
+       void __iomem *iostart;
+       void __iomem *ioctrl;
+
+       unsigned int timer_bit;
        unsigned long flags;
        unsigned long match_value;
        unsigned long next_match_value;
@@ -55,38 +109,53 @@ struct sh_cmt_priv {
        struct clocksource cs;
        unsigned long total_cycles;
        bool cs_enabled;
+};
 
-       /* callbacks for CMSTR and CMCSR access */
-       unsigned long (*read_control)(void __iomem *base, unsigned long offs);
-       void (*write_control)(void __iomem *base, unsigned long offs,
-                             unsigned long value);
+struct sh_cmt_device {
+       struct platform_device *pdev;
 
-       /* callbacks for CMCNT and CMCOR access */
-       unsigned long (*read_count)(void __iomem *base, unsigned long offs);
-       void (*write_count)(void __iomem *base, unsigned long offs,
-                           unsigned long value);
+       const struct sh_cmt_info *info;
+
+       void __iomem *mapbase;
+       struct clk *clk;
+
+       raw_spinlock_t lock; /* Protect the shared start/stop register */
+
+       struct sh_cmt_channel *channels;
+       unsigned int num_channels;
+       unsigned int hw_channels;
+
+       bool has_clockevent;
+       bool has_clocksource;
 };
 
-/* Examples of supported CMT timer register layouts and I/O access widths:
- *
- * "16-bit counter and 16-bit control" as found on sh7263:
- * CMSTR 0xfffec000 16-bit
- * CMCSR 0xfffec002 16-bit
- * CMCNT 0xfffec004 16-bit
- * CMCOR 0xfffec006 16-bit
- *
- * "32-bit counter and 16-bit control" as found on sh7372, sh73a0, r8a7740:
- * CMSTR 0xffca0000 16-bit
- * CMCSR 0xffca0060 16-bit
- * CMCNT 0xffca0064 32-bit
- * CMCOR 0xffca0068 32-bit
- *
- * "32-bit counter and 32-bit control" as found on r8a73a4 and r8a7790:
- * CMSTR 0xffca0500 32-bit
- * CMCSR 0xffca0510 32-bit
- * CMCNT 0xffca0514 32-bit
- * CMCOR 0xffca0518 32-bit
- */
+#define SH_CMT16_CMCSR_CMF             (1 << 7)
+#define SH_CMT16_CMCSR_CMIE            (1 << 6)
+#define SH_CMT16_CMCSR_CKS8            (0 << 0)
+#define SH_CMT16_CMCSR_CKS32           (1 << 0)
+#define SH_CMT16_CMCSR_CKS128          (2 << 0)
+#define SH_CMT16_CMCSR_CKS512          (3 << 0)
+#define SH_CMT16_CMCSR_CKS_MASK                (3 << 0)
+
+#define SH_CMT32_CMCSR_CMF             (1 << 15)
+#define SH_CMT32_CMCSR_OVF             (1 << 14)
+#define SH_CMT32_CMCSR_WRFLG           (1 << 13)
+#define SH_CMT32_CMCSR_STTF            (1 << 12)
+#define SH_CMT32_CMCSR_STPF            (1 << 11)
+#define SH_CMT32_CMCSR_SSIE            (1 << 10)
+#define SH_CMT32_CMCSR_CMS             (1 << 9)
+#define SH_CMT32_CMCSR_CMM             (1 << 8)
+#define SH_CMT32_CMCSR_CMTOUT_IE       (1 << 7)
+#define SH_CMT32_CMCSR_CMR_NONE                (0 << 4)
+#define SH_CMT32_CMCSR_CMR_DMA         (1 << 4)
+#define SH_CMT32_CMCSR_CMR_IRQ         (2 << 4)
+#define SH_CMT32_CMCSR_CMR_MASK                (3 << 4)
+#define SH_CMT32_CMCSR_DBGIVD          (1 << 3)
+#define SH_CMT32_CMCSR_CKS_RCLK8       (4 << 0)
+#define SH_CMT32_CMCSR_CKS_RCLK32      (5 << 0)
+#define SH_CMT32_CMCSR_CKS_RCLK128     (6 << 0)
+#define SH_CMT32_CMCSR_CKS_RCLK1       (7 << 0)
+#define SH_CMT32_CMCSR_CKS_MASK                (7 << 0)
 
 static unsigned long sh_cmt_read16(void __iomem *base, unsigned long offs)
 {
@@ -110,64 +179,123 @@ static void sh_cmt_write32(void __iomem *base, unsigned long offs,
        iowrite32(value, base + (offs << 2));
 }
 
+static const struct sh_cmt_info sh_cmt_info[] = {
+       [SH_CMT_16BIT] = {
+               .model = SH_CMT_16BIT,
+               .width = 16,
+               .overflow_bit = SH_CMT16_CMCSR_CMF,
+               .clear_bits = ~SH_CMT16_CMCSR_CMF,
+               .read_control = sh_cmt_read16,
+               .write_control = sh_cmt_write16,
+               .read_count = sh_cmt_read16,
+               .write_count = sh_cmt_write16,
+       },
+       [SH_CMT_32BIT] = {
+               .model = SH_CMT_32BIT,
+               .width = 32,
+               .overflow_bit = SH_CMT32_CMCSR_CMF,
+               .clear_bits = ~(SH_CMT32_CMCSR_CMF | SH_CMT32_CMCSR_OVF),
+               .read_control = sh_cmt_read16,
+               .write_control = sh_cmt_write16,
+               .read_count = sh_cmt_read32,
+               .write_count = sh_cmt_write32,
+       },
+       [SH_CMT_32BIT_FAST] = {
+               .model = SH_CMT_32BIT_FAST,
+               .width = 32,
+               .overflow_bit = SH_CMT32_CMCSR_CMF,
+               .clear_bits = ~(SH_CMT32_CMCSR_CMF | SH_CMT32_CMCSR_OVF),
+               .read_control = sh_cmt_read16,
+               .write_control = sh_cmt_write16,
+               .read_count = sh_cmt_read32,
+               .write_count = sh_cmt_write32,
+       },
+       [SH_CMT_48BIT] = {
+               .model = SH_CMT_48BIT,
+               .width = 32,
+               .overflow_bit = SH_CMT32_CMCSR_CMF,
+               .clear_bits = ~(SH_CMT32_CMCSR_CMF | SH_CMT32_CMCSR_OVF),
+               .read_control = sh_cmt_read32,
+               .write_control = sh_cmt_write32,
+               .read_count = sh_cmt_read32,
+               .write_count = sh_cmt_write32,
+       },
+       [SH_CMT_48BIT_GEN2] = {
+               .model = SH_CMT_48BIT_GEN2,
+               .width = 32,
+               .overflow_bit = SH_CMT32_CMCSR_CMF,
+               .clear_bits = ~(SH_CMT32_CMCSR_CMF | SH_CMT32_CMCSR_OVF),
+               .read_control = sh_cmt_read32,
+               .write_control = sh_cmt_write32,
+               .read_count = sh_cmt_read32,
+               .write_count = sh_cmt_write32,
+       },
+};
+
 #define CMCSR 0 /* channel register */
 #define CMCNT 1 /* channel register */
 #define CMCOR 2 /* channel register */
 
-static inline unsigned long sh_cmt_read_cmstr(struct sh_cmt_priv *p)
+static inline unsigned long sh_cmt_read_cmstr(struct sh_cmt_channel *ch)
 {
-       return p->read_control(p->mapbase_str, 0);
+       if (ch->iostart)
+               return ch->cmt->info->read_control(ch->iostart, 0);
+       else
+               return ch->cmt->info->read_control(ch->cmt->mapbase, 0);
 }
 
-static inline unsigned long sh_cmt_read_cmcsr(struct sh_cmt_priv *p)
+static inline void sh_cmt_write_cmstr(struct sh_cmt_channel *ch,
+                                     unsigned long value)
 {
-       return p->read_control(p->mapbase, CMCSR);
+       if (ch->iostart)
+               ch->cmt->info->write_control(ch->iostart, 0, value);
+       else
+               ch->cmt->info->write_control(ch->cmt->mapbase, 0, value);
 }
 
-static inline unsigned long sh_cmt_read_cmcnt(struct sh_cmt_priv *p)
+static inline unsigned long sh_cmt_read_cmcsr(struct sh_cmt_channel *ch)
 {
-       return p->read_count(p->mapbase, CMCNT);
+       return ch->cmt->info->read_control(ch->ioctrl, CMCSR);
 }
 
-static inline void sh_cmt_write_cmstr(struct sh_cmt_priv *p,
+static inline void sh_cmt_write_cmcsr(struct sh_cmt_channel *ch,
                                      unsigned long value)
 {
-       p->write_control(p->mapbase_str, 0, value);
+       ch->cmt->info->write_control(ch->ioctrl, CMCSR, value);
 }
 
-static inline void sh_cmt_write_cmcsr(struct sh_cmt_priv *p,
-                                     unsigned long value)
+static inline unsigned long sh_cmt_read_cmcnt(struct sh_cmt_channel *ch)
 {
-       p->write_control(p->mapbase, CMCSR, value);
+       return ch->cmt->info->read_count(ch->ioctrl, CMCNT);
 }
 
-static inline void sh_cmt_write_cmcnt(struct sh_cmt_priv *p,
+static inline void sh_cmt_write_cmcnt(struct sh_cmt_channel *ch,
                                      unsigned long value)
 {
-       p->write_count(p->mapbase, CMCNT, value);
+       ch->cmt->info->write_count(ch->ioctrl, CMCNT, value);
 }
 
-static inline void sh_cmt_write_cmcor(struct sh_cmt_priv *p,
+static inline void sh_cmt_write_cmcor(struct sh_cmt_channel *ch,
                                      unsigned long value)
 {
-       p->write_count(p->mapbase, CMCOR, value);
+       ch->cmt->info->write_count(ch->ioctrl, CMCOR, value);
 }
 
-static unsigned long sh_cmt_get_counter(struct sh_cmt_priv *p,
+static unsigned long sh_cmt_get_counter(struct sh_cmt_channel *ch,
                                        int *has_wrapped)
 {
        unsigned long v1, v2, v3;
        int o1, o2;
 
-       o1 = sh_cmt_read_cmcsr(p) & p->overflow_bit;
+       o1 = sh_cmt_read_cmcsr(ch) & ch->cmt->info->overflow_bit;
 
        /* Make sure the timer value is stable. Stolen from acpi_pm.c */
        do {
                o2 = o1;
-               v1 = sh_cmt_read_cmcnt(p);
-               v2 = sh_cmt_read_cmcnt(p);
-               v3 = sh_cmt_read_cmcnt(p);
-               o1 = sh_cmt_read_cmcsr(p) & p->overflow_bit;
+               v1 = sh_cmt_read_cmcnt(ch);
+               v2 = sh_cmt_read_cmcnt(ch);
+               v3 = sh_cmt_read_cmcnt(ch);
+               o1 = sh_cmt_read_cmcsr(ch) & ch->cmt->info->overflow_bit;
        } while (unlikely((o1 != o2) || (v1 > v2 && v1 < v3)
                          || (v2 > v3 && v2 < v1) || (v3 > v1 && v3 < v2)));
 
@@ -175,54 +303,56 @@ static unsigned long sh_cmt_get_counter(struct sh_cmt_priv *p,
        return v2;
 }
 
-static DEFINE_RAW_SPINLOCK(sh_cmt_lock);
-
-static void sh_cmt_start_stop_ch(struct sh_cmt_priv *p, int start)
+static void sh_cmt_start_stop_ch(struct sh_cmt_channel *ch, int start)
 {
-       struct sh_timer_config *cfg = p->pdev->dev.platform_data;
        unsigned long flags, value;
 
        /* start stop register shared by multiple timer channels */
-       raw_spin_lock_irqsave(&sh_cmt_lock, flags);
-       value = sh_cmt_read_cmstr(p);
+       raw_spin_lock_irqsave(&ch->cmt->lock, flags);
+       value = sh_cmt_read_cmstr(ch);
 
        if (start)
-               value |= 1 << cfg->timer_bit;
+               value |= 1 << ch->timer_bit;
        else
-               value &= ~(1 << cfg->timer_bit);
+               value &= ~(1 << ch->timer_bit);
 
-       sh_cmt_write_cmstr(p, value);
-       raw_spin_unlock_irqrestore(&sh_cmt_lock, flags);
+       sh_cmt_write_cmstr(ch, value);
+       raw_spin_unlock_irqrestore(&ch->cmt->lock, flags);
 }
 
-static int sh_cmt_enable(struct sh_cmt_priv *p, unsigned long *rate)
+static int sh_cmt_enable(struct sh_cmt_channel *ch, unsigned long *rate)
 {
        int k, ret;
 
-       pm_runtime_get_sync(&p->pdev->dev);
-       dev_pm_syscore_device(&p->pdev->dev, true);
+       pm_runtime_get_sync(&ch->cmt->pdev->dev);
+       dev_pm_syscore_device(&ch->cmt->pdev->dev, true);
 
        /* enable clock */
-       ret = clk_enable(p->clk);
+       ret = clk_enable(ch->cmt->clk);
        if (ret) {
-               dev_err(&p->pdev->dev, "cannot enable clock\n");
+               dev_err(&ch->cmt->pdev->dev, "ch%u: cannot enable clock\n",
+                       ch->index);
                goto err0;
        }
 
        /* make sure channel is disabled */
-       sh_cmt_start_stop_ch(p, 0);
+       sh_cmt_start_stop_ch(ch, 0);
 
        /* configure channel, periodic mode and maximum timeout */
-       if (p->width == 16) {
-               *rate = clk_get_rate(p->clk) / 512;
-               sh_cmt_write_cmcsr(p, 0x43);
+       if (ch->cmt->info->width == 16) {
+               *rate = clk_get_rate(ch->cmt->clk) / 512;
+               sh_cmt_write_cmcsr(ch, SH_CMT16_CMCSR_CMIE |
+                                  SH_CMT16_CMCSR_CKS512);
        } else {
-               *rate = clk_get_rate(p->clk) / 8;
-               sh_cmt_write_cmcsr(p, 0x01a4);
+               *rate = clk_get_rate(ch->cmt->clk) / 8;
+               sh_cmt_write_cmcsr(ch, SH_CMT32_CMCSR_CMM |
+                                  SH_CMT32_CMCSR_CMTOUT_IE |
+                                  SH_CMT32_CMCSR_CMR_IRQ |
+                                  SH_CMT32_CMCSR_CKS_RCLK8);
        }
 
-       sh_cmt_write_cmcor(p, 0xffffffff);
-       sh_cmt_write_cmcnt(p, 0);
+       sh_cmt_write_cmcor(ch, 0xffffffff);
+       sh_cmt_write_cmcnt(ch, 0);
 
        /*
         * According to the sh73a0 user's manual, as CMCNT can be operated
@@ -236,41 +366,42 @@ static int sh_cmt_enable(struct sh_cmt_priv *p, unsigned long *rate)
         * take RCLKx2 at maximum.
         */
        for (k = 0; k < 100; k++) {
-               if (!sh_cmt_read_cmcnt(p))
+               if (!sh_cmt_read_cmcnt(ch))
                        break;
                udelay(1);
        }
 
-       if (sh_cmt_read_cmcnt(p)) {
-               dev_err(&p->pdev->dev, "cannot clear CMCNT\n");
+       if (sh_cmt_read_cmcnt(ch)) {
+               dev_err(&ch->cmt->pdev->dev, "ch%u: cannot clear CMCNT\n",
+                       ch->index);
                ret = -ETIMEDOUT;
                goto err1;
        }
 
        /* enable channel */
-       sh_cmt_start_stop_ch(p, 1);
+       sh_cmt_start_stop_ch(ch, 1);
        return 0;
  err1:
        /* stop clock */
-       clk_disable(p->clk);
+       clk_disable(ch->cmt->clk);
 
  err0:
        return ret;
 }
 
-static void sh_cmt_disable(struct sh_cmt_priv *p)
+static void sh_cmt_disable(struct sh_cmt_channel *ch)
 {
        /* disable channel */
-       sh_cmt_start_stop_ch(p, 0);
+       sh_cmt_start_stop_ch(ch, 0);
 
        /* disable interrupts in CMT block */
-       sh_cmt_write_cmcsr(p, 0);
+       sh_cmt_write_cmcsr(ch, 0);
 
        /* stop clock */
-       clk_disable(p->clk);
+       clk_disable(ch->cmt->clk);
 
-       dev_pm_syscore_device(&p->pdev->dev, false);
-       pm_runtime_put(&p->pdev->dev);
+       dev_pm_syscore_device(&ch->cmt->pdev->dev, false);
+       pm_runtime_put(&ch->cmt->pdev->dev);
 }
 
 /* private flags */
@@ -280,24 +411,24 @@ static void sh_cmt_disable(struct sh_cmt_priv *p)
 #define FLAG_SKIPEVENT (1 << 3)
 #define FLAG_IRQCONTEXT (1 << 4)
 
-static void sh_cmt_clock_event_program_verify(struct sh_cmt_priv *p,
+static void sh_cmt_clock_event_program_verify(struct sh_cmt_channel *ch,
                                              int absolute)
 {
        unsigned long new_match;
-       unsigned long value = p->next_match_value;
+       unsigned long value = ch->next_match_value;
        unsigned long delay = 0;
        unsigned long now = 0;
        int has_wrapped;
 
-       now = sh_cmt_get_counter(p, &has_wrapped);
-       p->flags |= FLAG_REPROGRAM; /* force reprogram */
+       now = sh_cmt_get_counter(ch, &has_wrapped);
+       ch->flags |= FLAG_REPROGRAM; /* force reprogram */
 
        if (has_wrapped) {
                /* we're competing with the interrupt handler.
                 *  -> let the interrupt handler reprogram the timer.
                 *  -> interrupt number two handles the event.
                 */
-               p->flags |= FLAG_SKIPEVENT;
+               ch->flags |= FLAG_SKIPEVENT;
                return;
        }
 
@@ -309,20 +440,20 @@ static void sh_cmt_clock_event_program_verify(struct sh_cmt_priv *p,
                 * but don't save the new match value yet.
                 */
                new_match = now + value + delay;
-               if (new_match > p->max_match_value)
-                       new_match = p->max_match_value;
+               if (new_match > ch->max_match_value)
+                       new_match = ch->max_match_value;
 
-               sh_cmt_write_cmcor(p, new_match);
+               sh_cmt_write_cmcor(ch, new_match);
 
-               now = sh_cmt_get_counter(p, &has_wrapped);
-               if (has_wrapped && (new_match > p->match_value)) {
+               now = sh_cmt_get_counter(ch, &has_wrapped);
+               if (has_wrapped && (new_match > ch->match_value)) {
                        /* we are changing to a greater match value,
                         * so this wrap must be caused by the counter
                         * matching the old value.
                         * -> first interrupt reprograms the timer.
                         * -> interrupt number two handles the event.
                         */
-                       p->flags |= FLAG_SKIPEVENT;
+                       ch->flags |= FLAG_SKIPEVENT;
                        break;
                }
 
@@ -333,7 +464,7 @@ static void sh_cmt_clock_event_program_verify(struct sh_cmt_priv *p,
                         * -> save programmed match value.
                         * -> let isr handle the event.
                         */
-                       p->match_value = new_match;
+                       ch->match_value = new_match;
                        break;
                }
 
@@ -344,7 +475,7 @@ static void sh_cmt_clock_event_program_verify(struct sh_cmt_priv *p,
                         * -> save programmed match value.
                         * -> let isr handle the event.
                         */
-                       p->match_value = new_match;
+                       ch->match_value = new_match;
                        break;
                }
 
@@ -360,138 +491,141 @@ static void sh_cmt_clock_event_program_verify(struct sh_cmt_priv *p,
                        delay = 1;
 
                if (!delay)
-                       dev_warn(&p->pdev->dev, "too long delay\n");
+                       dev_warn(&ch->cmt->pdev->dev, "ch%u: too long delay\n",
+                                ch->index);
 
        } while (delay);
 }
 
-static void __sh_cmt_set_next(struct sh_cmt_priv *p, unsigned long delta)
+static void __sh_cmt_set_next(struct sh_cmt_channel *ch, unsigned long delta)
 {
-       if (delta > p->max_match_value)
-               dev_warn(&p->pdev->dev, "delta out of range\n");
+       if (delta > ch->max_match_value)
+               dev_warn(&ch->cmt->pdev->dev, "ch%u: delta out of range\n",
+                        ch->index);
 
-       p->next_match_value = delta;
-       sh_cmt_clock_event_program_verify(p, 0);
+       ch->next_match_value = delta;
+       sh_cmt_clock_event_program_verify(ch, 0);
 }
 
-static void sh_cmt_set_next(struct sh_cmt_priv *p, unsigned long delta)
+static void sh_cmt_set_next(struct sh_cmt_channel *ch, unsigned long delta)
 {
        unsigned long flags;
 
-       raw_spin_lock_irqsave(&p->lock, flags);
-       __sh_cmt_set_next(p, delta);
-       raw_spin_unlock_irqrestore(&p->lock, flags);
+       raw_spin_lock_irqsave(&ch->lock, flags);
+       __sh_cmt_set_next(ch, delta);
+       raw_spin_unlock_irqrestore(&ch->lock, flags);
 }
 
 static irqreturn_t sh_cmt_interrupt(int irq, void *dev_id)
 {
-       struct sh_cmt_priv *p = dev_id;
+       struct sh_cmt_channel *ch = dev_id;
 
        /* clear flags */
-       sh_cmt_write_cmcsr(p, sh_cmt_read_cmcsr(p) & p->clear_bits);
+       sh_cmt_write_cmcsr(ch, sh_cmt_read_cmcsr(ch) &
+                          ch->cmt->info->clear_bits);
 
        /* update clock source counter to begin with if enabled
         * the wrap flag should be cleared by the timer specific
         * isr before we end up here.
         */
-       if (p->flags & FLAG_CLOCKSOURCE)
-               p->total_cycles += p->match_value + 1;
+       if (ch->flags & FLAG_CLOCKSOURCE)
+               ch->total_cycles += ch->match_value + 1;
 
-       if (!(p->flags & FLAG_REPROGRAM))
-               p->next_match_value = p->max_match_value;
+       if (!(ch->flags & FLAG_REPROGRAM))
+               ch->next_match_value = ch->max_match_value;
 
-       p->flags |= FLAG_IRQCONTEXT;
+       ch->flags |= FLAG_IRQCONTEXT;
 
-       if (p->flags & FLAG_CLOCKEVENT) {
-               if (!(p->flags & FLAG_SKIPEVENT)) {
-                       if (p->ced.mode == CLOCK_EVT_MODE_ONESHOT) {
-                               p->next_match_value = p->max_match_value;
-                               p->flags |= FLAG_REPROGRAM;
+       if (ch->flags & FLAG_CLOCKEVENT) {
+               if (!(ch->flags & FLAG_SKIPEVENT)) {
+                       if (ch->ced.mode == CLOCK_EVT_MODE_ONESHOT) {
+                               ch->next_match_value = ch->max_match_value;
+                               ch->flags |= FLAG_REPROGRAM;
                        }
 
-                       p->ced.event_handler(&p->ced);
+                       ch->ced.event_handler(&ch->ced);
                }
        }
 
-       p->flags &= ~FLAG_SKIPEVENT;
+       ch->flags &= ~FLAG_SKIPEVENT;
 
-       if (p->flags & FLAG_REPROGRAM) {
-               p->flags &= ~FLAG_REPROGRAM;
-               sh_cmt_clock_event_program_verify(p, 1);
+       if (ch->flags & FLAG_REPROGRAM) {
+               ch->flags &= ~FLAG_REPROGRAM;
+               sh_cmt_clock_event_program_verify(ch, 1);
 
-               if (p->flags & FLAG_CLOCKEVENT)
-                       if ((p->ced.mode == CLOCK_EVT_MODE_SHUTDOWN)
-                           || (p->match_value == p->next_match_value))
-                               p->flags &= ~FLAG_REPROGRAM;
+               if (ch->flags & FLAG_CLOCKEVENT)
+                       if ((ch->ced.mode == CLOCK_EVT_MODE_SHUTDOWN)
+                           || (ch->match_value == ch->next_match_value))
+                               ch->flags &= ~FLAG_REPROGRAM;
        }
 
-       p->flags &= ~FLAG_IRQCONTEXT;
+       ch->flags &= ~FLAG_IRQCONTEXT;
 
        return IRQ_HANDLED;
 }
 
-static int sh_cmt_start(struct sh_cmt_priv *p, unsigned long flag)
+static int sh_cmt_start(struct sh_cmt_channel *ch, unsigned long flag)
 {
        int ret = 0;
        unsigned long flags;
 
-       raw_spin_lock_irqsave(&p->lock, flags);
+       raw_spin_lock_irqsave(&ch->lock, flags);
 
-       if (!(p->flags & (FLAG_CLOCKEVENT | FLAG_CLOCKSOURCE)))
-               ret = sh_cmt_enable(p, &p->rate);
+       if (!(ch->flags & (FLAG_CLOCKEVENT | FLAG_CLOCKSOURCE)))
+               ret = sh_cmt_enable(ch, &ch->rate);
 
        if (ret)
                goto out;
-       p->flags |= flag;
+       ch->flags |= flag;
 
        /* setup timeout if no clockevent */
-       if ((flag == FLAG_CLOCKSOURCE) && (!(p->flags & FLAG_CLOCKEVENT)))
-               __sh_cmt_set_next(p, p->max_match_value);
+       if ((flag == FLAG_CLOCKSOURCE) && (!(ch->flags & FLAG_CLOCKEVENT)))
+               __sh_cmt_set_next(ch, ch->max_match_value);
  out:
-       raw_spin_unlock_irqrestore(&p->lock, flags);
+       raw_spin_unlock_irqrestore(&ch->lock, flags);
 
        return ret;
 }
 
-static void sh_cmt_stop(struct sh_cmt_priv *p, unsigned long flag)
+static void sh_cmt_stop(struct sh_cmt_channel *ch, unsigned long flag)
 {
        unsigned long flags;
        unsigned long f;
 
-       raw_spin_lock_irqsave(&p->lock, flags);
+       raw_spin_lock_irqsave(&ch->lock, flags);
 
-       f = p->flags & (FLAG_CLOCKEVENT | FLAG_CLOCKSOURCE);
-       p->flags &= ~flag;
+       f = ch->flags & (FLAG_CLOCKEVENT | FLAG_CLOCKSOURCE);
+       ch->flags &= ~flag;
 
-       if (f && !(p->flags & (FLAG_CLOCKEVENT | FLAG_CLOCKSOURCE)))
-               sh_cmt_disable(p);
+       if (f && !(ch->flags & (FLAG_CLOCKEVENT | FLAG_CLOCKSOURCE)))
+               sh_cmt_disable(ch);
 
        /* adjust the timeout to maximum if only clocksource left */
-       if ((flag == FLAG_CLOCKEVENT) && (p->flags & FLAG_CLOCKSOURCE))
-               __sh_cmt_set_next(p, p->max_match_value);
+       if ((flag == FLAG_CLOCKEVENT) && (ch->flags & FLAG_CLOCKSOURCE))
+               __sh_cmt_set_next(ch, ch->max_match_value);
 
-       raw_spin_unlock_irqrestore(&p->lock, flags);
+       raw_spin_unlock_irqrestore(&ch->lock, flags);
 }
 
-static struct sh_cmt_priv *cs_to_sh_cmt(struct clocksource *cs)
+static struct sh_cmt_channel *cs_to_sh_cmt(struct clocksource *cs)
 {
-       return container_of(cs, struct sh_cmt_priv, cs);
+       return container_of(cs, struct sh_cmt_channel, cs);
 }
 
 static cycle_t sh_cmt_clocksource_read(struct clocksource *cs)
 {
-       struct sh_cmt_priv *p = cs_to_sh_cmt(cs);
+       struct sh_cmt_channel *ch = cs_to_sh_cmt(cs);
        unsigned long flags, raw;
        unsigned long value;
        int has_wrapped;
 
-       raw_spin_lock_irqsave(&p->lock, flags);
-       value = p->total_cycles;
-       raw = sh_cmt_get_counter(p, &has_wrapped);
+       raw_spin_lock_irqsave(&ch->lock, flags);
+       value = ch->total_cycles;
+       raw = sh_cmt_get_counter(ch, &has_wrapped);
 
        if (unlikely(has_wrapped))
-               raw += p->match_value + 1;
-       raw_spin_unlock_irqrestore(&p->lock, flags);
+               raw += ch->match_value + 1;
+       raw_spin_unlock_irqrestore(&ch->lock, flags);
 
        return value + raw;
 }
@@ -499,53 +633,53 @@ static cycle_t sh_cmt_clocksource_read(struct clocksource *cs)
 static int sh_cmt_clocksource_enable(struct clocksource *cs)
 {
        int ret;
-       struct sh_cmt_priv *p = cs_to_sh_cmt(cs);
+       struct sh_cmt_channel *ch = cs_to_sh_cmt(cs);
 
-       WARN_ON(p->cs_enabled);
+       WARN_ON(ch->cs_enabled);
 
-       p->total_cycles = 0;
+       ch->total_cycles = 0;
 
-       ret = sh_cmt_start(p, FLAG_CLOCKSOURCE);
+       ret = sh_cmt_start(ch, FLAG_CLOCKSOURCE);
        if (!ret) {
-               __clocksource_updatefreq_hz(cs, p->rate);
-               p->cs_enabled = true;
+               __clocksource_updatefreq_hz(cs, ch->rate);
+               ch->cs_enabled = true;
        }
        return ret;
 }
 
 static void sh_cmt_clocksource_disable(struct clocksource *cs)
 {
-       struct sh_cmt_priv *p = cs_to_sh_cmt(cs);
+       struct sh_cmt_channel *ch = cs_to_sh_cmt(cs);
 
-       WARN_ON(!p->cs_enabled);
+       WARN_ON(!ch->cs_enabled);
 
-       sh_cmt_stop(p, FLAG_CLOCKSOURCE);
-       p->cs_enabled = false;
+       sh_cmt_stop(ch, FLAG_CLOCKSOURCE);
+       ch->cs_enabled = false;
 }
 
 static void sh_cmt_clocksource_suspend(struct clocksource *cs)
 {
-       struct sh_cmt_priv *p = cs_to_sh_cmt(cs);
+       struct sh_cmt_channel *ch = cs_to_sh_cmt(cs);
 
-       sh_cmt_stop(p, FLAG_CLOCKSOURCE);
-       pm_genpd_syscore_poweroff(&p->pdev->dev);
+       sh_cmt_stop(ch, FLAG_CLOCKSOURCE);
+       pm_genpd_syscore_poweroff(&ch->cmt->pdev->dev);
 }
 
 static void sh_cmt_clocksource_resume(struct clocksource *cs)
 {
-       struct sh_cmt_priv *p = cs_to_sh_cmt(cs);
+       struct sh_cmt_channel *ch = cs_to_sh_cmt(cs);
 
-       pm_genpd_syscore_poweron(&p->pdev->dev);
-       sh_cmt_start(p, FLAG_CLOCKSOURCE);
+       pm_genpd_syscore_poweron(&ch->cmt->pdev->dev);
+       sh_cmt_start(ch, FLAG_CLOCKSOURCE);
 }
 
-static int sh_cmt_register_clocksource(struct sh_cmt_priv *p,
-                                      char *name, unsigned long rating)
+static int sh_cmt_register_clocksource(struct sh_cmt_channel *ch,
+                                      const char *name)
 {
-       struct clocksource *cs = &p->cs;
+       struct clocksource *cs = &ch->cs;
 
        cs->name = name;
-       cs->rating = rating;
+       cs->rating = 125;
        cs->read = sh_cmt_clocksource_read;
        cs->enable = sh_cmt_clocksource_enable;
        cs->disable = sh_cmt_clocksource_disable;
@@ -554,47 +688,48 @@ static int sh_cmt_register_clocksource(struct sh_cmt_priv *p,
        cs->mask = CLOCKSOURCE_MASK(sizeof(unsigned long) * 8);
        cs->flags = CLOCK_SOURCE_IS_CONTINUOUS;
 
-       dev_info(&p->pdev->dev, "used as clock source\n");
+       dev_info(&ch->cmt->pdev->dev, "ch%u: used as clock source\n",
+                ch->index);
 
        /* Register with dummy 1 Hz value, gets updated in ->enable() */
        clocksource_register_hz(cs, 1);
        return 0;
 }
 
-static struct sh_cmt_priv *ced_to_sh_cmt(struct clock_event_device *ced)
+static struct sh_cmt_channel *ced_to_sh_cmt(struct clock_event_device *ced)
 {
-       return container_of(ced, struct sh_cmt_priv, ced);
+       return container_of(ced, struct sh_cmt_channel, ced);
 }
 
-static void sh_cmt_clock_event_start(struct sh_cmt_priv *p, int periodic)
+static void sh_cmt_clock_event_start(struct sh_cmt_channel *ch, int periodic)
 {
-       struct clock_event_device *ced = &p->ced;
+       struct clock_event_device *ced = &ch->ced;
 
-       sh_cmt_start(p, FLAG_CLOCKEVENT);
+       sh_cmt_start(ch, FLAG_CLOCKEVENT);
 
        /* TODO: calculate good shift from rate and counter bit width */
 
        ced->shift = 32;
-       ced->mult = div_sc(p->rate, NSEC_PER_SEC, ced->shift);
-       ced->max_delta_ns = clockevent_delta2ns(p->max_match_value, ced);
+       ced->mult = div_sc(ch->rate, NSEC_PER_SEC, ced->shift);
+       ced->max_delta_ns = clockevent_delta2ns(ch->max_match_value, ced);
        ced->min_delta_ns = clockevent_delta2ns(0x1f, ced);
 
        if (periodic)
-               sh_cmt_set_next(p, ((p->rate + HZ/2) / HZ) - 1);
+               sh_cmt_set_next(ch, ((ch->rate + HZ/2) / HZ) - 1);
        else
-               sh_cmt_set_next(p, p->max_match_value);
+               sh_cmt_set_next(ch, ch->max_match_value);
 }
 
 static void sh_cmt_clock_event_mode(enum clock_event_mode mode,
                                    struct clock_event_device *ced)
 {
-       struct sh_cmt_priv *p = ced_to_sh_cmt(ced);
+       struct sh_cmt_channel *ch = ced_to_sh_cmt(ced);
 
        /* deal with old setting first */
        switch (ced->mode) {
        case CLOCK_EVT_MODE_PERIODIC:
        case CLOCK_EVT_MODE_ONESHOT:
-               sh_cmt_stop(p, FLAG_CLOCKEVENT);
+               sh_cmt_stop(ch, FLAG_CLOCKEVENT);
                break;
        default:
                break;
@@ -602,16 +737,18 @@ static void sh_cmt_clock_event_mode(enum clock_event_mode mode,
 
        switch (mode) {
        case CLOCK_EVT_MODE_PERIODIC:
-               dev_info(&p->pdev->dev, "used for periodic clock events\n");
-               sh_cmt_clock_event_start(p, 1);
+               dev_info(&ch->cmt->pdev->dev,
+                        "ch%u: used for periodic clock events\n", ch->index);
+               sh_cmt_clock_event_start(ch, 1);
                break;
        case CLOCK_EVT_MODE_ONESHOT:
-               dev_info(&p->pdev->dev, "used for oneshot clock events\n");
-               sh_cmt_clock_event_start(p, 0);
+               dev_info(&ch->cmt->pdev->dev,
+                        "ch%u: used for oneshot clock events\n", ch->index);
+               sh_cmt_clock_event_start(ch, 0);
                break;
        case CLOCK_EVT_MODE_SHUTDOWN:
        case CLOCK_EVT_MODE_UNUSED:
-               sh_cmt_stop(p, FLAG_CLOCKEVENT);
+               sh_cmt_stop(ch, FLAG_CLOCKEVENT);
                break;
        default:
                break;
@@ -621,196 +758,290 @@ static void sh_cmt_clock_event_mode(enum clock_event_mode mode,
 static int sh_cmt_clock_event_next(unsigned long delta,
                                   struct clock_event_device *ced)
 {
-       struct sh_cmt_priv *p = ced_to_sh_cmt(ced);
+       struct sh_cmt_channel *ch = ced_to_sh_cmt(ced);
 
        BUG_ON(ced->mode != CLOCK_EVT_MODE_ONESHOT);
-       if (likely(p->flags & FLAG_IRQCONTEXT))
-               p->next_match_value = delta - 1;
+       if (likely(ch->flags & FLAG_IRQCONTEXT))
+               ch->next_match_value = delta - 1;
        else
-               sh_cmt_set_next(p, delta - 1);
+               sh_cmt_set_next(ch, delta - 1);
 
        return 0;
 }
 
 static void sh_cmt_clock_event_suspend(struct clock_event_device *ced)
 {
-       struct sh_cmt_priv *p = ced_to_sh_cmt(ced);
+       struct sh_cmt_channel *ch = ced_to_sh_cmt(ced);
 
-       pm_genpd_syscore_poweroff(&p->pdev->dev);
-       clk_unprepare(p->clk);
+       pm_genpd_syscore_poweroff(&ch->cmt->pdev->dev);
+       clk_unprepare(ch->cmt->clk);
 }
 
 static void sh_cmt_clock_event_resume(struct clock_event_device *ced)
 {
-       struct sh_cmt_priv *p = ced_to_sh_cmt(ced);
+       struct sh_cmt_channel *ch = ced_to_sh_cmt(ced);
 
-       clk_prepare(p->clk);
-       pm_genpd_syscore_poweron(&p->pdev->dev);
+       clk_prepare(ch->cmt->clk);
+       pm_genpd_syscore_poweron(&ch->cmt->pdev->dev);
 }
 
-static void sh_cmt_register_clockevent(struct sh_cmt_priv *p,
-                                      char *name, unsigned long rating)
+static int sh_cmt_register_clockevent(struct sh_cmt_channel *ch,
+                                     const char *name)
 {
-       struct clock_event_device *ced = &p->ced;
+       struct clock_event_device *ced = &ch->ced;
+       int irq;
+       int ret;
+
+       irq = platform_get_irq(ch->cmt->pdev, ch->index);
+       if (irq < 0) {
+               dev_err(&ch->cmt->pdev->dev, "ch%u: failed to get irq\n",
+                       ch->index);
+               return irq;
+       }
 
-       memset(ced, 0, sizeof(*ced));
+       ret = request_irq(irq, sh_cmt_interrupt,
+                         IRQF_TIMER | IRQF_IRQPOLL | IRQF_NOBALANCING,
+                         dev_name(&ch->cmt->pdev->dev), ch);
+       if (ret) {
+               dev_err(&ch->cmt->pdev->dev, "ch%u: failed to request irq %d\n",
+                       ch->index, irq);
+               return ret;
+       }
 
        ced->name = name;
        ced->features = CLOCK_EVT_FEAT_PERIODIC;
        ced->features |= CLOCK_EVT_FEAT_ONESHOT;
-       ced->rating = rating;
-       ced->cpumask = cpumask_of(0);
+       ced->rating = 125;
+       ced->cpumask = cpu_possible_mask;
        ced->set_next_event = sh_cmt_clock_event_next;
        ced->set_mode = sh_cmt_clock_event_mode;
        ced->suspend = sh_cmt_clock_event_suspend;
        ced->resume = sh_cmt_clock_event_resume;
 
-       dev_info(&p->pdev->dev, "used for clock events\n");
+       dev_info(&ch->cmt->pdev->dev, "ch%u: used for clock events\n",
+                ch->index);
        clockevents_register_device(ced);
+
+       return 0;
 }
 
-static int sh_cmt_register(struct sh_cmt_priv *p, char *name,
-                          unsigned long clockevent_rating,
-                          unsigned long clocksource_rating)
+static int sh_cmt_register(struct sh_cmt_channel *ch, const char *name,
+                          bool clockevent, bool clocksource)
 {
-       if (clockevent_rating)
-               sh_cmt_register_clockevent(p, name, clockevent_rating);
+       int ret;
 
-       if (clocksource_rating)
-               sh_cmt_register_clocksource(p, name, clocksource_rating);
+       if (clockevent) {
+               ch->cmt->has_clockevent = true;
+               ret = sh_cmt_register_clockevent(ch, name);
+               if (ret < 0)
+                       return ret;
+       }
+
+       if (clocksource) {
+               ch->cmt->has_clocksource = true;
+               sh_cmt_register_clocksource(ch, name);
+       }
 
        return 0;
 }
 
-static int sh_cmt_setup(struct sh_cmt_priv *p, struct platform_device *pdev)
+static int sh_cmt_setup_channel(struct sh_cmt_channel *ch, unsigned int index,
+                               unsigned int hwidx, bool clockevent,
+                               bool clocksource, struct sh_cmt_device *cmt)
 {
-       struct sh_timer_config *cfg = pdev->dev.platform_data;
-       struct resource *res, *res2;
-       int irq, ret;
-       ret = -ENXIO;
+       int ret;
 
-       memset(p, 0, sizeof(*p));
-       p->pdev = pdev;
+       /* Skip unused channels. */
+       if (!clockevent && !clocksource)
+               return 0;
 
-       if (!cfg) {
-               dev_err(&p->pdev->dev, "missing platform data\n");
-               goto err0;
-       }
+       ch->cmt = cmt;
+       ch->index = index;
+       ch->hwidx = hwidx;
 
-       res = platform_get_resource(p->pdev, IORESOURCE_MEM, 0);
-       if (!res) {
-               dev_err(&p->pdev->dev, "failed to get I/O memory\n");
-               goto err0;
+       /*
+        * Compute the address of the channel control register block. For the
+        * timers with a per-channel start/stop register, compute its address
+        * as well.
+        */
+       switch (cmt->info->model) {
+       case SH_CMT_16BIT:
+               ch->ioctrl = cmt->mapbase + 2 + ch->hwidx * 6;
+               break;
+       case SH_CMT_32BIT:
+       case SH_CMT_48BIT:
+               ch->ioctrl = cmt->mapbase + 0x10 + ch->hwidx * 0x10;
+               break;
+       case SH_CMT_32BIT_FAST:
+               /*
+                * The 32-bit "fast" timer has a single channel at hwidx 5 but
+                * is located at offset 0x40 instead of 0x60 for some reason.
+                */
+               ch->ioctrl = cmt->mapbase + 0x40;
+               break;
+       case SH_CMT_48BIT_GEN2:
+               ch->iostart = cmt->mapbase + ch->hwidx * 0x100;
+               ch->ioctrl = ch->iostart + 0x10;
+               break;
        }
 
-       /* optional resource for the shared timer start/stop register */
-       res2 = platform_get_resource(p->pdev, IORESOURCE_MEM, 1);
+       if (cmt->info->width == (sizeof(ch->max_match_value) * 8))
+               ch->max_match_value = ~0;
+       else
+               ch->max_match_value = (1 << cmt->info->width) - 1;
 
-       irq = platform_get_irq(p->pdev, 0);
-       if (irq < 0) {
-               dev_err(&p->pdev->dev, "failed to get irq\n");
-               goto err0;
-       }
+       ch->match_value = ch->max_match_value;
+       raw_spin_lock_init(&ch->lock);
 
-       /* map memory, let mapbase point to our channel */
-       p->mapbase = ioremap_nocache(res->start, resource_size(res));
-       if (p->mapbase == NULL) {
-               dev_err(&p->pdev->dev, "failed to remap I/O memory\n");
-               goto err0;
+       ch->timer_bit = cmt->info->model == SH_CMT_48BIT_GEN2 ? 0 : ch->hwidx;
+
+       ret = sh_cmt_register(ch, dev_name(&cmt->pdev->dev),
+                             clockevent, clocksource);
+       if (ret) {
+               dev_err(&cmt->pdev->dev, "ch%u: registration failed\n",
+                       ch->index);
+               return ret;
        }
+       ch->cs_enabled = false;
 
-       /* map second resource for CMSTR */
-       p->mapbase_str = ioremap_nocache(res2 ? res2->start :
-                                        res->start - cfg->channel_offset,
-                                        res2 ? resource_size(res2) : 2);
-       if (p->mapbase_str == NULL) {
-               dev_err(&p->pdev->dev, "failed to remap I/O second memory\n");
-               goto err1;
+       return 0;
+}
+
+static int sh_cmt_map_memory(struct sh_cmt_device *cmt)
+{
+       struct resource *mem;
+
+       mem = platform_get_resource(cmt->pdev, IORESOURCE_MEM, 0);
+       if (!mem) {
+               dev_err(&cmt->pdev->dev, "failed to get I/O memory\n");
+               return -ENXIO;
        }
 
-       /* request irq using setup_irq() (too early for request_irq()) */
-       p->irqaction.name = dev_name(&p->pdev->dev);
-       p->irqaction.handler = sh_cmt_interrupt;
-       p->irqaction.dev_id = p;
-       p->irqaction.flags = IRQF_TIMER | IRQF_IRQPOLL | IRQF_NOBALANCING;
-
-       /* get hold of clock */
-       p->clk = clk_get(&p->pdev->dev, "cmt_fck");
-       if (IS_ERR(p->clk)) {
-               dev_err(&p->pdev->dev, "cannot get clock\n");
-               ret = PTR_ERR(p->clk);
-               goto err2;
+       cmt->mapbase = ioremap_nocache(mem->start, resource_size(mem));
+       if (cmt->mapbase == NULL) {
+               dev_err(&cmt->pdev->dev, "failed to remap I/O memory\n");
+               return -ENXIO;
        }
 
-       ret = clk_prepare(p->clk);
-       if (ret < 0)
-               goto err3;
+       return 0;
+}
 
-       if (res2 && (resource_size(res2) == 4)) {
-               /* assume both CMSTR and CMCSR to be 32-bit */
-               p->read_control = sh_cmt_read32;
-               p->write_control = sh_cmt_write32;
-       } else {
-               p->read_control = sh_cmt_read16;
-               p->write_control = sh_cmt_write16;
-       }
+static const struct platform_device_id sh_cmt_id_table[] = {
+       { "sh-cmt-16", (kernel_ulong_t)&sh_cmt_info[SH_CMT_16BIT] },
+       { "sh-cmt-32", (kernel_ulong_t)&sh_cmt_info[SH_CMT_32BIT] },
+       { "sh-cmt-32-fast", (kernel_ulong_t)&sh_cmt_info[SH_CMT_32BIT_FAST] },
+       { "sh-cmt-48", (kernel_ulong_t)&sh_cmt_info[SH_CMT_48BIT] },
+       { "sh-cmt-48-gen2", (kernel_ulong_t)&sh_cmt_info[SH_CMT_48BIT_GEN2] },
+       { }
+};
+MODULE_DEVICE_TABLE(platform, sh_cmt_id_table);
+
+static const struct of_device_id sh_cmt_of_table[] __maybe_unused = {
+       { .compatible = "renesas,cmt-32", .data = &sh_cmt_info[SH_CMT_32BIT] },
+       { .compatible = "renesas,cmt-32-fast", .data = &sh_cmt_info[SH_CMT_32BIT_FAST] },
+       { .compatible = "renesas,cmt-48", .data = &sh_cmt_info[SH_CMT_48BIT] },
+       { .compatible = "renesas,cmt-48-gen2", .data = &sh_cmt_info[SH_CMT_48BIT_GEN2] },
+       { }
+};
+MODULE_DEVICE_TABLE(of, sh_cmt_of_table);
+
+static int sh_cmt_parse_dt(struct sh_cmt_device *cmt)
+{
+       struct device_node *np = cmt->pdev->dev.of_node;
+
+       return of_property_read_u32(np, "renesas,channels-mask",
+                                   &cmt->hw_channels);
+}
+
+static int sh_cmt_setup(struct sh_cmt_device *cmt, struct platform_device *pdev)
+{
+       unsigned int mask;
+       unsigned int i;
+       int ret;
+
+       memset(cmt, 0, sizeof(*cmt));
+       cmt->pdev = pdev;
+       raw_spin_lock_init(&cmt->lock);
+
+       if (IS_ENABLED(CONFIG_OF) && pdev->dev.of_node) {
+               const struct of_device_id *id;
+
+               id = of_match_node(sh_cmt_of_table, pdev->dev.of_node);
+               cmt->info = id->data;
+
+               ret = sh_cmt_parse_dt(cmt);
+               if (ret < 0)
+                       return ret;
+       } else if (pdev->dev.platform_data) {
+               struct sh_timer_config *cfg = pdev->dev.platform_data;
+               const struct platform_device_id *id = pdev->id_entry;
 
-       if (resource_size(res) == 6) {
-               p->width = 16;
-               p->read_count = sh_cmt_read16;
-               p->write_count = sh_cmt_write16;
-               p->overflow_bit = 0x80;
-               p->clear_bits = ~0x80;
+               cmt->info = (const struct sh_cmt_info *)id->driver_data;
+               cmt->hw_channels = cfg->channels_mask;
        } else {
-               p->width = 32;
-               p->read_count = sh_cmt_read32;
-               p->write_count = sh_cmt_write32;
-               p->overflow_bit = 0x8000;
-               p->clear_bits = ~0xc000;
+               dev_err(&cmt->pdev->dev, "missing platform data\n");
+               return -ENXIO;
        }
 
-       if (p->width == (sizeof(p->max_match_value) * 8))
-               p->max_match_value = ~0;
-       else
-               p->max_match_value = (1 << p->width) - 1;
+       /* Get hold of clock. */
+       cmt->clk = clk_get(&cmt->pdev->dev, "fck");
+       if (IS_ERR(cmt->clk)) {
+               dev_err(&cmt->pdev->dev, "cannot get clock\n");
+               return PTR_ERR(cmt->clk);
+       }
 
-       p->match_value = p->max_match_value;
-       raw_spin_lock_init(&p->lock);
+       ret = clk_prepare(cmt->clk);
+       if (ret < 0)
+               goto err_clk_put;
 
-       ret = sh_cmt_register(p, (char *)dev_name(&p->pdev->dev),
-                             cfg->clockevent_rating,
-                             cfg->clocksource_rating);
-       if (ret) {
-               dev_err(&p->pdev->dev, "registration failed\n");
-               goto err4;
+       /* Map the memory resource(s). */
+       ret = sh_cmt_map_memory(cmt);
+       if (ret < 0)
+               goto err_clk_unprepare;
+
+       /* Allocate and setup the channels. */
+       cmt->num_channels = hweight8(cmt->hw_channels);
+       cmt->channels = kzalloc(cmt->num_channels * sizeof(*cmt->channels),
+                               GFP_KERNEL);
+       if (cmt->channels == NULL) {
+               ret = -ENOMEM;
+               goto err_unmap;
        }
-       p->cs_enabled = false;
 
-       ret = setup_irq(irq, &p->irqaction);
-       if (ret) {
-               dev_err(&p->pdev->dev, "failed to request irq %d\n", irq);
-               goto err4;
+       /*
+        * Use the first channel as a clock event device and the second channel
+        * as a clock source. If only one channel is available use it for both.
+        */
+       for (i = 0, mask = cmt->hw_channels; i < cmt->num_channels; ++i) {
+               unsigned int hwidx = ffs(mask) - 1;
+               bool clocksource = i == 1 || cmt->num_channels == 1;
+               bool clockevent = i == 0;
+
+               ret = sh_cmt_setup_channel(&cmt->channels[i], i, hwidx,
+                                          clockevent, clocksource, cmt);
+               if (ret < 0)
+                       goto err_unmap;
+
+               mask &= ~(1 << hwidx);
        }
 
-       platform_set_drvdata(pdev, p);
+       platform_set_drvdata(pdev, cmt);
 
        return 0;
-err4:
-       clk_unprepare(p->clk);
-err3:
-       clk_put(p->clk);
-err2:
-       iounmap(p->mapbase_str);
-err1:
-       iounmap(p->mapbase);
-err0:
+
+err_unmap:
+       kfree(cmt->channels);
+       iounmap(cmt->mapbase);
+err_clk_unprepare:
+       clk_unprepare(cmt->clk);
+err_clk_put:
+       clk_put(cmt->clk);
        return ret;
 }
 
 static int sh_cmt_probe(struct platform_device *pdev)
 {
-       struct sh_cmt_priv *p = platform_get_drvdata(pdev);
-       struct sh_timer_config *cfg = pdev->dev.platform_data;
+       struct sh_cmt_device *cmt = platform_get_drvdata(pdev);
        int ret;
 
        if (!is_early_platform_device(pdev)) {
@@ -818,20 +1049,18 @@ static int sh_cmt_probe(struct platform_device *pdev)
                pm_runtime_enable(&pdev->dev);
        }
 
-       if (p) {
+       if (cmt) {
                dev_info(&pdev->dev, "kept as earlytimer\n");
                goto out;
        }
 
-       p = kmalloc(sizeof(*p), GFP_KERNEL);
-       if (p == NULL) {
-               dev_err(&pdev->dev, "failed to allocate driver data\n");
+       cmt = kzalloc(sizeof(*cmt), GFP_KERNEL);
+       if (cmt == NULL)
                return -ENOMEM;
-       }
 
-       ret = sh_cmt_setup(p, pdev);
+       ret = sh_cmt_setup(cmt, pdev);
        if (ret) {
-               kfree(p);
+               kfree(cmt);
                pm_runtime_idle(&pdev->dev);
                return ret;
        }
@@ -839,7 +1068,7 @@ static int sh_cmt_probe(struct platform_device *pdev)
                return 0;
 
  out:
-       if (cfg->clockevent_rating || cfg->clocksource_rating)
+       if (cmt->has_clockevent || cmt->has_clocksource)
                pm_runtime_irq_safe(&pdev->dev);
        else
                pm_runtime_idle(&pdev->dev);
@@ -857,7 +1086,9 @@ static struct platform_driver sh_cmt_device_driver = {
        .remove         = sh_cmt_remove,
        .driver         = {
                .name   = "sh_cmt",
-       }
+               .of_match_table = of_match_ptr(sh_cmt_of_table),
+       },
+       .id_table       = sh_cmt_id_table,
 };
 
 static int __init sh_cmt_init(void)
index e30d76e..3d88698 100644 (file)
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  */
 
+#include <linux/clk.h>
+#include <linux/clockchips.h>
+#include <linux/delay.h>
+#include <linux/err.h>
 #include <linux/init.h>
-#include <linux/platform_device.h>
-#include <linux/spinlock.h>
 #include <linux/interrupt.h>
-#include <linux/ioport.h>
-#include <linux/delay.h>
 #include <linux/io.h>
-#include <linux/clk.h>
+#include <linux/ioport.h>
 #include <linux/irq.h>
-#include <linux/err.h>
-#include <linux/clockchips.h>
-#include <linux/sh_timer.h>
-#include <linux/slab.h>
 #include <linux/module.h>
+#include <linux/of.h>
+#include <linux/platform_device.h>
 #include <linux/pm_domain.h>
 #include <linux/pm_runtime.h>
+#include <linux/sh_timer.h>
+#include <linux/slab.h>
+#include <linux/spinlock.h>
+
+struct sh_mtu2_device;
+
+struct sh_mtu2_channel {
+       struct sh_mtu2_device *mtu;
+       unsigned int index;
+
+       void __iomem *base;
 
-struct sh_mtu2_priv {
-       void __iomem *mapbase;
-       struct clk *clk;
-       struct irqaction irqaction;
-       struct platform_device *pdev;
-       unsigned long rate;
-       unsigned long periodic;
        struct clock_event_device ced;
 };
 
-static DEFINE_RAW_SPINLOCK(sh_mtu2_lock);
+struct sh_mtu2_device {
+       struct platform_device *pdev;
+
+       void __iomem *mapbase;
+       struct clk *clk;
+
+       raw_spinlock_t lock; /* Protect the shared registers */
+
+       struct sh_mtu2_channel *channels;
+       unsigned int num_channels;
+
+       bool has_clockevent;
+};
 
 #define TSTR -1 /* shared register */
 #define TCR  0 /* channel register */
@@ -55,6 +65,88 @@ static DEFINE_RAW_SPINLOCK(sh_mtu2_lock);
 #define TCNT 5 /* channel register */
 #define TGR  6 /* channel register */
 
+#define TCR_CCLR_NONE          (0 << 5)
+#define TCR_CCLR_TGRA          (1 << 5)
+#define TCR_CCLR_TGRB          (2 << 5)
+#define TCR_CCLR_SYNC          (3 << 5)
+#define TCR_CCLR_TGRC          (5 << 5)
+#define TCR_CCLR_TGRD          (6 << 5)
+#define TCR_CCLR_MASK          (7 << 5)
+#define TCR_CKEG_RISING                (0 << 3)
+#define TCR_CKEG_FALLING       (1 << 3)
+#define TCR_CKEG_BOTH          (2 << 3)
+#define TCR_CKEG_MASK          (3 << 3)
+/* Values 4 to 7 are channel-dependent */
+#define TCR_TPSC_P1            (0 << 0)
+#define TCR_TPSC_P4            (1 << 0)
+#define TCR_TPSC_P16           (2 << 0)
+#define TCR_TPSC_P64           (3 << 0)
+#define TCR_TPSC_CH0_TCLKA     (4 << 0)
+#define TCR_TPSC_CH0_TCLKB     (5 << 0)
+#define TCR_TPSC_CH0_TCLKC     (6 << 0)
+#define TCR_TPSC_CH0_TCLKD     (7 << 0)
+#define TCR_TPSC_CH1_TCLKA     (4 << 0)
+#define TCR_TPSC_CH1_TCLKB     (5 << 0)
+#define TCR_TPSC_CH1_P256      (6 << 0)
+#define TCR_TPSC_CH1_TCNT2     (7 << 0)
+#define TCR_TPSC_CH2_TCLKA     (4 << 0)
+#define TCR_TPSC_CH2_TCLKB     (5 << 0)
+#define TCR_TPSC_CH2_TCLKC     (6 << 0)
+#define TCR_TPSC_CH2_P1024     (7 << 0)
+#define TCR_TPSC_CH34_P256     (4 << 0)
+#define TCR_TPSC_CH34_P1024    (5 << 0)
+#define TCR_TPSC_CH34_TCLKA    (6 << 0)
+#define TCR_TPSC_CH34_TCLKB    (7 << 0)
+#define TCR_TPSC_MASK          (7 << 0)
+
+#define TMDR_BFE               (1 << 6)
+#define TMDR_BFB               (1 << 5)
+#define TMDR_BFA               (1 << 4)
+#define TMDR_MD_NORMAL         (0 << 0)
+#define TMDR_MD_PWM_1          (2 << 0)
+#define TMDR_MD_PWM_2          (3 << 0)
+#define TMDR_MD_PHASE_1                (4 << 0)
+#define TMDR_MD_PHASE_2                (5 << 0)
+#define TMDR_MD_PHASE_3                (6 << 0)
+#define TMDR_MD_PHASE_4                (7 << 0)
+#define TMDR_MD_PWM_SYNC       (8 << 0)
+#define TMDR_MD_PWM_COMP_CREST (13 << 0)
+#define TMDR_MD_PWM_COMP_TROUGH        (14 << 0)
+#define TMDR_MD_PWM_COMP_BOTH  (15 << 0)
+#define TMDR_MD_MASK           (15 << 0)
+
+#define TIOC_IOCH(n)           ((n) << 4)
+#define TIOC_IOCL(n)           ((n) << 0)
+#define TIOR_OC_RETAIN         (0 << 0)
+#define TIOR_OC_0_CLEAR                (1 << 0)
+#define TIOR_OC_0_SET          (2 << 0)
+#define TIOR_OC_0_TOGGLE       (3 << 0)
+#define TIOR_OC_1_CLEAR                (5 << 0)
+#define TIOR_OC_1_SET          (6 << 0)
+#define TIOR_OC_1_TOGGLE       (7 << 0)
+#define TIOR_IC_RISING         (8 << 0)
+#define TIOR_IC_FALLING                (9 << 0)
+#define TIOR_IC_BOTH           (10 << 0)
+#define TIOR_IC_TCNT           (12 << 0)
+#define TIOR_MASK              (15 << 0)
+
+#define TIER_TTGE              (1 << 7)
+#define TIER_TTGE2             (1 << 6)
+#define TIER_TCIEU             (1 << 5)
+#define TIER_TCIEV             (1 << 4)
+#define TIER_TGIED             (1 << 3)
+#define TIER_TGIEC             (1 << 2)
+#define TIER_TGIEB             (1 << 1)
+#define TIER_TGIEA             (1 << 0)
+
+#define TSR_TCFD               (1 << 7)
+#define TSR_TCFU               (1 << 5)
+#define TSR_TCFV               (1 << 4)
+#define TSR_TGFD               (1 << 3)
+#define TSR_TGFC               (1 << 2)
+#define TSR_TGFB               (1 << 1)
+#define TSR_TGFA               (1 << 0)
+
 static unsigned long mtu2_reg_offs[] = {
        [TCR] = 0,
        [TMDR] = 1,
@@ -65,135 +157,135 @@ static unsigned long mtu2_reg_offs[] = {
        [TGR] = 8,
 };
 
-static inline unsigned long sh_mtu2_read(struct sh_mtu2_priv *p, int reg_nr)
+static inline unsigned long sh_mtu2_read(struct sh_mtu2_channel *ch, int reg_nr)
 {
-       struct sh_timer_config *cfg = p->pdev->dev.platform_data;
-       void __iomem *base = p->mapbase;
        unsigned long offs;
 
        if (reg_nr == TSTR)
-               return ioread8(base + cfg->channel_offset);
+               return ioread8(ch->mtu->mapbase + 0x280);
 
        offs = mtu2_reg_offs[reg_nr];
 
        if ((reg_nr == TCNT) || (reg_nr == TGR))
-               return ioread16(base + offs);
+               return ioread16(ch->base + offs);
        else
-               return ioread8(base + offs);
+               return ioread8(ch->base + offs);
 }
 
-static inline void sh_mtu2_write(struct sh_mtu2_priv *p, int reg_nr,
+static inline void sh_mtu2_write(struct sh_mtu2_channel *ch, int reg_nr,
                                unsigned long value)
 {
-       struct sh_timer_config *cfg = p->pdev->dev.platform_data;
-       void __iomem *base = p->mapbase;
        unsigned long offs;
 
-       if (reg_nr == TSTR) {
-               iowrite8(value, base + cfg->channel_offset);
-               return;
-       }
+       if (reg_nr == TSTR)
+               return iowrite8(value, ch->mtu->mapbase + 0x280);
 
        offs = mtu2_reg_offs[reg_nr];
 
        if ((reg_nr == TCNT) || (reg_nr == TGR))
-               iowrite16(value, base + offs);
+               iowrite16(value, ch->base + offs);
        else
-               iowrite8(value, base + offs);
+               iowrite8(value, ch->base + offs);
 }
 
-static void sh_mtu2_start_stop_ch(struct sh_mtu2_priv *p, int start)
+static void sh_mtu2_start_stop_ch(struct sh_mtu2_channel *ch, int start)
 {
-       struct sh_timer_config *cfg = p->pdev->dev.platform_data;
        unsigned long flags, value;
 
        /* start stop register shared by multiple timer channels */
-       raw_spin_lock_irqsave(&sh_mtu2_lock, flags);
-       value = sh_mtu2_read(p, TSTR);
+       raw_spin_lock_irqsave(&ch->mtu->lock, flags);
+       value = sh_mtu2_read(ch, TSTR);
 
        if (start)
-               value |= 1 << cfg->timer_bit;
+               value |= 1 << ch->index;
        else
-               value &= ~(1 << cfg->timer_bit);
+               value &= ~(1 << ch->index);
 
-       sh_mtu2_write(p, TSTR, value);
-       raw_spin_unlock_irqrestore(&sh_mtu2_lock, flags);
+       sh_mtu2_write(ch, TSTR, value);
+       raw_spin_unlock_irqrestore(&ch->mtu->lock, flags);
 }
 
-static int sh_mtu2_enable(struct sh_mtu2_priv *p)
+static int sh_mtu2_enable(struct sh_mtu2_channel *ch)
 {
+       unsigned long periodic;
+       unsigned long rate;
        int ret;
 
-       pm_runtime_get_sync(&p->pdev->dev);
-       dev_pm_syscore_device(&p->pdev->dev, true);
+       pm_runtime_get_sync(&ch->mtu->pdev->dev);
+       dev_pm_syscore_device(&ch->mtu->pdev->dev, true);
 
        /* enable clock */
-       ret = clk_enable(p->clk);
+       ret = clk_enable(ch->mtu->clk);
        if (ret) {
-               dev_err(&p->pdev->dev, "cannot enable clock\n");
+               dev_err(&ch->mtu->pdev->dev, "ch%u: cannot enable clock\n",
+                       ch->index);
                return ret;
        }
 
        /* make sure channel is disabled */
-       sh_mtu2_start_stop_ch(p, 0);
-
-       p->rate = clk_get_rate(p->clk) / 64;
-       p->periodic = (p->rate + HZ/2) / HZ;
-
-       /* "Periodic Counter Operation" */
-       sh_mtu2_write(p, TCR, 0x23); /* TGRA clear, divide clock by 64 */
-       sh_mtu2_write(p, TIOR, 0);
-       sh_mtu2_write(p, TGR, p->periodic);
-       sh_mtu2_write(p, TCNT, 0);
-       sh_mtu2_write(p, TMDR, 0);
-       sh_mtu2_write(p, TIER, 0x01);
+       sh_mtu2_start_stop_ch(ch, 0);
+
+       rate = clk_get_rate(ch->mtu->clk) / 64;
+       periodic = (rate + HZ/2) / HZ;
+
+       /*
+        * "Periodic Counter Operation"
+        * Clear on TGRA compare match, divide clock by 64.
+        */
+       sh_mtu2_write(ch, TCR, TCR_CCLR_TGRA | TCR_TPSC_P64);
+       sh_mtu2_write(ch, TIOR, TIOC_IOCH(TIOR_OC_0_CLEAR) |
+                     TIOC_IOCL(TIOR_OC_0_CLEAR));
+       sh_mtu2_write(ch, TGR, periodic);
+       sh_mtu2_write(ch, TCNT, 0);
+       sh_mtu2_write(ch, TMDR, TMDR_MD_NORMAL);
+       sh_mtu2_write(ch, TIER, TIER_TGIEA);
 
        /* enable channel */
-       sh_mtu2_start_stop_ch(p, 1);
+       sh_mtu2_start_stop_ch(ch, 1);
 
        return 0;
 }
 
-static void sh_mtu2_disable(struct sh_mtu2_priv *p)
+static void sh_mtu2_disable(struct sh_mtu2_channel *ch)
 {
        /* disable channel */
-       sh_mtu2_start_stop_ch(p, 0);
+       sh_mtu2_start_stop_ch(ch, 0);
 
        /* stop clock */
-       clk_disable(p->clk);
+       clk_disable(ch->mtu->clk);
 
-       dev_pm_syscore_device(&p->pdev->dev, false);
-       pm_runtime_put(&p->pdev->dev);
+       dev_pm_syscore_device(&ch->mtu->pdev->dev, false);
+       pm_runtime_put(&ch->mtu->pdev->dev);
 }
 
 static irqreturn_t sh_mtu2_interrupt(int irq, void *dev_id)
 {
-       struct sh_mtu2_priv *p = dev_id;
+       struct sh_mtu2_channel *ch = dev_id;
 
        /* acknowledge interrupt */
-       sh_mtu2_read(p, TSR);
-       sh_mtu2_write(p, TSR, 0xfe);
+       sh_mtu2_read(ch, TSR);
+       sh_mtu2_write(ch, TSR, ~TSR_TGFA);
 
        /* notify clockevent layer */
-       p->ced.event_handler(&p->ced);
+       ch->ced.event_handler(&ch->ced);
        return IRQ_HANDLED;
 }
 
-static struct sh_mtu2_priv *ced_to_sh_mtu2(struct clock_event_device *ced)
+static struct sh_mtu2_channel *ced_to_sh_mtu2(struct clock_event_device *ced)
 {
-       return container_of(ced, struct sh_mtu2_priv, ced);
+       return container_of(ced, struct sh_mtu2_channel, ced);
 }
 
 static void sh_mtu2_clock_event_mode(enum clock_event_mode mode,
                                    struct clock_event_device *ced)
 {
-       struct sh_mtu2_priv *p = ced_to_sh_mtu2(ced);
+       struct sh_mtu2_channel *ch = ced_to_sh_mtu2(ced);
        int disabled = 0;
 
        /* deal with old setting first */
        switch (ced->mode) {
        case CLOCK_EVT_MODE_PERIODIC:
-               sh_mtu2_disable(p);
+               sh_mtu2_disable(ch);
                disabled = 1;
                break;
        default:
@@ -202,12 +294,13 @@ static void sh_mtu2_clock_event_mode(enum clock_event_mode mode,
 
        switch (mode) {
        case CLOCK_EVT_MODE_PERIODIC:
-               dev_info(&p->pdev->dev, "used for periodic clock events\n");
-               sh_mtu2_enable(p);
+               dev_info(&ch->mtu->pdev->dev,
+                        "ch%u: used for periodic clock events\n", ch->index);
+               sh_mtu2_enable(ch);
                break;
        case CLOCK_EVT_MODE_UNUSED:
                if (!disabled)
-                       sh_mtu2_disable(p);
+                       sh_mtu2_disable(ch);
                break;
        case CLOCK_EVT_MODE_SHUTDOWN:
        default:
@@ -217,125 +310,152 @@ static void sh_mtu2_clock_event_mode(enum clock_event_mode mode,
 
 static void sh_mtu2_clock_event_suspend(struct clock_event_device *ced)
 {
-       pm_genpd_syscore_poweroff(&ced_to_sh_mtu2(ced)->pdev->dev);
+       pm_genpd_syscore_poweroff(&ced_to_sh_mtu2(ced)->mtu->pdev->dev);
 }
 
 static void sh_mtu2_clock_event_resume(struct clock_event_device *ced)
 {
-       pm_genpd_syscore_poweron(&ced_to_sh_mtu2(ced)->pdev->dev);
+       pm_genpd_syscore_poweron(&ced_to_sh_mtu2(ced)->mtu->pdev->dev);
 }
 
-static void sh_mtu2_register_clockevent(struct sh_mtu2_priv *p,
-                                      char *name, unsigned long rating)
+static void sh_mtu2_register_clockevent(struct sh_mtu2_channel *ch,
+                                       const char *name)
 {
-       struct clock_event_device *ced = &p->ced;
-       int ret;
-
-       memset(ced, 0, sizeof(*ced));
+       struct clock_event_device *ced = &ch->ced;
 
        ced->name = name;
        ced->features = CLOCK_EVT_FEAT_PERIODIC;
-       ced->rating = rating;
-       ced->cpumask = cpumask_of(0);
+       ced->rating = 200;
+       ced->cpumask = cpu_possible_mask;
        ced->set_mode = sh_mtu2_clock_event_mode;
        ced->suspend = sh_mtu2_clock_event_suspend;
        ced->resume = sh_mtu2_clock_event_resume;
 
-       dev_info(&p->pdev->dev, "used for clock events\n");
+       dev_info(&ch->mtu->pdev->dev, "ch%u: used for clock events\n",
+                ch->index);
        clockevents_register_device(ced);
-
-       ret = setup_irq(p->irqaction.irq, &p->irqaction);
-       if (ret) {
-               dev_err(&p->pdev->dev, "failed to request irq %d\n",
-                       p->irqaction.irq);
-               return;
-       }
 }
 
-static int sh_mtu2_register(struct sh_mtu2_priv *p, char *name,
-                           unsigned long clockevent_rating)
+static int sh_mtu2_register(struct sh_mtu2_channel *ch, const char *name)
 {
-       if (clockevent_rating)
-               sh_mtu2_register_clockevent(p, name, clockevent_rating);
+       ch->mtu->has_clockevent = true;
+       sh_mtu2_register_clockevent(ch, name);
 
        return 0;
 }
 
-static int sh_mtu2_setup(struct sh_mtu2_priv *p, struct platform_device *pdev)
+static int sh_mtu2_setup_channel(struct sh_mtu2_channel *ch, unsigned int index,
+                                struct sh_mtu2_device *mtu)
 {
-       struct sh_timer_config *cfg = pdev->dev.platform_data;
-       struct resource *res;
-       int irq, ret;
-       ret = -ENXIO;
+       static const unsigned int channel_offsets[] = {
+               0x300, 0x380, 0x000,
+       };
+       char name[6];
+       int irq;
+       int ret;
 
-       memset(p, 0, sizeof(*p));
-       p->pdev = pdev;
+       ch->mtu = mtu;
 
-       if (!cfg) {
-               dev_err(&p->pdev->dev, "missing platform data\n");
-               goto err0;
+       sprintf(name, "tgi%ua", index);
+       irq = platform_get_irq_byname(mtu->pdev, name);
+       if (irq < 0) {
+               /* Skip channels with no declared interrupt. */
+               return 0;
        }
 
-       platform_set_drvdata(pdev, p);
+       ret = request_irq(irq, sh_mtu2_interrupt,
+                         IRQF_TIMER | IRQF_IRQPOLL | IRQF_NOBALANCING,
+                         dev_name(&ch->mtu->pdev->dev), ch);
+       if (ret) {
+               dev_err(&ch->mtu->pdev->dev, "ch%u: failed to request irq %d\n",
+                       index, irq);
+               return ret;
+       }
+
+       ch->base = mtu->mapbase + channel_offsets[index];
+       ch->index = index;
+
+       return sh_mtu2_register(ch, dev_name(&mtu->pdev->dev));
+}
+
+static int sh_mtu2_map_memory(struct sh_mtu2_device *mtu)
+{
+       struct resource *res;
 
-       res = platform_get_resource(p->pdev, IORESOURCE_MEM, 0);
+       res = platform_get_resource(mtu->pdev, IORESOURCE_MEM, 0);
        if (!res) {
-               dev_err(&p->pdev->dev, "failed to get I/O memory\n");
-               goto err0;
+               dev_err(&mtu->pdev->dev, "failed to get I/O memory\n");
+               return -ENXIO;
        }
 
-       irq = platform_get_irq(p->pdev, 0);
-       if (irq < 0) {
-               dev_err(&p->pdev->dev, "failed to get irq\n");
-               goto err0;
+       mtu->mapbase = ioremap_nocache(res->start, resource_size(res));
+       if (mtu->mapbase == NULL)
+               return -ENXIO;
+
+       return 0;
+}
+
+static int sh_mtu2_setup(struct sh_mtu2_device *mtu,
+                        struct platform_device *pdev)
+{
+       unsigned int i;
+       int ret;
+
+       mtu->pdev = pdev;
+
+       raw_spin_lock_init(&mtu->lock);
+
+       /* Get hold of clock. */
+       mtu->clk = clk_get(&mtu->pdev->dev, "fck");
+       if (IS_ERR(mtu->clk)) {
+               dev_err(&mtu->pdev->dev, "cannot get clock\n");
+               return PTR_ERR(mtu->clk);
        }
 
-       /* map memory, let mapbase point to our channel */
-       p->mapbase = ioremap_nocache(res->start, resource_size(res));
-       if (p->mapbase == NULL) {
-               dev_err(&p->pdev->dev, "failed to remap I/O memory\n");
-               goto err0;
+       ret = clk_prepare(mtu->clk);
+       if (ret < 0)
+               goto err_clk_put;
+
+       /* Map the memory resource. */
+       ret = sh_mtu2_map_memory(mtu);
+       if (ret < 0) {
+               dev_err(&mtu->pdev->dev, "failed to remap I/O memory\n");
+               goto err_clk_unprepare;
        }
 
-       /* setup data for setup_irq() (too early for request_irq()) */
-       p->irqaction.name = dev_name(&p->pdev->dev);
-       p->irqaction.handler = sh_mtu2_interrupt;
-       p->irqaction.dev_id = p;
-       p->irqaction.irq = irq;
-       p->irqaction.flags = IRQF_TIMER | IRQF_IRQPOLL | IRQF_NOBALANCING;
-
-       /* get hold of clock */
-       p->clk = clk_get(&p->pdev->dev, "mtu2_fck");
-       if (IS_ERR(p->clk)) {
-               dev_err(&p->pdev->dev, "cannot get clock\n");
-               ret = PTR_ERR(p->clk);
-               goto err1;
+       /* Allocate and setup the channels. */
+       mtu->num_channels = 3;
+
+       mtu->channels = kzalloc(sizeof(*mtu->channels) * mtu->num_channels,
+                               GFP_KERNEL);
+       if (mtu->channels == NULL) {
+               ret = -ENOMEM;
+               goto err_unmap;
        }
 
-       ret = clk_prepare(p->clk);
-       if (ret < 0)
-               goto err2;
+       for (i = 0; i < mtu->num_channels; ++i) {
+               ret = sh_mtu2_setup_channel(&mtu->channels[i], i, mtu);
+               if (ret < 0)
+                       goto err_unmap;
+       }
 
-       ret = sh_mtu2_register(p, (char *)dev_name(&p->pdev->dev),
-                              cfg->clockevent_rating);
-       if (ret < 0)
-               goto err3;
+       platform_set_drvdata(pdev, mtu);
 
        return 0;
- err3:
-       clk_unprepare(p->clk);
- err2:
-       clk_put(p->clk);
- err1:
-       iounmap(p->mapbase);
- err0:
+
+err_unmap:
+       kfree(mtu->channels);
+       iounmap(mtu->mapbase);
+err_clk_unprepare:
+       clk_unprepare(mtu->clk);
+err_clk_put:
+       clk_put(mtu->clk);
        return ret;
 }
 
 static int sh_mtu2_probe(struct platform_device *pdev)
 {
-       struct sh_mtu2_priv *p = platform_get_drvdata(pdev);
-       struct sh_timer_config *cfg = pdev->dev.platform_data;
+       struct sh_mtu2_device *mtu = platform_get_drvdata(pdev);
        int ret;
 
        if (!is_early_platform_device(pdev)) {
@@ -343,20 +463,18 @@ static int sh_mtu2_probe(struct platform_device *pdev)
                pm_runtime_enable(&pdev->dev);
        }
 
-       if (p) {
+       if (mtu) {
                dev_info(&pdev->dev, "kept as earlytimer\n");
                goto out;
        }
 
-       p = kmalloc(sizeof(*p), GFP_KERNEL);
-       if (p == NULL) {
-               dev_err(&pdev->dev, "failed to allocate driver data\n");
+       mtu = kzalloc(sizeof(*mtu), GFP_KERNEL);
+       if (mtu == NULL)
                return -ENOMEM;
-       }
 
-       ret = sh_mtu2_setup(p, pdev);
+       ret = sh_mtu2_setup(mtu, pdev);
        if (ret) {
-               kfree(p);
+               kfree(mtu);
                pm_runtime_idle(&pdev->dev);
                return ret;
        }
@@ -364,7 +482,7 @@ static int sh_mtu2_probe(struct platform_device *pdev)
                return 0;
 
  out:
-       if (cfg->clockevent_rating)
+       if (mtu->has_clockevent)
                pm_runtime_irq_safe(&pdev->dev);
        else
                pm_runtime_idle(&pdev->dev);
@@ -377,12 +495,26 @@ static int sh_mtu2_remove(struct platform_device *pdev)
        return -EBUSY; /* cannot unregister clockevent */
 }
 
+static const struct platform_device_id sh_mtu2_id_table[] = {
+       { "sh-mtu2", 0 },
+       { },
+};
+MODULE_DEVICE_TABLE(platform, sh_mtu2_id_table);
+
+static const struct of_device_id sh_mtu2_of_table[] __maybe_unused = {
+       { .compatible = "renesas,mtu2" },
+       { }
+};
+MODULE_DEVICE_TABLE(of, sh_mtu2_of_table);
+
 static struct platform_driver sh_mtu2_device_driver = {
        .probe          = sh_mtu2_probe,
        .remove         = sh_mtu2_remove,
        .driver         = {
                .name   = "sh_mtu2",
-       }
+               .of_match_table = of_match_ptr(sh_mtu2_of_table),
+       },
+       .id_table       = sh_mtu2_id_table,
 };
 
 static int __init sh_mtu2_init(void)
index ecd7b60..0f665b8 100644 (file)
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  */
 
+#include <linux/clk.h>
+#include <linux/clockchips.h>
+#include <linux/clocksource.h>
+#include <linux/delay.h>
+#include <linux/err.h>
 #include <linux/init.h>
-#include <linux/platform_device.h>
-#include <linux/spinlock.h>
 #include <linux/interrupt.h>
-#include <linux/ioport.h>
-#include <linux/delay.h>
 #include <linux/io.h>
-#include <linux/clk.h>
+#include <linux/ioport.h>
 #include <linux/irq.h>
-#include <linux/err.h>
-#include <linux/clocksource.h>
-#include <linux/clockchips.h>
-#include <linux/sh_timer.h>
-#include <linux/slab.h>
 #include <linux/module.h>
+#include <linux/of.h>
+#include <linux/platform_device.h>
 #include <linux/pm_domain.h>
 #include <linux/pm_runtime.h>
+#include <linux/sh_timer.h>
+#include <linux/slab.h>
+#include <linux/spinlock.h>
+
+enum sh_tmu_model {
+       SH_TMU,
+       SH_TMU_SH3,
+};
+
+struct sh_tmu_device;
+
+struct sh_tmu_channel {
+       struct sh_tmu_device *tmu;
+       unsigned int index;
+
+       void __iomem *base;
+       int irq;
 
-struct sh_tmu_priv {
-       void __iomem *mapbase;
-       struct clk *clk;
-       struct irqaction irqaction;
-       struct platform_device *pdev;
        unsigned long rate;
        unsigned long periodic;
        struct clock_event_device ced;
@@ -48,196 +54,226 @@ struct sh_tmu_priv {
        unsigned int enable_count;
 };
 
-static DEFINE_RAW_SPINLOCK(sh_tmu_lock);
+struct sh_tmu_device {
+       struct platform_device *pdev;
+
+       void __iomem *mapbase;
+       struct clk *clk;
+
+       enum sh_tmu_model model;
+
+       raw_spinlock_t lock; /* Protect the shared start/stop register */
+
+       struct sh_tmu_channel *channels;
+       unsigned int num_channels;
+
+       bool has_clockevent;
+       bool has_clocksource;
+};
 
 #define TSTR -1 /* shared register */
 #define TCOR  0 /* channel register */
 #define TCNT 1 /* channel register */
 #define TCR 2 /* channel register */
 
-static inline unsigned long sh_tmu_read(struct sh_tmu_priv *p, int reg_nr)
+#define TCR_UNF                        (1 << 8)
+#define TCR_UNIE               (1 << 5)
+#define TCR_TPSC_CLK4          (0 << 0)
+#define TCR_TPSC_CLK16         (1 << 0)
+#define TCR_TPSC_CLK64         (2 << 0)
+#define TCR_TPSC_CLK256                (3 << 0)
+#define TCR_TPSC_CLK1024       (4 << 0)
+#define TCR_TPSC_MASK          (7 << 0)
+
+static inline unsigned long sh_tmu_read(struct sh_tmu_channel *ch, int reg_nr)
 {
-       struct sh_timer_config *cfg = p->pdev->dev.platform_data;
-       void __iomem *base = p->mapbase;
        unsigned long offs;
 
-       if (reg_nr == TSTR)
-               return ioread8(base - cfg->channel_offset);
+       if (reg_nr == TSTR) {
+               switch (ch->tmu->model) {
+               case SH_TMU_SH3:
+                       return ioread8(ch->tmu->mapbase + 2);
+               case SH_TMU:
+                       return ioread8(ch->tmu->mapbase + 4);
+               }
+       }
 
        offs = reg_nr << 2;
 
        if (reg_nr == TCR)
-               return ioread16(base + offs);
+               return ioread16(ch->base + offs);
        else
-               return ioread32(base + offs);
+               return ioread32(ch->base + offs);
 }
 
-static inline void sh_tmu_write(struct sh_tmu_priv *p, int reg_nr,
+static inline void sh_tmu_write(struct sh_tmu_channel *ch, int reg_nr,
                                unsigned long value)
 {
-       struct sh_timer_config *cfg = p->pdev->dev.platform_data;
-       void __iomem *base = p->mapbase;
        unsigned long offs;
 
        if (reg_nr == TSTR) {
-               iowrite8(value, base - cfg->channel_offset);
-               return;
+               switch (ch->tmu->model) {
+               case SH_TMU_SH3:
+                       return iowrite8(value, ch->tmu->mapbase + 2);
+               case SH_TMU:
+                       return iowrite8(value, ch->tmu->mapbase + 4);
+               }
        }
 
        offs = reg_nr << 2;
 
        if (reg_nr == TCR)
-               iowrite16(value, base + offs);
+               iowrite16(value, ch->base + offs);
        else
-               iowrite32(value, base + offs);
+               iowrite32(value, ch->base + offs);
 }
 
-static void sh_tmu_start_stop_ch(struct sh_tmu_priv *p, int start)
+static void sh_tmu_start_stop_ch(struct sh_tmu_channel *ch, int start)
 {
-       struct sh_timer_config *cfg = p->pdev->dev.platform_data;
        unsigned long flags, value;
 
        /* start stop register shared by multiple timer channels */
-       raw_spin_lock_irqsave(&sh_tmu_lock, flags);
-       value = sh_tmu_read(p, TSTR);
+       raw_spin_lock_irqsave(&ch->tmu->lock, flags);
+       value = sh_tmu_read(ch, TSTR);
 
        if (start)
-               value |= 1 << cfg->timer_bit;
+               value |= 1 << ch->index;
        else
-               value &= ~(1 << cfg->timer_bit);
+               value &= ~(1 << ch->index);
 
-       sh_tmu_write(p, TSTR, value);
-       raw_spin_unlock_irqrestore(&sh_tmu_lock, flags);
+       sh_tmu_write(ch, TSTR, value);
+       raw_spin_unlock_irqrestore(&ch->tmu->lock, flags);
 }
 
-static int __sh_tmu_enable(struct sh_tmu_priv *p)
+static int __sh_tmu_enable(struct sh_tmu_channel *ch)
 {
        int ret;
 
        /* enable clock */
-       ret = clk_enable(p->clk);
+       ret = clk_enable(ch->tmu->clk);
        if (ret) {
-               dev_err(&p->pdev->dev, "cannot enable clock\n");
+               dev_err(&ch->tmu->pdev->dev, "ch%u: cannot enable clock\n",
+                       ch->index);
                return ret;
        }
 
        /* make sure channel is disabled */
-       sh_tmu_start_stop_ch(p, 0);
+       sh_tmu_start_stop_ch(ch, 0);
 
        /* maximum timeout */
-       sh_tmu_write(p, TCOR, 0xffffffff);
-       sh_tmu_write(p, TCNT, 0xffffffff);
+       sh_tmu_write(ch, TCOR, 0xffffffff);
+       sh_tmu_write(ch, TCNT, 0xffffffff);
 
        /* configure channel to parent clock / 4, irq off */
-       p->rate = clk_get_rate(p->clk) / 4;
-       sh_tmu_write(p, TCR, 0x0000);
+       ch->rate = clk_get_rate(ch->tmu->clk) / 4;
+       sh_tmu_write(ch, TCR, TCR_TPSC_CLK4);
 
        /* enable channel */
-       sh_tmu_start_stop_ch(p, 1);
+       sh_tmu_start_stop_ch(ch, 1);
 
        return 0;
 }
 
-static int sh_tmu_enable(struct sh_tmu_priv *p)
+static int sh_tmu_enable(struct sh_tmu_channel *ch)
 {
-       if (p->enable_count++ > 0)
+       if (ch->enable_count++ > 0)
                return 0;
 
-       pm_runtime_get_sync(&p->pdev->dev);
-       dev_pm_syscore_device(&p->pdev->dev, true);
+       pm_runtime_get_sync(&ch->tmu->pdev->dev);
+       dev_pm_syscore_device(&ch->tmu->pdev->dev, true);
 
-       return __sh_tmu_enable(p);
+       return __sh_tmu_enable(ch);
 }
 
-static void __sh_tmu_disable(struct sh_tmu_priv *p)
+static void __sh_tmu_disable(struct sh_tmu_channel *ch)
 {
        /* disable channel */
-       sh_tmu_start_stop_ch(p, 0);
+       sh_tmu_start_stop_ch(ch, 0);
 
        /* disable interrupts in TMU block */
-       sh_tmu_write(p, TCR, 0x0000);
+       sh_tmu_write(ch, TCR, TCR_TPSC_CLK4);
 
        /* stop clock */
-       clk_disable(p->clk);
+       clk_disable(ch->tmu->clk);
 }
 
-static void sh_tmu_disable(struct sh_tmu_priv *p)
+static void sh_tmu_disable(struct sh_tmu_channel *ch)
 {
-       if (WARN_ON(p->enable_count == 0))
+       if (WARN_ON(ch->enable_count == 0))
                return;
 
-       if (--p->enable_count > 0)
+       if (--ch->enable_count > 0)
                return;
 
-       __sh_tmu_disable(p);
+       __sh_tmu_disable(ch);
 
-       dev_pm_syscore_device(&p->pdev->dev, false);
-       pm_runtime_put(&p->pdev->dev);
+       dev_pm_syscore_device(&ch->tmu->pdev->dev, false);
+       pm_runtime_put(&ch->tmu->pdev->dev);
 }
 
-static void sh_tmu_set_next(struct sh_tmu_priv *p, unsigned long delta,
+static void sh_tmu_set_next(struct sh_tmu_channel *ch, unsigned long delta,
                            int periodic)
 {
        /* stop timer */
-       sh_tmu_start_stop_ch(p, 0);
+       sh_tmu_start_stop_ch(ch, 0);
 
        /* acknowledge interrupt */
-       sh_tmu_read(p, TCR);
+       sh_tmu_read(ch, TCR);
 
        /* enable interrupt */
-       sh_tmu_write(p, TCR, 0x0020);
+       sh_tmu_write(ch, TCR, TCR_UNIE | TCR_TPSC_CLK4);
 
        /* reload delta value in case of periodic timer */
        if (periodic)
-               sh_tmu_write(p, TCOR, delta);
+               sh_tmu_write(ch, TCOR, delta);
        else
-               sh_tmu_write(p, TCOR, 0xffffffff);
+               sh_tmu_write(ch, TCOR, 0xffffffff);
 
-       sh_tmu_write(p, TCNT, delta);
+       sh_tmu_write(ch, TCNT, delta);
 
        /* start timer */
-       sh_tmu_start_stop_ch(p, 1);
+       sh_tmu_start_stop_ch(ch, 1);
 }
 
 static irqreturn_t sh_tmu_interrupt(int irq, void *dev_id)
 {
-       struct sh_tmu_priv *p = dev_id;
+       struct sh_tmu_channel *ch = dev_id;
 
        /* disable or acknowledge interrupt */
-       if (p->ced.mode == CLOCK_EVT_MODE_ONESHOT)
-               sh_tmu_write(p, TCR, 0x0000);
+       if (ch->ced.mode == CLOCK_EVT_MODE_ONESHOT)
+               sh_tmu_write(ch, TCR, TCR_TPSC_CLK4);
        else
-               sh_tmu_write(p, TCR, 0x0020);
+               sh_tmu_write(ch, TCR, TCR_UNIE | TCR_TPSC_CLK4);
 
        /* notify clockevent layer */
-       p->ced.event_handler(&p->ced);
+       ch->ced.event_handler(&ch->ced);
        return IRQ_HANDLED;
 }
 
-static struct sh_tmu_priv *cs_to_sh_tmu(struct clocksource *cs)
+static struct sh_tmu_channel *cs_to_sh_tmu(struct clocksource *cs)
 {
-       return container_of(cs, struct sh_tmu_priv, cs);
+       return container_of(cs, struct sh_tmu_channel, cs);
 }
 
 static cycle_t sh_tmu_clocksource_read(struct clocksource *cs)
 {
-       struct sh_tmu_priv *p = cs_to_sh_tmu(cs);
+       struct sh_tmu_channel *ch = cs_to_sh_tmu(cs);
 
-       return sh_tmu_read(p, TCNT) ^ 0xffffffff;
+       return sh_tmu_read(ch, TCNT) ^ 0xffffffff;
 }
 
 static int sh_tmu_clocksource_enable(struct clocksource *cs)
 {
-       struct sh_tmu_priv *p = cs_to_sh_tmu(cs);
+       struct sh_tmu_channel *ch = cs_to_sh_tmu(cs);
        int ret;
 
-       if (WARN_ON(p->cs_enabled))
+       if (WARN_ON(ch->cs_enabled))
                return 0;
 
-       ret = sh_tmu_enable(p);
+       ret = sh_tmu_enable(ch);
        if (!ret) {
-               __clocksource_updatefreq_hz(cs, p->rate);
-               p->cs_enabled = true;
+               __clocksource_updatefreq_hz(cs, ch->rate);
+               ch->cs_enabled = true;
        }
 
        return ret;
@@ -245,48 +281,48 @@ static int sh_tmu_clocksource_enable(struct clocksource *cs)
 
 static void sh_tmu_clocksource_disable(struct clocksource *cs)
 {
-       struct sh_tmu_priv *p = cs_to_sh_tmu(cs);
+       struct sh_tmu_channel *ch = cs_to_sh_tmu(cs);
 
-       if (WARN_ON(!p->cs_enabled))
+       if (WARN_ON(!ch->cs_enabled))
                return;
 
-       sh_tmu_disable(p);
-       p->cs_enabled = false;
+       sh_tmu_disable(ch);
+       ch->cs_enabled = false;
 }
 
 static void sh_tmu_clocksource_suspend(struct clocksource *cs)
 {
-       struct sh_tmu_priv *p = cs_to_sh_tmu(cs);
+       struct sh_tmu_channel *ch = cs_to_sh_tmu(cs);
 
-       if (!p->cs_enabled)
+       if (!ch->cs_enabled)
                return;
 
-       if (--p->enable_count == 0) {
-               __sh_tmu_disable(p);
-               pm_genpd_syscore_poweroff(&p->pdev->dev);
+       if (--ch->enable_count == 0) {
+               __sh_tmu_disable(ch);
+               pm_genpd_syscore_poweroff(&ch->tmu->pdev->dev);
        }
 }
 
 static void sh_tmu_clocksource_resume(struct clocksource *cs)
 {
-       struct sh_tmu_priv *p = cs_to_sh_tmu(cs);
+       struct sh_tmu_channel *ch = cs_to_sh_tmu(cs);
 
-       if (!p->cs_enabled)
+       if (!ch->cs_enabled)
                return;
 
-       if (p->enable_count++ == 0) {
-               pm_genpd_syscore_poweron(&p->pdev->dev);
-               __sh_tmu_enable(p);
+       if (ch->enable_count++ == 0) {
+               pm_genpd_syscore_poweron(&ch->tmu->pdev->dev);
+               __sh_tmu_enable(ch);
        }
 }
 
-static int sh_tmu_register_clocksource(struct sh_tmu_priv *p,
-                                      char *name, unsigned long rating)
+static int sh_tmu_register_clocksource(struct sh_tmu_channel *ch,
+                                      const char *name)
 {
-       struct clocksource *cs = &p->cs;
+       struct clocksource *cs = &ch->cs;
 
        cs->name = name;
-       cs->rating = rating;
+       cs->rating = 200;
        cs->read = sh_tmu_clocksource_read;
        cs->enable = sh_tmu_clocksource_enable;
        cs->disable = sh_tmu_clocksource_disable;
@@ -295,43 +331,44 @@ static int sh_tmu_register_clocksource(struct sh_tmu_priv *p,
        cs->mask = CLOCKSOURCE_MASK(32);
        cs->flags = CLOCK_SOURCE_IS_CONTINUOUS;
 
-       dev_info(&p->pdev->dev, "used as clock source\n");
+       dev_info(&ch->tmu->pdev->dev, "ch%u: used as clock source\n",
+                ch->index);
 
        /* Register with dummy 1 Hz value, gets updated in ->enable() */
        clocksource_register_hz(cs, 1);
        return 0;
 }
 
-static struct sh_tmu_priv *ced_to_sh_tmu(struct clock_event_device *ced)
+static struct sh_tmu_channel *ced_to_sh_tmu(struct clock_event_device *ced)
 {
-       return container_of(ced, struct sh_tmu_priv, ced);
+       return container_of(ced, struct sh_tmu_channel, ced);
 }
 
-static void sh_tmu_clock_event_start(struct sh_tmu_priv *p, int periodic)
+static void sh_tmu_clock_event_start(struct sh_tmu_channel *ch, int periodic)
 {
-       struct clock_event_device *ced = &p->ced;
+       struct clock_event_device *ced = &ch->ced;
 
-       sh_tmu_enable(p);
+       sh_tmu_enable(ch);
 
-       clockevents_config(ced, p->rate);
+       clockevents_config(ced, ch->rate);
 
        if (periodic) {
-               p->periodic = (p->rate + HZ/2) / HZ;
-               sh_tmu_set_next(p, p->periodic, 1);
+               ch->periodic = (ch->rate + HZ/2) / HZ;
+               sh_tmu_set_next(ch, ch->periodic, 1);
        }
 }
 
 static void sh_tmu_clock_event_mode(enum clock_event_mode mode,
                                    struct clock_event_device *ced)
 {
-       struct sh_tmu_priv *p = ced_to_sh_tmu(ced);
+       struct sh_tmu_channel *ch = ced_to_sh_tmu(ced);
        int disabled = 0;
 
        /* deal with old setting first */
        switch (ced->mode) {
        case CLOCK_EVT_MODE_PERIODIC:
        case CLOCK_EVT_MODE_ONESHOT:
-               sh_tmu_disable(p);
+               sh_tmu_disable(ch);
                disabled = 1;
                break;
        default:
@@ -340,16 +377,18 @@ static void sh_tmu_clock_event_mode(enum clock_event_mode mode,
 
        switch (mode) {
        case CLOCK_EVT_MODE_PERIODIC:
-               dev_info(&p->pdev->dev, "used for periodic clock events\n");
-               sh_tmu_clock_event_start(p, 1);
+               dev_info(&ch->tmu->pdev->dev,
+                        "ch%u: used for periodic clock events\n", ch->index);
+               sh_tmu_clock_event_start(ch, 1);
                break;
        case CLOCK_EVT_MODE_ONESHOT:
-               dev_info(&p->pdev->dev, "used for oneshot clock events\n");
-               sh_tmu_clock_event_start(p, 0);
+               dev_info(&ch->tmu->pdev->dev,
+                        "ch%u: used for oneshot clock events\n", ch->index);
+               sh_tmu_clock_event_start(ch, 0);
                break;
        case CLOCK_EVT_MODE_UNUSED:
                if (!disabled)
-                       sh_tmu_disable(p);
+                       sh_tmu_disable(ch);
                break;
        case CLOCK_EVT_MODE_SHUTDOWN:
        default:
@@ -360,147 +399,213 @@ static void sh_tmu_clock_event_mode(enum clock_event_mode mode,
 static int sh_tmu_clock_event_next(unsigned long delta,
                                   struct clock_event_device *ced)
 {
-       struct sh_tmu_priv *p = ced_to_sh_tmu(ced);
+       struct sh_tmu_channel *ch = ced_to_sh_tmu(ced);
 
        BUG_ON(ced->mode != CLOCK_EVT_MODE_ONESHOT);
 
        /* program new delta value */
-       sh_tmu_set_next(p, delta, 0);
+       sh_tmu_set_next(ch, delta, 0);
        return 0;
 }
 
 static void sh_tmu_clock_event_suspend(struct clock_event_device *ced)
 {
-       pm_genpd_syscore_poweroff(&ced_to_sh_tmu(ced)->pdev->dev);
+       pm_genpd_syscore_poweroff(&ced_to_sh_tmu(ced)->tmu->pdev->dev);
 }
 
 static void sh_tmu_clock_event_resume(struct clock_event_device *ced)
 {
-       pm_genpd_syscore_poweron(&ced_to_sh_tmu(ced)->pdev->dev);
+       pm_genpd_syscore_poweron(&ced_to_sh_tmu(ced)->tmu->pdev->dev);
 }
 
-static void sh_tmu_register_clockevent(struct sh_tmu_priv *p,
-                                      char *name, unsigned long rating)
+static void sh_tmu_register_clockevent(struct sh_tmu_channel *ch,
+                                      const char *name)
 {
-       struct clock_event_device *ced = &p->ced;
+       struct clock_event_device *ced = &ch->ced;
        int ret;
 
-       memset(ced, 0, sizeof(*ced));
-
        ced->name = name;
        ced->features = CLOCK_EVT_FEAT_PERIODIC;
        ced->features |= CLOCK_EVT_FEAT_ONESHOT;
-       ced->rating = rating;
+       ced->rating = 200;
        ced->cpumask = cpumask_of(0);
        ced->set_next_event = sh_tmu_clock_event_next;
        ced->set_mode = sh_tmu_clock_event_mode;
        ced->suspend = sh_tmu_clock_event_suspend;
        ced->resume = sh_tmu_clock_event_resume;
 
-       dev_info(&p->pdev->dev, "used for clock events\n");
+       dev_info(&ch->tmu->pdev->dev, "ch%u: used for clock events\n",
+                ch->index);
 
        clockevents_config_and_register(ced, 1, 0x300, 0xffffffff);
 
-       ret = setup_irq(p->irqaction.irq, &p->irqaction);
+       ret = request_irq(ch->irq, sh_tmu_interrupt,
+                         IRQF_TIMER | IRQF_IRQPOLL | IRQF_NOBALANCING,
+                         dev_name(&ch->tmu->pdev->dev), ch);
        if (ret) {
-               dev_err(&p->pdev->dev, "failed to request irq %d\n",
-                       p->irqaction.irq);
+               dev_err(&ch->tmu->pdev->dev, "ch%u: failed to request irq %d\n",
+                       ch->index, ch->irq);
                return;
        }
 }
 
-static int sh_tmu_register(struct sh_tmu_priv *p, char *name,
-                   unsigned long clockevent_rating,
-                   unsigned long clocksource_rating)
+static int sh_tmu_register(struct sh_tmu_channel *ch, const char *name,
+                          bool clockevent, bool clocksource)
 {
-       if (clockevent_rating)
-               sh_tmu_register_clockevent(p, name, clockevent_rating);
-       else if (clocksource_rating)
-               sh_tmu_register_clocksource(p, name, clocksource_rating);
+       if (clockevent) {
+               ch->tmu->has_clockevent = true;
+               sh_tmu_register_clockevent(ch, name);
+       } else if (clocksource) {
+               ch->tmu->has_clocksource = true;
+               sh_tmu_register_clocksource(ch, name);
+       }
 
        return 0;
 }
 
-static int sh_tmu_setup(struct sh_tmu_priv *p, struct platform_device *pdev)
+static int sh_tmu_channel_setup(struct sh_tmu_channel *ch, unsigned int index,
+                               bool clockevent, bool clocksource,
+                               struct sh_tmu_device *tmu)
 {
-       struct sh_timer_config *cfg = pdev->dev.platform_data;
-       struct resource *res;
-       int irq, ret;
-       ret = -ENXIO;
+       /* Skip unused channels. */
+       if (!clockevent && !clocksource)
+               return 0;
 
-       memset(p, 0, sizeof(*p));
-       p->pdev = pdev;
+       ch->tmu = tmu;
+       ch->index = index;
 
-       if (!cfg) {
-               dev_err(&p->pdev->dev, "missing platform data\n");
-               goto err0;
+       if (tmu->model == SH_TMU_SH3)
+               ch->base = tmu->mapbase + 4 + ch->index * 12;
+       else
+               ch->base = tmu->mapbase + 8 + ch->index * 12;
+
+       ch->irq = platform_get_irq(tmu->pdev, index);
+       if (ch->irq < 0) {
+               dev_err(&tmu->pdev->dev, "ch%u: failed to get irq\n",
+                       ch->index);
+               return ch->irq;
        }
 
-       platform_set_drvdata(pdev, p);
+       ch->cs_enabled = false;
+       ch->enable_count = 0;
+
+       return sh_tmu_register(ch, dev_name(&tmu->pdev->dev),
+                              clockevent, clocksource);
+}
 
-       res = platform_get_resource(p->pdev, IORESOURCE_MEM, 0);
+static int sh_tmu_map_memory(struct sh_tmu_device *tmu)
+{
+       struct resource *res;
+
+       res = platform_get_resource(tmu->pdev, IORESOURCE_MEM, 0);
        if (!res) {
-               dev_err(&p->pdev->dev, "failed to get I/O memory\n");
-               goto err0;
+               dev_err(&tmu->pdev->dev, "failed to get I/O memory\n");
+               return -ENXIO;
        }
 
-       irq = platform_get_irq(p->pdev, 0);
-       if (irq < 0) {
-               dev_err(&p->pdev->dev, "failed to get irq\n");
-               goto err0;
+       tmu->mapbase = ioremap_nocache(res->start, resource_size(res));
+       if (tmu->mapbase == NULL)
+               return -ENXIO;
+
+       return 0;
+}
+
+static int sh_tmu_parse_dt(struct sh_tmu_device *tmu)
+{
+       struct device_node *np = tmu->pdev->dev.of_node;
+
+       tmu->model = SH_TMU;
+       tmu->num_channels = 3;
+
+       of_property_read_u32(np, "#renesas,channels", &tmu->num_channels);
+
+       if (tmu->num_channels != 2 && tmu->num_channels != 3) {
+               dev_err(&tmu->pdev->dev, "invalid number of channels %u\n",
+                       tmu->num_channels);
+               return -EINVAL;
        }
 
-       /* map memory, let mapbase point to our channel */
-       p->mapbase = ioremap_nocache(res->start, resource_size(res));
-       if (p->mapbase == NULL) {
-               dev_err(&p->pdev->dev, "failed to remap I/O memory\n");
-               goto err0;
+       return 0;
+}
+
+static int sh_tmu_setup(struct sh_tmu_device *tmu, struct platform_device *pdev)
+{
+       unsigned int i;
+       int ret;
+
+       tmu->pdev = pdev;
+
+       raw_spin_lock_init(&tmu->lock);
+
+       if (IS_ENABLED(CONFIG_OF) && pdev->dev.of_node) {
+               ret = sh_tmu_parse_dt(tmu);
+               if (ret < 0)
+                       return ret;
+       } else if (pdev->dev.platform_data) {
+               const struct platform_device_id *id = pdev->id_entry;
+               struct sh_timer_config *cfg = pdev->dev.platform_data;
+
+               tmu->model = id->driver_data;
+               tmu->num_channels = hweight8(cfg->channels_mask);
+       } else {
+               dev_err(&tmu->pdev->dev, "missing platform data\n");
+               return -ENXIO;
        }
 
-       /* setup data for setup_irq() (too early for request_irq()) */
-       p->irqaction.name = dev_name(&p->pdev->dev);
-       p->irqaction.handler = sh_tmu_interrupt;
-       p->irqaction.dev_id = p;
-       p->irqaction.irq = irq;
-       p->irqaction.flags = IRQF_TIMER | IRQF_IRQPOLL | IRQF_NOBALANCING;
-
-       /* get hold of clock */
-       p->clk = clk_get(&p->pdev->dev, "tmu_fck");
-       if (IS_ERR(p->clk)) {
-               dev_err(&p->pdev->dev, "cannot get clock\n");
-               ret = PTR_ERR(p->clk);
-               goto err1;
+       /* Get hold of clock. */
+       tmu->clk = clk_get(&tmu->pdev->dev, "fck");
+       if (IS_ERR(tmu->clk)) {
+               dev_err(&tmu->pdev->dev, "cannot get clock\n");
+               return PTR_ERR(tmu->clk);
        }
 
-       ret = clk_prepare(p->clk);
+       ret = clk_prepare(tmu->clk);
        if (ret < 0)
-               goto err2;
+               goto err_clk_put;
 
-       p->cs_enabled = false;
-       p->enable_count = 0;
+       /* Map the memory resource. */
+       ret = sh_tmu_map_memory(tmu);
+       if (ret < 0) {
+               dev_err(&tmu->pdev->dev, "failed to remap I/O memory\n");
+               goto err_clk_unprepare;
+       }
 
-       ret = sh_tmu_register(p, (char *)dev_name(&p->pdev->dev),
-                             cfg->clockevent_rating,
-                             cfg->clocksource_rating);
-       if (ret < 0)
-               goto err3;
+       /* Allocate and setup the channels. */
+       tmu->channels = kzalloc(sizeof(*tmu->channels) * tmu->num_channels,
+                               GFP_KERNEL);
+       if (tmu->channels == NULL) {
+               ret = -ENOMEM;
+               goto err_unmap;
+       }
+
+       /*
+        * Use the first channel as a clock event device and the second channel
+        * as a clock source.
+        */
+       for (i = 0; i < tmu->num_channels; ++i) {
+               ret = sh_tmu_channel_setup(&tmu->channels[i], i,
+                                          i == 0, i == 1, tmu);
+               if (ret < 0)
+                       goto err_unmap;
+       }
+
+       platform_set_drvdata(pdev, tmu);
 
        return 0;
 
- err3:
-       clk_unprepare(p->clk);
- err2:
-       clk_put(p->clk);
- err1:
-       iounmap(p->mapbase);
- err0:
+err_unmap:
+       kfree(tmu->channels);
+       iounmap(tmu->mapbase);
+err_clk_unprepare:
+       clk_unprepare(tmu->clk);
+err_clk_put:
+       clk_put(tmu->clk);
        return ret;
 }
 
 static int sh_tmu_probe(struct platform_device *pdev)
 {
-       struct sh_tmu_priv *p = platform_get_drvdata(pdev);
-       struct sh_timer_config *cfg = pdev->dev.platform_data;
+       struct sh_tmu_device *tmu = platform_get_drvdata(pdev);
        int ret;
 
        if (!is_early_platform_device(pdev)) {
@@ -508,20 +613,18 @@ static int sh_tmu_probe(struct platform_device *pdev)
                pm_runtime_enable(&pdev->dev);
        }
 
-       if (p) {
+       if (tmu) {
                dev_info(&pdev->dev, "kept as earlytimer\n");
                goto out;
        }
 
-       p = kmalloc(sizeof(*p), GFP_KERNEL);
-       if (p == NULL) {
-               dev_err(&pdev->dev, "failed to allocate driver data\n");
+       tmu = kzalloc(sizeof(*tmu), GFP_KERNEL);
+       if (tmu == NULL)
                return -ENOMEM;
-       }
 
-       ret = sh_tmu_setup(p, pdev);
+       ret = sh_tmu_setup(tmu, pdev);
        if (ret) {
-               kfree(p);
+               kfree(tmu);
                pm_runtime_idle(&pdev->dev);
                return ret;
        }
@@ -529,7 +632,7 @@ static int sh_tmu_probe(struct platform_device *pdev)
                return 0;
 
  out:
-       if (cfg->clockevent_rating || cfg->clocksource_rating)
+       if (tmu->has_clockevent || tmu->has_clocksource)
                pm_runtime_irq_safe(&pdev->dev);
        else
                pm_runtime_idle(&pdev->dev);
@@ -542,12 +645,27 @@ static int sh_tmu_remove(struct platform_device *pdev)
        return -EBUSY; /* cannot unregister clockevent and clocksource */
 }
 
+static const struct platform_device_id sh_tmu_id_table[] = {
+       { "sh-tmu", SH_TMU },
+       { "sh-tmu-sh3", SH_TMU_SH3 },
+       { }
+};
+MODULE_DEVICE_TABLE(platform, sh_tmu_id_table);
+
+static const struct of_device_id sh_tmu_of_table[] __maybe_unused = {
+       { .compatible = "renesas,tmu" },
+       { }
+};
+MODULE_DEVICE_TABLE(of, sh_tmu_of_table);
+
 static struct platform_driver sh_tmu_device_driver = {
        .probe          = sh_tmu_probe,
        .remove         = sh_tmu_remove,
        .driver         = {
                .name   = "sh_tmu",
-       }
+               .of_match_table = of_match_ptr(sh_tmu_of_table),
+       },
+       .id_table       = sh_tmu_id_table,
 };
 
 static int __init sh_tmu_init(void)
index 4854f81..b4cd343 100644 (file)
@@ -257,8 +257,7 @@ static void adjust_jiffies(unsigned long val, struct cpufreq_freqs *ci)
                pr_debug("saving %lu as reference value for loops_per_jiffy; "
                        "freq is %u kHz\n", l_p_j_ref, l_p_j_ref_freq);
        }
-       if ((val == CPUFREQ_POSTCHANGE && ci->old != ci->new) ||
-           (val == CPUFREQ_RESUMECHANGE || val == CPUFREQ_SUSPENDCHANGE)) {
+       if (val == CPUFREQ_POSTCHANGE && ci->old != ci->new) {
                loops_per_jiffy = cpufreq_scale(l_p_j_ref, l_p_j_ref_freq,
                                                                ci->new);
                pr_debug("scaling loops_per_jiffy to %lu "
index dadd9e0..0349125 100644 (file)
@@ -2,21 +2,39 @@
 # DMA engine configuration for sh
 #
 
+#
+# DMA Engine Helpers
+#
+
 config SH_DMAE_BASE
        bool "Renesas SuperH DMA Engine support"
-       depends on (SUPERH && SH_DMA) || (ARM && ARCH_SHMOBILE)
+       depends on SUPERH || ARCH_SHMOBILE || COMPILE_TEST
+       depends on !SUPERH || SH_DMA
        depends on !SH_DMA_API
        default y
        select DMA_ENGINE
        help
          Enable support for the Renesas SuperH DMA controllers.
 
+#
+# DMA Controllers
+#
+
 config SH_DMAE
        tristate "Renesas SuperH DMAC support"
        depends on SH_DMAE_BASE
        help
          Enable support for the Renesas SuperH DMA controllers.
 
+if SH_DMAE
+
+config SH_DMAE_R8A73A4
+       def_bool y
+       depends on ARCH_R8A73A4
+       depends on OF
+
+endif
+
 config SUDMAC
        tristate "Renesas SUDMAC support"
        depends on SH_DMAE_BASE
@@ -29,6 +47,8 @@ config RCAR_HPB_DMAE
        help
          Enable support for the Renesas R-Car series DMA controllers.
 
-config SHDMA_R8A73A4
-       def_bool y
-       depends on ARCH_R8A73A4 && SH_DMAE != n
+config RCAR_AUDMAC_PP
+       tristate "Renesas R-Car Audio DMAC Peripheral Peripheral support"
+       depends on SH_DMAE_BASE
+       help
+         Enable support for the Renesas R-Car Audio DMAC Peripheral Peripheral controllers.
index e856af2..0a5cfdb 100644 (file)
@@ -1,9 +1,18 @@
+#
+# DMA Engine Helpers
+#
+
 obj-$(CONFIG_SH_DMAE_BASE) += shdma-base.o shdma-of.o
-obj-$(CONFIG_SH_DMAE) += shdma.o
+
+#
+# DMA Controllers
+#
+
 shdma-y := shdmac.o
-ifeq ($(CONFIG_OF),y)
-shdma-$(CONFIG_SHDMA_R8A73A4) += shdma-r8a73a4.o
-endif
+shdma-$(CONFIG_SH_DMAE_R8A73A4) += shdma-r8a73a4.o
 shdma-objs := $(shdma-y)
+obj-$(CONFIG_SH_DMAE) += shdma.o
+
 obj-$(CONFIG_SUDMAC) += sudmac.o
 obj-$(CONFIG_RCAR_HPB_DMAE) += rcar-hpbdma.o
+obj-$(CONFIG_RCAR_AUDMAC_PP) += rcar-audmapp.o
diff --git a/drivers/dma/sh/rcar-audmapp.c b/drivers/dma/sh/rcar-audmapp.c
new file mode 100644 (file)
index 0000000..2de7728
--- /dev/null
@@ -0,0 +1,320 @@
+/*
+ * This is for Renesas R-Car Audio-DMAC-peri-peri.
+ *
+ * Copyright (C) 2014 Renesas Electronics Corporation
+ * Copyright (C) 2014 Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
+ *
+ * based on the drivers/dma/sh/shdma.c
+ *
+ * Copyright (C) 2011-2012 Guennadi Liakhovetski <g.liakhovetski@gmx.de>
+ * Copyright (C) 2009 Nobuhiro Iwamatsu <iwamatsu.nobuhiro@renesas.com>
+ * Copyright (C) 2009 Renesas Solutions, Inc. All rights reserved.
+ * Copyright (C) 2007 Freescale Semiconductor, Inc. All rights reserved.
+ *
+ * This is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ */
+#include <linux/delay.h>
+#include <linux/init.h>
+#include <linux/module.h>
+#include <linux/slab.h>
+#include <linux/dmaengine.h>
+#include <linux/platform_data/dma-rcar-audmapp.h>
+#include <linux/platform_device.h>
+#include <linux/shdma-base.h>
+
+/*
+ * DMA register
+ */
+#define PDMASAR                0x00
+#define PDMADAR                0x04
+#define PDMACHCR       0x0c
+
+/* PDMACHCR */
+#define PDMACHCR_DE            (1 << 0)
+
+#define AUDMAPP_MAX_CHANNELS   29
+
+/* Default MEMCPY transfer size = 2^2 = 4 bytes */
+#define LOG2_DEFAULT_XFER_SIZE 2
+#define AUDMAPP_SLAVE_NUMBER   256
+#define AUDMAPP_LEN_MAX                (16 * 1024 * 1024)
+
+struct audmapp_chan {
+       struct shdma_chan shdma_chan;
+       struct audmapp_slave_config *config;
+       void __iomem *base;
+};
+
+struct audmapp_device {
+       struct shdma_dev shdma_dev;
+       struct audmapp_pdata *pdata;
+       struct device *dev;
+       void __iomem *chan_reg;
+};
+
+#define to_chan(chan) container_of(chan, struct audmapp_chan, shdma_chan)
+#define to_dev(chan) container_of(chan->shdma_chan.dma_chan.device,    \
+                                 struct audmapp_device, shdma_dev.dma_dev)
+
+static void audmapp_write(struct audmapp_chan *auchan, u32 data, u32 reg)
+{
+       struct audmapp_device *audev = to_dev(auchan);
+       struct device *dev = audev->dev;
+
+       dev_dbg(dev, "w %p : %08x\n", auchan->base + reg, data);
+
+       iowrite32(data, auchan->base + reg);
+}
+
+static u32 audmapp_read(struct audmapp_chan *auchan, u32 reg)
+{
+       return ioread32(auchan->base + reg);
+}
+
+static void audmapp_halt(struct shdma_chan *schan)
+{
+       struct audmapp_chan *auchan = to_chan(schan);
+       int i;
+
+       audmapp_write(auchan, 0, PDMACHCR);
+
+       for (i = 0; i < 1024; i++) {
+               if (0 == audmapp_read(auchan, PDMACHCR))
+                       return;
+               udelay(1);
+       }
+}
+
+static void audmapp_start_xfer(struct shdma_chan *schan,
+                              struct shdma_desc *sdecs)
+{
+       struct audmapp_chan *auchan = to_chan(schan);
+       struct audmapp_device *audev = to_dev(auchan);
+       struct audmapp_slave_config *cfg = auchan->config;
+       struct device *dev = audev->dev;
+       u32 chcr = cfg->chcr | PDMACHCR_DE;
+
+       dev_dbg(dev, "src/dst/chcr = %pad/%pad/%x\n",
+               &cfg->src, &cfg->dst, cfg->chcr);
+
+       audmapp_write(auchan, cfg->src, PDMASAR);
+       audmapp_write(auchan, cfg->dst, PDMADAR);
+       audmapp_write(auchan, chcr,     PDMACHCR);
+}
+
+static struct audmapp_slave_config *
+audmapp_find_slave(struct audmapp_chan *auchan, int slave_id)
+{
+       struct audmapp_device *audev = to_dev(auchan);
+       struct audmapp_pdata *pdata = audev->pdata;
+       struct audmapp_slave_config *cfg;
+       int i;
+
+       if (slave_id >= AUDMAPP_SLAVE_NUMBER)
+               return NULL;
+
+       for (i = 0, cfg = pdata->slave; i < pdata->slave_num; i++, cfg++)
+               if (cfg->slave_id == slave_id)
+                       return cfg;
+
+       return NULL;
+}
+
+static int audmapp_set_slave(struct shdma_chan *schan, int slave_id,
+                            dma_addr_t slave_addr, bool try)
+{
+       struct audmapp_chan *auchan = to_chan(schan);
+       struct audmapp_slave_config *cfg =
+               audmapp_find_slave(auchan, slave_id);
+
+       if (!cfg)
+               return -ENODEV;
+       if (try)
+               return 0;
+
+       auchan->config  = cfg;
+
+       return 0;
+}
+
+static int audmapp_desc_setup(struct shdma_chan *schan,
+                             struct shdma_desc *sdecs,
+                             dma_addr_t src, dma_addr_t dst, size_t *len)
+{
+       struct audmapp_chan *auchan = to_chan(schan);
+       struct audmapp_slave_config *cfg = auchan->config;
+
+       if (!cfg)
+               return -ENODEV;
+
+       if (*len > (size_t)AUDMAPP_LEN_MAX)
+               *len = (size_t)AUDMAPP_LEN_MAX;
+
+       return 0;
+}
+
+static void audmapp_setup_xfer(struct shdma_chan *schan,
+                              int slave_id)
+{
+}
+
+static dma_addr_t audmapp_slave_addr(struct shdma_chan *schan)
+{
+       return 0; /* always fixed address */
+}
+
+static bool audmapp_channel_busy(struct shdma_chan *schan)
+{
+       struct audmapp_chan *auchan = to_chan(schan);
+       u32 chcr = audmapp_read(auchan, PDMACHCR);
+
+       return chcr & ~PDMACHCR_DE;
+}
+
+static bool audmapp_desc_completed(struct shdma_chan *schan,
+                                  struct shdma_desc *sdesc)
+{
+       return true;
+}
+
+static struct shdma_desc *audmapp_embedded_desc(void *buf, int i)
+{
+       return &((struct shdma_desc *)buf)[i];
+}
+
+static const struct shdma_ops audmapp_shdma_ops = {
+       .halt_channel   = audmapp_halt,
+       .desc_setup     = audmapp_desc_setup,
+       .set_slave      = audmapp_set_slave,
+       .start_xfer     = audmapp_start_xfer,
+       .embedded_desc  = audmapp_embedded_desc,
+       .setup_xfer     = audmapp_setup_xfer,
+       .slave_addr     = audmapp_slave_addr,
+       .channel_busy   = audmapp_channel_busy,
+       .desc_completed = audmapp_desc_completed,
+};
+
+static int audmapp_chan_probe(struct platform_device *pdev,
+                             struct audmapp_device *audev, int id)
+{
+       struct shdma_dev *sdev = &audev->shdma_dev;
+       struct audmapp_chan *auchan;
+       struct shdma_chan *schan;
+       struct device *dev = audev->dev;
+
+       auchan = devm_kzalloc(dev, sizeof(*auchan), GFP_KERNEL);
+       if (!auchan)
+               return -ENOMEM;
+
+       schan = &auchan->shdma_chan;
+       schan->max_xfer_len = AUDMAPP_LEN_MAX;
+
+       shdma_chan_probe(sdev, schan, id);
+
+       auchan->base = audev->chan_reg + 0x20 + (0x10 * id);
+       dev_dbg(dev, "%02d : %p / %p", id, auchan->base, audev->chan_reg);
+
+       return 0;
+}
+
+static void audmapp_chan_remove(struct audmapp_device *audev)
+{
+       struct dma_device *dma_dev = &audev->shdma_dev.dma_dev;
+       struct shdma_chan *schan;
+       int i;
+
+       shdma_for_each_chan(schan, &audev->shdma_dev, i) {
+               BUG_ON(!schan);
+               shdma_chan_remove(schan);
+       }
+       dma_dev->chancnt = 0;
+}
+
+static int audmapp_probe(struct platform_device *pdev)
+{
+       struct audmapp_pdata *pdata = pdev->dev.platform_data;
+       struct audmapp_device *audev;
+       struct shdma_dev *sdev;
+       struct dma_device *dma_dev;
+       struct resource *res;
+       int err, i;
+
+       if (!pdata)
+               return -ENODEV;
+
+       res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
+
+       audev = devm_kzalloc(&pdev->dev, sizeof(*audev), GFP_KERNEL);
+       if (!audev)
+               return -ENOMEM;
+
+       audev->dev      = &pdev->dev;
+       audev->pdata    = pdata;
+       audev->chan_reg = devm_ioremap_resource(&pdev->dev, res);
+       if (IS_ERR(audev->chan_reg))
+               return PTR_ERR(audev->chan_reg);
+
+       sdev            = &audev->shdma_dev;
+       sdev->ops       = &audmapp_shdma_ops;
+       sdev->desc_size = sizeof(struct shdma_desc);
+
+       dma_dev                 = &sdev->dma_dev;
+       dma_dev->copy_align     = LOG2_DEFAULT_XFER_SIZE;
+       dma_cap_set(DMA_SLAVE, dma_dev->cap_mask);
+
+       err = shdma_init(&pdev->dev, sdev, AUDMAPP_MAX_CHANNELS);
+       if (err < 0)
+               return err;
+
+       platform_set_drvdata(pdev, audev);
+
+       /* Create DMA Channel */
+       for (i = 0; i < AUDMAPP_MAX_CHANNELS; i++) {
+               err = audmapp_chan_probe(pdev, audev, i);
+               if (err)
+                       goto chan_probe_err;
+       }
+
+       err = dma_async_device_register(dma_dev);
+       if (err < 0)
+               goto chan_probe_err;
+
+       return err;
+
+chan_probe_err:
+       audmapp_chan_remove(audev);
+       shdma_cleanup(sdev);
+
+       return err;
+}
+
+static int audmapp_remove(struct platform_device *pdev)
+{
+       struct audmapp_device *audev = platform_get_drvdata(pdev);
+       struct dma_device *dma_dev = &audev->shdma_dev.dma_dev;
+
+       dma_async_device_unregister(dma_dev);
+
+       audmapp_chan_remove(audev);
+       shdma_cleanup(&audev->shdma_dev);
+
+       return 0;
+}
+
+static struct platform_driver audmapp_driver = {
+       .probe          = audmapp_probe,
+       .remove         = audmapp_remove,
+       .driver         = {
+               .owner  = THIS_MODULE,
+               .name   = "rcar-audmapp-engine",
+       },
+};
+module_platform_driver(audmapp_driver);
+
+MODULE_AUTHOR("Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>");
+MODULE_DESCRIPTION("Renesas R-Car Audio DMAC peri-peri driver");
+MODULE_LICENSE("GPL");
index a2b8258..a1b0ef4 100644 (file)
@@ -45,7 +45,7 @@ enum {
        ((((i) & TS_LOW_BIT) << TS_LOW_SHIFT) |\
         (((i) & TS_HI_BIT)  << TS_HI_SHIFT))
 
-#define CHCR_TX(xmit_sz) (DM_FIX | SM_INC | 0x800 | TS_INDEX2VAL((xmit_sz)))
-#define CHCR_RX(xmit_sz) (DM_INC | SM_FIX | 0x800 | TS_INDEX2VAL((xmit_sz)))
+#define CHCR_TX(xmit_sz) (DM_FIX | SM_INC | RS_ERS | TS_INDEX2VAL((xmit_sz)))
+#define CHCR_RX(xmit_sz) (DM_INC | SM_FIX | RS_ERS | TS_INDEX2VAL((xmit_sz)))
 
 #endif
index 2e7b394..a26ded2 100644 (file)
@@ -227,7 +227,7 @@ bool shdma_chan_filter(struct dma_chan *chan, void *arg)
        struct shdma_chan *schan = to_shdma_chan(chan);
        struct shdma_dev *sdev = to_shdma_dev(schan->dma_chan.device);
        const struct shdma_ops *ops = sdev->ops;
-       int match = (int)arg;
+       int match = (long)arg;
        int ret;
 
        if (match < 0)
@@ -304,6 +304,7 @@ static dma_async_tx_callback __ld_cleanup(struct shdma_chan *schan, bool all)
        dma_async_tx_callback callback = NULL;
        void *param = NULL;
        unsigned long flags;
+       LIST_HEAD(cyclic_list);
 
        spin_lock_irqsave(&schan->chan_lock, flags);
        list_for_each_entry_safe(desc, _desc, &schan->ld_queue, node) {
@@ -369,10 +370,16 @@ static dma_async_tx_callback __ld_cleanup(struct shdma_chan *schan, bool all)
                if (((desc->mark == DESC_COMPLETED ||
                      desc->mark == DESC_WAITING) &&
                     async_tx_test_ack(&desc->async_tx)) || all) {
-                       /* Remove from ld_queue list */
-                       desc->mark = DESC_IDLE;
 
-                       list_move(&desc->node, &schan->ld_free);
+                       if (all || !desc->cyclic) {
+                               /* Remove from ld_queue list */
+                               desc->mark = DESC_IDLE;
+                               list_move(&desc->node, &schan->ld_free);
+                       } else {
+                               /* reuse as cyclic */
+                               desc->mark = DESC_SUBMITTED;
+                               list_move_tail(&desc->node, &cyclic_list);
+                       }
 
                        if (list_empty(&schan->ld_queue)) {
                                dev_dbg(schan->dev, "Bring down channel %d\n", schan->id);
@@ -389,6 +396,8 @@ static dma_async_tx_callback __ld_cleanup(struct shdma_chan *schan, bool all)
                 */
                schan->dma_chan.completed_cookie = schan->dma_chan.cookie;
 
+       list_splice_tail(&cyclic_list, &schan->ld_queue);
+
        spin_unlock_irqrestore(&schan->chan_lock, flags);
 
        if (callback)
@@ -491,8 +500,8 @@ static struct shdma_desc *shdma_add_desc(struct shdma_chan *schan,
        }
 
        dev_dbg(schan->dev,
-               "chaining (%u/%u)@%x -> %x with %p, cookie %d\n",
-               copy_size, *len, *src, *dst, &new->async_tx,
+               "chaining (%zu/%zu)@%pad -> %pad with %p, cookie %d\n",
+               copy_size, *len, src, dst, &new->async_tx,
                new->async_tx.cookie);
 
        new->mark = DESC_PREPARED;
@@ -521,7 +530,7 @@ static struct shdma_desc *shdma_add_desc(struct shdma_chan *schan,
  */
 static struct dma_async_tx_descriptor *shdma_prep_sg(struct shdma_chan *schan,
        struct scatterlist *sgl, unsigned int sg_len, dma_addr_t *addr,
-       enum dma_transfer_direction direction, unsigned long flags)
+       enum dma_transfer_direction direction, unsigned long flags, bool cyclic)
 {
        struct scatterlist *sg;
        struct shdma_desc *first = NULL, *new = NULL /* compiler... */;
@@ -555,8 +564,8 @@ static struct dma_async_tx_descriptor *shdma_prep_sg(struct shdma_chan *schan,
                        goto err_get_desc;
 
                do {
-                       dev_dbg(schan->dev, "Add SG #%d@%p[%d], dma %llx\n",
-                               i, sg, len, (unsigned long long)sg_addr);
+                       dev_dbg(schan->dev, "Add SG #%d@%p[%zu], dma %pad\n",
+                               i, sg, len, &sg_addr);
 
                        if (direction == DMA_DEV_TO_MEM)
                                new = shdma_add_desc(schan, flags,
@@ -569,7 +578,11 @@ static struct dma_async_tx_descriptor *shdma_prep_sg(struct shdma_chan *schan,
                        if (!new)
                                goto err_get_desc;
 
-                       new->chunks = chunks--;
+                       new->cyclic = cyclic;
+                       if (cyclic)
+                               new->chunks = 1;
+                       else
+                               new->chunks = chunks--;
                        list_add_tail(&new->node, &tx_list);
                } while (len);
        }
@@ -612,7 +625,8 @@ static struct dma_async_tx_descriptor *shdma_prep_memcpy(
        sg_dma_address(&sg) = dma_src;
        sg_dma_len(&sg) = len;
 
-       return shdma_prep_sg(schan, &sg, 1, &dma_dest, DMA_MEM_TO_MEM, flags);
+       return shdma_prep_sg(schan, &sg, 1, &dma_dest, DMA_MEM_TO_MEM,
+                            flags, false);
 }
 
 static struct dma_async_tx_descriptor *shdma_prep_slave_sg(
@@ -640,7 +654,50 @@ static struct dma_async_tx_descriptor *shdma_prep_slave_sg(
        slave_addr = ops->slave_addr(schan);
 
        return shdma_prep_sg(schan, sgl, sg_len, &slave_addr,
-                             direction, flags);
+                            direction, flags, false);
+}
+
+struct dma_async_tx_descriptor *shdma_prep_dma_cyclic(
+       struct dma_chan *chan, dma_addr_t buf_addr, size_t buf_len,
+       size_t period_len, enum dma_transfer_direction direction,
+       unsigned long flags, void *context)
+{
+       struct shdma_chan *schan = to_shdma_chan(chan);
+       struct shdma_dev *sdev = to_shdma_dev(schan->dma_chan.device);
+       const struct shdma_ops *ops = sdev->ops;
+       unsigned int sg_len = buf_len / period_len;
+       int slave_id = schan->slave_id;
+       dma_addr_t slave_addr;
+       struct scatterlist sgl[sg_len];
+       int i;
+
+       if (!chan)
+               return NULL;
+
+       BUG_ON(!schan->desc_num);
+
+       /* Someone calling slave DMA on a generic channel? */
+       if (slave_id < 0 || (buf_len < period_len)) {
+               dev_warn(schan->dev,
+                       "%s: bad parameter: buf_len=%d, period_len=%d, id=%d\n",
+                       __func__, buf_len, period_len, slave_id);
+               return NULL;
+       }
+
+       slave_addr = ops->slave_addr(schan);
+
+       sg_init_table(sgl, sg_len);
+       for (i = 0; i < sg_len; i++) {
+               dma_addr_t src = buf_addr + (period_len * i);
+
+               sg_set_page(&sgl[i], pfn_to_page(PFN_DOWN(src)), period_len,
+                           offset_in_page(src));
+               sg_dma_address(&sgl[i]) = src;
+               sg_dma_len(&sgl[i]) = period_len;
+       }
+
+       return shdma_prep_sg(schan, sgl, sg_len, &slave_addr,
+                            direction, flags, true);
 }
 
 static int shdma_control(struct dma_chan *chan, enum dma_ctrl_cmd cmd,
@@ -915,6 +972,7 @@ int shdma_init(struct device *dev, struct shdma_dev *sdev,
 
        /* Compulsory for DMA_SLAVE fields */
        dma_dev->device_prep_slave_sg = shdma_prep_slave_sg;
+       dma_dev->device_prep_dma_cyclic = shdma_prep_dma_cyclic;
        dma_dev->device_control = shdma_control;
 
        dma_dev->dev = dev;
index 06473a0..b4ff9d3 100644 (file)
@@ -33,7 +33,8 @@ static struct dma_chan *shdma_of_xlate(struct of_phandle_args *dma_spec,
        /* Only slave DMA channels can be allocated via DT */
        dma_cap_set(DMA_SLAVE, mask);
 
-       chan = dma_request_channel(mask, shdma_chan_filter, (void *)id);
+       chan = dma_request_channel(mask, shdma_chan_filter,
+                                  (void *)(uintptr_t)id);
        if (chan)
                to_shdma_chan(chan)->hw_req = id;
 
index 758a57b..2c0a969 100644 (file)
@@ -62,7 +62,7 @@ struct sh_dmae_desc {
 #define to_sh_dev(chan) container_of(chan->shdma_chan.dma_chan.device,\
                                     struct sh_dmae_device, shdma_dev.dma_dev)
 
-#ifdef CONFIG_SHDMA_R8A73A4
+#ifdef CONFIG_SH_DMAE_R8A73A4
 extern const struct sh_dmae_pdata r8a73a4_dma_pdata;
 #define r8a73a4_shdma_devid (&r8a73a4_dma_pdata)
 #else
index 0d765c0..5c1fbe7 100644 (file)
 #include "../dmaengine.h"
 #include "shdma.h"
 
-/* DMA register */
-#define SAR    0x00
-#define DAR    0x04
-#define TCR    0x08
-#define CHCR   0x0C
-#define DMAOR  0x40
+/* DMA registers */
+#define SAR    0x00    /* Source Address Register */
+#define DAR    0x04    /* Destination Address Register */
+#define TCR    0x08    /* Transfer Count Register */
+#define CHCR   0x0C    /* Channel Control Register */
+#define DMAOR  0x40    /* DMA Operation Register */
 
 #define TEND   0x18 /* USB-DMAC */
 
@@ -238,9 +238,8 @@ static void dmae_init(struct sh_dmae_chan *sh_chan)
 {
        /*
         * Default configuration for dual address memory-memory transfer.
-        * 0x400 represents auto-request.
         */
-       u32 chcr = DM_INC | SM_INC | 0x400 | log2size_to_chcr(sh_chan,
+       u32 chcr = DM_INC | SM_INC | RS_AUTO | log2size_to_chcr(sh_chan,
                                                   LOG2_DEFAULT_XFER_SIZE);
        sh_chan->xmit_shift = calc_xmit_shift(sh_chan, chcr);
        chcr_write(sh_chan, chcr);
index c7e9cdf..4e7df43 100644 (file)
@@ -178,8 +178,8 @@ static int sudmac_desc_setup(struct shdma_chan *schan,
        struct sudmac_chan *sc = to_chan(schan);
        struct sudmac_desc *sd = to_desc(sdesc);
 
-       dev_dbg(sc->shdma_chan.dev, "%s: src=%x, dst=%x, len=%d\n",
-               __func__, src, dst, *len);
+       dev_dbg(sc->shdma_chan.dev, "%s: src=%pad, dst=%pad, len=%zu\n",
+               __func__, &src, &dst, *len);
 
        if (*len > schan->max_xfer_len)
                *len = schan->max_xfer_len;
index ca76ce7..0d251dc 100644 (file)
@@ -26,6 +26,7 @@
 #include <linux/pinctrl/consumer.h>
 #include <linux/platform_data/gpio-rcar.h>
 #include <linux/platform_device.h>
+#include <linux/pm_runtime.h>
 #include <linux/spinlock.h>
 #include <linux/slab.h>
 
@@ -239,9 +240,9 @@ static int gpio_rcar_get(struct gpio_chip *chip, unsigned offset)
        /* testing on r8a7790 shows that INDT does not show correct pin state
         * when configured as output, so use OUTDT in case of output pins */
        if (gpio_rcar_read(gpio_to_priv(chip), INOUTSEL) & bit)
-               return (int)(gpio_rcar_read(gpio_to_priv(chip), OUTDT) & bit);
+               return !!(gpio_rcar_read(gpio_to_priv(chip), OUTDT) & bit);
        else
-               return (int)(gpio_rcar_read(gpio_to_priv(chip), INDT) & bit);
+               return !!(gpio_rcar_read(gpio_to_priv(chip), INDT) & bit);
 }
 
 static void gpio_rcar_set(struct gpio_chip *chip, unsigned offset, int value)
@@ -283,6 +284,7 @@ static int gpio_rcar_irq_domain_map(struct irq_domain *h, unsigned int irq,
 
 static struct irq_domain_ops gpio_rcar_irq_domain_ops = {
        .map    = gpio_rcar_irq_domain_map,
+       .xlate  = irq_domain_xlate_twocell,
 };
 
 struct gpio_rcar_info {
@@ -356,12 +358,12 @@ static int gpio_rcar_probe(struct platform_device *pdev)
        struct resource *io, *irq;
        struct gpio_chip *gpio_chip;
        struct irq_chip *irq_chip;
-       const char *name = dev_name(&pdev->dev);
+       struct device *dev = &pdev->dev;
+       const char *name = dev_name(dev);
        int ret;
 
-       p = devm_kzalloc(&pdev->dev, sizeof(*p), GFP_KERNEL);
+       p = devm_kzalloc(dev, sizeof(*p), GFP_KERNEL);
        if (!p) {
-               dev_err(&pdev->dev, "failed to allocate driver data\n");
                ret = -ENOMEM;
                goto err0;
        }
@@ -376,19 +378,21 @@ static int gpio_rcar_probe(struct platform_device *pdev)
 
        platform_set_drvdata(pdev, p);
 
+       pm_runtime_enable(dev);
+       pm_runtime_get_sync(dev);
+
        io = platform_get_resource(pdev, IORESOURCE_MEM, 0);
        irq = platform_get_resource(pdev, IORESOURCE_IRQ, 0);
 
        if (!io || !irq) {
-               dev_err(&pdev->dev, "missing IRQ or IOMEM\n");
+               dev_err(dev, "missing IRQ or IOMEM\n");
                ret = -EINVAL;
                goto err0;
        }
 
-       p->base = devm_ioremap_nocache(&pdev->dev, io->start,
-                                      resource_size(io));
+       p->base = devm_ioremap_nocache(dev, io->start, resource_size(io));
        if (!p->base) {
-               dev_err(&pdev->dev, "failed to remap I/O memory\n");
+               dev_err(dev, "failed to remap I/O memory\n");
                ret = -ENXIO;
                goto err0;
        }
@@ -402,7 +406,7 @@ static int gpio_rcar_probe(struct platform_device *pdev)
        gpio_chip->set = gpio_rcar_set;
        gpio_chip->to_irq = gpio_rcar_to_irq;
        gpio_chip->label = name;
-       gpio_chip->dev = &pdev->dev;
+       gpio_chip->dev = dev;
        gpio_chip->owner = THIS_MODULE;
        gpio_chip->base = p->config.gpio_base;
        gpio_chip->ngpio = p->config.number_of_pins;
@@ -421,30 +425,30 @@ static int gpio_rcar_probe(struct platform_device *pdev)
                                              &gpio_rcar_irq_domain_ops, p);
        if (!p->irq_domain) {
                ret = -ENXIO;
-               dev_err(&pdev->dev, "cannot initialize irq domain\n");
+               dev_err(dev, "cannot initialize irq domain\n");
                goto err0;
        }
 
-       if (devm_request_irq(&pdev->dev, irq->start,
-                            gpio_rcar_irq_handler, IRQF_SHARED, name, p)) {
-               dev_err(&pdev->dev, "failed to request IRQ\n");
+       if (devm_request_irq(dev, irq->start, gpio_rcar_irq_handler,
+                            IRQF_SHARED, name, p)) {
+               dev_err(dev, "failed to request IRQ\n");
                ret = -ENOENT;
                goto err1;
        }
 
        ret = gpiochip_add(gpio_chip);
        if (ret) {
-               dev_err(&pdev->dev, "failed to add GPIO controller\n");
+               dev_err(dev, "failed to add GPIO controller\n");
                goto err1;
        }
 
-       dev_info(&pdev->dev, "driving %d GPIOs\n", p->config.number_of_pins);
+       dev_info(dev, "driving %d GPIOs\n", p->config.number_of_pins);
 
        /* warn in case of mismatch if irq base is specified */
        if (p->config.irq_base) {
                ret = irq_find_mapping(p->irq_domain, 0);
                if (p->config.irq_base != ret)
-                       dev_warn(&pdev->dev, "irq base mismatch (%u/%u)\n",
+                       dev_warn(dev, "irq base mismatch (%u/%u)\n",
                                 p->config.irq_base, ret);
        }
 
@@ -452,7 +456,7 @@ static int gpio_rcar_probe(struct platform_device *pdev)
                ret = gpiochip_add_pin_range(gpio_chip, p->config.pctl_name, 0,
                                             gpio_chip->base, gpio_chip->ngpio);
                if (ret < 0)
-                       dev_warn(&pdev->dev, "failed to add pin range\n");
+                       dev_warn(dev, "failed to add pin range\n");
        }
 
        return 0;
@@ -460,6 +464,8 @@ static int gpio_rcar_probe(struct platform_device *pdev)
 err1:
        irq_domain_remove(p->irq_domain);
 err0:
+       pm_runtime_put(dev);
+       pm_runtime_disable(dev);
        return ret;
 }
 
@@ -473,6 +479,8 @@ static int gpio_rcar_remove(struct platform_device *pdev)
                return ret;
 
        irq_domain_remove(p->irq_domain);
+       pm_runtime_put(&pdev->dev);
+       pm_runtime_disable(&pdev->dev);
        return 0;
 }
 
index d8e835a..c96f608 100644 (file)
@@ -1,10 +1,12 @@
 config DRM_RCAR_DU
        tristate "DRM Support for R-Car Display Unit"
        depends on DRM && ARM
+       depends on ARCH_SHMOBILE || COMPILE_TEST
        select DRM_KMS_HELPER
        select DRM_KMS_CMA_HELPER
        select DRM_GEM_CMA_HELPER
        select DRM_KMS_FB_HELPER
+       select VIDEOMODE_HELPERS
        help
          Choose this option if you have an R-Car chipset.
          If M is selected the module will be called rcar-du-drm.
@@ -12,6 +14,7 @@ config DRM_RCAR_DU
 config DRM_RCAR_LVDS
        bool "R-Car DU LVDS Encoder Support"
        depends on DRM_RCAR_DU
+       depends on ARCH_R8A7790 || ARCH_R8A7791 || COMPILE_TEST
        help
          Enable support the R-Car Display Unit embedded LVDS encoders
          (currently only on R8A7790).
index fbf4be3..e97cbb3 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * rcar_du_crtc.c  --  R-Car Display Unit CRTCs
  *
- * Copyright (C) 2013 Renesas Corporation
+ * Copyright (C) 2013-2014 Renesas Electronics Corporation
  *
  * Contact: Laurent Pinchart (laurent.pinchart@ideasonboard.com)
  *
index 43e7575..e97ae50 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * rcar_du_crtc.h  --  R-Car Display Unit CRTCs
  *
- * Copyright (C) 2013 Renesas Corporation
+ * Copyright (C) 2013-2014 Renesas Electronics Corporation
  *
  * Contact: Laurent Pinchart (laurent.pinchart@ideasonboard.com)
  *
index 792fd1d..b9b7651 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * rcar_du_drv.c  --  R-Car Display Unit DRM driver
  *
- * Copyright (C) 2013 Renesas Corporation
+ * Copyright (C) 2013-2014 Renesas Electronics Corporation
  *
  * Contact: Laurent Pinchart (laurent.pinchart@ideasonboard.com)
  *
@@ -15,6 +15,7 @@
 #include <linux/io.h>
 #include <linux/mm.h>
 #include <linux/module.h>
+#include <linux/of_device.h>
 #include <linux/platform_device.h>
 #include <linux/pm.h>
 #include <linux/slab.h>
 #include "rcar_du_regs.h"
 
 /* -----------------------------------------------------------------------------
+ * Device Information
+ */
+
+static const struct rcar_du_device_info rcar_du_r8a7779_info = {
+       .features = 0,
+       .num_crtcs = 2,
+       .routes = {
+               /* R8A7779 has two RGB outputs and one (currently unsupported)
+                * TCON output.
+                */
+               [RCAR_DU_OUTPUT_DPAD0] = {
+                       .possible_crtcs = BIT(0),
+                       .encoder_type = DRM_MODE_ENCODER_NONE,
+                       .port = 0,
+               },
+               [RCAR_DU_OUTPUT_DPAD1] = {
+                       .possible_crtcs = BIT(1) | BIT(0),
+                       .encoder_type = DRM_MODE_ENCODER_NONE,
+                       .port = 1,
+               },
+       },
+       .num_lvds = 0,
+};
+
+static const struct rcar_du_device_info rcar_du_r8a7790_info = {
+       .features = RCAR_DU_FEATURE_CRTC_IRQ_CLOCK | RCAR_DU_FEATURE_DEFR8,
+       .quirks = RCAR_DU_QUIRK_ALIGN_128B | RCAR_DU_QUIRK_LVDS_LANES,
+       .num_crtcs = 3,
+       .routes = {
+               /* R8A7790 has one RGB output, two LVDS outputs and one
+                * (currently unsupported) TCON output.
+                */
+               [RCAR_DU_OUTPUT_DPAD0] = {
+                       .possible_crtcs = BIT(2) | BIT(1) | BIT(0),
+                       .encoder_type = DRM_MODE_ENCODER_NONE,
+                       .port = 0,
+               },
+               [RCAR_DU_OUTPUT_LVDS0] = {
+                       .possible_crtcs = BIT(0),
+                       .encoder_type = DRM_MODE_ENCODER_LVDS,
+                       .port = 1,
+               },
+               [RCAR_DU_OUTPUT_LVDS1] = {
+                       .possible_crtcs = BIT(2) | BIT(1),
+                       .encoder_type = DRM_MODE_ENCODER_LVDS,
+                       .port = 2,
+               },
+       },
+       .num_lvds = 2,
+};
+
+static const struct rcar_du_device_info rcar_du_r8a7791_info = {
+       .features = RCAR_DU_FEATURE_CRTC_IRQ_CLOCK | RCAR_DU_FEATURE_DEFR8,
+       .num_crtcs = 2,
+       .routes = {
+               /* R8A7791 has one RGB output, one LVDS output and one
+                * (currently unsupported) TCON output.
+                */
+               [RCAR_DU_OUTPUT_DPAD0] = {
+                       .possible_crtcs = BIT(1),
+                       .encoder_type = DRM_MODE_ENCODER_NONE,
+                       .port = 0,
+               },
+               [RCAR_DU_OUTPUT_LVDS0] = {
+                       .possible_crtcs = BIT(0),
+                       .encoder_type = DRM_MODE_ENCODER_LVDS,
+                       .port = 1,
+               },
+       },
+       .num_lvds = 1,
+};
+
+static const struct platform_device_id rcar_du_id_table[] = {
+       { "rcar-du-r8a7779", (kernel_ulong_t)&rcar_du_r8a7779_info },
+       { "rcar-du-r8a7790", (kernel_ulong_t)&rcar_du_r8a7790_info },
+       { "rcar-du-r8a7791", (kernel_ulong_t)&rcar_du_r8a7791_info },
+       { }
+};
+
+MODULE_DEVICE_TABLE(platform, rcar_du_id_table);
+
+static const struct of_device_id rcar_du_of_table[] = {
+       { .compatible = "renesas,du-r8a7779", .data = &rcar_du_r8a7779_info },
+       { .compatible = "renesas,du-r8a7790", .data = &rcar_du_r8a7790_info },
+       { .compatible = "renesas,du-r8a7791", .data = &rcar_du_r8a7791_info },
+       { }
+};
+
+MODULE_DEVICE_TABLE(of, rcar_du_of_table);
+
+/* -----------------------------------------------------------------------------
  * DRM operations
  */
 
@@ -53,12 +145,13 @@ static int rcar_du_unload(struct drm_device *dev)
 static int rcar_du_load(struct drm_device *dev, unsigned long flags)
 {
        struct platform_device *pdev = dev->platformdev;
+       struct device_node *np = pdev->dev.of_node;
        struct rcar_du_platform_data *pdata = pdev->dev.platform_data;
        struct rcar_du_device *rcdu;
        struct resource *mem;
        int ret;
 
-       if (pdata == NULL) {
+       if (pdata == NULL && np == NULL) {
                dev_err(dev->dev, "no platform data\n");
                return -ENODEV;
        }
@@ -71,7 +164,8 @@ static int rcar_du_load(struct drm_device *dev, unsigned long flags)
 
        rcdu->dev = &pdev->dev;
        rcdu->pdata = pdata;
-       rcdu->info = (struct rcar_du_device_info *)pdev->id_entry->driver_data;
+       rcdu->info = np ? of_match_device(rcar_du_of_table, rcdu->dev)->data
+                  : (void *)platform_get_device_id(pdev)->driver_data;
        rcdu->ddev = dev;
        dev->dev_private = rcdu;
 
@@ -187,7 +281,7 @@ static struct drm_driver rcar_du_driver = {
  * Power management
  */
 
-#if CONFIG_PM_SLEEP
+#ifdef CONFIG_PM_SLEEP
 static int rcar_du_pm_suspend(struct device *dev)
 {
        struct rcar_du_device *rcdu = dev_get_drvdata(dev);
@@ -231,77 +325,6 @@ static int rcar_du_remove(struct platform_device *pdev)
        return 0;
 }
 
-static const struct rcar_du_device_info rcar_du_r8a7779_info = {
-       .features = 0,
-       .num_crtcs = 2,
-       .routes = {
-               /* R8A7779 has two RGB outputs and one (currently unsupported)
-                * TCON output.
-                */
-               [RCAR_DU_OUTPUT_DPAD0] = {
-                       .possible_crtcs = BIT(0),
-                       .encoder_type = DRM_MODE_ENCODER_NONE,
-               },
-               [RCAR_DU_OUTPUT_DPAD1] = {
-                       .possible_crtcs = BIT(1) | BIT(0),
-                       .encoder_type = DRM_MODE_ENCODER_NONE,
-               },
-       },
-       .num_lvds = 0,
-};
-
-static const struct rcar_du_device_info rcar_du_r8a7790_info = {
-       .features = RCAR_DU_FEATURE_CRTC_IRQ_CLOCK | RCAR_DU_FEATURE_DEFR8,
-       .quirks = RCAR_DU_QUIRK_ALIGN_128B | RCAR_DU_QUIRK_LVDS_LANES,
-       .num_crtcs = 3,
-       .routes = {
-               /* R8A7790 has one RGB output, two LVDS outputs and one
-                * (currently unsupported) TCON output.
-                */
-               [RCAR_DU_OUTPUT_DPAD0] = {
-                       .possible_crtcs = BIT(2) | BIT(1) | BIT(0),
-                       .encoder_type = DRM_MODE_ENCODER_NONE,
-               },
-               [RCAR_DU_OUTPUT_LVDS0] = {
-                       .possible_crtcs = BIT(0),
-                       .encoder_type = DRM_MODE_ENCODER_LVDS,
-               },
-               [RCAR_DU_OUTPUT_LVDS1] = {
-                       .possible_crtcs = BIT(2) | BIT(1),
-                       .encoder_type = DRM_MODE_ENCODER_LVDS,
-               },
-       },
-       .num_lvds = 2,
-};
-
-static const struct rcar_du_device_info rcar_du_r8a7791_info = {
-       .features = RCAR_DU_FEATURE_CRTC_IRQ_CLOCK | RCAR_DU_FEATURE_DEFR8,
-       .num_crtcs = 2,
-       .routes = {
-               /* R8A7791 has one RGB output, one LVDS output and one
-                * (currently unsupported) TCON output.
-                */
-               [RCAR_DU_OUTPUT_DPAD0] = {
-                       .possible_crtcs = BIT(1),
-                       .encoder_type = DRM_MODE_ENCODER_NONE,
-               },
-               [RCAR_DU_OUTPUT_LVDS0] = {
-                       .possible_crtcs = BIT(0),
-                       .encoder_type = DRM_MODE_ENCODER_LVDS,
-               },
-       },
-       .num_lvds = 1,
-};
-
-static const struct platform_device_id rcar_du_id_table[] = {
-       { "rcar-du-r8a7779", (kernel_ulong_t)&rcar_du_r8a7779_info },
-       { "rcar-du-r8a7790", (kernel_ulong_t)&rcar_du_r8a7790_info },
-       { "rcar-du-r8a7791", (kernel_ulong_t)&rcar_du_r8a7791_info },
-       { }
-};
-
-MODULE_DEVICE_TABLE(platform, rcar_du_id_table);
-
 static struct platform_driver rcar_du_platform_driver = {
        .probe          = rcar_du_probe,
        .remove         = rcar_du_remove,
@@ -309,6 +332,7 @@ static struct platform_driver rcar_du_platform_driver = {
                .owner  = THIS_MODULE,
                .name   = "rcar-du",
                .pm     = &rcar_du_pm_ops,
+               .of_match_table = rcar_du_of_table,
        },
        .id_table       = rcar_du_id_table,
 };
index e31b735..8e49463 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * rcar_du_drv.h  --  R-Car Display Unit DRM driver
  *
- * Copyright (C) 2013 Renesas Corporation
+ * Copyright (C) 2013-2014 Renesas Electronics Corporation
  *
  * Contact: Laurent Pinchart (laurent.pinchart@ideasonboard.com)
  *
@@ -37,6 +37,7 @@ struct rcar_du_lvdsenc;
  * struct rcar_du_output_routing - Output routing specification
  * @possible_crtcs: bitmask of possible CRTCs for the output
  * @encoder_type: DRM type of the internal encoder associated with the output
+ * @port: device tree port number corresponding to this output route
  *
  * The DU has 5 possible outputs (DPAD0/1, LVDS0/1, TCON). Output routing data
  * specify the valid SoC outputs, which CRTCs can drive the output, and the type
@@ -45,6 +46,7 @@ struct rcar_du_lvdsenc;
 struct rcar_du_output_routing {
        unsigned int possible_crtcs;
        unsigned int encoder_type;
+       unsigned int port;
 };
 
 /*
index 3daa7a1..7c0ec95 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * rcar_du_encoder.c  --  R-Car Display Unit Encoder
  *
- * Copyright (C) 2013 Renesas Corporation
+ * Copyright (C) 2013-2014 Renesas Electronics Corporation
  *
  * Contact: Laurent Pinchart (laurent.pinchart@ideasonboard.com)
  *
@@ -142,7 +142,8 @@ static const struct drm_encoder_funcs encoder_funcs = {
 int rcar_du_encoder_init(struct rcar_du_device *rcdu,
                         enum rcar_du_encoder_type type,
                         enum rcar_du_output output,
-                        const struct rcar_du_encoder_data *data)
+                        const struct rcar_du_encoder_data *data,
+                        struct device_node *np)
 {
        struct rcar_du_encoder *renc;
        unsigned int encoder_type;
@@ -189,9 +190,11 @@ int rcar_du_encoder_init(struct rcar_du_device *rcdu,
        drm_encoder_helper_add(&renc->encoder, &encoder_helper_funcs);
 
        switch (encoder_type) {
-       case DRM_MODE_ENCODER_LVDS:
-               return rcar_du_lvds_connector_init(rcdu, renc,
-                                                  &data->connector.lvds.panel);
+       case DRM_MODE_ENCODER_LVDS: {
+               const struct rcar_du_panel_data *pdata =
+                       data ? &data->connector.lvds.panel : NULL;
+               return rcar_du_lvds_connector_init(rcdu, renc, pdata, np);
+       }
 
        case DRM_MODE_ENCODER_DAC:
                return rcar_du_vga_connector_init(rcdu, renc);
index 0e5a65e..bd62413 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * rcar_du_encoder.h  --  R-Car Display Unit Encoder
  *
- * Copyright (C) 2013 Renesas Corporation
+ * Copyright (C) 2013-2014 Renesas Electronics Corporation
  *
  * Contact: Laurent Pinchart (laurent.pinchart@ideasonboard.com)
  *
@@ -44,6 +44,7 @@ rcar_du_connector_best_encoder(struct drm_connector *connector);
 int rcar_du_encoder_init(struct rcar_du_device *rcdu,
                         enum rcar_du_encoder_type type,
                         enum rcar_du_output output,
-                        const struct rcar_du_encoder_data *data);
+                        const struct rcar_du_encoder_data *data,
+                        struct device_node *np);
 
 #endif /* __RCAR_DU_ENCODER_H__ */
index eb53cd9..4e7614b 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * rcar_du_group.c  --  R-Car Display Unit Channels Pair
  *
- * Copyright (C) 2013 Renesas Corporation
+ * Copyright (C) 2013-2014 Renesas Electronics Corporation
  *
  * Contact: Laurent Pinchart (laurent.pinchart@ideasonboard.com)
  *
index 5025930..0c38cdc 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * rcar_du_group.c  --  R-Car Display Unit Planes and CRTCs Group
  *
- * Copyright (C) 2013 Renesas Corporation
+ * Copyright (C) 2013-2014 Renesas Electronics Corporation
  *
  * Contact: Laurent Pinchart (laurent.pinchart@ideasonboard.com)
  *
index fbeabd9..6c24ad7 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * rcar_du_kms.c  --  R-Car Display Unit Mode Setting
  *
- * Copyright (C) 2013 Renesas Corporation
+ * Copyright (C) 2013-2014 Renesas Electronics Corporation
  *
  * Contact: Laurent Pinchart (laurent.pinchart@ideasonboard.com)
  *
@@ -17,6 +17,8 @@
 #include <drm/drm_fb_cma_helper.h>
 #include <drm/drm_gem_cma_helper.h>
 
+#include <linux/of_graph.h>
+
 #include "rcar_du_crtc.h"
 #include "rcar_du_drv.h"
 #include "rcar_du_encoder.h"
@@ -135,7 +137,9 @@ rcar_du_fb_create(struct drm_device *dev, struct drm_file *file_priv,
 {
        struct rcar_du_device *rcdu = dev->dev_private;
        const struct rcar_du_format_info *format;
+       unsigned int max_pitch;
        unsigned int align;
+       unsigned int bpp;
 
        format = rcar_du_format_info(mode_cmd->pixel_format);
        if (format == NULL) {
@@ -144,13 +148,20 @@ rcar_du_fb_create(struct drm_device *dev, struct drm_file *file_priv,
                return ERR_PTR(-EINVAL);
        }
 
+       /*
+        * The pitch and alignment constraints are expressed in pixels on the
+        * hardware side and in bytes in the DRM API.
+        */
+       bpp = format->planes == 2 ? 1 : format->bpp / 8;
+       max_pitch =  4096 * bpp;
+
        if (rcar_du_needs(rcdu, RCAR_DU_QUIRK_ALIGN_128B))
                align = 128;
        else
-               align = 16 * format->bpp / 8;
+               align = 16 * bpp;
 
        if (mode_cmd->pitches[0] & (align - 1) ||
-           mode_cmd->pitches[0] >= 8192) {
+           mode_cmd->pitches[0] >= max_pitch) {
                dev_dbg(dev->dev, "invalid pitch value %u\n",
                        mode_cmd->pitches[0]);
                return ERR_PTR(-EINVAL);
@@ -179,6 +190,205 @@ static const struct drm_mode_config_funcs rcar_du_mode_config_funcs = {
        .output_poll_changed = rcar_du_output_poll_changed,
 };
 
+static int rcar_du_encoders_init_pdata(struct rcar_du_device *rcdu)
+{
+       unsigned int num_encoders = 0;
+       unsigned int i;
+       int ret;
+
+       for (i = 0; i < rcdu->pdata->num_encoders; ++i) {
+               const struct rcar_du_encoder_data *pdata =
+                       &rcdu->pdata->encoders[i];
+               const struct rcar_du_output_routing *route =
+                       &rcdu->info->routes[pdata->output];
+
+               if (pdata->type == RCAR_DU_ENCODER_UNUSED)
+                       continue;
+
+               if (pdata->output >= RCAR_DU_OUTPUT_MAX ||
+                   route->possible_crtcs == 0) {
+                       dev_warn(rcdu->dev,
+                                "encoder %u references unexisting output %u, skipping\n",
+                                i, pdata->output);
+                       continue;
+               }
+
+               ret = rcar_du_encoder_init(rcdu, pdata->type, pdata->output,
+                                          pdata, NULL);
+               if (ret < 0)
+                       return ret;
+
+               num_encoders++;
+       }
+
+       return num_encoders;
+}
+
+static int rcar_du_encoders_init_dt_one(struct rcar_du_device *rcdu,
+                                       enum rcar_du_output output,
+                                       struct of_endpoint *ep)
+{
+       static const struct {
+               const char *compatible;
+               enum rcar_du_encoder_type type;
+       } encoders[] = {
+               { "adi,adv7123", RCAR_DU_ENCODER_VGA },
+               { "thine,thc63lvdm83d", RCAR_DU_ENCODER_LVDS },
+       };
+
+       enum rcar_du_encoder_type enc_type = RCAR_DU_ENCODER_NONE;
+       struct device_node *connector = NULL;
+       struct device_node *encoder = NULL;
+       struct device_node *prev = NULL;
+       struct device_node *entity_ep_node;
+       struct device_node *entity;
+       int ret;
+
+       /*
+        * Locate the connected entity and infer its type from the number of
+        * endpoints.
+        */
+       entity = of_graph_get_remote_port_parent(ep->local_node);
+       if (!entity) {
+               dev_dbg(rcdu->dev, "unconnected endpoint %s, skipping\n",
+                       ep->local_node->full_name);
+               return 0;
+       }
+
+       entity_ep_node = of_parse_phandle(ep->local_node, "remote-endpoint", 0);
+
+       while (1) {
+               struct device_node *ep_node;
+
+               ep_node = of_graph_get_next_endpoint(entity, prev);
+               of_node_put(prev);
+               prev = ep_node;
+
+               if (!ep_node)
+                       break;
+
+               if (ep_node == entity_ep_node)
+                       continue;
+
+               /*
+                * We've found one endpoint other than the input, this must
+                * be an encoder. Locate the connector.
+                */
+               encoder = entity;
+               connector = of_graph_get_remote_port_parent(ep_node);
+               of_node_put(ep_node);
+
+               if (!connector) {
+                       dev_warn(rcdu->dev,
+                                "no connector for encoder %s, skipping\n",
+                                encoder->full_name);
+                       of_node_put(entity_ep_node);
+                       of_node_put(encoder);
+                       return 0;
+               }
+
+               break;
+       }
+
+       of_node_put(entity_ep_node);
+
+       if (encoder) {
+               /*
+                * If an encoder has been found, get its type based on its
+                * compatible string.
+                */
+               unsigned int i;
+
+               for (i = 0; i < ARRAY_SIZE(encoders); ++i) {
+                       if (of_device_is_compatible(encoder,
+                                                   encoders[i].compatible)) {
+                               enc_type = encoders[i].type;
+                               break;
+                       }
+               }
+
+               if (i == ARRAY_SIZE(encoders)) {
+                       dev_warn(rcdu->dev,
+                                "unknown encoder type for %s, skipping\n",
+                                encoder->full_name);
+                       of_node_put(encoder);
+                       of_node_put(connector);
+                       return 0;
+               }
+       } else {
+               /*
+                * If no encoder has been found the entity must be the
+                * connector.
+                */
+               connector = entity;
+       }
+
+       ret = rcar_du_encoder_init(rcdu, enc_type, output, NULL, connector);
+       of_node_put(encoder);
+       of_node_put(connector);
+
+       return ret < 0 ? ret : 1;
+}
+
+static int rcar_du_encoders_init_dt(struct rcar_du_device *rcdu)
+{
+       struct device_node *np = rcdu->dev->of_node;
+       struct device_node *prev = NULL;
+       unsigned int num_encoders = 0;
+
+       /*
+        * Iterate over the endpoints and create one encoder for each output
+        * pipeline.
+        */
+       while (1) {
+               struct device_node *ep_node;
+               enum rcar_du_output output;
+               struct of_endpoint ep;
+               unsigned int i;
+               int ret;
+
+               ep_node = of_graph_get_next_endpoint(np, prev);
+               of_node_put(prev);
+               prev = ep_node;
+
+               if (ep_node == NULL)
+                       break;
+
+               ret = of_graph_parse_endpoint(ep_node, &ep);
+               if (ret < 0) {
+                       of_node_put(ep_node);
+                       return ret;
+               }
+
+               /* Find the output route corresponding to the port number. */
+               for (i = 0; i < RCAR_DU_OUTPUT_MAX; ++i) {
+                       if (rcdu->info->routes[i].possible_crtcs &&
+                           rcdu->info->routes[i].port == ep.port) {
+                               output = i;
+                               break;
+                       }
+               }
+
+               if (i == RCAR_DU_OUTPUT_MAX) {
+                       dev_warn(rcdu->dev,
+                                "port %u references unexisting output, skipping\n",
+                                ep.port);
+                       continue;
+               }
+
+               /* Process the output pipeline. */
+               ret = rcar_du_encoders_init_dt_one(rcdu, output, &ep);
+               if (ret < 0) {
+                       of_node_put(ep_node);
+                       return ret;
+               }
+
+               num_encoders += ret;
+       }
+
+       return num_encoders;
+}
+
 int rcar_du_modeset_init(struct rcar_du_device *rcdu)
 {
        static const unsigned int mmio_offsets[] = {
@@ -188,6 +398,7 @@ int rcar_du_modeset_init(struct rcar_du_device *rcdu)
        struct drm_device *dev = rcdu->ddev;
        struct drm_encoder *encoder;
        struct drm_fbdev_cma *fbdev;
+       unsigned int num_encoders;
        unsigned int num_groups;
        unsigned int i;
        int ret;
@@ -231,25 +442,15 @@ int rcar_du_modeset_init(struct rcar_du_device *rcdu)
        if (ret < 0)
                return ret;
 
-       for (i = 0; i < rcdu->pdata->num_encoders; ++i) {
-               const struct rcar_du_encoder_data *pdata =
-                       &rcdu->pdata->encoders[i];
-               const struct rcar_du_output_routing *route =
-                       &rcdu->info->routes[pdata->output];
-
-               if (pdata->type == RCAR_DU_ENCODER_UNUSED)
-                       continue;
+       if (rcdu->pdata)
+               ret = rcar_du_encoders_init_pdata(rcdu);
+       else
+               ret = rcar_du_encoders_init_dt(rcdu);
 
-               if (pdata->output >= RCAR_DU_OUTPUT_MAX ||
-                   route->possible_crtcs == 0) {
-                       dev_warn(rcdu->dev,
-                                "encoder %u references unexisting output %u, skipping\n",
-                                i, pdata->output);
-                       continue;
-               }
+       if (ret < 0)
+               return ret;
 
-               rcar_du_encoder_init(rcdu, pdata->type, pdata->output, pdata);
-       }
+       num_encoders = ret;
 
        /* Set the possible CRTCs and possible clones. There's always at least
         * one way for all encoders to clone each other, set all bits in the
@@ -261,7 +462,7 @@ int rcar_du_modeset_init(struct rcar_du_device *rcdu)
                        &rcdu->info->routes[renc->output];
 
                encoder->possible_crtcs = route->possible_crtcs;
-               encoder->possible_clones = (1 << rcdu->pdata->num_encoders) - 1;
+               encoder->possible_clones = (1 << num_encoders) - 1;
        }
 
        /* Now that the CRTCs have been initialized register the planes. */
index 5750e6a..07951d5 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * rcar_du_kms.h  --  R-Car Display Unit Mode Setting
  *
- * Copyright (C) 2013 Renesas Corporation
+ * Copyright (C) 2013-2014 Renesas Electronics Corporation
  *
  * Contact: Laurent Pinchart (laurent.pinchart@ideasonboard.com)
  *
index 4f3ba93..e3e3513 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * rcar_du_lvdscon.c  --  R-Car Display Unit LVDS Connector
  *
- * Copyright (C) 2013 Renesas Corporation
+ * Copyright (C) 2013-2014 Renesas Electronics Corporation
  *
  * Contact: Laurent Pinchart (laurent.pinchart@ideasonboard.com)
  *
 #include <drm/drm_crtc.h>
 #include <drm/drm_crtc_helper.h>
 
+#include <video/display_timing.h>
+#include <video/of_display_timing.h>
+#include <video/videomode.h>
+
 #include "rcar_du_drv.h"
 #include "rcar_du_encoder.h"
 #include "rcar_du_kms.h"
@@ -23,7 +27,7 @@
 struct rcar_du_lvds_connector {
        struct rcar_du_connector connector;
 
-       const struct rcar_du_panel_data *panel;
+       struct rcar_du_panel_data panel;
 };
 
 #define to_rcar_lvds_connector(c) \
@@ -40,18 +44,9 @@ static int rcar_du_lvds_connector_get_modes(struct drm_connector *connector)
                return 0;
 
        mode->type = DRM_MODE_TYPE_PREFERRED | DRM_MODE_TYPE_DRIVER;
-       mode->clock = lvdscon->panel->mode.clock;
-       mode->hdisplay = lvdscon->panel->mode.hdisplay;
-       mode->hsync_start = lvdscon->panel->mode.hsync_start;
-       mode->hsync_end = lvdscon->panel->mode.hsync_end;
-       mode->htotal = lvdscon->panel->mode.htotal;
-       mode->vdisplay = lvdscon->panel->mode.vdisplay;
-       mode->vsync_start = lvdscon->panel->mode.vsync_start;
-       mode->vsync_end = lvdscon->panel->mode.vsync_end;
-       mode->vtotal = lvdscon->panel->mode.vtotal;
-       mode->flags = lvdscon->panel->mode.flags;
-
-       drm_mode_set_name(mode);
+
+       drm_display_mode_from_videomode(&lvdscon->panel.mode, mode);
+
        drm_mode_probed_add(connector, mode);
 
        return 1;
@@ -90,7 +85,8 @@ static const struct drm_connector_funcs connector_funcs = {
 
 int rcar_du_lvds_connector_init(struct rcar_du_device *rcdu,
                                struct rcar_du_encoder *renc,
-                               const struct rcar_du_panel_data *panel)
+                               const struct rcar_du_panel_data *panel,
+                               /* TODO const */ struct device_node *np)
 {
        struct rcar_du_lvds_connector *lvdscon;
        struct drm_connector *connector;
@@ -100,11 +96,24 @@ int rcar_du_lvds_connector_init(struct rcar_du_device *rcdu,
        if (lvdscon == NULL)
                return -ENOMEM;
 
-       lvdscon->panel = panel;
+       if (panel) {
+               lvdscon->panel = *panel;
+       } else {
+               struct display_timing timing;
+
+               ret = of_get_display_timing(np, "panel-timing", &timing);
+               if (ret < 0)
+                       return ret;
+
+               videomode_from_timing(&timing, &lvdscon->panel.mode);
+
+               of_property_read_u32(np, "width-mm", &lvdscon->panel.width_mm);
+               of_property_read_u32(np, "height-mm", &lvdscon->panel.height_mm);
+       }
 
        connector = &lvdscon->connector.connector;
-       connector->display_info.width_mm = panel->width_mm;
-       connector->display_info.height_mm = panel->height_mm;
+       connector->display_info.width_mm = lvdscon->panel.width_mm;
+       connector->display_info.height_mm = lvdscon->panel.height_mm;
 
        ret = drm_connector_init(rcdu->ddev, connector, &connector_funcs,
                                 DRM_MODE_CONNECTOR_LVDS);
index bff8683..d11424d 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * rcar_du_lvdscon.h  --  R-Car Display Unit LVDS Connector
  *
- * Copyright (C) 2013 Renesas Corporation
+ * Copyright (C) 2013-2014 Renesas Electronics Corporation
  *
  * Contact: Laurent Pinchart (laurent.pinchart@ideasonboard.com)
  *
@@ -20,6 +20,7 @@ struct rcar_du_panel_data;
 
 int rcar_du_lvds_connector_init(struct rcar_du_device *rcdu,
                                struct rcar_du_encoder *renc,
-                               const struct rcar_du_panel_data *panel);
+                               const struct rcar_du_panel_data *panel,
+                               struct device_node *np);
 
 #endif /* __RCAR_DU_LVDSCON_H__ */
index df30a07..7cfb48c 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * rcar_du_lvdsenc.c  --  R-Car Display Unit LVDS Encoder
  *
- * Copyright (C) 2013 Renesas Corporation
+ * Copyright (C) 2013-2014 Renesas Electronics Corporation
  *
  * Contact: Laurent Pinchart (laurent.pinchart@ideasonboard.com)
  *
index 7051c6d..3303a55 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * rcar_du_lvdsenc.h  --  R-Car Display Unit LVDS Encoder
  *
- * Copyright (C) 2013 Renesas Corporation
+ * Copyright (C) 2013-2014 Renesas Electronics Corporation
  *
  * Contact: Laurent Pinchart (laurent.pinchart@ideasonboard.com)
  *
index 3fb69d9..72a7cb4 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * rcar_du_plane.c  --  R-Car Display Unit Planes
  *
- * Copyright (C) 2013 Renesas Corporation
+ * Copyright (C) 2013-2014 Renesas Electronics Corporation
  *
  * Contact: Laurent Pinchart (laurent.pinchart@ideasonboard.com)
  *
index f94f9ce..3021288 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * rcar_du_plane.h  --  R-Car Display Unit Planes
  *
- * Copyright (C) 2013 Renesas Corporation
+ * Copyright (C) 2013-2014 Renesas Electronics Corporation
  *
  * Contact: Laurent Pinchart (laurent.pinchart@ideasonboard.com)
  *
index 41d563a..3bcbf58 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * rcar_du_vgacon.c  --  R-Car Display Unit VGA Connector
  *
- * Copyright (C) 2013 Renesas Corporation
+ * Copyright (C) 2013-2014 Renesas Electronics Corporation
  *
  * Contact: Laurent Pinchart (laurent.pinchart@ideasonboard.com)
  *
index b12b0cf..112f503 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * rcar_du_vgacon.h  --  R-Car Display Unit VGA Connector
  *
- * Copyright (C) 2013 Renesas Corporation
+ * Copyright (C) 2013-2014 Renesas Electronics Corporation
  *
  * Contact: Laurent Pinchart (laurent.pinchart@ideasonboard.com)
  *
index 65ef966..899bede 100644 (file)
     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.
  * ------------------------------------------------------------------------- */
 
 /* With some changes from Frodo Looijaard <frodol@dds.nl>, Kyösti Mälkki
index 8b10f88..580dbf0 100644 (file)
  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  *  GNU General Public License for more details.
- *
- *  You should have received a copy of the GNU General Public License
- *  along with this program; if not, write to the Free Software
- *  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
- *  MA 02110-1301 USA.
  */
 
 #include <linux/kernel.h>
index 3437009..270d84b 100644 (file)
  *  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.
- *
  * With some changes from Kyösti Mälkki <kmalkki@cc.hut.fi> and
  * Frodo Looijaard <frodol@dds.nl>, and also from Martin Bailey
  * <mbailey@littlefeet-inc.com>
index 1ec703e..262ee80 100644 (file)
     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.                                                 */
+    GNU General Public License for more details.                       */
 /* --------------------------------------------------------------------        */
 
 /* With some changes from Frodo Looijaard <frodol@dds.nl> */
index c5eec02..bfacb9e 100644 (file)
@@ -109,6 +109,7 @@ config I2C_I801
            Avoton (SOC)
            Wellsburg (PCH)
            Coleto Creek (PCH)
+           Wildcat Point (PCH)
            Wildcat Point-LP (PCH)
            BayTrail (SOC)
 
@@ -937,7 +938,7 @@ config I2C_ACORN
 
 config I2C_ELEKTOR
        tristate "Elektor ISA card"
-       depends on ISA && HAS_IOPORT && BROKEN_ON_SMP
+       depends on ISA && HAS_IOPORT_MAP && BROKEN_ON_SMP
        select I2C_ALGOPCF
        help
          This supports the PCF8584 ISA bus I2C adapter.  Say Y if you own
index 7d60d3a..4f2d788 100644 (file)
  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  *  GNU General Public License for more details.
- *
- *  You should have received a copy of the GNU General Public License
- *  along with this program; if not, write to the Free Software
- *  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 */
 
 /*
@@ -494,7 +490,7 @@ static struct i2c_adapter ali1535_adapter = {
        .algo           = &smbus_algorithm,
 };
 
-static DEFINE_PCI_DEVICE_TABLE(ali1535_ids) = {
+static const struct pci_device_id ali1535_ids[] = {
        { PCI_DEVICE(PCI_VENDOR_ID_AL, PCI_DEVICE_ID_AL_M7101) },
        { },
 };
index 4611e47..98a1c97 100644 (file)
@@ -416,7 +416,7 @@ static void ali1563_remove(struct pci_dev *dev)
        ali1563_shutdown(dev);
 }
 
-static DEFINE_PCI_DEVICE_TABLE(ali1563_id_table) = {
+static const struct pci_device_id ali1563_id_table[] = {
        { PCI_DEVICE(PCI_VENDOR_ID_AL, PCI_DEVICE_ID_AL_M1563) },
        {},
 };
index 4823206..45c5c48 100644 (file)
     but WITHOUT ANY WARRANTY; without even the implied warranty of
     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
     GNU General Public License for more details.
-
-    You should have received a copy of the GNU General Public License
-    along with this program; if not, write to the Free Software
-    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 */
 
 /*
@@ -476,7 +472,7 @@ static struct i2c_adapter ali15x3_adapter = {
        .algo           = &smbus_algorithm,
 };
 
-static DEFINE_PCI_DEVICE_TABLE(ali15x3_ids) = {
+static const struct pci_device_id ali15x3_ids[] = {
        { PCI_DEVICE(PCI_VENDOR_ID_AL, PCI_DEVICE_ID_AL_M7101) },
        { 0, }
 };
index 41fc683..65e3240 100644 (file)
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  */
  
 /*
index 819d3c1..6c7113d 100644 (file)
     but WITHOUT ANY WARRANTY; without even the implied warranty of
     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
     GNU General Public License for more details.
-
-    You should have received a copy of the GNU General Public License
-    along with this program; if not, write to the Free Software
-    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 */
 
 /*
@@ -307,7 +303,7 @@ static const char* chipname[] = {
        "nVidia nForce", "AMD8111",
 };
 
-static DEFINE_PCI_DEVICE_TABLE(amd756_ids) = {
+static const struct pci_device_id amd756_ids[] = {
        { PCI_DEVICE(PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_VIPER_740B),
          .driver_data = AMD756 },
        { PCI_DEVICE(PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_VIPER_7413),
index f3d4d79..95a80a8 100644 (file)
@@ -414,7 +414,7 @@ static const struct i2c_algorithm smbus_algorithm = {
 };
 
 
-static DEFINE_PCI_DEVICE_TABLE(amd8111_ids) = {
+static const struct pci_device_id amd8111_ids[] = {
        { PCI_DEVICE(PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_8111_SMBUS2) },
        { 0, }
 };
index 8762458..6f8c075 100644 (file)
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
  */
 
 #include <linux/delay.h>
index 77df97b..9d7d1cd 100644 (file)
@@ -225,10 +225,8 @@ static int bcm2835_i2c_probe(struct platform_device *pdev)
        struct i2c_adapter *adap;
 
        i2c_dev = devm_kzalloc(&pdev->dev, sizeof(*i2c_dev), GFP_KERNEL);
-       if (!i2c_dev) {
-               dev_err(&pdev->dev, "Cannot allocate i2c_dev\n");
+       if (!i2c_dev)
                return -ENOMEM;
-       }
        platform_set_drvdata(pdev, i2c_dev);
        i2c_dev->dev = &pdev->dev;
        init_completion(&i2c_dev->completion);
index f3b89a4..5bdbc71 100644 (file)
  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  *  GNU General Public License for more details.
- *
- *  You should have received a copy of the GNU General Public License
- *  along with this program; if not, write to the Free Software
- *  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  */
 
 #include <linux/kernel.h>
index af0b583..e2d9639 100644 (file)
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  * ----------------------------------------------------------------------------
  *
  */
index d95b930..eb8736a 100644 (file)
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  * ----------------------------------------------------------------------------
  *
  */
index e8a7565..139677f 100644 (file)
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  * ----------------------------------------------------------------------------
  *
  */
index f6ed06c..1932468 100644 (file)
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  * ----------------------------------------------------------------------------
  *
  */
@@ -309,7 +305,7 @@ static void i2c_dw_pci_remove(struct pci_dev *pdev)
 /* work with hotplug and coldplug */
 MODULE_ALIAS("i2c_designware-pci");
 
-static DEFINE_PCI_DEVICE_TABLE(i2_designware_pci_ids) = {
+static const struct pci_device_id i2_designware_pci_ids[] = {
        /* Moorestown */
        { PCI_VDEVICE(INTEL, 0x0802), moorestown_0 },
        { PCI_VDEVICE(INTEL, 0x0803), moorestown_1 },
index d0bdac0..9c6cc51 100644 (file)
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  * ----------------------------------------------------------------------------
  *
  */
index 721f7eb..b19a310 100644 (file)
@@ -455,7 +455,6 @@ static int diolan_u2c_probe(struct usb_interface *interface,
        /* allocate memory for our device state and initialize it */
        dev = kzalloc(sizeof(*dev), GFP_KERNEL);
        if (dev == NULL) {
-               dev_err(&interface->dev, "no memory for device state\n");
                ret = -ENOMEM;
                goto error;
        }
index e08e458..76e699f 100644 (file)
@@ -9,10 +9,6 @@
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307, USA.
  */
 
 #include <linux/module.h>
@@ -186,7 +182,7 @@ static DEFINE_MUTEX(pch_mutex);
 #define PCI_DEVICE_ID_ML7223_I2C       0x8010
 #define PCI_DEVICE_ID_ML7831_I2C       0x8817
 
-static DEFINE_PCI_DEVICE_TABLE(pch_pcidev_id) = {
+static const struct pci_device_id pch_pcidev_id[] = {
        { PCI_VDEVICE(INTEL, PCI_DEVICE_ID_PCH_I2C),   1, },
        { PCI_VDEVICE(ROHM, PCI_DEVICE_ID_ML7213_I2C), 2, },
        { PCI_VDEVICE(ROHM, PCI_DEVICE_ID_ML7223_I2C), 1, },
@@ -751,10 +747,8 @@ static int pch_i2c_probe(struct pci_dev *pdev,
        pch_pci_dbg(pdev, "Entered.\n");
 
        adap_info = kzalloc((sizeof(struct adapter_info)), GFP_KERNEL);
-       if (adap_info == NULL) {
-               pch_pci_err(pdev, "Memory allocation FAILED\n");
+       if (adap_info == NULL)
                return -ENOMEM;
-       }
 
        ret = pci_enable_device(pdev);
        if (ret) {
index 4854970..92e8c0c 100644 (file)
     This program is distributed in the hope that it will be useful,
     but WITHOUT ANY WARRANTY; without even the implied warranty of
     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-    GNU General Public License for more details.
-
-    You should have received a copy of the GNU General Public License
-    along with this program; if not, write to the Free Software
-    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.               */
+    GNU General Public License for more details.                            */
 /* ------------------------------------------------------------------------- */
 
 /* With some changes from Kyösti Mälkki <kmalkki@cc.hut.fi> and even
index 9fd711c..6fcc0b2 100644 (file)
@@ -621,10 +621,8 @@ static int exynos5_i2c_probe(struct platform_device *pdev)
        int ret;
 
        i2c = devm_kzalloc(&pdev->dev, sizeof(struct exynos5_i2c), GFP_KERNEL);
-       if (!i2c) {
-               dev_err(&pdev->dev, "no memory for state\n");
+       if (!i2c)
                return -ENOMEM;
-       }
 
        if (of_property_read_u32(np, "clock-frequency", &op_clock)) {
                i2c->speed_mode = HSI2C_FAST_SPD;
index e248257..b7864cf 100644 (file)
     but WITHOUT ANY WARRANTY; without even the implied warranty of
     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
     GNU General Public License for more details.
-
-    You should have received a copy of the GNU General Public License
-    along with this program; if not, write to the Free Software
-    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 */
 
 #include <linux/kernel.h>
@@ -104,7 +100,7 @@ static struct i2c_adapter hydra_adap = {
        .algo_data      = &hydra_bit_data,
 };
 
-static DEFINE_PCI_DEVICE_TABLE(hydra_ids) = {
+static const struct pci_device_id hydra_ids[] = {
        { PCI_DEVICE(PCI_VENDOR_ID_APPLE, PCI_DEVICE_ID_APPLE_HYDRA) },
        { 0, }
 };
index 899f559..9a50a4f 100644 (file)
     but WITHOUT ANY WARRANTY; without even the implied warranty of
     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
     GNU General Public License for more details.
-
-    You should have received a copy of the GNU General Public License
-    along with this program; if not, write to the Free Software
-    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 */
 
 /*
-  Supports the following Intel I/O Controller Hubs (ICH):
-
-                                  I/O                     Block   I2C
-                                  region  SMBus   Block   proc.   block
-  Chip name             PCI ID    size    PEC     buffer  call    read
-  ----------------------------------------------------------------------
-  82801AA  (ICH)        0x2413     16      no      no      no      no
-  82801AB  (ICH0)       0x2423     16      no      no      no      no
-  82801BA  (ICH2)       0x2443     16      no      no      no      no
-  82801CA  (ICH3)       0x2483     32     soft     no      no      no
-  82801DB  (ICH4)       0x24c3     32     hard     yes     no      no
-  82801E   (ICH5)       0x24d3     32     hard     yes     yes     yes
-  6300ESB               0x25a4     32     hard     yes     yes     yes
-  82801F   (ICH6)       0x266a     32     hard     yes     yes     yes
-  6310ESB/6320ESB       0x269b     32     hard     yes     yes     yes
-  82801G   (ICH7)       0x27da     32     hard     yes     yes     yes
-  82801H   (ICH8)       0x283e     32     hard     yes     yes     yes
-  82801I   (ICH9)       0x2930     32     hard     yes     yes     yes
-  EP80579 (Tolapai)     0x5032     32     hard     yes     yes     yes
-  ICH10                 0x3a30     32     hard     yes     yes     yes
-  ICH10                 0x3a60     32     hard     yes     yes     yes
-  5/3400 Series (PCH)   0x3b30     32     hard     yes     yes     yes
-  6 Series (PCH)        0x1c22     32     hard     yes     yes     yes
-  Patsburg (PCH)        0x1d22     32     hard     yes     yes     yes
-  Patsburg (PCH) IDF    0x1d70     32     hard     yes     yes     yes
-  Patsburg (PCH) IDF    0x1d71     32     hard     yes     yes     yes
-  Patsburg (PCH) IDF    0x1d72     32     hard     yes     yes     yes
-  DH89xxCC (PCH)        0x2330     32     hard     yes     yes     yes
-  Panther Point (PCH)   0x1e22     32     hard     yes     yes     yes
-  Lynx Point (PCH)      0x8c22     32     hard     yes     yes     yes
-  Lynx Point-LP (PCH)   0x9c22     32     hard     yes     yes     yes
-  Avoton (SOC)          0x1f3c     32     hard     yes     yes     yes
-  Wellsburg (PCH)       0x8d22     32     hard     yes     yes     yes
-  Wellsburg (PCH) MS    0x8d7d     32     hard     yes     yes     yes
-  Wellsburg (PCH) MS    0x8d7e     32     hard     yes     yes     yes
-  Wellsburg (PCH) MS    0x8d7f     32     hard     yes     yes     yes
-  Coleto Creek (PCH)    0x23b0     32     hard     yes     yes     yes
-  Wildcat Point-LP (PCH)   0x9ca2     32     hard     yes     yes     yes
-  BayTrail (SOC)        0x0f12     32     hard     yes     yes     yes
-
-  Features supported by this driver:
-  Software PEC                     no
-  Hardware PEC                     yes
-  Block buffer                     yes
-  Block process call transaction   no
-  I2C block read transaction       yes  (doesn't use the block buffer)
-  Slave mode                       no
-  Interrupt processing             yes
-
-  See the file Documentation/i2c/busses/i2c-i801 for details.
-*/
+ * Supports the following Intel I/O Controller Hubs (ICH):
+ *
+ *                                     I/O                     Block   I2C
+ *                                     region  SMBus   Block   proc.   block
+ * Chip name                   PCI ID  size    PEC     buffer  call    read
+ * ---------------------------------------------------------------------------
+ * 82801AA (ICH)               0x2413  16      no      no      no      no
+ * 82801AB (ICH0)              0x2423  16      no      no      no      no
+ * 82801BA (ICH2)              0x2443  16      no      no      no      no
+ * 82801CA (ICH3)              0x2483  32      soft    no      no      no
+ * 82801DB (ICH4)              0x24c3  32      hard    yes     no      no
+ * 82801E (ICH5)               0x24d3  32      hard    yes     yes     yes
+ * 6300ESB                     0x25a4  32      hard    yes     yes     yes
+ * 82801F (ICH6)               0x266a  32      hard    yes     yes     yes
+ * 6310ESB/6320ESB             0x269b  32      hard    yes     yes     yes
+ * 82801G (ICH7)               0x27da  32      hard    yes     yes     yes
+ * 82801H (ICH8)               0x283e  32      hard    yes     yes     yes
+ * 82801I (ICH9)               0x2930  32      hard    yes     yes     yes
+ * EP80579 (Tolapai)           0x5032  32      hard    yes     yes     yes
+ * ICH10                       0x3a30  32      hard    yes     yes     yes
+ * ICH10                       0x3a60  32      hard    yes     yes     yes
+ * 5/3400 Series (PCH)         0x3b30  32      hard    yes     yes     yes
+ * 6 Series (PCH)              0x1c22  32      hard    yes     yes     yes
+ * Patsburg (PCH)              0x1d22  32      hard    yes     yes     yes
+ * Patsburg (PCH) IDF          0x1d70  32      hard    yes     yes     yes
+ * Patsburg (PCH) IDF          0x1d71  32      hard    yes     yes     yes
+ * Patsburg (PCH) IDF          0x1d72  32      hard    yes     yes     yes
+ * DH89xxCC (PCH)              0x2330  32      hard    yes     yes     yes
+ * Panther Point (PCH)         0x1e22  32      hard    yes     yes     yes
+ * Lynx Point (PCH)            0x8c22  32      hard    yes     yes     yes
+ * Lynx Point-LP (PCH)         0x9c22  32      hard    yes     yes     yes
+ * Avoton (SOC)                        0x1f3c  32      hard    yes     yes     yes
+ * Wellsburg (PCH)             0x8d22  32      hard    yes     yes     yes
+ * Wellsburg (PCH) MS          0x8d7d  32      hard    yes     yes     yes
+ * Wellsburg (PCH) MS          0x8d7e  32      hard    yes     yes     yes
+ * Wellsburg (PCH) MS          0x8d7f  32      hard    yes     yes     yes
+ * Coleto Creek (PCH)          0x23b0  32      hard    yes     yes     yes
+ * Wildcat Point (PCH)         0x8ca2  32      hard    yes     yes     yes
+ * Wildcat Point-LP (PCH)      0x9ca2  32      hard    yes     yes     yes
+ * BayTrail (SOC)              0x0f12  32      hard    yes     yes     yes
+ *
+ * Features supported by this driver:
+ * Software PEC                                no
+ * Hardware PEC                                yes
+ * Block buffer                                yes
+ * Block process call transaction      no
+ * I2C block read transaction          yes (doesn't use the block buffer)
+ * Slave mode                          no
+ * Interrupt processing                        yes
+ *
+ * See the file Documentation/i2c/busses/i2c-i801 for details.
+ */
 
 #include <linux/interrupt.h>
 #include <linux/module.h>
                                 STATUS_ERROR_FLAGS)
 
 /* Older devices have their ID defined in <linux/pci_ids.h> */
-#define PCI_DEVICE_ID_INTEL_BAYTRAIL_SMBUS     0x0f12
-#define PCI_DEVICE_ID_INTEL_COUGARPOINT_SMBUS  0x1c22
-#define PCI_DEVICE_ID_INTEL_PATSBURG_SMBUS     0x1d22
+#define PCI_DEVICE_ID_INTEL_BAYTRAIL_SMBUS             0x0f12
+#define PCI_DEVICE_ID_INTEL_BRASWELL_SMBUS             0x2292
+#define PCI_DEVICE_ID_INTEL_COUGARPOINT_SMBUS          0x1c22
+#define PCI_DEVICE_ID_INTEL_PATSBURG_SMBUS             0x1d22
 /* Patsburg also has three 'Integrated Device Function' SMBus controllers */
-#define PCI_DEVICE_ID_INTEL_PATSBURG_SMBUS_IDF0        0x1d70
-#define PCI_DEVICE_ID_INTEL_PATSBURG_SMBUS_IDF1        0x1d71
-#define PCI_DEVICE_ID_INTEL_PATSBURG_SMBUS_IDF2        0x1d72
-#define PCI_DEVICE_ID_INTEL_PANTHERPOINT_SMBUS 0x1e22
-#define PCI_DEVICE_ID_INTEL_AVOTON_SMBUS       0x1f3c
-#define PCI_DEVICE_ID_INTEL_DH89XXCC_SMBUS     0x2330
-#define PCI_DEVICE_ID_INTEL_COLETOCREEK_SMBUS  0x23b0
-#define PCI_DEVICE_ID_INTEL_5_3400_SERIES_SMBUS        0x3b30
-#define PCI_DEVICE_ID_INTEL_LYNXPOINT_SMBUS    0x8c22
-#define PCI_DEVICE_ID_INTEL_WELLSBURG_SMBUS    0x8d22
-#define PCI_DEVICE_ID_INTEL_WELLSBURG_SMBUS_MS0        0x8d7d
-#define PCI_DEVICE_ID_INTEL_WELLSBURG_SMBUS_MS1        0x8d7e
-#define PCI_DEVICE_ID_INTEL_WELLSBURG_SMBUS_MS2        0x8d7f
-#define PCI_DEVICE_ID_INTEL_LYNXPOINT_LP_SMBUS 0x9c22
+#define PCI_DEVICE_ID_INTEL_PATSBURG_SMBUS_IDF0                0x1d70
+#define PCI_DEVICE_ID_INTEL_PATSBURG_SMBUS_IDF1                0x1d71
+#define PCI_DEVICE_ID_INTEL_PATSBURG_SMBUS_IDF2                0x1d72
+#define PCI_DEVICE_ID_INTEL_PANTHERPOINT_SMBUS         0x1e22
+#define PCI_DEVICE_ID_INTEL_AVOTON_SMBUS               0x1f3c
+#define PCI_DEVICE_ID_INTEL_DH89XXCC_SMBUS             0x2330
+#define PCI_DEVICE_ID_INTEL_COLETOCREEK_SMBUS          0x23b0
+#define PCI_DEVICE_ID_INTEL_5_3400_SERIES_SMBUS                0x3b30
+#define PCI_DEVICE_ID_INTEL_LYNXPOINT_SMBUS            0x8c22
+#define PCI_DEVICE_ID_INTEL_WILDCATPOINT_SMBUS         0x8ca2
+#define PCI_DEVICE_ID_INTEL_WELLSBURG_SMBUS            0x8d22
+#define PCI_DEVICE_ID_INTEL_WELLSBURG_SMBUS_MS0                0x8d7d
+#define PCI_DEVICE_ID_INTEL_WELLSBURG_SMBUS_MS1                0x8d7e
+#define PCI_DEVICE_ID_INTEL_WELLSBURG_SMBUS_MS2                0x8d7f
+#define PCI_DEVICE_ID_INTEL_LYNXPOINT_LP_SMBUS         0x9c22
 #define PCI_DEVICE_ID_INTEL_WILDCATPOINT_LP_SMBUS      0x9ca2
 
 struct i801_mux_config {
@@ -791,7 +790,7 @@ static const struct i2c_algorithm smbus_algorithm = {
        .functionality  = i801_func,
 };
 
-static DEFINE_PCI_DEVICE_TABLE(i801_ids) = {
+static const struct pci_device_id i801_ids[] = {
        { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82801AA_3) },
        { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82801AB_3) },
        { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82801BA_2) },
@@ -823,8 +822,10 @@ static DEFINE_PCI_DEVICE_TABLE(i801_ids) = {
        { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_WELLSBURG_SMBUS_MS1) },
        { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_WELLSBURG_SMBUS_MS2) },
        { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_COLETOCREEK_SMBUS) },
+       { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_WILDCATPOINT_SMBUS) },
        { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_WILDCATPOINT_LP_SMBUS) },
        { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_BAYTRAIL_SMBUS) },
+       { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_BRASWELL_SMBUS) },
        { 0, }
 };
 
index db895fb..2e83a4a 100644 (file)
  *     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.
- *
  * Author:
  *     Darius Augulis, Teltonika Inc.
  *
@@ -617,10 +612,8 @@ static int i2c_imx_probe(struct platform_device *pdev)
 
        i2c_imx = devm_kzalloc(&pdev->dev, sizeof(struct imx_i2c_struct),
                                GFP_KERNEL);
-       if (!i2c_imx) {
-               dev_err(&pdev->dev, "can't allocate interface\n");
+       if (!i2c_imx)
                return -ENOMEM;
-       }
 
        if (of_id)
                i2c_imx->hwdata = of_id->data;
index 097e270..2d6929c 100644 (file)
     This program is distributed in the hope that it will be useful,
     but WITHOUT ANY WARRANTY; without even the implied warranty of
     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-    GNU General Public License for more details.
-
-    You should have received a copy of the GNU General Public License
-    along with this program; if not, write to the Free Software
-    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.                */
+    GNU General Public License for more details.                            */
 /* ------------------------------------------------------------------------- */
 
 
index cf99dbf..113293d 100644 (file)
     but WITHOUT ANY WARRANTY; without even the implied warranty of
     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
     GNU General Public License for more details.
-
-    You should have received a copy of the GNU General Public License
-    along with this program; if not, write to the Free Software
-    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 */
 
 /*
index 6e932d1..acd32d1 100644 (file)
  * WITHOUT ANY WARRANTY; without even the implied warranty of
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  * General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.
  * The full GNU General Public License is included in this distribution
  * in the file called LICENSE.GPL.
  *
@@ -182,7 +178,7 @@ struct ismt_priv {
 /**
  * ismt_ids - PCI device IDs supported by this driver
  */
-static DEFINE_PCI_DEVICE_TABLE(ismt_ids) = {
+static const struct pci_device_id ismt_ids[] = {
        { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_S1200_SMT0) },
        { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_S1200_SMT1) },
        { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_AVOTON_SMT) },
index b170bdf..88eda09 100644 (file)
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  */
 
 /*
index 0038c45..70b3c91 100644 (file)
     but WITHOUT ANY WARRANTY; without even the implied warranty of
     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
     GNU General Public License for more details.
-
-    You should have received a copy of the GNU General Public License
-    along with this program; if not, write to the Free Software
-    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 */
 
 /*
@@ -306,7 +302,7 @@ static struct i2c_algorithm smbus_algorithm = {
 };
 
 
-static DEFINE_PCI_DEVICE_TABLE(nforce2_ids) = {
+static const struct pci_device_id nforce2_ids[] = {
        { PCI_DEVICE(PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_NFORCE2_SMBUS) },
        { PCI_DEVICE(PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_NFORCE2S_SMBUS) },
        { PCI_DEVICE(PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_NFORCE3_SMBUS) },
index 90dcc2e..5c6edbc 100644 (file)
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  */
 
 #include <linux/module.h>
@@ -1114,10 +1110,8 @@ omap_i2c_probe(struct platform_device *pdev)
        }
 
        dev = devm_kzalloc(&pdev->dev, sizeof(struct omap_i2c_dev), GFP_KERNEL);
-       if (!dev) {
-               dev_err(&pdev->dev, "Menory allocation failed\n");
+       if (!dev)
                return -ENOMEM;
-       }
 
        mem = platform_get_resource(pdev, IORESOURCE_MEM, 0);
        dev->base = devm_ioremap_resource(&pdev->dev, mem);
index 62f55fe..d1f625f 100644 (file)
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.
-
-   You should have received a copy of the GNU General Public License
-   along with this program; if not, write to the Free Software
-   Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  * ------------------------------------------------------------------------ */
 
 #include <linux/kernel.h>
index a27aae2..a1fac5a 100644 (file)
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.
-
-   You should have received a copy of the GNU General Public License
-   along with this program; if not, write to the Free Software
-   Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  * ------------------------------------------------------------------------ */
 
 #include <linux/kernel.h>
index e572f3a..4e12945 100644 (file)
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.
-
-   You should have received a copy of the GNU General Public License
-   along with this program; if not, write to the Free Software
-   Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  * ------------------------------------------------------------------------ */
 
 #define PORT_DATA      0
index 615f632..df1dbc9 100644 (file)
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
  */
 
 #include <linux/module.h>
@@ -401,7 +397,7 @@ static void pasemi_smb_remove(struct pci_dev *dev)
        kfree(smbus);
 }
 
-static DEFINE_PCI_DEVICE_TABLE(pasemi_smb_ids) = {
+static const struct pci_device_id pasemi_smb_ids[] = {
        { PCI_DEVICE(0x1959, 0xa003) },
        { 0, }
 };
index 323f061..e0eb4ca 100644 (file)
  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  *  GNU General Public License for more details.
- *
- *  You should have received a copy of the GNU General Public License
- *  along with this program; if not, write to the Free Software
- *  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  */
 
 #include <linux/kernel.h>
index 39dd8ec..67cbec6 100644 (file)
     but WITHOUT ANY WARRANTY; without even the implied warranty of
     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
     GNU General Public License for more details.
-
-    You should have received a copy of the GNU General Public License
-    along with this program; if not, write to the Free Software
-    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 */
 
 /*
@@ -540,7 +536,7 @@ static const struct i2c_algorithm smbus_algorithm = {
        .functionality  = piix4_func,
 };
 
-static DEFINE_PCI_DEVICE_TABLE(piix4_ids) = {
+static const struct pci_device_id piix4_ids[] = {
        { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82371AB_3) },
        { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82443MX_3) },
        { PCI_DEVICE(PCI_VENDOR_ID_EFAR, PCI_DEVICE_ID_EFAR_SLC90E66_3) },
index 8564768..177834e 100644 (file)
  *  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.
- *
- *  You should have received a copy of the  GNU General Public License along
- *  with this program; if not, write  to the Free Software Foundation, Inc.,
- *  675 Mass Ave, Cambridge, MA 02139, USA.
  */
 
 #include <linux/kernel.h>
index 01e9677..60a53c1 100644 (file)
     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
     GNU General Public License for more details.
 
-    You should have received a copy of the GNU General Public License
-    along with this program; if not, write to the Free Software
-    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
-
 */
 
 #include <linux/module.h>
index 9639be8..417464e 100644 (file)
@@ -148,7 +148,7 @@ static void ce4100_i2c_remove(struct pci_dev *dev)
        kfree(sds);
 }
 
-static DEFINE_PCI_DEVICE_TABLE(ce4100_i2c_devices) = {
+static const struct pci_device_id ce4100_i2c_devices[] = {
        { PCI_DEVICE(PCI_VENDOR_ID_INTEL, 0x2e68)},
        { },
 };
index d3c5d62..d826e82 100644 (file)
@@ -1,7 +1,9 @@
 /*
- *  drivers/i2c/busses/i2c-rcar.c
+ * Driver for the Renesas RCar I2C unit
  *
- * Copyright (C) 2012 Renesas Solutions Corp.
+ * Copyright (C) 2014 Wolfram Sang <wsa@sang-engineering.com>
+ *
+ * Copyright (C) 2012-14 Renesas Solutions Corp.
  * Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
  *
  * This file is based on the drivers/i2c/busses/i2c-sh7760.c
  *
  * 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
+ * the Free Software Foundation; version 2 of the License.
  *
  * This program is distributed in the hope that it will be useful,
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  */
 #include <linux/clk.h>
 #include <linux/delay.h>
@@ -60,7 +58,7 @@
 #define FSB    (1 << 1)        /* force stop bit */
 #define ESG    (1 << 0)        /* en startbit gen */
 
-/* ICMSR */
+/* ICMSR (also for ICMIE) */
 #define MNR    (1 << 6)        /* nack received */
 #define MAL    (1 << 5)        /* arbitration lost */
 #define MST    (1 << 4)        /* sent a stop */
 #define MDR    (1 << 1)
 #define MAT    (1 << 0)        /* slave addr xfer done */
 
-/* ICMIE */
-#define MNRE   (1 << 6)        /* nack irq en */
-#define MALE   (1 << 5)        /* arblos irq en */
-#define MSTE   (1 << 4)        /* stop irq en */
-#define MDEE   (1 << 3)
-#define MDTE   (1 << 2)
-#define MDRE   (1 << 1)
-#define MATE   (1 << 0)        /* address sent irq en */
 
+#define RCAR_BUS_PHASE_START   (MDBS | MIE | ESG)
+#define RCAR_BUS_PHASE_DATA    (MDBS | MIE)
+#define RCAR_BUS_PHASE_STOP    (MDBS | MIE | FSB)
 
-enum {
-       RCAR_BUS_PHASE_ADDR,
-       RCAR_BUS_PHASE_DATA,
-       RCAR_BUS_PHASE_STOP,
-};
+#define RCAR_IRQ_SEND  (MNR | MAL | MST | MAT | MDE)
+#define RCAR_IRQ_RECV  (MNR | MAL | MST | MAT | MDR)
+#define RCAR_IRQ_STOP  (MST)
 
-enum {
-       RCAR_IRQ_CLOSE,
-       RCAR_IRQ_OPEN_FOR_SEND,
-       RCAR_IRQ_OPEN_FOR_RECV,
-       RCAR_IRQ_OPEN_FOR_STOP,
-};
+#define RCAR_IRQ_ACK_SEND      (~(MAT | MDE) & 0xFF)
+#define RCAR_IRQ_ACK_RECV      (~(MAT | MDR) & 0xFF)
 
-/*
- * flags
- */
 #define ID_LAST_MSG    (1 << 0)
 #define ID_IOERROR     (1 << 1)
 #define ID_DONE                (1 << 2)
@@ -116,10 +100,9 @@ struct rcar_i2c_priv {
        wait_queue_head_t wait;
 
        int pos;
-       int irq;
        u32 icccr;
        u32 flags;
-       enum rcar_i2c_type      devtype;
+       enum rcar_i2c_type devtype;
 };
 
 #define rcar_i2c_priv_to_dev(p)                ((p)->adap.dev.parent)
@@ -130,9 +113,7 @@ struct rcar_i2c_priv {
 
 #define LOOP_TIMEOUT   1024
 
-/*
- *             basic functions
- */
+
 static void rcar_i2c_write(struct rcar_i2c_priv *priv, int reg, u32 val)
 {
        writel(val, priv->io + reg);
@@ -161,36 +142,6 @@ static void rcar_i2c_init(struct rcar_i2c_priv *priv)
        rcar_i2c_write(priv, ICMAR, 0);
 }
 
-static void rcar_i2c_irq_mask(struct rcar_i2c_priv *priv, int open)
-{
-       u32 val = MNRE | MALE | MSTE | MATE; /* default */
-
-       switch (open) {
-       case RCAR_IRQ_OPEN_FOR_SEND:
-               val |= MDEE; /* default + send */
-               break;
-       case RCAR_IRQ_OPEN_FOR_RECV:
-               val |= MDRE; /* default + read */
-               break;
-       case RCAR_IRQ_OPEN_FOR_STOP:
-               val = MSTE; /* stop irq only */
-               break;
-       case RCAR_IRQ_CLOSE:
-       default:
-               val = 0; /* all close */
-               break;
-       }
-       rcar_i2c_write(priv, ICMIER, val);
-}
-
-static void rcar_i2c_set_addr(struct rcar_i2c_priv *priv, u32 recv)
-{
-       rcar_i2c_write(priv, ICMAR, (priv->msg->addr << 1) | recv);
-}
-
-/*
- *             bus control functions
- */
 static int rcar_i2c_bus_barrier(struct rcar_i2c_priv *priv)
 {
        int i;
@@ -205,24 +156,6 @@ static int rcar_i2c_bus_barrier(struct rcar_i2c_priv *priv)
        return -EBUSY;
 }
 
-static void rcar_i2c_bus_phase(struct rcar_i2c_priv *priv, int phase)
-{
-       switch (phase) {
-       case RCAR_BUS_PHASE_ADDR:
-               rcar_i2c_write(priv, ICMCR, MDBS | MIE | ESG);
-               break;
-       case RCAR_BUS_PHASE_DATA:
-               rcar_i2c_write(priv, ICMCR, MDBS | MIE);
-               break;
-       case RCAR_BUS_PHASE_STOP:
-               rcar_i2c_write(priv, ICMCR, MDBS | MIE | FSB);
-               break;
-       }
-}
-
-/*
- *             clock function
- */
 static int rcar_i2c_clock_calculate(struct rcar_i2c_priv *priv,
                                    u32 bus_speed,
                                    struct device *dev)
@@ -262,7 +195,7 @@ static int rcar_i2c_clock_calculate(struct rcar_i2c_priv *priv,
         */
        rate = clk_get_rate(priv->clk);
        cdf = rate / 20000000;
-       if (cdf >= 1 << cdf_width) {
+       if (cdf >= 1U << cdf_width) {
                dev_err(dev, "Input clock %lu too high\n", rate);
                return -EIO;
        }
@@ -312,60 +245,16 @@ scgd_find:
        return 0;
 }
 
-static void rcar_i2c_clock_start(struct rcar_i2c_priv *priv)
-{
-       rcar_i2c_write(priv, ICCCR, priv->icccr);
-}
-
-/*
- *             status functions
- */
-static u32 rcar_i2c_status_get(struct rcar_i2c_priv *priv)
-{
-       return rcar_i2c_read(priv, ICMSR);
-}
-
-#define rcar_i2c_status_clear(priv) rcar_i2c_status_bit_clear(priv, 0xffffffff)
-static void rcar_i2c_status_bit_clear(struct rcar_i2c_priv *priv, u32 bit)
-{
-       rcar_i2c_write(priv, ICMSR, ~bit);
-}
-
-/*
- *             recv/send functions
- */
-static int rcar_i2c_recv(struct rcar_i2c_priv *priv)
-{
-       rcar_i2c_set_addr(priv, 1);
-       rcar_i2c_status_clear(priv);
-       rcar_i2c_bus_phase(priv, RCAR_BUS_PHASE_ADDR);
-       rcar_i2c_irq_mask(priv, RCAR_IRQ_OPEN_FOR_RECV);
-
-       return 0;
-}
-
-static int rcar_i2c_send(struct rcar_i2c_priv *priv)
+static void rcar_i2c_prepare_msg(struct rcar_i2c_priv *priv)
 {
-       int ret;
-
-       /*
-        * It should check bus status when send case
-        */
-       ret = rcar_i2c_bus_barrier(priv);
-       if (ret < 0)
-               return ret;
+       int read = !!rcar_i2c_is_recv(priv);
 
-       rcar_i2c_set_addr(priv, 0);
-       rcar_i2c_status_clear(priv);
-       rcar_i2c_bus_phase(priv, RCAR_BUS_PHASE_ADDR);
-       rcar_i2c_irq_mask(priv, RCAR_IRQ_OPEN_FOR_SEND);
-
-       return 0;
+       rcar_i2c_write(priv, ICMAR, (priv->msg->addr << 1) | read);
+       rcar_i2c_write(priv, ICMSR, 0);
+       rcar_i2c_write(priv, ICMCR, RCAR_BUS_PHASE_START);
+       rcar_i2c_write(priv, ICMIER, read ? RCAR_IRQ_RECV : RCAR_IRQ_SEND);
 }
 
-#define rcar_i2c_send_restart(priv) rcar_i2c_status_bit_clear(priv, (MAT | MDE))
-#define rcar_i2c_recv_restart(priv) rcar_i2c_status_bit_clear(priv, (MAT | MDR))
-
 /*
  *             interrupt functions
  */
@@ -386,7 +275,7 @@ static int rcar_i2c_irq_send(struct rcar_i2c_priv *priv, u32 msr)
         * goto data phase.
         */
        if (msr & MAT)
-               rcar_i2c_bus_phase(priv, RCAR_BUS_PHASE_DATA);
+               rcar_i2c_write(priv, ICMCR, RCAR_BUS_PHASE_DATA);
 
        if (priv->pos < msg->len) {
                /*
@@ -414,7 +303,7 @@ static int rcar_i2c_irq_send(struct rcar_i2c_priv *priv, u32 msr)
                         * prepare stop condition here.
                         * ID_DONE will be set on STOP irq.
                         */
-                       rcar_i2c_bus_phase(priv, RCAR_BUS_PHASE_STOP);
+                       rcar_i2c_write(priv, ICMCR, RCAR_BUS_PHASE_STOP);
                else
                        /*
                         * If current msg is _NOT_ last msg,
@@ -425,7 +314,7 @@ static int rcar_i2c_irq_send(struct rcar_i2c_priv *priv, u32 msr)
                        return ID_DONE;
        }
 
-       rcar_i2c_send_restart(priv);
+       rcar_i2c_write(priv, ICMSR, RCAR_IRQ_ACK_SEND);
 
        return 0;
 }
@@ -462,11 +351,11 @@ static int rcar_i2c_irq_recv(struct rcar_i2c_priv *priv, u32 msr)
         * otherwise, go to DATA phase.
         */
        if (priv->pos + 1 >= msg->len)
-               rcar_i2c_bus_phase(priv, RCAR_BUS_PHASE_STOP);
+               rcar_i2c_write(priv, ICMCR, RCAR_BUS_PHASE_STOP);
        else
-               rcar_i2c_bus_phase(priv, RCAR_BUS_PHASE_DATA);
+               rcar_i2c_write(priv, ICMCR, RCAR_BUS_PHASE_DATA);
 
-       rcar_i2c_recv_restart(priv);
+       rcar_i2c_write(priv, ICMSR, RCAR_IRQ_ACK_RECV);
 
        return 0;
 }
@@ -474,53 +363,42 @@ static int rcar_i2c_irq_recv(struct rcar_i2c_priv *priv, u32 msr)
 static irqreturn_t rcar_i2c_irq(int irq, void *ptr)
 {
        struct rcar_i2c_priv *priv = ptr;
-       struct device *dev = rcar_i2c_priv_to_dev(priv);
+       irqreturn_t result = IRQ_HANDLED;
        u32 msr;
 
        /*-------------- spin lock -----------------*/
        spin_lock(&priv->lock);
 
-       msr = rcar_i2c_status_get(priv);
+       msr = rcar_i2c_read(priv, ICMSR);
 
-       /*
-        * Arbitration lost
-        */
-       if (msr & MAL) {
-               /*
-                * CAUTION
-                *
-                * When arbitration lost, device become _slave_ mode.
-                */
-               dev_dbg(dev, "Arbitration Lost\n");
-               rcar_i2c_flags_set(priv, (ID_DONE | ID_ARBLOST));
-               goto out;
+       /* Only handle interrupts that are currently enabled */
+       msr &= rcar_i2c_read(priv, ICMIER);
+       if (!msr) {
+               result = IRQ_NONE;
+               goto exit;
        }
 
-       /*
-        * Stop
-        */
-       if (msr & MST) {
-               dev_dbg(dev, "Stop\n");
-               rcar_i2c_flags_set(priv, ID_DONE);
+       /* Arbitration lost */
+       if (msr & MAL) {
+               rcar_i2c_flags_set(priv, (ID_DONE | ID_ARBLOST));
                goto out;
        }
 
-       /*
-        * Nack
-        */
+       /* Nack */
        if (msr & MNR) {
-               dev_dbg(dev, "Nack\n");
-
                /* go to stop phase */
-               rcar_i2c_bus_phase(priv, RCAR_BUS_PHASE_STOP);
-               rcar_i2c_irq_mask(priv, RCAR_IRQ_OPEN_FOR_STOP);
+               rcar_i2c_write(priv, ICMCR, RCAR_BUS_PHASE_STOP);
+               rcar_i2c_write(priv, ICMIER, RCAR_IRQ_STOP);
                rcar_i2c_flags_set(priv, ID_NACK);
                goto out;
        }
 
-       /*
-        * recv/send
-        */
+       /* Stop */
+       if (msr & MST) {
+               rcar_i2c_flags_set(priv, ID_DONE);
+               goto out;
+       }
+
        if (rcar_i2c_is_recv(priv))
                rcar_i2c_flags_set(priv, rcar_i2c_irq_recv(priv, msr));
        else
@@ -528,15 +406,16 @@ static irqreturn_t rcar_i2c_irq(int irq, void *ptr)
 
 out:
        if (rcar_i2c_flags_has(priv, ID_DONE)) {
-               rcar_i2c_irq_mask(priv, RCAR_IRQ_CLOSE);
-               rcar_i2c_status_clear(priv);
+               rcar_i2c_write(priv, ICMIER, 0);
+               rcar_i2c_write(priv, ICMSR, 0);
                wake_up(&priv->wait);
        }
 
+exit:
        spin_unlock(&priv->lock);
        /*-------------- spin unlock -----------------*/
 
-       return IRQ_HANDLED;
+       return result;
 }
 
 static int rcar_i2c_master_xfer(struct i2c_adapter *adap,
@@ -554,12 +433,16 @@ static int rcar_i2c_master_xfer(struct i2c_adapter *adap,
        spin_lock_irqsave(&priv->lock, flags);
 
        rcar_i2c_init(priv);
-       rcar_i2c_clock_start(priv);
+       /* start clock */
+       rcar_i2c_write(priv, ICCCR, priv->icccr);
 
        spin_unlock_irqrestore(&priv->lock, flags);
        /*-------------- spin unlock -----------------*/
 
-       ret = -EINVAL;
+       ret = rcar_i2c_bus_barrier(priv);
+       if (ret < 0)
+               goto out;
+
        for (i = 0; i < num; i++) {
                /* This HW can't send STOP after address phase */
                if (msgs[i].len == 0) {
@@ -574,24 +457,14 @@ static int rcar_i2c_master_xfer(struct i2c_adapter *adap,
                priv->msg       = &msgs[i];
                priv->pos       = 0;
                priv->flags     = 0;
-               if (priv->msg == &msgs[num - 1])
+               if (i == num - 1)
                        rcar_i2c_flags_set(priv, ID_LAST_MSG);
 
-               /* start send/recv */
-               if (rcar_i2c_is_recv(priv))
-                       ret = rcar_i2c_recv(priv);
-               else
-                       ret = rcar_i2c_send(priv);
+               rcar_i2c_prepare_msg(priv);
 
                spin_unlock_irqrestore(&priv->lock, flags);
                /*-------------- spin unlock -----------------*/
 
-               if (ret < 0)
-                       break;
-
-               /*
-                * wait result
-                */
                timeout = wait_event_timeout(priv->wait,
                                             rcar_i2c_flags_has(priv, ID_DONE),
                                             5 * HZ);
@@ -600,9 +473,6 @@ static int rcar_i2c_master_xfer(struct i2c_adapter *adap,
                        break;
                }
 
-               /*
-                * error handling
-                */
                if (rcar_i2c_flags_has(priv, ID_NACK)) {
                        ret = -ENXIO;
                        break;
@@ -620,7 +490,7 @@ static int rcar_i2c_master_xfer(struct i2c_adapter *adap,
 
                ret = i + 1; /* The number of transfer */
        }
-
+out:
        pm_runtime_put(dev);
 
        if (ret < 0 && ret != -ENXIO)
@@ -645,6 +515,10 @@ static const struct of_device_id rcar_i2c_dt_ids[] = {
        { .compatible = "renesas,i2c-r8a7778", .data = (void *)I2C_RCAR_GEN1 },
        { .compatible = "renesas,i2c-r8a7779", .data = (void *)I2C_RCAR_GEN1 },
        { .compatible = "renesas,i2c-r8a7790", .data = (void *)I2C_RCAR_GEN2 },
+       { .compatible = "renesas,i2c-r8a7791", .data = (void *)I2C_RCAR_GEN2 },
+       { .compatible = "renesas,i2c-r8a7792", .data = (void *)I2C_RCAR_GEN2 },
+       { .compatible = "renesas,i2c-r8a7793", .data = (void *)I2C_RCAR_GEN2 },
+       { .compatible = "renesas,i2c-r8a7794", .data = (void *)I2C_RCAR_GEN2 },
        {},
 };
 MODULE_DEVICE_TABLE(of, rcar_i2c_dt_ids);
@@ -657,13 +531,11 @@ static int rcar_i2c_probe(struct platform_device *pdev)
        struct resource *res;
        struct device *dev = &pdev->dev;
        u32 bus_speed;
-       int ret;
+       int irq, ret;
 
        priv = devm_kzalloc(dev, sizeof(struct rcar_i2c_priv), GFP_KERNEL);
-       if (!priv) {
-               dev_err(dev, "no mem for private data\n");
+       if (!priv)
                return -ENOMEM;
-       }
 
        priv->clk = devm_clk_get(dev, NULL);
        if (IS_ERR(priv->clk)) {
@@ -691,24 +563,24 @@ static int rcar_i2c_probe(struct platform_device *pdev)
        if (IS_ERR(priv->io))
                return PTR_ERR(priv->io);
 
-       priv->irq = platform_get_irq(pdev, 0);
+       irq = platform_get_irq(pdev, 0);
        init_waitqueue_head(&priv->wait);
        spin_lock_init(&priv->lock);
 
-       adap                    = &priv->adap;
-       adap->nr                = pdev->id;
-       adap->algo              = &rcar_i2c_algo;
-       adap->class             = I2C_CLASS_HWMON | I2C_CLASS_SPD;
-       adap->retries           = 3;
-       adap->dev.parent        = dev;
-       adap->dev.of_node       = dev->of_node;
+       adap = &priv->adap;
+       adap->nr = pdev->id;
+       adap->algo = &rcar_i2c_algo;
+       adap->class = I2C_CLASS_DEPRECATED;
+       adap->retries = 3;
+       adap->dev.parent = dev;
+       adap->dev.of_node = dev->of_node;
        i2c_set_adapdata(adap, priv);
        strlcpy(adap->name, pdev->name, sizeof(adap->name));
 
-       ret = devm_request_irq(dev, priv->irq, rcar_i2c_irq, 0,
+       ret = devm_request_irq(dev, irq, rcar_i2c_irq, 0,
                               dev_name(dev), priv);
        if (ret < 0) {
-               dev_err(dev, "cannot get irq %d\n", priv->irq);
+               dev_err(dev, "cannot get irq %d\n", irq);
                return ret;
        }
 
@@ -758,6 +630,6 @@ static struct platform_driver rcar_i2c_driver = {
 
 module_platform_driver(rcar_i2c_driver);
 
-MODULE_LICENSE("GPL");
+MODULE_LICENSE("GPL v2");
 MODULE_DESCRIPTION("Renesas R-Car I2C bus driver");
 MODULE_AUTHOR("Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>");
index 93ec376..27303c7 100644 (file)
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 */
 
 #include <linux/kernel.h>
@@ -1085,16 +1081,12 @@ static int s3c24xx_i2c_probe(struct platform_device *pdev)
        }
 
        i2c = devm_kzalloc(&pdev->dev, sizeof(struct s3c24xx_i2c), GFP_KERNEL);
-       if (!i2c) {
-               dev_err(&pdev->dev, "no memory for state\n");
+       if (!i2c)
                return -ENOMEM;
-       }
 
        i2c->pdata = devm_kzalloc(&pdev->dev, sizeof(*pdata), GFP_KERNEL);
-       if (!i2c->pdata) {
-               dev_err(&pdev->dev, "no memory for platform data\n");
+       if (!i2c->pdata)
                return -ENOMEM;
-       }
 
        i2c->quirks = s3c24xx_get_device_quirks(pdev);
        if (pdata)
index 1d79585..4855188 100644 (file)
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  */
 
 #include <linux/kernel.h>
@@ -32,6 +28,7 @@
 #include <linux/clk.h>
 #include <linux/io.h>
 #include <linux/slab.h>
+#include <linux/of_device.h>
 #include <linux/i2c/i2c-sh_mobile.h>
 
 /* Transmit operation:                                                      */
@@ -139,6 +136,10 @@ struct sh_mobile_i2c_data {
        bool send_stop;
 };
 
+struct sh_mobile_dt_config {
+       int clks_per_count;
+};
+
 #define IIC_FLAG_HAS_ICIC67    (1 << 0)
 
 #define STANDARD_MODE          100000
@@ -194,7 +195,7 @@ static void iic_set_clr(struct sh_mobile_i2c_data *pd, int offs,
        iic_wr(pd, offs, (iic_rd(pd, offs) | set) & ~clr);
 }
 
-static u32 sh_mobile_i2c_iccl(unsigned long count_khz, u32 tLOW, u32 tf, int offset)
+static u32 sh_mobile_i2c_iccl(unsigned long count_khz, u32 tLOW, u32 tf)
 {
        /*
         * Conditional expression:
@@ -206,10 +207,10 @@ static u32 sh_mobile_i2c_iccl(unsigned long count_khz, u32 tLOW, u32 tf, int off
         * account the fall time of SCL signal (tf).  Default tf value
         * should be 0.3 us, for safety.
         */
-       return (((count_khz * (tLOW + tf)) + 5000) / 10000) + offset;
+       return (((count_khz * (tLOW + tf)) + 5000) / 10000);
 }
 
-static u32 sh_mobile_i2c_icch(unsigned long count_khz, u32 tHIGH, u32 tf, int offset)
+static u32 sh_mobile_i2c_icch(unsigned long count_khz, u32 tHIGH, u32 tf)
 {
        /*
         * Conditional expression:
@@ -225,52 +226,58 @@ static u32 sh_mobile_i2c_icch(unsigned long count_khz, u32 tHIGH, u32 tf, int of
         * to take into account the fall time of SDA signal (tf) at START
         * condition, in order to meet both tHIGH and tHD;STA specs.
         */
-       return (((count_khz * (tHIGH + tf)) + 5000) / 10000) + offset;
+       return (((count_khz * (tHIGH + tf)) + 5000) / 10000);
 }
 
-static void sh_mobile_i2c_init(struct sh_mobile_i2c_data *pd)
+static int sh_mobile_i2c_init(struct sh_mobile_i2c_data *pd)
 {
        unsigned long i2c_clk_khz;
        u32 tHIGH, tLOW, tf;
-       int offset;
+       uint16_t max_val;
 
        /* Get clock rate after clock is enabled */
        clk_prepare_enable(pd->clk);
        i2c_clk_khz = clk_get_rate(pd->clk) / 1000;
+       clk_disable_unprepare(pd->clk);
        i2c_clk_khz /= pd->clks_per_count;
 
        if (pd->bus_speed == STANDARD_MODE) {
                tLOW    = 47;   /* tLOW = 4.7 us */
                tHIGH   = 40;   /* tHD;STA = tHIGH = 4.0 us */
                tf      = 3;    /* tf = 0.3 us */
-               offset  = 0;    /* No offset */
        } else if (pd->bus_speed == FAST_MODE) {
                tLOW    = 13;   /* tLOW = 1.3 us */
                tHIGH   = 6;    /* tHD;STA = tHIGH = 0.6 us */
                tf      = 3;    /* tf = 0.3 us */
-               offset  = 0;    /* No offset */
        } else {
                dev_err(pd->dev, "unrecognized bus speed %lu Hz\n",
                        pd->bus_speed);
-               goto out;
+               return -EINVAL;
+       }
+
+       pd->iccl = sh_mobile_i2c_iccl(i2c_clk_khz, tLOW, tf);
+       pd->icch = sh_mobile_i2c_icch(i2c_clk_khz, tHIGH, tf);
+
+       max_val = pd->flags & IIC_FLAG_HAS_ICIC67 ? 0x1ff : 0xff;
+       if (pd->iccl > max_val || pd->icch > max_val) {
+               dev_err(pd->dev, "timing values out of range: L/H=0x%x/0x%x\n",
+                       pd->iccl, pd->icch);
+               return -EINVAL;
        }
 
-       pd->iccl = sh_mobile_i2c_iccl(i2c_clk_khz, tLOW, tf, offset);
        /* one more bit of ICCL in ICIC */
-       if ((pd->iccl > 0xff) && (pd->flags & IIC_FLAG_HAS_ICIC67))
+       if (pd->iccl & 0x100)
                pd->icic |= ICIC_ICCLB8;
        else
                pd->icic &= ~ICIC_ICCLB8;
 
-       pd->icch = sh_mobile_i2c_icch(i2c_clk_khz, tHIGH, tf, offset);
        /* one more bit of ICCH in ICIC */
-       if ((pd->icch > 0xff) && (pd->flags & IIC_FLAG_HAS_ICIC67))
+       if (pd->icch & 0x100)
                pd->icic |= ICIC_ICCHB8;
        else
                pd->icic &= ~ICIC_ICCHB8;
 
-out:
-       clk_disable_unprepare(pd->clk);
+       return 0;
 }
 
 static void activate_ch(struct sh_mobile_i2c_data *pd)
@@ -316,7 +323,7 @@ static unsigned char i2c_op(struct sh_mobile_i2c_data *pd,
 
        switch (op) {
        case OP_START: /* issue start and trigger DTE interrupt */
-               iic_wr(pd, ICCR, 0x94);
+               iic_wr(pd, ICCR, ICCR_ICE | ICCR_TRS | ICCR_BBSY);
                break;
        case OP_TX_FIRST: /* disable DTE interrupt and write data */
                iic_wr(pd, ICIC, ICIC_WAITE | ICIC_ALE | ICIC_TACKE);
@@ -327,10 +334,11 @@ static unsigned char i2c_op(struct sh_mobile_i2c_data *pd,
                break;
        case OP_TX_STOP: /* write data and issue a stop afterwards */
                iic_wr(pd, ICDR, data);
-               iic_wr(pd, ICCR, pd->send_stop ? 0x90 : 0x94);
+               iic_wr(pd, ICCR, pd->send_stop ? ICCR_ICE | ICCR_TRS
+                                              : ICCR_ICE | ICCR_TRS | ICCR_BBSY);
                break;
        case OP_TX_TO_RX: /* select read mode */
-               iic_wr(pd, ICCR, 0x81);
+               iic_wr(pd, ICCR, ICCR_ICE | ICCR_SCP);
                break;
        case OP_RX: /* just read data */
                ret = iic_rd(pd, ICDR);
@@ -338,13 +346,13 @@ static unsigned char i2c_op(struct sh_mobile_i2c_data *pd,
        case OP_RX_STOP: /* enable DTE interrupt, issue stop */
                iic_wr(pd, ICIC,
                       ICIC_DTEE | ICIC_WAITE | ICIC_ALE | ICIC_TACKE);
-               iic_wr(pd, ICCR, 0xc0);
+               iic_wr(pd, ICCR, ICCR_ICE | ICCR_RACK);
                break;
        case OP_RX_STOP_DATA: /* enable DTE interrupt, read data, issue stop */
                iic_wr(pd, ICIC,
                       ICIC_DTEE | ICIC_WAITE | ICIC_ALE | ICIC_TACKE);
                ret = iic_rd(pd, ICDR);
-               iic_wr(pd, ICCR, 0xc0);
+               iic_wr(pd, ICCR, ICCR_ICE | ICCR_RACK);
                break;
        }
 
@@ -479,7 +487,7 @@ static int start_ch(struct sh_mobile_i2c_data *pd, struct i2c_msg *usr_msg,
 {
        if (usr_msg->len == 0 && (usr_msg->flags & I2C_M_RD)) {
                dev_err(pd->dev, "Unsupported zero length i2c read\n");
-               return -EIO;
+               return -EOPNOTSUPP;
        }
 
        if (do_init) {
@@ -514,17 +522,12 @@ static int poll_dte(struct sh_mobile_i2c_data *pd)
                        break;
 
                if (val & ICSR_TACK)
-                       return -EIO;
+                       return -ENXIO;
 
                udelay(10);
        }
 
-       if (!i) {
-               dev_warn(pd->dev, "Timeout polling for DTE!\n");
-               return -ETIMEDOUT;
-       }
-
-       return 0;
+       return i ? 0 : -ETIMEDOUT;
 }
 
 static int poll_busy(struct sh_mobile_i2c_data *pd)
@@ -542,20 +545,18 @@ static int poll_busy(struct sh_mobile_i2c_data *pd)
                 */
                if (!(val & ICSR_BUSY)) {
                        /* handle missing acknowledge and arbitration lost */
-                       if ((val | pd->sr) & (ICSR_TACK | ICSR_AL))
-                               return -EIO;
+                       val |= pd->sr;
+                       if (val & ICSR_TACK)
+                               return -ENXIO;
+                       if (val & ICSR_AL)
+                               return -EAGAIN;
                        break;
                }
 
                udelay(10);
        }
 
-       if (!i) {
-               dev_err(pd->dev, "Polling timed out\n");
-               return -ETIMEDOUT;
-       }
-
-       return 0;
+       return i ? 0 : -ETIMEDOUT;
 }
 
 static int sh_mobile_i2c_xfer(struct i2c_adapter *adapter,
@@ -617,42 +618,44 @@ static struct i2c_algorithm sh_mobile_i2c_algorithm = {
        .master_xfer    = sh_mobile_i2c_xfer,
 };
 
-static int sh_mobile_i2c_hook_irqs(struct platform_device *dev, int hook)
+static const struct sh_mobile_dt_config default_dt_config = {
+       .clks_per_count = 1,
+};
+
+static const struct sh_mobile_dt_config rcar_gen2_dt_config = {
+       .clks_per_count = 2,
+};
+
+static const struct of_device_id sh_mobile_i2c_dt_ids[] = {
+       { .compatible = "renesas,rmobile-iic", .data = &default_dt_config },
+       { .compatible = "renesas,iic-r8a7790", .data = &rcar_gen2_dt_config },
+       { .compatible = "renesas,iic-r8a7791", .data = &rcar_gen2_dt_config },
+       { .compatible = "renesas,iic-r8a7792", .data = &rcar_gen2_dt_config },
+       { .compatible = "renesas,iic-r8a7793", .data = &rcar_gen2_dt_config },
+       { .compatible = "renesas,iic-r8a7794", .data = &rcar_gen2_dt_config },
+       {},
+};
+MODULE_DEVICE_TABLE(of, sh_mobile_i2c_dt_ids);
+
+static int sh_mobile_i2c_hook_irqs(struct platform_device *dev)
 {
        struct resource *res;
-       int ret = -ENXIO;
-       int n, k = 0;
+       resource_size_t n;
+       int k = 0, ret;
 
        while ((res = platform_get_resource(dev, IORESOURCE_IRQ, k))) {
-               for (n = res->start; hook && n <= res->end; n++) {
-                       if (request_irq(n, sh_mobile_i2c_isr, 0,
-                                       dev_name(&dev->dev), dev)) {
-                               for (n--; n >= res->start; n--)
-                                       free_irq(n, dev);
-
-                               goto rollback;
+               for (n = res->start; n <= res->end; n++) {
+                       ret = devm_request_irq(&dev->dev, n, sh_mobile_i2c_isr,
+                                         0, dev_name(&dev->dev), dev);
+                       if (ret) {
+                               dev_err(&dev->dev, "cannot request IRQ %pa\n", &n);
+                               return ret;
                        }
                }
                k++;
        }
 
-       if (hook)
-               return k > 0 ? 0 : -ENOENT;
-
-       ret = 0;
-
- rollback:
-       k--;
-
-       while (k >= 0) {
-               res = platform_get_resource(dev, IORESOURCE_IRQ, k);
-               for (n = res->start; n <= res->end; n++)
-                       free_irq(n, dev);
-
-               k--;
-       }
-
-       return ret;
+       return k > 0 ? 0 : -ENOENT;
 }
 
 static int sh_mobile_i2c_probe(struct platform_device *dev)
@@ -661,62 +664,64 @@ static int sh_mobile_i2c_probe(struct platform_device *dev)
        struct sh_mobile_i2c_data *pd;
        struct i2c_adapter *adap;
        struct resource *res;
-       int size;
        int ret;
+       u32 bus_speed;
 
-       pd = kzalloc(sizeof(struct sh_mobile_i2c_data), GFP_KERNEL);
-       if (pd == NULL) {
-               dev_err(&dev->dev, "cannot allocate private data\n");
+       pd = devm_kzalloc(&dev->dev, sizeof(struct sh_mobile_i2c_data), GFP_KERNEL);
+       if (!pd)
                return -ENOMEM;
-       }
 
-       pd->clk = clk_get(&dev->dev, NULL);
+       pd->clk = devm_clk_get(&dev->dev, NULL);
        if (IS_ERR(pd->clk)) {
                dev_err(&dev->dev, "cannot get clock\n");
-               ret = PTR_ERR(pd->clk);
-               goto err;
+               return PTR_ERR(pd->clk);
        }
 
-       ret = sh_mobile_i2c_hook_irqs(dev, 1);
-       if (ret) {
-               dev_err(&dev->dev, "cannot request IRQ\n");
-               goto err_clk;
-       }
+       ret = sh_mobile_i2c_hook_irqs(dev);
+       if (ret)
+               return ret;
 
        pd->dev = &dev->dev;
        platform_set_drvdata(dev, pd);
 
        res = platform_get_resource(dev, IORESOURCE_MEM, 0);
-       if (res == NULL) {
-               dev_err(&dev->dev, "cannot find IO resource\n");
-               ret = -ENOENT;
-               goto err_irq;
-       }
-
-       size = resource_size(res);
 
-       pd->reg = ioremap(res->start, size);
-       if (pd->reg == NULL) {
-               dev_err(&dev->dev, "cannot map IO\n");
-               ret = -ENXIO;
-               goto err_irq;
-       }
+       pd->reg = devm_ioremap_resource(&dev->dev, res);
+       if (IS_ERR(pd->reg))
+               return PTR_ERR(pd->reg);
 
        /* Use platform data bus speed or STANDARD_MODE */
-       pd->bus_speed = STANDARD_MODE;
-       if (pdata && pdata->bus_speed)
-               pd->bus_speed = pdata->bus_speed;
+       ret = of_property_read_u32(dev->dev.of_node, "clock-frequency", &bus_speed);
+       pd->bus_speed = ret ? STANDARD_MODE : bus_speed;
+
        pd->clks_per_count = 1;
-       if (pdata && pdata->clks_per_count)
-               pd->clks_per_count = pdata->clks_per_count;
+
+       if (dev->dev.of_node) {
+               const struct of_device_id *match;
+
+               match = of_match_device(sh_mobile_i2c_dt_ids, &dev->dev);
+               if (match) {
+                       const struct sh_mobile_dt_config *config;
+
+                       config = match->data;
+                       pd->clks_per_count = config->clks_per_count;
+               }
+       } else {
+               if (pdata && pdata->bus_speed)
+                       pd->bus_speed = pdata->bus_speed;
+               if (pdata && pdata->clks_per_count)
+                       pd->clks_per_count = pdata->clks_per_count;
+       }
 
        /* The IIC blocks on SH-Mobile ARM processors
         * come with two new bits in ICIC.
         */
-       if (size > 0x17)
+       if (resource_size(res) > 0x17)
                pd->flags |= IIC_FLAG_HAS_ICIC67;
 
-       sh_mobile_i2c_init(pd);
+       ret = sh_mobile_i2c_init(pd);
+       if (ret)
+               return ret;
 
        /* Enable Runtime PM for this device.
         *
@@ -750,24 +755,14 @@ static int sh_mobile_i2c_probe(struct platform_device *dev)
        ret = i2c_add_numbered_adapter(adap);
        if (ret < 0) {
                dev_err(&dev->dev, "cannot add numbered adapter\n");
-               goto err_all;
+               return ret;
        }
 
        dev_info(&dev->dev,
-                "I2C adapter %d with bus speed %lu Hz (L/H=%x/%x)\n",
+                "I2C adapter %d with bus speed %lu Hz (L/H=0x%x/0x%x)\n",
                 adap->nr, pd->bus_speed, pd->iccl, pd->icch);
 
        return 0;
-
- err_all:
-       iounmap(pd->reg);
- err_irq:
-       sh_mobile_i2c_hook_irqs(dev, 0);
- err_clk:
-       clk_put(pd->clk);
- err:
-       kfree(pd);
-       return ret;
 }
 
 static int sh_mobile_i2c_remove(struct platform_device *dev)
@@ -775,11 +770,7 @@ static int sh_mobile_i2c_remove(struct platform_device *dev)
        struct sh_mobile_i2c_data *pd = platform_get_drvdata(dev);
 
        i2c_del_adapter(&pd->adap);
-       iounmap(pd->reg);
-       sh_mobile_i2c_hook_irqs(dev, 0);
-       clk_put(pd->clk);
        pm_runtime_disable(&dev->dev);
-       kfree(pd);
        return 0;
 }
 
@@ -800,12 +791,6 @@ static const struct dev_pm_ops sh_mobile_i2c_dev_pm_ops = {
        .runtime_resume = sh_mobile_i2c_runtime_nop,
 };
 
-static const struct of_device_id sh_mobile_i2c_dt_ids[] = {
-       { .compatible = "renesas,rmobile-iic", },
-       {},
-};
-MODULE_DEVICE_TABLE(of, sh_mobile_i2c_dt_ids);
-
 static struct platform_driver sh_mobile_i2c_driver = {
        .driver         = {
                .name           = "i2c-sh_mobile",
index 0fe505d..2b6219d 100644 (file)
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
  */
 
 #include <linux/kernel.h>
index 294c80f..15ac839 100644 (file)
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 */
 
 #include <linux/kernel.h>
@@ -77,10 +73,8 @@ static int simtec_i2c_probe(struct platform_device *dev)
        int ret;
 
        pd = kzalloc(sizeof(struct simtec_i2c_data), GFP_KERNEL);
-       if (pd == NULL) {
-               dev_err(&dev->dev, "cannot allocate private data\n");
+       if (pd == NULL)
                return -ENOMEM;
-       }
 
        platform_set_drvdata(dev, pd);
 
index 6784f7f..02556c0 100644 (file)
@@ -307,7 +307,6 @@ static int i2c_sirfsoc_probe(struct platform_device *pdev)
 
        siic = devm_kzalloc(&pdev->dev, sizeof(*siic), GFP_KERNEL);
        if (!siic) {
-               dev_err(&pdev->dev, "Can't allocate driver data\n");
                err = -ENOMEM;
                goto out;
        }
index 79fd96a..7d58a40 100644 (file)
     but WITHOUT ANY WARRANTY; without even the implied warranty of
     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
     GNU General Public License for more details.
-
-    You should have received a copy of the GNU General Public License
-    along with this program; if not, write to the Free Software
-    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 */
 
 /* Note: we assume there can only be one SIS5595 with one SMBus interface */
@@ -369,7 +365,7 @@ static struct i2c_adapter sis5595_adapter = {
        .algo           = &smbus_algorithm,
 };
 
-static DEFINE_PCI_DEVICE_TABLE(sis5595_ids) = {
+static const struct pci_device_id sis5595_ids[] = {
        { PCI_DEVICE(PCI_VENDOR_ID_SI, PCI_DEVICE_ID_SI_503) }, 
        { 0, }
 };
index 19b8505..1e6805b 100644 (file)
     but WITHOUT ANY WARRANTY; without even the implied warranty of
     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
     GNU General Public License for more details.
-
-    You should have received a copy of the GNU General Public License
-    along with this program; if not, write to the Free Software
-    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 */
 
 /*
@@ -510,7 +506,7 @@ static struct i2c_adapter sis630_adapter = {
        .retries        = 3
 };
 
-static DEFINE_PCI_DEVICE_TABLE(sis630_ids) = {
+static const struct pci_device_id sis630_ids[] = {
        { PCI_DEVICE(PCI_VENDOR_ID_SI, PCI_DEVICE_ID_SI_503) },
        { PCI_DEVICE(PCI_VENDOR_ID_SI, PCI_DEVICE_ID_SI_LPC) },
        { PCI_DEVICE(PCI_VENDOR_ID_SI, PCI_DEVICE_ID_SI_964) },
index f8aa0c2..44b9044 100644 (file)
     but WITHOUT ANY WARRANTY; without even the implied warranty of
     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
     GNU General Public License for more details.
-
-    You should have received a copy of the GNU General Public License
-    along with this program; if not, write to the Free Software
-    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 */
 
 /*
@@ -244,7 +240,7 @@ static struct i2c_adapter sis96x_adapter = {
        .algo           = &smbus_algorithm,
 };
 
-static DEFINE_PCI_DEVICE_TABLE(sis96x_ids) = {
+static const struct pci_device_id sis96x_ids[] = {
        { PCI_DEVICE(PCI_VENDOR_ID_SI, PCI_DEVICE_ID_SI_SMBUS) },
        { 0, }
 };
index 5b80ef3..dc57a16 100644 (file)
@@ -868,10 +868,8 @@ static int stu300_probe(struct platform_device *pdev)
        int ret = 0;
 
        dev = devm_kzalloc(&pdev->dev, sizeof(struct stu300_dev), GFP_KERNEL);
-       if (!dev) {
-               dev_err(&pdev->dev, "could not allocate device struct\n");
+       if (!dev)
                return -ENOMEM;
-       }
 
        bus_nr = pdev->id;
        dev->clk = devm_clk_get(&pdev->dev, NULL);
index 0576026..13c8301 100644 (file)
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  */
 
 #include <linux/delay.h>
index 9704537..8f6f1e4 100644 (file)
@@ -732,10 +732,8 @@ static int tegra_i2c_probe(struct platform_device *pdev)
        }
 
        i2c_dev = devm_kzalloc(&pdev->dev, sizeof(*i2c_dev), GFP_KERNEL);
-       if (!i2c_dev) {
-               dev_err(&pdev->dev, "Could not allocate struct tegra_i2c_dev");
+       if (!i2c_dev)
                return -ENOMEM;
-       }
 
        i2c_dev->base = base;
        i2c_dev->div_clk = div_clk;
index 49d7f14..59b1d23 100644 (file)
     but WITHOUT ANY WARRANTY; without even the implied warranty of
     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
     GNU General Public License for more details.
-
-    You should have received a copy of the GNU General Public License
-    along with this program; if not, write to the Free Software
-    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 */
 
 #include <linux/kernel.h>
@@ -88,7 +84,7 @@ static struct i2c_adapter vt586b_adapter = {
 };
 
 
-static DEFINE_PCI_DEVICE_TABLE(vt586b_ids) = {
+static const struct pci_device_id vt586b_ids[] = {
        { PCI_DEVICE(PCI_VENDOR_ID_VIA, PCI_DEVICE_ID_VIA_82C586_3) },
        { 0, }
 };
index 40d36df..0ee2646 100644 (file)
     but WITHOUT ANY WARRANTY; without even the implied warranty of
     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
     GNU General Public License for more details.
-
-    You should have received a copy of the GNU General Public License
-    along with this program; if not, write to the Free Software
-    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 */
 
 /*
@@ -442,7 +438,7 @@ release_region:
        return error;
 }
 
-static DEFINE_PCI_DEVICE_TABLE(vt596_ids) = {
+static const struct pci_device_id vt596_ids[] = {
        { PCI_DEVICE(PCI_VENDOR_ID_VIA, PCI_DEVICE_ID_VIA_82C596_3),
          .driver_data = SMBBA1 },
        { PCI_DEVICE(PCI_VENDOR_ID_VIA, PCI_DEVICE_ID_VIA_82C596B_3),
index 2c8a3e4..889a212 100644 (file)
@@ -379,10 +379,8 @@ static int wmt_i2c_probe(struct platform_device *pdev)
        u32 clk_rate;
 
        i2c_dev = devm_kzalloc(&pdev->dev, sizeof(*i2c_dev), GFP_KERNEL);
-       if (!i2c_dev) {
-               dev_err(&pdev->dev, "device memory allocation failed\n");
+       if (!i2c_dev)
                return -ENOMEM;
-       }
 
        res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
        i2c_dev->base = devm_ioremap_resource(&pdev->dev, res);
index 2810750..63c0a2f 100644 (file)
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  * GNU General Public License for more details.
  *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *
  *
  * This code was implemented by Mocean Laboratories AB when porting linux
  * to the automotive development board Russellville. The copyright holder
index 2d1d2c5..5153354 100644 (file)
     but WITHOUT ANY WARRANTY; without even the implied warranty of
     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
     General Public License for more details.
-
-    You should have received a copy of the GNU General Public License
-    along with this program; if not, write to the Free Software
-    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 */
 
 #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
@@ -431,10 +427,8 @@ static struct scx200_acb_iface *scx200_create_iface(const char *text,
        struct i2c_adapter *adapter;
 
        iface = kzalloc(sizeof(*iface), GFP_KERNEL);
-       if (!iface) {
-               pr_err("can't allocate memory\n");
+       if (!iface)
                return NULL;
-       }
 
        adapter = &iface->adapter;
        i2c_set_adapdata(adapter, iface);
@@ -556,7 +550,7 @@ static struct platform_driver scx200_pci_driver = {
        .remove = scx200_remove,
 };
 
-static DEFINE_PCI_DEVICE_TABLE(scx200_isa) = {
+static const struct pci_device_id scx200_isa[] = {
        { PCI_DEVICE(PCI_VENDOR_ID_NS, PCI_DEVICE_ID_NS_SCx200_BRIDGE) },
        { PCI_DEVICE(PCI_VENDOR_ID_NS, PCI_DEVICE_ID_NS_SC1100_BRIDGE) },
        { 0, }
index f24cc64..90e3229 100644 (file)
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
- * MA 02110-1301 USA.
  */
 
 #include <linux/kernel.h>
index 5fb80b8..f08e7db 100644 (file)
     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.                                                      */
+    GNU General Public License for more details.                            */
 /* ------------------------------------------------------------------------- */
 
 /* With some changes from Kyösti Mälkki <kmalkki@cc.hut.fi>.
@@ -1941,6 +1936,13 @@ static int i2c_detect_address(struct i2c_client *temp_client,
                struct i2c_client *client;
 
                /* Detection succeeded, instantiate the device */
+               if (adapter->class & I2C_CLASS_DEPRECATED)
+                       dev_warn(&adapter->dev,
+                               "This adapter will soon drop class based instantiation of devices. "
+                               "Please make sure client 0x%02x gets instantiated by other means. "
+                               "Check 'Documentation/i2c/instantiating-devices' for details.\n",
+                               info.addr);
+
                dev_dbg(&adapter->dev, "Creating %s at 0x%02x\n",
                        info.type, info.addr);
                client = i2c_new_device(adapter, &info);
index 18a8fd2..17700bf 100644 (file)
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
- * MA 02110-1301 USA.
  */
 
 #include <linux/rwsem.h>
index 80b47e8..71c7a39 100644 (file)
     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.
 */
 
 /* Note that this is a complete rewrite of Simon Vogl's i2c-dev module.
index fc99f0d..9ebf9cb 100644 (file)
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
- * MA 02110-1301 USA.
  */
 
 #include <linux/kernel.h>
index 77e4849..b58c328 100644 (file)
     but WITHOUT ANY WARRANTY; without even the implied warranty of
     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
     GNU General Public License for more details.
-
-    You should have received a copy of the GNU General Public License
-    along with this program; if not, write to the Free Software
-    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 */
 
 #define DEBUG 1
index d4e15a6..9d38f7b 100644 (file)
 #include <linux/videodev2.h>
 #include <linux/uaccess.h>
 #include <linux/of.h>
+#include <linux/of_graph.h>
 
 #include <media/adv7343.h>
 #include <media/v4l2-async.h>
 #include <media/v4l2-device.h>
 #include <media/v4l2-ctrls.h>
-#include <media/v4l2-of.h>
 
 #include "adv7343_regs.h"
 
@@ -410,7 +410,7 @@ adv7343_get_pdata(struct i2c_client *client)
        if (!IS_ENABLED(CONFIG_OF) || !client->dev.of_node)
                return client->dev.platform_data;
 
-       np = v4l2_of_get_next_endpoint(client->dev.of_node, NULL);
+       np = of_graph_get_next_endpoint(client->dev.of_node, NULL);
        if (!np)
                return NULL;
 
index e5ddf47..192c4aa 100644 (file)
@@ -21,6 +21,7 @@
 #include <linux/module.h>
 #include <linux/of.h>
 #include <linux/of_gpio.h>
+#include <linux/of_graph.h>
 #include <linux/pm.h>
 #include <linux/regulator/consumer.h>
 #include <linux/slab.h>
@@ -29,7 +30,6 @@
 #include <media/mt9p031.h>
 #include <media/v4l2-ctrls.h>
 #include <media/v4l2-device.h>
-#include <media/v4l2-of.h>
 #include <media/v4l2-subdev.h>
 
 #include "aptina-pll.h"
@@ -943,7 +943,7 @@ mt9p031_get_pdata(struct i2c_client *client)
        if (!IS_ENABLED(CONFIG_OF) || !client->dev.of_node)
                return client->dev.platform_data;
 
-       np = v4l2_of_get_next_endpoint(client->dev.of_node, NULL);
+       np = of_graph_get_next_endpoint(client->dev.of_node, NULL);
        if (!np)
                return NULL;
 
index 77e10e0..2d768ef 100644 (file)
@@ -21,6 +21,7 @@
 #include <linux/media.h>
 #include <linux/module.h>
 #include <linux/of_gpio.h>
+#include <linux/of_graph.h>
 #include <linux/regulator/consumer.h>
 #include <linux/slab.h>
 
@@ -1855,7 +1856,7 @@ static int s5k5baf_parse_device_node(struct s5k5baf *state, struct device *dev)
        if (ret < 0)
                return ret;
 
-       node_ep = v4l2_of_get_next_endpoint(node, NULL);
+       node_ep = of_graph_get_next_endpoint(node, NULL);
        if (!node_ep) {
                dev_err(dev, "no endpoint defined at node %s\n",
                        node->full_name);
index 83d85df..ca00117 100644 (file)
@@ -36,6 +36,7 @@
 #include <linux/module.h>
 #include <linux/v4l2-mediabus.h>
 #include <linux/of.h>
+#include <linux/of_graph.h>
 
 #include <media/v4l2-async.h>
 #include <media/v4l2-device.h>
@@ -1068,7 +1069,7 @@ tvp514x_get_pdata(struct i2c_client *client)
        if (!IS_ENABLED(CONFIG_OF) || !client->dev.of_node)
                return client->dev.platform_data;
 
-       endpoint = v4l2_of_get_next_endpoint(client->dev.of_node, NULL);
+       endpoint = of_graph_get_next_endpoint(client->dev.of_node, NULL);
        if (!endpoint)
                return NULL;
 
index 912e1cc..c4e1e2c 100644 (file)
@@ -30,6 +30,7 @@
 #include <linux/videodev2.h>
 #include <linux/module.h>
 #include <linux/of.h>
+#include <linux/of_graph.h>
 #include <linux/v4l2-dv-timings.h>
 #include <media/tvp7002.h>
 #include <media/v4l2-async.h>
@@ -957,7 +958,7 @@ tvp7002_get_pdata(struct i2c_client *client)
        if (!IS_ENABLED(CONFIG_OF) || !client->dev.of_node)
                return client->dev.platform_data;
 
-       endpoint = v4l2_of_get_next_endpoint(client->dev.of_node, NULL);
+       endpoint = of_graph_get_next_endpoint(client->dev.of_node, NULL);
        if (!endpoint)
                return NULL;
 
index d12bd33..b711b5b 100644 (file)
@@ -757,7 +757,6 @@ static int qcam_g_fmt_vid_cap(struct file *file, void *fh, struct v4l2_format *f
        pix->sizeimage = pix->width * pix->height;
        /* Just a guess */
        pix->colorspace = V4L2_COLORSPACE_SRGB;
-       pix->priv = 0;
        return 0;
 }
 
@@ -783,7 +782,6 @@ static int qcam_try_fmt_vid_cap(struct file *file, void *fh, struct v4l2_format
        pix->sizeimage = pix->width * pix->height;
        /* Just a guess */
        pix->colorspace = V4L2_COLORSPACE_SRGB;
-       pix->priv = 0;
        return 0;
 }
 
index 1110bcb..c4c3ff3 100644 (file)
@@ -156,7 +156,6 @@ static int cx18_g_fmt_vid_cap(struct file *file, void *fh,
        pixfmt->height = cx->cxhdl.height;
        pixfmt->colorspace = V4L2_COLORSPACE_SMPTE170M;
        pixfmt->field = V4L2_FIELD_INTERLACED;
-       pixfmt->priv = 0;
        if (id->type == CX18_ENC_STREAM_TYPE_YUV) {
                pixfmt->pixelformat = s->pixelformat;
                pixfmt->sizeimage = s->vb_bytes_per_frame;
index d270819..c7ae087 100644 (file)
@@ -576,7 +576,6 @@ static int cx25821_vidioc_g_fmt_vid_cap(struct file *file, void *priv,
        f->fmt.pix.bytesperline = (chan->width * chan->fmt->depth) >> 3;
        f->fmt.pix.sizeimage = chan->height * f->fmt.pix.bytesperline;
        f->fmt.pix.colorspace = V4L2_COLORSPACE_SMPTE170M;
-       f->fmt.pix.priv = 0;
 
        return 0;
 }
@@ -615,7 +614,6 @@ static int cx25821_vidioc_try_fmt_vid_cap(struct file *file, void *priv,
        f->fmt.pix.bytesperline = (f->fmt.pix.width * fmt->depth) >> 3;
        f->fmt.pix.sizeimage = f->fmt.pix.height * f->fmt.pix.bytesperline;
        f->fmt.pix.colorspace = V4L2_COLORSPACE_SMPTE170M;
-       f->fmt.pix.priv = 0;
 
        return 0;
 }
@@ -867,7 +865,6 @@ static int cx25821_vidioc_try_fmt_vid_out(struct file *file, void *priv,
        f->fmt.pix.bytesperline = (f->fmt.pix.width * fmt->depth) >> 3;
        f->fmt.pix.sizeimage = f->fmt.pix.height * f->fmt.pix.bytesperline;
        f->fmt.pix.colorspace = V4L2_COLORSPACE_SMPTE170M;
-       f->fmt.pix.priv = 0;
        return 0;
 }
 
index 807b275..d4d0f0e 100644 (file)
@@ -351,7 +351,6 @@ static int ivtv_g_fmt_vid_cap(struct file *file, void *fh, struct v4l2_format *f
        pixfmt->height = itv->cxhdl.height;
        pixfmt->colorspace = V4L2_COLORSPACE_SMPTE170M;
        pixfmt->field = V4L2_FIELD_INTERLACED;
-       pixfmt->priv = 0;
        if (id->type == IVTV_ENC_STREAM_TYPE_YUV) {
                pixfmt->pixelformat = V4L2_PIX_FMT_HM12;
                /* YUV size is (Y=(h*720) + UV=(h*(720/2))) */
@@ -418,7 +417,6 @@ static int ivtv_g_fmt_vid_out(struct file *file, void *fh, struct v4l2_format *f
        pixfmt->height = itv->main_rect.height;
        pixfmt->colorspace = V4L2_COLORSPACE_SMPTE170M;
        pixfmt->field = V4L2_FIELD_INTERLACED;
-       pixfmt->priv = 0;
        if (id->type == IVTV_DEC_STREAM_TYPE_YUV) {
                switch (itv->yuv_info.lace_mode & IVTV_YUV_MODE_MASK) {
                case IVTV_YUV_MODE_INTERLACED:
@@ -1384,7 +1382,6 @@ static int ivtv_g_fbuf(struct file *file, void *fh, struct v4l2_framebuffer *fb)
        fb->fmt.bytesperline = fb->fmt.width;
        fb->fmt.colorspace = V4L2_COLORSPACE_SMPTE170M;
        fb->fmt.field = V4L2_FIELD_INTERLACED;
-       fb->fmt.priv = 0;
        if (fb->fmt.pixelformat != V4L2_PIX_FMT_PAL8)
                fb->fmt.bytesperline *= 2;
        if (fb->fmt.pixelformat == V4L2_PIX_FMT_RGB32 ||
index 54d5c82..4e7fba0 100644 (file)
@@ -1166,7 +1166,6 @@ static int vidioc_try_fmt_vid_cap(struct file *file, void *fh,
        f->fmt.pix.sizeimage = f->fmt.pix.height *
                               f->fmt.pix.bytesperline;
        f->fmt.pix.colorspace = 0;
-       f->fmt.pix.priv = 0;
 
        return 0;
 }
@@ -1232,7 +1231,6 @@ static int vidioc_s_fmt_vid_cap(struct file *file, void *fh,
        f->fmt.pix.sizeimage = f->fmt.pix.height *
                               f->fmt.pix.bytesperline;
        f->fmt.pix.colorspace = 0;
-       f->fmt.pix.priv = 0;
 
        return 0;
 }
index 0a9047e..71bf872 100644 (file)
@@ -189,7 +189,6 @@ static int empress_g_fmt_vid_cap(struct file *file, void *priv,
        f->fmt.pix.pixelformat  = V4L2_PIX_FMT_MPEG;
        f->fmt.pix.sizeimage    = TS_PACKET_SIZE * dev->ts.nr_packets;
        f->fmt.pix.bytesperline = 0;
-       f->fmt.pix.priv = 0;
 
        return 0;
 }
@@ -207,7 +206,6 @@ static int empress_s_fmt_vid_cap(struct file *file, void *priv,
        f->fmt.pix.pixelformat  = V4L2_PIX_FMT_MPEG;
        f->fmt.pix.sizeimage    = TS_PACKET_SIZE * dev->ts.nr_packets;
        f->fmt.pix.bytesperline = 0;
-       f->fmt.pix.priv = 0;
 
        return 0;
 }
@@ -225,7 +223,6 @@ static int empress_try_fmt_vid_cap(struct file *file, void *priv,
        f->fmt.pix.pixelformat  = V4L2_PIX_FMT_MPEG;
        f->fmt.pix.sizeimage    = TS_PACKET_SIZE * dev->ts.nr_packets;
        f->fmt.pix.bytesperline = 0;
-       f->fmt.pix.priv = 0;
 
        return 0;
 }
index 40396e8..c8c2215 100644 (file)
@@ -1347,7 +1347,6 @@ static int saa7134_g_fmt_vid_cap(struct file *file, void *priv,
        f->fmt.pix.sizeimage =
                f->fmt.pix.height * f->fmt.pix.bytesperline;
        f->fmt.pix.colorspace   = V4L2_COLORSPACE_SMPTE170M;
-       f->fmt.pix.priv = 0;
        return 0;
 }
 
@@ -1429,7 +1428,6 @@ static int saa7134_try_fmt_vid_cap(struct file *file, void *priv,
        f->fmt.pix.sizeimage =
                f->fmt.pix.height * f->fmt.pix.bytesperline;
        f->fmt.pix.colorspace   = V4L2_COLORSPACE_SMPTE170M;
-       f->fmt.pix.priv = 0;
 
        return 0;
 }
index e5cfb6c..7219c59 100644 (file)
@@ -642,7 +642,6 @@ static int vidioc_try_fmt_vid_cap(struct file *file, void *priv,
        f->fmt.pix.bytesperline = f->fmt.pix.width * 2;
        f->fmt.pix.sizeimage = f->fmt.pix.width * 2 * f->fmt.pix.height;
        f->fmt.pix.colorspace = V4L2_COLORSPACE_SMPTE170M;
-       f->fmt.pix.priv = 0;
        return 0;
 }
 
index 61f3dbc..21c31bc 100644 (file)
@@ -613,8 +613,6 @@ static int coda_try_fmt(struct coda_ctx *ctx, struct coda_codec *codec,
                BUG();
        }
 
-       f->fmt.pix.priv = 0;
-
        return 0;
 }
 
index b02aba4..66e9e5f 100644 (file)
@@ -344,11 +344,6 @@ static int vpbe_start_streaming(struct vb2_queue *vq, unsigned int count)
        struct vpbe_device *vpbe_dev = fh->disp_dev->vpbe_dev;
        int ret;
 
-       /* If buffer queue is empty, return error */
-       if (list_empty(&layer->dma_queue)) {
-               v4l2_err(&vpbe_dev->v4l2_dev, "buffer queue is empty\n");
-               return -ENOBUFS;
-       }
        /* Get the next frame from the buffer queue */
        layer->next_frm = layer->cur_frm = list_entry(layer->dma_queue.next,
                                struct vpbe_disp_buffer, list);
@@ -1415,7 +1410,7 @@ static int vpbe_display_reqbufs(struct file *file, void *priv,
        q->ops = &video_qops;
        q->mem_ops = &vb2_dma_contig_memops;
        q->buf_struct_size = sizeof(struct vpbe_disp_buffer);
-       q->timestamp_type = V4L2_BUF_FLAG_TIMESTAMP_MONOTONIC;
+       q->timestamp_flags = V4L2_BUF_FLAG_TIMESTAMP_MONOTONIC;
 
        ret = vb2_queue_init(q);
        if (ret) {
index 735ec47..650b6f1 100644 (file)
@@ -272,13 +272,7 @@ static int vpif_start_streaming(struct vb2_queue *vq, unsigned int count)
        unsigned long flags;
        int ret;
 
-       /* If buffer queue is empty, return error */
        spin_lock_irqsave(&common->irqlock, flags);
-       if (list_empty(&common->dma_queue)) {
-               spin_unlock_irqrestore(&common->irqlock, flags);
-               vpif_dbg(1, debug, "buffer queue is empty\n");
-               return -ENOBUFS;
-       }
 
        /* Get the next frame from the buffer queue */
        common->cur_frm = common->next_frm = list_entry(common->dma_queue.next,
@@ -1023,7 +1017,7 @@ static int vpif_reqbufs(struct file *file, void *priv,
        q->ops = &video_qops;
        q->mem_ops = &vb2_dma_contig_memops;
        q->buf_struct_size = sizeof(struct vpif_cap_buffer);
-       q->timestamp_type = V4L2_BUF_FLAG_TIMESTAMP_MONOTONIC;
+       q->timestamp_flags = V4L2_BUF_FLAG_TIMESTAMP_MONOTONIC;
 
        ret = vb2_queue_init(q);
        if (ret) {
index 9d115cd..68ab419 100644 (file)
@@ -234,13 +234,7 @@ static int vpif_start_streaming(struct vb2_queue *vq, unsigned int count)
        unsigned long flags;
        int ret;
 
-       /* If buffer queue is empty, return error */
        spin_lock_irqsave(&common->irqlock, flags);
-       if (list_empty(&common->dma_queue)) {
-               spin_unlock_irqrestore(&common->irqlock, flags);
-               vpif_err("buffer queue is empty\n");
-               return -ENOBUFS;
-       }
 
        /* Get the next frame from the buffer queue */
        common->next_frm = common->cur_frm =
@@ -983,7 +977,7 @@ static int vpif_reqbufs(struct file *file, void *priv,
        q->ops = &video_qops;
        q->mem_ops = &vb2_dma_contig_memops;
        q->buf_struct_size = sizeof(struct vpif_disp_buffer);
-       q->timestamp_type = V4L2_BUF_FLAG_TIMESTAMP_MONOTONIC;
+       q->timestamp_flags = V4L2_BUF_FLAG_TIMESTAMP_MONOTONIC;
 
        ret = vb2_queue_init(q);
        if (ret) {
index 13a4228..9bdfa45 100644 (file)
 #include <linux/i2c.h>
 #include <linux/of_irq.h>
 #include <linux/of_address.h>
+#include <linux/of_graph.h>
 #include <linux/of_platform.h>
 #include <linux/platform_device.h>
 #include <linux/pm_runtime.h>
 #include <linux/slab.h>
 #include <linux/types.h>
 #include <linux/videodev2.h>
-#include <media/v4l2-of.h>
 #include <media/videobuf2-dma-contig.h>
 
 #include "media-dev.h"
@@ -167,10 +167,10 @@ static int fimc_is_parse_sensor_config(struct fimc_is_sensor *sensor,
        u32 tmp = 0;
        int ret;
 
-       np = v4l2_of_get_next_endpoint(np, NULL);
+       np = of_graph_get_next_endpoint(np, NULL);
        if (!np)
                return -ENXIO;
-       np = v4l2_of_get_remote_port(np);
+       np = of_graph_get_remote_port(np);
        if (!np)
                return -ENXIO;
 
index c1bce17..04d6ecd 100644 (file)
@@ -20,6 +20,7 @@
 #include <linux/of.h>
 #include <linux/of_platform.h>
 #include <linux/of_device.h>
+#include <linux/of_graph.h>
 #include <linux/platform_device.h>
 #include <linux/pm_runtime.h>
 #include <linux/types.h>
@@ -468,12 +469,12 @@ static int fimc_md_parse_port_node(struct fimc_md *fmd,
                return 0;
 
        v4l2_of_parse_endpoint(ep, &endpoint);
-       if (WARN_ON(endpoint.port == 0) || index >= FIMC_MAX_SENSORS)
+       if (WARN_ON(endpoint.base.port == 0) || index >= FIMC_MAX_SENSORS)
                return -EINVAL;
 
-       pd->mux_id = (endpoint.port - 1) & 0x1;
+       pd->mux_id = (endpoint.base.port - 1) & 0x1;
 
-       rem = v4l2_of_get_remote_port_parent(ep);
+       rem = of_graph_get_remote_port_parent(ep);
        of_node_put(ep);
        if (rem == NULL) {
                v4l2_info(&fmd->v4l2_dev, "Remote device at %s not found\n",
@@ -493,13 +494,13 @@ static int fimc_md_parse_port_node(struct fimc_md *fmd,
                return -EINVAL;
        }
 
-       if (fimc_input_is_parallel(endpoint.port)) {
+       if (fimc_input_is_parallel(endpoint.base.port)) {
                if (endpoint.bus_type == V4L2_MBUS_PARALLEL)
                        pd->sensor_bus_type = FIMC_BUS_TYPE_ITU_601;
                else
                        pd->sensor_bus_type = FIMC_BUS_TYPE_ITU_656;
                pd->flags = endpoint.bus.parallel.flags;
-       } else if (fimc_input_is_mipi_csi(endpoint.port)) {
+       } else if (fimc_input_is_mipi_csi(endpoint.base.port)) {
                /*
                 * MIPI CSI-2: only input mux selection and
                 * the sensor's clock frequency is needed.
@@ -507,7 +508,7 @@ static int fimc_md_parse_port_node(struct fimc_md *fmd,
                pd->sensor_bus_type = FIMC_BUS_TYPE_MIPI_CSI2;
        } else {
                v4l2_err(&fmd->v4l2_dev, "Wrong port id (%u) at node %s\n",
-                        endpoint.port, rem->full_name);
+                        endpoint.base.port, rem->full_name);
        }
        /*
         * For FIMC-IS handled sensors, that are placed under i2c-isp device
index f3c3591..3678ba5 100644 (file)
@@ -20,6 +20,7 @@
 #include <linux/memory.h>
 #include <linux/module.h>
 #include <linux/of.h>
+#include <linux/of_graph.h>
 #include <linux/phy/phy.h>
 #include <linux/platform_data/mipi-csis.h>
 #include <linux/platform_device.h>
@@ -762,7 +763,7 @@ static int s5pcsis_parse_dt(struct platform_device *pdev,
                                 &state->max_num_lanes))
                return -EINVAL;
 
-       node = v4l2_of_get_next_endpoint(node, NULL);
+       node = of_graph_get_next_endpoint(node, NULL);
        if (!node) {
                dev_err(&pdev->dev, "No port node at %s\n",
                                pdev->dev.of_node->full_name);
@@ -771,7 +772,7 @@ static int s5pcsis_parse_dt(struct platform_device *pdev,
        /* Get port node and validate MIPI-CSI channel id. */
        v4l2_of_parse_endpoint(node, &endpoint);
 
-       state->index = endpoint.port - FIMC_INPUT_MIPI_CSI2_0;
+       state->index = endpoint.base.port - FIMC_INPUT_MIPI_CSI2_0;
        if (state->index < 0 || state->index >= CSIS_MAX_ENTITIES)
                return -ENXIO;
 
index dfd0a21..17b4440 100644 (file)
@@ -165,7 +165,6 @@ static int omap_vout_try_format(struct v4l2_pix_format *pix)
 
        pix->pixelformat = omap_formats[ifmt].pixelformat;
        pix->field = V4L2_FIELD_ANY;
-       pix->priv = 0;
 
        switch (pix->pixelformat) {
        case V4L2_PIX_FMT_YUYV:
@@ -1895,7 +1894,6 @@ static int __init omap_vout_setup_video_data(struct omap_vout_device *vout)
        pix->field = V4L2_FIELD_ANY;
        pix->bytesperline = pix->width * 2;
        pix->sizeimage = pix->bytesperline * pix->height;
-       pix->priv = 0;
        pix->colorspace = V4L2_COLORSPACE_JPEG;
 
        vout->bpp = RGB565_BPP;
index c5059ba..a1ce55f 100644 (file)
@@ -946,11 +946,6 @@ static int start_streaming(struct vb2_queue *vq, unsigned int count)
 
        mxr_dbg(mdev, "%s\n", __func__);
 
-       if (count == 0) {
-               mxr_dbg(mdev, "no output buffers queued\n");
-               return -ENOBUFS;
-       }
-
        /* block any changes in output configuration */
        mxr_output_get(mdev);
 
@@ -1124,6 +1119,7 @@ struct mxr_layer *mxr_base_layer_create(struct mxr_device *mdev,
                .drv_priv = layer,
                .buf_struct_size = sizeof(struct mxr_buffer),
                .ops = &mxr_video_qops,
+               .min_buffers_needed = 1,
                .mem_ops = &vb2_dma_contig_memops,
        };
 
index 744e43b..8dc279d 100644 (file)
@@ -425,7 +425,6 @@ static int sh_veu_g_fmt(struct sh_veu_file *veu_file, struct v4l2_format *f)
        pix->bytesperline       = vfmt->bytesperline;
        pix->sizeimage          = vfmt->bytesperline * pix->height *
                vfmt->fmt->depth / vfmt->fmt->ydepth;
-       pix->priv               = 0;
        dev_dbg(veu->dev, "%s(): type: %d, size %u @ %ux%u, fmt %x\n", __func__,
                f->type, pix->sizeimage, pix->width, pix->height, pix->pixelformat);
 
@@ -473,7 +472,6 @@ static int sh_veu_try_fmt(struct v4l2_format *f, const struct sh_veu_format *fmt
 
        pix->pixelformat        = fmt->fourcc;
        pix->colorspace         = sh_veu_4cc2cspace(pix->pixelformat);
-       pix->priv               = 0;
 
        pr_debug("%s(): type: %d, size %u\n", __func__, f->type, pix->sizeimage);
 
index 3b1c05a..4ea0fa8 100644 (file)
@@ -19,6 +19,8 @@
 #include <linux/io.h>
 #include <linux/kernel.h>
 #include <linux/module.h>
+#include <linux/of.h>
+#include <linux/of_device.h>
 #include <linux/platform_data/camera-rcar.h>
 #include <linux/platform_device.h>
 #include <linux/pm_runtime.h>
@@ -31,6 +33,7 @@
 #include <media/v4l2-dev.h>
 #include <media/v4l2-device.h>
 #include <media/v4l2-mediabus.h>
+#include <media/v4l2-of.h>
 #include <media/v4l2-subdev.h>
 #include <media/videobuf2-dma-contig.h>
 
@@ -68,6 +71,8 @@
 #define VNMC_YCAL              (1 << 19)
 #define VNMC_INF_YUV8_BT656    (0 << 16)
 #define VNMC_INF_YUV8_BT601    (1 << 16)
+#define VNMC_INF_YUV10_BT656   (2 << 16)
+#define VNMC_INF_YUV10_BT601   (3 << 16)
 #define VNMC_INF_YUV16         (5 << 16)
 #define VNMC_VUP               (1 << 10)
 #define VNMC_IM_ODD            (0 << 3)
@@ -124,13 +129,13 @@ struct rcar_vin_priv {
        int                             sequence;
        /* State of the VIN module in capturing mode */
        enum rcar_vin_state             state;
-       struct rcar_vin_platform_data   *pdata;
        struct soc_camera_host          ici;
        struct list_head                capture;
 #define MAX_BUFFER_NUM                 3
        struct vb2_buffer               *queue_buf[MAX_BUFFER_NUM];
        struct vb2_alloc_ctx            *alloc_ctx;
        enum v4l2_field                 field;
+       unsigned int                    pdata_flags;
        unsigned int                    vb_count;
        unsigned int                    nr_hw_slots;
        bool                            request_to_stop;
@@ -273,8 +278,14 @@ static int rcar_vin_setup(struct rcar_vin_priv *priv)
                break;
        case V4L2_MBUS_FMT_YUYV8_2X8:
                /* BT.656 8bit YCbCr422 or BT.601 8bit YCbCr422 */
-               vnmc |= priv->pdata->flags & RCAR_VIN_BT656 ?
+               vnmc |= priv->pdata_flags & RCAR_VIN_BT656 ?
                        VNMC_INF_YUV8_BT656 : VNMC_INF_YUV8_BT601;
+               break;
+       case V4L2_MBUS_FMT_YUYV10_2X10:
+               /* BT.656 10bit YCbCr422 or BT.601 10bit YCbCr422 */
+               vnmc |= priv->pdata_flags & RCAR_VIN_BT656 ?
+                       VNMC_INF_YUV10_BT656 : VNMC_INF_YUV10_BT601;
+               break;
        default:
                break;
        }
@@ -791,7 +802,7 @@ static int rcar_vin_set_bus_param(struct soc_camera_device *icd)
        /* Make choises, based on platform preferences */
        if ((common_flags & V4L2_MBUS_HSYNC_ACTIVE_HIGH) &&
            (common_flags & V4L2_MBUS_HSYNC_ACTIVE_LOW)) {
-               if (priv->pdata->flags & RCAR_VIN_HSYNC_ACTIVE_LOW)
+               if (priv->pdata_flags & RCAR_VIN_HSYNC_ACTIVE_LOW)
                        common_flags &= ~V4L2_MBUS_HSYNC_ACTIVE_HIGH;
                else
                        common_flags &= ~V4L2_MBUS_HSYNC_ACTIVE_LOW;
@@ -799,7 +810,7 @@ static int rcar_vin_set_bus_param(struct soc_camera_device *icd)
 
        if ((common_flags & V4L2_MBUS_VSYNC_ACTIVE_HIGH) &&
            (common_flags & V4L2_MBUS_VSYNC_ACTIVE_LOW)) {
-               if (priv->pdata->flags & RCAR_VIN_VSYNC_ACTIVE_LOW)
+               if (priv->pdata_flags & RCAR_VIN_VSYNC_ACTIVE_LOW)
                        common_flags &= ~V4L2_MBUS_VSYNC_ACTIVE_HIGH;
                else
                        common_flags &= ~V4L2_MBUS_VSYNC_ACTIVE_LOW;
@@ -1003,6 +1014,7 @@ static int rcar_vin_get_formats(struct soc_camera_device *icd, unsigned int idx,
        switch (code) {
        case V4L2_MBUS_FMT_YUYV8_1X16:
        case V4L2_MBUS_FMT_YUYV8_2X8:
+       case V4L2_MBUS_FMT_YUYV10_2X10:
                if (cam->extra_fmt)
                        break;
 
@@ -1383,6 +1395,17 @@ static struct soc_camera_host_ops rcar_vin_host_ops = {
        .init_videobuf2 = rcar_vin_init_videobuf2,
 };
 
+#ifdef CONFIG_OF
+static struct of_device_id rcar_vin_of_table[] = {
+       { .compatible = "renesas,vin-r8a7791", .data = (void *)RCAR_GEN2 },
+       { .compatible = "renesas,vin-r8a7790", .data = (void *)RCAR_GEN2 },
+       { .compatible = "renesas,vin-r8a7779", .data = (void *)RCAR_H1 },
+       { .compatible = "renesas,vin-r8a7778", .data = (void *)RCAR_M1 },
+       { },
+};
+MODULE_DEVICE_TABLE(of, rcar_vin_of_table);
+#endif
+
 static struct platform_device_id rcar_vin_id_table[] = {
        { "r8a7791-vin",  RCAR_GEN2 },
        { "r8a7790-vin",  RCAR_GEN2 },
@@ -1395,15 +1418,52 @@ MODULE_DEVICE_TABLE(platform, rcar_vin_id_table);
 
 static int rcar_vin_probe(struct platform_device *pdev)
 {
+       const struct of_device_id *match = NULL;
        struct rcar_vin_priv *priv;
        struct resource *mem;
        struct rcar_vin_platform_data *pdata;
+       unsigned int pdata_flags;
        int irq, ret;
 
-       pdata = pdev->dev.platform_data;
-       if (!pdata || !pdata->flags) {
-               dev_err(&pdev->dev, "platform data not set\n");
-               return -EINVAL;
+       if (pdev->dev.of_node) {
+               struct v4l2_of_endpoint ep;
+               struct device_node *np;
+
+               match = of_match_device(of_match_ptr(rcar_vin_of_table),
+                                       &pdev->dev);
+
+               np = of_graph_get_next_endpoint(pdev->dev.of_node, NULL);
+               if (!np) {
+                       dev_err(&pdev->dev, "could not find endpoint\n");
+                       return -EINVAL;
+               }
+
+               ret = v4l2_of_parse_endpoint(np, &ep);
+               if (ret) {
+                       dev_err(&pdev->dev, "could not parse endpoint\n");
+                       return ret;
+               }
+
+               if (ep.bus_type == V4L2_MBUS_BT656)
+                       pdata_flags = RCAR_VIN_BT656;
+               else {
+                       pdata_flags = 0;
+                       if (ep.bus.parallel.flags & V4L2_MBUS_HSYNC_ACTIVE_LOW)
+                               pdata_flags |= RCAR_VIN_HSYNC_ACTIVE_LOW;
+                       if (ep.bus.parallel.flags & V4L2_MBUS_VSYNC_ACTIVE_LOW)
+                               pdata_flags |= RCAR_VIN_VSYNC_ACTIVE_LOW;
+               }
+
+               of_node_put(np);
+
+               dev_dbg(&pdev->dev, "pdata_flags = %08x\n", pdata_flags);
+       } else {
+               pdata = pdev->dev.platform_data;
+               if (!pdata || !pdata->flags) {
+                       dev_err(&pdev->dev, "platform data not set\n");
+                       return -EINVAL;
+               }
+               pdata_flags = pdata->flags;
        }
 
        mem = platform_get_resource(pdev, IORESOURCE_MEM, 0);
@@ -1434,12 +1494,18 @@ static int rcar_vin_probe(struct platform_device *pdev)
 
        priv->ici.priv = priv;
        priv->ici.v4l2_dev.dev = &pdev->dev;
-       priv->ici.nr = pdev->id;
        priv->ici.drv_name = dev_name(&pdev->dev);
        priv->ici.ops = &rcar_vin_host_ops;
 
-       priv->pdata = pdata;
-       priv->chip = pdev->id_entry->driver_data;
+       priv->pdata_flags = pdata_flags;
+       if (!match) {
+               priv->ici.nr = pdev->id;
+               priv->chip = pdev->id_entry->driver_data;
+       } else {
+               priv->ici.nr = of_alias_get_id(pdev->dev.of_node, "vin");
+               priv->chip = (enum chip_id)match->data;
+       };
+
        spin_lock_init(&priv->lock);
        INIT_LIST_HEAD(&priv->capture);
 
@@ -1480,6 +1546,7 @@ static struct platform_driver rcar_vin_driver = {
        .driver         = {
                .name           = DRV_NAME,
                .owner          = THIS_MODULE,
+               .of_match_table = of_match_ptr(rcar_vin_of_table),
        },
        .id_table       = rcar_vin_id_table,
 };
index c6af974..e58796e 100644 (file)
@@ -3147,7 +3147,6 @@ static int vino_try_fmt_vid_cap(struct file *file, void *__fh,
        pf->colorspace =
                vino_data_formats[tempvcs.data_format].colorspace;
 
-       pf->priv = 0;
        return 0;
 }
 
@@ -3175,8 +3174,6 @@ static int vino_g_fmt_vid_cap(struct file *file, void *__fh,
        pf->colorspace =
                vino_data_formats[vcs->data_format].colorspace;
 
-       pf->priv = 0;
-
        spin_unlock_irqrestore(&vino_drvdata->input_lock, flags);
        return 0;
 }
@@ -3219,8 +3216,6 @@ static int vino_s_fmt_vid_cap(struct file *file, void *__fh,
        pf->colorspace =
                vino_data_formats[vcs->data_format].colorspace;
 
-       pf->priv = 0;
-
        spin_unlock_irqrestore(&vino_drvdata->input_lock, flags);
        return 0;
 }
index 2d4e73b..4807225 100644 (file)
@@ -1015,7 +1015,6 @@ static int vidioc_try_fmt_vid_cap(struct file *file, void *priv,
                f->fmt.pix.colorspace = V4L2_COLORSPACE_SMPTE170M;
        else
                f->fmt.pix.colorspace = V4L2_COLORSPACE_SRGB;
-       f->fmt.pix.priv = 0;
        return 0;
 }
 
index 151cecd..6a93f92 100644 (file)
@@ -1,6 +1,6 @@
 vsp1-y                                 := vsp1_drv.o vsp1_entity.o vsp1_video.o
 vsp1-y                                 += vsp1_rpf.o vsp1_rwpf.o vsp1_wpf.o
 vsp1-y                                 += vsp1_hsit.o vsp1_lif.o vsp1_lut.o
-vsp1-y                                 += vsp1_sru.o vsp1_uds.o
+vsp1-y                                 += vsp1_bru.o vsp1_sru.o vsp1_uds.o
 
 obj-$(CONFIG_VIDEO_RENESAS_VSP1)       += vsp1.o
index 94d1b02..1246719 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * vsp1.h  --  R-Car VSP1 Driver
  *
- * Copyright (C) 2013 Renesas Corporation
+ * Copyright (C) 2013-2014 Renesas Electronics Corporation
  *
  * Contact: Laurent Pinchart (laurent.pinchart@ideasonboard.com)
  *
@@ -28,6 +28,7 @@ struct clk;
 struct device;
 
 struct vsp1_platform_data;
+struct vsp1_bru;
 struct vsp1_hsit;
 struct vsp1_lif;
 struct vsp1_lut;
@@ -35,9 +36,9 @@ struct vsp1_rwpf;
 struct vsp1_sru;
 struct vsp1_uds;
 
-#define VPS1_MAX_RPF           5
-#define VPS1_MAX_UDS           3
-#define VPS1_MAX_WPF           4
+#define VSP1_MAX_RPF           5
+#define VSP1_MAX_UDS           3
+#define VSP1_MAX_WPF           4
 
 struct vsp1_device {
        struct device *dev;
@@ -45,19 +46,19 @@ struct vsp1_device {
 
        void __iomem *mmio;
        struct clk *clock;
-       struct clk *rt_clock;
 
        struct mutex lock;
        int ref_count;
 
+       struct vsp1_bru *bru;
        struct vsp1_hsit *hsi;
        struct vsp1_hsit *hst;
        struct vsp1_lif *lif;
        struct vsp1_lut *lut;
-       struct vsp1_rwpf *rpf[VPS1_MAX_RPF];
+       struct vsp1_rwpf *rpf[VSP1_MAX_RPF];
        struct vsp1_sru *sru;
-       struct vsp1_uds *uds[VPS1_MAX_UDS];
-       struct vsp1_rwpf *wpf[VPS1_MAX_WPF];
+       struct vsp1_uds *uds[VSP1_MAX_UDS];
+       struct vsp1_rwpf *wpf[VSP1_MAX_WPF];
 
        struct list_head entities;
 
@@ -65,7 +66,7 @@ struct vsp1_device {
        struct media_device media_dev;
 };
 
-struct vsp1_device *vsp1_device_get(struct vsp1_device *vsp1);
+int vsp1_device_get(struct vsp1_device *vsp1);
 void vsp1_device_put(struct vsp1_device *vsp1);
 
 static inline u32 vsp1_read(struct vsp1_device *vsp1, u32 reg)
diff --git a/drivers/media/platform/vsp1/vsp1_bru.c b/drivers/media/platform/vsp1/vsp1_bru.c
new file mode 100644 (file)
index 0000000..a0c1984
--- /dev/null
@@ -0,0 +1,452 @@
+/*
+ * vsp1_bru.c  --  R-Car VSP1 Blend ROP Unit
+ *
+ * Copyright (C) 2013 Renesas Corporation
+ *
+ * Contact: Laurent Pinchart (laurent.pinchart@ideasonboard.com)
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ */
+
+#include <linux/device.h>
+#include <linux/gfp.h>
+
+#include <media/v4l2-subdev.h>
+
+#include "vsp1.h"
+#include "vsp1_bru.h"
+#include "vsp1_rwpf.h"
+
+#define BRU_MIN_SIZE                           4U
+#define BRU_MAX_SIZE                           8190U
+
+/* -----------------------------------------------------------------------------
+ * Device Access
+ */
+
+static inline u32 vsp1_bru_read(struct vsp1_bru *bru, u32 reg)
+{
+       return vsp1_read(bru->entity.vsp1, reg);
+}
+
+static inline void vsp1_bru_write(struct vsp1_bru *bru, u32 reg, u32 data)
+{
+       vsp1_write(bru->entity.vsp1, reg, data);
+}
+
+/* -----------------------------------------------------------------------------
+ * Controls
+ */
+
+static int bru_s_ctrl(struct v4l2_ctrl *ctrl)
+{
+       struct vsp1_bru *bru =
+               container_of(ctrl->handler, struct vsp1_bru, ctrls);
+
+       if (!vsp1_entity_is_streaming(&bru->entity))
+               return 0;
+
+       switch (ctrl->id) {
+       case V4L2_CID_BG_COLOR:
+               vsp1_bru_write(bru, VI6_BRU_VIRRPF_COL, ctrl->val |
+                              (0xff << VI6_BRU_VIRRPF_COL_A_SHIFT));
+               break;
+       }
+
+       return 0;
+}
+
+static const struct v4l2_ctrl_ops bru_ctrl_ops = {
+       .s_ctrl = bru_s_ctrl,
+};
+
+/* -----------------------------------------------------------------------------
+ * V4L2 Subdevice Core Operations
+ */
+
+static int bru_s_stream(struct v4l2_subdev *subdev, int enable)
+{
+       struct vsp1_pipeline *pipe = to_vsp1_pipeline(&subdev->entity);
+       struct vsp1_bru *bru = to_bru(subdev);
+       struct v4l2_mbus_framefmt *format;
+       unsigned int flags;
+       unsigned int i;
+       int ret;
+
+       ret = vsp1_entity_set_streaming(&bru->entity, enable);
+       if (ret < 0)
+               return ret;
+
+       if (!enable)
+               return 0;
+
+       format = &bru->entity.formats[BRU_PAD_SOURCE];
+
+       /* The hardware is extremely flexible but we have no userspace API to
+        * expose all the parameters, nor is it clear whether we would have use
+        * cases for all the supported modes. Let's just harcode the parameters
+        * to sane default values for now.
+        */
+
+       /* Disable dithering and enable color data normalization unless the
+        * format at the pipeline output is premultiplied.
+        */
+       flags = pipe->output ? pipe->output->video.format.flags : 0;
+       vsp1_bru_write(bru, VI6_BRU_INCTRL,
+                      flags & V4L2_PIX_FMT_FLAG_PREMUL_ALPHA ?
+                      0 : VI6_BRU_INCTRL_NRM);
+
+       /* Set the background position to cover the whole output image. */
+       vsp1_bru_write(bru, VI6_BRU_VIRRPF_SIZE,
+                      (format->width << VI6_BRU_VIRRPF_SIZE_HSIZE_SHIFT) |
+                      (format->height << VI6_BRU_VIRRPF_SIZE_VSIZE_SHIFT));
+       vsp1_bru_write(bru, VI6_BRU_VIRRPF_LOC, 0);
+
+       /* Route BRU input 1 as SRC input to the ROP unit and configure the ROP
+        * unit with a NOP operation to make BRU input 1 available as the
+        * Blend/ROP unit B SRC input.
+        */
+       vsp1_bru_write(bru, VI6_BRU_ROP, VI6_BRU_ROP_DSTSEL_BRUIN(1) |
+                      VI6_BRU_ROP_CROP(VI6_ROP_NOP) |
+                      VI6_BRU_ROP_AROP(VI6_ROP_NOP));
+
+       for (i = 0; i < 4; ++i) {
+               bool premultiplied = false;
+               u32 ctrl = 0;
+
+               /* Configure all Blend/ROP units corresponding to an enabled BRU
+                * input for alpha blending. Blend/ROP units corresponding to
+                * disabled BRU inputs are used in ROP NOP mode to ignore the
+                * SRC input.
+                */
+               if (bru->inputs[i].rpf) {
+                       ctrl |= VI6_BRU_CTRL_RBC;
+
+                       premultiplied = bru->inputs[i].rpf->video.format.flags
+                                     & V4L2_PIX_FMT_FLAG_PREMUL_ALPHA;
+               } else {
+                       ctrl |= VI6_BRU_CTRL_CROP(VI6_ROP_NOP)
+                            |  VI6_BRU_CTRL_AROP(VI6_ROP_NOP);
+               }
+
+               /* Select the virtual RPF as the Blend/ROP unit A DST input to
+                * serve as a background color.
+                */
+               if (i == 0)
+                       ctrl |= VI6_BRU_CTRL_DSTSEL_VRPF;
+
+               /* Route BRU inputs 0 to 3 as SRC inputs to Blend/ROP units A to
+                * D in that order. The Blend/ROP unit B SRC is hardwired to the
+                * ROP unit output, the corresponding register bits must be set
+                * to 0.
+                */
+               if (i != 1)
+                       ctrl |= VI6_BRU_CTRL_SRCSEL_BRUIN(i);
+
+               vsp1_bru_write(bru, VI6_BRU_CTRL(i), ctrl);
+
+               /* Harcode the blending formula to
+                *
+                *      DSTc = DSTc * (1 - SRCa) + SRCc * SRCa
+                *      DSTa = DSTa * (1 - SRCa) + SRCa
+                *
+                * when the SRC input isn't premultiplied, and to
+                *
+                *      DSTc = DSTc * (1 - SRCa) + SRCc
+                *      DSTa = DSTa * (1 - SRCa) + SRCa
+                *
+                * otherwise.
+                */
+               vsp1_bru_write(bru, VI6_BRU_BLD(i),
+                              VI6_BRU_BLD_CCMDX_255_SRC_A |
+                              (premultiplied ? VI6_BRU_BLD_CCMDY_COEFY :
+                                               VI6_BRU_BLD_CCMDY_SRC_A) |
+                              VI6_BRU_BLD_ACMDX_255_SRC_A |
+                              VI6_BRU_BLD_ACMDY_COEFY |
+                              (0xff << VI6_BRU_BLD_COEFY_SHIFT));
+       }
+
+       return 0;
+}
+
+/* -----------------------------------------------------------------------------
+ * V4L2 Subdevice Pad Operations
+ */
+
+/*
+ * The BRU can't perform format conversion, all sink and source formats must be
+ * identical. We pick the format on the first sink pad (pad 0) and propagate it
+ * to all other pads.
+ */
+
+static int bru_enum_mbus_code(struct v4l2_subdev *subdev,
+                             struct v4l2_subdev_fh *fh,
+                             struct v4l2_subdev_mbus_code_enum *code)
+{
+       static const unsigned int codes[] = {
+               V4L2_MBUS_FMT_ARGB8888_1X32,
+               V4L2_MBUS_FMT_AYUV8_1X32,
+       };
+       struct v4l2_mbus_framefmt *format;
+
+       if (code->pad == BRU_PAD_SINK(0)) {
+               if (code->index >= ARRAY_SIZE(codes))
+                       return -EINVAL;
+
+               code->code = codes[code->index];
+       } else {
+               if (code->index)
+                       return -EINVAL;
+
+               format = v4l2_subdev_get_try_format(fh, BRU_PAD_SINK(0));
+               code->code = format->code;
+       }
+
+       return 0;
+}
+
+static int bru_enum_frame_size(struct v4l2_subdev *subdev,
+                              struct v4l2_subdev_fh *fh,
+                              struct v4l2_subdev_frame_size_enum *fse)
+{
+       if (fse->index)
+               return -EINVAL;
+
+       if (fse->code != V4L2_MBUS_FMT_ARGB8888_1X32 &&
+           fse->code != V4L2_MBUS_FMT_AYUV8_1X32)
+               return -EINVAL;
+
+       fse->min_width = BRU_MIN_SIZE;
+       fse->max_width = BRU_MAX_SIZE;
+       fse->min_height = BRU_MIN_SIZE;
+       fse->max_height = BRU_MAX_SIZE;
+
+       return 0;
+}
+
+static struct v4l2_rect *bru_get_compose(struct vsp1_bru *bru,
+                                        struct v4l2_subdev_fh *fh,
+                                        unsigned int pad, u32 which)
+{
+       switch (which) {
+       case V4L2_SUBDEV_FORMAT_TRY:
+               return v4l2_subdev_get_try_crop(fh, pad);
+       case V4L2_SUBDEV_FORMAT_ACTIVE:
+               return &bru->inputs[pad].compose;
+       default:
+               return NULL;
+       }
+}
+
+static int bru_get_format(struct v4l2_subdev *subdev, struct v4l2_subdev_fh *fh,
+                         struct v4l2_subdev_format *fmt)
+{
+       struct vsp1_bru *bru = to_bru(subdev);
+
+       fmt->format = *vsp1_entity_get_pad_format(&bru->entity, fh, fmt->pad,
+                                                 fmt->which);
+
+       return 0;
+}
+
+static void bru_try_format(struct vsp1_bru *bru, struct v4l2_subdev_fh *fh,
+                          unsigned int pad, struct v4l2_mbus_framefmt *fmt,
+                          enum v4l2_subdev_format_whence which)
+{
+       struct v4l2_mbus_framefmt *format;
+
+       switch (pad) {
+       case BRU_PAD_SINK(0):
+               /* Default to YUV if the requested format is not supported. */
+               if (fmt->code != V4L2_MBUS_FMT_ARGB8888_1X32 &&
+                   fmt->code != V4L2_MBUS_FMT_AYUV8_1X32)
+                       fmt->code = V4L2_MBUS_FMT_AYUV8_1X32;
+               break;
+
+       default:
+               /* The BRU can't perform format conversion. */
+               format = vsp1_entity_get_pad_format(&bru->entity, fh,
+                                                   BRU_PAD_SINK(0), which);
+               fmt->code = format->code;
+               break;
+       }
+
+       fmt->width = clamp(fmt->width, BRU_MIN_SIZE, BRU_MAX_SIZE);
+       fmt->height = clamp(fmt->height, BRU_MIN_SIZE, BRU_MAX_SIZE);
+       fmt->field = V4L2_FIELD_NONE;
+       fmt->colorspace = V4L2_COLORSPACE_SRGB;
+}
+
+static int bru_set_format(struct v4l2_subdev *subdev, struct v4l2_subdev_fh *fh,
+                         struct v4l2_subdev_format *fmt)
+{
+       struct vsp1_bru *bru = to_bru(subdev);
+       struct v4l2_mbus_framefmt *format;
+
+       bru_try_format(bru, fh, fmt->pad, &fmt->format, fmt->which);
+
+       format = vsp1_entity_get_pad_format(&bru->entity, fh, fmt->pad,
+                                           fmt->which);
+       *format = fmt->format;
+
+       /* Reset the compose rectangle */
+       if (fmt->pad != BRU_PAD_SOURCE) {
+               struct v4l2_rect *compose;
+
+               compose = bru_get_compose(bru, fh, fmt->pad, fmt->which);
+               compose->left = 0;
+               compose->top = 0;
+               compose->width = format->width;
+               compose->height = format->height;
+       }
+
+       /* Propagate the format code to all pads */
+       if (fmt->pad == BRU_PAD_SINK(0)) {
+               unsigned int i;
+
+               for (i = 0; i <= BRU_PAD_SOURCE; ++i) {
+                       format = vsp1_entity_get_pad_format(&bru->entity, fh,
+                                                           i, fmt->which);
+                       format->code = fmt->format.code;
+               }
+       }
+
+       return 0;
+}
+
+static int bru_get_selection(struct v4l2_subdev *subdev,
+                            struct v4l2_subdev_fh *fh,
+                            struct v4l2_subdev_selection *sel)
+{
+       struct vsp1_bru *bru = to_bru(subdev);
+
+       if (sel->pad == BRU_PAD_SOURCE)
+               return -EINVAL;
+
+       switch (sel->target) {
+       case V4L2_SEL_TGT_COMPOSE_BOUNDS:
+               sel->r.left = 0;
+               sel->r.top = 0;
+               sel->r.width = BRU_MAX_SIZE;
+               sel->r.height = BRU_MAX_SIZE;
+               return 0;
+
+       case V4L2_SEL_TGT_COMPOSE:
+               sel->r = *bru_get_compose(bru, fh, sel->pad, sel->which);
+               return 0;
+
+       default:
+               return -EINVAL;
+       }
+}
+
+static int bru_set_selection(struct v4l2_subdev *subdev,
+                            struct v4l2_subdev_fh *fh,
+                            struct v4l2_subdev_selection *sel)
+{
+       struct vsp1_bru *bru = to_bru(subdev);
+       struct v4l2_mbus_framefmt *format;
+       struct v4l2_rect *compose;
+
+       if (sel->pad == BRU_PAD_SOURCE)
+               return -EINVAL;
+
+       if (sel->target != V4L2_SEL_TGT_COMPOSE)
+               return -EINVAL;
+
+       /* The compose rectangle top left corner must be inside the output
+        * frame.
+        */
+       format = vsp1_entity_get_pad_format(&bru->entity, fh, BRU_PAD_SOURCE,
+                                           sel->which);
+       sel->r.left = clamp_t(unsigned int, sel->r.left, 0, format->width - 1);
+       sel->r.top = clamp_t(unsigned int, sel->r.top, 0, format->height - 1);
+
+       /* Scaling isn't supported, the compose rectangle size must be identical
+        * to the sink format size.
+        */
+       format = vsp1_entity_get_pad_format(&bru->entity, fh, sel->pad,
+                                           sel->which);
+       sel->r.width = format->width;
+       sel->r.height = format->height;
+
+       compose = bru_get_compose(bru, fh, sel->pad, sel->which);
+       *compose = sel->r;
+
+       return 0;
+}
+
+/* -----------------------------------------------------------------------------
+ * V4L2 Subdevice Operations
+ */
+
+static struct v4l2_subdev_video_ops bru_video_ops = {
+       .s_stream = bru_s_stream,
+};
+
+static struct v4l2_subdev_pad_ops bru_pad_ops = {
+       .enum_mbus_code = bru_enum_mbus_code,
+       .enum_frame_size = bru_enum_frame_size,
+       .get_fmt = bru_get_format,
+       .set_fmt = bru_set_format,
+       .get_selection = bru_get_selection,
+       .set_selection = bru_set_selection,
+};
+
+static struct v4l2_subdev_ops bru_ops = {
+       .video  = &bru_video_ops,
+       .pad    = &bru_pad_ops,
+};
+
+/* -----------------------------------------------------------------------------
+ * Initialization and Cleanup
+ */
+
+struct vsp1_bru *vsp1_bru_create(struct vsp1_device *vsp1)
+{
+       struct v4l2_subdev *subdev;
+       struct vsp1_bru *bru;
+       int ret;
+
+       bru = devm_kzalloc(vsp1->dev, sizeof(*bru), GFP_KERNEL);
+       if (bru == NULL)
+               return ERR_PTR(-ENOMEM);
+
+       bru->entity.type = VSP1_ENTITY_BRU;
+
+       ret = vsp1_entity_init(vsp1, &bru->entity, 5);
+       if (ret < 0)
+               return ERR_PTR(ret);
+
+       /* Initialize the V4L2 subdev. */
+       subdev = &bru->entity.subdev;
+       v4l2_subdev_init(subdev, &bru_ops);
+
+       subdev->entity.ops = &vsp1_media_ops;
+       subdev->internal_ops = &vsp1_subdev_internal_ops;
+       snprintf(subdev->name, sizeof(subdev->name), "%s bru",
+                dev_name(vsp1->dev));
+       v4l2_set_subdevdata(subdev, bru);
+       subdev->flags |= V4L2_SUBDEV_FL_HAS_DEVNODE;
+
+       vsp1_entity_init_formats(subdev, NULL);
+
+       /* Initialize the control handler. */
+       v4l2_ctrl_handler_init(&bru->ctrls, 1);
+       v4l2_ctrl_new_std(&bru->ctrls, &bru_ctrl_ops, V4L2_CID_BG_COLOR,
+                         0, 0xffffff, 1, 0);
+
+       bru->entity.subdev.ctrl_handler = &bru->ctrls;
+
+       if (bru->ctrls.error) {
+               dev_err(vsp1->dev, "bru: failed to initialize controls\n");
+               ret = bru->ctrls.error;
+               vsp1_entity_destroy(&bru->entity);
+               return ERR_PTR(ret);
+       }
+
+       return bru;
+}
diff --git a/drivers/media/platform/vsp1/vsp1_bru.h b/drivers/media/platform/vsp1/vsp1_bru.h
new file mode 100644 (file)
index 0000000..16b1c65
--- /dev/null
@@ -0,0 +1,46 @@
+/*
+ * vsp1_bru.h  --  R-Car VSP1 Blend ROP Unit
+ *
+ * Copyright (C) 2013 Renesas Corporation
+ *
+ * Contact: Laurent Pinchart (laurent.pinchart@ideasonboard.com)
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ */
+#ifndef __VSP1_BRU_H__
+#define __VSP1_BRU_H__
+
+#include <media/media-entity.h>
+#include <media/v4l2-ctrls.h>
+#include <media/v4l2-subdev.h>
+
+#include "vsp1_entity.h"
+
+struct vsp1_device;
+struct vsp1_rwpf;
+
+#define BRU_PAD_SINK(n)                                (n)
+#define BRU_PAD_SOURCE                         4
+
+struct vsp1_bru {
+       struct vsp1_entity entity;
+
+       struct v4l2_ctrl_handler ctrls;
+
+       struct {
+               struct vsp1_rwpf *rpf;
+               struct v4l2_rect compose;
+       } inputs[4];
+};
+
+static inline struct vsp1_bru *to_bru(struct v4l2_subdev *subdev)
+{
+       return container_of(subdev, struct vsp1_bru, entity.subdev);
+}
+
+struct vsp1_bru *vsp1_bru_create(struct vsp1_device *vsp1);
+
+#endif /* __VSP1_BRU_H__ */
index 0df0a99..3e6601b 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * vsp1_drv.c  --  R-Car VSP1 Driver
  *
- * Copyright (C) 2013 Renesas Corporation
+ * Copyright (C) 2013-2014 Renesas Electronics Corporation
  *
  * Contact: Laurent Pinchart (laurent.pinchart@ideasonboard.com)
  *
 #include <linux/device.h>
 #include <linux/interrupt.h>
 #include <linux/module.h>
+#include <linux/of.h>
 #include <linux/platform_device.h>
 #include <linux/videodev2.h>
 
 #include "vsp1.h"
+#include "vsp1_bru.h"
 #include "vsp1_hsit.h"
 #include "vsp1_lif.h"
 #include "vsp1_lut.h"
@@ -155,6 +157,14 @@ static int vsp1_create_entities(struct vsp1_device *vsp1)
        }
 
        /* Instantiate all the entities. */
+       vsp1->bru = vsp1_bru_create(vsp1);
+       if (IS_ERR(vsp1->bru)) {
+               ret = PTR_ERR(vsp1->bru);
+               goto done;
+       }
+
+       list_add_tail(&vsp1->bru->entity.list_dev, &vsp1->entities);
+
        vsp1->hsi = vsp1_hsit_create(vsp1, true);
        if (IS_ERR(vsp1->hsi)) {
                ret = PTR_ERR(vsp1->hsi);
@@ -329,69 +339,38 @@ static int vsp1_device_init(struct vsp1_device *vsp1)
        return 0;
 }
 
-static int vsp1_clocks_enable(struct vsp1_device *vsp1)
-{
-       int ret;
-
-       ret = clk_prepare_enable(vsp1->clock);
-       if (ret < 0)
-               return ret;
-
-       if (IS_ERR(vsp1->rt_clock))
-               return 0;
-
-       ret = clk_prepare_enable(vsp1->rt_clock);
-       if (ret < 0) {
-               clk_disable_unprepare(vsp1->clock);
-               return ret;
-       }
-
-       return 0;
-}
-
-static void vsp1_clocks_disable(struct vsp1_device *vsp1)
-{
-       if (!IS_ERR(vsp1->rt_clock))
-               clk_disable_unprepare(vsp1->rt_clock);
-       clk_disable_unprepare(vsp1->clock);
-}
-
 /*
  * vsp1_device_get - Acquire the VSP1 device
  *
  * Increment the VSP1 reference count and initialize the device if the first
  * reference is taken.
  *
- * Return a pointer to the VSP1 device or NULL if an error occurred.
+ * Return 0 on success or a negative error code otherwise.
  */
-struct vsp1_device *vsp1_device_get(struct vsp1_device *vsp1)
+int vsp1_device_get(struct vsp1_device *vsp1)
 {
-       struct vsp1_device *__vsp1 = vsp1;
-       int ret;
+       int ret = 0;
 
        mutex_lock(&vsp1->lock);
        if (vsp1->ref_count > 0)
                goto done;
 
-       ret = vsp1_clocks_enable(vsp1);
-       if (ret < 0) {
-               __vsp1 = NULL;
+       ret = clk_prepare_enable(vsp1->clock);
+       if (ret < 0)
                goto done;
-       }
 
        ret = vsp1_device_init(vsp1);
        if (ret < 0) {
-               vsp1_clocks_disable(vsp1);
-               __vsp1 = NULL;
+               clk_disable_unprepare(vsp1->clock);
                goto done;
        }
 
 done:
-       if (__vsp1)
+       if (!ret)
                vsp1->ref_count++;
 
        mutex_unlock(&vsp1->lock);
-       return __vsp1;
+       return ret;
 }
 
 /*
@@ -405,7 +384,7 @@ void vsp1_device_put(struct vsp1_device *vsp1)
        mutex_lock(&vsp1->lock);
 
        if (--vsp1->ref_count == 0)
-               vsp1_clocks_disable(vsp1);
+               clk_disable_unprepare(vsp1->clock);
 
        mutex_unlock(&vsp1->lock);
 }
@@ -424,7 +403,7 @@ static int vsp1_pm_suspend(struct device *dev)
        if (vsp1->ref_count == 0)
                return 0;
 
-       vsp1_clocks_disable(vsp1);
+       clk_disable_unprepare(vsp1->clock);
        return 0;
 }
 
@@ -437,7 +416,7 @@ static int vsp1_pm_resume(struct device *dev)
        if (vsp1->ref_count)
                return 0;
 
-       return vsp1_clocks_enable(vsp1);
+       return clk_prepare_enable(vsp1->clock);
 }
 #endif
 
@@ -449,34 +428,59 @@ static const struct dev_pm_ops vsp1_pm_ops = {
  * Platform Driver
  */
 
-static struct vsp1_platform_data *
-vsp1_get_platform_data(struct platform_device *pdev)
+static int vsp1_validate_platform_data(struct platform_device *pdev,
+                                      struct vsp1_platform_data *pdata)
 {
-       struct vsp1_platform_data *pdata = pdev->dev.platform_data;
-
        if (pdata == NULL) {
                dev_err(&pdev->dev, "missing platform data\n");
-               return NULL;
+               return -EINVAL;
        }
 
-       if (pdata->rpf_count <= 0 || pdata->rpf_count > VPS1_MAX_RPF) {
+       if (pdata->rpf_count <= 0 || pdata->rpf_count > VSP1_MAX_RPF) {
                dev_err(&pdev->dev, "invalid number of RPF (%u)\n",
                        pdata->rpf_count);
-               return NULL;
+               return -EINVAL;
        }
 
-       if (pdata->uds_count <= 0 || pdata->uds_count > VPS1_MAX_UDS) {
+       if (pdata->uds_count <= 0 || pdata->uds_count > VSP1_MAX_UDS) {
                dev_err(&pdev->dev, "invalid number of UDS (%u)\n",
                        pdata->uds_count);
-               return NULL;
+               return -EINVAL;
        }
 
-       if (pdata->wpf_count <= 0 || pdata->wpf_count > VPS1_MAX_WPF) {
+       if (pdata->wpf_count <= 0 || pdata->wpf_count > VSP1_MAX_WPF) {
                dev_err(&pdev->dev, "invalid number of WPF (%u)\n",
                        pdata->wpf_count);
-               return NULL;
+               return -EINVAL;
        }
 
+       return 0;
+}
+
+static struct vsp1_platform_data *
+vsp1_get_platform_data(struct platform_device *pdev)
+{
+       struct device_node *np = pdev->dev.of_node;
+       struct vsp1_platform_data *pdata;
+
+       if (!IS_ENABLED(CONFIG_OF) || np == NULL)
+               return pdev->dev.platform_data;
+
+       pdata = devm_kzalloc(&pdev->dev, sizeof(*pdata), GFP_KERNEL);
+       if (pdata == NULL)
+               return NULL;
+
+       if (of_property_read_bool(np, "renesas,has-lif"))
+               pdata->features |= VSP1_HAS_LIF;
+       if (of_property_read_bool(np, "renesas,has-lut"))
+               pdata->features |= VSP1_HAS_LUT;
+       if (of_property_read_bool(np, "renesas,has-sru"))
+               pdata->features |= VSP1_HAS_SRU;
+
+       of_property_read_u32(np, "renesas,#rpf", &pdata->rpf_count);
+       of_property_read_u32(np, "renesas,#uds", &pdata->uds_count);
+       of_property_read_u32(np, "renesas,#wpf", &pdata->wpf_count);
+
        return pdata;
 }
 
@@ -499,6 +503,10 @@ static int vsp1_probe(struct platform_device *pdev)
        if (vsp1->pdata == NULL)
                return -ENODEV;
 
+       ret = vsp1_validate_platform_data(pdev, vsp1->pdata);
+       if (ret < 0)
+               return ret;
+
        /* I/O, IRQ and clock resources */
        io = platform_get_resource(pdev, IORESOURCE_MEM, 0);
        vsp1->mmio = devm_ioremap_resource(&pdev->dev, io);
@@ -511,9 +519,6 @@ static int vsp1_probe(struct platform_device *pdev)
                return PTR_ERR(vsp1->clock);
        }
 
-       /* The RT clock is optional */
-       vsp1->rt_clock = devm_clk_get(&pdev->dev, "rt");
-
        irq = platform_get_resource(pdev, IORESOURCE_IRQ, 0);
        if (!irq) {
                dev_err(&pdev->dev, "missing IRQ\n");
@@ -548,6 +553,11 @@ static int vsp1_remove(struct platform_device *pdev)
        return 0;
 }
 
+static const struct of_device_id vsp1_of_match[] = {
+       { .compatible = "renesas,vsp1" },
+       { },
+};
+
 static struct platform_driver vsp1_platform_driver = {
        .probe          = vsp1_probe,
        .remove         = vsp1_remove,
@@ -555,6 +565,7 @@ static struct platform_driver vsp1_platform_driver = {
                .owner  = THIS_MODULE,
                .name   = "vsp1",
                .pm     = &vsp1_pm_ops,
+               .of_match_table = vsp1_of_match,
        },
 };
 
index 0226e47..79af71d 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * vsp1_entity.c  --  R-Car VSP1 Base Entity
  *
- * Copyright (C) 2013 Renesas Corporation
+ * Copyright (C) 2013-2014 Renesas Electronics Corporation
  *
  * Contact: Laurent Pinchart (laurent.pinchart@ideasonboard.com)
  *
 
 #include "vsp1.h"
 #include "vsp1_entity.h"
+#include "vsp1_video.h"
+
+bool vsp1_entity_is_streaming(struct vsp1_entity *entity)
+{
+       bool streaming;
+
+       mutex_lock(&entity->lock);
+       streaming = entity->streaming;
+       mutex_unlock(&entity->lock);
+
+       return streaming;
+}
+
+int vsp1_entity_set_streaming(struct vsp1_entity *entity, bool streaming)
+{
+       int ret;
+
+       mutex_lock(&entity->lock);
+       entity->streaming = streaming;
+       mutex_unlock(&entity->lock);
+
+       if (!streaming)
+               return 0;
+
+       if (!entity->subdev.ctrl_handler)
+               return 0;
+
+       ret = v4l2_ctrl_handler_setup(entity->subdev.ctrl_handler);
+       if (ret < 0) {
+               mutex_lock(&entity->lock);
+               entity->streaming = false;
+               mutex_unlock(&entity->lock);
+       }
+
+       return ret;
+}
 
 /* -----------------------------------------------------------------------------
  * V4L2 Subdevice Operations
@@ -100,8 +136,10 @@ static int vsp1_entity_link_setup(struct media_entity *entity,
                if (source->sink)
                        return -EBUSY;
                source->sink = remote->entity;
+               source->sink_pad = remote->index;
        } else {
                source->sink = NULL;
+               source->sink_pad = 0;
        }
 
        return 0;
@@ -116,44 +154,47 @@ const struct media_entity_operations vsp1_media_ops = {
  * Initialization
  */
 
+static const struct vsp1_route vsp1_routes[] = {
+       { VSP1_ENTITY_BRU, 0, VI6_DPR_BRU_ROUTE,
+         { VI6_DPR_NODE_BRU_IN(0), VI6_DPR_NODE_BRU_IN(1),
+           VI6_DPR_NODE_BRU_IN(2), VI6_DPR_NODE_BRU_IN(3), } },
+       { VSP1_ENTITY_HSI, 0, VI6_DPR_HSI_ROUTE, { VI6_DPR_NODE_HSI, } },
+       { VSP1_ENTITY_HST, 0, VI6_DPR_HST_ROUTE, { VI6_DPR_NODE_HST, } },
+       { VSP1_ENTITY_LIF, 0, 0, { VI6_DPR_NODE_LIF, } },
+       { VSP1_ENTITY_LUT, 0, VI6_DPR_LUT_ROUTE, { VI6_DPR_NODE_LUT, } },
+       { VSP1_ENTITY_RPF, 0, VI6_DPR_RPF_ROUTE(0), { VI6_DPR_NODE_RPF(0), } },
+       { VSP1_ENTITY_RPF, 1, VI6_DPR_RPF_ROUTE(1), { VI6_DPR_NODE_RPF(1), } },
+       { VSP1_ENTITY_RPF, 2, VI6_DPR_RPF_ROUTE(2), { VI6_DPR_NODE_RPF(2), } },
+       { VSP1_ENTITY_RPF, 3, VI6_DPR_RPF_ROUTE(3), { VI6_DPR_NODE_RPF(3), } },
+       { VSP1_ENTITY_RPF, 4, VI6_DPR_RPF_ROUTE(4), { VI6_DPR_NODE_RPF(4), } },
+       { VSP1_ENTITY_SRU, 0, VI6_DPR_SRU_ROUTE, { VI6_DPR_NODE_SRU, } },
+       { VSP1_ENTITY_UDS, 0, VI6_DPR_UDS_ROUTE(0), { VI6_DPR_NODE_UDS(0), } },
+       { VSP1_ENTITY_UDS, 1, VI6_DPR_UDS_ROUTE(1), { VI6_DPR_NODE_UDS(1), } },
+       { VSP1_ENTITY_UDS, 2, VI6_DPR_UDS_ROUTE(2), { VI6_DPR_NODE_UDS(2), } },
+       { VSP1_ENTITY_WPF, 0, 0, { VI6_DPR_NODE_WPF(0), } },
+       { VSP1_ENTITY_WPF, 1, 0, { VI6_DPR_NODE_WPF(1), } },
+       { VSP1_ENTITY_WPF, 2, 0, { VI6_DPR_NODE_WPF(2), } },
+       { VSP1_ENTITY_WPF, 3, 0, { VI6_DPR_NODE_WPF(3), } },
+};
+
 int vsp1_entity_init(struct vsp1_device *vsp1, struct vsp1_entity *entity,
                     unsigned int num_pads)
 {
-       static const struct {
-               unsigned int id;
-               unsigned int reg;
-       } routes[] = {
-               { VI6_DPR_NODE_HSI, VI6_DPR_HSI_ROUTE },
-               { VI6_DPR_NODE_HST, VI6_DPR_HST_ROUTE },
-               { VI6_DPR_NODE_LIF, 0 },
-               { VI6_DPR_NODE_LUT, VI6_DPR_LUT_ROUTE },
-               { VI6_DPR_NODE_RPF(0), VI6_DPR_RPF_ROUTE(0) },
-               { VI6_DPR_NODE_RPF(1), VI6_DPR_RPF_ROUTE(1) },
-               { VI6_DPR_NODE_RPF(2), VI6_DPR_RPF_ROUTE(2) },
-               { VI6_DPR_NODE_RPF(3), VI6_DPR_RPF_ROUTE(3) },
-               { VI6_DPR_NODE_RPF(4), VI6_DPR_RPF_ROUTE(4) },
-               { VI6_DPR_NODE_SRU, VI6_DPR_SRU_ROUTE },
-               { VI6_DPR_NODE_UDS(0), VI6_DPR_UDS_ROUTE(0) },
-               { VI6_DPR_NODE_UDS(1), VI6_DPR_UDS_ROUTE(1) },
-               { VI6_DPR_NODE_UDS(2), VI6_DPR_UDS_ROUTE(2) },
-               { VI6_DPR_NODE_WPF(0), 0 },
-               { VI6_DPR_NODE_WPF(1), 0 },
-               { VI6_DPR_NODE_WPF(2), 0 },
-               { VI6_DPR_NODE_WPF(3), 0 },
-       };
-
        unsigned int i;
 
-       for (i = 0; i < ARRAY_SIZE(routes); ++i) {
-               if (routes[i].id == entity->id) {
-                       entity->route = routes[i].reg;
+       for (i = 0; i < ARRAY_SIZE(vsp1_routes); ++i) {
+               if (vsp1_routes[i].type == entity->type &&
+                   vsp1_routes[i].index == entity->index) {
+                       entity->route = &vsp1_routes[i];
                        break;
                }
        }
 
-       if (i == ARRAY_SIZE(routes))
+       if (i == ARRAY_SIZE(vsp1_routes))
                return -EINVAL;
 
+       mutex_init(&entity->lock);
+
        entity->vsp1 = vsp1;
        entity->source_pad = num_pads - 1;
 
@@ -182,7 +223,11 @@ int vsp1_entity_init(struct vsp1_device *vsp1, struct vsp1_entity *entity,
 
 void vsp1_entity_destroy(struct vsp1_entity *entity)
 {
+       if (entity->video)
+               vsp1_video_cleanup(entity->video);
        if (entity->subdev.ctrl_handler)
                v4l2_ctrl_handler_free(entity->subdev.ctrl_handler);
        media_entity_cleanup(&entity->subdev.entity);
+
+       mutex_destroy(&entity->lock);
 }
index e152798..aa20aaa 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * vsp1_entity.h  --  R-Car VSP1 Base Entity
  *
- * Copyright (C) 2013 Renesas Corporation
+ * Copyright (C) 2013-2014 Renesas Electronics Corporation
  *
  * Contact: Laurent Pinchart (laurent.pinchart@ideasonboard.com)
  *
 #define __VSP1_ENTITY_H__
 
 #include <linux/list.h>
+#include <linux/mutex.h>
 
 #include <media/v4l2-subdev.h>
 
 struct vsp1_device;
+struct vsp1_video;
 
 enum vsp1_entity_type {
+       VSP1_ENTITY_BRU,
        VSP1_ENTITY_HSI,
        VSP1_ENTITY_HST,
        VSP1_ENTITY_LIF,
@@ -30,13 +33,31 @@ enum vsp1_entity_type {
        VSP1_ENTITY_WPF,
 };
 
+/*
+ * struct vsp1_route - Entity routing configuration
+ * @type: Entity type this routing entry is associated with
+ * @index: Entity index this routing entry is associated with
+ * @reg: Output routing configuration register
+ * @inputs: Target node value for each input
+ *
+ * Each $vsp1_route entry describes routing configuration for the entity
+ * specified by the entry's @type and @index. @reg indicates the register that
+ * holds output routing configuration for the entity, and the @inputs array
+ * store the target node value for each input of the entity.
+ */
+struct vsp1_route {
+       enum vsp1_entity_type type;
+       unsigned int index;
+       unsigned int reg;
+       unsigned int inputs[4];
+};
+
 struct vsp1_entity {
        struct vsp1_device *vsp1;
 
        enum vsp1_entity_type type;
        unsigned int index;
-       unsigned int id;
-       unsigned int route;
+       const struct vsp1_route *route;
 
        struct list_head list_dev;
        struct list_head list_pipe;
@@ -45,9 +66,15 @@ struct vsp1_entity {
        unsigned int source_pad;
 
        struct media_entity *sink;
+       unsigned int sink_pad;
 
        struct v4l2_subdev subdev;
        struct v4l2_mbus_framefmt *formats;
+
+       struct vsp1_video *video;
+
+       struct mutex lock;              /* Protects the streaming field */
+       bool streaming;
 };
 
 static inline struct vsp1_entity *to_vsp1_entity(struct v4l2_subdev *subdev)
@@ -69,4 +96,7 @@ vsp1_entity_get_pad_format(struct vsp1_entity *entity,
 void vsp1_entity_init_formats(struct v4l2_subdev *subdev,
                              struct v4l2_subdev_fh *fh);
 
+bool vsp1_entity_is_streaming(struct vsp1_entity *entity);
+int vsp1_entity_set_streaming(struct vsp1_entity *entity, bool streaming);
+
 #endif /* __VSP1_ENTITY_H__ */
index 2854853..db2950a 100644 (file)
@@ -193,13 +193,10 @@ struct vsp1_hsit *vsp1_hsit_create(struct vsp1_device *vsp1, bool inverse)
 
        hsit->inverse = inverse;
 
-       if (inverse) {
+       if (inverse)
                hsit->entity.type = VSP1_ENTITY_HSI;
-               hsit->entity.id = VI6_DPR_NODE_HSI;
-       } else {
+       else
                hsit->entity.type = VSP1_ENTITY_HST;
-               hsit->entity.id = VI6_DPR_NODE_HST;
-       }
 
        ret = vsp1_entity_init(vsp1, &hsit->entity, 2);
        if (ret < 0)
index 74a32e6..d4fb23e 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * vsp1_lif.c  --  R-Car VSP1 LCD Controller Interface
  *
- * Copyright (C) 2013 Renesas Corporation
+ * Copyright (C) 2013-2014 Renesas Electronics Corporation
  *
  * Contact: Laurent Pinchart (laurent.pinchart@ideasonboard.com)
  *
@@ -215,7 +215,6 @@ struct vsp1_lif *vsp1_lif_create(struct vsp1_device *vsp1)
                return ERR_PTR(-ENOMEM);
 
        lif->entity.type = VSP1_ENTITY_LIF;
-       lif->entity.id = VI6_DPR_NODE_LIF;
 
        ret = vsp1_entity_init(vsp1, &lif->entity, 2);
        if (ret < 0)
index 89b93af..7b35879 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * vsp1_lif.h  --  R-Car VSP1 LCD Controller Interface
  *
- * Copyright (C) 2013 Renesas Corporation
+ * Copyright (C) 2013-2014 Renesas Electronics Corporation
  *
  * Contact: Laurent Pinchart (laurent.pinchart@ideasonboard.com)
  *
index 4e9dc7c..fea36eb 100644 (file)
@@ -229,7 +229,6 @@ struct vsp1_lut *vsp1_lut_create(struct vsp1_device *vsp1)
                return ERR_PTR(-ENOMEM);
 
        lut->entity.type = VSP1_ENTITY_LUT;
-       lut->entity.id = VI6_DPR_NODE_LUT;
 
        ret = vsp1_entity_init(vsp1, &lut->entity, 2);
        if (ret < 0)
index 2865080..55f163d 100644 (file)
  */
 
 #define VI6_SRU_CTRL0                  0x2200
+#define VI6_SRU_CTRL0_PARAM0_MASK      (0x1ff << 16)
 #define VI6_SRU_CTRL0_PARAM0_SHIFT     16
+#define VI6_SRU_CTRL0_PARAM1_MASK      (0x1f << 8)
 #define VI6_SRU_CTRL0_PARAM1_SHIFT     8
 #define VI6_SRU_CTRL0_MODE_UPSCALE     (4 << 4)
 #define VI6_SRU_CTRL0_PARAM2           (1 << 3)
  * BRU Control Registers
  */
 
+#define VI6_ROP_NOP                    0
+#define VI6_ROP_AND                    1
+#define VI6_ROP_AND_REV                        2
+#define VI6_ROP_COPY                   3
+#define VI6_ROP_AND_INV                        4
+#define VI6_ROP_CLEAR                  5
+#define VI6_ROP_XOR                    6
+#define VI6_ROP_OR                     7
+#define VI6_ROP_NOR                    8
+#define VI6_ROP_EQUIV                  9
+#define VI6_ROP_INVERT                 10
+#define VI6_ROP_OR_REV                 11
+#define VI6_ROP_COPY_INV               12
+#define VI6_ROP_OR_INV                 13
+#define VI6_ROP_NAND                   14
+#define VI6_ROP_SET                    15
+
 #define VI6_BRU_INCTRL                 0x2c00
+#define VI6_BRU_INCTRL_NRM             (1 << 28)
+#define VI6_BRU_INCTRL_DnON            (1 << (16 + (n)))
+#define VI6_BRU_INCTRL_DITHn_OFF       (0 << ((n) * 4))
+#define VI6_BRU_INCTRL_DITHn_18BPP     (1 << ((n) * 4))
+#define VI6_BRU_INCTRL_DITHn_16BPP     (2 << ((n) * 4))
+#define VI6_BRU_INCTRL_DITHn_15BPP     (3 << ((n) * 4))
+#define VI6_BRU_INCTRL_DITHn_12BPP     (4 << ((n) * 4))
+#define VI6_BRU_INCTRL_DITHn_8BPP      (5 << ((n) * 4))
+#define VI6_BRU_INCTRL_DITHn_MASK      (7 << ((n) * 4))
+#define VI6_BRU_INCTRL_DITHn_SHIFT     ((n) * 4)
+
 #define VI6_BRU_VIRRPF_SIZE            0x2c04
+#define VI6_BRU_VIRRPF_SIZE_HSIZE_MASK (0x1fff << 16)
+#define VI6_BRU_VIRRPF_SIZE_HSIZE_SHIFT        16
+#define VI6_BRU_VIRRPF_SIZE_VSIZE_MASK (0x1fff << 0)
+#define VI6_BRU_VIRRPF_SIZE_VSIZE_SHIFT        0
+
 #define VI6_BRU_VIRRPF_LOC             0x2c08
+#define VI6_BRU_VIRRPF_LOC_HCOORD_MASK (0x1fff << 16)
+#define VI6_BRU_VIRRPF_LOC_HCOORD_SHIFT        16
+#define VI6_BRU_VIRRPF_LOC_VCOORD_MASK (0x1fff << 0)
+#define VI6_BRU_VIRRPF_LOC_VCOORD_SHIFT        0
+
 #define VI6_BRU_VIRRPF_COL             0x2c0c
+#define VI6_BRU_VIRRPF_COL_A_MASK      (0xff << 24)
+#define VI6_BRU_VIRRPF_COL_A_SHIFT     24
+#define VI6_BRU_VIRRPF_COL_RCR_MASK    (0xff << 16)
+#define VI6_BRU_VIRRPF_COL_RCR_SHIFT   16
+#define VI6_BRU_VIRRPF_COL_GY_MASK     (0xff << 8)
+#define VI6_BRU_VIRRPF_COL_GY_SHIFT    8
+#define VI6_BRU_VIRRPF_COL_BCB_MASK    (0xff << 0)
+#define VI6_BRU_VIRRPF_COL_BCB_SHIFT   0
+
 #define VI6_BRU_CTRL(n)                        (0x2c10 + (n) * 8)
+#define VI6_BRU_CTRL_RBC               (1 << 31)
+#define VI6_BRU_CTRL_DSTSEL_BRUIN(n)   ((n) << 20)
+#define VI6_BRU_CTRL_DSTSEL_VRPF       (4 << 20)
+#define VI6_BRU_CTRL_DSTSEL_MASK       (7 << 20)
+#define VI6_BRU_CTRL_SRCSEL_BRUIN(n)   ((n) << 16)
+#define VI6_BRU_CTRL_SRCSEL_VRPF       (4 << 16)
+#define VI6_BRU_CTRL_SRCSEL_MASK       (7 << 16)
+#define VI6_BRU_CTRL_CROP(rop)         ((rop) << 4)
+#define VI6_BRU_CTRL_CROP_MASK         (0xf << 4)
+#define VI6_BRU_CTRL_AROP(rop)         ((rop) << 0)
+#define VI6_BRU_CTRL_AROP_MASK         (0xf << 0)
+
 #define VI6_BRU_BLD(n)                 (0x2c14 + (n) * 8)
+#define VI6_BRU_BLD_CBES               (1 << 31)
+#define VI6_BRU_BLD_CCMDX_DST_A                (0 << 28)
+#define VI6_BRU_BLD_CCMDX_255_DST_A    (1 << 28)
+#define VI6_BRU_BLD_CCMDX_SRC_A                (2 << 28)
+#define VI6_BRU_BLD_CCMDX_255_SRC_A    (3 << 28)
+#define VI6_BRU_BLD_CCMDX_COEFX                (4 << 28)
+#define VI6_BRU_BLD_CCMDX_MASK         (7 << 28)
+#define VI6_BRU_BLD_CCMDY_DST_A                (0 << 24)
+#define VI6_BRU_BLD_CCMDY_255_DST_A    (1 << 24)
+#define VI6_BRU_BLD_CCMDY_SRC_A                (2 << 24)
+#define VI6_BRU_BLD_CCMDY_255_SRC_A    (3 << 24)
+#define VI6_BRU_BLD_CCMDY_COEFY                (4 << 24)
+#define VI6_BRU_BLD_CCMDY_MASK         (7 << 24)
+#define VI6_BRU_BLD_CCMDY_SHIFT                24
+#define VI6_BRU_BLD_ABES               (1 << 23)
+#define VI6_BRU_BLD_ACMDX_DST_A                (0 << 20)
+#define VI6_BRU_BLD_ACMDX_255_DST_A    (1 << 20)
+#define VI6_BRU_BLD_ACMDX_SRC_A                (2 << 20)
+#define VI6_BRU_BLD_ACMDX_255_SRC_A    (3 << 20)
+#define VI6_BRU_BLD_ACMDX_COEFX                (4 << 20)
+#define VI6_BRU_BLD_ACMDX_MASK         (7 << 20)
+#define VI6_BRU_BLD_ACMDY_DST_A                (0 << 16)
+#define VI6_BRU_BLD_ACMDY_255_DST_A    (1 << 16)
+#define VI6_BRU_BLD_ACMDY_SRC_A                (2 << 16)
+#define VI6_BRU_BLD_ACMDY_255_SRC_A    (3 << 16)
+#define VI6_BRU_BLD_ACMDY_COEFY                (4 << 16)
+#define VI6_BRU_BLD_ACMDY_MASK         (7 << 16)
+#define VI6_BRU_BLD_COEFX_MASK         (0xff << 8)
+#define VI6_BRU_BLD_COEFX_SHIFT                8
+#define VI6_BRU_BLD_COEFY_MASK         (0xff << 0)
+#define VI6_BRU_BLD_COEFY_SHIFT                0
+
 #define VI6_BRU_ROP                    0x2c30
+#define VI6_BRU_ROP_DSTSEL_BRUIN(n)    ((n) << 20)
+#define VI6_BRU_ROP_DSTSEL_VRPF                (4 << 20)
+#define VI6_BRU_ROP_DSTSEL_MASK                (7 << 20)
+#define VI6_BRU_ROP_CROP(rop)          ((rop) << 4)
+#define VI6_BRU_ROP_CROP_MASK          (0xf << 4)
+#define VI6_BRU_ROP_AROP(rop)          ((rop) << 0)
+#define VI6_BRU_ROP_AROP_MASK          (0xf << 0)
 
 /* -----------------------------------------------------------------------------
  * HGO Control Registers
index bce2be5..d14d26b 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * vsp1_rpf.c  --  R-Car VSP1 Read Pixel Formatter
  *
- * Copyright (C) 2013 Renesas Corporation
+ * Copyright (C) 2013-2014 Renesas Electronics Corporation
  *
  * Contact: Laurent Pinchart (laurent.pinchart@ideasonboard.com)
  *
@@ -39,6 +39,36 @@ static inline void vsp1_rpf_write(struct vsp1_rwpf *rpf, u32 reg, u32 data)
 }
 
 /* -----------------------------------------------------------------------------
+ * Controls
+ */
+
+static int rpf_s_ctrl(struct v4l2_ctrl *ctrl)
+{
+       struct vsp1_rwpf *rpf =
+               container_of(ctrl->handler, struct vsp1_rwpf, ctrls);
+       struct vsp1_pipeline *pipe;
+
+       if (!vsp1_entity_is_streaming(&rpf->entity))
+               return 0;
+
+       switch (ctrl->id) {
+       case V4L2_CID_ALPHA_COMPONENT:
+               vsp1_rpf_write(rpf, VI6_RPF_VRTCOL_SET,
+                              ctrl->val << VI6_RPF_VRTCOL_SET_LAYA_SHIFT);
+
+               pipe = to_vsp1_pipeline(&rpf->entity.subdev.entity);
+               vsp1_pipeline_propagate_alpha(pipe, &rpf->entity, ctrl->val);
+               break;
+       }
+
+       return 0;
+}
+
+static const struct v4l2_ctrl_ops rpf_ctrl_ops = {
+       .s_ctrl = rpf_s_ctrl,
+};
+
+/* -----------------------------------------------------------------------------
  * V4L2 Subdevice Core Operations
  */
 
@@ -50,6 +80,11 @@ static int rpf_s_stream(struct v4l2_subdev *subdev, int enable)
        const struct v4l2_rect *crop = &rpf->crop;
        u32 pstride;
        u32 infmt;
+       int ret;
+
+       ret = vsp1_entity_set_streaming(&rpf->entity, enable);
+       if (ret < 0)
+               return ret;
 
        if (!enable)
                return 0;
@@ -96,15 +131,18 @@ static int rpf_s_stream(struct v4l2_subdev *subdev, int enable)
        vsp1_rpf_write(rpf, VI6_RPF_INFMT, infmt);
        vsp1_rpf_write(rpf, VI6_RPF_DSWAP, fmtinfo->swap);
 
-       /* Output location. Composing isn't supported yet. */
-       vsp1_rpf_write(rpf, VI6_RPF_LOC, 0);
+       /* Output location */
+       vsp1_rpf_write(rpf, VI6_RPF_LOC,
+                      (rpf->location.left << VI6_RPF_LOC_HCOORD_SHIFT) |
+                      (rpf->location.top << VI6_RPF_LOC_VCOORD_SHIFT));
 
-       /* Disable alpha, mask and color key. Set the alpha channel to a fixed
-        * value of 255.
+       /* Use the alpha channel (extended to 8 bits) when available or an
+        * alpha value set through the V4L2_CID_ALPHA_COMPONENT control
+        * otherwise. Disable color keying.
         */
-       vsp1_rpf_write(rpf, VI6_RPF_ALPH_SEL, VI6_RPF_ALPH_SEL_ASEL_FIXED);
-       vsp1_rpf_write(rpf, VI6_RPF_VRTCOL_SET,
-                      255 << VI6_RPF_VRTCOL_SET_LAYA_SHIFT);
+       vsp1_rpf_write(rpf, VI6_RPF_ALPH_SEL, VI6_RPF_ALPH_SEL_AEXT_EXT |
+                      (fmtinfo->alpha ? VI6_RPF_ALPH_SEL_ASEL_PACKED
+                                      : VI6_RPF_ALPH_SEL_ASEL_FIXED));
        vsp1_rpf_write(rpf, VI6_RPF_MSK_CTRL, 0);
        vsp1_rpf_write(rpf, VI6_RPF_CKEY_CTRL, 0);
 
@@ -176,7 +214,6 @@ struct vsp1_rwpf *vsp1_rpf_create(struct vsp1_device *vsp1, unsigned int index)
 
        rpf->entity.type = VSP1_ENTITY_RPF;
        rpf->entity.index = index;
-       rpf->entity.id = VI6_DPR_NODE_RPF(index);
 
        ret = vsp1_entity_init(vsp1, &rpf->entity, 2);
        if (ret < 0)
@@ -195,6 +232,20 @@ struct vsp1_rwpf *vsp1_rpf_create(struct vsp1_device *vsp1, unsigned int index)
 
        vsp1_entity_init_formats(subdev, NULL);
 
+       /* Initialize the control handler. */
+       v4l2_ctrl_handler_init(&rpf->ctrls, 1);
+       v4l2_ctrl_new_std(&rpf->ctrls, &rpf_ctrl_ops, V4L2_CID_ALPHA_COMPONENT,
+                         0, 255, 1, 255);
+
+       rpf->entity.subdev.ctrl_handler = &rpf->ctrls;
+
+       if (rpf->ctrls.error) {
+               dev_err(vsp1->dev, "rpf%u: failed to initialize controls\n",
+                       index);
+               ret = rpf->ctrls.error;
+               goto error;
+       }
+
        /* Initialize the video device. */
        video = &rpf->video;
 
@@ -204,7 +255,9 @@ struct vsp1_rwpf *vsp1_rpf_create(struct vsp1_device *vsp1, unsigned int index)
 
        ret = vsp1_video_init(video, &rpf->entity);
        if (ret < 0)
-               goto error_video;
+               goto error;
+
+       rpf->entity.video = video;
 
        /* Connect the video device to the RPF. */
        ret = media_entity_create_link(&rpf->video.video.entity, 0,
@@ -213,13 +266,11 @@ struct vsp1_rwpf *vsp1_rpf_create(struct vsp1_device *vsp1, unsigned int index)
                                       MEDIA_LNK_FL_ENABLED |
                                       MEDIA_LNK_FL_IMMUTABLE);
        if (ret < 0)
-               goto error_link;
+               goto error;
 
        return rpf;
 
-error_link:
-       vsp1_video_cleanup(video);
-error_video:
-       media_entity_cleanup(&rpf->entity.subdev.entity);
+error:
+       vsp1_entity_destroy(&rpf->entity);
        return ERR_PTR(ret);
 }
index 782f770..ec3dab6 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * vsp1_rwpf.c  --  R-Car VSP1 Read and Write Pixel Formatters
  *
- * Copyright (C) 2013 Renesas Corporation
+ * Copyright (C) 2013-2014 Renesas Electronics Corporation
  *
  * Contact: Laurent Pinchart (laurent.pinchart@ideasonboard.com)
  *
index 6cbdb54..28dd9e7 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * vsp1_rwpf.h  --  R-Car VSP1 Read and Write Pixel Formatters
  *
- * Copyright (C) 2013 Renesas Corporation
+ * Copyright (C) 2013-2014 Renesas Electronics Corporation
  *
  * Contact: Laurent Pinchart (laurent.pinchart@ideasonboard.com)
  *
@@ -14,6 +14,7 @@
 #define __VSP1_RWPF_H__
 
 #include <media/media-entity.h>
+#include <media/v4l2-ctrls.h>
 #include <media/v4l2-subdev.h>
 
 #include "vsp1.h"
 struct vsp1_rwpf {
        struct vsp1_entity entity;
        struct vsp1_video video;
+       struct v4l2_ctrl_handler ctrls;
 
        unsigned int max_width;
        unsigned int max_height;
 
+       struct {
+               unsigned int left;
+               unsigned int top;
+       } location;
        struct v4l2_rect crop;
 
        unsigned int offsets[2];
index 7ab1a0b..b7d3c8b 100644 (file)
@@ -42,38 +42,6 @@ static inline void vsp1_sru_write(struct vsp1_sru *sru, u32 reg, u32 data)
 
 #define V4L2_CID_VSP1_SRU_INTENSITY            (V4L2_CID_USER_BASE + 1)
 
-static int sru_s_ctrl(struct v4l2_ctrl *ctrl)
-{
-       struct vsp1_sru *sru =
-               container_of(ctrl->handler, struct vsp1_sru, ctrls);
-
-       switch (ctrl->id) {
-       case V4L2_CID_VSP1_SRU_INTENSITY:
-               sru->intensity = ctrl->val;
-               break;
-       }
-
-       return 0;
-}
-
-static const struct v4l2_ctrl_ops sru_ctrl_ops = {
-       .s_ctrl = sru_s_ctrl,
-};
-
-static const struct v4l2_ctrl_config sru_intensity_control = {
-       .ops = &sru_ctrl_ops,
-       .id = V4L2_CID_VSP1_SRU_INTENSITY,
-       .name = "Intensity",
-       .type = V4L2_CTRL_TYPE_INTEGER,
-       .min = 1,
-       .max = 6,
-       .step = 1,
-};
-
-/* -----------------------------------------------------------------------------
- * V4L2 Subdevice Core Operations
- */
-
 struct vsp1_sru_param {
        u32 ctrl0;
        u32 ctrl2;
@@ -110,22 +78,66 @@ static const struct vsp1_sru_param vsp1_sru_params[] = {
        },
 };
 
+static int sru_s_ctrl(struct v4l2_ctrl *ctrl)
+{
+       struct vsp1_sru *sru =
+               container_of(ctrl->handler, struct vsp1_sru, ctrls);
+       const struct vsp1_sru_param *param;
+       u32 value;
+
+       switch (ctrl->id) {
+       case V4L2_CID_VSP1_SRU_INTENSITY:
+               param = &vsp1_sru_params[ctrl->val - 1];
+
+               value = vsp1_sru_read(sru, VI6_SRU_CTRL0);
+               value &= ~(VI6_SRU_CTRL0_PARAM0_MASK |
+                          VI6_SRU_CTRL0_PARAM1_MASK);
+               value |= param->ctrl0;
+               vsp1_sru_write(sru, VI6_SRU_CTRL0, value);
+
+               vsp1_sru_write(sru, VI6_SRU_CTRL2, param->ctrl2);
+               break;
+       }
+
+       return 0;
+}
+
+static const struct v4l2_ctrl_ops sru_ctrl_ops = {
+       .s_ctrl = sru_s_ctrl,
+};
+
+static const struct v4l2_ctrl_config sru_intensity_control = {
+       .ops = &sru_ctrl_ops,
+       .id = V4L2_CID_VSP1_SRU_INTENSITY,
+       .name = "Intensity",
+       .type = V4L2_CTRL_TYPE_INTEGER,
+       .min = 1,
+       .max = 6,
+       .def = 1,
+       .step = 1,
+};
+
+/* -----------------------------------------------------------------------------
+ * V4L2 Subdevice Core Operations
+ */
+
 static int sru_s_stream(struct v4l2_subdev *subdev, int enable)
 {
        struct vsp1_sru *sru = to_sru(subdev);
-       const struct vsp1_sru_param *param;
        struct v4l2_mbus_framefmt *input;
        struct v4l2_mbus_framefmt *output;
-       bool upscale;
        u32 ctrl0;
+       int ret;
+
+       ret = vsp1_entity_set_streaming(&sru->entity, enable);
+       if (ret < 0)
+               return ret;
 
        if (!enable)
                return 0;
 
        input = &sru->entity.formats[SRU_PAD_SINK];
        output = &sru->entity.formats[SRU_PAD_SOURCE];
-       upscale = input->width != output->width;
-       param = &vsp1_sru_params[sru->intensity];
 
        if (input->code == V4L2_MBUS_FMT_ARGB8888_1X32)
                ctrl0 = VI6_SRU_CTRL0_PARAM2 | VI6_SRU_CTRL0_PARAM3
@@ -133,10 +145,18 @@ static int sru_s_stream(struct v4l2_subdev *subdev, int enable)
        else
                ctrl0 = VI6_SRU_CTRL0_PARAM3;
 
-       vsp1_sru_write(sru, VI6_SRU_CTRL0, param->ctrl0 | ctrl0 |
-                      (upscale ? VI6_SRU_CTRL0_MODE_UPSCALE : 0));
+       if (input->width != output->width)
+               ctrl0 |= VI6_SRU_CTRL0_MODE_UPSCALE;
+
+       /* Take the control handler lock to ensure that the CTRL0 value won't be
+        * changed behind our back by a set control operation.
+        */
+       mutex_lock(sru->ctrls.lock);
+       ctrl0 |= vsp1_sru_read(sru, VI6_SRU_CTRL0)
+              & (VI6_SRU_CTRL0_PARAM0_MASK | VI6_SRU_CTRL0_PARAM1_MASK);
+       mutex_unlock(sru->ctrls.lock);
+
        vsp1_sru_write(sru, VI6_SRU_CTRL1, VI6_SRU_CTRL1_PARAM5);
-       vsp1_sru_write(sru, VI6_SRU_CTRL2, param->ctrl2);
 
        return 0;
 }
@@ -327,7 +347,6 @@ struct vsp1_sru *vsp1_sru_create(struct vsp1_device *vsp1)
                return ERR_PTR(-ENOMEM);
 
        sru->entity.type = VSP1_ENTITY_SRU;
-       sru->entity.id = VI6_DPR_NODE_SRU;
 
        ret = vsp1_entity_init(vsp1, &sru->entity, 2);
        if (ret < 0)
@@ -349,8 +368,15 @@ struct vsp1_sru *vsp1_sru_create(struct vsp1_device *vsp1)
        /* Initialize the control handler. */
        v4l2_ctrl_handler_init(&sru->ctrls, 1);
        v4l2_ctrl_new_custom(&sru->ctrls, &sru_intensity_control, NULL);
-       v4l2_ctrl_handler_setup(&sru->ctrls);
+
        sru->entity.subdev.ctrl_handler = &sru->ctrls;
 
+       if (sru->ctrls.error) {
+               dev_err(vsp1->dev, "sru: failed to initialize controls\n");
+               ret = sru->ctrls.error;
+               vsp1_entity_destroy(&sru->entity);
+               return ERR_PTR(ret);
+       }
+
        return sru;
 }
index 381870b..b6768bf 100644 (file)
@@ -28,7 +28,6 @@ struct vsp1_sru {
        struct vsp1_entity entity;
 
        struct v4l2_ctrl_handler ctrls;
-       unsigned int intensity;
 };
 
 static inline struct vsp1_sru *to_sru(struct v4l2_subdev *subdev)
index 0e50b37..de92ef4 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * vsp1_uds.c  --  R-Car VSP1 Up and Down Scaler
  *
- * Copyright (C) 2013 Renesas Corporation
+ * Copyright (C) 2013-2014 Renesas Electronics Corporation
  *
  * Contact: Laurent Pinchart (laurent.pinchart@ideasonboard.com)
  *
@@ -45,6 +45,11 @@ static inline void vsp1_uds_write(struct vsp1_uds *uds, u32 reg, u32 data)
  * Scaling Computation
  */
 
+void vsp1_uds_set_alpha(struct vsp1_uds *uds, unsigned int alpha)
+{
+       vsp1_uds_write(uds, VI6_UDS_ALPVAL, alpha << VI6_UDS_ALPVAL_VAL0_SHIFT);
+}
+
 /*
  * uds_output_size - Return the output size for an input size and scaling ratio
  * @input: input size in pixels
@@ -105,50 +110,56 @@ static unsigned int uds_compute_ratio(unsigned int input, unsigned int output)
        return (input - 1) * 4096 / (output - 1);
 }
 
-static void uds_compute_ratios(struct vsp1_uds *uds)
-{
-       struct v4l2_mbus_framefmt *input = &uds->entity.formats[UDS_PAD_SINK];
-       struct v4l2_mbus_framefmt *output =
-               &uds->entity.formats[UDS_PAD_SOURCE];
-
-       uds->hscale = uds_compute_ratio(input->width, output->width);
-       uds->vscale = uds_compute_ratio(input->height, output->height);
-
-       dev_dbg(uds->entity.vsp1->dev, "hscale %u vscale %u\n",
-               uds->hscale, uds->vscale);
-}
-
 /* -----------------------------------------------------------------------------
  * V4L2 Subdevice Core Operations
  */
 
 static int uds_s_stream(struct v4l2_subdev *subdev, int enable)
 {
-       const struct v4l2_mbus_framefmt *format;
        struct vsp1_uds *uds = to_uds(subdev);
+       const struct v4l2_mbus_framefmt *output;
+       const struct v4l2_mbus_framefmt *input;
+       unsigned int hscale;
+       unsigned int vscale;
+       bool multitap;
 
        if (!enable)
                return 0;
 
-       /* Enable multi-tap scaling. */
-       vsp1_uds_write(uds, VI6_UDS_CTRL, VI6_UDS_CTRL_BC);
+       input = &uds->entity.formats[UDS_PAD_SINK];
+       output = &uds->entity.formats[UDS_PAD_SOURCE];
+
+       hscale = uds_compute_ratio(input->width, output->width);
+       vscale = uds_compute_ratio(input->height, output->height);
+
+       dev_dbg(uds->entity.vsp1->dev, "hscale %u vscale %u\n", hscale, vscale);
+
+       /* Multi-tap scaling can't be enabled along with alpha scaling when
+        * scaling down with a factor lower than or equal to 1/2 in either
+        * direction.
+        */
+       if (uds->scale_alpha && (hscale >= 8192 || vscale >= 8192))
+               multitap = false;
+       else
+               multitap = true;
+
+       vsp1_uds_write(uds, VI6_UDS_CTRL,
+                      (uds->scale_alpha ? VI6_UDS_CTRL_AON : 0) |
+                      (multitap ? VI6_UDS_CTRL_BC : 0));
 
        vsp1_uds_write(uds, VI6_UDS_PASS_BWIDTH,
-                      (uds_passband_width(uds->hscale)
+                      (uds_passband_width(hscale)
                                << VI6_UDS_PASS_BWIDTH_H_SHIFT) |
-                      (uds_passband_width(uds->vscale)
+                      (uds_passband_width(vscale)
                                << VI6_UDS_PASS_BWIDTH_V_SHIFT));
 
-
        /* Set the scaling ratios and the output size. */
-       format = &uds->entity.formats[UDS_PAD_SOURCE];
-
        vsp1_uds_write(uds, VI6_UDS_SCALE,
-                      (uds->hscale << VI6_UDS_SCALE_HFRAC_SHIFT) |
-                      (uds->vscale << VI6_UDS_SCALE_VFRAC_SHIFT));
+                      (hscale << VI6_UDS_SCALE_HFRAC_SHIFT) |
+                      (vscale << VI6_UDS_SCALE_VFRAC_SHIFT));
        vsp1_uds_write(uds, VI6_UDS_CLIP_SIZE,
-                      (format->width << VI6_UDS_CLIP_SIZE_HSIZE_SHIFT) |
-                      (format->height << VI6_UDS_CLIP_SIZE_VSIZE_SHIFT));
+                      (output->width << VI6_UDS_CLIP_SIZE_HSIZE_SHIFT) |
+                      (output->height << VI6_UDS_CLIP_SIZE_VSIZE_SHIFT));
 
        return 0;
 }
@@ -281,9 +292,6 @@ static int uds_set_format(struct v4l2_subdev *subdev, struct v4l2_subdev_fh *fh,
                uds_try_format(uds, fh, UDS_PAD_SOURCE, format, fmt->which);
        }
 
-       if (fmt->which == V4L2_SUBDEV_FORMAT_ACTIVE)
-               uds_compute_ratios(uds);
-
        return 0;
 }
 
@@ -323,7 +331,6 @@ struct vsp1_uds *vsp1_uds_create(struct vsp1_device *vsp1, unsigned int index)
 
        uds->entity.type = VSP1_ENTITY_UDS;
        uds->entity.index = index;
-       uds->entity.id = VI6_DPR_NODE_UDS(index);
 
        ret = vsp1_entity_init(vsp1, &uds->entity, 2);
        if (ret < 0)
index 972a285..031ac0d 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * vsp1_uds.h  --  R-Car VSP1 Up and Down Scaler
  *
- * Copyright (C) 2013 Renesas Corporation
+ * Copyright (C) 2013-2014 Renesas Electronics Corporation
  *
  * Contact: Laurent Pinchart (laurent.pinchart@ideasonboard.com)
  *
@@ -25,9 +25,7 @@ struct vsp1_device;
 
 struct vsp1_uds {
        struct vsp1_entity entity;
-
-       unsigned int hscale;
-       unsigned int vscale;
+       bool scale_alpha;
 };
 
 static inline struct vsp1_uds *to_uds(struct v4l2_subdev *subdev)
@@ -37,4 +35,6 @@ static inline struct vsp1_uds *to_uds(struct v4l2_subdev *subdev)
 
 struct vsp1_uds *vsp1_uds_create(struct vsp1_device *vsp1, unsigned int index);
 
+void vsp1_uds_set_alpha(struct vsp1_uds *uds, unsigned int alpha);
+
 #endif /* __VSP1_UDS_H__ */
index 7245cca..9750a61 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * vsp1_video.c  --  R-Car VSP1 Video Node
  *
- * Copyright (C) 2013 Renesas Corporation
+ * Copyright (C) 2013-2014 Renesas Electronics Corporation
  *
  * Contact: Laurent Pinchart (laurent.pinchart@ideasonboard.com)
  *
 #include <media/videobuf2-dma-contig.h>
 
 #include "vsp1.h"
+#include "vsp1_bru.h"
 #include "vsp1_entity.h"
 #include "vsp1_rwpf.h"
+#include "vsp1_uds.h"
 #include "vsp1_video.h"
 
 #define VSP1_VIDEO_DEF_FORMAT          V4L2_PIX_FMT_YUYV
@@ -49,70 +51,85 @@ static const struct vsp1_format_info vsp1_video_formats[] = {
        { V4L2_PIX_FMT_RGB332, V4L2_MBUS_FMT_ARGB8888_1X32,
          VI6_FMT_RGB_332, VI6_RPF_DSWAP_P_LLS | VI6_RPF_DSWAP_P_LWS |
          VI6_RPF_DSWAP_P_WDS | VI6_RPF_DSWAP_P_BTS,
-         1, { 8, 0, 0 }, false, false, 1, 1 },
-       { V4L2_PIX_FMT_RGB444, V4L2_MBUS_FMT_ARGB8888_1X32,
+         1, { 8, 0, 0 }, false, false, 1, 1, false },
+       { V4L2_PIX_FMT_ARGB444, V4L2_MBUS_FMT_ARGB8888_1X32,
+         VI6_FMT_ARGB_4444, VI6_RPF_DSWAP_P_LLS | VI6_RPF_DSWAP_P_LWS |
+         VI6_RPF_DSWAP_P_WDS,
+         1, { 16, 0, 0 }, false, false, 1, 1, true },
+       { V4L2_PIX_FMT_XRGB444, V4L2_MBUS_FMT_ARGB8888_1X32,
          VI6_FMT_XRGB_4444, VI6_RPF_DSWAP_P_LLS | VI6_RPF_DSWAP_P_LWS |
          VI6_RPF_DSWAP_P_WDS,
-         1, { 16, 0, 0 }, false, false, 1, 1 },
-       { V4L2_PIX_FMT_RGB555, V4L2_MBUS_FMT_ARGB8888_1X32,
+         1, { 16, 0, 0 }, false, false, 1, 1, true },
+       { V4L2_PIX_FMT_ARGB555, V4L2_MBUS_FMT_ARGB8888_1X32,
+         VI6_FMT_ARGB_1555, VI6_RPF_DSWAP_P_LLS | VI6_RPF_DSWAP_P_LWS |
+         VI6_RPF_DSWAP_P_WDS,
+         1, { 16, 0, 0 }, false, false, 1, 1, true },
+       { V4L2_PIX_FMT_XRGB555, V4L2_MBUS_FMT_ARGB8888_1X32,
          VI6_FMT_XRGB_1555, VI6_RPF_DSWAP_P_LLS | VI6_RPF_DSWAP_P_LWS |
          VI6_RPF_DSWAP_P_WDS,
-         1, { 16, 0, 0 }, false, false, 1, 1 },
+         1, { 16, 0, 0 }, false, false, 1, 1, false },
        { V4L2_PIX_FMT_RGB565, V4L2_MBUS_FMT_ARGB8888_1X32,
          VI6_FMT_RGB_565, VI6_RPF_DSWAP_P_LLS | VI6_RPF_DSWAP_P_LWS |
          VI6_RPF_DSWAP_P_WDS,
-         1, { 16, 0, 0 }, false, false, 1, 1 },
+         1, { 16, 0, 0 }, false, false, 1, 1, false },
        { V4L2_PIX_FMT_BGR24, V4L2_MBUS_FMT_ARGB8888_1X32,
          VI6_FMT_BGR_888, VI6_RPF_DSWAP_P_LLS | VI6_RPF_DSWAP_P_LWS |
          VI6_RPF_DSWAP_P_WDS | VI6_RPF_DSWAP_P_BTS,
-         1, { 24, 0, 0 }, false, false, 1, 1 },
+         1, { 24, 0, 0 }, false, false, 1, 1, false },
        { V4L2_PIX_FMT_RGB24, V4L2_MBUS_FMT_ARGB8888_1X32,
          VI6_FMT_RGB_888, VI6_RPF_DSWAP_P_LLS | VI6_RPF_DSWAP_P_LWS |
          VI6_RPF_DSWAP_P_WDS | VI6_RPF_DSWAP_P_BTS,
-         1, { 24, 0, 0 }, false, false, 1, 1 },
-       { V4L2_PIX_FMT_BGR32, V4L2_MBUS_FMT_ARGB8888_1X32,
+         1, { 24, 0, 0 }, false, false, 1, 1, false },
+       { V4L2_PIX_FMT_ABGR32, V4L2_MBUS_FMT_ARGB8888_1X32,
+         VI6_FMT_ARGB_8888, VI6_RPF_DSWAP_P_LLS | VI6_RPF_DSWAP_P_LWS,
+         1, { 32, 0, 0 }, false, false, 1, 1, true },
+       { V4L2_PIX_FMT_XBGR32, V4L2_MBUS_FMT_ARGB8888_1X32,
          VI6_FMT_ARGB_8888, VI6_RPF_DSWAP_P_LLS | VI6_RPF_DSWAP_P_LWS,
-         1, { 32, 0, 0 }, false, false, 1, 1 },
-       { V4L2_PIX_FMT_RGB32, V4L2_MBUS_FMT_ARGB8888_1X32,
+         1, { 32, 0, 0 }, false, false, 1, 1, false },
+       { V4L2_PIX_FMT_ARGB32, V4L2_MBUS_FMT_ARGB8888_1X32,
+         VI6_FMT_ARGB_8888, VI6_RPF_DSWAP_P_LLS | VI6_RPF_DSWAP_P_LWS |
+         VI6_RPF_DSWAP_P_WDS | VI6_RPF_DSWAP_P_BTS,
+         1, { 32, 0, 0 }, false, false, 1, 1, true },
+       { V4L2_PIX_FMT_XRGB32, V4L2_MBUS_FMT_ARGB8888_1X32,
          VI6_FMT_ARGB_8888, VI6_RPF_DSWAP_P_LLS | VI6_RPF_DSWAP_P_LWS |
          VI6_RPF_DSWAP_P_WDS | VI6_RPF_DSWAP_P_BTS,
-         1, { 32, 0, 0 }, false, false, 1, 1 },
+         1, { 32, 0, 0 }, false, false, 1, 1, false },
        { V4L2_PIX_FMT_UYVY, V4L2_MBUS_FMT_AYUV8_1X32,
          VI6_FMT_YUYV_422, VI6_RPF_DSWAP_P_LLS | VI6_RPF_DSWAP_P_LWS |
          VI6_RPF_DSWAP_P_WDS | VI6_RPF_DSWAP_P_BTS,
-         1, { 16, 0, 0 }, false, false, 2, 1 },
+         1, { 16, 0, 0 }, false, false, 2, 1, false },
        { V4L2_PIX_FMT_VYUY, V4L2_MBUS_FMT_AYUV8_1X32,
          VI6_FMT_YUYV_422, VI6_RPF_DSWAP_P_LLS | VI6_RPF_DSWAP_P_LWS |
          VI6_RPF_DSWAP_P_WDS | VI6_RPF_DSWAP_P_BTS,
-         1, { 16, 0, 0 }, false, true, 2, 1 },
+         1, { 16, 0, 0 }, false, true, 2, 1, false },
        { V4L2_PIX_FMT_YUYV, V4L2_MBUS_FMT_AYUV8_1X32,
          VI6_FMT_YUYV_422, VI6_RPF_DSWAP_P_LLS | VI6_RPF_DSWAP_P_LWS |
          VI6_RPF_DSWAP_P_WDS | VI6_RPF_DSWAP_P_BTS,
-         1, { 16, 0, 0 }, true, false, 2, 1 },
+         1, { 16, 0, 0 }, true, false, 2, 1, false },
        { V4L2_PIX_FMT_YVYU, V4L2_MBUS_FMT_AYUV8_1X32,
          VI6_FMT_YUYV_422, VI6_RPF_DSWAP_P_LLS | VI6_RPF_DSWAP_P_LWS |
          VI6_RPF_DSWAP_P_WDS | VI6_RPF_DSWAP_P_BTS,
-         1, { 16, 0, 0 }, true, true, 2, 1 },
+         1, { 16, 0, 0 }, true, true, 2, 1, false },
        { V4L2_PIX_FMT_NV12M, V4L2_MBUS_FMT_AYUV8_1X32,
          VI6_FMT_Y_UV_420, VI6_RPF_DSWAP_P_LLS | VI6_RPF_DSWAP_P_LWS |
          VI6_RPF_DSWAP_P_WDS | VI6_RPF_DSWAP_P_BTS,
-         2, { 8, 16, 0 }, false, false, 2, 2 },
+         2, { 8, 16, 0 }, false, false, 2, 2, false },
        { V4L2_PIX_FMT_NV21M, V4L2_MBUS_FMT_AYUV8_1X32,
          VI6_FMT_Y_UV_420, VI6_RPF_DSWAP_P_LLS | VI6_RPF_DSWAP_P_LWS |
          VI6_RPF_DSWAP_P_WDS | VI6_RPF_DSWAP_P_BTS,
-         2, { 8, 16, 0 }, false, true, 2, 2 },
+         2, { 8, 16, 0 }, false, true, 2, 2, false },
        { V4L2_PIX_FMT_NV16M, V4L2_MBUS_FMT_AYUV8_1X32,
          VI6_FMT_Y_UV_422, VI6_RPF_DSWAP_P_LLS | VI6_RPF_DSWAP_P_LWS |
          VI6_RPF_DSWAP_P_WDS | VI6_RPF_DSWAP_P_BTS,
-         2, { 8, 16, 0 }, false, false, 2, 1 },
+         2, { 8, 16, 0 }, false, false, 2, 1, false },
        { V4L2_PIX_FMT_NV61M, V4L2_MBUS_FMT_AYUV8_1X32,
          VI6_FMT_Y_UV_422, VI6_RPF_DSWAP_P_LLS | VI6_RPF_DSWAP_P_LWS |
          VI6_RPF_DSWAP_P_WDS | VI6_RPF_DSWAP_P_BTS,
-         2, { 8, 16, 0 }, false, true, 2, 1 },
+         2, { 8, 16, 0 }, false, true, 2, 1, false },
        { V4L2_PIX_FMT_YUV420M, V4L2_MBUS_FMT_AYUV8_1X32,
          VI6_FMT_Y_U_V_420, VI6_RPF_DSWAP_P_LLS | VI6_RPF_DSWAP_P_LWS |
          VI6_RPF_DSWAP_P_WDS | VI6_RPF_DSWAP_P_BTS,
-         3, { 8, 8, 8 }, false, false, 2, 2 },
+         3, { 8, 8, 8 }, false, false, 2, 2, false },
 };
 
 /*
@@ -180,11 +197,29 @@ static int __vsp1_video_try_format(struct vsp1_video *video,
                                   struct v4l2_pix_format_mplane *pix,
                                   const struct vsp1_format_info **fmtinfo)
 {
+       static const u32 xrgb_formats[][2] = {
+               { V4L2_PIX_FMT_RGB444, V4L2_PIX_FMT_XRGB444 },
+               { V4L2_PIX_FMT_RGB555, V4L2_PIX_FMT_XRGB555 },
+               { V4L2_PIX_FMT_BGR32, V4L2_PIX_FMT_XBGR32 },
+               { V4L2_PIX_FMT_RGB32, V4L2_PIX_FMT_XRGB32 },
+       };
+
        const struct vsp1_format_info *info;
        unsigned int width = pix->width;
        unsigned int height = pix->height;
        unsigned int i;
 
+       /* Backward compatibility: replace deprecated RGB formats by their XRGB
+        * equivalent. This selects the format older userspace applications want
+        * while still exposing the new format.
+        */
+       for (i = 0; i < ARRAY_SIZE(xrgb_formats); ++i) {
+               if (xrgb_formats[i][0] == pix->pixelformat) {
+                       pix->pixelformat = xrgb_formats[i][1];
+                       break;
+               }
+       }
+
        /* Retrieve format information and select the default format if the
         * requested format isn't supported.
         */
@@ -272,13 +307,17 @@ vsp1_video_format_adjust(struct vsp1_video *video,
  * Pipeline Management
  */
 
-static int vsp1_pipeline_validate_branch(struct vsp1_rwpf *input,
+static int vsp1_pipeline_validate_branch(struct vsp1_pipeline *pipe,
+                                        struct vsp1_rwpf *input,
                                         struct vsp1_rwpf *output)
 {
        struct vsp1_entity *entity;
        unsigned int entities = 0;
        struct media_pad *pad;
-       bool uds_found = false;
+       bool bru_found = false;
+
+       input->location.left = 0;
+       input->location.top = 0;
 
        pad = media_entity_remote_pad(&input->entity.pads[RWPF_PAD_SOURCE]);
 
@@ -292,6 +331,22 @@ static int vsp1_pipeline_validate_branch(struct vsp1_rwpf *input,
 
                entity = to_vsp1_entity(media_entity_to_v4l2_subdev(pad->entity));
 
+               /* A BRU is present in the pipeline, store the compose rectangle
+                * location in the input RPF for use when configuring the RPF.
+                */
+               if (entity->type == VSP1_ENTITY_BRU) {
+                       struct vsp1_bru *bru = to_bru(&entity->subdev);
+                       struct v4l2_rect *rect =
+                               &bru->inputs[pad->index].compose;
+
+                       bru->inputs[pad->index].rpf = input;
+
+                       input->location.left = rect->left;
+                       input->location.top = rect->top;
+
+                       bru_found = true;
+               }
+
                /* We've reached the WPF, we're done. */
                if (entity->type == VSP1_ENTITY_WPF)
                        break;
@@ -304,9 +359,12 @@ static int vsp1_pipeline_validate_branch(struct vsp1_rwpf *input,
 
                /* UDS can't be chained. */
                if (entity->type == VSP1_ENTITY_UDS) {
-                       if (uds_found)
+                       if (pipe->uds)
                                return -EPIPE;
-                       uds_found = true;
+
+                       pipe->uds = entity;
+                       pipe->uds_input = bru_found ? pipe->bru
+                                       : &input->entity;
                }
 
                /* Follow the source link. The link setup operations ensure
@@ -325,6 +383,27 @@ static int vsp1_pipeline_validate_branch(struct vsp1_rwpf *input,
        return 0;
 }
 
+static void __vsp1_pipeline_cleanup(struct vsp1_pipeline *pipe)
+{
+       if (pipe->bru) {
+               struct vsp1_bru *bru = to_bru(&pipe->bru->subdev);
+               unsigned int i;
+
+               for (i = 0; i < ARRAY_SIZE(bru->inputs); ++i)
+                       bru->inputs[i].rpf = NULL;
+       }
+
+       INIT_LIST_HEAD(&pipe->entities);
+       pipe->state = VSP1_PIPELINE_STOPPED;
+       pipe->buffers_ready = 0;
+       pipe->num_video = 0;
+       pipe->num_inputs = 0;
+       pipe->output = NULL;
+       pipe->bru = NULL;
+       pipe->lif = NULL;
+       pipe->uds = NULL;
+}
+
 static int vsp1_pipeline_validate(struct vsp1_pipeline *pipe,
                                  struct vsp1_video *video)
 {
@@ -363,6 +442,8 @@ static int vsp1_pipeline_validate(struct vsp1_pipeline *pipe,
                        rwpf->video.pipe_index = 0;
                } else if (e->type == VSP1_ENTITY_LIF) {
                        pipe->lif = e;
+               } else if (e->type == VSP1_ENTITY_BRU) {
+                       pipe->bru = e;
                }
        }
 
@@ -378,7 +459,7 @@ static int vsp1_pipeline_validate(struct vsp1_pipeline *pipe,
         * contains no loop and that all branches end at the output WPF.
         */
        for (i = 0; i < pipe->num_inputs; ++i) {
-               ret = vsp1_pipeline_validate_branch(pipe->inputs[i],
+               ret = vsp1_pipeline_validate_branch(pipe, pipe->inputs[i],
                                                    pipe->output);
                if (ret < 0)
                        goto error;
@@ -387,12 +468,7 @@ static int vsp1_pipeline_validate(struct vsp1_pipeline *pipe,
        return 0;
 
 error:
-       INIT_LIST_HEAD(&pipe->entities);
-       pipe->buffers_ready = 0;
-       pipe->num_video = 0;
-       pipe->num_inputs = 0;
-       pipe->output = NULL;
-       pipe->lif = NULL;
+       __vsp1_pipeline_cleanup(pipe);
        return ret;
 }
 
@@ -423,15 +499,8 @@ static void vsp1_pipeline_cleanup(struct vsp1_pipeline *pipe)
        mutex_lock(&pipe->lock);
 
        /* If we're the last user clean up the pipeline. */
-       if (--pipe->use_count == 0) {
-               INIT_LIST_HEAD(&pipe->entities);
-               pipe->state = VSP1_PIPELINE_STOPPED;
-               pipe->buffers_ready = 0;
-               pipe->num_video = 0;
-               pipe->num_inputs = 0;
-               pipe->output = NULL;
-               pipe->lif = NULL;
-       }
+       if (--pipe->use_count == 0)
+               __vsp1_pipeline_cleanup(pipe);
 
        mutex_unlock(&pipe->lock);
 }
@@ -452,7 +521,8 @@ static int vsp1_pipeline_stop(struct vsp1_pipeline *pipe)
        int ret;
 
        spin_lock_irqsave(&pipe->irqlock, flags);
-       pipe->state = VSP1_PIPELINE_STOPPING;
+       if (pipe->state == VSP1_PIPELINE_RUNNING)
+               pipe->state = VSP1_PIPELINE_STOPPING;
        spin_unlock_irqrestore(&pipe->irqlock, flags);
 
        ret = wait_event_timeout(pipe->wq, pipe->state == VSP1_PIPELINE_STOPPED,
@@ -460,8 +530,8 @@ static int vsp1_pipeline_stop(struct vsp1_pipeline *pipe)
        ret = ret == 0 ? -ETIMEDOUT : 0;
 
        list_for_each_entry(entity, &pipe->entities, list_pipe) {
-               if (entity->route)
-                       vsp1_write(entity->vsp1, entity->route,
+               if (entity->route && entity->route->reg)
+                       vsp1_write(entity->vsp1, entity->route->reg,
                                   VI6_DPR_NODE_UNUSED);
 
                v4l2_subdev_call(&entity->subdev, video, s_stream, 0);
@@ -557,6 +627,7 @@ static void vsp1_video_frame_end(struct vsp1_pipeline *pipe,
 
 void vsp1_pipeline_frame_end(struct vsp1_pipeline *pipe)
 {
+       enum vsp1_pipeline_state state;
        unsigned long flags;
        unsigned int i;
 
@@ -572,11 +643,13 @@ void vsp1_pipeline_frame_end(struct vsp1_pipeline *pipe)
 
        spin_lock_irqsave(&pipe->irqlock, flags);
 
+       state = pipe->state;
+       pipe->state = VSP1_PIPELINE_STOPPED;
+
        /* If a stop has been requested, mark the pipeline as stopped and
         * return.
         */
-       if (pipe->state == VSP1_PIPELINE_STOPPING) {
-               pipe->state = VSP1_PIPELINE_STOPPED;
+       if (state == VSP1_PIPELINE_STOPPING) {
                wake_up(&pipe->wq);
                goto done;
        }
@@ -589,6 +662,47 @@ done:
        spin_unlock_irqrestore(&pipe->irqlock, flags);
 }
 
+/*
+ * Propagate the alpha value through the pipeline.
+ *
+ * As the UDS has restricted scaling capabilities when the alpha component needs
+ * to be scaled, we disable alpha scaling when the UDS input has a fixed alpha
+ * value. The UDS then outputs a fixed alpha value which needs to be programmed
+ * from the input RPF alpha.
+ */
+void vsp1_pipeline_propagate_alpha(struct vsp1_pipeline *pipe,
+                                  struct vsp1_entity *input,
+                                  unsigned int alpha)
+{
+       struct vsp1_entity *entity;
+       struct media_pad *pad;
+
+       pad = media_entity_remote_pad(&input->pads[RWPF_PAD_SOURCE]);
+
+       while (pad) {
+               if (media_entity_type(pad->entity) != MEDIA_ENT_T_V4L2_SUBDEV)
+                       break;
+
+               entity = to_vsp1_entity(media_entity_to_v4l2_subdev(pad->entity));
+
+               /* The BRU background color has a fixed alpha value set to 255,
+                * the output alpha value is thus always equal to 255.
+                */
+               if (entity->type == VSP1_ENTITY_BRU)
+                       alpha = 255;
+
+               if (entity->type == VSP1_ENTITY_UDS) {
+                       struct vsp1_uds *uds = to_uds(&entity->subdev);
+
+                       vsp1_uds_set_alpha(uds, alpha);
+                       break;
+               }
+
+               pad = &entity->pads[entity->source_pad];
+               pad = media_entity_remote_pad(pad);
+       }
+}
+
 /* -----------------------------------------------------------------------------
  * videobuf2 Queue Operations
  */
@@ -678,11 +792,12 @@ static void vsp1_entity_route_setup(struct vsp1_entity *source)
 {
        struct vsp1_entity *sink;
 
-       if (source->route == 0)
+       if (source->route->reg == 0)
                return;
 
        sink = container_of(source->sink, struct vsp1_entity, subdev.entity);
-       vsp1_write(source->vsp1, source->route, sink->id);
+       vsp1_write(source->vsp1, source->route->reg,
+                  sink->route->inputs[source->sink_pad]);
 }
 
 static int vsp1_video_start_streaming(struct vb2_queue *vq, unsigned int count)
@@ -695,6 +810,25 @@ static int vsp1_video_start_streaming(struct vb2_queue *vq, unsigned int count)
 
        mutex_lock(&pipe->lock);
        if (pipe->stream_count == pipe->num_video - 1) {
+               if (pipe->uds) {
+                       struct vsp1_uds *uds = to_uds(&pipe->uds->subdev);
+
+                       /* If a BRU is present in the pipeline before the UDS,
+                        * the alpha component doesn't need to be scaled as the
+                        * BRU output alpha value is fixed to 255. Otherwise we
+                        * need to scale the alpha component only when available
+                        * at the input RPF.
+                        */
+                       if (pipe->uds_input->type == VSP1_ENTITY_BRU) {
+                               uds->scale_alpha = false;
+                       } else {
+                               struct vsp1_rwpf *rpf =
+                                       to_rwpf(&pipe->uds_input->subdev);
+
+                               uds->scale_alpha = rpf->video.fmtinfo->alpha;
+                       }
+               }
+
                list_for_each_entry(entity, &pipe->entities, list_pipe) {
                        vsp1_entity_route_setup(entity);
 
@@ -722,6 +856,7 @@ static int vsp1_video_stop_streaming(struct vb2_queue *vq)
 {
        struct vsp1_video *video = vb2_get_drv_priv(vq);
        struct vsp1_pipeline *pipe = to_vsp1_pipeline(&video->video.entity);
+       struct vsp1_video_buffer *buffer;
        unsigned long flags;
        int ret;
 
@@ -739,6 +874,8 @@ static int vsp1_video_stop_streaming(struct vb2_queue *vq)
 
        /* Remove all buffers from the IRQ queue. */
        spin_lock_irqsave(&video->irqlock, flags);
+       list_for_each_entry(buffer, &video->irqqueue, queue)
+               vb2_buffer_done(&buffer->buf, VB2_BUF_STATE_ERROR);
        INIT_LIST_HEAD(&video->irqqueue);
        spin_unlock_irqrestore(&video->irqlock, flags);
 
@@ -930,8 +1067,8 @@ static int vsp1_video_open(struct file *file)
 
        file->private_data = vfh;
 
-       if (!vsp1_device_get(video->vsp1)) {
-               ret = -EBUSY;
+       ret = vsp1_device_get(video->vsp1);
+       if (ret < 0) {
                v4l2_fh_del(vfh);
                kfree(vfh);
        }
index 47b7a8a..fd2851a 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * vsp1_video.h  --  R-Car VSP1 Video Node
  *
- * Copyright (C) 2013 Renesas Corporation
+ * Copyright (C) 2013-2014 Renesas Electronics Corporation
  *
  * Contact: Laurent Pinchart (laurent.pinchart@ideasonboard.com)
  *
@@ -33,6 +33,7 @@ struct vsp1_video;
  * @swap_uv: the U and V components are swapped (V comes before U)
  * @hsub: horizontal subsampling factor
  * @vsub: vertical subsampling factor
+ * @alpha: has an alpha channel
  */
 struct vsp1_format_info {
        u32 fourcc;
@@ -45,6 +46,7 @@ struct vsp1_format_info {
        bool swap_uv;
        unsigned int hsub;
        unsigned int vsub;
+       bool alpha;
 };
 
 enum vsp1_pipeline_state {
@@ -73,9 +75,12 @@ struct vsp1_pipeline {
 
        unsigned int num_video;
        unsigned int num_inputs;
-       struct vsp1_rwpf *inputs[VPS1_MAX_RPF];
+       struct vsp1_rwpf *inputs[VSP1_MAX_RPF];
        struct vsp1_rwpf *output;
+       struct vsp1_entity *bru;
        struct vsp1_entity *lif;
+       struct vsp1_entity *uds;
+       struct vsp1_entity *uds_input;
 
        struct list_head entities;
 };
@@ -140,4 +145,8 @@ void vsp1_video_cleanup(struct vsp1_video *video);
 
 void vsp1_pipeline_frame_end(struct vsp1_pipeline *pipe);
 
+void vsp1_pipeline_propagate_alpha(struct vsp1_pipeline *pipe,
+                                  struct vsp1_entity *input,
+                                  unsigned int alpha);
+
 #endif /* __VSP1_VIDEO_H__ */
index 7baed81..6e05776 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * vsp1_wpf.c  --  R-Car VSP1 Write Pixel Formatter
  *
- * Copyright (C) 2013 Renesas Corporation
+ * Copyright (C) 2013-2014 Renesas Electronics Corporation
  *
  * Contact: Laurent Pinchart (laurent.pinchart@ideasonboard.com)
  *
@@ -39,32 +39,74 @@ static inline void vsp1_wpf_write(struct vsp1_rwpf *wpf, u32 reg, u32 data)
 }
 
 /* -----------------------------------------------------------------------------
+ * Controls
+ */
+
+static int wpf_s_ctrl(struct v4l2_ctrl *ctrl)
+{
+       struct vsp1_rwpf *wpf =
+               container_of(ctrl->handler, struct vsp1_rwpf, ctrls);
+       u32 value;
+
+       if (!vsp1_entity_is_streaming(&wpf->entity))
+               return 0;
+
+       switch (ctrl->id) {
+       case V4L2_CID_ALPHA_COMPONENT:
+               value = vsp1_wpf_read(wpf, VI6_WPF_OUTFMT);
+               value &= ~VI6_WPF_OUTFMT_PDV_MASK;
+               value |= ctrl->val << VI6_WPF_OUTFMT_PDV_SHIFT;
+               vsp1_wpf_write(wpf, VI6_WPF_OUTFMT, value);
+               break;
+       }
+
+       return 0;
+}
+
+static const struct v4l2_ctrl_ops wpf_ctrl_ops = {
+       .s_ctrl = wpf_s_ctrl,
+};
+
+/* -----------------------------------------------------------------------------
  * V4L2 Subdevice Core Operations
  */
 
 static int wpf_s_stream(struct v4l2_subdev *subdev, int enable)
 {
+       struct vsp1_pipeline *pipe = to_vsp1_pipeline(&subdev->entity);
        struct vsp1_rwpf *wpf = to_rwpf(subdev);
-       struct vsp1_pipeline *pipe =
-               to_vsp1_pipeline(&wpf->entity.subdev.entity);
        struct vsp1_device *vsp1 = wpf->entity.vsp1;
        const struct v4l2_rect *crop = &wpf->crop;
        unsigned int i;
        u32 srcrpf = 0;
        u32 outfmt = 0;
+       int ret;
+
+       ret = vsp1_entity_set_streaming(&wpf->entity, enable);
+       if (ret < 0)
+               return ret;
 
        if (!enable) {
                vsp1_write(vsp1, VI6_WPF_IRQ_ENB(wpf->entity.index), 0);
+               vsp1_wpf_write(wpf, VI6_WPF_SRCRPF, 0);
                return 0;
        }
 
-       /* Sources */
+       /* Sources. If the pipeline has a single input configure it as the
+        * master layer. Otherwise configure all inputs as sub-layers and
+        * select the virtual RPF as the master layer.
+        */
        for (i = 0; i < pipe->num_inputs; ++i) {
                struct vsp1_rwpf *input = pipe->inputs[i];
 
-               srcrpf |= VI6_WPF_SRCRPF_RPF_ACT_MST(input->entity.index);
+               srcrpf |= pipe->num_inputs == 1
+                       ? VI6_WPF_SRCRPF_RPF_ACT_MST(input->entity.index)
+                       : VI6_WPF_SRCRPF_RPF_ACT_SUB(input->entity.index);
        }
 
+       if (pipe->num_inputs > 1)
+               srcrpf |= VI6_WPF_SRCRPF_VIRACT_MST;
+
        vsp1_wpf_write(wpf, VI6_WPF_SRCRPF, srcrpf);
 
        /* Destination stride. */
@@ -91,6 +133,8 @@ static int wpf_s_stream(struct v4l2_subdev *subdev, int enable)
 
                outfmt = fmtinfo->hwfmt << VI6_WPF_OUTFMT_WRFMT_SHIFT;
 
+               if (fmtinfo->alpha)
+                       outfmt |= VI6_WPF_OUTFMT_PXA;
                if (fmtinfo->swap_yc)
                        outfmt |= VI6_WPF_OUTFMT_SPYCS;
                if (fmtinfo->swap_uv)
@@ -103,7 +147,13 @@ static int wpf_s_stream(struct v4l2_subdev *subdev, int enable)
            wpf->entity.formats[RWPF_PAD_SOURCE].code)
                outfmt |= VI6_WPF_OUTFMT_CSC;
 
+       /* Take the control handler lock to ensure that the PDV value won't be
+        * changed behind our back by a set control operation.
+        */
+       mutex_lock(wpf->ctrls.lock);
+       outfmt |= vsp1_wpf_read(wpf, VI6_WPF_OUTFMT) & VI6_WPF_OUTFMT_PDV_MASK;
        vsp1_wpf_write(wpf, VI6_WPF_OUTFMT, outfmt);
+       mutex_unlock(wpf->ctrls.lock);
 
        vsp1_write(vsp1, VI6_DPR_WPF_FPORCH(wpf->entity.index),
                   VI6_DPR_WPF_FPORCH_FP_WPFN);
@@ -181,7 +231,6 @@ struct vsp1_rwpf *vsp1_wpf_create(struct vsp1_device *vsp1, unsigned int index)
 
        wpf->entity.type = VSP1_ENTITY_WPF;
        wpf->entity.index = index;
-       wpf->entity.id = VI6_DPR_NODE_WPF(index);
 
        ret = vsp1_entity_init(vsp1, &wpf->entity, 2);
        if (ret < 0)
@@ -200,6 +249,20 @@ struct vsp1_rwpf *vsp1_wpf_create(struct vsp1_device *vsp1, unsigned int index)
 
        vsp1_entity_init_formats(subdev, NULL);
 
+       /* Initialize the control handler. */
+       v4l2_ctrl_handler_init(&wpf->ctrls, 1);
+       v4l2_ctrl_new_std(&wpf->ctrls, &wpf_ctrl_ops, V4L2_CID_ALPHA_COMPONENT,
+                         0, 255, 1, 255);
+
+       wpf->entity.subdev.ctrl_handler = &wpf->ctrls;
+
+       if (wpf->ctrls.error) {
+               dev_err(vsp1->dev, "wpf%u: failed to initialize controls\n",
+                       index);
+               ret = wpf->ctrls.error;
+               goto error;
+       }
+
        /* Initialize the video device. */
        video = &wpf->video;
 
@@ -209,7 +272,9 @@ struct vsp1_rwpf *vsp1_wpf_create(struct vsp1_device *vsp1, unsigned int index)
 
        ret = vsp1_video_init(video, &wpf->entity);
        if (ret < 0)
-               goto error_video;
+               goto error;
+
+       wpf->entity.video = video;
 
        /* Connect the video device to the WPF. All connections are immutable
         * except for the WPF0 source link if a LIF is present.
@@ -222,15 +287,13 @@ struct vsp1_rwpf *vsp1_wpf_create(struct vsp1_device *vsp1, unsigned int index)
                                       RWPF_PAD_SOURCE,
                                       &wpf->video.video.entity, 0, flags);
        if (ret < 0)
-               goto error_link;
+               goto error;
 
        wpf->entity.sink = &wpf->video.video.entity;
 
        return wpf;
 
-error_link:
-       vsp1_video_cleanup(video);
-error_video:
-       media_entity_cleanup(&wpf->entity.subdev.entity);
+error:
+       vsp1_entity_destroy(&wpf->entity);
        return ERR_PTR(ret);
 }
index 2f63029..78a2e34 100644 (file)
@@ -1563,7 +1563,6 @@ static int vidioc_g_fmt_vid_cap(struct file *file, void *priv,
        f->fmt.pix.width = dev->ts1.width;
        f->fmt.pix.height = dev->ts1.height;
        f->fmt.pix.field = V4L2_FIELD_INTERLACED;
-       f->fmt.pix.priv = 0;
        dprintk(1, "VIDIOC_G_FMT: w: %d, h: %d\n",
                dev->ts1.width, dev->ts1.height);
        dprintk(3, "exit vidioc_g_fmt_vid_cap()\n");
@@ -1582,7 +1581,6 @@ static int vidioc_try_fmt_vid_cap(struct file *file, void *priv,
        f->fmt.pix.sizeimage = mpeglines * mpeglinesize;
        f->fmt.pix.field = V4L2_FIELD_INTERLACED;
        f->fmt.pix.colorspace = V4L2_COLORSPACE_SMPTE170M;
-       f->fmt.pix.priv = 0;
        dprintk(1, "VIDIOC_TRY_FMT: w: %d, h: %d\n",
                dev->ts1.width, dev->ts1.height);
        dprintk(3, "exit vidioc_try_fmt_vid_cap()\n");
index 9906261..71f1083 100644 (file)
@@ -886,7 +886,6 @@ static int vidioc_g_fmt_vid_cap(struct file *file, void *priv,
        f->fmt.pix.colorspace = V4L2_COLORSPACE_SMPTE170M;
 
        f->fmt.pix.field = V4L2_FIELD_INTERLACED;
-       f->fmt.pix.priv = 0;
 
        return 0;
 }
@@ -931,7 +930,6 @@ static int vidioc_try_fmt_vid_cap(struct file *file, void *priv,
        f->fmt.pix.sizeimage = f->fmt.pix.bytesperline * height;
        f->fmt.pix.colorspace = V4L2_COLORSPACE_SMPTE170M;
        f->fmt.pix.field = V4L2_FIELD_INTERLACED;
-       f->fmt.pix.priv = 0;
 
        return 0;
 }
index f3a7ace..1b3d7bf 100644 (file)
@@ -1102,8 +1102,8 @@ static int vidioc_g_fmt_vid_cap(struct file *file, void *priv,
        struct gspca_dev *gspca_dev = video_drvdata(file);
 
        fmt->fmt.pix = gspca_dev->pixfmt;
-       /* some drivers use priv internally, zero it before giving it to
-          userspace */
+       /* some drivers use priv internally, zero it before giving it back to
+          the core */
        fmt->fmt.pix.priv = 0;
        return 0;
 }
@@ -1139,8 +1139,8 @@ static int try_fmt_vid_cap(struct gspca_dev *gspca_dev,
                fmt->fmt.pix.height = h;
                gspca_dev->sd_desc->try_fmt(gspca_dev, fmt);
        }
-       /* some drivers use priv internally, zero it before giving it to
-          userspace */
+       /* some drivers use priv internally, zero it before giving it back to
+          the core */
        fmt->fmt.pix.priv = 0;
        return mode;                    /* used when s_fmt */
 }
index 6bce01a..caeae8f 100644 (file)
@@ -1022,7 +1022,6 @@ static int vidioc_g_fmt_vid_cap(struct file *file, void *_fh,
        f->fmt.pix.pixelformat  = V4L2_PIX_FMT_MPEG;
        f->fmt.pix.sizeimage    = dev->bulk_in_size;
        f->fmt.pix.bytesperline = 0;
-       f->fmt.pix.priv         = 0;
        if (f->fmt.pix.width == 720) {
                /* SDTV formats */
                f->fmt.pix.colorspace = V4L2_COLORSPACE_SMPTE170M;
index be77482..adfa832 100644 (file)
@@ -923,7 +923,6 @@ static int stk_vidioc_g_fmt_vid_cap(struct file *filp,
                pix_format->bytesperline = 2 * pix_format->width;
        pix_format->sizeimage = pix_format->bytesperline
                                * pix_format->height;
-       pix_format->priv = 0;
        return 0;
 }
 
@@ -967,7 +966,6 @@ static int stk_try_fmt_vid_cap(struct file *filp,
                fmtd->fmt.pix.bytesperline = 2 * fmtd->fmt.pix.width;
        fmtd->fmt.pix.sizeimage = fmtd->fmt.pix.bytesperline
                * fmtd->fmt.pix.height;
-       fmtd->fmt.pix.priv = 0;
        return 0;
 }
 
index 8df668d..8cd7f02 100644 (file)
@@ -1321,7 +1321,6 @@ static void init_video_context(struct running_context *context)
                                .bytesperline   = 720 * 2,
                                .sizeimage      = 720 * 576 * 2,
                                .colorspace     = V4L2_COLORSPACE_SMPTE170M,
-                               .priv           = 0
                        };
 }
 
index cc1aa14..97ad689 100644 (file)
@@ -918,7 +918,6 @@ static int vidioc_g_fmt_vid_cap(struct file *file, void *priv,
                (f->fmt.pix.width * fh->fmt->depth) >> 3;
        f->fmt.pix.sizeimage =
                f->fmt.pix.height * f->fmt.pix.bytesperline;
-       f->fmt.pix.priv = 0;
 
        return 0;
 }
@@ -959,7 +958,6 @@ static int vidioc_try_fmt_vid_cap(struct file *file, void *priv,
        f->fmt.pix.width &= ~0x01;
 
        f->fmt.pix.field = field;
-       f->fmt.pix.priv = 0;
 
        f->fmt.pix.bytesperline =
                (f->fmt.pix.width * fmt->depth) >> 3;
index 74d56df..0f63954 100644 (file)
@@ -806,7 +806,6 @@ static int zr364xx_vidioc_try_fmt_vid_cap(struct file *file, void *priv,
        f->fmt.pix.bytesperline = f->fmt.pix.width * 2;
        f->fmt.pix.sizeimage = f->fmt.pix.height * f->fmt.pix.bytesperline;
        f->fmt.pix.colorspace = V4L2_COLORSPACE_JPEG;
-       f->fmt.pix.priv = 0;
        DBG("%s: V4L2_PIX_FMT_%s (%d) ok!\n", __func__,
            decode_fourcc(f->fmt.pix.pixelformat, pixelformat_name),
            f->fmt.pix.field);
@@ -829,7 +828,6 @@ static int zr364xx_vidioc_g_fmt_vid_cap(struct file *file, void *priv,
        f->fmt.pix.bytesperline = f->fmt.pix.width * 2;
        f->fmt.pix.sizeimage = f->fmt.pix.height * f->fmt.pix.bytesperline;
        f->fmt.pix.colorspace = V4L2_COLORSPACE_JPEG;
-       f->fmt.pix.priv = 0;
        return 0;
 }
 
@@ -866,7 +864,6 @@ static int zr364xx_vidioc_s_fmt_vid_cap(struct file *file, void *priv,
        f->fmt.pix.bytesperline = f->fmt.pix.width * 2;
        f->fmt.pix.sizeimage = f->fmt.pix.height * f->fmt.pix.bytesperline;
        f->fmt.pix.colorspace = V4L2_COLORSPACE_JPEG;
-       f->fmt.pix.priv = 0;
        cam->vb_vidq.field = f->fmt.pix.field;
 
        if (f->fmt.pix.width == 160 && f->fmt.pix.height == 120)
index fca336b..d0d6530 100644 (file)
@@ -540,7 +540,16 @@ struct v4l2_framebuffer32 {
        __u32                   capability;
        __u32                   flags;
        compat_caddr_t          base;
-       struct v4l2_pix_format  fmt;
+       struct {
+               __u32           width;
+               __u32           height;
+               __u32           pixelformat;
+               __u32           field;
+               __u32           bytesperline;
+               __u32           sizeimage;
+               __u32           colorspace;
+               __u32           priv;
+       } fmt;
 };
 
 static int get_v4l2_framebuffer32(struct v4l2_framebuffer *kp, struct v4l2_framebuffer32 __user *up)
@@ -550,10 +559,10 @@ static int get_v4l2_framebuffer32(struct v4l2_framebuffer *kp, struct v4l2_frame
        if (!access_ok(VERIFY_READ, up, sizeof(struct v4l2_framebuffer32)) ||
                get_user(tmp, &up->base) ||
                get_user(kp->capability, &up->capability) ||
-               get_user(kp->flags, &up->flags))
+               get_user(kp->flags, &up->flags) ||
+               copy_from_user(&kp->fmt, &up->fmt, sizeof(up->fmt)))
                        return -EFAULT;
        kp->base = compat_ptr(tmp);
-       get_v4l2_pix_format(&kp->fmt, &up->fmt);
        return 0;
 }
 
@@ -564,9 +573,9 @@ static int put_v4l2_framebuffer32(struct v4l2_framebuffer *kp, struct v4l2_frame
        if (!access_ok(VERIFY_WRITE, up, sizeof(struct v4l2_framebuffer32)) ||
                put_user(tmp, &up->base) ||
                put_user(kp->capability, &up->capability) ||
-               put_user(kp->flags, &up->flags))
+               put_user(kp->flags, &up->flags) ||
+               copy_to_user(&up->fmt, &kp->fmt, sizeof(up->fmt)))
                        return -EFAULT;
-       put_v4l2_pix_format(&kp->fmt, &up->fmt);
        return 0;
 }
 
index 707aef7..9692009 100644 (file)
@@ -254,7 +254,8 @@ static void v4l_print_format(const void *arg, bool write_only)
                pix = &p->fmt.pix;
                pr_cont(", width=%u, height=%u, "
                        "pixelformat=%c%c%c%c, field=%s, "
-                       "bytesperline=%u, sizeimage=%u, colorspace=%d\n",
+                       "bytesperline=%u, sizeimage=%u, colorspace=%d, "
+                       "flags %u\n",
                        pix->width, pix->height,
                        (pix->pixelformat & 0xff),
                        (pix->pixelformat >>  8) & 0xff,
@@ -262,7 +263,7 @@ static void v4l_print_format(const void *arg, bool write_only)
                        (pix->pixelformat >> 24) & 0xff,
                        prt_names(pix->field, v4l2_field_names),
                        pix->bytesperline, pix->sizeimage,
-                       pix->colorspace);
+                       pix->colorspace, pix->flags);
                break;
        case V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE:
        case V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE:
@@ -936,13 +937,48 @@ static int check_fmt(struct file *file, enum v4l2_buf_type type)
        return -EINVAL;
 }
 
+static void v4l_sanitize_format(struct v4l2_format *fmt)
+{
+       unsigned int offset;
+
+       /*
+        * The v4l2_pix_format structure has been extended with fields that were
+        * not previously required to be set to zero by applications. The priv
+        * field, when set to a magic value, indicates the the extended fields
+        * are valid. Otherwise they will contain undefined values. To simplify
+        * the API towards drivers zero the extended fields and set the priv
+        * field to the magic value when the extended pixel format structure
+        * isn't used by applications.
+        */
+
+       if (fmt->type != V4L2_BUF_TYPE_VIDEO_CAPTURE &&
+           fmt->type != V4L2_BUF_TYPE_VIDEO_OUTPUT)
+               return;
+
+       if (fmt->fmt.pix.priv == V4L2_PIX_FMT_PRIV_MAGIC)
+               return;
+
+       fmt->fmt.pix.priv = V4L2_PIX_FMT_PRIV_MAGIC;
+
+       offset = offsetof(struct v4l2_pix_format, priv)
+              + sizeof(fmt->fmt.pix.priv);
+       memset(((void *)&fmt->fmt.pix) + offset, 0,
+              sizeof(fmt->fmt.pix) - offset);
+}
+
 static int v4l_querycap(const struct v4l2_ioctl_ops *ops,
                                struct file *file, void *fh, void *arg)
 {
        struct v4l2_capability *cap = (struct v4l2_capability *)arg;
+       int ret;
 
        cap->version = LINUX_VERSION_CODE;
-       return ops->vidioc_querycap(file, fh, cap);
+
+       ret = ops->vidioc_querycap(file, fh, cap);
+
+       cap->capabilities |= V4L2_CAP_EXT_PIX_FORMAT;
+
+       return ret;
 }
 
 static int v4l_s_input(const struct v4l2_ioctl_ops *ops,
@@ -1061,12 +1097,17 @@ static int v4l_g_fmt(const struct v4l2_ioctl_ops *ops,
        bool is_vid = vfd->vfl_type == VFL_TYPE_GRABBER;
        bool is_rx = vfd->vfl_dir != VFL_DIR_TX;
        bool is_tx = vfd->vfl_dir != VFL_DIR_RX;
+       int ret;
+
+       v4l_sanitize_format(p);
 
        switch (p->type) {
        case V4L2_BUF_TYPE_VIDEO_CAPTURE:
                if (unlikely(!is_rx || !is_vid || !ops->vidioc_g_fmt_vid_cap))
                        break;
-               return ops->vidioc_g_fmt_vid_cap(file, fh, arg);
+               ret = ops->vidioc_g_fmt_vid_cap(file, fh, arg);
+               p->fmt.pix.priv = V4L2_PIX_FMT_PRIV_MAGIC;
+               return ret;
        case V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE:
                if (unlikely(!is_rx || !is_vid || !ops->vidioc_g_fmt_vid_cap_mplane))
                        break;
@@ -1086,7 +1127,9 @@ static int v4l_g_fmt(const struct v4l2_ioctl_ops *ops,
        case V4L2_BUF_TYPE_VIDEO_OUTPUT:
                if (unlikely(!is_tx || !is_vid || !ops->vidioc_g_fmt_vid_out))
                        break;
-               return ops->vidioc_g_fmt_vid_out(file, fh, arg);
+               ret = ops->vidioc_g_fmt_vid_out(file, fh, arg);
+               p->fmt.pix.priv = V4L2_PIX_FMT_PRIV_MAGIC;
+               return ret;
        case V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE:
                if (unlikely(!is_tx || !is_vid || !ops->vidioc_g_fmt_vid_out_mplane))
                        break;
@@ -1446,7 +1489,18 @@ static int v4l_create_bufs(const struct v4l2_ioctl_ops *ops,
        struct v4l2_create_buffers *create = arg;
        int ret = check_fmt(file, create->format.type);
 
-       return ret ? ret : ops->vidioc_create_bufs(file, fh, create);
+       if (ret)
+               return ret;
+
+       v4l_sanitize_format(&create->format);
+
+       ret = ops->vidioc_create_bufs(file, fh, create);
+
+       if (create->format.type == V4L2_BUF_TYPE_VIDEO_CAPTURE ||
+           create->format.type == V4L2_BUF_TYPE_VIDEO_OUTPUT)
+               create->format.fmt.pix.priv = V4L2_PIX_FMT_PRIV_MAGIC;
+
+       return ret;
 }
 
 static int v4l_prepare_buf(const struct v4l2_ioctl_ops *ops,
index 42e3e8a..b4ed9a9 100644 (file)
@@ -127,17 +127,9 @@ static void v4l2_of_parse_parallel_bus(const struct device_node *node,
 int v4l2_of_parse_endpoint(const struct device_node *node,
                           struct v4l2_of_endpoint *endpoint)
 {
-       struct device_node *port_node = of_get_parent(node);
-
-       memset(endpoint, 0, offsetof(struct v4l2_of_endpoint, head));
-
-       endpoint->local_node = node;
-       /*
-        * It doesn't matter whether the two calls below succeed.
-        * If they don't then the default value 0 is used.
-        */
-       of_property_read_u32(port_node, "reg", &endpoint->port);
-       of_property_read_u32(node, "reg", &endpoint->id);
+       of_graph_parse_endpoint(node, &endpoint->base);
+       endpoint->bus_type = 0;
+       memset(&endpoint->bus, 0, sizeof(endpoint->bus));
 
        v4l2_of_parse_csi_bus(node, endpoint);
        /*
@@ -147,125 +139,6 @@ int v4l2_of_parse_endpoint(const struct device_node *node,
        if (endpoint->bus.mipi_csi2.flags == 0)
                v4l2_of_parse_parallel_bus(node, endpoint);
 
-       of_node_put(port_node);
-
        return 0;
 }
 EXPORT_SYMBOL(v4l2_of_parse_endpoint);
-
-/**
- * v4l2_of_get_next_endpoint() - get next endpoint node
- * @parent: pointer to the parent device node
- * @prev: previous endpoint node, or NULL to get first
- *
- * Return: An 'endpoint' node pointer with refcount incremented. Refcount
- * of the passed @prev node is not decremented, the caller have to use
- * of_node_put() on it when done.
- */
-struct device_node *v4l2_of_get_next_endpoint(const struct device_node *parent,
-                                       struct device_node *prev)
-{
-       struct device_node *endpoint;
-       struct device_node *port = NULL;
-
-       if (!parent)
-               return NULL;
-
-       if (!prev) {
-               struct device_node *node;
-               /*
-                * It's the first call, we have to find a port subnode
-                * within this node or within an optional 'ports' node.
-                */
-               node = of_get_child_by_name(parent, "ports");
-               if (node)
-                       parent = node;
-
-               port = of_get_child_by_name(parent, "port");
-
-               if (port) {
-                       /* Found a port, get an endpoint. */
-                       endpoint = of_get_next_child(port, NULL);
-                       of_node_put(port);
-               } else {
-                       endpoint = NULL;
-               }
-
-               if (!endpoint)
-                       pr_err("%s(): no endpoint nodes specified for %s\n",
-                              __func__, parent->full_name);
-               of_node_put(node);
-       } else {
-               port = of_get_parent(prev);
-               if (!port)
-                       /* Hm, has someone given us the root node ?... */
-                       return NULL;
-
-               /* Avoid dropping prev node refcount to 0. */
-               of_node_get(prev);
-               endpoint = of_get_next_child(port, prev);
-               if (endpoint) {
-                       of_node_put(port);
-                       return endpoint;
-               }
-
-               /* No more endpoints under this port, try the next one. */
-               do {
-                       port = of_get_next_child(parent, port);
-                       if (!port)
-                               return NULL;
-               } while (of_node_cmp(port->name, "port"));
-
-               /* Pick up the first endpoint in this port. */
-               endpoint = of_get_next_child(port, NULL);
-               of_node_put(port);
-       }
-
-       return endpoint;
-}
-EXPORT_SYMBOL(v4l2_of_get_next_endpoint);
-
-/**
- * v4l2_of_get_remote_port_parent() - get remote port's parent node
- * @node: pointer to a local endpoint device_node
- *
- * Return: Remote device node associated with remote endpoint node linked
- *        to @node. Use of_node_put() on it when done.
- */
-struct device_node *v4l2_of_get_remote_port_parent(
-                              const struct device_node *node)
-{
-       struct device_node *np;
-       unsigned int depth;
-
-       /* Get remote endpoint node. */
-       np = of_parse_phandle(node, "remote-endpoint", 0);
-
-       /* Walk 3 levels up only if there is 'ports' node. */
-       for (depth = 3; depth && np; depth--) {
-               np = of_get_next_parent(np);
-               if (depth == 2 && of_node_cmp(np->name, "ports"))
-                       break;
-       }
-       return np;
-}
-EXPORT_SYMBOL(v4l2_of_get_remote_port_parent);
-
-/**
- * v4l2_of_get_remote_port() - get remote port node
- * @node: pointer to a local endpoint device_node
- *
- * Return: Remote port node associated with remote endpoint node linked
- *        to @node. Use of_node_put() on it when done.
- */
-struct device_node *v4l2_of_get_remote_port(const struct device_node *node)
-{
-       struct device_node *np;
-
-       /* Get remote endpoint node. */
-       np = of_parse_phandle(node, "remote-endpoint", 0);
-       if (!np)
-               return NULL;
-       return of_get_next_parent(np);
-}
-EXPORT_SYMBOL(v4l2_of_get_remote_port);
index 06faea4..c13a203 100644 (file)
@@ -693,6 +693,7 @@ static int __reqbufs(struct vb2_queue *q, struct v4l2_requestbuffers *req)
         * Make sure the requested values and current defaults are sane.
         */
        num_buffers = min_t(unsigned int, req->count, VIDEO_MAX_FRAME);
+       num_buffers = max_t(unsigned int, req->count, q->min_buffers_needed);
        memset(q->plane_sizes, 0, sizeof(q->plane_sizes));
        memset(q->alloc_ctx, 0, sizeof(q->alloc_ctx));
        q->memory = req->memory;
@@ -716,9 +717,16 @@ static int __reqbufs(struct vb2_queue *q, struct v4l2_requestbuffers *req)
        allocated_buffers = ret;
 
        /*
+        * There is no point in continuing if we can't allocate the minimum
+        * number of buffers needed by this vb2_queue.
+        */
+       if (allocated_buffers < q->min_buffers_needed)
+               ret = -ENOMEM;
+
+       /*
         * Check if driver can handle the allocated number of buffers.
         */
-       if (allocated_buffers < num_buffers) {
+       if (!ret && allocated_buffers < num_buffers) {
                num_buffers = allocated_buffers;
 
                ret = call_qop(q, queue_setup, q, NULL, &num_buffers,
@@ -920,13 +928,20 @@ EXPORT_SYMBOL_GPL(vb2_plane_cookie);
  * vb2_buffer_done() - inform videobuf that an operation on a buffer is finished
  * @vb:                vb2_buffer returned from the driver
  * @state:     either VB2_BUF_STATE_DONE if the operation finished successfully
- *             or VB2_BUF_STATE_ERROR if the operation finished with an error
+ *             or VB2_BUF_STATE_ERROR if the operation finished with an error.
+ *             If start_streaming fails then it should return buffers with state
+ *             VB2_BUF_STATE_QUEUED to put them back into the queue.
  *
  * This function should be called by the driver after a hardware operation on
  * a buffer is finished and the buffer may be returned to userspace. The driver
  * cannot use this buffer anymore until it is queued back to it by videobuf
  * by the means of buf_queue callback. Only buffers previously queued to the
  * driver by buf_queue can be passed to this function.
+ *
+ * While streaming a buffer can only be returned in state DONE or ERROR.
+ * The start_streaming op can also return them in case the DMA engine cannot
+ * be started for some reason. In that case the buffers should be returned with
+ * state QUEUED.
  */
 void vb2_buffer_done(struct vb2_buffer *vb, enum vb2_buffer_state state)
 {
@@ -934,11 +949,17 @@ void vb2_buffer_done(struct vb2_buffer *vb, enum vb2_buffer_state state)
        unsigned long flags;
        unsigned int plane;
 
-       if (vb->state != VB2_BUF_STATE_ACTIVE)
+       if (WARN_ON(vb->state != VB2_BUF_STATE_ACTIVE))
                return;
 
-       if (state != VB2_BUF_STATE_DONE && state != VB2_BUF_STATE_ERROR)
-               return;
+       if (!q->start_streaming_called) {
+               if (WARN_ON(state != VB2_BUF_STATE_QUEUED))
+                       state = VB2_BUF_STATE_QUEUED;
+       } else if (!WARN_ON(!q->start_streaming_called)) {
+               if (WARN_ON(state != VB2_BUF_STATE_DONE &&
+                           state != VB2_BUF_STATE_ERROR))
+                       state = VB2_BUF_STATE_ERROR;
+       }
 
        dprintk(4, "Done processing on buffer %d, state: %d\n",
                        vb->v4l2_buf.index, state);
@@ -950,10 +971,14 @@ void vb2_buffer_done(struct vb2_buffer *vb, enum vb2_buffer_state state)
        /* Add the buffer to the done buffers list */
        spin_lock_irqsave(&q->done_lock, flags);
        vb->state = state;
-       list_add_tail(&vb->done_entry, &q->done_list);
-       atomic_dec(&q->queued_count);
+       if (state != VB2_BUF_STATE_QUEUED)
+               list_add_tail(&vb->done_entry, &q->done_list);
+       atomic_dec(&q->owned_by_drv_count);
        spin_unlock_irqrestore(&q->done_lock, flags);
 
+       if (state == VB2_BUF_STATE_QUEUED)
+               return;
+
        /* Inform any processes that may be waiting for buffers */
        wake_up(&q->done_wq);
 }
@@ -1240,7 +1265,7 @@ static void __enqueue_in_driver(struct vb2_buffer *vb)
        unsigned int plane;
 
        vb->state = VB2_BUF_STATE_ACTIVE;
-       atomic_inc(&q->queued_count);
+       atomic_inc(&q->owned_by_drv_count);
 
        /* sync buffers */
        for (plane = 0; plane < vb->num_planes; ++plane)
@@ -1384,32 +1409,50 @@ EXPORT_SYMBOL_GPL(vb2_prepare_buf);
  * vb2_start_streaming() - Attempt to start streaming.
  * @q:         videobuf2 queue
  *
- * If there are not enough buffers, then retry_start_streaming is set to
- * 1 and 0 is returned. The next time a buffer is queued and
- * retry_start_streaming is 1, this function will be called again to
- * retry starting the DMA engine.
+ * Attempt to start streaming. When this function is called there must be
+ * at least q->min_buffers_needed buffers queued up (i.e. the minimum
+ * number of buffers required for the DMA engine to function). If the
+ * @start_streaming op fails it is supposed to return all the driver-owned
+ * buffers back to vb2 in state QUEUED. Check if that happened and if
+ * not warn and reclaim them forcefully.
  */
 static int vb2_start_streaming(struct vb2_queue *q)
 {
+       struct vb2_buffer *vb;
        int ret;
 
-       /* Tell the driver to start streaming */
-       ret = call_qop(q, start_streaming, q, atomic_read(&q->queued_count));
-
        /*
-        * If there are not enough buffers queued to start streaming, then
-        * the start_streaming operation will return -ENOBUFS and you have to
-        * retry when the next buffer is queued.
+        * If any buffers were queued before streamon,
+        * we can now pass them to driver for processing.
         */
-       if (ret == -ENOBUFS) {
-               dprintk(1, "qbuf: not enough buffers, retry when more buffers are queued.\n");
-               q->retry_start_streaming = 1;
+       list_for_each_entry(vb, &q->queued_list, queued_entry)
+               __enqueue_in_driver(vb);
+
+       /* Tell the driver to start streaming */
+       q->start_streaming_called = 1;
+       ret = call_qop(q, start_streaming, q,
+                      atomic_read(&q->owned_by_drv_count));
+       if (!ret)
                return 0;
+
+       q->start_streaming_called = 0;
+
+       dprintk(1, "qbuf: driver refused to start streaming\n");
+       if (WARN_ON(atomic_read(&q->owned_by_drv_count))) {
+               unsigned i;
+
+               /*
+                * Forcefully reclaim buffers if the driver did not
+                * correctly return them to vb2.
+                */
+               for (i = 0; i < q->num_buffers; ++i) {
+                       vb = q->bufs[i];
+                       if (vb->state == VB2_BUF_STATE_ACTIVE)
+                               vb2_buffer_done(vb, VB2_BUF_STATE_QUEUED);
+               }
+               /* Must be zero now */
+               WARN_ON(atomic_read(&q->owned_by_drv_count));
        }
-       if (ret)
-               dprintk(1, "qbuf: driver refused to start streaming\n");
-       else
-               q->retry_start_streaming = 0;
        return ret;
 }
 
@@ -1449,6 +1492,7 @@ static int vb2_internal_qbuf(struct vb2_queue *q, struct v4l2_buffer *b)
         * dequeued in dqbuf.
         */
        list_add_tail(&vb->queued_entry, &q->queued_list);
+       q->queued_count++;
        q->waiting_for_buffers = false;
        vb->state = VB2_BUF_STATE_QUEUED;
 
@@ -1456,13 +1500,20 @@ static int vb2_internal_qbuf(struct vb2_queue *q, struct v4l2_buffer *b)
         * If already streaming, give the buffer to driver for processing.
         * If not, the buffer will be given to driver on next streamon.
         */
-       if (q->streaming)
+       if (q->start_streaming_called)
                __enqueue_in_driver(vb);
 
        /* Fill buffer information for the userspace */
        __fill_v4l2_buffer(vb, b);
 
-       if (q->retry_start_streaming) {
+       /*
+        * If streamon has been called, and we haven't yet called
+        * start_streaming() since not enough buffers were queued, and
+        * we now have reached the minimum number of queued buffers,
+        * then we can finally call start_streaming().
+        */
+       if (q->streaming && !q->start_streaming_called &&
+           q->queued_count >= q->min_buffers_needed) {
                ret = vb2_start_streaming(q);
                if (ret)
                        return ret;
@@ -1617,8 +1668,8 @@ int vb2_wait_for_all_buffers(struct vb2_queue *q)
                return -EINVAL;
        }
 
-       if (!q->retry_start_streaming)
-               wait_event(q->done_wq, !atomic_read(&q->queued_count));
+       if (q->start_streaming_called)
+               wait_event(q->done_wq, !atomic_read(&q->owned_by_drv_count));
        return 0;
 }
 EXPORT_SYMBOL_GPL(vb2_wait_for_all_buffers);
@@ -1682,6 +1733,7 @@ static int vb2_internal_dqbuf(struct vb2_queue *q, struct v4l2_buffer *b, bool n
        __fill_v4l2_buffer(vb, b);
        /* Remove from videobuf queue */
        list_del(&vb->queued_entry);
+       q->queued_count--;
        /* go back to dequeued state */
        __vb2_dqbuf(vb);
 
@@ -1732,18 +1784,23 @@ static void __vb2_queue_cancel(struct vb2_queue *q)
 {
        unsigned int i;
 
-       if (q->retry_start_streaming) {
-               q->retry_start_streaming = 0;
-               q->streaming = 0;
-       }
-
        /*
         * Tell driver to stop all transactions and release all queued
         * buffers.
         */
-       if (q->streaming)
+       if (q->start_streaming_called)
                call_qop(q, stop_streaming, q);
        q->streaming = 0;
+       q->start_streaming_called = 0;
+       q->queued_count = 0;
+
+       if (WARN_ON(atomic_read(&q->owned_by_drv_count))) {
+               for (i = 0; i < q->num_buffers; ++i)
+                       if (q->bufs[i]->state == VB2_BUF_STATE_ACTIVE)
+                               vb2_buffer_done(q->bufs[i], VB2_BUF_STATE_ERROR);
+               /* Must be zero now */
+               WARN_ON(atomic_read(&q->owned_by_drv_count));
+       }
 
        /*
         * Remove all buffers from videobuf's list...
@@ -1754,7 +1811,7 @@ static void __vb2_queue_cancel(struct vb2_queue *q)
         * has not already dequeued before initiating cancel.
         */
        INIT_LIST_HEAD(&q->done_list);
-       atomic_set(&q->queued_count, 0);
+       atomic_set(&q->owned_by_drv_count, 0);
        wake_up_all(&q->done_wq);
 
        /*
@@ -1766,7 +1823,6 @@ static void __vb2_queue_cancel(struct vb2_queue *q)
 
 static int vb2_internal_streamon(struct vb2_queue *q, enum v4l2_buf_type type)
 {
-       struct vb2_buffer *vb;
        int ret;
 
        if (type != q->type) {
@@ -1784,18 +1840,26 @@ static int vb2_internal_streamon(struct vb2_queue *q, enum v4l2_buf_type type)
                return -EINVAL;
        }
 
+       if (!q->num_buffers) {
+               dprintk(1, "streamon: no buffers have been allocated\n");
+               return -EINVAL;
+       }
+       if (q->num_buffers < q->min_buffers_needed) {
+               dprintk(1, "streamon: need at least %u allocated buffers\n",
+                               q->min_buffers_needed);
+               return -EINVAL;
+       }
+
        /*
-        * If any buffers were queued before streamon,
-        * we can now pass them to driver for processing.
+        * Tell driver to start streaming provided sufficient buffers
+        * are available.
         */
-       list_for_each_entry(vb, &q->queued_list, queued_entry)
-               __enqueue_in_driver(vb);
-
-       /* Tell driver to start streaming. */
-       ret = vb2_start_streaming(q);
-       if (ret) {
-               __vb2_queue_cancel(q);
-               return ret;
+       if (q->queued_count >= q->min_buffers_needed) {
+               ret = vb2_start_streaming(q);
+               if (ret) {
+                       __vb2_queue_cancel(q);
+                       return ret;
+               }
        }
 
        q->streaming = 1;
index 6250155..f495b8b 100644 (file)
@@ -20,7 +20,6 @@
 #include <linux/kernel.h>
 #include <linux/module.h>
 #include <linux/platform_device.h>
-#include <linux/init.h>
 #include <linux/slab.h>
 #include <linux/interrupt.h>
 #include <linux/irq.h>
index 17c1301..be91cb5 100644 (file)
@@ -23,7 +23,6 @@
  */
 
 #include <linux/kernel.h>
-#include <linux/init.h>
 #include <linux/mfd/core.h>
 #include <linux/module.h>
 #include <linux/pci.h>
index caf8dcf..b4d920c 100644 (file)
@@ -296,73 +296,73 @@ static struct resource da9055_ld05_6_resource = {
 
 static const struct mfd_cell da9055_devs[] = {
        {
-               .of_compatible = "dialog,da9055-gpio",
+               .of_compatible = "dlg,da9055-gpio",
                .name = "da9055-gpio",
        },
        {
-               .of_compatible = "dialog,da9055-regulator",
+               .of_compatible = "dlg,da9055-regulator",
                .name = "da9055-regulator",
                .id = 1,
        },
        {
-               .of_compatible = "dialog,da9055-regulator",
+               .of_compatible = "dlg,da9055-regulator",
                .name = "da9055-regulator",
                .id = 2,
        },
        {
-               .of_compatible = "dialog,da9055-regulator",
+               .of_compatible = "dlg,da9055-regulator",
                .name = "da9055-regulator",
                .id = 3,
        },
        {
-               .of_compatible = "dialog,da9055-regulator",
+               .of_compatible = "dlg,da9055-regulator",
                .name = "da9055-regulator",
                .id = 4,
        },
        {
-               .of_compatible = "dialog,da9055-regulator",
+               .of_compatible = "dlg,da9055-regulator",
                .name = "da9055-regulator",
                .id = 5,
        },
        {
-               .of_compatible = "dialog,da9055-regulator",
+               .of_compatible = "dlg,da9055-regulator",
                .name = "da9055-regulator",
                .id = 6,
        },
        {
-               .of_compatible = "dialog,da9055-regulator",
+               .of_compatible = "dlg,da9055-regulator",
                .name = "da9055-regulator",
                .id = 7,
                .resources = &da9055_ld05_6_resource,
                .num_resources = 1,
        },
        {
-               .of_compatible = "dialog,da9055-regulator",
+               .of_compatible = "dlg,da9055-regulator",
                .name = "da9055-regulator",
                .resources = &da9055_ld05_6_resource,
                .num_resources = 1,
                .id = 8,
        },
        {
-               .of_compatible = "dialog,da9055-onkey",
+               .of_compatible = "dlg,da9055-onkey",
                .name = "da9055-onkey",
                .resources = &da9055_onkey_resource,
                .num_resources = 1,
        },
        {
-               .of_compatible = "dialog,da9055-rtc",
+               .of_compatible = "dlg,da9055-rtc",
                .name = "da9055-rtc",
                .resources = da9055_rtc_resource,
                .num_resources = ARRAY_SIZE(da9055_rtc_resource),
        },
        {
-               .of_compatible = "dialog,da9055-hwmon",
+               .of_compatible = "dlg,da9055-hwmon",
                .name = "da9055-hwmon",
                .resources = &da9055_hwmon_resource,
                .num_resources = 1,
        },
        {
-               .of_compatible = "dialog,da9055-watchdog",
+               .of_compatible = "dlg,da9055-watchdog",
                .name = "da9055-watchdog",
        },
 };
index 81b7d88..433f823 100644 (file)
@@ -13,7 +13,6 @@
 
 #include <linux/kernel.h>
 #include <linux/module.h>
-#include <linux/init.h>
 #include <linux/pci.h>
 #include <linux/interrupt.h>
 #include <linux/delay.h>
index be93fa2..f35d428 100644 (file)
  *     document number TBD : Avoton SoC
  *     document number TBD : Coleto Creek
  *     document number TBD : Wildcat Point-LP
+ *     document number TBD : 9 Series
  */
 
 #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
 
-#include <linux/init.h>
 #include <linux/kernel.h>
 #include <linux/module.h>
 #include <linux/errno.h>
 #define ACPIBASE_GPE_END       0x2f
 #define ACPIBASE_SMI_OFF       0x30
 #define ACPIBASE_SMI_END       0x33
+#define ACPIBASE_PMC_OFF       0x08
+#define ACPIBASE_PMC_END       0x0c
 #define ACPIBASE_TCO_OFF       0x60
 #define ACPIBASE_TCO_END       0x7f
-#define ACPICTRL               0x44
+#define ACPICTRL_PMCBASE       0x44
 
 #define ACPIBASE_GCS_OFF       0x3410
 #define ACPIBASE_GCS_END       0x3414
 #define wdt_mem_res(i) wdt_res(ICH_RES_MEM_OFF, i)
 #define wdt_res(b, i) (&wdt_ich_res[(b) + (i)])
 
-struct lpc_ich_cfg {
-       int base;
-       int ctrl;
-       int save;
-};
-
 struct lpc_ich_priv {
        int chipset;
-       struct lpc_ich_cfg acpi;
-       struct lpc_ich_cfg gpio;
+
+       int abase;              /* ACPI base */
+       int actrl_pbase;        /* ACPI control or PMC base */
+       int gbase;              /* GPIO base */
+       int gctrl;              /* GPIO control */
+
+       int abase_save;         /* Cached ACPI base value */
+       int actrl_pbase_save;           /* Cached ACPI control or PMC base value */
+       int gctrl_save;         /* Cached GPIO control value */
 };
 
 static struct resource wdt_ich_res[] = {
@@ -111,7 +114,7 @@ static struct resource wdt_ich_res[] = {
        {
                .flags = IORESOURCE_IO,
        },
-       /* GCS */
+       /* GCS or PMC */
        {
                .flags = IORESOURCE_MEM,
        },
@@ -211,8 +214,11 @@ enum lpc_chipsets {
        LPC_LPT_LP,     /* Lynx Point-LP */
        LPC_WBG,        /* Wellsburg */
        LPC_AVN,        /* Avoton SoC */
+       LPC_BAYTRAIL,   /* Bay Trail SoC */
        LPC_COLETO,     /* Coleto Creek */
        LPC_WPT_LP,     /* Wildcat Point-LP */
+       LPC_BRASWELL,   /* Braswell SoC */
+       LPC_9S,         /* 9 Series */
 };
 
 static struct lpc_ich_info lpc_chipset_info[] = {
@@ -303,6 +309,7 @@ static struct lpc_ich_info lpc_chipset_info[] = {
        [LPC_NM10] = {
                .name = "NM10",
                .iTCO_version = 2,
+               .gpio_version = ICH_V7_GPIO,
        },
        [LPC_ICH8] = {
                .name = "ICH8 or ICH8R",
@@ -484,6 +491,7 @@ static struct lpc_ich_info lpc_chipset_info[] = {
        [LPC_PPT] = {
                .name = "Panther Point",
                .iTCO_version = 2,
+               .gpio_version = ICH_V5_GPIO,
        },
        [LPC_LPT] = {
                .name = "Lynx Point",
@@ -499,7 +507,12 @@ static struct lpc_ich_info lpc_chipset_info[] = {
        },
        [LPC_AVN] = {
                .name = "Avoton SoC",
-               .iTCO_version = 1,
+               .iTCO_version = 3,
+               .gpio_version = AVOTON_GPIO,
+       },
+       [LPC_BAYTRAIL] = {
+               .name = "Bay Trail SoC",
+               .iTCO_version = 3,
        },
        [LPC_COLETO] = {
                .name = "Coleto Creek",
@@ -509,6 +522,14 @@ static struct lpc_ich_info lpc_chipset_info[] = {
                .name = "Wildcat Point_LP",
                .iTCO_version = 2,
        },
+       [LPC_BRASWELL] = {
+               .name = "Braswell SoC",
+               .iTCO_version = 3,
+       },
+       [LPC_9S] = {
+               .name = "9 Series",
+               .iTCO_version = 2,
+       },
 };
 
 /*
@@ -726,6 +747,7 @@ static const struct pci_device_id lpc_ich_ids[] = {
        { PCI_VDEVICE(INTEL, 0x1f39), LPC_AVN},
        { PCI_VDEVICE(INTEL, 0x1f3a), LPC_AVN},
        { PCI_VDEVICE(INTEL, 0x1f3b), LPC_AVN},
+       { PCI_VDEVICE(INTEL, 0x0f1c), LPC_BAYTRAIL},
        { PCI_VDEVICE(INTEL, 0x2390), LPC_COLETO},
        { PCI_VDEVICE(INTEL, 0x9cc1), LPC_WPT_LP},
        { PCI_VDEVICE(INTEL, 0x9cc2), LPC_WPT_LP},
@@ -734,6 +756,12 @@ static const struct pci_device_id lpc_ich_ids[] = {
        { PCI_VDEVICE(INTEL, 0x9cc6), LPC_WPT_LP},
        { PCI_VDEVICE(INTEL, 0x9cc7), LPC_WPT_LP},
        { PCI_VDEVICE(INTEL, 0x9cc9), LPC_WPT_LP},
+       { PCI_VDEVICE(INTEL, 0x229c), LPC_BRASWELL},
+       { PCI_VDEVICE(INTEL, 0x8cc1), LPC_9S},
+       { PCI_VDEVICE(INTEL, 0x8cc2), LPC_9S},
+       { PCI_VDEVICE(INTEL, 0x8cc3), LPC_9S},
+       { PCI_VDEVICE(INTEL, 0x8cc4), LPC_9S},
+       { PCI_VDEVICE(INTEL, 0x8cc6), LPC_9S},
        { 0, },                 /* End of list */
 };
 MODULE_DEVICE_TABLE(pci, lpc_ich_ids);
@@ -742,14 +770,20 @@ static void lpc_ich_restore_config_space(struct pci_dev *dev)
 {
        struct lpc_ich_priv *priv = pci_get_drvdata(dev);
 
-       if (priv->acpi.save >= 0) {
-               pci_write_config_byte(dev, priv->acpi.ctrl, priv->acpi.save);
-               priv->acpi.save = -1;
+       if (priv->abase_save >= 0) {
+               pci_write_config_byte(dev, priv->abase, priv->abase_save);
+               priv->abase_save = -1;
        }
 
-       if (priv->gpio.save >= 0) {
-               pci_write_config_byte(dev, priv->gpio.ctrl, priv->gpio.save);
-               priv->gpio.save = -1;
+       if (priv->actrl_pbase_save >= 0) {
+               pci_write_config_byte(dev, priv->actrl_pbase,
+                       priv->actrl_pbase_save);
+               priv->actrl_pbase_save = -1;
+       }
+
+       if (priv->gctrl_save >= 0) {
+               pci_write_config_byte(dev, priv->gctrl, priv->gctrl_save);
+               priv->gctrl_save = -1;
        }
 }
 
@@ -758,9 +792,26 @@ static void lpc_ich_enable_acpi_space(struct pci_dev *dev)
        struct lpc_ich_priv *priv = pci_get_drvdata(dev);
        u8 reg_save;
 
-       pci_read_config_byte(dev, priv->acpi.ctrl, &reg_save);
-       pci_write_config_byte(dev, priv->acpi.ctrl, reg_save | 0x10);
-       priv->acpi.save = reg_save;
+       switch (lpc_chipset_info[priv->chipset].iTCO_version) {
+       case 3:
+               /*
+                * Some chipsets (eg Avoton) enable the ACPI space in the
+                * ACPI BASE register.
+                */
+               pci_read_config_byte(dev, priv->abase, &reg_save);
+               pci_write_config_byte(dev, priv->abase, reg_save | 0x2);
+               priv->abase_save = reg_save;
+               break;
+       default:
+               /*
+                * Most chipsets enable the ACPI space in the ACPI control
+                * register.
+                */
+               pci_read_config_byte(dev, priv->actrl_pbase, &reg_save);
+               pci_write_config_byte(dev, priv->actrl_pbase, reg_save | 0x80);
+               priv->actrl_pbase_save = reg_save;
+               break;
+       }
 }
 
 static void lpc_ich_enable_gpio_space(struct pci_dev *dev)
@@ -768,9 +819,20 @@ static void lpc_ich_enable_gpio_space(struct pci_dev *dev)
        struct lpc_ich_priv *priv = pci_get_drvdata(dev);
        u8 reg_save;
 
-       pci_read_config_byte(dev, priv->gpio.ctrl, &reg_save);
-       pci_write_config_byte(dev, priv->gpio.ctrl, reg_save | 0x10);
-       priv->gpio.save = reg_save;
+       pci_read_config_byte(dev, priv->gctrl, &reg_save);
+       pci_write_config_byte(dev, priv->gctrl, reg_save | 0x10);
+       priv->gctrl_save = reg_save;
+}
+
+static void lpc_ich_enable_pmc_space(struct pci_dev *dev)
+{
+       struct lpc_ich_priv *priv = pci_get_drvdata(dev);
+       u8 reg_save;
+
+       pci_read_config_byte(dev, priv->actrl_pbase, &reg_save);
+       pci_write_config_byte(dev, priv->actrl_pbase, reg_save | 0x2);
+
+       priv->actrl_pbase_save = reg_save;
 }
 
 static void lpc_ich_finalize_cell(struct pci_dev *dev, struct mfd_cell *cell)
@@ -815,7 +877,7 @@ static int lpc_ich_init_gpio(struct pci_dev *dev)
        struct resource *res;
 
        /* Setup power management base register */
-       pci_read_config_dword(dev, priv->acpi.base, &base_addr_cfg);
+       pci_read_config_dword(dev, priv->abase, &base_addr_cfg);
        base_addr = base_addr_cfg & 0x0000ff80;
        if (!base_addr) {
                dev_notice(&dev->dev, "I/O space for ACPI uninitialized\n");
@@ -841,7 +903,7 @@ static int lpc_ich_init_gpio(struct pci_dev *dev)
 
 gpe0_done:
        /* Setup GPIO base register */
-       pci_read_config_dword(dev, priv->gpio.base, &base_addr_cfg);
+       pci_read_config_dword(dev, priv->gbase, &base_addr_cfg);
        base_addr = base_addr_cfg & 0x0000ff80;
        if (!base_addr) {
                dev_notice(&dev->dev, "I/O space for GPIO uninitialized\n");
@@ -891,7 +953,7 @@ static int lpc_ich_init_wdt(struct pci_dev *dev)
        struct resource *res;
 
        /* Setup power management base register */
-       pci_read_config_dword(dev, priv->acpi.base, &base_addr_cfg);
+       pci_read_config_dword(dev, priv->abase, &base_addr_cfg);
        base_addr = base_addr_cfg & 0x0000ff80;
        if (!base_addr) {
                dev_notice(&dev->dev, "I/O space for ACPI uninitialized\n");
@@ -910,14 +972,20 @@ static int lpc_ich_init_wdt(struct pci_dev *dev)
        lpc_ich_enable_acpi_space(dev);
 
        /*
+        * iTCO v2:
         * Get the Memory-Mapped GCS register. To get access to it
         * we have to read RCBA from PCI Config space 0xf0 and use
         * it as base. GCS = RCBA + ICH6_GCS(0x3410).
+        *
+        * iTCO v3:
+        * Get the Power Management Configuration register.  To get access
+        * to it we have to read the PMC BASE from config space and address
+        * the register at offset 0x8.
         */
        if (lpc_chipset_info[priv->chipset].iTCO_version == 1) {
                /* Don't register iomem for TCO ver 1 */
                lpc_ich_cells[LPC_WDT].num_resources--;
-       } else {
+       } else if (lpc_chipset_info[priv->chipset].iTCO_version == 2) {
                pci_read_config_dword(dev, RCBABASE, &base_addr_cfg);
                base_addr = base_addr_cfg & 0xffffc000;
                if (!(base_addr_cfg & 1)) {
@@ -926,9 +994,17 @@ static int lpc_ich_init_wdt(struct pci_dev *dev)
                        ret = -ENODEV;
                        goto wdt_done;
                }
-               res = wdt_mem_res(ICH_RES_MEM_GCS);
+               res = wdt_mem_res(ICH_RES_MEM_GCS_PMC);
                res->start = base_addr + ACPIBASE_GCS_OFF;
                res->end = base_addr + ACPIBASE_GCS_END;
+       } else if (lpc_chipset_info[priv->chipset].iTCO_version == 3) {
+               lpc_ich_enable_pmc_space(dev);
+               pci_read_config_dword(dev, ACPICTRL_PMCBASE, &base_addr_cfg);
+               base_addr = base_addr_cfg & 0xfffffe00;
+
+               res = wdt_mem_res(ICH_RES_MEM_GCS_PMC);
+               res->start = base_addr + ACPIBASE_PMC_OFF;
+               res->end = base_addr + ACPIBASE_PMC_END;
        }
 
        lpc_ich_finalize_cell(dev, &lpc_ich_cells[LPC_WDT]);
@@ -952,28 +1028,35 @@ static int lpc_ich_probe(struct pci_dev *dev,
                return -ENOMEM;
 
        priv->chipset = id->driver_data;
-       priv->acpi.save = -1;
-       priv->acpi.base = ACPIBASE;
-       priv->acpi.ctrl = ACPICTRL;
 
-       priv->gpio.save = -1;
+       priv->actrl_pbase_save = -1;
+       priv->abase_save = -1;
+
+       priv->abase = ACPIBASE;
+       priv->actrl_pbase = ACPICTRL_PMCBASE;
+
+       priv->gctrl_save = -1;
        if (priv->chipset <= LPC_ICH5) {
-               priv->gpio.base = GPIOBASE_ICH0;
-               priv->gpio.ctrl = GPIOCTRL_ICH0;
+               priv->gbase = GPIOBASE_ICH0;
+               priv->gctrl = GPIOCTRL_ICH0;
        } else {
-               priv->gpio.base = GPIOBASE_ICH6;
-               priv->gpio.ctrl = GPIOCTRL_ICH6;
+               priv->gbase = GPIOBASE_ICH6;
+               priv->gctrl = GPIOCTRL_ICH6;
        }
 
        pci_set_drvdata(dev, priv);
 
-       ret = lpc_ich_init_wdt(dev);
-       if (!ret)
-               cell_added = true;
+       if (lpc_chipset_info[priv->chipset].iTCO_version) {
+               ret = lpc_ich_init_wdt(dev);
+               if (!ret)
+                       cell_added = true;
+       }
 
-       ret = lpc_ich_init_gpio(dev);
-       if (!ret)
-               cell_added = true;
+       if (lpc_chipset_info[priv->chipset].gpio_version) {
+               ret = lpc_ich_init_gpio(dev);
+               if (!ret)
+                       cell_added = true;
+       }
 
        /*
         * We only care if at least one or none of the cells registered
index 3bb05c0..4ee7550 100644 (file)
@@ -23,7 +23,6 @@
  *  the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
  */
 
-#include <linux/init.h>
 #include <linux/kernel.h>
 #include <linux/module.h>
 #include <linux/errno.h>
index 41c31b3..29d7698 100644 (file)
@@ -12,7 +12,6 @@
  *  MCP read/write timeouts from Jordi Colomer, rehacked by rmk.
  */
 #include <linux/module.h>
-#include <linux/init.h>
 #include <linux/io.h>
 #include <linux/errno.h>
 #include <linux/kernel.h>
index b8941a5..c1984b0 100644 (file)
@@ -19,7 +19,6 @@
 #include <linux/kernel.h>
 #include <linux/slab.h>
 #include <linux/module.h>
-#include <linux/init.h>
 #include <linux/device.h>
 #include <linux/platform_device.h>
 #include <linux/completion.h>
index b41db59..bb85020 100644 (file)
@@ -22,7 +22,6 @@
  */
 #include <linux/interrupt.h>
 #include <linux/irq.h>
-#include <linux/init.h>
 #include <linux/i2c.h>
 #include <linux/mfd/rc5t583.h>
 
index d346146..c795697 100644 (file)
@@ -19,7 +19,6 @@
  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  *
  */
-#include <linux/init.h>
 #include <linux/module.h>
 #include <linux/kernel.h>
 #include <linux/platform_device.h>
index c8f345f..663f8a3 100644 (file)
@@ -19,7 +19,6 @@
 #include <linux/err.h>
 #include <linux/i2c.h>
 #include <linux/irq.h>
-#include <linux/init.h>
 #include <linux/slab.h>
 #include <linux/mutex.h>
 #include <linux/module.h>
index 24ae3d8..90112d4 100644 (file)
@@ -13,7 +13,6 @@
 
 #include <linux/module.h>
 #include <linux/moduleparam.h>
-#include <linux/init.h>
 #include <linux/slab.h>
 #include <linux/i2c.h>
 #include <linux/gpio.h>
index a542457..0769ecd 100644 (file)
@@ -23,7 +23,6 @@
 #include <linux/module.h>
 #include <linux/slab.h>
 #include <linux/err.h>
-#include <linux/init.h>
 #include <linux/wait.h>
 #include <linux/clk.h>
 #include <linux/interrupt.h>
index e87a248..155fcc0 100644 (file)
@@ -14,7 +14,6 @@
  */
 
 #include <linux/module.h>
-#include <linux/init.h>
 #include <linux/slab.h>
 #include <linux/err.h>
 #include <linux/io.h>
index 27a518e..1f82d60 100644 (file)
@@ -15,7 +15,6 @@
 
 #include <linux/module.h>
 #include <linux/moduleparam.h>
-#include <linux/init.h>
 #include <linux/slab.h>
 #include <linux/gpio.h>
 #include <linux/mfd/core.h>
index d360a83..fbecec7 100644 (file)
@@ -15,7 +15,6 @@
 
 #include <linux/kernel.h>
 #include <linux/module.h>
-#include <linux/init.h>
 #include <linux/bug.h>
 #include <linux/device.h>
 #include <linux/interrupt.h>
index 9aa6d1e..596b1f6 100644 (file)
@@ -27,7 +27,6 @@
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
  */
 
-#include <linux/init.h>
 #include <linux/export.h>
 #include <linux/interrupt.h>
 #include <linux/irq.h>
index 4c583e4..d700cd2 100644 (file)
@@ -29,7 +29,6 @@
  *
  */
 
-#include <linux/init.h>
 #include <linux/device.h>
 #include <linux/interrupt.h>
 #include <linux/kernel.h>
index 18a607e..a6bb17d 100644 (file)
@@ -31,7 +31,6 @@
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
  */
 
-#include <linux/init.h>
 #include <linux/export.h>
 #include <linux/interrupt.h>
 #include <linux/irq.h>
index 84ce6b9..0c9c350 100644 (file)
@@ -16,7 +16,6 @@
 #include <linux/bitops.h>
 #include <linux/completion.h>
 #include <linux/export.h>
-#include <linux/init.h>
 #include <linux/list.h>
 #include <linux/of.h>
 #include <linux/of_device.h>
index 7c1ae24..4ab527f 100644 (file)
@@ -14,7 +14,6 @@
 
 #include <linux/kernel.h>
 #include <linux/module.h>
-#include <linux/init.h>
 #include <linux/slab.h>
 #include <linux/bug.h>
 #include <linux/device.h>
index 624ff90..cd01f79 100644 (file)
@@ -14,7 +14,6 @@
 
 #include <linux/kernel.h>
 #include <linux/module.h>
-#include <linux/init.h>
 #include <linux/bug.h>
 #include <linux/device.h>
 #include <linux/interrupt.h>
index 7b5424f..3a24edd 100644 (file)
@@ -1359,6 +1359,16 @@ static void mmc_blk_rw_rq_prep(struct mmc_queue_req *mqrq,
                if (card->host->caps2 & MMC_CAP2_NO_MULTI_READ &&
                    rq_data_dir(req) == READ)
                        brq->data.blocks = 1;
+
+               /*
+                * Some controllers have HW issues while operating
+                * in multiple I/O mode
+                */
+               if (card->host->ops->multi_io_quirk)
+                       brq->data.blocks = card->host->ops->multi_io_quirk(card,
+                                               (rq_data_dir(req) == READ) ?
+                                               MMC_DATA_READ : MMC_DATA_WRITE,
+                                               brq->data.blocks);
        }
 
        if (brq->data.blocks > 1 || do_rel_wr) {
index 54829c0..509229b 100644 (file)
@@ -135,6 +135,9 @@ static int mmc_ios_show(struct seq_file *s, void *data)
        case MMC_TIMING_UHS_DDR50:
                str = "sd uhs DDR50";
                break;
+       case MMC_TIMING_MMC_DDR52:
+               str = "mmc DDR52";
+               break;
        case MMC_TIMING_MMC_HS200:
                str = "mmc high-speed SDR200";
                break;
index 98e9eb0..6d91ff7 100644 (file)
@@ -1261,7 +1261,7 @@ static int mmc_init_card(struct mmc_host *host, u32 ocr,
                                        goto err;
                        }
                        mmc_card_set_ddr_mode(card);
-                       mmc_set_timing(card->host, MMC_TIMING_UHS_DDR50);
+                       mmc_set_timing(card->host, MMC_TIMING_MMC_DDR52);
                        mmc_set_bus_width(card->host, bus_width);
                }
        }
index 54730f4..d11708c 100644 (file)
@@ -386,7 +386,7 @@ sh_mmcif_request_dma_one(struct sh_mmcif_host *host,
                         struct sh_mmcif_plat_data *pdata,
                         enum dma_transfer_direction direction)
 {
-       struct dma_slave_config cfg;
+       struct dma_slave_config cfg = { 0, };
        struct dma_chan *chan;
        unsigned int slave_id;
        struct resource *res;
@@ -417,8 +417,15 @@ sh_mmcif_request_dma_one(struct sh_mmcif_host *host,
        /* In the OF case the driver will get the slave ID from the DT */
        cfg.slave_id = slave_id;
        cfg.direction = direction;
-       cfg.dst_addr = res->start + MMCIF_CE_DATA;
-       cfg.src_addr = 0;
+
+       if (direction == DMA_DEV_TO_MEM) {
+               cfg.src_addr = res->start + MMCIF_CE_DATA;
+               cfg.src_addr_width = DMA_SLAVE_BUSWIDTH_4_BYTES;
+       } else {
+               cfg.dst_addr = res->start + MMCIF_CE_DATA;
+               cfg.dst_addr_width = DMA_SLAVE_BUSWIDTH_4_BYTES;
+       }
+
        ret = dmaengine_slave_config(chan, &cfg);
        if (ret < 0) {
                dma_release_channel(chan);
@@ -803,12 +810,13 @@ static u32 sh_mmcif_set_cmd(struct sh_mmcif_host *host,
                        break;
                }
                switch (host->timing) {
-               case MMC_TIMING_UHS_DDR50:
+               case MMC_TIMING_MMC_DDR52:
                        /*
                         * MMC core will only set this timing, if the host
-                        * advertises the MMC_CAP_UHS_DDR50 capability. MMCIF
-                        * implementations with this capability, e.g. sh73a0,
-                        * will have to set it in their platform data.
+                        * advertises the MMC_CAP_1_8V_DDR/MMC_CAP_1_2V_DDR
+                        * capability. MMCIF implementations with this
+                        * capability, e.g. sh73a0, will have to set it
+                        * in their platform data.
                         */
                        tmp |= CMD_SET_DARS;
                        break;
@@ -1377,26 +1385,19 @@ static int sh_mmcif_probe(struct platform_device *pdev)
                dev_err(&pdev->dev, "Get irq error\n");
                return -ENXIO;
        }
+
        res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
-       if (!res) {
-               dev_err(&pdev->dev, "platform_get_resource error.\n");
-               return -ENXIO;
-       }
-       reg = ioremap(res->start, resource_size(res));
-       if (!reg) {
-               dev_err(&pdev->dev, "ioremap error.\n");
-               return -ENOMEM;
-       }
+       reg = devm_ioremap_resource(&pdev->dev, res);
+       if (IS_ERR(reg))
+               return PTR_ERR(reg);
 
        mmc = mmc_alloc_host(sizeof(struct sh_mmcif_host), &pdev->dev);
-       if (!mmc) {
-               ret = -ENOMEM;
-               goto ealloch;
-       }
+       if (!mmc)
+               return -ENOMEM;
 
        ret = mmc_of_parse(mmc);
        if (ret < 0)
-               goto eofparse;
+               goto err_host;
 
        host            = mmc_priv(mmc);
        host->mmc       = mmc;
@@ -1426,19 +1427,19 @@ static int sh_mmcif_probe(struct platform_device *pdev)
        pm_runtime_enable(&pdev->dev);
        host->power = false;
 
-       host->hclk = clk_get(&pdev->dev, NULL);
+       host->hclk = devm_clk_get(&pdev->dev, NULL);
        if (IS_ERR(host->hclk)) {
                ret = PTR_ERR(host->hclk);
                dev_err(&pdev->dev, "cannot get clock: %d\n", ret);
-               goto eclkget;
+               goto err_pm;
        }
        ret = sh_mmcif_clk_update(host);
        if (ret < 0)
-               goto eclkupdate;
+               goto err_pm;
 
        ret = pm_runtime_resume(&pdev->dev);
        if (ret < 0)
-               goto eresume;
+               goto err_clk;
 
        INIT_DELAYED_WORK(&host->timeout_work, mmcif_timeout_work);
 
@@ -1446,65 +1447,55 @@ static int sh_mmcif_probe(struct platform_device *pdev)
        sh_mmcif_writel(host->addr, MMCIF_CE_INT_MASK, MASK_ALL);
 
        name = irq[1] < 0 ? dev_name(&pdev->dev) : "sh_mmc:error";
-       ret = request_threaded_irq(irq[0], sh_mmcif_intr, sh_mmcif_irqt, 0, name, host);
+       ret = devm_request_threaded_irq(&pdev->dev, irq[0], sh_mmcif_intr,
+                                       sh_mmcif_irqt, 0, name, host);
        if (ret) {
                dev_err(&pdev->dev, "request_irq error (%s)\n", name);
-               goto ereqirq0;
+               goto err_clk;
        }
        if (irq[1] >= 0) {
-               ret = request_threaded_irq(irq[1], sh_mmcif_intr, sh_mmcif_irqt,
-                                          0, "sh_mmc:int", host);
+               ret = devm_request_threaded_irq(&pdev->dev, irq[1],
+                                               sh_mmcif_intr, sh_mmcif_irqt,
+                                               0, "sh_mmc:int", host);
                if (ret) {
                        dev_err(&pdev->dev, "request_irq error (sh_mmc:int)\n");
-                       goto ereqirq1;
+                       goto err_clk;
                }
        }
 
        if (pd && pd->use_cd_gpio) {
                ret = mmc_gpio_request_cd(mmc, pd->cd_gpio, 0);
                if (ret < 0)
-                       goto erqcd;
+                       goto err_clk;
        }
 
        mutex_init(&host->thread_lock);
 
-       clk_disable_unprepare(host->hclk);
        ret = mmc_add_host(mmc);
        if (ret < 0)
-               goto emmcaddh;
+               goto err_clk;
 
        dev_pm_qos_expose_latency_limit(&pdev->dev, 100);
 
-       dev_info(&pdev->dev, "driver version %s\n", DRIVER_VERSION);
-       dev_dbg(&pdev->dev, "chip ver H'%04x\n",
-               sh_mmcif_readl(host->addr, MMCIF_CE_VERSION) & 0x0000ffff);
+       dev_info(&pdev->dev, "Chip version 0x%04x, clock rate %luMHz\n",
+                sh_mmcif_readl(host->addr, MMCIF_CE_VERSION) & 0xffff,
+                clk_get_rate(host->hclk) / 1000000UL);
+
+       clk_disable_unprepare(host->hclk);
        return ret;
 
-emmcaddh:
-erqcd:
-       if (irq[1] >= 0)
-               free_irq(irq[1], host);
-ereqirq1:
-       free_irq(irq[0], host);
-ereqirq0:
-       pm_runtime_suspend(&pdev->dev);
-eresume:
+err_clk:
        clk_disable_unprepare(host->hclk);
-eclkupdate:
-       clk_put(host->hclk);
-eclkget:
+err_pm:
        pm_runtime_disable(&pdev->dev);
-eofparse:
+err_host:
        mmc_free_host(mmc);
-ealloch:
-       iounmap(reg);
        return ret;
 }
 
 static int sh_mmcif_remove(struct platform_device *pdev)
 {
        struct sh_mmcif_host *host = platform_get_drvdata(pdev);
-       int irq[2];
 
        host->dying = true;
        clk_prepare_enable(host->hclk);
@@ -1522,16 +1513,6 @@ static int sh_mmcif_remove(struct platform_device *pdev)
         */
        cancel_delayed_work_sync(&host->timeout_work);
 
-       if (host->addr)
-               iounmap(host->addr);
-
-       irq[0] = platform_get_irq(pdev, 0);
-       irq[1] = platform_get_irq(pdev, 1);
-
-       free_irq(irq[0], host);
-       if (irq[1] >= 0)
-               free_irq(irq[1], host);
-
        clk_disable_unprepare(host->hclk);
        mmc_free_host(host->mmc);
        pm_runtime_put_sync(&pdev->dev);
index 2d6ce25..5e76502 100644 (file)
@@ -37,6 +37,9 @@
 
 struct sh_mobile_sdhi_of_data {
        unsigned long tmio_flags;
+       unsigned long capabilities;
+       unsigned long capabilities2;
+       dma_addr_t dma_rx_offset;
 };
 
 static const struct sh_mobile_sdhi_of_data sh_mobile_sdhi_of_cfg[] = {
@@ -45,6 +48,36 @@ static const struct sh_mobile_sdhi_of_data sh_mobile_sdhi_of_cfg[] = {
        },
 };
 
+static const struct sh_mobile_sdhi_of_data of_rcar_gen1_compatible = {
+       .tmio_flags     = TMIO_MMC_HAS_IDLE_WAIT | TMIO_MMC_WRPROTECT_DISABLE |
+                         TMIO_MMC_CLK_ACTUAL,
+       .capabilities   = MMC_CAP_SD_HIGHSPEED | MMC_CAP_SDIO_IRQ,
+};
+
+static const struct sh_mobile_sdhi_of_data of_rcar_gen2_compatible = {
+       .tmio_flags     = TMIO_MMC_HAS_IDLE_WAIT | TMIO_MMC_WRPROTECT_DISABLE |
+                         TMIO_MMC_CLK_ACTUAL,
+       .capabilities   = MMC_CAP_SD_HIGHSPEED | MMC_CAP_SDIO_IRQ,
+       .dma_rx_offset  = 0x2000,
+};
+
+static const struct of_device_id sh_mobile_sdhi_of_match[] = {
+       { .compatible = "renesas,sdhi-shmobile" },
+       { .compatible = "renesas,sdhi-sh7372" },
+       { .compatible = "renesas,sdhi-sh73a0", .data = &sh_mobile_sdhi_of_cfg[0], },
+       { .compatible = "renesas,sdhi-r8a73a4", .data = &sh_mobile_sdhi_of_cfg[0], },
+       { .compatible = "renesas,sdhi-r8a7740", .data = &sh_mobile_sdhi_of_cfg[0], },
+       { .compatible = "renesas,sdhi-r8a7778", .data = &of_rcar_gen1_compatible, },
+       { .compatible = "renesas,sdhi-r8a7779", .data = &of_rcar_gen1_compatible, },
+       { .compatible = "renesas,sdhi-r8a7790", .data = &of_rcar_gen2_compatible, },
+       { .compatible = "renesas,sdhi-r8a7791", .data = &of_rcar_gen2_compatible, },
+       { .compatible = "renesas,sdhi-r8a7792", .data = &of_rcar_gen2_compatible, },
+       { .compatible = "renesas,sdhi-r8a7793", .data = &of_rcar_gen2_compatible, },
+       { .compatible = "renesas,sdhi-r8a7794", .data = &of_rcar_gen2_compatible, },
+       {},
+};
+MODULE_DEVICE_TABLE(of, sh_mobile_sdhi_of_match);
+
 struct sh_mobile_sdhi {
        struct clk *clk;
        struct tmio_mmc_data mmc_data;
@@ -105,6 +138,24 @@ static int sh_mobile_sdhi_write16_hook(struct tmio_mmc_host *host, int addr)
        return 0;
 }
 
+static int sh_mobile_sdhi_multi_io_quirk(struct mmc_card *card,
+                                        unsigned int direction, int blk_size)
+{
+       /*
+        * In Renesas controllers, when performing a
+        * multiple block read of one or two blocks,
+        * depending on the timing with which the
+        * response register is read, the response
+        * value may not be read properly.
+        * Use single block read for this HW bug
+        */
+       if ((direction == MMC_DATA_READ) &&
+           blk_size == 2)
+               return 1;
+
+       return blk_size;
+}
+
 static void sh_mobile_sdhi_cd_wakeup(const struct platform_device *pdev)
 {
        mmc_detect_change(platform_get_drvdata(pdev), msecs_to_jiffies(100));
@@ -114,19 +165,6 @@ static const struct sh_mobile_sdhi_ops sdhi_ops = {
        .cd_wakeup = sh_mobile_sdhi_cd_wakeup,
 };
 
-static const struct of_device_id sh_mobile_sdhi_of_match[] = {
-       { .compatible = "renesas,sdhi-shmobile" },
-       { .compatible = "renesas,sdhi-sh7372" },
-       { .compatible = "renesas,sdhi-sh73a0", .data = &sh_mobile_sdhi_of_cfg[0], },
-       { .compatible = "renesas,sdhi-r8a73a4", .data = &sh_mobile_sdhi_of_cfg[0], },
-       { .compatible = "renesas,sdhi-r8a7740", .data = &sh_mobile_sdhi_of_cfg[0], },
-       { .compatible = "renesas,sdhi-r8a7778", .data = &sh_mobile_sdhi_of_cfg[0], },
-       { .compatible = "renesas,sdhi-r8a7779", .data = &sh_mobile_sdhi_of_cfg[0], },
-       { .compatible = "renesas,sdhi-r8a7790", .data = &sh_mobile_sdhi_of_cfg[0], },
-       {},
-};
-MODULE_DEVICE_TABLE(of, sh_mobile_sdhi_of_match);
-
 static int sh_mobile_sdhi_probe(struct platform_device *pdev)
 {
        const struct of_device_id *of_id =
@@ -173,6 +211,7 @@ static int sh_mobile_sdhi_probe(struct platform_device *pdev)
        mmc_data->clk_disable = sh_mobile_sdhi_clk_disable;
        mmc_data->capabilities = MMC_CAP_MMC_HIGHSPEED;
        mmc_data->write16_hook = sh_mobile_sdhi_write16_hook;
+       mmc_data->multi_io_quirk = sh_mobile_sdhi_multi_io_quirk;
        if (p) {
                mmc_data->flags = p->tmio_flags;
                mmc_data->ocr_mask = p->tmio_ocr_mask;
@@ -209,9 +248,27 @@ static int sh_mobile_sdhi_probe(struct platform_device *pdev)
         */
        mmc_data->flags |= TMIO_MMC_SDIO_IRQ;
 
+       /*
+        * All SDHI have CMD12 controll bit
+        */
+       mmc_data->flags |= TMIO_MMC_HAVE_CMD12_CTRL;
+
+       /*
+        * All SDHI need SDIO_INFO1 reserved bit
+        */
+       mmc_data->flags |= TMIO_MMC_SDIO_STATUS_QUIRK;
+
+       /*
+        * All SDHI have DMA control register
+        */
+       mmc_data->flags |= TMIO_MMC_HAVE_CTL_DMA_REG;
+
        if (of_id && of_id->data) {
                const struct sh_mobile_sdhi_of_data *of_data = of_id->data;
                mmc_data->flags |= of_data->tmio_flags;
+               mmc_data->capabilities |= of_data->capabilities;
+               mmc_data->capabilities2 |= of_data->capabilities2;
+               dma_priv->dma_rx_offset = of_data->dma_rx_offset;
        }
 
        /* SD control register space size is 0x100, 0x200 for bus_shift=1 */
@@ -316,10 +373,11 @@ static int sh_mobile_sdhi_remove(struct platform_device *pdev)
 }
 
 static const struct dev_pm_ops tmio_mmc_dev_pm_ops = {
-       .suspend = tmio_mmc_host_suspend,
-       .resume = tmio_mmc_host_resume,
-       .runtime_suspend = tmio_mmc_host_runtime_suspend,
-       .runtime_resume = tmio_mmc_host_runtime_resume,
+       SET_SYSTEM_SLEEP_PM_OPS(pm_runtime_force_suspend,
+                       pm_runtime_force_resume)
+       SET_PM_RUNTIME_PM_OPS(tmio_mmc_host_runtime_suspend,
+                       tmio_mmc_host_runtime_resume,
+                       NULL)
 };
 
 static struct platform_driver sh_mobile_sdhi_driver = {
index 1900abb..659028d 100644 (file)
 
 #include "tmio_mmc.h"
 
-#ifdef CONFIG_PM
-static int tmio_mmc_suspend(struct platform_device *dev, pm_message_t state)
+#ifdef CONFIG_PM_SLEEP
+static int tmio_mmc_suspend(struct device *dev)
 {
-       const struct mfd_cell *cell = mfd_get_cell(dev);
+       struct platform_device *pdev = to_platform_device(dev);
+       const struct mfd_cell *cell = mfd_get_cell(pdev);
        int ret;
 
-       ret = tmio_mmc_host_suspend(&dev->dev);
+       ret = pm_runtime_force_suspend(dev);
 
        /* Tell MFD core it can disable us now.*/
        if (!ret && cell->disable)
-               cell->disable(dev);
+               cell->disable(pdev);
 
        return ret;
 }
 
-static int tmio_mmc_resume(struct platform_device *dev)
+static int tmio_mmc_resume(struct device *dev)
 {
-       const struct mfd_cell *cell = mfd_get_cell(dev);
+       struct platform_device *pdev = to_platform_device(dev);
+       const struct mfd_cell *cell = mfd_get_cell(pdev);
        int ret = 0;
 
        /* Tell the MFD core we are ready to be enabled */
        if (cell->resume)
-               ret = cell->resume(dev);
+               ret = cell->resume(pdev);
 
        if (!ret)
-               ret = tmio_mmc_host_resume(&dev->dev);
+               ret = pm_runtime_force_resume(dev);
 
        return ret;
 }
-#else
-#define tmio_mmc_suspend NULL
-#define tmio_mmc_resume NULL
 #endif
 
 static int tmio_mmc_probe(struct platform_device *pdev)
@@ -134,15 +133,21 @@ static int tmio_mmc_remove(struct platform_device *pdev)
 
 /* ------------------- device registration ----------------------- */
 
+static const struct dev_pm_ops tmio_mmc_dev_pm_ops = {
+       SET_SYSTEM_SLEEP_PM_OPS(tmio_mmc_suspend, tmio_mmc_resume)
+       SET_PM_RUNTIME_PM_OPS(tmio_mmc_host_runtime_suspend,
+                       tmio_mmc_host_runtime_resume,
+                       NULL)
+};
+
 static struct platform_driver tmio_mmc_driver = {
        .driver = {
                .name = "tmio-mmc",
                .owner = THIS_MODULE,
+               .pm = &tmio_mmc_dev_pm_ops,
        },
        .probe = tmio_mmc_probe,
        .remove = tmio_mmc_remove,
-       .suspend = tmio_mmc_suspend,
-       .resume = tmio_mmc_resume,
 };
 
 module_platform_driver(tmio_mmc_driver);
index aaa9c7e..a34ecbe 100644 (file)
 
 struct tmio_mmc_data;
 
-/*
- * We differentiate between the following 3 power states:
- * 1. card slot powered off, controller stopped. This is used, when either there
- *    is no card in the slot, or the card really has to be powered down.
- * 2. card slot powered on, controller stopped. This is used, when a card is in
- *    the slot, but no activity is currently taking place. This is a power-
- *    saving mode with card-state preserved. This state can be entered, e.g.
- *    when MMC clock-gating is used.
- * 3. card slot powered on, controller running. This is the actual active state.
- */
-enum tmio_mmc_power {
-       TMIO_MMC_OFF_STOP,      /* card power off, controller stopped */
-       TMIO_MMC_ON_STOP,       /* card power on, controller stopped */
-       TMIO_MMC_ON_RUN,        /* card power on, controller running */
-};
-
 struct tmio_mmc_host {
        void __iomem *ctl;
        struct mmc_command      *cmd;
@@ -63,9 +47,6 @@ struct tmio_mmc_host {
        struct mmc_data         *data;
        struct mmc_host         *mmc;
 
-       /* Controller and card power state */
-       enum tmio_mmc_power     power;
-
        /* Callbacks for clock / power control */
        void (*set_pwr)(struct platform_device *host, int state);
        void (*set_clk_div)(struct platform_device *host, int state);
@@ -92,15 +73,16 @@ struct tmio_mmc_host {
        struct delayed_work     delayed_reset_work;
        struct work_struct      done;
 
-       /* Cache IRQ mask */
+       /* Cache */
        u32                     sdcard_irq_mask;
        u32                     sdio_irq_mask;
+       unsigned int            clk_cache;
 
        spinlock_t              lock;           /* protect host private data */
        unsigned long           last_req_ts;
        struct mutex            ios_lock;       /* protect set_ios() context */
        bool                    native_hotplug;
-       bool                    resuming;
+       bool                    sdio_irq_enabled;
 };
 
 int tmio_mmc_host_probe(struct tmio_mmc_host **host,
@@ -163,15 +145,9 @@ static inline void tmio_mmc_abort_dma(struct tmio_mmc_host *host)
 #endif
 
 #ifdef CONFIG_PM
-int tmio_mmc_host_suspend(struct device *dev);
-int tmio_mmc_host_resume(struct device *dev);
-#else
-#define tmio_mmc_host_suspend NULL
-#define tmio_mmc_host_resume NULL
-#endif
-
 int tmio_mmc_host_runtime_suspend(struct device *dev);
 int tmio_mmc_host_runtime_resume(struct device *dev);
+#endif
 
 static inline u16 sd_ctrl_read16(struct tmio_mmc_host *host, int addr)
 {
index 03e7b28..7d07738 100644 (file)
@@ -28,10 +28,8 @@ void tmio_mmc_enable_dma(struct tmio_mmc_host *host, bool enable)
        if (!host->chan_tx || !host->chan_rx)
                return;
 
-#if defined(CONFIG_SUPERH) || defined(CONFIG_ARCH_SHMOBILE)
-       /* Switch DMA mode on or off - SuperH specific? */
-       sd_ctrl_write16(host, CTL_DMA_ENABLE, enable ? 2 : 0);
-#endif
+       if (host->pdata->flags & TMIO_MMC_HAVE_CTL_DMA_REG)
+               sd_ctrl_write16(host, CTL_DMA_ENABLE, enable ? 2 : 0);
 }
 
 void tmio_mmc_abort_dma(struct tmio_mmc_host *host)
@@ -294,6 +292,7 @@ void tmio_mmc_request_dma(struct tmio_mmc_host *host, struct tmio_mmc_data *pdat
                        cfg.slave_id = pdata->dma->slave_id_tx;
                cfg.direction = DMA_MEM_TO_DEV;
                cfg.dst_addr = res->start + (CTL_SD_DATA_PORT << host->pdata->bus_shift);
+               cfg.dst_addr_width = DMA_SLAVE_BUSWIDTH_2_BYTES;
                cfg.src_addr = 0;
                ret = dmaengine_slave_config(host->chan_tx, &cfg);
                if (ret < 0)
@@ -311,7 +310,8 @@ void tmio_mmc_request_dma(struct tmio_mmc_host *host, struct tmio_mmc_data *pdat
                if (pdata->dma->chan_priv_rx)
                        cfg.slave_id = pdata->dma->slave_id_rx;
                cfg.direction = DMA_DEV_TO_MEM;
-               cfg.src_addr = cfg.dst_addr;
+               cfg.src_addr = cfg.dst_addr + pdata->dma->dma_rx_offset;
+               cfg.src_addr_width = DMA_SLAVE_BUSWIDTH_2_BYTES;
                cfg.dst_addr = 0;
                ret = dmaengine_slave_config(host->chan_rx, &cfg);
                if (ret < 0)
index 8d8abf2..e487ba4 100644 (file)
@@ -44,6 +44,7 @@
 #include <linux/pm_qos.h>
 #include <linux/pm_runtime.h>
 #include <linux/regulator/consumer.h>
+#include <linux/mmc/sdio.h>
 #include <linux/scatterlist.h>
 #include <linux/spinlock.h>
 #include <linux/workqueue.h>
@@ -129,19 +130,28 @@ static void tmio_mmc_enable_sdio_irq(struct mmc_host *mmc, int enable)
 {
        struct tmio_mmc_host *host = mmc_priv(mmc);
 
-       if (enable) {
+       if (enable && !host->sdio_irq_enabled) {
+               /* Keep device active while SDIO irq is enabled */
+               pm_runtime_get_sync(mmc_dev(mmc));
+               host->sdio_irq_enabled = true;
+
                host->sdio_irq_mask = TMIO_SDIO_MASK_ALL &
                                        ~TMIO_SDIO_STAT_IOIRQ;
                sd_ctrl_write16(host, CTL_TRANSACTION_CTL, 0x0001);
                sd_ctrl_write16(host, CTL_SDIO_IRQ_MASK, host->sdio_irq_mask);
-       } else {
+       } else if (!enable && host->sdio_irq_enabled) {
                host->sdio_irq_mask = TMIO_SDIO_MASK_ALL;
                sd_ctrl_write16(host, CTL_SDIO_IRQ_MASK, host->sdio_irq_mask);
                sd_ctrl_write16(host, CTL_TRANSACTION_CTL, 0x0000);
+
+               host->sdio_irq_enabled = false;
+               pm_runtime_mark_last_busy(mmc_dev(mmc));
+               pm_runtime_put_autosuspend(mmc_dev(mmc));
        }
 }
 
-static void tmio_mmc_set_clock(struct tmio_mmc_host *host, int new_clock)
+static void tmio_mmc_set_clock(struct tmio_mmc_host *host,
+                               unsigned int new_clock)
 {
        u32 clk = 0, clock;
 
@@ -149,7 +159,11 @@ static void tmio_mmc_set_clock(struct tmio_mmc_host *host, int new_clock)
                for (clock = host->mmc->f_min, clk = 0x80000080;
                        new_clock >= (clock<<1); clk >>= 1)
                        clock <<= 1;
-               clk |= 0x100;
+
+               /* 1/1 clock is option */
+               if ((host->pdata->flags & TMIO_MMC_CLK_ACTUAL) &&
+                   ((clk >> 22) & 0x1))
+                       clk |= 0xff;
        }
 
        if (host->set_clk_div)
@@ -245,6 +259,9 @@ static void tmio_mmc_reset_work(struct work_struct *work)
 
        tmio_mmc_abort_dma(host);
        mmc_request_done(host->mmc, mrq);
+
+       pm_runtime_mark_last_busy(mmc_dev(host->mmc));
+       pm_runtime_put_autosuspend(mmc_dev(host->mmc));
 }
 
 /* called with host->lock held, interrupts disabled */
@@ -274,6 +291,9 @@ static void tmio_mmc_finish_request(struct tmio_mmc_host *host)
                tmio_mmc_abort_dma(host);
 
        mmc_request_done(host->mmc, mrq);
+
+       pm_runtime_mark_last_busy(mmc_dev(host->mmc));
+       pm_runtime_put_autosuspend(mmc_dev(host->mmc));
 }
 
 static void tmio_mmc_done_work(struct work_struct *work)
@@ -295,6 +315,7 @@ static void tmio_mmc_done_work(struct work_struct *work)
 #define TRANSFER_READ  0x1000
 #define TRANSFER_MULTI 0x2000
 #define SECURITY_CMD   0x4000
+#define NO_CMD12_ISSUE 0x4000 /* TMIO_MMC_HAVE_CMD12_CTRL */
 
 static int tmio_mmc_start_command(struct tmio_mmc_host *host, struct mmc_command *cmd)
 {
@@ -331,6 +352,14 @@ static int tmio_mmc_start_command(struct tmio_mmc_host *host, struct mmc_command
                if (data->blocks > 1) {
                        sd_ctrl_write16(host, CTL_STOP_INTERNAL_ACTION, 0x100);
                        c |= TRANSFER_MULTI;
+
+                       /*
+                        * Disable auto CMD12 at IO_RW_EXTENDED when
+                        * multiple block transfer
+                        */
+                       if ((host->pdata->flags & TMIO_MMC_HAVE_CMD12_CTRL) &&
+                           (cmd->opcode == SD_IO_RW_EXTENDED))
+                               c |= NO_CMD12_ISSUE;
                }
                if (data->flags & MMC_DATA_READ)
                        c |= TRANSFER_READ;
@@ -347,6 +376,40 @@ static int tmio_mmc_start_command(struct tmio_mmc_host *host, struct mmc_command
        return 0;
 }
 
+static void tmio_mmc_transfer_data(struct tmio_mmc_host *host,
+                                  unsigned short *buf,
+                                  unsigned int count)
+{
+       int is_read = host->data->flags & MMC_DATA_READ;
+       u8  *buf8;
+
+       /*
+        * Transfer the data
+        */
+       if (is_read)
+               sd_ctrl_read16_rep(host, CTL_SD_DATA_PORT, buf, count >> 1);
+       else
+               sd_ctrl_write16_rep(host, CTL_SD_DATA_PORT, buf, count >> 1);
+
+       /* if count was even number */
+       if (!(count & 0x1))
+               return;
+
+       /* if count was odd number */
+       buf8 = (u8 *)(buf + (count >> 1));
+
+       /*
+        * FIXME
+        *
+        * driver and this function are assuming that
+        * it is used as little endian
+        */
+       if (is_read)
+               *buf8 = sd_ctrl_read16(host, CTL_SD_DATA_PORT) & 0xff;
+       else
+               sd_ctrl_write16(host, CTL_SD_DATA_PORT, *buf8);
+}
+
 /*
  * This chip always returns (at least?) as much data as you ask for.
  * I'm unsure what happens if you ask for less than a block. This should be
@@ -379,10 +442,7 @@ static void tmio_mmc_pio_irq(struct tmio_mmc_host *host)
                 count, host->sg_off, data->flags);
 
        /* Transfer the data */
-       if (data->flags & MMC_DATA_READ)
-               sd_ctrl_read16_rep(host, CTL_SD_DATA_PORT, buf, count >> 1);
-       else
-               sd_ctrl_write16_rep(host, CTL_SD_DATA_PORT, buf, count >> 1);
+       tmio_mmc_transfer_data(host, buf, count);
 
        host->sg_off += count;
 
@@ -465,6 +525,9 @@ static void tmio_mmc_data_irq(struct tmio_mmc_host *host)
                goto out;
 
        if (host->chan_tx && (data->flags & MMC_DATA_WRITE) && !host->force_pio) {
+               u32 status = sd_ctrl_read32(host, CTL_STATUS);
+               bool done = false;
+
                /*
                 * Has all data been written out yet? Testing on SuperH showed,
                 * that in most cases the first interrupt comes already with the
@@ -473,7 +536,15 @@ static void tmio_mmc_data_irq(struct tmio_mmc_host *host)
                 * DATAEND interrupt with the BUSY bit set, in this cases
                 * waiting for one more interrupt fixes the problem.
                 */
-               if (!(sd_ctrl_read32(host, CTL_STATUS) & TMIO_STAT_CMD_BUSY)) {
+               if (host->pdata->flags & TMIO_MMC_HAS_IDLE_WAIT) {
+                       if (status & TMIO_STAT_ILL_FUNC)
+                               done = true;
+               } else {
+                       if (!(status & TMIO_STAT_CMD_BUSY))
+                               done = true;
+               }
+
+               if (done) {
                        tmio_mmc_disable_mmc_irqs(host, TMIO_STAT_DATAEND);
                        tasklet_schedule(&host->dma_complete);
                }
@@ -557,6 +628,9 @@ static void tmio_mmc_card_irq_status(struct tmio_mmc_host *host,
 
        pr_debug_status(*status);
        pr_debug_status(*ireg);
+
+       /* Clear the status except the interrupt status */
+       sd_ctrl_write32(host, CTL_STATUS, TMIO_MASK_IRQ);
 }
 
 static bool __tmio_mmc_card_detect_irq(struct tmio_mmc_host *host,
@@ -637,6 +711,7 @@ irqreturn_t tmio_mmc_sdio_irq(int irq, void *devid)
        struct mmc_host *mmc = host->mmc;
        struct tmio_mmc_data *pdata = host->pdata;
        unsigned int ireg, status;
+       unsigned int sdio_status;
 
        if (!(pdata->flags & TMIO_MMC_SDIO_IRQ))
                return IRQ_HANDLED;
@@ -644,7 +719,11 @@ irqreturn_t tmio_mmc_sdio_irq(int irq, void *devid)
        status = sd_ctrl_read16(host, CTL_SDIO_STATUS);
        ireg = status & TMIO_SDIO_MASK_ALL & ~host->sdcard_irq_mask;
 
-       sd_ctrl_write16(host, CTL_SDIO_STATUS, status & ~TMIO_SDIO_MASK_ALL);
+       sdio_status = status & ~TMIO_SDIO_MASK_ALL;
+       if (pdata->flags & TMIO_MMC_SDIO_STATUS_QUIRK)
+               sdio_status |= 6;
+
+       sd_ctrl_write16(host, CTL_SDIO_STATUS, sdio_status);
 
        if (mmc->caps & MMC_CAP_SDIO_IRQ && ireg & TMIO_SDIO_STAT_IOIRQ)
                mmc_signal_sdio_irq(mmc);
@@ -728,6 +807,8 @@ static void tmio_mmc_request(struct mmc_host *mmc, struct mmc_request *mrq)
 
        spin_unlock_irqrestore(&host->lock, flags);
 
+       pm_runtime_get_sync(mmc_dev(mmc));
+
        if (mrq->data) {
                ret = tmio_mmc_start_data(host, mrq->data);
                if (ret)
@@ -746,11 +827,14 @@ fail:
        host->mrq = NULL;
        mrq->cmd->error = ret;
        mmc_request_done(mmc, mrq);
+
+       pm_runtime_mark_last_busy(mmc_dev(mmc));
+       pm_runtime_put_autosuspend(mmc_dev(mmc));
 }
 
-static int tmio_mmc_clk_update(struct mmc_host *mmc)
+static int tmio_mmc_clk_update(struct tmio_mmc_host *host)
 {
-       struct tmio_mmc_host *host = mmc_priv(mmc);
+       struct mmc_host *mmc = host->mmc;
        struct tmio_mmc_data *pdata = host->pdata;
        int ret;
 
@@ -812,6 +896,19 @@ static void tmio_mmc_power_off(struct tmio_mmc_host *host)
                host->set_pwr(host->pdev, 0);
 }
 
+static void tmio_mmc_set_bus_width(struct tmio_mmc_host *host,
+                               unsigned char bus_width)
+{
+       switch (bus_width) {
+       case MMC_BUS_WIDTH_1:
+               sd_ctrl_write16(host, CTL_SD_MEM_CARD_OPT, 0x80e0);
+               break;
+       case MMC_BUS_WIDTH_4:
+               sd_ctrl_write16(host, CTL_SD_MEM_CARD_OPT, 0x00e0);
+               break;
+       }
+}
+
 /* Set MMC clock / power.
  * Note: This controller uses a simple divider scheme therefore it cannot
  * run a MMC card at full speed (20MHz). The max clock is 24MHz on SD, but as
@@ -824,6 +921,8 @@ static void tmio_mmc_set_ios(struct mmc_host *mmc, struct mmc_ios *ios)
        struct device *dev = &host->pdev->dev;
        unsigned long flags;
 
+       pm_runtime_get_sync(mmc_dev(mmc));
+
        mutex_lock(&host->ios_lock);
 
        spin_lock_irqsave(&host->lock, flags);
@@ -850,60 +949,22 @@ static void tmio_mmc_set_ios(struct mmc_host *mmc, struct mmc_ios *ios)
 
        spin_unlock_irqrestore(&host->lock, flags);
 
-       /*
-        * host->power toggles between false and true in both cases - either
-        * or not the controller can be runtime-suspended during inactivity.
-        * But if the controller has to be kept on, the runtime-pm usage_count
-        * is kept positive, so no suspending actually takes place.
-        */
-       if (ios->power_mode == MMC_POWER_ON && ios->clock) {
-               if (host->power != TMIO_MMC_ON_RUN) {
-                       tmio_mmc_clk_update(mmc);
-                       pm_runtime_get_sync(dev);
-                       if (host->resuming) {
-                               tmio_mmc_reset(host);
-                               host->resuming = false;
-                       }
-               }
-               if (host->power == TMIO_MMC_OFF_STOP)
-                       tmio_mmc_reset(host);
+       switch (ios->power_mode) {
+       case MMC_POWER_OFF:
+               tmio_mmc_power_off(host);
+               tmio_mmc_clk_stop(host);
+               break;
+       case MMC_POWER_UP:
                tmio_mmc_set_clock(host, ios->clock);
-               if (host->power == TMIO_MMC_OFF_STOP)
-                       /* power up SD card and the bus */
-                       tmio_mmc_power_on(host, ios->vdd);
-               host->power = TMIO_MMC_ON_RUN;
-               /* start bus clock */
+               tmio_mmc_power_on(host, ios->vdd);
                tmio_mmc_clk_start(host);
-       } else if (ios->power_mode != MMC_POWER_UP) {
-               struct tmio_mmc_data *pdata = host->pdata;
-               unsigned int old_power = host->power;
-
-               if (old_power != TMIO_MMC_OFF_STOP) {
-                       if (ios->power_mode == MMC_POWER_OFF) {
-                               tmio_mmc_power_off(host);
-                               host->power = TMIO_MMC_OFF_STOP;
-                       } else {
-                               host->power = TMIO_MMC_ON_STOP;
-                       }
-               }
-
-               if (old_power == TMIO_MMC_ON_RUN) {
-                       tmio_mmc_clk_stop(host);
-                       pm_runtime_put(dev);
-                       if (pdata->clk_disable)
-                               pdata->clk_disable(host->pdev);
-               }
-       }
-
-       if (host->power != TMIO_MMC_OFF_STOP) {
-               switch (ios->bus_width) {
-               case MMC_BUS_WIDTH_1:
-                       sd_ctrl_write16(host, CTL_SD_MEM_CARD_OPT, 0x80e0);
+               tmio_mmc_set_bus_width(host, ios->bus_width);
                break;
-               case MMC_BUS_WIDTH_4:
-                       sd_ctrl_write16(host, CTL_SD_MEM_CARD_OPT, 0x00e0);
+       case MMC_POWER_ON:
+               tmio_mmc_set_clock(host, ios->clock);
+               tmio_mmc_clk_start(host);
+               tmio_mmc_set_bus_width(host, ios->bus_width);
                break;
-               }
        }
 
        /* Let things settle. delay taken from winCE driver */
@@ -915,7 +976,12 @@ static void tmio_mmc_set_ios(struct mmc_host *mmc, struct mmc_ios *ios)
                        ios->clock, ios->power_mode);
        host->mrq = NULL;
 
+       host->clk_cache = ios->clock;
+
        mutex_unlock(&host->ios_lock);
+
+       pm_runtime_mark_last_busy(mmc_dev(mmc));
+       pm_runtime_put_autosuspend(mmc_dev(mmc));
 }
 
 static int tmio_mmc_get_ro(struct mmc_host *mmc)
@@ -926,8 +992,25 @@ static int tmio_mmc_get_ro(struct mmc_host *mmc)
        if (ret >= 0)
                return ret;
 
-       return !((pdata->flags & TMIO_MMC_WRPROTECT_DISABLE) ||
-                (sd_ctrl_read32(host, CTL_STATUS) & TMIO_STAT_WRPROTECT));
+       pm_runtime_get_sync(mmc_dev(mmc));
+       ret = !((pdata->flags & TMIO_MMC_WRPROTECT_DISABLE) ||
+               (sd_ctrl_read32(host, CTL_STATUS) & TMIO_STAT_WRPROTECT));
+       pm_runtime_mark_last_busy(mmc_dev(mmc));
+       pm_runtime_put_autosuspend(mmc_dev(mmc));
+
+       return ret;
+}
+
+static int tmio_multi_io_quirk(struct mmc_card *card,
+                              unsigned int direction, int blk_size)
+{
+       struct tmio_mmc_host *host = mmc_priv(card->host);
+       struct tmio_mmc_data *pdata = host->pdata;
+
+       if (pdata->multi_io_quirk)
+               return pdata->multi_io_quirk(card, direction, blk_size);
+
+       return blk_size;
 }
 
 static const struct mmc_host_ops tmio_mmc_ops = {
@@ -936,6 +1019,7 @@ static const struct mmc_host_ops tmio_mmc_ops = {
        .get_ro         = tmio_mmc_get_ro,
        .get_cd         = mmc_gpio_get_cd,
        .enable_sdio_irq = tmio_mmc_enable_sdio_irq,
+       .multi_io_quirk = tmio_multi_io_quirk,
 };
 
 static int tmio_mmc_init_ocr(struct tmio_mmc_host *host)
@@ -1032,28 +1116,23 @@ int tmio_mmc_host_probe(struct tmio_mmc_host **host,
                                  mmc->caps & MMC_CAP_NONREMOVABLE ||
                                  mmc->slot.cd_irq >= 0);
 
-       _host->power = TMIO_MMC_OFF_STOP;
-       pm_runtime_enable(&pdev->dev);
-       ret = pm_runtime_resume(&pdev->dev);
-       if (ret < 0)
-               goto pm_disable;
-
-       if (tmio_mmc_clk_update(mmc) < 0) {
+       if (tmio_mmc_clk_update(_host) < 0) {
                mmc->f_max = pdata->hclk;
                mmc->f_min = mmc->f_max / 512;
        }
 
        /*
-        * There are 4 different scenarios for the card detection:
-        *  1) an external gpio irq handles the cd (best for power savings)
-        *  2) internal sdhi irq handles the cd
-        *  3) a worker thread polls the sdhi - indicated by MMC_CAP_NEEDS_POLL
-        *  4) the medium is non-removable - indicated by MMC_CAP_NONREMOVABLE
-        *
-        *  While we increment the runtime PM counter for all scenarios when
-        *  the mmc core activates us by calling an appropriate set_ios(), we
-        *  must additionally ensure that in case 2) the tmio mmc hardware stays
-        *  powered on during runtime for the card detection to work.
+        * Check the sanity of mmc->f_min to prevent tmio_mmc_set_clock() from
+        * looping forever...
+        */
+       if (mmc->f_min == 0) {
+               ret = -EINVAL;
+               goto host_free;
+       }
+
+       /*
+        * While using internal tmio hardware logic for card detection, we need
+        * to ensure it stays powered for it to work.
         */
        if (_host->native_hotplug)
                pm_runtime_get_noresume(&pdev->dev);
@@ -1074,8 +1153,12 @@ int tmio_mmc_host_probe(struct tmio_mmc_host **host,
 
        _host->sdcard_irq_mask &= ~irq_mask;
 
-       if (pdata->flags & TMIO_MMC_SDIO_IRQ)
-               tmio_mmc_enable_sdio_irq(mmc, 0);
+       _host->sdio_irq_enabled = false;
+       if (pdata->flags & TMIO_MMC_SDIO_IRQ) {
+               _host->sdio_irq_mask = TMIO_SDIO_MASK_ALL;
+               sd_ctrl_write16(_host, CTL_SDIO_IRQ_MASK, _host->sdio_irq_mask);
+               sd_ctrl_write16(_host, CTL_TRANSACTION_CTL, 0x0000);
+       }
 
        spin_lock_init(&_host->lock);
        mutex_init(&_host->ios_lock);
@@ -1087,9 +1170,12 @@ int tmio_mmc_host_probe(struct tmio_mmc_host **host,
        /* See if we also get DMA */
        tmio_mmc_request_dma(_host, pdata);
 
+       pm_runtime_set_active(&pdev->dev);
+       pm_runtime_set_autosuspend_delay(&pdev->dev, 50);
+       pm_runtime_use_autosuspend(&pdev->dev);
+       pm_runtime_enable(&pdev->dev);
+
        ret = mmc_add_host(mmc);
-       if (pdata->clk_disable)
-               pdata->clk_disable(pdev);
        if (ret < 0) {
                tmio_mmc_host_remove(_host);
                return ret;
@@ -1109,9 +1195,6 @@ int tmio_mmc_host_probe(struct tmio_mmc_host **host,
 
        return 0;
 
-pm_disable:
-       pm_runtime_disable(&pdev->dev);
-       iounmap(_host->ctl);
 host_free:
        mmc_free_host(mmc);
 
@@ -1143,33 +1226,19 @@ void tmio_mmc_host_remove(struct tmio_mmc_host *host)
 EXPORT_SYMBOL(tmio_mmc_host_remove);
 
 #ifdef CONFIG_PM
-int tmio_mmc_host_suspend(struct device *dev)
+int tmio_mmc_host_runtime_suspend(struct device *dev)
 {
        struct mmc_host *mmc = dev_get_drvdata(dev);
        struct tmio_mmc_host *host = mmc_priv(mmc);
 
        tmio_mmc_disable_mmc_irqs(host, TMIO_MASK_ALL);
-       return 0;
-}
-EXPORT_SYMBOL(tmio_mmc_host_suspend);
-
-int tmio_mmc_host_resume(struct device *dev)
-{
-       struct mmc_host *mmc = dev_get_drvdata(dev);
-       struct tmio_mmc_host *host = mmc_priv(mmc);
 
-       tmio_mmc_enable_dma(host, true);
-
-       /* The MMC core will perform the complete set up */
-       host->resuming = true;
-       return 0;
-}
-EXPORT_SYMBOL(tmio_mmc_host_resume);
+       if (host->clk_cache)
+               tmio_mmc_clk_stop(host);
 
-#endif /* CONFIG_PM */
+       if (host->pdata->clk_disable)
+               host->pdata->clk_disable(host->pdev);
 
-int tmio_mmc_host_runtime_suspend(struct device *dev)
-{
        return 0;
 }
 EXPORT_SYMBOL(tmio_mmc_host_runtime_suspend);
@@ -1179,10 +1248,19 @@ int tmio_mmc_host_runtime_resume(struct device *dev)
        struct mmc_host *mmc = dev_get_drvdata(dev);
        struct tmio_mmc_host *host = mmc_priv(mmc);
 
+       tmio_mmc_reset(host);
+       tmio_mmc_clk_update(host);
+
+       if (host->clk_cache) {
+               tmio_mmc_set_clock(host, host->clk_cache);
+               tmio_mmc_clk_start(host);
+       }
+
        tmio_mmc_enable_dma(host, true);
 
        return 0;
 }
 EXPORT_SYMBOL(tmio_mmc_host_runtime_resume);
+#endif
 
 MODULE_LICENSE("GPL v2");
index 7751443..a19719e 100644 (file)
@@ -21,7 +21,6 @@
 #include <linux/types.h>
 #include <linux/kernel.h>
 #include <linux/sched.h>
-#include <linux/init.h>
 #include <asm/io.h>
 #include <asm/byteorder.h>
 
index 89b9d68..718244d 100644 (file)
@@ -24,7 +24,6 @@
 #include <linux/types.h>
 #include <linux/kernel.h>
 #include <linux/sched.h>
-#include <linux/init.h>
 #include <asm/io.h>
 #include <asm/byteorder.h>
 
index 096993f..8852942 100644 (file)
@@ -22,7 +22,6 @@
 #include <linux/types.h>
 #include <linux/kernel.h>
 #include <linux/sched.h>
-#include <linux/init.h>
 #include <asm/io.h>
 #include <asm/byteorder.h>
 
index ad19139..524dab3 100644 (file)
@@ -15,7 +15,6 @@
  *
  */
 
-#include <linux/init.h>
 #include <linux/err.h>
 #include <linux/errno.h>
 #include <linux/module.h>
@@ -41,7 +40,8 @@
 #define        OPCODE_WRSR             0x01    /* Write status register 1 byte */
 #define        OPCODE_NORM_READ        0x03    /* Read data bytes (low frequency) */
 #define        OPCODE_FAST_READ        0x0b    /* Read data bytes (high frequency) */
-#define        OPCODE_QUAD_READ        0x6b    /* Read data bytes */
+#define        OPCODE_DUAL_READ        0x3b    /* Read data bytes (Dual SPI) */
+#define        OPCODE_QUAD_READ        0x6b    /* Read data bytes (Quad SPI) */
 #define        OPCODE_PP               0x02    /* Page program (up to 256 bytes) */
 #define        OPCODE_BE_4K            0x20    /* Erase 4KiB block */
 #define        OPCODE_BE_4K_PMC        0xd7    /* Erase 4KiB block on PMC chips */
@@ -54,7 +54,8 @@
 /* 4-byte address opcodes - used on Spansion and some Macronix flashes. */
 #define        OPCODE_NORM_READ_4B     0x13    /* Read data bytes (low frequency) */
 #define        OPCODE_FAST_READ_4B     0x0c    /* Read data bytes (high frequency) */
-#define        OPCODE_QUAD_READ_4B     0x6c    /* Read data bytes */
+#define        OPCODE_DUAL_READ_4B     0x3c    /* Read data bytes (Dual SPI) */
+#define        OPCODE_QUAD_READ_4B     0x6c    /* Read data bytes (Quad SPI) */
 #define        OPCODE_PP_4B            0x12    /* Page program (up to 256 bytes) */
 #define        OPCODE_SE_4B            0xdc    /* Sector erase (usually 64KiB) */
 
@@ -95,6 +96,7 @@
 enum read_type {
        M25P80_NORMAL = 0,
        M25P80_FAST,
+       M25P80_DUAL,
        M25P80_QUAD,
 };
 
@@ -479,6 +481,7 @@ static inline int m25p80_dummy_cycles_read(struct m25p *flash)
 {
        switch (flash->flash_read) {
        case M25P80_FAST:
+       case M25P80_DUAL:
        case M25P80_QUAD:
                return 1;
        case M25P80_NORMAL:
@@ -492,6 +495,8 @@ static inline int m25p80_dummy_cycles_read(struct m25p *flash)
 static inline unsigned int m25p80_rx_nbits(const struct m25p *flash)
 {
        switch (flash->flash_read) {
+       case M25P80_DUAL:
+               return 2;
        case M25P80_QUAD:
                return 4;
        default:
@@ -855,7 +860,8 @@ struct flash_info {
 #define        SST_WRITE       0x04            /* use SST byte programming */
 #define        M25P_NO_FR      0x08            /* Can't do fastread */
 #define        SECT_4K_PMC     0x10            /* OPCODE_BE_4K_PMC works uniformly */
-#define        M25P80_QUAD_READ        0x20    /* Flash supports Quad Read */
+#define        M25P80_DUAL_READ        0x20    /* Flash supports Dual Read */
+#define        M25P80_QUAD_READ        0x40    /* Flash supports Quad Read */
 };
 
 #define INFO(_jedec_id, _ext_id, _sector_size, _n_sectors, _flags)     \
@@ -934,6 +940,7 @@ static const struct spi_device_id m25p_ids[] = {
        { "mx25l25635e", INFO(0xc22019, 0, 64 * 1024, 512, 0) },
        { "mx25l25655e", INFO(0xc22619, 0, 64 * 1024, 512, 0) },
        { "mx66l51235l", INFO(0xc2201a, 0, 64 * 1024, 1024, M25P80_QUAD_READ) },
+       { "mx66l1g55g",  INFO(0xc2261b, 0, 64 * 1024, 2048, M25P80_QUAD_READ) },
 
        /* Micron */
        { "n25q064",     INFO(0x20ba17, 0, 64 * 1024,  128, 0) },
@@ -953,8 +960,8 @@ static const struct spi_device_id m25p_ids[] = {
        { "s25sl032p",  INFO(0x010215, 0x4d00,  64 * 1024,  64, 0) },
        { "s25sl064p",  INFO(0x010216, 0x4d00,  64 * 1024, 128, 0) },
        { "s25fl256s0", INFO(0x010219, 0x4d00, 256 * 1024, 128, 0) },
-       { "s25fl256s1", INFO(0x010219, 0x4d01,  64 * 1024, 512, M25P80_QUAD_READ) },
-       { "s25fl512s",  INFO(0x010220, 0x4d00, 256 * 1024, 256, M25P80_QUAD_READ) },
+       { "s25fl256s1", INFO(0x010219, 0x4d01,  64 * 1024, 512, M25P80_DUAL_READ | M25P80_QUAD_READ) },
+       { "s25fl512s",  INFO(0x010220, 0x4d00, 256 * 1024, 256, M25P80_DUAL_READ | M25P80_QUAD_READ) },
        { "s70fl01gs",  INFO(0x010221, 0x4d00, 256 * 1024, 256, 0) },
        { "s25sl12800", INFO(0x012018, 0x0300, 256 * 1024,  64, 0) },
        { "s25sl12801", INFO(0x012018, 0x0301,  64 * 1024, 256, 0) },
@@ -965,6 +972,7 @@ static const struct spi_device_id m25p_ids[] = {
        { "s25sl016a",  INFO(0x010214,      0,  64 * 1024,  32, 0) },
        { "s25sl032a",  INFO(0x010215,      0,  64 * 1024,  64, 0) },
        { "s25sl064a",  INFO(0x010216,      0,  64 * 1024, 128, 0) },
+       { "s25fl008k",  INFO(0xef4014,      0,  64 * 1024,  16, SECT_4K) },
        { "s25fl016k",  INFO(0xef4015,      0,  64 * 1024,  32, SECT_4K) },
        { "s25fl064k",  INFO(0xef4017,      0,  64 * 1024, 128, SECT_4K) },
 
@@ -1072,9 +1080,8 @@ static const struct spi_device_id *jedec_probe(struct spi_device *spi)
        for (tmp = 0; tmp < ARRAY_SIZE(m25p_ids) - 1; tmp++) {
                info = (void *)m25p_ids[tmp].driver_data;
                if (info->jedec_id == jedec) {
-                       if (info->ext_id != 0 && info->ext_id != ext_jedec)
-                               continue;
-                       return &m25p_ids[tmp];
+                       if (info->ext_id == 0 || info->ext_id == ext_jedec)
+                               return &m25p_ids[tmp];
                }
        }
        dev_err(&spi->dev, "unrecognized JEDEC id %06x\n", jedec);
@@ -1226,7 +1233,7 @@ static int m25p_probe(struct spi_device *spi)
        if (info->flags & M25P_NO_FR)
                flash->flash_read = M25P80_NORMAL;
 
-       /* Quad-read mode takes precedence over fast/normal */
+       /* Quad/Dual-read mode takes precedence over fast/normal */
        if (spi->mode & SPI_RX_QUAD && info->flags & M25P80_QUAD_READ) {
                ret = set_quad_mode(flash, info->jedec_id);
                if (ret) {
@@ -1234,6 +1241,8 @@ static int m25p_probe(struct spi_device *spi)
                        return ret;
                }
                flash->flash_read = M25P80_QUAD;
+       } else if (spi->mode & SPI_RX_DUAL && info->flags & M25P80_DUAL_READ) {
+               flash->flash_read = M25P80_DUAL;
        }
 
        /* Default commands */
@@ -1241,6 +1250,9 @@ static int m25p_probe(struct spi_device *spi)
        case M25P80_QUAD:
                flash->read_opcode = OPCODE_QUAD_READ;
                break;
+       case M25P80_DUAL:
+               flash->read_opcode = OPCODE_DUAL_READ;
+               break;
        case M25P80_FAST:
                flash->read_opcode = OPCODE_FAST_READ;
                break;
@@ -1265,6 +1277,9 @@ static int m25p_probe(struct spi_device *spi)
                        case M25P80_QUAD:
                                flash->read_opcode = OPCODE_QUAD_READ_4B;
                                break;
+                       case M25P80_DUAL:
+                               flash->read_opcode = OPCODE_DUAL_READ_4B;
+                               break;
                        case M25P80_FAST:
                                flash->read_opcode = OPCODE_FAST_READ_4B;
                                break;
index 624069d..8b278d2 100644 (file)
@@ -10,7 +10,6 @@
  * 2 of the License, or (at your option) any later version.
 */
 #include <linux/module.h>
-#include <linux/init.h>
 #include <linux/slab.h>
 #include <linux/delay.h>
 #include <linux/device.h>
index 687bf27..c63ecbc 100644 (file)
@@ -15,7 +15,6 @@
  *
  */
 
-#include <linux/init.h>
 #include <linux/module.h>
 #include <linux/device.h>
 #include <linux/mutex.h>
index 4adc037..487e64f 100644 (file)
@@ -30,7 +30,6 @@
 #include <asm/uaccess.h>
 #include <linux/delay.h>
 #include <linux/slab.h>
-#include <linux/init.h>
 #include <linux/mtd/mtd.h>
 #include <linux/mtd/nftl.h>
 #include <linux/mtd/inftl.h>
index 5434d8d..6ea51e5 100644 (file)
@@ -14,7 +14,6 @@
  * Licensed under the GPL-2 or later.
  */
 
-#include <linux/init.h>
 #include <linux/kernel.h>
 #include <linux/module.h>
 #include <linux/mtd/mtd.h>
index 1adba86..a4c477b 100644 (file)
@@ -14,7 +14,6 @@
  */
 
 #include <linux/gpio.h>
-#include <linux/init.h>
 #include <linux/io.h>
 #include <linux/kernel.h>
 #include <linux/module.h>
index 46d195f..5ab71f0 100644 (file)
@@ -31,7 +31,6 @@
 #include <linux/kernel.h>
 #include <linux/slab.h>
 #include <linux/pci.h>
-#include <linux/init.h>
 #include <linux/mtd/mtd.h>
 #include <linux/mtd/map.h>
 #include <linux/mtd/partitions.h>
index d6b2451..6a589f1 100644 (file)
@@ -16,7 +16,6 @@
 #include <linux/err.h>
 #include <linux/module.h>
 #include <linux/types.h>
-#include <linux/init.h>
 #include <linux/kernel.h>
 #include <linux/string.h>
 #include <linux/slab.h>
index 93c507a..7aa682c 100644 (file)
@@ -13,7 +13,6 @@
 #include <linux/kernel.h>
 #include <linux/io.h>
 #include <linux/slab.h>
-#include <linux/init.h>
 #include <linux/mtd/mtd.h>
 #include <linux/mtd/map.h>
 #include <linux/mtd/partitions.h>
index 98bb5d5..cadfbe0 100644 (file)
@@ -10,7 +10,6 @@
  * kind, whether express or implied.
  */
 
-#include <linux/init.h>
 #include <linux/kernel.h>
 #include <linux/module.h>
 #include <linux/mtd/mtd.h>
index 36da518..eb0242e 100644 (file)
@@ -14,7 +14,6 @@
 #include <linux/module.h>
 #include <linux/kernel.h>
 #include <linux/pci.h>
-#include <linux/init.h>
 #include <linux/slab.h>
 
 #include <linux/mtd/mtd.h>
index d111097..217c25d 100644 (file)
@@ -15,7 +15,6 @@
 
 #include <linux/module.h>
 #include <linux/types.h>
-#include <linux/init.h>
 #include <linux/device.h>
 #include <linux/mtd/mtd.h>
 #include <linux/mtd/map.h>
index 10196f5..76ace85 100644 (file)
@@ -23,7 +23,6 @@
 
 #include <linux/module.h>
 #include <linux/types.h>
-#include <linux/init.h>
 #include <linux/kernel.h>
 #include <linux/string.h>
 #include <linux/ioport.h>
index 9aad854..cb4d92e 100644 (file)
@@ -13,7 +13,6 @@
 #include <linux/types.h>
 #include <linux/slab.h>
 #include <linux/kernel.h>
-#include <linux/init.h>
 #include <linux/platform_device.h>
 #include <linux/mtd/mtd.h>
 #include <linux/mtd/map.h>
index 9352512..146b604 100644 (file)
@@ -13,7 +13,6 @@
 #include <linux/module.h>
 #include <linux/types.h>
 #include <linux/kernel.h>
-#include <linux/init.h>
 #include <linux/slab.h>
 #include <linux/device.h>
 #include <linux/platform_device.h>
index 3051c4c..b7a22a6 100644 (file)
@@ -47,7 +47,6 @@
 #include <linux/module.h>
 #include <linux/types.h>
 #include <linux/kernel.h>
-#include <linux/init.h>
 #include <asm/io.h>
 #include <linux/mtd/mtd.h>
 #include <linux/mtd/map.h>
index 39cc418..b6f1aac 100644 (file)
@@ -11,7 +11,6 @@
 #include <linux/module.h>
 #include <linux/fs.h>
 #include <linux/errno.h>
-#include <linux/init.h>
 #include <linux/ioport.h>
 #include <linux/of.h>
 #include <linux/of_device.h>
index 5073cbc..0b2ccb6 100644 (file)
@@ -30,7 +30,6 @@
 #include <linux/blkpg.h>
 #include <linux/spinlock.h>
 #include <linux/hdreg.h>
-#include <linux/init.h>
 #include <linux/mutex.h>
 #include <asm/uaccess.h>
 
index 8611eb4..4936e9e 100644 (file)
@@ -17,7 +17,6 @@
  */
 
 #include <linux/slab.h>
-#include <linux/init.h>
 #include <linux/module.h>
 #include <linux/delay.h>
 #include <linux/mtd/mtd.h>
index 2880d88..7d84c4e 100644 (file)
@@ -11,7 +11,6 @@
 
 #include <linux/slab.h>
 #include <linux/gpio.h>
-#include <linux/init.h>
 #include <linux/module.h>
 #include <linux/interrupt.h>
 #include <linux/mtd/mtd.h>
index 94f55db..b7a2494 100644 (file)
@@ -37,7 +37,6 @@
 
 #include <linux/module.h>
 #include <linux/types.h>
-#include <linux/init.h>
 #include <linux/kernel.h>
 #include <linux/string.h>
 #include <linux/ioport.h>
index a4989ec..4f5f322 100644 (file)
@@ -24,7 +24,6 @@
  */
 
 #include <linux/kernel.h>
-#include <linux/init.h>
 #include <linux/module.h>
 #include <linux/platform_device.h>
 #include <linux/err.h>
index c09ab95..545a5c0 100644 (file)
@@ -24,7 +24,6 @@
 
 #include <linux/module.h>
 #include <linux/types.h>
-#include <linux/init.h>
 #include <linux/kernel.h>
 #include <linux/string.h>
 #include <linux/ioport.h>
index 90ca7e7..f8c77e3 100644 (file)
@@ -22,7 +22,6 @@
 
 #include <linux/module.h>
 #include <linux/types.h>
-#include <linux/init.h>
 #include <linux/kernel.h>
 #include <linux/of_address.h>
 #include <linux/slab.h>
index 8e6148a..117ce33 100644 (file)
@@ -18,7 +18,6 @@
 
 #include <linux/kernel.h>
 #include <linux/err.h>
-#include <linux/init.h>
 #include <linux/slab.h>
 #include <linux/module.h>
 #include <linux/platform_device.h>
index 31ee7cf..e78841a 100644 (file)
@@ -30,7 +30,6 @@
 #include <linux/gfp.h>
 #include <linux/delay.h>
 #include <linux/err.h>
-#include <linux/init.h>
 #include <linux/interrupt.h>
 #include <linux/io.h>
 #include <linux/mtd/mtd.h>
index 7360f78..1cb55dc 100644 (file)
@@ -10,7 +10,6 @@
  */
 
 #include <linux/slab.h>
-#include <linux/init.h>
 #include <linux/module.h>
 #include <linux/interrupt.h>
 #include <linux/io.h>
index 90f871a..2c98f9d 100644 (file)
@@ -23,7 +23,6 @@
 #undef DEBUG
 
 #include <linux/slab.h>
-#include <linux/init.h>
 #include <linux/module.h>
 #include <linux/mtd/mtd.h>
 #include <linux/mtd/nand.h>
index f0918e7..79acbb8 100644 (file)
@@ -29,7 +29,6 @@
 
 #include <linux/module.h>
 #include <linux/types.h>
-#include <linux/init.h>
 #include <linux/kernel.h>
 #include <linux/string.h>
 #include <linux/io.h>
index 8e1919b..093c29a 100644 (file)
@@ -13,7 +13,6 @@
  */
 
 #include <linux/module.h>
-#include <linux/init.h>
 #include <linux/slab.h>
 #include <linux/platform_device.h>
 #include <linux/mtd/mtd.h>
index 6547c84..d945473 100644 (file)
@@ -25,7 +25,6 @@
 
 #include <linux/device.h>
 #include <linux/module.h>
-#include <linux/init.h>
 #include <linux/mtd/mtd.h>
 #include <linux/mtd/onenand.h>
 #include <linux/mtd/partitions.h>
index 1de33b5..531ccbc 100644 (file)
@@ -24,7 +24,6 @@
 #include <linux/module.h>
 #include <linux/moduleparam.h>
 #include <linux/slab.h>
-#include <linux/init.h>
 #include <linux/sched.h>
 #include <linux/delay.h>
 #include <linux/interrupt.h>
index c818a63..111ee46 100644 (file)
@@ -1,6 +1,5 @@
 #define pr_fmt(fmt) "mtd_test: " fmt
 
-#include <linux/init.h>
 #include <linux/module.h>
 #include <linux/sched.h>
 #include <linux/printk.h>
index 8ea6297..4176322 100644 (file)
@@ -22,7 +22,6 @@
 #ifndef __UBI_UBI_H__
 #define __UBI_UBI_H__
 
-#include <linux/init.h>
 #include <linux/types.h>
 #include <linux/list.h>
 #include <linux/rbtree.h>
index ff2ba86..833ee8c 100644 (file)
@@ -46,7 +46,7 @@ config CAN_EMS_PCI
 config CAN_PEAK_PCMCIA
        tristate "PEAK PCAN-PC Card"
        depends on PCMCIA
-       depends on HAS_IOPORT
+       depends on HAS_IOPORT_MAP
        ---help---
          This driver is for the PCAN-PC Card PCMCIA adapter (1 or 2 channels)
          from PEAK-System (http://www.peak-system.com). To compile this
index 65b735d..afaab4b 100644 (file)
@@ -66,7 +66,7 @@ config PCMCIA_3C589
 
 config VORTEX
        tristate "3c590/3c900 series (592/595/597) \"Vortex/Boomerang\" support"
-       depends on (PCI || EISA) && HAS_IOPORT
+       depends on (PCI || EISA) && HAS_IOPORT_MAP
        select MII
        ---help---
          This option enables driver support for a large number of 10Mbps and
index 9e757c7..196e98a 100644 (file)
@@ -5,6 +5,7 @@
 config SH_ETH
        tristate "Renesas SuperH Ethernet support"
        depends on HAS_DMA
+       depends on ARCH_SHMOBILE || SUPERH || COMPILE_TEST
        select CRC32
        select MII
        select MDIO_BITBANG
index 957f0ff..177d263 100644 (file)
@@ -1,8 +1,9 @@
 /*  SuperH Ethernet device driver
  *
  *  Copyright (C) 2006-2012 Nobuhiro Iwamatsu
- *  Copyright (C) 2008-2013 Renesas Solutions Corp.
- *  Copyright (C) 2013 Cogent Embedded, Inc.
+ *  Copyright (C) 2008-2014 Renesas Solutions Corp.
+ *  Copyright (C) 2013-2014 Cogent Embedded, Inc.
+ *  Copyright (C) 2014 Codethink Limited
  *
  *  This program is free software; you can redistribute it and/or modify it
  *  under the terms and conditions of the GNU General Public License,
 #include <linux/platform_device.h>
 #include <linux/mdio-bitbang.h>
 #include <linux/netdevice.h>
+#include <linux/of.h>
+#include <linux/of_device.h>
+#include <linux/of_irq.h>
+#include <linux/of_net.h>
 #include <linux/phy.h>
 #include <linux/cache.h>
 #include <linux/io.h>
@@ -36,6 +41,7 @@
 #include <linux/if_vlan.h>
 #include <linux/clk.h>
 #include <linux/sh_eth.h>
+#include <linux/of_mdio.h>
 
 #include "sh_eth.h"
 
@@ -415,7 +421,8 @@ static void sh_eth_select_mii(struct net_device *ndev)
                value = 0x0;
                break;
        default:
-               pr_warn("PHY interface mode was not setup. Set to MII.\n");
+               netdev_warn(ndev,
+                           "PHY interface mode was not setup. Set to MII.\n");
                value = 0x1;
                break;
        }
@@ -862,7 +869,7 @@ static int sh_eth_check_reset(struct net_device *ndev)
                cnt--;
        }
        if (cnt <= 0) {
-               pr_err("Device reset failed\n");
+               netdev_err(ndev, "Device reset failed\n");
                ret = -ETIMEDOUT;
        }
        return ret;
@@ -880,7 +887,7 @@ static int sh_eth_reset(struct net_device *ndev)
 
                ret = sh_eth_check_reset(ndev);
                if (ret)
-                       goto out;
+                       return ret;
 
                /* Table Init */
                sh_eth_write(ndev, 0x0, TDLAR);
@@ -907,7 +914,6 @@ static int sh_eth_reset(struct net_device *ndev)
                             EDMR);
        }
 
-out:
        return ret;
 }
 
@@ -1088,20 +1094,16 @@ static void sh_eth_ring_free(struct net_device *ndev)
 
        /* Free Rx skb ringbuffer */
        if (mdp->rx_skbuff) {
-               for (i = 0; i < mdp->num_rx_ring; i++) {
-                       if (mdp->rx_skbuff[i])
-                               dev_kfree_skb(mdp->rx_skbuff[i]);
-               }
+               for (i = 0; i < mdp->num_rx_ring; i++)
+                       dev_kfree_skb(mdp->rx_skbuff[i]);
        }
        kfree(mdp->rx_skbuff);
        mdp->rx_skbuff = NULL;
 
        /* Free Tx skb ringbuffer */
        if (mdp->tx_skbuff) {
-               for (i = 0; i < mdp->num_tx_ring; i++) {
-                       if (mdp->tx_skbuff[i])
-                               dev_kfree_skb(mdp->tx_skbuff[i]);
-               }
+               for (i = 0; i < mdp->num_tx_ring; i++)
+                       dev_kfree_skb(mdp->tx_skbuff[i]);
        }
        kfree(mdp->tx_skbuff);
        mdp->tx_skbuff = NULL;
@@ -1271,7 +1273,7 @@ static int sh_eth_dev_init(struct net_device *ndev, bool start)
        /* Soft Reset */
        ret = sh_eth_reset(ndev);
        if (ret)
-               goto out;
+               return ret;
 
        if (mdp->cd->rmiimode)
                sh_eth_write(ndev, 0x1, RMIIMODE);
@@ -1350,7 +1352,6 @@ static int sh_eth_dev_init(struct net_device *ndev, bool start)
                netif_start_queue(ndev);
        }
 
-out:
        return ret;
 }
 
@@ -1394,7 +1395,6 @@ static int sh_eth_rx(struct net_device *ndev, u32 intr_status, int *quota)
        int entry = mdp->cur_rx % mdp->num_rx_ring;
        int boguscnt = (mdp->dirty_rx + mdp->num_rx_ring) - mdp->cur_rx;
        struct sk_buff *skb;
-       int exceeded = 0;
        u16 pkt_len = 0;
        u32 desc_status;
 
@@ -1406,10 +1406,9 @@ static int sh_eth_rx(struct net_device *ndev, u32 intr_status, int *quota)
                if (--boguscnt < 0)
                        break;
 
-               if (*quota <= 0) {
-                       exceeded = 1;
+               if (*quota <= 0)
                        break;
-               }
+
                (*quota)--;
 
                if (!(desc_status & RDFEND))
@@ -1457,7 +1456,6 @@ static int sh_eth_rx(struct net_device *ndev, u32 intr_status, int *quota)
                        ndev->stats.rx_packets++;
                        ndev->stats.rx_bytes += pkt_len;
                }
-               rxdesc->status |= cpu_to_edmac(mdp, RD_RACT);
                entry = (++mdp->cur_rx) % mdp->num_rx_ring;
                rxdesc = &mdp->rx_ring[entry];
        }
@@ -1503,7 +1501,7 @@ static int sh_eth_rx(struct net_device *ndev, u32 intr_status, int *quota)
                sh_eth_write(ndev, EDRRR_R, EDRRR);
        }
 
-       return exceeded;
+       return *quota <= 0;
 }
 
 static void sh_eth_rcv_snd_disable(struct net_device *ndev)
@@ -1564,8 +1562,7 @@ ignore_link:
                /* Unused write back interrupt */
                if (intr_status & EESR_TABT) {  /* Transmit Abort int */
                        ndev->stats.tx_aborted_errors++;
-                       if (netif_msg_tx_err(mdp))
-                               dev_err(&ndev->dev, "Transmit Abort\n");
+                       netif_err(mdp, tx_err, ndev, "Transmit Abort\n");
                }
        }
 
@@ -1574,45 +1571,38 @@ ignore_link:
                if (intr_status & EESR_RFRMER) {
                        /* Receive Frame Overflow int */
                        ndev->stats.rx_frame_errors++;
-                       if (netif_msg_rx_err(mdp))
-                               dev_err(&ndev->dev, "Receive Abort\n");
+                       netif_err(mdp, rx_err, ndev, "Receive Abort\n");
                }
        }
 
        if (intr_status & EESR_TDE) {
                /* Transmit Descriptor Empty int */
                ndev->stats.tx_fifo_errors++;
-               if (netif_msg_tx_err(mdp))
-                       dev_err(&ndev->dev, "Transmit Descriptor Empty\n");
+               netif_err(mdp, tx_err, ndev, "Transmit Descriptor Empty\n");
        }
 
        if (intr_status & EESR_TFE) {
                /* FIFO under flow */
                ndev->stats.tx_fifo_errors++;
-               if (netif_msg_tx_err(mdp))
-                       dev_err(&ndev->dev, "Transmit FIFO Under flow\n");
+               netif_err(mdp, tx_err, ndev, "Transmit FIFO Under flow\n");
        }
 
        if (intr_status & EESR_RDE) {
                /* Receive Descriptor Empty int */
                ndev->stats.rx_over_errors++;
-
-               if (netif_msg_rx_err(mdp))
-                       dev_err(&ndev->dev, "Receive Descriptor Empty\n");
+               netif_err(mdp, rx_err, ndev, "Receive Descriptor Empty\n");
        }
 
        if (intr_status & EESR_RFE) {
                /* Receive FIFO Overflow int */
                ndev->stats.rx_fifo_errors++;
-               if (netif_msg_rx_err(mdp))
-                       dev_err(&ndev->dev, "Receive FIFO Overflow\n");
+               netif_err(mdp, rx_err, ndev, "Receive FIFO Overflow\n");
        }
 
        if (!mdp->cd->no_ade && (intr_status & EESR_ADE)) {
                /* Address Error */
                ndev->stats.tx_fifo_errors++;
-               if (netif_msg_tx_err(mdp))
-                       dev_err(&ndev->dev, "Address Error\n");
+               netif_err(mdp, tx_err, ndev, "Address Error\n");
        }
 
        mask = EESR_TWB | EESR_TABT | EESR_ADE | EESR_TDE | EESR_TFE;
@@ -1623,9 +1613,9 @@ ignore_link:
                u32 edtrr = sh_eth_read(ndev, EDTRR);
 
                /* dmesg */
-               dev_err(&ndev->dev, "TX error. status=%8.8x cur_tx=%8.8x dirty_tx=%8.8x state=%8.8x EDTRR=%8.8x.\n",
-                       intr_status, mdp->cur_tx, mdp->dirty_tx,
-                       (u32)ndev->state, edtrr);
+               netdev_err(ndev, "TX error. status=%8.8x cur_tx=%8.8x dirty_tx=%8.8x state=%8.8x EDTRR=%8.8x.\n",
+                          intr_status, mdp->cur_tx, mdp->dirty_tx,
+                          (u32)ndev->state, edtrr);
                /* dirty buffer free */
                sh_eth_txfree(ndev);
 
@@ -1670,9 +1660,9 @@ static irqreturn_t sh_eth_interrupt(int irq, void *netdev)
                                     EESIPR);
                        __napi_schedule(&mdp->napi);
                } else {
-                       dev_warn(&ndev->dev,
-                                "ignoring interrupt, status 0x%08lx, mask 0x%08lx.\n",
-                                intr_status, intr_enable);
+                       netdev_warn(ndev,
+                                   "ignoring interrupt, status 0x%08lx, mask 0x%08lx.\n",
+                                   intr_status, intr_enable);
                }
        }
 
@@ -1771,27 +1761,42 @@ static void sh_eth_adjust_link(struct net_device *ndev)
 /* PHY init function */
 static int sh_eth_phy_init(struct net_device *ndev)
 {
+       struct device_node *np = ndev->dev.parent->of_node;
        struct sh_eth_private *mdp = netdev_priv(ndev);
-       char phy_id[MII_BUS_ID_SIZE + 3];
        struct phy_device *phydev = NULL;
 
-       snprintf(phy_id, sizeof(phy_id), PHY_ID_FMT,
-                mdp->mii_bus->id, mdp->phy_id);
-
        mdp->link = 0;
        mdp->speed = 0;
        mdp->duplex = -1;
 
        /* Try connect to PHY */
-       phydev = phy_connect(ndev, phy_id, sh_eth_adjust_link,
-                            mdp->phy_interface);
+       if (np) {
+               struct device_node *pn;
+
+               pn = of_parse_phandle(np, "phy-handle", 0);
+               phydev = of_phy_connect(ndev, pn,
+                                       sh_eth_adjust_link, 0,
+                                       mdp->phy_interface);
+
+               if (!phydev)
+                       phydev = ERR_PTR(-ENOENT);
+       } else {
+               char phy_id[MII_BUS_ID_SIZE + 3];
+
+               snprintf(phy_id, sizeof(phy_id), PHY_ID_FMT,
+                        mdp->mii_bus->id, mdp->phy_id);
+
+               phydev = phy_connect(ndev, phy_id, sh_eth_adjust_link,
+                                    mdp->phy_interface);
+       }
+
        if (IS_ERR(phydev)) {
-               dev_err(&ndev->dev, "phy_connect failed\n");
+               netdev_err(ndev, "failed to connect PHY\n");
                return PTR_ERR(phydev);
        }
 
-       dev_info(&ndev->dev, "attached PHY %d (IRQ %d) to driver %s\n",
-                phydev->addr, phydev->irq, phydev->drv->name);
+       netdev_info(ndev, "attached PHY %d (IRQ %d) to driver %s\n",
+                   phydev->addr, phydev->irq, phydev->drv->name);
 
        mdp->phydev = phydev;
 
@@ -1972,12 +1977,12 @@ static int sh_eth_set_ringparam(struct net_device *ndev,
 
        ret = sh_eth_ring_init(ndev);
        if (ret < 0) {
-               dev_err(&ndev->dev, "%s: sh_eth_ring_init failed.\n", __func__);
+               netdev_err(ndev, "%s: sh_eth_ring_init failed.\n", __func__);
                return ret;
        }
        ret = sh_eth_dev_init(ndev, false);
        if (ret < 0) {
-               dev_err(&ndev->dev, "%s: sh_eth_dev_init failed.\n", __func__);
+               netdev_err(ndev, "%s: sh_eth_dev_init failed.\n", __func__);
                return ret;
        }
 
@@ -2018,7 +2023,7 @@ static int sh_eth_open(struct net_device *ndev)
        ret = request_irq(ndev->irq, sh_eth_interrupt,
                          mdp->cd->irq_flags, ndev->name, ndev);
        if (ret) {
-               dev_err(&ndev->dev, "Can not assign IRQ number\n");
+               netdev_err(ndev, "Can not assign IRQ number\n");
                goto out_napi_off;
        }
 
@@ -2056,10 +2061,9 @@ static void sh_eth_tx_timeout(struct net_device *ndev)
 
        netif_stop_queue(ndev);
 
-       if (netif_msg_timer(mdp)) {
-               dev_err(&ndev->dev, "%s: transmit timed out, status %8.8x, resetting...\n",
-                       ndev->name, (int)sh_eth_read(ndev, EESR));
-       }
+       netif_err(mdp, timer, ndev,
+                 "transmit timed out, status %8.8x, resetting...\n",
+                 (int)sh_eth_read(ndev, EESR));
 
        /* tx_errors count up */
        ndev->stats.tx_errors++;
@@ -2069,13 +2073,11 @@ static void sh_eth_tx_timeout(struct net_device *ndev)
                rxdesc = &mdp->rx_ring[i];
                rxdesc->status = 0;
                rxdesc->addr = 0xBADF00D0;
-               if (mdp->rx_skbuff[i])
-                       dev_kfree_skb(mdp->rx_skbuff[i]);
+               dev_kfree_skb(mdp->rx_skbuff[i]);
                mdp->rx_skbuff[i] = NULL;
        }
        for (i = 0; i < mdp->num_tx_ring; i++) {
-               if (mdp->tx_skbuff[i])
-                       dev_kfree_skb(mdp->tx_skbuff[i]);
+               dev_kfree_skb(mdp->tx_skbuff[i]);
                mdp->tx_skbuff[i] = NULL;
        }
 
@@ -2094,8 +2096,7 @@ static int sh_eth_start_xmit(struct sk_buff *skb, struct net_device *ndev)
        spin_lock_irqsave(&mdp->lock, flags);
        if ((mdp->cur_tx - mdp->dirty_tx) >= (mdp->num_tx_ring - 4)) {
                if (!sh_eth_txfree(ndev)) {
-                       if (netif_msg_tx_queued(mdp))
-                               dev_warn(&ndev->dev, "TxFD exhausted.\n");
+                       netif_warn(mdp, tx_queued, ndev, "TxFD exhausted.\n");
                        netif_stop_queue(ndev);
                        spin_unlock_irqrestore(&mdp->lock, flags);
                        return NETDEV_TX_BUSY;
@@ -2112,8 +2113,8 @@ static int sh_eth_start_xmit(struct sk_buff *skb, struct net_device *ndev)
                                 skb->len + 2);
        txdesc->addr = dma_map_single(&ndev->dev, skb->data, skb->len,
                                      DMA_TO_DEVICE);
-       if (skb->len < ETHERSMALL)
-               txdesc->buffer_length = ETHERSMALL;
+       if (skb->len < ETH_ZLEN)
+               txdesc->buffer_length = ETH_ZLEN;
        else
                txdesc->buffer_length = skb->len;
 
@@ -2265,7 +2266,7 @@ static int sh_eth_tsu_busy(struct net_device *ndev)
                udelay(10);
                timeout--;
                if (timeout <= 0) {
-                       dev_err(&ndev->dev, "%s: timeout\n", __func__);
+                       netdev_err(ndev, "%s: timeout\n", __func__);
                        return -ETIMEDOUT;
                }
        }
@@ -2585,37 +2586,30 @@ static void sh_eth_tsu_init(struct sh_eth_private *mdp)
 }
 
 /* MDIO bus release function */
-static int sh_mdio_release(struct net_device *ndev)
+static int sh_mdio_release(struct sh_eth_private *mdp)
 {
-       struct mii_bus *bus = dev_get_drvdata(&ndev->dev);
-
        /* unregister mdio bus */
-       mdiobus_unregister(bus);
-
-       /* remove mdio bus info from net_device */
-       dev_set_drvdata(&ndev->dev, NULL);
+       mdiobus_unregister(mdp->mii_bus);
 
        /* free bitbang info */
-       free_mdio_bitbang(bus);
+       free_mdio_bitbang(mdp->mii_bus);
 
        return 0;
 }
 
 /* MDIO bus init function */
-static int sh_mdio_init(struct net_device *ndev, int id,
+static int sh_mdio_init(struct sh_eth_private *mdp,
                        struct sh_eth_plat_data *pd)
 {
        int ret, i;
        struct bb_info *bitbang;
-       struct sh_eth_private *mdp = netdev_priv(ndev);
+       struct platform_device *pdev = mdp->pdev;
+       struct device *dev = &mdp->pdev->dev;
 
        /* create bit control struct for PHY */
-       bitbang = devm_kzalloc(&ndev->dev, sizeof(struct bb_info),
-                              GFP_KERNEL);
-       if (!bitbang) {
-               ret = -ENOMEM;
-               goto out;
-       }
+       bitbang = devm_kzalloc(dev, sizeof(struct bb_info), GFP_KERNEL);
+       if (!bitbang)
+               return -ENOMEM;
 
        /* bitbang init */
        bitbang->addr = mdp->addr + mdp->reg_offset[PIR];
@@ -2628,44 +2622,42 @@ static int sh_mdio_init(struct net_device *ndev, int id,
 
        /* MII controller setting */
        mdp->mii_bus = alloc_mdio_bitbang(&bitbang->ctrl);
-       if (!mdp->mii_bus) {
-               ret = -ENOMEM;
-               goto out;
-       }
+       if (!mdp->mii_bus)
+               return -ENOMEM;
 
        /* Hook up MII support for ethtool */
        mdp->mii_bus->name = "sh_mii";
-       mdp->mii_bus->parent = &ndev->dev;
+       mdp->mii_bus->parent = dev;
        snprintf(mdp->mii_bus->id, MII_BUS_ID_SIZE, "%s-%x",
-                mdp->pdev->name, id);
+                pdev->name, pdev->id);
 
        /* PHY IRQ */
-       mdp->mii_bus->irq = devm_kzalloc(&ndev->dev,
-                                        sizeof(int) * PHY_MAX_ADDR,
-                                        GFP_KERNEL);
+       mdp->mii_bus->irq = devm_kmalloc_array(dev, PHY_MAX_ADDR, sizeof(int),
+                                              GFP_KERNEL);
        if (!mdp->mii_bus->irq) {
                ret = -ENOMEM;
                goto out_free_bus;
        }
 
-       for (i = 0; i < PHY_MAX_ADDR; i++)
-               mdp->mii_bus->irq[i] = PHY_POLL;
-       if (pd->phy_irq > 0)
-               mdp->mii_bus->irq[pd->phy] = pd->phy_irq;
+       /* register MDIO bus */
+       if (dev->of_node) {
+               ret = of_mdiobus_register(mdp->mii_bus, dev->of_node);
+       } else {
+               for (i = 0; i < PHY_MAX_ADDR; i++)
+                       mdp->mii_bus->irq[i] = PHY_POLL;
+               if (pd->phy_irq > 0)
+                       mdp->mii_bus->irq[pd->phy] = pd->phy_irq;
+
+               ret = mdiobus_register(mdp->mii_bus);
+       }
 
-       /* register mdio bus */
-       ret = mdiobus_register(mdp->mii_bus);
        if (ret)
                goto out_free_bus;
 
-       dev_set_drvdata(&ndev->dev, mdp->mii_bus);
-
        return 0;
 
 out_free_bus:
        free_mdio_bitbang(mdp->mii_bus);
-
-out:
        return ret;
 }
 
@@ -2690,7 +2682,6 @@ static const u16 *sh_eth_get_register_offset(int register_type)
                reg_offset = sh_eth_offset_fast_sh3_sh2;
                break;
        default:
-               pr_err("Unknown register type (%d)\n", register_type);
                break;
        }
 
@@ -2724,6 +2715,49 @@ static const struct net_device_ops sh_eth_netdev_ops_tsu = {
        .ndo_change_mtu         = eth_change_mtu,
 };
 
+#ifdef CONFIG_OF
+static struct sh_eth_plat_data *sh_eth_parse_dt(struct device *dev)
+{
+       struct device_node *np = dev->of_node;
+       struct sh_eth_plat_data *pdata;
+       const char *mac_addr;
+
+       pdata = devm_kzalloc(dev, sizeof(*pdata), GFP_KERNEL);
+       if (!pdata)
+               return NULL;
+
+       pdata->phy_interface = of_get_phy_mode(np);
+
+       mac_addr = of_get_mac_address(np);
+       if (mac_addr)
+               memcpy(pdata->mac_addr, mac_addr, ETH_ALEN);
+
+       pdata->no_ether_link =
+               of_property_read_bool(np, "renesas,no-ether-link");
+       pdata->ether_link_active_low =
+               of_property_read_bool(np, "renesas,ether-link-active-low");
+
+       return pdata;
+}
+
+static const struct of_device_id sh_eth_match_table[] = {
+       { .compatible = "renesas,gether-r8a7740", .data = &r8a7740_data },
+       { .compatible = "renesas,ether-r8a7778", .data = &r8a777x_data },
+       { .compatible = "renesas,ether-r8a7779", .data = &r8a777x_data },
+       { .compatible = "renesas,ether-r8a7790", .data = &r8a779x_data },
+       { .compatible = "renesas,ether-r8a7791", .data = &r8a779x_data },
+       { .compatible = "renesas,ether-r8a7794", .data = &r8a779x_data },
+       { .compatible = "renesas,ether-r7s72100", .data = &r7s72100_data },
+       { }
+};
+MODULE_DEVICE_TABLE(of, sh_eth_match_table);
+#else
+static inline struct sh_eth_plat_data *sh_eth_parse_dt(struct device *dev)
+{
+       return NULL;
+}
+#endif
+
 static int sh_eth_drv_probe(struct platform_device *pdev)
 {
        int ret, devno = 0;
@@ -2737,15 +2771,15 @@ static int sh_eth_drv_probe(struct platform_device *pdev)
        res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
        if (unlikely(res == NULL)) {
                dev_err(&pdev->dev, "invalid resource\n");
-               ret = -EINVAL;
-               goto out;
+               return -EINVAL;
        }
 
        ndev = alloc_etherdev(sizeof(struct sh_eth_private));
-       if (!ndev) {
-               ret = -ENOMEM;
-               goto out;
-       }
+       if (!ndev)
+               return -ENOMEM;
+
+       pm_runtime_enable(&pdev->dev);
+       pm_runtime_get_sync(&pdev->dev);
 
        /* The sh Ether-specific entries in the device structure. */
        ndev->base_addr = res->start;
@@ -2774,9 +2808,9 @@ static int sh_eth_drv_probe(struct platform_device *pdev)
 
        spin_lock_init(&mdp->lock);
        mdp->pdev = pdev;
-       pm_runtime_enable(&pdev->dev);
-       pm_runtime_resume(&pdev->dev);
 
+       if (pdev->dev.of_node)
+               pd = sh_eth_parse_dt(&pdev->dev);
        if (!pd) {
                dev_err(&pdev->dev, "no platform data\n");
                ret = -EINVAL;
@@ -2792,8 +2826,22 @@ static int sh_eth_drv_probe(struct platform_device *pdev)
        mdp->ether_link_active_low = pd->ether_link_active_low;
 
        /* set cpu data */
-       mdp->cd = (struct sh_eth_cpu_data *)id->driver_data;
+       if (id) {
+               mdp->cd = (struct sh_eth_cpu_data *)id->driver_data;
+       } else  {
+               const struct of_device_id *match;
+
+               match = of_match_device(of_match_ptr(sh_eth_match_table),
+                                       &pdev->dev);
+               mdp->cd = (struct sh_eth_cpu_data *)match->data;
+       }
        mdp->reg_offset = sh_eth_get_register_offset(mdp->cd->register_type);
+       if (!mdp->reg_offset) {
+               dev_err(&pdev->dev, "Unknown register type (%d)\n",
+                       mdp->cd->register_type);
+               ret = -EINVAL;
+               goto out_release;
+       }
        sh_eth_set_default_cpu_data(mdp->cd);
 
        /* set function */
@@ -2839,6 +2887,13 @@ static int sh_eth_drv_probe(struct platform_device *pdev)
                }
        }
 
+       /* MDIO bus init */
+       ret = sh_mdio_init(mdp, pd);
+       if (ret) {
+               dev_err(&ndev->dev, "failed to initialise MDIO\n");
+               goto out_release;
+       }
+
        netif_napi_add(ndev, &mdp->napi, sh_eth_poll, 64);
 
        /* network device register */
@@ -2846,31 +2901,26 @@ static int sh_eth_drv_probe(struct platform_device *pdev)
        if (ret)
                goto out_napi_del;
 
-       /* mdio bus init */
-       ret = sh_mdio_init(ndev, pdev->id, pd);
-       if (ret)
-               goto out_unregister;
-
        /* print device information */
-       pr_info("Base address at 0x%x, %pM, IRQ %d.\n",
-               (u32)ndev->base_addr, ndev->dev_addr, ndev->irq);
+       netdev_info(ndev, "Base address at 0x%x, %pM, IRQ %d.\n",
+                   (u32)ndev->base_addr, ndev->dev_addr, ndev->irq);
 
+       pm_runtime_put(&pdev->dev);
        platform_set_drvdata(pdev, ndev);
 
        return ret;
 
-out_unregister:
-       unregister_netdev(ndev);
-
 out_napi_del:
        netif_napi_del(&mdp->napi);
+       sh_mdio_release(mdp);
 
 out_release:
        /* net_dev free */
        if (ndev)
                free_netdev(ndev);
 
-out:
+       pm_runtime_put(&pdev->dev);
+       pm_runtime_disable(&pdev->dev);
        return ret;
 }
 
@@ -2879,9 +2929,9 @@ static int sh_eth_drv_remove(struct platform_device *pdev)
        struct net_device *ndev = platform_get_drvdata(pdev);
        struct sh_eth_private *mdp = netdev_priv(ndev);
 
-       sh_mdio_release(ndev);
        unregister_netdev(ndev);
        netif_napi_del(&mdp->napi);
+       sh_mdio_release(mdp);
        pm_runtime_disable(&pdev->dev);
        free_netdev(ndev);
 
@@ -2923,6 +2973,7 @@ static struct platform_device_id sh_eth_id_table[] = {
        { "r8a777x-ether", (kernel_ulong_t)&r8a777x_data },
        { "r8a7790-ether", (kernel_ulong_t)&r8a779x_data },
        { "r8a7791-ether", (kernel_ulong_t)&r8a779x_data },
+       { "r8a7794-ether", (kernel_ulong_t)&r8a779x_data },
        { }
 };
 MODULE_DEVICE_TABLE(platform, sh_eth_id_table);
@@ -2934,6 +2985,7 @@ static struct platform_driver sh_eth_driver = {
        .driver = {
                   .name = CARDNAME,
                   .pm = SH_ETH_PM_OPS,
+                  .of_match_table = of_match_ptr(sh_eth_match_table),
        },
 };
 
index a096b4b..b37c427 100644 (file)
@@ -27,8 +27,7 @@
 #define RX_RING_MIN    64
 #define TX_RING_MAX    1024
 #define RX_RING_MAX    1024
-#define ETHERSMALL             60
-#define PKT_BUF_SZ             1538
+#define PKT_BUF_SZ     1538
 #define SH_ETH_TSU_TIMEOUT_MS  500
 #define SH_ETH_TSU_CAM_ENTRIES 32
 
index 992bc02..692184d 100644 (file)
@@ -1,5 +1 @@
-
 obj-$(CONFIG_WIMAX_I2400M)     += i2400m/
-
-# (from Sam Ravnborg) force kbuild to create built-in.o
-obj- := dummy.o
index 3935614..ec992dc 100644 (file)
@@ -21,6 +21,7 @@
 #include <linux/cpu.h>
 #include <linux/module.h>
 #include <linux/of.h>
+#include <linux/of_graph.h>
 #include <linux/spinlock.h>
 #include <linux/slab.h>
 #include <linux/proc_fs.h>
@@ -904,6 +905,38 @@ struct device_node *of_find_node_by_phandle(phandle handle)
 EXPORT_SYMBOL(of_find_node_by_phandle);
 
 /**
+ * of_property_count_elems_of_size - Count the number of elements in a property
+ *
+ * @np:                device node from which the property value is to be read.
+ * @propname:  name of the property to be searched.
+ * @elem_size: size of the individual element
+ *
+ * Search for a property in a device node and count the number of elements of
+ * size elem_size in it. Returns number of elements on sucess, -EINVAL if the
+ * property does not exist or its length does not match a multiple of elem_size
+ * and -ENODATA if the property does not have a value.
+ */
+int of_property_count_elems_of_size(const struct device_node *np,
+                               const char *propname, int elem_size)
+{
+       struct property *prop = of_find_property(np, propname, NULL);
+
+       if (!prop)
+               return -EINVAL;
+       if (!prop->value)
+               return -ENODATA;
+
+       if (prop->length % elem_size != 0) {
+               pr_err("size of %s in node %s is not a multiple of %d\n",
+                      propname, np->full_name, elem_size);
+               return -EINVAL;
+       }
+
+       return prop->length / elem_size;
+}
+EXPORT_SYMBOL_GPL(of_property_count_elems_of_size);
+
+/**
  * of_find_property_value_of_size
  *
  * @np:                device node from which the property value is to be read.
@@ -1938,3 +1971,148 @@ struct device_node *of_find_next_cache_node(const struct device_node *np)
 
        return NULL;
 }
+
+/**
+ * of_graph_parse_endpoint() - parse common endpoint node properties
+ * @node: pointer to endpoint device_node
+ * @endpoint: pointer to the OF endpoint data structure
+ *
+ * The caller should hold a reference to @node.
+ */
+int of_graph_parse_endpoint(const struct device_node *node,
+                           struct of_endpoint *endpoint)
+{
+       struct device_node *port_node = of_get_parent(node);
+
+       memset(endpoint, 0, sizeof(*endpoint));
+
+       endpoint->local_node = node;
+       /*
+        * It doesn't matter whether the two calls below succeed.
+        * If they don't then the default value 0 is used.
+        */
+       of_property_read_u32(port_node, "reg", &endpoint->port);
+       of_property_read_u32(node, "reg", &endpoint->id);
+
+       of_node_put(port_node);
+
+       return 0;
+}
+EXPORT_SYMBOL(of_graph_parse_endpoint);
+
+/**
+ * of_graph_get_next_endpoint() - get next endpoint node
+ * @parent: pointer to the parent device node
+ * @prev: previous endpoint node, or NULL to get first
+ *
+ * Return: An 'endpoint' node pointer with refcount incremented. Refcount
+ * of the passed @prev node is not decremented, the caller have to use
+ * of_node_put() on it when done.
+ */
+struct device_node *of_graph_get_next_endpoint(const struct device_node *parent,
+                                       struct device_node *prev)
+{
+       struct device_node *endpoint;
+       struct device_node *port = NULL;
+
+       if (!parent)
+               return NULL;
+
+       if (!prev) {
+               struct device_node *node;
+               /*
+                * It's the first call, we have to find a port subnode
+                * within this node or within an optional 'ports' node.
+                */
+               node = of_get_child_by_name(parent, "ports");
+               if (node)
+                       parent = node;
+
+               port = of_get_child_by_name(parent, "port");
+
+               if (port) {
+                       /* Found a port, get an endpoint. */
+                       endpoint = of_get_next_child(port, NULL);
+                       of_node_put(port);
+               } else {
+                       endpoint = NULL;
+               }
+
+               if (!endpoint)
+                       pr_err("%s(): no endpoint nodes specified for %s\n",
+                              __func__, parent->full_name);
+               of_node_put(node);
+       } else {
+               port = of_get_parent(prev);
+               if (!port)
+                       /* Hm, has someone given us the root node ?... */
+                       return NULL;
+
+               /* Avoid dropping prev node refcount to 0. */
+               of_node_get(prev);
+               endpoint = of_get_next_child(port, prev);
+               if (endpoint) {
+                       of_node_put(port);
+                       return endpoint;
+               }
+
+               /* No more endpoints under this port, try the next one. */
+               do {
+                       port = of_get_next_child(parent, port);
+                       if (!port)
+                               return NULL;
+               } while (of_node_cmp(port->name, "port"));
+
+               /* Pick up the first endpoint in this port. */
+               endpoint = of_get_next_child(port, NULL);
+               of_node_put(port);
+       }
+
+       return endpoint;
+}
+EXPORT_SYMBOL(of_graph_get_next_endpoint);
+
+/**
+ * of_graph_get_remote_port_parent() - get remote port's parent node
+ * @node: pointer to a local endpoint device_node
+ *
+ * Return: Remote device node associated with remote endpoint node linked
+ *        to @node. Use of_node_put() on it when done.
+ */
+struct device_node *of_graph_get_remote_port_parent(
+                              const struct device_node *node)
+{
+       struct device_node *np;
+       unsigned int depth;
+
+       /* Get remote endpoint node. */
+       np = of_parse_phandle(node, "remote-endpoint", 0);
+
+       /* Walk 3 levels up only if there is 'ports' node. */
+       for (depth = 3; depth && np; depth--) {
+               np = of_get_next_parent(np);
+               if (depth == 2 && of_node_cmp(np->name, "ports"))
+                       break;
+       }
+       return np;
+}
+EXPORT_SYMBOL(of_graph_get_remote_port_parent);
+
+/**
+ * of_graph_get_remote_port() - get remote port node
+ * @node: pointer to a local endpoint device_node
+ *
+ * Return: Remote port node associated with remote endpoint node linked
+ *        to @node. Use of_node_put() on it when done.
+ */
+struct device_node *of_graph_get_remote_port(const struct device_node *node)
+{
+       struct device_node *np;
+
+       /* Get remote endpoint node. */
+       np = of_parse_phandle(node, "remote-endpoint", 0);
+       if (!np)
+               return NULL;
+       return of_get_next_parent(np);
+}
+EXPORT_SYMBOL(of_graph_get_remote_port);
index 758b4f8..9218d45 100644 (file)
@@ -38,7 +38,7 @@ char *of_fdt_get_string(struct boot_param_header *blob, u32 offset)
  */
 void *of_fdt_get_property(struct boot_param_header *blob,
                       unsigned long node, const char *name,
-                      unsigned long *size)
+                      int *size)
 {
        unsigned long p = node;
 
@@ -88,7 +88,8 @@ int of_fdt_is_compatible(struct boot_param_header *blob,
                      unsigned long node, const char *compat)
 {
        const char *cp;
-       unsigned long cplen, l, score = 0;
+       int cplen;
+       unsigned long l, score = 0;
 
        cp = of_fdt_get_property(blob, node, "compatible", &cplen);
        if (cp == NULL)
@@ -518,8 +519,8 @@ unsigned long __init of_get_flat_dt_root(void)
  * This function can be used within scan_flattened_dt callback to get
  * access to properties
  */
-void *__init of_get_flat_dt_prop(unsigned long node, const char *name,
-                                unsigned long *size)
+const void *__init of_get_flat_dt_prop(unsigned long node, const char *name,
+                                      int *size)
 {
        return of_fdt_get_property(initial_boot_params, node, name, size);
 }
@@ -657,7 +658,7 @@ const void * __init of_flat_dt_match_machine(const void *default_match,
        }
        if (!best_data) {
                const char *prop;
-               long size;
+               int size;
 
                pr_err("\n unrecognized device tree list:\n[ ");
 
@@ -686,8 +687,8 @@ const void * __init of_flat_dt_match_machine(const void *default_match,
 static void __init early_init_dt_check_for_initrd(unsigned long node)
 {
        u64 start, end;
-       unsigned long len;
-       __be32 *prop;
+       int len;
+       const __be32 *prop;
 
        pr_debug("Looking for initrd properties... ");
 
@@ -720,7 +721,7 @@ static inline void early_init_dt_check_for_initrd(unsigned long node)
 int __init early_init_dt_scan_root(unsigned long node, const char *uname,
                                   int depth, void *data)
 {
-       __be32 *prop;
+       const __be32 *prop;
 
        if (depth != 0)
                return 0;
@@ -742,9 +743,9 @@ int __init early_init_dt_scan_root(unsigned long node, const char *uname,
        return 1;
 }
 
-u64 __init dt_mem_next_cell(int s, __be32 **cellp)
+u64 __init dt_mem_next_cell(int s, const __be32 **cellp)
 {
-       __be32 *p = *cellp;
+       const __be32 *p = *cellp;
 
        *cellp = p + s;
        return of_read_number(p, s);
@@ -756,9 +757,9 @@ u64 __init dt_mem_next_cell(int s, __be32 **cellp)
 int __init early_init_dt_scan_memory(unsigned long node, const char *uname,
                                     int depth, void *data)
 {
-       char *type = of_get_flat_dt_prop(node, "device_type", NULL);
-       __be32 *reg, *endp;
-       unsigned long l;
+       const char *type = of_get_flat_dt_prop(node, "device_type", NULL);
+       const __be32 *reg, *endp;
+       int l;
 
        /* We are scanning "memory" nodes only */
        if (type == NULL) {
@@ -779,7 +780,7 @@ int __init early_init_dt_scan_memory(unsigned long node, const char *uname,
 
        endp = reg + (l / sizeof(__be32));
 
-       pr_debug("memory scan node %s, reg size %ld, data: %x %x %x %x,\n",
+       pr_debug("memory scan node %s, reg size %d, data: %x %x %x %x,\n",
            uname, l, reg[0], reg[1], reg[2], reg[3]);
 
        while ((endp - reg) >= (dt_root_addr_cells + dt_root_size_cells)) {
@@ -802,8 +803,8 @@ int __init early_init_dt_scan_memory(unsigned long node, const char *uname,
 int __init early_init_dt_scan_chosen(unsigned long node, const char *uname,
                                     int depth, void *data)
 {
-       unsigned long l;
-       char *p;
+       int l;
+       const char *p;
 
        pr_debug("search \"chosen\", depth: %d, uname: %s\n", depth, uname);
 
index 47d46c6..dc627e5 100644 (file)
@@ -33,4 +33,10 @@ config PCI_RCAR_GEN2
          There are 3 internal PCI controllers available with a single
          built-in EHCI/OHCI host controller present on each one.
 
+config PCI_RCAR_GEN2_PCIE
+       bool "Renesas R-Car PCIe controller"
+       depends on ARCH_SHMOBILE || (ARM && COMPILE_TEST)
+       help
+         Say Y here if you want PCIe controller support on R-Car Gen2 SoCs.
+
 endmenu
index 13fb333..19946f9 100644 (file)
@@ -4,3 +4,4 @@ obj-$(CONFIG_PCI_IMX6) += pci-imx6.o
 obj-$(CONFIG_PCI_MVEBU) += pci-mvebu.o
 obj-$(CONFIG_PCI_TEGRA) += pci-tegra.o
 obj-$(CONFIG_PCI_RCAR_GEN2) += pci-rcar-gen2.o
+obj-$(CONFIG_PCI_RCAR_GEN2_PCIE) += pcie-rcar.o
diff --git a/drivers/pci/host/pcie-rcar.c b/drivers/pci/host/pcie-rcar.c
new file mode 100644 (file)
index 0000000..0a9e816
--- /dev/null
@@ -0,0 +1,994 @@
+/*
+ * PCIe driver for Renesas R-Car SoCs
+ *  Copyright (C) 2014 Renesas Electronics Europe Ltd
+ *
+ * Based on:
+ *  arch/sh/drivers/pci/pcie-sh7786.c
+ *  arch/sh/drivers/pci/ops-sh7786.c
+ *  Copyright (C) 2009 - 2011  Paul Mundt
+ *
+ * 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 <linux/clk.h>
+#include <linux/delay.h>
+#include <linux/interrupt.h>
+#include <linux/irq.h>
+#include <linux/irqdomain.h>
+#include <linux/kernel.h>
+#include <linux/module.h>
+#include <linux/msi.h>
+#include <linux/of_address.h>
+#include <linux/of_irq.h>
+#include <linux/of_pci.h>
+#include <linux/of_platform.h>
+#include <linux/pci.h>
+#include <linux/platform_device.h>
+#include <linux/slab.h>
+
+#define DRV_NAME "rcar-pcie"
+
+#define PCIECAR                        0x000010
+#define PCIECCTLR              0x000018
+#define  CONFIG_SEND_ENABLE    (1 << 31)
+#define  TYPE0                 (0 << 8)
+#define  TYPE1                 (1 << 8)
+#define PCIECDR                        0x000020
+#define PCIEMSR                        0x000028
+#define PCIEINTXR              0x000400
+#define PCIEMSITXR             0x000840
+
+/* Transfer control */
+#define PCIETCTLR              0x02000
+#define  CFINIT                        1
+#define PCIETSTR               0x02004
+#define  DATA_LINK_ACTIVE      1
+#define PCIEERRFR              0x02020
+#define  UNSUPPORTED_REQUEST   (1 << 4)
+#define PCIEMSIFR              0x02044
+#define PCIEMSIALR             0x02048
+#define  MSIFE                 1
+#define PCIEMSIAUR             0x0204c
+#define PCIEMSIIER             0x02050
+
+/* root port address */
+#define PCIEPRAR(x)            (0x02080 + ((x) * 0x4))
+
+/* local address reg & mask */
+#define PCIELAR(x)             (0x02200 + ((x) * 0x20))
+#define PCIELAMR(x)            (0x02208 + ((x) * 0x20))
+#define  LAM_PREFETCH          (1 << 3)
+#define  LAM_64BIT             (1 << 2)
+#define  LAR_ENABLE            (1 << 1)
+
+/* PCIe address reg & mask */
+#define PCIEPARL(x)            (0x03400 + ((x) * 0x20))
+#define PCIEPARH(x)            (0x03404 + ((x) * 0x20))
+#define PCIEPAMR(x)            (0x03408 + ((x) * 0x20))
+#define PCIEPTCTLR(x)          (0x0340c + ((x) * 0x20))
+#define  PAR_ENABLE            (1 << 31)
+#define  IO_SPACE              (1 << 8)
+
+/* Configuration */
+#define PCICONF(x)             (0x010000 + ((x) * 0x4))
+#define PMCAP(x)               (0x010040 + ((x) * 0x4))
+#define EXPCAP(x)              (0x010070 + ((x) * 0x4))
+#define VCCAP(x)               (0x010100 + ((x) * 0x4))
+
+/* link layer */
+#define IDSETR1                        0x011004
+#define TLCTLR                 0x011048
+#define MACSR                  0x011054
+#define MACCTLR                        0x011058
+#define  SCRAMBLE_DISABLE      (1 << 27)
+
+/* R-Car H1 PHY */
+#define H1_PCIEPHYADRR         0x04000c
+#define  WRITE_CMD             (1 << 16)
+#define  PHY_ACK               (1 << 24)
+#define  RATE_POS              12
+#define  LANE_POS              8
+#define  ADR_POS               0
+#define H1_PCIEPHYDOUTR                0x040014
+#define H1_PCIEPHYSR           0x040018
+
+#define INT_PCI_MSI_NR 32
+
+#define RCONF(x)       (PCICONF(0)+(x))
+#define RPMCAP(x)      (PMCAP(0)+(x))
+#define REXPCAP(x)     (EXPCAP(0)+(x))
+#define RVCCAP(x)      (VCCAP(0)+(x))
+
+#define  PCIE_CONF_BUS(b)      (((b) & 0xff) << 24)
+#define  PCIE_CONF_DEV(d)      (((d) & 0x1f) << 19)
+#define  PCIE_CONF_FUNC(f)     (((f) & 0x7) << 16)
+
+#define RCAR_PCI_MAX_RESOURCES 4
+#define MAX_NR_INBOUND_MAPS 6
+
+struct rcar_msi {
+       DECLARE_BITMAP(used, INT_PCI_MSI_NR);
+       struct irq_domain *domain;
+       struct msi_chip chip;
+       unsigned long pages;
+       struct mutex lock;
+       int irq1;
+       int irq2;
+};
+
+static inline struct rcar_msi *to_rcar_msi(struct msi_chip *chip)
+{
+       return container_of(chip, struct rcar_msi, chip);
+}
+
+/* Structure representing the PCIe interface */
+struct rcar_pcie {
+       struct device           *dev;
+       void __iomem            *base;
+       struct resource         res[RCAR_PCI_MAX_RESOURCES];
+       struct resource         busn;
+       int                     root_bus_nr;
+       struct clk              *clk;
+       struct clk              *bus_clk;
+       struct                  rcar_msi msi;
+};
+
+static inline struct rcar_pcie *sys_to_pcie(struct pci_sys_data *sys)
+{
+       return sys->private_data;
+}
+
+static void rcar_pci_write_reg(struct rcar_pcie *pcie, unsigned long val,
+                              unsigned long reg)
+{
+       writel(val, pcie->base + reg);
+}
+
+static unsigned long rcar_pci_read_reg(struct rcar_pcie *pcie,
+                                      unsigned long reg)
+{
+       return readl(pcie->base + reg);
+}
+
+enum {
+       RCAR_PCI_ACCESS_READ,
+       RCAR_PCI_ACCESS_WRITE,
+};
+
+static void rcar_rmw32(struct rcar_pcie *pcie, int where, u32 mask, u32 data)
+{
+       int shift = 8 * (where & 3);
+       u32 val = rcar_pci_read_reg(pcie, where & ~3);
+
+       val &= ~(mask << shift);
+       val |= data << shift;
+       rcar_pci_write_reg(pcie, val, where & ~3);
+}
+
+static u32 rcar_read_conf(struct rcar_pcie *pcie, int where)
+{
+       int shift = 8 * (where & 3);
+       u32 val = rcar_pci_read_reg(pcie, where & ~3);
+
+       return val >> shift;
+}
+
+/* Serialization is provided by 'pci_lock' in drivers/pci/access.c */
+static int rcar_pcie_config_access(struct rcar_pcie *pcie,
+               unsigned char access_type, struct pci_bus *bus,
+               unsigned int devfn, int where, u32 *data)
+{
+       int dev, func, reg, index;
+
+       dev = PCI_SLOT(devfn);
+       func = PCI_FUNC(devfn);
+       reg = where & ~3;
+       index = reg / 4;
+
+       /*
+        * While each channel has its own memory-mapped extended config
+        * space, it's generally only accessible when in endpoint mode.
+        * When in root complex mode, the controller is unable to target
+        * itself with either type 0 or type 1 accesses, and indeed, any
+        * controller initiated target transfer to its own config space
+        * result in a completer abort.
+        *
+        * Each channel effectively only supports a single device, but as
+        * the same channel <-> device access works for any PCI_SLOT()
+        * value, we cheat a bit here and bind the controller's config
+        * space to devfn 0 in order to enable self-enumeration. In this
+        * case the regular ECAR/ECDR path is sidelined and the mangled
+        * config access itself is initiated as an internal bus transaction.
+        */
+       if (pci_is_root_bus(bus)) {
+               if (dev != 0)
+                       return PCIBIOS_DEVICE_NOT_FOUND;
+
+               if (access_type == RCAR_PCI_ACCESS_READ) {
+                       *data = rcar_pci_read_reg(pcie, PCICONF(index));
+               } else {
+                       /* Keep an eye out for changes to the root bus number */
+                       if (pci_is_root_bus(bus) && (reg == PCI_PRIMARY_BUS))
+                               pcie->root_bus_nr = *data & 0xff;
+
+                       rcar_pci_write_reg(pcie, *data, PCICONF(index));
+               }
+
+               return PCIBIOS_SUCCESSFUL;
+       }
+
+       if (pcie->root_bus_nr < 0)
+               return PCIBIOS_DEVICE_NOT_FOUND;
+
+       /* Clear errors */
+       rcar_pci_write_reg(pcie, rcar_pci_read_reg(pcie, PCIEERRFR), PCIEERRFR);
+
+       /* Set the PIO address */
+       rcar_pci_write_reg(pcie, PCIE_CONF_BUS(bus->number) |
+               PCIE_CONF_DEV(dev) | PCIE_CONF_FUNC(func) | reg, PCIECAR);
+
+       /* Enable the configuration access */
+       if (bus->parent->number == pcie->root_bus_nr)
+               rcar_pci_write_reg(pcie, CONFIG_SEND_ENABLE | TYPE0, PCIECCTLR);
+       else
+               rcar_pci_write_reg(pcie, CONFIG_SEND_ENABLE | TYPE1, PCIECCTLR);
+
+       /* Check for errors */
+       if (rcar_pci_read_reg(pcie, PCIEERRFR) & UNSUPPORTED_REQUEST)
+               return PCIBIOS_DEVICE_NOT_FOUND;
+
+       /* Check for master and target aborts */
+       if (rcar_read_conf(pcie, RCONF(PCI_STATUS)) &
+               (PCI_STATUS_REC_MASTER_ABORT | PCI_STATUS_REC_TARGET_ABORT))
+               return PCIBIOS_DEVICE_NOT_FOUND;
+
+       if (access_type == RCAR_PCI_ACCESS_READ)
+               *data = rcar_pci_read_reg(pcie, PCIECDR);
+       else
+               rcar_pci_write_reg(pcie, *data, PCIECDR);
+
+       /* Disable the configuration access */
+       rcar_pci_write_reg(pcie, 0, PCIECCTLR);
+
+       return PCIBIOS_SUCCESSFUL;
+}
+
+static int rcar_pcie_read_conf(struct pci_bus *bus, unsigned int devfn,
+                              int where, int size, u32 *val)
+{
+       struct rcar_pcie *pcie = sys_to_pcie(bus->sysdata);
+       int ret;
+
+       ret = rcar_pcie_config_access(pcie, RCAR_PCI_ACCESS_READ,
+                                     bus, devfn, where, val);
+       if (ret != PCIBIOS_SUCCESSFUL) {
+               *val = 0xffffffff;
+               return ret;
+       }
+
+       if (size == 1)
+               *val = (*val >> (8 * (where & 3))) & 0xff;
+       else if (size == 2)
+               *val = (*val >> (8 * (where & 2))) & 0xffff;
+
+       dev_dbg(&bus->dev, "pcie-config-read: bus=%3d devfn=0x%04x "
+               "where=0x%04x size=%d val=0x%08lx\n", bus->number,
+               devfn, where, size, (unsigned long)*val);
+
+       return ret;
+}
+
+/* Serialization is provided by 'pci_lock' in drivers/pci/access.c */
+static int rcar_pcie_write_conf(struct pci_bus *bus, unsigned int devfn,
+                               int where, int size, u32 val)
+{
+       struct rcar_pcie *pcie = sys_to_pcie(bus->sysdata);
+       int shift, ret;
+       u32 data;
+
+       ret = rcar_pcie_config_access(pcie, RCAR_PCI_ACCESS_READ,
+                                     bus, devfn, where, &data);
+       if (ret != PCIBIOS_SUCCESSFUL)
+               return ret;
+
+       dev_dbg(&bus->dev, "pcie-config-write: bus=%3d devfn=0x%04x "
+               "where=0x%04x size=%d val=0x%08lx\n", bus->number,
+               devfn, where, size, (unsigned long)val);
+
+       if (size == 1) {
+               shift = 8 * (where & 3);
+               data &= ~(0xff << shift);
+               data |= ((val & 0xff) << shift);
+       } else if (size == 2) {
+               shift = 8 * (where & 2);
+               data &= ~(0xffff << shift);
+               data |= ((val & 0xffff) << shift);
+       } else
+               data = val;
+
+       ret = rcar_pcie_config_access(pcie, RCAR_PCI_ACCESS_WRITE,
+                                     bus, devfn, where, &data);
+
+       return ret;
+}
+
+static struct pci_ops rcar_pcie_ops = {
+       .read   = rcar_pcie_read_conf,
+       .write  = rcar_pcie_write_conf,
+};
+
+static void rcar_pcie_setup_window(int win, struct rcar_pcie *pcie)
+{
+       struct resource *res = &pcie->res[win];
+
+       /* Setup PCIe address space mappings for each resource */
+       resource_size_t size;
+       u32 mask;
+
+       rcar_pci_write_reg(pcie, 0x00000000, PCIEPTCTLR(win));
+
+       /*
+        * The PAMR mask is calculated in units of 128Bytes, which
+        * keeps things pretty simple.
+        */
+       size = resource_size(res);
+       mask = (roundup_pow_of_two(size) / SZ_128) - 1;
+       rcar_pci_write_reg(pcie, mask << 7, PCIEPAMR(win));
+
+       rcar_pci_write_reg(pcie, upper_32_bits(res->start), PCIEPARH(win));
+       rcar_pci_write_reg(pcie, lower_32_bits(res->start), PCIEPARL(win));
+
+       /* First resource is for IO */
+       mask = PAR_ENABLE;
+       if (res->flags & IORESOURCE_IO)
+               mask |= IO_SPACE;
+
+       rcar_pci_write_reg(pcie, mask, PCIEPTCTLR(win));
+}
+
+static int rcar_pcie_setup(int nr, struct pci_sys_data *sys)
+{
+       struct rcar_pcie *pcie = sys_to_pcie(sys);
+       struct resource *res;
+       int i;
+
+       pcie->root_bus_nr = -1;
+
+       /* Setup PCI resources */
+       for (i = 0; i < RCAR_PCI_MAX_RESOURCES; i++) {
+
+               res = &pcie->res[i];
+               if (!res->flags)
+                       continue;
+
+               rcar_pcie_setup_window(i, pcie);
+
+               if (res->flags & IORESOURCE_IO)
+                       pci_ioremap_io(nr * SZ_64K, res->start);
+               else
+                       pci_add_resource(&sys->resources, res);
+       }
+       pci_add_resource(&sys->resources, &pcie->busn);
+
+       return 1;
+}
+
+static void rcar_pcie_add_bus(struct pci_bus *bus)
+{
+       if (IS_ENABLED(CONFIG_PCI_MSI)) {
+               struct rcar_pcie *pcie = sys_to_pcie(bus->sysdata);
+
+               bus->msi = &pcie->msi.chip;
+       }
+}
+
+struct hw_pci rcar_pci = {
+       .setup          = rcar_pcie_setup,
+       .map_irq        = of_irq_parse_and_map_pci,
+       .ops            = &rcar_pcie_ops,
+       .add_bus        = rcar_pcie_add_bus,
+};
+
+static void rcar_pcie_enable(struct rcar_pcie *pcie)
+{
+       struct platform_device *pdev = to_platform_device(pcie->dev);
+
+       rcar_pci.nr_controllers = 1;
+       rcar_pci.private_data = (void **)&pcie;
+
+       pci_common_init_dev(&pdev->dev, &rcar_pci);
+#ifdef CONFIG_PCI_DOMAINS
+       rcar_pci.domain++;
+#endif
+}
+
+static int phy_wait_for_ack(struct rcar_pcie *pcie)
+{
+       unsigned int timeout = 100;
+
+       while (timeout--) {
+               if (rcar_pci_read_reg(pcie, H1_PCIEPHYADRR) & PHY_ACK)
+                       return 0;
+
+               udelay(100);
+       }
+
+       dev_err(pcie->dev, "Access to PCIe phy timed out\n");
+
+       return -ETIMEDOUT;
+}
+
+static void phy_write_reg(struct rcar_pcie *pcie,
+                                unsigned int rate, unsigned int addr,
+                                unsigned int lane, unsigned int data)
+{
+       unsigned long phyaddr;
+
+       phyaddr = WRITE_CMD |
+               ((rate & 1) << RATE_POS) |
+               ((lane & 0xf) << LANE_POS) |
+               ((addr & 0xff) << ADR_POS);
+
+       /* Set write data */
+       rcar_pci_write_reg(pcie, data, H1_PCIEPHYDOUTR);
+       rcar_pci_write_reg(pcie, phyaddr, H1_PCIEPHYADRR);
+
+       /* Ignore errors as they will be dealt with if the data link is down */
+       phy_wait_for_ack(pcie);
+
+       /* Clear command */
+       rcar_pci_write_reg(pcie, 0, H1_PCIEPHYDOUTR);
+       rcar_pci_write_reg(pcie, 0, H1_PCIEPHYADRR);
+
+       /* Ignore errors as they will be dealt with if the data link is down */
+       phy_wait_for_ack(pcie);
+}
+
+static int rcar_pcie_wait_for_dl(struct rcar_pcie *pcie)
+{
+       unsigned int timeout = 10;
+
+       while (timeout--) {
+               if ((rcar_pci_read_reg(pcie, PCIETSTR) & DATA_LINK_ACTIVE))
+                       return 0;
+
+               msleep(5);
+       }
+
+       return -ETIMEDOUT;
+}
+
+static int rcar_pcie_hw_init(struct rcar_pcie *pcie)
+{
+       int err;
+
+       /* Begin initialization */
+       rcar_pci_write_reg(pcie, 0, PCIETCTLR);
+
+       /* Set mode */
+       rcar_pci_write_reg(pcie, 1, PCIEMSR);
+
+       /*
+        * Initial header for port config space is type 1, set the device
+        * class to match. Hardware takes care of propagating the IDSETR
+        * settings, so there is no need to bother with a quirk.
+        */
+       rcar_pci_write_reg(pcie, PCI_CLASS_BRIDGE_PCI << 16, IDSETR1);
+
+       /*
+        * Setup Secondary Bus Number & Subordinate Bus Number, even though
+        * they aren't used, to avoid bridge being detected as broken.
+        */
+       rcar_rmw32(pcie, RCONF(PCI_SECONDARY_BUS), 0xff, 1);
+       rcar_rmw32(pcie, RCONF(PCI_SUBORDINATE_BUS), 0xff, 1);
+
+       /* Initialize default capabilities. */
+       rcar_rmw32(pcie, REXPCAP(0), 0xff, PCI_CAP_ID_EXP);
+       rcar_rmw32(pcie, REXPCAP(PCI_EXP_FLAGS),
+               PCI_EXP_FLAGS_TYPE, PCI_EXP_TYPE_ROOT_PORT << 4);
+       rcar_rmw32(pcie, RCONF(PCI_HEADER_TYPE), 0x7f,
+               PCI_HEADER_TYPE_BRIDGE);
+
+       /* Enable data link layer active state reporting */
+       rcar_rmw32(pcie, REXPCAP(PCI_EXP_LNKCAP), PCI_EXP_LNKCAP_DLLLARC,
+               PCI_EXP_LNKCAP_DLLLARC);
+
+       /* Write out the physical slot number = 0 */
+       rcar_rmw32(pcie, REXPCAP(PCI_EXP_SLTCAP), PCI_EXP_SLTCAP_PSN, 0);
+
+       /* Set the completion timer timeout to the maximum 50ms. */
+       rcar_rmw32(pcie, TLCTLR + 1, 0x3f, 50);
+
+       /* Terminate list of capabilities (Next Capability Offset=0) */
+       rcar_rmw32(pcie, RVCCAP(0), 0xfff00000, 0);
+
+       /* Enable MSI */
+       if (IS_ENABLED(CONFIG_PCI_MSI))
+               rcar_pci_write_reg(pcie, 0x101f0000, PCIEMSITXR);
+
+       /* Finish initialization - establish a PCI Express link */
+       rcar_pci_write_reg(pcie, CFINIT, PCIETCTLR);
+
+       /* This will timeout if we don't have a link. */
+       err = rcar_pcie_wait_for_dl(pcie);
+       if (err)
+               return err;
+
+       /* Enable INTx interrupts */
+       rcar_rmw32(pcie, PCIEINTXR, 0, 0xF << 8);
+
+       wmb();
+
+       return 0;
+}
+
+static int rcar_pcie_hw_init_h1(struct rcar_pcie *pcie)
+{
+       unsigned int timeout = 10;
+
+       /* Initialize the phy */
+       phy_write_reg(pcie, 0, 0x42, 0x1, 0x0EC34191);
+       phy_write_reg(pcie, 1, 0x42, 0x1, 0x0EC34180);
+       phy_write_reg(pcie, 0, 0x43, 0x1, 0x00210188);
+       phy_write_reg(pcie, 1, 0x43, 0x1, 0x00210188);
+       phy_write_reg(pcie, 0, 0x44, 0x1, 0x015C0014);
+       phy_write_reg(pcie, 1, 0x44, 0x1, 0x015C0014);
+       phy_write_reg(pcie, 1, 0x4C, 0x1, 0x786174A0);
+       phy_write_reg(pcie, 1, 0x4D, 0x1, 0x048000BB);
+       phy_write_reg(pcie, 0, 0x51, 0x1, 0x079EC062);
+       phy_write_reg(pcie, 0, 0x52, 0x1, 0x20000000);
+       phy_write_reg(pcie, 1, 0x52, 0x1, 0x20000000);
+       phy_write_reg(pcie, 1, 0x56, 0x1, 0x00003806);
+
+       phy_write_reg(pcie, 0, 0x60, 0x1, 0x004B03A5);
+       phy_write_reg(pcie, 0, 0x64, 0x1, 0x3F0F1F0F);
+       phy_write_reg(pcie, 0, 0x66, 0x1, 0x00008000);
+
+       while (timeout--) {
+               if (rcar_pci_read_reg(pcie, H1_PCIEPHYSR))
+                       return rcar_pcie_hw_init(pcie);
+
+               msleep(5);
+       }
+
+       return -ETIMEDOUT;
+}
+
+static int rcar_msi_alloc(struct rcar_msi *chip)
+{
+       int msi;
+
+       mutex_lock(&chip->lock);
+
+       msi = find_first_zero_bit(chip->used, INT_PCI_MSI_NR);
+       if (msi < INT_PCI_MSI_NR)
+               set_bit(msi, chip->used);
+       else
+               msi = -ENOSPC;
+
+       mutex_unlock(&chip->lock);
+
+       return msi;
+}
+
+static void rcar_msi_free(struct rcar_msi *chip, unsigned long irq)
+{
+       mutex_lock(&chip->lock);
+       clear_bit(irq, chip->used);
+       mutex_unlock(&chip->lock);
+}
+
+static irqreturn_t rcar_pcie_msi_irq(int irq, void *data)
+{
+       struct rcar_pcie *pcie = data;
+       struct rcar_msi *msi = &pcie->msi;
+       unsigned long reg;
+
+       reg = rcar_pci_read_reg(pcie, PCIEMSIFR);
+
+       /* MSI & INTx share an interrupt - we only handle MSI here */
+       if (!reg)
+               return IRQ_NONE;
+
+       while (reg) {
+               unsigned int index = find_first_bit(&reg, 32);
+               unsigned int irq;
+
+               /* clear the interrupt */
+               rcar_pci_write_reg(pcie, 1 << index, PCIEMSIFR);
+
+               irq = irq_find_mapping(msi->domain, index);
+               if (irq) {
+                       if (test_bit(index, msi->used))
+                               generic_handle_irq(irq);
+                       else
+                               dev_info(pcie->dev, "unhandled MSI\n");
+               } else {
+                       /* Unknown MSI, just clear it */
+                       dev_dbg(pcie->dev, "unexpected MSI\n");
+               }
+
+               /* see if there's any more pending in this vector */
+               reg = rcar_pci_read_reg(pcie, PCIEMSIFR);
+       }
+
+       return IRQ_HANDLED;
+}
+
+static int rcar_msi_setup_irq(struct msi_chip *chip, struct pci_dev *pdev,
+                             struct msi_desc *desc)
+{
+       struct rcar_msi *msi = to_rcar_msi(chip);
+       struct rcar_pcie *pcie = container_of(chip, struct rcar_pcie, msi.chip);
+       struct msi_msg msg;
+       unsigned int irq;
+       int hwirq;
+
+       hwirq = rcar_msi_alloc(msi);
+       if (hwirq < 0)
+               return hwirq;
+
+       irq = irq_create_mapping(msi->domain, hwirq);
+       if (!irq) {
+               rcar_msi_free(msi, hwirq);
+               return -EINVAL;
+       }
+
+       irq_set_msi_desc(irq, desc);
+
+       msg.address_lo = rcar_pci_read_reg(pcie, PCIEMSIALR) & ~MSIFE;
+       msg.address_hi = rcar_pci_read_reg(pcie, PCIEMSIAUR);
+       msg.data = hwirq;
+
+       write_msi_msg(irq, &msg);
+
+       return 0;
+}
+
+static void rcar_msi_teardown_irq(struct msi_chip *chip, unsigned int irq)
+{
+       struct rcar_msi *msi = to_rcar_msi(chip);
+       struct irq_data *d = irq_get_irq_data(irq);
+
+       rcar_msi_free(msi, d->hwirq);
+}
+
+static struct irq_chip rcar_msi_irq_chip = {
+       .name = "R-Car PCIe MSI",
+       .irq_enable = unmask_msi_irq,
+       .irq_disable = mask_msi_irq,
+       .irq_mask = mask_msi_irq,
+       .irq_unmask = unmask_msi_irq,
+};
+
+static int rcar_msi_map(struct irq_domain *domain, unsigned int irq,
+                       irq_hw_number_t hwirq)
+{
+       irq_set_chip_and_handler(irq, &rcar_msi_irq_chip, handle_simple_irq);
+       irq_set_chip_data(irq, domain->host_data);
+       set_irq_flags(irq, IRQF_VALID);
+
+       return 0;
+}
+
+static const struct irq_domain_ops msi_domain_ops = {
+       .map = rcar_msi_map,
+};
+
+static int rcar_pcie_enable_msi(struct rcar_pcie *pcie)
+{
+       struct platform_device *pdev = to_platform_device(pcie->dev);
+       struct rcar_msi *msi = &pcie->msi;
+       unsigned long base;
+       int err;
+
+       mutex_init(&msi->lock);
+
+       msi->chip.dev = pcie->dev;
+       msi->chip.setup_irq = rcar_msi_setup_irq;
+       msi->chip.teardown_irq = rcar_msi_teardown_irq;
+
+       msi->domain = irq_domain_add_linear(pcie->dev->of_node, INT_PCI_MSI_NR,
+                                           &msi_domain_ops, &msi->chip);
+       if (!msi->domain) {
+               dev_err(&pdev->dev, "failed to create IRQ domain\n");
+               return -ENOMEM;
+       }
+
+       /* Two irqs are for MSI, but they are also used for non-MSI irqs */
+       err = devm_request_irq(&pdev->dev, msi->irq1, rcar_pcie_msi_irq,
+                              IRQF_SHARED, rcar_msi_irq_chip.name, pcie);
+       if (err < 0) {
+               dev_err(&pdev->dev, "failed to request IRQ: %d\n", err);
+               goto err;
+       }
+
+       err = devm_request_irq(&pdev->dev, msi->irq2, rcar_pcie_msi_irq,
+                              IRQF_SHARED, rcar_msi_irq_chip.name, pcie);
+       if (err < 0) {
+               dev_err(&pdev->dev, "failed to request IRQ: %d\n", err);
+               goto err;
+       }
+
+       /* setup MSI data target */
+       msi->pages = __get_free_pages(GFP_KERNEL, 0);
+       base = virt_to_phys((void *)msi->pages);
+
+       rcar_pci_write_reg(pcie, base | MSIFE, PCIEMSIALR);
+       rcar_pci_write_reg(pcie, 0, PCIEMSIAUR);
+
+       /* enable all MSI interrupts */
+       rcar_pci_write_reg(pcie, 0xffffffff, PCIEMSIIER);
+
+       return 0;
+
+err:
+       irq_domain_remove(msi->domain);
+       return err;
+}
+
+static int rcar_pcie_get_resources(struct platform_device *pdev,
+                                  struct rcar_pcie *pcie)
+{
+       struct resource res;
+       int err, i;
+
+       err = of_address_to_resource(pdev->dev.of_node, 0, &res);
+       if (err)
+               return err;
+
+       pcie->clk = devm_clk_get(&pdev->dev, "pcie");
+       if (IS_ERR(pcie->clk)) {
+               dev_err(pcie->dev, "cannot get platform clock\n");
+               return PTR_ERR(pcie->clk);
+       }
+       err = clk_prepare_enable(pcie->clk);
+       if (err)
+               goto fail_clk;
+
+       pcie->bus_clk = devm_clk_get(&pdev->dev, "pcie_bus");
+       if (IS_ERR(pcie->bus_clk)) {
+               dev_err(pcie->dev, "cannot get pcie bus clock\n");
+               err = PTR_ERR(pcie->bus_clk);
+               goto fail_clk;
+       }
+       err = clk_prepare_enable(pcie->bus_clk);
+       if (err)
+               goto err_map_reg;
+
+       i = irq_of_parse_and_map(pdev->dev.of_node, 0);
+       if (i < 0) {
+               dev_err(pcie->dev, "cannot get platform resources for msi interrupt\n");
+               err = -ENOENT;
+               goto err_map_reg;
+       }
+       pcie->msi.irq1 = i;
+
+       i = irq_of_parse_and_map(pdev->dev.of_node, 1);
+       if (i < 0) {
+               dev_err(pcie->dev, "cannot get platform resources for msi interrupt\n");
+               err = -ENOENT;
+               goto err_map_reg;
+       }
+       pcie->msi.irq2 = i;
+
+       pcie->base = devm_ioremap_resource(&pdev->dev, &res);
+       if (IS_ERR(pcie->base)) {
+               err = PTR_ERR(pcie->base);
+               goto err_map_reg;
+       }
+
+       return 0;
+
+err_map_reg:
+       clk_disable_unprepare(pcie->bus_clk);
+fail_clk:
+       clk_disable_unprepare(pcie->clk);
+
+       return err;
+}
+
+static int rcar_pcie_inbound_ranges(struct rcar_pcie *pcie,
+                                   struct of_pci_range *range,
+                                   int *index)
+{
+       u64 restype = range->flags;
+       u64 cpu_addr = range->cpu_addr;
+       u64 cpu_end = range->cpu_addr + range->size;
+       u64 pci_addr = range->pci_addr;
+       u32 flags = LAM_64BIT | LAR_ENABLE;
+       u64 mask;
+       u64 size;
+       int idx = *index;
+
+       if (restype & IORESOURCE_PREFETCH)
+               flags |= LAM_PREFETCH;
+
+       /*
+        * If the size of the range is larger than the alignment of the start
+        * address, we have to use multiple entries to perform the mapping.
+        */
+       if (cpu_addr > 0) {
+               unsigned long nr_zeros = __ffs64(cpu_addr);
+               u64 alignment = 1ULL << nr_zeros;
+
+               size = min(range->size, alignment);
+       } else {
+               size = range->size;
+       }
+       /* Hardware supports max 4GiB inbound region */
+       size = min(size, 1ULL << 32);
+
+       mask = roundup_pow_of_two(size) - 1;
+       mask &= ~0xf;
+
+       while (cpu_addr < cpu_end) {
+               /*
+                * Set up 64-bit inbound regions as the range parser doesn't
+                * distinguish between 32 and 64-bit types.
+                */
+               rcar_pci_write_reg(pcie, lower_32_bits(pci_addr), PCIEPRAR(idx));
+               rcar_pci_write_reg(pcie, lower_32_bits(cpu_addr), PCIELAR(idx));
+               rcar_pci_write_reg(pcie, lower_32_bits(mask) | flags, PCIELAMR(idx));
+
+               rcar_pci_write_reg(pcie, upper_32_bits(pci_addr), PCIEPRAR(idx+1));
+               rcar_pci_write_reg(pcie, upper_32_bits(cpu_addr), PCIELAR(idx+1));
+               rcar_pci_write_reg(pcie, 0, PCIELAMR(idx + 1));
+
+               pci_addr += size;
+               cpu_addr += size;
+               idx += 2;
+
+               if (idx > MAX_NR_INBOUND_MAPS) {
+                       dev_err(pcie->dev, "Failed to map inbound regions!\n");
+                       return -EINVAL;
+               }
+       }
+       *index = idx;
+
+       return 0;
+}
+
+static int pci_dma_range_parser_init(struct of_pci_range_parser *parser,
+                                    struct device_node *node)
+{
+       const int na = 3, ns = 2;
+       int rlen;
+
+       parser->node = node;
+       parser->pna = of_n_addr_cells(node);
+       parser->np = parser->pna + na + ns;
+
+       parser->range = of_get_property(node, "dma-ranges", &rlen);
+       if (!parser->range)
+               return -ENOENT;
+
+       parser->end = parser->range + rlen / sizeof(__be32);
+       return 0;
+}
+
+static int rcar_pcie_parse_map_dma_ranges(struct rcar_pcie *pcie,
+                                         struct device_node *np)
+{
+       struct of_pci_range range;
+       struct of_pci_range_parser parser;
+       int index = 0;
+       int err;
+
+       if (pci_dma_range_parser_init(&parser, np))
+               return -EINVAL;
+
+       /* Get the dma-ranges from DT */
+       for_each_of_pci_range(&parser, &range) {
+               u64 end = range.cpu_addr + range.size - 1;
+               dev_dbg(pcie->dev, "0x%08x 0x%016llx..0x%016llx -> 0x%016llx\n",
+                       range.flags, range.cpu_addr, end, range.pci_addr);
+
+               err = rcar_pcie_inbound_ranges(pcie, &range, &index);
+               if (err)
+                       return err;
+       }
+
+       return 0;
+}
+
+static const struct of_device_id rcar_pcie_of_match[] = {
+       { .compatible = "renesas,pcie-r8a7779", .data = rcar_pcie_hw_init_h1 },
+       { .compatible = "renesas,pcie-r8a7790", .data = rcar_pcie_hw_init },
+       { .compatible = "renesas,pcie-r8a7791", .data = rcar_pcie_hw_init },
+       {},
+};
+MODULE_DEVICE_TABLE(of, rcar_pcie_of_match);
+
+static int rcar_pcie_probe(struct platform_device *pdev)
+{
+       struct rcar_pcie *pcie;
+       unsigned int data;
+       struct of_pci_range range;
+       struct of_pci_range_parser parser;
+       const struct of_device_id *of_id;
+       int err, win = 0;
+       int (*hw_init_fn)(struct rcar_pcie *);
+
+       pcie = devm_kzalloc(&pdev->dev, sizeof(*pcie), GFP_KERNEL);
+       if (!pcie)
+               return -ENOMEM;
+
+       pcie->dev = &pdev->dev;
+       platform_set_drvdata(pdev, pcie);
+
+       /* Get the bus range */
+       if (of_pci_parse_bus_range(pdev->dev.of_node, &pcie->busn)) {
+               dev_err(&pdev->dev, "failed to parse bus-range property\n");
+               return -EINVAL;
+       }
+
+       if (of_pci_range_parser_init(&parser, pdev->dev.of_node)) {
+               dev_err(&pdev->dev, "missing ranges property\n");
+               return -EINVAL;
+       }
+
+       err = rcar_pcie_get_resources(pdev, pcie);
+       if (err < 0) {
+               dev_err(&pdev->dev, "failed to request resources: %d\n", err);
+               return err;
+       }
+
+       for_each_of_pci_range(&parser, &range) {
+               of_pci_range_to_resource(&range, pdev->dev.of_node,
+                                               &pcie->res[win++]);
+
+               if (win > RCAR_PCI_MAX_RESOURCES)
+                       break;
+       }
+
+        err = rcar_pcie_parse_map_dma_ranges(pcie, pdev->dev.of_node);
+        if (err)
+               return err;
+
+       if (IS_ENABLED(CONFIG_PCI_MSI)) {
+               err = rcar_pcie_enable_msi(pcie);
+               if (err < 0) {
+                       dev_err(&pdev->dev,
+                               "failed to enable MSI support: %d\n",
+                               err);
+                       return err;
+               }
+       }
+
+       of_id = of_match_device(rcar_pcie_of_match, pcie->dev);
+       if (!of_id || !of_id->data)
+               return -EINVAL;
+       hw_init_fn = of_id->data;
+
+       /* Failure to get a link might just be that no cards are inserted */
+       err = hw_init_fn(pcie);
+       if (err) {
+               dev_info(&pdev->dev, "PCIe link down\n");
+               return 0;
+       }
+
+       data = rcar_pci_read_reg(pcie, MACSR);
+       dev_info(&pdev->dev, "PCIe x%d: link up\n", (data >> 20) & 0x3f);
+
+       rcar_pcie_enable(pcie);
+
+       return 0;
+}
+
+static struct platform_driver rcar_pcie_driver = {
+       .driver = {
+               .name = DRV_NAME,
+               .owner = THIS_MODULE,
+               .of_match_table = rcar_pcie_of_match,
+               .suppress_bind_attrs = true,
+       },
+       .probe = rcar_pcie_probe,
+};
+module_platform_driver(rcar_pcie_driver);
+
+MODULE_AUTHOR("Phil Edworthy <phil.edworthy@renesas.com>");
+MODULE_DESCRIPTION("Renesas R-Car PCIe driver");
+MODULE_LICENSE("GPL v2");
index 6eecd7c..54d3089 100644 (file)
@@ -125,9 +125,6 @@ sa1100_pcmcia_frequency_change(struct soc_pcmcia_socket *skt,
                if (freqs->new < freqs->old)
                        sa1100_pcmcia_set_mecr(skt, freqs->new);
                break;
-       case CPUFREQ_RESUMECHANGE:
-               sa1100_pcmcia_set_mecr(skt, freqs->new);
-               break;
        }
 
        return 0;
index c0fe609..e09474e 100644 (file)
@@ -468,6 +468,9 @@ int pinctrl_get_group_pins(struct pinctrl_dev *pctldev, const char *pin_group,
        const struct pinctrl_ops *pctlops = pctldev->desc->pctlops;
        int gs;
 
+       if (!pctlops->get_group_pins)
+               return -EINVAL;
+
        gs = pinctrl_get_group_selector(pctldev, pin_group);
        if (gs < 0)
                return gs;
@@ -1362,15 +1365,16 @@ static int pinctrl_groups_show(struct seq_file *s, void *what)
 
        seq_puts(s, "registered pin groups:\n");
        while (selector < ngroups) {
-               const unsigned *pins;
-               unsigned num_pins;
+               const unsigned *pins = NULL;
+               unsigned num_pins = 0;
                const char *gname = ops->get_group_name(pctldev, selector);
                const char *pname;
-               int ret;
+               int ret = 0;
                int i;
 
-               ret = ops->get_group_pins(pctldev, selector,
-                                         &pins, &num_pins);
+               if (ops->get_group_pins)
+                       ret = ops->get_group_pins(pctldev, selector,
+                                                 &pins, &num_pins);
                if (ret)
                        seq_printf(s, "%s [ERROR GETTING PINS]\n",
                                   gname);
@@ -1694,8 +1698,7 @@ static int pinctrl_check_ops(struct pinctrl_dev *pctldev)
 
        if (!ops ||
            !ops->get_groups_count ||
-           !ops->get_group_name ||
-           !ops->get_group_pins)
+           !ops->get_group_name)
                return -EINVAL;
 
        if (ops->dt_node_to_map && !ops->dt_free_map)
index 340fb4e..eda13de 100644 (file)
@@ -186,7 +186,9 @@ int pinctrl_dt_to_map(struct pinctrl *p)
 
        /* CONFIG_OF enabled, p->dev not instantiated from DT */
        if (!np) {
-               dev_dbg(p->dev, "no of_node; not parsing pinctrl DT\n");
+               if (of_have_populated_dt())
+                       dev_dbg(p->dev,
+                               "no of_node; not parsing pinctrl DT\n");
                return 0;
        }
 
index 3d9a999..29ff77f 100644 (file)
@@ -166,6 +166,7 @@ static struct pinconf_generic_dt_params dt_params[] = {
        { "input-schmitt-enable", PIN_CONFIG_INPUT_SCHMITT_ENABLE, 1 },
        { "input-schmitt-disable", PIN_CONFIG_INPUT_SCHMITT_ENABLE, 0 },
        { "input-debounce", PIN_CONFIG_INPUT_DEBOUNCE, 0 },
+       { "power-source", PIN_CONFIG_POWER_SOURCE, 0 },
        { "low-power-enable", PIN_CONFIG_LOW_POWER_MODE, 1 },
        { "low-power-disable", PIN_CONFIG_LOW_POWER_MODE, 0 },
        { "output-low", PIN_CONFIG_OUTPUT, 0, },
@@ -228,13 +229,12 @@ int pinconf_generic_parse_dt_config(struct device_node *np,
         * Now limit the number of configs to the real number of
         * found properties.
         */
-       *configs = kzalloc(ncfg * sizeof(unsigned long), GFP_KERNEL);
+       *configs = kmemdup(cfg, ncfg * sizeof(unsigned long), GFP_KERNEL);
        if (!*configs) {
                ret = -ENOMEM;
                goto out;
        }
 
-       memcpy(*configs, cfg, ncfg * sizeof(unsigned long));
        *nconfigs = ncfg;
 
 out:
index 9248ce4..051e859 100644 (file)
@@ -391,14 +391,16 @@ int pinmux_enable_setting(struct pinctrl_setting const *setting)
        struct pinctrl_dev *pctldev = setting->pctldev;
        const struct pinctrl_ops *pctlops = pctldev->desc->pctlops;
        const struct pinmux_ops *ops = pctldev->desc->pmxops;
-       int ret;
-       const unsigned *pins;
-       unsigned num_pins;
+       int ret = 0;
+       const unsigned *pins = NULL;
+       unsigned num_pins = 0;
        int i;
        struct pin_desc *desc;
 
-       ret = pctlops->get_group_pins(pctldev, setting->data.mux.group,
-                                     &pins, &num_pins);
+       if (pctlops->get_group_pins)
+               ret = pctlops->get_group_pins(pctldev, setting->data.mux.group,
+                                             &pins, &num_pins);
+
        if (ret) {
                const char *gname;
 
@@ -470,14 +472,15 @@ void pinmux_disable_setting(struct pinctrl_setting const *setting)
        struct pinctrl_dev *pctldev = setting->pctldev;
        const struct pinctrl_ops *pctlops = pctldev->desc->pctlops;
        const struct pinmux_ops *ops = pctldev->desc->pmxops;
-       int ret;
-       const unsigned *pins;
-       unsigned num_pins;
+       int ret = 0;
+       const unsigned *pins = NULL;
+       unsigned num_pins = 0;
        int i;
        struct pin_desc *desc;
 
-       ret = pctlops->get_group_pins(pctldev, setting->data.mux.group,
-                                     &pins, &num_pins);
+       if (pctlops->get_group_pins)
+               ret = pctlops->get_group_pins(pctldev, setting->data.mux.group,
+                                             &pins, &num_pins);
        if (ret) {
                const char *gname;
 
index b9b464d..6572c23 100644 (file)
@@ -542,7 +542,7 @@ static int sh_pfc_probe(struct platform_device *pdev)
         */
        ret = sh_pfc_register_pinctrl(pfc);
        if (unlikely(ret != 0))
-               goto error;
+               return ret;
 
 #ifdef CONFIG_GPIO_SH_PFC
        /*
@@ -564,11 +564,6 @@ static int sh_pfc_probe(struct platform_device *pdev)
        dev_info(pfc->dev, "%s support registered\n", info->name);
 
        return 0;
-
-error:
-       if (info->ops && info->ops->exit)
-               info->ops->exit(pfc);
-       return ret;
 }
 
 static int sh_pfc_remove(struct platform_device *pdev)
@@ -580,9 +575,6 @@ static int sh_pfc_remove(struct platform_device *pdev)
 #endif
        sh_pfc_unregister_pinctrl(pfc);
 
-       if (pfc->info->ops && pfc->info->ops->exit)
-               pfc->info->ops->exit(pfc);
-
        return 0;
 }
 
index b7b0e6c..3daaa52 100644 (file)
@@ -33,7 +33,6 @@ struct sh_pfc_pin_range {
 struct sh_pfc {
        struct device *dev;
        const struct sh_pfc_soc_info *info;
-       void *soc_data;
        spinlock_t lock;
 
        unsigned int num_windows;
index d39ca87..280a56f 100644 (file)
 #include <linux/io.h>
 #include <linux/kernel.h>
 #include <linux/pinctrl/pinconf-generic.h>
+
+#ifndef CONFIG_ARCH_MULTIPLATFORM
 #include <mach/irqs.h>
+#endif
 
 #include "core.h"
 #include "sh_pfc.h"
@@ -2714,14 +2717,14 @@ static void r8a73a4_pinmux_set_bias(struct sh_pfc *pfc, unsigned int pin,
        iowrite8(value, addr);
 }
 
-static const struct sh_pfc_soc_operations r8a73a4_pinmux_ops = {
+static const struct sh_pfc_soc_operations r8a73a4_pfc_ops = {
        .get_bias = r8a73a4_pinmux_get_bias,
        .set_bias = r8a73a4_pinmux_set_bias,
 };
 
 const struct sh_pfc_soc_info r8a73a4_pinmux_info = {
        .name           = "r8a73a4_pfc",
-       .ops            = &r8a73a4_pinmux_ops,
+       .ops            = &r8a73a4_pfc_ops,
 
        .input = { PINMUX_INPUT_BEGIN, PINMUX_INPUT_END },
        .output = { PINMUX_OUTPUT_BEGIN, PINMUX_OUTPUT_END },
index 6c83ce4..b486e9d 100644 (file)
@@ -22,7 +22,9 @@
 #include <linux/kernel.h>
 #include <linux/pinctrl/pinconf-generic.h>
 
+#ifndef CONFIG_ARCH_MULTIPLATFORM
 #include <mach/irqs.h>
+#endif
 
 #include "core.h"
 #include "sh_pfc.h"
@@ -3750,14 +3752,14 @@ static void r8a7740_pinmux_set_bias(struct sh_pfc *pfc, unsigned int pin,
        iowrite8(value, addr);
 }
 
-static const struct sh_pfc_soc_operations r8a7740_pinmux_ops = {
+static const struct sh_pfc_soc_operations r8a7740_pfc_ops = {
        .get_bias = r8a7740_pinmux_get_bias,
        .set_bias = r8a7740_pinmux_set_bias,
 };
 
 const struct sh_pfc_soc_info r8a7740_pinmux_info = {
        .name           = "r8a7740_pfc",
-       .ops            = &r8a7740_pinmux_ops,
+       .ops            = &r8a7740_pfc_ops,
 
        .input          = { PINMUX_INPUT_BEGIN,
                            PINMUX_INPUT_END },
index c381ae6..9a179c9 100644 (file)
@@ -782,7 +782,8 @@ enum {
        USB1_PWEN_MARK, AUDIO_CLKOUT_D_MARK, USB1_OVC_MARK,
        TCLK1_B_MARK,
 
-       I2C3_SCL_MARK, I2C3_SDA_MARK,
+       IIC0_SCL_MARK, IIC0_SDA_MARK, I2C0_SCL_MARK, I2C0_SDA_MARK,
+       IIC3_SCL_MARK, IIC3_SDA_MARK, I2C3_SCL_MARK, I2C3_SDA_MARK,
        PINMUX_MARK_END,
 };
 
@@ -1722,6 +1723,13 @@ static const u16 pinmux_data[] = {
        PINMUX_IPSR_DATA(IP16_7, USB1_OVC),
        PINMUX_IPSR_MODSEL_DATA(IP16_7, TCLK1_B, SEL_TMU1_1),
 
+       PINMUX_DATA(IIC0_SCL_MARK, FN_SEL_IIC0_0),
+       PINMUX_DATA(IIC0_SDA_MARK, FN_SEL_IIC0_0),
+       PINMUX_DATA(I2C0_SCL_MARK, FN_SEL_IIC0_1),
+       PINMUX_DATA(I2C0_SDA_MARK, FN_SEL_IIC0_1),
+
+       PINMUX_DATA(IIC3_SCL_MARK, FN_SEL_IICDVFS_0),
+       PINMUX_DATA(IIC3_SDA_MARK, FN_SEL_IICDVFS_0),
        PINMUX_DATA(I2C3_SCL_MARK, FN_SEL_IICDVFS_1),
        PINMUX_DATA(I2C3_SDA_MARK, FN_SEL_IICDVFS_1),
 };
@@ -1735,8 +1743,10 @@ static const struct sh_pfc_pin pinmux_pins[] = {
        PINMUX_GPIO_GP_ALL(),
 
        /* Pins not associated with a GPIO port */
-       SH_PFC_PIN_NAMED(ROW_GROUP_A('J'), 15, AJ15),
+       SH_PFC_PIN_NAMED(ROW_GROUP_A('F'), 15, AF15),
+       SH_PFC_PIN_NAMED(ROW_GROUP_A('G'), 15, AG15),
        SH_PFC_PIN_NAMED(ROW_GROUP_A('H'), 15, AH15),
+       SH_PFC_PIN_NAMED(ROW_GROUP_A('J'), 15, AJ15),
 };
 
 /* - AUDIO CLOCK ------------------------------------------------------------ */
@@ -2054,6 +2064,14 @@ static const unsigned int hscif1_ctrl_b_pins[] = {
 static const unsigned int hscif1_ctrl_b_mux[] = {
        HRTS1_N_B_MARK, HCTS1_N_B_MARK,
 };
+/* - I2C0 ------------------------------------------------------------------- */
+static const unsigned int i2c0_pins[] = {
+       /* SCL, SDA */
+       PIN_A_NUMBER('G', 15), PIN_A_NUMBER('F', 15),
+};
+static const unsigned int i2c0_mux[] = {
+       I2C0_SCL_MARK, I2C0_SDA_MARK,
+};
 /* - I2C1 ------------------------------------------------------------------- */
 static const unsigned int i2c1_pins[] = {
        /* SCL, SDA */
@@ -2120,6 +2138,80 @@ static const unsigned int i2c3_pins[] = {
 static const unsigned int i2c3_mux[] = {
        I2C3_SCL_MARK, I2C3_SDA_MARK,
 };
+/* - IIC0 (I2C4) ------------------------------------------------------------ */
+static const unsigned int iic0_pins[] = {
+       /* SCL, SDA */
+       PIN_A_NUMBER('G', 15), PIN_A_NUMBER('F', 15),
+};
+static const unsigned int iic0_mux[] = {
+       IIC0_SCL_MARK, IIC0_SDA_MARK,
+};
+/* - IIC1 (I2C5) ------------------------------------------------------------ */
+static const unsigned int iic1_pins[] = {
+       /* SCL, SDA */
+       RCAR_GP_PIN(1, 16), RCAR_GP_PIN(1, 17),
+};
+static const unsigned int iic1_mux[] = {
+       IIC1_SCL_MARK, IIC1_SDA_MARK,
+};
+static const unsigned int iic1_b_pins[] = {
+       /* SCL, SDA */
+       RCAR_GP_PIN(3, 6), RCAR_GP_PIN(3, 7),
+};
+static const unsigned int iic1_b_mux[] = {
+       IIC1_SCL_B_MARK, IIC1_SDA_B_MARK,
+};
+static const unsigned int iic1_c_pins[] = {
+       /* SCL, SDA */
+       RCAR_GP_PIN(4, 30), RCAR_GP_PIN(4, 27),
+};
+static const unsigned int iic1_c_mux[] = {
+       IIC1_SCL_C_MARK, IIC1_SDA_C_MARK,
+};
+/* - IIC2 (I2C6) ------------------------------------------------------------ */
+static const unsigned int iic2_pins[] = {
+       /* SCL, SDA */
+       RCAR_GP_PIN(5, 5), RCAR_GP_PIN(5, 6),
+};
+static const unsigned int iic2_mux[] = {
+       IIC2_SCL_MARK, IIC2_SDA_MARK,
+};
+static const unsigned int iic2_b_pins[] = {
+       /* SCL, SDA */
+       RCAR_GP_PIN(4, 0), RCAR_GP_PIN(4, 1),
+};
+static const unsigned int iic2_b_mux[] = {
+       IIC2_SCL_B_MARK, IIC2_SDA_B_MARK,
+};
+static const unsigned int iic2_c_pins[] = {
+       /* SCL, SDA */
+       RCAR_GP_PIN(0, 6), RCAR_GP_PIN(0, 7),
+};
+static const unsigned int iic2_c_mux[] = {
+       IIC2_SCL_C_MARK, IIC2_SDA_C_MARK,
+};
+static const unsigned int iic2_d_pins[] = {
+       /* SCL, SDA */
+       RCAR_GP_PIN(3, 14), RCAR_GP_PIN(3, 15),
+};
+static const unsigned int iic2_d_mux[] = {
+       IIC2_SCL_D_MARK, IIC2_SDA_D_MARK,
+};
+static const unsigned int iic2_e_pins[] = {
+       /* SCL, SDA */
+       RCAR_GP_PIN(2, 18), RCAR_GP_PIN(2, 19),
+};
+static const unsigned int iic2_e_mux[] = {
+       IIC2_SCL_E_MARK, IIC2_SDA_E_MARK,
+};
+/* - IIC3 (I2C7) ------------------------------------------------------------ */
+static const unsigned int iic3_pins[] = {
+/* SCL, SDA */
+       PIN_A_NUMBER('J', 15), PIN_A_NUMBER('H', 15),
+};
+static const unsigned int iic3_mux[] = {
+       IIC3_SCL_MARK, IIC3_SDA_MARK,
+};
 /* - INTC ------------------------------------------------------------------- */
 static const unsigned int intc_irq0_pins[] = {
        /* IRQ */
@@ -2260,6 +2352,42 @@ static const unsigned int msiof0_tx_pins[] = {
 static const unsigned int msiof0_tx_mux[] = {
        MSIOF0_TXD_MARK,
 };
+
+static const unsigned int msiof0_clk_b_pins[] = {
+       /* SCK */
+       RCAR_GP_PIN(1, 23),
+};
+static const unsigned int msiof0_clk_b_mux[] = {
+       MSIOF0_SCK_B_MARK,
+};
+static const unsigned int msiof0_ss1_b_pins[] = {
+       /* SS1 */
+       RCAR_GP_PIN(1, 12),
+};
+static const unsigned int msiof0_ss1_b_mux[] = {
+       MSIOF0_SS1_B_MARK,
+};
+static const unsigned int msiof0_ss2_b_pins[] = {
+       /* SS2 */
+       RCAR_GP_PIN(1, 10),
+};
+static const unsigned int msiof0_ss2_b_mux[] = {
+       MSIOF0_SS2_B_MARK,
+};
+static const unsigned int msiof0_rx_b_pins[] = {
+       /* RXD */
+       RCAR_GP_PIN(1, 29),
+};
+static const unsigned int msiof0_rx_b_mux[] = {
+       MSIOF0_RXD_B_MARK,
+};
+static const unsigned int msiof0_tx_b_pins[] = {
+       /* TXD */
+       RCAR_GP_PIN(1, 28),
+};
+static const unsigned int msiof0_tx_b_mux[] = {
+       MSIOF0_TXD_B_MARK,
+};
 /* - MSIOF1 ----------------------------------------------------------------- */
 static const unsigned int msiof1_clk_pins[] = {
        /* SCK */
@@ -2303,6 +2431,42 @@ static const unsigned int msiof1_tx_pins[] = {
 static const unsigned int msiof1_tx_mux[] = {
        MSIOF1_TXD_MARK,
 };
+
+static const unsigned int msiof1_clk_b_pins[] = {
+       /* SCK */
+       RCAR_GP_PIN(1, 16),
+};
+static const unsigned int msiof1_clk_b_mux[] = {
+       MSIOF1_SCK_B_MARK,
+};
+static const unsigned int msiof1_ss1_b_pins[] = {
+       /* SS1 */
+       RCAR_GP_PIN(0, 18),
+};
+static const unsigned int msiof1_ss1_b_mux[] = {
+       MSIOF1_SS1_B_MARK,
+};
+static const unsigned int msiof1_ss2_b_pins[] = {
+       /* SS2 */
+       RCAR_GP_PIN(0, 19),
+};
+static const unsigned int msiof1_ss2_b_mux[] = {
+       MSIOF1_SS2_B_MARK,
+};
+static const unsigned int msiof1_rx_b_pins[] = {
+       /* RXD */
+       RCAR_GP_PIN(1, 17),
+};
+static const unsigned int msiof1_rx_b_mux[] = {
+       MSIOF1_RXD_B_MARK,
+};
+static const unsigned int msiof1_tx_b_pins[] = {
+       /* TXD */
+       RCAR_GP_PIN(0, 20),
+};
+static const unsigned int msiof1_tx_b_mux[] = {
+       MSIOF1_TXD_B_MARK,
+};
 /* - MSIOF2 ----------------------------------------------------------------- */
 static const unsigned int msiof2_clk_pins[] = {
        /* SCK */
@@ -2389,6 +2553,58 @@ static const unsigned int msiof3_tx_pins[] = {
 static const unsigned int msiof3_tx_mux[] = {
        MSIOF3_TXD_MARK,
 };
+
+static const unsigned int msiof3_clk_b_pins[] = {
+       /* SCK */
+       RCAR_GP_PIN(0, 0),
+};
+static const unsigned int msiof3_clk_b_mux[] = {
+       MSIOF3_SCK_B_MARK,
+};
+static const unsigned int msiof3_sync_b_pins[] = {
+       /* SYNC */
+       RCAR_GP_PIN(0, 1),
+};
+static const unsigned int msiof3_sync_b_mux[] = {
+       MSIOF3_SYNC_B_MARK,
+};
+static const unsigned int msiof3_rx_b_pins[] = {
+       /* RXD */
+       RCAR_GP_PIN(0, 2),
+};
+static const unsigned int msiof3_rx_b_mux[] = {
+       MSIOF3_RXD_B_MARK,
+};
+static const unsigned int msiof3_tx_b_pins[] = {
+       /* TXD */
+       RCAR_GP_PIN(0, 3),
+};
+static const unsigned int msiof3_tx_b_mux[] = {
+       MSIOF3_TXD_B_MARK,
+};
+/* - QSPI ------------------------------------------------------------------- */
+static const unsigned int qspi_ctrl_pins[] = {
+       /* SPCLK, SSL */
+       RCAR_GP_PIN(1, 4), RCAR_GP_PIN(1, 9),
+};
+static const unsigned int qspi_ctrl_mux[] = {
+       SPCLK_MARK, SSL_MARK,
+};
+static const unsigned int qspi_data2_pins[] = {
+       /* MOSI_IO0, MISO_IO1 */
+       RCAR_GP_PIN(1, 5), RCAR_GP_PIN(1, 6),
+};
+static const unsigned int qspi_data2_mux[] = {
+       MOSI_IO0_MARK, MISO_IO1_MARK,
+};
+static const unsigned int qspi_data4_pins[] = {
+       /* MOSI_IO0, MISO_IO1, IO2, IO3 */
+       RCAR_GP_PIN(1, 5), RCAR_GP_PIN(1, 6), RCAR_GP_PIN(1, 7),
+       RCAR_GP_PIN(1, 8),
+};
+static const unsigned int qspi_data4_mux[] = {
+       MOSI_IO0_MARK, MISO_IO1_MARK, IO2_MARK, IO3_MARK,
+};
 /* - SCIF0 ------------------------------------------------------------------ */
 static const unsigned int scif0_data_pins[] = {
        /* RX, TX */
@@ -3231,6 +3447,13 @@ static const unsigned int usb0_pins[] = {
 static const unsigned int usb0_mux[] = {
        USB0_PWEN_MARK, USB0_OVC_VBUS_MARK,
 };
+static const unsigned int usb0_ovc_vbus_pins[] = {
+       /* OVC/VBUS */
+       RCAR_GP_PIN(5, 19),
+};
+static const unsigned int usb0_ovc_vbus_mux[] = {
+       USB0_OVC_VBUS_MARK,
+};
 /* - USB1 ------------------------------------------------------------------- */
 static const unsigned int usb1_pins[] = {
        /* PWEN, OVC */
@@ -3626,6 +3849,7 @@ static const struct sh_pfc_pin_group pinmux_groups[] = {
        SH_PFC_PIN_GROUP(hscif1_data_b),
        SH_PFC_PIN_GROUP(hscif1_clk_b),
        SH_PFC_PIN_GROUP(hscif1_ctrl_b),
+       SH_PFC_PIN_GROUP(i2c0),
        SH_PFC_PIN_GROUP(i2c1),
        SH_PFC_PIN_GROUP(i2c1_b),
        SH_PFC_PIN_GROUP(i2c1_c),
@@ -3635,6 +3859,16 @@ static const struct sh_pfc_pin_group pinmux_groups[] = {
        SH_PFC_PIN_GROUP(i2c2_d),
        SH_PFC_PIN_GROUP(i2c2_e),
        SH_PFC_PIN_GROUP(i2c3),
+       SH_PFC_PIN_GROUP(iic0),
+       SH_PFC_PIN_GROUP(iic1),
+       SH_PFC_PIN_GROUP(iic1_b),
+       SH_PFC_PIN_GROUP(iic1_c),
+       SH_PFC_PIN_GROUP(iic2),
+       SH_PFC_PIN_GROUP(iic2_b),
+       SH_PFC_PIN_GROUP(iic2_c),
+       SH_PFC_PIN_GROUP(iic2_d),
+       SH_PFC_PIN_GROUP(iic2_e),
+       SH_PFC_PIN_GROUP(iic3),
        SH_PFC_PIN_GROUP(intc_irq0),
        SH_PFC_PIN_GROUP(intc_irq1),
        SH_PFC_PIN_GROUP(intc_irq2),
@@ -3653,12 +3887,22 @@ static const struct sh_pfc_pin_group pinmux_groups[] = {
        SH_PFC_PIN_GROUP(msiof0_ss2),
        SH_PFC_PIN_GROUP(msiof0_rx),
        SH_PFC_PIN_GROUP(msiof0_tx),
+       SH_PFC_PIN_GROUP(msiof0_clk_b),
+       SH_PFC_PIN_GROUP(msiof0_ss1_b),
+       SH_PFC_PIN_GROUP(msiof0_ss2_b),
+       SH_PFC_PIN_GROUP(msiof0_rx_b),
+       SH_PFC_PIN_GROUP(msiof0_tx_b),
        SH_PFC_PIN_GROUP(msiof1_clk),
        SH_PFC_PIN_GROUP(msiof1_sync),
        SH_PFC_PIN_GROUP(msiof1_ss1),
        SH_PFC_PIN_GROUP(msiof1_ss2),
        SH_PFC_PIN_GROUP(msiof1_rx),
        SH_PFC_PIN_GROUP(msiof1_tx),
+       SH_PFC_PIN_GROUP(msiof1_clk_b),
+       SH_PFC_PIN_GROUP(msiof1_ss1_b),
+       SH_PFC_PIN_GROUP(msiof1_ss2_b),
+       SH_PFC_PIN_GROUP(msiof1_rx_b),
+       SH_PFC_PIN_GROUP(msiof1_tx_b),
        SH_PFC_PIN_GROUP(msiof2_clk),
        SH_PFC_PIN_GROUP(msiof2_sync),
        SH_PFC_PIN_GROUP(msiof2_ss1),
@@ -3671,6 +3915,13 @@ static const struct sh_pfc_pin_group pinmux_groups[] = {
        SH_PFC_PIN_GROUP(msiof3_ss2),
        SH_PFC_PIN_GROUP(msiof3_rx),
        SH_PFC_PIN_GROUP(msiof3_tx),
+       SH_PFC_PIN_GROUP(msiof3_clk_b),
+       SH_PFC_PIN_GROUP(msiof3_sync_b),
+       SH_PFC_PIN_GROUP(msiof3_rx_b),
+       SH_PFC_PIN_GROUP(msiof3_tx_b),
+       SH_PFC_PIN_GROUP(qspi_ctrl),
+       SH_PFC_PIN_GROUP(qspi_data2),
+       SH_PFC_PIN_GROUP(qspi_data4),
        SH_PFC_PIN_GROUP(scif0_data),
        SH_PFC_PIN_GROUP(scif0_clk),
        SH_PFC_PIN_GROUP(scif0_ctrl),
@@ -3789,6 +4040,7 @@ static const struct sh_pfc_pin_group pinmux_groups[] = {
        SH_PFC_PIN_GROUP(tpu0_to2),
        SH_PFC_PIN_GROUP(tpu0_to3),
        SH_PFC_PIN_GROUP(usb0),
+       SH_PFC_PIN_GROUP(usb0_ovc_vbus),
        SH_PFC_PIN_GROUP(usb1),
        SH_PFC_PIN_GROUP(usb2),
        VIN_DATA_PIN_GROUP(vin0_data, 24),
@@ -3895,6 +4147,10 @@ static const char * const hscif1_groups[] = {
        "hscif1_ctrl_b",
 };
 
+static const char * const i2c0_groups[] = {
+       "i2c0",
+};
+
 static const char * const i2c1_groups[] = {
        "i2c1",
        "i2c1_b",
@@ -3913,6 +4169,28 @@ static const char * const i2c3_groups[] = {
        "i2c3",
 };
 
+static const char * const iic0_groups[] = {
+       "iic0",
+};
+
+static const char * const iic1_groups[] = {
+       "iic1",
+       "iic1_b",
+       "iic1_c",
+};
+
+static const char * const iic2_groups[] = {
+       "iic2",
+       "iic2_b",
+       "iic2_c",
+       "iic2_d",
+       "iic2_e",
+};
+
+static const char * const iic3_groups[] = {
+       "iic3",
+};
+
 static const char * const intc_groups[] = {
        "intc_irq0",
        "intc_irq1",
@@ -3941,6 +4219,11 @@ static const char * const msiof0_groups[] = {
        "msiof0_ss2",
        "msiof0_rx",
        "msiof0_tx",
+       "msiof0_clk_b",
+       "msiof0_ss1_b",
+       "msiof0_ss2_b",
+       "msiof0_rx_b",
+       "msiof0_tx_b",
 };
 
 static const char * const msiof1_groups[] = {
@@ -3950,6 +4233,11 @@ static const char * const msiof1_groups[] = {
        "msiof1_ss2",
        "msiof1_rx",
        "msiof1_tx",
+       "msiof1_clk_b",
+       "msiof1_ss1_b",
+       "msiof1_ss2_b",
+       "msiof1_rx_b",
+       "msiof1_tx_b",
 };
 
 static const char * const msiof2_groups[] = {
@@ -3968,6 +4256,16 @@ static const char * const msiof3_groups[] = {
        "msiof3_ss2",
        "msiof3_rx",
        "msiof3_tx",
+       "msiof3_clk_b",
+       "msiof3_sync_b",
+       "msiof3_rx_b",
+       "msiof3_tx_b",
+};
+
+static const char * const qspi_groups[] = {
+       "qspi_ctrl",
+       "qspi_data2",
+       "qspi_data4",
 };
 
 static const char * const scif0_groups[] = {
@@ -4134,6 +4432,7 @@ static const char * const tpu0_groups[] = {
 
 static const char * const usb0_groups[] = {
        "usb0",
+       "usb0_ovc_vbus",
 };
 
 static const char * const usb1_groups[] = {
@@ -4203,9 +4502,14 @@ static const struct sh_pfc_function pinmux_functions[] = {
        SH_PFC_FUNCTION(eth),
        SH_PFC_FUNCTION(hscif0),
        SH_PFC_FUNCTION(hscif1),
+       SH_PFC_FUNCTION(i2c0),
        SH_PFC_FUNCTION(i2c1),
        SH_PFC_FUNCTION(i2c2),
        SH_PFC_FUNCTION(i2c3),
+       SH_PFC_FUNCTION(iic0),
+       SH_PFC_FUNCTION(iic1),
+       SH_PFC_FUNCTION(iic2),
+       SH_PFC_FUNCTION(iic3),
        SH_PFC_FUNCTION(intc),
        SH_PFC_FUNCTION(mmc0),
        SH_PFC_FUNCTION(mmc1),
@@ -4213,6 +4517,7 @@ static const struct sh_pfc_function pinmux_functions[] = {
        SH_PFC_FUNCTION(msiof1),
        SH_PFC_FUNCTION(msiof2),
        SH_PFC_FUNCTION(msiof3),
+       SH_PFC_FUNCTION(qspi),
        SH_PFC_FUNCTION(scif0),
        SH_PFC_FUNCTION(scif1),
        SH_PFC_FUNCTION(scif2),
@@ -4623,8 +4928,7 @@ static const struct pinmux_cfg_reg pinmux_config_regs[] = {
                FN_MSIOF0_SCK_B, 0,
                /* IP5_23_21 [3] */
                FN_WE1_N, FN_IERX, FN_CAN1_RX, FN_VI1_G4,
-               FN_VI1_G4_B, FN_VI2_R6, FN_SCIFA0_CTS_N_B,
-               FN_IERX_C, 0,
+               FN_VI1_G4_B, FN_VI2_R6, FN_SCIFA0_CTS_N_B, FN_IERX_C,
                /* IP5_20_18 [3] */
                FN_WE0_N, FN_IECLK, FN_CAN_CLK,
                FN_VI2_VSYNC_N, FN_SCIFA0_TXD_B, FN_VI2_VSYNC_N_B, 0, 0,
index 567d691..c6e5deb 100644 (file)
@@ -1680,6 +1680,180 @@ static const struct sh_pfc_pin pinmux_pins[] = {
        PINMUX_GPIO_GP_ALL(),
 };
 
+/* - Audio Clock ------------------------------------------------------------ */
+static const unsigned int audio_clk_a_pins[] = {
+       /* CLK */
+       RCAR_GP_PIN(2, 28),
+};
+
+static const unsigned int audio_clk_a_mux[] = {
+       AUDIO_CLKA_MARK,
+};
+
+static const unsigned int audio_clk_b_pins[] = {
+       /* CLK */
+       RCAR_GP_PIN(2, 29),
+};
+
+static const unsigned int audio_clk_b_mux[] = {
+       AUDIO_CLKB_MARK,
+};
+
+static const unsigned int audio_clk_b_b_pins[] = {
+       /* CLK */
+       RCAR_GP_PIN(7, 20),
+};
+
+static const unsigned int audio_clk_b_b_mux[] = {
+       AUDIO_CLKB_B_MARK,
+};
+
+static const unsigned int audio_clk_c_pins[] = {
+       /* CLK */
+       RCAR_GP_PIN(2, 30),
+};
+
+static const unsigned int audio_clk_c_mux[] = {
+       AUDIO_CLKC_MARK,
+};
+
+static const unsigned int audio_clkout_pins[] = {
+       /* CLK */
+       RCAR_GP_PIN(2, 31),
+};
+
+static const unsigned int audio_clkout_mux[] = {
+       AUDIO_CLKOUT_MARK,
+};
+
+/* - CAN -------------------------------------------------------------------- */
+
+static const unsigned int can0_data_pins[] = {
+       /* TX, RX */
+       RCAR_GP_PIN(3, 26), RCAR_GP_PIN(3, 29),
+};
+
+static const unsigned int can0_data_mux[] = {
+       CAN0_TX_MARK, CAN0_RX_MARK,
+};
+
+static const unsigned int can0_data_b_pins[] = {
+       /* TX, RX */
+       RCAR_GP_PIN(7, 4), RCAR_GP_PIN(7, 3),
+};
+
+static const unsigned int can0_data_b_mux[] = {
+       CAN0_TX_B_MARK, CAN0_RX_B_MARK,
+};
+
+static const unsigned int can0_data_c_pins[] = {
+       /* TX, RX */
+       RCAR_GP_PIN(5, 17), RCAR_GP_PIN(5, 18),
+};
+
+static const unsigned int can0_data_c_mux[] = {
+       CAN0_TX_C_MARK, CAN0_RX_C_MARK,
+};
+
+static const unsigned int can0_data_d_pins[] = {
+       /* TX, RX */
+       RCAR_GP_PIN(2, 26), RCAR_GP_PIN(2, 27),
+};
+
+static const unsigned int can0_data_d_mux[] = {
+       CAN0_TX_D_MARK, CAN0_RX_D_MARK,
+};
+
+static const unsigned int can0_data_e_pins[] = {
+       /* TX, RX */
+       RCAR_GP_PIN(4, 18), RCAR_GP_PIN(4, 28),
+};
+
+static const unsigned int can0_data_e_mux[] = {
+       CAN0_TX_E_MARK, CAN0_RX_E_MARK,
+};
+
+static const unsigned int can0_data_f_pins[] = {
+       /* TX, RX */
+       RCAR_GP_PIN(6, 7), RCAR_GP_PIN(6, 6),
+};
+
+static const unsigned int can0_data_f_mux[] = {
+       CAN0_TX_F_MARK, CAN0_RX_F_MARK,
+};
+
+static const unsigned int can1_data_pins[] = {
+       /* TX, RX */
+        RCAR_GP_PIN(3, 21), RCAR_GP_PIN(3, 20),
+};
+
+static const unsigned int can1_data_mux[] = {
+       CAN1_TX_MARK, CAN1_RX_MARK,
+};
+
+static const unsigned int can1_data_b_pins[] = {
+       /* TX, RX */
+       RCAR_GP_PIN(7, 8), RCAR_GP_PIN(7, 9),
+};
+
+static const unsigned int can1_data_b_mux[] = {
+       CAN1_TX_B_MARK, CAN1_RX_B_MARK,
+};
+
+static const unsigned int can1_data_c_pins[] = {
+       /* TX, RX */
+       RCAR_GP_PIN(5, 20), RCAR_GP_PIN(5, 19),
+};
+
+static const unsigned int can1_data_c_mux[] = {
+       CAN1_TX_C_MARK, CAN1_RX_C_MARK,
+};
+
+static const unsigned int can1_data_d_pins[] = {
+       /* TX, RX */
+        RCAR_GP_PIN(4, 29), RCAR_GP_PIN(4, 31),
+};
+
+static const unsigned int can1_data_d_mux[] = {
+       CAN1_TX_D_MARK, CAN1_RX_D_MARK,
+};
+
+static const unsigned int can_clk_pins[] = {
+       /* CLK */
+       RCAR_GP_PIN(7, 2),
+};
+
+static const unsigned int can_clk_mux[] = {
+       CAN_CLK_MARK,
+};
+
+static const unsigned int can_clk_b_pins[] = {
+       /* CLK */
+       RCAR_GP_PIN(5, 21),
+};
+
+static const unsigned int can_clk_b_mux[] = {
+       CAN_CLK_B_MARK,
+};
+
+static const unsigned int can_clk_c_pins[] = {
+       /* CLK */
+       RCAR_GP_PIN(4, 30),
+};
+
+static const unsigned int can_clk_c_mux[] = {
+       CAN_CLK_C_MARK,
+};
+
+static const unsigned int can_clk_d_pins[] = {
+       /* CLK */
+       RCAR_GP_PIN(7, 19),
+};
+
+static const unsigned int can_clk_d_mux[] = {
+       CAN_CLK_D_MARK,
+};
+
 /* - DU --------------------------------------------------------------------- */
 static const unsigned int du_rgb666_pins[] = {
        /* R[7:2], G[7:2], B[7:2] */
@@ -1733,19 +1907,32 @@ static const unsigned int du_clk_out_1_mux[] = {
        DU1_DOTCLKOUT1_MARK
 };
 static const unsigned int du_sync_pins[] = {
-       /* EXVSYNC/VSYNC, EXHSYNC/HSYNC, EXDISP/EXODDF/EXCDE */
-       RCAR_GP_PIN(3, 29), RCAR_GP_PIN(3, 28), RCAR_GP_PIN(3, 27),
+       /* EXVSYNC/VSYNC, EXHSYNC/HSYNC */
+       RCAR_GP_PIN(3, 28), RCAR_GP_PIN(3, 27),
 };
 static const unsigned int du_sync_mux[] = {
-       DU1_EXODDF_DU1_ODDF_DISP_CDE_MARK,
        DU1_EXVSYNC_DU1_VSYNC_MARK, DU1_EXHSYNC_DU1_HSYNC_MARK
 };
-static const unsigned int du_cde_disp_pins[] = {
-       /* CDE DISP */
-       RCAR_GP_PIN(3, 31), RCAR_GP_PIN(3, 30),
+static const unsigned int du_oddf_pins[] = {
+       /* EXDISP/EXODDF/EXCDE */
+       RCAR_GP_PIN(3, 29),
+};
+static const unsigned int du_oddf_mux[] = {
+       DU1_EXODDF_DU1_ODDF_DISP_CDE_MARK,
+};
+static const unsigned int du_cde_pins[] = {
+       /* CDE */
+       RCAR_GP_PIN(3, 31),
+};
+static const unsigned int du_cde_mux[] = {
+       DU1_CDE_MARK,
+};
+static const unsigned int du_disp_pins[] = {
+       /* DISP */
+       RCAR_GP_PIN(3, 30),
 };
-static const unsigned int du_cde_disp_mux[] = {
-       DU1_CDE_MARK, DU1_DISP_MARK
+static const unsigned int du_disp_mux[] = {
+       DU1_DISP_MARK,
 };
 static const unsigned int du0_clk_in_pins[] = {
        /* CLKIN */
@@ -1807,6 +1994,192 @@ static const unsigned int eth_rmii_mux[] = {
        ETH_RXD0_MARK, ETH_RXD1_MARK, ETH_RX_ER_MARK, ETH_CRS_DV_MARK,
        ETH_TXD0_MARK, ETH_TXD1_MARK, ETH_TX_EN_MARK, ETH_REFCLK_MARK,
 };
+
+/* - HSCIF0 ----------------------------------------------------------------- */
+static const unsigned int hscif0_data_pins[] = {
+       /* RX, TX */
+       RCAR_GP_PIN(7, 3), RCAR_GP_PIN(7, 4),
+};
+static const unsigned int hscif0_data_mux[] = {
+       HRX0_MARK, HTX0_MARK,
+};
+static const unsigned int hscif0_clk_pins[] = {
+       /* SCK */
+       RCAR_GP_PIN(7, 2),
+};
+static const unsigned int hscif0_clk_mux[] = {
+       HSCK0_MARK,
+};
+static const unsigned int hscif0_ctrl_pins[] = {
+       /* RTS, CTS */
+       RCAR_GP_PIN(7, 1), RCAR_GP_PIN(7, 0),
+};
+static const unsigned int hscif0_ctrl_mux[] = {
+       HRTS0_N_MARK, HCTS0_N_MARK,
+};
+static const unsigned int hscif0_data_b_pins[] = {
+       /* RX, TX */
+       RCAR_GP_PIN(3, 12), RCAR_GP_PIN(3, 15),
+};
+static const unsigned int hscif0_data_b_mux[] = {
+       HRX0_B_MARK, HTX0_B_MARK,
+};
+static const unsigned int hscif0_ctrl_b_pins[] = {
+       /* RTS, CTS */
+       RCAR_GP_PIN(3, 14), RCAR_GP_PIN(3, 13),
+};
+static const unsigned int hscif0_ctrl_b_mux[] = {
+       HRTS0_N_B_MARK, HCTS0_N_B_MARK,
+};
+static const unsigned int hscif0_data_c_pins[] = {
+       /* RX, TX */
+       RCAR_GP_PIN(2, 0), RCAR_GP_PIN(2, 1),
+};
+static const unsigned int hscif0_data_c_mux[] = {
+       HRX0_C_MARK, HTX0_C_MARK,
+};
+static const unsigned int hscif0_clk_c_pins[] = {
+       /* SCK */
+       RCAR_GP_PIN(5, 31),
+};
+static const unsigned int hscif0_clk_c_mux[] = {
+       HSCK0_C_MARK,
+};
+/* - HSCIF1 ----------------------------------------------------------------- */
+static const unsigned int hscif1_data_pins[] = {
+       /* RX, TX */
+       RCAR_GP_PIN(7, 5), RCAR_GP_PIN(7, 6),
+};
+static const unsigned int hscif1_data_mux[] = {
+       HRX1_MARK, HTX1_MARK,
+};
+static const unsigned int hscif1_clk_pins[] = {
+       /* SCK */
+       RCAR_GP_PIN(7, 7),
+};
+static const unsigned int hscif1_clk_mux[] = {
+       HSCK1_MARK,
+};
+static const unsigned int hscif1_ctrl_pins[] = {
+       /* RTS, CTS */
+       RCAR_GP_PIN(7, 9), RCAR_GP_PIN(7, 8),
+};
+static const unsigned int hscif1_ctrl_mux[] = {
+       HRTS1_N_MARK, HCTS1_N_MARK,
+};
+static const unsigned int hscif1_data_b_pins[] = {
+       /* RX, TX */
+       RCAR_GP_PIN(1, 17), RCAR_GP_PIN(1, 18),
+};
+static const unsigned int hscif1_data_b_mux[] = {
+       HRX1_B_MARK, HTX1_B_MARK,
+};
+static const unsigned int hscif1_data_c_pins[] = {
+       /* RX, TX */
+       RCAR_GP_PIN(7, 14), RCAR_GP_PIN(7, 15),
+};
+static const unsigned int hscif1_data_c_mux[] = {
+       HRX1_C_MARK, HTX1_C_MARK,
+};
+static const unsigned int hscif1_clk_c_pins[] = {
+       /* SCK */
+       RCAR_GP_PIN(7, 16),
+};
+static const unsigned int hscif1_clk_c_mux[] = {
+       HSCK1_C_MARK,
+};
+static const unsigned int hscif1_ctrl_c_pins[] = {
+       /* RTS, CTS */
+       RCAR_GP_PIN(7, 18), RCAR_GP_PIN(7, 17),
+};
+static const unsigned int hscif1_ctrl_c_mux[] = {
+       HRTS1_N_C_MARK, HCTS1_N_C_MARK,
+};
+static const unsigned int hscif1_data_d_pins[] = {
+       /* RX, TX */
+       RCAR_GP_PIN(4, 28), RCAR_GP_PIN(4, 18),
+};
+static const unsigned int hscif1_data_d_mux[] = {
+       HRX1_D_MARK, HTX1_D_MARK,
+};
+static const unsigned int hscif1_data_e_pins[] = {
+       /* RX, TX */
+       RCAR_GP_PIN(7, 14), RCAR_GP_PIN(7, 15),
+};
+static const unsigned int hscif1_data_e_mux[] = {
+       HRX1_C_MARK, HTX1_C_MARK,
+};
+static const unsigned int hscif1_clk_e_pins[] = {
+       /* SCK */
+       RCAR_GP_PIN(2, 6),
+};
+static const unsigned int hscif1_clk_e_mux[] = {
+       HSCK1_E_MARK,
+};
+static const unsigned int hscif1_ctrl_e_pins[] = {
+       /* RTS, CTS */
+       RCAR_GP_PIN(2, 8), RCAR_GP_PIN(2, 7),
+};
+static const unsigned int hscif1_ctrl_e_mux[] = {
+       HRTS1_N_E_MARK, HCTS1_N_E_MARK,
+};
+/* - HSCIF2 ----------------------------------------------------------------- */
+static const unsigned int hscif2_data_pins[] = {
+       /* RX, TX */
+       RCAR_GP_PIN(4, 16), RCAR_GP_PIN(4, 17),
+};
+static const unsigned int hscif2_data_mux[] = {
+       HRX2_MARK, HTX2_MARK,
+};
+static const unsigned int hscif2_clk_pins[] = {
+       /* SCK */
+       RCAR_GP_PIN(4, 15),
+};
+static const unsigned int hscif2_clk_mux[] = {
+       HSCK2_MARK,
+};
+static const unsigned int hscif2_ctrl_pins[] = {
+       /* RTS, CTS */
+       RCAR_GP_PIN(4, 14), RCAR_GP_PIN(4, 13),
+};
+static const unsigned int hscif2_ctrl_mux[] = {
+       HRTS2_N_MARK, HCTS2_N_MARK,
+};
+static const unsigned int hscif2_data_b_pins[] = {
+       /* RX, TX */
+       RCAR_GP_PIN(1, 20), RCAR_GP_PIN(1, 22),
+};
+static const unsigned int hscif2_data_b_mux[] = {
+       HRX2_B_MARK, HTX2_B_MARK,
+};
+static const unsigned int hscif2_ctrl_b_pins[] = {
+       /* RTS, CTS */
+       RCAR_GP_PIN(1, 23), RCAR_GP_PIN(1, 21),
+};
+static const unsigned int hscif2_ctrl_b_mux[] = {
+       HRTS2_N_B_MARK, HCTS2_N_B_MARK,
+};
+static const unsigned int hscif2_data_c_pins[] = {
+       /* RX, TX */
+       RCAR_GP_PIN(2, 0), RCAR_GP_PIN(2, 1),
+};
+static const unsigned int hscif2_data_c_mux[] = {
+       HRX2_C_MARK, HTX2_C_MARK,
+};
+static const unsigned int hscif2_clk_c_pins[] = {
+       /* SCK */
+       RCAR_GP_PIN(5, 31),
+};
+static const unsigned int hscif2_clk_c_mux[] = {
+       HSCK2_C_MARK,
+};
+static const unsigned int hscif2_data_d_pins[] = {
+       /* RX, TX */
+       RCAR_GP_PIN(1, 20), RCAR_GP_PIN(5, 31),
+};
+static const unsigned int hscif2_data_d_mux[] = {
+       HRX2_B_MARK, HTX2_D_MARK,
+};
 /* - I2C0 ------------------------------------------------------------------- */
 static const unsigned int i2c0_pins[] = {
        /* SCL, SDA */
@@ -1945,6 +2318,50 @@ static const unsigned int i2c4_c_pins[] = {
 static const unsigned int i2c4_c_mux[] = {
        SCL4_C_MARK, SDA4_C_MARK,
 };
+/* - I2C7 ------------------------------------------------------------------- */
+static const unsigned int i2c7_pins[] = {
+       /* SCL, SDA */
+       RCAR_GP_PIN(5, 15), RCAR_GP_PIN(5, 16),
+};
+static const unsigned int i2c7_mux[] = {
+       SCL7_MARK, SDA7_MARK,
+};
+static const unsigned int i2c7_b_pins[] = {
+       /* SCL, SDA */
+       RCAR_GP_PIN(2, 2), RCAR_GP_PIN(2, 3),
+};
+static const unsigned int i2c7_b_mux[] = {
+       SCL7_B_MARK, SDA7_B_MARK,
+};
+static const unsigned int i2c7_c_pins[] = {
+       /* SCL, SDA */
+       RCAR_GP_PIN(6, 28), RCAR_GP_PIN(6, 29),
+};
+static const unsigned int i2c7_c_mux[] = {
+       SCL7_C_MARK, SDA7_C_MARK,
+};
+/* - I2C8 ------------------------------------------------------------------- */
+static const unsigned int i2c8_pins[] = {
+       /* SCL, SDA */
+       RCAR_GP_PIN(4, 13), RCAR_GP_PIN(4, 14),
+};
+static const unsigned int i2c8_mux[] = {
+       SCL8_MARK, SDA8_MARK,
+};
+static const unsigned int i2c8_b_pins[] = {
+       /* SCL, SDA */
+       RCAR_GP_PIN(2, 4), RCAR_GP_PIN(2, 5),
+};
+static const unsigned int i2c8_b_mux[] = {
+       SCL8_B_MARK, SDA8_B_MARK,
+};
+static const unsigned int i2c8_c_pins[] = {
+       /* SCL, SDA */
+       RCAR_GP_PIN(6, 22), RCAR_GP_PIN(6, 23),
+};
+static const unsigned int i2c8_c_mux[] = {
+       SCL8_C_MARK, SDA8_C_MARK,
+};
 /* - INTC ------------------------------------------------------------------- */
 static const unsigned int intc_irq0_pins[] = {
        /* IRQ */
@@ -2051,48 +2468,271 @@ static const unsigned int msiof0_tx_pins[] = {
 static const unsigned int msiof0_tx_mux[] = {
        MSIOF0_TXD_MARK,
 };
+
+static const unsigned int msiof0_clk_b_pins[] = {
+       /* SCK */
+       RCAR_GP_PIN(0, 16),
+};
+static const unsigned int msiof0_clk_b_mux[] = {
+       MSIOF0_SCK_B_MARK,
+};
+static const unsigned int msiof0_sync_b_pins[] = {
+       /* SYNC */
+       RCAR_GP_PIN(0, 17),
+};
+static const unsigned int msiof0_sync_b_mux[] = {
+       MSIOF0_SYNC_B_MARK,
+};
+static const unsigned int msiof0_ss1_b_pins[] = {
+       /* SS1 */
+       RCAR_GP_PIN(0, 18),
+};
+static const unsigned int msiof0_ss1_b_mux[] = {
+       MSIOF0_SS1_B_MARK,
+};
+static const unsigned int msiof0_ss2_b_pins[] = {
+       /* SS2 */
+       RCAR_GP_PIN(0, 19),
+};
+static const unsigned int msiof0_ss2_b_mux[] = {
+       MSIOF0_SS2_B_MARK,
+};
+static const unsigned int msiof0_rx_b_pins[] = {
+       /* RXD */
+       RCAR_GP_PIN(0, 21),
+};
+static const unsigned int msiof0_rx_b_mux[] = {
+       MSIOF0_RXD_B_MARK,
+};
+static const unsigned int msiof0_tx_b_pins[] = {
+       /* TXD */
+       RCAR_GP_PIN(0, 20),
+};
+static const unsigned int msiof0_tx_b_mux[] = {
+       MSIOF0_TXD_B_MARK,
+};
+
+static const unsigned int msiof0_clk_c_pins[] = {
+       /* SCK */
+       RCAR_GP_PIN(5, 26),
+};
+static const unsigned int msiof0_clk_c_mux[] = {
+       MSIOF0_SCK_C_MARK,
+};
+static const unsigned int msiof0_sync_c_pins[] = {
+       /* SYNC */
+       RCAR_GP_PIN(5, 25),
+};
+static const unsigned int msiof0_sync_c_mux[] = {
+       MSIOF0_SYNC_C_MARK,
+};
+static const unsigned int msiof0_ss1_c_pins[] = {
+       /* SS1 */
+       RCAR_GP_PIN(5, 27),
+};
+static const unsigned int msiof0_ss1_c_mux[] = {
+       MSIOF0_SS1_C_MARK,
+};
+static const unsigned int msiof0_ss2_c_pins[] = {
+       /* SS2 */
+       RCAR_GP_PIN(5, 28),
+};
+static const unsigned int msiof0_ss2_c_mux[] = {
+       MSIOF0_SS2_C_MARK,
+};
+static const unsigned int msiof0_rx_c_pins[] = {
+       /* RXD */
+       RCAR_GP_PIN(5, 29),
+};
+static const unsigned int msiof0_rx_c_mux[] = {
+       MSIOF0_RXD_C_MARK,
+};
+static const unsigned int msiof0_tx_c_pins[] = {
+       /* TXD */
+       RCAR_GP_PIN(5, 30),
+};
+static const unsigned int msiof0_tx_c_mux[] = {
+       MSIOF0_TXD_C_MARK,
+};
 /* - MSIOF1 ----------------------------------------------------------------- */
 static const unsigned int msiof1_clk_pins[] = {
        /* SCK */
-       RCAR_GP_PIN(0, 22),
+       RCAR_GP_PIN(0, 22),
+};
+static const unsigned int msiof1_clk_mux[] = {
+       MSIOF1_SCK_MARK,
+};
+static const unsigned int msiof1_sync_pins[] = {
+       /* SYNC */
+       RCAR_GP_PIN(0, 23),
+};
+static const unsigned int msiof1_sync_mux[] = {
+       MSIOF1_SYNC_MARK,
+};
+static const unsigned int msiof1_ss1_pins[] = {
+       /* SS1 */
+       RCAR_GP_PIN(0, 24),
+};
+static const unsigned int msiof1_ss1_mux[] = {
+       MSIOF1_SS1_MARK,
+};
+static const unsigned int msiof1_ss2_pins[] = {
+       /* SS2 */
+       RCAR_GP_PIN(0, 25),
+};
+static const unsigned int msiof1_ss2_mux[] = {
+       MSIOF1_SS2_MARK,
+};
+static const unsigned int msiof1_rx_pins[] = {
+       /* RXD */
+       RCAR_GP_PIN(0, 27),
+};
+static const unsigned int msiof1_rx_mux[] = {
+       MSIOF1_RXD_MARK,
+};
+static const unsigned int msiof1_tx_pins[] = {
+       /* TXD */
+       RCAR_GP_PIN(0, 26),
+};
+static const unsigned int msiof1_tx_mux[] = {
+       MSIOF1_TXD_MARK,
+};
+
+static const unsigned int msiof1_clk_b_pins[] = {
+       /* SCK */
+       RCAR_GP_PIN(2, 29),
+};
+static const unsigned int msiof1_clk_b_mux[] = {
+       MSIOF1_SCK_B_MARK,
+};
+static const unsigned int msiof1_sync_b_pins[] = {
+       /* SYNC */
+       RCAR_GP_PIN(2, 30),
+};
+static const unsigned int msiof1_sync_b_mux[] = {
+       MSIOF1_SYNC_B_MARK,
+};
+static const unsigned int msiof1_ss1_b_pins[] = {
+       /* SS1 */
+       RCAR_GP_PIN(2, 31),
+};
+static const unsigned int msiof1_ss1_b_mux[] = {
+       MSIOF1_SS1_B_MARK,
+};
+static const unsigned int msiof1_ss2_b_pins[] = {
+       /* SS2 */
+       RCAR_GP_PIN(7, 16),
+};
+static const unsigned int msiof1_ss2_b_mux[] = {
+       MSIOF1_SS2_B_MARK,
+};
+static const unsigned int msiof1_rx_b_pins[] = {
+       /* RXD */
+       RCAR_GP_PIN(7, 18),
+};
+static const unsigned int msiof1_rx_b_mux[] = {
+       MSIOF1_RXD_B_MARK,
+};
+static const unsigned int msiof1_tx_b_pins[] = {
+       /* TXD */
+       RCAR_GP_PIN(7, 17),
+};
+static const unsigned int msiof1_tx_b_mux[] = {
+       MSIOF1_TXD_B_MARK,
+};
+
+static const unsigned int msiof1_clk_c_pins[] = {
+       /* SCK */
+       RCAR_GP_PIN(2, 15),
+};
+static const unsigned int msiof1_clk_c_mux[] = {
+       MSIOF1_SCK_C_MARK,
+};
+static const unsigned int msiof1_sync_c_pins[] = {
+       /* SYNC */
+       RCAR_GP_PIN(2, 16),
+};
+static const unsigned int msiof1_sync_c_mux[] = {
+       MSIOF1_SYNC_C_MARK,
+};
+static const unsigned int msiof1_rx_c_pins[] = {
+       /* RXD */
+       RCAR_GP_PIN(2, 18),
+};
+static const unsigned int msiof1_rx_c_mux[] = {
+       MSIOF1_RXD_C_MARK,
+};
+static const unsigned int msiof1_tx_c_pins[] = {
+       /* TXD */
+       RCAR_GP_PIN(2, 17),
+};
+static const unsigned int msiof1_tx_c_mux[] = {
+       MSIOF1_TXD_C_MARK,
+};
+
+static const unsigned int msiof1_clk_d_pins[] = {
+       /* SCK */
+       RCAR_GP_PIN(0, 28),
 };
-static const unsigned int msiof1_clk_mux[] = {
-       MSIOF1_SCK_MARK,
+static const unsigned int msiof1_clk_d_mux[] = {
+       MSIOF1_SCK_D_MARK,
 };
-static const unsigned int msiof1_sync_pins[] = {
+static const unsigned int msiof1_sync_d_pins[] = {
        /* SYNC */
-       RCAR_GP_PIN(0, 23),
+       RCAR_GP_PIN(0, 30),
 };
-static const unsigned int msiof1_sync_mux[] = {
-       MSIOF1_SYNC_MARK,
+static const unsigned int msiof1_sync_d_mux[] = {
+       MSIOF1_SYNC_D_MARK,
 };
-static const unsigned int msiof1_ss1_pins[] = {
+static const unsigned int msiof1_ss1_d_pins[] = {
        /* SS1 */
-       RCAR_GP_PIN(0, 24),
-};
-static const unsigned int msiof1_ss1_mux[] = {
-       MSIOF1_SS1_MARK,
-};
-static const unsigned int msiof1_ss2_pins[] = {
-       /* SS2 */
-       RCAR_GP_PIN(0, 25),
+       RCAR_GP_PIN(0, 29),
 };
-static const unsigned int msiof1_ss2_mux[] = {
-       MSIOF1_SS2_MARK,
+static const unsigned int msiof1_ss1_d_mux[] = {
+       MSIOF1_SS1_D_MARK,
 };
-static const unsigned int msiof1_rx_pins[] = {
+static const unsigned int msiof1_rx_d_pins[] = {
        /* RXD */
        RCAR_GP_PIN(0, 27),
 };
-static const unsigned int msiof1_rx_mux[] = {
-       MSIOF1_RXD_MARK,
+static const unsigned int msiof1_rx_d_mux[] = {
+       MSIOF1_RXD_D_MARK,
 };
-static const unsigned int msiof1_tx_pins[] = {
+static const unsigned int msiof1_tx_d_pins[] = {
        /* TXD */
        RCAR_GP_PIN(0, 26),
 };
-static const unsigned int msiof1_tx_mux[] = {
-       MSIOF1_TXD_MARK,
+static const unsigned int msiof1_tx_d_mux[] = {
+       MSIOF1_TXD_D_MARK,
+};
+
+static const unsigned int msiof1_clk_e_pins[] = {
+       /* SCK */
+       RCAR_GP_PIN(5, 18),
+};
+static const unsigned int msiof1_clk_e_mux[] = {
+       MSIOF1_SCK_E_MARK,
+};
+static const unsigned int msiof1_sync_e_pins[] = {
+       /* SYNC */
+       RCAR_GP_PIN(5, 19),
+};
+static const unsigned int msiof1_sync_e_mux[] = {
+       MSIOF1_SYNC_E_MARK,
+};
+static const unsigned int msiof1_rx_e_pins[] = {
+       /* RXD */
+       RCAR_GP_PIN(5, 17),
+};
+static const unsigned int msiof1_rx_e_mux[] = {
+       MSIOF1_RXD_E_MARK,
+};
+static const unsigned int msiof1_tx_e_pins[] = {
+       /* TXD */
+       RCAR_GP_PIN(5, 20),
+};
+static const unsigned int msiof1_tx_e_mux[] = {
+       MSIOF1_TXD_E_MARK,
 };
 /* - MSIOF2 ----------------------------------------------------------------- */
 static const unsigned int msiof2_clk_pins[] = {
@@ -2137,6 +2777,197 @@ static const unsigned int msiof2_tx_pins[] = {
 static const unsigned int msiof2_tx_mux[] = {
        MSIOF2_TXD_MARK,
 };
+
+static const unsigned int msiof2_clk_b_pins[] = {
+       /* SCK */
+       RCAR_GP_PIN(3, 0),
+};
+static const unsigned int msiof2_clk_b_mux[] = {
+       MSIOF2_SCK_B_MARK,
+};
+static const unsigned int msiof2_sync_b_pins[] = {
+       /* SYNC */
+       RCAR_GP_PIN(3, 1),
+};
+static const unsigned int msiof2_sync_b_mux[] = {
+       MSIOF2_SYNC_B_MARK,
+};
+static const unsigned int msiof2_ss1_b_pins[] = {
+       /* SS1 */
+       RCAR_GP_PIN(3, 8),
+};
+static const unsigned int msiof2_ss1_b_mux[] = {
+       MSIOF2_SS1_B_MARK,
+};
+static const unsigned int msiof2_ss2_b_pins[] = {
+       /* SS2 */
+       RCAR_GP_PIN(3, 9),
+};
+static const unsigned int msiof2_ss2_b_mux[] = {
+       MSIOF2_SS2_B_MARK,
+};
+static const unsigned int msiof2_rx_b_pins[] = {
+       /* RXD */
+       RCAR_GP_PIN(3, 17),
+};
+static const unsigned int msiof2_rx_b_mux[] = {
+       MSIOF2_RXD_B_MARK,
+};
+static const unsigned int msiof2_tx_b_pins[] = {
+       /* TXD */
+       RCAR_GP_PIN(3, 16),
+};
+static const unsigned int msiof2_tx_b_mux[] = {
+       MSIOF2_TXD_B_MARK,
+};
+
+static const unsigned int msiof2_clk_c_pins[] = {
+       /* SCK */
+       RCAR_GP_PIN(2, 2),
+};
+static const unsigned int msiof2_clk_c_mux[] = {
+       MSIOF2_SCK_C_MARK,
+};
+static const unsigned int msiof2_sync_c_pins[] = {
+       /* SYNC */
+       RCAR_GP_PIN(2, 3),
+};
+static const unsigned int msiof2_sync_c_mux[] = {
+       MSIOF2_SYNC_C_MARK,
+};
+static const unsigned int msiof2_rx_c_pins[] = {
+       /* RXD */
+       RCAR_GP_PIN(2, 5),
+};
+static const unsigned int msiof2_rx_c_mux[] = {
+       MSIOF2_RXD_C_MARK,
+};
+static const unsigned int msiof2_tx_c_pins[] = {
+       /* TXD */
+       RCAR_GP_PIN(2, 4),
+};
+static const unsigned int msiof2_tx_c_mux[] = {
+       MSIOF2_TXD_C_MARK,
+};
+
+static const unsigned int msiof2_clk_d_pins[] = {
+       /* SCK */
+       RCAR_GP_PIN(2, 14),
+};
+static const unsigned int msiof2_clk_d_mux[] = {
+       MSIOF2_SCK_D_MARK,
+};
+static const unsigned int msiof2_sync_d_pins[] = {
+       /* SYNC */
+       RCAR_GP_PIN(2, 15),
+};
+static const unsigned int msiof2_sync_d_mux[] = {
+       MSIOF2_SYNC_D_MARK,
+};
+static const unsigned int msiof2_ss1_d_pins[] = {
+       /* SS1 */
+       RCAR_GP_PIN(2, 17),
+};
+static const unsigned int msiof2_ss1_d_mux[] = {
+       MSIOF2_SS1_D_MARK,
+};
+static const unsigned int msiof2_ss2_d_pins[] = {
+       /* SS2 */
+       RCAR_GP_PIN(2, 19),
+};
+static const unsigned int msiof2_ss2_d_mux[] = {
+       MSIOF2_SS2_D_MARK,
+};
+static const unsigned int msiof2_rx_d_pins[] = {
+       /* RXD */
+       RCAR_GP_PIN(2, 18),
+};
+static const unsigned int msiof2_rx_d_mux[] = {
+       MSIOF2_RXD_D_MARK,
+};
+static const unsigned int msiof2_tx_d_pins[] = {
+       /* TXD */
+       RCAR_GP_PIN(2, 16),
+};
+static const unsigned int msiof2_tx_d_mux[] = {
+       MSIOF2_TXD_D_MARK,
+};
+
+static const unsigned int msiof2_clk_e_pins[] = {
+       /* SCK */
+       RCAR_GP_PIN(7, 15),
+};
+static const unsigned int msiof2_clk_e_mux[] = {
+       MSIOF2_SCK_E_MARK,
+};
+static const unsigned int msiof2_sync_e_pins[] = {
+       /* SYNC */
+       RCAR_GP_PIN(7, 16),
+};
+static const unsigned int msiof2_sync_e_mux[] = {
+       MSIOF2_SYNC_E_MARK,
+};
+static const unsigned int msiof2_rx_e_pins[] = {
+       /* RXD */
+       RCAR_GP_PIN(7, 14),
+};
+static const unsigned int msiof2_rx_e_mux[] = {
+       MSIOF2_RXD_E_MARK,
+};
+static const unsigned int msiof2_tx_e_pins[] = {
+       /* TXD */
+       RCAR_GP_PIN(7, 13),
+};
+static const unsigned int msiof2_tx_e_mux[] = {
+       MSIOF2_TXD_E_MARK,
+};
+/* - QSPI ------------------------------------------------------------------- */
+static const unsigned int qspi_ctrl_pins[] = {
+       /* SPCLK, SSL */
+       RCAR_GP_PIN(1, 4), RCAR_GP_PIN(1, 9),
+};
+static const unsigned int qspi_ctrl_mux[] = {
+       SPCLK_MARK, SSL_MARK,
+};
+static const unsigned int qspi_data2_pins[] = {
+       /* MOSI_IO0, MISO_IO1 */
+       RCAR_GP_PIN(1, 5), RCAR_GP_PIN(1, 6),
+};
+static const unsigned int qspi_data2_mux[] = {
+       MOSI_IO0_MARK, MISO_IO1_MARK,
+};
+static const unsigned int qspi_data4_pins[] = {
+       /* MOSI_IO0, MISO_IO1, IO2, IO3 */
+       RCAR_GP_PIN(1, 5), RCAR_GP_PIN(1, 6), RCAR_GP_PIN(1, 7),
+       RCAR_GP_PIN(1, 8),
+};
+static const unsigned int qspi_data4_mux[] = {
+       MOSI_IO0_MARK, MISO_IO1_MARK, IO2_MARK, IO3_MARK,
+};
+
+static const unsigned int qspi_ctrl_b_pins[] = {
+       /* SPCLK, SSL */
+       RCAR_GP_PIN(6, 0), RCAR_GP_PIN(6, 5),
+};
+static const unsigned int qspi_ctrl_b_mux[] = {
+       SPCLK_B_MARK, SSL_B_MARK,
+};
+static const unsigned int qspi_data2_b_pins[] = {
+       /* MOSI_IO0, MISO_IO1 */
+       RCAR_GP_PIN(6, 1), RCAR_GP_PIN(6, 2),
+};
+static const unsigned int qspi_data2_b_mux[] = {
+       MOSI_IO0_B_MARK, MISO_IO1_B_MARK,
+};
+static const unsigned int qspi_data4_b_pins[] = {
+       /* MOSI_IO0, MISO_IO1, IO2, IO3 */
+       RCAR_GP_PIN(6, 1), RCAR_GP_PIN(6, 2), RCAR_GP_PIN(6, 3),
+       RCAR_GP_PIN(6, 4),
+};
+static const unsigned int qspi_data4_b_mux[] = {
+       SPCLK_B_MARK, MOSI_IO0_B_MARK, MISO_IO1_B_MARK,
+       IO2_B_MARK, IO3_B_MARK, SSL_B_MARK,
+};
 /* - SCIF0 ------------------------------------------------------------------ */
 static const unsigned int scif0_data_pins[] = {
        /* RX, TX */
@@ -2788,6 +3619,260 @@ static const unsigned int sdhi2_wp_pins[] = {
 static const unsigned int sdhi2_wp_mux[] = {
        SD2_WP_MARK,
 };
+
+/* - SSI -------------------------------------------------------------------- */
+static const unsigned int ssi0_data_pins[] = {
+       /* SDATA */
+       RCAR_GP_PIN(2, 2),
+};
+
+static const unsigned int ssi0_data_mux[] = {
+       SSI_SDATA0_MARK,
+};
+
+static const unsigned int ssi0_data_b_pins[] = {
+       /* SDATA */
+       RCAR_GP_PIN(3, 4),
+};
+
+static const unsigned int ssi0_data_b_mux[] = {
+       SSI_SDATA0_B_MARK,
+};
+
+static const unsigned int ssi0129_ctrl_pins[] = {
+       /* SCK, WS */
+       RCAR_GP_PIN(2, 0), RCAR_GP_PIN(2, 1),
+};
+
+static const unsigned int ssi0129_ctrl_mux[] = {
+       SSI_SCK0129_MARK, SSI_WS0129_MARK,
+};
+
+static const unsigned int ssi0129_ctrl_b_pins[] = {
+       /* SCK, WS */
+       RCAR_GP_PIN(3, 2), RCAR_GP_PIN(3, 3),
+};
+
+static const unsigned int ssi0129_ctrl_b_mux[] = {
+       SSI_SCK0129_B_MARK, SSI_WS0129_B_MARK,
+};
+
+static const unsigned int ssi1_data_pins[] = {
+       /* SDATA */
+       RCAR_GP_PIN(2, 5),
+};
+
+static const unsigned int ssi1_data_mux[] = {
+       SSI_SDATA1_MARK,
+};
+
+static const unsigned int ssi1_data_b_pins[] = {
+       /* SDATA */
+       RCAR_GP_PIN(3, 7),
+};
+
+static const unsigned int ssi1_data_b_mux[] = {
+       SSI_SDATA1_B_MARK,
+};
+
+static const unsigned int ssi1_ctrl_pins[] = {
+       /* SCK, WS */
+       RCAR_GP_PIN(2, 3), RCAR_GP_PIN(2, 4),
+};
+
+static const unsigned int ssi1_ctrl_mux[] = {
+       SSI_SCK1_MARK, SSI_WS1_MARK,
+};
+
+static const unsigned int ssi1_ctrl_b_pins[] = {
+       /* SCK, WS */
+       RCAR_GP_PIN(3, 5), RCAR_GP_PIN(3, 6),
+};
+
+static const unsigned int ssi1_ctrl_b_mux[] = {
+       SSI_SCK1_B_MARK, SSI_WS1_B_MARK,
+};
+
+static const unsigned int ssi2_data_pins[] = {
+       /* SDATA */
+       RCAR_GP_PIN(2, 8),
+};
+
+static const unsigned int ssi2_data_mux[] = {
+       SSI_SDATA2_MARK,
+};
+
+static const unsigned int ssi2_ctrl_pins[] = {
+       /* SCK, WS */
+       RCAR_GP_PIN(2, 6), RCAR_GP_PIN(2, 7),
+};
+
+static const unsigned int ssi2_ctrl_mux[] = {
+       SSI_SCK2_MARK, SSI_WS2_MARK,
+};
+
+static const unsigned int ssi3_data_pins[] = {
+       /* SDATA */
+       RCAR_GP_PIN(2, 11),
+};
+
+static const unsigned int ssi3_data_mux[] = {
+       SSI_SDATA3_MARK,
+};
+
+static const unsigned int ssi34_ctrl_pins[] = {
+       /* SCK, WS */
+       RCAR_GP_PIN(2, 9), RCAR_GP_PIN(2, 10),
+};
+
+static const unsigned int ssi34_ctrl_mux[] = {
+       SSI_SCK34_MARK, SSI_WS34_MARK,
+};
+
+static const unsigned int ssi4_data_pins[] = {
+       /* SDATA */
+       RCAR_GP_PIN(2, 14),
+};
+
+static const unsigned int ssi4_data_mux[] = {
+       SSI_SDATA4_MARK,
+};
+
+static const unsigned int ssi4_ctrl_pins[] = {
+       /* SCK, WS */
+       RCAR_GP_PIN(2, 12), RCAR_GP_PIN(2, 13),
+};
+
+static const unsigned int ssi4_ctrl_mux[] = {
+       SSI_SCK4_MARK, SSI_WS4_MARK,
+};
+
+static const unsigned int ssi5_data_pins[] = {
+       /* SDATA */
+       RCAR_GP_PIN(2, 17),
+};
+
+static const unsigned int ssi5_data_mux[] = {
+       SSI_SDATA5_MARK,
+};
+
+static const unsigned int ssi5_ctrl_pins[] = {
+       /* SCK, WS */
+       RCAR_GP_PIN(2, 15), RCAR_GP_PIN(2, 16),
+};
+
+static const unsigned int ssi5_ctrl_mux[] = {
+       SSI_SCK5_MARK, SSI_WS5_MARK,
+};
+
+static const unsigned int ssi6_data_pins[] = {
+       /* SDATA */
+       RCAR_GP_PIN(2, 20),
+};
+
+static const unsigned int ssi6_data_mux[] = {
+       SSI_SDATA6_MARK,
+};
+
+static const unsigned int ssi6_ctrl_pins[] = {
+       /* SCK, WS */
+       RCAR_GP_PIN(2, 18), RCAR_GP_PIN(2, 19),
+};
+
+static const unsigned int ssi6_ctrl_mux[] = {
+       SSI_SCK6_MARK, SSI_WS6_MARK,
+};
+
+static const unsigned int ssi7_data_pins[] = {
+       /* SDATA */
+       RCAR_GP_PIN(2, 23),
+};
+
+static const unsigned int ssi7_data_mux[] = {
+       SSI_SDATA7_MARK,
+};
+
+static const unsigned int ssi7_data_b_pins[] = {
+       /* SDATA */
+       RCAR_GP_PIN(3, 12),
+};
+
+static const unsigned int ssi7_data_b_mux[] = {
+       SSI_SDATA7_B_MARK,
+};
+
+static const unsigned int ssi78_ctrl_pins[] = {
+       /* SCK, WS */
+       RCAR_GP_PIN(2, 21), RCAR_GP_PIN(2, 22),
+};
+
+static const unsigned int ssi78_ctrl_mux[] = {
+       SSI_SCK78_MARK, SSI_WS78_MARK,
+};
+
+static const unsigned int ssi78_ctrl_b_pins[] = {
+       /* SCK, WS */
+       RCAR_GP_PIN(3, 10), RCAR_GP_PIN(3, 11),
+};
+
+static const unsigned int ssi78_ctrl_b_mux[] = {
+       SSI_SCK78_B_MARK, SSI_WS78_B_MARK,
+};
+
+static const unsigned int ssi8_data_pins[] = {
+       /* SDATA */
+       RCAR_GP_PIN(2, 24),
+};
+
+static const unsigned int ssi8_data_mux[] = {
+       SSI_SDATA8_MARK,
+};
+
+static const unsigned int ssi8_data_b_pins[] = {
+       /* SDATA */
+       RCAR_GP_PIN(3, 13),
+};
+
+static const unsigned int ssi8_data_b_mux[] = {
+       SSI_SDATA8_B_MARK,
+};
+
+static const unsigned int ssi9_data_pins[] = {
+       /* SDATA */
+       RCAR_GP_PIN(2, 27),
+};
+
+static const unsigned int ssi9_data_mux[] = {
+       SSI_SDATA9_MARK,
+};
+
+static const unsigned int ssi9_data_b_pins[] = {
+       /* SDATA */
+       RCAR_GP_PIN(3, 18),
+};
+
+static const unsigned int ssi9_data_b_mux[] = {
+       SSI_SDATA9_B_MARK,
+};
+
+static const unsigned int ssi9_ctrl_pins[] = {
+       /* SCK, WS */
+       RCAR_GP_PIN(2, 25), RCAR_GP_PIN(2, 26),
+};
+
+static const unsigned int ssi9_ctrl_mux[] = {
+       SSI_SCK9_MARK, SSI_WS9_MARK,
+};
+
+static const unsigned int ssi9_ctrl_b_pins[] = {
+       /* SCK, WS */
+       RCAR_GP_PIN(3, 14), RCAR_GP_PIN(3, 15),
+};
+
+static const unsigned int ssi9_ctrl_b_mux[] = {
+       SSI_SCK9_B_MARK, SSI_WS9_B_MARK,
+};
+
 /* - USB0 ------------------------------------------------------------------- */
 static const unsigned int usb0_pins[] = {
        RCAR_GP_PIN(7, 23), /* PWEN */
@@ -3092,12 +4177,33 @@ static const unsigned int vin2_clk_mux[] = {
 };
 
 static const struct sh_pfc_pin_group pinmux_groups[] = {
+       SH_PFC_PIN_GROUP(audio_clk_a),
+       SH_PFC_PIN_GROUP(audio_clk_b),
+       SH_PFC_PIN_GROUP(audio_clk_b_b),
+       SH_PFC_PIN_GROUP(audio_clk_c),
+       SH_PFC_PIN_GROUP(audio_clkout),
+       SH_PFC_PIN_GROUP(can0_data),
+       SH_PFC_PIN_GROUP(can0_data_b),
+       SH_PFC_PIN_GROUP(can0_data_c),
+       SH_PFC_PIN_GROUP(can0_data_d),
+       SH_PFC_PIN_GROUP(can0_data_e),
+       SH_PFC_PIN_GROUP(can0_data_f),
+       SH_PFC_PIN_GROUP(can1_data),
+       SH_PFC_PIN_GROUP(can1_data_b),
+       SH_PFC_PIN_GROUP(can1_data_c),
+       SH_PFC_PIN_GROUP(can1_data_d),
+       SH_PFC_PIN_GROUP(can_clk),
+       SH_PFC_PIN_GROUP(can_clk_b),
+       SH_PFC_PIN_GROUP(can_clk_c),
+       SH_PFC_PIN_GROUP(can_clk_d),
        SH_PFC_PIN_GROUP(du_rgb666),
        SH_PFC_PIN_GROUP(du_rgb888),
        SH_PFC_PIN_GROUP(du_clk_out_0),
        SH_PFC_PIN_GROUP(du_clk_out_1),
        SH_PFC_PIN_GROUP(du_sync),
-       SH_PFC_PIN_GROUP(du_cde_disp),
+       SH_PFC_PIN_GROUP(du_oddf),
+       SH_PFC_PIN_GROUP(du_cde),
+       SH_PFC_PIN_GROUP(du_disp),
        SH_PFC_PIN_GROUP(du0_clk_in),
        SH_PFC_PIN_GROUP(du1_clk_in),
        SH_PFC_PIN_GROUP(du1_clk_in_b),
@@ -3106,6 +4212,32 @@ static const struct sh_pfc_pin_group pinmux_groups[] = {
        SH_PFC_PIN_GROUP(eth_magic),
        SH_PFC_PIN_GROUP(eth_mdio),
        SH_PFC_PIN_GROUP(eth_rmii),
+       SH_PFC_PIN_GROUP(hscif0_data),
+       SH_PFC_PIN_GROUP(hscif0_clk),
+       SH_PFC_PIN_GROUP(hscif0_ctrl),
+       SH_PFC_PIN_GROUP(hscif0_data_b),
+       SH_PFC_PIN_GROUP(hscif0_ctrl_b),
+       SH_PFC_PIN_GROUP(hscif0_data_c),
+       SH_PFC_PIN_GROUP(hscif0_clk_c),
+       SH_PFC_PIN_GROUP(hscif1_data),
+       SH_PFC_PIN_GROUP(hscif1_clk),
+       SH_PFC_PIN_GROUP(hscif1_ctrl),
+       SH_PFC_PIN_GROUP(hscif1_data_b),
+       SH_PFC_PIN_GROUP(hscif1_data_c),
+       SH_PFC_PIN_GROUP(hscif1_clk_c),
+       SH_PFC_PIN_GROUP(hscif1_ctrl_c),
+       SH_PFC_PIN_GROUP(hscif1_data_d),
+       SH_PFC_PIN_GROUP(hscif1_data_e),
+       SH_PFC_PIN_GROUP(hscif1_clk_e),
+       SH_PFC_PIN_GROUP(hscif1_ctrl_e),
+       SH_PFC_PIN_GROUP(hscif2_data),
+       SH_PFC_PIN_GROUP(hscif2_clk),
+       SH_PFC_PIN_GROUP(hscif2_ctrl),
+       SH_PFC_PIN_GROUP(hscif2_data_b),
+       SH_PFC_PIN_GROUP(hscif2_ctrl_b),
+       SH_PFC_PIN_GROUP(hscif2_data_c),
+       SH_PFC_PIN_GROUP(hscif2_clk_c),
+       SH_PFC_PIN_GROUP(hscif2_data_d),
        SH_PFC_PIN_GROUP(i2c0),
        SH_PFC_PIN_GROUP(i2c0_b),
        SH_PFC_PIN_GROUP(i2c0_c),
@@ -3125,6 +4257,12 @@ static const struct sh_pfc_pin_group pinmux_groups[] = {
        SH_PFC_PIN_GROUP(i2c4),
        SH_PFC_PIN_GROUP(i2c4_b),
        SH_PFC_PIN_GROUP(i2c4_c),
+       SH_PFC_PIN_GROUP(i2c7),
+       SH_PFC_PIN_GROUP(i2c7_b),
+       SH_PFC_PIN_GROUP(i2c7_c),
+       SH_PFC_PIN_GROUP(i2c8),
+       SH_PFC_PIN_GROUP(i2c8_b),
+       SH_PFC_PIN_GROUP(i2c8_c),
        SH_PFC_PIN_GROUP(intc_irq0),
        SH_PFC_PIN_GROUP(intc_irq1),
        SH_PFC_PIN_GROUP(intc_irq2),
@@ -3139,18 +4277,75 @@ static const struct sh_pfc_pin_group pinmux_groups[] = {
        SH_PFC_PIN_GROUP(msiof0_ss2),
        SH_PFC_PIN_GROUP(msiof0_rx),
        SH_PFC_PIN_GROUP(msiof0_tx),
+       SH_PFC_PIN_GROUP(msiof0_clk_b),
+       SH_PFC_PIN_GROUP(msiof0_sync_b),
+       SH_PFC_PIN_GROUP(msiof0_ss1_b),
+       SH_PFC_PIN_GROUP(msiof0_ss2_b),
+       SH_PFC_PIN_GROUP(msiof0_rx_b),
+       SH_PFC_PIN_GROUP(msiof0_tx_b),
+       SH_PFC_PIN_GROUP(msiof0_clk_c),
+       SH_PFC_PIN_GROUP(msiof0_sync_c),
+       SH_PFC_PIN_GROUP(msiof0_ss1_c),
+       SH_PFC_PIN_GROUP(msiof0_ss2_c),
+       SH_PFC_PIN_GROUP(msiof0_rx_c),
+       SH_PFC_PIN_GROUP(msiof0_tx_c),
        SH_PFC_PIN_GROUP(msiof1_clk),
        SH_PFC_PIN_GROUP(msiof1_sync),
        SH_PFC_PIN_GROUP(msiof1_ss1),
        SH_PFC_PIN_GROUP(msiof1_ss2),
        SH_PFC_PIN_GROUP(msiof1_rx),
        SH_PFC_PIN_GROUP(msiof1_tx),
+       SH_PFC_PIN_GROUP(msiof1_clk_b),
+       SH_PFC_PIN_GROUP(msiof1_sync_b),
+       SH_PFC_PIN_GROUP(msiof1_ss1_b),
+       SH_PFC_PIN_GROUP(msiof1_ss2_b),
+       SH_PFC_PIN_GROUP(msiof1_rx_b),
+       SH_PFC_PIN_GROUP(msiof1_tx_b),
+       SH_PFC_PIN_GROUP(msiof1_clk_c),
+       SH_PFC_PIN_GROUP(msiof1_sync_c),
+       SH_PFC_PIN_GROUP(msiof1_rx_c),
+       SH_PFC_PIN_GROUP(msiof1_tx_c),
+       SH_PFC_PIN_GROUP(msiof1_clk_d),
+       SH_PFC_PIN_GROUP(msiof1_sync_d),
+       SH_PFC_PIN_GROUP(msiof1_ss1_d),
+       SH_PFC_PIN_GROUP(msiof1_rx_d),
+       SH_PFC_PIN_GROUP(msiof1_tx_d),
+       SH_PFC_PIN_GROUP(msiof1_clk_e),
+       SH_PFC_PIN_GROUP(msiof1_sync_e),
+       SH_PFC_PIN_GROUP(msiof1_rx_e),
+       SH_PFC_PIN_GROUP(msiof1_tx_e),
        SH_PFC_PIN_GROUP(msiof2_clk),
        SH_PFC_PIN_GROUP(msiof2_sync),
        SH_PFC_PIN_GROUP(msiof2_ss1),
        SH_PFC_PIN_GROUP(msiof2_ss2),
        SH_PFC_PIN_GROUP(msiof2_rx),
        SH_PFC_PIN_GROUP(msiof2_tx),
+       SH_PFC_PIN_GROUP(msiof2_clk_b),
+       SH_PFC_PIN_GROUP(msiof2_sync_b),
+       SH_PFC_PIN_GROUP(msiof2_ss1_b),
+       SH_PFC_PIN_GROUP(msiof2_ss2_b),
+       SH_PFC_PIN_GROUP(msiof2_rx_b),
+       SH_PFC_PIN_GROUP(msiof2_tx_b),
+       SH_PFC_PIN_GROUP(msiof2_clk_c),
+       SH_PFC_PIN_GROUP(msiof2_sync_c),
+       SH_PFC_PIN_GROUP(msiof2_rx_c),
+       SH_PFC_PIN_GROUP(msiof2_tx_c),
+       SH_PFC_PIN_GROUP(msiof2_clk_d),
+       SH_PFC_PIN_GROUP(msiof2_sync_d),
+       SH_PFC_PIN_GROUP(msiof2_ss1_d),
+       SH_PFC_PIN_GROUP(msiof2_ss2_d),
+       SH_PFC_PIN_GROUP(msiof2_rx_d),
+       SH_PFC_PIN_GROUP(msiof2_tx_d),
+       SH_PFC_PIN_GROUP(msiof2_clk_e),
+       SH_PFC_PIN_GROUP(msiof2_sync_e),
+       SH_PFC_PIN_GROUP(msiof2_rx_e),
+       SH_PFC_PIN_GROUP(msiof2_tx_e),
+       SH_PFC_PIN_GROUP(qspi_ctrl),
+       SH_PFC_PIN_GROUP(qspi_data2),
+       SH_PFC_PIN_GROUP(qspi_data4),
+       SH_PFC_PIN_GROUP(qspi_ctrl_b),
+       SH_PFC_PIN_GROUP(qspi_data2_b),
+       SH_PFC_PIN_GROUP(qspi_data4_b),
        SH_PFC_PIN_GROUP(scif0_data),
        SH_PFC_PIN_GROUP(scif0_data_b),
        SH_PFC_PIN_GROUP(scif0_data_c),
@@ -3241,6 +4436,34 @@ static const struct sh_pfc_pin_group pinmux_groups[] = {
        SH_PFC_PIN_GROUP(sdhi2_ctrl),
        SH_PFC_PIN_GROUP(sdhi2_cd),
        SH_PFC_PIN_GROUP(sdhi2_wp),
+       SH_PFC_PIN_GROUP(ssi0_data),
+       SH_PFC_PIN_GROUP(ssi0_data_b),
+       SH_PFC_PIN_GROUP(ssi0129_ctrl),
+       SH_PFC_PIN_GROUP(ssi0129_ctrl_b),
+       SH_PFC_PIN_GROUP(ssi1_data),
+       SH_PFC_PIN_GROUP(ssi1_data_b),
+       SH_PFC_PIN_GROUP(ssi1_ctrl),
+       SH_PFC_PIN_GROUP(ssi1_ctrl_b),
+       SH_PFC_PIN_GROUP(ssi2_data),
+       SH_PFC_PIN_GROUP(ssi2_ctrl),
+       SH_PFC_PIN_GROUP(ssi3_data),
+       SH_PFC_PIN_GROUP(ssi34_ctrl),
+       SH_PFC_PIN_GROUP(ssi4_data),
+       SH_PFC_PIN_GROUP(ssi4_ctrl),
+       SH_PFC_PIN_GROUP(ssi5_data),
+       SH_PFC_PIN_GROUP(ssi5_ctrl),
+       SH_PFC_PIN_GROUP(ssi6_data),
+       SH_PFC_PIN_GROUP(ssi6_ctrl),
+       SH_PFC_PIN_GROUP(ssi7_data),
+       SH_PFC_PIN_GROUP(ssi7_data_b),
+       SH_PFC_PIN_GROUP(ssi78_ctrl),
+       SH_PFC_PIN_GROUP(ssi78_ctrl_b),
+       SH_PFC_PIN_GROUP(ssi8_data),
+       SH_PFC_PIN_GROUP(ssi8_data_b),
+       SH_PFC_PIN_GROUP(ssi9_data),
+       SH_PFC_PIN_GROUP(ssi9_data_b),
+       SH_PFC_PIN_GROUP(ssi9_ctrl),
+       SH_PFC_PIN_GROUP(ssi9_ctrl_b),
        SH_PFC_PIN_GROUP(usb0),
        SH_PFC_PIN_GROUP(usb1),
        VIN_DATA_PIN_GROUP(vin0_data, 24),
@@ -3277,13 +4500,47 @@ static const struct sh_pfc_pin_group pinmux_groups[] = {
        SH_PFC_PIN_GROUP(vin2_clk),
 };
 
+static const char * const audio_clk_groups[] = {
+       "audio_clk_a",
+       "audio_clk_b",
+       "audio_clk_b_b",
+       "audio_clk_c",
+       "audio_clkout",
+};
+
+static const char * const can0_groups[] = {
+       "can0_data",
+       "can0_data_b",
+       "can0_data_c",
+       "can0_data_d",
+       "can0_data_e",
+       "can0_data_f",
+       "can_clk",
+       "can_clk_b",
+       "can_clk_c",
+       "can_clk_d",
+};
+
+static const char * const can1_groups[] = {
+       "can1_data",
+       "can1_data_b",
+       "can1_data_c",
+       "can1_data_d",
+       "can_clk",
+       "can_clk_b",
+       "can_clk_c",
+       "can_clk_d",
+};
+
 static const char * const du_groups[] = {
        "du_rgb666",
        "du_rgb888",
        "du_clk_out_0",
        "du_clk_out_1",
        "du_sync",
-       "du_cde_disp",
+       "du_oddf",
+       "du_cde",
+       "du_disp",
 };
 
 static const char * const du0_groups[] = {
@@ -3303,6 +4560,41 @@ static const char * const eth_groups[] = {
        "eth_rmii",
 };
 
+static const char * const hscif0_groups[] = {
+       "hscif0_data",
+       "hscif0_clk",
+       "hscif0_ctrl",
+       "hscif0_data_b",
+       "hscif0_ctrl_b",
+       "hscif0_data_c",
+       "hscif0_clk_c",
+};
+
+static const char * const hscif1_groups[] = {
+       "hscif1_data",
+       "hscif1_clk",
+       "hscif1_ctrl",
+       "hscif1_data_b",
+       "hscif1_data_c",
+       "hscif1_clk_c",
+       "hscif1_ctrl_c",
+       "hscif1_data_d",
+       "hscif1_data_e",
+       "hscif1_clk_e",
+       "hscif1_ctrl_e",
+};
+
+static const char * const hscif2_groups[] = {
+       "hscif2_data",
+       "hscif2_clk",
+       "hscif2_ctrl",
+       "hscif2_data_b",
+       "hscif2_ctrl_b",
+       "hscif2_data_c",
+       "hscif2_clk_c",
+       "hscif2_data_d",
+};
+
 static const char * const i2c0_groups[] = {
        "i2c0",
        "i2c0_b",
@@ -3337,6 +4629,18 @@ static const char * const i2c4_groups[] = {
        "i2c4_c",
 };
 
+static const char * const i2c7_groups[] = {
+       "i2c7",
+       "i2c7_b",
+       "i2c7_c",
+};
+
+static const char * const i2c8_groups[] = {
+       "i2c8",
+       "i2c8_b",
+       "i2c8_c",
+};
+
 static const char * const intc_groups[] = {
        "intc_irq0",
        "intc_irq1",
@@ -3358,6 +4662,18 @@ static const char * const msiof0_groups[] = {
        "msiof0_ss2",
        "msiof0_rx",
        "msiof0_tx",
+       "msiof0_clk_b",
+       "msiof0_sync_b",
+       "msiof0_ss1_b",
+       "msiof0_ss2_b",
+       "msiof0_rx_b",
+       "msiof0_tx_b",
+       "msiof0_clk_c",
+       "msiof0_sync_c",
+       "msiof0_ss1_c",
+       "msiof0_ss2_c",
+       "msiof0_rx_c",
+       "msiof0_tx_c",
 };
 
 static const char * const msiof1_groups[] = {
@@ -3367,6 +4683,25 @@ static const char * const msiof1_groups[] = {
        "msiof1_ss2",
        "msiof1_rx",
        "msiof1_tx",
+       "msiof1_clk_b",
+       "msiof1_sync_b",
+       "msiof1_ss1_b",
+       "msiof1_ss2_b",
+       "msiof1_rx_b",
+       "msiof1_tx_b",
+       "msiof1_clk_c",
+       "msiof1_sync_c",
+       "msiof1_rx_c",
+       "msiof1_tx_c",
+       "msiof1_clk_d",
+       "msiof1_sync_d",
+       "msiof1_ss1_d",
+       "msiof1_rx_d",
+       "msiof1_tx_d",
+       "msiof1_clk_e",
+       "msiof1_sync_e",
+       "msiof1_rx_e",
+       "msiof1_tx_e",
 };
 
 static const char * const msiof2_groups[] = {
@@ -3376,6 +4711,35 @@ static const char * const msiof2_groups[] = {
        "msiof2_ss2",
        "msiof2_rx",
        "msiof2_tx",
+       "msiof2_clk_b",
+       "msiof2_sync_b",
+       "msiof2_ss1_b",
+       "msiof2_ss2_b",
+       "msiof2_rx_b",
+       "msiof2_tx_b",
+       "msiof2_clk_c",
+       "msiof2_sync_c",
+       "msiof2_rx_c",
+       "msiof2_tx_c",
+       "msiof2_clk_d",
+       "msiof2_sync_d",
+       "msiof2_ss1_d",
+       "msiof2_ss2_d",
+       "msiof2_rx_d",
+       "msiof2_tx_d",
+       "msiof2_clk_e",
+       "msiof2_sync_e",
+       "msiof2_rx_e",
+       "msiof2_tx_e",
+};
+
+static const char * const qspi_groups[] = {
+       "qspi_ctrl",
+       "qspi_data2",
+       "qspi_data4",
+       "qspi_ctrl_b",
+       "qspi_data2_b",
+       "qspi_data4_b",
 };
 
 static const char * const scif0_groups[] = {
@@ -3510,6 +4874,37 @@ static const char * const sdhi2_groups[] = {
        "sdhi2_wp",
 };
 
+static const char * const ssi_groups[] = {
+       "ssi0_data",
+       "ssi0_data_b",
+       "ssi0129_ctrl",
+       "ssi0129_ctrl_b",
+       "ssi1_data",
+       "ssi1_data_b",
+       "ssi1_ctrl",
+       "ssi1_ctrl_b",
+       "ssi2_data",
+       "ssi2_ctrl",
+       "ssi3_data",
+       "ssi34_ctrl",
+       "ssi4_data",
+       "ssi4_ctrl",
+       "ssi5_data",
+       "ssi5_ctrl",
+       "ssi6_data",
+       "ssi6_ctrl",
+       "ssi7_data",
+       "ssi7_data_b",
+       "ssi78_ctrl",
+       "ssi78_ctrl_b",
+       "ssi8_data",
+       "ssi8_data_b",
+       "ssi9_data",
+       "ssi9_data_b",
+       "ssi9_ctrl",
+       "ssi9_ctrl_b",
+};
+
 static const char * const usb0_groups[] = {
        "usb0",
 };
@@ -3559,20 +4954,29 @@ static const char * const vin2_groups[] = {
 };
 
 static const struct sh_pfc_function pinmux_functions[] = {
+       SH_PFC_FUNCTION(audio_clk),
+       SH_PFC_FUNCTION(can0),
+       SH_PFC_FUNCTION(can1),
        SH_PFC_FUNCTION(du),
        SH_PFC_FUNCTION(du0),
        SH_PFC_FUNCTION(du1),
        SH_PFC_FUNCTION(eth),
+       SH_PFC_FUNCTION(hscif0),
+       SH_PFC_FUNCTION(hscif1),
+       SH_PFC_FUNCTION(hscif2),
        SH_PFC_FUNCTION(i2c0),
        SH_PFC_FUNCTION(i2c1),
        SH_PFC_FUNCTION(i2c2),
        SH_PFC_FUNCTION(i2c3),
        SH_PFC_FUNCTION(i2c4),
+       SH_PFC_FUNCTION(i2c7),
+       SH_PFC_FUNCTION(i2c8),
        SH_PFC_FUNCTION(intc),
        SH_PFC_FUNCTION(mmc),
        SH_PFC_FUNCTION(msiof0),
        SH_PFC_FUNCTION(msiof1),
        SH_PFC_FUNCTION(msiof2),
+       SH_PFC_FUNCTION(qspi),
        SH_PFC_FUNCTION(scif0),
        SH_PFC_FUNCTION(scif1),
        SH_PFC_FUNCTION(scif2),
@@ -3591,6 +4995,7 @@ static const struct sh_pfc_function pinmux_functions[] = {
        SH_PFC_FUNCTION(sdhi0),
        SH_PFC_FUNCTION(sdhi1),
        SH_PFC_FUNCTION(sdhi2),
+       SH_PFC_FUNCTION(ssi),
        SH_PFC_FUNCTION(usb0),
        SH_PFC_FUNCTION(usb1),
        SH_PFC_FUNCTION(vin0),
@@ -4692,7 +6097,7 @@ static const struct pinmux_cfg_reg pinmux_config_regs[] = {
                /* SEL_SCIF3 [2] */
                FN_SEL_SCIF3_0, FN_SEL_SCIF3_1, FN_SEL_SCIF3_2, FN_SEL_SCIF3_3,
                /* SEL_IEB [2] */
-               FN_SEL_IEB_0, FN_SEL_IEB_1, FN_SEL_IEB_2,
+               FN_SEL_IEB_0, FN_SEL_IEB_1, FN_SEL_IEB_2, 0,
                /* SEL_MMC [1] */
                FN_SEL_MMC_0, FN_SEL_MMC_1,
                /* SEL_SCIF5 [1] */
index d9158b3..8211f66 100644 (file)
@@ -2614,14 +2614,14 @@ static void sh7372_pinmux_set_bias(struct sh_pfc *pfc, unsigned int pin,
        iowrite8(value, addr);
 }
 
-static const struct sh_pfc_soc_operations sh7372_pinmux_ops = {
+static const struct sh_pfc_soc_operations sh7372_pfc_ops = {
        .get_bias = sh7372_pinmux_get_bias,
        .set_bias = sh7372_pinmux_set_bias,
 };
 
 const struct sh_pfc_soc_info sh7372_pinmux_info = {
        .name = "sh7372_pfc",
-       .ops = &sh7372_pinmux_ops,
+       .ops = &sh7372_pfc_ops,
 
        .input = { PINMUX_INPUT_BEGIN, PINMUX_INPUT_END },
        .output = { PINMUX_OUTPUT_BEGIN, PINMUX_OUTPUT_END },
index 6f6ba10..d2efbfb 100644 (file)
@@ -26,7 +26,9 @@
 #include <linux/regulator/machine.h>
 #include <linux/slab.h>
 
+#ifndef CONFIG_ARCH_MULTIPLATFORM
 #include <mach/irqs.h>
+#endif
 
 #include "core.h"
 #include "sh_pfc.h"
@@ -3822,54 +3824,36 @@ static void sh73a0_pinmux_set_bias(struct sh_pfc *pfc, unsigned int pin,
  * SoC information
  */
 
-struct sh73a0_pinmux_data {
-       struct regulator_dev *vccq_mc0;
-};
-
 static int sh73a0_pinmux_soc_init(struct sh_pfc *pfc)
 {
-       struct sh73a0_pinmux_data *data;
        struct regulator_config cfg = { };
+       struct regulator_dev *vccq;
        int ret;
 
-       data = devm_kzalloc(pfc->dev, sizeof(*data), GFP_KERNEL);
-       if (data == NULL)
-               return -ENOMEM;
-
        cfg.dev = pfc->dev;
        cfg.init_data = &sh73a0_vccq_mc0_init_data;
        cfg.driver_data = pfc;
 
-       data->vccq_mc0 = regulator_register(&sh73a0_vccq_mc0_desc, &cfg);
-       if (IS_ERR(data->vccq_mc0)) {
-               ret = PTR_ERR(data->vccq_mc0);
+       vccq = devm_regulator_register(pfc->dev, &sh73a0_vccq_mc0_desc, &cfg);
+       if (IS_ERR(vccq)) {
+               ret = PTR_ERR(vccq);
                dev_err(pfc->dev, "Failed to register VCCQ MC0 regulator: %d\n",
                        ret);
                return ret;
        }
 
-       pfc->soc_data = data;
-
        return 0;
 }
 
-static void sh73a0_pinmux_soc_exit(struct sh_pfc *pfc)
-{
-       struct sh73a0_pinmux_data *data = pfc->soc_data;
-
-       regulator_unregister(data->vccq_mc0);
-}
-
-static const struct sh_pfc_soc_operations sh73a0_pinmux_ops = {
+static const struct sh_pfc_soc_operations sh73a0_pfc_ops = {
        .init = sh73a0_pinmux_soc_init,
-       .exit = sh73a0_pinmux_soc_exit,
        .get_bias = sh73a0_pinmux_get_bias,
        .set_bias = sh73a0_pinmux_set_bias,
 };
 
 const struct sh_pfc_soc_info sh73a0_pinmux_info = {
        .name = "sh73a0_pfc",
-       .ops = &sh73a0_pinmux_ops,
+       .ops = &sh73a0_pfc_ops,
 
        .input = { PINMUX_INPUT_BEGIN, PINMUX_INPUT_END },
        .output = { PINMUX_OUTPUT_BEGIN, PINMUX_OUTPUT_END },
index ab8fd25..5b72831 100644 (file)
@@ -98,8 +98,13 @@ struct pinmux_irq {
        const short *gpios;
 };
 
+#ifdef CONFIG_ARCH_MULTIPLATFORM
+#define PINMUX_IRQ(irq_nr, ids...)                        \
+       { .gpios = (const short []) { ids, -1 } }
+#else
 #define PINMUX_IRQ(irq_nr, ids...)                        \
        { .irq = irq_nr, .gpios = (const short []) { ids, -1 } }
+#endif
 
 struct pinmux_range {
        u16 begin;
@@ -111,7 +116,6 @@ struct sh_pfc;
 
 struct sh_pfc_soc_operations {
        int (*init)(struct sh_pfc *pfc);
-       void (*exit)(struct sh_pfc *pfc);
        unsigned int (*get_bias)(struct sh_pfc *pfc, unsigned int pin);
        void (*set_bias)(struct sh_pfc *pfc, unsigned int pin,
                         unsigned int bias);
index 22f2f28..77399f1 100644 (file)
@@ -119,6 +119,33 @@ config PWM_LPC32XX
          To compile this driver as a module, choose M here: the module
          will be called pwm-lpc32xx.
 
+config PWM_LPSS
+       tristate "Intel LPSS PWM support"
+       help
+         Generic PWM framework driver for Intel Low Power Subsystem PWM
+         controller.
+
+         To compile this driver as a module, choose M here: the module
+         will be called pwm-lpss.
+
+config PWM_LPSS_PCI
+       tristate "Intel LPSS PWM PCI driver"
+       depends on PWM_LPSS && PCI
+       help
+         The PCI driver for Intel Low Power Subsystem PWM controller.
+
+         To compile this driver as a module, choose M here: the module
+         will be called pwm-lpss-pci.
+
+config PWM_LPSS_PLATFORM
+       tristate "Intel LPSS PWM platform driver"
+       depends on PWM_LPSS && ACPI
+       help
+         The platform driver for Intel Low Power Subsystem PWM controller.
+
+         To compile this driver as a module, choose M here: the module
+         will be called pwm-lpss-platform.
+
 config PWM_MXS
        tristate "Freescale MXS PWM support"
        depends on ARCH_MXS && OF
index d8906ec..f1345f3 100644 (file)
@@ -9,6 +9,9 @@ obj-$(CONFIG_PWM_IMX)           += pwm-imx.o
 obj-$(CONFIG_PWM_JZ4740)       += pwm-jz4740.o
 obj-$(CONFIG_PWM_LP3943)       += pwm-lp3943.o
 obj-$(CONFIG_PWM_LPC32XX)      += pwm-lpc32xx.o
+obj-$(CONFIG_PWM_LPSS)         += pwm-lpss.o
+obj-$(CONFIG_PWM_LPSS_PCI)     += pwm-lpss-pci.o
+obj-$(CONFIG_PWM_LPSS_PLATFORM)        += pwm-lpss-platform.o
 obj-$(CONFIG_PWM_MXS)          += pwm-mxs.o
 obj-$(CONFIG_PWM_PCA9685)      += pwm-pca9685.o
 obj-$(CONFIG_PWM_PUV3)         += pwm-puv3.o
index a804713..4b66bf0 100644 (file)
@@ -661,10 +661,16 @@ struct pwm_device *pwm_get(struct device *dev, const char *con_id)
                }
        }
 
+       mutex_unlock(&pwm_lookup_lock);
+
        if (chip)
                pwm = pwm_request_from_chip(chip, index, con_id ?: dev_id);
+       if (IS_ERR(pwm))
+               return pwm;
+
+       pwm_set_period(pwm, p->period);
+       pwm_set_polarity(pwm, p->polarity);
 
-       mutex_unlock(&pwm_lookup_lock);
 
        return pwm;
 }
diff --git a/drivers/pwm/pwm-lpss-pci.c b/drivers/pwm/pwm-lpss-pci.c
new file mode 100644 (file)
index 0000000..1bfdd89
--- /dev/null
@@ -0,0 +1,65 @@
+/*
+ * Intel Low Power Subsystem PWM controller PCI driver
+ *
+ * Copyright (C) 2014, Intel Corporation
+ *
+ * Derived from the original pwm-lpss.c
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ */
+
+#include <linux/kernel.h>
+#include <linux/module.h>
+#include <linux/pci.h>
+
+#include "pwm-lpss.h"
+
+static int pwm_lpss_probe_pci(struct pci_dev *pdev,
+                             const struct pci_device_id *id)
+{
+       const struct pwm_lpss_boardinfo *info;
+       struct pwm_lpss_chip *lpwm;
+       int err;
+
+       err = pci_enable_device(pdev);
+       if (err < 0)
+               return err;
+
+       info = (struct pwm_lpss_boardinfo *)id->driver_data;
+       lpwm = pwm_lpss_probe(&pdev->dev, &pdev->resource[0], info);
+       if (IS_ERR(lpwm))
+               return PTR_ERR(lpwm);
+
+       pci_set_drvdata(pdev, lpwm);
+       return 0;
+}
+
+static void pwm_lpss_remove_pci(struct pci_dev *pdev)
+{
+       struct pwm_lpss_chip *lpwm = pci_get_drvdata(pdev);
+
+       pwm_lpss_remove(lpwm);
+       pci_disable_device(pdev);
+}
+
+static const struct pci_device_id pwm_lpss_pci_ids[] = {
+       { PCI_VDEVICE(INTEL, 0x0f08), (unsigned long)&pwm_lpss_byt_info},
+       { PCI_VDEVICE(INTEL, 0x0f09), (unsigned long)&pwm_lpss_byt_info},
+       { PCI_VDEVICE(INTEL, 0x2288), (unsigned long)&pwm_lpss_bsw_info},
+       { PCI_VDEVICE(INTEL, 0x2289), (unsigned long)&pwm_lpss_bsw_info},
+       { },
+};
+MODULE_DEVICE_TABLE(pci, pwm_lpss_pci_ids);
+
+static struct pci_driver pwm_lpss_driver_pci = {
+       .name = "pwm-lpss",
+       .id_table = pwm_lpss_pci_ids,
+       .probe = pwm_lpss_probe_pci,
+       .remove = pwm_lpss_remove_pci,
+};
+module_pci_driver(pwm_lpss_driver_pci);
+
+MODULE_DESCRIPTION("PWM PCI driver for Intel LPSS");
+MODULE_LICENSE("GPL v2");
diff --git a/drivers/pwm/pwm-lpss-platform.c b/drivers/pwm/pwm-lpss-platform.c
new file mode 100644 (file)
index 0000000..18a9c88
--- /dev/null
@@ -0,0 +1,68 @@
+/*
+ * Intel Low Power Subsystem PWM controller driver
+ *
+ * Copyright (C) 2014, Intel Corporation
+ *
+ * Derived from the original pwm-lpss.c
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ */
+
+#include <linux/acpi.h>
+#include <linux/kernel.h>
+#include <linux/module.h>
+#include <linux/platform_device.h>
+
+#include "pwm-lpss.h"
+
+static int pwm_lpss_probe_platform(struct platform_device *pdev)
+{
+       const struct pwm_lpss_boardinfo *info;
+       const struct acpi_device_id *id;
+       struct pwm_lpss_chip *lpwm;
+       struct resource *r;
+
+       id = acpi_match_device(pdev->dev.driver->acpi_match_table, &pdev->dev);
+       if (!id)
+               return -ENODEV;
+
+       info = (const struct pwm_lpss_boardinfo *)id->driver_data;
+       r = platform_get_resource(pdev, IORESOURCE_MEM, 0);
+
+       lpwm = pwm_lpss_probe(&pdev->dev, r, info);
+       if (IS_ERR(lpwm))
+               return PTR_ERR(lpwm);
+
+       platform_set_drvdata(pdev, lpwm);
+       return 0;
+}
+
+static int pwm_lpss_remove_platform(struct platform_device *pdev)
+{
+       struct pwm_lpss_chip *lpwm = platform_get_drvdata(pdev);
+
+       return pwm_lpss_remove(lpwm);
+}
+
+static const struct acpi_device_id pwm_lpss_acpi_match[] = {
+       { "80860F09", (unsigned long)&pwm_lpss_byt_info },
+       { "80862288", (unsigned long)&pwm_lpss_bsw_info },
+       { },
+};
+MODULE_DEVICE_TABLE(acpi, pwm_lpss_acpi_match);
+
+static struct platform_driver pwm_lpss_driver_platform = {
+       .driver = {
+               .name = "pwm-lpss",
+               .acpi_match_table = pwm_lpss_acpi_match,
+       },
+       .probe = pwm_lpss_probe_platform,
+       .remove = pwm_lpss_remove_platform,
+};
+module_platform_driver(pwm_lpss_driver_platform);
+
+MODULE_DESCRIPTION("PWM platform driver for Intel LPSS");
+MODULE_LICENSE("GPL v2");
+MODULE_ALIAS("platform:pwm-lpss");
diff --git a/drivers/pwm/pwm-lpss.c b/drivers/pwm/pwm-lpss.c
new file mode 100644 (file)
index 0000000..e979825
--- /dev/null
@@ -0,0 +1,163 @@
+/*
+ * Intel Low Power Subsystem PWM controller driver
+ *
+ * Copyright (C) 2014, Intel Corporation
+ * Author: Mika Westerberg <mika.westerberg@linux.intel.com>
+ * Author: Chew Kean Ho <kean.ho.chew@intel.com>
+ * Author: Chang Rebecca Swee Fun <rebecca.swee.fun.chang@intel.com>
+ * Author: Chew Chiau Ee <chiau.ee.chew@intel.com>
+ * Author: Alan Cox <alan@linux.intel.com>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ */
+
+#include <linux/io.h>
+#include <linux/kernel.h>
+#include <linux/module.h>
+
+#include "pwm-lpss.h"
+
+#define PWM                            0x00000000
+#define PWM_ENABLE                     BIT(31)
+#define PWM_SW_UPDATE                  BIT(30)
+#define PWM_BASE_UNIT_SHIFT            8
+#define PWM_BASE_UNIT_MASK             0x00ffff00
+#define PWM_ON_TIME_DIV_MASK           0x000000ff
+#define PWM_DIVISION_CORRECTION                0x2
+#define PWM_LIMIT                      (0x8000 + PWM_DIVISION_CORRECTION)
+#define NSECS_PER_SEC                  1000000000UL
+
+struct pwm_lpss_chip {
+       struct pwm_chip chip;
+       void __iomem *regs;
+       unsigned long clk_rate;
+};
+
+/* BayTrail */
+const struct pwm_lpss_boardinfo pwm_lpss_byt_info = {
+       .clk_rate = 25000000
+};
+EXPORT_SYMBOL_GPL(pwm_lpss_byt_info);
+
+/* Braswell */
+const struct pwm_lpss_boardinfo pwm_lpss_bsw_info = {
+       .clk_rate = 19200000
+};
+EXPORT_SYMBOL_GPL(pwm_lpss_bsw_info);
+
+static inline struct pwm_lpss_chip *to_lpwm(struct pwm_chip *chip)
+{
+       return container_of(chip, struct pwm_lpss_chip, chip);
+}
+
+static int pwm_lpss_config(struct pwm_chip *chip, struct pwm_device *pwm,
+                          int duty_ns, int period_ns)
+{
+       struct pwm_lpss_chip *lpwm = to_lpwm(chip);
+       u8 on_time_div;
+       unsigned long c;
+       unsigned long long base_unit, freq = NSECS_PER_SEC;
+       u32 ctrl;
+
+       do_div(freq, period_ns);
+
+       /* The equation is: base_unit = ((freq / c) * 65536) + correction */
+       base_unit = freq * 65536;
+
+       c = lpwm->clk_rate;
+       if (!c)
+               return -EINVAL;
+
+       do_div(base_unit, c);
+       base_unit += PWM_DIVISION_CORRECTION;
+       if (base_unit > PWM_LIMIT)
+               return -EINVAL;
+
+       if (duty_ns <= 0)
+               duty_ns = 1;
+       on_time_div = 255 - (255 * duty_ns / period_ns);
+
+       ctrl = readl(lpwm->regs + PWM);
+       ctrl &= ~(PWM_BASE_UNIT_MASK | PWM_ON_TIME_DIV_MASK);
+       ctrl |= (u16) base_unit << PWM_BASE_UNIT_SHIFT;
+       ctrl |= on_time_div;
+       /* request PWM to update on next cycle */
+       ctrl |= PWM_SW_UPDATE;
+       writel(ctrl, lpwm->regs + PWM);
+
+       return 0;
+}
+
+static int pwm_lpss_enable(struct pwm_chip *chip, struct pwm_device *pwm)
+{
+       struct pwm_lpss_chip *lpwm = to_lpwm(chip);
+       u32 ctrl;
+
+       ctrl = readl(lpwm->regs + PWM);
+       writel(ctrl | PWM_ENABLE, lpwm->regs + PWM);
+
+       return 0;
+}
+
+static void pwm_lpss_disable(struct pwm_chip *chip, struct pwm_device *pwm)
+{
+       struct pwm_lpss_chip *lpwm = to_lpwm(chip);
+       u32 ctrl;
+
+       ctrl = readl(lpwm->regs + PWM);
+       writel(ctrl & ~PWM_ENABLE, lpwm->regs + PWM);
+}
+
+static const struct pwm_ops pwm_lpss_ops = {
+       .config = pwm_lpss_config,
+       .enable = pwm_lpss_enable,
+       .disable = pwm_lpss_disable,
+       .owner = THIS_MODULE,
+};
+
+struct pwm_lpss_chip *pwm_lpss_probe(struct device *dev, struct resource *r,
+                                    const struct pwm_lpss_boardinfo *info)
+{
+       struct pwm_lpss_chip *lpwm;
+       int ret;
+
+       lpwm = devm_kzalloc(dev, sizeof(*lpwm), GFP_KERNEL);
+       if (!lpwm)
+               return ERR_PTR(-ENOMEM);
+
+       lpwm->regs = devm_ioremap_resource(dev, r);
+       if (IS_ERR(lpwm->regs))
+               return ERR_CAST(lpwm->regs);
+
+       lpwm->clk_rate = info->clk_rate;
+       lpwm->chip.dev = dev;
+       lpwm->chip.ops = &pwm_lpss_ops;
+       lpwm->chip.base = -1;
+       lpwm->chip.npwm = 1;
+
+       ret = pwmchip_add(&lpwm->chip);
+       if (ret) {
+               dev_err(dev, "failed to add PWM chip: %d\n", ret);
+               return ERR_PTR(ret);
+       }
+
+       return lpwm;
+}
+EXPORT_SYMBOL_GPL(pwm_lpss_probe);
+
+int pwm_lpss_remove(struct pwm_lpss_chip *lpwm)
+{
+       u32 ctrl;
+
+       ctrl = readl(lpwm->regs + PWM);
+       writel(ctrl & ~PWM_ENABLE, lpwm->regs + PWM);
+
+       return pwmchip_remove(&lpwm->chip);
+}
+EXPORT_SYMBOL_GPL(pwm_lpss_remove);
+
+MODULE_DESCRIPTION("PWM driver for Intel LPSS");
+MODULE_AUTHOR("Mika Westerberg <mika.westerberg@linux.intel.com>");
+MODULE_LICENSE("GPL v2");
diff --git a/drivers/pwm/pwm-lpss.h b/drivers/pwm/pwm-lpss.h
new file mode 100644 (file)
index 0000000..aa041bb
--- /dev/null
@@ -0,0 +1,32 @@
+/*
+ * Intel Low Power Subsystem PWM controller driver
+ *
+ * Copyright (C) 2014, Intel Corporation
+ *
+ * Derived from the original pwm-lpss.c
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ */
+
+#ifndef __PWM_LPSS_H
+#define __PWM_LPSS_H
+
+#include <linux/device.h>
+#include <linux/pwm.h>
+
+struct pwm_lpss_chip;
+
+struct pwm_lpss_boardinfo {
+       unsigned long clk_rate;
+};
+
+extern const struct pwm_lpss_boardinfo pwm_lpss_byt_info;
+extern const struct pwm_lpss_boardinfo pwm_lpss_bsw_info;
+
+struct pwm_lpss_chip *pwm_lpss_probe(struct device *dev, struct resource *r,
+                                    const struct pwm_lpss_boardinfo *info);
+int pwm_lpss_remove(struct pwm_lpss_chip *lpwm);
+
+#endif /* __PWM_LPSS_H */
index afca1bc..bac485a 100644 (file)
@@ -2399,6 +2399,7 @@ int regulator_set_voltage(struct regulator *regulator, int min_uV, int max_uV)
        struct regulator_dev *rdev = regulator->rdev;
        int ret = 0;
        int old_min_uV, old_max_uV;
+       int current_uV;
 
        mutex_lock(&rdev->mutex);
 
@@ -2409,6 +2410,19 @@ int regulator_set_voltage(struct regulator *regulator, int min_uV, int max_uV)
        if (regulator->min_uV == min_uV && regulator->max_uV == max_uV)
                goto out;
 
+       /* If we're trying to set a range that overlaps the current voltage,
+        * return succesfully even though the regulator does not support
+        * changing the voltage.
+        */
+       if (!(rdev->constraints->valid_ops_mask & REGULATOR_CHANGE_VOLTAGE)) {
+               current_uV = _regulator_get_voltage(rdev);
+               if (min_uV <= current_uV && current_uV <= max_uV) {
+                       regulator->min_uV = min_uV;
+                       regulator->max_uV = max_uV;
+                       goto out;
+               }
+       }
+
        /* sanity check */
        if (!rdev->desc->ops->set_voltage &&
            !rdev->desc->ops->set_voltage_sel) {
index 6f5ecbe..7a320dd 100644 (file)
@@ -134,11 +134,8 @@ static int da9210_i2c_probe(struct i2c_client *i2c,
        int error;
 
        chip = devm_kzalloc(&i2c->dev, sizeof(struct da9210), GFP_KERNEL);
-       if (NULL == chip) {
-               dev_err(&i2c->dev,
-                       "Cannot kzalloc memory for regulator structure\n");
+       if (!chip)
                return -ENOMEM;
-       }
 
        chip->regmap = devm_regmap_init_i2c(i2c, &da9210_regmap_config);
        if (IS_ERR(chip->regmap)) {
index c0a1d00..989b23b 100644 (file)
@@ -136,7 +136,6 @@ static struct gpio_regulator_config *
 of_get_gpio_regulator_config(struct device *dev, struct device_node *np)
 {
        struct gpio_regulator_config *config;
-       struct property *prop;
        const char *regtype;
        int proplen, gpio, i;
        int ret;
@@ -172,22 +171,35 @@ of_get_gpio_regulator_config(struct device *dev, struct device_node *np)
        if (!config->gpios)
                return ERR_PTR(-ENOMEM);
 
+       proplen = of_property_count_u32_elems(np, "gpios-states");
+       /* optional property */
+       if (proplen < 0)
+               proplen = 0;
+
+       if (proplen > 0 && proplen != config->nr_gpios) {
+               dev_warn(dev, "gpios <-> gpios-states mismatch\n");
+               proplen = 0;
+       }
+
        for (i = 0; i < config->nr_gpios; i++) {
                gpio = of_get_named_gpio(np, "gpios", i);
                if (gpio < 0)
                        break;
                config->gpios[i].gpio = gpio;
+               if (proplen > 0) {
+                       of_property_read_u32_index(np, "gpios-states", i, &ret);
+                       if (ret)
+                               config->gpios[i].flags = GPIOF_OUT_INIT_HIGH;
+               }
        }
 
        /* Fetch states. */
-       prop = of_find_property(np, "states", NULL);
-       if (!prop) {
+       proplen = of_property_count_u32_elems(np, "states");
+       if (proplen < 0) {
                dev_err(dev, "No 'states' property found\n");
                return ERR_PTR(-EINVAL);
        }
 
-       proplen = prop->length / sizeof(int);
-
        config->states = devm_kzalloc(dev,
                                sizeof(struct gpio_regulator_state)
                                * (proplen / 2),
@@ -196,10 +208,10 @@ of_get_gpio_regulator_config(struct device *dev, struct device_node *np)
                return ERR_PTR(-ENOMEM);
 
        for (i = 0; i < proplen / 2; i++) {
-               config->states[i].value =
-                       be32_to_cpup((int *)prop->value + (i * 2));
-               config->states[i].gpios =
-                       be32_to_cpup((int *)prop->value + (i * 2 + 1));
+               of_property_read_u32_index(np, "states", i * 2,
+                                          &config->states[i].value);
+               of_property_read_u32_index(np, "states", i * 2 + 1,
+                                          &config->states[i].gpios);
        }
        config->nr_states = i;
 
@@ -239,10 +251,8 @@ static int gpio_regulator_probe(struct platform_device *pdev)
 
        drvdata = devm_kzalloc(&pdev->dev, sizeof(struct gpio_regulator_data),
                               GFP_KERNEL);
-       if (drvdata == NULL) {
-               dev_err(&pdev->dev, "Failed to allocate device data\n");
+       if (drvdata == NULL)
                return -ENOMEM;
-       }
 
        drvdata->desc.name = kstrdup(config->supply_name, GFP_KERNEL);
        if (drvdata->desc.name == NULL) {
index fc67f56..114203f 100644 (file)
@@ -1,10 +1,11 @@
 #
 # Makefile for the SuperH specific drivers.
 #
-obj-y  := intc/
+obj-$(CONFIG_SH_INTC)                  += intc/
+ifneq ($(CONFIG_COMMON_CLK),y)
+obj-$(CONFIG_HAVE_CLK)                 += clk/
+endif
+obj-$(CONFIG_MAPLE)                    += maple/
+obj-$(CONFIG_SUPERHYWAY)               += superhyway/
 
-obj-$(CONFIG_HAVE_CLK)         += clk/
-obj-$(CONFIG_MAPLE)            += maple/
-obj-$(CONFIG_SUPERHYWAY)       += superhyway/
-
-obj-y                          += pm_runtime.o
+obj-y                                  += pm_runtime.o
index 7472785..be56b22 100644 (file)
@@ -196,17 +196,11 @@ int clk_rate_table_find(struct clk *clk,
                        struct cpufreq_frequency_table *freq_table,
                        unsigned long rate)
 {
-       int i;
-
-       for (i = 0; freq_table[i].frequency != CPUFREQ_TABLE_END; i++) {
-               unsigned long freq = freq_table[i].frequency;
+       struct cpufreq_frequency_table *pos;
 
-               if (freq == CPUFREQ_ENTRY_INVALID)
-                       continue;
-
-               if (freq == rate)
-                       return i;
-       }
+       cpufreq_for_each_valid_entry(pos, freq_table)
+               if (pos->frequency == rate)
+                       return pos - freq_table;
 
        return -ENOENT;
 }
@@ -575,11 +569,7 @@ long clk_round_parent(struct clk *clk, unsigned long target,
                return abs(target - *best_freq);
        }
 
-       for (freq = parent->freq_table; freq->frequency != CPUFREQ_TABLE_END;
-            freq++) {
-               if (freq->frequency == CPUFREQ_ENTRY_INVALID)
-                       continue;
-
+       cpufreq_for_each_valid_entry(freq, parent->freq_table) {
                if (unlikely(freq->frequency / target <= div_min - 1)) {
                        unsigned long freq_max;
 
index 1ebe67c..7442bc1 100644 (file)
@@ -36,9 +36,47 @@ static void sh_clk_write(int value, struct clk *clk)
                iowrite32(value, clk->mapped_reg);
 }
 
+static unsigned int r8(const void __iomem *addr)
+{
+       return ioread8(addr);
+}
+
+static unsigned int r16(const void __iomem *addr)
+{
+       return ioread16(addr);
+}
+
+static unsigned int r32(const void __iomem *addr)
+{
+       return ioread32(addr);
+}
+
 static int sh_clk_mstp_enable(struct clk *clk)
 {
        sh_clk_write(sh_clk_read(clk) & ~(1 << clk->enable_bit), clk);
+       if (clk->status_reg) {
+               unsigned int (*read)(const void __iomem *addr);
+               int i;
+               void __iomem *mapped_status = (phys_addr_t)clk->status_reg -
+                       (phys_addr_t)clk->enable_reg + clk->mapped_reg;
+
+               if (clk->flags & CLK_ENABLE_REG_8BIT)
+                       read = r8;
+               else if (clk->flags & CLK_ENABLE_REG_16BIT)
+                       read = r16;
+               else
+                       read = r32;
+
+               for (i = 1000;
+                    (read(mapped_status) & (1 << clk->enable_bit)) && i;
+                    i--)
+                       cpu_relax();
+               if (!i) {
+                       pr_err("cpg: failed to enable %p[%d]\n",
+                              clk->enable_reg, clk->enable_bit);
+                       return -ETIMEDOUT;
+               }
+       }
        return 0;
 }
 
index a305731..6a1b05d 100644 (file)
@@ -1,12 +1,14 @@
 config SH_INTC
-       def_bool y
+       bool
        select IRQ_DOMAIN
 
+if SH_INTC
+
 comment "Interrupt controller options"
 
 config INTC_USERIMASK
        bool "Userspace interrupt masking support"
-       depends on ARCH_SHMOBILE || (SUPERH && CPU_SH4A)
+       depends on (SUPERH && CPU_SH4A) || COMPILE_TEST
        help
          This enables support for hardware-assisted userspace hardirq
          masking.
@@ -37,3 +39,5 @@ config INTC_MAPPING_DEBUG
          between system IRQs and the per-controller id tables.
 
          If in doubt, say N.
+
+endif
index 8f32a13..81f2298 100644 (file)
@@ -80,12 +80,6 @@ static void __init intc_register_irq(struct intc_desc *desc,
        unsigned int data[2], primary;
        unsigned long flags;
 
-       /*
-        * Register the IRQ position with the global IRQ map, then insert
-        * it in to the radix tree.
-        */
-       irq_reserve_irq(irq);
-
        raw_spin_lock_irqsave(&intc_big_lock, flags);
        radix_tree_insert(&d->tree, enum_id, intc_irq_xlate_get(irq));
        raw_spin_unlock_irqrestore(&intc_big_lock, flags);
index 8afa5a4..fe2c2d5 100644 (file)
 #include <linux/slab.h>
 
 #ifdef CONFIG_PM_RUNTIME
-
-static int default_platform_runtime_idle(struct device *dev)
+static int sh_pm_runtime_suspend(struct device *dev)
 {
-       /* suspend synchronously to disable clocks immediately */
+       int ret;
+
+       ret = pm_generic_runtime_suspend(dev);
+       if (ret) {
+               dev_err(dev, "failed to suspend device\n");
+               return ret;
+       }
+
+       ret = pm_clk_suspend(dev);
+       if (ret) {
+               dev_err(dev, "failed to suspend clock\n");
+               pm_generic_runtime_resume(dev);
+               return ret;
+       }
+
        return 0;
 }
 
+static int sh_pm_runtime_resume(struct device *dev)
+{
+       int ret;
+
+       ret = pm_clk_resume(dev);
+       if (ret) {
+               dev_err(dev, "failed to resume clock\n");
+               return ret;
+       }
+
+       return pm_generic_runtime_resume(dev);
+}
+
 static struct dev_pm_domain default_pm_domain = {
        .ops = {
-               .runtime_suspend = pm_clk_suspend,
-               .runtime_resume = pm_clk_resume,
-               .runtime_idle = default_platform_runtime_idle,
+               .runtime_suspend = sh_pm_runtime_suspend,
+               .runtime_resume = sh_pm_runtime_resume,
                USE_PLATFORM_PM_SLEEP_OPS
        },
 };
@@ -52,14 +77,24 @@ static struct pm_clk_notifier_block platform_bus_notifier = {
 
 static int __init sh_pm_runtime_init(void)
 {
+       if (IS_ENABLED(CONFIG_ARCH_SHMOBILE_MULTI)) {
+               if (!of_machine_is_compatible("renesas,emev2") &&
+                   !of_machine_is_compatible("renesas,r7s72100") &&
+                   !of_machine_is_compatible("renesas,r8a73a4") &&
+                   !of_machine_is_compatible("renesas,r8a7740") &&
+                   !of_machine_is_compatible("renesas,r8a7778") &&
+                   !of_machine_is_compatible("renesas,r8a7779") &&
+                   !of_machine_is_compatible("renesas,r8a7790") &&
+                   !of_machine_is_compatible("renesas,r8a7791") &&
+                   !of_machine_is_compatible("renesas,r8a7792") &&
+                   !of_machine_is_compatible("renesas,r8a7793") &&
+                   !of_machine_is_compatible("renesas,r8a7794") &&
+                   !of_machine_is_compatible("renesas,sh7372") &&
+                   !of_machine_is_compatible("renesas,sh73a0"))
+                       return 0;
+       }
+
        pm_clk_add_notifier(&platform_bus_type, &platform_bus_notifier);
        return 0;
 }
 core_initcall(sh_pm_runtime_init);
-
-static int __init sh_pm_runtime_late_init(void)
-{
-       pm_genpd_poweroff_unused();
-       return 0;
-}
-late_initcall(sh_pm_runtime_late_init);
index 581ee2a..90c6231 100644 (file)
@@ -416,7 +416,6 @@ config SPI_SH_MSIOF
        tristate "SuperH MSIOF SPI controller"
        depends on HAVE_CLK
        depends on SUPERH || ARCH_SHMOBILE || COMPILE_TEST
-       select SPI_BITBANG
        help
          SPI driver for SuperH and SH Mobile MSIOF blocks.
 
index 5d7deaf..1928b83 100644 (file)
@@ -13,7 +13,6 @@
  * published by the Free Software Foundation.
  */
 
-#include <linux/init.h>
 #include <linux/interrupt.h>
 #include <linux/errno.h>
 #include <linux/module.h>
index c3b2fb9..3898b0b 100644 (file)
@@ -14,7 +14,6 @@
 
 #include <linux/kernel.h>
 #include <linux/module.h>
-#include <linux/init.h>
 #include <linux/delay.h>
 #include <linux/spinlock.h>
 #include <linux/workqueue.h>
index 5d7b07f..af8a336 100644 (file)
@@ -9,7 +9,6 @@
  */
 
 #include <linux/kernel.h>
-#include <linux/init.h>
 #include <linux/clk.h>
 #include <linux/module.h>
 #include <linux/platform_device.h>
index 77286ae..9e9ee5f 100644 (file)
@@ -20,7 +20,6 @@
  */
 
 #include <linux/kernel.h>
-#include <linux/init.h>
 #include <linux/clk.h>
 #include <linux/io.h>
 #include <linux/module.h>
index 38941e5..f515c5e 100644 (file)
@@ -8,7 +8,6 @@
  * Licensed under the GPL-2 or later.
  */
 
-#include <linux/init.h>
 #include <linux/module.h>
 #include <linux/delay.h>
 #include <linux/device.h>
index bd222f6..3bfdb85 100644 (file)
@@ -16,7 +16,6 @@
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  */
 
-#include <linux/init.h>
 #include <linux/spinlock.h>
 #include <linux/workqueue.h>
 #include <linux/interrupt.h>
index 374ba4a..bee864d 100644 (file)
@@ -11,7 +11,6 @@
 
 #include <linux/io.h>
 #include <linux/clk.h>
-#include <linux/init.h>
 #include <linux/gpio.h>
 #include <linux/delay.h>
 #include <linux/module.h>
index 7beeb29..cfc9fb3 100644 (file)
@@ -19,7 +19,6 @@
  */
 #include <linux/kernel.h>
 #include <linux/module.h>
-#include <linux/init.h>
 #include <linux/platform_device.h>
 #include <linux/gpio.h>
 #include <linux/of.h>
index 47f15d9..3af247c 100644 (file)
@@ -23,7 +23,6 @@
 #include <linux/delay.h>
 #include <linux/err.h>
 #include <linux/gpio.h>
-#include <linux/init.h>
 #include <linux/interrupt.h>
 #include <linux/io.h>
 #include <linux/irq.h>
index 5032141..56cead9 100644 (file)
@@ -16,7 +16,6 @@
 
 #include <linux/module.h>
 #include <linux/kernel.h>
-#include <linux/init.h>
 #include <linux/errno.h>
 #include <linux/interrupt.h>
 #include <linux/of_address.h>
index 00ba910..3d18d93 100644 (file)
@@ -12,7 +12,6 @@
  */
 
 #include <linux/module.h>
-#include <linux/init.h>
 #include <linux/types.h>
 #include <linux/errno.h>
 #include <linux/interrupt.h>
index 7c675fe..f573c3c 100644 (file)
@@ -12,7 +12,6 @@
  */
 
 #include <linux/module.h>
-#include <linux/init.h>
 #include <linux/errno.h>
 #include <linux/of_platform.h>
 #include <linux/interrupt.h>
index 79e5aa2..17bb9a9 100644 (file)
@@ -29,7 +29,6 @@
  */
 
 #include <linux/kernel.h>
-#include <linux/init.h>
 #include <linux/ioport.h>
 #include <linux/of.h>
 #include <linux/of_device.h>
index bae97ff..d8d55c7 100644 (file)
@@ -9,7 +9,6 @@
  */
 
 #include <linux/module.h>
-#include <linux/init.h>
 #include <linux/spinlock.h>
 #include <linux/workqueue.h>
 #include <linux/interrupt.h>
index f7c896e..022774e 100644 (file)
@@ -15,7 +15,6 @@
  * published by the Free Software Foundation.
  */
 
-#include <linux/init.h>
 #include <linux/interrupt.h>
 #include <linux/errno.h>
 #include <linux/module.h>
index 67249a4..5665ae9 100644 (file)
@@ -11,7 +11,6 @@
 #include <linux/spi/spi.h>
 #include <linux/module.h>
 #include <linux/delay.h>
-#include <linux/init.h>
 #include <linux/io.h>
 #include <linux/of.h>
 
index b0059e7..7fe69d5 100644 (file)
@@ -22,7 +22,6 @@
  */
 
 #include <linux/kernel.h>
-#include <linux/init.h>
 #include <linux/interrupt.h>
 #include <linux/module.h>
 #include <linux/device.h>
index 977b061..a7aad67 100644 (file)
@@ -9,7 +9,6 @@
  * published by the Free Software Foundation.
  */
 
-#include <linux/init.h>
 #include <linux/interrupt.h>
 #include <linux/delay.h>
 #include <linux/platform_device.h>
index 5ee5672..80b8408 100644 (file)
@@ -24,7 +24,6 @@
  */
 
 #include <linux/module.h>
-#include <linux/init.h>
 #include <linux/sched.h>
 #include <linux/slab.h>
 #include <linux/errno.h>
index 3c0b551..713af48 100644 (file)
@@ -9,7 +9,6 @@
  * published by the Free Software Foundation.
  */
 
-#include <linux/init.h>
 #include <linux/device.h>
 #include <linux/dma-mapping.h>
 #include <linux/dmaengine.h>
index 2916efc..e8a26f2 100644 (file)
@@ -18,7 +18,6 @@
  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  */
 
-#include <linux/init.h>
 #include <linux/delay.h>
 #include <linux/device.h>
 #include <linux/dma-mapping.h>
index 28987d9..54bb0fa 100644 (file)
@@ -1,7 +1,8 @@
 /*
  * SH RSPI driver
  *
- * Copyright (C) 2012  Renesas Solutions Corp.
+ * Copyright (C) 2012, 2013  Renesas Solutions Corp.
+ * Copyright (C) 2014 Glider bvba
  *
  * Based on spi-sh.c:
  * Copyright (C) 2011 Renesas Solutions Corp.
 #include <linux/kernel.h>
 #include <linux/sched.h>
 #include <linux/errno.h>
-#include <linux/list.h>
-#include <linux/workqueue.h>
 #include <linux/interrupt.h>
 #include <linux/platform_device.h>
 #include <linux/io.h>
 #include <linux/clk.h>
 #include <linux/dmaengine.h>
 #include <linux/dma-mapping.h>
+#include <linux/of_device.h>
+#include <linux/pm_runtime.h>
 #include <linux/sh_dma.h>
 #include <linux/spi/spi.h>
 #include <linux/spi/rspi.h>
@@ -49,7 +50,7 @@
 #define RSPI_SPCKD             0x0c    /* Clock Delay Register */
 #define RSPI_SSLND             0x0d    /* Slave Select Negation Delay Register */
 #define RSPI_SPND              0x0e    /* Next-Access Delay Register */
-#define RSPI_SPCR2             0x0f    /* Control Register 2 */
+#define RSPI_SPCR2             0x0f    /* Control Register 2 (SH only) */
 #define RSPI_SPCMD0            0x10    /* Command Register 0 */
 #define RSPI_SPCMD1            0x12    /* Command Register 1 */
 #define RSPI_SPCMD2            0x14    /* Command Register 2 */
 #define RSPI_SPCMD5            0x1a    /* Command Register 5 */
 #define RSPI_SPCMD6            0x1c    /* Command Register 6 */
 #define RSPI_SPCMD7            0x1e    /* Command Register 7 */
+#define RSPI_SPCMD(i)          (RSPI_SPCMD0 + (i) * 2)
+#define RSPI_NUM_SPCMD         8
+#define RSPI_RZ_NUM_SPCMD      4
+#define QSPI_NUM_SPCMD         4
+
+/* RSPI on RZ only */
 #define RSPI_SPBFCR            0x20    /* Buffer Control Register */
 #define RSPI_SPBFDR            0x22    /* Buffer Data Count Setting Register */
 
-/*qspi only */
+/* QSPI only */
 #define QSPI_SPBFCR            0x18    /* Buffer Control Register */
 #define QSPI_SPBDCR            0x1a    /* Buffer Data Count Register */
 #define QSPI_SPBMUL0           0x1c    /* Transfer Data Length Multiplier Setting Register 0 */
 #define QSPI_SPBMUL1           0x20    /* Transfer Data Length Multiplier Setting Register 1 */
 #define QSPI_SPBMUL2           0x24    /* Transfer Data Length Multiplier Setting Register 2 */
 #define QSPI_SPBMUL3           0x28    /* Transfer Data Length Multiplier Setting Register 3 */
+#define QSPI_SPBMUL(i)         (QSPI_SPBMUL0 + (i) * 4)
 
 /* SPCR - Control Register */
 #define SPCR_SPRIE             0x80    /* Receive Interrupt Enable */
@@ -79,7 +87,7 @@
 /* RSPI on SH only */
 #define SPCR_TXMD              0x02    /* TX Only Mode (vs. Full Duplex) */
 #define SPCR_SPMS              0x01    /* 3-wire Mode (vs. 4-wire) */
-/* QSPI on R-Car M2 only */
+/* QSPI on R-Car Gen2 only */
 #define SPCR_WSWAP             0x02    /* Word Swap of read-data for DMAC */
 #define SPCR_BSWAP             0x01    /* Byte Swap of read-data for DMAC */
 
 #define SPSR_PERF              0x08    /* Parity Error Flag */
 #define SPSR_MODF              0x04    /* Mode Fault Error Flag */
 #define SPSR_IDLNF             0x02    /* RSPI Idle Flag */
-#define SPSR_OVRF              0x01    /* Overrun Error Flag */
+#define SPSR_OVRF              0x01    /* Overrun Error Flag (RSPI only) */
 
 /* SPSCR - Sequence Control Register */
 #define SPSCR_SPSLN_MASK       0x07    /* Sequence Length Specification */
 #define SPDCR_SPLWORD          SPDCR_SPLW1
 #define SPDCR_SPLBYTE          SPDCR_SPLW0
 #define SPDCR_SPLW             0x20    /* Access Width Specification (SH) */
-#define SPDCR_SPRDTD           0x10    /* Receive Transmit Data Select */
+#define SPDCR_SPRDTD           0x10    /* Receive Transmit Data Select (SH) */
 #define SPDCR_SLSEL1           0x08
 #define SPDCR_SLSEL0           0x04
-#define SPDCR_SLSEL_MASK       0x0c    /* SSL1 Output Select */
+#define SPDCR_SLSEL_MASK       0x0c    /* SSL1 Output Select (SH) */
 #define SPDCR_SPFC1            0x02
 #define SPDCR_SPFC0            0x01
-#define SPDCR_SPFC_MASK                0x03    /* Frame Count Setting (1-4) */
+#define SPDCR_SPFC_MASK                0x03    /* Frame Count Setting (1-4) (SH) */
 
 /* SPCKD - Clock Delay Register */
 #define SPCKD_SCKDL_MASK       0x07    /* Clock Delay Setting (1-8) */
 #define SPCMD_LSBF             0x1000  /* LSB First */
 #define SPCMD_SPB_MASK         0x0f00  /* Data Length Setting */
 #define SPCMD_SPB_8_TO_16(bit) (((bit - 1) << 8) & SPCMD_SPB_MASK)
-#define SPCMD_SPB_8BIT         0x0000  /* qspi only */
+#define SPCMD_SPB_8BIT         0x0000  /* QSPI only */
 #define SPCMD_SPB_16BIT                0x0100
 #define SPCMD_SPB_20BIT                0x0000
 #define SPCMD_SPB_24BIT                0x0100
 #define SPCMD_CPHA             0x0001  /* Clock Phase Setting */
 
 /* SPBFCR - Buffer Control Register */
-#define SPBFCR_TXRST           0x80    /* Transmit Buffer Data Reset (qspi only) */
-#define SPBFCR_RXRST           0x40    /* Receive Buffer Data Reset (qspi only) */
+#define SPBFCR_TXRST           0x80    /* Transmit Buffer Data Reset */
+#define SPBFCR_RXRST           0x40    /* Receive Buffer Data Reset */
 #define SPBFCR_TXTRG_MASK      0x30    /* Transmit Buffer Data Triggering Number */
 #define SPBFCR_RXTRG_MASK      0x07    /* Receive Buffer Data Triggering Number */
 
-#define DUMMY_DATA             0x00
-
 struct rspi_data {
        void __iomem *addr;
        u32 max_speed_hz;
        struct spi_master *master;
-       struct list_head queue;
-       struct work_struct ws;
        wait_queue_head_t wait;
-       spinlock_t lock;
        struct clk *clk;
-       u8 spsr;
        u16 spcmd;
+       u8 spsr;
+       u8 sppcr;
+       int rx_irq, tx_irq;
        const struct spi_ops *ops;
 
-       /* for dmaengine */
-       struct dma_chan *chan_tx;
-       struct dma_chan *chan_rx;
-       int irq;
-
-       unsigned dma_width_16bit:1;
        unsigned dma_callbacked:1;
+       unsigned byte_access:1;
 };
 
 static void rspi_write8(const struct rspi_data *rspi, u8 data, u16 offset)
@@ -224,34 +224,50 @@ static u16 rspi_read16(const struct rspi_data *rspi, u16 offset)
        return ioread16(rspi->addr + offset);
 }
 
+static void rspi_write_data(const struct rspi_data *rspi, u16 data)
+{
+       if (rspi->byte_access)
+               rspi_write8(rspi, data, RSPI_SPDR);
+       else /* 16 bit */
+               rspi_write16(rspi, data, RSPI_SPDR);
+}
+
+static u16 rspi_read_data(const struct rspi_data *rspi)
+{
+       if (rspi->byte_access)
+               return rspi_read8(rspi, RSPI_SPDR);
+       else /* 16 bit */
+               return rspi_read16(rspi, RSPI_SPDR);
+}
+
 /* optional functions */
 struct spi_ops {
-       int (*set_config_register)(const struct rspi_data *rspi,
-                                  int access_size);
-       int (*send_pio)(struct rspi_data *rspi, struct spi_message *mesg,
-                       struct spi_transfer *t);
-       int (*receive_pio)(struct rspi_data *rspi, struct spi_message *mesg,
-                          struct spi_transfer *t);
-
+       int (*set_config_register)(struct rspi_data *rspi, int access_size);
+       int (*transfer_one)(struct spi_master *master, struct spi_device *spi,
+                           struct spi_transfer *xfer);
+       u16 mode_bits;
+       u16 flags;
+       u16 fifo_size;
 };
 
 /*
- * functions for RSPI
+ * functions for RSPI on legacy SH
  */
-static int rspi_set_config_register(const struct rspi_data *rspi,
-                                   int access_size)
+static int rspi_set_config_register(struct rspi_data *rspi, int access_size)
 {
        int spbr;
 
-       /* Sets output mode(CMOS) and MOSI signal(from previous transfer) */
-       rspi_write8(rspi, 0x00, RSPI_SPPCR);
+       /* Sets output mode, MOSI signal, and (optionally) loopback */
+       rspi_write8(rspi, rspi->sppcr, RSPI_SPPCR);
 
        /* Sets transfer bit rate */
-       spbr = clk_get_rate(rspi->clk) / (2 * rspi->max_speed_hz) - 1;
+       spbr = DIV_ROUND_UP(clk_get_rate(rspi->clk),
+                           2 * rspi->max_speed_hz) - 1;
        rspi_write8(rspi, clamp(spbr, 0, 255), RSPI_SPBR);
 
-       /* Sets number of frames to be used: 1 frame */
-       rspi_write8(rspi, 0x00, RSPI_SPDCR);
+       /* Disable dummy transmission, set 16-bit word access, 1 frame */
+       rspi_write8(rspi, 0, RSPI_SPDCR);
+       rspi->byte_access = 0;
 
        /* Sets RSPCK, SSL, next-access delay value */
        rspi_write8(rspi, 0x00, RSPI_SPCKD);
@@ -262,8 +278,42 @@ static int rspi_set_config_register(const struct rspi_data *rspi,
        rspi_write8(rspi, 0x00, RSPI_SPCR2);
 
        /* Sets SPCMD */
-       rspi_write16(rspi, SPCMD_SPB_8_TO_16(access_size) | rspi->spcmd,
-                    RSPI_SPCMD0);
+       rspi->spcmd |= SPCMD_SPB_8_TO_16(access_size);
+       rspi_write16(rspi, rspi->spcmd, RSPI_SPCMD0);
+
+       /* Sets RSPI mode */
+       rspi_write8(rspi, SPCR_MSTR, RSPI_SPCR);
+
+       return 0;
+}
+
+/*
+ * functions for RSPI on RZ
+ */
+static int rspi_rz_set_config_register(struct rspi_data *rspi, int access_size)
+{
+       int spbr;
+
+       /* Sets output mode, MOSI signal, and (optionally) loopback */
+       rspi_write8(rspi, rspi->sppcr, RSPI_SPPCR);
+
+       /* Sets transfer bit rate */
+       spbr = DIV_ROUND_UP(clk_get_rate(rspi->clk),
+                           2 * rspi->max_speed_hz) - 1;
+       rspi_write8(rspi, clamp(spbr, 0, 255), RSPI_SPBR);
+
+       /* Disable dummy transmission, set byte access */
+       rspi_write8(rspi, SPDCR_SPLBYTE, RSPI_SPDCR);
+       rspi->byte_access = 1;
+
+       /* Sets RSPCK, SSL, next-access delay value */
+       rspi_write8(rspi, 0x00, RSPI_SPCKD);
+       rspi_write8(rspi, 0x00, RSPI_SSLND);
+       rspi_write8(rspi, 0x00, RSPI_SPND);
+
+       /* Sets SPCMD */
+       rspi->spcmd |= SPCMD_SPB_8_TO_16(access_size);
+       rspi_write16(rspi, rspi->spcmd, RSPI_SPCMD0);
 
        /* Sets RSPI mode */
        rspi_write8(rspi, SPCR_MSTR, RSPI_SPCR);
@@ -274,21 +324,20 @@ static int rspi_set_config_register(const struct rspi_data *rspi,
 /*
  * functions for QSPI
  */
-static int qspi_set_config_register(const struct rspi_data *rspi,
-                                   int access_size)
+static int qspi_set_config_register(struct rspi_data *rspi, int access_size)
 {
-       u16 spcmd;
        int spbr;
 
-       /* Sets output mode(CMOS) and MOSI signal(from previous transfer) */
-       rspi_write8(rspi, 0x00, RSPI_SPPCR);
+       /* Sets output mode, MOSI signal, and (optionally) loopback */
+       rspi_write8(rspi, rspi->sppcr, RSPI_SPPCR);
 
        /* Sets transfer bit rate */
-       spbr = clk_get_rate(rspi->clk) / (2 * rspi->max_speed_hz);
+       spbr = DIV_ROUND_UP(clk_get_rate(rspi->clk), 2 * rspi->max_speed_hz);
        rspi_write8(rspi, clamp(spbr, 0, 255), RSPI_SPBR);
 
-       /* Sets number of frames to be used: 1 frame */
-       rspi_write8(rspi, 0x00, RSPI_SPDCR);
+       /* Disable dummy transmission, set byte access */
+       rspi_write8(rspi, 0, RSPI_SPDCR);
+       rspi->byte_access = 1;
 
        /* Sets RSPCK, SSL, next-access delay value */
        rspi_write8(rspi, 0x00, RSPI_SPCKD);
@@ -297,13 +346,13 @@ static int qspi_set_config_register(const struct rspi_data *rspi,
 
        /* Data Length Setting */
        if (access_size == 8)
-               spcmd = SPCMD_SPB_8BIT;
+               rspi->spcmd |= SPCMD_SPB_8BIT;
        else if (access_size == 16)
-               spcmd = SPCMD_SPB_16BIT;
+               rspi->spcmd |= SPCMD_SPB_16BIT;
        else
-               spcmd = SPCMD_SPB_32BIT;
+               rspi->spcmd |= SPCMD_SPB_32BIT;
 
-       spcmd |= SPCMD_SCKDEN | SPCMD_SLNDEN | rspi->spcmd | SPCMD_SPNDEN;
+       rspi->spcmd |= SPCMD_SCKDEN | SPCMD_SLNDEN | SPCMD_SPNDEN;
 
        /* Resets transfer data length */
        rspi_write32(rspi, 0, QSPI_SPBMUL0);
@@ -314,9 +363,9 @@ static int qspi_set_config_register(const struct rspi_data *rspi,
        rspi_write8(rspi, 0x00, QSPI_SPBFCR);
 
        /* Sets SPCMD */
-       rspi_write16(rspi, spcmd, RSPI_SPCMD0);
+       rspi_write16(rspi, rspi->spcmd, RSPI_SPCMD0);
 
-       /* Enables SPI function in master mode */
+       /* Enables SPI function in master mode */
        rspi_write8(rspi, SPCR_SPE | SPCR_MSTR, RSPI_SPCR);
 
        return 0;
@@ -340,6 +389,9 @@ static int rspi_wait_for_interrupt(struct rspi_data *rspi, u8 wait_mask,
        int ret;
 
        rspi->spsr = rspi_read8(rspi, RSPI_SPSR);
+       if (rspi->spsr & wait_mask)
+               return 0;
+
        rspi_enable_irq(rspi, enable_bit);
        ret = wait_event_timeout(rspi->wait, rspi->spsr & wait_mask, HZ);
        if (ret == 0 && !(rspi->spsr & wait_mask))
@@ -348,78 +400,61 @@ static int rspi_wait_for_interrupt(struct rspi_data *rspi, u8 wait_mask,
        return 0;
 }
 
-static void rspi_assert_ssl(const struct rspi_data *rspi)
+static inline int rspi_wait_for_tx_empty(struct rspi_data *rspi)
 {
-       rspi_write8(rspi, rspi_read8(rspi, RSPI_SPCR) | SPCR_SPE, RSPI_SPCR);
+       return rspi_wait_for_interrupt(rspi, SPSR_SPTEF, SPCR_SPTIE);
 }
 
-static void rspi_negate_ssl(const struct rspi_data *rspi)
+static inline int rspi_wait_for_rx_full(struct rspi_data *rspi)
 {
-       rspi_write8(rspi, rspi_read8(rspi, RSPI_SPCR) & ~SPCR_SPE, RSPI_SPCR);
+       return rspi_wait_for_interrupt(rspi, SPSR_SPRF, SPCR_SPRIE);
 }
 
-static int rspi_send_pio(struct rspi_data *rspi, struct spi_message *mesg,
-                        struct spi_transfer *t)
+static int rspi_data_out(struct rspi_data *rspi, u8 data)
 {
-       int remain = t->len;
-       const u8 *data = t->tx_buf;
-       while (remain > 0) {
-               rspi_write8(rspi, rspi_read8(rspi, RSPI_SPCR) | SPCR_TXMD,
-                           RSPI_SPCR);
-
-               if (rspi_wait_for_interrupt(rspi, SPSR_SPTEF, SPCR_SPTIE) < 0) {
-                       dev_err(&rspi->master->dev,
-                               "%s: tx empty timeout\n", __func__);
-                       return -ETIMEDOUT;
-               }
-
-               rspi_write16(rspi, *data, RSPI_SPDR);
-               data++;
-               remain--;
+       int error = rspi_wait_for_tx_empty(rspi);
+       if (error < 0) {
+               dev_err(&rspi->master->dev, "transmit timeout\n");
+               return error;
        }
-
-       /* Waiting for the last transmission */
-       rspi_wait_for_interrupt(rspi, SPSR_SPTEF, SPCR_SPTIE);
-
+       rspi_write_data(rspi, data);
        return 0;
 }
 
-static int qspi_send_pio(struct rspi_data *rspi, struct spi_message *mesg,
-                        struct spi_transfer *t)
+static int rspi_data_in(struct rspi_data *rspi)
 {
-       int remain = t->len;
-       const u8 *data = t->tx_buf;
+       int error;
+       u8 data;
 
-       rspi_write8(rspi, SPBFCR_TXRST, QSPI_SPBFCR);
-       rspi_write8(rspi, 0x00, QSPI_SPBFCR);
-
-       while (remain > 0) {
+       error = rspi_wait_for_rx_full(rspi);
+       if (error < 0) {
+               dev_err(&rspi->master->dev, "receive timeout\n");
+               return error;
+       }
+       data = rspi_read_data(rspi);
+       return data;
+}
 
-               if (rspi_wait_for_interrupt(rspi, SPSR_SPTEF, SPCR_SPTIE) < 0) {
-                       dev_err(&rspi->master->dev,
-                               "%s: tx empty timeout\n", __func__);
-                       return -ETIMEDOUT;
+static int rspi_pio_transfer(struct rspi_data *rspi, const u8 *tx, u8 *rx,
+                            unsigned int n)
+{
+       while (n-- > 0) {
+               if (tx) {
+                       int ret = rspi_data_out(rspi, *tx++);
+                       if (ret < 0)
+                               return ret;
                }
-               rspi_write8(rspi, *data++, RSPI_SPDR);
-
-               if (rspi_wait_for_interrupt(rspi, SPSR_SPRF, SPCR_SPRIE) < 0) {
-                       dev_err(&rspi->master->dev,
-                               "%s: receive timeout\n", __func__);
-                       return -ETIMEDOUT;
+               if (rx) {
+                       int ret = rspi_data_in(rspi);
+                       if (ret < 0)
+                               return ret;
+                       *rx++ = ret;
                }
-               rspi_read8(rspi, RSPI_SPDR);
-
-               remain--;
        }
 
-       /* Waiting for the last transmission */
-       rspi_wait_for_interrupt(rspi, SPSR_SPTEF, SPCR_SPTIE);
-
        return 0;
 }
 
-#define send_pio(spi, mesg, t) spi->ops->send_pio(spi, mesg, t)
-
 static void rspi_dma_complete(void *arg)
 {
        struct rspi_data *rspi = arg;
@@ -428,114 +463,110 @@ static void rspi_dma_complete(void *arg)
        wake_up_interruptible(&rspi->wait);
 }
 
-static int rspi_dma_map_sg(struct scatterlist *sg, const void *buf,
-                          unsigned len, struct dma_chan *chan,
-                          enum dma_transfer_direction dir)
+static int rspi_dma_transfer(struct rspi_data *rspi, struct sg_table *tx,
+                            struct sg_table *rx)
 {
-       sg_init_table(sg, 1);
-       sg_set_buf(sg, buf, len);
-       sg_dma_len(sg) = len;
-       return dma_map_sg(chan->device->dev, sg, 1, dir);
-}
+       struct dma_async_tx_descriptor *desc_tx = NULL, *desc_rx = NULL;
+       u8 irq_mask = 0;
+       unsigned int other_irq = 0;
+       dma_cookie_t cookie;
+       int ret;
 
-static void rspi_dma_unmap_sg(struct scatterlist *sg, struct dma_chan *chan,
-                             enum dma_transfer_direction dir)
-{
-       dma_unmap_sg(chan->device->dev, sg, 1, dir);
-}
+       /* First prepare and submit the DMA request(s), as this may fail */
+       if (rx) {
+               desc_rx = dmaengine_prep_slave_sg(rspi->master->dma_rx,
+                                       rx->sgl, rx->nents, DMA_FROM_DEVICE,
+                                       DMA_PREP_INTERRUPT | DMA_CTRL_ACK);
+               if (!desc_rx) {
+                       ret = -EAGAIN;
+                       goto no_dma_rx;
+               }
 
-static void rspi_memory_to_8bit(void *buf, const void *data, unsigned len)
-{
-       u16 *dst = buf;
-       const u8 *src = data;
+               desc_rx->callback = rspi_dma_complete;
+               desc_rx->callback_param = rspi;
+               cookie = dmaengine_submit(desc_rx);
+               if (dma_submit_error(cookie)) {
+                       ret = cookie;
+                       goto no_dma_rx;
+               }
 
-       while (len) {
-               *dst++ = (u16)(*src++);
-               len--;
+               irq_mask |= SPCR_SPRIE;
        }
-}
-
-static void rspi_memory_from_8bit(void *buf, const void *data, unsigned len)
-{
-       u8 *dst = buf;
-       const u16 *src = data;
 
-       while (len) {
-               *dst++ = (u8)*src++;
-               len--;
-       }
-}
+       if (tx) {
+               desc_tx = dmaengine_prep_slave_sg(rspi->master->dma_tx,
+                                       tx->sgl, tx->nents, DMA_TO_DEVICE,
+                                       DMA_PREP_INTERRUPT | DMA_CTRL_ACK);
+               if (!desc_tx) {
+                       ret = -EAGAIN;
+                       goto no_dma_tx;
+               }
 
-static int rspi_send_dma(struct rspi_data *rspi, struct spi_transfer *t)
-{
-       struct scatterlist sg;
-       const void *buf = NULL;
-       struct dma_async_tx_descriptor *desc;
-       unsigned len;
-       int ret = 0;
-
-       if (rspi->dma_width_16bit) {
-               void *tmp;
-               /*
-                * If DMAC bus width is 16-bit, the driver allocates a dummy
-                * buffer. And, the driver converts original data into the
-                * DMAC data as the following format:
-                *  original data: 1st byte, 2nd byte ...
-                *  DMAC data:     1st byte, dummy, 2nd byte, dummy ...
-                */
-               len = t->len * 2;
-               tmp = kmalloc(len, GFP_KERNEL);
-               if (!tmp)
-                       return -ENOMEM;
-               rspi_memory_to_8bit(tmp, t->tx_buf, t->len);
-               buf = tmp;
-       } else {
-               len = t->len;
-               buf = t->tx_buf;
-       }
+               if (rx) {
+                       /* No callback */
+                       desc_tx->callback = NULL;
+               } else {
+                       desc_tx->callback = rspi_dma_complete;
+                       desc_tx->callback_param = rspi;
+               }
+               cookie = dmaengine_submit(desc_tx);
+               if (dma_submit_error(cookie)) {
+                       ret = cookie;
+                       goto no_dma_tx;
+               }
 
-       if (!rspi_dma_map_sg(&sg, buf, len, rspi->chan_tx, DMA_TO_DEVICE)) {
-               ret = -EFAULT;
-               goto end_nomap;
-       }
-       desc = dmaengine_prep_slave_sg(rspi->chan_tx, &sg, 1, DMA_TO_DEVICE,
-                                      DMA_PREP_INTERRUPT | DMA_CTRL_ACK);
-       if (!desc) {
-               ret = -EIO;
-               goto end;
+               irq_mask |= SPCR_SPTIE;
        }
 
        /*
-        * DMAC needs SPTIE, but if SPTIE is set, this IRQ routine will be
+        * DMAC needs SPxIE, but if SPxIE is set, the IRQ routine will be
         * called. So, this driver disables the IRQ while DMA transfer.
         */
-       disable_irq(rspi->irq);
+       if (tx)
+               disable_irq(other_irq = rspi->tx_irq);
+       if (rx && rspi->rx_irq != other_irq)
+               disable_irq(rspi->rx_irq);
 
-       rspi_write8(rspi, rspi_read8(rspi, RSPI_SPCR) | SPCR_TXMD, RSPI_SPCR);
-       rspi_enable_irq(rspi, SPCR_SPTIE);
+       rspi_enable_irq(rspi, irq_mask);
        rspi->dma_callbacked = 0;
 
-       desc->callback = rspi_dma_complete;
-       desc->callback_param = rspi;
-       dmaengine_submit(desc);
-       dma_async_issue_pending(rspi->chan_tx);
+       /* Now start DMA */
+       if (rx)
+               dma_async_issue_pending(rspi->master->dma_rx);
+       if (tx)
+               dma_async_issue_pending(rspi->master->dma_tx);
 
        ret = wait_event_interruptible_timeout(rspi->wait,
                                               rspi->dma_callbacked, HZ);
        if (ret > 0 && rspi->dma_callbacked)
                ret = 0;
-       else if (!ret)
+       else if (!ret) {
+               dev_err(&rspi->master->dev, "DMA timeout\n");
                ret = -ETIMEDOUT;
-       rspi_disable_irq(rspi, SPCR_SPTIE);
+               if (tx)
+                       dmaengine_terminate_all(rspi->master->dma_tx);
+               if (rx)
+                       dmaengine_terminate_all(rspi->master->dma_rx);
+       }
+
+       rspi_disable_irq(rspi, irq_mask);
 
-       enable_irq(rspi->irq);
+       if (tx)
+               enable_irq(rspi->tx_irq);
+       if (rx && rspi->rx_irq != other_irq)
+               enable_irq(rspi->rx_irq);
 
-end:
-       rspi_dma_unmap_sg(&sg, rspi->chan_tx, DMA_TO_DEVICE);
-end_nomap:
-       if (rspi->dma_width_16bit)
-               kfree(buf);
+       return ret;
 
+no_dma_tx:
+       if (rx)
+               dmaengine_terminate_all(rspi->master->dma_rx);
+no_dma_rx:
+       if (ret == -EAGAIN) {
+               pr_warn_once("%s %s: DMA not available, falling back to PIO\n",
+                            dev_driver_string(&rspi->master->dev),
+                            dev_name(&rspi->master->dev));
+       }
        return ret;
 }
 
@@ -545,46 +576,17 @@ static void rspi_receive_init(const struct rspi_data *rspi)
 
        spsr = rspi_read8(rspi, RSPI_SPSR);
        if (spsr & SPSR_SPRF)
-               rspi_read16(rspi, RSPI_SPDR);   /* dummy read */
+               rspi_read_data(rspi);   /* dummy read */
        if (spsr & SPSR_OVRF)
                rspi_write8(rspi, rspi_read8(rspi, RSPI_SPSR) & ~SPSR_OVRF,
                            RSPI_SPSR);
 }
 
-static int rspi_receive_pio(struct rspi_data *rspi, struct spi_message *mesg,
-                           struct spi_transfer *t)
+static void rspi_rz_receive_init(const struct rspi_data *rspi)
 {
-       int remain = t->len;
-       u8 *data;
-
        rspi_receive_init(rspi);
-
-       data = t->rx_buf;
-       while (remain > 0) {
-               rspi_write8(rspi, rspi_read8(rspi, RSPI_SPCR) & ~SPCR_TXMD,
-                           RSPI_SPCR);
-
-               if (rspi_wait_for_interrupt(rspi, SPSR_SPTEF, SPCR_SPTIE) < 0) {
-                       dev_err(&rspi->master->dev,
-                               "%s: tx empty timeout\n", __func__);
-                       return -ETIMEDOUT;
-               }
-               /* dummy write for generate clock */
-               rspi_write16(rspi, DUMMY_DATA, RSPI_SPDR);
-
-               if (rspi_wait_for_interrupt(rspi, SPSR_SPRF, SPCR_SPRIE) < 0) {
-                       dev_err(&rspi->master->dev,
-                               "%s: receive timeout\n", __func__);
-                       return -ETIMEDOUT;
-               }
-               /* SPDR allows 16 or 32-bit access only */
-               *data = (u8)rspi_read16(rspi, RSPI_SPDR);
-
-               data++;
-               remain--;
-       }
-
-       return 0;
+       rspi_write8(rspi, SPBFCR_TXRST | SPBFCR_RXRST, RSPI_SPBFCR);
+       rspi_write8(rspi, 0, RSPI_SPBFCR);
 }
 
 static void qspi_receive_init(const struct rspi_data *rspi)
@@ -593,209 +595,133 @@ static void qspi_receive_init(const struct rspi_data *rspi)
 
        spsr = rspi_read8(rspi, RSPI_SPSR);
        if (spsr & SPSR_SPRF)
-               rspi_read8(rspi, RSPI_SPDR);   /* dummy read */
+               rspi_read_data(rspi);   /* dummy read */
        rspi_write8(rspi, SPBFCR_TXRST | SPBFCR_RXRST, QSPI_SPBFCR);
-       rspi_write8(rspi, 0x00, QSPI_SPBFCR);
+       rspi_write8(rspi, 0, QSPI_SPBFCR);
 }
 
-static int qspi_receive_pio(struct rspi_data *rspi, struct spi_message *mesg,
-                           struct spi_transfer *t)
+static bool __rspi_can_dma(const struct rspi_data *rspi,
+                          const struct spi_transfer *xfer)
 {
-       int remain = t->len;
-       u8 *data;
+       return xfer->len > rspi->ops->fifo_size;
+}
 
-       qspi_receive_init(rspi);
+static bool rspi_can_dma(struct spi_master *master, struct spi_device *spi,
+                        struct spi_transfer *xfer)
+{
+       struct rspi_data *rspi = spi_master_get_devdata(master);
 
-       data = t->rx_buf;
-       while (remain > 0) {
+       return __rspi_can_dma(rspi, xfer);
+}
 
-               if (rspi_wait_for_interrupt(rspi, SPSR_SPTEF, SPCR_SPTIE) < 0) {
-                       dev_err(&rspi->master->dev,
-                               "%s: tx empty timeout\n", __func__);
-                       return -ETIMEDOUT;
-               }
-               /* dummy write for generate clock */
-               rspi_write8(rspi, DUMMY_DATA, RSPI_SPDR);
+static int rspi_common_transfer(struct rspi_data *rspi,
+                               struct spi_transfer *xfer)
+{
+       int ret;
 
-               if (rspi_wait_for_interrupt(rspi, SPSR_SPRF, SPCR_SPRIE) < 0) {
-                       dev_err(&rspi->master->dev,
-                               "%s: receive timeout\n", __func__);
-                       return -ETIMEDOUT;
-               }
-               /* SPDR allows 8, 16 or 32-bit access */
-               *data++ = rspi_read8(rspi, RSPI_SPDR);
-               remain--;
+       if (rspi->master->can_dma && __rspi_can_dma(rspi, xfer)) {
+               /* rx_buf can be NULL on RSPI on SH in TX-only Mode */
+               ret = rspi_dma_transfer(rspi, &xfer->tx_sg,
+                                       xfer->rx_buf ? &xfer->rx_sg : NULL);
+               if (ret != -EAGAIN)
+                       return ret;
        }
 
+       ret = rspi_pio_transfer(rspi, xfer->tx_buf, xfer->rx_buf, xfer->len);
+       if (ret < 0)
+               return ret;
+
+       /* Wait for the last transmission */
+       rspi_wait_for_tx_empty(rspi);
+
        return 0;
 }
 
-#define receive_pio(spi, mesg, t) spi->ops->receive_pio(spi, mesg, t)
-
-static int rspi_receive_dma(struct rspi_data *rspi, struct spi_transfer *t)
+static int rspi_transfer_one(struct spi_master *master, struct spi_device *spi,
+                            struct spi_transfer *xfer)
 {
-       struct scatterlist sg, sg_dummy;
-       void *dummy = NULL, *rx_buf = NULL;
-       struct dma_async_tx_descriptor *desc, *desc_dummy;
-       unsigned len;
-       int ret = 0;
-
-       if (rspi->dma_width_16bit) {
-               /*
-                * If DMAC bus width is 16-bit, the driver allocates a dummy
-                * buffer. And, finally the driver converts the DMAC data into
-                * actual data as the following format:
-                *  DMAC data:   1st byte, dummy, 2nd byte, dummy ...
-                *  actual data: 1st byte, 2nd byte ...
-                */
-               len = t->len * 2;
-               rx_buf = kmalloc(len, GFP_KERNEL);
-               if (!rx_buf)
-                       return -ENOMEM;
-        } else {
-               len = t->len;
-               rx_buf = t->rx_buf;
-       }
+       struct rspi_data *rspi = spi_master_get_devdata(master);
+       u8 spcr;
 
-       /* prepare dummy transfer to generate SPI clocks */
-       dummy = kzalloc(len, GFP_KERNEL);
-       if (!dummy) {
-               ret = -ENOMEM;
-               goto end_nomap;
-       }
-       if (!rspi_dma_map_sg(&sg_dummy, dummy, len, rspi->chan_tx,
-                            DMA_TO_DEVICE)) {
-               ret = -EFAULT;
-               goto end_nomap;
-       }
-       desc_dummy = dmaengine_prep_slave_sg(rspi->chan_tx, &sg_dummy, 1,
-                       DMA_TO_DEVICE, DMA_PREP_INTERRUPT | DMA_CTRL_ACK);
-       if (!desc_dummy) {
-               ret = -EIO;
-               goto end_dummy_mapped;
-       }
-
-       /* prepare receive transfer */
-       if (!rspi_dma_map_sg(&sg, rx_buf, len, rspi->chan_rx,
-                            DMA_FROM_DEVICE)) {
-               ret = -EFAULT;
-               goto end_dummy_mapped;
-
-       }
-       desc = dmaengine_prep_slave_sg(rspi->chan_rx, &sg, 1, DMA_FROM_DEVICE,
-                                      DMA_PREP_INTERRUPT | DMA_CTRL_ACK);
-       if (!desc) {
-               ret = -EIO;
-               goto end;
+       spcr = rspi_read8(rspi, RSPI_SPCR);
+       if (xfer->rx_buf) {
+               rspi_receive_init(rspi);
+               spcr &= ~SPCR_TXMD;
+       } else {
+               spcr |= SPCR_TXMD;
        }
+       rspi_write8(rspi, spcr, RSPI_SPCR);
 
-       rspi_receive_init(rspi);
+       return rspi_common_transfer(rspi, xfer);
+}
 
-       /*
-        * DMAC needs SPTIE, but if SPTIE is set, this IRQ routine will be
-        * called. So, this driver disables the IRQ while DMA transfer.
-        */
-       disable_irq(rspi->irq);
+static int rspi_rz_transfer_one(struct spi_master *master,
+                               struct spi_device *spi,
+                               struct spi_transfer *xfer)
+{
+       struct rspi_data *rspi = spi_master_get_devdata(master);
 
-       rspi_write8(rspi, rspi_read8(rspi, RSPI_SPCR) & ~SPCR_TXMD, RSPI_SPCR);
-       rspi_enable_irq(rspi, SPCR_SPTIE | SPCR_SPRIE);
-       rspi->dma_callbacked = 0;
+       rspi_rz_receive_init(rspi);
 
-       desc->callback = rspi_dma_complete;
-       desc->callback_param = rspi;
-       dmaengine_submit(desc);
-       dma_async_issue_pending(rspi->chan_rx);
+       return rspi_common_transfer(rspi, xfer);
+}
 
-       desc_dummy->callback = NULL;    /* No callback */
-       dmaengine_submit(desc_dummy);
-       dma_async_issue_pending(rspi->chan_tx);
+static int qspi_transfer_out_in(struct rspi_data *rspi,
+                               struct spi_transfer *xfer)
+{
+       qspi_receive_init(rspi);
 
-       ret = wait_event_interruptible_timeout(rspi->wait,
-                                              rspi->dma_callbacked, HZ);
-       if (ret > 0 && rspi->dma_callbacked)
-               ret = 0;
-       else if (!ret)
-               ret = -ETIMEDOUT;
-       rspi_disable_irq(rspi, SPCR_SPTIE | SPCR_SPRIE);
+       return rspi_common_transfer(rspi, xfer);
+}
 
-       enable_irq(rspi->irq);
+static int qspi_transfer_out(struct rspi_data *rspi, struct spi_transfer *xfer)
+{
+       int ret;
 
-end:
-       rspi_dma_unmap_sg(&sg, rspi->chan_rx, DMA_FROM_DEVICE);
-end_dummy_mapped:
-       rspi_dma_unmap_sg(&sg_dummy, rspi->chan_tx, DMA_TO_DEVICE);
-end_nomap:
-       if (rspi->dma_width_16bit) {
-               if (!ret)
-                       rspi_memory_from_8bit(t->rx_buf, rx_buf, t->len);
-               kfree(rx_buf);
+       if (rspi->master->can_dma && __rspi_can_dma(rspi, xfer)) {
+               ret = rspi_dma_transfer(rspi, &xfer->tx_sg, NULL);
+               if (ret != -EAGAIN)
+                       return ret;
        }
-       kfree(dummy);
 
-       return ret;
-}
+       ret = rspi_pio_transfer(rspi, xfer->tx_buf, NULL, xfer->len);
+       if (ret < 0)
+               return ret;
 
-static int rspi_is_dma(const struct rspi_data *rspi, struct spi_transfer *t)
-{
-       if (t->tx_buf && rspi->chan_tx)
-               return 1;
-       /* If the module receives data by DMAC, it also needs TX DMAC */
-       if (t->rx_buf && rspi->chan_tx && rspi->chan_rx)
-               return 1;
+       /* Wait for the last transmission */
+       rspi_wait_for_tx_empty(rspi);
 
        return 0;
 }
 
-static void rspi_work(struct work_struct *work)
+static int qspi_transfer_in(struct rspi_data *rspi, struct spi_transfer *xfer)
 {
-       struct rspi_data *rspi = container_of(work, struct rspi_data, ws);
-       struct spi_message *mesg;
-       struct spi_transfer *t;
-       unsigned long flags;
-       int ret;
-
-       while (1) {
-               spin_lock_irqsave(&rspi->lock, flags);
-               if (list_empty(&rspi->queue)) {
-                       spin_unlock_irqrestore(&rspi->lock, flags);
-                       break;
-               }
-               mesg = list_entry(rspi->queue.next, struct spi_message, queue);
-               list_del_init(&mesg->queue);
-               spin_unlock_irqrestore(&rspi->lock, flags);
-
-               rspi_assert_ssl(rspi);
-
-               list_for_each_entry(t, &mesg->transfers, transfer_list) {
-                       if (t->tx_buf) {
-                               if (rspi_is_dma(rspi, t))
-                                       ret = rspi_send_dma(rspi, t);
-                               else
-                                       ret = send_pio(rspi, mesg, t);
-                               if (ret < 0)
-                                       goto error;
-                       }
-                       if (t->rx_buf) {
-                               if (rspi_is_dma(rspi, t))
-                                       ret = rspi_receive_dma(rspi, t);
-                               else
-                                       ret = receive_pio(rspi, mesg, t);
-                               if (ret < 0)
-                                       goto error;
-                       }
-                       mesg->actual_length += t->len;
-               }
-               rspi_negate_ssl(rspi);
-
-               mesg->status = 0;
-               mesg->complete(mesg->context);
+       if (rspi->master->can_dma && __rspi_can_dma(rspi, xfer)) {
+               int ret = rspi_dma_transfer(rspi, NULL, &xfer->rx_sg);
+               if (ret != -EAGAIN)
+                       return ret;
        }
 
-       return;
+       return rspi_pio_transfer(rspi, NULL, xfer->rx_buf, xfer->len);
+}
 
-error:
-       mesg->status = ret;
-       mesg->complete(mesg->context);
+static int qspi_transfer_one(struct spi_master *master, struct spi_device *spi,
+                            struct spi_transfer *xfer)
+{
+       struct rspi_data *rspi = spi_master_get_devdata(master);
+
+       if (spi->mode & SPI_LOOP) {
+               return qspi_transfer_out_in(rspi, xfer);
+       } else if (xfer->tx_nbits > SPI_NBITS_SINGLE) {
+               /* Quad or Dual SPI Write */
+               return qspi_transfer_out(rspi, xfer);
+       } else if (xfer->rx_nbits > SPI_NBITS_SINGLE) {
+               /* Quad or Dual SPI Read */
+               return qspi_transfer_in(rspi, xfer);
+       } else {
+               /* Single SPI Transfer */
+               return qspi_transfer_out_in(rspi, xfer);
+       }
 }
 
 static int rspi_setup(struct spi_device *spi)
@@ -810,32 +736,115 @@ static int rspi_setup(struct spi_device *spi)
        if (spi->mode & SPI_CPHA)
                rspi->spcmd |= SPCMD_CPHA;
 
+       /* CMOS output mode and MOSI signal from previous transfer */
+       rspi->sppcr = 0;
+       if (spi->mode & SPI_LOOP)
+               rspi->sppcr |= SPPCR_SPLP;
+
        set_config_register(rspi, 8);
 
        return 0;
 }
 
-static int rspi_transfer(struct spi_device *spi, struct spi_message *mesg)
+static u16 qspi_transfer_mode(const struct spi_transfer *xfer)
 {
-       struct rspi_data *rspi = spi_master_get_devdata(spi->master);
-       unsigned long flags;
+       if (xfer->tx_buf)
+               switch (xfer->tx_nbits) {
+               case SPI_NBITS_QUAD:
+                       return SPCMD_SPIMOD_QUAD;
+               case SPI_NBITS_DUAL:
+                       return SPCMD_SPIMOD_DUAL;
+               default:
+                       return 0;
+               }
+       if (xfer->rx_buf)
+               switch (xfer->rx_nbits) {
+               case SPI_NBITS_QUAD:
+                       return SPCMD_SPIMOD_QUAD | SPCMD_SPRW;
+               case SPI_NBITS_DUAL:
+                       return SPCMD_SPIMOD_DUAL | SPCMD_SPRW;
+               default:
+                       return 0;
+               }
+
+       return 0;
+}
+
+static int qspi_setup_sequencer(struct rspi_data *rspi,
+                               const struct spi_message *msg)
+{
+       const struct spi_transfer *xfer;
+       unsigned int i = 0, len = 0;
+       u16 current_mode = 0xffff, mode;
+
+       list_for_each_entry(xfer, &msg->transfers, transfer_list) {
+               mode = qspi_transfer_mode(xfer);
+               if (mode == current_mode) {
+                       len += xfer->len;
+                       continue;
+               }
+
+               /* Transfer mode change */
+               if (i) {
+                       /* Set transfer data length of previous transfer */
+                       rspi_write32(rspi, len, QSPI_SPBMUL(i - 1));
+               }
+
+               if (i >= QSPI_NUM_SPCMD) {
+                       dev_err(&msg->spi->dev,
+                               "Too many different transfer modes");
+                       return -EINVAL;
+               }
 
-       mesg->actual_length = 0;
-       mesg->status = -EINPROGRESS;
+               /* Program transfer mode for this transfer */
+               rspi_write16(rspi, rspi->spcmd | mode, RSPI_SPCMD(i));
+               current_mode = mode;
+               len = xfer->len;
+               i++;
+       }
+       if (i) {
+               /* Set final transfer data length and sequence length */
+               rspi_write32(rspi, len, QSPI_SPBMUL(i - 1));
+               rspi_write8(rspi, i - 1, RSPI_SPSCR);
+       }
+
+       return 0;
+}
 
-       spin_lock_irqsave(&rspi->lock, flags);
-       list_add_tail(&mesg->queue, &rspi->queue);
-       schedule_work(&rspi->ws);
-       spin_unlock_irqrestore(&rspi->lock, flags);
+static int rspi_prepare_message(struct spi_master *master,
+                               struct spi_message *msg)
+{
+       struct rspi_data *rspi = spi_master_get_devdata(master);
+       int ret;
+
+       if (msg->spi->mode &
+           (SPI_TX_DUAL | SPI_TX_QUAD | SPI_RX_DUAL | SPI_RX_QUAD)) {
+               /* Setup sequencer for messages with multiple transfer modes */
+               ret = qspi_setup_sequencer(rspi, msg);
+               if (ret < 0)
+                       return ret;
+       }
 
+       /* Enable SPI function in master mode */
+       rspi_write8(rspi, rspi_read8(rspi, RSPI_SPCR) | SPCR_SPE, RSPI_SPCR);
        return 0;
 }
 
-static void rspi_cleanup(struct spi_device *spi)
+static int rspi_unprepare_message(struct spi_master *master,
+                                 struct spi_message *msg)
 {
+       struct rspi_data *rspi = spi_master_get_devdata(master);
+
+       /* Disable SPI function */
+       rspi_write8(rspi, rspi_read8(rspi, RSPI_SPCR) & ~SPCR_SPE, RSPI_SPCR);
+
+       /* Reset sequencer for Single SPI Transfers */
+       rspi_write16(rspi, rspi->spcmd, RSPI_SPCMD0);
+       rspi_write8(rspi, 0, RSPI_SPSCR);
+       return 0;
 }
 
-static irqreturn_t rspi_irq(int irq, void *_sr)
+static irqreturn_t rspi_irq_mux(int irq, void *_sr)
 {
        struct rspi_data *rspi = _sr;
        u8 spsr;
@@ -857,100 +866,215 @@ static irqreturn_t rspi_irq(int irq, void *_sr)
        return ret;
 }
 
-static int rspi_request_dma(struct rspi_data *rspi,
-                                     struct platform_device *pdev)
+static irqreturn_t rspi_irq_rx(int irq, void *_sr)
+{
+       struct rspi_data *rspi = _sr;
+       u8 spsr;
+
+       rspi->spsr = spsr = rspi_read8(rspi, RSPI_SPSR);
+       if (spsr & SPSR_SPRF) {
+               rspi_disable_irq(rspi, SPCR_SPRIE);
+               wake_up(&rspi->wait);
+               return IRQ_HANDLED;
+       }
+
+       return 0;
+}
+
+static irqreturn_t rspi_irq_tx(int irq, void *_sr)
+{
+       struct rspi_data *rspi = _sr;
+       u8 spsr;
+
+       rspi->spsr = spsr = rspi_read8(rspi, RSPI_SPSR);
+       if (spsr & SPSR_SPTEF) {
+               rspi_disable_irq(rspi, SPCR_SPTIE);
+               wake_up(&rspi->wait);
+               return IRQ_HANDLED;
+       }
+
+       return 0;
+}
+
+static struct dma_chan *rspi_request_dma_chan(struct device *dev,
+                                             enum dma_transfer_direction dir,
+                                             unsigned int id,
+                                             dma_addr_t port_addr)
 {
-       const struct rspi_plat_data *rspi_pd = dev_get_platdata(&pdev->dev);
-       struct resource *res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
        dma_cap_mask_t mask;
+       struct dma_chan *chan;
        struct dma_slave_config cfg;
        int ret;
 
-       if (!res || !rspi_pd)
-               return 0;       /* The driver assumes no error. */
-
-       rspi->dma_width_16bit = rspi_pd->dma_width_16bit;
-
-       /* If the module receives data by DMAC, it also needs TX DMAC */
-       if (rspi_pd->dma_rx_id && rspi_pd->dma_tx_id) {
-               dma_cap_zero(mask);
-               dma_cap_set(DMA_SLAVE, mask);
-               rspi->chan_rx = dma_request_channel(mask, shdma_chan_filter,
-                                                   (void *)rspi_pd->dma_rx_id);
-               if (rspi->chan_rx) {
-                       cfg.slave_id = rspi_pd->dma_rx_id;
-                       cfg.direction = DMA_DEV_TO_MEM;
-                       cfg.dst_addr = 0;
-                       cfg.src_addr = res->start + RSPI_SPDR;
-                       ret = dmaengine_slave_config(rspi->chan_rx, &cfg);
-                       if (!ret)
-                               dev_info(&pdev->dev, "Use DMA when rx.\n");
-                       else
-                               return ret;
-               }
+       dma_cap_zero(mask);
+       dma_cap_set(DMA_SLAVE, mask);
+
+       chan = dma_request_slave_channel_compat(mask, shdma_chan_filter,
+                               (void *)(unsigned long)id, dev,
+                               dir == DMA_MEM_TO_DEV ? "tx" : "rx");
+       if (!chan) {
+               dev_warn(dev, "dma_request_slave_channel_compat failed\n");
+               return NULL;
        }
-       if (rspi_pd->dma_tx_id) {
-               dma_cap_zero(mask);
-               dma_cap_set(DMA_SLAVE, mask);
-               rspi->chan_tx = dma_request_channel(mask, shdma_chan_filter,
-                                                   (void *)rspi_pd->dma_tx_id);
-               if (rspi->chan_tx) {
-                       cfg.slave_id = rspi_pd->dma_tx_id;
-                       cfg.direction = DMA_MEM_TO_DEV;
-                       cfg.dst_addr = res->start + RSPI_SPDR;
-                       cfg.src_addr = 0;
-                       ret = dmaengine_slave_config(rspi->chan_tx, &cfg);
-                       if (!ret)
-                               dev_info(&pdev->dev, "Use DMA when tx\n");
-                       else
-                               return ret;
-               }
+
+       memset(&cfg, 0, sizeof(cfg));
+       cfg.slave_id = id;
+       cfg.direction = dir;
+       if (dir == DMA_MEM_TO_DEV) {
+               cfg.dst_addr = port_addr;
+               cfg.dst_addr_width = DMA_SLAVE_BUSWIDTH_1_BYTE;
+       } else {
+               cfg.src_addr = port_addr;
+               cfg.src_addr_width = DMA_SLAVE_BUSWIDTH_1_BYTE;
+       }
+
+       ret = dmaengine_slave_config(chan, &cfg);
+       if (ret) {
+               dev_warn(dev, "dmaengine_slave_config failed %d\n", ret);
+               dma_release_channel(chan);
+               return NULL;
+       }
+
+       return chan;
+}
+
+static int rspi_request_dma(struct device *dev, struct spi_master *master,
+                           const struct resource *res)
+{
+       const struct rspi_plat_data *rspi_pd = dev_get_platdata(dev);
+       unsigned int dma_tx_id, dma_rx_id;
+
+       if (dev->of_node) {
+               /* In the OF case we will get the slave IDs from the DT */
+               dma_tx_id = 0;
+               dma_rx_id = 0;
+       } else if (rspi_pd && rspi_pd->dma_tx_id && rspi_pd->dma_rx_id) {
+               dma_tx_id = rspi_pd->dma_tx_id;
+               dma_rx_id = rspi_pd->dma_rx_id;
+       } else {
+               /* The driver assumes no error. */
+               return 0;
        }
 
+       master->dma_tx = rspi_request_dma_chan(dev, DMA_MEM_TO_DEV, dma_tx_id,
+                                              res->start + RSPI_SPDR);
+       if (!master->dma_tx)
+               return -ENODEV;
+
+       master->dma_rx = rspi_request_dma_chan(dev, DMA_DEV_TO_MEM, dma_rx_id,
+                                              res->start + RSPI_SPDR);
+       if (!master->dma_rx) {
+               dma_release_channel(master->dma_tx);
+               master->dma_tx = NULL;
+               return -ENODEV;
+       }
+
+       master->can_dma = rspi_can_dma;
+       dev_info(dev, "DMA available");
        return 0;
 }
 
-static void rspi_release_dma(struct rspi_data *rspi)
+static void rspi_release_dma(struct spi_master *master)
 {
-       if (rspi->chan_tx)
-               dma_release_channel(rspi->chan_tx);
-       if (rspi->chan_rx)
-               dma_release_channel(rspi->chan_rx);
+       if (master->dma_tx)
+               dma_release_channel(master->dma_tx);
+       if (master->dma_rx)
+               dma_release_channel(master->dma_rx);
 }
 
 static int rspi_remove(struct platform_device *pdev)
 {
        struct rspi_data *rspi = platform_get_drvdata(pdev);
 
-       rspi_release_dma(rspi);
-       clk_disable(rspi->clk);
+       rspi_release_dma(rspi->master);
+       pm_runtime_disable(&pdev->dev);
+
+       return 0;
+}
+
+static const struct spi_ops rspi_ops = {
+       .set_config_register =  rspi_set_config_register,
+       .transfer_one =         rspi_transfer_one,
+       .mode_bits =            SPI_CPHA | SPI_CPOL | SPI_LOOP,
+       .flags =                SPI_MASTER_MUST_TX,
+       .fifo_size =            8,
+};
+
+static const struct spi_ops rspi_rz_ops = {
+       .set_config_register =  rspi_rz_set_config_register,
+       .transfer_one =         rspi_rz_transfer_one,
+       .mode_bits =            SPI_CPHA | SPI_CPOL | SPI_LOOP,
+       .flags =                SPI_MASTER_MUST_RX | SPI_MASTER_MUST_TX,
+       .fifo_size =            8,      /* 8 for TX, 32 for RX */
+};
+
+static const struct spi_ops qspi_ops = {
+       .set_config_register =  qspi_set_config_register,
+       .transfer_one =         qspi_transfer_one,
+       .mode_bits =            SPI_CPHA | SPI_CPOL | SPI_LOOP |
+                               SPI_TX_DUAL | SPI_TX_QUAD |
+                               SPI_RX_DUAL | SPI_RX_QUAD,
+       .flags =                SPI_MASTER_MUST_RX | SPI_MASTER_MUST_TX,
+       .fifo_size =            32,
+};
+
+#ifdef CONFIG_OF
+static const struct of_device_id rspi_of_match[] = {
+       /* RSPI on legacy SH */
+       { .compatible = "renesas,rspi", .data = &rspi_ops },
+       /* RSPI on RZ/A1H */
+       { .compatible = "renesas,rspi-rz", .data = &rspi_rz_ops },
+       /* QSPI on R-Car Gen2 */
+       { .compatible = "renesas,qspi", .data = &qspi_ops },
+       { /* sentinel */ }
+};
+
+MODULE_DEVICE_TABLE(of, rspi_of_match);
 
+static int rspi_parse_dt(struct device *dev, struct spi_master *master)
+{
+       u32 num_cs;
+       int error;
+
+       /* Parse DT properties */
+       error = of_property_read_u32(dev->of_node, "num-cs", &num_cs);
+       if (error) {
+               dev_err(dev, "of_property_read_u32 num-cs failed %d\n", error);
+               return error;
+       }
+
+       master->num_chipselect = num_cs;
        return 0;
 }
+#else
+#define rspi_of_match  NULL
+static inline int rspi_parse_dt(struct device *dev, struct spi_master *master)
+{
+       return -EINVAL;
+}
+#endif /* CONFIG_OF */
+
+static int rspi_request_irq(struct device *dev, unsigned int irq,
+                           irq_handler_t handler, const char *suffix,
+                           void *dev_id)
+{
+       const char *name = devm_kasprintf(dev, GFP_KERNEL, "%s:%s",
+                                         dev_name(dev), suffix);
+       if (!name)
+               return -ENOMEM;
+
+       return devm_request_irq(dev, irq, handler, 0, name, dev_id);
+}
 
 static int rspi_probe(struct platform_device *pdev)
 {
        struct resource *res;
        struct spi_master *master;
        struct rspi_data *rspi;
-       int ret, irq;
-       char clk_name[16];
-       const struct rspi_plat_data *rspi_pd = dev_get_platdata(&pdev->dev);
+       int ret;
+       const struct of_device_id *of_id;
+       const struct rspi_plat_data *rspi_pd;
        const struct spi_ops *ops;
-       const struct platform_device_id *id_entry = pdev->id_entry;
-
-       ops = (struct spi_ops *)id_entry->driver_data;
-       /* ops parameter check */
-       if (!ops->set_config_register) {
-               dev_err(&pdev->dev, "there is no set_config_register\n");
-               return -ENODEV;
-       }
-
-       irq = platform_get_irq(pdev, 0);
-       if (irq < 0) {
-               dev_err(&pdev->dev, "platform_get_irq error\n");
-               return -ENODEV;
-       }
 
        master = spi_alloc_master(&pdev->dev, sizeof(struct rspi_data));
        if (master == NULL) {
@@ -958,6 +1082,28 @@ static int rspi_probe(struct platform_device *pdev)
                return -ENOMEM;
        }
 
+       of_id = of_match_device(rspi_of_match, &pdev->dev);
+       if (of_id) {
+               ops = of_id->data;
+               ret = rspi_parse_dt(&pdev->dev, master);
+               if (ret)
+                       goto error1;
+       } else {
+               ops = (struct spi_ops *)pdev->id_entry->driver_data;
+               rspi_pd = dev_get_platdata(&pdev->dev);
+               if (rspi_pd && rspi_pd->num_chipselect)
+                       master->num_chipselect = rspi_pd->num_chipselect;
+               else
+                       master->num_chipselect = 2; /* default */
+       }
+
+       /* ops parameter check */
+       if (!ops->set_config_register) {
+               dev_err(&pdev->dev, "there is no set_config_register\n");
+               ret = -ENODEV;
+               goto error1;
+       }
+
        rspi = spi_master_get_devdata(master);
        platform_set_drvdata(pdev, rspi);
        rspi->ops = ops;
@@ -970,45 +1116,66 @@ static int rspi_probe(struct platform_device *pdev)
                goto error1;
        }
 
-       snprintf(clk_name, sizeof(clk_name), "%s%d", id_entry->name, pdev->id);
-       rspi->clk = devm_clk_get(&pdev->dev, clk_name);
+       rspi->clk = devm_clk_get(&pdev->dev, NULL);
        if (IS_ERR(rspi->clk)) {
                dev_err(&pdev->dev, "cannot get clock\n");
                ret = PTR_ERR(rspi->clk);
                goto error1;
        }
-       clk_enable(rspi->clk);
 
-       INIT_LIST_HEAD(&rspi->queue);
-       spin_lock_init(&rspi->lock);
-       INIT_WORK(&rspi->ws, rspi_work);
-       init_waitqueue_head(&rspi->wait);
+       pm_runtime_enable(&pdev->dev);
 
-       if (rspi_pd && rspi_pd->num_chipselect)
-               master->num_chipselect = rspi_pd->num_chipselect;
-       else
-               master->num_chipselect = 2; /* default */
+       init_waitqueue_head(&rspi->wait);
 
        master->bus_num = pdev->id;
        master->setup = rspi_setup;
-       master->transfer = rspi_transfer;
-       master->cleanup = rspi_cleanup;
-       master->mode_bits = SPI_CPHA | SPI_CPOL;
-
-       ret = devm_request_irq(&pdev->dev, irq, rspi_irq, 0,
-                              dev_name(&pdev->dev), rspi);
+       master->auto_runtime_pm = true;
+       master->transfer_one = ops->transfer_one;
+       master->prepare_message = rspi_prepare_message;
+       master->unprepare_message = rspi_unprepare_message;
+       master->mode_bits = ops->mode_bits;
+       master->flags = ops->flags;
+       master->dev.of_node = pdev->dev.of_node;
+
+       ret = platform_get_irq_byname(pdev, "rx");
        if (ret < 0) {
-               dev_err(&pdev->dev, "request_irq error\n");
+               ret = platform_get_irq_byname(pdev, "mux");
+               if (ret < 0)
+                       ret = platform_get_irq(pdev, 0);
+               if (ret >= 0)
+                       rspi->rx_irq = rspi->tx_irq = ret;
+       } else {
+               rspi->rx_irq = ret;
+               ret = platform_get_irq_byname(pdev, "tx");
+               if (ret >= 0)
+                       rspi->tx_irq = ret;
+       }
+       if (ret < 0) {
+               dev_err(&pdev->dev, "platform_get_irq error\n");
                goto error2;
        }
 
-       rspi->irq = irq;
-       ret = rspi_request_dma(rspi, pdev);
+       if (rspi->rx_irq == rspi->tx_irq) {
+               /* Single multiplexed interrupt */
+               ret = rspi_request_irq(&pdev->dev, rspi->rx_irq, rspi_irq_mux,
+                                      "mux", rspi);
+       } else {
+               /* Multi-interrupt mode, only SPRI and SPTI are used */
+               ret = rspi_request_irq(&pdev->dev, rspi->rx_irq, rspi_irq_rx,
+                                      "rx", rspi);
+               if (!ret)
+                       ret = rspi_request_irq(&pdev->dev, rspi->tx_irq,
+                                              rspi_irq_tx, "tx", rspi);
+       }
        if (ret < 0) {
-               dev_err(&pdev->dev, "rspi_request_dma failed.\n");
-               goto error3;
+               dev_err(&pdev->dev, "request_irq error\n");
+               goto error2;
        }
 
+       ret = rspi_request_dma(&pdev->dev, master, res);
+       if (ret < 0)
+               dev_warn(&pdev->dev, "DMA not available, using PIO\n");
+
        ret = devm_spi_register_master(&pdev->dev, master);
        if (ret < 0) {
                dev_err(&pdev->dev, "spi_register_master error.\n");
@@ -1020,29 +1187,18 @@ static int rspi_probe(struct platform_device *pdev)
        return 0;
 
 error3:
-       rspi_release_dma(rspi);
+       rspi_release_dma(master);
 error2:
-       clk_disable(rspi->clk);
+       pm_runtime_disable(&pdev->dev);
 error1:
        spi_master_put(master);
 
        return ret;
 }
 
-static struct spi_ops rspi_ops = {
-       .set_config_register =          rspi_set_config_register,
-       .send_pio =                     rspi_send_pio,
-       .receive_pio =                  rspi_receive_pio,
-};
-
-static struct spi_ops qspi_ops = {
-       .set_config_register =          qspi_set_config_register,
-       .send_pio =                     qspi_send_pio,
-       .receive_pio =                  qspi_receive_pio,
-};
-
 static struct platform_device_id spi_driver_ids[] = {
        { "rspi",       (kernel_ulong_t)&rspi_ops },
+       { "rspi-rz",    (kernel_ulong_t)&rspi_rz_ops },
        { "qspi",       (kernel_ulong_t)&qspi_ops },
        {},
 };
@@ -1056,6 +1212,7 @@ static struct platform_driver rspi_driver = {
        .driver         = {
                .name = "renesas_spi",
                .owner  = THIS_MODULE,
+               .of_match_table = of_match_ptr(rspi_of_match),
        },
 };
 module_platform_driver(rspi_driver);
index 746424a..c20df45 100644 (file)
@@ -9,7 +9,6 @@
  *
 */
 
-#include <linux/init.h>
 #include <linux/spinlock.h>
 #include <linux/workqueue.h>
 #include <linux/interrupt.h>
index ae907dd..c717b2b 100644 (file)
@@ -381,7 +381,7 @@ static void s3c64xx_spi_dma_stop(struct s3c64xx_spi_driver_data *sdd,
 #else
 
 static void prepare_dma(struct s3c64xx_spi_dma_data *dma,
-                                       unsigned len, dma_addr_t buf)
+                       struct sg_table *sgt)
 {
        struct s3c64xx_spi_driver_data *sdd;
        struct dma_slave_config config;
@@ -407,8 +407,8 @@ static void prepare_dma(struct s3c64xx_spi_dma_data *dma,
                dmaengine_slave_config(dma->ch, &config);
        }
 
-       desc = dmaengine_prep_slave_single(dma->ch, buf, len,
-                                       dma->direction, DMA_PREP_INTERRUPT);
+       desc = dmaengine_prep_slave_sg(dma->ch, sgt->sgl, sgt->nents,
+                                      dma->direction, DMA_PREP_INTERRUPT);
 
        desc->callback = s3c64xx_spi_dmacb;
        desc->callback_param = dma;
@@ -515,7 +515,11 @@ static void enable_datapath(struct s3c64xx_spi_driver_data *sdd,
                chcfg |= S3C64XX_SPI_CH_TXCH_ON;
                if (dma_mode) {
                        modecfg |= S3C64XX_SPI_MODE_TXDMA_ON;
+#ifndef CONFIG_S3C_DMA
+                       prepare_dma(&sdd->tx_dma, &xfer->tx_sg);
+#else
                        prepare_dma(&sdd->tx_dma, xfer->len, xfer->tx_dma);
+#endif
                } else {
                        switch (sdd->cur_bpw) {
                        case 32:
@@ -547,7 +551,11 @@ static void enable_datapath(struct s3c64xx_spi_driver_data *sdd,
                        writel(((xfer->len * 8 / sdd->cur_bpw) & 0xffff)
                                        | S3C64XX_SPI_PACKET_CNT_EN,
                                        regs + S3C64XX_SPI_PACKET_CNT);
+#ifndef CONFIG_S3C_DMA
+                       prepare_dma(&sdd->rx_dma, &xfer->rx_sg);
+#else
                        prepare_dma(&sdd->rx_dma, xfer->len, xfer->rx_dma);
+#endif
                }
        }
 
index 81cc02f..3f36540 100644 (file)
@@ -2,6 +2,7 @@
  * SuperH MSIOF SPI Master Interface
  *
  * Copyright (c) 2009 Magnus Damm
+ * Copyright (C) 2014 Glider bvba
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License version 2 as
 #include <linux/clk.h>
 #include <linux/completion.h>
 #include <linux/delay.h>
+#include <linux/dma-mapping.h>
+#include <linux/dmaengine.h>
 #include <linux/err.h>
 #include <linux/gpio.h>
-#include <linux/init.h>
 #include <linux/interrupt.h>
 #include <linux/io.h>
 #include <linux/kernel.h>
 #include <linux/module.h>
 #include <linux/of.h>
+#include <linux/of_device.h>
 #include <linux/platform_device.h>
 #include <linux/pm_runtime.h>
+#include <linux/sh_dma.h>
 
 #include <linux/spi/sh_msiof.h>
 #include <linux/spi/spi.h>
-#include <linux/spi/spi_bitbang.h>
 
 #include <asm/unaligned.h>
 
+
+struct sh_msiof_chipdata {
+       u16 tx_fifo_size;
+       u16 rx_fifo_size;
+       u16 master_flags;
+};
+
 struct sh_msiof_spi_priv {
-       struct spi_bitbang bitbang; /* must be first for spi_bitbang.c */
+       struct spi_master *master;
        void __iomem *mapbase;
        struct clk *clk;
        struct platform_device *pdev;
+       const struct sh_msiof_chipdata *chipdata;
        struct sh_msiof_spi_info *info;
        struct completion done;
-       unsigned long flags;
        int tx_fifo_size;
        int rx_fifo_size;
+       void *tx_dma_page;
+       void *rx_dma_page;
+       dma_addr_t tx_dma_addr;
+       dma_addr_t rx_dma_addr;
 };
 
-#define TMDR1  0x00
-#define TMDR2  0x04
-#define TMDR3  0x08
-#define RMDR1  0x10
-#define RMDR2  0x14
-#define RMDR3  0x18
-#define TSCR   0x20
-#define RSCR   0x22
-#define CTR    0x28
-#define FCTR   0x30
-#define STR    0x40
-#define IER    0x44
-#define TDR1   0x48
-#define TDR2   0x4c
-#define TFDR   0x50
-#define RDR1   0x58
-#define RDR2   0x5c
-#define RFDR   0x60
-
-#define CTR_TSCKE (1 << 15)
-#define CTR_TFSE  (1 << 14)
-#define CTR_TXE   (1 << 9)
-#define CTR_RXE   (1 << 8)
-
-#define STR_TEOF  (1 << 23)
-#define STR_REOF  (1 << 7)
+#define TMDR1  0x00    /* Transmit Mode Register 1 */
+#define TMDR2  0x04    /* Transmit Mode Register 2 */
+#define TMDR3  0x08    /* Transmit Mode Register 3 */
+#define RMDR1  0x10    /* Receive Mode Register 1 */
+#define RMDR2  0x14    /* Receive Mode Register 2 */
+#define RMDR3  0x18    /* Receive Mode Register 3 */
+#define TSCR   0x20    /* Transmit Clock Select Register */
+#define RSCR   0x22    /* Receive Clock Select Register (SH, A1, APE6) */
+#define CTR    0x28    /* Control Register */
+#define FCTR   0x30    /* FIFO Control Register */
+#define STR    0x40    /* Status Register */
+#define IER    0x44    /* Interrupt Enable Register */
+#define TDR1   0x48    /* Transmit Control Data Register 1 (SH, A1) */
+#define TDR2   0x4c    /* Transmit Control Data Register 2 (SH, A1) */
+#define TFDR   0x50    /* Transmit FIFO Data Register */
+#define RDR1   0x58    /* Receive Control Data Register 1 (SH, A1) */
+#define RDR2   0x5c    /* Receive Control Data Register 2 (SH, A1) */
+#define RFDR   0x60    /* Receive FIFO Data Register */
+
+/* TMDR1 and RMDR1 */
+#define MDR1_TRMD       0x80000000 /* Transfer Mode (1 = Master mode) */
+#define MDR1_SYNCMD_MASK 0x30000000 /* SYNC Mode */
+#define MDR1_SYNCMD_SPI         0x20000000 /*   Level mode/SPI */
+#define MDR1_SYNCMD_LR  0x30000000 /*   L/R mode */
+#define MDR1_SYNCAC_SHIFT       25 /* Sync Polarity (1 = Active-low) */
+#define MDR1_BITLSB_SHIFT       24 /* MSB/LSB First (1 = LSB first) */
+#define MDR1_FLD_MASK   0x000000c0 /* Frame Sync Signal Interval (0-3) */
+#define MDR1_FLD_SHIFT           2
+#define MDR1_XXSTP      0x00000001 /* Transmission/Reception Stop on FIFO */
+/* TMDR1 */
+#define TMDR1_PCON      0x40000000 /* Transfer Signal Connection */
+
+/* TMDR2 and RMDR2 */
+#define MDR2_BITLEN1(i)        (((i) - 1) << 24) /* Data Size (8-32 bits) */
+#define MDR2_WDLEN1(i) (((i) - 1) << 16) /* Word Count (1-64/256 (SH, A1))) */
+#define MDR2_GRPMASK1  0x00000001 /* Group Output Mask 1 (SH, A1) */
+
+#define MAX_WDLEN      256U
+
+/* TSCR and RSCR */
+#define SCR_BRPS_MASK      0x1f00 /* Prescaler Setting (1-32) */
+#define SCR_BRPS(i)    (((i) - 1) << 8)
+#define SCR_BRDV_MASK      0x0007 /* Baud Rate Generator's Division Ratio */
+#define SCR_BRDV_DIV_2     0x0000
+#define SCR_BRDV_DIV_4     0x0001
+#define SCR_BRDV_DIV_8     0x0002
+#define SCR_BRDV_DIV_16            0x0003
+#define SCR_BRDV_DIV_32            0x0004
+#define SCR_BRDV_DIV_1     0x0007
+
+/* CTR */
+#define CTR_TSCKIZ_MASK        0xc0000000 /* Transmit Clock I/O Polarity Select */
+#define CTR_TSCKIZ_SCK 0x80000000 /*   Disable SCK when TX disabled */
+#define CTR_TSCKIZ_POL_SHIFT   30 /*   Transmit Clock Polarity */
+#define CTR_RSCKIZ_MASK        0x30000000 /* Receive Clock Polarity Select */
+#define CTR_RSCKIZ_SCK 0x20000000 /*   Must match CTR_TSCKIZ_SCK */
+#define CTR_RSCKIZ_POL_SHIFT   28 /*   Receive Clock Polarity */
+#define CTR_TEDG_SHIFT         27 /* Transmit Timing (1 = falling edge) */
+#define CTR_REDG_SHIFT         26 /* Receive Timing (1 = falling edge) */
+#define CTR_TXDIZ_MASK 0x00c00000 /* Pin Output When TX is Disabled */
+#define CTR_TXDIZ_LOW  0x00000000 /*   0 */
+#define CTR_TXDIZ_HIGH 0x00400000 /*   1 */
+#define CTR_TXDIZ_HIZ  0x00800000 /*   High-impedance */
+#define CTR_TSCKE      0x00008000 /* Transmit Serial Clock Output Enable */
+#define CTR_TFSE       0x00004000 /* Transmit Frame Sync Signal Output Enable */
+#define CTR_TXE                0x00000200 /* Transmit Enable */
+#define CTR_RXE                0x00000100 /* Receive Enable */
+
+/* FCTR */
+#define FCTR_TFWM_MASK 0xe0000000 /* Transmit FIFO Watermark */
+#define FCTR_TFWM_64   0x00000000 /*  Transfer Request when 64 empty stages */
+#define FCTR_TFWM_32   0x20000000 /*  Transfer Request when 32 empty stages */
+#define FCTR_TFWM_24   0x40000000 /*  Transfer Request when 24 empty stages */
+#define FCTR_TFWM_16   0x60000000 /*  Transfer Request when 16 empty stages */
+#define FCTR_TFWM_12   0x80000000 /*  Transfer Request when 12 empty stages */
+#define FCTR_TFWM_8    0xa0000000 /*  Transfer Request when 8 empty stages */
+#define FCTR_TFWM_4    0xc0000000 /*  Transfer Request when 4 empty stages */
+#define FCTR_TFWM_1    0xe0000000 /*  Transfer Request when 1 empty stage */
+#define FCTR_TFUA_MASK 0x07f00000 /* Transmit FIFO Usable Area */
+#define FCTR_TFUA_SHIFT                20
+#define FCTR_TFUA(i)   ((i) << FCTR_TFUA_SHIFT)
+#define FCTR_RFWM_MASK 0x0000e000 /* Receive FIFO Watermark */
+#define FCTR_RFWM_1    0x00000000 /*  Transfer Request when 1 valid stages */
+#define FCTR_RFWM_4    0x00002000 /*  Transfer Request when 4 valid stages */
+#define FCTR_RFWM_8    0x00004000 /*  Transfer Request when 8 valid stages */
+#define FCTR_RFWM_16   0x00006000 /*  Transfer Request when 16 valid stages */
+#define FCTR_RFWM_32   0x00008000 /*  Transfer Request when 32 valid stages */
+#define FCTR_RFWM_64   0x0000a000 /*  Transfer Request when 64 valid stages */
+#define FCTR_RFWM_128  0x0000c000 /*  Transfer Request when 128 valid stages */
+#define FCTR_RFWM_256  0x0000e000 /*  Transfer Request when 256 valid stages */
+#define FCTR_RFUA_MASK 0x00001ff0 /* Receive FIFO Usable Area (0x40 = full) */
+#define FCTR_RFUA_SHIFT                 4
+#define FCTR_RFUA(i)   ((i) << FCTR_RFUA_SHIFT)
+
+/* STR */
+#define STR_TFEMP      0x20000000 /* Transmit FIFO Empty */
+#define STR_TDREQ      0x10000000 /* Transmit Data Transfer Request */
+#define STR_TEOF       0x00800000 /* Frame Transmission End */
+#define STR_TFSERR     0x00200000 /* Transmit Frame Synchronization Error */
+#define STR_TFOVF      0x00100000 /* Transmit FIFO Overflow */
+#define STR_TFUDF      0x00080000 /* Transmit FIFO Underflow */
+#define STR_RFFUL      0x00002000 /* Receive FIFO Full */
+#define STR_RDREQ      0x00001000 /* Receive Data Transfer Request */
+#define STR_REOF       0x00000080 /* Frame Reception End */
+#define STR_RFSERR     0x00000020 /* Receive Frame Synchronization Error */
+#define STR_RFUDF      0x00000010 /* Receive FIFO Underflow */
+#define STR_RFOVF      0x00000008 /* Receive FIFO Overflow */
+
+/* IER */
+#define IER_TDMAE      0x80000000 /* Transmit Data DMA Transfer Req. Enable */
+#define IER_TFEMPE     0x20000000 /* Transmit FIFO Empty Enable */
+#define IER_TDREQE     0x10000000 /* Transmit Data Transfer Request Enable */
+#define IER_TEOFE      0x00800000 /* Frame Transmission End Enable */
+#define IER_TFSERRE    0x00200000 /* Transmit Frame Sync Error Enable */
+#define IER_TFOVFE     0x00100000 /* Transmit FIFO Overflow Enable */
+#define IER_TFUDFE     0x00080000 /* Transmit FIFO Underflow Enable */
+#define IER_RDMAE      0x00008000 /* Receive Data DMA Transfer Req. Enable */
+#define IER_RFFULE     0x00002000 /* Receive FIFO Full Enable */
+#define IER_RDREQE     0x00001000 /* Receive Data Transfer Request Enable */
+#define IER_REOFE      0x00000080 /* Frame Reception End Enable */
+#define IER_RFSERRE    0x00000020 /* Receive Frame Sync Error Enable */
+#define IER_RFUDFE     0x00000010 /* Receive FIFO Underflow Enable */
+#define IER_RFOVFE     0x00000008 /* Receive FIFO Overflow Enable */
+
 
 static u32 sh_msiof_read(struct sh_msiof_spi_priv *p, int reg_offs)
 {
@@ -131,22 +243,21 @@ static struct {
        unsigned short div;
        unsigned short scr;
 } const sh_msiof_spi_clk_table[] = {
-       { 1, 0x0007 },
-       { 2, 0x0000 },
-       { 4, 0x0001 },
-       { 8, 0x0002 },
-       { 16, 0x0003 },
-       { 32, 0x0004 },
-       { 64, 0x1f00 },
-       { 128, 0x1f01 },
-       { 256, 0x1f02 },
-       { 512, 0x1f03 },
-       { 1024, 0x1f04 },
+       { 1,    SCR_BRPS( 1) | SCR_BRDV_DIV_1 },
+       { 2,    SCR_BRPS( 1) | SCR_BRDV_DIV_2 },
+       { 4,    SCR_BRPS( 1) | SCR_BRDV_DIV_4 },
+       { 8,    SCR_BRPS( 1) | SCR_BRDV_DIV_8 },
+       { 16,   SCR_BRPS( 1) | SCR_BRDV_DIV_16 },
+       { 32,   SCR_BRPS( 1) | SCR_BRDV_DIV_32 },
+       { 64,   SCR_BRPS(32) | SCR_BRDV_DIV_2 },
+       { 128,  SCR_BRPS(32) | SCR_BRDV_DIV_4 },
+       { 256,  SCR_BRPS(32) | SCR_BRDV_DIV_8 },
+       { 512,  SCR_BRPS(32) | SCR_BRDV_DIV_16 },
+       { 1024, SCR_BRPS(32) | SCR_BRDV_DIV_32 },
 };
 
 static void sh_msiof_spi_set_clk_regs(struct sh_msiof_spi_priv *p,
-                                     unsigned long parent_rate,
-                                     unsigned long spi_hz)
+                                     unsigned long parent_rate, u32 spi_hz)
 {
        unsigned long div = 1024;
        size_t k;
@@ -164,7 +275,8 @@ static void sh_msiof_spi_set_clk_regs(struct sh_msiof_spi_priv *p,
        k = min_t(int, k, ARRAY_SIZE(sh_msiof_spi_clk_table) - 1);
 
        sh_msiof_write(p, TSCR, sh_msiof_spi_clk_table[k].scr);
-       sh_msiof_write(p, RSCR, sh_msiof_spi_clk_table[k].scr);
+       if (!(p->chipdata->master_flags & SPI_MASTER_MUST_TX))
+               sh_msiof_write(p, RSCR, sh_msiof_spi_clk_table[k].scr);
 }
 
 static void sh_msiof_spi_set_pin_regs(struct sh_msiof_spi_priv *p,
@@ -181,23 +293,25 @@ static void sh_msiof_spi_set_pin_regs(struct sh_msiof_spi_priv *p,
         *    1    0         11     11    0    0
         *    1    1         11     11    1    1
         */
-       sh_msiof_write(p, FCTR, 0);
+       tmp = MDR1_SYNCMD_SPI | 1 << MDR1_FLD_SHIFT | MDR1_XXSTP;
+       tmp |= !cs_high << MDR1_SYNCAC_SHIFT;
+       tmp |= lsb_first << MDR1_BITLSB_SHIFT;
+       sh_msiof_write(p, TMDR1, tmp | MDR1_TRMD | TMDR1_PCON);
+       if (p->chipdata->master_flags & SPI_MASTER_MUST_TX) {
+               /* These bits are reserved if RX needs TX */
+               tmp &= ~0x0000ffff;
+       }
+       sh_msiof_write(p, RMDR1, tmp);
 
        tmp = 0;
-       tmp |= !cs_high << 25;
-       tmp |= lsb_first << 24;
-       sh_msiof_write(p, TMDR1, 0xe0000005 | tmp);
-       sh_msiof_write(p, RMDR1, 0x20000005 | tmp);
-
-       tmp = 0xa0000000;
-       tmp |= cpol << 30; /* TSCKIZ */
-       tmp |= cpol << 28; /* RSCKIZ */
+       tmp |= CTR_TSCKIZ_SCK | cpol << CTR_TSCKIZ_POL_SHIFT;
+       tmp |= CTR_RSCKIZ_SCK | cpol << CTR_RSCKIZ_POL_SHIFT;
 
        edge = cpol ^ !cpha;
 
-       tmp |= edge << 27; /* TEDG */
-       tmp |= edge << 26; /* REDG */
-       tmp |= (tx_hi_z ? 2 : 0) << 22; /* TXDIZ */
+       tmp |= edge << CTR_TEDG_SHIFT;
+       tmp |= edge << CTR_REDG_SHIFT;
+       tmp |= tx_hi_z ? CTR_TXDIZ_HIZ : CTR_TXDIZ_LOW;
        sh_msiof_write(p, CTR, tmp);
 }
 
@@ -205,17 +319,15 @@ static void sh_msiof_spi_set_mode_regs(struct sh_msiof_spi_priv *p,
                                       const void *tx_buf, void *rx_buf,
                                       u32 bits, u32 words)
 {
-       u32 dr2 = ((bits - 1) << 24) | ((words - 1) << 16);
+       u32 dr2 = MDR2_BITLEN1(bits) | MDR2_WDLEN1(words);
 
-       if (tx_buf)
+       if (tx_buf || (p->chipdata->master_flags & SPI_MASTER_MUST_TX))
                sh_msiof_write(p, TMDR2, dr2);
        else
-               sh_msiof_write(p, TMDR2, dr2 | 1);
+               sh_msiof_write(p, TMDR2, dr2 | MDR2_GRPMASK1);
 
        if (rx_buf)
                sh_msiof_write(p, RMDR2, dr2);
-
-       sh_msiof_write(p, IER, STR_TEOF | STR_REOF);
 }
 
 static void sh_msiof_reset_str(struct sh_msiof_spi_priv *p)
@@ -363,77 +475,79 @@ static void sh_msiof_spi_read_fifo_s32u(struct sh_msiof_spi_priv *p,
                put_unaligned(swab32(sh_msiof_read(p, RFDR) >> fs), &buf_32[k]);
 }
 
-static int sh_msiof_spi_bits(struct spi_device *spi, struct spi_transfer *t)
+static int sh_msiof_spi_setup(struct spi_device *spi)
 {
-       int bits;
+       struct device_node      *np = spi->master->dev.of_node;
+       struct sh_msiof_spi_priv *p = spi_master_get_devdata(spi->master);
+
+       if (!np) {
+               /*
+                * Use spi->controller_data for CS (same strategy as spi_gpio),
+                * if any. otherwise let HW control CS
+                */
+               spi->cs_gpio = (uintptr_t)spi->controller_data;
+       }
 
-       bits = t ? t->bits_per_word : 0;
-       if (!bits)
-               bits = spi->bits_per_word;
-       return bits;
+       /* Configure pins before deasserting CS */
+       sh_msiof_spi_set_pin_regs(p, !!(spi->mode & SPI_CPOL),
+                                 !!(spi->mode & SPI_CPHA),
+                                 !!(spi->mode & SPI_3WIRE),
+                                 !!(spi->mode & SPI_LSB_FIRST),
+                                 !!(spi->mode & SPI_CS_HIGH));
+
+       if (spi->cs_gpio >= 0)
+               gpio_set_value(spi->cs_gpio, !(spi->mode & SPI_CS_HIGH));
+
+       return 0;
 }
 
-static unsigned long sh_msiof_spi_hz(struct spi_device *spi,
-                                    struct spi_transfer *t)
+static int sh_msiof_prepare_message(struct spi_master *master,
+                                   struct spi_message *msg)
 {
-       unsigned long hz;
-
-       hz = t ? t->speed_hz : 0;
-       if (!hz)
-               hz = spi->max_speed_hz;
-       return hz;
+       struct sh_msiof_spi_priv *p = spi_master_get_devdata(master);
+       const struct spi_device *spi = msg->spi;
+
+       /* Configure pins before asserting CS */
+       sh_msiof_spi_set_pin_regs(p, !!(spi->mode & SPI_CPOL),
+                                 !!(spi->mode & SPI_CPHA),
+                                 !!(spi->mode & SPI_3WIRE),
+                                 !!(spi->mode & SPI_LSB_FIRST),
+                                 !!(spi->mode & SPI_CS_HIGH));
+       return 0;
 }
 
-static int sh_msiof_spi_setup_transfer(struct spi_device *spi,
-                                      struct spi_transfer *t)
+static int sh_msiof_spi_start(struct sh_msiof_spi_priv *p, void *rx_buf)
 {
-       int bits;
+       int ret;
 
-       /* noting to check hz values against since parent clock is disabled */
+       /* setup clock and rx/tx signals */
+       ret = sh_msiof_modify_ctr_wait(p, 0, CTR_TSCKE);
+       if (rx_buf && !ret)
+               ret = sh_msiof_modify_ctr_wait(p, 0, CTR_RXE);
+       if (!ret)
+               ret = sh_msiof_modify_ctr_wait(p, 0, CTR_TXE);
 
-       bits = sh_msiof_spi_bits(spi, t);
-       if (bits < 8)
-               return -EINVAL;
-       if (bits > 32)
-               return -EINVAL;
+       /* start by setting frame bit */
+       if (!ret)
+               ret = sh_msiof_modify_ctr_wait(p, 0, CTR_TFSE);
 
-       return spi_bitbang_setup_transfer(spi, t);
+       return ret;
 }
 
-static void sh_msiof_spi_chipselect(struct spi_device *spi, int is_on)
+static int sh_msiof_spi_stop(struct sh_msiof_spi_priv *p, void *rx_buf)
 {
-       struct sh_msiof_spi_priv *p = spi_master_get_devdata(spi->master);
-       int value;
-
-       /* chip select is active low unless SPI_CS_HIGH is set */
-       if (spi->mode & SPI_CS_HIGH)
-               value = (is_on == BITBANG_CS_ACTIVE) ? 1 : 0;
-       else
-               value = (is_on == BITBANG_CS_ACTIVE) ? 0 : 1;
-
-       if (is_on == BITBANG_CS_ACTIVE) {
-               if (!test_and_set_bit(0, &p->flags)) {
-                       pm_runtime_get_sync(&p->pdev->dev);
-                       clk_enable(p->clk);
-               }
-
-               /* Configure pins before asserting CS */
-               sh_msiof_spi_set_pin_regs(p, !!(spi->mode & SPI_CPOL),
-                                         !!(spi->mode & SPI_CPHA),
-                                         !!(spi->mode & SPI_3WIRE),
-                                         !!(spi->mode & SPI_LSB_FIRST),
-                                         !!(spi->mode & SPI_CS_HIGH));
-       }
+       int ret;
 
-       /* use spi->controller data for CS (same strategy as spi_gpio) */
-       gpio_set_value((uintptr_t)spi->controller_data, value);
+       /* shut down frame, rx/tx and clock signals */
+       ret = sh_msiof_modify_ctr_wait(p, CTR_TFSE, 0);
+       if (!ret)
+               ret = sh_msiof_modify_ctr_wait(p, CTR_TXE, 0);
+       if (rx_buf && !ret)
+               ret = sh_msiof_modify_ctr_wait(p, CTR_RXE, 0);
+       if (!ret)
+               ret = sh_msiof_modify_ctr_wait(p, CTR_TSCKE, 0);
 
-       if (is_on == BITBANG_CS_INACTIVE) {
-               if (test_and_clear_bit(0, &p->flags)) {
-                       clk_disable(p->clk);
-                       pm_runtime_put(&p->pdev->dev);
-               }
-       }
+       return ret;
 }
 
 static int sh_msiof_spi_txrx_once(struct sh_msiof_spi_priv *p,
@@ -456,29 +570,32 @@ static int sh_msiof_spi_txrx_once(struct sh_msiof_spi_priv *p,
        /* the fifo contents need shifting */
        fifo_shift = 32 - bits;
 
+       /* default FIFO watermarks for PIO */
+       sh_msiof_write(p, FCTR, 0);
+
        /* setup msiof transfer mode registers */
        sh_msiof_spi_set_mode_regs(p, tx_buf, rx_buf, bits, words);
+       sh_msiof_write(p, IER, IER_TEOFE | IER_REOFE);
 
        /* write tx fifo */
        if (tx_buf)
                tx_fifo(p, tx_buf, words, fifo_shift);
 
-       /* setup clock and rx/tx signals */
-       ret = sh_msiof_modify_ctr_wait(p, 0, CTR_TSCKE);
-       if (rx_buf)
-               ret = ret ? ret : sh_msiof_modify_ctr_wait(p, 0, CTR_RXE);
-       ret = ret ? ret : sh_msiof_modify_ctr_wait(p, 0, CTR_TXE);
-
-       /* start by setting frame bit */
        reinit_completion(&p->done);
-       ret = ret ? ret : sh_msiof_modify_ctr_wait(p, 0, CTR_TFSE);
+
+       ret = sh_msiof_spi_start(p, rx_buf);
        if (ret) {
                dev_err(&p->pdev->dev, "failed to start hardware\n");
-               goto err;
+               goto stop_ier;
        }
 
        /* wait for tx fifo to be emptied / rx fifo to be filled */
-       wait_for_completion(&p->done);
+       ret = wait_for_completion_timeout(&p->done, HZ);
+       if (!ret) {
+               dev_err(&p->pdev->dev, "PIO timeout\n");
+               ret = -ETIMEDOUT;
+               goto stop_reset;
+       }
 
        /* read rx fifo */
        if (rx_buf)
@@ -487,39 +604,248 @@ static int sh_msiof_spi_txrx_once(struct sh_msiof_spi_priv *p,
        /* clear status bits */
        sh_msiof_reset_str(p);
 
-       /* shut down frame, tx/tx and clock signals */
-       ret = sh_msiof_modify_ctr_wait(p, CTR_TFSE, 0);
-       ret = ret ? ret : sh_msiof_modify_ctr_wait(p, CTR_TXE, 0);
-       if (rx_buf)
-               ret = ret ? ret : sh_msiof_modify_ctr_wait(p, CTR_RXE, 0);
-       ret = ret ? ret : sh_msiof_modify_ctr_wait(p, CTR_TSCKE, 0);
+       ret = sh_msiof_spi_stop(p, rx_buf);
        if (ret) {
                dev_err(&p->pdev->dev, "failed to shut down hardware\n");
-               goto err;
+               return ret;
        }
 
        return words;
 
- err:
+stop_reset:
+       sh_msiof_reset_str(p);
+       sh_msiof_spi_stop(p, rx_buf);
+stop_ier:
        sh_msiof_write(p, IER, 0);
        return ret;
 }
 
-static int sh_msiof_spi_txrx(struct spi_device *spi, struct spi_transfer *t)
+static void sh_msiof_dma_complete(void *arg)
 {
-       struct sh_msiof_spi_priv *p = spi_master_get_devdata(spi->master);
+       struct sh_msiof_spi_priv *p = arg;
+
+       sh_msiof_write(p, IER, 0);
+       complete(&p->done);
+}
+
+static int sh_msiof_dma_once(struct sh_msiof_spi_priv *p, const void *tx,
+                            void *rx, unsigned int len)
+{
+       u32 ier_bits = 0;
+       struct dma_async_tx_descriptor *desc_tx = NULL, *desc_rx = NULL;
+       dma_cookie_t cookie;
+       int ret;
+
+       /* First prepare and submit the DMA request(s), as this may fail */
+       if (rx) {
+               ier_bits |= IER_RDREQE | IER_RDMAE;
+               desc_rx = dmaengine_prep_slave_single(p->master->dma_rx,
+                                       p->rx_dma_addr, len, DMA_FROM_DEVICE,
+                                       DMA_PREP_INTERRUPT | DMA_CTRL_ACK);
+               if (!desc_rx)
+                       return -EAGAIN;
+
+               desc_rx->callback = sh_msiof_dma_complete;
+               desc_rx->callback_param = p;
+               cookie = dmaengine_submit(desc_rx);
+               if (dma_submit_error(cookie))
+                       return cookie;
+       }
+
+       if (tx) {
+               ier_bits |= IER_TDREQE | IER_TDMAE;
+               dma_sync_single_for_device(p->master->dma_tx->device->dev,
+                                          p->tx_dma_addr, len, DMA_TO_DEVICE);
+               desc_tx = dmaengine_prep_slave_single(p->master->dma_tx,
+                                       p->tx_dma_addr, len, DMA_TO_DEVICE,
+                                       DMA_PREP_INTERRUPT | DMA_CTRL_ACK);
+               if (!desc_tx) {
+                       ret = -EAGAIN;
+                       goto no_dma_tx;
+               }
+
+               if (rx) {
+                       /* No callback */
+                       desc_tx->callback = NULL;
+               } else {
+                       desc_tx->callback = sh_msiof_dma_complete;
+                       desc_tx->callback_param = p;
+               }
+               cookie = dmaengine_submit(desc_tx);
+               if (dma_submit_error(cookie)) {
+                       ret = cookie;
+                       goto no_dma_tx;
+               }
+       }
+
+       /* 1 stage FIFO watermarks for DMA */
+       sh_msiof_write(p, FCTR, FCTR_TFWM_1 | FCTR_RFWM_1);
+
+       /* setup msiof transfer mode registers (32-bit words) */
+       sh_msiof_spi_set_mode_regs(p, tx, rx, 32, len / 4);
+
+       sh_msiof_write(p, IER, ier_bits);
+
+       reinit_completion(&p->done);
+
+       /* Now start DMA */
+       if (rx)
+               dma_async_issue_pending(p->master->dma_rx);
+       if (tx)
+               dma_async_issue_pending(p->master->dma_tx);
+
+       ret = sh_msiof_spi_start(p, rx);
+       if (ret) {
+               dev_err(&p->pdev->dev, "failed to start hardware\n");
+               goto stop_dma;
+       }
+
+       /* wait for tx fifo to be emptied / rx fifo to be filled */
+       ret = wait_for_completion_timeout(&p->done, HZ);
+       if (!ret) {
+               dev_err(&p->pdev->dev, "DMA timeout\n");
+               ret = -ETIMEDOUT;
+               goto stop_reset;
+       }
+
+       /* clear status bits */
+       sh_msiof_reset_str(p);
+
+       ret = sh_msiof_spi_stop(p, rx);
+       if (ret) {
+               dev_err(&p->pdev->dev, "failed to shut down hardware\n");
+               return ret;
+       }
+
+       if (rx)
+               dma_sync_single_for_cpu(p->master->dma_rx->device->dev,
+                                       p->rx_dma_addr, len,
+                                       DMA_FROM_DEVICE);
+
+       return 0;
+
+stop_reset:
+       sh_msiof_reset_str(p);
+       sh_msiof_spi_stop(p, rx);
+stop_dma:
+       if (tx)
+               dmaengine_terminate_all(p->master->dma_tx);
+no_dma_tx:
+       if (rx)
+               dmaengine_terminate_all(p->master->dma_rx);
+       sh_msiof_write(p, IER, 0);
+       return ret;
+}
+
+static void copy_bswap32(u32 *dst, const u32 *src, unsigned int words)
+{
+       /* src or dst can be unaligned, but not both */
+       if ((unsigned long)src & 3) {
+               while (words--) {
+                       *dst++ = swab32(get_unaligned(src));
+                       src++;
+               }
+       } else if ((unsigned long)dst & 3) {
+               while (words--) {
+                       put_unaligned(swab32(*src++), dst);
+                       dst++;
+               }
+       } else {
+               while (words--)
+                       *dst++ = swab32(*src++);
+       }
+}
+
+static void copy_wswap32(u32 *dst, const u32 *src, unsigned int words)
+{
+       /* src or dst can be unaligned, but not both */
+       if ((unsigned long)src & 3) {
+               while (words--) {
+                       *dst++ = swahw32(get_unaligned(src));
+                       src++;
+               }
+       } else if ((unsigned long)dst & 3) {
+               while (words--) {
+                       put_unaligned(swahw32(*src++), dst);
+                       dst++;
+               }
+       } else {
+               while (words--)
+                       *dst++ = swahw32(*src++);
+       }
+}
+
+static void copy_plain32(u32 *dst, const u32 *src, unsigned int words)
+{
+       memcpy(dst, src, words * 4);
+}
+
+static int sh_msiof_transfer_one(struct spi_master *master,
+                                struct spi_device *spi,
+                                struct spi_transfer *t)
+{
+       struct sh_msiof_spi_priv *p = spi_master_get_devdata(master);
+       void (*copy32)(u32 *, const u32 *, unsigned int);
        void (*tx_fifo)(struct sh_msiof_spi_priv *, const void *, int, int);
        void (*rx_fifo)(struct sh_msiof_spi_priv *, void *, int, int);
-       int bits;
-       int bytes_per_word;
-       int bytes_done;
-       int words;
+       const void *tx_buf = t->tx_buf;
+       void *rx_buf = t->rx_buf;
+       unsigned int len = t->len;
+       unsigned int bits = t->bits_per_word;
+       unsigned int bytes_per_word;
+       unsigned int words;
        int n;
        bool swab;
+       int ret;
+
+       /* setup clocks (clock already enabled in chipselect()) */
+       sh_msiof_spi_set_clk_regs(p, clk_get_rate(p->clk), t->speed_hz);
+
+       while (master->dma_tx && len > 15) {
+               /*
+                *  DMA supports 32-bit words only, hence pack 8-bit and 16-bit
+                *  words, with byte resp. word swapping.
+                */
+               unsigned int l = min(len, MAX_WDLEN * 4);
+
+               if (bits <= 8) {
+                       if (l & 3)
+                               break;
+                       copy32 = copy_bswap32;
+               } else if (bits <= 16) {
+                       if (l & 1)
+                               break;
+                       copy32 = copy_wswap32;
+               } else {
+                       copy32 = copy_plain32;
+               }
+
+               if (tx_buf)
+                       copy32(p->tx_dma_page, tx_buf, l / 4);
 
-       bits = sh_msiof_spi_bits(spi, t);
+               ret = sh_msiof_dma_once(p, tx_buf, rx_buf, l);
+               if (ret == -EAGAIN) {
+                       pr_warn_once("%s %s: DMA not available, falling back to PIO\n",
+                                    dev_driver_string(&p->pdev->dev),
+                                    dev_name(&p->pdev->dev));
+                       break;
+               }
+               if (ret)
+                       return ret;
+
+               if (rx_buf) {
+                       copy32(rx_buf, p->rx_dma_page, l / 4);
+                       rx_buf += l;
+               }
+               if (tx_buf)
+                       tx_buf += l;
+
+               len -= l;
+               if (!len)
+                       return 0;
+       }
 
-       if (bits <= 8 && t->len > 15 && !(t->len & 3)) {
+       if (bits <= 8 && len > 15 && !(len & 3)) {
                bits = 32;
                swab = true;
        } else {
@@ -533,83 +859,92 @@ static int sh_msiof_spi_txrx(struct spi_device *spi, struct spi_transfer *t)
                rx_fifo = sh_msiof_spi_read_fifo_8;
        } else if (bits <= 16) {
                bytes_per_word = 2;
-               if ((unsigned long)t->tx_buf & 0x01)
+               if ((unsigned long)tx_buf & 0x01)
                        tx_fifo = sh_msiof_spi_write_fifo_16u;
                else
                        tx_fifo = sh_msiof_spi_write_fifo_16;
 
-               if ((unsigned long)t->rx_buf & 0x01)
+               if ((unsigned long)rx_buf & 0x01)
                        rx_fifo = sh_msiof_spi_read_fifo_16u;
                else
                        rx_fifo = sh_msiof_spi_read_fifo_16;
        } else if (swab) {
                bytes_per_word = 4;
-               if ((unsigned long)t->tx_buf & 0x03)
+               if ((unsigned long)tx_buf & 0x03)
                        tx_fifo = sh_msiof_spi_write_fifo_s32u;
                else
                        tx_fifo = sh_msiof_spi_write_fifo_s32;
 
-               if ((unsigned long)t->rx_buf & 0x03)
+               if ((unsigned long)rx_buf & 0x03)
                        rx_fifo = sh_msiof_spi_read_fifo_s32u;
                else
                        rx_fifo = sh_msiof_spi_read_fifo_s32;
        } else {
                bytes_per_word = 4;
-               if ((unsigned long)t->tx_buf & 0x03)
+               if ((unsigned long)tx_buf & 0x03)
                        tx_fifo = sh_msiof_spi_write_fifo_32u;
                else
                        tx_fifo = sh_msiof_spi_write_fifo_32;
 
-               if ((unsigned long)t->rx_buf & 0x03)
+               if ((unsigned long)rx_buf & 0x03)
                        rx_fifo = sh_msiof_spi_read_fifo_32u;
                else
                        rx_fifo = sh_msiof_spi_read_fifo_32;
        }
 
-       /* setup clocks (clock already enabled in chipselect()) */
-       sh_msiof_spi_set_clk_regs(p, clk_get_rate(p->clk),
-                                 sh_msiof_spi_hz(spi, t));
-
        /* transfer in fifo sized chunks */
-       words = t->len / bytes_per_word;
-       bytes_done = 0;
-
-       while (bytes_done < t->len) {
-               void *rx_buf = t->rx_buf ? t->rx_buf + bytes_done : NULL;
-               const void *tx_buf = t->tx_buf ? t->tx_buf + bytes_done : NULL;
-               n = sh_msiof_spi_txrx_once(p, tx_fifo, rx_fifo,
-                                          tx_buf,
-                                          rx_buf,
+       words = len / bytes_per_word;
+
+       while (words > 0) {
+               n = sh_msiof_spi_txrx_once(p, tx_fifo, rx_fifo, tx_buf, rx_buf,
                                           words, bits);
                if (n < 0)
-                       break;
+                       return n;
 
-               bytes_done += n * bytes_per_word;
+               if (tx_buf)
+                       tx_buf += n * bytes_per_word;
+               if (rx_buf)
+                       rx_buf += n * bytes_per_word;
                words -= n;
        }
 
-       return bytes_done;
-}
-
-static u32 sh_msiof_spi_txrx_word(struct spi_device *spi, unsigned nsecs,
-                                 u32 word, u8 bits)
-{
-       BUG(); /* unused but needed by bitbang code */
        return 0;
 }
 
+static const struct sh_msiof_chipdata sh_data = {
+       .tx_fifo_size = 64,
+       .rx_fifo_size = 64,
+       .master_flags = 0,
+};
+
+static const struct sh_msiof_chipdata r8a779x_data = {
+       .tx_fifo_size = 64,
+       .rx_fifo_size = 256,
+       .master_flags = SPI_MASTER_MUST_TX,
+};
+
+static const struct of_device_id sh_msiof_match[] = {
+       { .compatible = "renesas,sh-msiof",        .data = &sh_data },
+       { .compatible = "renesas,sh-mobile-msiof", .data = &sh_data },
+       { .compatible = "renesas,msiof-r8a7790",   .data = &r8a779x_data },
+       { .compatible = "renesas,msiof-r8a7791",   .data = &r8a779x_data },
+       { .compatible = "renesas,msiof-r8a7792",   .data = &r8a779x_data },
+       { .compatible = "renesas,msiof-r8a7793",   .data = &r8a779x_data },
+       { .compatible = "renesas,msiof-r8a7794",   .data = &r8a779x_data },
+       {},
+};
+MODULE_DEVICE_TABLE(of, sh_msiof_match);
+
 #ifdef CONFIG_OF
 static struct sh_msiof_spi_info *sh_msiof_spi_parse_dt(struct device *dev)
 {
        struct sh_msiof_spi_info *info;
        struct device_node *np = dev->of_node;
-       u32 num_cs = 0;
+       u32 num_cs = 1;
 
        info = devm_kzalloc(dev, sizeof(struct sh_msiof_spi_info), GFP_KERNEL);
-       if (!info) {
-               dev_err(dev, "failed to allocate setup data\n");
+       if (!info)
                return NULL;
-       }
 
        /* Parse the MSIOF properties */
        of_property_read_u32(np, "num-cs", &num_cs);
@@ -629,10 +964,147 @@ static struct sh_msiof_spi_info *sh_msiof_spi_parse_dt(struct device *dev)
 }
 #endif
 
+static struct dma_chan *sh_msiof_request_dma_chan(struct device *dev,
+       enum dma_transfer_direction dir, unsigned int id, dma_addr_t port_addr)
+{
+       dma_cap_mask_t mask;
+       struct dma_chan *chan;
+       struct dma_slave_config cfg;
+       int ret;
+
+       dma_cap_zero(mask);
+       dma_cap_set(DMA_SLAVE, mask);
+
+       chan = dma_request_slave_channel_compat(mask, shdma_chan_filter,
+                               (void *)(unsigned long)id, dev,
+                               dir == DMA_MEM_TO_DEV ? "tx" : "rx");
+       if (!chan) {
+               dev_warn(dev, "dma_request_slave_channel_compat failed\n");
+               return NULL;
+       }
+
+       memset(&cfg, 0, sizeof(cfg));
+       cfg.slave_id = id;
+       cfg.direction = dir;
+       if (dir == DMA_MEM_TO_DEV) {
+               cfg.dst_addr = port_addr;
+               cfg.dst_addr_width = DMA_SLAVE_BUSWIDTH_4_BYTES;
+       } else {
+               cfg.src_addr = port_addr;
+               cfg.src_addr_width = DMA_SLAVE_BUSWIDTH_4_BYTES;
+       }
+
+       ret = dmaengine_slave_config(chan, &cfg);
+       if (ret) {
+               dev_warn(dev, "dmaengine_slave_config failed %d\n", ret);
+               dma_release_channel(chan);
+               return NULL;
+       }
+
+       return chan;
+}
+
+static int sh_msiof_request_dma(struct sh_msiof_spi_priv *p)
+{
+       struct platform_device *pdev = p->pdev;
+       struct device *dev = &pdev->dev;
+       const struct sh_msiof_spi_info *info = dev_get_platdata(dev);
+       unsigned int dma_tx_id, dma_rx_id;
+       const struct resource *res;
+       struct spi_master *master;
+       struct device *tx_dev, *rx_dev;
+
+       if (dev->of_node) {
+               /* In the OF case we will get the slave IDs from the DT */
+               dma_tx_id = 0;
+               dma_rx_id = 0;
+       } else if (info && info->dma_tx_id && info->dma_rx_id) {
+               dma_tx_id = info->dma_tx_id;
+               dma_rx_id = info->dma_rx_id;
+       } else {
+               /* The driver assumes no error */
+               return 0;
+       }
+
+       /* The DMA engine uses the second register set, if present */
+       res = platform_get_resource(pdev, IORESOURCE_MEM, 1);
+       if (!res)
+               res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
+
+       master = p->master;
+       master->dma_tx = sh_msiof_request_dma_chan(dev, DMA_MEM_TO_DEV,
+                                                  dma_tx_id,
+                                                  res->start + TFDR);
+       if (!master->dma_tx)
+               return -ENODEV;
+
+       master->dma_rx = sh_msiof_request_dma_chan(dev, DMA_DEV_TO_MEM,
+                                                  dma_rx_id,
+                                                  res->start + RFDR);
+       if (!master->dma_rx)
+               goto free_tx_chan;
+
+       p->tx_dma_page = (void *)__get_free_page(GFP_KERNEL | GFP_DMA);
+       if (!p->tx_dma_page)
+               goto free_rx_chan;
+
+       p->rx_dma_page = (void *)__get_free_page(GFP_KERNEL | GFP_DMA);
+       if (!p->rx_dma_page)
+               goto free_tx_page;
+
+       tx_dev = master->dma_tx->device->dev;
+       p->tx_dma_addr = dma_map_single(tx_dev, p->tx_dma_page, PAGE_SIZE,
+                                       DMA_TO_DEVICE);
+       if (dma_mapping_error(tx_dev, p->tx_dma_addr))
+               goto free_rx_page;
+
+       rx_dev = master->dma_rx->device->dev;
+       p->rx_dma_addr = dma_map_single(rx_dev, p->rx_dma_page, PAGE_SIZE,
+                                       DMA_FROM_DEVICE);
+       if (dma_mapping_error(rx_dev, p->rx_dma_addr))
+               goto unmap_tx_page;
+
+       dev_info(dev, "DMA available");
+       return 0;
+
+unmap_tx_page:
+       dma_unmap_single(tx_dev, p->tx_dma_addr, PAGE_SIZE, DMA_TO_DEVICE);
+free_rx_page:
+       free_page((unsigned long)p->rx_dma_page);
+free_tx_page:
+       free_page((unsigned long)p->tx_dma_page);
+free_rx_chan:
+       dma_release_channel(master->dma_rx);
+free_tx_chan:
+       dma_release_channel(master->dma_tx);
+       master->dma_tx = NULL;
+       return -ENODEV;
+}
+
+static void sh_msiof_release_dma(struct sh_msiof_spi_priv *p)
+{
+       struct spi_master *master = p->master;
+       struct device *dev;
+
+       if (!master->dma_tx)
+               return;
+
+       dev = &p->pdev->dev;
+       dma_unmap_single(master->dma_rx->device->dev, p->rx_dma_addr,
+                        PAGE_SIZE, DMA_FROM_DEVICE);
+       dma_unmap_single(master->dma_tx->device->dev, p->tx_dma_addr,
+                        PAGE_SIZE, DMA_TO_DEVICE);
+       free_page((unsigned long)p->rx_dma_page);
+       free_page((unsigned long)p->tx_dma_page);
+       dma_release_channel(master->dma_rx);
+       dma_release_channel(master->dma_tx);
+}
+
 static int sh_msiof_spi_probe(struct platform_device *pdev)
 {
        struct resource *r;
        struct spi_master *master;
+       const struct of_device_id *of_id;
        struct sh_msiof_spi_priv *p;
        int i;
        int ret;
@@ -646,10 +1118,16 @@ static int sh_msiof_spi_probe(struct platform_device *pdev)
        p = spi_master_get_devdata(master);
 
        platform_set_drvdata(pdev, p);
-       if (pdev->dev.of_node)
+       p->master = master;
+
+       of_id = of_match_device(sh_msiof_match, &pdev->dev);
+       if (of_id) {
+               p->chipdata = of_id->data;
                p->info = sh_msiof_spi_parse_dt(&pdev->dev);
-       else
+       } else {
+               p->chipdata = (const void *)pdev->id_entry->driver_data;
                p->info = dev_get_platdata(&pdev->dev);
+       }
 
        if (!p->info) {
                dev_err(&pdev->dev, "failed to obtain device info\n");
@@ -687,49 +1165,45 @@ static int sh_msiof_spi_probe(struct platform_device *pdev)
                goto err1;
        }
 
-       ret = clk_prepare(p->clk);
-       if (ret < 0) {
-               dev_err(&pdev->dev, "unable to prepare clock\n");
-               goto err1;
-       }
-
        p->pdev = pdev;
        pm_runtime_enable(&pdev->dev);
 
-       /* The standard version of MSIOF use 64 word FIFOs */
-       p->tx_fifo_size = 64;
-       p->rx_fifo_size = 64;
-
        /* Platform data may override FIFO sizes */
+       p->tx_fifo_size = p->chipdata->tx_fifo_size;
+       p->rx_fifo_size = p->chipdata->rx_fifo_size;
        if (p->info->tx_fifo_override)
                p->tx_fifo_size = p->info->tx_fifo_override;
        if (p->info->rx_fifo_override)
                p->rx_fifo_size = p->info->rx_fifo_override;
 
-       /* init master and bitbang code */
+       /* init master code */
        master->mode_bits = SPI_CPOL | SPI_CPHA | SPI_CS_HIGH;
        master->mode_bits |= SPI_LSB_FIRST | SPI_3WIRE;
-       master->flags = 0;
+       master->flags = p->chipdata->master_flags;
        master->bus_num = pdev->id;
+       master->dev.of_node = pdev->dev.of_node;
        master->num_chipselect = p->info->num_chipselect;
-       master->setup = spi_bitbang_setup;
-       master->cleanup = spi_bitbang_cleanup;
-
-       p->bitbang.master = master;
-       p->bitbang.chipselect = sh_msiof_spi_chipselect;
-       p->bitbang.setup_transfer = sh_msiof_spi_setup_transfer;
-       p->bitbang.txrx_bufs = sh_msiof_spi_txrx;
-       p->bitbang.txrx_word[SPI_MODE_0] = sh_msiof_spi_txrx_word;
-       p->bitbang.txrx_word[SPI_MODE_1] = sh_msiof_spi_txrx_word;
-       p->bitbang.txrx_word[SPI_MODE_2] = sh_msiof_spi_txrx_word;
-       p->bitbang.txrx_word[SPI_MODE_3] = sh_msiof_spi_txrx_word;
-
-       ret = spi_bitbang_start(&p->bitbang);
-       if (ret == 0)
-               return 0;
+       master->setup = sh_msiof_spi_setup;
+       master->prepare_message = sh_msiof_prepare_message;
+       master->bits_per_word_mask = SPI_BPW_RANGE_MASK(8, 32);
+       master->auto_runtime_pm = true;
+       master->transfer_one = sh_msiof_transfer_one;
+
+       ret = sh_msiof_request_dma(p);
+       if (ret < 0)
+               dev_warn(&pdev->dev, "DMA not available, using PIO\n");
+
+       ret = devm_spi_register_master(&pdev->dev, master);
+       if (ret < 0) {
+               dev_err(&pdev->dev, "spi_register_master error.\n");
+               goto err2;
+       }
 
+       return 0;
+
+ err2:
+       sh_msiof_release_dma(p);
        pm_runtime_disable(&pdev->dev);
-       clk_unprepare(p->clk);
  err1:
        spi_master_put(master);
        return ret;
@@ -738,29 +1212,27 @@ static int sh_msiof_spi_probe(struct platform_device *pdev)
 static int sh_msiof_spi_remove(struct platform_device *pdev)
 {
        struct sh_msiof_spi_priv *p = platform_get_drvdata(pdev);
-       int ret;
 
-       ret = spi_bitbang_stop(&p->bitbang);
-       if (!ret) {
-               pm_runtime_disable(&pdev->dev);
-               clk_unprepare(p->clk);
-               spi_master_put(p->bitbang.master);
-       }
-       return ret;
+       sh_msiof_release_dma(p);
+       pm_runtime_disable(&pdev->dev);
+       return 0;
 }
 
-#ifdef CONFIG_OF
-static const struct of_device_id sh_msiof_match[] = {
-       { .compatible = "renesas,sh-msiof", },
-       { .compatible = "renesas,sh-mobile-msiof", },
+static struct platform_device_id spi_driver_ids[] = {
+       { "spi_sh_msiof",       (kernel_ulong_t)&sh_data },
+       { "spi_r8a7790_msiof",  (kernel_ulong_t)&r8a779x_data },
+       { "spi_r8a7791_msiof",  (kernel_ulong_t)&r8a779x_data },
+       { "spi_r8a7792_msiof",  (kernel_ulong_t)&r8a779x_data },
+       { "spi_r8a7793_msiof",  (kernel_ulong_t)&r8a779x_data },
+       { "spi_r8a7794_msiof",  (kernel_ulong_t)&r8a779x_data },
        {},
 };
-MODULE_DEVICE_TABLE(of, sh_msiof_match);
-#endif
+MODULE_DEVICE_TABLE(platform, spi_driver_ids);
 
 static struct platform_driver sh_msiof_spi_drv = {
        .probe          = sh_msiof_spi_probe,
        .remove         = sh_msiof_spi_remove,
+       .id_table       = spi_driver_ids,
        .driver         = {
                .name           = "spi_sh_msiof",
                .owner          = THIS_MODULE,
index 38eb24d..85c2efd 100644 (file)
@@ -14,7 +14,6 @@
  */
 
 #include <linux/kernel.h>
-#include <linux/init.h>
 #include <linux/delay.h>
 #include <linux/spinlock.h>
 #include <linux/workqueue.h>
index 413c718..3f61bbf 100644 (file)
@@ -23,7 +23,6 @@
 #include <linux/dma-mapping.h>
 #include <linux/dmapool.h>
 #include <linux/err.h>
-#include <linux/init.h>
 #include <linux/interrupt.h>
 #include <linux/io.h>
 #include <linux/kernel.h>
index 0879497..18037ab 100644 (file)
@@ -22,7 +22,6 @@
 #include <linux/completion.h>
 #include <linux/delay.h>
 #include <linux/err.h>
-#include <linux/init.h>
 #include <linux/interrupt.h>
 #include <linux/io.h>
 #include <linux/kernel.h>
index be3a069..8d62710 100644 (file)
@@ -23,7 +23,6 @@
 #include <linux/dma-mapping.h>
 #include <linux/dmapool.h>
 #include <linux/err.h>
-#include <linux/init.h>
 #include <linux/interrupt.h>
 #include <linux/io.h>
 #include <linux/kernel.h>
index 24c40b1..350a76b 100644 (file)
@@ -8,7 +8,6 @@
  */
 
 #include <linux/kernel.h>
-#include <linux/init.h>
 #include <linux/module.h>
 #include <linux/delay.h>
 #include <linux/i2c.h>
index 6d4ce46..e6cd111 100644 (file)
@@ -14,7 +14,6 @@
  */
 
 #include <linux/module.h>
-#include <linux/init.h>
 #include <linux/interrupt.h>
 #include <linux/of.h>
 #include <linux/platform_device.h>
index fbf3b22..caa658f 100644 (file)
@@ -24,6 +24,8 @@
 #include <linux/device.h>
 #include <linux/init.h>
 #include <linux/cache.h>
+#include <linux/dma-mapping.h>
+#include <linux/dmaengine.h>
 #include <linux/mutex.h>
 #include <linux/of_device.h>
 #include <linux/of_irq.h>
@@ -580,6 +582,169 @@ static void spi_set_cs(struct spi_device *spi, bool enable)
                spi->master->set_cs(spi, !enable);
 }
 
+static int spi_map_buf(struct spi_master *master, struct device *dev,
+                      struct sg_table *sgt, void *buf, size_t len,
+                      enum dma_data_direction dir)
+{
+       const bool vmalloced_buf = is_vmalloc_addr(buf);
+       const int desc_len = vmalloced_buf ? PAGE_SIZE : master->max_dma_len;
+       const int sgs = DIV_ROUND_UP(len, desc_len);
+       struct page *vm_page;
+       void *sg_buf;
+       size_t min;
+       int i, ret;
+
+       ret = sg_alloc_table(sgt, sgs, GFP_KERNEL);
+       if (ret != 0)
+               return ret;
+
+       for (i = 0; i < sgs; i++) {
+               min = min_t(size_t, len, desc_len);
+
+               if (vmalloced_buf) {
+                       vm_page = vmalloc_to_page(buf);
+                       if (!vm_page) {
+                               sg_free_table(sgt);
+                               return -ENOMEM;
+                       }
+                       sg_buf = page_address(vm_page) +
+                               ((size_t)buf & ~PAGE_MASK);
+               } else {
+                       sg_buf = buf;
+               }
+
+               sg_set_buf(&sgt->sgl[i], sg_buf, min);
+
+               buf += min;
+               len -= min;
+       }
+
+       ret = dma_map_sg(dev, sgt->sgl, sgt->nents, dir);
+       if (ret < 0) {
+               sg_free_table(sgt);
+               return ret;
+       }
+
+       sgt->nents = ret;
+
+       return 0;
+}
+
+static void spi_unmap_buf(struct spi_master *master, struct device *dev,
+                         struct sg_table *sgt, enum dma_data_direction dir)
+{
+       if (sgt->orig_nents) {
+               dma_unmap_sg(dev, sgt->sgl, sgt->orig_nents, dir);
+               sg_free_table(sgt);
+       }
+}
+
+static int spi_map_msg(struct spi_master *master, struct spi_message *msg)
+{
+       struct device *tx_dev, *rx_dev;
+       struct spi_transfer *xfer;
+       void *tmp;
+       size_t max_tx, max_rx;
+       int ret;
+
+       if (master->flags & (SPI_MASTER_MUST_RX | SPI_MASTER_MUST_TX)) {
+               max_tx = 0;
+               max_rx = 0;
+
+               list_for_each_entry(xfer, &msg->transfers, transfer_list) {
+                       if ((master->flags & SPI_MASTER_MUST_TX) &&
+                           !xfer->tx_buf)
+                               max_tx = max(xfer->len, max_tx);
+                       if ((master->flags & SPI_MASTER_MUST_RX) &&
+                           !xfer->rx_buf)
+                               max_rx = max(xfer->len, max_rx);
+               }
+
+               if (max_tx) {
+                       tmp = krealloc(master->dummy_tx, max_tx,
+                                      GFP_KERNEL | GFP_DMA);
+                       if (!tmp)
+                               return -ENOMEM;
+                       master->dummy_tx = tmp;
+                       memset(tmp, 0, max_tx);
+               }
+
+               if (max_rx) {
+                       tmp = krealloc(master->dummy_rx, max_rx,
+                                      GFP_KERNEL | GFP_DMA);
+                       if (!tmp)
+                               return -ENOMEM;
+                       master->dummy_rx = tmp;
+               }
+
+               if (max_tx || max_rx) {
+                       list_for_each_entry(xfer, &msg->transfers,
+                                           transfer_list) {
+                               if (!xfer->tx_buf)
+                                       xfer->tx_buf = master->dummy_tx;
+                               if (!xfer->rx_buf)
+                                       xfer->rx_buf = master->dummy_rx;
+                       }
+               }
+       }
+
+       if (!master->can_dma)
+               return 0;
+
+       tx_dev = &master->dma_tx->dev->device;
+       rx_dev = &master->dma_rx->dev->device;
+
+       list_for_each_entry(xfer, &msg->transfers, transfer_list) {
+               if (!master->can_dma(master, msg->spi, xfer))
+                       continue;
+
+               if (xfer->tx_buf != NULL) {
+                       ret = spi_map_buf(master, tx_dev, &xfer->tx_sg,
+                                         (void *)xfer->tx_buf, xfer->len,
+                                         DMA_TO_DEVICE);
+                       if (ret != 0)
+                               return ret;
+               }
+
+               if (xfer->rx_buf != NULL) {
+                       ret = spi_map_buf(master, rx_dev, &xfer->rx_sg,
+                                         xfer->rx_buf, xfer->len,
+                                         DMA_FROM_DEVICE);
+                       if (ret != 0) {
+                               spi_unmap_buf(master, tx_dev, &xfer->tx_sg,
+                                             DMA_TO_DEVICE);
+                               return ret;
+                       }
+               }
+       }
+
+       master->cur_msg_mapped = true;
+
+       return 0;
+}
+
+static int spi_unmap_msg(struct spi_master *master, struct spi_message *msg)
+{
+       struct spi_transfer *xfer;
+       struct device *tx_dev, *rx_dev;
+
+       if (!master->cur_msg_mapped || !master->can_dma)
+               return 0;
+
+       tx_dev = &master->dma_tx->dev->device;
+       rx_dev = &master->dma_rx->dev->device;
+
+       list_for_each_entry(xfer, &msg->transfers, transfer_list) {
+               if (!master->can_dma(master, msg->spi, xfer))
+                       continue;
+
+               spi_unmap_buf(master, rx_dev, &xfer->rx_sg, DMA_FROM_DEVICE);
+               spi_unmap_buf(master, tx_dev, &xfer->tx_sg, DMA_TO_DEVICE);
+       }
+
+       return 0;
+}
+
 /*
  * spi_transfer_one_message - Default implementation of transfer_one_message()
  *
@@ -686,6 +851,10 @@ static void spi_pump_messages(struct kthread_work *work)
                }
                master->busy = false;
                spin_unlock_irqrestore(&master->queue_lock, flags);
+               kfree(master->dummy_rx);
+               master->dummy_rx = NULL;
+               kfree(master->dummy_tx);
+               master->dummy_tx = NULL;
                if (master->unprepare_transfer_hardware &&
                    master->unprepare_transfer_hardware(master))
                        dev_err(&master->dev,
@@ -752,6 +921,13 @@ static void spi_pump_messages(struct kthread_work *work)
                master->cur_msg_prepared = true;
        }
 
+       ret = spi_map_msg(master, master->cur_msg);
+       if (ret) {
+               master->cur_msg->status = ret;
+               spi_finalize_current_message(master);
+               return;
+       }
+
        ret = master->transfer_one_message(master, master->cur_msg);
        if (ret) {
                dev_err(&master->dev,
@@ -839,6 +1015,8 @@ void spi_finalize_current_message(struct spi_master *master)
        queue_kthread_work(&master->kworker, &master->pump_messages);
        spin_unlock_irqrestore(&master->queue_lock, flags);
 
+       spi_unmap_msg(master, mesg);
+
        if (master->cur_msg_prepared && master->unprepare_message) {
                ret = master->unprepare_message(master, mesg);
                if (ret) {
@@ -1061,11 +1239,10 @@ static void of_register_spi_devices(struct spi_master *master)
                                spi->mode |= SPI_TX_QUAD;
                                break;
                        default:
-                               dev_err(&master->dev,
-                                       "spi-tx-bus-width %d not supported\n",
-                                       value);
-                               spi_dev_put(spi);
-                               continue;
+                               dev_warn(&master->dev,
+                                        "spi-tx-bus-width %d not supported\n",
+                                        value);
+                               break;
                        }
                }
 
@@ -1080,11 +1257,10 @@ static void of_register_spi_devices(struct spi_master *master)
                                spi->mode |= SPI_RX_QUAD;
                                break;
                        default:
-                               dev_err(&master->dev,
-                                       "spi-rx-bus-width %d not supported\n",
-                                       value);
-                               spi_dev_put(spi);
-                               continue;
+                               dev_warn(&master->dev,
+                                        "spi-rx-bus-width %d not supported\n",
+                                        value);
+                               break;
                        }
                }
 
@@ -1372,6 +1548,8 @@ int spi_register_master(struct spi_master *master)
        mutex_init(&master->bus_lock_mutex);
        master->bus_lock_flag = 0;
        init_completion(&master->xfer_completion);
+       if (!master->max_dma_len)
+               master->max_dma_len = INT_MAX;
 
        /* register the device, then userspace will see it.
         * registration fails if the bus ID is in use.
index 99375f0..7ab94ac 100644 (file)
@@ -146,4 +146,8 @@ source "drivers/staging/dgnc/Kconfig"
 
 source "drivers/staging/dgap/Kconfig"
 
+source "drivers/staging/lttng/Kconfig"
+
+source "drivers/staging/ktap/Kconfig"
+
 endif # STAGING
index ddc3c4a..a2b53b9 100644 (file)
@@ -65,3 +65,5 @@ obj-$(CONFIG_XILLYBUS)                += xillybus/
 obj-$(CONFIG_DGNC)                     += dgnc/
 obj-$(CONFIG_DGAP)                     += dgap/
 obj-$(CONFIG_MTD_SPINAND_MT29F)        += mt29f_spinand/
+obj-$(CONFIG_LTTNG)            += lttng/
+obj-$(CONFIG_KTAP)              += ktap/
diff --git a/drivers/staging/ktap/Kconfig b/drivers/staging/ktap/Kconfig
new file mode 100644 (file)
index 0000000..6c6cf63
--- /dev/null
@@ -0,0 +1,32 @@
+config KTAP
+       tristate "a programable dynamic tracing tool for Linux"
+       depends on PERF_EVENTS && EVENT_TRACING
+       default n
+       help
+         ktap is a new script-based dynamic tracing tool for Linux,
+         it uses a scripting language and lets users trace the
+         Linux kernel dynamically. ktap is designed to give
+         operational insights with interoperability that allow
+         users to tune, troubleshoot and extend kernel and application.
+         It's similar with Linux Systemtap and Solaris Dtrace.
+
+         ktap have different design principles from Linux mainstream
+         dynamic tracing language in that it's based on bytecode,
+         so it doesn't depend upon GCC, doesn't require compiling
+         kernel module for each script, safe to use in production
+         environment, fulfilling the embedded ecosystem's tracing needs.
+
+         See ktap tutorial for more information:
+             http://www.ktap.org/doc/tutorial.html
+
+config KTAP_FFI
+       tristate "FFI support for ktap"
+       depends on KTAP
+       depends on X86_64
+       default n
+       help
+         This option brings FFI support to ktap. With FFI enabled ktap,
+         users can call into native kernel C function directly in ktap
+         script. Except for a new cdef keyword, this option also adds
+         a ffi module which exports helper functions like ffi.new and
+         ffi.sizeof.
diff --git a/drivers/staging/ktap/Makefile b/drivers/staging/ktap/Makefile
new file mode 100644 (file)
index 0000000..f565438
--- /dev/null
@@ -0,0 +1,203 @@
+
+#
+# Define NO_LIBELF if you do not want libelf dependency (e.g. cross-builds)
+# (this will also disable resolve resolving symbols in DSO functionality)
+#
+# Define FFI if you want to compile ktap with FFI support. By default This
+# toggle is off.
+#
+# Define amalg to enable amalgamation build, This compiles the ktapvm as
+# one huge C file and allows GCC to generate faster and shorter code. Alas,
+# this requires lots of memory during the build.
+# Recommend to use amalgmation build as default.
+amalg = 1
+NO_LIBELF = 1
+# Do not instrument the tracer itself:
+ifdef CONFIG_FUNCTION_TRACER
+ORIG_CFLAGS := $(KBUILD_CFLAGS)
+KBUILD_CFLAGS = $(subst -pg,,$(ORIG_CFLAGS))
+endif
+
+all: mod ktap
+
+INC = include
+RUNTIME = runtime
+
+FFIDIR = $(RUNTIME)/ffi
+KTAP_LIBS = -lpthread
+
+LIB_OBJS += $(RUNTIME)/lib_base.o $(RUNTIME)/lib_kdebug.o $(RUNTIME)/lib_timer.o \
+               $(RUNTIME)/lib_ansi.o
+
+ifndef amalg
+ifdef FFI
+FFI_OBJS += $(FFIDIR)/ffi_call.o $(FFIDIR)/ffi_type.o $(FFIDIR)/ffi_symbol.o \
+    $(FFIDIR)/cdata.o $(FFIDIR)/ffi_util.o
+RUNTIME_OBJS += $(FFI_OBJS)
+LIB_OBJS += $(RUNTIME)/lib_ffi.o
+endif
+RUNTIME_OBJS += $(RUNTIME)/ktap.o $(RUNTIME)/kp_load.o $(RUNTIME)/kp_obj.o \
+               $(RUNTIME)/kp_str.o $(RUNTIME)/kp_tab.o $(RUNTIME)/kp_vm.o \
+               $(RUNTIME)/kp_opcode.o $(RUNTIME)/kp_transport.o \
+               $(LIB_OBJS)
+else
+RUNTIME_OBJS += $(RUNTIME)/kp_amalg.o
+endif
+
+ifdef FFI
+ifeq ($(KBUILD_MODULES), 1)
+ifdef CONFIG_X86_64
+# call_x86_64.o is compiled from call_x86_64.S
+RUNTIME_OBJS += $(FFIDIR)/call_x86_64.o
+else
+$(error ktap FFI only supports x86_64 for now!)
+endif
+endif
+
+
+ccflags-y      += -DCONFIG_KTAP_FFI
+endif
+
+obj-m          += ktapvm.o
+ktapvm-y       := $(RUNTIME_OBJS)
+
+KVERSION ?= $(shell uname -r)
+KERNEL_SRC ?= /lib/modules/$(KVERSION)/build
+PWD := $(shell pwd)
+mod:
+       $(MAKE) -C $(KERNEL_SRC) M=$(PWD) modules
+
+modules_install:
+       $(MAKE) -C $(KERNEL_SRC) M=$(PWD) modules_install
+
+KTAPC_CFLAGS = -Wall -O2
+
+
+# try-cc
+# Usage: option = $(call try-cc, source-to-build, cc-options, msg)
+ifneq ($(V),1)
+TRY_CC_OUTPUT= > /dev/null 2>&1
+endif
+TRY_CC_MSG=echo "    CHK $(3)" 1>&2;
+
+try-cc = $(shell sh -c                                                 \
+         'TMP="/tmp/.$$$$";                                            \
+          $(TRY_CC_MSG)                                                        \
+          echo "$(1)" |                                                        \
+          $(CC) -x c - $(2) -o "$$TMP" $(TRY_CC_OUTPUT) && echo y;     \
+          rm -f "$$TMP"')
+
+
+define SOURCE_LIBELF
+#include <libelf.h>
+
+int main(void)
+{
+        Elf *elf = elf_begin(0, ELF_C_READ, 0);
+        return (long)elf;
+}
+endef
+
+FLAGS_LIBELF = -lelf
+
+ifdef NO_LIBELF
+       KTAPC_CFLAGS += -DNO_LIBELF
+else
+ifneq ($(call try-cc,$(SOURCE_LIBELF),$(FLAGS_LIBELF),libelf),y)
+    $(warning No libelf found, disables symbol resolving, please install elfutils-libelf-devel/libelf-dev);
+    NO_LIBELF := 1
+    KTAPC_CFLAGS += -DNO_LIBELF
+else
+    KTAP_LIBS += -lelf
+endif
+endif
+
+UDIR = userspace
+
+$(UDIR)/lex.o: $(UDIR)/lex.c $(INC)/*
+       $(QUIET_CC)$(CC) $(DEBUGINFO_FLAG) $(KTAPC_CFLAGS) -o $@ -c $<
+$(UDIR)/parser.o: $(UDIR)/parser.c $(INC)/*
+       $(QUIET_CC)$(CC) $(DEBUGINFO_FLAG) $(KTAPC_CFLAGS) -o $@ -c $<
+$(UDIR)/code.o: $(UDIR)/code.c $(INC)/*
+       $(QUIET_CC)$(CC) $(DEBUGINFO_FLAG) $(KTAPC_CFLAGS) -o $@ -c $<
+$(UDIR)/dump.o: $(UDIR)/dump.c $(INC)/*
+       $(QUIET_CC)$(CC) $(DEBUGINFO_FLAG) $(KTAPC_CFLAGS) -o $@ -c $<
+$(UDIR)/main.o: $(UDIR)/main.c $(INC)/*
+       $(QUIET_CC)$(CC) $(DEBUGINFO_FLAG) $(KTAPC_CFLAGS) -o $@ -c $<
+$(UDIR)/util.o: $(UDIR)/util.c $(INC)/*
+       $(QUIET_CC)$(CC) $(DEBUGINFO_FLAG) $(KTAPC_CFLAGS) -o $@ -c $<
+$(UDIR)/ktapio.o: $(UDIR)/ktapio.c $(INC)/*
+       $(QUIET_CC)$(CC) $(DEBUGINFO_FLAG) $(KTAPC_CFLAGS) -o $@ -c $<
+$(UDIR)/eventdef.o: $(UDIR)/eventdef.c $(INC)/*
+       $(QUIET_CC)$(CC) $(DEBUGINFO_FLAG) $(KTAPC_CFLAGS) -o $@ -c $<
+$(UDIR)/kp_opcode.o: $(RUNTIME)/kp_opcode.c $(INC)/*
+       $(QUIET_CC)$(CC) $(DEBUGINFO_FLAG) $(KTAPC_CFLAGS) -o $@ -c $<
+$(UDIR)/kp_tab.o: $(RUNTIME)/kp_tab.c $(INC)/*
+       $(QUIET_CC)$(CC) $(DEBUGINFO_FLAG) $(KTAPC_CFLAGS) -o $@ -c $<
+$(UDIR)/kp_str.o: $(RUNTIME)/kp_str.c $(INC)/*
+       $(QUIET_CC)$(CC) $(DEBUGINFO_FLAG) $(KTAPC_CFLAGS) -o $@ -c $<
+$(UDIR)/kp_obj.o: $(RUNTIME)/kp_obj.c $(INC)/*
+       $(QUIET_CC)$(CC) $(DEBUGINFO_FLAG) $(KTAPC_CFLAGS) -o $@ -c $<
+ifndef NO_LIBELF
+$(UDIR)/symbol.o: $(UDIR)/symbol.c
+       $(QUIET_CC)$(CC) $(DEBUGINFO_FLAG) $(KTAPC_CFLAGS) -o $@ -c $<
+endif
+ifdef FFI
+KTAPC_CFLAGS += -DCONFIG_KTAP_FFI
+$(UDIR)/ffi_type.o: $(RUNTIME)/ffi/ffi_type.c $(INC)/*
+       $(QUIET_CC)$(CC) $(DEBUGINFO_FLAG) $(KTAPC_CFLAGS) -o $@ -c $<
+$(UDIR)/ffi/cparser.o: $(UDIR)/ffi/cparser.c $(INC)/*
+       $(QUIET_CC)$(CC) $(DEBUGINFO_FLAG) $(KTAPC_CFLAGS) -o $@ -c $<
+$(UDIR)/ffi/ctype.o: $(UDIR)/ffi/ctype.c $(INC)/*
+       $(QUIET_CC)$(CC) $(DEBUGINFO_FLAG) $(KTAPC_CFLAGS) -o $@ -c $<
+endif
+
+
+KTAPOBJS =
+KTAPOBJS += $(UDIR)/lex.o
+KTAPOBJS += $(UDIR)/parser.o
+KTAPOBJS += $(UDIR)/code.o
+KTAPOBJS += $(UDIR)/dump.o
+KTAPOBJS += $(UDIR)/main.o
+KTAPOBJS += $(UDIR)/util.o
+KTAPOBJS += $(UDIR)/ktapio.o
+KTAPOBJS += $(UDIR)/eventdef.o
+KTAPOBJS += $(UDIR)/kp_opcode.o
+KTAPOBJS += $(UDIR)/kp_tab.o
+KTAPOBJS += $(UDIR)/kp_str.o
+KTAPOBJS += $(UDIR)/kp_obj.o
+ifndef NO_LIBELF
+KTAPOBJS += $(UDIR)/symbol.o
+endif
+ifdef FFI
+KTAPOBJS += $(UDIR)/ffi_type.o
+KTAPOBJS += $(UDIR)/ffi/cparser.o
+KTAPOBJS += $(UDIR)/ffi/ctype.o
+endif
+
+ktap: $(KTAPOBJS)
+       $(QUIET_LINK)$(CC) $(KTAPC_CFLAGS) -o $@ $(KTAPOBJS) $(KTAP_LIBS)
+
+KMISC := /lib/modules/$(KVERSION)/ktapvm/
+
+install: mod ktap
+       install -d $(KMISC)
+       install -m 644 -c *.ko /lib/modules/$(KVERSION)/ktapvm/
+       /sbin/depmod -a
+
+load:
+       insmod ktapvm.ko
+
+unload:
+       rmmod ktapvm
+
+test: FORCE
+       cd test; sh ./run_test.sh; cd -
+
+clean:
+       $(MAKE) -C $(KERNEL_SRC) M=$(PWD) clean
+       $(RM) ktap
+
+PHONY += FORCE
+FORCE:
+
diff --git a/drivers/staging/ktap/README.md b/drivers/staging/ktap/README.md
new file mode 100644 (file)
index 0000000..82deb4b
--- /dev/null
@@ -0,0 +1,167 @@
+# ktap
+
+A New Scripting Dynamic Tracing Tool For Linux
+[www.ktap.org][homepage]
+
+ktap is a new scripting dynamic tracing tool for Linux,
+it uses a scripting language and lets users trace the Linux kernel dynamically.
+ktap is designed to give operational insights with interoperability
+that allows users to tune, troubleshoot and extend kernel and application.
+It's similar with Linux Systemtap and Solaris Dtrace.
+
+ktap have different design principles from Linux mainstream dynamic tracing
+language in that it's based on bytecode, so it doesn't depend upon GCC,
+doesn't require compiling kernel module for each script, safe to use in
+production environment, fulfilling the embedded ecosystem's tracing needs.
+
+More information can be found at [ktap homepage][homepage].
+
+[homepage]: http://www.ktap.org
+
+## Highlights
+
+  * simple but powerful scripting language
+  * register based interpreter (heavily optimized) in Linux kernel
+  * small and lightweight (6KLOC of interpreter)
+  * not depend on gcc for each script running
+  * easy to use in embedded environment without debugging info
+  * support for tracepoint, kprobe, uprobe, function trace, timer, and more
+  * supported in x86, arm, ppc, mips
+  * safety in sandbox
+
+## Building & Running
+
+1. Clone ktap from github
+
+        $ git clone http://github.com/ktap/ktap.git
+
+2. Compiling ktap
+
+        $ cd ktap
+        $ make       #generate ktapvm kernel module and ktap binary
+
+3. Load ktapvm kernel module(make sure debugfs mounted)
+
+        $ make load  #need to be root or have sudo access
+
+4. Running ktap
+
+        $ ./ktap samples/helloworld.kp
+
+
+## Examples
+
+1. simplest one-liner command to enable all tracepoints
+
+        ktap -e "trace *:* { print(argevent) }"
+
+2. syscall tracing on target process
+
+        ktap -e "trace syscalls:* { print(argevent) }" -- ls
+
+3. ftrace(kernel newer than 3.3, and must compiled with CONFIG_FUNCTION_TRACER)
+
+        ktap -e "trace ftrace:function { print(argevent) }"
+
+        ktap -e "trace ftrace:function /ip==mutex*/ { print(argevent) }"
+
+4. simple syscall tracing
+
+        trace syscalls:* {
+                print(cpu(), pid(), execname(), argevent)
+        }
+
+5. syscall tracing in histogram style
+
+        s = {}
+
+        trace syscalls:sys_enter_* {
+                s[argname] += 1
+        }
+
+        trace_end {
+                histogram(s)
+        }
+
+6. kprobe tracing
+
+        trace probe:do_sys_open dfd=%di fname=%dx flags=%cx mode=+4($stack) {
+                print("entry:", execname(), argevent)
+        }
+
+        trace probe:do_sys_open%return fd=$retval {
+                print("exit:", execname(), argevent)
+        }
+
+7. uprobe tracing
+
+        trace probe:/lib/libc.so.6:malloc {
+                print("entry:", execname(), argevent)
+        }
+
+        trace probe:/lib/libc.so.6:malloc%return {
+                print("exit:", execname(), argevent)
+        }
+
+8. stapsdt tracing (userspace static marker)
+
+        trace sdt:/lib64/libc.so.6:lll_futex_wake {
+                print("lll_futex_wake", execname(), argevent)
+        }
+
+        or:
+
+        #trace all static mark in libc
+        trace sdt:/lib64/libc.so.6:* {
+                print(execname(), argevent)
+        }
+
+9. timer
+
+        tick-1ms {
+                printf("time fired on one cpu\n");
+        }
+
+        profile-2s {
+                printf("time fired on every cpu\n");
+        }
+
+10. FFI (Call kernel function from ktap script, need compile with FFI=1)
+
+        cdef[[
+                int printk(char *fmt, ...);
+        ]]
+
+        C.printk("This message is called from ktap ffi\n")
+
+More examples can be found at [samples][samples_dir] directory.
+
+[samples_dir]: https://github.com/ktap/ktap/tree/master/samples
+
+## Mailing list
+
+ktap@freelists.org
+You can subscribe to ktap mailing list at link (subscribe before posting):
+http://www.freelists.org/list/ktap
+
+
+## Copyright and License
+
+ktap is licensed under GPL v2
+
+Copyright (C) 2012-2013, Jovi Zhangwei <jovi.zhangwei@gmail.com>.
+All rights reserved.
+
+
+## Contribution
+
+ktap is still under active development, so contributions are welcome.
+You are encouraged to report bugs, provide feedback, send feature request,
+or hack on it.
+
+
+## See More
+
+More info can be found at [documentation][tutorial]
+[tutorial]: http://www.ktap.org/doc/tutorial.html
+
diff --git a/drivers/staging/ktap/RELEASES.txt b/drivers/staging/ktap/RELEASES.txt
new file mode 100644 (file)
index 0000000..bdc47dd
--- /dev/null
@@ -0,0 +1,155 @@
+Version 0.4 (Dec 9 2013)
+-------------------------
+= Highlight changes from v0.3
+
+   * kernel symbol read (syntax: `symbol_name`)
+
+   * parse symbol on uprobe (need libelf link)
+        trace probe:/lib64/libc.so.6:malloc {}
+        trace probe:/lib64/libc.so.6:malloc%return {}
+        trace probe:/lib64/libc.so.6:* {} # trace all function in glibc
+
+   * support static marker(SDT)
+        trace sdt:/lib64/libc.so.6:setjmp {}
+        trace sdt:/lib64/libc.so.6:* {} # trace all sdt in glibc
+
+   * support kprobe wildcard
+        trace probe:vfs* {}
+
+   * support run multiple ktap instances concurrently
+
+   * add command option for list available events and symbols
+        -le [glob]     : list pre-defined events in system
+        -lf DSO        : list available functions from DSO
+        -lm DSO        : list available sdt notes from DSO
+
+   * better annotation for output of argname
+
+   * basic FFI support (depend on CONFIG_KTAP_FFI)
+        FFI will allow call kernel function from ktap script
+
+        cdef [[ int printk(char *fmt, ...); ]]
+        C.printk("this is ffi printk from ktap\n")
+
+        (currently only support basic C types, structure support is ongoing)
+
+   * New sample scripts
+        userspace/malloc_size_hist.kp
+        userspace/malloc_free.kp
+        userspace/gcc_unwind.kp
+        userspace/glibc_sdt.kp        #trace all static marker in glibc
+        userspace/glibc_trace.kp      #trace all functions in glibc
+        userspace/glibc_func_hist.kp  #show glibc functions in histogram
+        syscalls/syslatl.kp           #syscall latency linear aggregation
+        syscalls/syslist.kp           #syscall latency as a list with counts
+        syscalls/opensnoop.kp         #trace open() syscalls and print basic details
+        ffi/ffi_kmalloc.kp
+        ffi/printk.kp
+        ffi/sched_clock.kp
+
+   * use amalgamation build as default
+        x86_64 build: ktap binary size is 98K, ktapvm.ko size is 983K
+
+   * Big cleanups and lots of bugfix
+
+
+Version 0.3 (Oct 29 2013)
+-------------------------
+= Highlight changes from v0.2
+
+   * Homepage released: www.ktap.org
+
+   * Tutorial: http://www.ktap.org/doc/tutorial.html
+
+   * Wiki: https://github.com/ktap/ktap/wiki
+
+   * simple new tracing block syntax
+       trace EVENTDEF { action }
+       trace_end { action }
+
+   * New event tracing keywords: argevent, argname, arg1..arg9
+       trace "syscalls:*" function () {
+               print(argevent)
+       }
+
+   * New timer block syntax
+       tick-N { action }
+       profile-N { action }
+
+   * Basic aggregation support
+       It's similar with systemtap, use "<<<" operator
+       support aggregate function: count, sum, avg, max, min
+
+   * Introduce new "+=" operator
+
+   * Introduce sort_paris for table sort iteration
+
+   * New sample scripts
+       helloworld.kp
+       syscalls/sctop.kp
+       profiling/stack_profile.kp
+       io/traceio.kp
+       mem/kmalloc-top.kp
+       syscalls/errinfo.kp
+       schedule/schedtimes.kp
+       game/tetris.kp
+
+   * ansi library for sending ANSI escape sequences
+
+
+   * statistics of ktapvm
+
+   * Big cleanups and lots of bugfix
+
+Version 0.2 (Jul 31 2013)
+-------------------------
+
+= Script highlight changes from v0.1
+
+   * new tracing block syntax
+       trace EVENTDEF function (e) { BODY }
+       trace_end function (e) { BODY }
+
+   * support trace filter
+       trace 'sched:sched_switch /prev_comm == foo || next_comm == foo/
+
+   * support kprobe/kretprobe
+       trace "probe:do_sys_open dfd=%di filename=%dx flags=%cx mode=+4($stack)"
+       trace "probe:do_sys_open%return fd=$retval"
+
+   * support uprobe/uretprobe
+       trace "probe:/lib/libc.so.6:0x000773c0"
+       trace "probe:/lib/libc.so.6:0x000773c0%return"
+
+   * support function tracing
+       trace "ftrace:function /ip == mutex*/"
+
+   * support oneline scripting
+       ktap -e 'trace "syscalls:*" function (e) { print(e) }'
+
+   * specific pid or cpu to tracing
+       ktap -C cpu *.kp
+       ktap -p pid *.kp
+
+   * more sample scripts
+
+   * support calling print_backtrace() in any context
+
+   * support calling exit() in any context
+
+= Backend highlight changes from v0.1
+
+   * unified perf callback mechanism
+   * use ring buffer transport instead of relayfs
+   * reentrant in ktap tracing
+   * performance boost(use percpu data in many case)
+   * safe table/string manipulation
+   * safe ktap exit
+   * big code cleanups
+   * fixed a lot of bugs, more stable than v0.1
+
+Version 0.1 (May 21 2013)
+-------------------------
+
+    https://lwn.net/Articles/551253/
+
diff --git a/drivers/staging/ktap/doc/tutorial.md b/drivers/staging/ktap/doc/tutorial.md
new file mode 100644 (file)
index 0000000..8edce6d
--- /dev/null
@@ -0,0 +1,691 @@
+% The ktap Tutorial
+
+# Introduction
+
+ktap is a new script-based dynamic tracing tool for linux
+http://www.ktap.org
+
+ktap is a new script-based dynamic tracing tool for Linux,
+it uses a scripting language and lets users trace the Linux kernel dynamically.
+ktap is designed to give operational insights with interoperability
+that allows users to tune, troubleshoot and extend kernel and application.
+It's similar with Linux Systemtap and Solaris Dtrace.
+
+ktap have different design principles from Linux mainstream dynamic tracing
+language in that it's based on bytecode, so it doesn't depend upon GCC,
+doesn't require compiling kernel module for each script, safe to use in
+production environment, fulfilling the embedded ecosystem's tracing needs.
+
+Highlights features:
+
+* simple but powerful scripting language
+* register based interpreter (heavily optimized) in Linux kernel
+* small and lightweight
+* not depend on gcc for each script running
+* easy to use in embedded environment without debugging info
+* support for tracepoint, kprobe, uprobe, function trace, timer, and more
+* supported in x86, arm, ppc, mips
+* safety in sandbox
+
+
+# Getting started
+
+Requirements
+
+* Linux 3.1 or later(Need some kernel patches for kernel earlier than 3.1)
+* CONFIG_EVENT_TRACING enabled
+* CONFIG_PERF_EVENTS enabled
+* CONFIG_DEBUG_FS enabled
+     make sure debugfs mounted before insmod ktapvm
+     mount debugfs: mount -t debugfs none /sys/kernel/debug/
+* libelf (optional)
+     Install elfutils-libelf-devel on RHEL-based distros, or libelf-dev on
+     Debian-based distros.
+     Use `make NO_LIBELF=1` to build without libelf support.
+     libelf is required for resolving symbols to addresses in DSO, and for sdt.
+
+Note that those configuration is always enabled in Linux distribution,
+like REHL, Fedora, Ubuntu, etc.
+
+1. Clone ktap from github
+
+        $ git clone http://github.com/ktap/ktap.git
+
+2. Compiling ktap
+
+        $ cd ktap
+        $ make       #generate ktapvm kernel module and ktap binary
+
+3. Load ktapvm kernel module(make sure debugfs mounted)
+
+        $ make load  #need to be root or have sudo access
+
+4. Running ktap
+
+        $ ./ktap scripts/helloworld.kp
+
+
+# Language basics
+
+## Syntax basics
+
+ktap's syntax is design on the mind of C language syntax friendly,
+to make it easy scripting by kernel developer.
+
+1. Variable declaration
+The biggest syntax differences with C is that ktap is a dynamic typed
+language, so you won't need add any variable type declaration, just
+use the variable.
+
+2. function
+All functions in ktap should use keyword "function" declaration
+
+3. comments
+The comments of ktap is starting from '#', long comments doesn't support now.
+
+4. others
+Don't need place any ';' at the ending of statement in ktap.
+ktap use free syntax style, so you can choose to use the ';' or not.
+
+ktap use nil as NULL, the result of any number operate on nil is nil.
+
+ktap don't have array structure, also don't have any pointer operation.
+
+## Control structures
+
+ktap if/else is same as C language.
+
+There have two method of for-loop in ktap:
+
+    for (i = init, limit, step) { body }
+
+this is same as below in C:
+
+    for (i = init; i < limit; i += step) { body }
+
+The next for-loop method is:
+
+    for (k, v in pairs(t)) { body }   # looping all elements of table
+
+Note that ktap don't have "continue" keyword, but C does.
+
+## Date structures
+
+Associative array is heavily used in ktap, it's also called by table.
+
+table declaration:
+
+    t = {}
+
+how to use table:
+
+    t[1] = 1
+    t[1] = "xxx"
+    t["key"] = 10
+    t["key"] = "value"
+
+    for (k, v in pairs(t)) { body }   # looping all elements of table
+
+
+# Built in functions and librarys
+
+## Built in functions
+
+**print (...)**
+Receives any number of arguments, and prints their values,
+print is not intended for formatted output, but only as a
+quick way to show a value, typically for debugging.
+For formatted output, use printf.
+
+**printf (fmt, ...)**
+Similar with C printf, use for format string output.
+
+**pairs (t)**
+Returns three values: the next function, the table t, and nil,
+so that the construction
+for (k,v in pairs(t)) { body }
+will iterate over all key-value pairs of table t.
+
+**len (t) /len (s)**
+If the argument is string, return length of string,
+if the argument is table, return counts of table pairs.
+
+**in_interrupt ()**
+checking is context is interrupt context
+
+**exit ()**
+quit ktap executing, similar with exit syscall
+
+**pid ()**
+return current process pid
+
+**tid ()**
+return current thread id
+
+**uid ()**
+return current process uid
+
+**execname ()**
+return current process exec name string
+
+**cpu ()**
+return current cpu id
+
+**arch ()**
+return machine architecture, like x86, arm, etc.
+
+**kernel_v ()**
+return Linux kernel version string, like 3.9, etc.
+
+**user_string (addr)**
+Receive userspace address, read string from userspace, return string.
+
+**histogram (t)**
+Receive table, output table histogram to user.
+
+**curr_task_info (offset, fetch_bytes)**
+fetch value in field offset of task_struct structure, argument fetch_bytes
+could be 4 or 8, if fetch_bytes is not given, default is 4.
+
+user may need to get field offset by gdb, for example:
+gdb vmlinux
+(gdb)p &(((struct task_struct *)0).prio)
+
+**print_backtrace ()**
+print current task stack info
+
+
+## Librarys
+
+### Kdebug Library
+
+**kdebug.probe_by_id (eventdef_info, eventfun)**
+
+This function is underly representation of high level tracing primitive.
+Note that eventdef_info is just a userspace memory pointer refer to real
+eventdef_info structure, the structure defintion is:
+
+        struct ktap_eventdef_info {
+            int nr; /* the number to id */
+            int *id_arr; /* id array */
+            char *filter;
+        };
+
+Those id is read from /sys/kernel/debug/tracing/events/$SYS/$EVENT/id
+
+The second argument in above examples is a function:
+function eventfun () { action }
+
+
+**kdebug.probe_end (endfunc)**
+
+This function is used for invoking a function when tracing end, it will wait
+until user press CTRL+C to stop tracing, then ktap will call endfunc function,
+user could show tracing results in that function, or do other things.
+
+User don't have to use kdebug library directly, use trace/trace_end keyword.
+
+### Timer Library
+
+
+
+# Linux tracing basics
+
+tracepoints, probe, timer
+filters
+above explaintion
+Ring buffer
+
+# Tracing semantics in ktap
+
+## Tracing block
+
+**trace EVENTDEF /FILTER/ { ACTION }**
+
+This is the basic tracing block for ktap, you need to use a specific EVENTDEF
+string, and own event function.
+
+There have four type of EVENTDEF, tracepoint, kprobe, uprobe, sdt.
+
+- tracepoint:
+
+       EventDef               Description
+       --------------------   -------------------------------
+       syscalls:*             trace all syscalls events
+       syscalls:sys_enter_*   trace all syscalls entry events
+       kmem:*                 trace all kmem related events
+       sched:*                trace all sched related events
+       sched:sched_switch     trace sched_switch tracepoint
+       \*:\*                  trace all tracepoints in system
+
+       All tracepoint events are based on:
+                 /sys/kernel/debug/tracing/events/$SYS/$EVENT
+
+- ftrace(kernel newer than 3.3, and must compiled with CONFIG_FUNCTION_TRACER)
+
+       EventDef               Description
+       --------------------   -------------------------------
+       ftrace:function        trace kernel functions based on ftrace
+
+       User need to use filter (/ip==*/) to trace specfic functions.
+       Function must be listed in /sys/kernel/debug/tracing/available_filter_functions
+
+> ***Note*** of function event
+>
+> perf support ftrace:function tracepoint since Linux 3.3(see below commit),
+> ktap is based on perf callback, so it means kernel must be newer than 3.3
+> then can use this feature.
+>
+>     commit ced39002f5ea736b716ae233fb68b26d59783912
+>     Author: Jiri Olsa <jolsa@redhat.com>
+>     Date:   Wed Feb 15 15:51:52 2012 +0100
+>
+>     ftrace, perf: Add support to use function tracepoint in perf
+>
+
+- kprobe:
+
+       EventDef               Description
+       --------------------   -----------------------------------
+       probe:schedule         trace schedule function
+       probe:schedule%return  trace schedule function return
+       probe:SyS_write        trace SyS_write function
+       probe:vfs*             trace wildcards vfs related function
+
+       kprobe functions must be listed in /proc/kallsyms
+- uprobe:
+
+       EventDef                               Description
+       ------------------------------------   ---------------------------
+       probe:/lib64/libc.so.6:malloc          trace malloc function
+       probe:/lib64/libc.so.6:malloc%return   trace malloc function return
+       probe:/lib64/libc.so.6:free            trace free function
+       probe:/lib64/libc.so.6:0x82000         trace function with file offset 0x82000
+       probe:/lib64/libc.so.6:*               trace all libc function
+
+       symbol resolving need libelf support
+
+- sdt:
+
+       EventDef                               Description
+       ------------------------------------   --------------------------
+       sdt:/libc64/libc.so.6:lll_futex_wake   trace stapsdt lll_futex_wake
+       sdt:/libc64/libc.so.6:*                trace all static markers in libc
+
+       sdt resolving need libelf support
+
+
+**trace_end { ACTION }**
+
+## Tracing built-in variables
+
+**argevent**
+event object, you can print it by: print(argevent), it will print events
+into human readable string, the result is mostly same as each entry of
+/sys/kernel/debug/tracing/trace
+
+**argname**
+event name, each event have a name associated with it.
+
+**arg1..9**
+get argument 1..9 of event object.
+
+> ***Note*** of arg offset
+>
+> The arg offset(1..9) is determined by event format shown in debugfs.
+>
+>     #cat /sys/kernel/debug/tracing/events/sched/sched_switch/format
+>     name: sched_switch
+>     ID: 268
+>     format:
+>         field:char prev_comm[32];         <- arg1
+>         field:pid_t prev_pid;             <- arg2
+>         field:int prev_prio;              <- arg3
+>         field:long prev_state;            <- arg4
+>         field:char next_comm[32];         <- arg5
+>         field:pid_t next_pid;             <- arg6
+>         field:int next_prio;              <- arg7
+>
+> As shown, tracepoint event sched:sched_switch have 7 arguments, from arg1 to
+> arg7.
+>
+> Need to note that arg1 of syscall event is syscall number, not first argument
+> of syscall function. Use arg2 as first argument of syscall function.
+> For example:
+>
+>     SYSCALL_DEFINE3(read, unsigned int, fd, char __user *, buf, size_t, count)
+>                                         <arg2>             <arg3>       <arg4>
+>
+> This is similar with kprobe and uprobe, the arg1 of kprobe/uprobe event
+> always is _probe_ip, not the first argument given by user, for example:
+>
+>     # ktap -e 'trace probe:/lib64/libc.so.6:malloc size=%di'
+>
+>     # cat /sys/kernel/debug/tracing/events/ktap_uprobes_3796/malloc/format
+>         field:unsigned long __probe_ip;   <- arg1
+>         field:u64 size;                   <- arg2
+
+
+## Timer syntax
+
+**tick-Ns        { ACTION }**
+**tick-Nsec      { ACTION }**
+**tick-Nms       { ACTION }**
+**tick-Nmsec     { ACTION }**
+**tick-Nus       { ACTION }**
+**tick-Nusec     { ACTION }**
+
+**profile-Ns     { ACTION }**
+**profile-Nsec   { ACTION }**
+**profile-Nms    { ACTION }**
+**profile-Nmsec  { ACTION }**
+**profile-Nus    { ACTION }**
+**profile-Nusec  { ACTION }**
+
+architecture overview picture reference(pnp format)
+one-liners
+simple event tracing
+
+# Advanced tracing pattern
+
+Aggregation/Histogram
+thread local
+flame graph
+
+# Overhead/Performance
+
+ktap have more fast boot time thant Systemtap(try the helloword script)
+ktap have little memory usage than Systemtap
+and some scripts show that ktap have a little overhead than Systemtap
+(we choosed two scripts to compare, function profile, stack profile.
+this is not means all scripts in Systemtap have big overhead than ktap)
+
+
+# FAQ
+
+**Q: Why use bytecode design?**
+A: Using bytecode would be a clean and lightweight solution,
+   you don't need gcc toolchain to compile every scripts, all you
+   need is a ktapvm kernel modules and userspace tool called ktap.
+   Since its language virtual machine design, it have great portability,
+   suppose you are working at a multi-arch cluster, if you want to run
+   a tracing script on each board, you won't need cross-compile tracing
+   script onto all board, what you really need to do is use ktap tool
+   to run script just in time.
+
+   Bytecode based design also will make executing more safer, than native code
+   generation.
+
+   Reality already showing that SystemTap is not widely used in embedded Linux,
+   caused by problem of SystemTap's architecture design choice, it's a natural
+   design for Redhat and IBM, because Redhat/IBM is focusing on server area,
+   not embedded area.
+
+**Q: What's the differences with SystemTap and Dtrace?**
+A: For SystemTap, the answer is already mentioned at above question,
+   SystemTap use translator design, for trade-off on performance with usability,
+   based on GCC, that's what ktap want to solve.
+
+   For Dtrace, one common design with Dtrace is also use bytecode, so basically
+   Dtrace and ktap is on the same road. There have some projects aim to porting
+   Dtrace from Solaris to Linux, but the process is still on the road, Dtrace
+   is rooted in Solaris, and there have many huge differences between Solaris
+   tracing infrastructure with Linux's.
+
+   Dtrace is based on D language, a language subset of C, it's a restricted
+   language, like without for-looping, for safty use in production system.
+   It seems that Dtrace for Linux only support x86 architecture, not work on
+   powerpc and arm/mips, obviously it's not suit for embedded Linux currently.
+
+   Dtrace use ctf as input for debuginfo handing, compare with vmlinux for
+   SystemTap.
+
+   On the license part, Dtrace is released as CDDL, which is incompatible with
+   GPL(this is why it's impossible to upstream Dtrace into mainline).
+
+**Q: Why use dynamically typed language? but not statically typed language?**
+A: It's hard to say which one is more better than other, dynamically typed
+   language bring efficiency and fast prototype production, but loosing type
+   check at compiling phase, and easy to make mistake in runtime, also it's
+   need many runtime checking, In contrast, statically typed language win on
+   programing safety, and performance. Statically language would suit for
+   interoperate with kernel, as kernel is wrote mainly in C, Need to note that
+   SystemTap and Dtrace both is statically language.
+
+   ktap choose dynamically typed language as initial implementation.
+
+**Q: Why we need ktap for event tracing? There already have a built-in ftrace**
+A: This also is a common question for all dynamic tracing tool, not only ktap.
+   ktap provide more flexibility than built-in tracing infrastructure. Suppose
+   you need print a global variable when tracepoint hit, or you want print
+   backtrace, even more, you want to store some info into associative array, and
+   display it in histogram style when tracing end, in these case, some of them
+   ftrace can take it, some of them ftrace can not.
+   Overall, ktap provide you with great flexibility to scripting your own trace
+   need.
+
+**Q: How about the performance? Is ktap slow?**
+A: ktap is not slow, the bytecode is very high-level, based on lua, the language
+   virtual machine is register-based(compare with stack-based), with little
+   instruction, the table data structure is heavily optimized in ktapvm.
+   ktap use per-cpu allocation in many place, without global locking scheme,
+   it's very fast when executing tracepoint callback.
+   Performance benchmark showing that the overhead of ktap running is nearly
+   10%(store event name into associative array), compare with full speed
+   running without any tracepoint enabled.
+
+   ktap will optimize overhead all the time, hopefully the overhead will
+   decrease to little than 5%, even more.
+
+**Q: Why not porting a high level language implementation into kernel directly?
+   Like python/JVM?**
+A: I take serious on the size of vm and memory footprint. Python vm is large,
+   it's not suit to embed into kernel, and python have some functionality
+   which we don't need.
+
+   The bytecode of other high level language is also big, ktap only have 32
+   bytecodes, python/java/erlang have nearly two hundred bytecodes.
+   There also have some problems when porting those language into kernel,
+   userspace programming have many differences with kernel programming,
+   like float numbers, handle sleeping code carefully in kernel, deadloop is
+   not allowed in kernel, multi-thread management, etc.., so it's impossible
+   to porting language implementation into kernel with little adaption work.
+
+**Q: What's the status of ktap now?**
+A: Basically it works on x86-32, x86-64, powerpc, arm, it also could work for
+   other hardware architecture, but not proven yet(I don't have enough hardware
+   to test)
+   If you found some bug, fix it on you own programming skill, or report to me.
+
+**Q: How to hack ktap? I want to write some extensions onto ktap.**
+A: welcome hacking.
+   You can write your own library to fulfill your specific need,
+   you can write any script as you want.
+
+**Q: What's the plan of ktap? any roadmap?**
+A: the current plan is deliver stable ktapvm kernel modules, more ktap script,
+   and bugfix.
+
+
+# References
+
+* [Linux Performance Analysis and Tools][LPAT]
+* [Dtrace Blog][dtraceblog]
+* [Dtrace User Guide][dug]
+* [LWN: ktap -- yet another kernel tracer][lwn1]
+* [LWN: Ktap almost gets into 3.13][lwn2]
+* [staging: ktap: add to the kernel tree][ktap_commit]
+* [ktap introduction in LinuxCon Japan 2013][lcj](content is out of date)
+* [ktap Examples by Brendan Gregg][KEBG]
+
+[LPAT]: http://www.brendangregg.com/Slides/SCaLE_Linux_Performance2013.pdf
+[dtraceblog]: http://dtrace.org/blogs/
+[dug]: http://docs.huihoo.com/opensolaris/dtrace-user-guide/html/index.html
+[lwn1]: http://lwn.net/Articles/551314/
+[lwn2]: http://lwn.net/Articles/572788/
+[ktap_commit]: https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/commit/?id=c63a164271f81220ff4966d41218a9101f3d0ec4
+[lcj]: http://events.linuxfoundation.org/sites/events/files/lcjpcojp13_zhangwei.pdf
+[KEBG]: http://www.brendangregg.com/ktap.html
+
+# History
+
+* ktap was invented at 2002
+* First RFC sent to LKML at 2012.12.31
+* The code was released in github at 2013.01.18
+* ktap released v0.1 at 2013.05.21
+* ktap released v0.2 at 2013.07.31
+* ktap released v0.3 at 2013.10.29
+
+For more release info, please look at RELEASES.txt in project root directory.
+
+# Examples
+
+1. simplest one-liner command to enable all tracepoints
+
+        ktap -e "trace *:* { print(argevent) }"
+
+2. syscall tracing on target process
+
+        ktap -e "trace syscalls:* { print(argevent) }" -- ls
+
+3. ftrace(kernel newer than 3.3, and must compiled with CONFIG_FUNCTION_TRACER)
+
+        ktap -e "trace ftrace:function { print(argevent) }"
+
+        ktap -e "trace ftrace:function /ip==mutex*/ { print(argevent) }"
+
+4. simple syscall tracing
+
+        trace syscalls:* {
+                print(cpu(), pid(), execname(), argevent)
+        }
+
+5. syscall tracing in histogram style
+
+        s = {}
+
+        trace syscalls:sys_enter_* {
+                s[argname] += 1
+        }
+
+        trace_end {
+                histogram(s)
+        }
+
+6. kprobe tracing
+
+        trace probe:do_sys_open dfd=%di fname=%dx flags=%cx mode=+4($stack) {
+                print("entry:", execname(), argevent)
+        }
+
+        trace probe:do_sys_open%return fd=$retval {
+                print("exit:", execname(), argevent)
+        }
+
+7. uprobe tracing
+
+        trace probe:/lib/libc.so.6:malloc {
+                print("entry:", execname(), argevent)
+        }
+
+        trace probe:/lib/libc.so.6:malloc%return {
+                print("exit:", execname(), argevent)
+        }
+
+8. stapsdt tracing (userspace static marker)
+
+        trace sdt:/lib64/libc.so.6:lll_futex_wake {
+                print("lll_futex_wake", execname(), argevent)
+        }
+
+        or:
+
+        #trace all static mark in libc
+        trace sdt:/lib64/libc.so.6:* {
+                print(execname(), argevent)
+        }
+
+9. timer
+
+        tick-1ms {
+                printf("time fired on one cpu\n");
+        }
+
+        profile-2s {
+                printf("time fired on every cpu\n");
+        }
+
+10. FFI (Call kernel function from ktap script, need compile with FFI=1)
+
+        cdef[[
+                int printk(char *fmt, ...);
+        ]]
+
+        C.printk("This message is called from ktap ffi\n")
+
+More examples can be found at [samples][samples_dir] directory.
+
+[samples_dir]: https://github.com/ktap/ktap/tree/master/samples
+
+# Appendix
+
+Here is the complete syntax of ktap in extended BNF.
+(based on lua syntax: http://www.lua.org/manual/5.1/manual.html#5.1)
+
+        chunk ::= {stat [';']} [laststat [';']
+
+        block ::= chunk
+
+        stat ::=  varlist '=' explist |
+                 functioncall |
+                 { block } |
+                 while exp { block } |
+                 repeat block until exp |
+                 if exp { block {elseif exp { block }} [else block] } |
+                 for Name '=' exp ',' exp [',' exp] { block } |
+                 for namelist in explist { block } |
+                 function funcname funcbody |
+                 local function Name funcbody |
+                 local namelist ['=' explist]
+
+        laststat ::= return [explist] | break
+
+        funcname ::= Name {'.' Name} [':' Name]
+
+        varlist ::= var {',' var}
+
+        var ::=  Name | prefixexp '[' exp ']'| prefixexp '.' Name
+
+        namelist ::= Name {',' Name}
+
+        explist ::= {exp ',' exp
+
+        exp ::=  nil | false | true | Number | String | '...' | function |
+                 prefixexp | tableconstructor | exp binop exp | unop exp
+
+        prefixexp ::= var | functioncall | '(' exp ')'
+
+        functioncall ::=  prefixexp args | prefixexp ':' Name args
+
+        args ::=  '(' [explist] ')' | tableconstructor | String
+
+        function ::= function funcbody
+
+        funcbody ::= '(' [parlist] ')' { block }
+
+        parlist ::= namelist [',' '...'] | '...'
+
+        tableconstructor ::= '{' [fieldlist] '}'
+
+        fieldlist ::= field {fieldsep field} [fieldsep]
+
+        field ::= '[' exp ']' '=' exp | Name '=' exp | exp
+
+        fieldsep ::= ',' | ';'
+
+        binop ::= '+' | '-' | '*' | '/' | '^' | '%' | '..' |
+                  '<' | '<=' | '>' | '>=' | '==' | '!=' |
+                  and | or
+
+        unop ::= '-'
+
diff --git a/drivers/staging/ktap/include/ktap_ffi.h b/drivers/staging/ktap/include/ktap_ffi.h
new file mode 100644 (file)
index 0000000..c8167f0
--- /dev/null
@@ -0,0 +1,180 @@
+#ifndef __KTAP_FFI_H__
+#define __KTAP_FFI_H__
+
+#ifdef CONFIG_KTAP_FFI
+
+#include "../include/ktap_types.h"
+
+/*
+ * Types design in FFI module
+ *
+ * ktap_cdata is an instance of csymbol, so it's a combination of csymbol
+ * and it's actual data in memory.
+ *
+ * csymbol structs are globally unique and readonly type that represent C
+ * types.  For non scalar C types like struct and function, helper structs are
+ * used to store detailed information. See csymbol_func and csymbol_struct for
+ * more information.
+ */
+
+typedef enum {
+       /* 0 - 4 */
+       FFI_VOID,
+       FFI_UINT8,
+       FFI_INT8,
+       FFI_UINT16,
+       FFI_INT16,
+       /* 5 - 9 */
+       FFI_UINT32,
+       FFI_INT32,
+       FFI_UINT64,
+       FFI_INT64,
+       FFI_PTR,
+       /* 10 - 12 */
+       FFI_FUNC,
+       FFI_STRUCT,
+       FFI_UNKNOWN,
+} ffi_type;
+#define NUM_FFI_TYPE ((int)FFI_UNKNOWN)
+
+
+/* following struct and macros are added for C typedef
+ * size and alignment calculation */
+typedef struct {
+       size_t size;
+       size_t align;
+       const char *name;
+} ffi_mode;
+extern const ffi_mode const ffi_type_modes[];
+
+#define ffi_type_size(t) (ffi_type_modes[t].size)
+#define ffi_type_align(t) (ffi_type_modes[t].align)
+#define ffi_type_name(t) (ffi_type_modes[t].name)
+
+
+/* start of csymbol definition */
+#define CSYM_NAME_MAX_LEN 64
+
+typedef struct csymbol_func {
+       void *addr;             /* function address */
+       csymbol_id ret_id;      /* function return type */
+       int arg_nr;             /* number of arguments */
+       csymbol_id *arg_ids;    /* function argument types */
+       unsigned has_var_arg;   /* is this a var arg function? */
+} csymbol_func;
+
+typedef struct struct_member {
+       char name[CSYM_NAME_MAX_LEN];   /* name for this struct member */
+       csymbol_id id;                  /* type for this struct member */
+} struct_member;
+
+typedef struct csymbol_struct {
+       int memb_nr;                    /* number of members */
+       struct_member *members;         /* array for each member definition */
+       size_t size;                    /* bytes used to store struct */
+       /* alignment of the struct, 0 indicates uninitialization */
+       size_t align;
+} csymbol_struct;
+
+
+/* wrapper struct for all C symbols */
+typedef struct csymbol {
+       char name[CSYM_NAME_MAX_LEN];   /* name for this symbol */
+       ffi_type type;                  /* type for this symbol  */
+       /* following members are used only for non scalar C types */
+       union {
+               csymbol_id p;           /* pointer type */
+               csymbol_func f;         /* C function type */
+               csymbol_struct st;      /* struct type */
+               csymbol_id td;          /* typedef type */
+       } u;
+} csymbol;
+
+/* lookup csymbol address by it's id */
+inline csymbol *ffi_get_csym_by_id(ktap_state *ks, csymbol_id id);
+#define id_to_csym(ks, id) (ffi_get_csym_by_id(ks, id))
+
+/* helper macros for struct csymbol */
+#define csym_type(cs) ((cs)->type)
+#define csym_name(cs) ((cs)->name)
+
+/*
+ * helper macros for pointer symbol
+ */
+#define csym_ptr_deref_id(cs) ((cs)->u.p)
+#define csym_set_ptr_deref_id(cs, id) ((cs)->u.p = (id))
+/* following macro gets csymbol address */
+#define csym_ptr_deref(ks, cs) (id_to_csym(ks, csym_ptr_deref_id(cs)))
+
+/*
+ * helper macros for function symbol
+ * csym_* accepts csymbol type
+ * csymf_* accepts csymbol_func type
+ */
+#define csymf_addr(csf) ((csf)->addr)
+#define csymf_ret_id(csf) ((csf)->ret_id)
+#define csymf_arg_nr(csf) ((csf)->arg_nr)
+#define csymf_arg_ids(csf) ((csf)->arg_ids)
+/* get csymbol id for the nth argument */
+#define csymf_arg_id(csf, n) ((csf)->arg_ids[n])
+#define csym_func(cs) (&((cs)->u.f))
+#define csym_func_addr(cs) (csymf_addr(csym_func(cs)))
+#define csym_func_arg_ids(cs) (csymf_arg_ids(csym_func(cs)))
+/* following macros get csymbol address */
+#define csymf_ret(ks, csf) (id_to_csym(ks, csymf_ret_id(csf)))
+/* get csymbol address for the nth argument */
+#define csymf_arg(ks, csf, n) (id_to_csym(ks, csymf_arg_id(csf, n)))
+#define csym_func_arg(ks, cs, n) (csymf_arg(ks, csym_func(cs), n))
+
+/*
+ * helper macors for struct symbol
+ * csym_* accepts csymbol type
+ * csymst_* accepts csymbol_struct type
+ */
+#define csymst_mb_nr(csst) ((csst)->memb_nr)
+#define csym_struct(cs) (&(cs)->u.st)
+#define csym_struct_mb(cs) (csymst_mb(ks, csym_struct(cs), n))
+/* following macro gets csymbol address for the nth struct member */
+#define csymst_mb(ks, csst, n) (id_to_csym(ks, (csst)->members[n].id))
+
+
+/*
+ * helper macros for ktap_cdata type
+ */
+#define cd_csym_id(cd) ((cd)->id)
+#define cd_set_csym_id(cd, id) (cd_csym_id(cd) = (id))
+#define cd_csym(ks, cd) (id_to_csym(ks, cd_csym_id(cd)))
+#define cd_type(ks, cd) (cd_csym(ks, cd)->type)
+
+#define cd_int(cd) ((cd)->u.i)
+#define cd_ptr(cd) ((cd)->u.p)
+#define cd_struct(cd) ((cd)->u.st)
+
+
+#ifdef __KERNEL__
+size_t csym_size(ktap_state *ks, csymbol *sym);
+size_t csym_align(ktap_state *ks, csymbol *sym);
+size_t csym_struct_offset(ktap_state *ks, csymbol_struct *csst, int idx);
+void init_csym_struct(ktap_state *ks, csymbol_struct *csst);
+
+void kp_ffi_free_symbol(ktap_state *ks);
+csymbol_id ffi_get_csym_id(ktap_state *ks, char *name);
+
+ktap_cdata *kp_cdata_new(ktap_state *ks);
+void kp_cdata_dump(ktap_state *ks, ktap_cdata *cd);
+ktap_cdata *kp_cdata_new_ptr(ktap_state *ks, void *addr, csymbol_id id);
+ktap_cdata *kp_cdata_new_struct(ktap_state *ks, void *val, csymbol_id id);
+
+int kp_ffi_call(ktap_state *ks, csymbol_func *cf);
+#endif /* for __KERNEL__ */
+
+#else
+
+static void __maybe_unused kp_ffi_free_symbol(ktap_state *ks)
+{
+       return;
+}
+
+#endif /* CONFIG_KTAP_FFI */
+
+#endif /* __KTAP_FFI_H__ */
diff --git a/drivers/staging/ktap/include/ktap_opcodes.h b/drivers/staging/ktap/include/ktap_opcodes.h
new file mode 100644 (file)
index 0000000..fd9f955
--- /dev/null
@@ -0,0 +1,239 @@
+#ifndef __KTAP_BYTECODE_H__
+#define __KTAP_BYTECODE_H__
+
+
+/* opcode is copied from lua initially */
+
+typedef enum {
+/*----------------------------------------------------------------------
+ * name            args    description
+ * ------------------------------------------------------------------------*/
+OP_MOVE,/*      A B     R(A) := R(B)                                    */
+OP_LOADK,/*     A Bx    R(A) := Kst(Bx)                                 */
+OP_LOADKX,/*    A       R(A) := Kst(extra arg)                          */
+OP_LOADBOOL,/*  A B C   R(A) := (Bool)B; if (C) pc++                    */
+OP_LOADNIL,/*   A B     R(A), R(A+1), ..., R(A+B) := nil                */
+OP_GETUPVAL,/*  A B     R(A) := UpValue[B]                              */
+
+OP_GETTABUP,/*  A B C   R(A) := UpValue[B][RK(C)]                       */
+OP_GETTABLE,/*  A B C   R(A) := R(B)[RK(C)]                             */
+
+OP_SETTABUP,/*  A B C   UpValue[A][RK(B)] := RK(C)                      */
+OP_SETTABUP_INCR,/*  A B C   UpValue[A][RK(B)] += RK(C)                 */
+OP_SETTABUP_AGGR,/*  A B C   UpValue[A][RK(B)] <<< RK(C)                */
+OP_SETUPVAL,/*  A B     UpValue[B] := R(A)                              */
+OP_SETTABLE,/*  A B C   R(A)[RK(B)] := RK(C)                            */
+OP_SETTABLE_INCR,/*  A B C   R(A)[RK(B)] += RK(C)                       */
+OP_SETTABLE_AGGR,/*  A B C   R(A)[RK(B)] <<< RK(C)                      */
+
+OP_NEWTABLE,/*  A B C   R(A) := {} (size = B,C)                         */
+
+OP_SELF,/*      A B C   R(A+1) := R(B); R(A) := R(B)[RK(C)]             */
+
+OP_ADD,/*       A B C   R(A) := RK(B) + RK(C)                           */
+OP_SUB,/*       A B C   R(A) := RK(B) - RK(C)                           */
+OP_MUL,/*       A B C   R(A) := RK(B) * RK(C)                           */
+OP_DIV,/*       A B C   R(A) := RK(B) / RK(C)                           */
+OP_MOD,/*       A B C   R(A) := RK(B) % RK(C)                           */
+OP_POW,/*       A B C   R(A) := RK(B) ^ RK(C)                           */
+OP_UNM,/*       A B     R(A) := -R(B)                                   */
+OP_NOT,/*       A B     R(A) := not R(B)                                */
+OP_LEN,/*       A B     R(A) := length of R(B)                          */
+
+OP_CONCAT,/*    A B C   R(A) := R(B).. ... ..R(C)                       */
+
+OP_JMP,/*       A sBx   pc+=sBx; if (A) close all upvalues >= R(A) + 1  */
+OP_EQ,/*        A B C   if ((RK(B) == RK(C)) != A) then pc++            */
+OP_LT,/*        A B C   if ((RK(B) <  RK(C)) != A) then pc++            */
+OP_LE,/*        A B C   if ((RK(B) <= RK(C)) != A) then pc++            */
+
+OP_TEST,/*      A C     if not (R(A) <=> C) then pc++                   */
+OP_TESTSET,/*   A B C   if (R(B) <=> C) then R(A) := R(B) else pc++     */
+
+OP_CALL,/*      A B C   R(A), ... ,R(A+C-2) := R(A)(R(A+1), ... ,R(A+B-1)) */
+OP_TAILCALL,/*  A B C   return R(A)(R(A+1), ... ,R(A+B-1))              */
+OP_RETURN,/*    A B     return R(A), ... ,R(A+B-2)      (see note)      */
+
+OP_FORLOOP,/*   A sBx   R(A)+=R(A+2);
+                        if R(A) <?= R(A+1) then { pc+=sBx; R(A+3)=R(A) }*/
+OP_FORPREP,/*   A sBx   R(A)-=R(A+2); pc+=sBx                           */
+
+OP_TFORCALL,/*  A C     R(A+3), ... ,R(A+2+C) := R(A)(R(A+1), R(A+2));  */
+OP_TFORLOOP,/*  A sBx   if R(A+1) != nil then { R(A)=R(A+1); pc += sBx }*/
+
+OP_SETLIST,/*   A B C   R(A)[(C-1)*FPF+i] := R(A+i), 1 <= i <= B        */
+
+OP_CLOSURE,/*   A Bx    R(A) := closure(KPROTO[Bx])                     */
+
+OP_VARARG,/*    A B     R(A), R(A+1), ..., R(A+B-2) = vararg            */
+
+OP_EXTRAARG,/*   Ax      extra (larger) argument for previous opcode     */
+
+OP_EVENT,/*  A B C   R(A) := R(B)[C]                             */
+
+OP_EVENTNAME, /* A     R(A) = event_name() */
+
+OP_EVENTARG,/* A B     R(A) := event_arg(B)*/
+
+OP_LOAD_GLOBAL,/*  A B C   R(A) := R(B)[C]                             */
+
+OP_EXIT,
+
+} OpCode;
+
+
+#define NUM_OPCODES     ((int)OP_LOAD_GLOBAL + 1)
+
+
+enum OpMode {iABC, iABx, iAsBx, iAx};  /* basic instruction format */
+
+
+/*
+ * ** size and position of opcode arguments.
+ * */
+#define SIZE_C          9
+#define SIZE_B          9
+#define SIZE_Bx         (SIZE_C + SIZE_B)
+#define SIZE_A          8
+#define SIZE_Ax         (SIZE_C + SIZE_B + SIZE_A)
+
+#define SIZE_OP         6
+
+#define POS_OP          0
+#define POS_A           (POS_OP + SIZE_OP)
+#define POS_C           (POS_A + SIZE_A)
+#define POS_B           (POS_C + SIZE_C)
+#define POS_Bx          POS_C
+#define POS_Ax          POS_A
+
+
+
+/*
+ * ** limits for opcode arguments.
+ * ** we use (signed) int to manipulate most arguments,
+ * ** so they must fit in LUAI_BITSINT-1 bits (-1 for sign)
+ * */
+#define MAXARG_Bx        ((1<<SIZE_Bx)-1)
+#define MAXARG_sBx        (MAXARG_Bx>>1)         /* `sBx' is signed */
+
+#define MAXARG_Ax       ((1<<SIZE_Ax)-1)
+
+#define MAXARG_A        ((1<<SIZE_A)-1)
+#define MAXARG_B        ((1<<SIZE_B)-1)
+#define MAXARG_C        ((1<<SIZE_C)-1)
+
+
+/* creates a mask with `n' 1 bits at position `p' */
+#define MASK1(n,p)      ((~((~(ktap_instruction)0)<<(n)))<<(p))
+
+/* creates a mask with `n' 0 bits at position `p' */
+#define MASK0(n,p)      (~MASK1(n,p))
+
+/*
+ * ** the following macros help to manipulate instructions
+ * */
+
+#define GET_OPCODE(i)   ((OpCode)((i)>>POS_OP) & MASK1(SIZE_OP,0))
+#define SET_OPCODE(i,o) ((i) = (((i)&MASK0(SIZE_OP,POS_OP)) | \
+                ((((ktap_instruction)o)<<POS_OP)&MASK1(SIZE_OP,POS_OP))))
+
+#define getarg(i,pos,size)      ((int)((i)>>pos) & MASK1(size,0))
+#define setarg(i,v,pos,size)    ((i) = (((i)&MASK0(size,pos)) | \
+                ((((ktap_instruction)v)<<pos)&MASK1(size,pos))))
+
+#define GETARG_A(i)     getarg(i, POS_A, SIZE_A)
+#define SETARG_A(i,v)   setarg(i, v, POS_A, SIZE_A)
+
+#define GETARG_B(i)     getarg(i, POS_B, SIZE_B)
+#define SETARG_B(i,v)   setarg(i, v, POS_B, SIZE_B)
+
+#define GETARG_C(i)     getarg(i, POS_C, SIZE_C)
+#define SETARG_C(i,v)   setarg(i, v, POS_C, SIZE_C)
+
+#define GETARG_Bx(i)    getarg(i, POS_Bx, SIZE_Bx)
+#define SETARG_Bx(i,v)  setarg(i, v, POS_Bx, SIZE_Bx)
+
+#define GETARG_Ax(i)    getarg(i, POS_Ax, SIZE_Ax)
+#define SETARG_Ax(i,v)  setarg(i, v, POS_Ax, SIZE_Ax)
+
+#define GETARG_sBx(i)   (GETARG_Bx(i)-MAXARG_sBx)
+#define SETARG_sBx(i,b) SETARG_Bx((i), (unsigned int)(b)+MAXARG_sBx)
+
+#define CREATE_ABC(o,a,b,c)     (((ktap_instruction)(o))<<POS_OP) \
+                        | (((ktap_instruction)(a))<<POS_A) \
+                        | (((ktap_instruction)(b))<<POS_B) \
+                        | (((ktap_instruction)(c))<<POS_C)
+
+#define CREATE_ABx(o,a,bc)      (((ktap_instruction)(o))<<POS_OP) \
+                        | (((ktap_instruction)(a))<<POS_A) \
+                        | (((ktap_instruction)(bc))<<POS_Bx)
+
+#define CREATE_Ax(o,a)          (((ktap_instruction)(o))<<POS_OP) \
+                        | (((ktap_instruction)(a))<<POS_Ax)
+
+
+
+/*
+ * ** Macros to operate RK indices
+ * */
+
+/* this bit 1 means constant (0 means register) */
+#define BITRK           (1 << (SIZE_B - 1))
+
+/* test whether value is a constant */
+#define ISK(x)          ((x) & BITRK)
+
+/* gets the index of the constant */
+#define INDEXK(r)       ((int)(r) & ~BITRK)
+
+#define MAXINDEXRK      (BITRK - 1)
+
+/* code a constant index as a RK value */
+#define RKASK(x)        ((x) | BITRK)
+
+
+/*
+ * ** invalid register that fits in 8 bits
+ * */
+#define NO_REG          MAXARG_A
+
+
+/*
+ * ** R(x) - register
+ * ** Kst(x) - constant (in constant table)
+ * ** RK(x) == if ISK(x) then Kst(INDEXK(x)) else R(x)
+ * */
+
+
+
+/*
+ * ** masks for instruction properties. The format is:
+ * ** bits 0-1: op mode
+ * ** bits 2-3: C arg mode
+ * ** bits 4-5: B arg mode
+ * ** bit 6: instruction set register A
+ * ** bit 7: operator is a test (next instruction must be a jump)
+ * */
+
+enum OpArgMask {
+  OpArgN,  /* argument is not used */
+  OpArgU,  /* argument is used */
+  OpArgR,  /* argument is a register or a jump offset */
+  OpArgK   /* argument is a constant or register/constant */
+};
+
+extern const u8 ktap_opmodes[NUM_OPCODES];
+
+#define getOpMode(m)    ((enum OpMode)ktap_opmodes[m] & 3)
+#define getBMode(m)     ((enum OpArgMask)(ktap_opmodes[m] >> 4) & 3)
+#define getCMode(m)     ((enum OpArgMask)(ktap_opmodes[m] >> 2) & 3)
+#define testAMode(m)    (ktap_opmodes[m] & (1 << 6))
+#define testTMode(m)    (ktap_opmodes[m] & (1 << 7))
+
+
+/* number of list items to accumulate before a SETLIST instruction */
+#define LFIELDS_PER_FLUSH       50
+
+extern const char *const ktap_opnames[NUM_OPCODES + 1];
+
+#endif /* __KTAP_BYTECODE_H__ */
diff --git a/drivers/staging/ktap/include/ktap_types.h b/drivers/staging/ktap/include/ktap_types.h
new file mode 100644 (file)
index 0000000..7388a34
--- /dev/null
@@ -0,0 +1,609 @@
+#ifndef __KTAP_TYPES_H__
+#define __KTAP_TYPES_H__
+
+#ifdef __KERNEL__
+#include <linux/perf_event.h>
+#else
+typedef char u8;
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+#include <stdint.h>
+#endif
+
+/*
+ * The first argument type of kdebug.probe_by_id()
+ * The value is a userspace memory pointer.
+ */
+typedef struct ktap_eventdef_info {
+       int nr;
+       int *id_arr;
+       char *filter;
+} ktap_eventdef_info;
+
+typedef struct ktap_parm {
+       char *trunk; /* __user */
+       int trunk_len;
+       int argc;
+       char **argv; /* __user */
+       int verbose;
+       int trace_pid;
+       int workload;
+       int trace_cpu;
+       int print_timestamp;
+       int quiet;
+} ktap_parm;
+
+/*
+ * Ioctls that can be done on a ktap fd:
+ * todo: use _IO macro in include/uapi/asm-generic/ioctl.h
+ */
+#define KTAP_CMD_IOC_VERSION           ('$' + 0)
+#define KTAP_CMD_IOC_RUN               ('$' + 1)
+#define KTAP_CMD_IOC_EXIT              ('$' + 3)
+
+#define KTAP_ENV       "_ENV"
+
+#define KTAP_VERSION_MAJOR       "0"
+#define KTAP_VERSION_MINOR       "4"
+
+#define KTAP_VERSION    "ktap " KTAP_VERSION_MAJOR "." KTAP_VERSION_MINOR
+#define KTAP_AUTHOR    "Jovi Zhangwei <jovi.zhangwei@gmail.com>"
+#define KTAP_COPYRIGHT  KTAP_VERSION "  Copyright (C) 2012-2013, " KTAP_AUTHOR
+
+#define MYINT(s)        (s[0] - '0')
+#define VERSION         (MYINT(KTAP_VERSION_MAJOR) * 16 + MYINT(KTAP_VERSION_MINOR))
+#define FORMAT          0 /* this is the official format */
+
+#define KTAP_SIGNATURE  "\033ktap"
+
+/* data to catch conversion errors */
+#define KTAPC_TAIL      "\x19\x93\r\n\x1a\n"
+
+/* size in bytes of header of binary files */
+#define KTAPC_HEADERSIZE       (sizeof(KTAP_SIGNATURE) - sizeof(char) + 2 + \
+                                6 + sizeof(KTAPC_TAIL) - sizeof(char))
+
+typedef long ktap_number;
+#define kp_number2int(i, n)    ((i) = (int)(n))
+
+typedef int ktap_instruction;
+
+typedef union ktap_gcobject ktap_gcobject;
+
+#define CommonHeader ktap_gcobject *next; u8 tt;
+
+typedef union ktap_string {
+       int dummy;  /* ensures maximum alignment for strings */
+       struct {
+               CommonHeader;
+               u8 extra;  /* reserved words for short strings; "has hash" for longs */
+               unsigned int hash;
+               size_t len;  /* number of characters in string */
+       } tsv;
+       /* short string is stored here, just after tsv */
+} ktap_string;
+
+
+struct ktap_state;
+typedef int (*ktap_cfunction) (struct ktap_state *ks);
+
+typedef struct ktap_value {
+       union {
+               ktap_gcobject *gc;    /* collectable objects */
+               void *p;         /* light userdata */
+               int b;           /* booleans */
+               ktap_cfunction f; /* light C functions */
+               ktap_number n;         /* numbers */
+       } val;
+       int type;
+} ktap_value;
+
+typedef ktap_value * StkId;
+
+
+/*
+ * Description of an upvalue for function prototypes
+ */
+typedef struct ktap_upvaldesc {
+       ktap_string *name;  /* upvalue name (for debug information) */
+       u8 instack;  /* whether it is in stack */
+       u8 idx;  /* index of upvalue (in stack or in outer function's list) */
+} ktap_upvaldesc;
+
+/*
+ * Description of a local variable for function prototypes
+ * (used for debug information)
+ */
+typedef struct ktap_locvar {
+       ktap_string *varname;
+       int startpc;  /* first point where variable is active */
+       int endpc;    /* first point where variable is dead */
+} ktap_locvar;
+
+
+typedef struct ktap_upval {
+       CommonHeader;
+       ktap_value *v;  /* points to stack or to its own value */
+       union {
+               ktap_value value;  /* the value (when closed) */
+               struct {  /* double linked list (when open) */
+                       struct ktap_upval *prev;
+                       struct ktap_upval *next;
+               } l;
+       } u;
+} ktap_upval;
+
+
+#define KTAP_MAX_STACK_ENTRIES 100
+
+typedef struct ktap_btrace {
+       CommonHeader;
+       unsigned int nr_entries;
+       /* entries stored in here, after nr_entries */
+} ktap_btrace;
+
+typedef struct ktap_closure {
+       CommonHeader;
+       u8 nupvalues;
+       struct ktap_proto *p;
+       struct ktap_upval *upvals[1];  /* list of upvalues */
+       ktap_gcobject *gclist;
+} ktap_closure;
+
+typedef struct ktap_proto {
+       CommonHeader;
+       ktap_value *k;  /* constants used by the function */
+       ktap_instruction *code;
+       struct ktap_proto **p;  /* functions defined inside the function */
+       int *lineinfo;  /* map from opcodes to source lines (debug information) */
+       struct ktap_locvar *locvars;  /* information about local variables (debug information) */
+       struct ktap_upvaldesc *upvalues;  /* upvalue information */
+       ktap_closure *cache;  /* last created closure with this prototype */
+       ktap_string  *source;  /* used for debug information */
+       int sizeupvalues;  /* size of 'upvalues' */
+       int sizek;  /* size of `k' */
+       int sizecode;
+       int sizelineinfo;
+       int sizep;  /* size of `p' */
+       int sizelocvars;
+       int linedefined;
+       int lastlinedefined;
+       u8 numparams;  /* number of fixed parameters */
+       u8 is_vararg;
+       u8 maxstacksize;  /* maximum stack used by this function */
+} ktap_proto;
+
+
+/*
+ * information about a call
+ */
+typedef struct ktap_callinfo {
+       StkId func;  /* function index in the stack */
+       StkId top;  /* top for this function */
+       struct ktap_callinfo *prev, *next;  /* dynamic call link */
+       short nresults;  /* expected number of results from this function */
+       u8 callstatus;
+       int extra;
+       union {
+               struct {  /* only for ktap functions */
+                       StkId base;  /* base for this function */
+                       const unsigned int *savedpc;
+               } l;
+               struct {  /* only for C functions */
+                       int ctx;  /* context info. in case of yields */
+                       u8 status;
+               } c;
+       } u;
+} ktap_callinfo;
+
+
+/*
+ * ktap_tab
+ */
+typedef struct ktap_tkey {
+       struct ktap_tnode *next;  /* for chaining */
+       ktap_value tvk;
+} ktap_tkey;
+
+
+typedef struct ktap_tnode {
+       ktap_value i_val;
+       ktap_tkey i_key;
+} ktap_tnode;
+
+
+typedef struct ktap_stat_data {
+       int count;
+       int sum;
+       int min, max;
+} ktap_stat_data;
+
+
+typedef struct ktap_tab {
+       CommonHeader;
+#ifdef __KERNEL__
+       arch_spinlock_t lock;
+#endif
+       u8 flags;  /* 1<<p means tagmethod(p) is not present */
+       u8 lsizenode;  /* log2 of size of `node' array */
+       int sizearray;  /* size of `array' array */
+       ktap_value *array;  /* array part */
+       ktap_tnode *node;
+       ktap_tnode *lastfree;  /* any free position is before this position */
+
+       int with_stats;  /* for aggregation table: ptable */
+       ktap_stat_data *sd_arr;
+       ktap_stat_data *sd_rec;
+
+       ktap_tnode *sorted;  /* sorted table, with linked node list */
+       ktap_tnode *sort_head;
+
+       ktap_gcobject *gclist;
+} ktap_tab;
+
+#define lmod(s,size)   ((int)((s) & ((size)-1)))
+
+/* parallel table */
+typedef struct ktap_ptab {
+       CommonHeader;
+       ktap_tab **tbl; /* percpu table */
+       ktap_tab *agg;
+} ktap_ptab;
+
+typedef struct ktap_stringtable {
+       ktap_gcobject **hash;
+       int nuse;
+       int size;
+} ktap_stringtable;
+
+#ifdef CONFIG_KTAP_FFI
+typedef int csymbol_id;
+typedef struct csymbol csymbol;
+
+/* global ffi state maintained in each ktap vm instance */
+typedef struct ffi_state {
+       ktap_tab *ctable;
+       int csym_nr;
+       csymbol *csym_arr;
+} ffi_state;
+
+/* instance of csymbol */
+typedef struct ktap_cdata {
+       CommonHeader;
+       csymbol_id id;
+       union {
+               uint64_t i;
+               void *p;        /* pointer address */
+               void *st;       /* struct member data */
+       } u;
+} ktap_cdata;
+#endif
+
+typedef struct ktap_stats {
+       int mem_allocated;
+       int nr_mem_allocate;
+       int nr_mem_free;
+       int events_hits;
+       int events_missed;
+} ktap_stats;
+
+#define KTAP_STATS(ks) this_cpu_ptr(G(ks)->stats)
+
+enum {
+       KTAP_PERCPU_DATA_STATE,
+       KTAP_PERCPU_DATA_STACK,
+       KTAP_PERCPU_DATA_BUFFER,
+       KTAP_PERCPU_DATA_BUFFER2,
+       KTAP_PERCPU_DATA_BTRACE,
+
+       KTAP_PERCPU_DATA_MAX
+};
+
+typedef struct ktap_global_state {
+       ktap_stringtable strt;  /* hash table for strings */
+       ktap_value registry;
+       unsigned int seed; /* randonized seed for hashes */
+
+       ktap_gcobject *allgc; /* list of all collectable objects */
+
+       ktap_upval uvhead; /* head of double-linked list of all open upvalues */
+
+       struct ktap_state *mainthread;
+#ifdef __KERNEL__
+       /* global percpu data(like stack) */
+       void __percpu *pcpu_data[KTAP_PERCPU_DATA_MAX][PERF_NR_CONTEXTS];
+
+       int __percpu *recursion_context[PERF_NR_CONTEXTS];
+
+       arch_spinlock_t str_lock; /* string opertion lock */
+
+       ktap_parm *parm;
+       pid_t trace_pid;
+       struct task_struct *trace_task;
+       cpumask_var_t cpumask;
+       struct ring_buffer *buffer;
+       struct dentry *trace_pipe_dentry;
+       int nr_builtin_cfunction;
+       ktap_value *cfunction_tbl;
+       struct task_struct *task;
+       int trace_enabled;
+       struct list_head timers;
+       struct list_head probe_events_head;
+       int exit;
+       int wait_user;
+       ktap_closure *trace_end_closure;
+       struct ktap_stats __percpu *stats;
+       struct kmem_cache *pevent_cache;
+#ifdef CONFIG_KTAP_FFI
+       ffi_state  ffis;
+#endif
+#endif
+       int error;
+} ktap_global_state;
+
+typedef struct ktap_state {
+       CommonHeader;
+       ktap_global_state *g;
+       int stop;
+       StkId top;
+       ktap_callinfo *ci;
+       const unsigned long *oldpc;
+       StkId stack_last;
+       StkId stack;
+       ktap_gcobject *openupval;
+       ktap_callinfo baseci;
+
+       /* list of temp collectable objects, free when thread exit */
+       ktap_gcobject *gclist;
+
+#ifdef __KERNEL__
+       struct ktap_event *current_event;
+#endif
+} ktap_state;
+
+
+typedef struct gcheader {
+       CommonHeader;
+} gcheader;
+
+/*
+ * Union of all collectable objects
+ */
+union ktap_gcobject {
+       gcheader gch;  /* common header */
+       union ktap_string ts;
+       struct ktap_closure cl;
+       struct ktap_tab h;
+       struct ktap_ptab ph;
+       struct ktap_proto p;
+       struct ktap_upval uv;
+       struct ktap_state th;  /* thread */
+       struct ktap_btrace bt;  /* backtrace object */
+#ifdef CONFIG_KTAP_FFI
+       struct ktap_cdata cd;
+#endif
+};
+
+#define gch(o)                 (&(o)->gch)
+
+/* macros to convert a GCObject into a specific value */
+#define rawgco2ts(o)           (&((o)->ts))
+
+#define gco2ts(o)              (&rawgco2ts(o)->tsv)
+#define gco2uv(o)              (&((o)->uv))
+#define obj2gco(v)             ((ktap_gcobject *)(v))
+#define check_exp(c, e)                (e)
+
+
+/* predefined values in the registry */
+#define KTAP_RIDX_MAINTHREAD     1
+#define KTAP_RIDX_GLOBALS        2
+#define KTAP_RIDX_LAST           KTAP_RIDX_GLOBALS
+
+#define KTAP_TNONE             (-1)
+
+#define KTAP_TNIL              0
+#define KTAP_TBOOLEAN          1
+#define KTAP_TLIGHTUSERDATA    2
+#define KTAP_TNUMBER           3
+#define KTAP_TSTRING           4
+#define KTAP_TSHRSTR           (KTAP_TSTRING | (0 << 4))  /* short strings */
+#define KTAP_TLNGSTR           (KTAP_TSTRING | (1 << 4))  /* long strings */
+#define KTAP_TTABLE            5
+#define KTAP_TFUNCTION         6
+#define KTAP_TCLOSURE          (KTAP_TFUNCTION | (0 << 4))  /* closure */
+#define KTAP_TCFUNCTION                (KTAP_TFUNCTION | (1 << 4))  /* light C function */
+#define KTAP_TTHREAD           7
+#define KTAP_TPROTO            8
+#define KTAP_TUPVAL            9
+#define KTAP_TEVENT            10
+#define KTAP_TBTRACE           11
+#define KTAP_TPTABLE           12
+#define KTAP_TSTATDATA         13
+#define KTAP_TCDATA            14
+/*
+ * type number is ok so far, but it may collide later between
+ * 16+ and | (1 << 4), so be careful on this.
+ */
+
+#define ttype(o)               ((o->type) & 0x3F)
+#define settype(obj, t)                ((obj)->type = (t))
+
+/* raw type tag of a TValue */
+#define rttype(o)              ((o)->type)
+
+/* tag with no variants (bits 0-3) */
+#define novariant(x)           ((x) & 0x0F)
+
+/* type tag of a TValue with no variants (bits 0-3) */
+#define ttypenv(o)             (novariant(rttype(o)))
+
+#define val_(o)                        ((o)->val)
+#define gcvalue(o)             (val_(o).gc)
+
+#define bvalue(o)              (val_(o).b)
+#define nvalue(o)              (val_(o).n)
+#define hvalue(o)              (&val_(o).gc->h)
+#define phvalue(o)             (&val_(o).gc->ph)
+#define clvalue(o)             (&val_(o).gc->cl)
+
+#define getstr(ts)             (const char *)((ts) + 1)
+#define eqshrstr(a, b)         ((a) == (b))
+#define rawtsvalue(o)          (&val_(o).gc->ts)
+#define svalue(o)              getstr(rawtsvalue(o))
+
+#define pvalue(o)              (&val_(o).p)
+#define sdvalue(o)             ((ktap_stat_data *)val_(o).p)
+#define fvalue(o)              (val_(o).f)
+#define evalue(o)              (val_(o).p)
+#define btvalue(o)             (&val_(o).gc->bt)
+#define cdvalue(o)             (&val_(o).gc->cd)
+
+#define is_nil(o)              ((o)->type == KTAP_TNIL)
+#define is_boolean(o)          ((o)->type == KTAP_TBOOLEAN)
+#define is_false(o)            (is_nil(o) || (is_boolean(o) && bvalue(o) == 0))
+#define is_shrstring(o)                ((o)->type == KTAP_TSHRSTR)
+#define is_string(o)           (((o)->type & 0x0F) == KTAP_TSTRING)
+#define is_number(o)           ((o)->type == KTAP_TNUMBER)
+#define is_table(o)            ((o)->type == KTAP_TTABLE)
+#define is_ptable(o)           ((o)->type == KTAP_TPTABLE)
+#define is_statdata(o)         ((o)->type == KTAP_TSTATDATA)
+#define is_event(o)            ((o)->type == KTAP_TEVENT)
+#define is_btrace(o)           ((o)->type == KTAP_TBTRACE)
+#define is_needclone(o)                is_btrace(o)
+#ifdef CONFIG_KTAP_FFI
+#define is_cdata(o)            ((o)->type == KTAP_TCDATA)
+#endif
+
+
+#define set_nil(obj) \
+       { ktap_value *io = (obj); io->val.n = 0; settype(io, KTAP_TNIL); }
+
+#define set_boolean(obj, x) \
+       { ktap_value *io = (obj); io->val.b = (x); settype(io, KTAP_TBOOLEAN); }
+
+#define set_number(obj, x) \
+       { ktap_value *io = (obj); io->val.n = (x); settype(io, KTAP_TNUMBER); }
+
+#define set_statdata(obj, x) \
+       { ktap_value *io = (obj); \
+         io->val.p = (x); settype(io, KTAP_TSTATDATA); }
+
+#define set_string(obj, x) \
+       { ktap_value *io = (obj); \
+         ktap_string *x_ = (x); \
+         io->val.gc = (ktap_gcobject *)x_; settype(io, x_->tsv.tt); }
+
+#define set_closure(obj, x) \
+       { ktap_value *io = (obj); \
+         io->val.gc = (ktap_gcobject *)x; settype(io, KTAP_TCLOSURE); }
+
+#define set_cfunction(obj, x) \
+       { ktap_value *io = (obj); val_(io).f = (x); settype(io, KTAP_TCFUNCTION); }
+
+#define set_table(obj, x) \
+       { ktap_value *io = (obj); \
+         val_(io).gc = (ktap_gcobject *)(x); settype(io, KTAP_TTABLE); }
+
+#define set_ptable(obj, x) \
+       { ktap_value *io = (obj); \
+         val_(io).gc = (ktap_gcobject *)(x); settype(io, KTAP_TPTABLE); }
+
+#define set_thread(obj, x) \
+       { ktap_value *io = (obj); \
+         val_(io).gc = (ktap_gcobject *)(x); settype(io, KTAP_TTHREAD); }
+
+#define set_event(obj, x) \
+       { ktap_value *io = (obj); val_(io).p = (x); settype(io, KTAP_TEVENT); }
+
+#define set_btrace(obj, x) \
+       { ktap_value *io = (obj); \
+         val_(io).gc = (ktap_gcobject *)(x); settype(io, KTAP_TBTRACE); }
+
+#ifdef CONFIG_KTAP_FFI
+#define set_cdata(obj, x) \
+       { ktap_value *io=(obj); \
+         val_(io).gc = (ktap_gcobject *)(x); settype(io, KTAP_TCDATA); }
+#endif
+
+#define set_obj(obj1, obj2) \
+        { const ktap_value *io2 = (obj2); ktap_value *io1 = (obj1); \
+          io1->val = io2->val; io1->type = io2->type; }
+
+#define rawequalobj(t1, t2) \
+       (((t1)->type == (t2)->type) && kp_equalobjv(NULL, t1, t2))
+
+#define incr_top(ks) {ks->top++;}
+
+#define NUMADD(a, b)    ((a) + (b))
+#define NUMSUB(a, b)    ((a) - (b))
+#define NUMMUL(a, b)    ((a) * (b))
+#define NUMDIV(a, b)    ((a) / (b))
+#define NUMUNM(a)       (-(a))
+#define NUMEQ(a, b)     ((a) == (b))
+#define NUMLT(a, b)     ((a) < (b))
+#define NUMLE(a, b)     ((a) <= (b))
+#define NUMISNAN(a)     (!NUMEQ((a), (a)))
+
+/* todo: floor and pow in kernel */
+#define NUMMOD(a, b)    ((a) % (b))
+#define NUMPOW(a, b)    (pow(a, b))
+
+#define ktap_assert(s)
+
+#define kp_realloc(ks, v, osize, nsize, t) \
+       ((v) = (t *)kp_reallocv(ks, v, osize * sizeof(t), nsize * sizeof(t)))
+
+#define kp_error(ks, args...) \
+       do { \
+               kp_printf(ks, "error: "args);   \
+               G(ks)->error = 1; \
+               kp_exit(ks);    \
+       } while(0)
+
+#ifdef __KERNEL__
+#define G(ks)   (ks->g)
+
+void kp_printf(ktap_state *ks, const char *fmt, ...);
+extern void __kp_puts(ktap_state *ks, const char *str);
+extern void __kp_bputs(ktap_state *ks, const char *str);
+
+#define kp_puts(ks, str) ({                                            \
+       static const char *trace_printk_fmt                             \
+               __attribute__((section("__trace_printk_fmt"))) =        \
+               __builtin_constant_p(str) ? str : NULL;                 \
+                                                                       \
+       if (__builtin_constant_p(str))                                  \
+               __kp_bputs(ks, trace_printk_fmt);               \
+       else                                                            \
+               __kp_puts(ks, str);             \
+})
+
+#else
+/*
+ * this is used for ktapc tstring operation, tstring need G(ks)->strt
+ * and G(ks)->seed, so ktapc need to init those field
+ */
+#define G(ks)   (&dummy_global_state)
+extern ktap_global_state dummy_global_state;
+
+#define kp_printf(ks, args...)                 printf(args)
+#define kp_puts(ks, str)                       printf("%s", str)
+#define kp_exit(ks)                            exit(EXIT_FAILURE)
+
+#endif
+
+#define __maybe_unused __attribute__((unused))
+
+/*
+ * KTAP_QL describes how error messages quote program elements.
+ * CHANGE it if you want a different appearance.
+ */
+#define KTAP_QL(x)      "'" x "'"
+#define KTAP_QS         KTAP_QL("%s")
+
+#define STRINGIFY(type) #type
+
+#endif /* __KTAP_TYPES_H__ */
+
diff --git a/drivers/staging/ktap/runtime/ffi/call_x86_64.S b/drivers/staging/ktap/runtime/ffi/call_x86_64.S
new file mode 100644 (file)
index 0000000..29b2915
--- /dev/null
@@ -0,0 +1,143 @@
+/*
+ * call_x86_64.S - assembly code to call C function and handle return value
+ *
+ * This file is part of ktap by Jovi Zhangwei
+ *
+ * Copyright (C) 2012-2013 Jovi Zhangwei <jovi.zhangwei@gmail.com>.
+ *
+ * ktap 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.
+ *
+ * ktap is distributed in the hope it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
+ * more details.
+ *
+ * You should have received a copy of the GNU General Public License along with
+ * this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+
+
+#ifdef __x86_64
+
+       .file "call_x86_64.S"
+       .text
+
+/*     ffi_call_assem_x86_64(void *stack, void *temp_stack,
+ *             void *rvalue, void *func_addr, ffi_type rftype)
+ *     @stack: base address of register values and new stack
+ *     @temp_stack: stack to store temporary values
+ *     @func_addr: Function address
+ *     @rvalue: where to put return value
+ *     @rftype: FFI type of return value
+ */
+       .align 2
+       .globl  ffi_call_assem_x86_64
+       .type   ffi_call_assem_x86_64,@function
+
+ffi_call_assem_x86_64:
+       movq    (%rsp), %rax    /* save return address */
+       /* move stuffs to temp memory region(void *temp_stack) */
+       movq    %rcx, (%rsi)    /* save pointer to return value */
+       movq    %r8, 8(%rsi)    /* save return_ffi_type */
+       movq    %rbp, 16(%rsi)  /* save %rbp */
+       movq    %rax, 24(%rsi)  /* save return address */
+       movq    %rsp, 32(%rsi)  /* save %rsp */
+       movq    %rsi, %rbp      /* point %rbp to temp memory region */
+
+       movq    %rdx, %r11      /* move function address to %r11 */
+
+       movq    %rdi, %r10      /* set %r10 point to register region */
+       movq    (%r10), %rdi    /* load registers */
+       movq    8(%r10), %rsi
+       movq    16(%r10), %rdx
+       movq    24(%r10), %rcx
+       movq    32(%r10), %r8
+       movq    40(%r10), %r9
+       xorq    %rax, %rax
+
+       leaq    48(%r10), %rsp
+
+       callq   *%r11
+
+       movq    32(%rbp), %rsp  /* restore %rsp */
+       movq    24(%rbp), %rcx  /* restore return address */
+       movq    %rcx, (%rsp)
+
+       movq    (%rbp), %rcx    /* get pointer to return value */
+       movq    8(%rbp), %r8    /* get return_ffi_type */
+       movq    16(%rbp), %rbp  /* restore rbp */
+
+       leaq    .Lreturn_table(%rip), %r11      /* start address of return_table */
+       movslq  (%r11, %r8, 8), %r11    /* fetch target address from table */
+       jmpq    *%r11                   /* jump according to value in table */
+
+       .align 8
+.Lreturn_table:
+       .quad   .Lreturn_void           /* FFI_VOID */
+       .quad   .Lreturn_uint8          /* FFI_UINT8 */
+       .quad   .Lreturn_int8           /* FFI_INT8 */
+       .quad   .Lreturn_uint16         /* FFI_UINT16 */
+       .quad   .Lreturn_int16          /* FFI_INT16 */
+       .quad   .Lreturn_uint32         /* FFI_UINT32 */
+       .quad   .Lreturn_int32          /* FFI_INT32 */
+       .quad   .Lreturn_uint64         /* FFI_UINT64 */
+       .quad   .Lreturn_int64          /* FFI_INT64 */
+       .quad   .Lreturn_ptr            /* FFI_PTR */
+       .quad   .Lreturn_func           /* FFI_FUNC */
+       .quad   .Lreturn_struct         /* FFI_STRUCT */
+       .quad   .Lreturn_unknown        /* FFI_UNKNOWN */
+
+       .align 8
+.Lreturn_void:
+.Lreturn_func:
+.Lreturn_unknown:
+       retq
+       .align 8
+.Lreturn_uint8:
+       movzbq  %al, %rax
+       movq    %rax, (%rcx)
+       retq
+       .align 8
+.Lreturn_int8:
+       movsbq  %al, %rax
+       movq    %rax, (%rcx)
+       retq
+       .align 8
+.Lreturn_uint16:
+       movzwq  %ax, %rax
+       movq    %rax, (%rcx)
+       retq
+       .align 8
+.Lreturn_int16:
+       movswq  %ax, %rax
+       movq    %rax, (%rcx)
+       retq
+       .align 8
+.Lreturn_uint32:
+       movl    %eax, %eax
+       movq    %rax, (%rcx)
+       retq
+       .align 8
+.Lreturn_int32:
+       movslq  %eax, %rax
+       movq    %rax, (%rcx)
+       retq
+       .align 8
+.Lreturn_uint64:
+.Lreturn_int64:
+.Lreturn_ptr:
+       movq    %rax, (%rcx)
+       retq
+/* Struct type indicates that struct is put into at most two registers,
+ * and 16 bytes space is always available
+ */
+       .align 8
+.Lreturn_struct:
+       movq    %rax, (%rcx)
+       movq    %rdx, 8(%rcx)
+       retq
+
+#endif /* end for __x86_64 */
diff --git a/drivers/staging/ktap/runtime/ffi/cdata.c b/drivers/staging/ktap/runtime/ffi/cdata.c
new file mode 100644 (file)
index 0000000..aaea559
--- /dev/null
@@ -0,0 +1,67 @@
+/*
+ * cdata.c - support functions for ktap_cdata
+ *
+ * This file is part of ktap by Jovi Zhangwei
+ *
+ * Copyright (C) 2012-2013 Jovi Zhangwei <jovi.zhangwei@gmail.com>.
+ *
+ * ktap 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.
+ *
+ * ktap is distributed in the hope it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
+ * more details.
+ *
+ * You should have received a copy of the GNU General Public License along with
+ * this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+
+
+#include "../../include/ktap_types.h"
+#include "../../include/ktap_ffi.h"
+#include "../kp_obj.h"
+
+ktap_cdata *kp_cdata_new(ktap_state *ks)
+{
+       ktap_cdata *cd;
+
+       cd = &kp_newobject(ks, KTAP_TCDATA, sizeof(ktap_cdata), NULL)->cd;
+
+       return cd;
+}
+
+ktap_cdata *kp_cdata_new_ptr(ktap_state *ks, void *addr, csymbol_id id)
+{
+       ktap_cdata *cd;
+
+       cd = kp_cdata_new(ks);
+       cd_set_csym_id(cd, id);
+       cd_ptr(cd) = addr;
+
+       return cd;
+}
+
+ktap_cdata *kp_cdata_new_struct(ktap_state *ks, void *val, csymbol_id id)
+{
+       ktap_cdata *cd;
+
+       cd = kp_cdata_new(ks);
+       cd_set_csym_id(cd, id);
+       cd_struct(cd) = val;
+
+       return cd;
+}
+
+void kp_cdata_dump(ktap_state *ks, ktap_cdata *cd)
+{
+       switch (cd_type(ks, cd)) {
+       case FFI_PTR:
+               kp_printf(ks, "pointer(%p)", cd_ptr(cd));
+               break;
+       default:
+               kp_printf(ks, "unsupported cdata type %d!\n", cd_type(ks, cd));
+       }
+}
diff --git a/drivers/staging/ktap/runtime/ffi/ffi_call.c b/drivers/staging/ktap/runtime/ffi/ffi_call.c
new file mode 100644 (file)
index 0000000..7bd845a
--- /dev/null
@@ -0,0 +1,427 @@
+/*
+ * ffi_call.c - foreign function calling library support for ktap
+ *
+ * This file is part of ktap by Jovi Zhangwei.
+ *
+ * Copyright (C) 2012-2013 Jovi Zhangwei <jovi.zhangwei@gmail.com>.
+ *
+ * ktap 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.
+ *
+ * ktap is distributed in the hope it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
+ * more details.
+ *
+ * You should have received a copy of the GNU General Public License along with
+ * this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+
+#include <linux/ctype.h>
+#include <linux/slab.h>
+#include "../../include/ktap_types.h"
+#include "../../include/ktap_ffi.h"
+#include "../ktap.h"
+#include "../kp_vm.h"
+#include "../kp_obj.h"
+
+static int ffi_type_check(ktap_state *ks, csymbol_func *csf, int idx)
+{
+       StkId arg;
+       csymbol *cs;
+       ffi_type type;
+
+       if (idx >= csymf_arg_nr(csf))
+               return 0;
+       arg = kp_arg(ks, idx + 1);
+       cs = csymf_arg(ks, csf, idx);
+       type = csym_type(cs);
+
+       if (type == FFI_FUNC)
+               goto error;
+
+       switch (ttypenv(arg)) {
+       case KTAP_TLIGHTUSERDATA:
+               if (type != FFI_PTR) goto error;
+               break;
+       case KTAP_TBOOLEAN:
+       case KTAP_TNUMBER:
+               if (type != FFI_UINT8 && type != FFI_INT8
+               && type != FFI_UINT16 && type != FFI_INT16
+               && type != FFI_UINT32 && type != FFI_INT32
+               && type != FFI_UINT64 && type != FFI_INT64)
+                       goto error;
+               break;
+       case KTAP_TSTRING:
+               if (type != FFI_PTR && type != FFI_UINT8 && type != FFI_INT8)
+                       goto error;
+               break;
+       case KTAP_TCDATA:
+               if (cs != cd_csym(ks, cdvalue(arg)))
+                       goto error;
+               break;
+       default:
+               goto error;
+       }
+       return 0;
+
+ error:
+       kp_error(ks, "Error: Cannot convert to csymbol %s for arg %d\n",
+                       csym_name(cs), idx);
+       return -1;
+}
+
+static csymbol *ffi_get_arg_csym(ktap_state *ks, csymbol_func *csf, int idx)
+{
+       StkId arg;
+       csymbol *cs;
+
+       if (idx < csymf_arg_nr(csf))
+               return csymf_arg(ks, csf, idx);
+
+       arg = kp_arg(ks, idx + 1);
+       cs = id_to_csym(ks, ffi_get_csym_id(ks, "void *"));
+       switch (ttypenv(arg)) {
+       case KTAP_TLIGHTUSERDATA:
+       case KTAP_TBOOLEAN:
+       case KTAP_TNUMBER:
+       case KTAP_TSTRING:
+               return cs;
+       case KTAP_TCDATA:
+               return cd_csym(ks, cdvalue(arg));
+       default:
+               kp_error(ks, "Error: Cannot get type for arg %d\n", idx);
+               return cs;
+       }
+}
+
+static void ffi_unpack(ktap_state *ks, csymbol_func *csf, int idx,
+               char *dst, int align)
+{
+       StkId arg = kp_arg(ks, idx + 1);
+       csymbol *cs = ffi_get_arg_csym(ks, csf, idx);
+       ffi_type type = csym_type(cs);
+       size_t size = csym_size(ks, cs);
+       void *p;
+       struct ktap_cdata *cd;
+
+       /* initialize the destination section */
+       memset(dst, 0, ALIGN(size, align));
+
+       switch (ttypenv(arg)) {
+       case KTAP_TBOOLEAN:
+               memcpy(dst, &bvalue(arg), sizeof(bool));
+               return;
+       case KTAP_TLIGHTUSERDATA:
+               memcpy(dst, pvalue(arg), size);
+               return;
+       case KTAP_TNUMBER:
+               memcpy(dst, &nvalue(arg), size < sizeof(ktap_number) ?
+                               size : sizeof(ktap_number));
+               return;
+       case KTAP_TSTRING:
+               p = &rawtsvalue(arg)->tsv + 1;
+               memcpy(dst, &p, size);
+               return;
+       }
+
+       cd = cdvalue(arg);
+       switch (type) {
+       case FFI_VOID:
+               kp_error(ks, "Error: Cannot copy data from void type\n");
+               return;
+       case FFI_UINT8:
+       case FFI_INT8:
+       case FFI_UINT16:
+       case FFI_INT16:
+       case FFI_UINT32:
+       case FFI_INT32:
+       case FFI_UINT64:
+       case FFI_INT64:
+               memcpy(dst, &cd_int(cd), size);
+               return;
+       case FFI_PTR:
+               memcpy(dst, &cd_ptr(cd), size);
+               return;
+       case FFI_STRUCT:
+               memcpy(dst, cd_struct(cd), size);
+               return;
+       case FFI_FUNC:
+       case FFI_UNKNOWN:
+               kp_error(ks, "Error: internal error for csymbol %s\n",
+                               csym_name(cs));
+               return;
+       }
+}
+
+#ifdef __x86_64
+
+enum arg_status {
+       IN_REGISTER,
+       IN_MEMORY,
+       IN_STACK,
+};
+
+#define ALIGN_STACK(v, a) ((void *)(ALIGN(((uint64_t)v), a)))
+#define STACK_ALIGNMENT 8
+#define REDZONE_SIZE 128
+#define GPR_SIZE (sizeof(void *))
+#define MAX_GPR 6
+#define MAX_GPR_SIZE (MAX_GPR * GPR_SIZE)
+#define NEWSTACK_SIZE 512
+
+#define ffi_call(ks, cf, rvalue) ffi_call_x86_64(ks, cf, rvalue)
+
+extern void ffi_call_assem_x86_64(void *stack, void *temp_stack,
+                                       void *func_addr, void *rvalue, ffi_type rtype);
+
+static void ffi_call_x86_64(ktap_state *ks, csymbol_func *csf, void *rvalue)
+{
+       int i;
+       int gpr_nr;
+       int arg_bytes; /* total bytes needed for exceeded args in stack */
+       int mem_bytes; /* total bytes needed for memory storage */
+       char *stack, *stack_p, *gpr_p, *arg_p, *mem_p, *tmp_p;
+       int arg_nr;
+       csymbol *rsym;
+       ffi_type rtype;
+       size_t rsize;
+       bool ret_in_memory;
+       /* New stack to call C function */
+       char space[NEWSTACK_SIZE];
+
+       arg_nr = kp_arg_nr(ks);
+       rsym = csymf_ret(ks, csf);
+       rtype = csym_type(rsym);
+       rsize = csym_size(ks, rsym);
+       ret_in_memory = false;
+       if (rtype == FFI_STRUCT) {
+               if (rsize > 16) {
+                       rvalue = kp_malloc(ks, rsize);
+                       rtype = FFI_VOID;
+                       ret_in_memory = true;
+               } else {
+                       /* much easier to always copy 16 bytes from registers */
+                       rvalue = kp_malloc(ks, 16);
+               }
+       }
+
+       gpr_nr = 0;
+       arg_bytes = mem_bytes = 0;
+       if (ret_in_memory)
+               gpr_nr++;
+       /* calculate bytes needed for stack */
+       for (i = 0; i < arg_nr; i++) {
+               csymbol *cs = ffi_get_arg_csym(ks, csf, i);
+               size_t size = csym_size(ks, cs);
+               size_t align = csym_align(ks, cs);
+               enum arg_status st = IN_REGISTER;
+               int n_gpr_nr = 0;
+               if (size > 32) {
+                       st = IN_MEMORY;
+                       n_gpr_nr = 1;
+               } else if (size > 16)
+                       st = IN_STACK;
+               else
+                       n_gpr_nr = ALIGN(size, GPR_SIZE) / GPR_SIZE;
+
+               if (gpr_nr + n_gpr_nr > MAX_GPR) {
+                       if (st == IN_MEMORY)
+                               arg_bytes += GPR_SIZE;
+                       else
+                               st = IN_STACK;
+               } else
+                       gpr_nr += n_gpr_nr;
+               if (st == IN_STACK) {
+                       arg_bytes = ALIGN(arg_bytes, align);
+                       arg_bytes += size;
+                       arg_bytes = ALIGN(arg_bytes, STACK_ALIGNMENT);
+               }
+               if (st == IN_MEMORY) {
+                       mem_bytes = ALIGN(mem_bytes, align);
+                       mem_bytes += size;
+                       mem_bytes = ALIGN(mem_bytes, STACK_ALIGNMENT);
+               }
+       }
+
+       /* apply space to fake stack for C function call */
+       if (16 + REDZONE_SIZE + MAX_GPR_SIZE + arg_bytes +
+                       mem_bytes + 6 * 8 >= NEWSTACK_SIZE) {
+               kp_error(ks, "Unable to handle that many arguments by now\n");
+               return;
+       }
+       stack = space;
+       /* 128 bytes below %rsp is red zone */
+       /* stack should be 16-bytes aligned */
+       stack_p = ALIGN_STACK(stack + REDZONE_SIZE, 16);
+       /* save general purpose registers here */
+       gpr_p = stack_p;
+       memset(gpr_p, 0, MAX_GPR_SIZE);
+       /* save arguments in stack here */
+       arg_p = gpr_p + MAX_GPR_SIZE;
+       /* save arguments in memory here */
+       mem_p = arg_p + arg_bytes;
+       /* set additional space as temporary space */
+       tmp_p = mem_p + mem_bytes;
+
+       /* copy arguments here */
+       gpr_nr = 0;
+       if (ret_in_memory) {
+               memcpy(gpr_p, &rvalue, GPR_SIZE);
+               gpr_p += GPR_SIZE;
+               gpr_nr++;
+       }
+       for (i = 0; i < arg_nr; i++) {
+               csymbol *cs = ffi_get_arg_csym(ks, csf, i);
+               size_t size = csym_size(ks, cs);
+               size_t align = csym_align(ks, cs);
+               enum arg_status st = IN_REGISTER;
+               int n_gpr_nr = 0;
+               if (size > 32) {
+                       st = IN_MEMORY;
+                       n_gpr_nr = 1;
+               } else if (size > 16)
+                       st = IN_STACK;
+               else
+                       n_gpr_nr = ALIGN(size, GPR_SIZE) / GPR_SIZE;
+
+               if (st == IN_MEMORY)
+                       mem_p = ALIGN_STACK(mem_p, align);
+               /* Tricky way about storing it above mem_p. It won't overflow
+                * because temp region can be temporarily used if necesseary. */
+               ffi_unpack(ks, csf, i, mem_p, GPR_SIZE);
+               if (gpr_nr + n_gpr_nr > MAX_GPR) {
+                       if (st == IN_MEMORY) {
+                               memcpy(arg_p, &mem_p, GPR_SIZE);
+                               arg_p += GPR_SIZE;
+                       } else
+                               st = IN_STACK;
+               } else {
+                       memcpy(gpr_p, mem_p, n_gpr_nr * GPR_SIZE);
+                       gpr_p += n_gpr_nr * GPR_SIZE;
+                       gpr_nr += n_gpr_nr;
+               }
+               if (st == IN_STACK) {
+                       arg_p = ALIGN_STACK(arg_p, align);
+                       memcpy(arg_p, mem_p, size);
+                       arg_p += size;
+                       arg_p = ALIGN_STACK(arg_p, STACK_ALIGNMENT);
+               }
+               if (st == IN_MEMORY) {
+                       mem_p += size;
+                       mem_p = ALIGN_STACK(mem_p, STACK_ALIGNMENT);
+               }
+       }
+
+       kp_verbose_printf(ks, "Stack location: %p -redzone- %p -general purpose "
+                       "register used- %p -zero- %p -stack for argument- %p"
+                       " -memory for argument- %p -temp stack-\n",
+                       stack, stack_p, gpr_p, stack_p + MAX_GPR_SIZE,
+                       arg_p, mem_p);
+       kp_verbose_printf(ks, "GPR number: %d; arg in stack: %d; "
+                       "arg in mem: %d\n",
+                       gpr_nr, arg_bytes, mem_bytes);
+       kp_verbose_printf(ks, "Return: address %p type %d\n", rvalue, rtype);
+       kp_verbose_printf(ks, "Number of register used: %d\n", gpr_nr);
+       kp_verbose_printf(ks, "Start FFI call on %p\n", csf->addr);
+       ffi_call_assem_x86_64(stack_p, tmp_p, csf->addr, rvalue, rtype);
+}
+
+#else /* non-supported platform */
+
+#define ffi_call(ks, cf, rvalue) ffi_call_unsupported(ks, cf, rvalue)
+
+static void ffi_call_unsupported(ktap_state *ks,
+               csymbol_func *csf, void *rvalue)
+{
+       kp_error(ks, "unsupported architecture.\n");
+}
+
+#endif /* end for platform-specific setting */
+
+
+static int ffi_set_return(ktap_state *ks, void *rvalue, csymbol_id ret_id)
+{
+       ktap_cdata *cd;
+       ffi_type type = csym_type(id_to_csym(ks, ret_id));
+
+       /* push return value to ktap stack */
+       switch (type) {
+       case FFI_VOID:
+               return 0;
+       case FFI_UINT8:
+       case FFI_INT8:
+       case FFI_UINT16:
+       case FFI_INT16:
+       case FFI_UINT32:
+       case FFI_INT32:
+       case FFI_UINT64:
+       case FFI_INT64:
+               set_number(ks->top, (ktap_number)rvalue);
+               break;
+       case FFI_PTR:
+               cd = kp_cdata_new_ptr(ks, rvalue, ret_id);
+               set_cdata(ks->top, cd);
+               break;
+       case FFI_STRUCT:
+               cd = kp_cdata_new_struct(ks, rvalue, ret_id);
+               set_cdata(ks->top, cd);
+               break;
+       case FFI_FUNC:
+       case FFI_UNKNOWN:
+               kp_error(ks, "Error: Have not support ffi_type %s\n",
+                               ffi_type_name(type));
+               return 0;
+       }
+       incr_top(ks);
+       return 1;
+}
+
+/*
+ * Call C into function
+ * First argument should be function symbol address, argument types
+ * and return type.
+ * Left arguments should be arguments for calling the C function.
+ * Types between Ktap and C are converted automatically.
+ * Only support x86_64 function call by now
+ */
+int kp_ffi_call(ktap_state *ks, csymbol_func *csf)
+{
+       int i;
+       int expected_arg_nr, arg_nr;
+       ktap_closure *cl;
+       void *rvalue;
+
+       expected_arg_nr = csymf_arg_nr(csf);
+       arg_nr = kp_arg_nr(ks);
+
+       /* check stack status for C call */
+       if (!csf->has_var_arg && expected_arg_nr != arg_nr) {
+               kp_error(ks, "wrong argument number %d, which should be %d\n",
+                               arg_nr, expected_arg_nr);
+               goto out;
+       }
+       if (csf->has_var_arg && expected_arg_nr > arg_nr) {
+               kp_error(ks, "argument number %d, which should be bigger than %d\n",
+                               arg_nr, expected_arg_nr);
+               goto out;
+       }
+
+       /* maybe useful later, leave it here first */
+       cl = clvalue(kp_arg(ks, arg_nr + 1));
+
+       /* check the argument types */
+       for (i = 0; i < arg_nr; i++) {
+               if (ffi_type_check(ks, csf, i) < 0)
+                       goto out;
+       }
+
+       /* platform-specific calling workflow */
+       ffi_call(ks, csf, &rvalue);
+       kp_verbose_printf(ks, "Finish FFI call\n");
+
+out:
+       return ffi_set_return(ks, rvalue, csymf_ret_id(csf));
+}
diff --git a/drivers/staging/ktap/runtime/ffi/ffi_symbol.c b/drivers/staging/ktap/runtime/ffi/ffi_symbol.c
new file mode 100644 (file)
index 0000000..0534c37
--- /dev/null
@@ -0,0 +1,174 @@
+/*
+ * ffi_symbol.c - ktapvm kernel module ffi symbol submodule
+ *
+ * This file is part of ktap by Jovi Zhangwei.
+ *
+ * Copyright (C) 2012-2013 Jovi Zhangwei <jovi.zhangwei@gmail.com>.
+ *
+ * ktap 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.
+ *
+ * ktap is distributed in the hope it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
+ * more details.
+ *
+ * You should have received a copy of the GNU General Public License along with
+ * this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+
+
+#include "../../include/ktap_types.h"
+#include "../../include/ktap_ffi.h"
+#include "../ktap.h"
+#include "../kp_vm.h"
+#include "../kp_obj.h"
+#include "../kp_str.h"
+#include "../kp_tab.h"
+
+void setup_kp_ffi_symbol_table(ktap_state *ks);
+
+
+static inline csymbol *get_csym_arr(ktap_state *ks)
+{
+       return G(ks)->ffis.csym_arr;
+}
+
+static inline int get_csym_nr(ktap_state *ks)
+{
+       return G(ks)->ffis.csym_nr;
+}
+
+static inline void set_csym_arr(ktap_state *ks, csymbol *csym)
+{
+       G(ks)->ffis.csym_arr = csym;
+}
+
+static inline void set_csym_nr(ktap_state *ks, int nr)
+{
+       G(ks)->ffis.csym_nr = nr;
+}
+
+
+static inline ktap_tab *get_ffi_ctable(ktap_state *ks)
+{
+       return G(ks)->ffis.ctable;
+}
+
+static void setup_ffi_ctable(ktap_state *ks)
+{
+       ktap_value ffi_lib_name, ffi_mt;
+       ktap_tab *registry;
+       const ktap_value *gt;
+
+       gt = kp_tab_getint(hvalue(&G(ks)->registry), KTAP_RIDX_GLOBALS);
+
+       G(ks)->ffis.ctable = kp_tab_new(ks);
+
+       /* insert ffi C table to global table */
+       set_table(&ffi_mt, get_ffi_ctable(ks));
+       set_string(&ffi_lib_name, kp_tstring_new(ks, "C"));
+       registry = hvalue(gt);
+       kp_tab_setvalue(ks, registry, &ffi_lib_name, &ffi_mt);
+}
+
+void ffi_set_csym_arr(ktap_state *ks, int cs_nr, csymbol *new_arr)
+{
+       set_csym_nr(ks, cs_nr);
+       set_csym_arr(ks, new_arr);
+
+       if (!new_arr)
+               return;
+
+       setup_kp_ffi_symbol_table(ks);
+}
+
+inline csymbol *ffi_get_csym_by_id(ktap_state *ks, int id)
+{
+       return &(get_csym_arr(ks)[id]);
+}
+
+csymbol_id ffi_get_csym_id(ktap_state *ks, char *name)
+{
+       int i;
+
+       for (i = 0; i < get_csym_nr(ks); i++) {
+               if (!strcmp(name, csym_name(ffi_get_csym_by_id(ks, i)))) {
+                       return i;
+               }
+       }
+
+       kp_error(ks, "Cannot find csymbol with name %s\n", name);
+       return 0;
+}
+
+static void add_ffi_func_to_ctable(ktap_state *ks, csymbol_id id)
+{
+       ktap_value func_name, fv;
+       ktap_cdata *cd;
+       csymbol *cs;
+
+       /* push cdata to ctable */
+       set_cdata(&fv, kp_newobject(ks, KTAP_TCDATA, sizeof(ktap_cdata), NULL));
+       cd = cdvalue(&fv);
+       cd_set_csym_id(cd, id);
+
+       cs = id_to_csym(ks, id);
+       set_string(&func_name, kp_tstring_new(ks, csym_name(cs)));
+       kp_tab_setvalue(ks, get_ffi_ctable(ks), &func_name, &fv);
+}
+
+void setup_kp_ffi_symbol_table(ktap_state *ks)
+{
+       int i;
+       csymbol *cs;
+
+       setup_ffi_ctable(ks);
+
+       /* push all functions to ctable */
+       for (i = 0; i < get_csym_nr(ks); i++) {
+               cs = &get_csym_arr(ks)[i];
+               switch (cs->type) {
+               case FFI_FUNC:
+                       kp_verbose_printf(ks, "[%d] loading C function %s\n",
+                                       i, csym_name(cs));
+                       add_ffi_func_to_ctable(ks, i);
+                       kp_verbose_printf(ks, "%s loaded\n", csym_name(cs));
+                       break;
+               case FFI_STRUCT:
+                       break;
+               default:
+                       break;
+               }
+       }
+}
+
+void kp_ffi_free_symbol(ktap_state *ks)
+{
+       int i;
+       csymbol_id *arg_ids;
+       csymbol *cs;
+
+       if (!get_csym_arr(ks))
+               return;
+
+       for (i = 0; i < get_csym_nr(ks); i++) {
+               cs = &get_csym_arr(ks)[i];
+               switch (csym_type(cs)) {
+               case FFI_FUNC:
+                       arg_ids = csym_func_arg_ids(cs);
+                       if (arg_ids)
+                               kp_free(ks, arg_ids);
+                       break;
+               case FFI_STRUCT:
+                       /*@TODO finish this  20.11 2013 (houqp)*/
+                       break;
+               default:
+                       break;
+               }
+       }
+
+       kp_free(ks, get_csym_arr(ks));
+}
diff --git a/drivers/staging/ktap/runtime/ffi/ffi_type.c b/drivers/staging/ktap/runtime/ffi/ffi_type.c
new file mode 100644 (file)
index 0000000..6bb8316
--- /dev/null
@@ -0,0 +1,51 @@
+#include "../../include/ktap_ffi.h"
+#ifdef __KERNEL__
+#include <linux/types.h>
+#else
+#include <stdint.h>
+#include <stddef.h>
+#endif
+
+#define CTYPE_MODE_HELPER(name, type)  \
+struct _##name##_align {               \
+       type t1;                        \
+       char c;                         \
+       type t2;                        \
+};
+
+#define CTYPE_MODE(name)                               \
+{                                                      \
+       offsetof(struct _##name##_align, c),            \
+       offsetof(struct _##name##_align, t2) -          \
+               offsetof(struct _##name##_align, c),    \
+       #name                                   \
+}
+
+#define CTYPE_MODE_NAME(name) _##name##_mode
+
+/* ffi_ctype_mode should be corresponded to ffi_ctype */
+CTYPE_MODE_HELPER(uint8, uint8_t);
+CTYPE_MODE_HELPER(int8, int8_t);
+CTYPE_MODE_HELPER(uint16, uint16_t);
+CTYPE_MODE_HELPER(int16, int16_t);
+CTYPE_MODE_HELPER(uint32, uint32_t);
+CTYPE_MODE_HELPER(int32, int32_t);
+CTYPE_MODE_HELPER(uint64, uint64_t);
+CTYPE_MODE_HELPER(int64, int64_t);
+CTYPE_MODE_HELPER(pointer, void*);
+
+const ffi_mode ffi_type_modes[NUM_FFI_TYPE+1] = {
+       {0, 1, "void"},
+       CTYPE_MODE(uint8),
+       CTYPE_MODE(int8),
+       CTYPE_MODE(uint16),
+       CTYPE_MODE(int16),
+       CTYPE_MODE(uint32),
+       CTYPE_MODE(int32),
+       CTYPE_MODE(uint64),
+       CTYPE_MODE(int64),
+       CTYPE_MODE(pointer),
+       {0, 1, "function"},
+       {0, 1, "struct"},
+       {0, 1, "unknown"},
+};
diff --git a/drivers/staging/ktap/runtime/ffi/ffi_util.c b/drivers/staging/ktap/runtime/ffi/ffi_util.c
new file mode 100644 (file)
index 0000000..6b0376d
--- /dev/null
@@ -0,0 +1,92 @@
+/*
+ * ffi_util.c - utility function for ffi module
+ *
+ * This file is part of ktap by Jovi Zhangwei.
+ *
+ * Copyright (C) 2012-2013 Jovi Zhangwei <jovi.zhangwei@gmail.com>.
+ *
+ * ktap 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.
+ *
+ * ktap is distributed in the hope it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
+ * more details.
+ *
+ * You should have received a copy of the GNU General Public License along with
+ * this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+
+
+#include "../../include/ktap_types.h"
+#include "../../include/ktap_ffi.h"
+#include "../ktap.h"
+
+size_t csym_size(ktap_state *ks, csymbol *cs)
+{
+       ffi_type type = csym_type(cs);
+       switch(type) {
+       case FFI_STRUCT:
+               if (csym_struct(cs)->align == 0)
+                       init_csym_struct(ks, csym_struct(cs));
+               return csym_struct(cs)->size;
+       default:
+               return ffi_type_size(type);
+       }
+}
+
+size_t csym_align(ktap_state *ks, csymbol *cs)
+{
+       ffi_type type = csym_type(cs);
+       switch(type) {
+       case FFI_STRUCT:
+               if (csym_struct(cs)->align == 0)
+                       init_csym_struct(ks, csym_struct(cs));
+               return csym_struct(cs)->align;
+       default:
+               return ffi_type_align(type);
+       }
+}
+
+size_t csym_struct_offset(ktap_state *ks, csymbol_struct *csst, int idx)
+{
+       int nr = csymst_mb_nr(csst);
+       size_t off = 0;
+       size_t align = 1;
+       int i;
+
+       if (idx < 0 || idx > nr)
+               return -1;
+       for (i = 0; i < idx; i++) {
+               csymbol *var_cs = csymst_mb(ks, csst, i);
+               size_t var_size = csym_size(ks, var_cs);
+               size_t var_align = csym_align(ks, var_cs);
+               off = ALIGN(off, var_align);
+               off += var_size;
+               align = align > var_align ? align : var_align;
+       }
+       off = ALIGN(off, align);
+       return off;
+}
+
+void init_csym_struct(ktap_state *ks, csymbol_struct *csst)
+{
+       int nr = csymst_mb_nr(csst);
+       size_t size = 0;
+       size_t align = 1;
+       int i;
+
+       for (i = 0; i < nr; i++) {
+               csymbol *var_cs = csymst_mb(ks, csst, i);
+               size_t var_size = csym_size(ks, var_cs);
+               size_t var_align = csym_align(ks, var_cs);
+               size = ALIGN(size, var_align);
+               size += var_size;
+               align = align > var_align ? align : var_align;
+       }
+       size = ALIGN(size, align);
+       csst->size = size;
+       csst->align = align;
+}
diff --git a/drivers/staging/ktap/runtime/kp_amalg.c b/drivers/staging/ktap/runtime/kp_amalg.c
new file mode 100644 (file)
index 0000000..c244822
--- /dev/null
@@ -0,0 +1,43 @@
+/*
+ * kp_amalg.c - ktapvm kernel module amalgamation.
+ *
+ * This file is part of ktap by Jovi Zhangwei.
+ *
+ * Copyright (C) 2012-2013 Jovi Zhangwei <jovi.zhangwei@gmail.com>.
+ *
+ * ktap 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.
+ *
+ * ktap is distributed in the hope it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
+ * more details.
+ *
+ * You should have received a copy of the GNU General Public License along with
+ * this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+
+
+#include "ktap.c"
+#include "kp_opcode.c"
+#include "kp_obj.c"
+#include "kp_load.c"
+#include "kp_str.c"
+#include "kp_tab.c"
+#include "kp_transport.c"
+#include "kp_vm.c"
+#include "lib_base.c"
+#include "lib_ansi.c"
+#include "lib_kdebug.c"
+#include "lib_timer.c"
+
+#ifdef CONFIG_KTAP_FFI
+#include "ffi/ffi_call.c"
+#include "ffi/ffi_type.c"
+#include "ffi/ffi_symbol.c"
+#include "ffi/cdata.c"
+#include "ffi/ffi_util.c"
+#include "lib_ffi.c"
+#endif
diff --git a/drivers/staging/ktap/runtime/kp_load.c b/drivers/staging/ktap/runtime/kp_load.c
new file mode 100644 (file)
index 0000000..74f1da4
--- /dev/null
@@ -0,0 +1,401 @@
+/*
+ * kp_load.c - loader for ktap bytecode chunk file
+ *
+ * This file is part of ktap by Jovi Zhangwei.
+ *
+ * Copyright (C) 2012-2013 Jovi Zhangwei <jovi.zhangwei@gmail.com>.
+ *
+ * Copyright (C) 1994-2013 Lua.org, PUC-Rio.
+ *  - The part of code in this file is copied from lua initially.
+ *  - lua's MIT license is compatible with GPL.
+ *
+ * ktap 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.
+ *
+ * ktap is distributed in the hope it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
+ * more details.
+ *
+ * You should have received a copy of the GNU General Public License along with
+ * this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+
+#include <linux/slab.h>
+#include "../include/ktap_types.h"
+#include "../include/ktap_ffi.h"
+#include "ktap.h"
+#include "kp_load.h"
+#include "kp_obj.h"
+#include "kp_str.h"
+#include "kp_tab.h"
+#include "kp_vm.h"
+
+#define KTAPC_TAIL     "\x19\x93\r\n\x1a\n"
+
+struct load_state {
+       unsigned char *buff;
+       int pos;
+       ktap_state *ks;
+};
+
+#define READ_CHAR(S)  (S->buff[S->pos++])
+#define READ_BYTE(S)  READ_CHAR(S)
+#define READ_INT(S)  load_int(S)
+#define READ_NUMBER(S) load_number(S)
+#define READ_STRING(S) load_string(S)
+#define READ_VECTOR(S, dst, size)  \
+       do {    \
+               memcpy(dst, &S->buff[S->pos], size);    \
+               S->pos += size; \
+       } while(0)
+
+#define NEW_VECTOR(S, size)    kp_malloc(S->ks, size)
+#define FREE_VECTOR(S, v)      kp_free(S->ks, v)
+#define GET_CURRENT(S)         &S->buff[S->pos]
+#define ADD_POS(S, size)       S->pos += size
+
+
+static int load_function(struct load_state *S, ktap_proto *f);
+
+
+static int load_int(struct load_state *S)
+{
+       int x;
+
+       READ_VECTOR(S, &x, sizeof(int));
+       return x;
+}
+
+static long load_number(struct load_state *S)
+{
+       long x;
+
+       READ_VECTOR(S, &x, sizeof(ktap_number));
+       return x;
+}
+
+static ktap_string *load_string(struct load_state *S)
+{
+       ktap_string *ts;
+       size_t size;
+
+       size = READ_INT(S);
+
+       if (!size)
+               return NULL;
+       else {
+               char *s = GET_CURRENT(S);
+               ADD_POS(S, size);
+               /* remove trailing '\0' */
+               ts = kp_tstring_newlstr(S->ks, s, size - 1);
+               return ts;
+       }
+}
+
+
+static int load_code(struct load_state *S, ktap_proto *f)
+{
+       int n = READ_INT(S);
+
+       f->sizecode = n;
+       f->code = NEW_VECTOR(S, n * sizeof(ktap_instruction));
+       READ_VECTOR(S, f->code, n * sizeof(ktap_instruction));
+
+       return 0;
+}
+
+static int load_constants(struct load_state *S, ktap_proto *f)
+{
+       int i,n;
+
+       n = READ_INT(S);
+
+       f->sizek = n;
+       f->k = NEW_VECTOR(S, n * sizeof(ktap_value));
+       for (i = 0; i < n; i++)
+               set_nil(&f->k[i]);
+
+       for (i=0; i < n; i++) {
+               ktap_value *o = &f->k[i];
+
+               int t = READ_CHAR(S);
+               switch (t) {
+               case KTAP_TNIL:
+                       set_nil(o);
+                       break;
+               case KTAP_TBOOLEAN:
+                       set_boolean(o, READ_CHAR(S));
+                       break;
+               case KTAP_TNUMBER:
+                       /*
+                        * todo: kernel not support fp, check double when
+                        * loading
+                        */
+                       set_number(o, READ_NUMBER(S));
+                       break;
+               case KTAP_TSTRING:
+                       set_string(o, READ_STRING(S));
+                       break;
+               default:
+                       kp_error(S->ks, "ktap: load_constants: "
+                                       "unknow ktap_value\n");
+                       return -1;
+
+               }
+       }
+
+       n = READ_INT(S);
+       f->p = NEW_VECTOR(S, n * sizeof(ktap_proto));
+       f->sizep = n;
+       for (i = 0; i < n; i++)
+               f->p[i] = NULL;
+       for (i = 0; i < n; i++) {
+               f->p[i] = kp_newproto(S->ks);
+               if (load_function(S, f->p[i]))
+                       return -1;
+       }
+
+       return 0;
+}
+
+
+static int load_upvalues(struct load_state *S, ktap_proto *f)
+{
+       int i,n;
+
+       n = READ_INT(S);
+       f->upvalues = NEW_VECTOR(S, n * sizeof(ktap_upvaldesc));
+       f->sizeupvalues = n;
+
+       for (i = 0; i < n; i++)
+               f->upvalues[i].name = NULL;
+
+       for (i = 0; i < n; i++) {
+               f->upvalues[i].instack = READ_BYTE(S);
+               f->upvalues[i].idx = READ_BYTE(S);
+       }
+
+       return 0;
+}
+
+static int load_debuginfo(struct load_state *S, ktap_proto *f)
+{
+       int i,n;
+
+       f->source = READ_STRING(S);
+       n = READ_INT(S);
+       f->sizelineinfo = n;
+       f->lineinfo = NEW_VECTOR(S, n * sizeof(int));
+       READ_VECTOR(S, f->lineinfo, n * sizeof(int));
+       n = READ_INT(S);
+       f->locvars = NEW_VECTOR(S, n * sizeof(struct ktap_locvar));
+       f->sizelocvars = n;
+       for (i = 0; i < n; i++)
+               f->locvars[i].varname = NULL;
+       for (i = 0; i < n; i++) {
+               f->locvars[i].varname = READ_STRING(S);
+               f->locvars[i].startpc = READ_INT(S);
+               f->locvars[i].endpc = READ_INT(S);
+       }
+       n = READ_INT(S);
+       for (i = 0; i < n; i++)
+               f->upvalues[i].name = READ_STRING(S);
+
+       return 0;
+}
+
+static int load_function(struct load_state *S, ktap_proto *f)
+{
+       f->linedefined = READ_INT(S);
+       f->lastlinedefined = READ_INT(S);
+       f->numparams = READ_BYTE(S);
+       f->is_vararg = READ_BYTE(S);
+       f->maxstacksize = READ_BYTE(S);
+       if (load_code(S, f))
+               return -1;
+       if (load_constants(S, f))
+               return -1;
+       if (load_upvalues(S, f))
+               return -1;
+       if (load_debuginfo(S, f))
+               return -1;
+
+       return 0;
+}
+
+
+#define error(S, why) \
+       kp_error(S->ks, "load failed: %s precompiled chunk\n", why)
+
+#define N0     KTAPC_HEADERSIZE
+#define N1     (sizeof(KTAP_SIGNATURE) - sizeof(char))
+#define N2     N1 + 2
+#define N3     N2 + 6
+
+static int load_header(struct load_state *S)
+{
+       u8 h[KTAPC_HEADERSIZE];
+       u8 s[KTAPC_HEADERSIZE];
+
+       kp_header(h);
+       READ_VECTOR(S, s, KTAPC_HEADERSIZE);
+
+       if (memcmp(h, s, N0) == 0)
+               return 0;
+       if (memcmp(h, s, N1) != 0)
+               error(S, "not a");
+       else if (memcmp(h, s, N2) != 0)
+               error(S, "version mismatch in");
+       else if (memcmp(h, s, N3) != 0)
+               error(S, "incompatible");
+       else
+               error(S,"corrupted");
+
+       return -1;
+}
+
+#ifdef CONFIG_KTAP_FFI
+void ffi_set_csym_arr(ktap_state *ks, int cs_nr, csymbol *new_arr);
+
+static void load_csymbol_func(struct load_state *S, csymbol *cs)
+{
+       csymbol_func *csf = csym_func(cs);
+       int arg_nr = csymf_arg_nr(csf);
+
+       if (arg_nr > 0) {
+               csf->arg_ids = NEW_VECTOR(S, arg_nr*sizeof(int));
+               READ_VECTOR(S, csf->arg_ids, arg_nr*sizeof(int));
+       } else {
+               csf->arg_ids = NULL;
+       }
+}
+
+static void load_csymbol_struct(struct load_state *S, csymbol *cs)
+{
+       csymbol_struct *csst = csym_struct(cs);
+       int mb_nr = csymst_mb_nr(csst);
+
+       csst->members = NEW_VECTOR(S, mb_nr*sizeof(struct_member));
+       READ_VECTOR(S, csst->members, mb_nr*sizeof(struct_member));
+}
+
+static int load_csymbols(struct load_state *S)
+{
+       csymbol *cs_arr, *cs;
+       int i, csym_nr;
+
+       /* read number of csymbols */
+       csym_nr = READ_INT(S);
+       if (csym_nr <= 0) {
+               ffi_set_csym_arr(S->ks, 0, NULL);
+               return 0;
+       }
+
+       /* csymbol size safty check */
+       if (sizeof(csymbol) != READ_INT(S)) {
+               kp_error(S->ks, "invalid csymbol size in chunk\n");
+               return -1;
+       }
+
+       cs_arr = NEW_VECTOR(S, sizeof(csymbol)*csym_nr);
+       for (i = 0; i < csym_nr; i++) {
+               cs = &cs_arr[i];
+               READ_VECTOR(S, cs, sizeof(csymbol));
+               switch (cs->type) {
+               case FFI_FUNC:
+                       load_csymbol_func(S, cs);
+                       break;
+               case FFI_STRUCT:
+                       load_csymbol_struct(S, cs);
+                       break;
+               default:
+                       break;
+               }
+       }
+
+       ffi_set_csym_arr(S->ks, csym_nr, cs_arr);
+
+       return 0;
+}
+#else
+static int load_csymbols(struct load_state *S)
+{
+       int csym_nr = READ_INT(S);
+
+       /* if FFI is disabled in ktapc, csym_nr should be 0 */
+       if (csym_nr != 0) {
+                /* skip corrupted csymbol chunk */
+               int cs_size = READ_INT(S);
+               ADD_POS(S, cs_size*csym_nr);
+               kp_error(S->ks, "VM compiled without FFI support!\n");
+               return -1;
+       }
+
+       return 0;
+}
+#endif
+
+static int verify_code(struct load_state *S, ktap_proto *f)
+{
+       /* not support now */
+       return 0;
+}
+
+
+ktap_closure *kp_load(ktap_state *ks, unsigned char *buff)
+{
+       struct load_state S;
+       ktap_closure *cl;
+       int ret, i;
+
+       S.ks = ks;
+       S.buff = buff;
+       S.pos = 0;
+
+       ret = load_header(&S);
+       if (ret)
+               return NULL;
+
+       ret = load_csymbols(&S);
+       if (ret)
+               return NULL;
+
+       cl = kp_newclosure(ks, 1);
+       if (!cl)
+               return cl;
+
+       /* put closure on the top, prepare to run with this closure */
+       set_closure(ks->top, cl);
+       incr_top(ks);
+
+       cl->p = kp_newproto(ks);
+       if (load_function(&S, cl->p))
+               return NULL;
+
+       if (cl->p->sizeupvalues != 1) {
+               ktap_proto *p = cl->p;
+               cl = kp_newclosure(ks, cl->p->sizeupvalues);
+               cl->p = p;
+               set_closure(ks->top - 1, cl);
+       }
+
+       for (i = 0; i < cl->nupvalues; i++) {  /* initialize upvalues */
+               ktap_upval *up = kp_newupval(ks);
+               cl->upvals[i] = up;
+       }
+
+       /* set global table as 1st upvalue of 'f' */
+       if (cl->nupvalues == 1) {
+               ktap_tab *reg = hvalue(&G(ks)->registry);
+               const ktap_value *gt = kp_tab_getint(reg, KTAP_RIDX_GLOBALS);
+               set_obj(cl->upvals[0]->v, gt);
+       }
+
+       verify_code(&S, cl->p);
+
+       return cl;
+}
+
diff --git a/drivers/staging/ktap/runtime/kp_load.h b/drivers/staging/ktap/runtime/kp_load.h
new file mode 100644 (file)
index 0000000..fc41fa9
--- /dev/null
@@ -0,0 +1,6 @@
+#ifndef __KTAP_LOAD_H__
+#define __KTAP_LOAD_H__
+
+ktap_closure *kp_load(ktap_state *ks, unsigned char *buff);
+
+#endif /* __KTAP_LOAD_H__ */
diff --git a/drivers/staging/ktap/runtime/kp_obj.c b/drivers/staging/ktap/runtime/kp_obj.c
new file mode 100644 (file)
index 0000000..5149637
--- /dev/null
@@ -0,0 +1,478 @@
+/*
+ * kp_obj.c - ktap object generic operation
+ *
+ * This file is part of ktap by Jovi Zhangwei.
+ *
+ * Copyright (C) 2012-2013 Jovi Zhangwei <jovi.zhangwei@gmail.com>.
+ *
+ * Copyright (C) 1994-2013 Lua.org, PUC-Rio.
+ *  - The part of code in this file is copied from lua initially.
+ *  - lua's MIT license is compatible with GPL.
+ *
+ * ktap 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.
+ *
+ * ktap is distributed in the hope it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
+ * more details.
+ *
+ * You should have received a copy of the GNU General Public License along with
+ * this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+
+#include "../include/ktap_types.h"
+#include "../include/ktap_ffi.h"
+#include "kp_obj.h"
+#include "kp_str.h"
+#include "kp_tab.h"
+
+#ifdef __KERNEL__
+#include <linux/slab.h>
+#include "ktap.h"
+#include "kp_vm.h"
+#include "kp_transport.h"
+
+#define KTAP_ALLOC_FLAGS ((GFP_KERNEL | __GFP_NORETRY | __GFP_NOWARN) \
+                        & ~__GFP_WAIT)
+
+void *kp_malloc(ktap_state *ks, int size)
+{
+       void *addr;
+
+       /*
+        * Normally we don't want to trace under memory pressure,
+        * so we use a simple rule to handle memory allocation failure:
+        *
+        * retry until allocation success, this will make caller don't need
+        * to handle the unlikely failure case, then ktap exit.
+        *
+        * In this approach, if user find there have memory allocation failure,
+        * user should re-run the ktap script, or fix the memory pressure
+        * issue, or figure out why the script need so many memory.
+        *
+        * Perhaps return pre-allocated stub memory trunk when allocate failed
+        * is a better approch?
+        */
+       addr = kmalloc(size, KTAP_ALLOC_FLAGS);
+       if (unlikely(!addr)) {
+               kp_error(ks, "kmalloc size %d failed, retry again\n", size);
+               printk("ktap kmalloc size %d failed, retry again\n", size);
+               dump_stack();
+               while (1) {
+                       addr = kmalloc(size, KTAP_ALLOC_FLAGS);
+                       if (addr)
+                               break;
+               }
+               kp_printf(ks, "kmalloc retry success after failed, exit\n");
+       }
+
+       preempt_disable();
+       KTAP_STATS(ks)->nr_mem_allocate += 1;
+       KTAP_STATS(ks)->mem_allocated += size;
+       preempt_enable();
+
+       return addr;
+}
+
+void kp_free(ktap_state *ks, void *addr)
+{
+       preempt_disable();
+       KTAP_STATS(ks)->nr_mem_free += 1;
+       preempt_enable();
+
+       kfree(addr);
+}
+
+void *kp_reallocv(ktap_state *ks, void *addr, int oldsize, int newsize)
+{
+       void *new_addr;
+
+       new_addr = krealloc(addr, newsize, KTAP_ALLOC_FLAGS);
+       if (unlikely(!new_addr)) {
+               kp_error(ks, "krealloc size %d failed, retry again\n", newsize);
+               printk("ktap krealloc size %d failed, retry again\n", newsize);
+               dump_stack();
+               while (1) {
+                       new_addr = krealloc(addr, newsize, KTAP_ALLOC_FLAGS);
+                       if (new_addr)
+                               break;
+               }
+               kp_printf(ks, "krealloc retry success after failed, exit\n");
+       }
+
+       preempt_disable();
+       if (oldsize == 0) {
+               KTAP_STATS(ks)->nr_mem_allocate += 1;
+       }
+       KTAP_STATS(ks)->mem_allocated += newsize - oldsize;
+       preempt_enable();
+
+       return new_addr;
+}
+
+void *kp_zalloc(ktap_state *ks, int size)
+{
+       void *addr;
+
+       addr = kzalloc(size, KTAP_ALLOC_FLAGS);
+       if (unlikely(!addr)) {
+               kp_error(ks, "kzalloc size %d failed, retry again\n", size);
+               printk("ktap kzalloc size %d failed, retry again\n", size);
+               dump_stack();
+               while (1) {
+                       addr = kzalloc(size, KTAP_ALLOC_FLAGS);
+                       if (addr)
+                               break;
+               }
+               kp_printf(ks, "kzalloc retry success after failed, exit\n");
+       }
+
+       preempt_disable();
+       KTAP_STATS(ks)->nr_mem_allocate += 1;
+       KTAP_STATS(ks)->mem_allocated += size;
+       preempt_enable();
+
+       return addr;
+}
+#endif
+
+void kp_obj_dump(ktap_state *ks, const ktap_value *v)
+{
+       switch (ttype(v)) {
+       case KTAP_TNIL:
+               kp_puts(ks, "NIL");
+               break;
+       case KTAP_TNUMBER:
+               kp_printf(ks, "NUMBER %ld", nvalue(v));
+               break;
+       case KTAP_TBOOLEAN:
+               kp_printf(ks, "BOOLEAN %d", bvalue(v));
+               break;
+       case KTAP_TLIGHTUSERDATA:
+               kp_printf(ks, "LIGHTUSERDATA 0x%lx", (unsigned long)pvalue(v));
+               break;
+       case KTAP_TCFUNCTION:
+               kp_printf(ks, "LIGHTCFCUNTION 0x%lx", (unsigned long)fvalue(v));
+               break;
+       case KTAP_TSHRSTR:
+       case KTAP_TLNGSTR:
+               kp_printf(ks, "SHRSTR #%s", svalue(v));
+               break;
+       case KTAP_TTABLE:
+               kp_printf(ks, "TABLE 0x%lx", (unsigned long)hvalue(v));
+               break;
+        default:
+               kp_printf(ks, "GCVALUE 0x%lx", (unsigned long)gcvalue(v));
+               break;
+       }
+}
+
+#ifdef __KERNEL__
+#include <linux/stacktrace.h>
+#include <linux/module.h>
+#include <linux/kallsyms.h>
+
+static void kp_btrace_dump(ktap_state *ks, ktap_btrace *bt)
+{
+       char str[KSYM_SYMBOL_LEN];
+       unsigned long *entries = (unsigned long *)(bt + 1);
+       int i;
+
+       for (i = 0; i < bt->nr_entries; i++) {
+               unsigned long p = entries[i];
+
+               if (p == ULONG_MAX)
+                       break;
+
+               SPRINT_SYMBOL(str, p);
+               kp_printf(ks, "%s\n", str);
+       }
+}
+
+static int kp_btrace_equal(ktap_btrace *bt1, ktap_btrace *bt2)
+{
+       unsigned long *entries1 = (unsigned long *)(bt1 + 1);
+       unsigned long *entries2 = (unsigned long *)(bt2 + 1);
+       int i;
+
+       if (bt1->nr_entries != bt2->nr_entries)
+               return 0;
+
+       for (i = 0; i < bt1->nr_entries; i++) {
+               if (entries1[i] != entries2[i])
+                       return 0;
+       }
+
+       return 1;
+}
+#endif
+
+void kp_showobj(ktap_state *ks, const ktap_value *v)
+{
+       switch (ttype(v)) {
+       case KTAP_TNIL:
+               kp_puts(ks, "nil");
+               break;
+       case KTAP_TNUMBER:
+               kp_printf(ks, "%ld", nvalue(v));
+               break;
+       case KTAP_TBOOLEAN:
+               kp_puts(ks, (bvalue(v) == 1) ? "true" : "false");
+               break;
+       case KTAP_TLIGHTUSERDATA:
+               kp_printf(ks, "0x%lx", (unsigned long)pvalue(v));
+               break;
+       case KTAP_TCFUNCTION:
+               kp_printf(ks, "0x%lx", (unsigned long)fvalue(v));
+               break;
+       case KTAP_TSHRSTR:
+       case KTAP_TLNGSTR:
+               kp_puts(ks, svalue(v));
+               break;
+       case KTAP_TTABLE:
+               kp_tab_dump(ks, hvalue(v));
+               break;
+#ifdef __KERNEL__
+#ifdef CONFIG_KTAP_FFI
+       case KTAP_TCDATA:
+               kp_cdata_dump(ks, cdvalue(v));
+               break;
+#endif
+       case KTAP_TEVENT:
+               kp_transport_event_write(ks, evalue(v));
+               break;
+       case KTAP_TBTRACE:
+               kp_btrace_dump(ks, btvalue(v));
+               break;
+       case KTAP_TPTABLE:
+               kp_ptab_dump(ks, phvalue(v));
+               break;
+       case KTAP_TSTATDATA:
+               kp_statdata_dump(ks, sdvalue(v));
+               break;
+#endif
+        default:
+               kp_error(ks, "print unknown value type: %d\n", ttype(v));
+               break;
+       }
+}
+
+
+/*
+ * equality of ktap values. ks == NULL means raw equality
+ */
+int kp_equalobjv(ktap_state *ks, const ktap_value *t1, const ktap_value *t2)
+{
+       switch (ttype(t1)) {
+       case KTAP_TNIL:
+               return 1;
+       case KTAP_TNUMBER:
+               return nvalue(t1) == nvalue(t2);
+       case KTAP_TBOOLEAN:
+               return bvalue(t1) == bvalue(t2);  /* true must be 1 !! */
+       case KTAP_TLIGHTUSERDATA:
+               return pvalue(t1) == pvalue(t2);
+       case KTAP_TCFUNCTION:
+               return fvalue(t1) == fvalue(t2);
+       case KTAP_TSHRSTR:
+               return eqshrstr(rawtsvalue(t1), rawtsvalue(t2));
+       case KTAP_TLNGSTR:
+               return kp_tstring_eqlngstr(rawtsvalue(t1), rawtsvalue(t2));
+       case KTAP_TTABLE:
+               if (hvalue(t1) == hvalue(t2))
+                       return 1;
+               else if (ks == NULL)
+                       return 0;
+#ifdef __KERNEL__
+       case KTAP_TBTRACE:
+               return kp_btrace_equal(btvalue(t1), btvalue(t2));
+#endif
+       default:
+               return gcvalue(t1) == gcvalue(t2);
+       }
+
+       return 0;
+}
+
+/*
+ * ktap will not use lua's length operator on table meaning,
+ * also # is not for length operator any more in ktap.
+ */
+int kp_objlen(ktap_state *ks, const ktap_value *v)
+{
+       switch(v->type) {
+       case KTAP_TTABLE:
+               return kp_tab_length(ks, hvalue(v));
+       case KTAP_TSTRING:
+               return rawtsvalue(v)->tsv.len;
+       default:
+               kp_printf(ks, "cannot get length of type %d\n", v->type);
+               return -1;
+       }
+       return 0;
+}
+
+/* need to protect allgc field? */
+ktap_gcobject *kp_newobject(ktap_state *ks, int type, size_t size,
+                           ktap_gcobject **list)
+{
+       ktap_gcobject *o;
+
+       o = kp_malloc(ks, size);
+       if (list == NULL)
+               list = &G(ks)->allgc;
+
+       gch(o)->tt = type;
+       gch(o)->next = *list;
+       *list = o;
+
+       return o;
+}
+
+ktap_upval *kp_newupval(ktap_state *ks)
+{
+       ktap_upval *uv;
+
+       uv = &kp_newobject(ks, KTAP_TUPVAL, sizeof(ktap_upval), NULL)->uv;
+       uv->v = &uv->u.value;
+       set_nil(uv->v);
+       return uv;
+}
+
+static ktap_btrace *kp_newbacktrace(ktap_state *ks, int nr_entries,
+                                   ktap_gcobject **list)
+{
+       ktap_btrace *bt;
+       int size = sizeof(ktap_btrace) + nr_entries * sizeof(unsigned long);
+
+       bt = &kp_newobject(ks, KTAP_TBTRACE, size, list)->bt;
+       bt->nr_entries = nr_entries;
+       return bt;
+}
+
+void kp_objclone(ktap_state *ks, const ktap_value *o, ktap_value *newo,
+                ktap_gcobject **list)
+{
+       if (is_btrace(o)) {
+               int nr_entries = btvalue(o)->nr_entries;
+               ktap_btrace *bt;
+
+               bt = kp_newbacktrace(ks, nr_entries, list);
+               memcpy((unsigned long *)(bt + 1), btvalue(o) + 1,
+                       nr_entries * sizeof(unsigned long));
+               set_btrace(newo, bt);
+       } else {
+               kp_error(ks, "cannot clone ktap value type %d\n", ttype(o));
+               set_nil(newo);
+       }
+}
+
+ktap_closure *kp_newclosure(ktap_state *ks, int n)
+{
+       ktap_closure *cl;
+
+       cl = (ktap_closure *)kp_newobject(ks, KTAP_TCLOSURE, sizeof(*cl), NULL);
+       cl->p = NULL;
+       cl->nupvalues = n;
+       while (n--)
+               cl->upvals[n] = NULL;
+
+       return cl;
+}
+
+static void free_proto(ktap_state *ks, ktap_proto *f)
+{
+       kp_free(ks, f->code);
+       kp_free(ks, f->p);
+       kp_free(ks, f->k);
+       kp_free(ks, f->lineinfo);
+       kp_free(ks, f->locvars);
+       kp_free(ks, f->upvalues);
+       kp_free(ks, f);
+}
+
+ktap_proto *kp_newproto(ktap_state *ks)
+{
+       ktap_proto *f;
+       f = (ktap_proto *)kp_newobject(ks, KTAP_TPROTO, sizeof(*f), NULL);
+       f->k = NULL;
+       f->sizek = 0;
+       f->p = NULL;
+       f->sizep = 0;
+       f->code = NULL;
+       f->cache = NULL;
+       f->sizecode = 0;
+       f->lineinfo = NULL;
+       f->sizelineinfo = 0;
+       f->upvalues = NULL;
+       f->sizeupvalues = 0;
+       f->numparams = 0;
+       f->is_vararg = 0;
+       f->maxstacksize = 0;
+       f->locvars = NULL;
+       f->sizelocvars = 0;
+       f->linedefined = 0;
+       f->lastlinedefined = 0;
+       f->source = NULL;
+       return f;
+}
+
+void kp_free_gclist(ktap_state *ks, ktap_gcobject *o)
+{
+       while (o) {
+               ktap_gcobject *next;
+
+               next = gch(o)->next;
+               switch (gch(o)->tt) {
+               case KTAP_TTABLE:
+                       kp_tab_free(ks, (ktap_tab *)o);
+                       break;
+               case KTAP_TPROTO:
+                       free_proto(ks, (ktap_proto *)o);
+                       break;
+#ifdef __KERNEL__
+               case KTAP_TPTABLE:
+                       kp_ptab_free(ks, (ktap_ptab *)o);
+                       break;
+#endif
+               default:
+                       kp_free(ks, o);
+               }
+               o = next;
+       }
+}
+
+void kp_free_all_gcobject(ktap_state *ks)
+{
+       kp_free_gclist(ks, G(ks)->allgc);
+       G(ks)->allgc = NULL;
+}
+
+/******************************************************************************/
+
+/*
+ * make header for precompiled chunks
+ * if you change the code below be sure to update load_header and FORMAT above
+ * and KTAPC_HEADERSIZE in ktap_types.h
+ */
+void kp_header(u8 *h)
+{
+       int x = 1;
+
+       memcpy(h, KTAP_SIGNATURE, sizeof(KTAP_SIGNATURE) - sizeof(char));
+       h += sizeof(KTAP_SIGNATURE) - sizeof(char);
+       *h++ = (u8)VERSION;
+       *h++ = (u8)FORMAT;
+       *h++ = (u8)(*(char*)&x);                    /* endianness */
+       *h++ = (u8)(sizeof(int));
+       *h++ = (u8)(sizeof(size_t));
+       *h++ = (u8)(sizeof(ktap_instruction));
+       *h++ = (u8)(sizeof(ktap_number));
+       *h++ = (u8)(((ktap_number)0.5) == 0); /* is ktap_number integral? */
+       memcpy(h, KTAPC_TAIL, sizeof(KTAPC_TAIL) - sizeof(char));
+}
+
+
diff --git a/drivers/staging/ktap/runtime/kp_obj.h b/drivers/staging/ktap/runtime/kp_obj.h
new file mode 100644 (file)
index 0000000..02aea07
--- /dev/null
@@ -0,0 +1,29 @@
+#ifndef __KTAP_OBJ_H__
+#define __KTAP_OBJ_H__
+
+#ifdef __KERNEL__
+void *kp_malloc(ktap_state *ks, int size);
+void kp_free(ktap_state *ks, void *addr);
+void *kp_reallocv(ktap_state *ks, void *addr, int oldsize, int newsize);
+void *kp_zalloc(ktap_state *ks, int size);
+#else
+#define kp_malloc(ks, size)                    malloc(size)
+#define kp_free(ks, block)                     free(block)
+#define kp_reallocv(ks, block, osize, nsize)   realloc(block, nsize)
+#endif
+
+void kp_obj_dump(ktap_state *ks, const ktap_value *v);
+void kp_showobj(ktap_state *ks, const ktap_value *v);
+int kp_objlen(ktap_state *ks, const ktap_value *rb);
+void kp_objclone(ktap_state *ks, const ktap_value *o, ktap_value *newo,
+                ktap_gcobject **list);
+ktap_gcobject *kp_newobject(ktap_state *ks, int type, size_t size, ktap_gcobject **list);
+int kp_equalobjv(ktap_state *ks, const ktap_value *t1, const ktap_value *t2);
+ktap_closure *kp_newclosure(ktap_state *ks, int n);
+ktap_proto *kp_newproto(ktap_state *ks);
+ktap_upval *kp_newupval(ktap_state *ks);
+void kp_free_gclist(ktap_state *ks, ktap_gcobject *o);
+void kp_free_all_gcobject(ktap_state *ks);
+void kp_header(u8 *h);
+
+#endif /* __KTAP_OBJ_H__ */
diff --git a/drivers/staging/ktap/runtime/kp_opcode.c b/drivers/staging/ktap/runtime/kp_opcode.c
new file mode 100644 (file)
index 0000000..bdafbb6
--- /dev/null
@@ -0,0 +1,134 @@
+/*
+ * kp_opcode.c
+ *
+ * This file is part of ktap by Jovi Zhangwei.
+ *
+ * Copyright (C) 2012-2013 Jovi Zhangwei <jovi.zhangwei@gmail.com>.
+ *
+ * Copyright (C) 1994-2013 Lua.org, PUC-Rio.
+ *  - The part of code in this file is copied from lua initially.
+ *  - lua's MIT license is compatible with GPL.
+ *
+ * ktap 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.
+ *
+ * ktap is distributed in the hope it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
+ * more details.
+ *
+ * You should have received a copy of the GNU General Public License along with
+ * this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+
+#include "../include/ktap_types.h"
+#include "../include/ktap_opcodes.h"
+
+const char *const ktap_opnames[NUM_OPCODES + 1] = {
+  "MOVE",
+  "LOADK",
+  "LOADKX",
+  "LOADBOOL",
+  "LOADNIL",
+  "GETUPVAL",
+  "GETTABUP",
+  "GETTABLE",
+  "SETTABUP",
+  "SETTABUP_INCR",
+  "SETTABUP_AGGR",
+  "SETUPVAL",
+  "SETTABLE",
+  "SETTABLE_INCR",
+  "SETTABLE_AGGR",
+  "NEWTABLE",
+  "SELF",
+  "ADD",
+  "SUB",
+  "MUL",
+  "DIV",
+  "MOD",
+  "POW",
+  "UNM",
+  "NOT",
+  "LEN",
+  "CONCAT",
+  "JMP",
+  "EQ",
+  "LT",
+  "LE",
+  "TEST",
+  "TESTSET",
+  "CALL",
+  "TAILCALL",
+  "RETURN",
+  "FORLOOP",
+  "FORPREP",
+  "TFORCALL",
+  "TFORLOOP",
+  "SETLIST",
+  "CLOSURE",
+  "VARARG",
+  "EXTRAARG",
+
+  "EVENT",
+  "EVENT_NAME",
+  "EVENT_ARG", /* arg1, arg2 .. arg9 */
+  NULL
+};
+
+
+#define opmode(t,a,b,c,m) (((t)<<7) | ((a)<<6) | ((b)<<4) | ((c)<<2) | (m))
+
+const u8 ktap_opmodes[NUM_OPCODES] = {
+/*       T  A    B       C     mode                opcode       */
+  opmode(0, 1, OpArgR, OpArgN, iABC)            /* OP_MOVE */
+ ,opmode(0, 1, OpArgK, OpArgN, iABx)            /* OP_LOADK */
+ ,opmode(0, 1, OpArgN, OpArgN, iABx)            /* OP_LOADKX */
+ ,opmode(0, 1, OpArgU, OpArgU, iABC)            /* OP_LOADBOOL */
+ ,opmode(0, 1, OpArgU, OpArgN, iABC)            /* OP_LOADNIL */
+ ,opmode(0, 1, OpArgU, OpArgN, iABC)            /* OP_GETUPVAL */
+ ,opmode(0, 1, OpArgU, OpArgK, iABC)            /* OP_GETTABUP */
+ ,opmode(0, 1, OpArgR, OpArgK, iABC)            /* OP_GETTABLE */
+ ,opmode(0, 0, OpArgK, OpArgK, iABC)            /* OP_SETTABUP */
+ ,opmode(0, 0, OpArgK, OpArgK, iABC)            /* OP_SETTABUP_INCR */
+ ,opmode(0, 0, OpArgK, OpArgK, iABC)            /* OP_SETTABUP_AGGR */
+ ,opmode(0, 0, OpArgU, OpArgN, iABC)            /* OP_SETUPVAL */
+ ,opmode(0, 0, OpArgK, OpArgK, iABC)            /* OP_SETTABLE */
+ ,opmode(0, 0, OpArgK, OpArgK, iABC)            /* OP_SETTABUP_INCR */
+ ,opmode(0, 0, OpArgK, OpArgK, iABC)            /* OP_SETTABUP_AGGR */
+ ,opmode(0, 1, OpArgU, OpArgU, iABC)            /* OP_NEWTABLE */
+ ,opmode(0, 1, OpArgR, OpArgK, iABC)            /* OP_SELF */
+ ,opmode(0, 1, OpArgK, OpArgK, iABC)            /* OP_ADD */
+ ,opmode(0, 1, OpArgK, OpArgK, iABC)            /* OP_SUB */
+ ,opmode(0, 1, OpArgK, OpArgK, iABC)            /* OP_MUL */
+ ,opmode(0, 1, OpArgK, OpArgK, iABC)            /* OP_DIV */
+ ,opmode(0, 1, OpArgK, OpArgK, iABC)            /* OP_MOD */
+ ,opmode(0, 1, OpArgK, OpArgK, iABC)            /* OP_POW */
+ ,opmode(0, 1, OpArgR, OpArgN, iABC)            /* OP_UNM */
+ ,opmode(0, 1, OpArgR, OpArgN, iABC)            /* OP_NOT */
+ ,opmode(0, 1, OpArgR, OpArgN, iABC)            /* OP_LEN */
+ ,opmode(0, 1, OpArgR, OpArgR, iABC)            /* OP_CONCAT */
+ ,opmode(0, 0, OpArgR, OpArgN, iAsBx)           /* OP_JMP */
+ ,opmode(1, 0, OpArgK, OpArgK, iABC)            /* OP_EQ */
+ ,opmode(1, 0, OpArgK, OpArgK, iABC)            /* OP_LT */
+ ,opmode(1, 0, OpArgK, OpArgK, iABC)            /* OP_LE */
+ ,opmode(1, 0, OpArgN, OpArgU, iABC)            /* OP_TEST */
+ ,opmode(1, 1, OpArgR, OpArgU, iABC)            /* OP_TESTSET */
+ ,opmode(0, 1, OpArgU, OpArgU, iABC)            /* OP_CALL */
+ ,opmode(0, 1, OpArgU, OpArgU, iABC)            /* OP_TAILCALL */
+ ,opmode(0, 0, OpArgU, OpArgN, iABC)            /* OP_RETURN */
+ ,opmode(0, 1, OpArgR, OpArgN, iAsBx)           /* OP_FORLOOP */
+ ,opmode(0, 1, OpArgR, OpArgN, iAsBx)           /* OP_FORPREP */
+ ,opmode(0, 0, OpArgN, OpArgU, iABC)            /* OP_TFORCALL */
+ ,opmode(0, 1, OpArgR, OpArgN, iAsBx)           /* OP_TFORLOOP */
+ ,opmode(0, 0, OpArgU, OpArgU, iABC)            /* OP_SETLIST */
+ ,opmode(0, 1, OpArgU, OpArgN, iABx)            /* OP_CLOSURE */
+ ,opmode(0, 1, OpArgU, OpArgN, iABC)            /* OP_VARARG */
+ ,opmode(0, 0, OpArgU, OpArgU, iAx)             /* OP_EXTRAARG */
+ ,opmode(0, 1, OpArgR, OpArgK, iABC)            /* OP_EVENT */
+ ,opmode(0, 1, OpArgR, OpArgK, iABC)            /* OP_EVENTNAME */
+ ,opmode(0, 1, OpArgR, OpArgK, iABC)            /* OP_EVENTARG */
+};
+
diff --git a/drivers/staging/ktap/runtime/kp_str.c b/drivers/staging/ktap/runtime/kp_str.c
new file mode 100644 (file)
index 0000000..1af42fe
--- /dev/null
@@ -0,0 +1,460 @@
+/*
+ * kp_str.c - ktap string data struction manipulation
+ *
+ * This file is part of ktap by Jovi Zhangwei.
+ *
+ * Copyright (C) 2012-2013 Jovi Zhangwei <jovi.zhangwei@gmail.com>.
+ *
+ * Copyright (C) 1994-2013 Lua.org, PUC-Rio.
+ *  - The part of code in this file is copied from lua initially.
+ *  - lua's MIT license is compatible with GPL.
+ *
+ * ktap 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.
+ *
+ * ktap is distributed in the hope it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
+ * more details.
+ *
+ * You should have received a copy of the GNU General Public License along with
+ * this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+
+#include "../include/ktap_types.h"
+#include "kp_obj.h"
+#include "kp_str.h"
+
+#ifdef __KERNEL__
+#include <linux/ctype.h>
+#include <linux/module.h>
+#include <linux/kallsyms.h>
+#include "ktap.h"
+#include "kp_transport.h"
+#include "kp_vm.h"
+#endif
+
+#define STRING_MAXSHORTLEN     40
+
+int kp_tstring_cmp(const ktap_string *ls, const ktap_string *rs)
+{
+       const char *l = getstr(ls);
+       size_t ll = ls->tsv.len;
+       const char *r = getstr(rs);
+       size_t lr = rs->tsv.len;
+
+       for (;;) {
+               int temp = strcmp(l, r);
+               if (temp != 0)
+                       return temp;
+               else {
+                       /* strings are equal up to a `\0' */
+
+                       /* index of first `\0' in both strings */
+                       size_t len = strlen(l);
+
+                       /* r is finished? */
+                       if (len == lr)
+                               return (len == ll) ? 0 : 1;
+                       else if (len == ll)  /* l is finished? */
+                               return -1;
+
+                       /*
+                        * both strings longer than `len';
+                        * go on comparing (after the `\0')
+                        */
+                       len++;
+                       l += len; ll -= len; r += len; lr -= len;
+               }
+       }
+}
+
+/*
+ * equality for long strings
+ */
+int kp_tstring_eqlngstr(ktap_string *a, ktap_string *b)
+{
+       size_t len = a->tsv.len;
+
+       return (a == b) || ((len == b->tsv.len) &&
+               (memcmp(getstr(a), getstr(b), len) == 0));
+}
+
+/*
+ * equality for strings
+ */
+int kp_tstring_eqstr(ktap_string *a, ktap_string *b)
+{
+       return (a->tsv.tt == b->tsv.tt) &&
+              (a->tsv.tt == KTAP_TSHRSTR ? eqshrstr(a, b) :
+                               kp_tstring_eqlngstr(a, b));
+}
+
+#define STRING_HASHLIMIT       5
+unsigned int kp_string_hash(const char *str, size_t l, unsigned int seed)
+{
+       unsigned int h = seed ^ l;
+       size_t l1;
+       size_t step = (l >> STRING_HASHLIMIT) + 1;
+
+       for (l1 = l; l1 >= step; l1 -= step)
+               h = h ^ ((h<<5) + (h>>2) + (u8)(str[l1 - 1]));
+
+       return h;
+}
+
+
+/*
+ * resizes the string table
+ */
+void kp_tstring_resize(ktap_state *ks, int newsize)
+{
+       int i;
+       ktap_stringtable *tb = &G(ks)->strt;
+
+       if (newsize > tb->size) {
+               kp_realloc(ks, tb->hash, tb->size, newsize, ktap_gcobject *);
+
+       for (i = tb->size; i < newsize; i++)
+               tb->hash[i] = NULL;
+       }
+
+       /* rehash */
+       for (i = 0; i < tb->size; i++) {
+               ktap_gcobject *p = tb->hash[i];
+               tb->hash[i] = NULL;
+
+               while (p) {
+                       ktap_gcobject *next = gch(p)->next;
+                       unsigned int h = lmod(gco2ts(p)->hash, newsize);
+
+                       gch(p)->next = tb->hash[h];
+                       tb->hash[h] = p;
+                       p = next;
+               }
+       }
+
+       if (newsize < tb->size) {
+               /* shrinking slice must be empty */
+               kp_realloc(ks, tb->hash, tb->size, newsize, ktap_gcobject *);
+       }
+
+       tb->size = newsize;
+}
+
+/*
+ * creates a new string object
+ */
+static ktap_string *createstrobj(ktap_state *ks, const char *str, size_t l,
+                                int tag, unsigned int h, ktap_gcobject **list)
+{
+       ktap_string *ts;
+       size_t totalsize;  /* total size of TString object */
+
+       totalsize = sizeof(ktap_string) + ((l + 1) * sizeof(char));
+       ts = &kp_newobject(ks, tag, totalsize, list)->ts;
+       ts->tsv.len = l;
+       ts->tsv.hash = h;
+       ts->tsv.extra = 0;
+       memcpy(ts + 1, str, l * sizeof(char));
+       ((char *)(ts + 1))[l] = '\0';  /* ending 0 */
+       return ts;
+}
+
+/*
+ * creates a new short string, inserting it into string table
+ */
+static ktap_string *newshrstr(ktap_state *ks, const char *str, size_t l,
+                         unsigned int h)
+{
+       ktap_gcobject **list;
+       ktap_stringtable *tb = &G(ks)->strt;
+       ktap_string *s;
+
+       if (tb->nuse >= (int)tb->size)
+               kp_tstring_resize(ks, tb->size * 2);  /* too crowded */
+
+       list = &tb->hash[lmod(h, tb->size)];
+       s = createstrobj(ks, str, l, KTAP_TSHRSTR, h, list);
+       tb->nuse++;
+       return s;
+}
+
+/*
+ * checks whether short string exists and reuses it or creates a new one
+ */
+static ktap_string *internshrstr(ktap_state *ks, const char *str, size_t l)
+{
+       ktap_gcobject *o;
+       ktap_global_state *g = G(ks);
+       ktap_string *ts;
+       unsigned int h = kp_string_hash(str, l, g->seed);
+       unsigned long __maybe_unused flags;
+
+#ifdef __KERNEL__
+       local_irq_save(flags);
+       arch_spin_lock(&G(ks)->str_lock);
+#endif
+
+       for (o = g->strt.hash[lmod(h, g->strt.size)]; o != NULL;
+            o = gch(o)->next) {
+               ts = rawgco2ts(o);
+
+               if (h == ts->tsv.hash && ts->tsv.len == l &&
+                  (memcmp(str, getstr(ts), l * sizeof(char)) == 0))
+                       goto out;
+       }
+
+       ts = newshrstr(ks, str, l, h);  /* not found; create a new string */
+
+ out:
+#ifdef __KERNEL__
+       arch_spin_unlock(&G(ks)->str_lock);
+       local_irq_restore(flags);
+#endif
+       return ts;
+}
+
+
+/*
+ * new string (with explicit length)
+ */
+ktap_string *kp_tstring_newlstr(ktap_state *ks, const char *str, size_t l)
+{
+       /* short string? */
+       if (l <= STRING_MAXSHORTLEN)
+               return internshrstr(ks, str, l);
+       else
+               return createstrobj(ks, str, l, KTAP_TLNGSTR, G(ks)->seed,
+                                   NULL);
+}
+
+ktap_string *kp_tstring_newlstr_local(ktap_state *ks, const char *str, size_t l)
+{
+       return createstrobj(ks, str, l, KTAP_TLNGSTR, G(ks)->seed,
+                           &ks->gclist);
+}
+
+/*
+ * new zero-terminated string
+ */
+ktap_string *kp_tstring_new(ktap_state *ks, const char *str)
+{
+       return kp_tstring_newlstr(ks, str, strlen(str));
+}
+
+ktap_string *kp_tstring_new_local(ktap_state *ks, const char *str)
+{
+       return createstrobj(ks, str, strlen(str), KTAP_TLNGSTR, G(ks)->seed,
+                           &ks->gclist);
+}
+
+void kp_tstring_freeall(ktap_state *ks)
+{
+       ktap_global_state *g = G(ks);
+       int h;
+
+       for (h = 0; h < g->strt.size; h++) {
+               ktap_gcobject *o, *next;
+               o = g->strt.hash[h];
+               while (o) {
+                       next = gch(o)->next;
+                       kp_free(ks, o);
+                       o = next;
+               }
+               g->strt.hash[h] = NULL;
+       }
+
+       kp_free(ks, g->strt.hash);
+}
+
+/* todo: dump long string, strt table only contain short string */
+void kp_tstring_dump(ktap_state *ks)
+{
+       ktap_gcobject *o;
+       ktap_global_state *g = G(ks);
+       int h;
+
+       kp_printf(ks, "tstring dump: strt size: %d, nuse: %d\n", g->strt.size,
+                                                                g->strt.nuse);
+       for (h = 0; h < g->strt.size; h++) {
+               for (o = g->strt.hash[h]; o != NULL; o = gch(o)->next) {
+                       ktap_string *ts = rawgco2ts(o);
+                       kp_printf(ks, "%s [%d]\n", getstr(ts), (int)ts->tsv.len);
+               }
+       }
+}
+
+#ifdef __KERNEL__
+/* kp_str_fmt - printf implementation */
+
+/* macro to `unsign' a character */
+#define uchar(c)       ((unsigned char)(c))
+
+#define L_ESC          '%'
+
+/* valid flags in a format specification */
+#define FLAGS  "-+ #0"
+
+#define INTFRMLEN      "ll"
+#define INTFRM_T       long long
+
+/*
+ * maximum size of each format specification (such as '%-099.99d')
+ * (+10 accounts for %99.99x plus margin of error)
+ */
+#define MAX_FORMAT     (sizeof(FLAGS) + sizeof(INTFRMLEN) + 10)
+
+static const char *scanformat(ktap_state *ks, const char *strfrmt, char *form)
+{
+       const char *p = strfrmt;
+       while (*p != '\0' && strchr(FLAGS, *p) != NULL)
+               p++;  /* skip flags */
+
+       if ((size_t)(p - strfrmt) >= sizeof(FLAGS)/sizeof(char)) {
+               kp_error(ks, "invalid format (repeated flags)\n");
+               return NULL;
+       }
+
+       if (isdigit(uchar(*p)))
+               p++;  /* skip width */
+
+       if (isdigit(uchar(*p)))
+               p++;  /* (2 digits at most) */
+
+       if (*p == '.') {
+               p++;
+               if (isdigit(uchar(*p)))
+                       p++;  /* skip precision */
+               if (isdigit(uchar(*p)))
+                       p++;  /* (2 digits at most) */
+       }
+
+       if (isdigit(uchar(*p))) {
+               kp_error(ks, "invalid format (width or precision too long)\n");
+               return NULL;
+       }
+
+       *(form++) = '%';
+       memcpy(form, strfrmt, (p - strfrmt + 1) * sizeof(char));
+       form += p - strfrmt + 1;
+       *form = '\0';
+       return p;
+}
+
+
+/*
+ * add length modifier into formats
+ */
+static void addlenmod(char *form, const char *lenmod)
+{
+       size_t l = strlen(form);
+       size_t lm = strlen(lenmod);
+       char spec = form[l - 1];
+
+       strcpy(form + l - 1, lenmod);
+       form[l + lm - 1] = spec;
+       form[l + lm] = '\0';
+}
+
+
+static void ktap_argerror(ktap_state *ks, int narg, const char *extramsg)
+{
+       kp_error(ks, "bad argument #%d: (%s)\n", narg, extramsg);
+}
+
+int kp_str_fmt(ktap_state *ks, struct trace_seq *seq)
+{
+       int arg = 1;
+       size_t sfl;
+       ktap_value *arg_fmt = kp_arg(ks, 1);
+       int argnum = kp_arg_nr(ks);
+       const char *strfrmt, *strfrmt_end;
+
+       strfrmt = svalue(arg_fmt);
+       sfl = rawtsvalue(arg_fmt)->tsv.len;
+       strfrmt_end = strfrmt + sfl;
+
+       while (strfrmt < strfrmt_end) {
+               if (*strfrmt != L_ESC)
+                       trace_seq_putc(seq, *strfrmt++);
+               else if (*++strfrmt == L_ESC)
+                       trace_seq_putc(seq, *strfrmt++);
+               else { /* format item */
+                       char form[MAX_FORMAT];
+
+                       if (++arg > argnum) {
+                               ktap_argerror(ks, arg, "no value");
+                               return -1;
+                       }
+
+                       strfrmt = scanformat(ks, strfrmt, form);
+                       switch (*strfrmt++) {
+                       case 'c':
+                               trace_seq_printf(seq, form,
+                                                nvalue(kp_arg(ks, arg)));
+                               break;
+                       case 'd':  case 'i': {
+                               ktap_number n = nvalue(kp_arg(ks, arg));
+                               INTFRM_T ni = (INTFRM_T)n;
+                               addlenmod(form, INTFRMLEN);
+                               trace_seq_printf(seq, form, ni);
+                               break;
+                       }
+                       case 'p': {
+                               char str[KSYM_SYMBOL_LEN];
+                               SPRINT_SYMBOL(str, nvalue(kp_arg(ks, arg)));
+                               _trace_seq_puts(seq, str);
+                               break;
+                       }
+                       case 'o':  case 'u':  case 'x':  case 'X': {
+                               ktap_number n = nvalue(kp_arg(ks, arg));
+                               unsigned INTFRM_T ni = (unsigned INTFRM_T)n;
+                               addlenmod(form, INTFRMLEN);
+                               trace_seq_printf(seq, form, ni);
+                               break;
+                       }
+                       case 's': {
+                               ktap_value *v = kp_arg(ks, arg);
+                               const char *s;
+                               size_t l;
+
+                               if (is_nil(v)) {
+                                       _trace_seq_puts(seq, "nil");
+                                       return 0;
+                               }
+
+                               if (is_event(v)) {
+                                       kp_event_tostring(ks, seq);
+                                       return 0;
+                               }
+
+                               s = svalue(v);
+                               l = rawtsvalue(v)->tsv.len;
+                               if (!strchr(form, '.') && l >= 100) {
+                                       /*
+                                        * no precision and string is too long
+                                        * to be formatted;
+                                        * keep original string
+                                        */
+                                       _trace_seq_puts(seq, s);
+                                       break;
+                               } else {
+                                       trace_seq_printf(seq, form, s);
+                                       break;
+                               }
+                       }
+                       default: /* also treat cases `pnLlh' */
+                               kp_error(ks, "invalid option " KTAP_QL("%%%c")
+                                            " to " KTAP_QL("format"),
+                                            *(strfrmt - 1));
+                       }
+               }
+       }
+
+       return 0;
+}
+#endif
+
diff --git a/drivers/staging/ktap/runtime/kp_str.h b/drivers/staging/ktap/runtime/kp_str.h
new file mode 100644 (file)
index 0000000..9fc8da1
--- /dev/null
@@ -0,0 +1,20 @@
+#ifndef __KTAP_STR_H__
+#define __KTAP_STR_H__
+
+ktap_string *kp_tstring_newlstr(ktap_state *ks, const char *str, size_t l);
+ktap_string *kp_tstring_newlstr_local(ktap_state *ks, const char *str, size_t l);
+ktap_string *kp_tstring_new(ktap_state *ks, const char *str);
+ktap_string *kp_tstring_new_local(ktap_state *ks, const char *str);
+int kp_tstring_eqstr(ktap_string *a, ktap_string *b);
+unsigned int kp_string_hash(const char *str, size_t l, unsigned int seed);
+int kp_tstring_eqlngstr(ktap_string *a, ktap_string *b);
+int kp_tstring_cmp(const ktap_string *ls, const ktap_string *rs);
+void kp_tstring_resize(ktap_state *ks, int newsize);
+void kp_tstring_freeall(ktap_state *ks);
+
+#ifdef __KERNEL__
+#include <linux/trace_seq.h>
+int kp_str_fmt(ktap_state *ks, struct trace_seq *seq);
+#endif
+
+#endif /* __KTAP_STR_H__ */
diff --git a/drivers/staging/ktap/runtime/kp_tab.c b/drivers/staging/ktap/runtime/kp_tab.c
new file mode 100644 (file)
index 0000000..422f401
--- /dev/null
@@ -0,0 +1,1396 @@
+/*
+ * kp_tab.c - ktap table data structure manipulation
+ *
+ * This file is part of ktap by Jovi Zhangwei.
+ *
+ * Copyright (C) 2012-2013 Jovi Zhangwei <jovi.zhangwei@gmail.com>.
+ *
+ * Copyright (C) 1994-2013 Lua.org, PUC-Rio.
+ *  - The part of code in this file is copied from lua initially.
+ *  - lua's MIT license is compatible with GPL.
+ *
+ * ktap 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.
+ *
+ * ktap is distributed in the hope it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
+ * more details.
+ *
+ * You should have received a copy of the GNU General Public License along with
+ * this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+
+#include "../include/ktap_types.h"
+
+#ifdef __KERNEL__
+#include <linux/spinlock.h>
+#include <linux/module.h>
+#include <linux/kallsyms.h>
+#include <linux/sort.h>
+#include "ktap.h"
+#include "kp_vm.h"
+#else
+static inline void sort(void *base, size_t num, size_t size,
+                       int (*cmp_func)(const void *, const void *),
+                       void (*swap_func)(void *, void *, int size))
+{}
+#endif
+
+#include "kp_obj.h"
+#include "kp_str.h"
+
+#ifdef __KERNEL__
+#define kp_tab_lock_init(t)                                            \
+       do {                                                            \
+               (t)->lock = (arch_spinlock_t)__ARCH_SPIN_LOCK_UNLOCKED; \
+       } while (0)
+#define kp_tab_lock(t)                                         \
+       do {                                                            \
+               local_irq_save(flags);                                  \
+               arch_spin_lock(&(t)->lock);                             \
+       } while (0)
+#define kp_tab_unlock(t)                                               \
+       do {                                                            \
+               arch_spin_unlock(&(t)->lock);                           \
+               local_irq_restore(flags);                               \
+       } while (0)
+
+#else
+#define kp_tab_lock_init(t)
+#define kp_tab_lock(t)
+#define kp_tab_unlock(t)
+#endif
+
+#define MAXBITS         30
+#define MAXASIZE        (1 << MAXBITS)
+
+
+#define NILCONSTANT     {NULL}, KTAP_TNIL
+const struct ktap_value ktap_nilobjectv = {NILCONSTANT};
+#define ktap_nilobject (&ktap_nilobjectv)
+
+static const ktap_tnode dummynode_ = {
+       {NILCONSTANT}, /* value */
+       {NULL, {NILCONSTANT}}, /* key */
+};
+
+#define gnode(t,i)      (&(t)->node[i])
+#define gkey(n)         (&(n)->i_key.tvk)
+#define gval(n)         (&(n)->i_val)
+#define gnext(n)        ((n)->i_key.next)
+
+#define twoto(x)        (1<<(x))
+#define sizenode(t)    (twoto((t)->lsizenode))
+
+#define hashpow2(t,n)           (gnode(t, lmod((n), sizenode(t))))
+
+#define hashmod(t,n)           (gnode(t, ((n) % ((sizenode(t)-1)|1))))
+
+#define hashstr(t,str)          hashpow2(t, (str)->tsv.hash)
+#define hashboolean(t,p)        hashpow2(t, p)
+#define hashnum(t, n)          hashmod(t, (unsigned int)n)
+#define hashpointer(t,p)       hashmod(t, (unsigned long)(p))
+
+#define dummynode      (&dummynode_)
+#define isdummy(n)     ((n) == dummynode)
+
+static void table_setint(ktap_state *ks, ktap_tab *t, int key, ktap_value *v);
+static ktap_value *table_set(ktap_state *ks, ktap_tab *t,
+                            const ktap_value *key);
+static void setnodevector(ktap_state *ks, ktap_tab *t, int size);
+
+static int ceillog2(unsigned int x)
+{
+       static const u8 log_2[256] = {
+       0,1,2,2,3,3,3,3,4,4,4,4,4,4,4,4,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,
+       6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,
+       7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,
+       7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,
+       8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,
+       8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,
+       8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,
+       8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8
+       };
+
+       int l = 0;
+
+       x--;
+       while (x >= 256) { l += 8; x >>= 8; }
+       return l + log_2[x];
+}
+
+#ifdef __KERNEL__
+static inline ktap_stat_data *_read_sd(const ktap_value *v,
+                                   ktap_tnode *hnode, ktap_stat_data *hsd)
+{
+       ktap_tnode *node = container_of(v, ktap_tnode, i_val);
+       return hsd + (node - hnode);
+}
+
+static inline ktap_stat_data *read_sd(ktap_tab *t, const ktap_value *v)
+{
+       if (v >= &t->array[0] && v < &t->array[t->sizearray])
+               return &t->sd_arr[v - &t->array[0]];
+       else
+               return _read_sd(v, t->node, t->sd_rec);
+}
+
+#else
+static inline ktap_stat_data *_read_sd(const ktap_value *v,
+                                   ktap_tnode *hnode, ktap_stat_data *hsd)
+{
+       return NULL;
+}
+
+static inline ktap_stat_data *read_sd(ktap_tab *t, const ktap_value *v)
+{
+       return NULL;
+}
+#endif
+
+
+ktap_tab *kp_tab_new(ktap_state *ks)
+{
+       ktap_tab *t = &kp_newobject(ks, KTAP_TTABLE, sizeof(ktap_tab),
+                                     NULL)->h;
+       t->flags = (u8)(~0);
+       t->array = NULL;
+       t->sizearray = 0;
+       t->node = (ktap_tnode *)dummynode;
+       t->gclist = NULL;
+       t->with_stats = 0;
+       t->sd_arr = NULL;
+       t->sd_rec = NULL;
+       setnodevector(ks, t, 0);
+
+       t->sorted = NULL;
+       t->sort_head = NULL;
+
+       kp_tab_lock_init(t);
+       return t;
+}
+
+static const ktap_value *table_getint(ktap_tab *t, int key)
+{
+       ktap_tnode *n;
+
+       if ((unsigned int)(key - 1) < (unsigned int)t->sizearray)
+               return &t->array[key - 1];
+
+       n = hashnum(t, key);
+       do {
+               if (is_number(gkey(n)) && nvalue(gkey(n)) == key)
+                       return gval(n);
+               else
+                       n = gnext(n);
+       } while (n);
+
+       return ktap_nilobject;
+}
+
+const ktap_value *kp_tab_getint(ktap_tab *t, int key)
+{
+       const ktap_value *val;
+       unsigned long __maybe_unused flags;
+
+       kp_tab_lock(t);
+       val = table_getint(t, key);
+       kp_tab_unlock(t);
+
+       return val;
+}
+
+static ktap_tnode *mainposition (const ktap_tab *t, const ktap_value *key)
+{
+       switch (ttype(key)) {
+       case KTAP_TNUMBER:
+               return hashnum(t, nvalue(key));
+       case KTAP_TLNGSTR: {
+               ktap_string *s = rawtsvalue(key);
+               if (s->tsv.extra == 0) {  /* no hash? */
+                       s->tsv.hash = kp_string_hash(getstr(s), s->tsv.len,
+                                                    s->tsv.hash);
+                       s->tsv.extra = 1;  /* now it has its hash */
+               }
+               return hashstr(t, rawtsvalue(key));
+               }
+       case KTAP_TSHRSTR:
+               return hashstr(t, rawtsvalue(key));
+       case KTAP_TBOOLEAN:
+               return hashboolean(t, bvalue(key));
+       case KTAP_TLIGHTUSERDATA:
+               return hashpointer(t, pvalue(key));
+       case KTAP_TCFUNCTION:
+               return hashpointer(t, fvalue(key));
+       case KTAP_TBTRACE: {
+               /* use first entry as hash key, cannot use gcvalue as key */
+               unsigned long *entries = (unsigned long *)(btvalue(key) + 1);
+               return hashpointer(t, entries[0]);
+               }
+       default:
+               return hashpointer(t, gcvalue(key));
+       }
+}
+
+static int arrayindex(const ktap_value *key)
+{
+       if (is_number(key)) {
+               ktap_number n = nvalue(key);
+               int k = (int)n;
+               if ((ktap_number)k == n)
+                       return k;
+       }
+
+       /* `key' did not match some condition */
+       return -1;
+}
+
+/*
+ * returns the index of a `key' for table traversals. First goes all
+ * elements in the array part, then elements in the hash part. The
+ * beginning of a traversal is signaled by -1.
+ */
+static int findindex(ktap_state *ks, ktap_tab *t, StkId key)
+{
+       int i;
+
+       if (is_nil(key))
+               return -1;  /* first iteration */
+
+       i = arrayindex(key);
+       if (i > 0 && i <= t->sizearray)  /* is `key' inside array part? */
+               return i - 1;  /* yes; that's the index (corrected to C) */
+       else {
+               ktap_tnode *n = mainposition(t, key);
+               for (;;) {  /* check whether `key' is somewhere in the chain */
+                       /* key may be dead already, but it is ok to use it in `next' */
+                       if (kp_equalobjv(ks, gkey(n), key)) {
+                               i = n - gnode(t, 0);  /* key index in hash table */
+                               /* hash elements are numbered after array ones */
+                               return i + t->sizearray;
+                       } else
+                               n = gnext(n);
+
+                       if (n == NULL)
+                               /* key not found */
+                               kp_error(ks, "invalid table key to next");
+               }
+       }
+}
+
+int kp_tab_next(ktap_state *ks, ktap_tab *t, StkId key)
+{
+       unsigned long __maybe_unused flags;
+       int i;
+
+       kp_tab_lock(t);
+
+       i = findindex(ks, t, key);  /* find original element */
+
+       for (i++; i < t->sizearray; i++) {  /* try first array part */
+               if (!is_nil(&t->array[i])) {  /* a non-nil value? */
+                       set_number(key, i+1);
+                       set_obj(key+1, &t->array[i]);
+                       kp_tab_unlock(t);
+                       return 1;
+               }
+       }
+
+       for (i -= t->sizearray; i < sizenode(t); i++) {  /* then hash part */
+               if (!is_nil(gval(gnode(t, i)))) {  /* a non-nil value? */
+                       set_obj(key, gkey(gnode(t, i)));
+                       set_obj(key+1, gval(gnode(t, i)));
+                       kp_tab_unlock(t);
+                       return 1;
+               }
+       }
+
+       kp_tab_unlock(t);
+       return 0;  /* no more elements */
+}
+
+#ifdef __KERNEL__
+int kp_tab_sort_next(ktap_state *ks, ktap_tab *t, StkId key)
+{
+       unsigned long __maybe_unused flags;
+       ktap_tnode *node = t->sort_head;
+
+       kp_tab_lock(t);
+
+       if (is_nil(key)) {
+               /* first iteration */
+               set_obj(key, gkey(node));
+               set_obj(key + 1, gval(node));
+               kp_tab_unlock(t);
+               return 1;
+       }
+
+       while (node && !is_nil(gval(node))) {
+               if (kp_equalobjv(ks, gkey(node), key)) {
+                       node = gnext(node);
+                       if (!node)
+                               goto out;
+
+                       set_obj(key, gkey(node));
+                       set_obj(key + 1, gval(node));
+                       kp_tab_unlock(t);
+                       return 1;
+               }
+               node = gnext(node);
+       }
+
+ out:
+       kp_tab_unlock(t);
+       return 0;  /* no more elements */
+}
+
+
+static int default_compare(ktap_state *ks, ktap_closure *cmp_func,
+                               ktap_value *v1, ktap_value *v2)
+{
+       return nvalue(v1) < nvalue(v2);
+}
+
+static int closure_compare(ktap_state *ks, ktap_closure *cmp_func,
+                               ktap_value *v1, ktap_value *v2)
+{
+       ktap_value *func;
+       int res;
+
+       func = ks->top;
+       set_closure(ks->top++, cmp_func);
+       set_obj(ks->top++, v1);
+       set_obj(ks->top++, v2);
+
+       kp_call(ks, func, 1);
+
+       res = !is_false(ks->top - 1);
+
+       ks->top = func; /* restore ks->top */
+
+       return res;
+}
+
+static void insert_sorted_list(ktap_state *ks, ktap_tab *t,
+                               ktap_closure *cmp_func,
+                               ktap_value *key, ktap_value *val)
+{
+       ktap_tnode *node = t->sort_head;
+       ktap_tnode *newnode, *prevnode = NULL;
+       int (*compare)(ktap_state *ks, ktap_closure *cmp_func,
+                       ktap_value *v1, ktap_value *v2);
+       int i = 0;
+
+       if (is_nil(gval(node))) {
+               *gkey(node) = *key;
+               *gval(node) = *val;
+               return;
+       }
+
+       if (!cmp_func)
+               compare = default_compare;
+       else
+               compare = closure_compare;
+
+       while (node) {
+               //if (nvalue(gval(node)) < nvalue(val)) {
+               if (compare(ks, cmp_func, gval(node), val)) {
+                       prevnode = node;
+                       node = gnext(node);
+                       continue;
+               } else
+                       break;
+       }
+
+       /* find free position */
+       while (!is_nil(gval(&t->sorted[i]))) {
+               i++;
+       }
+
+       newnode = &t->sorted[i];
+       *gkey(newnode) = *key;
+       *gval(newnode) = *val;
+       gnext(newnode) = node;
+       if (prevnode)
+               gnext(prevnode) = newnode;
+       else
+               t->sort_head = newnode;
+}
+
+void kp_tab_sort(ktap_state *ks, ktap_tab *t, ktap_closure *cmp_func)
+{
+       unsigned long __maybe_unused flags;
+       int size = t->sizearray + sizenode(t);
+       int i;
+
+       kp_tab_lock(t);
+
+       kp_realloc(ks, t->sorted, 0, size, ktap_tnode);
+       memset(t->sorted, 0, size * sizeof(ktap_tnode));
+       t->sort_head = t->sorted;
+
+       for (i = 0; i < t->sizearray; i++) {
+               ktap_value *v = &t->array[i];
+               ktap_value key;
+
+               if (!is_nil(v)) {
+                       set_number(&key, i + 1);
+                       insert_sorted_list(ks, t, cmp_func, &key, v);
+               }
+       }
+
+       for (i = 0; i < sizenode(t); i++) {
+               ktap_tnode *node = &t->node[i];
+
+               if (is_nil(gkey(node)))
+                       continue;
+
+               insert_sorted_list(ks, t, cmp_func, gkey(node), gval(node));
+       }
+
+       kp_tab_unlock(t);
+}
+#endif
+
+static int computesizes (int nums[], int *narray)
+{
+       int i;
+       int twotoi;  /* 2^i */
+       int a = 0;  /* number of elements smaller than 2^i */
+       int na = 0;  /* number of elements to go to array part */
+       int n = 0;  /* optimal size for array part */
+
+       for (i = 0, twotoi = 1; twotoi/2 < *narray; i++, twotoi *= 2) {
+               if (nums[i] > 0) {
+                       a += nums[i];
+                       /* more than half elements present? */
+                       if (a > twotoi/2) {
+                               /* optimal size (till now) */
+                               n = twotoi;
+                               /*
+                                * all elements smaller than n will go to
+                                * array part
+                                */
+                               na = a;
+                       }
+               }
+               if (a == *narray)
+                       break;  /* all elements already counted */
+       }
+       *narray = n;
+       return na;
+}
+
+
+static int countint(const ktap_value *key, int *nums)
+{
+       int k = arrayindex(key);
+
+       /* is `key' an appropriate array index? */
+       if (0 < k && k <= MAXASIZE) {
+               nums[ceillog2(k)]++;  /* count as such */
+               return 1;
+       } else
+               return 0;
+}
+
+
+static int numusearray(const ktap_tab *t, int *nums)
+{
+       int lg;
+       int ttlg;  /* 2^lg */
+       int ause = 0;  /* summation of `nums' */
+       int i = 1;  /* count to traverse all array keys */
+
+       /* for each slice */
+       for (lg=0, ttlg=1; lg <= MAXBITS; lg++, ttlg *= 2) {
+               int lc = 0;  /* counter */
+               int lim = ttlg;
+
+               if (lim > t->sizearray) {
+                       lim = t->sizearray;  /* adjust upper limit */
+                       if (i > lim)
+                               break;  /* no more elements to count */
+               }
+
+               /* count elements in range (2^(lg-1), 2^lg] */
+               for (; i <= lim; i++) {
+                       if (!is_nil(&t->array[i-1]))
+                               lc++;
+               }
+               nums[lg] += lc;
+               ause += lc;
+       }
+       return ause;
+}
+
+static int numusehash(const ktap_tab *t, int *nums, int *pnasize)
+{
+       int totaluse = 0;  /* total number of elements */
+       int ause = 0;  /* summation of `nums' */
+       int i = sizenode(t);
+
+       while (i--) {
+               ktap_tnode *n = &t->node[i];
+               if (!is_nil(gval(n))) {
+                       ause += countint(gkey(n), nums);
+                       totaluse++;
+               }
+       }
+
+       *pnasize += ause;
+       return totaluse;
+}
+
+static void update_array_sd(ktap_tab *t)
+{
+       int i;
+
+       for (i = 0; i < t->sizearray; i++) {
+               ktap_value *v = &t->array[i];
+
+               if (!is_statdata(v))
+                       continue;
+
+               set_statdata(v, &t->sd_arr[i]);
+       }
+}
+
+static void setarrayvector(ktap_state *ks, ktap_tab *t, int size)
+{
+       int i;
+
+       kp_realloc(ks, t->array, t->sizearray, size, ktap_value);
+       if (t->with_stats) {
+               kp_realloc(ks, t->sd_arr, t->sizearray, size,
+                               ktap_stat_data);
+               update_array_sd(t);
+       }
+
+       for (i = t->sizearray; i < size; i++)
+               set_nil(&t->array[i]);
+
+       t->sizearray = size;
+}
+
+static void setnodevector(ktap_state *ks, ktap_tab *t, int size)
+{
+       int lsize;
+
+       if (size == 0) {  /* no elements to hash part? */
+               t->node = (ktap_tnode *)dummynode;  /* use common `dummynode' */
+               lsize = 0;
+       } else {
+               int i;
+               lsize = ceillog2(size);
+               if (lsize > MAXBITS) {
+                       kp_error(ks, "table overflow\n");
+                       return;
+               }
+
+               size = twoto(lsize);
+               t->node = kp_malloc(ks, size * sizeof(ktap_tnode));
+               if (t->with_stats)
+                       t->sd_rec = kp_malloc(ks, size *
+                                               sizeof(ktap_stat_data));
+               for (i = 0; i < size; i++) {
+                       ktap_tnode *n = gnode(t, i);
+                       gnext(n) = NULL;
+                       set_nil(gkey(n));
+                       set_nil(gval(n));
+               }
+       }
+
+       t->lsizenode = (u8)lsize;
+       t->lastfree = gnode(t, size);  /* all positions are free */
+}
+
+static void table_resize(ktap_state *ks, ktap_tab *t, int nasize, int nhsize)
+{
+       int oldasize = t->sizearray;
+       int oldhsize = t->lsizenode;
+       ktap_tnode *nold = t->node;  /* save old hash */
+       ktap_stat_data *sd_rec_old = t->sd_rec;  /* save stat_data */
+       int i;
+
+#ifdef __KERNEL__
+       kp_verbose_printf(ks, "table resize, nasize: %d, nhsize: %d\n",
+                               nasize, nhsize);
+#endif
+
+       if (nasize > oldasize)  /* array part must grow? */
+               setarrayvector(ks, t, nasize);
+
+       /* create new hash part with appropriate size */
+       setnodevector(ks, t, nhsize);
+
+       if (nasize < oldasize) {  /* array part must shrink? */
+               t->sizearray = nasize;
+               /* re-insert elements from vanishing slice */
+               for (i = nasize; i < oldasize; i++) {
+                       if (!is_nil(&t->array[i])) {
+                               ktap_value *v;
+                               v = (ktap_value *)table_getint(t, i + 1);
+                               set_obj(v, &t->array[i]);
+
+                               if (t->with_stats) {
+                                       *read_sd(t, v) = t->sd_arr[i];
+                                       set_statdata(v, read_sd(t, v));
+                               }
+                       }
+               }
+
+               /* shrink array */
+               kp_realloc(ks, t->array, oldasize, nasize, ktap_value);
+               if (t->with_stats) {
+                       kp_realloc(ks, t->sd_arr, oldasize, nasize,
+                                       ktap_stat_data);
+                       update_array_sd(t);
+               }
+       }
+
+       /* re-insert elements from hash part */
+       for (i = twoto(oldhsize) - 1; i >= 0; i--) {
+               ktap_tnode *old = nold + i;
+               if (!is_nil(gval(old))) {
+                       ktap_value *v = table_set(ks, t, gkey(old));
+                       /*
+                        * doesn't need barrier/invalidate cache, as entry was
+                        * already present in the table
+                        */
+                       set_obj(v, gval(old));
+
+                       if (t->with_stats) {
+                               ktap_stat_data *sd;
+
+                               sd = read_sd(t, v);
+                               *sd = *_read_sd(gval(old), nold, sd_rec_old);
+                               set_statdata(v, sd);
+                       }
+               }
+       }
+
+       if (!isdummy(nold)) {
+               kp_free(ks, nold); /* free old array */
+               kp_free(ks, sd_rec_old);
+       }
+}
+
+void kp_tab_resize(ktap_state *ks, ktap_tab *t, int nasize, int nhsize)
+{
+       unsigned long __maybe_unused flags;
+
+       kp_tab_lock(t);
+       table_resize(ks, t, nasize, nhsize);
+       kp_tab_unlock(t);
+}
+
+void kp_tab_resizearray(ktap_state *ks, ktap_tab *t, int nasize)
+{
+       unsigned long __maybe_unused flags;
+       int nsize;
+
+       kp_tab_lock(t);
+
+       nsize = isdummy(t->node) ? 0 : sizenode(t);
+       table_resize(ks, t, nasize, nsize);
+
+       kp_tab_unlock(t);
+}
+
+static void rehash(ktap_state *ks, ktap_tab *t, const ktap_value *ek)
+{
+       int nasize, na;
+       /* nums[i] = number of keys with 2^(i-1) < k <= 2^i */
+       int nums[MAXBITS+1];
+       int i;
+       int totaluse;
+
+       for (i = 0; i <= MAXBITS; i++)
+               nums[i] = 0;  /* reset counts */
+
+       nasize = numusearray(t, nums);  /* count keys in array part */
+       totaluse = nasize;  /* all those keys are integer keys */
+       totaluse += numusehash(t, nums, &nasize);  /* count keys in hash part */
+       /* count extra key */
+       nasize += countint(ek, nums);
+       totaluse++;
+       /* compute new size for array part */
+       na = computesizes(nums, &nasize);
+       /* resize the table to new computed sizes */
+       table_resize(ks, t, nasize, totaluse - na);
+}
+
+
+static ktap_tnode *getfreepos(ktap_tab *t)
+{
+       while (t->lastfree > t->node) {
+               t->lastfree--;
+               if (is_nil(gkey(t->lastfree)))
+                       return t->lastfree;
+       }
+       return NULL;  /* could not find a free place */
+}
+
+
+static ktap_value *table_newkey(ktap_state *ks, ktap_tab *t,
+                               const ktap_value *key)
+{
+       ktap_tnode *mp;
+       ktap_value newkey;
+
+       mp = mainposition(t, key);
+       if (!is_nil(gval(mp)) || isdummy(mp)) {  /* main position is taken? */
+               ktap_tnode *othern;
+               ktap_tnode *n = getfreepos(t);  /* get a free place */
+               if (n == NULL) {  /* cannot find a free place? */
+                       rehash(ks, t, key);  /* grow table */
+                       /* insert key into grown table */
+                       return table_set(ks, t, key);
+               }
+
+               othern = mainposition(t, gkey(mp));
+               if (othern != mp) {
+                       /* is colliding node out of its main position? */
+
+                       /* move colliding node into free position */
+                       while (gnext(othern) != mp)
+                               othern = gnext(othern);  /* find previous */
+
+                       /* redo the chain with `n' in place of `mp' */
+                       gnext(othern) = n;
+
+                       /* copy colliding node into free pos */
+                       *n = *mp;
+
+                       if (t->with_stats) {
+                               ktap_stat_data *sd = read_sd(t, gval(n));
+                               *sd = *read_sd(t, gval(mp));
+                               set_statdata(gval(n), sd);
+                       }
+
+                       gnext(mp) = NULL;  /* now `mp' is free */
+                       set_nil(gval(mp));
+               } else {
+                       /* colliding node is in its own main position */
+
+                       /* new node will go into free position */
+                       gnext(n) = gnext(mp);  /* chain new position */
+                       gnext(mp) = n;
+                       mp = n;
+               }
+       }
+
+       /* special handling for cloneable object, maily for btrace object */
+       if (is_needclone(key))
+               kp_objclone(ks, key, &newkey, &t->gclist);
+       else
+               newkey = *key;
+
+       set_obj(gkey(mp), &newkey);
+       return gval(mp);
+}
+
+
+/*
+ * search function for short strings
+ */
+static const ktap_value *table_getstr(ktap_tab *t, ktap_string *key)
+{
+       ktap_tnode *n = hashstr(t, key);
+
+       do {  /* check whether `key' is somewhere in the chain */
+               if (is_shrstring(gkey(n)) && eqshrstr(rawtsvalue(gkey(n)),
+                                                               key))
+                       return gval(n);  /* that's it */
+               else
+                       n = gnext(n);
+       } while (n);
+
+       return ktap_nilobject;
+}
+
+
+/*
+ * main search function
+ */
+static const ktap_value *table_get(ktap_tab *t, const ktap_value *key)
+{
+       switch (ttype(key)) {
+       case KTAP_TNIL:
+               return ktap_nilobject;
+       case KTAP_TSHRSTR:
+               return table_getstr(t, rawtsvalue(key));
+       case KTAP_TNUMBER: {
+               ktap_number n = nvalue(key);
+               int k = (int)n;
+               if ((ktap_number)k == nvalue(key)) /* index is int? */
+                       return table_getint(t, k);  /* use specialized version */
+               /* else go through */
+       }
+       default: {
+               ktap_tnode *n = mainposition(t, key);
+               do {  /* check whether `key' is somewhere in the chain */
+                       if (rawequalobj(gkey(n), key))
+                               return gval(n);  /* that's it */
+                       else
+                               n = gnext(n);
+               } while (n);
+
+               return ktap_nilobject;
+       }
+       }
+}
+
+const ktap_value *kp_tab_get(ktap_tab *t, const ktap_value *key)
+{
+       const ktap_value *val;
+       unsigned long __maybe_unused flags;
+
+       kp_tab_lock(t);
+       val = table_get(t, key);
+       kp_tab_unlock(t);
+
+       return val;
+}
+
+static ktap_value *table_set(ktap_state *ks, ktap_tab *t,
+                            const ktap_value *key)
+{
+       const ktap_value *p = table_get(t, key);
+
+       if (p != ktap_nilobject)
+               return (ktap_value *)p;
+       else
+               return table_newkey(ks, t, key);
+}
+
+void kp_tab_setvalue(ktap_state *ks, ktap_tab *t,
+                      const ktap_value *key, ktap_value *val)
+{
+       unsigned long __maybe_unused flags;
+
+       if (is_nil(key)) {
+               kp_printf(ks, "table index is nil\n");
+               kp_exit(ks);
+               return;
+       }
+
+       kp_tab_lock(t);
+       set_obj(table_set(ks, t, key), val);
+       kp_tab_unlock(t);
+}
+
+static void table_setint(ktap_state *ks, ktap_tab *t, int key, ktap_value *v)
+{
+       const ktap_value *p;
+       ktap_value *cell;
+
+       p = table_getint(t, key);
+
+       if (p != ktap_nilobject)
+               cell = (ktap_value *)p;
+       else {
+               ktap_value k;
+               set_number(&k, key);
+               cell = table_newkey(ks, t, &k);
+       }
+
+       set_obj(cell, v);
+}
+
+void kp_tab_setint(ktap_state *ks, ktap_tab *t, int key, ktap_value *val)
+{
+       unsigned long __maybe_unused flags;
+
+       kp_tab_lock(t);
+       table_setint(ks, t, key, val);
+       kp_tab_unlock(t);
+}
+
+void kp_tab_atomic_inc(ktap_state *ks, ktap_tab *t, ktap_value *key, int n)
+{
+       unsigned long __maybe_unused flags;
+       ktap_value *v;
+
+       if (is_nil(key)) {
+               kp_printf(ks, "table index is nil\n");
+               kp_exit(ks);
+               return;
+       }
+
+       kp_tab_lock(t);
+
+       v = table_set(ks, t, key);
+       if (is_nil(v)) {
+               set_number(v, n);
+       } else
+               set_number(v, nvalue(v) + n);
+
+       kp_tab_unlock(t);
+}
+
+int kp_tab_length(ktap_state *ks, ktap_tab *t)
+{
+       unsigned long __maybe_unused flags;
+       int i, len = 0;
+
+       kp_tab_lock(t);
+
+       for (i = 0; i < t->sizearray; i++) {
+               ktap_value *v = &t->array[i];
+
+               if (is_nil(v))
+                       continue;
+               len++;
+       }
+
+       for (i = 0; i < sizenode(t); i++) {
+               ktap_tnode *n = &t->node[i];
+
+               if (is_nil(gkey(n)))
+                       continue;
+
+               len++;
+       }
+
+       kp_tab_unlock(t);
+       return len;
+}
+
+void kp_tab_free(ktap_state *ks, ktap_tab *t)
+{
+       if (t->sizearray > 0) {
+               kp_free(ks, t->array);
+               kp_free(ks, t->sd_arr);
+       }
+
+       if (!isdummy(t->node)) {
+               kp_free(ks, t->node);
+               kp_free(ks, t->sd_rec);
+       }
+
+       kp_free(ks, t->sorted);
+       kp_free_gclist(ks, t->gclist);
+       kp_free(ks, t);
+}
+
+void kp_tab_dump(ktap_state *ks, ktap_tab *t)
+{
+       int i;
+
+       for (i = 0; i < t->sizearray; i++) {
+               ktap_value *v = &t->array[i];
+
+               if (is_nil(v))
+                       continue;
+
+               kp_printf(ks, "%d:\t", i + 1);
+               kp_showobj(ks, v);
+               kp_puts(ks, "\n");
+       }
+
+       for (i = 0; i < sizenode(t); i++) {
+               ktap_tnode *n = &t->node[i];
+
+               if (is_nil(gkey(n)))
+                       continue;
+
+               kp_showobj(ks, gkey(n));
+               kp_puts(ks, ":\t");
+               kp_showobj(ks, gval(n));
+               kp_puts(ks, "\n");
+       }
+}
+
+/*
+ * table-clear only set nil of all elements, not free t->array and nodes.
+ * we assume user will reuse table soon after clear table, so reserve array
+ * and nodes will avoid memory allocation when insert key-value again.
+ */
+void kp_tab_clear(ktap_state *ks, ktap_tab *t)
+{
+       unsigned long __maybe_unused flags;
+
+       kp_tab_lock(t);
+
+       memset(t->array, 0, t->sizearray * sizeof(ktap_value));
+       memset(t->node, 0, sizenode(t) * sizeof(ktap_tnode));
+
+       kp_tab_unlock(t);
+}
+
+#ifdef __KERNEL__
+static void string_convert(char *output, const char *input)
+{
+       if (strlen(input) > 32) {
+               strncpy(output, input, 32-4);
+               memset(output + 32-4, '.', 3);
+       } else
+               memcpy(output, input, strlen(input));
+}
+
+struct table_hist_record {
+       ktap_value key;
+       ktap_value val;
+};
+
+static int hist_record_cmp(const void *r1, const void *r2)
+{
+       const struct table_hist_record *i = r1;
+       const struct table_hist_record *j = r2;
+
+       if ((nvalue(&i->val) == nvalue(&j->val))) {
+               return 0;
+       } else if ((nvalue(&i->val) < nvalue(&j->val))) {
+               return 1;
+       } else
+               return -1;
+}
+
+/* todo: make histdump to be faster */
+
+/* histogram: key should be number or string, value must be number */
+static void table_histdump(ktap_state *ks, ktap_tab *t, int shownums)
+{
+       struct table_hist_record *thr;
+       unsigned long __maybe_unused flags;
+       char dist_str[40];
+       int i, ratio, total = 0, count = 0, top_num, is_kernel_address = 0;
+       int size, num;
+
+       size = sizeof(*thr) * (t->sizearray + sizenode(t));
+       thr = kp_malloc(ks, size);
+       if (!thr) {
+               kp_error(ks, "Cannot allocate %d of histogram memory", size);
+               return;
+       }
+
+       kp_tab_lock(t);
+
+       for (i = 0; i < t->sizearray; i++) {
+               ktap_value *v = &t->array[i];
+
+               if (is_nil(v))
+                       continue;
+
+               if (is_number(v))
+                       num = nvalue(v);
+               else if (is_statdata(v))
+                       num = sdvalue(v)->count;
+               else {
+                       kp_tab_unlock(t);
+                       goto error;
+               }
+
+               set_number(&thr[count].key, i + 1);
+               set_number(&thr[count].val, num);
+               count++;
+               total += num;
+       }
+
+       for (i = 0; i < sizenode(t); i++) {
+               ktap_tnode *n = &t->node[i];
+               ktap_value *v = gval(n);
+
+               if (is_nil(gkey(n)))
+                       continue;
+
+               if (is_number(v))
+                       num = nvalue(v);
+               else if (is_statdata(v))
+                       num = sdvalue(v)->count;
+               else {
+                       kp_tab_unlock(t);
+                       goto error;
+               }
+
+               set_obj(&thr[count].key, gkey(n));
+               set_number(&thr[count].val, num);
+               count++;
+               total += num;
+       }
+
+       kp_tab_unlock(t);
+
+       sort(thr, count, sizeof(struct table_hist_record),
+            hist_record_cmp, NULL);
+
+       dist_str[sizeof(dist_str) - 1] = '\0';
+
+       /* check the first key is a kernel text symbol or not */
+       if (is_number(&thr[0].key)) {
+               char str[KSYM_SYMBOL_LEN];
+
+               SPRINT_SYMBOL(str, nvalue(&thr[0].key));
+               if (str[0] != '0' || str[1] != 'x')
+                       is_kernel_address = 1;
+       }
+
+       top_num = min(shownums, count);
+       for (i = 0; i < top_num; i++) {
+               ktap_value *key = &thr[i].key;
+               ktap_value *val = &thr[i].val;
+
+               memset(dist_str, ' ', sizeof(dist_str) - 1);
+               ratio = (nvalue(val) * (sizeof(dist_str) - 1)) / total;
+               memset(dist_str, '@', ratio);
+
+               if (is_string(key)) {
+                       char buf[32 + 1] = {0};
+
+                       string_convert(buf, svalue(key));
+                       kp_printf(ks, "%32s |%s%-7d\n", buf, dist_str,
+                                     nvalue(val));
+               } else if (is_number(key)) {
+                       char str[KSYM_SYMBOL_LEN];
+                       char buf[32 + 1] = {0};
+
+                       if (is_kernel_address) {
+                               /* suppose it's a symbol, fix it in future */
+                               SPRINT_SYMBOL(str, nvalue(key));
+                               string_convert(buf, str);
+                               kp_printf(ks, "%32s |%s%-7d\n", buf, dist_str,
+                                               nvalue(val));
+                       } else {
+                               kp_printf(ks, "%32d |%s%-7d\n", nvalue(key),
+                                               dist_str, nvalue(val));
+                       }
+               }
+       }
+
+       if (count > shownums)
+               kp_printf(ks, "%32s |\n", "...");
+
+       goto out;
+
+ error:
+       kp_puts(ks, "error: table histogram only handle "
+                       " (key: string/number val: number)\n");
+ out:
+       kp_free(ks, thr);
+}
+
+#define HISTOGRAM_DEFAULT_TOP_NUM      20
+
+#define DISTRIBUTION_STR "------------- Distribution -------------"
+void kp_tab_histogram(ktap_state *ks, ktap_tab *t)
+{
+       kp_printf(ks, "%32s%s%s\n", "value ", DISTRIBUTION_STR, " count");
+       table_histdump(ks, t, HISTOGRAM_DEFAULT_TOP_NUM);
+}
+
+/*
+ * Parallel Table
+ */
+
+void kp_statdata_dump(ktap_state *ks, ktap_stat_data *sd)
+{
+       kp_printf(ks, "[count: %6d sum: %6d max: %6d min: %6d avg: %6d]",
+               sd->count, sd->sum, sd->max, sd->min, sd->sum/sd->count);
+}
+
+static void statdata_add(ktap_stat_data *sd1, ktap_stat_data *sd2)
+{
+       sd2->count += sd1->count;
+       sd2->sum += sd1->sum;
+       if (sd1->max > sd2->max)
+               sd2->max = sd1->max;
+       if (sd1->min < sd2->min)
+               sd2->min = sd1->min;
+}
+
+static void merge_table(ktap_state *ks, ktap_tab *t1, ktap_tab *t2)
+{
+       unsigned long __maybe_unused flags;
+       ktap_value *newv;
+       ktap_value n;
+       int i;
+
+       kp_tab_lock(t1);
+       kp_tab_lock(t2);
+
+       for (i = 0; i < t1->sizearray; i++) {
+               ktap_value *v = &t1->array[i];
+               ktap_stat_data *sd;
+
+               if (is_nil(v))
+                       continue;
+
+               set_number(&n, i);
+
+               newv = table_set(ks, t2, &n);
+               sd = read_sd(t2, newv);
+               if (is_nil(newv)) {
+                       *sd = *read_sd(t1, v);
+                       set_statdata(newv, sd);
+               } else
+                       statdata_add(read_sd(t1, v), sd);
+       }
+
+       for (i = 0; i < sizenode(t1); i++) {
+               ktap_tnode *node = &t1->node[i];
+
+               if (is_nil(gkey(node)))
+                       continue;
+
+               newv = table_set(ks, t2, gkey(node));
+               if (is_nil(newv)) {
+                       *read_sd(t2, newv) = *read_sd(t1, gval(node));
+                       set_statdata(newv, read_sd(t2, newv));
+               } else
+                       statdata_add(read_sd(t1, gval(node)),
+                                    read_sd(t2, newv));
+       }
+
+       kp_tab_unlock(t2);
+       kp_tab_unlock(t1);
+}
+
+ktap_tab *kp_ptab_synthesis(ktap_state *ks, ktap_ptab *ph)
+{
+       ktap_tab *agg;
+       int cpu;
+
+       agg = ph->agg;
+
+       /* clear the table content before store new elements */
+       kp_tab_clear(ks, agg);
+
+       for_each_possible_cpu(cpu) {
+               ktap_tab **t = per_cpu_ptr(ph->tbl, cpu);
+               merge_table(ks, *t, agg);
+       }
+
+       return agg;
+}
+
+void kp_ptab_dump(ktap_state *ks, ktap_ptab *ph)
+{
+       kp_tab_dump(ks, kp_ptab_synthesis(ks, ph));
+}
+
+ktap_ptab *kp_ptab_new(ktap_state *ks)
+{
+       ktap_ptab *ph;
+       int cpu;
+
+       ph = &kp_newobject(ks, KTAP_TPTABLE, sizeof(ktap_ptab),
+                       NULL)->ph;
+       ph->tbl = alloc_percpu(ktap_tab *);
+
+       for_each_possible_cpu(cpu) {
+               ktap_tab **t = per_cpu_ptr(ph->tbl, cpu);
+               *t = kp_tab_new(ks);
+
+               (*t)->with_stats = 1;
+
+               /* todo: make this value to be configuable, MAXENTRIES? */
+               table_resize(ks, *t, 0, 2000);
+       }
+
+       ph->agg = kp_tab_new(ks);
+       ph->agg->with_stats = 1;
+       table_resize(ks, ph->agg, 0, 2000);
+
+       return ph;
+}
+
+void kp_ptab_free(ktap_state *ks, ktap_ptab *ph)
+{
+       free_percpu(ph->tbl);
+       kp_free(ks, ph);
+}
+
+void kp_ptab_set(ktap_state *ks, ktap_ptab *ph,
+                                ktap_value *key, ktap_value *val)
+{
+       ktap_tab *t = *__this_cpu_ptr(ph->tbl);
+       unsigned long __maybe_unused flags;
+       ktap_value *v;
+       ktap_stat_data *sd;
+       int aggval;;
+
+       if (unlikely(!is_number(val))) {
+               kp_error(ks, "add non number value to aggregation table\n");
+               return;
+       }
+
+       aggval = nvalue(val);
+
+       kp_tab_lock(t);
+
+       v = table_set(ks, t, key);
+       sd = read_sd(t, v);
+
+       if (is_nil(v)) {
+               sd->count = 1;
+               sd->sum = sd->min = sd->max = aggval;
+               set_statdata(v, sd);
+               kp_tab_unlock(t);
+               return;
+       }
+
+       sd->count++;
+       sd->sum += aggval;
+       if (aggval > sd->max)
+               sd->max = aggval;
+       if (aggval < sd->min)
+               sd->min = aggval;
+
+       kp_tab_unlock(t);
+}
+
+void kp_ptab_get(ktap_state *ks, ktap_ptab *ph,
+                                ktap_value *key, ktap_value *val)
+{
+       unsigned long __maybe_unused flags;
+       ktap_stat_data sd, *aggsd;
+       const ktap_value *v;
+       ktap_value *aggval;
+       int cpu;
+
+       sd.count = sd.sum = sd.max = sd.min = -1;
+
+       for_each_possible_cpu(cpu) {
+               ktap_tab **t = per_cpu_ptr(ph->tbl, cpu);
+
+               kp_tab_lock(*t);
+               v = table_get(*t, key);
+               if (is_nil(v)) {
+                       kp_tab_unlock(*t);
+                       continue;
+               }
+
+               if (sd.count == -1) {
+                       sd = *read_sd(*t, v);
+                       kp_tab_unlock(*t);
+                       continue;
+               }
+
+               statdata_add(read_sd(*t, v), &sd);
+               kp_tab_unlock(*t);
+       }
+
+       if (sd.count == -1) {
+               set_nil(val);
+               return;
+       }
+
+       kp_tab_lock(ph->agg);
+       aggval = table_set(ks, ph->agg, key);
+       aggsd = read_sd(ph->agg, aggval);
+       *aggsd = sd;
+       set_statdata(aggval, aggsd);
+       set_statdata(val, aggsd);
+       kp_tab_unlock(ph->agg);
+}
+
+void kp_ptab_histogram(ktap_state *ks, ktap_ptab *ph)
+{
+       kp_tab_histogram(ks, kp_ptab_synthesis(ks, ph));
+}
+#endif
diff --git a/drivers/staging/ktap/runtime/kp_tab.h b/drivers/staging/ktap/runtime/kp_tab.h
new file mode 100644 (file)
index 0000000..51be4af
--- /dev/null
@@ -0,0 +1,32 @@
+#ifndef __KTAP_TAB_H__
+#define __KTAP_TAB_H__
+
+ktap_value *kp_tab_set(ktap_state *ks, ktap_tab *t, const ktap_value *key);
+ktap_tab *kp_tab_new(ktap_state *ks);
+const ktap_value *kp_tab_getint(ktap_tab *t, int key);
+void kp_tab_setint(ktap_state *ks, ktap_tab *t, int key, ktap_value *v);
+const ktap_value *kp_tab_get(ktap_tab *t, const ktap_value *key);
+void kp_tab_setvalue(ktap_state *ks, ktap_tab *t, const ktap_value *key, ktap_value *val);
+void kp_tab_resize(ktap_state *ks, ktap_tab *t, int nasize, int nhsize);
+void kp_tab_resizearray(ktap_state *ks, ktap_tab *t, int nasize);
+void kp_tab_free(ktap_state *ks, ktap_tab *t);
+int kp_tab_length(ktap_state *ks, ktap_tab *t);
+void kp_tab_dump(ktap_state *ks, ktap_tab *t);
+void kp_tab_clear(ktap_state *ks, ktap_tab *t);
+void kp_tab_histogram(ktap_state *ks, ktap_tab *t);
+int kp_tab_next(ktap_state *ks, ktap_tab *t, StkId key);
+int kp_tab_sort_next(ktap_state *ks, ktap_tab *t, StkId key);
+void kp_tab_sort(ktap_state *ks, ktap_tab *t, ktap_closure *cmp_func);
+void kp_tab_atomic_inc(ktap_state *ks, ktap_tab *t, ktap_value *key, int n);
+void kp_statdata_dump(ktap_state *ks, ktap_stat_data *sd);
+ktap_ptab *kp_ptab_new(ktap_state *ks);
+ktap_tab *kp_ptab_synthesis(ktap_state *ks, ktap_ptab *ph);
+void kp_ptab_dump(ktap_state *ks, ktap_ptab *ph);
+void kp_ptab_free(ktap_state *ks, ktap_ptab *ph);
+void kp_ptab_set(ktap_state *ks, ktap_ptab *ph,
+                       ktap_value *key, ktap_value *val);
+void kp_ptab_get(ktap_state *ks, ktap_ptab *ph,
+                       ktap_value *key, ktap_value *val);
+void kp_ptab_histogram(ktap_state *ks, ktap_ptab *ph);
+
+#endif /* __KTAP_TAB_H__ */
diff --git a/drivers/staging/ktap/runtime/kp_transport.c b/drivers/staging/ktap/runtime/kp_transport.c
new file mode 100644 (file)
index 0000000..5a1b1e1
--- /dev/null
@@ -0,0 +1,641 @@
+/*
+ * kp_transport.c - ktap transport functionality
+ *
+ * This file is part of ktap by Jovi Zhangwei.
+ *
+ * Copyright (C) 2012-2013 Jovi Zhangwei <jovi.zhangwei@gmail.com>.
+ *
+ * ktap 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.
+ *
+ * ktap is distributed in the hope it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
+ * more details.
+ *
+ * You should have received a copy of the GNU General Public License along with
+ * this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+
+#include <linux/debugfs.h>
+#include <linux/ftrace_event.h>
+#include <linux/stacktrace.h>
+#include <linux/clocksource.h>
+#include <asm/uaccess.h>
+#include <linux/slab.h>
+#include <linux/module.h>
+#include <linux/kallsyms.h>
+#include "../include/ktap_types.h"
+#include "ktap.h"
+#include "kp_transport.h"
+
+struct ktap_trace_iterator {
+       struct ring_buffer      *buffer;
+       int                     print_timestamp;
+       void                    *private;
+
+       struct trace_iterator   iter;
+};
+
+enum ktap_trace_type {
+       __TRACE_FIRST_TYPE = 0,
+
+       TRACE_FN = 1, /* must be same as ftrace definition in kernel */
+       TRACE_PRINT,
+       TRACE_BPUTS,
+       TRACE_STACK,
+       TRACE_USER_STACK,
+
+       __TRACE_LAST_TYPE,
+};
+
+#define KTAP_TRACE_ITER(iter)  \
+       container_of(iter, struct ktap_trace_iterator, iter)
+
+static
+ssize_t _trace_seq_to_user(struct trace_seq *s, char __user *ubuf, size_t cnt)
+{
+       int len;
+       int ret;
+
+       if (!cnt)
+               return 0;
+
+       if (s->len <= s->readpos)
+               return -EBUSY;
+
+       len = s->len - s->readpos;
+       if (cnt > len)
+               cnt = len;
+       ret = copy_to_user(ubuf, s->buffer + s->readpos, cnt);
+       if (ret == cnt)
+               return -EFAULT;
+
+       cnt -= ret;
+
+       s->readpos += cnt;
+       return cnt;
+}
+
+int _trace_seq_puts(struct trace_seq *s, const char *str)
+{
+       int len = strlen(str);
+
+       if (s->full)
+               return 0;
+
+       if (len > ((PAGE_SIZE - 1) - s->len)) {
+               s->full = 1;
+               return 0;
+       }
+
+       memcpy(s->buffer + s->len, str, len);
+       s->len += len;
+
+       return len;
+}
+
+static int trace_empty(struct trace_iterator *iter)
+{
+       struct ktap_trace_iterator *ktap_iter = KTAP_TRACE_ITER(iter);
+       int cpu;
+
+       for_each_online_cpu(cpu) {
+               if (!ring_buffer_empty_cpu(ktap_iter->buffer, cpu))
+                       return 0;
+       }
+
+       return 1;
+}
+
+static void trace_consume(struct trace_iterator *iter)
+{
+       struct ktap_trace_iterator *ktap_iter = KTAP_TRACE_ITER(iter);
+
+       ring_buffer_consume(ktap_iter->buffer, iter->cpu, &iter->ts,
+                           &iter->lost_events);
+}
+
+unsigned long long ns2usecs(cycle_t nsec)
+{
+       nsec += 500;
+       do_div(nsec, 1000);
+       return nsec;
+}
+
+static int trace_print_timestamp(struct trace_iterator *iter)
+{
+       struct trace_seq *s = &iter->seq;
+       unsigned long long t;
+       unsigned long secs, usec_rem;
+
+       t = ns2usecs(iter->ts);
+       usec_rem = do_div(t, USEC_PER_SEC);
+       secs = (unsigned long)t;
+
+       return trace_seq_printf(s, "%5lu.%06lu: ", secs, usec_rem);
+}
+
+/* todo: export kernel function ftrace_find_event in future, and make faster */
+static struct trace_event *(*ftrace_find_event)(int type);
+
+static enum print_line_t print_trace_fmt(struct trace_iterator *iter)
+{
+       struct ktap_trace_iterator *ktap_iter = KTAP_TRACE_ITER(iter);
+       struct trace_entry *entry = iter->ent;
+       struct trace_event *ev;
+
+       ev = ftrace_find_event(entry->type);
+
+       if (ktap_iter->print_timestamp && !trace_print_timestamp(iter))
+               return TRACE_TYPE_PARTIAL_LINE;
+
+       if (ev) {
+               int ret = ev->funcs->trace(iter, 0, ev);
+
+               /* overwrite '\n' at the ending */
+               iter->seq.buffer[iter->seq.len - 1] = '\0';
+               iter->seq.len--;
+               return ret;
+       }
+
+       return TRACE_TYPE_PARTIAL_LINE;
+}
+
+static enum print_line_t print_trace_stack(struct trace_iterator *iter)
+{
+       struct trace_entry *entry = iter->ent;
+       struct stack_trace trace;
+       char str[KSYM_SYMBOL_LEN];
+       int i;
+
+       trace.entries = (unsigned long *)(entry + 1);
+       trace.nr_entries = (iter->ent_size - sizeof(*entry)) /
+                          sizeof(unsigned long);
+
+       if (!_trace_seq_puts(&iter->seq, "<stack trace>\n"))
+               return TRACE_TYPE_PARTIAL_LINE;
+
+       for (i = 0; i < trace.nr_entries; i++) {
+               unsigned long p = trace.entries[i];
+
+               if (p == ULONG_MAX)
+                       break;
+
+               sprint_symbol(str, p);
+               if (!trace_seq_printf(&iter->seq, " => %s\n", str))
+                       return TRACE_TYPE_PARTIAL_LINE;
+       }
+
+       return TRACE_TYPE_HANDLED;
+}
+
+struct ktap_ftrace_entry {
+       struct trace_entry entry;
+       unsigned long ip;
+       unsigned long parent_ip;
+};
+
+static enum print_line_t print_trace_fn(struct trace_iterator *iter)
+{
+       struct ktap_trace_iterator *ktap_iter = KTAP_TRACE_ITER(iter);
+       struct ktap_ftrace_entry *field = (struct ktap_ftrace_entry *)iter->ent;
+       char str[KSYM_SYMBOL_LEN];
+
+       if (ktap_iter->print_timestamp && !trace_print_timestamp(iter))
+               return TRACE_TYPE_PARTIAL_LINE;
+
+       sprint_symbol(str, field->ip);
+       if (!_trace_seq_puts(&iter->seq, str))
+               return TRACE_TYPE_PARTIAL_LINE;
+
+       if (!_trace_seq_puts(&iter->seq, " <- "))
+               return TRACE_TYPE_PARTIAL_LINE;
+
+       sprint_symbol(str, field->parent_ip);
+       if (!_trace_seq_puts(&iter->seq, str))
+               return TRACE_TYPE_PARTIAL_LINE;
+
+       return TRACE_TYPE_HANDLED;
+}
+
+static enum print_line_t print_trace_bputs(struct trace_iterator *iter)
+{
+       if (!_trace_seq_puts(&iter->seq,
+                           (const char *)(*(unsigned long *)(iter->ent + 1))))
+               return TRACE_TYPE_PARTIAL_LINE;
+
+       return TRACE_TYPE_HANDLED;
+}
+
+static enum print_line_t print_trace_line(struct trace_iterator *iter)
+{
+       struct trace_entry *entry = iter->ent;
+       char *str = (char *)(entry + 1);
+
+       if (entry->type == TRACE_PRINT) {
+               if (!trace_seq_printf(&iter->seq, "%s", str))
+                       return TRACE_TYPE_PARTIAL_LINE;
+
+               return TRACE_TYPE_HANDLED;
+       }
+
+       if (entry->type == TRACE_BPUTS)
+               return print_trace_bputs(iter);
+
+       if (entry->type == TRACE_STACK)
+               return print_trace_stack(iter);
+
+       if (entry->type == TRACE_FN)
+               return print_trace_fn(iter);
+
+       return print_trace_fmt(iter);
+}
+
+static struct trace_entry *
+peek_next_entry(struct trace_iterator *iter, int cpu, u64 *ts,
+               unsigned long *lost_events)
+{
+       struct ktap_trace_iterator *ktap_iter = KTAP_TRACE_ITER(iter);
+       struct ring_buffer_event *event;
+
+       event = ring_buffer_peek(ktap_iter->buffer, cpu, ts, lost_events);
+       if (event) {
+               iter->ent_size = ring_buffer_event_length(event);
+               return ring_buffer_event_data(event);
+       }
+
+       return NULL;
+}
+
+static struct trace_entry *
+__find_next_entry(struct trace_iterator *iter, int *ent_cpu,
+                 unsigned long *missing_events, u64 *ent_ts)
+{
+       struct ktap_trace_iterator *ktap_iter = KTAP_TRACE_ITER(iter);
+       struct ring_buffer *buffer = ktap_iter->buffer;
+       struct trace_entry *ent, *next = NULL;
+       unsigned long lost_events = 0, next_lost = 0;
+       u64 next_ts = 0, ts;
+       int next_cpu = -1;
+       int next_size = 0;
+       int cpu;
+
+       for_each_online_cpu(cpu) {
+               if (ring_buffer_empty_cpu(buffer, cpu))
+                       continue;
+
+               ent = peek_next_entry(iter, cpu, &ts, &lost_events);
+               /*
+                * Pick the entry with the smallest timestamp:
+                */
+               if (ent && (!next || ts < next_ts)) {
+                       next = ent;
+                       next_cpu = cpu;
+                       next_ts = ts;
+                       next_lost = lost_events;
+                       next_size = iter->ent_size;
+               }
+       }
+
+       iter->ent_size = next_size;
+
+       if (ent_cpu)
+               *ent_cpu = next_cpu;
+
+       if (ent_ts)
+               *ent_ts = next_ts;
+
+       if (missing_events)
+               *missing_events = next_lost;
+
+       return next;
+}
+
+/* Find the next real entry, and increment the iterator to the next entry */
+static void *trace_find_next_entry_inc(struct trace_iterator *iter)
+{
+       iter->ent = __find_next_entry(iter, &iter->cpu,
+                                     &iter->lost_events, &iter->ts);
+       if (iter->ent)
+               iter->idx++;
+
+       return iter->ent ? iter : NULL;
+}
+
+static void poll_wait_pipe(void)
+{
+       set_current_state(TASK_INTERRUPTIBLE);
+       /* sleep for 100 msecs, and try again. */
+       schedule_timeout(HZ / 10);
+}
+
+static int tracing_wait_pipe(struct file *filp)
+{
+       struct trace_iterator *iter = filp->private_data;
+       struct ktap_trace_iterator *ktap_iter = KTAP_TRACE_ITER(iter);
+       ktap_state *ks = ktap_iter->private;
+
+       while (trace_empty(iter)) {
+
+               if ((filp->f_flags & O_NONBLOCK)) {
+                       return -EAGAIN;
+               }
+
+               mutex_unlock(&iter->mutex);
+
+               poll_wait_pipe();
+
+               mutex_lock(&iter->mutex);
+
+               if (G(ks)->wait_user && trace_empty(iter))
+                       return -EINTR;
+       }
+
+       return 1;
+}
+
+static ssize_t
+tracing_read_pipe(struct file *filp, char __user *ubuf, size_t cnt,
+                 loff_t *ppos)
+{
+       struct trace_iterator *iter = filp->private_data;
+       ssize_t sret;
+
+       /* return any leftover data */
+       sret = _trace_seq_to_user(&iter->seq, ubuf, cnt);
+       if (sret != -EBUSY)
+               return sret;
+       /*
+        * Avoid more than one consumer on a single file descriptor
+        * This is just a matter of traces coherency, the ring buffer itself
+        * is protected.
+        */
+       mutex_lock(&iter->mutex);
+
+waitagain:
+       sret = tracing_wait_pipe(filp);
+       if (sret <= 0)
+               goto out;
+
+       /* stop when tracing is finished */
+       if (trace_empty(iter)) {
+               sret = 0;
+               goto out;
+       }
+
+       if (cnt >= PAGE_SIZE)
+               cnt = PAGE_SIZE - 1;
+
+       /* reset all but tr, trace, and overruns */
+       memset(&iter->seq, 0,
+              sizeof(struct trace_iterator) -
+              offsetof(struct trace_iterator, seq));
+       iter->pos = -1;
+
+       while (trace_find_next_entry_inc(iter) != NULL) {
+               enum print_line_t ret;
+               int len = iter->seq.len;
+
+               ret = print_trace_line(iter);
+               if (ret == TRACE_TYPE_PARTIAL_LINE) {
+                       /* don't print partial lines */
+                       iter->seq.len = len;
+                       break;
+               }
+               if (ret != TRACE_TYPE_NO_CONSUME)
+                       trace_consume(iter);
+
+               if (iter->seq.len >= cnt)
+                       break;
+
+               /*
+                * Setting the full flag means we reached the trace_seq buffer
+                * size and we should leave by partial output condition above.
+                * One of the trace_seq_* functions is not used properly.
+                */
+               WARN_ONCE(iter->seq.full, "full flag set for trace type %d",
+                         iter->ent->type);
+       }
+
+       /* Now copy what we have to the user */
+       sret = _trace_seq_to_user(&iter->seq, ubuf, cnt);
+       if (iter->seq.readpos >= iter->seq.len)
+               trace_seq_init(&iter->seq);
+
+       /*
+        * If there was nothing to send to user, in spite of consuming trace
+        * entries, go back to wait for more entries.
+        */
+       if (sret == -EBUSY)
+               goto waitagain;
+
+out:
+       mutex_unlock(&iter->mutex);
+
+       return sret;
+}
+
+static int tracing_open_pipe(struct inode *inode, struct file *filp)
+{
+       struct ktap_trace_iterator *ktap_iter;
+       ktap_state *ks = inode->i_private;
+
+       /* create a buffer to store the information to pass to userspace */
+       ktap_iter = kzalloc(sizeof(*ktap_iter), GFP_KERNEL);
+       if (!ktap_iter)
+               return -ENOMEM;
+
+       ktap_iter->private = ks;
+       ktap_iter->buffer = G(ks)->buffer;
+       ktap_iter->print_timestamp = G(ks)->parm->print_timestamp;
+       mutex_init(&ktap_iter->iter.mutex);
+       filp->private_data = &ktap_iter->iter;
+
+       nonseekable_open(inode, filp);
+
+       return 0;
+}
+
+static int tracing_release_pipe(struct inode *inode, struct file *file)
+{
+       struct trace_iterator *iter = file->private_data;
+       struct ktap_trace_iterator *ktap_iter = KTAP_TRACE_ITER(iter);
+
+       mutex_destroy(&iter->mutex);
+       kfree(ktap_iter);
+       return 0;
+}
+
+static const struct file_operations tracing_pipe_fops = {
+       .open           = tracing_open_pipe,
+       .read           = tracing_read_pipe,
+       .splice_read    = NULL,
+       .release        = tracing_release_pipe,
+       .llseek         = no_llseek,
+};
+
+/*
+ * preempt disabled in ring_buffer_lock_reserve
+ *
+ * The implementation is similar with funtion __ftrace_trace_stack.
+ */
+void kp_transport_print_backtrace(ktap_state *ks, int skip, int max_entries)
+{
+       struct ring_buffer *buffer = G(ks)->buffer;
+       struct ring_buffer_event *event;
+       struct trace_entry *entry;
+       int size;
+
+       size = max_entries * sizeof(unsigned long);
+       event = ring_buffer_lock_reserve(buffer, sizeof(*entry) + size);
+       if (!event) {
+               KTAP_STATS(ks)->events_missed += 1;
+               return;
+       } else {
+               struct stack_trace trace;
+
+               entry = ring_buffer_event_data(event);
+               tracing_generic_entry_update(entry, 0, 0);
+               entry->type = TRACE_STACK;
+
+               trace.nr_entries = 0;
+               trace.skip = skip;
+               trace.max_entries = max_entries;
+               trace.entries = (unsigned long *)(entry + 1);
+               save_stack_trace(&trace);
+
+               ring_buffer_unlock_commit(buffer, event);
+       }
+}
+
+void kp_transport_event_write(ktap_state *ks, struct ktap_event *e)
+{
+       struct ring_buffer *buffer = G(ks)->buffer;
+       struct ring_buffer_event *event;
+       struct trace_entry *entry;
+
+       event = ring_buffer_lock_reserve(buffer, e->entry_size +
+                                        sizeof(struct ftrace_event_call *));
+       if (!event) {
+               KTAP_STATS(ks)->events_missed += 1;
+               return;
+       } else {
+               entry = ring_buffer_event_data(event);
+
+               memcpy(entry, e->entry, e->entry_size);
+
+               ring_buffer_unlock_commit(buffer, event);
+       }
+}
+
+void kp_transport_write(ktap_state *ks, const void *data, size_t length)
+{
+       struct ring_buffer *buffer = G(ks)->buffer;
+       struct ring_buffer_event *event;
+       struct trace_entry *entry;
+       int size;
+
+       size = sizeof(struct trace_entry) + length;
+
+       event = ring_buffer_lock_reserve(buffer, size);
+       if (!event) {
+               KTAP_STATS(ks)->events_missed += 1;
+               return;
+       } else {
+               entry = ring_buffer_event_data(event);
+
+               tracing_generic_entry_update(entry, 0, 0);
+               entry->type = TRACE_PRINT;
+               memcpy(entry + 1, data, length);
+
+               ring_buffer_unlock_commit(buffer, event);
+       }
+}
+
+/* general print function */
+void kp_printf(ktap_state *ks, const char *fmt, ...)
+{
+       char buff[1024];
+       va_list args;
+       int len;
+
+       va_start(args, fmt);
+       len = vscnprintf(buff, 1024, fmt, args);
+       va_end(args);
+
+       buff[len] = '\0';
+       kp_transport_write(ks, buff, len + 1);
+}
+
+void __kp_puts(ktap_state *ks, const char *str)
+{
+       kp_transport_write(ks, str, strlen(str) + 1);
+}
+
+void __kp_bputs(ktap_state *ks, const char *str)
+{
+       struct ring_buffer *buffer = G(ks)->buffer;
+       struct ring_buffer_event *event;
+       struct trace_entry *entry;
+       int size;
+
+       size = sizeof(struct trace_entry) + sizeof(unsigned long *);
+
+       event = ring_buffer_lock_reserve(buffer, size);
+       if (!event) {
+               KTAP_STATS(ks)->events_missed += 1;
+               return;
+       } else {
+               entry = ring_buffer_event_data(event);
+
+               tracing_generic_entry_update(entry, 0, 0);
+               entry->type = TRACE_BPUTS;
+               *(unsigned long *)(entry + 1) = (unsigned long)str;
+
+               ring_buffer_unlock_commit(buffer, event);
+       }
+}
+
+void kp_transport_exit(ktap_state *ks)
+{
+       ring_buffer_free(G(ks)->buffer);
+       debugfs_remove(G(ks)->trace_pipe_dentry);
+}
+
+#define TRACE_BUF_SIZE_DEFAULT 1441792UL /* 16384 * 88 (sizeof(entry)) */
+
+int kp_transport_init(ktap_state *ks, struct dentry *dir)
+{
+       struct ring_buffer *buffer;
+       struct dentry *dentry;
+       char filename[32] = {0};
+
+       ftrace_find_event = (void *)kallsyms_lookup_name("ftrace_find_event");
+       if (!ftrace_find_event) {
+               printk("ktap: cannot lookup ftrace_find_event in kallsyms\n");
+               return -EINVAL;
+       }
+
+       buffer = ring_buffer_alloc(TRACE_BUF_SIZE_DEFAULT, RB_FL_OVERWRITE);
+       if (!buffer)
+               return -ENOMEM;
+
+       sprintf(filename, "trace_pipe_%d", (int)task_tgid_vnr(current));
+
+       dentry = debugfs_create_file(filename, 0444, dir,
+                                    ks, &tracing_pipe_fops);
+       if (!dentry) {
+               pr_err("ktapvm: cannot create trace_pipe file in debugfs\n");
+               ring_buffer_free(buffer);
+               return -1;
+       }
+
+       G(ks)->buffer = buffer;
+       G(ks)->trace_pipe_dentry = dentry;
+
+       return 0;
+}
+
diff --git a/drivers/staging/ktap/runtime/kp_transport.h b/drivers/staging/ktap/runtime/kp_transport.h
new file mode 100644 (file)
index 0000000..71b9c53
--- /dev/null
@@ -0,0 +1,13 @@
+#ifndef __KTAP_TRANSPORT_H__
+#define __KTAP_TRANSPORT_H__
+
+void kp_transport_write(ktap_state *ks, const void *data, size_t length);
+void kp_transport_event_write(ktap_state *ks, struct ktap_event *e);
+void kp_transport_print_backtrace(ktap_state *ks, int skip, int max_entries);
+void *kp_transport_reserve(ktap_state *ks, size_t length);
+void kp_transport_exit(ktap_state *ks);
+int kp_transport_init(ktap_state *ks, struct dentry *dir);
+
+int _trace_seq_puts(struct trace_seq *s, const char *str);
+
+#endif /* __KTAP_TRANSPORT_H__ */
diff --git a/drivers/staging/ktap/runtime/kp_vm.c b/drivers/staging/ktap/runtime/kp_vm.c
new file mode 100644 (file)
index 0000000..9c498c9
--- /dev/null
@@ -0,0 +1,1496 @@
+/*
+ * kp_vm.c - ktap script virtual machine in Linux kernel
+ *
+ * This file is part of ktap by Jovi Zhangwei.
+ *
+ * Copyright (C) 2012-2013 Jovi Zhangwei <jovi.zhangwei@gmail.com>.
+ *
+ * Copyright (C) 1994-2013 Lua.org, PUC-Rio.
+ *  - The part of code in this file is copied from lua initially.
+ *  - lua's MIT license is compatible with GPL.
+ *
+ * ktap 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.
+ *
+ * ktap is distributed in the hope it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
+ * more details.
+ *
+ * You should have received a copy of the GNU General Public License along with
+ * this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+
+#include <linux/slab.h>
+#include <linux/ftrace_event.h>
+#include <linux/signal.h>
+#include <linux/sched.h>
+#include <linux/uaccess.h>
+#include "../include/ktap_types.h"
+#include "../include/ktap_opcodes.h"
+#include "../include/ktap_ffi.h"
+#include "ktap.h"
+#include "kp_obj.h"
+#include "kp_str.h"
+#include "kp_tab.h"
+#include "kp_transport.h"
+#include "kp_vm.h"
+
+#define KTAP_MIN_RESERVED_STACK_SIZE 20
+#define KTAP_STACK_SIZE                120 /* enlarge this value for big stack */
+#define KTAP_STACK_SIZE_BYTES  (KTAP_STACK_SIZE * sizeof(ktap_value))
+
+#define CIST_KTAP      (1 << 0) /* call is running a ktap function */
+#define CIST_REENTRY   (1 << 2)
+
+#define isktapfunc(ci) ((ci)->callstatus & CIST_KTAP)
+
+
+/* common helper function */
+int gettimeofday_us(void)
+{
+       struct timeval tv;
+
+       do_gettimeofday(&tv);
+       return tv.tv_sec * USEC_PER_SEC + tv.tv_usec;
+}
+
+
+static void ktap_concat(ktap_state *ks, int start, int end)
+{
+       int i, len = 0;
+       StkId top = ks->ci->u.l.base;
+       ktap_string *ts;
+       char *ptr, *buffer;
+
+       for (i = start; i <= end; i++) {
+               if (!is_string(top + i)) {
+                       kp_error(ks, "cannot concat non-string\n");
+                       set_nil(top + start);
+                       return;
+               }
+
+               len += rawtsvalue(top + i)->tsv.len;
+       }
+
+       if (len >= KTAP_PERCPU_BUFFER_SIZE) {
+               kp_error(ks, "Error: too long string concatenation\n");
+               return;
+       }
+
+       preempt_disable_notrace();
+
+       buffer = kp_percpu_data(ks, KTAP_PERCPU_DATA_BUFFER);
+       ptr = buffer;
+
+       for (i = start; i <= end; i++) {
+               int len = rawtsvalue(top + i)->tsv.len;
+               strncpy(ptr, svalue(top + i), len);
+               ptr += len;
+       }
+       ts = kp_tstring_newlstr(ks, buffer, len);
+       set_string(top + start, ts);
+
+       preempt_enable_notrace();
+}
+
+/* todo: compare l == r if both is tstring type? */
+static int lessthan(ktap_state *ks, const ktap_value *l, const ktap_value *r)
+{
+       if (is_number(l) && is_number(r))
+               return NUMLT(nvalue(l), nvalue(r));
+       else if (is_string(l) && is_string(r))
+               return kp_tstring_cmp(rawtsvalue(l), rawtsvalue(r)) < 0;
+
+       return 0;
+}
+
+static int lessequal(ktap_state *ks, const ktap_value *l, const ktap_value *r)
+{
+       if (is_number(l) && is_number(r))
+               return NUMLE(nvalue(l), nvalue(r));
+       else if (is_string(l) && is_string(r))
+               return kp_tstring_cmp(rawtsvalue(l), rawtsvalue(r)) <= 0;
+
+       return 0;
+}
+
+static int fb2int (int x)
+{
+       int e = (x >> 3) & 0x1f;
+       if (e == 0)
+               return x;
+       else
+               return ((x & 7) + 8) << (e - 1);
+}
+
+static const ktap_value *ktap_tonumber(const ktap_value *obj, ktap_value *n)
+{
+       if (is_number(obj))
+               return obj;
+
+       return NULL;
+}
+
+static ktap_upval *findupval(ktap_state *ks, StkId level)
+{
+       ktap_global_state *g = G(ks);
+       ktap_gcobject **pp = &ks->openupval;
+       ktap_upval *p;
+       ktap_upval *uv;
+
+       while (*pp != NULL && (p = gco2uv(*pp))->v >= level) {
+               if (p->v == level) {  /* found a corresponding upvalue? */
+                       return p;
+               }
+               pp = &p->next;
+       }
+
+       /* not found: create a new one */
+       uv = &kp_newobject(ks, KTAP_TUPVAL, sizeof(ktap_upval), pp)->uv;
+       uv->v = level;  /* current value lives in the stack */
+       uv->u.l.prev = &g->uvhead;  /* double link it in `uvhead' list */
+       uv->u.l.next = g->uvhead.u.l.next;
+       uv->u.l.next->u.l.prev = uv;
+       g->uvhead.u.l.next = uv;
+       return uv;
+}
+
+/* todo: implement this*/
+static void function_close (ktap_state *ks, StkId level)
+{
+}
+
+/* create a new closure */
+static void pushclosure(ktap_state *ks, ktap_proto *p, ktap_upval **encup,
+                       StkId base, StkId ra)
+{
+       int nup = p->sizeupvalues;
+       ktap_upvaldesc *uv = p->upvalues;
+       int i;
+       ktap_closure *ncl = kp_newclosure(ks, nup);
+
+       ncl->p = p;
+       set_closure(ra, ncl);  /* anchor new closure in stack */
+
+       /* fill in its upvalues */
+       for (i = 0; i < nup; i++) {
+               if (uv[i].instack) {
+                       /* upvalue refers to local variable? */
+                       ncl->upvals[i] = findupval(ks, base + uv[i].idx);
+               } else {
+                       /* get upvalue from enclosing function */
+                       ncl->upvals[i] = encup[uv[i].idx];
+               }
+       }
+       //p->cache = ncl;  /* save it on cache for reuse */
+}
+
+static void gettable(ktap_state *ks, const ktap_value *t, ktap_value *key,
+                    StkId val)
+{
+       if (is_table(t)) {
+               set_obj(val, kp_tab_get(hvalue(t), key));
+       } else if (is_ptable(t)) {
+               kp_ptab_get(ks, phvalue(t), key, val);
+       } else {
+               kp_error(ks, "get key from non-table\n");
+       }
+}
+
+static void settable(ktap_state *ks, const ktap_value *t, ktap_value *key,
+                    StkId val)
+{
+       if (is_table(t)) {
+               kp_tab_setvalue(ks, hvalue(t), key, val);
+       } else if (is_ptable(t)) {
+               kp_ptab_set(ks, phvalue(t), key, val);
+       } else {
+               kp_error(ks, "set key to non-table\n");
+       }
+}
+
+static void settable_incr(ktap_state *ks, const ktap_value *t, ktap_value *key,
+                         StkId val)
+{
+       if (unlikely(!is_table(t))) {
+               kp_error(ks, "use += operator for non-table\n");
+               return;
+       }
+
+       if (unlikely(!is_number(val))) {
+               kp_error(ks, "use non-number to += operator\n");
+               return;
+       }
+
+       kp_tab_atomic_inc(ks, hvalue(t), key, nvalue(val));
+}
+
+static inline int checkstack(ktap_state *ks, int n)
+{
+       if (unlikely(ks->stack_last - ks->top <= n)) {
+               kp_error(ks, "stack overflow, please enlarge stack size\n");
+               return -1;
+       }
+
+       return 0;
+}
+
+static StkId adjust_varargs(ktap_state *ks, ktap_proto *p, int actual)
+{
+       int i;
+       int nfixargs = p->numparams;
+       StkId base, fixed;
+
+       /* move fixed parameters to final position */
+       fixed = ks->top - actual;  /* first fixed argument */
+       base = ks->top;  /* final position of first argument */
+
+       for (i=0; i < nfixargs; i++) {
+               set_obj(ks->top++, fixed + i);
+               set_nil(fixed + i);
+       }
+
+       return base;
+}
+
+static int poscall(ktap_state *ks, StkId first_result)
+{
+       ktap_callinfo *ci;
+       StkId res;
+       int wanted, i;
+
+       ci = ks->ci;
+
+       res = ci->func;
+       wanted = ci->nresults;
+
+       ks->ci = ci = ci->prev;
+
+       for (i = wanted; i != 0 && first_result < ks->top; i--)
+               set_obj(res++, first_result++);
+
+       while(i-- > 0)
+               set_nil(res++);
+
+       ks->top = res;
+
+       return (wanted - (-1));
+}
+
+static ktap_callinfo *extend_ci(ktap_state *ks)
+{
+       ktap_callinfo *ci;
+
+       ci = kp_malloc(ks, sizeof(ktap_callinfo));
+       ks->ci->next = ci;
+       ci->prev = ks->ci;
+       ci->next = NULL;
+
+       return ci;
+}
+
+static void free_ci(ktap_state *ks)
+{
+       ktap_callinfo *ci = ks->ci;
+       ktap_callinfo *next;
+
+       if (!ci)
+               return;
+
+       next = ci->next;
+       ci->next = NULL;
+       while ((ci = next) != NULL) {
+               next = ci->next;
+               kp_free(ks, ci);
+       }
+}
+
+#define next_ci(ks) (ks->ci = ks->ci->next ? ks->ci->next : extend_ci(ks))
+#define savestack(ks, p)       ((char *)(p) - (char *)ks->stack)
+#define restorestack(ks, n)    ((ktap_value *)((char *)ks->stack + (n)))
+
+static int precall(ktap_state *ks, StkId func, int nresults)
+{
+       ktap_cfunction f;
+       ktap_callinfo *ci;
+       ktap_proto *p;
+#ifdef CONFIG_KTAP_FFI
+       ktap_cdata *cd;
+       csymbol *cs;
+#endif
+       StkId base;
+       ptrdiff_t funcr = savestack(ks, func);
+       int n;
+
+       switch (ttype(func)) {
+       case KTAP_TCFUNCTION: /* light C function */
+               f = fvalue(func);
+
+               if (checkstack(ks, KTAP_MIN_RESERVED_STACK_SIZE))
+                       return 1;
+
+               ci = next_ci(ks);
+               ci->nresults = nresults;
+               ci->func = restorestack(ks, funcr);
+               ci->top = ks->top + KTAP_MIN_RESERVED_STACK_SIZE;
+               ci->callstatus = 0;
+               n = (*f)(ks);
+               poscall(ks, ks->top - n);
+               return 1;
+       case KTAP_TCLOSURE:
+               p = clvalue(func)->p;
+
+               if (checkstack(ks, p->maxstacksize))
+                       return 1;
+
+               func = restorestack(ks, funcr);
+               n = (int)(ks->top - func) - 1; /* number of real arguments */
+
+               /* complete missing arguments */
+               for (; n < p->numparams; n++)
+                       set_nil(ks->top++);
+
+               base = (!p->is_vararg) ? func + 1 : adjust_varargs(ks, p, n);
+               ci = next_ci(ks);
+               ci->nresults = nresults;
+               ci->func = func;
+               ci->u.l.base = base;
+               ci->top = base + p->maxstacksize;
+               ci->u.l.savedpc = p->code; /* starting point */
+               ci->callstatus = CIST_KTAP;
+               ks->top = ci->top;
+               return 0;
+#ifdef CONFIG_KTAP_FFI
+       case KTAP_TCDATA:
+               cd = cdvalue(func);
+
+               if (checkstack(ks, KTAP_MIN_RESERVED_STACK_SIZE))
+                       return 1;
+
+               if (cd_type(ks, cd) != FFI_FUNC)
+                       kp_error(ks, "Value in cdata is not a c funcion\n");
+               cs = cd_csym(ks, cd);
+               kp_verbose_printf(ks, "calling ffi function [%s] with address %p\n",
+                               csym_name(cs), csym_func_addr(cs));
+
+               ci = next_ci(ks);
+               ci->nresults = nresults;
+               ci->func = restorestack(ks, funcr);
+               ci->top = ks->top + KTAP_MIN_RESERVED_STACK_SIZE;
+               ci->callstatus = 0;
+
+               n = kp_ffi_call(ks, csym_func(cs));
+               kp_verbose_printf(ks, "returned from ffi call...\n");
+               poscall(ks, ks->top - n);
+               return 1;
+#endif
+       default:
+               kp_error(ks, "attempt to call nil function\n");
+       }
+
+       return 0;
+}
+
+#define RA(i)   (base+GETARG_A(i))
+#define RB(i)   (base+GETARG_B(i))
+#define ISK(x)  ((x) & BITRK)
+#define RC(i)   base+GETARG_C(i)
+#define RKB(i) \
+        ISK(GETARG_B(i)) ? k+INDEXK(GETARG_B(i)) : base+GETARG_B(i)
+#define RKC(i)  \
+        ISK(GETARG_C(i)) ? k+INDEXK(GETARG_C(i)) : base+GETARG_C(i)
+
+#define dojump(ci,i,e) { \
+       ci->u.l.savedpc += GETARG_sBx(i) + e; }
+#define donextjump(ci)  { instr = *ci->u.l.savedpc; dojump(ci, instr, 1); }
+
+#define arith_op(ks, op) { \
+       ktap_value *rb = RKB(instr); \
+       ktap_value *rc = RKC(instr); \
+       if (is_number(rb) && is_number(rc)) { \
+               ktap_number nb = nvalue(rb), nc = nvalue(rc); \
+               set_number(ra, op(nb, nc)); \
+       } else {        \
+               kp_puts(ks, "Error: Cannot make arith operation\n");    \
+               return; \
+       } }
+
+static ktap_value *cfunction_cache_get(ktap_state *ks, int index);
+
+static void ktap_execute(ktap_state *ks)
+{
+       int exec_count = 0;
+       ktap_callinfo *ci;
+       ktap_closure *cl;
+       ktap_value *k;
+       unsigned int instr, opcode;
+       StkId base; /* stack pointer */
+       StkId ra; /* register pointer */
+       int res, nresults; /* temp varible */
+
+       ci = ks->ci;
+
+ newframe:
+       cl = clvalue(ci->func);
+       k = cl->p->k;
+       base = ci->u.l.base;
+
+ mainloop:
+       /* main loop of interpreter */
+
+       /* dead loop detaction */
+       if (exec_count++ == kp_max_exec_count) {
+               if (G(ks)->mainthread != ks) {
+                       kp_error(ks, "non-mainthread executed instructions "
+                                    "exceed max limit(%d)\n",
+                                       kp_max_exec_count);
+                       return;
+               }
+
+               cond_resched();
+               if (signal_pending(current)) {
+                       flush_signals(current);
+                       return;
+               }
+               exec_count = 0;
+       }
+
+       instr = *(ci->u.l.savedpc++);
+       opcode = GET_OPCODE(instr);
+
+       /* ra is target register */
+       ra = RA(instr);
+
+       switch (opcode) {
+       case OP_MOVE:
+               set_obj(ra, base + GETARG_B(instr));
+               break;
+       case OP_LOADK:
+               set_obj(ra, k + GETARG_Bx(instr));
+               break;
+       case OP_LOADKX:
+               set_obj(ra, k + GETARG_Ax(*ci->u.l.savedpc++));
+               break;
+       case OP_LOADBOOL:
+               set_boolean(ra, GETARG_B(instr));
+               if (GETARG_C(instr))
+                       ci->u.l.savedpc++;
+               break;
+       case OP_LOADNIL: {
+               int b = GETARG_B(instr);
+               do {
+                       set_nil(ra++);
+               } while (b--);
+               break;
+               }
+       case OP_GETUPVAL: {
+               int b = GETARG_B(instr);
+               set_obj(ra, cl->upvals[b]->v);
+               break;
+               }
+       case OP_GETTABUP: {
+               int b = GETARG_B(instr);
+               gettable(ks, cl->upvals[b]->v, RKC(instr), ra);
+               base = ci->u.l.base;
+               break;
+               }
+       case OP_GETTABLE:
+               gettable(ks, RB(instr), RKC(instr), ra);
+               base = ci->u.l.base;
+               break;
+       case OP_SETTABUP: {
+               int a = GETARG_A(instr);
+               settable(ks, cl->upvals[a]->v, RKB(instr), RKC(instr));
+               base = ci->u.l.base;
+               break;
+               }
+       case OP_SETTABUP_INCR: {
+               int a = GETARG_A(instr);
+               settable_incr(ks, cl->upvals[a]->v, RKB(instr), RKC(instr));
+               base = ci->u.l.base;
+               break;
+               }
+       case OP_SETTABUP_AGGR: {
+               int a = GETARG_A(instr);
+               ktap_value *v = cl->upvals[a]->v;
+               if (!is_ptable(v)) {
+                       kp_error(ks, "<<< must be operate on ptable\n");
+                       return;
+               }
+
+               kp_ptab_set(ks, phvalue(v), RKB(instr), RKC(instr));
+               base = ci->u.l.base;
+               break;
+               }
+       case OP_SETUPVAL: {
+               ktap_upval *uv = cl->upvals[GETARG_B(instr)];
+               set_obj(uv->v, ra);
+               break;
+               }
+       case OP_SETTABLE:
+               settable(ks, ra, RKB(instr), RKC(instr));
+               base = ci->u.l.base;
+               break;
+       case OP_SETTABLE_INCR:
+               settable_incr(ks, ra, RKB(instr), RKC(instr));
+               base = ci->u.l.base;
+               break;
+       case OP_SETTABLE_AGGR:
+               if (!is_ptable(ra)) {
+                       kp_error(ks, "<<< must be operate on ptable\n");
+                       return;
+               }
+
+               kp_ptab_set(ks, phvalue(ra), RKB(instr), RKC(instr));
+               base = ci->u.l.base;
+               break;
+       case OP_NEWTABLE: {
+               int b = GETARG_B(instr);
+               int c = GETARG_C(instr);
+               ktap_tab *t = kp_tab_new(ks);
+               set_table(ra, t);
+               if (b != 0 || c != 0)
+                       kp_tab_resize(ks, t, fb2int(b), fb2int(c));
+               break;
+               }
+       case OP_SELF: {
+               StkId rb = RB(instr);
+               set_obj(ra+1, rb);
+               gettable(ks, rb, RKC(instr), ra);
+               base = ci->u.l.base;
+               break;
+               }
+       case OP_ADD:
+               arith_op(ks, NUMADD);
+               break;
+       case OP_SUB:
+               arith_op(ks, NUMSUB);
+               break;
+       case OP_MUL:
+               arith_op(ks, NUMMUL);
+               break;
+       case OP_DIV:
+               /* divide 0 checking */
+               if (!nvalue(RKC(instr))) {
+                       kp_error(ks, "divide 0 arith operation\n");
+                       return;
+               }
+               arith_op(ks, NUMDIV);
+               break;
+       case OP_MOD:
+               /* divide 0 checking */
+               if (!nvalue(RKC(instr))) {
+                       kp_error(ks, "mod 0 arith operation\n");
+                       return;
+               }
+               arith_op(ks, NUMMOD);
+               break;
+       case OP_POW:
+               kp_error(ks, "ktap don't support pow arith in kernel\n");
+               return;
+       case OP_UNM: {
+               ktap_value *rb = RB(instr);
+               if (is_number(rb)) {
+                       ktap_number nb = nvalue(rb);
+                       set_number(ra, NUMUNM(nb));
+               }
+               break;
+               }
+       case OP_NOT:
+               res = is_false(RB(instr));
+               set_boolean(ra, res);
+               break;
+       case OP_LEN: {
+               int len = kp_objlen(ks, RB(instr));
+               if (len < 0)
+                       return;
+               set_number(ra, len);
+               break;
+               }
+       case OP_CONCAT: {
+               int b = GETARG_B(instr);
+               int c = GETARG_C(instr);
+               ktap_concat(ks, b, c);
+               break;
+               }
+       case OP_JMP:
+               dojump(ci, instr, 0);
+               break;
+       case OP_EQ: {
+               ktap_value *rb = RKB(instr);
+               ktap_value *rc = RKC(instr);
+               if ((int)rawequalobj(rb, rc) != GETARG_A(instr))
+                       ci->u.l.savedpc++;
+               else
+                       donextjump(ci);
+
+               base = ci->u.l.base;
+               break;
+               }
+       case OP_LT: {
+               if (lessthan(ks, RKB(instr), RKC(instr)) != GETARG_A(instr)) {
+                       ci->u.l.savedpc++;
+               } else
+                       donextjump(ci);
+               base = ci->u.l.base;
+               break;
+               }
+       case OP_LE:
+               if (lessequal(ks, RKB(instr), RKC(instr)) != GETARG_A(instr))
+                       ci->u.l.savedpc++;
+               else
+                       donextjump(ci);
+               base = ci->u.l.base;
+               break;
+       case OP_TEST:
+               if (GETARG_C(instr) ? is_false(ra) : !is_false(ra))
+                       ci->u.l.savedpc++;
+               else
+                       donextjump(ci);
+               break;
+       case OP_TESTSET: {
+               ktap_value *rb = RB(instr);
+               if (GETARG_C(instr) ? is_false(rb) : !is_false(rb))
+                       ci->u.l.savedpc++;
+               else {
+                       set_obj(ra, rb);
+                       donextjump(ci);
+               }
+               break;
+               }
+       case OP_CALL: {
+               int b = GETARG_B(instr);
+               int ret;
+
+               nresults = GETARG_C(instr) - 1;
+
+               if (b != 0)
+                       ks->top = ra + b;
+
+               ret = precall(ks, ra, nresults);
+               if (ret) { /* C function */
+                       if (nresults >= 0)
+                               ks->top = ci->top;
+                       base = ci->u.l.base;
+                       break;
+               } else { /* ktap function */
+                       ci = ks->ci;
+                       /* this flag is used for return time, see OP_RETURN */
+                       ci->callstatus |= CIST_REENTRY;
+                       goto newframe;
+               }
+               break;
+               }
+       case OP_TAILCALL: {
+               int b = GETARG_B(instr);
+
+               if (b != 0)
+                       ks->top = ra+b;
+               if (precall(ks, ra, -1))  /* C function? */
+                       base = ci->u.l.base;
+               else {
+                       int aux;
+
+                       /*
+                        * tail call: put called frame (n) in place of
+                        * caller one (o)
+                        */
+                       ktap_callinfo *nci = ks->ci;  /* called frame */
+                       ktap_callinfo *oci = nci->prev;  /* caller frame */
+                       StkId nfunc = nci->func;  /* called function */
+                       StkId ofunc = oci->func;  /* caller function */
+                       /* last stack slot filled by 'precall' */
+                       StkId lim = nci->u.l.base +
+                                   clvalue(nfunc)->p->numparams;
+
+                       /* close all upvalues from previous call */
+                       if (cl->p->sizep > 0)
+                               function_close(ks, oci->u.l.base);
+
+                       /* move new frame into old one */
+                       for (aux = 0; nfunc + aux < lim; aux++)
+                               set_obj(ofunc + aux, nfunc + aux);
+                       /* correct base */
+                       oci->u.l.base = ofunc + (nci->u.l.base - nfunc);
+                       /* correct top */
+                       oci->top = ks->top = ofunc + (ks->top - nfunc);
+                       oci->u.l.savedpc = nci->u.l.savedpc;
+                       /* remove new frame */
+                       ci = ks->ci = oci;
+                       /* restart ktap_execute over new ktap function */
+                       goto newframe;
+               }
+               break;
+               }
+       case OP_RETURN: {
+               int b = GETARG_B(instr);
+               if (b != 0)
+                       ks->top = ra+b-1;
+               if (cl->p->sizep > 0)
+                       function_close(ks, base);
+               b = poscall(ks, ra);
+
+               /* if it's called from external invocation, just return */
+               if (!(ci->callstatus & CIST_REENTRY))
+                       return;
+
+               ci = ks->ci;
+               if (b)
+                       ks->top = ci->top;
+               goto newframe;
+               }
+       case OP_FORLOOP: {
+               ktap_number step = nvalue(ra+2);
+               /* increment index */
+               ktap_number idx = NUMADD(nvalue(ra), step);
+               ktap_number limit = nvalue(ra+1);
+               if (NUMLT(0, step) ? NUMLE(idx, limit) : NUMLE(limit, idx)) {
+                       ci->u.l.savedpc += GETARG_sBx(instr);  /* jump back */
+                       set_number(ra, idx);  /* update internal index... */
+                       set_number(ra+3, idx);  /* ...and external index */
+               }
+               break;
+               }
+       case OP_FORPREP: {
+               const ktap_value *init = ra;
+               const ktap_value *plimit = ra + 1;
+               const ktap_value *pstep = ra + 2;
+
+               if (!ktap_tonumber(init, ra)) {
+                       kp_error(ks, KTAP_QL("for")
+                                " initial value must be a number\n");
+                       return;
+               } else if (!ktap_tonumber(plimit, ra + 1)) {
+                       kp_error(ks, KTAP_QL("for")
+                                " limit must be a number\n");
+                       return;
+               } else if (!ktap_tonumber(pstep, ra + 2)) {
+                       kp_error(ks, KTAP_QL("for") " step must be a number\n");
+                       return;
+               }
+
+               set_number(ra, NUMSUB(nvalue(ra), nvalue(pstep)));
+               ci->u.l.savedpc += GETARG_sBx(instr);
+               break;
+               }
+       case OP_TFORCALL: {
+               StkId cb = ra + 3;  /* call base */
+               set_obj(cb + 2, ra + 2);
+               set_obj(cb + 1, ra + 1);
+               set_obj(cb, ra);
+               ks->top = cb + 3;  /* func. + 2 args (state and index) */
+               kp_call(ks, cb, GETARG_C(instr));
+               base = ci->u.l.base;
+               ks->top = ci->top;
+               instr = *(ci->u.l.savedpc++);  /* go to next instruction */
+               ra = RA(instr);
+               }
+               /*go through */
+       case OP_TFORLOOP:
+               if (!is_nil(ra + 1)) {  /* continue loop? */
+                       set_obj(ra, ra + 1);  /* save control variable */
+                       ci->u.l.savedpc += GETARG_sBx(instr);  /* jump back */
+               }
+               break;
+       case OP_SETLIST: {
+               int n = GETARG_B(instr);
+               int c = GETARG_C(instr);
+               int last;
+               ktap_tab *h;
+
+               if (n == 0)
+                       n = (int)(ks->top - ra) - 1;
+               if (c == 0)
+                       c = GETARG_Ax(*ci->u.l.savedpc++);
+
+               h = hvalue(ra);
+               last = ((c - 1) * LFIELDS_PER_FLUSH) + n;
+               if (last > h->sizearray)  /* needs more space? */
+                       kp_tab_resizearray(ks, h, last);
+
+               for (; n > 0; n--) {
+                       ktap_value *val = ra+n;
+                       kp_tab_setint(ks, h, last--, val);
+               }
+               /* correct top (in case of previous open call) */
+               ks->top = ci->top;
+               break;
+               }
+       case OP_CLOSURE: {
+               /* need to use closure cache? (multithread contention issue)*/
+               ktap_proto *p = cl->p->p[GETARG_Bx(instr)];
+               pushclosure(ks, p, cl->upvals, base, ra);
+               break;
+               }
+       case OP_VARARG: {
+               int b = GETARG_B(instr) - 1;
+               int j;
+               int n = (int)(base - ci->func) - cl->p->numparams - 1;
+               if (b < 0) {  /* B == 0? */
+                       b = n;  /* get all var. arguments */
+                       if(checkstack(ks, n))
+                               return;
+                       /* previous call may change the stack */
+                       ra = RA(instr);
+                       ks->top = ra + n;
+               }
+               for (j = 0; j < b; j++) {
+                       if (j < n) {
+                               set_obj(ra + j, base - n + j);
+                       } else
+                               set_nil(ra + j);
+               }
+               break;
+               }
+       case OP_EXTRAARG:
+               return;
+
+       case OP_EVENT: {
+               struct ktap_event *e = ks->current_event;
+
+               if (unlikely(!e)) {
+                       kp_error(ks, "invalid event context\n");
+                       return;
+               }
+               set_event(ra, e);
+               break;
+               }
+
+       case OP_EVENTNAME: {
+               struct ktap_event *e = ks->current_event;
+
+               if (unlikely(!e)) {
+                       kp_error(ks, "invalid event context\n");
+                       return;
+               }
+               set_string(ra, kp_tstring_new(ks, e->call->name));
+               break;
+               }
+       case OP_EVENTARG:
+               if (unlikely(!ks->current_event)) {
+                       kp_error(ks, "invalid event context\n");
+                       return;
+               }
+
+               kp_event_getarg(ks, ra, GETARG_B(instr));
+               break;
+       case OP_LOAD_GLOBAL: {
+               ktap_value *cfunc = cfunction_cache_get(ks, GETARG_C(instr));
+               set_obj(ra, cfunc);
+               }
+               break;
+
+       case OP_EXIT:
+               return;
+       }
+
+       goto mainloop;
+}
+
+void kp_call(ktap_state *ks, StkId func, int nresults)
+{
+       if (!precall(ks, func, nresults))
+               ktap_execute(ks);
+}
+
+static int cfunction_cache_getindex(ktap_state *ks, ktap_value *fname);
+
+/*
+ * This function must be called before all code loaded.
+ */
+void kp_optimize_code(ktap_state *ks, int level, ktap_proto *f)
+{
+       int i;
+
+       for (i = 0; i < f->sizecode; i++) {
+               int instr = f->code[i];
+               ktap_value *k = f->k;
+
+               if (GET_OPCODE(instr) == OP_GETTABUP) {
+                       if ((GETARG_B(instr) == 0) && ISK(GETARG_C(instr))) {
+                               ktap_value *field = k + INDEXK(GETARG_C(instr));
+                               if (ttype(field) == KTAP_TSTRING) {
+                                       int index = cfunction_cache_getindex(ks,
+                                                                       field);
+                                       if (index == -1)
+                                               break;
+
+                                       SET_OPCODE(instr, OP_LOAD_GLOBAL);
+                                       SETARG_C(instr, index);
+                                       f->code[i] = instr;
+                                       break;
+                               }
+                       }
+               }
+       }
+
+       /* continue optimize sub functions */
+       for (i = 0; i < f->sizep; i++)
+               kp_optimize_code(ks, level + 1, f->p[i]);
+}
+
+static ktap_value *cfunction_cache_get(ktap_state *ks, int index)
+{
+       return &G(ks)->cfunction_tbl[index];
+}
+
+static int cfunction_cache_getindex(ktap_state *ks, ktap_value *fname)
+{
+       const ktap_value *gt = kp_tab_getint(hvalue(&G(ks)->registry),
+                               KTAP_RIDX_GLOBALS);
+       const ktap_value *cfunc;
+       int nr, i;
+
+       nr = G(ks)->nr_builtin_cfunction;
+       cfunc = kp_tab_get(hvalue(gt), fname);
+
+       for (i = 0; i < nr; i++) {
+               if (rawequalobj(&G(ks)->cfunction_tbl[i], cfunc))
+                       return i;
+       }
+
+       return -1;
+}
+
+static void cfunction_cache_add(ktap_state *ks, ktap_value *func)
+{
+       int nr = G(ks)->nr_builtin_cfunction;
+       set_obj(&G(ks)->cfunction_tbl[nr], func);
+       G(ks)->nr_builtin_cfunction++;
+}
+
+static void cfunction_cache_exit(ktap_state *ks)
+{
+       kp_free(ks, G(ks)->cfunction_tbl);
+}
+
+static int cfunction_cache_init(ktap_state *ks)
+{
+       G(ks)->cfunction_tbl = kp_zalloc(ks, sizeof(ktap_value) * 128);
+       if (!G(ks)->cfunction_tbl)
+               return -ENOMEM;
+
+       return 0;
+}
+
+/* function for register library */
+void kp_register_lib(ktap_state *ks, const char *libname, const ktap_Reg *funcs)
+{
+       int i;
+       ktap_tab *target_tbl;
+       const ktap_value *gt = kp_tab_getint(hvalue(&G(ks)->registry),
+                                              KTAP_RIDX_GLOBALS);
+
+       /* lib is null when register baselib function */
+       if (libname == NULL)
+               target_tbl = hvalue(gt);
+       else {
+               ktap_value key, val;
+
+               target_tbl = kp_tab_new(ks);
+               kp_tab_resize(ks, target_tbl, 0,
+                               sizeof(*funcs) / sizeof(ktap_Reg));
+
+               set_string(&key, kp_tstring_new(ks, libname));
+               set_table(&val, target_tbl);
+               kp_tab_setvalue(ks, hvalue(gt), &key, &val);
+       }
+
+       for (i = 0; funcs[i].name != NULL; i++) {
+               ktap_value func_name, cl;
+
+               set_string(&func_name, kp_tstring_new(ks, funcs[i].name));
+               set_cfunction(&cl, funcs[i].func);
+               kp_tab_setvalue(ks, target_tbl, &func_name, &cl);
+
+               cfunction_cache_add(ks, &cl);
+       }
+}
+
+static void kp_init_registry(ktap_state *ks)
+{
+       ktap_value mt;
+       ktap_tab *registry = kp_tab_new(ks);
+
+       set_table(&G(ks)->registry, registry);
+       kp_tab_resize(ks, registry, KTAP_RIDX_LAST, 0);
+       set_thread(&mt, ks);
+       kp_tab_setint(ks, registry, KTAP_RIDX_MAINTHREAD, &mt);
+       set_table(&mt, kp_tab_new(ks));
+       kp_tab_setint(ks, registry, KTAP_RIDX_GLOBALS, &mt);
+}
+
+static int kp_init_arguments(ktap_state *ks, int argc, char __user **user_argv)
+{
+       const ktap_value *gt = kp_tab_getint(hvalue(&G(ks)->registry),
+                          KTAP_RIDX_GLOBALS);
+       ktap_tab *global_tbl = hvalue(gt);
+       ktap_tab *arg_tbl = kp_tab_new(ks);
+       ktap_value arg_tblval;
+       ktap_value arg_tsval;
+       char **argv;
+       int i, ret;
+
+       set_string(&arg_tsval, kp_tstring_new(ks, "arg"));
+       set_table(&arg_tblval, arg_tbl);
+       kp_tab_setvalue(ks, global_tbl, &arg_tsval, &arg_tblval);
+
+       if (!argc)
+               return 0;
+
+       if (argc > 1024)
+               return -EINVAL;
+
+       argv = kzalloc(argc * sizeof(char *), GFP_KERNEL);
+       if (!argv)
+               return -ENOMEM;
+
+       ret = copy_from_user(argv, user_argv, argc * sizeof(char *));
+       if (ret < 0) {
+               kfree(argv);
+               return -EFAULT;
+       }
+
+       kp_tab_resize(ks, arg_tbl, argc, 1);
+
+       ret = 0;
+       for (i = 0; i < argc; i++) {
+               ktap_value val;
+               char __user *ustr = argv[i];
+               char *kstr;
+               int len;
+               int res;
+
+               len = strlen_user(ustr);
+               if (len > 0x1000) {
+                       ret = -EINVAL;
+                       break;
+               }
+
+               kstr = kmalloc(len + 1, GFP_KERNEL);
+               if (!kstr) {
+                       ret = -ENOMEM;
+                       break;
+               }
+
+               if (strncpy_from_user(kstr, ustr, len) < 0) {
+                       ret = -EFAULT;
+                       break;
+               }
+
+               kstr[len] = '\0';
+
+               if (!kstrtoint(kstr, 10, &res)) {
+                       set_number(&val, res);
+               } else
+                       set_string(&val, kp_tstring_new(ks, kstr));
+
+               kp_tab_setint(ks, arg_tbl, i, &val);
+
+               kfree(kstr);
+       }
+
+       kfree(argv);
+       return ret;
+}
+
+static void free_kp_percpu_data(ktap_state *ks)
+{
+       int i, j;
+
+       for (i = 0; i < KTAP_PERCPU_DATA_MAX; i++) {
+               for (j = 0; j < PERF_NR_CONTEXTS; j++)
+                       free_percpu(G(ks)->pcpu_data[i][j]);
+       }
+
+       for (j = 0; j < PERF_NR_CONTEXTS; j++)
+               if (G(ks)->recursion_context[j])
+                       free_percpu(G(ks)->recursion_context[j]);
+}
+
+static int alloc_kp_percpu_data(ktap_state *ks)
+{
+       int data_size[KTAP_PERCPU_DATA_MAX] = {
+               sizeof(ktap_state), KTAP_STACK_SIZE_BYTES,
+               KTAP_PERCPU_BUFFER_SIZE, KTAP_PERCPU_BUFFER_SIZE,
+               sizeof(ktap_btrace) + (KTAP_MAX_STACK_ENTRIES *
+                       sizeof(unsigned long))};
+       int i, j;
+
+       for (i = 0; i < KTAP_PERCPU_DATA_MAX; i++) {
+               for (j = 0; j < PERF_NR_CONTEXTS; j++) {
+                       void __percpu *data = __alloc_percpu(data_size[i],
+                                                            __alignof__(char));
+                       if (!data)
+                               goto fail;
+                       G(ks)->pcpu_data[i][j] = data;
+               }
+       }
+
+       for (j = 0; j < PERF_NR_CONTEXTS; j++) {
+               G(ks)->recursion_context[j] = alloc_percpu(int);
+               if (!G(ks)->recursion_context[j])
+                       goto fail;
+       }
+
+       return 0;
+
+ fail:
+       free_kp_percpu_data(ks);
+       return -ENOMEM;
+}
+
+static void kp_init_state(ktap_state *ks)
+{
+       ktap_callinfo *ci;
+
+       /* init all stack vaule to nil */
+       memset(ks->stack, 0, KTAP_STACK_SIZE_BYTES);
+
+       ks->top = ks->stack;
+       ks->stack_last = ks->stack + KTAP_STACK_SIZE;
+
+       ci = &ks->baseci;
+       ci->callstatus = 0;
+       ci->func = ks->top;
+       ci->top = ks->top + KTAP_MIN_RESERVED_STACK_SIZE;
+       ks->ci = ci;
+}
+
+static void free_all_ci(ktap_state *ks)
+{
+       int cpu, j;
+
+       for_each_possible_cpu(cpu) {
+               for (j = 0; j < PERF_NR_CONTEXTS; j++) {
+                       void *pcd = G(ks)->pcpu_data[KTAP_PERCPU_DATA_STATE][j];
+                       ktap_state *ks;
+
+                       if (!pcd)
+                               break;
+
+                       ks = per_cpu_ptr(pcd, cpu);
+                       if (!ks)
+                               break;
+
+                       free_ci(ks);
+               }
+       }
+
+       free_ci(ks);
+}
+
+void kp_exitthread(ktap_state *ks)
+{
+       /* free local allocation objects, like annotate strings */
+       kp_free_gclist(ks, ks->gclist);
+}
+
+ktap_state *kp_newthread(ktap_state *mainthread)
+{
+       ktap_state *ks;
+
+       ks = kp_percpu_data(mainthread, KTAP_PERCPU_DATA_STATE);
+       ks->stack = kp_percpu_data(mainthread, KTAP_PERCPU_DATA_STACK);
+       G(ks) = G(mainthread);
+       ks->gclist = NULL;
+       kp_init_state(ks);
+       return ks;
+}
+
+/*
+ * wait ktapio thread read all content in ring buffer.
+ *
+ * Here we use stupid approach to sync with ktapio thread,
+ * note that we cannot use semaphore/completion/other sync method,
+ * because ktapio thread could be killed by SIG_KILL in anytime, there
+ * have no safe way to up semaphore or wake waitqueue before thread exit.
+ *
+ * we also cannot use waitqueue of current->signal->wait_chldexit to sync
+ * exit, becasue mainthread and ktapio thread are in same thread group.
+ *
+ * Also ktap mainthread must wait ktapio thread exit, otherwise ktapio
+ * thread will oops when access ktap structure.
+ */
+static void wait_user_completion(ktap_state *ks)
+{
+       struct task_struct *tsk = G(ks)->task;
+       G(ks)->wait_user = 1;
+
+       while (1) {
+               set_current_state(TASK_INTERRUPTIBLE);
+               /* sleep for 100 msecs, and try again. */
+               schedule_timeout(HZ / 10);
+
+               if (get_nr_threads(tsk) == 1)
+                       break;
+       }
+}
+
+static void sleep_loop(ktap_state *ks,
+                       int (*actor)(ktap_state *ks, void *arg), void *arg)
+{
+       while (!ks->stop) {
+               set_current_state(TASK_INTERRUPTIBLE);
+               /* sleep for 100 msecs, and try again. */
+               schedule_timeout(HZ / 10);
+
+               if (actor(ks, arg))
+                       return;
+       }
+}
+
+static int sl_wait_task_pause_actor(ktap_state *ks, void *arg)
+{
+       struct task_struct *task = (struct task_struct *)arg;
+
+       if (task->state)
+               return 1;
+       else
+               return 0;
+}
+
+static int sl_wait_task_exit_actor(ktap_state *ks, void *arg)
+{
+       struct task_struct *task = (struct task_struct *)arg;
+
+       if (signal_pending(current)) {
+               flush_signals(current);
+
+               /* newline for handle CTRL+C display as ^C */
+               kp_puts(ks, "\n");
+               return 1;
+       }
+
+       /* stop waiting if target pid is exited */
+       if (task && task->state == TASK_DEAD)
+                       return 1;
+
+       return 0;
+}
+
+/* kp_wait: used for mainthread waiting for exit */
+static void kp_wait(ktap_state *ks)
+{
+       struct task_struct *task = G(ks)->trace_task;
+
+       if (G(ks)->exit)
+               return;
+
+       ks->stop = 0;
+
+       if (G(ks)->parm->workload) {
+               /* make sure workload is in pause state
+                * so it won't miss the signal */
+               sleep_loop(ks, sl_wait_task_pause_actor, task);
+               /* tell workload process to start executing */
+               send_sig(SIGINT, G(ks)->trace_task, 0);
+       }
+
+       if (!G(ks)->parm->quiet)
+               kp_printf(ks, "Tracing... Hit Ctrl-C to end.\n");
+
+       sleep_loop(ks, sl_wait_task_exit_actor, task);
+}
+
+static unsigned int kp_stub_exit_instr;
+
+static inline void set_next_as_exit(ktap_state *ks)
+{
+       ktap_callinfo *ci;
+
+       ci = ks->ci;
+       if (!ci)
+               return;
+
+       ci->u.l.savedpc = &kp_stub_exit_instr;
+
+       /* See precall, ci changed to ci->prev after invoke C function */
+       if (ci->prev) {
+               ci = ci->prev;
+               ci->u.l.savedpc = &kp_stub_exit_instr;
+       }
+}
+
+void kp_exit(ktap_state *ks)
+{
+       set_next_as_exit(ks);
+
+       G(ks)->mainthread->stop = 1;
+       G(ks)->exit = 1;
+}
+
+void kp_init_exit_instruction(void)
+{
+       SET_OPCODE(kp_stub_exit_instr, OP_EXIT);
+}
+
+/*
+ * Be careful in stats_cleanup, only can use kp_printf, since almost
+ * all ktap resources already freed now.
+ */
+static void kp_stats_cleanup(ktap_state *ks)
+{
+       ktap_stats __percpu *stats = G(ks)->stats;
+       int mem_allocated = 0, nr_mem_allocate = 0, nr_mem_free = 0;
+       int events_hits = 0, events_missed = 0;
+       int cpu;
+
+       for_each_possible_cpu(cpu) {
+               ktap_stats *per_stats = per_cpu_ptr(stats, cpu);
+               mem_allocated += per_stats->mem_allocated;
+               nr_mem_allocate += per_stats->nr_mem_allocate;
+               nr_mem_free += per_stats->nr_mem_free;
+               events_hits += per_stats->events_hits;
+               events_missed += per_stats->events_missed;
+       }
+
+       kp_verbose_printf(ks, "ktap stats:\n");
+       kp_verbose_printf(ks, "memory allocated size: %d\n", mem_allocated);
+       kp_verbose_printf(ks, "memory allocate num: %d\n", nr_mem_allocate);
+       kp_verbose_printf(ks, "memory free num: %d\n", nr_mem_free);
+       kp_verbose_printf(ks, "events_hits: %d\n", events_hits);
+       kp_verbose_printf(ks, "events_missed: %d\n", events_missed);
+
+       if (stats)
+               free_percpu(stats);
+}
+
+static int kp_stats_init(ktap_state *ks)
+{
+       ktap_stats __percpu *stats = alloc_percpu(ktap_stats);
+       if (!stats)
+               return -ENOMEM;
+
+       G(ks)->stats = stats;
+       return 0;
+}
+
+void kp_final_exit(ktap_state *ks)
+{
+       if (!list_empty(&G(ks)->probe_events_head) ||
+           !list_empty(&G(ks)->timers))
+               kp_wait(ks);
+
+       kp_exit_timers(ks);
+       kp_probe_exit(ks);
+
+       /* free all resources got by ktap */
+       kp_ffi_free_symbol(ks);
+       kp_tstring_freeall(ks);
+       kp_free_all_gcobject(ks);
+       cfunction_cache_exit(ks);
+
+       kp_exitthread(ks);
+       kp_free(ks, ks->stack);
+       free_all_ci(ks);
+
+       free_kp_percpu_data(ks);
+       free_cpumask_var(G(ks)->cpumask);
+
+       kp_stats_cleanup(ks);
+       wait_user_completion(ks);
+
+       /* should invoke after wait_user_completion */
+       if (G(ks)->trace_task)
+               put_task_struct(G(ks)->trace_task);
+
+       kp_transport_exit(ks);
+       kp_free(ks, ks);
+}
+
+/* ktap mainthread initization, main entry for ktap */
+ktap_state *kp_newstate(ktap_parm *parm, struct dentry *dir)
+{
+       ktap_state *ks;
+       pid_t pid;
+       int cpu;
+
+       ks = kzalloc(sizeof(ktap_state) + sizeof(ktap_global_state),
+                    GFP_KERNEL);
+       if (!ks)
+               return NULL;
+
+       G(ks) = (ktap_global_state *)(ks + 1);
+       G(ks)->mainthread = ks;
+       G(ks)->seed = 201236; /* todo: make more random in future */
+       G(ks)->task = current;
+       G(ks)->parm = parm;
+       G(ks)->str_lock = (arch_spinlock_t)__ARCH_SPIN_LOCK_UNLOCKED;
+       INIT_LIST_HEAD(&(G(ks)->timers));
+       INIT_LIST_HEAD(&(G(ks)->probe_events_head));
+       G(ks)->exit = 0;
+
+       if (kp_stats_init(ks))
+               goto out;
+
+       if (kp_transport_init(ks, dir))
+               goto out;
+
+       ks->stack = kp_malloc(ks, KTAP_STACK_SIZE_BYTES);
+
+       pid = (pid_t)parm->trace_pid;
+       if (pid != -1) {
+               struct task_struct *task;
+
+               rcu_read_lock();
+               task = pid_task(find_vpid(pid), PIDTYPE_PID);
+               if (!task) {
+                       kp_error(ks, "cannot find pid %d\n", pid);
+                       rcu_read_unlock();
+                       goto out;
+               }
+               G(ks)->trace_task = task;
+               get_task_struct(task);
+               rcu_read_unlock();
+       }
+
+       if( !alloc_cpumask_var(&G(ks)->cpumask, GFP_KERNEL))
+               goto out;
+
+       cpumask_copy(G(ks)->cpumask, cpu_online_mask);
+
+       cpu = parm->trace_cpu;
+       if (cpu != -1) {
+               if (!cpu_online(cpu)) {
+                       kp_error(ks, "ktap: cpu %d is not online\n", cpu);
+                       goto out;
+               }
+
+               cpumask_clear(G(ks)->cpumask);
+               cpumask_set_cpu(cpu, G(ks)->cpumask);
+       }
+
+       if (cfunction_cache_init(ks))
+               goto out;
+
+       kp_tstring_resize(ks, 512); /* set inital string hashtable size */
+
+       kp_init_state(ks);
+       kp_init_registry(ks);
+       kp_init_arguments(ks, parm->argc, parm->argv);
+
+       /* init library */
+       kp_init_baselib(ks);
+       kp_init_kdebuglib(ks);
+       kp_init_timerlib(ks);
+       kp_init_ansilib(ks);
+       kp_init_ffilib(ks);
+
+       if (alloc_kp_percpu_data(ks))
+               goto out;
+
+       if (kp_probe_init(ks))
+               goto out;
+
+       return ks;
+
+ out:
+       G(ks)->exit = 1;
+       kp_final_exit(ks);
+       return NULL;
+}
+
diff --git a/drivers/staging/ktap/runtime/kp_vm.h b/drivers/staging/ktap/runtime/kp_vm.h
new file mode 100644 (file)
index 0000000..3c7dfa5
--- /dev/null
@@ -0,0 +1,16 @@
+#ifndef __KTAP_VM_H__
+#define __KTAP_VM_H__
+
+int gettimeofday_us(void); /* common helper function */
+ktap_state *kp_newstate(struct ktap_parm *parm, struct dentry *dir);
+void kp_exit(ktap_state *ks);
+void kp_init_exit_instruction(void);
+void kp_final_exit(ktap_state *ks);
+ktap_state *kp_newthread(ktap_state *mainthread);
+void kp_exitthread(ktap_state *ks);
+void kp_call(ktap_state *ks, StkId func, int nresults);
+void kp_optimize_code(ktap_state *ks, int level, ktap_proto *f);
+void kp_register_lib(ktap_state *ks, const char *libname,
+                       const ktap_Reg *funcs);
+
+#endif /* __KTAP_VM_H__ */
diff --git a/drivers/staging/ktap/runtime/ktap.c b/drivers/staging/ktap/runtime/ktap.c
new file mode 100644 (file)
index 0000000..3df1928
--- /dev/null
@@ -0,0 +1,217 @@
+/*
+ * ktap.c - ktapvm kernel module main entry
+ *
+ * This file is part of ktap by Jovi Zhangwei.
+ *
+ * Copyright (C) 2012-2013 Jovi Zhangwei <jovi.zhangwei@gmail.com>.
+ *
+ * ktap 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.
+ *
+ * ktap is distributed in the hope it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
+ * more details.
+ *
+ * You should have received a copy of the GNU General Public License along with
+ * this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+
+/*
+ * this file is the first file to be compile, add CONFIG_ checking in here.
+ * See Requirements in doc/introduction.txt
+ */
+
+#include <linux/version.h>
+#if LINUX_VERSION_CODE < KERNEL_VERSION(3, 1, 0)
+#error "Currently ktap don't support kernel older than 3.1"
+#endif
+
+#if !CONFIG_EVENT_TRACING
+#error "Please enable CONFIG_EVENT_TRACING before compile ktap"
+#endif
+
+#if !CONFIG_PERF_EVENTS
+#error "Please enable CONFIG_PERF_EVENTS before compile ktap"
+#endif
+
+#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
+
+#include <linux/module.h>
+#include <linux/errno.h>
+#include <linux/file.h>
+#include <linux/slab.h>
+#include <linux/fcntl.h>
+#include <linux/sched.h>
+#include <linux/poll.h>
+#include <linux/anon_inodes.h>
+#include <linux/debugfs.h>
+#include <linux/vmalloc.h>
+#include "../include/ktap_types.h"
+#include "ktap.h"
+#include "kp_load.h"
+#include "kp_vm.h"
+
+static int load_trunk(struct ktap_parm *parm, unsigned long **buff)
+{
+       int ret;
+       unsigned long *vmstart;
+
+       vmstart = vmalloc(parm->trunk_len);
+       if (!vmstart)
+               return -ENOMEM;
+
+       ret = copy_from_user(vmstart, (void __user *)parm->trunk,
+                            parm->trunk_len);
+       if (ret < 0) {
+               vfree(vmstart);
+               return -EFAULT;
+       }
+
+       *buff = vmstart;
+       return 0;
+}
+
+static struct dentry *kp_dir_dentry;
+
+/* Ktap Main Entry */
+static int ktap_main(struct file *file, ktap_parm *parm)
+{
+       unsigned long *buff = NULL;
+       ktap_state *ks;
+       ktap_closure *cl;
+       int start_time, delta_time;
+       int ret;
+
+       start_time = gettimeofday_us();
+
+       ks = kp_newstate(parm, kp_dir_dentry);
+       if (unlikely(!ks))
+               return -ENOEXEC;
+
+       file->private_data = ks;
+
+       ret = load_trunk(parm, &buff);
+       if (ret) {
+               pr_err("cannot load file\n");
+               return ret;
+       }
+
+       cl = kp_load(ks, (unsigned char *)buff);
+
+       vfree(buff);
+
+       if (cl) {
+               /* optimize bytecode before excuting */
+               kp_optimize_code(ks, 0, cl->p);
+
+               delta_time = gettimeofday_us() - start_time;
+               kp_verbose_printf(ks, "booting time: %d (us)\n", delta_time);
+               kp_call(ks, ks->top - 1, 0);
+       }
+
+       kp_final_exit(ks);
+       return ret;
+}
+
+
+static void print_version(void)
+{
+}
+
+static long ktap_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
+{
+       ktap_parm parm;
+       int ret;
+
+       switch (cmd) {
+       case KTAP_CMD_IOC_VERSION:
+               print_version();
+               return 0;
+       case KTAP_CMD_IOC_RUN:
+               ret = copy_from_user(&parm, (void __user *)arg,
+                                    sizeof(ktap_parm));
+               if (ret < 0)
+                       return -EFAULT;
+
+               return ktap_main(file, &parm);
+       default:
+               return -EINVAL;
+       };
+
+        return 0;
+}
+
+static const struct file_operations ktap_fops = {
+       .llseek                 = no_llseek,
+       .unlocked_ioctl         = ktap_ioctl,
+};
+
+static long ktapvm_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
+{
+       int new_fd, err;
+       struct file *new_file;
+
+       new_fd = get_unused_fd();
+       if (new_fd < 0)
+               return new_fd;
+
+       new_file = anon_inode_getfile("[ktap]", &ktap_fops, NULL, O_RDWR);
+       if (IS_ERR(new_file)) {
+               err = PTR_ERR(new_file);
+               put_unused_fd(new_fd);
+               return err;
+       }
+
+       file->private_data = NULL;
+       fd_install(new_fd, new_file);
+       return new_fd;
+}
+
+static const struct file_operations ktapvm_fops = {
+       .owner  = THIS_MODULE,
+       .unlocked_ioctl         = ktapvm_ioctl,
+};
+
+static int __init init_ktap(void)
+{
+       struct dentry *ktapvm_dentry;
+
+       kp_dir_dentry = debugfs_create_dir("ktap", NULL);
+       if (!kp_dir_dentry) {
+               pr_err("ktap: debugfs_create_dir failed\n");
+               return -1;
+       }
+
+       ktapvm_dentry = debugfs_create_file("ktapvm", 0444, kp_dir_dentry, NULL,
+                                           &ktapvm_fops);
+
+       if (!ktapvm_dentry) {
+               pr_err("ktapvm: cannot create ktapvm file\n");
+               debugfs_remove_recursive(kp_dir_dentry);
+               return -1;
+       }
+
+       kp_init_exit_instruction();
+
+       return 0;
+}
+
+static void __exit exit_ktap(void)
+{
+       debugfs_remove_recursive(kp_dir_dentry);
+}
+
+module_init(init_ktap);
+module_exit(exit_ktap);
+
+MODULE_AUTHOR("Jovi Zhangwei <jovi.zhangwei@gmail.com>");
+MODULE_DESCRIPTION("ktap");
+MODULE_LICENSE("GPL");
+
+int kp_max_exec_count = 10000;
+module_param_named(max_exec_count, kp_max_exec_count, int, S_IRUGO | S_IWUSR);
+MODULE_PARM_DESC(max_exec_count, "non-mainthread max instruction execution count");
+
diff --git a/drivers/staging/ktap/runtime/ktap.h b/drivers/staging/ktap/runtime/ktap.h
new file mode 100644 (file)
index 0000000..06ede8c
--- /dev/null
@@ -0,0 +1,130 @@
+#ifndef __KTAP_H__
+#define __KTAP_H__
+
+#ifdef __KERNEL__
+#include <linux/version.h>
+#include <linux/hardirq.h>
+#include <linux/trace_seq.h>
+#endif
+
+typedef struct ktap_Reg {
+        const char *name;
+        ktap_cfunction func;
+} ktap_Reg;
+
+struct ktap_probe_event {
+       struct list_head list;
+       struct perf_event *perf;
+       ktap_state *ks;
+       ktap_closure *cl;
+};
+
+/* this structure allocate on stack */
+struct ktap_event {
+       struct ktap_probe_event *pevent;
+       struct ftrace_event_call *call;
+       struct trace_entry *entry;
+       int entry_size;
+       struct pt_regs *regs;
+};
+
+#define KTAP_PERCPU_BUFFER_SIZE        (3 * PAGE_SIZE)
+
+void kp_init_baselib(ktap_state *ks);
+void kp_init_oslib(ktap_state *ks);
+void kp_init_kdebuglib(ktap_state *ks);
+void kp_init_timerlib(ktap_state *ks);
+void kp_init_ansilib(ktap_state *ks);
+#ifdef CONFIG_KTAP_FFI
+void kp_init_ffilib(ktap_state *ks);
+#else
+static void __maybe_unused kp_init_ffilib(ktap_state *ks)
+{
+       return;
+}
+#endif
+
+
+int kp_probe_init(ktap_state *ks);
+void kp_probe_exit(ktap_state *ks);
+
+void kp_perf_event_register(ktap_state *ks, struct perf_event_attr *attr,
+                           struct task_struct *task, char *filter,
+                           ktap_closure *cl);
+
+void kp_event_getarg(ktap_state *ks, ktap_value *ra, int n);
+void kp_event_tostring(ktap_state *ks, struct trace_seq *seq);
+void kp_exit_timers(ktap_state *ks);
+
+extern int kp_max_exec_count;
+
+/* get from kernel/trace/trace.h */
+static __always_inline int trace_get_context_bit(void)
+{
+       int bit;
+
+       if (in_interrupt()) {
+               if (in_nmi())
+                       bit = 0;
+               else if (in_irq())
+                       bit = 1;
+               else
+                       bit = 2;
+       } else
+               bit = 3;
+
+       return bit;
+}
+
+static __always_inline int get_recursion_context(ktap_state *ks)
+{
+       int rctx = trace_get_context_bit();
+       int *val = __this_cpu_ptr(G(ks)->recursion_context[rctx]);
+
+       if (*val)
+               return -1;
+
+       *val = true;
+       barrier();
+
+       return rctx;
+}
+
+static inline void put_recursion_context(ktap_state *ks, int rctx)
+{
+       int *val = __this_cpu_ptr(G(ks)->recursion_context[rctx]);
+
+       barrier();
+       *val = false;
+}
+
+static inline void *kp_percpu_data(ktap_state *ks, int type)
+{
+       return this_cpu_ptr(G(ks)->pcpu_data[type][trace_get_context_bit()]);
+}
+
+
+#define kp_verbose_printf(ks, ...) \
+       if (G(ks)->parm->verbose)       \
+               kp_printf(ks, "[verbose] "__VA_ARGS__);
+
+/* get argument operation macro */
+#define kp_arg(ks, n)  ((ks)->ci->func + (n))
+#define kp_arg_nr(ks)  ((int)(ks->top - (ks->ci->func + 1)))
+
+#define kp_arg_check(ks, narg, type)                           \
+       do {                                                    \
+               if (unlikely(ttypenv(kp_arg(ks, narg)) != type)) {      \
+                       kp_error(ks, "wrong type of argument %d\n", narg);\
+                       return -1;                              \
+               }                                               \
+       } while (0)
+
+
+#if LINUX_VERSION_CODE > KERNEL_VERSION(3, 5, 0)
+#define SPRINT_SYMBOL  sprint_symbol_no_offset
+#else
+#define SPRINT_SYMBOL  sprint_symbol
+#endif
+
+#endif /* __KTAP_H__ */
diff --git a/drivers/staging/ktap/runtime/lib_ansi.c b/drivers/staging/ktap/runtime/lib_ansi.c
new file mode 100644 (file)
index 0000000..03f841a
--- /dev/null
@@ -0,0 +1,155 @@
+/*
+ * ansilib.c - ANSI escape sequences library
+ *
+ * http://en.wikipedia.org/wiki/ANSI_escape_code
+ *
+ * This file is part of ktap by Jovi Zhangwei.
+ *
+ * Copyright (C) 2012-2013 Jovi Zhangwei <jovi.zhangwei@gmail.com>.
+ *
+ * ktap 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.
+ *
+ * ktap is distributed in the hope it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
+ * more details.
+ *
+ * You should have received a copy of the GNU General Public License along with
+ * this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+
+#include "../include/ktap_types.h"
+#include "ktap.h"
+#include "kp_vm.h"
+
+/**
+ * function ansi.clear_screen - Move cursor to top left and clear screen.
+ *
+ * Description: Sends ansi code for moving cursor to top left and then the
+ * ansi code for clearing the screen from the cursor position to the end.
+ */
+
+static int ktap_lib_clear_screen(ktap_state *ks)
+{
+       kp_printf(ks, "\033[1;1H\033[J");
+       return 0;
+}
+
+/**
+ * function ansi.set_color - Set the ansi Select Graphic Rendition mode.
+ * @fg: Foreground color to set.
+ *
+ * Description: Sends ansi code for Select Graphic Rendition mode for the
+ * given forground color. Black (30), Blue (34), Green (32), Cyan (36),
+ * Red (31), Purple (35), Brown (33), Light Gray (37).
+ */
+
+static int ktap_lib_set_color(ktap_state *ks)
+{
+       int fg;
+
+       kp_arg_check(ks, 1, KTAP_TNUMBER);
+
+       fg = nvalue(kp_arg(ks, 1));
+       kp_printf(ks, "\033[%dm", fg);
+       return 0;
+}
+
+/**
+ * function ansi.set_color2 - Set the ansi Select Graphic Rendition mode.
+ * @fg: Foreground color to set.
+ * @bg: Background color to set.
+ *
+ * Description: Sends ansi code for Select Graphic Rendition mode for the
+ * given forground color, Black (30), Blue (34), Green (32), Cyan (36),
+ * Red (31), Purple (35), Brown (33), Light Gray (37) and the given
+ * background color, Black (40), Red (41), Green (42), Yellow (43),
+ * Blue (44), Magenta (45), Cyan (46), White (47).
+ */
+static int ktap_lib_set_color2(ktap_state *ks)
+{
+       int fg, bg;
+
+       kp_arg_check(ks, 1, KTAP_TNUMBER);
+       kp_arg_check(ks, 2, KTAP_TNUMBER);
+
+       fg = nvalue(kp_arg(ks, 1));
+       bg = nvalue(kp_arg(ks, 2));
+       kp_printf(ks, "\033[%d;%dm", fg, bg);
+       return 0;
+}
+
+/**
+ * function ansi.set_color3 - Set the ansi Select Graphic Rendition mode.
+ * @fg: Foreground color to set.
+ * @bg: Background color to set.
+ * @attr: Color attribute to set.
+ *
+ * Description: Sends ansi code for Select Graphic Rendition mode for the
+ * given forground color, Black (30), Blue (34), Green (32), Cyan (36),
+ * Red (31), Purple (35), Brown (33), Light Gray (37), the given
+ * background color, Black (40), Red (41), Green (42), Yellow (43),
+ * Blue (44), Magenta (45), Cyan (46), White (47) and the color attribute
+ * All attributes off (0), Intensity Bold (1), Underline Single (4),
+ * Blink Slow (5), Blink Rapid (6), Image Negative (7).
+ */
+static int ktap_lib_set_color3(ktap_state *ks)
+{
+       int fg, bg, attr;
+
+       kp_arg_check(ks, 1, KTAP_TNUMBER);
+       kp_arg_check(ks, 2, KTAP_TNUMBER);
+       kp_arg_check(ks, 3, KTAP_TNUMBER);
+
+       fg = nvalue(kp_arg(ks, 1));
+       bg = nvalue(kp_arg(ks, 2));
+       attr = nvalue(kp_arg(ks, 3));
+
+       if (attr)
+               kp_printf(ks, "\033[%d;%d;%dm", fg, bg, attr);
+       else
+               kp_printf(ks, "\033[%d;%dm", fg, bg);
+
+       return 0;
+}
+
+/**
+ * function ansi.reset_color - Resets Select Graphic Rendition mode.
+ *
+ * Description: Sends ansi code to reset foreground, background and color
+ * attribute to default values.
+ */
+static int ktap_lib_reset_color(ktap_state *ks)
+{
+       kp_printf(ks, "\033[0;0m");
+       return 0;
+}
+
+/**
+ * function ansi.new_line - Move cursor to new line.
+ *
+ * Description: Sends ansi code new line.
+ */
+static int ktap_lib_new_line (ktap_state *ks)
+{
+       kp_printf(ks, "\12");
+       return 0;
+}
+
+static const ktap_Reg ansi_funcs[] = {
+       {"clear_screen", ktap_lib_clear_screen},
+       {"set_color", ktap_lib_set_color},
+       {"set_color2", ktap_lib_set_color2},
+       {"set_color3", ktap_lib_set_color3},
+       {"reset_color", ktap_lib_reset_color},
+       {"new_line", ktap_lib_new_line},
+       {NULL}
+};
+
+void kp_init_ansilib(ktap_state *ks)
+{
+       kp_register_lib(ks, "ansi", ansi_funcs);
+}
diff --git a/drivers/staging/ktap/runtime/lib_base.c b/drivers/staging/ktap/runtime/lib_base.c
new file mode 100644 (file)
index 0000000..cf084df
--- /dev/null
@@ -0,0 +1,607 @@
+/*
+ * baselib.c - ktapvm kernel module base library
+ *
+ * This file is part of ktap by Jovi Zhangwei.
+ *
+ * Copyright (C) 2012-2013 Jovi Zhangwei <jovi.zhangwei@gmail.com>.
+ *
+ * ktap 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.
+ *
+ * ktap is distributed in the hope it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
+ * more details.
+ *
+ * You should have received a copy of the GNU General Public License along with
+ * this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+
+#include <linux/version.h>
+#include <linux/hardirq.h>
+#include <linux/kallsyms.h>
+#include <linux/sched.h>
+#include <linux/uaccess.h>
+#include <linux/utsname.h>
+#include <linux/time.h>
+#include <linux/clocksource.h>
+#include <linux/ring_buffer.h>
+#include <linux/stacktrace.h>
+#include <linux/cred.h>
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 5, 0)
+#include <linux/uidgid.h>
+#endif
+#include "../include/ktap_types.h"
+#include "ktap.h"
+#include "kp_obj.h"
+#include "kp_str.h"
+#include "kp_tab.h"
+#include "kp_transport.h"
+#include "kp_vm.h"
+
+static int ktap_lib_next(ktap_state *ks)
+{
+       ktap_tab *t = hvalue(ks->top - 2);
+
+       if (kp_tab_next(ks, t, ks->top-1)) {
+               ks->top += 1;
+               return 2;
+       } else {
+               ks->top -= 1;
+               set_nil(ks->top++);
+               return 1;
+       }
+}
+
+static int ktap_lib_pairs(ktap_state *ks)
+{
+       ktap_value *v = kp_arg(ks, 1);
+       ktap_tab *t;
+
+       if (is_table(v)) {
+               t = hvalue(v);
+       } else if (is_ptable(v)) {
+               t = kp_ptab_synthesis(ks, phvalue(v));
+       } else if (is_nil(v)) {
+               kp_error(ks, "table is nil in pairs\n");
+               return 0;
+       } else {
+               kp_error(ks, "wrong argument for pairs\n");
+               return 0;
+       }
+
+       set_cfunction(ks->top++, ktap_lib_next);
+       set_table(ks->top++, t);
+       set_nil(ks->top++);
+       return 3;
+}
+
+static int ktap_lib_sort_next(ktap_state *ks)
+{
+       ktap_tab *t = hvalue(ks->top - 2);
+
+       if (kp_tab_sort_next(ks, t, ks->top-1)) {
+               ks->top += 1;
+               return 2;
+       } else {
+               ks->top -= 1;
+               set_nil(ks->top++);
+               return 1;
+       }
+}
+
+static int ktap_lib_sort_pairs(ktap_state *ks)
+{
+       ktap_value *v = kp_arg(ks, 1);
+       ktap_closure *cmp_func = NULL;
+       ktap_tab *t;
+
+       if (is_table(v)) {
+               t = hvalue(v);
+       } else if (is_ptable(v)) {
+               t = kp_ptab_synthesis(ks, phvalue(v));
+       } else if (is_nil(v)) {
+               kp_error(ks, "table is nil in pairs\n");
+               return 0;
+       } else {
+               kp_error(ks, "wrong argument for pairs\n");
+               return 0;
+       }
+
+       if (kp_arg_nr(ks) > 1) {
+               kp_arg_check(ks, 2, KTAP_TFUNCTION);
+               cmp_func = clvalue(kp_arg(ks, 2));
+       }
+
+       kp_tab_sort(ks, t, cmp_func);
+       set_cfunction(ks->top++, ktap_lib_sort_next);
+       set_table(ks->top++, t);
+       set_nil(ks->top++);
+       return 3;
+}
+
+static int ktap_lib_len(ktap_state *ks)
+{
+       int len = kp_objlen(ks, kp_arg(ks, 1));
+
+       if (len < 0)
+               return -1;
+
+       set_number(ks->top, len);
+       incr_top(ks);
+       return 1;
+}
+
+static int ktap_lib_print(ktap_state *ks)
+{
+       int i;
+       int n = kp_arg_nr(ks);
+
+       for (i = 1; i <= n; i++) {
+               ktap_value *arg = kp_arg(ks, i);
+               if (i > 1)
+                       kp_puts(ks, "\t");
+               kp_showobj(ks, arg);
+       }
+
+       kp_puts(ks, "\n");
+
+       return 0;
+}
+
+/* don't engage with tstring when printf, use buffer directly */
+static int ktap_lib_printf(ktap_state *ks)
+{
+       struct trace_seq *seq;
+
+       preempt_disable_notrace();
+
+       seq = kp_percpu_data(ks, KTAP_PERCPU_DATA_BUFFER);
+       trace_seq_init(seq);
+
+       if (kp_str_fmt(ks, seq))
+               goto out;
+
+       seq->buffer[seq->len] = '\0';
+       kp_transport_write(ks, seq->buffer, seq->len + 1);
+
+ out:
+       preempt_enable_notrace();
+       return 0;
+}
+
+#ifdef CONFIG_STACKTRACE
+static int ktap_lib_print_backtrace(ktap_state *ks)
+{
+       int skip = 10, max_entries = 10;
+       int n = kp_arg_nr(ks);
+
+       if (n >= 1) {
+               kp_arg_check(ks, 1, KTAP_TNUMBER);
+               skip = nvalue(kp_arg(ks, 1));
+       }
+       if (n >= 2) {
+               kp_arg_check(ks, 2, KTAP_TNUMBER);
+               max_entries = nvalue(kp_arg(ks, 2));
+               max_entries = min(max_entries, KTAP_MAX_STACK_ENTRIES);
+       }
+
+       kp_transport_print_backtrace(ks, skip, max_entries);
+       return 0;
+}
+#else
+static int ktap_lib_print_backtrace(ktap_state *ks)
+{
+       kp_error(ks, "Please enable CONFIG_STACKTRACE before use "
+                    "ktap print_backtrace\n");
+       return 0;
+}
+#endif
+
+static int ktap_lib_backtrace(ktap_state *ks)
+{
+       struct stack_trace trace;
+       int skip = 10, max_entries = 10;
+       int n = kp_arg_nr(ks);
+       ktap_btrace *bt;
+
+       if (n >= 1) {
+               kp_arg_check(ks, 1, KTAP_TNUMBER);
+               skip = nvalue(kp_arg(ks, 1));
+       }
+       if (n >= 2) {
+               kp_arg_check(ks, 2, KTAP_TNUMBER);
+               max_entries = nvalue(kp_arg(ks, 2));
+               max_entries = min(max_entries, KTAP_MAX_STACK_ENTRIES);
+       }
+
+       bt = kp_percpu_data(ks, KTAP_PERCPU_DATA_BTRACE);
+
+       trace.nr_entries = 0;
+       trace.skip = skip;
+       trace.max_entries = max_entries;
+       trace.entries = (unsigned long *)(bt + 1);
+       save_stack_trace(&trace);
+
+       bt->nr_entries = trace.nr_entries;
+       set_btrace(ks->top, bt);
+       incr_top(ks);
+       return 1;
+}
+
+extern unsigned long long ns2usecs(cycle_t nsec);
+static int ktap_lib_print_trace_clock(ktap_state *ks)
+{
+       unsigned long long t;
+       unsigned long secs, usec_rem;
+       u64 timestamp;
+
+       /* use ring buffer's timestamp */
+       timestamp = ring_buffer_time_stamp(G(ks)->buffer, smp_processor_id());
+
+       t = ns2usecs(timestamp);
+       usec_rem = do_div(t, USEC_PER_SEC);
+       secs = (unsigned long)t;
+
+       kp_printf(ks, "%5lu.%06lu\n", secs, usec_rem);
+
+       return 0;
+}
+
+static int ktap_lib_exit(ktap_state *ks)
+{
+       kp_exit(ks);
+
+       /* do not execute bytecode any more in this thread */
+       return -1;
+}
+
+static int ktap_lib_pid(ktap_state *ks)
+{
+       set_number(ks->top, (int)current->pid);
+       incr_top(ks);
+       return 1;
+}
+
+static int ktap_lib_tid(ktap_state *ks)
+{
+       pid_t pid = task_pid_vnr(current);
+
+       set_number(ks->top, (int)pid);
+       incr_top(ks);
+       return 1;
+}
+
+static int ktap_lib_uid(ktap_state *ks)
+{
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 5, 0)
+       uid_t uid = from_kuid_munged(current_user_ns(), current_uid());
+#else
+       uid_t uid = current_uid();
+#endif
+       set_number(ks->top, (int)uid);
+       incr_top(ks);
+       return 1;
+}
+
+static int ktap_lib_execname(ktap_state *ks)
+{
+       ktap_string *ts = kp_tstring_new(ks, current->comm);
+       set_string(ks->top, ts);
+       incr_top(ks);
+       return 1;
+}
+
+static int ktap_lib_cpu(ktap_state *ks)
+{
+       set_number(ks->top, smp_processor_id());
+       incr_top(ks);
+       return 1;
+}
+
+static int ktap_lib_num_cpus(ktap_state *ks)
+{
+       set_number(ks->top, num_online_cpus());
+       incr_top(ks);
+       return 1;
+}
+
+static int ktap_lib_in_interrupt(ktap_state *ks)
+{
+       int ret = in_interrupt();
+
+       set_number(ks->top, ret);
+       incr_top(ks);
+       return 1;
+}
+
+static int ktap_lib_arch(ktap_state *ks)
+{
+       set_string(ks->top, kp_tstring_new(ks, utsname()->machine));
+       incr_top(ks);
+       return 1;
+}
+
+static int ktap_lib_kernel_v(ktap_state *ks)
+{
+       set_string(ks->top, kp_tstring_new(ks, utsname()->release));
+       incr_top(ks);
+       return 1;
+}
+
+static int ktap_lib_kernel_string(ktap_state *ks)
+{
+       unsigned long addr;
+       char str[256] = {0};
+       char *ret;
+
+       kp_arg_check(ks, 1, KTAP_TNUMBER);
+
+       addr = nvalue(kp_arg(ks, 1));
+
+       ret = strncpy((void *)str, (const void *)addr, 256);
+       (void) &ret;  /* Silence compiler warning. */
+
+       str[255] = '\0';
+       set_string(ks->top, kp_tstring_new_local(ks, str));
+
+       incr_top(ks);
+       return 1;
+}
+
+static int ktap_lib_user_string(ktap_state *ks)
+{
+       unsigned long addr;
+       char str[256] = {0};
+       int ret;
+
+       kp_arg_check(ks, 1, KTAP_TNUMBER);
+
+       addr = nvalue(kp_arg(ks, 1));
+
+       pagefault_disable();
+       ret = __copy_from_user_inatomic((void *)str, (const void *)addr, 256);
+       (void) &ret;  /* Silence compiler warning. */
+       pagefault_enable();
+       str[255] = '\0';
+       set_string(ks->top, kp_tstring_new(ks, str));
+
+       incr_top(ks);
+       return 1;
+}
+
+static int ktap_lib_histogram(ktap_state *ks)
+{
+       ktap_value *v = kp_arg(ks, 1);
+
+       if (is_table(v))
+               kp_tab_histogram(ks, hvalue(v));
+       else if (is_ptable(v))
+               kp_ptab_histogram(ks, phvalue(v));
+
+       return 0;
+}
+
+static int ktap_lib_ptable(ktap_state *ks)
+{
+       ktap_ptab *ph;
+
+       ph = kp_ptab_new(ks);
+       set_ptable(ks->top, ph);
+       incr_top(ks);
+       return 1;
+}
+
+static int ktap_lib_count(ktap_state *ks)
+{
+       ktap_value *v = kp_arg(ks, 1);
+       ktap_stat_data *sd;
+
+       if (is_nil(v)) {
+               set_number(ks->top, 0);
+               incr_top(ks);
+               return 1;
+       }
+
+       kp_arg_check(ks, 1, KTAP_TSTATDATA);
+       sd = sdvalue(v);
+
+       set_number(ks->top, sd->count);
+       incr_top(ks);
+       return 1;
+}
+
+static int ktap_lib_max(ktap_state *ks)
+{
+       ktap_value *v = kp_arg(ks, 1);
+       ktap_stat_data *sd;
+
+       if (is_nil(v)) {
+               set_number(ks->top, 0);
+               incr_top(ks);
+               return 1;
+       }
+
+       kp_arg_check(ks, 1, KTAP_TSTATDATA);
+       sd = sdvalue(v);
+
+       set_number(ks->top, sd->max);
+       incr_top(ks);
+       return 1;
+}
+
+static int ktap_lib_min(ktap_state *ks)
+{
+       ktap_value *v = kp_arg(ks, 1);
+       ktap_stat_data *sd;
+
+       if (is_nil(v)) {
+               set_number(ks->top, 0);
+               incr_top(ks);
+               return 1;
+       }
+
+       kp_arg_check(ks, 1, KTAP_TSTATDATA);
+       sd = sdvalue(v);
+
+       set_number(ks->top, sd->min);
+       incr_top(ks);
+       return 1;
+}
+
+static int ktap_lib_sum(ktap_state *ks)
+{
+       ktap_value *v = kp_arg(ks, 1);
+       ktap_stat_data *sd;
+
+       if (is_nil(v)) {
+               set_number(ks->top, 0);
+               incr_top(ks);
+               return 1;
+       }
+
+       kp_arg_check(ks, 1, KTAP_TSTATDATA);
+       sd = sdvalue(v);
+
+       set_number(ks->top, sd->sum);
+       incr_top(ks);
+       return 1;
+}
+
+static int ktap_lib_avg(ktap_state *ks)
+{
+       ktap_value *v = kp_arg(ks, 1);
+       ktap_stat_data *sd;
+
+       if (is_nil(v)) {
+               set_number(ks->top, 0);
+               incr_top(ks);
+               return 1;
+       }
+
+       kp_arg_check(ks, 1, KTAP_TSTATDATA);
+       sd = sdvalue(v);
+
+       set_number(ks->top, sd->sum / sd->count);
+       incr_top(ks);
+       return 1;
+}
+
+static int ktap_lib_delete(ktap_state *ks)
+{
+       kp_arg_check(ks, 1, KTAP_TTABLE);
+
+       kp_tab_clear(ks, hvalue(kp_arg(ks, 1)));
+       return 0;
+}
+
+static int ktap_lib_gettimeofday_us(ktap_state *ks)
+{
+       set_number(ks->top, gettimeofday_us());
+       incr_top(ks);
+
+       return 1;
+}
+
+/*
+ * use gdb to get field offset of struct task_struct, for example:
+ *
+ * gdb vmlinux
+ * (gdb)p &(((struct task_struct *)0).prio)
+ */
+static int ktap_lib_curr_task_info(ktap_state *ks)
+{
+       int offset;
+       int fetch_bytes;
+
+       kp_arg_check(ks, 1, KTAP_TNUMBER);
+
+       offset = nvalue(kp_arg(ks, 1));
+
+       if (kp_arg_nr(ks) == 1)
+               fetch_bytes = 4; /* default fetch 4 bytes*/
+       else {
+               kp_arg_check(ks, 2, KTAP_TNUMBER);
+               fetch_bytes = nvalue(kp_arg(ks, 2));
+       }
+
+       if (offset >= sizeof(struct task_struct)) {
+               set_nil(ks->top++);
+               kp_error(ks, "access out of bound value of task_struct\n");
+               return 1;
+       }
+
+#define RET_VALUE ((unsigned long)current + offset)
+
+       switch (fetch_bytes) {
+       case 4:
+               set_number(ks->top, *(unsigned int *)RET_VALUE);
+               break;
+       case 8:
+               set_number(ks->top, *(unsigned long *)RET_VALUE);
+               break;
+       default:
+               kp_error(ks, "unsupported fetch bytes in curr_task_info\n");
+               set_nil(ks->top);
+               break;
+       }
+
+#undef RET_VALUE
+
+       incr_top(ks);
+       return 1;
+}
+
+/*
+ * This built-in function mainly purpose scripts/schedule/schedtimes.kp
+ */
+static int ktap_lib_in_iowait(ktap_state *ks)
+{
+       set_number(ks->top, current->in_iowait);
+       incr_top(ks);
+
+       return 1;
+}
+
+static const ktap_Reg base_funcs[] = {
+       {"pairs", ktap_lib_pairs},
+       {"sort_pairs", ktap_lib_sort_pairs},
+       {"len", ktap_lib_len},
+       {"print", ktap_lib_print},
+       {"printf", ktap_lib_printf},
+       {"print_backtrace", ktap_lib_print_backtrace},
+       {"backtrace", ktap_lib_backtrace},
+       {"print_trace_clock", ktap_lib_print_trace_clock},
+       {"in_interrupt", ktap_lib_in_interrupt},
+       {"exit", ktap_lib_exit},
+       {"pid", ktap_lib_pid},
+       {"tid", ktap_lib_tid},
+       {"uid", ktap_lib_uid},
+       {"execname", ktap_lib_execname},
+       {"cpu", ktap_lib_cpu},
+       {"num_cpus", ktap_lib_num_cpus},
+       {"arch", ktap_lib_arch},
+       {"kernel_v", ktap_lib_kernel_v},
+       {"kernel_string", ktap_lib_kernel_string},
+       {"user_string", ktap_lib_user_string},
+       {"histogram", ktap_lib_histogram},
+       {"ptable", ktap_lib_ptable},
+       {"count", ktap_lib_count},
+       {"max", ktap_lib_max},
+       {"min", ktap_lib_min},
+       {"sum", ktap_lib_sum},
+       {"avg", ktap_lib_avg},
+
+       {"delete", ktap_lib_delete},
+       {"gettimeofday_us", ktap_lib_gettimeofday_us},
+       {"curr_taskinfo", ktap_lib_curr_task_info},
+       {"in_iowait", ktap_lib_in_iowait},
+       {NULL}
+};
+
+void kp_init_baselib(ktap_state *ks)
+{
+       kp_register_lib(ks, NULL, base_funcs);
+}
diff --git a/drivers/staging/ktap/runtime/lib_ffi.c b/drivers/staging/ktap/runtime/lib_ffi.c
new file mode 100644 (file)
index 0000000..ac1e4ef
--- /dev/null
@@ -0,0 +1,50 @@
+/*
+ * ffi.c - ktapvm kernel module ffi library
+ *
+ * This file is part of ktap by Jovi Zhangwei.
+ *
+ * Copyright (C) 2012-2013 Jovi Zhangwei <jovi.zhangwei@gmail.com>.
+ *
+ * ktap 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.
+ *
+ * ktap is distributed in the hope it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
+ * more details.
+ *
+ * You should have received a copy of the GNU General Public License along with
+ * this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+
+#include "../include/ktap_types.h"
+#include "../include/ktap_ffi.h"
+#include "ktap.h"
+#include "kp_vm.h"
+
+/*@TODO Design how to implement ffi helper functions  22.11 2013 (unihorn)*/
+
+static int kp_ffi_new(ktap_state *ks)
+{
+       /*@TODO finish this  08.11 2013 (houqp)*/
+       return 0;
+}
+
+static int kp_ffi_sizeof(ktap_state *ks)
+{
+       /*@TODO finish this  08.11 2013 (houqp)*/
+       return 0;
+}
+
+static const ktap_Reg ffi_funcs[] = {
+       {"sizeof", kp_ffi_sizeof},
+       {"new", kp_ffi_new},
+       {NULL}
+};
+
+void kp_init_ffilib(ktap_state *ks)
+{
+       kp_register_lib(ks, "ffi", ffi_funcs);
+}
diff --git a/drivers/staging/ktap/runtime/lib_kdebug.c b/drivers/staging/ktap/runtime/lib_kdebug.c
new file mode 100644 (file)
index 0000000..409a632
--- /dev/null
@@ -0,0 +1,426 @@
+/*
+ * kdebug.c - ktap probing core implementation
+ *
+ * This file is part of ktap by Jovi Zhangwei.
+ *
+ * Copyright (C) 2012-2013 Jovi Zhangwei <jovi.zhangwei@gmail.com>.
+ *
+ * ktap 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.
+ *
+ * ktap is distributed in the hope it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
+ * more details.
+ *
+ * You should have received a copy of the GNU General Public License along with
+ * this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+
+#include <linux/module.h>
+#include <linux/ctype.h>
+#include <linux/version.h>
+#include <linux/ftrace_event.h>
+#include "../include/ktap_types.h"
+#include "ktap.h"
+#include "kp_obj.h"
+#include "kp_str.h"
+#include "kp_transport.h"
+#include "kp_vm.h"
+
+static void ktap_call_probe_closure(ktap_state *mainthread, ktap_closure *cl,
+                                   struct ktap_event *e)
+{
+       ktap_state *ks;
+       ktap_value *func;
+
+       ks = kp_newthread(mainthread);
+       set_closure(ks->top, cl);
+       func = ks->top;
+       incr_top(ks);
+
+       ks->current_event = e;
+
+       kp_call(ks, func, 0);
+
+       ks->current_event = NULL;
+       kp_exitthread(ks);
+}
+
+void kp_event_tostring(ktap_state *ks, struct trace_seq *seq)
+{
+       struct ktap_event *e = ks->current_event;
+       struct trace_iterator *iter;
+       struct trace_event *ev;
+       enum print_line_t ret = TRACE_TYPE_NO_CONSUME;
+
+       /* Simulate the iterator */
+
+       /*
+        * use temp percpu buffer as trace_iterator
+        * we cannot use same temp buffer as printf.
+        */
+       iter = kp_percpu_data(ks, KTAP_PERCPU_DATA_BUFFER2);
+
+       trace_seq_init(&iter->seq);
+       iter->ent = e->entry;
+
+       ev = &(e->call->event);
+       if (ev)
+               ret = ev->funcs->trace(iter, 0, ev);
+
+       if (ret != TRACE_TYPE_NO_CONSUME) {
+               struct trace_seq *s = &iter->seq;
+               int len = s->len >= PAGE_SIZE ? PAGE_SIZE - 1 : s->len;
+
+               s->buffer[len] = '\0';
+               _trace_seq_puts(seq, s->buffer);
+       }
+}
+
+/* This definition should keep update with kernel/trace/trace.h */
+struct ftrace_event_field {
+       struct list_head        link;
+       const char              *name;
+       const char              *type;
+       int                     filter_type;
+       int                     offset;
+       int                     size;
+       int                     is_signed;
+};
+
+static struct list_head *ktap_get_fields(struct ftrace_event_call *event_call)
+{
+       if (!event_call->class->get_fields)
+               return &event_call->class->fields;
+       return event_call->class->get_fields(event_call);
+}
+
+static void get_field_value(ktap_state *ks, struct ktap_event *e,
+                           struct ftrace_event_field *field, ktap_value *ra)
+{
+       void *value = (unsigned char *)e->entry + field->offset;
+
+       if (field->size == 4) {
+               int n = *(int *)value;
+               set_number(ra, n);
+               return;
+       } else if (field->size == 8) {
+               long n = *(long *)value;
+               set_number(ra, n);
+               return;
+       }
+
+       if (!strncmp(field->type, "char", 4)) {
+               set_string(ra, kp_tstring_new(ks, (char *)value));
+               return;
+       }
+}
+
+void kp_event_getarg(ktap_state *ks, ktap_value *ra, int n)
+{
+       struct ktap_event *e = ks->current_event;
+       int index = n;
+       struct ftrace_event_field *field;
+       struct list_head *head;
+
+       /* this is very slow and not safe, fix it in future */
+       head = ktap_get_fields(e->call);
+       list_for_each_entry_reverse(field, head, link) {
+               if (--index == 0) {
+                       get_field_value(ks, e, field, ra);
+                       return;
+               }
+       }
+
+       set_nil(ra);
+       return;
+}
+
+/* Callback function for perf event subsystem
+ * make ktap reentrant, don't disable irq in callback function,
+ * same as perf and ftrace. to make reentrant, we need some
+ * percpu data to be context isolation(irq/sirq/nmi/process)
+ *
+ * The recursion checking in here is mainly purpose for avoiding
+ * corrupt ktap_state with timer closure callback. For tracepoint
+ * recusion, perf core already handle it.
+ *
+ * Note tracepoint handler is calling with rcu_read_lock.
+ */
+static void ktap_overflow_callback(struct perf_event *event,
+                                  struct perf_sample_data *data,
+                                  struct pt_regs *regs)
+{
+       struct ktap_probe_event *ktap_pevent;
+       struct ktap_event e;
+       ktap_state  *ks;
+       int rctx;
+
+       ktap_pevent = event->overflow_handler_context;
+       ks = ktap_pevent->ks;
+
+       if (unlikely(ks->stop))
+               return;
+
+       rctx = get_recursion_context(ks);
+       if (rctx < 0)
+               return;
+
+       KTAP_STATS(ks)->events_hits += 1;
+
+       /* profile perf event don't have valid associated tp_event */
+       if (event->tp_event) {
+               e.call = event->tp_event;
+               e.entry = data->raw->data;
+               e.entry_size = data->raw->size;
+       }
+       e.pevent = ktap_pevent;
+       e.regs = regs;
+
+       ktap_call_probe_closure(ks, ktap_pevent->cl, &e);
+
+       put_recursion_context(ks, rctx);
+}
+
+static void perf_destructor(struct ktap_probe_event *ktap_pevent)
+{
+       perf_event_release_kernel(ktap_pevent->perf);
+}
+
+static int (*kp_ftrace_profile_set_filter)(struct perf_event *event,
+                                          int event_id, char *filter_str);
+
+/*
+ * Generic perf event register function
+ * used by tracepoints/kprobe/uprobe/profile-timer/hw_breakpoint.
+ */
+void kp_perf_event_register(ktap_state *ks, struct perf_event_attr *attr,
+                           struct task_struct *task, char *filter,
+                           ktap_closure *cl)
+{
+       struct ktap_probe_event *ktap_pevent;
+       struct kmem_cache *pevent_cache = G(ks)->pevent_cache;
+       struct perf_event *event;
+       int cpu, ret;
+
+       kp_verbose_printf(ks, "enable perf event id: %d, filter: %s "
+                             "pid: %d\n", attr->config, filter,
+                             task ? task_tgid_vnr(task) : -1);
+
+       /*
+        * don't tracing until ktap_wait, the reason is:
+        * 1). some event may hit before apply filter
+        * 2). more simple to manage tracing thread
+        * 3). avoid race with mainthread.
+        *
+        * Another way to do this is make attr.disabled as 1, then use
+        * perf_event_enable after filter apply, however, perf_event_enable
+        * was not exported in kernel older than 3.3, so we drop this method.
+        */
+       ks->stop = 1;
+
+       for_each_cpu(cpu, G(ks)->cpumask) {
+               ktap_pevent = kmem_cache_zalloc(pevent_cache, GFP_KERNEL);
+               if (!ktap_pevent)
+                       return;
+
+               ktap_pevent->ks = ks;
+               ktap_pevent->cl = cl;
+               event = perf_event_create_kernel_counter(attr, cpu, task,
+                                                        ktap_overflow_callback,
+                                                        ktap_pevent);
+               if (IS_ERR(event)) {
+                       int err = PTR_ERR(event);
+                       kp_error(ks, "unable register perf event %d on cpu %d, "
+                                    "err: %d\n", attr->config, cpu, err);
+                       kp_free(ks, ktap_pevent);
+                       return;
+               }
+
+               ktap_pevent->perf = event;
+               INIT_LIST_HEAD(&ktap_pevent->list);
+               list_add_tail(&ktap_pevent->list, &G(ks)->probe_events_head);
+
+               if (!filter)
+                       continue;
+
+               ret = kp_ftrace_profile_set_filter(event, attr->config, filter);
+               if (ret) {
+                       kp_error(ks, "unable set filter %s for event id %d, "
+                                    "ret: %d\n", filter, attr->config, ret);
+                       perf_destructor(ktap_pevent);
+                       list_del(&ktap_pevent->list);
+                       kp_free(ks, ktap_pevent);
+                       return;
+               }
+       }
+}
+
+static void end_probes(struct ktap_state *ks)
+{
+       struct ktap_probe_event *ktap_pevent;
+       struct list_head *tmp, *pos;
+       struct list_head *head = &G(ks)->probe_events_head;
+
+       list_for_each(pos, head) {
+               ktap_pevent = container_of(pos, struct ktap_probe_event,
+                                          list);
+               perf_destructor(ktap_pevent);
+        }
+               /*
+        * Ensure our callback won't be called anymore. The buffers
+        * will be freed after that.
+        */
+       tracepoint_synchronize_unregister();
+
+       list_for_each_safe(pos, tmp, head) {
+               ktap_pevent = container_of(pos, struct ktap_probe_event,
+                                          list);
+               list_del(&ktap_pevent->list);
+               kp_free(ks, ktap_pevent);
+       }
+}
+
+static int ktap_lib_probe_by_id(ktap_state *ks)
+{
+       ktap_closure *cl;
+       struct task_struct *task = G(ks)->trace_task;
+       ktap_eventdef_info evdef_info;
+       char *filter = NULL;
+       int *id_arr;
+       int ret, i;
+
+       /* the number is userspace address refer to ktap_eventdef_info */
+       kp_arg_check(ks, 1, KTAP_TNUMBER);
+       kp_arg_check(ks, 2, KTAP_TFUNCTION);
+
+       ret = copy_from_user(&evdef_info, (void *)nvalue(kp_arg(ks, 1)),
+                            sizeof(evdef_info));
+       if (ret < 0)
+               return -1;
+
+       if (evdef_info.filter) {
+               int len;
+
+               len = strlen_user(evdef_info.filter);
+               if (len > 0x1000)
+                       return -1;
+
+               filter = kmalloc(len + 1, GFP_KERNEL);
+               if (!filter)
+                       return -1;
+
+               if (strncpy_from_user(filter, evdef_info.filter, len) < 0) {
+                       kfree(filter);
+                       return -1;
+               }
+       }
+
+       id_arr = kmalloc(evdef_info.nr * sizeof(int), GFP_KERNEL);
+       if (!id_arr) {
+               kfree(filter);
+               return -1;
+       }
+
+       ret = copy_from_user(id_arr, evdef_info.id_arr,
+                            evdef_info.nr * sizeof(int));
+       if (ret < 0) {
+               kfree(filter);
+               kfree(id_arr);
+               return -1;
+       }
+
+       cl = clvalue(kp_arg(ks, 2));
+
+       for (i = 0; i < evdef_info.nr; i++) {
+               struct perf_event_attr attr;
+
+               memset(&attr, 0, sizeof(attr));
+               attr.type = PERF_TYPE_TRACEPOINT;
+               attr.config = id_arr[i];
+               attr.sample_type = PERF_SAMPLE_RAW | PERF_SAMPLE_TIME |
+                                  PERF_SAMPLE_CPU | PERF_SAMPLE_PERIOD;
+               attr.sample_period = 1;
+               attr.size = sizeof(attr);
+               attr.disabled = 0;
+
+               kp_perf_event_register(ks, &attr, task, filter, cl);
+       }
+
+       kfree(filter);
+       kfree(id_arr);
+       return 0;
+}
+
+static int ktap_lib_probe_end(ktap_state *ks)
+{
+       kp_arg_check(ks, 1, KTAP_TFUNCTION);
+
+       G(ks)->trace_end_closure = clvalue(kp_arg(ks, 1));
+       return 0;
+}
+
+static int ktap_lib_traceoff(ktap_state *ks)
+{
+       end_probes(ks);
+
+       /* call trace_end_closure after probed end */
+       if (G(ks)->trace_end_closure) {
+               set_closure(ks->top, G(ks)->trace_end_closure);
+               incr_top(ks);
+               kp_call(ks, ks->top - 1, 0);
+               G(ks)->trace_end_closure = NULL;
+       }
+
+       return 0;
+}
+
+void kp_probe_exit(ktap_state *ks)
+{
+       if (!G(ks)->trace_enabled)
+               return;
+
+       end_probes(ks);
+
+       /* call trace_end_closure after probed end */
+       if (!G(ks)->error && G(ks)->trace_end_closure) {
+               set_closure(ks->top, G(ks)->trace_end_closure);
+               incr_top(ks);
+               kp_call(ks, ks->top - 1, 0);
+               G(ks)->trace_end_closure = NULL;
+       }
+
+       kmem_cache_destroy(G(ks)->pevent_cache);
+       G(ks)->trace_enabled = 0;
+}
+
+int kp_probe_init(ktap_state *ks)
+{
+       G(ks)->pevent_cache = KMEM_CACHE(ktap_probe_event, SLAB_PANIC);
+       G(ks)->trace_enabled = 1;
+       return 0;
+}
+
+static const ktap_Reg kdebuglib_funcs[] = {
+       {"probe_by_id", ktap_lib_probe_by_id},
+       {"probe_end", ktap_lib_probe_end},
+       {"traceoff", ktap_lib_traceoff},
+       {NULL}
+};
+
+void kp_init_kdebuglib(ktap_state *ks)
+{
+       kp_ftrace_profile_set_filter =
+               (void *)kallsyms_lookup_name("ftrace_profile_set_filter");
+       if (!kp_ftrace_profile_set_filter) {
+               kp_error(ks, "ktap: cannot lookup ftrace_profile_set_filter "
+                               "in kallsyms\n");
+               return;
+       }
+
+       kp_register_lib(ks, "kdebug", kdebuglib_funcs);
+}
+
diff --git a/drivers/staging/ktap/runtime/lib_timer.c b/drivers/staging/ktap/runtime/lib_timer.c
new file mode 100644 (file)
index 0000000..2fa4575
--- /dev/null
@@ -0,0 +1,193 @@
+/*
+ * timer.c - timer library support for ktap
+ *
+ * This file is part of ktap by Jovi Zhangwei.
+ *
+ * Copyright (C) 2012-2013 Jovi Zhangwei <jovi.zhangwei@gmail.com>.
+ *
+ * ktap 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.
+ *
+ * ktap is distributed in the hope it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
+ * more details.
+ *
+ * You should have received a copy of the GNU General Public License along with
+ * this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+
+#include <linux/ctype.h>
+#include <linux/slab.h>
+#include <linux/delay.h>
+#include <linux/sched.h>
+#include "../include/ktap_types.h"
+#include "ktap.h"
+#include "kp_obj.h"
+#include "kp_vm.h"
+
+struct hrtimer_ktap {
+       struct hrtimer timer;
+       ktap_state *ks;
+       ktap_closure *cl;
+       u64 ns;
+       struct list_head list;
+};
+
+/*
+ * Currently ktap disallow tracing event in timer callback closure,
+ * that will corrupt ktap_state and ktap stack, because timer closure
+ * and event closure use same irq percpu ktap_state and stack.
+ * We can use a different percpu ktap_state and stack for timer purpuse,
+ * but that's don't bring any big value with cost on memory consuming.
+ *
+ * So just simply disable tracing in timer closure,
+ * get_recursion_context()/put_recursion_context() is used for this purpose.
+ */
+static enum hrtimer_restart hrtimer_ktap_fn(struct hrtimer *timer)
+{
+       struct hrtimer_ktap *t;
+       ktap_state *ks;
+       int rctx;
+
+       rcu_read_lock_sched_notrace();
+
+       t = container_of(timer, struct hrtimer_ktap, timer);
+       rctx = get_recursion_context(t->ks);
+
+       ks = kp_newthread(t->ks);
+       set_closure(ks->top, t->cl);
+       incr_top(ks);
+       kp_call(ks, ks->top - 1, 0);
+       kp_exitthread(ks);
+
+       hrtimer_add_expires_ns(timer, t->ns);
+
+       put_recursion_context(ks, rctx);
+       rcu_read_unlock_sched_notrace();
+
+       return HRTIMER_RESTART;
+}
+
+static void set_tick_timer(ktap_state *ks, u64 period, ktap_closure *cl)
+{
+       struct hrtimer_ktap *t;
+
+       t = kp_malloc(ks, sizeof(*t));
+       t->ks = ks;
+       t->cl = cl;
+       t->ns = period;
+
+       INIT_LIST_HEAD(&t->list);
+       list_add(&t->list, &(G(ks)->timers));
+
+       hrtimer_init(&t->timer, CLOCK_MONOTONIC, HRTIMER_MODE_REL);
+       t->timer.function = hrtimer_ktap_fn;
+       hrtimer_start(&t->timer, ns_to_ktime(period), HRTIMER_MODE_REL);
+}
+
+static void set_profile_timer(ktap_state *ks, u64 period, ktap_closure *cl)
+{
+       struct perf_event_attr attr;
+
+       memset(&attr, 0, sizeof(attr));
+       attr.type = PERF_TYPE_SOFTWARE;
+       attr.config = PERF_COUNT_SW_CPU_CLOCK;
+       attr.sample_type = PERF_SAMPLE_RAW | PERF_SAMPLE_TIME |
+                          PERF_SAMPLE_CPU | PERF_SAMPLE_PERIOD;
+       attr.sample_period = period;
+       attr.size = sizeof(attr);
+       attr.disabled = 0;
+
+       kp_perf_event_register(ks, &attr, NULL, NULL, cl);
+}
+
+static int do_tick_profile(ktap_state *ks, int is_tick)
+{
+       const char *str, *tmp;
+       char interval_str[32] = {0};
+       char suffix[10] = {0};
+       int n, i = 0;
+       int factor;
+
+       kp_arg_check(ks, 1, KTAP_TSTRING);
+       kp_arg_check(ks, 2, KTAP_TFUNCTION);
+
+       str = svalue(kp_arg(ks, 1));
+       tmp = str;
+       while (isdigit(*tmp))
+               tmp++;
+
+       strncpy(interval_str, str, tmp - str);
+       if (kstrtoint(interval_str, 10, &n))
+               goto error;
+
+       strncpy(suffix, tmp, 9);
+       while (suffix[i] != ' ' && suffix[i] != '\0')
+               i++;
+
+       suffix[i] = '\0';
+
+       if (!strcmp(suffix, "s") || !strcmp(suffix, "sec"))
+               factor = NSEC_PER_SEC;
+       else if (!strcmp(suffix, "ms") || !strcmp(suffix, "msec"))
+               factor = NSEC_PER_MSEC;
+       else if (!strcmp(suffix, "us") || !strcmp(suffix, "usec"))
+               factor = NSEC_PER_USEC;
+       else
+               goto error;
+
+       if (is_tick)
+               set_tick_timer(ks, (u64)factor * n, clvalue(kp_arg(ks, 2)));
+       else
+               set_profile_timer(ks, (u64)factor * n, clvalue(kp_arg(ks, 2)));
+
+       return 0;
+
+ error:
+       kp_error(ks, "cannot parse timer interval: %s\n", str);
+       return -1;
+}
+
+/*
+ * tick-n probes fire on only one CPU per interval.
+ * valid time suffixes: sec/s, msec/ms, usec/us
+ */
+static int ktap_lib_tick(ktap_state *ks)
+{
+       return do_tick_profile(ks, 1);
+}
+
+/*
+ * A profile-n probe fires every fixed interval on every CPU
+ * valid time suffixes: sec/s, msec/ms, usec/us
+ */
+static int ktap_lib_profile(ktap_state *ks)
+{
+       return do_tick_profile(ks, 0);
+}
+
+void kp_exit_timers(ktap_state *ks)
+{
+       struct hrtimer_ktap *t, *tmp;
+       struct list_head *timers_list = &(G(ks)->timers);
+
+       list_for_each_entry_safe(t, tmp, timers_list, list) {
+               hrtimer_cancel(&t->timer);
+               kp_free(ks, t);
+       }
+}
+
+static const ktap_Reg timerlib_funcs[] = {
+       {"profile",     ktap_lib_profile},
+       {"tick",        ktap_lib_tick},
+       {NULL}
+};
+
+void kp_init_timerlib(ktap_state *ks)
+{
+       kp_register_lib(ks, "timer", timerlib_funcs);
+}
+
diff --git a/drivers/staging/ktap/samples/ansi/ansi_color_demo.kp b/drivers/staging/ktap/samples/ansi/ansi_color_demo.kp
new file mode 100644 (file)
index 0000000..2998fe0
--- /dev/null
@@ -0,0 +1,22 @@
+#!/usr/bin/env ktap
+
+#this script demonstrate how to use ktap to output color text.
+
+ansi.clear_screen()
+
+ansi.set_color(32)
+printf("this line should be Green color\n")
+
+ansi.set_color(31)
+printf("this line should be Red color\n")
+
+ansi.set_color2(34, 43)
+printf("this line should be Blue color, with Yellow background\n")
+
+ansi.reset_color()
+ansi.set_color3(34, 46, 4)
+printf("this line should be Blue color, with Cyan background, underline single attribute\n")
+
+ansi.reset_color()
+ansi.new_line()
+
diff --git a/drivers/staging/ktap/samples/basic/backtrace.kp b/drivers/staging/ktap/samples/basic/backtrace.kp
new file mode 100644 (file)
index 0000000..39b8c39
--- /dev/null
@@ -0,0 +1,6 @@
+#!/usr/bin/env ktap
+
+trace sched:sched_switch {
+       print_backtrace()
+}
+
diff --git a/drivers/staging/ktap/samples/basic/event_trigger.kp b/drivers/staging/ktap/samples/basic/event_trigger.kp
new file mode 100644 (file)
index 0000000..3cc8b04
--- /dev/null
@@ -0,0 +1,24 @@
+#!/usr/bin/env ktap
+
+soft_disabled = 1
+this_cpu = 0
+
+trace syscalls:sys_enter_open {
+       print(argevent)
+       soft_disabled = 0
+       this_cpu = cpu()
+}
+
+trace *:* {
+       if (soft_disabled == 0 && cpu() == this_cpu) {
+               print(argevent)
+       }
+}
+
+trace syscalls:sys_exit_open {
+       print(argevent)
+       if (cpu() == this_cpu) {
+               exit()
+       }
+}
+
diff --git a/drivers/staging/ktap/samples/basic/event_trigger_ftrace.kp b/drivers/staging/ktap/samples/basic/event_trigger_ftrace.kp
new file mode 100644 (file)
index 0000000..7e0d7d3
--- /dev/null
@@ -0,0 +1,28 @@
+#!/usr/bin/env ktap
+
+
+#This ktap script will output all function calling between
+#sys_enter_open and sys_exit_open, in one cpu.
+
+soft_disabled = 1
+this_cpu = 0
+
+trace syscalls:sys_enter_open {
+       print(argevent)
+       soft_disabled = 0
+       this_cpu = cpu()
+}
+
+trace ftrace:function {
+       if (soft_disabled == 0 && cpu() == this_cpu) {
+               print(argevent)
+       }
+}
+
+trace syscalls:sys_exit_open {
+       print(argevent)
+       if (cpu() == this_cpu) {
+               exit()
+       }
+}
+
diff --git a/drivers/staging/ktap/samples/basic/ftrace.kp b/drivers/staging/ktap/samples/basic/ftrace.kp
new file mode 100644 (file)
index 0000000..9feca2b
--- /dev/null
@@ -0,0 +1,6 @@
+#!/usr/bin/env ktap
+
+trace ftrace:function /ip==mutex*/ {
+       print(cpu(), pid(), execname(), argevent)
+}
+
diff --git a/drivers/staging/ktap/samples/basic/function_time.kp b/drivers/staging/ktap/samples/basic/function_time.kp
new file mode 100644 (file)
index 0000000..e7859a3
--- /dev/null
@@ -0,0 +1,57 @@
+#!/usr/bin/env ktap
+
+#Demo for thread-local variable
+#
+#Note this kind of function time tracing already handled concurrent issue,
+#but not aware on the recursion problem, user need to aware this limitation,
+#so don't use this script to trace function which could be called recursive.
+
+self = {}
+count_max = 0
+count_min = 0
+count_num = 0
+total_time = 0
+
+printf("measure time(us) of function vfs_read\n");
+
+trace probe:vfs_read {
+       if (execname() == "ktap") {
+               return
+       }
+
+       self[tid()] = gettimeofday_us()
+}
+
+trace probe:vfs_read%return {
+       if (execname() == "ktap") {
+               return
+       }
+
+       if (self[tid()] == nil) {
+               return
+       }
+
+       local durtion = gettimeofday_us() - self[tid()]
+       if (durtion > count_max) {
+               count_max = durtion
+       }
+       local min = count_min
+       if (min == 0 || durtion < min) {
+               count_min = durtion
+       }
+
+       count_num = count_num + 1
+       total_time = total_time + durtion
+
+       self[tid()] = nil
+}
+
+trace_end {
+       printf("avg\tmax\tmin\n");
+       printf("-------------------\n")
+
+       printf("%d\t%d\t%d\n", total_time/count_num,
+               count_max, count_min)
+}
+
+
diff --git a/drivers/staging/ktap/samples/basic/kretprobe.kp b/drivers/staging/ktap/samples/basic/kretprobe.kp
new file mode 100644 (file)
index 0000000..82de3cf
--- /dev/null
@@ -0,0 +1,6 @@
+#!/usr/bin/env ktap
+
+trace probe:vfs_read%return fd=$retval {
+       print(execname(), argevent);
+}
+
diff --git a/drivers/staging/ktap/samples/ffi/ffi_kmalloc.kp b/drivers/staging/ktap/samples/ffi/ffi_kmalloc.kp
new file mode 100644 (file)
index 0000000..d8f0898
--- /dev/null
@@ -0,0 +1,19 @@
+#!/usr/bin/env ktap
+
+cdef[[
+       typedef unsigned gfp_t;
+       typedef unsigned long size_t;
+       void *__kmalloc( size_t size, gfp_t flags);
+       void kfree(const void *objp);
+]]
+
+t1 = gettimeofday_us()
+
+for (i = 1, 1000, 1) {
+       local object = C.__kmalloc(128, 208) #GFP_KERNEL is 208
+       C.kfree(object)
+}
+
+t2 = gettimeofday_us()
+
+printf("execution time: %d us\n", t2 - t1)
diff --git a/drivers/staging/ktap/samples/ffi/printk.kp b/drivers/staging/ktap/samples/ffi/printk.kp
new file mode 100644 (file)
index 0000000..dab9049
--- /dev/null
@@ -0,0 +1,10 @@
+cdef[[
+       int printk(char *fmt, ...);
+]]
+
+
+C.printk("This is printed out by ffi\n")
+C.printk("Show me the %s\n", "code")
+C.printk("%s should be at %02d/%02d %02d:%02d:%02d\n", "New Year", 1, 1, 0, 0, 0)
+C.printk("\'a\' + 5 = \'%c\'\n", 95 + 5)
+C.printk("The string is located at 0x%p\n", "str")
diff --git a/drivers/staging/ktap/samples/ffi/sched_clock.kp b/drivers/staging/ktap/samples/ffi/sched_clock.kp
new file mode 100644 (file)
index 0000000..2a94587
--- /dev/null
@@ -0,0 +1,6 @@
+cdef[[
+       unsigned long long sched_clock();
+]]
+
+ret = C.sched_clock()
+print("C.sched_clock returned, value: ", ret)
diff --git a/drivers/staging/ktap/samples/game/tetris.kp b/drivers/staging/ktap/samples/game/tetris.kp
new file mode 100644 (file)
index 0000000..26e1c9f
--- /dev/null
@@ -0,0 +1,293 @@
+#!/usr/bin/env ktap
+
+#
+# Tetris KTAP Script
+#
+# Copyright (C) 2013/OCT/05 Tadaki SAKAI
+#
+# based on stapgames (Systemtap Game Collection)
+#   https://github.com/mhiramat/stapgames/blob/master/games/tetris.stp
+#
+#   - Requirements
+#     Kernel Configuration: CONFIG_KPROBE_EVENT=y
+#                           CONFIG_EVENT_TRACING=y
+#                           CONFIG_PERF_EVENTS=y
+#                           CONFIG_DEBUG_FS=y
+#     CPU Architecture : x86_64
+#
+#   - Setup
+#     $ sudo mount -t debugfs none /sys/kernel/debug/
+#
+#     $ git clone https://github.com/ktap/ktap
+#     $ cd ktap
+#     $ make 2>&1 | tee ../make.log
+#     $ sudo make load
+#     $ sudo sh -c 'echo 50000 > /sys/module/ktapvm/parameters/max_exec_count'
+#
+#   - Run Tetris
+#     $ sudo ./ktap samples/game/tetris.kp
+#
+
+
+#
+# utils
+#
+
+function rand(max) {
+       r = gettimeofday_us()
+       if (r < 0) {
+               r = r * -1
+       }
+       return r % max
+}
+
+function update_display() {
+       for (i = 0, 239, 1) {
+               if ((i % 12 - 11) != 0) {
+                       tmp = ""
+               } else {
+                       tmp = "\n"
+               }
+
+               if (display_buffer[240 + i] == empty) {
+                       printf("  %s", tmp)
+               } else {
+                       color = display_buffer[240 + i] + 40
+                       ansi.set_color2(color, color)
+                       printf("  %s", tmp)
+                       ansi.reset_color()
+               }
+
+               # clear the display buffer
+               display_buffer[240 + i] = display_buffer[i]
+       }
+
+       printf("%d\n",point)
+}
+
+
+#
+# global value
+#
+
+empty = -1
+
+key_code = 0
+point = 0
+block_number = 0
+height = 0
+height_update = 0
+
+destination_position = {}
+display_buffer = {}
+
+block_data0 = {}
+block_data1 = {}
+block_data2 = {}
+block_data3 = {}
+block_data4 = {}
+block_data5 = {}
+block_data6 = {}
+block_table = {}
+
+#
+# Initialize
+#
+
+# Create blocks
+# block is represented by the position from the center.
+# Every block has "L" part in the center except for a bar.
+block_data0[0] = -11 # non-"L" part for each block
+block_data1[0] = -24
+block_data2[0] = 2
+block_data3[0] = 13
+block_data4[0] = -13
+block_data5[0] = -1
+block_data6[0] = 2
+
+block_table[0] = block_data0
+block_table[1] = block_data1
+block_table[2] = block_data2
+block_table[3] = block_data3
+block_table[4] = block_data4
+block_table[5] = block_data5
+block_table[6] = block_data6
+
+for (i = 0, len(block_table) - 1, 1) {
+       # common "L" part
+       block_table[i][1] = 0
+       block_table[i][2] = 1
+       block_table[i][3] = -12
+}
+
+block_table[6][3] = -1 # bar is not common
+# Position: 1 row has 12 columns,
+# and (x, y) is represented by h = x + y * 12.p
+height = 17 # First block position (center)
+
+for (i = 0, 240, 1) {
+       # Wall and Floor (sentinel)
+       if (((i % 12) < 2) || (i > 228)) {
+               tmp = 7 # White
+       } else {
+               tmp = empty
+       }
+       display_buffer[i - 1] = tmp
+       display_buffer[240 + i - 1] = tmp
+}
+
+block_number = rand(7)
+
+ansi.clear_screen()
+
+
+#
+# Key Input
+#
+
+trace probe:kbd_event handle=%di event_type=%si event_code=%dx value=%cx {
+       # Only can run it in x86_64
+       #
+       # Register follow x86_64 call conversion:
+       #
+       # x86_64:
+       #       %rcx    4 argument
+       #       %rdx    3 argument
+       #       %rsi    2 argument
+       #       %rdi    1 argument
+
+       local event_code = arg4
+       local value = arg5
+
+       if (value != 0) {
+               if ((event_code - 4) != 0) {
+                       key_code = event_code
+               }
+       }
+}
+
+
+#
+# timer
+#
+
+tick-200ms {
+       ansi.clear_screen()
+
+       f = 0 # move/rotate flag
+
+       if (key_code != 0) { # if key is pressed
+               if(key_code != 103) { #move left or right
+                       # d: movement direction
+                       if ((key_code - 105) != 0) {
+                               if ((key_code - 106) != 0) {
+                                       d = 0
+                               } else {
+                                       d = 1
+                               }
+                       } else {
+                               d = -1
+                       }
+
+                       for (i = 0, 3, 1) { # check if the block can be moved
+                               # destination is free
+                               if (display_buffer[height +
+                                       block_table[block_number][i] + d]
+                                   != empty) {
+                                       f = 1
+                               }
+                       }
+                       # move if destinations of every block are free
+                       if (f == 0) {
+                               height = height + d
+                       }
+               } else { # rotate
+                       for (i = 0, 3, 1) { # check if block can be rotated
+                               # each block position
+                               p = block_table[block_number][i]
+
+                               # destination x pos(p/12 rounded)
+                               v = (p * 2 + 252) / 24 - 10
+                               w = p - v * 12 # destination y pos
+
+                               # destination position
+                               destination_position[i] = w * 12 - v
+
+                               # check if desetination is free
+                               if (display_buffer[height +
+                                   destination_position[i]] != empty) {
+                                       f = 1
+                               }
+                       }
+
+                       if (f == 0) {
+                               # rotate if destinations of every block
+                               # are free
+                               for (i = 0, 3, 1) {
+                                       block_table[block_number][i] =
+                                               destination_position[i]
+                               }
+                       }
+               }
+       }
+       key_code = 0 # clear the input key
+
+       f = 0
+       for (i = 0, 3, 1) { # drop 1 row
+               # check if destination is free
+               p = height + block_table[block_number][i]
+               if (display_buffer[12 + p] != empty) {
+                       f = 1
+               }
+
+               # copy the moving block to display buffer
+               display_buffer[240 + p] = block_number
+       }
+
+       if ((f == 1) && (height == 17)) {
+               update_display()
+               exit() # exit if there are block at initial position
+       }
+
+       height_update = !height_update
+       if (height_update != 0) {
+               if(f != 0) { # the block can't drop anymore
+                       for (i = 0, 3, 1) {
+                               # fix the block
+                               display_buffer[height +
+                                 block_table[block_number][i]] = block_number
+                       }
+                       # determin the next block
+                       block_number = rand(7)
+                       height = 17 # make the block to initial position
+               } else {
+                       height = height + 12 # drop the block 1 row
+               }
+       }
+
+       k = 1
+       for (i = 18, 0, -1) { #check if line is filled
+               # search for filled line
+               j = 10
+               while ((j > 0) &&
+                      (display_buffer[i * 12 + j] != empty)) {
+                       j = j - 1
+               }
+
+               if (j == 0) { # filled!
+                       # add a point: 1 line - 1 point, ..., tetris - 10points
+                       point = point + k
+                       k = k + 1
+
+                       # drop every upper block
+                       j = (i + 1) * 12
+                       i = i + 1
+                       while (j > 2 * 12) {
+                               j = j - 1
+                               display_buffer[j] = display_buffer[j - 12]
+                       }
+               }
+       }
+
+       update_display()
+}
diff --git a/drivers/staging/ktap/samples/helloworld.kp b/drivers/staging/ktap/samples/helloworld.kp
new file mode 100644 (file)
index 0000000..5673c15
--- /dev/null
@@ -0,0 +1,3 @@
+#!/usr/bin/env ktap
+
+print("Hello World! I am ktap")
diff --git a/drivers/staging/ktap/samples/interrupt/hardirq_time.kp b/drivers/staging/ktap/samples/interrupt/hardirq_time.kp
new file mode 100644 (file)
index 0000000..e570f15
--- /dev/null
@@ -0,0 +1,24 @@
+#!/usr/bin/env ktap
+
+#this script output each average consumimg time of each hardirq
+s = ptable()
+map = {}
+
+trace irq:irq_handler_entry {
+       map[cpu()] = gettimeofday_us()
+}
+
+trace irq:irq_handler_exit {
+       local entry_time = map[cpu()]
+       if (entry_time == nil) {
+               return;
+       }
+
+       s[arg1] <<< gettimeofday_us() - entry_time
+       map[cpu()] = nil
+}
+
+trace_end {
+       print(s)
+}
+
diff --git a/drivers/staging/ktap/samples/interrupt/softirq_time.kp b/drivers/staging/ktap/samples/interrupt/softirq_time.kp
new file mode 100644 (file)
index 0000000..5aec09a
--- /dev/null
@@ -0,0 +1,24 @@
+#!/usr/bin/env ktap
+
+#this script output each average consumimg time of each softirq line
+s = ptable()
+map = {}
+
+trace irq:softirq_entry {
+       map[cpu()] = gettimeofday_us()
+}
+
+trace irq:softirq_exit {
+       local entry_time = map[cpu()]
+       if (entry_time == nil) {
+               return;
+       }
+
+       s[arg1] <<< gettimeofday_us() - entry_time
+       map[cpu()] = nil
+}
+
+trace_end {
+       print(s)
+}
+
diff --git a/drivers/staging/ktap/samples/io/kprobes-do-sys-open.kp b/drivers/staging/ktap/samples/io/kprobes-do-sys-open.kp
new file mode 100644 (file)
index 0000000..a15f911
--- /dev/null
@@ -0,0 +1,20 @@
+#!/usr/bin/env ktap
+
+#Only can run it in x86_64
+#
+#Register follow x86_64 call conversion:
+#
+#x86_64:
+#      %rcx    4 argument
+#      %rdx    3 argument
+#      %rsi    2 argument
+#      %rdi    1 argument
+
+trace probe:do_sys_open dfd=%di filename=%si flags=%dx mode=%cx {
+       printf("[do_sys_open entry]: (%s) open file (%s)\n",
+               execname(),  user_string(arg3))
+}
+
+trace probe:do_sys_open%return fd=$retval {
+       printf("[do_sys_open exit]:  return fd (%d)\n", arg3)
+}
diff --git a/drivers/staging/ktap/samples/io/traceio.kp b/drivers/staging/ktap/samples/io/traceio.kp
new file mode 100644 (file)
index 0000000..89f979b
--- /dev/null
@@ -0,0 +1,54 @@
+#! /usr/bin/env ktap
+
+# Based on systemtap traceio.stp
+
+reads = ptable()
+writes = ptable()
+total_io = ptable()
+
+trace syscalls:sys_exit_read {
+       reads[execname()] <<< arg2
+       total_io[execname()] <<< arg2
+}
+
+trace syscalls:sys_exit_write {
+       writes[execname()] <<< arg2
+       total_io[execname()] <<< arg2
+}
+
+function humanread_digit(bytes) {
+       if (bytes > 1024*1024*1024) {
+               return bytes/1024/1024/1024
+       } elseif (bytes > 1024*1024) {
+               return bytes/1024/1024
+       } elseif (bytes > 1024) {
+               return bytes/1024
+       } else {
+               return bytes
+       }
+}
+
+function humanread_x(bytes) {
+       if (bytes > 1024*1024*1024) {
+               return " GiB"
+       } elseif (bytes > 1024*1024) {
+               return " MiB"
+       } elseif (bytes > 1024) {
+               return " KiB"
+       } else {
+               return "   B"
+       }
+}
+
+tick-1s {
+       ansi.clear_screen()
+       for (exec, _ in pairs(total_io)) {
+               local readnum = sum(reads[exec])
+               local writenum = sum(writes[exec])
+               printf("%15s r: %12d%s w: %12d%s\n", exec,
+                       humanread_digit(readnum), humanread_x(readnum),
+                       humanread_digit(writenum), humanread_x(writenum))
+       }
+       printf("\n")
+}
+
diff --git a/drivers/staging/ktap/samples/mem/kmalloc-top.kp b/drivers/staging/ktap/samples/mem/kmalloc-top.kp
new file mode 100644 (file)
index 0000000..f18ed9f
--- /dev/null
@@ -0,0 +1,17 @@
+#!/usr/bin/env ktap
+
+kmalloc_stack = {}
+
+trace kmem:kmalloc {
+       kmalloc_stack[backtrace()] += 1
+}
+
+tick-60s {
+       for (k, v in pairs(kmalloc_stack)) {
+               print(k)
+               printf("%d\n\n", v)
+       }
+
+       exit()
+}
+
diff --git a/drivers/staging/ktap/samples/mem/kmem.kp b/drivers/staging/ktap/samples/mem/kmem.kp
new file mode 100644 (file)
index 0000000..c6f2c99
--- /dev/null
@@ -0,0 +1,30 @@
+#!/usr/bin/env ktap
+
+count1 = 0
+trace kmem:kmalloc {
+       count1 = count1 + 1
+}
+
+count2 = 0
+trace kmem:kfree {
+       count2 = count2 + 1
+}
+
+count3 = 0
+trace kmem:mm_page_alloc {
+       count3 = count3 + 1
+}
+
+count4 = 0
+trace kmem:mm_page_free {
+       count4 = count4 + 1
+}
+
+trace_end {
+       print("\n")
+       print("kmem:kmalloc:\t", count1)
+       print("kmem:kfree:\t", count2)
+       print("kmem:mm_page_alloc:", count3)
+       print("kmem:mm_page_free:", count4)
+       print("trace ending\n")
+}
diff --git a/drivers/staging/ktap/samples/profiling/function_profiler.kp b/drivers/staging/ktap/samples/profiling/function_profiler.kp
new file mode 100644 (file)
index 0000000..28f1fa6
--- /dev/null
@@ -0,0 +1,41 @@
+#!/usr/bin/env ktap
+
+#kernel function profile
+#You can use this script to know what function is called frequently,
+#without enable CONFIG_FUNCTION_PROFILER in kernel.
+
+s = ptable()
+
+trace ftrace:function {
+       s[arg1] <<< 1
+}
+
+trace_end {
+       histogram(s)
+}
+
+#sample output
+#^C
+#                          value ------------- Distribution ------------- count
+#               sub_preempt_count | @@@@@                                  34904
+#               add_preempt_count | @@@@@                                  33435
+#              nsecs_to_jiffies64 | @@@                                    19919
+# irqtime_account_process_tick... | @                                      9970
+#               account_idle_time | @                                      9880
+#                  _raw_spin_lock |                                        5100
+#                _raw_spin_unlock |                                        5021
+#     _raw_spin_unlock_irqrestore |                                        4235
+#          _raw_spin_lock_irqsave |                                        4232
+#                 __rcu_read_lock |                                        3373
+#               __rcu_read_unlock |                                        3373
+#                  lookup_address |                                        2392
+#             pfn_range_is_mapped |                                        2384
+#      update_cfs_rq_blocked_load |                                        1983
+#                        idle_cpu |                                        1808
+#                       ktime_get |                                        1394
+#            _raw_spin_unlock_irq |                                        1270
+#              _raw_spin_lock_irq |                                        1091
+#                     update_curr |                                        950
+#             irqtime_account_irq |                                        950
+#                             ... |
+#
diff --git a/drivers/staging/ktap/samples/profiling/stack_profile.kp b/drivers/staging/ktap/samples/profiling/stack_profile.kp
new file mode 100644 (file)
index 0000000..c88f850
--- /dev/null
@@ -0,0 +1,30 @@
+#!/usr/bin/env ktap
+
+# This ktap script samples stacktrace of system per 10us,
+# you can use generated output to make a flame graph.
+#
+# Flame Graphs:
+# http://dtrace.org/blogs/brendan/2012/03/17/linux-kernel-performance-flame-graphs/
+
+s = ptable()
+
+profile-10us {
+       #skip 12 stack entries, and dump all remain entries.
+       s[backtrace(12, -1)] <<< 1
+}
+
+tick-60s {
+       exit()
+}
+
+trace_end {
+       function cmp(v1, v2) {
+               return (count(v1) < count(v2))
+       }
+       for (k, v in sort_pairs(s, cmp)) {
+               print(k)
+               print(count(v))
+               print()
+       }
+}
+
diff --git a/drivers/staging/ktap/samples/schedule/sched_transition.kp b/drivers/staging/ktap/samples/schedule/sched_transition.kp
new file mode 100644 (file)
index 0000000..eb54b09
--- /dev/null
@@ -0,0 +1,5 @@
+#!/usr/bin/env ktap
+
+trace sched:sched_switch {
+       printf("%s ... ", arg1)
+}
diff --git a/drivers/staging/ktap/samples/schedule/schedtimes.kp b/drivers/staging/ktap/samples/schedule/schedtimes.kp
new file mode 100644 (file)
index 0000000..e8a6f9e
--- /dev/null
@@ -0,0 +1,125 @@
+#!/usr/vin/env ktap
+
+#schedtimer.kp
+#Initially inspired by Systemtap schedtimes.stp
+#and more bugfree compare with Systemtap's version
+#
+#Note that the time value is associate with pid, not with execname strictly,
+#sometime you will found there have sleep time for command "ls", the reason
+#is that sleep time is belong to parent process bash, so clear on this.
+
+RUNNING = 0
+QUEUED = 1
+SLEEPING = 2
+DEAD = 64
+
+run_time = {}
+queued_time = {}
+sleep_time = {}
+io_wait_time = {}
+
+pid_state = {}
+pid_names = {}
+prev_timestamp = {}
+io_wait = {}
+
+trace sched:sched_switch {
+       local prev_comm = arg1
+       local prev_pid = arg2
+       local prev_state = arg4
+       local next_comm = arg5
+       local next_pid = arg6
+       local t = gettimeofday_us()
+
+       if (pid_state[prev_pid] == nil) {
+               #do nothing
+       } elseif (pid_state[prev_pid] == RUNNING) {
+               run_time[prev_pid] += t - prev_timestamp[prev_pid]
+       } elseif (pid_state[prev_pid] == QUEUED) {
+               #found this:
+               #sched_wakeup comm=foo
+               #sched_switch prev_comm=foo
+               run_time[prev_pid] += t - prev_timestamp[prev_pid]
+       }
+
+       pid_names[prev_pid] = prev_comm
+       prev_timestamp[prev_pid] = t
+
+       if (prev_state == DEAD) {
+               pid_state[prev_pid] = DEAD
+       } elseif (prev_state > 0) {
+               if (in_iowait() == 1) {
+                       io_wait[prev_pid] = 1
+               }
+               pid_state[prev_pid] = SLEEPING
+       } elseif (prev_state == 0) {
+               pid_state[prev_pid] = QUEUED
+       }
+
+       if (pid_state[next_pid] == nil) {
+               pid_state[next_pid] = RUNNING
+       } elseif (pid_state[next_pid] == QUEUED) {
+               queued_time[next_pid] += t - prev_timestamp[next_pid]
+               pid_state[next_pid] = RUNNING
+       }
+
+       pid_names[next_pid] = next_comm
+       prev_timestamp[next_pid] = t
+}
+
+trace sched:sched_wakeup, sched:sched_wakeup_new {
+       local comm = arg1
+       local wakeup_pid = arg2
+       local success = arg4
+       local t = gettimeofday_us()
+
+       if (pid_state[wakeup_pid] == nil) {
+               #do nothing
+       } elseif (pid_state[wakeup_pid] == SLEEPING) {
+               local durtion = t - prev_timestamp[wakeup_pid]
+
+               sleep_time[wakeup_pid] += durtion
+               if (io_wait[wakeup_pid] == 1) {
+                       io_wait_time[wakeup_pid] += durtion
+                       io_wait[wakeup_pid] = 0
+               }
+       } elseif (pid_state[wakeup_pid] == RUNNING) {
+               return
+       }
+
+       pid_names[wakeup_pid] = comm
+       prev_timestamp[wakeup_pid] = t
+       pid_state[wakeup_pid] = QUEUED
+}
+
+trace_end {
+       local t = gettimeofday_us()
+
+       for (pid, state in pairs(pid_state)) {
+               local durtion = t - prev_timestamp[pid]
+               if (state == SLEEPING) {
+                       sleep_time[pid] += durtion
+               } elseif (state == QUEUED) {
+                       queued_time[pid] += durtion
+               } elseif (state == RUNNING) {
+                       run_time[pid] += durtion
+               }
+       }
+
+       printf ("%16s: %6s %10s %10s %10s %10s %10s\n\n",
+               "execname", "pid", "run(us)", "sleep(us)", "io_wait(us)",
+               "queued(us)", "total(us)")
+
+       for (pid, time in pairs(run_time)) {
+               if (sleep_time[pid] == nil) {
+                       sleep_time[pid] = 0
+               }
+               if (queued_time[pid] == nil) {
+                       queue_time[pid] = 0
+               }
+               printf("%16s: %6d %10d %10d %10d %10d %10d\n",
+                       pid_names[pid], pid, run_time[pid], sleep_time[pid],
+                       io_wait_time[pid], queued_time[pid],
+                       run_time[pid] + sleep_time[pid] + queued_time[pid]);
+       }
+}
diff --git a/drivers/staging/ktap/samples/syscalls/errinfo.kp b/drivers/staging/ktap/samples/syscalls/errinfo.kp
new file mode 100644 (file)
index 0000000..c8662d6
--- /dev/null
@@ -0,0 +1,145 @@
+#!/usr/bin/env ktap
+
+#errdesc get from include/uapi/asm-generic/errno*.h
+errdesc = {
+       [1] = "Operation not permitted",                #EPERM
+       [2] = "No such file or directory",              #ENOENT
+       [3] = "No such process",                        #ESRCH
+       [4] = "Interrupted system call",                #EINRT
+       [5] = "I/O error",                              #EIO
+       [6] = "No such device or address",              #ENXIO
+       [7] = "Argument list too long",                 #E2BIG
+       [8] = "Exec format error",                      #ENOEXEC
+       [9] = "Bad file number",                        #EBADF
+       [10] = "No child processes",                    #ECHILD
+       [11] = "Try again",                             #EAGAIN
+       [12] = "Out of memory",                         #ENOMEM
+       [13] = "Permission denied",                     #EACCES
+       [14] = "Bad address",                           #EFAULT
+       [15] = "Block device required",                 #ENOTBLK
+       [16] = "Device or resource busy",               #EBUSY
+       [17] = "File exists",                           #EEXIST
+       [18] = "Cross-device link",                     #EXDEV
+       [19] = "No such device",                        #ENODEV
+       [20] = "Not a directory",                       #ENOTDIR
+       [21] = "Is a directory",                        #EISDIR
+       [22] = "Invalid argument",                      #EINVAL
+       [23] = "File table overflow",                   #ENFILE
+       [24] = "Too many open files",                   #EMFILE
+       [25] = "Not a typewriter",                      #ENOTTY
+       [26] = "Text file busy",                        #ETXTBSY
+       [27] = "File too large",                        #EFBIG
+       [28] = "No space left on device",               #ENOSPC
+       [29] = "Illegal seek",                          #ESPIPE
+       [30] = "Read-only file system",                 #EROFS
+       [31] = "Too many links",                        #EMLINK
+       [32] = "Broken pipe",                           #EPIPE
+       [33] = "Math argument out of domain of func",   #EDOM
+       [34] = "Math result not representable",         #ERANGE
+
+       [35] = "Resource deadlock would occur",         #EDEADLK
+       [36] = "File name too long",                    #ENAMETOOLONG
+       [37] = "No record locks available",             #ENOLCK
+       [38] = "Function not implemented",              #ENOSYS
+       [39] = "Directory not empty",                   #ENOTEMPTY
+       [40] = "Too many symbolic links encountered",   #ELOOP
+       [42] = "No message of desired type",            #ENOMSG
+       [43] = "Identifier removed",                    #EIDRM
+       [44] = "Channel number out of range",           #ECHRNG
+       [45] = "Level 2 not synchronized",              #EL2NSYNC
+       [46] = "Level 3 halted",                        #EL3HLT
+       [47] = "Level 3 reset",                         #EL3RST
+       [48] = "Link number out of range",              #ELNRNG
+       [49] = "Protocol driver not attached",          #EUNATCH
+       [50] = "No CSI structure available",            #ENOCSI
+       [51] = "Level 2 halted",                        #EL2HLT
+       [52] = "Invalid exchange",                      #EBADE
+       [53] = "Invalid request descriptor",            #EBADR
+       [54] = "Exchange full",                         #EXFULL
+       [55] = "No anode",                              #ENOANO
+       [56] = "Invalid request code",                  #EBADRQC
+       [57] = "Invalid slot",                          #EBADSLT
+
+       [59] = "Bad font file format",                  #EBFONT
+       [60] = "Device not a stream",                   #ENOSTR
+       [61] = "No data available",                     #ENODATA
+       [62] = "Timer expired",                         #ETIME
+       [63] = "Out of streams resources",              #ENOSR
+       [64] = "Machine is not on the network",         #ENONET
+       [65] = "Package not installed",                 #ENOPKG
+       [66] = "Object is remote",                      #EREMOTE
+       [67] = "Link has been severed",                 #ENOLINK
+       [68] = "Advertise error",                       #EADV
+       [69] = "Srmount error",                         #ESRMNT
+       [70] = "Communication error on send",           #ECOMM
+       [71] = "Protocol error",                        #EPROTO
+       [72] = "Multihop attempted",                    #EMULTIHOP
+       [73] = "RFS specific error",                    #EDOTDOT
+       [74] = "Not a data message",                    #EBADMSG
+       [75] = "Value too large for defined data type", #EOVERFLOW
+       [76] = "Name not unique on network",            #ENOTUNIQ
+       [77] = "File descriptor in bad state",          #EBADFD
+       [78] = "Remote address changed",                #EREMCHG
+       [79] = "Can not access a needed shared library", #ELIBACC
+       [80] = "Accessing a corrupted shared library",  #ELIBBAD
+       [81] = ".lib section in a.out corrupted",       #ELIBSCN
+       [82] = "Attempting to link in too many shared libraries", #ELIBMAX
+       [83] = "Cannot exec a shared library directly", #ELIBEXEC
+       [84] = "Illegal byte sequence",                 #EILSEQ
+       [85] = "Interrupted system call should be restarted", #ERESTART
+       [86] = "Streams pipe error",                    #ESTRPIPE
+       [87] = "Too many users",                        #EUSERS
+       [88] = "Socket operation on non-socket",        #ENOTSOCK
+       [89] = "Destination address required",          #EDESTADDRREQ
+       [90] = "Message too long",                      #EMSGSIZE
+       [91] = "Protocol wrong type for socket",        #EPROTOTYPE
+       [92] = "Protocol not available",                #ENOPROTOOPT
+       [93] = "Protocol not supported",                #EPROTONOSUPPORT
+       [94] = "Socket type not supported",             #ESOCKTNOSUPPORT
+       [95] = "Operation not supported on transport endpoint", #EOPNOTSUPP
+       [96] = "Protocol family not supported",         #EPFNOSUPPORT
+       [97] = "Address family not supported by protocol", #EAFNOSUPPORT
+       [98] = "Address already in use",                #EADDRINUSE
+       [99] = "Cannot assign requested address",       #EADDRNOTAVAIL
+       [100] = "Network is down",                      #ENETDOWN
+       [101] = "Network is unreachable",               #ENETUNREACH
+       [102] = "Network dropped connection because of reset",  #ENETRESET
+       [103] = "Software caused connection abort",     #ECONNABORTED
+       [104] = "Connection reset by peer",             #ECONNRESET
+       [105] = "No buffer space available",            #ENOBUFS
+       [106] = "Transport endpoint is already connected", #EISCONN
+       [107] = "Transport endpoint is not connected",  #ENOTCONN
+       [108] = " Cannot send after transport endpoint shutdown", #ESHUTDOWN
+       [109] = "Too many references: cannot splice",   #ETOOMANYREFS
+       [110] = "Connection timed out",                 #ETIMEDOUT
+       [111] = "Connection refused",                   #ECONNREFUSED
+       [112] = "Host is down",                         #EHOSTDOWN
+       [113] = "No route to host",                     #EHOSTUNREACH
+       [114] = "Operation already in progress",        #EALREADY
+       [115] = "Operation now in progress",            #EINPROGRESS
+       [116] = "Stale NFS file handle",                #ESTALE
+       [117] = "Structure needs cleaning",             #EUCLEAN
+       [118] = "Not a XENIX named type file",          #ENOTNAM
+       [119] = "No XENIX semaphores available",        #ENAVAIL
+       [120] = "Is a named type file",                 #EISNAM
+       [121] = "Remote I/O error",                     #EREMOTEIO
+       [122] = "Quota exceeded",                       #EDQUOT
+       [123] = "No medium found",                      #ENOMEDIUM
+       [124] = "Wrong medium type",                    #EMEDIUMTYPE
+       [125] = "Operation Canceled",                   #ECANCELED
+       [126] = "Required key not available",           #ENOKEY
+       [127] = "Key has expired",                      #EKEYEXPIRED
+       [128] = "Key has been revoked",                 #EKEYREVOKED
+       [129] = "Key was rejected by service",          #EKEYREJECTED
+       [130] = "Owner died",                           #EOWNERDEAD
+       [131] = "State not recoverable",                #ENOTRECOVERABLE
+
+}
+
+trace syscalls:sys_exit_* {
+       if (arg2 < 0) {
+               local errno = -arg2
+               printf("%-15s%-20s\t%d\t%-30s\n",
+                       execname(), argname, errno, errdesc[errno])
+       }
+}
diff --git a/drivers/staging/ktap/samples/syscalls/execve.kp b/drivers/staging/ktap/samples/syscalls/execve.kp
new file mode 100644 (file)
index 0000000..e7019d6
--- /dev/null
@@ -0,0 +1,8 @@
+#!/usr/bin/env ktap
+
+#This script trace filename of process execution
+#only tested in x86-64
+
+trace probe:do_execve filename=%di {
+       printf("[do_execve entry]: (%s) name=%s\n", execname(), kernel_string(arg2))
+}
diff --git a/drivers/staging/ktap/samples/syscalls/opensnoop.kp b/drivers/staging/ktap/samples/syscalls/opensnoop.kp
new file mode 100644 (file)
index 0000000..7369ebe
--- /dev/null
@@ -0,0 +1,31 @@
+#!/usr/local/bin/ktap -q
+#
+# opensnoop.kp trace open syscalls with pathnames and basic info
+#
+# 23-Nov-2013  Brendan Gregg   Created this
+
+path = {}
+
+printf("%5s %6s %-12s %3s %3s %s\n", "UID", "PID", "COMM", "FD", "ERR", "PATH");
+
+trace syscalls:sys_enter_open {
+       path[tid()] = user_string(arg2)
+}
+
+trace syscalls:sys_exit_open {
+       local fd
+       local errno
+
+       if (arg2 < 0) {
+               fd = 0
+               errno = -arg2
+       } else {
+               fd = arg2
+               errno = 0
+       }
+
+       printf("%5d %6d %-12s %3d %3d %s\n", uid(), pid(), execname(), fd,
+           errno, path[tid()])
+
+       path[tid()] = 0
+}
diff --git a/drivers/staging/ktap/samples/syscalls/sctop.kp b/drivers/staging/ktap/samples/syscalls/sctop.kp
new file mode 100644 (file)
index 0000000..a45b4cb
--- /dev/null
@@ -0,0 +1,13 @@
+#! /usr/bin/env ktap
+
+s = {}
+
+trace syscalls:sys_enter_* {
+       s[argname] += 1
+}
+
+tick-5s {
+       ansi.clear_screen()
+       histogram(s)
+       delete(s)
+}
diff --git a/drivers/staging/ktap/samples/syscalls/syscalls.kp b/drivers/staging/ktap/samples/syscalls/syscalls.kp
new file mode 100644 (file)
index 0000000..8bbaaca
--- /dev/null
@@ -0,0 +1,6 @@
+#!/usr/bin/env ktap
+
+trace syscalls:* {
+       print(cpu(), pid(), execname(), argevent)
+}
+
diff --git a/drivers/staging/ktap/samples/syscalls/syscalls_count.kp b/drivers/staging/ktap/samples/syscalls/syscalls_count.kp
new file mode 100644 (file)
index 0000000..ed7d989
--- /dev/null
@@ -0,0 +1,54 @@
+#!/usr/bin/env ktap
+
+s = ptable()
+
+trace syscalls:sys_enter_* {
+       s[argname] <<< 1
+}
+
+trace_end {
+       histogram(s)
+}
+
+#Result:
+#
+#[root@jovi ktap]# ./ktap samples/syscalls_histogram.kp
+#^C
+#                          value ------------- Distribution ------------- count
+#        sys_enter_rt_sigprocmask |@@@@@@                                 326
+#                  sys_enter_read |@@@@@                                  287
+#                 sys_enter_close |@@@@                                   236
+#                  sys_enter_open |@@@@                                   222
+#                sys_enter_stat64 |@@                                     132
+#                sys_enter_select |@@                                     123
+#          sys_enter_rt_sigaction |@@                                     107
+#                  sys_enter_poll |@                                      72
+#                 sys_enter_write |@                                      70
+#            sys_enter_mmap_pgoff |@                                      58
+#               sys_enter_fstat64 |                                       41
+#             sys_enter_nanosleep |                                       23
+#                sys_enter_access |                                       20
+#              sys_enter_mprotect |                                       18
+#               sys_enter_geteuid |                                       17
+#               sys_enter_getegid |                                       16
+#                sys_enter_getuid |                                       16
+#                sys_enter_getgid |                                       16
+#                   sys_enter_brk |                                       15
+#               sys_enter_waitpid |                                       11
+#                  sys_enter_time |                                       10
+#                 sys_enter_ioctl |                                       9
+#                sys_enter_munmap |                                       9
+#               sys_enter_fcntl64 |                                       7
+#                  sys_enter_dup2 |                                       7
+#                 sys_enter_clone |                                       6
+#            sys_enter_exit_group |                                       6
+#                sys_enter_execve |                                       4
+#                  sys_enter_pipe |                                       3
+#          sys_enter_gettimeofday |                                       3
+#              sys_enter_getdents |                                       2
+#             sys_enter_getgroups |                                       2
+#              sys_enter_statfs64 |                                       2
+#                 sys_enter_lseek |                                       2
+#                sys_enter_openat |                                       1
+#              sys_enter_newuname |                                       1
+
diff --git a/drivers/staging/ktap/samples/syscalls/syscalls_count_by_proc.kp b/drivers/staging/ktap/samples/syscalls/syscalls_count_by_proc.kp
new file mode 100644 (file)
index 0000000..67d7bee
--- /dev/null
@@ -0,0 +1,22 @@
+#!/usr/bin/env ktap
+
+s = ptable()
+
+trace syscalls:sys_enter_* {
+       s[execname()] <<< 1
+}
+
+trace_end {
+       histogram(s)
+}
+
+#Result:
+#
+#[root@jovi ktap]# ./ktap samples/syscalls_histogram2.kp
+#^C
+#                          value ------------- Distribution ------------- count
+#                            sshd |@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@      196
+#                          iscsid |@@@@                                   24
+#                        sendmail |@                                      9
+
+
diff --git a/drivers/staging/ktap/samples/syscalls/syslatl.kp b/drivers/staging/ktap/samples/syscalls/syslatl.kp
new file mode 100644 (file)
index 0000000..5ba3219
--- /dev/null
@@ -0,0 +1,30 @@
+#!/usr/bin/env ktap
+#
+# syslatl.kp   syscall latency linear aggregation
+#
+# 10-Nov-2013  Brendan Gregg   Created this
+
+step = 10      # number of ms per step
+
+self = {}
+lats = {}
+max = 0
+
+trace syscalls:sys_enter_* {
+       self[tid()] = gettimeofday_us()
+}
+
+trace syscalls:sys_exit_* {
+       if (self[tid()] == nil) { return }
+       delta = (gettimeofday_us() - self[tid()]) / (step * 1000)
+       if (delta > max) { max = delta }
+       lats[delta] += 1
+       self[tid()] = nil
+}
+
+trace_end {
+       printf("   %8s %8s\n", "LAT(ms)+", "COUNT");
+       for (i = 0, max, 1) {
+               printf("   %8d %8d\n", i * step, lats[i]);
+       }
+}
diff --git a/drivers/staging/ktap/samples/syscalls/syslist.kp b/drivers/staging/ktap/samples/syscalls/syslist.kp
new file mode 100644 (file)
index 0000000..a4a3cb0
--- /dev/null
@@ -0,0 +1,31 @@
+#!/usr/bin/env ktap
+#
+# syslist.kp    syscall latency as a list with counts
+#
+# 10-Nov-2013   Brendan Gregg   Created this
+
+self = {}
+lats = {}
+order = {}  # a workaround for key sorting
+
+trace syscalls:sys_enter_* {
+    self[tid()] = gettimeofday_us()
+}
+
+trace syscalls:sys_exit_* {
+    if (self[tid()] == nil) { return }
+    delta = gettimeofday_us() - self[tid()]
+    lats[delta] += 1
+    order[delta] = delta
+    self[tid()] = nil
+}
+
+trace_end {
+    printf("   %8s %8s\n", "LAT(us)", "COUNT");
+    function cmp(v1, v2) {
+        return (v1 < v2)
+    }
+    for (lat, dummy in sort_pairs(order, cmp)) {
+        printf("   %8d %8d\n", lat, lats[lat]);
+    }
+}
diff --git a/drivers/staging/ktap/samples/tracepoints/eventcount.kp b/drivers/staging/ktap/samples/tracepoints/eventcount.kp
new file mode 100644 (file)
index 0000000..1bd37eb
--- /dev/null
@@ -0,0 +1,210 @@
+#!/usr/bin/env ktap
+
+# showing all tracepoints in histogram style
+
+s = ptable()
+
+trace *:* {
+       s[argname] <<< 1
+}
+
+trace_end {
+       histogram(s)
+}
+
+#Results:
+#^C
+#
+#                          value ------------- Distribution ------------- count
+#                 rcu_utilization |@@@@@                                  225289
+#                        cpu_idle |@@@                                    120168
+#                    sched_wakeup |@@                                     91950
+#                    timer_cancel |@@                                     91232
+#                     timer_start |@@                                     91201
+#                sched_stat_sleep |@@                                     90981
+#               timer_expire_exit |@@                                     90634
+#              timer_expire_entry |@@                                     90625
+#                  hrtimer_cancel |@                                      75411
+#                   hrtimer_start |@                                      74946
+#                   softirq_raise |@                                      63117
+#                    softirq_exit |@                                      63109
+#                   softirq_entry |@                                      63094
+#                    sched_switch |@                                      62331
+#                 sched_stat_wait |@                                      60491
+#             hrtimer_expire_exit |@                                      47538
+#            hrtimer_expire_entry |@                                      47530
+#              sched_stat_runtime |                                       2780
+#                 kmem_cache_free |                                       2684
+#                kmem_cache_alloc |                                       2415
+#                           kfree |                                       2288
+#                        sys_exit |                                       2145
+#                       sys_enter |                                       2145
+#         sys_exit_rt_sigprocmask |                                       1000
+#        sys_enter_rt_sigprocmask |                                       1000
+#                      timer_init |                                       912
+#              sched_stat_blocked |                                       685
+#                         kmalloc |                                       667
+#           workqueue_execute_end |                                       621
+#         workqueue_execute_start |                                       621
+#                sys_enter_select |                                       566
+#                 sys_exit_select |                                       566
+#                  sys_enter_read |                                       526
+#                   sys_exit_read |                                       526
+#                    mm_page_free |                                       478
+#                   mm_page_alloc |                                       427
+#            mm_page_free_batched |                                       382
+#                   net_dev_queue |                                       296
+#                    net_dev_xmit |                                       296
+#                     consume_skb |                                       296
+#                  sys_exit_write |                                       290
+#                 sys_enter_write |                                       290
+#                       kfree_skb |                                       289
+#           kmem_cache_alloc_node |                                       269
+#                    kmalloc_node |                                       263
+#                 sys_enter_close |                                       249
+#                  sys_exit_close |                                       249
+#                    hrtimer_init |                                       248
+#               netif_receive_skb |                                       242
+#                  sys_enter_open |                                       237
+#                   sys_exit_open |                                       237
+#                       napi_poll |                                       226
+#              sched_migrate_task |                                       207
+#                   sys_exit_poll |                                       173
+#                  sys_enter_poll |                                       173
+#            workqueue_queue_work |                                       152
+#         workqueue_activate_work |                                       152
+#                sys_enter_stat64 |                                       133
+#                 sys_exit_stat64 |                                       133
+#           sys_exit_rt_sigaction |                                       133
+#          sys_enter_rt_sigaction |                                       133
+#               irq_handler_entry |                                       125
+#                irq_handler_exit |                                       125
+#       mm_page_alloc_zone_locked |                                       99
+#             sys_exit_mmap_pgoff |                                       66
+#            sys_enter_mmap_pgoff |                                       66
+#                sys_exit_fstat64 |                                       54
+#               sys_enter_fstat64 |                                       54
+#             sys_enter_nanosleep |                                       51
+#              sys_exit_nanosleep |                                       51
+#                 block_bio_queue |                                       46
+#                 block_bio_remap |                                       46
+#              block_bio_complete |                                       46
+#                  mix_pool_bytes |                                       44
+#              mm_page_pcpu_drain |                                       31
+#                   sys_exit_time |                                       23
+#                  sys_enter_time |                                       23
+#                 sys_exit_access |                                       20
+#                sys_enter_access |                                       20
+#           mix_pool_bytes_nolock |                                       18
+#              sys_enter_mprotect |                                       18
+#               sys_exit_mprotect |                                       18
+#               sys_enter_geteuid |                                       17
+#                sys_exit_geteuid |                                       17
+#                sys_enter_munmap |                                       17
+#                 sys_exit_munmap |                                       17
+#                     block_getrq |                                       16
+#                sys_enter_getuid |                                       16
+#                sys_enter_getgid |                                       16
+#                 sys_exit_getgid |                                       16
+#                 sys_exit_getuid |                                       16
+#                  block_rq_issue |                                       16
+#         scsi_dispatch_cmd_start |                                       16
+#               block_rq_complete |                                       16
+#          scsi_dispatch_cmd_done |                                       16
+#               sys_enter_getegid |                                       16
+#                sys_exit_getegid |                                       16
+#                 block_rq_insert |                                       16
+#         skb_copy_datagram_iovec |                                       15
+#                   sys_enter_brk |                                       15
+#                    sys_exit_brk |                                       15
+#             credit_entropy_bits |                                       14
+#                   wbc_writepage |                                       14
+#                  sys_exit_clone |                                       12
+#              block_touch_buffer |                                       12
+#              sched_process_wait |                                       11
+#               sys_enter_waitpid |                                       11
+#                sys_exit_waitpid |                                       11
+#               writeback_written |                                       10
+#                 writeback_start |                                       10
+#              writeback_queue_io |                                       10
+#     ext4_es_lookup_extent_enter |                                       9
+#                 sys_enter_ioctl |                                       9
+#                  sys_exit_ioctl |                                       9
+#       ext4_ext_map_blocks_enter |                                       9
+#        ext4_ext_map_blocks_exit |                                       9
+#      ext4_es_lookup_extent_exit |                                       9
+#           ext4_es_insert_extent |                                       9
+#            ext4_ext_show_extent |                                       8
+#                 extract_entropy |                                       8
+#ext4_es_find_delayed_extent_exit |                                       8
+# ext4_es_find_delayed_extent_... |                                       8
+#         writeback_pages_written |                                       7
+#                   sys_exit_dup2 |                                       7
+#                  sys_enter_dup2 |                                       7
+#                 signal_generate |                                       7
+#               sys_enter_fcntl64 |                                       7
+#                sys_exit_fcntl64 |                                       7
+#              global_dirty_state |                                       7
+#     writeback_dirty_inode_start |                                       7
+#             block_bio_backmerge |                                       7
+#           writeback_dirty_inode |                                       7
+#                sched_wakeup_new |                                       6
+#              sched_process_free |                                       6
+#            sys_enter_exit_group |                                       6
+#                    task_newtask |                                       6
+#                 sys_enter_clone |                                       6
+#              sched_process_fork |                                       6
+#              sched_process_exit |                                       6
+#           sys_exit_gettimeofday |                                       5
+#                  signal_deliver |                                       5
+#          sys_enter_gettimeofday |                                       5
+#          writeback_single_inode |                                       4
+#                sys_enter_execve |                                       4
+#                     task_rename |                                       4
+#              sched_process_exec |                                       4
+#              block_dirty_buffer |                                       4
+#                 sys_exit_execve |                                       4
+#                    block_unplug |                                       4
+#               sched_stat_iowait |                                       4
+#    writeback_single_inode_start |                                       4
+#                      block_plug |                                       4
+#           writeback_write_inode |                                       3
+#                  sys_enter_pipe |                                       3
+#            writeback_dirty_page |                                       3
+#     writeback_write_inode_start |                                       3
+#           ext4_mark_inode_dirty |                                       3
+#              ext4_journal_start |                                       3
+#                   sys_exit_pipe |                                       3
+#           jbd2_drop_transaction |                                       2
+#             jbd2_commit_locking |                                       2
+#            jbd2_commit_flushing |                                       2
+#               jbd2_handle_start |                                       2
+#                  jbd2_run_stats |                                       2
+#               sys_exit_getdents |                                       2
+#           jbd2_checkpoint_stats |                                       2
+#             sys_enter_getgroups |                                       2
+#               jbd2_start_commit |                                       2
+#                 jbd2_end_commit |                                       2
+#              ext4_da_writepages |                                       2
+#               jbd2_handle_stats |                                       2
+#              sys_enter_statfs64 |                                       2
+#               sys_exit_statfs64 |                                       2
+#              sys_exit_getgroups |                                       2
+#                  sys_exit_lseek |                                       2
+#                 sys_enter_lseek |                                       2
+#              sys_enter_getdents |                                       2
+#             ext4_da_write_pages |                                       2
+#             jbd2_commit_logging |                                       2
+#             ext4_request_blocks |                                       1
+#                 sys_exit_openat |                                       1
+#     ext4_discard_preallocations |                                       1
+#              ext4_mballoc_alloc |                                       1
+#                sys_enter_openat |                                       1
+#       ext4_da_writepages_result |                                       1
+#            ext4_allocate_blocks |                                       1
+#              sys_enter_newuname |                                       1
+#    ext4_da_update_reserve_space |                                       1
+# ext4_get_reserved_cluster_alloc |                                       1
+#               sys_exit_newuname |                                       1
+#           writeback_wake_thread |                                       1
+
diff --git a/drivers/staging/ktap/samples/tracepoints/eventcount_by_proc.kp b/drivers/staging/ktap/samples/tracepoints/eventcount_by_proc.kp
new file mode 100644 (file)
index 0000000..5b9547e
--- /dev/null
@@ -0,0 +1,57 @@
+#!/usr/bin/env ktap
+
+# showing all tracepoints in histogram style
+
+s = ptable()
+
+trace *:* {
+       s[execname()] <<< 1
+}
+
+trace_end {
+       histogram(s)
+}
+
+#Results:
+#^C
+#                          value ------------- Distribution ------------- count
+#                       swapper/0 |@@@@@@@@@@@@                           354378
+#                       swapper/1 |@@@@@@@@@@                             284984
+#                              ps |@@@@                                   115697
+#                        ksmtuned |@@@                                    95857
+#                          iscsid |@@                                     80008
+#                             awk |@                                      30354
+#                      irqbalance |                                       16530
+#                       rcu_sched |                                       15892
+#                        sendmail |                                       14463
+#                     kworker/0:1 |                                       10540
+#                    kworker/u4:2 |                                       9250
+#                     kworker/1:2 |                                       7943
+#                           sleep |                                       7555
+#                           crond |                                       3911
+#                     ksoftirqd/0 |                                       3817
+#                            sshd |                                       2849
+#                 systemd-journal |                                       2209
+#                     migration/1 |                                       1601
+#                     migration/0 |                                       1350
+#                        dhclient |                                       1343
+#                 nm-dhcp-client. |                                       1208
+#                     ksoftirqd/1 |                                       1064
+#                      watchdog/1 |                                       966
+#                      watchdog/0 |                                       964
+#                      khugepaged |                                       776
+#                     dbus-daemon |                                       611
+#                         rpcbind |                                       607
+#                           gdbus |                                       529
+#                  NetworkManager |                                       399
+#                     jbd2/dm-1-8 |                                       378
+#                   modem-manager |                                       184
+#                  abrt-watch-log |                                       157
+#                         polkitd |                                       156
+#                   rs:main Q:Reg |                                       153
+#                    avahi-daemon |                                       151
+#                        rsyslogd |                                       102
+#                         systemd |                                       96
+#                    kworker/0:1H |                                       45
+#                          smartd |                                       30
+
diff --git a/drivers/staging/ktap/samples/tracepoints/tracepoints.kp b/drivers/staging/ktap/samples/tracepoints/tracepoints.kp
new file mode 100644 (file)
index 0000000..5d08869
--- /dev/null
@@ -0,0 +1,6 @@
+#!/usr/bin/env ktap
+
+trace *:* {
+       print(cpu(), pid(), execname(), argevent)
+}
+
diff --git a/drivers/staging/ktap/samples/userspace/gcc_unwind.kp b/drivers/staging/ktap/samples/userspace/gcc_unwind.kp
new file mode 100644 (file)
index 0000000..0890872
--- /dev/null
@@ -0,0 +1,9 @@
+#!/usr/bin/env ktap
+
+#only tested in x86-64 system,
+#if you run this script in x86_32, change the libc path.
+
+trace sdt:/lib/x86_64-linux-gnu/libgcc_s.so.1:unwind {
+       print(execname(), argevent)
+}
+
diff --git a/drivers/staging/ktap/samples/userspace/glibc_func_hist.kp b/drivers/staging/ktap/samples/userspace/glibc_func_hist.kp
new file mode 100644 (file)
index 0000000..5c30b3f
--- /dev/null
@@ -0,0 +1,44 @@
+#!/usr/bin/env ktap
+
+#This ktap script trace all glibc functions in histogram output
+
+#only tested in x86-64 system,
+#if you run this script in x86_32, change the libc path.
+
+s = {}
+
+trace probe:/lib64/libc.so.6:* {
+       s[argname] += 1
+}
+
+trace_end {
+       histogram(s)
+}
+
+# Example result:
+#[root@localhost ktap]# ./ktap ./glibc_func_hist.kp
+#Tracing... Ctrl-C to end.
+#^C
+#                          value ------------- Distribution ------------- count
+#                   _IO_sputbackc |                                       1536
+#                  __strncmp_sse2 |                                       1522
+#                    __GI_strncmp |                                       1522
+#                     __GI_memcpy |                                       1446
+#                   __memcpy_sse2 |                                       1446
+#        _dl_mcount_wrapper_check |                                       1433
+#   __GI__dl_mcount_wrapper_check |                                       1433
+# __gconv_transform_utf8_internal |                                       1429
+#                       __mbrtowc |                                       1425
+#                        mbrtoc32 |                                       1425
+#                  __GI___mbrtowc |                                       1425
+#                         mbrtowc |                                       1425
+#                    __GI_mbrtowc |                                       1425
+#                         strtouq |                                       1274
+#                        strtoull |                                       1274
+#                         strtoul |                                       1274
+#          __ctype_get_mb_cur_max |                                       984
+#         ____strtoull_l_internal |                                       970
+#     __GI_____strtoul_l_internal |                                       970
+#              __GI__IO_sputbackc |                                       960
+#                             ... |
+
diff --git a/drivers/staging/ktap/samples/userspace/glibc_sdt.kp b/drivers/staging/ktap/samples/userspace/glibc_sdt.kp
new file mode 100644 (file)
index 0000000..626151a
--- /dev/null
@@ -0,0 +1,11 @@
+#!/usr/bin/env ktap
+
+#This ktap script trace all sdt notes in glibc
+
+#only tested in x86-64 system,
+#if you run this script in x86_32, change the libc path.
+
+trace sdt:/lib64/libc.so.6:* {
+       print(execname(), argevent)
+}
+
diff --git a/drivers/staging/ktap/samples/userspace/glibc_trace.kp b/drivers/staging/ktap/samples/userspace/glibc_trace.kp
new file mode 100644 (file)
index 0000000..ca03089
--- /dev/null
@@ -0,0 +1,11 @@
+#!/usr/bin/env ktap
+
+#This ktap script trace all functions in glibc
+
+#only tested in x86-64 system,
+#if you run this script in x86_32, change the libc path.
+
+trace probe:/lib64/libc.so.6:* {
+       print(execname(), argevent)
+}
+
diff --git a/drivers/staging/ktap/samples/userspace/malloc_free.kp b/drivers/staging/ktap/samples/userspace/malloc_free.kp
new file mode 100644 (file)
index 0000000..7c7da25
--- /dev/null
@@ -0,0 +1,20 @@
+#!/usr/bin/env ktap
+
+#only tested in x86-64 system,
+#if you run this script in x86_32, change the libc path.
+
+trace probe:/lib64/libc.so.6:malloc {
+       print("malloc entry:", execname())
+}
+
+trace probe:/lib64/libc.so.6:malloc%return {
+       print("malloc exit:", execname())
+}
+
+trace probe:/lib64/libc.so.6:free {
+       print("free entry:", execname())
+}
+
+trace probe:/lib64/libc.so.6:free%return {
+       print("free exit:", execname())
+}
diff --git a/drivers/staging/ktap/samples/userspace/malloc_size_hist.kp b/drivers/staging/ktap/samples/userspace/malloc_size_hist.kp
new file mode 100644 (file)
index 0000000..9df89e6
--- /dev/null
@@ -0,0 +1,22 @@
+#!/usr/bin/env ktap
+
+# Aggregate system or process malloc size
+
+# only tested in x86-64 system,
+# if you run this script in x86_32, change the libc path and register name.
+#
+# Examples:
+#
+# ktap malloc_size_hist.kp
+# ktap malloc_size_hist.kp -- ls
+
+m = {}
+
+trace probe:/lib64/libc.so.6:malloc size=%di {
+       #arg2 is argument "size" of malloc function
+       m[arg2] += 1
+}
+
+trace_end {
+       histogram(m)
+}
diff --git a/drivers/staging/ktap/test/arg.kp b/drivers/staging/ktap/test/arg.kp
new file mode 100644 (file)
index 0000000..0cf16eb
--- /dev/null
@@ -0,0 +1,24 @@
+#!/usr/bin/env ktap
+
+function failed() {
+       printf("failed\n");
+       exit(-1);
+}
+
+#-----------------------------------------#
+
+if (!arg[0]) {
+       failed()
+}
+
+if (arg[1] != 1) {
+       failed()
+}
+
+if (arg[2] != "testing") {
+       failed()
+}
+
+if (arg[3] != "2 3 4") {
+       failed()
+}
diff --git a/drivers/staging/ktap/test/arithmetic.kp b/drivers/staging/ktap/test/arithmetic.kp
new file mode 100644 (file)
index 0000000..5063e50
--- /dev/null
@@ -0,0 +1,50 @@
+#!/usr/bin/env ktap
+
+function failed() {
+       printf("failed\n");
+       exit(-1);
+}
+
+#-----------------------------------------#
+
+if (1 > 2) {
+       failed()
+}
+
+if (200 < 100) {
+       failed()
+}
+
+a = 4
+b = 5
+
+if ((a + b) != 9) {
+       failed()
+}
+
+if ((a - b) != -1) {
+       failed()
+}
+
+if ((a % b) != 4) {
+       failed()
+}
+
+if ((a / b) != 0) {
+       failed()
+}
+
+
+#below checking only valid for 64-bit system
+
+c = 0x1234567812345678
+d = 0x2
+
+if (c + d != 0x123456781234567a) {
+       failed()
+}
+
+if (-1 != 0xffffffffffffffff) {
+       failed()
+}
+
diff --git a/drivers/staging/ktap/test/benchmark/sembench.c b/drivers/staging/ktap/test/benchmark/sembench.c
new file mode 100644 (file)
index 0000000..0811934
--- /dev/null
@@ -0,0 +1,556 @@
+/*
+ * copyright Oracle 2007.  Licensed under GPLv2
+ * To compile: gcc -Wall -o sembench sembench.c -lpthread
+ *
+ * usage: sembench -t thread count -w wakenum -r runtime -o op
+ * op can be: 0 (ipc sem) 1 (nanosleep) 2 (futexes)
+ *
+ * example:
+ *     sembench -t 1024 -w 512 -r 60 -o 2
+ * runs 1024 threads, waking up 512 at a time, running for 60 seconds using
+ * futex locking.
+ *
+ */
+#define  _GNU_SOURCE
+#define _POSIX_C_SOURCE 199309
+#include <fcntl.h>
+#include <sched.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <sys/sem.h>
+#include <sys/ipc.h>
+#include <sys/types.h>
+#include <sys/mman.h>
+#include <pthread.h>
+#include <unistd.h>
+#include <string.h>
+#include <time.h>
+#include <sys/time.h>
+#include <sys/syscall.h>
+#include <errno.h>
+
+#define VERSION "0.2"
+
+/* futexes have been around since 2.5.something, but it still seems I
+ * need to make my own syscall.  Sigh.
+ */
+#define FUTEX_WAIT              0
+#define FUTEX_WAKE              1
+#define FUTEX_FD                2
+#define FUTEX_REQUEUE           3
+#define FUTEX_CMP_REQUEUE       4
+#define FUTEX_WAKE_OP           5
+static inline int futex (int *uaddr, int op, int val,
+                        const struct timespec *timeout,
+                        int *uaddr2, int val3)
+{
+       return syscall(__NR_futex, uaddr, op, val, timeout, uaddr2, val3);
+}
+
+static void smp_mb(void)
+{
+       __sync_synchronize();
+}
+
+static int all_done = 0;
+static int timeout_test = 0;
+
+#define SEMS_PERID 250
+
+struct sem_operations;
+
+struct lockinfo {
+       unsigned long id;
+       unsigned long index;
+       int data;
+       pthread_t tid;
+       struct lockinfo *next;
+       struct sem_operations *ops;
+       unsigned long ready;
+};
+
+struct sem_wakeup_info {
+       int wakeup_count;
+       struct sembuf sb[SEMS_PERID];
+};
+
+struct sem_operations {
+       void (*wait)(struct lockinfo *l);
+       int (*wake)(struct sem_wakeup_info *wi, int num_semids, int num);
+       void (*setup)(struct sem_wakeup_info **wi, int num_semids);
+       void (*cleanup)(int num_semids);
+       char *name;
+};
+
+int *semid_lookup = NULL;
+
+pthread_mutex_t worklist_mutex = PTHREAD_MUTEX_INITIALIZER;
+static unsigned long total_burns = 0;
+static unsigned long min_burns = ~0UL;
+static unsigned long max_burns = 0;
+
+/* currently running threads */
+static int thread_count = 0;
+
+struct lockinfo *worklist = NULL;
+static int workers_started = 0;
+
+/* total threads started */
+static int num_threads = 2048;
+
+static void worklist_add(struct lockinfo *l)
+{
+       smp_mb();
+       l->ready = 1;
+}
+
+static struct lockinfo *worklist_rm(void)
+{
+       static int last_index = 0;
+       int i;
+       struct lockinfo *l;
+
+       for (i = 0; i < num_threads; i++) {
+               int test = (last_index + i) % num_threads;
+
+               l = worklist + test;
+               smp_mb();
+               if (l->ready) {
+                       l->ready = 0;
+                       last_index = test;
+                       return l;
+               }
+       }
+       return NULL;
+}
+
+/* ipc semaphore post& wait */
+void wait_ipc_sem(struct lockinfo *l)
+{
+       struct sembuf sb;
+       int ret;
+       struct timespec *tvp = NULL;
+       struct timespec tv = { 0, 1 };
+
+       sb.sem_num = l->index;
+       sb.sem_flg = 0;
+
+       sb.sem_op = -1;
+       l->data = 1;
+
+       if (timeout_test && (l->id % 5) == 0)
+               tvp = &tv;
+
+       worklist_add(l);
+       ret = semtimedop(semid_lookup[l->id], &sb, 1, tvp);
+
+       while(l->data != 0 && tvp) {
+               struct timespec tv2 = { 0, 500 };
+               nanosleep(&tv2, NULL);
+       }
+
+       if (l->data != 0) {
+               if (tvp)
+                       return;
+               fprintf(stderr, "wakeup without data update\n");
+               exit(1);
+       }
+       if (ret) {
+               if (errno == EAGAIN && tvp)
+                       return;
+               perror("semtimed op");
+               exit(1);
+       }
+}
+
+int ipc_wake_some(struct sem_wakeup_info *wi, int num_semids, int num)
+{
+       int i;
+       int ret;
+       struct lockinfo *l;
+       int found = 0;
+
+       for (i = 0; i < num_semids; i++) {
+               wi[i].wakeup_count = 0;
+       }
+       while(num > 0) {
+               struct sembuf *sb;
+               l = worklist_rm();
+               if (!l)
+                       break;
+               if (l->data != 1)
+                       fprintf(stderr, "warning, lockinfo data was %d\n",
+                               l->data);
+               l->data = 0;
+               sb = wi[l->id].sb + wi[l->id].wakeup_count;
+               sb->sem_num = l->index;
+               sb->sem_op = 1;
+               sb->sem_flg = IPC_NOWAIT;
+               wi[l->id].wakeup_count++;
+               found++;
+               num--;
+       }
+       if (!found)
+               return 0;
+       for (i = 0; i < num_semids; i++) {
+               int wakeup_total;
+               int cur;
+               int offset = 0;
+               if (!wi[i].wakeup_count)
+                       continue;
+               wakeup_total = wi[i].wakeup_count;
+               while(wakeup_total > 0) {
+                       cur = wakeup_total > 64 ? 64 : wakeup_total;
+                       ret = semtimedop(semid_lookup[i], wi[i].sb + offset,
+                                        cur, NULL);
+                       if (ret) {
+                               perror("semtimedop");
+                               exit(1);
+                       }
+                       offset += cur;
+                       wakeup_total -= cur;
+               }
+       }
+       return found;
+}
+
+void setup_ipc_sems(struct sem_wakeup_info **wi, int num_semids)
+{
+       int i;
+       *wi = malloc(sizeof(**wi) * num_semids);
+       semid_lookup = malloc(num_semids * sizeof(int));
+       for(i = 0; i < num_semids; i++) {
+               semid_lookup[i] = semget(IPC_PRIVATE, SEMS_PERID,
+                                        IPC_CREAT | 0777);
+               if (semid_lookup[i] < 0) {
+                       perror("semget");
+                       exit(1);
+               }
+       }
+       sleep(10);
+}
+
+void cleanup_ipc_sems(int num)
+{
+       int i;
+       for (i = 0; i < num; i++) {
+               semctl(semid_lookup[i], 0, IPC_RMID);
+       }
+}
+
+struct sem_operations ipc_sem_ops = {
+       .wait = wait_ipc_sem,
+       .wake = ipc_wake_some,
+       .setup = setup_ipc_sems,
+       .cleanup = cleanup_ipc_sems,
+       .name = "ipc sem operations",
+};
+
+/* futex post & wait */
+void wait_futex_sem(struct lockinfo *l)
+{
+       int ret;
+       l->data = 1;
+       worklist_add(l);
+       while(l->data == 1) {
+               ret = futex(&l->data, FUTEX_WAIT, 1, NULL, NULL, 0);
+               /*
+               if (ret && ret != EWOULDBLOCK) {
+                       perror("futex wait");
+                       exit(1);
+               }*/
+       }
+}
+
+int futex_wake_some(struct sem_wakeup_info *wi, int num_semids, int num)
+{
+       int i;
+       int ret;
+       struct lockinfo *l;
+       int found = 0;
+
+       for (i = 0; i < num; i++) {
+               l = worklist_rm();
+               if (!l)
+                       break;
+               if (l->data != 1)
+                       fprintf(stderr, "warning, lockinfo data was %d\n",
+                               l->data);
+               l->data = 0;
+               ret = futex(&l->data, FUTEX_WAKE, 1, NULL, NULL, 0);
+               if (ret < 0) {
+                       perror("futex wake");
+                       exit(1);
+               }
+               found++;
+       }
+       return found;
+}
+
+void setup_futex_sems(struct sem_wakeup_info **wi, int num_semids)
+{
+       return;
+}
+
+void cleanup_futex_sems(int num)
+{
+       return;
+}
+
+struct sem_operations futex_sem_ops = {
+       .wait = wait_futex_sem,
+       .wake = futex_wake_some,
+       .setup = setup_futex_sems,
+       .cleanup = cleanup_futex_sems,
+       .name = "futex sem operations",
+};
+
+/* nanosleep sems here */
+void wait_nanosleep_sem(struct lockinfo *l)
+{
+       int ret;
+       struct timespec tv = { 0, 1000000 };
+       int count = 0;
+
+       l->data = 1;
+       worklist_add(l);
+       while(l->data) {
+               ret = nanosleep(&tv, NULL);
+               if (ret) {
+                       perror("nanosleep");
+                       exit(1);
+               }
+               count++;
+       }
+}
+
+int nanosleep_wake_some(struct sem_wakeup_info *wi, int num_semids, int num)
+{
+       int i;
+       struct lockinfo *l;
+
+       for (i = 0; i < num; i++) {
+               l = worklist_rm();
+               if (!l)
+                       break;
+               if (l->data != 1)
+                       fprintf(stderr, "warning, lockinfo data was %d\n",
+                               l->data);
+               l->data = 0;
+       }
+       return i;
+}
+
+void setup_nanosleep_sems(struct sem_wakeup_info **wi, int num_semids)
+{
+       return;
+}
+
+void cleanup_nanosleep_sems(int num)
+{
+       return;
+}
+
+struct sem_operations nanosleep_sem_ops = {
+       .wait = wait_nanosleep_sem,
+       .wake = nanosleep_wake_some,
+       .setup = setup_nanosleep_sems,
+       .cleanup = cleanup_nanosleep_sems,
+       .name = "nano sleep sem operations",
+};
+
+void *worker(void *arg)
+{
+       struct lockinfo *l = (struct lockinfo *)arg;
+       int burn_count = 0;
+       pthread_t tid = pthread_self();
+       size_t pagesize = getpagesize();
+       char *buf = malloc(pagesize);
+
+       if (!buf) {
+               perror("malloc");
+               exit(1);
+       }
+
+       l->tid = tid;
+       workers_started = 1;
+       smp_mb();
+
+       while(!all_done) {
+               l->ops->wait(l);
+               if (all_done)
+                       break;
+               burn_count++;
+       }
+       pthread_mutex_lock(&worklist_mutex);
+       total_burns += burn_count;
+       if (burn_count < min_burns)
+               min_burns = burn_count;
+       if (burn_count > max_burns)
+               max_burns = burn_count;
+       thread_count--;
+       pthread_mutex_unlock(&worklist_mutex);
+       return (void *)0;
+}
+
+void print_usage(void)
+{
+       printf("usage: sembench [-t threads] [-w wake incr] [-r runtime]");
+       printf("                [-o num] (0=ipc, 1=nanosleep, 2=futex)\n");
+       exit(1);
+}
+
+#define NUM_OPERATIONS 3
+struct sem_operations *allops[NUM_OPERATIONS] = { &ipc_sem_ops,
+                                               &nanosleep_sem_ops,
+                                               &futex_sem_ops};
+
+int main(int ac, char **av) {
+       int ret;
+       int i;
+       int semid = 0;
+       int sem_num = 0;
+       int burn_count = 0;
+       struct sem_wakeup_info *wi = NULL;
+       struct timeval start;
+       struct timeval now;
+       int num_semids = 0;
+       int wake_num = 256;
+       int run_secs = 30;
+       int pagesize = getpagesize();
+       char *buf = malloc(pagesize);
+       struct sem_operations *ops = allops[0];
+       cpu_set_t cpu_mask;
+       cpu_set_t target_mask;
+       int target_cpu = 0;
+       int max_cpu = -1;
+
+       if (!buf) {
+               perror("malloc");
+               exit(1);
+       }
+       for (i = 1; i < ac; i++) {
+               if (strcmp(av[i], "-t") == 0) {
+                       if (i == ac -1)
+                               print_usage();
+                       num_threads = atoi(av[i+1]);
+                       i++;
+               } else if (strcmp(av[i], "-w") == 0) {
+                       if (i == ac -1)
+                               print_usage();
+                       wake_num = atoi(av[i+1]);
+                       i++;
+               } else if (strcmp(av[i], "-r") == 0) {
+                       if (i == ac -1)
+                               print_usage();
+                       run_secs = atoi(av[i+1]);
+                       i++;
+               } else if (strcmp(av[i], "-o") == 0) {
+                       int index;
+                       if (i == ac -1)
+                               print_usage();
+                       index = atoi(av[i+1]);
+                       if (index >= NUM_OPERATIONS) {
+                               fprintf(stderr, "invalid operations %d\n",
+                                       index);
+                               exit(1);
+                       }
+                       ops = allops[index];
+                       i++;
+               } else if (strcmp(av[i], "-T") == 0) {
+                       timeout_test = 1;
+               } else if (strcmp(av[i], "-h") == 0) {
+                       print_usage();
+               }
+       }
+       num_semids = (num_threads + SEMS_PERID - 1) / SEMS_PERID;
+       ops->setup(&wi, num_semids);
+
+       ret = sched_getaffinity(0, sizeof(cpu_set_t), &cpu_mask);
+       if (ret) {
+               perror("sched_getaffinity");
+               exit(1);
+       }
+       for (i = 0; i < CPU_SETSIZE; i++)
+               if (CPU_ISSET(i, &cpu_mask))
+                       max_cpu = i;
+       if (max_cpu == -1) {
+               fprintf(stderr, "sched_getaffinity returned empty mask\n");
+               exit(1);
+       }
+
+       CPU_ZERO(&target_mask);
+
+       worklist = malloc(sizeof(*worklist) * num_threads);
+       memset(worklist, 0, sizeof(*worklist) * num_threads);
+
+       for (i = 0; i < num_threads; i++) {
+               struct lockinfo *l;
+               pthread_t tid;
+               thread_count++;
+               l = worklist + i;
+               if (!l) {
+                       perror("malloc");
+                       exit(1);
+               }
+               l->id = semid;
+               l->index = sem_num++;
+               l->ops = ops;
+               if (sem_num >= SEMS_PERID) {
+                       semid++;
+                       sem_num = 0;
+               }
+               ret = pthread_create(&tid, NULL, worker, (void *)l);
+               if (ret) {
+                       perror("pthread_create");
+                       exit(1);
+               }
+
+               while (!CPU_ISSET(target_cpu, &cpu_mask)) {
+                       target_cpu++;
+                       if (target_cpu > max_cpu)
+                               target_cpu = 0;
+               }
+               CPU_SET(target_cpu, &target_mask);
+               ret = pthread_setaffinity_np(tid, sizeof(cpu_set_t),
+                                            &target_mask);
+               CPU_CLR(target_cpu, &target_mask);
+               target_cpu++;
+
+               ret = pthread_detach(tid);
+               if (ret) {
+                       perror("pthread_detach");
+                       exit(1);
+               }
+       }
+       while(!workers_started) {
+               smp_mb();
+               usleep(200);
+       }
+       gettimeofday(&start, NULL);
+       fprintf(stderr, "main loop going\n");
+       while(1) {
+               ops->wake(wi, num_semids, wake_num);
+               burn_count++;
+               gettimeofday(&now, NULL);
+               if (now.tv_sec - start.tv_sec >= run_secs)
+                       break;
+       }
+       fprintf(stderr, "all done\n");
+       all_done = 1;
+       while(thread_count > 0) {
+               ops->wake(wi, num_semids, wake_num);
+               usleep(200);
+       }
+       printf("%d threads, waking %d at a time\n", num_threads, wake_num);
+       printf("using %s\n", ops->name);
+       printf("main thread burns: %d\n", burn_count);
+       printf("worker burn count total %lu min %lu max %lu avg %lu\n",
+              total_burns, min_burns, max_burns, total_burns / num_threads);
+       printf("run time %d seconds %lu worker burns per second\n",
+               (int)(now.tv_sec - start.tv_sec),
+               total_burns / (now.tv_sec - start.tv_sec));
+       ops->cleanup(num_semids);
+       return 0;
+}
+
diff --git a/drivers/staging/ktap/test/benchmark/test.sh b/drivers/staging/ktap/test/benchmark/test.sh
new file mode 100644 (file)
index 0000000..f29a882
--- /dev/null
@@ -0,0 +1,26 @@
+#!/bin/sh
+
+gcc -o sembench sembench.c -O2 -lpthread
+
+COMMAND="./sembench -t 200 -w 20 -r 30 -o 2"
+
+echo -e "\n\t\tPass 1 without tracing"
+$COMMAND
+echo -e "\n\t\tPass 2 without tracing"
+$COMMAND
+echo -e "\n\t\tPass 3 without tracing"
+$COMMAND
+
+echo ""
+
+../../ktap -e 'trace syscalls:sys_*_futex {}' &
+
+echo -e "\n\t\tPass 1 with tracing"
+$COMMAND
+echo -e "\n\t\tPass 2 with tracing"
+$COMMAND
+echo -e "\n\t\tPass 3 with tracing"
+$COMMAND
+
+pkill ktap
+rm -rf ./sembench
diff --git a/drivers/staging/ktap/test/concat.kp b/drivers/staging/ktap/test/concat.kp
new file mode 100644 (file)
index 0000000..be77bb7
--- /dev/null
@@ -0,0 +1,15 @@
+#!/usr/bin/env ktap
+
+function failed() {
+       printf("failed\n");
+       exit(-1);
+}
+
+#----------------------------------------#
+
+a = "123"
+b = "456"
+
+if (a..b != "123456") {
+       failed()
+}
diff --git a/drivers/staging/ktap/test/count.kp b/drivers/staging/ktap/test/count.kp
new file mode 100644 (file)
index 0000000..26f962c
--- /dev/null
@@ -0,0 +1,20 @@
+#!/usr/bin/env ktap
+
+function failed() {
+       printf("failed\n");
+       exit(-1);
+}
+
+#---------------------------------------#
+
+t = {}
+
+t["key"] += 1
+if (t["key"] != 1) {
+       failed()
+}
+
+t["key"] += 1
+if (t["key"] != 2) {
+       failed()
+}
diff --git a/drivers/staging/ktap/test/ffi/.gitignore b/drivers/staging/ktap/test/ffi/.gitignore
new file mode 100644 (file)
index 0000000..3fdfdc1
--- /dev/null
@@ -0,0 +1,2 @@
+cparser_test
+Module.symvers
diff --git a/drivers/staging/ktap/test/ffi/Makefile b/drivers/staging/ktap/test/ffi/Makefile
new file mode 100644 (file)
index 0000000..fd7016f
--- /dev/null
@@ -0,0 +1,46 @@
+obj-m += ktap_ffi_test.o
+
+all: funct_mod cparser_test
+
+funct_mod:
+       make -C /lib/modules/$(shell uname -r)/build M=$(PWD) modules
+
+INC=../../include
+U_DIR=../../userspace
+RUNTIME=../../runtime
+U_FFI_DIR=$(U_DIR)/ffi
+CPARSER_FILES=cparser.o ctype.o ffi_type.o
+KTAPC_CFLAGS = -Wall -O2
+
+cparser.o: $(U_FFI_DIR)/cparser.c $(INC)/*
+       $(QUIET_CC)$(CC) -DCONFIG_KTAP_FFI -o $@ -c $<
+
+ctype.o: $(U_FFI_DIR)/ctype.c $(INC)/*
+       $(QUIET_CC)$(CC) -DCONFIG_KTAP_FFI -o $@ -c $<
+
+ffi_type.o: $(RUNTIME)/ffi/ffi_type.c $(INC)/*
+       $(QUIET_CC)$(CC) -DCONFIG_KTAP_FFI -o $@ -c $<
+
+cparser_test: cparser_test.c $(CPARSER_FILES) $(INC)/*
+       $(QUIET_CC)$(CC) -DCONFIG_KTAP_FFI -I$(INC) -I$(U_DIR) $(KTAPC_CFLAGS) \
+               -o $@ $< $(CPARSER_FILES)
+
+load:
+       insmod ktap_ffi_test.ko
+
+unload:
+       rmmod ktap_ffi_test
+
+test: all
+       @echo "testing cparser:"
+       ./cparser_test
+       @echo "testing ffi module:"
+       rmmod ktap_ffi_test > /dev/null 2>&1 || true
+       insmod ktap_ffi_test.ko
+       ../../ktap ffi_test.kp
+       rmmod ktap_ffi_test.ko
+       @echo "[*] all ffi tests passed."
+
+clean:
+       make -C /lib/modules/$(shell uname -r)/build M=$(PWD) clean
+       rm -rf cparser_test
diff --git a/drivers/staging/ktap/test/ffi/cparser_test.c b/drivers/staging/ktap/test/ffi/cparser_test.c
new file mode 100644 (file)
index 0000000..21a7814
--- /dev/null
@@ -0,0 +1,322 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <assert.h>
+
+#include "ktap_types.h"
+#include "ktap_opcodes.h"
+#include "../../userspace/ktapc.h"
+#include "cparser.h"
+
+void ffi_cparser_init(void);
+void ffi_cparser_free(void);
+int ffi_cdef(const char *s);
+
+static cp_csymbol_state *csym_state;
+
+#define cs_nr (csym_state->cs_nr)
+#define cs_arr_size (csym_state->cs_arr_size)
+#define cs_arr (csym_state->cs_arr)
+
+
+#define DO_TEST(name) do {                                     \
+       ffi_cparser_init();                                     \
+       int ret;                                                \
+       printf("[*] start "#name" test...  ");                  \
+       ret = test_##name();                                    \
+       if (ret)                                                \
+               fprintf(stderr, "\n[!] "#name" test failed.\n");\
+       else                                                    \
+               printf(" passed.\n");                           \
+       ffi_cparser_free();                                     \
+} while (0)
+
+#define assert_csym_arr_type(cs_arr, n, t) do {                        \
+       csymbol *ncs;                                           \
+       ncs = &cs_arr[n];                                       \
+       assert(ncs->type == t);                                 \
+} while (0)
+
+#define assert_fret_type(fcs, t) do {                          \
+       csymbol *ncs;                                           \
+       ncs = &cs_arr[fcs->ret_id];                             \
+       assert(ncs->type == t);                                 \
+} while (0)
+
+#define assert_farg_type(fcs, n, t) do {                       \
+       csymbol *ncs;                                           \
+       ncs = &cs_arr[fcs->arg_ids[n]];                         \
+       assert(ncs->type == t);                                 \
+} while (0)
+
+
+
+
+/* mock find_kernel_symbol */
+unsigned long find_kernel_symbol(const char *symbol)
+{
+       return 0xdeadbeef;
+}
+
+int lookup_csymbol_id_by_name(char *name)
+{
+       int i;
+
+       for (i = 0; i < cs_nr; i++) {
+               if (!strcmp(name, cs_arr[i].name)) {
+                       return i;
+               }
+       }
+
+       return -1;
+}
+
+int test_func_sched_clock()
+{
+       int idx;
+       csymbol *cs;
+       csymbol_func *fcs;
+
+       ffi_cdef("unsigned long long sched_clock();");
+
+       csym_state = ctype_get_csym_state();
+       assert(cs_arr);
+
+       idx = lookup_csymbol_id_by_name("sched_clock");
+       assert(idx >= 0);
+       cs = &cs_arr[idx];
+       assert(cs->type == FFI_FUNC);
+
+       fcs = csym_func(cs);
+
+       /* check return type */
+       assert_fret_type(fcs, FFI_UINT64);
+
+       /* check arguments */
+       assert(fcs->arg_nr == 0);
+
+       return 0;
+}
+
+int test_func_funct_module()
+{
+       int idx;
+       csymbol *cs;
+       csymbol_func *fcs;
+
+       ffi_cdef("void funct_void();");
+       ffi_cdef("int funct_int1(unsigned char a, char b, unsigned short c, "
+                       "short d);");
+       ffi_cdef("long long funct_int2(unsigned int a, int b, "
+                       "unsigned long c, long d, unsigned long long e, "
+                       "long long f, long long g);");
+       ffi_cdef("void *funct_pointer1(char *a);");
+
+       csym_state = ctype_get_csym_state();
+       assert(cs_arr);
+
+       /* check funct_void function */
+       idx = lookup_csymbol_id_by_name("funct_void");
+       assert(idx >= 0);
+       cs = &cs_arr[idx];
+       assert(cs->type == FFI_FUNC);
+       fcs = csym_func(cs);
+
+       /* check return type */
+       assert_fret_type(fcs, FFI_VOID);
+
+       /* check arguments */
+       assert(fcs->arg_nr == 0);
+
+
+
+       /* check funct_int1 function */
+       idx = lookup_csymbol_id_by_name("funct_int1");
+       assert(idx >= 0);
+       cs = &cs_arr[idx];
+       assert(cs);
+       assert(cs->type == FFI_FUNC);
+       fcs = csym_func(cs);
+
+       /* check return type */
+       assert_fret_type(fcs, FFI_INT32);
+
+       /* check arguments */
+       assert(fcs->arg_nr == 4);
+       assert_farg_type(fcs, 0, FFI_UINT8);
+       assert_farg_type(fcs, 1, FFI_INT8);
+       assert_farg_type(fcs, 2, FFI_UINT16);
+       assert_farg_type(fcs, 3, FFI_INT16);
+
+
+
+       /* check funct_int2 function */
+       idx = lookup_csymbol_id_by_name("funct_int2");
+       assert(idx >= 0);
+       cs = &cs_arr[idx];
+       assert(cs);
+       assert(cs->type == FFI_FUNC);
+       fcs = csym_func(cs);
+
+       /* check return type */
+       assert_fret_type(fcs, FFI_INT64);
+
+       /* check arguments */
+       assert(fcs->arg_nr == 7);
+       assert_farg_type(fcs, 0, FFI_UINT32);
+       assert_farg_type(fcs, 1, FFI_INT32);
+       assert_farg_type(fcs, 2, FFI_UINT64);
+       assert_farg_type(fcs, 3, FFI_INT64);
+       assert_farg_type(fcs, 4, FFI_UINT64);
+       assert_farg_type(fcs, 5, FFI_INT64);
+       assert_farg_type(fcs, 6, FFI_INT64);
+
+
+
+       /* check funct_pointer1 function */
+       idx = lookup_csymbol_id_by_name("funct_pointer1");
+       assert(idx >= 0);
+       cs = &cs_arr[idx];
+       assert(cs);
+       assert(cs->type == FFI_FUNC);
+       fcs = csym_func(cs);
+
+       /* check return type */
+       assert_fret_type(fcs, FFI_PTR);
+
+       /* check arguments */
+       assert(fcs->arg_nr == 1);
+       assert_farg_type(fcs, 0, FFI_PTR);
+       /*@TODO check pointer dereference type  18.11 2013 (houqp)*/
+
+       return 0;
+}
+
+int test_struct_timespec()
+{
+       int idx;
+       csymbol *cs;
+       csymbol_struct *stcs;
+
+       ffi_cdef("struct timespec { long ts_sec; long ts_nsec; };");
+
+       csym_state = ctype_get_csym_state();
+       assert(cs_arr);
+
+       idx = lookup_csymbol_id_by_name("struct timespec");
+       assert(idx >= 0);
+       cs = &cs_arr[idx];
+       assert(cs);
+       assert(cs->type == FFI_STRUCT);
+
+       stcs = csym_struct(cs);
+       assert(stcs->memb_nr == 2);
+
+       return 0;
+}
+
+int test_func_time_to_tm()
+{
+       int idx;
+       csymbol *cs, *arg_cs;
+       csymbol_struct *stcs;
+       csymbol_func *fcs;
+
+       ffi_cdef("typedef long time_t;");
+       ffi_cdef("struct tm { "
+                       "int tm_sec;"
+                       "int tm_min;"
+                       "int tm_hour;"
+                       "int tm_mday;"
+                       "int tm_mon;"
+                       "long tm_year;"
+                       "int tm_wday;"
+                       "int tm_yday;"
+               "};");
+       ffi_cdef("void time_to_tm(time_t totalsecs, int offset, struct tm *result);");
+
+       csym_state = ctype_get_csym_state();
+       assert(cs_arr);
+
+       idx = lookup_csymbol_id_by_name("struct tm");
+       assert(idx >= 0);
+       cs = cp_id_to_csym(idx);
+       assert(cs);
+       assert(cs->type == FFI_STRUCT);
+
+       stcs = csym_struct(cs);
+       assert(stcs->memb_nr == 8);
+
+
+       idx = lookup_csymbol_id_by_name("time_to_tm");
+       assert(idx >= 0);
+       cs = cp_id_to_csym(idx);
+       assert(cs);
+       assert(cs->type == FFI_FUNC);
+
+       fcs = csym_func(cs);
+       assert(csymf_arg_nr(fcs) == 3);
+       /* check first argument */
+       assert_farg_type(fcs, 0, FFI_INT64);
+
+       /* check second argument */
+       assert_farg_type(fcs, 1, FFI_INT32);
+       /* check third argument */
+       assert_farg_type(fcs, 2, FFI_PTR);
+       arg_cs = cp_csymf_arg(fcs, 2);
+       assert(!strcmp(csym_name(arg_cs), "struct tm *"));
+       assert(csym_ptr_deref_id(arg_cs) ==
+                       lookup_csymbol_id_by_name("struct tm"));
+
+       return 0;
+}
+
+int test_pointer_symbols()
+{
+       csymbol_func *fcs_foo, *fcs_bar;
+
+       /* int pointer symbol should be resolved to the same id */
+       ffi_cdef("void foo(int *a);");
+       ffi_cdef("int *bar(void);");
+
+       csym_state = ctype_get_csym_state();
+       assert(cs_arr);
+
+       fcs_foo = csym_func(cp_id_to_csym(lookup_csymbol_id_by_name("foo")));
+       fcs_bar = csym_func(cp_id_to_csym(lookup_csymbol_id_by_name("bar")));
+
+       assert(csymf_arg_ids(fcs_foo)[0] == csymf_ret_id(fcs_bar));
+       assert(cp_csymf_arg(fcs_foo, 0) == cp_csymf_ret(fcs_bar));
+
+       return 0;
+}
+
+int test_var_arg_function()
+{
+       csymbol_func *fcs;
+
+       ffi_cdef("int printk(char *fmt, ...);");
+
+       fcs = csym_func(cp_id_to_csym(lookup_csymbol_id_by_name("printk")));
+
+       /* var arg function needs void * type argument type checking */
+       assert(lookup_csymbol_id_by_name("void *") >= 0);
+
+       assert_fret_type(fcs, FFI_INT32);
+       assert_farg_type(fcs, 0, FFI_PTR);
+       assert(fcs->has_var_arg);
+
+       return 0;
+}
+
+int main (int argc, char *argv[])
+{
+       DO_TEST(func_sched_clock);
+       DO_TEST(func_funct_module);
+       DO_TEST(struct_timespec);
+       DO_TEST(func_time_to_tm);
+       DO_TEST(pointer_symbols);
+       DO_TEST(var_arg_function);
+
+       return 0;
+}
diff --git a/drivers/staging/ktap/test/ffi/ffi_test.kp b/drivers/staging/ktap/test/ffi/ffi_test.kp
new file mode 100644 (file)
index 0000000..20a9a5e
--- /dev/null
@@ -0,0 +1,47 @@
+function failed(msg) {
+       printf("failed: " .. msg);
+       printf("\n")
+       exit(-1);
+}
+
+
+cdef[[
+       void ffi_test_void();
+       int ffi_test_int1(unsigned char a, char b, unsigned short c, short d);
+       long long ffi_test_int2(unsigned int a, int b, unsigned long c, long d,
+                               unsigned long long e, long long f, long long g);
+       void *ffi_test_pointer1(char *a);
+       long long ffi_test_var_arg(int n, ...);
+       unsigned long long ffi_test_sched_clock(void);
+]]
+
+
+ret = C.ffi_test_void()
+if (ret != nil) {
+       failed("ffi_test_void should return nil")
+}
+
+ret = C.ffi_test_int1(1111, 1111, 1111, 1111)
+if (ret != 2396) {
+       failed("ffi_test_int1(1111, 1111, 1111, 1111) should return 2396")
+}
+
+ret = C.ffi_test_int2(90, 7800, 560000, 34000000, 1200000000, 900000000000, 78000000000000)
+if (ret != 78901234567890) {
+       failed("ffi_test_int2 should return 78901234567890")
+}
+
+ret = C.ffi_test_pointer1("")
+if (ret == nil) {
+       failed("ffi_test_pointer1 shoudl return address around 0xffff8800--------")
+}
+
+ret = C.ffi_test_var_arg(7, 90, 7800, 560000, 34000000, 1200000000, 900000000000, 78000000000000)
+if (ret != 78901234567890) {
+       failed("ffi_test_var_arg should return 78901234567890")
+}
+
+ret = C.ffi_test_sched_clock()
+if (ret == nil) {
+       failed("ffi_test_clock should not return nil")
+}
diff --git a/drivers/staging/ktap/test/ffi/ktap_ffi_test.c b/drivers/staging/ktap/test/ffi/ktap_ffi_test.c
new file mode 100644 (file)
index 0000000..9434244
--- /dev/null
@@ -0,0 +1,64 @@
+#include <linux/module.h>
+#include <linux/kernel.h>
+#include <linux/init.h>
+#include <linux/sched.h>
+
+void ffi_test_void(void)
+{
+}
+EXPORT_SYMBOL(ffi_test_void);
+
+int ffi_test_int1(unsigned char a, char b, unsigned short c, short d)
+{
+       return a + b + c + d;
+}
+EXPORT_SYMBOL(ffi_test_int1);
+
+long long ffi_test_int2(unsigned int a, int b, unsigned long c, long d,
+               unsigned long long e, long long f, long long g)
+{
+       return a + b + c + d + e + f + g;
+}
+EXPORT_SYMBOL(ffi_test_int2);
+
+void *ffi_test_pointer1(char *a) {
+       return a;
+}
+EXPORT_SYMBOL(ffi_test_pointer1);
+
+long long ffi_test_var_arg(int n, ...) {
+       va_list ap;
+       int i;
+       long long sum = 0;
+       va_start(ap, n);
+       for (i = 0; i < n; i++) {
+               sum += va_arg(ap, long long);
+       }
+       va_end(ap);
+       return sum;
+}
+EXPORT_SYMBOL(ffi_test_var_arg);
+
+unsigned long long ffi_test_sched_clock(void)
+{
+       return sched_clock();
+}
+EXPORT_SYMBOL(ffi_test_sched_clock);
+
+
+
+static int __init ffi_test_init(void)
+{
+       return 0;
+}
+
+static void __exit ffi_test_exit(void)
+{
+}
+
+
+MODULE_DESCRIPTION("ktap ffi test module");
+MODULE_LICENSE("GPL");
+
+module_init(ffi_test_init);
+module_exit(ffi_test_exit);
diff --git a/drivers/staging/ktap/test/fibonacci.kp b/drivers/staging/ktap/test/fibonacci.kp
new file mode 100644 (file)
index 0000000..7e141da
--- /dev/null
@@ -0,0 +1,36 @@
+#!/usr/bin/env ktap
+
+function failed() {
+       printf("failed\n");
+       exit(-1);
+}
+
+#---------------fibonacci----------------
+
+
+#regular recursive fibonacci
+function fib(n) {
+       if (n < 2) {
+               return n
+       }
+       return fib(n-1) + fib(n-2)
+}
+
+if (fib(20) != 6765) {
+       failed()
+}
+
+#tail recursive fibonacci
+function fib(n) {
+       f = function (iter, res, next) {
+               if (iter == 0) {
+                       return res;
+               }
+               return f(iter-1, next, res+next)
+       }
+       return f(n, 0, 1)
+}
+
+if (fib(20) != 6765) {
+       failed()
+}
diff --git a/drivers/staging/ktap/test/function.kp b/drivers/staging/ktap/test/function.kp
new file mode 100644 (file)
index 0000000..b808b91
--- /dev/null
@@ -0,0 +1,88 @@
+#!/usr/bin/env ktap
+
+function failed() {
+       printf("failed\n");
+       exit(-1);
+}
+
+### basic function call ###
+function f1(a, b) {
+       return a + b
+}
+
+if (f1(2, 3) != 5) {
+       failed();
+}
+
+### return string ###
+function f2() {
+       return "function return"
+}
+
+if (f2() != "function return") {
+       failed();
+}
+
+### mutli-value return ###
+function f3(a, b) {
+       return a+b, a-b;
+}
+
+c, d = f3(2, 3);
+if(c != 5 || d != -1) {
+       failed();
+}
+
+
+### closure testing ###
+function f4() {
+       f5 = function(a, b) {
+               return a * b
+       }
+       return f5
+}
+
+local f = f4()
+if (f(9, 9) != 81) {
+       failed();
+}
+
+### closure with lexcial variable ###
+# issue: variable cannot be local
+i = 1
+function f6() {
+       i = 5
+       f7 = function(a, b) {
+               return a * b + i
+       }
+       return f7
+}
+
+f = f6()
+if (f(9, 9) != 81 + i) {
+       failed();
+}
+
+i = 6
+if (f(9, 9) != 81 + i) {
+       failed();
+}
+
+### tail call
+### stack should not overflow in tail call mechanism
+a = 0
+function f8(i) {
+       if (i == 1000000) {
+               a = 1000000
+               return
+       }
+       # must add return here, otherwise stack overflow
+       return f8(i+1)
+}
+
+f8(0)
+if (a != 1000000) {
+       failed();
+}
+
+
diff --git a/drivers/staging/ktap/test/if.kp b/drivers/staging/ktap/test/if.kp
new file mode 100644 (file)
index 0000000..3122084
--- /dev/null
@@ -0,0 +1,24 @@
+#!/usr/bin/env ktap
+
+function failed() {
+       printf("failed\n");
+       exit(-1);
+}
+
+#-----------------------------------------#
+
+if (false) {
+       failed()
+}
+
+if (nil) {
+       failed()
+}
+
+# ktap only think false and nil is "real false", number 0 is true
+# it's same as lua
+# Might change it in future, to make similar with C
+if (0) {
+       #failed()
+}
+
diff --git a/drivers/staging/ktap/test/kprobe.kp b/drivers/staging/ktap/test/kprobe.kp
new file mode 100644 (file)
index 0000000..483bccd
--- /dev/null
@@ -0,0 +1,19 @@
+#!/usr/bin/env ktap
+
+n = 0
+trace probe:schedule {
+       n = n + 1
+}
+
+# share same event id with previous one
+trace probe:schedule {
+}
+
+
+tick-1s {
+       if (n == 0) {
+               printf("failed\n");
+       }
+       exit()
+}
+
diff --git a/drivers/staging/ktap/test/kretprobe.kp b/drivers/staging/ktap/test/kretprobe.kp
new file mode 100644 (file)
index 0000000..e311e84
--- /dev/null
@@ -0,0 +1,14 @@
+#!/usr/bin/env ktap
+
+n = 0
+trace probe:__schedule%return {
+       n = n + 1
+}
+
+tick-1s {
+       if (n == 0) {
+               printf("failed\n");
+       }
+       exit()
+}
+
diff --git a/drivers/staging/ktap/test/ksym.kp b/drivers/staging/ktap/test/ksym.kp
new file mode 100644 (file)
index 0000000..736acfe
--- /dev/null
@@ -0,0 +1,17 @@
+#!/usr/bin/env ktap
+
+function failed() {
+       printf("failed\n");
+       exit(-1);
+}
+
+#-----------------------------------------#
+
+a = `generic_file_buffered_write`
+b = `generic_file_mmap`
+
+printf("generic_file_buffered_write: 0x%x\n", a);
+printf("generic_file_mmap: 0x%x\n", b);
+
+# test read symbol in kernel module
+printf("kp_call: 0x%x\n", `kp_call`)
diff --git a/drivers/staging/ktap/test/len.kp b/drivers/staging/ktap/test/len.kp
new file mode 100644 (file)
index 0000000..697d915
--- /dev/null
@@ -0,0 +1,25 @@
+#!/usr/bin/env ktap
+
+function failed() {
+       printf("failed\n");
+       exit(-1);
+}
+
+#-----------------------------------------#
+
+a = "123456789"
+
+if (len(a) != 9) {
+       failed()
+}
+
+b = {}
+b[0] = 0
+b[1] = 1
+b["keys"] = "values"
+
+if (len(b) != 3) {
+       failed()
+}
+
+
diff --git a/drivers/staging/ktap/test/looping.kp b/drivers/staging/ktap/test/looping.kp
new file mode 100644 (file)
index 0000000..fe48051
--- /dev/null
@@ -0,0 +1,40 @@
+#!/usr/bin/env ktap
+
+function failed() {
+       printf("failed\n");
+       exit(-1);
+}
+
+### basic while-loop testing
+a = 1
+while (a < 1000) {
+       a = a + 1
+}
+
+if (a != 1000) {
+       failed()
+}
+
+### break testing
+### Note that ktap don't have continue keyword
+a = 1
+while (a < 1000) {
+       if (a == 10) {
+               break
+       }
+       a = a + 1
+}
+
+if (a != 10) {
+       failed()
+}
+
+### for-loop testing
+b=0
+for (c = 0, 1000, 1) {
+       b = b + 1
+}
+
+if (b != 1001) {
+       failed()
+}
diff --git a/drivers/staging/ktap/test/pairs.kp b/drivers/staging/ktap/test/pairs.kp
new file mode 100644 (file)
index 0000000..c062f16
--- /dev/null
@@ -0,0 +1,84 @@
+#!/usr/bin/env ktap
+
+function failed() {
+       printf("failed\n");
+       exit(-1);
+}
+
+#-----------------------------------------#
+
+t = {}
+t[1] = 101
+t[2] = 102
+t[3] = 103
+t["key_1"] = "value_1"
+t["key_2"] = "value_2"
+t["key_3"] = "value_3"
+
+local n = 0
+
+for (k, v in pairs(t)) {
+       n = n + 1
+
+       if (k == 1 && v != 101) {
+               failed()
+       }
+       if (k == 2 && v != 102) {
+               failed()
+       }
+       if (k == 3 && v != 103) {
+               failed()
+       }
+       if (k == "key_1" && v != "value_1") {
+               failed()
+       }
+       if (k == "key_2" && v != "value_2") {
+               failed()
+       }
+       if (k == "key_3" && v != "value_3") {
+               failed()
+       }
+}
+
+if (n != len(t)) {
+       failed()
+}
+
+
+#-------------------------------------------------#
+
+s = {}
+s[1] = 12
+s[2] = 2
+s[3] = 3
+s["124"] = 100
+s["125"] = -1
+
+ordered = {}
+
+number = 0
+
+function cmp(v1, v2) {
+       return (v1 > v2)
+}
+
+for (k, v in sort_pairs(s, cmp)) {
+       number += 1
+       ordered[number] = v
+}
+
+if (ordered[1] != 100) {
+       failed()
+}
+if (ordered[2] != 12) {
+       failed()
+}
+if (ordered[3] != 3) {
+       failed()
+}
+if (ordered[4] != 2) {
+       failed()
+}
+if (ordered[5] != -1) {
+       failed()
+}
diff --git a/drivers/staging/ktap/test/ptable.kp b/drivers/staging/ktap/test/ptable.kp
new file mode 100644 (file)
index 0000000..0f394cf
--- /dev/null
@@ -0,0 +1,46 @@
+#!/usr/bin/env ktap
+
+function failed() {
+       printf("failed\n");
+       exit(-1);
+}
+
+#---------------------------------#
+
+s = ptable()
+
+for (i = 1, 100, 1) {
+       s["k"] <<< i
+}
+
+if (count(s["k"]) != 100) {
+       failed()
+}
+if (sum(s["k"]) != 5050) {
+       failed()
+}
+if (max(s["k"]) != 100) {
+       failed()
+}
+if (min(s["k"]) != 1) {
+       failed()
+}
+
+for (i = 1, 10000, 1) {
+       s[i] <<< i
+}
+
+if (min(s[1]) != 1) {
+       failed()
+}
+
+if (sum(s[10]) != 10) {
+       failed()
+}
+
+if (max(s[100]) != 100) {
+       failed()
+}
+
+
+
diff --git a/drivers/staging/ktap/test/run_test.sh b/drivers/staging/ktap/test/run_test.sh
new file mode 100644 (file)
index 0000000..d33105e
--- /dev/null
@@ -0,0 +1,62 @@
+#!/bin/sh
+
+rmmod ktapvm > /dev/null 2>&1
+insmod ../ktapvm.ko
+if test $? -ne 0; then
+       echo "Cannot insmod ../ktapvm.ko"
+       exit -1
+fi
+
+KTAP=../ktap
+ktaprun() {
+       echo "$KTAP $@"
+       $KTAP $@
+}
+
+
+
+#######################################################
+# Use $ktap directly if the arguments contains strings
+$KTAP arg.kp 1 testing "2 3 4"
+$KTAP -e 'print("one-liner testing")'
+$KTAP -e 'exit()'
+$KTAP -o /dev/null -e 'trace syscalls:* { print(argevent) }' \
+               -- ls > /dev/null
+
+$KTAP -o /dev/null -e 'trace syscalls:* { print(argevent) }' \
+               -- $KTAP -e 'print("trace ktap by self")'
+
+ktaprun arithmetic.kp
+ktaprun -o /dev/null stack_overflow.kp
+ktaprun concat.kp
+ktaprun count.kp
+ktaprun fibonacci.kp
+ktaprun function.kp
+ktaprun if.kp
+ktaprun -q kprobe.kp
+ktaprun -q kretprobe.kp
+ktaprun len.kp
+ktaprun looping.kp
+ktaprun pairs.kp
+ktaprun table.kp
+ktaprun ptable.kp
+ktaprun -q timer.kp
+ktaprun -q tracepoint.kp
+ktaprun -o /dev/null zerodivide.kp
+ktaprun -o /dev/null ksym.kp
+
+echo "testing kill deadloop ktap script"
+$KTAP -e 'while (1) {}' &
+sleep 1
+pkill ktap
+sleep 1
+
+cd ffi && make --quiet --no-print-directory test && cd -
+
+#####################################################
+rmmod ktapvm
+if test $? -ne 0; then
+       echo "Error in rmmod ../ktapvm.ko, leak module refcount?"
+       exit -1
+fi
+
diff --git a/drivers/staging/ktap/test/stack_overflow.kp b/drivers/staging/ktap/test/stack_overflow.kp
new file mode 100644 (file)
index 0000000..ce33e62
--- /dev/null
@@ -0,0 +1,9 @@
+#!/usr/bin/env ktap
+
+#this script check overflow in ktap
+
+function f(a) {
+       return 1 + f(a+1)
+}
+
+print(f(0))
diff --git a/drivers/staging/ktap/test/table.kp b/drivers/staging/ktap/test/table.kp
new file mode 100644 (file)
index 0000000..fc96b73
--- /dev/null
@@ -0,0 +1,71 @@
+#!/usr/bin/env ktap
+
+function failed() {
+       printf("failed\n");
+       exit(-1);
+}
+
+### table testing ###
+x = {}
+x[1] = "1"
+if (x[1] != "1") {
+       failed()
+}
+
+x[1] = 22222222222222222222222222222222222222222
+if (x[1] != 22222222222222222222222222222222222222222) {
+       failed()
+}
+
+x[1] = "jovi"
+if (x[1] != "jovi") {
+       failed()
+}
+
+x[11111111111111111111111111111111] = "jovi"
+if (x[11111111111111111111111111111111] != "jovi") {
+       failed()
+}
+
+x["jovi"] = 1
+if (x["jovi"] != 1) {
+       failed()
+}
+
+x["long string....................................."] = 1
+if (x["long string....................................."] != 1) {
+       failed()
+}
+
+# issue: subx must declare firstly, otherwise kernel will oops
+subx = {}
+subx["test"] = "this is test"
+x["test"] = subx
+if (x["test"]["test"] != "this is test") {
+       failed()
+}
+
+tbl = {}
+i = 1
+while (i < 100000) {
+       tbl[i] = i
+       i = i + 1
+}
+
+i = 1
+while (i < 100000) {
+       if (tbl[i] != i) {
+               failed()
+       }
+       i = i + 1
+}
+
+#### table initization
+days = {"Sunday", "Monday", "Tuesday", "Wednesday",
+       "Thursday", "Friday", "Saturday"}
+
+if (days[2] != "Monday") {
+       failed()
+}
+
+
diff --git a/drivers/staging/ktap/test/timer.kp b/drivers/staging/ktap/test/timer.kp
new file mode 100644 (file)
index 0000000..02e8a61
--- /dev/null
@@ -0,0 +1,28 @@
+#!/usr/bin/env ktap
+
+function failed() {
+       printf("failed\n");
+       exit(-1);
+}
+
+#---------------------------------------#
+
+n1 = 0
+n2 = 0
+
+tick-1s {
+       n1 = n1 + 1
+}
+
+tick-1s {
+       n2 = n2 + 1
+}
+
+tick-4s {
+       if (n1 == 0 || n2 == 0) {
+               failed()
+       }
+       exit()
+}
+
+
diff --git a/drivers/staging/ktap/test/tracepoint.kp b/drivers/staging/ktap/test/tracepoint.kp
new file mode 100644 (file)
index 0000000..fb036e6
--- /dev/null
@@ -0,0 +1,22 @@
+#!/usr/bin/env ktap
+
+function failed() {
+       printf("failed\n");
+       exit(-1);
+}
+
+#----------------------------------------#
+
+n = 0
+
+trace sched:* {
+       n = n + 1
+}
+
+tick-1s {
+       if (n == 0) {
+               failed()
+       }
+       exit()
+}
+
diff --git a/drivers/staging/ktap/test/zerodivide.kp b/drivers/staging/ktap/test/zerodivide.kp
new file mode 100644 (file)
index 0000000..abb1eae
--- /dev/null
@@ -0,0 +1,5 @@
+#!/usr/bin/env ktap
+
+a = 1/0
+#should not go here
+printf("Failed\n")
diff --git a/drivers/staging/ktap/userspace/code.c b/drivers/staging/ktap/userspace/code.c
new file mode 100644 (file)
index 0000000..e7317f6
--- /dev/null
@@ -0,0 +1,998 @@
+/*
+ * code.c - Code generator for ktap
+ *
+ * This file is part of ktap by Jovi Zhangwei.
+ *
+ * Copyright (C) 2012-2013 Jovi Zhangwei <jovi.zhangwei@gmail.com>.
+ *
+ * Copyright (C) 1994-2013 Lua.org, PUC-Rio.
+ *  - The part of code in this file is copied from lua initially.
+ *  - lua's MIT license is compatible with GPL.
+ *
+ * ktap 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.
+ *
+ * ktap is distributed in the hope it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
+ * more details.
+ *
+ * You should have received a copy of the GNU General Public License along with
+ * this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include "../include/ktap_types.h"
+#include "../include/ktap_opcodes.h"
+#include "ktapc.h"
+#include "../runtime/kp_obj.h"
+
+
+#define hasjumps(e)    ((e)->t != (e)->f)
+
+void codegen_patchtohere (ktap_funcstate *fs, int list);
+
+static int isnumeral(ktap_expdesc *e)
+{
+       return (e->k == VKNUM && e->t == NO_JUMP && e->f == NO_JUMP);
+}
+
+void codegen_nil(ktap_funcstate *fs, int from, int n)
+{
+       ktap_instruction *previous;
+       int l = from + n - 1;  /* last register to set nil */
+
+       if (fs->pc > fs->lasttarget) {  /* no jumps to current position? */
+               previous = &fs->f->code[fs->pc-1];
+               if (GET_OPCODE(*previous) == OP_LOADNIL) {
+                       int pfrom = GETARG_A(*previous);
+                       int pl = pfrom + GETARG_B(*previous);
+
+                       if ((pfrom <= from && from <= pl + 1) ||
+                               (from <= pfrom && pfrom <= l + 1)) {  /* can connect both? */
+                               if (pfrom < from)
+                                       from = pfrom;  /* from = min(from, pfrom) */
+                               if (pl > l)
+                                       l = pl;  /* l = max(l, pl) */
+                               SETARG_A(*previous, from);
+                               SETARG_B(*previous, l - from);
+                               return;
+                       }
+               }  /* else go through */
+       }
+       codegen_codeABC(fs, OP_LOADNIL, from, n - 1, 0);  /* else no optimization */
+}
+
+int codegen_jump(ktap_funcstate *fs)
+{
+       int jpc = fs->jpc;  /* save list of jumps to here */
+       int j;
+
+       fs->jpc = NO_JUMP;
+       j = codegen_codeAsBx(fs, OP_JMP, 0, NO_JUMP);
+       codegen_concat(fs, &j, jpc);  /* keep them on hold */
+       return j;
+}
+
+void codegen_ret(ktap_funcstate *fs, int first, int nret)
+{
+       codegen_codeABC(fs, OP_RETURN, first, nret+1, 0);
+}
+
+static int condjump(ktap_funcstate *fs, OpCode op, int A, int B, int C)
+{
+       codegen_codeABC(fs, op, A, B, C);
+       return codegen_jump(fs);
+}
+
+static void fixjump(ktap_funcstate *fs, int pc, int dest)
+{
+       ktap_instruction *jmp = &fs->f->code[pc];
+       int offset = dest-(pc+1);
+
+       ktap_assert(dest != NO_JUMP);
+       if (abs(offset) > MAXARG_sBx)
+               lex_syntaxerror(fs->ls, "control structure too long");
+       SETARG_sBx(*jmp, offset);
+}
+
+/*
+ * returns current `pc' and marks it as a jump target (to avoid wrong
+ * optimizations with consecutive instructions not in the same basic block).
+ */
+int codegen_getlabel(ktap_funcstate *fs)
+{
+       fs->lasttarget = fs->pc;
+       return fs->pc;
+}
+
+static int getjump(ktap_funcstate *fs, int pc)
+{
+       int offset = GETARG_sBx(fs->f->code[pc]);
+
+       if (offset == NO_JUMP)  /* point to itself represents end of list */
+               return NO_JUMP;  /* end of list */
+       else
+               return (pc+1)+offset;  /* turn offset into absolute position */
+}
+
+static ktap_instruction *getjumpcontrol(ktap_funcstate *fs, int pc)
+{
+       ktap_instruction *pi = &fs->f->code[pc];
+       if (pc >= 1 && testTMode(GET_OPCODE(*(pi-1))))
+               return pi-1;
+       else
+               return pi;
+}
+
+/*
+ * check whether list has any jump that do not produce a value
+ * (or produce an inverted value)
+ */
+static int need_value(ktap_funcstate *fs, int list)
+{
+       for (; list != NO_JUMP; list = getjump(fs, list)) {
+               ktap_instruction i = *getjumpcontrol(fs, list);
+               if (GET_OPCODE(i) != OP_TESTSET)
+                       return 1;
+       }
+       return 0;  /* not found */
+}
+
+static int patchtestreg(ktap_funcstate *fs, int node, int reg)
+{
+       ktap_instruction *i = getjumpcontrol(fs, node);
+       if (GET_OPCODE(*i) != OP_TESTSET)
+               return 0;  /* cannot patch other instructions */
+       if (reg != NO_REG && reg != GETARG_B(*i))
+               SETARG_A(*i, reg);
+       else  /* no register to put value or register already has the value */
+               *i = CREATE_ABC(OP_TEST, GETARG_B(*i), 0, GETARG_C(*i));
+
+       return 1;
+}
+
+static void removevalues(ktap_funcstate *fs, int list)
+{
+       for (; list != NO_JUMP; list = getjump(fs, list))
+               patchtestreg(fs, list, NO_REG);
+}
+
+static void patchlistaux(ktap_funcstate *fs, int list, int vtarget, int reg,
+                        int dtarget)
+{
+       while (list != NO_JUMP) {
+               int next = getjump(fs, list);
+               if (patchtestreg(fs, list, reg))
+                       fixjump(fs, list, vtarget);
+               else
+                       fixjump(fs, list, dtarget);  /* jump to default target */
+               list = next;
+       }
+}
+
+static void dischargejpc(ktap_funcstate *fs)
+{
+       patchlistaux(fs, fs->jpc, fs->pc, NO_REG, fs->pc);
+       fs->jpc = NO_JUMP;
+}
+
+void codegen_patchlist(ktap_funcstate *fs, int list, int target)
+{
+       if (target == fs->pc)
+               codegen_patchtohere(fs, list);
+       else {
+               ktap_assert(target < fs->pc);
+               patchlistaux(fs, list, target, NO_REG, target);
+       }
+}
+
+void codegen_patchclose(ktap_funcstate *fs, int list, int level)
+{
+       level++;  /* argument is +1 to reserve 0 as non-op */
+       while (list != NO_JUMP) {
+               int next = getjump(fs, list);
+               ktap_assert(GET_OPCODE(fs->f->code[list]) == OP_JMP &&
+                          (GETARG_A(fs->f->code[list]) == 0 ||
+                           GETARG_A(fs->f->code[list]) >= level));
+               SETARG_A(fs->f->code[list], level);
+               list = next;
+       }
+}
+
+void codegen_patchtohere(ktap_funcstate *fs, int list)
+{
+       codegen_getlabel(fs);
+       codegen_concat(fs, &fs->jpc, list);
+}
+
+void codegen_concat(ktap_funcstate *fs, int *l1, int l2)
+{
+       if (l2 == NO_JUMP)
+               return;
+       else if (*l1 == NO_JUMP)
+               *l1 = l2;
+       else {
+               int list = *l1;
+               int next;
+               while ((next = getjump(fs, list)) != NO_JUMP)  /* find last element */
+                       list = next;
+               fixjump(fs, list, l2);
+       }
+}
+
+static int codegen_code(ktap_funcstate *fs, ktap_instruction i)
+{
+       ktap_proto *f = fs->f;
+
+       dischargejpc(fs);  /* `pc' will change */
+
+       /* put new instruction in code array */
+       ktapc_growvector(f->code, fs->pc, f->sizecode, ktap_instruction,
+                        MAX_INT, "opcodes");
+       f->code[fs->pc] = i;
+
+       /* save corresponding line information */
+       ktapc_growvector(f->lineinfo, fs->pc, f->sizelineinfo, int,
+                        MAX_INT, "opcodes");
+       f->lineinfo[fs->pc] = fs->ls->lastline;
+       return fs->pc++;
+}
+
+int codegen_codeABC(ktap_funcstate *fs, OpCode o, int a, int b, int c)
+{
+       ktap_assert(getOpMode(o) == iABC);
+       //ktap_assert(getBMode(o) != OpArgN || b == 0);
+       //ktap_assert(getCMode(o) != OpArgN || c == 0);
+       //ktap_assert(a <= MAXARG_A && b <= MAXARG_B && c <= MAXARG_C);
+       return codegen_code(fs, CREATE_ABC(o, a, b, c));
+}
+
+int codegen_codeABx(ktap_funcstate *fs, OpCode o, int a, unsigned int bc)
+{
+       ktap_assert(getOpMode(o) == iABx || getOpMode(o) == iAsBx);
+       ktap_assert(getCMode(o) == OpArgN);
+       ktap_assert(a <= MAXARG_A && bc <= MAXARG_Bx);
+       return codegen_code(fs, CREATE_ABx(o, a, bc));
+}
+
+static int codeextraarg(ktap_funcstate *fs, int a)
+{
+       ktap_assert(a <= MAXARG_Ax);
+       return codegen_code(fs, CREATE_Ax(OP_EXTRAARG, a));
+}
+
+int codegen_codek(ktap_funcstate *fs, int reg, int k)
+{
+       if (k <= MAXARG_Bx)
+               return codegen_codeABx(fs, OP_LOADK, reg, k);
+       else {
+               int p = codegen_codeABx(fs, OP_LOADKX, reg, 0);
+               codeextraarg(fs, k);
+               return p;
+       }
+}
+
+void codegen_checkstack(ktap_funcstate *fs, int n)
+{
+       int newstack = fs->freereg + n;
+
+       if (newstack > fs->f->maxstacksize) {
+               if (newstack >= MAXSTACK)
+                       lex_syntaxerror(fs->ls, "function or expression too complex");
+               fs->f->maxstacksize = (u8)(newstack);
+       }
+}
+
+void codegen_reserveregs(ktap_funcstate *fs, int n)
+{
+       codegen_checkstack(fs, n);
+       fs->freereg += n;
+}
+
+static void freereg(ktap_funcstate *fs, int reg)
+{
+       if (!ISK(reg) && reg >= fs->nactvar) {
+               fs->freereg--;
+               ktap_assert(reg == fs->freereg);
+       }
+}
+
+static void freeexp(ktap_funcstate *fs, ktap_expdesc *e)
+{
+       if (e->k == VNONRELOC)
+               freereg(fs, e->u.info);
+}
+
+static int addk(ktap_funcstate *fs, ktap_value *key, ktap_value *v)
+{
+       const ktap_value *idx = ktapc_table_get(fs->h, key);
+       ktap_proto *f = fs->f;
+       ktap_value kn;
+       int k, oldsize;
+
+       if (is_number(idx)) {
+               ktap_number n = nvalue(idx);
+               kp_number2int(k, n);
+               if (ktapc_equalobj(&f->k[k], v))
+                       return k;
+               /* else may be a collision (e.g., between 0.0 and "\0\0\0\0\0\0\0\0");
+                       go through and create a new entry for this value */
+       }
+       /* constant not found; create a new entry */
+       oldsize = f->sizek;
+       k = fs->nk;
+
+       /* numerical value does not need GC barrier;
+          table has no metatable, so it does not need to invalidate cache */
+       set_number(&kn, (ktap_number)k);
+       ktapc_table_setvalue(fs->h, key, &kn);
+       ktapc_growvector(f->k, k, f->sizek, ktap_value, MAXARG_Ax, "constants");
+       while (oldsize < f->sizek)
+               set_nil(&f->k[oldsize++]);
+       set_obj(&f->k[k], v);
+       fs->nk++;
+       return k;
+}
+
+int codegen_stringK(ktap_funcstate *fs, ktap_string *s)
+{
+       ktap_value o;
+
+       set_string(&o, s);
+       return addk(fs, &o, &o);
+}
+
+int codegen_numberK(ktap_funcstate *fs, ktap_number r)
+{
+       int n;
+       ktap_value o, s;
+
+       set_number(&o, r);
+       if (r == 0 || ktap_numisnan(NULL, r)) {  /* handle -0 and NaN */
+               /* use raw representation as key to avoid numeric problems */
+               set_string(&s, ktapc_ts_newlstr((char *)&r, sizeof(r)));
+               //   incr_top(L);
+               n = addk(fs, &s, &o);
+               //   L->top--;
+       } else
+               n = addk(fs, &o, &o);  /* regular case */
+       return n;
+}
+
+static int boolK(ktap_funcstate *fs, int b)
+{
+       ktap_value o;
+       set_boolean(&o, b);
+       return addk(fs, &o, &o);
+}
+
+static int nilK(ktap_funcstate *fs)
+{
+       ktap_value k, v;
+       set_nil(&v);
+       /* cannot use nil as key; instead use table itself to represent nil */
+       set_table(&k, fs->h);
+       return addk(fs, &k, &v);
+}
+
+void codegen_setreturns(ktap_funcstate *fs, ktap_expdesc *e, int nresults)
+{
+       if (e->k == VCALL) {  /* expression is an open function call? */
+               SETARG_C(getcode(fs, e), nresults+1);
+       }
+       else if (e->k == VVARARG) {
+               SETARG_B(getcode(fs, e), nresults+1);
+               SETARG_A(getcode(fs, e), fs->freereg);
+               codegen_reserveregs(fs, 1);
+       }
+}
+
+void codegen_setoneret(ktap_funcstate *fs, ktap_expdesc *e)
+{
+       if (e->k == VCALL) {  /* expression is an open function call? */
+               e->k = VNONRELOC;
+               e->u.info = GETARG_A(getcode(fs, e));
+       } else if (e->k == VVARARG) {
+               SETARG_B(getcode(fs, e), 2);
+               e->k = VRELOCABLE;  /* can relocate its simple result */
+       }
+}
+
+void codegen_dischargevars(ktap_funcstate *fs, ktap_expdesc *e)
+{
+       switch (e->k) {
+       case VLOCAL: {
+               e->k = VNONRELOC;
+               break;
+       }
+       case VUPVAL: {
+               e->u.info = codegen_codeABC(fs, OP_GETUPVAL, 0, e->u.info, 0);
+               e->k = VRELOCABLE;
+               break;
+       }
+       case VINDEXED: {
+               OpCode op = OP_GETTABUP;  /* assume 't' is in an upvalue */
+               freereg(fs, e->u.ind.idx);
+               if (e->u.ind.vt == VLOCAL) {  /* 't' is in a register? */
+                       freereg(fs, e->u.ind.t);
+                       op = OP_GETTABLE;
+               }
+               e->u.info = codegen_codeABC(fs, op, 0, e->u.ind.t, e->u.ind.idx);
+               e->k = VRELOCABLE;
+               break;
+       }
+       case VVARARG:
+       case VCALL: {
+               codegen_setoneret(fs, e);
+               break;
+       }
+       default:
+               break;  /* there is one value available (somewhere) */
+       }
+}
+
+static int code_label(ktap_funcstate *fs, int A, int b, int jump)
+{
+       codegen_getlabel(fs);  /* those instructions may be jump targets */
+       return codegen_codeABC(fs, OP_LOADBOOL, A, b, jump);
+}
+
+static void discharge2reg(ktap_funcstate *fs, ktap_expdesc *e, int reg)
+{
+       codegen_dischargevars(fs, e);
+       switch (e->k) {
+       case VNIL: {
+               codegen_nil(fs, reg, 1);
+               break;
+       }
+       case VFALSE:  case VTRUE: {
+               codegen_codeABC(fs, OP_LOADBOOL, reg, e->k == VTRUE, 0);
+               break;
+       }
+       case VEVENT:
+               codegen_codeABC(fs, OP_EVENT, reg, 0, 0);
+               break;
+       case VEVENTNAME:
+               codegen_codeABC(fs, OP_EVENTNAME, reg, 0, 0);
+               break;
+       case VEVENTARG:
+               codegen_codeABC(fs, OP_EVENTARG, reg, e->u.info, 0);
+               break;
+       case VK: {
+               codegen_codek(fs, reg, e->u.info);
+               break;
+       }
+       case VKNUM: {
+               codegen_codek(fs, reg, codegen_numberK(fs, e->u.nval));
+               break;
+       }
+       case VRELOCABLE: {
+               ktap_instruction *pc = &getcode(fs, e);
+               SETARG_A(*pc, reg);
+               break;
+       }
+       case VNONRELOC: {
+               if (reg != e->u.info)
+                       codegen_codeABC(fs, OP_MOVE, reg, e->u.info, 0);
+               break;
+       }
+       default:
+               ktap_assert(e->k == VVOID || e->k == VJMP);
+               return;  /* nothing to do... */
+       }
+
+       e->u.info = reg;
+       e->k = VNONRELOC;
+}
+
+static void discharge2anyreg(ktap_funcstate *fs, ktap_expdesc *e)
+{
+       if (e->k != VNONRELOC) {
+               codegen_reserveregs(fs, 1);
+               discharge2reg(fs, e, fs->freereg-1);
+       }
+}
+
+static void exp2reg(ktap_funcstate *fs, ktap_expdesc *e, int reg)
+{
+       discharge2reg(fs, e, reg);
+       if (e->k == VJMP)
+               codegen_concat(fs, &e->t, e->u.info);  /* put this jump in `t' list */
+       if (hasjumps(e)) {
+               int final;  /* position after whole expression */
+               int p_f = NO_JUMP;  /* position of an eventual LOAD false */
+               int p_t = NO_JUMP;  /* position of an eventual LOAD true */
+
+               if (need_value(fs, e->t) || need_value(fs, e->f)) {
+                       int fj = (e->k == VJMP) ? NO_JUMP : codegen_jump(fs);
+
+                       p_f = code_label(fs, reg, 0, 1);
+                       p_t = code_label(fs, reg, 1, 0);
+                       codegen_patchtohere(fs, fj);
+               }
+               final = codegen_getlabel(fs);
+               patchlistaux(fs, e->f, final, reg, p_f);
+               patchlistaux(fs, e->t, final, reg, p_t);
+       }
+       e->f = e->t = NO_JUMP;
+       e->u.info = reg;
+       e->k = VNONRELOC;
+}
+
+void codegen_exp2nextreg(ktap_funcstate *fs, ktap_expdesc *e)
+{
+       codegen_dischargevars(fs, e);
+       freeexp(fs, e);
+       codegen_reserveregs(fs, 1);
+       exp2reg(fs, e, fs->freereg - 1);
+}
+
+int codegen_exp2anyreg(ktap_funcstate *fs, ktap_expdesc *e)
+{
+       codegen_dischargevars(fs, e);
+       if (e->k == VNONRELOC) {
+               if (!hasjumps(e))
+                       return e->u.info;  /* exp is already in a register */
+               if (e->u.info >= fs->nactvar) {  /* reg. is not a local? */
+                       exp2reg(fs, e, e->u.info);  /* put value on it */
+                       return e->u.info;
+               }
+       }
+       codegen_exp2nextreg(fs, e);  /* default */
+       return e->u.info;
+}
+
+void codegen_exp2anyregup(ktap_funcstate *fs, ktap_expdesc *e)
+{
+       if (e->k != VUPVAL || hasjumps(e))
+               codegen_exp2anyreg(fs, e);
+}
+
+void codegen_exp2val(ktap_funcstate *fs, ktap_expdesc *e)
+{
+       if (hasjumps(e))
+               codegen_exp2anyreg(fs, e);
+       else
+               codegen_dischargevars(fs, e);
+}
+
+int codegen_exp2RK(ktap_funcstate *fs, ktap_expdesc *e)
+{
+       codegen_exp2val(fs, e);
+       switch (e->k) {
+       case VTRUE:
+       case VFALSE:
+       case VNIL: {
+               if (fs->nk <= MAXINDEXRK) {  /* constant fits in RK operand? */
+                       e->u.info = (e->k == VNIL) ? nilK(fs) :
+                                                    boolK(fs, (e->k == VTRUE));
+                       e->k = VK;
+                       return RKASK(e->u.info);
+               }
+               else
+                       break;
+       }
+       case VKNUM: {
+               e->u.info = codegen_numberK(fs, e->u.nval);
+               e->k = VK;
+               /* go through */
+       }
+       case VK: {
+               if (e->u.info <= MAXINDEXRK)  /* constant fits in argC? */
+                       return RKASK(e->u.info);
+               else
+                       break;
+       }
+       default:
+               break;
+       }
+       /* not a constant in the right range: put it in a register */
+       return codegen_exp2anyreg(fs, e);
+}
+
+void codegen_storevar(ktap_funcstate *fs, ktap_expdesc *var, ktap_expdesc *ex)
+{
+       switch (var->k) {
+       case VLOCAL: {
+               freeexp(fs, ex);
+               exp2reg(fs, ex, var->u.info);
+               return;
+       }
+       case VUPVAL: {
+               int e = codegen_exp2anyreg(fs, ex);
+               codegen_codeABC(fs, OP_SETUPVAL, e, var->u.info, 0);
+               break;
+       }
+       case VINDEXED: {
+               OpCode op = (var->u.ind.vt == VLOCAL) ? OP_SETTABLE : OP_SETTABUP;
+               int e = codegen_exp2RK(fs, ex);
+               codegen_codeABC(fs, op, var->u.ind.t, var->u.ind.idx, e);
+               break;
+       }
+       default:
+               ktap_assert(0);  /* invalid var kind to store */
+               break;
+       }
+
+       freeexp(fs, ex);
+}
+
+void codegen_storeincr(ktap_funcstate *fs, ktap_expdesc *var, ktap_expdesc *ex)
+{
+       switch (var->k) {
+#if 0 /*current not supported */
+       case VLOCAL: {
+               freeexp(fs, ex);
+               exp2reg(fs, ex, var->u.info);
+               return;
+       }
+       case VUPVAL: {
+               int e = codegen_exp2anyreg(fs, ex);
+               codegen_codeABC(fs, OP_SETUPVAL, e, var->u.info, 0);
+               break;
+       }
+#endif
+       case VINDEXED: {
+               OpCode op = (var->u.ind.vt == VLOCAL) ? OP_SETTABLE_INCR :
+                               OP_SETTABUP_INCR;
+               int e = codegen_exp2RK(fs, ex);
+               codegen_codeABC(fs, op, var->u.ind.t, var->u.ind.idx, e);
+               break;
+       }
+       default:
+               ktap_assert(0);  /* invalid var kind to store */
+               break;
+       }
+
+       freeexp(fs, ex);
+}
+
+void codegen_store_aggr(ktap_funcstate *fs, ktap_expdesc *var, ktap_expdesc *ex)
+{
+       switch (var->k) {
+#if 0 /*current not supported */
+       case VLOCAL: {
+               freeexp(fs, ex);
+               exp2reg(fs, ex, var->u.info);
+               return;
+       }
+       case VUPVAL: {
+               int e = codegen_exp2anyreg(fs, ex);
+               codegen_codeABC(fs, OP_SETUPVAL, e, var->u.info, 0);
+               break;
+       }
+#endif
+       case VINDEXED: {
+               OpCode op = (var->u.ind.vt == VLOCAL) ? OP_SETTABLE_AGGR :
+                               OP_SETTABUP_AGGR;
+               int e = codegen_exp2RK(fs, ex);
+               codegen_codeABC(fs, op, var->u.ind.t, var->u.ind.idx, e);
+               break;
+       }
+       default:
+               ktap_assert(0);  /* invalid var kind to store */
+               break;
+       }
+
+       freeexp(fs, ex);
+}
+
+void codegen_self(ktap_funcstate *fs, ktap_expdesc *e, ktap_expdesc *key)
+{
+       int ereg;
+
+       codegen_exp2anyreg(fs, e);
+       ereg = e->u.info;  /* register where 'e' was placed */
+       freeexp(fs, e);
+       e->u.info = fs->freereg;  /* base register for op_self */
+       e->k = VNONRELOC;
+       codegen_reserveregs(fs, 2);  /* function and 'self' produced by op_self */
+       codegen_codeABC(fs, OP_SELF, e->u.info, ereg, codegen_exp2RK(fs, key));
+       freeexp(fs, key);
+}
+
+static void invertjump(ktap_funcstate *fs, ktap_expdesc *e)
+{
+       ktap_instruction *pc = getjumpcontrol(fs, e->u.info);
+       ktap_assert(testTMode(GET_OPCODE(*pc)) && GET_OPCODE(*pc) != OP_TESTSET &&
+                       GET_OPCODE(*pc) != OP_TEST);
+       SETARG_A(*pc, !(GETARG_A(*pc)));
+}
+
+static int jumponcond(ktap_funcstate *fs, ktap_expdesc *e, int cond)
+{
+       if (e->k == VRELOCABLE) {
+               ktap_instruction ie = getcode(fs, e);
+               if (GET_OPCODE(ie) == OP_NOT) {
+                       fs->pc--;  /* remove previous OP_NOT */
+                       return condjump(fs, OP_TEST, GETARG_B(ie), 0, !cond);
+               }
+               /* else go through */
+       }
+       discharge2anyreg(fs, e);
+       freeexp(fs, e);
+       return condjump(fs, OP_TESTSET, NO_REG, e->u.info, cond);
+}
+
+void codegen_goiftrue(ktap_funcstate *fs, ktap_expdesc *e)
+{
+       int pc;  /* pc of last jump */
+
+       codegen_dischargevars(fs, e);
+       switch (e->k) {
+       case VJMP: {
+               invertjump(fs, e);
+               pc = e->u.info;
+               break;
+       }
+       case VK: case VKNUM: case VTRUE: {
+               pc = NO_JUMP;  /* always true; do nothing */
+               break;
+       }
+       default:
+               pc = jumponcond(fs, e, 0);
+               break;
+       }
+
+       codegen_concat(fs, &e->f, pc);  /* insert last jump in `f' list */
+       codegen_patchtohere(fs, e->t);
+       e->t = NO_JUMP;
+}
+
+void codegen_goiffalse(ktap_funcstate *fs, ktap_expdesc *e)
+{
+       int pc;  /* pc of last jump */
+       codegen_dischargevars(fs, e);
+
+       switch (e->k) {
+       case VJMP: {
+               pc = e->u.info;
+               break;
+       }
+       case VNIL: case VFALSE: {
+               pc = NO_JUMP;  /* always false; do nothing */
+               break;
+       }
+       default:
+               pc = jumponcond(fs, e, 1);
+               break;
+       }
+       codegen_concat(fs, &e->t, pc);  /* insert last jump in `t' list */
+       codegen_patchtohere(fs, e->f);
+       e->f = NO_JUMP;
+}
+
+static void codenot(ktap_funcstate *fs, ktap_expdesc *e)
+{
+       codegen_dischargevars(fs, e);
+       switch (e->k) {
+       case VNIL: case VFALSE: {
+               e->k = VTRUE;
+               break;
+       }
+       case VK: case VKNUM: case VTRUE: {
+               e->k = VFALSE;
+               break;
+       }
+       case VJMP: {
+               invertjump(fs, e);
+               break;
+       }
+       case VRELOCABLE:
+       case VNONRELOC: {
+               discharge2anyreg(fs, e);
+               freeexp(fs, e);
+               e->u.info = codegen_codeABC(fs, OP_NOT, 0, e->u.info, 0);
+               e->k = VRELOCABLE;
+               break;
+       }
+       default:
+               ktap_assert(0);  /* cannot happen */
+               break;
+       }
+
+       /* interchange true and false lists */
+       { int temp = e->f; e->f = e->t; e->t = temp; }
+       removevalues(fs, e->f);
+       removevalues(fs, e->t);
+}
+
+void codegen_indexed(ktap_funcstate *fs, ktap_expdesc *t, ktap_expdesc *k)
+{
+       ktap_assert(!hasjumps(t));
+       t->u.ind.t = t->u.info;
+       t->u.ind.idx = codegen_exp2RK(fs, k);
+       t->u.ind.vt = (t->k == VUPVAL) ? VUPVAL
+                       : check_exp(vkisinreg(t->k), VLOCAL);
+       t->k = VINDEXED;
+}
+
+static int constfolding(OpCode op, ktap_expdesc *e1, ktap_expdesc *e2)
+{
+       ktap_number r;
+
+       if (!isnumeral(e1) || !isnumeral(e2))
+               return 0;
+
+       if ((op == OP_DIV || op == OP_MOD) && e2->u.nval == 0)
+               return 0;  /* do not attempt to divide by 0 */
+
+       if (op == OP_POW)
+               return 0; /* ktap current do not suppor pow arith */
+
+       r = ktapc_arith(op - OP_ADD + KTAP_OPADD, e1->u.nval, e2->u.nval);
+       e1->u.nval = r;
+       return 1;
+}
+
+static void codearith(ktap_funcstate *fs, OpCode op,
+                     ktap_expdesc *e1, ktap_expdesc *e2, int line)
+{
+       if (constfolding(op, e1, e2))
+               return;
+       else {
+               int o2 = (op != OP_UNM && op != OP_LEN) ? codegen_exp2RK(fs, e2) : 0;
+               int o1 = codegen_exp2RK(fs, e1);
+
+               if (o1 > o2) {
+                       freeexp(fs, e1);
+                       freeexp(fs, e2);
+               } else {
+                       freeexp(fs, e2);
+                       freeexp(fs, e1);
+               }
+               e1->u.info = codegen_codeABC(fs, op, 0, o1, o2);
+               e1->k = VRELOCABLE;
+               codegen_fixline(fs, line);
+       }
+}
+
+static void codecomp(ktap_funcstate *fs, OpCode op, int cond, ktap_expdesc *e1,
+                    ktap_expdesc *e2)
+{
+       int o1 = codegen_exp2RK(fs, e1);
+       int o2 = codegen_exp2RK(fs, e2);
+
+       freeexp(fs, e2);
+       freeexp(fs, e1);
+       if (cond == 0 && op != OP_EQ) {
+               int temp;  /* exchange args to replace by `<' or `<=' */
+               temp = o1; o1 = o2; o2 = temp;  /* o1 <==> o2 */
+               cond = 1;
+       }
+       e1->u.info = condjump(fs, op, cond, o1, o2);
+       e1->k = VJMP;
+}
+
+void codegen_prefix(ktap_funcstate *fs, UnOpr op, ktap_expdesc *e, int line)
+{
+       ktap_expdesc e2;
+
+       e2.t = e2.f = NO_JUMP;
+       e2.k = VKNUM;
+       e2.u.nval = 0;
+
+       switch (op) {
+       case OPR_MINUS: {
+               if (isnumeral(e))  /* minus constant? */
+                       e->u.nval = ktap_numunm(e->u.nval);  /* fold it */
+               else {
+                       codegen_exp2anyreg(fs, e);
+                       codearith(fs, OP_UNM, e, &e2, line);
+               }
+               break;
+       }
+       case OPR_NOT:
+               codenot(fs, e);
+               break;
+       case OPR_LEN: {
+               codegen_exp2anyreg(fs, e);  /* cannot operate on constants */
+               codearith(fs, OP_LEN, e, &e2, line);
+               break;
+       }
+       default:
+               ktap_assert(0);
+       }
+}
+
+void codegen_infix(ktap_funcstate *fs, BinOpr op, ktap_expdesc *v)
+{
+       switch (op) {
+       case OPR_AND: {
+               codegen_goiftrue(fs, v);
+               break;
+       }
+       case OPR_OR: {
+               codegen_goiffalse(fs, v);
+               break;
+       }
+       case OPR_CONCAT: {
+               codegen_exp2nextreg(fs, v);  /* operand must be on the `stack' */
+               break;
+       }
+       case OPR_ADD: case OPR_SUB: case OPR_MUL: case OPR_DIV:
+       case OPR_MOD: case OPR_POW: {
+               if (!isnumeral(v)) codegen_exp2RK(fs, v);
+                       break;
+       }
+       default:
+               codegen_exp2RK(fs, v);
+               break;
+       }
+}
+
+void codegen_posfix(ktap_funcstate *fs, BinOpr op, ktap_expdesc *e1, ktap_expdesc *e2, int line)
+{
+       switch (op) {
+       case OPR_AND: {
+               ktap_assert(e1->t == NO_JUMP);  /* list must be closed */
+               codegen_dischargevars(fs, e2);
+               codegen_concat(fs, &e2->f, e1->f);
+               *e1 = *e2;
+               break;
+       }
+       case OPR_OR: {
+               ktap_assert(e1->f == NO_JUMP);  /* list must be closed */
+               codegen_dischargevars(fs, e2);
+               codegen_concat(fs, &e2->t, e1->t);
+               *e1 = *e2;
+               break;
+       }
+       case OPR_CONCAT: {
+               codegen_exp2val(fs, e2);
+               if (e2->k == VRELOCABLE && GET_OPCODE(getcode(fs, e2)) == OP_CONCAT) {
+                       ktap_assert(e1->u.info == GETARG_B(getcode(fs, e2))-1);
+                       freeexp(fs, e1);
+                       SETARG_B(getcode(fs, e2), e1->u.info);
+                       e1->k = VRELOCABLE; e1->u.info = e2->u.info;
+               } else {
+                       codegen_exp2nextreg(fs, e2);  /* operand must be on the 'stack' */
+                       codearith(fs, OP_CONCAT, e1, e2, line);
+               }
+               break;
+       }
+       case OPR_ADD: case OPR_SUB: case OPR_MUL: case OPR_DIV:
+       case OPR_MOD: case OPR_POW: {
+               codearith(fs, (OpCode)(op - OPR_ADD + OP_ADD), e1, e2, line);
+               break;
+       }
+       case OPR_EQ: case OPR_LT: case OPR_LE: {
+               codecomp(fs, (OpCode)(op - OPR_EQ + OP_EQ), 1, e1, e2);
+               break;
+       }
+       case OPR_NE: case OPR_GT: case OPR_GE: {
+               codecomp(fs, (OpCode)(op - OPR_NE + OP_EQ), 0, e1, e2);
+               break;
+       }
+       default:
+               ktap_assert(0);
+       }
+}
+
+void codegen_fixline(ktap_funcstate *fs, int line)
+{
+       fs->f->lineinfo[fs->pc - 1] = line;
+}
+
+void codegen_setlist(ktap_funcstate *fs, int base, int nelems, int tostore)
+{
+       int c =  (nelems - 1)/LFIELDS_PER_FLUSH + 1;
+       int b = (tostore == KTAP_MULTRET) ? 0 : tostore;
+
+       ktap_assert(tostore != 0);
+       if (c <= MAXARG_C)
+               codegen_codeABC(fs, OP_SETLIST, base, b, c);
+       else if (c <= MAXARG_Ax) {
+               codegen_codeABC(fs, OP_SETLIST, base, b, 0);
+               codeextraarg(fs, c);
+       } else
+               lex_syntaxerror(fs->ls, "constructor too long");
+       fs->freereg = base + 1;  /* free registers with list values */
+}
+
diff --git a/drivers/staging/ktap/userspace/cparser.h b/drivers/staging/ktap/userspace/cparser.h
new file mode 100644 (file)
index 0000000..f2a9004
--- /dev/null
@@ -0,0 +1,202 @@
+#ifndef __KTAP_CPARSER_H__
+#define __KTAP_CPARSER_H__
+
+/*
+ * Copyright (c) 2011 James R. McKaskill
+ *
+ * This software is licensed under the stock MIT license:
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
+ *
+ * ----------------------------------------------------------------------------
+ */
+
+/*
+ * Adapted from luaffi commit: abc638c9341025580099dcf77795c4b320ba0e63
+ *
+ * Copyright (c) 2013 Yicheng Qin, Qingping Hou
+ */
+
+#ifdef CONFIG_KTAP_FFI
+
+#include <assert.h>
+#include <stdlib.h>
+#include <stdio.h>
+#include <stdint.h>
+#include <string.h>
+#include <stdbool.h>
+
+#include "../include/ktap_ffi.h"
+
+#define PTR_ALIGN_MASK (sizeof(void*) - 1)
+#define FUNCTION_ALIGN_MASK (sizeof(void (*)()) - 1)
+#define DEFAULT_ALIGN_MASK 7
+
+struct parser {
+       int line;
+       const char *next;
+       const char *prev;
+       unsigned align_mask;
+};
+
+enum {
+       C_CALL,
+       STD_CALL,
+       FAST_CALL,
+};
+
+
+#define MAX_TYPE_NAME_LEN CSYM_NAME_MAX_LEN
+
+enum {
+       /* 0 - 4 */
+       INVALID_TYPE,
+       VOID_TYPE,
+       BOOL_TYPE,
+       INT8_TYPE,
+       INT16_TYPE,
+       /* 5 - 9 */
+       INT32_TYPE,
+       INT64_TYPE,
+       INTPTR_TYPE,
+       ENUM_TYPE,
+       UNION_TYPE,
+       /* 10 - 12 */
+       STRUCT_TYPE,
+       FUNCTION_TYPE,
+       FUNCTION_PTR_TYPE,
+};
+
+
+#define IS_CHAR_UNSIGNED (((char) -1) > 0)
+
+#define POINTER_BITS 2
+#define POINTER_MAX ((1 << POINTER_BITS) - 1)
+
+#define ALIGNOF(S) ((int) ((char*) &S.v - (char*) &S - 1))
+
+
+/* Note: if adding a new member that is associated with a struct/union
+ * definition then it needs to be copied over in ctype.c:set_defined for when
+ * we create types based off of the declaration alone.
+ *
+ * Since this is used as a header for every ctype and cdata, and we create a
+ * ton of them on the stack, we try and minimise its size.
+ */
+struct cp_ctype {
+       size_t base_size; /* size of the base type in bytes */
+       int ffi_cs_id; /* index for csymbol from ktap vm */
+       union {
+               /* valid if is_bitfield */
+               struct {
+                       /* size of bitfield in bits */
+                       unsigned bit_size : 7;
+                       /* offset within the current byte between 0-63 */
+                       unsigned bit_offset : 6;
+               };
+               /* Valid if is_array */
+               size_t array_size;
+               /* Valid for is_variable_struct or is_variable_array. If
+                * variable_size_known (only used for is_variable_struct)
+                * then this is the total increment otherwise this is the
+                * per element increment.
+                */
+               size_t variable_increment;
+       };
+       size_t offset;
+       /* as (align bytes - 1) eg 7 gives 8 byte alignment */
+       unsigned align_mask : 4;
+       /* number of dereferences to get to the base type
+        * including +1 for arrays */
+       unsigned pointers : POINTER_BITS;
+       /* const pointer mask, LSB is current pointer, +1 for the whether
+        * the base type is const */
+       unsigned const_mask : POINTER_MAX + 1;
+       unsigned type : 5; /* value given by type enum above */
+       unsigned is_reference : 1;
+       unsigned is_array : 1;
+       unsigned is_defined : 1;
+       unsigned is_null : 1;
+       unsigned has_member_name : 1;
+       unsigned calling_convention : 2;
+       unsigned has_var_arg : 1;
+       /* set for variable array types where we don't know
+        * the variable size yet */
+       unsigned is_variable_array : 1;
+       unsigned is_variable_struct : 1;
+       /* used for variable structs after we know the variable size */
+       unsigned variable_size_known : 1;
+       unsigned is_bitfield : 1;
+       unsigned has_bitfield : 1;
+       unsigned is_jitted : 1;
+       unsigned is_packed : 1;
+       unsigned is_unsigned : 1;
+};
+
+#define ALIGNED_DEFAULT (__alignof__(void* __attribute__((aligned))) - 1)
+
+csymbol *cp_id_to_csym(int id);
+#define ct_ffi_cs(ct) (cp_id_to_csym((ct)->ffi_cs_id))
+
+size_t ctype_size(const struct cp_ctype* ct);
+int cp_ctype_init();
+int cp_ctype_free();
+struct cp_ctype *ctype_lookup_type(char *name);
+void cp_ctype_dump_stack();
+void cp_error(const char *err_msg_fmt, ...);
+struct cp_ctype *cp_ctype_reg_type(char *name, struct cp_ctype *ct);
+
+void cp_push_ctype_with_name(struct cp_ctype *ct, const char *name, int nlen);
+void cp_push_ctype(struct cp_ctype *ct);
+void cp_set_defined(struct cp_ctype *ct);
+
+int cp_symbol_build_func(struct cp_ctype *type,
+               const char *fname, int fn_size);
+int cp_symbol_build_struct(const char *stname);
+int cp_symbol_build_pointer(struct cp_ctype *ct);
+
+int ffi_cdef(const char *s);
+void ffi_cparser_init(void);
+void ffi_cparser_free(void);
+
+
+static inline csymbol *cp_csymf_ret(csymbol_func *csf)
+{
+       return cp_id_to_csym(csf->ret_id);
+}
+
+static inline csymbol *cp_csymf_arg(csymbol_func *csf, int idx)
+{
+       return cp_id_to_csym(csf->arg_ids[idx]);
+}
+
+
+#else
+static void __maybe_unused ffi_cparser_init(void)
+{
+       return;
+}
+static void __maybe_unused ffi_cparser_free(void)
+{
+       return;
+}
+#endif /* CONFIG_KTAP_FFI */
+
+
+#endif /* __KTAP_CPARSER_H__ */
diff --git a/drivers/staging/ktap/userspace/dump.c b/drivers/staging/ktap/userspace/dump.c
new file mode 100644 (file)
index 0000000..eb0acc1
--- /dev/null
@@ -0,0 +1,251 @@
+/*
+ * dump.c - save precompiled ktap chunks
+ *
+ * This file is part of ktap by Jovi Zhangwei.
+ *
+ * Copyright (C) 2012-2013 Jovi Zhangwei <jovi.zhangwei@gmail.com>.
+ *
+ * Copyright (C) 1994-2013 Lua.org, PUC-Rio.
+ *  - The part of code in this file is copied from lua initially.
+ *  - lua's MIT license is compatible with GPL.
+ *
+ * ktap 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.
+ *
+ * ktap is distributed in the hope it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
+ * more details.
+ *
+ * You should have received a copy of the GNU General Public License along with
+ * this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include "../include/ktap_types.h"
+#include "../include/ktap_opcodes.h"
+#include "ktapc.h"
+#include "../runtime/kp_obj.h"
+#include "cparser.h"
+
+
+typedef struct {
+       ktap_writer writer;
+       void *data;
+       int strip;
+       int status;
+} DumpState;
+
+#define DumpMem(b, n, size, D) DumpBlock(b, (n)*(size), D)
+#define DumpVar(x, D)          DumpMem(&x, 1, sizeof(x), D)
+
+static void DumpBlock(const void *b, size_t size, DumpState *D)
+{
+       if (D->status == 0)
+               D->status = ((D->writer))(b, size, D->data);
+}
+
+static void DumpChar(int y, DumpState *D)
+{
+       char x = (char)y;
+       DumpVar(x, D);
+}
+
+static void DumpInt(int x, DumpState *D)
+{
+       DumpVar(x, D);
+}
+
+static void DumpNumber(ktap_number x, DumpState *D)
+{
+       DumpVar(x,D);
+}
+
+static void DumpVector(const void *b, int n, size_t size, DumpState *D)
+{
+       DumpInt(n, D);
+       DumpMem(b, n, size, D);
+}
+
+static void DumpString(const ktap_string *s, DumpState *D)
+{
+       if (s == NULL) {
+               int size = 0;
+               DumpVar(size, D);
+       } else {
+               int size = s->tsv.len + 1;              /* include trailing '\0' */
+               DumpVar(size, D);
+               DumpBlock(getstr(s), size * sizeof(char), D);
+       }
+}
+
+#define DumpCode(f, D)  DumpVector(f->code, f->sizecode, sizeof(ktap_instruction), D)
+
+static void DumpFunction(const ktap_proto *f, DumpState *D);
+
+static void DumpConstants(const ktap_proto *f, DumpState *D)
+{
+       int i, n = f->sizek;
+
+       DumpInt(n, D);
+       for (i = 0; i < n; i++) {
+               const ktap_value* o=&f->k[i];
+               DumpChar(ttypenv(o), D);
+               switch (ttypenv(o)) {
+               case KTAP_TNIL:
+                       break;
+               case KTAP_TBOOLEAN:
+                       DumpChar(bvalue(o), D);
+                       break;
+               case KTAP_TNUMBER:
+                       DumpNumber(nvalue(o), D);
+                       break;
+               case KTAP_TSTRING:
+                       DumpString(rawtsvalue(o), D);
+                       break;
+               default:
+                       printf("ktap: DumpConstants with unknown vaule type %d\n", ttypenv(o));
+                       ktap_assert(0);
+               }
+       }
+       n = f->sizep;
+       DumpInt(n, D);
+       for (i = 0; i < n; i++)
+               DumpFunction(f->p[i], D);
+}
+
+static void DumpUpvalues(const ktap_proto *f, DumpState *D)
+{
+       int i, n = f->sizeupvalues;
+
+       DumpInt(n, D);
+       for (i = 0; i < n; i++) {
+               DumpChar(f->upvalues[i].instack, D);
+               DumpChar(f->upvalues[i].idx, D);
+       }
+}
+
+static void DumpDebug(const ktap_proto *f, DumpState *D)
+{
+       int i,n;
+
+       DumpString((D->strip) ? NULL : f->source, D);
+       n= (D->strip) ? 0 : f->sizelineinfo;
+       DumpVector(f->lineinfo, n, sizeof(int), D);
+       n = (D->strip) ? 0 : f->sizelocvars;
+       DumpInt(n, D);
+
+       for (i = 0; i < n; i++) {
+               DumpString(f->locvars[i].varname, D);
+               DumpInt(f->locvars[i].startpc, D);
+               DumpInt(f->locvars[i].endpc, D);
+       }
+       n = (D->strip) ? 0 : f->sizeupvalues;
+       DumpInt(n, D);
+       for (i = 0; i < n; i++)
+               DumpString(f->upvalues[i].name, D);
+}
+
+static void DumpFunction(const ktap_proto *f, DumpState *D)
+{
+       DumpInt(f->linedefined, D);
+       DumpInt(f->lastlinedefined, D);
+       DumpChar(f->numparams, D);
+       DumpChar(f->is_vararg, D);
+       DumpChar(f->maxstacksize, D);
+       DumpCode(f, D);
+       DumpConstants(f, D);
+       DumpUpvalues(f, D);
+       DumpDebug(f, D);
+}
+
+static void DumpHeader(DumpState *D)
+{
+       u8 h[KTAPC_HEADERSIZE];
+
+       kp_header(h);
+       DumpBlock(h, KTAPC_HEADERSIZE, D);
+}
+
+#ifdef CONFIG_KTAP_FFI
+static void DumpCSymbolFunc(csymbol *cs, DumpState *D)
+{
+       csymbol_func *csf = csym_func(cs);
+
+       DumpBlock(cs, sizeof(csymbol), D);
+       /* dump csymbol index for argument types */
+       DumpBlock(csf->arg_ids, csf->arg_nr*sizeof(int), D);
+}
+
+static void DumpCSymbolStruct(csymbol *cs, DumpState *D)
+{
+       csymbol_struct *csst = csym_struct(cs);
+
+       DumpBlock(cs, sizeof(csymbol), D);
+       /* dump csymbol index for argument types */
+       DumpBlock(csst->members, csst->memb_nr*sizeof(struct_member), D);
+}
+
+static void DumpCSymbols(DumpState *D)
+{
+       int i, cs_nr;
+       cp_csymbol_state *cs_state;
+       csymbol *cs, *cs_arr;
+
+       cs_state = ctype_get_csym_state();
+       cs_arr = cs_state->cs_arr;
+       cs_nr = cs_state->cs_nr;
+
+       if (!cs_arr || cs_nr == 0) {
+               DumpInt(0, D);
+               return;
+       }
+
+       /* dump number of csymbols */
+       DumpInt(cs_nr, D);
+       /* dump size of csymbol, for safty check in vm */
+       DumpInt(sizeof(csymbol), D);
+       for (i = 0; i < cs_nr; i++) {
+               cs = &cs_arr[i];
+               switch (cs->type) {
+               case FFI_FUNC:
+                       DumpCSymbolFunc(cs, D);
+                       break;
+               case FFI_STRUCT:
+                       DumpCSymbolStruct(cs, D);
+                       break;
+               default:
+                       DumpBlock(cs, sizeof(csymbol), D);
+                       break;
+               }
+       }
+}
+#else
+static void DumpCSymbols(DumpState *D)
+{
+       /* always dump zero when FFI is disabled */
+       DumpInt(0, D);
+}
+#endif /* CONFIG_KTAP_FFI */
+
+/*
+ * dump ktap function as precompiled chunk
+ */
+int ktapc_dump(const ktap_proto *f, ktap_writer w, void *data, int strip)
+{
+       DumpState D;
+
+       D.writer = w;
+       D.data = data;
+       D.strip = strip;
+       D.status = 0;
+       DumpHeader(&D);
+       DumpCSymbols(&D);
+       DumpFunction(f, &D);
+       return D.status;
+}
diff --git a/drivers/staging/ktap/userspace/eventdef.c b/drivers/staging/ktap/userspace/eventdef.c
new file mode 100644 (file)
index 0000000..9896dd3
--- /dev/null
@@ -0,0 +1,857 @@
+/*
+ * eventdef.c - ktap eventdef parser
+ *
+ * This file is part of ktap by Jovi Zhangwei.
+ *
+ * Copyright (C) 2012-2013 Jovi Zhangwei <jovi.zhangwei@gmail.com>.
+ *
+ * ktap 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.
+ *
+ * ktap is distributed in the hope it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
+ * more details.
+ *
+ * You should have received a copy of the GNU General Public License along with
+ * this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+
+#include <unistd.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <dirent.h>
+#include <fcntl.h>
+
+#include "../include/ktap_types.h"
+#include "../include/ktap_opcodes.h"
+#include "ktapc.h"
+#include "symbol.h"
+
+#define TRACING_EVENTS_DIR "/sys/kernel/debug/tracing/events"
+
+static u8 *idmap;
+static int idmap_size = 1024; /* set init size */
+static int id_nr = 0;
+
+static int idmap_init(void)
+{
+       idmap = malloc(idmap_size);
+       if (!idmap)
+               return -1;
+
+       memset(idmap, 0, idmap_size);
+       return 0;
+}
+
+static void idmap_free(void)
+{
+       free(idmap);
+}
+
+static inline int idmap_is_set(int id)
+{
+       return idmap[id / 8] & (1 << (id % 8));
+}
+
+static void idmap_set(int id)
+{
+       if (id >= idmap_size * 8) {
+               int newsize = id + 100; /* allocate extra 800 id */
+               idmap = realloc(idmap, newsize);
+               memset(idmap + idmap_size, 0, newsize - idmap_size);
+               idmap_size = newsize;
+       }
+
+       if (!idmap_is_set(id))
+               id_nr++;
+
+       idmap[id / 8] = idmap[id / 8] | (1 << (id % 8));
+}
+
+static void idmap_clear(int id)
+{
+       id_nr--;
+       idmap[id / 8] = idmap[id / 8] & ~ (1 << (id % 8));
+}
+
+static int idmap_get_max_id(void)
+{
+       return idmap_size * 8;
+}
+
+static int *get_id_array()
+{
+       int *id_array;
+       int i, j = 0;
+
+       id_array = malloc(sizeof(int) * id_nr);
+       if (!id_array)
+               return NULL;
+
+       for (i = 0; i < idmap_get_max_id(); i++) {
+               if (idmap_is_set(i))
+                       id_array[j++] = i;
+       }
+
+       return id_array;
+}
+
+static int add_event(char *evtid_path)
+{
+       char id_buf[24];
+       int id, fd;
+
+       fd = open(evtid_path, O_RDONLY);
+       if (fd < 0) {
+               /*
+                * some tracepoint doesn't have id file, like ftrace,
+                * return success in here, and don't print error.
+                */
+               verbose_printf("warning: cannot open file %s\n", evtid_path);
+               return 0;
+       }
+
+       if (read(fd, id_buf, sizeof(id_buf)) < 0) {
+               fprintf(stderr, "read file error %s\n", evtid_path);
+               close(fd);
+               return -1;
+       }
+
+       id = atoll(id_buf);
+
+       idmap_set(id);
+
+       close(fd);
+       return 0;
+}
+
+static int add_tracepoint(char *sys_name, char *evt_name)
+{
+       char evtid_path[PATH_MAX] = {0};
+
+
+       snprintf(evtid_path, PATH_MAX, "%s/%s/%s/id", TRACING_EVENTS_DIR,
+                                       sys_name, evt_name);
+       return add_event(evtid_path);
+}
+
+static int add_tracepoint_multi_event(char *sys_name, char *evt_name)
+{
+       char evt_path[PATH_MAX];
+       struct dirent *evt_ent;
+       DIR *evt_dir;
+       int ret = 0;
+
+       snprintf(evt_path, PATH_MAX, "%s/%s", TRACING_EVENTS_DIR, sys_name);
+       evt_dir = opendir(evt_path);
+       if (!evt_dir) {
+               perror("Can't open event dir");
+               return -1;
+       }
+
+       while (!ret && (evt_ent = readdir(evt_dir))) {
+               if (!strcmp(evt_ent->d_name, ".")
+                   || !strcmp(evt_ent->d_name, "..")
+                   || !strcmp(evt_ent->d_name, "enable")
+                   || !strcmp(evt_ent->d_name, "filter"))
+                       continue;
+
+               if (!strglobmatch(evt_ent->d_name, evt_name))
+                       continue;
+
+               ret = add_tracepoint(sys_name, evt_ent->d_name);
+       }
+
+       closedir(evt_dir);
+       return ret;
+}
+
+static int add_tracepoint_event(char *sys_name, char *evt_name)
+{
+       return strpbrk(evt_name, "*?") ?
+              add_tracepoint_multi_event(sys_name, evt_name) :
+              add_tracepoint(sys_name, evt_name);
+}
+
+static int add_tracepoint_multi_sys(char *sys_name, char *evt_name)
+{
+       struct dirent *events_ent;
+       DIR *events_dir;
+       int ret = 0;
+
+       events_dir = opendir(TRACING_EVENTS_DIR);
+       if (!events_dir) {
+               perror("Can't open event dir");
+               return -1;
+       }
+
+       while (!ret && (events_ent = readdir(events_dir))) {
+               if (!strcmp(events_ent->d_name, ".")
+                   || !strcmp(events_ent->d_name, "..")
+                   || !strcmp(events_ent->d_name, "enable")
+                   || !strcmp(events_ent->d_name, "header_event")
+                   || !strcmp(events_ent->d_name, "header_page"))
+                       continue;
+
+               if (!strglobmatch(events_ent->d_name, sys_name))
+                       continue;
+
+               ret = add_tracepoint_event(events_ent->d_name,
+                                          evt_name);
+       }
+
+       closedir(events_dir);
+       return ret;
+}
+
+static int parse_events_add_tracepoint(char *sys, char *event)
+{
+       if (strpbrk(sys, "*?"))
+               return add_tracepoint_multi_sys(sys, event);
+       else
+               return add_tracepoint_event(sys, event);
+}
+
+enum {
+       KPROBE_EVENT,
+       UPROBE_EVENT,
+};
+
+struct probe_list {
+       struct probe_list *next;
+       int type;
+       char event[64];
+};
+
+static struct probe_list *probe_list_head; /* for cleanup resources */
+
+/*
+ * Some symbol format cannot write to uprobe_events in debugfs, like:
+ * symbol "check_one_fd.part.0" in glibc.
+ * For those symbols, we change the format, get rid of invalid chars,
+ * "check_one_fd.part.0" -> "check_one_fd"
+ *
+ * This function copy is_good_name function in linux/kernel/trace/trace_probe.h
+ */
+static char *format_symbol_name(const char *old_symbol)
+{
+       char *new_name = strdup(old_symbol);
+       char *name = new_name;
+
+        if (!isalpha(*name) && *name != '_')
+               *name = '\0';
+
+        while (*++name != '\0') {
+                if (!isalpha(*name) && !isdigit(*name) && *name != '_') {
+                       *name = '\0';
+                       break;
+               }
+        }
+
+       /* this is a good name */
+        return new_name;
+}
+
+
+#define KPROBE_EVENTS_PATH "/sys/kernel/debug/tracing/kprobe_events"
+
+/**
+ * @return 0 on success, otherwise -1
+ */
+static int
+write_kprobe_event(int fd, int ret_probe, const char *symbol, char *fetch_args)
+{
+       char probe_event[128] = {0};
+       char event[64] = {0};
+       struct probe_list *pl;
+       char event_id_path[128] = {0};
+       char *symbol_name;
+       int id_fd, ret;
+
+       /* In case some symbols cannot write to uprobe_events debugfs file */
+       symbol_name = format_symbol_name(symbol);
+
+       if (!fetch_args)
+               fetch_args = " ";
+
+       if (ret_probe) {
+               snprintf(event, 64, "ktap_kprobes_%d/ret_%s",
+                        getpid(), symbol_name);
+               snprintf(probe_event, 128, "r:%s %s %s",
+                        event, symbol, fetch_args);
+       } else {
+               snprintf(event, 64, "ktap_kprobes_%d/%s",
+                        getpid(), symbol_name);
+               snprintf(probe_event, 128, "p:%s %s %s",
+                        event, symbol, fetch_args);
+       }
+
+       sprintf(event_id_path, "/sys/kernel/debug/tracing/events/%s/id", event);
+       /* if event id already exist, then don't write to kprobes_event again */
+       id_fd = open(event_id_path, O_RDONLY);
+       if (id_fd > 0) {
+               close(id_fd);
+
+               /* remember add event id to ids_array */
+               ret = add_event(event_id_path);
+               if (ret)
+                       goto error;
+
+               goto out;
+       }
+
+       verbose_printf("write kprobe event %s\n", probe_event);
+
+       if (write(fd, probe_event, strlen(probe_event)) <= 0) {
+               fprintf(stderr, "Cannot write %s to %s\n", probe_event,
+                               KPROBE_EVENTS_PATH);
+               goto error;
+       }
+
+       /* add to cleanup list */
+       pl = malloc(sizeof(struct probe_list));
+       if (!pl)
+               goto error;
+
+       pl->type = KPROBE_EVENT;
+       pl->next = probe_list_head;
+       memcpy(pl->event, event, 64);
+       probe_list_head = pl;
+
+       ret = add_event(event_id_path);
+       if (ret < 0)
+               goto error;
+
+ out:
+       free(symbol_name);
+       return 0;
+
+ error:
+       free(symbol_name);
+       return -1;
+}
+
+static unsigned long core_kernel_text_start;
+static unsigned long core_kernel_text_end;
+static unsigned long kprobes_text_start;
+static unsigned long kprobes_text_end;
+
+static void init_kprobe_prohibited_area(void)
+{
+       static int once = 0;
+
+       if (once > 0)
+               return;
+
+       once = 1;
+
+       core_kernel_text_start = find_kernel_symbol("_stext");
+       core_kernel_text_end   = find_kernel_symbol("_etext");
+       kprobes_text_start     = find_kernel_symbol("__kprobes_text_start");
+       kprobes_text_end       = find_kernel_symbol("__kprobes_text_end");
+}
+
+static int check_kprobe_addr_prohibited(unsigned long addr)
+{
+       if (addr <= core_kernel_text_start || addr >= core_kernel_text_end)
+               return -1;
+
+       if (addr >= kprobes_text_start && addr <= kprobes_text_end)
+               return -1;
+
+       return 0;
+}
+
+struct probe_cb_base {
+       int fd;
+       int ret_probe;
+       const char *event;
+       char *binary;
+       char *symbol;
+       char *fetch_args;
+};
+
+static int kprobe_symbol_actor(void *arg, const char *name, char type,
+                              unsigned long start)
+{
+       struct probe_cb_base *base = (struct probe_cb_base *)arg;
+
+       /* only can probe text function */
+       if (type != 't' && type != 'T')
+               return 0;
+
+       if (!strglobmatch(name, base->symbol))
+               return 0;
+
+       if (check_kprobe_addr_prohibited(start))
+               return 0;
+
+       return write_kprobe_event(base->fd, base->ret_probe, name,
+                                 base->fetch_args);
+}
+
+static int parse_events_add_kprobe(char *event)
+{
+       char *symbol, *end;
+       struct probe_cb_base base;
+       int fd, ret;
+
+       fd = open(KPROBE_EVENTS_PATH, O_WRONLY);
+       if (fd < 0) {
+               fprintf(stderr, "Cannot open %s\n", KPROBE_EVENTS_PATH);
+               return -1;
+       }
+
+       end = strpbrk(event, "% ");
+       if (end)
+               symbol = strndup(event, end - event);
+       else
+               symbol = strdup(event);
+
+       base.fd = fd;
+       base.ret_probe = !!strstr(event, "%return");
+       base.symbol = symbol;
+       base.fetch_args = strchr(event, ' ');
+
+       init_kprobe_prohibited_area();
+
+       ret = kallsyms_parse(&base, kprobe_symbol_actor);
+       if (ret < 0)
+               fprintf(stderr, "cannot parse symbol \"%s\"\n", symbol);
+
+       free(symbol);
+       close(fd);
+
+       return ret;
+}
+
+#define UPROBE_EVENTS_PATH "/sys/kernel/debug/tracing/uprobe_events"
+
+/**
+ * @return 0 on success, otherwise -1
+ */
+static int
+write_uprobe_event(int fd, int ret_probe, const char *binary,
+                  const char *symbol, unsigned long addr,
+                  char *fetch_args)
+{
+       char probe_event[128] = {0};
+       char event[64] = {0};
+       struct probe_list *pl;
+       char event_id_path[128] = {0};
+       char *symbol_name;
+       int id_fd, ret;
+
+       /* In case some symbols cannot write to uprobe_events debugfs file */
+       symbol_name = format_symbol_name(symbol);
+
+       if (!fetch_args)
+               fetch_args = " ";
+
+       if (ret_probe) {
+               snprintf(event, 64, "ktap_uprobes_%d/ret_%s",
+                        getpid(), symbol_name);
+               snprintf(probe_event, 128, "r:%s %s:0x%lx %s",
+                        event, binary, addr, fetch_args);
+       } else {
+               snprintf(event, 64, "ktap_uprobes_%d/%s",
+                        getpid(), symbol_name);
+               snprintf(probe_event, 128, "p:%s %s:0x%lx %s",
+                        event, binary, addr, fetch_args);
+       }
+
+       sprintf(event_id_path, "/sys/kernel/debug/tracing/events/%s/id", event);
+       /* if event id already exist, then don't write to uprobes_event again */
+       id_fd = open(event_id_path, O_RDONLY);
+       if (id_fd > 0) {
+               close(id_fd);
+
+               /* remember add event id to ids_array */
+               ret = add_event(event_id_path);
+               if (ret)
+                       goto error;
+
+               goto out;
+       }
+
+       verbose_printf("write uprobe event %s\n", probe_event);
+
+       if (write(fd, probe_event, strlen(probe_event)) <= 0) {
+               fprintf(stderr, "Cannot write %s to %s\n", probe_event,
+                               UPROBE_EVENTS_PATH);
+               goto error;
+       }
+
+       /* add to cleanup list */
+       pl = malloc(sizeof(struct probe_list));
+       if (!pl)
+               goto error;
+
+       pl->type = UPROBE_EVENT;
+       pl->next = probe_list_head;
+       memcpy(pl->event, event, 64);
+       probe_list_head = pl;
+
+       ret = add_event(event_id_path);
+       if (ret < 0)
+               goto error;
+
+ out:
+       free(symbol_name);
+       return 0;
+
+ error:
+       free(symbol_name);
+       return -1;
+}
+
+/**
+ * TODO: avoid copy-paste stuff
+ *
+ * @return 1 on success, otherwise 0
+ */
+#ifdef NO_LIBELF
+static int parse_events_resolve_symbol(int fd, char *event, int type)
+{
+       char *colon, *binary, *fetch_args;
+       unsigned long symbol_address;
+
+       colon = strchr(event, ':');
+       if (!colon)
+               return -1;
+
+       symbol_address = strtol(colon + 1 /* skip ":" */, NULL, 0);
+
+       fetch_args = strchr(event, ' ');
+
+       /**
+        * We already have address, no need in resolving.
+        */
+       if (symbol_address) {
+               int ret;
+
+               binary = strndup(event, colon - event);
+               ret = write_uprobe_event(fd, !!strstr(event, "%return"), binary,
+                                        "NULL", symbol_address, fetch_args);
+               free(binary);
+               return ret;
+       }
+
+       fprintf(stderr, "error: cannot resolve event \"%s\" without libelf, "
+                       "please recompile ktap with NO_LIBELF disabled\n",
+                       event);
+       exit(EXIT_FAILURE);
+       return -1;
+}
+
+#else
+static int uprobe_symbol_actor(const char *name, vaddr_t addr, void *arg)
+{
+       struct probe_cb_base *base = (struct probe_cb_base *)arg;
+       int ret;
+
+       if (!strglobmatch(name, base->symbol))
+               return 0;
+
+       verbose_printf("uprobe: binary: \"%s\" symbol \"%s\" "
+                       "resolved to 0x%lx\n",
+                       base->binary, base->symbol, addr);
+
+       ret = write_uprobe_event(base->fd, base->ret_probe, base->binary,
+                                name, addr, base->fetch_args);
+       if (ret)
+               return ret;
+
+       return 0;
+}
+
+static int parse_events_resolve_symbol(int fd, char *event, int type)
+{
+       char *colon, *end;
+       vaddr_t symbol_address;
+       int ret;
+       struct probe_cb_base base = {
+               .fd = fd,
+               .event = event
+       };
+
+       colon = strchr(event, ':');
+       if (!colon)
+               return 0;
+
+       base.ret_probe = !!strstr(event, "%return");
+       symbol_address = strtol(colon + 1 /* skip ":" */, NULL, 0);
+       base.binary = strndup(event, colon - event);
+
+       base.fetch_args = strchr(event, ' ');
+
+       /*
+        * We already have address, no need in resolving.
+        */
+       if (symbol_address) {
+               int ret;
+               ret = write_uprobe_event(fd, base.ret_probe, base.binary,
+                                        "NULL", symbol_address,
+                                        base.fetch_args);
+               free(base.binary);
+               return ret;
+       }
+
+       end = strpbrk(event, "% ");
+       if (end)
+               base.symbol = strndup(colon + 1, end - 1 - colon);
+       else
+               base.symbol = strdup(colon + 1);
+
+       ret = parse_dso_symbols(base.binary, type, uprobe_symbol_actor,
+                               (void *)&base);
+       if (!ret) {
+               fprintf(stderr, "error: cannot find symbol %s in binary %s\n",
+                       base.symbol, base.binary);
+               ret = -1;
+       } else if(ret > 0) {
+               /* no error found when parse symbols */
+               ret = 0;
+       }
+
+       free(base.binary);
+       free(base.symbol);
+
+       return ret;
+}
+#endif
+
+static int parse_events_add_uprobe(char *old_event, int type)
+{
+       int ret;
+       int fd;
+
+       fd = open(UPROBE_EVENTS_PATH, O_WRONLY);
+       if (fd < 0) {
+               fprintf(stderr, "Cannot open %s\n", UPROBE_EVENTS_PATH);
+               return -1;
+       }
+
+       ret = parse_events_resolve_symbol(fd, old_event, type);
+
+       close(fd);
+       return ret;
+}
+
+static int parse_events_add_probe(char *old_event)
+{
+       char *separator;
+
+       separator = strchr(old_event, ':');
+       if (!separator || (separator == old_event))
+               return parse_events_add_kprobe(old_event);
+       else
+               return parse_events_add_uprobe(old_event, FIND_SYMBOL);
+}
+
+static int parse_events_add_sdt(char *old_event)
+{
+       return parse_events_add_uprobe(old_event, FIND_STAPSDT_NOTE);
+}
+
+static void strim(char *s)
+{
+       size_t size;
+       char *end;
+
+       size = strlen(s);
+       if (!size)
+               return;
+
+       end = s + size -1;
+       while (end >= s && isspace(*end))
+               end--;
+
+       *(end + 1) = '\0';
+}
+
+static int get_sys_event_filter_str(char *start,
+                                   char **sys, char **event, char **filter)
+{
+       char *separator, *separator2, *ptr, *end;
+
+       while (*start == ' ')
+               start++;
+
+       /* find sys */
+       separator = strchr(start, ':');
+       if (!separator || (separator == start)) {
+               return -1;
+       }
+
+       ptr = malloc(separator - start + 1);
+       if (!ptr)
+               return -1;
+
+       strncpy(ptr, start, separator - start);
+       ptr[separator - start] = '\0';
+
+       strim(ptr);
+       *sys = ptr;
+
+       if (!strcmp(*sys, "probe") && (*(separator + 1) == '/')) {
+               /* it's uprobe event */
+               separator2 = strchr(separator + 1, ':');
+               if (!separator2)
+                       return -1;
+       } else
+               separator2 = separator;
+
+       /* find filter */
+       end = start + strlen(start);
+       while (*--end == ' ') {
+       }
+
+       if (*end == '/') {
+               char *filter_start;
+
+               filter_start = strchr(separator2, '/');
+               if (filter_start == end)
+                       return -1;
+
+               ptr = malloc(end - filter_start + 2);
+               if (!ptr)
+                       return -1;
+
+               memcpy(ptr, filter_start, end - filter_start + 1);
+               ptr[end - filter_start + 1] = '\0';
+
+               *filter = ptr;
+
+               end = filter_start;
+       } else {
+               *filter = NULL;
+               end++;
+       }
+
+       /* find event */
+       ptr = malloc(end - separator);
+       if (!ptr)
+               return -1;
+
+       memcpy(ptr, separator + 1, end - separator - 1);
+       ptr[end - separator - 1] = '\0';
+
+       strim(ptr);
+       *event = ptr;
+
+       return 0;
+}
+
+static char *get_next_eventdef(char *str)
+{
+       char *separator;
+
+       separator = strchr(str, ',');
+       if (!separator)
+               return str + strlen(str);
+
+       *separator = '\0';
+       return separator + 1;
+}
+
+ktap_eventdef_info *ktapc_parse_eventdef(const char *eventdef)
+{
+       char *str = strdup(eventdef);
+       char *sys, *event, *filter, *next;
+       ktap_eventdef_info *evdef_info;
+       int ret;
+
+       idmap_init();
+
+ parse_next_eventdef:
+       next = get_next_eventdef(str);
+
+       if (get_sys_event_filter_str(str, &sys, &event, &filter))
+               goto error;
+
+       verbose_printf("parse_eventdef: sys[%s], event[%s], filter[%s]\n",
+                      sys, event, filter);
+
+       if (!strcmp(sys, "probe"))
+               ret = parse_events_add_probe(event);
+       else if (!strcmp(sys, "sdt"))
+               ret = parse_events_add_sdt(event);
+       else
+               ret = parse_events_add_tracepoint(sys, event);
+
+       if (ret)
+               goto error;
+
+       /* don't trace ftrace:function when all tracepoints enabled */
+       if (!strcmp(sys, "*"))
+               idmap_clear(1);
+
+
+       if (filter && *next != '\0') {
+               fprintf(stderr, "Error: eventdef only can append one filter\n");
+               goto error;
+       }
+
+       str = next;
+       if (*next != '\0')
+               goto parse_next_eventdef;
+
+       evdef_info = malloc(sizeof(*evdef_info));
+       if (!evdef_info)
+               goto error;
+
+       evdef_info->nr = id_nr;
+       evdef_info->id_arr = get_id_array();
+       evdef_info->filter = filter;
+
+       idmap_free();
+       return evdef_info;
+ error:
+       idmap_free();
+       cleanup_event_resources();
+       return NULL;
+}
+
+void cleanup_event_resources(void)
+{
+       struct probe_list *pl;
+       const char *path;
+       char probe_event[128] = {0};
+       int fd, ret;
+
+       for (pl = probe_list_head; pl; pl = pl->next) {
+               if (pl->type == KPROBE_EVENT)
+                       path = KPROBE_EVENTS_PATH;
+               else if (pl->type == UPROBE_EVENT)
+                       path = UPROBE_EVENTS_PATH;
+               else {
+                       fprintf(stderr, "Cannot cleanup event type %d\n",
+                                       pl->type);
+                       continue;
+               }
+
+               snprintf(probe_event, 128, "-:%s", pl->event);
+
+               fd = open(path, O_WRONLY);
+               if (fd < 0) {
+                       fprintf(stderr, "Cannot open %s\n", UPROBE_EVENTS_PATH);
+                       continue;
+               }
+
+               ret = write(fd, probe_event, strlen(probe_event));
+               if (ret <= 0) {
+                       fprintf(stderr, "Cannot write %s to %s\n", probe_event,
+                                       path);
+                       close(fd);
+                       continue;
+               }
+
+               close(fd);
+       }
+}
+
diff --git a/drivers/staging/ktap/userspace/ffi/cparser.c b/drivers/staging/ktap/userspace/ffi/cparser.c
new file mode 100644 (file)
index 0000000..9f9a429
--- /dev/null
@@ -0,0 +1,1755 @@
+#include <stdarg.h>
+#include "../cparser.h"
+
+#define IS_CONST(tok) (IS_LITERAL(tok, "const") || IS_LITERAL(tok, "__const") \
+                       || IS_LITERAL(tok, "__const__"))
+#define IS_VOLATILE(tok) (IS_LITERAL(tok, "volatile") || \
+                               IS_LITERAL(tok, "__volatile") || \
+                               IS_LITERAL(tok, "__volatile__"))
+#define IS_RESTRICT(tok) (IS_LITERAL(tok, "restrict") || \
+                               IS_LITERAL(tok, "__restrict") || \
+                               IS_LITERAL(tok, "__restrict__"))
+
+#define max(a,b) ((a) < (b) ? (b) : (a))
+#define min(a,b) ((a) < (b) ? (a) : (b))
+
+
+enum etoken {
+       /* 0 - 3 */
+       TOK_NIL,
+       TOK_NUMBER,
+       TOK_STRING,
+       TOK_TOKEN,
+
+       /* the order of these values must match the token strings in lex.c */
+
+       /* 4 - 5 */
+       TOK_3_BEGIN,
+       TOK_VA_ARG,
+
+       /* 6 - 14 */
+       TOK_2_BEGIN,
+       TOK_LEFT_SHIFT, TOK_RIGHT_SHIFT, TOK_LOGICAL_AND, TOK_LOGICAL_OR,
+       TOK_LESS_EQUAL, TOK_GREATER_EQUAL, TOK_EQUAL, TOK_NOT_EQUAL,
+
+       /* 15 - 20 */
+       TOK_1_BEGIN,
+       TOK_OPEN_CURLY, TOK_CLOSE_CURLY, TOK_SEMICOLON, TOK_COMMA, TOK_COLON,
+       /* 21 - 30 */
+       TOK_ASSIGN, TOK_OPEN_PAREN, TOK_CLOSE_PAREN, TOK_OPEN_SQUARE, TOK_CLOSE_SQUARE,
+       TOK_DOT, TOK_AMPERSAND, TOK_LOGICAL_NOT, TOK_BITWISE_NOT, TOK_MINUS,
+       /* 31 - 40 */
+       TOK_PLUS, TOK_STAR, TOK_DIVIDE, TOK_MODULUS, TOK_LESS,
+       TOK_GREATER, TOK_BITWISE_XOR, TOK_BITWISE_OR, TOK_QUESTION, TOK_POUND,
+
+       /* 41 - 43 */
+       TOK_REFERENCE = TOK_AMPERSAND,
+       TOK_MULTIPLY = TOK_STAR,
+       TOK_BITWISE_AND = TOK_AMPERSAND,
+};
+
+struct token {
+       enum etoken type;
+       int64_t integer;
+       const char *str;
+       size_t size;
+};
+
+#define IS_LITERAL(TOK, STR) \
+       (((TOK).size == sizeof(STR) - 1) && \
+               0 == memcmp((TOK).str, STR, sizeof(STR) - 1))
+
+
+static int parse_type_name(struct parser *P, char *type_name);
+static void parse_argument(struct parser *P, struct cp_ctype *ct,
+               struct token *pname, struct parser *asmname);
+static int parse_attribute(struct parser *P, struct token *tok,
+               struct cp_ctype *ct, struct parser *asmname);
+static int parse_record(struct parser *P, struct cp_ctype *ct);
+static void instantiate_typedef(struct parser *P, struct cp_ctype *tt,
+               const struct cp_ctype *ft);
+
+
+/* the order of tokens _must_ match the order of the enum etoken enum */
+
+static char tok3[][4] = {
+       "...", /* unused ">>=", "<<=", */
+};
+
+static char tok2[][3] = {
+       "<<", ">>", "&&", "||", "<=",
+       ">=", "==", "!=",
+       /* unused "+=", "-=", "*=", "/=", "%=", "&=", "^=",
+        * "|=", "++", "--", "->", "::", */
+};
+
+static char tok1[] = {
+       '{', '}', ';', ',', ':',
+       '=', '(', ')', '[', ']',
+       '.', '&', '!', '~', '-',
+       '+', '*', '/', '%', '<',
+       '>', '^', '|', '?', '#'
+};
+
+
+/* this function never returns, but it's an idiom to use it in C functions
+ * as return cp_error */
+void cp_error(const char *err_msg_fmt, ...)
+{
+       va_list ap;
+
+       fprintf(stderr, "cparser error:\n");
+
+       va_start(ap, err_msg_fmt);
+       vfprintf(stderr, err_msg_fmt, ap);
+       va_end(ap);
+
+       exit(EXIT_FAILURE);
+}
+
+static int set_struct_type_name(char *dst, const char *src, int len)
+{
+       int prefix_len = sizeof("struct ");
+
+       if (len + prefix_len > MAX_TYPE_NAME_LEN)
+               return -1;
+
+       memset(dst, 0, MAX_TYPE_NAME_LEN);
+       strcpy(dst, "struct ");
+       strncat(dst, src, len);
+
+       return 0;
+}
+
+static void increase_ptr_deref_level(struct parser *P, struct cp_ctype *ct)
+{
+       if (ct->pointers == POINTER_MAX) {
+               cp_error("maximum number of pointer derefs reached - use a "
+                       "struct to break up the pointers on line %d", P->line);
+       } else {
+               ct->pointers++;
+               ct->const_mask <<= 1;
+       }
+}
+
+static int next_token(struct parser *P, struct token *tok)
+{
+       size_t i;
+       const char *s = P->next;
+
+       /* UTF8 BOM */
+       if (s[0] == '\xEF' && s[1] == '\xBB' && s[2] == '\xBF') {
+               s += 3;
+       }
+
+       /* consume whitespace and comments */
+       for (;;) {
+               /* consume whitespace */
+               while (*s == '\t' || *s == '\n' || *s == ' '
+                               || *s == '\v' || *s == '\r') {
+                       if (*s == '\n') {
+                               P->line++;
+                       }
+                       s++;
+               }
+
+               /* consume comments */
+               if (*s == '/' && *(s+1) == '/') {
+
+                       s = strchr(s, '\n');
+                       if (!s) {
+                               cp_error("non-terminated comment");
+                       }
+
+               } else if (*s == '/' && *(s+1) == '*') {
+                       s += 2;
+
+                       for (;;) {
+                               if (s[0] == '\0') {
+                                       cp_error("non-terminated comment");
+                               } else if (s[0] == '*' && s[1] == '/') {
+                                       s += 2;
+                                       break;
+                               } else if (s[0] == '\n') {
+                                       P->line++;
+                               }
+                               s++;
+                       }
+
+               } else if (*s == '\0') {
+                       tok->type = TOK_NIL;
+                       return 0;
+
+               } else {
+                       break;
+               }
+       }
+
+       P->prev = s;
+
+       for (i = 0; i < sizeof(tok3) / sizeof(tok3[0]); i++) {
+               if (s[0] == tok3[i][0] && s[1] == tok3[i][1] && s[2] == tok3[i][2]) {
+                       tok->type = (enum etoken) (TOK_3_BEGIN + 1 + i);
+                       P->next = s + 3;
+                       goto end;
+               }
+       }
+
+       for (i = 0; i < sizeof(tok2) / sizeof(tok2[0]); i++) {
+               if (s[0] == tok2[i][0] && s[1] == tok2[i][1]) {
+                       tok->type = (enum etoken) (TOK_2_BEGIN + 1 + i);
+                       P->next = s + 2;
+                       goto end;
+               }
+       }
+
+       for (i = 0; i < sizeof(tok1) / sizeof(tok1[0]); i++) {
+               if (s[0] == tok1[i]) {
+                       tok->type = (enum etoken) (TOK_1_BEGIN + 1 + i);
+                       P->next = s + 1;
+                       goto end;
+               }
+       }
+
+       if (*s == '.' || *s == '-' || ('0' <= *s && *s <= '9')) {
+               /* number */
+               tok->type = TOK_NUMBER;
+
+               /* split out the negative case so we get the full range of
+                * bits for unsigned (eg to support 0xFFFFFFFF where
+                * sizeof(long) == 4 */
+               if (*s == '-') {
+                       tok->integer = strtol(s, (char**) &s, 0);
+               } else {
+                       tok->integer = strtoul(s, (char**) &s, 0);
+               }
+
+               while (*s == 'u' || *s == 'U' || *s == 'l' || *s == 'L') {
+                       s++;
+               }
+
+               P->next = s;
+               goto end;
+
+       } else if (*s == '\'' || *s == '\"') {
+               /* "..." or '...' */
+               char quote = *s;
+               s++; /* jump over " */
+
+               tok->type = TOK_STRING;
+               tok->str = s;
+
+               while (*s != quote) {
+                       if (*s == '\0' || (*s == '\\' && *(s+1) == '\0')) {
+                               cp_error("string not finished\n");
+                       }
+                       if (*s == '\\') {
+                               s++;
+                       }
+                       s++;
+               }
+
+               tok->size = s - tok->str;
+               s++; /* jump over " */
+               P->next = s;
+               goto end;
+
+       } else if (('a' <= *s && *s <= 'z') || ('A' <= *s && *s <= 'Z')
+                       || *s == '_') {
+               /* tokens */
+               tok->type = TOK_TOKEN;
+               tok->str = s;
+
+               while (('a' <= *s && *s <= 'z') || ('A' <= *s && *s <= 'Z')
+                               || *s == '_' || ('0' <= *s && *s <= '9')) {
+                       s++;
+               }
+
+               tok->size = s - tok->str;
+               P->next = s;
+               goto end;
+       } else {
+               cp_error("invalid character %d", P->line);
+       }
+
+end:
+       return 1;
+}
+
+static void require_token(struct parser *P, struct token *tok)
+{
+       if (!next_token(P, tok)) {
+               cp_error("unexpected end");
+       }
+}
+
+static void check_token(struct parser *P, int type, const char *str,
+                               const char *err, ...)
+{
+       va_list ap;
+       struct token tok;
+       if (!next_token(P, &tok) || tok.type != type
+                       || (tok.type == TOK_TOKEN && (tok.size != strlen(str)
+                               || memcmp(tok.str, str, tok.size) != 0))) {
+
+               va_start(ap, err);
+               vfprintf(stderr, err, ap);
+               va_end(ap);
+
+               exit(EXIT_FAILURE);
+       }
+}
+
+static void put_back(struct parser *P) {
+       P->next = P->prev;
+}
+
+int64_t calculate_constant(struct parser *P);
+
+/* parses out the base type of a type expression in a function declaration,
+ * struct definition, typedef etc
+ *
+ * leaves the usr value of the type on the stack
+ */
+int parse_type(struct parser *P, struct cp_ctype *ct)
+{
+       struct token tok;
+
+       memset(ct, 0, sizeof(*ct));
+
+       require_token(P, &tok);
+
+       /* get function attributes before the return type */
+       while (parse_attribute(P, &tok, ct, NULL)) {
+               require_token(P, &tok);
+       }
+
+       /* get const/volatile before the base type */
+       for (;;) {
+               if (tok.type != TOK_TOKEN) {
+                       cp_error("unexpected value before type name on line %d",
+                                       P->line);
+                       return 0;
+               } else if (IS_CONST(tok)) {
+                       ct->const_mask = 1;
+                       require_token(P, &tok);
+               } else if (IS_VOLATILE(tok) || IS_RESTRICT(tok)) {
+                       /* ignored for now */
+                       require_token(P, &tok);
+               } else {
+                       break;
+               }
+       }
+
+       /* get base type */
+       if (tok.type != TOK_TOKEN) {
+               cp_error("unexpected value before type name on line %d", P->line);
+               return 0;
+       } else if (IS_LITERAL(tok, "struct")) {
+               ct->type = STRUCT_TYPE;
+               parse_record(P, ct);
+       } else if (IS_LITERAL(tok, "union")) {
+               ct->type = UNION_TYPE;
+               parse_record(P, ct);
+       } else if (IS_LITERAL(tok, "enum")) {
+               ct->type = ENUM_TYPE;
+               parse_record(P, ct);
+       } else {
+               put_back(P);
+
+               /* lookup type */
+               struct cp_ctype *lct;
+               char cur_type_name[MAX_TYPE_NAME_LEN];
+
+               memset(cur_type_name, 0, MAX_TYPE_NAME_LEN);
+               parse_type_name(P, cur_type_name);
+               lct = ctype_lookup_type(cur_type_name);
+               if (!lct)
+                       cp_error("unknow type: \"%s\"\n", cur_type_name);
+
+               instantiate_typedef(P, ct, lct);
+       }
+
+       while (next_token(P, &tok)) {
+               if (tok.type != TOK_TOKEN) {
+                       put_back(P);
+                       break;
+               } else if (IS_CONST(tok) || IS_VOLATILE(tok)) {
+                       /* ignore for now */
+               } else {
+                       put_back(P);
+                       break;
+               }
+       }
+
+       return 0;
+}
+
+enum test {TEST};
+
+/* Parses an enum definition from after the open curly through to the close
+ * curly. Expects the user table to be on the top of the stack
+ */
+static int parse_enum(struct parser *P, struct cp_ctype *type)
+{
+       struct token tok;
+       int value = -1;
+
+       /*@TODO clean up this function when enum support is added*/
+       cp_error("TODO: enum not supported!\n");
+
+       for (;;) {
+               require_token(P, &tok);
+
+               if (tok.type == TOK_CLOSE_CURLY) {
+                       break;
+               } else if (tok.type != TOK_TOKEN) {
+                       cp_error("unexpected token in enum at line %d", P->line);
+                       return 0;
+               }
+               require_token(P, &tok);
+
+               if (tok.type == TOK_COMMA || tok.type == TOK_CLOSE_CURLY) {
+                       /* we have an auto calculated enum value */
+                       value++;
+               } else if (tok.type == TOK_ASSIGN) {
+                       /* we have an explicit enum value */
+                       value = (int) calculate_constant(P);
+                       require_token(P, &tok);
+               } else {
+                       cp_error("unexpected token in enum at line %d", P->line);
+                       return 0;
+               }
+
+               if (tok.type == TOK_CLOSE_CURLY) {
+                       break;
+               } else if (tok.type != TOK_COMMA) {
+                       cp_error("unexpected token in enum at line %d", P->line);
+                       return 0;
+               }
+       }
+
+       type->base_size = sizeof(enum test);
+       type->align_mask = sizeof(enum test) - 1;
+
+       return 0;
+}
+
+/* Parses a struct from after the open curly through to the close curly. */
+static int parse_struct(struct parser *P, const struct cp_ctype *ct)
+{
+       struct token tok;
+
+       /* parse members */
+       for (;;) {
+               struct cp_ctype mbase;
+
+               /* see if we're at the end of the struct */
+               require_token(P, &tok);
+               if (tok.type == TOK_CLOSE_CURLY) {
+                       break;
+               } else if (ct->is_variable_struct) {
+                       cp_error("can't have members after a variable sized "
+                                       "member on line %d", P->line);
+                       return -1;
+               } else {
+                       put_back(P);
+               }
+
+               /* members are of the form
+                * <base type> <arg>, <arg>, <arg>;
+                * eg struct foo bar, *bar2[2];
+                * mbase is 'struct foo'
+                * mtype is '' then '*[2]'
+                * mname is 'bar' then 'bar2'
+                */
+
+               parse_type(P, &mbase);
+
+               for (;;) {
+                       struct token mname;
+                       struct cp_ctype mt = mbase;
+
+                       memset(&mname, 0, sizeof(mname));
+
+                       if (ct->is_variable_struct) {
+                               cp_error("can't have members after a variable "
+                                       "sized member on line %d", P->line);
+                               return -1;
+                       }
+
+                       parse_argument(P, &mt, &mname, NULL);
+
+                       if (!mt.is_defined && (mt.pointers - mt.is_array) == 0) {
+                               cp_error("member type is undefined on line %d",
+                                               P->line);
+                               return -1;
+                       }
+
+                       if (mt.type == VOID_TYPE
+                                       && (mt.pointers - mt.is_array) == 0) {
+                               cp_error("member type can not be void on line %d",
+                                               P->line);
+                               return -1;
+                       }
+
+                       mt.has_member_name = (mname.size > 0);
+                       if (mt.has_member_name) {
+                               cp_push_ctype_with_name(&mt,
+                                               mname.str, mname.size);
+                       } else {
+                               /* @TODO handle unnamed member (houqp) */
+                               cp_error("TODO: unnamed member not supported.");
+                               cp_push_ctype(&mt);
+                       }
+
+                       require_token(P, &tok);
+                       if (tok.type == TOK_SEMICOLON) {
+                               break;
+                       } else if (tok.type != TOK_COMMA) {
+                               cp_error("unexpected token in struct "
+                                       "definition on line %d", P->line);
+                       }
+               }
+       }
+
+       return 0;
+}
+
+/* copy over attributes that could be specified before the typedef eg
+ * __attribute__(packed) const type_t */
+static void instantiate_typedef(struct parser *P, struct cp_ctype *tt,
+               const struct cp_ctype *ft)
+{
+       struct cp_ctype pt = *tt;
+       *tt = *ft;
+
+       tt->const_mask |= pt.const_mask;
+       tt->is_packed = pt.is_packed;
+
+       if (tt->is_packed) {
+               tt->align_mask = 0;
+       } else {
+               /* Instantiate the typedef in the current packing. This may be
+                * further updated if a pointer is added or another alignment
+                * attribute is applied. If pt.align_mask is already non-zero
+                * than an increased alignment via __declspec(aligned(#)) has
+                * been set. */
+               tt->align_mask = max(min(P->align_mask, tt->align_mask),
+                                       pt.align_mask);
+       }
+}
+
+/* this parses a struct or union starting with the optional
+ * name before the opening brace
+ * leaves the type usr value on the stack */
+static int parse_record(struct parser *P, struct cp_ctype *ct)
+{
+       struct token tok;
+       char cur_type_name[MAX_TYPE_NAME_LEN];
+
+       require_token(P, &tok);
+
+       /* name is optional */
+       if (tok.type == TOK_TOKEN) {
+               /* declaration */
+               struct cp_ctype *lct;
+
+               memset(cur_type_name, 0, MAX_TYPE_NAME_LEN);
+               set_struct_type_name(cur_type_name, tok.str, tok.size);
+;
+               /* lookup the name to see if we've seen this type before */
+               lct = ctype_lookup_type(cur_type_name);
+
+               if (!lct) {
+                       /* new type, delay type registration to the end
+                        * of this function */
+               } else {
+                       /* get the exsting declared type */
+                       if (lct->type != ct->type) {
+                               cp_error("type '%s' previously declared as '%s'",
+                                       cur_type_name,
+                                       csym_name(ct_ffi_cs(lct)));
+                       }
+
+                       instantiate_typedef(P, ct, lct);
+               }
+
+               /* if a name is given then we may be at the end of the string
+                * eg for ffi.new('struct foo') */
+               if (!next_token(P, &tok)) {
+                       return 0;
+               }
+       } else {
+               /* create a new unnamed record */
+
+               /*@TODO clean this up after unnamed record support is added */
+               cp_error("TODO: support unnamed record.\n");
+       }
+
+       if (tok.type != TOK_OPEN_CURLY) {
+               /* this may just be a declaration or use of the type as an
+                * argument or member */
+               put_back(P);
+               return 0;
+       }
+
+       if (ct->is_defined) {
+               cp_error("redefinition in line %d", P->line);
+               return 0;
+       }
+
+       if (ct->type == ENUM_TYPE) {
+               parse_enum(P, ct);
+       } else {
+               /* we do a two stage parse, where we parse the content first
+                * and build up the temp user table. We then iterate over that
+                * to calculate the offsets and fill out ct_usr. This is so we
+                * can handle out of order members (eg vtable) and attributes
+                * specified at the end of the struct. */
+               parse_struct(P, ct);
+               /* build symbol for vm */
+               ct->ffi_cs_id = cp_symbol_build_struct(cur_type_name);
+               /* save cp_ctype for parser */
+               cp_ctype_reg_type(cur_type_name, ct);
+       }
+
+       cp_set_defined(ct);
+       return 0;
+}
+
+/* parses single or multi work built in types, and pushes it onto the stack */
+static int parse_type_name(struct parser *P, char *type_name)
+{
+       struct token tok;
+       int flags = 0;
+
+       enum {
+               UNSIGNED = 0x01,
+               SIGNED = 0x02,
+               LONG = 0x04,
+               SHORT = 0x08,
+               INT = 0x10,
+               CHAR = 0x20,
+               LONG_LONG = 0x40,
+               INT8 = 0x80,
+               INT16 = 0x100,
+               INT32 = 0x200,
+               INT64 = 0x400,
+       };
+
+       require_token(P, &tok);
+
+       /* we have to manually decode the builtin types since they can take up
+        * more then one token */
+       for (;;) {
+               if (tok.type != TOK_TOKEN) {
+                       break;
+               } else if (IS_LITERAL(tok, "unsigned")) {
+                       flags |= UNSIGNED;
+               } else if (IS_LITERAL(tok, "signed")) {
+                       flags |= SIGNED;
+               } else if (IS_LITERAL(tok, "short")) {
+                       flags |= SHORT;
+               } else if (IS_LITERAL(tok, "char")) {
+                       flags |= CHAR;
+               } else if (IS_LITERAL(tok, "long")) {
+                       flags |= (flags & LONG) ? LONG_LONG : LONG;
+               } else if (IS_LITERAL(tok, "int")) {
+                       flags |= INT;
+               } else if (IS_LITERAL(tok, "__int8")) {
+                       flags |= INT8;
+               } else if (IS_LITERAL(tok, "__int16")) {
+                       flags |= INT16;
+               } else if (IS_LITERAL(tok, "__int32")) {
+                       flags |= INT32;
+               } else if (IS_LITERAL(tok, "__int64")) {
+                       flags |= INT64;
+               } else if (IS_LITERAL(tok, "register")) {
+                       /* ignore */
+               } else {
+                       break;
+               }
+
+               if (!next_token(P, &tok)) {
+                       break;
+               }
+       }
+
+       if (flags) {
+               put_back(P);
+       }
+
+       if (flags & CHAR) {
+               if (flags & SIGNED) {
+                       strcpy(type_name, "int8_t");
+               } else if (flags & UNSIGNED) {
+                       strcpy(type_name, "uint8_t");
+               } else {
+                       if (((char) -1) > 0) {
+                               strcpy(type_name, "uint8_t");
+                       } else {
+                               strcpy(type_name, "int8_t");
+                       }
+               }
+       } else if (flags & INT8) {
+               strcpy(type_name, (flags & UNSIGNED) ? "uint8_t" : "int8_t");
+       } else if (flags & INT16) {
+               strcpy(type_name, (flags & UNSIGNED) ? "uint16_t" : "int16_t");
+       } else if (flags & INT32) {
+               strcpy(type_name, (flags & UNSIGNED) ? "uint32_t" : "int32_t");
+       } else if (flags & INT64) {
+               strcpy(type_name, (flags & UNSIGNED) ? "uint64_t" : "int64_t");
+       } else if (flags & LONG_LONG) {
+               strcpy(type_name, (flags & UNSIGNED) ? "uint64_t" : "int64_t");
+       } else if (flags & SHORT) {
+#define SHORT_TYPE(u) (sizeof(short) == sizeof(int64_t) ? \
+               u "int64_t" : sizeof(short) == sizeof(int32_t) ? \
+               u "int32_t" : u "int16_t")
+               if (flags & UNSIGNED) {
+                       strcpy(type_name, SHORT_TYPE("u"));
+               } else {
+                       strcpy(type_name, SHORT_TYPE(""));
+               }
+#undef SHORT_TYPE
+       } else if (flags & LONG) {
+#define LONG_TYPE(u) (sizeof(long) == sizeof(int64_t) ? \
+               u "int64_t" : u "int32_t")
+               if (flags & UNSIGNED) {
+                       strcpy(type_name, LONG_TYPE("u"));
+               } else {
+                       strcpy(type_name, LONG_TYPE(""));
+               }
+#undef LONG_TYPE
+       } else if (flags) {
+#define INT_TYPE(u) (sizeof(int) == sizeof(int64_t) ? \
+               u "int64_t" : sizeof(int) == sizeof(int32_t) ? \
+               u "int32_t" : u "int16_t")
+               if (flags & UNSIGNED) {
+                       strcpy(type_name, INT_TYPE("u"));
+               } else {
+                       strcpy(type_name, INT_TYPE(""));
+               }
+#undef INT_TYPE
+       } else {
+               strncpy(type_name, tok.str, tok.size);
+       }
+
+       return 0;
+}
+
+/* parse_attribute parses a token to see if it is an attribute. It may then
+ * parse some following tokens to decode the attribute setting the appropriate
+ * fields in ct. It will return 1 if the token was used (and possibly some
+ * more following it) or 0 if not. If the token was used, the next token must
+ * be retrieved using next_token/require_token. */
+static int parse_attribute(struct parser *P, struct token *tok,
+               struct cp_ctype *ct, struct parser *asmname)
+{
+       if (tok->type != TOK_TOKEN) {
+               return 0;
+       } else if (asmname && (IS_LITERAL(*tok, "__asm__")
+                               || IS_LITERAL(*tok, "__asm"))) {
+               check_token(P, TOK_OPEN_PAREN, NULL,
+                               "unexpected token after __asm__ on line %d",
+                               P->line);
+               *asmname = *P;
+
+               require_token(P, tok);
+               while (tok->type == TOK_STRING) {
+                       require_token(P, tok);
+               }
+
+               if (tok->type != TOK_CLOSE_PAREN) {
+                       cp_error("unexpected token after __asm__ on line %d",
+                                       P->line);
+               }
+               return 1;
+
+       } else if (IS_LITERAL(*tok, "__attribute__")
+                       || IS_LITERAL(*tok, "__declspec")) {
+               int parens = 1;
+               check_token(P, TOK_OPEN_PAREN, NULL,
+                               "expected parenthesis after __attribute__ or "
+                               "__declspec on line %d", P->line);
+
+               for (;;) {
+                       require_token(P, tok);
+                       if (tok->type == TOK_OPEN_PAREN) {
+                               parens++;
+                       } else if (tok->type == TOK_CLOSE_PAREN) {
+                               if (--parens == 0) {
+                                       break;
+                               }
+
+                       } else if (tok->type != TOK_TOKEN) {
+                               /* ignore unknown symbols within parentheses */
+
+                       } else if (IS_LITERAL(*tok, "align") ||
+                                       IS_LITERAL(*tok, "aligned") ||
+                                       IS_LITERAL(*tok, "__aligned__")) {
+                               unsigned align = 0;
+                               require_token(P, tok);
+
+                               switch (tok->type) {
+                               case TOK_CLOSE_PAREN:
+                                       align = ALIGNED_DEFAULT;
+                                       put_back(P);
+                                       break;
+
+                               case TOK_OPEN_PAREN:
+                                       require_token(P, tok);
+
+                                       if (tok->type != TOK_NUMBER) {
+                                               cp_error("expected align(#) "
+                                                       "on line %d", P->line);
+                                       }
+
+                                       switch (tok->integer) {
+                                       case 1: align = 0; break;
+                                       case 2: align = 1; break;
+                                       case 4: align = 3; break;
+                                       case 8: align = 7; break;
+                                       case 16: align = 15; break;
+                                       default:
+                                               cp_error("unsupported align "
+                                                       "size on line %d",
+                                                       P->line);
+                                       }
+
+                                       check_token(P, TOK_CLOSE_PAREN, NULL,
+                                               "expected align(#) on line %d",
+                                               P->line);
+                                       break;
+
+                               default:
+                                       cp_error("expected align(#) on line %d",
+                                                       P->line);
+                               }
+
+                               /* __attribute__(aligned(#)) is only supposed
+                                * to increase alignment */
+                               ct->align_mask = max(align, ct->align_mask);
+
+                       } else if (IS_LITERAL(*tok, "packed")
+                                       || IS_LITERAL(*tok, "__packed__")) {
+                               ct->align_mask = 0;
+                               ct->is_packed = 1;
+
+                       } else if (IS_LITERAL(*tok, "mode")
+                                       || IS_LITERAL(*tok, "__mode__")) {
+
+                               check_token(P, TOK_OPEN_PAREN, NULL,
+                                       "expected mode(MODE) on line %d",
+                                       P->line);
+
+                               require_token(P, tok);
+                               if (tok->type != TOK_TOKEN) {
+                                       cp_error("expected mode(MODE) on line %d",
+                                                       P->line);
+                               }
+
+
+                               struct {char ch; uint16_t v;} a16;
+                               struct {char ch; uint32_t v;} a32;
+                               struct {char ch; uint64_t v;} a64;
+
+                               if (IS_LITERAL(*tok, "QI")
+                                               || IS_LITERAL(*tok, "__QI__")
+                                               || IS_LITERAL(*tok, "byte")
+                                               || IS_LITERAL(*tok, "__byte__")
+                                  ) {
+                                       ct->type = INT8_TYPE;
+                                       ct->base_size = sizeof(uint8_t);
+                                       ct->align_mask = 0;
+
+                               } else if (IS_LITERAL(*tok, "HI")
+                                               || IS_LITERAL(*tok, "__HI__")) {
+                                       ct->type = INT16_TYPE;
+                                       ct->base_size = sizeof(uint16_t);
+                                       ct->align_mask = ALIGNOF(a16);
+
+                               } else if (IS_LITERAL(*tok, "SI")
+                                               || IS_LITERAL(*tok, "__SI__")
+#if defined ARCH_X86 || defined ARCH_ARM
+                                               || IS_LITERAL(*tok, "word")
+                                               || IS_LITERAL(*tok, "__word__")
+                                               || IS_LITERAL(*tok, "pointer")
+                                               || IS_LITERAL(*tok, "__pointer__")
+#endif
+                                         ) {
+                                       ct->type = INT32_TYPE;
+                                       ct->base_size = sizeof(uint32_t);
+                                       ct->align_mask = ALIGNOF(a32);
+
+                               } else if (IS_LITERAL(*tok, "DI")
+                                               || IS_LITERAL(*tok, "__DI__")
+#if defined ARCH_X64
+                                               || IS_LITERAL(*tok, "word")
+                                               || IS_LITERAL(*tok, "__word__")
+                                               || IS_LITERAL(*tok, "pointer")
+                                               || IS_LITERAL(*tok, "__pointer__")
+#endif
+                                         ) {
+                                       ct->type = INT64_TYPE;
+                                       ct->base_size = sizeof(uint64_t);
+                                       ct->align_mask = ALIGNOF(a64);
+
+                               } else {
+                                       cp_error("unexpected mode on line %d",
+                                                       P->line);
+                               }
+
+                               check_token(P, TOK_CLOSE_PAREN, NULL,
+                                       "expected mode(MODE) on line %d", P->line);
+
+                       } else if (IS_LITERAL(*tok, "cdecl")
+                                       || IS_LITERAL(*tok, "__cdecl__")) {
+                               ct->calling_convention = C_CALL;
+
+                       } else if (IS_LITERAL(*tok, "fastcall")
+                                       || IS_LITERAL(*tok, "__fastcall__")) {
+                               ct->calling_convention = FAST_CALL;
+
+                       } else if (IS_LITERAL(*tok, "stdcall")
+                                       || IS_LITERAL(*tok, "__stdcall__")) {
+                               ct->calling_convention = STD_CALL;
+                       }
+                       /* ignore unknown tokens within parentheses */
+               }
+               return 1;
+
+       } else if (IS_LITERAL(*tok, "__cdecl")) {
+               ct->calling_convention = C_CALL;
+               return 1;
+
+       } else if (IS_LITERAL(*tok, "__fastcall")) {
+               ct->calling_convention = FAST_CALL;
+               return 1;
+
+       } else if (IS_LITERAL(*tok, "__stdcall")) {
+               ct->calling_convention = STD_CALL;
+               return 1;
+
+       } else if (IS_LITERAL(*tok, "__extension__")
+                       || IS_LITERAL(*tok, "extern")) {
+               /* ignore */
+               return 1;
+       } else {
+               return 0;
+       }
+}
+
+/* parses from after the opening paranthesis to after the closing parenthesis */
+static void parse_function_arguments(struct parser* P, struct cp_ctype* ct)
+{
+       struct token tok;
+       int args = 0;
+
+       for (;;) {
+               require_token(P, &tok);
+
+               if (tok.type == TOK_CLOSE_PAREN)
+                       break;
+
+               if (args) {
+                       if (tok.type != TOK_COMMA) {
+                               cp_error("unexpected token in function "
+                                               "argument %d on line %d",
+                                               args, P->line);
+                       }
+                       require_token(P, &tok);
+               }
+
+               if (tok.type == TOK_VA_ARG) {
+                       ct->has_var_arg = true;
+                       check_token(P, TOK_CLOSE_PAREN, "",
+                                       "unexpected token after ... in "
+                                       "function on line %d",
+                                       P->line);
+                       break;
+               } else if (tok.type == TOK_TOKEN) {
+                       struct cp_ctype at;
+
+                       put_back(P);
+                       parse_type(P, &at);
+                       parse_argument(P, &at, NULL, NULL);
+
+                       /* array arguments are just treated as their
+                        * base pointer type */
+                       at.is_array = 0;
+
+                       /* check for the c style int func(void) and error
+                        * on other uses of arguments of type void */
+                       if (at.type == VOID_TYPE && at.pointers == 0) {
+                               if (args) {
+                                       cp_error("can't have argument of type "
+                                                       "void on line %d",
+                                                       P->line);
+                               }
+
+                               check_token(P, TOK_CLOSE_PAREN, "",
+                                       "unexpected void in function on line %d",
+                                       P->line);
+                               break;
+                       }
+                       cp_push_ctype(&at);
+                       args++;
+               } else {
+                       cp_error("unexpected token in function argument %d "
+                                       "on line %d", args+1, P->line);
+               }
+       }
+}
+
+static int max_bitfield_size(int type)
+{
+       switch (type) {
+       case BOOL_TYPE:
+               return 1;
+       case INT8_TYPE:
+               return 8;
+       case INT16_TYPE:
+               return 16;
+       case INT32_TYPE:
+       case ENUM_TYPE:
+               return 32;
+       case INT64_TYPE:
+               return 64;
+       default:
+               return -1;
+       }
+}
+
+static struct cp_ctype *parse_argument2(struct parser *P, struct cp_ctype *ct,
+               struct token *name, struct parser *asmname);
+
+/* parses from after the first ( in a function declaration or function pointer
+ * can be one of:
+ * void foo(...) before ...
+ * void (foo)(...) before foo
+ * void (* <>)(...) before <> which is the inner type */
+static struct cp_ctype *parse_function(struct parser *P, struct cp_ctype *ct,
+                               struct token *name, struct parser *asmname)
+{
+       /* We have a function pointer or a function. The usr table will
+        * get replaced by the canonical one (if there is one) in
+        * find_canonical_usr after all the arguments and returns have
+        * been parsed. */
+       struct token tok;
+       struct cp_ctype *ret = ct;
+
+       cp_push_ctype(ct);
+
+       memset(ct, 0, sizeof(*ct));
+       ct->base_size = sizeof(void (*)());
+       ct->align_mask = min(FUNCTION_ALIGN_MASK, P->align_mask);
+       ct->type = FUNCTION_TYPE;
+       ct->is_defined = 1;
+
+       if (name->type == TOK_NIL) {
+               for (;;) {
+                       require_token(P, &tok);
+
+                       if (tok.type == TOK_STAR) {
+                               if (ct->type == FUNCTION_TYPE) {
+                                       ct->type = FUNCTION_PTR_TYPE;
+                               } else {
+                                       increase_ptr_deref_level(P, ct);
+                               }
+                       } else if (parse_attribute(P, &tok, ct, asmname)) {
+                               /* parse_attribute sets the appropriate fields */
+                       } else {
+                               /* call parse_argument to handle the inner
+                                * contents e.g. the <> in "void (* <>)
+                                * (...)". Note that the inner contents can
+                                * itself be a function, a function ptr,
+                                * array, etc (e.g. "void (*signal(int sig,
+                                * void (*func)(int)))(int)" ). */
+                               cp_error("TODO: inner function not supported for now.");
+                               put_back(P);
+                               ct = parse_argument2(P, ct, name, asmname);
+                               break;
+                       }
+               }
+
+               check_token(P, TOK_CLOSE_PAREN, NULL,
+                       "unexpected token in function on line %d", P->line);
+               check_token(P, TOK_OPEN_PAREN, NULL,
+                       "unexpected token in function on line %d", P->line);
+       }
+
+       parse_function_arguments(P, ct);
+
+       /*@TODO support for inner function  24.11 2013 (houqp)*/
+       /* if we have an inner function then set the outer function ptr as its
+        * return type and return the inner function
+        * e.g. for void (* <signal(int, void (*)(int))> )(int) inner is
+        * surrounded by <>, return type is void (*)(int) */
+
+       return ret;
+}
+
+static struct cp_ctype *parse_argument2(struct parser *P, struct cp_ctype *ct,
+                               struct token *name, struct parser *asmname)
+{
+       struct token tok;
+
+       for (;;) {
+               if (!next_token(P, &tok)) {
+                       /* we've reached the end of the string */
+                       break;
+               } else if (tok.type == TOK_STAR) {
+                       increase_ptr_deref_level(P, ct);
+
+                       /* __declspec(align(#)) may come before the type in a
+                        * member */
+                       if (!ct->is_packed) {
+                               ct->align_mask = max(min(PTR_ALIGN_MASK, P->align_mask),
+                                                       ct->align_mask);
+                       }
+               } else if (tok.type == TOK_REFERENCE) {
+                       cp_error("NYI: c++ reference types");
+                       return 0;
+               } else if (parse_attribute(P, &tok, ct, asmname)) {
+                       /* parse attribute has filled out appropriate fields in type */
+
+               } else if (tok.type == TOK_OPEN_PAREN) {
+                       ct = parse_function(P, ct, name, asmname);
+               } else if (tok.type == TOK_OPEN_SQUARE) {
+                       /* array */
+                       if (ct->pointers == POINTER_MAX) {
+                               cp_error("maximum number of pointer derefs "
+                                       "reached - use a struct to break up "
+                                       "the pointers");
+                       }
+                       ct->is_array = 1;
+                       ct->pointers++;
+                       ct->const_mask <<= 1;
+                       require_token(P, &tok);
+
+                       if (ct->pointers == 1 && !ct->is_defined) {
+                               cp_error("array of undefined type on line %d",
+                                               P->line);
+                       }
+
+                       if (ct->is_variable_struct || ct->is_variable_array) {
+                               cp_error("can't have an array of a variably "
+                                       "sized type on line %d", P->line);
+                       }
+
+                       if (tok.type == TOK_QUESTION) {
+                               ct->is_variable_array = 1;
+                               ct->variable_increment = (ct->pointers > 1) ?
+                                               sizeof(void*) : ct->base_size;
+                               check_token(P, TOK_CLOSE_SQUARE, "",
+                                       "invalid character in array on line %d",
+                                       P->line);
+
+                       } else if (tok.type == TOK_CLOSE_SQUARE) {
+                               ct->array_size = 0;
+
+                       } else if (tok.type == TOK_TOKEN && IS_RESTRICT(tok)) {
+                               /* odd gcc extension foo[__restrict] for arguments */
+                               ct->array_size = 0;
+                               check_token(P, TOK_CLOSE_SQUARE, "",
+                                       "invalid character in array on line %d",
+                                       P->line);
+                       } else {
+                               int64_t asize;
+                               put_back(P);
+                               asize = calculate_constant(P);
+                               if (asize < 0) {
+                                       cp_error("array size can not be "
+                                               "negative on line %d", P->line);
+                                       return 0;
+                               }
+                               ct->array_size = (size_t) asize;
+                               check_token(P, TOK_CLOSE_SQUARE, "",
+                                       "invalid character in array on line %d",
+                                       P->line);
+                       }
+
+               } else if (tok.type == TOK_COLON) {
+                       int64_t bsize = calculate_constant(P);
+
+                       if (ct->pointers || bsize < 0
+                                       || bsize > max_bitfield_size(ct->type)) {
+                               cp_error("invalid bitfield on line %d", P->line);
+                       }
+
+                       ct->is_bitfield = 1;
+                       ct->bit_size = (unsigned) bsize;
+
+               } else if (tok.type != TOK_TOKEN) {
+                       /* we've reached the end of the declaration */
+                       put_back(P);
+                       break;
+
+               } else if (IS_CONST(tok)) {
+                       ct->const_mask |= 1;
+
+               } else if (IS_VOLATILE(tok) || IS_RESTRICT(tok)) {
+                       /* ignored for now */
+
+               } else {
+                       *name = tok;
+               }
+       }
+
+       return ct;
+}
+
+
+
+/* parses after the main base type of a typedef, function argument or
+ * struct/union member
+ * eg for const void* bar[3] the base type is void with the subtype so far of
+ * const, this parses the "* bar[3]" and updates the type argument
+ *
+ * type must be as filled out by parse_type
+ *
+ * pushes the updated user value on the top of the stack
+ */
+void parse_argument(struct parser *P, struct cp_ctype *ct, struct token *pname,
+                       struct parser *asmname)
+{
+       struct token tok, name;
+
+       memset(&name, 0, sizeof(name));
+       parse_argument2(P, ct, &name, asmname);
+
+       for (;;) {
+               if (!next_token(P, &tok)) {
+                       break;
+               } else if (parse_attribute(P, &tok, ct, asmname)) {
+                       /* parse_attribute sets the appropriate fields */
+               } else {
+                       put_back(P);
+                       break;
+               }
+       }
+
+       if (pname) {
+               *pname = name;
+       }
+}
+
+static void parse_typedef(struct parser *P)
+{
+       struct token tok;
+       struct cp_ctype base_type;
+       char typedef_name[MAX_TYPE_NAME_LEN];
+
+       parse_type(P, &base_type);
+
+       for (;;) {
+               struct cp_ctype arg_type = base_type;
+               struct token name;
+
+               memset(&name, 0, sizeof(name));
+
+               parse_argument(P, &arg_type, &name, NULL);
+
+               if (!name.size) {
+                       cp_error("Can't have a typedef without a name on line %d",
+                                       P->line);
+               } else if (arg_type.is_variable_array) {
+                       cp_error("Can't typedef a variable length array on line %d",
+                                       P->line);
+               }
+
+               memset(typedef_name, 0, sizeof(typedef_name));
+               strncpy(typedef_name, name.str, name.size);
+               /* link typedef name with ctype for parser */
+               cp_ctype_reg_type(typedef_name, &arg_type);
+
+               require_token(P, &tok);
+
+               if (tok.type == TOK_SEMICOLON) {
+                       break;
+               } else if (tok.type != TOK_COMMA) {
+                       cp_error("Unexpected character in typedef on line %d",
+                                       P->line);
+               }
+       }
+}
+
+#define END 0
+#define PRAGMA_POP 1
+
+static int parse_root(struct parser *P)
+{
+       struct token tok;
+
+       while (next_token(P, &tok)) {
+               /* we can have:
+                * struct definition
+                * enum definition
+                * union definition
+                * struct/enum/union declaration
+                * typedef
+                * function declaration
+                * pragma pack
+                */
+
+               if (tok.type == TOK_SEMICOLON) {
+                       /* empty semicolon in root continue on */
+
+               } else if (tok.type == TOK_POUND) {
+
+                       check_token(P, TOK_TOKEN, "pragma",
+                               "unexpected pre processor directive on line %d",
+                               P->line);
+                       check_token(P, TOK_TOKEN, "pack",
+                               "unexpected pre processor directive on line %d",
+                               P->line);
+                       check_token(P, TOK_OPEN_PAREN, "",
+                               "invalid pack directive on line %d",
+                               P->line);
+                       require_token(P, &tok);
+
+                       if (tok.type == TOK_NUMBER) {
+                               if (tok.integer != 1 && tok.integer != 2
+                                               && tok.integer != 4
+                                               && tok.integer != 8
+                                               && tok.integer != 16) {
+                                       cp_error("pack directive with invalid "
+                                                       "pack size on line %d",
+                                                       P->line);
+                                       return 0;
+                               }
+
+                               P->align_mask = (unsigned) (tok.integer - 1);
+                               check_token(P, TOK_CLOSE_PAREN, "",
+                                       "invalid pack directive on line %d",
+                                       P->line);
+                       } else if (tok.type == TOK_TOKEN && IS_LITERAL(tok, "push")) {
+                               /*int line = P->line;*/
+                               unsigned previous_alignment = P->align_mask;
+
+                               check_token(P, TOK_CLOSE_PAREN, "",
+                                       "invalid pack directive on line %d",
+                                       P->line);
+
+                               if (parse_root(P) != PRAGMA_POP) {
+                                       cp_error("reached end of string "
+                                               "without a pragma pop to "
+                                               "match the push on line %d",
+                                               P->line);
+                                       return 0;
+                               }
+
+                               P->align_mask = previous_alignment;
+
+                       } else if (tok.type == TOK_TOKEN && IS_LITERAL(tok, "pop")) {
+                               check_token(P, TOK_CLOSE_PAREN, "",
+                                       "invalid pack directive on line %d",
+                                               P->line);
+                               return PRAGMA_POP;
+                       } else {
+                               cp_error("invalid pack directive on line %d",
+                                               P->line);
+                               return 0;
+                       }
+               } else if (tok.type != TOK_TOKEN) {
+                       cp_error("unexpected character on line %d", P->line);
+                       return 0;
+               } else if (IS_LITERAL(tok, "__extension__")) {
+                       /* ignore */
+                       continue;
+               } else if (IS_LITERAL(tok, "extern")) {
+                       /* ignore extern as data and functions can only be
+                        * extern */
+                       continue;
+               } else if (IS_LITERAL(tok, "typedef")) {
+                       parse_typedef(P);
+               } else if (IS_LITERAL(tok, "static")) {
+                       /*@TODO we haven't tested static so far */
+                       cp_error("TODO: support static keyword.\n");
+               } else {
+                       /* type declaration, type definition, or function
+                        * declaration */
+                       struct cp_ctype type;
+                       struct token name;
+                       struct parser asmname;
+
+                       memset(&name, 0, sizeof(name));
+                       memset(&asmname, 0, sizeof(asmname));
+
+                       put_back(P);
+                       parse_type(P, &type);
+
+                       for (;;) {
+                               parse_argument(P, &type, &name, &asmname);
+
+                               if (name.size) {
+                                       /* global/function declaration */
+                                       cp_symbol_build_func(&type, name.str, name.size);
+                                       /* @TODO asmname is not used for now
+                                        * since we are not supporting __asm__
+                                        * as this point.
+                                        * might need to bind it with function
+                                        * name later. */
+                               } else {
+                                       /* type declaration/definition -
+                                        * already been processed */
+                               }
+                               require_token(P, &tok);
+
+                               if (tok.type == TOK_SEMICOLON) {
+                                       break;
+                               } else if (tok.type != TOK_COMMA) {
+                                       cp_error("missing semicolon on line %d",
+                                                       P->line);
+                               }
+                       }
+               }
+       }
+
+       return END;
+}
+
+static int64_t calculate_constant2(struct parser *P, struct token *tok);
+
+/* () */
+static int64_t calculate_constant1(struct parser *P, struct token *tok)
+{
+       int64_t ret;
+
+       if (tok->type == TOK_NUMBER) {
+               ret = tok->integer;
+               next_token(P, tok);
+               return ret;
+
+       } else if (tok->type == TOK_TOKEN) {
+               /* look up name in constants table */
+               cp_error("TODO: support name lookup in constant table\n");
+               next_token(P, tok);
+               return ret;
+
+       } else if (tok->type == TOK_OPEN_PAREN) {
+               struct parser before_cast = *P;
+               cp_error("TODO: handle open parent token in constant1\n");
+               *P = before_cast;
+               ret = calculate_constant(P);
+
+               require_token(P, tok);
+               if (tok->type != TOK_CLOSE_PAREN) {
+                       cp_error("error whilst parsing constant at line %d",
+                                       P->line);
+               }
+
+               next_token(P, tok);
+               return ret;
+       } else {
+               cp_error("unexpected token whilst parsing constant at line %d",
+                               P->line);
+               return 0;
+       }
+}
+
+/* ! and ~, unary + and -, and sizeof */
+static int64_t calculate_constant2(struct parser *P, struct token *tok)
+{
+       if (tok->type == TOK_LOGICAL_NOT) {
+               require_token(P, tok);
+               return !calculate_constant2(P, tok);
+
+       } else if (tok->type == TOK_BITWISE_NOT) {
+               require_token(P, tok);
+               return ~calculate_constant2(P, tok);
+
+       } else if (tok->type == TOK_PLUS) {
+               require_token(P, tok);
+               return calculate_constant2(P, tok);
+
+       } else if (tok->type == TOK_MINUS) {
+               require_token(P, tok);
+               return -calculate_constant2(P, tok);
+
+       } else if (tok->type == TOK_TOKEN &&
+                       (IS_LITERAL(*tok, "sizeof")
+                        || IS_LITERAL(*tok, "alignof")
+                        || IS_LITERAL(*tok, "__alignof__")
+                        || IS_LITERAL(*tok, "__alignof"))) {
+               cp_error("TODO: support sizeof\n");
+               bool issize = IS_LITERAL(*tok, "sizeof");
+               struct cp_ctype type;
+
+               require_token(P, tok);
+               if (tok->type != TOK_OPEN_PAREN) {
+                       cp_error("invalid sizeof at line %d", P->line);
+               }
+
+               parse_type(P, &type);
+               parse_argument(P, &type, NULL, NULL);
+
+               require_token(P, tok);
+               if (tok->type != TOK_CLOSE_PAREN) {
+                       cp_error("invalid sizeof at line %d", P->line);
+               }
+
+               next_token(P, tok);
+
+               return issize ? ctype_size(&type) : type.align_mask + 1;
+
+       } else {
+               return calculate_constant1(P, tok);
+       }
+}
+
+/* binary * / and % (left associative) */
+static int64_t calculate_constant3(struct parser *P, struct token *tok)
+{
+       int64_t left = calculate_constant2(P, tok);
+
+       for (;;) {
+               if (tok->type == TOK_MULTIPLY) {
+                       require_token(P, tok);
+                       left *= calculate_constant2(P, tok);
+
+               } else if (tok->type == TOK_DIVIDE) {
+                       require_token(P, tok);
+                       left /= calculate_constant2(P, tok);
+
+               } else if (tok->type == TOK_MODULUS) {
+                       require_token(P, tok);
+                       left %= calculate_constant2(P, tok);
+
+               } else {
+                       return left;
+               }
+       }
+}
+
+/* binary + and - (left associative) */
+static int64_t calculate_constant4(struct parser *P, struct token *tok)
+{
+       int64_t left = calculate_constant3(P, tok);
+
+       for (;;) {
+               if (tok->type == TOK_PLUS) {
+                       require_token(P, tok);
+                       left += calculate_constant3(P, tok);
+
+               } else if (tok->type == TOK_MINUS) {
+                       require_token(P, tok);
+                       left -= calculate_constant3(P, tok);
+
+               } else {
+                       return left;
+               }
+       }
+}
+
+/* binary << and >> (left associative) */
+static int64_t calculate_constant5(struct parser *P, struct token *tok)
+{
+       int64_t left = calculate_constant4(P, tok);
+
+       for (;;) {
+               if (tok->type == TOK_LEFT_SHIFT) {
+                       require_token(P, tok);
+                       left <<= calculate_constant4(P, tok);
+
+               } else if (tok->type == TOK_RIGHT_SHIFT) {
+                       require_token(P, tok);
+                       left >>= calculate_constant4(P, tok);
+
+               } else {
+                       return left;
+               }
+       }
+}
+
+/* binary <, <=, >, and >= (left associative) */
+static int64_t calculate_constant6(struct parser *P, struct token *tok)
+{
+       int64_t left = calculate_constant5(P, tok);
+
+       for (;;) {
+               if (tok->type == TOK_LESS) {
+                       require_token(P, tok);
+                       left = (left < calculate_constant5(P, tok));
+
+               } else if (tok->type == TOK_LESS_EQUAL) {
+                       require_token(P, tok);
+                       left = (left <= calculate_constant5(P, tok));
+
+               } else if (tok->type == TOK_GREATER) {
+                       require_token(P, tok);
+                       left = (left > calculate_constant5(P, tok));
+
+               } else if (tok->type == TOK_GREATER_EQUAL) {
+                       require_token(P, tok);
+                       left = (left >= calculate_constant5(P, tok));
+
+               } else {
+                       return left;
+               }
+       }
+}
+
+/* binary ==, != (left associative) */
+static int64_t calculate_constant7(struct parser *P, struct token *tok)
+{
+       int64_t left = calculate_constant6(P, tok);
+
+       for (;;) {
+               if (tok->type == TOK_EQUAL) {
+                       require_token(P, tok);
+                       left = (left == calculate_constant6(P, tok));
+
+               } else if (tok->type == TOK_NOT_EQUAL) {
+                       require_token(P, tok);
+                       left = (left != calculate_constant6(P, tok));
+
+               } else {
+                       return left;
+               }
+       }
+}
+
+/* binary & (left associative) */
+static int64_t calculate_constant8(struct parser *P, struct token *tok)
+{
+       int64_t left = calculate_constant7(P, tok);
+
+       for (;;) {
+               if (tok->type == TOK_BITWISE_AND) {
+                       require_token(P, tok);
+                       left = (left & calculate_constant7(P, tok));
+
+               } else {
+                       return left;
+               }
+       }
+}
+
+/* binary ^ (left associative) */
+static int64_t calculate_constant9(struct parser *P, struct token *tok)
+{
+       int64_t left = calculate_constant8(P, tok);
+
+       for (;;) {
+               if (tok->type == TOK_BITWISE_XOR) {
+                       require_token(P, tok);
+                       left = (left ^ calculate_constant8(P, tok));
+
+               } else {
+                       return left;
+               }
+       }
+}
+
+/* binary | (left associative) */
+static int64_t calculate_constant10(struct parser *P, struct token *tok)
+{
+       int64_t left = calculate_constant9(P, tok);
+
+       for (;;) {
+               if (tok->type == TOK_BITWISE_OR) {
+                       require_token(P, tok);
+                       left = (left | calculate_constant9(P, tok));
+
+               } else {
+                       return left;
+               }
+       }
+}
+
+/* binary && (left associative) */
+static int64_t calculate_constant11(struct parser *P, struct token *tok)
+{
+       int64_t left = calculate_constant10(P, tok);
+
+       for (;;) {
+               if (tok->type == TOK_LOGICAL_AND) {
+                       require_token(P, tok);
+                       left = (left && calculate_constant10(P, tok));
+
+               } else {
+                       return left;
+               }
+       }
+}
+
+/* binary || (left associative) */
+static int64_t calculate_constant12(struct parser *P, struct token *tok)
+{
+       int64_t left = calculate_constant11(P, tok);
+
+       for (;;) {
+               if (tok->type == TOK_LOGICAL_OR) {
+                       require_token(P, tok);
+                       left = (left || calculate_constant11(P, tok));
+
+               } else {
+                       return left;
+               }
+       }
+}
+
+/* ternary ?: (right associative) */
+static int64_t calculate_constant13(struct parser *P, struct token *tok)
+{
+       int64_t left = calculate_constant12(P, tok);
+
+       if (tok->type == TOK_QUESTION) {
+               int64_t middle, right;
+               require_token(P, tok);
+               middle = calculate_constant13(P, tok);
+               if (tok->type != TOK_COLON) {
+                       cp_error("invalid ternery (? :) in constant on line %d",
+                                       P->line);
+               }
+               require_token(P, tok);
+               right = calculate_constant13(P, tok);
+               return left ? middle : right;
+
+       } else {
+               return left;
+       }
+}
+
+int64_t calculate_constant(struct parser* P)
+{
+       struct token tok;
+       int64_t ret;
+       require_token(P, &tok);
+       ret = calculate_constant13(P, &tok);
+
+       if (tok.type != TOK_NIL) {
+               put_back(P);
+       }
+
+       return ret;
+}
+
+int ffi_cdef(const char *s)
+{
+       struct parser P;
+
+       memset(&P, 0, sizeof(struct parser));
+       P.line = 1;
+       P.prev = P.next = s;
+       P.align_mask = DEFAULT_ALIGN_MASK;
+
+       if (parse_root(&P) == PRAGMA_POP) {
+               cp_error("pragma pop without an associated push on line %d",
+                               P.line);
+       }
+
+       return 0;
+}
+
+void ffi_cparser_init(void)
+{
+       cp_ctype_init();
+}
+
+void ffi_cparser_free(void)
+{
+       cp_ctype_free();
+}
diff --git a/drivers/staging/ktap/userspace/ffi/ctype.c b/drivers/staging/ktap/userspace/ffi/ctype.c
new file mode 100644 (file)
index 0000000..40d1d9d
--- /dev/null
@@ -0,0 +1,551 @@
+#include "../../include/ktap_types.h"
+#include "../../include/ktap_opcodes.h"
+#include "../ktapc.h"
+#include "../cparser.h"
+
+
+/* for ktap vm */
+cp_csymbol_state csym_state;
+
+#define cs_nr (csym_state.cs_nr)
+#define cs_arr_size (csym_state.cs_arr_size)
+#define cs_arr (csym_state.cs_arr)
+
+csymbol *cp_id_to_csym(int id)
+{
+       return &cs_arr[id];
+}
+
+
+typedef struct cp_ctype_entry {
+       char name[MAX_TYPE_NAME_LEN];
+       struct cp_ctype ct;
+} cp_ctype_entry;
+
+#define DEFAULT_CTYPE_ARR_SIZE 100
+static int cte_nr;
+static int cte_arr_size;
+static cp_ctype_entry *cte_arr;
+
+
+/* stack to help maintain state during parsing */
+typedef struct cp_ctype_stack {
+       int size;
+       int top;
+       cp_ctype_entry *stack;
+} ctype_stack;
+
+
+static ctype_stack cts;
+
+#define ct_stack(id) (&(cts.stack[id]))
+#define ct_stack_ct(id) (&(cts.stack[id].ct))
+
+
+
+int cp_ctype_reg_csymbol(csymbol *cs);
+
+
+size_t ctype_size(const struct cp_ctype *ct)
+{
+       if (ct->pointers - ct->is_array) {
+               return sizeof(void*) * (ct->is_array ? ct->array_size : 1);
+
+       } else if (!ct->is_defined || ct->type == VOID_TYPE) {
+               cp_error("can't calculate size of an undefined type");
+               return 0;
+       } else if (ct->variable_size_known) {
+               assert(ct->is_variable_struct && !ct->is_array);
+               return ct->base_size + ct->variable_increment;
+       } else if (ct->is_variable_array || ct->is_variable_struct) {
+               cp_error("internal error: calc size of variable type with "
+                               "unknown size");
+               return 0;
+       } else {
+               return ct->base_size * (ct->is_array ? ct->array_size : 1);
+       }
+}
+
+#define MAX_STACK_SIZE 100
+int ctype_stack_grow(int size)
+{
+       struct cp_ctype_entry *new_st;
+
+       assert(cts.size + size < MAX_STACK_SIZE);
+
+       new_st = realloc(cts.stack, (cts.size+size)*sizeof(cp_ctype_entry));
+       if (new_st)
+               cts.stack = new_st;
+       else
+               return -1;
+
+       cts.size += size;
+
+       return size;
+}
+
+int ctype_stack_free_space()
+{
+       return cts.size - cts.top;
+}
+
+void ctype_stack_reset()
+{
+       cts.top = 0;
+}
+
+/* push ctype to stack, create new csymbol if needed */
+void cp_push_ctype_with_name(struct cp_ctype *ct, const char *name, int nlen)
+{
+       int i;
+       struct cp_ctype *nct;
+
+       if (ctype_stack_free_space() < 1)
+               ctype_stack_grow(4);
+
+       /* we have to check pointer here because does type lookup by name
+        * before parsing '*', and for pointers, ct will always be the
+        * original type */
+       if (ct->pointers) {
+               for (i = 0; i < cte_nr; i++) {
+                       nct = &(cte_arr[i].ct);
+                       if (nct->type == ct->type &&
+                                       nct->pointers == ct->pointers) {
+                               break;
+                       }
+               }
+
+               if (i == cte_nr) {
+                       /* pointer type not found
+                        * create a new pointer symbol for this type */
+                       /* associate ctype with new csymbol */
+                       ct->ffi_cs_id = cp_symbol_build_pointer(ct);
+                       /* register wit new pointer name */
+                       cp_ctype_reg_type(csym_name(ct_ffi_cs(ct)), ct);
+               } else {
+                       /* pointer type already registered, reinstantiate ct */
+                       *ct = cte_arr[i].ct;
+               }
+       }
+       memset(ct_stack(cts.top), 0, sizeof(cp_ctype_entry));
+       ct_stack(cts.top)->ct = *ct;
+       if (name)
+               strncpy(ct_stack(cts.top)->name, name, nlen);
+       cts.top++;
+}
+
+void cp_push_ctype(struct cp_ctype *ct)
+{
+       cp_push_ctype_with_name(ct, NULL, 0);
+}
+
+void cp_set_defined(struct cp_ctype *ct)
+{
+       ct->is_defined = 1;
+
+       /* @TODO: update ctypes and cdatas that were created before the
+        * definition came in */
+}
+
+void cp_ctype_dump_stack()
+{
+       int i;
+       struct cp_ctype *ct;
+
+       printf("---------------------------\n");
+       printf("start of ctype stack (%d) dump: \n", cts.top);
+       for (i = 0; i < cts.top; i++) {
+               ct = ct_stack_ct(i);
+               printf("[%d] -> cp_ctype: %d, sym_type: %d, pointer: %d "
+                       "symbol_id: %d, name: %s\n",
+                       i, ct->type,
+                       csym_type(ct_ffi_cs(ct)), ct->pointers, ct->ffi_cs_id,
+                       ct_stack(i)->name);
+       }
+}
+
+int ctype_reg_table_grow()
+{
+       cp_ctype_entry *new_arr;
+
+       new_arr = realloc(cte_arr, sizeof(cp_ctype_entry)*cte_arr_size*2);
+       if (!new_arr)
+               cp_error("failed to allocate memory for ctype array\n");
+
+       cte_arr_size = cte_arr_size * 2;
+       return 0;
+}
+
+/* return index in csymbol array */
+int cp_ctype_reg_csymbol(csymbol *cs)
+{
+       if (cs_nr >= cs_arr_size) {
+               cs_arr_size *= 2;
+               cs_arr = realloc(cs_arr, cs_arr_size*sizeof(csymbol));
+               if (!cs_arr)
+                       cp_error("failed to extend csymbol array!\n");
+       }
+
+       cs_arr[cs_nr] = *cs;
+       cs_nr++;
+
+       return cs_nr-1;
+}
+
+void __cp_symbol_dump_struct(csymbol *cs)
+{
+       int i;
+       csymbol *ncs;
+       csymbol_struct *stcs = csym_struct(cs);
+
+       printf("=== [%s] definition ==================\n", csym_name(cs));
+       for (i = 0; i < stcs->memb_nr; i++) {
+               printf("\t(%d) ", i);
+               printf("csym_id: %d, ", stcs->members[i].id);
+               ncs = &cs_arr[stcs->members[i].id];
+               printf("name: %s, ffi_ctype: %d, %s\n",
+                       stcs->members[i].name, ncs->type, csym_name(ncs));
+       }
+}
+
+void cp_symbol_dump_struct(int id)
+{
+       __cp_symbol_dump_struct(&cs_arr[id]);
+}
+
+int cp_symbol_build_struct(const char *stname)
+{
+       int i, id, memb_size;
+       cp_ctype_entry *cte;
+       csymbol nst;
+       struct_member *st_membs;
+       csymbol_struct *stcs;
+
+       if (cts.top <= 0 || !stname) {
+               cp_error("invalid struct definition.\n");
+       }
+
+       memb_size = cts.top;
+       st_membs = malloc(memb_size*sizeof(struct_member));
+       if (!st_membs)
+               cp_error("failed to allocate memory for struct members.\n");
+       memset(st_membs, 0, memb_size*sizeof(struct_member));
+
+       nst.type = FFI_STRUCT;
+       strcpy(nst.name, stname);
+
+       stcs = csym_struct(&nst);
+       stcs->memb_nr = memb_size;
+       stcs->members = st_membs;
+
+       for (i = 0; i < memb_size; i++) {
+               assert(i < cts.top);
+               cte = ct_stack(i);
+               if (cte->name)
+                       strcpy(st_membs[i].name, cte->name);
+               st_membs[i].id = ct_stack_ct(i)->ffi_cs_id;
+       }
+
+       id = cp_ctype_reg_csymbol(&nst);
+
+       ctype_stack_reset();
+
+       return id;
+}
+
+/* build pointer symbol from given csymbol */
+int cp_symbol_build_pointer(struct cp_ctype *ct)
+{
+       int id, ret;
+       csymbol ncspt;
+       csymbol *ref_cs = ct_ffi_cs(ct);
+
+       /* TODO: Check correctness of multi-level pointer 24.11.2013(unihorn) */
+       memset(&ncspt, 0, sizeof(csymbol));
+       ncspt.type = FFI_PTR;
+       ret = sprintf(ncspt.name, "%s *", csym_name(ref_cs));
+       assert(ret < MAX_TYPE_NAME_LEN);
+
+       csym_set_ptr_deref_id(&ncspt, ct->ffi_cs_id);
+       id = cp_ctype_reg_csymbol(&ncspt);
+
+       return id;
+}
+
+void __cp_symbol_dump_func(csymbol *cs)
+{
+       int i;
+       csymbol *ncs;
+       csymbol_func *fcs = csym_func(cs);
+
+       printf("=== [%s] function definition =============\n", csym_name(cs));
+       ncs = cp_csymf_ret(fcs);
+       printf("address: %p\n", fcs->addr);
+       printf("return type: \n");
+       printf("\tcsym_id: %d, ffi_ctype: %d, %s\n",
+                       fcs->ret_id, ncs->type, csym_name(ncs));
+       printf("args type (%d): \n", fcs->arg_nr);
+       for (i = 0; i < csymf_arg_nr(fcs); i++) {
+           printf("\t (%d) ", i);
+           printf("csym_id: %d, ", fcs->arg_ids[i]);
+           ncs = cp_csymf_arg(fcs, i);
+           printf("ffi_ctype: %d, %s\n", ncs->type, csym_name(ncs));
+       }
+}
+
+void cp_symbol_dump_func(int id)
+{
+       __cp_symbol_dump_func(&cs_arr[id]);
+}
+
+int cp_symbol_build_func(struct cp_ctype *type, const char *fname, int fn_size)
+{
+       int i = 1, arg_nr, id;
+       int *argsym_id_arr;
+       csymbol nfcs;
+       csymbol_func *fcs;
+
+       if (cts.top == 0 || fn_size < 0 || !fname) {
+               cp_error("invalid function definition.\n");
+       }
+
+       argsym_id_arr = NULL;
+       memset(&nfcs, 0, sizeof(csymbol));
+       csym_type(&nfcs) = FFI_FUNC;
+
+       strncpy(csym_name(&nfcs), fname, fn_size);
+
+       fcs = csym_func(&nfcs);
+       fcs->has_var_arg = type->has_var_arg;
+       /* Type needed for handling variable args handle */
+       if (fcs->has_var_arg && !ctype_lookup_type("void *"))
+               cp_symbol_build_pointer(ctype_lookup_type("void"));
+
+       /* Fetch start address of function  */
+       fcs->addr = (void *)find_kernel_symbol(csym_name(&nfcs));
+       if (!fcs->addr)
+               cp_error("wrong function address for %s\n", csym_name(&nfcs));
+
+       /* bottom of the stack is return type */
+       fcs->ret_id = ct_stack_ct(0)->ffi_cs_id;
+
+       /* the rest is argument type */
+       if (cts.top == 1) {
+               /* function takes no argument */
+               arg_nr = 0;
+       } else {
+               arg_nr = cts.top - 1;
+               argsym_id_arr = malloc(arg_nr * sizeof(int));
+               if (!argsym_id_arr)
+                       cp_error("failed to allocate memory for function args.\n");
+               for (i = 0; i < arg_nr; i++) {
+                       argsym_id_arr[i] = ct_stack_ct(i+1)->ffi_cs_id;
+               }
+       }
+       fcs->arg_nr = arg_nr;
+       fcs->arg_ids = argsym_id_arr;
+
+       id = cp_ctype_reg_csymbol(&nfcs);
+
+       /* clear stack since we have consumed all the ctypes */
+       ctype_stack_reset();
+
+       return id;
+}
+
+struct cp_ctype *cp_ctype_reg_type(char *name, struct cp_ctype *ct)
+{
+       if (cte_nr >= cte_arr_size)
+               ctype_reg_table_grow();
+
+       memset(cte_arr[cte_nr].name, 0, MAX_TYPE_NAME_LEN);
+       strcpy(cte_arr[cte_nr].name, name);
+
+       cte_arr[cte_nr].ct = *ct;
+       cte_nr++;
+
+       return &(cte_arr[cte_nr-1].ct);
+}
+
+#if 0
+/* TODO: used for size calculation */
+static ffi_type ffi_int_type(ktap_state *ks, int size, bool sign)
+{
+       switch(size) {
+       case 1:
+               if (!sign)
+                       return FFI_UINT8;
+               else
+                       return FFI_INT8;
+       case 2:
+               if (!sign)
+                       return FFI_UINT16;
+               else
+                       return FFI_INT16;
+       case 4:
+               if (!sign)
+                       return FFI_UINT32;
+               else
+                       return FFI_INT32;
+       case 8:
+               if (!sign)
+                       return FFI_UINT64;
+               else
+                       return FFI_INT64;
+       default:
+               kp_error(ks, "Error: Have not support int type of size %d\n", size);
+               return FFI_UNKNOWN;
+       }
+
+       /* NEVER reach here, silence compiler */
+       return -1;
+}
+#endif
+
+
+static inline void ct_set_type(struct cp_ctype *ct, int type, int is_unsigned)
+{
+       ct->type = type;
+       ct->is_unsigned = is_unsigned;
+}
+
+static void init_builtin_type(struct cp_ctype *ct, ffi_type ftype)
+{
+       csymbol cs;
+       int cs_id;
+
+       csym_type(&cs) = ftype;
+       strncpy(csym_name(&cs), ffi_type_name(ftype), CSYM_NAME_MAX_LEN);
+       cs_id = cp_ctype_reg_csymbol(&cs);
+
+       memset(ct, 0, sizeof(*ct));
+       ct->ffi_cs_id = cs_id;
+       switch (ftype) {
+       case FFI_VOID:          ct_set_type(ct, VOID_TYPE, 0); break;
+       case FFI_UINT8:         ct_set_type(ct, INT8_TYPE, 1); break;
+       case FFI_INT8:          ct_set_type(ct, INT8_TYPE, 0); break;
+       case FFI_UINT16:        ct_set_type(ct, INT16_TYPE, 1); break;
+       case FFI_INT16:         ct_set_type(ct, INT16_TYPE, 0); break;
+       case FFI_UINT32:        ct_set_type(ct, INT32_TYPE, 1); break;
+       case FFI_INT32:         ct_set_type(ct, INT32_TYPE, 0); break;
+       case FFI_UINT64:        ct_set_type(ct, INT64_TYPE, 1); break;
+       case FFI_INT64:         ct_set_type(ct, INT64_TYPE, 0); break;
+       default:                break;
+       }
+       ct->base_size = ffi_type_size(ftype);
+       ct->align_mask = ffi_type_align(ftype) - 1;
+       ct->is_defined = 1;
+}
+
+/*
+ * lookup and register builtin C type on demand
+ * You should ensure that the type with name doesn't appear in
+ * csymbol table before calling.
+ */
+struct cp_ctype *ctype_lookup_builtin_type(char *name)
+{
+       struct cp_ctype ct;
+
+       if (!strncmp(name, "void", sizeof("void"))) {
+               init_builtin_type(&ct, FFI_VOID);
+               return cp_ctype_reg_type("void", &ct);
+       } else if (!strncmp(name, "int8_t", sizeof("int8_t"))) {
+               init_builtin_type(&ct, FFI_INT8);
+               return cp_ctype_reg_type("int8_t", &ct);
+       } else if (!strncmp(name, "uint8_t", sizeof("uint8_t"))) {
+               init_builtin_type(&ct, FFI_UINT8);
+               return cp_ctype_reg_type("uint8_t", &ct);
+       } else if (!strncmp(name, "int16_t", sizeof("int16_t"))) {
+               init_builtin_type(&ct, FFI_INT16);
+               return cp_ctype_reg_type("int16_t", &ct);
+       } else if (!strncmp(name, "uint16_t", sizeof("uint16_t"))) {
+               init_builtin_type(&ct, FFI_UINT16);
+               return cp_ctype_reg_type("uint16_t", &ct);
+       } else if (!strncmp(name, "int32_t", sizeof("int32_t"))) {
+               init_builtin_type(&ct, FFI_INT32);
+               return cp_ctype_reg_type("int32_t", &ct);
+       } else if (!strncmp(name, "uint32_t", sizeof("uint32_t"))) {
+               init_builtin_type(&ct, FFI_UINT32);
+               return cp_ctype_reg_type("uint32_t", &ct);
+       } else if (!strncmp(name, "int64_t", sizeof("int64_t"))) {
+               init_builtin_type(&ct, FFI_INT64);
+               return cp_ctype_reg_type("int64_t", &ct);
+       } else if (!strncmp(name, "uint64_t", sizeof("uint64_t"))) {
+               init_builtin_type(&ct, FFI_UINT64);
+               return cp_ctype_reg_type("uint64_t", &ct);
+       } else {
+               /* no builtin type matched */
+               return NULL;
+       }
+}
+
+/* start ctype reg table */
+struct cp_ctype *ctype_lookup_type(char *name)
+{
+       int i;
+       struct cp_ctype *ct;
+
+       for (i = 0; i < cte_nr; i++) {
+               ct = &cte_arr[i].ct;
+               if (!strcmp(name, cte_arr[i].name))
+                       return ct;
+       }
+
+       /* see if it's a builtin C type
+        * return NULL if still no match */
+       return ctype_lookup_builtin_type(name);
+}
+
+cp_csymbol_state *ctype_get_csym_state(void)
+{
+       return &csym_state;
+}
+
+#define DEFAULT_STACK_SIZE 20
+#define DEFAULT_SYM_ARR_SIZE 20
+int cp_ctype_init()
+{
+       cts.size = DEFAULT_STACK_SIZE;
+       cts.top = 0;
+       cts.stack = malloc(sizeof(cp_ctype_entry)*DEFAULT_STACK_SIZE);
+
+       cs_nr = 0;
+       cs_arr_size = DEFAULT_SYM_ARR_SIZE;
+       cs_arr = malloc(sizeof(csymbol)*DEFAULT_SYM_ARR_SIZE);
+       memset(cs_arr, 0, sizeof(csymbol)*DEFAULT_SYM_ARR_SIZE);
+
+       cte_nr = 0;
+       cte_arr_size = DEFAULT_CTYPE_ARR_SIZE;
+       cte_arr = malloc(sizeof(cp_ctype_entry)*DEFAULT_CTYPE_ARR_SIZE);
+
+       return 0;
+}
+
+int cp_ctype_free()
+{
+       int i;
+       csymbol *cs;
+
+       if (cts.stack)
+               free(cts.stack);
+
+       if (cs_arr) {
+               for (i = 0; i < cs_nr; i++) {
+                       cs = &cs_arr[i];
+                       if (csym_type(cs) == FFI_FUNC) {
+                               if (csym_func(cs)->arg_ids)
+                                       free(csym_func(cs)->arg_ids);
+                       } else if (csym_type(cs) == FFI_STRUCT) {
+                               if (csym_struct(cs)->members)
+                                       free(csym_struct(cs)->members);
+                       }
+               }
+               free(cs_arr);
+       }
+
+       if (cte_arr) {
+               free(cte_arr);
+       }
+
+       return 0;
+}
diff --git a/drivers/staging/ktap/userspace/ktapc.h b/drivers/staging/ktap/userspace/ktapc.h
new file mode 100644 (file)
index 0000000..76348df
--- /dev/null
@@ -0,0 +1,393 @@
+/*
+ * ktapc.h
+ * only can be included by userspace compiler
+ */
+
+#include <ctype.h>
+
+typedef int bool;
+#define false 0
+#define true 1
+
+#define MAX_INT         ((int)(~0U>>1))
+#define UCHAR_MAX      255
+
+#define MAX_SIZET  ((size_t)(~(size_t)0)-2)
+
+#define KTAP_ERRSYNTAX 3
+
+/*
+ * KTAP_IDSIZE gives the maximum size for the description of the source
+ * of a function in debug information.
+ * CHANGE it if you want a different size.
+ */
+#define KTAP_IDSIZE      60
+
+
+#define FIRST_RESERVED  257
+
+/*
+ * maximum depth for nested C calls and syntactical nested non-terminals
+ * in a program. (Value must fit in an unsigned short int.)
+ */
+#define KTAP_MAXCCALLS          200
+
+#define KTAP_MULTRET     (-1)
+
+
+#define SHRT_MAX       UCHAR_MAX
+
+#define MAXUPVAL   UCHAR_MAX
+
+
+/* maximum stack for a ktap function */
+#define MAXSTACK        250
+
+#define islalpha(c)   (isalpha(c) || (c) == '_')
+#define islalnum(c)   (isalnum(c) || (c) == '_')
+
+#define isreserved(s) ((s)->tsv.tt == KTAP_TSHRSTR && (s)->tsv.extra > 0)
+
+#define ktap_numeq(a,b)                ((a)==(b))
+#define ktap_numisnan(L,a)     (!ktap_numeq((a), (a)))
+
+#define ktap_numunm(a)         (-(a))
+
+/*
+ * ** Comparison and arithmetic functions
+ * */
+
+#define KTAP_OPADD       0       /* ORDER TM */
+#define KTAP_OPSUB       1
+#define KTAP_OPMUL       2
+#define KTAP_OPDIV       3
+#define KTAP_OPMOD       4
+#define KTAP_OPPOW       5
+#define KTAP_OPUNM       6
+
+#define KTAP_OPEQ        0
+#define KTAP_OPLT        1
+#define KTAP_OPLE        2
+
+
+/*
+ * WARNING: if you change the order of this enumeration,
+ * grep "ORDER RESERVED"
+ */
+enum RESERVED {
+       /* terminal symbols denoted by reserved words */
+       TK_TRACE = FIRST_RESERVED, TK_TRACE_END,
+       TK_ARGEVENT, TK_ARGNAME,
+       TK_FFI_CDEF,
+       TK_ARG1, TK_ARG2, TK_ARG3, TK_ARG4, TK_ARG5, TK_ARG6, TK_ARG7, TK_ARG8,
+       TK_ARG9, TK_PROFILE, TK_TICK, TK_AGGR_ASSIGN,
+       TK_AND, TK_BREAK,
+       TK_DO, TK_ELSE, TK_ELSEIF, TK_END, TK_FALSE, TK_FOR, TK_FUNCTION,
+       TK_GOTO, TK_IF, TK_IN, TK_LOCAL, TK_NIL, TK_NOT, TK_OR, TK_REPEAT,
+       TK_RETURN, TK_THEN, TK_TRUE, TK_UNTIL, TK_WHILE,
+       /* other terminal symbols */
+       TK_CONCAT, TK_DOTS, TK_EQ, TK_GE, TK_LE, TK_NE, TK_INCR, TK_DBCOLON,
+       TK_EOS, TK_NUMBER, TK_NAME, TK_STRING, TK_KSYM
+};
+
+/* number of reserved words */
+#define NUM_RESERVED    ((int)(TK_WHILE-FIRST_RESERVED + 1))
+
+#define EOZ     (0)                    /* end of stream */
+
+typedef union {
+       ktap_number r;
+       ktap_string *ts;
+} ktap_seminfo;  /* semantics information */
+
+
+typedef struct ktap_token {
+       int token;
+       ktap_seminfo seminfo;
+} ktap_token;
+
+typedef struct ktap_mbuffer {
+       char *buffer;
+       size_t n;
+       size_t buffsize;
+} ktap_mbuffer;
+
+#define mbuff_init(buff)       ((buff)->buffer = NULL, (buff)->buffsize = 0)
+#define mbuff(buff)            ((buff)->buffer)
+#define mbuff_reset(buff)      ((buff)->n = 0, memset((buff)->buffer, 0, (buff)->buffsize))
+#define mbuff_len(buff)                ((buff)->n)
+#define mbuff_size(buff)       ((buff)->buffsize)
+
+#define mbuff_resize(buff, size) \
+       (ktapc_realloc((buff)->buffer, (buff)->buffsize, size, char), \
+       (buff)->buffsize = size)
+
+#define mbuff_free(buff)        mbuff_resize(buff, 0)
+
+
+/*
+ * state of the lexer plus state of the parser when shared by all
+ * functions
+ */
+typedef struct ktap_lexstate {
+       char *ptr; /* source file reading position */
+       int current;  /* current character (charint) */
+       int linenumber;  /* input line counter */
+       int lastline;  /* line of last token `consumed' */
+       ktap_token t;  /* current token */
+       ktap_token lookahead;  /* look ahead token */
+       struct ktap_funcstate *fs;  /* current function (parser) */
+       ktap_mbuffer *buff;  /* buffer for tokens */
+       struct ktap_dyndata *dyd;  /* dynamic structures used by the parser */
+       ktap_string *source;  /* current source name */
+       ktap_string *envn;  /* environment variable name */
+       char decpoint;  /* locale decimal point */
+       int nCcalls;
+} ktap_lexstate;
+
+
+/*
+ * Expression descriptor
+ */
+typedef enum {
+       VVOID,        /* no value */
+       VNIL,
+       VTRUE,
+       VFALSE,
+       VK,           /* info = index of constant in `k' */
+       VKNUM,        /* nval = numerical value */
+       VNONRELOC,    /* info = result register */
+       VLOCAL,       /* info = local register */
+       VUPVAL,       /* info = index of upvalue in 'upvalues' */
+       VINDEXED,     /* t = table register/upvalue; idx = index R/K */
+       VJMP,         /* info = instruction pc */
+       VRELOCABLE,   /* info = instruction pc */
+       VCALL,        /* info = instruction pc */
+       VVARARG,      /* info = instruction pc */
+       VEVENT,
+       VEVENTNAME,
+       VEVENTARG,
+} expkind;
+
+
+#define vkisvar(k)      (VLOCAL <= (k) && (k) <= VINDEXED)
+#define vkisinreg(k)    ((k) == VNONRELOC || (k) == VLOCAL)
+
+typedef struct ktap_expdesc {
+       expkind k;
+       union {
+               struct {  /* for indexed variables (VINDEXED) */
+                       short idx;  /* index (R/K) */
+                       u8 t;  /* table (register or upvalue) */
+                       u8 vt;  /* whether 't' is register (VLOCAL) or upvalue (VUPVAL) */
+               } ind;
+               int info;  /* for generic use */
+               ktap_number nval;  /* for VKNUM */
+       } u;
+       int t;  /* patch list of `exit when true' */
+       int f;  /* patch list of `exit when false' */
+} ktap_expdesc;
+
+
+typedef struct ktap_vardesc {
+       short idx;  /* variable index in stack */
+} ktap_vardesc;
+
+
+/* description of pending goto statements and label statements */
+typedef struct ktap_labeldesc {
+       ktap_string *name;  /* label identifier */
+       int pc;  /* position in code */
+       int line;  /* line where it appeared */
+       u8 nactvar;  /* local level where it appears in current block */
+} ktap_labeldesc;
+
+
+/* list of labels or gotos */
+typedef struct ktap_labellist {
+       ktap_labeldesc *arr;  /* array */
+       int n;  /* number of entries in use */
+       int size;  /* array size */
+} ktap_labellist;
+
+
+/* dynamic structures used by the parser */
+typedef struct ktap_dyndata {
+       struct {  /* list of active local variables */
+               ktap_vardesc *arr;
+               int n;
+               int size;
+       } actvar;
+       ktap_labellist gt;  /* list of pending gotos */
+       ktap_labellist label;   /* list of active labels */
+} ktap_dyndata;
+
+
+/* control of blocks */
+struct ktap_blockcnt;  /* defined in lparser.c */
+
+
+/* state needed to generate code for a given function */
+typedef struct ktap_funcstate {
+       ktap_proto *f;  /* current function header */
+       ktap_tab *h;  /* table to find (and reuse) elements in `k' */
+       struct ktap_funcstate *prev;  /* enclosing function */
+       struct ktap_lexstate *ls;  /* lexical state */
+       struct ktap_blockcnt *bl;  /* chain of current blocks */
+       int pc;  /* next position to code (equivalent to `ncode') */
+       int lasttarget;   /* 'label' of last 'jump label' */
+       int jpc;  /* list of pending jumps to `pc' */
+       int nk;  /* number of elements in `k' */
+       int np;  /* number of elements in `p' */
+       int firstlocal;  /* index of first local var (in ktap_dyndata array) */
+       short nlocvars;  /* number of elements in 'f->locvars' */
+       u8 nactvar;  /* number of active local variables */
+       u8 nups;  /* number of upvalues */
+       u8 freereg;  /* first free register */
+} ktap_funcstate;
+
+
+/*
+ * Marks the end of a patch list. It is an invalid value both as an absolute
+ * address, and as a list link (would link an element to itself).
+ */
+#define NO_JUMP (-1)
+
+
+/*
+ * grep "ORDER OPR" if you change these enums  (ORDER OP)
+ */
+typedef enum BinOpr {
+       OPR_ADD, OPR_SUB, OPR_MUL, OPR_DIV, OPR_MOD, OPR_POW,
+       OPR_CONCAT,
+       OPR_EQ, OPR_LT, OPR_LE,
+       OPR_NE, OPR_GT, OPR_GE,
+       OPR_AND, OPR_OR,
+       OPR_NOBINOPR
+} BinOpr;
+
+
+typedef enum UnOpr { OPR_MINUS, OPR_NOT, OPR_LEN, OPR_NOUNOPR } UnOpr;
+
+
+#define getcode(fs,e)   ((fs)->f->code[(e)->u.info])
+
+#define codegen_codeAsBx(fs,o,A,sBx)       codegen_codeABx(fs,o,A,(sBx)+MAXARG_sBx)
+
+#define codegen_setmultret(fs,e)   codegen_setreturns(fs, e, KTAP_MULTRET)
+
+#define codegen_jumpto(fs,t)       codegen_patchlist(fs, codegen_jump(fs), t)
+
+
+#define ktapc_realloc(v, osize, nsize, t) \
+        ((v) = (t *)ktapc_reallocv(v, osize * sizeof(t), nsize * sizeof(t)))
+
+#define ktapc_reallocvector(v,oldn,n,t)        ktapc_realloc(v,oldn,n,t)
+
+
+#define ktapc_growvector(v,nelems,size,t,limit,e) \
+          if ((nelems)+1 > (size)) \
+            ((v)=(t *)ktapc_growaux(v,&(size),sizeof(t),limit,e))
+
+
+void lex_init();
+ktap_string *lex_newstring(ktap_lexstate *ls, const char *str, size_t l);
+const char *lex_token2str(ktap_lexstate *ls, int token);
+void lex_syntaxerror(ktap_lexstate *ls, const char *msg);
+void lex_setinput(ktap_lexstate *ls, char *ptr, ktap_string *source, int firstchar);
+void lex_next(ktap_lexstate *ls);
+int lex_lookahead(ktap_lexstate *ls);
+void lex_read_string_until(ktap_lexstate *ls, int c);
+ktap_closure *ktapc_parser(char *pos, const char *name);
+ktap_string *ktapc_ts_new(const char *str);
+int ktapc_ts_eqstr(ktap_string *a, ktap_string *b);
+ktap_string *ktapc_ts_newlstr(const char *str, size_t l);
+ktap_proto *ktapc_newproto();
+ktap_tab *ktapc_table_new();
+const ktap_value *ktapc_table_get(ktap_tab *t, const ktap_value *key);
+void ktapc_table_setvalue(ktap_tab *t, const ktap_value *key, ktap_value *val);
+ktap_closure *ktapc_newclosure(int n);
+char *ktapc_sprintf(const char *fmt, ...);
+
+void *ktapc_reallocv(void *block, size_t osize, size_t nsize);
+void *ktapc_growaux(void *block, int *size, size_t size_elems, int limit,
+                   const char *what);
+
+void ktapio_exit(void);
+int ktapio_create(const char *output_filename);
+
+ktap_eventdef_info *ktapc_parse_eventdef(const char *eventdef);
+void cleanup_event_resources(void);
+
+extern int verbose;
+#define verbose_printf(...) \
+       if (verbose)    \
+               printf("[verbose] " __VA_ARGS__);
+
+#define ktapc_equalobj(t1, t2) kp_equalobjv(NULL, t1, t2)
+
+int codegen_stringK(ktap_funcstate *fs, ktap_string *s);
+void codegen_indexed(ktap_funcstate *fs, ktap_expdesc *t, ktap_expdesc *k);
+void codegen_setreturns(ktap_funcstate *fs, ktap_expdesc *e, int nresults);
+void codegen_reserveregs(ktap_funcstate *fs, int n);
+void codegen_exp2nextreg(ktap_funcstate *fs, ktap_expdesc *e);
+void codegen_nil(ktap_funcstate *fs, int from, int n);
+void codegen_patchlist(ktap_funcstate *fs, int list, int target);
+void codegen_patchclose(ktap_funcstate *fs, int list, int level);
+int codegen_jump(ktap_funcstate *fs);
+void codegen_patchtohere(ktap_funcstate *fs, int list);
+int codegen_codeABx(ktap_funcstate *fs, OpCode o, int a, unsigned int bc);
+void codegen_ret(ktap_funcstate *fs, int first, int nret);
+void codegen_exp2anyregup(ktap_funcstate *fs, ktap_expdesc *e);
+void codegen_exp2val(ktap_funcstate *fs, ktap_expdesc *e);
+int codegen_exp2RK(ktap_funcstate *fs, ktap_expdesc *e);
+int codegen_codeABC(ktap_funcstate *fs, OpCode o, int a, int b, int c);
+void codegen_setlist(ktap_funcstate *fs, int base, int nelems, int tostore);
+void codegen_fixline (ktap_funcstate *fs, int line);
+void codegen_dischargevars(ktap_funcstate *fs, ktap_expdesc *e);
+void codegen_self(ktap_funcstate *fs, ktap_expdesc *e, ktap_expdesc *key);
+void codegen_prefix(ktap_funcstate *fs, UnOpr op, ktap_expdesc *e, int line);
+void codegen_infix(ktap_funcstate *fs, BinOpr op, ktap_expdesc *v);
+void codegen_posfix(ktap_funcstate *fs, BinOpr op, ktap_expdesc *e1, ktap_expdesc *e2, int line);
+void codegen_setoneret(ktap_funcstate *fs, ktap_expdesc *e);
+void codegen_storevar(ktap_funcstate *fs, ktap_expdesc *var, ktap_expdesc *ex);
+void codegen_storeincr(ktap_funcstate *fs, ktap_expdesc *var, ktap_expdesc *ex);
+void codegen_store_aggr(ktap_funcstate *fs, ktap_expdesc *var,
+                                           ktap_expdesc *ex);
+void codegen_goiftrue(ktap_funcstate *fs, ktap_expdesc *e);
+int codegen_getlabel(ktap_funcstate *fs);
+int codegen_codek(ktap_funcstate *fs, int reg, int k);
+int codegen_numberK(ktap_funcstate *fs, ktap_number r);
+void codegen_checkstack(ktap_funcstate *fs, int n);
+void codegen_goiffalse(ktap_funcstate *fs, ktap_expdesc *e);
+void codegen_concat(ktap_funcstate *fs, int *l1, int l2);
+int codegen_exp2anyreg(ktap_funcstate *fs, ktap_expdesc *e);
+
+typedef int (*ktap_writer)(const void* p, size_t sz, void* ud);
+int ktapc_dump(const ktap_proto *f, ktap_writer w, void *data, int strip);
+
+void ktapc_chunkid(char *out, const char *source, size_t bufflen);
+int ktapc_str2d(const char *s, size_t len, ktap_number *result);
+int ktapc_hexavalue(int c);
+ktap_number ktapc_arith(int op, ktap_number v1, ktap_number v2);
+int ktapc_int2fb(unsigned int x);
+bool strglobmatch(const char *str, const char *pat);
+int kallsyms_parse(void *arg,
+                  int(*process_symbol)(void *arg, const char *name,
+                  char type, unsigned long start));
+
+unsigned long find_kernel_symbol(const char *symbol);
+void list_available_events(const char *match);
+
+
+#ifdef CONFIG_KTAP_FFI
+#include "../include/ktap_ffi.h"
+
+typedef struct cp_csymbol_state {
+       int cs_nr; /* number of c symbols */
+       int cs_arr_size; /* size of current symbol arrays */
+       csymbol *cs_arr;
+} cp_csymbol_state;
+
+cp_csymbol_state *ctype_get_csym_state(void);
+#endif
diff --git a/drivers/staging/ktap/userspace/ktapio.c b/drivers/staging/ktap/userspace/ktapio.c
new file mode 100644 (file)
index 0000000..7bef6e8
--- /dev/null
@@ -0,0 +1,106 @@
+/*
+ * ktapio.c - ring buffer transport in userspace
+ *
+ * This file is part of ktap by Jovi Zhangwei.
+ *
+ * Copyright (C) 2012-2013 Jovi Zhangwei <jovi.zhangwei@gmail.com>.
+ *
+ * ktap 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.
+ *
+ * ktap is distributed in the hope it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
+ * more details.
+ *
+ * You should have received a copy of the GNU General Public License along with
+ * this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+#include <sys/mman.h>
+#include <sys/stat.h>
+#include <sys/poll.h>
+#include <sys/signal.h>
+#include <fcntl.h>
+#include <pthread.h>
+
+#define MAX_BUFLEN  131072
+#define PATH_MAX 128
+
+#define handle_error(str) do { perror(str); exit(-1); } while(0)
+
+void sigfunc(int signo)
+{
+       /* should not not reach here */
+}
+
+static void block_sigint()
+{
+       sigset_t mask;
+
+       sigemptyset(&mask);
+       sigaddset(&mask, SIGINT);
+
+       pthread_sigmask(SIG_BLOCK, &mask, NULL);
+}
+
+static void *reader_thread(void *data)
+{
+       char buf[MAX_BUFLEN];
+       char filename[PATH_MAX];
+       const char *output = data;
+       int failed = 0, fd, out_fd, len;
+
+       block_sigint();
+
+       if (output) {
+               out_fd = open(output, O_CREAT | O_WRONLY | O_TRUNC,
+                                       S_IRUSR|S_IWUSR);
+               if (out_fd < 0) {
+                       fprintf(stderr, "Cannot open output file %s\n", output);
+                       return NULL;
+               }
+       } else
+               out_fd = 2;
+
+       sprintf(filename, "/sys/kernel/debug/ktap/trace_pipe_%d", getpid());
+
+ open_again:
+       fd = open(filename, O_RDONLY);
+       if (fd < 0) {
+               usleep(10000);
+
+               if (failed++ == 10) {
+                       fprintf(stderr, "Cannot open file %s\n", filename);
+                       return NULL;
+               }
+               goto open_again;
+       }
+
+       while ((len = read(fd, buf, sizeof(buf))) > 0)
+               write(out_fd, buf, len);
+
+       close(fd);
+       close(out_fd);
+
+       return NULL;
+}
+
+int ktapio_create(const char *output)
+{
+       pthread_t reader;
+
+       signal(SIGINT, sigfunc);
+
+       if (pthread_create(&reader, NULL, reader_thread, (void *)output) < 0)
+               handle_error("pthread_create reader_thread failed\n");
+
+       return 0;
+}
+
diff --git a/drivers/staging/ktap/userspace/lex.c b/drivers/staging/ktap/userspace/lex.c
new file mode 100644 (file)
index 0000000..2cfcd92
--- /dev/null
@@ -0,0 +1,632 @@
+/*
+ * lex.c - ktap lexical analyzer
+ *
+ * This file is part of ktap by Jovi Zhangwei.
+ *
+ * Copyright (C) 2012-2013 Jovi Zhangwei <jovi.zhangwei@gmail.com>.
+ *
+ * Copyright (C) 1994-2013 Lua.org, PUC-Rio.
+ *  - The part of code in this file is copied from lua initially.
+ *  - lua's MIT license is compatible with GPL.
+ *
+ * ktap 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.
+ *
+ * ktap is distributed in the hope it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
+ * more details.
+ *
+ * You should have received a copy of the GNU General Public License along with
+ * this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <locale.h>
+#include "../include/ktap_types.h"
+#include "../include/ktap_opcodes.h"
+#include "ktapc.h"
+
+#define next(ls) (ls->current = *ls->ptr++)
+
+#define currIsNewline(ls)      (ls->current == '\n' || ls->current == '\r')
+
+#define KTAP_MINBUFFER   32
+
+/* ORDER RESERVED */
+static const char *const ktap_tokens [] = {
+       "trace", "trace_end", "argevent", "argname", "cdef",
+       "arg1", "arg2", "arg3", "arg4", "arg5", "arg6", "arg7", "arg9", "arg9",
+       "profile", "tick", "<<<",
+       "and", "break", "do", "else", "elseif",
+       "end", "false", "for", "function", "goto", "if",
+       "in", "local", "nil", "not", "or", "repeat",
+       "return", "then", "true", "until", "while",
+       "..", "...", "==", ">=", "<=", "!=", "+=", "::", "<eof>",
+       "<number>", "<name>", "<string>", "<symbol>"
+};
+
+#define save_and_next(ls) (save(ls, ls->current), next(ls))
+
+static void lexerror(ktap_lexstate *ls, const char *msg, int token);
+
+static void save(ktap_lexstate *ls, int c)
+{
+       ktap_mbuffer *b = ls->buff;
+       if (mbuff_len(b) + 1 > mbuff_size(b)) {
+               size_t newsize;
+               if (mbuff_size(b) >= MAX_SIZET / 2)
+                       lexerror(ls, "lexical element too long", 0);
+               newsize = mbuff_size(b) * 2;
+               mbuff_resize(b, newsize);
+       }
+       b->buffer[mbuff_len(b)++] = (char)c;
+}
+
+void lex_init()
+{
+       int i;
+       for (i = 0; i < NUM_RESERVED; i++) {
+               ktap_string *ts = ktapc_ts_new(ktap_tokens[i]);
+               ts->tsv.extra = (u8)(i+1);  /* reserved word */
+       }
+}
+
+const char *lex_token2str(ktap_lexstate *ls, int token)
+{
+       if (token < FIRST_RESERVED) {
+               ktap_assert(token == (unsigned char)token);
+               return (isprint(token)) ? ktapc_sprintf(KTAP_QL("%c"), token) :
+                       ktapc_sprintf("char(%d)", token);
+       } else {
+               const char *s = ktap_tokens[token - FIRST_RESERVED];
+               if (token < TK_EOS)
+                       return ktapc_sprintf(KTAP_QS, s);
+               else
+                       return s;
+       }
+}
+
+static const char *txtToken(ktap_lexstate *ls, int token)
+{
+       switch (token) {
+       case TK_NAME:
+       case TK_STRING:
+       case TK_NUMBER:
+               save(ls, '\0');
+               return ktapc_sprintf(KTAP_QS, mbuff(ls->buff));
+       default:
+               return lex_token2str(ls, token);
+       }
+}
+
+static void lexerror(ktap_lexstate *ls, const char *msg, int token)
+{
+       char buff[KTAP_IDSIZE];
+       char *newmsg;
+
+       ktapc_chunkid(buff, getstr(ls->source), KTAP_IDSIZE);
+       newmsg = ktapc_sprintf("%s:%d: %s", buff, ls->linenumber, msg);
+       if (token)
+               newmsg = ktapc_sprintf("%s near %s", newmsg, txtToken(ls, token));
+       printf("lexerror: %s\n", newmsg);
+       exit(EXIT_FAILURE);
+}
+
+void lex_syntaxerror(ktap_lexstate *ls, const char *msg)
+{
+       lexerror(ls, msg, ls->t.token);
+}
+
+/*
+ * creates a new string and anchors it in function's table so that
+ * it will not be collected until the end of the function's compilation
+ * (by that time it should be anchored in function's prototype)
+ */
+ktap_string *lex_newstring(ktap_lexstate *ls, const char *str, size_t l)
+{
+       const ktap_value *o;  /* entry for `str' */
+       ktap_value val;  /* entry for `str' */
+       ktap_value tsv;
+       ktap_string *ts = ktapc_ts_newlstr(str, l);  /* create new string */
+       set_string(&tsv, ts);
+       o = ktapc_table_get(ls->fs->h, &tsv);
+       if (is_nil(o)) {  /* not in use yet? (see 'addK') */
+               /* boolean value does not need GC barrier;
+               table has no metatable, so it does not need to invalidate cache */
+               set_boolean(&val, 1);  /* t[string] = true */
+               ktapc_table_setvalue(ls->fs->h, &tsv, &val);
+       }
+       return ts;
+}
+
+/*
+ * increment line number and skips newline sequence (any of
+ * \n, \r, \n\r, or \r\n)
+ */
+static void inclinenumber(ktap_lexstate *ls)
+{
+       int old = ls->current;
+       ktap_assert(currIsNewline(ls));
+       next(ls);  /* skip `\n' or `\r' */
+       if (currIsNewline(ls) && ls->current != old)
+               next(ls);  /* skip `\n\r' or `\r\n' */
+       if (++ls->linenumber >= MAX_INT)
+               lex_syntaxerror(ls, "chunk has too many lines");
+}
+
+void lex_setinput(ktap_lexstate *ls, char *ptr, ktap_string *source, int firstchar)
+{
+       ls->decpoint = '.';
+       ls->current = firstchar;
+       ls->lookahead.token = TK_EOS;  /* no look-ahead token */
+       ls->ptr = ptr;
+       ls->fs = NULL;
+       ls->linenumber = 1;
+       ls->lastline = 1;
+       ls->source = source;
+       ls->envn = ktapc_ts_new(KTAP_ENV);  /* create env name */
+       mbuff_resize(ls->buff, KTAP_MINBUFFER);  /* initialize buffer */
+}
+
+/*
+ * =======================================================
+ * LEXICAL ANALYZER
+ * =======================================================
+ */
+static int check_next(ktap_lexstate *ls, const char *set)
+{
+       if (ls->current == '\0' || !strchr(set, ls->current))
+               return 0;
+       save_and_next(ls);
+       return 1;
+}
+
+/*
+ * change all characters 'from' in buffer to 'to'
+ */
+static void buffreplace(ktap_lexstate *ls, char from, char to)
+{
+       size_t n = mbuff_len(ls->buff);
+       char *p = mbuff(ls->buff);
+       while (n--)
+               if (p[n] == from) p[n] = to;
+}
+
+#if !defined(getlocaledecpoint)
+#define getlocaledecpoint()    (localeconv()->decimal_point[0])
+#endif
+
+#define mbuff2d(b,e)   ktapc_str2d(mbuff(b), mbuff_len(b) - 1, e)
+
+/*
+ * in case of format error, try to change decimal point separator to
+ * the one defined in the current locale and check again
+ */
+static void trydecpoint(ktap_lexstate *ls, ktap_seminfo *seminfo)
+{
+       char old = ls->decpoint;
+       ls->decpoint = getlocaledecpoint();
+       buffreplace(ls, old, ls->decpoint);  /* try new decimal separator */
+       if (!mbuff2d(ls->buff, &seminfo->r)) {
+               /* format error with correct decimal point: no more options */
+               buffreplace(ls, ls->decpoint, '.');  /* undo change (for error message) */
+               lexerror(ls, "malformed number", TK_NUMBER);
+       }
+}
+
+/*
+ * this function is quite liberal in what it accepts, as 'ktapc_str2d'
+ * will reject ill-formed numerals.
+ */
+static void read_numeral(ktap_lexstate *ls, ktap_seminfo *seminfo)
+{
+       const char *expo = "Ee";
+       int first = ls->current;
+
+       ktap_assert(isdigit(ls->current));
+       save_and_next(ls);
+       if (first == '0' && check_next(ls, "Xx"))  /* hexadecimal? */
+               expo = "Pp";
+       for (;;) {
+               if (check_next(ls, expo))  /* exponent part? */
+                       check_next(ls, "+-");  /* optional exponent sign */
+               if (isxdigit(ls->current) || ls->current == '.')
+                       save_and_next(ls);
+               else
+                       break;
+       }
+       save(ls, '\0');
+       buffreplace(ls, '.', ls->decpoint);  /* follow locale for decimal point */
+       if (!mbuff2d(ls->buff, &seminfo->r))  /* format error? */
+               trydecpoint(ls, seminfo); /* try to update decimal point separator */
+}
+
+/*
+ * skip a sequence '[=*[' or ']=*]' and return its number of '='s or
+ * -1 if sequence is malformed
+ */
+static int skip_sep(ktap_lexstate *ls)
+{
+       int count = 0;
+       int s = ls->current;
+
+       ktap_assert(s == '[' || s == ']');
+       save_and_next(ls);
+       while (ls->current == '=') {
+               save_and_next(ls);
+               count++;
+       }
+       return (ls->current == s) ? count : (-count) - 1;
+}
+
+static void read_long_string(ktap_lexstate *ls, ktap_seminfo *seminfo, int sep)
+{
+       save_and_next(ls);  /* skip 2nd `[' */
+       if (currIsNewline(ls))  /* string starts with a newline? */
+               inclinenumber(ls);  /* skip it */
+       for (;;) {
+               switch (ls->current) {
+               case EOZ:
+                       lexerror(ls, (seminfo) ? "unfinished long string" :
+                               "unfinished long comment", TK_EOS);
+                       break;  /* to avoid warnings */
+               case ']': {
+                       if (skip_sep(ls) == sep) {
+                               save_and_next(ls);  /* skip 2nd `]' */
+                               goto endloop;
+                       }
+                       break;
+               }
+               case '\n':
+               case '\r': {
+                       save(ls, '\n');
+                       inclinenumber(ls);
+                       /* avoid wasting space */
+                       if (!seminfo)
+                               mbuff_reset(ls->buff);
+                       break;
+               }
+               default: {
+                       if (seminfo)
+                               save_and_next(ls);
+                       else
+                               next(ls);
+               }
+               }
+       }
+
+ endloop:
+       if (seminfo)
+               seminfo->ts = lex_newstring(ls, mbuff(ls->buff) + (2 + sep),
+                       mbuff_len(ls->buff) - 2*(2 + sep));
+}
+
+static void escerror(ktap_lexstate *ls, int *c, int n, const char *msg)
+{
+       int i;
+       mbuff_reset(ls->buff);  /* prepare error message */
+       save(ls, '\\');
+       for (i = 0; i < n && c[i] != EOZ; i++)
+               save(ls, c[i]);
+       lexerror(ls, msg, TK_STRING);
+}
+
+static int readhexaesc(ktap_lexstate *ls)
+{
+       int c[3], i;  /* keep input for error message */
+       int r = 0;  /* result accumulator */
+       c[0] = 'x';  /* for error message */
+       for (i = 1; i < 3; i++) {  /* read two hexa digits */
+               c[i] = next(ls);
+               if (!isxdigit(c[i]))
+                       escerror(ls, c, i + 1, "hexadecimal digit expected");
+               r = (r << 4) + ktapc_hexavalue(c[i]);
+       }
+       return r;
+}
+
+static int readdecesc(ktap_lexstate *ls)
+{
+       int c[3], i;
+       int r = 0;  /* result accumulator */
+       for (i = 0; i < 3 && isdigit(ls->current); i++) {  /* read up to 3 digits */
+               c[i] = ls->current;
+               r = 10*r + c[i] - '0';
+               next(ls);
+       }
+       if (r > UCHAR_MAX)
+               escerror(ls, c, i, "decimal escape too large");
+       return r;
+}
+
+static void read_string(ktap_lexstate *ls, int del, ktap_seminfo *seminfo)
+{
+       save_and_next(ls);  /* keep delimiter (for error messages) */
+       while (ls->current != del) {
+               switch (ls->current) {
+               case EOZ:
+                       lexerror(ls, "unfinished string", TK_EOS);
+                       break;  /* to avoid warnings */
+               case '\n':
+               case '\r':
+                       lexerror(ls, "unfinished string", TK_STRING);
+                       break;  /* to avoid warnings */
+               case '\\': {  /* escape sequences */
+                       int c;  /* final character to be saved */
+                       next(ls);  /* do not save the `\' */
+                       switch (ls->current) {
+                       case 'a': c = '\a'; goto read_save;
+                       case 'b': c = '\b'; goto read_save;
+                       case 'f': c = '\f'; goto read_save;
+                       case 'n': c = '\n'; goto read_save;
+                       case 'r': c = '\r'; goto read_save;
+                       case 't': c = '\t'; goto read_save;
+                       case 'v': c = '\v'; goto read_save;
+                       case 'x': c = readhexaesc(ls); goto read_save;
+                       case '\n': case '\r':
+                               inclinenumber(ls); c = '\n'; goto only_save;
+                       case '\\': case '\"': case '\'':
+                               c = ls->current; goto read_save;
+                       case EOZ: goto no_save;  /* will raise an error next loop */
+                       case 'z': {  /* zap following span of spaces */
+                               next(ls);  /* skip the 'z' */
+                               while (isspace(ls->current)) {
+                                       if (currIsNewline(ls))
+                                               inclinenumber(ls);
+                                       else
+                                               next(ls);
+                               }
+                               goto no_save;
+                       }
+                       default: {
+                               if (!isdigit(ls->current))
+                                       escerror(ls, &ls->current, 1, "invalid escape sequence");
+                               /* digital escape \ddd */
+                               c = readdecesc(ls);
+                               goto only_save;
+                       }
+                       }
+ read_save:
+                       next(ls);  /* read next character */
+ only_save:
+                       save(ls, c);  /* save 'c' */
+ no_save:
+                       break;
+               }
+               default:
+                       save_and_next(ls);
+               }
+       }
+       save_and_next(ls);  /* skip delimiter */
+       seminfo->ts = lex_newstring(ls, mbuff(ls->buff) + 1, mbuff_len(ls->buff) - 2);
+}
+
+static int llex(ktap_lexstate *ls, ktap_seminfo *seminfo)
+{
+       mbuff_reset(ls->buff);
+
+       for (;;) {
+               switch (ls->current) {
+               case '\n': case '\r': {  /* line breaks */
+                       inclinenumber(ls);
+                       break;
+               }
+               case ' ': case '\f': case '\t': case '\v': {  /* spaces */
+                       next(ls);
+                       break;
+               }
+               case '#': {
+                       while (!currIsNewline(ls) && ls->current != EOZ)
+                               next(ls);  /* skip until end of line (or end of file) */
+                       break;
+               }
+               #if 0
+               case '-': {  /* '-' or '--' (comment) */
+                       next(ls);
+                       if (ls->current != '-')
+                               return '-';
+                       /* else is a comment */
+                       next(ls);
+                       if (ls->current == '[') {  /* long comment? */
+                               int sep = skip_sep(ls);
+                               mbuff_reset(ls->buff);  /* `skip_sep' may dirty the buffer */
+                               if (sep >= 0) {
+                                       read_long_string(ls, NULL, sep);  /* skip long comment */
+                                       mbuff_reset(ls->buff);  /* previous call may dirty the buff. */
+                                       break;
+                               }
+                       }
+                       /* else short comment */
+                       while (!currIsNewline(ls) && ls->current != EOZ)
+                               next(ls);  /* skip until end of line (or end of file) */
+                       break;
+               }
+               #endif
+               case '[': {  /* long string or simply '[' */
+                       int sep = skip_sep(ls);
+                       if (sep >= 0) {
+                               read_long_string(ls, seminfo, sep);
+                               return TK_STRING;
+                       }
+                       else if (sep == -1)
+                               return '[';
+                       else
+                               lexerror(ls, "invalid long string delimiter", TK_STRING);
+               }
+               case '+': {
+                       next(ls);
+                       if (ls->current != '=')
+                               return '+';
+                       else {
+                               next(ls);
+                               return TK_INCR;
+                       }
+               }
+               case '=': {
+                       next(ls);
+                       if (ls->current != '=')
+                               return '=';
+                       else {
+                               next(ls);
+                               return TK_EQ;
+                       }
+               }
+               case '<': {
+                       next(ls);
+                       if (ls->current == '=')
+                               return TK_LE;
+                       else if (ls->current == '<') {
+                               next(ls);
+                               if (ls->current == '<') {
+                                       next(ls);
+                                       return TK_AGGR_ASSIGN;
+                               }
+                       } else {
+                               return '<';
+                       }
+               }
+               case '>': {
+                       next(ls);
+                       if (ls->current != '=')
+                               return '>';
+                       else {
+                               next(ls);
+                               return TK_GE;
+                       }
+               }
+               case '!': {
+                       next(ls);
+                       if (ls->current != '=')
+                               return TK_NOT;
+                       else {
+                               next(ls);
+                               return TK_NE;
+                       }
+               }
+               case ':': {
+                       next(ls);
+                       if (ls->current != ':')
+                               return ':';
+                       else {
+                               next(ls);
+                               return TK_DBCOLON;
+                       }
+               }
+               case '"': case '\'': {  /* short literal strings */
+                       read_string(ls, ls->current, seminfo);
+                       return TK_STRING;
+               }
+               case '`': {  /* short literal kernel symbol */
+                       read_string(ls, ls->current, seminfo);
+                       return TK_KSYM;
+               }
+               case '.': {  /* '.', '..', '...', or number */
+                       save_and_next(ls);
+                       if (check_next(ls, ".")) {
+                               if (check_next(ls, "."))
+                                       return TK_DOTS;   /* '...' */
+                               else
+                                       return TK_CONCAT;   /* '..' */
+                       }
+                       else if (!isdigit(ls->current))
+                               return '.';
+                       /* else go through */
+               }
+               case '0': case '1': case '2': case '3': case '4':
+               case '5': case '6': case '7': case '8': case '9': {
+                       read_numeral(ls, seminfo);
+                       return TK_NUMBER;
+               }
+               case EOZ: {
+                       return TK_EOS;
+               }
+               case '&': {
+                       next(ls);
+                       if (ls->current != '&')
+                               return '&';
+                       else {
+                               next(ls);
+                               return TK_AND;
+                       }
+               }
+               case '|': {
+                       next(ls);
+                       if (ls->current != '|')
+                               return '|';
+                       else {
+                               next(ls);
+                               return TK_OR;
+                       }
+               }
+               default: {
+                       if (islalpha(ls->current)) {
+                               /* identifier or reserved word? */
+                               ktap_string *ts;
+                               do {
+                                       save_and_next(ls);
+                               } while (islalnum(ls->current));
+                               ts = lex_newstring(ls, mbuff(ls->buff),
+                                                       mbuff_len(ls->buff));
+                               seminfo->ts = ts;
+                               if (isreserved(ts))  /* reserved word? */
+                                       return ts->tsv.extra - 1 +
+                                               FIRST_RESERVED;
+                               else {
+                                       return TK_NAME;
+                               }
+                       } else {  /* single-char tokens (+ - / ...) */
+                               int c = ls->current;
+                               next(ls);
+                               return c;
+                       }
+               }
+               }
+       }
+}
+
+void lex_read_string_until(ktap_lexstate *ls, int c)
+{
+       ktap_string *ts;
+       char errmsg[32];
+
+       mbuff_reset(ls->buff);
+
+       while (ls->current == ' ')
+               next(ls);
+
+       do {
+               save_and_next(ls);
+       } while (ls->current != c && ls->current != EOZ);
+
+       if (ls->current != c) {
+               sprintf(errmsg, "expect %c", c);
+               lexerror(ls, errmsg, 0);
+       }
+
+       ts = lex_newstring(ls, mbuff(ls->buff), mbuff_len(ls->buff));
+       ls->t.seminfo.ts = ts;
+       ls->t.token = TK_STRING;
+}
+
+void lex_next(ktap_lexstate *ls)
+{
+       ls->lastline = ls->linenumber;
+       if (ls->lookahead.token != TK_EOS) {  /* is there a look-ahead token? */
+               ls->t = ls->lookahead;  /* use this one */
+               ls->lookahead.token = TK_EOS;  /* and discharge it */
+       } else
+               ls->t.token = llex(ls, &ls->t.seminfo);  /* read next token */
+}
+
+int lex_lookahead(ktap_lexstate *ls)
+{
+       ktap_assert(ls->lookahead.token == TK_EOS);
+       ls->lookahead.token = llex(ls, &ls->lookahead.seminfo);
+       return ls->lookahead.token;
+}
+
diff --git a/drivers/staging/ktap/userspace/main.c b/drivers/staging/ktap/userspace/main.c
new file mode 100644 (file)
index 0000000..82fbab2
--- /dev/null
@@ -0,0 +1,727 @@
+/*
+ * main.c - ktap compiler and loader entry
+ *
+ * This file is part of ktap by Jovi Zhangwei.
+ *
+ * Copyright (C) 2012-2013 Jovi Zhangwei <jovi.zhangwei@gmail.com>.
+ *
+ * ktap 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.
+ *
+ * ktap is distributed in the hope it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
+ * more details.
+ *
+ * You should have received a copy of the GNU General Public License along with
+ * this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <sched.h>
+#include <string.h>
+#include <signal.h>
+#include <stdarg.h>
+#include <sys/mman.h>
+#include <sys/stat.h>
+#include <sys/ioctl.h>
+#include <sys/types.h>
+#include <unistd.h>
+#include <fcntl.h>
+#include <math.h>
+
+#include "../include/ktap_types.h"
+#include "../include/ktap_opcodes.h"
+#include "ktapc.h"
+#include "../runtime/kp_obj.h"
+#include "../runtime/kp_str.h"
+#include "../runtime/kp_tab.h"
+#include "symbol.h"
+#include "cparser.h"
+
+
+/*******************************************************************/
+
+void *ktapc_reallocv(void *block, size_t osize, size_t nsize)
+{
+       return kp_reallocv(NULL, block, osize, nsize);
+}
+
+ktap_closure *ktapc_newclosure(int n)
+{
+       return kp_newclosure(NULL, n);
+}
+
+ktap_proto *ktapc_newproto()
+{
+       return kp_newproto(NULL);
+}
+
+const ktap_value *ktapc_table_get(ktap_tab *t, const ktap_value *key)
+{
+       return kp_tab_get(t, key);
+}
+
+void ktapc_table_setvalue(ktap_tab *t, const ktap_value *key, ktap_value *val)
+{
+       kp_tab_setvalue(NULL, t, key, val);
+}
+
+ktap_tab *ktapc_table_new()
+{
+       return kp_tab_new(NULL);
+}
+
+ktap_string *ktapc_ts_newlstr(const char *str, size_t l)
+{
+       return kp_tstring_newlstr(NULL, str, l);
+}
+
+ktap_string *ktapc_ts_new(const char *str)
+{
+       return kp_tstring_new(NULL, str);
+}
+
+int ktapc_ts_eqstr(ktap_string *a, ktap_string *b)
+{
+       return kp_tstring_eqstr(a, b);
+}
+
+static void ktapc_runerror(const char *err_msg_fmt, ...)
+{
+       va_list ap;
+
+       fprintf(stderr, "ktapc_runerror\n");
+
+       va_start(ap, err_msg_fmt);
+       vfprintf(stderr, err_msg_fmt, ap);
+       va_end(ap);
+
+       exit(EXIT_FAILURE);
+}
+
+/*
+ * todo: memory leak here
+ */
+char *ktapc_sprintf(const char *fmt, ...)
+{
+       char *msg = malloc(128);
+
+       va_list argp;
+       va_start(argp, fmt);
+       vsprintf(msg, fmt, argp);
+       va_end(argp);
+       return msg;
+}
+
+
+#define MINSIZEARRAY   4
+
+void *ktapc_growaux(void *block, int *size, size_t size_elems, int limit,
+                   const char *what)
+{
+       void *newblock;
+       int newsize;
+
+       if (*size >= limit/2) {  /* cannot double it? */
+               if (*size >= limit)  /* cannot grow even a little? */
+                       ktapc_runerror("too many %s (limit is %d)\n",
+                                       what, limit);
+               newsize = limit;  /* still have at least one free place */
+       } else {
+               newsize = (*size) * 2;
+               if (newsize < MINSIZEARRAY)
+                       newsize = MINSIZEARRAY;  /* minimum size */
+       }
+
+       newblock = ktapc_reallocv(block, (*size) * size_elems, newsize * size_elems);
+       *size = newsize;  /* update only when everything else is OK */
+       return newblock;
+}
+
+/*************************************************************************/
+
+#define print_base(i) \
+       do {    \
+               if (i < f->sizelocvars) /* it's a localvars */ \
+                       printf("%s", getstr(f->locvars[i].varname));  \
+               else \
+                       printf("base + %d", i); \
+       } while (0)
+
+#define print_RK(instr, _field)  \
+       do {    \
+               if (ISK(GETARG_##_field(instr))) \
+                       kp_showobj(NULL, k + INDEXK(GETARG_##_field(instr))); \
+               else \
+                       print_base(GETARG_##_field(instr)); \
+       } while (0)
+
+#define print_RKA(instr) print_RK(instr, A)
+#define print_RKB(instr) print_RK(instr, B)
+#define print_RKC(instr) print_RK(instr, C)
+
+#define print_upvalue(idx) \
+       do {    \
+               if ((idx) == 0) \
+                       printf("global"); \
+               else \
+                       printf("upvalues[%d]", (idx)); \
+       } while (0)
+
+static void decode_instruction(ktap_proto *f, int instr)
+{
+       int opcode = GET_OPCODE(instr);
+       ktap_value *k;
+
+       k = f->k;
+
+       printf("%.8x\t", instr);
+       printf("%s\t", ktap_opnames[opcode]);
+
+       switch (opcode) {
+       case OP_MOVE:
+               printf("\t");
+               print_base(GETARG_A(instr));
+               printf(" <- ");
+               print_base(GETARG_B(instr));
+               break;
+       case OP_GETTABUP:
+               print_base(GETARG_A(instr));
+               printf(" <- ");
+               print_upvalue(GETARG_B(instr));
+               printf("{"); print_RKC(instr); printf("}");
+
+               break;
+       case OP_GETTABLE:
+               print_base(GETARG_A(instr));
+               printf(" <- ");
+
+               print_base(GETARG_B(instr));
+
+               printf("{");
+               print_RKC(instr);
+               printf("}");
+               break;
+       case OP_SETTABLE:
+               print_base(GETARG_A(instr));
+               printf("{");
+               print_RKB(instr);
+               printf("}");
+               printf(" <- ");
+               print_RKC(instr);
+               break;
+       case OP_LOADK:
+               printf("\t");
+               print_base(GETARG_A(instr));
+               printf(" <- ");
+
+               kp_showobj(NULL, k + GETARG_Bx(instr));
+               break;
+       case OP_CALL:
+               printf("\t");
+               print_base(GETARG_A(instr));
+               break;
+       case OP_JMP:
+               printf("\t%d", GETARG_sBx(instr));
+               break;
+       case OP_CLOSURE:
+               printf("\t");
+               print_base(GETARG_A(instr));
+               printf(" <- closure(func starts from line %d)",
+                       f->p[GETARG_Bx(instr)]->lineinfo[0]);
+               break;
+       case OP_SETTABUP:
+               print_upvalue(GETARG_A(instr));
+               printf("{");
+               print_RKB(instr);
+               printf("} <- ");
+
+               print_RKC(instr);
+               break;
+       case OP_GETUPVAL:
+               print_base(GETARG_A(instr));
+               printf(" <- ");
+
+               print_upvalue(GETARG_B(instr));
+               break;
+       case OP_NEWTABLE:
+               print_base(GETARG_A(instr));
+               printf(" <- {}");
+       default:
+               break;
+       }
+
+       printf("\n");
+}
+
+static int function_nr = 0;
+
+/* this is a debug function used for check bytecode chunk file */
+static void dump_function(int level, ktap_proto *f)
+{
+       int i;
+
+       printf("\n----------------------------------------------------\n");
+       printf("function %d [level %d]:\n", function_nr++, level);
+       printf("linedefined: %d\n", f->linedefined);
+       printf("lastlinedefined: %d\n", f->lastlinedefined);
+       printf("numparams: %d\n", f->numparams);
+       printf("is_vararg: %d\n", f->is_vararg);
+       printf("maxstacksize: %d\n", f->maxstacksize);
+       printf("source: %s\n", getstr(f->source));
+       printf("sizelineinfo: %d \t", f->sizelineinfo);
+       for (i = 0; i < f->sizelineinfo; i++)
+               printf("%d ", f->lineinfo[i]);
+       printf("\n");
+
+       printf("sizek: %d\n", f->sizek);
+       for (i = 0; i < f->sizek; i++) {
+               switch(f->k[i].type) {
+               case KTAP_TNIL:
+                       printf("\tNIL\n");
+                       break;
+               case KTAP_TBOOLEAN:
+                       printf("\tBOOLEAN: ");
+                       printf("%d\n", f->k[i].val.b);
+                       break;
+               case KTAP_TNUMBER:
+                       printf("\tTNUMBER: ");
+                       printf("%ld\n", f->k[i].val.n);
+                       break;
+               case KTAP_TSHRSTR:
+               case KTAP_TLNGSTR:
+                       printf("\tTSTRING: ");
+                       printf("%s\n", svalue(&(f->k[i])));
+                       break;
+               default:
+                       printf("\tUnknow constant type %d: ", f->k[i].type);
+                       kp_showobj(NULL, &(f->k[i]));
+                       printf("\n");
+               }
+       }
+
+       printf("sizelocvars: %d\n", f->sizelocvars);
+       for (i = 0; i < f->sizelocvars; i++) {
+               printf("\tlocvars: %s startpc: %d endpc: %d\n",
+                       getstr(f->locvars[i].varname), f->locvars[i].startpc,
+                       f->locvars[i].endpc);
+       }
+
+       printf("sizeupvalues: %d\n", f->sizeupvalues);
+       for (i = 0; i < f->sizeupvalues; i++) {
+               printf("\tname: %s instack: %d idx: %d\n",
+                       getstr(f->upvalues[i].name), f->upvalues[i].instack,
+                       f->upvalues[i].idx);
+       }
+
+       printf("\n");
+       printf("sizecode: %d\n", f->sizecode);
+       for (i = 0; i < f->sizecode; i++)
+               decode_instruction(f, f->code[i]);
+
+       printf("sizep: %d\n", f->sizep);
+       for (i = 0; i < f->sizep; i++)
+               dump_function(level + 1, f->p[i]);
+
+}
+
+static void usage(const char *msg_fmt, ...)
+{
+       va_list ap;
+
+       va_start(ap, msg_fmt);
+       vfprintf(stderr, msg_fmt, ap);
+       va_end(ap);
+
+       fprintf(stderr,
+"Usage: ktap [options] file [script args] -- cmd [args]\n"
+"   or: ktap [options] -e one-liner  -- cmd [args]\n"
+"\n"
+"Options and arguments:\n"
+"  -o file        : send script output to file, instead of stderr\n"
+"  -p pid         : specific tracing pid\n"
+"  -C cpu         : cpu to monitor in system-wide\n"
+"  -T             : show timestamp for event\n"
+"  -V             : show version\n"
+"  -v             : enable verbose mode\n"
+"  -q             : suppress start tracing message\n"
+"  -s             : simple event tracing\n"
+"  -b             : list byte codes\n"
+"  -le [glob]     : list pre-defined events in system\n"
+#ifndef NO_LIBELF
+"  -lf DSO        : list available functions from DSO\n"
+"  -lm DSO        : list available sdt notes from DSO\n"
+#endif
+"  file           : program read from script file\n"
+"  -- cmd [args]  : workload to tracing\n");
+
+       exit(EXIT_FAILURE);
+}
+
+ktap_global_state dummy_global_state;
+
+static void init_dummy_global_state()
+{
+       memset(&dummy_global_state, 0, sizeof(ktap_global_state));
+       dummy_global_state.seed = 201236;
+
+        kp_tstring_resize(NULL, 32); /* set inital string hashtable size */
+}
+
+#define handle_error(str) do { perror(str); exit(-1); } while(0)
+
+static struct ktap_parm uparm;
+static int ktap_trunk_mem_size = 1024;
+
+static int ktapc_writer(const void* p, size_t sz, void* ud)
+{
+       if (uparm.trunk_len + sz > ktap_trunk_mem_size) {
+               int new_size = (uparm.trunk_len + sz) * 2;
+               uparm.trunk = realloc(uparm.trunk, new_size);
+               ktap_trunk_mem_size = new_size;
+       }
+
+       memcpy(uparm.trunk + uparm.trunk_len, p, sz);
+       uparm.trunk_len += sz;
+
+       return 0;
+}
+
+
+static int forks;
+static char **workload_argv;
+
+static int fork_workload(int ktap_fd)
+{
+       int pid;
+
+       pid = fork();
+       if (pid < 0)
+               handle_error("failed to fork");
+
+       if (pid > 0)
+               return pid;
+
+       signal(SIGTERM, SIG_DFL);
+
+       execvp("", workload_argv);
+
+       /*
+        * waiting ktapvm prepare all tracing event
+        * make it more robust in future.
+        */
+       pause();
+
+       execvp(workload_argv[0], workload_argv);
+
+       perror(workload_argv[0]);
+       exit(-1);
+
+       return -1;
+}
+
+#define KTAPVM_PATH "/sys/kernel/debug/ktap/ktapvm"
+
+static char *output_filename;
+
+static int run_ktapvm()
+{
+        int ktapvm_fd, ktap_fd;
+       int ret;
+
+       ktapvm_fd = open(KTAPVM_PATH, O_RDONLY);
+       if (ktapvm_fd < 0)
+               handle_error("open " KTAPVM_PATH " failed");
+
+       ktap_fd = ioctl(ktapvm_fd, 0, NULL);
+       if (ktap_fd < 0)
+               handle_error("ioctl ktapvm failed");
+
+       ktapio_create(output_filename);
+
+       if (forks) {
+               uparm.trace_pid = fork_workload(ktap_fd);
+               uparm.workload = 1;
+       }
+
+       ret = ioctl(ktap_fd, KTAP_CMD_IOC_RUN, &uparm);
+
+       close(ktap_fd);
+       close(ktapvm_fd);
+
+       return ret;
+}
+
+int verbose;
+static int quiet;
+static int dump_bytecode;
+static char oneline_src[1024];
+static int trace_pid = -1;
+static int trace_cpu = -1;
+static int print_timestamp;
+
+#define SIMPLE_ONE_LINER_FMT   \
+       "trace %s { print(cpu(), tid(), execname(), argevent) }"
+
+static const char *script_file;
+static int script_args_start;
+static int script_args_end;
+
+#ifndef NO_LIBELF
+struct binary_base
+{
+       int type;
+       const char *binary;
+};
+static int print_symbol(const char *name, vaddr_t addr, void *arg)
+{
+       struct binary_base *base = (struct binary_base *)arg;
+       const char *type = base->type == FIND_SYMBOL ?
+               "probe" : "sdt";
+
+       printf("%s:%s:%s\n", type, base->binary, name);
+       return 0;
+}
+#endif
+
+static void parse_option(int argc, char **argv)
+{
+       char pid[32] = {0};
+       char cpu_str[32] = {0};
+       char *next_arg;
+       int i, j;
+
+       for (i = 1; i < argc; i++) {
+               if (argv[i][0] != '-') {
+                       script_file = argv[i];
+                       if (!script_file)
+                               usage("");
+
+                       script_args_start = i + 1;
+                       script_args_end = argc;
+
+                       for (j = i + 1; j < argc; j++) {
+                               if (argv[j][0] == '-' && argv[j][1] == '-')
+                                       goto found_cmd;
+                       }
+
+                       return;
+               }
+
+               if (argv[i][0] == '-' && argv[i][1] == '-') {
+                       j = i;
+                       goto found_cmd;
+               }
+
+               next_arg = argv[i + 1];
+
+               switch (argv[i][1]) {
+               case 'o':
+                       output_filename = malloc(strlen(next_arg) + 1);
+                       if (!output_filename)
+                               return;
+
+                       strncpy(output_filename, next_arg, strlen(next_arg));
+                       i++;
+                       break;
+               case 'e':
+                       strncpy(oneline_src, next_arg, strlen(next_arg));
+                       i++;
+                       break;
+               case 'p':
+                       strncpy(pid, next_arg, strlen(next_arg));
+                       trace_pid = atoi(pid);
+                       i++;
+                       break;
+               case 'C':
+                       strncpy(cpu_str, next_arg, strlen(next_arg));
+                       trace_cpu = atoi(cpu_str);
+                       i++;
+                       break;
+               case 'T':
+                       print_timestamp = 1;
+                       break;
+               case 'v':
+                       verbose = 1;
+                       break;
+               case 'q':
+                       quiet = 1;
+                       break;
+               case 's':
+                       sprintf(oneline_src, SIMPLE_ONE_LINER_FMT, next_arg);
+                       i++;
+                       break;
+               case 'b':
+                       dump_bytecode = 1;
+                       break;
+               case 'l': /* list available events */
+                       switch (argv[i][2]) {
+                       case 'e': /* tracepoints */
+                               list_available_events(next_arg);
+                               exit(EXIT_SUCCESS);
+#ifndef NO_LIBELF
+                       case 'f': /* functions in DSO */
+                       case 'm': /* static marks in DSO */ {
+                               const char *binary = next_arg;
+                               int type = argv[i][2] == 'f' ?
+                                               FIND_SYMBOL : FIND_STAPSDT_NOTE;
+                               struct binary_base base = {
+                                       .type = type,
+                                       .binary = binary,
+                               };
+                               int ret;
+
+                               ret = parse_dso_symbols(binary, type,
+                                                       print_symbol,
+                                                       (void *)&base);
+                               if (ret <= 0) {
+                                       fprintf(stderr,
+                                       "error: no symbols in binary %s\n",
+                                               binary);
+                                       exit(EXIT_FAILURE);
+                               }
+                               exit(EXIT_SUCCESS);
+                       }
+#endif
+                       default:
+                               exit(EXIT_FAILURE);
+                       }
+                       break;
+               case 'V':
+#ifdef CONFIG_KTAP_FFI
+                       usage("%s (with FFI)\n\n", KTAP_VERSION);
+#else
+                       usage("%s\n\n", KTAP_VERSION);
+#endif
+                       break;
+               case '?':
+               case 'h':
+                       usage("");
+                       break;
+               default:
+                       usage("wrong argument\n");
+                       break;
+               }
+       }
+
+       return;
+
+ found_cmd:
+       script_args_end = j;
+       forks = 1;
+       workload_argv = &argv[j + 1];
+}
+
+static void compile(const char *input)
+{
+       ktap_closure *cl;
+       char *buff;
+       struct stat sb;
+       int fdin;
+
+       if (oneline_src[0] != '\0') {
+               init_dummy_global_state();
+               ffi_cparser_init();
+               cl = ktapc_parser(oneline_src, input);
+               goto dump;
+       }
+
+       fdin = open(input, O_RDONLY);
+       if (fdin < 0) {
+               fprintf(stderr, "open file %s failed\n", input);
+               exit(-1);
+       }
+
+       if (fstat(fdin, &sb) == -1)
+               handle_error("fstat failed");
+
+       buff = mmap(NULL, sb.st_size, PROT_READ, MAP_PRIVATE, fdin, 0);
+       if (buff == MAP_FAILED)
+               handle_error("mmap failed");
+
+       init_dummy_global_state();
+       ffi_cparser_init();
+       cl = ktapc_parser(buff, input);
+
+       munmap(buff, sb.st_size);
+       close(fdin);
+
+ dump:
+       if (dump_bytecode) {
+               dump_function(1, cl->p);
+               exit(0);
+       }
+
+       /* ktapc output */
+       uparm.trunk = malloc(ktap_trunk_mem_size);
+       if (!uparm.trunk)
+               handle_error("malloc failed");
+
+       ktapc_dump(cl->p, ktapc_writer, NULL, 0);
+       ffi_cparser_free();
+}
+
+int main(int argc, char **argv)
+{
+       char **ktapvm_argv;
+       int new_index, i;
+       int ret;
+
+       if (argc == 1)
+               usage("");
+
+       parse_option(argc, argv);
+
+       if (oneline_src[0] != '\0')
+               script_file = "one-liner";
+
+       compile(script_file);
+
+       ktapvm_argv = (char **)malloc(sizeof(char *)*(script_args_end -
+                                       script_args_start + 1));
+       if (!ktapvm_argv) {
+               fprintf(stderr, "canno allocate ktapvm_argv\n");
+               return -1;
+       }
+
+       ktapvm_argv[0] = malloc(strlen(script_file) + 1);
+       if (!ktapvm_argv[0]) {
+               fprintf(stderr, "canno allocate memory\n");
+               return -1;
+       }
+       strcpy(ktapvm_argv[0], script_file);
+       ktapvm_argv[0][strlen(script_file)] = '\0';
+
+       /* pass rest argv into ktapvm */
+       new_index = 1;
+       for (i = script_args_start; i < script_args_end; i++) {
+               ktapvm_argv[new_index] = malloc(strlen(argv[i]) + 1);
+               if (!ktapvm_argv[new_index]) {
+                       fprintf(stderr, "canno allocate memory\n");
+                       return -1;
+               }
+               strcpy(ktapvm_argv[new_index], argv[i]);
+               ktapvm_argv[new_index][strlen(argv[i])] = '\0';
+               new_index++;
+       }
+
+       uparm.argv = ktapvm_argv;
+       uparm.argc = new_index;
+       uparm.verbose = verbose;
+       uparm.trace_pid = trace_pid;
+       uparm.trace_cpu = trace_cpu;
+       uparm.print_timestamp = print_timestamp;
+       uparm.quiet = quiet;
+
+       /* start running into kernel ktapvm */
+       ret = run_ktapvm();
+
+       cleanup_event_resources();
+       return ret;
+}
+
+
diff --git a/drivers/staging/ktap/userspace/parser.c b/drivers/staging/ktap/userspace/parser.c
new file mode 100644 (file)
index 0000000..f47c0c0
--- /dev/null
@@ -0,0 +1,1963 @@
+/*
+ * parser.c - ktap parser
+ *
+ * This file is part of ktap by Jovi Zhangwei.
+ *
+ * Copyright (C) 2012-2013 Jovi Zhangwei <jovi.zhangwei@gmail.com>.
+ *
+ * Copyright (C) 1994-2013 Lua.org, PUC-Rio.
+ *  - The part of code in this file is copied from lua initially.
+ *  - lua's MIT license is compatible with GPL.
+ *
+ * ktap 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.
+ *
+ * ktap is distributed in the hope it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
+ * more details.
+ *
+ * You should have received a copy of the GNU General Public License along with
+ * this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include "../include/ktap_types.h"
+#include "../include/ktap_opcodes.h"
+#include "ktapc.h"
+#include "cparser.h"
+
+/* maximum number of local variables per function (must be smaller
+   than 250, due to the bytecode format) */
+#define MAXVARS                200
+
+#define hasmultret(k)          ((k) == VCALL || (k) == VVARARG)
+
+/*
+ * nodes for block list (list of active blocks)
+ */
+typedef struct ktap_blockcnt {
+       struct ktap_blockcnt *previous;  /* chain */
+       short firstlabel;  /* index of first label in this block */
+       short firstgoto;  /* index of first pending goto in this block */
+       u8 nactvar;  /* # active locals outside the block */
+       u8 upval;  /* true if some variable in the block is an upvalue */
+        u8 isloop;  /* true if `block' is a loop */
+} ktap_blockcnt;
+
+/*
+ * prototypes for recursive non-terminal functions
+ */
+static void statement (ktap_lexstate *ls);
+static void expr (ktap_lexstate *ls, ktap_expdesc *v);
+
+static void anchor_token(ktap_lexstate *ls)
+{
+       /* last token from outer function must be EOS */
+       ktap_assert((int)(ls->fs != NULL) || ls->t.token == TK_EOS);
+       if (ls->t.token == TK_NAME || ls->t.token == TK_STRING) {
+               ktap_string *ts = ls->t.seminfo.ts;
+               lex_newstring(ls, getstr(ts), ts->tsv.len);
+       }
+}
+
+/* semantic error */
+static void semerror(ktap_lexstate *ls, const char *msg)
+{
+       ls->t.token = 0;  /* remove 'near to' from final message */
+       lex_syntaxerror(ls, msg);
+}
+
+static void error_expected(ktap_lexstate *ls, int token)
+{
+       lex_syntaxerror(ls,
+               ktapc_sprintf("%s expected", lex_token2str(ls, token)));
+}
+
+static void errorlimit(ktap_funcstate *fs, int limit, const char *what)
+{
+       const char *msg;
+       int line = fs->f->linedefined;
+       const char *where = (line == 0) ? "main function"
+                               : ktapc_sprintf("function at line %d", line);
+
+       msg = ktapc_sprintf("too many %s (limit is %d) in %s",
+                               what, limit, where);
+       lex_syntaxerror(fs->ls, msg);
+}
+
+static void checklimit(ktap_funcstate *fs, int v, int l, const char *what)
+{
+       if (v > l)
+               errorlimit(fs, l, what);
+}
+
+static int testnext(ktap_lexstate *ls, int c)
+{
+       if (ls->t.token == c) {
+               lex_next(ls);
+               return 1;
+       }
+       else
+               return 0;
+}
+
+static void check(ktap_lexstate *ls, int c)
+{
+       if (ls->t.token != c)
+               error_expected(ls, c);
+}
+
+static void checknext(ktap_lexstate *ls, int c)
+{
+       check(ls, c);
+       lex_next(ls);
+}
+
+#define check_condition(ls,c,msg)      { if (!(c)) lex_syntaxerror(ls, msg); }
+
+static void check_match(ktap_lexstate *ls, int what, int who, int where)
+{
+       if (!testnext(ls, what)) {
+               if (where == ls->linenumber)
+                       error_expected(ls, what);
+               else {
+                       lex_syntaxerror(ls, ktapc_sprintf(
+                                       "%s expected (to close %s at line %d)",
+                                       lex_token2str(ls, what),
+                                       lex_token2str(ls, who), where));
+               }
+       }
+}
+
+static ktap_string *str_checkname(ktap_lexstate *ls)
+{
+       ktap_string *ts;
+
+       check(ls, TK_NAME);
+       ts = ls->t.seminfo.ts;
+       lex_next(ls);
+       return ts;
+}
+
+static void init_exp(ktap_expdesc *e, expkind k, int i)
+{
+       e->f = e->t = NO_JUMP;
+       e->k = k;
+       e->u.info = i;
+}
+
+static void codestring(ktap_lexstate *ls, ktap_expdesc *e, ktap_string *s)
+{
+       init_exp(e, VK, codegen_stringK(ls->fs, s));
+}
+
+static void codenumber(ktap_lexstate *ls, ktap_expdesc *e, ktap_number n)
+{
+       init_exp(e, VK, codegen_numberK(ls->fs, n));
+}
+
+static void checkname(ktap_lexstate *ls, ktap_expdesc *e)
+{
+       codestring(ls, e, str_checkname(ls));
+}
+
+static int registerlocalvar(ktap_lexstate *ls, ktap_string *varname)
+{
+       ktap_funcstate *fs = ls->fs;
+       ktap_proto *f = fs->f;
+       int oldsize = f->sizelocvars;
+
+       ktapc_growvector(f->locvars, fs->nlocvars, f->sizelocvars,
+                        ktap_locvar, SHRT_MAX, "local variables");
+
+       while (oldsize < f->sizelocvars)
+               f->locvars[oldsize++].varname = NULL;
+
+       f->locvars[fs->nlocvars].varname = varname;
+       return fs->nlocvars++;
+}
+
+static void new_localvar(ktap_lexstate *ls, ktap_string *name)
+{
+       ktap_funcstate *fs = ls->fs;
+       ktap_dyndata *dyd = ls->dyd;
+       int reg = registerlocalvar(ls, name);
+
+       checklimit(fs, dyd->actvar.n + 1 - fs->firstlocal,
+                  MAXVARS, "local variables");
+       ktapc_growvector(dyd->actvar.arr, dyd->actvar.n + 1,
+                        dyd->actvar.size, ktap_vardesc, MAX_INT, "local variables");
+       dyd->actvar.arr[dyd->actvar.n++].idx = (short)reg;
+}
+
+static void new_localvarliteral_(ktap_lexstate *ls, const char *name, size_t sz)
+{
+       new_localvar(ls, lex_newstring(ls, name, sz));
+}
+
+#define new_localvarliteral(ls,v) \
+       new_localvarliteral_(ls, "" v, (sizeof(v)/sizeof(char))-1)
+
+static ktap_locvar *getlocvar(ktap_funcstate *fs, int i)
+{
+       int idx = fs->ls->dyd->actvar.arr[fs->firstlocal + i].idx;
+
+       ktap_assert(idx < fs->nlocvars);
+       return &fs->f->locvars[idx];
+}
+
+static void adjustlocalvars(ktap_lexstate *ls, int nvars)
+{
+       ktap_funcstate *fs = ls->fs;
+
+       fs->nactvar = (u8)(fs->nactvar + nvars);
+       for (; nvars; nvars--) {
+               getlocvar(fs, fs->nactvar - nvars)->startpc = fs->pc;
+       }
+}
+
+static void removevars(ktap_funcstate *fs, int tolevel)
+{
+       fs->ls->dyd->actvar.n -= (fs->nactvar - tolevel);
+
+       while (fs->nactvar > tolevel)
+               getlocvar(fs, --fs->nactvar)->endpc = fs->pc;
+}
+
+static int searchupvalue(ktap_funcstate *fs, ktap_string *name)
+{
+       int i;
+       ktap_upvaldesc *up = fs->f->upvalues;
+
+       for (i = 0; i < fs->nups; i++) {
+               if (ktapc_ts_eqstr(up[i].name, name))
+                       return i;
+       }
+       return -1;  /* not found */
+}
+
+static int newupvalue(ktap_funcstate *fs, ktap_string *name, ktap_expdesc *v)
+{
+       ktap_proto *f = fs->f;
+       int oldsize = f->sizeupvalues;
+
+       checklimit(fs, fs->nups + 1, MAXUPVAL, "upvalues");
+       ktapc_growvector(f->upvalues, fs->nups, f->sizeupvalues,
+                        ktap_upvaldesc, MAXUPVAL, "upvalues");
+
+       while (oldsize < f->sizeupvalues)
+               f->upvalues[oldsize++].name = NULL;
+       f->upvalues[(int)fs->nups].instack = (v->k == VLOCAL);
+       f->upvalues[(int)fs->nups].idx = (u8)(v->u.info);
+       f->upvalues[(int)fs->nups].name = name;
+       return fs->nups++;
+}
+
+static int searchvar(ktap_funcstate *fs, ktap_string *n)
+{
+       int i;
+
+       for (i = fs->nactvar-1; i >= 0; i--) {
+               if (ktapc_ts_eqstr(n, getlocvar(fs, i)->varname))
+                       return i;
+       }
+       return -1;  /* not found */
+}
+
+/*
+ * Mark block where variable at given level was defined
+ * (to emit close instructions later).
+ */
+static void markupval(ktap_funcstate *fs, int level)
+{
+       ktap_blockcnt *bl = fs->bl;
+
+       while (bl->nactvar > level)
+               bl = bl->previous;
+       bl->upval = 1;
+}
+
+/*
+ * Find variable with given name 'n'. If it is an upvalue, add this
+ * upvalue into all intermediate functions.
+ */
+static int singlevaraux(ktap_funcstate *fs, ktap_string *n, ktap_expdesc *var, int base)
+{
+       if (fs == NULL)  /* no more levels? */
+               return VVOID;  /* default is global */
+       else {
+               int v = searchvar(fs, n);  /* look up locals at current level */
+               if (v >= 0) {  /* found? */
+                       init_exp(var, VLOCAL, v);  /* variable is local */
+                       if (!base)
+                               markupval(fs, v);  /* local will be used as an upval */
+                       return VLOCAL;
+               } else {  /* not found as local at current level; try upvalues */
+                       int idx = searchupvalue(fs, n);  /* try existing upvalues */
+                       if (idx < 0) {  /* not found? */
+                               if (singlevaraux(fs->prev, n, var, 0) == VVOID) /* try upper levels */
+                                       return VVOID;  /* not found; is a global */
+                               /* else was LOCAL or UPVAL */
+                               idx  = newupvalue(fs, n, var);  /* will be a new upvalue */
+                       }
+                       init_exp(var, VUPVAL, idx);
+                       return VUPVAL;
+               }
+       }
+}
+
+static void singlevar(ktap_lexstate *ls, ktap_expdesc *var)
+{
+       ktap_string *varname = str_checkname(ls);
+       ktap_funcstate *fs = ls->fs;
+
+       if (singlevaraux(fs, varname, var, 1) == VVOID) {  /* global name? */
+               ktap_expdesc key;
+               singlevaraux(fs, ls->envn, var, 1);  /* get environment variable */
+               ktap_assert(var->k == VLOCAL || var->k == VUPVAL);
+               codestring(ls, &key, varname);  /* key is variable name */
+               codegen_indexed(fs, var, &key);  /* env[varname] */
+       }
+}
+
+static void adjust_assign(ktap_lexstate *ls, int nvars, int nexps, ktap_expdesc *e)
+{
+       ktap_funcstate *fs = ls->fs;
+       int extra = nvars - nexps;
+
+       if (hasmultret(e->k)) {
+               extra++;  /* includes call itself */
+               if (extra < 0)
+                       extra = 0;
+               codegen_setreturns(fs, e, extra);  /* last exp. provides the difference */
+               if (extra > 1)
+                       codegen_reserveregs(fs, extra-1);
+       } else {
+               if (e->k != VVOID)
+                       codegen_exp2nextreg(fs, e);  /* close last expression */
+               if (extra > 0) {
+                       int reg = fs->freereg;
+
+                       codegen_reserveregs(fs, extra);
+                       codegen_nil(fs, reg, extra);
+               }
+       }
+}
+
+static void enterlevel(ktap_lexstate *ls)
+{
+       ++ls->nCcalls;
+       checklimit(ls->fs, ls->nCcalls, KTAP_MAXCCALLS, "C levels");
+}
+
+static void closegoto(ktap_lexstate *ls, int g, ktap_labeldesc *label)
+{
+       int i;
+       ktap_funcstate *fs = ls->fs;
+       ktap_labellist *gl = &ls->dyd->gt;
+       ktap_labeldesc *gt = &gl->arr[g];
+
+       ktap_assert(ktapc_ts_eqstr(gt->name, label->name));
+       if (gt->nactvar < label->nactvar) {
+               ktap_string *vname = getlocvar(fs, gt->nactvar)->varname;
+               const char *msg = ktapc_sprintf(
+                       "<goto %s> at line %d jumps into the scope of local " KTAP_QS,
+                       getstr(gt->name), gt->line, getstr(vname));
+               semerror(ls, msg);
+       }
+
+       codegen_patchlist(fs, gt->pc, label->pc);
+       /* remove goto from pending list */
+       for (i = g; i < gl->n - 1; i++)
+               gl->arr[i] = gl->arr[i + 1];
+       gl->n--;
+}
+
+/*
+ * try to close a goto with existing labels; this solves backward jumps
+ */
+static int findlabel(ktap_lexstate *ls, int g)
+{
+       int i;
+       ktap_blockcnt *bl = ls->fs->bl;
+       ktap_dyndata *dyd = ls->dyd;
+       ktap_labeldesc *gt = &dyd->gt.arr[g];
+
+       /* check labels in current block for a match */
+       for (i = bl->firstlabel; i < dyd->label.n; i++) {
+               ktap_labeldesc *lb = &dyd->label.arr[i];
+               if (ktapc_ts_eqstr(lb->name, gt->name)) {  /* correct label? */
+                       if (gt->nactvar > lb->nactvar &&
+                               (bl->upval || dyd->label.n > bl->firstlabel))
+                               codegen_patchclose(ls->fs, gt->pc, lb->nactvar);
+                       closegoto(ls, g, lb);  /* close it */
+                       return 1;
+               }
+       }
+       return 0;  /* label not found; cannot close goto */
+}
+
+static int newlabelentry(ktap_lexstate *ls, ktap_labellist *l, ktap_string *name,
+                        int line, int pc)
+{
+       int n = l->n;
+
+       ktapc_growvector(l->arr, n, l->size,
+                        ktap_labeldesc, SHRT_MAX, "labels/gotos");
+       l->arr[n].name = name;
+       l->arr[n].line = line;
+       l->arr[n].nactvar = ls->fs->nactvar;
+       l->arr[n].pc = pc;
+       l->n++;
+       return n;
+}
+
+
+/*
+ * check whether new label 'lb' matches any pending gotos in current
+ * block; solves forward jumps
+ */
+static void findgotos(ktap_lexstate *ls, ktap_labeldesc *lb)
+{
+       ktap_labellist *gl = &ls->dyd->gt;
+       int i = ls->fs->bl->firstgoto;
+
+       while (i < gl->n) {
+               if (ktapc_ts_eqstr(gl->arr[i].name, lb->name))
+                       closegoto(ls, i, lb);
+               else
+                       i++;
+       }
+}
+
+/*
+ * "export" pending gotos to outer level, to check them against
+ * outer labels; if the block being exited has upvalues, and
+ * the goto exits the scope of any variable (which can be the
+ * upvalue), close those variables being exited.
+ */
+static void movegotosout(ktap_funcstate *fs, ktap_blockcnt *bl)
+{
+       int i = bl->firstgoto;
+       ktap_labellist *gl = &fs->ls->dyd->gt;
+
+       /* correct pending gotos to current block and try to close it
+               with visible labels */
+       while (i < gl->n) {
+               ktap_labeldesc *gt = &gl->arr[i];
+
+               if (gt->nactvar > bl->nactvar) {
+                       if (bl->upval)
+                               codegen_patchclose(fs, gt->pc, bl->nactvar);
+                       gt->nactvar = bl->nactvar;
+               }
+               if (!findlabel(fs->ls, i))
+                       i++;  /* move to next one */
+       }
+}
+
+static void enterblock(ktap_funcstate *fs, ktap_blockcnt *bl, u8 isloop)
+{
+       bl->isloop = isloop;
+       bl->nactvar = fs->nactvar;
+       bl->firstlabel = fs->ls->dyd->label.n;
+       bl->firstgoto = fs->ls->dyd->gt.n;
+       bl->upval = 0;
+       bl->previous = fs->bl;
+       fs->bl = bl;
+       ktap_assert(fs->freereg == fs->nactvar);
+}
+
+
+/*
+ * create a label named "break" to resolve break statements
+ */
+static void breaklabel(ktap_lexstate *ls)
+{
+       ktap_string *n = ktapc_ts_new("break");
+       int l = newlabelentry(ls, &ls->dyd->label, n, 0, ls->fs->pc);
+
+       findgotos(ls, &ls->dyd->label.arr[l]);
+}
+
+/*
+ * generates an error for an undefined 'goto'; choose appropriate
+ * message when label name is a reserved word (which can only be 'break')
+ */
+static void undefgoto(ktap_lexstate *ls, ktap_labeldesc *gt)
+{
+       const char *msg = isreserved(gt->name)
+                       ? "<%s> at line %d not inside a loop"
+                       : "no visible label " KTAP_QS " for <goto> at line %d";
+
+       msg = ktapc_sprintf(msg, getstr(gt->name), gt->line);
+       semerror(ls, msg);
+}
+
+static void leaveblock(ktap_funcstate *fs)
+{
+       ktap_blockcnt *bl = fs->bl;
+       ktap_lexstate *ls = fs->ls;
+       if (bl->previous && bl->upval) {
+               /* create a 'jump to here' to close upvalues */
+               int j = codegen_jump(fs);
+
+               codegen_patchclose(fs, j, bl->nactvar);
+               codegen_patchtohere(fs, j);
+       }
+
+       if (bl->isloop)
+               breaklabel(ls);  /* close pending breaks */
+
+       fs->bl = bl->previous;
+       removevars(fs, bl->nactvar);
+       ktap_assert(bl->nactvar == fs->nactvar);
+       fs->freereg = fs->nactvar;  /* free registers */
+       ls->dyd->label.n = bl->firstlabel;  /* remove local labels */
+       if (bl->previous)  /* inner block? */
+               movegotosout(fs, bl);  /* update pending gotos to outer block */
+       else if (bl->firstgoto < ls->dyd->gt.n)  /* pending gotos in outer block? */
+               undefgoto(ls, &ls->dyd->gt.arr[bl->firstgoto]);  /* error */
+}
+
+/*
+ * adds a new prototype into list of prototypes
+ */
+static ktap_proto *addprototype(ktap_lexstate *ls)
+{
+       ktap_proto *clp;
+       ktap_funcstate *fs = ls->fs;
+       ktap_proto *f = fs->f;  /* prototype of current function */
+
+       if (fs->np >= f->sizep) {
+               int oldsize = f->sizep;
+               ktapc_growvector(f->p, fs->np, f->sizep, ktap_proto *, MAXARG_Bx, "functions");
+               while (oldsize < f->sizep)
+                       f->p[oldsize++] = NULL;
+       }
+       f->p[fs->np++] = clp = ktapc_newproto();
+       return clp;
+}
+
+/*
+ * codes instruction to create new closure in parent function
+ */
+static void codeclosure(ktap_lexstate *ls, ktap_expdesc *v)
+{
+       ktap_funcstate *fs = ls->fs->prev;
+       init_exp(v, VRELOCABLE, codegen_codeABx(fs, OP_CLOSURE, 0, fs->np - 1));
+       codegen_exp2nextreg(fs, v);  /* fix it at stack top (for GC) */
+}
+
+static void open_func(ktap_lexstate *ls, ktap_funcstate *fs, ktap_blockcnt *bl)
+{
+       ktap_proto *f;
+
+       fs->prev = ls->fs;  /* linked list of funcstates */
+       fs->ls = ls;
+       ls->fs = fs;
+       fs->pc = 0;
+       fs->lasttarget = 0;
+       fs->jpc = NO_JUMP;
+       fs->freereg = 0;
+       fs->nk = 0;
+       fs->np = 0;
+       fs->nups = 0;
+       fs->nlocvars = 0;
+       fs->nactvar = 0;
+       fs->firstlocal = ls->dyd->actvar.n;
+       fs->bl = NULL;
+       f = fs->f;
+       f->source = ls->source;
+       f->maxstacksize = 2;  /* registers 0/1 are always valid */
+       fs->h = ktapc_table_new();
+       //table_resize(NULL, fs->h, 32, 32);
+       enterblock(fs, bl, 0);
+}
+
+static void close_func(ktap_lexstate *ls)
+{
+       ktap_funcstate *fs = ls->fs;
+       ktap_proto *f = fs->f;
+
+       codegen_ret(fs, 0, 0);  /* final return */
+       leaveblock(fs);
+       ktapc_reallocvector(f->code, f->sizecode, fs->pc, ktap_instruction);
+       f->sizecode = fs->pc;
+       ktapc_reallocvector(f->lineinfo, f->sizelineinfo, fs->pc, int);
+       f->sizelineinfo = fs->pc;
+       ktapc_reallocvector(f->k, f->sizek, fs->nk, ktap_value);
+       f->sizek = fs->nk;
+       ktapc_reallocvector(f->p, f->sizep, fs->np, ktap_proto *);
+       f->sizep = fs->np;
+       ktapc_reallocvector(f->locvars, f->sizelocvars, fs->nlocvars, ktap_locvar);
+       f->sizelocvars = fs->nlocvars;
+       ktapc_reallocvector(f->upvalues, f->sizeupvalues, fs->nups, ktap_upvaldesc);
+       f->sizeupvalues = fs->nups;
+       ktap_assert((int)(fs->bl == NULL));
+       ls->fs = fs->prev;
+       /* last token read was anchored in defunct function; must re-anchor it */
+       anchor_token(ls);
+}
+
+
+/*============================================================*/
+/* GRAMMAR RULES */
+/*============================================================*/
+
+/*
+ * check whether current token is in the follow set of a block.
+ * 'until' closes syntactical blocks, but do not close scope,
+ * so it handled in separate.
+ */
+static int block_follow(ktap_lexstate *ls, int withuntil)
+{
+       switch (ls->t.token) {
+       case TK_ELSE: case TK_ELSEIF:
+       case TK_END: case TK_EOS:
+               return 1;
+       case TK_UNTIL:
+               return withuntil;
+       case '}':
+               return 1;
+       default:
+               return 0;
+       }
+}
+
+static void statlist(ktap_lexstate *ls)
+{
+       /* statlist -> { stat [`;'] } */
+       while (!block_follow(ls, 1)) {
+               if (ls->t.token == TK_RETURN) {
+                       statement(ls);
+                       return;  /* 'return' must be last statement */
+               }
+               statement(ls);
+       }
+}
+
+static void fieldsel(ktap_lexstate *ls, ktap_expdesc *v)
+{
+       /* fieldsel -> ['.' | ':'] NAME */
+       ktap_funcstate *fs = ls->fs;
+       ktap_expdesc key;
+
+       codegen_exp2anyregup(fs, v);
+       lex_next(ls);  /* skip the dot or colon */
+       checkname(ls, &key);
+       codegen_indexed(fs, v, &key);
+}
+
+static void yindex(ktap_lexstate *ls, ktap_expdesc *v)
+{
+       /* index -> '[' expr ']' */
+       lex_next(ls);  /* skip the '[' */
+       expr(ls, v);
+       codegen_exp2val(ls->fs, v);
+       checknext(ls, ']');
+}
+
+/*
+ * {======================================================================
+ * Rules for Constructors
+ * =======================================================================
+ */
+struct ConsControl {
+       ktap_expdesc v;  /* last list item read */
+       ktap_expdesc *t;  /* table descriptor */
+       int nh;  /* total number of `record' elements */
+       int na;  /* total number of array elements */
+       int tostore;  /* number of array elements pending to be stored */
+};
+
+static void recfield(ktap_lexstate *ls, struct ConsControl *cc)
+{
+       /* recfield -> (NAME | `['exp1`]') = exp1 */
+       ktap_funcstate *fs = ls->fs;
+       int reg = ls->fs->freereg;
+       ktap_expdesc key, val;
+       int rkkey;
+
+       if (ls->t.token == TK_NAME) {
+               checklimit(fs, cc->nh, MAX_INT, "items in a constructor");
+               checkname(ls, &key);
+       } else  /* ls->t.token == '[' */
+               yindex(ls, &key);
+
+       cc->nh++;
+       checknext(ls, '=');
+       rkkey = codegen_exp2RK(fs, &key);
+       expr(ls, &val);
+       codegen_codeABC(fs, OP_SETTABLE, cc->t->u.info, rkkey, codegen_exp2RK(fs, &val));
+       fs->freereg = reg;  /* free registers */
+}
+
+static void closelistfield(ktap_funcstate *fs, struct ConsControl *cc)
+{
+       if (cc->v.k == VVOID)
+               return;  /* there is no list item */
+       codegen_exp2nextreg(fs, &cc->v);
+       cc->v.k = VVOID;
+       if (cc->tostore == LFIELDS_PER_FLUSH) {
+               codegen_setlist(fs, cc->t->u.info, cc->na, cc->tostore);  /* flush */
+               cc->tostore = 0;  /* no more items pending */
+       }
+}
+
+static void lastlistfield(ktap_funcstate *fs, struct ConsControl *cc)
+{
+       if (cc->tostore == 0)
+               return;
+
+       if (hasmultret(cc->v.k)) {
+               codegen_setmultret(fs, &cc->v);
+               codegen_setlist(fs, cc->t->u.info, cc->na, KTAP_MULTRET);
+               cc->na--;  /* do not count last expression (unknown number of elements) */
+       } else {
+               if (cc->v.k != VVOID)
+                       codegen_exp2nextreg(fs, &cc->v);
+               codegen_setlist(fs, cc->t->u.info, cc->na, cc->tostore);
+       }
+}
+
+static void listfield(ktap_lexstate *ls, struct ConsControl *cc)
+{
+       /* listfield -> exp */
+       expr(ls, &cc->v);
+       checklimit(ls->fs, cc->na, MAX_INT, "items in a constructor");
+       cc->na++;
+       cc->tostore++;
+}
+
+static void field(ktap_lexstate *ls, struct ConsControl *cc)
+{
+       /* field -> listfield | recfield */
+       switch(ls->t.token) {
+       case TK_NAME: {  /* may be 'listfield' or 'recfield' */
+               if (lex_lookahead(ls) != '=')  /* expression? */
+                       listfield(ls, cc);
+               else
+                       recfield(ls, cc);
+               break;
+       }
+       case '[': {
+               recfield(ls, cc);
+               break;
+       }
+       default:
+               listfield(ls, cc);
+               break;
+       }
+}
+
+static void constructor(ktap_lexstate *ls, ktap_expdesc *t)
+{
+       /* constructor -> '{' [ field { sep field } [sep] ] '}'
+               sep -> ',' | ';' */
+       ktap_funcstate *fs = ls->fs;
+       int line = ls->linenumber;
+       int pc = codegen_codeABC(fs, OP_NEWTABLE, 0, 0, 0);
+       struct ConsControl cc;
+
+       cc.na = cc.nh = cc.tostore = 0;
+       cc.t = t;
+       init_exp(t, VRELOCABLE, pc);
+       init_exp(&cc.v, VVOID, 0);  /* no value (yet) */
+       codegen_exp2nextreg(ls->fs, t);  /* fix it at stack top */
+       checknext(ls, '{');
+       do {
+               ktap_assert(cc.v.k == VVOID || cc.tostore > 0);
+               if (ls->t.token == '}')
+                       break;
+               closelistfield(fs, &cc);
+               field(ls, &cc);
+       } while (testnext(ls, ',') || testnext(ls, ';'));
+       check_match(ls, '}', '{', line);
+       lastlistfield(fs, &cc);
+       SETARG_B(fs->f->code[pc], ktapc_int2fb(cc.na)); /* set initial array size */
+       SETARG_C(fs->f->code[pc], ktapc_int2fb(cc.nh));  /* set initial table size */
+}
+
+/* }====================================================================== */
+
+static void parlist(ktap_lexstate *ls)
+{
+       /* parlist -> [ param { `,' param } ] */
+       ktap_funcstate *fs = ls->fs;
+       ktap_proto *f = fs->f;
+       int nparams = 0;
+       f->is_vararg = 0;
+
+       if (ls->t.token != ')') {  /* is `parlist' not empty? */
+               do {
+                       switch (ls->t.token) {
+                       case TK_NAME: {  /* param -> NAME */
+                               new_localvar(ls, str_checkname(ls));
+                               nparams++;
+                               break;
+                       }
+                       case TK_DOTS: {  /* param -> `...' */
+                               lex_next(ls);
+                               f->is_vararg = 1;
+                               break;
+                       }
+                       default:
+                               lex_syntaxerror(ls, "<name> or " KTAP_QL("...") " expected");
+                       }
+               } while (!f->is_vararg && testnext(ls, ','));
+       }
+       adjustlocalvars(ls, nparams);
+       f->numparams = (u8)(fs->nactvar);
+       codegen_reserveregs(fs, fs->nactvar);  /* reserve register for parameters */
+}
+
+static void body(ktap_lexstate *ls, ktap_expdesc *e, int ismethod, int line)
+{
+       /* body ->  `(' parlist `)' block END */
+       ktap_funcstate new_fs;
+       ktap_blockcnt bl;
+
+       new_fs.f = addprototype(ls);
+       new_fs.f->linedefined = line;
+       open_func(ls, &new_fs, &bl);
+       checknext(ls, '(');
+       if (ismethod) {
+               new_localvarliteral(ls, "self");  /* create 'self' parameter */
+               adjustlocalvars(ls, 1);
+       }
+       parlist(ls);
+       checknext(ls, ')');
+       checknext(ls, '{');
+       statlist(ls);
+       new_fs.f->lastlinedefined = ls->linenumber;
+       checknext(ls, '}');
+       //check_match(ls, TK_END, TK_FUNCTION, line);
+       codeclosure(ls, e);
+       close_func(ls);
+}
+
+static void func_body_no_args(ktap_lexstate *ls, ktap_expdesc *e, int line)
+{
+       /* body ->  `(' parlist `)' block END */
+       ktap_funcstate new_fs;
+       ktap_blockcnt bl;
+
+       new_fs.f = addprototype(ls);
+       new_fs.f->linedefined = line;
+       open_func(ls, &new_fs, &bl);
+       checknext(ls, '{');
+       statlist(ls);
+       new_fs.f->lastlinedefined = ls->linenumber;
+       checknext(ls, '}');
+       //check_match(ls, TK_END, TK_FUNCTION, line);
+       codeclosure(ls, e);
+       close_func(ls);
+}
+
+static int explist(ktap_lexstate *ls, ktap_expdesc *v)
+{
+       /* explist -> expr { `,' expr } */
+       int n = 1;  /* at least one expression */
+
+       expr(ls, v);
+       while (testnext(ls, ',')) {
+               codegen_exp2nextreg(ls->fs, v);
+               expr(ls, v);
+               n++;
+       }
+       return n;
+}
+
+static void funcargs(ktap_lexstate *ls, ktap_expdesc *f, int line)
+{
+       ktap_funcstate *fs = ls->fs;
+       ktap_expdesc args;
+       int base, nparams;
+
+       switch (ls->t.token) {
+       case '(': {  /* funcargs -> `(' [ explist ] `)' */
+               lex_next(ls);
+               if (ls->t.token == ')')  /* arg list is empty? */
+                       args.k = VVOID;
+               else {
+                       explist(ls, &args);
+                       codegen_setmultret(fs, &args);
+               }
+               check_match(ls, ')', '(', line);
+               break;
+       }
+       case '{': {  /* funcargs -> constructor */
+               constructor(ls, &args);
+               break;
+       }
+       case TK_STRING: {  /* funcargs -> STRING */
+               codestring(ls, &args, ls->t.seminfo.ts);
+               lex_next(ls);  /* must use `seminfo' before `next' */
+               break;
+       }
+       default: {
+               lex_syntaxerror(ls, "function arguments expected");
+       }
+       }
+       ktap_assert(f->k == VNONRELOC);
+       base = f->u.info;  /* base register for call */
+       if (hasmultret(args.k))
+               nparams = KTAP_MULTRET;  /* open call */
+       else {
+               if (args.k != VVOID)
+                       codegen_exp2nextreg(fs, &args);  /* close last argument */
+               nparams = fs->freereg - (base+1);
+       }
+       init_exp(f, VCALL, codegen_codeABC(fs, OP_CALL, base, nparams+1, 2));
+       codegen_fixline(fs, line);
+       fs->freereg = base+1;  /* call remove function and arguments and leaves
+                               (unless changed) one result */
+}
+
+/*
+ * {======================================================================
+ * Expression parsing
+ * =======================================================================
+ */
+static void primaryexp(ktap_lexstate *ls, ktap_expdesc *v)
+{
+       /* primaryexp -> NAME | '(' expr ')' */
+       switch (ls->t.token) {
+       case '(': {
+               int line = ls->linenumber;
+
+               lex_next(ls);
+               expr(ls, v);
+               check_match(ls, ')', '(', line);
+               codegen_dischargevars(ls->fs, v);
+               return;
+       }
+       case TK_NAME:
+               singlevar(ls, v);
+               return;
+       default:
+               lex_syntaxerror(ls, "unexpected symbol");
+       }
+}
+
+static void suffixedexp(ktap_lexstate *ls, ktap_expdesc *v)
+{
+       /* suffixedexp ->
+               primaryexp { '.' NAME | '[' exp ']' | ':' NAME funcargs | funcargs } */
+       ktap_funcstate *fs = ls->fs;
+       int line = ls->linenumber;
+
+       primaryexp(ls, v);
+       for (;;) {
+               switch (ls->t.token) {
+               case '.': {  /* fieldsel */
+                       fieldsel(ls, v);
+                       break;
+               }
+               case '[': {  /* `[' exp1 `]' */
+                       ktap_expdesc key;
+                       codegen_exp2anyregup(fs, v);
+                       yindex(ls, &key);
+                       codegen_indexed(fs, v, &key);
+                       break;
+               }
+               case ':': {  /* `:' NAME funcargs */
+                       ktap_expdesc key;
+                       lex_next(ls);
+                       checkname(ls, &key);
+                       codegen_self(fs, v, &key);
+                       funcargs(ls, v, line);
+                       break;
+               }
+               case '(': case TK_STRING: case '{': {  /* funcargs */
+                       codegen_exp2nextreg(fs, v);
+                       funcargs(ls, v, line);
+                       break;
+               }
+               default:
+                       return;
+               }
+       }
+}
+
+static void simpleexp(ktap_lexstate *ls, ktap_expdesc *v)
+{
+       /* simpleexp -> NUMBER | STRING | NIL | TRUE | FALSE | ... |
+               constructor | FUNCTION body | suffixedexp */
+       switch (ls->t.token) {
+       case TK_NUMBER: {
+               init_exp(v, VKNUM, 0);
+               v->u.nval = ls->t.seminfo.r;
+               break;
+       }
+       case TK_STRING: {
+               codestring(ls, v, ls->t.seminfo.ts);
+               break;
+       }
+       case TK_KSYM: {
+               init_exp(v, VKNUM, 0);
+               v->u.nval =
+               (ktap_number)find_kernel_symbol(getstr(ls->t.seminfo.ts));
+               break;
+       }
+       case TK_NIL: {
+               init_exp(v, VNIL, 0);
+               break;
+       }
+       case TK_TRUE: {
+               init_exp(v, VTRUE, 0);
+               break;
+       }
+       case TK_FALSE: {
+               init_exp(v, VFALSE, 0);
+               break;
+       }
+       case TK_DOTS: {  /* vararg */
+               ktap_funcstate *fs = ls->fs;
+               check_condition(ls, fs->f->is_vararg,
+                      "cannot use " KTAP_QL("...") " outside a vararg function");
+               init_exp(v, VVARARG, codegen_codeABC(fs, OP_VARARG, 0, 1, 0));
+               break;
+       }
+       case '{': {  /* constructor */
+               constructor(ls, v);
+               return;
+       }
+       case TK_FUNCTION: {
+               lex_next(ls);
+               body(ls, v, 0, ls->linenumber);
+               return;
+       }
+       case TK_ARGEVENT:
+               init_exp(v, VEVENT, 0);
+               break;
+
+       case TK_ARGNAME:
+               init_exp(v, VEVENTNAME, 0);
+               break;
+       case TK_ARG1:
+       case TK_ARG2:
+       case TK_ARG3:
+       case TK_ARG4:
+       case TK_ARG5:
+       case TK_ARG6:
+       case TK_ARG7:
+       case TK_ARG8:
+       case TK_ARG9:
+               init_exp(v, VEVENTARG, ls->t.token - TK_ARG1 + 1);
+               break;
+       default: {
+               suffixedexp(ls, v);
+               return;
+       }
+       }
+       lex_next(ls);
+}
+
+static UnOpr getunopr(int op)
+{
+       switch (op) {
+       case TK_NOT: return OPR_NOT;
+       case '-': return OPR_MINUS;
+       case '#': return OPR_LEN;
+       default: return OPR_NOUNOPR;
+       }
+}
+
+static BinOpr getbinopr(int op)
+{
+       switch (op) {
+       case '+': return OPR_ADD;
+       case '-': return OPR_SUB;
+       case '*': return OPR_MUL;
+       case '/': return OPR_DIV;
+       case '%': return OPR_MOD;
+       case '^': return OPR_POW;
+       case TK_CONCAT: return OPR_CONCAT;
+       case TK_NE: return OPR_NE;
+       case TK_EQ: return OPR_EQ;
+       case '<': return OPR_LT;
+       case TK_LE: return OPR_LE;
+       case '>': return OPR_GT;
+       case TK_GE: return OPR_GE;
+       case TK_AND: return OPR_AND;
+       case TK_OR: return OPR_OR;
+       default: return OPR_NOBINOPR;
+       }
+}
+
+static const struct {
+       u8 left;  /* left priority for each binary operator */
+       u8 right; /* right priority */
+} priority[] = {  /* ORDER OPR */
+       {6, 6}, {6, 6}, {7, 7}, {7, 7}, {7, 7},  /* `+' `-' `*' `/' `%' */
+       {10, 9}, {5, 4},                 /* ^, .. (right associative) */
+       {3, 3}, {3, 3}, {3, 3},          /* ==, <, <= */
+       {3, 3}, {3, 3}, {3, 3},          /* !=, >, >= */
+       {2, 2}, {1, 1}                   /* and, or */
+};
+
+#define UNARY_PRIORITY 8  /* priority for unary operators */
+
+#define leavelevel(ls) (ls->nCcalls--)
+
+/*
+ * subexpr -> (simpleexp | unop subexpr) { binop subexpr }
+ * where `binop' is any binary operator with a priority higher than `limit'
+ */
+static BinOpr subexpr(ktap_lexstate *ls, ktap_expdesc *v, int limit)
+{
+       BinOpr op;
+       UnOpr uop;
+
+       enterlevel(ls);
+       uop = getunopr(ls->t.token);
+       if (uop != OPR_NOUNOPR) {
+               int line = ls->linenumber;
+
+               lex_next(ls);
+               subexpr(ls, v, UNARY_PRIORITY);
+               codegen_prefix(ls->fs, uop, v, line);
+       } else
+               simpleexp(ls, v);
+
+       /* expand while operators have priorities higher than `limit' */
+       op = getbinopr(ls->t.token);
+       while (op != OPR_NOBINOPR && priority[op].left > limit) {
+               ktap_expdesc v2;
+               BinOpr nextop;
+               int line = ls->linenumber;
+
+               lex_next(ls);
+               codegen_infix(ls->fs, op, v);
+               /* read sub-expression with higher priority */
+               nextop = subexpr(ls, &v2, priority[op].right);
+               codegen_posfix(ls->fs, op, v, &v2, line);
+               op = nextop;
+       }
+       leavelevel(ls);
+       return op;  /* return first untreated operator */
+}
+
+static void expr(ktap_lexstate *ls, ktap_expdesc *v)
+{
+       subexpr(ls, v, 0);
+}
+
+/* }==================================================================== */
+
+/*
+ * {======================================================================
+ * Rules for Statements
+ * =======================================================================
+ */
+static void block(ktap_lexstate *ls)
+{
+       /* block -> statlist */
+       ktap_funcstate *fs = ls->fs;
+       ktap_blockcnt bl;
+
+       enterblock(fs, &bl, 0);
+       statlist(ls);
+       leaveblock(fs);
+}
+
+/*
+ * structure to chain all variables in the left-hand side of an
+ * assignment
+ */
+struct LHS_assign {
+       struct LHS_assign *prev;
+       ktap_expdesc v;  /* variable (global, local, upvalue, or indexed) */
+};
+
+/*
+ * check whether, in an assignment to an upvalue/local variable, the
+ * upvalue/local variable is begin used in a previous assignment to a
+ * table. If so, save original upvalue/local value in a safe place and
+ * use this safe copy in the previous assignment.
+ */
+static void check_conflict(ktap_lexstate *ls, struct LHS_assign *lh, ktap_expdesc *v)
+{
+       ktap_funcstate *fs = ls->fs;
+       int extra = fs->freereg;  /* eventual position to save local variable */
+       int conflict = 0;
+
+       for (; lh; lh = lh->prev) {  /* check all previous assignments */
+               if (lh->v.k == VINDEXED) {  /* assigning to a table? */
+                       /* table is the upvalue/local being assigned now? */
+                       if (lh->v.u.ind.vt == v->k && lh->v.u.ind.t == v->u.info) {
+                               conflict = 1;
+                               lh->v.u.ind.vt = VLOCAL;
+                               lh->v.u.ind.t = extra;  /* previous assignment will use safe copy */
+                       }
+                       /* index is the local being assigned? (index cannot be upvalue) */
+                       if (v->k == VLOCAL && lh->v.u.ind.idx == v->u.info) {
+                               conflict = 1;
+                               lh->v.u.ind.idx = extra;  /* previous assignment will use safe copy */
+                       }
+               }
+       }
+       if (conflict) {
+               /* copy upvalue/local value to a temporary (in position 'extra') */
+               OpCode op = (v->k == VLOCAL) ? OP_MOVE : OP_GETUPVAL;
+               codegen_codeABC(fs, op, extra, v->u.info, 0);
+               codegen_reserveregs(fs, 1);
+       }
+}
+
+static void assignment(ktap_lexstate *ls, struct LHS_assign *lh, int nvars)
+{
+       ktap_expdesc e;
+
+       check_condition(ls, vkisvar(lh->v.k), "syntax error");
+       if (testnext(ls, ',')) {  /* assignment -> ',' suffixedexp assignment */
+               struct LHS_assign nv;
+
+               nv.prev = lh;
+               suffixedexp(ls, &nv.v);
+               if (nv.v.k != VINDEXED)
+                       check_conflict(ls, lh, &nv.v);
+               checklimit(ls->fs, nvars + ls->nCcalls, KTAP_MAXCCALLS,
+                               "C levels");
+               assignment(ls, &nv, nvars+1);
+       } else if (testnext(ls, '=')) {  /* assignment -> '=' explist */
+               int nexps;
+
+               nexps = explist(ls, &e);
+               if (nexps != nvars) {
+                       adjust_assign(ls, nvars, nexps, &e);
+                       /* remove extra values */
+                       if (nexps > nvars)
+                               ls->fs->freereg -= nexps - nvars;
+               } else {
+                       /* close last expression */
+                       codegen_setoneret(ls->fs, &e);
+                       codegen_storevar(ls->fs, &lh->v, &e);
+                       return;  /* avoid default */
+               }
+       } else if (testnext(ls, TK_INCR)) { /* assignment -> '+=' explist */
+               int nexps;
+
+               nexps = explist(ls, &e);
+               if (nexps != nvars) {
+                       lex_syntaxerror(ls, "don't allow multi-assign for +=");
+               } else {
+                       /* close last expression */
+                       codegen_setoneret(ls->fs, &e);
+                       codegen_storeincr(ls->fs, &lh->v, &e);
+                       return;  /* avoid default */
+               }
+       } else if (testnext(ls, TK_AGGR_ASSIGN)) { /* assignment -> '<<<' explist */
+               int nexps;
+
+               nexps = explist(ls, &e);
+               if (nexps != nvars) {
+                       lex_syntaxerror(ls, "don't allow multi-assign for <<<");
+               } else {
+                       /* close last expression */
+                       codegen_setoneret(ls->fs, &e);
+                       codegen_store_aggr(ls->fs, &lh->v, &e);
+                       return;  /* avoid default */
+               }
+       }
+
+       init_exp(&e, VNONRELOC, ls->fs->freereg-1);  /* default assignment */
+       codegen_storevar(ls->fs, &lh->v, &e);
+}
+
+static int cond(ktap_lexstate *ls)
+{
+       /* cond -> exp */
+       ktap_expdesc v;
+       expr(ls, &v);  /* read condition */
+       if (v.k == VNIL)
+               v.k = VFALSE;  /* `falses' are all equal here */
+       codegen_goiftrue(ls->fs, &v);
+       return v.f;
+}
+
+static void gotostat(ktap_lexstate *ls, int pc)
+{
+       int line = ls->linenumber;
+       ktap_string *label;
+       int g;
+
+       if (testnext(ls, TK_GOTO))
+               label = str_checkname(ls);
+       else {
+               lex_next(ls);  /* skip break */
+               label = ktapc_ts_new("break");
+       }
+       g = newlabelentry(ls, &ls->dyd->gt, label, line, pc);
+       findlabel(ls, g);  /* close it if label already defined */
+}
+
+/* check for repeated labels on the same block */
+static void checkrepeated(ktap_funcstate *fs, ktap_labellist *ll, ktap_string *label)
+{
+       int i;
+       for (i = fs->bl->firstlabel; i < ll->n; i++) {
+               if (ktapc_ts_eqstr(label, ll->arr[i].name)) {
+                       const char *msg = ktapc_sprintf(
+                               "label " KTAP_QS " already defined on line %d",
+                               getstr(label), ll->arr[i].line);
+                       semerror(fs->ls, msg);
+               }
+       }
+}
+
+/* skip no-op statements */
+static void skipnoopstat(ktap_lexstate *ls)
+{
+       while (ls->t.token == ';' || ls->t.token == TK_DBCOLON)
+               statement(ls);
+}
+
+static void labelstat (ktap_lexstate *ls, ktap_string *label, int line)
+{
+       /* label -> '::' NAME '::' */
+       ktap_funcstate *fs = ls->fs;
+       ktap_labellist *ll = &ls->dyd->label;
+       int l;  /* index of new label being created */
+
+       checkrepeated(fs, ll, label);  /* check for repeated labels */
+       checknext(ls, TK_DBCOLON);  /* skip double colon */
+       /* create new entry for this label */
+       l = newlabelentry(ls, ll, label, line, fs->pc);
+       skipnoopstat(ls);  /* skip other no-op statements */
+       if (block_follow(ls, 0)) {  /* label is last no-op statement in the block? */
+               /* assume that locals are already out of scope */
+               ll->arr[l].nactvar = fs->bl->nactvar;
+       }
+       findgotos(ls, &ll->arr[l]);
+}
+
+static void whilestat(ktap_lexstate *ls, int line)
+{
+       /* whilestat -> WHILE cond DO block END */
+       ktap_funcstate *fs = ls->fs;
+       int whileinit;
+       int condexit;
+       ktap_blockcnt bl;
+
+       lex_next(ls);  /* skip WHILE */
+       whileinit = codegen_getlabel(fs);
+       checknext(ls, '(');
+       condexit = cond(ls);
+       checknext(ls, ')');
+
+       enterblock(fs, &bl, 1);
+       //checknext(ls, TK_DO);
+       checknext(ls, '{');
+       block(ls);
+       codegen_jumpto(fs, whileinit);
+       checknext(ls, '}');
+       //check_match(ls, TK_END, TK_WHILE, line);
+       leaveblock(fs);
+       codegen_patchtohere(fs, condexit);  /* false conditions finish the loop */
+}
+
+static void repeatstat(ktap_lexstate *ls, int line)
+{
+       /* repeatstat -> REPEAT block UNTIL cond */
+       int condexit;
+       ktap_funcstate *fs = ls->fs;
+       int repeat_init = codegen_getlabel(fs);
+       ktap_blockcnt bl1, bl2;
+
+       enterblock(fs, &bl1, 1);  /* loop block */
+       enterblock(fs, &bl2, 0);  /* scope block */
+       lex_next(ls);  /* skip REPEAT */
+       statlist(ls);
+       check_match(ls, TK_UNTIL, TK_REPEAT, line);
+       condexit = cond(ls);  /* read condition (inside scope block) */
+       if (bl2.upval)  /* upvalues? */
+               codegen_patchclose(fs, condexit, bl2.nactvar);
+       leaveblock(fs);  /* finish scope */
+       codegen_patchlist(fs, condexit, repeat_init);  /* close the loop */
+       leaveblock(fs);  /* finish loop */
+}
+
+static int exp1(ktap_lexstate *ls)
+{
+       ktap_expdesc e;
+       int reg;
+
+       expr(ls, &e);
+       codegen_exp2nextreg(ls->fs, &e);
+       ktap_assert(e.k == VNONRELOC);
+       reg = e.u.info;
+       return reg;
+}
+
+static void forbody(ktap_lexstate *ls, int base, int line, int nvars, int isnum)
+{
+       /* forbody -> DO block */
+       ktap_blockcnt bl;
+       ktap_funcstate *fs = ls->fs;
+       int prep, endfor;
+
+       checknext(ls, ')');
+
+       adjustlocalvars(ls, 3);  /* control variables */
+       //checknext(ls, TK_DO);
+       checknext(ls, '{');
+       prep = isnum ? codegen_codeAsBx(fs, OP_FORPREP, base, NO_JUMP) : codegen_jump(fs);
+       enterblock(fs, &bl, 0);  /* scope for declared variables */
+       adjustlocalvars(ls, nvars);
+       codegen_reserveregs(fs, nvars);
+       block(ls);
+       leaveblock(fs);  /* end of scope for declared variables */
+       codegen_patchtohere(fs, prep);
+       if (isnum)  /* numeric for? */
+               endfor = codegen_codeAsBx(fs, OP_FORLOOP, base, NO_JUMP);
+       else {  /* generic for */
+               codegen_codeABC(fs, OP_TFORCALL, base, 0, nvars);
+               codegen_fixline(fs, line);
+               endfor = codegen_codeAsBx(fs, OP_TFORLOOP, base + 2, NO_JUMP);
+       }
+       codegen_patchlist(fs, endfor, prep + 1);
+       codegen_fixline(fs, line);
+}
+
+static void fornum(ktap_lexstate *ls, ktap_string *varname, int line)
+{
+       /* fornum -> NAME = exp1,exp1[,exp1] forbody */
+       ktap_funcstate *fs = ls->fs;
+       int base = fs->freereg;
+
+       new_localvarliteral(ls, "(for index)");
+       new_localvarliteral(ls, "(for limit)");
+       new_localvarliteral(ls, "(for step)");
+       new_localvar(ls, varname);
+       checknext(ls, '=');
+       exp1(ls);  /* initial value */
+       checknext(ls, ',');
+       exp1(ls);  /* limit */
+       if (testnext(ls, ','))
+               exp1(ls);  /* optional step */
+       else {  /* default step = 1 */
+               codegen_codek(fs, fs->freereg, codegen_numberK(fs, 1));
+               codegen_reserveregs(fs, 1);
+       }
+       forbody(ls, base, line, 1, 1);
+}
+
+static void forlist(ktap_lexstate *ls, ktap_string *indexname)
+{
+       /* forlist -> NAME {,NAME} IN explist forbody */
+       ktap_funcstate *fs = ls->fs;
+       ktap_expdesc e;
+       int nvars = 4;  /* gen, state, control, plus at least one declared var */
+       int line;
+       int base = fs->freereg;
+
+       /* create control variables */
+       new_localvarliteral(ls, "(for generator)");
+       new_localvarliteral(ls, "(for state)");
+       new_localvarliteral(ls, "(for control)");
+       /* create declared variables */
+       new_localvar(ls, indexname);
+       while (testnext(ls, ',')) {
+               new_localvar(ls, str_checkname(ls));
+               nvars++;
+       }
+       checknext(ls, TK_IN);
+       line = ls->linenumber;
+       adjust_assign(ls, 3, explist(ls, &e), &e);
+       codegen_checkstack(fs, 3);  /* extra space to call generator */
+       forbody(ls, base, line, nvars - 3, 0);
+}
+
+static void forstat(ktap_lexstate *ls, int line)
+{
+       /* forstat -> FOR (fornum | forlist) END */
+       ktap_funcstate *fs = ls->fs;
+       ktap_string *varname;
+       ktap_blockcnt bl;
+
+       enterblock(fs, &bl, 1);  /* scope for loop and control variables */
+       lex_next(ls);  /* skip `for' */
+
+       checknext(ls, '(');
+       varname = str_checkname(ls);  /* first variable name */
+       switch (ls->t.token) {
+       case '=':
+               fornum(ls, varname, line);
+               break;
+       case ',': case TK_IN:
+               forlist(ls, varname);
+               break;
+       default:
+               lex_syntaxerror(ls, KTAP_QL("=") " or " KTAP_QL("in") " expected");
+       }
+       //check_match(ls, TK_END, TK_FOR, line);
+       checknext(ls, '}');
+       leaveblock(fs);  /* loop scope (`break' jumps to this point) */
+}
+
+static void test_then_block(ktap_lexstate *ls, int *escapelist)
+{
+       /* test_then_block -> [IF | ELSEIF] cond THEN block */
+       ktap_blockcnt bl;
+       ktap_funcstate *fs = ls->fs;
+       ktap_expdesc v;
+       int jf;  /* instruction to skip 'then' code (if condition is false) */
+
+       lex_next(ls);  /* skip IF or ELSEIF */
+       checknext(ls, '(');
+       expr(ls, &v);  /* read condition */
+       checknext(ls, ')');
+       //checknext(ls, TK_THEN);
+       checknext(ls, '{');
+       if (ls->t.token == TK_GOTO || ls->t.token == TK_BREAK) {
+               codegen_goiffalse(ls->fs, &v);  /* will jump to label if condition is true */
+               enterblock(fs, &bl, 0);  /* must enter block before 'goto' */
+               gotostat(ls, v.t);  /* handle goto/break */
+               skipnoopstat(ls);  /* skip other no-op statements */
+               if (block_follow(ls, 0)) {  /* 'goto' is the entire block? */
+                       leaveblock(fs);
+                       checknext(ls, '}');
+                       return;  /* and that is it */
+               } else  /* must skip over 'then' part if condition is false */
+                       jf = codegen_jump(fs);
+       } else {  /* regular case (not goto/break) */
+               codegen_goiftrue(ls->fs, &v);  /* skip over block if condition is false */
+               enterblock(fs, &bl, 0);
+               jf = v.f;
+       }
+       statlist(ls);  /* `then' part */
+       checknext(ls, '}');
+       leaveblock(fs);
+       if (ls->t.token == TK_ELSE || ls->t.token == TK_ELSEIF)  /* followed by 'else'/'elseif'? */
+               codegen_concat(fs, escapelist, codegen_jump(fs));  /* must jump over it */
+       codegen_patchtohere(fs, jf);
+}
+
+static void ifstat(ktap_lexstate *ls, int line)
+{
+       /* ifstat -> IF cond THEN block {ELSEIF cond THEN block} [ELSE block] END */
+       ktap_funcstate *fs = ls->fs;
+       int escapelist = NO_JUMP;  /* exit list for finished parts */
+
+       test_then_block(ls, &escapelist);  /* IF cond THEN block */
+       while (ls->t.token == TK_ELSEIF)
+               test_then_block(ls, &escapelist);  /* ELSEIF cond THEN block */
+       if (testnext(ls, TK_ELSE)) {
+               checknext(ls, '{');
+               block(ls);  /* `else' part */
+               checknext(ls, '}');
+       }
+       //check_match(ls, TK_END, TK_IF, line);
+       codegen_patchtohere(fs, escapelist);  /* patch escape list to 'if' end */
+}
+
+static void localfunc(ktap_lexstate *ls)
+{
+       ktap_expdesc b;
+       ktap_funcstate *fs = ls->fs;
+
+       new_localvar(ls, str_checkname(ls));  /* new local variable */
+       adjustlocalvars(ls, 1);  /* enter its scope */
+       body(ls, &b, 0, ls->linenumber);  /* function created in next register */
+       /* debug information will only see the variable after this point! */
+       getlocvar(fs, b.u.info)->startpc = fs->pc;
+}
+
+static void localstat(ktap_lexstate *ls)
+{
+       /* stat -> LOCAL NAME {`,' NAME} [`=' explist] */
+       int nvars = 0;
+       int nexps;
+       ktap_expdesc e;
+
+       do {
+               new_localvar(ls, str_checkname(ls));
+               nvars++;
+       } while (testnext(ls, ','));
+       if (testnext(ls, '='))
+               nexps = explist(ls, &e);
+       else {
+               e.k = VVOID;
+               nexps = 0;
+       }
+       adjust_assign(ls, nvars, nexps, &e);
+       adjustlocalvars(ls, nvars);
+}
+
+static int funcname(ktap_lexstate *ls, ktap_expdesc *v)
+{
+       /* funcname -> NAME {fieldsel} [`:' NAME] */
+       int ismethod = 0;
+
+       singlevar(ls, v);
+       while (ls->t.token == '.')
+               fieldsel(ls, v);
+               if (ls->t.token == ':') {
+                       ismethod = 1;
+                       fieldsel(ls, v);
+       }
+       return ismethod;
+}
+
+static void funcstat(ktap_lexstate *ls, int line)
+{
+       /* funcstat -> FUNCTION funcname body */
+       int ismethod;
+       ktap_expdesc v, b;
+
+       lex_next(ls);  /* skip FUNCTION */
+       ismethod = funcname(ls, &v);
+       body(ls, &b, ismethod, line);
+       codegen_storevar(ls->fs, &v, &b);
+       codegen_fixline(ls->fs, line);  /* definition `happens' in the first line */
+}
+
+static void exprstat(ktap_lexstate *ls)
+{
+       /* stat -> func | assignment */
+       ktap_funcstate *fs = ls->fs;
+       struct LHS_assign v;
+
+       suffixedexp(ls, &v.v);
+       /* stat -> assignment ? */
+       if (ls->t.token == '=' || ls->t.token == ',' ||
+           ls->t.token == TK_INCR || ls->t.token == TK_AGGR_ASSIGN) {
+               v.prev = NULL;
+               assignment(ls, &v, 1);
+       } else {  /* stat -> func */
+               check_condition(ls, v.v.k == VCALL, "syntax error");
+               SETARG_C(getcode(fs, &v.v), 1);  /* call statement uses no results */
+       }
+}
+
+static void retstat(ktap_lexstate *ls)
+{
+       /* stat -> RETURN [explist] [';'] */
+       ktap_funcstate *fs = ls->fs;
+       ktap_expdesc e;
+       int first, nret;  /* registers with returned values */
+
+       if (block_follow(ls, 1) || ls->t.token == ';')
+               first = nret = 0;  /* return no values */
+       else {
+               nret = explist(ls, &e);  /* optional return values */
+               if (hasmultret(e.k)) {
+                       codegen_setmultret(fs, &e);
+                       if (e.k == VCALL && nret == 1) {  /* tail call? */
+                               SET_OPCODE(getcode(fs,&e), OP_TAILCALL);
+                               ktap_assert(GETARG_A(getcode(fs,&e)) == fs->nactvar);
+                       }
+                       first = fs->nactvar;
+                       nret = KTAP_MULTRET;  /* return all values */
+               } else {
+                       if (nret == 1)  /* only one single value? */
+                               first = codegen_exp2anyreg(fs, &e);
+                       else {
+                               codegen_exp2nextreg(fs, &e);  /* values must go to the `stack' */
+                               first = fs->nactvar;  /* return all `active' values */
+                               ktap_assert(nret == fs->freereg - first);
+                       }
+               }
+       }
+       codegen_ret(fs, first, nret);
+       testnext(ls, ';');  /* skip optional semicolon */
+}
+
+static void tracestat(ktap_lexstate *ls)
+{
+       ktap_expdesc v0, key, args;
+       ktap_expdesc *v = &v0;
+       ktap_string *kdebug_str = ktapc_ts_new("kdebug");
+       ktap_string *probe_str = ktapc_ts_new("probe_by_id");
+       ktap_string *probe_end_str = ktapc_ts_new("probe_end");
+       ktap_funcstate *fs = ls->fs;
+       int token = ls->t.token;
+       int line = ls->linenumber;
+       int base, nparams;
+
+       if (token == TK_TRACE)
+               lex_read_string_until(ls, '{');
+       else
+               lex_next(ls);  /* skip "trace_end" keyword */
+
+       /* kdebug */
+       singlevaraux(fs, ls->envn, v, 1);  /* get environment variable */
+       codestring(ls, &key, kdebug_str);  /* key is variable name */
+       codegen_indexed(fs, v, &key);  /* env[varname] */
+
+       /* fieldsel: kdebug.probe */
+       codegen_exp2anyregup(fs, v);
+       if (token == TK_TRACE)
+               codestring(ls, &key, probe_str);
+       else if (token == TK_TRACE_END)
+               codestring(ls, &key, probe_end_str);
+       codegen_indexed(fs, v, &key);
+
+       /* funcargs*/
+       codegen_exp2nextreg(fs, v);
+
+       if (token == TK_TRACE) {
+               ktap_eventdef_info *evdef_info;
+
+               /* argument: EVENTDEF string */
+               check(ls, TK_STRING);
+               enterlevel(ls);
+               evdef_info = ktapc_parse_eventdef(getstr(ls->t.seminfo.ts));
+               check_condition(ls, evdef_info != NULL, "Cannot parse eventdef");
+
+               /* pass a userspace pointer to kernel */
+               codenumber(ls, &args, (ktap_number)evdef_info);
+               lex_next(ls);  /* skip EVENTDEF string */
+               leavelevel(ls);
+
+               codegen_exp2nextreg(fs, &args); /* for next argument */
+       }
+
+       /* argument: callback function */
+       enterlevel(ls);
+       func_body_no_args(ls, &args, ls->linenumber);
+       leavelevel(ls);
+
+       codegen_setmultret(fs, &args);
+
+       base = v->u.info;  /* base register for call */
+       if (hasmultret(args.k))
+               nparams = KTAP_MULTRET;  /* open call */
+       else {
+               codegen_exp2nextreg(fs, &args);  /* close last argument */
+               nparams = fs->freereg - (base+1);
+       }
+       init_exp(v, VCALL, codegen_codeABC(fs, OP_CALL, base, nparams+1, 2));
+       codegen_fixline(fs, line);
+       fs->freereg = base+1;
+
+       check_condition(ls, v->k == VCALL, "syntax error");
+       SETARG_C(getcode(fs, v), 1);  /* call statement uses no results */
+}
+
+static void timerstat(ktap_lexstate *ls)
+{
+       ktap_expdesc v0, key, args;
+       ktap_expdesc *v = &v0;
+       ktap_funcstate *fs = ls->fs;
+       ktap_string *token_str = ls->t.seminfo.ts;
+       ktap_string *interval_str;
+       int line = ls->linenumber;
+       int base, nparams;
+
+       lex_next(ls);  /* skip profile/tick keyword */
+       check(ls, '-');
+
+       lex_read_string_until(ls, '{');
+       interval_str = ls->t.seminfo.ts;
+
+       //printf("timerstat str: %s\n", getstr(interval_str));
+       //exit(0);
+
+       /* timer */
+       singlevaraux(fs, ls->envn, v, 1);  /* get environment variable */
+       codestring(ls, &key, ktapc_ts_new("timer"));  /* key is variable name */
+       codegen_indexed(fs, v, &key);  /* env[varname] */
+
+       /* fieldsel: timer.profile, timer.tick */
+       codegen_exp2anyregup(fs, v);
+       codestring(ls, &key, token_str);
+       codegen_indexed(fs, v, &key);
+
+       /* funcargs*/
+       codegen_exp2nextreg(fs, v);
+
+       /* argument: interval string */
+       check(ls, TK_STRING);
+       enterlevel(ls);
+       codestring(ls, &args, interval_str);
+       lex_next(ls);  /* skip interval string */
+       leavelevel(ls);
+
+       codegen_exp2nextreg(fs, &args); /* for next argument */
+
+       /* argument: callback function */
+       enterlevel(ls);
+       func_body_no_args(ls, &args, ls->linenumber);
+       leavelevel(ls);
+
+       codegen_setmultret(fs, &args);
+
+       base = v->u.info;  /* base register for call */
+       if (hasmultret(args.k))
+               nparams = KTAP_MULTRET;  /* open call */
+       else {
+               codegen_exp2nextreg(fs, &args);  /* close last argument */
+               nparams = fs->freereg - (base+1);
+       }
+       init_exp(v, VCALL, codegen_codeABC(fs, OP_CALL, base, nparams+1, 2));
+       codegen_fixline(fs, line);
+       fs->freereg = base+1;
+
+       check_condition(ls, v->k == VCALL, "syntax error");
+       SETARG_C(getcode(fs, v), 1);  /* call statement uses no results */
+}
+
+/* we still keep cdef keyword even FFI feature is disabled, it just does
+ * nothing and prints out a warning */
+#ifdef CONFIG_KTAP_FFI
+static void parsecdef(ktap_lexstate *ls)
+{
+       /* read long string cdef */
+       lex_next(ls);
+
+       check(ls, TK_STRING);
+       ffi_cdef(getstr(ls->t.seminfo.ts));
+
+       /* consume newline */
+       lex_next(ls);
+}
+#else
+static void parsecdef(ktap_lexstate *ls)
+{
+       printf("Please compile with FFI support to use cdef!\n");
+       exit(EXIT_SUCCESS);
+}
+#endif
+
+
+static void statement(ktap_lexstate *ls)
+{
+       int line = ls->linenumber;  /* may be needed for error messages */
+
+       enterlevel(ls);
+       switch (ls->t.token) {
+       case ';': {  /* stat -> ';' (empty statement) */
+               lex_next(ls);  /* skip ';' */
+               break;
+       }
+       case TK_IF: {  /* stat -> ifstat */
+               ifstat(ls, line);
+               break;
+       }
+       case TK_WHILE: {  /* stat -> whilestat */
+               whilestat(ls, line);
+               break;
+       }
+       case TK_DO: {  /* stat -> DO block END */
+               lex_next(ls);  /* skip DO */
+               block(ls);
+               check_match(ls, TK_END, TK_DO, line);
+               break;
+       }
+       case TK_FOR: {  /* stat -> forstat */
+               forstat(ls, line);
+               break;
+       }
+       case TK_REPEAT: {  /* stat -> repeatstat */
+               repeatstat(ls, line);
+               break;
+       }
+       case TK_FUNCTION: {  /* stat -> funcstat */
+               funcstat(ls, line);
+               break;
+       }
+       case TK_LOCAL: {  /* stat -> localstat */
+               lex_next(ls);  /* skip LOCAL */
+               if (testnext(ls, TK_FUNCTION))  /* local function? */
+                       localfunc(ls);
+               else
+                       localstat(ls);
+               break;
+       }
+       case TK_DBCOLON: {  /* stat -> label */
+               lex_next(ls);  /* skip double colon */
+               labelstat(ls, str_checkname(ls), line);
+               break;
+       }
+       case TK_RETURN: {  /* stat -> retstat */
+               lex_next(ls);  /* skip RETURN */
+               retstat(ls);
+               break;
+       }
+       case TK_BREAK:   /* stat -> breakstat */
+       case TK_GOTO: {  /* stat -> 'goto' NAME */
+               gotostat(ls, codegen_jump(ls->fs));
+               break;
+       }
+
+       case TK_TRACE:
+       case TK_TRACE_END:
+               tracestat(ls);
+               break;
+       case TK_PROFILE:
+       case TK_TICK:
+               timerstat(ls);
+               break;
+       case TK_FFI_CDEF:
+               parsecdef(ls);
+               break;
+       default: {  /* stat -> func | assignment */
+               exprstat(ls);
+               break;
+       }
+       }
+       //ktap_assert(ls->fs->f->maxstacksize >= ls->fs->freereg &&
+       //      ls->fs->freereg >= ls->fs->nactvar);
+       ls->fs->freereg = ls->fs->nactvar;  /* free registers */
+       leavelevel(ls);
+}
+/* }====================================================================== */
+
+/*
+ * compiles the main function, which is a regular vararg function with an upvalue
+ */
+static void mainfunc(ktap_lexstate *ls, ktap_funcstate *fs)
+{
+       ktap_blockcnt bl;
+       ktap_expdesc v;
+
+       open_func(ls, fs, &bl);
+       fs->f->is_vararg = 1;  /* main function is always vararg */
+       init_exp(&v, VLOCAL, 0);  /* create and... */
+       newupvalue(fs, ls->envn, &v);  /* ...set environment upvalue */
+       lex_next(ls);  /* read first token */
+       statlist(ls);  /* parse main body */
+       check(ls, TK_EOS);
+       close_func(ls);
+}
+
+ktap_closure *ktapc_parser(char *ptr, const char *name)
+{
+       ktap_lexstate lexstate;
+       ktap_funcstate funcstate;
+       ktap_dyndata dyd;
+       ktap_mbuffer buff;
+       int firstchar = *ptr++;
+       ktap_closure *cl = ktapc_newclosure(1);  /* create main closure */
+
+       memset(&lexstate, 0, sizeof(ktap_lexstate));
+       memset(&funcstate, 0, sizeof(ktap_funcstate));
+       funcstate.f = cl->p = ktapc_newproto();
+       funcstate.f->source = ktapc_ts_new(name);  /* create and anchor ktap_string */
+
+       lex_init();
+
+       mbuff_init(&buff);
+       memset(&dyd, 0, sizeof(ktap_dyndata));
+       lexstate.buff = &buff;
+       lexstate.dyd = &dyd;
+       lex_setinput(&lexstate, ptr, funcstate.f->source, firstchar);
+
+       mainfunc(&lexstate, &funcstate);
+
+       ktap_assert(!funcstate.prev && funcstate.nups == 1 && !lexstate.fs);
+
+       /* all scopes should be correctly finished */
+       ktap_assert(dyd.actvar.n == 0 && dyd.gt.n == 0 && dyd.label.n == 0);
+       return cl;
+}
diff --git a/drivers/staging/ktap/userspace/symbol.c b/drivers/staging/ktap/userspace/symbol.c
new file mode 100644 (file)
index 0000000..74129e2
--- /dev/null
@@ -0,0 +1,291 @@
+/*
+ * symbol.c
+ *
+ * This file is part of ktap by Jovi Zhangwei.
+ *
+ * Copyright (C) 2013 Azat Khuzhin <a3at.mail@gmail.com>.
+ *
+ * ktap 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.
+ *
+ * ktap is distributed in the hope it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
+ * more details.
+ *
+ * You should have received a copy of the GNU General Public License along with
+ * this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+
+#include "symbol.h"
+
+#include <stdio.h>
+#include <stdlib.h>
+
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <unistd.h>
+#include <fcntl.h>
+#include <string.h>
+
+#include <libelf.h>
+
+static Elf_Scn *elf_section_by_name(Elf *elf, GElf_Ehdr *ep,
+                                   GElf_Shdr *shp, const char *name)
+{
+       Elf_Scn *scn = NULL;
+
+       /* Elf is corrupted/truncated, avoid calling elf_strptr. */
+       if (!elf_rawdata(elf_getscn(elf, ep->e_shstrndx), NULL))
+               return NULL;
+
+       while ((scn = elf_nextscn(elf, scn)) != NULL) {
+               char *str;
+
+               gelf_getshdr(scn, shp);
+               str = elf_strptr(elf, ep->e_shstrndx, shp->sh_name);
+               if (!strcmp(name, str))
+                       break;
+       }
+
+       return scn;
+}
+
+/**
+ * @return v_addr of "LOAD" program header, that have zero offset.
+ */
+static int find_load_address(Elf *elf, vaddr_t *load_address)
+{
+       GElf_Phdr phdr;
+       size_t i, phdrnum;
+
+       if (elf_getphdrnum(elf, &phdrnum))
+               return -1;
+
+       for (i = 0; i < phdrnum; i++) {
+               if (gelf_getphdr(elf, i, &phdr) == NULL)
+                       return -1;
+
+               if (phdr.p_type != PT_LOAD || phdr.p_offset != 0)
+                       continue;
+
+               *load_address = phdr.p_vaddr;
+               return 0;
+       }
+
+       /* cannot found load address */
+       return -1;
+}
+
+static size_t elf_symbols(GElf_Shdr shdr)
+{
+       return shdr.sh_size / shdr.sh_entsize;
+}
+
+static int dso_symbols(Elf *elf, symbol_actor actor, void *arg)
+{
+       Elf_Data *elf_data = NULL;
+       Elf_Scn *scn = NULL;
+       GElf_Sym sym;
+       GElf_Shdr shdr;
+       int symbols_count = 0;
+       vaddr_t load_address;
+
+       if (find_load_address(elf, &load_address))
+               return -1;
+
+       while ((scn = elf_nextscn(elf, scn))) {
+               int i;
+
+               gelf_getshdr(scn, &shdr);
+
+               if (shdr.sh_type != SHT_SYMTAB)
+                       continue;
+
+               elf_data = elf_getdata(scn, elf_data);
+
+               for (i = 0; i < elf_symbols(shdr); i++) {
+                       char *name;
+                       vaddr_t addr;
+                       int ret;
+
+                       gelf_getsym(elf_data, i, &sym);
+
+                       if (GELF_ST_TYPE(sym.st_info) != STT_FUNC)
+                               continue;
+
+                       name = elf_strptr(elf, shdr.sh_link, sym.st_name);
+                       addr = sym.st_value - load_address;
+
+                       ret = actor(name, addr, arg);
+                       if (ret)
+                               return ret;
+
+                       ++symbols_count;
+               }
+       }
+
+       return symbols_count;
+}
+
+#define SDT_NOTE_TYPE 3
+#define SDT_NOTE_COUNT 3
+#define SDT_NOTE_SCN ".note.stapsdt"
+#define SDT_NOTE_NAME "stapsdt"
+
+static vaddr_t sdt_note_addr(Elf *elf, const char *data, size_t len, int type)
+{
+       vaddr_t vaddr;
+
+       /*
+        * Three addresses need to be obtained :
+        * Marker location, address of base section and semaphore location
+        */
+       union {
+               Elf64_Addr a64[3];
+               Elf32_Addr a32[3];
+       } buf;
+
+       /*
+        * dst and src are required for translation from file to memory
+        * representation
+        */
+       Elf_Data dst = {
+               .d_buf = &buf, .d_type = ELF_T_ADDR, .d_version = EV_CURRENT,
+               .d_size = gelf_fsize(elf, ELF_T_ADDR, SDT_NOTE_COUNT, EV_CURRENT),
+               .d_off = 0, .d_align = 0
+       };
+
+       Elf_Data src = {
+               .d_buf = (void *) data, .d_type = ELF_T_ADDR,
+               .d_version = EV_CURRENT, .d_size = dst.d_size, .d_off = 0,
+               .d_align = 0
+       };
+
+       /* Check the type of each of the notes */
+       if (type != SDT_NOTE_TYPE)
+               return 0;
+
+       if (len < dst.d_size + SDT_NOTE_COUNT)
+               return 0;
+
+       /* Translation from file representation to memory representation */
+       if (gelf_xlatetom(elf, &dst, &src,
+                         elf_getident(elf, NULL)[EI_DATA]) == NULL)
+               return 0; /* TODO */
+
+       memcpy(&vaddr, &buf, sizeof(vaddr));
+
+       return vaddr;
+}
+
+static const char *sdt_note_name(Elf *elf, GElf_Nhdr *nhdr, const char *data)
+{
+       const char *provider = data + gelf_fsize(elf,
+               ELF_T_ADDR, SDT_NOTE_COUNT, EV_CURRENT);
+       const char *name = (const char *)memchr(provider, '\0',
+               data + nhdr->n_descsz - provider);
+
+       if (name++ == NULL)
+               return NULL;
+
+       return name;
+}
+
+static const char *sdt_note_data(const Elf_Data *data, size_t off)
+{
+       return ((data->d_buf) + off);
+}
+
+static int dso_sdt_notes(Elf *elf, symbol_actor actor, void *arg)
+{
+       GElf_Ehdr ehdr;
+       Elf_Scn *scn = NULL;
+       Elf_Data *data;
+       GElf_Shdr shdr;
+       size_t shstrndx;
+       size_t next;
+       GElf_Nhdr nhdr;
+       size_t name_off, desc_off, offset;
+       vaddr_t vaddr = 0;
+       int symbols_count = 0;
+
+       if (gelf_getehdr(elf, &ehdr) == NULL)
+               return 0;
+       if (elf_getshdrstrndx(elf, &shstrndx) != 0)
+               return 0;
+
+       /*
+        * Look for section type = SHT_NOTE, flags = no SHF_ALLOC
+        * and name = .note.stapsdt
+        */
+       scn = elf_section_by_name(elf, &ehdr, &shdr, SDT_NOTE_SCN);
+       if (!scn)
+               return 0;
+       if (!(shdr.sh_type == SHT_NOTE) || (shdr.sh_flags & SHF_ALLOC))
+               return 0;
+
+       data = elf_getdata(scn, NULL);
+
+       for (offset = 0;
+               (next = gelf_getnote(data, offset, &nhdr, &name_off, &desc_off)) > 0;
+               offset = next) {
+               const char *name;
+               int ret;
+
+               if (nhdr.n_namesz != sizeof(SDT_NOTE_NAME) ||
+                   memcmp(data->d_buf + name_off, SDT_NOTE_NAME,
+                           sizeof(SDT_NOTE_NAME)))
+                       continue;
+
+               name = sdt_note_name(elf, &nhdr, sdt_note_data(data, desc_off));
+               if (!name)
+                       continue;
+
+               vaddr = sdt_note_addr(elf, sdt_note_data(data, desc_off),
+                                       nhdr.n_descsz, nhdr.n_type);
+               if (!vaddr)
+                       continue;
+
+               ret = actor(name, vaddr, arg);
+               if (ret)
+                       return ret;
+
+               ++symbols_count;
+       }
+
+       return symbols_count;
+}
+
+int parse_dso_symbols(const char *exec, int type, symbol_actor actor, void *arg)
+{
+       int symbols_count = 0;
+       Elf *elf;
+       int fd;
+
+       if (elf_version(EV_CURRENT) == EV_NONE)
+               return -1;
+
+       fd = open(exec, O_RDONLY);
+       if (fd < 0)
+               return -1;
+
+       elf = elf_begin(fd, ELF_C_READ, NULL);
+       if (elf) {
+               switch (type) {
+               case FIND_SYMBOL:
+                       symbols_count = dso_symbols(elf, actor, arg);
+                       break;
+               case FIND_STAPSDT_NOTE:
+                       symbols_count = dso_sdt_notes(elf, actor, arg);
+                       break;
+               }
+
+               elf_end(elf);
+       }
+
+       close(fd);
+       return symbols_count;
+}
diff --git a/drivers/staging/ktap/userspace/symbol.h b/drivers/staging/ktap/userspace/symbol.h
new file mode 100644 (file)
index 0000000..650e785
--- /dev/null
@@ -0,0 +1,50 @@
+/*
+ * symbol.h - extract symbols from DSO.
+ *
+ * This file is part of ktap by Jovi Zhangwei.
+ *
+ * Copyright (C) 2013 Azat Khuzhin <a3at.mail@gmail.com>.
+ *
+ * ktap 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.
+ *
+ * ktap is distributed in the hope it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
+ * more details.
+ *
+ * You should have received a copy of the GNU General Public License along with
+ * this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+
+
+#define FIND_SYMBOL 1
+#define FIND_STAPSDT_NOTE 2
+
+#ifndef NO_LIBELF
+
+#include <gelf.h>
+#include <sys/queue.h>
+
+typedef GElf_Addr vaddr_t;
+typedef int (*symbol_actor)(const char *name, vaddr_t addr, void *arg);
+
+/**
+ * Parse all DSO symbols/sdt notes and all for every of them
+ * an actor.
+ *
+ * @exec - path to DSO
+ * @type - see FIND_*
+ * @symbol_actor - actor to call (callback)
+ * @arg - argument for @actor
+ *
+ * @return
+ * If there have errors, return negative value;
+ * No symbols found, return 0;
+ * Otherwise return number of dso symbols found
+ */
+int
+parse_dso_symbols(const char *exec, int type, symbol_actor actor, void *arg);
+#endif
diff --git a/drivers/staging/ktap/userspace/util.c b/drivers/staging/ktap/userspace/util.c
new file mode 100644 (file)
index 0000000..c0e6545
--- /dev/null
@@ -0,0 +1,381 @@
+/*
+ * util.c
+ *
+ * This file is part of ktap by Jovi Zhangwei.
+ *
+ * Copyright (C) 2012-2013 Jovi Zhangwei <jovi.zhangwei@gmail.com>.
+ *
+ * Copyright (C) 1994-2013 Lua.org, PUC-Rio.
+ *  - The part of code in this file is copied from lua initially.
+ *  - lua's MIT license is compatible with GPL.
+ *
+ * ktap 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.
+ *
+ * ktap is distributed in the hope it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
+ * more details.
+ *
+ * You should have received a copy of the GNU General Public License along with
+ * this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+
+#include <stdarg.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <math.h>
+#include "../include/ktap_types.h"
+#include "../include/ktap_opcodes.h"
+#include "ktapc.h"
+
+/*
+ * converts an integer to a "floating point byte", represented as
+ * (eeeeexxx), where the real value is (1xxx) * 2^(eeeee - 1) if
+ * eeeee != 0 and (xxx) otherwise.
+ */
+int ktapc_int2fb(unsigned int x)
+{
+       int e = 0;  /* exponent */
+
+       if (x < 8)
+               return x;
+       while (x >= 0x10) {
+               x = (x+1) >> 1;
+               e++;
+       }
+       return ((e+1) << 3) | ((int)x - 8);
+}
+
+/* converts back */
+int ktapc_fb2int(int x)
+{
+       int e = (x >> 3) & 0x1f;
+
+       if (e == 0)
+               return x;
+       else
+               return ((x & 7) + 8) << (e - 1);
+}
+
+int ktapc_ceillog2(unsigned int x)
+{
+       static const u8 log_2[256] = {
+       0,1,2,2,3,3,3,3,4,4,4,4,4,4,4,4,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,
+       6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,
+       7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,
+       7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,
+       8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,
+       8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,
+       8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,
+       8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8
+       };
+       int l = 0;
+
+       x--;
+       while (x >= 256) {
+               l += 8;
+               x >>= 8;
+       }
+       return l + log_2[x];
+}
+
+ktap_number ktapc_arith(int op, ktap_number v1, ktap_number v2)
+{
+       switch (op) {
+       case KTAP_OPADD: return NUMADD(v1, v2);
+       case KTAP_OPSUB: return NUMSUB(v1, v2);
+       case KTAP_OPMUL: return NUMMUL(v1, v2);
+       case KTAP_OPDIV: return NUMDIV(v1, v2);
+       case KTAP_OPMOD: return NUMMOD(v1, v2);
+       //case KTAP_OPPOW: return NUMPOW(v1, v2);
+       case KTAP_OPUNM: return NUMUNM(v1);
+       default: ktap_assert(0); return 0;
+       }
+}
+
+int ktapc_hexavalue(int c)
+{
+       if (isdigit(c))
+               return c - '0';
+       else
+               return tolower(c) - 'a' + 10;
+}
+
+int ktapc_str2d(const char *s, size_t len, ktap_number *result)
+{
+       char *endptr;
+
+       if (strpbrk(s, "nN"))  /* reject 'inf' and 'nan' */
+               return 0;
+       else
+               *result = (long)strtoul(s, &endptr, 0);
+
+       if (endptr == s)
+               return 0;  /* nothing recognized */
+       while (isspace((unsigned char)(*endptr)))
+               endptr++;
+       return (endptr == s + len);  /* OK if no trailing characters */
+}
+
+/* number of chars of a literal string without the ending \0 */
+#define LL(x)  (sizeof(x)/sizeof(char) - 1)
+
+#define RETS   "..."
+#define PRE    "[string \""
+#define POS    "\"]"
+
+#define addstr(a,b,l)  ( memcpy(a,b,(l) * sizeof(char)), a += (l) )
+
+void ktapc_chunkid(char *out, const char *source, size_t bufflen)
+{
+       size_t l = strlen(source);
+
+       if (*source == '=') {  /* 'literal' source */
+               if (l <= bufflen)  /* small enough? */
+                       memcpy(out, source + 1, l * sizeof(char));
+               else {  /* truncate it */
+                       addstr(out, source + 1, bufflen - 1);
+                       *out = '\0';
+               }
+       } else if (*source == '@') {  /* file name */
+               if (l <= bufflen)  /* small enough? */
+                       memcpy(out, source + 1, l * sizeof(char));
+               else {  /* add '...' before rest of name */
+                       addstr(out, RETS, LL(RETS));
+                       bufflen -= LL(RETS);
+                       memcpy(out, source + 1 + l - bufflen, bufflen * sizeof(char));
+               }
+       } else {  /* string; format as [string "source"] */
+               const char *nl = strchr(source, '\n');  /* find first new line (if any) */
+               addstr(out, PRE, LL(PRE));  /* add prefix */
+               bufflen -= LL(PRE RETS POS) + 1;  /* save space for prefix+suffix+'\0' */
+               if (l < bufflen && nl == NULL) {  /* small one-line source? */
+                       addstr(out, source, l);  /* keep it */
+               } else {
+                       if (nl != NULL)
+                               l = nl - source;  /* stop at first newline */
+                       if (l > bufflen)
+                               l = bufflen;
+                       addstr(out, source, l);
+                       addstr(out, RETS, LL(RETS));
+               }
+               memcpy(out, POS, (LL(POS) + 1) * sizeof(char));
+       }
+}
+
+
+/*
+ * strglobmatch is copyed from perf(linux/tools/perf/util/string.c)
+ */
+
+/* Character class matching */
+static bool __match_charclass(const char *pat, char c, const char **npat)
+{
+       bool complement = false, ret = true;
+
+       if (*pat == '!') {
+               complement = true;
+               pat++;
+       }
+       if (*pat++ == c)        /* First character is special */
+               goto end;
+
+       while (*pat && *pat != ']') {   /* Matching */
+               if (*pat == '-' && *(pat + 1) != ']') { /* Range */
+                       if (*(pat - 1) <= c && c <= *(pat + 1))
+                               goto end;
+                       if (*(pat - 1) > *(pat + 1))
+                               goto error;
+                       pat += 2;
+               } else if (*pat++ == c)
+                       goto end;
+       }
+       if (!*pat)
+               goto error;
+       ret = false;
+
+end:
+       while (*pat && *pat != ']')     /* Searching closing */
+               pat++;
+       if (!*pat)
+               goto error;
+       *npat = pat + 1;
+       return complement ? !ret : ret;
+
+error:
+       return false;
+}
+
+/* Glob/lazy pattern matching */
+static bool __match_glob(const char *str, const char *pat, bool ignore_space)
+{
+       while (*str && *pat && *pat != '*') {
+               if (ignore_space) {
+                       /* Ignore spaces for lazy matching */
+                       if (isspace(*str)) {
+                               str++;
+                               continue;
+                       }
+                       if (isspace(*pat)) {
+                               pat++;
+                               continue;
+                       }
+               }
+               if (*pat == '?') {      /* Matches any single character */
+                       str++;
+                       pat++;
+                       continue;
+               } else if (*pat == '[') /* Character classes/Ranges */
+                       if (__match_charclass(pat + 1, *str, &pat)) {
+                               str++;
+                               continue;
+                       } else
+                               return false;
+               else if (*pat == '\\') /* Escaped char match as normal char */
+                       pat++;
+               if (*str++ != *pat++)
+                       return false;
+       }
+       /* Check wild card */
+       if (*pat == '*') {
+               while (*pat == '*')
+                       pat++;
+               if (!*pat)      /* Tail wild card matches all */
+                       return true;
+               while (*str)
+                       if (__match_glob(str++, pat, ignore_space))
+                               return true;
+       }
+       return !*str && !*pat;
+}
+
+/**
+ * strglobmatch - glob expression pattern matching
+ * @str: the target string to match
+ * @pat: the pattern string to match
+ *
+ * This returns true if the @str matches @pat. @pat can includes wildcards
+ * ('*','?') and character classes ([CHARS], complementation and ranges are
+ * also supported). Also, this supports escape character ('\') to use special
+ * characters as normal character.
+ *
+ * Note: if @pat syntax is broken, this always returns false.
+ */
+bool strglobmatch(const char *str, const char *pat)
+{
+       return __match_glob(str, pat, false);
+}
+
+#define handle_error(str) do { perror(str); exit(-1); } while(0)
+
+#define KALLSYMS_PATH "/proc/kallsyms"
+/*
+ * read kernel symbol from /proc/kallsyms
+ */
+int kallsyms_parse(void *arg,
+                  int(*process_symbol)(void *arg, const char *name,
+                  char type, unsigned long start))
+{
+       int ret = 0;
+       FILE *file;
+       char *line = NULL;
+
+       file = fopen(KALLSYMS_PATH, "r");
+       if (file == NULL)
+               handle_error("open " KALLSYMS_PATH " failed");
+
+       while (!feof(file)) {
+               char *symbol_addr, *symbol_name;
+               char symbol_type;
+               unsigned long start;
+               int line_len;
+               size_t n;
+
+               line_len = getline(&line, &n, file);
+               if (line_len < 0 || !line)
+                       break;
+
+               line[--line_len] = '\0'; /* \n */
+
+               symbol_addr = strtok(line, " \t");
+               start = strtoul(symbol_addr, NULL, 16);
+
+               symbol_type = *strtok(NULL, " \t");
+               symbol_name = strtok(NULL, " \t");
+
+               ret = process_symbol(arg, symbol_name, symbol_type, start);
+               if (ret)
+                       break;
+       }
+
+       free(line);
+       fclose(file);
+
+       return ret;
+}
+
+struct ksym_addr_t {
+       const char *name;
+       unsigned long addr;
+};
+
+static int symbol_cmp(void *arg, const char *name, char type,
+                     unsigned long start)
+{
+       struct ksym_addr_t *base = arg;
+
+       if (strcmp(base->name, name) == 0) {
+               base->addr = start;
+               return 1;
+       }
+
+       return 0;
+}
+
+unsigned long find_kernel_symbol(const char *symbol)
+{
+       int ret;
+       struct ksym_addr_t arg = {
+               .name = symbol,
+               .addr = 0
+       };
+
+       ret = kallsyms_parse(&arg, symbol_cmp);
+       if (ret < 0 || arg.addr == 0) {
+               fprintf(stderr, "cannot read kernel symbol \"%s\" in %s\n",
+                       symbol, KALLSYMS_PATH);
+               exit(EXIT_FAILURE);
+       }
+
+       return arg.addr;
+}
+
+
+#define AVAILABLE_EVENTS_PATH "/sys/kernel/debug/tracing/available_events"
+
+void list_available_events(const char *match)
+{
+       FILE *file;
+       char *line = NULL;
+
+       file = fopen(AVAILABLE_EVENTS_PATH, "r");
+       if (file == NULL)
+               handle_error("open " AVAILABLE_EVENTS_PATH " failed");
+
+       while (!feof(file)) {
+               size_t n;
+
+               getline(&line, &n, file);
+
+               if (!match || strglobmatch(line, match))
+                       printf("%s", line);
+       }
+
+       free(line);
+       fclose(file);
+}
+
diff --git a/drivers/staging/lttng/Kconfig b/drivers/staging/lttng/Kconfig
new file mode 100644 (file)
index 0000000..34c4a4f
--- /dev/null
@@ -0,0 +1,35 @@
+config LTTNG
+       tristate "LTTng kernel tracer"
+       depends on TRACEPOINTS
+       help
+         The LTTng 2.0 Tracer Toolchain allows integrated kernel and
+         user-space tracing from a single user interface: the "lttng"
+         command. See http://lttng.org website for the "lttng-tools"
+         user-space tracer control tools package and the "babeltrace"
+         package for conversion of trace data to a human-readable
+         format.
+
+         LTTng features:
+         - System-wide tracing across kernel, libraries and
+           applications,
+         - Tracepoints, detailed syscall tracing (fast strace replacement),
+           Function tracer, CPU Performance Monitoring Unit (PMU) counters
+           and kprobes support,
+         - Have the ability to attach "context" information to events in the
+           trace (e.g. any PMU counter, pid, ppid, tid, comm name, etc). All
+           the extra information fields to be collected with events are
+           optional, specified on a per-tracing-session basis (except for
+           timestamp and event id, which are mandatory).
+         - Precise and fast clock sources with near cycle-level
+           timestamps,
+         - Efficient trace data transport:
+           - Compact Binary format with CTF,
+           - Per-core buffers ensures scalability,
+           - Fast-paths in caller context, amortized synchronization,
+           - Zero-copy using splice and mmap system calls, over disk,
+             network or consumed in-place,
+         - Multiple concurrent tracing sessions are supported,
+         - Designed to meet hard real-time constraints,
+         - Supports live streaming of the trace data,
+         - Produces CTF (Common Trace Format) natively (see
+           http://www.efficios.com/ctf).
diff --git a/drivers/staging/lttng/LICENSE b/drivers/staging/lttng/LICENSE
new file mode 100644 (file)
index 0000000..bb880bf
--- /dev/null
@@ -0,0 +1,27 @@
+LTTng modules licensing
+Mathieu Desnoyers
+June 2, 2011
+
+* LGPLv2.1/GPLv2 dual-license
+
+The files contained within this package are licensed under
+LGPLv2.1/GPLv2 dual-license (see lgpl-2.1.txt and gpl-2.0.txt for
+details), except for files identified by the following sections.
+
+* GPLv2 license
+
+These files are licensed exclusively under the GPLv2 license. See
+gpl-2.0.txt for details.
+
+lib/ringbuffer/ring_buffer_splice.c
+lib/ringbuffer/ring_buffer_mmap.c
+instrumentation/events/mainline/*.h
+instrumentation/events/lttng-modules/*.h
+
+* MIT-style license
+
+These files are licensed under an MIT-style license:
+
+lib/prio_heap/lttng_prio_heap.h
+lib/prio_heap/lttng_prio_heap.c
+lib/bitfield.h
diff --git a/drivers/staging/lttng/Makefile b/drivers/staging/lttng/Makefile
new file mode 100644 (file)
index 0000000..cf6e232
--- /dev/null
@@ -0,0 +1,38 @@
+#
+# Makefile for the LTTng modules.
+#
+
+obj-m += lttng-ring-buffer-client-discard.o
+obj-m += lttng-ring-buffer-client-overwrite.o
+obj-m += lttng-ring-buffer-metadata-client.o
+obj-m += lttng-ring-buffer-client-mmap-discard.o
+obj-m += lttng-ring-buffer-client-mmap-overwrite.o
+obj-m += lttng-ring-buffer-metadata-mmap-client.o
+
+obj-m += lttng-tracer.o
+lttng-tracer-objs :=  lttng-events.o lttng-abi.o \
+                       lttng-probes.o lttng-context.o \
+                       lttng-context-pid.o lttng-context-procname.o \
+                       lttng-context-prio.o lttng-context-nice.o \
+                       lttng-context-vpid.o lttng-context-tid.o \
+                       lttng-context-vtid.o lttng-context-ppid.o \
+                       lttng-context-vppid.o lttng-calibrate.o \
+                       lttng-context-hostname.o wrapper/random.o
+
+obj-m += lttng-statedump.o
+lttng-statedump-objs := lttng-statedump-impl.o wrapper/irqdesc.o \
+                       wrapper/fdtable.o
+
+ifneq ($(CONFIG_HAVE_SYSCALL_TRACEPOINTS),)
+lttng-tracer-objs += lttng-syscalls.o probes/lttng-probe-user.o
+endif
+
+ifneq ($(CONFIG_PERF_EVENTS),)
+lttng-tracer-objs += $(shell \
+       if [ $(VERSION) -ge 3 \
+               -o \( $(VERSION) -eq 2 -a $(PATCHLEVEL) -ge 6 -a $(SUBLEVEL) -ge 33 \) ] ; then \
+               echo "lttng-context-perf-counters.o" ; fi;)
+endif
+
+obj-m += probes/
+obj-m += lib/
diff --git a/drivers/staging/lttng/README b/drivers/staging/lttng/README
new file mode 100644 (file)
index 0000000..9aa5b93
--- /dev/null
@@ -0,0 +1,93 @@
+LTTng 2.x modules
+
+Mathieu Desnoyers
+March 29, 2013
+
+LTTng 2.x kernel modules build against a vanilla or distribution kernel, without
+need for additional patches. Other features:
+
+- Produces CTF (Common Trace Format) natively,
+  (http://www.efficios.com/ctf)
+- Tracepoints, Function tracer, CPU Performance Monitoring Unit (PMU)
+  counters, kprobes, and kretprobes support,
+- Integrated interface for both kernel and userspace tracing,
+- Have the ability to attach "context" information to events in the
+  trace (e.g. any PMU counter, pid, ppid, tid, comm name, etc).
+  All the extra information fields to be collected with events are
+  optional, specified on a per-tracing-session basis (except for
+  timestamp and event id, which are mandatory).
+
+To build and install, you will need to have your kernel headers available (or
+access to your full kernel source tree), and use:
+
+% make
+# make modules_install
+# depmod -a
+
+If you need to specify the target directory to the kernel you want to build
+against, use:
+
+% KERNELDIR=path_to_kernel_dir make
+# KERNELDIR=path_to_kernel_dir make modules_install
+# depmod -a kernel_version
+
+Use lttng-tools to control the tracer. LTTng tools should automatically load
+the kernel modules when needed. Use Babeltrace to print traces as a
+human-readable text log. These tools are available at the following URL:
+http://lttng.org/lttng2.0
+
+So far, it has been tested on vanilla Linux kernels 2.6.38, 2.6.39, 3.0,
+3.1, 3.2, 3.3 (on x86 32/64-bit, and powerpc 32-bit at the moment, build
+tested on ARM), 3.4, 3.5, 3.8, 3.9-rc on x86 64-bit. Kernels 2.6.32 to
+2.6.34 need up to 3 patches applied (refer to linux-patches within the
+lttng-modules tree). It should work fine with newer kernels and other
+architectures, but expect build issues with kernels older than 2.6.36.
+The clock source currently used is the standard gettimeofday (slower,
+less scalable and less precise than the LTTng 0.x clocks).  Support for
+LTTng 0.x clocks will be added back soon into LTTng 2.0.
+
+
+* Kernel config options required
+
+CONFIG_MODULES: required
+  * Kernel modules support.
+CONFIG_KALLSYMS: required
+  * See wrapper/ files. This is necessary until the few required missing
+    symbols are exported to GPL modules from mainline.
+CONFIG_HIGH_RES_TIMERS: required
+  * Needed for LTTng 2.0 clock source.
+CONFIG_TRACEPOINTS: required
+    kernel tracepoint instrumentation
+    * Enabled as side-effect of any of the perf/ftrace/blktrace
+      instrumentation features.
+
+
+* Kernel config options supported (optional)
+
+The following kernel configuration options will affect the features
+available from LTTng:
+
+
+CONFIG_HAVE_SYSCALL_TRACEPOINTS:
+            system call tracing
+               lttng enable-event -k --syscall
+               lttng enable-event -k -a
+CONFIG_PERF_EVENTS:
+            performance counters
+               lttng add-context -t perf:*
+CONFIG_EVENT_TRACING:
+            needed to allow block layer tracing
+CONFIG_KPROBES:
+            Dynamic probe.
+               lttng enable-event -k --probe ...
+CONFIG_KRETPROBES:
+            Dynamic function entry/return probe.
+               lttng enable-event -k --function ...
+
+
+* Note about Perf PMU counters support
+
+Each PMU counter has its zero value set when it is attached to a context with
+add-context. Therefore, it is normal that the same counters attached to both the
+stream context and event context show different values for a given event; what
+matters is that they increment at the same rate.
diff --git a/drivers/staging/lttng/TODO b/drivers/staging/lttng/TODO
new file mode 100644 (file)
index 0000000..5383ef3
--- /dev/null
@@ -0,0 +1,117 @@
+Please contact Mathieu Desnoyers <mathieu.desnoyers@efficios.com> for
+questions about this TODO list. The "Cleanup/Testing" section would be
+good to go through before integration into mainline. The "Features"
+section is a wish list of features to complete before releasing the
+"LTTng 2.0" final version, but are not required to have LTTng working.
+These features are mostly performance enhancements and instrumentation
+enhancements.
+
+TODO:
+
+A) Cleanup/Testing
+
+       1) Test lib ring buffer snapshot feature.
+          When working on the lttngtop project, Julien Desfossez
+          reported that he needed to push the consumer position
+          forward explicitely with lib_ring_buffer_put_next_subbuf.
+          This means that although the usual case of pairs of
+          lib_ring_buffer_get_next_subbuf/lib_ring_buffer_put_next_subbuf
+          work fine, there is probably a problem that needs to be
+          investigated in
+          lib_ring_buffer_get_subbuf/lib_ring_buffer_put_subbuf, which
+          depend on the producer to push the reader position.
+          Contact: Julien Desfossez <julien.desfossez@polymtl.ca>
+
+
+B) Features
+
+       1) Integration of the LTTng 0.x trace clocks into
+          LTTng 2.0.
+            Currently using mainline kernel monotonic clock. NMIs can
+            therefore not be traced, and this causes a significant
+            performance degradation compared to the LTTng 0.x trace
+            clocks. Imply the creation of drivers/staging/lttng/arch to
+            contain the arch-specific clock support files.
+            * Dependency: addition of clock descriptions to CTF.
+          See: http://git.lttng.org/?p=linux-2.6-lttng.git;a=summary
+               for the LTTng 0.x git tree.
+
+       2) Port OMAP3 LTTng trace clocks to x86 to support systems
+          without constant TSC.
+           * Dependency: (B.1)
+          See: http://git.lttng.org/?p=linux-2.6-lttng.git;a=summary
+               for the LTTng 0.x git tree.
+
+       3) Implement mmap operation on an anonymous file created by a
+          LTTNG_KERNEL_CLOCK ioctl to export data to export
+          synchronized kernel and user-level LTTng trace clocks:
+          with:
+             - shared per-cpu data,
+             - read seqlock.
+          The content exported by this shared memory area will be
+          arch-specific.
+          * Dependency: (B.1) && (B.2)
+          See: http://git.lttng.org/?p=linux-2.6-lttng.git;a=summary
+               for the LTTng 0.x git tree, which has vDSO support for
+               LTTng trace clock on the x86 architecture.
+
+       3) Integrate the "statedump" module from LTTng 0.x into LTTng
+          2.0.
+          See: http://git.lttng.org/?p=lttng-modules.git;a=shortlog;h=refs/heads/v0.19-stable
+               ltt-statedump.c
+
+       4) Generate system call TRACE_EVENT headers for all
+          architectures (currently done: x86 32/64).
+
+       5) Define "unknown" system calls into instrumentation/syscalls
+          override files / or do SYSCALL_DEFINE improvements to
+          mainline kernel to allow automatic generation of these
+          missing system call descriptions.
+
+       6) Create missing tracepoint event headers files into
+          instrumentation/events from headers located in
+          include/trace/events/. Choice: either do as currently done,
+          and copy those headers locally into the lttng driver and
+          perform the modifications locally, or push TRACE_EVENT API
+          modification into mainline headers, which would require
+          collaboration from Ftrace/Perf maintainers.
+
+       7) Poll: implement a poll and/or epoll exclusive wakeup scheme,
+          which contradicts POSIX, but protect multiple consumer
+          threads from thundering herd effect.
+
+       8) Re-integrate sample modules from libringbuffer into
+          lttng driver. Those modules can be used as example of how to
+          use libringbuffer in other contexts than LTTng, and are
+          useful to perform benchmarks of the ringbuffer library.
+          See: http://www.efficios.com/ringbuffer
+
+       9) NOHZ support for lib ring buffer. NOHZ infrastructure in the
+          Linux kernel does not support notifiers chains, which does
+          not let LTTng play nicely with low power consumption setups
+          for flight recorder (overwrite mode) live traces. One way to
+          allow integration between NOHZ and LTTng would be to add
+          support for such notifiers into NOHZ kernel infrastructure.
+
+       10) Turn lttng-probes.c probe_list into a
+           hash table. Turns O(n^2) trace systems registration (cost
+           for n systems) into O(n). (O(1) per system)
+
+       11) drivers/staging/lttng/probes/lttng-ftrace.c:
+           LTTng currently uses kretprobes for per-function tracing,
+           not the function tracer. So lttng-ftrace.c should be used
+           for "all" function tracing.
+
+       12) drivers/staging/lttng/probes/lttng-types.c:
+           This is a currently unused placeholder to export entire C
+           type declarations into the trace metadata, e.g. for support
+           of describing the layout of structures/enumeration mapping
+           along with syscall entry events.  The design of this support
+           will likely change though, and become integrated with the
+           TRACE_EVENT support within lttng, by adding new macros, and
+           support for generation of metadata from these macros, to
+           allow description of those compound types/enumerations.
+
+Please send patches
+To: Greg Kroah-Hartman <greg@kroah.com>
+To: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
diff --git a/drivers/staging/lttng/instrumentation/events/README b/drivers/staging/lttng/instrumentation/events/README
new file mode 100644 (file)
index 0000000..79224e2
--- /dev/null
@@ -0,0 +1,27 @@
+* Workflow for updating patches from newer kernel:
+
+Diff mainline/ and lttng-module/ directories.
+
+Pull the new headers from mainline kernel to mainline/.
+Copy them into lttng-modules.
+Apply diff. Fix conflicts.
+
+
+* Workflow to add new Tracepoint instrumentation to newer kernel,
+  and add support for it into LTTng:
+
+a) instrument the kernel with new trace events headers. If you want that
+   instrumentation distributed, you will have to push those changes into
+   the upstream Linux kernel first,
+b) copy those headers into lttng mainline/ directory,
+c) look at a diff from other headers between mainline/ and
+   lttng/, and use that as a recipe to create a new lttng/
+   header from the mainline/ header,
+d) create a new file in probes/ for the new trace event header you added,
+e) add it to probes/Makefile,
+f) build, make modules_install,
+g) don't forget to load that new module too.
+
+Currently, LTTng policy is to only accept headers derived from trace
+event headers accepted into the Linux kernel upstream for tracepoints
+related to upstream kernel instrumentation.
diff --git a/drivers/staging/lttng/instrumentation/events/lttng-module/arch/x86/kvm/mmutrace.h b/drivers/staging/lttng/instrumentation/events/lttng-module/arch/x86/kvm/mmutrace.h
new file mode 100644 (file)
index 0000000..56ddbab
--- /dev/null
@@ -0,0 +1,285 @@
+#if !defined(_TRACE_KVMMMU_H) || defined(TRACE_HEADER_MULTI_READ)
+#define _TRACE_KVMMMU_H
+
+#include <linux/tracepoint.h>
+#include <linux/ftrace_event.h>
+
+#undef TRACE_SYSTEM
+#define TRACE_SYSTEM kvmmmu
+
+#define KVM_MMU_PAGE_FIELDS \
+       __field(__u64, gfn) \
+       __field(__u32, role) \
+       __field(__u32, root_count) \
+       __field(bool, unsync)
+
+#define KVM_MMU_PAGE_ASSIGN(sp)                             \
+       tp_assign(gfn, sp->gfn)                      \
+       tp_assign(role, sp->role.word)               \
+       tp_assign(root_count, sp->root_count)        \
+       tp_assign(unsync, sp->unsync)
+
+#define KVM_MMU_PAGE_PRINTK() ({                                       \
+       const char *ret = p->buffer + p->len;                           \
+       static const char *access_str[] = {                             \
+               "---", "--x", "w--", "w-x", "-u-", "-ux", "wu-", "wux"  \
+       };                                                              \
+       union kvm_mmu_page_role role;                                   \
+                                                                       \
+       role.word = __entry->role;                                      \
+                                                                       \
+       trace_seq_printf(p, "sp gfn %llx %u%s q%u%s %s%s"               \
+                        " %snxe root %u %s%c",                         \
+                        __entry->gfn, role.level,                      \
+                        role.cr4_pae ? " pae" : "",                    \
+                        role.quadrant,                                 \
+                        role.direct ? " direct" : "",                  \
+                        access_str[role.access],                       \
+                        role.invalid ? " invalid" : "",                \
+                        role.nxe ? "" : "!",                           \
+                        __entry->root_count,                           \
+                        __entry->unsync ? "unsync" : "sync", 0);       \
+       ret;                                                            \
+               })
+
+#define kvm_mmu_trace_pferr_flags       \
+       { PFERR_PRESENT_MASK, "P" },    \
+       { PFERR_WRITE_MASK, "W" },      \
+       { PFERR_USER_MASK, "U" },       \
+       { PFERR_RSVD_MASK, "RSVD" },    \
+       { PFERR_FETCH_MASK, "F" }
+
+/*
+ * A pagetable walk has started
+ */
+TRACE_EVENT(
+       kvm_mmu_pagetable_walk,
+       TP_PROTO(u64 addr, u32 pferr),
+       TP_ARGS(addr, pferr),
+
+       TP_STRUCT__entry(
+               __field(__u64, addr)
+               __field(__u32, pferr)
+       ),
+
+       TP_fast_assign(
+               tp_assign(addr, addr)
+               tp_assign(pferr, pferr)
+       ),
+
+       TP_printk("addr %llx pferr %x %s", __entry->addr, __entry->pferr,
+                 __print_flags(__entry->pferr, "|", kvm_mmu_trace_pferr_flags))
+)
+
+
+/* We just walked a paging element */
+TRACE_EVENT(
+       kvm_mmu_paging_element,
+       TP_PROTO(u64 pte, int level),
+       TP_ARGS(pte, level),
+
+       TP_STRUCT__entry(
+               __field(__u64, pte)
+               __field(__u32, level)
+               ),
+
+       TP_fast_assign(
+               tp_assign(pte, pte)
+               tp_assign(level, level)
+               ),
+
+       TP_printk("pte %llx level %u", __entry->pte, __entry->level)
+)
+
+DECLARE_EVENT_CLASS(kvm_mmu_set_bit_class,
+
+       TP_PROTO(unsigned long table_gfn, unsigned index, unsigned size),
+
+       TP_ARGS(table_gfn, index, size),
+
+       TP_STRUCT__entry(
+               __field(__u64, gpa)
+       ),
+
+       TP_fast_assign(
+               tp_assign(gpa, ((u64)table_gfn << PAGE_SHIFT)
+                               + index * size)
+               ),
+
+       TP_printk("gpa %llx", __entry->gpa)
+)
+
+/* We set a pte accessed bit */
+DEFINE_EVENT(kvm_mmu_set_bit_class, kvm_mmu_set_accessed_bit,
+
+       TP_PROTO(unsigned long table_gfn, unsigned index, unsigned size),
+
+       TP_ARGS(table_gfn, index, size)
+)
+
+/* We set a pte dirty bit */
+DEFINE_EVENT(kvm_mmu_set_bit_class, kvm_mmu_set_dirty_bit,
+
+       TP_PROTO(unsigned long table_gfn, unsigned index, unsigned size),
+
+       TP_ARGS(table_gfn, index, size)
+)
+
+TRACE_EVENT(
+       kvm_mmu_walker_error,
+       TP_PROTO(u32 pferr),
+       TP_ARGS(pferr),
+
+       TP_STRUCT__entry(
+               __field(__u32, pferr)
+               ),
+
+       TP_fast_assign(
+               tp_assign(pferr, pferr)
+               ),
+
+       TP_printk("pferr %x %s", __entry->pferr,
+                 __print_flags(__entry->pferr, "|", kvm_mmu_trace_pferr_flags))
+)
+
+TRACE_EVENT(
+       kvm_mmu_get_page,
+       TP_PROTO(struct kvm_mmu_page *sp, bool created),
+       TP_ARGS(sp, created),
+
+       TP_STRUCT__entry(
+               KVM_MMU_PAGE_FIELDS
+               __field(bool, created)
+               ),
+
+       TP_fast_assign(
+               KVM_MMU_PAGE_ASSIGN(sp)
+               tp_assign(created, created)
+               ),
+
+       TP_printk("%s %s", KVM_MMU_PAGE_PRINTK(),
+                 __entry->created ? "new" : "existing")
+)
+
+DECLARE_EVENT_CLASS(kvm_mmu_page_class,
+
+       TP_PROTO(struct kvm_mmu_page *sp),
+       TP_ARGS(sp),
+
+       TP_STRUCT__entry(
+               KVM_MMU_PAGE_FIELDS
+       ),
+
+       TP_fast_assign(
+               KVM_MMU_PAGE_ASSIGN(sp)
+       ),
+
+       TP_printk("%s", KVM_MMU_PAGE_PRINTK())
+)
+
+DEFINE_EVENT(kvm_mmu_page_class, kvm_mmu_sync_page,
+       TP_PROTO(struct kvm_mmu_page *sp),
+
+       TP_ARGS(sp)
+)
+
+DEFINE_EVENT(kvm_mmu_page_class, kvm_mmu_unsync_page,
+       TP_PROTO(struct kvm_mmu_page *sp),
+
+       TP_ARGS(sp)
+)
+
+DEFINE_EVENT(kvm_mmu_page_class, kvm_mmu_prepare_zap_page,
+       TP_PROTO(struct kvm_mmu_page *sp),
+
+       TP_ARGS(sp)
+)
+
+TRACE_EVENT(
+       mark_mmio_spte,
+       TP_PROTO(u64 *sptep, gfn_t gfn, unsigned access),
+       TP_ARGS(sptep, gfn, access),
+
+       TP_STRUCT__entry(
+               __field(void *, sptep)
+               __field(gfn_t, gfn)
+               __field(unsigned, access)
+       ),
+
+       TP_fast_assign(
+               tp_assign(sptep, sptep)
+               tp_assign(gfn, gfn)
+               tp_assign(access, access)
+       ),
+
+       TP_printk("sptep:%p gfn %llx access %x", __entry->sptep, __entry->gfn,
+                 __entry->access)
+)
+
+TRACE_EVENT(
+       handle_mmio_page_fault,
+       TP_PROTO(u64 addr, gfn_t gfn, unsigned access),
+       TP_ARGS(addr, gfn, access),
+
+       TP_STRUCT__entry(
+               __field(u64, addr)
+               __field(gfn_t, gfn)
+               __field(unsigned, access)
+       ),
+
+       TP_fast_assign(
+               tp_assign(addr, addr)
+               tp_assign(gfn, gfn)
+               tp_assign(access, access)
+       ),
+
+       TP_printk("addr:%llx gfn %llx access %x", __entry->addr, __entry->gfn,
+                 __entry->access)
+)
+
+#define __spte_satisfied(__spte)                               \
+       (__entry->retry && is_writable_pte(__entry->__spte))
+
+TRACE_EVENT(
+       fast_page_fault,
+       TP_PROTO(struct kvm_vcpu *vcpu, gva_t gva, u32 error_code,
+                u64 *sptep, u64 old_spte, bool retry),
+       TP_ARGS(vcpu, gva, error_code, sptep, old_spte, retry),
+
+       TP_STRUCT__entry(
+               __field(int, vcpu_id)
+               __field(gva_t, gva)
+               __field(u32, error_code)
+               __field(u64 *, sptep)
+               __field(u64, old_spte)
+               __field(u64, new_spte)
+               __field(bool, retry)
+       ),
+
+       TP_fast_assign(
+               tp_assign(vcpu_id, vcpu->vcpu_id)
+               tp_assign(gva, gva)
+               tp_assign(error_code, error_code)
+               tp_assign(sptep, sptep)
+               tp_assign(old_spte, old_spte)
+               tp_assign(new_spte, *sptep)
+               tp_assign(retry, retry)
+       ),
+
+       TP_printk("vcpu %d gva %lx error_code %s sptep %p old %#llx"
+                 " new %llx spurious %d fixed %d", __entry->vcpu_id,
+                 __entry->gva, __print_flags(__entry->error_code, "|",
+                 kvm_mmu_trace_pferr_flags), __entry->sptep,
+                 __entry->old_spte, __entry->new_spte,
+                 __spte_satisfied(old_spte), __spte_satisfied(new_spte)
+       )
+)
+#endif /* _TRACE_KVMMMU_H */
+
+#undef TRACE_INCLUDE_PATH
+#define TRACE_INCLUDE_PATH ../instrumentation/events/lttng-module/arch/x86/kvm
+#undef TRACE_INCLUDE_FILE
+#define TRACE_INCLUDE_FILE mmutrace
+
+/* This part must be outside protection */
+#include "../../../../../../probes/define_trace.h"
diff --git a/drivers/staging/lttng/instrumentation/events/lttng-module/arch/x86/kvm/trace.h b/drivers/staging/lttng/instrumentation/events/lttng-module/arch/x86/kvm/trace.h
new file mode 100644 (file)
index 0000000..8e71a7f
--- /dev/null
@@ -0,0 +1,833 @@
+#if !defined(_TRACE_KVM_H) || defined(TRACE_HEADER_MULTI_READ)
+#define _TRACE_KVM_H
+
+#include <linux/tracepoint.h>
+#include <asm/vmx.h>
+#include <asm/svm.h>
+#include <asm/clocksource.h>
+#include <linux/version.h>
+#include <../arch/x86/kvm/lapic.h>
+#include <../arch/x86/kvm/kvm_cache_regs.h>
+
+#undef TRACE_SYSTEM
+#define TRACE_SYSTEM kvm
+
+/*
+ * Tracepoint for guest mode entry.
+ */
+TRACE_EVENT(kvm_entry,
+       TP_PROTO(unsigned int vcpu_id),
+       TP_ARGS(vcpu_id),
+
+       TP_STRUCT__entry(
+               __field(        unsigned int,   vcpu_id         )
+       ),
+
+       TP_fast_assign(
+               tp_assign(vcpu_id, vcpu_id)
+       ),
+
+       TP_printk("vcpu %u", __entry->vcpu_id)
+)
+
+/*
+ * Tracepoint for hypercall.
+ */
+TRACE_EVENT(kvm_hypercall,
+       TP_PROTO(unsigned long nr, unsigned long a0, unsigned long a1,
+                unsigned long a2, unsigned long a3),
+       TP_ARGS(nr, a0, a1, a2, a3),
+
+       TP_STRUCT__entry(
+               __field(        unsigned long,  nr              )
+               __field(        unsigned long,  a0              )
+               __field(        unsigned long,  a1              )
+               __field(        unsigned long,  a2              )
+               __field(        unsigned long,  a3              )
+       ),
+
+       TP_fast_assign(
+               tp_assign(nr, nr)
+               tp_assign(a0, a0)
+               tp_assign(a1, a1)
+               tp_assign(a2, a2)
+               tp_assign(a3, a3)
+       ),
+
+       TP_printk("nr 0x%lx a0 0x%lx a1 0x%lx a2 0x%lx a3 0x%lx",
+                __entry->nr, __entry->a0, __entry->a1,  __entry->a2,
+                __entry->a3)
+)
+
+/*
+ * Tracepoint for hypercall.
+ */
+TRACE_EVENT(kvm_hv_hypercall,
+       TP_PROTO(__u16 code, bool fast, __u16 rep_cnt, __u16 rep_idx,
+                __u64 ingpa, __u64 outgpa),
+       TP_ARGS(code, fast, rep_cnt, rep_idx, ingpa, outgpa),
+
+       TP_STRUCT__entry(
+               __field(        __u16,          rep_cnt         )
+               __field(        __u16,          rep_idx         )
+               __field(        __u64,          ingpa           )
+               __field(        __u64,          outgpa          )
+               __field(        __u16,          code            )
+               __field(        bool,           fast            )
+       ),
+
+       TP_fast_assign(
+               tp_assign(rep_cnt, rep_cnt)
+               tp_assign(rep_idx, rep_idx)
+               tp_assign(ingpa, ingpa)
+               tp_assign(outgpa, outgpa)
+               tp_assign(code, code)
+               tp_assign(fast, fast)
+       ),
+
+       TP_printk("code 0x%x %s cnt 0x%x idx 0x%x in 0x%llx out 0x%llx",
+                 __entry->code, __entry->fast ? "fast" : "slow",
+                 __entry->rep_cnt, __entry->rep_idx,  __entry->ingpa,
+                 __entry->outgpa)
+)
+
+/*
+ * Tracepoint for PIO.
+ */
+TRACE_EVENT(kvm_pio,
+       TP_PROTO(unsigned int rw, unsigned int port, unsigned int size,
+                unsigned int count),
+       TP_ARGS(rw, port, size, count),
+
+       TP_STRUCT__entry(
+               __field(        unsigned int,   rw              )
+               __field(        unsigned int,   port            )
+               __field(        unsigned int,   size            )
+               __field(        unsigned int,   count           )
+       ),
+
+       TP_fast_assign(
+               tp_assign(rw, rw)
+               tp_assign(port, port)
+               tp_assign(size, size)
+               tp_assign(count, count)
+       ),
+
+       TP_printk("pio_%s at 0x%x size %d count %d",
+                 __entry->rw ? "write" : "read",
+                 __entry->port, __entry->size, __entry->count)
+)
+
+/*
+ * Tracepoint for cpuid.
+ */
+TRACE_EVENT(kvm_cpuid,
+       TP_PROTO(unsigned int function, unsigned long rax, unsigned long rbx,
+                unsigned long rcx, unsigned long rdx),
+       TP_ARGS(function, rax, rbx, rcx, rdx),
+
+       TP_STRUCT__entry(
+               __field(        unsigned int,   function        )
+               __field(        unsigned long,  rax             )
+               __field(        unsigned long,  rbx             )
+               __field(        unsigned long,  rcx             )
+               __field(        unsigned long,  rdx             )
+       ),
+
+       TP_fast_assign(
+               tp_assign(function, function)
+               tp_assign(rax, rax)
+               tp_assign(rbx, rbx)
+               tp_assign(rcx, rcx)
+               tp_assign(rdx, rdx)
+       ),
+
+       TP_printk("func %x rax %lx rbx %lx rcx %lx rdx %lx",
+                 __entry->function, __entry->rax,
+                 __entry->rbx, __entry->rcx, __entry->rdx)
+)
+
+#define AREG(x) { APIC_##x, "APIC_" #x }
+
+#define kvm_trace_symbol_apic                                              \
+       AREG(ID), AREG(LVR), AREG(TASKPRI), AREG(ARBPRI), AREG(PROCPRI),    \
+       AREG(EOI), AREG(RRR), AREG(LDR), AREG(DFR), AREG(SPIV), AREG(ISR),  \
+       AREG(TMR), AREG(IRR), AREG(ESR), AREG(ICR), AREG(ICR2), AREG(LVTT), \
+       AREG(LVTTHMR), AREG(LVTPC), AREG(LVT0), AREG(LVT1), AREG(LVTERR),   \
+       AREG(TMICT), AREG(TMCCT), AREG(TDCR), AREG(SELF_IPI), AREG(EFEAT),  \
+       AREG(ECTRL)
+/*
+ * Tracepoint for apic access.
+ */
+TRACE_EVENT(kvm_apic,
+       TP_PROTO(unsigned int rw, unsigned int reg, unsigned int val),
+       TP_ARGS(rw, reg, val),
+
+       TP_STRUCT__entry(
+               __field(        unsigned int,   rw              )
+               __field(        unsigned int,   reg             )
+               __field(        unsigned int,   val             )
+       ),
+
+       TP_fast_assign(
+               tp_assign(rw, rw)
+               tp_assign(reg, reg)
+               tp_assign(val, val)
+       ),
+
+       TP_printk("apic_%s %s = 0x%x",
+                 __entry->rw ? "write" : "read",
+                 __print_symbolic(__entry->reg, kvm_trace_symbol_apic),
+                 __entry->val)
+)
+
+#define trace_kvm_apic_read(reg, val)          trace_kvm_apic(0, reg, val)
+#define trace_kvm_apic_write(reg, val)         trace_kvm_apic(1, reg, val)
+
+#define KVM_ISA_VMX   1
+#define KVM_ISA_SVM   2
+
+/*
+ * Tracepoint for kvm guest exit:
+ */
+TRACE_EVENT(kvm_exit,
+       TP_PROTO(unsigned int exit_reason, struct kvm_vcpu *vcpu, u32 isa, u64 info1, u64 info2),
+       TP_ARGS(exit_reason, vcpu, isa, info1, info2),
+
+       TP_STRUCT__entry(
+               __field(        unsigned int,   exit_reason     )
+               __field(        unsigned long,  guest_rip       )
+               __field(        u32,            isa             )
+               __field(        u64,            info1           )
+               __field(        u64,            info2           )
+       ),
+
+       TP_fast_assign(
+               tp_assign(exit_reason, exit_reason)
+               tp_assign(guest_rip, kvm_rip_read(vcpu))
+               tp_assign(isa, isa)
+    kvm_x86_ops->get_exit_info(vcpu, &info1,
+              &info2);
+    tp_assign(info1, info1)
+    tp_assign(info2, info2)
+       ),
+
+       TP_printk("reason %s rip  info %llx %llx",
+                (__entry->isa == KVM_ISA_VMX) ?
+                __print_symbolic(__entry->exit_reason, VMX_EXIT_REASONS) :
+                __print_symbolic(__entry->exit_reason, SVM_EXIT_REASONS),
+               /* __entry->guest_rip,*/ __entry->info1, __entry->info2)
+)
+
+/*
+ * Tracepoint for kvm interrupt injection:
+ */
+TRACE_EVENT(kvm_inj_virq,
+       TP_PROTO(unsigned int irq),
+       TP_ARGS(irq),
+
+       TP_STRUCT__entry(
+               __field(        unsigned int,   irq             )
+       ),
+
+       TP_fast_assign(
+               tp_assign(irq, irq)
+       ),
+
+       TP_printk("irq %u", __entry->irq)
+)
+
+#define EXS(x) { x##_VECTOR, "#" #x }
+
+#define kvm_trace_sym_exc                                              \
+       EXS(DE), EXS(DB), EXS(BP), EXS(OF), EXS(BR), EXS(UD), EXS(NM),  \
+       EXS(DF), EXS(TS), EXS(NP), EXS(SS), EXS(GP), EXS(PF),           \
+       EXS(MF), EXS(MC)
+
+/*
+ * Tracepoint for kvm interrupt injection:
+ */
+TRACE_EVENT(kvm_inj_exception,
+       TP_PROTO(unsigned exception, bool has_error, unsigned error_code),
+       TP_ARGS(exception, has_error, error_code),
+
+       TP_STRUCT__entry(
+               __field(        u8,     exception       )
+               __field(        u8,     has_error       )
+               __field(        u32,    error_code      )
+       ),
+
+       TP_fast_assign(
+               tp_assign(exception, exception)
+               tp_assign(has_error, has_error)
+               tp_assign(error_code, error_code)
+       ),
+
+       TP_printk("%s (0x%x)",
+                 __print_symbolic(__entry->exception, kvm_trace_sym_exc),
+                 /* FIXME: don't print error_code if not present */
+                 __entry->has_error ? __entry->error_code : 0)
+)
+
+/*
+ * Tracepoint for page fault.
+ */
+TRACE_EVENT(kvm_page_fault,
+       TP_PROTO(unsigned long fault_address, unsigned int error_code),
+       TP_ARGS(fault_address, error_code),
+
+       TP_STRUCT__entry(
+               __field(        unsigned long,  fault_address   )
+               __field(        unsigned int,   error_code      )
+       ),
+
+       TP_fast_assign(
+               tp_assign(fault_address, fault_address)
+               tp_assign(error_code, error_code)
+       ),
+
+       TP_printk("address %lx error_code %x",
+                 __entry->fault_address, __entry->error_code)
+)
+
+/*
+ * Tracepoint for guest MSR access.
+ */
+TRACE_EVENT(kvm_msr,
+       TP_PROTO(unsigned write, u32 ecx, u64 data, bool exception),
+       TP_ARGS(write, ecx, data, exception),
+
+       TP_STRUCT__entry(
+               __field(        unsigned,       write           )
+               __field(        u32,            ecx             )
+               __field(        u64,            data            )
+               __field(        u8,             exception       )
+       ),
+
+       TP_fast_assign(
+               tp_assign(write, write)
+               tp_assign(ecx, ecx)
+               tp_assign(data, data)
+               tp_assign(exception, exception)
+       ),
+
+       TP_printk("msr_%s %x = 0x%llx%s",
+                 __entry->write ? "write" : "read",
+                 __entry->ecx, __entry->data,
+                 __entry->exception ? " (#GP)" : "")
+)
+
+#define trace_kvm_msr_read(ecx, data)      trace_kvm_msr(0, ecx, data, false)
+#define trace_kvm_msr_write(ecx, data)     trace_kvm_msr(1, ecx, data, false)
+#define trace_kvm_msr_read_ex(ecx)         trace_kvm_msr(0, ecx, 0, true)
+#define trace_kvm_msr_write_ex(ecx, data)  trace_kvm_msr(1, ecx, data, true)
+
+/*
+ * Tracepoint for guest CR access.
+ */
+TRACE_EVENT(kvm_cr,
+       TP_PROTO(unsigned int rw, unsigned int cr, unsigned long val),
+       TP_ARGS(rw, cr, val),
+
+       TP_STRUCT__entry(
+               __field(        unsigned int,   rw              )
+               __field(        unsigned int,   cr              )
+               __field(        unsigned long,  val             )
+       ),
+
+       TP_fast_assign(
+               tp_assign(rw, rw)
+               tp_assign(cr, cr)
+               tp_assign(val, val)
+       ),
+
+       TP_printk("cr_%s %x = 0x%lx",
+                 __entry->rw ? "write" : "read",
+                 __entry->cr, __entry->val)
+)
+
+#define trace_kvm_cr_read(cr, val)             trace_kvm_cr(0, cr, val)
+#define trace_kvm_cr_write(cr, val)            trace_kvm_cr(1, cr, val)
+
+TRACE_EVENT(kvm_pic_set_irq,
+           TP_PROTO(__u8 chip, __u8 pin, __u8 elcr, __u8 imr, bool coalesced),
+           TP_ARGS(chip, pin, elcr, imr, coalesced),
+
+       TP_STRUCT__entry(
+               __field(        __u8,           chip            )
+               __field(        __u8,           pin             )
+               __field(        __u8,           elcr            )
+               __field(        __u8,           imr             )
+               __field(        bool,           coalesced       )
+       ),
+
+       TP_fast_assign(
+               tp_assign(chip, chip)
+               tp_assign(pin, pin)
+               tp_assign(elcr, elcr)
+               tp_assign(imr, imr)
+               tp_assign(coalesced, coalesced)
+       ),
+
+       TP_printk("chip %u pin %u (%s%s)%s",
+                 __entry->chip, __entry->pin,
+                 (__entry->elcr & (1 << __entry->pin)) ? "level":"edge",
+                 (__entry->imr & (1 << __entry->pin)) ? "|masked":"",
+                 __entry->coalesced ? " (coalesced)" : "")
+)
+
+#define kvm_apic_dst_shorthand         \
+       {0x0, "dst"},                   \
+       {0x1, "self"},                  \
+       {0x2, "all"},                   \
+       {0x3, "all-but-self"}
+
+TRACE_EVENT(kvm_apic_ipi,
+           TP_PROTO(__u32 icr_low, __u32 dest_id),
+           TP_ARGS(icr_low, dest_id),
+
+       TP_STRUCT__entry(
+               __field(        __u32,          icr_low         )
+               __field(        __u32,          dest_id         )
+       ),
+
+       TP_fast_assign(
+               tp_assign(icr_low, icr_low)
+               tp_assign(dest_id, dest_id)
+       ),
+
+       TP_printk("dst %x vec %u (%s|%s|%s|%s|%s)",
+                 __entry->dest_id, (u8)__entry->icr_low,
+                 __print_symbolic((__entry->icr_low >> 8 & 0x7),
+                                  kvm_deliver_mode),
+                 (__entry->icr_low & (1<<11)) ? "logical" : "physical",
+                 (__entry->icr_low & (1<<14)) ? "assert" : "de-assert",
+                 (__entry->icr_low & (1<<15)) ? "level" : "edge",
+                 __print_symbolic((__entry->icr_low >> 18 & 0x3),
+                                  kvm_apic_dst_shorthand))
+)
+
+TRACE_EVENT(kvm_apic_accept_irq,
+           TP_PROTO(__u32 apicid, __u16 dm, __u8 tm, __u8 vec, bool coalesced),
+           TP_ARGS(apicid, dm, tm, vec, coalesced),
+
+       TP_STRUCT__entry(
+               __field(        __u32,          apicid          )
+               __field(        __u16,          dm              )
+               __field(        __u8,           tm              )
+               __field(        __u8,           vec             )
+               __field(        bool,           coalesced       )
+       ),
+
+       TP_fast_assign(
+               tp_assign(apicid, apicid)
+               tp_assign(dm, dm)
+               tp_assign(tm, tm)
+               tp_assign(vec, vec)
+               tp_assign(coalesced, coalesced)
+       ),
+
+       TP_printk("apicid %x vec %u (%s|%s)%s",
+                 __entry->apicid, __entry->vec,
+                 __print_symbolic((__entry->dm >> 8 & 0x7), kvm_deliver_mode),
+                 __entry->tm ? "level" : "edge",
+                 __entry->coalesced ? " (coalesced)" : "")
+)
+
+TRACE_EVENT(kvm_eoi,
+           TP_PROTO(struct kvm_lapic *apic, int vector),
+           TP_ARGS(apic, vector),
+
+       TP_STRUCT__entry(
+               __field(        __u32,          apicid          )
+               __field(        int,            vector          )
+       ),
+
+       TP_fast_assign(
+               tp_assign(apicid, apic->vcpu->vcpu_id)
+               tp_assign(vector, vector)
+       ),
+
+       TP_printk("apicid %x vector %d", __entry->apicid, __entry->vector)
+)
+
+TRACE_EVENT(kvm_pv_eoi,
+           TP_PROTO(struct kvm_lapic *apic, int vector),
+           TP_ARGS(apic, vector),
+
+       TP_STRUCT__entry(
+               __field(        __u32,          apicid          )
+               __field(        int,            vector          )
+       ),
+
+       TP_fast_assign(
+               tp_assign(apicid, apic->vcpu->vcpu_id)
+               tp_assign(vector, vector)
+       ),
+
+       TP_printk("apicid %x vector %d", __entry->apicid, __entry->vector)
+)
+
+/*
+ * Tracepoint for nested VMRUN
+ */
+TRACE_EVENT(kvm_nested_vmrun,
+           TP_PROTO(__u64 rip, __u64 vmcb, __u64 nested_rip, __u32 int_ctl,
+                    __u32 event_inj, bool npt),
+           TP_ARGS(rip, vmcb, nested_rip, int_ctl, event_inj, npt),
+
+       TP_STRUCT__entry(
+               __field(        __u64,          rip             )
+               __field(        __u64,          vmcb            )
+               __field(        __u64,          nested_rip      )
+               __field(        __u32,          int_ctl         )
+               __field(        __u32,          event_inj       )
+               __field(        bool,           npt             )
+       ),
+
+       TP_fast_assign(
+               tp_assign(rip, rip)
+               tp_assign(vmcb, vmcb)
+               tp_assign(nested_rip, nested_rip)
+               tp_assign(int_ctl, int_ctl)
+               tp_assign(event_inj, event_inj)
+               tp_assign(npt, npt)
+       ),
+
+       TP_printk("rip: 0x%016llx vmcb: 0x%016llx nrip: 0x%016llx int_ctl: 0x%08x "
+                 "event_inj: 0x%08x npt: %s",
+               __entry->rip, __entry->vmcb, __entry->nested_rip,
+               __entry->int_ctl, __entry->event_inj,
+               __entry->npt ? "on" : "off")
+)
+
+TRACE_EVENT(kvm_nested_intercepts,
+           TP_PROTO(__u16 cr_read, __u16 cr_write, __u32 exceptions, __u64 intercept),
+           TP_ARGS(cr_read, cr_write, exceptions, intercept),
+
+       TP_STRUCT__entry(
+               __field(        __u16,          cr_read         )
+               __field(        __u16,          cr_write        )
+               __field(        __u32,          exceptions      )
+               __field(        __u64,          intercept       )
+       ),
+
+       TP_fast_assign(
+               tp_assign(cr_read, cr_read)
+               tp_assign(cr_write, cr_write)
+               tp_assign(exceptions, exceptions)
+               tp_assign(intercept, intercept)
+       ),
+
+       TP_printk("cr_read: %04x cr_write: %04x excp: %08x intercept: %016llx",
+               __entry->cr_read, __entry->cr_write, __entry->exceptions,
+               __entry->intercept)
+)
+/*
+ * Tracepoint for #VMEXIT while nested
+ */
+TRACE_EVENT(kvm_nested_vmexit,
+           TP_PROTO(__u64 rip, __u32 exit_code,
+                    __u64 exit_info1, __u64 exit_info2,
+                    __u32 exit_int_info, __u32 exit_int_info_err, __u32 isa),
+           TP_ARGS(rip, exit_code, exit_info1, exit_info2,
+                   exit_int_info, exit_int_info_err, isa),
+
+       TP_STRUCT__entry(
+               __field(        __u64,          rip                     )
+               __field(        __u32,          exit_code               )
+               __field(        __u64,          exit_info1              )
+               __field(        __u64,          exit_info2              )
+               __field(        __u32,          exit_int_info           )
+               __field(        __u32,          exit_int_info_err       )
+               __field(        __u32,          isa                     )
+       ),
+
+       TP_fast_assign(
+               tp_assign(rip, rip)
+               tp_assign(exit_code, exit_code)
+               tp_assign(exit_info1, exit_info1)
+               tp_assign(exit_info2, exit_info2)
+               tp_assign(exit_int_info, exit_int_info)
+               tp_assign(exit_int_info_err, exit_int_info_err)
+               tp_assign(isa, isa)
+       ),
+       TP_printk("rip: 0x%016llx reason: %s ext_inf1: 0x%016llx "
+                 "ext_inf2: 0x%016llx ext_int: 0x%08x ext_int_err: 0x%08x",
+                 __entry->rip,
+                (__entry->isa == KVM_ISA_VMX) ?
+                __print_symbolic(__entry->exit_code, VMX_EXIT_REASONS) :
+                __print_symbolic(__entry->exit_code, SVM_EXIT_REASONS),
+                 __entry->exit_info1, __entry->exit_info2,
+                 __entry->exit_int_info, __entry->exit_int_info_err)
+)
+
+/*
+ * Tracepoint for #VMEXIT reinjected to the guest
+ */
+TRACE_EVENT(kvm_nested_vmexit_inject,
+           TP_PROTO(__u32 exit_code,
+                    __u64 exit_info1, __u64 exit_info2,
+                    __u32 exit_int_info, __u32 exit_int_info_err, __u32 isa),
+           TP_ARGS(exit_code, exit_info1, exit_info2,
+                   exit_int_info, exit_int_info_err, isa),
+
+       TP_STRUCT__entry(
+               __field(        __u32,          exit_code               )
+               __field(        __u64,          exit_info1              )
+               __field(        __u64,          exit_info2              )
+               __field(        __u32,          exit_int_info           )
+               __field(        __u32,          exit_int_info_err       )
+               __field(        __u32,          isa                     )
+       ),
+
+       TP_fast_assign(
+               tp_assign(exit_code, exit_code)
+               tp_assign(exit_info1, exit_info1)
+               tp_assign(exit_info2, exit_info2)
+               tp_assign(exit_int_info, exit_int_info)
+               tp_assign(exit_int_info_err, exit_int_info_err)
+               tp_assign(isa, isa)
+       ),
+
+       TP_printk("reason: %s ext_inf1: 0x%016llx "
+                 "ext_inf2: 0x%016llx ext_int: 0x%08x ext_int_err: 0x%08x",
+                (__entry->isa == KVM_ISA_VMX) ?
+                __print_symbolic(__entry->exit_code, VMX_EXIT_REASONS) :
+                __print_symbolic(__entry->exit_code, SVM_EXIT_REASONS),
+               __entry->exit_info1, __entry->exit_info2,
+               __entry->exit_int_info, __entry->exit_int_info_err)
+)
+
+/*
+ * Tracepoint for nested #vmexit because of interrupt pending
+ */
+TRACE_EVENT(kvm_nested_intr_vmexit,
+           TP_PROTO(__u64 rip),
+           TP_ARGS(rip),
+
+       TP_STRUCT__entry(
+               __field(        __u64,  rip     )
+       ),
+
+       TP_fast_assign(
+               tp_assign(rip,  rip)
+       ),
+
+       TP_printk("rip: 0x%016llx", __entry->rip)
+)
+
+/*
+ * Tracepoint for nested #vmexit because of interrupt pending
+ */
+TRACE_EVENT(kvm_invlpga,
+           TP_PROTO(__u64 rip, int asid, u64 address),
+           TP_ARGS(rip, asid, address),
+
+       TP_STRUCT__entry(
+               __field(        __u64,  rip     )
+               __field(        int,    asid    )
+               __field(        __u64,  address )
+       ),
+
+       TP_fast_assign(
+               tp_assign(rip,  rip)
+               tp_assign(asid, asid)
+               tp_assign(address,      address)
+       ),
+
+       TP_printk("rip: 0x%016llx asid: %d address: 0x%016llx",
+                 __entry->rip, __entry->asid, __entry->address)
+)
+
+/*
+ * Tracepoint for nested #vmexit because of interrupt pending
+ */
+TRACE_EVENT(kvm_skinit,
+           TP_PROTO(__u64 rip, __u32 slb),
+           TP_ARGS(rip, slb),
+
+       TP_STRUCT__entry(
+               __field(        __u64,  rip     )
+               __field(        __u32,  slb     )
+       ),
+
+       TP_fast_assign(
+               tp_assign(rip,  rip)
+               tp_assign(slb,  slb)
+       ),
+
+       TP_printk("rip: 0x%016llx slb: 0x%08x",
+                 __entry->rip, __entry->slb)
+)
+
+#define KVM_EMUL_INSN_F_CR0_PE (1 << 0)
+#define KVM_EMUL_INSN_F_EFL_VM (1 << 1)
+#define KVM_EMUL_INSN_F_CS_D   (1 << 2)
+#define KVM_EMUL_INSN_F_CS_L   (1 << 3)
+
+#define kvm_trace_symbol_emul_flags                      \
+       { 0,                        "real" },             \
+       { KVM_EMUL_INSN_F_CR0_PE                          \
+         | KVM_EMUL_INSN_F_EFL_VM, "vm16" },             \
+       { KVM_EMUL_INSN_F_CR0_PE,   "prot16" },           \
+       { KVM_EMUL_INSN_F_CR0_PE                          \
+         | KVM_EMUL_INSN_F_CS_D,   "prot32" },           \
+       { KVM_EMUL_INSN_F_CR0_PE                          \
+         | KVM_EMUL_INSN_F_CS_L,   "prot64" }
+
+#define kei_decode_mode(mode) ({                       \
+       u8 flags = 0xff;                                \
+       switch (mode) {                                 \
+       case X86EMUL_MODE_REAL:                         \
+               flags = 0;                              \
+               break;                                  \
+       case X86EMUL_MODE_VM86:                         \
+               flags = KVM_EMUL_INSN_F_EFL_VM;         \
+               break;                                  \
+       case X86EMUL_MODE_PROT16:                       \
+               flags = KVM_EMUL_INSN_F_CR0_PE;         \
+               break;                                  \
+       case X86EMUL_MODE_PROT32:                       \
+               flags = KVM_EMUL_INSN_F_CR0_PE          \
+                       | KVM_EMUL_INSN_F_CS_D;         \
+               break;                                  \
+       case X86EMUL_MODE_PROT64:                       \
+               flags = KVM_EMUL_INSN_F_CR0_PE          \
+                       | KVM_EMUL_INSN_F_CS_L;         \
+               break;                                  \
+       }                                               \
+       flags;                                          \
+       })
+
+TRACE_EVENT(kvm_emulate_insn,
+       TP_PROTO(struct kvm_vcpu *vcpu, __u8 failed),
+       TP_ARGS(vcpu, failed),
+
+       TP_STRUCT__entry(
+               __field(    __u64, rip                       )
+               __field(    __u32, csbase                    )
+               __field(    __u8,  len                       )
+               __array(    __u8,  insn,    15               )
+               __field(    __u8,  flags                     )
+               __field(    __u8,  failed                    )
+               ),
+
+       TP_fast_assign(
+               tp_assign(rip, vcpu->arch.emulate_ctxt.fetch.start)
+         tp_assign(csbase, kvm_x86_ops->get_segment_base(vcpu, VCPU_SREG_CS))
+               tp_assign(len, vcpu->arch.emulate_ctxt._eip
+                              - vcpu->arch.emulate_ctxt.fetch.start)
+               tp_memcpy(insn,
+                      vcpu->arch.emulate_ctxt.fetch.data,
+                      15)
+               tp_assign(flags, kei_decode_mode(vcpu->arch.emulate_ctxt.mode))
+               tp_assign(failed, failed)
+               ),
+
+       TP_printk("%x:%llx:%s (%s)%s",
+                 __entry->csbase, __entry->rip,
+                 __print_hex(__entry->insn, __entry->len),
+                 __print_symbolic(__entry->flags,
+                                  kvm_trace_symbol_emul_flags),
+                 __entry->failed ? " failed" : ""
+               )
+       )
+
+#define trace_kvm_emulate_insn_start(vcpu) trace_kvm_emulate_insn(vcpu, 0)
+#define trace_kvm_emulate_insn_failed(vcpu) trace_kvm_emulate_insn(vcpu, 1)
+
+TRACE_EVENT(
+       vcpu_match_mmio,
+       TP_PROTO(gva_t gva, gpa_t gpa, bool write, bool gpa_match),
+       TP_ARGS(gva, gpa, write, gpa_match),
+
+       TP_STRUCT__entry(
+               __field(gva_t, gva)
+               __field(gpa_t, gpa)
+               __field(bool, write)
+               __field(bool, gpa_match)
+               ),
+
+       TP_fast_assign(
+               tp_assign(gva, gva)
+               tp_assign(gpa, gpa)
+               tp_assign(write, write)
+               tp_assign(gpa_match, gpa_match)
+               ),
+
+       TP_printk("gva %#lx gpa %#llx %s %s", __entry->gva, __entry->gpa,
+                 __entry->write ? "Write" : "Read",
+                 __entry->gpa_match ? "GPA" : "GVA")
+)
+
+#ifdef CONFIG_X86_64
+
+#define host_clocks                                    \
+       {VCLOCK_NONE, "none"},                          \
+       {VCLOCK_TSC,  "tsc"},                           \
+       {VCLOCK_HPET, "hpet"}                           \
+
+TRACE_EVENT(kvm_update_master_clock,
+       TP_PROTO(bool use_master_clock, unsigned int host_clock, bool offset_matched),
+       TP_ARGS(use_master_clock, host_clock, offset_matched),
+
+       TP_STRUCT__entry(
+               __field(                bool,   use_master_clock        )
+               __field(        unsigned int,   host_clock              )
+               __field(                bool,   offset_matched          )
+       ),
+
+       TP_fast_assign(
+               tp_assign(use_master_clock, use_master_clock)
+               tp_assign(host_clock, host_clock)
+               tp_assign(offset_matched, offset_matched)
+       ),
+
+       TP_printk("masterclock %d hostclock %s offsetmatched %u",
+                 __entry->use_master_clock,
+                 __print_symbolic(__entry->host_clock, host_clocks),
+                 __entry->offset_matched)
+)
+
+TRACE_EVENT(kvm_track_tsc,
+       TP_PROTO(unsigned int vcpu_id, unsigned int nr_matched,
+                unsigned int online_vcpus, bool use_master_clock,
+                unsigned int host_clock),
+       TP_ARGS(vcpu_id, nr_matched, online_vcpus, use_master_clock,
+               host_clock),
+
+       TP_STRUCT__entry(
+               __field(        unsigned int,   vcpu_id                 )
+               __field(        unsigned int,   nr_vcpus_matched_tsc    )
+               __field(        unsigned int,   online_vcpus            )
+               __field(        bool,           use_master_clock        )
+               __field(        unsigned int,   host_clock              )
+       ),
+
+       TP_fast_assign(
+               tp_assign(vcpu_id, vcpu_id)
+               tp_assign(nr_vcpus_matched_tsc, nr_matched)
+               tp_assign(online_vcpus, online_vcpus)
+               tp_assign(use_master_clock, use_master_clock)
+               tp_assign(host_clock, host_clock)
+       ),
+
+       TP_printk("vcpu_id %u masterclock %u offsetmatched %u nr_online %u"
+                 " hostclock %s",
+                 __entry->vcpu_id, __entry->use_master_clock,
+                 __entry->nr_vcpus_matched_tsc, __entry->online_vcpus,
+                 __print_symbolic(__entry->host_clock, host_clocks))
+)
+
+#endif /* CONFIG_X86_64 */
+
+#endif /* _TRACE_KVM_H */
+
+#undef TRACE_INCLUDE_PATH
+#define TRACE_INCLUDE_PATH ../instrumentation/events/lttng-module/arch/x86/kvm
+#undef TRACE_INCLUDE_FILE
+#define TRACE_INCLUDE_FILE trace
+
+/* This part must be outside protection */
+#include "../../../../../../probes/define_trace.h"
diff --git a/drivers/staging/lttng/instrumentation/events/lttng-module/asoc.h b/drivers/staging/lttng/instrumentation/events/lttng-module/asoc.h
new file mode 100644 (file)
index 0000000..672bea4
--- /dev/null
@@ -0,0 +1,422 @@
+#undef TRACE_SYSTEM
+#define TRACE_SYSTEM asoc
+
+#if !defined(_TRACE_ASOC_H) || defined(TRACE_HEADER_MULTI_READ)
+#define _TRACE_ASOC_H
+
+#include <linux/ktime.h>
+#include <linux/tracepoint.h>
+#include <linux/version.h>
+
+#define DAPM_DIRECT "(direct)"
+
+#ifndef _TRACE_ASOC_DEF
+#define _TRACE_ASOC_DEF
+struct snd_soc_jack;
+struct snd_soc_codec;
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,1,0))
+struct snd_soc_platform;
+#endif
+struct snd_soc_card;
+struct snd_soc_dapm_widget;
+#endif
+
+/*
+ * Log register events
+ */
+DECLARE_EVENT_CLASS(snd_soc_reg,
+
+       TP_PROTO(struct snd_soc_codec *codec, unsigned int reg,
+                unsigned int val),
+
+       TP_ARGS(codec, reg, val),
+
+       TP_STRUCT__entry(
+               __string(       name,           codec->name     )
+               __field(        int,            id              )
+               __field(        unsigned int,   reg             )
+               __field(        unsigned int,   val             )
+       ),
+
+       TP_fast_assign(
+               tp_strcpy(name, codec->name)
+               tp_assign(id, codec->id)
+               tp_assign(reg, reg)
+               tp_assign(val, val)
+       ),
+
+       TP_printk("codec=%s.%d reg=%x val=%x", __get_str(name),
+                 (int)__entry->id, (unsigned int)__entry->reg,
+                 (unsigned int)__entry->val)
+)
+
+DEFINE_EVENT(snd_soc_reg, snd_soc_reg_write,
+
+       TP_PROTO(struct snd_soc_codec *codec, unsigned int reg,
+                unsigned int val),
+
+       TP_ARGS(codec, reg, val)
+
+)
+
+DEFINE_EVENT(snd_soc_reg, snd_soc_reg_read,
+
+       TP_PROTO(struct snd_soc_codec *codec, unsigned int reg,
+                unsigned int val),
+
+       TP_ARGS(codec, reg, val)
+
+)
+
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,1,0))
+DECLARE_EVENT_CLASS(snd_soc_preg,
+
+       TP_PROTO(struct snd_soc_platform *platform, unsigned int reg,
+                unsigned int val),
+
+       TP_ARGS(platform, reg, val),
+
+       TP_STRUCT__entry(
+               __string(       name,           platform->name  )
+               __field(        int,            id              )
+               __field(        unsigned int,   reg             )
+               __field(        unsigned int,   val             )
+       ),
+
+       TP_fast_assign(
+               tp_strcpy(name, platform->name)
+               tp_assign(id, platform->id)
+               tp_assign(reg, reg)
+               tp_assign(val, val)
+       ),
+
+       TP_printk("platform=%s.%d reg=%x val=%x", __get_str(name),
+                 (int)__entry->id, (unsigned int)__entry->reg,
+                 (unsigned int)__entry->val)
+)
+
+DEFINE_EVENT(snd_soc_preg, snd_soc_preg_write,
+
+       TP_PROTO(struct snd_soc_platform *platform, unsigned int reg,
+                unsigned int val),
+
+       TP_ARGS(platform, reg, val)
+
+)
+
+DEFINE_EVENT(snd_soc_preg, snd_soc_preg_read,
+
+       TP_PROTO(struct snd_soc_platform *platform, unsigned int reg,
+                unsigned int val),
+
+       TP_ARGS(platform, reg, val)
+
+)
+#endif
+
+DECLARE_EVENT_CLASS(snd_soc_card,
+
+       TP_PROTO(struct snd_soc_card *card, int val),
+
+       TP_ARGS(card, val),
+
+       TP_STRUCT__entry(
+               __string(       name,           card->name      )
+               __field(        int,            val             )
+       ),
+
+       TP_fast_assign(
+               tp_strcpy(name, card->name)
+               tp_assign(val, val)
+       ),
+
+       TP_printk("card=%s val=%d", __get_str(name), (int)__entry->val)
+)
+
+DEFINE_EVENT(snd_soc_card, snd_soc_bias_level_start,
+
+       TP_PROTO(struct snd_soc_card *card, int val),
+
+       TP_ARGS(card, val)
+
+)
+
+DEFINE_EVENT(snd_soc_card, snd_soc_bias_level_done,
+
+       TP_PROTO(struct snd_soc_card *card, int val),
+
+       TP_ARGS(card, val)
+
+)
+
+DECLARE_EVENT_CLASS(snd_soc_dapm_basic,
+
+       TP_PROTO(struct snd_soc_card *card),
+
+       TP_ARGS(card),
+
+       TP_STRUCT__entry(
+               __string(       name,   card->name      )
+       ),
+
+       TP_fast_assign(
+               tp_strcpy(name, card->name)
+       ),
+
+       TP_printk("card=%s", __get_str(name))
+)
+
+DEFINE_EVENT(snd_soc_dapm_basic, snd_soc_dapm_start,
+
+       TP_PROTO(struct snd_soc_card *card),
+
+       TP_ARGS(card)
+
+)
+
+DEFINE_EVENT(snd_soc_dapm_basic, snd_soc_dapm_done,
+
+       TP_PROTO(struct snd_soc_card *card),
+
+       TP_ARGS(card)
+
+)
+
+DECLARE_EVENT_CLASS(snd_soc_dapm_widget,
+
+       TP_PROTO(struct snd_soc_dapm_widget *w, int val),
+
+       TP_ARGS(w, val),
+
+       TP_STRUCT__entry(
+               __string(       name,   w->name         )
+               __field(        int,    val             )
+       ),
+
+       TP_fast_assign(
+               tp_strcpy(name, w->name)
+               tp_assign(val, val)
+       ),
+
+       TP_printk("widget=%s val=%d", __get_str(name),
+                 (int)__entry->val)
+)
+
+DEFINE_EVENT(snd_soc_dapm_widget, snd_soc_dapm_widget_power,
+
+       TP_PROTO(struct snd_soc_dapm_widget *w, int val),
+
+       TP_ARGS(w, val)
+
+)
+
+DEFINE_EVENT(snd_soc_dapm_widget, snd_soc_dapm_widget_event_start,
+
+       TP_PROTO(struct snd_soc_dapm_widget *w, int val),
+
+       TP_ARGS(w, val)
+
+)
+
+DEFINE_EVENT(snd_soc_dapm_widget, snd_soc_dapm_widget_event_done,
+
+       TP_PROTO(struct snd_soc_dapm_widget *w, int val),
+
+       TP_ARGS(w, val)
+
+)
+
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,2,0))
+TRACE_EVENT(snd_soc_dapm_walk_done,
+
+       TP_PROTO(struct snd_soc_card *card),
+
+       TP_ARGS(card),
+
+       TP_STRUCT__entry(
+               __string(       name,   card->name              )
+               __field(        int,    power_checks            )
+               __field(        int,    path_checks             )
+               __field(        int,    neighbour_checks        )
+       ),
+
+       TP_fast_assign(
+               tp_strcpy(name, card->name)
+               tp_assign(power_checks, card->dapm_stats.power_checks)
+               tp_assign(path_checks, card->dapm_stats.path_checks)
+               tp_assign(neighbour_checks, card->dapm_stats.neighbour_checks)
+       ),
+
+       TP_printk("%s: checks %d power, %d path, %d neighbour",
+                 __get_str(name), (int)__entry->power_checks,
+                 (int)__entry->path_checks, (int)__entry->neighbour_checks)
+)
+#endif
+
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,5,0))
+TRACE_EVENT(snd_soc_dapm_output_path,
+
+       TP_PROTO(struct snd_soc_dapm_widget *widget,
+               struct snd_soc_dapm_path *path),
+
+       TP_ARGS(widget, path),
+
+       TP_STRUCT__entry(
+               __string(       wname,  widget->name            )
+               __string(       pname,  path->name ? path->name : DAPM_DIRECT)
+               __string(       psname, path->sink->name        )
+               __field(        int,    path_sink               )
+               __field(        int,    path_connect            )
+       ),
+
+       TP_fast_assign(
+               tp_strcpy(wname, widget->name)
+               tp_strcpy(pname, path->name ? path->name : DAPM_DIRECT)
+               tp_strcpy(psname, path->sink->name)
+               tp_assign(path_connect, path->connect)
+               tp_assign(path_sink, (long)path->sink)
+       ),
+
+       TP_printk("%c%s -> %s -> %s\n",
+               (int) __entry->path_sink &&
+               (int) __entry->path_connect ? '*' : ' ',
+               __get_str(wname), __get_str(pname), __get_str(psname))
+)
+
+TRACE_EVENT(snd_soc_dapm_input_path,
+
+       TP_PROTO(struct snd_soc_dapm_widget *widget,
+               struct snd_soc_dapm_path *path),
+
+       TP_ARGS(widget, path),
+
+       TP_STRUCT__entry(
+               __string(       wname,  widget->name            )
+               __string(       pname,  path->name ? path->name : DAPM_DIRECT)
+               __string(       psname, path->source->name      )
+               __field(        int,    path_source             )
+               __field(        int,    path_connect            )
+       ),
+
+       TP_fast_assign(
+               tp_strcpy(wname, widget->name)
+               tp_strcpy(pname, path->name ? path->name : DAPM_DIRECT)
+               tp_strcpy(psname, path->source->name)
+               tp_assign(path_connect, path->connect)
+               tp_assign(path_source, (long)path->source)
+       ),
+
+       TP_printk("%c%s <- %s <- %s\n",
+               (int) __entry->path_source &&
+               (int) __entry->path_connect ? '*' : ' ',
+               __get_str(wname), __get_str(pname), __get_str(psname))
+)
+
+TRACE_EVENT(snd_soc_dapm_connected,
+
+       TP_PROTO(int paths, int stream),
+
+       TP_ARGS(paths, stream),
+
+       TP_STRUCT__entry(
+               __field(        int,    paths           )
+               __field(        int,    stream          )
+       ),
+
+       TP_fast_assign(
+               tp_assign(paths, paths)
+               tp_assign(stream, stream)
+       ),
+
+       TP_printk("%s: found %d paths\n",
+               __entry->stream ? "capture" : "playback", __entry->paths)
+)
+#endif
+
+TRACE_EVENT(snd_soc_jack_irq,
+
+       TP_PROTO(const char *name),
+
+       TP_ARGS(name),
+
+       TP_STRUCT__entry(
+               __string(       name,   name            )
+       ),
+
+       TP_fast_assign(
+               tp_strcpy(name, name)
+       ),
+
+       TP_printk("%s", __get_str(name))
+)
+
+TRACE_EVENT(snd_soc_jack_report,
+
+       TP_PROTO(struct snd_soc_jack *jack, int mask, int val),
+
+       TP_ARGS(jack, mask, val),
+
+       TP_STRUCT__entry(
+               __string(       name,           jack->jack->name        )
+               __field(        int,            mask                    )
+               __field(        int,            val                     )
+       ),
+
+       TP_fast_assign(
+               tp_strcpy(name, jack->jack->name)
+               tp_assign(mask, mask)
+               tp_assign(val, val)
+       ),
+
+       TP_printk("jack=%s %x/%x", __get_str(name), (int)__entry->val,
+                 (int)__entry->mask)
+)
+
+TRACE_EVENT(snd_soc_jack_notify,
+
+       TP_PROTO(struct snd_soc_jack *jack, int val),
+
+       TP_ARGS(jack, val),
+
+       TP_STRUCT__entry(
+               __string(       name,           jack->jack->name        )
+               __field(        int,            val                     )
+       ),
+
+       TP_fast_assign(
+               tp_strcpy(name, jack->jack->name)
+               tp_assign(val, val)
+       ),
+
+       TP_printk("jack=%s %x", __get_str(name), (int)__entry->val)
+)
+
+TRACE_EVENT(snd_soc_cache_sync,
+
+       TP_PROTO(struct snd_soc_codec *codec, const char *type,
+                const char *status),
+
+       TP_ARGS(codec, type, status),
+
+       TP_STRUCT__entry(
+               __string(       name,           codec->name     )
+               __string(       status,         status          )
+               __string(       type,           type            )
+               __field(        int,            id              )
+       ),
+
+       TP_fast_assign(
+               tp_strcpy(name, codec->name)
+               tp_strcpy(status, status)
+               tp_strcpy(type, type)
+               tp_assign(id, codec->id)
+       ),
+
+       TP_printk("codec=%s.%d type=%s status=%s", __get_str(name),
+                 (int)__entry->id, __get_str(type), __get_str(status))
+)
+
+#endif /* _TRACE_ASOC_H */
+
+/* This part must be outside protection */
+#include "../../../probes/define_trace.h"
diff --git a/drivers/staging/lttng/instrumentation/events/lttng-module/block.h b/drivers/staging/lttng/instrumentation/events/lttng-module/block.h
new file mode 100644 (file)
index 0000000..f3b8bff
--- /dev/null
@@ -0,0 +1,878 @@
+#undef TRACE_SYSTEM
+#define TRACE_SYSTEM block
+
+#if !defined(_TRACE_BLOCK_H) || defined(TRACE_HEADER_MULTI_READ)
+#define _TRACE_BLOCK_H
+
+#include <linux/blktrace_api.h>
+#include <linux/blkdev.h>
+#include <linux/tracepoint.h>
+#include <linux/trace_seq.h>
+#include <linux/version.h>
+
+#define RWBS_LEN       8
+
+#ifndef _TRACE_BLOCK_DEF_
+#define _TRACE_BLOCK_DEF_
+
+#define __blk_dump_cmd(cmd, len)       "<unknown>"
+
+enum {
+       RWBS_FLAG_WRITE         = (1 << 0),
+       RWBS_FLAG_DISCARD       = (1 << 1),
+       RWBS_FLAG_READ          = (1 << 2),
+       RWBS_FLAG_RAHEAD        = (1 << 3),
+       RWBS_FLAG_BARRIER       = (1 << 4),
+       RWBS_FLAG_SYNC          = (1 << 5),
+       RWBS_FLAG_META          = (1 << 6),
+       RWBS_FLAG_SECURE        = (1 << 7),
+       RWBS_FLAG_FLUSH         = (1 << 8),
+       RWBS_FLAG_FUA           = (1 << 9),
+};
+
+#endif /* _TRACE_BLOCK_DEF_ */
+
+#define __print_rwbs_flags(rwbs)               \
+       __print_flags(rwbs, "",                 \
+               { RWBS_FLAG_FLUSH, "F" },       \
+               { RWBS_FLAG_WRITE, "W" },       \
+               { RWBS_FLAG_DISCARD, "D" },     \
+               { RWBS_FLAG_READ, "R" },        \
+               { RWBS_FLAG_FUA, "F" },         \
+               { RWBS_FLAG_RAHEAD, "A" },      \
+               { RWBS_FLAG_BARRIER, "B" },     \
+               { RWBS_FLAG_SYNC, "S" },        \
+               { RWBS_FLAG_META, "M" },        \
+               { RWBS_FLAG_SECURE, "E" })
+
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,1,0))
+
+#define blk_fill_rwbs(rwbs, rw, bytes)                                       \
+               tp_assign(rwbs, ((rw) & WRITE ? RWBS_FLAG_WRITE :             \
+                       ( (rw) & REQ_DISCARD ? RWBS_FLAG_DISCARD :            \
+                       ( (bytes) ? RWBS_FLAG_READ :                          \
+                       ( 0 ))))                                              \
+                       | ((rw) & REQ_RAHEAD ? RWBS_FLAG_RAHEAD : 0)          \
+                       | ((rw) & REQ_SYNC ? RWBS_FLAG_SYNC : 0)              \
+                       | ((rw) & REQ_META ? RWBS_FLAG_META : 0)              \
+                       | ((rw) & REQ_SECURE ? RWBS_FLAG_SECURE : 0)          \
+                       | ((rw) & REQ_FLUSH ? RWBS_FLAG_FLUSH : 0)            \
+                       | ((rw) & REQ_FUA ? RWBS_FLAG_FUA : 0))
+
+#elif (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,37))
+
+#define blk_fill_rwbs(rwbs, rw, bytes)                                       \
+               tp_assign(rwbs, ((rw) & WRITE ? RWBS_FLAG_WRITE :             \
+                       ( (rw) & REQ_DISCARD ? RWBS_FLAG_DISCARD :            \
+                       ( (bytes) ? RWBS_FLAG_READ :                          \
+                       ( 0 ))))                                              \
+                       | ((rw) & REQ_RAHEAD ? RWBS_FLAG_RAHEAD : 0)          \
+                       | ((rw) & REQ_SYNC ? RWBS_FLAG_SYNC : 0)              \
+                       | ((rw) & REQ_META ? RWBS_FLAG_META : 0)              \
+                       | ((rw) & REQ_SECURE ? RWBS_FLAG_SECURE : 0))
+
+#elif (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,36))
+
+#define blk_fill_rwbs(rwbs, rw, bytes)                                       \
+               tp_assign(rwbs, ((rw) & WRITE ? RWBS_FLAG_WRITE :             \
+                       ( (rw) & REQ_DISCARD ? RWBS_FLAG_DISCARD :            \
+                       ( (bytes) ? RWBS_FLAG_READ :                          \
+                       ( 0 ))))                                              \
+                       | ((rw) & REQ_RAHEAD ? RWBS_FLAG_RAHEAD : 0)          \
+                       | ((rw) & REQ_HARDBARRIER ? RWBS_FLAG_BARRIER : 0)    \
+                       | ((rw) & REQ_SYNC ? RWBS_FLAG_SYNC : 0)              \
+                       | ((rw) & REQ_META ? RWBS_FLAG_META : 0)              \
+                       | ((rw) & REQ_SECURE ? RWBS_FLAG_SECURE : 0))
+
+#else
+
+#define blk_fill_rwbs(rwbs, rw, bytes)                                       \
+               tp_assign(rwbs, ((rw) & WRITE ? RWBS_FLAG_WRITE :             \
+                       ( (rw) & (1 << BIO_RW_DISCARD) ? RWBS_FLAG_DISCARD :  \
+                       ( (bytes) ? RWBS_FLAG_READ :                          \
+                       ( 0 ))))                                              \
+                       | ((rw) & (1 << BIO_RW_AHEAD) ? RWBS_FLAG_RAHEAD : 0) \
+                       | ((rw) & (1 << BIO_RW_SYNCIO) ? RWBS_FLAG_SYNC : 0)  \
+                       | ((rw) & (1 << BIO_RW_META) ? RWBS_FLAG_META : 0)    \
+                       | ((rw) & (1 << BIO_RW_BARRIER) ? RWBS_FLAG_BARRIER : 0))
+
+#endif
+
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,9,0))
+DECLARE_EVENT_CLASS(block_buffer,
+
+       TP_PROTO(struct buffer_head *bh),
+
+       TP_ARGS(bh),
+
+       TP_STRUCT__entry (
+               __field(  dev_t,        dev                     )
+               __field(  sector_t,     sector                  )
+               __field(  size_t,       size                    )
+       ),
+
+       TP_fast_assign(
+               tp_assign(dev, bh->b_bdev->bd_dev)
+               tp_assign(sector, bh->b_blocknr)
+               tp_assign(size, bh->b_size)
+       ),
+
+       TP_printk("%d,%d sector=%llu size=%zu",
+               MAJOR(__entry->dev), MINOR(__entry->dev),
+               (unsigned long long)__entry->sector, __entry->size
+       )
+)
+
+/**
+ * block_touch_buffer - mark a buffer accessed
+ * @bh: buffer_head being touched
+ *
+ * Called from touch_buffer().
+ */
+DEFINE_EVENT(block_buffer, block_touch_buffer,
+
+       TP_PROTO(struct buffer_head *bh),
+
+       TP_ARGS(bh)
+)
+
+/**
+ * block_dirty_buffer - mark a buffer dirty
+ * @bh: buffer_head being dirtied
+ *
+ * Called from mark_buffer_dirty().
+ */
+DEFINE_EVENT(block_buffer, block_dirty_buffer,
+
+       TP_PROTO(struct buffer_head *bh),
+
+       TP_ARGS(bh)
+)
+#endif
+
+DECLARE_EVENT_CLASS(block_rq_with_error,
+
+       TP_PROTO(struct request_queue *q, struct request *rq),
+
+       TP_ARGS(q, rq),
+
+       TP_STRUCT__entry(
+               __field(  dev_t,        dev                     )
+               __field(  sector_t,     sector                  )
+               __field(  unsigned int, nr_sector               )
+               __field(  int,          errors                  )
+               __field(  unsigned int, rwbs                    )
+               __dynamic_array_hex( unsigned char,     cmd,
+                       (rq->cmd_type == REQ_TYPE_BLOCK_PC) ?
+                               rq->cmd_len : 0)
+       ),
+
+       TP_fast_assign(
+               tp_assign(dev, rq->rq_disk ? disk_devt(rq->rq_disk) : 0)
+               tp_assign(sector, (rq->cmd_type == REQ_TYPE_BLOCK_PC) ?
+                                       0 : blk_rq_pos(rq))
+               tp_assign(nr_sector, (rq->cmd_type == REQ_TYPE_BLOCK_PC) ?
+                                       0 : blk_rq_sectors(rq))
+               tp_assign(errors, rq->errors)
+               blk_fill_rwbs(rwbs, rq->cmd_flags, blk_rq_bytes(rq))
+               tp_memcpy_dyn(cmd, (rq->cmd_type == REQ_TYPE_BLOCK_PC) ?
+                                       rq->cmd : NULL)
+       ),
+
+       TP_printk("%d,%d %s (%s) %llu + %u [%d]",
+                 MAJOR(__entry->dev), MINOR(__entry->dev),
+                 __print_rwbs_flags(__entry->rwbs),
+                 __blk_dump_cmd(__get_dynamic_array(cmd),
+                                __get_dynamic_array_len(cmd)),
+                 (unsigned long long)__entry->sector,
+                 __entry->nr_sector, __entry->errors)
+)
+
+/**
+ * block_rq_abort - abort block operation request
+ * @q: queue containing the block operation request
+ * @rq: block IO operation request
+ *
+ * Called immediately after pending block IO operation request @rq in
+ * queue @q is aborted. The fields in the operation request @rq
+ * can be examined to determine which device and sectors the pending
+ * operation would access.
+ */
+DEFINE_EVENT(block_rq_with_error, block_rq_abort,
+
+       TP_PROTO(struct request_queue *q, struct request *rq),
+
+       TP_ARGS(q, rq)
+)
+
+/**
+ * block_rq_requeue - place block IO request back on a queue
+ * @q: queue holding operation
+ * @rq: block IO operation request
+ *
+ * The block operation request @rq is being placed back into queue
+ * @q.  For some reason the request was not completed and needs to be
+ * put back in the queue.
+ */
+DEFINE_EVENT(block_rq_with_error, block_rq_requeue,
+
+       TP_PROTO(struct request_queue *q, struct request *rq),
+
+       TP_ARGS(q, rq)
+)
+
+/**
+ * block_rq_complete - block IO operation completed by device driver
+ * @q: queue containing the block operation request
+ * @rq: block operations request
+ *
+ * The block_rq_complete tracepoint event indicates that some portion
+ * of operation request has been completed by the device driver.  If
+ * the @rq->bio is %NULL, then there is absolutely no additional work to
+ * do for the request. If @rq->bio is non-NULL then there is
+ * additional work required to complete the request.
+ */
+DEFINE_EVENT(block_rq_with_error, block_rq_complete,
+
+       TP_PROTO(struct request_queue *q, struct request *rq),
+
+       TP_ARGS(q, rq)
+)
+
+DECLARE_EVENT_CLASS(block_rq,
+
+       TP_PROTO(struct request_queue *q, struct request *rq),
+
+       TP_ARGS(q, rq),
+
+       TP_STRUCT__entry(
+               __field(  dev_t,        dev                     )
+               __field(  sector_t,     sector                  )
+               __field(  unsigned int, nr_sector               )
+               __field(  unsigned int, bytes                   )
+               __field(  unsigned int, rwbs                    )
+               __array_text(  char,         comm,   TASK_COMM_LEN   )
+               __dynamic_array_hex( unsigned char,     cmd,
+                       (rq->cmd_type == REQ_TYPE_BLOCK_PC) ?
+                               rq->cmd_len : 0)
+       ),
+
+       TP_fast_assign(
+               tp_assign(dev, rq->rq_disk ? disk_devt(rq->rq_disk) : 0)
+               tp_assign(sector, (rq->cmd_type == REQ_TYPE_BLOCK_PC) ?
+                                       0 : blk_rq_pos(rq))
+               tp_assign(nr_sector, (rq->cmd_type == REQ_TYPE_BLOCK_PC) ?
+                                       0 : blk_rq_sectors(rq))
+               tp_assign(bytes, (rq->cmd_type == REQ_TYPE_BLOCK_PC) ?
+                                       blk_rq_bytes(rq) : 0)
+               blk_fill_rwbs(rwbs, rq->cmd_flags, blk_rq_bytes(rq))
+               tp_memcpy_dyn(cmd, (rq->cmd_type == REQ_TYPE_BLOCK_PC) ?
+                                       rq->cmd : NULL)
+               tp_memcpy(comm, current->comm, TASK_COMM_LEN)
+       ),
+
+       TP_printk("%d,%d %s %u (%s) %llu + %u [%s]",
+                 MAJOR(__entry->dev), MINOR(__entry->dev),
+                 __print_rwbs_flags(__entry->rwbs),
+                 __entry->bytes,
+                 __blk_dump_cmd(__get_dynamic_array(cmd),
+                                __get_dynamic_array_len(cmd)),
+                 (unsigned long long)__entry->sector,
+                 __entry->nr_sector, __entry->comm)
+)
+
+/**
+ * block_rq_insert - insert block operation request into queue
+ * @q: target queue
+ * @rq: block IO operation request
+ *
+ * Called immediately before block operation request @rq is inserted
+ * into queue @q.  The fields in the operation request @rq struct can
+ * be examined to determine which device and sectors the pending
+ * operation would access.
+ */
+DEFINE_EVENT(block_rq, block_rq_insert,
+
+       TP_PROTO(struct request_queue *q, struct request *rq),
+
+       TP_ARGS(q, rq)
+)
+
+/**
+ * block_rq_issue - issue pending block IO request operation to device driver
+ * @q: queue holding operation
+ * @rq: block IO operation operation request
+ *
+ * Called when block operation request @rq from queue @q is sent to a
+ * device driver for processing.
+ */
+DEFINE_EVENT(block_rq, block_rq_issue,
+
+       TP_PROTO(struct request_queue *q, struct request *rq),
+
+       TP_ARGS(q, rq)
+)
+
+/**
+ * block_bio_bounce - used bounce buffer when processing block operation
+ * @q: queue holding the block operation
+ * @bio: block operation
+ *
+ * A bounce buffer was used to handle the block operation @bio in @q.
+ * This occurs when hardware limitations prevent a direct transfer of
+ * data between the @bio data memory area and the IO device.  Use of a
+ * bounce buffer requires extra copying of data and decreases
+ * performance.
+ */
+TRACE_EVENT(block_bio_bounce,
+
+       TP_PROTO(struct request_queue *q, struct bio *bio),
+
+       TP_ARGS(q, bio),
+
+       TP_STRUCT__entry(
+               __field( dev_t,         dev                     )
+               __field( sector_t,      sector                  )
+               __field( unsigned int,  nr_sector               )
+               __field( unsigned int,  rwbs                    )
+               __array_text( char,             comm,   TASK_COMM_LEN   )
+       ),
+
+       TP_fast_assign(
+               tp_assign(dev, bio->bi_bdev ?
+                                         bio->bi_bdev->bd_dev : 0)
+               tp_assign(sector, bio->bi_sector)
+               tp_assign(nr_sector, bio->bi_size >> 9)
+               blk_fill_rwbs(rwbs, bio->bi_rw, bio->bi_size)
+               tp_memcpy(comm, current->comm, TASK_COMM_LEN)
+       ),
+
+       TP_printk("%d,%d %s %llu + %u [%s]",
+                 MAJOR(__entry->dev), MINOR(__entry->dev),
+                 __print_rwbs_flags(__entry->rwbs),
+                 (unsigned long long)__entry->sector,
+                 __entry->nr_sector, __entry->comm)
+)
+
+/**
+ * block_bio_complete - completed all work on the block operation
+ * @q: queue holding the block operation
+ * @bio: block operation completed
+ * @error: io error value
+ *
+ * This tracepoint indicates there is no further work to do on this
+ * block IO operation @bio.
+ */
+TRACE_EVENT(block_bio_complete,
+
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
+       TP_PROTO(struct request_queue *q, struct bio *bio, int error),
+
+       TP_ARGS(q, bio, error),
+#else
+       TP_PROTO(struct request_queue *q, struct bio *bio),
+
+       TP_ARGS(q, bio),
+#endif
+
+       TP_STRUCT__entry(
+               __field( dev_t,         dev             )
+               __field( sector_t,      sector          )
+               __field( unsigned,      nr_sector       )
+               __field( int,           error           )
+               __field( unsigned int,  rwbs            )
+       ),
+
+       TP_fast_assign(
+               tp_assign(dev, bio->bi_bdev->bd_dev)
+               tp_assign(sector, bio->bi_sector)
+               tp_assign(nr_sector, bio->bi_size >> 9)
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
+               tp_assign(error, error)
+#else
+               tp_assign(error, 0)
+#endif
+               blk_fill_rwbs(rwbs, bio->bi_rw, bio->bi_size)
+       ),
+
+       TP_printk("%d,%d %s %llu + %u [%d]",
+                 MAJOR(__entry->dev), MINOR(__entry->dev),
+                 __print_rwbs_flags(__entry->rwbs),
+                 (unsigned long long)__entry->sector,
+                 __entry->nr_sector, __entry->error)
+)
+
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,9,0))
+DECLARE_EVENT_CLASS(block_bio_merge,
+
+       TP_PROTO(struct request_queue *q, struct request *rq, struct bio *bio),
+
+       TP_ARGS(q, rq, bio),
+
+       TP_STRUCT__entry(
+               __field( dev_t,         dev                     )
+               __field( sector_t,      sector                  )
+               __field( unsigned int,  nr_sector               )
+               __field( unsigned int,  rwbs                    )
+               __array_text( char,             comm,   TASK_COMM_LEN   )
+       ),
+
+       TP_fast_assign(
+               tp_assign(dev, bio->bi_bdev->bd_dev)
+               tp_assign(sector, bio->bi_sector)
+               tp_assign(nr_sector, bio->bi_size >> 9)
+               blk_fill_rwbs(rwbs, bio->bi_rw, bio->bi_size)
+               tp_memcpy(comm, current->comm, TASK_COMM_LEN)
+       ),
+
+       TP_printk("%d,%d %s %llu + %u [%s]",
+                 MAJOR(__entry->dev), MINOR(__entry->dev),
+                 __print_rwbs_flags(__entry->rwbs),
+                 (unsigned long long)__entry->sector,
+                 __entry->nr_sector, __entry->comm)
+)
+
+/**
+ * block_bio_backmerge - merging block operation to the end of an existing operation
+ * @q: queue holding operation
+ * @bio: new block operation to merge
+ *
+ * Merging block request @bio to the end of an existing block request
+ * in queue @q.
+ */
+DEFINE_EVENT(block_bio_merge, block_bio_backmerge,
+
+       TP_PROTO(struct request_queue *q, struct request *rq, struct bio *bio),
+
+       TP_ARGS(q, rq, bio)
+)
+
+/**
+ * block_bio_frontmerge - merging block operation to the beginning of an existing operation
+ * @q: queue holding operation
+ * @bio: new block operation to merge
+ *
+ * Merging block IO operation @bio to the beginning of an existing block
+ * operation in queue @q.
+ */
+DEFINE_EVENT(block_bio_merge, block_bio_frontmerge,
+
+       TP_PROTO(struct request_queue *q, struct request *rq, struct bio *bio),
+
+       TP_ARGS(q, rq, bio)
+)
+
+/**
+ * block_bio_queue - putting new block IO operation in queue
+ * @q: queue holding operation
+ * @bio: new block operation
+ *
+ * About to place the block IO operation @bio into queue @q.
+ */
+TRACE_EVENT(block_bio_queue,
+
+       TP_PROTO(struct request_queue *q, struct bio *bio),
+
+       TP_ARGS(q, bio),
+
+       TP_STRUCT__entry(
+               __field( dev_t,         dev                     )
+               __field( sector_t,      sector                  )
+               __field( unsigned int,  nr_sector               )
+               __array( char,          rwbs,   RWBS_LEN        )
+               __array( char,          comm,   TASK_COMM_LEN   )
+       ),
+
+       TP_fast_assign(
+               tp_assign(dev, bio->bi_bdev->bd_dev)
+               tp_assign(sector, bio->bi_sector)
+               tp_assign(nr_sector, bio->bi_size >> 9)
+               blk_fill_rwbs(rwbs, bio->bi_rw, bio->bi_size)
+               tp_memcpy(comm, current->comm, TASK_COMM_LEN)
+       ),
+
+       TP_printk("%d,%d %s %llu + %u [%s]",
+                 MAJOR(__entry->dev), MINOR(__entry->dev), __entry->rwbs,
+                 (unsigned long long)__entry->sector,
+                 __entry->nr_sector, __entry->comm)
+)
+#else
+DECLARE_EVENT_CLASS(block_bio,
+
+       TP_PROTO(struct request_queue *q, struct bio *bio),
+
+       TP_ARGS(q, bio),
+
+       TP_STRUCT__entry(
+               __field( dev_t,         dev                     )
+               __field( sector_t,      sector                  )
+               __field( unsigned int,  nr_sector               )
+               __field( unsigned int,  rwbs                    )
+               __array_text( char,             comm,   TASK_COMM_LEN   )
+       ),
+
+       TP_fast_assign(
+               tp_assign(dev, bio->bi_bdev ? bio->bi_bdev->bd_dev : 0)
+               tp_assign(sector, bio->bi_sector)
+               tp_assign(nr_sector, bio->bi_size >> 9)
+               blk_fill_rwbs(rwbs, bio->bi_rw, bio->bi_size)
+               tp_memcpy(comm, current->comm, TASK_COMM_LEN)
+       ),
+
+       TP_printk("%d,%d %s %llu + %u [%s]",
+                 MAJOR(__entry->dev), MINOR(__entry->dev),
+                 __print_rwbs_flags(__entry->rwbs),
+                 (unsigned long long)__entry->sector,
+                 __entry->nr_sector, __entry->comm)
+)
+
+/**
+ * block_bio_backmerge - merging block operation to the end of an existing operation
+ * @q: queue holding operation
+ * @bio: new block operation to merge
+ *
+ * Merging block request @bio to the end of an existing block request
+ * in queue @q.
+ */
+DEFINE_EVENT(block_bio, block_bio_backmerge,
+
+       TP_PROTO(struct request_queue *q, struct bio *bio),
+
+       TP_ARGS(q, bio)
+)
+
+/**
+ * block_bio_frontmerge - merging block operation to the beginning of an existing operation
+ * @q: queue holding operation
+ * @bio: new block operation to merge
+ *
+ * Merging block IO operation @bio to the beginning of an existing block
+ * operation in queue @q.
+ */
+DEFINE_EVENT(block_bio, block_bio_frontmerge,
+
+       TP_PROTO(struct request_queue *q, struct bio *bio),
+
+       TP_ARGS(q, bio)
+)
+
+/**
+ * block_bio_queue - putting new block IO operation in queue
+ * @q: queue holding operation
+ * @bio: new block operation
+ *
+ * About to place the block IO operation @bio into queue @q.
+ */
+DEFINE_EVENT(block_bio, block_bio_queue,
+
+       TP_PROTO(struct request_queue *q, struct bio *bio),
+
+       TP_ARGS(q, bio)
+)
+#endif
+
+DECLARE_EVENT_CLASS(block_get_rq,
+
+       TP_PROTO(struct request_queue *q, struct bio *bio, int rw),
+
+       TP_ARGS(q, bio, rw),
+
+       TP_STRUCT__entry(
+               __field( dev_t,         dev                     )
+               __field( sector_t,      sector                  )
+               __field( unsigned int,  nr_sector               )
+               __field( unsigned int,  rwbs                    )
+               __array_text( char,             comm,   TASK_COMM_LEN   )
+        ),
+
+       TP_fast_assign(
+               tp_assign(dev, bio ? bio->bi_bdev->bd_dev : 0)
+               tp_assign(sector, bio ? bio->bi_sector : 0)
+               tp_assign(nr_sector, bio ? bio->bi_size >> 9 : 0)
+               blk_fill_rwbs(rwbs, bio ? bio->bi_rw : 0,
+                             bio ? bio->bi_size >> 9 : 0)
+               tp_memcpy(comm, current->comm, TASK_COMM_LEN)
+        ),
+
+       TP_printk("%d,%d %s %llu + %u [%s]",
+                 MAJOR(__entry->dev), MINOR(__entry->dev),
+                 __print_rwbs_flags(__entry->rwbs),
+                 (unsigned long long)__entry->sector,
+                 __entry->nr_sector, __entry->comm)
+)
+
+/**
+ * block_getrq - get a free request entry in queue for block IO operations
+ * @q: queue for operations
+ * @bio: pending block IO operation
+ * @rw: low bit indicates a read (%0) or a write (%1)
+ *
+ * A request struct for queue @q has been allocated to handle the
+ * block IO operation @bio.
+ */
+DEFINE_EVENT(block_get_rq, block_getrq,
+
+       TP_PROTO(struct request_queue *q, struct bio *bio, int rw),
+
+       TP_ARGS(q, bio, rw)
+)
+
+/**
+ * block_sleeprq - waiting to get a free request entry in queue for block IO operation
+ * @q: queue for operation
+ * @bio: pending block IO operation
+ * @rw: low bit indicates a read (%0) or a write (%1)
+ *
+ * In the case where a request struct cannot be provided for queue @q
+ * the process needs to wait for an request struct to become
+ * available.  This tracepoint event is generated each time the
+ * process goes to sleep waiting for request struct become available.
+ */
+DEFINE_EVENT(block_get_rq, block_sleeprq,
+
+       TP_PROTO(struct request_queue *q, struct bio *bio, int rw),
+
+       TP_ARGS(q, bio, rw)
+)
+
+/**
+ * block_plug - keep operations requests in request queue
+ * @q: request queue to plug
+ *
+ * Plug the request queue @q.  Do not allow block operation requests
+ * to be sent to the device driver. Instead, accumulate requests in
+ * the queue to improve throughput performance of the block device.
+ */
+TRACE_EVENT(block_plug,
+
+       TP_PROTO(struct request_queue *q),
+
+       TP_ARGS(q),
+
+       TP_STRUCT__entry(
+               __array_text( char,             comm,   TASK_COMM_LEN   )
+       ),
+
+       TP_fast_assign(
+               tp_memcpy(comm, current->comm, TASK_COMM_LEN)
+       ),
+
+       TP_printk("[%s]", __entry->comm)
+)
+
+DECLARE_EVENT_CLASS(block_unplug,
+
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,39))
+       TP_PROTO(struct request_queue *q, unsigned int depth, bool explicit),
+
+       TP_ARGS(q, depth, explicit),
+#else
+       TP_PROTO(struct request_queue *q),
+
+       TP_ARGS(q),
+#endif
+
+       TP_STRUCT__entry(
+               __field( int,           nr_rq                   )
+               __array_text( char,             comm,   TASK_COMM_LEN   )
+       ),
+
+       TP_fast_assign(
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,39))
+               tp_assign(nr_rq, depth)
+#else
+               tp_assign(nr_rq, q->rq.count[READ] + q->rq.count[WRITE])
+#endif
+               tp_memcpy(comm, current->comm, TASK_COMM_LEN)
+       ),
+
+       TP_printk("[%s] %d", __entry->comm, __entry->nr_rq)
+)
+
+#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,39))
+/**
+ * block_unplug_timer - timed release of operations requests in queue to device driver
+ * @q: request queue to unplug
+ *
+ * Unplug the request queue @q because a timer expired and allow block
+ * operation requests to be sent to the device driver.
+ */
+DEFINE_EVENT(block_unplug, block_unplug_timer,
+
+       TP_PROTO(struct request_queue *q),
+
+       TP_ARGS(q)
+)
+#endif
+
+/**
+ * block_unplug - release of operations requests in request queue
+ * @q: request queue to unplug
+ * @depth: number of requests just added to the queue
+ * @explicit: whether this was an explicit unplug, or one from schedule()
+ *
+ * Unplug request queue @q because device driver is scheduled to work
+ * on elements in the request queue.
+ */
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,39))
+DEFINE_EVENT(block_unplug, block_unplug,
+#else
+DEFINE_EVENT(block_unplug, block_unplug_io,
+#endif
+
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,39))
+       TP_PROTO(struct request_queue *q, unsigned int depth, bool explicit),
+
+       TP_ARGS(q, depth, explicit)
+#else
+       TP_PROTO(struct request_queue *q),
+
+       TP_ARGS(q)
+#endif
+)
+
+/**
+ * block_split - split a single bio struct into two bio structs
+ * @q: queue containing the bio
+ * @bio: block operation being split
+ * @new_sector: The starting sector for the new bio
+ *
+ * The bio request @bio in request queue @q needs to be split into two
+ * bio requests. The newly created @bio request starts at
+ * @new_sector. This split may be required due to hardware limitation
+ * such as operation crossing device boundaries in a RAID system.
+ */
+TRACE_EVENT(block_split,
+
+       TP_PROTO(struct request_queue *q, struct bio *bio,
+                unsigned int new_sector),
+
+       TP_ARGS(q, bio, new_sector),
+
+       TP_STRUCT__entry(
+               __field( dev_t,         dev                             )
+               __field( sector_t,      sector                          )
+               __field( sector_t,      new_sector                      )
+               __field( unsigned int,  rwbs            )
+               __array_text( char,             comm,           TASK_COMM_LEN   )
+       ),
+
+       TP_fast_assign(
+               tp_assign(dev, bio->bi_bdev->bd_dev)
+               tp_assign(sector, bio->bi_sector)
+               tp_assign(new_sector, new_sector)
+               blk_fill_rwbs(rwbs, bio->bi_rw, bio->bi_size)
+               tp_memcpy(comm, current->comm, TASK_COMM_LEN)
+       ),
+
+       TP_printk("%d,%d %s %llu / %llu [%s]",
+                 MAJOR(__entry->dev), MINOR(__entry->dev),
+                 __print_rwbs_flags(__entry->rwbs),
+                 (unsigned long long)__entry->sector,
+                 (unsigned long long)__entry->new_sector,
+                 __entry->comm)
+)
+
+/**
+ * block_bio_remap - map request for a logical device to the raw device
+ * @q: queue holding the operation
+ * @bio: revised operation
+ * @dev: device for the operation
+ * @from: original sector for the operation
+ *
+ * An operation for a logical device has been mapped to the
+ * raw block device.
+ */
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
+TRACE_EVENT(block_bio_remap,
+#else
+TRACE_EVENT(block_remap,
+#endif
+
+       TP_PROTO(struct request_queue *q, struct bio *bio, dev_t dev,
+                sector_t from),
+
+       TP_ARGS(q, bio, dev, from),
+
+       TP_STRUCT__entry(
+               __field( dev_t,         dev             )
+               __field( sector_t,      sector          )
+               __field( unsigned int,  nr_sector       )
+               __field( dev_t,         old_dev         )
+               __field( sector_t,      old_sector      )
+               __field( unsigned int,  rwbs            )
+       ),
+
+       TP_fast_assign(
+               tp_assign(dev, bio->bi_bdev->bd_dev)
+               tp_assign(sector, bio->bi_sector)
+               tp_assign(nr_sector, bio->bi_size >> 9)
+               tp_assign(old_dev, dev)
+               tp_assign(old_sector, from)
+               blk_fill_rwbs(rwbs, bio->bi_rw, bio->bi_size)
+       ),
+
+       TP_printk("%d,%d %s %llu + %u <- (%d,%d) %llu",
+                 MAJOR(__entry->dev), MINOR(__entry->dev),
+                 __print_rwbs_flags(__entry->rwbs),
+                 (unsigned long long)__entry->sector,
+                 __entry->nr_sector,
+                 MAJOR(__entry->old_dev), MINOR(__entry->old_dev),
+                 (unsigned long long)__entry->old_sector)
+)
+
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,32))
+/**
+ * block_rq_remap - map request for a block operation request
+ * @q: queue holding the operation
+ * @rq: block IO operation request
+ * @dev: device for the operation
+ * @from: original sector for the operation
+ *
+ * The block operation request @rq in @q has been remapped.  The block
+ * operation request @rq holds the current information and @from hold
+ * the original sector.
+ */
+TRACE_EVENT(block_rq_remap,
+
+       TP_PROTO(struct request_queue *q, struct request *rq, dev_t dev,
+                sector_t from),
+
+       TP_ARGS(q, rq, dev, from),
+
+       TP_STRUCT__entry(
+               __field( dev_t,         dev             )
+               __field( sector_t,      sector          )
+               __field( unsigned int,  nr_sector       )
+               __field( dev_t,         old_dev         )
+               __field( sector_t,      old_sector      )
+               __field( unsigned int,  rwbs            )
+       ),
+
+       TP_fast_assign(
+               tp_assign(dev, disk_devt(rq->rq_disk))
+               tp_assign(sector, blk_rq_pos(rq))
+               tp_assign(nr_sector, blk_rq_sectors(rq))
+               tp_assign(old_dev, dev)
+               tp_assign(old_sector, from)
+               blk_fill_rwbs(rwbs, rq->cmd_flags, blk_rq_bytes(rq))
+       ),
+
+       TP_printk("%d,%d %s %llu + %u <- (%d,%d) %llu",
+                 MAJOR(__entry->dev), MINOR(__entry->dev),
+                 __print_rwbs_flags(__entry->rwbs),
+                 (unsigned long long)__entry->sector,
+                 __entry->nr_sector,
+                 MAJOR(__entry->old_dev), MINOR(__entry->old_dev),
+                 (unsigned long long)__entry->old_sector)
+)
+#endif
+
+#undef __print_rwbs_flags
+#undef blk_fill_rwbs
+
+#endif /* _TRACE_BLOCK_H */
+
+/* This part must be outside protection */
+#include "../../../probes/define_trace.h"
+
diff --git a/drivers/staging/lttng/instrumentation/events/lttng-module/btrfs.h b/drivers/staging/lttng/instrumentation/events/lttng-module/btrfs.h
new file mode 100644 (file)
index 0000000..246f388
--- /dev/null
@@ -0,0 +1,1117 @@
+#undef TRACE_SYSTEM
+#define TRACE_SYSTEM btrfs
+
+#if !defined(_TRACE_BTRFS_H) || defined(TRACE_HEADER_MULTI_READ)
+#define _TRACE_BTRFS_H
+
+#include <linux/writeback.h>
+#include <linux/tracepoint.h>
+#include <trace/events/gfpflags.h>
+#include <linux/version.h>
+
+#ifndef _TRACE_BTRFS_DEF_
+#define _TRACE_BTRFS_DEF_
+struct btrfs_root;
+struct btrfs_fs_info;
+struct btrfs_inode;
+struct extent_map;
+struct btrfs_ordered_extent;
+struct btrfs_delayed_ref_node;
+struct btrfs_delayed_tree_ref;
+struct btrfs_delayed_data_ref;
+struct btrfs_delayed_ref_head;
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,3,0))
+struct btrfs_block_group_cache;
+struct btrfs_free_cluster;
+#endif
+struct map_lookup;
+struct extent_buffer;
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,4,0))
+struct extent_state;
+#endif
+#endif
+
+#define show_ref_type(type)                                            \
+       __print_symbolic(type,                                          \
+               { BTRFS_TREE_BLOCK_REF_KEY,     "TREE_BLOCK_REF" },     \
+               { BTRFS_EXTENT_DATA_REF_KEY,    "EXTENT_DATA_REF" },    \
+               { BTRFS_EXTENT_REF_V0_KEY,      "EXTENT_REF_V0" },      \
+               { BTRFS_SHARED_BLOCK_REF_KEY,   "SHARED_BLOCK_REF" },   \
+               { BTRFS_SHARED_DATA_REF_KEY,    "SHARED_DATA_REF" })
+
+
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,12,0))
+#define __show_root_type(obj)                                          \
+       __print_symbolic_u64(obj,                                       \
+               { BTRFS_ROOT_TREE_OBJECTID,     "ROOT_TREE"     },      \
+               { BTRFS_EXTENT_TREE_OBJECTID,   "EXTENT_TREE"   },      \
+               { BTRFS_CHUNK_TREE_OBJECTID,    "CHUNK_TREE"    },      \
+               { BTRFS_DEV_TREE_OBJECTID,      "DEV_TREE"      },      \
+               { BTRFS_FS_TREE_OBJECTID,       "FS_TREE"       },      \
+               { BTRFS_ROOT_TREE_DIR_OBJECTID, "ROOT_TREE_DIR" },      \
+               { BTRFS_CSUM_TREE_OBJECTID,     "CSUM_TREE"     },      \
+               { BTRFS_TREE_LOG_OBJECTID,      "TREE_LOG"      },      \
+               { BTRFS_QUOTA_TREE_OBJECTID,    "QUOTA_TREE"    },      \
+               { BTRFS_TREE_RELOC_OBJECTID,    "TREE_RELOC"    },      \
+               { BTRFS_UUID_TREE_OBJECTID,     "UUID_RELOC"    },      \
+               { BTRFS_DATA_RELOC_TREE_OBJECTID, "DATA_RELOC_TREE" })
+#elif (LINUX_VERSION_CODE >= KERNEL_VERSION(3,11,0))
+#define __show_root_type(obj)                                          \
+       __print_symbolic_u64(obj,                                       \
+               { BTRFS_ROOT_TREE_OBJECTID,     "ROOT_TREE"     },      \
+               { BTRFS_EXTENT_TREE_OBJECTID,   "EXTENT_TREE"   },      \
+               { BTRFS_CHUNK_TREE_OBJECTID,    "CHUNK_TREE"    },      \
+               { BTRFS_DEV_TREE_OBJECTID,      "DEV_TREE"      },      \
+               { BTRFS_FS_TREE_OBJECTID,       "FS_TREE"       },      \
+               { BTRFS_ROOT_TREE_DIR_OBJECTID, "ROOT_TREE_DIR" },      \
+               { BTRFS_CSUM_TREE_OBJECTID,     "CSUM_TREE"     },      \
+               { BTRFS_TREE_LOG_OBJECTID,      "TREE_LOG"      },      \
+               { BTRFS_QUOTA_TREE_OBJECTID,    "QUOTA_TREE"    },      \
+               { BTRFS_TREE_RELOC_OBJECTID,    "TREE_RELOC"    },      \
+               { BTRFS_DATA_RELOC_TREE_OBJECTID, "DATA_RELOC_TREE" })
+#elif (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,40))
+#define __show_root_type(obj)                                          \
+       __print_symbolic_u64(obj,                                       \
+               { BTRFS_ROOT_TREE_OBJECTID,     "ROOT_TREE"     },      \
+               { BTRFS_EXTENT_TREE_OBJECTID,   "EXTENT_TREE"   },      \
+               { BTRFS_CHUNK_TREE_OBJECTID,    "CHUNK_TREE"    },      \
+               { BTRFS_DEV_TREE_OBJECTID,      "DEV_TREE"      },      \
+               { BTRFS_FS_TREE_OBJECTID,       "FS_TREE"       },      \
+               { BTRFS_ROOT_TREE_DIR_OBJECTID, "ROOT_TREE_DIR" },      \
+               { BTRFS_CSUM_TREE_OBJECTID,     "CSUM_TREE"     },      \
+               { BTRFS_TREE_LOG_OBJECTID,      "TREE_LOG"      },      \
+               { BTRFS_TREE_RELOC_OBJECTID,    "TREE_RELOC"    },      \
+               { BTRFS_DATA_RELOC_TREE_OBJECTID, "DATA_RELOC_TREE" })
+#else
+#define __show_root_type(obj)                                          \
+       __print_symbolic(obj,                                   \
+               { BTRFS_ROOT_TREE_OBJECTID,     "ROOT_TREE"     },      \
+               { BTRFS_EXTENT_TREE_OBJECTID,   "EXTENT_TREE"   },      \
+               { BTRFS_CHUNK_TREE_OBJECTID,    "CHUNK_TREE"    },      \
+               { BTRFS_DEV_TREE_OBJECTID,      "DEV_TREE"      },      \
+               { BTRFS_FS_TREE_OBJECTID,       "FS_TREE"       },      \
+               { BTRFS_ROOT_TREE_DIR_OBJECTID, "ROOT_TREE_DIR" },      \
+               { BTRFS_CSUM_TREE_OBJECTID,     "CSUM_TREE"     },      \
+               { BTRFS_TREE_LOG_OBJECTID,      "TREE_LOG"      },      \
+               { BTRFS_TREE_RELOC_OBJECTID,    "TREE_RELOC"    },      \
+               { BTRFS_DATA_RELOC_TREE_OBJECTID, "DATA_RELOC_TREE" })
+#endif
+
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,11,0))
+#define show_root_type(obj)                                            \
+       obj, ((obj >= BTRFS_DATA_RELOC_TREE_OBJECTID) ||                \
+             (obj >= BTRFS_ROOT_TREE_OBJECTID &&                       \
+              obj <= BTRFS_QUOTA_TREE_OBJECTID)) ? __show_root_type(obj) : "-"
+#elif (LINUX_VERSION_CODE >= KERNEL_VERSION(3,8,0))
+#define show_root_type(obj)                                            \
+       obj, ((obj >= BTRFS_DATA_RELOC_TREE_OBJECTID) ||                \
+             (obj >= BTRFS_ROOT_TREE_OBJECTID &&                       \
+              obj <= BTRFS_CSUM_TREE_OBJECTID)) ? __show_root_type(obj) : "-"
+#else /* #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,8,0)) */
+#define show_root_type(obj)                                            \
+       obj, ((obj >= BTRFS_DATA_RELOC_TREE_OBJECTID) ||                \
+             (obj <= BTRFS_CSUM_TREE_OBJECTID )) ? __show_root_type(obj) : "-"
+#endif /* #else #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,8,0)) */
+
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,11,0))
+
+#define BTRFS_GROUP_FLAGS      \
+       { BTRFS_BLOCK_GROUP_DATA,       "DATA"},        \
+       { BTRFS_BLOCK_GROUP_SYSTEM,     "SYSTEM"},      \
+       { BTRFS_BLOCK_GROUP_METADATA,   "METADATA"},    \
+       { BTRFS_BLOCK_GROUP_RAID0,      "RAID0"},       \
+       { BTRFS_BLOCK_GROUP_RAID1,      "RAID1"},       \
+       { BTRFS_BLOCK_GROUP_DUP,        "DUP"},         \
+       { BTRFS_BLOCK_GROUP_RAID10,     "RAID10"},      \
+       { BTRFS_BLOCK_GROUP_RAID5,      "RAID5"},       \
+       { BTRFS_BLOCK_GROUP_RAID6,      "RAID6"}
+
+#elif (LINUX_VERSION_CODE >= KERNEL_VERSION(3,3,0))
+
+#define BTRFS_GROUP_FLAGS      \
+       { BTRFS_BLOCK_GROUP_DATA,       "DATA"}, \
+       { BTRFS_BLOCK_GROUP_SYSTEM,     "SYSTEM"}, \
+       { BTRFS_BLOCK_GROUP_METADATA,   "METADATA"}, \
+       { BTRFS_BLOCK_GROUP_RAID0,      "RAID0"}, \
+       { BTRFS_BLOCK_GROUP_RAID1,      "RAID1"}, \
+       { BTRFS_BLOCK_GROUP_DUP,        "DUP"}, \
+       { BTRFS_BLOCK_GROUP_RAID10,     "RAID10"}
+
+#define BTRFS_UUID_SIZE 16
+
+#endif
+
+TRACE_EVENT(btrfs_transaction_commit,
+
+       TP_PROTO(struct btrfs_root *root),
+
+       TP_ARGS(root),
+
+       TP_STRUCT__entry(
+               __field(        u64,  generation                )
+               __field(        u64,  root_objectid             )
+       ),
+
+       TP_fast_assign(
+               tp_assign(generation, root->fs_info->generation)
+               tp_assign(root_objectid, root->root_key.objectid)
+       ),
+
+       TP_printk("root = %llu(%s), gen = %llu",
+                 show_root_type(__entry->root_objectid),
+                 (unsigned long long)__entry->generation)
+)
+
+DECLARE_EVENT_CLASS(btrfs__inode,
+
+       TP_PROTO(struct inode *inode),
+
+       TP_ARGS(inode),
+
+       TP_STRUCT__entry(
+               __field(        ino_t,  ino                     )
+               __field(        blkcnt_t,  blocks               )
+               __field(        u64,  disk_i_size               )
+               __field(        u64,  generation                )
+               __field(        u64,  last_trans                )
+               __field(        u64,  logged_trans              )
+               __field(        u64,  root_objectid             )
+       ),
+
+       TP_fast_assign(
+               tp_assign(ino, inode->i_ino)
+               tp_assign(blocks, inode->i_blocks)
+               tp_assign(disk_i_size, BTRFS_I(inode)->disk_i_size)
+               tp_assign(generation, BTRFS_I(inode)->generation)
+               tp_assign(last_trans, BTRFS_I(inode)->last_trans)
+               tp_assign(logged_trans, BTRFS_I(inode)->logged_trans)
+               tp_assign(root_objectid,
+                               BTRFS_I(inode)->root->root_key.objectid)
+       ),
+
+       TP_printk("root = %llu(%s), gen = %llu, ino = %lu, blocks = %llu, "
+                 "disk_i_size = %llu, last_trans = %llu, logged_trans = %llu",
+                 show_root_type(__entry->root_objectid),
+                 (unsigned long long)__entry->generation,
+                 (unsigned long)__entry->ino,
+                 (unsigned long long)__entry->blocks,
+                 (unsigned long long)__entry->disk_i_size,
+                 (unsigned long long)__entry->last_trans,
+                 (unsigned long long)__entry->logged_trans)
+)
+
+DEFINE_EVENT(btrfs__inode, btrfs_inode_new,
+
+       TP_PROTO(struct inode *inode),
+
+       TP_ARGS(inode)
+)
+
+DEFINE_EVENT(btrfs__inode, btrfs_inode_request,
+
+       TP_PROTO(struct inode *inode),
+
+       TP_ARGS(inode)
+)
+
+DEFINE_EVENT(btrfs__inode, btrfs_inode_evict,
+
+       TP_PROTO(struct inode *inode),
+
+       TP_ARGS(inode)
+)
+
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,40))
+#define __show_map_type(type)                                          \
+       __print_symbolic_u64(type,                                      \
+               { EXTENT_MAP_LAST_BYTE, "LAST_BYTE"     },              \
+               { EXTENT_MAP_HOLE,      "HOLE"          },              \
+               { EXTENT_MAP_INLINE,    "INLINE"        },              \
+               { EXTENT_MAP_DELALLOC,  "DELALLOC"      })
+#else
+#define __show_map_type(type)                                          \
+       __print_symbolic(type,                                  \
+               { EXTENT_MAP_LAST_BYTE, "LAST_BYTE"     },              \
+               { EXTENT_MAP_HOLE,      "HOLE"          },              \
+               { EXTENT_MAP_INLINE,    "INLINE"        },              \
+               { EXTENT_MAP_DELALLOC,  "DELALLOC"      })
+#endif
+
+#define show_map_type(type)                    \
+       type, (type >= EXTENT_MAP_LAST_BYTE) ? "-" :  __show_map_type(type)
+
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,11,0))
+
+#define show_map_flags(flag)                                           \
+       __print_flags(flag, "|",                                        \
+               { EXTENT_FLAG_PINNED,           "PINNED"        },      \
+               { EXTENT_FLAG_COMPRESSED,       "COMPRESSED"    },      \
+               { EXTENT_FLAG_VACANCY,          "VACANCY"       },      \
+               { EXTENT_FLAG_PREALLOC,         "PREALLOC"      },      \
+               { EXTENT_FLAG_LOGGING,          "LOGGING"       },      \
+               { EXTENT_FLAG_FILLING,          "FILLING"       })
+
+#else
+
+#define show_map_flags(flag)                                           \
+       __print_flags(flag, "|",                                        \
+               { EXTENT_FLAG_PINNED,           "PINNED"        },      \
+               { EXTENT_FLAG_COMPRESSED,       "COMPRESSED"    },      \
+               { EXTENT_FLAG_VACANCY,          "VACANCY"       },      \
+               { EXTENT_FLAG_PREALLOC,         "PREALLOC"      })
+
+#endif
+
+TRACE_EVENT(btrfs_get_extent,
+
+       TP_PROTO(struct btrfs_root *root, struct extent_map *map),
+
+       TP_ARGS(root, map),
+
+       TP_STRUCT__entry(
+               __field(        u64,  root_objectid     )
+               __field(        u64,  start             )
+               __field(        u64,  len               )
+               __field(        u64,  orig_start        )
+               __field(        u64,  block_start       )
+               __field(        u64,  block_len         )
+               __field(        unsigned long,  flags   )
+               __field(        int,  refs              )
+               __field(        unsigned int,  compress_type    )
+       ),
+
+       TP_fast_assign(
+               tp_assign(root_objectid, root->root_key.objectid)
+               tp_assign(start, map->start)
+               tp_assign(len, map->len)
+               tp_assign(orig_start, map->orig_start)
+               tp_assign(block_start, map->block_start)
+               tp_assign(block_len, map->block_len)
+               tp_assign(flags, map->flags)
+               tp_assign(refs, atomic_read(&map->refs))
+               tp_assign(compress_type, map->compress_type)
+       ),
+
+       TP_printk("root = %llu(%s), start = %llu, len = %llu, "
+                 "orig_start = %llu, block_start = %llu(%s), "
+                 "block_len = %llu, flags = %s, refs = %u, "
+                 "compress_type = %u",
+                 show_root_type(__entry->root_objectid),
+                 (unsigned long long)__entry->start,
+                 (unsigned long long)__entry->len,
+                 (unsigned long long)__entry->orig_start,
+                 show_map_type(__entry->block_start),
+                 (unsigned long long)__entry->block_len,
+                 show_map_flags(__entry->flags),
+                 __entry->refs, __entry->compress_type)
+)
+
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,11,0))
+
+#define show_ordered_flags(flags)                                      \
+       __print_symbolic(flags,                                         \
+               { BTRFS_ORDERED_IO_DONE,        "IO_DONE"       },      \
+               { BTRFS_ORDERED_COMPLETE,       "COMPLETE"      },      \
+               { BTRFS_ORDERED_NOCOW,          "NOCOW"         },      \
+               { BTRFS_ORDERED_COMPRESSED,     "COMPRESSED"    },      \
+               { BTRFS_ORDERED_PREALLOC,       "PREALLOC"      },      \
+               { BTRFS_ORDERED_DIRECT,         "DIRECT"        },      \
+               { BTRFS_ORDERED_IOERR,          "IOERR"         },      \
+               { BTRFS_ORDERED_UPDATED_ISIZE,  "UPDATED_ISIZE" },      \
+               { BTRFS_ORDERED_LOGGED_CSUM,    "LOGGED_CSUM"   })
+
+#else
+
+#define show_ordered_flags(flags)                                      \
+       __print_symbolic(flags,                                 \
+               { BTRFS_ORDERED_IO_DONE,        "IO_DONE"       },      \
+               { BTRFS_ORDERED_COMPLETE,       "COMPLETE"      },      \
+               { BTRFS_ORDERED_NOCOW,          "NOCOW"         },      \
+               { BTRFS_ORDERED_COMPRESSED,     "COMPRESSED"    },      \
+               { BTRFS_ORDERED_PREALLOC,       "PREALLOC"      },      \
+               { BTRFS_ORDERED_DIRECT,         "DIRECT"        })
+
+#endif
+
+DECLARE_EVENT_CLASS(btrfs__ordered_extent,
+
+       TP_PROTO(struct inode *inode, struct btrfs_ordered_extent *ordered),
+
+       TP_ARGS(inode, ordered),
+
+       TP_STRUCT__entry(
+               __field(        ino_t,  ino             )
+               __field(        u64,  file_offset       )
+               __field(        u64,  start             )
+               __field(        u64,  len               )
+               __field(        u64,  disk_len          )
+               __field(        u64,  bytes_left        )
+               __field(        unsigned long,  flags   )
+               __field(        int,  compress_type     )
+               __field(        int,  refs              )
+               __field(        u64,  root_objectid     )
+       ),
+
+       TP_fast_assign(
+               tp_assign(ino, inode->i_ino)
+               tp_assign(file_offset, ordered->file_offset)
+               tp_assign(start, ordered->start)
+               tp_assign(len, ordered->len)
+               tp_assign(disk_len, ordered->disk_len)
+               tp_assign(bytes_left, ordered->bytes_left)
+               tp_assign(flags, ordered->flags)
+               tp_assign(compress_type, ordered->compress_type)
+               tp_assign(refs, atomic_read(&ordered->refs))
+               tp_assign(root_objectid,
+                               BTRFS_I(inode)->root->root_key.objectid)
+       ),
+
+       TP_printk("root = %llu(%s), ino = %llu, file_offset = %llu, "
+                 "start = %llu, len = %llu, disk_len = %llu, "
+                 "bytes_left = %llu, flags = %s, compress_type = %d, "
+                 "refs = %d",
+                 show_root_type(__entry->root_objectid),
+                 (unsigned long long)__entry->ino,
+                 (unsigned long long)__entry->file_offset,
+                 (unsigned long long)__entry->start,
+                 (unsigned long long)__entry->len,
+                 (unsigned long long)__entry->disk_len,
+                 (unsigned long long)__entry->bytes_left,
+                 show_ordered_flags(__entry->flags),
+                 __entry->compress_type, __entry->refs)
+)
+
+DEFINE_EVENT(btrfs__ordered_extent, btrfs_ordered_extent_add,
+
+       TP_PROTO(struct inode *inode, struct btrfs_ordered_extent *ordered),
+
+       TP_ARGS(inode, ordered)
+)
+
+DEFINE_EVENT(btrfs__ordered_extent, btrfs_ordered_extent_remove,
+
+       TP_PROTO(struct inode *inode, struct btrfs_ordered_extent *ordered),
+
+       TP_ARGS(inode, ordered)
+)
+
+DEFINE_EVENT(btrfs__ordered_extent, btrfs_ordered_extent_start,
+
+       TP_PROTO(struct inode *inode, struct btrfs_ordered_extent *ordered),
+
+       TP_ARGS(inode, ordered)
+)
+
+DEFINE_EVENT(btrfs__ordered_extent, btrfs_ordered_extent_put,
+
+       TP_PROTO(struct inode *inode, struct btrfs_ordered_extent *ordered),
+
+       TP_ARGS(inode, ordered)
+)
+
+DECLARE_EVENT_CLASS(btrfs__writepage,
+
+       TP_PROTO(struct page *page, struct inode *inode,
+                struct writeback_control *wbc),
+
+       TP_ARGS(page, inode, wbc),
+
+       TP_STRUCT__entry(
+               __field(        ino_t,  ino                     )
+               __field(        pgoff_t,  index                 )
+               __field(        long,   nr_to_write             )
+               __field(        long,   pages_skipped           )
+               __field(        loff_t, range_start             )
+               __field(        loff_t, range_end               )
+#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,1,0))
+               __field(        char,   nonblocking             )
+#endif
+               __field(        char,   for_kupdate             )
+               __field(        char,   for_reclaim             )
+               __field(        char,   range_cyclic            )
+               __field(        pgoff_t,  writeback_index       )
+               __field(        u64,    root_objectid           )
+       ),
+
+       TP_fast_assign(
+               tp_assign(ino, inode->i_ino)
+               tp_assign(index, page->index)
+               tp_assign(nr_to_write, wbc->nr_to_write)
+               tp_assign(pages_skipped, wbc->pages_skipped)
+               tp_assign(range_start, wbc->range_start)
+               tp_assign(range_end, wbc->range_end)
+#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,1,0))
+               tp_assign(nonblocking, wbc->nonblocking)
+#endif
+               tp_assign(for_kupdate, wbc->for_kupdate)
+               tp_assign(for_reclaim, wbc->for_reclaim)
+               tp_assign(range_cyclic, wbc->range_cyclic)
+               tp_assign(writeback_index, inode->i_mapping->writeback_index)
+               tp_assign(root_objectid,
+                                BTRFS_I(inode)->root->root_key.objectid)
+       ),
+
+#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,1,0))
+       TP_printk("root = %llu(%s), ino = %lu, page_index = %lu, "
+                 "nr_to_write = %ld, pages_skipped = %ld, range_start = %llu, "
+                 "range_end = %llu, nonblocking = %d, for_kupdate = %d, "
+                 "for_reclaim = %d, range_cyclic = %d, writeback_index = %lu",
+                 show_root_type(__entry->root_objectid),
+                 (unsigned long)__entry->ino, __entry->index,
+                 __entry->nr_to_write, __entry->pages_skipped,
+                 __entry->range_start, __entry->range_end,
+                 __entry->nonblocking, __entry->for_kupdate,
+                 __entry->for_reclaim, __entry->range_cyclic,
+                 (unsigned long)__entry->writeback_index)
+#else
+       TP_printk("root = %llu(%s), ino = %lu, page_index = %lu, "
+                 "nr_to_write = %ld, pages_skipped = %ld, range_start = %llu, "
+                 "range_end = %llu, for_kupdate = %d, "
+                 "for_reclaim = %d, range_cyclic = %d, writeback_index = %lu",
+                 show_root_type(__entry->root_objectid),
+                 (unsigned long)__entry->ino, __entry->index,
+                 __entry->nr_to_write, __entry->pages_skipped,
+                 __entry->range_start, __entry->range_end,
+                 __entry->for_kupdate,
+                 __entry->for_reclaim, __entry->range_cyclic,
+                 (unsigned long)__entry->writeback_index)
+#endif
+)
+
+DEFINE_EVENT(btrfs__writepage, __extent_writepage,
+
+       TP_PROTO(struct page *page, struct inode *inode,
+                struct writeback_control *wbc),
+
+       TP_ARGS(page, inode, wbc)
+)
+
+TRACE_EVENT(btrfs_writepage_end_io_hook,
+
+       TP_PROTO(struct page *page, u64 start, u64 end, int uptodate),
+
+       TP_ARGS(page, start, end, uptodate),
+
+       TP_STRUCT__entry(
+               __field(        ino_t,   ino            )
+               __field(        pgoff_t, index          )
+               __field(        u64,     start          )
+               __field(        u64,     end            )
+               __field(        int,     uptodate       )
+               __field(        u64,    root_objectid   )
+       ),
+
+       TP_fast_assign(
+               tp_assign(ino, page->mapping->host->i_ino)
+               tp_assign(index, page->index)
+               tp_assign(start, start)
+               tp_assign(end, end)
+               tp_assign(uptodate, uptodate)
+               tp_assign(root_objectid,
+                        BTRFS_I(page->mapping->host)->root->root_key.objectid)
+       ),
+
+       TP_printk("root = %llu(%s), ino = %lu, page_index = %lu, start = %llu, "
+                 "end = %llu, uptodate = %d",
+                 show_root_type(__entry->root_objectid),
+                 (unsigned long)__entry->ino, (unsigned long)__entry->index,
+                 (unsigned long long)__entry->start,
+                 (unsigned long long)__entry->end, __entry->uptodate)
+)
+
+TRACE_EVENT(btrfs_sync_file,
+
+       TP_PROTO(struct file *file, int datasync),
+
+       TP_ARGS(file, datasync),
+
+       TP_STRUCT__entry(
+               __field(        ino_t,  ino             )
+               __field(        ino_t,  parent          )
+               __field(        int,    datasync        )
+               __field(        u64,    root_objectid   )
+       ),
+
+       TP_fast_assign(
+               tp_assign(ino, file->f_path.dentry->d_inode->i_ino)
+               tp_assign(parent, file->f_path.dentry->d_parent->d_inode->i_ino)
+               tp_assign(datasync, datasync)
+               tp_assign(root_objectid,
+                       BTRFS_I(file->f_path.dentry->d_inode)->root->root_key.objectid)
+       ),
+
+       TP_printk("root = %llu(%s), ino = %ld, parent = %ld, datasync = %d",
+                 show_root_type(__entry->root_objectid),
+                 (unsigned long)__entry->ino, (unsigned long)__entry->parent,
+                 __entry->datasync)
+)
+
+TRACE_EVENT(btrfs_sync_fs,
+
+       TP_PROTO(int wait),
+
+       TP_ARGS(wait),
+
+       TP_STRUCT__entry(
+               __field(        int,  wait              )
+       ),
+
+       TP_fast_assign(
+               tp_assign(wait, wait)
+       ),
+
+       TP_printk("wait = %d", __entry->wait)
+)
+
+#define show_ref_action(action)                                                \
+       __print_symbolic(action,                                        \
+               { BTRFS_ADD_DELAYED_REF,    "ADD_DELAYED_REF" },        \
+               { BTRFS_DROP_DELAYED_REF,   "DROP_DELAYED_REF" },       \
+               { BTRFS_ADD_DELAYED_EXTENT, "ADD_DELAYED_EXTENT" },     \
+               { BTRFS_UPDATE_DELAYED_HEAD, "UPDATE_DELAYED_HEAD" })
+
+
+TRACE_EVENT(btrfs_delayed_tree_ref,
+
+       TP_PROTO(struct btrfs_delayed_ref_node *ref,
+                struct btrfs_delayed_tree_ref *full_ref,
+                int action),
+
+       TP_ARGS(ref, full_ref, action),
+
+       TP_STRUCT__entry(
+               __field(        u64,  bytenr            )
+               __field(        u64,  num_bytes         )
+               __field(        int,  action            )
+               __field(        u64,  parent            )
+               __field(        u64,  ref_root          )
+               __field(        int,  level             )
+               __field(        int,  type              )
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,7,0))
+               __field(        u64,  seq               )
+#endif
+       ),
+
+       TP_fast_assign(
+               tp_assign(bytenr, ref->bytenr)
+               tp_assign(num_bytes, ref->num_bytes)
+               tp_assign(action, action)
+               tp_assign(parent, full_ref->parent)
+               tp_assign(ref_root, full_ref->root)
+               tp_assign(level, full_ref->level)
+               tp_assign(type, ref->type)
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,7,0))
+               tp_assign(seq, ref->seq)
+#endif
+       ),
+
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,7,0))
+       TP_printk("bytenr = %llu, num_bytes = %llu, action = %s, "
+                 "parent = %llu(%s), ref_root = %llu(%s), level = %d, "
+                 "type = %s, seq = %llu",
+#else
+       TP_printk("bytenr = %llu, num_bytes = %llu, action = %s, "
+                 "parent = %llu(%s), ref_root = %llu(%s), level = %d, "
+                 "type = %s",
+#endif
+                 (unsigned long long)__entry->bytenr,
+                 (unsigned long long)__entry->num_bytes,
+                 show_ref_action(__entry->action),
+                 show_root_type(__entry->parent),
+                 show_root_type(__entry->ref_root),
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,7,0))
+                 __entry->level, show_ref_type(__entry->type),
+                 (unsigned long long)__entry->seq)
+#else
+                 __entry->level, show_ref_type(__entry->type))
+#endif
+)
+
+TRACE_EVENT(btrfs_delayed_data_ref,
+
+       TP_PROTO(struct btrfs_delayed_ref_node *ref,
+                struct btrfs_delayed_data_ref *full_ref,
+                int action),
+
+       TP_ARGS(ref, full_ref, action),
+
+       TP_STRUCT__entry(
+               __field(        u64,  bytenr            )
+               __field(        u64,  num_bytes         )
+               __field(        int,  action            )
+               __field(        u64,  parent            )
+               __field(        u64,  ref_root          )
+               __field(        u64,  owner             )
+               __field(        u64,  offset            )
+               __field(        int,  type              )
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,7,0))
+               __field(        u64,  seq               )
+#endif
+       ),
+
+       TP_fast_assign(
+               tp_assign(bytenr, ref->bytenr)
+               tp_assign(num_bytes, ref->num_bytes)
+               tp_assign(action, action)
+               tp_assign(parent, full_ref->parent)
+               tp_assign(ref_root, full_ref->root)
+               tp_assign(owner, full_ref->objectid)
+               tp_assign(offset, full_ref->offset)
+               tp_assign(type, ref->type)
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,7,0))
+               tp_assign(seq, ref->seq)
+#endif
+       ),
+
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,7,0))
+       TP_printk("bytenr = %llu, num_bytes = %llu, action = %s, "
+                 "parent = %llu(%s), ref_root = %llu(%s), owner = %llu, "
+                 "offset = %llu, type = %s, seq = %llu",
+#else
+       TP_printk("bytenr = %llu, num_bytes = %llu, action = %s, "
+                 "parent = %llu(%s), ref_root = %llu(%s), owner = %llu, "
+                 "offset = %llu, type = %s",
+#endif
+                 (unsigned long long)__entry->bytenr,
+                 (unsigned long long)__entry->num_bytes,
+                 show_ref_action(__entry->action),
+                 show_root_type(__entry->parent),
+                 show_root_type(__entry->ref_root),
+                 (unsigned long long)__entry->owner,
+                 (unsigned long long)__entry->offset,
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,7,0))
+                 show_ref_type(__entry->type),
+                 (unsigned long long)__entry->seq)
+#else
+                 show_ref_type(__entry->type))
+#endif
+)
+
+TRACE_EVENT(btrfs_delayed_ref_head,
+
+       TP_PROTO(struct btrfs_delayed_ref_node *ref,
+                struct btrfs_delayed_ref_head *head_ref,
+                int action),
+
+       TP_ARGS(ref, head_ref, action),
+
+       TP_STRUCT__entry(
+               __field(        u64,  bytenr            )
+               __field(        u64,  num_bytes         )
+               __field(        int,  action            )
+               __field(        int,  is_data           )
+       ),
+
+       TP_fast_assign(
+               tp_assign(bytenr, ref->bytenr)
+               tp_assign(num_bytes, ref->num_bytes)
+               tp_assign(action, action)
+               tp_assign(is_data, head_ref->is_data)
+       ),
+
+       TP_printk("bytenr = %llu, num_bytes = %llu, action = %s, is_data = %d",
+                 (unsigned long long)__entry->bytenr,
+                 (unsigned long long)__entry->num_bytes,
+                 show_ref_action(__entry->action),
+                 __entry->is_data)
+)
+
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,11,0))
+
+#define show_chunk_type(type)                                  \
+       __print_flags(type, "|",                                \
+               { BTRFS_BLOCK_GROUP_DATA,       "DATA"  },      \
+               { BTRFS_BLOCK_GROUP_SYSTEM,     "SYSTEM"},      \
+               { BTRFS_BLOCK_GROUP_METADATA,   "METADATA"},    \
+               { BTRFS_BLOCK_GROUP_RAID0,      "RAID0" },      \
+               { BTRFS_BLOCK_GROUP_RAID1,      "RAID1" },      \
+               { BTRFS_BLOCK_GROUP_DUP,        "DUP"   },      \
+               { BTRFS_BLOCK_GROUP_RAID10,     "RAID10"},      \
+               { BTRFS_BLOCK_GROUP_RAID5,      "RAID5" },      \
+               { BTRFS_BLOCK_GROUP_RAID6,      "RAID6" })
+
+#else
+
+#define show_chunk_type(type)                                  \
+       __print_flags(type, "|",                                \
+               { BTRFS_BLOCK_GROUP_DATA,       "DATA"  },      \
+               { BTRFS_BLOCK_GROUP_SYSTEM,     "SYSTEM"},      \
+               { BTRFS_BLOCK_GROUP_METADATA,   "METADATA"},    \
+               { BTRFS_BLOCK_GROUP_RAID0,      "RAID0" },      \
+               { BTRFS_BLOCK_GROUP_RAID1,      "RAID1" },      \
+               { BTRFS_BLOCK_GROUP_DUP,        "DUP"   },      \
+               { BTRFS_BLOCK_GROUP_RAID10,     "RAID10"})
+
+#endif
+
+DECLARE_EVENT_CLASS(btrfs__chunk,
+
+       TP_PROTO(struct btrfs_root *root, struct map_lookup *map,
+                u64 offset, u64 size),
+
+       TP_ARGS(root, map, offset, size),
+
+       TP_STRUCT__entry(
+               __field(        int,  num_stripes               )
+               __field(        u64,  type                      )
+               __field(        int,  sub_stripes               )
+               __field(        u64,  offset                    )
+               __field(        u64,  size                      )
+               __field(        u64,  root_objectid             )
+       ),
+
+       TP_fast_assign(
+               tp_assign(num_stripes, map->num_stripes)
+               tp_assign(type, map->type)
+               tp_assign(sub_stripes, map->sub_stripes)
+               tp_assign(offset, offset)
+               tp_assign(size, size)
+               tp_assign(root_objectid, root->root_key.objectid)
+       ),
+
+       TP_printk("root = %llu(%s), offset = %llu, size = %llu, "
+                 "num_stripes = %d, sub_stripes = %d, type = %s",
+                 show_root_type(__entry->root_objectid),
+                 (unsigned long long)__entry->offset,
+                 (unsigned long long)__entry->size,
+                 __entry->num_stripes, __entry->sub_stripes,
+                 show_chunk_type(__entry->type))
+)
+
+DEFINE_EVENT(btrfs__chunk,  btrfs_chunk_alloc,
+
+       TP_PROTO(struct btrfs_root *root, struct map_lookup *map,
+                u64 offset, u64 size),
+
+       TP_ARGS(root, map, offset, size)
+)
+
+DEFINE_EVENT(btrfs__chunk,  btrfs_chunk_free,
+
+       TP_PROTO(struct btrfs_root *root, struct map_lookup *map,
+                u64 offset, u64 size),
+
+       TP_ARGS(root, map, offset, size)
+)
+
+TRACE_EVENT(btrfs_cow_block,
+
+       TP_PROTO(struct btrfs_root *root, struct extent_buffer *buf,
+                struct extent_buffer *cow),
+
+       TP_ARGS(root, buf, cow),
+
+       TP_STRUCT__entry(
+               __field(        u64,  root_objectid             )
+               __field(        u64,  buf_start                 )
+               __field(        int,  refs                      )
+               __field(        u64,  cow_start                 )
+               __field(        int,  buf_level                 )
+               __field(        int,  cow_level                 )
+       ),
+
+       TP_fast_assign(
+               tp_assign(root_objectid, root->root_key.objectid)
+               tp_assign(buf_start, buf->start)
+               tp_assign(refs, atomic_read(&buf->refs))
+               tp_assign(cow_start, cow->start)
+               tp_assign(buf_level, btrfs_header_level(buf))
+               tp_assign(cow_level, btrfs_header_level(cow))
+       ),
+
+       TP_printk("root = %llu(%s), refs = %d, orig_buf = %llu "
+                 "(orig_level = %d), cow_buf = %llu (cow_level = %d)",
+                 show_root_type(__entry->root_objectid),
+                 __entry->refs,
+                 (unsigned long long)__entry->buf_start,
+                 __entry->buf_level,
+                 (unsigned long long)__entry->cow_start,
+                 __entry->cow_level)
+)
+
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,3,0))
+TRACE_EVENT(btrfs_space_reservation,
+
+       TP_PROTO(struct btrfs_fs_info *fs_info, char *type, u64 val,
+                u64 bytes, int reserve),
+
+       TP_ARGS(fs_info, type, val, bytes, reserve),
+
+       TP_STRUCT__entry(
+               __array(        u8,     fsid,   BTRFS_UUID_SIZE )
+               __string(       type,   type                    )
+               __field(        u64,    val                     )
+               __field(        u64,    bytes                   )
+               __field(        int,    reserve                 )
+       ),
+
+       TP_fast_assign(
+               tp_memcpy(fsid, fs_info->fsid, BTRFS_UUID_SIZE)
+               tp_strcpy(type, type)
+               tp_assign(val, val)
+               tp_assign(bytes, bytes)
+               tp_assign(reserve, reserve)
+       ),
+
+       TP_printk("%pU: %s: %Lu %s %Lu", __entry->fsid, __get_str(type),
+                 __entry->val, __entry->reserve ? "reserve" : "release",
+                 __entry->bytes)
+)
+#endif
+
+DECLARE_EVENT_CLASS(btrfs__reserved_extent,
+
+       TP_PROTO(struct btrfs_root *root, u64 start, u64 len),
+
+       TP_ARGS(root, start, len),
+
+       TP_STRUCT__entry(
+               __field(        u64,  root_objectid             )
+               __field(        u64,  start                     )
+               __field(        u64,  len                       )
+       ),
+
+       TP_fast_assign(
+               tp_assign(root_objectid, root->root_key.objectid)
+               tp_assign(start, start)
+               tp_assign(len, len)
+       ),
+
+       TP_printk("root = %llu(%s), start = %llu, len = %llu",
+                 show_root_type(__entry->root_objectid),
+                 (unsigned long long)__entry->start,
+                 (unsigned long long)__entry->len)
+)
+
+DEFINE_EVENT(btrfs__reserved_extent,  btrfs_reserved_extent_alloc,
+
+       TP_PROTO(struct btrfs_root *root, u64 start, u64 len),
+
+       TP_ARGS(root, start, len)
+)
+
+DEFINE_EVENT(btrfs__reserved_extent,  btrfs_reserved_extent_free,
+
+       TP_PROTO(struct btrfs_root *root, u64 start, u64 len),
+
+       TP_ARGS(root, start, len)
+)
+
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,3,0))
+TRACE_EVENT_MAP(find_free_extent,
+
+       btrfs_find_free_extent,
+
+       TP_PROTO(struct btrfs_root *root, u64 num_bytes, u64 empty_size,
+                u64 data),
+
+       TP_ARGS(root, num_bytes, empty_size, data),
+
+       TP_STRUCT__entry(
+               __field(        u64,    root_objectid           )
+               __field(        u64,    num_bytes               )
+               __field(        u64,    empty_size              )
+               __field(        u64,    data                    )
+       ),
+
+       TP_fast_assign(
+               tp_assign(root_objectid, root->root_key.objectid)
+               tp_assign(num_bytes, num_bytes)
+               tp_assign(empty_size, empty_size)
+               tp_assign(data, data)
+       ),
+
+       TP_printk("root = %Lu(%s), len = %Lu, empty_size = %Lu, "
+                 "flags = %Lu(%s)", show_root_type(__entry->root_objectid),
+                 __entry->num_bytes, __entry->empty_size, __entry->data,
+                 __print_flags((unsigned long)__entry->data, "|",
+                                BTRFS_GROUP_FLAGS))
+)
+
+DECLARE_EVENT_CLASS(btrfs__reserve_extent,
+
+       TP_PROTO(struct btrfs_root *root,
+                struct btrfs_block_group_cache *block_group, u64 start,
+                u64 len),
+
+       TP_ARGS(root, block_group, start, len),
+
+       TP_STRUCT__entry(
+               __field(        u64,    root_objectid           )
+               __field(        u64,    bg_objectid             )
+               __field(        u64,    flags                   )
+               __field(        u64,    start                   )
+               __field(        u64,    len                     )
+       ),
+
+       TP_fast_assign(
+               tp_assign(root_objectid, root->root_key.objectid)
+               tp_assign(bg_objectid, block_group->key.objectid)
+               tp_assign(flags, block_group->flags)
+               tp_assign(start, start)
+               tp_assign(len, len)
+       ),
+
+       TP_printk("root = %Lu(%s), block_group = %Lu, flags = %Lu(%s), "
+                 "start = %Lu, len = %Lu",
+                 show_root_type(__entry->root_objectid), __entry->bg_objectid,
+                 __entry->flags, __print_flags((unsigned long)__entry->flags,
+                                               "|", BTRFS_GROUP_FLAGS),
+                 __entry->start, __entry->len)
+)
+
+DEFINE_EVENT(btrfs__reserve_extent, btrfs_reserve_extent,
+
+       TP_PROTO(struct btrfs_root *root,
+                struct btrfs_block_group_cache *block_group, u64 start,
+                u64 len),
+
+       TP_ARGS(root, block_group, start, len)
+)
+
+DEFINE_EVENT(btrfs__reserve_extent, btrfs_reserve_extent_cluster,
+
+       TP_PROTO(struct btrfs_root *root,
+                struct btrfs_block_group_cache *block_group, u64 start,
+                u64 len),
+
+       TP_ARGS(root, block_group, start, len)
+)
+
+TRACE_EVENT(btrfs_find_cluster,
+
+       TP_PROTO(struct btrfs_block_group_cache *block_group, u64 start,
+                u64 bytes, u64 empty_size, u64 min_bytes),
+
+       TP_ARGS(block_group, start, bytes, empty_size, min_bytes),
+
+       TP_STRUCT__entry(
+               __field(        u64,    bg_objectid             )
+               __field(        u64,    flags                   )
+               __field(        u64,    start                   )
+               __field(        u64,    bytes                   )
+               __field(        u64,    empty_size              )
+               __field(        u64,    min_bytes               )
+       ),
+
+       TP_fast_assign(
+               tp_assign(bg_objectid, block_group->key.objectid)
+               tp_assign(flags, block_group->flags)
+               tp_assign(start, start)
+               tp_assign(bytes, bytes)
+               tp_assign(empty_size, empty_size)
+               tp_assign(min_bytes, min_bytes)
+       ),
+
+       TP_printk("block_group = %Lu, flags = %Lu(%s), start = %Lu, len = %Lu,"
+                 " empty_size = %Lu, min_bytes = %Lu", __entry->bg_objectid,
+                 __entry->flags,
+                 __print_flags((unsigned long)__entry->flags, "|",
+                               BTRFS_GROUP_FLAGS), __entry->start,
+                 __entry->bytes, __entry->empty_size,  __entry->min_bytes)
+)
+
+TRACE_EVENT(btrfs_failed_cluster_setup,
+
+       TP_PROTO(struct btrfs_block_group_cache *block_group),
+
+       TP_ARGS(block_group),
+
+       TP_STRUCT__entry(
+               __field(        u64,    bg_objectid             )
+       ),
+
+       TP_fast_assign(
+               tp_assign(bg_objectid, block_group->key.objectid)
+       ),
+
+       TP_printk("block_group = %Lu", __entry->bg_objectid)
+)
+
+TRACE_EVENT(btrfs_setup_cluster,
+
+       TP_PROTO(struct btrfs_block_group_cache *block_group,
+                struct btrfs_free_cluster *cluster, u64 size, int bitmap),
+
+       TP_ARGS(block_group, cluster, size, bitmap),
+
+       TP_STRUCT__entry(
+               __field(        u64,    bg_objectid             )
+               __field(        u64,    flags                   )
+               __field(        u64,    start                   )
+               __field(        u64,    max_size                )
+               __field(        u64,    size                    )
+               __field(        int,    bitmap                  )
+       ),
+
+       TP_fast_assign(
+               tp_assign(bg_objectid, block_group->key.objectid)
+               tp_assign(flags, block_group->flags)
+               tp_assign(start, cluster->window_start)
+               tp_assign(max_size, cluster->max_size)
+               tp_assign(size, size)
+               tp_assign(bitmap, bitmap)
+       ),
+
+       TP_printk("block_group = %Lu, flags = %Lu(%s), window_start = %Lu, "
+                 "size = %Lu, max_size = %Lu, bitmap = %d",
+                 __entry->bg_objectid,
+                 __entry->flags,
+                 __print_flags((unsigned long)__entry->flags, "|",
+                               BTRFS_GROUP_FLAGS), __entry->start,
+                 __entry->size, __entry->max_size, __entry->bitmap)
+)
+#endif
+
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,4,0))
+TRACE_EVENT_MAP(alloc_extent_state,
+
+       btrfs_alloc_extent_state,
+
+       TP_PROTO(struct extent_state *state, gfp_t mask, unsigned long IP),
+
+       TP_ARGS(state, mask, IP),
+
+       TP_STRUCT__entry(
+               __field(struct extent_state *, state)
+               __field(gfp_t, mask)
+               __field(unsigned long, ip)
+       ),
+
+       TP_fast_assign(
+               tp_assign(state, state)
+               tp_assign(mask, mask)
+               tp_assign(ip, IP)
+       ),
+
+       TP_printk("state=%p; mask = %s; caller = %pF", __entry->state,
+                 show_gfp_flags(__entry->mask), (void *)__entry->ip)
+)
+
+TRACE_EVENT_MAP(free_extent_state,
+
+       btrfs_free_extent_state,
+
+       TP_PROTO(struct extent_state *state, unsigned long IP),
+
+       TP_ARGS(state, IP),
+
+       TP_STRUCT__entry(
+               __field(struct extent_state *, state)
+               __field(unsigned long, ip)
+       ),
+
+       TP_fast_assign(
+               tp_assign(state, state)
+               tp_assign(ip, IP)
+       ),
+
+       TP_printk(" state=%p; caller = %pF", __entry->state,
+                 (void *)__entry->ip)
+)
+#endif
+
+#endif /* _TRACE_BTRFS_H */
+
+/* This part must be outside protection */
+#include "../../../probes/define_trace.h"
diff --git a/drivers/staging/lttng/instrumentation/events/lttng-module/compaction.h b/drivers/staging/lttng/instrumentation/events/lttng-module/compaction.h
new file mode 100644 (file)
index 0000000..1b237fa
--- /dev/null
@@ -0,0 +1,74 @@
+#undef TRACE_SYSTEM
+#define TRACE_SYSTEM compaction
+
+#if !defined(_TRACE_COMPACTION_H) || defined(TRACE_HEADER_MULTI_READ)
+#define _TRACE_COMPACTION_H
+
+#include <linux/types.h>
+#include <linux/tracepoint.h>
+#include <trace/events/gfpflags.h>
+
+DECLARE_EVENT_CLASS(mm_compaction_isolate_template,
+
+       TP_PROTO(unsigned long nr_scanned,
+               unsigned long nr_taken),
+
+       TP_ARGS(nr_scanned, nr_taken),
+
+       TP_STRUCT__entry(
+               __field(unsigned long, nr_scanned)
+               __field(unsigned long, nr_taken)
+       ),
+
+       TP_fast_assign(
+               tp_assign(nr_scanned, nr_scanned)
+               tp_assign(nr_taken, nr_taken)
+       ),
+
+       TP_printk("nr_scanned=%lu nr_taken=%lu",
+               __entry->nr_scanned,
+               __entry->nr_taken)
+)
+
+DEFINE_EVENT(mm_compaction_isolate_template, mm_compaction_isolate_migratepages,
+
+       TP_PROTO(unsigned long nr_scanned,
+               unsigned long nr_taken),
+
+       TP_ARGS(nr_scanned, nr_taken)
+)
+
+DEFINE_EVENT(mm_compaction_isolate_template, mm_compaction_isolate_freepages,
+       TP_PROTO(unsigned long nr_scanned,
+               unsigned long nr_taken),
+
+       TP_ARGS(nr_scanned, nr_taken)
+)
+
+TRACE_EVENT(mm_compaction_migratepages,
+
+       TP_PROTO(unsigned long nr_migrated,
+               unsigned long nr_failed),
+
+       TP_ARGS(nr_migrated, nr_failed),
+
+       TP_STRUCT__entry(
+               __field(unsigned long, nr_migrated)
+               __field(unsigned long, nr_failed)
+       ),
+
+       TP_fast_assign(
+               tp_assign(nr_migrated, nr_migrated)
+               tp_assign(nr_failed, nr_failed)
+       ),
+
+       TP_printk("nr_migrated=%lu nr_failed=%lu",
+               __entry->nr_migrated,
+               __entry->nr_failed)
+)
+
+
+#endif /* _TRACE_COMPACTION_H */
+
+/* This part must be outside protection */
+#include "../../../probes/define_trace.h"
diff --git a/drivers/staging/lttng/instrumentation/events/lttng-module/ext3.h b/drivers/staging/lttng/instrumentation/events/lttng-module/ext3.h
new file mode 100644 (file)
index 0000000..286a1df
--- /dev/null
@@ -0,0 +1,902 @@
+#undef TRACE_SYSTEM
+#define TRACE_SYSTEM ext3
+
+#if !defined(_TRACE_EXT3_H) || defined(TRACE_HEADER_MULTI_READ)
+#define _TRACE_EXT3_H
+
+#include <linux/tracepoint.h>
+#include <linux/version.h>
+
+TRACE_EVENT(ext3_free_inode,
+       TP_PROTO(struct inode *inode),
+
+       TP_ARGS(inode),
+
+       TP_STRUCT__entry(
+               __field(        dev_t,  dev                     )
+               __field(        ino_t,  ino                     )
+               __field(        umode_t, mode                   )
+               __field(        uid_t,  uid                     )
+               __field(        gid_t,  gid                     )
+               __field(        blkcnt_t, blocks                )
+       ),
+
+       TP_fast_assign(
+               tp_assign(dev, inode->i_sb->s_dev)
+               tp_assign(ino, inode->i_ino)
+               tp_assign(mode, inode->i_mode)
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,5,0))
+               tp_assign(uid, i_uid_read(inode))
+               tp_assign(gid, i_gid_read(inode))
+#else
+               tp_assign(uid, inode->i_uid)
+               tp_assign(gid, inode->i_gid)
+#endif
+               tp_assign(blocks, inode->i_blocks)
+       ),
+
+       TP_printk("dev %d,%d ino %lu mode 0%o uid %u gid %u blocks %lu",
+                 MAJOR(__entry->dev), MINOR(__entry->dev),
+                 (unsigned long) __entry->ino,
+                 __entry->mode, __entry->uid, __entry->gid,
+                 (unsigned long) __entry->blocks)
+)
+
+TRACE_EVENT(ext3_request_inode,
+       TP_PROTO(struct inode *dir, int mode),
+
+       TP_ARGS(dir, mode),
+
+       TP_STRUCT__entry(
+               __field(        dev_t,  dev                     )
+               __field(        ino_t,  dir                     )
+               __field(        umode_t, mode                   )
+       ),
+
+       TP_fast_assign(
+               tp_assign(dev, dir->i_sb->s_dev)
+               tp_assign(dir, dir->i_ino)
+               tp_assign(mode, mode)
+       ),
+
+       TP_printk("dev %d,%d dir %lu mode 0%o",
+                 MAJOR(__entry->dev), MINOR(__entry->dev),
+                 (unsigned long) __entry->dir, __entry->mode)
+)
+
+TRACE_EVENT(ext3_allocate_inode,
+       TP_PROTO(struct inode *inode, struct inode *dir, int mode),
+
+       TP_ARGS(inode, dir, mode),
+
+       TP_STRUCT__entry(
+               __field(        dev_t,  dev                     )
+               __field(        ino_t,  ino                     )
+               __field(        ino_t,  dir                     )
+               __field(        umode_t, mode                   )
+       ),
+
+       TP_fast_assign(
+               tp_assign(dev, inode->i_sb->s_dev)
+               tp_assign(ino, inode->i_ino)
+               tp_assign(dir, dir->i_ino)
+               tp_assign(mode, mode)
+       ),
+
+       TP_printk("dev %d,%d ino %lu dir %lu mode 0%o",
+                 MAJOR(__entry->dev), MINOR(__entry->dev),
+                 (unsigned long) __entry->ino,
+                 (unsigned long) __entry->dir, __entry->mode)
+)
+
+TRACE_EVENT(ext3_evict_inode,
+       TP_PROTO(struct inode *inode),
+
+       TP_ARGS(inode),
+
+       TP_STRUCT__entry(
+               __field(        dev_t,  dev                     )
+               __field(        ino_t,  ino                     )
+               __field(        int,    nlink                   )
+       ),
+
+       TP_fast_assign(
+               tp_assign(dev, inode->i_sb->s_dev)
+               tp_assign(ino, inode->i_ino)
+               tp_assign(nlink, inode->i_nlink)
+       ),
+
+       TP_printk("dev %d,%d ino %lu nlink %d",
+                 MAJOR(__entry->dev), MINOR(__entry->dev),
+                 (unsigned long) __entry->ino, __entry->nlink)
+)
+
+TRACE_EVENT(ext3_drop_inode,
+       TP_PROTO(struct inode *inode, int drop),
+
+       TP_ARGS(inode, drop),
+
+       TP_STRUCT__entry(
+               __field(        dev_t,  dev                     )
+               __field(        ino_t,  ino                     )
+               __field(        int,    drop                    )
+       ),
+
+       TP_fast_assign(
+               tp_assign(dev, inode->i_sb->s_dev)
+               tp_assign(ino, inode->i_ino)
+               tp_assign(drop, drop)
+       ),
+
+       TP_printk("dev %d,%d ino %lu drop %d",
+                 MAJOR(__entry->dev), MINOR(__entry->dev),
+                 (unsigned long) __entry->ino, __entry->drop)
+)
+
+TRACE_EVENT(ext3_mark_inode_dirty,
+       TP_PROTO(struct inode *inode, unsigned long IP),
+
+       TP_ARGS(inode, IP),
+
+       TP_STRUCT__entry(
+               __field(        dev_t,  dev                     )
+               __field(        ino_t,  ino                     )
+               __field(unsigned long,  ip                      )
+       ),
+
+       TP_fast_assign(
+               tp_assign(dev, inode->i_sb->s_dev)
+               tp_assign(ino, inode->i_ino)
+               tp_assign(ip, IP)
+       ),
+
+       TP_printk("dev %d,%d ino %lu caller %pF",
+                 MAJOR(__entry->dev), MINOR(__entry->dev),
+                 (unsigned long) __entry->ino, (void *)__entry->ip)
+)
+
+TRACE_EVENT(ext3_write_begin,
+       TP_PROTO(struct inode *inode, loff_t pos, unsigned int len,
+                unsigned int flags),
+
+       TP_ARGS(inode, pos, len, flags),
+
+       TP_STRUCT__entry(
+               __field(        dev_t,  dev                     )
+               __field(        ino_t,  ino                     )
+               __field(        loff_t, pos                     )
+               __field(        unsigned int, len               )
+               __field(        unsigned int, flags             )
+       ),
+
+       TP_fast_assign(
+               tp_assign(dev, inode->i_sb->s_dev)
+               tp_assign(ino, inode->i_ino)
+               tp_assign(pos, pos)
+               tp_assign(len, len)
+               tp_assign(flags, flags)
+       ),
+
+       TP_printk("dev %d,%d ino %lu pos %llu len %u flags %u",
+                 MAJOR(__entry->dev), MINOR(__entry->dev),
+                 (unsigned long) __entry->ino,
+                 (unsigned long long) __entry->pos, __entry->len,
+                 __entry->flags)
+)
+
+DECLARE_EVENT_CLASS(ext3__write_end,
+       TP_PROTO(struct inode *inode, loff_t pos, unsigned int len,
+                       unsigned int copied),
+
+       TP_ARGS(inode, pos, len, copied),
+
+       TP_STRUCT__entry(
+               __field(        dev_t,  dev                     )
+               __field(        ino_t,  ino                     )
+               __field(        loff_t, pos                     )
+               __field(        unsigned int, len               )
+               __field(        unsigned int, copied            )
+       ),
+
+       TP_fast_assign(
+               tp_assign(dev, inode->i_sb->s_dev)
+               tp_assign(ino, inode->i_ino)
+               tp_assign(pos, pos)
+               tp_assign(len, len)
+               tp_assign(copied, copied)
+       ),
+
+       TP_printk("dev %d,%d ino %lu pos %llu len %u copied %u",
+                 MAJOR(__entry->dev), MINOR(__entry->dev),
+                 (unsigned long) __entry->ino,
+                 (unsigned long long) __entry->pos, __entry->len,
+                 __entry->copied)
+)
+
+DEFINE_EVENT(ext3__write_end, ext3_ordered_write_end,
+
+       TP_PROTO(struct inode *inode, loff_t pos, unsigned int len,
+                unsigned int copied),
+
+       TP_ARGS(inode, pos, len, copied)
+)
+
+DEFINE_EVENT(ext3__write_end, ext3_writeback_write_end,
+
+       TP_PROTO(struct inode *inode, loff_t pos, unsigned int len,
+                unsigned int copied),
+
+       TP_ARGS(inode, pos, len, copied)
+)
+
+DEFINE_EVENT(ext3__write_end, ext3_journalled_write_end,
+
+       TP_PROTO(struct inode *inode, loff_t pos, unsigned int len,
+                unsigned int copied),
+
+       TP_ARGS(inode, pos, len, copied)
+)
+
+DECLARE_EVENT_CLASS(ext3__page_op,
+       TP_PROTO(struct page *page),
+
+       TP_ARGS(page),
+
+       TP_STRUCT__entry(
+               __field(        dev_t,  dev                     )
+               __field(        ino_t,  ino                     )
+               __field(        pgoff_t, index                  )
+
+       ),
+
+       TP_fast_assign(
+               tp_assign(index, page->index)
+               tp_assign(ino, page->mapping->host->i_ino)
+               tp_assign(dev, page->mapping->host->i_sb->s_dev)
+       ),
+
+       TP_printk("dev %d,%d ino %lu page_index %lu",
+                 MAJOR(__entry->dev), MINOR(__entry->dev),
+                 (unsigned long) __entry->ino, __entry->index)
+)
+
+DEFINE_EVENT(ext3__page_op, ext3_ordered_writepage,
+
+       TP_PROTO(struct page *page),
+
+       TP_ARGS(page)
+)
+
+DEFINE_EVENT(ext3__page_op, ext3_writeback_writepage,
+
+       TP_PROTO(struct page *page),
+
+       TP_ARGS(page)
+)
+
+DEFINE_EVENT(ext3__page_op, ext3_journalled_writepage,
+
+       TP_PROTO(struct page *page),
+
+       TP_ARGS(page)
+)
+
+DEFINE_EVENT(ext3__page_op, ext3_readpage,
+
+       TP_PROTO(struct page *page),
+
+       TP_ARGS(page)
+)
+
+DEFINE_EVENT(ext3__page_op, ext3_releasepage,
+
+       TP_PROTO(struct page *page),
+
+       TP_ARGS(page)
+)
+
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,11,0))
+
+TRACE_EVENT(ext3_invalidatepage,
+       TP_PROTO(struct page *page, unsigned int offset, unsigned int length),
+
+       TP_ARGS(page, offset, length),
+
+       TP_STRUCT__entry(
+               __field(        pgoff_t, index                  )
+               __field(        unsigned int, offset            )
+               __field(        unsigned int, length            )
+               __field(        ino_t,  ino                     )
+               __field(        dev_t,  dev                     )
+
+       ),
+
+       TP_fast_assign(
+               tp_assign(index, page->index)
+               tp_assign(offset, offset)
+               tp_assign(length, length)
+               tp_assign(ino, page->mapping->host->i_ino)
+               tp_assign(dev, page->mapping->host->i_sb->s_dev)
+       ),
+
+       TP_printk("dev %d,%d ino %lu page_index %lu offset %u length %u",
+                 MAJOR(__entry->dev), MINOR(__entry->dev),
+                 (unsigned long) __entry->ino,
+                 __entry->index, __entry->offset, __entry->length)
+)
+
+#else
+
+TRACE_EVENT(ext3_invalidatepage,
+       TP_PROTO(struct page *page, unsigned long offset),
+
+       TP_ARGS(page, offset),
+
+       TP_STRUCT__entry(
+               __field(        pgoff_t, index                  )
+               __field(        unsigned long, offset           )
+               __field(        ino_t,  ino                     )
+               __field(        dev_t,  dev                     )
+
+       ),
+
+       TP_fast_assign(
+               tp_assign(index, page->index)
+               tp_assign(offset, offset)
+               tp_assign(ino, page->mapping->host->i_ino)
+               tp_assign(dev, page->mapping->host->i_sb->s_dev)
+       ),
+
+       TP_printk("dev %d,%d ino %lu page_index %lu offset %lu",
+                 MAJOR(__entry->dev), MINOR(__entry->dev),
+                 (unsigned long) __entry->ino,
+                 __entry->index, __entry->offset)
+)
+
+#endif
+
+TRACE_EVENT(ext3_discard_blocks,
+       TP_PROTO(struct super_block *sb, unsigned long blk,
+                       unsigned long count),
+
+       TP_ARGS(sb, blk, count),
+
+       TP_STRUCT__entry(
+               __field(        dev_t,          dev             )
+               __field(        unsigned long,  blk             )
+               __field(        unsigned long,  count           )
+
+       ),
+
+       TP_fast_assign(
+               tp_assign(dev, sb->s_dev)
+               tp_assign(blk, blk)
+               tp_assign(count, count)
+       ),
+
+       TP_printk("dev %d,%d blk %lu count %lu",
+                 MAJOR(__entry->dev), MINOR(__entry->dev),
+                 __entry->blk, __entry->count)
+)
+
+TRACE_EVENT(ext3_request_blocks,
+       TP_PROTO(struct inode *inode, unsigned long goal,
+                unsigned long count),
+
+       TP_ARGS(inode, goal, count),
+
+       TP_STRUCT__entry(
+               __field(        dev_t,  dev                     )
+               __field(        ino_t,  ino                     )
+               __field(        unsigned long, count            )
+               __field(        unsigned long,  goal            )
+       ),
+
+       TP_fast_assign(
+               tp_assign(dev, inode->i_sb->s_dev)
+               tp_assign(ino, inode->i_ino)
+               tp_assign(count, count)
+               tp_assign(goal, goal)
+       ),
+
+       TP_printk("dev %d,%d ino %lu count %lu goal %lu ",
+                 MAJOR(__entry->dev), MINOR(__entry->dev),
+                 (unsigned long) __entry->ino,
+                 __entry->count, __entry->goal)
+)
+
+TRACE_EVENT(ext3_allocate_blocks,
+       TP_PROTO(struct inode *inode, unsigned long goal,
+                unsigned long count, unsigned long block),
+
+       TP_ARGS(inode, goal, count, block),
+
+       TP_STRUCT__entry(
+               __field(        dev_t,  dev                     )
+               __field(        ino_t,  ino                     )
+               __field(        unsigned long,  block           )
+               __field(        unsigned long, count            )
+               __field(        unsigned long,  goal            )
+       ),
+
+       TP_fast_assign(
+               tp_assign(dev, inode->i_sb->s_dev)
+               tp_assign(ino, inode->i_ino)
+               tp_assign(block, block)
+               tp_assign(count, count)
+               tp_assign(goal, goal)
+       ),
+
+       TP_printk("dev %d,%d ino %lu count %lu block %lu goal %lu",
+                 MAJOR(__entry->dev), MINOR(__entry->dev),
+                 (unsigned long) __entry->ino,
+                  __entry->count, __entry->block,
+                 __entry->goal)
+)
+
+TRACE_EVENT(ext3_free_blocks,
+       TP_PROTO(struct inode *inode, unsigned long block,
+                unsigned long count),
+
+       TP_ARGS(inode, block, count),
+
+       TP_STRUCT__entry(
+               __field(        dev_t,  dev                     )
+               __field(        ino_t,  ino                     )
+               __field(        umode_t, mode                   )
+               __field(        unsigned long,  block           )
+               __field(        unsigned long,  count           )
+       ),
+
+       TP_fast_assign(
+               tp_assign(dev, inode->i_sb->s_dev)
+               tp_assign(ino, inode->i_ino)
+               tp_assign(mode, inode->i_mode)
+               tp_assign(block, block)
+               tp_assign(count, count)
+       ),
+
+       TP_printk("dev %d,%d ino %lu mode 0%o block %lu count %lu",
+                 MAJOR(__entry->dev), MINOR(__entry->dev),
+                 (unsigned long) __entry->ino,
+                 __entry->mode, __entry->block, __entry->count)
+)
+
+TRACE_EVENT(ext3_sync_file_enter,
+       TP_PROTO(struct file *file, int datasync),
+
+       TP_ARGS(file, datasync),
+
+       TP_STRUCT__entry(
+               __field(        dev_t,  dev                     )
+               __field(        ino_t,  ino                     )
+               __field(        ino_t,  parent                  )
+               __field(        int,    datasync                )
+       ),
+
+       TP_fast_assign(
+               tp_assign(dev, file->f_path.dentry->d_inode->i_sb->s_dev)
+               tp_assign(ino, file->f_path.dentry->d_inode->i_ino)
+               tp_assign(datasync, datasync)
+               tp_assign(parent, file->f_path.dentry->d_parent->d_inode->i_ino)
+       ),
+
+       TP_printk("dev %d,%d ino %lu parent %ld datasync %d ",
+                 MAJOR(__entry->dev), MINOR(__entry->dev),
+                 (unsigned long) __entry->ino,
+                 (unsigned long) __entry->parent, __entry->datasync)
+)
+
+TRACE_EVENT(ext3_sync_file_exit,
+       TP_PROTO(struct inode *inode, int ret),
+
+       TP_ARGS(inode, ret),
+
+       TP_STRUCT__entry(
+               __field(        int,    ret                     )
+               __field(        ino_t,  ino                     )
+               __field(        dev_t,  dev                     )
+       ),
+
+       TP_fast_assign(
+               tp_assign(ret, ret)
+               tp_assign(ino, inode->i_ino)
+               tp_assign(dev, inode->i_sb->s_dev)
+       ),
+
+       TP_printk("dev %d,%d ino %lu ret %d",
+                 MAJOR(__entry->dev), MINOR(__entry->dev),
+                 (unsigned long) __entry->ino,
+                 __entry->ret)
+)
+
+TRACE_EVENT(ext3_sync_fs,
+       TP_PROTO(struct super_block *sb, int wait),
+
+       TP_ARGS(sb, wait),
+
+       TP_STRUCT__entry(
+               __field(        dev_t,  dev                     )
+               __field(        int,    wait                    )
+
+       ),
+
+       TP_fast_assign(
+               tp_assign(dev, sb->s_dev)
+               tp_assign(wait, wait)
+       ),
+
+       TP_printk("dev %d,%d wait %d",
+                 MAJOR(__entry->dev), MINOR(__entry->dev),
+                 __entry->wait)
+)
+
+TRACE_EVENT(ext3_rsv_window_add,
+       TP_PROTO(struct super_block *sb,
+                struct ext3_reserve_window_node *rsv_node),
+
+       TP_ARGS(sb, rsv_node),
+
+       TP_STRUCT__entry(
+               __field(        unsigned long,  start           )
+               __field(        unsigned long,  end             )
+               __field(        dev_t,  dev                     )
+       ),
+
+       TP_fast_assign(
+               tp_assign(dev, sb->s_dev)
+               tp_assign(start, rsv_node->rsv_window._rsv_start)
+               tp_assign(end, rsv_node->rsv_window._rsv_end)
+       ),
+
+       TP_printk("dev %d,%d start %lu end %lu",
+                 MAJOR(__entry->dev), MINOR(__entry->dev),
+                 __entry->start, __entry->end)
+)
+
+TRACE_EVENT(ext3_discard_reservation,
+       TP_PROTO(struct inode *inode,
+                struct ext3_reserve_window_node *rsv_node),
+
+       TP_ARGS(inode, rsv_node),
+
+       TP_STRUCT__entry(
+               __field(        unsigned long,  start           )
+               __field(        unsigned long,  end             )
+               __field(        ino_t,  ino                     )
+               __field(        dev_t,  dev                     )
+       ),
+
+       TP_fast_assign(
+               tp_assign(start, rsv_node->rsv_window._rsv_start)
+               tp_assign(end, rsv_node->rsv_window._rsv_end)
+               tp_assign(ino, inode->i_ino)
+               tp_assign(dev, inode->i_sb->s_dev)
+       ),
+
+       TP_printk("dev %d,%d ino %lu start %lu end %lu",
+                 MAJOR(__entry->dev), MINOR(__entry->dev),
+                 (unsigned long)__entry->ino, __entry->start,
+                 __entry->end)
+)
+
+TRACE_EVENT(ext3_alloc_new_reservation,
+       TP_PROTO(struct super_block *sb, unsigned long goal),
+
+       TP_ARGS(sb, goal),
+
+       TP_STRUCT__entry(
+               __field(        dev_t,  dev                     )
+               __field(        unsigned long,  goal            )
+       ),
+
+       TP_fast_assign(
+               tp_assign(dev, sb->s_dev)
+               tp_assign(goal, goal)
+       ),
+
+       TP_printk("dev %d,%d goal %lu",
+                 MAJOR(__entry->dev), MINOR(__entry->dev),
+                 __entry->goal)
+)
+
+TRACE_EVENT(ext3_reserved,
+       TP_PROTO(struct super_block *sb, unsigned long block,
+                struct ext3_reserve_window_node *rsv_node),
+
+       TP_ARGS(sb, block, rsv_node),
+
+       TP_STRUCT__entry(
+               __field(        unsigned long,  block           )
+               __field(        unsigned long,  start           )
+               __field(        unsigned long,  end             )
+               __field(        dev_t,  dev                     )
+       ),
+
+       TP_fast_assign(
+               tp_assign(block, block)
+               tp_assign(start, rsv_node->rsv_window._rsv_start)
+               tp_assign(end, rsv_node->rsv_window._rsv_end)
+               tp_assign(dev, sb->s_dev)
+       ),
+
+       TP_printk("dev %d,%d block %lu, start %lu end %lu",
+                 MAJOR(__entry->dev), MINOR(__entry->dev),
+                 __entry->block, __entry->start, __entry->end)
+)
+
+TRACE_EVENT(ext3_forget,
+       TP_PROTO(struct inode *inode, int is_metadata, unsigned long block),
+
+       TP_ARGS(inode, is_metadata, block),
+
+       TP_STRUCT__entry(
+               __field(        dev_t,  dev                     )
+               __field(        ino_t,  ino                     )
+               __field(        umode_t, mode                   )
+               __field(        int,    is_metadata             )
+               __field(        unsigned long,  block           )
+       ),
+
+       TP_fast_assign(
+               tp_assign(dev, inode->i_sb->s_dev)
+               tp_assign(ino, inode->i_ino)
+               tp_assign(mode, inode->i_mode)
+               tp_assign(is_metadata, is_metadata)
+               tp_assign(block, block)
+       ),
+
+       TP_printk("dev %d,%d ino %lu mode 0%o is_metadata %d block %lu",
+                 MAJOR(__entry->dev), MINOR(__entry->dev),
+                 (unsigned long) __entry->ino,
+                 __entry->mode, __entry->is_metadata, __entry->block)
+)
+
+TRACE_EVENT(ext3_read_block_bitmap,
+       TP_PROTO(struct super_block *sb, unsigned int group),
+
+       TP_ARGS(sb, group),
+
+       TP_STRUCT__entry(
+               __field(        dev_t,  dev                     )
+               __field(        __u32,  group                   )
+
+       ),
+
+       TP_fast_assign(
+               tp_assign(dev, sb->s_dev)
+               tp_assign(group, group)
+       ),
+
+       TP_printk("dev %d,%d group %u",
+                 MAJOR(__entry->dev), MINOR(__entry->dev),
+                 __entry->group)
+)
+
+TRACE_EVENT(ext3_direct_IO_enter,
+       TP_PROTO(struct inode *inode, loff_t offset, unsigned long len, int rw),
+
+       TP_ARGS(inode, offset, len, rw),
+
+       TP_STRUCT__entry(
+               __field(        ino_t,  ino                     )
+               __field(        dev_t,  dev                     )
+               __field(        loff_t, pos                     )
+               __field(        unsigned long,  len             )
+               __field(        int,    rw                      )
+       ),
+
+       TP_fast_assign(
+               tp_assign(ino, inode->i_ino)
+               tp_assign(dev, inode->i_sb->s_dev)
+               tp_assign(pos, offset)
+               tp_assign(len, len)
+               tp_assign(rw, rw)
+       ),
+
+       TP_printk("dev %d,%d ino %lu pos %llu len %lu rw %d",
+                 MAJOR(__entry->dev), MINOR(__entry->dev),
+                 (unsigned long) __entry->ino,
+                 (unsigned long long) __entry->pos, __entry->len,
+                 __entry->rw)
+)
+
+TRACE_EVENT(ext3_direct_IO_exit,
+       TP_PROTO(struct inode *inode, loff_t offset, unsigned long len,
+                int rw, int ret),
+
+       TP_ARGS(inode, offset, len, rw, ret),
+
+       TP_STRUCT__entry(
+               __field(        ino_t,  ino                     )
+               __field(        dev_t,  dev                     )
+               __field(        loff_t, pos                     )
+               __field(        unsigned long,  len             )
+               __field(        int,    rw                      )
+               __field(        int,    ret                     )
+       ),
+
+       TP_fast_assign(
+               tp_assign(ino, inode->i_ino)
+               tp_assign(dev, inode->i_sb->s_dev)
+               tp_assign(pos, offset)
+               tp_assign(len, len)
+               tp_assign(rw, rw)
+               tp_assign(ret, ret)
+       ),
+
+       TP_printk("dev %d,%d ino %lu pos %llu len %lu rw %d ret %d",
+                 MAJOR(__entry->dev), MINOR(__entry->dev),
+                 (unsigned long) __entry->ino,
+                 (unsigned long long) __entry->pos, __entry->len,
+                 __entry->rw, __entry->ret)
+)
+
+TRACE_EVENT(ext3_unlink_enter,
+       TP_PROTO(struct inode *parent, struct dentry *dentry),
+
+       TP_ARGS(parent, dentry),
+
+       TP_STRUCT__entry(
+               __field(        ino_t,  parent                  )
+               __field(        ino_t,  ino                     )
+               __field(        loff_t, size                    )
+               __field(        dev_t,  dev                     )
+       ),
+
+       TP_fast_assign(
+               tp_assign(parent, parent->i_ino)
+               tp_assign(ino, dentry->d_inode->i_ino)
+               tp_assign(size, dentry->d_inode->i_size)
+               tp_assign(dev, dentry->d_inode->i_sb->s_dev)
+       ),
+
+       TP_printk("dev %d,%d ino %lu size %lld parent %ld",
+                 MAJOR(__entry->dev), MINOR(__entry->dev),
+                 (unsigned long) __entry->ino,
+                 (unsigned long long)__entry->size,
+                 (unsigned long) __entry->parent)
+)
+
+TRACE_EVENT(ext3_unlink_exit,
+       TP_PROTO(struct dentry *dentry, int ret),
+
+       TP_ARGS(dentry, ret),
+
+       TP_STRUCT__entry(
+               __field(        ino_t,  ino                     )
+               __field(        dev_t,  dev                     )
+               __field(        int,    ret                     )
+       ),
+
+       TP_fast_assign(
+               tp_assign(ino, dentry->d_inode->i_ino)
+               tp_assign(dev, dentry->d_inode->i_sb->s_dev)
+               tp_assign(ret, ret)
+       ),
+
+       TP_printk("dev %d,%d ino %lu ret %d",
+                 MAJOR(__entry->dev), MINOR(__entry->dev),
+                 (unsigned long) __entry->ino,
+                 __entry->ret)
+)
+
+DECLARE_EVENT_CLASS(ext3__truncate,
+       TP_PROTO(struct inode *inode),
+
+       TP_ARGS(inode),
+
+       TP_STRUCT__entry(
+               __field(        ino_t,          ino             )
+               __field(        dev_t,          dev             )
+               __field(        blkcnt_t,       blocks          )
+       ),
+
+       TP_fast_assign(
+               tp_assign(ino, inode->i_ino)
+               tp_assign(dev, inode->i_sb->s_dev)
+               tp_assign(blocks, inode->i_blocks)
+       ),
+
+       TP_printk("dev %d,%d ino %lu blocks %lu",
+                 MAJOR(__entry->dev), MINOR(__entry->dev),
+                 (unsigned long) __entry->ino, (unsigned long) __entry->blocks)
+)
+
+DEFINE_EVENT(ext3__truncate, ext3_truncate_enter,
+
+       TP_PROTO(struct inode *inode),
+
+       TP_ARGS(inode)
+)
+
+DEFINE_EVENT(ext3__truncate, ext3_truncate_exit,
+
+       TP_PROTO(struct inode *inode),
+
+       TP_ARGS(inode)
+)
+
+TRACE_EVENT(ext3_get_blocks_enter,
+       TP_PROTO(struct inode *inode, unsigned long lblk,
+                unsigned long len, int create),
+
+       TP_ARGS(inode, lblk, len, create),
+
+       TP_STRUCT__entry(
+               __field(        ino_t,          ino             )
+               __field(        dev_t,          dev             )
+               __field(        unsigned long,  lblk            )
+               __field(        unsigned long,  len             )
+               __field(        int,            create          )
+       ),
+
+       TP_fast_assign(
+               tp_assign(ino, inode->i_ino)
+               tp_assign(dev, inode->i_sb->s_dev)
+               tp_assign(lblk, lblk)
+               tp_assign(len, len)
+               tp_assign(create, create)
+       ),
+
+       TP_printk("dev %d,%d ino %lu lblk %lu len %lu create %u",
+                 MAJOR(__entry->dev), MINOR(__entry->dev),
+                 (unsigned long) __entry->ino,
+                 __entry->lblk, __entry->len, __entry->create)
+)
+
+TRACE_EVENT(ext3_get_blocks_exit,
+       TP_PROTO(struct inode *inode, unsigned long lblk,
+                unsigned long pblk, unsigned long len, int ret),
+
+       TP_ARGS(inode, lblk, pblk, len, ret),
+
+       TP_STRUCT__entry(
+               __field(        ino_t,          ino             )
+               __field(        dev_t,          dev             )
+               __field(        unsigned long,  lblk            )
+               __field(        unsigned long,  pblk            )
+               __field(        unsigned long,  len             )
+               __field(        int,            ret             )
+       ),
+
+       TP_fast_assign(
+               tp_assign(ino, inode->i_ino)
+               tp_assign(dev, inode->i_sb->s_dev)
+               tp_assign(lblk, lblk)
+               tp_assign(pblk, pblk)
+               tp_assign(len, len)
+               tp_assign(ret, ret)
+       ),
+
+       TP_printk("dev %d,%d ino %lu lblk %lu pblk %lu len %lu ret %d",
+                 MAJOR(__entry->dev), MINOR(__entry->dev),
+                 (unsigned long) __entry->ino,
+                  __entry->lblk, __entry->pblk,
+                 __entry->len, __entry->ret)
+)
+
+TRACE_EVENT(ext3_load_inode,
+       TP_PROTO(struct inode *inode),
+
+       TP_ARGS(inode),
+
+       TP_STRUCT__entry(
+               __field(        ino_t,  ino             )
+               __field(        dev_t,  dev             )
+       ),
+
+       TP_fast_assign(
+               tp_assign(ino, inode->i_ino)
+               tp_assign(dev, inode->i_sb->s_dev)
+       ),
+
+       TP_printk("dev %d,%d ino %lu",
+                 MAJOR(__entry->dev), MINOR(__entry->dev),
+                 (unsigned long) __entry->ino)
+)
+
+#endif /* _TRACE_EXT3_H */
+
+/* This part must be outside protection */
+#include "../../../probes/define_trace.h"
diff --git a/drivers/staging/lttng/instrumentation/events/lttng-module/ext4.h b/drivers/staging/lttng/instrumentation/events/lttng-module/ext4.h
new file mode 100644 (file)
index 0000000..d742904
--- /dev/null
@@ -0,0 +1,3130 @@
+#undef TRACE_SYSTEM
+#define TRACE_SYSTEM ext4
+
+#if !defined(_TRACE_EXT4_H) || defined(TRACE_HEADER_MULTI_READ)
+#define _TRACE_EXT4_H
+
+#include <linux/writeback.h>
+#include <linux/tracepoint.h>
+#include <linux/version.h>
+
+#ifndef _TRACE_EXT4_DEF_
+#define _TRACE_EXT4_DEF_
+struct ext4_allocation_context;
+struct ext4_allocation_request;
+struct ext4_prealloc_space;
+struct ext4_inode_info;
+struct mpage_da_data;
+struct ext4_map_blocks;
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,2,0))
+struct ext4_extent;
+#endif
+#endif
+
+#define EXT4_I(inode) (container_of(inode, struct ext4_inode_info, vfs_inode))
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,1,0))
+#define TP_MODE_T      __u16
+#else
+#define TP_MODE_T      umode_t
+#endif
+
+TRACE_EVENT(ext4_free_inode,
+       TP_PROTO(struct inode *inode),
+
+       TP_ARGS(inode),
+
+       TP_STRUCT__entry(
+               __field(        dev_t,  dev                     )
+               __field(        ino_t,  ino                     )
+               __field(        uid_t,  uid                     )
+               __field(        gid_t,  gid                     )
+               __field(        __u64, blocks                   )
+               __field(        TP_MODE_T, mode                 )
+       ),
+
+       TP_fast_assign(
+               tp_assign(dev, inode->i_sb->s_dev)
+               tp_assign(ino, inode->i_ino)
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,5,0))
+               tp_assign(uid, i_uid_read(inode))
+               tp_assign(gid, i_gid_read(inode))
+#else
+               tp_assign(uid, inode->i_uid)
+               tp_assign(gid, inode->i_gid)
+#endif
+               tp_assign(blocks, inode->i_blocks)
+               tp_assign(mode, inode->i_mode)
+       ),
+
+       TP_printk("dev %d,%d ino %lu mode 0%o uid %u gid %u blocks %llu",
+                 MAJOR(__entry->dev), MINOR(__entry->dev),
+                 (unsigned long) __entry->ino, __entry->mode,
+                 __entry->uid, __entry->gid, __entry->blocks)
+)
+
+TRACE_EVENT(ext4_request_inode,
+       TP_PROTO(struct inode *dir, int mode),
+
+       TP_ARGS(dir, mode),
+
+       TP_STRUCT__entry(
+               __field(        dev_t,  dev                     )
+               __field(        ino_t,  dir                     )
+               __field(        TP_MODE_T, mode                 )
+       ),
+
+       TP_fast_assign(
+               tp_assign(dev, dir->i_sb->s_dev)
+               tp_assign(dir, dir->i_ino)
+               tp_assign(mode, mode)
+       ),
+
+       TP_printk("dev %d,%d dir %lu mode 0%o",
+                 MAJOR(__entry->dev), MINOR(__entry->dev),
+                 (unsigned long) __entry->dir, __entry->mode)
+)
+
+TRACE_EVENT(ext4_allocate_inode,
+       TP_PROTO(struct inode *inode, struct inode *dir, int mode),
+
+       TP_ARGS(inode, dir, mode),
+
+       TP_STRUCT__entry(
+               __field(        dev_t,  dev                     )
+               __field(        ino_t,  ino                     )
+               __field(        ino_t,  dir                     )
+               __field(        TP_MODE_T, mode                 )
+       ),
+
+       TP_fast_assign(
+               tp_assign(dev, inode->i_sb->s_dev)
+               tp_assign(ino, inode->i_ino)
+               tp_assign(dir, dir->i_ino)
+               tp_assign(mode, mode)
+       ),
+
+       TP_printk("dev %d,%d ino %lu dir %lu mode 0%o",
+                 MAJOR(__entry->dev), MINOR(__entry->dev),
+                 (unsigned long) __entry->ino,
+                 (unsigned long) __entry->dir, __entry->mode)
+)
+
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,37))
+TRACE_EVENT(ext4_evict_inode,
+       TP_PROTO(struct inode *inode),
+
+       TP_ARGS(inode),
+
+       TP_STRUCT__entry(
+               __field(        dev_t,  dev                     )
+               __field(        ino_t,  ino                     )
+               __field(        int,    nlink                   )
+       ),
+
+       TP_fast_assign(
+               tp_assign(dev, inode->i_sb->s_dev)
+               tp_assign(ino, inode->i_ino)
+               tp_assign(nlink, inode->i_nlink)
+       ),
+
+       TP_printk("dev %d,%d ino %lu nlink %d",
+                 MAJOR(__entry->dev), MINOR(__entry->dev),
+                 (unsigned long) __entry->ino, __entry->nlink)
+)
+
+TRACE_EVENT(ext4_drop_inode,
+       TP_PROTO(struct inode *inode, int drop),
+
+       TP_ARGS(inode, drop),
+
+       TP_STRUCT__entry(
+               __field(        dev_t,  dev                     )
+               __field(        ino_t,  ino                     )
+               __field(        int,    drop                    )
+       ),
+
+       TP_fast_assign(
+               tp_assign(dev, inode->i_sb->s_dev)
+               tp_assign(ino, inode->i_ino)
+               tp_assign(drop, drop)
+       ),
+
+       TP_printk("dev %d,%d ino %lu drop %d",
+                 MAJOR(__entry->dev), MINOR(__entry->dev),
+                 (unsigned long) __entry->ino, __entry->drop)
+)
+
+TRACE_EVENT(ext4_mark_inode_dirty,
+       TP_PROTO(struct inode *inode, unsigned long IP),
+
+       TP_ARGS(inode, IP),
+
+       TP_STRUCT__entry(
+               __field(        dev_t,  dev                     )
+               __field(        ino_t,  ino                     )
+               __field(unsigned long,  ip                      )
+       ),
+
+       TP_fast_assign(
+               tp_assign(dev, inode->i_sb->s_dev)
+               tp_assign(ino, inode->i_ino)
+               tp_assign(ip, IP)
+       ),
+
+       TP_printk("dev %d,%d ino %lu caller %pF",
+                 MAJOR(__entry->dev), MINOR(__entry->dev),
+                 (unsigned long) __entry->ino, (void *)__entry->ip)
+)
+
+TRACE_EVENT(ext4_begin_ordered_truncate,
+       TP_PROTO(struct inode *inode, loff_t new_size),
+
+       TP_ARGS(inode, new_size),
+
+       TP_STRUCT__entry(
+               __field(        dev_t,  dev                     )
+               __field(        ino_t,  ino                     )
+               __field(        loff_t, new_size                )
+       ),
+
+       TP_fast_assign(
+               tp_assign(dev, inode->i_sb->s_dev)
+               tp_assign(ino, inode->i_ino)
+               tp_assign(new_size, new_size)
+       ),
+
+       TP_printk("dev %d,%d ino %lu new_size %lld",
+                 MAJOR(__entry->dev), MINOR(__entry->dev),
+                 (unsigned long) __entry->ino,
+                 __entry->new_size)
+)
+#endif
+
+DECLARE_EVENT_CLASS(ext4__write_begin,
+
+       TP_PROTO(struct inode *inode, loff_t pos, unsigned int len,
+                unsigned int flags),
+
+       TP_ARGS(inode, pos, len, flags),
+
+       TP_STRUCT__entry(
+               __field(        dev_t,  dev                     )
+               __field(        ino_t,  ino                     )
+               __field(        loff_t, pos                     )
+               __field(        unsigned int, len               )
+               __field(        unsigned int, flags             )
+       ),
+
+       TP_fast_assign(
+               tp_assign(dev, inode->i_sb->s_dev)
+               tp_assign(ino, inode->i_ino)
+               tp_assign(pos, pos)
+               tp_assign(len, len)
+               tp_assign(flags, flags)
+       ),
+
+       TP_printk("dev %d,%d ino %lu pos %lld len %u flags %u",
+                 MAJOR(__entry->dev), MINOR(__entry->dev),
+                 (unsigned long) __entry->ino,
+                 __entry->pos, __entry->len, __entry->flags)
+)
+
+DEFINE_EVENT(ext4__write_begin, ext4_write_begin,
+
+       TP_PROTO(struct inode *inode, loff_t pos, unsigned int len,
+                unsigned int flags),
+
+       TP_ARGS(inode, pos, len, flags)
+)
+
+DEFINE_EVENT(ext4__write_begin, ext4_da_write_begin,
+
+       TP_PROTO(struct inode *inode, loff_t pos, unsigned int len,
+                unsigned int flags),
+
+       TP_ARGS(inode, pos, len, flags)
+)
+
+DECLARE_EVENT_CLASS(ext4__write_end,
+       TP_PROTO(struct inode *inode, loff_t pos, unsigned int len,
+                       unsigned int copied),
+
+       TP_ARGS(inode, pos, len, copied),
+
+       TP_STRUCT__entry(
+               __field(        dev_t,  dev                     )
+               __field(        ino_t,  ino                     )
+               __field(        loff_t, pos                     )
+               __field(        unsigned int, len               )
+               __field(        unsigned int, copied            )
+       ),
+
+       TP_fast_assign(
+               tp_assign(dev, inode->i_sb->s_dev)
+               tp_assign(ino, inode->i_ino)
+               tp_assign(pos, pos)
+               tp_assign(len, len)
+               tp_assign(copied, copied)
+       ),
+
+       TP_printk("dev %d,%d ino %lu pos %lld len %u copied %u",
+                 MAJOR(__entry->dev), MINOR(__entry->dev),
+                 (unsigned long) __entry->ino,
+                 __entry->pos, __entry->len, __entry->copied)
+)
+
+DEFINE_EVENT(ext4__write_end, ext4_ordered_write_end,
+
+       TP_PROTO(struct inode *inode, loff_t pos, unsigned int len,
+                unsigned int copied),
+
+       TP_ARGS(inode, pos, len, copied)
+)
+
+DEFINE_EVENT(ext4__write_end, ext4_writeback_write_end,
+
+       TP_PROTO(struct inode *inode, loff_t pos, unsigned int len,
+                unsigned int copied),
+
+       TP_ARGS(inode, pos, len, copied)
+)
+
+DEFINE_EVENT(ext4__write_end, ext4_journalled_write_end,
+
+       TP_PROTO(struct inode *inode, loff_t pos, unsigned int len,
+                unsigned int copied),
+
+       TP_ARGS(inode, pos, len, copied)
+)
+
+DEFINE_EVENT(ext4__write_end, ext4_da_write_end,
+
+       TP_PROTO(struct inode *inode, loff_t pos, unsigned int len,
+                unsigned int copied),
+
+       TP_ARGS(inode, pos, len, copied)
+)
+
+#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,40))
+TRACE_EVENT(ext4_writepage,
+       TP_PROTO(struct inode *inode, struct page *page),
+
+       TP_ARGS(inode, page),
+
+       TP_STRUCT__entry(
+               __field(        dev_t,  dev                     )
+               __field(        ino_t,  ino                     )
+               __field(        pgoff_t, index                  )
+
+       ),
+
+       TP_fast_assign(
+               tp_assign(dev, inode->i_sb->s_dev)
+               tp_assign(ino, inode->i_ino)
+               tp_assign(index, page->index)
+       ),
+
+       TP_printk("dev %d,%d ino %lu page_index %lu",
+                 MAJOR(__entry->dev), MINOR(__entry->dev),
+                 (unsigned long) __entry->ino, __entry->index)
+)
+#endif
+
+TRACE_EVENT(ext4_da_writepages,
+       TP_PROTO(struct inode *inode, struct writeback_control *wbc),
+
+       TP_ARGS(inode, wbc),
+
+       TP_STRUCT__entry(
+               __field(        dev_t,  dev                     )
+               __field(        ino_t,  ino                     )
+               __field(        long,   nr_to_write             )
+               __field(        long,   pages_skipped           )
+               __field(        loff_t, range_start             )
+               __field(        loff_t, range_end               )
+               __field(       pgoff_t, writeback_index         )
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,39))
+               __field(        int,    sync_mode               )
+#endif
+#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,37))
+               __field(        char,   nonblocking             )
+#endif
+               __field(        char,   for_kupdate             )
+#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,39))
+               __field(        char,   for_reclaim             )
+#endif
+               __field(        char,   range_cyclic            )
+       ),
+
+       TP_fast_assign(
+               tp_assign(dev, inode->i_sb->s_dev)
+               tp_assign(ino, inode->i_ino)
+               tp_assign(nr_to_write, wbc->nr_to_write)
+               tp_assign(pages_skipped, wbc->pages_skipped)
+               tp_assign(range_start, wbc->range_start)
+               tp_assign(range_end, wbc->range_end)
+               tp_assign(writeback_index, inode->i_mapping->writeback_index)
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,39))
+               tp_assign(sync_mode, wbc->sync_mode)
+#endif
+#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,37))
+               tp_assign(nonblocking, wbc->nonblocking)
+#endif
+               tp_assign(for_kupdate, wbc->for_kupdate)
+#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,39))
+               tp_assign(for_reclaim, wbc->for_reclaim)
+#endif
+               tp_assign(range_cyclic, wbc->range_cyclic)
+       ),
+
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,39))
+       TP_printk("dev %d,%d ino %lu nr_to_write %ld pages_skipped %ld "
+                 "range_start %lld range_end %lld sync_mode %d "
+                 "for_kupdate %d range_cyclic %d writeback_index %lu",
+#elif (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,37))
+       TP_printk("dev %d,%d ino %lu nr_to_write %ld pages_skipped %ld "
+                 "range_start %llu range_end %llu "
+                 "for_kupdate %d for_reclaim %d "
+                 "range_cyclic %d writeback_index %lu",
+#else
+       TP_printk("dev %d,%d ino %lu nr_to_write %ld pages_skipped %ld "
+                 "range_start %llu range_end %llu "
+                 "nonblocking %d for_kupdate %d for_reclaim %d "
+                 "range_cyclic %d writeback_index %lu",
+#endif
+                 MAJOR(__entry->dev), MINOR(__entry->dev),
+                 (unsigned long) __entry->ino, __entry->nr_to_write,
+                 __entry->pages_skipped, __entry->range_start,
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,39))
+                 __entry->range_end, __entry->sync_mode,
+                 __entry->for_kupdate, __entry->range_cyclic,
+#elif (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,37))
+                 __entry->range_end,
+                 __entry->for_kupdate, __entry->for_reclaim,
+                 __entry->range_cyclic,
+#else
+                 __entry->range_end, __entry->nonblocking,
+                 __entry->for_kupdate, __entry->for_reclaim,
+                 __entry->range_cyclic,
+#endif
+                 (unsigned long) __entry->writeback_index)
+)
+
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,11,0))
+
+TRACE_EVENT(ext4_da_write_pages,
+       TP_PROTO(struct inode *inode, pgoff_t first_page,
+                struct writeback_control *wbc),
+
+       TP_ARGS(inode, first_page, wbc),
+
+       TP_STRUCT__entry(
+               __field(        dev_t,  dev                     )
+               __field(        ino_t,  ino                     )
+               __field(      pgoff_t,  first_page              )
+               __field(         long,  nr_to_write             )
+               __field(          int,  sync_mode               )
+       ),
+
+       TP_fast_assign(
+               tp_assign(dev, inode->i_sb->s_dev)
+               tp_assign(ino, inode->i_ino)
+               tp_assign(first_page, first_page)
+               tp_assign(nr_to_write, wbc->nr_to_write)
+               tp_assign(sync_mode, wbc->sync_mode)
+       ),
+
+       TP_printk("dev %d,%d ino %lu first_page %lu nr_to_write %ld "
+                 "sync_mode %d",
+                 MAJOR(__entry->dev), MINOR(__entry->dev),
+                 (unsigned long) __entry->ino, __entry->first_page,
+                 __entry->nr_to_write, __entry->sync_mode)
+)
+
+#else
+
+TRACE_EVENT(ext4_da_write_pages,
+       TP_PROTO(struct inode *inode, struct mpage_da_data *mpd),
+
+       TP_ARGS(inode, mpd),
+
+       TP_STRUCT__entry(
+               __field(        dev_t,  dev                     )
+               __field(        ino_t,  ino                     )
+               __field(        __u64,  b_blocknr               )
+               __field(        __u32,  b_size                  )
+               __field(        __u32,  b_state                 )
+               __field(        unsigned long,  first_page      )
+               __field(        int,    io_done                 )
+               __field(        int,    pages_written           )
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,39))
+               __field(        int,    sync_mode               )
+#endif
+       ),
+
+       TP_fast_assign(
+               tp_assign(dev, inode->i_sb->s_dev)
+               tp_assign(ino, inode->i_ino)
+               tp_assign(b_blocknr, mpd->b_blocknr)
+               tp_assign(b_size, mpd->b_size)
+               tp_assign(b_state, mpd->b_state)
+               tp_assign(first_page, mpd->first_page)
+               tp_assign(io_done, mpd->io_done)
+               tp_assign(pages_written, mpd->pages_written)
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,39))
+               tp_assign(sync_mode, mpd->wbc->sync_mode)
+#endif
+       ),
+
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,39))
+       TP_printk("dev %d,%d ino %lu b_blocknr %llu b_size %u b_state 0x%04x "
+                 "first_page %lu io_done %d pages_written %d sync_mode %d",
+#else
+       TP_printk("dev %d,%d ino %lu b_blocknr %llu b_size %u b_state 0x%04x "
+                 "first_page %lu io_done %d pages_written %d",
+#endif
+                 MAJOR(__entry->dev), MINOR(__entry->dev),
+                 (unsigned long) __entry->ino,
+                 __entry->b_blocknr, __entry->b_size,
+                 __entry->b_state, __entry->first_page,
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,39))
+                 __entry->io_done, __entry->pages_written,
+                 __entry->sync_mode
+#else
+                 __entry->io_done, __entry->pages_written
+#endif
+                  )
+)
+
+#endif
+
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,11,0))
+
+TRACE_EVENT(ext4_da_write_pages_extent,
+       TP_PROTO(struct inode *inode, struct ext4_map_blocks *map),
+
+       TP_ARGS(inode, map),
+
+       TP_STRUCT__entry(
+               __field(        dev_t,  dev                     )
+               __field(        ino_t,  ino                     )
+               __field(        __u64,  lblk                    )
+               __field(        __u32,  len                     )
+               __field(        __u32,  flags                   )
+       ),
+
+       TP_fast_assign(
+               tp_assign(dev, inode->i_sb->s_dev)
+               tp_assign(ino, inode->i_ino)
+               tp_assign(lblk, map->m_lblk)
+               tp_assign(len, map->m_len)
+               tp_assign(flags, map->m_flags)
+       ),
+
+       TP_printk("dev %d,%d ino %lu lblk %llu len %u flags %s",
+                 MAJOR(__entry->dev), MINOR(__entry->dev),
+                 (unsigned long) __entry->ino, __entry->lblk, __entry->len,
+                 show_mflags(__entry->flags))
+)
+
+#endif
+
+TRACE_EVENT(ext4_da_writepages_result,
+       TP_PROTO(struct inode *inode, struct writeback_control *wbc,
+                       int ret, int pages_written),
+
+       TP_ARGS(inode, wbc, ret, pages_written),
+
+       TP_STRUCT__entry(
+               __field(        dev_t,  dev                     )
+               __field(        ino_t,  ino                     )
+               __field(        int,    ret                     )
+               __field(        int,    pages_written           )
+               __field(        long,   pages_skipped           )
+               __field(       pgoff_t, writeback_index         )
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,39))
+               __field(        int,    sync_mode               )
+#endif
+#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,33))
+               __field(        char,   encountered_congestion  )
+#endif
+#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,1,0))
+               __field(        char,   more_io                 )
+#endif
+#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,35))
+               __field(        char,   no_nrwrite_index_update )
+#endif
+       ),
+
+       TP_fast_assign(
+               tp_assign(dev, inode->i_sb->s_dev)
+               tp_assign(ino, inode->i_ino)
+               tp_assign(ret, ret)
+               tp_assign(pages_written, pages_written)
+               tp_assign(pages_skipped, wbc->pages_skipped)
+               tp_assign(writeback_index, inode->i_mapping->writeback_index)
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,39))
+               tp_assign(sync_mode, wbc->sync_mode)
+#endif
+#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,33))
+               tp_assign(encountered_congestion, wbc->encountered_congestion)
+#endif
+#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,1,0))
+               tp_assign(more_io, wbc->more_io)
+#endif
+#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,35))
+               tp_assign(no_nrwrite_index_update, wbc->no_nrwrite_index_update)
+#endif
+       ),
+
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,1,0))
+       TP_printk("dev %d,%d ino %lu ret %d pages_written %d pages_skipped %ld "
+                 "sync_mode %d writeback_index %lu",
+                 MAJOR(__entry->dev), MINOR(__entry->dev),
+                 (unsigned long) __entry->ino, __entry->ret,
+                 __entry->pages_written, __entry->pages_skipped,
+                 __entry->sync_mode,
+                 (unsigned long) __entry->writeback_index)
+#elif (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,39))
+       TP_printk("dev %d,%d ino %lu ret %d pages_written %d pages_skipped %ld "
+                 " more_io %d sync_mode %d writeback_index %lu",
+                 MAJOR(__entry->dev), MINOR(__entry->dev),
+                 (unsigned long) __entry->ino, __entry->ret,
+                 __entry->pages_written, __entry->pages_skipped,
+                 __entry->more_io, __entry->sync_mode,
+                 (unsigned long) __entry->writeback_index)
+#elif (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,35))
+       TP_printk("dev %d,%d ino %lu ret %d pages_written %d pages_skipped %ld "
+                 " more_io %d writeback_index %lu",
+                 MAJOR(__entry->dev), MINOR(__entry->dev),
+                 (unsigned long) __entry->ino, __entry->ret,
+                 __entry->pages_written, __entry->pages_skipped,
+                 __entry->more_io,
+                 (unsigned long) __entry->writeback_index)
+#elif (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,33))
+       TP_printk("dev %d,%d ino %lu ret %d pages_written %d pages_skipped %ld "
+                 " more_io %d no_nrwrite_index_update %d writeback_index %lu",
+                 MAJOR(__entry->dev), MINOR(__entry->dev),
+                 (unsigned long) __entry->ino, __entry->ret,
+                 __entry->pages_written, __entry->pages_skipped,
+                 __entry->more_io, __entry->no_nrwrite_index_update,
+                 (unsigned long) __entry->writeback_index)
+#else
+       TP_printk("dev %d,%d ino %lu ret %d pages_written %d pages_skipped %ld "
+                 " congestion %d"
+                 " more_io %d no_nrwrite_index_update %d writeback_index %lu",
+                 MAJOR(__entry->dev), MINOR(__entry->dev),
+                 (unsigned long) __entry->ino, __entry->ret,
+                 __entry->pages_written, __entry->pages_skipped,
+                 __entry->encountered_congestion,
+                 __entry->more_io, __entry->no_nrwrite_index_update,
+                 (unsigned long) __entry->writeback_index)
+#endif
+)
+
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,39))
+DECLARE_EVENT_CLASS(ext4__page_op,
+       TP_PROTO(struct page *page),
+
+       TP_ARGS(page),
+
+       TP_STRUCT__entry(
+               __field(        dev_t,  dev                     )
+               __field(        ino_t,  ino                     )
+               __field(        pgoff_t, index                  )
+
+       ),
+
+       TP_fast_assign(
+               tp_assign(dev, page->mapping->host->i_sb->s_dev)
+               tp_assign(ino, page->mapping->host->i_ino)
+               tp_assign(index, page->index)
+       ),
+
+       TP_printk("dev %d,%d ino %lu page_index %lu",
+                 MAJOR(__entry->dev), MINOR(__entry->dev),
+                 (unsigned long) __entry->ino,
+                 (unsigned long) __entry->index)
+)
+
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,40))
+DEFINE_EVENT(ext4__page_op, ext4_writepage,
+
+       TP_PROTO(struct page *page),
+
+       TP_ARGS(page)
+)
+#endif
+
+DEFINE_EVENT(ext4__page_op, ext4_readpage,
+
+       TP_PROTO(struct page *page),
+
+       TP_ARGS(page)
+)
+
+DEFINE_EVENT(ext4__page_op, ext4_releasepage,
+
+       TP_PROTO(struct page *page),
+
+       TP_ARGS(page)
+)
+
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,11,0))
+
+DECLARE_EVENT_CLASS(ext4_invalidatepage_op,
+       TP_PROTO(struct page *page, unsigned int offset, unsigned int length),
+
+       TP_ARGS(page, offset, length),
+
+       TP_STRUCT__entry(
+               __field(        dev_t,  dev                     )
+               __field(        ino_t,  ino                     )
+               __field(        pgoff_t, index                  )
+               __field(        unsigned int, offset            )
+               __field(        unsigned int, length            )
+       ),
+
+       TP_fast_assign(
+               tp_assign(dev, page->mapping->host->i_sb->s_dev)
+               tp_assign(ino, page->mapping->host->i_ino)
+               tp_assign(index, page->index)
+               tp_assign(offset, offset)
+               tp_assign(length, length)
+       ),
+
+       TP_printk("dev %d,%d ino %lu page_index %lu offset %u length %u",
+                 MAJOR(__entry->dev), MINOR(__entry->dev),
+                 (unsigned long) __entry->ino,
+                 (unsigned long) __entry->index,
+                 __entry->offset, __entry->length)
+)
+
+DEFINE_EVENT(ext4_invalidatepage_op, ext4_invalidatepage,
+       TP_PROTO(struct page *page, unsigned int offset, unsigned int length),
+
+       TP_ARGS(page, offset, length)
+)
+
+DEFINE_EVENT(ext4_invalidatepage_op, ext4_journalled_invalidatepage,
+       TP_PROTO(struct page *page, unsigned int offset, unsigned int length),
+
+       TP_ARGS(page, offset, length)
+)
+
+#else
+
+TRACE_EVENT(ext4_invalidatepage,
+       TP_PROTO(struct page *page, unsigned long offset),
+
+       TP_ARGS(page, offset),
+
+       TP_STRUCT__entry(
+               __field(        dev_t,  dev                     )
+               __field(        ino_t,  ino                     )
+               __field(        pgoff_t, index                  )
+               __field(        unsigned long, offset           )
+
+       ),
+
+       TP_fast_assign(
+               tp_assign(dev, page->mapping->host->i_sb->s_dev)
+               tp_assign(ino, page->mapping->host->i_ino)
+               tp_assign(index, page->index)
+               tp_assign(offset, offset)
+       ),
+
+       TP_printk("dev %d,%d ino %lu page_index %lu offset %lu",
+                 MAJOR(__entry->dev), MINOR(__entry->dev),
+                 (unsigned long) __entry->ino,
+                 (unsigned long) __entry->index, __entry->offset)
+)
+
+#endif
+
+#endif
+
+TRACE_EVENT(ext4_discard_blocks,
+       TP_PROTO(struct super_block *sb, unsigned long long blk,
+                       unsigned long long count),
+
+       TP_ARGS(sb, blk, count),
+
+       TP_STRUCT__entry(
+               __field(        dev_t,  dev                     )
+               __field(        __u64,  blk                     )
+               __field(        __u64,  count                   )
+
+       ),
+
+       TP_fast_assign(
+               tp_assign(dev, sb->s_dev)
+               tp_assign(blk, blk)
+               tp_assign(count, count)
+       ),
+
+       TP_printk("dev %d,%d blk %llu count %llu",
+                 MAJOR(__entry->dev), MINOR(__entry->dev),
+                 __entry->blk, __entry->count)
+)
+
+DECLARE_EVENT_CLASS(ext4__mb_new_pa,
+       TP_PROTO(struct ext4_allocation_context *ac,
+                struct ext4_prealloc_space *pa),
+
+       TP_ARGS(ac, pa),
+
+       TP_STRUCT__entry(
+               __field(        dev_t,  dev                     )
+               __field(        ino_t,  ino                     )
+               __field(        __u64,  pa_pstart               )
+               __field(        __u64,  pa_lstart               )
+               __field(        __u32,  pa_len                  )
+
+       ),
+
+       TP_fast_assign(
+               tp_assign(dev, ac->ac_sb->s_dev)
+               tp_assign(ino, ac->ac_inode->i_ino)
+               tp_assign(pa_pstart, pa->pa_pstart)
+               tp_assign(pa_lstart, pa->pa_lstart)
+               tp_assign(pa_len, pa->pa_len)
+       ),
+
+       TP_printk("dev %d,%d ino %lu pstart %llu len %u lstart %llu",
+                 MAJOR(__entry->dev), MINOR(__entry->dev),
+                 (unsigned long) __entry->ino,
+                 __entry->pa_pstart, __entry->pa_len, __entry->pa_lstart)
+)
+
+DEFINE_EVENT(ext4__mb_new_pa, ext4_mb_new_inode_pa,
+
+       TP_PROTO(struct ext4_allocation_context *ac,
+                struct ext4_prealloc_space *pa),
+
+       TP_ARGS(ac, pa)
+)
+
+DEFINE_EVENT(ext4__mb_new_pa, ext4_mb_new_group_pa,
+
+       TP_PROTO(struct ext4_allocation_context *ac,
+                struct ext4_prealloc_space *pa),
+
+       TP_ARGS(ac, pa)
+)
+
+TRACE_EVENT(ext4_mb_release_inode_pa,
+       TP_PROTO(
+#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,40))
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,37))
+                struct super_block *sb,
+                struct inode *inode,
+#elif (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,36))
+                struct super_block *sb,
+                struct ext4_allocation_context *ac,
+#else
+                struct ext4_allocation_context *ac,
+#endif
+#endif
+                struct ext4_prealloc_space *pa,
+                unsigned long long block, unsigned int count),
+
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,40))
+       TP_ARGS(pa, block, count),
+#elif (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,37))
+       TP_ARGS(sb, inode, pa, block, count),
+#elif (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,36))
+       TP_ARGS(sb, ac, pa, block, count),
+#else
+       TP_ARGS(ac, pa, block, count),
+#endif
+
+       TP_STRUCT__entry(
+               __field(        dev_t,  dev                     )
+               __field(        ino_t,  ino                     )
+               __field(        __u64,  block                   )
+               __field(        __u32,  count                   )
+
+       ),
+
+       TP_fast_assign(
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,40))
+               tp_assign(dev, pa->pa_inode->i_sb->s_dev)
+               tp_assign(ino, pa->pa_inode->i_ino)
+#else
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,36))
+               tp_assign(dev, sb->s_dev)
+#else
+               tp_assign(dev, ac->ac_sb->s_dev)
+#endif
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,37))
+               tp_assign(ino, inode->i_ino)
+#else
+               tp_assign(ino, (ac && ac->ac_inode) ? ac->ac_inode->i_ino : 0)
+#endif
+#endif
+               tp_assign(block, block)
+               tp_assign(count, count)
+       ),
+
+       TP_printk("dev %d,%d ino %lu block %llu count %u",
+                 MAJOR(__entry->dev), MINOR(__entry->dev),
+                 (unsigned long) __entry->ino,
+                 __entry->block, __entry->count)
+)
+
+TRACE_EVENT(ext4_mb_release_group_pa,
+
+#if (LTTNG_KERNEL_RANGE(2,6,40, 3,3,0))
+       TP_PROTO(struct ext4_prealloc_space *pa),
+
+       TP_ARGS(pa),
+#elif (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,37))
+       TP_PROTO(struct super_block *sb, struct ext4_prealloc_space *pa),
+
+       TP_ARGS(sb, pa),
+#elif (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,36))
+       TP_PROTO(struct super_block *sb,
+                struct ext4_allocation_context *ac,
+                struct ext4_prealloc_space *pa),
+
+       TP_ARGS(sb, ac, pa),
+#else
+       TP_PROTO(struct ext4_allocation_context *ac,
+                struct ext4_prealloc_space *pa),
+
+       TP_ARGS(ac, pa),
+#endif
+
+       TP_STRUCT__entry(
+               __field(        dev_t,  dev                     )
+#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,37))
+               __field(        ino_t,  ino                     )
+#endif
+               __field(        __u64,  pa_pstart               )
+               __field(        __u32,  pa_len                  )
+
+       ),
+
+       TP_fast_assign(
+#if (LTTNG_KERNEL_RANGE(2,6,40, 3,3,0))
+               tp_assign(dev, pa->pa_inode->i_sb->s_dev)
+#elif (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,36))
+               tp_assign(dev, sb->s_dev)
+#else
+               tp_assign(dev, ac->ac_sb->s_dev)
+#endif
+#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,37))
+               tp_assign(ino, (ac && ac->ac_inode) ? ac->ac_inode->i_ino : 0)
+#endif
+               tp_assign(pa_pstart, pa->pa_pstart)
+               tp_assign(pa_len, pa->pa_len)
+       ),
+
+       TP_printk("dev %d,%d pstart %llu len %u",
+                 MAJOR(__entry->dev), MINOR(__entry->dev),
+                 __entry->pa_pstart, __entry->pa_len)
+)
+
+TRACE_EVENT(ext4_discard_preallocations,
+       TP_PROTO(struct inode *inode),
+
+       TP_ARGS(inode),
+
+       TP_STRUCT__entry(
+               __field(        dev_t,  dev                     )
+               __field(        ino_t,  ino                     )
+
+       ),
+
+       TP_fast_assign(
+               tp_assign(dev, inode->i_sb->s_dev)
+               tp_assign(ino, inode->i_ino)
+       ),
+
+       TP_printk("dev %d,%d ino %lu",
+                 MAJOR(__entry->dev), MINOR(__entry->dev),
+                 (unsigned long) __entry->ino)
+)
+
+TRACE_EVENT(ext4_mb_discard_preallocations,
+       TP_PROTO(struct super_block *sb, int needed),
+
+       TP_ARGS(sb, needed),
+
+       TP_STRUCT__entry(
+               __field(        dev_t,  dev                     )
+               __field(        int,    needed                  )
+
+       ),
+
+       TP_fast_assign(
+               tp_assign(dev, sb->s_dev)
+               tp_assign(needed, needed)
+       ),
+
+       TP_printk("dev %d,%d needed %d",
+                 MAJOR(__entry->dev), MINOR(__entry->dev),
+                 __entry->needed)
+)
+
+TRACE_EVENT(ext4_request_blocks,
+       TP_PROTO(struct ext4_allocation_request *ar),
+
+       TP_ARGS(ar),
+
+       TP_STRUCT__entry(
+               __field(        dev_t,  dev                     )
+               __field(        ino_t,  ino                     )
+               __field(        unsigned int, len               )
+               __field(        __u32,  logical                 )
+               __field(        __u32,  lleft                   )
+               __field(        __u32,  lright                  )
+               __field(        __u64,  goal                    )
+               __field(        __u64,  pleft                   )
+               __field(        __u64,  pright                  )
+               __field(        unsigned int, flags             )
+       ),
+
+       TP_fast_assign(
+               tp_assign(dev, ar->inode->i_sb->s_dev)
+               tp_assign(ino, ar->inode->i_ino)
+               tp_assign(len, ar->len)
+               tp_assign(logical, ar->logical)
+               tp_assign(goal, ar->goal)
+               tp_assign(lleft, ar->lleft)
+               tp_assign(lright, ar->lright)
+               tp_assign(pleft, ar->pleft)
+               tp_assign(pright, ar->pright)
+               tp_assign(flags, ar->flags)
+       ),
+
+       TP_printk("dev %d,%d ino %lu flags %u len %u lblk %u goal %llu "
+                 "lleft %u lright %u pleft %llu pright %llu ",
+                 MAJOR(__entry->dev), MINOR(__entry->dev),
+                 (unsigned long) __entry->ino, __entry->flags,
+                 __entry->len, __entry->logical, __entry->goal,
+                 __entry->lleft, __entry->lright, __entry->pleft,
+                 __entry->pright)
+)
+
+TRACE_EVENT(ext4_allocate_blocks,
+       TP_PROTO(struct ext4_allocation_request *ar, unsigned long long block),
+
+       TP_ARGS(ar, block),
+
+       TP_STRUCT__entry(
+               __field(        dev_t,  dev                     )
+               __field(        ino_t,  ino                     )
+               __field(        __u64,  block                   )
+               __field(        unsigned int, len               )
+               __field(        __u32,  logical                 )
+               __field(        __u32,  lleft                   )
+               __field(        __u32,  lright                  )
+               __field(        __u64,  goal                    )
+               __field(        __u64,  pleft                   )
+               __field(        __u64,  pright                  )
+               __field(        unsigned int, flags             )
+       ),
+
+       TP_fast_assign(
+               tp_assign(dev, ar->inode->i_sb->s_dev)
+               tp_assign(ino, ar->inode->i_ino)
+               tp_assign(block, block)
+               tp_assign(len, ar->len)
+               tp_assign(logical, ar->logical)
+               tp_assign(goal, ar->goal)
+               tp_assign(lleft, ar->lleft)
+               tp_assign(lright, ar->lright)
+               tp_assign(pleft, ar->pleft)
+               tp_assign(pright, ar->pright)
+               tp_assign(flags, ar->flags)
+       ),
+
+       TP_printk("dev %d,%d ino %lu flags %u len %u block %llu lblk %u "
+                 "goal %llu lleft %u lright %u pleft %llu pright %llu",
+                 MAJOR(__entry->dev), MINOR(__entry->dev),
+                 (unsigned long) __entry->ino, __entry->flags,
+                 __entry->len, __entry->block, __entry->logical,
+                 __entry->goal,  __entry->lleft, __entry->lright,
+                 __entry->pleft, __entry->pright)
+)
+
+TRACE_EVENT(ext4_free_blocks,
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,33))
+       TP_PROTO(struct inode *inode, __u64 block, unsigned long count,
+                int flags),
+
+       TP_ARGS(inode, block, count, flags),
+#else
+       TP_PROTO(struct inode *inode, __u64 block, unsigned long count,
+                int metadata),
+
+       TP_ARGS(inode, block, count, metadata),
+#endif
+
+       TP_STRUCT__entry(
+               __field(        dev_t,  dev                     )
+               __field(        ino_t,  ino                     )
+               __field(        __u64,  block                   )
+               __field(        unsigned long,  count           )
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,33))
+               __field(        int,    flags                   )
+               __field(        TP_MODE_T, mode                 )
+#else
+               __field(        int,    metadata                )
+#endif
+       ),
+
+       TP_fast_assign(
+               tp_assign(dev, inode->i_sb->s_dev)
+               tp_assign(ino, inode->i_ino)
+               tp_assign(block, block)
+               tp_assign(count, count)
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,33))
+               tp_assign(flags, flags)
+               tp_assign(mode, inode->i_mode)
+#else
+               tp_assign(metadata, metadata)
+#endif
+       ),
+
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,33))
+       TP_printk("dev %d,%d ino %lu mode 0%o block %llu count %lu flags %d",
+#else
+       TP_printk("dev %d,%d ino %lu block %llu count %lu metadata %d",
+#endif
+                 MAJOR(__entry->dev), MINOR(__entry->dev),
+                 (unsigned long) __entry->ino,
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,33))
+                 __entry->mode, __entry->block, __entry->count,
+                 __entry->flags)
+#else
+                 __entry->block, __entry->count, __entry->metadata)
+#endif
+)
+
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,39))
+TRACE_EVENT(ext4_sync_file_enter,
+#else
+TRACE_EVENT(ext4_sync_file,
+#endif
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,35))
+       TP_PROTO(struct file *file, int datasync),
+
+       TP_ARGS(file, datasync),
+#else
+       TP_PROTO(struct file *file, struct dentry *dentry, int datasync),
+
+       TP_ARGS(file, dentry, datasync),
+#endif
+
+       TP_STRUCT__entry(
+               __field(        dev_t,  dev                     )
+               __field(        ino_t,  ino                     )
+               __field(        ino_t,  parent                  )
+               __field(        int,    datasync                )
+       ),
+
+       TP_fast_assign(
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,35))
+               tp_assign(dev, file->f_path.dentry->d_inode->i_sb->s_dev)
+               tp_assign(ino, file->f_path.dentry->d_inode->i_ino)
+               tp_assign(datasync, datasync)
+               tp_assign(parent, file->f_path.dentry->d_parent->d_inode->i_ino)
+#else
+               tp_assign(dev, dentry->d_inode->i_sb->s_dev)
+               tp_assign(ino, dentry->d_inode->i_ino)
+               tp_assign(datasync, datasync)
+               tp_assign(parent, dentry->d_parent->d_inode->i_ino)
+#endif
+       ),
+
+       TP_printk("dev %d,%d ino %lu parent %lu datasync %d ",
+                 MAJOR(__entry->dev), MINOR(__entry->dev),
+                 (unsigned long) __entry->ino,
+                 (unsigned long) __entry->parent, __entry->datasync)
+)
+
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,39))
+TRACE_EVENT(ext4_sync_file_exit,
+       TP_PROTO(struct inode *inode, int ret),
+
+       TP_ARGS(inode, ret),
+
+       TP_STRUCT__entry(
+               __field(        dev_t,  dev                     )
+               __field(        ino_t,  ino                     )
+               __field(        int,    ret                     )
+       ),
+
+       TP_fast_assign(
+               tp_assign(dev, inode->i_sb->s_dev)
+               tp_assign(ino, inode->i_ino)
+               tp_assign(ret, ret)
+       ),
+
+       TP_printk("dev %d,%d ino %lu ret %d",
+                 MAJOR(__entry->dev), MINOR(__entry->dev),
+                 (unsigned long) __entry->ino,
+                 __entry->ret)
+)
+#endif
+
+TRACE_EVENT(ext4_sync_fs,
+       TP_PROTO(struct super_block *sb, int wait),
+
+       TP_ARGS(sb, wait),
+
+       TP_STRUCT__entry(
+               __field(        dev_t,  dev                     )
+               __field(        int,    wait                    )
+
+       ),
+
+       TP_fast_assign(
+               tp_assign(dev, sb->s_dev)
+               tp_assign(wait, wait)
+       ),
+
+       TP_printk("dev %d,%d wait %d",
+                 MAJOR(__entry->dev), MINOR(__entry->dev),
+                 __entry->wait)
+)
+
+TRACE_EVENT(ext4_alloc_da_blocks,
+       TP_PROTO(struct inode *inode),
+
+       TP_ARGS(inode),
+
+       TP_STRUCT__entry(
+               __field(        dev_t,  dev                     )
+               __field(        ino_t,  ino                     )
+               __field( unsigned int,  data_blocks     )
+               __field( unsigned int,  meta_blocks     )
+       ),
+
+       TP_fast_assign(
+               tp_assign(dev, inode->i_sb->s_dev)
+               tp_assign(ino, inode->i_ino)
+               tp_assign(data_blocks, EXT4_I(inode)->i_reserved_data_blocks)
+               tp_assign(meta_blocks, EXT4_I(inode)->i_reserved_meta_blocks)
+       ),
+
+       TP_printk("dev %d,%d ino %lu data_blocks %u meta_blocks %u",
+                 MAJOR(__entry->dev), MINOR(__entry->dev),
+                 (unsigned long) __entry->ino,
+                 __entry->data_blocks, __entry->meta_blocks)
+)
+
+TRACE_EVENT(ext4_mballoc_alloc,
+       TP_PROTO(struct ext4_allocation_context *ac),
+
+       TP_ARGS(ac),
+
+       TP_STRUCT__entry(
+               __field(        dev_t,  dev                     )
+               __field(        ino_t,  ino                     )
+               __field(        __u32,  orig_logical            )
+               __field(          int,  orig_start              )
+               __field(        __u32,  orig_group              )
+               __field(          int,  orig_len                )
+               __field(        __u32,  goal_logical            )
+               __field(          int,  goal_start              )
+               __field(        __u32,  goal_group              )
+               __field(          int,  goal_len                )
+               __field(        __u32,  result_logical          )
+               __field(          int,  result_start            )
+               __field(        __u32,  result_group            )
+               __field(          int,  result_len              )
+               __field(        __u16,  found                   )
+               __field(        __u16,  groups                  )
+               __field(        __u16,  buddy                   )
+               __field(        __u16,  flags                   )
+               __field(        __u16,  tail                    )
+               __field(        __u8,   cr                      )
+       ),
+
+       TP_fast_assign(
+               tp_assign(dev, ac->ac_inode->i_sb->s_dev)
+               tp_assign(ino, ac->ac_inode->i_ino)
+               tp_assign(orig_logical, ac->ac_o_ex.fe_logical)
+               tp_assign(orig_start, ac->ac_o_ex.fe_start)
+               tp_assign(orig_group, ac->ac_o_ex.fe_group)
+               tp_assign(orig_len, ac->ac_o_ex.fe_len)
+               tp_assign(goal_logical, ac->ac_g_ex.fe_logical)
+               tp_assign(goal_start, ac->ac_g_ex.fe_start)
+               tp_assign(goal_group, ac->ac_g_ex.fe_group)
+               tp_assign(goal_len, ac->ac_g_ex.fe_len)
+               tp_assign(result_logical, ac->ac_f_ex.fe_logical)
+               tp_assign(result_start, ac->ac_f_ex.fe_start)
+               tp_assign(result_group, ac->ac_f_ex.fe_group)
+               tp_assign(result_len, ac->ac_f_ex.fe_len)
+               tp_assign(found, ac->ac_found)
+               tp_assign(flags, ac->ac_flags)
+               tp_assign(groups, ac->ac_groups_scanned)
+               tp_assign(buddy, ac->ac_buddy)
+               tp_assign(tail, ac->ac_tail)
+               tp_assign(cr, ac->ac_criteria)
+       ),
+
+       TP_printk("dev %d,%d inode %lu orig %u/%d/%u@%u goal %u/%d/%u@%u "
+                 "result %u/%d/%u@%u blks %u grps %u cr %u flags 0x%04x "
+                 "tail %u broken %u",
+                 MAJOR(__entry->dev), MINOR(__entry->dev),
+                 (unsigned long) __entry->ino,
+                 __entry->orig_group, __entry->orig_start,
+                 __entry->orig_len, __entry->orig_logical,
+                 __entry->goal_group, __entry->goal_start,
+                 __entry->goal_len, __entry->goal_logical,
+                 __entry->result_group, __entry->result_start,
+                 __entry->result_len, __entry->result_logical,
+                 __entry->found, __entry->groups, __entry->cr,
+                 __entry->flags, __entry->tail,
+                 __entry->buddy ? 1 << __entry->buddy : 0)
+)
+
+TRACE_EVENT(ext4_mballoc_prealloc,
+       TP_PROTO(struct ext4_allocation_context *ac),
+
+       TP_ARGS(ac),
+
+       TP_STRUCT__entry(
+               __field(        dev_t,  dev                     )
+               __field(        ino_t,  ino                     )
+               __field(        __u32,  orig_logical            )
+               __field(          int,  orig_start              )
+               __field(        __u32,  orig_group              )
+               __field(          int,  orig_len                )
+               __field(        __u32,  result_logical          )
+               __field(          int,  result_start            )
+               __field(        __u32,  result_group            )
+               __field(          int,  result_len              )
+       ),
+
+       TP_fast_assign(
+               tp_assign(dev, ac->ac_inode->i_sb->s_dev)
+               tp_assign(ino, ac->ac_inode->i_ino)
+               tp_assign(orig_logical, ac->ac_o_ex.fe_logical)
+               tp_assign(orig_start, ac->ac_o_ex.fe_start)
+               tp_assign(orig_group, ac->ac_o_ex.fe_group)
+               tp_assign(orig_len, ac->ac_o_ex.fe_len)
+               tp_assign(result_logical, ac->ac_b_ex.fe_logical)
+               tp_assign(result_start, ac->ac_b_ex.fe_start)
+               tp_assign(result_group, ac->ac_b_ex.fe_group)
+               tp_assign(result_len, ac->ac_b_ex.fe_len)
+       ),
+
+       TP_printk("dev %d,%d inode %lu orig %u/%d/%u@%u result %u/%d/%u@%u",
+                 MAJOR(__entry->dev), MINOR(__entry->dev),
+                 (unsigned long) __entry->ino,
+                 __entry->orig_group, __entry->orig_start,
+                 __entry->orig_len, __entry->orig_logical,
+                 __entry->result_group, __entry->result_start,
+                 __entry->result_len, __entry->result_logical)
+)
+
+DECLARE_EVENT_CLASS(ext4__mballoc,
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,37))
+       TP_PROTO(struct super_block *sb,
+                struct inode *inode,
+                ext4_group_t group,
+                ext4_grpblk_t start,
+                ext4_grpblk_t len),
+
+       TP_ARGS(sb, inode, group, start, len),
+#else
+       TP_PROTO(struct ext4_allocation_context *ac),
+
+       TP_ARGS(ac),
+#endif
+
+       TP_STRUCT__entry(
+               __field(        dev_t,  dev                     )
+               __field(        ino_t,  ino                     )
+#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,37))
+               __field(        __u32,  result_logical          )
+#endif
+               __field(          int,  result_start            )
+               __field(        __u32,  result_group            )
+               __field(          int,  result_len              )
+       ),
+
+       TP_fast_assign(
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,37))
+               tp_assign(dev, sb->s_dev)
+               tp_assign(ino, inode ? inode->i_ino : 0)
+               tp_assign(result_start, start)
+               tp_assign(result_group, group)
+               tp_assign(result_len, len)
+#else
+               tp_assign(dev, ac->ac_sb->s_dev)
+               tp_assign(ino, ac->ac_inode ? ac->ac_inode->i_ino : 0)
+               tp_assign(result_logical, ac->ac_b_ex.fe_logical)
+               tp_assign(result_start, ac->ac_b_ex.fe_start)
+               tp_assign(result_group, ac->ac_b_ex.fe_group)
+               tp_assign(result_len, ac->ac_b_ex.fe_len)
+#endif
+       ),
+
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,37))
+       TP_printk("dev %d,%d inode %lu extent %u/%d/%d ",
+#else
+       TP_printk("dev %d,%d inode %lu extent %u/%d/%u@%u ",
+#endif
+                 MAJOR(__entry->dev), MINOR(__entry->dev),
+                 (unsigned long) __entry->ino,
+                 __entry->result_group, __entry->result_start,
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,37))
+                 __entry->result_len
+#else
+                 __entry->result_len, __entry->result_logical
+#endif
+       )
+)
+
+DEFINE_EVENT(ext4__mballoc, ext4_mballoc_discard,
+
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,37))
+       TP_PROTO(struct super_block *sb,
+                struct inode *inode,
+                ext4_group_t group,
+                ext4_grpblk_t start,
+                ext4_grpblk_t len),
+
+       TP_ARGS(sb, inode, group, start, len)
+#else
+       TP_PROTO(struct ext4_allocation_context *ac),
+
+       TP_ARGS(ac)
+#endif
+)
+
+DEFINE_EVENT(ext4__mballoc, ext4_mballoc_free,
+
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,37))
+       TP_PROTO(struct super_block *sb,
+                struct inode *inode,
+                ext4_group_t group,
+                ext4_grpblk_t start,
+                ext4_grpblk_t len),
+
+       TP_ARGS(sb, inode, group, start, len)
+#else
+       TP_PROTO(struct ext4_allocation_context *ac),
+
+       TP_ARGS(ac)
+#endif
+)
+
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,33))
+TRACE_EVENT(ext4_forget,
+       TP_PROTO(struct inode *inode, int is_metadata, __u64 block),
+
+       TP_ARGS(inode, is_metadata, block),
+
+       TP_STRUCT__entry(
+               __field(        dev_t,  dev                     )
+               __field(        ino_t,  ino                     )
+               __field(        __u64,  block                   )
+               __field(        int,    is_metadata             )
+               __field(        TP_MODE_T, mode                 )
+       ),
+
+       TP_fast_assign(
+               tp_assign(dev, inode->i_sb->s_dev)
+               tp_assign(ino, inode->i_ino)
+               tp_assign(block, block)
+               tp_assign(is_metadata, is_metadata)
+               tp_assign(mode, inode->i_mode)
+       ),
+
+       TP_printk("dev %d,%d ino %lu mode 0%o is_metadata %d block %llu",
+                 MAJOR(__entry->dev), MINOR(__entry->dev),
+                 (unsigned long) __entry->ino,
+                 __entry->mode, __entry->is_metadata, __entry->block)
+)
+#endif
+
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,34))
+TRACE_EVENT(ext4_da_update_reserve_space,
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,2,0))
+       TP_PROTO(struct inode *inode, int used_blocks, int quota_claim),
+
+       TP_ARGS(inode, used_blocks, quota_claim),
+#else
+       TP_PROTO(struct inode *inode, int used_blocks),
+
+       TP_ARGS(inode, used_blocks),
+#endif
+
+       TP_STRUCT__entry(
+               __field(        dev_t,  dev                     )
+               __field(        ino_t,  ino                     )
+               __field(        __u64,  i_blocks                )
+               __field(        int,    used_blocks             )
+               __field(        int,    reserved_data_blocks    )
+               __field(        int,    reserved_meta_blocks    )
+               __field(        int,    allocated_meta_blocks   )
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,2,0))
+               __field(        int,    quota_claim             )
+#endif
+               __field(        TP_MODE_T, mode                 )
+       ),
+
+       TP_fast_assign(
+               tp_assign(dev, inode->i_sb->s_dev)
+               tp_assign(ino, inode->i_ino)
+               tp_assign(i_blocks, inode->i_blocks)
+               tp_assign(used_blocks, used_blocks)
+               tp_assign(reserved_data_blocks,
+                               EXT4_I(inode)->i_reserved_data_blocks)
+               tp_assign(reserved_meta_blocks,
+                               EXT4_I(inode)->i_reserved_meta_blocks)
+               tp_assign(allocated_meta_blocks,
+                               EXT4_I(inode)->i_allocated_meta_blocks)
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,2,0))
+               tp_assign(quota_claim, quota_claim)
+#endif
+               tp_assign(mode, inode->i_mode)
+       ),
+
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,2,0))
+       TP_printk("dev %d,%d ino %lu mode 0%o i_blocks %llu used_blocks %d "
+                 "reserved_data_blocks %d reserved_meta_blocks %d "
+                 "allocated_meta_blocks %d quota_claim %d",
+                 MAJOR(__entry->dev), MINOR(__entry->dev),
+                 (unsigned long) __entry->ino,
+                 __entry->mode, __entry->i_blocks,
+                 __entry->used_blocks, __entry->reserved_data_blocks,
+                 __entry->reserved_meta_blocks, __entry->allocated_meta_blocks,
+                 __entry->quota_claim)
+#else
+       TP_printk("dev %d,%d ino %lu mode 0%o i_blocks %llu used_blocks %d "
+                 "reserved_data_blocks %d reserved_meta_blocks %d "
+                 "allocated_meta_blocks %d",
+                 MAJOR(__entry->dev), MINOR(__entry->dev),
+                 (unsigned long) __entry->ino,
+                 __entry->mode, __entry->i_blocks,
+                 __entry->used_blocks, __entry->reserved_data_blocks,
+                 __entry->reserved_meta_blocks, __entry->allocated_meta_blocks)
+#endif
+)
+
+TRACE_EVENT(ext4_da_reserve_space,
+       TP_PROTO(struct inode *inode, int md_needed),
+
+       TP_ARGS(inode, md_needed),
+
+       TP_STRUCT__entry(
+               __field(        dev_t,  dev                     )
+               __field(        ino_t,  ino                     )
+               __field(        __u64,  i_blocks                )
+               __field(        int,    md_needed               )
+               __field(        int,    reserved_data_blocks    )
+               __field(        int,    reserved_meta_blocks    )
+               __field(        TP_MODE_T, mode                 )
+       ),
+
+       TP_fast_assign(
+               tp_assign(dev, inode->i_sb->s_dev)
+               tp_assign(ino, inode->i_ino)
+               tp_assign(i_blocks, inode->i_blocks)
+               tp_assign(md_needed, md_needed)
+               tp_assign(reserved_data_blocks,
+                               EXT4_I(inode)->i_reserved_data_blocks)
+               tp_assign(reserved_meta_blocks,
+                               EXT4_I(inode)->i_reserved_meta_blocks)
+               tp_assign(mode, inode->i_mode)
+       ),
+
+       TP_printk("dev %d,%d ino %lu mode 0%o i_blocks %llu md_needed %d "
+                 "reserved_data_blocks %d reserved_meta_blocks %d",
+                 MAJOR(__entry->dev), MINOR(__entry->dev),
+                 (unsigned long) __entry->ino,
+                 __entry->mode, __entry->i_blocks,
+                 __entry->md_needed, __entry->reserved_data_blocks,
+                 __entry->reserved_meta_blocks)
+)
+
+TRACE_EVENT(ext4_da_release_space,
+       TP_PROTO(struct inode *inode, int freed_blocks),
+
+       TP_ARGS(inode, freed_blocks),
+
+       TP_STRUCT__entry(
+               __field(        dev_t,  dev                     )
+               __field(        ino_t,  ino                     )
+               __field(        __u64,  i_blocks                )
+               __field(        int,    freed_blocks            )
+               __field(        int,    reserved_data_blocks    )
+               __field(        int,    reserved_meta_blocks    )
+               __field(        int,    allocated_meta_blocks   )
+               __field(        TP_MODE_T, mode                 )
+       ),
+
+       TP_fast_assign(
+               tp_assign(dev, inode->i_sb->s_dev)
+               tp_assign(ino, inode->i_ino)
+               tp_assign(i_blocks, inode->i_blocks)
+               tp_assign(freed_blocks, freed_blocks)
+               tp_assign(reserved_data_blocks,
+                               EXT4_I(inode)->i_reserved_data_blocks)
+               tp_assign(reserved_meta_blocks,
+                               EXT4_I(inode)->i_reserved_meta_blocks)
+               tp_assign(allocated_meta_blocks,
+                               EXT4_I(inode)->i_allocated_meta_blocks)
+               tp_assign(mode, inode->i_mode)
+       ),
+
+       TP_printk("dev %d,%d ino %lu mode 0%o i_blocks %llu freed_blocks %d "
+                 "reserved_data_blocks %d reserved_meta_blocks %d "
+                 "allocated_meta_blocks %d",
+                 MAJOR(__entry->dev), MINOR(__entry->dev),
+                 (unsigned long) __entry->ino,
+                 __entry->mode, __entry->i_blocks,
+                 __entry->freed_blocks, __entry->reserved_data_blocks,
+                 __entry->reserved_meta_blocks, __entry->allocated_meta_blocks)
+)
+#endif
+
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,35))
+DECLARE_EVENT_CLASS(ext4__bitmap_load,
+       TP_PROTO(struct super_block *sb, unsigned long group),
+
+       TP_ARGS(sb, group),
+
+       TP_STRUCT__entry(
+               __field(        dev_t,  dev                     )
+               __field(        __u32,  group                   )
+
+       ),
+
+       TP_fast_assign(
+               tp_assign(dev, sb->s_dev)
+               tp_assign(group, group)
+       ),
+
+       TP_printk("dev %d,%d group %u",
+                 MAJOR(__entry->dev), MINOR(__entry->dev),
+                 __entry->group)
+)
+
+DEFINE_EVENT(ext4__bitmap_load, ext4_mb_bitmap_load,
+
+       TP_PROTO(struct super_block *sb, unsigned long group),
+
+       TP_ARGS(sb, group)
+)
+
+DEFINE_EVENT(ext4__bitmap_load, ext4_mb_buddy_bitmap_load,
+
+       TP_PROTO(struct super_block *sb, unsigned long group),
+
+       TP_ARGS(sb, group)
+)
+#endif
+
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,39))
+DEFINE_EVENT(ext4__bitmap_load, ext4_read_block_bitmap_load,
+
+       TP_PROTO(struct super_block *sb, unsigned long group),
+
+       TP_ARGS(sb, group)
+)
+
+DEFINE_EVENT(ext4__bitmap_load, ext4_load_inode_bitmap,
+
+       TP_PROTO(struct super_block *sb, unsigned long group),
+
+       TP_ARGS(sb, group)
+)
+
+TRACE_EVENT(ext4_direct_IO_enter,
+       TP_PROTO(struct inode *inode, loff_t offset, unsigned long len, int rw),
+
+       TP_ARGS(inode, offset, len, rw),
+
+       TP_STRUCT__entry(
+               __field(        dev_t,  dev                     )
+               __field(        ino_t,  ino                     )
+               __field(        loff_t, pos                     )
+               __field(        unsigned long,  len             )
+               __field(        int,    rw                      )
+       ),
+
+       TP_fast_assign(
+               tp_assign(dev, inode->i_sb->s_dev)
+               tp_assign(ino, inode->i_ino)
+               tp_assign(pos, offset)
+               tp_assign(len, len)
+               tp_assign(rw, rw)
+       ),
+
+       TP_printk("dev %d,%d ino %lu pos %lld len %lu rw %d",
+                 MAJOR(__entry->dev), MINOR(__entry->dev),
+                 (unsigned long) __entry->ino,
+                 __entry->pos, __entry->len, __entry->rw)
+)
+
+TRACE_EVENT(ext4_direct_IO_exit,
+       TP_PROTO(struct inode *inode, loff_t offset, unsigned long len,
+                int rw, int ret),
+
+       TP_ARGS(inode, offset, len, rw, ret),
+
+       TP_STRUCT__entry(
+               __field(        dev_t,  dev                     )
+               __field(        ino_t,  ino                     )
+               __field(        loff_t, pos                     )
+               __field(        unsigned long,  len             )
+               __field(        int,    rw                      )
+               __field(        int,    ret                     )
+       ),
+
+       TP_fast_assign(
+               tp_assign(dev, inode->i_sb->s_dev)
+               tp_assign(ino, inode->i_ino)
+               tp_assign(pos, offset)
+               tp_assign(len, len)
+               tp_assign(rw, rw)
+               tp_assign(ret, ret)
+       ),
+
+       TP_printk("dev %d,%d ino %lu pos %lld len %lu rw %d ret %d",
+                 MAJOR(__entry->dev), MINOR(__entry->dev),
+                 (unsigned long) __entry->ino,
+                 __entry->pos, __entry->len,
+                 __entry->rw, __entry->ret)
+)
+
+TRACE_EVENT(ext4_fallocate_enter,
+       TP_PROTO(struct inode *inode, loff_t offset, loff_t len, int mode),
+
+       TP_ARGS(inode, offset, len, mode),
+
+       TP_STRUCT__entry(
+               __field(        dev_t,  dev                     )
+               __field(        ino_t,  ino                     )
+               __field(        loff_t, pos                     )
+               __field(        loff_t, len                     )
+               __field(        int,    mode                    )
+       ),
+
+       TP_fast_assign(
+               tp_assign(dev, inode->i_sb->s_dev)
+               tp_assign(ino, inode->i_ino)
+               tp_assign(pos, offset)
+               tp_assign(len, len)
+               tp_assign(mode, mode)
+       ),
+
+       TP_printk("dev %d,%d ino %lu pos %lld len %lld mode %d",
+                 MAJOR(__entry->dev), MINOR(__entry->dev),
+                 (unsigned long) __entry->ino, __entry->pos,
+                 __entry->len, __entry->mode)
+)
+
+TRACE_EVENT(ext4_fallocate_exit,
+       TP_PROTO(struct inode *inode, loff_t offset,
+                unsigned int max_blocks, int ret),
+
+       TP_ARGS(inode, offset, max_blocks, ret),
+
+       TP_STRUCT__entry(
+               __field(        dev_t,  dev                     )
+               __field(        ino_t,  ino                     )
+               __field(        loff_t, pos                     )
+               __field(        unsigned int,   blocks          )
+               __field(        int,    ret                     )
+       ),
+
+       TP_fast_assign(
+               tp_assign(dev, inode->i_sb->s_dev)
+               tp_assign(ino, inode->i_ino)
+               tp_assign(pos, offset)
+               tp_assign(blocks, max_blocks)
+               tp_assign(ret, ret)
+       ),
+
+       TP_printk("dev %d,%d ino %lu pos %lld blocks %u ret %d",
+                 MAJOR(__entry->dev), MINOR(__entry->dev),
+                 (unsigned long) __entry->ino,
+                 __entry->pos, __entry->blocks,
+                 __entry->ret)
+)
+
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,11,0))
+
+TRACE_EVENT(ext4_punch_hole,
+       TP_PROTO(struct inode *inode, loff_t offset, loff_t len),
+
+       TP_ARGS(inode, offset, len),
+
+       TP_STRUCT__entry(
+               __field(        dev_t,  dev                     )
+               __field(        ino_t,  ino                     )
+               __field(        loff_t, offset                  )
+               __field(        loff_t, len                     )
+       ),
+
+       TP_fast_assign(
+               tp_assign(dev, inode->i_sb->s_dev)
+               tp_assign(ino, inode->i_ino)
+               tp_assign(offset, offset)
+               tp_assign(len, len)
+       ),
+
+       TP_printk("dev %d,%d ino %lu offset %lld len %lld",
+                 MAJOR(__entry->dev), MINOR(__entry->dev),
+                 (unsigned long) __entry->ino,
+                 __entry->offset, __entry->len)
+)
+
+#endif
+
+TRACE_EVENT(ext4_unlink_enter,
+       TP_PROTO(struct inode *parent, struct dentry *dentry),
+
+       TP_ARGS(parent, dentry),
+
+       TP_STRUCT__entry(
+               __field(        dev_t,  dev                     )
+               __field(        ino_t,  ino                     )
+               __field(        ino_t,  parent                  )
+               __field(        loff_t, size                    )
+       ),
+
+       TP_fast_assign(
+               tp_assign(dev, dentry->d_inode->i_sb->s_dev)
+               tp_assign(ino, dentry->d_inode->i_ino)
+               tp_assign(parent, parent->i_ino)
+               tp_assign(size, dentry->d_inode->i_size)
+       ),
+
+       TP_printk("dev %d,%d ino %lu size %lld parent %lu",
+                 MAJOR(__entry->dev), MINOR(__entry->dev),
+                 (unsigned long) __entry->ino, __entry->size,
+                 (unsigned long) __entry->parent)
+)
+
+TRACE_EVENT(ext4_unlink_exit,
+       TP_PROTO(struct dentry *dentry, int ret),
+
+       TP_ARGS(dentry, ret),
+
+       TP_STRUCT__entry(
+               __field(        dev_t,  dev                     )
+               __field(        ino_t,  ino                     )
+               __field(        int,    ret                     )
+       ),
+
+       TP_fast_assign(
+               tp_assign(dev, dentry->d_inode->i_sb->s_dev)
+               tp_assign(ino, dentry->d_inode->i_ino)
+               tp_assign(ret, ret)
+       ),
+
+       TP_printk("dev %d,%d ino %lu ret %d",
+                 MAJOR(__entry->dev), MINOR(__entry->dev),
+                 (unsigned long) __entry->ino,
+                 __entry->ret)
+)
+
+DECLARE_EVENT_CLASS(ext4__truncate,
+       TP_PROTO(struct inode *inode),
+
+       TP_ARGS(inode),
+
+       TP_STRUCT__entry(
+               __field(        dev_t,          dev             )
+               __field(        ino_t,          ino             )
+               __field(        __u64,          blocks          )
+       ),
+
+       TP_fast_assign(
+               tp_assign(dev, inode->i_sb->s_dev)
+               tp_assign(ino, inode->i_ino)
+               tp_assign(blocks, inode->i_blocks)
+       ),
+
+       TP_printk("dev %d,%d ino %lu blocks %llu",
+                 MAJOR(__entry->dev), MINOR(__entry->dev),
+                 (unsigned long) __entry->ino, __entry->blocks)
+)
+
+DEFINE_EVENT(ext4__truncate, ext4_truncate_enter,
+
+       TP_PROTO(struct inode *inode),
+
+       TP_ARGS(inode)
+)
+
+DEFINE_EVENT(ext4__truncate, ext4_truncate_exit,
+
+       TP_PROTO(struct inode *inode),
+
+       TP_ARGS(inode)
+)
+
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,2,0))
+/* 'ux' is the uninitialized extent. */
+TRACE_EVENT(ext4_ext_convert_to_initialized_enter,
+       TP_PROTO(struct inode *inode, struct ext4_map_blocks *map,
+                struct ext4_extent *ux),
+
+       TP_ARGS(inode, map, ux),
+
+       TP_STRUCT__entry(
+               __field(        dev_t,          dev     )
+               __field(        ino_t,          ino     )
+               __field(        ext4_lblk_t,    m_lblk  )
+               __field(        unsigned,       m_len   )
+               __field(        ext4_lblk_t,    u_lblk  )
+               __field(        unsigned,       u_len   )
+               __field(        ext4_fsblk_t,   u_pblk  )
+       ),
+
+       TP_fast_assign(
+               tp_assign(dev, inode->i_sb->s_dev)
+               tp_assign(ino, inode->i_ino)
+               tp_assign(m_lblk, map->m_lblk)
+               tp_assign(m_len, map->m_len)
+               tp_assign(u_lblk, le32_to_cpu(ux->ee_block))
+               tp_assign(u_len, ext4_ext_get_actual_len(ux))
+               tp_assign(u_pblk, ext4_ext_pblock(ux))
+       ),
+
+       TP_printk("dev %d,%d ino %lu m_lblk %u m_len %u u_lblk %u u_len %u "
+                 "u_pblk %llu",
+                 MAJOR(__entry->dev), MINOR(__entry->dev),
+                 (unsigned long) __entry->ino,
+                 __entry->m_lblk, __entry->m_len,
+                 __entry->u_lblk, __entry->u_len, __entry->u_pblk)
+)
+
+/*
+ * 'ux' is the uninitialized extent.
+ * 'ix' is the initialized extent to which blocks are transferred.
+ */
+TRACE_EVENT(ext4_ext_convert_to_initialized_fastpath,
+       TP_PROTO(struct inode *inode, struct ext4_map_blocks *map,
+                struct ext4_extent *ux, struct ext4_extent *ix),
+
+       TP_ARGS(inode, map, ux, ix),
+
+       TP_STRUCT__entry(
+               __field(        dev_t,          dev     )
+               __field(        ino_t,          ino     )
+               __field(        ext4_lblk_t,    m_lblk  )
+               __field(        unsigned,       m_len   )
+               __field(        ext4_lblk_t,    u_lblk  )
+               __field(        unsigned,       u_len   )
+               __field(        ext4_fsblk_t,   u_pblk  )
+               __field(        ext4_lblk_t,    i_lblk  )
+               __field(        unsigned,       i_len   )
+               __field(        ext4_fsblk_t,   i_pblk  )
+       ),
+
+       TP_fast_assign(
+               tp_assign(dev, inode->i_sb->s_dev)
+               tp_assign(ino, inode->i_ino)
+               tp_assign(m_lblk, map->m_lblk)
+               tp_assign(m_len, map->m_len)
+               tp_assign(u_lblk, le32_to_cpu(ux->ee_block))
+               tp_assign(u_len, ext4_ext_get_actual_len(ux))
+               tp_assign(u_pblk, ext4_ext_pblock(ux))
+               tp_assign(i_lblk, le32_to_cpu(ix->ee_block))
+               tp_assign(i_len, ext4_ext_get_actual_len(ix))
+               tp_assign(i_pblk, ext4_ext_pblock(ix))
+       ),
+
+       TP_printk("dev %d,%d ino %lu m_lblk %u m_len %u "
+                 "u_lblk %u u_len %u u_pblk %llu "
+                 "i_lblk %u i_len %u i_pblk %llu ",
+                 MAJOR(__entry->dev), MINOR(__entry->dev),
+                 (unsigned long) __entry->ino,
+                 __entry->m_lblk, __entry->m_len,
+                 __entry->u_lblk, __entry->u_len, __entry->u_pblk,
+                 __entry->i_lblk, __entry->i_len, __entry->i_pblk)
+)
+#endif
+
+DECLARE_EVENT_CLASS(ext4__map_blocks_enter,
+       TP_PROTO(struct inode *inode, ext4_lblk_t lblk,
+                unsigned int len, unsigned int flags),
+
+       TP_ARGS(inode, lblk, len, flags),
+
+       TP_STRUCT__entry(
+               __field(        dev_t,          dev             )
+               __field(        ino_t,          ino             )
+               __field(        ext4_lblk_t,    lblk            )
+               __field(        unsigned int,   len             )
+               __field(        unsigned int,   flags           )
+       ),
+
+       TP_fast_assign(
+               tp_assign(dev, inode->i_sb->s_dev)
+               tp_assign(ino, inode->i_ino)
+               tp_assign(lblk, lblk)
+               tp_assign(len, len)
+               tp_assign(flags, flags)
+       ),
+
+       TP_printk("dev %d,%d ino %lu lblk %u len %u flags %u",
+                 MAJOR(__entry->dev), MINOR(__entry->dev),
+                 (unsigned long) __entry->ino,
+                 __entry->lblk, __entry->len, __entry->flags)
+)
+
+DEFINE_EVENT(ext4__map_blocks_enter, ext4_ext_map_blocks_enter,
+       TP_PROTO(struct inode *inode, ext4_lblk_t lblk,
+                unsigned len, unsigned flags),
+
+       TP_ARGS(inode, lblk, len, flags)
+)
+
+DEFINE_EVENT(ext4__map_blocks_enter, ext4_ind_map_blocks_enter,
+       TP_PROTO(struct inode *inode, ext4_lblk_t lblk,
+                unsigned len, unsigned flags),
+
+       TP_ARGS(inode, lblk, len, flags)
+)
+
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,11,0))
+
+DECLARE_EVENT_CLASS(ext4__map_blocks_exit,
+       TP_PROTO(struct inode *inode, unsigned flags, struct ext4_map_blocks *map,
+                int ret),
+
+       TP_ARGS(inode, flags, map, ret),
+
+       TP_STRUCT__entry(
+               __field(        dev_t,          dev             )
+               __field(        ino_t,          ino             )
+               __field(        unsigned int,   flags           )
+               __field(        ext4_fsblk_t,   pblk            )
+               __field(        ext4_lblk_t,    lblk            )
+               __field(        unsigned int,   len             )
+               __field(        unsigned int,   mflags          )
+               __field(        int,            ret             )
+       ),
+
+       TP_fast_assign(
+               tp_assign(dev, inode->i_sb->s_dev)
+               tp_assign(ino, inode->i_ino)
+               tp_assign(flags, flags)
+               tp_assign(pblk, map->m_pblk)
+               tp_assign(lblk, map->m_lblk)
+               tp_assign(len, map->m_len)
+               tp_assign(mflags, map->m_flags)
+               tp_assign(ret, ret)
+       ),
+
+       TP_printk("dev %d,%d ino %lu flags %s lblk %u pblk %llu len %u "
+                 "mflags %s ret %d",
+                 MAJOR(__entry->dev), MINOR(__entry->dev),
+                 (unsigned long) __entry->ino,
+                 show_map_flags(__entry->flags), __entry->lblk, __entry->pblk,
+                 __entry->len, show_mflags(__entry->mflags), __entry->ret)
+)
+
+DEFINE_EVENT(ext4__map_blocks_exit, ext4_ext_map_blocks_exit,
+       TP_PROTO(struct inode *inode, unsigned flags,
+                struct ext4_map_blocks *map, int ret),
+
+       TP_ARGS(inode, flags, map, ret)
+)
+
+DEFINE_EVENT(ext4__map_blocks_exit, ext4_ind_map_blocks_exit,
+       TP_PROTO(struct inode *inode, unsigned flags,
+                struct ext4_map_blocks *map, int ret),
+
+       TP_ARGS(inode, flags, map, ret)
+)
+
+#elif (LINUX_VERSION_CODE >= KERNEL_VERSION(3,8,0))
+
+DECLARE_EVENT_CLASS(ext4__map_blocks_exit,
+       TP_PROTO(struct inode *inode, struct ext4_map_blocks *map, int ret),
+
+       TP_ARGS(inode, map, ret),
+
+       TP_STRUCT__entry(
+               __field(        dev_t,          dev             )
+               __field(        ino_t,          ino             )
+               __field(        ext4_fsblk_t,   pblk            )
+               __field(        ext4_lblk_t,    lblk            )
+               __field(        unsigned int,   len             )
+               __field(        unsigned int,   flags           )
+               __field(        int,            ret             )
+       ),
+
+       TP_fast_assign(
+               tp_assign(dev, inode->i_sb->s_dev)
+               tp_assign(ino, inode->i_ino)
+               tp_assign(pblk, map->m_pblk)
+               tp_assign(lblk, map->m_lblk)
+               tp_assign(len, map->m_len)
+               tp_assign(flags, map->m_flags)
+               tp_assign(ret, ret)
+       ),
+
+       TP_printk("dev %d,%d ino %lu lblk %u pblk %llu len %u flags %x ret %d",
+                 MAJOR(__entry->dev), MINOR(__entry->dev),
+                 (unsigned long) __entry->ino,
+                 __entry->lblk, __entry->pblk,
+                 __entry->len, __entry->flags, __entry->ret)
+)
+
+DEFINE_EVENT(ext4__map_blocks_exit, ext4_ext_map_blocks_exit,
+       TP_PROTO(struct inode *inode, struct ext4_map_blocks *map, int ret),
+
+       TP_ARGS(inode, map, ret)
+)
+
+DEFINE_EVENT(ext4__map_blocks_exit, ext4_ind_map_blocks_exit,
+       TP_PROTO(struct inode *inode, struct ext4_map_blocks *map, int ret),
+
+       TP_ARGS(inode, map, ret)
+)
+
+#else  /* #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,8,0)) */
+
+DECLARE_EVENT_CLASS(ext4__map_blocks_exit,
+       TP_PROTO(struct inode *inode, ext4_lblk_t lblk,
+                ext4_fsblk_t pblk, unsigned int len, int ret),
+
+       TP_ARGS(inode, lblk, pblk, len, ret),
+
+       TP_STRUCT__entry(
+               __field(        dev_t,          dev             )
+               __field(        ino_t,          ino             )
+               __field(        ext4_fsblk_t,   pblk            )
+               __field(        ext4_lblk_t,    lblk            )
+               __field(        unsigned int,   len             )
+               __field(        int,            ret             )
+       ),
+
+       TP_fast_assign(
+               tp_assign(dev, inode->i_sb->s_dev)
+               tp_assign(ino, inode->i_ino)
+               tp_assign(pblk, pblk)
+               tp_assign(lblk, lblk)
+               tp_assign(len, len)
+               tp_assign(ret, ret)
+       ),
+
+       TP_printk("dev %d,%d ino %lu lblk %u pblk %llu len %u ret %d",
+                 MAJOR(__entry->dev), MINOR(__entry->dev),
+                 (unsigned long) __entry->ino,
+                 __entry->lblk, __entry->pblk,
+                 __entry->len, __entry->ret)
+)
+
+DEFINE_EVENT(ext4__map_blocks_exit, ext4_ext_map_blocks_exit,
+       TP_PROTO(struct inode *inode, ext4_lblk_t lblk,
+                ext4_fsblk_t pblk, unsigned len, int ret),
+
+       TP_ARGS(inode, lblk, pblk, len, ret)
+)
+
+DEFINE_EVENT(ext4__map_blocks_exit, ext4_ind_map_blocks_exit,
+       TP_PROTO(struct inode *inode, ext4_lblk_t lblk,
+                ext4_fsblk_t pblk, unsigned len, int ret),
+
+       TP_ARGS(inode, lblk, pblk, len, ret)
+)
+
+#endif /* #else #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,8,0)) */
+
+TRACE_EVENT(ext4_ext_load_extent,
+       TP_PROTO(struct inode *inode, ext4_lblk_t lblk, ext4_fsblk_t pblk),
+
+       TP_ARGS(inode, lblk, pblk),
+
+       TP_STRUCT__entry(
+               __field(        dev_t,          dev             )
+               __field(        ino_t,          ino             )
+               __field(        ext4_fsblk_t,   pblk            )
+               __field(        ext4_lblk_t,    lblk            )
+       ),
+
+       TP_fast_assign(
+               tp_assign(dev, inode->i_sb->s_dev)
+               tp_assign(ino, inode->i_ino)
+               tp_assign(pblk, pblk)
+               tp_assign(lblk, lblk)
+       ),
+
+       TP_printk("dev %d,%d ino %lu lblk %u pblk %llu",
+                 MAJOR(__entry->dev), MINOR(__entry->dev),
+                 (unsigned long) __entry->ino,
+                 __entry->lblk, __entry->pblk)
+)
+
+TRACE_EVENT(ext4_load_inode,
+       TP_PROTO(struct inode *inode),
+
+       TP_ARGS(inode),
+
+       TP_STRUCT__entry(
+               __field(        dev_t,  dev             )
+               __field(        ino_t,  ino             )
+       ),
+
+       TP_fast_assign(
+               tp_assign(dev, inode->i_sb->s_dev)
+               tp_assign(ino, inode->i_ino)
+       ),
+
+       TP_printk("dev %d,%d ino %ld",
+                 MAJOR(__entry->dev), MINOR(__entry->dev),
+                 (unsigned long) __entry->ino)
+)
+#endif
+
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,11,0))
+
+TRACE_EVENT(ext4_journal_start,
+       TP_PROTO(struct super_block *sb, int blocks, int rsv_blocks,
+                unsigned long IP),
+
+       TP_ARGS(sb, blocks, rsv_blocks, IP),
+
+       TP_STRUCT__entry(
+               __field(        dev_t,  dev                     )
+               __field(unsigned long,  ip                      )
+               __field(          int,  blocks                  )
+               __field(          int,  rsv_blocks              )
+       ),
+
+       TP_fast_assign(
+               tp_assign(dev, sb->s_dev)
+               tp_assign(ip, IP)
+               tp_assign(blocks, blocks)
+               tp_assign(rsv_blocks, rsv_blocks)
+       ),
+
+       TP_printk("dev %d,%d blocks, %d rsv_blocks, %d caller %pF",
+                 MAJOR(__entry->dev), MINOR(__entry->dev),
+                 __entry->blocks, __entry->rsv_blocks, (void *)__entry->ip)
+)
+
+TRACE_EVENT(ext4_journal_start_reserved,
+       TP_PROTO(struct super_block *sb, int blocks, unsigned long IP),
+
+       TP_ARGS(sb, blocks, IP),
+
+       TP_STRUCT__entry(
+               __field(        dev_t,  dev                     )
+               __field(unsigned long,  ip                      )
+               __field(          int,  blocks                  )
+       ),
+
+       TP_fast_assign(
+               tp_assign(dev, sb->s_dev)
+               tp_assign(ip, IP)
+               tp_assign(blocks, blocks)
+       ),
+
+       TP_printk("dev %d,%d blocks, %d caller %pF",
+                 MAJOR(__entry->dev), MINOR(__entry->dev),
+                 __entry->blocks, (void *)__entry->ip)
+)
+
+#elif (LINUX_VERSION_CODE >= KERNEL_VERSION(3,1,0))
+
+TRACE_EVENT(ext4_journal_start,
+       TP_PROTO(struct super_block *sb, int nblocks, unsigned long IP),
+
+       TP_ARGS(sb, nblocks, IP),
+
+       TP_STRUCT__entry(
+               __field(        dev_t,  dev                     )
+               __field(unsigned long,  ip                      )
+               __field(          int,  nblocks                 )
+       ),
+
+       TP_fast_assign(
+               tp_assign(dev, sb->s_dev)
+               tp_assign(ip, IP)
+               tp_assign(nblocks, nblocks)
+       ),
+
+       TP_printk("dev %d,%d nblocks %d caller %pF",
+                 MAJOR(__entry->dev), MINOR(__entry->dev),
+                 __entry->nblocks, (void *)__entry->ip)
+)
+
+DECLARE_EVENT_CLASS(ext4__trim,
+       TP_PROTO(struct super_block *sb,
+                ext4_group_t group,
+                ext4_grpblk_t start,
+                ext4_grpblk_t len),
+
+       TP_ARGS(sb, group, start, len),
+
+       TP_STRUCT__entry(
+               __field(        int,    dev_major               )
+               __field(        int,    dev_minor               )
+               __field(        __u32,  group                   )
+               __field(        int,    start                   )
+               __field(        int,    len                     )
+       ),
+
+       TP_fast_assign(
+               tp_assign(dev_major, MAJOR(sb->s_dev))
+               tp_assign(dev_minor, MINOR(sb->s_dev))
+               tp_assign(group, group)
+               tp_assign(start, start)
+               tp_assign(len, len)
+       ),
+
+       TP_printk("dev %d,%d group %u, start %d, len %d",
+                 __entry->dev_major, __entry->dev_minor,
+                 __entry->group, __entry->start, __entry->len)
+)
+
+DEFINE_EVENT(ext4__trim, ext4_trim_extent,
+
+       TP_PROTO(struct super_block *sb,
+                ext4_group_t group,
+                ext4_grpblk_t start,
+                ext4_grpblk_t len),
+
+       TP_ARGS(sb, group, start, len)
+)
+
+DEFINE_EVENT(ext4__trim, ext4_trim_all_free,
+
+       TP_PROTO(struct super_block *sb,
+                ext4_group_t group,
+                ext4_grpblk_t start,
+                ext4_grpblk_t len),
+
+       TP_ARGS(sb, group, start, len)
+)
+#endif
+
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,2,0))
+
+TRACE_EVENT(ext4_ext_handle_uninitialized_extents,
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,8,0))
+       TP_PROTO(struct inode *inode, struct ext4_map_blocks *map, int flags,
+                unsigned int allocated, ext4_fsblk_t newblock),
+
+       TP_ARGS(inode, map, flags, allocated, newblock),
+#else /* #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,8,0)) */
+       TP_PROTO(struct inode *inode, struct ext4_map_blocks *map,
+                unsigned int allocated, ext4_fsblk_t newblock),
+
+       TP_ARGS(inode, map, allocated, newblock),
+#endif /* #else #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,8,0)) */
+
+       TP_STRUCT__entry(
+               __field(        dev_t,          dev             )
+               __field(        ino_t,          ino             )
+               __field(        int,            flags           )
+               __field(        ext4_lblk_t,    lblk            )
+               __field(        ext4_fsblk_t,   pblk            )
+               __field(        unsigned int,   len             )
+               __field(        unsigned int,   allocated       )
+               __field(        ext4_fsblk_t,   newblk          )
+       ),
+
+       TP_fast_assign(
+               tp_assign(dev, inode->i_sb->s_dev)
+               tp_assign(ino, inode->i_ino)
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,8,0))
+               tp_assign(flags, flags)
+#else /* #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,8,0)) */
+               tp_assign(flags, map->m_flags)
+#endif /* #else #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,8,0)) */
+               tp_assign(lblk, map->m_lblk)
+               tp_assign(pblk, map->m_pblk)
+               tp_assign(len, map->m_len)
+               tp_assign(allocated, allocated)
+               tp_assign(newblk, newblock)
+       ),
+
+       TP_printk("dev %d,%d ino %lu m_lblk %u m_pblk %llu m_len %u flags %d"
+                 "allocated %d newblock %llu",
+                 MAJOR(__entry->dev), MINOR(__entry->dev),
+                 (unsigned long) __entry->ino,
+                 (unsigned) __entry->lblk, (unsigned long long) __entry->pblk,
+                 __entry->len, __entry->flags,
+                 (unsigned int) __entry->allocated,
+                 (unsigned long long) __entry->newblk)
+)
+
+TRACE_EVENT(ext4_get_implied_cluster_alloc_exit,
+       TP_PROTO(struct super_block *sb, struct ext4_map_blocks *map, int ret),
+
+       TP_ARGS(sb, map, ret),
+
+       TP_STRUCT__entry(
+               __field(        dev_t,          dev     )
+               __field(        unsigned int,   flags   )
+               __field(        ext4_lblk_t,    lblk    )
+               __field(        ext4_fsblk_t,   pblk    )
+               __field(        unsigned int,   len     )
+               __field(        int,            ret     )
+       ),
+
+       TP_fast_assign(
+               tp_assign(dev, sb->s_dev)
+               tp_assign(flags, map->m_flags)
+               tp_assign(lblk, map->m_lblk)
+               tp_assign(pblk, map->m_pblk)
+               tp_assign(len, map->m_len)
+               tp_assign(ret, ret)
+       ),
+
+       TP_printk("dev %d,%d m_lblk %u m_pblk %llu m_len %u m_flags %u ret %d",
+                 MAJOR(__entry->dev), MINOR(__entry->dev),
+                 __entry->lblk, (unsigned long long) __entry->pblk,
+                 __entry->len, __entry->flags, __entry->ret)
+)
+
+TRACE_EVENT(ext4_ext_put_in_cache,
+       TP_PROTO(struct inode *inode, ext4_lblk_t lblk, unsigned int len,
+                ext4_fsblk_t start),
+
+       TP_ARGS(inode, lblk, len, start),
+
+       TP_STRUCT__entry(
+               __field(        dev_t,          dev     )
+               __field(        ino_t,          ino     )
+               __field(        ext4_lblk_t,    lblk    )
+               __field(        unsigned int,   len     )
+               __field(        ext4_fsblk_t,   start   )
+       ),
+
+       TP_fast_assign(
+               tp_assign(dev, inode->i_sb->s_dev)
+               tp_assign(ino, inode->i_ino)
+               tp_assign(lblk, lblk)
+               tp_assign(len, len)
+               tp_assign(start, start)
+       ),
+
+       TP_printk("dev %d,%d ino %lu lblk %u len %u start %llu",
+                 MAJOR(__entry->dev), MINOR(__entry->dev),
+                 (unsigned long) __entry->ino,
+                 (unsigned) __entry->lblk,
+                 __entry->len,
+                 (unsigned long long) __entry->start)
+)
+
+TRACE_EVENT(ext4_ext_in_cache,
+       TP_PROTO(struct inode *inode, ext4_lblk_t lblk, int ret),
+
+       TP_ARGS(inode, lblk, ret),
+
+       TP_STRUCT__entry(
+               __field(        dev_t,          dev     )
+               __field(        ino_t,          ino     )
+               __field(        ext4_lblk_t,    lblk    )
+               __field(        int,            ret     )
+       ),
+
+       TP_fast_assign(
+               tp_assign(dev, inode->i_sb->s_dev)
+               tp_assign(ino, inode->i_ino)
+               tp_assign(lblk, lblk)
+               tp_assign(ret, ret)
+       ),
+
+       TP_printk("dev %d,%d ino %lu lblk %u ret %d",
+                 MAJOR(__entry->dev), MINOR(__entry->dev),
+                 (unsigned long) __entry->ino,
+                 (unsigned) __entry->lblk,
+                 __entry->ret)
+
+)
+
+TRACE_EVENT(ext4_find_delalloc_range,
+       TP_PROTO(struct inode *inode, ext4_lblk_t from, ext4_lblk_t to,
+               int reverse, int found, ext4_lblk_t found_blk),
+
+       TP_ARGS(inode, from, to, reverse, found, found_blk),
+
+       TP_STRUCT__entry(
+               __field(        dev_t,          dev             )
+               __field(        ino_t,          ino             )
+               __field(        ext4_lblk_t,    from            )
+               __field(        ext4_lblk_t,    to              )
+               __field(        int,            reverse         )
+               __field(        int,            found           )
+               __field(        ext4_lblk_t,    found_blk       )
+       ),
+
+       TP_fast_assign(
+               tp_assign(dev, inode->i_sb->s_dev)
+               tp_assign(ino, inode->i_ino)
+               tp_assign(from, from)
+               tp_assign(to, to)
+               tp_assign(reverse, reverse)
+               tp_assign(found, found)
+               tp_assign(found_blk, found_blk)
+       ),
+
+       TP_printk("dev %d,%d ino %lu from %u to %u reverse %d found %d "
+                 "(blk = %u)",
+                 MAJOR(__entry->dev), MINOR(__entry->dev),
+                 (unsigned long) __entry->ino,
+                 (unsigned) __entry->from, (unsigned) __entry->to,
+                 __entry->reverse, __entry->found,
+                 (unsigned) __entry->found_blk)
+)
+
+TRACE_EVENT(ext4_get_reserved_cluster_alloc,
+       TP_PROTO(struct inode *inode, ext4_lblk_t lblk, unsigned int len),
+
+       TP_ARGS(inode, lblk, len),
+
+       TP_STRUCT__entry(
+               __field(        dev_t,          dev     )
+               __field(        ino_t,          ino     )
+               __field(        ext4_lblk_t,    lblk    )
+               __field(        unsigned int,   len     )
+       ),
+
+       TP_fast_assign(
+               tp_assign(dev, inode->i_sb->s_dev)
+               tp_assign(ino, inode->i_ino)
+               tp_assign(lblk, lblk)
+               tp_assign(len, len)
+       ),
+
+       TP_printk("dev %d,%d ino %lu lblk %u len %u",
+                 MAJOR(__entry->dev), MINOR(__entry->dev),
+                 (unsigned long) __entry->ino,
+                 (unsigned) __entry->lblk,
+                 __entry->len)
+)
+
+TRACE_EVENT(ext4_ext_show_extent,
+       TP_PROTO(struct inode *inode, ext4_lblk_t lblk, ext4_fsblk_t pblk,
+                unsigned short len),
+
+       TP_ARGS(inode, lblk, pblk, len),
+
+       TP_STRUCT__entry(
+               __field(        dev_t,          dev     )
+               __field(        ino_t,          ino     )
+               __field(        ext4_fsblk_t,   pblk    )
+               __field(        ext4_lblk_t,    lblk    )
+               __field(        unsigned short, len     )
+       ),
+
+       TP_fast_assign(
+               tp_assign(dev, inode->i_sb->s_dev)
+               tp_assign(ino, inode->i_ino)
+               tp_assign(pblk, pblk)
+               tp_assign(lblk, lblk)
+               tp_assign(len, len)
+       ),
+
+       TP_printk("dev %d,%d ino %lu lblk %u pblk %llu len %u",
+                 MAJOR(__entry->dev), MINOR(__entry->dev),
+                 (unsigned long) __entry->ino,
+                 (unsigned) __entry->lblk,
+                 (unsigned long long) __entry->pblk,
+                 (unsigned short) __entry->len)
+)
+
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,11,0))
+
+TRACE_EVENT(ext4_remove_blocks,
+           TP_PROTO(struct inode *inode, struct ext4_extent *ex,
+               ext4_lblk_t from, ext4_fsblk_t to,
+               long long partial_cluster),
+
+       TP_ARGS(inode, ex, from, to, partial_cluster),
+
+       TP_STRUCT__entry(
+               __field(        dev_t,          dev     )
+               __field(        ino_t,          ino     )
+               __field(        ext4_lblk_t,    from    )
+               __field(        ext4_lblk_t,    to      )
+               __field(        long long,      partial )
+               __field(        ext4_fsblk_t,   ee_pblk )
+               __field(        ext4_lblk_t,    ee_lblk )
+               __field(        unsigned short, ee_len  )
+       ),
+
+       TP_fast_assign(
+               tp_assign(dev, inode->i_sb->s_dev)
+               tp_assign(ino, inode->i_ino)
+               tp_assign(from, from)
+               tp_assign(to, to)
+               tp_assign(partial, partial_cluster)
+               tp_assign(ee_pblk, ext4_ext_pblock(ex))
+               tp_assign(ee_lblk, le32_to_cpu(ex->ee_block))
+               tp_assign(ee_len, ext4_ext_get_actual_len(ex))
+       ),
+
+       TP_printk("dev %d,%d ino %lu extent [%u(%llu), %u]"
+                 "from %u to %u partial_cluster %lld",
+                 MAJOR(__entry->dev), MINOR(__entry->dev),
+                 (unsigned long) __entry->ino,
+                 (unsigned) __entry->ee_lblk,
+                 (unsigned long long) __entry->ee_pblk,
+                 (unsigned short) __entry->ee_len,
+                 (unsigned) __entry->from,
+                 (unsigned) __entry->to,
+                 (long long) __entry->partial)
+)
+
+#else
+
+TRACE_EVENT(ext4_remove_blocks,
+           TP_PROTO(struct inode *inode, struct ext4_extent *ex,
+               ext4_lblk_t from, ext4_fsblk_t to,
+               ext4_fsblk_t partial_cluster),
+
+       TP_ARGS(inode, ex, from, to, partial_cluster),
+
+       TP_STRUCT__entry(
+               __field(        dev_t,          dev     )
+               __field(        ino_t,          ino     )
+               __field(        ext4_lblk_t,    from    )
+               __field(        ext4_lblk_t,    to      )
+               __field(        ext4_fsblk_t,   partial )
+               __field(        ext4_fsblk_t,   ee_pblk )
+               __field(        ext4_lblk_t,    ee_lblk )
+               __field(        unsigned short, ee_len  )
+       ),
+
+       TP_fast_assign(
+               tp_assign(dev, inode->i_sb->s_dev)
+               tp_assign(ino, inode->i_ino)
+               tp_assign(from, from)
+               tp_assign(to, to)
+               tp_assign(partial, partial_cluster)
+               tp_assign(ee_pblk, ext4_ext_pblock(ex))
+               tp_assign(ee_lblk, cpu_to_le32(ex->ee_block))
+               tp_assign(ee_len, ext4_ext_get_actual_len(ex))
+       ),
+
+       TP_printk("dev %d,%d ino %lu extent [%u(%llu), %u]"
+                 "from %u to %u partial_cluster %u",
+                 MAJOR(__entry->dev), MINOR(__entry->dev),
+                 (unsigned long) __entry->ino,
+                 (unsigned) __entry->ee_lblk,
+                 (unsigned long long) __entry->ee_pblk,
+                 (unsigned short) __entry->ee_len,
+                 (unsigned) __entry->from,
+                 (unsigned) __entry->to,
+                 (unsigned) __entry->partial)
+)
+
+#endif
+
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,11,0))
+
+TRACE_EVENT(ext4_ext_rm_leaf,
+       TP_PROTO(struct inode *inode, ext4_lblk_t start,
+                struct ext4_extent *ex,
+                long long partial_cluster),
+
+       TP_ARGS(inode, start, ex, partial_cluster),
+
+       TP_STRUCT__entry(
+               __field(        dev_t,          dev     )
+               __field(        ino_t,          ino     )
+               __field(        long long,      partial )
+               __field(        ext4_lblk_t,    start   )
+               __field(        ext4_lblk_t,    ee_lblk )
+               __field(        ext4_fsblk_t,   ee_pblk )
+               __field(        short,          ee_len  )
+       ),
+
+       TP_fast_assign(
+               tp_assign(dev, inode->i_sb->s_dev)
+               tp_assign(ino, inode->i_ino)
+               tp_assign(partial, partial_cluster)
+               tp_assign(start, start)
+               tp_assign(ee_lblk, le32_to_cpu(ex->ee_block))
+               tp_assign(ee_pblk, ext4_ext_pblock(ex))
+               tp_assign(ee_len, ext4_ext_get_actual_len(ex))
+       ),
+
+       TP_printk("dev %d,%d ino %lu start_lblk %u last_extent [%u(%llu), %u]"
+                 "partial_cluster %lld",
+                 MAJOR(__entry->dev), MINOR(__entry->dev),
+                 (unsigned long) __entry->ino,
+                 (unsigned) __entry->start,
+                 (unsigned) __entry->ee_lblk,
+                 (unsigned long long) __entry->ee_pblk,
+                 (unsigned short) __entry->ee_len,
+                 (long long) __entry->partial)
+)
+
+#else
+
+TRACE_EVENT(ext4_ext_rm_leaf,
+       TP_PROTO(struct inode *inode, ext4_lblk_t start,
+                struct ext4_extent *ex, ext4_fsblk_t partial_cluster),
+
+       TP_ARGS(inode, start, ex, partial_cluster),
+
+       TP_STRUCT__entry(
+               __field(        dev_t,          dev     )
+               __field(        ino_t,          ino     )
+               __field(        ext4_fsblk_t,   partial )
+               __field(        ext4_lblk_t,    start   )
+               __field(        ext4_lblk_t,    ee_lblk )
+               __field(        ext4_fsblk_t,   ee_pblk )
+               __field(        short,          ee_len  )
+       ),
+
+       TP_fast_assign(
+               tp_assign(dev, inode->i_sb->s_dev)
+               tp_assign(ino, inode->i_ino)
+               tp_assign(partial, partial_cluster)
+               tp_assign(start, start)
+               tp_assign(ee_lblk, le32_to_cpu(ex->ee_block))
+               tp_assign(ee_pblk, ext4_ext_pblock(ex))
+               tp_assign(ee_len, ext4_ext_get_actual_len(ex))
+       ),
+
+       TP_printk("dev %d,%d ino %lu start_lblk %u last_extent [%u(%llu), %u]"
+                 "partial_cluster %u",
+                 MAJOR(__entry->dev), MINOR(__entry->dev),
+                 (unsigned long) __entry->ino,
+                 (unsigned) __entry->start,
+                 (unsigned) __entry->ee_lblk,
+                 (unsigned long long) __entry->ee_pblk,
+                 (unsigned short) __entry->ee_len,
+                 (unsigned) __entry->partial)
+)
+
+#endif
+
+TRACE_EVENT(ext4_ext_rm_idx,
+       TP_PROTO(struct inode *inode, ext4_fsblk_t pblk),
+
+       TP_ARGS(inode, pblk),
+
+       TP_STRUCT__entry(
+               __field(        dev_t,          dev     )
+               __field(        ino_t,          ino     )
+               __field(        ext4_fsblk_t,   pblk    )
+       ),
+
+       TP_fast_assign(
+               tp_assign(dev, inode->i_sb->s_dev)
+               tp_assign(ino, inode->i_ino)
+               tp_assign(pblk, pblk)
+       ),
+
+       TP_printk("dev %d,%d ino %lu index_pblk %llu",
+                 MAJOR(__entry->dev), MINOR(__entry->dev),
+                 (unsigned long) __entry->ino,
+                 (unsigned long long) __entry->pblk)
+)
+
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,11,0))
+
+TRACE_EVENT(ext4_ext_remove_space,
+       TP_PROTO(struct inode *inode, ext4_lblk_t start,
+                ext4_lblk_t end, int depth),
+
+       TP_ARGS(inode, start, end, depth),
+
+       TP_STRUCT__entry(
+               __field(        dev_t,          dev     )
+               __field(        ino_t,          ino     )
+               __field(        ext4_lblk_t,    start   )
+               __field(        ext4_lblk_t,    end     )
+               __field(        int,            depth   )
+       ),
+
+       TP_fast_assign(
+               tp_assign(dev, inode->i_sb->s_dev)
+               tp_assign(ino, inode->i_ino)
+               tp_assign(start, start)
+               tp_assign(end, end)
+               tp_assign(depth, depth)
+       ),
+
+       TP_printk("dev %d,%d ino %lu since %u end %u depth %d",
+                 MAJOR(__entry->dev), MINOR(__entry->dev),
+                 (unsigned long) __entry->ino,
+                 (unsigned) __entry->start,
+                 (unsigned) __entry->end,
+                 __entry->depth)
+)
+
+#else
+
+TRACE_EVENT(ext4_ext_remove_space,
+       TP_PROTO(struct inode *inode, ext4_lblk_t start, int depth),
+
+       TP_ARGS(inode, start, depth),
+
+       TP_STRUCT__entry(
+               __field(        dev_t,          dev     )
+               __field(        ino_t,          ino     )
+               __field(        ext4_lblk_t,    start   )
+               __field(        int,            depth   )
+       ),
+
+       TP_fast_assign(
+               tp_assign(dev, inode->i_sb->s_dev)
+               tp_assign(ino, inode->i_ino)
+               tp_assign(start, start)
+               tp_assign(depth, depth)
+       ),
+
+       TP_printk("dev %d,%d ino %lu since %u depth %d",
+                 MAJOR(__entry->dev), MINOR(__entry->dev),
+                 (unsigned long) __entry->ino,
+                 (unsigned) __entry->start,
+                 __entry->depth)
+)
+
+#endif
+
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,11,0))
+
+TRACE_EVENT(ext4_ext_remove_space_done,
+       TP_PROTO(struct inode *inode, ext4_lblk_t start, ext4_lblk_t end,
+                int depth, long long partial, __le16 eh_entries),
+
+       TP_ARGS(inode, start, end, depth, partial, eh_entries),
+
+       TP_STRUCT__entry(
+               __field(        dev_t,          dev             )
+               __field(        ino_t,          ino             )
+               __field(        ext4_lblk_t,    start           )
+               __field(        ext4_lblk_t,    end             )
+               __field(        int,            depth           )
+               __field(        long long,      partial         )
+               __field(        unsigned short, eh_entries      )
+       ),
+
+       TP_fast_assign(
+               tp_assign(dev, inode->i_sb->s_dev)
+               tp_assign(ino, inode->i_ino)
+               tp_assign(start, start)
+               tp_assign(end, end)
+               tp_assign(depth, depth)
+               tp_assign(partial, partial)
+               tp_assign(eh_entries, le16_to_cpu(eh_entries))
+       ),
+
+       TP_printk("dev %d,%d ino %lu since %u end %u depth %d partial %lld "
+                 "remaining_entries %u",
+                 MAJOR(__entry->dev), MINOR(__entry->dev),
+                 (unsigned long) __entry->ino,
+                 (unsigned) __entry->start,
+                 (unsigned) __entry->end,
+                 __entry->depth,
+                 (long long) __entry->partial,
+                 (unsigned short) __entry->eh_entries)
+)
+
+#else
+
+TRACE_EVENT(ext4_ext_remove_space_done,
+       TP_PROTO(struct inode *inode, ext4_lblk_t start, int depth,
+               ext4_lblk_t partial, unsigned short eh_entries),
+
+       TP_ARGS(inode, start, depth, partial, eh_entries),
+
+       TP_STRUCT__entry(
+               __field(        dev_t,          dev             )
+               __field(        ino_t,          ino             )
+               __field(        ext4_lblk_t,    start           )
+               __field(        int,            depth           )
+               __field(        ext4_lblk_t,    partial         )
+               __field(        unsigned short, eh_entries      )
+       ),
+
+       TP_fast_assign(
+               tp_assign(dev, inode->i_sb->s_dev)
+               tp_assign(ino, inode->i_ino)
+               tp_assign(start, start)
+               tp_assign(depth, depth)
+               tp_assign(partial, partial)
+               tp_assign(eh_entries, eh_entries)
+       ),
+
+       TP_printk("dev %d,%d ino %lu since %u depth %d partial %u "
+                 "remaining_entries %u",
+                 MAJOR(__entry->dev), MINOR(__entry->dev),
+                 (unsigned long) __entry->ino,
+                 (unsigned) __entry->start,
+                 __entry->depth,
+                 (unsigned) __entry->partial,
+                 (unsigned short) __entry->eh_entries)
+)
+
+#endif
+
+#endif
+
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,12,0))
+
+DECLARE_EVENT_CLASS(ext4__es_extent,
+       TP_PROTO(struct inode *inode, struct extent_status *es),
+
+       TP_ARGS(inode, es),
+
+       TP_STRUCT__entry(
+               __field(        dev_t,          dev             )
+               __field(        ino_t,          ino             )
+               __field(        ext4_lblk_t,    lblk            )
+               __field(        ext4_lblk_t,    len             )
+               __field(        ext4_fsblk_t,   pblk            )
+               __field(        char, status    )
+       ),
+
+       TP_fast_assign(
+               tp_assign(dev, inode->i_sb->s_dev)
+               tp_assign(ino, inode->i_ino)
+               tp_assign(lblk, es->es_lblk)
+               tp_assign(len, es->es_len)
+               tp_assign(pblk, ext4_es_pblock(es))
+               tp_assign(status, ext4_es_status(es))
+       ),
+
+       TP_printk("dev %d,%d ino %lu es [%u/%u) mapped %llu status %s",
+                 MAJOR(__entry->dev), MINOR(__entry->dev),
+                 (unsigned long) __entry->ino,
+                 __entry->lblk, __entry->len,
+                 __entry->pblk, show_extent_status(__entry->status))
+)
+
+DEFINE_EVENT(ext4__es_extent, ext4_es_insert_extent,
+       TP_PROTO(struct inode *inode, struct extent_status *es),
+
+       TP_ARGS(inode, es)
+)
+
+DEFINE_EVENT(ext4__es_extent, ext4_es_cache_extent,
+       TP_PROTO(struct inode *inode, struct extent_status *es),
+
+       TP_ARGS(inode, es)
+)
+
+#elif (LINUX_VERSION_CODE >= KERNEL_VERSION(3,11,0))
+
+TRACE_EVENT(ext4_es_insert_extent,
+       TP_PROTO(struct inode *inode, struct extent_status *es),
+
+       TP_ARGS(inode, es),
+
+       TP_STRUCT__entry(
+               __field(        dev_t,          dev             )
+               __field(        ino_t,          ino             )
+               __field(        ext4_lblk_t,    lblk            )
+               __field(        ext4_lblk_t,    len             )
+               __field(        ext4_fsblk_t,   pblk            )
+               __field(        char, status    )
+       ),
+
+       TP_fast_assign(
+               tp_assign(dev, inode->i_sb->s_dev)
+               tp_assign(ino, inode->i_ino)
+               tp_assign(lblk, es->es_lblk)
+               tp_assign(len, es->es_len)
+               tp_assign(pblk, ext4_es_pblock(es))
+               tp_assign(status, ext4_es_status(es) >> 60)
+       ),
+
+       TP_printk("dev %d,%d ino %lu es [%u/%u) mapped %llu status %s",
+                 MAJOR(__entry->dev), MINOR(__entry->dev),
+                 (unsigned long) __entry->ino,
+                 __entry->lblk, __entry->len,
+                 __entry->pblk, show_extent_status(__entry->status))
+)
+
+TRACE_EVENT(ext4_es_remove_extent,
+       TP_PROTO(struct inode *inode, ext4_lblk_t lblk, ext4_lblk_t len),
+
+       TP_ARGS(inode, lblk, len),
+
+       TP_STRUCT__entry(
+               __field(        dev_t,  dev                     )
+               __field(        ino_t,  ino                     )
+               __field(        loff_t, lblk                    )
+               __field(        loff_t, len                     )
+       ),
+
+       TP_fast_assign(
+               tp_assign(dev, inode->i_sb->s_dev)
+               tp_assign(ino, inode->i_ino)
+               tp_assign(lblk, lblk)
+               tp_assign(len, len)
+       ),
+
+       TP_printk("dev %d,%d ino %lu es [%lld/%lld)",
+                 MAJOR(__entry->dev), MINOR(__entry->dev),
+                 (unsigned long) __entry->ino,
+                 __entry->lblk, __entry->len)
+)
+
+TRACE_EVENT(ext4_es_find_delayed_extent_range_enter,
+       TP_PROTO(struct inode *inode, ext4_lblk_t lblk),
+
+       TP_ARGS(inode, lblk),
+
+       TP_STRUCT__entry(
+               __field(        dev_t,          dev             )
+               __field(        ino_t,          ino             )
+               __field(        ext4_lblk_t,    lblk            )
+       ),
+
+       TP_fast_assign(
+               tp_assign(dev, inode->i_sb->s_dev)
+               tp_assign(ino, inode->i_ino)
+               tp_assign(lblk, lblk)
+       ),
+
+       TP_printk("dev %d,%d ino %lu lblk %u",
+                 MAJOR(__entry->dev), MINOR(__entry->dev),
+                 (unsigned long) __entry->ino, __entry->lblk)
+)
+
+TRACE_EVENT(ext4_es_find_delayed_extent_range_exit,
+       TP_PROTO(struct inode *inode, struct extent_status *es),
+
+       TP_ARGS(inode, es),
+
+       TP_STRUCT__entry(
+               __field(        dev_t,          dev             )
+               __field(        ino_t,          ino             )
+               __field(        ext4_lblk_t,    lblk            )
+               __field(        ext4_lblk_t,    len             )
+               __field(        ext4_fsblk_t,   pblk            )
+               __field(        char, status    )
+       ),
+
+       TP_fast_assign(
+               tp_assign(dev, inode->i_sb->s_dev)
+               tp_assign(ino, inode->i_ino)
+               tp_assign(lblk, es->es_lblk)
+               tp_assign(len, es->es_len)
+               tp_assign(pblk, ext4_es_pblock(es))
+               tp_assign(status, ext4_es_status(es) >> 60)
+       ),
+
+       TP_printk("dev %d,%d ino %lu es [%u/%u) mapped %llu status %s",
+                 MAJOR(__entry->dev), MINOR(__entry->dev),
+                 (unsigned long) __entry->ino,
+                 __entry->lblk, __entry->len,
+                 __entry->pblk, show_extent_status(__entry->status))
+)
+
+TRACE_EVENT(ext4_es_lookup_extent_enter,
+       TP_PROTO(struct inode *inode, ext4_lblk_t lblk),
+
+       TP_ARGS(inode, lblk),
+
+       TP_STRUCT__entry(
+               __field(        dev_t,          dev             )
+               __field(        ino_t,          ino             )
+               __field(        ext4_lblk_t,    lblk            )
+       ),
+
+       TP_fast_assign(
+               tp_assign(dev, inode->i_sb->s_dev)
+               tp_assign(ino, inode->i_ino)
+               tp_assign(lblk, lblk)
+       ),
+
+       TP_printk("dev %d,%d ino %lu lblk %u",
+                 MAJOR(__entry->dev), MINOR(__entry->dev),
+                 (unsigned long) __entry->ino, __entry->lblk)
+)
+
+TRACE_EVENT(ext4_es_lookup_extent_exit,
+       TP_PROTO(struct inode *inode, struct extent_status *es,
+                int found),
+
+       TP_ARGS(inode, es, found),
+
+       TP_STRUCT__entry(
+               __field(        dev_t,          dev             )
+               __field(        ino_t,          ino             )
+               __field(        ext4_lblk_t,    lblk            )
+               __field(        ext4_lblk_t,    len             )
+               __field(        ext4_fsblk_t,   pblk            )
+               __field(        char,           status          )
+               __field(        int,            found           )
+       ),
+
+       TP_fast_assign(
+               tp_assign(dev, inode->i_sb->s_dev)
+               tp_assign(ino, inode->i_ino)
+               tp_assign(lblk, es->es_lblk)
+               tp_assign(len, es->es_len)
+               tp_assign(pblk, ext4_es_pblock(es))
+               tp_assign(status, ext4_es_status(es) >> 60)
+               tp_assign(found, found)
+       ),
+
+       TP_printk("dev %d,%d ino %lu found %d [%u/%u) %llu %s",
+                 MAJOR(__entry->dev), MINOR(__entry->dev),
+                 (unsigned long) __entry->ino, __entry->found,
+                 __entry->lblk, __entry->len,
+                 __entry->found ? __entry->pblk : 0,
+                 show_extent_status(__entry->found ? __entry->status : 0))
+)
+
+TRACE_EVENT(ext4_es_shrink_enter,
+       TP_PROTO(struct super_block *sb, int nr_to_scan, int cache_cnt),
+
+       TP_ARGS(sb, nr_to_scan, cache_cnt),
+
+       TP_STRUCT__entry(
+               __field(        dev_t,  dev                     )
+               __field(        int,    nr_to_scan              )
+               __field(        int,    cache_cnt               )
+       ),
+
+       TP_fast_assign(
+               tp_assign(dev, sb->s_dev)
+               tp_assign(nr_to_scan, nr_to_scan)
+               tp_assign(cache_cnt, cache_cnt)
+       ),
+
+       TP_printk("dev %d,%d nr_to_scan %d cache_cnt %d",
+                 MAJOR(__entry->dev), MINOR(__entry->dev),
+                 __entry->nr_to_scan, __entry->cache_cnt)
+)
+
+TRACE_EVENT(ext4_es_shrink_exit,
+       TP_PROTO(struct super_block *sb, int shrunk_nr, int cache_cnt),
+
+       TP_ARGS(sb, shrunk_nr, cache_cnt),
+
+       TP_STRUCT__entry(
+               __field(        dev_t,  dev                     )
+               __field(        int,    shrunk_nr               )
+               __field(        int,    cache_cnt               )
+       ),
+
+       TP_fast_assign(
+               tp_assign(dev, sb->s_dev)
+               tp_assign(shrunk_nr, shrunk_nr)
+               tp_assign(cache_cnt, cache_cnt)
+       ),
+
+       TP_printk("dev %d,%d shrunk_nr %d cache_cnt %d",
+                 MAJOR(__entry->dev), MINOR(__entry->dev),
+                 __entry->shrunk_nr, __entry->cache_cnt)
+)
+
+#endif
+
+#endif /* _TRACE_EXT4_H */
+
+/* This part must be outside protection */
+#include "../../../probes/define_trace.h"
diff --git a/drivers/staging/lttng/instrumentation/events/lttng-module/gpio.h b/drivers/staging/lttng/instrumentation/events/lttng-module/gpio.h
new file mode 100644 (file)
index 0000000..a0c5876
--- /dev/null
@@ -0,0 +1,56 @@
+#undef TRACE_SYSTEM
+#define TRACE_SYSTEM gpio
+
+#if !defined(_TRACE_GPIO_H) || defined(TRACE_HEADER_MULTI_READ)
+#define _TRACE_GPIO_H
+
+#include <linux/tracepoint.h>
+
+TRACE_EVENT(gpio_direction,
+
+       TP_PROTO(unsigned gpio, int in, int err),
+
+       TP_ARGS(gpio, in, err),
+
+       TP_STRUCT__entry(
+               __field(unsigned, gpio)
+               __field(int, in)
+               __field(int, err)
+       ),
+
+       TP_fast_assign(
+               tp_assign(gpio, gpio)
+               tp_assign(in, in)
+               tp_assign(err, err)
+       ),
+
+       TP_printk("%u %3s (%d)", __entry->gpio,
+               __entry->in ? "in" : "out", __entry->err)
+)
+
+TRACE_EVENT(gpio_value,
+
+       TP_PROTO(unsigned gpio, int get, int value),
+
+       TP_ARGS(gpio, get, value),
+
+       TP_STRUCT__entry(
+               __field(unsigned, gpio)
+               __field(int, get)
+               __field(int, value)
+       ),
+
+       TP_fast_assign(
+               tp_assign(gpio, gpio)
+               tp_assign(get, get)
+               tp_assign(value, value)
+       ),
+
+       TP_printk("%u %3s %d", __entry->gpio,
+               __entry->get ? "get" : "set", __entry->value)
+)
+
+#endif /* if !defined(_TRACE_GPIO_H) || defined(TRACE_HEADER_MULTI_READ) */
+
+/* This part must be outside protection */
+#include "../../../probes/define_trace.h"
diff --git a/drivers/staging/lttng/instrumentation/events/lttng-module/irq.h b/drivers/staging/lttng/instrumentation/events/lttng-module/irq.h
new file mode 100644 (file)
index 0000000..e766326
--- /dev/null
@@ -0,0 +1,220 @@
+#undef TRACE_SYSTEM
+#define TRACE_SYSTEM irq
+
+#if !defined(_TRACE_IRQ_H) || defined(TRACE_HEADER_MULTI_READ)
+#define _TRACE_IRQ_H
+
+#include <linux/tracepoint.h>
+
+#ifndef _TRACE_IRQ_DEF_
+#define _TRACE_IRQ_DEF_
+
+struct irqaction;
+struct softirq_action;
+
+#define softirq_name(sirq) { sirq##_SOFTIRQ, #sirq }
+#define show_softirq_name(val)                         \
+       __print_symbolic(val,                           \
+                        softirq_name(HI),              \
+                        softirq_name(TIMER),           \
+                        softirq_name(NET_TX),          \
+                        softirq_name(NET_RX),          \
+                        softirq_name(BLOCK),           \
+                        softirq_name(BLOCK_IOPOLL),    \
+                        softirq_name(TASKLET),         \
+                        softirq_name(SCHED),           \
+                        softirq_name(HRTIMER),         \
+                        softirq_name(RCU))
+
+#endif /* _TRACE_IRQ_DEF_ */
+
+/**
+ * irq_handler_entry - called immediately before the irq action handler
+ * @irq: irq number
+ * @action: pointer to struct irqaction
+ *
+ * The struct irqaction pointed to by @action contains various
+ * information about the handler, including the device name,
+ * @action->name, and the device id, @action->dev_id. When used in
+ * conjunction with the irq_handler_exit tracepoint, we can figure
+ * out irq handler latencies.
+ */
+TRACE_EVENT(irq_handler_entry,
+
+       TP_PROTO(int irq, struct irqaction *action),
+
+       TP_ARGS(irq, action),
+
+       TP_STRUCT__entry(
+               __field(        int,    irq             )
+               __string(       name,   action->name    )
+       ),
+
+       TP_fast_assign(
+               tp_assign(irq, irq)
+               tp_strcpy(name, action->name)
+       ),
+
+       TP_printk("irq=%d name=%s", __entry->irq, __get_str(name))
+)
+
+/**
+ * irq_handler_exit - called immediately after the irq action handler returns
+ * @irq: irq number
+ * @action: pointer to struct irqaction
+ * @ret: return value
+ *
+ * If the @ret value is set to IRQ_HANDLED, then we know that the corresponding
+ * @action->handler scuccessully handled this irq. Otherwise, the irq might be
+ * a shared irq line, or the irq was not handled successfully. Can be used in
+ * conjunction with the irq_handler_entry to understand irq handler latencies.
+ */
+TRACE_EVENT(irq_handler_exit,
+
+       TP_PROTO(int irq, struct irqaction *action, int ret),
+
+       TP_ARGS(irq, action, ret),
+
+       TP_STRUCT__entry(
+               __field(        int,    irq     )
+               __field(        int,    ret     )
+       ),
+
+       TP_fast_assign(
+               tp_assign(irq, irq)
+               tp_assign(ret, ret)
+       ),
+
+       TP_printk("irq=%d ret=%s",
+                 __entry->irq, __entry->ret ? "handled" : "unhandled")
+)
+
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,37))
+DECLARE_EVENT_CLASS(softirq,
+
+       TP_PROTO(unsigned int vec_nr),
+
+       TP_ARGS(vec_nr),
+
+       TP_STRUCT__entry(
+               __field(        unsigned int,   vec     )
+       ),
+
+       TP_fast_assign(
+               tp_assign(vec, vec_nr)
+       ),
+
+       TP_printk("vec=%u [action=%s]", __entry->vec,
+                 show_softirq_name(__entry->vec))
+)
+
+/**
+ * softirq_entry - called immediately before the softirq handler
+ * @vec_nr:  softirq vector number
+ *
+ * When used in combination with the softirq_exit tracepoint
+ * we can determine the softirq handler runtine.
+ */
+DEFINE_EVENT(softirq, softirq_entry,
+
+       TP_PROTO(unsigned int vec_nr),
+
+       TP_ARGS(vec_nr)
+)
+
+/**
+ * softirq_exit - called immediately after the softirq handler returns
+ * @vec_nr:  softirq vector number
+ *
+ * When used in combination with the softirq_entry tracepoint
+ * we can determine the softirq handler runtine.
+ */
+DEFINE_EVENT(softirq, softirq_exit,
+
+       TP_PROTO(unsigned int vec_nr),
+
+       TP_ARGS(vec_nr)
+)
+
+/**
+ * softirq_raise - called immediately when a softirq is raised
+ * @vec_nr:  softirq vector number
+ *
+ * When used in combination with the softirq_entry tracepoint
+ * we can determine the softirq raise to run latency.
+ */
+DEFINE_EVENT(softirq, softirq_raise,
+
+       TP_PROTO(unsigned int vec_nr),
+
+       TP_ARGS(vec_nr)
+)
+#else /* #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,37)) */
+DECLARE_EVENT_CLASS(softirq,
+
+       TP_PROTO(struct softirq_action *h, struct softirq_action *vec),
+
+       TP_ARGS(h, vec),
+
+       TP_STRUCT__entry(
+               __field(        unsigned int,   vec     )
+       ),
+
+       TP_fast_assign(
+               tp_assign(vec, (int)(h - vec))
+       ),
+
+       TP_printk("vec=%u [action=%s]", __entry->vec,
+                 show_softirq_name(__entry->vec))
+)
+
+/**
+ * softirq_entry - called immediately before the softirq handler
+ * @h: pointer to struct softirq_action
+ * @vec: pointer to first struct softirq_action in softirq_vec array
+ *
+ * When used in combination with the softirq_exit tracepoint
+ * we can determine the softirq handler runtine.
+ */
+DEFINE_EVENT(softirq, softirq_entry,
+
+       TP_PROTO(struct softirq_action *h, struct softirq_action *vec),
+
+       TP_ARGS(h, vec)
+)
+
+/**
+ * softirq_exit - called immediately after the softirq handler returns
+ * @h: pointer to struct softirq_action
+ * @vec: pointer to first struct softirq_action in softirq_vec array
+ *
+ * When used in combination with the softirq_entry tracepoint
+ * we can determine the softirq handler runtine.
+ */
+DEFINE_EVENT(softirq, softirq_exit,
+
+       TP_PROTO(struct softirq_action *h, struct softirq_action *vec),
+
+       TP_ARGS(h, vec)
+)
+
+/**
+ * softirq_raise - called immediately when a softirq is raised
+ * @h: pointer to struct softirq_action
+ * @vec: pointer to first struct softirq_action in softirq_vec array
+ *
+ * When used in combination with the softirq_entry tracepoint
+ * we can determine the softirq raise to run latency.
+ */
+DEFINE_EVENT(softirq, softirq_raise,
+
+       TP_PROTO(struct softirq_action *h, struct softirq_action *vec),
+
+       TP_ARGS(h, vec)
+)
+#endif /* #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,37)) */
+
+#endif /*  _TRACE_IRQ_H */
+
+/* This part must be outside protection */
+#include "../../../probes/define_trace.h"
diff --git a/drivers/staging/lttng/instrumentation/events/lttng-module/jbd.h b/drivers/staging/lttng/instrumentation/events/lttng-module/jbd.h
new file mode 100644 (file)
index 0000000..f20eef2
--- /dev/null
@@ -0,0 +1,268 @@
+#undef TRACE_SYSTEM
+#define TRACE_SYSTEM jbd
+
+#if !defined(_TRACE_JBD_H) || defined(TRACE_HEADER_MULTI_READ)
+#define _TRACE_JBD_H
+
+#include <linux/jbd.h>
+#include <linux/tracepoint.h>
+#include <linux/version.h>
+
+TRACE_EVENT(jbd_checkpoint,
+
+       TP_PROTO(journal_t *journal, int result),
+
+       TP_ARGS(journal, result),
+
+       TP_STRUCT__entry(
+               __field(        dev_t,  dev                     )
+               __field(        int,    result                  )
+       ),
+
+       TP_fast_assign(
+               tp_assign(dev, journal->j_fs_dev->bd_dev)
+               tp_assign(result, result)
+       ),
+
+       TP_printk("dev %d,%d result %d",
+                 MAJOR(__entry->dev), MINOR(__entry->dev),
+                 __entry->result)
+)
+
+DECLARE_EVENT_CLASS(jbd_commit,
+
+       TP_PROTO(journal_t *journal, transaction_t *commit_transaction),
+
+       TP_ARGS(journal, commit_transaction),
+
+       TP_STRUCT__entry(
+               __field(        dev_t,  dev                     )
+#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,5,0))
+               __field(        char,   sync_commit             )
+#endif
+               __field(        int,    transaction             )
+       ),
+
+       TP_fast_assign(
+               tp_assign(dev, journal->j_fs_dev->bd_dev)
+#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,5,0))
+               tp_assign(sync_commit, commit_transaction->t_synchronous_commit)
+#endif
+               tp_assign(transaction, commit_transaction->t_tid)
+       ),
+
+#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,5,0))
+       TP_printk("dev %d,%d transaction %d sync %d",
+                 MAJOR(__entry->dev), MINOR(__entry->dev),
+                 __entry->transaction, __entry->sync_commit)
+#else
+       TP_printk("dev %d,%d transaction %d",
+                 MAJOR(__entry->dev), MINOR(__entry->dev),
+                 __entry->transaction)
+#endif
+)
+
+DEFINE_EVENT(jbd_commit, jbd_start_commit,
+
+       TP_PROTO(journal_t *journal, transaction_t *commit_transaction),
+
+       TP_ARGS(journal, commit_transaction)
+)
+
+DEFINE_EVENT(jbd_commit, jbd_commit_locking,
+
+       TP_PROTO(journal_t *journal, transaction_t *commit_transaction),
+
+       TP_ARGS(journal, commit_transaction)
+)
+
+DEFINE_EVENT(jbd_commit, jbd_commit_flushing,
+
+       TP_PROTO(journal_t *journal, transaction_t *commit_transaction),
+
+       TP_ARGS(journal, commit_transaction)
+)
+
+DEFINE_EVENT(jbd_commit, jbd_commit_logging,
+
+       TP_PROTO(journal_t *journal, transaction_t *commit_transaction),
+
+       TP_ARGS(journal, commit_transaction)
+)
+
+TRACE_EVENT(jbd_drop_transaction,
+
+       TP_PROTO(journal_t *journal, transaction_t *commit_transaction),
+
+       TP_ARGS(journal, commit_transaction),
+
+       TP_STRUCT__entry(
+               __field(        dev_t,  dev                     )
+#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,5,0))
+               __field(        char,   sync_commit             )
+#endif
+               __field(        int,    transaction             )
+       ),
+
+       TP_fast_assign(
+               tp_assign(dev, journal->j_fs_dev->bd_dev)
+#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,5,0))
+               tp_assign(sync_commit, commit_transaction->t_synchronous_commit)
+#endif
+               tp_assign(transaction, commit_transaction->t_tid)
+       ),
+
+#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,5,0))
+       TP_printk("dev %d,%d transaction %d sync %d",
+                 MAJOR(__entry->dev), MINOR(__entry->dev),
+                 __entry->transaction, __entry->sync_commit)
+#else
+       TP_printk("dev %d,%d transaction %d",
+                 MAJOR(__entry->dev), MINOR(__entry->dev),
+                 __entry->transaction)
+#endif
+)
+
+TRACE_EVENT(jbd_end_commit,
+       TP_PROTO(journal_t *journal, transaction_t *commit_transaction),
+
+       TP_ARGS(journal, commit_transaction),
+
+       TP_STRUCT__entry(
+               __field(        dev_t,  dev                     )
+#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,5,0))
+               __field(        char,   sync_commit             )
+#endif
+               __field(        int,    transaction             )
+               __field(        int,    head                    )
+       ),
+
+       TP_fast_assign(
+               tp_assign(dev, journal->j_fs_dev->bd_dev)
+#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,5,0))
+               tp_assign(sync_commit, commit_transaction->t_synchronous_commit)
+#endif
+               tp_assign(transaction, commit_transaction->t_tid)
+               tp_assign(head, journal->j_tail_sequence)
+       ),
+
+#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,5,0))
+       TP_printk("dev %d,%d transaction %d sync %d head %d",
+                 MAJOR(__entry->dev), MINOR(__entry->dev),
+                 __entry->transaction, __entry->sync_commit, __entry->head)
+#else
+       TP_printk("dev %d,%d transaction %d head %d",
+                 MAJOR(__entry->dev), MINOR(__entry->dev),
+                 __entry->transaction, __entry->head)
+#endif
+)
+
+TRACE_EVENT(jbd_do_submit_data,
+       TP_PROTO(journal_t *journal, transaction_t *commit_transaction),
+
+       TP_ARGS(journal, commit_transaction),
+
+       TP_STRUCT__entry(
+               __field(        dev_t,  dev                     )
+#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,5,0))
+               __field(        char,   sync_commit             )
+#endif
+               __field(        int,    transaction             )
+       ),
+
+       TP_fast_assign(
+               tp_assign(dev, journal->j_fs_dev->bd_dev)
+#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,5,0))
+               tp_assign(sync_commit, commit_transaction->t_synchronous_commit)
+#endif
+               tp_assign(transaction, commit_transaction->t_tid)
+       ),
+
+#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,5,0))
+       TP_printk("dev %d,%d transaction %d sync %d",
+                 MAJOR(__entry->dev), MINOR(__entry->dev),
+                  __entry->transaction, __entry->sync_commit)
+#else
+       TP_printk("dev %d,%d transaction %d",
+                 MAJOR(__entry->dev), MINOR(__entry->dev),
+                  __entry->transaction)
+#endif
+)
+
+TRACE_EVENT(jbd_cleanup_journal_tail,
+
+       TP_PROTO(journal_t *journal, tid_t first_tid,
+                unsigned long block_nr, unsigned long freed),
+
+       TP_ARGS(journal, first_tid, block_nr, freed),
+
+       TP_STRUCT__entry(
+               __field(        dev_t,  dev                     )
+               __field(        tid_t,  tail_sequence           )
+               __field(        tid_t,  first_tid               )
+               __field(unsigned long,  block_nr                )
+               __field(unsigned long,  freed                   )
+       ),
+
+       TP_fast_assign(
+               tp_assign(dev, journal->j_fs_dev->bd_dev)
+               tp_assign(tail_sequence, journal->j_tail_sequence)
+               tp_assign(first_tid, first_tid)
+               tp_assign(block_nr, block_nr)
+               tp_assign(freed, freed)
+       ),
+
+       TP_printk("dev %d,%d from %u to %u offset %lu freed %lu",
+                 MAJOR(__entry->dev), MINOR(__entry->dev),
+                 __entry->tail_sequence, __entry->first_tid,
+                 __entry->block_nr, __entry->freed)
+)
+
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,5,0))
+TRACE_EVENT_MAP(journal_write_superblock,
+
+       jbd_journal_write_superblock,
+
+       TP_PROTO(journal_t *journal, int write_op),
+
+       TP_ARGS(journal, write_op),
+
+       TP_STRUCT__entry(
+               __field(        dev_t,  dev                     )
+               __field(        int,    write_op                )
+       ),
+
+       TP_fast_assign(
+               tp_assign(dev, journal->j_fs_dev->bd_dev)
+               tp_assign(write_op, write_op)
+       ),
+
+       TP_printk("dev %d,%d write_op %x", MAJOR(__entry->dev),
+                 MINOR(__entry->dev), __entry->write_op)
+)
+#else
+TRACE_EVENT(jbd_update_superblock_end,
+       TP_PROTO(journal_t *journal, int wait),
+
+       TP_ARGS(journal, wait),
+
+       TP_STRUCT__entry(
+               __field(        dev_t,  dev                     )
+               __field(        int,    wait                    )
+       ),
+
+       TP_fast_assign(
+               tp_assign(dev, journal->j_fs_dev->bd_dev)
+               tp_assign(wait, wait)
+       ),
+
+       TP_printk("dev %d,%d wait %d",
+                 MAJOR(__entry->dev), MINOR(__entry->dev),
+                  __entry->wait)
+)
+#endif
+
+#endif /* _TRACE_JBD_H */
+
+/* This part must be outside protection */
+#include "../../../probes/define_trace.h"
diff --git a/drivers/staging/lttng/instrumentation/events/lttng-module/jbd2.h b/drivers/staging/lttng/instrumentation/events/lttng-module/jbd2.h
new file mode 100644 (file)
index 0000000..872cf9e
--- /dev/null
@@ -0,0 +1,280 @@
+#undef TRACE_SYSTEM
+#define TRACE_SYSTEM jbd2
+
+#if !defined(_TRACE_JBD2_H) || defined(TRACE_HEADER_MULTI_READ)
+#define _TRACE_JBD2_H
+
+#include <linux/jbd2.h>
+#include <linux/tracepoint.h>
+#include <linux/version.h>
+
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,32))
+#ifndef _TRACE_JBD2_DEF
+#define _TRACE_JBD2_DEF
+struct transaction_chp_stats_s;
+struct transaction_run_stats_s;
+#endif
+#endif
+
+TRACE_EVENT(jbd2_checkpoint,
+
+       TP_PROTO(journal_t *journal, int result),
+
+       TP_ARGS(journal, result),
+
+       TP_STRUCT__entry(
+               __field(        dev_t,  dev                     )
+               __field(        int,    result                  )
+       ),
+
+       TP_fast_assign(
+               tp_assign(dev, journal->j_fs_dev->bd_dev)
+               tp_assign(result, result)
+       ),
+
+       TP_printk("dev %d,%d result %d",
+                 MAJOR(__entry->dev), MINOR(__entry->dev), __entry->result)
+)
+
+DECLARE_EVENT_CLASS(jbd2_commit,
+
+       TP_PROTO(journal_t *journal, transaction_t *commit_transaction),
+
+       TP_ARGS(journal, commit_transaction),
+
+       TP_STRUCT__entry(
+               __field(        dev_t,  dev                     )
+               __field(        char,   sync_commit               )
+               __field(        int,    transaction               )
+       ),
+
+       TP_fast_assign(
+               tp_assign(dev, journal->j_fs_dev->bd_dev)
+               tp_assign(sync_commit, commit_transaction->t_synchronous_commit)
+               tp_assign(transaction, commit_transaction->t_tid)
+       ),
+
+       TP_printk("dev %d,%d transaction %d sync %d",
+                 MAJOR(__entry->dev), MINOR(__entry->dev),
+                 __entry->transaction, __entry->sync_commit)
+)
+
+DEFINE_EVENT(jbd2_commit, jbd2_start_commit,
+
+       TP_PROTO(journal_t *journal, transaction_t *commit_transaction),
+
+       TP_ARGS(journal, commit_transaction)
+)
+
+DEFINE_EVENT(jbd2_commit, jbd2_commit_locking,
+
+       TP_PROTO(journal_t *journal, transaction_t *commit_transaction),
+
+       TP_ARGS(journal, commit_transaction)
+)
+
+DEFINE_EVENT(jbd2_commit, jbd2_commit_flushing,
+
+       TP_PROTO(journal_t *journal, transaction_t *commit_transaction),
+
+       TP_ARGS(journal, commit_transaction)
+)
+
+DEFINE_EVENT(jbd2_commit, jbd2_commit_logging,
+
+       TP_PROTO(journal_t *journal, transaction_t *commit_transaction),
+
+       TP_ARGS(journal, commit_transaction)
+)
+
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,4,0))
+DEFINE_EVENT(jbd2_commit, jbd2_drop_transaction,
+
+       TP_PROTO(journal_t *journal, transaction_t *commit_transaction),
+
+       TP_ARGS(journal, commit_transaction)
+)
+#endif
+
+TRACE_EVENT(jbd2_end_commit,
+       TP_PROTO(journal_t *journal, transaction_t *commit_transaction),
+
+       TP_ARGS(journal, commit_transaction),
+
+       TP_STRUCT__entry(
+               __field(        dev_t,  dev                     )
+               __field(        char,   sync_commit               )
+               __field(        int,    transaction               )
+               __field(        int,    head                      )
+       ),
+
+       TP_fast_assign(
+               tp_assign(dev, journal->j_fs_dev->bd_dev)
+               tp_assign(sync_commit, commit_transaction->t_synchronous_commit)
+               tp_assign(transaction, commit_transaction->t_tid)
+               tp_assign(head, journal->j_tail_sequence)
+       ),
+
+       TP_printk("dev %d,%d transaction %d sync %d head %d",
+                 MAJOR(__entry->dev), MINOR(__entry->dev),
+                 __entry->transaction, __entry->sync_commit, __entry->head)
+)
+
+TRACE_EVENT(jbd2_submit_inode_data,
+       TP_PROTO(struct inode *inode),
+
+       TP_ARGS(inode),
+
+       TP_STRUCT__entry(
+               __field(        dev_t,  dev                     )
+               __field(        ino_t,  ino                     )
+       ),
+
+       TP_fast_assign(
+               tp_assign(dev, inode->i_sb->s_dev)
+               tp_assign(ino, inode->i_ino)
+       ),
+
+       TP_printk("dev %d,%d ino %lu",
+                 MAJOR(__entry->dev), MINOR(__entry->dev),
+                 (unsigned long) __entry->ino)
+)
+
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,32))
+TRACE_EVENT(jbd2_run_stats,
+       TP_PROTO(dev_t dev, unsigned long tid,
+                struct transaction_run_stats_s *stats),
+
+       TP_ARGS(dev, tid, stats),
+
+       TP_STRUCT__entry(
+               __field(                dev_t,  dev             )
+               __field(        unsigned long,  tid             )
+               __field(        unsigned long,  wait            )
+               __field(        unsigned long,  running         )
+               __field(        unsigned long,  locked          )
+               __field(        unsigned long,  flushing        )
+               __field(        unsigned long,  logging         )
+               __field(                __u32,  handle_count    )
+               __field(                __u32,  blocks          )
+               __field(                __u32,  blocks_logged   )
+       ),
+
+       TP_fast_assign(
+               tp_assign(dev, dev)
+               tp_assign(tid, tid)
+               tp_assign(wait, stats->rs_wait)
+               tp_assign(running, stats->rs_running)
+               tp_assign(locked, stats->rs_locked)
+               tp_assign(flushing, stats->rs_flushing)
+               tp_assign(logging, stats->rs_logging)
+               tp_assign(handle_count, stats->rs_handle_count)
+               tp_assign(blocks, stats->rs_blocks)
+               tp_assign(blocks_logged, stats->rs_blocks_logged)
+       ),
+
+       TP_printk("dev %d,%d tid %lu wait %u running %u locked %u flushing %u "
+                 "logging %u handle_count %u blocks %u blocks_logged %u",
+                 MAJOR(__entry->dev), MINOR(__entry->dev), __entry->tid,
+                 jiffies_to_msecs(__entry->wait),
+                 jiffies_to_msecs(__entry->running),
+                 jiffies_to_msecs(__entry->locked),
+                 jiffies_to_msecs(__entry->flushing),
+                 jiffies_to_msecs(__entry->logging),
+                 __entry->handle_count, __entry->blocks,
+                 __entry->blocks_logged)
+)
+
+TRACE_EVENT(jbd2_checkpoint_stats,
+       TP_PROTO(dev_t dev, unsigned long tid,
+                struct transaction_chp_stats_s *stats),
+
+       TP_ARGS(dev, tid, stats),
+
+       TP_STRUCT__entry(
+               __field(                dev_t,  dev             )
+               __field(        unsigned long,  tid             )
+               __field(        unsigned long,  chp_time        )
+               __field(                __u32,  forced_to_close )
+               __field(                __u32,  written         )
+               __field(                __u32,  dropped         )
+       ),
+
+       TP_fast_assign(
+               tp_assign(dev, dev)
+               tp_assign(tid, tid)
+               tp_assign(chp_time, stats->cs_chp_time)
+               tp_assign(forced_to_close, stats->cs_forced_to_close)
+               tp_assign(written, stats->cs_written)
+               tp_assign(dropped, stats->cs_dropped)
+       ),
+
+       TP_printk("dev %d,%d tid %lu chp_time %u forced_to_close %u "
+                 "written %u dropped %u",
+                 MAJOR(__entry->dev), MINOR(__entry->dev), __entry->tid,
+                 jiffies_to_msecs(__entry->chp_time),
+                 __entry->forced_to_close, __entry->written, __entry->dropped)
+)
+#endif
+
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,34))
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,4,0))
+TRACE_EVENT(jbd2_update_log_tail,
+#else
+TRACE_EVENT(jbd2_cleanup_journal_tail,
+#endif
+
+       TP_PROTO(journal_t *journal, tid_t first_tid,
+                unsigned long block_nr, unsigned long freed),
+
+       TP_ARGS(journal, first_tid, block_nr, freed),
+
+       TP_STRUCT__entry(
+               __field(        dev_t,  dev                     )
+               __field(        tid_t,  tail_sequence           )
+               __field(        tid_t,  first_tid               )
+               __field(unsigned long,  block_nr                )
+               __field(unsigned long,  freed                   )
+       ),
+
+       TP_fast_assign(
+               tp_assign(dev, journal->j_fs_dev->bd_dev)
+               tp_assign(tail_sequence, journal->j_tail_sequence)
+               tp_assign(first_tid, first_tid)
+               tp_assign(block_nr, block_nr)
+               tp_assign(freed, freed)
+       ),
+
+       TP_printk("dev %d,%d from %u to %u offset %lu freed %lu",
+                 MAJOR(__entry->dev), MINOR(__entry->dev),
+                 __entry->tail_sequence, __entry->first_tid,
+                 __entry->block_nr, __entry->freed)
+)
+#endif
+
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,4,0))
+TRACE_EVENT(jbd2_write_superblock,
+
+       TP_PROTO(journal_t *journal, int write_op),
+
+       TP_ARGS(journal, write_op),
+
+       TP_STRUCT__entry(
+               __field(        dev_t,  dev                     )
+               __field(          int,  write_op                )
+       ),
+
+       TP_fast_assign(
+               tp_assign(dev, journal->j_fs_dev->bd_dev)
+               tp_assign(write_op, write_op)
+       ),
+
+       TP_printk("dev %d,%d write_op %x", MAJOR(__entry->dev),
+                 MINOR(__entry->dev), __entry->write_op)
+)
+#endif
+
+#endif /* _TRACE_JBD2_H */
+
+/* This part must be outside protection */
+#include "../../../probes/define_trace.h"
diff --git a/drivers/staging/lttng/instrumentation/events/lttng-module/kmem.h b/drivers/staging/lttng/instrumentation/events/lttng-module/kmem.h
new file mode 100644 (file)
index 0000000..2bc70a8
--- /dev/null
@@ -0,0 +1,380 @@
+#undef TRACE_SYSTEM
+#define TRACE_SYSTEM kmem
+
+#if !defined(_TRACE_KMEM_H) || defined(TRACE_HEADER_MULTI_READ)
+#define _TRACE_KMEM_H
+
+#include <linux/types.h>
+#include <linux/tracepoint.h>
+#include <linux/version.h>
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,36))
+#include <trace/events/gfpflags.h>
+#endif
+
+DECLARE_EVENT_CLASS(kmem_alloc,
+
+       TP_PROTO(unsigned long call_site,
+                const void *ptr,
+                size_t bytes_req,
+                size_t bytes_alloc,
+                gfp_t gfp_flags),
+
+       TP_ARGS(call_site, ptr, bytes_req, bytes_alloc, gfp_flags),
+
+       TP_STRUCT__entry(
+               __field_hex(    unsigned long,  call_site       )
+               __field_hex(    const void *,   ptr             )
+               __field(        size_t,         bytes_req       )
+               __field(        size_t,         bytes_alloc     )
+               __field(        gfp_t,          gfp_flags       )
+       ),
+
+       TP_fast_assign(
+               tp_assign(call_site, call_site)
+               tp_assign(ptr, ptr)
+               tp_assign(bytes_req, bytes_req)
+               tp_assign(bytes_alloc, bytes_alloc)
+               tp_assign(gfp_flags, gfp_flags)
+       ),
+
+       TP_printk("call_site=%lx ptr=%p bytes_req=%zu bytes_alloc=%zu gfp_flags=%s",
+               __entry->call_site,
+               __entry->ptr,
+               __entry->bytes_req,
+               __entry->bytes_alloc,
+               show_gfp_flags(__entry->gfp_flags))
+)
+
+DEFINE_EVENT_MAP(kmem_alloc, kmalloc,
+
+       kmem_kmalloc,
+
+       TP_PROTO(unsigned long call_site, const void *ptr,
+                size_t bytes_req, size_t bytes_alloc, gfp_t gfp_flags),
+
+       TP_ARGS(call_site, ptr, bytes_req, bytes_alloc, gfp_flags)
+)
+
+DEFINE_EVENT(kmem_alloc, kmem_cache_alloc,
+
+       TP_PROTO(unsigned long call_site, const void *ptr,
+                size_t bytes_req, size_t bytes_alloc, gfp_t gfp_flags),
+
+       TP_ARGS(call_site, ptr, bytes_req, bytes_alloc, gfp_flags)
+)
+
+DECLARE_EVENT_CLASS(kmem_alloc_node,
+
+       TP_PROTO(unsigned long call_site,
+                const void *ptr,
+                size_t bytes_req,
+                size_t bytes_alloc,
+                gfp_t gfp_flags,
+                int node),
+
+       TP_ARGS(call_site, ptr, bytes_req, bytes_alloc, gfp_flags, node),
+
+       TP_STRUCT__entry(
+               __field_hex(    unsigned long,  call_site       )
+               __field_hex(    const void *,   ptr             )
+               __field(        size_t,         bytes_req       )
+               __field(        size_t,         bytes_alloc     )
+               __field(        gfp_t,          gfp_flags       )
+               __field(        int,            node            )
+       ),
+
+       TP_fast_assign(
+               tp_assign(call_site, call_site)
+               tp_assign(ptr, ptr)
+               tp_assign(bytes_req, bytes_req)
+               tp_assign(bytes_alloc, bytes_alloc)
+               tp_assign(gfp_flags, gfp_flags)
+               tp_assign(node, node)
+       ),
+
+       TP_printk("call_site=%lx ptr=%p bytes_req=%zu bytes_alloc=%zu gfp_flags=%s node=%d",
+               __entry->call_site,
+               __entry->ptr,
+               __entry->bytes_req,
+               __entry->bytes_alloc,
+               show_gfp_flags(__entry->gfp_flags),
+               __entry->node)
+)
+
+DEFINE_EVENT_MAP(kmem_alloc_node, kmalloc_node,
+
+       kmem_kmalloc_node,
+
+       TP_PROTO(unsigned long call_site, const void *ptr,
+                size_t bytes_req, size_t bytes_alloc,
+                gfp_t gfp_flags, int node),
+
+       TP_ARGS(call_site, ptr, bytes_req, bytes_alloc, gfp_flags, node)
+)
+
+DEFINE_EVENT(kmem_alloc_node, kmem_cache_alloc_node,
+
+       TP_PROTO(unsigned long call_site, const void *ptr,
+                size_t bytes_req, size_t bytes_alloc,
+                gfp_t gfp_flags, int node),
+
+       TP_ARGS(call_site, ptr, bytes_req, bytes_alloc, gfp_flags, node)
+)
+
+DECLARE_EVENT_CLASS(kmem_free,
+
+       TP_PROTO(unsigned long call_site, const void *ptr),
+
+       TP_ARGS(call_site, ptr),
+
+       TP_STRUCT__entry(
+               __field_hex(    unsigned long,  call_site       )
+               __field_hex(    const void *,   ptr             )
+       ),
+
+       TP_fast_assign(
+               tp_assign(call_site, call_site)
+               tp_assign(ptr, ptr)
+       ),
+
+       TP_printk("call_site=%lx ptr=%p", __entry->call_site, __entry->ptr)
+)
+
+DEFINE_EVENT_MAP(kmem_free, kfree,
+
+       kmem_kfree,
+
+       TP_PROTO(unsigned long call_site, const void *ptr),
+
+       TP_ARGS(call_site, ptr)
+)
+
+DEFINE_EVENT(kmem_free, kmem_cache_free,
+
+       TP_PROTO(unsigned long call_site, const void *ptr),
+
+       TP_ARGS(call_site, ptr)
+)
+
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,32))
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,3,0))
+TRACE_EVENT(mm_page_free,
+#else
+TRACE_EVENT(mm_page_free_direct,
+#endif
+
+       TP_PROTO(struct page *page, unsigned int order),
+
+       TP_ARGS(page, order),
+
+       TP_STRUCT__entry(
+               __field_hex(    struct page *,  page            )
+               __field(        unsigned int,   order           )
+       ),
+
+       TP_fast_assign(
+               tp_assign(page, page)
+               tp_assign(order, order)
+       ),
+
+       TP_printk("page=%p pfn=%lu order=%d",
+                       __entry->page,
+                       page_to_pfn(__entry->page),
+                       __entry->order)
+)
+
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,3,0))
+TRACE_EVENT(mm_page_free_batched,
+#else
+TRACE_EVENT(mm_pagevec_free,
+#endif
+
+       TP_PROTO(struct page *page, int cold),
+
+       TP_ARGS(page, cold),
+
+       TP_STRUCT__entry(
+               __field_hex(    struct page *,  page            )
+               __field(        int,            cold            )
+       ),
+
+       TP_fast_assign(
+               tp_assign(page, page)
+               tp_assign(cold, cold)
+       ),
+
+       TP_printk("page=%p pfn=%lu order=0 cold=%d",
+                       __entry->page,
+                       page_to_pfn(__entry->page),
+                       __entry->cold)
+)
+
+TRACE_EVENT(mm_page_alloc,
+
+       TP_PROTO(struct page *page, unsigned int order,
+                       gfp_t gfp_flags, int migratetype),
+
+       TP_ARGS(page, order, gfp_flags, migratetype),
+
+       TP_STRUCT__entry(
+               __field_hex(    struct page *,  page            )
+               __field(        unsigned int,   order           )
+               __field(        gfp_t,          gfp_flags       )
+               __field(        int,            migratetype     )
+       ),
+
+       TP_fast_assign(
+               tp_assign(page, page)
+               tp_assign(order, order)
+               tp_assign(gfp_flags, gfp_flags)
+               tp_assign(migratetype, migratetype)
+       ),
+
+       TP_printk("page=%p pfn=%lu order=%d migratetype=%d gfp_flags=%s",
+               __entry->page,
+               __entry->page ? page_to_pfn(__entry->page) : 0,
+               __entry->order,
+               __entry->migratetype,
+               show_gfp_flags(__entry->gfp_flags))
+)
+
+DECLARE_EVENT_CLASS(mm_page,
+
+       TP_PROTO(struct page *page, unsigned int order, int migratetype),
+
+       TP_ARGS(page, order, migratetype),
+
+       TP_STRUCT__entry(
+               __field_hex(    struct page *,  page            )
+               __field(        unsigned int,   order           )
+               __field(        int,            migratetype     )
+       ),
+
+       TP_fast_assign(
+               tp_assign(page, page)
+               tp_assign(order, order)
+               tp_assign(migratetype, migratetype)
+       ),
+
+       TP_printk("page=%p pfn=%lu order=%u migratetype=%d percpu_refill=%d",
+               __entry->page,
+               __entry->page ? page_to_pfn(__entry->page) : 0,
+               __entry->order,
+               __entry->migratetype,
+               __entry->order == 0)
+)
+
+DEFINE_EVENT(mm_page, mm_page_alloc_zone_locked,
+
+       TP_PROTO(struct page *page, unsigned int order, int migratetype),
+
+       TP_ARGS(page, order, migratetype)
+)
+
+DEFINE_EVENT_PRINT(mm_page, mm_page_pcpu_drain,
+
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,33))
+       TP_PROTO(struct page *page, unsigned int order, int migratetype),
+#else
+       TP_PROTO(struct page *page, int order, int migratetype),
+#endif
+
+       TP_ARGS(page, order, migratetype),
+
+       TP_printk("page=%p pfn=%lu order=%d migratetype=%d",
+               __entry->page, page_to_pfn(__entry->page),
+               __entry->order, __entry->migratetype)
+)
+
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,12,0))
+
+TRACE_EVENT(mm_page_alloc_extfrag,
+
+       TP_PROTO(struct page *page,
+                       int alloc_order, int fallback_order,
+                       int alloc_migratetype, int fallback_migratetype,
+                       int change_ownership),
+
+       TP_ARGS(page,
+               alloc_order, fallback_order,
+               alloc_migratetype, fallback_migratetype,
+               change_ownership),
+
+       TP_STRUCT__entry(
+               __field_hex(    struct page *,  page                    )
+               __field(        int,            alloc_order             )
+               __field(        int,            fallback_order          )
+               __field(        int,            alloc_migratetype       )
+               __field(        int,            fallback_migratetype    )
+               __field(        int,            change_ownership        )
+       ),
+
+       TP_fast_assign(
+               tp_assign(page, page)
+               tp_assign(alloc_order, alloc_order)
+               tp_assign(fallback_order, fallback_order)
+               tp_assign(alloc_migratetype, alloc_migratetype)
+               tp_assign(fallback_migratetype, fallback_migratetype)
+               tp_assign(change_ownership, change_ownership)
+       ),
+
+       TP_printk("page=%p pfn=%lu alloc_order=%d fallback_order=%d pageblock_order=%d alloc_migratetype=%d fallback_migratetype=%d fragmenting=%d change_ownership=%d",
+               __entry->page,
+               page_to_pfn(__entry->page),
+               __entry->alloc_order,
+               __entry->fallback_order,
+               pageblock_order,
+               __entry->alloc_migratetype,
+               __entry->fallback_migratetype,
+               __entry->fallback_order < pageblock_order,
+               __entry->change_ownership)
+)
+
+#else /* #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,12,0)) */
+
+TRACE_EVENT(mm_page_alloc_extfrag,
+
+       TP_PROTO(struct page *page,
+                       int alloc_order, int fallback_order,
+                       int alloc_migratetype, int fallback_migratetype),
+
+       TP_ARGS(page,
+               alloc_order, fallback_order,
+               alloc_migratetype, fallback_migratetype),
+
+       TP_STRUCT__entry(
+               __field_hex(    struct page *,  page                    )
+               __field(        int,            alloc_order             )
+               __field(        int,            fallback_order          )
+               __field(        int,            alloc_migratetype       )
+               __field(        int,            fallback_migratetype    )
+       ),
+
+       TP_fast_assign(
+               tp_assign(page, page)
+               tp_assign(alloc_order, alloc_order)
+               tp_assign(fallback_order, fallback_order)
+               tp_assign(alloc_migratetype, alloc_migratetype)
+               tp_assign(fallback_migratetype, fallback_migratetype)
+       ),
+
+       TP_printk("page=%p pfn=%lu alloc_order=%d fallback_order=%d pageblock_order=%d alloc_migratetype=%d fallback_migratetype=%d fragmenting=%d change_ownership=%d",
+               __entry->page,
+               page_to_pfn(__entry->page),
+               __entry->alloc_order,
+               __entry->fallback_order,
+               pageblock_order,
+               __entry->alloc_migratetype,
+               __entry->fallback_migratetype,
+               __entry->fallback_order < pageblock_order,
+               __entry->alloc_migratetype == __entry->fallback_migratetype)
+)
+
+#endif /* #else #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,12,0)) */
+
+#endif
+
+#endif /* _TRACE_KMEM_H */
+
+/* This part must be outside protection */
+#include "../../../probes/define_trace.h"
diff --git a/drivers/staging/lttng/instrumentation/events/lttng-module/kvm.h b/drivers/staging/lttng/instrumentation/events/lttng-module/kvm.h
new file mode 100644 (file)
index 0000000..ba4e528
--- /dev/null
@@ -0,0 +1,356 @@
+#if !defined(_TRACE_KVM_MAIN_H) || defined(TRACE_HEADER_MULTI_READ)
+#define _TRACE_KVM_MAIN_H
+
+#include <linux/tracepoint.h>
+#include <linux/version.h>
+
+#undef TRACE_SYSTEM
+#define TRACE_SYSTEM kvm
+
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
+
+#define ERSN(x) { KVM_EXIT_##x, "KVM_EXIT_" #x }
+
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,9,0))
+
+#define kvm_trace_exit_reason                                          \
+       ERSN(UNKNOWN), ERSN(EXCEPTION), ERSN(IO), ERSN(HYPERCALL),      \
+       ERSN(DEBUG), ERSN(HLT), ERSN(MMIO), ERSN(IRQ_WINDOW_OPEN),      \
+       ERSN(SHUTDOWN), ERSN(FAIL_ENTRY), ERSN(INTR), ERSN(SET_TPR),    \
+       ERSN(TPR_ACCESS), ERSN(S390_SIEIC), ERSN(S390_RESET), ERSN(DCR),\
+       ERSN(NMI), ERSN(INTERNAL_ERROR), ERSN(OSI), ERSN(PAPR_HCALL),   \
+       ERSN(S390_UCONTROL), ERSN(WATCHDOG), ERSN(S390_TSCH)
+
+#elif (LINUX_VERSION_CODE >= KERNEL_VERSION(3,6,0))
+
+#define kvm_trace_exit_reason                                          \
+       ERSN(UNKNOWN), ERSN(EXCEPTION), ERSN(IO), ERSN(HYPERCALL),      \
+       ERSN(DEBUG), ERSN(HLT), ERSN(MMIO), ERSN(IRQ_WINDOW_OPEN),      \
+       ERSN(SHUTDOWN), ERSN(FAIL_ENTRY), ERSN(INTR), ERSN(SET_TPR),    \
+       ERSN(TPR_ACCESS), ERSN(S390_SIEIC), ERSN(S390_RESET), ERSN(DCR),\
+       ERSN(NMI), ERSN(INTERNAL_ERROR), ERSN(OSI), ERSN(PAPR_HCALL),   \
+       ERSN(S390_UCONTROL)
+
+#else
+
+#define kvm_trace_exit_reason                                          \
+       ERSN(UNKNOWN), ERSN(EXCEPTION), ERSN(IO), ERSN(HYPERCALL),      \
+       ERSN(DEBUG), ERSN(HLT), ERSN(MMIO), ERSN(IRQ_WINDOW_OPEN),      \
+       ERSN(SHUTDOWN), ERSN(FAIL_ENTRY), ERSN(INTR), ERSN(SET_TPR),    \
+       ERSN(TPR_ACCESS), ERSN(S390_SIEIC), ERSN(S390_RESET), ERSN(DCR),\
+       ERSN(NMI), ERSN(INTERNAL_ERROR), ERSN(OSI)
+
+#endif
+
+TRACE_EVENT(kvm_userspace_exit,
+           TP_PROTO(__u32 reason, int errno),
+           TP_ARGS(reason, errno),
+
+       TP_STRUCT__entry(
+               __field(        __u32,          reason          )
+               __field(        int,            errno           )
+       ),
+
+       TP_fast_assign(
+               tp_assign(reason, reason)
+               tp_assign(errno, errno)
+       ),
+
+       TP_printk("reason %s (%d)",
+                 __entry->errno < 0 ?
+                 (__entry->errno == -EINTR ? "restart" : "error") :
+                 __print_symbolic(__entry->reason, kvm_trace_exit_reason),
+                 __entry->errno < 0 ? -__entry->errno : __entry->reason)
+)
+#endif
+
+#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,6,0))
+#if defined(__KVM_HAVE_IOAPIC)
+#undef __KVM_HAVE_IRQ_LINE
+#define __KVM_HAVE_IRQ_LINE
+#endif
+#endif
+
+#if defined(__KVM_HAVE_IRQ_LINE)
+TRACE_EVENT(kvm_set_irq,
+       TP_PROTO(unsigned int gsi, int level, int irq_source_id),
+       TP_ARGS(gsi, level, irq_source_id),
+
+       TP_STRUCT__entry(
+               __field(        unsigned int,   gsi             )
+               __field(        int,            level           )
+               __field(        int,            irq_source_id   )
+       ),
+
+       TP_fast_assign(
+               tp_assign(gsi, gsi)
+               tp_assign(level, level)
+               tp_assign(irq_source_id, irq_source_id)
+       ),
+
+       TP_printk("gsi %u level %d source %d",
+                 __entry->gsi, __entry->level, __entry->irq_source_id)
+)
+#endif
+
+#if defined(__KVM_HAVE_IOAPIC)
+#define kvm_deliver_mode               \
+       {0x0, "Fixed"},                 \
+       {0x1, "LowPrio"},               \
+       {0x2, "SMI"},                   \
+       {0x3, "Res3"},                  \
+       {0x4, "NMI"},                   \
+       {0x5, "INIT"},                  \
+       {0x6, "SIPI"},                  \
+       {0x7, "ExtINT"}
+
+TRACE_EVENT(kvm_ioapic_set_irq,
+           TP_PROTO(__u64 e, int pin, bool coalesced),
+           TP_ARGS(e, pin, coalesced),
+
+       TP_STRUCT__entry(
+               __field(        __u64,          e               )
+               __field(        int,            pin             )
+               __field(        bool,           coalesced       )
+       ),
+
+       TP_fast_assign(
+               tp_assign(e, e)
+               tp_assign(pin, pin)
+               tp_assign(coalesced, coalesced)
+       ),
+
+       TP_printk("pin %u dst %x vec=%u (%s|%s|%s%s)%s",
+                 __entry->pin, (u8)(__entry->e >> 56), (u8)__entry->e,
+                 __print_symbolic((__entry->e >> 8 & 0x7), kvm_deliver_mode),
+                 (__entry->e & (1<<11)) ? "logical" : "physical",
+                 (__entry->e & (1<<15)) ? "level" : "edge",
+                 (__entry->e & (1<<16)) ? "|masked" : "",
+                 __entry->coalesced ? " (coalesced)" : "")
+)
+
+TRACE_EVENT(kvm_msi_set_irq,
+           TP_PROTO(__u64 address, __u64 data),
+           TP_ARGS(address, data),
+
+       TP_STRUCT__entry(
+               __field(        __u64,          address         )
+               __field(        __u64,          data            )
+       ),
+
+       TP_fast_assign(
+               tp_assign(address, address)
+               tp_assign(data, data)
+       ),
+
+       TP_printk("dst %u vec %x (%s|%s|%s%s)",
+                 (u8)(__entry->address >> 12), (u8)__entry->data,
+                 __print_symbolic((__entry->data >> 8 & 0x7), kvm_deliver_mode),
+                 (__entry->address & (1<<2)) ? "logical" : "physical",
+                 (__entry->data & (1<<15)) ? "level" : "edge",
+                 (__entry->address & (1<<3)) ? "|rh" : "")
+)
+
+#define kvm_irqchips                                           \
+       {KVM_IRQCHIP_PIC_MASTER,        "PIC master"},          \
+       {KVM_IRQCHIP_PIC_SLAVE,         "PIC slave"},           \
+       {KVM_IRQCHIP_IOAPIC,            "IOAPIC"}
+
+TRACE_EVENT(kvm_ack_irq,
+       TP_PROTO(unsigned int irqchip, unsigned int pin),
+       TP_ARGS(irqchip, pin),
+
+       TP_STRUCT__entry(
+               __field(        unsigned int,   irqchip         )
+               __field(        unsigned int,   pin             )
+       ),
+
+       TP_fast_assign(
+               tp_assign(irqchip, irqchip)
+               tp_assign(pin, pin)
+       ),
+
+       TP_printk("irqchip %s pin %u",
+                 __print_symbolic(__entry->irqchip, kvm_irqchips),
+                __entry->pin)
+)
+
+
+
+#endif /* defined(__KVM_HAVE_IOAPIC) */
+
+#define KVM_TRACE_MMIO_READ_UNSATISFIED 0
+#define KVM_TRACE_MMIO_READ 1
+#define KVM_TRACE_MMIO_WRITE 2
+
+#define kvm_trace_symbol_mmio \
+       { KVM_TRACE_MMIO_READ_UNSATISFIED, "unsatisfied-read" }, \
+       { KVM_TRACE_MMIO_READ, "read" }, \
+       { KVM_TRACE_MMIO_WRITE, "write" }
+
+TRACE_EVENT(kvm_mmio,
+       TP_PROTO(int type, int len, u64 gpa, u64 val),
+       TP_ARGS(type, len, gpa, val),
+
+       TP_STRUCT__entry(
+               __field(        u32,    type            )
+               __field(        u32,    len             )
+               __field(        u64,    gpa             )
+               __field(        u64,    val             )
+       ),
+
+       TP_fast_assign(
+               tp_assign(type, type)
+               tp_assign(len, len)
+               tp_assign(gpa, gpa)
+               tp_assign(val, val)
+       ),
+
+       TP_printk("mmio %s len %u gpa 0x%llx val 0x%llx",
+                 __print_symbolic(__entry->type, kvm_trace_symbol_mmio),
+                 __entry->len, __entry->gpa, __entry->val)
+)
+
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,34))
+
+#define kvm_fpu_load_symbol    \
+       {0, "unload"},          \
+       {1, "load"}
+
+TRACE_EVENT(kvm_fpu,
+       TP_PROTO(int load),
+       TP_ARGS(load),
+
+       TP_STRUCT__entry(
+               __field(        u32,            load            )
+       ),
+
+       TP_fast_assign(
+               tp_assign(load, load)
+       ),
+
+       TP_printk("%s", __print_symbolic(__entry->load, kvm_fpu_load_symbol))
+)
+
+TRACE_EVENT(kvm_age_page,
+       TP_PROTO(ulong hva, struct kvm_memory_slot *slot, int ref),
+       TP_ARGS(hva, slot, ref),
+
+       TP_STRUCT__entry(
+               __field(        u64,    hva             )
+               __field(        u64,    gfn             )
+               __field(        u8,     referenced      )
+       ),
+
+       TP_fast_assign(
+               tp_assign(hva, hva)
+               tp_assign(gfn,
+                 slot->base_gfn + ((hva - slot->userspace_addr) >> PAGE_SHIFT))
+               tp_assign(referenced, ref)
+       ),
+
+       TP_printk("hva %llx gfn %llx %s",
+                 __entry->hva, __entry->gfn,
+                 __entry->referenced ? "YOUNG" : "OLD")
+)
+#endif
+
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
+
+#ifdef CONFIG_KVM_ASYNC_PF
+DECLARE_EVENT_CLASS(kvm_async_get_page_class,
+
+       TP_PROTO(u64 gva, u64 gfn),
+
+       TP_ARGS(gva, gfn),
+
+       TP_STRUCT__entry(
+               __field(__u64, gva)
+               __field(u64, gfn)
+       ),
+
+       TP_fast_assign(
+               tp_assign(gva, gva)
+               tp_assign(gfn, gfn)
+       ),
+
+       TP_printk("gva = %#llx, gfn = %#llx", __entry->gva, __entry->gfn)
+)
+
+DEFINE_EVENT(kvm_async_get_page_class, kvm_try_async_get_page,
+
+       TP_PROTO(u64 gva, u64 gfn),
+
+       TP_ARGS(gva, gfn)
+)
+
+DEFINE_EVENT(kvm_async_get_page_class, kvm_async_pf_doublefault,
+
+       TP_PROTO(u64 gva, u64 gfn),
+
+       TP_ARGS(gva, gfn)
+)
+
+DECLARE_EVENT_CLASS(kvm_async_pf_nopresent_ready,
+
+       TP_PROTO(u64 token, u64 gva),
+
+       TP_ARGS(token, gva),
+
+       TP_STRUCT__entry(
+               __field(__u64, token)
+               __field(__u64, gva)
+       ),
+
+       TP_fast_assign(
+               tp_assign(token, token)
+               tp_assign(gva, gva)
+       ),
+
+       TP_printk("token %#llx gva %#llx", __entry->token, __entry->gva)
+
+)
+
+DEFINE_EVENT(kvm_async_pf_nopresent_ready, kvm_async_pf_not_present,
+
+       TP_PROTO(u64 token, u64 gva),
+
+       TP_ARGS(token, gva)
+)
+
+DEFINE_EVENT(kvm_async_pf_nopresent_ready, kvm_async_pf_ready,
+
+       TP_PROTO(u64 token, u64 gva),
+
+       TP_ARGS(token, gva)
+)
+
+TRACE_EVENT(
+       kvm_async_pf_completed,
+       TP_PROTO(unsigned long address, struct page *page, u64 gva),
+       TP_ARGS(address, page, gva),
+
+       TP_STRUCT__entry(
+               __field(unsigned long, address)
+               __field(pfn_t, pfn)
+               __field(u64, gva)
+               ),
+
+       TP_fast_assign(
+               tp_assign(address, address)
+               tp_assign(pfn, page ? page_to_pfn(page) : 0)
+               tp_assign(gva, gva)
+               ),
+
+       TP_printk("gva %#llx address %#lx pfn %#llx",  __entry->gva,
+                 __entry->address, __entry->pfn)
+)
+
+#endif
+
+#endif
+
+#endif /* _TRACE_KVM_MAIN_H */
+
+/* This part must be outside protection */
+#include "../../../probes/define_trace.h"
diff --git a/drivers/staging/lttng/instrumentation/events/lttng-module/lock.h b/drivers/staging/lttng/instrumentation/events/lttng-module/lock.h
new file mode 100644 (file)
index 0000000..8c1389d
--- /dev/null
@@ -0,0 +1,207 @@
+#include <linux/version.h>
+
+#undef TRACE_SYSTEM
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,33))
+#define TRACE_SYSTEM lock
+#else
+#define TRACE_SYSTEM lockdep
+#define TRACE_INCLUDE_FILE lock
+#if defined(_TRACE_LOCKDEP_H)
+#define _TRACE_LOCK_H
+#endif
+#endif
+
+#if !defined(_TRACE_LOCK_H) || defined(TRACE_HEADER_MULTI_READ)
+#define _TRACE_LOCK_H
+
+#include <linux/lockdep.h>
+#include <linux/tracepoint.h>
+
+#ifdef CONFIG_LOCKDEP
+
+TRACE_EVENT(lock_acquire,
+
+       TP_PROTO(struct lockdep_map *lock, unsigned int subclass,
+               int trylock, int read, int check,
+               struct lockdep_map *next_lock, unsigned long ip),
+
+       TP_ARGS(lock, subclass, trylock, read, check, next_lock, ip),
+
+       TP_STRUCT__entry(
+               __field(unsigned int, flags)
+               __string(name, lock->name)
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,34))
+               __field(void *, lockdep_addr)
+#endif
+       ),
+
+       TP_fast_assign(
+               tp_assign(flags, (trylock ? 1 : 0) | (read ? 2 : 0))
+               tp_strcpy(name, lock->name)
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,34))
+               tp_assign(lockdep_addr, lock)
+#endif
+       ),
+
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,34))
+       TP_printk("%p %s%s%s", __entry->lockdep_addr,
+#else
+       TP_printk("%s%s%s",
+#endif
+                 (__entry->flags & 1) ? "try " : "",
+                 (__entry->flags & 2) ? "read " : "",
+                 __get_str(name))
+)
+
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,35))
+
+DECLARE_EVENT_CLASS(lock,
+
+       TP_PROTO(struct lockdep_map *lock, unsigned long ip),
+
+       TP_ARGS(lock, ip),
+
+       TP_STRUCT__entry(
+               __string(       name,   lock->name      )
+               __field(        void *, lockdep_addr    )
+       ),
+
+       TP_fast_assign(
+               tp_strcpy(name, lock->name)
+               tp_assign(lockdep_addr, lock)
+       ),
+
+       TP_printk("%p %s",  __entry->lockdep_addr, __get_str(name))
+)
+
+DEFINE_EVENT(lock, lock_release,
+
+       TP_PROTO(struct lockdep_map *lock, unsigned long ip),
+
+       TP_ARGS(lock, ip)
+)
+
+#ifdef CONFIG_LOCK_STAT
+
+DEFINE_EVENT(lock, lock_contended,
+
+       TP_PROTO(struct lockdep_map *lock, unsigned long ip),
+
+       TP_ARGS(lock, ip)
+)
+
+DEFINE_EVENT(lock, lock_acquired,
+
+       TP_PROTO(struct lockdep_map *lock, unsigned long ip),
+
+       TP_ARGS(lock, ip)
+)
+
+#endif
+
+#else /* #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,35)) */
+
+TRACE_EVENT(lock_release,
+
+       TP_PROTO(struct lockdep_map *lock, int nested, unsigned long ip),
+
+       TP_ARGS(lock, nested, ip),
+
+       TP_STRUCT__entry(
+               __string(       name,   lock->name      )
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,34))
+               __field(        void *, lockdep_addr    )
+#endif
+       ),
+
+       TP_fast_assign(
+               tp_strcpy(name, lock->name)
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,34))
+               tp_assign(lockdep_addr, lock)
+#endif
+       ),
+
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,34))
+       TP_printk("%p %s",  __entry->lockdep_addr, __get_str(name))
+#else
+       TP_printk("%s",  __get_str(name))
+#endif
+)
+
+#ifdef CONFIG_LOCK_STAT
+
+TRACE_EVENT(lock_contended,
+
+       TP_PROTO(struct lockdep_map *lock, unsigned long ip),
+
+       TP_ARGS(lock, ip),
+
+       TP_STRUCT__entry(
+               __string(       name,   lock->name      )
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,34))
+               __field(        void *, lockdep_addr    )
+#endif
+       ),
+
+       TP_fast_assign(
+               tp_strcpy(name, lock->name)
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,34))
+               tp_assign(lockdep_addr, lock)
+#endif
+       ),
+
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,34))
+       TP_printk("%p %s",  __entry->lockdep_addr, __get_str(name))
+#else
+       TP_printk("%s",  __get_str(name))
+#endif
+)
+
+TRACE_EVENT(lock_acquired,
+
+       TP_PROTO(struct lockdep_map *lock, unsigned long ip, s64 waittime),
+
+       TP_ARGS(lock, ip, waittime),
+
+       TP_STRUCT__entry(
+               __string(       name,   lock->name      )
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,34))
+               __field(        s64,    wait_nsec       )
+               __field(        void *, lockdep_addr    )
+#else
+               __field(unsigned long, wait_usec)
+               __field(unsigned long, wait_nsec_rem)
+#endif
+       ),
+
+       TP_fast_assign(
+               tp_strcpy(name, lock->name)
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,34))
+               tp_assign(wait_nsec, waittime)
+               tp_assign(lockdep_addr, lock)
+#else
+               tp_assign(wait_usec, (unsigned long)waittime)
+               tp_assign(wait_nsec_rem, do_div(waittime, NSEC_PER_USEC))
+#endif
+       ),
+
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,34))
+       TP_printk("%p %s (%llu ns)",  __entry->lockdep_addr,
+                 __get_str(name), __entry->wait_nsec)
+#else
+       TP_printk("%s (%lu.%03lu us)",
+                 __get_str(name),
+                 __entry->wait_usec, __entry->wait_nsec_rem)
+#endif
+)
+
+#endif
+
+#endif /* #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,35)) */
+
+#endif
+
+#endif /* _TRACE_LOCK_H */
+
+/* This part must be outside protection */
+#include "../../../probes/define_trace.h"
diff --git a/drivers/staging/lttng/instrumentation/events/lttng-module/lttng-statedump.h b/drivers/staging/lttng/instrumentation/events/lttng-module/lttng-statedump.h
new file mode 100644 (file)
index 0000000..e4c86d6
--- /dev/null
@@ -0,0 +1,166 @@
+#undef TRACE_SYSTEM
+#define TRACE_SYSTEM lttng_statedump
+
+#if !defined(_TRACE_LTTNG_STATEDUMP_H) || defined(TRACE_HEADER_MULTI_READ)
+#define _TRACE_LTTNG_STATEDUMP_H
+
+#include <linux/tracepoint.h>
+#include <linux/nsproxy.h>
+#include <linux/pid_namespace.h>
+
+TRACE_EVENT(lttng_statedump_start,
+       TP_PROTO(struct lttng_session *session),
+       TP_ARGS(session),
+       TP_STRUCT__entry(
+       ),
+       TP_fast_assign(
+       ),
+       TP_printk("")
+)
+
+TRACE_EVENT(lttng_statedump_end,
+       TP_PROTO(struct lttng_session *session),
+       TP_ARGS(session),
+       TP_STRUCT__entry(
+       ),
+       TP_fast_assign(
+       ),
+       TP_printk("")
+)
+
+TRACE_EVENT(lttng_statedump_process_state,
+       TP_PROTO(struct lttng_session *session,
+               struct task_struct *p,
+               int type, int mode, int submode, int status,
+               struct pid_namespace *pid_ns),
+       TP_ARGS(session, p, type, mode, submode, status, pid_ns),
+       TP_STRUCT__entry(
+               __field(pid_t, tid)
+               __field(pid_t, vtid)
+               __field(pid_t, pid)
+               __field(pid_t, vpid)
+               __field(pid_t, ppid)
+               __field(pid_t, vppid)
+               __array_text(char, name, TASK_COMM_LEN)
+               __field(int, type)
+               __field(int, mode)
+               __field(int, submode)
+               __field(int, status)
+               __field(int, ns_level)
+       ),
+       TP_fast_assign(
+               tp_assign(tid, p->pid)
+               tp_assign(vtid, pid_ns ? task_pid_nr_ns(p, pid_ns) : 0)
+               tp_assign(pid, p->tgid)
+               tp_assign(vpid, pid_ns ? task_tgid_nr_ns(p, pid_ns) : 0)
+               tp_assign(ppid,
+                       ({
+                               pid_t ret;
+
+                               rcu_read_lock();
+                               ret = task_tgid_nr(p->real_parent);
+                               rcu_read_unlock();
+                               ret;
+                       }))
+               tp_assign(vppid,
+                       ({
+                               struct task_struct *parent;
+                               pid_t ret = 0;
+
+                               if (pid_ns) {
+                                       rcu_read_lock();
+                                       parent = rcu_dereference(p->real_parent);
+                                       ret = task_tgid_nr_ns(parent, pid_ns);
+                                       rcu_read_unlock();
+                               }
+                               ret;
+                       }))
+               tp_memcpy(name, p->comm, TASK_COMM_LEN)
+               tp_assign(type, type)
+               tp_assign(mode, mode)
+               tp_assign(submode, submode)
+               tp_assign(status, status)
+               tp_assign(ns_level, pid_ns ? pid_ns->level : 0)
+       ),
+       TP_printk("")
+)
+
+TRACE_EVENT(lttng_statedump_file_descriptor,
+       TP_PROTO(struct lttng_session *session,
+               struct task_struct *p, int fd, const char *filename),
+       TP_ARGS(session, p, fd, filename),
+       TP_STRUCT__entry(
+               __field(pid_t, pid)
+               __field(int, fd)
+               __string(filename, filename)
+       ),
+       TP_fast_assign(
+               tp_assign(pid, p->tgid)
+               tp_assign(fd, fd)
+               tp_strcpy(filename, filename)
+       ),
+       TP_printk("")
+)
+
+TRACE_EVENT(lttng_statedump_vm_map,
+       TP_PROTO(struct lttng_session *session,
+               struct task_struct *p, struct vm_area_struct *map,
+               unsigned long inode),
+       TP_ARGS(session, p, map, inode),
+       TP_STRUCT__entry(
+               __field(pid_t, pid)
+               __field_hex(unsigned long, start)
+               __field_hex(unsigned long, end)
+               __field_hex(unsigned long, flags)
+               __field(unsigned long, inode)
+               __field(unsigned long, pgoff)
+       ),
+       TP_fast_assign(
+               tp_assign(pid, p->tgid)
+               tp_assign(start, map->vm_start)
+               tp_assign(end, map->vm_end)
+               tp_assign(flags, map->vm_flags)
+               tp_assign(inode, inode)
+               tp_assign(pgoff, map->vm_pgoff << PAGE_SHIFT)
+       ),
+       TP_printk("")
+)
+
+TRACE_EVENT(lttng_statedump_network_interface,
+       TP_PROTO(struct lttng_session *session,
+               struct net_device *dev, struct in_ifaddr *ifa),
+       TP_ARGS(session, dev, ifa),
+       TP_STRUCT__entry(
+               __string(name, dev->name)
+               __field_network_hex(uint32_t, address_ipv4)
+       ),
+       TP_fast_assign(
+               tp_strcpy(name, dev->name)
+               tp_assign(address_ipv4, ifa ? ifa->ifa_address : 0U)
+       ),
+       TP_printk("")
+)
+
+/* Called with desc->lock held */
+TRACE_EVENT(lttng_statedump_interrupt,
+       TP_PROTO(struct lttng_session *session,
+               unsigned int irq, const char *chip_name,
+               struct irqaction *action),
+       TP_ARGS(session, irq, chip_name, action),
+       TP_STRUCT__entry(
+               __field(unsigned int, irq)
+               __string(name, chip_name)
+               __string(action, action->name ? : "")
+       ),
+       TP_fast_assign(
+               tp_assign(irq, irq)
+               tp_strcpy(name, chip_name)
+               tp_strcpy(action, action->name ? : "")
+       ),
+       TP_printk("")
+)
+
+#endif /*  _TRACE_LTTNG_STATEDUMP_H */
+
+/* This part must be outside protection */
+#include "../../../probes/define_trace.h"
diff --git a/drivers/staging/lttng/instrumentation/events/lttng-module/module.h b/drivers/staging/lttng/instrumentation/events/lttng-module/module.h
new file mode 100644 (file)
index 0000000..c63f866
--- /dev/null
@@ -0,0 +1,157 @@
+/*
+ * Because linux/module.h has tracepoints in the header, and ftrace.h
+ * eventually includes this file, define_trace.h includes linux/module.h
+ * But we do not want the module.h to override the TRACE_SYSTEM macro
+ * variable that define_trace.h is processing, so we only set it
+ * when module events are being processed, which would happen when
+ * CREATE_TRACE_POINTS is defined.
+ */
+#ifdef CREATE_TRACE_POINTS
+#undef TRACE_SYSTEM
+#define TRACE_SYSTEM module
+#endif
+
+#if !defined(_TRACE_MODULE_H) || defined(TRACE_HEADER_MULTI_READ)
+#define _TRACE_MODULE_H
+
+#include <linux/tracepoint.h>
+#include <linux/version.h>
+
+#ifdef CONFIG_MODULES
+
+#ifndef _TRACE_MODULE_DEF
+#define _TRACE_MODULE_DEF
+struct module;
+
+#define show_module_flags(flags) __print_flags(flags, "",      \
+       { (1UL << TAINT_PROPRIETARY_MODULE),    "P" },          \
+       { (1UL << TAINT_FORCED_MODULE),         "F" },          \
+       { (1UL << TAINT_CRAP),                  "C" })
+#endif
+
+TRACE_EVENT(module_load,
+
+       TP_PROTO(struct module *mod),
+
+       TP_ARGS(mod),
+
+       TP_STRUCT__entry(
+               __field(        unsigned int,   taints          )
+               __string(       name,           mod->name       )
+       ),
+
+       TP_fast_assign(
+               tp_assign(taints, mod->taints)
+               tp_strcpy(name, mod->name)
+       ),
+
+       TP_printk("%s %s", __get_str(name), show_module_flags(__entry->taints))
+)
+
+TRACE_EVENT(module_free,
+
+       TP_PROTO(struct module *mod),
+
+       TP_ARGS(mod),
+
+       TP_STRUCT__entry(
+               __string(       name,           mod->name       )
+       ),
+
+       TP_fast_assign(
+               tp_strcpy(name, mod->name)
+       ),
+
+       TP_printk("%s", __get_str(name))
+)
+
+#ifdef CONFIG_MODULE_UNLOAD
+/* trace_module_get/put are only used if CONFIG_MODULE_UNLOAD is defined */
+
+DECLARE_EVENT_CLASS(module_refcnt,
+
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,35))
+       TP_PROTO(struct module *mod, unsigned long ip),
+
+       TP_ARGS(mod, ip),
+#else
+       TP_PROTO(struct module *mod, unsigned long ip, int refcnt),
+
+       TP_ARGS(mod, ip, refcnt),
+#endif
+
+       TP_STRUCT__entry(
+               __field(        unsigned long,  ip              )
+               __field(        int,            refcnt          )
+               __string(       name,           mod->name       )
+       ),
+
+       TP_fast_assign(
+               tp_assign(ip, ip)
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,35))
+               tp_assign(refcnt, __this_cpu_read(mod->refptr->incs) + __this_cpu_read(mod->refptr->decs))
+#else
+               tp_assign(refcnt, refcnt)
+#endif
+               tp_strcpy(name, mod->name)
+       ),
+
+       TP_printk("%s call_site=%pf refcnt=%d",
+                 __get_str(name), (void *)__entry->ip, __entry->refcnt)
+)
+
+DEFINE_EVENT(module_refcnt, module_get,
+
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,35))
+       TP_PROTO(struct module *mod, unsigned long ip),
+
+       TP_ARGS(mod, ip)
+#else
+       TP_PROTO(struct module *mod, unsigned long ip, int refcnt),
+
+       TP_ARGS(mod, ip, refcnt)
+#endif
+)
+
+DEFINE_EVENT(module_refcnt, module_put,
+
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,35))
+       TP_PROTO(struct module *mod, unsigned long ip),
+
+       TP_ARGS(mod, ip)
+#else
+       TP_PROTO(struct module *mod, unsigned long ip, int refcnt),
+
+       TP_ARGS(mod, ip, refcnt)
+#endif
+)
+#endif /* CONFIG_MODULE_UNLOAD */
+
+TRACE_EVENT(module_request,
+
+       TP_PROTO(char *name, bool wait, unsigned long ip),
+
+       TP_ARGS(name, wait, ip),
+
+       TP_STRUCT__entry(
+               __field(        unsigned long,  ip              )
+               __field(        bool,           wait            )
+               __string(       name,           name            )
+       ),
+
+       TP_fast_assign(
+               tp_assign(ip, ip)
+               tp_assign(wait, wait)
+               tp_strcpy(name, name)
+       ),
+
+       TP_printk("%s wait=%d call_site=%pf",
+                 __get_str(name), (int)__entry->wait, (void *)__entry->ip)
+)
+
+#endif /* CONFIG_MODULES */
+
+#endif /* _TRACE_MODULE_H */
+
+/* This part must be outside protection */
+#include "../../../probes/define_trace.h"
diff --git a/drivers/staging/lttng/instrumentation/events/lttng-module/napi.h b/drivers/staging/lttng/instrumentation/events/lttng-module/napi.h
new file mode 100644 (file)
index 0000000..26b10ba
--- /dev/null
@@ -0,0 +1,38 @@
+#undef TRACE_SYSTEM
+#define TRACE_SYSTEM napi
+
+#if !defined(_TRACE_NAPI_H_) || defined(TRACE_HEADER_MULTI_READ)
+#define _TRACE_NAPI_H_
+
+#include <linux/netdevice.h>
+#include <linux/tracepoint.h>
+#include <linux/ftrace.h>
+
+#define NO_DEV "(no_device)"
+
+TRACE_EVENT(napi_poll,
+
+       TP_PROTO(struct napi_struct *napi),
+
+       TP_ARGS(napi),
+
+       TP_STRUCT__entry(
+               __field(        struct napi_struct *,   napi)
+               __string(       dev_name, napi->dev ? napi->dev->name : NO_DEV)
+       ),
+
+       TP_fast_assign(
+               tp_assign(napi, napi)
+               tp_strcpy(dev_name, napi->dev ? napi->dev->name : NO_DEV)
+       ),
+
+       TP_printk("napi poll on napi struct %p for device %s",
+               __entry->napi, __get_str(dev_name))
+)
+
+#undef NO_DEV
+
+#endif /* _TRACE_NAPI_H_ */
+
+/* This part must be outside protection */
+#include "../../../probes/define_trace.h"
diff --git a/drivers/staging/lttng/instrumentation/events/lttng-module/net.h b/drivers/staging/lttng/instrumentation/events/lttng-module/net.h
new file mode 100644 (file)
index 0000000..e156a04
--- /dev/null
@@ -0,0 +1,105 @@
+#undef TRACE_SYSTEM
+#define TRACE_SYSTEM net
+
+#if !defined(_TRACE_NET_H) || defined(TRACE_HEADER_MULTI_READ)
+#define _TRACE_NET_H
+
+#include <linux/skbuff.h>
+#include <linux/netdevice.h>
+#include <linux/ip.h>
+#include <linux/tracepoint.h>
+#include <linux/version.h>
+
+TRACE_EVENT(net_dev_xmit,
+
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,40))
+       TP_PROTO(struct sk_buff *skb,
+                int rc,
+                struct net_device *dev,
+                unsigned int skb_len),
+
+       TP_ARGS(skb, rc, dev, skb_len),
+#else
+       TP_PROTO(struct sk_buff *skb,
+                int rc),
+
+       TP_ARGS(skb, rc),
+#endif
+
+       TP_STRUCT__entry(
+               __field(        void *,         skbaddr         )
+               __field(        unsigned int,   len             )
+               __field(        int,            rc              )
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,40))
+               __string(       name,           dev->name       )
+#else
+               __string(       name,           skb->dev->name  )
+#endif
+       ),
+
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,40))
+       TP_fast_assign(
+               tp_assign(skbaddr, skb)
+               tp_assign(len, skb_len)
+               tp_assign(rc, rc)
+               tp_strcpy(name, dev->name)
+       ),
+#else
+       TP_fast_assign(
+               tp_assign(skbaddr, skb)
+               tp_assign(len, skb->len)
+               tp_assign(rc, rc)
+               tp_strcpy(name, skb->dev->name)
+       ),
+#endif
+
+       TP_printk("dev=%s skbaddr=%p len=%u rc=%d",
+               __get_str(name), __entry->skbaddr, __entry->len, __entry->rc)
+)
+
+DECLARE_EVENT_CLASS(net_dev_template,
+
+       TP_PROTO(struct sk_buff *skb),
+
+       TP_ARGS(skb),
+
+       TP_STRUCT__entry(
+               __field(        void *,         skbaddr         )
+               __field(        unsigned int,   len             )
+               __string(       name,           skb->dev->name  )
+       ),
+
+       TP_fast_assign(
+               tp_assign(skbaddr, skb)
+               tp_assign(len, skb->len)
+               tp_strcpy(name, skb->dev->name)
+       ),
+
+       TP_printk("dev=%s skbaddr=%p len=%u",
+               __get_str(name), __entry->skbaddr, __entry->len)
+)
+
+DEFINE_EVENT(net_dev_template, net_dev_queue,
+
+       TP_PROTO(struct sk_buff *skb),
+
+       TP_ARGS(skb)
+)
+
+DEFINE_EVENT(net_dev_template, netif_receive_skb,
+
+       TP_PROTO(struct sk_buff *skb),
+
+       TP_ARGS(skb)
+)
+
+DEFINE_EVENT(net_dev_template, netif_rx,
+
+       TP_PROTO(struct sk_buff *skb),
+
+       TP_ARGS(skb)
+)
+#endif /* _TRACE_NET_H */
+
+/* This part must be outside protection */
+#include "../../../probes/define_trace.h"
diff --git a/drivers/staging/lttng/instrumentation/events/lttng-module/power.h b/drivers/staging/lttng/instrumentation/events/lttng-module/power.h
new file mode 100644 (file)
index 0000000..f366a63
--- /dev/null
@@ -0,0 +1,351 @@
+#undef TRACE_SYSTEM
+#define TRACE_SYSTEM power
+
+#if !defined(_TRACE_POWER_H) || defined(TRACE_HEADER_MULTI_READ)
+#define _TRACE_POWER_H
+
+#include <linux/ktime.h>
+#include <linux/tracepoint.h>
+#include <linux/version.h>
+
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
+DECLARE_EVENT_CLASS(power_cpu,
+
+       TP_PROTO(unsigned int state, unsigned int cpu_id),
+
+       TP_ARGS(state, cpu_id),
+
+       TP_STRUCT__entry(
+               __field(        u32,            state           )
+               __field(        u32,            cpu_id          )
+       ),
+
+       TP_fast_assign(
+               tp_assign(state, state)
+               tp_assign(cpu_id, cpu_id)
+       ),
+
+       TP_printk("state=%lu cpu_id=%lu", (unsigned long)__entry->state,
+                 (unsigned long)__entry->cpu_id)
+)
+
+DEFINE_EVENT_MAP(power_cpu, cpu_idle,
+
+       power_cpu_idle,
+
+       TP_PROTO(unsigned int state, unsigned int cpu_id),
+
+       TP_ARGS(state, cpu_id)
+)
+
+/* This file can get included multiple times, TRACE_HEADER_MULTI_READ at top */
+#ifndef _PWR_EVENT_AVOID_DOUBLE_DEFINING
+#define _PWR_EVENT_AVOID_DOUBLE_DEFINING
+
+#define PWR_EVENT_EXIT -1
+#endif
+
+DEFINE_EVENT_MAP(power_cpu, cpu_frequency,
+
+       power_cpu_frequency,
+
+       TP_PROTO(unsigned int frequency, unsigned int cpu_id),
+
+       TP_ARGS(frequency, cpu_id)
+)
+
+TRACE_EVENT_MAP(machine_suspend,
+
+       power_machine_suspend,
+
+       TP_PROTO(unsigned int state),
+
+       TP_ARGS(state),
+
+       TP_STRUCT__entry(
+               __field(        u32,            state           )
+       ),
+
+       TP_fast_assign(
+               tp_assign(state, state)
+       ),
+
+       TP_printk("state=%lu", (unsigned long)__entry->state)
+)
+#endif
+
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,5,0))
+DECLARE_EVENT_CLASS(power_wakeup_source,
+
+       TP_PROTO(const char *name, unsigned int state),
+
+       TP_ARGS(name, state),
+
+       TP_STRUCT__entry(
+               __string(       name,           name            )
+               __field(        u64,            state           )
+       ),
+
+       TP_fast_assign(
+               tp_strcpy(name, name)
+               tp_assign(state, state)
+       ),
+
+       TP_printk("%s state=0x%lx", __get_str(name),
+               (unsigned long)__entry->state)
+)
+
+DEFINE_EVENT_MAP(power_wakeup_source, wakeup_source_activate,
+
+       power_wakeup_source_activate,
+
+       TP_PROTO(const char *name, unsigned int state),
+
+       TP_ARGS(name, state)
+)
+
+DEFINE_EVENT_MAP(power_wakeup_source, wakeup_source_deactivate,
+
+       power_wakeup_source_deactivate,
+
+       TP_PROTO(const char *name, unsigned int state),
+
+       TP_ARGS(name, state)
+)
+#endif
+
+#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,38))
+#undef CONFIG_EVENT_POWER_TRACING_DEPRECATED
+#define CONFIG_EVENT_POWER_TRACING_DEPRECATED
+#define _PWR_EVENT_AVOID_DOUBLE_DEFINING_DEPRECATED
+#endif
+
+#ifdef CONFIG_EVENT_POWER_TRACING_DEPRECATED
+
+/*
+ * The power events are used for cpuidle & suspend (power_start, power_end)
+ *  and for cpufreq (power_frequency)
+ */
+DECLARE_EVENT_CLASS(power,
+
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,36))
+       TP_PROTO(unsigned int type, unsigned int state, unsigned int cpu_id),
+
+       TP_ARGS(type, state, cpu_id),
+#else
+       TP_PROTO(unsigned int type, unsigned int state),
+
+       TP_ARGS(type, state),
+#endif
+
+       TP_STRUCT__entry(
+               __field(        u64,            type            )
+               __field(        u64,            state           )
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,36))
+               __field(        u64,            cpu_id          )
+#endif
+       ),
+
+       TP_fast_assign(
+               tp_assign(type, type)
+               tp_assign(state, state)
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,36))
+               tp_assign(cpu_id, cpu_id)
+#endif
+       ),
+
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,36))
+       TP_printk("type=%lu state=%lu cpu_id=%lu", (unsigned long)__entry->type,
+               (unsigned long)__entry->state, (unsigned long)__entry->cpu_id)
+#else
+       TP_printk("type=%lu state=%lu", (unsigned long)__entry->type,
+               (unsigned long)__entry->state)
+#endif
+)
+
+DEFINE_EVENT(power, power_start,
+
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,36))
+       TP_PROTO(unsigned int type, unsigned int state, unsigned int cpu_id),
+
+       TP_ARGS(type, state, cpu_id)
+#else
+       TP_PROTO(unsigned int type, unsigned int state),
+
+       TP_ARGS(type, state)
+#endif
+)
+
+DEFINE_EVENT(power, power_frequency,
+
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,36))
+       TP_PROTO(unsigned int type, unsigned int state, unsigned int cpu_id),
+
+       TP_ARGS(type, state, cpu_id)
+#else
+       TP_PROTO(unsigned int type, unsigned int state),
+
+       TP_ARGS(type, state)
+#endif
+)
+
+TRACE_EVENT(power_end,
+
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,36))
+       TP_PROTO(unsigned int cpu_id),
+
+       TP_ARGS(cpu_id),
+#else
+       TP_PROTO(int dummy),
+
+       TP_ARGS(dummy),
+#endif
+
+       TP_STRUCT__entry(
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,36))
+               __field(        u64,            cpu_id          )
+#else
+               __field(        u64,            dummy           )
+#endif
+       ),
+
+       TP_fast_assign(
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,36))
+               tp_assign(cpu_id, cpu_id)
+#else
+               tp_assign(dummy, 0xffff)
+#endif
+       ),
+
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,36))
+       TP_printk("cpu_id=%lu", (unsigned long)__entry->cpu_id)
+#else
+       TP_printk("dummy=%lu", (unsigned long)__entry->dummy)
+#endif
+)
+
+/* Deprecated dummy functions must be protected against multi-declartion */
+#ifndef _PWR_EVENT_AVOID_DOUBLE_DEFINING_DEPRECATED
+#define _PWR_EVENT_AVOID_DOUBLE_DEFINING_DEPRECATED
+
+enum {
+       POWER_NONE = 0,
+       POWER_CSTATE = 1,
+       POWER_PSTATE = 2,
+};
+#endif /* _PWR_EVENT_AVOID_DOUBLE_DEFINING_DEPRECATED */
+
+#else /* CONFIG_EVENT_POWER_TRACING_DEPRECATED */
+
+#ifndef _PWR_EVENT_AVOID_DOUBLE_DEFINING_DEPRECATED
+#define _PWR_EVENT_AVOID_DOUBLE_DEFINING_DEPRECATED
+enum {
+       POWER_NONE = 0,
+       POWER_CSTATE = 1,
+       POWER_PSTATE = 2,
+};
+
+/* These dummy declaration have to be ripped out when the deprecated
+   events get removed */
+static inline void trace_power_start(u64 type, u64 state, u64 cpuid) {};
+static inline void trace_power_end(u64 cpuid) {};
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,4,0))
+static inline void trace_power_start_rcuidle(u64 type, u64 state, u64 cpuid) {};
+static inline void trace_power_end_rcuidle(u64 cpuid) {};
+#endif
+static inline void trace_power_frequency(u64 type, u64 state, u64 cpuid) {};
+#endif /* _PWR_EVENT_AVOID_DOUBLE_DEFINING_DEPRECATED */
+
+#endif /* CONFIG_EVENT_POWER_TRACING_DEPRECATED */
+
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,37))
+/*
+ * The clock events are used for clock enable/disable and for
+ *  clock rate change
+ */
+DECLARE_EVENT_CLASS(power_clock,
+
+       TP_PROTO(const char *name, unsigned int state, unsigned int cpu_id),
+
+       TP_ARGS(name, state, cpu_id),
+
+       TP_STRUCT__entry(
+               __string(       name,           name            )
+               __field(        u64,            state           )
+               __field(        u64,            cpu_id          )
+       ),
+
+       TP_fast_assign(
+               tp_strcpy(name, name)
+               tp_assign(state, state)
+               tp_assign(cpu_id, cpu_id)
+       ),
+
+       TP_printk("%s state=%lu cpu_id=%lu", __get_str(name),
+               (unsigned long)__entry->state, (unsigned long)__entry->cpu_id)
+)
+
+DEFINE_EVENT_MAP(power_clock, clock_enable,
+
+       power_clock_enable,
+
+       TP_PROTO(const char *name, unsigned int state, unsigned int cpu_id),
+
+       TP_ARGS(name, state, cpu_id)
+)
+
+DEFINE_EVENT_MAP(power_clock, clock_disable,
+
+       power_clock_disable,
+
+       TP_PROTO(const char *name, unsigned int state, unsigned int cpu_id),
+
+       TP_ARGS(name, state, cpu_id)
+)
+
+DEFINE_EVENT_MAP(power_clock, clock_set_rate,
+
+       power_clock_set_rate,
+
+       TP_PROTO(const char *name, unsigned int state, unsigned int cpu_id),
+
+       TP_ARGS(name, state, cpu_id)
+)
+
+/*
+ * The power domain events are used for power domains transitions
+ */
+DECLARE_EVENT_CLASS(power_domain,
+
+       TP_PROTO(const char *name, unsigned int state, unsigned int cpu_id),
+
+       TP_ARGS(name, state, cpu_id),
+
+       TP_STRUCT__entry(
+               __string(       name,           name            )
+               __field(        u64,            state           )
+               __field(        u64,            cpu_id          )
+       ),
+
+       TP_fast_assign(
+               tp_strcpy(name, name)
+               tp_assign(state, state)
+               tp_assign(cpu_id, cpu_id)
+),
+
+       TP_printk("%s state=%lu cpu_id=%lu", __get_str(name),
+               (unsigned long)__entry->state, (unsigned long)__entry->cpu_id)
+)
+
+DEFINE_EVENT(power_domain, power_domain_target,
+
+       TP_PROTO(const char *name, unsigned int state, unsigned int cpu_id),
+
+       TP_ARGS(name, state, cpu_id)
+)
+#endif
+
+#endif /* _TRACE_POWER_H */
+
+/* This part must be outside protection */
+#include "../../../probes/define_trace.h"
diff --git a/drivers/staging/lttng/instrumentation/events/lttng-module/printk.h b/drivers/staging/lttng/instrumentation/events/lttng-module/printk.h
new file mode 100644 (file)
index 0000000..9ac55c7
--- /dev/null
@@ -0,0 +1,83 @@
+#undef TRACE_SYSTEM
+#define TRACE_SYSTEM printk
+
+#if !defined(_TRACE_PRINTK_H) || defined(TRACE_HEADER_MULTI_READ)
+#define _TRACE_PRINTK_H
+
+#include <linux/tracepoint.h>
+#include <linux/version.h>
+
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,10,0))
+
+TRACE_EVENT(console,
+       TP_PROTO(const char *text, size_t len),
+
+       TP_ARGS(text, len),
+
+       TP_STRUCT__entry(
+               __dynamic_array_text(char, msg, len)
+       ),
+
+       TP_fast_assign(
+               tp_memcpy_dyn(msg, text)
+       ),
+
+       TP_printk("%s", __get_str(msg))
+)
+
+#elif (LINUX_VERSION_CODE >= KERNEL_VERSION(3,5,0))
+
+TRACE_EVENT_CONDITION(console,
+       TP_PROTO(const char *log_buf, unsigned start, unsigned end,
+                unsigned log_buf_len),
+
+       TP_ARGS(log_buf, start, end, log_buf_len),
+
+       TP_CONDITION(start != end),
+
+       TP_STRUCT__entry(
+               __dynamic_array_text(char, msg, end - start)
+       ),
+
+       TP_fast_assign(
+               tp_memcpy_dyn(msg, log_buf + start)
+       ),
+
+       TP_printk("%s", __get_str(msg))
+)
+
+#else /* (LINUX_VERSION_CODE < KERNEL_VERSION(3,5,0)) */
+
+TRACE_EVENT_CONDITION(console,
+       TP_PROTO(const char *log_buf, unsigned start, unsigned end,
+                unsigned log_buf_len),
+
+       TP_ARGS(log_buf, start, end, log_buf_len),
+
+       TP_CONDITION(start != end),
+
+       TP_STRUCT__entry(
+               __dynamic_array_text_2(char, msg,
+                       (start & (log_buf_len - 1)) > (end & (log_buf_len - 1))
+                               ? log_buf_len - (start & (log_buf_len - 1))
+                               : end - start,
+                       (start & (log_buf_len - 1)) > (end & (log_buf_len - 1))
+                               ? end & (log_buf_len - 1)
+                               : 0)
+       ),
+
+       TP_fast_assign(
+               tp_memcpy_dyn_2(msg,
+                       log_buf + (start & (log_buf_len - 1)),
+                       log_buf)
+       ),
+
+       TP_printk("%s", __get_str(msg))
+)
+
+#endif
+
+#endif /* _TRACE_PRINTK_H */
+
+/* This part must be outside protection */
+#include "../../../probes/define_trace.h"
diff --git a/drivers/staging/lttng/instrumentation/events/lttng-module/random.h b/drivers/staging/lttng/instrumentation/events/lttng-module/random.h
new file mode 100644 (file)
index 0000000..d7bda0d
--- /dev/null
@@ -0,0 +1,152 @@
+#undef TRACE_SYSTEM
+#define TRACE_SYSTEM random
+
+#if !defined(_TRACE_RANDOM_H) || defined(TRACE_HEADER_MULTI_READ)
+#define _TRACE_RANDOM_H
+
+#include <linux/writeback.h>
+#include <linux/tracepoint.h>
+
+DECLARE_EVENT_CLASS(random__mix_pool_bytes,
+       TP_PROTO(const char *pool_name, int bytes, unsigned long IP),
+
+       TP_ARGS(pool_name, bytes, IP),
+
+       TP_STRUCT__entry(
+               __string(   pool_name,  pool_name               )
+               __field(          int,  bytes                   )
+               __field(unsigned long,  IP                      )
+       ),
+
+       TP_fast_assign(
+               tp_strcpy(pool_name, pool_name)
+               tp_assign(bytes, bytes)
+               tp_assign(IP, IP)
+       ),
+
+       TP_printk("%s pool: bytes %d caller %pF",
+                 __get_str(pool_name), __entry->bytes, (void *)__entry->IP)
+)
+
+DEFINE_EVENT_MAP(random__mix_pool_bytes, mix_pool_bytes,
+
+       random_mix_pool_bytes,
+
+       TP_PROTO(const char *pool_name, int bytes, unsigned long IP),
+
+       TP_ARGS(pool_name, bytes, IP)
+)
+
+DEFINE_EVENT_MAP(random__mix_pool_bytes, mix_pool_bytes_nolock,
+
+       random_mix_pool_bytes_nolock,
+
+       TP_PROTO(const char *pool_name, int bytes, unsigned long IP),
+
+       TP_ARGS(pool_name, bytes, IP)
+)
+
+TRACE_EVENT_MAP(credit_entropy_bits,
+
+       random_credit_entropy_bits,
+
+       TP_PROTO(const char *pool_name, int bits, int entropy_count,
+                int entropy_total, unsigned long IP),
+
+       TP_ARGS(pool_name, bits, entropy_count, entropy_total, IP),
+
+       TP_STRUCT__entry(
+               __string(   pool_name,  pool_name               )
+               __field(          int,  bits                    )
+               __field(          int,  entropy_count           )
+               __field(          int,  entropy_total           )
+               __field(unsigned long,  IP                      )
+       ),
+
+       TP_fast_assign(
+               tp_strcpy(pool_name, pool_name)
+               tp_assign(bits, bits)
+               tp_assign(entropy_count, entropy_count)
+               tp_assign(entropy_total, entropy_total)
+               tp_assign(IP, IP)
+       ),
+
+       TP_printk("%s pool: bits %d entropy_count %d entropy_total %d "
+                 "caller %pF", __get_str(pool_name), __entry->bits,
+                 __entry->entropy_count, __entry->entropy_total,
+                 (void *)__entry->IP)
+)
+
+TRACE_EVENT_MAP(get_random_bytes,
+
+       random_get_random_bytes,
+
+       TP_PROTO(int nbytes, unsigned long IP),
+
+       TP_ARGS(nbytes, IP),
+
+       TP_STRUCT__entry(
+               __field(          int,  nbytes                  )
+               __field(unsigned long,  IP                      )
+       ),
+
+       TP_fast_assign(
+               tp_assign(nbytes, nbytes)
+               tp_assign(IP, IP)
+       ),
+
+       TP_printk("nbytes %d caller %pF", __entry->nbytes, (void *)__entry->IP)
+)
+
+DECLARE_EVENT_CLASS(random__extract_entropy,
+       TP_PROTO(const char *pool_name, int nbytes, int entropy_count,
+                unsigned long IP),
+
+       TP_ARGS(pool_name, nbytes, entropy_count, IP),
+
+       TP_STRUCT__entry(
+               __string(   pool_name,  pool_name               )
+               __field(          int,  nbytes                  )
+               __field(          int,  entropy_count           )
+               __field(unsigned long,  IP                      )
+       ),
+
+       TP_fast_assign(
+               tp_strcpy(pool_name, pool_name)
+               tp_assign(nbytes, nbytes)
+               tp_assign(entropy_count, entropy_count)
+               tp_assign(IP, IP)
+       ),
+
+       TP_printk("%s pool: nbytes %d entropy_count %d caller %pF",
+                 __get_str(pool_name), __entry->nbytes, __entry->entropy_count,
+                 (void *)__entry->IP)
+)
+
+
+DEFINE_EVENT_MAP(random__extract_entropy, extract_entropy,
+
+       random_extract_entropy,
+
+       TP_PROTO(const char *pool_name, int nbytes, int entropy_count,
+                unsigned long IP),
+
+       TP_ARGS(pool_name, nbytes, entropy_count, IP)
+)
+
+DEFINE_EVENT_MAP(random__extract_entropy, extract_entropy_user,
+
+       random_extract_entropy_user,
+
+       TP_PROTO(const char *pool_name, int nbytes, int entropy_count,
+                unsigned long IP),
+
+       TP_ARGS(pool_name, nbytes, entropy_count, IP)
+)
+
+
+
+#endif /* _TRACE_RANDOM_H */
+
+/* This part must be outside protection */
+#include "../../../probes/define_trace.h"
diff --git a/drivers/staging/lttng/instrumentation/events/lttng-module/rcu.h b/drivers/staging/lttng/instrumentation/events/lttng-module/rcu.h
new file mode 100644 (file)
index 0000000..1220fb7
--- /dev/null
@@ -0,0 +1,763 @@
+#undef TRACE_SYSTEM
+#define TRACE_SYSTEM rcu
+
+#if !defined(_TRACE_RCU_H) || defined(TRACE_HEADER_MULTI_READ)
+#define _TRACE_RCU_H
+
+#include <linux/tracepoint.h>
+#include <linux/version.h>
+
+/*
+ * Tracepoint for start/end markers used for utilization calculations.
+ * By convention, the string is of the following forms:
+ *
+ * "Start <activity>" -- Mark the start of the specified activity,
+ *                      such as "context switch".  Nesting is permitted.
+ * "End <activity>" -- Mark the end of the specified activity.
+ *
+ * An "@" character within "<activity>" is a comment character: Data
+ * reduction scripts will ignore the "@" and the remainder of the line.
+ */
+TRACE_EVENT(rcu_utilization,
+
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,12,0))
+       TP_PROTO(const char *s),
+#else /* #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,12,0)) */
+       TP_PROTO(char *s),
+#endif /* #else #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,12,0)) */
+
+       TP_ARGS(s),
+
+       TP_STRUCT__entry(
+               __string(s, s)
+       ),
+
+       TP_fast_assign(
+               tp_strcpy(s, s)
+       ),
+
+       TP_printk("%s", __get_str(s))
+)
+
+#ifdef CONFIG_RCU_TRACE
+
+#if defined(CONFIG_TREE_RCU) || defined(CONFIG_TREE_PREEMPT_RCU)
+
+/*
+ * Tracepoint for grace-period events: starting and ending a grace
+ * period ("start" and "end", respectively), a CPU noting the start
+ * of a new grace period or the end of an old grace period ("cpustart"
+ * and "cpuend", respectively), a CPU passing through a quiescent
+ * state ("cpuqs"), a CPU coming online or going offline ("cpuonl"
+ * and "cpuofl", respectively), and a CPU being kicked for being too
+ * long in dyntick-idle mode ("kick").
+ */
+TRACE_EVENT(rcu_grace_period,
+
+       TP_PROTO(char *rcuname, unsigned long gpnum, char *gpevent),
+
+       TP_ARGS(rcuname, gpnum, gpevent),
+
+       TP_STRUCT__entry(
+               __string(rcuname, rcuname)
+               __field(unsigned long, gpnum)
+               __string(gpevent, gpevent)
+       ),
+
+       TP_fast_assign(
+               tp_strcpy(rcuname, rcuname)
+               tp_assign(gpnum, gpnum)
+               tp_strcpy(gpevent, gpevent)
+       ),
+
+       TP_printk("%s %lu %s",
+                 __get_str(rcuname), __entry->gpnum, __get_str(gpevent))
+)
+
+/*
+ * Tracepoint for grace-period-initialization events.  These are
+ * distinguished by the type of RCU, the new grace-period number, the
+ * rcu_node structure level, the starting and ending CPU covered by the
+ * rcu_node structure, and the mask of CPUs that will be waited for.
+ * All but the type of RCU are extracted from the rcu_node structure.
+ */
+TRACE_EVENT(rcu_grace_period_init,
+
+       TP_PROTO(char *rcuname, unsigned long gpnum, u8 level,
+                int grplo, int grphi, unsigned long qsmask),
+
+       TP_ARGS(rcuname, gpnum, level, grplo, grphi, qsmask),
+
+       TP_STRUCT__entry(
+               __string(rcuname, rcuname)
+               __field(unsigned long, gpnum)
+               __field(u8, level)
+               __field(int, grplo)
+               __field(int, grphi)
+               __field(unsigned long, qsmask)
+       ),
+
+       TP_fast_assign(
+               tp_strcpy(rcuname, rcuname)
+               tp_assign(gpnum, gpnum)
+               tp_assign(level, level)
+               tp_assign(grplo, grplo)
+               tp_assign(grphi, grphi)
+               tp_assign(qsmask, qsmask)
+       ),
+
+       TP_printk("%s %lu %u %d %d %lx",
+                 __get_str(rcuname), __entry->gpnum, __entry->level,
+                 __entry->grplo, __entry->grphi, __entry->qsmask)
+)
+
+/*
+ * Tracepoint for tasks blocking within preemptible-RCU read-side
+ * critical sections.  Track the type of RCU (which one day might
+ * include SRCU), the grace-period number that the task is blocking
+ * (the current or the next), and the task's PID.
+ */
+TRACE_EVENT(rcu_preempt_task,
+
+       TP_PROTO(char *rcuname, int pid, unsigned long gpnum),
+
+       TP_ARGS(rcuname, pid, gpnum),
+
+       TP_STRUCT__entry(
+               __string(rcuname, rcuname)
+               __field(unsigned long, gpnum)
+               __field(int, pid)
+       ),
+
+       TP_fast_assign(
+               tp_strcpy(rcuname, rcuname)
+               tp_assign(gpnum, gpnum)
+               tp_assign(pid, pid)
+       ),
+
+       TP_printk("%s %lu %d",
+                 __get_str(rcuname), __entry->gpnum, __entry->pid)
+)
+
+/*
+ * Tracepoint for tasks that blocked within a given preemptible-RCU
+ * read-side critical section exiting that critical section.  Track the
+ * type of RCU (which one day might include SRCU) and the task's PID.
+ */
+TRACE_EVENT(rcu_unlock_preempted_task,
+
+       TP_PROTO(char *rcuname, unsigned long gpnum, int pid),
+
+       TP_ARGS(rcuname, gpnum, pid),
+
+       TP_STRUCT__entry(
+               __string(rcuname, rcuname)
+               __field(unsigned long, gpnum)
+               __field(int, pid)
+       ),
+
+       TP_fast_assign(
+               tp_strcpy(rcuname, rcuname)
+               tp_assign(gpnum, gpnum)
+               tp_assign(pid, pid)
+       ),
+
+       TP_printk("%s %lu %d", __get_str(rcuname), __entry->gpnum, __entry->pid)
+)
+
+/*
+ * Tracepoint for quiescent-state-reporting events.  These are
+ * distinguished by the type of RCU, the grace-period number, the
+ * mask of quiescent lower-level entities, the rcu_node structure level,
+ * the starting and ending CPU covered by the rcu_node structure, and
+ * whether there are any blocked tasks blocking the current grace period.
+ * All but the type of RCU are extracted from the rcu_node structure.
+ */
+TRACE_EVENT(rcu_quiescent_state_report,
+
+       TP_PROTO(char *rcuname, unsigned long gpnum,
+                unsigned long mask, unsigned long qsmask,
+                u8 level, int grplo, int grphi, int gp_tasks),
+
+       TP_ARGS(rcuname, gpnum, mask, qsmask, level, grplo, grphi, gp_tasks),
+
+       TP_STRUCT__entry(
+               __string(rcuname, rcuname)
+               __field(unsigned long, gpnum)
+               __field(unsigned long, mask)
+               __field(unsigned long, qsmask)
+               __field(u8, level)
+               __field(int, grplo)
+               __field(int, grphi)
+               __field(u8, gp_tasks)
+       ),
+
+       TP_fast_assign(
+               tp_strcpy(rcuname, rcuname)
+               tp_assign(gpnum, gpnum)
+               tp_assign(mask, mask)
+               tp_assign(qsmask, qsmask)
+               tp_assign(level, level)
+               tp_assign(grplo, grplo)
+               tp_assign(grphi, grphi)
+               tp_assign(gp_tasks, gp_tasks)
+       ),
+
+       TP_printk("%s %lu %lx>%lx %u %d %d %u",
+                 __get_str(rcuname), __entry->gpnum,
+                 __entry->mask, __entry->qsmask, __entry->level,
+                 __entry->grplo, __entry->grphi, __entry->gp_tasks)
+)
+
+/*
+ * Tracepoint for quiescent states detected by force_quiescent_state().
+ * These trace events include the type of RCU, the grace-period number
+ * that was blocked by the CPU, the CPU itself, and the type of quiescent
+ * state, which can be "dti" for dyntick-idle mode, "ofl" for CPU offline,
+ * or "kick" when kicking a CPU that has been in dyntick-idle mode for
+ * too long.
+ */
+TRACE_EVENT(rcu_fqs,
+
+       TP_PROTO(char *rcuname, unsigned long gpnum, int cpu, char *qsevent),
+
+       TP_ARGS(rcuname, gpnum, cpu, qsevent),
+
+       TP_STRUCT__entry(
+               __string(rcuname, rcuname)
+               __field(unsigned long, gpnum)
+               __field(int, cpu)
+               __string(qsevent, qsevent)
+       ),
+
+       TP_fast_assign(
+               tp_strcpy(rcuname, rcuname)
+               tp_assign(gpnum, gpnum)
+               tp_assign(cpu, cpu)
+               tp_strcpy(qsevent, qsevent)
+       ),
+
+       TP_printk("%s %lu %d %s",
+                 __get_str(rcuname), __entry->gpnum,
+                 __entry->cpu, __get_str(qsevent))
+)
+
+#endif /* #if defined(CONFIG_TREE_RCU) || defined(CONFIG_TREE_PREEMPT_RCU) */
+
+/*
+ * Tracepoint for dyntick-idle entry/exit events.  These take a string
+ * as argument: "Start" for entering dyntick-idle mode, "End" for
+ * leaving it, "--=" for events moving towards idle, and "++=" for events
+ * moving away from idle.  "Error on entry: not idle task" and "Error on
+ * exit: not idle task" indicate that a non-idle task is erroneously
+ * toying with the idle loop.
+ *
+ * These events also take a pair of numbers, which indicate the nesting
+ * depth before and after the event of interest.  Note that task-related
+ * events use the upper bits of each number, while interrupt-related
+ * events use the lower bits.
+ */
+TRACE_EVENT(rcu_dyntick,
+
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,3,0))
+       TP_PROTO(char *polarity, long long oldnesting, long long newnesting),
+
+       TP_ARGS(polarity, oldnesting, newnesting),
+#else
+       TP_PROTO(char *polarity),
+
+       TP_ARGS(polarity),
+#endif
+
+       TP_STRUCT__entry(
+               __string(polarity, polarity)
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,3,0))
+               __field(long long, oldnesting)
+               __field(long long, newnesting)
+#endif
+       ),
+
+       TP_fast_assign(
+               tp_strcpy(polarity, polarity)
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,3,0))
+               tp_assign(oldnesting, oldnesting)
+               tp_assign(newnesting, newnesting)
+#endif
+       ),
+
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,3,0))
+       TP_printk("%s %llx %llx", __get_str(polarity),
+                 __entry->oldnesting, __entry->newnesting)
+#else
+       TP_printk("%s", __get_str(polarity))
+#endif
+)
+
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,3,0))
+/*
+ * Tracepoint for RCU preparation for idle, the goal being to get RCU
+ * processing done so that the current CPU can shut off its scheduling
+ * clock and enter dyntick-idle mode.  One way to accomplish this is
+ * to drain all RCU callbacks from this CPU, and the other is to have
+ * done everything RCU requires for the current grace period.  In this
+ * latter case, the CPU will be awakened at the end of the current grace
+ * period in order to process the remainder of its callbacks.
+ *
+ * These tracepoints take a string as argument:
+ *
+ *     "No callbacks": Nothing to do, no callbacks on this CPU.
+ *     "In holdoff": Nothing to do, holding off after unsuccessful attempt.
+ *     "Begin holdoff": Attempt failed, don't retry until next jiffy.
+ *     "Dyntick with callbacks": Entering dyntick-idle despite callbacks.
+ *     "Dyntick with lazy callbacks": Entering dyntick-idle w/lazy callbacks.
+ *     "More callbacks": Still more callbacks, try again to clear them out.
+ *     "Callbacks drained": All callbacks processed, off to dyntick idle!
+ *     "Timer": Timer fired to cause CPU to continue processing callbacks.
+ *     "Demigrate": Timer fired on wrong CPU, woke up correct CPU.
+ *     "Cleanup after idle": Idle exited, timer canceled.
+ */
+TRACE_EVENT(rcu_prep_idle,
+
+       TP_PROTO(char *reason),
+
+       TP_ARGS(reason),
+
+       TP_STRUCT__entry(
+               __string(reason, reason)
+       ),
+
+       TP_fast_assign(
+               tp_strcpy(reason, reason)
+       ),
+
+       TP_printk("%s", __get_str(reason))
+)
+#endif
+
+/*
+ * Tracepoint for the registration of a single RCU callback function.
+ * The first argument is the type of RCU, the second argument is
+ * a pointer to the RCU callback itself, the third element is the
+ * number of lazy callbacks queued, and the fourth element is the
+ * total number of callbacks queued.
+ */
+TRACE_EVENT(rcu_callback,
+
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,4,0))
+       TP_PROTO(char *rcuname, struct rcu_head *rhp, long qlen_lazy,
+                long qlen),
+
+       TP_ARGS(rcuname, rhp, qlen_lazy, qlen),
+#else
+       TP_PROTO(char *rcuname, struct rcu_head *rhp, long qlen),
+
+       TP_ARGS(rcuname, rhp, qlen),
+#endif
+
+       TP_STRUCT__entry(
+               __string(rcuname, rcuname)
+               __field(void *, rhp)
+               __field(void *, func)
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,4,0))
+               __field(long, qlen_lazy)
+#endif
+               __field(long, qlen)
+       ),
+
+       TP_fast_assign(
+               tp_strcpy(rcuname, rcuname)
+               tp_assign(rhp, rhp)
+               tp_assign(func, rhp->func)
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,4,0))
+               tp_assign(qlen_lazy, qlen_lazy)
+#endif
+               tp_assign(qlen, qlen)
+       ),
+
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,4,0))
+       TP_printk("%s rhp=%p func=%pf %ld/%ld",
+                 __get_str(rcuname), __entry->rhp, __entry->func,
+                 __entry->qlen_lazy, __entry->qlen)
+#else
+       TP_printk("%s rhp=%p func=%pf %ld",
+                 __get_str(rcuname), __entry->rhp, __entry->func,
+                 __entry->qlen)
+#endif
+)
+
+/*
+ * Tracepoint for the registration of a single RCU callback of the special
+ * kfree() form.  The first argument is the RCU type, the second argument
+ * is a pointer to the RCU callback, the third argument is the offset
+ * of the callback within the enclosing RCU-protected data structure,
+ * the fourth argument is the number of lazy callbacks queued, and the
+ * fifth argument is the total number of callbacks queued.
+ */
+TRACE_EVENT(rcu_kfree_callback,
+
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,4,0))
+       TP_PROTO(char *rcuname, struct rcu_head *rhp, unsigned long offset,
+                long qlen_lazy, long qlen),
+
+       TP_ARGS(rcuname, rhp, offset, qlen_lazy, qlen),
+#else
+       TP_PROTO(char *rcuname, struct rcu_head *rhp, unsigned long offset,
+                long qlen),
+
+       TP_ARGS(rcuname, rhp, offset, qlen),
+#endif
+
+       TP_STRUCT__entry(
+               __string(rcuname, rcuname)
+               __field(void *, rhp)
+               __field(unsigned long, offset)
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,4,0))
+               __field(long, qlen_lazy)
+#endif
+               __field(long, qlen)
+       ),
+
+       TP_fast_assign(
+               tp_strcpy(rcuname, rcuname)
+               tp_assign(rhp, rhp)
+               tp_assign(offset, offset)
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,4,0))
+               tp_assign(qlen_lazy, qlen_lazy)
+#endif
+               tp_assign(qlen, qlen)
+       ),
+
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,4,0))
+       TP_printk("%s rhp=%p func=%ld %ld/%ld",
+                 __get_str(rcuname), __entry->rhp, __entry->offset,
+                 __entry->qlen_lazy, __entry->qlen)
+#else
+       TP_printk("%s rhp=%p func=%ld %ld",
+                 __get_str(rcuname), __entry->rhp, __entry->offset,
+                 __entry->qlen)
+#endif
+)
+
+/*
+ * Tracepoint for marking the beginning rcu_do_batch, performed to start
+ * RCU callback invocation.  The first argument is the RCU flavor,
+ * the second is the number of lazy callbacks queued, the third is
+ * the total number of callbacks queued, and the fourth argument is
+ * the current RCU-callback batch limit.
+ */
+TRACE_EVENT(rcu_batch_start,
+
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,9,0))
+       TP_PROTO(char *rcuname, long qlen_lazy, long qlen, long blimit),
+
+       TP_ARGS(rcuname, qlen_lazy, qlen, blimit),
+#elif (LINUX_VERSION_CODE >= KERNEL_VERSION(3,4,0))
+       TP_PROTO(char *rcuname, long qlen_lazy, long qlen, int blimit),
+
+       TP_ARGS(rcuname, qlen_lazy, qlen, blimit),
+#else
+       TP_PROTO(char *rcuname, long qlen, int blimit),
+
+       TP_ARGS(rcuname, qlen, blimit),
+#endif
+
+       TP_STRUCT__entry(
+               __string(rcuname, rcuname)
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,4,0))
+               __field(long, qlen_lazy)
+#endif
+               __field(long, qlen)
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,9,0))
+               __field(long, blimit)
+#else
+               __field(int, blimit)
+#endif
+       ),
+
+       TP_fast_assign(
+               tp_strcpy(rcuname, rcuname)
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,4,0))
+               tp_assign(qlen_lazy, qlen_lazy)
+#endif
+               tp_assign(qlen, qlen)
+               tp_assign(blimit, blimit)
+       ),
+
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,9,0))
+       TP_printk("%s CBs=%ld/%ld bl=%ld",
+                 __get_str(rcuname), __entry->qlen_lazy, __entry->qlen,
+                 __entry->blimit)
+#elif (LINUX_VERSION_CODE >= KERNEL_VERSION(3,4,0))
+       TP_printk("%s CBs=%ld/%ld bl=%d",
+                 __get_str(rcuname), __entry->qlen_lazy, __entry->qlen,
+                 __entry->blimit)
+#else
+       TP_printk("%s CBs=%ld bl=%d",
+                 __get_str(rcuname), __entry->qlen, __entry->blimit)
+#endif
+)
+
+/*
+ * Tracepoint for the invocation of a single RCU callback function.
+ * The first argument is the type of RCU, and the second argument is
+ * a pointer to the RCU callback itself.
+ */
+TRACE_EVENT(rcu_invoke_callback,
+
+       TP_PROTO(char *rcuname, struct rcu_head *rhp),
+
+       TP_ARGS(rcuname, rhp),
+
+       TP_STRUCT__entry(
+               __string(rcuname, rcuname)
+               __field(void *, rhp)
+               __field(void *, func)
+       ),
+
+       TP_fast_assign(
+               tp_strcpy(rcuname, rcuname)
+               tp_assign(rhp, rhp)
+               tp_assign(func, rhp->func)
+       ),
+
+       TP_printk("%s rhp=%p func=%pf",
+                 __get_str(rcuname), __entry->rhp, __entry->func)
+)
+
+/*
+ * Tracepoint for the invocation of a single RCU callback of the special
+ * kfree() form.  The first argument is the RCU flavor, the second
+ * argument is a pointer to the RCU callback, and the third argument
+ * is the offset of the callback within the enclosing RCU-protected
+ * data structure.
+ */
+TRACE_EVENT(rcu_invoke_kfree_callback,
+
+       TP_PROTO(char *rcuname, struct rcu_head *rhp, unsigned long offset),
+
+       TP_ARGS(rcuname, rhp, offset),
+
+       TP_STRUCT__entry(
+               __string(rcuname, rcuname)
+               __field(void *, rhp)
+               __field(unsigned long, offset)
+       ),
+
+       TP_fast_assign(
+               tp_strcpy(rcuname, rcuname)
+               tp_assign(rhp, rhp)
+               tp_assign(offset, offset)
+       ),
+
+       TP_printk("%s rhp=%p func=%ld",
+                 __get_str(rcuname), __entry->rhp, __entry->offset)
+)
+
+/*
+ * Tracepoint for exiting rcu_do_batch after RCU callbacks have been
+ * invoked.  The first argument is the name of the RCU flavor,
+ * the second argument is number of callbacks actually invoked,
+ * the third argument (cb) is whether or not any of the callbacks that
+ * were ready to invoke at the beginning of this batch are still
+ * queued, the fourth argument (nr) is the return value of need_resched(),
+ * the fifth argument (iit) is 1 if the current task is the idle task,
+ * and the sixth argument (risk) is the return value from
+ * rcu_is_callbacks_kthread().
+ */
+TRACE_EVENT(rcu_batch_end,
+
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,3,0))
+       TP_PROTO(char *rcuname, int callbacks_invoked,
+                bool cb, bool nr, bool iit, bool risk),
+
+       TP_ARGS(rcuname, callbacks_invoked, cb, nr, iit, risk),
+#else
+       TP_PROTO(char *rcuname, int callbacks_invoked),
+
+       TP_ARGS(rcuname, callbacks_invoked),
+#endif
+
+       TP_STRUCT__entry(
+               __string(rcuname, rcuname)
+               __field(int, callbacks_invoked)
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,3,0))
+               __field(bool, cb)
+               __field(bool, nr)
+               __field(bool, iit)
+               __field(bool, risk)
+#endif
+       ),
+
+       TP_fast_assign(
+               tp_strcpy(rcuname, rcuname)
+               tp_assign(callbacks_invoked, callbacks_invoked)
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,3,0))
+               tp_assign(cb, cb)
+               tp_assign(nr, nr)
+               tp_assign(iit, iit)
+               tp_assign(risk, risk)
+#endif
+       ),
+
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,3,0))
+       TP_printk("%s CBs-invoked=%d idle=%c%c%c%c",
+                 __get_str(rcuname), __entry->callbacks_invoked,
+                 __entry->cb ? 'C' : '.',
+                 __entry->nr ? 'S' : '.',
+                 __entry->iit ? 'I' : '.',
+                 __entry->risk ? 'R' : '.')
+#else
+       TP_printk("%s CBs-invoked=%d",
+                 __get_str(rcuname), __entry->callbacks_invoked)
+#endif
+)
+
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,3,0))
+/*
+ * Tracepoint for rcutorture readers.  The first argument is the name
+ * of the RCU flavor from rcutorture's viewpoint and the second argument
+ * is the callback address.
+ */
+TRACE_EVENT(rcu_torture_read,
+
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,9,0))
+       TP_PROTO(char *rcutorturename, struct rcu_head *rhp,
+                unsigned long secs, unsigned long c_old, unsigned long c),
+
+       TP_ARGS(rcutorturename, rhp, secs, c_old, c),
+#else
+       TP_PROTO(char *rcutorturename, struct rcu_head *rhp),
+
+       TP_ARGS(rcutorturename, rhp),
+#endif
+
+       TP_STRUCT__entry(
+               __string(rcutorturename, rcutorturename)
+               __field(struct rcu_head *, rhp)
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,9,0))
+               __field(unsigned long, secs)
+               __field(unsigned long, c_old)
+               __field(unsigned long, c)
+#endif
+       ),
+
+       TP_fast_assign(
+               tp_strcpy(rcutorturename, rcutorturename)
+               tp_assign(rhp, rhp)
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,9,0))
+               tp_assign(secs, secs)
+               tp_assign(c_old, c_old)
+               tp_assign(c, c)
+#endif
+       ),
+
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,9,0))
+       TP_printk("%s torture read %p %luus c: %lu %lu",
+                 __entry->rcutorturename, __entry->rhp,
+                 __entry->secs, __entry->c_old, __entry->c)
+#else
+       TP_printk("%s torture read %p",
+                 __get_str(rcutorturename), __entry->rhp)
+#endif
+)
+#endif
+
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,6,0))
+/*
+ * Tracepoint for _rcu_barrier() execution.  The string "s" describes
+ * the _rcu_barrier phase:
+ *     "Begin": rcu_barrier_callback() started.
+ *     "Check": rcu_barrier_callback() checking for piggybacking.
+ *     "EarlyExit": rcu_barrier_callback() piggybacked, thus early exit.
+ *     "Inc1": rcu_barrier_callback() piggyback check counter incremented.
+ *     "Offline": rcu_barrier_callback() found offline CPU
+ *     "OnlineQ": rcu_barrier_callback() found online CPU with callbacks.
+ *     "OnlineNQ": rcu_barrier_callback() found online CPU, no callbacks.
+ *     "IRQ": An rcu_barrier_callback() callback posted on remote CPU.
+ *     "CB": An rcu_barrier_callback() invoked a callback, not the last.
+ *     "LastCB": An rcu_barrier_callback() invoked the last callback.
+ *     "Inc2": rcu_barrier_callback() piggyback check counter incremented.
+ * The "cpu" argument is the CPU or -1 if meaningless, the "cnt" argument
+ * is the count of remaining callbacks, and "done" is the piggybacking count.
+ */
+TRACE_EVENT(rcu_barrier,
+
+       TP_PROTO(char *rcuname, char *s, int cpu, int cnt, unsigned long done),
+
+       TP_ARGS(rcuname, s, cpu, cnt, done),
+
+       TP_STRUCT__entry(
+               __string(rcuname, rcuname)
+               __string(s, s)
+               __field(int, cpu)
+               __field(int, cnt)
+               __field(unsigned long, done)
+       ),
+
+       TP_fast_assign(
+               tp_strcpy(rcuname, rcuname)
+               tp_strcpy(s, s)
+               tp_assign(cpu, cpu)
+               tp_assign(cnt, cnt)
+               tp_assign(done, done)
+       ),
+
+       TP_printk("%s %s cpu %d remaining %d # %lu",
+                 __get_str(rcuname), __get_str(s), __entry->cpu, __entry->cnt,
+                 __entry->done)
+)
+#endif
+
+#else /* #ifdef CONFIG_RCU_TRACE */
+
+#define trace_rcu_grace_period(rcuname, gpnum, gpevent) do { } while (0)
+#define trace_rcu_grace_period_init(rcuname, gpnum, level, grplo, grphi, \
+                                   qsmask) do { } while (0)
+#define trace_rcu_preempt_task(rcuname, pid, gpnum) do { } while (0)
+#define trace_rcu_unlock_preempted_task(rcuname, gpnum, pid) do { } while (0)
+#define trace_rcu_quiescent_state_report(rcuname, gpnum, mask, qsmask, level, \
+                                        grplo, grphi, gp_tasks) do { } \
+       while (0)
+#define trace_rcu_fqs(rcuname, gpnum, cpu, qsevent) do { } while (0)
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,3,0))
+#define trace_rcu_dyntick(polarity, oldnesting, newnesting) do { } while (0)
+#else
+#define trace_rcu_dyntick(polarity) do { } while (0)
+#endif
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,3,0))
+#define trace_rcu_prep_idle(reason) do { } while (0)
+#endif
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,4,0))
+#define trace_rcu_callback(rcuname, rhp, qlen_lazy, qlen) do { } while (0)
+#define trace_rcu_kfree_callback(rcuname, rhp, offset, qlen_lazy, qlen) \
+       do { } while (0)
+#define trace_rcu_batch_start(rcuname, qlen_lazy, qlen, blimit) \
+       do { } while (0)
+#else
+#define trace_rcu_callback(rcuname, rhp, qlen) do { } while (0)
+#define trace_rcu_kfree_callback(rcuname, rhp, offset, qlen) do { } while (0)
+#define trace_rcu_batch_start(rcuname, qlen, blimit) do { } while (0)
+#endif
+#define trace_rcu_invoke_callback(rcuname, rhp) do { } while (0)
+#define trace_rcu_invoke_kfree_callback(rcuname, rhp, offset) do { } while (0)
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,3,0))
+#define trace_rcu_batch_end(rcuname, callbacks_invoked, cb, nr, iit, risk) \
+       do { } while (0)
+#else
+#define trace_rcu_batch_end(rcuname, callbacks_invoked) do { } while (0)
+#endif
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,9,0))
+#define trace_rcu_torture_read(rcutorturename, rhp, secs, c_old, c) \
+       do { } while (0)
+#elif (LINUX_VERSION_CODE >= KERNEL_VERSION(3,3,0))
+#define trace_rcu_torture_read(rcutorturename, rhp) do { } while (0)
+#endif
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,6,0))
+#define trace_rcu_barrier(name, s, cpu, cnt, done) do { } while (0)
+#endif
+#endif /* #else #ifdef CONFIG_RCU_TRACE */
+
+#endif /* _TRACE_RCU_H */
+
+/* This part must be outside protection */
+#include "../../../probes/define_trace.h"
diff --git a/drivers/staging/lttng/instrumentation/events/lttng-module/regmap.h b/drivers/staging/lttng/instrumentation/events/lttng-module/regmap.h
new file mode 100644 (file)
index 0000000..df56ac0
--- /dev/null
@@ -0,0 +1,188 @@
+#undef TRACE_SYSTEM
+#define TRACE_SYSTEM regmap
+
+#if !defined(_TRACE_REGMAP_H) || defined(TRACE_HEADER_MULTI_READ)
+#define _TRACE_REGMAP_H
+
+#include <linux/ktime.h>
+#include <linux/tracepoint.h>
+#include <linux/version.h>
+
+#ifndef _TRACE_REGMAP_DEF_
+#define _TRACE_REGMAP_DEF_
+struct device;
+struct regmap;
+#endif
+
+/*
+ * Log register events
+ */
+DECLARE_EVENT_CLASS(regmap_reg,
+
+       TP_PROTO(struct device *dev, unsigned int reg,
+                unsigned int val),
+
+       TP_ARGS(dev, reg, val),
+
+       TP_STRUCT__entry(
+               __string(       name,           dev_name(dev)   )
+               __field(        unsigned int,   reg             )
+               __field(        unsigned int,   val             )
+       ),
+
+       TP_fast_assign(
+               tp_strcpy(name, dev_name(dev))
+               tp_assign(reg, reg)
+               tp_assign(val, val)
+       ),
+
+       TP_printk("%s reg=%x val=%x", __get_str(name),
+                 (unsigned int)__entry->reg,
+                 (unsigned int)__entry->val)
+)
+
+DEFINE_EVENT(regmap_reg, regmap_reg_write,
+
+       TP_PROTO(struct device *dev, unsigned int reg,
+                unsigned int val),
+
+       TP_ARGS(dev, reg, val)
+
+)
+
+DEFINE_EVENT(regmap_reg, regmap_reg_read,
+
+       TP_PROTO(struct device *dev, unsigned int reg,
+                unsigned int val),
+
+       TP_ARGS(dev, reg, val)
+
+)
+
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,3,0))
+DEFINE_EVENT(regmap_reg, regmap_reg_read_cache,
+
+       TP_PROTO(struct device *dev, unsigned int reg,
+                unsigned int val),
+
+       TP_ARGS(dev, reg, val)
+
+)
+#endif
+
+DECLARE_EVENT_CLASS(regmap_block,
+
+       TP_PROTO(struct device *dev, unsigned int reg, int count),
+
+       TP_ARGS(dev, reg, count),
+
+       TP_STRUCT__entry(
+               __string(       name,           dev_name(dev)   )
+               __field(        unsigned int,   reg             )
+               __field(        int,            count           )
+       ),
+
+       TP_fast_assign(
+               tp_strcpy(name, dev_name(dev))
+               tp_assign(reg, reg)
+               tp_assign(count, count)
+       ),
+
+       TP_printk("%s reg=%x count=%d", __get_str(name),
+                 (unsigned int)__entry->reg,
+                 (int)__entry->count)
+)
+
+DEFINE_EVENT(regmap_block, regmap_hw_read_start,
+
+       TP_PROTO(struct device *dev, unsigned int reg, int count),
+
+       TP_ARGS(dev, reg, count)
+)
+
+DEFINE_EVENT(regmap_block, regmap_hw_read_done,
+
+       TP_PROTO(struct device *dev, unsigned int reg, int count),
+
+       TP_ARGS(dev, reg, count)
+)
+
+DEFINE_EVENT(regmap_block, regmap_hw_write_start,
+
+       TP_PROTO(struct device *dev, unsigned int reg, int count),
+
+       TP_ARGS(dev, reg, count)
+)
+
+DEFINE_EVENT(regmap_block, regmap_hw_write_done,
+
+       TP_PROTO(struct device *dev, unsigned int reg, int count),
+
+       TP_ARGS(dev, reg, count)
+)
+
+TRACE_EVENT(regcache_sync,
+
+       TP_PROTO(struct device *dev, const char *type,
+                const char *status),
+
+       TP_ARGS(dev, type, status),
+
+       TP_STRUCT__entry(
+               __string(       name,           dev_name(dev)   )
+               __string(       status,         status          )
+               __string(       type,           type            )
+       ),
+
+       TP_fast_assign(
+               tp_strcpy(name, dev_name(dev))
+               tp_strcpy(status, status)
+               tp_strcpy(type, type)
+       ),
+
+       TP_printk("%s type=%s status=%s", __get_str(name),
+                 __get_str(type), __get_str(status))
+)
+
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,4,0))
+DECLARE_EVENT_CLASS(regmap_bool,
+
+       TP_PROTO(struct device *dev, bool flag),
+
+       TP_ARGS(dev, flag),
+
+       TP_STRUCT__entry(
+               __string(       name,           dev_name(dev)   )
+               __field(        int,            flag            )
+       ),
+
+       TP_fast_assign(
+               tp_strcpy(name, dev_name(dev))
+               tp_assign(flag, flag)
+       ),
+
+       TP_printk("%s flag=%d", __get_str(name),
+                 (int)__entry->flag)
+)
+
+DEFINE_EVENT(regmap_bool, regmap_cache_only,
+
+       TP_PROTO(struct device *dev, bool flag),
+
+       TP_ARGS(dev, flag)
+
+)
+
+DEFINE_EVENT(regmap_bool, regmap_cache_bypass,
+
+       TP_PROTO(struct device *dev, bool flag),
+
+       TP_ARGS(dev, flag)
+
+)
+#endif
+
+#endif /* _TRACE_REGMAP_H */
+
+/* This part must be outside protection */
+#include "../../../probes/define_trace.h"
diff --git a/drivers/staging/lttng/instrumentation/events/lttng-module/regulator.h b/drivers/staging/lttng/instrumentation/events/lttng-module/regulator.h
new file mode 100644 (file)
index 0000000..bb84c47
--- /dev/null
@@ -0,0 +1,141 @@
+#undef TRACE_SYSTEM
+#define TRACE_SYSTEM regulator
+
+#if !defined(_TRACE_REGULATOR_H) || defined(TRACE_HEADER_MULTI_READ)
+#define _TRACE_REGULATOR_H
+
+#include <linux/ktime.h>
+#include <linux/tracepoint.h>
+
+/*
+ * Events which just log themselves and the regulator name for enable/disable
+ * type tracking.
+ */
+DECLARE_EVENT_CLASS(regulator_basic,
+
+       TP_PROTO(const char *name),
+
+       TP_ARGS(name),
+
+       TP_STRUCT__entry(
+               __string(       name,   name    )
+       ),
+
+       TP_fast_assign(
+               tp_strcpy(name, name)
+       ),
+
+       TP_printk("name=%s", __get_str(name))
+
+)
+
+DEFINE_EVENT(regulator_basic, regulator_enable,
+
+       TP_PROTO(const char *name),
+
+       TP_ARGS(name)
+
+)
+
+DEFINE_EVENT(regulator_basic, regulator_enable_delay,
+
+       TP_PROTO(const char *name),
+
+       TP_ARGS(name)
+
+)
+
+DEFINE_EVENT(regulator_basic, regulator_enable_complete,
+
+       TP_PROTO(const char *name),
+
+       TP_ARGS(name)
+
+)
+
+DEFINE_EVENT(regulator_basic, regulator_disable,
+
+       TP_PROTO(const char *name),
+
+       TP_ARGS(name)
+
+)
+
+DEFINE_EVENT(regulator_basic, regulator_disable_complete,
+
+       TP_PROTO(const char *name),
+
+       TP_ARGS(name)
+
+)
+
+/*
+ * Events that take a range of numerical values, mostly for voltages
+ * and so on.
+ */
+DECLARE_EVENT_CLASS(regulator_range,
+
+       TP_PROTO(const char *name, int min, int max),
+
+       TP_ARGS(name, min, max),
+
+       TP_STRUCT__entry(
+               __string(       name,           name            )
+               __field(        int,            min             )
+               __field(        int,            max             )
+       ),
+
+       TP_fast_assign(
+               tp_strcpy(name, name)
+               tp_assign(min, min)
+               tp_assign(max, max)
+       ),
+
+       TP_printk("name=%s (%d-%d)", __get_str(name),
+                 (int)__entry->min, (int)__entry->max)
+)
+
+DEFINE_EVENT(regulator_range, regulator_set_voltage,
+
+       TP_PROTO(const char *name, int min, int max),
+
+       TP_ARGS(name, min, max)
+
+)
+
+
+/*
+ * Events that take a single value, mostly for readback and refcounts.
+ */
+DECLARE_EVENT_CLASS(regulator_value,
+
+       TP_PROTO(const char *name, unsigned int val),
+
+       TP_ARGS(name, val),
+
+       TP_STRUCT__entry(
+               __string(       name,           name            )
+               __field(        unsigned int,   val             )
+       ),
+
+       TP_fast_assign(
+               tp_strcpy(name, name)
+               tp_assign(val, val)
+       ),
+
+       TP_printk("name=%s, val=%u", __get_str(name),
+                 (int)__entry->val)
+)
+
+DEFINE_EVENT(regulator_value, regulator_set_voltage_complete,
+
+       TP_PROTO(const char *name, unsigned int value),
+
+       TP_ARGS(name, value)
+
+)
+
+#endif /* _TRACE_POWER_H */
+
+/* This part must be outside protection */
+#include "../../../probes/define_trace.h"
diff --git a/drivers/staging/lttng/instrumentation/events/lttng-module/rpm.h b/drivers/staging/lttng/instrumentation/events/lttng-module/rpm.h
new file mode 100644 (file)
index 0000000..16bcad0
--- /dev/null
@@ -0,0 +1,101 @@
+
+#undef TRACE_SYSTEM
+#define TRACE_SYSTEM rpm
+
+#if !defined(_TRACE_RUNTIME_POWER_H) || defined(TRACE_HEADER_MULTI_READ)
+#define _TRACE_RUNTIME_POWER_H
+
+#include <linux/ktime.h>
+#include <linux/tracepoint.h>
+
+#ifndef _TRACE_RPM_DEF_
+#define _TRACE_RPM_DEF_
+struct device;
+#endif
+
+/*
+ * The rpm_internal events are used for tracing some important
+ * runtime pm internal functions.
+ */
+DECLARE_EVENT_CLASS(rpm_internal,
+
+       TP_PROTO(struct device *dev, int flags),
+
+       TP_ARGS(dev, flags),
+
+       TP_STRUCT__entry(
+               __string(       name,           dev_name(dev)   )
+               __field(        int,            flags           )
+               __field(        int ,           usage_count     )
+               __field(        int ,           disable_depth   )
+               __field(        int ,           runtime_auto    )
+               __field(        int ,           request_pending )
+               __field(        int ,           irq_safe        )
+               __field(        int ,           child_count     )
+       ),
+
+       TP_fast_assign(
+               tp_strcpy(name, dev_name(dev))
+               tp_assign(flags, flags)
+               tp_assign(usage_count, atomic_read(&dev->power.usage_count))
+               tp_assign(disable_depth, dev->power.disable_depth)
+               tp_assign(runtime_auto, dev->power.runtime_auto)
+               tp_assign(request_pending, dev->power.request_pending)
+               tp_assign(irq_safe, dev->power.irq_safe)
+               tp_assign(child_count, atomic_read(&dev->power.child_count))
+       ),
+
+       TP_printk("%s flags-%x cnt-%-2d dep-%-2d auto-%-1d p-%-1d"
+                       " irq-%-1d child-%d",
+                       __get_str(name), __entry->flags,
+                       __entry->usage_count,
+                       __entry->disable_depth,
+                       __entry->runtime_auto,
+                       __entry->request_pending,
+                       __entry->irq_safe,
+                       __entry->child_count
+                )
+)
+DEFINE_EVENT(rpm_internal, rpm_suspend,
+
+       TP_PROTO(struct device *dev, int flags),
+
+       TP_ARGS(dev, flags)
+)
+DEFINE_EVENT(rpm_internal, rpm_resume,
+
+       TP_PROTO(struct device *dev, int flags),
+
+       TP_ARGS(dev, flags)
+)
+DEFINE_EVENT(rpm_internal, rpm_idle,
+
+       TP_PROTO(struct device *dev, int flags),
+
+       TP_ARGS(dev, flags)
+)
+
+TRACE_EVENT(rpm_return_int,
+       TP_PROTO(struct device *dev, unsigned long ip, int ret),
+       TP_ARGS(dev, ip, ret),
+
+       TP_STRUCT__entry(
+               __string(       name,           dev_name(dev))
+               __field(        unsigned long,          ip      )
+               __field(        int,                    ret     )
+       ),
+
+       TP_fast_assign(
+               tp_strcpy(name, dev_name(dev))
+               tp_assign(ip, ip)
+               tp_assign(ret, ret)
+       ),
+
+       TP_printk("%pS:%s ret=%d", (void *)__entry->ip, __get_str(name),
+               __entry->ret)
+)
+
+#endif /* _TRACE_RUNTIME_POWER_H */
+
+/* This part must be outside protection */
+#include "../../../probes/define_trace.h"
diff --git a/drivers/staging/lttng/instrumentation/events/lttng-module/sched.h b/drivers/staging/lttng/instrumentation/events/lttng-module/sched.h
new file mode 100644 (file)
index 0000000..2a453fb
--- /dev/null
@@ -0,0 +1,560 @@
+#undef TRACE_SYSTEM
+#define TRACE_SYSTEM sched
+
+#if !defined(_TRACE_SCHED_H) || defined(TRACE_HEADER_MULTI_READ)
+#define _TRACE_SCHED_H
+
+#include <linux/sched.h>
+#include <linux/tracepoint.h>
+#include <linux/binfmts.h>
+#include <linux/version.h>
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,9,0))
+#include <linux/sched/rt.h>
+#endif
+
+#ifndef _TRACE_SCHED_DEF_
+#define _TRACE_SCHED_DEF_
+
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,35))
+
+static inline long __trace_sched_switch_state(struct task_struct *p)
+{
+       long state = p->state;
+
+#ifdef CONFIG_PREEMPT
+       /*
+        * For all intents and purposes a preempted task is a running task.
+        */
+       if (task_thread_info(p)->preempt_count & PREEMPT_ACTIVE)
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,2,0))
+               state = TASK_RUNNING | TASK_STATE_MAX;
+#else
+               state = TASK_RUNNING;
+#endif
+#endif
+
+       return state;
+}
+
+#endif
+
+#endif /* _TRACE_SCHED_DEF_ */
+
+/*
+ * Tracepoint for calling kthread_stop, performed to end a kthread:
+ */
+TRACE_EVENT(sched_kthread_stop,
+
+       TP_PROTO(struct task_struct *t),
+
+       TP_ARGS(t),
+
+       TP_STRUCT__entry(
+               __array_text(   char,   comm,   TASK_COMM_LEN   )
+               __field(        pid_t,  tid                     )
+       ),
+
+       TP_fast_assign(
+               tp_memcpy(comm, t->comm, TASK_COMM_LEN)
+               tp_assign(tid, t->pid)
+       ),
+
+       TP_printk("comm=%s tid=%d", __entry->comm, __entry->tid)
+)
+
+/*
+ * Tracepoint for the return value of the kthread stopping:
+ */
+TRACE_EVENT(sched_kthread_stop_ret,
+
+       TP_PROTO(int ret),
+
+       TP_ARGS(ret),
+
+       TP_STRUCT__entry(
+               __field(        int,    ret     )
+       ),
+
+       TP_fast_assign(
+               tp_assign(ret, ret)
+       ),
+
+       TP_printk("ret=%d", __entry->ret)
+)
+
+/*
+ * Tracepoint for waking up a task:
+ */
+DECLARE_EVENT_CLASS(sched_wakeup_template,
+
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,35))
+       TP_PROTO(struct task_struct *p, int success),
+
+       TP_ARGS(p, success),
+#else
+       TP_PROTO(struct rq *rq, struct task_struct *p, int success),
+
+       TP_ARGS(rq, p, success),
+#endif
+
+       TP_STRUCT__entry(
+               __array_text(   char,   comm,   TASK_COMM_LEN   )
+               __field(        pid_t,  tid                     )
+               __field(        int,    prio                    )
+               __field(        int,    success                 )
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,32))
+               __field(        int,    target_cpu              )
+#endif
+       ),
+
+       TP_fast_assign(
+               tp_memcpy(comm, p->comm, TASK_COMM_LEN)
+               tp_assign(tid, p->pid)
+               tp_assign(prio, p->prio)
+               tp_assign(success, success)
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,32))
+               tp_assign(target_cpu, task_cpu(p))
+#endif
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,6,0))
+       )
+       TP_perf_assign(
+               __perf_task(p)
+#endif
+       ),
+
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,32))
+       TP_printk("comm=%s tid=%d prio=%d success=%d target_cpu=%03d",
+                 __entry->comm, __entry->tid, __entry->prio,
+                 __entry->success, __entry->target_cpu)
+#else
+       TP_printk("comm=%s tid=%d prio=%d success=%d",
+                 __entry->comm, __entry->tid, __entry->prio,
+                 __entry->success)
+#endif
+)
+
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,35))
+
+DEFINE_EVENT(sched_wakeup_template, sched_wakeup,
+            TP_PROTO(struct task_struct *p, int success),
+            TP_ARGS(p, success))
+
+/*
+ * Tracepoint for waking up a new task:
+ */
+DEFINE_EVENT(sched_wakeup_template, sched_wakeup_new,
+            TP_PROTO(struct task_struct *p, int success),
+            TP_ARGS(p, success))
+
+#else /* #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,35)) */
+
+DEFINE_EVENT(sched_wakeup_template, sched_wakeup,
+            TP_PROTO(struct rq *rq, struct task_struct *p, int success),
+            TP_ARGS(rq, p, success))
+
+/*
+ * Tracepoint for waking up a new task:
+ */
+DEFINE_EVENT(sched_wakeup_template, sched_wakeup_new,
+            TP_PROTO(struct rq *rq, struct task_struct *p, int success),
+            TP_ARGS(rq, p, success))
+
+#endif /* #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,35)) */
+
+/*
+ * Tracepoint for task switches, performed by the scheduler:
+ */
+TRACE_EVENT(sched_switch,
+
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,35))
+       TP_PROTO(struct task_struct *prev,
+                struct task_struct *next),
+
+       TP_ARGS(prev, next),
+#else /* #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,35)) */
+       TP_PROTO(struct rq *rq, struct task_struct *prev,
+                struct task_struct *next),
+
+       TP_ARGS(rq, prev, next),
+#endif /* #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,35)) */
+
+       TP_STRUCT__entry(
+               __array_text(   char,   prev_comm,      TASK_COMM_LEN   )
+               __field(        pid_t,  prev_tid                        )
+               __field(        int,    prev_prio                       )
+               __field(        long,   prev_state                      )
+               __array_text(   char,   next_comm,      TASK_COMM_LEN   )
+               __field(        pid_t,  next_tid                        )
+               __field(        int,    next_prio                       )
+       ),
+
+       TP_fast_assign(
+               tp_memcpy(next_comm, next->comm, TASK_COMM_LEN)
+               tp_assign(prev_tid, prev->pid)
+               tp_assign(prev_prio, prev->prio - MAX_RT_PRIO)
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,35))
+               tp_assign(prev_state, __trace_sched_switch_state(prev))
+#else
+               tp_assign(prev_state, prev->state)
+#endif
+               tp_memcpy(prev_comm, prev->comm, TASK_COMM_LEN)
+               tp_assign(next_tid, next->pid)
+               tp_assign(next_prio, next->prio - MAX_RT_PRIO)
+       ),
+
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,2,0))
+       TP_printk("prev_comm=%s prev_tid=%d prev_prio=%d prev_state=%s%s ==> next_comm=%s next_tid=%d next_prio=%d",
+               __entry->prev_comm, __entry->prev_tid, __entry->prev_prio,
+               __entry->prev_state & (TASK_STATE_MAX-1) ?
+                 __print_flags(__entry->prev_state & (TASK_STATE_MAX-1), "|",
+                               { 1, "S"} , { 2, "D" }, { 4, "T" }, { 8, "t" },
+                               { 16, "Z" }, { 32, "X" }, { 64, "x" },
+                               { 128, "W" }) : "R",
+               __entry->prev_state & TASK_STATE_MAX ? "+" : "",
+               __entry->next_comm, __entry->next_tid, __entry->next_prio)
+#else
+       TP_printk("prev_comm=%s prev_tid=%d prev_prio=%d prev_state=%s ==> next_comm=%s next_tid=%d next_prio=%d",
+               __entry->prev_comm, __entry->prev_tid, __entry->prev_prio,
+               __entry->prev_state ?
+                 __print_flags(__entry->prev_state, "|",
+                               { 1, "S"} , { 2, "D" }, { 4, "T" }, { 8, "t" },
+                               { 16, "Z" }, { 32, "X" }, { 64, "x" },
+                               { 128, "W" }) : "R",
+               __entry->next_comm, __entry->next_tid, __entry->next_prio)
+#endif
+)
+
+/*
+ * Tracepoint for a task being migrated:
+ */
+TRACE_EVENT(sched_migrate_task,
+
+       TP_PROTO(struct task_struct *p, int dest_cpu),
+
+       TP_ARGS(p, dest_cpu),
+
+       TP_STRUCT__entry(
+               __array_text(   char,   comm,   TASK_COMM_LEN   )
+               __field(        pid_t,  tid                     )
+               __field(        int,    prio                    )
+               __field(        int,    orig_cpu                )
+               __field(        int,    dest_cpu                )
+       ),
+
+       TP_fast_assign(
+               tp_memcpy(comm, p->comm, TASK_COMM_LEN)
+               tp_assign(tid, p->pid)
+               tp_assign(prio, p->prio - MAX_RT_PRIO)
+               tp_assign(orig_cpu, task_cpu(p))
+               tp_assign(dest_cpu, dest_cpu)
+       ),
+
+       TP_printk("comm=%s tid=%d prio=%d orig_cpu=%d dest_cpu=%d",
+                 __entry->comm, __entry->tid, __entry->prio,
+                 __entry->orig_cpu, __entry->dest_cpu)
+)
+
+DECLARE_EVENT_CLASS(sched_process_template,
+
+       TP_PROTO(struct task_struct *p),
+
+       TP_ARGS(p),
+
+       TP_STRUCT__entry(
+               __array_text(   char,   comm,   TASK_COMM_LEN   )
+               __field(        pid_t,  tid                     )
+               __field(        int,    prio                    )
+       ),
+
+       TP_fast_assign(
+               tp_memcpy(comm, p->comm, TASK_COMM_LEN)
+               tp_assign(tid, p->pid)
+               tp_assign(prio, p->prio - MAX_RT_PRIO)
+       ),
+
+       TP_printk("comm=%s tid=%d prio=%d",
+                 __entry->comm, __entry->tid, __entry->prio)
+)
+
+/*
+ * Tracepoint for freeing a task:
+ */
+DEFINE_EVENT(sched_process_template, sched_process_free,
+            TP_PROTO(struct task_struct *p),
+            TP_ARGS(p))
+
+
+/*
+ * Tracepoint for a task exiting:
+ */
+DEFINE_EVENT(sched_process_template, sched_process_exit,
+            TP_PROTO(struct task_struct *p),
+            TP_ARGS(p))
+
+/*
+ * Tracepoint for waiting on task to unschedule:
+ */
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,35))
+DEFINE_EVENT(sched_process_template, sched_wait_task,
+       TP_PROTO(struct task_struct *p),
+       TP_ARGS(p))
+#else /* #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,35)) */
+DEFINE_EVENT(sched_process_template, sched_wait_task,
+       TP_PROTO(struct rq *rq, struct task_struct *p),
+       TP_ARGS(rq, p))
+#endif /* #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,35)) */
+
+/*
+ * Tracepoint for a waiting task:
+ */
+TRACE_EVENT(sched_process_wait,
+
+       TP_PROTO(struct pid *pid),
+
+       TP_ARGS(pid),
+
+       TP_STRUCT__entry(
+               __array_text(   char,   comm,   TASK_COMM_LEN   )
+               __field(        pid_t,  tid                     )
+               __field(        int,    prio                    )
+       ),
+
+       TP_fast_assign(
+               tp_memcpy(comm, current->comm, TASK_COMM_LEN)
+               tp_assign(tid, pid_nr(pid))
+               tp_assign(prio, current->prio - MAX_RT_PRIO)
+       ),
+
+       TP_printk("comm=%s tid=%d prio=%d",
+                 __entry->comm, __entry->tid, __entry->prio)
+)
+
+/*
+ * Tracepoint for do_fork.
+ * Saving both TID and PID information, especially for the child, allows
+ * trace analyzers to distinguish between creation of a new process and
+ * creation of a new thread. Newly created processes will have child_tid
+ * == child_pid, while creation of a thread yields to child_tid !=
+ * child_pid.
+ */
+TRACE_EVENT(sched_process_fork,
+
+       TP_PROTO(struct task_struct *parent, struct task_struct *child),
+
+       TP_ARGS(parent, child),
+
+       TP_STRUCT__entry(
+               __array_text(   char,   parent_comm,    TASK_COMM_LEN   )
+               __field(        pid_t,  parent_tid                      )
+               __field(        pid_t,  parent_pid                      )
+               __array_text(   char,   child_comm,     TASK_COMM_LEN   )
+               __field(        pid_t,  child_tid                       )
+               __field(        pid_t,  child_pid                       )
+       ),
+
+       TP_fast_assign(
+               tp_memcpy(parent_comm, parent->comm, TASK_COMM_LEN)
+               tp_assign(parent_tid, parent->pid)
+               tp_assign(parent_pid, parent->tgid)
+               tp_memcpy(child_comm, child->comm, TASK_COMM_LEN)
+               tp_assign(child_tid, child->pid)
+               tp_assign(child_pid, child->tgid)
+       ),
+
+       TP_printk("comm=%s tid=%d child_comm=%s child_tid=%d",
+               __entry->parent_comm, __entry->parent_tid,
+               __entry->child_comm, __entry->child_tid)
+)
+
+#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,33))
+/*
+ * Tracepoint for sending a signal:
+ */
+TRACE_EVENT(sched_signal_send,
+
+       TP_PROTO(int sig, struct task_struct *p),
+
+       TP_ARGS(sig, p),
+
+       TP_STRUCT__entry(
+               __field(        int,    sig                     )
+               __array(        char,   comm,   TASK_COMM_LEN   )
+               __field(        pid_t,  pid                     )
+       ),
+
+       TP_fast_assign(
+               tp_memcpy(comm, p->comm, TASK_COMM_LEN)
+               tp_assign(pid, p->pid)
+               tp_assign(sig, sig)
+       ),
+
+       TP_printk("sig=%d comm=%s pid=%d",
+               __entry->sig, __entry->comm, __entry->pid)
+)
+#endif
+
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,4,0))
+/*
+ * Tracepoint for exec:
+ */
+TRACE_EVENT(sched_process_exec,
+
+       TP_PROTO(struct task_struct *p, pid_t old_pid,
+                struct linux_binprm *bprm),
+
+       TP_ARGS(p, old_pid, bprm),
+
+       TP_STRUCT__entry(
+               __string(       filename,       bprm->filename  )
+               __field(        pid_t,          tid             )
+               __field(        pid_t,          old_tid         )
+       ),
+
+       TP_fast_assign(
+               tp_strcpy(filename, bprm->filename)
+               tp_assign(tid, p->pid)
+               tp_assign(old_tid, old_pid)
+       ),
+
+       TP_printk("filename=%s tid=%d old_tid=%d", __get_str(filename),
+                 __entry->tid, __entry->old_tid)
+)
+#endif
+
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,32))
+/*
+ * XXX the below sched_stat tracepoints only apply to SCHED_OTHER/BATCH/IDLE
+ *     adding sched_stat support to SCHED_FIFO/RR would be welcome.
+ */
+DECLARE_EVENT_CLASS(sched_stat_template,
+
+       TP_PROTO(struct task_struct *tsk, u64 delay),
+
+       TP_ARGS(tsk, delay),
+
+       TP_STRUCT__entry(
+               __array_text( char,     comm,   TASK_COMM_LEN   )
+               __field( pid_t, tid                     )
+               __field( u64,   delay                   )
+       ),
+
+       TP_fast_assign(
+               tp_memcpy(comm, tsk->comm, TASK_COMM_LEN)
+               tp_assign(tid,  tsk->pid)
+               tp_assign(delay, delay)
+       )
+       TP_perf_assign(
+               __perf_count(delay)
+       ),
+
+       TP_printk("comm=%s tid=%d delay=%Lu [ns]",
+                       __entry->comm, __entry->tid,
+                       (unsigned long long)__entry->delay)
+)
+
+
+/*
+ * Tracepoint for accounting wait time (time the task is runnable
+ * but not actually running due to scheduler contention).
+ */
+DEFINE_EVENT(sched_stat_template, sched_stat_wait,
+            TP_PROTO(struct task_struct *tsk, u64 delay),
+            TP_ARGS(tsk, delay))
+
+/*
+ * Tracepoint for accounting sleep time (time the task is not runnable,
+ * including iowait, see below).
+ */
+DEFINE_EVENT(sched_stat_template, sched_stat_sleep,
+            TP_PROTO(struct task_struct *tsk, u64 delay),
+            TP_ARGS(tsk, delay))
+
+/*
+ * Tracepoint for accounting iowait time (time the task is not runnable
+ * due to waiting on IO to complete).
+ */
+DEFINE_EVENT(sched_stat_template, sched_stat_iowait,
+            TP_PROTO(struct task_struct *tsk, u64 delay),
+            TP_ARGS(tsk, delay))
+
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,3,0))
+/*
+ * Tracepoint for accounting blocked time (time the task is in uninterruptible).
+ */
+DEFINE_EVENT(sched_stat_template, sched_stat_blocked,
+            TP_PROTO(struct task_struct *tsk, u64 delay),
+            TP_ARGS(tsk, delay))
+#endif
+
+/*
+ * Tracepoint for accounting runtime (time the task is executing
+ * on a CPU).
+ */
+TRACE_EVENT(sched_stat_runtime,
+
+       TP_PROTO(struct task_struct *tsk, u64 runtime, u64 vruntime),
+
+       TP_ARGS(tsk, runtime, vruntime),
+
+       TP_STRUCT__entry(
+               __array_text( char,     comm,   TASK_COMM_LEN   )
+               __field( pid_t, tid                     )
+               __field( u64,   runtime                 )
+               __field( u64,   vruntime                        )
+       ),
+
+       TP_fast_assign(
+               tp_memcpy(comm, tsk->comm, TASK_COMM_LEN)
+               tp_assign(tid, tsk->pid)
+               tp_assign(runtime, runtime)
+               tp_assign(vruntime, vruntime)
+       )
+       TP_perf_assign(
+               __perf_count(runtime)
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,6,0))
+               __perf_task(tsk)
+#endif
+       ),
+
+       TP_printk("comm=%s tid=%d runtime=%Lu [ns] vruntime=%Lu [ns]",
+                       __entry->comm, __entry->tid,
+                       (unsigned long long)__entry->runtime,
+                       (unsigned long long)__entry->vruntime)
+)
+#endif
+
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,37))
+/*
+ * Tracepoint for showing priority inheritance modifying a tasks
+ * priority.
+ */
+TRACE_EVENT(sched_pi_setprio,
+
+       TP_PROTO(struct task_struct *tsk, int newprio),
+
+       TP_ARGS(tsk, newprio),
+
+       TP_STRUCT__entry(
+               __array_text( char,     comm,   TASK_COMM_LEN   )
+               __field( pid_t, tid                     )
+               __field( int,   oldprio                 )
+               __field( int,   newprio                 )
+       ),
+
+       TP_fast_assign(
+               tp_memcpy(comm, tsk->comm, TASK_COMM_LEN)
+               tp_assign(tid, tsk->pid)
+               tp_assign(oldprio, tsk->prio - MAX_RT_PRIO)
+               tp_assign(newprio, newprio - MAX_RT_PRIO)
+       ),
+
+       TP_printk("comm=%s tid=%d oldprio=%d newprio=%d",
+                       __entry->comm, __entry->tid,
+                       __entry->oldprio, __entry->newprio)
+)
+#endif
+
+#endif /* _TRACE_SCHED_H */
+
+/* This part must be outside protection */
+#include "../../../probes/define_trace.h"
diff --git a/drivers/staging/lttng/instrumentation/events/lttng-module/scsi.h b/drivers/staging/lttng/instrumentation/events/lttng-module/scsi.h
new file mode 100644 (file)
index 0000000..15f0c70
--- /dev/null
@@ -0,0 +1,406 @@
+#undef TRACE_SYSTEM
+#define TRACE_SYSTEM scsi
+
+#if !defined(_TRACE_SCSI_H) || defined(TRACE_HEADER_MULTI_READ)
+#define _TRACE_SCSI_H
+
+#include <scsi/scsi_cmnd.h>
+#include <scsi/scsi_host.h>
+#include <linux/tracepoint.h>
+#include <linux/trace_seq.h>
+#include <linux/version.h>
+
+#ifndef _TRACE_SCSI_DEF
+#define _TRACE_SCSI_DEF
+
+#define scsi_opcode_name(opcode)       { opcode, #opcode }
+#define show_opcode_name(val)                                  \
+       __print_symbolic(val,                                   \
+               scsi_opcode_name(TEST_UNIT_READY),              \
+               scsi_opcode_name(REZERO_UNIT),                  \
+               scsi_opcode_name(REQUEST_SENSE),                \
+               scsi_opcode_name(FORMAT_UNIT),                  \
+               scsi_opcode_name(READ_BLOCK_LIMITS),            \
+               scsi_opcode_name(REASSIGN_BLOCKS),              \
+               scsi_opcode_name(INITIALIZE_ELEMENT_STATUS),    \
+               scsi_opcode_name(READ_6),                       \
+               scsi_opcode_name(WRITE_6),                      \
+               scsi_opcode_name(SEEK_6),                       \
+               scsi_opcode_name(READ_REVERSE),                 \
+               scsi_opcode_name(WRITE_FILEMARKS),              \
+               scsi_opcode_name(SPACE),                        \
+               scsi_opcode_name(INQUIRY),                      \
+               scsi_opcode_name(RECOVER_BUFFERED_DATA),        \
+               scsi_opcode_name(MODE_SELECT),                  \
+               scsi_opcode_name(RESERVE),                      \
+               scsi_opcode_name(RELEASE),                      \
+               scsi_opcode_name(COPY),                         \
+               scsi_opcode_name(ERASE),                        \
+               scsi_opcode_name(MODE_SENSE),                   \
+               scsi_opcode_name(START_STOP),                   \
+               scsi_opcode_name(RECEIVE_DIAGNOSTIC),           \
+               scsi_opcode_name(SEND_DIAGNOSTIC),              \
+               scsi_opcode_name(ALLOW_MEDIUM_REMOVAL),         \
+               scsi_opcode_name(SET_WINDOW),                   \
+               scsi_opcode_name(READ_CAPACITY),                \
+               scsi_opcode_name(READ_10),                      \
+               scsi_opcode_name(WRITE_10),                     \
+               scsi_opcode_name(SEEK_10),                      \
+               scsi_opcode_name(POSITION_TO_ELEMENT),          \
+               scsi_opcode_name(WRITE_VERIFY),                 \
+               scsi_opcode_name(VERIFY),                       \
+               scsi_opcode_name(SEARCH_HIGH),                  \
+               scsi_opcode_name(SEARCH_EQUAL),                 \
+               scsi_opcode_name(SEARCH_LOW),                   \
+               scsi_opcode_name(SET_LIMITS),                   \
+               scsi_opcode_name(PRE_FETCH),                    \
+               scsi_opcode_name(READ_POSITION),                \
+               scsi_opcode_name(SYNCHRONIZE_CACHE),            \
+               scsi_opcode_name(LOCK_UNLOCK_CACHE),            \
+               scsi_opcode_name(READ_DEFECT_DATA),             \
+               scsi_opcode_name(MEDIUM_SCAN),                  \
+               scsi_opcode_name(COMPARE),                      \
+               scsi_opcode_name(COPY_VERIFY),                  \
+               scsi_opcode_name(WRITE_BUFFER),                 \
+               scsi_opcode_name(READ_BUFFER),                  \
+               scsi_opcode_name(UPDATE_BLOCK),                 \
+               scsi_opcode_name(READ_LONG),                    \
+               scsi_opcode_name(WRITE_LONG),                   \
+               scsi_opcode_name(CHANGE_DEFINITION),            \
+               scsi_opcode_name(WRITE_SAME),                   \
+               scsi_opcode_name(UNMAP),                        \
+               scsi_opcode_name(READ_TOC),                     \
+               scsi_opcode_name(LOG_SELECT),                   \
+               scsi_opcode_name(LOG_SENSE),                    \
+               scsi_opcode_name(XDWRITEREAD_10),               \
+               scsi_opcode_name(MODE_SELECT_10),               \
+               scsi_opcode_name(RESERVE_10),                   \
+               scsi_opcode_name(RELEASE_10),                   \
+               scsi_opcode_name(MODE_SENSE_10),                \
+               scsi_opcode_name(PERSISTENT_RESERVE_IN),        \
+               scsi_opcode_name(PERSISTENT_RESERVE_OUT),       \
+               scsi_opcode_name(VARIABLE_LENGTH_CMD),          \
+               scsi_opcode_name(REPORT_LUNS),                  \
+               scsi_opcode_name(MAINTENANCE_IN),               \
+               scsi_opcode_name(MAINTENANCE_OUT),              \
+               scsi_opcode_name(MOVE_MEDIUM),                  \
+               scsi_opcode_name(EXCHANGE_MEDIUM),              \
+               scsi_opcode_name(READ_12),                      \
+               scsi_opcode_name(WRITE_12),                     \
+               scsi_opcode_name(WRITE_VERIFY_12),              \
+               scsi_opcode_name(SEARCH_HIGH_12),               \
+               scsi_opcode_name(SEARCH_EQUAL_12),              \
+               scsi_opcode_name(SEARCH_LOW_12),                \
+               scsi_opcode_name(READ_ELEMENT_STATUS),          \
+               scsi_opcode_name(SEND_VOLUME_TAG),              \
+               scsi_opcode_name(WRITE_LONG_2),                 \
+               scsi_opcode_name(READ_16),                      \
+               scsi_opcode_name(WRITE_16),                     \
+               scsi_opcode_name(VERIFY_16),                    \
+               scsi_opcode_name(WRITE_SAME_16),                \
+               scsi_opcode_name(SERVICE_ACTION_IN),            \
+               scsi_opcode_name(SAI_READ_CAPACITY_16),         \
+               scsi_opcode_name(SAI_GET_LBA_STATUS),           \
+               scsi_opcode_name(MI_REPORT_TARGET_PGS),         \
+               scsi_opcode_name(MO_SET_TARGET_PGS),            \
+               scsi_opcode_name(READ_32),                      \
+               scsi_opcode_name(WRITE_32),                     \
+               scsi_opcode_name(WRITE_SAME_32),                \
+               scsi_opcode_name(ATA_16),                       \
+               scsi_opcode_name(ATA_12))
+
+#define scsi_hostbyte_name(result)     { result, #result }
+#define show_hostbyte_name(val)                                        \
+       __print_symbolic(val,                                   \
+               scsi_hostbyte_name(DID_OK),                     \
+               scsi_hostbyte_name(DID_NO_CONNECT),             \
+               scsi_hostbyte_name(DID_BUS_BUSY),               \
+               scsi_hostbyte_name(DID_TIME_OUT),               \
+               scsi_hostbyte_name(DID_BAD_TARGET),             \
+               scsi_hostbyte_name(DID_ABORT),                  \
+               scsi_hostbyte_name(DID_PARITY),                 \
+               scsi_hostbyte_name(DID_ERROR),                  \
+               scsi_hostbyte_name(DID_RESET),                  \
+               scsi_hostbyte_name(DID_BAD_INTR),               \
+               scsi_hostbyte_name(DID_PASSTHROUGH),            \
+               scsi_hostbyte_name(DID_SOFT_ERROR),             \
+               scsi_hostbyte_name(DID_IMM_RETRY),              \
+               scsi_hostbyte_name(DID_REQUEUE),                \
+               scsi_hostbyte_name(DID_TRANSPORT_DISRUPTED),    \
+               scsi_hostbyte_name(DID_TRANSPORT_FAILFAST))
+
+#define scsi_driverbyte_name(result)   { result, #result }
+#define show_driverbyte_name(val)                              \
+       __print_symbolic(val,                                   \
+               scsi_driverbyte_name(DRIVER_OK),                \
+               scsi_driverbyte_name(DRIVER_BUSY),              \
+               scsi_driverbyte_name(DRIVER_SOFT),              \
+               scsi_driverbyte_name(DRIVER_MEDIA),             \
+               scsi_driverbyte_name(DRIVER_ERROR),             \
+               scsi_driverbyte_name(DRIVER_INVALID),           \
+               scsi_driverbyte_name(DRIVER_TIMEOUT),           \
+               scsi_driverbyte_name(DRIVER_HARD),              \
+               scsi_driverbyte_name(DRIVER_SENSE))
+
+#define scsi_msgbyte_name(result)      { result, #result }
+#define show_msgbyte_name(val)                                 \
+       __print_symbolic(val,                                   \
+               scsi_msgbyte_name(COMMAND_COMPLETE),            \
+               scsi_msgbyte_name(EXTENDED_MESSAGE),            \
+               scsi_msgbyte_name(SAVE_POINTERS),               \
+               scsi_msgbyte_name(RESTORE_POINTERS),            \
+               scsi_msgbyte_name(DISCONNECT),                  \
+               scsi_msgbyte_name(INITIATOR_ERROR),             \
+               scsi_msgbyte_name(ABORT_TASK_SET),              \
+               scsi_msgbyte_name(MESSAGE_REJECT),              \
+               scsi_msgbyte_name(NOP),                         \
+               scsi_msgbyte_name(MSG_PARITY_ERROR),            \
+               scsi_msgbyte_name(LINKED_CMD_COMPLETE),         \
+               scsi_msgbyte_name(LINKED_FLG_CMD_COMPLETE),     \
+               scsi_msgbyte_name(TARGET_RESET),                \
+               scsi_msgbyte_name(ABORT_TASK),                  \
+               scsi_msgbyte_name(CLEAR_TASK_SET),              \
+               scsi_msgbyte_name(INITIATE_RECOVERY),           \
+               scsi_msgbyte_name(RELEASE_RECOVERY),            \
+               scsi_msgbyte_name(CLEAR_ACA),                   \
+               scsi_msgbyte_name(LOGICAL_UNIT_RESET),          \
+               scsi_msgbyte_name(SIMPLE_QUEUE_TAG),            \
+               scsi_msgbyte_name(HEAD_OF_QUEUE_TAG),           \
+               scsi_msgbyte_name(ORDERED_QUEUE_TAG),           \
+               scsi_msgbyte_name(IGNORE_WIDE_RESIDUE),         \
+               scsi_msgbyte_name(ACA),                         \
+               scsi_msgbyte_name(QAS_REQUEST),                 \
+               scsi_msgbyte_name(BUS_DEVICE_RESET),            \
+               scsi_msgbyte_name(ABORT))
+
+#define scsi_statusbyte_name(result)   { result, #result }
+#define show_statusbyte_name(val)                              \
+       __print_symbolic(val,                                   \
+               scsi_statusbyte_name(SAM_STAT_GOOD),            \
+               scsi_statusbyte_name(SAM_STAT_CHECK_CONDITION), \
+               scsi_statusbyte_name(SAM_STAT_CONDITION_MET),   \
+               scsi_statusbyte_name(SAM_STAT_BUSY),            \
+               scsi_statusbyte_name(SAM_STAT_INTERMEDIATE),    \
+               scsi_statusbyte_name(SAM_STAT_INTERMEDIATE_CONDITION_MET), \
+               scsi_statusbyte_name(SAM_STAT_RESERVATION_CONFLICT),    \
+               scsi_statusbyte_name(SAM_STAT_COMMAND_TERMINATED),      \
+               scsi_statusbyte_name(SAM_STAT_TASK_SET_FULL),   \
+               scsi_statusbyte_name(SAM_STAT_ACA_ACTIVE),      \
+               scsi_statusbyte_name(SAM_STAT_TASK_ABORTED))
+
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,39))
+#define scsi_prot_op_name(result)      { result, #result }
+#define show_prot_op_name(val)                                 \
+       __print_symbolic(val,                                   \
+               scsi_prot_op_name(SCSI_PROT_NORMAL),            \
+               scsi_prot_op_name(SCSI_PROT_READ_INSERT),       \
+               scsi_prot_op_name(SCSI_PROT_WRITE_STRIP),       \
+               scsi_prot_op_name(SCSI_PROT_READ_STRIP),        \
+               scsi_prot_op_name(SCSI_PROT_WRITE_INSERT),      \
+               scsi_prot_op_name(SCSI_PROT_READ_PASS),         \
+               scsi_prot_op_name(SCSI_PROT_WRITE_PASS))
+#endif
+
+const char *scsi_trace_parse_cdb(struct trace_seq*, unsigned char*, int);
+#define __parse_cdb(cdb, len) scsi_trace_parse_cdb(p, cdb, len)
+#endif
+
+TRACE_EVENT(scsi_dispatch_cmd_start,
+
+       TP_PROTO(struct scsi_cmnd *cmd),
+
+       TP_ARGS(cmd),
+
+       TP_STRUCT__entry(
+               __field( unsigned int,  host_no )
+               __field( unsigned int,  channel )
+               __field( unsigned int,  id      )
+               __field( unsigned int,  lun     )
+               __field( unsigned int,  opcode  )
+               __field( unsigned int,  cmd_len )
+               __field( unsigned int,  data_sglen )
+               __field( unsigned int,  prot_sglen )
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,39))
+               __field( unsigned char, prot_op )
+#endif
+               __dynamic_array_hex(unsigned char,      cmnd, cmd->cmd_len)
+       ),
+
+       TP_fast_assign(
+               tp_assign(host_no, cmd->device->host->host_no)
+               tp_assign(channel, cmd->device->channel)
+               tp_assign(id, cmd->device->id)
+               tp_assign(lun, cmd->device->lun)
+               tp_assign(opcode, cmd->cmnd[0])
+               tp_assign(cmd_len, cmd->cmd_len)
+               tp_assign(data_sglen, scsi_sg_count(cmd))
+               tp_assign(prot_sglen, scsi_prot_sg_count(cmd))
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,39))
+               tp_assign(prot_op, scsi_get_prot_op(cmd))
+#endif
+               tp_memcpy_dyn(cmnd, cmd->cmnd)
+       ),
+
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,39))
+       TP_printk("host_no=%u channel=%u id=%u lun=%u data_sgl=%u prot_sgl=%u" \
+                 " prot_op=%s cmnd=(%s %s raw=%s)",
+#else
+       TP_printk("host_no=%u channel=%u id=%u lun=%u data_sgl=%u prot_sgl=%u" \
+                 " cmnd=(%s %s raw=%s)",
+#endif
+                 __entry->host_no, __entry->channel, __entry->id,
+                 __entry->lun, __entry->data_sglen, __entry->prot_sglen,
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,39))
+                 show_prot_op_name(__entry->prot_op),
+#endif
+                 show_opcode_name(__entry->opcode),
+                 __parse_cdb(__get_dynamic_array(cmnd), __entry->cmd_len),
+                 __print_hex(__get_dynamic_array(cmnd), __entry->cmd_len))
+)
+
+TRACE_EVENT(scsi_dispatch_cmd_error,
+
+       TP_PROTO(struct scsi_cmnd *cmd, int rtn),
+
+       TP_ARGS(cmd, rtn),
+
+       TP_STRUCT__entry(
+               __field( unsigned int,  host_no )
+               __field( unsigned int,  channel )
+               __field( unsigned int,  id      )
+               __field( unsigned int,  lun     )
+               __field( int,           rtn     )
+               __field( unsigned int,  opcode  )
+               __field( unsigned int,  cmd_len )
+               __field( unsigned int,  data_sglen )
+               __field( unsigned int,  prot_sglen )
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,39))
+               __field( unsigned char, prot_op )
+#endif
+               __dynamic_array_hex(unsigned char,      cmnd, cmd->cmd_len)
+       ),
+
+       TP_fast_assign(
+               tp_assign(host_no, cmd->device->host->host_no)
+               tp_assign(channel, cmd->device->channel)
+               tp_assign(id, cmd->device->id)
+               tp_assign(lun, cmd->device->lun)
+               tp_assign(rtn, rtn)
+               tp_assign(opcode, cmd->cmnd[0])
+               tp_assign(cmd_len, cmd->cmd_len)
+               tp_assign(data_sglen, scsi_sg_count(cmd))
+               tp_assign(prot_sglen, scsi_prot_sg_count(cmd))
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,39))
+               tp_assign(prot_op, scsi_get_prot_op(cmd))
+#endif
+               tp_memcpy_dyn(cmnd, cmd->cmnd)
+       ),
+
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,39))
+       TP_printk("host_no=%u channel=%u id=%u lun=%u data_sgl=%u prot_sgl=%u" \
+                 " prot_op=%s cmnd=(%s %s raw=%s) rtn=%d",
+#else
+       TP_printk("host_no=%u channel=%u id=%u lun=%u data_sgl=%u prot_sgl=%u" \
+                 " cmnd=(%s %s raw=%s) rtn=%d",
+#endif
+                 __entry->host_no, __entry->channel, __entry->id,
+                 __entry->lun, __entry->data_sglen, __entry->prot_sglen,
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,39))
+                 show_prot_op_name(__entry->prot_op),
+#endif
+                 show_opcode_name(__entry->opcode),
+                 __parse_cdb(__get_dynamic_array(cmnd), __entry->cmd_len),
+                 __print_hex(__get_dynamic_array(cmnd), __entry->cmd_len),
+                 __entry->rtn)
+)
+
+DECLARE_EVENT_CLASS(scsi_cmd_done_timeout_template,
+
+       TP_PROTO(struct scsi_cmnd *cmd),
+
+       TP_ARGS(cmd),
+
+       TP_STRUCT__entry(
+               __field( unsigned int,  host_no )
+               __field( unsigned int,  channel )
+               __field( unsigned int,  id      )
+               __field( unsigned int,  lun     )
+               __field( int,           result  )
+               __field( unsigned int,  opcode  )
+               __field( unsigned int,  cmd_len )
+               __field( unsigned int,  data_sglen )
+               __field( unsigned int,  prot_sglen )
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,39))
+               __field( unsigned char, prot_op )
+#endif
+               __dynamic_array_hex(unsigned char,      cmnd, cmd->cmd_len)
+       ),
+
+       TP_fast_assign(
+               tp_assign(host_no, cmd->device->host->host_no)
+               tp_assign(channel, cmd->device->channel)
+               tp_assign(id, cmd->device->id)
+               tp_assign(lun, cmd->device->lun)
+               tp_assign(result, cmd->result)
+               tp_assign(opcode, cmd->cmnd[0])
+               tp_assign(cmd_len, cmd->cmd_len)
+               tp_assign(data_sglen, scsi_sg_count(cmd))
+               tp_assign(prot_sglen, scsi_prot_sg_count(cmd))
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,39))
+               tp_assign(prot_op, scsi_get_prot_op(cmd))
+#endif
+               tp_memcpy_dyn(cmnd, cmd->cmnd)
+       ),
+
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,39))
+       TP_printk("host_no=%u channel=%u id=%u lun=%u data_sgl=%u " \
+                 "prot_sgl=%u prot_op=%s cmnd=(%s %s raw=%s) result=(driver=" \
+                 "%s host=%s message=%s status=%s)",
+#else
+       TP_printk("host_no=%u channel=%u id=%u lun=%u data_sgl=%u " \
+                 "prot_sgl=%u cmnd=(%s %s raw=%s) result=(driver=%s host=%s " \
+                 "message=%s status=%s)",
+#endif
+                 __entry->host_no, __entry->channel, __entry->id,
+                 __entry->lun, __entry->data_sglen, __entry->prot_sglen,
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,39))
+                 show_prot_op_name(__entry->prot_op),
+#endif
+                 show_opcode_name(__entry->opcode),
+                 __parse_cdb(__get_dynamic_array(cmnd), __entry->cmd_len),
+                 __print_hex(__get_dynamic_array(cmnd), __entry->cmd_len),
+                 show_driverbyte_name(((__entry->result) >> 24) & 0xff),
+                 show_hostbyte_name(((__entry->result) >> 16) & 0xff),
+                 show_msgbyte_name(((__entry->result) >> 8) & 0xff),
+                 show_statusbyte_name(__entry->result & 0xff))
+)
+
+DEFINE_EVENT(scsi_cmd_done_timeout_template, scsi_dispatch_cmd_done,
+            TP_PROTO(struct scsi_cmnd *cmd),
+            TP_ARGS(cmd))
+
+DEFINE_EVENT(scsi_cmd_done_timeout_template, scsi_dispatch_cmd_timeout,
+            TP_PROTO(struct scsi_cmnd *cmd),
+            TP_ARGS(cmd))
+
+TRACE_EVENT(scsi_eh_wakeup,
+
+       TP_PROTO(struct Scsi_Host *shost),
+
+       TP_ARGS(shost),
+
+       TP_STRUCT__entry(
+               __field( unsigned int,  host_no )
+       ),
+
+       TP_fast_assign(
+               tp_assign(host_no, shost->host_no)
+       ),
+
+       TP_printk("host_no=%u", __entry->host_no)
+)
+
+#endif /*  _TRACE_SCSI_H */
+
+/* This part must be outside protection */
+#include "../../../probes/define_trace.h"
diff --git a/drivers/staging/lttng/instrumentation/events/lttng-module/signal.h b/drivers/staging/lttng/instrumentation/events/lttng-module/signal.h
new file mode 100644 (file)
index 0000000..a1c904b
--- /dev/null
@@ -0,0 +1,202 @@
+#undef TRACE_SYSTEM
+#define TRACE_SYSTEM signal
+
+#if !defined(_TRACE_SIGNAL_H) || defined(TRACE_HEADER_MULTI_READ)
+#define _TRACE_SIGNAL_H
+
+#include <linux/tracepoint.h>
+#include <linux/version.h>
+
+#ifndef _TRACE_SIGNAL_DEF
+#define _TRACE_SIGNAL_DEF
+#include <linux/signal.h>
+#include <linux/sched.h>
+#undef TP_STORE_SIGINFO
+#define TP_STORE_SIGINFO(info)                                 \
+               tp_assign(errno,                                \
+                       (info == SEND_SIG_NOINFO || info == SEND_SIG_FORCED || info == SEND_SIG_PRIV) ? \
+                       0 :                                     \
+                       info->si_errno)                         \
+               tp_assign(code,                                 \
+                       (info == SEND_SIG_NOINFO || info == SEND_SIG_FORCED) ? \
+                       SI_USER :                               \
+                       ((info == SEND_SIG_PRIV) ? SI_KERNEL : info->si_code))
+#endif /* _TRACE_SIGNAL_DEF */
+
+/**
+ * signal_generate - called when a signal is generated
+ * @sig: signal number
+ * @info: pointer to struct siginfo
+ * @task: pointer to struct task_struct
+ *
+ * Current process sends a 'sig' signal to 'task' process with
+ * 'info' siginfo. If 'info' is SEND_SIG_NOINFO or SEND_SIG_PRIV,
+ * 'info' is not a pointer and you can't access its field. Instead,
+ * SEND_SIG_NOINFO means that si_code is SI_USER, and SEND_SIG_PRIV
+ * means that si_code is SI_KERNEL.
+ */
+#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0))
+TRACE_EVENT(signal_generate,
+
+       TP_PROTO(int sig, struct siginfo *info, struct task_struct *task),
+
+       TP_ARGS(sig, info, task),
+
+       TP_STRUCT__entry(
+               __field(        int,    sig                     )
+               __field(        int,    errno                   )
+               __field(        int,    code                    )
+               __array_text(   char,   comm,   TASK_COMM_LEN   )
+               __field(        pid_t,  pid                     )
+       ),
+
+       TP_fast_assign(
+               tp_assign(sig, sig)
+               TP_STORE_SIGINFO(info)
+               tp_memcpy(comm, task->comm, TASK_COMM_LEN)
+               tp_assign(pid, task->pid)
+       ),
+
+       TP_printk("sig=%d errno=%d code=%d comm=%s pid=%d",
+                 __entry->sig, __entry->errno, __entry->code,
+                 __entry->comm, __entry->pid)
+)
+#else
+TRACE_EVENT(signal_generate,
+
+       TP_PROTO(int sig, struct siginfo *info, struct task_struct *task,
+                       int group, int result),
+
+       TP_ARGS(sig, info, task, group, result),
+
+       TP_STRUCT__entry(
+               __field(        int,    sig                     )
+               __field(        int,    errno                   )
+               __field(        int,    code                    )
+               __array_text(   char,   comm,   TASK_COMM_LEN   )
+               __field(        pid_t,  pid                     )
+               __field(        int,    group                   )
+               __field(        int,    result                  )
+       ),
+
+       TP_fast_assign(
+               tp_assign(sig, sig)
+               TP_STORE_SIGINFO(info)
+               tp_memcpy(comm, task->comm, TASK_COMM_LEN)
+               tp_assign(pid, task->pid)
+               tp_assign(group, group)
+               tp_assign(result, result)
+       ),
+
+       TP_printk("sig=%d errno=%d code=%d comm=%s pid=%d grp=%d res=%d",
+                 __entry->sig, __entry->errno, __entry->code,
+                 __entry->comm, __entry->pid, __entry->group,
+                 __entry->result)
+)
+#endif
+
+/**
+ * signal_deliver - called when a signal is delivered
+ * @sig: signal number
+ * @info: pointer to struct siginfo
+ * @ka: pointer to struct k_sigaction
+ *
+ * A 'sig' signal is delivered to current process with 'info' siginfo,
+ * and it will be handled by 'ka'. ka->sa.sa_handler can be SIG_IGN or
+ * SIG_DFL.
+ * Note that some signals reported by signal_generate tracepoint can be
+ * lost, ignored or modified (by debugger) before hitting this tracepoint.
+ * This means, this can show which signals are actually delivered, but
+ * matching generated signals and delivered signals may not be correct.
+ */
+TRACE_EVENT(signal_deliver,
+
+       TP_PROTO(int sig, struct siginfo *info, struct k_sigaction *ka),
+
+       TP_ARGS(sig, info, ka),
+
+       TP_STRUCT__entry(
+               __field(        int,            sig             )
+               __field(        int,            errno           )
+               __field(        int,            code            )
+               __field(        unsigned long,  sa_handler      )
+               __field(        unsigned long,  sa_flags        )
+       ),
+
+       TP_fast_assign(
+               tp_assign(sig, sig)
+               TP_STORE_SIGINFO(info)
+               tp_assign(sa_handler, (unsigned long)ka->sa.sa_handler)
+               tp_assign(sa_flags, ka->sa.sa_flags)
+       ),
+
+       TP_printk("sig=%d errno=%d code=%d sa_handler=%lx sa_flags=%lx",
+                 __entry->sig, __entry->errno, __entry->code,
+                 __entry->sa_handler, __entry->sa_flags)
+)
+
+#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0))
+DECLARE_EVENT_CLASS(signal_queue_overflow,
+
+       TP_PROTO(int sig, int group, struct siginfo *info),
+
+       TP_ARGS(sig, group, info),
+
+       TP_STRUCT__entry(
+               __field(        int,    sig     )
+               __field(        int,    group   )
+               __field(        int,    errno   )
+               __field(        int,    code    )
+       ),
+
+       TP_fast_assign(
+               tp_assign(sig, sig)
+               tp_assign(group, group)
+               TP_STORE_SIGINFO(info)
+       ),
+
+       TP_printk("sig=%d group=%d errno=%d code=%d",
+                 __entry->sig, __entry->group, __entry->errno, __entry->code)
+)
+
+/**
+ * signal_overflow_fail - called when signal queue is overflow
+ * @sig: signal number
+ * @group: signal to process group or not (bool)
+ * @info: pointer to struct siginfo
+ *
+ * Kernel fails to generate 'sig' signal with 'info' siginfo, because
+ * siginfo queue is overflow, and the signal is dropped.
+ * 'group' is not 0 if the signal will be sent to a process group.
+ * 'sig' is always one of RT signals.
+ */
+DEFINE_EVENT(signal_queue_overflow, signal_overflow_fail,
+
+       TP_PROTO(int sig, int group, struct siginfo *info),
+
+       TP_ARGS(sig, group, info)
+)
+
+/**
+ * signal_lose_info - called when siginfo is lost
+ * @sig: signal number
+ * @group: signal to process group or not (bool)
+ * @info: pointer to struct siginfo
+ *
+ * Kernel generates 'sig' signal but loses 'info' siginfo, because siginfo
+ * queue is overflow.
+ * 'group' is not 0 if the signal will be sent to a process group.
+ * 'sig' is always one of non-RT signals.
+ */
+DEFINE_EVENT(signal_queue_overflow, signal_lose_info,
+
+       TP_PROTO(int sig, int group, struct siginfo *info),
+
+       TP_ARGS(sig, group, info)
+)
+#endif
+
+#endif /* _TRACE_SIGNAL_H */
+
+/* This part must be outside protection */
+#include "../../../probes/define_trace.h"
diff --git a/drivers/staging/lttng/instrumentation/events/lttng-module/skb.h b/drivers/staging/lttng/instrumentation/events/lttng-module/skb.h
new file mode 100644 (file)
index 0000000..a257304
--- /dev/null
@@ -0,0 +1,84 @@
+#undef TRACE_SYSTEM
+#define TRACE_SYSTEM skb
+
+#if !defined(_TRACE_SKB_H) || defined(TRACE_HEADER_MULTI_READ)
+#define _TRACE_SKB_H
+
+#include <linux/skbuff.h>
+#include <linux/netdevice.h>
+#include <linux/tracepoint.h>
+#include <linux/version.h>
+
+/*
+ * Tracepoint for free an sk_buff:
+ */
+TRACE_EVENT_MAP(kfree_skb,
+
+       skb_kfree,
+
+       TP_PROTO(struct sk_buff *skb, void *location),
+
+       TP_ARGS(skb, location),
+
+       TP_STRUCT__entry(
+               __field(        void *,         skbaddr         )
+               __field(        void *,         location        )
+               __field(        unsigned short, protocol        )
+       ),
+
+       TP_fast_assign(
+               tp_assign(skbaddr, skb)
+               tp_assign(location, location)
+               tp_assign(protocol, ntohs(skb->protocol))
+       ),
+
+       TP_printk("skbaddr=%p protocol=%u location=%p",
+               __entry->skbaddr, __entry->protocol, __entry->location)
+)
+
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,37))
+TRACE_EVENT_MAP(consume_skb,
+
+       skb_consume,
+
+       TP_PROTO(struct sk_buff *skb),
+
+       TP_ARGS(skb),
+
+       TP_STRUCT__entry(
+               __field(        void *, skbaddr )
+       ),
+
+       TP_fast_assign(
+               tp_assign(skbaddr, skb)
+       ),
+
+       TP_printk("skbaddr=%p", __entry->skbaddr)
+)
+#endif
+
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,32))
+TRACE_EVENT(skb_copy_datagram_iovec,
+
+       TP_PROTO(const struct sk_buff *skb, int len),
+
+       TP_ARGS(skb, len),
+
+       TP_STRUCT__entry(
+               __field(        const void *,           skbaddr         )
+               __field(        int,                    len             )
+       ),
+
+       TP_fast_assign(
+               tp_assign(skbaddr, skb)
+               tp_assign(len, len)
+       ),
+
+       TP_printk("skbaddr=%p len=%d", __entry->skbaddr, __entry->len)
+)
+#endif
+
+#endif /* _TRACE_SKB_H */
+
+/* This part must be outside protection */
+#include "../../../probes/define_trace.h"
diff --git a/drivers/staging/lttng/instrumentation/events/lttng-module/sock.h b/drivers/staging/lttng/instrumentation/events/lttng-module/sock.h
new file mode 100644 (file)
index 0000000..3e3dbc7
--- /dev/null
@@ -0,0 +1,68 @@
+#undef TRACE_SYSTEM
+#define TRACE_SYSTEM sock
+
+#if !defined(_TRACE_SOCK_H) || defined(TRACE_HEADER_MULTI_READ)
+#define _TRACE_SOCK_H
+
+#include <net/sock.h>
+#include <linux/tracepoint.h>
+
+TRACE_EVENT(sock_rcvqueue_full,
+
+       TP_PROTO(struct sock *sk, struct sk_buff *skb),
+
+       TP_ARGS(sk, skb),
+
+       TP_STRUCT__entry(
+               __field(int, rmem_alloc)
+               __field(unsigned int, truesize)
+               __field(int, sk_rcvbuf)
+       ),
+
+       TP_fast_assign(
+               tp_assign(rmem_alloc, atomic_read(&sk->sk_rmem_alloc))
+               tp_assign(truesize, skb->truesize)
+               tp_assign(sk_rcvbuf, sk->sk_rcvbuf)
+       ),
+
+       TP_printk("rmem_alloc=%d truesize=%u sk_rcvbuf=%d",
+               __entry->rmem_alloc, __entry->truesize, __entry->sk_rcvbuf)
+)
+
+TRACE_EVENT(sock_exceed_buf_limit,
+
+       TP_PROTO(struct sock *sk, struct proto *prot, long allocated),
+
+       TP_ARGS(sk, prot, allocated),
+
+       TP_STRUCT__entry(
+               __string(name, prot->name)
+               __array(long, sysctl_mem, 3)
+               __field(long, allocated)
+               __field(int, sysctl_rmem)
+               __field(int, rmem_alloc)
+       ),
+
+       TP_fast_assign(
+               tp_strcpy(name, prot->name)
+               tp_memcpy(sysctl_mem, prot->sysctl_mem, 3 * sizeof(long))
+               tp_assign(allocated, allocated)
+               tp_assign(sysctl_rmem, prot->sysctl_rmem[0])
+               tp_assign(rmem_alloc, atomic_read(&sk->sk_rmem_alloc))
+       ),
+
+       TP_printk("proto:%s sysctl_mem=%ld,%ld,%ld allocated=%ld "
+               "sysctl_rmem=%d rmem_alloc=%d",
+               __entry->name,
+               __entry->sysctl_mem[0],
+               __entry->sysctl_mem[1],
+               __entry->sysctl_mem[2],
+               __entry->allocated,
+               __entry->sysctl_rmem,
+               __entry->rmem_alloc)
+)
+
+#endif /* _TRACE_SOCK_H */
+
+/* This part must be outside protection */
+#include "../../../probes/define_trace.h"
diff --git a/drivers/staging/lttng/instrumentation/events/lttng-module/sunrpc.h b/drivers/staging/lttng/instrumentation/events/lttng-module/sunrpc.h
new file mode 100644 (file)
index 0000000..6320668
--- /dev/null
@@ -0,0 +1,177 @@
+#undef TRACE_SYSTEM
+#define TRACE_SYSTEM sunrpc
+
+#if !defined(_TRACE_SUNRPC_H) || defined(TRACE_HEADER_MULTI_READ)
+#define _TRACE_SUNRPC_H
+
+#include <linux/sunrpc/sched.h>
+#include <linux/sunrpc/clnt.h>
+#include <linux/tracepoint.h>
+
+DECLARE_EVENT_CLASS(rpc_task_status,
+
+       TP_PROTO(struct rpc_task *task),
+
+       TP_ARGS(task),
+
+       TP_STRUCT__entry(
+               __field(const struct rpc_task *, task)
+               __field(const struct rpc_clnt *, clnt)
+               __field(int, status)
+       ),
+
+       TP_fast_assign(
+               tp_assign(task, task)
+               tp_assign(clnt, task->tk_client)
+               tp_assign(status, task->tk_status)
+       ),
+
+       TP_printk("task:%p@%p, status %d",__entry->task, __entry->clnt, __entry->status)
+)
+
+DEFINE_EVENT(rpc_task_status, rpc_call_status,
+       TP_PROTO(struct rpc_task *task),
+
+       TP_ARGS(task)
+)
+
+DEFINE_EVENT(rpc_task_status, rpc_bind_status,
+       TP_PROTO(struct rpc_task *task),
+
+       TP_ARGS(task)
+)
+
+TRACE_EVENT(rpc_connect_status,
+       TP_PROTO(struct rpc_task *task, int status),
+
+       TP_ARGS(task, status),
+
+       TP_STRUCT__entry(
+               __field(const struct rpc_task *, task)
+               __field(const struct rpc_clnt *, clnt)
+               __field(int, status)
+       ),
+
+       TP_fast_assign(
+               tp_assign(task, task)
+               tp_assign(clnt, task->tk_client)
+               tp_assign(status, status)
+       ),
+
+       TP_printk("task:%p@%p, status %d",__entry->task, __entry->clnt, __entry->status)
+)
+
+DECLARE_EVENT_CLASS(rpc_task_running,
+
+       TP_PROTO(const struct rpc_clnt *clnt, const struct rpc_task *task, const void *action),
+
+       TP_ARGS(clnt, task, action),
+
+       TP_STRUCT__entry(
+               __field(const struct rpc_clnt *, clnt)
+               __field(const struct rpc_task *, task)
+               __field(const void *, action)
+               __field(unsigned long, runstate)
+               __field(int, status)
+               __field(unsigned short, flags)
+               ),
+
+       TP_fast_assign(
+               tp_assign(clnt, clnt)
+               tp_assign(task, task)
+               tp_assign(action, action)
+               tp_assign(runstate, task->tk_runstate)
+               tp_assign(status, task->tk_status)
+               tp_assign(flags, task->tk_flags)
+               ),
+
+       TP_printk("task:%p@%p flags=%4.4x state=%4.4lx status=%d action=%pf",
+               __entry->task,
+               __entry->clnt,
+               __entry->flags,
+               __entry->runstate,
+               __entry->status,
+               __entry->action
+               )
+)
+
+DEFINE_EVENT(rpc_task_running, rpc_task_begin,
+
+       TP_PROTO(const struct rpc_clnt *clnt, const struct rpc_task *task, const void *action),
+
+       TP_ARGS(clnt, task, action)
+
+)
+
+DEFINE_EVENT(rpc_task_running, rpc_task_run_action,
+
+       TP_PROTO(const struct rpc_clnt *clnt, const struct rpc_task *task, const void *action),
+
+       TP_ARGS(clnt, task, action)
+
+)
+
+DEFINE_EVENT(rpc_task_running, rpc_task_complete,
+
+       TP_PROTO(const struct rpc_clnt *clnt, const struct rpc_task *task, const void *action),
+
+       TP_ARGS(clnt, task, action)
+
+)
+
+DECLARE_EVENT_CLASS(rpc_task_queued,
+
+       TP_PROTO(const struct rpc_clnt *clnt, const struct rpc_task *task, const struct rpc_wait_queue *q),
+
+       TP_ARGS(clnt, task, q),
+
+       TP_STRUCT__entry(
+               __field(const struct rpc_clnt *, clnt)
+               __field(const struct rpc_task *, task)
+               __field(unsigned long, timeout)
+               __field(unsigned long, runstate)
+               __field(int, status)
+               __field(unsigned short, flags)
+               __string(q_name, rpc_qname(q))
+               ),
+
+       TP_fast_assign(
+               tp_assign(clnt, clnt)
+               tp_assign(task, task)
+               tp_assign(timeout, task->tk_timeout)
+               tp_assign(runstate, task->tk_runstate)
+               tp_assign(status, task->tk_status)
+               tp_assign(flags, task->tk_flags)
+               tp_strcpy(q_name, rpc_qname(q))
+               ),
+
+       TP_printk("task:%p@%p flags=%4.4x state=%4.4lx status=%d timeout=%lu queue=%s",
+               __entry->task,
+               __entry->clnt,
+               __entry->flags,
+               __entry->runstate,
+               __entry->status,
+               __entry->timeout,
+               __get_str(q_name)
+               )
+)
+
+DEFINE_EVENT(rpc_task_queued, rpc_task_sleep,
+
+       TP_PROTO(const struct rpc_clnt *clnt, const struct rpc_task *task, const struct rpc_wait_queue *q),
+
+       TP_ARGS(clnt, task, q)
+
+)
+
+DEFINE_EVENT(rpc_task_queued, rpc_task_wakeup,
+
+       TP_PROTO(const struct rpc_clnt *clnt, const struct rpc_task *task, const struct rpc_wait_queue *q),
+
+       TP_ARGS(clnt, task, q)
+
+)
+
+#endif /* _TRACE_SUNRPC_H */
+
+#include "../../../probes/define_trace.h"
diff --git a/drivers/staging/lttng/instrumentation/events/lttng-module/syscalls.h b/drivers/staging/lttng/instrumentation/events/lttng-module/syscalls.h
new file mode 100644 (file)
index 0000000..a2bb956
--- /dev/null
@@ -0,0 +1,76 @@
+#undef TRACE_SYSTEM
+#define TRACE_SYSTEM raw_syscalls
+#define TRACE_INCLUDE_FILE syscalls
+
+#if !defined(_TRACE_EVENTS_SYSCALLS_H) || defined(TRACE_HEADER_MULTI_READ)
+#define _TRACE_EVENTS_SYSCALLS_H
+
+#include <linux/tracepoint.h>
+
+#ifdef CONFIG_HAVE_SYSCALL_TRACEPOINTS
+
+#ifndef _TRACE_SYSCALLS_DEF_
+#define _TRACE_SYSCALLS_DEF_
+
+#include <asm/ptrace.h>
+#include <asm/syscall.h>
+
+#endif /* _TRACE_SYSCALLS_DEF_ */
+
+TRACE_EVENT(sys_enter,
+
+       TP_PROTO(struct pt_regs *regs, long id),
+
+       TP_ARGS(regs, id),
+
+       TP_STRUCT__entry(
+               __field(        long,           id              )
+               __array(        unsigned long,  args,   6       )
+       ),
+
+       TP_fast_assign(
+               tp_assign(id, id)
+               {
+                       tp_memcpy(args,
+                               ({
+                                       unsigned long args_copy[6];
+                                       syscall_get_arguments(current, regs,
+                                                       0, 6, args_copy);
+                                       args_copy;
+                               }), 6 * sizeof(unsigned long));
+               }
+       ),
+
+       TP_printk("NR %ld (%lx, %lx, %lx, %lx, %lx, %lx)",
+                 __entry->id,
+                 __entry->args[0], __entry->args[1], __entry->args[2],
+                 __entry->args[3], __entry->args[4], __entry->args[5])
+)
+
+TRACE_EVENT(sys_exit,
+
+       TP_PROTO(struct pt_regs *regs, long ret),
+
+       TP_ARGS(regs, ret),
+
+       TP_STRUCT__entry(
+               __field(        long,   id      )
+               __field(        long,   ret     )
+       ),
+
+       TP_fast_assign(
+               tp_assign(id, syscall_get_nr(current, regs))
+               tp_assign(ret, ret)
+       ),
+
+       TP_printk("NR %ld = %ld",
+                 __entry->id, __entry->ret)
+)
+
+#endif /* CONFIG_HAVE_SYSCALL_TRACEPOINTS */
+
+#endif /* _TRACE_EVENTS_SYSCALLS_H */
+
+/* This part must be outside protection */
+#include "../../../probes/define_trace.h"
+
diff --git a/drivers/staging/lttng/instrumentation/events/lttng-module/timer.h b/drivers/staging/lttng/instrumentation/events/lttng-module/timer.h
new file mode 100644 (file)
index 0000000..dd27838
--- /dev/null
@@ -0,0 +1,336 @@
+#undef TRACE_SYSTEM
+#define TRACE_SYSTEM timer
+
+#if !defined(_TRACE_TIMER_H) || defined(TRACE_HEADER_MULTI_READ)
+#define _TRACE_TIMER_H
+
+#include <linux/tracepoint.h>
+
+#ifndef _TRACE_TIMER_DEF_
+#define _TRACE_TIMER_DEF_
+#include <linux/hrtimer.h>
+#include <linux/timer.h>
+
+struct timer_list;
+
+#endif /* _TRACE_TIMER_DEF_ */
+
+DECLARE_EVENT_CLASS(timer_class,
+
+       TP_PROTO(struct timer_list *timer),
+
+       TP_ARGS(timer),
+
+       TP_STRUCT__entry(
+               __field( void *,        timer   )
+       ),
+
+       TP_fast_assign(
+               tp_assign(timer, timer)
+       ),
+
+       TP_printk("timer=%p", __entry->timer)
+)
+
+/**
+ * timer_init - called when the timer is initialized
+ * @timer:     pointer to struct timer_list
+ */
+DEFINE_EVENT(timer_class, timer_init,
+
+       TP_PROTO(struct timer_list *timer),
+
+       TP_ARGS(timer)
+)
+
+/**
+ * timer_start - called when the timer is started
+ * @timer:     pointer to struct timer_list
+ * @expires:   the timers expiry time
+ */
+TRACE_EVENT(timer_start,
+
+       TP_PROTO(struct timer_list *timer, unsigned long expires),
+
+       TP_ARGS(timer, expires),
+
+       TP_STRUCT__entry(
+               __field( void *,        timer           )
+               __field( void *,        function        )
+               __field( unsigned long, expires         )
+               __field( unsigned long, now             )
+       ),
+
+       TP_fast_assign(
+               tp_assign(timer, timer)
+               tp_assign(function, timer->function)
+               tp_assign(expires, expires)
+               tp_assign(now, jiffies)
+       ),
+
+       TP_printk("timer=%p function=%pf expires=%lu [timeout=%ld]",
+                 __entry->timer, __entry->function, __entry->expires,
+                 (long)__entry->expires - __entry->now)
+)
+
+/**
+ * timer_expire_entry - called immediately before the timer callback
+ * @timer:     pointer to struct timer_list
+ *
+ * Allows to determine the timer latency.
+ */
+TRACE_EVENT(timer_expire_entry,
+
+       TP_PROTO(struct timer_list *timer),
+
+       TP_ARGS(timer),
+
+       TP_STRUCT__entry(
+               __field( void *,        timer   )
+               __field( unsigned long, now     )
+               __field( void *,        function)
+       ),
+
+       TP_fast_assign(
+               tp_assign(timer, timer)
+               tp_assign(now, jiffies)
+               tp_assign(function, timer->function)
+       ),
+
+       TP_printk("timer=%p function=%pf now=%lu", __entry->timer, __entry->function,__entry->now)
+)
+
+/**
+ * timer_expire_exit - called immediately after the timer callback returns
+ * @timer:     pointer to struct timer_list
+ *
+ * When used in combination with the timer_expire_entry tracepoint we can
+ * determine the runtime of the timer callback function.
+ *
+ * NOTE: Do NOT derefernce timer in TP_fast_assign. The pointer might
+ * be invalid. We solely track the pointer.
+ */
+DEFINE_EVENT(timer_class, timer_expire_exit,
+
+       TP_PROTO(struct timer_list *timer),
+
+       TP_ARGS(timer)
+)
+
+/**
+ * timer_cancel - called when the timer is canceled
+ * @timer:     pointer to struct timer_list
+ */
+DEFINE_EVENT(timer_class, timer_cancel,
+
+       TP_PROTO(struct timer_list *timer),
+
+       TP_ARGS(timer)
+)
+
+/**
+ * hrtimer_init - called when the hrtimer is initialized
+ * @timer:     pointer to struct hrtimer
+ * @clockid:   the hrtimers clock
+ * @mode:      the hrtimers mode
+ */
+TRACE_EVENT(hrtimer_init,
+
+       TP_PROTO(struct hrtimer *hrtimer, clockid_t clockid,
+                enum hrtimer_mode mode),
+
+       TP_ARGS(hrtimer, clockid, mode),
+
+       TP_STRUCT__entry(
+               __field( void *,                hrtimer         )
+               __field( clockid_t,             clockid         )
+               __field( enum hrtimer_mode,     mode            )
+       ),
+
+       TP_fast_assign(
+               tp_assign(hrtimer, hrtimer)
+               tp_assign(clockid, clockid)
+               tp_assign(mode, mode)
+       ),
+
+       TP_printk("hrtimer=%p clockid=%s mode=%s", __entry->hrtimer,
+                 __entry->clockid == CLOCK_REALTIME ?
+                       "CLOCK_REALTIME" : "CLOCK_MONOTONIC",
+                 __entry->mode == HRTIMER_MODE_ABS ?
+                       "HRTIMER_MODE_ABS" : "HRTIMER_MODE_REL")
+)
+
+/**
+ * hrtimer_start - called when the hrtimer is started
+ * @timer: pointer to struct hrtimer
+ */
+TRACE_EVENT(hrtimer_start,
+
+       TP_PROTO(struct hrtimer *hrtimer),
+
+       TP_ARGS(hrtimer),
+
+       TP_STRUCT__entry(
+               __field( void *,        hrtimer         )
+               __field( void *,        function        )
+               __field( s64,           expires         )
+               __field( s64,           softexpires     )
+       ),
+
+       TP_fast_assign(
+               tp_assign(hrtimer, hrtimer)
+               tp_assign(function, hrtimer->function)
+               tp_assign(expires, hrtimer_get_expires(hrtimer).tv64)
+               tp_assign(softexpires, hrtimer_get_softexpires(hrtimer).tv64)
+       ),
+
+       TP_printk("hrtimer=%p function=%pf expires=%llu softexpires=%llu",
+                 __entry->hrtimer, __entry->function,
+                 (unsigned long long)ktime_to_ns((ktime_t) {
+                                 .tv64 = __entry->expires }),
+                 (unsigned long long)ktime_to_ns((ktime_t) {
+                                 .tv64 = __entry->softexpires }))
+)
+
+/**
+ * htimmer_expire_entry - called immediately before the hrtimer callback
+ * @timer:     pointer to struct hrtimer
+ * @now:       pointer to variable which contains current time of the
+ *             timers base.
+ *
+ * Allows to determine the timer latency.
+ */
+TRACE_EVENT(hrtimer_expire_entry,
+
+       TP_PROTO(struct hrtimer *hrtimer, ktime_t *now),
+
+       TP_ARGS(hrtimer, now),
+
+       TP_STRUCT__entry(
+               __field( void *,        hrtimer )
+               __field( s64,           now     )
+               __field( void *,        function)
+       ),
+
+       TP_fast_assign(
+               tp_assign(hrtimer, hrtimer)
+               tp_assign(now, now->tv64)
+               tp_assign(function, hrtimer->function)
+       ),
+
+       TP_printk("hrtimer=%p function=%pf now=%llu", __entry->hrtimer, __entry->function,
+                 (unsigned long long)ktime_to_ns((ktime_t) { .tv64 = __entry->now }))
+)
+
+DECLARE_EVENT_CLASS(hrtimer_class,
+
+       TP_PROTO(struct hrtimer *hrtimer),
+
+       TP_ARGS(hrtimer),
+
+       TP_STRUCT__entry(
+               __field( void *,        hrtimer )
+       ),
+
+       TP_fast_assign(
+               tp_assign(hrtimer, hrtimer)
+       ),
+
+       TP_printk("hrtimer=%p", __entry->hrtimer)
+)
+
+/**
+ * hrtimer_expire_exit - called immediately after the hrtimer callback returns
+ * @timer:     pointer to struct hrtimer
+ *
+ * When used in combination with the hrtimer_expire_entry tracepoint we can
+ * determine the runtime of the callback function.
+ */
+DEFINE_EVENT(hrtimer_class, hrtimer_expire_exit,
+
+       TP_PROTO(struct hrtimer *hrtimer),
+
+       TP_ARGS(hrtimer)
+)
+
+/**
+ * hrtimer_cancel - called when the hrtimer is canceled
+ * @hrtimer:   pointer to struct hrtimer
+ */
+DEFINE_EVENT(hrtimer_class, hrtimer_cancel,
+
+       TP_PROTO(struct hrtimer *hrtimer),
+
+       TP_ARGS(hrtimer)
+)
+
+/**
+ * itimer_state - called when itimer is started or canceled
+ * @which:     name of the interval timer
+ * @value:     the itimers value, itimer is canceled if value->it_value is
+ *             zero, otherwise it is started
+ * @expires:   the itimers expiry time
+ */
+TRACE_EVENT(itimer_state,
+
+       TP_PROTO(int which, const struct itimerval *const value,
+                cputime_t expires),
+
+       TP_ARGS(which, value, expires),
+
+       TP_STRUCT__entry(
+               __field(        int,            which           )
+               __field(        cputime_t,      expires         )
+               __field(        long,           value_sec       )
+               __field(        long,           value_usec      )
+               __field(        long,           interval_sec    )
+               __field(        long,           interval_usec   )
+       ),
+
+       TP_fast_assign(
+               tp_assign(which, which)
+               tp_assign(expires, expires)
+               tp_assign(value_sec, value->it_value.tv_sec)
+               tp_assign(value_usec, value->it_value.tv_usec)
+               tp_assign(interval_sec, value->it_interval.tv_sec)
+               tp_assign(interval_usec, value->it_interval.tv_usec)
+       ),
+
+       TP_printk("which=%d expires=%llu it_value=%ld.%ld it_interval=%ld.%ld",
+                 __entry->which, (unsigned long long)__entry->expires,
+                 __entry->value_sec, __entry->value_usec,
+                 __entry->interval_sec, __entry->interval_usec)
+)
+
+/**
+ * itimer_expire - called when itimer expires
+ * @which:     type of the interval timer
+ * @pid:       pid of the process which owns the timer
+ * @now:       current time, used to calculate the latency of itimer
+ */
+TRACE_EVENT(itimer_expire,
+
+       TP_PROTO(int which, struct pid *pid, cputime_t now),
+
+       TP_ARGS(which, pid, now),
+
+       TP_STRUCT__entry(
+               __field( int ,          which   )
+               __field( pid_t,         pid     )
+               __field( cputime_t,     now     )
+       ),
+
+       TP_fast_assign(
+               tp_assign(which, which)
+               tp_assign(now, now)
+               tp_assign(pid, pid_nr(pid))
+       ),
+
+       TP_printk("which=%d pid=%d now=%llu", __entry->which,
+                 (int) __entry->pid, (unsigned long long)__entry->now)
+)
+
+#endif /*  _TRACE_TIMER_H */
+
+/* This part must be outside protection */
+#include "../../../probes/define_trace.h"
diff --git a/drivers/staging/lttng/instrumentation/events/lttng-module/udp.h b/drivers/staging/lttng/instrumentation/events/lttng-module/udp.h
new file mode 100644 (file)
index 0000000..a246e84
--- /dev/null
@@ -0,0 +1,32 @@
+#undef TRACE_SYSTEM
+#define TRACE_SYSTEM udp
+
+#if !defined(_TRACE_UDP_H) || defined(TRACE_HEADER_MULTI_READ)
+#define _TRACE_UDP_H
+
+#include <linux/udp.h>
+#include <linux/tracepoint.h>
+
+TRACE_EVENT(udp_fail_queue_rcv_skb,
+
+       TP_PROTO(int rc, struct sock *sk),
+
+       TP_ARGS(rc, sk),
+
+       TP_STRUCT__entry(
+               __field(int, rc)
+               __field(__u16, lport)
+       ),
+
+       TP_fast_assign(
+               tp_assign(rc, rc)
+               tp_assign(lport, inet_sk(sk)->inet_num)
+       ),
+
+       TP_printk("rc=%d port=%hu", __entry->rc, __entry->lport)
+)
+
+#endif /* _TRACE_UDP_H */
+
+/* This part must be outside protection */
+#include "../../../probes/define_trace.h"
diff --git a/drivers/staging/lttng/instrumentation/events/lttng-module/vmscan.h b/drivers/staging/lttng/instrumentation/events/lttng-module/vmscan.h
new file mode 100644 (file)
index 0000000..1fd50ba
--- /dev/null
@@ -0,0 +1,594 @@
+#undef TRACE_SYSTEM
+#define TRACE_SYSTEM vmscan
+
+#if !defined(_TRACE_VMSCAN_H) || defined(TRACE_HEADER_MULTI_READ)
+#define _TRACE_VMSCAN_H
+
+#include <linux/types.h>
+#include <linux/tracepoint.h>
+#include <linux/mm.h>
+#include <linux/memcontrol.h>
+#include <trace/events/gfpflags.h>
+#include <linux/version.h>
+
+#ifndef _TRACE_VMSCAN_DEF
+#define _TRACE_VMSCAN_DEF
+#define RECLAIM_WB_ANON                0x0001u
+#define RECLAIM_WB_FILE                0x0002u
+#define RECLAIM_WB_MIXED       0x0010u
+#define RECLAIM_WB_SYNC                0x0004u /* Unused, all reclaim async */
+#define RECLAIM_WB_ASYNC       0x0008u
+
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,37))
+#define show_reclaim_flags(flags)                              \
+       (flags) ? __print_flags(flags, "|",                     \
+               {RECLAIM_WB_ANON,       "RECLAIM_WB_ANON"},     \
+               {RECLAIM_WB_FILE,       "RECLAIM_WB_FILE"},     \
+               {RECLAIM_WB_MIXED,      "RECLAIM_WB_MIXED"},    \
+               {RECLAIM_WB_SYNC,       "RECLAIM_WB_SYNC"},     \
+               {RECLAIM_WB_ASYNC,      "RECLAIM_WB_ASYNC"}     \
+               ) : "RECLAIM_WB_NONE"
+#else
+#define show_reclaim_flags(flags)                              \
+       (flags) ? __print_flags(flags, "|",                     \
+               {RECLAIM_WB_ANON,       "RECLAIM_WB_ANON"},     \
+               {RECLAIM_WB_FILE,       "RECLAIM_WB_FILE"},     \
+               {RECLAIM_WB_SYNC,       "RECLAIM_WB_SYNC"},     \
+               {RECLAIM_WB_ASYNC,      "RECLAIM_WB_ASYNC"}     \
+               ) : "RECLAIM_WB_NONE"
+#endif
+
+#if ((LINUX_VERSION_CODE <= KERNEL_VERSION(3,0,38)) || \
+       LTTNG_KERNEL_RANGE(3,1,0, 3,2,0))
+typedef int isolate_mode_t;
+#endif
+
+#endif
+
+TRACE_EVENT(mm_vmscan_kswapd_sleep,
+
+       TP_PROTO(int nid),
+
+       TP_ARGS(nid),
+
+       TP_STRUCT__entry(
+               __field(        int,    nid     )
+       ),
+
+       TP_fast_assign(
+               tp_assign(nid, nid)
+       ),
+
+       TP_printk("nid=%d", __entry->nid)
+)
+
+TRACE_EVENT(mm_vmscan_kswapd_wake,
+
+       TP_PROTO(int nid, int order),
+
+       TP_ARGS(nid, order),
+
+       TP_STRUCT__entry(
+               __field(        int,    nid     )
+               __field(        int,    order   )
+       ),
+
+       TP_fast_assign(
+               tp_assign(nid, nid)
+               tp_assign(order, order)
+       ),
+
+       TP_printk("nid=%d order=%d", __entry->nid, __entry->order)
+)
+
+TRACE_EVENT(mm_vmscan_wakeup_kswapd,
+
+       TP_PROTO(int nid, int zid, int order),
+
+       TP_ARGS(nid, zid, order),
+
+       TP_STRUCT__entry(
+               __field(        int,            nid     )
+               __field(        int,            zid     )
+               __field(        int,            order   )
+       ),
+
+       TP_fast_assign(
+               tp_assign(nid, nid)
+               tp_assign(zid, zid)
+               tp_assign(order, order)
+       ),
+
+       TP_printk("nid=%d zid=%d order=%d",
+               __entry->nid,
+               __entry->zid,
+               __entry->order)
+)
+
+DECLARE_EVENT_CLASS(mm_vmscan_direct_reclaim_begin_template,
+
+       TP_PROTO(int order, int may_writepage, gfp_t gfp_flags),
+
+       TP_ARGS(order, may_writepage, gfp_flags),
+
+       TP_STRUCT__entry(
+               __field(        int,    order           )
+               __field(        int,    may_writepage   )
+               __field(        gfp_t,  gfp_flags       )
+       ),
+
+       TP_fast_assign(
+               tp_assign(order, order)
+               tp_assign(may_writepage, may_writepage)
+               tp_assign(gfp_flags, gfp_flags)
+       ),
+
+       TP_printk("order=%d may_writepage=%d gfp_flags=%s",
+               __entry->order,
+               __entry->may_writepage,
+               show_gfp_flags(__entry->gfp_flags))
+)
+
+DEFINE_EVENT(mm_vmscan_direct_reclaim_begin_template, mm_vmscan_direct_reclaim_begin,
+
+       TP_PROTO(int order, int may_writepage, gfp_t gfp_flags),
+
+       TP_ARGS(order, may_writepage, gfp_flags)
+)
+
+DEFINE_EVENT(mm_vmscan_direct_reclaim_begin_template, mm_vmscan_memcg_reclaim_begin,
+
+       TP_PROTO(int order, int may_writepage, gfp_t gfp_flags),
+
+       TP_ARGS(order, may_writepage, gfp_flags)
+)
+
+DEFINE_EVENT(mm_vmscan_direct_reclaim_begin_template, mm_vmscan_memcg_softlimit_reclaim_begin,
+
+       TP_PROTO(int order, int may_writepage, gfp_t gfp_flags),
+
+       TP_ARGS(order, may_writepage, gfp_flags)
+)
+
+DECLARE_EVENT_CLASS(mm_vmscan_direct_reclaim_end_template,
+
+       TP_PROTO(unsigned long nr_reclaimed),
+
+       TP_ARGS(nr_reclaimed),
+
+       TP_STRUCT__entry(
+               __field(        unsigned long,  nr_reclaimed    )
+       ),
+
+       TP_fast_assign(
+               tp_assign(nr_reclaimed, nr_reclaimed)
+       ),
+
+       TP_printk("nr_reclaimed=%lu", __entry->nr_reclaimed)
+)
+
+DEFINE_EVENT(mm_vmscan_direct_reclaim_end_template, mm_vmscan_direct_reclaim_end,
+
+       TP_PROTO(unsigned long nr_reclaimed),
+
+       TP_ARGS(nr_reclaimed)
+)
+
+DEFINE_EVENT(mm_vmscan_direct_reclaim_end_template, mm_vmscan_memcg_reclaim_end,
+
+       TP_PROTO(unsigned long nr_reclaimed),
+
+       TP_ARGS(nr_reclaimed)
+)
+
+DEFINE_EVENT(mm_vmscan_direct_reclaim_end_template, mm_vmscan_memcg_softlimit_reclaim_end,
+
+       TP_PROTO(unsigned long nr_reclaimed),
+
+       TP_ARGS(nr_reclaimed)
+)
+
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,1,0))
+TRACE_EVENT(mm_shrink_slab_start,
+       TP_PROTO(struct shrinker *shr, struct shrink_control *sc,
+               long nr_objects_to_shrink, unsigned long pgs_scanned,
+               unsigned long lru_pgs, unsigned long cache_items,
+               unsigned long long delta, unsigned long total_scan),
+
+       TP_ARGS(shr, sc, nr_objects_to_shrink, pgs_scanned, lru_pgs,
+               cache_items, delta, total_scan),
+
+       TP_STRUCT__entry(
+               __field(struct shrinker *, shr)
+               __field(void *, shrink)
+               __field(long, nr_objects_to_shrink)
+               __field(gfp_t, gfp_flags)
+               __field(unsigned long, pgs_scanned)
+               __field(unsigned long, lru_pgs)
+               __field(unsigned long, cache_items)
+               __field(unsigned long long, delta)
+               __field(unsigned long, total_scan)
+       ),
+
+       TP_fast_assign(
+               tp_assign(shr,shr)
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,12,0))
+               tp_assign(shrink, shr->scan_objects)
+#else /* #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,12,0)) */
+               tp_assign(shrink, shr->shrink)
+#endif /* #else #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,12,0)) */
+               tp_assign(nr_objects_to_shrink, nr_objects_to_shrink)
+               tp_assign(gfp_flags, sc->gfp_mask)
+               tp_assign(pgs_scanned, pgs_scanned)
+               tp_assign(lru_pgs, lru_pgs)
+               tp_assign(cache_items, cache_items)
+               tp_assign(delta, delta)
+               tp_assign(total_scan, total_scan)
+       ),
+
+       TP_printk("%pF %p: objects to shrink %ld gfp_flags %s pgs_scanned %ld lru_pgs %ld cache items %ld delta %lld total_scan %ld",
+               __entry->shrink,
+               __entry->shr,
+               __entry->nr_objects_to_shrink,
+               show_gfp_flags(__entry->gfp_flags),
+               __entry->pgs_scanned,
+               __entry->lru_pgs,
+               __entry->cache_items,
+               __entry->delta,
+               __entry->total_scan)
+)
+
+TRACE_EVENT(mm_shrink_slab_end,
+       TP_PROTO(struct shrinker *shr, int shrinker_retval,
+               long unused_scan_cnt, long new_scan_cnt),
+
+       TP_ARGS(shr, shrinker_retval, unused_scan_cnt, new_scan_cnt),
+
+       TP_STRUCT__entry(
+               __field(struct shrinker *, shr)
+               __field(void *, shrink)
+               __field(long, unused_scan)
+               __field(long, new_scan)
+               __field(int, retval)
+               __field(long, total_scan)
+       ),
+
+       TP_fast_assign(
+               tp_assign(shr, shr)
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,12,0))
+               tp_assign(shrink, shr->scan_objects)
+#else /* #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,12,0)) */
+               tp_assign(shrink, shr->shrink)
+#endif /* #else #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,12,0)) */
+               tp_assign(unused_scan, unused_scan_cnt)
+               tp_assign(new_scan, new_scan_cnt)
+               tp_assign(retval, shrinker_retval)
+               tp_assign(total_scan, new_scan_cnt - unused_scan_cnt)
+       ),
+
+       TP_printk("%pF %p: unused scan count %ld new scan count %ld total_scan %ld last shrinker return val %d",
+               __entry->shrink,
+               __entry->shr,
+               __entry->unused_scan,
+               __entry->new_scan,
+               __entry->total_scan,
+               __entry->retval)
+)
+#endif
+
+DECLARE_EVENT_CLASS(mm_vmscan_lru_isolate_template,
+
+       TP_PROTO(int order,
+               unsigned long nr_requested,
+               unsigned long nr_scanned,
+               unsigned long nr_taken,
+#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,5,0))
+               unsigned long nr_lumpy_taken,
+               unsigned long nr_lumpy_dirty,
+               unsigned long nr_lumpy_failed,
+#endif
+#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,3,0))
+               isolate_mode_t isolate_mode
+#else
+               isolate_mode_t isolate_mode,
+               int file
+#endif
+       ),
+
+       TP_ARGS(order, nr_requested, nr_scanned, nr_taken,
+#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,5,0))
+               nr_lumpy_taken, nr_lumpy_dirty, nr_lumpy_failed,
+#endif
+#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,3,0))
+               isolate_mode
+#else
+               isolate_mode, file
+#endif
+       ),
+
+
+       TP_STRUCT__entry(
+               __field(int, order)
+               __field(unsigned long, nr_requested)
+               __field(unsigned long, nr_scanned)
+               __field(unsigned long, nr_taken)
+#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,5,0))
+               __field(unsigned long, nr_lumpy_taken)
+               __field(unsigned long, nr_lumpy_dirty)
+               __field(unsigned long, nr_lumpy_failed)
+#endif
+               __field(isolate_mode_t, isolate_mode)
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,3,0))
+               __field(int, file)
+#endif
+       ),
+
+       TP_fast_assign(
+               tp_assign(order, order)
+               tp_assign(nr_requested, nr_requested)
+               tp_assign(nr_scanned, nr_scanned)
+               tp_assign(nr_taken, nr_taken)
+#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,5,0))
+               tp_assign(nr_lumpy_taken, nr_lumpy_taken)
+               tp_assign(nr_lumpy_dirty, nr_lumpy_dirty)
+               tp_assign(nr_lumpy_failed, nr_lumpy_failed)
+#endif
+               tp_assign(isolate_mode, isolate_mode)
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,3,0))
+               tp_assign(file, file)
+#endif
+       ),
+
+#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,3,0))
+       TP_printk("isolate_mode=%d order=%d nr_requested=%lu nr_scanned=%lu nr_taken=%lu contig_taken=%lu contig_dirty=%lu contig_failed=%lu",
+               __entry->isolate_mode,
+               __entry->order,
+               __entry->nr_requested,
+               __entry->nr_scanned,
+               __entry->nr_taken,
+               __entry->nr_lumpy_taken,
+               __entry->nr_lumpy_dirty,
+               __entry->nr_lumpy_failed)
+#elif (LINUX_VERSION_CODE < KERNEL_VERSION(3,5,0))
+       TP_printk("isolate_mode=%d order=%d nr_requested=%lu nr_scanned=%lu nr_taken=%lu contig_taken=%lu contig_dirty=%lu contig_failed=%lu file=%d",
+               __entry->isolate_mode,
+               __entry->order,
+               __entry->nr_requested,
+               __entry->nr_scanned,
+               __entry->nr_taken,
+               __entry->nr_lumpy_taken,
+               __entry->nr_lumpy_dirty,
+               __entry->nr_lumpy_failed,
+               __entry->file)
+#else
+       TP_printk("isolate_mode=%d order=%d nr_requested=%lu nr_scanned=%lu nr_taken=%lu file=%d",
+               __entry->isolate_mode,
+               __entry->order,
+               __entry->nr_requested,
+               __entry->nr_scanned,
+               __entry->nr_taken,
+               __entry->file)
+#endif
+)
+
+DEFINE_EVENT(mm_vmscan_lru_isolate_template, mm_vmscan_lru_isolate,
+
+       TP_PROTO(int order,
+               unsigned long nr_requested,
+               unsigned long nr_scanned,
+               unsigned long nr_taken,
+#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,5,0))
+               unsigned long nr_lumpy_taken,
+               unsigned long nr_lumpy_dirty,
+               unsigned long nr_lumpy_failed,
+#endif
+#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,3,0))
+               isolate_mode_t isolate_mode
+#else
+               isolate_mode_t isolate_mode,
+               int file
+#endif
+       ),
+
+       TP_ARGS(order, nr_requested, nr_scanned, nr_taken,
+#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,5,0))
+               nr_lumpy_taken, nr_lumpy_dirty, nr_lumpy_failed,
+#endif
+#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,3,0))
+               isolate_mode
+#else
+               isolate_mode, file
+#endif
+       )
+
+)
+
+DEFINE_EVENT(mm_vmscan_lru_isolate_template, mm_vmscan_memcg_isolate,
+
+       TP_PROTO(int order,
+               unsigned long nr_requested,
+               unsigned long nr_scanned,
+               unsigned long nr_taken,
+#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,5,0))
+               unsigned long nr_lumpy_taken,
+               unsigned long nr_lumpy_dirty,
+               unsigned long nr_lumpy_failed,
+#endif
+#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,3,0))
+               isolate_mode_t isolate_mode
+#else
+               isolate_mode_t isolate_mode,
+               int file
+#endif
+       ),
+
+       TP_ARGS(order, nr_requested, nr_scanned, nr_taken,
+#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,5,0))
+               nr_lumpy_taken, nr_lumpy_dirty, nr_lumpy_failed,
+#endif
+#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,3,0))
+               isolate_mode
+#else
+               isolate_mode, file
+#endif
+       )
+)
+
+TRACE_EVENT(mm_vmscan_writepage,
+
+       TP_PROTO(struct page *page,
+               int reclaim_flags),
+
+       TP_ARGS(page, reclaim_flags),
+
+       TP_STRUCT__entry(
+               __field(struct page *, page)
+               __field(int, reclaim_flags)
+       ),
+
+       TP_fast_assign(
+               tp_assign(page, page)
+               tp_assign(reclaim_flags, reclaim_flags)
+       ),
+
+       TP_printk("page=%p pfn=%lu flags=%s",
+               __entry->page,
+               page_to_pfn(__entry->page),
+               show_reclaim_flags(__entry->reclaim_flags))
+)
+
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,37))
+TRACE_EVENT(mm_vmscan_lru_shrink_inactive,
+
+       TP_PROTO(int nid, int zid,
+                       unsigned long nr_scanned, unsigned long nr_reclaimed,
+                       int priority, int reclaim_flags),
+
+       TP_ARGS(nid, zid, nr_scanned, nr_reclaimed, priority, reclaim_flags),
+
+       TP_STRUCT__entry(
+               __field(int, nid)
+               __field(int, zid)
+               __field(unsigned long, nr_scanned)
+               __field(unsigned long, nr_reclaimed)
+               __field(int, priority)
+               __field(int, reclaim_flags)
+       ),
+
+       TP_fast_assign(
+               tp_assign(nid, nid)
+               tp_assign(zid, zid)
+               tp_assign(nr_scanned, nr_scanned)
+               tp_assign(nr_reclaimed, nr_reclaimed)
+               tp_assign(priority, priority)
+               tp_assign(reclaim_flags, reclaim_flags)
+       ),
+
+       TP_printk("nid=%d zid=%d nr_scanned=%ld nr_reclaimed=%ld priority=%d flags=%s",
+               __entry->nid, __entry->zid,
+               __entry->nr_scanned, __entry->nr_reclaimed,
+               __entry->priority,
+               show_reclaim_flags(__entry->reclaim_flags))
+)
+#endif
+
+#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,5,0))
+TRACE_EVENT_MAP(replace_swap_token,
+
+       mm_vmscan_replace_swap_token,
+
+       TP_PROTO(struct mm_struct *old_mm,
+                struct mm_struct *new_mm),
+
+       TP_ARGS(old_mm, new_mm),
+
+       TP_STRUCT__entry(
+               __field(struct mm_struct*,      old_mm)
+               __field(unsigned int,           old_prio)
+               __field(struct mm_struct*,      new_mm)
+               __field(unsigned int,           new_prio)
+       ),
+
+       TP_fast_assign(
+               tp_assign(old_mm, old_mm)
+               tp_assign(old_prio, old_mm ? old_mm->token_priority : 0)
+               tp_assign(new_mm, new_mm)
+               tp_assign(new_prio, new_mm->token_priority)
+       ),
+
+       TP_printk("old_token_mm=%p old_prio=%u new_token_mm=%p new_prio=%u",
+                 __entry->old_mm, __entry->old_prio,
+                 __entry->new_mm, __entry->new_prio)
+)
+
+DECLARE_EVENT_CLASS(mm_vmscan_put_swap_token_template,
+       TP_PROTO(struct mm_struct *swap_token_mm),
+
+       TP_ARGS(swap_token_mm),
+
+       TP_STRUCT__entry(
+               __field(struct mm_struct*, swap_token_mm)
+       ),
+
+       TP_fast_assign(
+               tp_assign(swap_token_mm, swap_token_mm)
+       ),
+
+       TP_printk("token_mm=%p", __entry->swap_token_mm)
+)
+
+DEFINE_EVENT_MAP(mm_vmscan_put_swap_token_template, put_swap_token,
+
+       mm_vmscan_put_swap_token,
+
+       TP_PROTO(struct mm_struct *swap_token_mm),
+       TP_ARGS(swap_token_mm)
+)
+
+DEFINE_EVENT_CONDITION_MAP(mm_vmscan_put_swap_token_template, disable_swap_token,
+
+       mm_vmscan_disable_swap_token,
+
+       TP_PROTO(struct mm_struct *swap_token_mm),
+       TP_ARGS(swap_token_mm),
+       TP_CONDITION(swap_token_mm != NULL)
+)
+
+TRACE_EVENT_CONDITION_MAP(update_swap_token_priority,
+
+       mm_vmscan_update_swap_token_priority,
+
+       TP_PROTO(struct mm_struct *mm,
+                unsigned int old_prio,
+                struct mm_struct *swap_token_mm),
+
+       TP_ARGS(mm, old_prio, swap_token_mm),
+
+       TP_CONDITION(mm->token_priority != old_prio),
+
+       TP_STRUCT__entry(
+               __field(struct mm_struct*, mm)
+               __field(unsigned int, old_prio)
+               __field(unsigned int, new_prio)
+               __field(struct mm_struct*, swap_token_mm)
+               __field(unsigned int, swap_token_prio)
+       ),
+
+       TP_fast_assign(
+               tp_assign(mm, mm)
+               tp_assign(old_prio, old_prio)
+               tp_assign(new_prio, mm->token_priority)
+               tp_assign(swap_token_mm, swap_token_mm)
+               tp_assign(swap_token_prio, swap_token_mm ? swap_token_mm->token_priority : 0)
+       ),
+
+       TP_printk("mm=%p old_prio=%u new_prio=%u swap_token_mm=%p token_prio=%u",
+                 __entry->mm, __entry->old_prio, __entry->new_prio,
+                 __entry->swap_token_mm, __entry->swap_token_prio)
+)
+#endif
+
+#endif /* _TRACE_VMSCAN_H */
+
+/* This part must be outside protection */
+#include "../../../probes/define_trace.h"
diff --git a/drivers/staging/lttng/instrumentation/events/lttng-module/workqueue.h b/drivers/staging/lttng/instrumentation/events/lttng-module/workqueue.h
new file mode 100644 (file)
index 0000000..96aa240
--- /dev/null
@@ -0,0 +1,219 @@
+#undef TRACE_SYSTEM
+#define TRACE_SYSTEM workqueue
+
+#if !defined(_TRACE_WORKQUEUE_H) || defined(TRACE_HEADER_MULTI_READ)
+#define _TRACE_WORKQUEUE_H
+
+#include <linux/tracepoint.h>
+#include <linux/workqueue.h>
+#include <linux/version.h>
+
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,36))
+
+#ifndef _TRACE_WORKQUEUE_DEF_
+#define _TRACE_WORKQUEUE_DEF_
+
+struct worker;
+struct global_cwq;
+
+#endif
+
+DECLARE_EVENT_CLASS(workqueue_work,
+
+       TP_PROTO(struct work_struct *work),
+
+       TP_ARGS(work),
+
+       TP_STRUCT__entry(
+               __field( void *,        work    )
+       ),
+
+       TP_fast_assign(
+               tp_assign(work, work)
+       ),
+
+       TP_printk("work struct %p", __entry->work)
+)
+
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,37))
+/**
+ * workqueue_queue_work - called when a work gets queued
+ * @req_cpu:   the requested cpu
+ * @cwq:       pointer to struct cpu_workqueue_struct
+ * @work:      pointer to struct work_struct
+ *
+ * This event occurs when a work is queued immediately or once a
+ * delayed work is actually queued on a workqueue (ie: once the delay
+ * has been reached).
+ */
+TRACE_EVENT(workqueue_queue_work,
+
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,9,0))
+       TP_PROTO(unsigned int req_cpu, struct pool_workqueue *pwq,
+                struct work_struct *work),
+
+       TP_ARGS(req_cpu, pwq, work),
+#else
+       TP_PROTO(unsigned int req_cpu, struct cpu_workqueue_struct *cwq,
+                struct work_struct *work),
+
+       TP_ARGS(req_cpu, cwq, work),
+#endif
+
+       TP_STRUCT__entry(
+               __field( void *,        work    )
+               __field( void *,        function)
+               __field( unsigned int,  req_cpu )
+       ),
+
+       TP_fast_assign(
+               tp_assign(work, work)
+               tp_assign(function, work->func)
+               tp_assign(req_cpu, req_cpu)
+       ),
+
+       TP_printk("work struct=%p function=%pf req_cpu=%u",
+                 __entry->work, __entry->function,
+                 __entry->req_cpu)
+)
+
+/**
+ * workqueue_activate_work - called when a work gets activated
+ * @work:      pointer to struct work_struct
+ *
+ * This event occurs when a queued work is put on the active queue,
+ * which happens immediately after queueing unless @max_active limit
+ * is reached.
+ */
+DEFINE_EVENT(workqueue_work, workqueue_activate_work,
+
+       TP_PROTO(struct work_struct *work),
+
+       TP_ARGS(work)
+)
+#endif
+
+/**
+ * workqueue_execute_start - called immediately before the workqueue callback
+ * @work:      pointer to struct work_struct
+ *
+ * Allows to track workqueue execution.
+ */
+TRACE_EVENT(workqueue_execute_start,
+
+       TP_PROTO(struct work_struct *work),
+
+       TP_ARGS(work),
+
+       TP_STRUCT__entry(
+               __field( void *,        work    )
+               __field( void *,        function)
+       ),
+
+       TP_fast_assign(
+               tp_assign(work, work)
+               tp_assign(function, work->func)
+       ),
+
+       TP_printk("work struct %p: function %pf", __entry->work, __entry->function)
+)
+
+/**
+ * workqueue_execute_end - called immediately after the workqueue callback
+ * @work:      pointer to struct work_struct
+ *
+ * Allows to track workqueue execution.
+ */
+DEFINE_EVENT(workqueue_work, workqueue_execute_end,
+
+       TP_PROTO(struct work_struct *work),
+
+       TP_ARGS(work)
+)
+
+#else
+
+DECLARE_EVENT_CLASS(workqueue,
+
+       TP_PROTO(struct task_struct *wq_thread, struct work_struct *work),
+
+       TP_ARGS(wq_thread, work),
+
+       TP_STRUCT__entry(
+               __array(char,           thread_comm,    TASK_COMM_LEN)
+               __field(pid_t,          thread_pid)
+               __field(work_func_t,    func)
+       ),
+
+       TP_fast_assign(
+               tp_memcpy(thread_comm, wq_thread->comm, TASK_COMM_LEN)
+               tp_assign(thread_pid, wq_thread->pid)
+               tp_assign(func, work->func)
+       ),
+
+       TP_printk("thread=%s:%d func=%pf", __entry->thread_comm,
+               __entry->thread_pid, __entry->func)
+)
+
+DEFINE_EVENT(workqueue, workqueue_insertion,
+
+       TP_PROTO(struct task_struct *wq_thread, struct work_struct *work),
+
+       TP_ARGS(wq_thread, work)
+)
+
+DEFINE_EVENT(workqueue, workqueue_execution,
+
+       TP_PROTO(struct task_struct *wq_thread, struct work_struct *work),
+
+       TP_ARGS(wq_thread, work)
+)
+
+/* Trace the creation of one workqueue thread on a cpu */
+TRACE_EVENT(workqueue_creation,
+
+       TP_PROTO(struct task_struct *wq_thread, int cpu),
+
+       TP_ARGS(wq_thread, cpu),
+
+       TP_STRUCT__entry(
+               __array(char,   thread_comm,    TASK_COMM_LEN)
+               __field(pid_t,  thread_pid)
+               __field(int,    cpu)
+       ),
+
+       TP_fast_assign(
+               tp_memcpy(thread_comm, wq_thread->comm, TASK_COMM_LEN)
+               tp_assign(thread_pid, wq_thread->pid)
+               tp_assign(cpu, cpu)
+       ),
+
+       TP_printk("thread=%s:%d cpu=%d", __entry->thread_comm,
+               __entry->thread_pid, __entry->cpu)
+)
+
+TRACE_EVENT(workqueue_destruction,
+
+       TP_PROTO(struct task_struct *wq_thread),
+
+       TP_ARGS(wq_thread),
+
+       TP_STRUCT__entry(
+               __array(char,   thread_comm,    TASK_COMM_LEN)
+               __field(pid_t,  thread_pid)
+       ),
+
+       TP_fast_assign(
+               tp_memcpy(thread_comm, wq_thread->comm, TASK_COMM_LEN)
+               tp_assign(thread_pid, wq_thread->pid)
+       ),
+
+       TP_printk("thread=%s:%d", __entry->thread_comm, __entry->thread_pid)
+)
+
+#endif
+
+#endif /*  _TRACE_WORKQUEUE_H */
+
+/* This part must be outside protection */
+#include "../../../probes/define_trace.h"
diff --git a/drivers/staging/lttng/instrumentation/events/lttng-module/writeback.h b/drivers/staging/lttng/instrumentation/events/lttng-module/writeback.h
new file mode 100644 (file)
index 0000000..fd9c520
--- /dev/null
@@ -0,0 +1,617 @@
+#undef TRACE_SYSTEM
+#define TRACE_SYSTEM writeback
+
+#if !defined(_TRACE_WRITEBACK_H) || defined(TRACE_HEADER_MULTI_READ)
+#define _TRACE_WRITEBACK_H
+
+#include <linux/backing-dev.h>
+#include <linux/writeback.h>
+#include <linux/version.h>
+
+#ifndef _TRACE_WRITEBACK_DEF_
+#define _TRACE_WRITEBACK_DEF_
+static inline struct backing_dev_info *inode_to_bdi(struct inode *inode)
+{
+       struct super_block *sb = inode->i_sb;
+
+       if (strcmp(sb->s_type->name, "bdev") == 0)
+               return inode->i_mapping->backing_dev_info;
+
+       return sb->s_bdi;
+}
+#endif
+
+#define show_inode_state(state)                                        \
+       __print_flags(state, "|",                               \
+               {I_DIRTY_SYNC,          "I_DIRTY_SYNC"},        \
+               {I_DIRTY_DATASYNC,      "I_DIRTY_DATASYNC"},    \
+               {I_DIRTY_PAGES,         "I_DIRTY_PAGES"},       \
+               {I_NEW,                 "I_NEW"},               \
+               {I_WILL_FREE,           "I_WILL_FREE"},         \
+               {I_FREEING,             "I_FREEING"},           \
+               {I_CLEAR,               "I_CLEAR"},             \
+               {I_SYNC,                "I_SYNC"},              \
+               {I_REFERENCED,          "I_REFERENCED"}         \
+       )
+
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,2,0))
+#define WB_WORK_REASON                                                 \
+               {WB_REASON_BACKGROUND,          "background"},          \
+               {WB_REASON_TRY_TO_FREE_PAGES,   "try_to_free_pages"},   \
+               {WB_REASON_SYNC,                "sync"},                \
+               {WB_REASON_PERIODIC,            "periodic"},            \
+               {WB_REASON_LAPTOP_TIMER,        "laptop_timer"},        \
+               {WB_REASON_FREE_MORE_MEM,       "free_more_memory"},    \
+               {WB_REASON_FS_FREE_SPACE,       "fs_free_space"},       \
+               {WB_REASON_FORKER_THREAD,       "forker_thread"}
+#endif
+
+DECLARE_EVENT_CLASS(writeback_work_class,
+       TP_PROTO(struct backing_dev_info *bdi, struct wb_writeback_work *work),
+       TP_ARGS(bdi, work),
+       TP_STRUCT__entry(
+               __array(char, name, 32)
+       ),
+       TP_fast_assign(
+               tp_memcpy(name, dev_name(bdi->dev ? bdi->dev :
+                               default_backing_dev_info.dev), 32)
+       ),
+       TP_printk("bdi %s",
+                 __entry->name
+       )
+)
+#define DEFINE_WRITEBACK_WORK_EVENT(name) \
+DEFINE_EVENT(writeback_work_class, name, \
+       TP_PROTO(struct backing_dev_info *bdi, struct wb_writeback_work *work), \
+       TP_ARGS(bdi, work))
+DEFINE_WRITEBACK_WORK_EVENT(writeback_nothread)
+DEFINE_WRITEBACK_WORK_EVENT(writeback_queue)
+DEFINE_WRITEBACK_WORK_EVENT(writeback_exec)
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,1,0))
+DEFINE_WRITEBACK_WORK_EVENT(writeback_start)
+DEFINE_WRITEBACK_WORK_EVENT(writeback_written)
+DEFINE_WRITEBACK_WORK_EVENT(writeback_wait)
+#endif
+
+TRACE_EVENT(writeback_pages_written,
+       TP_PROTO(long pages_written),
+       TP_ARGS(pages_written),
+       TP_STRUCT__entry(
+               __field(long,           pages)
+       ),
+       TP_fast_assign(
+               tp_assign(pages, pages_written)
+       ),
+       TP_printk("%ld", __entry->pages)
+)
+
+DECLARE_EVENT_CLASS(writeback_class,
+       TP_PROTO(struct backing_dev_info *bdi),
+       TP_ARGS(bdi),
+       TP_STRUCT__entry(
+               __array(char, name, 32)
+       ),
+       TP_fast_assign(
+               tp_memcpy(name, dev_name(bdi->dev), 32)
+       ),
+       TP_printk("bdi %s",
+                 __entry->name
+       )
+)
+#define DEFINE_WRITEBACK_EVENT(name) \
+DEFINE_EVENT(writeback_class, name, \
+       TP_PROTO(struct backing_dev_info *bdi), \
+       TP_ARGS(bdi))
+
+#define DEFINE_WRITEBACK_EVENT_MAP(name, map) \
+DEFINE_EVENT_MAP(writeback_class, name, map, \
+       TP_PROTO(struct backing_dev_info *bdi), \
+       TP_ARGS(bdi))
+
+DEFINE_WRITEBACK_EVENT(writeback_nowork)
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
+DEFINE_WRITEBACK_EVENT(writeback_wake_background)
+#endif
+DEFINE_WRITEBACK_EVENT(writeback_wake_thread)
+DEFINE_WRITEBACK_EVENT(writeback_wake_forker_thread)
+DEFINE_WRITEBACK_EVENT(writeback_bdi_register)
+DEFINE_WRITEBACK_EVENT(writeback_bdi_unregister)
+DEFINE_WRITEBACK_EVENT(writeback_thread_start)
+DEFINE_WRITEBACK_EVENT(writeback_thread_stop)
+#if (LTTNG_KERNEL_RANGE(3,1,0, 3,2,0))
+DEFINE_WRITEBACK_EVENT_MAP(balance_dirty_start, writeback_balance_dirty_start)
+DEFINE_WRITEBACK_EVENT_MAP(balance_dirty_wait, writeback_balance_dirty_wait)
+
+TRACE_EVENT_MAP(balance_dirty_written,
+
+       writeback_balance_dirty_written,
+
+       TP_PROTO(struct backing_dev_info *bdi, int written),
+
+       TP_ARGS(bdi, written),
+
+       TP_STRUCT__entry(
+               __array(char,   name, 32)
+               __field(int,    written)
+       ),
+
+       TP_fast_assign(
+               tp_memcpy(name, dev_name(bdi->dev), 32)
+               tp_assign(written, written)
+       ),
+
+       TP_printk("bdi %s written %d",
+                 __entry->name,
+                 __entry->written
+       )
+)
+#endif
+
+DECLARE_EVENT_CLASS(writeback_wbc_class,
+       TP_PROTO(struct writeback_control *wbc, struct backing_dev_info *bdi),
+       TP_ARGS(wbc, bdi),
+       TP_STRUCT__entry(
+               __array(char, name, 32)
+               __field(long, nr_to_write)
+               __field(long, pages_skipped)
+               __field(int, sync_mode)
+               __field(int, for_kupdate)
+               __field(int, for_background)
+               __field(int, for_reclaim)
+               __field(int, range_cyclic)
+#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,1,0))
+               __field(int, more_io)
+               __field(unsigned long, older_than_this)
+#endif
+               __field(long, range_start)
+               __field(long, range_end)
+       ),
+
+       TP_fast_assign(
+               tp_memcpy(name, dev_name(bdi->dev), 32)
+               tp_assign(nr_to_write, wbc->nr_to_write)
+               tp_assign(pages_skipped, wbc->pages_skipped)
+               tp_assign(sync_mode, wbc->sync_mode)
+               tp_assign(for_kupdate, wbc->for_kupdate)
+               tp_assign(for_background, wbc->for_background)
+               tp_assign(for_reclaim, wbc->for_reclaim)
+               tp_assign(range_cyclic, wbc->range_cyclic)
+#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,1,0))
+               tp_assign(more_io, wbc->more_io)
+               tp_assign(older_than_this, wbc->older_than_this ?
+                                               *wbc->older_than_this : 0)
+#endif
+               tp_assign(range_start, (long)wbc->range_start)
+               tp_assign(range_end, (long)wbc->range_end)
+       ),
+
+       TP_printk("bdi %s: towrt=%ld skip=%ld mode=%d kupd=%d "
+#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,1,0))
+               "bgrd=%d reclm=%d cyclic=%d more=%d older=0x%lx "
+#else
+               "bgrd=%d reclm=%d cyclic=%d "
+#endif
+               "start=0x%lx end=0x%lx",
+               __entry->name,
+               __entry->nr_to_write,
+               __entry->pages_skipped,
+               __entry->sync_mode,
+               __entry->for_kupdate,
+               __entry->for_background,
+               __entry->for_reclaim,
+               __entry->range_cyclic,
+#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,1,0))
+               __entry->more_io,
+               __entry->older_than_this,
+#endif
+               __entry->range_start,
+               __entry->range_end)
+)
+
+#undef DEFINE_WBC_EVENT
+#define DEFINE_WBC_EVENT(name, map) \
+DEFINE_EVENT_MAP(writeback_wbc_class, name, map, \
+       TP_PROTO(struct writeback_control *wbc, struct backing_dev_info *bdi), \
+       TP_ARGS(wbc, bdi))
+#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,1,0))
+DEFINE_WBC_EVENT(wbc_writeback_start, writeback_wbc_writeback_start)
+DEFINE_WBC_EVENT(wbc_writeback_written, writeback_wbc_writeback_written)
+DEFINE_WBC_EVENT(wbc_writeback_wait, writeback_wbc_writeback_wait)
+DEFINE_WBC_EVENT(wbc_balance_dirty_start, writeback_wbc_balance_dirty_start)
+DEFINE_WBC_EVENT(wbc_balance_dirty_written, writeback_wbc_balance_dirty_written)
+DEFINE_WBC_EVENT(wbc_balance_dirty_wait, writeback_wbc_balance_dirty_wait)
+#endif
+DEFINE_WBC_EVENT(wbc_writepage, writeback_wbc_writepage)
+
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,1,0))
+TRACE_EVENT(writeback_queue_io,
+       TP_PROTO(struct bdi_writeback *wb,
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,2,0))
+                struct wb_writeback_work *work,
+#else
+                unsigned long *older_than_this,
+#endif
+                int moved),
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,2,0))
+       TP_ARGS(wb, work, moved),
+#else
+       TP_ARGS(wb, older_than_this, moved),
+#endif
+       TP_STRUCT__entry(
+               __array(char,           name, 32)
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,2,0))
+#else
+               __field(unsigned long,  older)
+               __field(long,           age)
+#endif
+               __field(int,            moved)
+       ),
+       TP_fast_assign(
+               tp_memcpy(name, dev_name(wb->bdi->dev), 32)
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,2,0))
+#else
+               tp_assign(older, older_than_this ?  *older_than_this : 0)
+               tp_assign(age, older_than_this ?
+                       (jiffies - *older_than_this) * 1000 / HZ : -1)
+#endif
+               tp_assign(moved, moved)
+       ),
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,2,0))
+       TP_printk("bdi %s: enqueue=%d",
+               __entry->name,
+               __entry->moved,
+       )
+#else
+       TP_printk("bdi %s: older=%lu age=%ld enqueue=%d",
+               __entry->name,
+               __entry->older, /* older_than_this in jiffies */
+               __entry->age,   /* older_than_this in relative milliseconds */
+               __entry->moved
+       )
+#endif
+)
+
+TRACE_EVENT_MAP(global_dirty_state,
+
+       writeback_global_dirty_state,
+
+       TP_PROTO(unsigned long background_thresh,
+                unsigned long dirty_thresh
+       ),
+
+       TP_ARGS(background_thresh,
+               dirty_thresh
+       ),
+
+       TP_STRUCT__entry(
+               __field(unsigned long,  nr_dirty)
+               __field(unsigned long,  nr_writeback)
+               __field(unsigned long,  nr_unstable)
+               __field(unsigned long,  background_thresh)
+               __field(unsigned long,  dirty_thresh)
+               __field(unsigned long,  dirty_limit)
+               __field(unsigned long,  nr_dirtied)
+               __field(unsigned long,  nr_written)
+       ),
+
+       TP_fast_assign(
+               tp_assign(nr_dirty, global_page_state(NR_FILE_DIRTY))
+               tp_assign(nr_writeback, global_page_state(NR_WRITEBACK))
+               tp_assign(nr_unstable, global_page_state(NR_UNSTABLE_NFS))
+               tp_assign(nr_dirtied, global_page_state(NR_DIRTIED))
+               tp_assign(nr_written, global_page_state(NR_WRITTEN))
+               tp_assign(background_thresh, background_thresh)
+               tp_assign(dirty_thresh, dirty_thresh)
+               tp_assign(dirty_limit, global_dirty_limit)
+       ),
+
+       TP_printk("dirty=%lu writeback=%lu unstable=%lu "
+                 "bg_thresh=%lu thresh=%lu limit=%lu "
+                 "dirtied=%lu written=%lu",
+                 __entry->nr_dirty,
+                 __entry->nr_writeback,
+                 __entry->nr_unstable,
+                 __entry->background_thresh,
+                 __entry->dirty_thresh,
+                 __entry->dirty_limit,
+                 __entry->nr_dirtied,
+                 __entry->nr_written
+       )
+)
+#endif
+
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,2,0))
+
+#define KBps(x)                        ((x) << (PAGE_SHIFT - 10))
+
+TRACE_EVENT_MAP(bdi_dirty_ratelimit,
+
+       writeback_bdi_dirty_ratelimit,
+
+       TP_PROTO(struct backing_dev_info *bdi,
+                unsigned long dirty_rate,
+                unsigned long task_ratelimit),
+
+       TP_ARGS(bdi, dirty_rate, task_ratelimit),
+
+       TP_STRUCT__entry(
+               __array(char,           bdi, 32)
+               __field(unsigned long,  write_bw)
+               __field(unsigned long,  avg_write_bw)
+               __field(unsigned long,  dirty_rate)
+               __field(unsigned long,  dirty_ratelimit)
+               __field(unsigned long,  task_ratelimit)
+               __field(unsigned long,  balanced_dirty_ratelimit)
+       ),
+
+       TP_fast_assign(
+               tp_memcpy(bdi, dev_name(bdi->dev), 32)
+               tp_assign(write_bw, KBps(bdi->write_bandwidth))
+               tp_assign(avg_write_bw, KBps(bdi->avg_write_bandwidth))
+               tp_assign(dirty_rate, KBps(dirty_rate))
+               tp_assign(dirty_ratelimit, KBps(bdi->dirty_ratelimit))
+               tp_assign(task_ratelimit, KBps(task_ratelimit))
+               tp_assign(balanced_dirty_ratelimit,
+                                       KBps(bdi->balanced_dirty_ratelimit))
+       ),
+
+       TP_printk("bdi %s: "
+                 "write_bw=%lu awrite_bw=%lu dirty_rate=%lu "
+                 "dirty_ratelimit=%lu task_ratelimit=%lu "
+                 "balanced_dirty_ratelimit=%lu",
+                 __entry->bdi,
+                 __entry->write_bw,            /* write bandwidth */
+                 __entry->avg_write_bw,        /* avg write bandwidth */
+                 __entry->dirty_rate,          /* bdi dirty rate */
+                 __entry->dirty_ratelimit,     /* base ratelimit */
+                 __entry->task_ratelimit, /* ratelimit with position control */
+                 __entry->balanced_dirty_ratelimit /* the balanced ratelimit */
+       )
+)
+
+TRACE_EVENT_MAP(balance_dirty_pages,
+
+       writeback_balance_dirty_pages,
+
+       TP_PROTO(struct backing_dev_info *bdi,
+                unsigned long thresh,
+                unsigned long bg_thresh,
+                unsigned long dirty,
+                unsigned long bdi_thresh,
+                unsigned long bdi_dirty,
+                unsigned long dirty_ratelimit,
+                unsigned long task_ratelimit,
+                unsigned long dirtied,
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,3,0))
+                unsigned long period,
+#endif
+                long pause,
+                unsigned long start_time),
+
+       TP_ARGS(bdi, thresh, bg_thresh, dirty, bdi_thresh, bdi_dirty,
+               dirty_ratelimit, task_ratelimit,
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,3,0))
+               dirtied, period, pause, start_time),
+#else
+               dirtied, pause, start_time),
+#endif
+       TP_STRUCT__entry(
+               __array(         char,  bdi, 32)
+               __field(unsigned long,  limit)
+               __field(unsigned long,  setpoint)
+               __field(unsigned long,  dirty)
+               __field(unsigned long,  bdi_setpoint)
+               __field(unsigned long,  bdi_dirty)
+               __field(unsigned long,  dirty_ratelimit)
+               __field(unsigned long,  task_ratelimit)
+               __field(unsigned int,   dirtied)
+               __field(unsigned int,   dirtied_pause)
+               __field(unsigned long,  paused)
+               __field(         long,  pause)
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,3,0))
+               __field(unsigned long,  period)
+               __field(         long,  think)
+#endif
+       ),
+
+       TP_fast_assign(
+               tp_memcpy(bdi, dev_name(bdi->dev), 32)
+               tp_assign(limit, global_dirty_limit)
+               tp_assign(setpoint,
+                       (global_dirty_limit + (thresh + bg_thresh) / 2) / 2)
+               tp_assign(dirty, dirty)
+               tp_assign(bdi_setpoint,
+                       ((global_dirty_limit + (thresh + bg_thresh) / 2) / 2) *
+                       bdi_thresh / (thresh + 1))
+               tp_assign(bdi_dirty, bdi_dirty)
+               tp_assign(dirty_ratelimit, KBps(dirty_ratelimit))
+               tp_assign(task_ratelimit, KBps(task_ratelimit))
+               tp_assign(dirtied, dirtied)
+               tp_assign(dirtied_pause, current->nr_dirtied_pause)
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,3,0))
+               tp_assign(think, current->dirty_paused_when == 0 ? 0 :
+                       (long)(jiffies - current->dirty_paused_when) * 1000/HZ)
+               tp_assign(period, period * 1000 / HZ)
+#endif
+               tp_assign(pause, pause * 1000 / HZ)
+               tp_assign(paused, (jiffies - start_time) * 1000 / HZ)
+       ),
+
+
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,3,0))
+       TP_printk("bdi %s: "
+                 "limit=%lu setpoint=%lu dirty=%lu "
+                 "bdi_setpoint=%lu bdi_dirty=%lu "
+                 "dirty_ratelimit=%lu task_ratelimit=%lu "
+                 "dirtied=%u dirtied_pause=%u "
+                 "paused=%lu pause=%ld period=%lu think=%ld",
+                 __entry->bdi,
+                 __entry->limit,
+                 __entry->setpoint,
+                 __entry->dirty,
+                 __entry->bdi_setpoint,
+                 __entry->bdi_dirty,
+                 __entry->dirty_ratelimit,
+                 __entry->task_ratelimit,
+                 __entry->dirtied,
+                 __entry->dirtied_pause,
+                 __entry->paused,      /* ms */
+                 __entry->pause,       /* ms */
+                 __entry->period,      /* ms */
+                 __entry->think        /* ms */
+         )
+#else
+       TP_printk("bdi %s: "
+                 "limit=%lu setpoint=%lu dirty=%lu "
+                 "bdi_setpoint=%lu bdi_dirty=%lu "
+                 "dirty_ratelimit=%lu task_ratelimit=%lu "
+                 "dirtied=%u dirtied_pause=%u "
+                 "paused=%lu pause=%ld",
+                 __entry->bdi,
+                 __entry->limit,
+                 __entry->setpoint,
+                 __entry->dirty,
+                 __entry->bdi_setpoint,
+                 __entry->bdi_dirty,
+                 __entry->dirty_ratelimit,
+                 __entry->task_ratelimit,
+                 __entry->dirtied,
+                 __entry->dirtied_pause,
+                 __entry->paused,      /* ms */
+                 __entry->pause        /* ms */
+         )
+#endif
+)
+#endif
+
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,5,0))
+TRACE_EVENT(writeback_sb_inodes_requeue,
+
+       TP_PROTO(struct inode *inode),
+       TP_ARGS(inode),
+
+       TP_STRUCT__entry(
+               __array(char, name, 32)
+               __field(unsigned long, ino)
+               __field(unsigned long, state)
+               __field(unsigned long, dirtied_when)
+       ),
+
+       TP_fast_assign(
+               tp_memcpy(name, dev_name(inode_to_bdi(inode)->dev), 32)
+               tp_assign(ino, inode->i_ino)
+               tp_assign(state, inode->i_state)
+               tp_assign(dirtied_when, inode->dirtied_when)
+       ),
+
+       TP_printk("bdi %s: ino=%lu state=%s dirtied_when=%lu age=%lu",
+                 __entry->name,
+                 __entry->ino,
+                 show_inode_state(__entry->state),
+                 __entry->dirtied_when,
+                 (jiffies - __entry->dirtied_when) / HZ
+       )
+)
+#endif
+
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,37))
+DECLARE_EVENT_CLASS(writeback_congest_waited_template,
+
+       TP_PROTO(unsigned int usec_timeout, unsigned int usec_delayed),
+
+       TP_ARGS(usec_timeout, usec_delayed),
+
+       TP_STRUCT__entry(
+               __field(        unsigned int,   usec_timeout    )
+               __field(        unsigned int,   usec_delayed    )
+       ),
+
+       TP_fast_assign(
+               tp_assign(usec_timeout, usec_timeout)
+               tp_assign(usec_delayed, usec_delayed)
+       ),
+
+       TP_printk("usec_timeout=%u usec_delayed=%u",
+                       __entry->usec_timeout,
+                       __entry->usec_delayed)
+)
+
+DEFINE_EVENT(writeback_congest_waited_template, writeback_congestion_wait,
+
+       TP_PROTO(unsigned int usec_timeout, unsigned int usec_delayed),
+
+       TP_ARGS(usec_timeout, usec_delayed)
+)
+
+DEFINE_EVENT(writeback_congest_waited_template, writeback_wait_iff_congested,
+
+       TP_PROTO(unsigned int usec_timeout, unsigned int usec_delayed),
+
+       TP_ARGS(usec_timeout, usec_delayed)
+)
+#endif
+
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,1,0))
+DECLARE_EVENT_CLASS(writeback_single_inode_template,
+
+       TP_PROTO(struct inode *inode,
+                struct writeback_control *wbc,
+                unsigned long nr_to_write
+       ),
+
+       TP_ARGS(inode, wbc, nr_to_write),
+
+       TP_STRUCT__entry(
+               __array(char, name, 32)
+               __field(unsigned long, ino)
+               __field(unsigned long, state)
+               __field(unsigned long, dirtied_when)
+               __field(unsigned long, writeback_index)
+               __field(long, nr_to_write)
+               __field(unsigned long, wrote)
+       ),
+
+       TP_fast_assign(
+               tp_memcpy(name, dev_name(inode_to_bdi(inode)->dev), 32)
+               tp_assign(ino, inode->i_ino)
+               tp_assign(state, inode->i_state)
+               tp_assign(dirtied_when, inode->dirtied_when)
+               tp_assign(writeback_index, inode->i_mapping->writeback_index)
+               tp_assign(nr_to_write, nr_to_write)
+               tp_assign(wrote, nr_to_write - wbc->nr_to_write)
+       ),
+
+       TP_printk("bdi %s: ino=%lu state=%s dirtied_when=%lu age=%lu "
+                 "index=%lu to_write=%ld wrote=%lu",
+                 __entry->name,
+                 __entry->ino,
+                 show_inode_state(__entry->state),
+                 __entry->dirtied_when,
+                 (jiffies - __entry->dirtied_when) / HZ,
+                 __entry->writeback_index,
+                 __entry->nr_to_write,
+                 __entry->wrote
+       )
+)
+
+#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,5,0))
+DEFINE_EVENT(writeback_single_inode_template, writeback_single_inode_requeue,
+       TP_PROTO(struct inode *inode,
+               struct writeback_control *wbc,
+               unsigned long nr_to_write),
+       TP_ARGS(inode, wbc, nr_to_write)
+)
+#endif
+
+DEFINE_EVENT(writeback_single_inode_template, writeback_single_inode,
+       TP_PROTO(struct inode *inode,
+                struct writeback_control *wbc,
+                unsigned long nr_to_write),
+       TP_ARGS(inode, wbc, nr_to_write)
+)
+#endif
+
+#endif /* _TRACE_WRITEBACK_H */
+
+/* This part must be outside protection */
+#include "../../../probes/define_trace.h"
diff --git a/drivers/staging/lttng/instrumentation/events/mainline/arch/x86/kvm/mmutrace.h b/drivers/staging/lttng/instrumentation/events/mainline/arch/x86/kvm/mmutrace.h
new file mode 100644 (file)
index 0000000..b8f6172
--- /dev/null
@@ -0,0 +1,285 @@
+#if !defined(_TRACE_KVMMMU_H) || defined(TRACE_HEADER_MULTI_READ)
+#define _TRACE_KVMMMU_H
+
+#include <linux/tracepoint.h>
+#include <linux/ftrace_event.h>
+
+#undef TRACE_SYSTEM
+#define TRACE_SYSTEM kvmmmu
+
+#define KVM_MMU_PAGE_FIELDS \
+       __field(__u64, gfn) \
+       __field(__u32, role) \
+       __field(__u32, root_count) \
+       __field(bool, unsync)
+
+#define KVM_MMU_PAGE_ASSIGN(sp)                             \
+       __entry->gfn = sp->gfn;                      \
+       __entry->role = sp->role.word;               \
+       __entry->root_count = sp->root_count;        \
+       __entry->unsync = sp->unsync;
+
+#define KVM_MMU_PAGE_PRINTK() ({                                       \
+       const char *ret = p->buffer + p->len;                           \
+       static const char *access_str[] = {                             \
+               "---", "--x", "w--", "w-x", "-u-", "-ux", "wu-", "wux"  \
+       };                                                              \
+       union kvm_mmu_page_role role;                                   \
+                                                                       \
+       role.word = __entry->role;                                      \
+                                                                       \
+       trace_seq_printf(p, "sp gfn %llx %u%s q%u%s %s%s"               \
+                        " %snxe root %u %s%c",                         \
+                        __entry->gfn, role.level,                      \
+                        role.cr4_pae ? " pae" : "",                    \
+                        role.quadrant,                                 \
+                        role.direct ? " direct" : "",                  \
+                        access_str[role.access],                       \
+                        role.invalid ? " invalid" : "",                \
+                        role.nxe ? "" : "!",                           \
+                        __entry->root_count,                           \
+                        __entry->unsync ? "unsync" : "sync", 0);       \
+       ret;                                                            \
+               })
+
+#define kvm_mmu_trace_pferr_flags       \
+       { PFERR_PRESENT_MASK, "P" },    \
+       { PFERR_WRITE_MASK, "W" },      \
+       { PFERR_USER_MASK, "U" },       \
+       { PFERR_RSVD_MASK, "RSVD" },    \
+       { PFERR_FETCH_MASK, "F" }
+
+/*
+ * A pagetable walk has started
+ */
+TRACE_EVENT(
+       kvm_mmu_pagetable_walk,
+       TP_PROTO(u64 addr, u32 pferr),
+       TP_ARGS(addr, pferr),
+
+       TP_STRUCT__entry(
+               __field(__u64, addr)
+               __field(__u32, pferr)
+       ),
+
+       TP_fast_assign(
+               __entry->addr = addr;
+               __entry->pferr = pferr;
+       ),
+
+       TP_printk("addr %llx pferr %x %s", __entry->addr, __entry->pferr,
+                 __print_flags(__entry->pferr, "|", kvm_mmu_trace_pferr_flags))
+);
+
+
+/* We just walked a paging element */
+TRACE_EVENT(
+       kvm_mmu_paging_element,
+       TP_PROTO(u64 pte, int level),
+       TP_ARGS(pte, level),
+
+       TP_STRUCT__entry(
+               __field(__u64, pte)
+               __field(__u32, level)
+               ),
+
+       TP_fast_assign(
+               __entry->pte = pte;
+               __entry->level = level;
+               ),
+
+       TP_printk("pte %llx level %u", __entry->pte, __entry->level)
+);
+
+DECLARE_EVENT_CLASS(kvm_mmu_set_bit_class,
+
+       TP_PROTO(unsigned long table_gfn, unsigned index, unsigned size),
+
+       TP_ARGS(table_gfn, index, size),
+
+       TP_STRUCT__entry(
+               __field(__u64, gpa)
+       ),
+
+       TP_fast_assign(
+               __entry->gpa = ((u64)table_gfn << PAGE_SHIFT)
+                               + index * size;
+               ),
+
+       TP_printk("gpa %llx", __entry->gpa)
+);
+
+/* We set a pte accessed bit */
+DEFINE_EVENT(kvm_mmu_set_bit_class, kvm_mmu_set_accessed_bit,
+
+       TP_PROTO(unsigned long table_gfn, unsigned index, unsigned size),
+
+       TP_ARGS(table_gfn, index, size)
+);
+
+/* We set a pte dirty bit */
+DEFINE_EVENT(kvm_mmu_set_bit_class, kvm_mmu_set_dirty_bit,
+
+       TP_PROTO(unsigned long table_gfn, unsigned index, unsigned size),
+
+       TP_ARGS(table_gfn, index, size)
+);
+
+TRACE_EVENT(
+       kvm_mmu_walker_error,
+       TP_PROTO(u32 pferr),
+       TP_ARGS(pferr),
+
+       TP_STRUCT__entry(
+               __field(__u32, pferr)
+               ),
+
+       TP_fast_assign(
+               __entry->pferr = pferr;
+               ),
+
+       TP_printk("pferr %x %s", __entry->pferr,
+                 __print_flags(__entry->pferr, "|", kvm_mmu_trace_pferr_flags))
+);
+
+TRACE_EVENT(
+       kvm_mmu_get_page,
+       TP_PROTO(struct kvm_mmu_page *sp, bool created),
+       TP_ARGS(sp, created),
+
+       TP_STRUCT__entry(
+               KVM_MMU_PAGE_FIELDS
+               __field(bool, created)
+               ),
+
+       TP_fast_assign(
+               KVM_MMU_PAGE_ASSIGN(sp)
+               __entry->created = created;
+               ),
+
+       TP_printk("%s %s", KVM_MMU_PAGE_PRINTK(),
+                 __entry->created ? "new" : "existing")
+);
+
+DECLARE_EVENT_CLASS(kvm_mmu_page_class,
+
+       TP_PROTO(struct kvm_mmu_page *sp),
+       TP_ARGS(sp),
+
+       TP_STRUCT__entry(
+               KVM_MMU_PAGE_FIELDS
+       ),
+
+       TP_fast_assign(
+               KVM_MMU_PAGE_ASSIGN(sp)
+       ),
+
+       TP_printk("%s", KVM_MMU_PAGE_PRINTK())
+);
+
+DEFINE_EVENT(kvm_mmu_page_class, kvm_mmu_sync_page,
+       TP_PROTO(struct kvm_mmu_page *sp),
+
+       TP_ARGS(sp)
+);
+
+DEFINE_EVENT(kvm_mmu_page_class, kvm_mmu_unsync_page,
+       TP_PROTO(struct kvm_mmu_page *sp),
+
+       TP_ARGS(sp)
+);
+
+DEFINE_EVENT(kvm_mmu_page_class, kvm_mmu_prepare_zap_page,
+       TP_PROTO(struct kvm_mmu_page *sp),
+
+       TP_ARGS(sp)
+);
+
+TRACE_EVENT(
+       mark_mmio_spte,
+       TP_PROTO(u64 *sptep, gfn_t gfn, unsigned access),
+       TP_ARGS(sptep, gfn, access),
+
+       TP_STRUCT__entry(
+               __field(void *, sptep)
+               __field(gfn_t, gfn)
+               __field(unsigned, access)
+       ),
+
+       TP_fast_assign(
+               __entry->sptep = sptep;
+               __entry->gfn = gfn;
+               __entry->access = access;
+       ),
+
+       TP_printk("sptep:%p gfn %llx access %x", __entry->sptep, __entry->gfn,
+                 __entry->access)
+);
+
+TRACE_EVENT(
+       handle_mmio_page_fault,
+       TP_PROTO(u64 addr, gfn_t gfn, unsigned access),
+       TP_ARGS(addr, gfn, access),
+
+       TP_STRUCT__entry(
+               __field(u64, addr)
+               __field(gfn_t, gfn)
+               __field(unsigned, access)
+       ),
+
+       TP_fast_assign(
+               __entry->addr = addr;
+               __entry->gfn = gfn;
+               __entry->access = access;
+       ),
+
+       TP_printk("addr:%llx gfn %llx access %x", __entry->addr, __entry->gfn,
+                 __entry->access)
+);
+
+#define __spte_satisfied(__spte)                               \
+       (__entry->retry && is_writable_pte(__entry->__spte))
+
+TRACE_EVENT(
+       fast_page_fault,
+       TP_PROTO(struct kvm_vcpu *vcpu, gva_t gva, u32 error_code,
+                u64 *sptep, u64 old_spte, bool retry),
+       TP_ARGS(vcpu, gva, error_code, sptep, old_spte, retry),
+
+       TP_STRUCT__entry(
+               __field(int, vcpu_id)
+               __field(gva_t, gva)
+               __field(u32, error_code)
+               __field(u64 *, sptep)
+               __field(u64, old_spte)
+               __field(u64, new_spte)
+               __field(bool, retry)
+       ),
+
+       TP_fast_assign(
+               __entry->vcpu_id = vcpu->vcpu_id;
+               __entry->gva = gva;
+               __entry->error_code = error_code;
+               __entry->sptep = sptep;
+               __entry->old_spte = old_spte;
+               __entry->new_spte = *sptep;
+               __entry->retry = retry;
+       ),
+
+       TP_printk("vcpu %d gva %lx error_code %s sptep %p old %#llx"
+                 " new %llx spurious %d fixed %d", __entry->vcpu_id,
+                 __entry->gva, __print_flags(__entry->error_code, "|",
+                 kvm_mmu_trace_pferr_flags), __entry->sptep,
+                 __entry->old_spte, __entry->new_spte,
+                 __spte_satisfied(old_spte), __spte_satisfied(new_spte)
+       )
+);
+#endif /* _TRACE_KVMMMU_H */
+
+#undef TRACE_INCLUDE_PATH
+#define TRACE_INCLUDE_PATH .
+#undef TRACE_INCLUDE_FILE
+#define TRACE_INCLUDE_FILE mmutrace
+
+/* This part must be outside protection */
+#include <trace/define_trace.h>
diff --git a/drivers/staging/lttng/instrumentation/events/mainline/arch/x86/kvm/trace.h b/drivers/staging/lttng/instrumentation/events/mainline/arch/x86/kvm/trace.h
new file mode 100644 (file)
index 0000000..fe5e00e
--- /dev/null
@@ -0,0 +1,828 @@
+#if !defined(_TRACE_KVM_H) || defined(TRACE_HEADER_MULTI_READ)
+#define _TRACE_KVM_H
+
+#include <linux/tracepoint.h>
+#include <asm/vmx.h>
+#include <asm/svm.h>
+#include <asm/clocksource.h>
+
+#undef TRACE_SYSTEM
+#define TRACE_SYSTEM kvm
+
+/*
+ * Tracepoint for guest mode entry.
+ */
+TRACE_EVENT(kvm_entry,
+       TP_PROTO(unsigned int vcpu_id),
+       TP_ARGS(vcpu_id),
+
+       TP_STRUCT__entry(
+               __field(        unsigned int,   vcpu_id         )
+       ),
+
+       TP_fast_assign(
+               __entry->vcpu_id        = vcpu_id;
+       ),
+
+       TP_printk("vcpu %u", __entry->vcpu_id)
+);
+
+/*
+ * Tracepoint for hypercall.
+ */
+TRACE_EVENT(kvm_hypercall,
+       TP_PROTO(unsigned long nr, unsigned long a0, unsigned long a1,
+                unsigned long a2, unsigned long a3),
+       TP_ARGS(nr, a0, a1, a2, a3),
+
+       TP_STRUCT__entry(
+               __field(        unsigned long,  nr              )
+               __field(        unsigned long,  a0              )
+               __field(        unsigned long,  a1              )
+               __field(        unsigned long,  a2              )
+               __field(        unsigned long,  a3              )
+       ),
+
+       TP_fast_assign(
+               __entry->nr             = nr;
+               __entry->a0             = a0;
+               __entry->a1             = a1;
+               __entry->a2             = a2;
+               __entry->a3             = a3;
+       ),
+
+       TP_printk("nr 0x%lx a0 0x%lx a1 0x%lx a2 0x%lx a3 0x%lx",
+                __entry->nr, __entry->a0, __entry->a1,  __entry->a2,
+                __entry->a3)
+);
+
+/*
+ * Tracepoint for hypercall.
+ */
+TRACE_EVENT(kvm_hv_hypercall,
+       TP_PROTO(__u16 code, bool fast, __u16 rep_cnt, __u16 rep_idx,
+                __u64 ingpa, __u64 outgpa),
+       TP_ARGS(code, fast, rep_cnt, rep_idx, ingpa, outgpa),
+
+       TP_STRUCT__entry(
+               __field(        __u16,          rep_cnt         )
+               __field(        __u16,          rep_idx         )
+               __field(        __u64,          ingpa           )
+               __field(        __u64,          outgpa          )
+               __field(        __u16,          code            )
+               __field(        bool,           fast            )
+       ),
+
+       TP_fast_assign(
+               __entry->rep_cnt        = rep_cnt;
+               __entry->rep_idx        = rep_idx;
+               __entry->ingpa          = ingpa;
+               __entry->outgpa         = outgpa;
+               __entry->code           = code;
+               __entry->fast           = fast;
+       ),
+
+       TP_printk("code 0x%x %s cnt 0x%x idx 0x%x in 0x%llx out 0x%llx",
+                 __entry->code, __entry->fast ? "fast" : "slow",
+                 __entry->rep_cnt, __entry->rep_idx,  __entry->ingpa,
+                 __entry->outgpa)
+);
+
+/*
+ * Tracepoint for PIO.
+ */
+TRACE_EVENT(kvm_pio,
+       TP_PROTO(unsigned int rw, unsigned int port, unsigned int size,
+                unsigned int count),
+       TP_ARGS(rw, port, size, count),
+
+       TP_STRUCT__entry(
+               __field(        unsigned int,   rw              )
+               __field(        unsigned int,   port            )
+               __field(        unsigned int,   size            )
+               __field(        unsigned int,   count           )
+       ),
+
+       TP_fast_assign(
+               __entry->rw             = rw;
+               __entry->port           = port;
+               __entry->size           = size;
+               __entry->count          = count;
+       ),
+
+       TP_printk("pio_%s at 0x%x size %d count %d",
+                 __entry->rw ? "write" : "read",
+                 __entry->port, __entry->size, __entry->count)
+);
+
+/*
+ * Tracepoint for cpuid.
+ */
+TRACE_EVENT(kvm_cpuid,
+       TP_PROTO(unsigned int function, unsigned long rax, unsigned long rbx,
+                unsigned long rcx, unsigned long rdx),
+       TP_ARGS(function, rax, rbx, rcx, rdx),
+
+       TP_STRUCT__entry(
+               __field(        unsigned int,   function        )
+               __field(        unsigned long,  rax             )
+               __field(        unsigned long,  rbx             )
+               __field(        unsigned long,  rcx             )
+               __field(        unsigned long,  rdx             )
+       ),
+
+       TP_fast_assign(
+               __entry->function       = function;
+               __entry->rax            = rax;
+               __entry->rbx            = rbx;
+               __entry->rcx            = rcx;
+               __entry->rdx            = rdx;
+       ),
+
+       TP_printk("func %x rax %lx rbx %lx rcx %lx rdx %lx",
+                 __entry->function, __entry->rax,
+                 __entry->rbx, __entry->rcx, __entry->rdx)
+);
+
+#define AREG(x) { APIC_##x, "APIC_" #x }
+
+#define kvm_trace_symbol_apic                                              \
+       AREG(ID), AREG(LVR), AREG(TASKPRI), AREG(ARBPRI), AREG(PROCPRI),    \
+       AREG(EOI), AREG(RRR), AREG(LDR), AREG(DFR), AREG(SPIV), AREG(ISR),  \
+       AREG(TMR), AREG(IRR), AREG(ESR), AREG(ICR), AREG(ICR2), AREG(LVTT), \
+       AREG(LVTTHMR), AREG(LVTPC), AREG(LVT0), AREG(LVT1), AREG(LVTERR),   \
+       AREG(TMICT), AREG(TMCCT), AREG(TDCR), AREG(SELF_IPI), AREG(EFEAT),  \
+       AREG(ECTRL)
+/*
+ * Tracepoint for apic access.
+ */
+TRACE_EVENT(kvm_apic,
+       TP_PROTO(unsigned int rw, unsigned int reg, unsigned int val),
+       TP_ARGS(rw, reg, val),
+
+       TP_STRUCT__entry(
+               __field(        unsigned int,   rw              )
+               __field(        unsigned int,   reg             )
+               __field(        unsigned int,   val             )
+       ),
+
+       TP_fast_assign(
+               __entry->rw             = rw;
+               __entry->reg            = reg;
+               __entry->val            = val;
+       ),
+
+       TP_printk("apic_%s %s = 0x%x",
+                 __entry->rw ? "write" : "read",
+                 __print_symbolic(__entry->reg, kvm_trace_symbol_apic),
+                 __entry->val)
+);
+
+#define trace_kvm_apic_read(reg, val)          trace_kvm_apic(0, reg, val)
+#define trace_kvm_apic_write(reg, val)         trace_kvm_apic(1, reg, val)
+
+#define KVM_ISA_VMX   1
+#define KVM_ISA_SVM   2
+
+/*
+ * Tracepoint for kvm guest exit:
+ */
+TRACE_EVENT(kvm_exit,
+       TP_PROTO(unsigned int exit_reason, struct kvm_vcpu *vcpu, u32 isa),
+       TP_ARGS(exit_reason, vcpu, isa),
+
+       TP_STRUCT__entry(
+               __field(        unsigned int,   exit_reason     )
+               __field(        unsigned long,  guest_rip       )
+               __field(        u32,            isa             )
+               __field(        u64,            info1           )
+               __field(        u64,            info2           )
+       ),
+
+       TP_fast_assign(
+               __entry->exit_reason    = exit_reason;
+               __entry->guest_rip      = kvm_rip_read(vcpu);
+               __entry->isa            = isa;
+               kvm_x86_ops->get_exit_info(vcpu, &__entry->info1,
+                                          &__entry->info2);
+       ),
+
+       TP_printk("reason %s rip 0x%lx info %llx %llx",
+                (__entry->isa == KVM_ISA_VMX) ?
+                __print_symbolic(__entry->exit_reason, VMX_EXIT_REASONS) :
+                __print_symbolic(__entry->exit_reason, SVM_EXIT_REASONS),
+                __entry->guest_rip, __entry->info1, __entry->info2)
+);
+
+/*
+ * Tracepoint for kvm interrupt injection:
+ */
+TRACE_EVENT(kvm_inj_virq,
+       TP_PROTO(unsigned int irq),
+       TP_ARGS(irq),
+
+       TP_STRUCT__entry(
+               __field(        unsigned int,   irq             )
+       ),
+
+       TP_fast_assign(
+               __entry->irq            = irq;
+       ),
+
+       TP_printk("irq %u", __entry->irq)
+);
+
+#define EXS(x) { x##_VECTOR, "#" #x }
+
+#define kvm_trace_sym_exc                                              \
+       EXS(DE), EXS(DB), EXS(BP), EXS(OF), EXS(BR), EXS(UD), EXS(NM),  \
+       EXS(DF), EXS(TS), EXS(NP), EXS(SS), EXS(GP), EXS(PF),           \
+       EXS(MF), EXS(MC)
+
+/*
+ * Tracepoint for kvm interrupt injection:
+ */
+TRACE_EVENT(kvm_inj_exception,
+       TP_PROTO(unsigned exception, bool has_error, unsigned error_code),
+       TP_ARGS(exception, has_error, error_code),
+
+       TP_STRUCT__entry(
+               __field(        u8,     exception       )
+               __field(        u8,     has_error       )
+               __field(        u32,    error_code      )
+       ),
+
+       TP_fast_assign(
+               __entry->exception      = exception;
+               __entry->has_error      = has_error;
+               __entry->error_code     = error_code;
+       ),
+
+       TP_printk("%s (0x%x)",
+                 __print_symbolic(__entry->exception, kvm_trace_sym_exc),
+                 /* FIXME: don't print error_code if not present */
+                 __entry->has_error ? __entry->error_code : 0)
+);
+
+/*
+ * Tracepoint for page fault.
+ */
+TRACE_EVENT(kvm_page_fault,
+       TP_PROTO(unsigned long fault_address, unsigned int error_code),
+       TP_ARGS(fault_address, error_code),
+
+       TP_STRUCT__entry(
+               __field(        unsigned long,  fault_address   )
+               __field(        unsigned int,   error_code      )
+       ),
+
+       TP_fast_assign(
+               __entry->fault_address  = fault_address;
+               __entry->error_code     = error_code;
+       ),
+
+       TP_printk("address %lx error_code %x",
+                 __entry->fault_address, __entry->error_code)
+);
+
+/*
+ * Tracepoint for guest MSR access.
+ */
+TRACE_EVENT(kvm_msr,
+       TP_PROTO(unsigned write, u32 ecx, u64 data, bool exception),
+       TP_ARGS(write, ecx, data, exception),
+
+       TP_STRUCT__entry(
+               __field(        unsigned,       write           )
+               __field(        u32,            ecx             )
+               __field(        u64,            data            )
+               __field(        u8,             exception       )
+       ),
+
+       TP_fast_assign(
+               __entry->write          = write;
+               __entry->ecx            = ecx;
+               __entry->data           = data;
+               __entry->exception      = exception;
+       ),
+
+       TP_printk("msr_%s %x = 0x%llx%s",
+                 __entry->write ? "write" : "read",
+                 __entry->ecx, __entry->data,
+                 __entry->exception ? " (#GP)" : "")
+);
+
+#define trace_kvm_msr_read(ecx, data)      trace_kvm_msr(0, ecx, data, false)
+#define trace_kvm_msr_write(ecx, data)     trace_kvm_msr(1, ecx, data, false)
+#define trace_kvm_msr_read_ex(ecx)         trace_kvm_msr(0, ecx, 0, true)
+#define trace_kvm_msr_write_ex(ecx, data)  trace_kvm_msr(1, ecx, data, true)
+
+/*
+ * Tracepoint for guest CR access.
+ */
+TRACE_EVENT(kvm_cr,
+       TP_PROTO(unsigned int rw, unsigned int cr, unsigned long val),
+       TP_ARGS(rw, cr, val),
+
+       TP_STRUCT__entry(
+               __field(        unsigned int,   rw              )
+               __field(        unsigned int,   cr              )
+               __field(        unsigned long,  val             )
+       ),
+
+       TP_fast_assign(
+               __entry->rw             = rw;
+               __entry->cr             = cr;
+               __entry->val            = val;
+       ),
+
+       TP_printk("cr_%s %x = 0x%lx",
+                 __entry->rw ? "write" : "read",
+                 __entry->cr, __entry->val)
+);
+
+#define trace_kvm_cr_read(cr, val)             trace_kvm_cr(0, cr, val)
+#define trace_kvm_cr_write(cr, val)            trace_kvm_cr(1, cr, val)
+
+TRACE_EVENT(kvm_pic_set_irq,
+           TP_PROTO(__u8 chip, __u8 pin, __u8 elcr, __u8 imr, bool coalesced),
+           TP_ARGS(chip, pin, elcr, imr, coalesced),
+
+       TP_STRUCT__entry(
+               __field(        __u8,           chip            )
+               __field(        __u8,           pin             )
+               __field(        __u8,           elcr            )
+               __field(        __u8,           imr             )
+               __field(        bool,           coalesced       )
+       ),
+
+       TP_fast_assign(
+               __entry->chip           = chip;
+               __entry->pin            = pin;
+               __entry->elcr           = elcr;
+               __entry->imr            = imr;
+               __entry->coalesced      = coalesced;
+       ),
+
+       TP_printk("chip %u pin %u (%s%s)%s",
+                 __entry->chip, __entry->pin,
+                 (__entry->elcr & (1 << __entry->pin)) ? "level":"edge",
+                 (__entry->imr & (1 << __entry->pin)) ? "|masked":"",
+                 __entry->coalesced ? " (coalesced)" : "")
+);
+
+#define kvm_apic_dst_shorthand         \
+       {0x0, "dst"},                   \
+       {0x1, "self"},                  \
+       {0x2, "all"},                   \
+       {0x3, "all-but-self"}
+
+TRACE_EVENT(kvm_apic_ipi,
+           TP_PROTO(__u32 icr_low, __u32 dest_id),
+           TP_ARGS(icr_low, dest_id),
+
+       TP_STRUCT__entry(
+               __field(        __u32,          icr_low         )
+               __field(        __u32,          dest_id         )
+       ),
+
+       TP_fast_assign(
+               __entry->icr_low        = icr_low;
+               __entry->dest_id        = dest_id;
+       ),
+
+       TP_printk("dst %x vec %u (%s|%s|%s|%s|%s)",
+                 __entry->dest_id, (u8)__entry->icr_low,
+                 __print_symbolic((__entry->icr_low >> 8 & 0x7),
+                                  kvm_deliver_mode),
+                 (__entry->icr_low & (1<<11)) ? "logical" : "physical",
+                 (__entry->icr_low & (1<<14)) ? "assert" : "de-assert",
+                 (__entry->icr_low & (1<<15)) ? "level" : "edge",
+                 __print_symbolic((__entry->icr_low >> 18 & 0x3),
+                                  kvm_apic_dst_shorthand))
+);
+
+TRACE_EVENT(kvm_apic_accept_irq,
+           TP_PROTO(__u32 apicid, __u16 dm, __u8 tm, __u8 vec, bool coalesced),
+           TP_ARGS(apicid, dm, tm, vec, coalesced),
+
+       TP_STRUCT__entry(
+               __field(        __u32,          apicid          )
+               __field(        __u16,          dm              )
+               __field(        __u8,           tm              )
+               __field(        __u8,           vec             )
+               __field(        bool,           coalesced       )
+       ),
+
+       TP_fast_assign(
+               __entry->apicid         = apicid;
+               __entry->dm             = dm;
+               __entry->tm             = tm;
+               __entry->vec            = vec;
+               __entry->coalesced      = coalesced;
+       ),
+
+       TP_printk("apicid %x vec %u (%s|%s)%s",
+                 __entry->apicid, __entry->vec,
+                 __print_symbolic((__entry->dm >> 8 & 0x7), kvm_deliver_mode),
+                 __entry->tm ? "level" : "edge",
+                 __entry->coalesced ? " (coalesced)" : "")
+);
+
+TRACE_EVENT(kvm_eoi,
+           TP_PROTO(struct kvm_lapic *apic, int vector),
+           TP_ARGS(apic, vector),
+
+       TP_STRUCT__entry(
+               __field(        __u32,          apicid          )
+               __field(        int,            vector          )
+       ),
+
+       TP_fast_assign(
+               __entry->apicid         = apic->vcpu->vcpu_id;
+               __entry->vector         = vector;
+       ),
+
+       TP_printk("apicid %x vector %d", __entry->apicid, __entry->vector)
+);
+
+TRACE_EVENT(kvm_pv_eoi,
+           TP_PROTO(struct kvm_lapic *apic, int vector),
+           TP_ARGS(apic, vector),
+
+       TP_STRUCT__entry(
+               __field(        __u32,          apicid          )
+               __field(        int,            vector          )
+       ),
+
+       TP_fast_assign(
+               __entry->apicid         = apic->vcpu->vcpu_id;
+               __entry->vector         = vector;
+       ),
+
+       TP_printk("apicid %x vector %d", __entry->apicid, __entry->vector)
+);
+
+/*
+ * Tracepoint for nested VMRUN
+ */
+TRACE_EVENT(kvm_nested_vmrun,
+           TP_PROTO(__u64 rip, __u64 vmcb, __u64 nested_rip, __u32 int_ctl,
+                    __u32 event_inj, bool npt),
+           TP_ARGS(rip, vmcb, nested_rip, int_ctl, event_inj, npt),
+
+       TP_STRUCT__entry(
+               __field(        __u64,          rip             )
+               __field(        __u64,          vmcb            )
+               __field(        __u64,          nested_rip      )
+               __field(        __u32,          int_ctl         )
+               __field(        __u32,          event_inj       )
+               __field(        bool,           npt             )
+       ),
+
+       TP_fast_assign(
+               __entry->rip            = rip;
+               __entry->vmcb           = vmcb;
+               __entry->nested_rip     = nested_rip;
+               __entry->int_ctl        = int_ctl;
+               __entry->event_inj      = event_inj;
+               __entry->npt            = npt;
+       ),
+
+       TP_printk("rip: 0x%016llx vmcb: 0x%016llx nrip: 0x%016llx int_ctl: 0x%08x "
+                 "event_inj: 0x%08x npt: %s",
+               __entry->rip, __entry->vmcb, __entry->nested_rip,
+               __entry->int_ctl, __entry->event_inj,
+               __entry->npt ? "on" : "off")
+);
+
+TRACE_EVENT(kvm_nested_intercepts,
+           TP_PROTO(__u16 cr_read, __u16 cr_write, __u32 exceptions, __u64 intercept),
+           TP_ARGS(cr_read, cr_write, exceptions, intercept),
+
+       TP_STRUCT__entry(
+               __field(        __u16,          cr_read         )
+               __field(        __u16,          cr_write        )
+               __field(        __u32,          exceptions      )
+               __field(        __u64,          intercept       )
+       ),
+
+       TP_fast_assign(
+               __entry->cr_read        = cr_read;
+               __entry->cr_write       = cr_write;
+               __entry->exceptions     = exceptions;
+               __entry->intercept      = intercept;
+       ),
+
+       TP_printk("cr_read: %04x cr_write: %04x excp: %08x intercept: %016llx",
+               __entry->cr_read, __entry->cr_write, __entry->exceptions,
+               __entry->intercept)
+);
+/*
+ * Tracepoint for #VMEXIT while nested
+ */
+TRACE_EVENT(kvm_nested_vmexit,
+           TP_PROTO(__u64 rip, __u32 exit_code,
+                    __u64 exit_info1, __u64 exit_info2,
+                    __u32 exit_int_info, __u32 exit_int_info_err, __u32 isa),
+           TP_ARGS(rip, exit_code, exit_info1, exit_info2,
+                   exit_int_info, exit_int_info_err, isa),
+
+       TP_STRUCT__entry(
+               __field(        __u64,          rip                     )
+               __field(        __u32,          exit_code               )
+               __field(        __u64,          exit_info1              )
+               __field(        __u64,          exit_info2              )
+               __field(        __u32,          exit_int_info           )
+               __field(        __u32,          exit_int_info_err       )
+               __field(        __u32,          isa                     )
+       ),
+
+       TP_fast_assign(
+               __entry->rip                    = rip;
+               __entry->exit_code              = exit_code;
+               __entry->exit_info1             = exit_info1;
+               __entry->exit_info2             = exit_info2;
+               __entry->exit_int_info          = exit_int_info;
+               __entry->exit_int_info_err      = exit_int_info_err;
+               __entry->isa                    = isa;
+       ),
+       TP_printk("rip: 0x%016llx reason: %s ext_inf1: 0x%016llx "
+                 "ext_inf2: 0x%016llx ext_int: 0x%08x ext_int_err: 0x%08x",
+                 __entry->rip,
+                (__entry->isa == KVM_ISA_VMX) ?
+                __print_symbolic(__entry->exit_code, VMX_EXIT_REASONS) :
+                __print_symbolic(__entry->exit_code, SVM_EXIT_REASONS),
+                 __entry->exit_info1, __entry->exit_info2,
+                 __entry->exit_int_info, __entry->exit_int_info_err)
+);
+
+/*
+ * Tracepoint for #VMEXIT reinjected to the guest
+ */
+TRACE_EVENT(kvm_nested_vmexit_inject,
+           TP_PROTO(__u32 exit_code,
+                    __u64 exit_info1, __u64 exit_info2,
+                    __u32 exit_int_info, __u32 exit_int_info_err, __u32 isa),
+           TP_ARGS(exit_code, exit_info1, exit_info2,
+                   exit_int_info, exit_int_info_err, isa),
+
+       TP_STRUCT__entry(
+               __field(        __u32,          exit_code               )
+               __field(        __u64,          exit_info1              )
+               __field(        __u64,          exit_info2              )
+               __field(        __u32,          exit_int_info           )
+               __field(        __u32,          exit_int_info_err       )
+               __field(        __u32,          isa                     )
+       ),
+
+       TP_fast_assign(
+               __entry->exit_code              = exit_code;
+               __entry->exit_info1             = exit_info1;
+               __entry->exit_info2             = exit_info2;
+               __entry->exit_int_info          = exit_int_info;
+               __entry->exit_int_info_err      = exit_int_info_err;
+               __entry->isa                    = isa;
+       ),
+
+       TP_printk("reason: %s ext_inf1: 0x%016llx "
+                 "ext_inf2: 0x%016llx ext_int: 0x%08x ext_int_err: 0x%08x",
+                (__entry->isa == KVM_ISA_VMX) ?
+                __print_symbolic(__entry->exit_code, VMX_EXIT_REASONS) :
+                __print_symbolic(__entry->exit_code, SVM_EXIT_REASONS),
+               __entry->exit_info1, __entry->exit_info2,
+               __entry->exit_int_info, __entry->exit_int_info_err)
+);
+
+/*
+ * Tracepoint for nested #vmexit because of interrupt pending
+ */
+TRACE_EVENT(kvm_nested_intr_vmexit,
+           TP_PROTO(__u64 rip),
+           TP_ARGS(rip),
+
+       TP_STRUCT__entry(
+               __field(        __u64,  rip     )
+       ),
+
+       TP_fast_assign(
+               __entry->rip    =       rip
+       ),
+
+       TP_printk("rip: 0x%016llx", __entry->rip)
+);
+
+/*
+ * Tracepoint for nested #vmexit because of interrupt pending
+ */
+TRACE_EVENT(kvm_invlpga,
+           TP_PROTO(__u64 rip, int asid, u64 address),
+           TP_ARGS(rip, asid, address),
+
+       TP_STRUCT__entry(
+               __field(        __u64,  rip     )
+               __field(        int,    asid    )
+               __field(        __u64,  address )
+       ),
+
+       TP_fast_assign(
+               __entry->rip            =       rip;
+               __entry->asid           =       asid;
+               __entry->address        =       address;
+       ),
+
+       TP_printk("rip: 0x%016llx asid: %d address: 0x%016llx",
+                 __entry->rip, __entry->asid, __entry->address)
+);
+
+/*
+ * Tracepoint for nested #vmexit because of interrupt pending
+ */
+TRACE_EVENT(kvm_skinit,
+           TP_PROTO(__u64 rip, __u32 slb),
+           TP_ARGS(rip, slb),
+
+       TP_STRUCT__entry(
+               __field(        __u64,  rip     )
+               __field(        __u32,  slb     )
+       ),
+
+       TP_fast_assign(
+               __entry->rip            =       rip;
+               __entry->slb            =       slb;
+       ),
+
+       TP_printk("rip: 0x%016llx slb: 0x%08x",
+                 __entry->rip, __entry->slb)
+);
+
+#define KVM_EMUL_INSN_F_CR0_PE (1 << 0)
+#define KVM_EMUL_INSN_F_EFL_VM (1 << 1)
+#define KVM_EMUL_INSN_F_CS_D   (1 << 2)
+#define KVM_EMUL_INSN_F_CS_L   (1 << 3)
+
+#define kvm_trace_symbol_emul_flags                      \
+       { 0,                        "real" },             \
+       { KVM_EMUL_INSN_F_CR0_PE                          \
+         | KVM_EMUL_INSN_F_EFL_VM, "vm16" },             \
+       { KVM_EMUL_INSN_F_CR0_PE,   "prot16" },           \
+       { KVM_EMUL_INSN_F_CR0_PE                          \
+         | KVM_EMUL_INSN_F_CS_D,   "prot32" },           \
+       { KVM_EMUL_INSN_F_CR0_PE                          \
+         | KVM_EMUL_INSN_F_CS_L,   "prot64" }
+
+#define kei_decode_mode(mode) ({                       \
+       u8 flags = 0xff;                                \
+       switch (mode) {                                 \
+       case X86EMUL_MODE_REAL:                         \
+               flags = 0;                              \
+               break;                                  \
+       case X86EMUL_MODE_VM86:                         \
+               flags = KVM_EMUL_INSN_F_EFL_VM;         \
+               break;                                  \
+       case X86EMUL_MODE_PROT16:                       \
+               flags = KVM_EMUL_INSN_F_CR0_PE;         \
+               break;                                  \
+       case X86EMUL_MODE_PROT32:                       \
+               flags = KVM_EMUL_INSN_F_CR0_PE          \
+                       | KVM_EMUL_INSN_F_CS_D;         \
+               break;                                  \
+       case X86EMUL_MODE_PROT64:                       \
+               flags = KVM_EMUL_INSN_F_CR0_PE          \
+                       | KVM_EMUL_INSN_F_CS_L;         \
+               break;                                  \
+       }                                               \
+       flags;                                          \
+       })
+
+TRACE_EVENT(kvm_emulate_insn,
+       TP_PROTO(struct kvm_vcpu *vcpu, __u8 failed),
+       TP_ARGS(vcpu, failed),
+
+       TP_STRUCT__entry(
+               __field(    __u64, rip                       )
+               __field(    __u32, csbase                    )
+               __field(    __u8,  len                       )
+               __array(    __u8,  insn,    15               )
+               __field(    __u8,  flags                     )
+               __field(    __u8,  failed                    )
+               ),
+
+       TP_fast_assign(
+               __entry->rip = vcpu->arch.emulate_ctxt.fetch.start;
+               __entry->csbase = kvm_x86_ops->get_segment_base(vcpu, VCPU_SREG_CS);
+               __entry->len = vcpu->arch.emulate_ctxt._eip
+                              - vcpu->arch.emulate_ctxt.fetch.start;
+               memcpy(__entry->insn,
+                      vcpu->arch.emulate_ctxt.fetch.data,
+                      15);
+               __entry->flags = kei_decode_mode(vcpu->arch.emulate_ctxt.mode);
+               __entry->failed = failed;
+               ),
+
+       TP_printk("%x:%llx:%s (%s)%s",
+                 __entry->csbase, __entry->rip,
+                 __print_hex(__entry->insn, __entry->len),
+                 __print_symbolic(__entry->flags,
+                                  kvm_trace_symbol_emul_flags),
+                 __entry->failed ? " failed" : ""
+               )
+       );
+
+#define trace_kvm_emulate_insn_start(vcpu) trace_kvm_emulate_insn(vcpu, 0)
+#define trace_kvm_emulate_insn_failed(vcpu) trace_kvm_emulate_insn(vcpu, 1)
+
+TRACE_EVENT(
+       vcpu_match_mmio,
+       TP_PROTO(gva_t gva, gpa_t gpa, bool write, bool gpa_match),
+       TP_ARGS(gva, gpa, write, gpa_match),
+
+       TP_STRUCT__entry(
+               __field(gva_t, gva)
+               __field(gpa_t, gpa)
+               __field(bool, write)
+               __field(bool, gpa_match)
+               ),
+
+       TP_fast_assign(
+               __entry->gva = gva;
+               __entry->gpa = gpa;
+               __entry->write = write;
+               __entry->gpa_match = gpa_match
+               ),
+
+       TP_printk("gva %#lx gpa %#llx %s %s", __entry->gva, __entry->gpa,
+                 __entry->write ? "Write" : "Read",
+                 __entry->gpa_match ? "GPA" : "GVA")
+);
+
+#ifdef CONFIG_X86_64
+
+#define host_clocks                                    \
+       {VCLOCK_NONE, "none"},                          \
+       {VCLOCK_TSC,  "tsc"},                           \
+       {VCLOCK_HPET, "hpet"}                           \
+
+TRACE_EVENT(kvm_update_master_clock,
+       TP_PROTO(bool use_master_clock, unsigned int host_clock, bool offset_matched),
+       TP_ARGS(use_master_clock, host_clock, offset_matched),
+
+       TP_STRUCT__entry(
+               __field(                bool,   use_master_clock        )
+               __field(        unsigned int,   host_clock              )
+               __field(                bool,   offset_matched          )
+       ),
+
+       TP_fast_assign(
+               __entry->use_master_clock       = use_master_clock;
+               __entry->host_clock             = host_clock;
+               __entry->offset_matched         = offset_matched;
+       ),
+
+       TP_printk("masterclock %d hostclock %s offsetmatched %u",
+                 __entry->use_master_clock,
+                 __print_symbolic(__entry->host_clock, host_clocks),
+                 __entry->offset_matched)
+);
+
+TRACE_EVENT(kvm_track_tsc,
+       TP_PROTO(unsigned int vcpu_id, unsigned int nr_matched,
+                unsigned int online_vcpus, bool use_master_clock,
+                unsigned int host_clock),
+       TP_ARGS(vcpu_id, nr_matched, online_vcpus, use_master_clock,
+               host_clock),
+
+       TP_STRUCT__entry(
+               __field(        unsigned int,   vcpu_id                 )
+               __field(        unsigned int,   nr_vcpus_matched_tsc    )
+               __field(        unsigned int,   online_vcpus            )
+               __field(        bool,           use_master_clock        )
+               __field(        unsigned int,   host_clock              )
+       ),
+
+       TP_fast_assign(
+               __entry->vcpu_id                = vcpu_id;
+               __entry->nr_vcpus_matched_tsc   = nr_matched;
+               __entry->online_vcpus           = online_vcpus;
+               __entry->use_master_clock       = use_master_clock;
+               __entry->host_clock             = host_clock;
+       ),
+
+       TP_printk("vcpu_id %u masterclock %u offsetmatched %u nr_online %u"
+                 " hostclock %s",
+                 __entry->vcpu_id, __entry->use_master_clock,
+                 __entry->nr_vcpus_matched_tsc, __entry->online_vcpus,
+                 __print_symbolic(__entry->host_clock, host_clocks))
+);
+
+#endif /* CONFIG_X86_64 */
+
+#endif /* _TRACE_KVM_H */
+
+#undef TRACE_INCLUDE_PATH
+#define TRACE_INCLUDE_PATH arch/x86/kvm
+#undef TRACE_INCLUDE_FILE
+#define TRACE_INCLUDE_FILE trace
+
+/* This part must be outside protection */
+#include <trace/define_trace.h>
diff --git a/drivers/staging/lttng/instrumentation/events/mainline/asoc.h b/drivers/staging/lttng/instrumentation/events/mainline/asoc.h
new file mode 100644 (file)
index 0000000..5fc2dcd
--- /dev/null
@@ -0,0 +1,410 @@
+#undef TRACE_SYSTEM
+#define TRACE_SYSTEM asoc
+
+#if !defined(_TRACE_ASOC_H) || defined(TRACE_HEADER_MULTI_READ)
+#define _TRACE_ASOC_H
+
+#include <linux/ktime.h>
+#include <linux/tracepoint.h>
+
+#define DAPM_DIRECT "(direct)"
+
+struct snd_soc_jack;
+struct snd_soc_codec;
+struct snd_soc_platform;
+struct snd_soc_card;
+struct snd_soc_dapm_widget;
+
+/*
+ * Log register events
+ */
+DECLARE_EVENT_CLASS(snd_soc_reg,
+
+       TP_PROTO(struct snd_soc_codec *codec, unsigned int reg,
+                unsigned int val),
+
+       TP_ARGS(codec, reg, val),
+
+       TP_STRUCT__entry(
+               __string(       name,           codec->name     )
+               __field(        int,            id              )
+               __field(        unsigned int,   reg             )
+               __field(        unsigned int,   val             )
+       ),
+
+       TP_fast_assign(
+               __assign_str(name, codec->name);
+               __entry->id = codec->id;
+               __entry->reg = reg;
+               __entry->val = val;
+       ),
+
+       TP_printk("codec=%s.%d reg=%x val=%x", __get_str(name),
+                 (int)__entry->id, (unsigned int)__entry->reg,
+                 (unsigned int)__entry->val)
+);
+
+DEFINE_EVENT(snd_soc_reg, snd_soc_reg_write,
+
+       TP_PROTO(struct snd_soc_codec *codec, unsigned int reg,
+                unsigned int val),
+
+       TP_ARGS(codec, reg, val)
+
+);
+
+DEFINE_EVENT(snd_soc_reg, snd_soc_reg_read,
+
+       TP_PROTO(struct snd_soc_codec *codec, unsigned int reg,
+                unsigned int val),
+
+       TP_ARGS(codec, reg, val)
+
+);
+
+DECLARE_EVENT_CLASS(snd_soc_preg,
+
+       TP_PROTO(struct snd_soc_platform *platform, unsigned int reg,
+                unsigned int val),
+
+       TP_ARGS(platform, reg, val),
+
+       TP_STRUCT__entry(
+               __string(       name,           platform->name  )
+               __field(        int,            id              )
+               __field(        unsigned int,   reg             )
+               __field(        unsigned int,   val             )
+       ),
+
+       TP_fast_assign(
+               __assign_str(name, platform->name);
+               __entry->id = platform->id;
+               __entry->reg = reg;
+               __entry->val = val;
+       ),
+
+       TP_printk("platform=%s.%d reg=%x val=%x", __get_str(name),
+                 (int)__entry->id, (unsigned int)__entry->reg,
+                 (unsigned int)__entry->val)
+);
+
+DEFINE_EVENT(snd_soc_preg, snd_soc_preg_write,
+
+       TP_PROTO(struct snd_soc_platform *platform, unsigned int reg,
+                unsigned int val),
+
+       TP_ARGS(platform, reg, val)
+
+);
+
+DEFINE_EVENT(snd_soc_preg, snd_soc_preg_read,
+
+       TP_PROTO(struct snd_soc_platform *platform, unsigned int reg,
+                unsigned int val),
+
+       TP_ARGS(platform, reg, val)
+
+);
+
+DECLARE_EVENT_CLASS(snd_soc_card,
+
+       TP_PROTO(struct snd_soc_card *card, int val),
+
+       TP_ARGS(card, val),
+
+       TP_STRUCT__entry(
+               __string(       name,           card->name      )
+               __field(        int,            val             )
+       ),
+
+       TP_fast_assign(
+               __assign_str(name, card->name);
+               __entry->val = val;
+       ),
+
+       TP_printk("card=%s val=%d", __get_str(name), (int)__entry->val)
+);
+
+DEFINE_EVENT(snd_soc_card, snd_soc_bias_level_start,
+
+       TP_PROTO(struct snd_soc_card *card, int val),
+
+       TP_ARGS(card, val)
+
+);
+
+DEFINE_EVENT(snd_soc_card, snd_soc_bias_level_done,
+
+       TP_PROTO(struct snd_soc_card *card, int val),
+
+       TP_ARGS(card, val)
+
+);
+
+DECLARE_EVENT_CLASS(snd_soc_dapm_basic,
+
+       TP_PROTO(struct snd_soc_card *card),
+
+       TP_ARGS(card),
+
+       TP_STRUCT__entry(
+               __string(       name,   card->name      )
+       ),
+
+       TP_fast_assign(
+               __assign_str(name, card->name);
+       ),
+
+       TP_printk("card=%s", __get_str(name))
+);
+
+DEFINE_EVENT(snd_soc_dapm_basic, snd_soc_dapm_start,
+
+       TP_PROTO(struct snd_soc_card *card),
+
+       TP_ARGS(card)
+
+);
+
+DEFINE_EVENT(snd_soc_dapm_basic, snd_soc_dapm_done,
+
+       TP_PROTO(struct snd_soc_card *card),
+
+       TP_ARGS(card)
+
+);
+
+DECLARE_EVENT_CLASS(snd_soc_dapm_widget,
+
+       TP_PROTO(struct snd_soc_dapm_widget *w, int val),
+
+       TP_ARGS(w, val),
+
+       TP_STRUCT__entry(
+               __string(       name,   w->name         )
+               __field(        int,    val             )
+       ),
+
+       TP_fast_assign(
+               __assign_str(name, w->name);
+               __entry->val = val;
+       ),
+
+       TP_printk("widget=%s val=%d", __get_str(name),
+                 (int)__entry->val)
+);
+
+DEFINE_EVENT(snd_soc_dapm_widget, snd_soc_dapm_widget_power,
+
+       TP_PROTO(struct snd_soc_dapm_widget *w, int val),
+
+       TP_ARGS(w, val)
+
+);
+
+DEFINE_EVENT(snd_soc_dapm_widget, snd_soc_dapm_widget_event_start,
+
+       TP_PROTO(struct snd_soc_dapm_widget *w, int val),
+
+       TP_ARGS(w, val)
+
+);
+
+DEFINE_EVENT(snd_soc_dapm_widget, snd_soc_dapm_widget_event_done,
+
+       TP_PROTO(struct snd_soc_dapm_widget *w, int val),
+
+       TP_ARGS(w, val)
+
+);
+
+TRACE_EVENT(snd_soc_dapm_walk_done,
+
+       TP_PROTO(struct snd_soc_card *card),
+
+       TP_ARGS(card),
+
+       TP_STRUCT__entry(
+               __string(       name,   card->name              )
+               __field(        int,    power_checks            )
+               __field(        int,    path_checks             )
+               __field(        int,    neighbour_checks        )
+       ),
+
+       TP_fast_assign(
+               __assign_str(name, card->name);
+               __entry->power_checks = card->dapm_stats.power_checks;
+               __entry->path_checks = card->dapm_stats.path_checks;
+               __entry->neighbour_checks = card->dapm_stats.neighbour_checks;
+       ),
+
+       TP_printk("%s: checks %d power, %d path, %d neighbour",
+                 __get_str(name), (int)__entry->power_checks,
+                 (int)__entry->path_checks, (int)__entry->neighbour_checks)
+);
+
+TRACE_EVENT(snd_soc_dapm_output_path,
+
+       TP_PROTO(struct snd_soc_dapm_widget *widget,
+               struct snd_soc_dapm_path *path),
+
+       TP_ARGS(widget, path),
+
+       TP_STRUCT__entry(
+               __string(       wname,  widget->name            )
+               __string(       pname,  path->name ? path->name : DAPM_DIRECT)
+               __string(       psname, path->sink->name        )
+               __field(        int,    path_sink               )
+               __field(        int,    path_connect            )
+       ),
+
+       TP_fast_assign(
+               __assign_str(wname, widget->name);
+               __assign_str(pname, path->name ? path->name : DAPM_DIRECT);
+               __assign_str(psname, path->sink->name);
+               __entry->path_connect = path->connect;
+               __entry->path_sink = (long)path->sink;
+       ),
+
+       TP_printk("%c%s -> %s -> %s\n",
+               (int) __entry->path_sink &&
+               (int) __entry->path_connect ? '*' : ' ',
+               __get_str(wname), __get_str(pname), __get_str(psname))
+);
+
+TRACE_EVENT(snd_soc_dapm_input_path,
+
+       TP_PROTO(struct snd_soc_dapm_widget *widget,
+               struct snd_soc_dapm_path *path),
+
+       TP_ARGS(widget, path),
+
+       TP_STRUCT__entry(
+               __string(       wname,  widget->name            )
+               __string(       pname,  path->name ? path->name : DAPM_DIRECT)
+               __string(       psname, path->source->name      )
+               __field(        int,    path_source             )
+               __field(        int,    path_connect            )
+       ),
+
+       TP_fast_assign(
+               __assign_str(wname, widget->name);
+               __assign_str(pname, path->name ? path->name : DAPM_DIRECT);
+               __assign_str(psname, path->source->name);
+               __entry->path_connect = path->connect;
+               __entry->path_source = (long)path->source;
+       ),
+
+       TP_printk("%c%s <- %s <- %s\n",
+               (int) __entry->path_source &&
+               (int) __entry->path_connect ? '*' : ' ',
+               __get_str(wname), __get_str(pname), __get_str(psname))
+);
+
+TRACE_EVENT(snd_soc_dapm_connected,
+
+       TP_PROTO(int paths, int stream),
+
+       TP_ARGS(paths, stream),
+
+       TP_STRUCT__entry(
+               __field(        int,    paths           )
+               __field(        int,    stream          )
+       ),
+
+       TP_fast_assign(
+               __entry->paths = paths;
+               __entry->stream = stream;
+       ),
+
+       TP_printk("%s: found %d paths\n",
+               __entry->stream ? "capture" : "playback", __entry->paths)
+);
+
+TRACE_EVENT(snd_soc_jack_irq,
+
+       TP_PROTO(const char *name),
+
+       TP_ARGS(name),
+
+       TP_STRUCT__entry(
+               __string(       name,   name            )
+       ),
+
+       TP_fast_assign(
+               __assign_str(name, name);
+       ),
+
+       TP_printk("%s", __get_str(name))
+);
+
+TRACE_EVENT(snd_soc_jack_report,
+
+       TP_PROTO(struct snd_soc_jack *jack, int mask, int val),
+
+       TP_ARGS(jack, mask, val),
+
+       TP_STRUCT__entry(
+               __string(       name,           jack->jack->name        )
+               __field(        int,            mask                    )
+               __field(        int,            val                     )
+       ),
+
+       TP_fast_assign(
+               __assign_str(name, jack->jack->name);
+               __entry->mask = mask;
+               __entry->val = val;
+       ),
+
+       TP_printk("jack=%s %x/%x", __get_str(name), (int)__entry->val,
+                 (int)__entry->mask)
+);
+
+TRACE_EVENT(snd_soc_jack_notify,
+
+       TP_PROTO(struct snd_soc_jack *jack, int val),
+
+       TP_ARGS(jack, val),
+
+       TP_STRUCT__entry(
+               __string(       name,           jack->jack->name        )
+               __field(        int,            val                     )
+       ),
+
+       TP_fast_assign(
+               __assign_str(name, jack->jack->name);
+               __entry->val = val;
+       ),
+
+       TP_printk("jack=%s %x", __get_str(name), (int)__entry->val)
+);
+
+TRACE_EVENT(snd_soc_cache_sync,
+
+       TP_PROTO(struct snd_soc_codec *codec, const char *type,
+                const char *status),
+
+       TP_ARGS(codec, type, status),
+
+       TP_STRUCT__entry(
+               __string(       name,           codec->name     )
+               __string(       status,         status          )
+               __string(       type,           type            )
+               __field(        int,            id              )
+       ),
+
+       TP_fast_assign(
+               __assign_str(name, codec->name);
+               __assign_str(status, status);
+               __assign_str(type, type);
+               __entry->id = codec->id;
+       ),
+
+       TP_printk("codec=%s.%d type=%s status=%s", __get_str(name),
+                 (int)__entry->id, __get_str(type), __get_str(status))
+);
+
+#endif /* _TRACE_ASOC_H */
+
+/* This part must be outside protection */
+#include <trace/define_trace.h>
diff --git a/drivers/staging/lttng/instrumentation/events/mainline/block.h b/drivers/staging/lttng/instrumentation/events/mainline/block.h
new file mode 100644 (file)
index 0000000..05c5e61
--- /dev/null
@@ -0,0 +1,571 @@
+#undef TRACE_SYSTEM
+#define TRACE_SYSTEM block
+
+#if !defined(_TRACE_BLOCK_H) || defined(TRACE_HEADER_MULTI_READ)
+#define _TRACE_BLOCK_H
+
+#include <linux/blktrace_api.h>
+#include <linux/blkdev.h>
+#include <linux/tracepoint.h>
+
+#define RWBS_LEN       8
+
+DECLARE_EVENT_CLASS(block_rq_with_error,
+
+       TP_PROTO(struct request_queue *q, struct request *rq),
+
+       TP_ARGS(q, rq),
+
+       TP_STRUCT__entry(
+               __field(  dev_t,        dev                     )
+               __field(  sector_t,     sector                  )
+               __field(  unsigned int, nr_sector               )
+               __field(  int,          errors                  )
+               __array(  char,         rwbs,   RWBS_LEN        )
+               __dynamic_array( char,  cmd,    blk_cmd_buf_len(rq)     )
+       ),
+
+       TP_fast_assign(
+               __entry->dev       = rq->rq_disk ? disk_devt(rq->rq_disk) : 0;
+               __entry->sector    = (rq->cmd_type == REQ_TYPE_BLOCK_PC) ?
+                                       0 : blk_rq_pos(rq);
+               __entry->nr_sector = (rq->cmd_type == REQ_TYPE_BLOCK_PC) ?
+                                       0 : blk_rq_sectors(rq);
+               __entry->errors    = rq->errors;
+
+               blk_fill_rwbs(__entry->rwbs, rq->cmd_flags, blk_rq_bytes(rq));
+               blk_dump_cmd(__get_str(cmd), rq);
+       ),
+
+       TP_printk("%d,%d %s (%s) %llu + %u [%d]",
+                 MAJOR(__entry->dev), MINOR(__entry->dev),
+                 __entry->rwbs, __get_str(cmd),
+                 (unsigned long long)__entry->sector,
+                 __entry->nr_sector, __entry->errors)
+);
+
+/**
+ * block_rq_abort - abort block operation request
+ * @q: queue containing the block operation request
+ * @rq: block IO operation request
+ *
+ * Called immediately after pending block IO operation request @rq in
+ * queue @q is aborted. The fields in the operation request @rq
+ * can be examined to determine which device and sectors the pending
+ * operation would access.
+ */
+DEFINE_EVENT(block_rq_with_error, block_rq_abort,
+
+       TP_PROTO(struct request_queue *q, struct request *rq),
+
+       TP_ARGS(q, rq)
+);
+
+/**
+ * block_rq_requeue - place block IO request back on a queue
+ * @q: queue holding operation
+ * @rq: block IO operation request
+ *
+ * The block operation request @rq is being placed back into queue
+ * @q.  For some reason the request was not completed and needs to be
+ * put back in the queue.
+ */
+DEFINE_EVENT(block_rq_with_error, block_rq_requeue,
+
+       TP_PROTO(struct request_queue *q, struct request *rq),
+
+       TP_ARGS(q, rq)
+);
+
+/**
+ * block_rq_complete - block IO operation completed by device driver
+ * @q: queue containing the block operation request
+ * @rq: block operations request
+ *
+ * The block_rq_complete tracepoint event indicates that some portion
+ * of operation request has been completed by the device driver.  If
+ * the @rq->bio is %NULL, then there is absolutely no additional work to
+ * do for the request. If @rq->bio is non-NULL then there is
+ * additional work required to complete the request.
+ */
+DEFINE_EVENT(block_rq_with_error, block_rq_complete,
+
+       TP_PROTO(struct request_queue *q, struct request *rq),
+
+       TP_ARGS(q, rq)
+);
+
+DECLARE_EVENT_CLASS(block_rq,
+
+       TP_PROTO(struct request_queue *q, struct request *rq),
+
+       TP_ARGS(q, rq),
+
+       TP_STRUCT__entry(
+               __field(  dev_t,        dev                     )
+               __field(  sector_t,     sector                  )
+               __field(  unsigned int, nr_sector               )
+               __field(  unsigned int, bytes                   )
+               __array(  char,         rwbs,   RWBS_LEN        )
+               __array(  char,         comm,   TASK_COMM_LEN   )
+               __dynamic_array( char,  cmd,    blk_cmd_buf_len(rq)     )
+       ),
+
+       TP_fast_assign(
+               __entry->dev       = rq->rq_disk ? disk_devt(rq->rq_disk) : 0;
+               __entry->sector    = (rq->cmd_type == REQ_TYPE_BLOCK_PC) ?
+                                       0 : blk_rq_pos(rq);
+               __entry->nr_sector = (rq->cmd_type == REQ_TYPE_BLOCK_PC) ?
+                                       0 : blk_rq_sectors(rq);
+               __entry->bytes     = (rq->cmd_type == REQ_TYPE_BLOCK_PC) ?
+                                       blk_rq_bytes(rq) : 0;
+
+               blk_fill_rwbs(__entry->rwbs, rq->cmd_flags, blk_rq_bytes(rq));
+               blk_dump_cmd(__get_str(cmd), rq);
+               memcpy(__entry->comm, current->comm, TASK_COMM_LEN);
+       ),
+
+       TP_printk("%d,%d %s %u (%s) %llu + %u [%s]",
+                 MAJOR(__entry->dev), MINOR(__entry->dev),
+                 __entry->rwbs, __entry->bytes, __get_str(cmd),
+                 (unsigned long long)__entry->sector,
+                 __entry->nr_sector, __entry->comm)
+);
+
+/**
+ * block_rq_insert - insert block operation request into queue
+ * @q: target queue
+ * @rq: block IO operation request
+ *
+ * Called immediately before block operation request @rq is inserted
+ * into queue @q.  The fields in the operation request @rq struct can
+ * be examined to determine which device and sectors the pending
+ * operation would access.
+ */
+DEFINE_EVENT(block_rq, block_rq_insert,
+
+       TP_PROTO(struct request_queue *q, struct request *rq),
+
+       TP_ARGS(q, rq)
+);
+
+/**
+ * block_rq_issue - issue pending block IO request operation to device driver
+ * @q: queue holding operation
+ * @rq: block IO operation operation request
+ *
+ * Called when block operation request @rq from queue @q is sent to a
+ * device driver for processing.
+ */
+DEFINE_EVENT(block_rq, block_rq_issue,
+
+       TP_PROTO(struct request_queue *q, struct request *rq),
+
+       TP_ARGS(q, rq)
+);
+
+/**
+ * block_bio_bounce - used bounce buffer when processing block operation
+ * @q: queue holding the block operation
+ * @bio: block operation
+ *
+ * A bounce buffer was used to handle the block operation @bio in @q.
+ * This occurs when hardware limitations prevent a direct transfer of
+ * data between the @bio data memory area and the IO device.  Use of a
+ * bounce buffer requires extra copying of data and decreases
+ * performance.
+ */
+TRACE_EVENT(block_bio_bounce,
+
+       TP_PROTO(struct request_queue *q, struct bio *bio),
+
+       TP_ARGS(q, bio),
+
+       TP_STRUCT__entry(
+               __field( dev_t,         dev                     )
+               __field( sector_t,      sector                  )
+               __field( unsigned int,  nr_sector               )
+               __array( char,          rwbs,   RWBS_LEN        )
+               __array( char,          comm,   TASK_COMM_LEN   )
+       ),
+
+       TP_fast_assign(
+               __entry->dev            = bio->bi_bdev ?
+                                         bio->bi_bdev->bd_dev : 0;
+               __entry->sector         = bio->bi_sector;
+               __entry->nr_sector      = bio->bi_size >> 9;
+               blk_fill_rwbs(__entry->rwbs, bio->bi_rw, bio->bi_size);
+               memcpy(__entry->comm, current->comm, TASK_COMM_LEN);
+       ),
+
+       TP_printk("%d,%d %s %llu + %u [%s]",
+                 MAJOR(__entry->dev), MINOR(__entry->dev), __entry->rwbs,
+                 (unsigned long long)__entry->sector,
+                 __entry->nr_sector, __entry->comm)
+);
+
+/**
+ * block_bio_complete - completed all work on the block operation
+ * @q: queue holding the block operation
+ * @bio: block operation completed
+ * @error: io error value
+ *
+ * This tracepoint indicates there is no further work to do on this
+ * block IO operation @bio.
+ */
+TRACE_EVENT(block_bio_complete,
+
+       TP_PROTO(struct request_queue *q, struct bio *bio, int error),
+
+       TP_ARGS(q, bio, error),
+
+       TP_STRUCT__entry(
+               __field( dev_t,         dev             )
+               __field( sector_t,      sector          )
+               __field( unsigned,      nr_sector       )
+               __field( int,           error           )
+               __array( char,          rwbs,   RWBS_LEN)
+       ),
+
+       TP_fast_assign(
+               __entry->dev            = bio->bi_bdev->bd_dev;
+               __entry->sector         = bio->bi_sector;
+               __entry->nr_sector      = bio->bi_size >> 9;
+               __entry->error          = error;
+               blk_fill_rwbs(__entry->rwbs, bio->bi_rw, bio->bi_size);
+       ),
+
+       TP_printk("%d,%d %s %llu + %u [%d]",
+                 MAJOR(__entry->dev), MINOR(__entry->dev), __entry->rwbs,
+                 (unsigned long long)__entry->sector,
+                 __entry->nr_sector, __entry->error)
+);
+
+DECLARE_EVENT_CLASS(block_bio,
+
+       TP_PROTO(struct request_queue *q, struct bio *bio),
+
+       TP_ARGS(q, bio),
+
+       TP_STRUCT__entry(
+               __field( dev_t,         dev                     )
+               __field( sector_t,      sector                  )
+               __field( unsigned int,  nr_sector               )
+               __array( char,          rwbs,   RWBS_LEN        )
+               __array( char,          comm,   TASK_COMM_LEN   )
+       ),
+
+       TP_fast_assign(
+               __entry->dev            = bio->bi_bdev->bd_dev;
+               __entry->sector         = bio->bi_sector;
+               __entry->nr_sector      = bio->bi_size >> 9;
+               blk_fill_rwbs(__entry->rwbs, bio->bi_rw, bio->bi_size);
+               memcpy(__entry->comm, current->comm, TASK_COMM_LEN);
+       ),
+
+       TP_printk("%d,%d %s %llu + %u [%s]",
+                 MAJOR(__entry->dev), MINOR(__entry->dev), __entry->rwbs,
+                 (unsigned long long)__entry->sector,
+                 __entry->nr_sector, __entry->comm)
+);
+
+/**
+ * block_bio_backmerge - merging block operation to the end of an existing operation
+ * @q: queue holding operation
+ * @bio: new block operation to merge
+ *
+ * Merging block request @bio to the end of an existing block request
+ * in queue @q.
+ */
+DEFINE_EVENT(block_bio, block_bio_backmerge,
+
+       TP_PROTO(struct request_queue *q, struct bio *bio),
+
+       TP_ARGS(q, bio)
+);
+
+/**
+ * block_bio_frontmerge - merging block operation to the beginning of an existing operation
+ * @q: queue holding operation
+ * @bio: new block operation to merge
+ *
+ * Merging block IO operation @bio to the beginning of an existing block
+ * operation in queue @q.
+ */
+DEFINE_EVENT(block_bio, block_bio_frontmerge,
+
+       TP_PROTO(struct request_queue *q, struct bio *bio),
+
+       TP_ARGS(q, bio)
+);
+
+/**
+ * block_bio_queue - putting new block IO operation in queue
+ * @q: queue holding operation
+ * @bio: new block operation
+ *
+ * About to place the block IO operation @bio into queue @q.
+ */
+DEFINE_EVENT(block_bio, block_bio_queue,
+
+       TP_PROTO(struct request_queue *q, struct bio *bio),
+
+       TP_ARGS(q, bio)
+);
+
+DECLARE_EVENT_CLASS(block_get_rq,
+
+       TP_PROTO(struct request_queue *q, struct bio *bio, int rw),
+
+       TP_ARGS(q, bio, rw),
+
+       TP_STRUCT__entry(
+               __field( dev_t,         dev                     )
+               __field( sector_t,      sector                  )
+               __field( unsigned int,  nr_sector               )
+               __array( char,          rwbs,   RWBS_LEN        )
+               __array( char,          comm,   TASK_COMM_LEN   )
+        ),
+
+       TP_fast_assign(
+               __entry->dev            = bio ? bio->bi_bdev->bd_dev : 0;
+               __entry->sector         = bio ? bio->bi_sector : 0;
+               __entry->nr_sector      = bio ? bio->bi_size >> 9 : 0;
+               blk_fill_rwbs(__entry->rwbs,
+                             bio ? bio->bi_rw : 0, __entry->nr_sector);
+               memcpy(__entry->comm, current->comm, TASK_COMM_LEN);
+        ),
+
+       TP_printk("%d,%d %s %llu + %u [%s]",
+                 MAJOR(__entry->dev), MINOR(__entry->dev), __entry->rwbs,
+                 (unsigned long long)__entry->sector,
+                 __entry->nr_sector, __entry->comm)
+);
+
+/**
+ * block_getrq - get a free request entry in queue for block IO operations
+ * @q: queue for operations
+ * @bio: pending block IO operation
+ * @rw: low bit indicates a read (%0) or a write (%1)
+ *
+ * A request struct for queue @q has been allocated to handle the
+ * block IO operation @bio.
+ */
+DEFINE_EVENT(block_get_rq, block_getrq,
+
+       TP_PROTO(struct request_queue *q, struct bio *bio, int rw),
+
+       TP_ARGS(q, bio, rw)
+);
+
+/**
+ * block_sleeprq - waiting to get a free request entry in queue for block IO operation
+ * @q: queue for operation
+ * @bio: pending block IO operation
+ * @rw: low bit indicates a read (%0) or a write (%1)
+ *
+ * In the case where a request struct cannot be provided for queue @q
+ * the process needs to wait for an request struct to become
+ * available.  This tracepoint event is generated each time the
+ * process goes to sleep waiting for request struct become available.
+ */
+DEFINE_EVENT(block_get_rq, block_sleeprq,
+
+       TP_PROTO(struct request_queue *q, struct bio *bio, int rw),
+
+       TP_ARGS(q, bio, rw)
+);
+
+/**
+ * block_plug - keep operations requests in request queue
+ * @q: request queue to plug
+ *
+ * Plug the request queue @q.  Do not allow block operation requests
+ * to be sent to the device driver. Instead, accumulate requests in
+ * the queue to improve throughput performance of the block device.
+ */
+TRACE_EVENT(block_plug,
+
+       TP_PROTO(struct request_queue *q),
+
+       TP_ARGS(q),
+
+       TP_STRUCT__entry(
+               __array( char,          comm,   TASK_COMM_LEN   )
+       ),
+
+       TP_fast_assign(
+               memcpy(__entry->comm, current->comm, TASK_COMM_LEN);
+       ),
+
+       TP_printk("[%s]", __entry->comm)
+);
+
+DECLARE_EVENT_CLASS(block_unplug,
+
+       TP_PROTO(struct request_queue *q, unsigned int depth, bool explicit),
+
+       TP_ARGS(q, depth, explicit),
+
+       TP_STRUCT__entry(
+               __field( int,           nr_rq                   )
+               __array( char,          comm,   TASK_COMM_LEN   )
+       ),
+
+       TP_fast_assign(
+               __entry->nr_rq = depth;
+               memcpy(__entry->comm, current->comm, TASK_COMM_LEN);
+       ),
+
+       TP_printk("[%s] %d", __entry->comm, __entry->nr_rq)
+);
+
+/**
+ * block_unplug - release of operations requests in request queue
+ * @q: request queue to unplug
+ * @depth: number of requests just added to the queue
+ * @explicit: whether this was an explicit unplug, or one from schedule()
+ *
+ * Unplug request queue @q because device driver is scheduled to work
+ * on elements in the request queue.
+ */
+DEFINE_EVENT(block_unplug, block_unplug,
+
+       TP_PROTO(struct request_queue *q, unsigned int depth, bool explicit),
+
+       TP_ARGS(q, depth, explicit)
+);
+
+/**
+ * block_split - split a single bio struct into two bio structs
+ * @q: queue containing the bio
+ * @bio: block operation being split
+ * @new_sector: The starting sector for the new bio
+ *
+ * The bio request @bio in request queue @q needs to be split into two
+ * bio requests. The newly created @bio request starts at
+ * @new_sector. This split may be required due to hardware limitation
+ * such as operation crossing device boundaries in a RAID system.
+ */
+TRACE_EVENT(block_split,
+
+       TP_PROTO(struct request_queue *q, struct bio *bio,
+                unsigned int new_sector),
+
+       TP_ARGS(q, bio, new_sector),
+
+       TP_STRUCT__entry(
+               __field( dev_t,         dev                             )
+               __field( sector_t,      sector                          )
+               __field( sector_t,      new_sector                      )
+               __array( char,          rwbs,           RWBS_LEN        )
+               __array( char,          comm,           TASK_COMM_LEN   )
+       ),
+
+       TP_fast_assign(
+               __entry->dev            = bio->bi_bdev->bd_dev;
+               __entry->sector         = bio->bi_sector;
+               __entry->new_sector     = new_sector;
+               blk_fill_rwbs(__entry->rwbs, bio->bi_rw, bio->bi_size);
+               memcpy(__entry->comm, current->comm, TASK_COMM_LEN);
+       ),
+
+       TP_printk("%d,%d %s %llu / %llu [%s]",
+                 MAJOR(__entry->dev), MINOR(__entry->dev), __entry->rwbs,
+                 (unsigned long long)__entry->sector,
+                 (unsigned long long)__entry->new_sector,
+                 __entry->comm)
+);
+
+/**
+ * block_bio_remap - map request for a logical device to the raw device
+ * @q: queue holding the operation
+ * @bio: revised operation
+ * @dev: device for the operation
+ * @from: original sector for the operation
+ *
+ * An operation for a logical device has been mapped to the
+ * raw block device.
+ */
+TRACE_EVENT(block_bio_remap,
+
+       TP_PROTO(struct request_queue *q, struct bio *bio, dev_t dev,
+                sector_t from),
+
+       TP_ARGS(q, bio, dev, from),
+
+       TP_STRUCT__entry(
+               __field( dev_t,         dev             )
+               __field( sector_t,      sector          )
+               __field( unsigned int,  nr_sector       )
+               __field( dev_t,         old_dev         )
+               __field( sector_t,      old_sector      )
+               __array( char,          rwbs,   RWBS_LEN)
+       ),
+
+       TP_fast_assign(
+               __entry->dev            = bio->bi_bdev->bd_dev;
+               __entry->sector         = bio->bi_sector;
+               __entry->nr_sector      = bio->bi_size >> 9;
+               __entry->old_dev        = dev;
+               __entry->old_sector     = from;
+               blk_fill_rwbs(__entry->rwbs, bio->bi_rw, bio->bi_size);
+       ),
+
+       TP_printk("%d,%d %s %llu + %u <- (%d,%d) %llu",
+                 MAJOR(__entry->dev), MINOR(__entry->dev), __entry->rwbs,
+                 (unsigned long long)__entry->sector,
+                 __entry->nr_sector,
+                 MAJOR(__entry->old_dev), MINOR(__entry->old_dev),
+                 (unsigned long long)__entry->old_sector)
+);
+
+/**
+ * block_rq_remap - map request for a block operation request
+ * @q: queue holding the operation
+ * @rq: block IO operation request
+ * @dev: device for the operation
+ * @from: original sector for the operation
+ *
+ * The block operation request @rq in @q has been remapped.  The block
+ * operation request @rq holds the current information and @from hold
+ * the original sector.
+ */
+TRACE_EVENT(block_rq_remap,
+
+       TP_PROTO(struct request_queue *q, struct request *rq, dev_t dev,
+                sector_t from),
+
+       TP_ARGS(q, rq, dev, from),
+
+       TP_STRUCT__entry(
+               __field( dev_t,         dev             )
+               __field( sector_t,      sector          )
+               __field( unsigned int,  nr_sector       )
+               __field( dev_t,         old_dev         )
+               __field( sector_t,      old_sector      )
+               __array( char,          rwbs,   RWBS_LEN)
+       ),
+
+       TP_fast_assign(
+               __entry->dev            = disk_devt(rq->rq_disk);
+               __entry->sector         = blk_rq_pos(rq);
+               __entry->nr_sector      = blk_rq_sectors(rq);
+               __entry->old_dev        = dev;
+               __entry->old_sector     = from;
+               blk_fill_rwbs(__entry->rwbs, rq->cmd_flags, blk_rq_bytes(rq));
+       ),
+
+       TP_printk("%d,%d %s %llu + %u <- (%d,%d) %llu",
+                 MAJOR(__entry->dev), MINOR(__entry->dev), __entry->rwbs,
+                 (unsigned long long)__entry->sector,
+                 __entry->nr_sector,
+                 MAJOR(__entry->old_dev), MINOR(__entry->old_dev),
+                 (unsigned long long)__entry->old_sector)
+);
+
+#endif /* _TRACE_BLOCK_H */
+
+/* This part must be outside protection */
+#include <trace/define_trace.h>
+
diff --git a/drivers/staging/lttng/instrumentation/events/mainline/btrfs.h b/drivers/staging/lttng/instrumentation/events/mainline/btrfs.h
new file mode 100644 (file)
index 0000000..5c41993
--- /dev/null
@@ -0,0 +1,918 @@
+#undef TRACE_SYSTEM
+#define TRACE_SYSTEM btrfs
+
+#if !defined(_TRACE_BTRFS_H) || defined(TRACE_HEADER_MULTI_READ)
+#define _TRACE_BTRFS_H
+
+#include <linux/writeback.h>
+#include <linux/tracepoint.h>
+#include <trace/events/gfpflags.h>
+
+struct btrfs_root;
+struct btrfs_fs_info;
+struct btrfs_inode;
+struct extent_map;
+struct btrfs_ordered_extent;
+struct btrfs_delayed_ref_node;
+struct btrfs_delayed_tree_ref;
+struct btrfs_delayed_data_ref;
+struct btrfs_delayed_ref_head;
+struct btrfs_block_group_cache;
+struct btrfs_free_cluster;
+struct map_lookup;
+struct extent_buffer;
+
+#define show_ref_type(type)                                            \
+       __print_symbolic(type,                                          \
+               { BTRFS_TREE_BLOCK_REF_KEY,     "TREE_BLOCK_REF" },     \
+               { BTRFS_EXTENT_DATA_REF_KEY,    "EXTENT_DATA_REF" },    \
+               { BTRFS_EXTENT_REF_V0_KEY,      "EXTENT_REF_V0" },      \
+               { BTRFS_SHARED_BLOCK_REF_KEY,   "SHARED_BLOCK_REF" },   \
+               { BTRFS_SHARED_DATA_REF_KEY,    "SHARED_DATA_REF" })
+
+#define __show_root_type(obj)                                          \
+       __print_symbolic_u64(obj,                                       \
+               { BTRFS_ROOT_TREE_OBJECTID,     "ROOT_TREE"     },      \
+               { BTRFS_EXTENT_TREE_OBJECTID,   "EXTENT_TREE"   },      \
+               { BTRFS_CHUNK_TREE_OBJECTID,    "CHUNK_TREE"    },      \
+               { BTRFS_DEV_TREE_OBJECTID,      "DEV_TREE"      },      \
+               { BTRFS_FS_TREE_OBJECTID,       "FS_TREE"       },      \
+               { BTRFS_ROOT_TREE_DIR_OBJECTID, "ROOT_TREE_DIR" },      \
+               { BTRFS_CSUM_TREE_OBJECTID,     "CSUM_TREE"     },      \
+               { BTRFS_TREE_LOG_OBJECTID,      "TREE_LOG"      },      \
+               { BTRFS_TREE_RELOC_OBJECTID,    "TREE_RELOC"    },      \
+               { BTRFS_DATA_RELOC_TREE_OBJECTID, "DATA_RELOC_TREE" })
+
+#define show_root_type(obj)                                            \
+       obj, ((obj >= BTRFS_DATA_RELOC_TREE_OBJECTID) ||                \
+             (obj <= BTRFS_CSUM_TREE_OBJECTID )) ? __show_root_type(obj) : "-"
+
+#define BTRFS_GROUP_FLAGS      \
+       { BTRFS_BLOCK_GROUP_DATA,       "DATA"}, \
+       { BTRFS_BLOCK_GROUP_SYSTEM,     "SYSTEM"}, \
+       { BTRFS_BLOCK_GROUP_METADATA,   "METADATA"}, \
+       { BTRFS_BLOCK_GROUP_RAID0,      "RAID0"}, \
+       { BTRFS_BLOCK_GROUP_RAID1,      "RAID1"}, \
+       { BTRFS_BLOCK_GROUP_DUP,        "DUP"}, \
+       { BTRFS_BLOCK_GROUP_RAID10,     "RAID10"}
+
+#define BTRFS_UUID_SIZE 16
+
+TRACE_EVENT(btrfs_transaction_commit,
+
+       TP_PROTO(struct btrfs_root *root),
+
+       TP_ARGS(root),
+
+       TP_STRUCT__entry(
+               __field(        u64,  generation                )
+               __field(        u64,  root_objectid             )
+       ),
+
+       TP_fast_assign(
+               __entry->generation     = root->fs_info->generation;
+               __entry->root_objectid  = root->root_key.objectid;
+       ),
+
+       TP_printk("root = %llu(%s), gen = %llu",
+                 show_root_type(__entry->root_objectid),
+                 (unsigned long long)__entry->generation)
+);
+
+DECLARE_EVENT_CLASS(btrfs__inode,
+
+       TP_PROTO(struct inode *inode),
+
+       TP_ARGS(inode),
+
+       TP_STRUCT__entry(
+               __field(        ino_t,  ino                     )
+               __field(        blkcnt_t,  blocks               )
+               __field(        u64,  disk_i_size               )
+               __field(        u64,  generation                )
+               __field(        u64,  last_trans                )
+               __field(        u64,  logged_trans              )
+               __field(        u64,  root_objectid             )
+       ),
+
+       TP_fast_assign(
+               __entry->ino    = inode->i_ino;
+               __entry->blocks = inode->i_blocks;
+               __entry->disk_i_size  = BTRFS_I(inode)->disk_i_size;
+               __entry->generation = BTRFS_I(inode)->generation;
+               __entry->last_trans = BTRFS_I(inode)->last_trans;
+               __entry->logged_trans = BTRFS_I(inode)->logged_trans;
+               __entry->root_objectid =
+                               BTRFS_I(inode)->root->root_key.objectid;
+       ),
+
+       TP_printk("root = %llu(%s), gen = %llu, ino = %lu, blocks = %llu, "
+                 "disk_i_size = %llu, last_trans = %llu, logged_trans = %llu",
+                 show_root_type(__entry->root_objectid),
+                 (unsigned long long)__entry->generation,
+                 (unsigned long)__entry->ino,
+                 (unsigned long long)__entry->blocks,
+                 (unsigned long long)__entry->disk_i_size,
+                 (unsigned long long)__entry->last_trans,
+                 (unsigned long long)__entry->logged_trans)
+);
+
+DEFINE_EVENT(btrfs__inode, btrfs_inode_new,
+
+       TP_PROTO(struct inode *inode),
+
+       TP_ARGS(inode)
+);
+
+DEFINE_EVENT(btrfs__inode, btrfs_inode_request,
+
+       TP_PROTO(struct inode *inode),
+
+       TP_ARGS(inode)
+);
+
+DEFINE_EVENT(btrfs__inode, btrfs_inode_evict,
+
+       TP_PROTO(struct inode *inode),
+
+       TP_ARGS(inode)
+);
+
+#define __show_map_type(type)                                          \
+       __print_symbolic_u64(type,                                      \
+               { EXTENT_MAP_LAST_BYTE, "LAST_BYTE"     },              \
+               { EXTENT_MAP_HOLE,      "HOLE"          },              \
+               { EXTENT_MAP_INLINE,    "INLINE"        },              \
+               { EXTENT_MAP_DELALLOC,  "DELALLOC"      })
+
+#define show_map_type(type)                    \
+       type, (type >= EXTENT_MAP_LAST_BYTE) ? "-" :  __show_map_type(type)
+
+#define show_map_flags(flag)                                           \
+       __print_flags(flag, "|",                                        \
+               { EXTENT_FLAG_PINNED,           "PINNED"        },      \
+               { EXTENT_FLAG_COMPRESSED,       "COMPRESSED"    },      \
+               { EXTENT_FLAG_VACANCY,          "VACANCY"       },      \
+               { EXTENT_FLAG_PREALLOC,         "PREALLOC"      })
+
+TRACE_EVENT(btrfs_get_extent,
+
+       TP_PROTO(struct btrfs_root *root, struct extent_map *map),
+
+       TP_ARGS(root, map),
+
+       TP_STRUCT__entry(
+               __field(        u64,  root_objectid     )
+               __field(        u64,  start             )
+               __field(        u64,  len               )
+               __field(        u64,  orig_start        )
+               __field(        u64,  block_start       )
+               __field(        u64,  block_len         )
+               __field(        unsigned long,  flags   )
+               __field(        int,  refs              )
+               __field(        unsigned int,  compress_type    )
+       ),
+
+       TP_fast_assign(
+               __entry->root_objectid  = root->root_key.objectid;
+               __entry->start          = map->start;
+               __entry->len            = map->len;
+               __entry->orig_start     = map->orig_start;
+               __entry->block_start    = map->block_start;
+               __entry->block_len      = map->block_len;
+               __entry->flags          = map->flags;
+               __entry->refs           = atomic_read(&map->refs);
+               __entry->compress_type  = map->compress_type;
+       ),
+
+       TP_printk("root = %llu(%s), start = %llu, len = %llu, "
+                 "orig_start = %llu, block_start = %llu(%s), "
+                 "block_len = %llu, flags = %s, refs = %u, "
+                 "compress_type = %u",
+                 show_root_type(__entry->root_objectid),
+                 (unsigned long long)__entry->start,
+                 (unsigned long long)__entry->len,
+                 (unsigned long long)__entry->orig_start,
+                 show_map_type(__entry->block_start),
+                 (unsigned long long)__entry->block_len,
+                 show_map_flags(__entry->flags),
+                 __entry->refs, __entry->compress_type)
+);
+
+#define show_ordered_flags(flags)                                      \
+       __print_symbolic(flags,                                 \
+               { BTRFS_ORDERED_IO_DONE,        "IO_DONE"       },      \
+               { BTRFS_ORDERED_COMPLETE,       "COMPLETE"      },      \
+               { BTRFS_ORDERED_NOCOW,          "NOCOW"         },      \
+               { BTRFS_ORDERED_COMPRESSED,     "COMPRESSED"    },      \
+               { BTRFS_ORDERED_PREALLOC,       "PREALLOC"      },      \
+               { BTRFS_ORDERED_DIRECT,         "DIRECT"        })
+
+DECLARE_EVENT_CLASS(btrfs__ordered_extent,
+
+       TP_PROTO(struct inode *inode, struct btrfs_ordered_extent *ordered),
+
+       TP_ARGS(inode, ordered),
+
+       TP_STRUCT__entry(
+               __field(        ino_t,  ino             )
+               __field(        u64,  file_offset       )
+               __field(        u64,  start             )
+               __field(        u64,  len               )
+               __field(        u64,  disk_len          )
+               __field(        u64,  bytes_left        )
+               __field(        unsigned long,  flags   )
+               __field(        int,  compress_type     )
+               __field(        int,  refs              )
+               __field(        u64,  root_objectid     )
+       ),
+
+       TP_fast_assign(
+               __entry->ino            = inode->i_ino;
+               __entry->file_offset    = ordered->file_offset;
+               __entry->start          = ordered->start;
+               __entry->len            = ordered->len;
+               __entry->disk_len       = ordered->disk_len;
+               __entry->bytes_left     = ordered->bytes_left;
+               __entry->flags          = ordered->flags;
+               __entry->compress_type  = ordered->compress_type;
+               __entry->refs           = atomic_read(&ordered->refs);
+               __entry->root_objectid  =
+                               BTRFS_I(inode)->root->root_key.objectid;
+       ),
+
+       TP_printk("root = %llu(%s), ino = %llu, file_offset = %llu, "
+                 "start = %llu, len = %llu, disk_len = %llu, "
+                 "bytes_left = %llu, flags = %s, compress_type = %d, "
+                 "refs = %d",
+                 show_root_type(__entry->root_objectid),
+                 (unsigned long long)__entry->ino,
+                 (unsigned long long)__entry->file_offset,
+                 (unsigned long long)__entry->start,
+                 (unsigned long long)__entry->len,
+                 (unsigned long long)__entry->disk_len,
+                 (unsigned long long)__entry->bytes_left,
+                 show_ordered_flags(__entry->flags),
+                 __entry->compress_type, __entry->refs)
+);
+
+DEFINE_EVENT(btrfs__ordered_extent, btrfs_ordered_extent_add,
+
+       TP_PROTO(struct inode *inode, struct btrfs_ordered_extent *ordered),
+
+       TP_ARGS(inode, ordered)
+);
+
+DEFINE_EVENT(btrfs__ordered_extent, btrfs_ordered_extent_remove,
+
+       TP_PROTO(struct inode *inode, struct btrfs_ordered_extent *ordered),
+
+       TP_ARGS(inode, ordered)
+);
+
+DEFINE_EVENT(btrfs__ordered_extent, btrfs_ordered_extent_start,
+
+       TP_PROTO(struct inode *inode, struct btrfs_ordered_extent *ordered),
+
+       TP_ARGS(inode, ordered)
+);
+
+DEFINE_EVENT(btrfs__ordered_extent, btrfs_ordered_extent_put,
+
+       TP_PROTO(struct inode *inode, struct btrfs_ordered_extent *ordered),
+
+       TP_ARGS(inode, ordered)
+);
+
+DECLARE_EVENT_CLASS(btrfs__writepage,
+
+       TP_PROTO(struct page *page, struct inode *inode,
+                struct writeback_control *wbc),
+
+       TP_ARGS(page, inode, wbc),
+
+       TP_STRUCT__entry(
+               __field(        ino_t,  ino                     )
+               __field(        pgoff_t,  index                 )
+               __field(        long,   nr_to_write             )
+               __field(        long,   pages_skipped           )
+               __field(        loff_t, range_start             )
+               __field(        loff_t, range_end               )
+               __field(        char,   for_kupdate             )
+               __field(        char,   for_reclaim             )
+               __field(        char,   range_cyclic            )
+               __field(        pgoff_t,  writeback_index       )
+               __field(        u64,    root_objectid           )
+       ),
+
+       TP_fast_assign(
+               __entry->ino            = inode->i_ino;
+               __entry->index          = page->index;
+               __entry->nr_to_write    = wbc->nr_to_write;
+               __entry->pages_skipped  = wbc->pages_skipped;
+               __entry->range_start    = wbc->range_start;
+               __entry->range_end      = wbc->range_end;
+               __entry->for_kupdate    = wbc->for_kupdate;
+               __entry->for_reclaim    = wbc->for_reclaim;
+               __entry->range_cyclic   = wbc->range_cyclic;
+               __entry->writeback_index = inode->i_mapping->writeback_index;
+               __entry->root_objectid  =
+                                BTRFS_I(inode)->root->root_key.objectid;
+       ),
+
+       TP_printk("root = %llu(%s), ino = %lu, page_index = %lu, "
+                 "nr_to_write = %ld, pages_skipped = %ld, range_start = %llu, "
+                 "range_end = %llu, for_kupdate = %d, "
+                 "for_reclaim = %d, range_cyclic = %d, writeback_index = %lu",
+                 show_root_type(__entry->root_objectid),
+                 (unsigned long)__entry->ino, __entry->index,
+                 __entry->nr_to_write, __entry->pages_skipped,
+                 __entry->range_start, __entry->range_end,
+                 __entry->for_kupdate,
+                 __entry->for_reclaim, __entry->range_cyclic,
+                 (unsigned long)__entry->writeback_index)
+);
+
+DEFINE_EVENT(btrfs__writepage, __extent_writepage,
+
+       TP_PROTO(struct page *page, struct inode *inode,
+                struct writeback_control *wbc),
+
+       TP_ARGS(page, inode, wbc)
+);
+
+TRACE_EVENT(btrfs_writepage_end_io_hook,
+
+       TP_PROTO(struct page *page, u64 start, u64 end, int uptodate),
+
+       TP_ARGS(page, start, end, uptodate),
+
+       TP_STRUCT__entry(
+               __field(        ino_t,   ino            )
+               __field(        pgoff_t, index          )
+               __field(        u64,     start          )
+               __field(        u64,     end            )
+               __field(        int,     uptodate       )
+               __field(        u64,    root_objectid   )
+       ),
+
+       TP_fast_assign(
+               __entry->ino    = page->mapping->host->i_ino;
+               __entry->index  = page->index;
+               __entry->start  = start;
+               __entry->end    = end;
+               __entry->uptodate = uptodate;
+               __entry->root_objectid  =
+                        BTRFS_I(page->mapping->host)->root->root_key.objectid;
+       ),
+
+       TP_printk("root = %llu(%s), ino = %lu, page_index = %lu, start = %llu, "
+                 "end = %llu, uptodate = %d",
+                 show_root_type(__entry->root_objectid),
+                 (unsigned long)__entry->ino, (unsigned long)__entry->index,
+                 (unsigned long long)__entry->start,
+                 (unsigned long long)__entry->end, __entry->uptodate)
+);
+
+TRACE_EVENT(btrfs_sync_file,
+
+       TP_PROTO(struct file *file, int datasync),
+
+       TP_ARGS(file, datasync),
+
+       TP_STRUCT__entry(
+               __field(        ino_t,  ino             )
+               __field(        ino_t,  parent          )
+               __field(        int,    datasync        )
+               __field(        u64,    root_objectid   )
+       ),
+
+       TP_fast_assign(
+               struct dentry *dentry = file->f_path.dentry;
+               struct inode *inode = dentry->d_inode;
+
+               __entry->ino            = inode->i_ino;
+               __entry->parent         = dentry->d_parent->d_inode->i_ino;
+               __entry->datasync       = datasync;
+               __entry->root_objectid  =
+                                BTRFS_I(inode)->root->root_key.objectid;
+       ),
+
+       TP_printk("root = %llu(%s), ino = %ld, parent = %ld, datasync = %d",
+                 show_root_type(__entry->root_objectid),
+                 (unsigned long)__entry->ino, (unsigned long)__entry->parent,
+                 __entry->datasync)
+);
+
+TRACE_EVENT(btrfs_sync_fs,
+
+       TP_PROTO(int wait),
+
+       TP_ARGS(wait),
+
+       TP_STRUCT__entry(
+               __field(        int,  wait              )
+       ),
+
+       TP_fast_assign(
+               __entry->wait   = wait;
+       ),
+
+       TP_printk("wait = %d", __entry->wait)
+);
+
+#define show_ref_action(action)                                                \
+       __print_symbolic(action,                                        \
+               { BTRFS_ADD_DELAYED_REF,    "ADD_DELAYED_REF" },        \
+               { BTRFS_DROP_DELAYED_REF,   "DROP_DELAYED_REF" },       \
+               { BTRFS_ADD_DELAYED_EXTENT, "ADD_DELAYED_EXTENT" },     \
+               { BTRFS_UPDATE_DELAYED_HEAD, "UPDATE_DELAYED_HEAD" })
+
+
+TRACE_EVENT(btrfs_delayed_tree_ref,
+
+       TP_PROTO(struct btrfs_delayed_ref_node *ref,
+                struct btrfs_delayed_tree_ref *full_ref,
+                int action),
+
+       TP_ARGS(ref, full_ref, action),
+
+       TP_STRUCT__entry(
+               __field(        u64,  bytenr            )
+               __field(        u64,  num_bytes         )
+               __field(        int,  action            )
+               __field(        u64,  parent            )
+               __field(        u64,  ref_root          )
+               __field(        int,  level             )
+               __field(        int,  type              )
+               __field(        u64,  seq               )
+       ),
+
+       TP_fast_assign(
+               __entry->bytenr         = ref->bytenr;
+               __entry->num_bytes      = ref->num_bytes;
+               __entry->action         = action;
+               __entry->parent         = full_ref->parent;
+               __entry->ref_root       = full_ref->root;
+               __entry->level          = full_ref->level;
+               __entry->type           = ref->type;
+               __entry->seq            = ref->seq;
+       ),
+
+       TP_printk("bytenr = %llu, num_bytes = %llu, action = %s, "
+                 "parent = %llu(%s), ref_root = %llu(%s), level = %d, "
+                 "type = %s, seq = %llu",
+                 (unsigned long long)__entry->bytenr,
+                 (unsigned long long)__entry->num_bytes,
+                 show_ref_action(__entry->action),
+                 show_root_type(__entry->parent),
+                 show_root_type(__entry->ref_root),
+                 __entry->level, show_ref_type(__entry->type),
+                 (unsigned long long)__entry->seq)
+);
+
+TRACE_EVENT(btrfs_delayed_data_ref,
+
+       TP_PROTO(struct btrfs_delayed_ref_node *ref,
+                struct btrfs_delayed_data_ref *full_ref,
+                int action),
+
+       TP_ARGS(ref, full_ref, action),
+
+       TP_STRUCT__entry(
+               __field(        u64,  bytenr            )
+               __field(        u64,  num_bytes         )
+               __field(        int,  action            )
+               __field(        u64,  parent            )
+               __field(        u64,  ref_root          )
+               __field(        u64,  owner             )
+               __field(        u64,  offset            )
+               __field(        int,  type              )
+               __field(        u64,  seq               )
+       ),
+
+       TP_fast_assign(
+               __entry->bytenr         = ref->bytenr;
+               __entry->num_bytes      = ref->num_bytes;
+               __entry->action         = action;
+               __entry->parent         = full_ref->parent;
+               __entry->ref_root       = full_ref->root;
+               __entry->owner          = full_ref->objectid;
+               __entry->offset         = full_ref->offset;
+               __entry->type           = ref->type;
+               __entry->seq            = ref->seq;
+       ),
+
+       TP_printk("bytenr = %llu, num_bytes = %llu, action = %s, "
+                 "parent = %llu(%s), ref_root = %llu(%s), owner = %llu, "
+                 "offset = %llu, type = %s, seq = %llu",
+                 (unsigned long long)__entry->bytenr,
+                 (unsigned long long)__entry->num_bytes,
+                 show_ref_action(__entry->action),
+                 show_root_type(__entry->parent),
+                 show_root_type(__entry->ref_root),
+                 (unsigned long long)__entry->owner,
+                 (unsigned long long)__entry->offset,
+                 show_ref_type(__entry->type),
+                 (unsigned long long)__entry->seq)
+);
+
+TRACE_EVENT(btrfs_delayed_ref_head,
+
+       TP_PROTO(struct btrfs_delayed_ref_node *ref,
+                struct btrfs_delayed_ref_head *head_ref,
+                int action),
+
+       TP_ARGS(ref, head_ref, action),
+
+       TP_STRUCT__entry(
+               __field(        u64,  bytenr            )
+               __field(        u64,  num_bytes         )
+               __field(        int,  action            )
+               __field(        int,  is_data           )
+       ),
+
+       TP_fast_assign(
+               __entry->bytenr         = ref->bytenr;
+               __entry->num_bytes      = ref->num_bytes;
+               __entry->action         = action;
+               __entry->is_data        = head_ref->is_data;
+       ),
+
+       TP_printk("bytenr = %llu, num_bytes = %llu, action = %s, is_data = %d",
+                 (unsigned long long)__entry->bytenr,
+                 (unsigned long long)__entry->num_bytes,
+                 show_ref_action(__entry->action),
+                 __entry->is_data)
+);
+
+#define show_chunk_type(type)                                  \
+       __print_flags(type, "|",                                \
+               { BTRFS_BLOCK_GROUP_DATA,       "DATA"  },      \
+               { BTRFS_BLOCK_GROUP_SYSTEM,     "SYSTEM"},      \
+               { BTRFS_BLOCK_GROUP_METADATA,   "METADATA"},    \
+               { BTRFS_BLOCK_GROUP_RAID0,      "RAID0" },      \
+               { BTRFS_BLOCK_GROUP_RAID1,      "RAID1" },      \
+               { BTRFS_BLOCK_GROUP_DUP,        "DUP"   },      \
+               { BTRFS_BLOCK_GROUP_RAID10,     "RAID10"})
+
+DECLARE_EVENT_CLASS(btrfs__chunk,
+
+       TP_PROTO(struct btrfs_root *root, struct map_lookup *map,
+                u64 offset, u64 size),
+
+       TP_ARGS(root, map, offset, size),
+
+       TP_STRUCT__entry(
+               __field(        int,  num_stripes               )
+               __field(        u64,  type                      )
+               __field(        int,  sub_stripes               )
+               __field(        u64,  offset                    )
+               __field(        u64,  size                      )
+               __field(        u64,  root_objectid             )
+       ),
+
+       TP_fast_assign(
+               __entry->num_stripes    = map->num_stripes;
+               __entry->type           = map->type;
+               __entry->sub_stripes    = map->sub_stripes;
+               __entry->offset         = offset;
+               __entry->size           = size;
+               __entry->root_objectid  = root->root_key.objectid;
+       ),
+
+       TP_printk("root = %llu(%s), offset = %llu, size = %llu, "
+                 "num_stripes = %d, sub_stripes = %d, type = %s",
+                 show_root_type(__entry->root_objectid),
+                 (unsigned long long)__entry->offset,
+                 (unsigned long long)__entry->size,
+                 __entry->num_stripes, __entry->sub_stripes,
+                 show_chunk_type(__entry->type))
+);
+
+DEFINE_EVENT(btrfs__chunk,  btrfs_chunk_alloc,
+
+       TP_PROTO(struct btrfs_root *root, struct map_lookup *map,
+                u64 offset, u64 size),
+
+       TP_ARGS(root, map, offset, size)
+);
+
+DEFINE_EVENT(btrfs__chunk,  btrfs_chunk_free,
+
+       TP_PROTO(struct btrfs_root *root, struct map_lookup *map,
+                u64 offset, u64 size),
+
+       TP_ARGS(root, map, offset, size)
+);
+
+TRACE_EVENT(btrfs_cow_block,
+
+       TP_PROTO(struct btrfs_root *root, struct extent_buffer *buf,
+                struct extent_buffer *cow),
+
+       TP_ARGS(root, buf, cow),
+
+       TP_STRUCT__entry(
+               __field(        u64,  root_objectid             )
+               __field(        u64,  buf_start                 )
+               __field(        int,  refs                      )
+               __field(        u64,  cow_start                 )
+               __field(        int,  buf_level                 )
+               __field(        int,  cow_level                 )
+       ),
+
+       TP_fast_assign(
+               __entry->root_objectid  = root->root_key.objectid;
+               __entry->buf_start      = buf->start;
+               __entry->refs           = atomic_read(&buf->refs);
+               __entry->cow_start      = cow->start;
+               __entry->buf_level      = btrfs_header_level(buf);
+               __entry->cow_level      = btrfs_header_level(cow);
+       ),
+
+       TP_printk("root = %llu(%s), refs = %d, orig_buf = %llu "
+                 "(orig_level = %d), cow_buf = %llu (cow_level = %d)",
+                 show_root_type(__entry->root_objectid),
+                 __entry->refs,
+                 (unsigned long long)__entry->buf_start,
+                 __entry->buf_level,
+                 (unsigned long long)__entry->cow_start,
+                 __entry->cow_level)
+);
+
+TRACE_EVENT(btrfs_space_reservation,
+
+       TP_PROTO(struct btrfs_fs_info *fs_info, char *type, u64 val,
+                u64 bytes, int reserve),
+
+       TP_ARGS(fs_info, type, val, bytes, reserve),
+
+       TP_STRUCT__entry(
+               __array(        u8,     fsid,   BTRFS_UUID_SIZE )
+               __string(       type,   type                    )
+               __field(        u64,    val                     )
+               __field(        u64,    bytes                   )
+               __field(        int,    reserve                 )
+       ),
+
+       TP_fast_assign(
+               memcpy(__entry->fsid, fs_info->fsid, BTRFS_UUID_SIZE);
+               __assign_str(type, type);
+               __entry->val            = val;
+               __entry->bytes          = bytes;
+               __entry->reserve        = reserve;
+       ),
+
+       TP_printk("%pU: %s: %Lu %s %Lu", __entry->fsid, __get_str(type),
+                 __entry->val, __entry->reserve ? "reserve" : "release",
+                 __entry->bytes)
+);
+
+DECLARE_EVENT_CLASS(btrfs__reserved_extent,
+
+       TP_PROTO(struct btrfs_root *root, u64 start, u64 len),
+
+       TP_ARGS(root, start, len),
+
+       TP_STRUCT__entry(
+               __field(        u64,  root_objectid             )
+               __field(        u64,  start                     )
+               __field(        u64,  len                       )
+       ),
+
+       TP_fast_assign(
+               __entry->root_objectid  = root->root_key.objectid;
+               __entry->start          = start;
+               __entry->len            = len;
+       ),
+
+       TP_printk("root = %llu(%s), start = %llu, len = %llu",
+                 show_root_type(__entry->root_objectid),
+                 (unsigned long long)__entry->start,
+                 (unsigned long long)__entry->len)
+);
+
+DEFINE_EVENT(btrfs__reserved_extent,  btrfs_reserved_extent_alloc,
+
+       TP_PROTO(struct btrfs_root *root, u64 start, u64 len),
+
+       TP_ARGS(root, start, len)
+);
+
+DEFINE_EVENT(btrfs__reserved_extent,  btrfs_reserved_extent_free,
+
+       TP_PROTO(struct btrfs_root *root, u64 start, u64 len),
+
+       TP_ARGS(root, start, len)
+);
+
+TRACE_EVENT(find_free_extent,
+
+       TP_PROTO(struct btrfs_root *root, u64 num_bytes, u64 empty_size,
+                u64 data),
+
+       TP_ARGS(root, num_bytes, empty_size, data),
+
+       TP_STRUCT__entry(
+               __field(        u64,    root_objectid           )
+               __field(        u64,    num_bytes               )
+               __field(        u64,    empty_size              )
+               __field(        u64,    data                    )
+       ),
+
+       TP_fast_assign(
+               __entry->root_objectid  = root->root_key.objectid;
+               __entry->num_bytes      = num_bytes;
+               __entry->empty_size     = empty_size;
+               __entry->data           = data;
+       ),
+
+       TP_printk("root = %Lu(%s), len = %Lu, empty_size = %Lu, "
+                 "flags = %Lu(%s)", show_root_type(__entry->root_objectid),
+                 __entry->num_bytes, __entry->empty_size, __entry->data,
+                 __print_flags((unsigned long)__entry->data, "|",
+                                BTRFS_GROUP_FLAGS))
+);
+
+DECLARE_EVENT_CLASS(btrfs__reserve_extent,
+
+       TP_PROTO(struct btrfs_root *root,
+                struct btrfs_block_group_cache *block_group, u64 start,
+                u64 len),
+
+       TP_ARGS(root, block_group, start, len),
+
+       TP_STRUCT__entry(
+               __field(        u64,    root_objectid           )
+               __field(        u64,    bg_objectid             )
+               __field(        u64,    flags                   )
+               __field(        u64,    start                   )
+               __field(        u64,    len                     )
+       ),
+
+       TP_fast_assign(
+               __entry->root_objectid  = root->root_key.objectid;
+               __entry->bg_objectid    = block_group->key.objectid;
+               __entry->flags          = block_group->flags;
+               __entry->start          = start;
+               __entry->len            = len;
+       ),
+
+       TP_printk("root = %Lu(%s), block_group = %Lu, flags = %Lu(%s), "
+                 "start = %Lu, len = %Lu",
+                 show_root_type(__entry->root_objectid), __entry->bg_objectid,
+                 __entry->flags, __print_flags((unsigned long)__entry->flags,
+                                               "|", BTRFS_GROUP_FLAGS),
+                 __entry->start, __entry->len)
+);
+
+DEFINE_EVENT(btrfs__reserve_extent, btrfs_reserve_extent,
+
+       TP_PROTO(struct btrfs_root *root,
+                struct btrfs_block_group_cache *block_group, u64 start,
+                u64 len),
+
+       TP_ARGS(root, block_group, start, len)
+);
+
+DEFINE_EVENT(btrfs__reserve_extent, btrfs_reserve_extent_cluster,
+
+       TP_PROTO(struct btrfs_root *root,
+                struct btrfs_block_group_cache *block_group, u64 start,
+                u64 len),
+
+       TP_ARGS(root, block_group, start, len)
+);
+
+TRACE_EVENT(btrfs_find_cluster,
+
+       TP_PROTO(struct btrfs_block_group_cache *block_group, u64 start,
+                u64 bytes, u64 empty_size, u64 min_bytes),
+
+       TP_ARGS(block_group, start, bytes, empty_size, min_bytes),
+
+       TP_STRUCT__entry(
+               __field(        u64,    bg_objectid             )
+               __field(        u64,    flags                   )
+               __field(        u64,    start                   )
+               __field(        u64,    bytes                   )
+               __field(        u64,    empty_size              )
+               __field(        u64,    min_bytes               )
+       ),
+
+       TP_fast_assign(
+               __entry->bg_objectid    = block_group->key.objectid;
+               __entry->flags          = block_group->flags;
+               __entry->start          = start;
+               __entry->bytes          = bytes;
+               __entry->empty_size     = empty_size;
+               __entry->min_bytes      = min_bytes;
+       ),
+
+       TP_printk("block_group = %Lu, flags = %Lu(%s), start = %Lu, len = %Lu,"
+                 " empty_size = %Lu, min_bytes = %Lu", __entry->bg_objectid,
+                 __entry->flags,
+                 __print_flags((unsigned long)__entry->flags, "|",
+                               BTRFS_GROUP_FLAGS), __entry->start,
+                 __entry->bytes, __entry->empty_size,  __entry->min_bytes)
+);
+
+TRACE_EVENT(btrfs_failed_cluster_setup,
+
+       TP_PROTO(struct btrfs_block_group_cache *block_group),
+
+       TP_ARGS(block_group),
+
+       TP_STRUCT__entry(
+               __field(        u64,    bg_objectid             )
+       ),
+
+       TP_fast_assign(
+               __entry->bg_objectid    = block_group->key.objectid;
+       ),
+
+       TP_printk("block_group = %Lu", __entry->bg_objectid)
+);
+
+TRACE_EVENT(btrfs_setup_cluster,
+
+       TP_PROTO(struct btrfs_block_group_cache *block_group,
+                struct btrfs_free_cluster *cluster, u64 size, int bitmap),
+
+       TP_ARGS(block_group, cluster, size, bitmap),
+
+       TP_STRUCT__entry(
+               __field(        u64,    bg_objectid             )
+               __field(        u64,    flags                   )
+               __field(        u64,    start                   )
+               __field(        u64,    max_size                )
+               __field(        u64,    size                    )
+               __field(        int,    bitmap                  )
+       ),
+
+       TP_fast_assign(
+               __entry->bg_objectid    = block_group->key.objectid;
+               __entry->flags          = block_group->flags;
+               __entry->start          = cluster->window_start;
+               __entry->max_size       = cluster->max_size;
+               __entry->size           = size;
+               __entry->bitmap         = bitmap;
+       ),
+
+       TP_printk("block_group = %Lu, flags = %Lu(%s), window_start = %Lu, "
+                 "size = %Lu, max_size = %Lu, bitmap = %d",
+                 __entry->bg_objectid,
+                 __entry->flags,
+                 __print_flags((unsigned long)__entry->flags, "|",
+                               BTRFS_GROUP_FLAGS), __entry->start,
+                 __entry->size, __entry->max_size, __entry->bitmap)
+);
+
+struct extent_state;
+TRACE_EVENT(alloc_extent_state,
+
+       TP_PROTO(struct extent_state *state, gfp_t mask, unsigned long IP),
+
+       TP_ARGS(state, mask, IP),
+
+       TP_STRUCT__entry(
+               __field(struct extent_state *, state)
+               __field(gfp_t, mask)
+               __field(unsigned long, ip)
+       ),
+
+       TP_fast_assign(
+               __entry->state  = state,
+               __entry->mask   = mask,
+               __entry->ip     = IP
+       ),
+
+       TP_printk("state=%p; mask = %s; caller = %pF", __entry->state,
+                 show_gfp_flags(__entry->mask), (void *)__entry->ip)
+);
+
+TRACE_EVENT(free_extent_state,
+
+       TP_PROTO(struct extent_state *state, unsigned long IP),
+
+       TP_ARGS(state, IP),
+
+       TP_STRUCT__entry(
+               __field(struct extent_state *, state)
+               __field(unsigned long, ip)
+       ),
+
+       TP_fast_assign(
+               __entry->state  = state,
+               __entry->ip = IP
+       ),
+
+       TP_printk(" state=%p; caller = %pF", __entry->state,
+                 (void *)__entry->ip)
+);
+
+#endif /* _TRACE_BTRFS_H */
+
+/* This part must be outside protection */
+#include <trace/define_trace.h>
diff --git a/drivers/staging/lttng/instrumentation/events/mainline/compaction.h b/drivers/staging/lttng/instrumentation/events/mainline/compaction.h
new file mode 100644 (file)
index 0000000..fde1b3e
--- /dev/null
@@ -0,0 +1,74 @@
+#undef TRACE_SYSTEM
+#define TRACE_SYSTEM compaction
+
+#if !defined(_TRACE_COMPACTION_H) || defined(TRACE_HEADER_MULTI_READ)
+#define _TRACE_COMPACTION_H
+
+#include <linux/types.h>
+#include <linux/tracepoint.h>
+#include <trace/events/gfpflags.h>
+
+DECLARE_EVENT_CLASS(mm_compaction_isolate_template,
+
+       TP_PROTO(unsigned long nr_scanned,
+               unsigned long nr_taken),
+
+       TP_ARGS(nr_scanned, nr_taken),
+
+       TP_STRUCT__entry(
+               __field(unsigned long, nr_scanned)
+               __field(unsigned long, nr_taken)
+       ),
+
+       TP_fast_assign(
+               __entry->nr_scanned = nr_scanned;
+               __entry->nr_taken = nr_taken;
+       ),
+
+       TP_printk("nr_scanned=%lu nr_taken=%lu",
+               __entry->nr_scanned,
+               __entry->nr_taken)
+);
+
+DEFINE_EVENT(mm_compaction_isolate_template, mm_compaction_isolate_migratepages,
+
+       TP_PROTO(unsigned long nr_scanned,
+               unsigned long nr_taken),
+
+       TP_ARGS(nr_scanned, nr_taken)
+);
+
+DEFINE_EVENT(mm_compaction_isolate_template, mm_compaction_isolate_freepages,
+       TP_PROTO(unsigned long nr_scanned,
+               unsigned long nr_taken),
+
+       TP_ARGS(nr_scanned, nr_taken)
+);
+
+TRACE_EVENT(mm_compaction_migratepages,
+
+       TP_PROTO(unsigned long nr_migrated,
+               unsigned long nr_failed),
+
+       TP_ARGS(nr_migrated, nr_failed),
+
+       TP_STRUCT__entry(
+               __field(unsigned long, nr_migrated)
+               __field(unsigned long, nr_failed)
+       ),
+
+       TP_fast_assign(
+               __entry->nr_migrated = nr_migrated;
+               __entry->nr_failed = nr_failed;
+       ),
+
+       TP_printk("nr_migrated=%lu nr_failed=%lu",
+               __entry->nr_migrated,
+               __entry->nr_failed)
+);
+
+
+#endif /* _TRACE_COMPACTION_H */
+
+/* This part must be outside protection */
+#include <trace/define_trace.h>
diff --git a/drivers/staging/lttng/instrumentation/events/mainline/ext3.h b/drivers/staging/lttng/instrumentation/events/mainline/ext3.h
new file mode 100644 (file)
index 0000000..15d11a3
--- /dev/null
@@ -0,0 +1,864 @@
+#undef TRACE_SYSTEM
+#define TRACE_SYSTEM ext3
+
+#if !defined(_TRACE_EXT3_H) || defined(TRACE_HEADER_MULTI_READ)
+#define _TRACE_EXT3_H
+
+#include <linux/tracepoint.h>
+
+TRACE_EVENT(ext3_free_inode,
+       TP_PROTO(struct inode *inode),
+
+       TP_ARGS(inode),
+
+       TP_STRUCT__entry(
+               __field(        dev_t,  dev                     )
+               __field(        ino_t,  ino                     )
+               __field(        umode_t, mode                   )
+               __field(        uid_t,  uid                     )
+               __field(        gid_t,  gid                     )
+               __field(        blkcnt_t, blocks                )
+       ),
+
+       TP_fast_assign(
+               __entry->dev    = inode->i_sb->s_dev;
+               __entry->ino    = inode->i_ino;
+               __entry->mode   = inode->i_mode;
+               __entry->uid    = i_uid_read(inode);
+               __entry->gid    = i_gid_read(inode);
+               __entry->blocks = inode->i_blocks;
+       ),
+
+       TP_printk("dev %d,%d ino %lu mode 0%o uid %u gid %u blocks %lu",
+                 MAJOR(__entry->dev), MINOR(__entry->dev),
+                 (unsigned long) __entry->ino,
+                 __entry->mode, __entry->uid, __entry->gid,
+                 (unsigned long) __entry->blocks)
+);
+
+TRACE_EVENT(ext3_request_inode,
+       TP_PROTO(struct inode *dir, int mode),
+
+       TP_ARGS(dir, mode),
+
+       TP_STRUCT__entry(
+               __field(        dev_t,  dev                     )
+               __field(        ino_t,  dir                     )
+               __field(        umode_t, mode                   )
+       ),
+
+       TP_fast_assign(
+               __entry->dev    = dir->i_sb->s_dev;
+               __entry->dir    = dir->i_ino;
+               __entry->mode   = mode;
+       ),
+
+       TP_printk("dev %d,%d dir %lu mode 0%o",
+                 MAJOR(__entry->dev), MINOR(__entry->dev),
+                 (unsigned long) __entry->dir, __entry->mode)
+);
+
+TRACE_EVENT(ext3_allocate_inode,
+       TP_PROTO(struct inode *inode, struct inode *dir, int mode),
+
+       TP_ARGS(inode, dir, mode),
+
+       TP_STRUCT__entry(
+               __field(        dev_t,  dev                     )
+               __field(        ino_t,  ino                     )
+               __field(        ino_t,  dir                     )
+               __field(        umode_t, mode                   )
+       ),
+
+       TP_fast_assign(
+               __entry->dev    = inode->i_sb->s_dev;
+               __entry->ino    = inode->i_ino;
+               __entry->dir    = dir->i_ino;
+               __entry->mode   = mode;
+       ),
+
+       TP_printk("dev %d,%d ino %lu dir %lu mode 0%o",
+                 MAJOR(__entry->dev), MINOR(__entry->dev),
+                 (unsigned long) __entry->ino,
+                 (unsigned long) __entry->dir, __entry->mode)
+);
+
+TRACE_EVENT(ext3_evict_inode,
+       TP_PROTO(struct inode *inode),
+
+       TP_ARGS(inode),
+
+       TP_STRUCT__entry(
+               __field(        dev_t,  dev                     )
+               __field(        ino_t,  ino                     )
+               __field(        int,    nlink                   )
+       ),
+
+       TP_fast_assign(
+               __entry->dev    = inode->i_sb->s_dev;
+               __entry->ino    = inode->i_ino;
+               __entry->nlink  = inode->i_nlink;
+       ),
+
+       TP_printk("dev %d,%d ino %lu nlink %d",
+                 MAJOR(__entry->dev), MINOR(__entry->dev),
+                 (unsigned long) __entry->ino, __entry->nlink)
+);
+
+TRACE_EVENT(ext3_drop_inode,
+       TP_PROTO(struct inode *inode, int drop),
+
+       TP_ARGS(inode, drop),
+
+       TP_STRUCT__entry(
+               __field(        dev_t,  dev                     )
+               __field(        ino_t,  ino                     )
+               __field(        int,    drop                    )
+       ),
+
+       TP_fast_assign(
+               __entry->dev    = inode->i_sb->s_dev;
+               __entry->ino    = inode->i_ino;
+               __entry->drop   = drop;
+       ),
+
+       TP_printk("dev %d,%d ino %lu drop %d",
+                 MAJOR(__entry->dev), MINOR(__entry->dev),
+                 (unsigned long) __entry->ino, __entry->drop)
+);
+
+TRACE_EVENT(ext3_mark_inode_dirty,
+       TP_PROTO(struct inode *inode, unsigned long IP),
+
+       TP_ARGS(inode, IP),
+
+       TP_STRUCT__entry(
+               __field(        dev_t,  dev                     )
+               __field(        ino_t,  ino                     )
+               __field(unsigned long,  ip                      )
+       ),
+
+       TP_fast_assign(
+               __entry->dev    = inode->i_sb->s_dev;
+               __entry->ino    = inode->i_ino;
+               __entry->ip     = IP;
+       ),
+
+       TP_printk("dev %d,%d ino %lu caller %pF",
+                 MAJOR(__entry->dev), MINOR(__entry->dev),
+                 (unsigned long) __entry->ino, (void *)__entry->ip)
+);
+
+TRACE_EVENT(ext3_write_begin,
+       TP_PROTO(struct inode *inode, loff_t pos, unsigned int len,
+                unsigned int flags),
+
+       TP_ARGS(inode, pos, len, flags),
+
+       TP_STRUCT__entry(
+               __field(        dev_t,  dev                     )
+               __field(        ino_t,  ino                     )
+               __field(        loff_t, pos                     )
+               __field(        unsigned int, len               )
+               __field(        unsigned int, flags             )
+       ),
+
+       TP_fast_assign(
+               __entry->dev    = inode->i_sb->s_dev;
+               __entry->ino    = inode->i_ino;
+               __entry->pos    = pos;
+               __entry->len    = len;
+               __entry->flags  = flags;
+       ),
+
+       TP_printk("dev %d,%d ino %lu pos %llu len %u flags %u",
+                 MAJOR(__entry->dev), MINOR(__entry->dev),
+                 (unsigned long) __entry->ino,
+                 (unsigned long long) __entry->pos, __entry->len,
+                 __entry->flags)
+);
+
+DECLARE_EVENT_CLASS(ext3__write_end,
+       TP_PROTO(struct inode *inode, loff_t pos, unsigned int len,
+                       unsigned int copied),
+
+       TP_ARGS(inode, pos, len, copied),
+
+       TP_STRUCT__entry(
+               __field(        dev_t,  dev                     )
+               __field(        ino_t,  ino                     )
+               __field(        loff_t, pos                     )
+               __field(        unsigned int, len               )
+               __field(        unsigned int, copied            )
+       ),
+
+       TP_fast_assign(
+               __entry->dev    = inode->i_sb->s_dev;
+               __entry->ino    = inode->i_ino;
+               __entry->pos    = pos;
+               __entry->len    = len;
+               __entry->copied = copied;
+       ),
+
+       TP_printk("dev %d,%d ino %lu pos %llu len %u copied %u",
+                 MAJOR(__entry->dev), MINOR(__entry->dev),
+                 (unsigned long) __entry->ino,
+                 (unsigned long long) __entry->pos, __entry->len,
+                 __entry->copied)
+);
+
+DEFINE_EVENT(ext3__write_end, ext3_ordered_write_end,
+
+       TP_PROTO(struct inode *inode, loff_t pos, unsigned int len,
+                unsigned int copied),
+
+       TP_ARGS(inode, pos, len, copied)
+);
+
+DEFINE_EVENT(ext3__write_end, ext3_writeback_write_end,
+
+       TP_PROTO(struct inode *inode, loff_t pos, unsigned int len,
+                unsigned int copied),
+
+       TP_ARGS(inode, pos, len, copied)
+);
+
+DEFINE_EVENT(ext3__write_end, ext3_journalled_write_end,
+
+       TP_PROTO(struct inode *inode, loff_t pos, unsigned int len,
+                unsigned int copied),
+
+       TP_ARGS(inode, pos, len, copied)
+);
+
+DECLARE_EVENT_CLASS(ext3__page_op,
+       TP_PROTO(struct page *page),
+
+       TP_ARGS(page),
+
+       TP_STRUCT__entry(
+               __field(        dev_t,  dev                     )
+               __field(        ino_t,  ino                     )
+               __field(        pgoff_t, index                  )
+
+       ),
+
+       TP_fast_assign(
+               __entry->index  = page->index;
+               __entry->ino    = page->mapping->host->i_ino;
+               __entry->dev    = page->mapping->host->i_sb->s_dev;
+       ),
+
+       TP_printk("dev %d,%d ino %lu page_index %lu",
+                 MAJOR(__entry->dev), MINOR(__entry->dev),
+                 (unsigned long) __entry->ino, __entry->index)
+);
+
+DEFINE_EVENT(ext3__page_op, ext3_ordered_writepage,
+
+       TP_PROTO(struct page *page),
+
+       TP_ARGS(page)
+);
+
+DEFINE_EVENT(ext3__page_op, ext3_writeback_writepage,
+
+       TP_PROTO(struct page *page),
+
+       TP_ARGS(page)
+);
+
+DEFINE_EVENT(ext3__page_op, ext3_journalled_writepage,
+
+       TP_PROTO(struct page *page),
+
+       TP_ARGS(page)
+);
+
+DEFINE_EVENT(ext3__page_op, ext3_readpage,
+
+       TP_PROTO(struct page *page),
+
+       TP_ARGS(page)
+);
+
+DEFINE_EVENT(ext3__page_op, ext3_releasepage,
+
+       TP_PROTO(struct page *page),
+
+       TP_ARGS(page)
+);
+
+TRACE_EVENT(ext3_invalidatepage,
+       TP_PROTO(struct page *page, unsigned long offset),
+
+       TP_ARGS(page, offset),
+
+       TP_STRUCT__entry(
+               __field(        pgoff_t, index                  )
+               __field(        unsigned long, offset           )
+               __field(        ino_t,  ino                     )
+               __field(        dev_t,  dev                     )
+
+       ),
+
+       TP_fast_assign(
+               __entry->index  = page->index;
+               __entry->offset = offset;
+               __entry->ino    = page->mapping->host->i_ino;
+               __entry->dev    = page->mapping->host->i_sb->s_dev;
+       ),
+
+       TP_printk("dev %d,%d ino %lu page_index %lu offset %lu",
+                 MAJOR(__entry->dev), MINOR(__entry->dev),
+                 (unsigned long) __entry->ino,
+                 __entry->index, __entry->offset)
+);
+
+TRACE_EVENT(ext3_discard_blocks,
+       TP_PROTO(struct super_block *sb, unsigned long blk,
+                       unsigned long count),
+
+       TP_ARGS(sb, blk, count),
+
+       TP_STRUCT__entry(
+               __field(        dev_t,          dev             )
+               __field(        unsigned long,  blk             )
+               __field(        unsigned long,  count           )
+
+       ),
+
+       TP_fast_assign(
+               __entry->dev    = sb->s_dev;
+               __entry->blk    = blk;
+               __entry->count  = count;
+       ),
+
+       TP_printk("dev %d,%d blk %lu count %lu",
+                 MAJOR(__entry->dev), MINOR(__entry->dev),
+                 __entry->blk, __entry->count)
+);
+
+TRACE_EVENT(ext3_request_blocks,
+       TP_PROTO(struct inode *inode, unsigned long goal,
+                unsigned long count),
+
+       TP_ARGS(inode, goal, count),
+
+       TP_STRUCT__entry(
+               __field(        dev_t,  dev                     )
+               __field(        ino_t,  ino                     )
+               __field(        unsigned long, count            )
+               __field(        unsigned long,  goal            )
+       ),
+
+       TP_fast_assign(
+               __entry->dev    = inode->i_sb->s_dev;
+               __entry->ino    = inode->i_ino;
+               __entry->count  = count;
+               __entry->goal   = goal;
+       ),
+
+       TP_printk("dev %d,%d ino %lu count %lu goal %lu ",
+                 MAJOR(__entry->dev), MINOR(__entry->dev),
+                 (unsigned long) __entry->ino,
+                 __entry->count, __entry->goal)
+);
+
+TRACE_EVENT(ext3_allocate_blocks,
+       TP_PROTO(struct inode *inode, unsigned long goal,
+                unsigned long count, unsigned long block),
+
+       TP_ARGS(inode, goal, count, block),
+
+       TP_STRUCT__entry(
+               __field(        dev_t,  dev                     )
+               __field(        ino_t,  ino                     )
+               __field(        unsigned long,  block           )
+               __field(        unsigned long, count            )
+               __field(        unsigned long,  goal            )
+       ),
+
+       TP_fast_assign(
+               __entry->dev    = inode->i_sb->s_dev;
+               __entry->ino    = inode->i_ino;
+               __entry->block  = block;
+               __entry->count  = count;
+               __entry->goal   = goal;
+       ),
+
+       TP_printk("dev %d,%d ino %lu count %lu block %lu goal %lu",
+                 MAJOR(__entry->dev), MINOR(__entry->dev),
+                 (unsigned long) __entry->ino,
+                  __entry->count, __entry->block,
+                 __entry->goal)
+);
+
+TRACE_EVENT(ext3_free_blocks,
+       TP_PROTO(struct inode *inode, unsigned long block,
+                unsigned long count),
+
+       TP_ARGS(inode, block, count),
+
+       TP_STRUCT__entry(
+               __field(        dev_t,  dev                     )
+               __field(        ino_t,  ino                     )
+               __field(        umode_t, mode                   )
+               __field(        unsigned long,  block           )
+               __field(        unsigned long,  count           )
+       ),
+
+       TP_fast_assign(
+               __entry->dev            = inode->i_sb->s_dev;
+               __entry->ino            = inode->i_ino;
+               __entry->mode           = inode->i_mode;
+               __entry->block          = block;
+               __entry->count          = count;
+       ),
+
+       TP_printk("dev %d,%d ino %lu mode 0%o block %lu count %lu",
+                 MAJOR(__entry->dev), MINOR(__entry->dev),
+                 (unsigned long) __entry->ino,
+                 __entry->mode, __entry->block, __entry->count)
+);
+
+TRACE_EVENT(ext3_sync_file_enter,
+       TP_PROTO(struct file *file, int datasync),
+
+       TP_ARGS(file, datasync),
+
+       TP_STRUCT__entry(
+               __field(        dev_t,  dev                     )
+               __field(        ino_t,  ino                     )
+               __field(        ino_t,  parent                  )
+               __field(        int,    datasync                )
+       ),
+
+       TP_fast_assign(
+               struct dentry *dentry = file->f_path.dentry;
+
+               __entry->dev            = dentry->d_inode->i_sb->s_dev;
+               __entry->ino            = dentry->d_inode->i_ino;
+               __entry->datasync       = datasync;
+               __entry->parent         = dentry->d_parent->d_inode->i_ino;
+       ),
+
+       TP_printk("dev %d,%d ino %lu parent %ld datasync %d ",
+                 MAJOR(__entry->dev), MINOR(__entry->dev),
+                 (unsigned long) __entry->ino,
+                 (unsigned long) __entry->parent, __entry->datasync)
+);
+
+TRACE_EVENT(ext3_sync_file_exit,
+       TP_PROTO(struct inode *inode, int ret),
+
+       TP_ARGS(inode, ret),
+
+       TP_STRUCT__entry(
+               __field(        int,    ret                     )
+               __field(        ino_t,  ino                     )
+               __field(        dev_t,  dev                     )
+       ),
+
+       TP_fast_assign(
+               __entry->ret            = ret;
+               __entry->ino            = inode->i_ino;
+               __entry->dev            = inode->i_sb->s_dev;
+       ),
+
+       TP_printk("dev %d,%d ino %lu ret %d",
+                 MAJOR(__entry->dev), MINOR(__entry->dev),
+                 (unsigned long) __entry->ino,
+                 __entry->ret)
+);
+
+TRACE_EVENT(ext3_sync_fs,
+       TP_PROTO(struct super_block *sb, int wait),
+
+       TP_ARGS(sb, wait),
+
+       TP_STRUCT__entry(
+               __field(        dev_t,  dev                     )
+               __field(        int,    wait                    )
+
+       ),
+
+       TP_fast_assign(
+               __entry->dev    = sb->s_dev;
+               __entry->wait   = wait;
+       ),
+
+       TP_printk("dev %d,%d wait %d",
+                 MAJOR(__entry->dev), MINOR(__entry->dev),
+                 __entry->wait)
+);
+
+TRACE_EVENT(ext3_rsv_window_add,
+       TP_PROTO(struct super_block *sb,
+                struct ext3_reserve_window_node *rsv_node),
+
+       TP_ARGS(sb, rsv_node),
+
+       TP_STRUCT__entry(
+               __field(        unsigned long,  start           )
+               __field(        unsigned long,  end             )
+               __field(        dev_t,  dev                     )
+       ),
+
+       TP_fast_assign(
+               __entry->dev    = sb->s_dev;
+               __entry->start  = rsv_node->rsv_window._rsv_start;
+               __entry->end    = rsv_node->rsv_window._rsv_end;
+       ),
+
+       TP_printk("dev %d,%d start %lu end %lu",
+                 MAJOR(__entry->dev), MINOR(__entry->dev),
+                 __entry->start, __entry->end)
+);
+
+TRACE_EVENT(ext3_discard_reservation,
+       TP_PROTO(struct inode *inode,
+                struct ext3_reserve_window_node *rsv_node),
+
+       TP_ARGS(inode, rsv_node),
+
+       TP_STRUCT__entry(
+               __field(        unsigned long,  start           )
+               __field(        unsigned long,  end             )
+               __field(        ino_t,  ino                     )
+               __field(        dev_t,  dev                     )
+       ),
+
+       TP_fast_assign(
+               __entry->start  = rsv_node->rsv_window._rsv_start;
+               __entry->end    = rsv_node->rsv_window._rsv_end;
+               __entry->ino    = inode->i_ino;
+               __entry->dev    = inode->i_sb->s_dev;
+       ),
+
+       TP_printk("dev %d,%d ino %lu start %lu end %lu",
+                 MAJOR(__entry->dev), MINOR(__entry->dev),
+                 (unsigned long)__entry->ino, __entry->start,
+                 __entry->end)
+);
+
+TRACE_EVENT(ext3_alloc_new_reservation,
+       TP_PROTO(struct super_block *sb, unsigned long goal),
+
+       TP_ARGS(sb, goal),
+
+       TP_STRUCT__entry(
+               __field(        dev_t,  dev                     )
+               __field(        unsigned long,  goal            )
+       ),
+
+       TP_fast_assign(
+               __entry->dev    = sb->s_dev;
+               __entry->goal   = goal;
+       ),
+
+       TP_printk("dev %d,%d goal %lu",
+                 MAJOR(__entry->dev), MINOR(__entry->dev),
+                 __entry->goal)
+);
+
+TRACE_EVENT(ext3_reserved,
+       TP_PROTO(struct super_block *sb, unsigned long block,
+                struct ext3_reserve_window_node *rsv_node),
+
+       TP_ARGS(sb, block, rsv_node),
+
+       TP_STRUCT__entry(
+               __field(        unsigned long,  block           )
+               __field(        unsigned long,  start           )
+               __field(        unsigned long,  end             )
+               __field(        dev_t,  dev                     )
+       ),
+
+       TP_fast_assign(
+               __entry->block  = block;
+               __entry->start  = rsv_node->rsv_window._rsv_start;
+               __entry->end    = rsv_node->rsv_window._rsv_end;
+               __entry->dev    = sb->s_dev;
+       ),
+
+       TP_printk("dev %d,%d block %lu, start %lu end %lu",
+                 MAJOR(__entry->dev), MINOR(__entry->dev),
+                 __entry->block, __entry->start, __entry->end)
+);
+
+TRACE_EVENT(ext3_forget,
+       TP_PROTO(struct inode *inode, int is_metadata, unsigned long block),
+
+       TP_ARGS(inode, is_metadata, block),
+
+       TP_STRUCT__entry(
+               __field(        dev_t,  dev                     )
+               __field(        ino_t,  ino                     )
+               __field(        umode_t, mode                   )
+               __field(        int,    is_metadata             )
+               __field(        unsigned long,  block           )
+       ),
+
+       TP_fast_assign(
+               __entry->dev    = inode->i_sb->s_dev;
+               __entry->ino    = inode->i_ino;
+               __entry->mode   = inode->i_mode;
+               __entry->is_metadata = is_metadata;
+               __entry->block  = block;
+       ),
+
+       TP_printk("dev %d,%d ino %lu mode 0%o is_metadata %d block %lu",
+                 MAJOR(__entry->dev), MINOR(__entry->dev),
+                 (unsigned long) __entry->ino,
+                 __entry->mode, __entry->is_metadata, __entry->block)
+);
+
+TRACE_EVENT(ext3_read_block_bitmap,
+       TP_PROTO(struct super_block *sb, unsigned int group),
+
+       TP_ARGS(sb, group),
+
+       TP_STRUCT__entry(
+               __field(        dev_t,  dev                     )
+               __field(        __u32,  group                   )
+
+       ),
+
+       TP_fast_assign(
+               __entry->dev    = sb->s_dev;
+               __entry->group  = group;
+       ),
+
+       TP_printk("dev %d,%d group %u",
+                 MAJOR(__entry->dev), MINOR(__entry->dev),
+                 __entry->group)
+);
+
+TRACE_EVENT(ext3_direct_IO_enter,
+       TP_PROTO(struct inode *inode, loff_t offset, unsigned long len, int rw),
+
+       TP_ARGS(inode, offset, len, rw),
+
+       TP_STRUCT__entry(
+               __field(        ino_t,  ino                     )
+               __field(        dev_t,  dev                     )
+               __field(        loff_t, pos                     )
+               __field(        unsigned long,  len             )
+               __field(        int,    rw                      )
+       ),
+
+       TP_fast_assign(
+               __entry->ino    = inode->i_ino;
+               __entry->dev    = inode->i_sb->s_dev;
+               __entry->pos    = offset;
+               __entry->len    = len;
+               __entry->rw     = rw;
+       ),
+
+       TP_printk("dev %d,%d ino %lu pos %llu len %lu rw %d",
+                 MAJOR(__entry->dev), MINOR(__entry->dev),
+                 (unsigned long) __entry->ino,
+                 (unsigned long long) __entry->pos, __entry->len,
+                 __entry->rw)
+);
+
+TRACE_EVENT(ext3_direct_IO_exit,
+       TP_PROTO(struct inode *inode, loff_t offset, unsigned long len,
+                int rw, int ret),
+
+       TP_ARGS(inode, offset, len, rw, ret),
+
+       TP_STRUCT__entry(
+               __field(        ino_t,  ino                     )
+               __field(        dev_t,  dev                     )
+               __field(        loff_t, pos                     )
+               __field(        unsigned long,  len             )
+               __field(        int,    rw                      )
+               __field(        int,    ret                     )
+       ),
+
+       TP_fast_assign(
+               __entry->ino    = inode->i_ino;
+               __entry->dev    = inode->i_sb->s_dev;
+               __entry->pos    = offset;
+               __entry->len    = len;
+               __entry->rw     = rw;
+               __entry->ret    = ret;
+       ),
+
+       TP_printk("dev %d,%d ino %lu pos %llu len %lu rw %d ret %d",
+                 MAJOR(__entry->dev), MINOR(__entry->dev),
+                 (unsigned long) __entry->ino,
+                 (unsigned long long) __entry->pos, __entry->len,
+                 __entry->rw, __entry->ret)
+);
+
+TRACE_EVENT(ext3_unlink_enter,
+       TP_PROTO(struct inode *parent, struct dentry *dentry),
+
+       TP_ARGS(parent, dentry),
+
+       TP_STRUCT__entry(
+               __field(        ino_t,  parent                  )
+               __field(        ino_t,  ino                     )
+               __field(        loff_t, size                    )
+               __field(        dev_t,  dev                     )
+       ),
+
+       TP_fast_assign(
+               __entry->parent         = parent->i_ino;
+               __entry->ino            = dentry->d_inode->i_ino;
+               __entry->size           = dentry->d_inode->i_size;
+               __entry->dev            = dentry->d_inode->i_sb->s_dev;
+       ),
+
+       TP_printk("dev %d,%d ino %lu size %lld parent %ld",
+                 MAJOR(__entry->dev), MINOR(__entry->dev),
+                 (unsigned long) __entry->ino,
+                 (unsigned long long)__entry->size,
+                 (unsigned long) __entry->parent)
+);
+
+TRACE_EVENT(ext3_unlink_exit,
+       TP_PROTO(struct dentry *dentry, int ret),
+
+       TP_ARGS(dentry, ret),
+
+       TP_STRUCT__entry(
+               __field(        ino_t,  ino                     )
+               __field(        dev_t,  dev                     )
+               __field(        int,    ret                     )
+       ),
+
+       TP_fast_assign(
+               __entry->ino            = dentry->d_inode->i_ino;
+               __entry->dev            = dentry->d_inode->i_sb->s_dev;
+               __entry->ret            = ret;
+       ),
+
+       TP_printk("dev %d,%d ino %lu ret %d",
+                 MAJOR(__entry->dev), MINOR(__entry->dev),
+                 (unsigned long) __entry->ino,
+                 __entry->ret)
+);
+
+DECLARE_EVENT_CLASS(ext3__truncate,
+       TP_PROTO(struct inode *inode),
+
+       TP_ARGS(inode),
+
+       TP_STRUCT__entry(
+               __field(        ino_t,          ino             )
+               __field(        dev_t,          dev             )
+               __field(        blkcnt_t,       blocks          )
+       ),
+
+       TP_fast_assign(
+               __entry->ino    = inode->i_ino;
+               __entry->dev    = inode->i_sb->s_dev;
+               __entry->blocks = inode->i_blocks;
+       ),
+
+       TP_printk("dev %d,%d ino %lu blocks %lu",
+                 MAJOR(__entry->dev), MINOR(__entry->dev),
+                 (unsigned long) __entry->ino, (unsigned long) __entry->blocks)
+);
+
+DEFINE_EVENT(ext3__truncate, ext3_truncate_enter,
+
+       TP_PROTO(struct inode *inode),
+
+       TP_ARGS(inode)
+);
+
+DEFINE_EVENT(ext3__truncate, ext3_truncate_exit,
+
+       TP_PROTO(struct inode *inode),
+
+       TP_ARGS(inode)
+);
+
+TRACE_EVENT(ext3_get_blocks_enter,
+       TP_PROTO(struct inode *inode, unsigned long lblk,
+                unsigned long len, int create),
+
+       TP_ARGS(inode, lblk, len, create),
+
+       TP_STRUCT__entry(
+               __field(        ino_t,          ino             )
+               __field(        dev_t,          dev             )
+               __field(        unsigned long,  lblk            )
+               __field(        unsigned long,  len             )
+               __field(        int,            create          )
+       ),
+
+       TP_fast_assign(
+               __entry->ino    = inode->i_ino;
+               __entry->dev    = inode->i_sb->s_dev;
+               __entry->lblk   = lblk;
+               __entry->len    = len;
+               __entry->create = create;
+       ),
+
+       TP_printk("dev %d,%d ino %lu lblk %lu len %lu create %u",
+                 MAJOR(__entry->dev), MINOR(__entry->dev),
+                 (unsigned long) __entry->ino,
+                 __entry->lblk, __entry->len, __entry->create)
+);
+
+TRACE_EVENT(ext3_get_blocks_exit,
+       TP_PROTO(struct inode *inode, unsigned long lblk,
+                unsigned long pblk, unsigned long len, int ret),
+
+       TP_ARGS(inode, lblk, pblk, len, ret),
+
+       TP_STRUCT__entry(
+               __field(        ino_t,          ino             )
+               __field(        dev_t,          dev             )
+               __field(        unsigned long,  lblk            )
+               __field(        unsigned long,  pblk            )
+               __field(        unsigned long,  len             )
+               __field(        int,            ret             )
+       ),
+
+       TP_fast_assign(
+               __entry->ino    = inode->i_ino;
+               __entry->dev    = inode->i_sb->s_dev;
+               __entry->lblk   = lblk;
+               __entry->pblk   = pblk;
+               __entry->len    = len;
+               __entry->ret    = ret;
+       ),
+
+       TP_printk("dev %d,%d ino %lu lblk %lu pblk %lu len %lu ret %d",
+                 MAJOR(__entry->dev), MINOR(__entry->dev),
+                 (unsigned long) __entry->ino,
+                  __entry->lblk, __entry->pblk,
+                 __entry->len, __entry->ret)
+);
+
+TRACE_EVENT(ext3_load_inode,
+       TP_PROTO(struct inode *inode),
+
+       TP_ARGS(inode),
+
+       TP_STRUCT__entry(
+               __field(        ino_t,  ino             )
+               __field(        dev_t,  dev             )
+       ),
+
+       TP_fast_assign(
+               __entry->ino            = inode->i_ino;
+               __entry->dev            = inode->i_sb->s_dev;
+       ),
+
+       TP_printk("dev %d,%d ino %lu",
+                 MAJOR(__entry->dev), MINOR(__entry->dev),
+                 (unsigned long) __entry->ino)
+);
+
+#endif /* _TRACE_EXT3_H */
+
+/* This part must be outside protection */
+#include <trace/define_trace.h>
diff --git a/drivers/staging/lttng/instrumentation/events/mainline/ext4.h b/drivers/staging/lttng/instrumentation/events/mainline/ext4.h
new file mode 100644 (file)
index 0000000..d49b285
--- /dev/null
@@ -0,0 +1,2061 @@
+#undef TRACE_SYSTEM
+#define TRACE_SYSTEM ext4
+
+#if !defined(_TRACE_EXT4_H) || defined(TRACE_HEADER_MULTI_READ)
+#define _TRACE_EXT4_H
+
+#include <linux/writeback.h>
+#include <linux/tracepoint.h>
+
+struct ext4_allocation_context;
+struct ext4_allocation_request;
+struct ext4_extent;
+struct ext4_prealloc_space;
+struct ext4_inode_info;
+struct mpage_da_data;
+struct ext4_map_blocks;
+struct ext4_extent;
+
+#define EXT4_I(inode) (container_of(inode, struct ext4_inode_info, vfs_inode))
+
+TRACE_EVENT(ext4_free_inode,
+       TP_PROTO(struct inode *inode),
+
+       TP_ARGS(inode),
+
+       TP_STRUCT__entry(
+               __field(        dev_t,  dev                     )
+               __field(        ino_t,  ino                     )
+               __field(        uid_t,  uid                     )
+               __field(        gid_t,  gid                     )
+               __field(        __u64, blocks                   )
+               __field(        __u16, mode                     )
+       ),
+
+       TP_fast_assign(
+               __entry->dev    = inode->i_sb->s_dev;
+               __entry->ino    = inode->i_ino;
+               __entry->uid    = i_uid_read(inode);
+               __entry->gid    = i_gid_read(inode);
+               __entry->blocks = inode->i_blocks;
+               __entry->mode   = inode->i_mode;
+       ),
+
+       TP_printk("dev %d,%d ino %lu mode 0%o uid %u gid %u blocks %llu",
+                 MAJOR(__entry->dev), MINOR(__entry->dev),
+                 (unsigned long) __entry->ino, __entry->mode,
+                 __entry->uid, __entry->gid, __entry->blocks)
+);
+
+TRACE_EVENT(ext4_request_inode,
+       TP_PROTO(struct inode *dir, int mode),
+
+       TP_ARGS(dir, mode),
+
+       TP_STRUCT__entry(
+               __field(        dev_t,  dev                     )
+               __field(        ino_t,  dir                     )
+               __field(        __u16, mode                     )
+       ),
+
+       TP_fast_assign(
+               __entry->dev    = dir->i_sb->s_dev;
+               __entry->dir    = dir->i_ino;
+               __entry->mode   = mode;
+       ),
+
+       TP_printk("dev %d,%d dir %lu mode 0%o",
+                 MAJOR(__entry->dev), MINOR(__entry->dev),
+                 (unsigned long) __entry->dir, __entry->mode)
+);
+
+TRACE_EVENT(ext4_allocate_inode,
+       TP_PROTO(struct inode *inode, struct inode *dir, int mode),
+
+       TP_ARGS(inode, dir, mode),
+
+       TP_STRUCT__entry(
+               __field(        dev_t,  dev                     )
+               __field(        ino_t,  ino                     )
+               __field(        ino_t,  dir                     )
+               __field(        __u16,  mode                    )
+       ),
+
+       TP_fast_assign(
+               __entry->dev    = inode->i_sb->s_dev;
+               __entry->ino    = inode->i_ino;
+               __entry->dir    = dir->i_ino;
+               __entry->mode   = mode;
+       ),
+
+       TP_printk("dev %d,%d ino %lu dir %lu mode 0%o",
+                 MAJOR(__entry->dev), MINOR(__entry->dev),
+                 (unsigned long) __entry->ino,
+                 (unsigned long) __entry->dir, __entry->mode)
+);
+
+TRACE_EVENT(ext4_evict_inode,
+       TP_PROTO(struct inode *inode),
+
+       TP_ARGS(inode),
+
+       TP_STRUCT__entry(
+               __field(        dev_t,  dev                     )
+               __field(        ino_t,  ino                     )
+               __field(        int,    nlink                   )
+       ),
+
+       TP_fast_assign(
+               __entry->dev    = inode->i_sb->s_dev;
+               __entry->ino    = inode->i_ino;
+               __entry->nlink  = inode->i_nlink;
+       ),
+
+       TP_printk("dev %d,%d ino %lu nlink %d",
+                 MAJOR(__entry->dev), MINOR(__entry->dev),
+                 (unsigned long) __entry->ino, __entry->nlink)
+);
+
+TRACE_EVENT(ext4_drop_inode,
+       TP_PROTO(struct inode *inode, int drop),
+
+       TP_ARGS(inode, drop),
+
+       TP_STRUCT__entry(
+               __field(        dev_t,  dev                     )
+               __field(        ino_t,  ino                     )
+               __field(        int,    drop                    )
+       ),
+
+       TP_fast_assign(
+               __entry->dev    = inode->i_sb->s_dev;
+               __entry->ino    = inode->i_ino;
+               __entry->drop   = drop;
+       ),
+
+       TP_printk("dev %d,%d ino %lu drop %d",
+                 MAJOR(__entry->dev), MINOR(__entry->dev),
+                 (unsigned long) __entry->ino, __entry->drop)
+);
+
+TRACE_EVENT(ext4_mark_inode_dirty,
+       TP_PROTO(struct inode *inode, unsigned long IP),
+
+       TP_ARGS(inode, IP),
+
+       TP_STRUCT__entry(
+               __field(        dev_t,  dev                     )
+               __field(        ino_t,  ino                     )
+               __field(unsigned long,  ip                      )
+       ),
+
+       TP_fast_assign(
+               __entry->dev    = inode->i_sb->s_dev;
+               __entry->ino    = inode->i_ino;
+               __entry->ip     = IP;
+       ),
+
+       TP_printk("dev %d,%d ino %lu caller %pF",
+                 MAJOR(__entry->dev), MINOR(__entry->dev),
+                 (unsigned long) __entry->ino, (void *)__entry->ip)
+);
+
+TRACE_EVENT(ext4_begin_ordered_truncate,
+       TP_PROTO(struct inode *inode, loff_t new_size),
+
+       TP_ARGS(inode, new_size),
+
+       TP_STRUCT__entry(
+               __field(        dev_t,  dev                     )
+               __field(        ino_t,  ino                     )
+               __field(        loff_t, new_size                )
+       ),
+
+       TP_fast_assign(
+               __entry->dev            = inode->i_sb->s_dev;
+               __entry->ino            = inode->i_ino;
+               __entry->new_size       = new_size;
+       ),
+
+       TP_printk("dev %d,%d ino %lu new_size %lld",
+                 MAJOR(__entry->dev), MINOR(__entry->dev),
+                 (unsigned long) __entry->ino,
+                 __entry->new_size)
+);
+
+DECLARE_EVENT_CLASS(ext4__write_begin,
+
+       TP_PROTO(struct inode *inode, loff_t pos, unsigned int len,
+                unsigned int flags),
+
+       TP_ARGS(inode, pos, len, flags),
+
+       TP_STRUCT__entry(
+               __field(        dev_t,  dev                     )
+               __field(        ino_t,  ino                     )
+               __field(        loff_t, pos                     )
+               __field(        unsigned int, len               )
+               __field(        unsigned int, flags             )
+       ),
+
+       TP_fast_assign(
+               __entry->dev    = inode->i_sb->s_dev;
+               __entry->ino    = inode->i_ino;
+               __entry->pos    = pos;
+               __entry->len    = len;
+               __entry->flags  = flags;
+       ),
+
+       TP_printk("dev %d,%d ino %lu pos %lld len %u flags %u",
+                 MAJOR(__entry->dev), MINOR(__entry->dev),
+                 (unsigned long) __entry->ino,
+                 __entry->pos, __entry->len, __entry->flags)
+);
+
+DEFINE_EVENT(ext4__write_begin, ext4_write_begin,
+
+       TP_PROTO(struct inode *inode, loff_t pos, unsigned int len,
+                unsigned int flags),
+
+       TP_ARGS(inode, pos, len, flags)
+);
+
+DEFINE_EVENT(ext4__write_begin, ext4_da_write_begin,
+
+       TP_PROTO(struct inode *inode, loff_t pos, unsigned int len,
+                unsigned int flags),
+
+       TP_ARGS(inode, pos, len, flags)
+);
+
+DECLARE_EVENT_CLASS(ext4__write_end,
+       TP_PROTO(struct inode *inode, loff_t pos, unsigned int len,
+                       unsigned int copied),
+
+       TP_ARGS(inode, pos, len, copied),
+
+       TP_STRUCT__entry(
+               __field(        dev_t,  dev                     )
+               __field(        ino_t,  ino                     )
+               __field(        loff_t, pos                     )
+               __field(        unsigned int, len               )
+               __field(        unsigned int, copied            )
+       ),
+
+       TP_fast_assign(
+               __entry->dev    = inode->i_sb->s_dev;
+               __entry->ino    = inode->i_ino;
+               __entry->pos    = pos;
+               __entry->len    = len;
+               __entry->copied = copied;
+       ),
+
+       TP_printk("dev %d,%d ino %lu pos %lld len %u copied %u",
+                 MAJOR(__entry->dev), MINOR(__entry->dev),
+                 (unsigned long) __entry->ino,
+                 __entry->pos, __entry->len, __entry->copied)
+);
+
+DEFINE_EVENT(ext4__write_end, ext4_ordered_write_end,
+
+       TP_PROTO(struct inode *inode, loff_t pos, unsigned int len,
+                unsigned int copied),
+
+       TP_ARGS(inode, pos, len, copied)
+);
+
+DEFINE_EVENT(ext4__write_end, ext4_writeback_write_end,
+
+       TP_PROTO(struct inode *inode, loff_t pos, unsigned int len,
+                unsigned int copied),
+
+       TP_ARGS(inode, pos, len, copied)
+);
+
+DEFINE_EVENT(ext4__write_end, ext4_journalled_write_end,
+
+       TP_PROTO(struct inode *inode, loff_t pos, unsigned int len,
+                unsigned int copied),
+
+       TP_ARGS(inode, pos, len, copied)
+);
+
+DEFINE_EVENT(ext4__write_end, ext4_da_write_end,
+
+       TP_PROTO(struct inode *inode, loff_t pos, unsigned int len,
+                unsigned int copied),
+
+       TP_ARGS(inode, pos, len, copied)
+);
+
+TRACE_EVENT(ext4_da_writepages,
+       TP_PROTO(struct inode *inode, struct writeback_control *wbc),
+
+       TP_ARGS(inode, wbc),
+
+       TP_STRUCT__entry(
+               __field(        dev_t,  dev                     )
+               __field(        ino_t,  ino                     )
+               __field(        long,   nr_to_write             )
+               __field(        long,   pages_skipped           )
+               __field(        loff_t, range_start             )
+               __field(        loff_t, range_end               )
+               __field(       pgoff_t, writeback_index         )
+               __field(        int,    sync_mode               )
+               __field(        char,   for_kupdate             )
+               __field(        char,   range_cyclic            )
+       ),
+
+       TP_fast_assign(
+               __entry->dev            = inode->i_sb->s_dev;
+               __entry->ino            = inode->i_ino;
+               __entry->nr_to_write    = wbc->nr_to_write;
+               __entry->pages_skipped  = wbc->pages_skipped;
+               __entry->range_start    = wbc->range_start;
+               __entry->range_end      = wbc->range_end;
+               __entry->writeback_index = inode->i_mapping->writeback_index;
+               __entry->sync_mode      = wbc->sync_mode;
+               __entry->for_kupdate    = wbc->for_kupdate;
+               __entry->range_cyclic   = wbc->range_cyclic;
+       ),
+
+       TP_printk("dev %d,%d ino %lu nr_to_write %ld pages_skipped %ld "
+                 "range_start %lld range_end %lld sync_mode %d "
+                 "for_kupdate %d range_cyclic %d writeback_index %lu",
+                 MAJOR(__entry->dev), MINOR(__entry->dev),
+                 (unsigned long) __entry->ino, __entry->nr_to_write,
+                 __entry->pages_skipped, __entry->range_start,
+                 __entry->range_end, __entry->sync_mode,
+                 __entry->for_kupdate, __entry->range_cyclic,
+                 (unsigned long) __entry->writeback_index)
+);
+
+TRACE_EVENT(ext4_da_write_pages,
+       TP_PROTO(struct inode *inode, struct mpage_da_data *mpd),
+
+       TP_ARGS(inode, mpd),
+
+       TP_STRUCT__entry(
+               __field(        dev_t,  dev                     )
+               __field(        ino_t,  ino                     )
+               __field(        __u64,  b_blocknr               )
+               __field(        __u32,  b_size                  )
+               __field(        __u32,  b_state                 )
+               __field(        unsigned long,  first_page      )
+               __field(        int,    io_done                 )
+               __field(        int,    pages_written           )
+               __field(        int,    sync_mode               )
+       ),
+
+       TP_fast_assign(
+               __entry->dev            = inode->i_sb->s_dev;
+               __entry->ino            = inode->i_ino;
+               __entry->b_blocknr      = mpd->b_blocknr;
+               __entry->b_size         = mpd->b_size;
+               __entry->b_state        = mpd->b_state;
+               __entry->first_page     = mpd->first_page;
+               __entry->io_done        = mpd->io_done;
+               __entry->pages_written  = mpd->pages_written;
+               __entry->sync_mode      = mpd->wbc->sync_mode;
+       ),
+
+       TP_printk("dev %d,%d ino %lu b_blocknr %llu b_size %u b_state 0x%04x "
+                 "first_page %lu io_done %d pages_written %d sync_mode %d",
+                 MAJOR(__entry->dev), MINOR(__entry->dev),
+                 (unsigned long) __entry->ino,
+                 __entry->b_blocknr, __entry->b_size,
+                 __entry->b_state, __entry->first_page,
+                 __entry->io_done, __entry->pages_written,
+                 __entry->sync_mode
+                  )
+);
+
+TRACE_EVENT(ext4_da_writepages_result,
+       TP_PROTO(struct inode *inode, struct writeback_control *wbc,
+                       int ret, int pages_written),
+
+       TP_ARGS(inode, wbc, ret, pages_written),
+
+       TP_STRUCT__entry(
+               __field(        dev_t,  dev                     )
+               __field(        ino_t,  ino                     )
+               __field(        int,    ret                     )
+               __field(        int,    pages_written           )
+               __field(        long,   pages_skipped           )
+               __field(       pgoff_t, writeback_index         )
+               __field(        int,    sync_mode               )
+       ),
+
+       TP_fast_assign(
+               __entry->dev            = inode->i_sb->s_dev;
+               __entry->ino            = inode->i_ino;
+               __entry->ret            = ret;
+               __entry->pages_written  = pages_written;
+               __entry->pages_skipped  = wbc->pages_skipped;
+               __entry->writeback_index = inode->i_mapping->writeback_index;
+               __entry->sync_mode      = wbc->sync_mode;
+       ),
+
+       TP_printk("dev %d,%d ino %lu ret %d pages_written %d pages_skipped %ld "
+                 "sync_mode %d writeback_index %lu",
+                 MAJOR(__entry->dev), MINOR(__entry->dev),
+                 (unsigned long) __entry->ino, __entry->ret,
+                 __entry->pages_written, __entry->pages_skipped,
+                 __entry->sync_mode,
+                 (unsigned long) __entry->writeback_index)
+);
+
+DECLARE_EVENT_CLASS(ext4__page_op,
+       TP_PROTO(struct page *page),
+
+       TP_ARGS(page),
+
+       TP_STRUCT__entry(
+               __field(        dev_t,  dev                     )
+               __field(        ino_t,  ino                     )
+               __field(        pgoff_t, index                  )
+
+       ),
+
+       TP_fast_assign(
+               __entry->dev    = page->mapping->host->i_sb->s_dev;
+               __entry->ino    = page->mapping->host->i_ino;
+               __entry->index  = page->index;
+       ),
+
+       TP_printk("dev %d,%d ino %lu page_index %lu",
+                 MAJOR(__entry->dev), MINOR(__entry->dev),
+                 (unsigned long) __entry->ino,
+                 (unsigned long) __entry->index)
+);
+
+DEFINE_EVENT(ext4__page_op, ext4_writepage,
+
+       TP_PROTO(struct page *page),
+
+       TP_ARGS(page)
+);
+
+DEFINE_EVENT(ext4__page_op, ext4_readpage,
+
+       TP_PROTO(struct page *page),
+
+       TP_ARGS(page)
+);
+
+DEFINE_EVENT(ext4__page_op, ext4_releasepage,
+
+       TP_PROTO(struct page *page),
+
+       TP_ARGS(page)
+);
+
+TRACE_EVENT(ext4_invalidatepage,
+       TP_PROTO(struct page *page, unsigned long offset),
+
+       TP_ARGS(page, offset),
+
+       TP_STRUCT__entry(
+               __field(        dev_t,  dev                     )
+               __field(        ino_t,  ino                     )
+               __field(        pgoff_t, index                  )
+               __field(        unsigned long, offset           )
+
+       ),
+
+       TP_fast_assign(
+               __entry->dev    = page->mapping->host->i_sb->s_dev;
+               __entry->ino    = page->mapping->host->i_ino;
+               __entry->index  = page->index;
+               __entry->offset = offset;
+       ),
+
+       TP_printk("dev %d,%d ino %lu page_index %lu offset %lu",
+                 MAJOR(__entry->dev), MINOR(__entry->dev),
+                 (unsigned long) __entry->ino,
+                 (unsigned long) __entry->index, __entry->offset)
+);
+
+TRACE_EVENT(ext4_discard_blocks,
+       TP_PROTO(struct super_block *sb, unsigned long long blk,
+                       unsigned long long count),
+
+       TP_ARGS(sb, blk, count),
+
+       TP_STRUCT__entry(
+               __field(        dev_t,  dev                     )
+               __field(        __u64,  blk                     )
+               __field(        __u64,  count                   )
+
+       ),
+
+       TP_fast_assign(
+               __entry->dev    = sb->s_dev;
+               __entry->blk    = blk;
+               __entry->count  = count;
+       ),
+
+       TP_printk("dev %d,%d blk %llu count %llu",
+                 MAJOR(__entry->dev), MINOR(__entry->dev),
+                 __entry->blk, __entry->count)
+);
+
+DECLARE_EVENT_CLASS(ext4__mb_new_pa,
+       TP_PROTO(struct ext4_allocation_context *ac,
+                struct ext4_prealloc_space *pa),
+
+       TP_ARGS(ac, pa),
+
+       TP_STRUCT__entry(
+               __field(        dev_t,  dev                     )
+               __field(        ino_t,  ino                     )
+               __field(        __u64,  pa_pstart               )
+               __field(        __u64,  pa_lstart               )
+               __field(        __u32,  pa_len                  )
+
+       ),
+
+       TP_fast_assign(
+               __entry->dev            = ac->ac_sb->s_dev;
+               __entry->ino            = ac->ac_inode->i_ino;
+               __entry->pa_pstart      = pa->pa_pstart;
+               __entry->pa_lstart      = pa->pa_lstart;
+               __entry->pa_len         = pa->pa_len;
+       ),
+
+       TP_printk("dev %d,%d ino %lu pstart %llu len %u lstart %llu",
+                 MAJOR(__entry->dev), MINOR(__entry->dev),
+                 (unsigned long) __entry->ino,
+                 __entry->pa_pstart, __entry->pa_len, __entry->pa_lstart)
+);
+
+DEFINE_EVENT(ext4__mb_new_pa, ext4_mb_new_inode_pa,
+
+       TP_PROTO(struct ext4_allocation_context *ac,
+                struct ext4_prealloc_space *pa),
+
+       TP_ARGS(ac, pa)
+);
+
+DEFINE_EVENT(ext4__mb_new_pa, ext4_mb_new_group_pa,
+
+       TP_PROTO(struct ext4_allocation_context *ac,
+                struct ext4_prealloc_space *pa),
+
+       TP_ARGS(ac, pa)
+);
+
+TRACE_EVENT(ext4_mb_release_inode_pa,
+       TP_PROTO(struct ext4_prealloc_space *pa,
+                unsigned long long block, unsigned int count),
+
+       TP_ARGS(pa, block, count),
+
+       TP_STRUCT__entry(
+               __field(        dev_t,  dev                     )
+               __field(        ino_t,  ino                     )
+               __field(        __u64,  block                   )
+               __field(        __u32,  count                   )
+
+       ),
+
+       TP_fast_assign(
+               __entry->dev            = pa->pa_inode->i_sb->s_dev;
+               __entry->ino            = pa->pa_inode->i_ino;
+               __entry->block          = block;
+               __entry->count          = count;
+       ),
+
+       TP_printk("dev %d,%d ino %lu block %llu count %u",
+                 MAJOR(__entry->dev), MINOR(__entry->dev),
+                 (unsigned long) __entry->ino,
+                 __entry->block, __entry->count)
+);
+
+TRACE_EVENT(ext4_mb_release_group_pa,
+       TP_PROTO(struct super_block *sb, struct ext4_prealloc_space *pa),
+
+       TP_ARGS(sb, pa),
+
+       TP_STRUCT__entry(
+               __field(        dev_t,  dev                     )
+               __field(        __u64,  pa_pstart               )
+               __field(        __u32,  pa_len                  )
+
+       ),
+
+       TP_fast_assign(
+               __entry->dev            = sb->s_dev;
+               __entry->pa_pstart      = pa->pa_pstart;
+               __entry->pa_len         = pa->pa_len;
+       ),
+
+       TP_printk("dev %d,%d pstart %llu len %u",
+                 MAJOR(__entry->dev), MINOR(__entry->dev),
+                 __entry->pa_pstart, __entry->pa_len)
+);
+
+TRACE_EVENT(ext4_discard_preallocations,
+       TP_PROTO(struct inode *inode),
+
+       TP_ARGS(inode),
+
+       TP_STRUCT__entry(
+               __field(        dev_t,  dev                     )
+               __field(        ino_t,  ino                     )
+
+       ),
+
+       TP_fast_assign(
+               __entry->dev    = inode->i_sb->s_dev;
+               __entry->ino    = inode->i_ino;
+       ),
+
+       TP_printk("dev %d,%d ino %lu",
+                 MAJOR(__entry->dev), MINOR(__entry->dev),
+                 (unsigned long) __entry->ino)
+);
+
+TRACE_EVENT(ext4_mb_discard_preallocations,
+       TP_PROTO(struct super_block *sb, int needed),
+
+       TP_ARGS(sb, needed),
+
+       TP_STRUCT__entry(
+               __field(        dev_t,  dev                     )
+               __field(        int,    needed                  )
+
+       ),
+
+       TP_fast_assign(
+               __entry->dev    = sb->s_dev;
+               __entry->needed = needed;
+       ),
+
+       TP_printk("dev %d,%d needed %d",
+                 MAJOR(__entry->dev), MINOR(__entry->dev),
+                 __entry->needed)
+);
+
+TRACE_EVENT(ext4_request_blocks,
+       TP_PROTO(struct ext4_allocation_request *ar),
+
+       TP_ARGS(ar),
+
+       TP_STRUCT__entry(
+               __field(        dev_t,  dev                     )
+               __field(        ino_t,  ino                     )
+               __field(        unsigned int, len               )
+               __field(        __u32,  logical                 )
+               __field(        __u32,  lleft                   )
+               __field(        __u32,  lright                  )
+               __field(        __u64,  goal                    )
+               __field(        __u64,  pleft                   )
+               __field(        __u64,  pright                  )
+               __field(        unsigned int, flags             )
+       ),
+
+       TP_fast_assign(
+               __entry->dev    = ar->inode->i_sb->s_dev;
+               __entry->ino    = ar->inode->i_ino;
+               __entry->len    = ar->len;
+               __entry->logical = ar->logical;
+               __entry->goal   = ar->goal;
+               __entry->lleft  = ar->lleft;
+               __entry->lright = ar->lright;
+               __entry->pleft  = ar->pleft;
+               __entry->pright = ar->pright;
+               __entry->flags  = ar->flags;
+       ),
+
+       TP_printk("dev %d,%d ino %lu flags %u len %u lblk %u goal %llu "
+                 "lleft %u lright %u pleft %llu pright %llu ",
+                 MAJOR(__entry->dev), MINOR(__entry->dev),
+                 (unsigned long) __entry->ino, __entry->flags,
+                 __entry->len, __entry->logical, __entry->goal,
+                 __entry->lleft, __entry->lright, __entry->pleft,
+                 __entry->pright)
+);
+
+TRACE_EVENT(ext4_allocate_blocks,
+       TP_PROTO(struct ext4_allocation_request *ar, unsigned long long block),
+
+       TP_ARGS(ar, block),
+
+       TP_STRUCT__entry(
+               __field(        dev_t,  dev                     )
+               __field(        ino_t,  ino                     )
+               __field(        __u64,  block                   )
+               __field(        unsigned int, len               )
+               __field(        __u32,  logical                 )
+               __field(        __u32,  lleft                   )
+               __field(        __u32,  lright                  )
+               __field(        __u64,  goal                    )
+               __field(        __u64,  pleft                   )
+               __field(        __u64,  pright                  )
+               __field(        unsigned int, flags             )
+       ),
+
+       TP_fast_assign(
+               __entry->dev    = ar->inode->i_sb->s_dev;
+               __entry->ino    = ar->inode->i_ino;
+               __entry->block  = block;
+               __entry->len    = ar->len;
+               __entry->logical = ar->logical;
+               __entry->goal   = ar->goal;
+               __entry->lleft  = ar->lleft;
+               __entry->lright = ar->lright;
+               __entry->pleft  = ar->pleft;
+               __entry->pright = ar->pright;
+               __entry->flags  = ar->flags;
+       ),
+
+       TP_printk("dev %d,%d ino %lu flags %u len %u block %llu lblk %u "
+                 "goal %llu lleft %u lright %u pleft %llu pright %llu",
+                 MAJOR(__entry->dev), MINOR(__entry->dev),
+                 (unsigned long) __entry->ino, __entry->flags,
+                 __entry->len, __entry->block, __entry->logical,
+                 __entry->goal,  __entry->lleft, __entry->lright,
+                 __entry->pleft, __entry->pright)
+);
+
+TRACE_EVENT(ext4_free_blocks,
+       TP_PROTO(struct inode *inode, __u64 block, unsigned long count,
+                int flags),
+
+       TP_ARGS(inode, block, count, flags),
+
+       TP_STRUCT__entry(
+               __field(        dev_t,  dev                     )
+               __field(        ino_t,  ino                     )
+               __field(        __u64,  block                   )
+               __field(        unsigned long,  count           )
+               __field(        int,    flags                   )
+               __field(        __u16,  mode                    )
+       ),
+
+       TP_fast_assign(
+               __entry->dev            = inode->i_sb->s_dev;
+               __entry->ino            = inode->i_ino;
+               __entry->block          = block;
+               __entry->count          = count;
+               __entry->flags          = flags;
+               __entry->mode           = inode->i_mode;
+       ),
+
+       TP_printk("dev %d,%d ino %lu mode 0%o block %llu count %lu flags %d",
+                 MAJOR(__entry->dev), MINOR(__entry->dev),
+                 (unsigned long) __entry->ino,
+                 __entry->mode, __entry->block, __entry->count,
+                 __entry->flags)
+);
+
+TRACE_EVENT(ext4_sync_file_enter,
+       TP_PROTO(struct file *file, int datasync),
+
+       TP_ARGS(file, datasync),
+
+       TP_STRUCT__entry(
+               __field(        dev_t,  dev                     )
+               __field(        ino_t,  ino                     )
+               __field(        ino_t,  parent                  )
+               __field(        int,    datasync                )
+       ),
+
+       TP_fast_assign(
+               struct dentry *dentry = file->f_path.dentry;
+
+               __entry->dev            = dentry->d_inode->i_sb->s_dev;
+               __entry->ino            = dentry->d_inode->i_ino;
+               __entry->datasync       = datasync;
+               __entry->parent         = dentry->d_parent->d_inode->i_ino;
+       ),
+
+       TP_printk("dev %d,%d ino %lu parent %lu datasync %d ",
+                 MAJOR(__entry->dev), MINOR(__entry->dev),
+                 (unsigned long) __entry->ino,
+                 (unsigned long) __entry->parent, __entry->datasync)
+);
+
+TRACE_EVENT(ext4_sync_file_exit,
+       TP_PROTO(struct inode *inode, int ret),
+
+       TP_ARGS(inode, ret),
+
+       TP_STRUCT__entry(
+               __field(        dev_t,  dev                     )
+               __field(        ino_t,  ino                     )
+               __field(        int,    ret                     )
+       ),
+
+       TP_fast_assign(
+               __entry->dev            = inode->i_sb->s_dev;
+               __entry->ino            = inode->i_ino;
+               __entry->ret            = ret;
+       ),
+
+       TP_printk("dev %d,%d ino %lu ret %d",
+                 MAJOR(__entry->dev), MINOR(__entry->dev),
+                 (unsigned long) __entry->ino,
+                 __entry->ret)
+);
+
+TRACE_EVENT(ext4_sync_fs,
+       TP_PROTO(struct super_block *sb, int wait),
+
+       TP_ARGS(sb, wait),
+
+       TP_STRUCT__entry(
+               __field(        dev_t,  dev                     )
+               __field(        int,    wait                    )
+
+       ),
+
+       TP_fast_assign(
+               __entry->dev    = sb->s_dev;
+               __entry->wait   = wait;
+       ),
+
+       TP_printk("dev %d,%d wait %d",
+                 MAJOR(__entry->dev), MINOR(__entry->dev),
+                 __entry->wait)
+);
+
+TRACE_EVENT(ext4_alloc_da_blocks,
+       TP_PROTO(struct inode *inode),
+
+       TP_ARGS(inode),
+
+       TP_STRUCT__entry(
+               __field(        dev_t,  dev                     )
+               __field(        ino_t,  ino                     )
+               __field( unsigned int,  data_blocks     )
+               __field( unsigned int,  meta_blocks     )
+       ),
+
+       TP_fast_assign(
+               __entry->dev    = inode->i_sb->s_dev;
+               __entry->ino    = inode->i_ino;
+               __entry->data_blocks = EXT4_I(inode)->i_reserved_data_blocks;
+               __entry->meta_blocks = EXT4_I(inode)->i_reserved_meta_blocks;
+       ),
+
+       TP_printk("dev %d,%d ino %lu data_blocks %u meta_blocks %u",
+                 MAJOR(__entry->dev), MINOR(__entry->dev),
+                 (unsigned long) __entry->ino,
+                 __entry->data_blocks, __entry->meta_blocks)
+);
+
+TRACE_EVENT(ext4_mballoc_alloc,
+       TP_PROTO(struct ext4_allocation_context *ac),
+
+       TP_ARGS(ac),
+
+       TP_STRUCT__entry(
+               __field(        dev_t,  dev                     )
+               __field(        ino_t,  ino                     )
+               __field(        __u32,  orig_logical            )
+               __field(          int,  orig_start              )
+               __field(        __u32,  orig_group              )
+               __field(          int,  orig_len                )
+               __field(        __u32,  goal_logical            )
+               __field(          int,  goal_start              )
+               __field(        __u32,  goal_group              )
+               __field(          int,  goal_len                )
+               __field(        __u32,  result_logical          )
+               __field(          int,  result_start            )
+               __field(        __u32,  result_group            )
+               __field(          int,  result_len              )
+               __field(        __u16,  found                   )
+               __field(        __u16,  groups                  )
+               __field(        __u16,  buddy                   )
+               __field(        __u16,  flags                   )
+               __field(        __u16,  tail                    )
+               __field(        __u8,   cr                      )
+       ),
+
+       TP_fast_assign(
+               __entry->dev            = ac->ac_inode->i_sb->s_dev;
+               __entry->ino            = ac->ac_inode->i_ino;
+               __entry->orig_logical   = ac->ac_o_ex.fe_logical;
+               __entry->orig_start     = ac->ac_o_ex.fe_start;
+               __entry->orig_group     = ac->ac_o_ex.fe_group;
+               __entry->orig_len       = ac->ac_o_ex.fe_len;
+               __entry->goal_logical   = ac->ac_g_ex.fe_logical;
+               __entry->goal_start     = ac->ac_g_ex.fe_start;
+               __entry->goal_group     = ac->ac_g_ex.fe_group;
+               __entry->goal_len       = ac->ac_g_ex.fe_len;
+               __entry->result_logical = ac->ac_f_ex.fe_logical;
+               __entry->result_start   = ac->ac_f_ex.fe_start;
+               __entry->result_group   = ac->ac_f_ex.fe_group;
+               __entry->result_len     = ac->ac_f_ex.fe_len;
+               __entry->found          = ac->ac_found;
+               __entry->flags          = ac->ac_flags;
+               __entry->groups         = ac->ac_groups_scanned;
+               __entry->buddy          = ac->ac_buddy;
+               __entry->tail           = ac->ac_tail;
+               __entry->cr             = ac->ac_criteria;
+       ),
+
+       TP_printk("dev %d,%d inode %lu orig %u/%d/%u@%u goal %u/%d/%u@%u "
+                 "result %u/%d/%u@%u blks %u grps %u cr %u flags 0x%04x "
+                 "tail %u broken %u",
+                 MAJOR(__entry->dev), MINOR(__entry->dev),
+                 (unsigned long) __entry->ino,
+                 __entry->orig_group, __entry->orig_start,
+                 __entry->orig_len, __entry->orig_logical,
+                 __entry->goal_group, __entry->goal_start,
+                 __entry->goal_len, __entry->goal_logical,
+                 __entry->result_group, __entry->result_start,
+                 __entry->result_len, __entry->result_logical,
+                 __entry->found, __entry->groups, __entry->cr,
+                 __entry->flags, __entry->tail,
+                 __entry->buddy ? 1 << __entry->buddy : 0)
+);
+
+TRACE_EVENT(ext4_mballoc_prealloc,
+       TP_PROTO(struct ext4_allocation_context *ac),
+
+       TP_ARGS(ac),
+
+       TP_STRUCT__entry(
+               __field(        dev_t,  dev                     )
+               __field(        ino_t,  ino                     )
+               __field(        __u32,  orig_logical            )
+               __field(          int,  orig_start              )
+               __field(        __u32,  orig_group              )
+               __field(          int,  orig_len                )
+               __field(        __u32,  result_logical          )
+               __field(          int,  result_start            )
+               __field(        __u32,  result_group            )
+               __field(          int,  result_len              )
+       ),
+
+       TP_fast_assign(
+               __entry->dev            = ac->ac_inode->i_sb->s_dev;
+               __entry->ino            = ac->ac_inode->i_ino;
+               __entry->orig_logical   = ac->ac_o_ex.fe_logical;
+               __entry->orig_start     = ac->ac_o_ex.fe_start;
+               __entry->orig_group     = ac->ac_o_ex.fe_group;
+               __entry->orig_len       = ac->ac_o_ex.fe_len;
+               __entry->result_logical = ac->ac_b_ex.fe_logical;
+               __entry->result_start   = ac->ac_b_ex.fe_start;
+               __entry->result_group   = ac->ac_b_ex.fe_group;
+               __entry->result_len     = ac->ac_b_ex.fe_len;
+       ),
+
+       TP_printk("dev %d,%d inode %lu orig %u/%d/%u@%u result %u/%d/%u@%u",
+                 MAJOR(__entry->dev), MINOR(__entry->dev),
+                 (unsigned long) __entry->ino,
+                 __entry->orig_group, __entry->orig_start,
+                 __entry->orig_len, __entry->orig_logical,
+                 __entry->result_group, __entry->result_start,
+                 __entry->result_len, __entry->result_logical)
+);
+
+DECLARE_EVENT_CLASS(ext4__mballoc,
+       TP_PROTO(struct super_block *sb,
+                struct inode *inode,
+                ext4_group_t group,
+                ext4_grpblk_t start,
+                ext4_grpblk_t len),
+
+       TP_ARGS(sb, inode, group, start, len),
+
+       TP_STRUCT__entry(
+               __field(        dev_t,  dev                     )
+               __field(        ino_t,  ino                     )
+               __field(          int,  result_start            )
+               __field(        __u32,  result_group            )
+               __field(          int,  result_len              )
+       ),
+
+       TP_fast_assign(
+               __entry->dev            = sb->s_dev;
+               __entry->ino            = inode ? inode->i_ino : 0;
+               __entry->result_start   = start;
+               __entry->result_group   = group;
+               __entry->result_len     = len;
+       ),
+
+       TP_printk("dev %d,%d inode %lu extent %u/%d/%d ",
+                 MAJOR(__entry->dev), MINOR(__entry->dev),
+                 (unsigned long) __entry->ino,
+                 __entry->result_group, __entry->result_start,
+                 __entry->result_len)
+);
+
+DEFINE_EVENT(ext4__mballoc, ext4_mballoc_discard,
+
+       TP_PROTO(struct super_block *sb,
+                struct inode *inode,
+                ext4_group_t group,
+                ext4_grpblk_t start,
+                ext4_grpblk_t len),
+
+       TP_ARGS(sb, inode, group, start, len)
+);
+
+DEFINE_EVENT(ext4__mballoc, ext4_mballoc_free,
+
+       TP_PROTO(struct super_block *sb,
+                struct inode *inode,
+                ext4_group_t group,
+                ext4_grpblk_t start,
+                ext4_grpblk_t len),
+
+       TP_ARGS(sb, inode, group, start, len)
+);
+
+TRACE_EVENT(ext4_forget,
+       TP_PROTO(struct inode *inode, int is_metadata, __u64 block),
+
+       TP_ARGS(inode, is_metadata, block),
+
+       TP_STRUCT__entry(
+               __field(        dev_t,  dev                     )
+               __field(        ino_t,  ino                     )
+               __field(        __u64,  block                   )
+               __field(        int,    is_metadata             )
+               __field(        __u16,  mode                    )
+       ),
+
+       TP_fast_assign(
+               __entry->dev    = inode->i_sb->s_dev;
+               __entry->ino    = inode->i_ino;
+               __entry->block  = block;
+               __entry->is_metadata = is_metadata;
+               __entry->mode   = inode->i_mode;
+       ),
+
+       TP_printk("dev %d,%d ino %lu mode 0%o is_metadata %d block %llu",
+                 MAJOR(__entry->dev), MINOR(__entry->dev),
+                 (unsigned long) __entry->ino,
+                 __entry->mode, __entry->is_metadata, __entry->block)
+);
+
+TRACE_EVENT(ext4_da_update_reserve_space,
+       TP_PROTO(struct inode *inode, int used_blocks, int quota_claim),
+
+       TP_ARGS(inode, used_blocks, quota_claim),
+
+       TP_STRUCT__entry(
+               __field(        dev_t,  dev                     )
+               __field(        ino_t,  ino                     )
+               __field(        __u64,  i_blocks                )
+               __field(        int,    used_blocks             )
+               __field(        int,    reserved_data_blocks    )
+               __field(        int,    reserved_meta_blocks    )
+               __field(        int,    allocated_meta_blocks   )
+               __field(        int,    quota_claim             )
+               __field(        __u16,  mode                    )
+       ),
+
+       TP_fast_assign(
+               __entry->dev    = inode->i_sb->s_dev;
+               __entry->ino    = inode->i_ino;
+               __entry->i_blocks = inode->i_blocks;
+               __entry->used_blocks = used_blocks;
+               __entry->reserved_data_blocks =
+                               EXT4_I(inode)->i_reserved_data_blocks;
+               __entry->reserved_meta_blocks =
+                               EXT4_I(inode)->i_reserved_meta_blocks;
+               __entry->allocated_meta_blocks =
+                               EXT4_I(inode)->i_allocated_meta_blocks;
+               __entry->quota_claim = quota_claim;
+               __entry->mode   = inode->i_mode;
+       ),
+
+       TP_printk("dev %d,%d ino %lu mode 0%o i_blocks %llu used_blocks %d "
+                 "reserved_data_blocks %d reserved_meta_blocks %d "
+                 "allocated_meta_blocks %d quota_claim %d",
+                 MAJOR(__entry->dev), MINOR(__entry->dev),
+                 (unsigned long) __entry->ino,
+                 __entry->mode, __entry->i_blocks,
+                 __entry->used_blocks, __entry->reserved_data_blocks,
+                 __entry->reserved_meta_blocks, __entry->allocated_meta_blocks,
+                 __entry->quota_claim)
+);
+
+TRACE_EVENT(ext4_da_reserve_space,
+       TP_PROTO(struct inode *inode, int md_needed),
+
+       TP_ARGS(inode, md_needed),
+
+       TP_STRUCT__entry(
+               __field(        dev_t,  dev                     )
+               __field(        ino_t,  ino                     )
+               __field(        __u64,  i_blocks                )
+               __field(        int,    md_needed               )
+               __field(        int,    reserved_data_blocks    )
+               __field(        int,    reserved_meta_blocks    )
+               __field(        __u16,  mode                    )
+       ),
+
+       TP_fast_assign(
+               __entry->dev    = inode->i_sb->s_dev;
+               __entry->ino    = inode->i_ino;
+               __entry->i_blocks = inode->i_blocks;
+               __entry->md_needed = md_needed;
+               __entry->reserved_data_blocks = EXT4_I(inode)->i_reserved_data_blocks;
+               __entry->reserved_meta_blocks = EXT4_I(inode)->i_reserved_meta_blocks;
+               __entry->mode   = inode->i_mode;
+       ),
+
+       TP_printk("dev %d,%d ino %lu mode 0%o i_blocks %llu md_needed %d "
+                 "reserved_data_blocks %d reserved_meta_blocks %d",
+                 MAJOR(__entry->dev), MINOR(__entry->dev),
+                 (unsigned long) __entry->ino,
+                 __entry->mode, __entry->i_blocks,
+                 __entry->md_needed, __entry->reserved_data_blocks,
+                 __entry->reserved_meta_blocks)
+);
+
+TRACE_EVENT(ext4_da_release_space,
+       TP_PROTO(struct inode *inode, int freed_blocks),
+
+       TP_ARGS(inode, freed_blocks),
+
+       TP_STRUCT__entry(
+               __field(        dev_t,  dev                     )
+               __field(        ino_t,  ino                     )
+               __field(        __u64,  i_blocks                )
+               __field(        int,    freed_blocks            )
+               __field(        int,    reserved_data_blocks    )
+               __field(        int,    reserved_meta_blocks    )
+               __field(        int,    allocated_meta_blocks   )
+               __field(        __u16,  mode                    )
+       ),
+
+       TP_fast_assign(
+               __entry->dev    = inode->i_sb->s_dev;
+               __entry->ino    = inode->i_ino;
+               __entry->i_blocks = inode->i_blocks;
+               __entry->freed_blocks = freed_blocks;
+               __entry->reserved_data_blocks = EXT4_I(inode)->i_reserved_data_blocks;
+               __entry->reserved_meta_blocks = EXT4_I(inode)->i_reserved_meta_blocks;
+               __entry->allocated_meta_blocks = EXT4_I(inode)->i_allocated_meta_blocks;
+               __entry->mode   = inode->i_mode;
+       ),
+
+       TP_printk("dev %d,%d ino %lu mode 0%o i_blocks %llu freed_blocks %d "
+                 "reserved_data_blocks %d reserved_meta_blocks %d "
+                 "allocated_meta_blocks %d",
+                 MAJOR(__entry->dev), MINOR(__entry->dev),
+                 (unsigned long) __entry->ino,
+                 __entry->mode, __entry->i_blocks,
+                 __entry->freed_blocks, __entry->reserved_data_blocks,
+                 __entry->reserved_meta_blocks, __entry->allocated_meta_blocks)
+);
+
+DECLARE_EVENT_CLASS(ext4__bitmap_load,
+       TP_PROTO(struct super_block *sb, unsigned long group),
+
+       TP_ARGS(sb, group),
+
+       TP_STRUCT__entry(
+               __field(        dev_t,  dev                     )
+               __field(        __u32,  group                   )
+
+       ),
+
+       TP_fast_assign(
+               __entry->dev    = sb->s_dev;
+               __entry->group  = group;
+       ),
+
+       TP_printk("dev %d,%d group %u",
+                 MAJOR(__entry->dev), MINOR(__entry->dev),
+                 __entry->group)
+);
+
+DEFINE_EVENT(ext4__bitmap_load, ext4_mb_bitmap_load,
+
+       TP_PROTO(struct super_block *sb, unsigned long group),
+
+       TP_ARGS(sb, group)
+);
+
+DEFINE_EVENT(ext4__bitmap_load, ext4_mb_buddy_bitmap_load,
+
+       TP_PROTO(struct super_block *sb, unsigned long group),
+
+       TP_ARGS(sb, group)
+);
+
+DEFINE_EVENT(ext4__bitmap_load, ext4_read_block_bitmap_load,
+
+       TP_PROTO(struct super_block *sb, unsigned long group),
+
+       TP_ARGS(sb, group)
+);
+
+DEFINE_EVENT(ext4__bitmap_load, ext4_load_inode_bitmap,
+
+       TP_PROTO(struct super_block *sb, unsigned long group),
+
+       TP_ARGS(sb, group)
+);
+
+TRACE_EVENT(ext4_direct_IO_enter,
+       TP_PROTO(struct inode *inode, loff_t offset, unsigned long len, int rw),
+
+       TP_ARGS(inode, offset, len, rw),
+
+       TP_STRUCT__entry(
+               __field(        dev_t,  dev                     )
+               __field(        ino_t,  ino                     )
+               __field(        loff_t, pos                     )
+               __field(        unsigned long,  len             )
+               __field(        int,    rw                      )
+       ),
+
+       TP_fast_assign(
+               __entry->dev    = inode->i_sb->s_dev;
+               __entry->ino    = inode->i_ino;
+               __entry->pos    = offset;
+               __entry->len    = len;
+               __entry->rw     = rw;
+       ),
+
+       TP_printk("dev %d,%d ino %lu pos %lld len %lu rw %d",
+                 MAJOR(__entry->dev), MINOR(__entry->dev),
+                 (unsigned long) __entry->ino,
+                 __entry->pos, __entry->len, __entry->rw)
+);
+
+TRACE_EVENT(ext4_direct_IO_exit,
+       TP_PROTO(struct inode *inode, loff_t offset, unsigned long len,
+                int rw, int ret),
+
+       TP_ARGS(inode, offset, len, rw, ret),
+
+       TP_STRUCT__entry(
+               __field(        dev_t,  dev                     )
+               __field(        ino_t,  ino                     )
+               __field(        loff_t, pos                     )
+               __field(        unsigned long,  len             )
+               __field(        int,    rw                      )
+               __field(        int,    ret                     )
+       ),
+
+       TP_fast_assign(
+               __entry->dev    = inode->i_sb->s_dev;
+               __entry->ino    = inode->i_ino;
+               __entry->pos    = offset;
+               __entry->len    = len;
+               __entry->rw     = rw;
+               __entry->ret    = ret;
+       ),
+
+       TP_printk("dev %d,%d ino %lu pos %lld len %lu rw %d ret %d",
+                 MAJOR(__entry->dev), MINOR(__entry->dev),
+                 (unsigned long) __entry->ino,
+                 __entry->pos, __entry->len,
+                 __entry->rw, __entry->ret)
+);
+
+TRACE_EVENT(ext4_fallocate_enter,
+       TP_PROTO(struct inode *inode, loff_t offset, loff_t len, int mode),
+
+       TP_ARGS(inode, offset, len, mode),
+
+       TP_STRUCT__entry(
+               __field(        dev_t,  dev                     )
+               __field(        ino_t,  ino                     )
+               __field(        loff_t, pos                     )
+               __field(        loff_t, len                     )
+               __field(        int,    mode                    )
+       ),
+
+       TP_fast_assign(
+               __entry->dev    = inode->i_sb->s_dev;
+               __entry->ino    = inode->i_ino;
+               __entry->pos    = offset;
+               __entry->len    = len;
+               __entry->mode   = mode;
+       ),
+
+       TP_printk("dev %d,%d ino %lu pos %lld len %lld mode %d",
+                 MAJOR(__entry->dev), MINOR(__entry->dev),
+                 (unsigned long) __entry->ino, __entry->pos,
+                 __entry->len, __entry->mode)
+);
+
+TRACE_EVENT(ext4_fallocate_exit,
+       TP_PROTO(struct inode *inode, loff_t offset,
+                unsigned int max_blocks, int ret),
+
+       TP_ARGS(inode, offset, max_blocks, ret),
+
+       TP_STRUCT__entry(
+               __field(        dev_t,  dev                     )
+               __field(        ino_t,  ino                     )
+               __field(        loff_t, pos                     )
+               __field(        unsigned int,   blocks          )
+               __field(        int,    ret                     )
+       ),
+
+       TP_fast_assign(
+               __entry->dev    = inode->i_sb->s_dev;
+               __entry->ino    = inode->i_ino;
+               __entry->pos    = offset;
+               __entry->blocks = max_blocks;
+               __entry->ret    = ret;
+       ),
+
+       TP_printk("dev %d,%d ino %lu pos %lld blocks %u ret %d",
+                 MAJOR(__entry->dev), MINOR(__entry->dev),
+                 (unsigned long) __entry->ino,
+                 __entry->pos, __entry->blocks,
+                 __entry->ret)
+);
+
+TRACE_EVENT(ext4_unlink_enter,
+       TP_PROTO(struct inode *parent, struct dentry *dentry),
+
+       TP_ARGS(parent, dentry),
+
+       TP_STRUCT__entry(
+               __field(        dev_t,  dev                     )
+               __field(        ino_t,  ino                     )
+               __field(        ino_t,  parent                  )
+               __field(        loff_t, size                    )
+       ),
+
+       TP_fast_assign(
+               __entry->dev            = dentry->d_inode->i_sb->s_dev;
+               __entry->ino            = dentry->d_inode->i_ino;
+               __entry->parent         = parent->i_ino;
+               __entry->size           = dentry->d_inode->i_size;
+       ),
+
+       TP_printk("dev %d,%d ino %lu size %lld parent %lu",
+                 MAJOR(__entry->dev), MINOR(__entry->dev),
+                 (unsigned long) __entry->ino, __entry->size,
+                 (unsigned long) __entry->parent)
+);
+
+TRACE_EVENT(ext4_unlink_exit,
+       TP_PROTO(struct dentry *dentry, int ret),
+
+       TP_ARGS(dentry, ret),
+
+       TP_STRUCT__entry(
+               __field(        dev_t,  dev                     )
+               __field(        ino_t,  ino                     )
+               __field(        int,    ret                     )
+       ),
+
+       TP_fast_assign(
+               __entry->dev            = dentry->d_inode->i_sb->s_dev;
+               __entry->ino            = dentry->d_inode->i_ino;
+               __entry->ret            = ret;
+       ),
+
+       TP_printk("dev %d,%d ino %lu ret %d",
+                 MAJOR(__entry->dev), MINOR(__entry->dev),
+                 (unsigned long) __entry->ino,
+                 __entry->ret)
+);
+
+DECLARE_EVENT_CLASS(ext4__truncate,
+       TP_PROTO(struct inode *inode),
+
+       TP_ARGS(inode),
+
+       TP_STRUCT__entry(
+               __field(        dev_t,          dev             )
+               __field(        ino_t,          ino             )
+               __field(        __u64,          blocks          )
+       ),
+
+       TP_fast_assign(
+               __entry->dev    = inode->i_sb->s_dev;
+               __entry->ino    = inode->i_ino;
+               __entry->blocks = inode->i_blocks;
+       ),
+
+       TP_printk("dev %d,%d ino %lu blocks %llu",
+                 MAJOR(__entry->dev), MINOR(__entry->dev),
+                 (unsigned long) __entry->ino, __entry->blocks)
+);
+
+DEFINE_EVENT(ext4__truncate, ext4_truncate_enter,
+
+       TP_PROTO(struct inode *inode),
+
+       TP_ARGS(inode)
+);
+
+DEFINE_EVENT(ext4__truncate, ext4_truncate_exit,
+
+       TP_PROTO(struct inode *inode),
+
+       TP_ARGS(inode)
+);
+
+/* 'ux' is the uninitialized extent. */
+TRACE_EVENT(ext4_ext_convert_to_initialized_enter,
+       TP_PROTO(struct inode *inode, struct ext4_map_blocks *map,
+                struct ext4_extent *ux),
+
+       TP_ARGS(inode, map, ux),
+
+       TP_STRUCT__entry(
+               __field(        dev_t,          dev     )
+               __field(        ino_t,          ino     )
+               __field(        ext4_lblk_t,    m_lblk  )
+               __field(        unsigned,       m_len   )
+               __field(        ext4_lblk_t,    u_lblk  )
+               __field(        unsigned,       u_len   )
+               __field(        ext4_fsblk_t,   u_pblk  )
+       ),
+
+       TP_fast_assign(
+               __entry->dev            = inode->i_sb->s_dev;
+               __entry->ino            = inode->i_ino;
+               __entry->m_lblk         = map->m_lblk;
+               __entry->m_len          = map->m_len;
+               __entry->u_lblk         = le32_to_cpu(ux->ee_block);
+               __entry->u_len          = ext4_ext_get_actual_len(ux);
+               __entry->u_pblk         = ext4_ext_pblock(ux);
+       ),
+
+       TP_printk("dev %d,%d ino %lu m_lblk %u m_len %u u_lblk %u u_len %u "
+                 "u_pblk %llu",
+                 MAJOR(__entry->dev), MINOR(__entry->dev),
+                 (unsigned long) __entry->ino,
+                 __entry->m_lblk, __entry->m_len,
+                 __entry->u_lblk, __entry->u_len, __entry->u_pblk)
+);
+
+/*
+ * 'ux' is the uninitialized extent.
+ * 'ix' is the initialized extent to which blocks are transferred.
+ */
+TRACE_EVENT(ext4_ext_convert_to_initialized_fastpath,
+       TP_PROTO(struct inode *inode, struct ext4_map_blocks *map,
+                struct ext4_extent *ux, struct ext4_extent *ix),
+
+       TP_ARGS(inode, map, ux, ix),
+
+       TP_STRUCT__entry(
+               __field(        dev_t,          dev     )
+               __field(        ino_t,          ino     )
+               __field(        ext4_lblk_t,    m_lblk  )
+               __field(        unsigned,       m_len   )
+               __field(        ext4_lblk_t,    u_lblk  )
+               __field(        unsigned,       u_len   )
+               __field(        ext4_fsblk_t,   u_pblk  )
+               __field(        ext4_lblk_t,    i_lblk  )
+               __field(        unsigned,       i_len   )
+               __field(        ext4_fsblk_t,   i_pblk  )
+       ),
+
+       TP_fast_assign(
+               __entry->dev            = inode->i_sb->s_dev;
+               __entry->ino            = inode->i_ino;
+               __entry->m_lblk         = map->m_lblk;
+               __entry->m_len          = map->m_len;
+               __entry->u_lblk         = le32_to_cpu(ux->ee_block);
+               __entry->u_len          = ext4_ext_get_actual_len(ux);
+               __entry->u_pblk         = ext4_ext_pblock(ux);
+               __entry->i_lblk         = le32_to_cpu(ix->ee_block);
+               __entry->i_len          = ext4_ext_get_actual_len(ix);
+               __entry->i_pblk         = ext4_ext_pblock(ix);
+       ),
+
+       TP_printk("dev %d,%d ino %lu m_lblk %u m_len %u "
+                 "u_lblk %u u_len %u u_pblk %llu "
+                 "i_lblk %u i_len %u i_pblk %llu ",
+                 MAJOR(__entry->dev), MINOR(__entry->dev),
+                 (unsigned long) __entry->ino,
+                 __entry->m_lblk, __entry->m_len,
+                 __entry->u_lblk, __entry->u_len, __entry->u_pblk,
+                 __entry->i_lblk, __entry->i_len, __entry->i_pblk)
+);
+
+DECLARE_EVENT_CLASS(ext4__map_blocks_enter,
+       TP_PROTO(struct inode *inode, ext4_lblk_t lblk,
+                unsigned int len, unsigned int flags),
+
+       TP_ARGS(inode, lblk, len, flags),
+
+       TP_STRUCT__entry(
+               __field(        dev_t,          dev             )
+               __field(        ino_t,          ino             )
+               __field(        ext4_lblk_t,    lblk            )
+               __field(        unsigned int,   len             )
+               __field(        unsigned int,   flags           )
+       ),
+
+       TP_fast_assign(
+               __entry->dev    = inode->i_sb->s_dev;
+               __entry->ino    = inode->i_ino;
+               __entry->lblk   = lblk;
+               __entry->len    = len;
+               __entry->flags  = flags;
+       ),
+
+       TP_printk("dev %d,%d ino %lu lblk %u len %u flags %u",
+                 MAJOR(__entry->dev), MINOR(__entry->dev),
+                 (unsigned long) __entry->ino,
+                 __entry->lblk, __entry->len, __entry->flags)
+);
+
+DEFINE_EVENT(ext4__map_blocks_enter, ext4_ext_map_blocks_enter,
+       TP_PROTO(struct inode *inode, ext4_lblk_t lblk,
+                unsigned len, unsigned flags),
+
+       TP_ARGS(inode, lblk, len, flags)
+);
+
+DEFINE_EVENT(ext4__map_blocks_enter, ext4_ind_map_blocks_enter,
+       TP_PROTO(struct inode *inode, ext4_lblk_t lblk,
+                unsigned len, unsigned flags),
+
+       TP_ARGS(inode, lblk, len, flags)
+);
+
+DECLARE_EVENT_CLASS(ext4__map_blocks_exit,
+       TP_PROTO(struct inode *inode, ext4_lblk_t lblk,
+                ext4_fsblk_t pblk, unsigned int len, int ret),
+
+       TP_ARGS(inode, lblk, pblk, len, ret),
+
+       TP_STRUCT__entry(
+               __field(        dev_t,          dev             )
+               __field(        ino_t,          ino             )
+               __field(        ext4_fsblk_t,   pblk            )
+               __field(        ext4_lblk_t,    lblk            )
+               __field(        unsigned int,   len             )
+               __field(        int,            ret             )
+       ),
+
+       TP_fast_assign(
+               __entry->dev    = inode->i_sb->s_dev;
+               __entry->ino    = inode->i_ino;
+               __entry->pblk   = pblk;
+               __entry->lblk   = lblk;
+               __entry->len    = len;
+               __entry->ret    = ret;
+       ),
+
+       TP_printk("dev %d,%d ino %lu lblk %u pblk %llu len %u ret %d",
+                 MAJOR(__entry->dev), MINOR(__entry->dev),
+                 (unsigned long) __entry->ino,
+                 __entry->lblk, __entry->pblk,
+                 __entry->len, __entry->ret)
+);
+
+DEFINE_EVENT(ext4__map_blocks_exit, ext4_ext_map_blocks_exit,
+       TP_PROTO(struct inode *inode, ext4_lblk_t lblk,
+                ext4_fsblk_t pblk, unsigned len, int ret),
+
+       TP_ARGS(inode, lblk, pblk, len, ret)
+);
+
+DEFINE_EVENT(ext4__map_blocks_exit, ext4_ind_map_blocks_exit,
+       TP_PROTO(struct inode *inode, ext4_lblk_t lblk,
+                ext4_fsblk_t pblk, unsigned len, int ret),
+
+       TP_ARGS(inode, lblk, pblk, len, ret)
+);
+
+TRACE_EVENT(ext4_ext_load_extent,
+       TP_PROTO(struct inode *inode, ext4_lblk_t lblk, ext4_fsblk_t pblk),
+
+       TP_ARGS(inode, lblk, pblk),
+
+       TP_STRUCT__entry(
+               __field(        dev_t,          dev             )
+               __field(        ino_t,          ino             )
+               __field(        ext4_fsblk_t,   pblk            )
+               __field(        ext4_lblk_t,    lblk            )
+       ),
+
+       TP_fast_assign(
+               __entry->dev    = inode->i_sb->s_dev;
+               __entry->ino    = inode->i_ino;
+               __entry->pblk   = pblk;
+               __entry->lblk   = lblk;
+       ),
+
+       TP_printk("dev %d,%d ino %lu lblk %u pblk %llu",
+                 MAJOR(__entry->dev), MINOR(__entry->dev),
+                 (unsigned long) __entry->ino,
+                 __entry->lblk, __entry->pblk)
+);
+
+TRACE_EVENT(ext4_load_inode,
+       TP_PROTO(struct inode *inode),
+
+       TP_ARGS(inode),
+
+       TP_STRUCT__entry(
+               __field(        dev_t,  dev             )
+               __field(        ino_t,  ino             )
+       ),
+
+       TP_fast_assign(
+               __entry->dev            = inode->i_sb->s_dev;
+               __entry->ino            = inode->i_ino;
+       ),
+
+       TP_printk("dev %d,%d ino %ld",
+                 MAJOR(__entry->dev), MINOR(__entry->dev),
+                 (unsigned long) __entry->ino)
+);
+
+TRACE_EVENT(ext4_journal_start,
+       TP_PROTO(struct super_block *sb, int nblocks, unsigned long IP),
+
+       TP_ARGS(sb, nblocks, IP),
+
+       TP_STRUCT__entry(
+               __field(        dev_t,  dev                     )
+               __field(unsigned long,  ip                      )
+               __field(        int,    nblocks                 )
+       ),
+
+       TP_fast_assign(
+               __entry->dev     = sb->s_dev;
+               __entry->ip      = IP;
+               __entry->nblocks = nblocks;
+       ),
+
+       TP_printk("dev %d,%d nblocks %d caller %pF",
+                 MAJOR(__entry->dev), MINOR(__entry->dev),
+                 __entry->nblocks, (void *)__entry->ip)
+);
+
+DECLARE_EVENT_CLASS(ext4__trim,
+       TP_PROTO(struct super_block *sb,
+                ext4_group_t group,
+                ext4_grpblk_t start,
+                ext4_grpblk_t len),
+
+       TP_ARGS(sb, group, start, len),
+
+       TP_STRUCT__entry(
+               __field(        int,    dev_major               )
+               __field(        int,    dev_minor               )
+               __field(        __u32,  group                   )
+               __field(        int,    start                   )
+               __field(        int,    len                     )
+       ),
+
+       TP_fast_assign(
+               __entry->dev_major      = MAJOR(sb->s_dev);
+               __entry->dev_minor      = MINOR(sb->s_dev);
+               __entry->group          = group;
+               __entry->start          = start;
+               __entry->len            = len;
+       ),
+
+       TP_printk("dev %d,%d group %u, start %d, len %d",
+                 __entry->dev_major, __entry->dev_minor,
+                 __entry->group, __entry->start, __entry->len)
+);
+
+DEFINE_EVENT(ext4__trim, ext4_trim_extent,
+
+       TP_PROTO(struct super_block *sb,
+                ext4_group_t group,
+                ext4_grpblk_t start,
+                ext4_grpblk_t len),
+
+       TP_ARGS(sb, group, start, len)
+);
+
+DEFINE_EVENT(ext4__trim, ext4_trim_all_free,
+
+       TP_PROTO(struct super_block *sb,
+                ext4_group_t group,
+                ext4_grpblk_t start,
+                ext4_grpblk_t len),
+
+       TP_ARGS(sb, group, start, len)
+);
+
+TRACE_EVENT(ext4_ext_handle_uninitialized_extents,
+       TP_PROTO(struct inode *inode, struct ext4_map_blocks *map,
+                unsigned int allocated, ext4_fsblk_t newblock),
+
+       TP_ARGS(inode, map, allocated, newblock),
+
+       TP_STRUCT__entry(
+               __field(        dev_t,          dev             )
+               __field(        ino_t,          ino             )
+               __field(        int,            flags           )
+               __field(        ext4_lblk_t,    lblk            )
+               __field(        ext4_fsblk_t,   pblk            )
+               __field(        unsigned int,   len             )
+               __field(        unsigned int,   allocated       )
+               __field(        ext4_fsblk_t,   newblk          )
+       ),
+
+       TP_fast_assign(
+               __entry->dev            = inode->i_sb->s_dev;
+               __entry->ino            = inode->i_ino;
+               __entry->flags          = map->m_flags;
+               __entry->lblk           = map->m_lblk;
+               __entry->pblk           = map->m_pblk;
+               __entry->len            = map->m_len;
+               __entry->allocated      = allocated;
+               __entry->newblk         = newblock;
+       ),
+
+       TP_printk("dev %d,%d ino %lu m_lblk %u m_pblk %llu m_len %u flags %d"
+                 "allocated %d newblock %llu",
+                 MAJOR(__entry->dev), MINOR(__entry->dev),
+                 (unsigned long) __entry->ino,
+                 (unsigned) __entry->lblk, (unsigned long long) __entry->pblk,
+                 __entry->len, __entry->flags,
+                 (unsigned int) __entry->allocated,
+                 (unsigned long long) __entry->newblk)
+);
+
+TRACE_EVENT(ext4_get_implied_cluster_alloc_exit,
+       TP_PROTO(struct super_block *sb, struct ext4_map_blocks *map, int ret),
+
+       TP_ARGS(sb, map, ret),
+
+       TP_STRUCT__entry(
+               __field(        dev_t,          dev     )
+               __field(        unsigned int,   flags   )
+               __field(        ext4_lblk_t,    lblk    )
+               __field(        ext4_fsblk_t,   pblk    )
+               __field(        unsigned int,   len     )
+               __field(        int,            ret     )
+       ),
+
+       TP_fast_assign(
+               __entry->dev    = sb->s_dev;
+               __entry->flags  = map->m_flags;
+               __entry->lblk   = map->m_lblk;
+               __entry->pblk   = map->m_pblk;
+               __entry->len    = map->m_len;
+               __entry->ret    = ret;
+       ),
+
+       TP_printk("dev %d,%d m_lblk %u m_pblk %llu m_len %u m_flags %u ret %d",
+                 MAJOR(__entry->dev), MINOR(__entry->dev),
+                 __entry->lblk, (unsigned long long) __entry->pblk,
+                 __entry->len, __entry->flags, __entry->ret)
+);
+
+TRACE_EVENT(ext4_ext_put_in_cache,
+       TP_PROTO(struct inode *inode, ext4_lblk_t lblk, unsigned int len,
+                ext4_fsblk_t start),
+
+       TP_ARGS(inode, lblk, len, start),
+
+       TP_STRUCT__entry(
+               __field(        dev_t,          dev     )
+               __field(        ino_t,          ino     )
+               __field(        ext4_lblk_t,    lblk    )
+               __field(        unsigned int,   len     )
+               __field(        ext4_fsblk_t,   start   )
+       ),
+
+       TP_fast_assign(
+               __entry->dev    = inode->i_sb->s_dev;
+               __entry->ino    = inode->i_ino;
+               __entry->lblk   = lblk;
+               __entry->len    = len;
+               __entry->start  = start;
+       ),
+
+       TP_printk("dev %d,%d ino %lu lblk %u len %u start %llu",
+                 MAJOR(__entry->dev), MINOR(__entry->dev),
+                 (unsigned long) __entry->ino,
+                 (unsigned) __entry->lblk,
+                 __entry->len,
+                 (unsigned long long) __entry->start)
+);
+
+TRACE_EVENT(ext4_ext_in_cache,
+       TP_PROTO(struct inode *inode, ext4_lblk_t lblk, int ret),
+
+       TP_ARGS(inode, lblk, ret),
+
+       TP_STRUCT__entry(
+               __field(        dev_t,          dev     )
+               __field(        ino_t,          ino     )
+               __field(        ext4_lblk_t,    lblk    )
+               __field(        int,            ret     )
+       ),
+
+       TP_fast_assign(
+               __entry->dev    = inode->i_sb->s_dev;
+               __entry->ino    = inode->i_ino;
+               __entry->lblk   = lblk;
+               __entry->ret    = ret;
+       ),
+
+       TP_printk("dev %d,%d ino %lu lblk %u ret %d",
+                 MAJOR(__entry->dev), MINOR(__entry->dev),
+                 (unsigned long) __entry->ino,
+                 (unsigned) __entry->lblk,
+                 __entry->ret)
+
+);
+
+TRACE_EVENT(ext4_find_delalloc_range,
+       TP_PROTO(struct inode *inode, ext4_lblk_t from, ext4_lblk_t to,
+               int reverse, int found, ext4_lblk_t found_blk),
+
+       TP_ARGS(inode, from, to, reverse, found, found_blk),
+
+       TP_STRUCT__entry(
+               __field(        dev_t,          dev             )
+               __field(        ino_t,          ino             )
+               __field(        ext4_lblk_t,    from            )
+               __field(        ext4_lblk_t,    to              )
+               __field(        int,            reverse         )
+               __field(        int,            found           )
+               __field(        ext4_lblk_t,    found_blk       )
+       ),
+
+       TP_fast_assign(
+               __entry->dev            = inode->i_sb->s_dev;
+               __entry->ino            = inode->i_ino;
+               __entry->from           = from;
+               __entry->to             = to;
+               __entry->reverse        = reverse;
+               __entry->found          = found;
+               __entry->found_blk      = found_blk;
+       ),
+
+       TP_printk("dev %d,%d ino %lu from %u to %u reverse %d found %d "
+                 "(blk = %u)",
+                 MAJOR(__entry->dev), MINOR(__entry->dev),
+                 (unsigned long) __entry->ino,
+                 (unsigned) __entry->from, (unsigned) __entry->to,
+                 __entry->reverse, __entry->found,
+                 (unsigned) __entry->found_blk)
+);
+
+TRACE_EVENT(ext4_get_reserved_cluster_alloc,
+       TP_PROTO(struct inode *inode, ext4_lblk_t lblk, unsigned int len),
+
+       TP_ARGS(inode, lblk, len),
+
+       TP_STRUCT__entry(
+               __field(        dev_t,          dev     )
+               __field(        ino_t,          ino     )
+               __field(        ext4_lblk_t,    lblk    )
+               __field(        unsigned int,   len     )
+       ),
+
+       TP_fast_assign(
+               __entry->dev    = inode->i_sb->s_dev;
+               __entry->ino    = inode->i_ino;
+               __entry->lblk   = lblk;
+               __entry->len    = len;
+       ),
+
+       TP_printk("dev %d,%d ino %lu lblk %u len %u",
+                 MAJOR(__entry->dev), MINOR(__entry->dev),
+                 (unsigned long) __entry->ino,
+                 (unsigned) __entry->lblk,
+                 __entry->len)
+);
+
+TRACE_EVENT(ext4_ext_show_extent,
+       TP_PROTO(struct inode *inode, ext4_lblk_t lblk, ext4_fsblk_t pblk,
+                unsigned short len),
+
+       TP_ARGS(inode, lblk, pblk, len),
+
+       TP_STRUCT__entry(
+               __field(        dev_t,          dev     )
+               __field(        ino_t,          ino     )
+               __field(        ext4_fsblk_t,   pblk    )
+               __field(        ext4_lblk_t,    lblk    )
+               __field(        unsigned short, len     )
+       ),
+
+       TP_fast_assign(
+               __entry->dev    = inode->i_sb->s_dev;
+               __entry->ino    = inode->i_ino;
+               __entry->pblk   = pblk;
+               __entry->lblk   = lblk;
+               __entry->len    = len;
+       ),
+
+       TP_printk("dev %d,%d ino %lu lblk %u pblk %llu len %u",
+                 MAJOR(__entry->dev), MINOR(__entry->dev),
+                 (unsigned long) __entry->ino,
+                 (unsigned) __entry->lblk,
+                 (unsigned long long) __entry->pblk,
+                 (unsigned short) __entry->len)
+);
+
+TRACE_EVENT(ext4_remove_blocks,
+           TP_PROTO(struct inode *inode, struct ext4_extent *ex,
+               ext4_lblk_t from, ext4_fsblk_t to,
+               ext4_fsblk_t partial_cluster),
+
+       TP_ARGS(inode, ex, from, to, partial_cluster),
+
+       TP_STRUCT__entry(
+               __field(        dev_t,          dev     )
+               __field(        ino_t,          ino     )
+               __field(        ext4_lblk_t,    from    )
+               __field(        ext4_lblk_t,    to      )
+               __field(        ext4_fsblk_t,   partial )
+               __field(        ext4_fsblk_t,   ee_pblk )
+               __field(        ext4_lblk_t,    ee_lblk )
+               __field(        unsigned short, ee_len  )
+       ),
+
+       TP_fast_assign(
+               __entry->dev            = inode->i_sb->s_dev;
+               __entry->ino            = inode->i_ino;
+               __entry->from           = from;
+               __entry->to             = to;
+               __entry->partial        = partial_cluster;
+               __entry->ee_pblk        = ext4_ext_pblock(ex);
+               __entry->ee_lblk        = cpu_to_le32(ex->ee_block);
+               __entry->ee_len         = ext4_ext_get_actual_len(ex);
+       ),
+
+       TP_printk("dev %d,%d ino %lu extent [%u(%llu), %u]"
+                 "from %u to %u partial_cluster %u",
+                 MAJOR(__entry->dev), MINOR(__entry->dev),
+                 (unsigned long) __entry->ino,
+                 (unsigned) __entry->ee_lblk,
+                 (unsigned long long) __entry->ee_pblk,
+                 (unsigned short) __entry->ee_len,
+                 (unsigned) __entry->from,
+                 (unsigned) __entry->to,
+                 (unsigned) __entry->partial)
+);
+
+TRACE_EVENT(ext4_ext_rm_leaf,
+       TP_PROTO(struct inode *inode, ext4_lblk_t start,
+                struct ext4_extent *ex, ext4_fsblk_t partial_cluster),
+
+       TP_ARGS(inode, start, ex, partial_cluster),
+
+       TP_STRUCT__entry(
+               __field(        dev_t,          dev     )
+               __field(        ino_t,          ino     )
+               __field(        ext4_fsblk_t,   partial )
+               __field(        ext4_lblk_t,    start   )
+               __field(        ext4_lblk_t,    ee_lblk )
+               __field(        ext4_fsblk_t,   ee_pblk )
+               __field(        short,          ee_len  )
+       ),
+
+       TP_fast_assign(
+               __entry->dev            = inode->i_sb->s_dev;
+               __entry->ino            = inode->i_ino;
+               __entry->partial        = partial_cluster;
+               __entry->start          = start;
+               __entry->ee_lblk        = le32_to_cpu(ex->ee_block);
+               __entry->ee_pblk        = ext4_ext_pblock(ex);
+               __entry->ee_len         = ext4_ext_get_actual_len(ex);
+       ),
+
+       TP_printk("dev %d,%d ino %lu start_lblk %u last_extent [%u(%llu), %u]"
+                 "partial_cluster %u",
+                 MAJOR(__entry->dev), MINOR(__entry->dev),
+                 (unsigned long) __entry->ino,
+                 (unsigned) __entry->start,
+                 (unsigned) __entry->ee_lblk,
+                 (unsigned long long) __entry->ee_pblk,
+                 (unsigned short) __entry->ee_len,
+                 (unsigned) __entry->partial)
+);
+
+TRACE_EVENT(ext4_ext_rm_idx,
+       TP_PROTO(struct inode *inode, ext4_fsblk_t pblk),
+
+       TP_ARGS(inode, pblk),
+
+       TP_STRUCT__entry(
+               __field(        dev_t,          dev     )
+               __field(        ino_t,          ino     )
+               __field(        ext4_fsblk_t,   pblk    )
+       ),
+
+       TP_fast_assign(
+               __entry->dev    = inode->i_sb->s_dev;
+               __entry->ino    = inode->i_ino;
+               __entry->pblk   = pblk;
+       ),
+
+       TP_printk("dev %d,%d ino %lu index_pblk %llu",
+                 MAJOR(__entry->dev), MINOR(__entry->dev),
+                 (unsigned long) __entry->ino,
+                 (unsigned long long) __entry->pblk)
+);
+
+TRACE_EVENT(ext4_ext_remove_space,
+       TP_PROTO(struct inode *inode, ext4_lblk_t start, int depth),
+
+       TP_ARGS(inode, start, depth),
+
+       TP_STRUCT__entry(
+               __field(        dev_t,          dev     )
+               __field(        ino_t,          ino     )
+               __field(        ext4_lblk_t,    start   )
+               __field(        int,            depth   )
+       ),
+
+       TP_fast_assign(
+               __entry->dev    = inode->i_sb->s_dev;
+               __entry->ino    = inode->i_ino;
+               __entry->start  = start;
+               __entry->depth  = depth;
+       ),
+
+       TP_printk("dev %d,%d ino %lu since %u depth %d",
+                 MAJOR(__entry->dev), MINOR(__entry->dev),
+                 (unsigned long) __entry->ino,
+                 (unsigned) __entry->start,
+                 __entry->depth)
+);
+
+TRACE_EVENT(ext4_ext_remove_space_done,
+       TP_PROTO(struct inode *inode, ext4_lblk_t start, int depth,
+               ext4_lblk_t partial, unsigned short eh_entries),
+
+       TP_ARGS(inode, start, depth, partial, eh_entries),
+
+       TP_STRUCT__entry(
+               __field(        dev_t,          dev             )
+               __field(        ino_t,          ino             )
+               __field(        ext4_lblk_t,    start           )
+               __field(        int,            depth           )
+               __field(        ext4_lblk_t,    partial         )
+               __field(        unsigned short, eh_entries      )
+       ),
+
+       TP_fast_assign(
+               __entry->dev            = inode->i_sb->s_dev;
+               __entry->ino            = inode->i_ino;
+               __entry->start          = start;
+               __entry->depth          = depth;
+               __entry->partial        = partial;
+               __entry->eh_entries     = eh_entries;
+       ),
+
+       TP_printk("dev %d,%d ino %lu since %u depth %d partial %u "
+                 "remaining_entries %u",
+                 MAJOR(__entry->dev), MINOR(__entry->dev),
+                 (unsigned long) __entry->ino,
+                 (unsigned) __entry->start,
+                 __entry->depth,
+                 (unsigned) __entry->partial,
+                 (unsigned short) __entry->eh_entries)
+);
+
+#endif /* _TRACE_EXT4_H */
+
+/* This part must be outside protection */
+#include <trace/define_trace.h>
diff --git a/drivers/staging/lttng/instrumentation/events/mainline/gpio.h b/drivers/staging/lttng/instrumentation/events/mainline/gpio.h
new file mode 100644 (file)
index 0000000..927a8ad
--- /dev/null
@@ -0,0 +1,56 @@
+#undef TRACE_SYSTEM
+#define TRACE_SYSTEM gpio
+
+#if !defined(_TRACE_GPIO_H) || defined(TRACE_HEADER_MULTI_READ)
+#define _TRACE_GPIO_H
+
+#include <linux/tracepoint.h>
+
+TRACE_EVENT(gpio_direction,
+
+       TP_PROTO(unsigned gpio, int in, int err),
+
+       TP_ARGS(gpio, in, err),
+
+       TP_STRUCT__entry(
+               __field(unsigned, gpio)
+               __field(int, in)
+               __field(int, err)
+       ),
+
+       TP_fast_assign(
+               __entry->gpio = gpio;
+               __entry->in = in;
+               __entry->err = err;
+       ),
+
+       TP_printk("%u %3s (%d)", __entry->gpio,
+               __entry->in ? "in" : "out", __entry->err)
+);
+
+TRACE_EVENT(gpio_value,
+
+       TP_PROTO(unsigned gpio, int get, int value),
+
+       TP_ARGS(gpio, get, value),
+
+       TP_STRUCT__entry(
+               __field(unsigned, gpio)
+               __field(int, get)
+               __field(int, value)
+       ),
+
+       TP_fast_assign(
+               __entry->gpio = gpio;
+               __entry->get = get;
+               __entry->value = value;
+       ),
+
+       TP_printk("%u %3s %d", __entry->gpio,
+               __entry->get ? "get" : "set", __entry->value)
+);
+
+#endif /* if !defined(_TRACE_GPIO_H) || defined(TRACE_HEADER_MULTI_READ) */
+
+/* This part must be outside protection */
+#include <trace/define_trace.h>
diff --git a/drivers/staging/lttng/instrumentation/events/mainline/irq.h b/drivers/staging/lttng/instrumentation/events/mainline/irq.h
new file mode 100644 (file)
index 0000000..1c09820
--- /dev/null
@@ -0,0 +1,150 @@
+#undef TRACE_SYSTEM
+#define TRACE_SYSTEM irq
+
+#if !defined(_TRACE_IRQ_H) || defined(TRACE_HEADER_MULTI_READ)
+#define _TRACE_IRQ_H
+
+#include <linux/tracepoint.h>
+
+struct irqaction;
+struct softirq_action;
+
+#define softirq_name(sirq) { sirq##_SOFTIRQ, #sirq }
+#define show_softirq_name(val)                         \
+       __print_symbolic(val,                           \
+                        softirq_name(HI),              \
+                        softirq_name(TIMER),           \
+                        softirq_name(NET_TX),          \
+                        softirq_name(NET_RX),          \
+                        softirq_name(BLOCK),           \
+                        softirq_name(BLOCK_IOPOLL),    \
+                        softirq_name(TASKLET),         \
+                        softirq_name(SCHED),           \
+                        softirq_name(HRTIMER),         \
+                        softirq_name(RCU))
+
+/**
+ * irq_handler_entry - called immediately before the irq action handler
+ * @irq: irq number
+ * @action: pointer to struct irqaction
+ *
+ * The struct irqaction pointed to by @action contains various
+ * information about the handler, including the device name,
+ * @action->name, and the device id, @action->dev_id. When used in
+ * conjunction with the irq_handler_exit tracepoint, we can figure
+ * out irq handler latencies.
+ */
+TRACE_EVENT(irq_handler_entry,
+
+       TP_PROTO(int irq, struct irqaction *action),
+
+       TP_ARGS(irq, action),
+
+       TP_STRUCT__entry(
+               __field(        int,    irq             )
+               __string(       name,   action->name    )
+       ),
+
+       TP_fast_assign(
+               __entry->irq = irq;
+               __assign_str(name, action->name);
+       ),
+
+       TP_printk("irq=%d name=%s", __entry->irq, __get_str(name))
+);
+
+/**
+ * irq_handler_exit - called immediately after the irq action handler returns
+ * @irq: irq number
+ * @action: pointer to struct irqaction
+ * @ret: return value
+ *
+ * If the @ret value is set to IRQ_HANDLED, then we know that the corresponding
+ * @action->handler scuccessully handled this irq. Otherwise, the irq might be
+ * a shared irq line, or the irq was not handled successfully. Can be used in
+ * conjunction with the irq_handler_entry to understand irq handler latencies.
+ */
+TRACE_EVENT(irq_handler_exit,
+
+       TP_PROTO(int irq, struct irqaction *action, int ret),
+
+       TP_ARGS(irq, action, ret),
+
+       TP_STRUCT__entry(
+               __field(        int,    irq     )
+               __field(        int,    ret     )
+       ),
+
+       TP_fast_assign(
+               __entry->irq    = irq;
+               __entry->ret    = ret;
+       ),
+
+       TP_printk("irq=%d ret=%s",
+                 __entry->irq, __entry->ret ? "handled" : "unhandled")
+);
+
+DECLARE_EVENT_CLASS(softirq,
+
+       TP_PROTO(unsigned int vec_nr),
+
+       TP_ARGS(vec_nr),
+
+       TP_STRUCT__entry(
+               __field(        unsigned int,   vec     )
+       ),
+
+       TP_fast_assign(
+               __entry->vec = vec_nr;
+       ),
+
+       TP_printk("vec=%u [action=%s]", __entry->vec,
+                 show_softirq_name(__entry->vec))
+);
+
+/**
+ * softirq_entry - called immediately before the softirq handler
+ * @vec_nr:  softirq vector number
+ *
+ * When used in combination with the softirq_exit tracepoint
+ * we can determine the softirq handler runtine.
+ */
+DEFINE_EVENT(softirq, softirq_entry,
+
+       TP_PROTO(unsigned int vec_nr),
+
+       TP_ARGS(vec_nr)
+);
+
+/**
+ * softirq_exit - called immediately after the softirq handler returns
+ * @vec_nr:  softirq vector number
+ *
+ * When used in combination with the softirq_entry tracepoint
+ * we can determine the softirq handler runtine.
+ */
+DEFINE_EVENT(softirq, softirq_exit,
+
+       TP_PROTO(unsigned int vec_nr),
+
+       TP_ARGS(vec_nr)
+);
+
+/**
+ * softirq_raise - called immediately when a softirq is raised
+ * @vec_nr:  softirq vector number
+ *
+ * When used in combination with the softirq_entry tracepoint
+ * we can determine the softirq raise to run latency.
+ */
+DEFINE_EVENT(softirq, softirq_raise,
+
+       TP_PROTO(unsigned int vec_nr),
+
+       TP_ARGS(vec_nr)
+);
+
+#endif /*  _TRACE_IRQ_H */
+
+/* This part must be outside protection */
+#include <trace/define_trace.h>
diff --git a/drivers/staging/lttng/instrumentation/events/mainline/jbd.h b/drivers/staging/lttng/instrumentation/events/mainline/jbd.h
new file mode 100644 (file)
index 0000000..da6f259
--- /dev/null
@@ -0,0 +1,194 @@
+#undef TRACE_SYSTEM
+#define TRACE_SYSTEM jbd
+
+#if !defined(_TRACE_JBD_H) || defined(TRACE_HEADER_MULTI_READ)
+#define _TRACE_JBD_H
+
+#include <linux/jbd.h>
+#include <linux/tracepoint.h>
+
+TRACE_EVENT(jbd_checkpoint,
+
+       TP_PROTO(journal_t *journal, int result),
+
+       TP_ARGS(journal, result),
+
+       TP_STRUCT__entry(
+               __field(        dev_t,  dev                     )
+               __field(        int,    result                  )
+       ),
+
+       TP_fast_assign(
+               __entry->dev            = journal->j_fs_dev->bd_dev;
+               __entry->result         = result;
+       ),
+
+       TP_printk("dev %d,%d result %d",
+                 MAJOR(__entry->dev), MINOR(__entry->dev),
+                 __entry->result)
+);
+
+DECLARE_EVENT_CLASS(jbd_commit,
+
+       TP_PROTO(journal_t *journal, transaction_t *commit_transaction),
+
+       TP_ARGS(journal, commit_transaction),
+
+       TP_STRUCT__entry(
+               __field(        dev_t,  dev                     )
+               __field(        int,    transaction             )
+       ),
+
+       TP_fast_assign(
+               __entry->dev            = journal->j_fs_dev->bd_dev;
+               __entry->transaction    = commit_transaction->t_tid;
+       ),
+
+       TP_printk("dev %d,%d transaction %d",
+                 MAJOR(__entry->dev), MINOR(__entry->dev),
+                 __entry->transaction)
+);
+
+DEFINE_EVENT(jbd_commit, jbd_start_commit,
+
+       TP_PROTO(journal_t *journal, transaction_t *commit_transaction),
+
+       TP_ARGS(journal, commit_transaction)
+);
+
+DEFINE_EVENT(jbd_commit, jbd_commit_locking,
+
+       TP_PROTO(journal_t *journal, transaction_t *commit_transaction),
+
+       TP_ARGS(journal, commit_transaction)
+);
+
+DEFINE_EVENT(jbd_commit, jbd_commit_flushing,
+
+       TP_PROTO(journal_t *journal, transaction_t *commit_transaction),
+
+       TP_ARGS(journal, commit_transaction)
+);
+
+DEFINE_EVENT(jbd_commit, jbd_commit_logging,
+
+       TP_PROTO(journal_t *journal, transaction_t *commit_transaction),
+
+       TP_ARGS(journal, commit_transaction)
+);
+
+TRACE_EVENT(jbd_drop_transaction,
+
+       TP_PROTO(journal_t *journal, transaction_t *commit_transaction),
+
+       TP_ARGS(journal, commit_transaction),
+
+       TP_STRUCT__entry(
+               __field(        dev_t,  dev                     )
+               __field(        int,    transaction             )
+       ),
+
+       TP_fast_assign(
+               __entry->dev            = journal->j_fs_dev->bd_dev;
+               __entry->transaction    = commit_transaction->t_tid;
+       ),
+
+       TP_printk("dev %d,%d transaction %d",
+                 MAJOR(__entry->dev), MINOR(__entry->dev),
+                 __entry->transaction)
+);
+
+TRACE_EVENT(jbd_end_commit,
+       TP_PROTO(journal_t *journal, transaction_t *commit_transaction),
+
+       TP_ARGS(journal, commit_transaction),
+
+       TP_STRUCT__entry(
+               __field(        dev_t,  dev                     )
+               __field(        int,    transaction             )
+               __field(        int,    head                    )
+       ),
+
+       TP_fast_assign(
+               __entry->dev            = journal->j_fs_dev->bd_dev;
+               __entry->transaction    = commit_transaction->t_tid;
+               __entry->head           = journal->j_tail_sequence;
+       ),
+
+       TP_printk("dev %d,%d transaction %d head %d",
+                 MAJOR(__entry->dev), MINOR(__entry->dev),
+                 __entry->transaction, __entry->head)
+);
+
+TRACE_EVENT(jbd_do_submit_data,
+       TP_PROTO(journal_t *journal, transaction_t *commit_transaction),
+
+       TP_ARGS(journal, commit_transaction),
+
+       TP_STRUCT__entry(
+               __field(        dev_t,  dev                     )
+               __field(        int,    transaction             )
+       ),
+
+       TP_fast_assign(
+               __entry->dev            = journal->j_fs_dev->bd_dev;
+               __entry->transaction    = commit_transaction->t_tid;
+       ),
+
+       TP_printk("dev %d,%d transaction %d",
+                 MAJOR(__entry->dev), MINOR(__entry->dev),
+                  __entry->transaction)
+);
+
+TRACE_EVENT(jbd_cleanup_journal_tail,
+
+       TP_PROTO(journal_t *journal, tid_t first_tid,
+                unsigned long block_nr, unsigned long freed),
+
+       TP_ARGS(journal, first_tid, block_nr, freed),
+
+       TP_STRUCT__entry(
+               __field(        dev_t,  dev                     )
+               __field(        tid_t,  tail_sequence           )
+               __field(        tid_t,  first_tid               )
+               __field(unsigned long,  block_nr                )
+               __field(unsigned long,  freed                   )
+       ),
+
+       TP_fast_assign(
+               __entry->dev            = journal->j_fs_dev->bd_dev;
+               __entry->tail_sequence  = journal->j_tail_sequence;
+               __entry->first_tid      = first_tid;
+               __entry->block_nr       = block_nr;
+               __entry->freed          = freed;
+       ),
+
+       TP_printk("dev %d,%d from %u to %u offset %lu freed %lu",
+                 MAJOR(__entry->dev), MINOR(__entry->dev),
+                 __entry->tail_sequence, __entry->first_tid,
+                 __entry->block_nr, __entry->freed)
+);
+
+TRACE_EVENT(journal_write_superblock,
+       TP_PROTO(journal_t *journal, int write_op),
+
+       TP_ARGS(journal, write_op),
+
+       TP_STRUCT__entry(
+               __field(        dev_t,  dev                     )
+               __field(        int,    write_op                )
+       ),
+
+       TP_fast_assign(
+               __entry->dev            = journal->j_fs_dev->bd_dev;
+               __entry->write_op       = write_op;
+       ),
+
+       TP_printk("dev %d,%d write_op %x", MAJOR(__entry->dev),
+                 MINOR(__entry->dev), __entry->write_op)
+);
+
+#endif /* _TRACE_JBD_H */
+
+/* This part must be outside protection */
+#include <trace/define_trace.h>
diff --git a/drivers/staging/lttng/instrumentation/events/mainline/jbd2.h b/drivers/staging/lttng/instrumentation/events/mainline/jbd2.h
new file mode 100644 (file)
index 0000000..127993d
--- /dev/null
@@ -0,0 +1,262 @@
+#undef TRACE_SYSTEM
+#define TRACE_SYSTEM jbd2
+
+#if !defined(_TRACE_JBD2_H) || defined(TRACE_HEADER_MULTI_READ)
+#define _TRACE_JBD2_H
+
+#include <linux/jbd2.h>
+#include <linux/tracepoint.h>
+
+struct transaction_chp_stats_s;
+struct transaction_run_stats_s;
+
+TRACE_EVENT(jbd2_checkpoint,
+
+       TP_PROTO(journal_t *journal, int result),
+
+       TP_ARGS(journal, result),
+
+       TP_STRUCT__entry(
+               __field(        dev_t,  dev                     )
+               __field(        int,    result                  )
+       ),
+
+       TP_fast_assign(
+               __entry->dev            = journal->j_fs_dev->bd_dev;
+               __entry->result         = result;
+       ),
+
+       TP_printk("dev %d,%d result %d",
+                 MAJOR(__entry->dev), MINOR(__entry->dev), __entry->result)
+);
+
+DECLARE_EVENT_CLASS(jbd2_commit,
+
+       TP_PROTO(journal_t *journal, transaction_t *commit_transaction),
+
+       TP_ARGS(journal, commit_transaction),
+
+       TP_STRUCT__entry(
+               __field(        dev_t,  dev                     )
+               __field(        char,   sync_commit               )
+               __field(        int,    transaction               )
+       ),
+
+       TP_fast_assign(
+               __entry->dev            = journal->j_fs_dev->bd_dev;
+               __entry->sync_commit = commit_transaction->t_synchronous_commit;
+               __entry->transaction    = commit_transaction->t_tid;
+       ),
+
+       TP_printk("dev %d,%d transaction %d sync %d",
+                 MAJOR(__entry->dev), MINOR(__entry->dev),
+                 __entry->transaction, __entry->sync_commit)
+);
+
+DEFINE_EVENT(jbd2_commit, jbd2_start_commit,
+
+       TP_PROTO(journal_t *journal, transaction_t *commit_transaction),
+
+       TP_ARGS(journal, commit_transaction)
+);
+
+DEFINE_EVENT(jbd2_commit, jbd2_commit_locking,
+
+       TP_PROTO(journal_t *journal, transaction_t *commit_transaction),
+
+       TP_ARGS(journal, commit_transaction)
+);
+
+DEFINE_EVENT(jbd2_commit, jbd2_commit_flushing,
+
+       TP_PROTO(journal_t *journal, transaction_t *commit_transaction),
+
+       TP_ARGS(journal, commit_transaction)
+);
+
+DEFINE_EVENT(jbd2_commit, jbd2_commit_logging,
+
+       TP_PROTO(journal_t *journal, transaction_t *commit_transaction),
+
+       TP_ARGS(journal, commit_transaction)
+);
+
+DEFINE_EVENT(jbd2_commit, jbd2_drop_transaction,
+
+       TP_PROTO(journal_t *journal, transaction_t *commit_transaction),
+
+       TP_ARGS(journal, commit_transaction)
+);
+
+TRACE_EVENT(jbd2_end_commit,
+       TP_PROTO(journal_t *journal, transaction_t *commit_transaction),
+
+       TP_ARGS(journal, commit_transaction),
+
+       TP_STRUCT__entry(
+               __field(        dev_t,  dev                     )
+               __field(        char,   sync_commit               )
+               __field(        int,    transaction               )
+               __field(        int,    head                      )
+       ),
+
+       TP_fast_assign(
+               __entry->dev            = journal->j_fs_dev->bd_dev;
+               __entry->sync_commit = commit_transaction->t_synchronous_commit;
+               __entry->transaction    = commit_transaction->t_tid;
+               __entry->head           = journal->j_tail_sequence;
+       ),
+
+       TP_printk("dev %d,%d transaction %d sync %d head %d",
+                 MAJOR(__entry->dev), MINOR(__entry->dev),
+                 __entry->transaction, __entry->sync_commit, __entry->head)
+);
+
+TRACE_EVENT(jbd2_submit_inode_data,
+       TP_PROTO(struct inode *inode),
+
+       TP_ARGS(inode),
+
+       TP_STRUCT__entry(
+               __field(        dev_t,  dev                     )
+               __field(        ino_t,  ino                     )
+       ),
+
+       TP_fast_assign(
+               __entry->dev    = inode->i_sb->s_dev;
+               __entry->ino    = inode->i_ino;
+       ),
+
+       TP_printk("dev %d,%d ino %lu",
+                 MAJOR(__entry->dev), MINOR(__entry->dev),
+                 (unsigned long) __entry->ino)
+);
+
+TRACE_EVENT(jbd2_run_stats,
+       TP_PROTO(dev_t dev, unsigned long tid,
+                struct transaction_run_stats_s *stats),
+
+       TP_ARGS(dev, tid, stats),
+
+       TP_STRUCT__entry(
+               __field(                dev_t,  dev             )
+               __field(        unsigned long,  tid             )
+               __field(        unsigned long,  wait            )
+               __field(        unsigned long,  running         )
+               __field(        unsigned long,  locked          )
+               __field(        unsigned long,  flushing        )
+               __field(        unsigned long,  logging         )
+               __field(                __u32,  handle_count    )
+               __field(                __u32,  blocks          )
+               __field(                __u32,  blocks_logged   )
+       ),
+
+       TP_fast_assign(
+               __entry->dev            = dev;
+               __entry->tid            = tid;
+               __entry->wait           = stats->rs_wait;
+               __entry->running        = stats->rs_running;
+               __entry->locked         = stats->rs_locked;
+               __entry->flushing       = stats->rs_flushing;
+               __entry->logging        = stats->rs_logging;
+               __entry->handle_count   = stats->rs_handle_count;
+               __entry->blocks         = stats->rs_blocks;
+               __entry->blocks_logged  = stats->rs_blocks_logged;
+       ),
+
+       TP_printk("dev %d,%d tid %lu wait %u running %u locked %u flushing %u "
+                 "logging %u handle_count %u blocks %u blocks_logged %u",
+                 MAJOR(__entry->dev), MINOR(__entry->dev), __entry->tid,
+                 jiffies_to_msecs(__entry->wait),
+                 jiffies_to_msecs(__entry->running),
+                 jiffies_to_msecs(__entry->locked),
+                 jiffies_to_msecs(__entry->flushing),
+                 jiffies_to_msecs(__entry->logging),
+                 __entry->handle_count, __entry->blocks,
+                 __entry->blocks_logged)
+);
+
+TRACE_EVENT(jbd2_checkpoint_stats,
+       TP_PROTO(dev_t dev, unsigned long tid,
+                struct transaction_chp_stats_s *stats),
+
+       TP_ARGS(dev, tid, stats),
+
+       TP_STRUCT__entry(
+               __field(                dev_t,  dev             )
+               __field(        unsigned long,  tid             )
+               __field(        unsigned long,  chp_time        )
+               __field(                __u32,  forced_to_close )
+               __field(                __u32,  written         )
+               __field(                __u32,  dropped         )
+       ),
+
+       TP_fast_assign(
+               __entry->dev            = dev;
+               __entry->tid            = tid;
+               __entry->chp_time       = stats->cs_chp_time;
+               __entry->forced_to_close= stats->cs_forced_to_close;
+               __entry->written        = stats->cs_written;
+               __entry->dropped        = stats->cs_dropped;
+       ),
+
+       TP_printk("dev %d,%d tid %lu chp_time %u forced_to_close %u "
+                 "written %u dropped %u",
+                 MAJOR(__entry->dev), MINOR(__entry->dev), __entry->tid,
+                 jiffies_to_msecs(__entry->chp_time),
+                 __entry->forced_to_close, __entry->written, __entry->dropped)
+);
+
+TRACE_EVENT(jbd2_update_log_tail,
+
+       TP_PROTO(journal_t *journal, tid_t first_tid,
+                unsigned long block_nr, unsigned long freed),
+
+       TP_ARGS(journal, first_tid, block_nr, freed),
+
+       TP_STRUCT__entry(
+               __field(        dev_t,  dev                     )
+               __field(        tid_t,  tail_sequence           )
+               __field(        tid_t,  first_tid               )
+               __field(unsigned long,  block_nr                )
+               __field(unsigned long,  freed                   )
+       ),
+
+       TP_fast_assign(
+               __entry->dev            = journal->j_fs_dev->bd_dev;
+               __entry->tail_sequence  = journal->j_tail_sequence;
+               __entry->first_tid      = first_tid;
+               __entry->block_nr       = block_nr;
+               __entry->freed          = freed;
+       ),
+
+       TP_printk("dev %d,%d from %u to %u offset %lu freed %lu",
+                 MAJOR(__entry->dev), MINOR(__entry->dev),
+                 __entry->tail_sequence, __entry->first_tid,
+                 __entry->block_nr, __entry->freed)
+);
+
+TRACE_EVENT(jbd2_write_superblock,
+
+       TP_PROTO(journal_t *journal, int write_op),
+
+       TP_ARGS(journal, write_op),
+
+       TP_STRUCT__entry(
+               __field(        dev_t,  dev                     )
+               __field(          int,  write_op                )
+       ),
+
+       TP_fast_assign(
+               __entry->dev            = journal->j_fs_dev->bd_dev;
+               __entry->write_op       = write_op;
+       ),
+
+       TP_printk("dev %d,%d write_op %x", MAJOR(__entry->dev),
+                 MINOR(__entry->dev), __entry->write_op)
+);
+
+#endif /* _TRACE_JBD2_H */
+
+/* This part must be outside protection */
+#include <trace/define_trace.h>
diff --git a/drivers/staging/lttng/instrumentation/events/mainline/kmem.h b/drivers/staging/lttng/instrumentation/events/mainline/kmem.h
new file mode 100644 (file)
index 0000000..6bc943e
--- /dev/null
@@ -0,0 +1,308 @@
+#undef TRACE_SYSTEM
+#define TRACE_SYSTEM kmem
+
+#if !defined(_TRACE_KMEM_H) || defined(TRACE_HEADER_MULTI_READ)
+#define _TRACE_KMEM_H
+
+#include <linux/types.h>
+#include <linux/tracepoint.h>
+#include <trace/events/gfpflags.h>
+
+DECLARE_EVENT_CLASS(kmem_alloc,
+
+       TP_PROTO(unsigned long call_site,
+                const void *ptr,
+                size_t bytes_req,
+                size_t bytes_alloc,
+                gfp_t gfp_flags),
+
+       TP_ARGS(call_site, ptr, bytes_req, bytes_alloc, gfp_flags),
+
+       TP_STRUCT__entry(
+               __field(        unsigned long,  call_site       )
+               __field(        const void *,   ptr             )
+               __field(        size_t,         bytes_req       )
+               __field(        size_t,         bytes_alloc     )
+               __field(        gfp_t,          gfp_flags       )
+       ),
+
+       TP_fast_assign(
+               __entry->call_site      = call_site;
+               __entry->ptr            = ptr;
+               __entry->bytes_req      = bytes_req;
+               __entry->bytes_alloc    = bytes_alloc;
+               __entry->gfp_flags      = gfp_flags;
+       ),
+
+       TP_printk("call_site=%lx ptr=%p bytes_req=%zu bytes_alloc=%zu gfp_flags=%s",
+               __entry->call_site,
+               __entry->ptr,
+               __entry->bytes_req,
+               __entry->bytes_alloc,
+               show_gfp_flags(__entry->gfp_flags))
+);
+
+DEFINE_EVENT(kmem_alloc, kmalloc,
+
+       TP_PROTO(unsigned long call_site, const void *ptr,
+                size_t bytes_req, size_t bytes_alloc, gfp_t gfp_flags),
+
+       TP_ARGS(call_site, ptr, bytes_req, bytes_alloc, gfp_flags)
+);
+
+DEFINE_EVENT(kmem_alloc, kmem_cache_alloc,
+
+       TP_PROTO(unsigned long call_site, const void *ptr,
+                size_t bytes_req, size_t bytes_alloc, gfp_t gfp_flags),
+
+       TP_ARGS(call_site, ptr, bytes_req, bytes_alloc, gfp_flags)
+);
+
+DECLARE_EVENT_CLASS(kmem_alloc_node,
+
+       TP_PROTO(unsigned long call_site,
+                const void *ptr,
+                size_t bytes_req,
+                size_t bytes_alloc,
+                gfp_t gfp_flags,
+                int node),
+
+       TP_ARGS(call_site, ptr, bytes_req, bytes_alloc, gfp_flags, node),
+
+       TP_STRUCT__entry(
+               __field(        unsigned long,  call_site       )
+               __field(        const void *,   ptr             )
+               __field(        size_t,         bytes_req       )
+               __field(        size_t,         bytes_alloc     )
+               __field(        gfp_t,          gfp_flags       )
+               __field(        int,            node            )
+       ),
+
+       TP_fast_assign(
+               __entry->call_site      = call_site;
+               __entry->ptr            = ptr;
+               __entry->bytes_req      = bytes_req;
+               __entry->bytes_alloc    = bytes_alloc;
+               __entry->gfp_flags      = gfp_flags;
+               __entry->node           = node;
+       ),
+
+       TP_printk("call_site=%lx ptr=%p bytes_req=%zu bytes_alloc=%zu gfp_flags=%s node=%d",
+               __entry->call_site,
+               __entry->ptr,
+               __entry->bytes_req,
+               __entry->bytes_alloc,
+               show_gfp_flags(__entry->gfp_flags),
+               __entry->node)
+);
+
+DEFINE_EVENT(kmem_alloc_node, kmalloc_node,
+
+       TP_PROTO(unsigned long call_site, const void *ptr,
+                size_t bytes_req, size_t bytes_alloc,
+                gfp_t gfp_flags, int node),
+
+       TP_ARGS(call_site, ptr, bytes_req, bytes_alloc, gfp_flags, node)
+);
+
+DEFINE_EVENT(kmem_alloc_node, kmem_cache_alloc_node,
+
+       TP_PROTO(unsigned long call_site, const void *ptr,
+                size_t bytes_req, size_t bytes_alloc,
+                gfp_t gfp_flags, int node),
+
+       TP_ARGS(call_site, ptr, bytes_req, bytes_alloc, gfp_flags, node)
+);
+
+DECLARE_EVENT_CLASS(kmem_free,
+
+       TP_PROTO(unsigned long call_site, const void *ptr),
+
+       TP_ARGS(call_site, ptr),
+
+       TP_STRUCT__entry(
+               __field(        unsigned long,  call_site       )
+               __field(        const void *,   ptr             )
+       ),
+
+       TP_fast_assign(
+               __entry->call_site      = call_site;
+               __entry->ptr            = ptr;
+       ),
+
+       TP_printk("call_site=%lx ptr=%p", __entry->call_site, __entry->ptr)
+);
+
+DEFINE_EVENT(kmem_free, kfree,
+
+       TP_PROTO(unsigned long call_site, const void *ptr),
+
+       TP_ARGS(call_site, ptr)
+);
+
+DEFINE_EVENT(kmem_free, kmem_cache_free,
+
+       TP_PROTO(unsigned long call_site, const void *ptr),
+
+       TP_ARGS(call_site, ptr)
+);
+
+TRACE_EVENT(mm_page_free,
+
+       TP_PROTO(struct page *page, unsigned int order),
+
+       TP_ARGS(page, order),
+
+       TP_STRUCT__entry(
+               __field(        struct page *,  page            )
+               __field(        unsigned int,   order           )
+       ),
+
+       TP_fast_assign(
+               __entry->page           = page;
+               __entry->order          = order;
+       ),
+
+       TP_printk("page=%p pfn=%lu order=%d",
+                       __entry->page,
+                       page_to_pfn(__entry->page),
+                       __entry->order)
+);
+
+TRACE_EVENT(mm_page_free_batched,
+
+       TP_PROTO(struct page *page, int cold),
+
+       TP_ARGS(page, cold),
+
+       TP_STRUCT__entry(
+               __field(        struct page *,  page            )
+               __field(        int,            cold            )
+       ),
+
+       TP_fast_assign(
+               __entry->page           = page;
+               __entry->cold           = cold;
+       ),
+
+       TP_printk("page=%p pfn=%lu order=0 cold=%d",
+                       __entry->page,
+                       page_to_pfn(__entry->page),
+                       __entry->cold)
+);
+
+TRACE_EVENT(mm_page_alloc,
+
+       TP_PROTO(struct page *page, unsigned int order,
+                       gfp_t gfp_flags, int migratetype),
+
+       TP_ARGS(page, order, gfp_flags, migratetype),
+
+       TP_STRUCT__entry(
+               __field(        struct page *,  page            )
+               __field(        unsigned int,   order           )
+               __field(        gfp_t,          gfp_flags       )
+               __field(        int,            migratetype     )
+       ),
+
+       TP_fast_assign(
+               __entry->page           = page;
+               __entry->order          = order;
+               __entry->gfp_flags      = gfp_flags;
+               __entry->migratetype    = migratetype;
+       ),
+
+       TP_printk("page=%p pfn=%lu order=%d migratetype=%d gfp_flags=%s",
+               __entry->page,
+               __entry->page ? page_to_pfn(__entry->page) : 0,
+               __entry->order,
+               __entry->migratetype,
+               show_gfp_flags(__entry->gfp_flags))
+);
+
+DECLARE_EVENT_CLASS(mm_page,
+
+       TP_PROTO(struct page *page, unsigned int order, int migratetype),
+
+       TP_ARGS(page, order, migratetype),
+
+       TP_STRUCT__entry(
+               __field(        struct page *,  page            )
+               __field(        unsigned int,   order           )
+               __field(        int,            migratetype     )
+       ),
+
+       TP_fast_assign(
+               __entry->page           = page;
+               __entry->order          = order;
+               __entry->migratetype    = migratetype;
+       ),
+
+       TP_printk("page=%p pfn=%lu order=%u migratetype=%d percpu_refill=%d",
+               __entry->page,
+               __entry->page ? page_to_pfn(__entry->page) : 0,
+               __entry->order,
+               __entry->migratetype,
+               __entry->order == 0)
+);
+
+DEFINE_EVENT(mm_page, mm_page_alloc_zone_locked,
+
+       TP_PROTO(struct page *page, unsigned int order, int migratetype),
+
+       TP_ARGS(page, order, migratetype)
+);
+
+DEFINE_EVENT_PRINT(mm_page, mm_page_pcpu_drain,
+
+       TP_PROTO(struct page *page, unsigned int order, int migratetype),
+
+       TP_ARGS(page, order, migratetype),
+
+       TP_printk("page=%p pfn=%lu order=%d migratetype=%d",
+               __entry->page, page_to_pfn(__entry->page),
+               __entry->order, __entry->migratetype)
+);
+
+TRACE_EVENT(mm_page_alloc_extfrag,
+
+       TP_PROTO(struct page *page,
+                       int alloc_order, int fallback_order,
+                       int alloc_migratetype, int fallback_migratetype),
+
+       TP_ARGS(page,
+               alloc_order, fallback_order,
+               alloc_migratetype, fallback_migratetype),
+
+       TP_STRUCT__entry(
+               __field(        struct page *,  page                    )
+               __field(        int,            alloc_order             )
+               __field(        int,            fallback_order          )
+               __field(        int,            alloc_migratetype       )
+               __field(        int,            fallback_migratetype    )
+       ),
+
+       TP_fast_assign(
+               __entry->page                   = page;
+               __entry->alloc_order            = alloc_order;
+               __entry->fallback_order         = fallback_order;
+               __entry->alloc_migratetype      = alloc_migratetype;
+               __entry->fallback_migratetype   = fallback_migratetype;
+       ),
+
+       TP_printk("page=%p pfn=%lu alloc_order=%d fallback_order=%d pageblock_order=%d alloc_migratetype=%d fallback_migratetype=%d fragmenting=%d change_ownership=%d",
+               __entry->page,
+               page_to_pfn(__entry->page),
+               __entry->alloc_order,
+               __entry->fallback_order,
+               pageblock_order,
+               __entry->alloc_migratetype,
+               __entry->fallback_migratetype,
+               __entry->fallback_order < pageblock_order,
+               __entry->alloc_migratetype == __entry->fallback_migratetype)
+);
+
+#endif /* _TRACE_KMEM_H */
+
+/* This part must be outside protection */
+#include <trace/define_trace.h>
diff --git a/drivers/staging/lttng/instrumentation/events/mainline/kvm.h b/drivers/staging/lttng/instrumentation/events/mainline/kvm.h
new file mode 100644 (file)
index 0000000..46e3cd8
--- /dev/null
@@ -0,0 +1,312 @@
+#if !defined(_TRACE_KVM_MAIN_H) || defined(TRACE_HEADER_MULTI_READ)
+#define _TRACE_KVM_MAIN_H
+
+#include <linux/tracepoint.h>
+
+#undef TRACE_SYSTEM
+#define TRACE_SYSTEM kvm
+
+#define ERSN(x) { KVM_EXIT_##x, "KVM_EXIT_" #x }
+
+#define kvm_trace_exit_reason                                          \
+       ERSN(UNKNOWN), ERSN(EXCEPTION), ERSN(IO), ERSN(HYPERCALL),      \
+       ERSN(DEBUG), ERSN(HLT), ERSN(MMIO), ERSN(IRQ_WINDOW_OPEN),      \
+       ERSN(SHUTDOWN), ERSN(FAIL_ENTRY), ERSN(INTR), ERSN(SET_TPR),    \
+       ERSN(TPR_ACCESS), ERSN(S390_SIEIC), ERSN(S390_RESET), ERSN(DCR),\
+       ERSN(NMI), ERSN(INTERNAL_ERROR), ERSN(OSI)
+
+TRACE_EVENT(kvm_userspace_exit,
+           TP_PROTO(__u32 reason, int errno),
+           TP_ARGS(reason, errno),
+
+       TP_STRUCT__entry(
+               __field(        __u32,          reason          )
+               __field(        int,            errno           )
+       ),
+
+       TP_fast_assign(
+               __entry->reason         = reason;
+               __entry->errno          = errno;
+       ),
+
+       TP_printk("reason %s (%d)",
+                 __entry->errno < 0 ?
+                 (__entry->errno == -EINTR ? "restart" : "error") :
+                 __print_symbolic(__entry->reason, kvm_trace_exit_reason),
+                 __entry->errno < 0 ? -__entry->errno : __entry->reason)
+);
+
+#if defined(__KVM_HAVE_IOAPIC)
+TRACE_EVENT(kvm_set_irq,
+       TP_PROTO(unsigned int gsi, int level, int irq_source_id),
+       TP_ARGS(gsi, level, irq_source_id),
+
+       TP_STRUCT__entry(
+               __field(        unsigned int,   gsi             )
+               __field(        int,            level           )
+               __field(        int,            irq_source_id   )
+       ),
+
+       TP_fast_assign(
+               __entry->gsi            = gsi;
+               __entry->level          = level;
+               __entry->irq_source_id  = irq_source_id;
+       ),
+
+       TP_printk("gsi %u level %d source %d",
+                 __entry->gsi, __entry->level, __entry->irq_source_id)
+);
+
+#define kvm_deliver_mode               \
+       {0x0, "Fixed"},                 \
+       {0x1, "LowPrio"},               \
+       {0x2, "SMI"},                   \
+       {0x3, "Res3"},                  \
+       {0x4, "NMI"},                   \
+       {0x5, "INIT"},                  \
+       {0x6, "SIPI"},                  \
+       {0x7, "ExtINT"}
+
+TRACE_EVENT(kvm_ioapic_set_irq,
+           TP_PROTO(__u64 e, int pin, bool coalesced),
+           TP_ARGS(e, pin, coalesced),
+
+       TP_STRUCT__entry(
+               __field(        __u64,          e               )
+               __field(        int,            pin             )
+               __field(        bool,           coalesced       )
+       ),
+
+       TP_fast_assign(
+               __entry->e              = e;
+               __entry->pin            = pin;
+               __entry->coalesced      = coalesced;
+       ),
+
+       TP_printk("pin %u dst %x vec=%u (%s|%s|%s%s)%s",
+                 __entry->pin, (u8)(__entry->e >> 56), (u8)__entry->e,
+                 __print_symbolic((__entry->e >> 8 & 0x7), kvm_deliver_mode),
+                 (__entry->e & (1<<11)) ? "logical" : "physical",
+                 (__entry->e & (1<<15)) ? "level" : "edge",
+                 (__entry->e & (1<<16)) ? "|masked" : "",
+                 __entry->coalesced ? " (coalesced)" : "")
+);
+
+TRACE_EVENT(kvm_msi_set_irq,
+           TP_PROTO(__u64 address, __u64 data),
+           TP_ARGS(address, data),
+
+       TP_STRUCT__entry(
+               __field(        __u64,          address         )
+               __field(        __u64,          data            )
+       ),
+
+       TP_fast_assign(
+               __entry->address        = address;
+               __entry->data           = data;
+       ),
+
+       TP_printk("dst %u vec %x (%s|%s|%s%s)",
+                 (u8)(__entry->address >> 12), (u8)__entry->data,
+                 __print_symbolic((__entry->data >> 8 & 0x7), kvm_deliver_mode),
+                 (__entry->address & (1<<2)) ? "logical" : "physical",
+                 (__entry->data & (1<<15)) ? "level" : "edge",
+                 (__entry->address & (1<<3)) ? "|rh" : "")
+);
+
+#define kvm_irqchips                                           \
+       {KVM_IRQCHIP_PIC_MASTER,        "PIC master"},          \
+       {KVM_IRQCHIP_PIC_SLAVE,         "PIC slave"},           \
+       {KVM_IRQCHIP_IOAPIC,            "IOAPIC"}
+
+TRACE_EVENT(kvm_ack_irq,
+       TP_PROTO(unsigned int irqchip, unsigned int pin),
+       TP_ARGS(irqchip, pin),
+
+       TP_STRUCT__entry(
+               __field(        unsigned int,   irqchip         )
+               __field(        unsigned int,   pin             )
+       ),
+
+       TP_fast_assign(
+               __entry->irqchip        = irqchip;
+               __entry->pin            = pin;
+       ),
+
+       TP_printk("irqchip %s pin %u",
+                 __print_symbolic(__entry->irqchip, kvm_irqchips),
+                __entry->pin)
+);
+
+
+
+#endif /* defined(__KVM_HAVE_IOAPIC) */
+
+#define KVM_TRACE_MMIO_READ_UNSATISFIED 0
+#define KVM_TRACE_MMIO_READ 1
+#define KVM_TRACE_MMIO_WRITE 2
+
+#define kvm_trace_symbol_mmio \
+       { KVM_TRACE_MMIO_READ_UNSATISFIED, "unsatisfied-read" }, \
+       { KVM_TRACE_MMIO_READ, "read" }, \
+       { KVM_TRACE_MMIO_WRITE, "write" }
+
+TRACE_EVENT(kvm_mmio,
+       TP_PROTO(int type, int len, u64 gpa, u64 val),
+       TP_ARGS(type, len, gpa, val),
+
+       TP_STRUCT__entry(
+               __field(        u32,    type            )
+               __field(        u32,    len             )
+               __field(        u64,    gpa             )
+               __field(        u64,    val             )
+       ),
+
+       TP_fast_assign(
+               __entry->type           = type;
+               __entry->len            = len;
+               __entry->gpa            = gpa;
+               __entry->val            = val;
+       ),
+
+       TP_printk("mmio %s len %u gpa 0x%llx val 0x%llx",
+                 __print_symbolic(__entry->type, kvm_trace_symbol_mmio),
+                 __entry->len, __entry->gpa, __entry->val)
+);
+
+#define kvm_fpu_load_symbol    \
+       {0, "unload"},          \
+       {1, "load"}
+
+TRACE_EVENT(kvm_fpu,
+       TP_PROTO(int load),
+       TP_ARGS(load),
+
+       TP_STRUCT__entry(
+               __field(        u32,            load            )
+       ),
+
+       TP_fast_assign(
+               __entry->load           = load;
+       ),
+
+       TP_printk("%s", __print_symbolic(__entry->load, kvm_fpu_load_symbol))
+);
+
+TRACE_EVENT(kvm_age_page,
+       TP_PROTO(ulong hva, struct kvm_memory_slot *slot, int ref),
+       TP_ARGS(hva, slot, ref),
+
+       TP_STRUCT__entry(
+               __field(        u64,    hva             )
+               __field(        u64,    gfn             )
+               __field(        u8,     referenced      )
+       ),
+
+       TP_fast_assign(
+               __entry->hva            = hva;
+               __entry->gfn            =
+                 slot->base_gfn + ((hva - slot->userspace_addr) >> PAGE_SHIFT);
+               __entry->referenced     = ref;
+       ),
+
+       TP_printk("hva %llx gfn %llx %s",
+                 __entry->hva, __entry->gfn,
+                 __entry->referenced ? "YOUNG" : "OLD")
+);
+
+#ifdef CONFIG_KVM_ASYNC_PF
+DECLARE_EVENT_CLASS(kvm_async_get_page_class,
+
+       TP_PROTO(u64 gva, u64 gfn),
+
+       TP_ARGS(gva, gfn),
+
+       TP_STRUCT__entry(
+               __field(__u64, gva)
+               __field(u64, gfn)
+       ),
+
+       TP_fast_assign(
+               __entry->gva = gva;
+               __entry->gfn = gfn;
+       ),
+
+       TP_printk("gva = %#llx, gfn = %#llx", __entry->gva, __entry->gfn)
+);
+
+DEFINE_EVENT(kvm_async_get_page_class, kvm_try_async_get_page,
+
+       TP_PROTO(u64 gva, u64 gfn),
+
+       TP_ARGS(gva, gfn)
+);
+
+DEFINE_EVENT(kvm_async_get_page_class, kvm_async_pf_doublefault,
+
+       TP_PROTO(u64 gva, u64 gfn),
+
+       TP_ARGS(gva, gfn)
+);
+
+DECLARE_EVENT_CLASS(kvm_async_pf_nopresent_ready,
+
+       TP_PROTO(u64 token, u64 gva),
+
+       TP_ARGS(token, gva),
+
+       TP_STRUCT__entry(
+               __field(__u64, token)
+               __field(__u64, gva)
+       ),
+
+       TP_fast_assign(
+               __entry->token = token;
+               __entry->gva = gva;
+       ),
+
+       TP_printk("token %#llx gva %#llx", __entry->token, __entry->gva)
+
+);
+
+DEFINE_EVENT(kvm_async_pf_nopresent_ready, kvm_async_pf_not_present,
+
+       TP_PROTO(u64 token, u64 gva),
+
+       TP_ARGS(token, gva)
+);
+
+DEFINE_EVENT(kvm_async_pf_nopresent_ready, kvm_async_pf_ready,
+
+       TP_PROTO(u64 token, u64 gva),
+
+       TP_ARGS(token, gva)
+);
+
+TRACE_EVENT(
+       kvm_async_pf_completed,
+       TP_PROTO(unsigned long address, struct page *page, u64 gva),
+       TP_ARGS(address, page, gva),
+
+       TP_STRUCT__entry(
+               __field(unsigned long, address)
+               __field(pfn_t, pfn)
+               __field(u64, gva)
+               ),
+
+       TP_fast_assign(
+               __entry->address = address;
+               __entry->pfn = page ? page_to_pfn(page) : 0;
+               __entry->gva = gva;
+               ),
+
+       TP_printk("gva %#llx address %#lx pfn %#llx",  __entry->gva,
+                 __entry->address, __entry->pfn)
+);
+
+#endif
+
+#endif /* _TRACE_KVM_MAIN_H */
+
+/* This part must be outside protection */
+#include <trace/define_trace.h>
diff --git a/drivers/staging/lttng/instrumentation/events/mainline/lock.h b/drivers/staging/lttng/instrumentation/events/mainline/lock.h
new file mode 100644 (file)
index 0000000..2821b86
--- /dev/null
@@ -0,0 +1,86 @@
+#undef TRACE_SYSTEM
+#define TRACE_SYSTEM lock
+
+#if !defined(_TRACE_LOCK_H) || defined(TRACE_HEADER_MULTI_READ)
+#define _TRACE_LOCK_H
+
+#include <linux/lockdep.h>
+#include <linux/tracepoint.h>
+
+#ifdef CONFIG_LOCKDEP
+
+TRACE_EVENT(lock_acquire,
+
+       TP_PROTO(struct lockdep_map *lock, unsigned int subclass,
+               int trylock, int read, int check,
+               struct lockdep_map *next_lock, unsigned long ip),
+
+       TP_ARGS(lock, subclass, trylock, read, check, next_lock, ip),
+
+       TP_STRUCT__entry(
+               __field(unsigned int, flags)
+               __string(name, lock->name)
+               __field(void *, lockdep_addr)
+       ),
+
+       TP_fast_assign(
+               __entry->flags = (trylock ? 1 : 0) | (read ? 2 : 0);
+               __assign_str(name, lock->name);
+               __entry->lockdep_addr = lock;
+       ),
+
+       TP_printk("%p %s%s%s", __entry->lockdep_addr,
+                 (__entry->flags & 1) ? "try " : "",
+                 (__entry->flags & 2) ? "read " : "",
+                 __get_str(name))
+);
+
+DECLARE_EVENT_CLASS(lock,
+
+       TP_PROTO(struct lockdep_map *lock, unsigned long ip),
+
+       TP_ARGS(lock, ip),
+
+       TP_STRUCT__entry(
+               __string(       name,   lock->name      )
+               __field(        void *, lockdep_addr    )
+       ),
+
+       TP_fast_assign(
+               __assign_str(name, lock->name);
+               __entry->lockdep_addr = lock;
+       ),
+
+       TP_printk("%p %s",  __entry->lockdep_addr, __get_str(name))
+);
+
+DEFINE_EVENT(lock, lock_release,
+
+       TP_PROTO(struct lockdep_map *lock, unsigned long ip),
+
+       TP_ARGS(lock, ip)
+);
+
+#ifdef CONFIG_LOCK_STAT
+
+DEFINE_EVENT(lock, lock_contended,
+
+       TP_PROTO(struct lockdep_map *lock, unsigned long ip),
+
+       TP_ARGS(lock, ip)
+);
+
+DEFINE_EVENT(lock, lock_acquired,
+
+       TP_PROTO(struct lockdep_map *lock, unsigned long ip),
+
+       TP_ARGS(lock, ip)
+);
+
+#endif
+#endif
+
+#endif /* _TRACE_LOCK_H */
+
+/* This part must be outside protection */
+#include <trace/define_trace.h>
diff --git a/drivers/staging/lttng/instrumentation/events/mainline/module.h b/drivers/staging/lttng/instrumentation/events/mainline/module.h
new file mode 100644 (file)
index 0000000..21a546d
--- /dev/null
@@ -0,0 +1,131 @@
+/*
+ * Because linux/module.h has tracepoints in the header, and ftrace.h
+ * eventually includes this file, define_trace.h includes linux/module.h
+ * But we do not want the module.h to override the TRACE_SYSTEM macro
+ * variable that define_trace.h is processing, so we only set it
+ * when module events are being processed, which would happen when
+ * CREATE_TRACE_POINTS is defined.
+ */
+#ifdef CREATE_TRACE_POINTS
+#undef TRACE_SYSTEM
+#define TRACE_SYSTEM module
+#endif
+
+#if !defined(_TRACE_MODULE_H) || defined(TRACE_HEADER_MULTI_READ)
+#define _TRACE_MODULE_H
+
+#include <linux/tracepoint.h>
+
+#ifdef CONFIG_MODULES
+
+struct module;
+
+#define show_module_flags(flags) __print_flags(flags, "",      \
+       { (1UL << TAINT_PROPRIETARY_MODULE),    "P" },          \
+       { (1UL << TAINT_FORCED_MODULE),         "F" },          \
+       { (1UL << TAINT_CRAP),                  "C" })
+
+TRACE_EVENT(module_load,
+
+       TP_PROTO(struct module *mod),
+
+       TP_ARGS(mod),
+
+       TP_STRUCT__entry(
+               __field(        unsigned int,   taints          )
+               __string(       name,           mod->name       )
+       ),
+
+       TP_fast_assign(
+               __entry->taints = mod->taints;
+               __assign_str(name, mod->name);
+       ),
+
+       TP_printk("%s %s", __get_str(name), show_module_flags(__entry->taints))
+);
+
+TRACE_EVENT(module_free,
+
+       TP_PROTO(struct module *mod),
+
+       TP_ARGS(mod),
+
+       TP_STRUCT__entry(
+               __string(       name,           mod->name       )
+       ),
+
+       TP_fast_assign(
+               __assign_str(name, mod->name);
+       ),
+
+       TP_printk("%s", __get_str(name))
+);
+
+#ifdef CONFIG_MODULE_UNLOAD
+/* trace_module_get/put are only used if CONFIG_MODULE_UNLOAD is defined */
+
+DECLARE_EVENT_CLASS(module_refcnt,
+
+       TP_PROTO(struct module *mod, unsigned long ip),
+
+       TP_ARGS(mod, ip),
+
+       TP_STRUCT__entry(
+               __field(        unsigned long,  ip              )
+               __field(        int,            refcnt          )
+               __string(       name,           mod->name       )
+       ),
+
+       TP_fast_assign(
+               __entry->ip     = ip;
+               __entry->refcnt = __this_cpu_read(mod->refptr->incs) + __this_cpu_read(mod->refptr->decs);
+               __assign_str(name, mod->name);
+       ),
+
+       TP_printk("%s call_site=%pf refcnt=%d",
+                 __get_str(name), (void *)__entry->ip, __entry->refcnt)
+);
+
+DEFINE_EVENT(module_refcnt, module_get,
+
+       TP_PROTO(struct module *mod, unsigned long ip),
+
+       TP_ARGS(mod, ip)
+);
+
+DEFINE_EVENT(module_refcnt, module_put,
+
+       TP_PROTO(struct module *mod, unsigned long ip),
+
+       TP_ARGS(mod, ip)
+);
+#endif /* CONFIG_MODULE_UNLOAD */
+
+TRACE_EVENT(module_request,
+
+       TP_PROTO(char *name, bool wait, unsigned long ip),
+
+       TP_ARGS(name, wait, ip),
+
+       TP_STRUCT__entry(
+               __field(        unsigned long,  ip              )
+               __field(        bool,           wait            )
+               __string(       name,           name            )
+       ),
+
+       TP_fast_assign(
+               __entry->ip     = ip;
+               __entry->wait   = wait;
+               __assign_str(name, name);
+       ),
+
+       TP_printk("%s wait=%d call_site=%pf",
+                 __get_str(name), (int)__entry->wait, (void *)__entry->ip)
+);
+
+#endif /* CONFIG_MODULES */
+
+#endif /* _TRACE_MODULE_H */
+
+/* This part must be outside protection */
+#include <trace/define_trace.h>
diff --git a/drivers/staging/lttng/instrumentation/events/mainline/napi.h b/drivers/staging/lttng/instrumentation/events/mainline/napi.h
new file mode 100644 (file)
index 0000000..8fe1e93
--- /dev/null
@@ -0,0 +1,38 @@
+#undef TRACE_SYSTEM
+#define TRACE_SYSTEM napi
+
+#if !defined(_TRACE_NAPI_H) || defined(TRACE_HEADER_MULTI_READ)
+#define _TRACE_NAPI_H_
+
+#include <linux/netdevice.h>
+#include <linux/tracepoint.h>
+#include <linux/ftrace.h>
+
+#define NO_DEV "(no_device)"
+
+TRACE_EVENT(napi_poll,
+
+       TP_PROTO(struct napi_struct *napi),
+
+       TP_ARGS(napi),
+
+       TP_STRUCT__entry(
+               __field(        struct napi_struct *,   napi)
+               __string(       dev_name, napi->dev ? napi->dev->name : NO_DEV)
+       ),
+
+       TP_fast_assign(
+               __entry->napi = napi;
+               __assign_str(dev_name, napi->dev ? napi->dev->name : NO_DEV);
+       ),
+
+       TP_printk("napi poll on napi struct %p for device %s",
+               __entry->napi, __get_str(dev_name))
+);
+
+#undef NO_DEV
+
+#endif /* _TRACE_NAPI_H_ */
+
+/* This part must be outside protection */
+#include <trace/define_trace.h>
diff --git a/drivers/staging/lttng/instrumentation/events/mainline/net.h b/drivers/staging/lttng/instrumentation/events/mainline/net.h
new file mode 100644 (file)
index 0000000..f99645d
--- /dev/null
@@ -0,0 +1,84 @@
+#undef TRACE_SYSTEM
+#define TRACE_SYSTEM net
+
+#if !defined(_TRACE_NET_H) || defined(TRACE_HEADER_MULTI_READ)
+#define _TRACE_NET_H
+
+#include <linux/skbuff.h>
+#include <linux/netdevice.h>
+#include <linux/ip.h>
+#include <linux/tracepoint.h>
+
+TRACE_EVENT(net_dev_xmit,
+
+       TP_PROTO(struct sk_buff *skb,
+                int rc,
+                struct net_device *dev,
+                unsigned int skb_len),
+
+       TP_ARGS(skb, rc, dev, skb_len),
+
+       TP_STRUCT__entry(
+               __field(        void *,         skbaddr         )
+               __field(        unsigned int,   len             )
+               __field(        int,            rc              )
+               __string(       name,           dev->name       )
+       ),
+
+       TP_fast_assign(
+               __entry->skbaddr = skb;
+               __entry->len = skb_len;
+               __entry->rc = rc;
+               __assign_str(name, dev->name);
+       ),
+
+       TP_printk("dev=%s skbaddr=%p len=%u rc=%d",
+               __get_str(name), __entry->skbaddr, __entry->len, __entry->rc)
+);
+
+DECLARE_EVENT_CLASS(net_dev_template,
+
+       TP_PROTO(struct sk_buff *skb),
+
+       TP_ARGS(skb),
+
+       TP_STRUCT__entry(
+               __field(        void *,         skbaddr         )
+               __field(        unsigned int,   len             )
+               __string(       name,           skb->dev->name  )
+       ),
+
+       TP_fast_assign(
+               __entry->skbaddr = skb;
+               __entry->len = skb->len;
+               __assign_str(name, skb->dev->name);
+       ),
+
+       TP_printk("dev=%s skbaddr=%p len=%u",
+               __get_str(name), __entry->skbaddr, __entry->len)
+)
+
+DEFINE_EVENT(net_dev_template, net_dev_queue,
+
+       TP_PROTO(struct sk_buff *skb),
+
+       TP_ARGS(skb)
+);
+
+DEFINE_EVENT(net_dev_template, netif_receive_skb,
+
+       TP_PROTO(struct sk_buff *skb),
+
+       TP_ARGS(skb)
+);
+
+DEFINE_EVENT(net_dev_template, netif_rx,
+
+       TP_PROTO(struct sk_buff *skb),
+
+       TP_ARGS(skb)
+);
+#endif /* _TRACE_NET_H */
+
+/* This part must be outside protection */
+#include <trace/define_trace.h>
diff --git a/drivers/staging/lttng/instrumentation/events/mainline/power.h b/drivers/staging/lttng/instrumentation/events/mainline/power.h
new file mode 100644 (file)
index 0000000..0c97838
--- /dev/null
@@ -0,0 +1,275 @@
+#undef TRACE_SYSTEM
+#define TRACE_SYSTEM power
+
+#if !defined(_TRACE_POWER_H) || defined(TRACE_HEADER_MULTI_READ)
+#define _TRACE_POWER_H
+
+#include <linux/ktime.h>
+#include <linux/tracepoint.h>
+
+DECLARE_EVENT_CLASS(cpu,
+
+       TP_PROTO(unsigned int state, unsigned int cpu_id),
+
+       TP_ARGS(state, cpu_id),
+
+       TP_STRUCT__entry(
+               __field(        u32,            state           )
+               __field(        u32,            cpu_id          )
+       ),
+
+       TP_fast_assign(
+               __entry->state = state;
+               __entry->cpu_id = cpu_id;
+       ),
+
+       TP_printk("state=%lu cpu_id=%lu", (unsigned long)__entry->state,
+                 (unsigned long)__entry->cpu_id)
+);
+
+DEFINE_EVENT(cpu, cpu_idle,
+
+       TP_PROTO(unsigned int state, unsigned int cpu_id),
+
+       TP_ARGS(state, cpu_id)
+);
+
+/* This file can get included multiple times, TRACE_HEADER_MULTI_READ at top */
+#ifndef _PWR_EVENT_AVOID_DOUBLE_DEFINING
+#define _PWR_EVENT_AVOID_DOUBLE_DEFINING
+
+#define PWR_EVENT_EXIT -1
+#endif
+
+DEFINE_EVENT(cpu, cpu_frequency,
+
+       TP_PROTO(unsigned int frequency, unsigned int cpu_id),
+
+       TP_ARGS(frequency, cpu_id)
+);
+
+TRACE_EVENT(machine_suspend,
+
+       TP_PROTO(unsigned int state),
+
+       TP_ARGS(state),
+
+       TP_STRUCT__entry(
+               __field(        u32,            state           )
+       ),
+
+       TP_fast_assign(
+               __entry->state = state;
+       ),
+
+       TP_printk("state=%lu", (unsigned long)__entry->state)
+);
+
+DECLARE_EVENT_CLASS(wakeup_source,
+
+       TP_PROTO(const char *name, unsigned int state),
+
+       TP_ARGS(name, state),
+
+       TP_STRUCT__entry(
+               __string(       name,           name            )
+               __field(        u64,            state           )
+       ),
+
+       TP_fast_assign(
+               __assign_str(name, name);
+               __entry->state = state;
+       ),
+
+       TP_printk("%s state=0x%lx", __get_str(name),
+               (unsigned long)__entry->state)
+);
+
+DEFINE_EVENT(wakeup_source, wakeup_source_activate,
+
+       TP_PROTO(const char *name, unsigned int state),
+
+       TP_ARGS(name, state)
+);
+
+DEFINE_EVENT(wakeup_source, wakeup_source_deactivate,
+
+       TP_PROTO(const char *name, unsigned int state),
+
+       TP_ARGS(name, state)
+);
+
+#ifdef CONFIG_EVENT_POWER_TRACING_DEPRECATED
+
+/*
+ * The power events are used for cpuidle & suspend (power_start, power_end)
+ *  and for cpufreq (power_frequency)
+ */
+DECLARE_EVENT_CLASS(power,
+
+       TP_PROTO(unsigned int type, unsigned int state, unsigned int cpu_id),
+
+       TP_ARGS(type, state, cpu_id),
+
+       TP_STRUCT__entry(
+               __field(        u64,            type            )
+               __field(        u64,            state           )
+               __field(        u64,            cpu_id          )
+       ),
+
+       TP_fast_assign(
+               __entry->type = type;
+               __entry->state = state;
+               __entry->cpu_id = cpu_id;
+       ),
+
+       TP_printk("type=%lu state=%lu cpu_id=%lu", (unsigned long)__entry->type,
+               (unsigned long)__entry->state, (unsigned long)__entry->cpu_id)
+);
+
+DEFINE_EVENT(power, power_start,
+
+       TP_PROTO(unsigned int type, unsigned int state, unsigned int cpu_id),
+
+       TP_ARGS(type, state, cpu_id)
+);
+
+DEFINE_EVENT(power, power_frequency,
+
+       TP_PROTO(unsigned int type, unsigned int state, unsigned int cpu_id),
+
+       TP_ARGS(type, state, cpu_id)
+);
+
+TRACE_EVENT(power_end,
+
+       TP_PROTO(unsigned int cpu_id),
+
+       TP_ARGS(cpu_id),
+
+       TP_STRUCT__entry(
+               __field(        u64,            cpu_id          )
+       ),
+
+       TP_fast_assign(
+               __entry->cpu_id = cpu_id;
+       ),
+
+       TP_printk("cpu_id=%lu", (unsigned long)__entry->cpu_id)
+
+);
+
+/* Deprecated dummy functions must be protected against multi-declartion */
+#ifndef _PWR_EVENT_AVOID_DOUBLE_DEFINING_DEPRECATED
+#define _PWR_EVENT_AVOID_DOUBLE_DEFINING_DEPRECATED
+
+enum {
+       POWER_NONE = 0,
+       POWER_CSTATE = 1,
+       POWER_PSTATE = 2,
+};
+#endif /* _PWR_EVENT_AVOID_DOUBLE_DEFINING_DEPRECATED */
+
+#else /* CONFIG_EVENT_POWER_TRACING_DEPRECATED */
+
+#ifndef _PWR_EVENT_AVOID_DOUBLE_DEFINING_DEPRECATED
+#define _PWR_EVENT_AVOID_DOUBLE_DEFINING_DEPRECATED
+enum {
+       POWER_NONE = 0,
+       POWER_CSTATE = 1,
+       POWER_PSTATE = 2,
+};
+
+/* These dummy declaration have to be ripped out when the deprecated
+   events get removed */
+static inline void trace_power_start(u64 type, u64 state, u64 cpuid) {};
+static inline void trace_power_end(u64 cpuid) {};
+static inline void trace_power_start_rcuidle(u64 type, u64 state, u64 cpuid) {};
+static inline void trace_power_end_rcuidle(u64 cpuid) {};
+static inline void trace_power_frequency(u64 type, u64 state, u64 cpuid) {};
+#endif /* _PWR_EVENT_AVOID_DOUBLE_DEFINING_DEPRECATED */
+
+#endif /* CONFIG_EVENT_POWER_TRACING_DEPRECATED */
+
+/*
+ * The clock events are used for clock enable/disable and for
+ *  clock rate change
+ */
+DECLARE_EVENT_CLASS(clock,
+
+       TP_PROTO(const char *name, unsigned int state, unsigned int cpu_id),
+
+       TP_ARGS(name, state, cpu_id),
+
+       TP_STRUCT__entry(
+               __string(       name,           name            )
+               __field(        u64,            state           )
+               __field(        u64,            cpu_id          )
+       ),
+
+       TP_fast_assign(
+               __assign_str(name, name);
+               __entry->state = state;
+               __entry->cpu_id = cpu_id;
+       ),
+
+       TP_printk("%s state=%lu cpu_id=%lu", __get_str(name),
+               (unsigned long)__entry->state, (unsigned long)__entry->cpu_id)
+);
+
+DEFINE_EVENT(clock, clock_enable,
+
+       TP_PROTO(const char *name, unsigned int state, unsigned int cpu_id),
+
+       TP_ARGS(name, state, cpu_id)
+);
+
+DEFINE_EVENT(clock, clock_disable,
+
+       TP_PROTO(const char *name, unsigned int state, unsigned int cpu_id),
+
+       TP_ARGS(name, state, cpu_id)
+);
+
+DEFINE_EVENT(clock, clock_set_rate,
+
+       TP_PROTO(const char *name, unsigned int state, unsigned int cpu_id),
+
+       TP_ARGS(name, state, cpu_id)
+);
+
+/*
+ * The power domain events are used for power domains transitions
+ */
+DECLARE_EVENT_CLASS(power_domain,
+
+       TP_PROTO(const char *name, unsigned int state, unsigned int cpu_id),
+
+       TP_ARGS(name, state, cpu_id),
+
+       TP_STRUCT__entry(
+               __string(       name,           name            )
+               __field(        u64,            state           )
+               __field(        u64,            cpu_id          )
+       ),
+
+       TP_fast_assign(
+               __assign_str(name, name);
+               __entry->state = state;
+               __entry->cpu_id = cpu_id;
+),
+
+       TP_printk("%s state=%lu cpu_id=%lu", __get_str(name),
+               (unsigned long)__entry->state, (unsigned long)__entry->cpu_id)
+);
+
+DEFINE_EVENT(power_domain, power_domain_target,
+
+       TP_PROTO(const char *name, unsigned int state, unsigned int cpu_id),
+
+       TP_ARGS(name, state, cpu_id)
+);
+#endif /* _TRACE_POWER_H */
+
+/* This part must be outside protection */
+#include <trace/define_trace.h>
diff --git a/drivers/staging/lttng/instrumentation/events/mainline/printk.h b/drivers/staging/lttng/instrumentation/events/mainline/printk.h
new file mode 100644 (file)
index 0000000..94ec79c
--- /dev/null
@@ -0,0 +1,41 @@
+#undef TRACE_SYSTEM
+#define TRACE_SYSTEM printk
+
+#if !defined(_TRACE_PRINTK_H) || defined(TRACE_HEADER_MULTI_READ)
+#define _TRACE_PRINTK_H
+
+#include <linux/tracepoint.h>
+
+TRACE_EVENT_CONDITION(console,
+       TP_PROTO(const char *log_buf, unsigned start, unsigned end,
+                unsigned log_buf_len),
+
+       TP_ARGS(log_buf, start, end, log_buf_len),
+
+       TP_CONDITION(start != end),
+
+       TP_STRUCT__entry(
+               __dynamic_array(char, msg, end - start + 1)
+       ),
+
+       TP_fast_assign(
+               if ((start & (log_buf_len - 1)) > (end & (log_buf_len - 1))) {
+                       memcpy(__get_dynamic_array(msg),
+                              log_buf + (start & (log_buf_len - 1)),
+                              log_buf_len - (start & (log_buf_len - 1)));
+                       memcpy((char *)__get_dynamic_array(msg) +
+                              log_buf_len - (start & (log_buf_len - 1)),
+                              log_buf, end & (log_buf_len - 1));
+               } else
+                       memcpy(__get_dynamic_array(msg),
+                              log_buf + (start & (log_buf_len - 1)),
+                              end - start);
+               ((char *)__get_dynamic_array(msg))[end - start] = 0;
+       ),
+
+       TP_printk("%s", __get_str(msg))
+);
+#endif /* _TRACE_PRINTK_H */
+
+/* This part must be outside protection */
+#include <trace/define_trace.h>
diff --git a/drivers/staging/lttng/instrumentation/events/mainline/random.h b/drivers/staging/lttng/instrumentation/events/mainline/random.h
new file mode 100644 (file)
index 0000000..422df19
--- /dev/null
@@ -0,0 +1,134 @@
+#undef TRACE_SYSTEM
+#define TRACE_SYSTEM random
+
+#if !defined(_TRACE_RANDOM_H) || defined(TRACE_HEADER_MULTI_READ)
+#define _TRACE_RANDOM_H
+
+#include <linux/writeback.h>
+#include <linux/tracepoint.h>
+
+DECLARE_EVENT_CLASS(random__mix_pool_bytes,
+       TP_PROTO(const char *pool_name, int bytes, unsigned long IP),
+
+       TP_ARGS(pool_name, bytes, IP),
+
+       TP_STRUCT__entry(
+               __field( const char *,  pool_name               )
+               __field(          int,  bytes                   )
+               __field(unsigned long,  IP                      )
+       ),
+
+       TP_fast_assign(
+               __entry->pool_name      = pool_name;
+               __entry->bytes          = bytes;
+               __entry->IP             = IP;
+       ),
+
+       TP_printk("%s pool: bytes %d caller %pF",
+                 __entry->pool_name, __entry->bytes, (void *)__entry->IP)
+);
+
+DEFINE_EVENT(random__mix_pool_bytes, mix_pool_bytes,
+       TP_PROTO(const char *pool_name, int bytes, unsigned long IP),
+
+       TP_ARGS(pool_name, bytes, IP)
+);
+
+DEFINE_EVENT(random__mix_pool_bytes, mix_pool_bytes_nolock,
+       TP_PROTO(const char *pool_name, int bytes, unsigned long IP),
+
+       TP_ARGS(pool_name, bytes, IP)
+);
+
+TRACE_EVENT(credit_entropy_bits,
+       TP_PROTO(const char *pool_name, int bits, int entropy_count,
+                int entropy_total, unsigned long IP),
+
+       TP_ARGS(pool_name, bits, entropy_count, entropy_total, IP),
+
+       TP_STRUCT__entry(
+               __field( const char *,  pool_name               )
+               __field(          int,  bits                    )
+               __field(          int,  entropy_count           )
+               __field(          int,  entropy_total           )
+               __field(unsigned long,  IP                      )
+       ),
+
+       TP_fast_assign(
+               __entry->pool_name      = pool_name;
+               __entry->bits           = bits;
+               __entry->entropy_count  = entropy_count;
+               __entry->entropy_total  = entropy_total;
+               __entry->IP             = IP;
+       ),
+
+       TP_printk("%s pool: bits %d entropy_count %d entropy_total %d "
+                 "caller %pF", __entry->pool_name, __entry->bits,
+                 __entry->entropy_count, __entry->entropy_total,
+                 (void *)__entry->IP)
+);
+
+TRACE_EVENT(get_random_bytes,
+       TP_PROTO(int nbytes, unsigned long IP),
+
+       TP_ARGS(nbytes, IP),
+
+       TP_STRUCT__entry(
+               __field(          int,  nbytes                  )
+               __field(unsigned long,  IP                      )
+       ),
+
+       TP_fast_assign(
+               __entry->nbytes         = nbytes;
+               __entry->IP             = IP;
+       ),
+
+       TP_printk("nbytes %d caller %pF", __entry->nbytes, (void *)__entry->IP)
+);
+
+DECLARE_EVENT_CLASS(random__extract_entropy,
+       TP_PROTO(const char *pool_name, int nbytes, int entropy_count,
+                unsigned long IP),
+
+       TP_ARGS(pool_name, nbytes, entropy_count, IP),
+
+       TP_STRUCT__entry(
+               __field( const char *,  pool_name               )
+               __field(          int,  nbytes                  )
+               __field(          int,  entropy_count           )
+               __field(unsigned long,  IP                      )
+       ),
+
+       TP_fast_assign(
+               __entry->pool_name      = pool_name;
+               __entry->nbytes         = nbytes;
+               __entry->entropy_count  = entropy_count;
+               __entry->IP             = IP;
+       ),
+
+       TP_printk("%s pool: nbytes %d entropy_count %d caller %pF",
+                 __entry->pool_name, __entry->nbytes, __entry->entropy_count,
+                 (void *)__entry->IP)
+);
+
+
+DEFINE_EVENT(random__extract_entropy, extract_entropy,
+       TP_PROTO(const char *pool_name, int nbytes, int entropy_count,
+                unsigned long IP),
+
+       TP_ARGS(pool_name, nbytes, entropy_count, IP)
+);
+
+DEFINE_EVENT(random__extract_entropy, extract_entropy_user,
+       TP_PROTO(const char *pool_name, int nbytes, int entropy_count,
+                unsigned long IP),
+
+       TP_ARGS(pool_name, nbytes, entropy_count, IP)
+);
+
+
+
+#endif /* _TRACE_RANDOM_H */
+
+/* This part must be outside protection */
+#include <trace/define_trace.h>
diff --git a/drivers/staging/lttng/instrumentation/events/mainline/rcu.h b/drivers/staging/lttng/instrumentation/events/mainline/rcu.h
new file mode 100644 (file)
index 0000000..5bde94d
--- /dev/null
@@ -0,0 +1,618 @@
+#undef TRACE_SYSTEM
+#define TRACE_SYSTEM rcu
+
+#if !defined(_TRACE_RCU_H) || defined(TRACE_HEADER_MULTI_READ)
+#define _TRACE_RCU_H
+
+#include <linux/tracepoint.h>
+
+/*
+ * Tracepoint for start/end markers used for utilization calculations.
+ * By convention, the string is of the following forms:
+ *
+ * "Start <activity>" -- Mark the start of the specified activity,
+ *                      such as "context switch".  Nesting is permitted.
+ * "End <activity>" -- Mark the end of the specified activity.
+ *
+ * An "@" character within "<activity>" is a comment character: Data
+ * reduction scripts will ignore the "@" and the remainder of the line.
+ */
+TRACE_EVENT(rcu_utilization,
+
+       TP_PROTO(char *s),
+
+       TP_ARGS(s),
+
+       TP_STRUCT__entry(
+               __field(char *, s)
+       ),
+
+       TP_fast_assign(
+               __entry->s = s;
+       ),
+
+       TP_printk("%s", __entry->s)
+);
+
+#ifdef CONFIG_RCU_TRACE
+
+#if defined(CONFIG_TREE_RCU) || defined(CONFIG_TREE_PREEMPT_RCU)
+
+/*
+ * Tracepoint for grace-period events: starting and ending a grace
+ * period ("start" and "end", respectively), a CPU noting the start
+ * of a new grace period or the end of an old grace period ("cpustart"
+ * and "cpuend", respectively), a CPU passing through a quiescent
+ * state ("cpuqs"), a CPU coming online or going offline ("cpuonl"
+ * and "cpuofl", respectively), and a CPU being kicked for being too
+ * long in dyntick-idle mode ("kick").
+ */
+TRACE_EVENT(rcu_grace_period,
+
+       TP_PROTO(char *rcuname, unsigned long gpnum, char *gpevent),
+
+       TP_ARGS(rcuname, gpnum, gpevent),
+
+       TP_STRUCT__entry(
+               __field(char *, rcuname)
+               __field(unsigned long, gpnum)
+               __field(char *, gpevent)
+       ),
+
+       TP_fast_assign(
+               __entry->rcuname = rcuname;
+               __entry->gpnum = gpnum;
+               __entry->gpevent = gpevent;
+       ),
+
+       TP_printk("%s %lu %s",
+                 __entry->rcuname, __entry->gpnum, __entry->gpevent)
+);
+
+/*
+ * Tracepoint for grace-period-initialization events.  These are
+ * distinguished by the type of RCU, the new grace-period number, the
+ * rcu_node structure level, the starting and ending CPU covered by the
+ * rcu_node structure, and the mask of CPUs that will be waited for.
+ * All but the type of RCU are extracted from the rcu_node structure.
+ */
+TRACE_EVENT(rcu_grace_period_init,
+
+       TP_PROTO(char *rcuname, unsigned long gpnum, u8 level,
+                int grplo, int grphi, unsigned long qsmask),
+
+       TP_ARGS(rcuname, gpnum, level, grplo, grphi, qsmask),
+
+       TP_STRUCT__entry(
+               __field(char *, rcuname)
+               __field(unsigned long, gpnum)
+               __field(u8, level)
+               __field(int, grplo)
+               __field(int, grphi)
+               __field(unsigned long, qsmask)
+       ),
+
+       TP_fast_assign(
+               __entry->rcuname = rcuname;
+               __entry->gpnum = gpnum;
+               __entry->level = level;
+               __entry->grplo = grplo;
+               __entry->grphi = grphi;
+               __entry->qsmask = qsmask;
+       ),
+
+       TP_printk("%s %lu %u %d %d %lx",
+                 __entry->rcuname, __entry->gpnum, __entry->level,
+                 __entry->grplo, __entry->grphi, __entry->qsmask)
+);
+
+/*
+ * Tracepoint for tasks blocking within preemptible-RCU read-side
+ * critical sections.  Track the type of RCU (which one day might
+ * include SRCU), the grace-period number that the task is blocking
+ * (the current or the next), and the task's PID.
+ */
+TRACE_EVENT(rcu_preempt_task,
+
+       TP_PROTO(char *rcuname, int pid, unsigned long gpnum),
+
+       TP_ARGS(rcuname, pid, gpnum),
+
+       TP_STRUCT__entry(
+               __field(char *, rcuname)
+               __field(unsigned long, gpnum)
+               __field(int, pid)
+       ),
+
+       TP_fast_assign(
+               __entry->rcuname = rcuname;
+               __entry->gpnum = gpnum;
+               __entry->pid = pid;
+       ),
+
+       TP_printk("%s %lu %d",
+                 __entry->rcuname, __entry->gpnum, __entry->pid)
+);
+
+/*
+ * Tracepoint for tasks that blocked within a given preemptible-RCU
+ * read-side critical section exiting that critical section.  Track the
+ * type of RCU (which one day might include SRCU) and the task's PID.
+ */
+TRACE_EVENT(rcu_unlock_preempted_task,
+
+       TP_PROTO(char *rcuname, unsigned long gpnum, int pid),
+
+       TP_ARGS(rcuname, gpnum, pid),
+
+       TP_STRUCT__entry(
+               __field(char *, rcuname)
+               __field(unsigned long, gpnum)
+               __field(int, pid)
+       ),
+
+       TP_fast_assign(
+               __entry->rcuname = rcuname;
+               __entry->gpnum = gpnum;
+               __entry->pid = pid;
+       ),
+
+       TP_printk("%s %lu %d", __entry->rcuname, __entry->gpnum, __entry->pid)
+);
+
+/*
+ * Tracepoint for quiescent-state-reporting events.  These are
+ * distinguished by the type of RCU, the grace-period number, the
+ * mask of quiescent lower-level entities, the rcu_node structure level,
+ * the starting and ending CPU covered by the rcu_node structure, and
+ * whether there are any blocked tasks blocking the current grace period.
+ * All but the type of RCU are extracted from the rcu_node structure.
+ */
+TRACE_EVENT(rcu_quiescent_state_report,
+
+       TP_PROTO(char *rcuname, unsigned long gpnum,
+                unsigned long mask, unsigned long qsmask,
+                u8 level, int grplo, int grphi, int gp_tasks),
+
+       TP_ARGS(rcuname, gpnum, mask, qsmask, level, grplo, grphi, gp_tasks),
+
+       TP_STRUCT__entry(
+               __field(char *, rcuname)
+               __field(unsigned long, gpnum)
+               __field(unsigned long, mask)
+               __field(unsigned long, qsmask)
+               __field(u8, level)
+               __field(int, grplo)
+               __field(int, grphi)
+               __field(u8, gp_tasks)
+       ),
+
+       TP_fast_assign(
+               __entry->rcuname = rcuname;
+               __entry->gpnum = gpnum;
+               __entry->mask = mask;
+               __entry->qsmask = qsmask;
+               __entry->level = level;
+               __entry->grplo = grplo;
+               __entry->grphi = grphi;
+               __entry->gp_tasks = gp_tasks;
+       ),
+
+       TP_printk("%s %lu %lx>%lx %u %d %d %u",
+                 __entry->rcuname, __entry->gpnum,
+                 __entry->mask, __entry->qsmask, __entry->level,
+                 __entry->grplo, __entry->grphi, __entry->gp_tasks)
+);
+
+/*
+ * Tracepoint for quiescent states detected by force_quiescent_state().
+ * These trace events include the type of RCU, the grace-period number
+ * that was blocked by the CPU, the CPU itself, and the type of quiescent
+ * state, which can be "dti" for dyntick-idle mode, "ofl" for CPU offline,
+ * or "kick" when kicking a CPU that has been in dyntick-idle mode for
+ * too long.
+ */
+TRACE_EVENT(rcu_fqs,
+
+       TP_PROTO(char *rcuname, unsigned long gpnum, int cpu, char *qsevent),
+
+       TP_ARGS(rcuname, gpnum, cpu, qsevent),
+
+       TP_STRUCT__entry(
+               __field(char *, rcuname)
+               __field(unsigned long, gpnum)
+               __field(int, cpu)
+               __field(char *, qsevent)
+       ),
+
+       TP_fast_assign(
+               __entry->rcuname = rcuname;
+               __entry->gpnum = gpnum;
+               __entry->cpu = cpu;
+               __entry->qsevent = qsevent;
+       ),
+
+       TP_printk("%s %lu %d %s",
+                 __entry->rcuname, __entry->gpnum,
+                 __entry->cpu, __entry->qsevent)
+);
+
+#endif /* #if defined(CONFIG_TREE_RCU) || defined(CONFIG_TREE_PREEMPT_RCU) */
+
+/*
+ * Tracepoint for dyntick-idle entry/exit events.  These take a string
+ * as argument: "Start" for entering dyntick-idle mode, "End" for
+ * leaving it, "--=" for events moving towards idle, and "++=" for events
+ * moving away from idle.  "Error on entry: not idle task" and "Error on
+ * exit: not idle task" indicate that a non-idle task is erroneously
+ * toying with the idle loop.
+ *
+ * These events also take a pair of numbers, which indicate the nesting
+ * depth before and after the event of interest.  Note that task-related
+ * events use the upper bits of each number, while interrupt-related
+ * events use the lower bits.
+ */
+TRACE_EVENT(rcu_dyntick,
+
+       TP_PROTO(char *polarity, long long oldnesting, long long newnesting),
+
+       TP_ARGS(polarity, oldnesting, newnesting),
+
+       TP_STRUCT__entry(
+               __field(char *, polarity)
+               __field(long long, oldnesting)
+               __field(long long, newnesting)
+       ),
+
+       TP_fast_assign(
+               __entry->polarity = polarity;
+               __entry->oldnesting = oldnesting;
+               __entry->newnesting = newnesting;
+       ),
+
+       TP_printk("%s %llx %llx", __entry->polarity,
+                 __entry->oldnesting, __entry->newnesting)
+);
+
+/*
+ * Tracepoint for RCU preparation for idle, the goal being to get RCU
+ * processing done so that the current CPU can shut off its scheduling
+ * clock and enter dyntick-idle mode.  One way to accomplish this is
+ * to drain all RCU callbacks from this CPU, and the other is to have
+ * done everything RCU requires for the current grace period.  In this
+ * latter case, the CPU will be awakened at the end of the current grace
+ * period in order to process the remainder of its callbacks.
+ *
+ * These tracepoints take a string as argument:
+ *
+ *     "No callbacks": Nothing to do, no callbacks on this CPU.
+ *     "In holdoff": Nothing to do, holding off after unsuccessful attempt.
+ *     "Begin holdoff": Attempt failed, don't retry until next jiffy.
+ *     "Dyntick with callbacks": Entering dyntick-idle despite callbacks.
+ *     "Dyntick with lazy callbacks": Entering dyntick-idle w/lazy callbacks.
+ *     "More callbacks": Still more callbacks, try again to clear them out.
+ *     "Callbacks drained": All callbacks processed, off to dyntick idle!
+ *     "Timer": Timer fired to cause CPU to continue processing callbacks.
+ *     "Demigrate": Timer fired on wrong CPU, woke up correct CPU.
+ *     "Cleanup after idle": Idle exited, timer canceled.
+ */
+TRACE_EVENT(rcu_prep_idle,
+
+       TP_PROTO(char *reason),
+
+       TP_ARGS(reason),
+
+       TP_STRUCT__entry(
+               __field(char *, reason)
+       ),
+
+       TP_fast_assign(
+               __entry->reason = reason;
+       ),
+
+       TP_printk("%s", __entry->reason)
+);
+
+/*
+ * Tracepoint for the registration of a single RCU callback function.
+ * The first argument is the type of RCU, the second argument is
+ * a pointer to the RCU callback itself, the third element is the
+ * number of lazy callbacks queued, and the fourth element is the
+ * total number of callbacks queued.
+ */
+TRACE_EVENT(rcu_callback,
+
+       TP_PROTO(char *rcuname, struct rcu_head *rhp, long qlen_lazy,
+                long qlen),
+
+       TP_ARGS(rcuname, rhp, qlen_lazy, qlen),
+
+       TP_STRUCT__entry(
+               __field(char *, rcuname)
+               __field(void *, rhp)
+               __field(void *, func)
+               __field(long, qlen_lazy)
+               __field(long, qlen)
+       ),
+
+       TP_fast_assign(
+               __entry->rcuname = rcuname;
+               __entry->rhp = rhp;
+               __entry->func = rhp->func;
+               __entry->qlen_lazy = qlen_lazy;
+               __entry->qlen = qlen;
+       ),
+
+       TP_printk("%s rhp=%p func=%pf %ld/%ld",
+                 __entry->rcuname, __entry->rhp, __entry->func,
+                 __entry->qlen_lazy, __entry->qlen)
+);
+
+/*
+ * Tracepoint for the registration of a single RCU callback of the special
+ * kfree() form.  The first argument is the RCU type, the second argument
+ * is a pointer to the RCU callback, the third argument is the offset
+ * of the callback within the enclosing RCU-protected data structure,
+ * the fourth argument is the number of lazy callbacks queued, and the
+ * fifth argument is the total number of callbacks queued.
+ */
+TRACE_EVENT(rcu_kfree_callback,
+
+       TP_PROTO(char *rcuname, struct rcu_head *rhp, unsigned long offset,
+                long qlen_lazy, long qlen),
+
+       TP_ARGS(rcuname, rhp, offset, qlen_lazy, qlen),
+
+       TP_STRUCT__entry(
+               __field(char *, rcuname)
+               __field(void *, rhp)
+               __field(unsigned long, offset)
+               __field(long, qlen_lazy)
+               __field(long, qlen)
+       ),
+
+       TP_fast_assign(
+               __entry->rcuname = rcuname;
+               __entry->rhp = rhp;
+               __entry->offset = offset;
+               __entry->qlen_lazy = qlen_lazy;
+               __entry->qlen = qlen;
+       ),
+
+       TP_printk("%s rhp=%p func=%ld %ld/%ld",
+                 __entry->rcuname, __entry->rhp, __entry->offset,
+                 __entry->qlen_lazy, __entry->qlen)
+);
+
+/*
+ * Tracepoint for marking the beginning rcu_do_batch, performed to start
+ * RCU callback invocation.  The first argument is the RCU flavor,
+ * the second is the number of lazy callbacks queued, the third is
+ * the total number of callbacks queued, and the fourth argument is
+ * the current RCU-callback batch limit.
+ */
+TRACE_EVENT(rcu_batch_start,
+
+       TP_PROTO(char *rcuname, long qlen_lazy, long qlen, int blimit),
+
+       TP_ARGS(rcuname, qlen_lazy, qlen, blimit),
+
+       TP_STRUCT__entry(
+               __field(char *, rcuname)
+               __field(long, qlen_lazy)
+               __field(long, qlen)
+               __field(int, blimit)
+       ),
+
+       TP_fast_assign(
+               __entry->rcuname = rcuname;
+               __entry->qlen_lazy = qlen_lazy;
+               __entry->qlen = qlen;
+               __entry->blimit = blimit;
+       ),
+
+       TP_printk("%s CBs=%ld/%ld bl=%d",
+                 __entry->rcuname, __entry->qlen_lazy, __entry->qlen,
+                 __entry->blimit)
+);
+
+/*
+ * Tracepoint for the invocation of a single RCU callback function.
+ * The first argument is the type of RCU, and the second argument is
+ * a pointer to the RCU callback itself.
+ */
+TRACE_EVENT(rcu_invoke_callback,
+
+       TP_PROTO(char *rcuname, struct rcu_head *rhp),
+
+       TP_ARGS(rcuname, rhp),
+
+       TP_STRUCT__entry(
+               __field(char *, rcuname)
+               __field(void *, rhp)
+               __field(void *, func)
+       ),
+
+       TP_fast_assign(
+               __entry->rcuname = rcuname;
+               __entry->rhp = rhp;
+               __entry->func = rhp->func;
+       ),
+
+       TP_printk("%s rhp=%p func=%pf",
+                 __entry->rcuname, __entry->rhp, __entry->func)
+);
+
+/*
+ * Tracepoint for the invocation of a single RCU callback of the special
+ * kfree() form.  The first argument is the RCU flavor, the second
+ * argument is a pointer to the RCU callback, and the third argument
+ * is the offset of the callback within the enclosing RCU-protected
+ * data structure.
+ */
+TRACE_EVENT(rcu_invoke_kfree_callback,
+
+       TP_PROTO(char *rcuname, struct rcu_head *rhp, unsigned long offset),
+
+       TP_ARGS(rcuname, rhp, offset),
+
+       TP_STRUCT__entry(
+               __field(char *, rcuname)
+               __field(void *, rhp)
+               __field(unsigned long, offset)
+       ),
+
+       TP_fast_assign(
+               __entry->rcuname = rcuname;
+               __entry->rhp = rhp;
+               __entry->offset = offset;
+       ),
+
+       TP_printk("%s rhp=%p func=%ld",
+                 __entry->rcuname, __entry->rhp, __entry->offset)
+);
+
+/*
+ * Tracepoint for exiting rcu_do_batch after RCU callbacks have been
+ * invoked.  The first argument is the name of the RCU flavor,
+ * the second argument is number of callbacks actually invoked,
+ * the third argument (cb) is whether or not any of the callbacks that
+ * were ready to invoke at the beginning of this batch are still
+ * queued, the fourth argument (nr) is the return value of need_resched(),
+ * the fifth argument (iit) is 1 if the current task is the idle task,
+ * and the sixth argument (risk) is the return value from
+ * rcu_is_callbacks_kthread().
+ */
+TRACE_EVENT(rcu_batch_end,
+
+       TP_PROTO(char *rcuname, int callbacks_invoked,
+                bool cb, bool nr, bool iit, bool risk),
+
+       TP_ARGS(rcuname, callbacks_invoked, cb, nr, iit, risk),
+
+       TP_STRUCT__entry(
+               __field(char *, rcuname)
+               __field(int, callbacks_invoked)
+               __field(bool, cb)
+               __field(bool, nr)
+               __field(bool, iit)
+               __field(bool, risk)
+       ),
+
+       TP_fast_assign(
+               __entry->rcuname = rcuname;
+               __entry->callbacks_invoked = callbacks_invoked;
+               __entry->cb = cb;
+               __entry->nr = nr;
+               __entry->iit = iit;
+               __entry->risk = risk;
+       ),
+
+       TP_printk("%s CBs-invoked=%d idle=%c%c%c%c",
+                 __entry->rcuname, __entry->callbacks_invoked,
+                 __entry->cb ? 'C' : '.',
+                 __entry->nr ? 'S' : '.',
+                 __entry->iit ? 'I' : '.',
+                 __entry->risk ? 'R' : '.')
+);
+
+/*
+ * Tracepoint for rcutorture readers.  The first argument is the name
+ * of the RCU flavor from rcutorture's viewpoint and the second argument
+ * is the callback address.
+ */
+TRACE_EVENT(rcu_torture_read,
+
+       TP_PROTO(char *rcutorturename, struct rcu_head *rhp),
+
+       TP_ARGS(rcutorturename, rhp),
+
+       TP_STRUCT__entry(
+               __field(char *, rcutorturename)
+               __field(struct rcu_head *, rhp)
+       ),
+
+       TP_fast_assign(
+               __entry->rcutorturename = rcutorturename;
+               __entry->rhp = rhp;
+       ),
+
+       TP_printk("%s torture read %p",
+                 __entry->rcutorturename, __entry->rhp)
+);
+
+/*
+ * Tracepoint for _rcu_barrier() execution.  The string "s" describes
+ * the _rcu_barrier phase:
+ *     "Begin": rcu_barrier_callback() started.
+ *     "Check": rcu_barrier_callback() checking for piggybacking.
+ *     "EarlyExit": rcu_barrier_callback() piggybacked, thus early exit.
+ *     "Inc1": rcu_barrier_callback() piggyback check counter incremented.
+ *     "Offline": rcu_barrier_callback() found offline CPU
+ *     "OnlineQ": rcu_barrier_callback() found online CPU with callbacks.
+ *     "OnlineNQ": rcu_barrier_callback() found online CPU, no callbacks.
+ *     "IRQ": An rcu_barrier_callback() callback posted on remote CPU.
+ *     "CB": An rcu_barrier_callback() invoked a callback, not the last.
+ *     "LastCB": An rcu_barrier_callback() invoked the last callback.
+ *     "Inc2": rcu_barrier_callback() piggyback check counter incremented.
+ * The "cpu" argument is the CPU or -1 if meaningless, the "cnt" argument
+ * is the count of remaining callbacks, and "done" is the piggybacking count.
+ */
+TRACE_EVENT(rcu_barrier,
+
+       TP_PROTO(char *rcuname, char *s, int cpu, int cnt, unsigned long done),
+
+       TP_ARGS(rcuname, s, cpu, cnt, done),
+
+       TP_STRUCT__entry(
+               __field(char *, rcuname)
+               __field(char *, s)
+               __field(int, cpu)
+               __field(int, cnt)
+               __field(unsigned long, done)
+       ),
+
+       TP_fast_assign(
+               __entry->rcuname = rcuname;
+               __entry->s = s;
+               __entry->cpu = cpu;
+               __entry->cnt = cnt;
+               __entry->done = done;
+       ),
+
+       TP_printk("%s %s cpu %d remaining %d # %lu",
+                 __entry->rcuname, __entry->s, __entry->cpu, __entry->cnt,
+                 __entry->done)
+);
+
+#else /* #ifdef CONFIG_RCU_TRACE */
+
+#define trace_rcu_grace_period(rcuname, gpnum, gpevent) do { } while (0)
+#define trace_rcu_grace_period_init(rcuname, gpnum, level, grplo, grphi, \
+                                   qsmask) do { } while (0)
+#define trace_rcu_preempt_task(rcuname, pid, gpnum) do { } while (0)
+#define trace_rcu_unlock_preempted_task(rcuname, gpnum, pid) do { } while (0)
+#define trace_rcu_quiescent_state_report(rcuname, gpnum, mask, qsmask, level, \
+                                        grplo, grphi, gp_tasks) do { } \
+       while (0)
+#define trace_rcu_fqs(rcuname, gpnum, cpu, qsevent) do { } while (0)
+#define trace_rcu_dyntick(polarity, oldnesting, newnesting) do { } while (0)
+#define trace_rcu_prep_idle(reason) do { } while (0)
+#define trace_rcu_callback(rcuname, rhp, qlen_lazy, qlen) do { } while (0)
+#define trace_rcu_kfree_callback(rcuname, rhp, offset, qlen_lazy, qlen) \
+       do { } while (0)
+#define trace_rcu_batch_start(rcuname, qlen_lazy, qlen, blimit) \
+       do { } while (0)
+#define trace_rcu_invoke_callback(rcuname, rhp) do { } while (0)
+#define trace_rcu_invoke_kfree_callback(rcuname, rhp, offset) do { } while (0)
+#define trace_rcu_batch_end(rcuname, callbacks_invoked, cb, nr, iit, risk) \
+       do { } while (0)
+#define trace_rcu_torture_read(rcutorturename, rhp) do { } while (0)
+#define trace_rcu_barrier(name, s, cpu, cnt, done) do { } while (0)
+
+#endif /* #else #ifdef CONFIG_RCU_TRACE */
+
+#endif /* _TRACE_RCU_H */
+
+/* This part must be outside protection */
+#include <trace/define_trace.h>
diff --git a/drivers/staging/lttng/instrumentation/events/mainline/regmap.h b/drivers/staging/lttng/instrumentation/events/mainline/regmap.h
new file mode 100644 (file)
index 0000000..41a7dbd
--- /dev/null
@@ -0,0 +1,181 @@
+#undef TRACE_SYSTEM
+#define TRACE_SYSTEM regmap
+
+#if !defined(_TRACE_REGMAP_H) || defined(TRACE_HEADER_MULTI_READ)
+#define _TRACE_REGMAP_H
+
+#include <linux/ktime.h>
+#include <linux/tracepoint.h>
+
+struct device;
+struct regmap;
+
+/*
+ * Log register events
+ */
+DECLARE_EVENT_CLASS(regmap_reg,
+
+       TP_PROTO(struct device *dev, unsigned int reg,
+                unsigned int val),
+
+       TP_ARGS(dev, reg, val),
+
+       TP_STRUCT__entry(
+               __string(       name,           dev_name(dev)   )
+               __field(        unsigned int,   reg             )
+               __field(        unsigned int,   val             )
+       ),
+
+       TP_fast_assign(
+               __assign_str(name, dev_name(dev));
+               __entry->reg = reg;
+               __entry->val = val;
+       ),
+
+       TP_printk("%s reg=%x val=%x", __get_str(name),
+                 (unsigned int)__entry->reg,
+                 (unsigned int)__entry->val)
+);
+
+DEFINE_EVENT(regmap_reg, regmap_reg_write,
+
+       TP_PROTO(struct device *dev, unsigned int reg,
+                unsigned int val),
+
+       TP_ARGS(dev, reg, val)
+
+);
+
+DEFINE_EVENT(regmap_reg, regmap_reg_read,
+
+       TP_PROTO(struct device *dev, unsigned int reg,
+                unsigned int val),
+
+       TP_ARGS(dev, reg, val)
+
+);
+
+DEFINE_EVENT(regmap_reg, regmap_reg_read_cache,
+
+       TP_PROTO(struct device *dev, unsigned int reg,
+                unsigned int val),
+
+       TP_ARGS(dev, reg, val)
+
+);
+
+DECLARE_EVENT_CLASS(regmap_block,
+
+       TP_PROTO(struct device *dev, unsigned int reg, int count),
+
+       TP_ARGS(dev, reg, count),
+
+       TP_STRUCT__entry(
+               __string(       name,           dev_name(dev)   )
+               __field(        unsigned int,   reg             )
+               __field(        int,            count           )
+       ),
+
+       TP_fast_assign(
+               __assign_str(name, dev_name(dev));
+               __entry->reg = reg;
+               __entry->count = count;
+       ),
+
+       TP_printk("%s reg=%x count=%d", __get_str(name),
+                 (unsigned int)__entry->reg,
+                 (int)__entry->count)
+);
+
+DEFINE_EVENT(regmap_block, regmap_hw_read_start,
+
+       TP_PROTO(struct device *dev, unsigned int reg, int count),
+
+       TP_ARGS(dev, reg, count)
+);
+
+DEFINE_EVENT(regmap_block, regmap_hw_read_done,
+
+       TP_PROTO(struct device *dev, unsigned int reg, int count),
+
+       TP_ARGS(dev, reg, count)
+);
+
+DEFINE_EVENT(regmap_block, regmap_hw_write_start,
+
+       TP_PROTO(struct device *dev, unsigned int reg, int count),
+
+       TP_ARGS(dev, reg, count)
+);
+
+DEFINE_EVENT(regmap_block, regmap_hw_write_done,
+
+       TP_PROTO(struct device *dev, unsigned int reg, int count),
+
+       TP_ARGS(dev, reg, count)
+);
+
+TRACE_EVENT(regcache_sync,
+
+       TP_PROTO(struct device *dev, const char *type,
+                const char *status),
+
+       TP_ARGS(dev, type, status),
+
+       TP_STRUCT__entry(
+               __string(       name,           dev_name(dev)   )
+               __string(       status,         status          )
+               __string(       type,           type            )
+               __field(        int,            type            )
+       ),
+
+       TP_fast_assign(
+               __assign_str(name, dev_name(dev));
+               __assign_str(status, status);
+               __assign_str(type, type);
+       ),
+
+       TP_printk("%s type=%s status=%s", __get_str(name),
+                 __get_str(type), __get_str(status))
+);
+
+DECLARE_EVENT_CLASS(regmap_bool,
+
+       TP_PROTO(struct device *dev, bool flag),
+
+       TP_ARGS(dev, flag),
+
+       TP_STRUCT__entry(
+               __string(       name,           dev_name(dev)   )
+               __field(        int,            flag            )
+       ),
+
+       TP_fast_assign(
+               __assign_str(name, dev_name(dev));
+               __entry->flag = flag;
+       ),
+
+       TP_printk("%s flag=%d", __get_str(name),
+                 (int)__entry->flag)
+);
+
+DEFINE_EVENT(regmap_bool, regmap_cache_only,
+
+       TP_PROTO(struct device *dev, bool flag),
+
+       TP_ARGS(dev, flag)
+
+);
+
+DEFINE_EVENT(regmap_bool, regmap_cache_bypass,
+
+       TP_PROTO(struct device *dev, bool flag),
+
+       TP_ARGS(dev, flag)
+
+);
+
+#endif /* _TRACE_REGMAP_H */
+
+/* This part must be outside protection */
+#include <trace/define_trace.h>
diff --git a/drivers/staging/lttng/instrumentation/events/mainline/regulator.h b/drivers/staging/lttng/instrumentation/events/mainline/regulator.h
new file mode 100644 (file)
index 0000000..37502a7
--- /dev/null
@@ -0,0 +1,141 @@
+#undef TRACE_SYSTEM
+#define TRACE_SYSTEM regulator
+
+#if !defined(_TRACE_REGULATOR_H) || defined(TRACE_HEADER_MULTI_READ)
+#define _TRACE_REGULATOR_H
+
+#include <linux/ktime.h>
+#include <linux/tracepoint.h>
+
+/*
+ * Events which just log themselves and the regulator name for enable/disable
+ * type tracking.
+ */
+DECLARE_EVENT_CLASS(regulator_basic,
+
+       TP_PROTO(const char *name),
+
+       TP_ARGS(name),
+
+       TP_STRUCT__entry(
+               __string(       name,   name    )
+       ),
+
+       TP_fast_assign(
+               __assign_str(name, name);
+       ),
+
+       TP_printk("name=%s", __get_str(name))
+
+);
+
+DEFINE_EVENT(regulator_basic, regulator_enable,
+
+       TP_PROTO(const char *name),
+
+       TP_ARGS(name)
+
+);
+
+DEFINE_EVENT(regulator_basic, regulator_enable_delay,
+
+       TP_PROTO(const char *name),
+
+       TP_ARGS(name)
+
+);
+
+DEFINE_EVENT(regulator_basic, regulator_enable_complete,
+
+       TP_PROTO(const char *name),
+
+       TP_ARGS(name)
+
+);
+
+DEFINE_EVENT(regulator_basic, regulator_disable,
+
+       TP_PROTO(const char *name),
+
+       TP_ARGS(name)
+
+);
+
+DEFINE_EVENT(regulator_basic, regulator_disable_complete,
+
+       TP_PROTO(const char *name),
+
+       TP_ARGS(name)
+
+);
+
+/*
+ * Events that take a range of numerical values, mostly for voltages
+ * and so on.
+ */
+DECLARE_EVENT_CLASS(regulator_range,
+
+       TP_PROTO(const char *name, int min, int max),
+
+       TP_ARGS(name, min, max),
+
+       TP_STRUCT__entry(
+               __string(       name,           name            )
+               __field(        int,            min             )
+               __field(        int,            max             )
+       ),
+
+       TP_fast_assign(
+               __assign_str(name, name);
+               __entry->min  = min;
+               __entry->max  = max;
+       ),
+
+       TP_printk("name=%s (%d-%d)", __get_str(name),
+                 (int)__entry->min, (int)__entry->max)
+);
+
+DEFINE_EVENT(regulator_range, regulator_set_voltage,
+
+       TP_PROTO(const char *name, int min, int max),
+
+       TP_ARGS(name, min, max)
+
+);
+
+
+/*
+ * Events that take a single value, mostly for readback and refcounts.
+ */
+DECLARE_EVENT_CLASS(regulator_value,
+
+       TP_PROTO(const char *name, unsigned int val),
+
+       TP_ARGS(name, val),
+
+       TP_STRUCT__entry(
+               __string(       name,           name            )
+               __field(        unsigned int,   val             )
+       ),
+
+       TP_fast_assign(
+               __assign_str(name, name);
+               __entry->val  = val;
+       ),
+
+       TP_printk("name=%s, val=%u", __get_str(name),
+                 (int)__entry->val)
+);
+
+DEFINE_EVENT(regulator_value, regulator_set_voltage_complete,
+
+       TP_PROTO(const char *name, unsigned int value),
+
+       TP_ARGS(name, value)
+
+);
+
+#endif /* _TRACE_POWER_H */
+
+/* This part must be outside protection */
+#include <trace/define_trace.h>
diff --git a/drivers/staging/lttng/instrumentation/events/mainline/rpm.h b/drivers/staging/lttng/instrumentation/events/mainline/rpm.h
new file mode 100644 (file)
index 0000000..33f85b6
--- /dev/null
@@ -0,0 +1,100 @@
+
+#undef TRACE_SYSTEM
+#define TRACE_SYSTEM rpm
+
+#if !defined(_TRACE_RUNTIME_POWER_H) || defined(TRACE_HEADER_MULTI_READ)
+#define _TRACE_RUNTIME_POWER_H
+
+#include <linux/ktime.h>
+#include <linux/tracepoint.h>
+
+struct device;
+
+/*
+ * The rpm_internal events are used for tracing some important
+ * runtime pm internal functions.
+ */
+DECLARE_EVENT_CLASS(rpm_internal,
+
+       TP_PROTO(struct device *dev, int flags),
+
+       TP_ARGS(dev, flags),
+
+       TP_STRUCT__entry(
+               __string(       name,           dev_name(dev)   )
+               __field(        int,            flags           )
+               __field(        int ,           usage_count     )
+               __field(        int ,           disable_depth   )
+               __field(        int ,           runtime_auto    )
+               __field(        int ,           request_pending )
+               __field(        int ,           irq_safe        )
+               __field(        int ,           child_count     )
+       ),
+
+       TP_fast_assign(
+               __assign_str(name, dev_name(dev));
+               __entry->flags = flags;
+               __entry->usage_count = atomic_read(
+                       &dev->power.usage_count);
+               __entry->disable_depth = dev->power.disable_depth;
+               __entry->runtime_auto = dev->power.runtime_auto;
+               __entry->request_pending = dev->power.request_pending;
+               __entry->irq_safe = dev->power.irq_safe;
+               __entry->child_count = atomic_read(
+                       &dev->power.child_count);
+       ),
+
+       TP_printk("%s flags-%x cnt-%-2d dep-%-2d auto-%-1d p-%-1d"
+                       " irq-%-1d child-%d",
+                       __get_str(name), __entry->flags,
+                       __entry->usage_count,
+                       __entry->disable_depth,
+                       __entry->runtime_auto,
+                       __entry->request_pending,
+                       __entry->irq_safe,
+                       __entry->child_count
+                )
+);
+DEFINE_EVENT(rpm_internal, rpm_suspend,
+
+       TP_PROTO(struct device *dev, int flags),
+
+       TP_ARGS(dev, flags)
+);
+DEFINE_EVENT(rpm_internal, rpm_resume,
+
+       TP_PROTO(struct device *dev, int flags),
+
+       TP_ARGS(dev, flags)
+);
+DEFINE_EVENT(rpm_internal, rpm_idle,
+
+       TP_PROTO(struct device *dev, int flags),
+
+       TP_ARGS(dev, flags)
+);
+
+TRACE_EVENT(rpm_return_int,
+       TP_PROTO(struct device *dev, unsigned long ip, int ret),
+       TP_ARGS(dev, ip, ret),
+
+       TP_STRUCT__entry(
+               __string(       name,           dev_name(dev))
+               __field(        unsigned long,          ip      )
+               __field(        int,                    ret     )
+       ),
+
+       TP_fast_assign(
+               __assign_str(name, dev_name(dev));
+               __entry->ip = ip;
+               __entry->ret = ret;
+       ),
+
+       TP_printk("%pS:%s ret=%d", (void *)__entry->ip, __get_str(name),
+               __entry->ret)
+);
+
+#endif /* _TRACE_RUNTIME_POWER_H */
+
+/* This part must be outside protection */
+#include <trace/define_trace.h>
diff --git a/drivers/staging/lttng/instrumentation/events/mainline/sched.h b/drivers/staging/lttng/instrumentation/events/mainline/sched.h
new file mode 100644 (file)
index 0000000..0662c8c
--- /dev/null
@@ -0,0 +1,432 @@
+#undef TRACE_SYSTEM
+#define TRACE_SYSTEM sched
+
+#if !defined(_TRACE_SCHED_H) || defined(TRACE_HEADER_MULTI_READ)
+#define _TRACE_SCHED_H
+
+#include <linux/sched.h>
+#include <linux/tracepoint.h>
+#include <linux/binfmts.h>
+
+/*
+ * Tracepoint for calling kthread_stop, performed to end a kthread:
+ */
+TRACE_EVENT(sched_kthread_stop,
+
+       TP_PROTO(struct task_struct *t),
+
+       TP_ARGS(t),
+
+       TP_STRUCT__entry(
+               __array(        char,   comm,   TASK_COMM_LEN   )
+               __field(        pid_t,  pid                     )
+       ),
+
+       TP_fast_assign(
+               memcpy(__entry->comm, t->comm, TASK_COMM_LEN);
+               __entry->pid    = t->pid;
+       ),
+
+       TP_printk("comm=%s pid=%d", __entry->comm, __entry->pid)
+);
+
+/*
+ * Tracepoint for the return value of the kthread stopping:
+ */
+TRACE_EVENT(sched_kthread_stop_ret,
+
+       TP_PROTO(int ret),
+
+       TP_ARGS(ret),
+
+       TP_STRUCT__entry(
+               __field(        int,    ret     )
+       ),
+
+       TP_fast_assign(
+               __entry->ret    = ret;
+       ),
+
+       TP_printk("ret=%d", __entry->ret)
+);
+
+/*
+ * Tracepoint for waking up a task:
+ */
+DECLARE_EVENT_CLASS(sched_wakeup_template,
+
+       TP_PROTO(struct task_struct *p, int success),
+
+       TP_ARGS(p, success),
+
+       TP_STRUCT__entry(
+               __array(        char,   comm,   TASK_COMM_LEN   )
+               __field(        pid_t,  pid                     )
+               __field(        int,    prio                    )
+               __field(        int,    success                 )
+               __field(        int,    target_cpu              )
+       ),
+
+       TP_fast_assign(
+               memcpy(__entry->comm, p->comm, TASK_COMM_LEN);
+               __entry->pid            = p->pid;
+               __entry->prio           = p->prio;
+               __entry->success        = success;
+               __entry->target_cpu     = task_cpu(p);
+       ),
+
+       TP_printk("comm=%s pid=%d prio=%d success=%d target_cpu=%03d",
+                 __entry->comm, __entry->pid, __entry->prio,
+                 __entry->success, __entry->target_cpu)
+);
+
+DEFINE_EVENT(sched_wakeup_template, sched_wakeup,
+            TP_PROTO(struct task_struct *p, int success),
+            TP_ARGS(p, success));
+
+/*
+ * Tracepoint for waking up a new task:
+ */
+DEFINE_EVENT(sched_wakeup_template, sched_wakeup_new,
+            TP_PROTO(struct task_struct *p, int success),
+            TP_ARGS(p, success));
+
+#ifdef CREATE_TRACE_POINTS
+static inline long __trace_sched_switch_state(struct task_struct *p)
+{
+       long state = p->state;
+
+#ifdef CONFIG_PREEMPT
+       /*
+        * For all intents and purposes a preempted task is a running task.
+        */
+       if (task_thread_info(p)->preempt_count & PREEMPT_ACTIVE)
+               state = TASK_RUNNING | TASK_STATE_MAX;
+#endif
+
+       return state;
+}
+#endif
+
+/*
+ * Tracepoint for task switches, performed by the scheduler:
+ */
+TRACE_EVENT(sched_switch,
+
+       TP_PROTO(struct task_struct *prev,
+                struct task_struct *next),
+
+       TP_ARGS(prev, next),
+
+       TP_STRUCT__entry(
+               __array(        char,   prev_comm,      TASK_COMM_LEN   )
+               __field(        pid_t,  prev_pid                        )
+               __field(        int,    prev_prio                       )
+               __field(        long,   prev_state                      )
+               __array(        char,   next_comm,      TASK_COMM_LEN   )
+               __field(        pid_t,  next_pid                        )
+               __field(        int,    next_prio                       )
+       ),
+
+       TP_fast_assign(
+               memcpy(__entry->next_comm, next->comm, TASK_COMM_LEN);
+               __entry->prev_pid       = prev->pid;
+               __entry->prev_prio      = prev->prio;
+               __entry->prev_state     = __trace_sched_switch_state(prev);
+               memcpy(__entry->prev_comm, prev->comm, TASK_COMM_LEN);
+               __entry->next_pid       = next->pid;
+               __entry->next_prio      = next->prio;
+       ),
+
+       TP_printk("prev_comm=%s prev_pid=%d prev_prio=%d prev_state=%s%s ==> next_comm=%s next_pid=%d next_prio=%d",
+               __entry->prev_comm, __entry->prev_pid, __entry->prev_prio,
+               __entry->prev_state & (TASK_STATE_MAX-1) ?
+                 __print_flags(__entry->prev_state & (TASK_STATE_MAX-1), "|",
+                               { 1, "S"} , { 2, "D" }, { 4, "T" }, { 8, "t" },
+                               { 16, "Z" }, { 32, "X" }, { 64, "x" },
+                               { 128, "W" }) : "R",
+               __entry->prev_state & TASK_STATE_MAX ? "+" : "",
+               __entry->next_comm, __entry->next_pid, __entry->next_prio)
+);
+
+/*
+ * Tracepoint for a task being migrated:
+ */
+TRACE_EVENT(sched_migrate_task,
+
+       TP_PROTO(struct task_struct *p, int dest_cpu),
+
+       TP_ARGS(p, dest_cpu),
+
+       TP_STRUCT__entry(
+               __array(        char,   comm,   TASK_COMM_LEN   )
+               __field(        pid_t,  pid                     )
+               __field(        int,    prio                    )
+               __field(        int,    orig_cpu                )
+               __field(        int,    dest_cpu                )
+       ),
+
+       TP_fast_assign(
+               memcpy(__entry->comm, p->comm, TASK_COMM_LEN);
+               __entry->pid            = p->pid;
+               __entry->prio           = p->prio;
+               __entry->orig_cpu       = task_cpu(p);
+               __entry->dest_cpu       = dest_cpu;
+       ),
+
+       TP_printk("comm=%s pid=%d prio=%d orig_cpu=%d dest_cpu=%d",
+                 __entry->comm, __entry->pid, __entry->prio,
+                 __entry->orig_cpu, __entry->dest_cpu)
+);
+
+DECLARE_EVENT_CLASS(sched_process_template,
+
+       TP_PROTO(struct task_struct *p),
+
+       TP_ARGS(p),
+
+       TP_STRUCT__entry(
+               __array(        char,   comm,   TASK_COMM_LEN   )
+               __field(        pid_t,  pid                     )
+               __field(        int,    prio                    )
+       ),
+
+       TP_fast_assign(
+               memcpy(__entry->comm, p->comm, TASK_COMM_LEN);
+               __entry->pid            = p->pid;
+               __entry->prio           = p->prio;
+       ),
+
+       TP_printk("comm=%s pid=%d prio=%d",
+                 __entry->comm, __entry->pid, __entry->prio)
+);
+
+/*
+ * Tracepoint for freeing a task:
+ */
+DEFINE_EVENT(sched_process_template, sched_process_free,
+            TP_PROTO(struct task_struct *p),
+            TP_ARGS(p));
+
+
+/*
+ * Tracepoint for a task exiting:
+ */
+DEFINE_EVENT(sched_process_template, sched_process_exit,
+            TP_PROTO(struct task_struct *p),
+            TP_ARGS(p));
+
+/*
+ * Tracepoint for waiting on task to unschedule:
+ */
+DEFINE_EVENT(sched_process_template, sched_wait_task,
+       TP_PROTO(struct task_struct *p),
+       TP_ARGS(p));
+
+/*
+ * Tracepoint for a waiting task:
+ */
+TRACE_EVENT(sched_process_wait,
+
+       TP_PROTO(struct pid *pid),
+
+       TP_ARGS(pid),
+
+       TP_STRUCT__entry(
+               __array(        char,   comm,   TASK_COMM_LEN   )
+               __field(        pid_t,  pid                     )
+               __field(        int,    prio                    )
+       ),
+
+       TP_fast_assign(
+               memcpy(__entry->comm, current->comm, TASK_COMM_LEN);
+               __entry->pid            = pid_nr(pid);
+               __entry->prio           = current->prio;
+       ),
+
+       TP_printk("comm=%s pid=%d prio=%d",
+                 __entry->comm, __entry->pid, __entry->prio)
+);
+
+/*
+ * Tracepoint for do_fork:
+ */
+TRACE_EVENT(sched_process_fork,
+
+       TP_PROTO(struct task_struct *parent, struct task_struct *child),
+
+       TP_ARGS(parent, child),
+
+       TP_STRUCT__entry(
+               __array(        char,   parent_comm,    TASK_COMM_LEN   )
+               __field(        pid_t,  parent_pid                      )
+               __array(        char,   child_comm,     TASK_COMM_LEN   )
+               __field(        pid_t,  child_pid                       )
+       ),
+
+       TP_fast_assign(
+               memcpy(__entry->parent_comm, parent->comm, TASK_COMM_LEN);
+               __entry->parent_pid     = parent->pid;
+               memcpy(__entry->child_comm, child->comm, TASK_COMM_LEN);
+               __entry->child_pid      = child->pid;
+       ),
+
+       TP_printk("comm=%s pid=%d child_comm=%s child_pid=%d",
+               __entry->parent_comm, __entry->parent_pid,
+               __entry->child_comm, __entry->child_pid)
+);
+
+/*
+ * Tracepoint for exec:
+ */
+TRACE_EVENT(sched_process_exec,
+
+       TP_PROTO(struct task_struct *p, pid_t old_pid,
+                struct linux_binprm *bprm),
+
+       TP_ARGS(p, old_pid, bprm),
+
+       TP_STRUCT__entry(
+               __string(       filename,       bprm->filename  )
+               __field(        pid_t,          pid             )
+               __field(        pid_t,          old_pid         )
+       ),
+
+       TP_fast_assign(
+               __assign_str(filename, bprm->filename);
+               __entry->pid            = p->pid;
+               __entry->old_pid        = old_pid;
+       ),
+
+       TP_printk("filename=%s pid=%d old_pid=%d", __get_str(filename),
+                 __entry->pid, __entry->old_pid)
+);
+
+/*
+ * XXX the below sched_stat tracepoints only apply to SCHED_OTHER/BATCH/IDLE
+ *     adding sched_stat support to SCHED_FIFO/RR would be welcome.
+ */
+DECLARE_EVENT_CLASS(sched_stat_template,
+
+       TP_PROTO(struct task_struct *tsk, u64 delay),
+
+       TP_ARGS(tsk, delay),
+
+       TP_STRUCT__entry(
+               __array( char,  comm,   TASK_COMM_LEN   )
+               __field( pid_t, pid                     )
+               __field( u64,   delay                   )
+       ),
+
+       TP_fast_assign(
+               memcpy(__entry->comm, tsk->comm, TASK_COMM_LEN);
+               __entry->pid    = tsk->pid;
+               __entry->delay  = delay;
+       )
+       TP_perf_assign(
+               __perf_count(delay);
+       ),
+
+       TP_printk("comm=%s pid=%d delay=%Lu [ns]",
+                       __entry->comm, __entry->pid,
+                       (unsigned long long)__entry->delay)
+);
+
+
+/*
+ * Tracepoint for accounting wait time (time the task is runnable
+ * but not actually running due to scheduler contention).
+ */
+DEFINE_EVENT(sched_stat_template, sched_stat_wait,
+            TP_PROTO(struct task_struct *tsk, u64 delay),
+            TP_ARGS(tsk, delay));
+
+/*
+ * Tracepoint for accounting sleep time (time the task is not runnable,
+ * including iowait, see below).
+ */
+DEFINE_EVENT(sched_stat_template, sched_stat_sleep,
+            TP_PROTO(struct task_struct *tsk, u64 delay),
+            TP_ARGS(tsk, delay));
+
+/*
+ * Tracepoint for accounting iowait time (time the task is not runnable
+ * due to waiting on IO to complete).
+ */
+DEFINE_EVENT(sched_stat_template, sched_stat_iowait,
+            TP_PROTO(struct task_struct *tsk, u64 delay),
+            TP_ARGS(tsk, delay));
+
+/*
+ * Tracepoint for accounting blocked time (time the task is in uninterruptible).
+ */
+DEFINE_EVENT(sched_stat_template, sched_stat_blocked,
+            TP_PROTO(struct task_struct *tsk, u64 delay),
+            TP_ARGS(tsk, delay));
+
+/*
+ * Tracepoint for accounting runtime (time the task is executing
+ * on a CPU).
+ */
+TRACE_EVENT(sched_stat_runtime,
+
+       TP_PROTO(struct task_struct *tsk, u64 runtime, u64 vruntime),
+
+       TP_ARGS(tsk, runtime, vruntime),
+
+       TP_STRUCT__entry(
+               __array( char,  comm,   TASK_COMM_LEN   )
+               __field( pid_t, pid                     )
+               __field( u64,   runtime                 )
+               __field( u64,   vruntime                        )
+       ),
+
+       TP_fast_assign(
+               memcpy(__entry->comm, tsk->comm, TASK_COMM_LEN);
+               __entry->pid            = tsk->pid;
+               __entry->runtime        = runtime;
+               __entry->vruntime       = vruntime;
+       )
+       TP_perf_assign(
+               __perf_count(runtime);
+       ),
+
+       TP_printk("comm=%s pid=%d runtime=%Lu [ns] vruntime=%Lu [ns]",
+                       __entry->comm, __entry->pid,
+                       (unsigned long long)__entry->runtime,
+                       (unsigned long long)__entry->vruntime)
+);
+
+/*
+ * Tracepoint for showing priority inheritance modifying a tasks
+ * priority.
+ */
+TRACE_EVENT(sched_pi_setprio,
+
+       TP_PROTO(struct task_struct *tsk, int newprio),
+
+       TP_ARGS(tsk, newprio),
+
+       TP_STRUCT__entry(
+               __array( char,  comm,   TASK_COMM_LEN   )
+               __field( pid_t, pid                     )
+               __field( int,   oldprio                 )
+               __field( int,   newprio                 )
+       ),
+
+       TP_fast_assign(
+               memcpy(__entry->comm, tsk->comm, TASK_COMM_LEN);
+               __entry->pid            = tsk->pid;
+               __entry->oldprio        = tsk->prio;
+               __entry->newprio        = newprio;
+       ),
+
+       TP_printk("comm=%s pid=%d oldprio=%d newprio=%d",
+                       __entry->comm, __entry->pid,
+                       __entry->oldprio, __entry->newprio)
+);
+
+#endif /* _TRACE_SCHED_H */
+
+/* This part must be outside protection */
+#include <trace/define_trace.h>
diff --git a/drivers/staging/lttng/instrumentation/events/mainline/scsi.h b/drivers/staging/lttng/instrumentation/events/mainline/scsi.h
new file mode 100644 (file)
index 0000000..db6c935
--- /dev/null
@@ -0,0 +1,365 @@
+#undef TRACE_SYSTEM
+#define TRACE_SYSTEM scsi
+
+#if !defined(_TRACE_SCSI_H) || defined(TRACE_HEADER_MULTI_READ)
+#define _TRACE_SCSI_H
+
+#include <scsi/scsi_cmnd.h>
+#include <scsi/scsi_host.h>
+#include <linux/tracepoint.h>
+#include <linux/trace_seq.h>
+
+#define scsi_opcode_name(opcode)       { opcode, #opcode }
+#define show_opcode_name(val)                                  \
+       __print_symbolic(val,                                   \
+               scsi_opcode_name(TEST_UNIT_READY),              \
+               scsi_opcode_name(REZERO_UNIT),                  \
+               scsi_opcode_name(REQUEST_SENSE),                \
+               scsi_opcode_name(FORMAT_UNIT),                  \
+               scsi_opcode_name(READ_BLOCK_LIMITS),            \
+               scsi_opcode_name(REASSIGN_BLOCKS),              \
+               scsi_opcode_name(INITIALIZE_ELEMENT_STATUS),    \
+               scsi_opcode_name(READ_6),                       \
+               scsi_opcode_name(WRITE_6),                      \
+               scsi_opcode_name(SEEK_6),                       \
+               scsi_opcode_name(READ_REVERSE),                 \
+               scsi_opcode_name(WRITE_FILEMARKS),              \
+               scsi_opcode_name(SPACE),                        \
+               scsi_opcode_name(INQUIRY),                      \
+               scsi_opcode_name(RECOVER_BUFFERED_DATA),        \
+               scsi_opcode_name(MODE_SELECT),                  \
+               scsi_opcode_name(RESERVE),                      \
+               scsi_opcode_name(RELEASE),                      \
+               scsi_opcode_name(COPY),                         \
+               scsi_opcode_name(ERASE),                        \
+               scsi_opcode_name(MODE_SENSE),                   \
+               scsi_opcode_name(START_STOP),                   \
+               scsi_opcode_name(RECEIVE_DIAGNOSTIC),           \
+               scsi_opcode_name(SEND_DIAGNOSTIC),              \
+               scsi_opcode_name(ALLOW_MEDIUM_REMOVAL),         \
+               scsi_opcode_name(SET_WINDOW),                   \
+               scsi_opcode_name(READ_CAPACITY),                \
+               scsi_opcode_name(READ_10),                      \
+               scsi_opcode_name(WRITE_10),                     \
+               scsi_opcode_name(SEEK_10),                      \
+               scsi_opcode_name(POSITION_TO_ELEMENT),          \
+               scsi_opcode_name(WRITE_VERIFY),                 \
+               scsi_opcode_name(VERIFY),                       \
+               scsi_opcode_name(SEARCH_HIGH),                  \
+               scsi_opcode_name(SEARCH_EQUAL),                 \
+               scsi_opcode_name(SEARCH_LOW),                   \
+               scsi_opcode_name(SET_LIMITS),                   \
+               scsi_opcode_name(PRE_FETCH),                    \
+               scsi_opcode_name(READ_POSITION),                \
+               scsi_opcode_name(SYNCHRONIZE_CACHE),            \
+               scsi_opcode_name(LOCK_UNLOCK_CACHE),            \
+               scsi_opcode_name(READ_DEFECT_DATA),             \
+               scsi_opcode_name(MEDIUM_SCAN),                  \
+               scsi_opcode_name(COMPARE),                      \
+               scsi_opcode_name(COPY_VERIFY),                  \
+               scsi_opcode_name(WRITE_BUFFER),                 \
+               scsi_opcode_name(READ_BUFFER),                  \
+               scsi_opcode_name(UPDATE_BLOCK),                 \
+               scsi_opcode_name(READ_LONG),                    \
+               scsi_opcode_name(WRITE_LONG),                   \
+               scsi_opcode_name(CHANGE_DEFINITION),            \
+               scsi_opcode_name(WRITE_SAME),                   \
+               scsi_opcode_name(UNMAP),                        \
+               scsi_opcode_name(READ_TOC),                     \
+               scsi_opcode_name(LOG_SELECT),                   \
+               scsi_opcode_name(LOG_SENSE),                    \
+               scsi_opcode_name(XDWRITEREAD_10),               \
+               scsi_opcode_name(MODE_SELECT_10),               \
+               scsi_opcode_name(RESERVE_10),                   \
+               scsi_opcode_name(RELEASE_10),                   \
+               scsi_opcode_name(MODE_SENSE_10),                \
+               scsi_opcode_name(PERSISTENT_RESERVE_IN),        \
+               scsi_opcode_name(PERSISTENT_RESERVE_OUT),       \
+               scsi_opcode_name(VARIABLE_LENGTH_CMD),          \
+               scsi_opcode_name(REPORT_LUNS),                  \
+               scsi_opcode_name(MAINTENANCE_IN),               \
+               scsi_opcode_name(MAINTENANCE_OUT),              \
+               scsi_opcode_name(MOVE_MEDIUM),                  \
+               scsi_opcode_name(EXCHANGE_MEDIUM),              \
+               scsi_opcode_name(READ_12),                      \
+               scsi_opcode_name(WRITE_12),                     \
+               scsi_opcode_name(WRITE_VERIFY_12),              \
+               scsi_opcode_name(SEARCH_HIGH_12),               \
+               scsi_opcode_name(SEARCH_EQUAL_12),              \
+               scsi_opcode_name(SEARCH_LOW_12),                \
+               scsi_opcode_name(READ_ELEMENT_STATUS),          \
+               scsi_opcode_name(SEND_VOLUME_TAG),              \
+               scsi_opcode_name(WRITE_LONG_2),                 \
+               scsi_opcode_name(READ_16),                      \
+               scsi_opcode_name(WRITE_16),                     \
+               scsi_opcode_name(VERIFY_16),                    \
+               scsi_opcode_name(WRITE_SAME_16),                \
+               scsi_opcode_name(SERVICE_ACTION_IN),            \
+               scsi_opcode_name(SAI_READ_CAPACITY_16),         \
+               scsi_opcode_name(SAI_GET_LBA_STATUS),           \
+               scsi_opcode_name(MI_REPORT_TARGET_PGS),         \
+               scsi_opcode_name(MO_SET_TARGET_PGS),            \
+               scsi_opcode_name(READ_32),                      \
+               scsi_opcode_name(WRITE_32),                     \
+               scsi_opcode_name(WRITE_SAME_32),                \
+               scsi_opcode_name(ATA_16),                       \
+               scsi_opcode_name(ATA_12))
+
+#define scsi_hostbyte_name(result)     { result, #result }
+#define show_hostbyte_name(val)                                        \
+       __print_symbolic(val,                                   \
+               scsi_hostbyte_name(DID_OK),                     \
+               scsi_hostbyte_name(DID_NO_CONNECT),             \
+               scsi_hostbyte_name(DID_BUS_BUSY),               \
+               scsi_hostbyte_name(DID_TIME_OUT),               \
+               scsi_hostbyte_name(DID_BAD_TARGET),             \
+               scsi_hostbyte_name(DID_ABORT),                  \
+               scsi_hostbyte_name(DID_PARITY),                 \
+               scsi_hostbyte_name(DID_ERROR),                  \
+               scsi_hostbyte_name(DID_RESET),                  \
+               scsi_hostbyte_name(DID_BAD_INTR),               \
+               scsi_hostbyte_name(DID_PASSTHROUGH),            \
+               scsi_hostbyte_name(DID_SOFT_ERROR),             \
+               scsi_hostbyte_name(DID_IMM_RETRY),              \
+               scsi_hostbyte_name(DID_REQUEUE),                \
+               scsi_hostbyte_name(DID_TRANSPORT_DISRUPTED),    \
+               scsi_hostbyte_name(DID_TRANSPORT_FAILFAST))
+
+#define scsi_driverbyte_name(result)   { result, #result }
+#define show_driverbyte_name(val)                              \
+       __print_symbolic(val,                                   \
+               scsi_driverbyte_name(DRIVER_OK),                \
+               scsi_driverbyte_name(DRIVER_BUSY),              \
+               scsi_driverbyte_name(DRIVER_SOFT),              \
+               scsi_driverbyte_name(DRIVER_MEDIA),             \
+               scsi_driverbyte_name(DRIVER_ERROR),             \
+               scsi_driverbyte_name(DRIVER_INVALID),           \
+               scsi_driverbyte_name(DRIVER_TIMEOUT),           \
+               scsi_driverbyte_name(DRIVER_HARD),              \
+               scsi_driverbyte_name(DRIVER_SENSE))
+
+#define scsi_msgbyte_name(result)      { result, #result }
+#define show_msgbyte_name(val)                                 \
+       __print_symbolic(val,                                   \
+               scsi_msgbyte_name(COMMAND_COMPLETE),            \
+               scsi_msgbyte_name(EXTENDED_MESSAGE),            \
+               scsi_msgbyte_name(SAVE_POINTERS),               \
+               scsi_msgbyte_name(RESTORE_POINTERS),            \
+               scsi_msgbyte_name(DISCONNECT),                  \
+               scsi_msgbyte_name(INITIATOR_ERROR),             \
+               scsi_msgbyte_name(ABORT_TASK_SET),              \
+               scsi_msgbyte_name(MESSAGE_REJECT),              \
+               scsi_msgbyte_name(NOP),                         \
+               scsi_msgbyte_name(MSG_PARITY_ERROR),            \
+               scsi_msgbyte_name(LINKED_CMD_COMPLETE),         \
+               scsi_msgbyte_name(LINKED_FLG_CMD_COMPLETE),     \
+               scsi_msgbyte_name(TARGET_RESET),                \
+               scsi_msgbyte_name(ABORT_TASK),                  \
+               scsi_msgbyte_name(CLEAR_TASK_SET),              \
+               scsi_msgbyte_name(INITIATE_RECOVERY),           \
+               scsi_msgbyte_name(RELEASE_RECOVERY),            \
+               scsi_msgbyte_name(CLEAR_ACA),                   \
+               scsi_msgbyte_name(LOGICAL_UNIT_RESET),          \
+               scsi_msgbyte_name(SIMPLE_QUEUE_TAG),            \
+               scsi_msgbyte_name(HEAD_OF_QUEUE_TAG),           \
+               scsi_msgbyte_name(ORDERED_QUEUE_TAG),           \
+               scsi_msgbyte_name(IGNORE_WIDE_RESIDUE),         \
+               scsi_msgbyte_name(ACA),                         \
+               scsi_msgbyte_name(QAS_REQUEST),                 \
+               scsi_msgbyte_name(BUS_DEVICE_RESET),            \
+               scsi_msgbyte_name(ABORT))
+
+#define scsi_statusbyte_name(result)   { result, #result }
+#define show_statusbyte_name(val)                              \
+       __print_symbolic(val,                                   \
+               scsi_statusbyte_name(SAM_STAT_GOOD),            \
+               scsi_statusbyte_name(SAM_STAT_CHECK_CONDITION), \
+               scsi_statusbyte_name(SAM_STAT_CONDITION_MET),   \
+               scsi_statusbyte_name(SAM_STAT_BUSY),            \
+               scsi_statusbyte_name(SAM_STAT_INTERMEDIATE),    \
+               scsi_statusbyte_name(SAM_STAT_INTERMEDIATE_CONDITION_MET), \
+               scsi_statusbyte_name(SAM_STAT_RESERVATION_CONFLICT),    \
+               scsi_statusbyte_name(SAM_STAT_COMMAND_TERMINATED),      \
+               scsi_statusbyte_name(SAM_STAT_TASK_SET_FULL),   \
+               scsi_statusbyte_name(SAM_STAT_ACA_ACTIVE),      \
+               scsi_statusbyte_name(SAM_STAT_TASK_ABORTED))
+
+#define scsi_prot_op_name(result)      { result, #result }
+#define show_prot_op_name(val)                                 \
+       __print_symbolic(val,                                   \
+               scsi_prot_op_name(SCSI_PROT_NORMAL),            \
+               scsi_prot_op_name(SCSI_PROT_READ_INSERT),       \
+               scsi_prot_op_name(SCSI_PROT_WRITE_STRIP),       \
+               scsi_prot_op_name(SCSI_PROT_READ_STRIP),        \
+               scsi_prot_op_name(SCSI_PROT_WRITE_INSERT),      \
+               scsi_prot_op_name(SCSI_PROT_READ_PASS),         \
+               scsi_prot_op_name(SCSI_PROT_WRITE_PASS))
+
+const char *scsi_trace_parse_cdb(struct trace_seq*, unsigned char*, int);
+#define __parse_cdb(cdb, len) scsi_trace_parse_cdb(p, cdb, len)
+
+TRACE_EVENT(scsi_dispatch_cmd_start,
+
+       TP_PROTO(struct scsi_cmnd *cmd),
+
+       TP_ARGS(cmd),
+
+       TP_STRUCT__entry(
+               __field( unsigned int,  host_no )
+               __field( unsigned int,  channel )
+               __field( unsigned int,  id      )
+               __field( unsigned int,  lun     )
+               __field( unsigned int,  opcode  )
+               __field( unsigned int,  cmd_len )
+               __field( unsigned int,  data_sglen )
+               __field( unsigned int,  prot_sglen )
+               __field( unsigned char, prot_op )
+               __dynamic_array(unsigned char,  cmnd, cmd->cmd_len)
+       ),
+
+       TP_fast_assign(
+               __entry->host_no        = cmd->device->host->host_no;
+               __entry->channel        = cmd->device->channel;
+               __entry->id             = cmd->device->id;
+               __entry->lun            = cmd->device->lun;
+               __entry->opcode         = cmd->cmnd[0];
+               __entry->cmd_len        = cmd->cmd_len;
+               __entry->data_sglen     = scsi_sg_count(cmd);
+               __entry->prot_sglen     = scsi_prot_sg_count(cmd);
+               __entry->prot_op        = scsi_get_prot_op(cmd);
+               memcpy(__get_dynamic_array(cmnd), cmd->cmnd, cmd->cmd_len);
+       ),
+
+       TP_printk("host_no=%u channel=%u id=%u lun=%u data_sgl=%u prot_sgl=%u" \
+                 " prot_op=%s cmnd=(%s %s raw=%s)",
+                 __entry->host_no, __entry->channel, __entry->id,
+                 __entry->lun, __entry->data_sglen, __entry->prot_sglen,
+                 show_prot_op_name(__entry->prot_op),
+                 show_opcode_name(__entry->opcode),
+                 __parse_cdb(__get_dynamic_array(cmnd), __entry->cmd_len),
+                 __print_hex(__get_dynamic_array(cmnd), __entry->cmd_len))
+);
+
+TRACE_EVENT(scsi_dispatch_cmd_error,
+
+       TP_PROTO(struct scsi_cmnd *cmd, int rtn),
+
+       TP_ARGS(cmd, rtn),
+
+       TP_STRUCT__entry(
+               __field( unsigned int,  host_no )
+               __field( unsigned int,  channel )
+               __field( unsigned int,  id      )
+               __field( unsigned int,  lun     )
+               __field( int,           rtn     )
+               __field( unsigned int,  opcode  )
+               __field( unsigned int,  cmd_len )
+               __field( unsigned int,  data_sglen )
+               __field( unsigned int,  prot_sglen )
+               __field( unsigned char, prot_op )
+               __dynamic_array(unsigned char,  cmnd, cmd->cmd_len)
+       ),
+
+       TP_fast_assign(
+               __entry->host_no        = cmd->device->host->host_no;
+               __entry->channel        = cmd->device->channel;
+               __entry->id             = cmd->device->id;
+               __entry->lun            = cmd->device->lun;
+               __entry->rtn            = rtn;
+               __entry->opcode         = cmd->cmnd[0];
+               __entry->cmd_len        = cmd->cmd_len;
+               __entry->data_sglen     = scsi_sg_count(cmd);
+               __entry->prot_sglen     = scsi_prot_sg_count(cmd);
+               __entry->prot_op        = scsi_get_prot_op(cmd);
+               memcpy(__get_dynamic_array(cmnd), cmd->cmnd, cmd->cmd_len);
+       ),
+
+       TP_printk("host_no=%u channel=%u id=%u lun=%u data_sgl=%u prot_sgl=%u" \
+                 " prot_op=%s cmnd=(%s %s raw=%s) rtn=%d",
+                 __entry->host_no, __entry->channel, __entry->id,
+                 __entry->lun, __entry->data_sglen, __entry->prot_sglen,
+                 show_prot_op_name(__entry->prot_op),
+                 show_opcode_name(__entry->opcode),
+                 __parse_cdb(__get_dynamic_array(cmnd), __entry->cmd_len),
+                 __print_hex(__get_dynamic_array(cmnd), __entry->cmd_len),
+                 __entry->rtn)
+);
+
+DECLARE_EVENT_CLASS(scsi_cmd_done_timeout_template,
+
+       TP_PROTO(struct scsi_cmnd *cmd),
+
+       TP_ARGS(cmd),
+
+       TP_STRUCT__entry(
+               __field( unsigned int,  host_no )
+               __field( unsigned int,  channel )
+               __field( unsigned int,  id      )
+               __field( unsigned int,  lun     )
+               __field( int,           result  )
+               __field( unsigned int,  opcode  )
+               __field( unsigned int,  cmd_len )
+               __field( unsigned int,  data_sglen )
+               __field( unsigned int,  prot_sglen )
+               __field( unsigned char, prot_op )
+               __dynamic_array(unsigned char,  cmnd, cmd->cmd_len)
+       ),
+
+       TP_fast_assign(
+               __entry->host_no        = cmd->device->host->host_no;
+               __entry->channel        = cmd->device->channel;
+               __entry->id             = cmd->device->id;
+               __entry->lun            = cmd->device->lun;
+               __entry->result         = cmd->result;
+               __entry->opcode         = cmd->cmnd[0];
+               __entry->cmd_len        = cmd->cmd_len;
+               __entry->data_sglen     = scsi_sg_count(cmd);
+               __entry->prot_sglen     = scsi_prot_sg_count(cmd);
+               __entry->prot_op        = scsi_get_prot_op(cmd);
+               memcpy(__get_dynamic_array(cmnd), cmd->cmnd, cmd->cmd_len);
+       ),
+
+       TP_printk("host_no=%u channel=%u id=%u lun=%u data_sgl=%u " \
+                 "prot_sgl=%u prot_op=%s cmnd=(%s %s raw=%s) result=(driver=" \
+                 "%s host=%s message=%s status=%s)",
+                 __entry->host_no, __entry->channel, __entry->id,
+                 __entry->lun, __entry->data_sglen, __entry->prot_sglen,
+                 show_prot_op_name(__entry->prot_op),
+                 show_opcode_name(__entry->opcode),
+                 __parse_cdb(__get_dynamic_array(cmnd), __entry->cmd_len),
+                 __print_hex(__get_dynamic_array(cmnd), __entry->cmd_len),
+                 show_driverbyte_name(((__entry->result) >> 24) & 0xff),
+                 show_hostbyte_name(((__entry->result) >> 16) & 0xff),
+                 show_msgbyte_name(((__entry->result) >> 8) & 0xff),
+                 show_statusbyte_name(__entry->result & 0xff))
+);
+
+DEFINE_EVENT(scsi_cmd_done_timeout_template, scsi_dispatch_cmd_done,
+            TP_PROTO(struct scsi_cmnd *cmd),
+            TP_ARGS(cmd));
+
+DEFINE_EVENT(scsi_cmd_done_timeout_template, scsi_dispatch_cmd_timeout,
+            TP_PROTO(struct scsi_cmnd *cmd),
+            TP_ARGS(cmd));
+
+TRACE_EVENT(scsi_eh_wakeup,
+
+       TP_PROTO(struct Scsi_Host *shost),
+
+       TP_ARGS(shost),
+
+       TP_STRUCT__entry(
+               __field( unsigned int,  host_no )
+       ),
+
+       TP_fast_assign(
+               __entry->host_no        = shost->host_no;
+       ),
+
+       TP_printk("host_no=%u", __entry->host_no)
+);
+
+#endif /*  _TRACE_SCSI_H */
+
+/* This part must be outside protection */
+#include <trace/define_trace.h>
diff --git a/drivers/staging/lttng/instrumentation/events/mainline/signal.h b/drivers/staging/lttng/instrumentation/events/mainline/signal.h
new file mode 100644 (file)
index 0000000..39a8a43
--- /dev/null
@@ -0,0 +1,125 @@
+#undef TRACE_SYSTEM
+#define TRACE_SYSTEM signal
+
+#if !defined(_TRACE_SIGNAL_H) || defined(TRACE_HEADER_MULTI_READ)
+#define _TRACE_SIGNAL_H
+
+#include <linux/signal.h>
+#include <linux/sched.h>
+#include <linux/tracepoint.h>
+
+#define TP_STORE_SIGINFO(__entry, info)                                \
+       do {                                                    \
+               if (info == SEND_SIG_NOINFO ||                  \
+                   info == SEND_SIG_FORCED) {                  \
+                       __entry->errno  = 0;                    \
+                       __entry->code   = SI_USER;              \
+               } else if (info == SEND_SIG_PRIV) {             \
+                       __entry->errno  = 0;                    \
+                       __entry->code   = SI_KERNEL;            \
+               } else {                                        \
+                       __entry->errno  = info->si_errno;       \
+                       __entry->code   = info->si_code;        \
+               }                                               \
+       } while (0)
+
+#ifndef TRACE_HEADER_MULTI_READ
+enum {
+       TRACE_SIGNAL_DELIVERED,
+       TRACE_SIGNAL_IGNORED,
+       TRACE_SIGNAL_ALREADY_PENDING,
+       TRACE_SIGNAL_OVERFLOW_FAIL,
+       TRACE_SIGNAL_LOSE_INFO,
+};
+#endif
+
+/**
+ * signal_generate - called when a signal is generated
+ * @sig: signal number
+ * @info: pointer to struct siginfo
+ * @task: pointer to struct task_struct
+ * @group: shared or private
+ * @result: TRACE_SIGNAL_*
+ *
+ * Current process sends a 'sig' signal to 'task' process with
+ * 'info' siginfo. If 'info' is SEND_SIG_NOINFO or SEND_SIG_PRIV,
+ * 'info' is not a pointer and you can't access its field. Instead,
+ * SEND_SIG_NOINFO means that si_code is SI_USER, and SEND_SIG_PRIV
+ * means that si_code is SI_KERNEL.
+ */
+TRACE_EVENT(signal_generate,
+
+       TP_PROTO(int sig, struct siginfo *info, struct task_struct *task,
+                       int group, int result),
+
+       TP_ARGS(sig, info, task, group, result),
+
+       TP_STRUCT__entry(
+               __field(        int,    sig                     )
+               __field(        int,    errno                   )
+               __field(        int,    code                    )
+               __array(        char,   comm,   TASK_COMM_LEN   )
+               __field(        pid_t,  pid                     )
+               __field(        int,    group                   )
+               __field(        int,    result                  )
+       ),
+
+       TP_fast_assign(
+               __entry->sig    = sig;
+               TP_STORE_SIGINFO(__entry, info);
+               memcpy(__entry->comm, task->comm, TASK_COMM_LEN);
+               __entry->pid    = task->pid;
+               __entry->group  = group;
+               __entry->result = result;
+       ),
+
+       TP_printk("sig=%d errno=%d code=%d comm=%s pid=%d grp=%d res=%d",
+                 __entry->sig, __entry->errno, __entry->code,
+                 __entry->comm, __entry->pid, __entry->group,
+                 __entry->result)
+);
+
+/**
+ * signal_deliver - called when a signal is delivered
+ * @sig: signal number
+ * @info: pointer to struct siginfo
+ * @ka: pointer to struct k_sigaction
+ *
+ * A 'sig' signal is delivered to current process with 'info' siginfo,
+ * and it will be handled by 'ka'. ka->sa.sa_handler can be SIG_IGN or
+ * SIG_DFL.
+ * Note that some signals reported by signal_generate tracepoint can be
+ * lost, ignored or modified (by debugger) before hitting this tracepoint.
+ * This means, this can show which signals are actually delivered, but
+ * matching generated signals and delivered signals may not be correct.
+ */
+TRACE_EVENT(signal_deliver,
+
+       TP_PROTO(int sig, struct siginfo *info, struct k_sigaction *ka),
+
+       TP_ARGS(sig, info, ka),
+
+       TP_STRUCT__entry(
+               __field(        int,            sig             )
+               __field(        int,            errno           )
+               __field(        int,            code            )
+               __field(        unsigned long,  sa_handler      )
+               __field(        unsigned long,  sa_flags        )
+       ),
+
+       TP_fast_assign(
+               __entry->sig    = sig;
+               TP_STORE_SIGINFO(__entry, info);
+               __entry->sa_handler     = (unsigned long)ka->sa.sa_handler;
+               __entry->sa_flags       = ka->sa.sa_flags;
+       ),
+
+       TP_printk("sig=%d errno=%d code=%d sa_handler=%lx sa_flags=%lx",
+                 __entry->sig, __entry->errno, __entry->code,
+                 __entry->sa_handler, __entry->sa_flags)
+);
+
+#endif /* _TRACE_SIGNAL_H */
+
+/* This part must be outside protection */
+#include <trace/define_trace.h>
diff --git a/drivers/staging/lttng/instrumentation/events/mainline/skb.h b/drivers/staging/lttng/instrumentation/events/mainline/skb.h
new file mode 100644 (file)
index 0000000..0c68ae2
--- /dev/null
@@ -0,0 +1,75 @@
+#undef TRACE_SYSTEM
+#define TRACE_SYSTEM skb
+
+#if !defined(_TRACE_SKB_H) || defined(TRACE_HEADER_MULTI_READ)
+#define _TRACE_SKB_H
+
+#include <linux/skbuff.h>
+#include <linux/netdevice.h>
+#include <linux/tracepoint.h>
+
+/*
+ * Tracepoint for free an sk_buff:
+ */
+TRACE_EVENT(kfree_skb,
+
+       TP_PROTO(struct sk_buff *skb, void *location),
+
+       TP_ARGS(skb, location),
+
+       TP_STRUCT__entry(
+               __field(        void *,         skbaddr         )
+               __field(        void *,         location        )
+               __field(        unsigned short, protocol        )
+       ),
+
+       TP_fast_assign(
+               __entry->skbaddr = skb;
+               __entry->location = location;
+               __entry->protocol = ntohs(skb->protocol);
+       ),
+
+       TP_printk("skbaddr=%p protocol=%u location=%p",
+               __entry->skbaddr, __entry->protocol, __entry->location)
+);
+
+TRACE_EVENT(consume_skb,
+
+       TP_PROTO(struct sk_buff *skb),
+
+       TP_ARGS(skb),
+
+       TP_STRUCT__entry(
+               __field(        void *, skbaddr )
+       ),
+
+       TP_fast_assign(
+               __entry->skbaddr = skb;
+       ),
+
+       TP_printk("skbaddr=%p", __entry->skbaddr)
+);
+
+TRACE_EVENT(skb_copy_datagram_iovec,
+
+       TP_PROTO(const struct sk_buff *skb, int len),
+
+       TP_ARGS(skb, len),
+
+       TP_STRUCT__entry(
+               __field(        const void *,           skbaddr         )
+               __field(        int,                    len             )
+       ),
+
+       TP_fast_assign(
+               __entry->skbaddr = skb;
+               __entry->len = len;
+       ),
+
+       TP_printk("skbaddr=%p len=%d", __entry->skbaddr, __entry->len)
+);
+
+#endif /* _TRACE_SKB_H */
+
+/* This part must be outside protection */
+#include <trace/define_trace.h>
diff --git a/drivers/staging/lttng/instrumentation/events/mainline/sock.h b/drivers/staging/lttng/instrumentation/events/mainline/sock.h
new file mode 100644 (file)
index 0000000..779abb9
--- /dev/null
@@ -0,0 +1,68 @@
+#undef TRACE_SYSTEM
+#define TRACE_SYSTEM sock
+
+#if !defined(_TRACE_SOCK_H) || defined(TRACE_HEADER_MULTI_READ)
+#define _TRACE_SOCK_H
+
+#include <net/sock.h>
+#include <linux/tracepoint.h>
+
+TRACE_EVENT(sock_rcvqueue_full,
+
+       TP_PROTO(struct sock *sk, struct sk_buff *skb),
+
+       TP_ARGS(sk, skb),
+
+       TP_STRUCT__entry(
+               __field(int, rmem_alloc)
+               __field(unsigned int, truesize)
+               __field(int, sk_rcvbuf)
+       ),
+
+       TP_fast_assign(
+               __entry->rmem_alloc = atomic_read(&sk->sk_rmem_alloc);
+               __entry->truesize   = skb->truesize;
+               __entry->sk_rcvbuf  = sk->sk_rcvbuf;
+       ),
+
+       TP_printk("rmem_alloc=%d truesize=%u sk_rcvbuf=%d",
+               __entry->rmem_alloc, __entry->truesize, __entry->sk_rcvbuf)
+);
+
+TRACE_EVENT(sock_exceed_buf_limit,
+
+       TP_PROTO(struct sock *sk, struct proto *prot, long allocated),
+
+       TP_ARGS(sk, prot, allocated),
+
+       TP_STRUCT__entry(
+               __array(char, name, 32)
+               __field(long *, sysctl_mem)
+               __field(long, allocated)
+               __field(int, sysctl_rmem)
+               __field(int, rmem_alloc)
+       ),
+
+       TP_fast_assign(
+               strncpy(__entry->name, prot->name, 32);
+               __entry->sysctl_mem = prot->sysctl_mem;
+               __entry->allocated = allocated;
+               __entry->sysctl_rmem = prot->sysctl_rmem[0];
+               __entry->rmem_alloc = atomic_read(&sk->sk_rmem_alloc);
+       ),
+
+       TP_printk("proto:%s sysctl_mem=%ld,%ld,%ld allocated=%ld "
+               "sysctl_rmem=%d rmem_alloc=%d",
+               __entry->name,
+               __entry->sysctl_mem[0],
+               __entry->sysctl_mem[1],
+               __entry->sysctl_mem[2],
+               __entry->allocated,
+               __entry->sysctl_rmem,
+               __entry->rmem_alloc)
+);
+
+#endif /* _TRACE_SOCK_H */
+
+/* This part must be outside protection */
+#include <trace/define_trace.h>
diff --git a/drivers/staging/lttng/instrumentation/events/mainline/sunrpc.h b/drivers/staging/lttng/instrumentation/events/mainline/sunrpc.h
new file mode 100644 (file)
index 0000000..43be87d
--- /dev/null
@@ -0,0 +1,177 @@
+#undef TRACE_SYSTEM
+#define TRACE_SYSTEM sunrpc
+
+#if !defined(_TRACE_SUNRPC_H) || defined(TRACE_HEADER_MULTI_READ)
+#define _TRACE_SUNRPC_H
+
+#include <linux/sunrpc/sched.h>
+#include <linux/sunrpc/clnt.h>
+#include <linux/tracepoint.h>
+
+DECLARE_EVENT_CLASS(rpc_task_status,
+
+       TP_PROTO(struct rpc_task *task),
+
+       TP_ARGS(task),
+
+       TP_STRUCT__entry(
+               __field(const struct rpc_task *, task)
+               __field(const struct rpc_clnt *, clnt)
+               __field(int, status)
+       ),
+
+       TP_fast_assign(
+               __entry->task = task;
+               __entry->clnt = task->tk_client;
+               __entry->status = task->tk_status;
+       ),
+
+       TP_printk("task:%p@%p, status %d",__entry->task, __entry->clnt, __entry->status)
+);
+
+DEFINE_EVENT(rpc_task_status, rpc_call_status,
+       TP_PROTO(struct rpc_task *task),
+
+       TP_ARGS(task)
+);
+
+DEFINE_EVENT(rpc_task_status, rpc_bind_status,
+       TP_PROTO(struct rpc_task *task),
+
+       TP_ARGS(task)
+);
+
+TRACE_EVENT(rpc_connect_status,
+       TP_PROTO(struct rpc_task *task, int status),
+
+       TP_ARGS(task, status),
+
+       TP_STRUCT__entry(
+               __field(const struct rpc_task *, task)
+               __field(const struct rpc_clnt *, clnt)
+               __field(int, status)
+       ),
+
+       TP_fast_assign(
+               __entry->task = task;
+               __entry->clnt = task->tk_client;
+               __entry->status = status;
+       ),
+
+       TP_printk("task:%p@%p, status %d",__entry->task, __entry->clnt, __entry->status)
+);
+
+DECLARE_EVENT_CLASS(rpc_task_running,
+
+       TP_PROTO(const struct rpc_clnt *clnt, const struct rpc_task *task, const void *action),
+
+       TP_ARGS(clnt, task, action),
+
+       TP_STRUCT__entry(
+               __field(const struct rpc_clnt *, clnt)
+               __field(const struct rpc_task *, task)
+               __field(const void *, action)
+               __field(unsigned long, runstate)
+               __field(int, status)
+               __field(unsigned short, flags)
+               ),
+
+       TP_fast_assign(
+               __entry->clnt = clnt;
+               __entry->task = task;
+               __entry->action = action;
+               __entry->runstate = task->tk_runstate;
+               __entry->status = task->tk_status;
+               __entry->flags = task->tk_flags;
+               ),
+
+       TP_printk("task:%p@%p flags=%4.4x state=%4.4lx status=%d action=%pf",
+               __entry->task,
+               __entry->clnt,
+               __entry->flags,
+               __entry->runstate,
+               __entry->status,
+               __entry->action
+               )
+);
+
+DEFINE_EVENT(rpc_task_running, rpc_task_begin,
+
+       TP_PROTO(const struct rpc_clnt *clnt, const struct rpc_task *task, const void *action),
+
+       TP_ARGS(clnt, task, action)
+
+);
+
+DEFINE_EVENT(rpc_task_running, rpc_task_run_action,
+
+       TP_PROTO(const struct rpc_clnt *clnt, const struct rpc_task *task, const void *action),
+
+       TP_ARGS(clnt, task, action)
+
+);
+
+DEFINE_EVENT(rpc_task_running, rpc_task_complete,
+
+       TP_PROTO(const struct rpc_clnt *clnt, const struct rpc_task *task, const void *action),
+
+       TP_ARGS(clnt, task, action)
+
+);
+
+DECLARE_EVENT_CLASS(rpc_task_queued,
+
+       TP_PROTO(const struct rpc_clnt *clnt, const struct rpc_task *task, const struct rpc_wait_queue *q),
+
+       TP_ARGS(clnt, task, q),
+
+       TP_STRUCT__entry(
+               __field(const struct rpc_clnt *, clnt)
+               __field(const struct rpc_task *, task)
+               __field(unsigned long, timeout)
+               __field(unsigned long, runstate)
+               __field(int, status)
+               __field(unsigned short, flags)
+               __string(q_name, rpc_qname(q))
+               ),
+
+       TP_fast_assign(
+               __entry->clnt = clnt;
+               __entry->task = task;
+               __entry->timeout = task->tk_timeout;
+               __entry->runstate = task->tk_runstate;
+               __entry->status = task->tk_status;
+               __entry->flags = task->tk_flags;
+               __assign_str(q_name, rpc_qname(q));
+               ),
+
+       TP_printk("task:%p@%p flags=%4.4x state=%4.4lx status=%d timeout=%lu queue=%s",
+               __entry->task,
+               __entry->clnt,
+               __entry->flags,
+               __entry->runstate,
+               __entry->status,
+               __entry->timeout,
+               __get_str(q_name)
+               )
+);
+
+DEFINE_EVENT(rpc_task_queued, rpc_task_sleep,
+
+       TP_PROTO(const struct rpc_clnt *clnt, const struct rpc_task *task, const struct rpc_wait_queue *q),
+
+       TP_ARGS(clnt, task, q)
+
+);
+
+DEFINE_EVENT(rpc_task_queued, rpc_task_wakeup,
+
+       TP_PROTO(const struct rpc_clnt *clnt, const struct rpc_task *task, const struct rpc_wait_queue *q),
+
+       TP_ARGS(clnt, task, q)
+
+);
+
+#endif /* _TRACE_SUNRPC_H */
+
+#include <trace/define_trace.h>
diff --git a/drivers/staging/lttng/instrumentation/events/mainline/syscalls.h b/drivers/staging/lttng/instrumentation/events/mainline/syscalls.h
new file mode 100644 (file)
index 0000000..5a4c04a
--- /dev/null
@@ -0,0 +1,75 @@
+#undef TRACE_SYSTEM
+#define TRACE_SYSTEM raw_syscalls
+#define TRACE_INCLUDE_FILE syscalls
+
+#if !defined(_TRACE_EVENTS_SYSCALLS_H) || defined(TRACE_HEADER_MULTI_READ)
+#define _TRACE_EVENTS_SYSCALLS_H
+
+#include <linux/tracepoint.h>
+
+#include <asm/ptrace.h>
+#include <asm/syscall.h>
+
+
+#ifdef CONFIG_HAVE_SYSCALL_TRACEPOINTS
+
+extern void syscall_regfunc(void);
+extern void syscall_unregfunc(void);
+
+TRACE_EVENT_FN(sys_enter,
+
+       TP_PROTO(struct pt_regs *regs, long id),
+
+       TP_ARGS(regs, id),
+
+       TP_STRUCT__entry(
+               __field(        long,           id              )
+               __array(        unsigned long,  args,   6       )
+       ),
+
+       TP_fast_assign(
+               __entry->id     = id;
+               syscall_get_arguments(current, regs, 0, 6, __entry->args);
+       ),
+
+       TP_printk("NR %ld (%lx, %lx, %lx, %lx, %lx, %lx)",
+                 __entry->id,
+                 __entry->args[0], __entry->args[1], __entry->args[2],
+                 __entry->args[3], __entry->args[4], __entry->args[5]),
+
+       syscall_regfunc, syscall_unregfunc
+);
+
+TRACE_EVENT_FLAGS(sys_enter, TRACE_EVENT_FL_CAP_ANY)
+
+TRACE_EVENT_FN(sys_exit,
+
+       TP_PROTO(struct pt_regs *regs, long ret),
+
+       TP_ARGS(regs, ret),
+
+       TP_STRUCT__entry(
+               __field(        long,   id      )
+               __field(        long,   ret     )
+       ),
+
+       TP_fast_assign(
+               __entry->id     = syscall_get_nr(current, regs);
+               __entry->ret    = ret;
+       ),
+
+       TP_printk("NR %ld = %ld",
+                 __entry->id, __entry->ret),
+
+       syscall_regfunc, syscall_unregfunc
+);
+
+TRACE_EVENT_FLAGS(sys_exit, TRACE_EVENT_FL_CAP_ANY)
+
+#endif /* CONFIG_HAVE_SYSCALL_TRACEPOINTS */
+
+#endif /* _TRACE_EVENTS_SYSCALLS_H */
+
+/* This part must be outside protection */
+#include <trace/define_trace.h>
+
diff --git a/drivers/staging/lttng/instrumentation/events/mainline/timer.h b/drivers/staging/lttng/instrumentation/events/mainline/timer.h
new file mode 100644 (file)
index 0000000..425bcfe
--- /dev/null
@@ -0,0 +1,329 @@
+#undef TRACE_SYSTEM
+#define TRACE_SYSTEM timer
+
+#if !defined(_TRACE_TIMER_H) || defined(TRACE_HEADER_MULTI_READ)
+#define _TRACE_TIMER_H
+
+#include <linux/tracepoint.h>
+#include <linux/hrtimer.h>
+#include <linux/timer.h>
+
+DECLARE_EVENT_CLASS(timer_class,
+
+       TP_PROTO(struct timer_list *timer),
+
+       TP_ARGS(timer),
+
+       TP_STRUCT__entry(
+               __field( void *,        timer   )
+       ),
+
+       TP_fast_assign(
+               __entry->timer  = timer;
+       ),
+
+       TP_printk("timer=%p", __entry->timer)
+);
+
+/**
+ * timer_init - called when the timer is initialized
+ * @timer:     pointer to struct timer_list
+ */
+DEFINE_EVENT(timer_class, timer_init,
+
+       TP_PROTO(struct timer_list *timer),
+
+       TP_ARGS(timer)
+);
+
+/**
+ * timer_start - called when the timer is started
+ * @timer:     pointer to struct timer_list
+ * @expires:   the timers expiry time
+ */
+TRACE_EVENT(timer_start,
+
+       TP_PROTO(struct timer_list *timer, unsigned long expires),
+
+       TP_ARGS(timer, expires),
+
+       TP_STRUCT__entry(
+               __field( void *,        timer           )
+               __field( void *,        function        )
+               __field( unsigned long, expires         )
+               __field( unsigned long, now             )
+       ),
+
+       TP_fast_assign(
+               __entry->timer          = timer;
+               __entry->function       = timer->function;
+               __entry->expires        = expires;
+               __entry->now            = jiffies;
+       ),
+
+       TP_printk("timer=%p function=%pf expires=%lu [timeout=%ld]",
+                 __entry->timer, __entry->function, __entry->expires,
+                 (long)__entry->expires - __entry->now)
+);
+
+/**
+ * timer_expire_entry - called immediately before the timer callback
+ * @timer:     pointer to struct timer_list
+ *
+ * Allows to determine the timer latency.
+ */
+TRACE_EVENT(timer_expire_entry,
+
+       TP_PROTO(struct timer_list *timer),
+
+       TP_ARGS(timer),
+
+       TP_STRUCT__entry(
+               __field( void *,        timer   )
+               __field( unsigned long, now     )
+               __field( void *,        function)
+       ),
+
+       TP_fast_assign(
+               __entry->timer          = timer;
+               __entry->now            = jiffies;
+               __entry->function       = timer->function;
+       ),
+
+       TP_printk("timer=%p function=%pf now=%lu", __entry->timer, __entry->function,__entry->now)
+);
+
+/**
+ * timer_expire_exit - called immediately after the timer callback returns
+ * @timer:     pointer to struct timer_list
+ *
+ * When used in combination with the timer_expire_entry tracepoint we can
+ * determine the runtime of the timer callback function.
+ *
+ * NOTE: Do NOT derefernce timer in TP_fast_assign. The pointer might
+ * be invalid. We solely track the pointer.
+ */
+DEFINE_EVENT(timer_class, timer_expire_exit,
+
+       TP_PROTO(struct timer_list *timer),
+
+       TP_ARGS(timer)
+);
+
+/**
+ * timer_cancel - called when the timer is canceled
+ * @timer:     pointer to struct timer_list
+ */
+DEFINE_EVENT(timer_class, timer_cancel,
+
+       TP_PROTO(struct timer_list *timer),
+
+       TP_ARGS(timer)
+);
+
+/**
+ * hrtimer_init - called when the hrtimer is initialized
+ * @timer:     pointer to struct hrtimer
+ * @clockid:   the hrtimers clock
+ * @mode:      the hrtimers mode
+ */
+TRACE_EVENT(hrtimer_init,
+
+       TP_PROTO(struct hrtimer *hrtimer, clockid_t clockid,
+                enum hrtimer_mode mode),
+
+       TP_ARGS(hrtimer, clockid, mode),
+
+       TP_STRUCT__entry(
+               __field( void *,                hrtimer         )
+               __field( clockid_t,             clockid         )
+               __field( enum hrtimer_mode,     mode            )
+       ),
+
+       TP_fast_assign(
+               __entry->hrtimer        = hrtimer;
+               __entry->clockid        = clockid;
+               __entry->mode           = mode;
+       ),
+
+       TP_printk("hrtimer=%p clockid=%s mode=%s", __entry->hrtimer,
+                 __entry->clockid == CLOCK_REALTIME ?
+                       "CLOCK_REALTIME" : "CLOCK_MONOTONIC",
+                 __entry->mode == HRTIMER_MODE_ABS ?
+                       "HRTIMER_MODE_ABS" : "HRTIMER_MODE_REL")
+);
+
+/**
+ * hrtimer_start - called when the hrtimer is started
+ * @timer: pointer to struct hrtimer
+ */
+TRACE_EVENT(hrtimer_start,
+
+       TP_PROTO(struct hrtimer *hrtimer),
+
+       TP_ARGS(hrtimer),
+
+       TP_STRUCT__entry(
+               __field( void *,        hrtimer         )
+               __field( void *,        function        )
+               __field( s64,           expires         )
+               __field( s64,           softexpires     )
+       ),
+
+       TP_fast_assign(
+               __entry->hrtimer        = hrtimer;
+               __entry->function       = hrtimer->function;
+               __entry->expires        = hrtimer_get_expires(hrtimer).tv64;
+               __entry->softexpires    = hrtimer_get_softexpires(hrtimer).tv64;
+       ),
+
+       TP_printk("hrtimer=%p function=%pf expires=%llu softexpires=%llu",
+                 __entry->hrtimer, __entry->function,
+                 (unsigned long long)ktime_to_ns((ktime_t) {
+                                 .tv64 = __entry->expires }),
+                 (unsigned long long)ktime_to_ns((ktime_t) {
+                                 .tv64 = __entry->softexpires }))
+);
+
+/**
+ * htimmer_expire_entry - called immediately before the hrtimer callback
+ * @timer:     pointer to struct hrtimer
+ * @now:       pointer to variable which contains current time of the
+ *             timers base.
+ *
+ * Allows to determine the timer latency.
+ */
+TRACE_EVENT(hrtimer_expire_entry,
+
+       TP_PROTO(struct hrtimer *hrtimer, ktime_t *now),
+
+       TP_ARGS(hrtimer, now),
+
+       TP_STRUCT__entry(
+               __field( void *,        hrtimer )
+               __field( s64,           now     )
+               __field( void *,        function)
+       ),
+
+       TP_fast_assign(
+               __entry->hrtimer        = hrtimer;
+               __entry->now            = now->tv64;
+               __entry->function       = hrtimer->function;
+       ),
+
+       TP_printk("hrtimer=%p function=%pf now=%llu", __entry->hrtimer, __entry->function,
+                 (unsigned long long)ktime_to_ns((ktime_t) { .tv64 = __entry->now }))
+ );
+
+DECLARE_EVENT_CLASS(hrtimer_class,
+
+       TP_PROTO(struct hrtimer *hrtimer),
+
+       TP_ARGS(hrtimer),
+
+       TP_STRUCT__entry(
+               __field( void *,        hrtimer )
+       ),
+
+       TP_fast_assign(
+               __entry->hrtimer        = hrtimer;
+       ),
+
+       TP_printk("hrtimer=%p", __entry->hrtimer)
+);
+
+/**
+ * hrtimer_expire_exit - called immediately after the hrtimer callback returns
+ * @timer:     pointer to struct hrtimer
+ *
+ * When used in combination with the hrtimer_expire_entry tracepoint we can
+ * determine the runtime of the callback function.
+ */
+DEFINE_EVENT(hrtimer_class, hrtimer_expire_exit,
+
+       TP_PROTO(struct hrtimer *hrtimer),
+
+       TP_ARGS(hrtimer)
+);
+
+/**
+ * hrtimer_cancel - called when the hrtimer is canceled
+ * @hrtimer:   pointer to struct hrtimer
+ */
+DEFINE_EVENT(hrtimer_class, hrtimer_cancel,
+
+       TP_PROTO(struct hrtimer *hrtimer),
+
+       TP_ARGS(hrtimer)
+);
+
+/**
+ * itimer_state - called when itimer is started or canceled
+ * @which:     name of the interval timer
+ * @value:     the itimers value, itimer is canceled if value->it_value is
+ *             zero, otherwise it is started
+ * @expires:   the itimers expiry time
+ */
+TRACE_EVENT(itimer_state,
+
+       TP_PROTO(int which, const struct itimerval *const value,
+                cputime_t expires),
+
+       TP_ARGS(which, value, expires),
+
+       TP_STRUCT__entry(
+               __field(        int,            which           )
+               __field(        cputime_t,      expires         )
+               __field(        long,           value_sec       )
+               __field(        long,           value_usec      )
+               __field(        long,           interval_sec    )
+               __field(        long,           interval_usec   )
+       ),
+
+       TP_fast_assign(
+               __entry->which          = which;
+               __entry->expires        = expires;
+               __entry->value_sec      = value->it_value.tv_sec;
+               __entry->value_usec     = value->it_value.tv_usec;
+               __entry->interval_sec   = value->it_interval.tv_sec;
+               __entry->interval_usec  = value->it_interval.tv_usec;
+       ),
+
+       TP_printk("which=%d expires=%llu it_value=%ld.%ld it_interval=%ld.%ld",
+                 __entry->which, (unsigned long long)__entry->expires,
+                 __entry->value_sec, __entry->value_usec,
+                 __entry->interval_sec, __entry->interval_usec)
+);
+
+/**
+ * itimer_expire - called when itimer expires
+ * @which:     type of the interval timer
+ * @pid:       pid of the process which owns the timer
+ * @now:       current time, used to calculate the latency of itimer
+ */
+TRACE_EVENT(itimer_expire,
+
+       TP_PROTO(int which, struct pid *pid, cputime_t now),
+
+       TP_ARGS(which, pid, now),
+
+       TP_STRUCT__entry(
+               __field( int ,          which   )
+               __field( pid_t,         pid     )
+               __field( cputime_t,     now     )
+       ),
+
+       TP_fast_assign(
+               __entry->which  = which;
+               __entry->now    = now;
+               __entry->pid    = pid_nr(pid);
+       ),
+
+       TP_printk("which=%d pid=%d now=%llu", __entry->which,
+                 (int) __entry->pid, (unsigned long long)__entry->now)
+);
+
+#endif /*  _TRACE_TIMER_H */
+
+/* This part must be outside protection */
+#include <trace/define_trace.h>
diff --git a/drivers/staging/lttng/instrumentation/events/mainline/udp.h b/drivers/staging/lttng/instrumentation/events/mainline/udp.h
new file mode 100644 (file)
index 0000000..a664bb9
--- /dev/null
@@ -0,0 +1,32 @@
+#undef TRACE_SYSTEM
+#define TRACE_SYSTEM udp
+
+#if !defined(_TRACE_UDP_H) || defined(TRACE_HEADER_MULTI_READ)
+#define _TRACE_UDP_H
+
+#include <linux/udp.h>
+#include <linux/tracepoint.h>
+
+TRACE_EVENT(udp_fail_queue_rcv_skb,
+
+       TP_PROTO(int rc, struct sock *sk),
+
+       TP_ARGS(rc, sk),
+
+       TP_STRUCT__entry(
+               __field(int, rc)
+               __field(__u16, lport)
+       ),
+
+       TP_fast_assign(
+               __entry->rc = rc;
+               __entry->lport = inet_sk(sk)->inet_num;
+       ),
+
+       TP_printk("rc=%d port=%hu", __entry->rc, __entry->lport)
+);
+
+#endif /* _TRACE_UDP_H */
+
+/* This part must be outside protection */
+#include <trace/define_trace.h>
diff --git a/drivers/staging/lttng/instrumentation/events/mainline/vmscan.h b/drivers/staging/lttng/instrumentation/events/mainline/vmscan.h
new file mode 100644 (file)
index 0000000..63cfccc
--- /dev/null
@@ -0,0 +1,383 @@
+#undef TRACE_SYSTEM
+#define TRACE_SYSTEM vmscan
+
+#if !defined(_TRACE_VMSCAN_H) || defined(TRACE_HEADER_MULTI_READ)
+#define _TRACE_VMSCAN_H
+
+#include <linux/types.h>
+#include <linux/tracepoint.h>
+#include <linux/mm.h>
+#include <linux/memcontrol.h>
+#include <trace/events/gfpflags.h>
+
+#define RECLAIM_WB_ANON                0x0001u
+#define RECLAIM_WB_FILE                0x0002u
+#define RECLAIM_WB_MIXED       0x0010u
+#define RECLAIM_WB_SYNC                0x0004u /* Unused, all reclaim async */
+#define RECLAIM_WB_ASYNC       0x0008u
+
+#define show_reclaim_flags(flags)                              \
+       (flags) ? __print_flags(flags, "|",                     \
+               {RECLAIM_WB_ANON,       "RECLAIM_WB_ANON"},     \
+               {RECLAIM_WB_FILE,       "RECLAIM_WB_FILE"},     \
+               {RECLAIM_WB_MIXED,      "RECLAIM_WB_MIXED"},    \
+               {RECLAIM_WB_SYNC,       "RECLAIM_WB_SYNC"},     \
+               {RECLAIM_WB_ASYNC,      "RECLAIM_WB_ASYNC"}     \
+               ) : "RECLAIM_WB_NONE"
+
+#define trace_reclaim_flags(page) ( \
+       (page_is_file_cache(page) ? RECLAIM_WB_FILE : RECLAIM_WB_ANON) | \
+       (RECLAIM_WB_ASYNC) \
+       )
+
+#define trace_shrink_flags(file) \
+       ( \
+               (file ? RECLAIM_WB_FILE : RECLAIM_WB_ANON) | \
+               (RECLAIM_WB_ASYNC) \
+       )
+
+TRACE_EVENT(mm_vmscan_kswapd_sleep,
+
+       TP_PROTO(int nid),
+
+       TP_ARGS(nid),
+
+       TP_STRUCT__entry(
+               __field(        int,    nid     )
+       ),
+
+       TP_fast_assign(
+               __entry->nid    = nid;
+       ),
+
+       TP_printk("nid=%d", __entry->nid)
+);
+
+TRACE_EVENT(mm_vmscan_kswapd_wake,
+
+       TP_PROTO(int nid, int order),
+
+       TP_ARGS(nid, order),
+
+       TP_STRUCT__entry(
+               __field(        int,    nid     )
+               __field(        int,    order   )
+       ),
+
+       TP_fast_assign(
+               __entry->nid    = nid;
+               __entry->order  = order;
+       ),
+
+       TP_printk("nid=%d order=%d", __entry->nid, __entry->order)
+);
+
+TRACE_EVENT(mm_vmscan_wakeup_kswapd,
+
+       TP_PROTO(int nid, int zid, int order),
+
+       TP_ARGS(nid, zid, order),
+
+       TP_STRUCT__entry(
+               __field(        int,            nid     )
+               __field(        int,            zid     )
+               __field(        int,            order   )
+       ),
+
+       TP_fast_assign(
+               __entry->nid            = nid;
+               __entry->zid            = zid;
+               __entry->order          = order;
+       ),
+
+       TP_printk("nid=%d zid=%d order=%d",
+               __entry->nid,
+               __entry->zid,
+               __entry->order)
+);
+
+DECLARE_EVENT_CLASS(mm_vmscan_direct_reclaim_begin_template,
+
+       TP_PROTO(int order, int may_writepage, gfp_t gfp_flags),
+
+       TP_ARGS(order, may_writepage, gfp_flags),
+
+       TP_STRUCT__entry(
+               __field(        int,    order           )
+               __field(        int,    may_writepage   )
+               __field(        gfp_t,  gfp_flags       )
+       ),
+
+       TP_fast_assign(
+               __entry->order          = order;
+               __entry->may_writepage  = may_writepage;
+               __entry->gfp_flags      = gfp_flags;
+       ),
+
+       TP_printk("order=%d may_writepage=%d gfp_flags=%s",
+               __entry->order,
+               __entry->may_writepage,
+               show_gfp_flags(__entry->gfp_flags))
+);
+
+DEFINE_EVENT(mm_vmscan_direct_reclaim_begin_template, mm_vmscan_direct_reclaim_begin,
+
+       TP_PROTO(int order, int may_writepage, gfp_t gfp_flags),
+
+       TP_ARGS(order, may_writepage, gfp_flags)
+);
+
+DEFINE_EVENT(mm_vmscan_direct_reclaim_begin_template, mm_vmscan_memcg_reclaim_begin,
+
+       TP_PROTO(int order, int may_writepage, gfp_t gfp_flags),
+
+       TP_ARGS(order, may_writepage, gfp_flags)
+);
+
+DEFINE_EVENT(mm_vmscan_direct_reclaim_begin_template, mm_vmscan_memcg_softlimit_reclaim_begin,
+
+       TP_PROTO(int order, int may_writepage, gfp_t gfp_flags),
+
+       TP_ARGS(order, may_writepage, gfp_flags)
+);
+
+DECLARE_EVENT_CLASS(mm_vmscan_direct_reclaim_end_template,
+
+       TP_PROTO(unsigned long nr_reclaimed),
+
+       TP_ARGS(nr_reclaimed),
+
+       TP_STRUCT__entry(
+               __field(        unsigned long,  nr_reclaimed    )
+       ),
+
+       TP_fast_assign(
+               __entry->nr_reclaimed   = nr_reclaimed;
+       ),
+
+       TP_printk("nr_reclaimed=%lu", __entry->nr_reclaimed)
+);
+
+DEFINE_EVENT(mm_vmscan_direct_reclaim_end_template, mm_vmscan_direct_reclaim_end,
+
+       TP_PROTO(unsigned long nr_reclaimed),
+
+       TP_ARGS(nr_reclaimed)
+);
+
+DEFINE_EVENT(mm_vmscan_direct_reclaim_end_template, mm_vmscan_memcg_reclaim_end,
+
+       TP_PROTO(unsigned long nr_reclaimed),
+
+       TP_ARGS(nr_reclaimed)
+);
+
+DEFINE_EVENT(mm_vmscan_direct_reclaim_end_template, mm_vmscan_memcg_softlimit_reclaim_end,
+
+       TP_PROTO(unsigned long nr_reclaimed),
+
+       TP_ARGS(nr_reclaimed)
+);
+
+TRACE_EVENT(mm_shrink_slab_start,
+       TP_PROTO(struct shrinker *shr, struct shrink_control *sc,
+               long nr_objects_to_shrink, unsigned long pgs_scanned,
+               unsigned long lru_pgs, unsigned long cache_items,
+               unsigned long long delta, unsigned long total_scan),
+
+       TP_ARGS(shr, sc, nr_objects_to_shrink, pgs_scanned, lru_pgs,
+               cache_items, delta, total_scan),
+
+       TP_STRUCT__entry(
+               __field(struct shrinker *, shr)
+               __field(void *, shrink)
+               __field(long, nr_objects_to_shrink)
+               __field(gfp_t, gfp_flags)
+               __field(unsigned long, pgs_scanned)
+               __field(unsigned long, lru_pgs)
+               __field(unsigned long, cache_items)
+               __field(unsigned long long, delta)
+               __field(unsigned long, total_scan)
+       ),
+
+       TP_fast_assign(
+               __entry->shr = shr;
+               __entry->shrink = shr->shrink;
+               __entry->nr_objects_to_shrink = nr_objects_to_shrink;
+               __entry->gfp_flags = sc->gfp_mask;
+               __entry->pgs_scanned = pgs_scanned;
+               __entry->lru_pgs = lru_pgs;
+               __entry->cache_items = cache_items;
+               __entry->delta = delta;
+               __entry->total_scan = total_scan;
+       ),
+
+       TP_printk("%pF %p: objects to shrink %ld gfp_flags %s pgs_scanned %ld lru_pgs %ld cache items %ld delta %lld total_scan %ld",
+               __entry->shrink,
+               __entry->shr,
+               __entry->nr_objects_to_shrink,
+               show_gfp_flags(__entry->gfp_flags),
+               __entry->pgs_scanned,
+               __entry->lru_pgs,
+               __entry->cache_items,
+               __entry->delta,
+               __entry->total_scan)
+);
+
+TRACE_EVENT(mm_shrink_slab_end,
+       TP_PROTO(struct shrinker *shr, int shrinker_retval,
+               long unused_scan_cnt, long new_scan_cnt),
+
+       TP_ARGS(shr, shrinker_retval, unused_scan_cnt, new_scan_cnt),
+
+       TP_STRUCT__entry(
+               __field(struct shrinker *, shr)
+               __field(void *, shrink)
+               __field(long, unused_scan)
+               __field(long, new_scan)
+               __field(int, retval)
+               __field(long, total_scan)
+       ),
+
+       TP_fast_assign(
+               __entry->shr = shr;
+               __entry->shrink = shr->shrink;
+               __entry->unused_scan = unused_scan_cnt;
+               __entry->new_scan = new_scan_cnt;
+               __entry->retval = shrinker_retval;
+               __entry->total_scan = new_scan_cnt - unused_scan_cnt;
+       ),
+
+       TP_printk("%pF %p: unused scan count %ld new scan count %ld total_scan %ld last shrinker return val %d",
+               __entry->shrink,
+               __entry->shr,
+               __entry->unused_scan,
+               __entry->new_scan,
+               __entry->total_scan,
+               __entry->retval)
+);
+
+DECLARE_EVENT_CLASS(mm_vmscan_lru_isolate_template,
+
+       TP_PROTO(int order,
+               unsigned long nr_requested,
+               unsigned long nr_scanned,
+               unsigned long nr_taken,
+               isolate_mode_t isolate_mode,
+               int file),
+
+       TP_ARGS(order, nr_requested, nr_scanned, nr_taken, isolate_mode, file),
+
+       TP_STRUCT__entry(
+               __field(int, order)
+               __field(unsigned long, nr_requested)
+               __field(unsigned long, nr_scanned)
+               __field(unsigned long, nr_taken)
+               __field(isolate_mode_t, isolate_mode)
+               __field(int, file)
+       ),
+
+       TP_fast_assign(
+               __entry->order = order;
+               __entry->nr_requested = nr_requested;
+               __entry->nr_scanned = nr_scanned;
+               __entry->nr_taken = nr_taken;
+               __entry->isolate_mode = isolate_mode;
+               __entry->file = file;
+       ),
+
+       TP_printk("isolate_mode=%d order=%d nr_requested=%lu nr_scanned=%lu nr_taken=%lu file=%d",
+               __entry->isolate_mode,
+               __entry->order,
+               __entry->nr_requested,
+               __entry->nr_scanned,
+               __entry->nr_taken,
+               __entry->file)
+);
+
+DEFINE_EVENT(mm_vmscan_lru_isolate_template, mm_vmscan_lru_isolate,
+
+       TP_PROTO(int order,
+               unsigned long nr_requested,
+               unsigned long nr_scanned,
+               unsigned long nr_taken,
+               isolate_mode_t isolate_mode,
+               int file),
+
+       TP_ARGS(order, nr_requested, nr_scanned, nr_taken, isolate_mode, file)
+
+);
+
+DEFINE_EVENT(mm_vmscan_lru_isolate_template, mm_vmscan_memcg_isolate,
+
+       TP_PROTO(int order,
+               unsigned long nr_requested,
+               unsigned long nr_scanned,
+               unsigned long nr_taken,
+               isolate_mode_t isolate_mode,
+               int file),
+
+       TP_ARGS(order, nr_requested, nr_scanned, nr_taken, isolate_mode, file)
+
+);
+
+TRACE_EVENT(mm_vmscan_writepage,
+
+       TP_PROTO(struct page *page,
+               int reclaim_flags),
+
+       TP_ARGS(page, reclaim_flags),
+
+       TP_STRUCT__entry(
+               __field(struct page *, page)
+               __field(int, reclaim_flags)
+       ),
+
+       TP_fast_assign(
+               __entry->page = page;
+               __entry->reclaim_flags = reclaim_flags;
+       ),
+
+       TP_printk("page=%p pfn=%lu flags=%s",
+               __entry->page,
+               page_to_pfn(__entry->page),
+               show_reclaim_flags(__entry->reclaim_flags))
+);
+
+TRACE_EVENT(mm_vmscan_lru_shrink_inactive,
+
+       TP_PROTO(int nid, int zid,
+                       unsigned long nr_scanned, unsigned long nr_reclaimed,
+                       int priority, int reclaim_flags),
+
+       TP_ARGS(nid, zid, nr_scanned, nr_reclaimed, priority, reclaim_flags),
+
+       TP_STRUCT__entry(
+               __field(int, nid)
+               __field(int, zid)
+               __field(unsigned long, nr_scanned)
+               __field(unsigned long, nr_reclaimed)
+               __field(int, priority)
+               __field(int, reclaim_flags)
+       ),
+
+       TP_fast_assign(
+               __entry->nid = nid;
+               __entry->zid = zid;
+               __entry->nr_scanned = nr_scanned;
+               __entry->nr_reclaimed = nr_reclaimed;
+               __entry->priority = priority;
+               __entry->reclaim_flags = reclaim_flags;
+       ),
+
+       TP_printk("nid=%d zid=%d nr_scanned=%ld nr_reclaimed=%ld priority=%d flags=%s",
+               __entry->nid, __entry->zid,
+               __entry->nr_scanned, __entry->nr_reclaimed,
+               __entry->priority,
+               show_reclaim_flags(__entry->reclaim_flags))
+);
+
+#endif /* _TRACE_VMSCAN_H */
+
+/* This part must be outside protection */
+#include <trace/define_trace.h>
diff --git a/drivers/staging/lttng/instrumentation/events/mainline/workqueue.h b/drivers/staging/lttng/instrumentation/events/mainline/workqueue.h
new file mode 100644 (file)
index 0000000..f28d1b6
--- /dev/null
@@ -0,0 +1,121 @@
+#undef TRACE_SYSTEM
+#define TRACE_SYSTEM workqueue
+
+#if !defined(_TRACE_WORKQUEUE_H) || defined(TRACE_HEADER_MULTI_READ)
+#define _TRACE_WORKQUEUE_H
+
+#include <linux/tracepoint.h>
+#include <linux/workqueue.h>
+
+DECLARE_EVENT_CLASS(workqueue_work,
+
+       TP_PROTO(struct work_struct *work),
+
+       TP_ARGS(work),
+
+       TP_STRUCT__entry(
+               __field( void *,        work    )
+       ),
+
+       TP_fast_assign(
+               __entry->work           = work;
+       ),
+
+       TP_printk("work struct %p", __entry->work)
+);
+
+/**
+ * workqueue_queue_work - called when a work gets queued
+ * @req_cpu:   the requested cpu
+ * @cwq:       pointer to struct cpu_workqueue_struct
+ * @work:      pointer to struct work_struct
+ *
+ * This event occurs when a work is queued immediately or once a
+ * delayed work is actually queued on a workqueue (ie: once the delay
+ * has been reached).
+ */
+TRACE_EVENT(workqueue_queue_work,
+
+       TP_PROTO(unsigned int req_cpu, struct cpu_workqueue_struct *cwq,
+                struct work_struct *work),
+
+       TP_ARGS(req_cpu, cwq, work),
+
+       TP_STRUCT__entry(
+               __field( void *,        work    )
+               __field( void *,        function)
+               __field( void *,        workqueue)
+               __field( unsigned int,  req_cpu )
+               __field( unsigned int,  cpu     )
+       ),
+
+       TP_fast_assign(
+               __entry->work           = work;
+               __entry->function       = work->func;
+               __entry->workqueue      = cwq->wq;
+               __entry->req_cpu        = req_cpu;
+               __entry->cpu            = cwq->pool->gcwq->cpu;
+       ),
+
+       TP_printk("work struct=%p function=%pf workqueue=%p req_cpu=%u cpu=%u",
+                 __entry->work, __entry->function, __entry->workqueue,
+                 __entry->req_cpu, __entry->cpu)
+);
+
+/**
+ * workqueue_activate_work - called when a work gets activated
+ * @work:      pointer to struct work_struct
+ *
+ * This event occurs when a queued work is put on the active queue,
+ * which happens immediately after queueing unless @max_active limit
+ * is reached.
+ */
+DEFINE_EVENT(workqueue_work, workqueue_activate_work,
+
+       TP_PROTO(struct work_struct *work),
+
+       TP_ARGS(work)
+);
+
+/**
+ * workqueue_execute_start - called immediately before the workqueue callback
+ * @work:      pointer to struct work_struct
+ *
+ * Allows to track workqueue execution.
+ */
+TRACE_EVENT(workqueue_execute_start,
+
+       TP_PROTO(struct work_struct *work),
+
+       TP_ARGS(work),
+
+       TP_STRUCT__entry(
+               __field( void *,        work    )
+               __field( void *,        function)
+       ),
+
+       TP_fast_assign(
+               __entry->work           = work;
+               __entry->function       = work->func;
+       ),
+
+       TP_printk("work struct %p: function %pf", __entry->work, __entry->function)
+);
+
+/**
+ * workqueue_execute_end - called immediately after the workqueue callback
+ * @work:      pointer to struct work_struct
+ *
+ * Allows to track workqueue execution.
+ */
+DEFINE_EVENT(workqueue_work, workqueue_execute_end,
+
+       TP_PROTO(struct work_struct *work),
+
+       TP_ARGS(work)
+);
+
+#endif /*  _TRACE_WORKQUEUE_H */
+
+/* This part must be outside protection */
+#include <trace/define_trace.h>
diff --git a/drivers/staging/lttng/instrumentation/events/mainline/writeback.h b/drivers/staging/lttng/instrumentation/events/mainline/writeback.h
new file mode 100644 (file)
index 0000000..b453d92
--- /dev/null
@@ -0,0 +1,492 @@
+#undef TRACE_SYSTEM
+#define TRACE_SYSTEM writeback
+
+#if !defined(_TRACE_WRITEBACK_H) || defined(TRACE_HEADER_MULTI_READ)
+#define _TRACE_WRITEBACK_H
+
+#include <linux/backing-dev.h>
+#include <linux/writeback.h>
+
+#define show_inode_state(state)                                        \
+       __print_flags(state, "|",                               \
+               {I_DIRTY_SYNC,          "I_DIRTY_SYNC"},        \
+               {I_DIRTY_DATASYNC,      "I_DIRTY_DATASYNC"},    \
+               {I_DIRTY_PAGES,         "I_DIRTY_PAGES"},       \
+               {I_NEW,                 "I_NEW"},               \
+               {I_WILL_FREE,           "I_WILL_FREE"},         \
+               {I_FREEING,             "I_FREEING"},           \
+               {I_CLEAR,               "I_CLEAR"},             \
+               {I_SYNC,                "I_SYNC"},              \
+               {I_REFERENCED,          "I_REFERENCED"}         \
+       )
+
+#define WB_WORK_REASON                                                 \
+               {WB_REASON_BACKGROUND,          "background"},          \
+               {WB_REASON_TRY_TO_FREE_PAGES,   "try_to_free_pages"},   \
+               {WB_REASON_SYNC,                "sync"},                \
+               {WB_REASON_PERIODIC,            "periodic"},            \
+               {WB_REASON_LAPTOP_TIMER,        "laptop_timer"},        \
+               {WB_REASON_FREE_MORE_MEM,       "free_more_memory"},    \
+               {WB_REASON_FS_FREE_SPACE,       "fs_free_space"},       \
+               {WB_REASON_FORKER_THREAD,       "forker_thread"}
+
+struct wb_writeback_work;
+
+DECLARE_EVENT_CLASS(writeback_work_class,
+       TP_PROTO(struct backing_dev_info *bdi, struct wb_writeback_work *work),
+       TP_ARGS(bdi, work),
+       TP_STRUCT__entry(
+               __array(char, name, 32)
+               __field(long, nr_pages)
+               __field(dev_t, sb_dev)
+               __field(int, sync_mode)
+               __field(int, for_kupdate)
+               __field(int, range_cyclic)
+               __field(int, for_background)
+               __field(int, reason)
+       ),
+       TP_fast_assign(
+               struct device *dev = bdi->dev;
+               if (!dev)
+                       dev = default_backing_dev_info.dev;
+               strncpy(__entry->name, dev_name(dev), 32);
+               __entry->nr_pages = work->nr_pages;
+               __entry->sb_dev = work->sb ? work->sb->s_dev : 0;
+               __entry->sync_mode = work->sync_mode;
+               __entry->for_kupdate = work->for_kupdate;
+               __entry->range_cyclic = work->range_cyclic;
+               __entry->for_background = work->for_background;
+               __entry->reason = work->reason;
+       ),
+       TP_printk("bdi %s: sb_dev %d:%d nr_pages=%ld sync_mode=%d "
+                 "kupdate=%d range_cyclic=%d background=%d reason=%s",
+                 __entry->name,
+                 MAJOR(__entry->sb_dev), MINOR(__entry->sb_dev),
+                 __entry->nr_pages,
+                 __entry->sync_mode,
+                 __entry->for_kupdate,
+                 __entry->range_cyclic,
+                 __entry->for_background,
+                 __print_symbolic(__entry->reason, WB_WORK_REASON)
+       )
+);
+#define DEFINE_WRITEBACK_WORK_EVENT(name) \
+DEFINE_EVENT(writeback_work_class, name, \
+       TP_PROTO(struct backing_dev_info *bdi, struct wb_writeback_work *work), \
+       TP_ARGS(bdi, work))
+DEFINE_WRITEBACK_WORK_EVENT(writeback_nothread);
+DEFINE_WRITEBACK_WORK_EVENT(writeback_queue);
+DEFINE_WRITEBACK_WORK_EVENT(writeback_exec);
+DEFINE_WRITEBACK_WORK_EVENT(writeback_start);
+DEFINE_WRITEBACK_WORK_EVENT(writeback_written);
+DEFINE_WRITEBACK_WORK_EVENT(writeback_wait);
+
+TRACE_EVENT(writeback_pages_written,
+       TP_PROTO(long pages_written),
+       TP_ARGS(pages_written),
+       TP_STRUCT__entry(
+               __field(long,           pages)
+       ),
+       TP_fast_assign(
+               __entry->pages          = pages_written;
+       ),
+       TP_printk("%ld", __entry->pages)
+);
+
+DECLARE_EVENT_CLASS(writeback_class,
+       TP_PROTO(struct backing_dev_info *bdi),
+       TP_ARGS(bdi),
+       TP_STRUCT__entry(
+               __array(char, name, 32)
+       ),
+       TP_fast_assign(
+               strncpy(__entry->name, dev_name(bdi->dev), 32);
+       ),
+       TP_printk("bdi %s",
+                 __entry->name
+       )
+);
+#define DEFINE_WRITEBACK_EVENT(name) \
+DEFINE_EVENT(writeback_class, name, \
+       TP_PROTO(struct backing_dev_info *bdi), \
+       TP_ARGS(bdi))
+
+DEFINE_WRITEBACK_EVENT(writeback_nowork);
+DEFINE_WRITEBACK_EVENT(writeback_wake_background);
+DEFINE_WRITEBACK_EVENT(writeback_wake_thread);
+DEFINE_WRITEBACK_EVENT(writeback_wake_forker_thread);
+DEFINE_WRITEBACK_EVENT(writeback_bdi_register);
+DEFINE_WRITEBACK_EVENT(writeback_bdi_unregister);
+DEFINE_WRITEBACK_EVENT(writeback_thread_start);
+DEFINE_WRITEBACK_EVENT(writeback_thread_stop);
+
+DECLARE_EVENT_CLASS(wbc_class,
+       TP_PROTO(struct writeback_control *wbc, struct backing_dev_info *bdi),
+       TP_ARGS(wbc, bdi),
+       TP_STRUCT__entry(
+               __array(char, name, 32)
+               __field(long, nr_to_write)
+               __field(long, pages_skipped)
+               __field(int, sync_mode)
+               __field(int, for_kupdate)
+               __field(int, for_background)
+               __field(int, for_reclaim)
+               __field(int, range_cyclic)
+               __field(long, range_start)
+               __field(long, range_end)
+       ),
+
+       TP_fast_assign(
+               strncpy(__entry->name, dev_name(bdi->dev), 32);
+               __entry->nr_to_write    = wbc->nr_to_write;
+               __entry->pages_skipped  = wbc->pages_skipped;
+               __entry->sync_mode      = wbc->sync_mode;
+               __entry->for_kupdate    = wbc->for_kupdate;
+               __entry->for_background = wbc->for_background;
+               __entry->for_reclaim    = wbc->for_reclaim;
+               __entry->range_cyclic   = wbc->range_cyclic;
+               __entry->range_start    = (long)wbc->range_start;
+               __entry->range_end      = (long)wbc->range_end;
+       ),
+
+       TP_printk("bdi %s: towrt=%ld skip=%ld mode=%d kupd=%d "
+               "bgrd=%d reclm=%d cyclic=%d "
+               "start=0x%lx end=0x%lx",
+               __entry->name,
+               __entry->nr_to_write,
+               __entry->pages_skipped,
+               __entry->sync_mode,
+               __entry->for_kupdate,
+               __entry->for_background,
+               __entry->for_reclaim,
+               __entry->range_cyclic,
+               __entry->range_start,
+               __entry->range_end)
+)
+
+#define DEFINE_WBC_EVENT(name) \
+DEFINE_EVENT(wbc_class, name, \
+       TP_PROTO(struct writeback_control *wbc, struct backing_dev_info *bdi), \
+       TP_ARGS(wbc, bdi))
+DEFINE_WBC_EVENT(wbc_writepage);
+
+TRACE_EVENT(writeback_queue_io,
+       TP_PROTO(struct bdi_writeback *wb,
+                struct wb_writeback_work *work,
+                int moved),
+       TP_ARGS(wb, work, moved),
+       TP_STRUCT__entry(
+               __array(char,           name, 32)
+               __field(unsigned long,  older)
+               __field(long,           age)
+               __field(int,            moved)
+               __field(int,            reason)
+       ),
+       TP_fast_assign(
+               unsigned long *older_than_this = work->older_than_this;
+               strncpy(__entry->name, dev_name(wb->bdi->dev), 32);
+               __entry->older  = older_than_this ?  *older_than_this : 0;
+               __entry->age    = older_than_this ?
+                                 (jiffies - *older_than_this) * 1000 / HZ : -1;
+               __entry->moved  = moved;
+               __entry->reason = work->reason;
+       ),
+       TP_printk("bdi %s: older=%lu age=%ld enqueue=%d reason=%s",
+               __entry->name,
+               __entry->older, /* older_than_this in jiffies */
+               __entry->age,   /* older_than_this in relative milliseconds */
+               __entry->moved,
+               __print_symbolic(__entry->reason, WB_WORK_REASON)
+       )
+);
+
+TRACE_EVENT(global_dirty_state,
+
+       TP_PROTO(unsigned long background_thresh,
+                unsigned long dirty_thresh
+       ),
+
+       TP_ARGS(background_thresh,
+               dirty_thresh
+       ),
+
+       TP_STRUCT__entry(
+               __field(unsigned long,  nr_dirty)
+               __field(unsigned long,  nr_writeback)
+               __field(unsigned long,  nr_unstable)
+               __field(unsigned long,  background_thresh)
+               __field(unsigned long,  dirty_thresh)
+               __field(unsigned long,  dirty_limit)
+               __field(unsigned long,  nr_dirtied)
+               __field(unsigned long,  nr_written)
+       ),
+
+       TP_fast_assign(
+               __entry->nr_dirty       = global_page_state(NR_FILE_DIRTY);
+               __entry->nr_writeback   = global_page_state(NR_WRITEBACK);
+               __entry->nr_unstable    = global_page_state(NR_UNSTABLE_NFS);
+               __entry->nr_dirtied     = global_page_state(NR_DIRTIED);
+               __entry->nr_written     = global_page_state(NR_WRITTEN);
+               __entry->background_thresh = background_thresh;
+               __entry->dirty_thresh   = dirty_thresh;
+               __entry->dirty_limit = global_dirty_limit;
+       ),
+
+       TP_printk("dirty=%lu writeback=%lu unstable=%lu "
+                 "bg_thresh=%lu thresh=%lu limit=%lu "
+                 "dirtied=%lu written=%lu",
+                 __entry->nr_dirty,
+                 __entry->nr_writeback,
+                 __entry->nr_unstable,
+                 __entry->background_thresh,
+                 __entry->dirty_thresh,
+                 __entry->dirty_limit,
+                 __entry->nr_dirtied,
+                 __entry->nr_written
+       )
+);
+
+#define KBps(x)                        ((x) << (PAGE_SHIFT - 10))
+
+TRACE_EVENT(bdi_dirty_ratelimit,
+
+       TP_PROTO(struct backing_dev_info *bdi,
+                unsigned long dirty_rate,
+                unsigned long task_ratelimit),
+
+       TP_ARGS(bdi, dirty_rate, task_ratelimit),
+
+       TP_STRUCT__entry(
+               __array(char,           bdi, 32)
+               __field(unsigned long,  write_bw)
+               __field(unsigned long,  avg_write_bw)
+               __field(unsigned long,  dirty_rate)
+               __field(unsigned long,  dirty_ratelimit)
+               __field(unsigned long,  task_ratelimit)
+               __field(unsigned long,  balanced_dirty_ratelimit)
+       ),
+
+       TP_fast_assign(
+               strlcpy(__entry->bdi, dev_name(bdi->dev), 32);
+               __entry->write_bw       = KBps(bdi->write_bandwidth);
+               __entry->avg_write_bw   = KBps(bdi->avg_write_bandwidth);
+               __entry->dirty_rate     = KBps(dirty_rate);
+               __entry->dirty_ratelimit = KBps(bdi->dirty_ratelimit);
+               __entry->task_ratelimit = KBps(task_ratelimit);
+               __entry->balanced_dirty_ratelimit =
+                                         KBps(bdi->balanced_dirty_ratelimit);
+       ),
+
+       TP_printk("bdi %s: "
+                 "write_bw=%lu awrite_bw=%lu dirty_rate=%lu "
+                 "dirty_ratelimit=%lu task_ratelimit=%lu "
+                 "balanced_dirty_ratelimit=%lu",
+                 __entry->bdi,
+                 __entry->write_bw,            /* write bandwidth */
+                 __entry->avg_write_bw,        /* avg write bandwidth */
+                 __entry->dirty_rate,          /* bdi dirty rate */
+                 __entry->dirty_ratelimit,     /* base ratelimit */
+                 __entry->task_ratelimit, /* ratelimit with position control */
+                 __entry->balanced_dirty_ratelimit /* the balanced ratelimit */
+       )
+);
+
+TRACE_EVENT(balance_dirty_pages,
+
+       TP_PROTO(struct backing_dev_info *bdi,
+                unsigned long thresh,
+                unsigned long bg_thresh,
+                unsigned long dirty,
+                unsigned long bdi_thresh,
+                unsigned long bdi_dirty,
+                unsigned long dirty_ratelimit,
+                unsigned long task_ratelimit,
+                unsigned long dirtied,
+                unsigned long period,
+                long pause,
+                unsigned long start_time),
+
+       TP_ARGS(bdi, thresh, bg_thresh, dirty, bdi_thresh, bdi_dirty,
+               dirty_ratelimit, task_ratelimit,
+               dirtied, period, pause, start_time),
+
+       TP_STRUCT__entry(
+               __array(         char,  bdi, 32)
+               __field(unsigned long,  limit)
+               __field(unsigned long,  setpoint)
+               __field(unsigned long,  dirty)
+               __field(unsigned long,  bdi_setpoint)
+               __field(unsigned long,  bdi_dirty)
+               __field(unsigned long,  dirty_ratelimit)
+               __field(unsigned long,  task_ratelimit)
+               __field(unsigned int,   dirtied)
+               __field(unsigned int,   dirtied_pause)
+               __field(unsigned long,  paused)
+               __field(         long,  pause)
+               __field(unsigned long,  period)
+               __field(         long,  think)
+       ),
+
+       TP_fast_assign(
+               unsigned long freerun = (thresh + bg_thresh) / 2;
+               strlcpy(__entry->bdi, dev_name(bdi->dev), 32);
+
+               __entry->limit          = global_dirty_limit;
+               __entry->setpoint       = (global_dirty_limit + freerun) / 2;
+               __entry->dirty          = dirty;
+               __entry->bdi_setpoint   = __entry->setpoint *
+                                               bdi_thresh / (thresh + 1);
+               __entry->bdi_dirty      = bdi_dirty;
+               __entry->dirty_ratelimit = KBps(dirty_ratelimit);
+               __entry->task_ratelimit = KBps(task_ratelimit);
+               __entry->dirtied        = dirtied;
+               __entry->dirtied_pause  = current->nr_dirtied_pause;
+               __entry->think          = current->dirty_paused_when == 0 ? 0 :
+                        (long)(jiffies - current->dirty_paused_when) * 1000/HZ;
+               __entry->period         = period * 1000 / HZ;
+               __entry->pause          = pause * 1000 / HZ;
+               __entry->paused         = (jiffies - start_time) * 1000 / HZ;
+       ),
+
+
+       TP_printk("bdi %s: "
+                 "limit=%lu setpoint=%lu dirty=%lu "
+                 "bdi_setpoint=%lu bdi_dirty=%lu "
+                 "dirty_ratelimit=%lu task_ratelimit=%lu "
+                 "dirtied=%u dirtied_pause=%u "
+                 "paused=%lu pause=%ld period=%lu think=%ld",
+                 __entry->bdi,
+                 __entry->limit,
+                 __entry->setpoint,
+                 __entry->dirty,
+                 __entry->bdi_setpoint,
+                 __entry->bdi_dirty,
+                 __entry->dirty_ratelimit,
+                 __entry->task_ratelimit,
+                 __entry->dirtied,
+                 __entry->dirtied_pause,
+                 __entry->paused,      /* ms */
+                 __entry->pause,       /* ms */
+                 __entry->period,      /* ms */
+                 __entry->think        /* ms */
+         )
+);
+
+TRACE_EVENT(writeback_sb_inodes_requeue,
+
+       TP_PROTO(struct inode *inode),
+       TP_ARGS(inode),
+
+       TP_STRUCT__entry(
+               __array(char, name, 32)
+               __field(unsigned long, ino)
+               __field(unsigned long, state)
+               __field(unsigned long, dirtied_when)
+       ),
+
+       TP_fast_assign(
+               strncpy(__entry->name,
+                       dev_name(inode_to_bdi(inode)->dev), 32);
+               __entry->ino            = inode->i_ino;
+               __entry->state          = inode->i_state;
+               __entry->dirtied_when   = inode->dirtied_when;
+       ),
+
+       TP_printk("bdi %s: ino=%lu state=%s dirtied_when=%lu age=%lu",
+                 __entry->name,
+                 __entry->ino,
+                 show_inode_state(__entry->state),
+                 __entry->dirtied_when,
+                 (jiffies - __entry->dirtied_when) / HZ
+       )
+);
+
+DECLARE_EVENT_CLASS(writeback_congest_waited_template,
+
+       TP_PROTO(unsigned int usec_timeout, unsigned int usec_delayed),
+
+       TP_ARGS(usec_timeout, usec_delayed),
+
+       TP_STRUCT__entry(
+               __field(        unsigned int,   usec_timeout    )
+               __field(        unsigned int,   usec_delayed    )
+       ),
+
+       TP_fast_assign(
+               __entry->usec_timeout   = usec_timeout;
+               __entry->usec_delayed   = usec_delayed;
+       ),
+
+       TP_printk("usec_timeout=%u usec_delayed=%u",
+                       __entry->usec_timeout,
+                       __entry->usec_delayed)
+);
+
+DEFINE_EVENT(writeback_congest_waited_template, writeback_congestion_wait,
+
+       TP_PROTO(unsigned int usec_timeout, unsigned int usec_delayed),
+
+       TP_ARGS(usec_timeout, usec_delayed)
+);
+
+DEFINE_EVENT(writeback_congest_waited_template, writeback_wait_iff_congested,
+
+       TP_PROTO(unsigned int usec_timeout, unsigned int usec_delayed),
+
+       TP_ARGS(usec_timeout, usec_delayed)
+);
+
+DECLARE_EVENT_CLASS(writeback_single_inode_template,
+
+       TP_PROTO(struct inode *inode,
+                struct writeback_control *wbc,
+                unsigned long nr_to_write
+       ),
+
+       TP_ARGS(inode, wbc, nr_to_write),
+
+       TP_STRUCT__entry(
+               __array(char, name, 32)
+               __field(unsigned long, ino)
+               __field(unsigned long, state)
+               __field(unsigned long, dirtied_when)
+               __field(unsigned long, writeback_index)
+               __field(long, nr_to_write)
+               __field(unsigned long, wrote)
+       ),
+
+       TP_fast_assign(
+               strncpy(__entry->name,
+                       dev_name(inode_to_bdi(inode)->dev), 32);
+               __entry->ino            = inode->i_ino;
+               __entry->state          = inode->i_state;
+               __entry->dirtied_when   = inode->dirtied_when;
+               __entry->writeback_index = inode->i_mapping->writeback_index;
+               __entry->nr_to_write    = nr_to_write;
+               __entry->wrote          = nr_to_write - wbc->nr_to_write;
+       ),
+
+       TP_printk("bdi %s: ino=%lu state=%s dirtied_when=%lu age=%lu "
+                 "index=%lu to_write=%ld wrote=%lu",
+                 __entry->name,
+                 __entry->ino,
+                 show_inode_state(__entry->state),
+                 __entry->dirtied_when,
+                 (jiffies - __entry->dirtied_when) / HZ,
+                 __entry->writeback_index,
+                 __entry->nr_to_write,
+                 __entry->wrote
+       )
+);
+
+DEFINE_EVENT(writeback_single_inode_template, writeback_single_inode,
+       TP_PROTO(struct inode *inode,
+                struct writeback_control *wbc,
+                unsigned long nr_to_write),
+       TP_ARGS(inode, wbc, nr_to_write)
+);
+
+#endif /* _TRACE_WRITEBACK_H */
+
+/* This part must be outside protection */
+#include <trace/define_trace.h>
diff --git a/drivers/staging/lttng/instrumentation/syscalls/3.0.34/powerpc-32-syscalls-3.0.34 b/drivers/staging/lttng/instrumentation/syscalls/3.0.34/powerpc-32-syscalls-3.0.34
new file mode 100644 (file)
index 0000000..daad72d
--- /dev/null
@@ -0,0 +1,286 @@
+syscall sys_restart_syscall nr 0 nbargs 0 types: () args: ()
+syscall sys_exit nr 1 nbargs 1 types: (int) args: (error_code)
+syscall sys_read nr 3 nbargs 3 types: (unsigned int, char *, size_t) args: (fd, buf, count)
+syscall sys_write nr 4 nbargs 3 types: (unsigned int, const char *, size_t) args: (fd, buf, count)
+syscall sys_open nr 5 nbargs 3 types: (const char *, int, int) args: (filename, flags, mode)
+syscall sys_close nr 6 nbargs 1 types: (unsigned int) args: (fd)
+syscall sys_waitpid nr 7 nbargs 3 types: (pid_t, int *, int) args: (pid, stat_addr, options)
+syscall sys_creat nr 8 nbargs 2 types: (const char *, int) args: (pathname, mode)
+syscall sys_link nr 9 nbargs 2 types: (const char *, const char *) args: (oldname, newname)
+syscall sys_unlink nr 10 nbargs 1 types: (const char *) args: (pathname)
+syscall sys_chdir nr 12 nbargs 1 types: (const char *) args: (filename)
+syscall sys_time nr 13 nbargs 1 types: (time_t *) args: (tloc)
+syscall sys_mknod nr 14 nbargs 3 types: (const char *, int, unsigned) args: (filename, mode, dev)
+syscall sys_chmod nr 15 nbargs 2 types: (const char *, mode_t) args: (filename, mode)
+syscall sys_lchown nr 16 nbargs 3 types: (const char *, uid_t, gid_t) args: (filename, user, group)
+syscall sys_stat nr 18 nbargs 2 types: (const char *, struct __old_kernel_stat *) args: (filename, statbuf)
+syscall sys_lseek nr 19 nbargs 3 types: (unsigned int, off_t, unsigned int) args: (fd, offset, origin)
+syscall sys_getpid nr 20 nbargs 0 types: () args: ()
+syscall sys_mount nr 21 nbargs 5 types: (char *, char *, char *, unsigned long, void *) args: (dev_name, dir_name, type, flags, data)
+syscall sys_oldumount nr 22 nbargs 1 types: (char *) args: (name)
+syscall sys_setuid nr 23 nbargs 1 types: (uid_t) args: (uid)
+syscall sys_getuid nr 24 nbargs 0 types: () args: ()
+syscall sys_stime nr 25 nbargs 1 types: (time_t *) args: (tptr)
+syscall sys_ptrace nr 26 nbargs 4 types: (long, long, unsigned long, unsigned long) args: (request, pid, addr, data)
+syscall sys_alarm nr 27 nbargs 1 types: (unsigned int) args: (seconds)
+syscall sys_fstat nr 28 nbargs 2 types: (unsigned int, struct __old_kernel_stat *) args: (fd, statbuf)
+syscall sys_pause nr 29 nbargs 0 types: () args: ()
+syscall sys_utime nr 30 nbargs 2 types: (char *, struct utimbuf *) args: (filename, times)
+syscall sys_access nr 33 nbargs 2 types: (const char *, int) args: (filename, mode)
+syscall sys_nice nr 34 nbargs 1 types: (int) args: (increment)
+syscall sys_sync nr 36 nbargs 0 types: () args: ()
+syscall sys_kill nr 37 nbargs 2 types: (pid_t, int) args: (pid, sig)
+syscall sys_rename nr 38 nbargs 2 types: (const char *, const char *) args: (oldname, newname)
+syscall sys_mkdir nr 39 nbargs 2 types: (const char *, int) args: (pathname, mode)
+syscall sys_rmdir nr 40 nbargs 1 types: (const char *) args: (pathname)
+syscall sys_dup nr 41 nbargs 1 types: (unsigned int) args: (fildes)
+syscall sys_pipe nr 42 nbargs 1 types: (int *) args: (fildes)
+syscall sys_times nr 43 nbargs 1 types: (struct tms *) args: (tbuf)
+syscall sys_brk nr 45 nbargs 1 types: (unsigned long) args: (brk)
+syscall sys_setgid nr 46 nbargs 1 types: (gid_t) args: (gid)
+syscall sys_getgid nr 47 nbargs 0 types: () args: ()
+syscall sys_signal nr 48 nbargs 2 types: (int, __sighandler_t) args: (sig, handler)
+syscall sys_geteuid nr 49 nbargs 0 types: () args: ()
+syscall sys_getegid nr 50 nbargs 0 types: () args: ()
+syscall sys_acct nr 51 nbargs 1 types: (const char *) args: (name)
+syscall sys_umount nr 52 nbargs 2 types: (char *, int) args: (name, flags)
+syscall sys_ioctl nr 54 nbargs 3 types: (unsigned int, unsigned int, unsigned long) args: (fd, cmd, arg)
+syscall sys_fcntl nr 55 nbargs 3 types: (unsigned int, unsigned int, unsigned long) args: (fd, cmd, arg)
+syscall sys_setpgid nr 57 nbargs 2 types: (pid_t, pid_t) args: (pid, pgid)
+syscall sys_olduname nr 59 nbargs 1 types: (struct oldold_utsname *) args: (name)
+syscall sys_umask nr 60 nbargs 1 types: (int) args: (mask)
+syscall sys_chroot nr 61 nbargs 1 types: (const char *) args: (filename)
+syscall sys_ustat nr 62 nbargs 2 types: (unsigned, struct ustat *) args: (dev, ubuf)
+syscall sys_dup2 nr 63 nbargs 2 types: (unsigned int, unsigned int) args: (oldfd, newfd)
+syscall sys_getppid nr 64 nbargs 0 types: () args: ()
+syscall sys_getpgrp nr 65 nbargs 0 types: () args: ()
+syscall sys_setsid nr 66 nbargs 0 types: () args: ()
+syscall sys_sgetmask nr 68 nbargs 0 types: () args: ()
+syscall sys_ssetmask nr 69 nbargs 1 types: (int) args: (newmask)
+syscall sys_setreuid nr 70 nbargs 2 types: (uid_t, uid_t) args: (ruid, euid)
+syscall sys_setregid nr 71 nbargs 2 types: (gid_t, gid_t) args: (rgid, egid)
+syscall sys_sigpending nr 73 nbargs 1 types: (old_sigset_t *) args: (set)
+syscall sys_sethostname nr 74 nbargs 2 types: (char *, int) args: (name, len)
+syscall sys_setrlimit nr 75 nbargs 2 types: (unsigned int, struct rlimit *) args: (resource, rlim)
+syscall sys_old_getrlimit nr 76 nbargs 2 types: (unsigned int, struct rlimit *) args: (resource, rlim)
+syscall sys_getrusage nr 77 nbargs 2 types: (int, struct rusage *) args: (who, ru)
+syscall sys_gettimeofday nr 78 nbargs 2 types: (struct timeval *, struct timezone *) args: (tv, tz)
+syscall sys_settimeofday nr 79 nbargs 2 types: (struct timeval *, struct timezone *) args: (tv, tz)
+syscall sys_getgroups nr 80 nbargs 2 types: (int, gid_t *) args: (gidsetsize, grouplist)
+syscall sys_setgroups nr 81 nbargs 2 types: (int, gid_t *) args: (gidsetsize, grouplist)
+syscall sys_symlink nr 83 nbargs 2 types: (const char *, const char *) args: (oldname, newname)
+syscall sys_lstat nr 84 nbargs 2 types: (const char *, struct __old_kernel_stat *) args: (filename, statbuf)
+syscall sys_readlink nr 85 nbargs 3 types: (const char *, char *, int) args: (path, buf, bufsiz)
+syscall sys_uselib nr 86 nbargs 1 types: (const char *) args: (library)
+syscall sys_swapon nr 87 nbargs 2 types: (const char *, int) args: (specialfile, swap_flags)
+syscall sys_reboot nr 88 nbargs 4 types: (int, int, unsigned int, void *) args: (magic1, magic2, cmd, arg)
+syscall sys_old_readdir nr 89 nbargs 3 types: (unsigned int, struct old_linux_dirent *, unsigned int) args: (fd, dirent, count)
+syscall sys_munmap nr 91 nbargs 2 types: (unsigned long, size_t) args: (addr, len)
+syscall sys_truncate nr 92 nbargs 2 types: (const char *, long) args: (path, length)
+syscall sys_ftruncate nr 93 nbargs 2 types: (unsigned int, unsigned long) args: (fd, length)
+syscall sys_fchmod nr 94 nbargs 2 types: (unsigned int, mode_t) args: (fd, mode)
+syscall sys_fchown nr 95 nbargs 3 types: (unsigned int, uid_t, gid_t) args: (fd, user, group)
+syscall sys_getpriority nr 96 nbargs 2 types: (int, int) args: (which, who)
+syscall sys_setpriority nr 97 nbargs 3 types: (int, int, int) args: (which, who, niceval)
+syscall sys_statfs nr 99 nbargs 2 types: (const char *, struct statfs *) args: (pathname, buf)
+syscall sys_fstatfs nr 100 nbargs 2 types: (unsigned int, struct statfs *) args: (fd, buf)
+syscall sys_socketcall nr 102 nbargs 2 types: (int, unsigned long *) args: (call, args)
+syscall sys_syslog nr 103 nbargs 3 types: (int, char *, int) args: (type, buf, len)
+syscall sys_setitimer nr 104 nbargs 3 types: (int, struct itimerval *, struct itimerval *) args: (which, value, ovalue)
+syscall sys_getitimer nr 105 nbargs 2 types: (int, struct itimerval *) args: (which, value)
+syscall sys_newstat nr 106 nbargs 2 types: (const char *, struct stat *) args: (filename, statbuf)
+syscall sys_newlstat nr 107 nbargs 2 types: (const char *, struct stat *) args: (filename, statbuf)
+syscall sys_newfstat nr 108 nbargs 2 types: (unsigned int, struct stat *) args: (fd, statbuf)
+syscall sys_uname nr 109 nbargs 1 types: (struct old_utsname *) args: (name)
+syscall sys_vhangup nr 111 nbargs 0 types: () args: ()
+syscall sys_wait4 nr 114 nbargs 4 types: (pid_t, int *, int, struct rusage *) args: (upid, stat_addr, options, ru)
+syscall sys_swapoff nr 115 nbargs 1 types: (const char *) args: (specialfile)
+syscall sys_sysinfo nr 116 nbargs 1 types: (struct sysinfo *) args: (info)
+syscall sys_ipc nr 117 nbargs 6 types: (unsigned int, int, unsigned long, unsigned long, void *, long) args: (call, first, second, third, ptr, fifth)
+syscall sys_fsync nr 118 nbargs 1 types: (unsigned int) args: (fd)
+syscall sys_setdomainname nr 121 nbargs 2 types: (char *, int) args: (name, len)
+syscall sys_newuname nr 122 nbargs 1 types: (struct new_utsname *) args: (name)
+syscall sys_adjtimex nr 124 nbargs 1 types: (struct timex *) args: (txc_p)
+syscall sys_mprotect nr 125 nbargs 3 types: (unsigned long, size_t, unsigned long) args: (start, len, prot)
+syscall sys_sigprocmask nr 126 nbargs 3 types: (int, old_sigset_t *, old_sigset_t *) args: (how, nset, oset)
+syscall sys_init_module nr 128 nbargs 3 types: (void *, unsigned long, const char *) args: (umod, len, uargs)
+syscall sys_delete_module nr 129 nbargs 2 types: (const char *, unsigned int) args: (name_user, flags)
+syscall sys_getpgid nr 132 nbargs 1 types: (pid_t) args: (pid)
+syscall sys_fchdir nr 133 nbargs 1 types: (unsigned int) args: (fd)
+syscall sys_bdflush nr 134 nbargs 2 types: (int, long) args: (func, data)
+syscall sys_sysfs nr 135 nbargs 3 types: (int, unsigned long, unsigned long) args: (option, arg1, arg2)
+syscall sys_personality nr 136 nbargs 1 types: (unsigned int) args: (personality)
+syscall sys_setfsuid nr 138 nbargs 1 types: (uid_t) args: (uid)
+syscall sys_setfsgid nr 139 nbargs 1 types: (gid_t) args: (gid)
+syscall sys_llseek nr 140 nbargs 5 types: (unsigned int, unsigned long, unsigned long, loff_t *, unsigned int) args: (fd, offset_high, offset_low, result, origin)
+syscall sys_getdents nr 141 nbargs 3 types: (unsigned int, struct linux_dirent *, unsigned int) args: (fd, dirent, count)
+syscall sys_select nr 142 nbargs 5 types: (int, fd_set *, fd_set *, fd_set *, struct timeval *) args: (n, inp, outp, exp, tvp)
+syscall sys_flock nr 143 nbargs 2 types: (unsigned int, unsigned int) args: (fd, cmd)
+syscall sys_msync nr 144 nbargs 3 types: (unsigned long, size_t, int) args: (start, len, flags)
+syscall sys_readv nr 145 nbargs 3 types: (unsigned long, const struct iovec *, unsigned long) args: (fd, vec, vlen)
+syscall sys_writev nr 146 nbargs 3 types: (unsigned long, const struct iovec *, unsigned long) args: (fd, vec, vlen)
+syscall sys_getsid nr 147 nbargs 1 types: (pid_t) args: (pid)
+syscall sys_fdatasync nr 148 nbargs 1 types: (unsigned int) args: (fd)
+syscall sys_sysctl nr 149 nbargs 1 types: (struct __sysctl_args *) args: (args)
+syscall sys_mlock nr 150 nbargs 2 types: (unsigned long, size_t) args: (start, len)
+syscall sys_munlock nr 151 nbargs 2 types: (unsigned long, size_t) args: (start, len)
+syscall sys_mlockall nr 152 nbargs 1 types: (int) args: (flags)
+syscall sys_munlockall nr 153 nbargs 0 types: () args: ()
+syscall sys_sched_setparam nr 154 nbargs 2 types: (pid_t, struct sched_param *) args: (pid, param)
+syscall sys_sched_getparam nr 155 nbargs 2 types: (pid_t, struct sched_param *) args: (pid, param)
+syscall sys_sched_setscheduler nr 156 nbargs 3 types: (pid_t, int, struct sched_param *) args: (pid, policy, param)
+syscall sys_sched_getscheduler nr 157 nbargs 1 types: (pid_t) args: (pid)
+syscall sys_sched_yield nr 158 nbargs 0 types: () args: ()
+syscall sys_sched_get_priority_max nr 159 nbargs 1 types: (int) args: (policy)
+syscall sys_sched_get_priority_min nr 160 nbargs 1 types: (int) args: (policy)
+syscall sys_sched_rr_get_interval nr 161 nbargs 2 types: (pid_t, struct timespec *) args: (pid, interval)
+syscall sys_nanosleep nr 162 nbargs 2 types: (struct timespec *, struct timespec *) args: (rqtp, rmtp)
+syscall sys_mremap nr 163 nbargs 5 types: (unsigned long, unsigned long, unsigned long, unsigned long, unsigned long) args: (addr, old_len, new_len, flags, new_addr)
+syscall sys_setresuid nr 164 nbargs 3 types: (uid_t, uid_t, uid_t) args: (ruid, euid, suid)
+syscall sys_getresuid nr 165 nbargs 3 types: (uid_t *, uid_t *, uid_t *) args: (ruid, euid, suid)
+syscall sys_poll nr 167 nbargs 3 types: (struct pollfd *, unsigned int, long) args: (ufds, nfds, timeout_msecs)
+syscall sys_nfsservctl nr 168 nbargs 3 types: (int, struct nfsctl_arg *, void *) args: (cmd, arg, res)
+syscall sys_setresgid nr 169 nbargs 3 types: (gid_t, gid_t, gid_t) args: (rgid, egid, sgid)
+syscall sys_getresgid nr 170 nbargs 3 types: (gid_t *, gid_t *, gid_t *) args: (rgid, egid, sgid)
+syscall sys_prctl nr 171 nbargs 5 types: (int, unsigned long, unsigned long, unsigned long, unsigned long) args: (option, arg2, arg3, arg4, arg5)
+syscall sys_rt_sigaction nr 173 nbargs 4 types: (int, const struct sigaction *, struct sigaction *, size_t) args: (sig, act, oact, sigsetsize)
+syscall sys_rt_sigprocmask nr 174 nbargs 4 types: (int, sigset_t *, sigset_t *, size_t) args: (how, nset, oset, sigsetsize)
+syscall sys_rt_sigpending nr 175 nbargs 2 types: (sigset_t *, size_t) args: (set, sigsetsize)
+syscall sys_rt_sigtimedwait nr 176 nbargs 4 types: (const sigset_t *, siginfo_t *, const struct timespec *, size_t) args: (uthese, uinfo, uts, sigsetsize)
+syscall sys_rt_sigqueueinfo nr 177 nbargs 3 types: (pid_t, int, siginfo_t *) args: (pid, sig, uinfo)
+syscall sys_rt_sigsuspend nr 178 nbargs 2 types: (sigset_t *, size_t) args: (unewset, sigsetsize)
+syscall sys_chown nr 181 nbargs 3 types: (const char *, uid_t, gid_t) args: (filename, user, group)
+syscall sys_getcwd nr 182 nbargs 2 types: (char *, unsigned long) args: (buf, size)
+syscall sys_capget nr 183 nbargs 2 types: (cap_user_header_t, cap_user_data_t) args: (header, dataptr)
+syscall sys_capset nr 184 nbargs 2 types: (cap_user_header_t, const cap_user_data_t) args: (header, data)
+syscall sys_sendfile nr 186 nbargs 4 types: (int, int, off_t *, size_t) args: (out_fd, in_fd, offset, count)
+syscall sys_getrlimit nr 190 nbargs 2 types: (unsigned int, struct rlimit *) args: (resource, rlim)
+syscall sys_stat64 nr 195 nbargs 2 types: (const char *, struct stat64 *) args: (filename, statbuf)
+syscall sys_lstat64 nr 196 nbargs 2 types: (const char *, struct stat64 *) args: (filename, statbuf)
+syscall sys_fstat64 nr 197 nbargs 2 types: (unsigned long, struct stat64 *) args: (fd, statbuf)
+syscall sys_pciconfig_read nr 198 nbargs 5 types: (unsigned long, unsigned long, unsigned long, unsigned long, void *) args: (bus, dfn, off, len, buf)
+syscall sys_pciconfig_write nr 199 nbargs 5 types: (unsigned long, unsigned long, unsigned long, unsigned long, void *) args: (bus, dfn, off, len, buf)
+syscall sys_getdents64 nr 202 nbargs 3 types: (unsigned int, struct linux_dirent64 *, unsigned int) args: (fd, dirent, count)
+syscall sys_pivot_root nr 203 nbargs 2 types: (const char *, const char *) args: (new_root, put_old)
+syscall sys_fcntl64 nr 204 nbargs 3 types: (unsigned int, unsigned int, unsigned long) args: (fd, cmd, arg)
+syscall sys_madvise nr 205 nbargs 3 types: (unsigned long, size_t, int) args: (start, len_in, behavior)
+syscall sys_mincore nr 206 nbargs 3 types: (unsigned long, size_t, unsigned char *) args: (start, len, vec)
+syscall sys_gettid nr 207 nbargs 0 types: () args: ()
+syscall sys_tkill nr 208 nbargs 2 types: (pid_t, int) args: (pid, sig)
+syscall sys_setxattr nr 209 nbargs 5 types: (const char *, const char *, const void *, size_t, int) args: (pathname, name, value, size, flags)
+syscall sys_lsetxattr nr 210 nbargs 5 types: (const char *, const char *, const void *, size_t, int) args: (pathname, name, value, size, flags)
+syscall sys_fsetxattr nr 211 nbargs 5 types: (int, const char *, const void *, size_t, int) args: (fd, name, value, size, flags)
+syscall sys_getxattr nr 212 nbargs 4 types: (const char *, const char *, void *, size_t) args: (pathname, name, value, size)
+syscall sys_lgetxattr nr 213 nbargs 4 types: (const char *, const char *, void *, size_t) args: (pathname, name, value, size)
+syscall sys_fgetxattr nr 214 nbargs 4 types: (int, const char *, void *, size_t) args: (fd, name, value, size)
+syscall sys_listxattr nr 215 nbargs 3 types: (const char *, char *, size_t) args: (pathname, list, size)
+syscall sys_llistxattr nr 216 nbargs 3 types: (const char *, char *, size_t) args: (pathname, list, size)
+syscall sys_flistxattr nr 217 nbargs 3 types: (int, char *, size_t) args: (fd, list, size)
+syscall sys_removexattr nr 218 nbargs 2 types: (const char *, const char *) args: (pathname, name)
+syscall sys_lremovexattr nr 219 nbargs 2 types: (const char *, const char *) args: (pathname, name)
+syscall sys_fremovexattr nr 220 nbargs 2 types: (int, const char *) args: (fd, name)
+syscall sys_futex nr 221 nbargs 6 types: (u32 *, int, u32, struct timespec *, u32 *, u32) args: (uaddr, op, val, utime, uaddr2, val3)
+syscall sys_sched_setaffinity nr 222 nbargs 3 types: (pid_t, unsigned int, unsigned long *) args: (pid, len, user_mask_ptr)
+syscall sys_sched_getaffinity nr 223 nbargs 3 types: (pid_t, unsigned int, unsigned long *) args: (pid, len, user_mask_ptr)
+syscall sys_sendfile64 nr 226 nbargs 4 types: (int, int, loff_t *, size_t) args: (out_fd, in_fd, offset, count)
+syscall sys_io_setup nr 227 nbargs 2 types: (unsigned, aio_context_t *) args: (nr_events, ctxp)
+syscall sys_io_destroy nr 228 nbargs 1 types: (aio_context_t) args: (ctx)
+syscall sys_io_getevents nr 229 nbargs 5 types: (aio_context_t, long, long, struct io_event *, struct timespec *) args: (ctx_id, min_nr, nr, events, timeout)
+syscall sys_io_submit nr 230 nbargs 3 types: (aio_context_t, long, struct iocb * *) args: (ctx_id, nr, iocbpp)
+syscall sys_io_cancel nr 231 nbargs 3 types: (aio_context_t, struct iocb *, struct io_event *) args: (ctx_id, iocb, result)
+syscall sys_set_tid_address nr 232 nbargs 1 types: (int *) args: (tidptr)
+syscall sys_exit_group nr 234 nbargs 1 types: (int) args: (error_code)
+syscall sys_epoll_create nr 236 nbargs 1 types: (int) args: (size)
+syscall sys_epoll_ctl nr 237 nbargs 4 types: (int, int, int, struct epoll_event *) args: (epfd, op, fd, event)
+syscall sys_epoll_wait nr 238 nbargs 4 types: (int, struct epoll_event *, int, int) args: (epfd, events, maxevents, timeout)
+syscall sys_remap_file_pages nr 239 nbargs 5 types: (unsigned long, unsigned long, unsigned long, unsigned long, unsigned long) args: (start, size, prot, pgoff, flags)
+syscall sys_timer_create nr 240 nbargs 3 types: (const clockid_t, struct sigevent *, timer_t *) args: (which_clock, timer_event_spec, created_timer_id)
+syscall sys_timer_settime nr 241 nbargs 4 types: (timer_t, int, const struct itimerspec *, struct itimerspec *) args: (timer_id, flags, new_setting, old_setting)
+syscall sys_timer_gettime nr 242 nbargs 2 types: (timer_t, struct itimerspec *) args: (timer_id, setting)
+syscall sys_timer_getoverrun nr 243 nbargs 1 types: (timer_t) args: (timer_id)
+syscall sys_timer_delete nr 244 nbargs 1 types: (timer_t) args: (timer_id)
+syscall sys_clock_settime nr 245 nbargs 2 types: (const clockid_t, const struct timespec *) args: (which_clock, tp)
+syscall sys_clock_gettime nr 246 nbargs 2 types: (const clockid_t, struct timespec *) args: (which_clock, tp)
+syscall sys_clock_getres nr 247 nbargs 2 types: (const clockid_t, struct timespec *) args: (which_clock, tp)
+syscall sys_clock_nanosleep nr 248 nbargs 4 types: (const clockid_t, int, const struct timespec *, struct timespec *) args: (which_clock, flags, rqtp, rmtp)
+syscall sys_tgkill nr 250 nbargs 3 types: (pid_t, pid_t, int) args: (tgid, pid, sig)
+syscall sys_utimes nr 251 nbargs 2 types: (char *, struct timeval *) args: (filename, utimes)
+syscall sys_statfs64 nr 252 nbargs 3 types: (const char *, size_t, struct statfs64 *) args: (pathname, sz, buf)
+syscall sys_fstatfs64 nr 253 nbargs 3 types: (unsigned int, size_t, struct statfs64 *) args: (fd, sz, buf)
+syscall sys_mq_open nr 262 nbargs 4 types: (const char *, int, mode_t, struct mq_attr *) args: (u_name, oflag, mode, u_attr)
+syscall sys_mq_unlink nr 263 nbargs 1 types: (const char *) args: (u_name)
+syscall sys_mq_timedsend nr 264 nbargs 5 types: (mqd_t, const char *, size_t, unsigned int, const struct timespec *) args: (mqdes, u_msg_ptr, msg_len, msg_prio, u_abs_timeout)
+syscall sys_mq_timedreceive nr 265 nbargs 5 types: (mqd_t, char *, size_t, unsigned int *, const struct timespec *) args: (mqdes, u_msg_ptr, msg_len, u_msg_prio, u_abs_timeout)
+syscall sys_mq_notify nr 266 nbargs 2 types: (mqd_t, const struct sigevent *) args: (mqdes, u_notification)
+syscall sys_mq_getsetattr nr 267 nbargs 3 types: (mqd_t, const struct mq_attr *, struct mq_attr *) args: (mqdes, u_mqstat, u_omqstat)
+syscall sys_add_key nr 269 nbargs 5 types: (const char *, const char *, const void *, size_t, key_serial_t) args: (_type, _description, _payload, plen, ringid)
+syscall sys_request_key nr 270 nbargs 4 types: (const char *, const char *, const char *, key_serial_t) args: (_type, _description, _callout_info, destringid)
+syscall sys_keyctl nr 271 nbargs 5 types: (int, unsigned long, unsigned long, unsigned long, unsigned long) args: (option, arg2, arg3, arg4, arg5)
+syscall sys_waitid nr 272 nbargs 5 types: (int, pid_t, struct siginfo *, int, struct rusage *) args: (which, upid, infop, options, ru)
+syscall sys_ioprio_set nr 273 nbargs 3 types: (int, int, int) args: (which, who, ioprio)
+syscall sys_ioprio_get nr 274 nbargs 2 types: (int, int) args: (which, who)
+syscall sys_inotify_init nr 275 nbargs 0 types: () args: ()
+syscall sys_inotify_add_watch nr 276 nbargs 3 types: (int, const char *, u32) args: (fd, pathname, mask)
+syscall sys_inotify_rm_watch nr 277 nbargs 2 types: (int, __s32) args: (fd, wd)
+syscall sys_pselect6 nr 280 nbargs 6 types: (int, fd_set *, fd_set *, fd_set *, struct timespec *, void *) args: (n, inp, outp, exp, tsp, sig)
+syscall sys_ppoll nr 281 nbargs 5 types: (struct pollfd *, unsigned int, struct timespec *, const sigset_t *, size_t) args: (ufds, nfds, tsp, sigmask, sigsetsize)
+syscall sys_unshare nr 282 nbargs 1 types: (unsigned long) args: (unshare_flags)
+syscall sys_splice nr 283 nbargs 6 types: (int, loff_t *, int, loff_t *, size_t, unsigned int) args: (fd_in, off_in, fd_out, off_out, len, flags)
+syscall sys_tee nr 284 nbargs 4 types: (int, int, size_t, unsigned int) args: (fdin, fdout, len, flags)
+syscall sys_vmsplice nr 285 nbargs 4 types: (int, const struct iovec *, unsigned long, unsigned int) args: (fd, iov, nr_segs, flags)
+syscall sys_openat nr 286 nbargs 4 types: (int, const char *, int, int) args: (dfd, filename, flags, mode)
+syscall sys_mkdirat nr 287 nbargs 3 types: (int, const char *, int) args: (dfd, pathname, mode)
+syscall sys_mknodat nr 288 nbargs 4 types: (int, const char *, int, unsigned) args: (dfd, filename, mode, dev)
+syscall sys_fchownat nr 289 nbargs 5 types: (int, const char *, uid_t, gid_t, int) args: (dfd, filename, user, group, flag)
+syscall sys_futimesat nr 290 nbargs 3 types: (int, const char *, struct timeval *) args: (dfd, filename, utimes)
+syscall sys_fstatat64 nr 291 nbargs 4 types: (int, const char *, struct stat64 *, int) args: (dfd, filename, statbuf, flag)
+syscall sys_unlinkat nr 292 nbargs 3 types: (int, const char *, int) args: (dfd, pathname, flag)
+syscall sys_renameat nr 293 nbargs 4 types: (int, const char *, int, const char *) args: (olddfd, oldname, newdfd, newname)
+syscall sys_linkat nr 294 nbargs 5 types: (int, const char *, int, const char *, int) args: (olddfd, oldname, newdfd, newname, flags)
+syscall sys_symlinkat nr 295 nbargs 3 types: (const char *, int, const char *) args: (oldname, newdfd, newname)
+syscall sys_readlinkat nr 296 nbargs 4 types: (int, const char *, char *, int) args: (dfd, pathname, buf, bufsiz)
+syscall sys_fchmodat nr 297 nbargs 3 types: (int, const char *, mode_t) args: (dfd, filename, mode)
+syscall sys_faccessat nr 298 nbargs 3 types: (int, const char *, int) args: (dfd, filename, mode)
+syscall sys_get_robust_list nr 299 nbargs 3 types: (int, struct robust_list_head * *, size_t *) args: (pid, head_ptr, len_ptr)
+syscall sys_set_robust_list nr 300 nbargs 2 types: (struct robust_list_head *, size_t) args: (head, len)
+syscall sys_getcpu nr 302 nbargs 3 types: (unsigned *, unsigned *, struct getcpu_cache *) args: (cpup, nodep, unused)
+syscall sys_epoll_pwait nr 303 nbargs 6 types: (int, struct epoll_event *, int, int, const sigset_t *, size_t) args: (epfd, events, maxevents, timeout, sigmask, sigsetsize)
+syscall sys_utimensat nr 304 nbargs 4 types: (int, const char *, struct timespec *, int) args: (dfd, filename, utimes, flags)
+syscall sys_signalfd nr 305 nbargs 3 types: (int, sigset_t *, size_t) args: (ufd, user_mask, sizemask)
+syscall sys_timerfd_create nr 306 nbargs 2 types: (int, int) args: (clockid, flags)
+syscall sys_eventfd nr 307 nbargs 1 types: (unsigned int) args: (count)
+syscall sys_timerfd_settime nr 311 nbargs 4 types: (int, int, const struct itimerspec *, struct itimerspec *) args: (ufd, flags, utmr, otmr)
+syscall sys_timerfd_gettime nr 312 nbargs 2 types: (int, struct itimerspec *) args: (ufd, otmr)
+syscall sys_signalfd4 nr 313 nbargs 4 types: (int, sigset_t *, size_t, int) args: (ufd, user_mask, sizemask, flags)
+syscall sys_eventfd2 nr 314 nbargs 2 types: (unsigned int, int) args: (count, flags)
+syscall sys_epoll_create1 nr 315 nbargs 1 types: (int) args: (flags)
+syscall sys_dup3 nr 316 nbargs 3 types: (unsigned int, unsigned int, int) args: (oldfd, newfd, flags)
+syscall sys_pipe2 nr 317 nbargs 2 types: (int *, int) args: (fildes, flags)
+syscall sys_inotify_init1 nr 318 nbargs 1 types: (int) args: (flags)
+syscall sys_perf_event_open nr 319 nbargs 5 types: (struct perf_event_attr *, pid_t, int, int, unsigned long) args: (attr_uptr, pid, cpu, group_fd, flags)
+syscall sys_preadv nr 320 nbargs 5 types: (unsigned long, const struct iovec *, unsigned long, unsigned long, unsigned long) args: (fd, vec, vlen, pos_l, pos_h)
+syscall sys_pwritev nr 321 nbargs 5 types: (unsigned long, const struct iovec *, unsigned long, unsigned long, unsigned long) args: (fd, vec, vlen, pos_l, pos_h)
+syscall sys_rt_tgsigqueueinfo nr 322 nbargs 4 types: (pid_t, pid_t, int, siginfo_t *) args: (tgid, pid, sig, uinfo)
+syscall sys_prlimit64 nr 325 nbargs 4 types: (pid_t, unsigned int, const struct rlimit64 *, struct rlimit64 *) args: (pid, resource, new_rlim, old_rlim)
+syscall sys_socket nr 326 nbargs 3 types: (int, int, int) args: (family, type, protocol)
+syscall sys_bind nr 327 nbargs 3 types: (int, struct sockaddr *, int) args: (fd, umyaddr, addrlen)
+syscall sys_connect nr 328 nbargs 3 types: (int, struct sockaddr *, int) args: (fd, uservaddr, addrlen)
+syscall sys_listen nr 329 nbargs 2 types: (int, int) args: (fd, backlog)
+syscall sys_accept nr 330 nbargs 3 types: (int, struct sockaddr *, int *) args: (fd, upeer_sockaddr, upeer_addrlen)
+syscall sys_getsockname nr 331 nbargs 3 types: (int, struct sockaddr *, int *) args: (fd, usockaddr, usockaddr_len)
+syscall sys_getpeername nr 332 nbargs 3 types: (int, struct sockaddr *, int *) args: (fd, usockaddr, usockaddr_len)
+syscall sys_socketpair nr 333 nbargs 4 types: (int, int, int, int *) args: (family, type, protocol, usockvec)
+syscall sys_send nr 334 nbargs 4 types: (int, void *, size_t, unsigned) args: (fd, buff, len, flags)
+syscall sys_sendto nr 335 nbargs 6 types: (int, void *, size_t, unsigned, struct sockaddr *, int) args: (fd, buff, len, flags, addr, addr_len)
+syscall sys_recvfrom nr 337 nbargs 6 types: (int, void *, size_t, unsigned, struct sockaddr *, int *) args: (fd, ubuf, size, flags, addr, addr_len)
+syscall sys_shutdown nr 338 nbargs 2 types: (int, int) args: (fd, how)
+syscall sys_setsockopt nr 339 nbargs 5 types: (int, int, int, char *, int) args: (fd, level, optname, optval, optlen)
+syscall sys_getsockopt nr 340 nbargs 5 types: (int, int, int, char *, int *) args: (fd, level, optname, optval, optlen)
+syscall sys_sendmsg nr 341 nbargs 3 types: (int, struct msghdr *, unsigned) args: (fd, msg, flags)
+syscall sys_recvmsg nr 342 nbargs 3 types: (int, struct msghdr *, unsigned int) args: (fd, msg, flags)
+syscall sys_recvmmsg nr 343 nbargs 5 types: (int, struct mmsghdr *, unsigned int, unsigned int, struct timespec *) args: (fd, mmsg, vlen, flags, timeout)
+syscall sys_accept4 nr 344 nbargs 4 types: (int, struct sockaddr *, int *, int) args: (fd, upeer_sockaddr, upeer_addrlen, flags)
+syscall sys_clock_adjtime nr 347 nbargs 2 types: (const clockid_t, struct timex *) args: (which_clock, utx)
+syscall sys_syncfs nr 348 nbargs 1 types: (int) args: (fd)
+syscall sys_sendmmsg nr 349 nbargs 4 types: (int, struct mmsghdr *, unsigned int, unsigned int) args: (fd, mmsg, vlen, flags)
+syscall sys_setns nr 350 nbargs 2 types: (int, int) args: (fd, nstype)
diff --git a/drivers/staging/lttng/instrumentation/syscalls/3.1.0-rc6/x86-32-syscalls-3.1.0-rc6 b/drivers/staging/lttng/instrumentation/syscalls/3.1.0-rc6/x86-32-syscalls-3.1.0-rc6
new file mode 100644 (file)
index 0000000..130c1e3
--- /dev/null
@@ -0,0 +1,291 @@
+syscall sys_restart_syscall nr 0 nbargs 0 types: () args: ()
+syscall sys_exit nr 1 nbargs 1 types: (int) args: (error_code)
+syscall sys_read nr 3 nbargs 3 types: (unsigned int, char *, size_t) args: (fd, buf, count)
+syscall sys_write nr 4 nbargs 3 types: (unsigned int, const char *, size_t) args: (fd, buf, count)
+syscall sys_open nr 5 nbargs 3 types: (const char *, int, int) args: (filename, flags, mode)
+syscall sys_close nr 6 nbargs 1 types: (unsigned int) args: (fd)
+syscall sys_waitpid nr 7 nbargs 3 types: (pid_t, int *, int) args: (pid, stat_addr, options)
+syscall sys_creat nr 8 nbargs 2 types: (const char *, int) args: (pathname, mode)
+syscall sys_link nr 9 nbargs 2 types: (const char *, const char *) args: (oldname, newname)
+syscall sys_unlink nr 10 nbargs 1 types: (const char *) args: (pathname)
+syscall sys_chdir nr 12 nbargs 1 types: (const char *) args: (filename)
+syscall sys_time nr 13 nbargs 1 types: (time_t *) args: (tloc)
+syscall sys_mknod nr 14 nbargs 3 types: (const char *, int, unsigned) args: (filename, mode, dev)
+syscall sys_chmod nr 15 nbargs 2 types: (const char *, mode_t) args: (filename, mode)
+syscall sys_lchown16 nr 16 nbargs 3 types: (const char *, old_uid_t, old_gid_t) args: (filename, user, group)
+syscall sys_stat nr 18 nbargs 2 types: (const char *, struct __old_kernel_stat *) args: (filename, statbuf)
+syscall sys_lseek nr 19 nbargs 3 types: (unsigned int, off_t, unsigned int) args: (fd, offset, origin)
+syscall sys_getpid nr 20 nbargs 0 types: () args: ()
+syscall sys_mount nr 21 nbargs 5 types: (char *, char *, char *, unsigned long, void *) args: (dev_name, dir_name, type, flags, data)
+syscall sys_oldumount nr 22 nbargs 1 types: (char *) args: (name)
+syscall sys_setuid16 nr 23 nbargs 1 types: (old_uid_t) args: (uid)
+syscall sys_getuid16 nr 24 nbargs 0 types: () args: ()
+syscall sys_stime nr 25 nbargs 1 types: (time_t *) args: (tptr)
+syscall sys_ptrace nr 26 nbargs 4 types: (long, long, unsigned long, unsigned long) args: (request, pid, addr, data)
+syscall sys_alarm nr 27 nbargs 1 types: (unsigned int) args: (seconds)
+syscall sys_fstat nr 28 nbargs 2 types: (unsigned int, struct __old_kernel_stat *) args: (fd, statbuf)
+syscall sys_pause nr 29 nbargs 0 types: () args: ()
+syscall sys_utime nr 30 nbargs 2 types: (char *, struct utimbuf *) args: (filename, times)
+syscall sys_access nr 33 nbargs 2 types: (const char *, int) args: (filename, mode)
+syscall sys_nice nr 34 nbargs 1 types: (int) args: (increment)
+syscall sys_sync nr 36 nbargs 0 types: () args: ()
+syscall sys_kill nr 37 nbargs 2 types: (pid_t, int) args: (pid, sig)
+syscall sys_rename nr 38 nbargs 2 types: (const char *, const char *) args: (oldname, newname)
+syscall sys_mkdir nr 39 nbargs 2 types: (const char *, int) args: (pathname, mode)
+syscall sys_rmdir nr 40 nbargs 1 types: (const char *) args: (pathname)
+syscall sys_dup nr 41 nbargs 1 types: (unsigned int) args: (fildes)
+syscall sys_pipe nr 42 nbargs 1 types: (int *) args: (fildes)
+syscall sys_times nr 43 nbargs 1 types: (struct tms *) args: (tbuf)
+syscall sys_brk nr 45 nbargs 1 types: (unsigned long) args: (brk)
+syscall sys_setgid16 nr 46 nbargs 1 types: (old_gid_t) args: (gid)
+syscall sys_getgid16 nr 47 nbargs 0 types: () args: ()
+syscall sys_signal nr 48 nbargs 2 types: (int, __sighandler_t) args: (sig, handler)
+syscall sys_geteuid16 nr 49 nbargs 0 types: () args: ()
+syscall sys_getegid16 nr 50 nbargs 0 types: () args: ()
+syscall sys_acct nr 51 nbargs 1 types: (const char *) args: (name)
+syscall sys_umount nr 52 nbargs 2 types: (char *, int) args: (name, flags)
+syscall sys_ioctl nr 54 nbargs 3 types: (unsigned int, unsigned int, unsigned long) args: (fd, cmd, arg)
+syscall sys_fcntl nr 55 nbargs 3 types: (unsigned int, unsigned int, unsigned long) args: (fd, cmd, arg)
+syscall sys_setpgid nr 57 nbargs 2 types: (pid_t, pid_t) args: (pid, pgid)
+syscall sys_olduname nr 59 nbargs 1 types: (struct oldold_utsname *) args: (name)
+syscall sys_umask nr 60 nbargs 1 types: (int) args: (mask)
+syscall sys_chroot nr 61 nbargs 1 types: (const char *) args: (filename)
+syscall sys_ustat nr 62 nbargs 2 types: (unsigned, struct ustat *) args: (dev, ubuf)
+syscall sys_dup2 nr 63 nbargs 2 types: (unsigned int, unsigned int) args: (oldfd, newfd)
+syscall sys_getppid nr 64 nbargs 0 types: () args: ()
+syscall sys_getpgrp nr 65 nbargs 0 types: () args: ()
+syscall sys_setsid nr 66 nbargs 0 types: () args: ()
+syscall sys_sgetmask nr 68 nbargs 0 types: () args: ()
+syscall sys_ssetmask nr 69 nbargs 1 types: (int) args: (newmask)
+syscall sys_setreuid16 nr 70 nbargs 2 types: (old_uid_t, old_uid_t) args: (ruid, euid)
+syscall sys_setregid16 nr 71 nbargs 2 types: (old_gid_t, old_gid_t) args: (rgid, egid)
+syscall sys_sigpending nr 73 nbargs 1 types: (old_sigset_t *) args: (set)
+syscall sys_sethostname nr 74 nbargs 2 types: (char *, int) args: (name, len)
+syscall sys_setrlimit nr 75 nbargs 2 types: (unsigned int, struct rlimit *) args: (resource, rlim)
+syscall sys_old_getrlimit nr 76 nbargs 2 types: (unsigned int, struct rlimit *) args: (resource, rlim)
+syscall sys_getrusage nr 77 nbargs 2 types: (int, struct rusage *) args: (who, ru)
+syscall sys_gettimeofday nr 78 nbargs 2 types: (struct timeval *, struct timezone *) args: (tv, tz)
+syscall sys_settimeofday nr 79 nbargs 2 types: (struct timeval *, struct timezone *) args: (tv, tz)
+syscall sys_getgroups16 nr 80 nbargs 2 types: (int, old_gid_t *) args: (gidsetsize, grouplist)
+syscall sys_setgroups16 nr 81 nbargs 2 types: (int, old_gid_t *) args: (gidsetsize, grouplist)
+syscall sys_old_select nr 82 nbargs 1 types: (struct sel_arg_struct *) args: (arg)
+syscall sys_symlink nr 83 nbargs 2 types: (const char *, const char *) args: (oldname, newname)
+syscall sys_lstat nr 84 nbargs 2 types: (const char *, struct __old_kernel_stat *) args: (filename, statbuf)
+syscall sys_readlink nr 85 nbargs 3 types: (const char *, char *, int) args: (path, buf, bufsiz)
+syscall sys_uselib nr 86 nbargs 1 types: (const char *) args: (library)
+syscall sys_swapon nr 87 nbargs 2 types: (const char *, int) args: (specialfile, swap_flags)
+syscall sys_reboot nr 88 nbargs 4 types: (int, int, unsigned int, void *) args: (magic1, magic2, cmd, arg)
+syscall sys_old_readdir nr 89 nbargs 3 types: (unsigned int, struct old_linux_dirent *, unsigned int) args: (fd, dirent, count)
+syscall sys_old_mmap nr 90 nbargs 1 types: (struct mmap_arg_struct *) args: (arg)
+syscall sys_munmap nr 91 nbargs 2 types: (unsigned long, size_t) args: (addr, len)
+syscall sys_truncate nr 92 nbargs 2 types: (const char *, long) args: (path, length)
+syscall sys_ftruncate nr 93 nbargs 2 types: (unsigned int, unsigned long) args: (fd, length)
+syscall sys_fchmod nr 94 nbargs 2 types: (unsigned int, mode_t) args: (fd, mode)
+syscall sys_fchown16 nr 95 nbargs 3 types: (unsigned int, old_uid_t, old_gid_t) args: (fd, user, group)
+syscall sys_getpriority nr 96 nbargs 2 types: (int, int) args: (which, who)
+syscall sys_setpriority nr 97 nbargs 3 types: (int, int, int) args: (which, who, niceval)
+syscall sys_statfs nr 99 nbargs 2 types: (const char *, struct statfs *) args: (pathname, buf)
+syscall sys_fstatfs nr 100 nbargs 2 types: (unsigned int, struct statfs *) args: (fd, buf)
+syscall sys_socketcall nr 102 nbargs 2 types: (int, unsigned long *) args: (call, args)
+syscall sys_syslog nr 103 nbargs 3 types: (int, char *, int) args: (type, buf, len)
+syscall sys_setitimer nr 104 nbargs 3 types: (int, struct itimerval *, struct itimerval *) args: (which, value, ovalue)
+syscall sys_getitimer nr 105 nbargs 2 types: (int, struct itimerval *) args: (which, value)
+syscall sys_newstat nr 106 nbargs 2 types: (const char *, struct stat *) args: (filename, statbuf)
+syscall sys_newlstat nr 107 nbargs 2 types: (const char *, struct stat *) args: (filename, statbuf)
+syscall sys_newfstat nr 108 nbargs 2 types: (unsigned int, struct stat *) args: (fd, statbuf)
+syscall sys_uname nr 109 nbargs 1 types: (struct old_utsname *) args: (name)
+syscall sys_vhangup nr 111 nbargs 0 types: () args: ()
+syscall sys_wait4 nr 114 nbargs 4 types: (pid_t, int *, int, struct rusage *) args: (upid, stat_addr, options, ru)
+syscall sys_swapoff nr 115 nbargs 1 types: (const char *) args: (specialfile)
+syscall sys_sysinfo nr 116 nbargs 1 types: (struct sysinfo *) args: (info)
+syscall sys_ipc nr 117 nbargs 6 types: (unsigned int, int, unsigned long, unsigned long, void *, long) args: (call, first, second, third, ptr, fifth)
+syscall sys_fsync nr 118 nbargs 1 types: (unsigned int) args: (fd)
+syscall sys_setdomainname nr 121 nbargs 2 types: (char *, int) args: (name, len)
+syscall sys_newuname nr 122 nbargs 1 types: (struct new_utsname *) args: (name)
+syscall sys_adjtimex nr 124 nbargs 1 types: (struct timex *) args: (txc_p)
+syscall sys_mprotect nr 125 nbargs 3 types: (unsigned long, size_t, unsigned long) args: (start, len, prot)
+syscall sys_sigprocmask nr 126 nbargs 3 types: (int, old_sigset_t *, old_sigset_t *) args: (how, nset, oset)
+syscall sys_init_module nr 128 nbargs 3 types: (void *, unsigned long, const char *) args: (umod, len, uargs)
+syscall sys_delete_module nr 129 nbargs 2 types: (const char *, unsigned int) args: (name_user, flags)
+syscall sys_quotactl nr 131 nbargs 4 types: (unsigned int, const char *, qid_t, void *) args: (cmd, special, id, addr)
+syscall sys_getpgid nr 132 nbargs 1 types: (pid_t) args: (pid)
+syscall sys_fchdir nr 133 nbargs 1 types: (unsigned int) args: (fd)
+syscall sys_bdflush nr 134 nbargs 2 types: (int, long) args: (func, data)
+syscall sys_sysfs nr 135 nbargs 3 types: (int, unsigned long, unsigned long) args: (option, arg1, arg2)
+syscall sys_personality nr 136 nbargs 1 types: (unsigned int) args: (personality)
+syscall sys_setfsuid16 nr 138 nbargs 1 types: (old_uid_t) args: (uid)
+syscall sys_setfsgid16 nr 139 nbargs 1 types: (old_gid_t) args: (gid)
+syscall sys_llseek nr 140 nbargs 5 types: (unsigned int, unsigned long, unsigned long, loff_t *, unsigned int) args: (fd, offset_high, offset_low, result, origin)
+syscall sys_getdents nr 141 nbargs 3 types: (unsigned int, struct linux_dirent *, unsigned int) args: (fd, dirent, count)
+syscall sys_select nr 142 nbargs 5 types: (int, fd_set *, fd_set *, fd_set *, struct timeval *) args: (n, inp, outp, exp, tvp)
+syscall sys_flock nr 143 nbargs 2 types: (unsigned int, unsigned int) args: (fd, cmd)
+syscall sys_msync nr 144 nbargs 3 types: (unsigned long, size_t, int) args: (start, len, flags)
+syscall sys_readv nr 145 nbargs 3 types: (unsigned long, const struct iovec *, unsigned long) args: (fd, vec, vlen)
+syscall sys_writev nr 146 nbargs 3 types: (unsigned long, const struct iovec *, unsigned long) args: (fd, vec, vlen)
+syscall sys_getsid nr 147 nbargs 1 types: (pid_t) args: (pid)
+syscall sys_fdatasync nr 148 nbargs 1 types: (unsigned int) args: (fd)
+syscall sys_sysctl nr 149 nbargs 1 types: (struct __sysctl_args *) args: (args)
+syscall sys_mlock nr 150 nbargs 2 types: (unsigned long, size_t) args: (start, len)
+syscall sys_munlock nr 151 nbargs 2 types: (unsigned long, size_t) args: (start, len)
+syscall sys_mlockall nr 152 nbargs 1 types: (int) args: (flags)
+syscall sys_munlockall nr 153 nbargs 0 types: () args: ()
+syscall sys_sched_setparam nr 154 nbargs 2 types: (pid_t, struct sched_param *) args: (pid, param)
+syscall sys_sched_getparam nr 155 nbargs 2 types: (pid_t, struct sched_param *) args: (pid, param)
+syscall sys_sched_setscheduler nr 156 nbargs 3 types: (pid_t, int, struct sched_param *) args: (pid, policy, param)
+syscall sys_sched_getscheduler nr 157 nbargs 1 types: (pid_t) args: (pid)
+syscall sys_sched_yield nr 158 nbargs 0 types: () args: ()
+syscall sys_sched_get_priority_max nr 159 nbargs 1 types: (int) args: (policy)
+syscall sys_sched_get_priority_min nr 160 nbargs 1 types: (int) args: (policy)
+syscall sys_sched_rr_get_interval nr 161 nbargs 2 types: (pid_t, struct timespec *) args: (pid, interval)
+syscall sys_nanosleep nr 162 nbargs 2 types: (struct timespec *, struct timespec *) args: (rqtp, rmtp)
+syscall sys_mremap nr 163 nbargs 5 types: (unsigned long, unsigned long, unsigned long, unsigned long, unsigned long) args: (addr, old_len, new_len, flags, new_addr)
+syscall sys_setresuid16 nr 164 nbargs 3 types: (old_uid_t, old_uid_t, old_uid_t) args: (ruid, euid, suid)
+syscall sys_getresuid16 nr 165 nbargs 3 types: (old_uid_t *, old_uid_t *, old_uid_t *) args: (ruid, euid, suid)
+syscall sys_poll nr 168 nbargs 3 types: (struct pollfd *, unsigned int, long) args: (ufds, nfds, timeout_msecs)
+syscall sys_setresgid16 nr 170 nbargs 3 types: (old_gid_t, old_gid_t, old_gid_t) args: (rgid, egid, sgid)
+syscall sys_getresgid16 nr 171 nbargs 3 types: (old_gid_t *, old_gid_t *, old_gid_t *) args: (rgid, egid, sgid)
+syscall sys_prctl nr 172 nbargs 5 types: (int, unsigned long, unsigned long, unsigned long, unsigned long) args: (option, arg2, arg3, arg4, arg5)
+syscall sys_rt_sigaction nr 174 nbargs 4 types: (int, const struct sigaction *, struct sigaction *, size_t) args: (sig, act, oact, sigsetsize)
+syscall sys_rt_sigprocmask nr 175 nbargs 4 types: (int, sigset_t *, sigset_t *, size_t) args: (how, nset, oset, sigsetsize)
+syscall sys_rt_sigpending nr 176 nbargs 2 types: (sigset_t *, size_t) args: (set, sigsetsize)
+syscall sys_rt_sigtimedwait nr 177 nbargs 4 types: (const sigset_t *, siginfo_t *, const struct timespec *, size_t) args: (uthese, uinfo, uts, sigsetsize)
+syscall sys_rt_sigqueueinfo nr 178 nbargs 3 types: (pid_t, int, siginfo_t *) args: (pid, sig, uinfo)
+syscall sys_rt_sigsuspend nr 179 nbargs 2 types: (sigset_t *, size_t) args: (unewset, sigsetsize)
+syscall sys_chown16 nr 182 nbargs 3 types: (const char *, old_uid_t, old_gid_t) args: (filename, user, group)
+syscall sys_getcwd nr 183 nbargs 2 types: (char *, unsigned long) args: (buf, size)
+syscall sys_capget nr 184 nbargs 2 types: (cap_user_header_t, cap_user_data_t) args: (header, dataptr)
+syscall sys_capset nr 185 nbargs 2 types: (cap_user_header_t, const cap_user_data_t) args: (header, data)
+syscall sys_sendfile nr 187 nbargs 4 types: (int, int, off_t *, size_t) args: (out_fd, in_fd, offset, count)
+syscall sys_getrlimit nr 191 nbargs 2 types: (unsigned int, struct rlimit *) args: (resource, rlim)
+syscall sys_mmap_pgoff nr 192 nbargs 6 types: (unsigned long, unsigned long, unsigned long, unsigned long, unsigned long, unsigned long) args: (addr, len, prot, flags, fd, pgoff)
+syscall sys_stat64 nr 195 nbargs 2 types: (const char *, struct stat64 *) args: (filename, statbuf)
+syscall sys_lstat64 nr 196 nbargs 2 types: (const char *, struct stat64 *) args: (filename, statbuf)
+syscall sys_fstat64 nr 197 nbargs 2 types: (unsigned long, struct stat64 *) args: (fd, statbuf)
+syscall sys_lchown nr 198 nbargs 3 types: (const char *, uid_t, gid_t) args: (filename, user, group)
+syscall sys_getuid nr 199 nbargs 0 types: () args: ()
+syscall sys_getgid nr 200 nbargs 0 types: () args: ()
+syscall sys_geteuid nr 201 nbargs 0 types: () args: ()
+syscall sys_getegid nr 202 nbargs 0 types: () args: ()
+syscall sys_setreuid nr 203 nbargs 2 types: (uid_t, uid_t) args: (ruid, euid)
+syscall sys_setregid nr 204 nbargs 2 types: (gid_t, gid_t) args: (rgid, egid)
+syscall sys_getgroups nr 205 nbargs 2 types: (int, gid_t *) args: (gidsetsize, grouplist)
+syscall sys_setgroups nr 206 nbargs 2 types: (int, gid_t *) args: (gidsetsize, grouplist)
+syscall sys_fchown nr 207 nbargs 3 types: (unsigned int, uid_t, gid_t) args: (fd, user, group)
+syscall sys_setresuid nr 208 nbargs 3 types: (uid_t, uid_t, uid_t) args: (ruid, euid, suid)
+syscall sys_getresuid nr 209 nbargs 3 types: (uid_t *, uid_t *, uid_t *) args: (ruid, euid, suid)
+syscall sys_setresgid nr 210 nbargs 3 types: (gid_t, gid_t, gid_t) args: (rgid, egid, sgid)
+syscall sys_getresgid nr 211 nbargs 3 types: (gid_t *, gid_t *, gid_t *) args: (rgid, egid, sgid)
+syscall sys_chown nr 212 nbargs 3 types: (const char *, uid_t, gid_t) args: (filename, user, group)
+syscall sys_setuid nr 213 nbargs 1 types: (uid_t) args: (uid)
+syscall sys_setgid nr 214 nbargs 1 types: (gid_t) args: (gid)
+syscall sys_setfsuid nr 215 nbargs 1 types: (uid_t) args: (uid)
+syscall sys_setfsgid nr 216 nbargs 1 types: (gid_t) args: (gid)
+syscall sys_pivot_root nr 217 nbargs 2 types: (const char *, const char *) args: (new_root, put_old)
+syscall sys_mincore nr 218 nbargs 3 types: (unsigned long, size_t, unsigned char *) args: (start, len, vec)
+syscall sys_madvise nr 219 nbargs 3 types: (unsigned long, size_t, int) args: (start, len_in, behavior)
+syscall sys_getdents64 nr 220 nbargs 3 types: (unsigned int, struct linux_dirent64 *, unsigned int) args: (fd, dirent, count)
+syscall sys_fcntl64 nr 221 nbargs 3 types: (unsigned int, unsigned int, unsigned long) args: (fd, cmd, arg)
+syscall sys_gettid nr 224 nbargs 0 types: () args: ()
+syscall sys_setxattr nr 226 nbargs 5 types: (const char *, const char *, const void *, size_t, int) args: (pathname, name, value, size, flags)
+syscall sys_lsetxattr nr 227 nbargs 5 types: (const char *, const char *, const void *, size_t, int) args: (pathname, name, value, size, flags)
+syscall sys_fsetxattr nr 228 nbargs 5 types: (int, const char *, const void *, size_t, int) args: (fd, name, value, size, flags)
+syscall sys_getxattr nr 229 nbargs 4 types: (const char *, const char *, void *, size_t) args: (pathname, name, value, size)
+syscall sys_lgetxattr nr 230 nbargs 4 types: (const char *, const char *, void *, size_t) args: (pathname, name, value, size)
+syscall sys_fgetxattr nr 231 nbargs 4 types: (int, const char *, void *, size_t) args: (fd, name, value, size)
+syscall sys_listxattr nr 232 nbargs 3 types: (const char *, char *, size_t) args: (pathname, list, size)
+syscall sys_llistxattr nr 233 nbargs 3 types: (const char *, char *, size_t) args: (pathname, list, size)
+syscall sys_flistxattr nr 234 nbargs 3 types: (int, char *, size_t) args: (fd, list, size)
+syscall sys_removexattr nr 235 nbargs 2 types: (const char *, const char *) args: (pathname, name)
+syscall sys_lremovexattr nr 236 nbargs 2 types: (const char *, const char *) args: (pathname, name)
+syscall sys_fremovexattr nr 237 nbargs 2 types: (int, const char *) args: (fd, name)
+syscall sys_tkill nr 238 nbargs 2 types: (pid_t, int) args: (pid, sig)
+syscall sys_sendfile64 nr 239 nbargs 4 types: (int, int, loff_t *, size_t) args: (out_fd, in_fd, offset, count)
+syscall sys_futex nr 240 nbargs 6 types: (u32 *, int, u32, struct timespec *, u32 *, u32) args: (uaddr, op, val, utime, uaddr2, val3)
+syscall sys_sched_setaffinity nr 241 nbargs 3 types: (pid_t, unsigned int, unsigned long *) args: (pid, len, user_mask_ptr)
+syscall sys_sched_getaffinity nr 242 nbargs 3 types: (pid_t, unsigned int, unsigned long *) args: (pid, len, user_mask_ptr)
+syscall sys_io_setup nr 245 nbargs 2 types: (unsigned, aio_context_t *) args: (nr_events, ctxp)
+syscall sys_io_destroy nr 246 nbargs 1 types: (aio_context_t) args: (ctx)
+syscall sys_io_getevents nr 247 nbargs 5 types: (aio_context_t, long, long, struct io_event *, struct timespec *) args: (ctx_id, min_nr, nr, events, timeout)
+syscall sys_io_submit nr 248 nbargs 3 types: (aio_context_t, long, struct iocb * *) args: (ctx_id, nr, iocbpp)
+syscall sys_io_cancel nr 249 nbargs 3 types: (aio_context_t, struct iocb *, struct io_event *) args: (ctx_id, iocb, result)
+syscall sys_exit_group nr 252 nbargs 1 types: (int) args: (error_code)
+syscall sys_epoll_create nr 254 nbargs 1 types: (int) args: (size)
+syscall sys_epoll_ctl nr 255 nbargs 4 types: (int, int, int, struct epoll_event *) args: (epfd, op, fd, event)
+syscall sys_epoll_wait nr 256 nbargs 4 types: (int, struct epoll_event *, int, int) args: (epfd, events, maxevents, timeout)
+syscall sys_remap_file_pages nr 257 nbargs 5 types: (unsigned long, unsigned long, unsigned long, unsigned long, unsigned long) args: (start, size, prot, pgoff, flags)
+syscall sys_set_tid_address nr 258 nbargs 1 types: (int *) args: (tidptr)
+syscall sys_timer_create nr 259 nbargs 3 types: (const clockid_t, struct sigevent *, timer_t *) args: (which_clock, timer_event_spec, created_timer_id)
+syscall sys_timer_settime nr 260 nbargs 4 types: (timer_t, int, const struct itimerspec *, struct itimerspec *) args: (timer_id, flags, new_setting, old_setting)
+syscall sys_timer_gettime nr 261 nbargs 2 types: (timer_t, struct itimerspec *) args: (timer_id, setting)
+syscall sys_timer_getoverrun nr 262 nbargs 1 types: (timer_t) args: (timer_id)
+syscall sys_timer_delete nr 263 nbargs 1 types: (timer_t) args: (timer_id)
+syscall sys_clock_settime nr 264 nbargs 2 types: (const clockid_t, const struct timespec *) args: (which_clock, tp)
+syscall sys_clock_gettime nr 265 nbargs 2 types: (const clockid_t, struct timespec *) args: (which_clock, tp)
+syscall sys_clock_getres nr 266 nbargs 2 types: (const clockid_t, struct timespec *) args: (which_clock, tp)
+syscall sys_clock_nanosleep nr 267 nbargs 4 types: (const clockid_t, int, const struct timespec *, struct timespec *) args: (which_clock, flags, rqtp, rmtp)
+syscall sys_statfs64 nr 268 nbargs 3 types: (const char *, size_t, struct statfs64 *) args: (pathname, sz, buf)
+syscall sys_fstatfs64 nr 269 nbargs 3 types: (unsigned int, size_t, struct statfs64 *) args: (fd, sz, buf)
+syscall sys_tgkill nr 270 nbargs 3 types: (pid_t, pid_t, int) args: (tgid, pid, sig)
+syscall sys_utimes nr 271 nbargs 2 types: (char *, struct timeval *) args: (filename, utimes)
+syscall sys_mq_open nr 277 nbargs 4 types: (const char *, int, mode_t, struct mq_attr *) args: (u_name, oflag, mode, u_attr)
+syscall sys_mq_unlink nr 278 nbargs 1 types: (const char *) args: (u_name)
+syscall sys_mq_timedsend nr 279 nbargs 5 types: (mqd_t, const char *, size_t, unsigned int, const struct timespec *) args: (mqdes, u_msg_ptr, msg_len, msg_prio, u_abs_timeout)
+syscall sys_mq_timedreceive nr 280 nbargs 5 types: (mqd_t, char *, size_t, unsigned int *, const struct timespec *) args: (mqdes, u_msg_ptr, msg_len, u_msg_prio, u_abs_timeout)
+syscall sys_mq_notify nr 281 nbargs 2 types: (mqd_t, const struct sigevent *) args: (mqdes, u_notification)
+syscall sys_mq_getsetattr nr 282 nbargs 3 types: (mqd_t, const struct mq_attr *, struct mq_attr *) args: (mqdes, u_mqstat, u_omqstat)
+syscall sys_kexec_load nr 283 nbargs 4 types: (unsigned long, unsigned long, struct kexec_segment *, unsigned long) args: (entry, nr_segments, segments, flags)
+syscall sys_waitid nr 284 nbargs 5 types: (int, pid_t, struct siginfo *, int, struct rusage *) args: (which, upid, infop, options, ru)
+syscall sys_add_key nr 286 nbargs 5 types: (const char *, const char *, const void *, size_t, key_serial_t) args: (_type, _description, _payload, plen, ringid)
+syscall sys_request_key nr 287 nbargs 4 types: (const char *, const char *, const char *, key_serial_t) args: (_type, _description, _callout_info, destringid)
+syscall sys_keyctl nr 288 nbargs 5 types: (int, unsigned long, unsigned long, unsigned long, unsigned long) args: (option, arg2, arg3, arg4, arg5)
+syscall sys_ioprio_set nr 289 nbargs 3 types: (int, int, int) args: (which, who, ioprio)
+syscall sys_ioprio_get nr 290 nbargs 2 types: (int, int) args: (which, who)
+syscall sys_inotify_init nr 291 nbargs 0 types: () args: ()
+syscall sys_inotify_add_watch nr 292 nbargs 3 types: (int, const char *, u32) args: (fd, pathname, mask)
+syscall sys_inotify_rm_watch nr 293 nbargs 2 types: (int, __s32) args: (fd, wd)
+syscall sys_openat nr 295 nbargs 4 types: (int, const char *, int, int) args: (dfd, filename, flags, mode)
+syscall sys_mkdirat nr 296 nbargs 3 types: (int, const char *, int) args: (dfd, pathname, mode)
+syscall sys_mknodat nr 297 nbargs 4 types: (int, const char *, int, unsigned) args: (dfd, filename, mode, dev)
+syscall sys_fchownat nr 298 nbargs 5 types: (int, const char *, uid_t, gid_t, int) args: (dfd, filename, user, group, flag)
+syscall sys_futimesat nr 299 nbargs 3 types: (int, const char *, struct timeval *) args: (dfd, filename, utimes)
+syscall sys_fstatat64 nr 300 nbargs 4 types: (int, const char *, struct stat64 *, int) args: (dfd, filename, statbuf, flag)
+syscall sys_unlinkat nr 301 nbargs 3 types: (int, const char *, int) args: (dfd, pathname, flag)
+syscall sys_renameat nr 302 nbargs 4 types: (int, const char *, int, const char *) args: (olddfd, oldname, newdfd, newname)
+syscall sys_linkat nr 303 nbargs 5 types: (int, const char *, int, const char *, int) args: (olddfd, oldname, newdfd, newname, flags)
+syscall sys_symlinkat nr 304 nbargs 3 types: (const char *, int, const char *) args: (oldname, newdfd, newname)
+syscall sys_readlinkat nr 305 nbargs 4 types: (int, const char *, char *, int) args: (dfd, pathname, buf, bufsiz)
+syscall sys_fchmodat nr 306 nbargs 3 types: (int, const char *, mode_t) args: (dfd, filename, mode)
+syscall sys_faccessat nr 307 nbargs 3 types: (int, const char *, int) args: (dfd, filename, mode)
+syscall sys_pselect6 nr 308 nbargs 6 types: (int, fd_set *, fd_set *, fd_set *, struct timespec *, void *) args: (n, inp, outp, exp, tsp, sig)
+syscall sys_ppoll nr 309 nbargs 5 types: (struct pollfd *, unsigned int, struct timespec *, const sigset_t *, size_t) args: (ufds, nfds, tsp, sigmask, sigsetsize)
+syscall sys_unshare nr 310 nbargs 1 types: (unsigned long) args: (unshare_flags)
+syscall sys_set_robust_list nr 311 nbargs 2 types: (struct robust_list_head *, size_t) args: (head, len)
+syscall sys_get_robust_list nr 312 nbargs 3 types: (int, struct robust_list_head * *, size_t *) args: (pid, head_ptr, len_ptr)
+syscall sys_splice nr 313 nbargs 6 types: (int, loff_t *, int, loff_t *, size_t, unsigned int) args: (fd_in, off_in, fd_out, off_out, len, flags)
+syscall sys_tee nr 315 nbargs 4 types: (int, int, size_t, unsigned int) args: (fdin, fdout, len, flags)
+syscall sys_vmsplice nr 316 nbargs 4 types: (int, const struct iovec *, unsigned long, unsigned int) args: (fd, iov, nr_segs, flags)
+syscall sys_getcpu nr 318 nbargs 3 types: (unsigned *, unsigned *, struct getcpu_cache *) args: (cpup, nodep, unused)
+syscall sys_epoll_pwait nr 319 nbargs 6 types: (int, struct epoll_event *, int, int, const sigset_t *, size_t) args: (epfd, events, maxevents, timeout, sigmask, sigsetsize)
+syscall sys_utimensat nr 320 nbargs 4 types: (int, const char *, struct timespec *, int) args: (dfd, filename, utimes, flags)
+syscall sys_signalfd nr 321 nbargs 3 types: (int, sigset_t *, size_t) args: (ufd, user_mask, sizemask)
+syscall sys_timerfd_create nr 322 nbargs 2 types: (int, int) args: (clockid, flags)
+syscall sys_eventfd nr 323 nbargs 1 types: (unsigned int) args: (count)
+syscall sys_timerfd_settime nr 325 nbargs 4 types: (int, int, const struct itimerspec *, struct itimerspec *) args: (ufd, flags, utmr, otmr)
+syscall sys_timerfd_gettime nr 326 nbargs 2 types: (int, struct itimerspec *) args: (ufd, otmr)
+syscall sys_signalfd4 nr 327 nbargs 4 types: (int, sigset_t *, size_t, int) args: (ufd, user_mask, sizemask, flags)
+syscall sys_eventfd2 nr 328 nbargs 2 types: (unsigned int, int) args: (count, flags)
+syscall sys_epoll_create1 nr 329 nbargs 1 types: (int) args: (flags)
+syscall sys_dup3 nr 330 nbargs 3 types: (unsigned int, unsigned int, int) args: (oldfd, newfd, flags)
+syscall sys_pipe2 nr 331 nbargs 2 types: (int *, int) args: (fildes, flags)
+syscall sys_inotify_init1 nr 332 nbargs 1 types: (int) args: (flags)
+syscall sys_preadv nr 333 nbargs 5 types: (unsigned long, const struct iovec *, unsigned long, unsigned long, unsigned long) args: (fd, vec, vlen, pos_l, pos_h)
+syscall sys_pwritev nr 334 nbargs 5 types: (unsigned long, const struct iovec *, unsigned long, unsigned long, unsigned long) args: (fd, vec, vlen, pos_l, pos_h)
+syscall sys_rt_tgsigqueueinfo nr 335 nbargs 4 types: (pid_t, pid_t, int, siginfo_t *) args: (tgid, pid, sig, uinfo)
+syscall sys_perf_event_open nr 336 nbargs 5 types: (struct perf_event_attr *, pid_t, int, int, unsigned long) args: (attr_uptr, pid, cpu, group_fd, flags)
+syscall sys_recvmmsg nr 337 nbargs 5 types: (int, struct mmsghdr *, unsigned int, unsigned int, struct timespec *) args: (fd, mmsg, vlen, flags, timeout)
+syscall sys_fanotify_init nr 338 nbargs 2 types: (unsigned int, unsigned int) args: (flags, event_f_flags)
+syscall sys_prlimit64 nr 340 nbargs 4 types: (pid_t, unsigned int, const struct rlimit64 *, struct rlimit64 *) args: (pid, resource, new_rlim, old_rlim)
+syscall sys_clock_adjtime nr 343 nbargs 2 types: (const clockid_t, struct timex *) args: (which_clock, utx)
+syscall sys_syncfs nr 344 nbargs 1 types: (int) args: (fd)
+syscall sys_sendmmsg nr 345 nbargs 4 types: (int, struct mmsghdr *, unsigned int, unsigned int) args: (fd, mmsg, vlen, flags)
+syscall sys_setns nr 346 nbargs 2 types: (int, int) args: (fd, nstype)
diff --git a/drivers/staging/lttng/instrumentation/syscalls/3.10.0-rc7/x86-64-syscalls-3.10.0-rc7 b/drivers/staging/lttng/instrumentation/syscalls/3.10.0-rc7/x86-64-syscalls-3.10.0-rc7
new file mode 100644 (file)
index 0000000..d9f81c0
--- /dev/null
@@ -0,0 +1,290 @@
+syscall sys_read nr 0 nbargs 3 types: (unsigned int, char *, size_t) args: (fd, buf, count)
+syscall sys_write nr 1 nbargs 3 types: (unsigned int, const char *, size_t) args: (fd, buf, count)
+syscall sys_open nr 2 nbargs 3 types: (const char *, int, umode_t) args: (filename, flags, mode)
+syscall sys_close nr 3 nbargs 1 types: (unsigned int) args: (fd)
+syscall sys_newstat nr 4 nbargs 2 types: (const char *, struct stat *) args: (filename, statbuf)
+syscall sys_newfstat nr 5 nbargs 2 types: (unsigned int, struct stat *) args: (fd, statbuf)
+syscall sys_newlstat nr 6 nbargs 2 types: (const char *, struct stat *) args: (filename, statbuf)
+syscall sys_poll nr 7 nbargs 3 types: (struct pollfd *, unsigned int, int) args: (ufds, nfds, timeout_msecs)
+syscall sys_lseek nr 8 nbargs 3 types: (unsigned int, off_t, unsigned int) args: (fd, offset, whence)
+syscall sys_mmap nr 9 nbargs 6 types: (unsigned long, unsigned long, unsigned long, unsigned long, unsigned long, unsigned long) args: (addr, len, prot, flags, fd, off)
+syscall sys_mprotect nr 10 nbargs 3 types: (unsigned long, size_t, unsigned long) args: (start, len, prot)
+syscall sys_munmap nr 11 nbargs 2 types: (unsigned long, size_t) args: (addr, len)
+syscall sys_brk nr 12 nbargs 1 types: (unsigned long) args: (brk)
+syscall sys_rt_sigaction nr 13 nbargs 4 types: (int, const struct sigaction *, struct sigaction *, size_t) args: (sig, act, oact, sigsetsize)
+syscall sys_rt_sigprocmask nr 14 nbargs 4 types: (int, sigset_t *, sigset_t *, size_t) args: (how, nset, oset, sigsetsize)
+syscall sys_ioctl nr 16 nbargs 3 types: (unsigned int, unsigned int, unsigned long) args: (fd, cmd, arg)
+syscall sys_pread64 nr 17 nbargs 4 types: (unsigned int, char *, size_t, loff_t) args: (fd, buf, count, pos)
+syscall sys_pwrite64 nr 18 nbargs 4 types: (unsigned int, const char *, size_t, loff_t) args: (fd, buf, count, pos)
+syscall sys_readv nr 19 nbargs 3 types: (unsigned long, const struct iovec *, unsigned long) args: (fd, vec, vlen)
+syscall sys_writev nr 20 nbargs 3 types: (unsigned long, const struct iovec *, unsigned long) args: (fd, vec, vlen)
+syscall sys_access nr 21 nbargs 2 types: (const char *, int) args: (filename, mode)
+syscall sys_pipe nr 22 nbargs 1 types: (int *) args: (fildes)
+syscall sys_select nr 23 nbargs 5 types: (int, fd_set *, fd_set *, fd_set *, struct timeval *) args: (n, inp, outp, exp, tvp)
+syscall sys_sched_yield nr 24 nbargs 0 types: () args: ()
+syscall sys_mremap nr 25 nbargs 5 types: (unsigned long, unsigned long, unsigned long, unsigned long, unsigned long) args: (addr, old_len, new_len, flags, new_addr)
+syscall sys_msync nr 26 nbargs 3 types: (unsigned long, size_t, int) args: (start, len, flags)
+syscall sys_mincore nr 27 nbargs 3 types: (unsigned long, size_t, unsigned char *) args: (start, len, vec)
+syscall sys_madvise nr 28 nbargs 3 types: (unsigned long, size_t, int) args: (start, len_in, behavior)
+syscall sys_shmget nr 29 nbargs 3 types: (key_t, size_t, int) args: (key, size, shmflg)
+syscall sys_shmat nr 30 nbargs 3 types: (int, char *, int) args: (shmid, shmaddr, shmflg)
+syscall sys_shmctl nr 31 nbargs 3 types: (int, int, struct shmid_ds *) args: (shmid, cmd, buf)
+syscall sys_dup nr 32 nbargs 1 types: (unsigned int) args: (fildes)
+syscall sys_dup2 nr 33 nbargs 2 types: (unsigned int, unsigned int) args: (oldfd, newfd)
+syscall sys_pause nr 34 nbargs 0 types: () args: ()
+syscall sys_nanosleep nr 35 nbargs 2 types: (struct timespec *, struct timespec *) args: (rqtp, rmtp)
+syscall sys_getitimer nr 36 nbargs 2 types: (int, struct itimerval *) args: (which, value)
+syscall sys_alarm nr 37 nbargs 1 types: (unsigned int) args: (seconds)
+syscall sys_setitimer nr 38 nbargs 3 types: (int, struct itimerval *, struct itimerval *) args: (which, value, ovalue)
+syscall sys_getpid nr 39 nbargs 0 types: () args: ()
+syscall sys_sendfile64 nr 40 nbargs 4 types: (int, int, loff_t *, size_t) args: (out_fd, in_fd, offset, count)
+syscall sys_socket nr 41 nbargs 3 types: (int, int, int) args: (family, type, protocol)
+syscall sys_connect nr 42 nbargs 3 types: (int, struct sockaddr *, int) args: (fd, uservaddr, addrlen)
+syscall sys_accept nr 43 nbargs 3 types: (int, struct sockaddr *, int *) args: (fd, upeer_sockaddr, upeer_addrlen)
+syscall sys_sendto nr 44 nbargs 6 types: (int, void *, size_t, unsigned int, struct sockaddr *, int) args: (fd, buff, len, flags, addr, addr_len)
+syscall sys_recvfrom nr 45 nbargs 6 types: (int, void *, size_t, unsigned int, struct sockaddr *, int *) args: (fd, ubuf, size, flags, addr, addr_len)
+syscall sys_sendmsg nr 46 nbargs 3 types: (int, struct msghdr *, unsigned int) args: (fd, msg, flags)
+syscall sys_recvmsg nr 47 nbargs 3 types: (int, struct msghdr *, unsigned int) args: (fd, msg, flags)
+syscall sys_shutdown nr 48 nbargs 2 types: (int, int) args: (fd, how)
+syscall sys_bind nr 49 nbargs 3 types: (int, struct sockaddr *, int) args: (fd, umyaddr, addrlen)
+syscall sys_listen nr 50 nbargs 2 types: (int, int) args: (fd, backlog)
+syscall sys_getsockname nr 51 nbargs 3 types: (int, struct sockaddr *, int *) args: (fd, usockaddr, usockaddr_len)
+syscall sys_getpeername nr 52 nbargs 3 types: (int, struct sockaddr *, int *) args: (fd, usockaddr, usockaddr_len)
+syscall sys_socketpair nr 53 nbargs 4 types: (int, int, int, int *) args: (family, type, protocol, usockvec)
+syscall sys_setsockopt nr 54 nbargs 5 types: (int, int, int, char *, int) args: (fd, level, optname, optval, optlen)
+syscall sys_getsockopt nr 55 nbargs 5 types: (int, int, int, char *, int *) args: (fd, level, optname, optval, optlen)
+syscall sys_exit nr 60 nbargs 1 types: (int) args: (error_code)
+syscall sys_wait4 nr 61 nbargs 4 types: (pid_t, int *, int, struct rusage *) args: (upid, stat_addr, options, ru)
+syscall sys_kill nr 62 nbargs 2 types: (pid_t, int) args: (pid, sig)
+syscall sys_newuname nr 63 nbargs 1 types: (struct new_utsname *) args: (name)
+syscall sys_semget nr 64 nbargs 3 types: (key_t, int, int) args: (key, nsems, semflg)
+syscall sys_semop nr 65 nbargs 3 types: (int, struct sembuf *, unsigned) args: (semid, tsops, nsops)
+syscall sys_semctl nr 66 nbargs 4 types: (int, int, int, unsigned long) args: (semid, semnum, cmd, arg)
+syscall sys_shmdt nr 67 nbargs 1 types: (char *) args: (shmaddr)
+syscall sys_msgget nr 68 nbargs 2 types: (key_t, int) args: (key, msgflg)
+syscall sys_msgsnd nr 69 nbargs 4 types: (int, struct msgbuf *, size_t, int) args: (msqid, msgp, msgsz, msgflg)
+syscall sys_msgrcv nr 70 nbargs 5 types: (int, struct msgbuf *, size_t, long, int) args: (msqid, msgp, msgsz, msgtyp, msgflg)
+syscall sys_msgctl nr 71 nbargs 3 types: (int, int, struct msqid_ds *) args: (msqid, cmd, buf)
+syscall sys_fcntl nr 72 nbargs 3 types: (unsigned int, unsigned int, unsigned long) args: (fd, cmd, arg)
+syscall sys_flock nr 73 nbargs 2 types: (unsigned int, unsigned int) args: (fd, cmd)
+syscall sys_fsync nr 74 nbargs 1 types: (unsigned int) args: (fd)
+syscall sys_fdatasync nr 75 nbargs 1 types: (unsigned int) args: (fd)
+syscall sys_truncate nr 76 nbargs 2 types: (const char *, long) args: (path, length)
+syscall sys_ftruncate nr 77 nbargs 2 types: (unsigned int, unsigned long) args: (fd, length)
+syscall sys_getdents nr 78 nbargs 3 types: (unsigned int, struct linux_dirent *, unsigned int) args: (fd, dirent, count)
+syscall sys_getcwd nr 79 nbargs 2 types: (char *, unsigned long) args: (buf, size)
+syscall sys_chdir nr 80 nbargs 1 types: (const char *) args: (filename)
+syscall sys_fchdir nr 81 nbargs 1 types: (unsigned int) args: (fd)
+syscall sys_rename nr 82 nbargs 2 types: (const char *, const char *) args: (oldname, newname)
+syscall sys_mkdir nr 83 nbargs 2 types: (const char *, umode_t) args: (pathname, mode)
+syscall sys_rmdir nr 84 nbargs 1 types: (const char *) args: (pathname)
+syscall sys_creat nr 85 nbargs 2 types: (const char *, umode_t) args: (pathname, mode)
+syscall sys_link nr 86 nbargs 2 types: (const char *, const char *) args: (oldname, newname)
+syscall sys_unlink nr 87 nbargs 1 types: (const char *) args: (pathname)
+syscall sys_symlink nr 88 nbargs 2 types: (const char *, const char *) args: (oldname, newname)
+syscall sys_readlink nr 89 nbargs 3 types: (const char *, char *, int) args: (path, buf, bufsiz)
+syscall sys_chmod nr 90 nbargs 2 types: (const char *, umode_t) args: (filename, mode)
+syscall sys_fchmod nr 91 nbargs 2 types: (unsigned int, umode_t) args: (fd, mode)
+syscall sys_chown nr 92 nbargs 3 types: (const char *, uid_t, gid_t) args: (filename, user, group)
+syscall sys_fchown nr 93 nbargs 3 types: (unsigned int, uid_t, gid_t) args: (fd, user, group)
+syscall sys_lchown nr 94 nbargs 3 types: (const char *, uid_t, gid_t) args: (filename, user, group)
+syscall sys_umask nr 95 nbargs 1 types: (int) args: (mask)
+syscall sys_gettimeofday nr 96 nbargs 2 types: (struct timeval *, struct timezone *) args: (tv, tz)
+syscall sys_getrlimit nr 97 nbargs 2 types: (unsigned int, struct rlimit *) args: (resource, rlim)
+syscall sys_getrusage nr 98 nbargs 2 types: (int, struct rusage *) args: (who, ru)
+syscall sys_sysinfo nr 99 nbargs 1 types: (struct sysinfo *) args: (info)
+syscall sys_times nr 100 nbargs 1 types: (struct tms *) args: (tbuf)
+syscall sys_ptrace nr 101 nbargs 4 types: (long, long, unsigned long, unsigned long) args: (request, pid, addr, data)
+syscall sys_getuid nr 102 nbargs 0 types: () args: ()
+syscall sys_syslog nr 103 nbargs 3 types: (int, char *, int) args: (type, buf, len)
+syscall sys_getgid nr 104 nbargs 0 types: () args: ()
+syscall sys_setuid nr 105 nbargs 1 types: (uid_t) args: (uid)
+syscall sys_setgid nr 106 nbargs 1 types: (gid_t) args: (gid)
+syscall sys_geteuid nr 107 nbargs 0 types: () args: ()
+syscall sys_getegid nr 108 nbargs 0 types: () args: ()
+syscall sys_setpgid nr 109 nbargs 2 types: (pid_t, pid_t) args: (pid, pgid)
+syscall sys_getppid nr 110 nbargs 0 types: () args: ()
+syscall sys_getpgrp nr 111 nbargs 0 types: () args: ()
+syscall sys_setsid nr 112 nbargs 0 types: () args: ()
+syscall sys_setreuid nr 113 nbargs 2 types: (uid_t, uid_t) args: (ruid, euid)
+syscall sys_setregid nr 114 nbargs 2 types: (gid_t, gid_t) args: (rgid, egid)
+syscall sys_getgroups nr 115 nbargs 2 types: (int, gid_t *) args: (gidsetsize, grouplist)
+syscall sys_setgroups nr 116 nbargs 2 types: (int, gid_t *) args: (gidsetsize, grouplist)
+syscall sys_setresuid nr 117 nbargs 3 types: (uid_t, uid_t, uid_t) args: (ruid, euid, suid)
+syscall sys_getresuid nr 118 nbargs 3 types: (uid_t *, uid_t *, uid_t *) args: (ruidp, euidp, suidp)
+syscall sys_setresgid nr 119 nbargs 3 types: (gid_t, gid_t, gid_t) args: (rgid, egid, sgid)
+syscall sys_getresgid nr 120 nbargs 3 types: (gid_t *, gid_t *, gid_t *) args: (rgidp, egidp, sgidp)
+syscall sys_getpgid nr 121 nbargs 1 types: (pid_t) args: (pid)
+syscall sys_setfsuid nr 122 nbargs 1 types: (uid_t) args: (uid)
+syscall sys_setfsgid nr 123 nbargs 1 types: (gid_t) args: (gid)
+syscall sys_getsid nr 124 nbargs 1 types: (pid_t) args: (pid)
+syscall sys_capget nr 125 nbargs 2 types: (cap_user_header_t, cap_user_data_t) args: (header, dataptr)
+syscall sys_capset nr 126 nbargs 2 types: (cap_user_header_t, const cap_user_data_t) args: (header, data)
+syscall sys_rt_sigpending nr 127 nbargs 2 types: (sigset_t *, size_t) args: (uset, sigsetsize)
+syscall sys_rt_sigtimedwait nr 128 nbargs 4 types: (const sigset_t *, siginfo_t *, const struct timespec *, size_t) args: (uthese, uinfo, uts, sigsetsize)
+syscall sys_rt_sigqueueinfo nr 129 nbargs 3 types: (pid_t, int, siginfo_t *) args: (pid, sig, uinfo)
+syscall sys_rt_sigsuspend nr 130 nbargs 2 types: (sigset_t *, size_t) args: (unewset, sigsetsize)
+syscall sys_sigaltstack nr 131 nbargs 2 types: (const stack_t *, stack_t *) args: (uss, uoss)
+syscall sys_utime nr 132 nbargs 2 types: (char *, struct utimbuf *) args: (filename, times)
+syscall sys_mknod nr 133 nbargs 3 types: (const char *, umode_t, unsigned) args: (filename, mode, dev)
+syscall sys_personality nr 135 nbargs 1 types: (unsigned int) args: (personality)
+syscall sys_ustat nr 136 nbargs 2 types: (unsigned, struct ustat *) args: (dev, ubuf)
+syscall sys_statfs nr 137 nbargs 2 types: (const char *, struct statfs *) args: (pathname, buf)
+syscall sys_fstatfs nr 138 nbargs 2 types: (unsigned int, struct statfs *) args: (fd, buf)
+syscall sys_sysfs nr 139 nbargs 3 types: (int, unsigned long, unsigned long) args: (option, arg1, arg2)
+syscall sys_getpriority nr 140 nbargs 2 types: (int, int) args: (which, who)
+syscall sys_setpriority nr 141 nbargs 3 types: (int, int, int) args: (which, who, niceval)
+syscall sys_sched_setparam nr 142 nbargs 2 types: (pid_t, struct sched_param *) args: (pid, param)
+syscall sys_sched_getparam nr 143 nbargs 2 types: (pid_t, struct sched_param *) args: (pid, param)
+syscall sys_sched_setscheduler nr 144 nbargs 3 types: (pid_t, int, struct sched_param *) args: (pid, policy, param)
+syscall sys_sched_getscheduler nr 145 nbargs 1 types: (pid_t) args: (pid)
+syscall sys_sched_get_priority_max nr 146 nbargs 1 types: (int) args: (policy)
+syscall sys_sched_get_priority_min nr 147 nbargs 1 types: (int) args: (policy)
+syscall sys_sched_rr_get_interval nr 148 nbargs 2 types: (pid_t, struct timespec *) args: (pid, interval)
+syscall sys_mlock nr 149 nbargs 2 types: (unsigned long, size_t) args: (start, len)
+syscall sys_munlock nr 150 nbargs 2 types: (unsigned long, size_t) args: (start, len)
+syscall sys_mlockall nr 151 nbargs 1 types: (int) args: (flags)
+syscall sys_munlockall nr 152 nbargs 0 types: () args: ()
+syscall sys_vhangup nr 153 nbargs 0 types: () args: ()
+syscall sys_pivot_root nr 155 nbargs 2 types: (const char *, const char *) args: (new_root, put_old)
+syscall sys_sysctl nr 156 nbargs 1 types: (struct __sysctl_args *) args: (args)
+syscall sys_prctl nr 157 nbargs 5 types: (int, unsigned long, unsigned long, unsigned long, unsigned long) args: (option, arg2, arg3, arg4, arg5)
+syscall sys_adjtimex nr 159 nbargs 1 types: (struct timex *) args: (txc_p)
+syscall sys_setrlimit nr 160 nbargs 2 types: (unsigned int, struct rlimit *) args: (resource, rlim)
+syscall sys_chroot nr 161 nbargs 1 types: (const char *) args: (filename)
+syscall sys_sync nr 162 nbargs 0 types: () args: ()
+syscall sys_acct nr 163 nbargs 1 types: (const char *) args: (name)
+syscall sys_settimeofday nr 164 nbargs 2 types: (struct timeval *, struct timezone *) args: (tv, tz)
+syscall sys_mount nr 165 nbargs 5 types: (char *, char *, char *, unsigned long, void *) args: (dev_name, dir_name, type, flags, data)
+syscall sys_umount nr 166 nbargs 2 types: (char *, int) args: (name, flags)
+syscall sys_swapon nr 167 nbargs 2 types: (const char *, int) args: (specialfile, swap_flags)
+syscall sys_swapoff nr 168 nbargs 1 types: (const char *) args: (specialfile)
+syscall sys_reboot nr 169 nbargs 4 types: (int, int, unsigned int, void *) args: (magic1, magic2, cmd, arg)
+syscall sys_sethostname nr 170 nbargs 2 types: (char *, int) args: (name, len)
+syscall sys_setdomainname nr 171 nbargs 2 types: (char *, int) args: (name, len)
+syscall sys_init_module nr 175 nbargs 3 types: (void *, unsigned long, const char *) args: (umod, len, uargs)
+syscall sys_delete_module nr 176 nbargs 2 types: (const char *, unsigned int) args: (name_user, flags)
+syscall sys_quotactl nr 179 nbargs 4 types: (unsigned int, const char *, qid_t, void *) args: (cmd, special, id, addr)
+syscall sys_gettid nr 186 nbargs 0 types: () args: ()
+syscall sys_readahead nr 187 nbargs 3 types: (int, loff_t, size_t) args: (fd, offset, count)
+syscall sys_setxattr nr 188 nbargs 5 types: (const char *, const char *, const void *, size_t, int) args: (pathname, name, value, size, flags)
+syscall sys_lsetxattr nr 189 nbargs 5 types: (const char *, const char *, const void *, size_t, int) args: (pathname, name, value, size, flags)
+syscall sys_fsetxattr nr 190 nbargs 5 types: (int, const char *, const void *, size_t, int) args: (fd, name, value, size, flags)
+syscall sys_getxattr nr 191 nbargs 4 types: (const char *, const char *, void *, size_t) args: (pathname, name, value, size)
+syscall sys_lgetxattr nr 192 nbargs 4 types: (const char *, const char *, void *, size_t) args: (pathname, name, value, size)
+syscall sys_fgetxattr nr 193 nbargs 4 types: (int, const char *, void *, size_t) args: (fd, name, value, size)
+syscall sys_listxattr nr 194 nbargs 3 types: (const char *, char *, size_t) args: (pathname, list, size)
+syscall sys_llistxattr nr 195 nbargs 3 types: (const char *, char *, size_t) args: (pathname, list, size)
+syscall sys_flistxattr nr 196 nbargs 3 types: (int, char *, size_t) args: (fd, list, size)
+syscall sys_removexattr nr 197 nbargs 2 types: (const char *, const char *) args: (pathname, name)
+syscall sys_lremovexattr nr 198 nbargs 2 types: (const char *, const char *) args: (pathname, name)
+syscall sys_fremovexattr nr 199 nbargs 2 types: (int, const char *) args: (fd, name)
+syscall sys_tkill nr 200 nbargs 2 types: (pid_t, int) args: (pid, sig)
+syscall sys_time nr 201 nbargs 1 types: (time_t *) args: (tloc)
+syscall sys_futex nr 202 nbargs 6 types: (u32 *, int, u32, struct timespec *, u32 *, u32) args: (uaddr, op, val, utime, uaddr2, val3)
+syscall sys_sched_setaffinity nr 203 nbargs 3 types: (pid_t, unsigned int, unsigned long *) args: (pid, len, user_mask_ptr)
+syscall sys_sched_getaffinity nr 204 nbargs 3 types: (pid_t, unsigned int, unsigned long *) args: (pid, len, user_mask_ptr)
+syscall sys_io_setup nr 206 nbargs 2 types: (unsigned, aio_context_t *) args: (nr_events, ctxp)
+syscall sys_io_destroy nr 207 nbargs 1 types: (aio_context_t) args: (ctx)
+syscall sys_io_getevents nr 208 nbargs 5 types: (aio_context_t, long, long, struct io_event *, struct timespec *) args: (ctx_id, min_nr, nr, events, timeout)
+syscall sys_io_submit nr 209 nbargs 3 types: (aio_context_t, long, struct iocb * *) args: (ctx_id, nr, iocbpp)
+syscall sys_io_cancel nr 210 nbargs 3 types: (aio_context_t, struct iocb *, struct io_event *) args: (ctx_id, iocb, result)
+syscall sys_lookup_dcookie nr 212 nbargs 3 types: (u64, char *, size_t) args: (cookie64, buf, len)
+syscall sys_epoll_create nr 213 nbargs 1 types: (int) args: (size)
+syscall sys_remap_file_pages nr 216 nbargs 5 types: (unsigned long, unsigned long, unsigned long, unsigned long, unsigned long) args: (start, size, prot, pgoff, flags)
+syscall sys_getdents64 nr 217 nbargs 3 types: (unsigned int, struct linux_dirent64 *, unsigned int) args: (fd, dirent, count)
+syscall sys_set_tid_address nr 218 nbargs 1 types: (int *) args: (tidptr)
+syscall sys_restart_syscall nr 219 nbargs 0 types: () args: ()
+syscall sys_semtimedop nr 220 nbargs 4 types: (int, struct sembuf *, unsigned, const struct timespec *) args: (semid, tsops, nsops, timeout)
+syscall sys_fadvise64 nr 221 nbargs 4 types: (int, loff_t, size_t, int) args: (fd, offset, len, advice)
+syscall sys_timer_create nr 222 nbargs 3 types: (const clockid_t, struct sigevent *, timer_t *) args: (which_clock, timer_event_spec, created_timer_id)
+syscall sys_timer_settime nr 223 nbargs 4 types: (timer_t, int, const struct itimerspec *, struct itimerspec *) args: (timer_id, flags, new_setting, old_setting)
+syscall sys_timer_gettime nr 224 nbargs 2 types: (timer_t, struct itimerspec *) args: (timer_id, setting)
+syscall sys_timer_getoverrun nr 225 nbargs 1 types: (timer_t) args: (timer_id)
+syscall sys_timer_delete nr 226 nbargs 1 types: (timer_t) args: (timer_id)
+syscall sys_clock_settime nr 227 nbargs 2 types: (const clockid_t, const struct timespec *) args: (which_clock, tp)
+syscall sys_clock_gettime nr 228 nbargs 2 types: (const clockid_t, struct timespec *) args: (which_clock, tp)
+syscall sys_clock_getres nr 229 nbargs 2 types: (const clockid_t, struct timespec *) args: (which_clock, tp)
+syscall sys_clock_nanosleep nr 230 nbargs 4 types: (const clockid_t, int, const struct timespec *, struct timespec *) args: (which_clock, flags, rqtp, rmtp)
+syscall sys_exit_group nr 231 nbargs 1 types: (int) args: (error_code)
+syscall sys_epoll_wait nr 232 nbargs 4 types: (int, struct epoll_event *, int, int) args: (epfd, events, maxevents, timeout)
+syscall sys_epoll_ctl nr 233 nbargs 4 types: (int, int, int, struct epoll_event *) args: (epfd, op, fd, event)
+syscall sys_tgkill nr 234 nbargs 3 types: (pid_t, pid_t, int) args: (tgid, pid, sig)
+syscall sys_utimes nr 235 nbargs 2 types: (char *, struct timeval *) args: (filename, utimes)
+syscall sys_mbind nr 237 nbargs 6 types: (unsigned long, unsigned long, unsigned long, unsigned long *, unsigned long, unsigned) args: (start, len, mode, nmask, maxnode, flags)
+syscall sys_set_mempolicy nr 238 nbargs 3 types: (int, unsigned long *, unsigned long) args: (mode, nmask, maxnode)
+syscall sys_get_mempolicy nr 239 nbargs 5 types: (int *, unsigned long *, unsigned long, unsigned long, unsigned long) args: (policy, nmask, maxnode, addr, flags)
+syscall sys_mq_open nr 240 nbargs 4 types: (const char *, int, umode_t, struct mq_attr *) args: (u_name, oflag, mode, u_attr)
+syscall sys_mq_unlink nr 241 nbargs 1 types: (const char *) args: (u_name)
+syscall sys_mq_timedsend nr 242 nbargs 5 types: (mqd_t, const char *, size_t, unsigned int, const struct timespec *) args: (mqdes, u_msg_ptr, msg_len, msg_prio, u_abs_timeout)
+syscall sys_mq_timedreceive nr 243 nbargs 5 types: (mqd_t, char *, size_t, unsigned int *, const struct timespec *) args: (mqdes, u_msg_ptr, msg_len, u_msg_prio, u_abs_timeout)
+syscall sys_mq_notify nr 244 nbargs 2 types: (mqd_t, const struct sigevent *) args: (mqdes, u_notification)
+syscall sys_mq_getsetattr nr 245 nbargs 3 types: (mqd_t, const struct mq_attr *, struct mq_attr *) args: (mqdes, u_mqstat, u_omqstat)
+syscall sys_kexec_load nr 246 nbargs 4 types: (unsigned long, unsigned long, struct kexec_segment *, unsigned long) args: (entry, nr_segments, segments, flags)
+syscall sys_waitid nr 247 nbargs 5 types: (int, pid_t, struct siginfo *, int, struct rusage *) args: (which, upid, infop, options, ru)
+syscall sys_add_key nr 248 nbargs 5 types: (const char *, const char *, const void *, size_t, key_serial_t) args: (_type, _description, _payload, plen, ringid)
+syscall sys_request_key nr 249 nbargs 4 types: (const char *, const char *, const char *, key_serial_t) args: (_type, _description, _callout_info, destringid)
+syscall sys_keyctl nr 250 nbargs 5 types: (int, unsigned long, unsigned long, unsigned long, unsigned long) args: (option, arg2, arg3, arg4, arg5)
+syscall sys_ioprio_set nr 251 nbargs 3 types: (int, int, int) args: (which, who, ioprio)
+syscall sys_ioprio_get nr 252 nbargs 2 types: (int, int) args: (which, who)
+syscall sys_inotify_init nr 253 nbargs 0 types: () args: ()
+syscall sys_inotify_add_watch nr 254 nbargs 3 types: (int, const char *, u32) args: (fd, pathname, mask)
+syscall sys_inotify_rm_watch nr 255 nbargs 2 types: (int, __s32) args: (fd, wd)
+syscall sys_migrate_pages nr 256 nbargs 4 types: (pid_t, unsigned long, const unsigned long *, const unsigned long *) args: (pid, maxnode, old_nodes, new_nodes)
+syscall sys_openat nr 257 nbargs 4 types: (int, const char *, int, umode_t) args: (dfd, filename, flags, mode)
+syscall sys_mkdirat nr 258 nbargs 3 types: (int, const char *, umode_t) args: (dfd, pathname, mode)
+syscall sys_mknodat nr 259 nbargs 4 types: (int, const char *, umode_t, unsigned) args: (dfd, filename, mode, dev)
+syscall sys_fchownat nr 260 nbargs 5 types: (int, const char *, uid_t, gid_t, int) args: (dfd, filename, user, group, flag)
+syscall sys_futimesat nr 261 nbargs 3 types: (int, const char *, struct timeval *) args: (dfd, filename, utimes)
+syscall sys_newfstatat nr 262 nbargs 4 types: (int, const char *, struct stat *, int) args: (dfd, filename, statbuf, flag)
+syscall sys_unlinkat nr 263 nbargs 3 types: (int, const char *, int) args: (dfd, pathname, flag)
+syscall sys_renameat nr 264 nbargs 4 types: (int, const char *, int, const char *) args: (olddfd, oldname, newdfd, newname)
+syscall sys_linkat nr 265 nbargs 5 types: (int, const char *, int, const char *, int) args: (olddfd, oldname, newdfd, newname, flags)
+syscall sys_symlinkat nr 266 nbargs 3 types: (const char *, int, const char *) args: (oldname, newdfd, newname)
+syscall sys_readlinkat nr 267 nbargs 4 types: (int, const char *, char *, int) args: (dfd, pathname, buf, bufsiz)
+syscall sys_fchmodat nr 268 nbargs 3 types: (int, const char *, umode_t) args: (dfd, filename, mode)
+syscall sys_faccessat nr 269 nbargs 3 types: (int, const char *, int) args: (dfd, filename, mode)
+syscall sys_pselect6 nr 270 nbargs 6 types: (int, fd_set *, fd_set *, fd_set *, struct timespec *, void *) args: (n, inp, outp, exp, tsp, sig)
+syscall sys_ppoll nr 271 nbargs 5 types: (struct pollfd *, unsigned int, struct timespec *, const sigset_t *, size_t) args: (ufds, nfds, tsp, sigmask, sigsetsize)
+syscall sys_unshare nr 272 nbargs 1 types: (unsigned long) args: (unshare_flags)
+syscall sys_set_robust_list nr 273 nbargs 2 types: (struct robust_list_head *, size_t) args: (head, len)
+syscall sys_get_robust_list nr 274 nbargs 3 types: (int, struct robust_list_head * *, size_t *) args: (pid, head_ptr, len_ptr)
+syscall sys_splice nr 275 nbargs 6 types: (int, loff_t *, int, loff_t *, size_t, unsigned int) args: (fd_in, off_in, fd_out, off_out, len, flags)
+syscall sys_tee nr 276 nbargs 4 types: (int, int, size_t, unsigned int) args: (fdin, fdout, len, flags)
+syscall sys_sync_file_range nr 277 nbargs 4 types: (int, loff_t, loff_t, unsigned int) args: (fd, offset, nbytes, flags)
+syscall sys_vmsplice nr 278 nbargs 4 types: (int, const struct iovec *, unsigned long, unsigned int) args: (fd, iov, nr_segs, flags)
+syscall sys_move_pages nr 279 nbargs 6 types: (pid_t, unsigned long, const void * *, const int *, int *, int) args: (pid, nr_pages, pages, nodes, status, flags)
+syscall sys_utimensat nr 280 nbargs 4 types: (int, const char *, struct timespec *, int) args: (dfd, filename, utimes, flags)
+syscall sys_epoll_pwait nr 281 nbargs 6 types: (int, struct epoll_event *, int, int, const sigset_t *, size_t) args: (epfd, events, maxevents, timeout, sigmask, sigsetsize)
+syscall sys_signalfd nr 282 nbargs 3 types: (int, sigset_t *, size_t) args: (ufd, user_mask, sizemask)
+syscall sys_timerfd_create nr 283 nbargs 2 types: (int, int) args: (clockid, flags)
+syscall sys_eventfd nr 284 nbargs 1 types: (unsigned int) args: (count)
+syscall sys_fallocate nr 285 nbargs 4 types: (int, int, loff_t, loff_t) args: (fd, mode, offset, len)
+syscall sys_timerfd_settime nr 286 nbargs 4 types: (int, int, const struct itimerspec *, struct itimerspec *) args: (ufd, flags, utmr, otmr)
+syscall sys_timerfd_gettime nr 287 nbargs 2 types: (int, struct itimerspec *) args: (ufd, otmr)
+syscall sys_accept4 nr 288 nbargs 4 types: (int, struct sockaddr *, int *, int) args: (fd, upeer_sockaddr, upeer_addrlen, flags)
+syscall sys_signalfd4 nr 289 nbargs 4 types: (int, sigset_t *, size_t, int) args: (ufd, user_mask, sizemask, flags)
+syscall sys_eventfd2 nr 290 nbargs 2 types: (unsigned int, int) args: (count, flags)
+syscall sys_epoll_create1 nr 291 nbargs 1 types: (int) args: (flags)
+syscall sys_dup3 nr 292 nbargs 3 types: (unsigned int, unsigned int, int) args: (oldfd, newfd, flags)
+syscall sys_pipe2 nr 293 nbargs 2 types: (int *, int) args: (fildes, flags)
+syscall sys_inotify_init1 nr 294 nbargs 1 types: (int) args: (flags)
+syscall sys_preadv nr 295 nbargs 5 types: (unsigned long, const struct iovec *, unsigned long, unsigned long, unsigned long) args: (fd, vec, vlen, pos_l, pos_h)
+syscall sys_pwritev nr 296 nbargs 5 types: (unsigned long, const struct iovec *, unsigned long, unsigned long, unsigned long) args: (fd, vec, vlen, pos_l, pos_h)
+syscall sys_rt_tgsigqueueinfo nr 297 nbargs 4 types: (pid_t, pid_t, int, siginfo_t *) args: (tgid, pid, sig, uinfo)
+syscall sys_perf_event_open nr 298 nbargs 5 types: (struct perf_event_attr *, pid_t, int, int, unsigned long) args: (attr_uptr, pid, cpu, group_fd, flags)
+syscall sys_recvmmsg nr 299 nbargs 5 types: (int, struct mmsghdr *, unsigned int, unsigned int, struct timespec *) args: (fd, mmsg, vlen, flags, timeout)
+syscall sys_fanotify_init nr 300 nbargs 2 types: (unsigned int, unsigned int) args: (flags, event_f_flags)
+syscall sys_fanotify_mark nr 301 nbargs 5 types: (int, unsigned int, __u64, int, const char *) args: (fanotify_fd, flags, mask, dfd, pathname)
+syscall sys_prlimit64 nr 302 nbargs 4 types: (pid_t, unsigned int, const struct rlimit64 *, struct rlimit64 *) args: (pid, resource, new_rlim, old_rlim)
+syscall sys_name_to_handle_at nr 303 nbargs 5 types: (int, const char *, struct file_handle *, int *, int) args: (dfd, name, handle, mnt_id, flag)
+syscall sys_open_by_handle_at nr 304 nbargs 3 types: (int, struct file_handle *, int) args: (mountdirfd, handle, flags)
+syscall sys_clock_adjtime nr 305 nbargs 2 types: (const clockid_t, struct timex *) args: (which_clock, utx)
+syscall sys_syncfs nr 306 nbargs 1 types: (int) args: (fd)
+syscall sys_sendmmsg nr 307 nbargs 4 types: (int, struct mmsghdr *, unsigned int, unsigned int) args: (fd, mmsg, vlen, flags)
+syscall sys_setns nr 308 nbargs 2 types: (int, int) args: (fd, nstype)
+syscall sys_getcpu nr 309 nbargs 3 types: (unsigned *, unsigned *, struct getcpu_cache *) args: (cpup, nodep, unused)
+syscall sys_process_vm_readv nr 310 nbargs 6 types: (pid_t, const struct iovec *, unsigned long, const struct iovec *, unsigned long, unsigned long) args: (pid, lvec, liovcnt, rvec, riovcnt, flags)
+syscall sys_process_vm_writev nr 311 nbargs 6 types: (pid_t, const struct iovec *, unsigned long, const struct iovec *, unsigned long, unsigned long) args: (pid, lvec, liovcnt, rvec, riovcnt, flags)
+syscall sys_finit_module nr 313 nbargs 3 types: (int, const char *, int) args: (fd, uargs, flags)
+SUCCESS
diff --git a/drivers/staging/lttng/instrumentation/syscalls/3.4.25/arm-32-syscalls-3.4.25 b/drivers/staging/lttng/instrumentation/syscalls/3.4.25/arm-32-syscalls-3.4.25
new file mode 100644 (file)
index 0000000..65c3973
--- /dev/null
@@ -0,0 +1,299 @@
+syscall sys_restart_syscall nr 0 nbargs 0 types: () args: ()
+syscall sys_exit nr 1 nbargs 1 types: (int) args: (error_code)
+syscall sys_read nr 3 nbargs 3 types: (unsigned int, char *, size_t) args: (fd, buf, count)
+syscall sys_write nr 4 nbargs 3 types: (unsigned int, const char *, size_t) args: (fd, buf, count)
+syscall sys_open nr 5 nbargs 3 types: (const char *, int, umode_t) args: (filename, flags, mode)
+syscall sys_close nr 6 nbargs 1 types: (unsigned int) args: (fd)
+syscall sys_creat nr 8 nbargs 2 types: (const char *, umode_t) args: (pathname, mode)
+syscall sys_link nr 9 nbargs 2 types: (const char *, const char *) args: (oldname, newname)
+syscall sys_unlink nr 10 nbargs 1 types: (const char *) args: (pathname)
+syscall sys_chdir nr 12 nbargs 1 types: (const char *) args: (filename)
+syscall sys_mknod nr 14 nbargs 3 types: (const char *, umode_t, unsigned) args: (filename, mode, dev)
+syscall sys_chmod nr 15 nbargs 2 types: (const char *, umode_t) args: (filename, mode)
+syscall sys_lchown16 nr 16 nbargs 3 types: (const char *, old_uid_t, old_gid_t) args: (filename, user, group)
+syscall sys_lseek nr 19 nbargs 3 types: (unsigned int, off_t, unsigned int) args: (fd, offset, origin)
+syscall sys_getpid nr 20 nbargs 0 types: () args: ()
+syscall sys_mount nr 21 nbargs 5 types: (char *, char *, char *, unsigned long, void *) args: (dev_name, dir_name, type, flags, data)
+syscall sys_setuid16 nr 23 nbargs 1 types: (old_uid_t) args: (uid)
+syscall sys_getuid16 nr 24 nbargs 0 types: () args: ()
+syscall sys_ptrace nr 26 nbargs 4 types: (long, long, unsigned long, unsigned long) args: (request, pid, addr, data)
+syscall sys_pause nr 29 nbargs 0 types: () args: ()
+syscall sys_access nr 33 nbargs 2 types: (const char *, int) args: (filename, mode)
+syscall sys_nice nr 34 nbargs 1 types: (int) args: (increment)
+syscall sys_sync nr 36 nbargs 0 types: () args: ()
+syscall sys_kill nr 37 nbargs 2 types: (pid_t, int) args: (pid, sig)
+syscall sys_rename nr 38 nbargs 2 types: (const char *, const char *) args: (oldname, newname)
+syscall sys_mkdir nr 39 nbargs 2 types: (const char *, umode_t) args: (pathname, mode)
+syscall sys_rmdir nr 40 nbargs 1 types: (const char *) args: (pathname)
+syscall sys_dup nr 41 nbargs 1 types: (unsigned int) args: (fildes)
+syscall sys_pipe nr 42 nbargs 1 types: (int *) args: (fildes)
+syscall sys_times nr 43 nbargs 1 types: (struct tms *) args: (tbuf)
+syscall sys_brk nr 45 nbargs 1 types: (unsigned long) args: (brk)
+syscall sys_setgid16 nr 46 nbargs 1 types: (old_gid_t) args: (gid)
+syscall sys_getgid16 nr 47 nbargs 0 types: () args: ()
+syscall sys_geteuid16 nr 49 nbargs 0 types: () args: ()
+syscall sys_getegid16 nr 50 nbargs 0 types: () args: ()
+syscall sys_acct nr 51 nbargs 1 types: (const char *) args: (name)
+syscall sys_umount nr 52 nbargs 2 types: (char *, int) args: (name, flags)
+syscall sys_ioctl nr 54 nbargs 3 types: (unsigned int, unsigned int, unsigned long) args: (fd, cmd, arg)
+syscall sys_fcntl nr 55 nbargs 3 types: (unsigned int, unsigned int, unsigned long) args: (fd, cmd, arg)
+syscall sys_setpgid nr 57 nbargs 2 types: (pid_t, pid_t) args: (pid, pgid)
+syscall sys_umask nr 60 nbargs 1 types: (int) args: (mask)
+syscall sys_chroot nr 61 nbargs 1 types: (const char *) args: (filename)
+syscall sys_ustat nr 62 nbargs 2 types: (unsigned, struct ustat *) args: (dev, ubuf)
+syscall sys_dup2 nr 63 nbargs 2 types: (unsigned int, unsigned int) args: (oldfd, newfd)
+syscall sys_getppid nr 64 nbargs 0 types: () args: ()
+syscall sys_getpgrp nr 65 nbargs 0 types: () args: ()
+syscall sys_setsid nr 66 nbargs 0 types: () args: ()
+syscall sys_setreuid16 nr 70 nbargs 2 types: (old_uid_t, old_uid_t) args: (ruid, euid)
+syscall sys_setregid16 nr 71 nbargs 2 types: (old_gid_t, old_gid_t) args: (rgid, egid)
+syscall sys_sigpending nr 73 nbargs 1 types: (old_sigset_t *) args: (set)
+syscall sys_sethostname nr 74 nbargs 2 types: (char *, int) args: (name, len)
+syscall sys_setrlimit nr 75 nbargs 2 types: (unsigned int, struct rlimit *) args: (resource, rlim)
+syscall sys_getrusage nr 77 nbargs 2 types: (int, struct rusage *) args: (who, ru)
+syscall sys_gettimeofday nr 78 nbargs 2 types: (struct timeval *, struct timezone *) args: (tv, tz)
+syscall sys_settimeofday nr 79 nbargs 2 types: (struct timeval *, struct timezone *) args: (tv, tz)
+syscall sys_getgroups16 nr 80 nbargs 2 types: (int, old_gid_t *) args: (gidsetsize, grouplist)
+syscall sys_setgroups16 nr 81 nbargs 2 types: (int, old_gid_t *) args: (gidsetsize, grouplist)
+syscall sys_symlink nr 83 nbargs 2 types: (const char *, const char *) args: (oldname, newname)
+syscall sys_readlink nr 85 nbargs 3 types: (const char *, char *, int) args: (path, buf, bufsiz)
+syscall sys_uselib nr 86 nbargs 1 types: (const char *) args: (library)
+syscall sys_swapon nr 87 nbargs 2 types: (const char *, int) args: (specialfile, swap_flags)
+syscall sys_reboot nr 88 nbargs 4 types: (int, int, unsigned int, void *) args: (magic1, magic2, cmd, arg)
+syscall sys_munmap nr 91 nbargs 2 types: (unsigned long, size_t) args: (addr, len)
+syscall sys_truncate nr 92 nbargs 2 types: (const char *, long) args: (path, length)
+syscall sys_ftruncate nr 93 nbargs 2 types: (unsigned int, unsigned long) args: (fd, length)
+syscall sys_fchmod nr 94 nbargs 2 types: (unsigned int, umode_t) args: (fd, mode)
+syscall sys_fchown16 nr 95 nbargs 3 types: (unsigned int, old_uid_t, old_gid_t) args: (fd, user, group)
+syscall sys_getpriority nr 96 nbargs 2 types: (int, int) args: (which, who)
+syscall sys_setpriority nr 97 nbargs 3 types: (int, int, int) args: (which, who, niceval)
+syscall sys_statfs nr 99 nbargs 2 types: (const char *, struct statfs *) args: (pathname, buf)
+syscall sys_fstatfs nr 100 nbargs 2 types: (unsigned int, struct statfs *) args: (fd, buf)
+syscall sys_syslog nr 103 nbargs 3 types: (int, char *, int) args: (type, buf, len)
+syscall sys_setitimer nr 104 nbargs 3 types: (int, struct itimerval *, struct itimerval *) args: (which, value, ovalue)
+syscall sys_getitimer nr 105 nbargs 2 types: (int, struct itimerval *) args: (which, value)
+syscall sys_newstat nr 106 nbargs 2 types: (const char *, struct stat *) args: (filename, statbuf)
+syscall sys_newlstat nr 107 nbargs 2 types: (const char *, struct stat *) args: (filename, statbuf)
+syscall sys_newfstat nr 108 nbargs 2 types: (unsigned int, struct stat *) args: (fd, statbuf)
+syscall sys_vhangup nr 111 nbargs 0 types: () args: ()
+syscall sys_wait4 nr 114 nbargs 4 types: (pid_t, int *, int, struct rusage *) args: (upid, stat_addr, options, ru)
+syscall sys_swapoff nr 115 nbargs 1 types: (const char *) args: (specialfile)
+syscall sys_sysinfo nr 116 nbargs 1 types: (struct sysinfo *) args: (info)
+syscall sys_fsync nr 118 nbargs 1 types: (unsigned int) args: (fd)
+syscall sys_setdomainname nr 121 nbargs 2 types: (char *, int) args: (name, len)
+syscall sys_newuname nr 122 nbargs 1 types: (struct new_utsname *) args: (name)
+syscall sys_adjtimex nr 124 nbargs 1 types: (struct timex *) args: (txc_p)
+syscall sys_mprotect nr 125 nbargs 3 types: (unsigned long, size_t, unsigned long) args: (start, len, prot)
+syscall sys_sigprocmask nr 126 nbargs 3 types: (int, old_sigset_t *, old_sigset_t *) args: (how, nset, oset)
+syscall sys_init_module nr 128 nbargs 3 types: (void *, unsigned long, const char *) args: (umod, len, uargs)
+syscall sys_delete_module nr 129 nbargs 2 types: (const char *, unsigned int) args: (name_user, flags)
+syscall sys_quotactl nr 131 nbargs 4 types: (unsigned int, const char *, qid_t, void *) args: (cmd, special, id, addr)
+syscall sys_getpgid nr 132 nbargs 1 types: (pid_t) args: (pid)
+syscall sys_fchdir nr 133 nbargs 1 types: (unsigned int) args: (fd)
+syscall sys_bdflush nr 134 nbargs 2 types: (int, long) args: (func, data)
+syscall sys_sysfs nr 135 nbargs 3 types: (int, unsigned long, unsigned long) args: (option, arg1, arg2)
+syscall sys_personality nr 136 nbargs 1 types: (unsigned int) args: (personality)
+syscall sys_setfsuid16 nr 138 nbargs 1 types: (old_uid_t) args: (uid)
+syscall sys_setfsgid16 nr 139 nbargs 1 types: (old_gid_t) args: (gid)
+syscall sys_llseek nr 140 nbargs 5 types: (unsigned int, unsigned long, unsigned long, loff_t *, unsigned int) args: (fd, offset_high, offset_low, result, origin)
+syscall sys_getdents nr 141 nbargs 3 types: (unsigned int, struct linux_dirent *, unsigned int) args: (fd, dirent, count)
+syscall sys_select nr 142 nbargs 5 types: (int, fd_set *, fd_set *, fd_set *, struct timeval *) args: (n, inp, outp, exp, tvp)
+syscall sys_flock nr 143 nbargs 2 types: (unsigned int, unsigned int) args: (fd, cmd)
+syscall sys_msync nr 144 nbargs 3 types: (unsigned long, size_t, int) args: (start, len, flags)
+syscall sys_readv nr 145 nbargs 3 types: (unsigned long, const struct iovec *, unsigned long) args: (fd, vec, vlen)
+syscall sys_writev nr 146 nbargs 3 types: (unsigned long, const struct iovec *, unsigned long) args: (fd, vec, vlen)
+syscall sys_getsid nr 147 nbargs 1 types: (pid_t) args: (pid)
+syscall sys_fdatasync nr 148 nbargs 1 types: (unsigned int) args: (fd)
+syscall sys_sysctl nr 149 nbargs 1 types: (struct __sysctl_args *) args: (args)
+syscall sys_mlock nr 150 nbargs 2 types: (unsigned long, size_t) args: (start, len)
+syscall sys_munlock nr 151 nbargs 2 types: (unsigned long, size_t) args: (start, len)
+syscall sys_mlockall nr 152 nbargs 1 types: (int) args: (flags)
+syscall sys_munlockall nr 153 nbargs 0 types: () args: ()
+syscall sys_sched_setparam nr 154 nbargs 2 types: (pid_t, struct sched_param *) args: (pid, param)
+syscall sys_sched_getparam nr 155 nbargs 2 types: (pid_t, struct sched_param *) args: (pid, param)
+syscall sys_sched_setscheduler nr 156 nbargs 3 types: (pid_t, int, struct sched_param *) args: (pid, policy, param)
+syscall sys_sched_getscheduler nr 157 nbargs 1 types: (pid_t) args: (pid)
+syscall sys_sched_yield nr 158 nbargs 0 types: () args: ()
+syscall sys_sched_get_priority_max nr 159 nbargs 1 types: (int) args: (policy)
+syscall sys_sched_get_priority_min nr 160 nbargs 1 types: (int) args: (policy)
+syscall sys_sched_rr_get_interval nr 161 nbargs 2 types: (pid_t, struct timespec *) args: (pid, interval)
+syscall sys_nanosleep nr 162 nbargs 2 types: (struct timespec *, struct timespec *) args: (rqtp, rmtp)
+syscall sys_mremap nr 163 nbargs 5 types: (unsigned long, unsigned long, unsigned long, unsigned long, unsigned long) args: (addr, old_len, new_len, flags, new_addr)
+syscall sys_setresuid16 nr 164 nbargs 3 types: (old_uid_t, old_uid_t, old_uid_t) args: (ruid, euid, suid)
+syscall sys_getresuid16 nr 165 nbargs 3 types: (old_uid_t *, old_uid_t *, old_uid_t *) args: (ruid, euid, suid)
+syscall sys_poll nr 168 nbargs 3 types: (struct pollfd *, unsigned int, int) args: (ufds, nfds, timeout_msecs)
+syscall sys_setresgid16 nr 170 nbargs 3 types: (old_gid_t, old_gid_t, old_gid_t) args: (rgid, egid, sgid)
+syscall sys_getresgid16 nr 171 nbargs 3 types: (old_gid_t *, old_gid_t *, old_gid_t *) args: (rgid, egid, sgid)
+syscall sys_prctl nr 172 nbargs 5 types: (int, unsigned long, unsigned long, unsigned long, unsigned long) args: (option, arg2, arg3, arg4, arg5)
+syscall sys_rt_sigaction nr 174 nbargs 4 types: (int, const struct sigaction *, struct sigaction *, size_t) args: (sig, act, oact, sigsetsize)
+syscall sys_rt_sigprocmask nr 175 nbargs 4 types: (int, sigset_t *, sigset_t *, size_t) args: (how, nset, oset, sigsetsize)
+syscall sys_rt_sigpending nr 176 nbargs 2 types: (sigset_t *, size_t) args: (set, sigsetsize)
+syscall sys_rt_sigtimedwait nr 177 nbargs 4 types: (const sigset_t *, siginfo_t *, const struct timespec *, size_t) args: (uthese, uinfo, uts, sigsetsize)
+syscall sys_rt_sigqueueinfo nr 178 nbargs 3 types: (pid_t, int, siginfo_t *) args: (pid, sig, uinfo)
+syscall sys_rt_sigsuspend nr 179 nbargs 2 types: (sigset_t *, size_t) args: (unewset, sigsetsize)
+syscall sys_chown16 nr 182 nbargs 3 types: (const char *, old_uid_t, old_gid_t) args: (filename, user, group)
+syscall sys_getcwd nr 183 nbargs 2 types: (char *, unsigned long) args: (buf, size)
+syscall sys_capget nr 184 nbargs 2 types: (cap_user_header_t, cap_user_data_t) args: (header, dataptr)
+syscall sys_capset nr 185 nbargs 2 types: (cap_user_header_t, const cap_user_data_t) args: (header, data)
+syscall sys_sendfile nr 187 nbargs 4 types: (int, int, off_t *, size_t) args: (out_fd, in_fd, offset, count)
+syscall sys_getrlimit nr 191 nbargs 2 types: (unsigned int, struct rlimit *) args: (resource, rlim)
+syscall sys_stat64 nr 195 nbargs 2 types: (const char *, struct stat64 *) args: (filename, statbuf)
+syscall sys_lstat64 nr 196 nbargs 2 types: (const char *, struct stat64 *) args: (filename, statbuf)
+syscall sys_fstat64 nr 197 nbargs 2 types: (unsigned long, struct stat64 *) args: (fd, statbuf)
+syscall sys_lchown nr 198 nbargs 3 types: (const char *, uid_t, gid_t) args: (filename, user, group)
+syscall sys_getuid nr 199 nbargs 0 types: () args: ()
+syscall sys_getgid nr 200 nbargs 0 types: () args: ()
+syscall sys_geteuid nr 201 nbargs 0 types: () args: ()
+syscall sys_getegid nr 202 nbargs 0 types: () args: ()
+syscall sys_setreuid nr 203 nbargs 2 types: (uid_t, uid_t) args: (ruid, euid)
+syscall sys_setregid nr 204 nbargs 2 types: (gid_t, gid_t) args: (rgid, egid)
+syscall sys_getgroups nr 205 nbargs 2 types: (int, gid_t *) args: (gidsetsize, grouplist)
+syscall sys_setgroups nr 206 nbargs 2 types: (int, gid_t *) args: (gidsetsize, grouplist)
+syscall sys_fchown nr 207 nbargs 3 types: (unsigned int, uid_t, gid_t) args: (fd, user, group)
+syscall sys_setresuid nr 208 nbargs 3 types: (uid_t, uid_t, uid_t) args: (ruid, euid, suid)
+syscall sys_getresuid nr 209 nbargs 3 types: (uid_t *, uid_t *, uid_t *) args: (ruid, euid, suid)
+syscall sys_setresgid nr 210 nbargs 3 types: (gid_t, gid_t, gid_t) args: (rgid, egid, sgid)
+syscall sys_getresgid nr 211 nbargs 3 types: (gid_t *, gid_t *, gid_t *) args: (rgid, egid, sgid)
+syscall sys_chown nr 212 nbargs 3 types: (const char *, uid_t, gid_t) args: (filename, user, group)
+syscall sys_setuid nr 213 nbargs 1 types: (uid_t) args: (uid)
+syscall sys_setgid nr 214 nbargs 1 types: (gid_t) args: (gid)
+syscall sys_setfsuid nr 215 nbargs 1 types: (uid_t) args: (uid)
+syscall sys_setfsgid nr 216 nbargs 1 types: (gid_t) args: (gid)
+syscall sys_getdents64 nr 217 nbargs 3 types: (unsigned int, struct linux_dirent64 *, unsigned int) args: (fd, dirent, count)
+syscall sys_pivot_root nr 218 nbargs 2 types: (const char *, const char *) args: (new_root, put_old)
+syscall sys_mincore nr 219 nbargs 3 types: (unsigned long, size_t, unsigned char *) args: (start, len, vec)
+syscall sys_madvise nr 220 nbargs 3 types: (unsigned long, size_t, int) args: (start, len_in, behavior)
+syscall sys_fcntl64 nr 221 nbargs 3 types: (unsigned int, unsigned int, unsigned long) args: (fd, cmd, arg)
+syscall sys_gettid nr 224 nbargs 0 types: () args: ()
+syscall sys_setxattr nr 226 nbargs 5 types: (const char *, const char *, const void *, size_t, int) args: (pathname, name, value, size, flags)
+syscall sys_lsetxattr nr 227 nbargs 5 types: (const char *, const char *, const void *, size_t, int) args: (pathname, name, value, size, flags)
+syscall sys_fsetxattr nr 228 nbargs 5 types: (int, const char *, const void *, size_t, int) args: (fd, name, value, size, flags)
+syscall sys_getxattr nr 229 nbargs 4 types: (const char *, const char *, void *, size_t) args: (pathname, name, value, size)
+syscall sys_lgetxattr nr 230 nbargs 4 types: (const char *, const char *, void *, size_t) args: (pathname, name, value, size)
+syscall sys_fgetxattr nr 231 nbargs 4 types: (int, const char *, void *, size_t) args: (fd, name, value, size)
+syscall sys_listxattr nr 232 nbargs 3 types: (const char *, char *, size_t) args: (pathname, list, size)
+syscall sys_llistxattr nr 233 nbargs 3 types: (const char *, char *, size_t) args: (pathname, list, size)
+syscall sys_flistxattr nr 234 nbargs 3 types: (int, char *, size_t) args: (fd, list, size)
+syscall sys_removexattr nr 235 nbargs 2 types: (const char *, const char *) args: (pathname, name)
+syscall sys_lremovexattr nr 236 nbargs 2 types: (const char *, const char *) args: (pathname, name)
+syscall sys_fremovexattr nr 237 nbargs 2 types: (int, const char *) args: (fd, name)
+syscall sys_tkill nr 238 nbargs 2 types: (pid_t, int) args: (pid, sig)
+syscall sys_sendfile64 nr 239 nbargs 4 types: (int, int, loff_t *, size_t) args: (out_fd, in_fd, offset, count)
+syscall sys_futex nr 240 nbargs 6 types: (u32 *, int, u32, struct timespec *, u32 *, u32) args: (uaddr, op, val, utime, uaddr2, val3)
+syscall sys_sched_setaffinity nr 241 nbargs 3 types: (pid_t, unsigned int, unsigned long *) args: (pid, len, user_mask_ptr)
+syscall sys_sched_getaffinity nr 242 nbargs 3 types: (pid_t, unsigned int, unsigned long *) args: (pid, len, user_mask_ptr)
+syscall sys_io_setup nr 243 nbargs 2 types: (unsigned, aio_context_t *) args: (nr_events, ctxp)
+syscall sys_io_destroy nr 244 nbargs 1 types: (aio_context_t) args: (ctx)
+syscall sys_io_getevents nr 245 nbargs 5 types: (aio_context_t, long, long, struct io_event *, struct timespec *) args: (ctx_id, min_nr, nr, events, timeout)
+syscall sys_io_submit nr 246 nbargs 3 types: (aio_context_t, long, struct iocb * *) args: (ctx_id, nr, iocbpp)
+syscall sys_io_cancel nr 247 nbargs 3 types: (aio_context_t, struct iocb *, struct io_event *) args: (ctx_id, iocb, result)
+syscall sys_exit_group nr 248 nbargs 1 types: (int) args: (error_code)
+syscall sys_epoll_create nr 250 nbargs 1 types: (int) args: (size)
+syscall sys_epoll_ctl nr 251 nbargs 4 types: (int, int, int, struct epoll_event *) args: (epfd, op, fd, event)
+syscall sys_epoll_wait nr 252 nbargs 4 types: (int, struct epoll_event *, int, int) args: (epfd, events, maxevents, timeout)
+syscall sys_remap_file_pages nr 253 nbargs 5 types: (unsigned long, unsigned long, unsigned long, unsigned long, unsigned long) args: (start, size, prot, pgoff, flags)
+syscall sys_set_tid_address nr 256 nbargs 1 types: (int *) args: (tidptr)
+syscall sys_timer_create nr 257 nbargs 3 types: (const clockid_t, struct sigevent *, timer_t *) args: (which_clock, timer_event_spec, created_timer_id)
+syscall sys_timer_settime nr 258 nbargs 4 types: (timer_t, int, const struct itimerspec *, struct itimerspec *) args: (timer_id, flags, new_setting, old_setting)
+syscall sys_timer_gettime nr 259 nbargs 2 types: (timer_t, struct itimerspec *) args: (timer_id, setting)
+syscall sys_timer_getoverrun nr 260 nbargs 1 types: (timer_t) args: (timer_id)
+syscall sys_timer_delete nr 261 nbargs 1 types: (timer_t) args: (timer_id)
+syscall sys_clock_settime nr 262 nbargs 2 types: (const clockid_t, const struct timespec *) args: (which_clock, tp)
+syscall sys_clock_gettime nr 263 nbargs 2 types: (const clockid_t, struct timespec *) args: (which_clock, tp)
+syscall sys_clock_getres nr 264 nbargs 2 types: (const clockid_t, struct timespec *) args: (which_clock, tp)
+syscall sys_clock_nanosleep nr 265 nbargs 4 types: (const clockid_t, int, const struct timespec *, struct timespec *) args: (which_clock, flags, rqtp, rmtp)
+syscall sys_tgkill nr 268 nbargs 3 types: (pid_t, pid_t, int) args: (tgid, pid, sig)
+syscall sys_utimes nr 269 nbargs 2 types: (char *, struct timeval *) args: (filename, utimes)
+syscall sys_mq_open nr 274 nbargs 4 types: (const char *, int, umode_t, struct mq_attr *) args: (u_name, oflag, mode, u_attr)
+syscall sys_mq_unlink nr 275 nbargs 1 types: (const char *) args: (u_name)
+syscall sys_mq_timedsend nr 276 nbargs 5 types: (mqd_t, const char *, size_t, unsigned int, const struct timespec *) args: (mqdes, u_msg_ptr, msg_len, msg_prio, u_abs_timeout)
+syscall sys_mq_timedreceive nr 277 nbargs 5 types: (mqd_t, char *, size_t, unsigned int *, const struct timespec *) args: (mqdes, u_msg_ptr, msg_len, u_msg_prio, u_abs_timeout)
+syscall sys_mq_notify nr 278 nbargs 2 types: (mqd_t, const struct sigevent *) args: (mqdes, u_notification)
+syscall sys_mq_getsetattr nr 279 nbargs 3 types: (mqd_t, const struct mq_attr *, struct mq_attr *) args: (mqdes, u_mqstat, u_omqstat)
+syscall sys_waitid nr 280 nbargs 5 types: (int, pid_t, struct siginfo *, int, struct rusage *) args: (which, upid, infop, options, ru)
+syscall sys_socket nr 281 nbargs 3 types: (int, int, int) args: (family, type, protocol)
+syscall sys_bind nr 282 nbargs 3 types: (int, struct sockaddr *, int) args: (fd, umyaddr, addrlen)
+syscall sys_connect nr 283 nbargs 3 types: (int, struct sockaddr *, int) args: (fd, uservaddr, addrlen)
+syscall sys_listen nr 284 nbargs 2 types: (int, int) args: (fd, backlog)
+syscall sys_accept nr 285 nbargs 3 types: (int, struct sockaddr *, int *) args: (fd, upeer_sockaddr, upeer_addrlen)
+syscall sys_getsockname nr 286 nbargs 3 types: (int, struct sockaddr *, int *) args: (fd, usockaddr, usockaddr_len)
+syscall sys_getpeername nr 287 nbargs 3 types: (int, struct sockaddr *, int *) args: (fd, usockaddr, usockaddr_len)
+syscall sys_socketpair nr 288 nbargs 4 types: (int, int, int, int *) args: (family, type, protocol, usockvec)
+syscall sys_send nr 289 nbargs 4 types: (int, void *, size_t, unsigned) args: (fd, buff, len, flags)
+syscall sys_sendto nr 290 nbargs 6 types: (int, void *, size_t, unsigned, struct sockaddr *, int) args: (fd, buff, len, flags, addr, addr_len)
+syscall sys_recvfrom nr 292 nbargs 6 types: (int, void *, size_t, unsigned, struct sockaddr *, int *) args: (fd, ubuf, size, flags, addr, addr_len)
+syscall sys_shutdown nr 293 nbargs 2 types: (int, int) args: (fd, how)
+syscall sys_setsockopt nr 294 nbargs 5 types: (int, int, int, char *, int) args: (fd, level, optname, optval, optlen)
+syscall sys_getsockopt nr 295 nbargs 5 types: (int, int, int, char *, int *) args: (fd, level, optname, optval, optlen)
+syscall sys_sendmsg nr 296 nbargs 3 types: (int, struct msghdr *, unsigned) args: (fd, msg, flags)
+syscall sys_recvmsg nr 297 nbargs 3 types: (int, struct msghdr *, unsigned int) args: (fd, msg, flags)
+syscall sys_semop nr 298 nbargs 3 types: (int, struct sembuf *, unsigned) args: (semid, tsops, nsops)
+syscall sys_semget nr 299 nbargs 3 types: (key_t, int, int) args: (key, nsems, semflg)
+syscall sys_msgsnd nr 301 nbargs 4 types: (int, struct msgbuf *, size_t, int) args: (msqid, msgp, msgsz, msgflg)
+syscall sys_msgrcv nr 302 nbargs 5 types: (int, struct msgbuf *, size_t, long, int) args: (msqid, msgp, msgsz, msgtyp, msgflg)
+syscall sys_msgget nr 303 nbargs 2 types: (key_t, int) args: (key, msgflg)
+syscall sys_msgctl nr 304 nbargs 3 types: (int, int, struct msqid_ds *) args: (msqid, cmd, buf)
+syscall sys_shmat nr 305 nbargs 3 types: (int, char *, int) args: (shmid, shmaddr, shmflg)
+syscall sys_shmdt nr 306 nbargs 1 types: (char *) args: (shmaddr)
+syscall sys_shmget nr 307 nbargs 3 types: (key_t, size_t, int) args: (key, size, shmflg)
+syscall sys_shmctl nr 308 nbargs 3 types: (int, int, struct shmid_ds *) args: (shmid, cmd, buf)
+syscall sys_add_key nr 309 nbargs 5 types: (const char *, const char *, const void *, size_t, key_serial_t) args: (_type, _description, _payload, plen, ringid)
+syscall sys_request_key nr 310 nbargs 4 types: (const char *, const char *, const char *, key_serial_t) args: (_type, _description, _callout_info, destringid)
+syscall sys_keyctl nr 311 nbargs 5 types: (int, unsigned long, unsigned long, unsigned long, unsigned long) args: (option, arg2, arg3, arg4, arg5)
+syscall sys_semtimedop nr 312 nbargs 4 types: (int, struct sembuf *, unsigned, const struct timespec *) args: (semid, tsops, nsops, timeout)
+syscall sys_ioprio_set nr 314 nbargs 3 types: (int, int, int) args: (which, who, ioprio)
+syscall sys_ioprio_get nr 315 nbargs 2 types: (int, int) args: (which, who)
+syscall sys_inotify_init nr 316 nbargs 0 types: () args: ()
+syscall sys_inotify_add_watch nr 317 nbargs 3 types: (int, const char *, u32) args: (fd, pathname, mask)
+syscall sys_inotify_rm_watch nr 318 nbargs 2 types: (int, __s32) args: (fd, wd)
+syscall sys_openat nr 322 nbargs 4 types: (int, const char *, int, umode_t) args: (dfd, filename, flags, mode)
+syscall sys_mkdirat nr 323 nbargs 3 types: (int, const char *, umode_t) args: (dfd, pathname, mode)
+syscall sys_mknodat nr 324 nbargs 4 types: (int, const char *, umode_t, unsigned) args: (dfd, filename, mode, dev)
+syscall sys_fchownat nr 325 nbargs 5 types: (int, const char *, uid_t, gid_t, int) args: (dfd, filename, user, group, flag)
+syscall sys_futimesat nr 326 nbargs 3 types: (int, const char *, struct timeval *) args: (dfd, filename, utimes)
+syscall sys_fstatat64 nr 327 nbargs 4 types: (int, const char *, struct stat64 *, int) args: (dfd, filename, statbuf, flag)
+syscall sys_unlinkat nr 328 nbargs 3 types: (int, const char *, int) args: (dfd, pathname, flag)
+syscall sys_renameat nr 329 nbargs 4 types: (int, const char *, int, const char *) args: (olddfd, oldname, newdfd, newname)
+syscall sys_linkat nr 330 nbargs 5 types: (int, const char *, int, const char *, int) args: (olddfd, oldname, newdfd, newname, flags)
+syscall sys_symlinkat nr 331 nbargs 3 types: (const char *, int, const char *) args: (oldname, newdfd, newname)
+syscall sys_readlinkat nr 332 nbargs 4 types: (int, const char *, char *, int) args: (dfd, pathname, buf, bufsiz)
+syscall sys_fchmodat nr 333 nbargs 3 types: (int, const char *, umode_t) args: (dfd, filename, mode)
+syscall sys_faccessat nr 334 nbargs 3 types: (int, const char *, int) args: (dfd, filename, mode)
+syscall sys_pselect6 nr 335 nbargs 6 types: (int, fd_set *, fd_set *, fd_set *, struct timespec *, void *) args: (n, inp, outp, exp, tsp, sig)
+syscall sys_ppoll nr 336 nbargs 5 types: (struct pollfd *, unsigned int, struct timespec *, const sigset_t *, size_t) args: (ufds, nfds, tsp, sigmask, sigsetsize)
+syscall sys_unshare nr 337 nbargs 1 types: (unsigned long) args: (unshare_flags)
+syscall sys_set_robust_list nr 338 nbargs 2 types: (struct robust_list_head *, size_t) args: (head, len)
+syscall sys_get_robust_list nr 339 nbargs 3 types: (int, struct robust_list_head * *, size_t *) args: (pid, head_ptr, len_ptr)
+syscall sys_splice nr 340 nbargs 6 types: (int, loff_t *, int, loff_t *, size_t, unsigned int) args: (fd_in, off_in, fd_out, off_out, len, flags)
+syscall sys_tee nr 342 nbargs 4 types: (int, int, size_t, unsigned int) args: (fdin, fdout, len, flags)
+syscall sys_vmsplice nr 343 nbargs 4 types: (int, const struct iovec *, unsigned long, unsigned int) args: (fd, iov, nr_segs, flags)
+syscall sys_getcpu nr 345 nbargs 3 types: (unsigned *, unsigned *, struct getcpu_cache *) args: (cpup, nodep, unused)
+syscall sys_epoll_pwait nr 346 nbargs 6 types: (int, struct epoll_event *, int, int, const sigset_t *, size_t) args: (epfd, events, maxevents, timeout, sigmask, sigsetsize)
+syscall sys_utimensat nr 348 nbargs 4 types: (int, const char *, struct timespec *, int) args: (dfd, filename, utimes, flags)
+syscall sys_signalfd nr 349 nbargs 3 types: (int, sigset_t *, size_t) args: (ufd, user_mask, sizemask)
+syscall sys_timerfd_create nr 350 nbargs 2 types: (int, int) args: (clockid, flags)
+syscall sys_eventfd nr 351 nbargs 1 types: (unsigned int) args: (count)
+syscall sys_timerfd_settime nr 353 nbargs 4 types: (int, int, const struct itimerspec *, struct itimerspec *) args: (ufd, flags, utmr, otmr)
+syscall sys_timerfd_gettime nr 354 nbargs 2 types: (int, struct itimerspec *) args: (ufd, otmr)
+syscall sys_signalfd4 nr 355 nbargs 4 types: (int, sigset_t *, size_t, int) args: (ufd, user_mask, sizemask, flags)
+syscall sys_eventfd2 nr 356 nbargs 2 types: (unsigned int, int) args: (count, flags)
+syscall sys_epoll_create1 nr 357 nbargs 1 types: (int) args: (flags)
+syscall sys_dup3 nr 358 nbargs 3 types: (unsigned int, unsigned int, int) args: (oldfd, newfd, flags)
+syscall sys_pipe2 nr 359 nbargs 2 types: (int *, int) args: (fildes, flags)
+syscall sys_inotify_init1 nr 360 nbargs 1 types: (int) args: (flags)
+syscall sys_preadv nr 361 nbargs 5 types: (unsigned long, const struct iovec *, unsigned long, unsigned long, unsigned long) args: (fd, vec, vlen, pos_l, pos_h)
+syscall sys_pwritev nr 362 nbargs 5 types: (unsigned long, const struct iovec *, unsigned long, unsigned long, unsigned long) args: (fd, vec, vlen, pos_l, pos_h)
+syscall sys_rt_tgsigqueueinfo nr 363 nbargs 4 types: (pid_t, pid_t, int, siginfo_t *) args: (tgid, pid, sig, uinfo)
+syscall sys_perf_event_open nr 364 nbargs 5 types: (struct perf_event_attr *, pid_t, int, int, unsigned long) args: (attr_uptr, pid, cpu, group_fd, flags)
+syscall sys_recvmmsg nr 365 nbargs 5 types: (int, struct mmsghdr *, unsigned int, unsigned int, struct timespec *) args: (fd, mmsg, vlen, flags, timeout)
+syscall sys_accept4 nr 366 nbargs 4 types: (int, struct sockaddr *, int *, int) args: (fd, upeer_sockaddr, upeer_addrlen, flags)
+syscall sys_fanotify_init nr 367 nbargs 2 types: (unsigned int, unsigned int) args: (flags, event_f_flags)
+syscall sys_prlimit64 nr 369 nbargs 4 types: (pid_t, unsigned int, const struct rlimit64 *, struct rlimit64 *) args: (pid, resource, new_rlim, old_rlim)
+syscall sys_name_to_handle_at nr 370 nbargs 5 types: (int, const char *, struct file_handle *, int *, int) args: (dfd, name, handle, mnt_id, flag)
+syscall sys_open_by_handle_at nr 371 nbargs 3 types: (int, struct file_handle *, int) args: (mountdirfd, handle, flags)
+syscall sys_clock_adjtime nr 372 nbargs 2 types: (const clockid_t, struct timex *) args: (which_clock, utx)
+syscall sys_syncfs nr 373 nbargs 1 types: (int) args: (fd)
+syscall sys_sendmmsg nr 374 nbargs 4 types: (int, struct mmsghdr *, unsigned int, unsigned int) args: (fd, mmsg, vlen, flags)
+syscall sys_setns nr 375 nbargs 2 types: (int, int) args: (fd, nstype)
+syscall sys_process_vm_readv nr 376 nbargs 6 types: (pid_t, const struct iovec *, unsigned long, const struct iovec *, unsigned long, unsigned long) args: (pid, lvec, liovcnt, rvec, riovcnt, flags)
+syscall sys_process_vm_writev nr 377 nbargs 6 types: (pid_t, const struct iovec *, unsigned long, const struct iovec *, unsigned long, unsigned long) args: (pid, lvec, liovcnt, rvec, riovcnt, flags)
diff --git a/drivers/staging/lttng/instrumentation/syscalls/3.5.0/mips-32-syscalls-3.5.0 b/drivers/staging/lttng/instrumentation/syscalls/3.5.0/mips-32-syscalls-3.5.0
new file mode 100644 (file)
index 0000000..5b62cc7
--- /dev/null
@@ -0,0 +1,141 @@
+syscall sys_exit nr 4003 nbargs 1 types: (int) args: (error_code)
+syscall sys_read nr 4007 nbargs 3 types: (unsigned int, char *, size_t) args: (fd, buf, count)
+syscall sys_write nr 4009 nbargs 3 types: (unsigned int, const char *, size_t) args: (fd, buf, count)
+syscall sys_open nr 4011 nbargs 3 types: (const char *, int, umode_t) args: (filename, flags, mode)
+syscall sys_close nr 4013 nbargs 1 types: (unsigned int) args: (fd)
+syscall sys_waitpid nr 4015 nbargs 3 types: (pid_t, int *, int) args: (pid, stat_addr, options)
+syscall sys_creat nr 4017 nbargs 2 types: (const char *, umode_t) args: (pathname, mode)
+syscall sys_link nr 4019 nbargs 2 types: (const char *, const char *) args: (oldname, newname)
+syscall sys_unlink nr 4021 nbargs 1 types: (const char *) args: (pathname)
+syscall sys_chdir nr 4025 nbargs 1 types: (const char *) args: (filename)
+syscall sys_time nr 4027 nbargs 1 types: (time_t *) args: (tloc)
+syscall sys_mknod nr 4029 nbargs 3 types: (const char *, umode_t, unsigned) args: (filename, mode, dev)
+syscall sys_chmod nr 4031 nbargs 2 types: (const char *, umode_t) args: (filename, mode)
+syscall sys_lchown nr 4033 nbargs 3 types: (const char *, uid_t, gid_t) args: (filename, user, group)
+syscall sys_lseek nr 4039 nbargs 3 types: (unsigned int, off_t, unsigned int) args: (fd, offset, origin)
+syscall sys_getpid nr 4041 nbargs 0 types: () args: ()
+syscall sys_mount nr 4043 nbargs 5 types: (char *, char *, char *, unsigned long, void *) args: (dev_name, dir_name, type, flags, data)
+syscall sys_oldumount nr 4045 nbargs 1 types: (char *) args: (name)
+syscall sys_setuid nr 4047 nbargs 1 types: (uid_t) args: (uid)
+syscall sys_getuid nr 4049 nbargs 0 types: () args: ()
+syscall sys_stime nr 4051 nbargs 1 types: (time_t *) args: (tptr)
+syscall sys_ptrace nr 4053 nbargs 4 types: (long, long, unsigned long, unsigned long) args: (request, pid, addr, data)
+syscall sys_alarm nr 4055 nbargs 1 types: (unsigned int) args: (seconds)
+syscall sys_pause nr 4059 nbargs 0 types: () args: ()
+syscall sys_utime nr 4061 nbargs 2 types: (char *, struct utimbuf *) args: (filename, times)
+syscall sys_access nr 4067 nbargs 2 types: (const char *, int) args: (filename, mode)
+syscall sys_nice nr 4069 nbargs 1 types: (int) args: (increment)
+syscall sys_sync nr 4073 nbargs 0 types: () args: ()
+syscall sys_kill nr 4075 nbargs 2 types: (pid_t, int) args: (pid, sig)
+syscall sys_rename nr 4077 nbargs 2 types: (const char *, const char *) args: (oldname, newname)
+syscall sys_mkdir nr 4079 nbargs 2 types: (const char *, umode_t) args: (pathname, mode)
+syscall sys_rmdir nr 4081 nbargs 1 types: (const char *) args: (pathname)
+syscall sys_dup nr 4083 nbargs 1 types: (unsigned int) args: (fildes)
+syscall sys_times nr 4087 nbargs 1 types: (struct tms *) args: (tbuf)
+syscall sys_brk nr 4091 nbargs 1 types: (unsigned long) args: (brk)
+syscall sys_setgid nr 4093 nbargs 1 types: (gid_t) args: (gid)
+syscall sys_getgid nr 4095 nbargs 0 types: () args: ()
+syscall sys_geteuid nr 4099 nbargs 0 types: () args: ()
+syscall sys_getegid nr 4101 nbargs 0 types: () args: ()
+syscall sys_umount nr 4105 nbargs 2 types: (char *, int) args: (name, flags)
+syscall sys_ioctl nr 4109 nbargs 3 types: (unsigned int, unsigned int, unsigned long) args: (fd, cmd, arg)
+syscall sys_fcntl nr 4111 nbargs 3 types: (unsigned int, unsigned int, unsigned long) args: (fd, cmd, arg)
+syscall sys_setpgid nr 4115 nbargs 2 types: (pid_t, pid_t) args: (pid, pgid)
+syscall sys_olduname nr 4119 nbargs 1 types: (struct oldold_utsname *) args: (name)
+syscall sys_umask nr 4121 nbargs 1 types: (int) args: (mask)
+syscall sys_chroot nr 4123 nbargs 1 types: (const char *) args: (filename)
+syscall sys_ustat nr 4125 nbargs 2 types: (unsigned, struct ustat *) args: (dev, ubuf)
+syscall sys_dup2 nr 4127 nbargs 2 types: (unsigned int, unsigned int) args: (oldfd, newfd)
+syscall sys_getppid nr 4129 nbargs 0 types: () args: ()
+syscall sys_getpgrp nr 4131 nbargs 0 types: () args: ()
+syscall sys_setsid nr 4133 nbargs 0 types: () args: ()
+syscall sys_sigaction nr 4135 nbargs 3 types: (int, const struct sigaction *, struct sigaction *) args: (sig, act, oact)
+syscall sys_sgetmask nr 4137 nbargs 0 types: () args: ()
+syscall sys_ssetmask nr 4139 nbargs 1 types: (int) args: (newmask)
+syscall sys_setreuid nr 4141 nbargs 2 types: (uid_t, uid_t) args: (ruid, euid)
+syscall sys_setregid nr 4143 nbargs 2 types: (gid_t, gid_t) args: (rgid, egid)
+syscall sys_sigpending nr 4147 nbargs 1 types: (old_sigset_t *) args: (set)
+syscall sys_sethostname nr 4149 nbargs 2 types: (char *, int) args: (name, len)
+syscall sys_setrlimit nr 4151 nbargs 2 types: (unsigned int, struct rlimit *) args: (resource, rlim)
+syscall sys_getrlimit nr 4153 nbargs 2 types: (unsigned int, struct rlimit *) args: (resource, rlim)
+syscall sys_getrusage nr 4155 nbargs 2 types: (int, struct rusage *) args: (who, ru)
+syscall sys_gettimeofday nr 4157 nbargs 2 types: (struct timeval *, struct timezone *) args: (tv, tz)
+syscall sys_settimeofday nr 4159 nbargs 2 types: (struct timeval *, struct timezone *) args: (tv, tz)
+syscall sys_getgroups nr 4161 nbargs 2 types: (int, gid_t *) args: (gidsetsize, grouplist)
+syscall sys_setgroups nr 4163 nbargs 2 types: (int, gid_t *) args: (gidsetsize, grouplist)
+syscall sys_symlink nr 4167 nbargs 2 types: (const char *, const char *) args: (oldname, newname)
+syscall sys_readlink nr 4171 nbargs 3 types: (const char *, char *, int) args: (path, buf, bufsiz)
+syscall sys_uselib nr 4173 nbargs 1 types: (const char *) args: (library)
+syscall sys_swapon nr 4175 nbargs 2 types: (const char *, int) args: (specialfile, swap_flags)
+syscall sys_reboot nr 4177 nbargs 4 types: (int, int, unsigned int, void *) args: (magic1, magic2, cmd, arg)
+syscall sys_old_readdir nr 4179 nbargs 3 types: (unsigned int, struct old_linux_dirent *, unsigned int) args: (fd, dirent, count)
+syscall sys_mips_mmap nr 4181 nbargs 6 types: (unsigned long, unsigned long, unsigned long, unsigned long, unsigned long, off_t) args: (addr, len, prot, flags, fd, offset)
+syscall sys_munmap nr 4183 nbargs 2 types: (unsigned long, size_t) args: (addr, len)
+syscall sys_truncate nr 4185 nbargs 2 types: (const char *, long) args: (path, length)
+syscall sys_ftruncate nr 4187 nbargs 2 types: (unsigned int, unsigned long) args: (fd, length)
+syscall sys_fchmod nr 4189 nbargs 2 types: (unsigned int, umode_t) args: (fd, mode)
+syscall sys_fchown nr 4191 nbargs 3 types: (unsigned int, uid_t, gid_t) args: (fd, user, group)
+syscall sys_getpriority nr 4193 nbargs 2 types: (int, int) args: (which, who)
+syscall sys_setpriority nr 4195 nbargs 3 types: (int, int, int) args: (which, who, niceval)
+syscall sys_statfs nr 4199 nbargs 2 types: (const char *, struct statfs *) args: (pathname, buf)
+syscall sys_fstatfs nr 4201 nbargs 2 types: (unsigned int, struct statfs *) args: (fd, buf)
+syscall sys_socketcall nr 4205 nbargs 2 types: (int, unsigned long *) args: (call, args)
+syscall sys_syslog nr 4207 nbargs 3 types: (int, char *, int) args: (type, buf, len)
+syscall sys_setitimer nr 4209 nbargs 3 types: (int, struct itimerval *, struct itimerval *) args: (which, value, ovalue)
+syscall sys_getitimer nr 4211 nbargs 2 types: (int, struct itimerval *) args: (which, value)
+syscall sys_newstat nr 4213 nbargs 2 types: (const char *, struct stat *) args: (filename, statbuf)
+syscall sys_newlstat nr 4215 nbargs 2 types: (const char *, struct stat *) args: (filename, statbuf)
+syscall sys_newfstat nr 4217 nbargs 2 types: (unsigned int, struct stat *) args: (fd, statbuf)
+syscall sys_uname nr 4219 nbargs 1 types: (struct old_utsname *) args: (name)
+syscall sys_vhangup nr 4223 nbargs 0 types: () args: ()
+syscall sys_wait4 nr 4229 nbargs 4 types: (pid_t, int *, int, struct rusage *) args: (upid, stat_addr, options, ru)
+syscall sys_swapoff nr 4231 nbargs 1 types: (const char *) args: (specialfile)
+syscall sys_sysinfo nr 4233 nbargs 1 types: (struct sysinfo *) args: (info)
+syscall sys_ipc nr 4235 nbargs 6 types: (unsigned int, int, unsigned long, unsigned long, void *, long) args: (call, first, second, third, ptr, fifth)
+syscall sys_fsync nr 4237 nbargs 1 types: (unsigned int) args: (fd)
+syscall sys_setdomainname nr 4243 nbargs 2 types: (char *, int) args: (name, len)
+syscall sys_newuname nr 4245 nbargs 1 types: (struct new_utsname *) args: (name)
+syscall sys_adjtimex nr 4249 nbargs 1 types: (struct timex *) args: (txc_p)
+syscall sys_mprotect nr 4251 nbargs 3 types: (unsigned long, size_t, unsigned long) args: (start, len, prot)
+syscall sys_sigprocmask nr 4253 nbargs 3 types: (int, old_sigset_t *, old_sigset_t *) args: (how, nset, oset)
+syscall sys_init_module nr 4257 nbargs 3 types: (void *, unsigned long, const char *) args: (umod, len, uargs)
+syscall sys_delete_module nr 4259 nbargs 2 types: (const char *, unsigned int) args: (name_user, flags)
+syscall sys_quotactl nr 4263 nbargs 4 types: (unsigned int, const char *, qid_t, void *) args: (cmd, special, id, addr)
+syscall sys_getpgid nr 4265 nbargs 1 types: (pid_t) args: (pid)
+syscall sys_fchdir nr 4267 nbargs 1 types: (unsigned int) args: (fd)
+syscall sys_bdflush nr 4269 nbargs 2 types: (int, long) args: (func, data)
+syscall sys_sysfs nr 4271 nbargs 3 types: (int, unsigned long, unsigned long) args: (option, arg1, arg2)
+syscall sys_personality nr 4273 nbargs 1 types: (unsigned int) args: (personality)
+syscall sys_setfsuid nr 4277 nbargs 1 types: (uid_t) args: (uid)
+syscall sys_setfsgid nr 4279 nbargs 1 types: (gid_t) args: (gid)
+syscall sys_llseek nr 4281 nbargs 5 types: (unsigned int, unsigned long, unsigned long, loff_t *, unsigned int) args: (fd, offset_high, offset_low, result, origin)
+syscall sys_getdents nr 4283 nbargs 3 types: (unsigned int, struct linux_dirent *, unsigned int) args: (fd, dirent, count)
+syscall sys_select nr 4285 nbargs 5 types: (int, fd_set *, fd_set *, fd_set *, struct timeval *) args: (n, inp, outp, exp, tvp)
+syscall sys_flock nr 4287 nbargs 2 types: (unsigned int, unsigned int) args: (fd, cmd)
+syscall sys_msync nr 4289 nbargs 3 types: (unsigned long, size_t, int) args: (start, len, flags)
+syscall sys_readv nr 4291 nbargs 3 types: (unsigned long, const struct iovec *, unsigned long) args: (fd, vec, vlen)
+syscall sys_writev nr 4293 nbargs 3 types: (unsigned long, const struct iovec *, unsigned long) args: (fd, vec, vlen)
+syscall sys_cacheflush nr 4295 nbargs 3 types: (unsigned long, unsigned long, unsigned int) args: (addr, bytes, cache)
+syscall sys_cachectl nr 4297 nbargs 3 types: (char *, int, int) args: (addr, nbytes, op)
+syscall sys_getsid nr 4303 nbargs 1 types: (pid_t) args: (pid)
+syscall sys_fdatasync nr 4305 nbargs 1 types: (unsigned int) args: (fd)
+syscall sys_sysctl nr 4307 nbargs 1 types: (struct __sysctl_args *) args: (args)
+syscall sys_mlock nr 4309 nbargs 2 types: (unsigned long, size_t) args: (start, len)
+syscall sys_munlock nr 4311 nbargs 2 types: (unsigned long, size_t) args: (start, len)
+syscall sys_mlockall nr 4313 nbargs 1 types: (int) args: (flags)
+syscall sys_munlockall nr 4315 nbargs 0 types: () args: ()
+syscall sys_sched_setparam nr 4317 nbargs 2 types: (pid_t, struct sched_param *) args: (pid, param)
+syscall sys_sched_getparam nr 4319 nbargs 2 types: (pid_t, struct sched_param *) args: (pid, param)
+syscall sys_sched_setscheduler nr 4321 nbargs 3 types: (pid_t, int, struct sched_param *) args: (pid, policy, param)
+syscall sys_sched_getscheduler nr 4323 nbargs 1 types: (pid_t) args: (pid)
+syscall sys_sched_yield nr 4325 nbargs 0 types: () args: ()
+syscall sys_sched_get_priority_max nr 4327 nbargs 1 types: (int) args: (policy)
+syscall sys_sched_get_priority_min nr 4329 nbargs 1 types: (int) args: (policy)
+syscall sys_sched_rr_get_interval nr 4331 nbargs 2 types: (pid_t, struct timespec *) args: (pid, interval)
+syscall sys_nanosleep nr 4333 nbargs 2 types: (struct timespec *, struct timespec *) args: (rqtp, rmtp)
+syscall sys_mremap nr 4335 nbargs 5 types: (unsigned long, unsigned long, unsigned long, unsigned long, unsigned long) args: (addr, old_len, new_len, flags, new_addr)
+syscall sys_accept nr 4337 nbargs 3 types: (int, struct sockaddr *, int *) args: (fd, upeer_sockaddr, upeer_addrlen)
+syscall sys_bind nr 4339 nbargs 3 types: (int, struct sockaddr *, int) args: (fd, umyaddr, addrlen)
+syscall sys_connect nr 4341 nbargs 3 types: (int, struct sockaddr *, int) args: (fd, uservaddr, addrlen)
+syscall sys_getpeername nr 4343 nbargs 3 types: (int, struct sockaddr *, int *) args: (fd, usockaddr, usockaddr_len)
+syscall sys_getsockname nr 4345 nbargs 3 types: (int, struct sockaddr *, int *) args: (fd, usockaddr, usockaddr_len)
diff --git a/drivers/staging/lttng/instrumentation/syscalls/3.5.0/mips-64-syscalls-3.5.0 b/drivers/staging/lttng/instrumentation/syscalls/3.5.0/mips-64-syscalls-3.5.0
new file mode 100644 (file)
index 0000000..7753e06
--- /dev/null
@@ -0,0 +1,289 @@
+syscall sys_waitpid nr 4007 nbargs 3 types: (pid_t, int *, int) args: (pid, stat_addr, options)
+syscall sys_oldumount nr 4022 nbargs 1 types: (char *) args: (name)
+syscall sys_nice nr 4034 nbargs 1 types: (int) args: (increment)
+syscall sys_olduname nr 4059 nbargs 1 types: (struct oldold_utsname *) args: (name)
+syscall sys_32_sigaction nr 4067 nbargs 3 types: (long, const struct sigaction32 *, struct sigaction32 *) args: (sig, act, oact)
+syscall sys_sgetmask nr 4068 nbargs 0 types: () args: ()
+syscall sys_ssetmask nr 4069 nbargs 1 types: (int) args: (newmask)
+syscall sys_uselib nr 4086 nbargs 1 types: (const char *) args: (library)
+syscall sys_uname nr 4109 nbargs 1 types: (struct old_utsname *) args: (name)
+syscall sys_32_ipc nr 4117 nbargs 6 types: (u32, long, long, long, unsigned long, unsigned long) args: (call, first, second, third, ptr, fifth)
+syscall sys_bdflush nr 4134 nbargs 2 types: (int, long) args: (func, data)
+syscall sys_32_llseek nr 4140 nbargs 5 types: (unsigned int, unsigned int, unsigned int, loff_t *, unsigned int) args: (fd, offset_high, offset_low, result, origin)
+syscall sys_send nr 4178 nbargs 4 types: (int, void *, size_t, unsigned int) args: (fd, buff, len, flags)
+syscall sys_32_pread nr 4200 nbargs 6 types: (unsigned long, char *, size_t, unsigned long, unsigned long, unsigned long) args: (fd, buf, count, unused, a4, a5)
+syscall sys_32_pwrite nr 4201 nbargs 6 types: (unsigned int, const char *, size_t, u32, u64, u64) args: (fd, buf, count, unused, a4, a5)
+syscall sys_mips_mmap2 nr 4210 nbargs 6 types: (unsigned long, unsigned long, unsigned long, unsigned long, unsigned long, unsigned long) args: (addr, len, prot, flags, fd, pgoff)
+syscall sys_32_truncate64 nr 4211 nbargs 4 types: (const char *, unsigned long, unsigned long, unsigned long) args: (path, __dummy, a2, a3)
+syscall sys_32_ftruncate64 nr 4212 nbargs 4 types: (unsigned long, unsigned long, unsigned long, unsigned long) args: (fd, __dummy, a2, a3)
+syscall sys_32_waitid nr 4278 nbargs 5 types: (int, compat_pid_t, compat_siginfo_t *, int, struct compat_rusage *) args: (which, pid, uinfo, options, uru)
+syscall sys_32_fanotify_mark nr 4337 nbargs 6 types: (int, unsigned int, u64, u64, int, const char *) args: (fanotify_fd, flags, a3, a4, dfd, pathname)
+syscall sys_rt_sigaction nr 5013 nbargs 4 types: (int, const struct sigaction *, struct sigaction *, size_t) args: (sig, act, oact, sigsetsize)
+syscall sys_rt_sigprocmask nr 5014 nbargs 4 types: (int, sigset_t *, sigset_t *, size_t) args: (how, nset, oset, sigsetsize)
+syscall sys_ioctl nr 5015 nbargs 3 types: (unsigned int, unsigned int, unsigned long) args: (fd, cmd, arg)
+syscall sys_readv nr 5018 nbargs 3 types: (unsigned long, const struct iovec *, unsigned long) args: (fd, vec, vlen)
+syscall sys_writev nr 5019 nbargs 3 types: (unsigned long, const struct iovec *, unsigned long) args: (fd, vec, vlen)
+syscall sys_select nr 5022 nbargs 5 types: (int, fd_set *, fd_set *, fd_set *, struct timeval *) args: (n, inp, outp, exp, tvp)
+syscall sys_shmctl nr 5030 nbargs 3 types: (int, int, struct shmid_ds *) args: (shmid, cmd, buf)
+syscall sys_nanosleep nr 5034 nbargs 2 types: (struct timespec *, struct timespec *) args: (rqtp, rmtp)
+syscall sys_getitimer nr 5035 nbargs 2 types: (int, struct itimerval *) args: (which, value)
+syscall sys_setitimer nr 5036 nbargs 3 types: (int, struct itimerval *, struct itimerval *) args: (which, value, ovalue)
+syscall sys_recvfrom nr 5044 nbargs 6 types: (int, void *, size_t, unsigned int, struct sockaddr *, int *) args: (fd, ubuf, size, flags, addr, addr_len)
+syscall sys_sendmsg nr 5045 nbargs 3 types: (int, struct msghdr *, unsigned int) args: (fd, msg, flags)
+syscall sys_recvmsg nr 5046 nbargs 3 types: (int, struct msghdr *, unsigned int) args: (fd, msg, flags)
+syscall sys_setsockopt nr 5053 nbargs 5 types: (int, int, int, char *, int) args: (fd, level, optname, optval, optlen)
+syscall sys_wait4 nr 5059 nbargs 4 types: (pid_t, int *, int, struct rusage *) args: (upid, stat_addr, options, ru)
+syscall sys_msgsnd nr 5067 nbargs 4 types: (int, struct msgbuf *, size_t, int) args: (msqid, msgp, msgsz, msgflg)
+syscall sys_msgrcv nr 5068 nbargs 5 types: (int, struct msgbuf *, size_t, long, int) args: (msqid, msgp, msgsz, msgtyp, msgflg)
+syscall sys_msgctl nr 5069 nbargs 3 types: (int, int, struct msqid_ds *) args: (msqid, cmd, buf)
+syscall sys_fcntl nr 5070 nbargs 3 types: (unsigned int, unsigned int, unsigned long) args: (fd, cmd, arg)
+syscall sys_getdents nr 5076 nbargs 3 types: (unsigned int, struct linux_dirent *, unsigned int) args: (fd, dirent, count)
+syscall sys_gettimeofday nr 5094 nbargs 2 types: (struct timeval *, struct timezone *) args: (tv, tz)
+syscall sys_getrlimit nr 5095 nbargs 2 types: (unsigned int, struct rlimit *) args: (resource, rlim)
+syscall sys_getrusage nr 5096 nbargs 2 types: (int, struct rusage *) args: (who, ru)
+syscall sys_sysinfo nr 5097 nbargs 1 types: (struct sysinfo *) args: (info)
+syscall sys_times nr 5098 nbargs 1 types: (struct tms *) args: (tbuf)
+syscall sys_ptrace nr 5099 nbargs 4 types: (long, long, unsigned long, unsigned long) args: (request, pid, addr, data)
+syscall sys_rt_sigpending nr 5125 nbargs 2 types: (sigset_t *, size_t) args: (set, sigsetsize)
+syscall sys_rt_sigtimedwait nr 5126 nbargs 4 types: (const sigset_t *, siginfo_t *, const struct timespec *, size_t) args: (uthese, uinfo, uts, sigsetsize)
+syscall sys_rt_sigqueueinfo nr 5127 nbargs 3 types: (pid_t, int, siginfo_t *) args: (pid, sig, uinfo)
+syscall sys_utime nr 5130 nbargs 2 types: (char *, struct utimbuf *) args: (filename, times)
+syscall sys_personality nr 5132 nbargs 1 types: (unsigned int) args: (personality)
+syscall sys_ustat nr 5133 nbargs 2 types: (unsigned, struct ustat *) args: (dev, ubuf)
+syscall sys_statfs nr 5134 nbargs 2 types: (const char *, struct statfs *) args: (pathname, buf)
+syscall sys_fstatfs nr 5135 nbargs 2 types: (unsigned int, struct statfs *) args: (fd, buf)
+syscall sys_sched_rr_get_interval nr 5145 nbargs 2 types: (pid_t, struct timespec *) args: (pid, interval)
+syscall sys_sysctl nr 5152 nbargs 1 types: (struct __sysctl_args *) args: (args)
+syscall sys_adjtimex nr 5154 nbargs 1 types: (struct timex *) args: (txc_p)
+syscall sys_setrlimit nr 5155 nbargs 2 types: (unsigned int, struct rlimit *) args: (resource, rlim)
+syscall sys_settimeofday nr 5159 nbargs 2 types: (struct timeval *, struct timezone *) args: (tv, tz)
+syscall sys_mount nr 5160 nbargs 5 types: (char *, char *, char *, unsigned long, void *) args: (dev_name, dir_name, type, flags, data)
+syscall sys_futex nr 5194 nbargs 6 types: (u32 *, int, u32, struct timespec *, u32 *, u32) args: (uaddr, op, val, utime, uaddr2, val3)
+syscall sys_sched_setaffinity nr 5195 nbargs 3 types: (pid_t, unsigned int, unsigned long *) args: (pid, len, user_mask_ptr)
+syscall sys_sched_getaffinity nr 5196 nbargs 3 types: (pid_t, unsigned int, unsigned long *) args: (pid, len, user_mask_ptr)
+syscall sys_io_setup nr 5200 nbargs 2 types: (unsigned, aio_context_t *) args: (nr_events, ctxp)
+syscall sys_io_getevents nr 5202 nbargs 5 types: (aio_context_t, long, long, struct io_event *, struct timespec *) args: (ctx_id, min_nr, nr, events, timeout)
+syscall sys_io_submit nr 5203 nbargs 3 types: (aio_context_t, long, struct iocb * *) args: (ctx_id, nr, iocbpp)
+syscall sys_semtimedop nr 5214 nbargs 4 types: (int, struct sembuf *, unsigned, const struct timespec *) args: (semid, tsops, nsops, timeout)
+syscall sys_timer_create nr 5216 nbargs 3 types: (const clockid_t, struct sigevent *, timer_t *) args: (which_clock, timer_event_spec, created_timer_id)
+syscall sys_timer_settime nr 5217 nbargs 4 types: (timer_t, int, const struct itimerspec *, struct itimerspec *) args: (timer_id, flags, new_setting, old_setting)
+syscall sys_timer_gettime nr 5218 nbargs 2 types: (timer_t, struct itimerspec *) args: (timer_id, setting)
+syscall sys_clock_settime nr 5221 nbargs 2 types: (const clockid_t, const struct timespec *) args: (which_clock, tp)
+syscall sys_clock_gettime nr 5222 nbargs 2 types: (const clockid_t, struct timespec *) args: (which_clock, tp)
+syscall sys_clock_getres nr 5223 nbargs 2 types: (const clockid_t, struct timespec *) args: (which_clock, tp)
+syscall sys_clock_nanosleep nr 5224 nbargs 4 types: (const clockid_t, int, const struct timespec *, struct timespec *) args: (which_clock, flags, rqtp, rmtp)
+syscall sys_utimes nr 5226 nbargs 2 types: (char *, struct timeval *) args: (filename, utimes)
+syscall sys_waitid nr 5237 nbargs 5 types: (int, pid_t, struct siginfo *, int, struct rusage *) args: (which, upid, infop, options, ru)
+syscall sys_futimesat nr 5251 nbargs 3 types: (int, const char *, struct timeval *) args: (dfd, filename, utimes)
+syscall sys_pselect6 nr 5260 nbargs 6 types: (int, fd_set *, fd_set *, fd_set *, struct timespec *, void *) args: (n, inp, outp, exp, tsp, sig)
+syscall sys_ppoll nr 5261 nbargs 5 types: (struct pollfd *, unsigned int, struct timespec *, const sigset_t *, size_t) args: (ufds, nfds, tsp, sigmask, sigsetsize)
+syscall sys_vmsplice nr 5266 nbargs 4 types: (int, const struct iovec *, unsigned long, unsigned int) args: (fd, iov, nr_segs, flags)
+syscall sys_set_robust_list nr 5268 nbargs 2 types: (struct robust_list_head *, size_t) args: (head, len)
+syscall sys_get_robust_list nr 5269 nbargs 3 types: (int, struct robust_list_head * *, size_t *) args: (pid, head_ptr, len_ptr)
+syscall sys_epoll_pwait nr 5272 nbargs 6 types: (int, struct epoll_event *, int, int, const sigset_t *, size_t) args: (epfd, events, maxevents, timeout, sigmask, sigsetsize)
+syscall sys_utimensat nr 5275 nbargs 4 types: (int, const char *, struct timespec *, int) args: (dfd, filename, utimes, flags)
+syscall sys_signalfd nr 5276 nbargs 3 types: (int, sigset_t *, size_t) args: (ufd, user_mask, sizemask)
+syscall sys_timerfd_gettime nr 5281 nbargs 2 types: (int, struct itimerspec *) args: (ufd, otmr)
+syscall sys_timerfd_settime nr 5282 nbargs 4 types: (int, int, const struct itimerspec *, struct itimerspec *) args: (ufd, flags, utmr, otmr)
+syscall sys_rt_tgsigqueueinfo nr 5291 nbargs 4 types: (pid_t, pid_t, int, siginfo_t *) args: (tgid, pid, sig, uinfo)
+syscall sys_recvmmsg nr 5294 nbargs 5 types: (int, struct mmsghdr *, unsigned int, unsigned int, struct timespec *) args: (fd, mmsg, vlen, flags, timeout)
+syscall sys_clock_adjtime nr 5300 nbargs 2 types: (const clockid_t, struct timex *) args: (which_clock, utx)
+syscall sys_sendmmsg nr 5302 nbargs 4 types: (int, struct mmsghdr *, unsigned int, unsigned int) args: (fd, mmsg, vlen, flags)
+syscall sys_process_vm_readv nr 5304 nbargs 6 types: (pid_t, const struct iovec *, unsigned long, const struct iovec *, unsigned long, unsigned long) args: (pid, lvec, liovcnt, rvec, riovcnt, flags)
+syscall sys_process_vm_writev nr 5305 nbargs 6 types: (pid_t, const struct iovec *, unsigned long, const struct iovec *, unsigned long, unsigned long) args: (pid, lvec, liovcnt, rvec, riovcnt, flags)
+syscall sys_read nr 6000 nbargs 3 types: (unsigned int, char *, size_t) args: (fd, buf, count)
+syscall sys_write nr 6001 nbargs 3 types: (unsigned int, const char *, size_t) args: (fd, buf, count)
+syscall sys_open nr 6002 nbargs 3 types: (const char *, int, umode_t) args: (filename, flags, mode)
+syscall sys_close nr 6003 nbargs 1 types: (unsigned int) args: (fd)
+syscall sys_newstat nr 6004 nbargs 2 types: (const char *, struct stat *) args: (filename, statbuf)
+syscall sys_newfstat nr 6005 nbargs 2 types: (unsigned int, struct stat *) args: (fd, statbuf)
+syscall sys_newlstat nr 6006 nbargs 2 types: (const char *, struct stat *) args: (filename, statbuf)
+syscall sys_poll nr 6007 nbargs 3 types: (struct pollfd *, unsigned int, int) args: (ufds, nfds, timeout_msecs)
+syscall sys_lseek nr 6008 nbargs 3 types: (unsigned int, off_t, unsigned int) args: (fd, offset, origin)
+syscall sys_mips_mmap nr 6009 nbargs 6 types: (unsigned long, unsigned long, unsigned long, unsigned long, unsigned long, off_t) args: (addr, len, prot, flags, fd, offset)
+syscall sys_mprotect nr 6010 nbargs 3 types: (unsigned long, size_t, unsigned long) args: (start, len, prot)
+syscall sys_munmap nr 6011 nbargs 2 types: (unsigned long, size_t) args: (addr, len)
+syscall sys_brk nr 6012 nbargs 1 types: (unsigned long) args: (brk)
+syscall sys_32_rt_sigaction nr 6013 nbargs 4 types: (int, const struct sigaction32 *, struct sigaction32 *, unsigned int) args: (sig, act, oact, sigsetsize)
+syscall sys_32_rt_sigprocmask nr 6014 nbargs 4 types: (int, compat_sigset_t *, compat_sigset_t *, unsigned int) args: (how, set, oset, sigsetsize)
+syscall sys_access nr 6020 nbargs 2 types: (const char *, int) args: (filename, mode)
+syscall sys_sched_yield nr 6023 nbargs 0 types: () args: ()
+syscall sys_mremap nr 6024 nbargs 5 types: (unsigned long, unsigned long, unsigned long, unsigned long, unsigned long) args: (addr, old_len, new_len, flags, new_addr)
+syscall sys_msync nr 6025 nbargs 3 types: (unsigned long, size_t, int) args: (start, len, flags)
+syscall sys_mincore nr 6026 nbargs 3 types: (unsigned long, size_t, unsigned char *) args: (start, len, vec)
+syscall sys_madvise nr 6027 nbargs 3 types: (unsigned long, size_t, int) args: (start, len_in, behavior)
+syscall sys_shmget nr 6028 nbargs 3 types: (key_t, size_t, int) args: (key, size, shmflg)
+syscall sys_shmat nr 6029 nbargs 3 types: (int, char *, int) args: (shmid, shmaddr, shmflg)
+syscall sys_dup nr 6031 nbargs 1 types: (unsigned int) args: (fildes)
+syscall sys_dup2 nr 6032 nbargs 2 types: (unsigned int, unsigned int) args: (oldfd, newfd)
+syscall sys_pause nr 6033 nbargs 0 types: () args: ()
+syscall sys_alarm nr 6037 nbargs 1 types: (unsigned int) args: (seconds)
+syscall sys_getpid nr 6038 nbargs 0 types: () args: ()
+syscall sys_32_sendfile nr 6039 nbargs 4 types: (long, long, compat_off_t *, s32) args: (out_fd, in_fd, offset, count)
+syscall sys_socket nr 6040 nbargs 3 types: (int, int, int) args: (family, type, protocol)
+syscall sys_connect nr 6041 nbargs 3 types: (int, struct sockaddr *, int) args: (fd, uservaddr, addrlen)
+syscall sys_accept nr 6042 nbargs 3 types: (int, struct sockaddr *, int *) args: (fd, upeer_sockaddr, upeer_addrlen)
+syscall sys_sendto nr 6043 nbargs 6 types: (int, void *, size_t, unsigned int, struct sockaddr *, int) args: (fd, buff, len, flags, addr, addr_len)
+syscall sys_shutdown nr 6047 nbargs 2 types: (int, int) args: (fd, how)
+syscall sys_bind nr 6048 nbargs 3 types: (int, struct sockaddr *, int) args: (fd, umyaddr, addrlen)
+syscall sys_listen nr 6049 nbargs 2 types: (int, int) args: (fd, backlog)
+syscall sys_getsockname nr 6050 nbargs 3 types: (int, struct sockaddr *, int *) args: (fd, usockaddr, usockaddr_len)
+syscall sys_getpeername nr 6051 nbargs 3 types: (int, struct sockaddr *, int *) args: (fd, usockaddr, usockaddr_len)
+syscall sys_socketpair nr 6052 nbargs 4 types: (int, int, int, int *) args: (family, type, protocol, usockvec)
+syscall sys_getsockopt nr 6054 nbargs 5 types: (int, int, int, char *, int *) args: (fd, level, optname, optval, optlen)
+syscall sys_exit nr 6058 nbargs 1 types: (int) args: (error_code)
+syscall sys_kill nr 6060 nbargs 2 types: (pid_t, int) args: (pid, sig)
+syscall sys_newuname nr 6061 nbargs 1 types: (struct new_utsname *) args: (name)
+syscall sys_semget nr 6062 nbargs 3 types: (key_t, int, int) args: (key, nsems, semflg)
+syscall sys_semop nr 6063 nbargs 3 types: (int, struct sembuf *, unsigned) args: (semid, tsops, nsops)
+syscall sys_n32_semctl nr 6064 nbargs 4 types: (int, int, int, u32) args: (semid, semnum, cmd, arg)
+syscall sys_shmdt nr 6065 nbargs 1 types: (char *) args: (shmaddr)
+syscall sys_msgget nr 6066 nbargs 2 types: (key_t, int) args: (key, msgflg)
+syscall sys_n32_msgsnd nr 6067 nbargs 4 types: (int, u32, unsigned int, int) args: (msqid, msgp, msgsz, msgflg)
+syscall sys_n32_msgrcv nr 6068 nbargs 5 types: (int, u32, size_t, int, int) args: (msqid, msgp, msgsz, msgtyp, msgflg)
+syscall sys_flock nr 6071 nbargs 2 types: (unsigned int, unsigned int) args: (fd, cmd)
+syscall sys_fsync nr 6072 nbargs 1 types: (unsigned int) args: (fd)
+syscall sys_fdatasync nr 6073 nbargs 1 types: (unsigned int) args: (fd)
+syscall sys_truncate nr 6074 nbargs 2 types: (const char *, long) args: (path, length)
+syscall sys_ftruncate nr 6075 nbargs 2 types: (unsigned int, unsigned long) args: (fd, length)
+syscall sys_getcwd nr 6077 nbargs 2 types: (char *, unsigned long) args: (buf, size)
+syscall sys_chdir nr 6078 nbargs 1 types: (const char *) args: (filename)
+syscall sys_fchdir nr 6079 nbargs 1 types: (unsigned int) args: (fd)
+syscall sys_rename nr 6080 nbargs 2 types: (const char *, const char *) args: (oldname, newname)
+syscall sys_mkdir nr 6081 nbargs 2 types: (const char *, umode_t) args: (pathname, mode)
+syscall sys_rmdir nr 6082 nbargs 1 types: (const char *) args: (pathname)
+syscall sys_creat nr 6083 nbargs 2 types: (const char *, umode_t) args: (pathname, mode)
+syscall sys_link nr 6084 nbargs 2 types: (const char *, const char *) args: (oldname, newname)
+syscall sys_unlink nr 6085 nbargs 1 types: (const char *) args: (pathname)
+syscall sys_symlink nr 6086 nbargs 2 types: (const char *, const char *) args: (oldname, newname)
+syscall sys_readlink nr 6087 nbargs 3 types: (const char *, char *, int) args: (path, buf, bufsiz)
+syscall sys_chmod nr 6088 nbargs 2 types: (const char *, umode_t) args: (filename, mode)
+syscall sys_fchmod nr 6089 nbargs 2 types: (unsigned int, umode_t) args: (fd, mode)
+syscall sys_chown nr 6090 nbargs 3 types: (const char *, uid_t, gid_t) args: (filename, user, group)
+syscall sys_fchown nr 6091 nbargs 3 types: (unsigned int, uid_t, gid_t) args: (fd, user, group)
+syscall sys_lchown nr 6092 nbargs 3 types: (const char *, uid_t, gid_t) args: (filename, user, group)
+syscall sys_umask nr 6093 nbargs 1 types: (int) args: (mask)
+syscall sys_getuid nr 6100 nbargs 0 types: () args: ()
+syscall sys_syslog nr 6101 nbargs 3 types: (int, char *, int) args: (type, buf, len)
+syscall sys_getgid nr 6102 nbargs 0 types: () args: ()
+syscall sys_setuid nr 6103 nbargs 1 types: (uid_t) args: (uid)
+syscall sys_setgid nr 6104 nbargs 1 types: (gid_t) args: (gid)
+syscall sys_geteuid nr 6105 nbargs 0 types: () args: ()
+syscall sys_getegid nr 6106 nbargs 0 types: () args: ()
+syscall sys_setpgid nr 6107 nbargs 2 types: (pid_t, pid_t) args: (pid, pgid)
+syscall sys_getppid nr 6108 nbargs 0 types: () args: ()
+syscall sys_getpgrp nr 6109 nbargs 0 types: () args: ()
+syscall sys_setsid nr 6110 nbargs 0 types: () args: ()
+syscall sys_setreuid nr 6111 nbargs 2 types: (uid_t, uid_t) args: (ruid, euid)
+syscall sys_setregid nr 6112 nbargs 2 types: (gid_t, gid_t) args: (rgid, egid)
+syscall sys_getgroups nr 6113 nbargs 2 types: (int, gid_t *) args: (gidsetsize, grouplist)
+syscall sys_setgroups nr 6114 nbargs 2 types: (int, gid_t *) args: (gidsetsize, grouplist)
+syscall sys_setresuid nr 6115 nbargs 3 types: (uid_t, uid_t, uid_t) args: (ruid, euid, suid)
+syscall sys_getresuid nr 6116 nbargs 3 types: (uid_t *, uid_t *, uid_t *) args: (ruidp, euidp, suidp)
+syscall sys_setresgid nr 6117 nbargs 3 types: (gid_t, gid_t, gid_t) args: (rgid, egid, sgid)
+syscall sys_getresgid nr 6118 nbargs 3 types: (gid_t *, gid_t *, gid_t *) args: (rgidp, egidp, sgidp)
+syscall sys_getpgid nr 6119 nbargs 1 types: (pid_t) args: (pid)
+syscall sys_setfsuid nr 6120 nbargs 1 types: (uid_t) args: (uid)
+syscall sys_setfsgid nr 6121 nbargs 1 types: (gid_t) args: (gid)
+syscall sys_getsid nr 6122 nbargs 1 types: (pid_t) args: (pid)
+syscall sys_capget nr 6123 nbargs 2 types: (cap_user_header_t, cap_user_data_t) args: (header, dataptr)
+syscall sys_capset nr 6124 nbargs 2 types: (cap_user_header_t, const cap_user_data_t) args: (header, data)
+syscall sys_32_rt_sigpending nr 6125 nbargs 2 types: (compat_sigset_t *, unsigned int) args: (uset, sigsetsize)
+syscall sys_32_rt_sigqueueinfo nr 6127 nbargs 3 types: (int, int, compat_siginfo_t *) args: (pid, sig, uinfo)
+syscall sys_mknod nr 6131 nbargs 3 types: (const char *, umode_t, unsigned) args: (filename, mode, dev)
+syscall sys_32_personality nr 6132 nbargs 1 types: (unsigned long) args: (personality)
+syscall sys_sysfs nr 6136 nbargs 3 types: (int, unsigned long, unsigned long) args: (option, arg1, arg2)
+syscall sys_getpriority nr 6137 nbargs 2 types: (int, int) args: (which, who)
+syscall sys_setpriority nr 6138 nbargs 3 types: (int, int, int) args: (which, who, niceval)
+syscall sys_sched_setparam nr 6139 nbargs 2 types: (pid_t, struct sched_param *) args: (pid, param)
+syscall sys_sched_getparam nr 6140 nbargs 2 types: (pid_t, struct sched_param *) args: (pid, param)
+syscall sys_sched_setscheduler nr 6141 nbargs 3 types: (pid_t, int, struct sched_param *) args: (pid, policy, param)
+syscall sys_sched_getscheduler nr 6142 nbargs 1 types: (pid_t) args: (pid)
+syscall sys_sched_get_priority_max nr 6143 nbargs 1 types: (int) args: (policy)
+syscall sys_sched_get_priority_min nr 6144 nbargs 1 types: (int) args: (policy)
+syscall sys_32_sched_rr_get_interval nr 6145 nbargs 2 types: (compat_pid_t, struct compat_timespec *) args: (pid, interval)
+syscall sys_mlock nr 6146 nbargs 2 types: (unsigned long, size_t) args: (start, len)
+syscall sys_munlock nr 6147 nbargs 2 types: (unsigned long, size_t) args: (start, len)
+syscall sys_mlockall nr 6148 nbargs 1 types: (int) args: (flags)
+syscall sys_munlockall nr 6149 nbargs 0 types: () args: ()
+syscall sys_vhangup nr 6150 nbargs 0 types: () args: ()
+syscall sys_pivot_root nr 6151 nbargs 2 types: (const char *, const char *) args: (new_root, put_old)
+syscall sys_prctl nr 6153 nbargs 5 types: (int, unsigned long, unsigned long, unsigned long, unsigned long) args: (option, arg2, arg3, arg4, arg5)
+syscall sys_chroot nr 6156 nbargs 1 types: (const char *) args: (filename)
+syscall sys_sync nr 6157 nbargs 0 types: () args: ()
+syscall sys_umount nr 6161 nbargs 2 types: (char *, int) args: (name, flags)
+syscall sys_swapon nr 6162 nbargs 2 types: (const char *, int) args: (specialfile, swap_flags)
+syscall sys_swapoff nr 6163 nbargs 1 types: (const char *) args: (specialfile)
+syscall sys_reboot nr 6164 nbargs 4 types: (int, int, unsigned int, void *) args: (magic1, magic2, cmd, arg)
+syscall sys_sethostname nr 6165 nbargs 2 types: (char *, int) args: (name, len)
+syscall sys_setdomainname nr 6166 nbargs 2 types: (char *, int) args: (name, len)
+syscall sys_init_module nr 6168 nbargs 3 types: (void *, unsigned long, const char *) args: (umod, len, uargs)
+syscall sys_delete_module nr 6169 nbargs 2 types: (const char *, unsigned int) args: (name_user, flags)
+syscall sys_quotactl nr 6172 nbargs 4 types: (unsigned int, const char *, qid_t, void *) args: (cmd, special, id, addr)
+syscall sys_gettid nr 6178 nbargs 0 types: () args: ()
+syscall sys_setxattr nr 6180 nbargs 5 types: (const char *, const char *, const void *, size_t, int) args: (pathname, name, value, size, flags)
+syscall sys_lsetxattr nr 6181 nbargs 5 types: (const char *, const char *, const void *, size_t, int) args: (pathname, name, value, size, flags)
+syscall sys_fsetxattr nr 6182 nbargs 5 types: (int, const char *, const void *, size_t, int) args: (fd, name, value, size, flags)
+syscall sys_getxattr nr 6183 nbargs 4 types: (const char *, const char *, void *, size_t) args: (pathname, name, value, size)
+syscall sys_lgetxattr nr 6184 nbargs 4 types: (const char *, const char *, void *, size_t) args: (pathname, name, value, size)
+syscall sys_fgetxattr nr 6185 nbargs 4 types: (int, const char *, void *, size_t) args: (fd, name, value, size)
+syscall sys_listxattr nr 6186 nbargs 3 types: (const char *, char *, size_t) args: (pathname, list, size)
+syscall sys_llistxattr nr 6187 nbargs 3 types: (const char *, char *, size_t) args: (pathname, list, size)
+syscall sys_flistxattr nr 6188 nbargs 3 types: (int, char *, size_t) args: (fd, list, size)
+syscall sys_removexattr nr 6189 nbargs 2 types: (const char *, const char *) args: (pathname, name)
+syscall sys_lremovexattr nr 6190 nbargs 2 types: (const char *, const char *) args: (pathname, name)
+syscall sys_fremovexattr nr 6191 nbargs 2 types: (int, const char *) args: (fd, name)
+syscall sys_tkill nr 6192 nbargs 2 types: (pid_t, int) args: (pid, sig)
+syscall sys_32_futex nr 6194 nbargs 6 types: (u32 *, int, u32, struct compat_timespec *, u32 *, u32) args: (uaddr, op, val, utime, uaddr2, val3)
+syscall sys_cacheflush nr 6197 nbargs 3 types: (unsigned long, unsigned long, unsigned int) args: (addr, bytes, cache)
+syscall sys_cachectl nr 6198 nbargs 3 types: (char *, int, int) args: (addr, nbytes, op)
+syscall sys_io_destroy nr 6201 nbargs 1 types: (aio_context_t) args: (ctx)
+syscall sys_io_cancel nr 6204 nbargs 3 types: (aio_context_t, struct iocb *, struct io_event *) args: (ctx_id, iocb, result)
+syscall sys_exit_group nr 6205 nbargs 1 types: (int) args: (error_code)
+syscall sys_epoll_create nr 6207 nbargs 1 types: (int) args: (size)
+syscall sys_epoll_ctl nr 6208 nbargs 4 types: (int, int, int, struct epoll_event *) args: (epfd, op, fd, event)
+syscall sys_epoll_wait nr 6209 nbargs 4 types: (int, struct epoll_event *, int, int) args: (epfd, events, maxevents, timeout)
+syscall sys_remap_file_pages nr 6210 nbargs 5 types: (unsigned long, unsigned long, unsigned long, unsigned long, unsigned long) args: (start, size, prot, pgoff, flags)
+syscall sys_set_tid_address nr 6213 nbargs 1 types: (int *) args: (tidptr)
+syscall sys_restart_syscall nr 6214 nbargs 0 types: () args: ()
+syscall sys_sendfile64 nr 6219 nbargs 4 types: (int, int, loff_t *, size_t) args: (out_fd, in_fd, offset, count)
+syscall sys_timer_getoverrun nr 6223 nbargs 1 types: (timer_t) args: (timer_id)
+syscall sys_timer_delete nr 6224 nbargs 1 types: (timer_t) args: (timer_id)
+syscall sys_tgkill nr 6229 nbargs 3 types: (pid_t, pid_t, int) args: (tgid, pid, sig)
+syscall sys_set_thread_area nr 6246 nbargs 1 types: (unsigned long) args: (addr)
+syscall sys_inotify_init nr 6247 nbargs 0 types: () args: ()
+syscall sys_inotify_add_watch nr 6248 nbargs 3 types: (int, const char *, u32) args: (fd, pathname, mask)
+syscall sys_inotify_rm_watch nr 6249 nbargs 2 types: (int, __s32) args: (fd, wd)
+syscall sys_openat nr 6251 nbargs 4 types: (int, const char *, int, umode_t) args: (dfd, filename, flags, mode)
+syscall sys_mkdirat nr 6252 nbargs 3 types: (int, const char *, umode_t) args: (dfd, pathname, mode)
+syscall sys_mknodat nr 6253 nbargs 4 types: (int, const char *, umode_t, unsigned) args: (dfd, filename, mode, dev)
+syscall sys_fchownat nr 6254 nbargs 5 types: (int, const char *, uid_t, gid_t, int) args: (dfd, filename, user, group, flag)
+syscall sys_newfstatat nr 6256 nbargs 4 types: (int, const char *, struct stat *, int) args: (dfd, filename, statbuf, flag)
+syscall sys_unlinkat nr 6257 nbargs 3 types: (int, const char *, int) args: (dfd, pathname, flag)
+syscall sys_renameat nr 6258 nbargs 4 types: (int, const char *, int, const char *) args: (olddfd, oldname, newdfd, newname)
+syscall sys_linkat nr 6259 nbargs 5 types: (int, const char *, int, const char *, int) args: (olddfd, oldname, newdfd, newname, flags)
+syscall sys_symlinkat nr 6260 nbargs 3 types: (const char *, int, const char *) args: (oldname, newdfd, newname)
+syscall sys_readlinkat nr 6261 nbargs 4 types: (int, const char *, char *, int) args: (dfd, pathname, buf, bufsiz)
+syscall sys_fchmodat nr 6262 nbargs 3 types: (int, const char *, umode_t) args: (dfd, filename, mode)
+syscall sys_faccessat nr 6263 nbargs 3 types: (int, const char *, int) args: (dfd, filename, mode)
+syscall sys_unshare nr 6266 nbargs 1 types: (unsigned long) args: (unshare_flags)
+syscall sys_splice nr 6267 nbargs 6 types: (int, loff_t *, int, loff_t *, size_t, unsigned int) args: (fd_in, off_in, fd_out, off_out, len, flags)
+syscall sys_tee nr 6269 nbargs 4 types: (int, int, size_t, unsigned int) args: (fdin, fdout, len, flags)
+syscall sys_getcpu nr 6275 nbargs 3 types: (unsigned *, unsigned *, struct getcpu_cache *) args: (cpup, nodep, unused)
+syscall sys_ioprio_set nr 6277 nbargs 3 types: (int, int, int) args: (which, who, ioprio)
+syscall sys_ioprio_get nr 6278 nbargs 2 types: (int, int) args: (which, who)
+syscall sys_eventfd nr 6282 nbargs 1 types: (unsigned int) args: (count)
+syscall sys_timerfd_create nr 6284 nbargs 2 types: (int, int) args: (clockid, flags)
+syscall sys_signalfd4 nr 6287 nbargs 4 types: (int, sigset_t *, size_t, int) args: (ufd, user_mask, sizemask, flags)
+syscall sys_eventfd2 nr 6288 nbargs 2 types: (unsigned int, int) args: (count, flags)
+syscall sys_epoll_create1 nr 6289 nbargs 1 types: (int) args: (flags)
+syscall sys_dup3 nr 6290 nbargs 3 types: (unsigned int, unsigned int, int) args: (oldfd, newfd, flags)
+syscall sys_pipe2 nr 6291 nbargs 2 types: (int *, int) args: (fildes, flags)
+syscall sys_inotify_init1 nr 6292 nbargs 1 types: (int) args: (flags)
+syscall sys_preadv nr 6293 nbargs 5 types: (unsigned long, const struct iovec *, unsigned long, unsigned long, unsigned long) args: (fd, vec, vlen, pos_l, pos_h)
+syscall sys_pwritev nr 6294 nbargs 5 types: (unsigned long, const struct iovec *, unsigned long, unsigned long, unsigned long) args: (fd, vec, vlen, pos_l, pos_h)
+syscall sys_accept4 nr 6297 nbargs 4 types: (int, struct sockaddr *, int *, int) args: (fd, upeer_sockaddr, upeer_addrlen, flags)
+syscall sys_getdents64 nr 6299 nbargs 3 types: (unsigned int, struct linux_dirent64 *, unsigned int) args: (fd, dirent, count)
+syscall sys_prlimit64 nr 6302 nbargs 4 types: (pid_t, unsigned int, const struct rlimit64 *, struct rlimit64 *) args: (pid, resource, new_rlim, old_rlim)
+syscall sys_syncfs nr 6306 nbargs 1 types: (int) args: (fd)
+syscall sys_setns nr 6308 nbargs 2 types: (int, int) args: (fd, nstype)
diff --git a/drivers/staging/lttng/instrumentation/syscalls/README b/drivers/staging/lttng/instrumentation/syscalls/README
new file mode 100644 (file)
index 0000000..1e9bec4
--- /dev/null
@@ -0,0 +1,18 @@
+LTTng system call tracing
+
+1) lttng-syscall-extractor
+
+You need to build a kernel with CONFIG_FTRACE_SYSCALLS=y and
+CONFIG_KALLSYMS_ALL=y for extraction. Apply the linker patch to get your
+kernel to keep the system call metadata after boot.  Then build and load
+the LTTng syscall extractor module. The module will fail to load (this
+is expected). See the dmesg output for system call metadata.
+
+2) Generate system call TRACE_EVENT().
+
+Take the dmesg metadata and feed it to lttng-syscalls-generate-headers.sh, e.g.,
+from the instrumentation/syscalls directory. See the script header for
+usage example. It should be run for both the integers and pointers types.
+
+After these are created, we just need to follow the new system call additions,
+no need to regenerate the whole thing, since system calls are only appended to.
diff --git a/drivers/staging/lttng/instrumentation/syscalls/headers/arm-32-syscalls-3.4.25_integers.h b/drivers/staging/lttng/instrumentation/syscalls/headers/arm-32-syscalls-3.4.25_integers.h
new file mode 100644 (file)
index 0000000..9b10e5e
--- /dev/null
@@ -0,0 +1,1181 @@
+/* THIS FILE IS AUTO-GENERATED. DO NOT EDIT */
+#ifndef CREATE_SYSCALL_TABLE
+
+#if !defined(_TRACE_SYSCALLS_INTEGERS_H) || defined(TRACE_HEADER_MULTI_READ)
+#define _TRACE_SYSCALLS_INTEGERS_H
+
+#include <linux/tracepoint.h>
+#include <linux/syscalls.h>
+#include "arm-32-syscalls-3.4.25_integers_override.h"
+#include "syscalls_integers_override.h"
+
+SC_DECLARE_EVENT_CLASS_NOARGS(syscalls_noargs,
+       TP_STRUCT__entry(),
+       TP_fast_assign(),
+       TP_printk()
+)
+#ifndef OVERRIDE_32_sys_restart_syscall
+SC_DEFINE_EVENT_NOARGS(syscalls_noargs, sys_restart_syscall)
+#endif
+#ifndef OVERRIDE_32_sys_getpid
+SC_DEFINE_EVENT_NOARGS(syscalls_noargs, sys_getpid)
+#endif
+#ifndef OVERRIDE_32_sys_getuid16
+SC_DEFINE_EVENT_NOARGS(syscalls_noargs, sys_getuid16)
+#endif
+#ifndef OVERRIDE_32_sys_pause
+SC_DEFINE_EVENT_NOARGS(syscalls_noargs, sys_pause)
+#endif
+#ifndef OVERRIDE_32_sys_sync
+SC_DEFINE_EVENT_NOARGS(syscalls_noargs, sys_sync)
+#endif
+#ifndef OVERRIDE_32_sys_getgid16
+SC_DEFINE_EVENT_NOARGS(syscalls_noargs, sys_getgid16)
+#endif
+#ifndef OVERRIDE_32_sys_geteuid16
+SC_DEFINE_EVENT_NOARGS(syscalls_noargs, sys_geteuid16)
+#endif
+#ifndef OVERRIDE_32_sys_getegid16
+SC_DEFINE_EVENT_NOARGS(syscalls_noargs, sys_getegid16)
+#endif
+#ifndef OVERRIDE_32_sys_getppid
+SC_DEFINE_EVENT_NOARGS(syscalls_noargs, sys_getppid)
+#endif
+#ifndef OVERRIDE_32_sys_getpgrp
+SC_DEFINE_EVENT_NOARGS(syscalls_noargs, sys_getpgrp)
+#endif
+#ifndef OVERRIDE_32_sys_setsid
+SC_DEFINE_EVENT_NOARGS(syscalls_noargs, sys_setsid)
+#endif
+#ifndef OVERRIDE_32_sys_vhangup
+SC_DEFINE_EVENT_NOARGS(syscalls_noargs, sys_vhangup)
+#endif
+#ifndef OVERRIDE_32_sys_munlockall
+SC_DEFINE_EVENT_NOARGS(syscalls_noargs, sys_munlockall)
+#endif
+#ifndef OVERRIDE_32_sys_sched_yield
+SC_DEFINE_EVENT_NOARGS(syscalls_noargs, sys_sched_yield)
+#endif
+#ifndef OVERRIDE_32_sys_getuid
+SC_DEFINE_EVENT_NOARGS(syscalls_noargs, sys_getuid)
+#endif
+#ifndef OVERRIDE_32_sys_getgid
+SC_DEFINE_EVENT_NOARGS(syscalls_noargs, sys_getgid)
+#endif
+#ifndef OVERRIDE_32_sys_geteuid
+SC_DEFINE_EVENT_NOARGS(syscalls_noargs, sys_geteuid)
+#endif
+#ifndef OVERRIDE_32_sys_getegid
+SC_DEFINE_EVENT_NOARGS(syscalls_noargs, sys_getegid)
+#endif
+#ifndef OVERRIDE_32_sys_gettid
+SC_DEFINE_EVENT_NOARGS(syscalls_noargs, sys_gettid)
+#endif
+#ifndef OVERRIDE_32_sys_inotify_init
+SC_DEFINE_EVENT_NOARGS(syscalls_noargs, sys_inotify_init)
+#endif
+#ifndef OVERRIDE_32_sys_exit
+SC_TRACE_EVENT(sys_exit,
+       TP_PROTO(int error_code),
+       TP_ARGS(error_code),
+       TP_STRUCT__entry(__field(int, error_code)),
+       TP_fast_assign(tp_assign(error_code, error_code)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_close
+SC_TRACE_EVENT(sys_close,
+       TP_PROTO(unsigned int fd),
+       TP_ARGS(fd),
+       TP_STRUCT__entry(__field(unsigned int, fd)),
+       TP_fast_assign(tp_assign(fd, fd)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_setuid16
+SC_TRACE_EVENT(sys_setuid16,
+       TP_PROTO(old_uid_t uid),
+       TP_ARGS(uid),
+       TP_STRUCT__entry(__field(old_uid_t, uid)),
+       TP_fast_assign(tp_assign(uid, uid)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_nice
+SC_TRACE_EVENT(sys_nice,
+       TP_PROTO(int increment),
+       TP_ARGS(increment),
+       TP_STRUCT__entry(__field(int, increment)),
+       TP_fast_assign(tp_assign(increment, increment)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_dup
+SC_TRACE_EVENT(sys_dup,
+       TP_PROTO(unsigned int fildes),
+       TP_ARGS(fildes),
+       TP_STRUCT__entry(__field(unsigned int, fildes)),
+       TP_fast_assign(tp_assign(fildes, fildes)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_brk
+SC_TRACE_EVENT(sys_brk,
+       TP_PROTO(unsigned long brk),
+       TP_ARGS(brk),
+       TP_STRUCT__entry(__field(unsigned long, brk)),
+       TP_fast_assign(tp_assign(brk, brk)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_setgid16
+SC_TRACE_EVENT(sys_setgid16,
+       TP_PROTO(old_gid_t gid),
+       TP_ARGS(gid),
+       TP_STRUCT__entry(__field(old_gid_t, gid)),
+       TP_fast_assign(tp_assign(gid, gid)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_umask
+SC_TRACE_EVENT(sys_umask,
+       TP_PROTO(int mask),
+       TP_ARGS(mask),
+       TP_STRUCT__entry(__field(int, mask)),
+       TP_fast_assign(tp_assign(mask, mask)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_fsync
+SC_TRACE_EVENT(sys_fsync,
+       TP_PROTO(unsigned int fd),
+       TP_ARGS(fd),
+       TP_STRUCT__entry(__field(unsigned int, fd)),
+       TP_fast_assign(tp_assign(fd, fd)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_getpgid
+SC_TRACE_EVENT(sys_getpgid,
+       TP_PROTO(pid_t pid),
+       TP_ARGS(pid),
+       TP_STRUCT__entry(__field(pid_t, pid)),
+       TP_fast_assign(tp_assign(pid, pid)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_fchdir
+SC_TRACE_EVENT(sys_fchdir,
+       TP_PROTO(unsigned int fd),
+       TP_ARGS(fd),
+       TP_STRUCT__entry(__field(unsigned int, fd)),
+       TP_fast_assign(tp_assign(fd, fd)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_personality
+SC_TRACE_EVENT(sys_personality,
+       TP_PROTO(unsigned int personality),
+       TP_ARGS(personality),
+       TP_STRUCT__entry(__field(unsigned int, personality)),
+       TP_fast_assign(tp_assign(personality, personality)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_setfsuid16
+SC_TRACE_EVENT(sys_setfsuid16,
+       TP_PROTO(old_uid_t uid),
+       TP_ARGS(uid),
+       TP_STRUCT__entry(__field(old_uid_t, uid)),
+       TP_fast_assign(tp_assign(uid, uid)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_setfsgid16
+SC_TRACE_EVENT(sys_setfsgid16,
+       TP_PROTO(old_gid_t gid),
+       TP_ARGS(gid),
+       TP_STRUCT__entry(__field(old_gid_t, gid)),
+       TP_fast_assign(tp_assign(gid, gid)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_getsid
+SC_TRACE_EVENT(sys_getsid,
+       TP_PROTO(pid_t pid),
+       TP_ARGS(pid),
+       TP_STRUCT__entry(__field(pid_t, pid)),
+       TP_fast_assign(tp_assign(pid, pid)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_fdatasync
+SC_TRACE_EVENT(sys_fdatasync,
+       TP_PROTO(unsigned int fd),
+       TP_ARGS(fd),
+       TP_STRUCT__entry(__field(unsigned int, fd)),
+       TP_fast_assign(tp_assign(fd, fd)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_mlockall
+SC_TRACE_EVENT(sys_mlockall,
+       TP_PROTO(int flags),
+       TP_ARGS(flags),
+       TP_STRUCT__entry(__field(int, flags)),
+       TP_fast_assign(tp_assign(flags, flags)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_sched_getscheduler
+SC_TRACE_EVENT(sys_sched_getscheduler,
+       TP_PROTO(pid_t pid),
+       TP_ARGS(pid),
+       TP_STRUCT__entry(__field(pid_t, pid)),
+       TP_fast_assign(tp_assign(pid, pid)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_sched_get_priority_max
+SC_TRACE_EVENT(sys_sched_get_priority_max,
+       TP_PROTO(int policy),
+       TP_ARGS(policy),
+       TP_STRUCT__entry(__field(int, policy)),
+       TP_fast_assign(tp_assign(policy, policy)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_sched_get_priority_min
+SC_TRACE_EVENT(sys_sched_get_priority_min,
+       TP_PROTO(int policy),
+       TP_ARGS(policy),
+       TP_STRUCT__entry(__field(int, policy)),
+       TP_fast_assign(tp_assign(policy, policy)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_setuid
+SC_TRACE_EVENT(sys_setuid,
+       TP_PROTO(uid_t uid),
+       TP_ARGS(uid),
+       TP_STRUCT__entry(__field(uid_t, uid)),
+       TP_fast_assign(tp_assign(uid, uid)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_setgid
+SC_TRACE_EVENT(sys_setgid,
+       TP_PROTO(gid_t gid),
+       TP_ARGS(gid),
+       TP_STRUCT__entry(__field(gid_t, gid)),
+       TP_fast_assign(tp_assign(gid, gid)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_setfsuid
+SC_TRACE_EVENT(sys_setfsuid,
+       TP_PROTO(uid_t uid),
+       TP_ARGS(uid),
+       TP_STRUCT__entry(__field(uid_t, uid)),
+       TP_fast_assign(tp_assign(uid, uid)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_setfsgid
+SC_TRACE_EVENT(sys_setfsgid,
+       TP_PROTO(gid_t gid),
+       TP_ARGS(gid),
+       TP_STRUCT__entry(__field(gid_t, gid)),
+       TP_fast_assign(tp_assign(gid, gid)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_io_destroy
+SC_TRACE_EVENT(sys_io_destroy,
+       TP_PROTO(aio_context_t ctx),
+       TP_ARGS(ctx),
+       TP_STRUCT__entry(__field(aio_context_t, ctx)),
+       TP_fast_assign(tp_assign(ctx, ctx)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_exit_group
+SC_TRACE_EVENT(sys_exit_group,
+       TP_PROTO(int error_code),
+       TP_ARGS(error_code),
+       TP_STRUCT__entry(__field(int, error_code)),
+       TP_fast_assign(tp_assign(error_code, error_code)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_epoll_create
+SC_TRACE_EVENT(sys_epoll_create,
+       TP_PROTO(int size),
+       TP_ARGS(size),
+       TP_STRUCT__entry(__field(int, size)),
+       TP_fast_assign(tp_assign(size, size)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_timer_getoverrun
+SC_TRACE_EVENT(sys_timer_getoverrun,
+       TP_PROTO(timer_t timer_id),
+       TP_ARGS(timer_id),
+       TP_STRUCT__entry(__field(timer_t, timer_id)),
+       TP_fast_assign(tp_assign(timer_id, timer_id)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_timer_delete
+SC_TRACE_EVENT(sys_timer_delete,
+       TP_PROTO(timer_t timer_id),
+       TP_ARGS(timer_id),
+       TP_STRUCT__entry(__field(timer_t, timer_id)),
+       TP_fast_assign(tp_assign(timer_id, timer_id)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_unshare
+SC_TRACE_EVENT(sys_unshare,
+       TP_PROTO(unsigned long unshare_flags),
+       TP_ARGS(unshare_flags),
+       TP_STRUCT__entry(__field(unsigned long, unshare_flags)),
+       TP_fast_assign(tp_assign(unshare_flags, unshare_flags)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_eventfd
+SC_TRACE_EVENT(sys_eventfd,
+       TP_PROTO(unsigned int count),
+       TP_ARGS(count),
+       TP_STRUCT__entry(__field(unsigned int, count)),
+       TP_fast_assign(tp_assign(count, count)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_epoll_create1
+SC_TRACE_EVENT(sys_epoll_create1,
+       TP_PROTO(int flags),
+       TP_ARGS(flags),
+       TP_STRUCT__entry(__field(int, flags)),
+       TP_fast_assign(tp_assign(flags, flags)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_inotify_init1
+SC_TRACE_EVENT(sys_inotify_init1,
+       TP_PROTO(int flags),
+       TP_ARGS(flags),
+       TP_STRUCT__entry(__field(int, flags)),
+       TP_fast_assign(tp_assign(flags, flags)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_syncfs
+SC_TRACE_EVENT(sys_syncfs,
+       TP_PROTO(int fd),
+       TP_ARGS(fd),
+       TP_STRUCT__entry(__field(int, fd)),
+       TP_fast_assign(tp_assign(fd, fd)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_kill
+SC_TRACE_EVENT(sys_kill,
+       TP_PROTO(pid_t pid, int sig),
+       TP_ARGS(pid, sig),
+       TP_STRUCT__entry(__field(pid_t, pid) __field(int, sig)),
+       TP_fast_assign(tp_assign(pid, pid) tp_assign(sig, sig)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_setpgid
+SC_TRACE_EVENT(sys_setpgid,
+       TP_PROTO(pid_t pid, pid_t pgid),
+       TP_ARGS(pid, pgid),
+       TP_STRUCT__entry(__field(pid_t, pid) __field(pid_t, pgid)),
+       TP_fast_assign(tp_assign(pid, pid) tp_assign(pgid, pgid)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_dup2
+SC_TRACE_EVENT(sys_dup2,
+       TP_PROTO(unsigned int oldfd, unsigned int newfd),
+       TP_ARGS(oldfd, newfd),
+       TP_STRUCT__entry(__field(unsigned int, oldfd) __field(unsigned int, newfd)),
+       TP_fast_assign(tp_assign(oldfd, oldfd) tp_assign(newfd, newfd)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_setreuid16
+SC_TRACE_EVENT(sys_setreuid16,
+       TP_PROTO(old_uid_t ruid, old_uid_t euid),
+       TP_ARGS(ruid, euid),
+       TP_STRUCT__entry(__field(old_uid_t, ruid) __field(old_uid_t, euid)),
+       TP_fast_assign(tp_assign(ruid, ruid) tp_assign(euid, euid)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_setregid16
+SC_TRACE_EVENT(sys_setregid16,
+       TP_PROTO(old_gid_t rgid, old_gid_t egid),
+       TP_ARGS(rgid, egid),
+       TP_STRUCT__entry(__field(old_gid_t, rgid) __field(old_gid_t, egid)),
+       TP_fast_assign(tp_assign(rgid, rgid) tp_assign(egid, egid)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_munmap
+SC_TRACE_EVENT(sys_munmap,
+       TP_PROTO(unsigned long addr, size_t len),
+       TP_ARGS(addr, len),
+       TP_STRUCT__entry(__field_hex(unsigned long, addr) __field(size_t, len)),
+       TP_fast_assign(tp_assign(addr, addr) tp_assign(len, len)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_ftruncate
+SC_TRACE_EVENT(sys_ftruncate,
+       TP_PROTO(unsigned int fd, unsigned long length),
+       TP_ARGS(fd, length),
+       TP_STRUCT__entry(__field(unsigned int, fd) __field(unsigned long, length)),
+       TP_fast_assign(tp_assign(fd, fd) tp_assign(length, length)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_fchmod
+SC_TRACE_EVENT(sys_fchmod,
+       TP_PROTO(unsigned int fd, umode_t mode),
+       TP_ARGS(fd, mode),
+       TP_STRUCT__entry(__field(unsigned int, fd) __field(umode_t, mode)),
+       TP_fast_assign(tp_assign(fd, fd) tp_assign(mode, mode)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_getpriority
+SC_TRACE_EVENT(sys_getpriority,
+       TP_PROTO(int which, int who),
+       TP_ARGS(which, who),
+       TP_STRUCT__entry(__field(int, which) __field(int, who)),
+       TP_fast_assign(tp_assign(which, which) tp_assign(who, who)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_bdflush
+SC_TRACE_EVENT(sys_bdflush,
+       TP_PROTO(int func, long data),
+       TP_ARGS(func, data),
+       TP_STRUCT__entry(__field(int, func) __field(long, data)),
+       TP_fast_assign(tp_assign(func, func) tp_assign(data, data)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_flock
+SC_TRACE_EVENT(sys_flock,
+       TP_PROTO(unsigned int fd, unsigned int cmd),
+       TP_ARGS(fd, cmd),
+       TP_STRUCT__entry(__field(unsigned int, fd) __field(unsigned int, cmd)),
+       TP_fast_assign(tp_assign(fd, fd) tp_assign(cmd, cmd)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_mlock
+SC_TRACE_EVENT(sys_mlock,
+       TP_PROTO(unsigned long start, size_t len),
+       TP_ARGS(start, len),
+       TP_STRUCT__entry(__field(unsigned long, start) __field(size_t, len)),
+       TP_fast_assign(tp_assign(start, start) tp_assign(len, len)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_munlock
+SC_TRACE_EVENT(sys_munlock,
+       TP_PROTO(unsigned long start, size_t len),
+       TP_ARGS(start, len),
+       TP_STRUCT__entry(__field(unsigned long, start) __field(size_t, len)),
+       TP_fast_assign(tp_assign(start, start) tp_assign(len, len)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_setreuid
+SC_TRACE_EVENT(sys_setreuid,
+       TP_PROTO(uid_t ruid, uid_t euid),
+       TP_ARGS(ruid, euid),
+       TP_STRUCT__entry(__field(uid_t, ruid) __field(uid_t, euid)),
+       TP_fast_assign(tp_assign(ruid, ruid) tp_assign(euid, euid)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_setregid
+SC_TRACE_EVENT(sys_setregid,
+       TP_PROTO(gid_t rgid, gid_t egid),
+       TP_ARGS(rgid, egid),
+       TP_STRUCT__entry(__field(gid_t, rgid) __field(gid_t, egid)),
+       TP_fast_assign(tp_assign(rgid, rgid) tp_assign(egid, egid)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_tkill
+SC_TRACE_EVENT(sys_tkill,
+       TP_PROTO(pid_t pid, int sig),
+       TP_ARGS(pid, sig),
+       TP_STRUCT__entry(__field(pid_t, pid) __field(int, sig)),
+       TP_fast_assign(tp_assign(pid, pid) tp_assign(sig, sig)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_listen
+SC_TRACE_EVENT(sys_listen,
+       TP_PROTO(int fd, int backlog),
+       TP_ARGS(fd, backlog),
+       TP_STRUCT__entry(__field(int, fd) __field(int, backlog)),
+       TP_fast_assign(tp_assign(fd, fd) tp_assign(backlog, backlog)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_shutdown
+SC_TRACE_EVENT(sys_shutdown,
+       TP_PROTO(int fd, int how),
+       TP_ARGS(fd, how),
+       TP_STRUCT__entry(__field(int, fd) __field(int, how)),
+       TP_fast_assign(tp_assign(fd, fd) tp_assign(how, how)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_msgget
+SC_TRACE_EVENT(sys_msgget,
+       TP_PROTO(key_t key, int msgflg),
+       TP_ARGS(key, msgflg),
+       TP_STRUCT__entry(__field(key_t, key) __field(int, msgflg)),
+       TP_fast_assign(tp_assign(key, key) tp_assign(msgflg, msgflg)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_ioprio_get
+SC_TRACE_EVENT(sys_ioprio_get,
+       TP_PROTO(int which, int who),
+       TP_ARGS(which, who),
+       TP_STRUCT__entry(__field(int, which) __field(int, who)),
+       TP_fast_assign(tp_assign(which, which) tp_assign(who, who)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_inotify_rm_watch
+SC_TRACE_EVENT(sys_inotify_rm_watch,
+       TP_PROTO(int fd, __s32 wd),
+       TP_ARGS(fd, wd),
+       TP_STRUCT__entry(__field(int, fd) __field(__s32, wd)),
+       TP_fast_assign(tp_assign(fd, fd) tp_assign(wd, wd)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_timerfd_create
+SC_TRACE_EVENT(sys_timerfd_create,
+       TP_PROTO(int clockid, int flags),
+       TP_ARGS(clockid, flags),
+       TP_STRUCT__entry(__field(int, clockid) __field(int, flags)),
+       TP_fast_assign(tp_assign(clockid, clockid) tp_assign(flags, flags)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_eventfd2
+SC_TRACE_EVENT(sys_eventfd2,
+       TP_PROTO(unsigned int count, int flags),
+       TP_ARGS(count, flags),
+       TP_STRUCT__entry(__field(unsigned int, count) __field(int, flags)),
+       TP_fast_assign(tp_assign(count, count) tp_assign(flags, flags)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_fanotify_init
+SC_TRACE_EVENT(sys_fanotify_init,
+       TP_PROTO(unsigned int flags, unsigned int event_f_flags),
+       TP_ARGS(flags, event_f_flags),
+       TP_STRUCT__entry(__field(unsigned int, flags) __field(unsigned int, event_f_flags)),
+       TP_fast_assign(tp_assign(flags, flags) tp_assign(event_f_flags, event_f_flags)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_setns
+SC_TRACE_EVENT(sys_setns,
+       TP_PROTO(int fd, int nstype),
+       TP_ARGS(fd, nstype),
+       TP_STRUCT__entry(__field(int, fd) __field(int, nstype)),
+       TP_fast_assign(tp_assign(fd, fd) tp_assign(nstype, nstype)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_lseek
+SC_TRACE_EVENT(sys_lseek,
+       TP_PROTO(unsigned int fd, off_t offset, unsigned int origin),
+       TP_ARGS(fd, offset, origin),
+       TP_STRUCT__entry(__field(unsigned int, fd) __field(off_t, offset) __field(unsigned int, origin)),
+       TP_fast_assign(tp_assign(fd, fd) tp_assign(offset, offset) tp_assign(origin, origin)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_ioctl
+SC_TRACE_EVENT(sys_ioctl,
+       TP_PROTO(unsigned int fd, unsigned int cmd, unsigned long arg),
+       TP_ARGS(fd, cmd, arg),
+       TP_STRUCT__entry(__field(unsigned int, fd) __field(unsigned int, cmd) __field(unsigned long, arg)),
+       TP_fast_assign(tp_assign(fd, fd) tp_assign(cmd, cmd) tp_assign(arg, arg)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_fcntl
+SC_TRACE_EVENT(sys_fcntl,
+       TP_PROTO(unsigned int fd, unsigned int cmd, unsigned long arg),
+       TP_ARGS(fd, cmd, arg),
+       TP_STRUCT__entry(__field(unsigned int, fd) __field(unsigned int, cmd) __field(unsigned long, arg)),
+       TP_fast_assign(tp_assign(fd, fd) tp_assign(cmd, cmd) tp_assign(arg, arg)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_fchown16
+SC_TRACE_EVENT(sys_fchown16,
+       TP_PROTO(unsigned int fd, old_uid_t user, old_gid_t group),
+       TP_ARGS(fd, user, group),
+       TP_STRUCT__entry(__field(unsigned int, fd) __field(old_uid_t, user) __field(old_gid_t, group)),
+       TP_fast_assign(tp_assign(fd, fd) tp_assign(user, user) tp_assign(group, group)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_setpriority
+SC_TRACE_EVENT(sys_setpriority,
+       TP_PROTO(int which, int who, int niceval),
+       TP_ARGS(which, who, niceval),
+       TP_STRUCT__entry(__field(int, which) __field(int, who) __field(int, niceval)),
+       TP_fast_assign(tp_assign(which, which) tp_assign(who, who) tp_assign(niceval, niceval)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_mprotect
+SC_TRACE_EVENT(sys_mprotect,
+       TP_PROTO(unsigned long start, size_t len, unsigned long prot),
+       TP_ARGS(start, len, prot),
+       TP_STRUCT__entry(__field(unsigned long, start) __field(size_t, len) __field(unsigned long, prot)),
+       TP_fast_assign(tp_assign(start, start) tp_assign(len, len) tp_assign(prot, prot)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_sysfs
+SC_TRACE_EVENT(sys_sysfs,
+       TP_PROTO(int option, unsigned long arg1, unsigned long arg2),
+       TP_ARGS(option, arg1, arg2),
+       TP_STRUCT__entry(__field(int, option) __field(unsigned long, arg1) __field(unsigned long, arg2)),
+       TP_fast_assign(tp_assign(option, option) tp_assign(arg1, arg1) tp_assign(arg2, arg2)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_msync
+SC_TRACE_EVENT(sys_msync,
+       TP_PROTO(unsigned long start, size_t len, int flags),
+       TP_ARGS(start, len, flags),
+       TP_STRUCT__entry(__field(unsigned long, start) __field(size_t, len) __field(int, flags)),
+       TP_fast_assign(tp_assign(start, start) tp_assign(len, len) tp_assign(flags, flags)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_setresuid16
+SC_TRACE_EVENT(sys_setresuid16,
+       TP_PROTO(old_uid_t ruid, old_uid_t euid, old_uid_t suid),
+       TP_ARGS(ruid, euid, suid),
+       TP_STRUCT__entry(__field(old_uid_t, ruid) __field(old_uid_t, euid) __field(old_uid_t, suid)),
+       TP_fast_assign(tp_assign(ruid, ruid) tp_assign(euid, euid) tp_assign(suid, suid)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_setresgid16
+SC_TRACE_EVENT(sys_setresgid16,
+       TP_PROTO(old_gid_t rgid, old_gid_t egid, old_gid_t sgid),
+       TP_ARGS(rgid, egid, sgid),
+       TP_STRUCT__entry(__field(old_gid_t, rgid) __field(old_gid_t, egid) __field(old_gid_t, sgid)),
+       TP_fast_assign(tp_assign(rgid, rgid) tp_assign(egid, egid) tp_assign(sgid, sgid)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_fchown
+SC_TRACE_EVENT(sys_fchown,
+       TP_PROTO(unsigned int fd, uid_t user, gid_t group),
+       TP_ARGS(fd, user, group),
+       TP_STRUCT__entry(__field(unsigned int, fd) __field(uid_t, user) __field(gid_t, group)),
+       TP_fast_assign(tp_assign(fd, fd) tp_assign(user, user) tp_assign(group, group)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_setresuid
+SC_TRACE_EVENT(sys_setresuid,
+       TP_PROTO(uid_t ruid, uid_t euid, uid_t suid),
+       TP_ARGS(ruid, euid, suid),
+       TP_STRUCT__entry(__field(uid_t, ruid) __field(uid_t, euid) __field(uid_t, suid)),
+       TP_fast_assign(tp_assign(ruid, ruid) tp_assign(euid, euid) tp_assign(suid, suid)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_setresgid
+SC_TRACE_EVENT(sys_setresgid,
+       TP_PROTO(gid_t rgid, gid_t egid, gid_t sgid),
+       TP_ARGS(rgid, egid, sgid),
+       TP_STRUCT__entry(__field(gid_t, rgid) __field(gid_t, egid) __field(gid_t, sgid)),
+       TP_fast_assign(tp_assign(rgid, rgid) tp_assign(egid, egid) tp_assign(sgid, sgid)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_madvise
+SC_TRACE_EVENT(sys_madvise,
+       TP_PROTO(unsigned long start, size_t len_in, int behavior),
+       TP_ARGS(start, len_in, behavior),
+       TP_STRUCT__entry(__field(unsigned long, start) __field(size_t, len_in) __field(int, behavior)),
+       TP_fast_assign(tp_assign(start, start) tp_assign(len_in, len_in) tp_assign(behavior, behavior)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_fcntl64
+SC_TRACE_EVENT(sys_fcntl64,
+       TP_PROTO(unsigned int fd, unsigned int cmd, unsigned long arg),
+       TP_ARGS(fd, cmd, arg),
+       TP_STRUCT__entry(__field(unsigned int, fd) __field(unsigned int, cmd) __field(unsigned long, arg)),
+       TP_fast_assign(tp_assign(fd, fd) tp_assign(cmd, cmd) tp_assign(arg, arg)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_tgkill
+SC_TRACE_EVENT(sys_tgkill,
+       TP_PROTO(pid_t tgid, pid_t pid, int sig),
+       TP_ARGS(tgid, pid, sig),
+       TP_STRUCT__entry(__field(pid_t, tgid) __field(pid_t, pid) __field(int, sig)),
+       TP_fast_assign(tp_assign(tgid, tgid) tp_assign(pid, pid) tp_assign(sig, sig)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_socket
+SC_TRACE_EVENT(sys_socket,
+       TP_PROTO(int family, int type, int protocol),
+       TP_ARGS(family, type, protocol),
+       TP_STRUCT__entry(__field(int, family) __field(int, type) __field(int, protocol)),
+       TP_fast_assign(tp_assign(family, family) tp_assign(type, type) tp_assign(protocol, protocol)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_semget
+SC_TRACE_EVENT(sys_semget,
+       TP_PROTO(key_t key, int nsems, int semflg),
+       TP_ARGS(key, nsems, semflg),
+       TP_STRUCT__entry(__field(key_t, key) __field(int, nsems) __field(int, semflg)),
+       TP_fast_assign(tp_assign(key, key) tp_assign(nsems, nsems) tp_assign(semflg, semflg)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_shmget
+SC_TRACE_EVENT(sys_shmget,
+       TP_PROTO(key_t key, size_t size, int shmflg),
+       TP_ARGS(key, size, shmflg),
+       TP_STRUCT__entry(__field(key_t, key) __field(size_t, size) __field(int, shmflg)),
+       TP_fast_assign(tp_assign(key, key) tp_assign(size, size) tp_assign(shmflg, shmflg)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_ioprio_set
+SC_TRACE_EVENT(sys_ioprio_set,
+       TP_PROTO(int which, int who, int ioprio),
+       TP_ARGS(which, who, ioprio),
+       TP_STRUCT__entry(__field(int, which) __field(int, who) __field(int, ioprio)),
+       TP_fast_assign(tp_assign(which, which) tp_assign(who, who) tp_assign(ioprio, ioprio)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_dup3
+SC_TRACE_EVENT(sys_dup3,
+       TP_PROTO(unsigned int oldfd, unsigned int newfd, int flags),
+       TP_ARGS(oldfd, newfd, flags),
+       TP_STRUCT__entry(__field(unsigned int, oldfd) __field(unsigned int, newfd) __field(int, flags)),
+       TP_fast_assign(tp_assign(oldfd, oldfd) tp_assign(newfd, newfd) tp_assign(flags, flags)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_ptrace
+SC_TRACE_EVENT(sys_ptrace,
+       TP_PROTO(long request, long pid, unsigned long addr, unsigned long data),
+       TP_ARGS(request, pid, addr, data),
+       TP_STRUCT__entry(__field(long, request) __field(long, pid) __field_hex(unsigned long, addr) __field(unsigned long, data)),
+       TP_fast_assign(tp_assign(request, request) tp_assign(pid, pid) tp_assign(addr, addr) tp_assign(data, data)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_tee
+SC_TRACE_EVENT(sys_tee,
+       TP_PROTO(int fdin, int fdout, size_t len, unsigned int flags),
+       TP_ARGS(fdin, fdout, len, flags),
+       TP_STRUCT__entry(__field(int, fdin) __field(int, fdout) __field(size_t, len) __field(unsigned int, flags)),
+       TP_fast_assign(tp_assign(fdin, fdin) tp_assign(fdout, fdout) tp_assign(len, len) tp_assign(flags, flags)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_mremap
+SC_TRACE_EVENT(sys_mremap,
+       TP_PROTO(unsigned long addr, unsigned long old_len, unsigned long new_len, unsigned long flags, unsigned long new_addr),
+       TP_ARGS(addr, old_len, new_len, flags, new_addr),
+       TP_STRUCT__entry(__field_hex(unsigned long, addr) __field(unsigned long, old_len) __field(unsigned long, new_len) __field(unsigned long, flags) __field_hex(unsigned long, new_addr)),
+       TP_fast_assign(tp_assign(addr, addr) tp_assign(old_len, old_len) tp_assign(new_len, new_len) tp_assign(flags, flags) tp_assign(new_addr, new_addr)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_prctl
+SC_TRACE_EVENT(sys_prctl,
+       TP_PROTO(int option, unsigned long arg2, unsigned long arg3, unsigned long arg4, unsigned long arg5),
+       TP_ARGS(option, arg2, arg3, arg4, arg5),
+       TP_STRUCT__entry(__field(int, option) __field(unsigned long, arg2) __field(unsigned long, arg3) __field(unsigned long, arg4) __field(unsigned long, arg5)),
+       TP_fast_assign(tp_assign(option, option) tp_assign(arg2, arg2) tp_assign(arg3, arg3) tp_assign(arg4, arg4) tp_assign(arg5, arg5)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_remap_file_pages
+SC_TRACE_EVENT(sys_remap_file_pages,
+       TP_PROTO(unsigned long start, unsigned long size, unsigned long prot, unsigned long pgoff, unsigned long flags),
+       TP_ARGS(start, size, prot, pgoff, flags),
+       TP_STRUCT__entry(__field(unsigned long, start) __field(unsigned long, size) __field(unsigned long, prot) __field(unsigned long, pgoff) __field(unsigned long, flags)),
+       TP_fast_assign(tp_assign(start, start) tp_assign(size, size) tp_assign(prot, prot) tp_assign(pgoff, pgoff) tp_assign(flags, flags)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_keyctl
+SC_TRACE_EVENT(sys_keyctl,
+       TP_PROTO(int option, unsigned long arg2, unsigned long arg3, unsigned long arg4, unsigned long arg5),
+       TP_ARGS(option, arg2, arg3, arg4, arg5),
+       TP_STRUCT__entry(__field(int, option) __field(unsigned long, arg2) __field(unsigned long, arg3) __field(unsigned long, arg4) __field(unsigned long, arg5)),
+       TP_fast_assign(tp_assign(option, option) tp_assign(arg2, arg2) tp_assign(arg3, arg3) tp_assign(arg4, arg4) tp_assign(arg5, arg5)),
+       TP_printk()
+)
+#endif
+
+#endif /*  _TRACE_SYSCALLS_INTEGERS_H */
+
+/* This part must be outside protection */
+#include "../../../probes/define_trace.h"
+
+#else /* CREATE_SYSCALL_TABLE */
+
+#include "arm-32-syscalls-3.4.25_integers_override.h"
+#include "syscalls_integers_override.h"
+
+#ifndef OVERRIDE_TABLE_32_sys_restart_syscall
+TRACE_SYSCALL_TABLE(syscalls_noargs, sys_restart_syscall, 0, 0)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_getpid
+TRACE_SYSCALL_TABLE(syscalls_noargs, sys_getpid, 20, 0)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_getuid16
+TRACE_SYSCALL_TABLE(syscalls_noargs, sys_getuid16, 24, 0)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_pause
+TRACE_SYSCALL_TABLE(syscalls_noargs, sys_pause, 29, 0)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_sync
+TRACE_SYSCALL_TABLE(syscalls_noargs, sys_sync, 36, 0)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_getgid16
+TRACE_SYSCALL_TABLE(syscalls_noargs, sys_getgid16, 47, 0)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_geteuid16
+TRACE_SYSCALL_TABLE(syscalls_noargs, sys_geteuid16, 49, 0)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_getegid16
+TRACE_SYSCALL_TABLE(syscalls_noargs, sys_getegid16, 50, 0)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_getppid
+TRACE_SYSCALL_TABLE(syscalls_noargs, sys_getppid, 64, 0)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_getpgrp
+TRACE_SYSCALL_TABLE(syscalls_noargs, sys_getpgrp, 65, 0)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_setsid
+TRACE_SYSCALL_TABLE(syscalls_noargs, sys_setsid, 66, 0)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_vhangup
+TRACE_SYSCALL_TABLE(syscalls_noargs, sys_vhangup, 111, 0)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_munlockall
+TRACE_SYSCALL_TABLE(syscalls_noargs, sys_munlockall, 153, 0)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_sched_yield
+TRACE_SYSCALL_TABLE(syscalls_noargs, sys_sched_yield, 158, 0)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_getuid
+TRACE_SYSCALL_TABLE(syscalls_noargs, sys_getuid, 199, 0)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_getgid
+TRACE_SYSCALL_TABLE(syscalls_noargs, sys_getgid, 200, 0)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_geteuid
+TRACE_SYSCALL_TABLE(syscalls_noargs, sys_geteuid, 201, 0)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_getegid
+TRACE_SYSCALL_TABLE(syscalls_noargs, sys_getegid, 202, 0)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_gettid
+TRACE_SYSCALL_TABLE(syscalls_noargs, sys_gettid, 224, 0)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_inotify_init
+TRACE_SYSCALL_TABLE(syscalls_noargs, sys_inotify_init, 316, 0)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_exit
+TRACE_SYSCALL_TABLE(sys_exit, sys_exit, 1, 1)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_close
+TRACE_SYSCALL_TABLE(sys_close, sys_close, 6, 1)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_lseek
+TRACE_SYSCALL_TABLE(sys_lseek, sys_lseek, 19, 3)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_setuid16
+TRACE_SYSCALL_TABLE(sys_setuid16, sys_setuid16, 23, 1)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_ptrace
+TRACE_SYSCALL_TABLE(sys_ptrace, sys_ptrace, 26, 4)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_nice
+TRACE_SYSCALL_TABLE(sys_nice, sys_nice, 34, 1)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_kill
+TRACE_SYSCALL_TABLE(sys_kill, sys_kill, 37, 2)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_dup
+TRACE_SYSCALL_TABLE(sys_dup, sys_dup, 41, 1)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_brk
+TRACE_SYSCALL_TABLE(sys_brk, sys_brk, 45, 1)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_setgid16
+TRACE_SYSCALL_TABLE(sys_setgid16, sys_setgid16, 46, 1)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_ioctl
+TRACE_SYSCALL_TABLE(sys_ioctl, sys_ioctl, 54, 3)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_fcntl
+TRACE_SYSCALL_TABLE(sys_fcntl, sys_fcntl, 55, 3)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_setpgid
+TRACE_SYSCALL_TABLE(sys_setpgid, sys_setpgid, 57, 2)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_umask
+TRACE_SYSCALL_TABLE(sys_umask, sys_umask, 60, 1)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_dup2
+TRACE_SYSCALL_TABLE(sys_dup2, sys_dup2, 63, 2)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_setreuid16
+TRACE_SYSCALL_TABLE(sys_setreuid16, sys_setreuid16, 70, 2)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_setregid16
+TRACE_SYSCALL_TABLE(sys_setregid16, sys_setregid16, 71, 2)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_munmap
+TRACE_SYSCALL_TABLE(sys_munmap, sys_munmap, 91, 2)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_ftruncate
+TRACE_SYSCALL_TABLE(sys_ftruncate, sys_ftruncate, 93, 2)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_fchmod
+TRACE_SYSCALL_TABLE(sys_fchmod, sys_fchmod, 94, 2)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_fchown16
+TRACE_SYSCALL_TABLE(sys_fchown16, sys_fchown16, 95, 3)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_getpriority
+TRACE_SYSCALL_TABLE(sys_getpriority, sys_getpriority, 96, 2)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_setpriority
+TRACE_SYSCALL_TABLE(sys_setpriority, sys_setpriority, 97, 3)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_fsync
+TRACE_SYSCALL_TABLE(sys_fsync, sys_fsync, 118, 1)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_mprotect
+TRACE_SYSCALL_TABLE(sys_mprotect, sys_mprotect, 125, 3)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_getpgid
+TRACE_SYSCALL_TABLE(sys_getpgid, sys_getpgid, 132, 1)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_fchdir
+TRACE_SYSCALL_TABLE(sys_fchdir, sys_fchdir, 133, 1)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_bdflush
+TRACE_SYSCALL_TABLE(sys_bdflush, sys_bdflush, 134, 2)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_sysfs
+TRACE_SYSCALL_TABLE(sys_sysfs, sys_sysfs, 135, 3)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_personality
+TRACE_SYSCALL_TABLE(sys_personality, sys_personality, 136, 1)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_setfsuid16
+TRACE_SYSCALL_TABLE(sys_setfsuid16, sys_setfsuid16, 138, 1)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_setfsgid16
+TRACE_SYSCALL_TABLE(sys_setfsgid16, sys_setfsgid16, 139, 1)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_flock
+TRACE_SYSCALL_TABLE(sys_flock, sys_flock, 143, 2)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_msync
+TRACE_SYSCALL_TABLE(sys_msync, sys_msync, 144, 3)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_getsid
+TRACE_SYSCALL_TABLE(sys_getsid, sys_getsid, 147, 1)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_fdatasync
+TRACE_SYSCALL_TABLE(sys_fdatasync, sys_fdatasync, 148, 1)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_mlock
+TRACE_SYSCALL_TABLE(sys_mlock, sys_mlock, 150, 2)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_munlock
+TRACE_SYSCALL_TABLE(sys_munlock, sys_munlock, 151, 2)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_mlockall
+TRACE_SYSCALL_TABLE(sys_mlockall, sys_mlockall, 152, 1)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_sched_getscheduler
+TRACE_SYSCALL_TABLE(sys_sched_getscheduler, sys_sched_getscheduler, 157, 1)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_sched_get_priority_max
+TRACE_SYSCALL_TABLE(sys_sched_get_priority_max, sys_sched_get_priority_max, 159, 1)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_sched_get_priority_min
+TRACE_SYSCALL_TABLE(sys_sched_get_priority_min, sys_sched_get_priority_min, 160, 1)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_mremap
+TRACE_SYSCALL_TABLE(sys_mremap, sys_mremap, 163, 5)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_setresuid16
+TRACE_SYSCALL_TABLE(sys_setresuid16, sys_setresuid16, 164, 3)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_setresgid16
+TRACE_SYSCALL_TABLE(sys_setresgid16, sys_setresgid16, 170, 3)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_prctl
+TRACE_SYSCALL_TABLE(sys_prctl, sys_prctl, 172, 5)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_setreuid
+TRACE_SYSCALL_TABLE(sys_setreuid, sys_setreuid, 203, 2)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_setregid
+TRACE_SYSCALL_TABLE(sys_setregid, sys_setregid, 204, 2)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_fchown
+TRACE_SYSCALL_TABLE(sys_fchown, sys_fchown, 207, 3)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_setresuid
+TRACE_SYSCALL_TABLE(sys_setresuid, sys_setresuid, 208, 3)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_setresgid
+TRACE_SYSCALL_TABLE(sys_setresgid, sys_setresgid, 210, 3)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_setuid
+TRACE_SYSCALL_TABLE(sys_setuid, sys_setuid, 213, 1)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_setgid
+TRACE_SYSCALL_TABLE(sys_setgid, sys_setgid, 214, 1)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_setfsuid
+TRACE_SYSCALL_TABLE(sys_setfsuid, sys_setfsuid, 215, 1)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_setfsgid
+TRACE_SYSCALL_TABLE(sys_setfsgid, sys_setfsgid, 216, 1)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_madvise
+TRACE_SYSCALL_TABLE(sys_madvise, sys_madvise, 220, 3)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_fcntl64
+TRACE_SYSCALL_TABLE(sys_fcntl64, sys_fcntl64, 221, 3)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_tkill
+TRACE_SYSCALL_TABLE(sys_tkill, sys_tkill, 238, 2)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_io_destroy
+TRACE_SYSCALL_TABLE(sys_io_destroy, sys_io_destroy, 244, 1)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_exit_group
+TRACE_SYSCALL_TABLE(sys_exit_group, sys_exit_group, 248, 1)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_epoll_create
+TRACE_SYSCALL_TABLE(sys_epoll_create, sys_epoll_create, 250, 1)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_remap_file_pages
+TRACE_SYSCALL_TABLE(sys_remap_file_pages, sys_remap_file_pages, 253, 5)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_timer_getoverrun
+TRACE_SYSCALL_TABLE(sys_timer_getoverrun, sys_timer_getoverrun, 260, 1)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_timer_delete
+TRACE_SYSCALL_TABLE(sys_timer_delete, sys_timer_delete, 261, 1)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_tgkill
+TRACE_SYSCALL_TABLE(sys_tgkill, sys_tgkill, 268, 3)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_socket
+TRACE_SYSCALL_TABLE(sys_socket, sys_socket, 281, 3)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_listen
+TRACE_SYSCALL_TABLE(sys_listen, sys_listen, 284, 2)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_shutdown
+TRACE_SYSCALL_TABLE(sys_shutdown, sys_shutdown, 293, 2)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_semget
+TRACE_SYSCALL_TABLE(sys_semget, sys_semget, 299, 3)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_msgget
+TRACE_SYSCALL_TABLE(sys_msgget, sys_msgget, 303, 2)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_shmget
+TRACE_SYSCALL_TABLE(sys_shmget, sys_shmget, 307, 3)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_keyctl
+TRACE_SYSCALL_TABLE(sys_keyctl, sys_keyctl, 311, 5)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_ioprio_set
+TRACE_SYSCALL_TABLE(sys_ioprio_set, sys_ioprio_set, 314, 3)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_ioprio_get
+TRACE_SYSCALL_TABLE(sys_ioprio_get, sys_ioprio_get, 315, 2)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_inotify_rm_watch
+TRACE_SYSCALL_TABLE(sys_inotify_rm_watch, sys_inotify_rm_watch, 318, 2)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_unshare
+TRACE_SYSCALL_TABLE(sys_unshare, sys_unshare, 337, 1)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_tee
+TRACE_SYSCALL_TABLE(sys_tee, sys_tee, 342, 4)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_timerfd_create
+TRACE_SYSCALL_TABLE(sys_timerfd_create, sys_timerfd_create, 350, 2)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_eventfd
+TRACE_SYSCALL_TABLE(sys_eventfd, sys_eventfd, 351, 1)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_eventfd2
+TRACE_SYSCALL_TABLE(sys_eventfd2, sys_eventfd2, 356, 2)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_epoll_create1
+TRACE_SYSCALL_TABLE(sys_epoll_create1, sys_epoll_create1, 357, 1)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_dup3
+TRACE_SYSCALL_TABLE(sys_dup3, sys_dup3, 358, 3)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_inotify_init1
+TRACE_SYSCALL_TABLE(sys_inotify_init1, sys_inotify_init1, 360, 1)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_fanotify_init
+TRACE_SYSCALL_TABLE(sys_fanotify_init, sys_fanotify_init, 367, 2)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_syncfs
+TRACE_SYSCALL_TABLE(sys_syncfs, sys_syncfs, 373, 1)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_setns
+TRACE_SYSCALL_TABLE(sys_setns, sys_setns, 375, 2)
+#endif
+
+#endif /* CREATE_SYSCALL_TABLE */
diff --git a/drivers/staging/lttng/instrumentation/syscalls/headers/arm-32-syscalls-3.4.25_integers_override.h b/drivers/staging/lttng/instrumentation/syscalls/headers/arm-32-syscalls-3.4.25_integers_override.h
new file mode 100644 (file)
index 0000000..895370f
--- /dev/null
@@ -0,0 +1,52 @@
+
+
+#define OVERRIDE_TABLE_32_sys_arm_fadvise64_64
+#define OVERRIDE_TABLE_32_sys_sync_file_range2
+
+#ifndef CREATE_SYSCALL_TABLE
+
+SC_TRACE_EVENT(sys_arm_fadvise64_64,
+       TP_PROTO(int fd, int advice, loff_t offset, loff_t len),
+       TP_ARGS(fd, advice, offset, len),
+       TP_STRUCT__entry(
+               __field_hex(int, fd)
+               __field_hex(int, advice)
+               __field_hex(loff_t, offset)
+               __field_hex(loff_t, len)),
+       TP_fast_assign(
+               tp_assign(fd, fd)
+               tp_assign(advice, advice)
+               tp_assign(offset, offset)
+               tp_assign(len, len)),
+       TP_printk()
+)
+
+SC_TRACE_EVENT(sys_sync_file_range2,
+       TP_PROTO(int fd, loff_t offset, loff_t nbytes, unsigned int flags),
+       TP_ARGS(fd, offset, nbytes, flags),
+       TP_STRUCT__entry(
+               __field_hex(int, fd)
+               __field_hex(loff_t, offset)
+               __field_hex(loff_t, nbytes)
+               __field_hex(unsigned int, flags)),
+       TP_fast_assign(
+               tp_assign(fd, fd)
+               tp_assign(offset, offset)
+               tp_assign(nbytes, nbytes)
+               tp_assign(flags, flags)),
+       TP_printk()
+)
+
+#else  /* CREATE_SYSCALL_TABLE */
+
+#define OVVERRIDE_TABLE_32_sys_mmap
+TRACE_SYSCALL_TABLE(sys_mmap, sys_mmap, 90, 6)
+
+#define OVERRIDE_TABLE_32_sys_arm_fadvise64_64
+TRACE_SYSCALL_TABLE(sys_arm_fadvise64_64, sys_arm_fadvise64_64, 270, 4)
+#define OVERRIDE_TABLE_32_sys_sync_file_range2
+TRACE_SYSCALL_TABLE(sys_sync_file_range2, sys_sync_file_range2, 341, 4)
+
+#endif /* CREATE_SYSCALL_TABLE */
+
+
diff --git a/drivers/staging/lttng/instrumentation/syscalls/headers/arm-32-syscalls-3.4.25_pointers.h b/drivers/staging/lttng/instrumentation/syscalls/headers/arm-32-syscalls-3.4.25_pointers.h
new file mode 100644 (file)
index 0000000..3a9c146
--- /dev/null
@@ -0,0 +1,2316 @@
+/* THIS FILE IS AUTO-GENERATED. DO NOT EDIT */
+#ifndef CREATE_SYSCALL_TABLE
+
+#if !defined(_TRACE_SYSCALLS_POINTERS_H) || defined(TRACE_HEADER_MULTI_READ)
+#define _TRACE_SYSCALLS_POINTERS_H
+
+#include <linux/tracepoint.h>
+#include <linux/syscalls.h>
+#include "arm-32-syscalls-3.4.25_pointers_override.h"
+#include "syscalls_pointers_override.h"
+
+#ifndef OVERRIDE_32_sys_unlink
+SC_TRACE_EVENT(sys_unlink,
+       TP_PROTO(const char * pathname),
+       TP_ARGS(pathname),
+       TP_STRUCT__entry(__string_from_user(pathname, pathname)),
+       TP_fast_assign(tp_copy_string_from_user(pathname, pathname)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_chdir
+SC_TRACE_EVENT(sys_chdir,
+       TP_PROTO(const char * filename),
+       TP_ARGS(filename),
+       TP_STRUCT__entry(__string_from_user(filename, filename)),
+       TP_fast_assign(tp_copy_string_from_user(filename, filename)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_rmdir
+SC_TRACE_EVENT(sys_rmdir,
+       TP_PROTO(const char * pathname),
+       TP_ARGS(pathname),
+       TP_STRUCT__entry(__string_from_user(pathname, pathname)),
+       TP_fast_assign(tp_copy_string_from_user(pathname, pathname)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_pipe
+SC_TRACE_EVENT(sys_pipe,
+       TP_PROTO(int * fildes),
+       TP_ARGS(fildes),
+       TP_STRUCT__entry(__field_hex(int *, fildes)),
+       TP_fast_assign(tp_assign(fildes, fildes)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_times
+SC_TRACE_EVENT(sys_times,
+       TP_PROTO(struct tms * tbuf),
+       TP_ARGS(tbuf),
+       TP_STRUCT__entry(__field_hex(struct tms *, tbuf)),
+       TP_fast_assign(tp_assign(tbuf, tbuf)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_acct
+SC_TRACE_EVENT(sys_acct,
+       TP_PROTO(const char * name),
+       TP_ARGS(name),
+       TP_STRUCT__entry(__string_from_user(name, name)),
+       TP_fast_assign(tp_copy_string_from_user(name, name)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_chroot
+SC_TRACE_EVENT(sys_chroot,
+       TP_PROTO(const char * filename),
+       TP_ARGS(filename),
+       TP_STRUCT__entry(__string_from_user(filename, filename)),
+       TP_fast_assign(tp_copy_string_from_user(filename, filename)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_sigpending
+SC_TRACE_EVENT(sys_sigpending,
+       TP_PROTO(old_sigset_t * set),
+       TP_ARGS(set),
+       TP_STRUCT__entry(__field_hex(old_sigset_t *, set)),
+       TP_fast_assign(tp_assign(set, set)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_uselib
+SC_TRACE_EVENT(sys_uselib,
+       TP_PROTO(const char * library),
+       TP_ARGS(library),
+       TP_STRUCT__entry(__field_hex(const char *, library)),
+       TP_fast_assign(tp_assign(library, library)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_swapoff
+SC_TRACE_EVENT(sys_swapoff,
+       TP_PROTO(const char * specialfile),
+       TP_ARGS(specialfile),
+       TP_STRUCT__entry(__string_from_user(specialfile, specialfile)),
+       TP_fast_assign(tp_copy_string_from_user(specialfile, specialfile)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_sysinfo
+SC_TRACE_EVENT(sys_sysinfo,
+       TP_PROTO(struct sysinfo * info),
+       TP_ARGS(info),
+       TP_STRUCT__entry(__field_hex(struct sysinfo *, info)),
+       TP_fast_assign(tp_assign(info, info)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_newuname
+SC_TRACE_EVENT(sys_newuname,
+       TP_PROTO(struct new_utsname * name),
+       TP_ARGS(name),
+       TP_STRUCT__entry(__field_hex(struct new_utsname *, name)),
+       TP_fast_assign(tp_assign(name, name)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_adjtimex
+SC_TRACE_EVENT(sys_adjtimex,
+       TP_PROTO(struct timex * txc_p),
+       TP_ARGS(txc_p),
+       TP_STRUCT__entry(__field_hex(struct timex *, txc_p)),
+       TP_fast_assign(tp_assign(txc_p, txc_p)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_sysctl
+SC_TRACE_EVENT(sys_sysctl,
+       TP_PROTO(struct __sysctl_args * args),
+       TP_ARGS(args),
+       TP_STRUCT__entry(__field_hex(struct __sysctl_args *, args)),
+       TP_fast_assign(tp_assign(args, args)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_set_tid_address
+SC_TRACE_EVENT(sys_set_tid_address,
+       TP_PROTO(int * tidptr),
+       TP_ARGS(tidptr),
+       TP_STRUCT__entry(__field_hex(int *, tidptr)),
+       TP_fast_assign(tp_assign(tidptr, tidptr)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_mq_unlink
+SC_TRACE_EVENT(sys_mq_unlink,
+       TP_PROTO(const char * u_name),
+       TP_ARGS(u_name),
+       TP_STRUCT__entry(__string_from_user(u_name, u_name)),
+       TP_fast_assign(tp_copy_string_from_user(u_name, u_name)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_shmdt
+SC_TRACE_EVENT(sys_shmdt,
+       TP_PROTO(char * shmaddr),
+       TP_ARGS(shmaddr),
+       TP_STRUCT__entry(__field_hex(char *, shmaddr)),
+       TP_fast_assign(tp_assign(shmaddr, shmaddr)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_creat
+SC_TRACE_EVENT(sys_creat,
+       TP_PROTO(const char * pathname, umode_t mode),
+       TP_ARGS(pathname, mode),
+       TP_STRUCT__entry(__string_from_user(pathname, pathname) __field(umode_t, mode)),
+       TP_fast_assign(tp_copy_string_from_user(pathname, pathname) tp_assign(mode, mode)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_link
+SC_TRACE_EVENT(sys_link,
+       TP_PROTO(const char * oldname, const char * newname),
+       TP_ARGS(oldname, newname),
+       TP_STRUCT__entry(__string_from_user(oldname, oldname) __string_from_user(newname, newname)),
+       TP_fast_assign(tp_copy_string_from_user(oldname, oldname) tp_copy_string_from_user(newname, newname)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_chmod
+SC_TRACE_EVENT(sys_chmod,
+       TP_PROTO(const char * filename, umode_t mode),
+       TP_ARGS(filename, mode),
+       TP_STRUCT__entry(__string_from_user(filename, filename) __field(umode_t, mode)),
+       TP_fast_assign(tp_copy_string_from_user(filename, filename) tp_assign(mode, mode)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_access
+SC_TRACE_EVENT(sys_access,
+       TP_PROTO(const char * filename, int mode),
+       TP_ARGS(filename, mode),
+       TP_STRUCT__entry(__string_from_user(filename, filename) __field(int, mode)),
+       TP_fast_assign(tp_copy_string_from_user(filename, filename) tp_assign(mode, mode)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_rename
+SC_TRACE_EVENT(sys_rename,
+       TP_PROTO(const char * oldname, const char * newname),
+       TP_ARGS(oldname, newname),
+       TP_STRUCT__entry(__string_from_user(oldname, oldname) __string_from_user(newname, newname)),
+       TP_fast_assign(tp_copy_string_from_user(oldname, oldname) tp_copy_string_from_user(newname, newname)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_mkdir
+SC_TRACE_EVENT(sys_mkdir,
+       TP_PROTO(const char * pathname, umode_t mode),
+       TP_ARGS(pathname, mode),
+       TP_STRUCT__entry(__string_from_user(pathname, pathname) __field(umode_t, mode)),
+       TP_fast_assign(tp_copy_string_from_user(pathname, pathname) tp_assign(mode, mode)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_umount
+SC_TRACE_EVENT(sys_umount,
+       TP_PROTO(char * name, int flags),
+       TP_ARGS(name, flags),
+       TP_STRUCT__entry(__string_from_user(name, name) __field(int, flags)),
+       TP_fast_assign(tp_copy_string_from_user(name, name) tp_assign(flags, flags)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_ustat
+SC_TRACE_EVENT(sys_ustat,
+       TP_PROTO(unsigned dev, struct ustat * ubuf),
+       TP_ARGS(dev, ubuf),
+       TP_STRUCT__entry(__field(unsigned, dev) __field_hex(struct ustat *, ubuf)),
+       TP_fast_assign(tp_assign(dev, dev) tp_assign(ubuf, ubuf)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_sethostname
+SC_TRACE_EVENT(sys_sethostname,
+       TP_PROTO(char * name, int len),
+       TP_ARGS(name, len),
+       TP_STRUCT__entry(__string_from_user(name, name) __field(int, len)),
+       TP_fast_assign(tp_copy_string_from_user(name, name) tp_assign(len, len)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_setrlimit
+SC_TRACE_EVENT(sys_setrlimit,
+       TP_PROTO(unsigned int resource, struct rlimit * rlim),
+       TP_ARGS(resource, rlim),
+       TP_STRUCT__entry(__field(unsigned int, resource) __field_hex(struct rlimit *, rlim)),
+       TP_fast_assign(tp_assign(resource, resource) tp_assign(rlim, rlim)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_getrusage
+SC_TRACE_EVENT(sys_getrusage,
+       TP_PROTO(int who, struct rusage * ru),
+       TP_ARGS(who, ru),
+       TP_STRUCT__entry(__field(int, who) __field_hex(struct rusage *, ru)),
+       TP_fast_assign(tp_assign(who, who) tp_assign(ru, ru)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_gettimeofday
+SC_TRACE_EVENT(sys_gettimeofday,
+       TP_PROTO(struct timeval * tv, struct timezone * tz),
+       TP_ARGS(tv, tz),
+       TP_STRUCT__entry(__field_hex(struct timeval *, tv) __field_hex(struct timezone *, tz)),
+       TP_fast_assign(tp_assign(tv, tv) tp_assign(tz, tz)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_settimeofday
+SC_TRACE_EVENT(sys_settimeofday,
+       TP_PROTO(struct timeval * tv, struct timezone * tz),
+       TP_ARGS(tv, tz),
+       TP_STRUCT__entry(__field_hex(struct timeval *, tv) __field_hex(struct timezone *, tz)),
+       TP_fast_assign(tp_assign(tv, tv) tp_assign(tz, tz)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_getgroups16
+SC_TRACE_EVENT(sys_getgroups16,
+       TP_PROTO(int gidsetsize, old_gid_t * grouplist),
+       TP_ARGS(gidsetsize, grouplist),
+       TP_STRUCT__entry(__field(int, gidsetsize) __field_hex(old_gid_t *, grouplist)),
+       TP_fast_assign(tp_assign(gidsetsize, gidsetsize) tp_assign(grouplist, grouplist)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_setgroups16
+SC_TRACE_EVENT(sys_setgroups16,
+       TP_PROTO(int gidsetsize, old_gid_t * grouplist),
+       TP_ARGS(gidsetsize, grouplist),
+       TP_STRUCT__entry(__field(int, gidsetsize) __field_hex(old_gid_t *, grouplist)),
+       TP_fast_assign(tp_assign(gidsetsize, gidsetsize) tp_assign(grouplist, grouplist)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_symlink
+SC_TRACE_EVENT(sys_symlink,
+       TP_PROTO(const char * oldname, const char * newname),
+       TP_ARGS(oldname, newname),
+       TP_STRUCT__entry(__string_from_user(oldname, oldname) __string_from_user(newname, newname)),
+       TP_fast_assign(tp_copy_string_from_user(oldname, oldname) tp_copy_string_from_user(newname, newname)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_swapon
+SC_TRACE_EVENT(sys_swapon,
+       TP_PROTO(const char * specialfile, int swap_flags),
+       TP_ARGS(specialfile, swap_flags),
+       TP_STRUCT__entry(__string_from_user(specialfile, specialfile) __field(int, swap_flags)),
+       TP_fast_assign(tp_copy_string_from_user(specialfile, specialfile) tp_assign(swap_flags, swap_flags)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_truncate
+SC_TRACE_EVENT(sys_truncate,
+       TP_PROTO(const char * path, long length),
+       TP_ARGS(path, length),
+       TP_STRUCT__entry(__string_from_user(path, path) __field(long, length)),
+       TP_fast_assign(tp_copy_string_from_user(path, path) tp_assign(length, length)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_statfs
+SC_TRACE_EVENT(sys_statfs,
+       TP_PROTO(const char * pathname, struct statfs * buf),
+       TP_ARGS(pathname, buf),
+       TP_STRUCT__entry(__string_from_user(pathname, pathname) __field_hex(struct statfs *, buf)),
+       TP_fast_assign(tp_copy_string_from_user(pathname, pathname) tp_assign(buf, buf)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_fstatfs
+SC_TRACE_EVENT(sys_fstatfs,
+       TP_PROTO(unsigned int fd, struct statfs * buf),
+       TP_ARGS(fd, buf),
+       TP_STRUCT__entry(__field(unsigned int, fd) __field_hex(struct statfs *, buf)),
+       TP_fast_assign(tp_assign(fd, fd) tp_assign(buf, buf)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_getitimer
+SC_TRACE_EVENT(sys_getitimer,
+       TP_PROTO(int which, struct itimerval * value),
+       TP_ARGS(which, value),
+       TP_STRUCT__entry(__field(int, which) __field_hex(struct itimerval *, value)),
+       TP_fast_assign(tp_assign(which, which) tp_assign(value, value)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_newstat
+SC_TRACE_EVENT(sys_newstat,
+       TP_PROTO(const char * filename, struct stat * statbuf),
+       TP_ARGS(filename, statbuf),
+       TP_STRUCT__entry(__string_from_user(filename, filename) __field_hex(struct stat *, statbuf)),
+       TP_fast_assign(tp_copy_string_from_user(filename, filename) tp_assign(statbuf, statbuf)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_newlstat
+SC_TRACE_EVENT(sys_newlstat,
+       TP_PROTO(const char * filename, struct stat * statbuf),
+       TP_ARGS(filename, statbuf),
+       TP_STRUCT__entry(__string_from_user(filename, filename) __field_hex(struct stat *, statbuf)),
+       TP_fast_assign(tp_copy_string_from_user(filename, filename) tp_assign(statbuf, statbuf)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_newfstat
+SC_TRACE_EVENT(sys_newfstat,
+       TP_PROTO(unsigned int fd, struct stat * statbuf),
+       TP_ARGS(fd, statbuf),
+       TP_STRUCT__entry(__field(unsigned int, fd) __field_hex(struct stat *, statbuf)),
+       TP_fast_assign(tp_assign(fd, fd) tp_assign(statbuf, statbuf)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_setdomainname
+SC_TRACE_EVENT(sys_setdomainname,
+       TP_PROTO(char * name, int len),
+       TP_ARGS(name, len),
+       TP_STRUCT__entry(__string_from_user(name, name) __field(int, len)),
+       TP_fast_assign(tp_copy_string_from_user(name, name) tp_assign(len, len)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_delete_module
+SC_TRACE_EVENT(sys_delete_module,
+       TP_PROTO(const char * name_user, unsigned int flags),
+       TP_ARGS(name_user, flags),
+       TP_STRUCT__entry(__string_from_user(name_user, name_user) __field(unsigned int, flags)),
+       TP_fast_assign(tp_copy_string_from_user(name_user, name_user) tp_assign(flags, flags)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_sched_setparam
+SC_TRACE_EVENT(sys_sched_setparam,
+       TP_PROTO(pid_t pid, struct sched_param * param),
+       TP_ARGS(pid, param),
+       TP_STRUCT__entry(__field(pid_t, pid) __field_hex(struct sched_param *, param)),
+       TP_fast_assign(tp_assign(pid, pid) tp_assign(param, param)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_sched_getparam
+SC_TRACE_EVENT(sys_sched_getparam,
+       TP_PROTO(pid_t pid, struct sched_param * param),
+       TP_ARGS(pid, param),
+       TP_STRUCT__entry(__field(pid_t, pid) __field_hex(struct sched_param *, param)),
+       TP_fast_assign(tp_assign(pid, pid) tp_assign(param, param)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_sched_rr_get_interval
+SC_TRACE_EVENT(sys_sched_rr_get_interval,
+       TP_PROTO(pid_t pid, struct timespec * interval),
+       TP_ARGS(pid, interval),
+       TP_STRUCT__entry(__field(pid_t, pid) __field_hex(struct timespec *, interval)),
+       TP_fast_assign(tp_assign(pid, pid) tp_assign(interval, interval)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_nanosleep
+SC_TRACE_EVENT(sys_nanosleep,
+       TP_PROTO(struct timespec * rqtp, struct timespec * rmtp),
+       TP_ARGS(rqtp, rmtp),
+       TP_STRUCT__entry(__field_hex(struct timespec *, rqtp) __field_hex(struct timespec *, rmtp)),
+       TP_fast_assign(tp_assign(rqtp, rqtp) tp_assign(rmtp, rmtp)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_rt_sigpending
+SC_TRACE_EVENT(sys_rt_sigpending,
+       TP_PROTO(sigset_t * set, size_t sigsetsize),
+       TP_ARGS(set, sigsetsize),
+       TP_STRUCT__entry(__field_hex(sigset_t *, set) __field(size_t, sigsetsize)),
+       TP_fast_assign(tp_assign(set, set) tp_assign(sigsetsize, sigsetsize)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_rt_sigsuspend
+SC_TRACE_EVENT(sys_rt_sigsuspend,
+       TP_PROTO(sigset_t * unewset, size_t sigsetsize),
+       TP_ARGS(unewset, sigsetsize),
+       TP_STRUCT__entry(__field_hex(sigset_t *, unewset) __field(size_t, sigsetsize)),
+       TP_fast_assign(tp_assign(unewset, unewset) tp_assign(sigsetsize, sigsetsize)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_getcwd
+SC_TRACE_EVENT(sys_getcwd,
+       TP_PROTO(char * buf, unsigned long size),
+       TP_ARGS(buf, size),
+       TP_STRUCT__entry(__field_hex(char *, buf) __field(unsigned long, size)),
+       TP_fast_assign(tp_assign(buf, buf) tp_assign(size, size)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_getrlimit
+SC_TRACE_EVENT(sys_getrlimit,
+       TP_PROTO(unsigned int resource, struct rlimit * rlim),
+       TP_ARGS(resource, rlim),
+       TP_STRUCT__entry(__field(unsigned int, resource) __field_hex(struct rlimit *, rlim)),
+       TP_fast_assign(tp_assign(resource, resource) tp_assign(rlim, rlim)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_stat64
+SC_TRACE_EVENT(sys_stat64,
+       TP_PROTO(const char * filename, struct stat64 * statbuf),
+       TP_ARGS(filename, statbuf),
+       TP_STRUCT__entry(__string_from_user(filename, filename) __field_hex(struct stat64 *, statbuf)),
+       TP_fast_assign(tp_copy_string_from_user(filename, filename) tp_assign(statbuf, statbuf)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_lstat64
+SC_TRACE_EVENT(sys_lstat64,
+       TP_PROTO(const char * filename, struct stat64 * statbuf),
+       TP_ARGS(filename, statbuf),
+       TP_STRUCT__entry(__string_from_user(filename, filename) __field_hex(struct stat64 *, statbuf)),
+       TP_fast_assign(tp_copy_string_from_user(filename, filename) tp_assign(statbuf, statbuf)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_fstat64
+SC_TRACE_EVENT(sys_fstat64,
+       TP_PROTO(unsigned long fd, struct stat64 * statbuf),
+       TP_ARGS(fd, statbuf),
+       TP_STRUCT__entry(__field(unsigned long, fd) __field_hex(struct stat64 *, statbuf)),
+       TP_fast_assign(tp_assign(fd, fd) tp_assign(statbuf, statbuf)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_getgroups
+SC_TRACE_EVENT(sys_getgroups,
+       TP_PROTO(int gidsetsize, gid_t * grouplist),
+       TP_ARGS(gidsetsize, grouplist),
+       TP_STRUCT__entry(__field(int, gidsetsize) __field_hex(gid_t *, grouplist)),
+       TP_fast_assign(tp_assign(gidsetsize, gidsetsize) tp_assign(grouplist, grouplist)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_setgroups
+SC_TRACE_EVENT(sys_setgroups,
+       TP_PROTO(int gidsetsize, gid_t * grouplist),
+       TP_ARGS(gidsetsize, grouplist),
+       TP_STRUCT__entry(__field(int, gidsetsize) __field_hex(gid_t *, grouplist)),
+       TP_fast_assign(tp_assign(gidsetsize, gidsetsize) tp_assign(grouplist, grouplist)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_pivot_root
+SC_TRACE_EVENT(sys_pivot_root,
+       TP_PROTO(const char * new_root, const char * put_old),
+       TP_ARGS(new_root, put_old),
+       TP_STRUCT__entry(__string_from_user(new_root, new_root) __string_from_user(put_old, put_old)),
+       TP_fast_assign(tp_copy_string_from_user(new_root, new_root) tp_copy_string_from_user(put_old, put_old)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_removexattr
+SC_TRACE_EVENT(sys_removexattr,
+       TP_PROTO(const char * pathname, const char * name),
+       TP_ARGS(pathname, name),
+       TP_STRUCT__entry(__string_from_user(pathname, pathname) __string_from_user(name, name)),
+       TP_fast_assign(tp_copy_string_from_user(pathname, pathname) tp_copy_string_from_user(name, name)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_lremovexattr
+SC_TRACE_EVENT(sys_lremovexattr,
+       TP_PROTO(const char * pathname, const char * name),
+       TP_ARGS(pathname, name),
+       TP_STRUCT__entry(__string_from_user(pathname, pathname) __string_from_user(name, name)),
+       TP_fast_assign(tp_copy_string_from_user(pathname, pathname) tp_copy_string_from_user(name, name)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_fremovexattr
+SC_TRACE_EVENT(sys_fremovexattr,
+       TP_PROTO(int fd, const char * name),
+       TP_ARGS(fd, name),
+       TP_STRUCT__entry(__field(int, fd) __string_from_user(name, name)),
+       TP_fast_assign(tp_assign(fd, fd) tp_copy_string_from_user(name, name)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_io_setup
+SC_TRACE_EVENT(sys_io_setup,
+       TP_PROTO(unsigned nr_events, aio_context_t * ctxp),
+       TP_ARGS(nr_events, ctxp),
+       TP_STRUCT__entry(__field(unsigned, nr_events) __field_hex(aio_context_t *, ctxp)),
+       TP_fast_assign(tp_assign(nr_events, nr_events) tp_assign(ctxp, ctxp)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_timer_gettime
+SC_TRACE_EVENT(sys_timer_gettime,
+       TP_PROTO(timer_t timer_id, struct itimerspec * setting),
+       TP_ARGS(timer_id, setting),
+       TP_STRUCT__entry(__field(timer_t, timer_id) __field_hex(struct itimerspec *, setting)),
+       TP_fast_assign(tp_assign(timer_id, timer_id) tp_assign(setting, setting)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_clock_settime
+SC_TRACE_EVENT(sys_clock_settime,
+       TP_PROTO(const clockid_t which_clock, const struct timespec * tp),
+       TP_ARGS(which_clock, tp),
+       TP_STRUCT__entry(__field(const clockid_t, which_clock) __field_hex(const struct timespec *, tp)),
+       TP_fast_assign(tp_assign(which_clock, which_clock) tp_assign(tp, tp)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_clock_gettime
+SC_TRACE_EVENT(sys_clock_gettime,
+       TP_PROTO(const clockid_t which_clock, struct timespec * tp),
+       TP_ARGS(which_clock, tp),
+       TP_STRUCT__entry(__field(const clockid_t, which_clock) __field_hex(struct timespec *, tp)),
+       TP_fast_assign(tp_assign(which_clock, which_clock) tp_assign(tp, tp)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_clock_getres
+SC_TRACE_EVENT(sys_clock_getres,
+       TP_PROTO(const clockid_t which_clock, struct timespec * tp),
+       TP_ARGS(which_clock, tp),
+       TP_STRUCT__entry(__field(const clockid_t, which_clock) __field_hex(struct timespec *, tp)),
+       TP_fast_assign(tp_assign(which_clock, which_clock) tp_assign(tp, tp)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_utimes
+SC_TRACE_EVENT(sys_utimes,
+       TP_PROTO(char * filename, struct timeval * utimes),
+       TP_ARGS(filename, utimes),
+       TP_STRUCT__entry(__string_from_user(filename, filename) __field_hex(struct timeval *, utimes)),
+       TP_fast_assign(tp_copy_string_from_user(filename, filename) tp_assign(utimes, utimes)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_mq_notify
+SC_TRACE_EVENT(sys_mq_notify,
+       TP_PROTO(mqd_t mqdes, const struct sigevent * u_notification),
+       TP_ARGS(mqdes, u_notification),
+       TP_STRUCT__entry(__field(mqd_t, mqdes) __field_hex(const struct sigevent *, u_notification)),
+       TP_fast_assign(tp_assign(mqdes, mqdes) tp_assign(u_notification, u_notification)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_set_robust_list
+SC_TRACE_EVENT(sys_set_robust_list,
+       TP_PROTO(struct robust_list_head * head, size_t len),
+       TP_ARGS(head, len),
+       TP_STRUCT__entry(__field_hex(struct robust_list_head *, head) __field(size_t, len)),
+       TP_fast_assign(tp_assign(head, head) tp_assign(len, len)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_timerfd_gettime
+SC_TRACE_EVENT(sys_timerfd_gettime,
+       TP_PROTO(int ufd, struct itimerspec * otmr),
+       TP_ARGS(ufd, otmr),
+       TP_STRUCT__entry(__field(int, ufd) __field_hex(struct itimerspec *, otmr)),
+       TP_fast_assign(tp_assign(ufd, ufd) tp_assign(otmr, otmr)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_pipe2
+SC_TRACE_EVENT(sys_pipe2,
+       TP_PROTO(int * fildes, int flags),
+       TP_ARGS(fildes, flags),
+       TP_STRUCT__entry(__field_hex(int *, fildes) __field(int, flags)),
+       TP_fast_assign(tp_assign(fildes, fildes) tp_assign(flags, flags)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_clock_adjtime
+SC_TRACE_EVENT(sys_clock_adjtime,
+       TP_PROTO(const clockid_t which_clock, struct timex * utx),
+       TP_ARGS(which_clock, utx),
+       TP_STRUCT__entry(__field(const clockid_t, which_clock) __field_hex(struct timex *, utx)),
+       TP_fast_assign(tp_assign(which_clock, which_clock) tp_assign(utx, utx)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_read
+SC_TRACE_EVENT(sys_read,
+       TP_PROTO(unsigned int fd, char * buf, size_t count),
+       TP_ARGS(fd, buf, count),
+       TP_STRUCT__entry(__field(unsigned int, fd) __field_hex(char *, buf) __field(size_t, count)),
+       TP_fast_assign(tp_assign(fd, fd) tp_assign(buf, buf) tp_assign(count, count)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_write
+SC_TRACE_EVENT(sys_write,
+       TP_PROTO(unsigned int fd, const char * buf, size_t count),
+       TP_ARGS(fd, buf, count),
+       TP_STRUCT__entry(__field(unsigned int, fd) __field_hex(const char *, buf) __field(size_t, count)),
+       TP_fast_assign(tp_assign(fd, fd) tp_assign(buf, buf) tp_assign(count, count)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_open
+SC_TRACE_EVENT(sys_open,
+       TP_PROTO(const char * filename, int flags, umode_t mode),
+       TP_ARGS(filename, flags, mode),
+       TP_STRUCT__entry(__string_from_user(filename, filename) __field(int, flags) __field(umode_t, mode)),
+       TP_fast_assign(tp_copy_string_from_user(filename, filename) tp_assign(flags, flags) tp_assign(mode, mode)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_mknod
+SC_TRACE_EVENT(sys_mknod,
+       TP_PROTO(const char * filename, umode_t mode, unsigned dev),
+       TP_ARGS(filename, mode, dev),
+       TP_STRUCT__entry(__string_from_user(filename, filename) __field(umode_t, mode) __field(unsigned, dev)),
+       TP_fast_assign(tp_copy_string_from_user(filename, filename) tp_assign(mode, mode) tp_assign(dev, dev)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_lchown16
+SC_TRACE_EVENT(sys_lchown16,
+       TP_PROTO(const char * filename, old_uid_t user, old_gid_t group),
+       TP_ARGS(filename, user, group),
+       TP_STRUCT__entry(__string_from_user(filename, filename) __field(old_uid_t, user) __field(old_gid_t, group)),
+       TP_fast_assign(tp_copy_string_from_user(filename, filename) tp_assign(user, user) tp_assign(group, group)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_readlink
+SC_TRACE_EVENT(sys_readlink,
+       TP_PROTO(const char * path, char * buf, int bufsiz),
+       TP_ARGS(path, buf, bufsiz),
+       TP_STRUCT__entry(__string_from_user(path, path) __field_hex(char *, buf) __field(int, bufsiz)),
+       TP_fast_assign(tp_copy_string_from_user(path, path) tp_assign(buf, buf) tp_assign(bufsiz, bufsiz)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_syslog
+SC_TRACE_EVENT(sys_syslog,
+       TP_PROTO(int type, char * buf, int len),
+       TP_ARGS(type, buf, len),
+       TP_STRUCT__entry(__field(int, type) __field_hex(char *, buf) __field(int, len)),
+       TP_fast_assign(tp_assign(type, type) tp_assign(buf, buf) tp_assign(len, len)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_setitimer
+SC_TRACE_EVENT(sys_setitimer,
+       TP_PROTO(int which, struct itimerval * value, struct itimerval * ovalue),
+       TP_ARGS(which, value, ovalue),
+       TP_STRUCT__entry(__field(int, which) __field_hex(struct itimerval *, value) __field_hex(struct itimerval *, ovalue)),
+       TP_fast_assign(tp_assign(which, which) tp_assign(value, value) tp_assign(ovalue, ovalue)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_sigprocmask
+SC_TRACE_EVENT(sys_sigprocmask,
+       TP_PROTO(int how, old_sigset_t * nset, old_sigset_t * oset),
+       TP_ARGS(how, nset, oset),
+       TP_STRUCT__entry(__field(int, how) __field_hex(old_sigset_t *, nset) __field_hex(old_sigset_t *, oset)),
+       TP_fast_assign(tp_assign(how, how) tp_assign(nset, nset) tp_assign(oset, oset)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_init_module
+SC_TRACE_EVENT(sys_init_module,
+       TP_PROTO(void * umod, unsigned long len, const char * uargs),
+       TP_ARGS(umod, len, uargs),
+       TP_STRUCT__entry(__field_hex(void *, umod) __field(unsigned long, len) __field_hex(const char *, uargs)),
+       TP_fast_assign(tp_assign(umod, umod) tp_assign(len, len) tp_assign(uargs, uargs)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_getdents
+SC_TRACE_EVENT(sys_getdents,
+       TP_PROTO(unsigned int fd, struct linux_dirent * dirent, unsigned int count),
+       TP_ARGS(fd, dirent, count),
+       TP_STRUCT__entry(__field(unsigned int, fd) __field_hex(struct linux_dirent *, dirent) __field(unsigned int, count)),
+       TP_fast_assign(tp_assign(fd, fd) tp_assign(dirent, dirent) tp_assign(count, count)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_readv
+SC_TRACE_EVENT(sys_readv,
+       TP_PROTO(unsigned long fd, const struct iovec * vec, unsigned long vlen),
+       TP_ARGS(fd, vec, vlen),
+       TP_STRUCT__entry(__field(unsigned long, fd) __field_hex(const struct iovec *, vec) __field(unsigned long, vlen)),
+       TP_fast_assign(tp_assign(fd, fd) tp_assign(vec, vec) tp_assign(vlen, vlen)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_writev
+SC_TRACE_EVENT(sys_writev,
+       TP_PROTO(unsigned long fd, const struct iovec * vec, unsigned long vlen),
+       TP_ARGS(fd, vec, vlen),
+       TP_STRUCT__entry(__field(unsigned long, fd) __field_hex(const struct iovec *, vec) __field(unsigned long, vlen)),
+       TP_fast_assign(tp_assign(fd, fd) tp_assign(vec, vec) tp_assign(vlen, vlen)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_sched_setscheduler
+SC_TRACE_EVENT(sys_sched_setscheduler,
+       TP_PROTO(pid_t pid, int policy, struct sched_param * param),
+       TP_ARGS(pid, policy, param),
+       TP_STRUCT__entry(__field(pid_t, pid) __field(int, policy) __field_hex(struct sched_param *, param)),
+       TP_fast_assign(tp_assign(pid, pid) tp_assign(policy, policy) tp_assign(param, param)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_getresuid16
+SC_TRACE_EVENT(sys_getresuid16,
+       TP_PROTO(old_uid_t * ruid, old_uid_t * euid, old_uid_t * suid),
+       TP_ARGS(ruid, euid, suid),
+       TP_STRUCT__entry(__field_hex(old_uid_t *, ruid) __field_hex(old_uid_t *, euid) __field_hex(old_uid_t *, suid)),
+       TP_fast_assign(tp_assign(ruid, ruid) tp_assign(euid, euid) tp_assign(suid, suid)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_poll
+SC_TRACE_EVENT(sys_poll,
+       TP_PROTO(struct pollfd * ufds, unsigned int nfds, int timeout_msecs),
+       TP_ARGS(ufds, nfds, timeout_msecs),
+       TP_STRUCT__entry(__field_hex(struct pollfd *, ufds) __field(unsigned int, nfds) __field(int, timeout_msecs)),
+       TP_fast_assign(tp_assign(ufds, ufds) tp_assign(nfds, nfds) tp_assign(timeout_msecs, timeout_msecs)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_getresgid16
+SC_TRACE_EVENT(sys_getresgid16,
+       TP_PROTO(old_gid_t * rgid, old_gid_t * egid, old_gid_t * sgid),
+       TP_ARGS(rgid, egid, sgid),
+       TP_STRUCT__entry(__field_hex(old_gid_t *, rgid) __field_hex(old_gid_t *, egid) __field_hex(old_gid_t *, sgid)),
+       TP_fast_assign(tp_assign(rgid, rgid) tp_assign(egid, egid) tp_assign(sgid, sgid)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_rt_sigqueueinfo
+SC_TRACE_EVENT(sys_rt_sigqueueinfo,
+       TP_PROTO(pid_t pid, int sig, siginfo_t * uinfo),
+       TP_ARGS(pid, sig, uinfo),
+       TP_STRUCT__entry(__field(pid_t, pid) __field(int, sig) __field_hex(siginfo_t *, uinfo)),
+       TP_fast_assign(tp_assign(pid, pid) tp_assign(sig, sig) tp_assign(uinfo, uinfo)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_chown16
+SC_TRACE_EVENT(sys_chown16,
+       TP_PROTO(const char * filename, old_uid_t user, old_gid_t group),
+       TP_ARGS(filename, user, group),
+       TP_STRUCT__entry(__string_from_user(filename, filename) __field(old_uid_t, user) __field(old_gid_t, group)),
+       TP_fast_assign(tp_copy_string_from_user(filename, filename) tp_assign(user, user) tp_assign(group, group)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_lchown
+SC_TRACE_EVENT(sys_lchown,
+       TP_PROTO(const char * filename, uid_t user, gid_t group),
+       TP_ARGS(filename, user, group),
+       TP_STRUCT__entry(__string_from_user(filename, filename) __field(uid_t, user) __field(gid_t, group)),
+       TP_fast_assign(tp_copy_string_from_user(filename, filename) tp_assign(user, user) tp_assign(group, group)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_getresuid
+SC_TRACE_EVENT(sys_getresuid,
+       TP_PROTO(uid_t * ruid, uid_t * euid, uid_t * suid),
+       TP_ARGS(ruid, euid, suid),
+       TP_STRUCT__entry(__field_hex(uid_t *, ruid) __field_hex(uid_t *, euid) __field_hex(uid_t *, suid)),
+       TP_fast_assign(tp_assign(ruid, ruid) tp_assign(euid, euid) tp_assign(suid, suid)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_getresgid
+SC_TRACE_EVENT(sys_getresgid,
+       TP_PROTO(gid_t * rgid, gid_t * egid, gid_t * sgid),
+       TP_ARGS(rgid, egid, sgid),
+       TP_STRUCT__entry(__field_hex(gid_t *, rgid) __field_hex(gid_t *, egid) __field_hex(gid_t *, sgid)),
+       TP_fast_assign(tp_assign(rgid, rgid) tp_assign(egid, egid) tp_assign(sgid, sgid)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_chown
+SC_TRACE_EVENT(sys_chown,
+       TP_PROTO(const char * filename, uid_t user, gid_t group),
+       TP_ARGS(filename, user, group),
+       TP_STRUCT__entry(__string_from_user(filename, filename) __field(uid_t, user) __field(gid_t, group)),
+       TP_fast_assign(tp_copy_string_from_user(filename, filename) tp_assign(user, user) tp_assign(group, group)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_getdents64
+SC_TRACE_EVENT(sys_getdents64,
+       TP_PROTO(unsigned int fd, struct linux_dirent64 * dirent, unsigned int count),
+       TP_ARGS(fd, dirent, count),
+       TP_STRUCT__entry(__field(unsigned int, fd) __field_hex(struct linux_dirent64 *, dirent) __field(unsigned int, count)),
+       TP_fast_assign(tp_assign(fd, fd) tp_assign(dirent, dirent) tp_assign(count, count)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_mincore
+SC_TRACE_EVENT(sys_mincore,
+       TP_PROTO(unsigned long start, size_t len, unsigned char * vec),
+       TP_ARGS(start, len, vec),
+       TP_STRUCT__entry(__field(unsigned long, start) __field(size_t, len) __field_hex(unsigned char *, vec)),
+       TP_fast_assign(tp_assign(start, start) tp_assign(len, len) tp_assign(vec, vec)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_listxattr
+SC_TRACE_EVENT(sys_listxattr,
+       TP_PROTO(const char * pathname, char * list, size_t size),
+       TP_ARGS(pathname, list, size),
+       TP_STRUCT__entry(__string_from_user(pathname, pathname) __field_hex(char *, list) __field(size_t, size)),
+       TP_fast_assign(tp_copy_string_from_user(pathname, pathname) tp_assign(list, list) tp_assign(size, size)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_llistxattr
+SC_TRACE_EVENT(sys_llistxattr,
+       TP_PROTO(const char * pathname, char * list, size_t size),
+       TP_ARGS(pathname, list, size),
+       TP_STRUCT__entry(__string_from_user(pathname, pathname) __field_hex(char *, list) __field(size_t, size)),
+       TP_fast_assign(tp_copy_string_from_user(pathname, pathname) tp_assign(list, list) tp_assign(size, size)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_flistxattr
+SC_TRACE_EVENT(sys_flistxattr,
+       TP_PROTO(int fd, char * list, size_t size),
+       TP_ARGS(fd, list, size),
+       TP_STRUCT__entry(__field(int, fd) __field_hex(char *, list) __field(size_t, size)),
+       TP_fast_assign(tp_assign(fd, fd) tp_assign(list, list) tp_assign(size, size)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_sched_setaffinity
+SC_TRACE_EVENT(sys_sched_setaffinity,
+       TP_PROTO(pid_t pid, unsigned int len, unsigned long * user_mask_ptr),
+       TP_ARGS(pid, len, user_mask_ptr),
+       TP_STRUCT__entry(__field(pid_t, pid) __field(unsigned int, len) __field_hex(unsigned long *, user_mask_ptr)),
+       TP_fast_assign(tp_assign(pid, pid) tp_assign(len, len) tp_assign(user_mask_ptr, user_mask_ptr)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_sched_getaffinity
+SC_TRACE_EVENT(sys_sched_getaffinity,
+       TP_PROTO(pid_t pid, unsigned int len, unsigned long * user_mask_ptr),
+       TP_ARGS(pid, len, user_mask_ptr),
+       TP_STRUCT__entry(__field(pid_t, pid) __field(unsigned int, len) __field_hex(unsigned long *, user_mask_ptr)),
+       TP_fast_assign(tp_assign(pid, pid) tp_assign(len, len) tp_assign(user_mask_ptr, user_mask_ptr)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_io_submit
+SC_TRACE_EVENT(sys_io_submit,
+       TP_PROTO(aio_context_t ctx_id, long nr, struct iocb * * iocbpp),
+       TP_ARGS(ctx_id, nr, iocbpp),
+       TP_STRUCT__entry(__field(aio_context_t, ctx_id) __field(long, nr) __field_hex(struct iocb * *, iocbpp)),
+       TP_fast_assign(tp_assign(ctx_id, ctx_id) tp_assign(nr, nr) tp_assign(iocbpp, iocbpp)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_io_cancel
+SC_TRACE_EVENT(sys_io_cancel,
+       TP_PROTO(aio_context_t ctx_id, struct iocb * iocb, struct io_event * result),
+       TP_ARGS(ctx_id, iocb, result),
+       TP_STRUCT__entry(__field(aio_context_t, ctx_id) __field_hex(struct iocb *, iocb) __field_hex(struct io_event *, result)),
+       TP_fast_assign(tp_assign(ctx_id, ctx_id) tp_assign(iocb, iocb) tp_assign(result, result)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_timer_create
+SC_TRACE_EVENT(sys_timer_create,
+       TP_PROTO(const clockid_t which_clock, struct sigevent * timer_event_spec, timer_t * created_timer_id),
+       TP_ARGS(which_clock, timer_event_spec, created_timer_id),
+       TP_STRUCT__entry(__field(const clockid_t, which_clock) __field_hex(struct sigevent *, timer_event_spec) __field_hex(timer_t *, created_timer_id)),
+       TP_fast_assign(tp_assign(which_clock, which_clock) tp_assign(timer_event_spec, timer_event_spec) tp_assign(created_timer_id, created_timer_id)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_mq_getsetattr
+SC_TRACE_EVENT(sys_mq_getsetattr,
+       TP_PROTO(mqd_t mqdes, const struct mq_attr * u_mqstat, struct mq_attr * u_omqstat),
+       TP_ARGS(mqdes, u_mqstat, u_omqstat),
+       TP_STRUCT__entry(__field(mqd_t, mqdes) __field_hex(const struct mq_attr *, u_mqstat) __field_hex(struct mq_attr *, u_omqstat)),
+       TP_fast_assign(tp_assign(mqdes, mqdes) tp_assign(u_mqstat, u_mqstat) tp_assign(u_omqstat, u_omqstat)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_bind
+SC_TRACE_EVENT(sys_bind,
+       TP_PROTO(int fd, struct sockaddr * umyaddr, int addrlen),
+       TP_ARGS(fd, umyaddr, addrlen),
+       TP_STRUCT__entry(__field(int, fd) __field_hex(struct sockaddr *, umyaddr) __field_hex(int, addrlen)),
+       TP_fast_assign(tp_assign(fd, fd) tp_assign(umyaddr, umyaddr) tp_assign(addrlen, addrlen)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_connect
+SC_TRACE_EVENT(sys_connect,
+       TP_PROTO(int fd, struct sockaddr * uservaddr, int addrlen),
+       TP_ARGS(fd, uservaddr, addrlen),
+       TP_STRUCT__entry(__field(int, fd) __field_hex(struct sockaddr *, uservaddr) __field_hex(int, addrlen)),
+       TP_fast_assign(tp_assign(fd, fd) tp_assign(uservaddr, uservaddr) tp_assign(addrlen, addrlen)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_accept
+SC_TRACE_EVENT(sys_accept,
+       TP_PROTO(int fd, struct sockaddr * upeer_sockaddr, int * upeer_addrlen),
+       TP_ARGS(fd, upeer_sockaddr, upeer_addrlen),
+       TP_STRUCT__entry(__field(int, fd) __field_hex(struct sockaddr *, upeer_sockaddr) __field_hex(int *, upeer_addrlen)),
+       TP_fast_assign(tp_assign(fd, fd) tp_assign(upeer_sockaddr, upeer_sockaddr) tp_assign(upeer_addrlen, upeer_addrlen)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_getsockname
+SC_TRACE_EVENT(sys_getsockname,
+       TP_PROTO(int fd, struct sockaddr * usockaddr, int * usockaddr_len),
+       TP_ARGS(fd, usockaddr, usockaddr_len),
+       TP_STRUCT__entry(__field(int, fd) __field_hex(struct sockaddr *, usockaddr) __field_hex(int *, usockaddr_len)),
+       TP_fast_assign(tp_assign(fd, fd) tp_assign(usockaddr, usockaddr) tp_assign(usockaddr_len, usockaddr_len)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_getpeername
+SC_TRACE_EVENT(sys_getpeername,
+       TP_PROTO(int fd, struct sockaddr * usockaddr, int * usockaddr_len),
+       TP_ARGS(fd, usockaddr, usockaddr_len),
+       TP_STRUCT__entry(__field(int, fd) __field_hex(struct sockaddr *, usockaddr) __field_hex(int *, usockaddr_len)),
+       TP_fast_assign(tp_assign(fd, fd) tp_assign(usockaddr, usockaddr) tp_assign(usockaddr_len, usockaddr_len)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_sendmsg
+SC_TRACE_EVENT(sys_sendmsg,
+       TP_PROTO(int fd, struct msghdr * msg, unsigned flags),
+       TP_ARGS(fd, msg, flags),
+       TP_STRUCT__entry(__field(int, fd) __field_hex(struct msghdr *, msg) __field(unsigned, flags)),
+       TP_fast_assign(tp_assign(fd, fd) tp_assign(msg, msg) tp_assign(flags, flags)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_recvmsg
+SC_TRACE_EVENT(sys_recvmsg,
+       TP_PROTO(int fd, struct msghdr * msg, unsigned int flags),
+       TP_ARGS(fd, msg, flags),
+       TP_STRUCT__entry(__field(int, fd) __field_hex(struct msghdr *, msg) __field(unsigned int, flags)),
+       TP_fast_assign(tp_assign(fd, fd) tp_assign(msg, msg) tp_assign(flags, flags)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_semop
+SC_TRACE_EVENT(sys_semop,
+       TP_PROTO(int semid, struct sembuf * tsops, unsigned nsops),
+       TP_ARGS(semid, tsops, nsops),
+       TP_STRUCT__entry(__field(int, semid) __field_hex(struct sembuf *, tsops) __field(unsigned, nsops)),
+       TP_fast_assign(tp_assign(semid, semid) tp_assign(tsops, tsops) tp_assign(nsops, nsops)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_msgctl
+SC_TRACE_EVENT(sys_msgctl,
+       TP_PROTO(int msqid, int cmd, struct msqid_ds * buf),
+       TP_ARGS(msqid, cmd, buf),
+       TP_STRUCT__entry(__field(int, msqid) __field(int, cmd) __field_hex(struct msqid_ds *, buf)),
+       TP_fast_assign(tp_assign(msqid, msqid) tp_assign(cmd, cmd) tp_assign(buf, buf)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_shmat
+SC_TRACE_EVENT(sys_shmat,
+       TP_PROTO(int shmid, char * shmaddr, int shmflg),
+       TP_ARGS(shmid, shmaddr, shmflg),
+       TP_STRUCT__entry(__field(int, shmid) __field_hex(char *, shmaddr) __field(int, shmflg)),
+       TP_fast_assign(tp_assign(shmid, shmid) tp_assign(shmaddr, shmaddr) tp_assign(shmflg, shmflg)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_shmctl
+SC_TRACE_EVENT(sys_shmctl,
+       TP_PROTO(int shmid, int cmd, struct shmid_ds * buf),
+       TP_ARGS(shmid, cmd, buf),
+       TP_STRUCT__entry(__field(int, shmid) __field(int, cmd) __field_hex(struct shmid_ds *, buf)),
+       TP_fast_assign(tp_assign(shmid, shmid) tp_assign(cmd, cmd) tp_assign(buf, buf)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_inotify_add_watch
+SC_TRACE_EVENT(sys_inotify_add_watch,
+       TP_PROTO(int fd, const char * pathname, u32 mask),
+       TP_ARGS(fd, pathname, mask),
+       TP_STRUCT__entry(__field(int, fd) __string_from_user(pathname, pathname) __field(u32, mask)),
+       TP_fast_assign(tp_assign(fd, fd) tp_copy_string_from_user(pathname, pathname) tp_assign(mask, mask)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_mkdirat
+SC_TRACE_EVENT(sys_mkdirat,
+       TP_PROTO(int dfd, const char * pathname, umode_t mode),
+       TP_ARGS(dfd, pathname, mode),
+       TP_STRUCT__entry(__field(int, dfd) __string_from_user(pathname, pathname) __field(umode_t, mode)),
+       TP_fast_assign(tp_assign(dfd, dfd) tp_copy_string_from_user(pathname, pathname) tp_assign(mode, mode)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_futimesat
+SC_TRACE_EVENT(sys_futimesat,
+       TP_PROTO(int dfd, const char * filename, struct timeval * utimes),
+       TP_ARGS(dfd, filename, utimes),
+       TP_STRUCT__entry(__field(int, dfd) __string_from_user(filename, filename) __field_hex(struct timeval *, utimes)),
+       TP_fast_assign(tp_assign(dfd, dfd) tp_copy_string_from_user(filename, filename) tp_assign(utimes, utimes)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_unlinkat
+SC_TRACE_EVENT(sys_unlinkat,
+       TP_PROTO(int dfd, const char * pathname, int flag),
+       TP_ARGS(dfd, pathname, flag),
+       TP_STRUCT__entry(__field(int, dfd) __string_from_user(pathname, pathname) __field(int, flag)),
+       TP_fast_assign(tp_assign(dfd, dfd) tp_copy_string_from_user(pathname, pathname) tp_assign(flag, flag)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_symlinkat
+SC_TRACE_EVENT(sys_symlinkat,
+       TP_PROTO(const char * oldname, int newdfd, const char * newname),
+       TP_ARGS(oldname, newdfd, newname),
+       TP_STRUCT__entry(__string_from_user(oldname, oldname) __field(int, newdfd) __string_from_user(newname, newname)),
+       TP_fast_assign(tp_copy_string_from_user(oldname, oldname) tp_assign(newdfd, newdfd) tp_copy_string_from_user(newname, newname)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_fchmodat
+SC_TRACE_EVENT(sys_fchmodat,
+       TP_PROTO(int dfd, const char * filename, umode_t mode),
+       TP_ARGS(dfd, filename, mode),
+       TP_STRUCT__entry(__field(int, dfd) __string_from_user(filename, filename) __field(umode_t, mode)),
+       TP_fast_assign(tp_assign(dfd, dfd) tp_copy_string_from_user(filename, filename) tp_assign(mode, mode)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_faccessat
+SC_TRACE_EVENT(sys_faccessat,
+       TP_PROTO(int dfd, const char * filename, int mode),
+       TP_ARGS(dfd, filename, mode),
+       TP_STRUCT__entry(__field(int, dfd) __string_from_user(filename, filename) __field(int, mode)),
+       TP_fast_assign(tp_assign(dfd, dfd) tp_copy_string_from_user(filename, filename) tp_assign(mode, mode)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_get_robust_list
+SC_TRACE_EVENT(sys_get_robust_list,
+       TP_PROTO(int pid, struct robust_list_head * * head_ptr, size_t * len_ptr),
+       TP_ARGS(pid, head_ptr, len_ptr),
+       TP_STRUCT__entry(__field(int, pid) __field_hex(struct robust_list_head * *, head_ptr) __field_hex(size_t *, len_ptr)),
+       TP_fast_assign(tp_assign(pid, pid) tp_assign(head_ptr, head_ptr) tp_assign(len_ptr, len_ptr)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_getcpu
+SC_TRACE_EVENT(sys_getcpu,
+       TP_PROTO(unsigned * cpup, unsigned * nodep, struct getcpu_cache * unused),
+       TP_ARGS(cpup, nodep, unused),
+       TP_STRUCT__entry(__field_hex(unsigned *, cpup) __field_hex(unsigned *, nodep) __field_hex(struct getcpu_cache *, unused)),
+       TP_fast_assign(tp_assign(cpup, cpup) tp_assign(nodep, nodep) tp_assign(unused, unused)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_signalfd
+SC_TRACE_EVENT(sys_signalfd,
+       TP_PROTO(int ufd, sigset_t * user_mask, size_t sizemask),
+       TP_ARGS(ufd, user_mask, sizemask),
+       TP_STRUCT__entry(__field(int, ufd) __field_hex(sigset_t *, user_mask) __field(size_t, sizemask)),
+       TP_fast_assign(tp_assign(ufd, ufd) tp_assign(user_mask, user_mask) tp_assign(sizemask, sizemask)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_open_by_handle_at
+SC_TRACE_EVENT(sys_open_by_handle_at,
+       TP_PROTO(int mountdirfd, struct file_handle * handle, int flags),
+       TP_ARGS(mountdirfd, handle, flags),
+       TP_STRUCT__entry(__field(int, mountdirfd) __field_hex(struct file_handle *, handle) __field(int, flags)),
+       TP_fast_assign(tp_assign(mountdirfd, mountdirfd) tp_assign(handle, handle) tp_assign(flags, flags)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_reboot
+SC_TRACE_EVENT(sys_reboot,
+       TP_PROTO(int magic1, int magic2, unsigned int cmd, void * arg),
+       TP_ARGS(magic1, magic2, cmd, arg),
+       TP_STRUCT__entry(__field(int, magic1) __field(int, magic2) __field(unsigned int, cmd) __field_hex(void *, arg)),
+       TP_fast_assign(tp_assign(magic1, magic1) tp_assign(magic2, magic2) tp_assign(cmd, cmd) tp_assign(arg, arg)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_wait4
+SC_TRACE_EVENT(sys_wait4,
+       TP_PROTO(pid_t upid, int * stat_addr, int options, struct rusage * ru),
+       TP_ARGS(upid, stat_addr, options, ru),
+       TP_STRUCT__entry(__field(pid_t, upid) __field_hex(int *, stat_addr) __field(int, options) __field_hex(struct rusage *, ru)),
+       TP_fast_assign(tp_assign(upid, upid) tp_assign(stat_addr, stat_addr) tp_assign(options, options) tp_assign(ru, ru)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_quotactl
+SC_TRACE_EVENT(sys_quotactl,
+       TP_PROTO(unsigned int cmd, const char * special, qid_t id, void * addr),
+       TP_ARGS(cmd, special, id, addr),
+       TP_STRUCT__entry(__field(unsigned int, cmd) __field_hex(const char *, special) __field(qid_t, id) __field_hex(void *, addr)),
+       TP_fast_assign(tp_assign(cmd, cmd) tp_assign(special, special) tp_assign(id, id) tp_assign(addr, addr)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_rt_sigaction
+SC_TRACE_EVENT(sys_rt_sigaction,
+       TP_PROTO(int sig, const struct sigaction * act, struct sigaction * oact, size_t sigsetsize),
+       TP_ARGS(sig, act, oact, sigsetsize),
+       TP_STRUCT__entry(__field(int, sig) __field_hex(const struct sigaction *, act) __field_hex(struct sigaction *, oact) __field(size_t, sigsetsize)),
+       TP_fast_assign(tp_assign(sig, sig) tp_assign(act, act) tp_assign(oact, oact) tp_assign(sigsetsize, sigsetsize)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_rt_sigprocmask
+SC_TRACE_EVENT(sys_rt_sigprocmask,
+       TP_PROTO(int how, sigset_t * nset, sigset_t * oset, size_t sigsetsize),
+       TP_ARGS(how, nset, oset, sigsetsize),
+       TP_STRUCT__entry(__field(int, how) __field_hex(sigset_t *, nset) __field_hex(sigset_t *, oset) __field(size_t, sigsetsize)),
+       TP_fast_assign(tp_assign(how, how) tp_assign(nset, nset) tp_assign(oset, oset) tp_assign(sigsetsize, sigsetsize)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_rt_sigtimedwait
+SC_TRACE_EVENT(sys_rt_sigtimedwait,
+       TP_PROTO(const sigset_t * uthese, siginfo_t * uinfo, const struct timespec * uts, size_t sigsetsize),
+       TP_ARGS(uthese, uinfo, uts, sigsetsize),
+       TP_STRUCT__entry(__field_hex(const sigset_t *, uthese) __field_hex(siginfo_t *, uinfo) __field_hex(const struct timespec *, uts) __field(size_t, sigsetsize)),
+       TP_fast_assign(tp_assign(uthese, uthese) tp_assign(uinfo, uinfo) tp_assign(uts, uts) tp_assign(sigsetsize, sigsetsize)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_sendfile
+SC_TRACE_EVENT(sys_sendfile,
+       TP_PROTO(int out_fd, int in_fd, off_t * offset, size_t count),
+       TP_ARGS(out_fd, in_fd, offset, count),
+       TP_STRUCT__entry(__field(int, out_fd) __field(int, in_fd) __field_hex(off_t *, offset) __field(size_t, count)),
+       TP_fast_assign(tp_assign(out_fd, out_fd) tp_assign(in_fd, in_fd) tp_assign(offset, offset) tp_assign(count, count)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_getxattr
+SC_TRACE_EVENT(sys_getxattr,
+       TP_PROTO(const char * pathname, const char * name, void * value, size_t size),
+       TP_ARGS(pathname, name, value, size),
+       TP_STRUCT__entry(__string_from_user(pathname, pathname) __string_from_user(name, name) __field_hex(void *, value) __field(size_t, size)),
+       TP_fast_assign(tp_copy_string_from_user(pathname, pathname) tp_copy_string_from_user(name, name) tp_assign(value, value) tp_assign(size, size)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_lgetxattr
+SC_TRACE_EVENT(sys_lgetxattr,
+       TP_PROTO(const char * pathname, const char * name, void * value, size_t size),
+       TP_ARGS(pathname, name, value, size),
+       TP_STRUCT__entry(__string_from_user(pathname, pathname) __string_from_user(name, name) __field_hex(void *, value) __field(size_t, size)),
+       TP_fast_assign(tp_copy_string_from_user(pathname, pathname) tp_copy_string_from_user(name, name) tp_assign(value, value) tp_assign(size, size)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_fgetxattr
+SC_TRACE_EVENT(sys_fgetxattr,
+       TP_PROTO(int fd, const char * name, void * value, size_t size),
+       TP_ARGS(fd, name, value, size),
+       TP_STRUCT__entry(__field(int, fd) __string_from_user(name, name) __field_hex(void *, value) __field(size_t, size)),
+       TP_fast_assign(tp_assign(fd, fd) tp_copy_string_from_user(name, name) tp_assign(value, value) tp_assign(size, size)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_sendfile64
+SC_TRACE_EVENT(sys_sendfile64,
+       TP_PROTO(int out_fd, int in_fd, loff_t * offset, size_t count),
+       TP_ARGS(out_fd, in_fd, offset, count),
+       TP_STRUCT__entry(__field(int, out_fd) __field(int, in_fd) __field_hex(loff_t *, offset) __field(size_t, count)),
+       TP_fast_assign(tp_assign(out_fd, out_fd) tp_assign(in_fd, in_fd) tp_assign(offset, offset) tp_assign(count, count)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_epoll_ctl
+SC_TRACE_EVENT(sys_epoll_ctl,
+       TP_PROTO(int epfd, int op, int fd, struct epoll_event * event),
+       TP_ARGS(epfd, op, fd, event),
+       TP_STRUCT__entry(__field(int, epfd) __field(int, op) __field(int, fd) __field_hex(struct epoll_event *, event)),
+       TP_fast_assign(tp_assign(epfd, epfd) tp_assign(op, op) tp_assign(fd, fd) tp_assign(event, event)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_epoll_wait
+SC_TRACE_EVENT(sys_epoll_wait,
+       TP_PROTO(int epfd, struct epoll_event * events, int maxevents, int timeout),
+       TP_ARGS(epfd, events, maxevents, timeout),
+       TP_STRUCT__entry(__field(int, epfd) __field_hex(struct epoll_event *, events) __field(int, maxevents) __field(int, timeout)),
+       TP_fast_assign(tp_assign(epfd, epfd) tp_assign(events, events) tp_assign(maxevents, maxevents) tp_assign(timeout, timeout)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_timer_settime
+SC_TRACE_EVENT(sys_timer_settime,
+       TP_PROTO(timer_t timer_id, int flags, const struct itimerspec * new_setting, struct itimerspec * old_setting),
+       TP_ARGS(timer_id, flags, new_setting, old_setting),
+       TP_STRUCT__entry(__field(timer_t, timer_id) __field(int, flags) __field_hex(const struct itimerspec *, new_setting) __field_hex(struct itimerspec *, old_setting)),
+       TP_fast_assign(tp_assign(timer_id, timer_id) tp_assign(flags, flags) tp_assign(new_setting, new_setting) tp_assign(old_setting, old_setting)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_clock_nanosleep
+SC_TRACE_EVENT(sys_clock_nanosleep,
+       TP_PROTO(const clockid_t which_clock, int flags, const struct timespec * rqtp, struct timespec * rmtp),
+       TP_ARGS(which_clock, flags, rqtp, rmtp),
+       TP_STRUCT__entry(__field(const clockid_t, which_clock) __field(int, flags) __field_hex(const struct timespec *, rqtp) __field_hex(struct timespec *, rmtp)),
+       TP_fast_assign(tp_assign(which_clock, which_clock) tp_assign(flags, flags) tp_assign(rqtp, rqtp) tp_assign(rmtp, rmtp)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_mq_open
+SC_TRACE_EVENT(sys_mq_open,
+       TP_PROTO(const char * u_name, int oflag, umode_t mode, struct mq_attr * u_attr),
+       TP_ARGS(u_name, oflag, mode, u_attr),
+       TP_STRUCT__entry(__string_from_user(u_name, u_name) __field(int, oflag) __field(umode_t, mode) __field_hex(struct mq_attr *, u_attr)),
+       TP_fast_assign(tp_copy_string_from_user(u_name, u_name) tp_assign(oflag, oflag) tp_assign(mode, mode) tp_assign(u_attr, u_attr)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_socketpair
+SC_TRACE_EVENT(sys_socketpair,
+       TP_PROTO(int family, int type, int protocol, int * usockvec),
+       TP_ARGS(family, type, protocol, usockvec),
+       TP_STRUCT__entry(__field(int, family) __field(int, type) __field(int, protocol) __field_hex(int *, usockvec)),
+       TP_fast_assign(tp_assign(family, family) tp_assign(type, type) tp_assign(protocol, protocol) tp_assign(usockvec, usockvec)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_send
+SC_TRACE_EVENT(sys_send,
+       TP_PROTO(int fd, void * buff, size_t len, unsigned flags),
+       TP_ARGS(fd, buff, len, flags),
+       TP_STRUCT__entry(__field(int, fd) __field_hex(void *, buff) __field(size_t, len) __field(unsigned, flags)),
+       TP_fast_assign(tp_assign(fd, fd) tp_assign(buff, buff) tp_assign(len, len) tp_assign(flags, flags)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_msgsnd
+SC_TRACE_EVENT(sys_msgsnd,
+       TP_PROTO(int msqid, struct msgbuf * msgp, size_t msgsz, int msgflg),
+       TP_ARGS(msqid, msgp, msgsz, msgflg),
+       TP_STRUCT__entry(__field(int, msqid) __field_hex(struct msgbuf *, msgp) __field(size_t, msgsz) __field(int, msgflg)),
+       TP_fast_assign(tp_assign(msqid, msqid) tp_assign(msgp, msgp) tp_assign(msgsz, msgsz) tp_assign(msgflg, msgflg)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_request_key
+SC_TRACE_EVENT(sys_request_key,
+       TP_PROTO(const char * _type, const char * _description, const char * _callout_info, key_serial_t destringid),
+       TP_ARGS(_type, _description, _callout_info, destringid),
+       TP_STRUCT__entry(__string_from_user(_type, _type) __field_hex(const char *, _description) __field_hex(const char *, _callout_info) __field(key_serial_t, destringid)),
+       TP_fast_assign(tp_copy_string_from_user(_type, _type) tp_assign(_description, _description) tp_assign(_callout_info, _callout_info) tp_assign(destringid, destringid)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_semtimedop
+SC_TRACE_EVENT(sys_semtimedop,
+       TP_PROTO(int semid, struct sembuf * tsops, unsigned nsops, const struct timespec * timeout),
+       TP_ARGS(semid, tsops, nsops, timeout),
+       TP_STRUCT__entry(__field(int, semid) __field_hex(struct sembuf *, tsops) __field(unsigned, nsops) __field_hex(const struct timespec *, timeout)),
+       TP_fast_assign(tp_assign(semid, semid) tp_assign(tsops, tsops) tp_assign(nsops, nsops) tp_assign(timeout, timeout)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_openat
+SC_TRACE_EVENT(sys_openat,
+       TP_PROTO(int dfd, const char * filename, int flags, umode_t mode),
+       TP_ARGS(dfd, filename, flags, mode),
+       TP_STRUCT__entry(__field(int, dfd) __string_from_user(filename, filename) __field(int, flags) __field(umode_t, mode)),
+       TP_fast_assign(tp_assign(dfd, dfd) tp_copy_string_from_user(filename, filename) tp_assign(flags, flags) tp_assign(mode, mode)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_mknodat
+SC_TRACE_EVENT(sys_mknodat,
+       TP_PROTO(int dfd, const char * filename, umode_t mode, unsigned dev),
+       TP_ARGS(dfd, filename, mode, dev),
+       TP_STRUCT__entry(__field(int, dfd) __string_from_user(filename, filename) __field(umode_t, mode) __field(unsigned, dev)),
+       TP_fast_assign(tp_assign(dfd, dfd) tp_copy_string_from_user(filename, filename) tp_assign(mode, mode) tp_assign(dev, dev)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_fstatat64
+SC_TRACE_EVENT(sys_fstatat64,
+       TP_PROTO(int dfd, const char * filename, struct stat64 * statbuf, int flag),
+       TP_ARGS(dfd, filename, statbuf, flag),
+       TP_STRUCT__entry(__field(int, dfd) __string_from_user(filename, filename) __field_hex(struct stat64 *, statbuf) __field(int, flag)),
+       TP_fast_assign(tp_assign(dfd, dfd) tp_copy_string_from_user(filename, filename) tp_assign(statbuf, statbuf) tp_assign(flag, flag)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_renameat
+SC_TRACE_EVENT(sys_renameat,
+       TP_PROTO(int olddfd, const char * oldname, int newdfd, const char * newname),
+       TP_ARGS(olddfd, oldname, newdfd, newname),
+       TP_STRUCT__entry(__field(int, olddfd) __string_from_user(oldname, oldname) __field(int, newdfd) __string_from_user(newname, newname)),
+       TP_fast_assign(tp_assign(olddfd, olddfd) tp_copy_string_from_user(oldname, oldname) tp_assign(newdfd, newdfd) tp_copy_string_from_user(newname, newname)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_readlinkat
+SC_TRACE_EVENT(sys_readlinkat,
+       TP_PROTO(int dfd, const char * pathname, char * buf, int bufsiz),
+       TP_ARGS(dfd, pathname, buf, bufsiz),
+       TP_STRUCT__entry(__field(int, dfd) __string_from_user(pathname, pathname) __field_hex(char *, buf) __field(int, bufsiz)),
+       TP_fast_assign(tp_assign(dfd, dfd) tp_copy_string_from_user(pathname, pathname) tp_assign(buf, buf) tp_assign(bufsiz, bufsiz)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_vmsplice
+SC_TRACE_EVENT(sys_vmsplice,
+       TP_PROTO(int fd, const struct iovec * iov, unsigned long nr_segs, unsigned int flags),
+       TP_ARGS(fd, iov, nr_segs, flags),
+       TP_STRUCT__entry(__field(int, fd) __field_hex(const struct iovec *, iov) __field(unsigned long, nr_segs) __field(unsigned int, flags)),
+       TP_fast_assign(tp_assign(fd, fd) tp_assign(iov, iov) tp_assign(nr_segs, nr_segs) tp_assign(flags, flags)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_utimensat
+SC_TRACE_EVENT(sys_utimensat,
+       TP_PROTO(int dfd, const char * filename, struct timespec * utimes, int flags),
+       TP_ARGS(dfd, filename, utimes, flags),
+       TP_STRUCT__entry(__field(int, dfd) __string_from_user(filename, filename) __field_hex(struct timespec *, utimes) __field(int, flags)),
+       TP_fast_assign(tp_assign(dfd, dfd) tp_copy_string_from_user(filename, filename) tp_assign(utimes, utimes) tp_assign(flags, flags)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_timerfd_settime
+SC_TRACE_EVENT(sys_timerfd_settime,
+       TP_PROTO(int ufd, int flags, const struct itimerspec * utmr, struct itimerspec * otmr),
+       TP_ARGS(ufd, flags, utmr, otmr),
+       TP_STRUCT__entry(__field(int, ufd) __field(int, flags) __field_hex(const struct itimerspec *, utmr) __field_hex(struct itimerspec *, otmr)),
+       TP_fast_assign(tp_assign(ufd, ufd) tp_assign(flags, flags) tp_assign(utmr, utmr) tp_assign(otmr, otmr)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_signalfd4
+SC_TRACE_EVENT(sys_signalfd4,
+       TP_PROTO(int ufd, sigset_t * user_mask, size_t sizemask, int flags),
+       TP_ARGS(ufd, user_mask, sizemask, flags),
+       TP_STRUCT__entry(__field(int, ufd) __field_hex(sigset_t *, user_mask) __field(size_t, sizemask) __field(int, flags)),
+       TP_fast_assign(tp_assign(ufd, ufd) tp_assign(user_mask, user_mask) tp_assign(sizemask, sizemask) tp_assign(flags, flags)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_rt_tgsigqueueinfo
+SC_TRACE_EVENT(sys_rt_tgsigqueueinfo,
+       TP_PROTO(pid_t tgid, pid_t pid, int sig, siginfo_t * uinfo),
+       TP_ARGS(tgid, pid, sig, uinfo),
+       TP_STRUCT__entry(__field(pid_t, tgid) __field(pid_t, pid) __field(int, sig) __field_hex(siginfo_t *, uinfo)),
+       TP_fast_assign(tp_assign(tgid, tgid) tp_assign(pid, pid) tp_assign(sig, sig) tp_assign(uinfo, uinfo)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_accept4
+SC_TRACE_EVENT(sys_accept4,
+       TP_PROTO(int fd, struct sockaddr * upeer_sockaddr, int * upeer_addrlen, int flags),
+       TP_ARGS(fd, upeer_sockaddr, upeer_addrlen, flags),
+       TP_STRUCT__entry(__field(int, fd) __field_hex(struct sockaddr *, upeer_sockaddr) __field_hex(int *, upeer_addrlen) __field(int, flags)),
+       TP_fast_assign(tp_assign(fd, fd) tp_assign(upeer_sockaddr, upeer_sockaddr) tp_assign(upeer_addrlen, upeer_addrlen) tp_assign(flags, flags)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_prlimit64
+SC_TRACE_EVENT(sys_prlimit64,
+       TP_PROTO(pid_t pid, unsigned int resource, const struct rlimit64 * new_rlim, struct rlimit64 * old_rlim),
+       TP_ARGS(pid, resource, new_rlim, old_rlim),
+       TP_STRUCT__entry(__field(pid_t, pid) __field(unsigned int, resource) __field_hex(const struct rlimit64 *, new_rlim) __field_hex(struct rlimit64 *, old_rlim)),
+       TP_fast_assign(tp_assign(pid, pid) tp_assign(resource, resource) tp_assign(new_rlim, new_rlim) tp_assign(old_rlim, old_rlim)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_sendmmsg
+SC_TRACE_EVENT(sys_sendmmsg,
+       TP_PROTO(int fd, struct mmsghdr * mmsg, unsigned int vlen, unsigned int flags),
+       TP_ARGS(fd, mmsg, vlen, flags),
+       TP_STRUCT__entry(__field(int, fd) __field_hex(struct mmsghdr *, mmsg) __field(unsigned int, vlen) __field(unsigned int, flags)),
+       TP_fast_assign(tp_assign(fd, fd) tp_assign(mmsg, mmsg) tp_assign(vlen, vlen) tp_assign(flags, flags)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_mount
+SC_TRACE_EVENT(sys_mount,
+       TP_PROTO(char * dev_name, char * dir_name, char * type, unsigned long flags, void * data),
+       TP_ARGS(dev_name, dir_name, type, flags, data),
+       TP_STRUCT__entry(__string_from_user(dev_name, dev_name) __string_from_user(dir_name, dir_name) __string_from_user(type, type) __field(unsigned long, flags) __field_hex(void *, data)),
+       TP_fast_assign(tp_copy_string_from_user(dev_name, dev_name) tp_copy_string_from_user(dir_name, dir_name) tp_copy_string_from_user(type, type) tp_assign(flags, flags) tp_assign(data, data)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_llseek
+SC_TRACE_EVENT(sys_llseek,
+       TP_PROTO(unsigned int fd, unsigned long offset_high, unsigned long offset_low, loff_t * result, unsigned int origin),
+       TP_ARGS(fd, offset_high, offset_low, result, origin),
+       TP_STRUCT__entry(__field(unsigned int, fd) __field(unsigned long, offset_high) __field(unsigned long, offset_low) __field_hex(loff_t *, result) __field(unsigned int, origin)),
+       TP_fast_assign(tp_assign(fd, fd) tp_assign(offset_high, offset_high) tp_assign(offset_low, offset_low) tp_assign(result, result) tp_assign(origin, origin)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_select
+SC_TRACE_EVENT(sys_select,
+       TP_PROTO(int n, fd_set * inp, fd_set * outp, fd_set * exp, struct timeval * tvp),
+       TP_ARGS(n, inp, outp, exp, tvp),
+       TP_STRUCT__entry(__field(int, n) __field_hex(fd_set *, inp) __field_hex(fd_set *, outp) __field_hex(fd_set *, exp) __field_hex(struct timeval *, tvp)),
+       TP_fast_assign(tp_assign(n, n) tp_assign(inp, inp) tp_assign(outp, outp) tp_assign(exp, exp) tp_assign(tvp, tvp)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_setxattr
+SC_TRACE_EVENT(sys_setxattr,
+       TP_PROTO(const char * pathname, const char * name, const void * value, size_t size, int flags),
+       TP_ARGS(pathname, name, value, size, flags),
+       TP_STRUCT__entry(__string_from_user(pathname, pathname) __string_from_user(name, name) __field_hex(const void *, value) __field(size_t, size) __field(int, flags)),
+       TP_fast_assign(tp_copy_string_from_user(pathname, pathname) tp_copy_string_from_user(name, name) tp_assign(value, value) tp_assign(size, size) tp_assign(flags, flags)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_lsetxattr
+SC_TRACE_EVENT(sys_lsetxattr,
+       TP_PROTO(const char * pathname, const char * name, const void * value, size_t size, int flags),
+       TP_ARGS(pathname, name, value, size, flags),
+       TP_STRUCT__entry(__string_from_user(pathname, pathname) __string_from_user(name, name) __field_hex(const void *, value) __field(size_t, size) __field(int, flags)),
+       TP_fast_assign(tp_copy_string_from_user(pathname, pathname) tp_copy_string_from_user(name, name) tp_assign(value, value) tp_assign(size, size) tp_assign(flags, flags)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_fsetxattr
+SC_TRACE_EVENT(sys_fsetxattr,
+       TP_PROTO(int fd, const char * name, const void * value, size_t size, int flags),
+       TP_ARGS(fd, name, value, size, flags),
+       TP_STRUCT__entry(__field(int, fd) __string_from_user(name, name) __field_hex(const void *, value) __field(size_t, size) __field(int, flags)),
+       TP_fast_assign(tp_assign(fd, fd) tp_copy_string_from_user(name, name) tp_assign(value, value) tp_assign(size, size) tp_assign(flags, flags)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_io_getevents
+SC_TRACE_EVENT(sys_io_getevents,
+       TP_PROTO(aio_context_t ctx_id, long min_nr, long nr, struct io_event * events, struct timespec * timeout),
+       TP_ARGS(ctx_id, min_nr, nr, events, timeout),
+       TP_STRUCT__entry(__field(aio_context_t, ctx_id) __field(long, min_nr) __field(long, nr) __field_hex(struct io_event *, events) __field_hex(struct timespec *, timeout)),
+       TP_fast_assign(tp_assign(ctx_id, ctx_id) tp_assign(min_nr, min_nr) tp_assign(nr, nr) tp_assign(events, events) tp_assign(timeout, timeout)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_mq_timedsend
+SC_TRACE_EVENT(sys_mq_timedsend,
+       TP_PROTO(mqd_t mqdes, const char * u_msg_ptr, size_t msg_len, unsigned int msg_prio, const struct timespec * u_abs_timeout),
+       TP_ARGS(mqdes, u_msg_ptr, msg_len, msg_prio, u_abs_timeout),
+       TP_STRUCT__entry(__field(mqd_t, mqdes) __field_hex(const char *, u_msg_ptr) __field(size_t, msg_len) __field(unsigned int, msg_prio) __field_hex(const struct timespec *, u_abs_timeout)),
+       TP_fast_assign(tp_assign(mqdes, mqdes) tp_assign(u_msg_ptr, u_msg_ptr) tp_assign(msg_len, msg_len) tp_assign(msg_prio, msg_prio) tp_assign(u_abs_timeout, u_abs_timeout)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_mq_timedreceive
+SC_TRACE_EVENT(sys_mq_timedreceive,
+       TP_PROTO(mqd_t mqdes, char * u_msg_ptr, size_t msg_len, unsigned int * u_msg_prio, const struct timespec * u_abs_timeout),
+       TP_ARGS(mqdes, u_msg_ptr, msg_len, u_msg_prio, u_abs_timeout),
+       TP_STRUCT__entry(__field(mqd_t, mqdes) __field_hex(char *, u_msg_ptr) __field(size_t, msg_len) __field_hex(unsigned int *, u_msg_prio) __field_hex(const struct timespec *, u_abs_timeout)),
+       TP_fast_assign(tp_assign(mqdes, mqdes) tp_assign(u_msg_ptr, u_msg_ptr) tp_assign(msg_len, msg_len) tp_assign(u_msg_prio, u_msg_prio) tp_assign(u_abs_timeout, u_abs_timeout)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_waitid
+SC_TRACE_EVENT(sys_waitid,
+       TP_PROTO(int which, pid_t upid, struct siginfo * infop, int options, struct rusage * ru),
+       TP_ARGS(which, upid, infop, options, ru),
+       TP_STRUCT__entry(__field(int, which) __field(pid_t, upid) __field_hex(struct siginfo *, infop) __field(int, options) __field_hex(struct rusage *, ru)),
+       TP_fast_assign(tp_assign(which, which) tp_assign(upid, upid) tp_assign(infop, infop) tp_assign(options, options) tp_assign(ru, ru)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_setsockopt
+SC_TRACE_EVENT(sys_setsockopt,
+       TP_PROTO(int fd, int level, int optname, char * optval, int optlen),
+       TP_ARGS(fd, level, optname, optval, optlen),
+       TP_STRUCT__entry(__field(int, fd) __field(int, level) __field(int, optname) __field_hex(char *, optval) __field(int, optlen)),
+       TP_fast_assign(tp_assign(fd, fd) tp_assign(level, level) tp_assign(optname, optname) tp_assign(optval, optval) tp_assign(optlen, optlen)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_getsockopt
+SC_TRACE_EVENT(sys_getsockopt,
+       TP_PROTO(int fd, int level, int optname, char * optval, int * optlen),
+       TP_ARGS(fd, level, optname, optval, optlen),
+       TP_STRUCT__entry(__field(int, fd) __field(int, level) __field(int, optname) __field_hex(char *, optval) __field_hex(int *, optlen)),
+       TP_fast_assign(tp_assign(fd, fd) tp_assign(level, level) tp_assign(optname, optname) tp_assign(optval, optval) tp_assign(optlen, optlen)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_msgrcv
+SC_TRACE_EVENT(sys_msgrcv,
+       TP_PROTO(int msqid, struct msgbuf * msgp, size_t msgsz, long msgtyp, int msgflg),
+       TP_ARGS(msqid, msgp, msgsz, msgtyp, msgflg),
+       TP_STRUCT__entry(__field(int, msqid) __field_hex(struct msgbuf *, msgp) __field(size_t, msgsz) __field(long, msgtyp) __field(int, msgflg)),
+       TP_fast_assign(tp_assign(msqid, msqid) tp_assign(msgp, msgp) tp_assign(msgsz, msgsz) tp_assign(msgtyp, msgtyp) tp_assign(msgflg, msgflg)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_add_key
+SC_TRACE_EVENT(sys_add_key,
+       TP_PROTO(const char * _type, const char * _description, const void * _payload, size_t plen, key_serial_t ringid),
+       TP_ARGS(_type, _description, _payload, plen, ringid),
+       TP_STRUCT__entry(__string_from_user(_type, _type) __field_hex(const char *, _description) __field_hex(const void *, _payload) __field(size_t, plen) __field(key_serial_t, ringid)),
+       TP_fast_assign(tp_copy_string_from_user(_type, _type) tp_assign(_description, _description) tp_assign(_payload, _payload) tp_assign(plen, plen) tp_assign(ringid, ringid)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_fchownat
+SC_TRACE_EVENT(sys_fchownat,
+       TP_PROTO(int dfd, const char * filename, uid_t user, gid_t group, int flag),
+       TP_ARGS(dfd, filename, user, group, flag),
+       TP_STRUCT__entry(__field(int, dfd) __string_from_user(filename, filename) __field(uid_t, user) __field(gid_t, group) __field(int, flag)),
+       TP_fast_assign(tp_assign(dfd, dfd) tp_copy_string_from_user(filename, filename) tp_assign(user, user) tp_assign(group, group) tp_assign(flag, flag)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_linkat
+SC_TRACE_EVENT(sys_linkat,
+       TP_PROTO(int olddfd, const char * oldname, int newdfd, const char * newname, int flags),
+       TP_ARGS(olddfd, oldname, newdfd, newname, flags),
+       TP_STRUCT__entry(__field(int, olddfd) __string_from_user(oldname, oldname) __field(int, newdfd) __string_from_user(newname, newname) __field(int, flags)),
+       TP_fast_assign(tp_assign(olddfd, olddfd) tp_copy_string_from_user(oldname, oldname) tp_assign(newdfd, newdfd) tp_copy_string_from_user(newname, newname) tp_assign(flags, flags)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_ppoll
+SC_TRACE_EVENT(sys_ppoll,
+       TP_PROTO(struct pollfd * ufds, unsigned int nfds, struct timespec * tsp, const sigset_t * sigmask, size_t sigsetsize),
+       TP_ARGS(ufds, nfds, tsp, sigmask, sigsetsize),
+       TP_STRUCT__entry(__field_hex(struct pollfd *, ufds) __field(unsigned int, nfds) __field_hex(struct timespec *, tsp) __field_hex(const sigset_t *, sigmask) __field(size_t, sigsetsize)),
+       TP_fast_assign(tp_assign(ufds, ufds) tp_assign(nfds, nfds) tp_assign(tsp, tsp) tp_assign(sigmask, sigmask) tp_assign(sigsetsize, sigsetsize)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_preadv
+SC_TRACE_EVENT(sys_preadv,
+       TP_PROTO(unsigned long fd, const struct iovec * vec, unsigned long vlen, unsigned long pos_l, unsigned long pos_h),
+       TP_ARGS(fd, vec, vlen, pos_l, pos_h),
+       TP_STRUCT__entry(__field(unsigned long, fd) __field_hex(const struct iovec *, vec) __field(unsigned long, vlen) __field(unsigned long, pos_l) __field(unsigned long, pos_h)),
+       TP_fast_assign(tp_assign(fd, fd) tp_assign(vec, vec) tp_assign(vlen, vlen) tp_assign(pos_l, pos_l) tp_assign(pos_h, pos_h)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_pwritev
+SC_TRACE_EVENT(sys_pwritev,
+       TP_PROTO(unsigned long fd, const struct iovec * vec, unsigned long vlen, unsigned long pos_l, unsigned long pos_h),
+       TP_ARGS(fd, vec, vlen, pos_l, pos_h),
+       TP_STRUCT__entry(__field(unsigned long, fd) __field_hex(const struct iovec *, vec) __field(unsigned long, vlen) __field(unsigned long, pos_l) __field(unsigned long, pos_h)),
+       TP_fast_assign(tp_assign(fd, fd) tp_assign(vec, vec) tp_assign(vlen, vlen) tp_assign(pos_l, pos_l) tp_assign(pos_h, pos_h)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_perf_event_open
+SC_TRACE_EVENT(sys_perf_event_open,
+       TP_PROTO(struct perf_event_attr * attr_uptr, pid_t pid, int cpu, int group_fd, unsigned long flags),
+       TP_ARGS(attr_uptr, pid, cpu, group_fd, flags),
+       TP_STRUCT__entry(__field_hex(struct perf_event_attr *, attr_uptr) __field(pid_t, pid) __field(int, cpu) __field(int, group_fd) __field(unsigned long, flags)),
+       TP_fast_assign(tp_assign(attr_uptr, attr_uptr) tp_assign(pid, pid) tp_assign(cpu, cpu) tp_assign(group_fd, group_fd) tp_assign(flags, flags)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_recvmmsg
+SC_TRACE_EVENT(sys_recvmmsg,
+       TP_PROTO(int fd, struct mmsghdr * mmsg, unsigned int vlen, unsigned int flags, struct timespec * timeout),
+       TP_ARGS(fd, mmsg, vlen, flags, timeout),
+       TP_STRUCT__entry(__field(int, fd) __field_hex(struct mmsghdr *, mmsg) __field(unsigned int, vlen) __field(unsigned int, flags) __field_hex(struct timespec *, timeout)),
+       TP_fast_assign(tp_assign(fd, fd) tp_assign(mmsg, mmsg) tp_assign(vlen, vlen) tp_assign(flags, flags) tp_assign(timeout, timeout)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_name_to_handle_at
+SC_TRACE_EVENT(sys_name_to_handle_at,
+       TP_PROTO(int dfd, const char * name, struct file_handle * handle, int * mnt_id, int flag),
+       TP_ARGS(dfd, name, handle, mnt_id, flag),
+       TP_STRUCT__entry(__field(int, dfd) __string_from_user(name, name) __field_hex(struct file_handle *, handle) __field_hex(int *, mnt_id) __field(int, flag)),
+       TP_fast_assign(tp_assign(dfd, dfd) tp_copy_string_from_user(name, name) tp_assign(handle, handle) tp_assign(mnt_id, mnt_id) tp_assign(flag, flag)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_futex
+SC_TRACE_EVENT(sys_futex,
+       TP_PROTO(u32 * uaddr, int op, u32 val, struct timespec * utime, u32 * uaddr2, u32 val3),
+       TP_ARGS(uaddr, op, val, utime, uaddr2, val3),
+       TP_STRUCT__entry(__field_hex(u32 *, uaddr) __field(int, op) __field(u32, val) __field_hex(struct timespec *, utime) __field_hex(u32 *, uaddr2) __field(u32, val3)),
+       TP_fast_assign(tp_assign(uaddr, uaddr) tp_assign(op, op) tp_assign(val, val) tp_assign(utime, utime) tp_assign(uaddr2, uaddr2) tp_assign(val3, val3)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_sendto
+SC_TRACE_EVENT(sys_sendto,
+       TP_PROTO(int fd, void * buff, size_t len, unsigned flags, struct sockaddr * addr, int addr_len),
+       TP_ARGS(fd, buff, len, flags, addr, addr_len),
+       TP_STRUCT__entry(__field(int, fd) __field_hex(void *, buff) __field(size_t, len) __field(unsigned, flags) __field_hex(struct sockaddr *, addr) __field_hex(int, addr_len)),
+       TP_fast_assign(tp_assign(fd, fd) tp_assign(buff, buff) tp_assign(len, len) tp_assign(flags, flags) tp_assign(addr, addr) tp_assign(addr_len, addr_len)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_recvfrom
+SC_TRACE_EVENT(sys_recvfrom,
+       TP_PROTO(int fd, void * ubuf, size_t size, unsigned flags, struct sockaddr * addr, int * addr_len),
+       TP_ARGS(fd, ubuf, size, flags, addr, addr_len),
+       TP_STRUCT__entry(__field(int, fd) __field_hex(void *, ubuf) __field(size_t, size) __field(unsigned, flags) __field_hex(struct sockaddr *, addr) __field_hex(int *, addr_len)),
+       TP_fast_assign(tp_assign(fd, fd) tp_assign(ubuf, ubuf) tp_assign(size, size) tp_assign(flags, flags) tp_assign(addr, addr) tp_assign(addr_len, addr_len)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_pselect6
+SC_TRACE_EVENT(sys_pselect6,
+       TP_PROTO(int n, fd_set * inp, fd_set * outp, fd_set * exp, struct timespec * tsp, void * sig),
+       TP_ARGS(n, inp, outp, exp, tsp, sig),
+       TP_STRUCT__entry(__field(int, n) __field_hex(fd_set *, inp) __field_hex(fd_set *, outp) __field_hex(fd_set *, exp) __field_hex(struct timespec *, tsp) __field_hex(void *, sig)),
+       TP_fast_assign(tp_assign(n, n) tp_assign(inp, inp) tp_assign(outp, outp) tp_assign(exp, exp) tp_assign(tsp, tsp) tp_assign(sig, sig)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_splice
+SC_TRACE_EVENT(sys_splice,
+       TP_PROTO(int fd_in, loff_t * off_in, int fd_out, loff_t * off_out, size_t len, unsigned int flags),
+       TP_ARGS(fd_in, off_in, fd_out, off_out, len, flags),
+       TP_STRUCT__entry(__field(int, fd_in) __field_hex(loff_t *, off_in) __field(int, fd_out) __field_hex(loff_t *, off_out) __field(size_t, len) __field(unsigned int, flags)),
+       TP_fast_assign(tp_assign(fd_in, fd_in) tp_assign(off_in, off_in) tp_assign(fd_out, fd_out) tp_assign(off_out, off_out) tp_assign(len, len) tp_assign(flags, flags)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_epoll_pwait
+SC_TRACE_EVENT(sys_epoll_pwait,
+       TP_PROTO(int epfd, struct epoll_event * events, int maxevents, int timeout, const sigset_t * sigmask, size_t sigsetsize),
+       TP_ARGS(epfd, events, maxevents, timeout, sigmask, sigsetsize),
+       TP_STRUCT__entry(__field(int, epfd) __field_hex(struct epoll_event *, events) __field(int, maxevents) __field(int, timeout) __field_hex(const sigset_t *, sigmask) __field(size_t, sigsetsize)),
+       TP_fast_assign(tp_assign(epfd, epfd) tp_assign(events, events) tp_assign(maxevents, maxevents) tp_assign(timeout, timeout) tp_assign(sigmask, sigmask) tp_assign(sigsetsize, sigsetsize)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_process_vm_readv
+SC_TRACE_EVENT(sys_process_vm_readv,
+       TP_PROTO(pid_t pid, const struct iovec * lvec, unsigned long liovcnt, const struct iovec * rvec, unsigned long riovcnt, unsigned long flags),
+       TP_ARGS(pid, lvec, liovcnt, rvec, riovcnt, flags),
+       TP_STRUCT__entry(__field(pid_t, pid) __field_hex(const struct iovec *, lvec) __field(unsigned long, liovcnt) __field_hex(const struct iovec *, rvec) __field(unsigned long, riovcnt) __field(unsigned long, flags)),
+       TP_fast_assign(tp_assign(pid, pid) tp_assign(lvec, lvec) tp_assign(liovcnt, liovcnt) tp_assign(rvec, rvec) tp_assign(riovcnt, riovcnt) tp_assign(flags, flags)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_process_vm_writev
+SC_TRACE_EVENT(sys_process_vm_writev,
+       TP_PROTO(pid_t pid, const struct iovec * lvec, unsigned long liovcnt, const struct iovec * rvec, unsigned long riovcnt, unsigned long flags),
+       TP_ARGS(pid, lvec, liovcnt, rvec, riovcnt, flags),
+       TP_STRUCT__entry(__field(pid_t, pid) __field_hex(const struct iovec *, lvec) __field(unsigned long, liovcnt) __field_hex(const struct iovec *, rvec) __field(unsigned long, riovcnt) __field(unsigned long, flags)),
+       TP_fast_assign(tp_assign(pid, pid) tp_assign(lvec, lvec) tp_assign(liovcnt, liovcnt) tp_assign(rvec, rvec) tp_assign(riovcnt, riovcnt) tp_assign(flags, flags)),
+       TP_printk()
+)
+#endif
+
+#endif /*  _TRACE_SYSCALLS_POINTERS_H */
+
+/* This part must be outside protection */
+#include "../../../probes/define_trace.h"
+
+#else /* CREATE_SYSCALL_TABLE */
+
+#include "arm-32-syscalls-3.4.25_pointers_override.h"
+#include "syscalls_pointers_override.h"
+
+#ifndef OVERRIDE_TABLE_32_sys_read
+TRACE_SYSCALL_TABLE(sys_read, sys_read, 3, 3)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_write
+TRACE_SYSCALL_TABLE(sys_write, sys_write, 4, 3)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_open
+TRACE_SYSCALL_TABLE(sys_open, sys_open, 5, 3)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_creat
+TRACE_SYSCALL_TABLE(sys_creat, sys_creat, 8, 2)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_link
+TRACE_SYSCALL_TABLE(sys_link, sys_link, 9, 2)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_unlink
+TRACE_SYSCALL_TABLE(sys_unlink, sys_unlink, 10, 1)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_chdir
+TRACE_SYSCALL_TABLE(sys_chdir, sys_chdir, 12, 1)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_mknod
+TRACE_SYSCALL_TABLE(sys_mknod, sys_mknod, 14, 3)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_chmod
+TRACE_SYSCALL_TABLE(sys_chmod, sys_chmod, 15, 2)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_lchown16
+TRACE_SYSCALL_TABLE(sys_lchown16, sys_lchown16, 16, 3)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_mount
+TRACE_SYSCALL_TABLE(sys_mount, sys_mount, 21, 5)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_access
+TRACE_SYSCALL_TABLE(sys_access, sys_access, 33, 2)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_rename
+TRACE_SYSCALL_TABLE(sys_rename, sys_rename, 38, 2)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_mkdir
+TRACE_SYSCALL_TABLE(sys_mkdir, sys_mkdir, 39, 2)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_rmdir
+TRACE_SYSCALL_TABLE(sys_rmdir, sys_rmdir, 40, 1)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_pipe
+TRACE_SYSCALL_TABLE(sys_pipe, sys_pipe, 42, 1)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_times
+TRACE_SYSCALL_TABLE(sys_times, sys_times, 43, 1)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_acct
+TRACE_SYSCALL_TABLE(sys_acct, sys_acct, 51, 1)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_umount
+TRACE_SYSCALL_TABLE(sys_umount, sys_umount, 52, 2)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_chroot
+TRACE_SYSCALL_TABLE(sys_chroot, sys_chroot, 61, 1)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_ustat
+TRACE_SYSCALL_TABLE(sys_ustat, sys_ustat, 62, 2)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_sigpending
+TRACE_SYSCALL_TABLE(sys_sigpending, sys_sigpending, 73, 1)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_sethostname
+TRACE_SYSCALL_TABLE(sys_sethostname, sys_sethostname, 74, 2)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_setrlimit
+TRACE_SYSCALL_TABLE(sys_setrlimit, sys_setrlimit, 75, 2)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_getrusage
+TRACE_SYSCALL_TABLE(sys_getrusage, sys_getrusage, 77, 2)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_gettimeofday
+TRACE_SYSCALL_TABLE(sys_gettimeofday, sys_gettimeofday, 78, 2)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_settimeofday
+TRACE_SYSCALL_TABLE(sys_settimeofday, sys_settimeofday, 79, 2)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_getgroups16
+TRACE_SYSCALL_TABLE(sys_getgroups16, sys_getgroups16, 80, 2)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_setgroups16
+TRACE_SYSCALL_TABLE(sys_setgroups16, sys_setgroups16, 81, 2)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_symlink
+TRACE_SYSCALL_TABLE(sys_symlink, sys_symlink, 83, 2)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_readlink
+TRACE_SYSCALL_TABLE(sys_readlink, sys_readlink, 85, 3)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_uselib
+TRACE_SYSCALL_TABLE(sys_uselib, sys_uselib, 86, 1)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_swapon
+TRACE_SYSCALL_TABLE(sys_swapon, sys_swapon, 87, 2)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_reboot
+TRACE_SYSCALL_TABLE(sys_reboot, sys_reboot, 88, 4)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_truncate
+TRACE_SYSCALL_TABLE(sys_truncate, sys_truncate, 92, 2)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_statfs
+TRACE_SYSCALL_TABLE(sys_statfs, sys_statfs, 99, 2)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_fstatfs
+TRACE_SYSCALL_TABLE(sys_fstatfs, sys_fstatfs, 100, 2)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_syslog
+TRACE_SYSCALL_TABLE(sys_syslog, sys_syslog, 103, 3)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_setitimer
+TRACE_SYSCALL_TABLE(sys_setitimer, sys_setitimer, 104, 3)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_getitimer
+TRACE_SYSCALL_TABLE(sys_getitimer, sys_getitimer, 105, 2)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_newstat
+TRACE_SYSCALL_TABLE(sys_newstat, sys_newstat, 106, 2)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_newlstat
+TRACE_SYSCALL_TABLE(sys_newlstat, sys_newlstat, 107, 2)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_newfstat
+TRACE_SYSCALL_TABLE(sys_newfstat, sys_newfstat, 108, 2)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_wait4
+TRACE_SYSCALL_TABLE(sys_wait4, sys_wait4, 114, 4)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_swapoff
+TRACE_SYSCALL_TABLE(sys_swapoff, sys_swapoff, 115, 1)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_sysinfo
+TRACE_SYSCALL_TABLE(sys_sysinfo, sys_sysinfo, 116, 1)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_setdomainname
+TRACE_SYSCALL_TABLE(sys_setdomainname, sys_setdomainname, 121, 2)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_newuname
+TRACE_SYSCALL_TABLE(sys_newuname, sys_newuname, 122, 1)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_adjtimex
+TRACE_SYSCALL_TABLE(sys_adjtimex, sys_adjtimex, 124, 1)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_sigprocmask
+TRACE_SYSCALL_TABLE(sys_sigprocmask, sys_sigprocmask, 126, 3)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_init_module
+TRACE_SYSCALL_TABLE(sys_init_module, sys_init_module, 128, 3)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_delete_module
+TRACE_SYSCALL_TABLE(sys_delete_module, sys_delete_module, 129, 2)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_quotactl
+TRACE_SYSCALL_TABLE(sys_quotactl, sys_quotactl, 131, 4)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_llseek
+TRACE_SYSCALL_TABLE(sys_llseek, sys_llseek, 140, 5)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_getdents
+TRACE_SYSCALL_TABLE(sys_getdents, sys_getdents, 141, 3)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_select
+TRACE_SYSCALL_TABLE(sys_select, sys_select, 142, 5)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_readv
+TRACE_SYSCALL_TABLE(sys_readv, sys_readv, 145, 3)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_writev
+TRACE_SYSCALL_TABLE(sys_writev, sys_writev, 146, 3)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_sysctl
+TRACE_SYSCALL_TABLE(sys_sysctl, sys_sysctl, 149, 1)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_sched_setparam
+TRACE_SYSCALL_TABLE(sys_sched_setparam, sys_sched_setparam, 154, 2)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_sched_getparam
+TRACE_SYSCALL_TABLE(sys_sched_getparam, sys_sched_getparam, 155, 2)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_sched_setscheduler
+TRACE_SYSCALL_TABLE(sys_sched_setscheduler, sys_sched_setscheduler, 156, 3)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_sched_rr_get_interval
+TRACE_SYSCALL_TABLE(sys_sched_rr_get_interval, sys_sched_rr_get_interval, 161, 2)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_nanosleep
+TRACE_SYSCALL_TABLE(sys_nanosleep, sys_nanosleep, 162, 2)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_getresuid16
+TRACE_SYSCALL_TABLE(sys_getresuid16, sys_getresuid16, 165, 3)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_poll
+TRACE_SYSCALL_TABLE(sys_poll, sys_poll, 168, 3)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_getresgid16
+TRACE_SYSCALL_TABLE(sys_getresgid16, sys_getresgid16, 171, 3)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_rt_sigaction
+TRACE_SYSCALL_TABLE(sys_rt_sigaction, sys_rt_sigaction, 174, 4)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_rt_sigprocmask
+TRACE_SYSCALL_TABLE(sys_rt_sigprocmask, sys_rt_sigprocmask, 175, 4)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_rt_sigpending
+TRACE_SYSCALL_TABLE(sys_rt_sigpending, sys_rt_sigpending, 176, 2)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_rt_sigtimedwait
+TRACE_SYSCALL_TABLE(sys_rt_sigtimedwait, sys_rt_sigtimedwait, 177, 4)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_rt_sigqueueinfo
+TRACE_SYSCALL_TABLE(sys_rt_sigqueueinfo, sys_rt_sigqueueinfo, 178, 3)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_rt_sigsuspend
+TRACE_SYSCALL_TABLE(sys_rt_sigsuspend, sys_rt_sigsuspend, 179, 2)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_chown16
+TRACE_SYSCALL_TABLE(sys_chown16, sys_chown16, 182, 3)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_getcwd
+TRACE_SYSCALL_TABLE(sys_getcwd, sys_getcwd, 183, 2)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_sendfile
+TRACE_SYSCALL_TABLE(sys_sendfile, sys_sendfile, 187, 4)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_getrlimit
+TRACE_SYSCALL_TABLE(sys_getrlimit, sys_getrlimit, 191, 2)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_stat64
+TRACE_SYSCALL_TABLE(sys_stat64, sys_stat64, 195, 2)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_lstat64
+TRACE_SYSCALL_TABLE(sys_lstat64, sys_lstat64, 196, 2)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_fstat64
+TRACE_SYSCALL_TABLE(sys_fstat64, sys_fstat64, 197, 2)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_lchown
+TRACE_SYSCALL_TABLE(sys_lchown, sys_lchown, 198, 3)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_getgroups
+TRACE_SYSCALL_TABLE(sys_getgroups, sys_getgroups, 205, 2)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_setgroups
+TRACE_SYSCALL_TABLE(sys_setgroups, sys_setgroups, 206, 2)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_getresuid
+TRACE_SYSCALL_TABLE(sys_getresuid, sys_getresuid, 209, 3)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_getresgid
+TRACE_SYSCALL_TABLE(sys_getresgid, sys_getresgid, 211, 3)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_chown
+TRACE_SYSCALL_TABLE(sys_chown, sys_chown, 212, 3)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_getdents64
+TRACE_SYSCALL_TABLE(sys_getdents64, sys_getdents64, 217, 3)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_pivot_root
+TRACE_SYSCALL_TABLE(sys_pivot_root, sys_pivot_root, 218, 2)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_mincore
+TRACE_SYSCALL_TABLE(sys_mincore, sys_mincore, 219, 3)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_setxattr
+TRACE_SYSCALL_TABLE(sys_setxattr, sys_setxattr, 226, 5)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_lsetxattr
+TRACE_SYSCALL_TABLE(sys_lsetxattr, sys_lsetxattr, 227, 5)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_fsetxattr
+TRACE_SYSCALL_TABLE(sys_fsetxattr, sys_fsetxattr, 228, 5)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_getxattr
+TRACE_SYSCALL_TABLE(sys_getxattr, sys_getxattr, 229, 4)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_lgetxattr
+TRACE_SYSCALL_TABLE(sys_lgetxattr, sys_lgetxattr, 230, 4)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_fgetxattr
+TRACE_SYSCALL_TABLE(sys_fgetxattr, sys_fgetxattr, 231, 4)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_listxattr
+TRACE_SYSCALL_TABLE(sys_listxattr, sys_listxattr, 232, 3)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_llistxattr
+TRACE_SYSCALL_TABLE(sys_llistxattr, sys_llistxattr, 233, 3)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_flistxattr
+TRACE_SYSCALL_TABLE(sys_flistxattr, sys_flistxattr, 234, 3)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_removexattr
+TRACE_SYSCALL_TABLE(sys_removexattr, sys_removexattr, 235, 2)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_lremovexattr
+TRACE_SYSCALL_TABLE(sys_lremovexattr, sys_lremovexattr, 236, 2)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_fremovexattr
+TRACE_SYSCALL_TABLE(sys_fremovexattr, sys_fremovexattr, 237, 2)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_sendfile64
+TRACE_SYSCALL_TABLE(sys_sendfile64, sys_sendfile64, 239, 4)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_futex
+TRACE_SYSCALL_TABLE(sys_futex, sys_futex, 240, 6)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_sched_setaffinity
+TRACE_SYSCALL_TABLE(sys_sched_setaffinity, sys_sched_setaffinity, 241, 3)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_sched_getaffinity
+TRACE_SYSCALL_TABLE(sys_sched_getaffinity, sys_sched_getaffinity, 242, 3)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_io_setup
+TRACE_SYSCALL_TABLE(sys_io_setup, sys_io_setup, 243, 2)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_io_getevents
+TRACE_SYSCALL_TABLE(sys_io_getevents, sys_io_getevents, 245, 5)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_io_submit
+TRACE_SYSCALL_TABLE(sys_io_submit, sys_io_submit, 246, 3)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_io_cancel
+TRACE_SYSCALL_TABLE(sys_io_cancel, sys_io_cancel, 247, 3)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_epoll_ctl
+TRACE_SYSCALL_TABLE(sys_epoll_ctl, sys_epoll_ctl, 251, 4)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_epoll_wait
+TRACE_SYSCALL_TABLE(sys_epoll_wait, sys_epoll_wait, 252, 4)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_set_tid_address
+TRACE_SYSCALL_TABLE(sys_set_tid_address, sys_set_tid_address, 256, 1)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_timer_create
+TRACE_SYSCALL_TABLE(sys_timer_create, sys_timer_create, 257, 3)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_timer_settime
+TRACE_SYSCALL_TABLE(sys_timer_settime, sys_timer_settime, 258, 4)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_timer_gettime
+TRACE_SYSCALL_TABLE(sys_timer_gettime, sys_timer_gettime, 259, 2)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_clock_settime
+TRACE_SYSCALL_TABLE(sys_clock_settime, sys_clock_settime, 262, 2)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_clock_gettime
+TRACE_SYSCALL_TABLE(sys_clock_gettime, sys_clock_gettime, 263, 2)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_clock_getres
+TRACE_SYSCALL_TABLE(sys_clock_getres, sys_clock_getres, 264, 2)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_clock_nanosleep
+TRACE_SYSCALL_TABLE(sys_clock_nanosleep, sys_clock_nanosleep, 265, 4)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_utimes
+TRACE_SYSCALL_TABLE(sys_utimes, sys_utimes, 269, 2)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_mq_open
+TRACE_SYSCALL_TABLE(sys_mq_open, sys_mq_open, 274, 4)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_mq_unlink
+TRACE_SYSCALL_TABLE(sys_mq_unlink, sys_mq_unlink, 275, 1)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_mq_timedsend
+TRACE_SYSCALL_TABLE(sys_mq_timedsend, sys_mq_timedsend, 276, 5)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_mq_timedreceive
+TRACE_SYSCALL_TABLE(sys_mq_timedreceive, sys_mq_timedreceive, 277, 5)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_mq_notify
+TRACE_SYSCALL_TABLE(sys_mq_notify, sys_mq_notify, 278, 2)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_mq_getsetattr
+TRACE_SYSCALL_TABLE(sys_mq_getsetattr, sys_mq_getsetattr, 279, 3)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_waitid
+TRACE_SYSCALL_TABLE(sys_waitid, sys_waitid, 280, 5)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_bind
+TRACE_SYSCALL_TABLE(sys_bind, sys_bind, 282, 3)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_connect
+TRACE_SYSCALL_TABLE(sys_connect, sys_connect, 283, 3)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_accept
+TRACE_SYSCALL_TABLE(sys_accept, sys_accept, 285, 3)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_getsockname
+TRACE_SYSCALL_TABLE(sys_getsockname, sys_getsockname, 286, 3)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_getpeername
+TRACE_SYSCALL_TABLE(sys_getpeername, sys_getpeername, 287, 3)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_socketpair
+TRACE_SYSCALL_TABLE(sys_socketpair, sys_socketpair, 288, 4)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_send
+TRACE_SYSCALL_TABLE(sys_send, sys_send, 289, 4)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_sendto
+TRACE_SYSCALL_TABLE(sys_sendto, sys_sendto, 290, 6)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_recvfrom
+TRACE_SYSCALL_TABLE(sys_recvfrom, sys_recvfrom, 292, 6)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_setsockopt
+TRACE_SYSCALL_TABLE(sys_setsockopt, sys_setsockopt, 294, 5)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_getsockopt
+TRACE_SYSCALL_TABLE(sys_getsockopt, sys_getsockopt, 295, 5)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_sendmsg
+TRACE_SYSCALL_TABLE(sys_sendmsg, sys_sendmsg, 296, 3)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_recvmsg
+TRACE_SYSCALL_TABLE(sys_recvmsg, sys_recvmsg, 297, 3)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_semop
+TRACE_SYSCALL_TABLE(sys_semop, sys_semop, 298, 3)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_msgsnd
+TRACE_SYSCALL_TABLE(sys_msgsnd, sys_msgsnd, 301, 4)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_msgrcv
+TRACE_SYSCALL_TABLE(sys_msgrcv, sys_msgrcv, 302, 5)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_msgctl
+TRACE_SYSCALL_TABLE(sys_msgctl, sys_msgctl, 304, 3)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_shmat
+TRACE_SYSCALL_TABLE(sys_shmat, sys_shmat, 305, 3)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_shmdt
+TRACE_SYSCALL_TABLE(sys_shmdt, sys_shmdt, 306, 1)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_shmctl
+TRACE_SYSCALL_TABLE(sys_shmctl, sys_shmctl, 308, 3)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_add_key
+TRACE_SYSCALL_TABLE(sys_add_key, sys_add_key, 309, 5)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_request_key
+TRACE_SYSCALL_TABLE(sys_request_key, sys_request_key, 310, 4)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_semtimedop
+TRACE_SYSCALL_TABLE(sys_semtimedop, sys_semtimedop, 312, 4)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_inotify_add_watch
+TRACE_SYSCALL_TABLE(sys_inotify_add_watch, sys_inotify_add_watch, 317, 3)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_openat
+TRACE_SYSCALL_TABLE(sys_openat, sys_openat, 322, 4)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_mkdirat
+TRACE_SYSCALL_TABLE(sys_mkdirat, sys_mkdirat, 323, 3)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_mknodat
+TRACE_SYSCALL_TABLE(sys_mknodat, sys_mknodat, 324, 4)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_fchownat
+TRACE_SYSCALL_TABLE(sys_fchownat, sys_fchownat, 325, 5)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_futimesat
+TRACE_SYSCALL_TABLE(sys_futimesat, sys_futimesat, 326, 3)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_fstatat64
+TRACE_SYSCALL_TABLE(sys_fstatat64, sys_fstatat64, 327, 4)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_unlinkat
+TRACE_SYSCALL_TABLE(sys_unlinkat, sys_unlinkat, 328, 3)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_renameat
+TRACE_SYSCALL_TABLE(sys_renameat, sys_renameat, 329, 4)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_linkat
+TRACE_SYSCALL_TABLE(sys_linkat, sys_linkat, 330, 5)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_symlinkat
+TRACE_SYSCALL_TABLE(sys_symlinkat, sys_symlinkat, 331, 3)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_readlinkat
+TRACE_SYSCALL_TABLE(sys_readlinkat, sys_readlinkat, 332, 4)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_fchmodat
+TRACE_SYSCALL_TABLE(sys_fchmodat, sys_fchmodat, 333, 3)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_faccessat
+TRACE_SYSCALL_TABLE(sys_faccessat, sys_faccessat, 334, 3)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_pselect6
+TRACE_SYSCALL_TABLE(sys_pselect6, sys_pselect6, 335, 6)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_ppoll
+TRACE_SYSCALL_TABLE(sys_ppoll, sys_ppoll, 336, 5)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_set_robust_list
+TRACE_SYSCALL_TABLE(sys_set_robust_list, sys_set_robust_list, 338, 2)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_get_robust_list
+TRACE_SYSCALL_TABLE(sys_get_robust_list, sys_get_robust_list, 339, 3)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_splice
+TRACE_SYSCALL_TABLE(sys_splice, sys_splice, 340, 6)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_vmsplice
+TRACE_SYSCALL_TABLE(sys_vmsplice, sys_vmsplice, 343, 4)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_getcpu
+TRACE_SYSCALL_TABLE(sys_getcpu, sys_getcpu, 345, 3)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_epoll_pwait
+TRACE_SYSCALL_TABLE(sys_epoll_pwait, sys_epoll_pwait, 346, 6)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_utimensat
+TRACE_SYSCALL_TABLE(sys_utimensat, sys_utimensat, 348, 4)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_signalfd
+TRACE_SYSCALL_TABLE(sys_signalfd, sys_signalfd, 349, 3)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_timerfd_settime
+TRACE_SYSCALL_TABLE(sys_timerfd_settime, sys_timerfd_settime, 353, 4)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_timerfd_gettime
+TRACE_SYSCALL_TABLE(sys_timerfd_gettime, sys_timerfd_gettime, 354, 2)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_signalfd4
+TRACE_SYSCALL_TABLE(sys_signalfd4, sys_signalfd4, 355, 4)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_pipe2
+TRACE_SYSCALL_TABLE(sys_pipe2, sys_pipe2, 359, 2)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_preadv
+TRACE_SYSCALL_TABLE(sys_preadv, sys_preadv, 361, 5)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_pwritev
+TRACE_SYSCALL_TABLE(sys_pwritev, sys_pwritev, 362, 5)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_rt_tgsigqueueinfo
+TRACE_SYSCALL_TABLE(sys_rt_tgsigqueueinfo, sys_rt_tgsigqueueinfo, 363, 4)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_perf_event_open
+TRACE_SYSCALL_TABLE(sys_perf_event_open, sys_perf_event_open, 364, 5)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_recvmmsg
+TRACE_SYSCALL_TABLE(sys_recvmmsg, sys_recvmmsg, 365, 5)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_accept4
+TRACE_SYSCALL_TABLE(sys_accept4, sys_accept4, 366, 4)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_prlimit64
+TRACE_SYSCALL_TABLE(sys_prlimit64, sys_prlimit64, 369, 4)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_name_to_handle_at
+TRACE_SYSCALL_TABLE(sys_name_to_handle_at, sys_name_to_handle_at, 370, 5)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_open_by_handle_at
+TRACE_SYSCALL_TABLE(sys_open_by_handle_at, sys_open_by_handle_at, 371, 3)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_clock_adjtime
+TRACE_SYSCALL_TABLE(sys_clock_adjtime, sys_clock_adjtime, 372, 2)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_sendmmsg
+TRACE_SYSCALL_TABLE(sys_sendmmsg, sys_sendmmsg, 374, 4)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_process_vm_readv
+TRACE_SYSCALL_TABLE(sys_process_vm_readv, sys_process_vm_readv, 376, 6)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_process_vm_writev
+TRACE_SYSCALL_TABLE(sys_process_vm_writev, sys_process_vm_writev, 377, 6)
+#endif
+
+#endif /* CREATE_SYSCALL_TABLE */
diff --git a/drivers/staging/lttng/instrumentation/syscalls/headers/arm-32-syscalls-3.4.25_pointers_override.h b/drivers/staging/lttng/instrumentation/syscalls/headers/arm-32-syscalls-3.4.25_pointers_override.h
new file mode 100644 (file)
index 0000000..65131bb
--- /dev/null
@@ -0,0 +1,39 @@
+
+#define OVERRIDE_TABLE_32_sys_mmap2
+
+
+#ifndef CREATE_SYSCALL_TABLE
+
+SC_TRACE_EVENT(sys_mmap2,
+       TP_PROTO(void *addr, size_t len, int prot,
+                 int flags, int fd, off_t pgoff),
+       TP_ARGS(addr, len, prot, flags, fd, pgoff),
+       TP_STRUCT__entry(
+               __field_hex(void *, addr)
+               __field(size_t, len)
+               __field(int, prot)
+               __field(int, flags)
+               __field(int, fd)
+               __field(off_t, pgoff)),
+       TP_fast_assign(
+               tp_assign(addr, addr)
+               tp_assign(len, len)
+               tp_assign(prot, prot)
+               tp_assign(flags, flags)
+               tp_assign(fd, fd)
+               tp_assign(pgoff, pgoff)),
+       TP_printk()
+)
+
+#else  /* CREATE_SYSCALL_TABLE */
+
+#define OVERRIDE_TABLE_32_sys_execve
+TRACE_SYSCALL_TABLE(sys_execve, sys_execve, 11, 3)
+#define OVERRIDE_TABLE_32_sys_clone
+TRACE_SYSCALL_TABLE(sys_clone, sys_clone, 120, 5)
+#define OVERRIDE_TABLE_32_sys_mmap2
+TRACE_SYSCALL_TABLE(sys_mmap2, sys_mmap2, 192, 6)
+
+#endif /* CREATE_SYSCALL_TABLE */
+
+
diff --git a/drivers/staging/lttng/instrumentation/syscalls/headers/compat_syscalls_integers.h b/drivers/staging/lttng/instrumentation/syscalls/headers/compat_syscalls_integers.h
new file mode 100644 (file)
index 0000000..dabc4bf
--- /dev/null
@@ -0,0 +1,3 @@
+#ifdef CONFIG_X86_64
+#include "x86-32-syscalls-3.1.0-rc6_integers.h"
+#endif
diff --git a/drivers/staging/lttng/instrumentation/syscalls/headers/compat_syscalls_pointers.h b/drivers/staging/lttng/instrumentation/syscalls/headers/compat_syscalls_pointers.h
new file mode 100644 (file)
index 0000000..a84423c
--- /dev/null
@@ -0,0 +1,3 @@
+#ifdef CONFIG_X86_64
+#include "x86-32-syscalls-3.1.0-rc6_pointers.h"
+#endif
diff --git a/drivers/staging/lttng/instrumentation/syscalls/headers/mips-32-syscalls-3.5.0_integers.h b/drivers/staging/lttng/instrumentation/syscalls/headers/mips-32-syscalls-3.5.0_integers.h
new file mode 100644 (file)
index 0000000..da8ed56
--- /dev/null
@@ -0,0 +1,677 @@
+/* THIS FILE IS AUTO-GENERATED. DO NOT EDIT */
+#ifndef CREATE_SYSCALL_TABLE
+
+#if !defined(_TRACE_SYSCALLS_INTEGERS_H) || defined(TRACE_HEADER_MULTI_READ)
+#define _TRACE_SYSCALLS_INTEGERS_H
+
+#include <linux/tracepoint.h>
+#include <linux/syscalls.h>
+#include "mips-32-syscalls-3.5.0_integers_override.h"
+#include "syscalls_integers_override.h"
+
+SC_DECLARE_EVENT_CLASS_NOARGS(syscalls_noargs,
+       TP_STRUCT__entry(),
+       TP_fast_assign(),
+       TP_printk()
+)
+#ifndef OVERRIDE_32_sys_getpid
+SC_DEFINE_EVENT_NOARGS(syscalls_noargs, sys_getpid)
+#endif
+#ifndef OVERRIDE_32_sys_getuid
+SC_DEFINE_EVENT_NOARGS(syscalls_noargs, sys_getuid)
+#endif
+#ifndef OVERRIDE_32_sys_pause
+SC_DEFINE_EVENT_NOARGS(syscalls_noargs, sys_pause)
+#endif
+#ifndef OVERRIDE_32_sys_sync
+SC_DEFINE_EVENT_NOARGS(syscalls_noargs, sys_sync)
+#endif
+#ifndef OVERRIDE_32_sys_getgid
+SC_DEFINE_EVENT_NOARGS(syscalls_noargs, sys_getgid)
+#endif
+#ifndef OVERRIDE_32_sys_geteuid
+SC_DEFINE_EVENT_NOARGS(syscalls_noargs, sys_geteuid)
+#endif
+#ifndef OVERRIDE_32_sys_getegid
+SC_DEFINE_EVENT_NOARGS(syscalls_noargs, sys_getegid)
+#endif
+#ifndef OVERRIDE_32_sys_getppid
+SC_DEFINE_EVENT_NOARGS(syscalls_noargs, sys_getppid)
+#endif
+#ifndef OVERRIDE_32_sys_getpgrp
+SC_DEFINE_EVENT_NOARGS(syscalls_noargs, sys_getpgrp)
+#endif
+#ifndef OVERRIDE_32_sys_setsid
+SC_DEFINE_EVENT_NOARGS(syscalls_noargs, sys_setsid)
+#endif
+#ifndef OVERRIDE_32_sys_sgetmask
+SC_DEFINE_EVENT_NOARGS(syscalls_noargs, sys_sgetmask)
+#endif
+#ifndef OVERRIDE_32_sys_vhangup
+SC_DEFINE_EVENT_NOARGS(syscalls_noargs, sys_vhangup)
+#endif
+#ifndef OVERRIDE_32_sys_munlockall
+SC_DEFINE_EVENT_NOARGS(syscalls_noargs, sys_munlockall)
+#endif
+#ifndef OVERRIDE_32_sys_sched_yield
+SC_DEFINE_EVENT_NOARGS(syscalls_noargs, sys_sched_yield)
+#endif
+#ifndef OVERRIDE_32_sys_exit
+SC_TRACE_EVENT(sys_exit,
+       TP_PROTO(int error_code),
+       TP_ARGS(error_code),
+       TP_STRUCT__entry(__field(int, error_code)),
+       TP_fast_assign(tp_assign(error_code, error_code)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_close
+SC_TRACE_EVENT(sys_close,
+       TP_PROTO(unsigned int fd),
+       TP_ARGS(fd),
+       TP_STRUCT__entry(__field(unsigned int, fd)),
+       TP_fast_assign(tp_assign(fd, fd)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_setuid
+SC_TRACE_EVENT(sys_setuid,
+       TP_PROTO(uid_t uid),
+       TP_ARGS(uid),
+       TP_STRUCT__entry(__field(uid_t, uid)),
+       TP_fast_assign(tp_assign(uid, uid)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_alarm
+SC_TRACE_EVENT(sys_alarm,
+       TP_PROTO(unsigned int seconds),
+       TP_ARGS(seconds),
+       TP_STRUCT__entry(__field(unsigned int, seconds)),
+       TP_fast_assign(tp_assign(seconds, seconds)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_nice
+SC_TRACE_EVENT(sys_nice,
+       TP_PROTO(int increment),
+       TP_ARGS(increment),
+       TP_STRUCT__entry(__field(int, increment)),
+       TP_fast_assign(tp_assign(increment, increment)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_dup
+SC_TRACE_EVENT(sys_dup,
+       TP_PROTO(unsigned int fildes),
+       TP_ARGS(fildes),
+       TP_STRUCT__entry(__field(unsigned int, fildes)),
+       TP_fast_assign(tp_assign(fildes, fildes)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_brk
+SC_TRACE_EVENT(sys_brk,
+       TP_PROTO(unsigned long brk),
+       TP_ARGS(brk),
+       TP_STRUCT__entry(__field(unsigned long, brk)),
+       TP_fast_assign(tp_assign(brk, brk)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_setgid
+SC_TRACE_EVENT(sys_setgid,
+       TP_PROTO(gid_t gid),
+       TP_ARGS(gid),
+       TP_STRUCT__entry(__field(gid_t, gid)),
+       TP_fast_assign(tp_assign(gid, gid)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_umask
+SC_TRACE_EVENT(sys_umask,
+       TP_PROTO(int mask),
+       TP_ARGS(mask),
+       TP_STRUCT__entry(__field(int, mask)),
+       TP_fast_assign(tp_assign(mask, mask)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_ssetmask
+SC_TRACE_EVENT(sys_ssetmask,
+       TP_PROTO(int newmask),
+       TP_ARGS(newmask),
+       TP_STRUCT__entry(__field(int, newmask)),
+       TP_fast_assign(tp_assign(newmask, newmask)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_fsync
+SC_TRACE_EVENT(sys_fsync,
+       TP_PROTO(unsigned int fd),
+       TP_ARGS(fd),
+       TP_STRUCT__entry(__field(unsigned int, fd)),
+       TP_fast_assign(tp_assign(fd, fd)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_getpgid
+SC_TRACE_EVENT(sys_getpgid,
+       TP_PROTO(pid_t pid),
+       TP_ARGS(pid),
+       TP_STRUCT__entry(__field(pid_t, pid)),
+       TP_fast_assign(tp_assign(pid, pid)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_fchdir
+SC_TRACE_EVENT(sys_fchdir,
+       TP_PROTO(unsigned int fd),
+       TP_ARGS(fd),
+       TP_STRUCT__entry(__field(unsigned int, fd)),
+       TP_fast_assign(tp_assign(fd, fd)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_personality
+SC_TRACE_EVENT(sys_personality,
+       TP_PROTO(unsigned int personality),
+       TP_ARGS(personality),
+       TP_STRUCT__entry(__field(unsigned int, personality)),
+       TP_fast_assign(tp_assign(personality, personality)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_setfsuid
+SC_TRACE_EVENT(sys_setfsuid,
+       TP_PROTO(uid_t uid),
+       TP_ARGS(uid),
+       TP_STRUCT__entry(__field(uid_t, uid)),
+       TP_fast_assign(tp_assign(uid, uid)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_setfsgid
+SC_TRACE_EVENT(sys_setfsgid,
+       TP_PROTO(gid_t gid),
+       TP_ARGS(gid),
+       TP_STRUCT__entry(__field(gid_t, gid)),
+       TP_fast_assign(tp_assign(gid, gid)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_getsid
+SC_TRACE_EVENT(sys_getsid,
+       TP_PROTO(pid_t pid),
+       TP_ARGS(pid),
+       TP_STRUCT__entry(__field(pid_t, pid)),
+       TP_fast_assign(tp_assign(pid, pid)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_fdatasync
+SC_TRACE_EVENT(sys_fdatasync,
+       TP_PROTO(unsigned int fd),
+       TP_ARGS(fd),
+       TP_STRUCT__entry(__field(unsigned int, fd)),
+       TP_fast_assign(tp_assign(fd, fd)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_mlockall
+SC_TRACE_EVENT(sys_mlockall,
+       TP_PROTO(int flags),
+       TP_ARGS(flags),
+       TP_STRUCT__entry(__field(int, flags)),
+       TP_fast_assign(tp_assign(flags, flags)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_sched_getscheduler
+SC_TRACE_EVENT(sys_sched_getscheduler,
+       TP_PROTO(pid_t pid),
+       TP_ARGS(pid),
+       TP_STRUCT__entry(__field(pid_t, pid)),
+       TP_fast_assign(tp_assign(pid, pid)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_sched_get_priority_max
+SC_TRACE_EVENT(sys_sched_get_priority_max,
+       TP_PROTO(int policy),
+       TP_ARGS(policy),
+       TP_STRUCT__entry(__field(int, policy)),
+       TP_fast_assign(tp_assign(policy, policy)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_sched_get_priority_min
+SC_TRACE_EVENT(sys_sched_get_priority_min,
+       TP_PROTO(int policy),
+       TP_ARGS(policy),
+       TP_STRUCT__entry(__field(int, policy)),
+       TP_fast_assign(tp_assign(policy, policy)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_kill
+SC_TRACE_EVENT(sys_kill,
+       TP_PROTO(pid_t pid, int sig),
+       TP_ARGS(pid, sig),
+       TP_STRUCT__entry(__field(pid_t, pid) __field(int, sig)),
+       TP_fast_assign(tp_assign(pid, pid) tp_assign(sig, sig)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_setpgid
+SC_TRACE_EVENT(sys_setpgid,
+       TP_PROTO(pid_t pid, pid_t pgid),
+       TP_ARGS(pid, pgid),
+       TP_STRUCT__entry(__field(pid_t, pid) __field(pid_t, pgid)),
+       TP_fast_assign(tp_assign(pid, pid) tp_assign(pgid, pgid)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_dup2
+SC_TRACE_EVENT(sys_dup2,
+       TP_PROTO(unsigned int oldfd, unsigned int newfd),
+       TP_ARGS(oldfd, newfd),
+       TP_STRUCT__entry(__field(unsigned int, oldfd) __field(unsigned int, newfd)),
+       TP_fast_assign(tp_assign(oldfd, oldfd) tp_assign(newfd, newfd)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_setreuid
+SC_TRACE_EVENT(sys_setreuid,
+       TP_PROTO(uid_t ruid, uid_t euid),
+       TP_ARGS(ruid, euid),
+       TP_STRUCT__entry(__field(uid_t, ruid) __field(uid_t, euid)),
+       TP_fast_assign(tp_assign(ruid, ruid) tp_assign(euid, euid)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_setregid
+SC_TRACE_EVENT(sys_setregid,
+       TP_PROTO(gid_t rgid, gid_t egid),
+       TP_ARGS(rgid, egid),
+       TP_STRUCT__entry(__field(gid_t, rgid) __field(gid_t, egid)),
+       TP_fast_assign(tp_assign(rgid, rgid) tp_assign(egid, egid)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_munmap
+SC_TRACE_EVENT(sys_munmap,
+       TP_PROTO(unsigned long addr, size_t len),
+       TP_ARGS(addr, len),
+       TP_STRUCT__entry(__field_hex(unsigned long, addr) __field(size_t, len)),
+       TP_fast_assign(tp_assign(addr, addr) tp_assign(len, len)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_ftruncate
+SC_TRACE_EVENT(sys_ftruncate,
+       TP_PROTO(unsigned int fd, unsigned long length),
+       TP_ARGS(fd, length),
+       TP_STRUCT__entry(__field(unsigned int, fd) __field(unsigned long, length)),
+       TP_fast_assign(tp_assign(fd, fd) tp_assign(length, length)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_fchmod
+SC_TRACE_EVENT(sys_fchmod,
+       TP_PROTO(unsigned int fd, umode_t mode),
+       TP_ARGS(fd, mode),
+       TP_STRUCT__entry(__field(unsigned int, fd) __field(umode_t, mode)),
+       TP_fast_assign(tp_assign(fd, fd) tp_assign(mode, mode)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_getpriority
+SC_TRACE_EVENT(sys_getpriority,
+       TP_PROTO(int which, int who),
+       TP_ARGS(which, who),
+       TP_STRUCT__entry(__field(int, which) __field(int, who)),
+       TP_fast_assign(tp_assign(which, which) tp_assign(who, who)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_bdflush
+SC_TRACE_EVENT(sys_bdflush,
+       TP_PROTO(int func, long data),
+       TP_ARGS(func, data),
+       TP_STRUCT__entry(__field(int, func) __field(long, data)),
+       TP_fast_assign(tp_assign(func, func) tp_assign(data, data)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_flock
+SC_TRACE_EVENT(sys_flock,
+       TP_PROTO(unsigned int fd, unsigned int cmd),
+       TP_ARGS(fd, cmd),
+       TP_STRUCT__entry(__field(unsigned int, fd) __field(unsigned int, cmd)),
+       TP_fast_assign(tp_assign(fd, fd) tp_assign(cmd, cmd)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_mlock
+SC_TRACE_EVENT(sys_mlock,
+       TP_PROTO(unsigned long start, size_t len),
+       TP_ARGS(start, len),
+       TP_STRUCT__entry(__field(unsigned long, start) __field(size_t, len)),
+       TP_fast_assign(tp_assign(start, start) tp_assign(len, len)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_munlock
+SC_TRACE_EVENT(sys_munlock,
+       TP_PROTO(unsigned long start, size_t len),
+       TP_ARGS(start, len),
+       TP_STRUCT__entry(__field(unsigned long, start) __field(size_t, len)),
+       TP_fast_assign(tp_assign(start, start) tp_assign(len, len)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_lseek
+SC_TRACE_EVENT(sys_lseek,
+       TP_PROTO(unsigned int fd, off_t offset, unsigned int origin),
+       TP_ARGS(fd, offset, origin),
+       TP_STRUCT__entry(__field(unsigned int, fd) __field(off_t, offset) __field(unsigned int, origin)),
+       TP_fast_assign(tp_assign(fd, fd) tp_assign(offset, offset) tp_assign(origin, origin)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_ioctl
+SC_TRACE_EVENT(sys_ioctl,
+       TP_PROTO(unsigned int fd, unsigned int cmd, unsigned long arg),
+       TP_ARGS(fd, cmd, arg),
+       TP_STRUCT__entry(__field(unsigned int, fd) __field(unsigned int, cmd) __field(unsigned long, arg)),
+       TP_fast_assign(tp_assign(fd, fd) tp_assign(cmd, cmd) tp_assign(arg, arg)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_fcntl
+SC_TRACE_EVENT(sys_fcntl,
+       TP_PROTO(unsigned int fd, unsigned int cmd, unsigned long arg),
+       TP_ARGS(fd, cmd, arg),
+       TP_STRUCT__entry(__field(unsigned int, fd) __field(unsigned int, cmd) __field(unsigned long, arg)),
+       TP_fast_assign(tp_assign(fd, fd) tp_assign(cmd, cmd) tp_assign(arg, arg)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_fchown
+SC_TRACE_EVENT(sys_fchown,
+       TP_PROTO(unsigned int fd, uid_t user, gid_t group),
+       TP_ARGS(fd, user, group),
+       TP_STRUCT__entry(__field(unsigned int, fd) __field(uid_t, user) __field(gid_t, group)),
+       TP_fast_assign(tp_assign(fd, fd) tp_assign(user, user) tp_assign(group, group)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_setpriority
+SC_TRACE_EVENT(sys_setpriority,
+       TP_PROTO(int which, int who, int niceval),
+       TP_ARGS(which, who, niceval),
+       TP_STRUCT__entry(__field(int, which) __field(int, who) __field(int, niceval)),
+       TP_fast_assign(tp_assign(which, which) tp_assign(who, who) tp_assign(niceval, niceval)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_mprotect
+SC_TRACE_EVENT(sys_mprotect,
+       TP_PROTO(unsigned long start, size_t len, unsigned long prot),
+       TP_ARGS(start, len, prot),
+       TP_STRUCT__entry(__field(unsigned long, start) __field(size_t, len) __field(unsigned long, prot)),
+       TP_fast_assign(tp_assign(start, start) tp_assign(len, len) tp_assign(prot, prot)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_sysfs
+SC_TRACE_EVENT(sys_sysfs,
+       TP_PROTO(int option, unsigned long arg1, unsigned long arg2),
+       TP_ARGS(option, arg1, arg2),
+       TP_STRUCT__entry(__field(int, option) __field(unsigned long, arg1) __field(unsigned long, arg2)),
+       TP_fast_assign(tp_assign(option, option) tp_assign(arg1, arg1) tp_assign(arg2, arg2)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_msync
+SC_TRACE_EVENT(sys_msync,
+       TP_PROTO(unsigned long start, size_t len, int flags),
+       TP_ARGS(start, len, flags),
+       TP_STRUCT__entry(__field(unsigned long, start) __field(size_t, len) __field(int, flags)),
+       TP_fast_assign(tp_assign(start, start) tp_assign(len, len) tp_assign(flags, flags)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_cacheflush
+SC_TRACE_EVENT(sys_cacheflush,
+       TP_PROTO(unsigned long addr, unsigned long bytes, unsigned int cache),
+       TP_ARGS(addr, bytes, cache),
+       TP_STRUCT__entry(__field_hex(unsigned long, addr) __field(unsigned long, bytes) __field(unsigned int, cache)),
+       TP_fast_assign(tp_assign(addr, addr) tp_assign(bytes, bytes) tp_assign(cache, cache)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_ptrace
+SC_TRACE_EVENT(sys_ptrace,
+       TP_PROTO(long request, long pid, unsigned long addr, unsigned long data),
+       TP_ARGS(request, pid, addr, data),
+       TP_STRUCT__entry(__field(long, request) __field(long, pid) __field_hex(unsigned long, addr) __field(unsigned long, data)),
+       TP_fast_assign(tp_assign(request, request) tp_assign(pid, pid) tp_assign(addr, addr) tp_assign(data, data)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_mremap
+SC_TRACE_EVENT(sys_mremap,
+       TP_PROTO(unsigned long addr, unsigned long old_len, unsigned long new_len, unsigned long flags, unsigned long new_addr),
+       TP_ARGS(addr, old_len, new_len, flags, new_addr),
+       TP_STRUCT__entry(__field_hex(unsigned long, addr) __field(unsigned long, old_len) __field(unsigned long, new_len) __field(unsigned long, flags) __field_hex(unsigned long, new_addr)),
+       TP_fast_assign(tp_assign(addr, addr) tp_assign(old_len, old_len) tp_assign(new_len, new_len) tp_assign(flags, flags) tp_assign(new_addr, new_addr)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_mips_mmap
+SC_TRACE_EVENT(sys_mips_mmap,
+       TP_PROTO(unsigned long addr, unsigned long len, unsigned long prot, unsigned long flags, unsigned long fd, off_t offset),
+       TP_ARGS(addr, len, prot, flags, fd, offset),
+       TP_STRUCT__entry(__field_hex(unsigned long, addr) __field(unsigned long, len) __field(unsigned long, prot) __field(unsigned long, flags) __field(unsigned long, fd) __field(off_t, offset)),
+       TP_fast_assign(tp_assign(addr, addr) tp_assign(len, len) tp_assign(prot, prot) tp_assign(flags, flags) tp_assign(fd, fd) tp_assign(offset, offset)),
+       TP_printk()
+)
+#endif
+
+#endif /*  _TRACE_SYSCALLS_INTEGERS_H */
+
+/* This part must be outside protection */
+#include "../../../probes/define_trace.h"
+
+#else /* CREATE_SYSCALL_TABLE */
+
+#include "mips-32-syscalls-3.5.0_integers_override.h"
+#include "syscalls_integers_override.h"
+
+#ifndef OVERRIDE_TABLE_32_sys_getpid
+TRACE_SYSCALL_TABLE(syscalls_noargs, sys_getpid, 4041, 0)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_getuid
+TRACE_SYSCALL_TABLE(syscalls_noargs, sys_getuid, 4049, 0)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_pause
+TRACE_SYSCALL_TABLE(syscalls_noargs, sys_pause, 4059, 0)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_sync
+TRACE_SYSCALL_TABLE(syscalls_noargs, sys_sync, 4073, 0)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_getgid
+TRACE_SYSCALL_TABLE(syscalls_noargs, sys_getgid, 4095, 0)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_geteuid
+TRACE_SYSCALL_TABLE(syscalls_noargs, sys_geteuid, 4099, 0)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_getegid
+TRACE_SYSCALL_TABLE(syscalls_noargs, sys_getegid, 4101, 0)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_getppid
+TRACE_SYSCALL_TABLE(syscalls_noargs, sys_getppid, 4129, 0)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_getpgrp
+TRACE_SYSCALL_TABLE(syscalls_noargs, sys_getpgrp, 4131, 0)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_setsid
+TRACE_SYSCALL_TABLE(syscalls_noargs, sys_setsid, 4133, 0)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_sgetmask
+TRACE_SYSCALL_TABLE(syscalls_noargs, sys_sgetmask, 4137, 0)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_vhangup
+TRACE_SYSCALL_TABLE(syscalls_noargs, sys_vhangup, 4223, 0)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_munlockall
+TRACE_SYSCALL_TABLE(syscalls_noargs, sys_munlockall, 4315, 0)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_sched_yield
+TRACE_SYSCALL_TABLE(syscalls_noargs, sys_sched_yield, 4325, 0)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_exit
+TRACE_SYSCALL_TABLE(sys_exit, sys_exit, 4003, 1)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_close
+TRACE_SYSCALL_TABLE(sys_close, sys_close, 4013, 1)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_lseek
+TRACE_SYSCALL_TABLE(sys_lseek, sys_lseek, 4039, 3)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_setuid
+TRACE_SYSCALL_TABLE(sys_setuid, sys_setuid, 4047, 1)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_ptrace
+TRACE_SYSCALL_TABLE(sys_ptrace, sys_ptrace, 4053, 4)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_alarm
+TRACE_SYSCALL_TABLE(sys_alarm, sys_alarm, 4055, 1)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_nice
+TRACE_SYSCALL_TABLE(sys_nice, sys_nice, 4069, 1)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_kill
+TRACE_SYSCALL_TABLE(sys_kill, sys_kill, 4075, 2)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_dup
+TRACE_SYSCALL_TABLE(sys_dup, sys_dup, 4083, 1)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_brk
+TRACE_SYSCALL_TABLE(sys_brk, sys_brk, 4091, 1)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_setgid
+TRACE_SYSCALL_TABLE(sys_setgid, sys_setgid, 4093, 1)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_ioctl
+TRACE_SYSCALL_TABLE(sys_ioctl, sys_ioctl, 4109, 3)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_fcntl
+TRACE_SYSCALL_TABLE(sys_fcntl, sys_fcntl, 4111, 3)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_setpgid
+TRACE_SYSCALL_TABLE(sys_setpgid, sys_setpgid, 4115, 2)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_umask
+TRACE_SYSCALL_TABLE(sys_umask, sys_umask, 4121, 1)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_dup2
+TRACE_SYSCALL_TABLE(sys_dup2, sys_dup2, 4127, 2)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_ssetmask
+TRACE_SYSCALL_TABLE(sys_ssetmask, sys_ssetmask, 4139, 1)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_setreuid
+TRACE_SYSCALL_TABLE(sys_setreuid, sys_setreuid, 4141, 2)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_setregid
+TRACE_SYSCALL_TABLE(sys_setregid, sys_setregid, 4143, 2)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_mips_mmap
+TRACE_SYSCALL_TABLE(sys_mips_mmap, sys_mips_mmap, 4181, 6)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_munmap
+TRACE_SYSCALL_TABLE(sys_munmap, sys_munmap, 4183, 2)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_ftruncate
+TRACE_SYSCALL_TABLE(sys_ftruncate, sys_ftruncate, 4187, 2)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_fchmod
+TRACE_SYSCALL_TABLE(sys_fchmod, sys_fchmod, 4189, 2)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_fchown
+TRACE_SYSCALL_TABLE(sys_fchown, sys_fchown, 4191, 3)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_getpriority
+TRACE_SYSCALL_TABLE(sys_getpriority, sys_getpriority, 4193, 2)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_setpriority
+TRACE_SYSCALL_TABLE(sys_setpriority, sys_setpriority, 4195, 3)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_fsync
+TRACE_SYSCALL_TABLE(sys_fsync, sys_fsync, 4237, 1)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_mprotect
+TRACE_SYSCALL_TABLE(sys_mprotect, sys_mprotect, 4251, 3)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_getpgid
+TRACE_SYSCALL_TABLE(sys_getpgid, sys_getpgid, 4265, 1)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_fchdir
+TRACE_SYSCALL_TABLE(sys_fchdir, sys_fchdir, 4267, 1)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_bdflush
+TRACE_SYSCALL_TABLE(sys_bdflush, sys_bdflush, 4269, 2)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_sysfs
+TRACE_SYSCALL_TABLE(sys_sysfs, sys_sysfs, 4271, 3)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_personality
+TRACE_SYSCALL_TABLE(sys_personality, sys_personality, 4273, 1)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_setfsuid
+TRACE_SYSCALL_TABLE(sys_setfsuid, sys_setfsuid, 4277, 1)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_setfsgid
+TRACE_SYSCALL_TABLE(sys_setfsgid, sys_setfsgid, 4279, 1)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_flock
+TRACE_SYSCALL_TABLE(sys_flock, sys_flock, 4287, 2)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_msync
+TRACE_SYSCALL_TABLE(sys_msync, sys_msync, 4289, 3)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_cacheflush
+TRACE_SYSCALL_TABLE(sys_cacheflush, sys_cacheflush, 4295, 3)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_getsid
+TRACE_SYSCALL_TABLE(sys_getsid, sys_getsid, 4303, 1)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_fdatasync
+TRACE_SYSCALL_TABLE(sys_fdatasync, sys_fdatasync, 4305, 1)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_mlock
+TRACE_SYSCALL_TABLE(sys_mlock, sys_mlock, 4309, 2)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_munlock
+TRACE_SYSCALL_TABLE(sys_munlock, sys_munlock, 4311, 2)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_mlockall
+TRACE_SYSCALL_TABLE(sys_mlockall, sys_mlockall, 4313, 1)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_sched_getscheduler
+TRACE_SYSCALL_TABLE(sys_sched_getscheduler, sys_sched_getscheduler, 4323, 1)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_sched_get_priority_max
+TRACE_SYSCALL_TABLE(sys_sched_get_priority_max, sys_sched_get_priority_max, 4327, 1)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_sched_get_priority_min
+TRACE_SYSCALL_TABLE(sys_sched_get_priority_min, sys_sched_get_priority_min, 4329, 1)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_mremap
+TRACE_SYSCALL_TABLE(sys_mremap, sys_mremap, 4335, 5)
+#endif
+
+#endif /* CREATE_SYSCALL_TABLE */
diff --git a/drivers/staging/lttng/instrumentation/syscalls/headers/mips-32-syscalls-3.5.0_integers_override.h b/drivers/staging/lttng/instrumentation/syscalls/headers/mips-32-syscalls-3.5.0_integers_override.h
new file mode 100644 (file)
index 0000000..49b485b
--- /dev/null
@@ -0,0 +1,3 @@
+/*
+ * this is a place-holder for MIPS integer syscall definition override.
+ */
diff --git a/drivers/staging/lttng/instrumentation/syscalls/headers/mips-32-syscalls-3.5.0_pointers.h b/drivers/staging/lttng/instrumentation/syscalls/headers/mips-32-syscalls-3.5.0_pointers.h
new file mode 100644 (file)
index 0000000..db57eb6
--- /dev/null
@@ -0,0 +1,984 @@
+/* THIS FILE IS AUTO-GENERATED. DO NOT EDIT */
+#ifndef CREATE_SYSCALL_TABLE
+
+#if !defined(_TRACE_SYSCALLS_POINTERS_H) || defined(TRACE_HEADER_MULTI_READ)
+#define _TRACE_SYSCALLS_POINTERS_H
+
+#include <linux/tracepoint.h>
+#include <linux/syscalls.h>
+#include "mips-32-syscalls-3.5.0_pointers_override.h"
+#include "syscalls_pointers_override.h"
+
+#ifndef OVERRIDE_32_sys_unlink
+SC_TRACE_EVENT(sys_unlink,
+       TP_PROTO(const char * pathname),
+       TP_ARGS(pathname),
+       TP_STRUCT__entry(__string_from_user(pathname, pathname)),
+       TP_fast_assign(tp_copy_string_from_user(pathname, pathname)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_chdir
+SC_TRACE_EVENT(sys_chdir,
+       TP_PROTO(const char * filename),
+       TP_ARGS(filename),
+       TP_STRUCT__entry(__string_from_user(filename, filename)),
+       TP_fast_assign(tp_copy_string_from_user(filename, filename)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_time
+SC_TRACE_EVENT(sys_time,
+       TP_PROTO(time_t * tloc),
+       TP_ARGS(tloc),
+       TP_STRUCT__entry(__field_hex(time_t *, tloc)),
+       TP_fast_assign(tp_assign(tloc, tloc)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_oldumount
+SC_TRACE_EVENT(sys_oldumount,
+       TP_PROTO(char * name),
+       TP_ARGS(name),
+       TP_STRUCT__entry(__string_from_user(name, name)),
+       TP_fast_assign(tp_copy_string_from_user(name, name)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_stime
+SC_TRACE_EVENT(sys_stime,
+       TP_PROTO(time_t * tptr),
+       TP_ARGS(tptr),
+       TP_STRUCT__entry(__field_hex(time_t *, tptr)),
+       TP_fast_assign(tp_assign(tptr, tptr)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_rmdir
+SC_TRACE_EVENT(sys_rmdir,
+       TP_PROTO(const char * pathname),
+       TP_ARGS(pathname),
+       TP_STRUCT__entry(__string_from_user(pathname, pathname)),
+       TP_fast_assign(tp_copy_string_from_user(pathname, pathname)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_times
+SC_TRACE_EVENT(sys_times,
+       TP_PROTO(struct tms * tbuf),
+       TP_ARGS(tbuf),
+       TP_STRUCT__entry(__field_hex(struct tms *, tbuf)),
+       TP_fast_assign(tp_assign(tbuf, tbuf)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_olduname
+SC_TRACE_EVENT(sys_olduname,
+       TP_PROTO(struct oldold_utsname * name),
+       TP_ARGS(name),
+       TP_STRUCT__entry(__field_hex(struct oldold_utsname *, name)),
+       TP_fast_assign(tp_assign(name, name)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_chroot
+SC_TRACE_EVENT(sys_chroot,
+       TP_PROTO(const char * filename),
+       TP_ARGS(filename),
+       TP_STRUCT__entry(__string_from_user(filename, filename)),
+       TP_fast_assign(tp_copy_string_from_user(filename, filename)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_sigpending
+SC_TRACE_EVENT(sys_sigpending,
+       TP_PROTO(old_sigset_t * set),
+       TP_ARGS(set),
+       TP_STRUCT__entry(__field_hex(old_sigset_t *, set)),
+       TP_fast_assign(tp_assign(set, set)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_uselib
+SC_TRACE_EVENT(sys_uselib,
+       TP_PROTO(const char * library),
+       TP_ARGS(library),
+       TP_STRUCT__entry(__field_hex(const char *, library)),
+       TP_fast_assign(tp_assign(library, library)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_uname
+SC_TRACE_EVENT(sys_uname,
+       TP_PROTO(struct old_utsname * name),
+       TP_ARGS(name),
+       TP_STRUCT__entry(__field_hex(struct old_utsname *, name)),
+       TP_fast_assign(tp_assign(name, name)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_swapoff
+SC_TRACE_EVENT(sys_swapoff,
+       TP_PROTO(const char * specialfile),
+       TP_ARGS(specialfile),
+       TP_STRUCT__entry(__string_from_user(specialfile, specialfile)),
+       TP_fast_assign(tp_copy_string_from_user(specialfile, specialfile)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_sysinfo
+SC_TRACE_EVENT(sys_sysinfo,
+       TP_PROTO(struct sysinfo * info),
+       TP_ARGS(info),
+       TP_STRUCT__entry(__field_hex(struct sysinfo *, info)),
+       TP_fast_assign(tp_assign(info, info)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_newuname
+SC_TRACE_EVENT(sys_newuname,
+       TP_PROTO(struct new_utsname * name),
+       TP_ARGS(name),
+       TP_STRUCT__entry(__field_hex(struct new_utsname *, name)),
+       TP_fast_assign(tp_assign(name, name)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_adjtimex
+SC_TRACE_EVENT(sys_adjtimex,
+       TP_PROTO(struct timex * txc_p),
+       TP_ARGS(txc_p),
+       TP_STRUCT__entry(__field_hex(struct timex *, txc_p)),
+       TP_fast_assign(tp_assign(txc_p, txc_p)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_sysctl
+SC_TRACE_EVENT(sys_sysctl,
+       TP_PROTO(struct __sysctl_args * args),
+       TP_ARGS(args),
+       TP_STRUCT__entry(__field_hex(struct __sysctl_args *, args)),
+       TP_fast_assign(tp_assign(args, args)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_creat
+SC_TRACE_EVENT(sys_creat,
+       TP_PROTO(const char * pathname, umode_t mode),
+       TP_ARGS(pathname, mode),
+       TP_STRUCT__entry(__string_from_user(pathname, pathname) __field(umode_t, mode)),
+       TP_fast_assign(tp_copy_string_from_user(pathname, pathname) tp_assign(mode, mode)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_link
+SC_TRACE_EVENT(sys_link,
+       TP_PROTO(const char * oldname, const char * newname),
+       TP_ARGS(oldname, newname),
+       TP_STRUCT__entry(__string_from_user(oldname, oldname) __string_from_user(newname, newname)),
+       TP_fast_assign(tp_copy_string_from_user(oldname, oldname) tp_copy_string_from_user(newname, newname)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_chmod
+SC_TRACE_EVENT(sys_chmod,
+       TP_PROTO(const char * filename, umode_t mode),
+       TP_ARGS(filename, mode),
+       TP_STRUCT__entry(__string_from_user(filename, filename) __field(umode_t, mode)),
+       TP_fast_assign(tp_copy_string_from_user(filename, filename) tp_assign(mode, mode)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_utime
+SC_TRACE_EVENT(sys_utime,
+       TP_PROTO(char * filename, struct utimbuf * times),
+       TP_ARGS(filename, times),
+       TP_STRUCT__entry(__string_from_user(filename, filename) __field_hex(struct utimbuf *, times)),
+       TP_fast_assign(tp_copy_string_from_user(filename, filename) tp_assign(times, times)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_access
+SC_TRACE_EVENT(sys_access,
+       TP_PROTO(const char * filename, int mode),
+       TP_ARGS(filename, mode),
+       TP_STRUCT__entry(__string_from_user(filename, filename) __field(int, mode)),
+       TP_fast_assign(tp_copy_string_from_user(filename, filename) tp_assign(mode, mode)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_rename
+SC_TRACE_EVENT(sys_rename,
+       TP_PROTO(const char * oldname, const char * newname),
+       TP_ARGS(oldname, newname),
+       TP_STRUCT__entry(__string_from_user(oldname, oldname) __string_from_user(newname, newname)),
+       TP_fast_assign(tp_copy_string_from_user(oldname, oldname) tp_copy_string_from_user(newname, newname)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_mkdir
+SC_TRACE_EVENT(sys_mkdir,
+       TP_PROTO(const char * pathname, umode_t mode),
+       TP_ARGS(pathname, mode),
+       TP_STRUCT__entry(__string_from_user(pathname, pathname) __field(umode_t, mode)),
+       TP_fast_assign(tp_copy_string_from_user(pathname, pathname) tp_assign(mode, mode)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_umount
+SC_TRACE_EVENT(sys_umount,
+       TP_PROTO(char * name, int flags),
+       TP_ARGS(name, flags),
+       TP_STRUCT__entry(__string_from_user(name, name) __field(int, flags)),
+       TP_fast_assign(tp_copy_string_from_user(name, name) tp_assign(flags, flags)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_ustat
+SC_TRACE_EVENT(sys_ustat,
+       TP_PROTO(unsigned dev, struct ustat * ubuf),
+       TP_ARGS(dev, ubuf),
+       TP_STRUCT__entry(__field(unsigned, dev) __field_hex(struct ustat *, ubuf)),
+       TP_fast_assign(tp_assign(dev, dev) tp_assign(ubuf, ubuf)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_sethostname
+SC_TRACE_EVENT(sys_sethostname,
+       TP_PROTO(char * name, int len),
+       TP_ARGS(name, len),
+       TP_STRUCT__entry(__string_from_user(name, name) __field(int, len)),
+       TP_fast_assign(tp_copy_string_from_user(name, name) tp_assign(len, len)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_setrlimit
+SC_TRACE_EVENT(sys_setrlimit,
+       TP_PROTO(unsigned int resource, struct rlimit * rlim),
+       TP_ARGS(resource, rlim),
+       TP_STRUCT__entry(__field(unsigned int, resource) __field_hex(struct rlimit *, rlim)),
+       TP_fast_assign(tp_assign(resource, resource) tp_assign(rlim, rlim)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_getrlimit
+SC_TRACE_EVENT(sys_getrlimit,
+       TP_PROTO(unsigned int resource, struct rlimit * rlim),
+       TP_ARGS(resource, rlim),
+       TP_STRUCT__entry(__field(unsigned int, resource) __field_hex(struct rlimit *, rlim)),
+       TP_fast_assign(tp_assign(resource, resource) tp_assign(rlim, rlim)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_getrusage
+SC_TRACE_EVENT(sys_getrusage,
+       TP_PROTO(int who, struct rusage * ru),
+       TP_ARGS(who, ru),
+       TP_STRUCT__entry(__field(int, who) __field_hex(struct rusage *, ru)),
+       TP_fast_assign(tp_assign(who, who) tp_assign(ru, ru)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_gettimeofday
+SC_TRACE_EVENT(sys_gettimeofday,
+       TP_PROTO(struct timeval * tv, struct timezone * tz),
+       TP_ARGS(tv, tz),
+       TP_STRUCT__entry(__field_hex(struct timeval *, tv) __field_hex(struct timezone *, tz)),
+       TP_fast_assign(tp_assign(tv, tv) tp_assign(tz, tz)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_settimeofday
+SC_TRACE_EVENT(sys_settimeofday,
+       TP_PROTO(struct timeval * tv, struct timezone * tz),
+       TP_ARGS(tv, tz),
+       TP_STRUCT__entry(__field_hex(struct timeval *, tv) __field_hex(struct timezone *, tz)),
+       TP_fast_assign(tp_assign(tv, tv) tp_assign(tz, tz)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_getgroups
+SC_TRACE_EVENT(sys_getgroups,
+       TP_PROTO(int gidsetsize, gid_t * grouplist),
+       TP_ARGS(gidsetsize, grouplist),
+       TP_STRUCT__entry(__field(int, gidsetsize) __field_hex(gid_t *, grouplist)),
+       TP_fast_assign(tp_assign(gidsetsize, gidsetsize) tp_assign(grouplist, grouplist)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_setgroups
+SC_TRACE_EVENT(sys_setgroups,
+       TP_PROTO(int gidsetsize, gid_t * grouplist),
+       TP_ARGS(gidsetsize, grouplist),
+       TP_STRUCT__entry(__field(int, gidsetsize) __field_hex(gid_t *, grouplist)),
+       TP_fast_assign(tp_assign(gidsetsize, gidsetsize) tp_assign(grouplist, grouplist)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_symlink
+SC_TRACE_EVENT(sys_symlink,
+       TP_PROTO(const char * oldname, const char * newname),
+       TP_ARGS(oldname, newname),
+       TP_STRUCT__entry(__string_from_user(oldname, oldname) __string_from_user(newname, newname)),
+       TP_fast_assign(tp_copy_string_from_user(oldname, oldname) tp_copy_string_from_user(newname, newname)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_swapon
+SC_TRACE_EVENT(sys_swapon,
+       TP_PROTO(const char * specialfile, int swap_flags),
+       TP_ARGS(specialfile, swap_flags),
+       TP_STRUCT__entry(__string_from_user(specialfile, specialfile) __field(int, swap_flags)),
+       TP_fast_assign(tp_copy_string_from_user(specialfile, specialfile) tp_assign(swap_flags, swap_flags)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_truncate
+SC_TRACE_EVENT(sys_truncate,
+       TP_PROTO(const char * path, long length),
+       TP_ARGS(path, length),
+       TP_STRUCT__entry(__string_from_user(path, path) __field(long, length)),
+       TP_fast_assign(tp_copy_string_from_user(path, path) tp_assign(length, length)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_statfs
+SC_TRACE_EVENT(sys_statfs,
+       TP_PROTO(const char * pathname, struct statfs * buf),
+       TP_ARGS(pathname, buf),
+       TP_STRUCT__entry(__string_from_user(pathname, pathname) __field_hex(struct statfs *, buf)),
+       TP_fast_assign(tp_copy_string_from_user(pathname, pathname) tp_assign(buf, buf)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_fstatfs
+SC_TRACE_EVENT(sys_fstatfs,
+       TP_PROTO(unsigned int fd, struct statfs * buf),
+       TP_ARGS(fd, buf),
+       TP_STRUCT__entry(__field(unsigned int, fd) __field_hex(struct statfs *, buf)),
+       TP_fast_assign(tp_assign(fd, fd) tp_assign(buf, buf)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_socketcall
+SC_TRACE_EVENT(sys_socketcall,
+       TP_PROTO(int call, unsigned long * args),
+       TP_ARGS(call, args),
+       TP_STRUCT__entry(__field(int, call) __field_hex(unsigned long *, args)),
+       TP_fast_assign(tp_assign(call, call) tp_assign(args, args)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_getitimer
+SC_TRACE_EVENT(sys_getitimer,
+       TP_PROTO(int which, struct itimerval * value),
+       TP_ARGS(which, value),
+       TP_STRUCT__entry(__field(int, which) __field_hex(struct itimerval *, value)),
+       TP_fast_assign(tp_assign(which, which) tp_assign(value, value)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_newstat
+SC_TRACE_EVENT(sys_newstat,
+       TP_PROTO(const char * filename, struct stat * statbuf),
+       TP_ARGS(filename, statbuf),
+       TP_STRUCT__entry(__string_from_user(filename, filename) __field_hex(struct stat *, statbuf)),
+       TP_fast_assign(tp_copy_string_from_user(filename, filename) tp_assign(statbuf, statbuf)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_newlstat
+SC_TRACE_EVENT(sys_newlstat,
+       TP_PROTO(const char * filename, struct stat * statbuf),
+       TP_ARGS(filename, statbuf),
+       TP_STRUCT__entry(__string_from_user(filename, filename) __field_hex(struct stat *, statbuf)),
+       TP_fast_assign(tp_copy_string_from_user(filename, filename) tp_assign(statbuf, statbuf)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_newfstat
+SC_TRACE_EVENT(sys_newfstat,
+       TP_PROTO(unsigned int fd, struct stat * statbuf),
+       TP_ARGS(fd, statbuf),
+       TP_STRUCT__entry(__field(unsigned int, fd) __field_hex(struct stat *, statbuf)),
+       TP_fast_assign(tp_assign(fd, fd) tp_assign(statbuf, statbuf)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_setdomainname
+SC_TRACE_EVENT(sys_setdomainname,
+       TP_PROTO(char * name, int len),
+       TP_ARGS(name, len),
+       TP_STRUCT__entry(__string_from_user(name, name) __field(int, len)),
+       TP_fast_assign(tp_copy_string_from_user(name, name) tp_assign(len, len)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_delete_module
+SC_TRACE_EVENT(sys_delete_module,
+       TP_PROTO(const char * name_user, unsigned int flags),
+       TP_ARGS(name_user, flags),
+       TP_STRUCT__entry(__string_from_user(name_user, name_user) __field(unsigned int, flags)),
+       TP_fast_assign(tp_copy_string_from_user(name_user, name_user) tp_assign(flags, flags)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_sched_setparam
+SC_TRACE_EVENT(sys_sched_setparam,
+       TP_PROTO(pid_t pid, struct sched_param * param),
+       TP_ARGS(pid, param),
+       TP_STRUCT__entry(__field(pid_t, pid) __field_hex(struct sched_param *, param)),
+       TP_fast_assign(tp_assign(pid, pid) tp_assign(param, param)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_sched_getparam
+SC_TRACE_EVENT(sys_sched_getparam,
+       TP_PROTO(pid_t pid, struct sched_param * param),
+       TP_ARGS(pid, param),
+       TP_STRUCT__entry(__field(pid_t, pid) __field_hex(struct sched_param *, param)),
+       TP_fast_assign(tp_assign(pid, pid) tp_assign(param, param)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_sched_rr_get_interval
+SC_TRACE_EVENT(sys_sched_rr_get_interval,
+       TP_PROTO(pid_t pid, struct timespec * interval),
+       TP_ARGS(pid, interval),
+       TP_STRUCT__entry(__field(pid_t, pid) __field_hex(struct timespec *, interval)),
+       TP_fast_assign(tp_assign(pid, pid) tp_assign(interval, interval)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_nanosleep
+SC_TRACE_EVENT(sys_nanosleep,
+       TP_PROTO(struct timespec * rqtp, struct timespec * rmtp),
+       TP_ARGS(rqtp, rmtp),
+       TP_STRUCT__entry(__field_hex(struct timespec *, rqtp) __field_hex(struct timespec *, rmtp)),
+       TP_fast_assign(tp_assign(rqtp, rqtp) tp_assign(rmtp, rmtp)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_read
+SC_TRACE_EVENT(sys_read,
+       TP_PROTO(unsigned int fd, char * buf, size_t count),
+       TP_ARGS(fd, buf, count),
+       TP_STRUCT__entry(__field(unsigned int, fd) __field_hex(char *, buf) __field(size_t, count)),
+       TP_fast_assign(tp_assign(fd, fd) tp_assign(buf, buf) tp_assign(count, count)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_write
+SC_TRACE_EVENT(sys_write,
+       TP_PROTO(unsigned int fd, const char * buf, size_t count),
+       TP_ARGS(fd, buf, count),
+       TP_STRUCT__entry(__field(unsigned int, fd) __field_hex(const char *, buf) __field(size_t, count)),
+       TP_fast_assign(tp_assign(fd, fd) tp_assign(buf, buf) tp_assign(count, count)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_open
+SC_TRACE_EVENT(sys_open,
+       TP_PROTO(const char * filename, int flags, umode_t mode),
+       TP_ARGS(filename, flags, mode),
+       TP_STRUCT__entry(__string_from_user(filename, filename) __field(int, flags) __field(umode_t, mode)),
+       TP_fast_assign(tp_copy_string_from_user(filename, filename) tp_assign(flags, flags) tp_assign(mode, mode)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_waitpid
+SC_TRACE_EVENT(sys_waitpid,
+       TP_PROTO(pid_t pid, int * stat_addr, int options),
+       TP_ARGS(pid, stat_addr, options),
+       TP_STRUCT__entry(__field(pid_t, pid) __field_hex(int *, stat_addr) __field(int, options)),
+       TP_fast_assign(tp_assign(pid, pid) tp_assign(stat_addr, stat_addr) tp_assign(options, options)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_mknod
+SC_TRACE_EVENT(sys_mknod,
+       TP_PROTO(const char * filename, umode_t mode, unsigned dev),
+       TP_ARGS(filename, mode, dev),
+       TP_STRUCT__entry(__string_from_user(filename, filename) __field(umode_t, mode) __field(unsigned, dev)),
+       TP_fast_assign(tp_copy_string_from_user(filename, filename) tp_assign(mode, mode) tp_assign(dev, dev)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_lchown
+SC_TRACE_EVENT(sys_lchown,
+       TP_PROTO(const char * filename, uid_t user, gid_t group),
+       TP_ARGS(filename, user, group),
+       TP_STRUCT__entry(__string_from_user(filename, filename) __field(uid_t, user) __field(gid_t, group)),
+       TP_fast_assign(tp_copy_string_from_user(filename, filename) tp_assign(user, user) tp_assign(group, group)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_sigaction
+SC_TRACE_EVENT(sys_sigaction,
+       TP_PROTO(int sig, const struct sigaction * act, struct sigaction * oact),
+       TP_ARGS(sig, act, oact),
+       TP_STRUCT__entry(__field(int, sig) __field_hex(const struct sigaction *, act) __field_hex(struct sigaction *, oact)),
+       TP_fast_assign(tp_assign(sig, sig) tp_assign(act, act) tp_assign(oact, oact)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_readlink
+SC_TRACE_EVENT(sys_readlink,
+       TP_PROTO(const char * path, char * buf, int bufsiz),
+       TP_ARGS(path, buf, bufsiz),
+       TP_STRUCT__entry(__string_from_user(path, path) __field_hex(char *, buf) __field(int, bufsiz)),
+       TP_fast_assign(tp_copy_string_from_user(path, path) tp_assign(buf, buf) tp_assign(bufsiz, bufsiz)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_old_readdir
+SC_TRACE_EVENT(sys_old_readdir,
+       TP_PROTO(unsigned int fd, struct old_linux_dirent * dirent, unsigned int count),
+       TP_ARGS(fd, dirent, count),
+       TP_STRUCT__entry(__field(unsigned int, fd) __field_hex(struct old_linux_dirent *, dirent) __field(unsigned int, count)),
+       TP_fast_assign(tp_assign(fd, fd) tp_assign(dirent, dirent) tp_assign(count, count)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_syslog
+SC_TRACE_EVENT(sys_syslog,
+       TP_PROTO(int type, char * buf, int len),
+       TP_ARGS(type, buf, len),
+       TP_STRUCT__entry(__field(int, type) __field_hex(char *, buf) __field(int, len)),
+       TP_fast_assign(tp_assign(type, type) tp_assign(buf, buf) tp_assign(len, len)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_setitimer
+SC_TRACE_EVENT(sys_setitimer,
+       TP_PROTO(int which, struct itimerval * value, struct itimerval * ovalue),
+       TP_ARGS(which, value, ovalue),
+       TP_STRUCT__entry(__field(int, which) __field_hex(struct itimerval *, value) __field_hex(struct itimerval *, ovalue)),
+       TP_fast_assign(tp_assign(which, which) tp_assign(value, value) tp_assign(ovalue, ovalue)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_sigprocmask
+SC_TRACE_EVENT(sys_sigprocmask,
+       TP_PROTO(int how, old_sigset_t * nset, old_sigset_t * oset),
+       TP_ARGS(how, nset, oset),
+       TP_STRUCT__entry(__field(int, how) __field_hex(old_sigset_t *, nset) __field_hex(old_sigset_t *, oset)),
+       TP_fast_assign(tp_assign(how, how) tp_assign(nset, nset) tp_assign(oset, oset)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_init_module
+SC_TRACE_EVENT(sys_init_module,
+       TP_PROTO(void * umod, unsigned long len, const char * uargs),
+       TP_ARGS(umod, len, uargs),
+       TP_STRUCT__entry(__field_hex(void *, umod) __field(unsigned long, len) __field_hex(const char *, uargs)),
+       TP_fast_assign(tp_assign(umod, umod) tp_assign(len, len) tp_assign(uargs, uargs)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_getdents
+SC_TRACE_EVENT(sys_getdents,
+       TP_PROTO(unsigned int fd, struct linux_dirent * dirent, unsigned int count),
+       TP_ARGS(fd, dirent, count),
+       TP_STRUCT__entry(__field(unsigned int, fd) __field_hex(struct linux_dirent *, dirent) __field(unsigned int, count)),
+       TP_fast_assign(tp_assign(fd, fd) tp_assign(dirent, dirent) tp_assign(count, count)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_readv
+SC_TRACE_EVENT(sys_readv,
+       TP_PROTO(unsigned long fd, const struct iovec * vec, unsigned long vlen),
+       TP_ARGS(fd, vec, vlen),
+       TP_STRUCT__entry(__field(unsigned long, fd) __field_hex(const struct iovec *, vec) __field(unsigned long, vlen)),
+       TP_fast_assign(tp_assign(fd, fd) tp_assign(vec, vec) tp_assign(vlen, vlen)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_writev
+SC_TRACE_EVENT(sys_writev,
+       TP_PROTO(unsigned long fd, const struct iovec * vec, unsigned long vlen),
+       TP_ARGS(fd, vec, vlen),
+       TP_STRUCT__entry(__field(unsigned long, fd) __field_hex(const struct iovec *, vec) __field(unsigned long, vlen)),
+       TP_fast_assign(tp_assign(fd, fd) tp_assign(vec, vec) tp_assign(vlen, vlen)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_cachectl
+SC_TRACE_EVENT(sys_cachectl,
+       TP_PROTO(char * addr, int nbytes, int op),
+       TP_ARGS(addr, nbytes, op),
+       TP_STRUCT__entry(__field_hex(char *, addr) __field(int, nbytes) __field(int, op)),
+       TP_fast_assign(tp_assign(addr, addr) tp_assign(nbytes, nbytes) tp_assign(op, op)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_sched_setscheduler
+SC_TRACE_EVENT(sys_sched_setscheduler,
+       TP_PROTO(pid_t pid, int policy, struct sched_param * param),
+       TP_ARGS(pid, policy, param),
+       TP_STRUCT__entry(__field(pid_t, pid) __field(int, policy) __field_hex(struct sched_param *, param)),
+       TP_fast_assign(tp_assign(pid, pid) tp_assign(policy, policy) tp_assign(param, param)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_accept
+SC_TRACE_EVENT(sys_accept,
+       TP_PROTO(int fd, struct sockaddr * upeer_sockaddr, int * upeer_addrlen),
+       TP_ARGS(fd, upeer_sockaddr, upeer_addrlen),
+       TP_STRUCT__entry(__field(int, fd) __field_hex(struct sockaddr *, upeer_sockaddr) __field_hex(int *, upeer_addrlen)),
+       TP_fast_assign(tp_assign(fd, fd) tp_assign(upeer_sockaddr, upeer_sockaddr) tp_assign(upeer_addrlen, upeer_addrlen)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_bind
+SC_TRACE_EVENT(sys_bind,
+       TP_PROTO(int fd, struct sockaddr * umyaddr, int addrlen),
+       TP_ARGS(fd, umyaddr, addrlen),
+       TP_STRUCT__entry(__field(int, fd) __field_hex(struct sockaddr *, umyaddr) __field_hex(int, addrlen)),
+       TP_fast_assign(tp_assign(fd, fd) tp_assign(umyaddr, umyaddr) tp_assign(addrlen, addrlen)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_connect
+SC_TRACE_EVENT(sys_connect,
+       TP_PROTO(int fd, struct sockaddr * uservaddr, int addrlen),
+       TP_ARGS(fd, uservaddr, addrlen),
+       TP_STRUCT__entry(__field(int, fd) __field_hex(struct sockaddr *, uservaddr) __field_hex(int, addrlen)),
+       TP_fast_assign(tp_assign(fd, fd) tp_assign(uservaddr, uservaddr) tp_assign(addrlen, addrlen)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_getpeername
+SC_TRACE_EVENT(sys_getpeername,
+       TP_PROTO(int fd, struct sockaddr * usockaddr, int * usockaddr_len),
+       TP_ARGS(fd, usockaddr, usockaddr_len),
+       TP_STRUCT__entry(__field(int, fd) __field_hex(struct sockaddr *, usockaddr) __field_hex(int *, usockaddr_len)),
+       TP_fast_assign(tp_assign(fd, fd) tp_assign(usockaddr, usockaddr) tp_assign(usockaddr_len, usockaddr_len)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_getsockname
+SC_TRACE_EVENT(sys_getsockname,
+       TP_PROTO(int fd, struct sockaddr * usockaddr, int * usockaddr_len),
+       TP_ARGS(fd, usockaddr, usockaddr_len),
+       TP_STRUCT__entry(__field(int, fd) __field_hex(struct sockaddr *, usockaddr) __field_hex(int *, usockaddr_len)),
+       TP_fast_assign(tp_assign(fd, fd) tp_assign(usockaddr, usockaddr) tp_assign(usockaddr_len, usockaddr_len)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_reboot
+SC_TRACE_EVENT(sys_reboot,
+       TP_PROTO(int magic1, int magic2, unsigned int cmd, void * arg),
+       TP_ARGS(magic1, magic2, cmd, arg),
+       TP_STRUCT__entry(__field(int, magic1) __field(int, magic2) __field(unsigned int, cmd) __field_hex(void *, arg)),
+       TP_fast_assign(tp_assign(magic1, magic1) tp_assign(magic2, magic2) tp_assign(cmd, cmd) tp_assign(arg, arg)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_wait4
+SC_TRACE_EVENT(sys_wait4,
+       TP_PROTO(pid_t upid, int * stat_addr, int options, struct rusage * ru),
+       TP_ARGS(upid, stat_addr, options, ru),
+       TP_STRUCT__entry(__field(pid_t, upid) __field_hex(int *, stat_addr) __field(int, options) __field_hex(struct rusage *, ru)),
+       TP_fast_assign(tp_assign(upid, upid) tp_assign(stat_addr, stat_addr) tp_assign(options, options) tp_assign(ru, ru)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_quotactl
+SC_TRACE_EVENT(sys_quotactl,
+       TP_PROTO(unsigned int cmd, const char * special, qid_t id, void * addr),
+       TP_ARGS(cmd, special, id, addr),
+       TP_STRUCT__entry(__field(unsigned int, cmd) __field_hex(const char *, special) __field(qid_t, id) __field_hex(void *, addr)),
+       TP_fast_assign(tp_assign(cmd, cmd) tp_assign(special, special) tp_assign(id, id) tp_assign(addr, addr)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_mount
+SC_TRACE_EVENT(sys_mount,
+       TP_PROTO(char * dev_name, char * dir_name, char * type, unsigned long flags, void * data),
+       TP_ARGS(dev_name, dir_name, type, flags, data),
+       TP_STRUCT__entry(__string_from_user(dev_name, dev_name) __string_from_user(dir_name, dir_name) __string_from_user(type, type) __field(unsigned long, flags) __field_hex(void *, data)),
+       TP_fast_assign(tp_copy_string_from_user(dev_name, dev_name) tp_copy_string_from_user(dir_name, dir_name) tp_copy_string_from_user(type, type) tp_assign(flags, flags) tp_assign(data, data)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_llseek
+SC_TRACE_EVENT(sys_llseek,
+       TP_PROTO(unsigned int fd, unsigned long offset_high, unsigned long offset_low, loff_t * result, unsigned int origin),
+       TP_ARGS(fd, offset_high, offset_low, result, origin),
+       TP_STRUCT__entry(__field(unsigned int, fd) __field(unsigned long, offset_high) __field(unsigned long, offset_low) __field_hex(loff_t *, result) __field(unsigned int, origin)),
+       TP_fast_assign(tp_assign(fd, fd) tp_assign(offset_high, offset_high) tp_assign(offset_low, offset_low) tp_assign(result, result) tp_assign(origin, origin)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_select
+SC_TRACE_EVENT(sys_select,
+       TP_PROTO(int n, fd_set * inp, fd_set * outp, fd_set * exp, struct timeval * tvp),
+       TP_ARGS(n, inp, outp, exp, tvp),
+       TP_STRUCT__entry(__field(int, n) __field_hex(fd_set *, inp) __field_hex(fd_set *, outp) __field_hex(fd_set *, exp) __field_hex(struct timeval *, tvp)),
+       TP_fast_assign(tp_assign(n, n) tp_assign(inp, inp) tp_assign(outp, outp) tp_assign(exp, exp) tp_assign(tvp, tvp)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_ipc
+SC_TRACE_EVENT(sys_ipc,
+       TP_PROTO(unsigned int call, int first, unsigned long second, unsigned long third, void * ptr, long fifth),
+       TP_ARGS(call, first, second, third, ptr, fifth),
+       TP_STRUCT__entry(__field(unsigned int, call) __field(int, first) __field(unsigned long, second) __field(unsigned long, third) __field_hex(void *, ptr) __field(long, fifth)),
+       TP_fast_assign(tp_assign(call, call) tp_assign(first, first) tp_assign(second, second) tp_assign(third, third) tp_assign(ptr, ptr) tp_assign(fifth, fifth)),
+       TP_printk()
+)
+#endif
+
+#endif /*  _TRACE_SYSCALLS_POINTERS_H */
+
+/* This part must be outside protection */
+#include "../../../probes/define_trace.h"
+
+#else /* CREATE_SYSCALL_TABLE */
+
+#include "mips-32-syscalls-3.5.0_pointers_override.h"
+#include "syscalls_pointers_override.h"
+
+#ifndef OVERRIDE_TABLE_32_sys_read
+TRACE_SYSCALL_TABLE(sys_read, sys_read, 4007, 3)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_write
+TRACE_SYSCALL_TABLE(sys_write, sys_write, 4009, 3)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_open
+TRACE_SYSCALL_TABLE(sys_open, sys_open, 4011, 3)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_waitpid
+TRACE_SYSCALL_TABLE(sys_waitpid, sys_waitpid, 4015, 3)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_creat
+TRACE_SYSCALL_TABLE(sys_creat, sys_creat, 4017, 2)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_link
+TRACE_SYSCALL_TABLE(sys_link, sys_link, 4019, 2)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_unlink
+TRACE_SYSCALL_TABLE(sys_unlink, sys_unlink, 4021, 1)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_chdir
+TRACE_SYSCALL_TABLE(sys_chdir, sys_chdir, 4025, 1)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_time
+TRACE_SYSCALL_TABLE(sys_time, sys_time, 4027, 1)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_mknod
+TRACE_SYSCALL_TABLE(sys_mknod, sys_mknod, 4029, 3)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_chmod
+TRACE_SYSCALL_TABLE(sys_chmod, sys_chmod, 4031, 2)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_lchown
+TRACE_SYSCALL_TABLE(sys_lchown, sys_lchown, 4033, 3)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_mount
+TRACE_SYSCALL_TABLE(sys_mount, sys_mount, 4043, 5)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_oldumount
+TRACE_SYSCALL_TABLE(sys_oldumount, sys_oldumount, 4045, 1)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_stime
+TRACE_SYSCALL_TABLE(sys_stime, sys_stime, 4051, 1)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_utime
+TRACE_SYSCALL_TABLE(sys_utime, sys_utime, 4061, 2)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_access
+TRACE_SYSCALL_TABLE(sys_access, sys_access, 4067, 2)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_rename
+TRACE_SYSCALL_TABLE(sys_rename, sys_rename, 4077, 2)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_mkdir
+TRACE_SYSCALL_TABLE(sys_mkdir, sys_mkdir, 4079, 2)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_rmdir
+TRACE_SYSCALL_TABLE(sys_rmdir, sys_rmdir, 4081, 1)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_times
+TRACE_SYSCALL_TABLE(sys_times, sys_times, 4087, 1)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_umount
+TRACE_SYSCALL_TABLE(sys_umount, sys_umount, 4105, 2)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_olduname
+TRACE_SYSCALL_TABLE(sys_olduname, sys_olduname, 4119, 1)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_chroot
+TRACE_SYSCALL_TABLE(sys_chroot, sys_chroot, 4123, 1)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_ustat
+TRACE_SYSCALL_TABLE(sys_ustat, sys_ustat, 4125, 2)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_sigaction
+TRACE_SYSCALL_TABLE(sys_sigaction, sys_sigaction, 4135, 3)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_sigpending
+TRACE_SYSCALL_TABLE(sys_sigpending, sys_sigpending, 4147, 1)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_sethostname
+TRACE_SYSCALL_TABLE(sys_sethostname, sys_sethostname, 4149, 2)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_setrlimit
+TRACE_SYSCALL_TABLE(sys_setrlimit, sys_setrlimit, 4151, 2)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_getrlimit
+TRACE_SYSCALL_TABLE(sys_getrlimit, sys_getrlimit, 4153, 2)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_getrusage
+TRACE_SYSCALL_TABLE(sys_getrusage, sys_getrusage, 4155, 2)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_gettimeofday
+TRACE_SYSCALL_TABLE(sys_gettimeofday, sys_gettimeofday, 4157, 2)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_settimeofday
+TRACE_SYSCALL_TABLE(sys_settimeofday, sys_settimeofday, 4159, 2)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_getgroups
+TRACE_SYSCALL_TABLE(sys_getgroups, sys_getgroups, 4161, 2)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_setgroups
+TRACE_SYSCALL_TABLE(sys_setgroups, sys_setgroups, 4163, 2)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_symlink
+TRACE_SYSCALL_TABLE(sys_symlink, sys_symlink, 4167, 2)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_readlink
+TRACE_SYSCALL_TABLE(sys_readlink, sys_readlink, 4171, 3)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_uselib
+TRACE_SYSCALL_TABLE(sys_uselib, sys_uselib, 4173, 1)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_swapon
+TRACE_SYSCALL_TABLE(sys_swapon, sys_swapon, 4175, 2)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_reboot
+TRACE_SYSCALL_TABLE(sys_reboot, sys_reboot, 4177, 4)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_old_readdir
+TRACE_SYSCALL_TABLE(sys_old_readdir, sys_old_readdir, 4179, 3)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_truncate
+TRACE_SYSCALL_TABLE(sys_truncate, sys_truncate, 4185, 2)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_statfs
+TRACE_SYSCALL_TABLE(sys_statfs, sys_statfs, 4199, 2)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_fstatfs
+TRACE_SYSCALL_TABLE(sys_fstatfs, sys_fstatfs, 4201, 2)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_socketcall
+TRACE_SYSCALL_TABLE(sys_socketcall, sys_socketcall, 4205, 2)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_syslog
+TRACE_SYSCALL_TABLE(sys_syslog, sys_syslog, 4207, 3)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_setitimer
+TRACE_SYSCALL_TABLE(sys_setitimer, sys_setitimer, 4209, 3)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_getitimer
+TRACE_SYSCALL_TABLE(sys_getitimer, sys_getitimer, 4211, 2)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_newstat
+TRACE_SYSCALL_TABLE(sys_newstat, sys_newstat, 4213, 2)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_newlstat
+TRACE_SYSCALL_TABLE(sys_newlstat, sys_newlstat, 4215, 2)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_newfstat
+TRACE_SYSCALL_TABLE(sys_newfstat, sys_newfstat, 4217, 2)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_uname
+TRACE_SYSCALL_TABLE(sys_uname, sys_uname, 4219, 1)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_wait4
+TRACE_SYSCALL_TABLE(sys_wait4, sys_wait4, 4229, 4)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_swapoff
+TRACE_SYSCALL_TABLE(sys_swapoff, sys_swapoff, 4231, 1)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_sysinfo
+TRACE_SYSCALL_TABLE(sys_sysinfo, sys_sysinfo, 4233, 1)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_ipc
+TRACE_SYSCALL_TABLE(sys_ipc, sys_ipc, 4235, 6)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_setdomainname
+TRACE_SYSCALL_TABLE(sys_setdomainname, sys_setdomainname, 4243, 2)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_newuname
+TRACE_SYSCALL_TABLE(sys_newuname, sys_newuname, 4245, 1)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_adjtimex
+TRACE_SYSCALL_TABLE(sys_adjtimex, sys_adjtimex, 4249, 1)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_sigprocmask
+TRACE_SYSCALL_TABLE(sys_sigprocmask, sys_sigprocmask, 4253, 3)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_init_module
+TRACE_SYSCALL_TABLE(sys_init_module, sys_init_module, 4257, 3)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_delete_module
+TRACE_SYSCALL_TABLE(sys_delete_module, sys_delete_module, 4259, 2)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_quotactl
+TRACE_SYSCALL_TABLE(sys_quotactl, sys_quotactl, 4263, 4)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_llseek
+TRACE_SYSCALL_TABLE(sys_llseek, sys_llseek, 4281, 5)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_getdents
+TRACE_SYSCALL_TABLE(sys_getdents, sys_getdents, 4283, 3)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_select
+TRACE_SYSCALL_TABLE(sys_select, sys_select, 4285, 5)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_readv
+TRACE_SYSCALL_TABLE(sys_readv, sys_readv, 4291, 3)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_writev
+TRACE_SYSCALL_TABLE(sys_writev, sys_writev, 4293, 3)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_cachectl
+TRACE_SYSCALL_TABLE(sys_cachectl, sys_cachectl, 4297, 3)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_sysctl
+TRACE_SYSCALL_TABLE(sys_sysctl, sys_sysctl, 4307, 1)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_sched_setparam
+TRACE_SYSCALL_TABLE(sys_sched_setparam, sys_sched_setparam, 4317, 2)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_sched_getparam
+TRACE_SYSCALL_TABLE(sys_sched_getparam, sys_sched_getparam, 4319, 2)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_sched_setscheduler
+TRACE_SYSCALL_TABLE(sys_sched_setscheduler, sys_sched_setscheduler, 4321, 3)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_sched_rr_get_interval
+TRACE_SYSCALL_TABLE(sys_sched_rr_get_interval, sys_sched_rr_get_interval, 4331, 2)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_nanosleep
+TRACE_SYSCALL_TABLE(sys_nanosleep, sys_nanosleep, 4333, 2)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_accept
+TRACE_SYSCALL_TABLE(sys_accept, sys_accept, 4337, 3)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_bind
+TRACE_SYSCALL_TABLE(sys_bind, sys_bind, 4339, 3)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_connect
+TRACE_SYSCALL_TABLE(sys_connect, sys_connect, 4341, 3)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_getpeername
+TRACE_SYSCALL_TABLE(sys_getpeername, sys_getpeername, 4343, 3)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_getsockname
+TRACE_SYSCALL_TABLE(sys_getsockname, sys_getsockname, 4345, 3)
+#endif
+
+#endif /* CREATE_SYSCALL_TABLE */
diff --git a/drivers/staging/lttng/instrumentation/syscalls/headers/mips-32-syscalls-3.5.0_pointers_override.h b/drivers/staging/lttng/instrumentation/syscalls/headers/mips-32-syscalls-3.5.0_pointers_override.h
new file mode 100644 (file)
index 0000000..596104d
--- /dev/null
@@ -0,0 +1,8 @@
+#ifndef CREATE_SYSCALL_TABLE
+
+#else  /* CREATE_SYSCALL_TABLE */
+
+#define OVERRIDE_TABLE_32_sys_clone
+TRACE_SYSCALL_TABLE(sys_clone, sys_clone, 4120, 0)
+
+#endif /* CREATE_SYSCALL_TABLE */
diff --git a/drivers/staging/lttng/instrumentation/syscalls/headers/mips-64-syscalls-3.5.0_integers.h b/drivers/staging/lttng/instrumentation/syscalls/headers/mips-64-syscalls-3.5.0_integers.h
new file mode 100644 (file)
index 0000000..a54cddb
--- /dev/null
@@ -0,0 +1,1163 @@
+/* THIS FILE IS AUTO-GENERATED. DO NOT EDIT */
+#ifndef CREATE_SYSCALL_TABLE
+
+#if !defined(_TRACE_SYSCALLS_INTEGERS_H) || defined(TRACE_HEADER_MULTI_READ)
+#define _TRACE_SYSCALLS_INTEGERS_H
+
+#include <linux/tracepoint.h>
+#include <linux/syscalls.h>
+#include "mips-64-syscalls-3.5.0_integers_override.h"
+#include "syscalls_integers_override.h"
+
+SC_DECLARE_EVENT_CLASS_NOARGS(syscalls_noargs,
+       TP_STRUCT__entry(),
+       TP_fast_assign(),
+       TP_printk()
+)
+#ifndef OVERRIDE_64_sys_sgetmask
+SC_DEFINE_EVENT_NOARGS(syscalls_noargs, sys_sgetmask)
+#endif
+#ifndef OVERRIDE_64_sys_sched_yield
+SC_DEFINE_EVENT_NOARGS(syscalls_noargs, sys_sched_yield)
+#endif
+#ifndef OVERRIDE_64_sys_pause
+SC_DEFINE_EVENT_NOARGS(syscalls_noargs, sys_pause)
+#endif
+#ifndef OVERRIDE_64_sys_getpid
+SC_DEFINE_EVENT_NOARGS(syscalls_noargs, sys_getpid)
+#endif
+#ifndef OVERRIDE_64_sys_getuid
+SC_DEFINE_EVENT_NOARGS(syscalls_noargs, sys_getuid)
+#endif
+#ifndef OVERRIDE_64_sys_getgid
+SC_DEFINE_EVENT_NOARGS(syscalls_noargs, sys_getgid)
+#endif
+#ifndef OVERRIDE_64_sys_geteuid
+SC_DEFINE_EVENT_NOARGS(syscalls_noargs, sys_geteuid)
+#endif
+#ifndef OVERRIDE_64_sys_getegid
+SC_DEFINE_EVENT_NOARGS(syscalls_noargs, sys_getegid)
+#endif
+#ifndef OVERRIDE_64_sys_getppid
+SC_DEFINE_EVENT_NOARGS(syscalls_noargs, sys_getppid)
+#endif
+#ifndef OVERRIDE_64_sys_getpgrp
+SC_DEFINE_EVENT_NOARGS(syscalls_noargs, sys_getpgrp)
+#endif
+#ifndef OVERRIDE_64_sys_setsid
+SC_DEFINE_EVENT_NOARGS(syscalls_noargs, sys_setsid)
+#endif
+#ifndef OVERRIDE_64_sys_munlockall
+SC_DEFINE_EVENT_NOARGS(syscalls_noargs, sys_munlockall)
+#endif
+#ifndef OVERRIDE_64_sys_vhangup
+SC_DEFINE_EVENT_NOARGS(syscalls_noargs, sys_vhangup)
+#endif
+#ifndef OVERRIDE_64_sys_sync
+SC_DEFINE_EVENT_NOARGS(syscalls_noargs, sys_sync)
+#endif
+#ifndef OVERRIDE_64_sys_gettid
+SC_DEFINE_EVENT_NOARGS(syscalls_noargs, sys_gettid)
+#endif
+#ifndef OVERRIDE_64_sys_restart_syscall
+SC_DEFINE_EVENT_NOARGS(syscalls_noargs, sys_restart_syscall)
+#endif
+#ifndef OVERRIDE_64_sys_inotify_init
+SC_DEFINE_EVENT_NOARGS(syscalls_noargs, sys_inotify_init)
+#endif
+#ifndef OVERRIDE_64_sys_nice
+SC_TRACE_EVENT(sys_nice,
+       TP_PROTO(int increment),
+       TP_ARGS(increment),
+       TP_STRUCT__entry(__field(int, increment)),
+       TP_fast_assign(tp_assign(increment, increment)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_64_sys_ssetmask
+SC_TRACE_EVENT(sys_ssetmask,
+       TP_PROTO(int newmask),
+       TP_ARGS(newmask),
+       TP_STRUCT__entry(__field(int, newmask)),
+       TP_fast_assign(tp_assign(newmask, newmask)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_64_sys_personality
+SC_TRACE_EVENT(sys_personality,
+       TP_PROTO(unsigned int personality),
+       TP_ARGS(personality),
+       TP_STRUCT__entry(__field(unsigned int, personality)),
+       TP_fast_assign(tp_assign(personality, personality)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_64_sys_close
+SC_TRACE_EVENT(sys_close,
+       TP_PROTO(unsigned int fd),
+       TP_ARGS(fd),
+       TP_STRUCT__entry(__field(unsigned int, fd)),
+       TP_fast_assign(tp_assign(fd, fd)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_64_sys_brk
+SC_TRACE_EVENT(sys_brk,
+       TP_PROTO(unsigned long brk),
+       TP_ARGS(brk),
+       TP_STRUCT__entry(__field(unsigned long, brk)),
+       TP_fast_assign(tp_assign(brk, brk)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_64_sys_dup
+SC_TRACE_EVENT(sys_dup,
+       TP_PROTO(unsigned int fildes),
+       TP_ARGS(fildes),
+       TP_STRUCT__entry(__field(unsigned int, fildes)),
+       TP_fast_assign(tp_assign(fildes, fildes)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_64_sys_alarm
+SC_TRACE_EVENT(sys_alarm,
+       TP_PROTO(unsigned int seconds),
+       TP_ARGS(seconds),
+       TP_STRUCT__entry(__field(unsigned int, seconds)),
+       TP_fast_assign(tp_assign(seconds, seconds)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_64_sys_exit
+SC_TRACE_EVENT(sys_exit,
+       TP_PROTO(int error_code),
+       TP_ARGS(error_code),
+       TP_STRUCT__entry(__field(int, error_code)),
+       TP_fast_assign(tp_assign(error_code, error_code)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_64_sys_fsync
+SC_TRACE_EVENT(sys_fsync,
+       TP_PROTO(unsigned int fd),
+       TP_ARGS(fd),
+       TP_STRUCT__entry(__field(unsigned int, fd)),
+       TP_fast_assign(tp_assign(fd, fd)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_64_sys_fdatasync
+SC_TRACE_EVENT(sys_fdatasync,
+       TP_PROTO(unsigned int fd),
+       TP_ARGS(fd),
+       TP_STRUCT__entry(__field(unsigned int, fd)),
+       TP_fast_assign(tp_assign(fd, fd)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_64_sys_fchdir
+SC_TRACE_EVENT(sys_fchdir,
+       TP_PROTO(unsigned int fd),
+       TP_ARGS(fd),
+       TP_STRUCT__entry(__field(unsigned int, fd)),
+       TP_fast_assign(tp_assign(fd, fd)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_64_sys_umask
+SC_TRACE_EVENT(sys_umask,
+       TP_PROTO(int mask),
+       TP_ARGS(mask),
+       TP_STRUCT__entry(__field(int, mask)),
+       TP_fast_assign(tp_assign(mask, mask)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_64_sys_setuid
+SC_TRACE_EVENT(sys_setuid,
+       TP_PROTO(uid_t uid),
+       TP_ARGS(uid),
+       TP_STRUCT__entry(__field(uid_t, uid)),
+       TP_fast_assign(tp_assign(uid, uid)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_64_sys_setgid
+SC_TRACE_EVENT(sys_setgid,
+       TP_PROTO(gid_t gid),
+       TP_ARGS(gid),
+       TP_STRUCT__entry(__field(gid_t, gid)),
+       TP_fast_assign(tp_assign(gid, gid)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_64_sys_getpgid
+SC_TRACE_EVENT(sys_getpgid,
+       TP_PROTO(pid_t pid),
+       TP_ARGS(pid),
+       TP_STRUCT__entry(__field(pid_t, pid)),
+       TP_fast_assign(tp_assign(pid, pid)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_64_sys_setfsuid
+SC_TRACE_EVENT(sys_setfsuid,
+       TP_PROTO(uid_t uid),
+       TP_ARGS(uid),
+       TP_STRUCT__entry(__field(uid_t, uid)),
+       TP_fast_assign(tp_assign(uid, uid)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_64_sys_setfsgid
+SC_TRACE_EVENT(sys_setfsgid,
+       TP_PROTO(gid_t gid),
+       TP_ARGS(gid),
+       TP_STRUCT__entry(__field(gid_t, gid)),
+       TP_fast_assign(tp_assign(gid, gid)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_64_sys_getsid
+SC_TRACE_EVENT(sys_getsid,
+       TP_PROTO(pid_t pid),
+       TP_ARGS(pid),
+       TP_STRUCT__entry(__field(pid_t, pid)),
+       TP_fast_assign(tp_assign(pid, pid)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_64_sys_32_personality
+SC_TRACE_EVENT(sys_32_personality,
+       TP_PROTO(unsigned long personality),
+       TP_ARGS(personality),
+       TP_STRUCT__entry(__field(unsigned long, personality)),
+       TP_fast_assign(tp_assign(personality, personality)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_64_sys_sched_getscheduler
+SC_TRACE_EVENT(sys_sched_getscheduler,
+       TP_PROTO(pid_t pid),
+       TP_ARGS(pid),
+       TP_STRUCT__entry(__field(pid_t, pid)),
+       TP_fast_assign(tp_assign(pid, pid)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_64_sys_sched_get_priority_max
+SC_TRACE_EVENT(sys_sched_get_priority_max,
+       TP_PROTO(int policy),
+       TP_ARGS(policy),
+       TP_STRUCT__entry(__field(int, policy)),
+       TP_fast_assign(tp_assign(policy, policy)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_64_sys_sched_get_priority_min
+SC_TRACE_EVENT(sys_sched_get_priority_min,
+       TP_PROTO(int policy),
+       TP_ARGS(policy),
+       TP_STRUCT__entry(__field(int, policy)),
+       TP_fast_assign(tp_assign(policy, policy)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_64_sys_mlockall
+SC_TRACE_EVENT(sys_mlockall,
+       TP_PROTO(int flags),
+       TP_ARGS(flags),
+       TP_STRUCT__entry(__field(int, flags)),
+       TP_fast_assign(tp_assign(flags, flags)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_64_sys_io_destroy
+SC_TRACE_EVENT(sys_io_destroy,
+       TP_PROTO(aio_context_t ctx),
+       TP_ARGS(ctx),
+       TP_STRUCT__entry(__field(aio_context_t, ctx)),
+       TP_fast_assign(tp_assign(ctx, ctx)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_64_sys_exit_group
+SC_TRACE_EVENT(sys_exit_group,
+       TP_PROTO(int error_code),
+       TP_ARGS(error_code),
+       TP_STRUCT__entry(__field(int, error_code)),
+       TP_fast_assign(tp_assign(error_code, error_code)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_64_sys_epoll_create
+SC_TRACE_EVENT(sys_epoll_create,
+       TP_PROTO(int size),
+       TP_ARGS(size),
+       TP_STRUCT__entry(__field(int, size)),
+       TP_fast_assign(tp_assign(size, size)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_64_sys_timer_getoverrun
+SC_TRACE_EVENT(sys_timer_getoverrun,
+       TP_PROTO(timer_t timer_id),
+       TP_ARGS(timer_id),
+       TP_STRUCT__entry(__field(timer_t, timer_id)),
+       TP_fast_assign(tp_assign(timer_id, timer_id)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_64_sys_timer_delete
+SC_TRACE_EVENT(sys_timer_delete,
+       TP_PROTO(timer_t timer_id),
+       TP_ARGS(timer_id),
+       TP_STRUCT__entry(__field(timer_t, timer_id)),
+       TP_fast_assign(tp_assign(timer_id, timer_id)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_64_sys_set_thread_area
+SC_TRACE_EVENT(sys_set_thread_area,
+       TP_PROTO(unsigned long addr),
+       TP_ARGS(addr),
+       TP_STRUCT__entry(__field_hex(unsigned long, addr)),
+       TP_fast_assign(tp_assign(addr, addr)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_64_sys_unshare
+SC_TRACE_EVENT(sys_unshare,
+       TP_PROTO(unsigned long unshare_flags),
+       TP_ARGS(unshare_flags),
+       TP_STRUCT__entry(__field(unsigned long, unshare_flags)),
+       TP_fast_assign(tp_assign(unshare_flags, unshare_flags)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_64_sys_eventfd
+SC_TRACE_EVENT(sys_eventfd,
+       TP_PROTO(unsigned int count),
+       TP_ARGS(count),
+       TP_STRUCT__entry(__field(unsigned int, count)),
+       TP_fast_assign(tp_assign(count, count)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_64_sys_epoll_create1
+SC_TRACE_EVENT(sys_epoll_create1,
+       TP_PROTO(int flags),
+       TP_ARGS(flags),
+       TP_STRUCT__entry(__field(int, flags)),
+       TP_fast_assign(tp_assign(flags, flags)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_64_sys_inotify_init1
+SC_TRACE_EVENT(sys_inotify_init1,
+       TP_PROTO(int flags),
+       TP_ARGS(flags),
+       TP_STRUCT__entry(__field(int, flags)),
+       TP_fast_assign(tp_assign(flags, flags)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_64_sys_syncfs
+SC_TRACE_EVENT(sys_syncfs,
+       TP_PROTO(int fd),
+       TP_ARGS(fd),
+       TP_STRUCT__entry(__field(int, fd)),
+       TP_fast_assign(tp_assign(fd, fd)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_64_sys_bdflush
+SC_TRACE_EVENT(sys_bdflush,
+       TP_PROTO(int func, long data),
+       TP_ARGS(func, data),
+       TP_STRUCT__entry(__field(int, func) __field(long, data)),
+       TP_fast_assign(tp_assign(func, func) tp_assign(data, data)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_64_sys_munmap
+SC_TRACE_EVENT(sys_munmap,
+       TP_PROTO(unsigned long addr, size_t len),
+       TP_ARGS(addr, len),
+       TP_STRUCT__entry(__field_hex(unsigned long, addr) __field(size_t, len)),
+       TP_fast_assign(tp_assign(addr, addr) tp_assign(len, len)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_64_sys_dup2
+SC_TRACE_EVENT(sys_dup2,
+       TP_PROTO(unsigned int oldfd, unsigned int newfd),
+       TP_ARGS(oldfd, newfd),
+       TP_STRUCT__entry(__field(unsigned int, oldfd) __field(unsigned int, newfd)),
+       TP_fast_assign(tp_assign(oldfd, oldfd) tp_assign(newfd, newfd)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_64_sys_shutdown
+SC_TRACE_EVENT(sys_shutdown,
+       TP_PROTO(int fd, int how),
+       TP_ARGS(fd, how),
+       TP_STRUCT__entry(__field(int, fd) __field(int, how)),
+       TP_fast_assign(tp_assign(fd, fd) tp_assign(how, how)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_64_sys_listen
+SC_TRACE_EVENT(sys_listen,
+       TP_PROTO(int fd, int backlog),
+       TP_ARGS(fd, backlog),
+       TP_STRUCT__entry(__field(int, fd) __field(int, backlog)),
+       TP_fast_assign(tp_assign(fd, fd) tp_assign(backlog, backlog)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_64_sys_kill
+SC_TRACE_EVENT(sys_kill,
+       TP_PROTO(pid_t pid, int sig),
+       TP_ARGS(pid, sig),
+       TP_STRUCT__entry(__field(pid_t, pid) __field(int, sig)),
+       TP_fast_assign(tp_assign(pid, pid) tp_assign(sig, sig)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_64_sys_msgget
+SC_TRACE_EVENT(sys_msgget,
+       TP_PROTO(key_t key, int msgflg),
+       TP_ARGS(key, msgflg),
+       TP_STRUCT__entry(__field(key_t, key) __field(int, msgflg)),
+       TP_fast_assign(tp_assign(key, key) tp_assign(msgflg, msgflg)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_64_sys_flock
+SC_TRACE_EVENT(sys_flock,
+       TP_PROTO(unsigned int fd, unsigned int cmd),
+       TP_ARGS(fd, cmd),
+       TP_STRUCT__entry(__field(unsigned int, fd) __field(unsigned int, cmd)),
+       TP_fast_assign(tp_assign(fd, fd) tp_assign(cmd, cmd)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_64_sys_ftruncate
+SC_TRACE_EVENT(sys_ftruncate,
+       TP_PROTO(unsigned int fd, unsigned long length),
+       TP_ARGS(fd, length),
+       TP_STRUCT__entry(__field(unsigned int, fd) __field(unsigned long, length)),
+       TP_fast_assign(tp_assign(fd, fd) tp_assign(length, length)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_64_sys_fchmod
+SC_TRACE_EVENT(sys_fchmod,
+       TP_PROTO(unsigned int fd, umode_t mode),
+       TP_ARGS(fd, mode),
+       TP_STRUCT__entry(__field(unsigned int, fd) __field(umode_t, mode)),
+       TP_fast_assign(tp_assign(fd, fd) tp_assign(mode, mode)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_64_sys_setpgid
+SC_TRACE_EVENT(sys_setpgid,
+       TP_PROTO(pid_t pid, pid_t pgid),
+       TP_ARGS(pid, pgid),
+       TP_STRUCT__entry(__field(pid_t, pid) __field(pid_t, pgid)),
+       TP_fast_assign(tp_assign(pid, pid) tp_assign(pgid, pgid)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_64_sys_setreuid
+SC_TRACE_EVENT(sys_setreuid,
+       TP_PROTO(uid_t ruid, uid_t euid),
+       TP_ARGS(ruid, euid),
+       TP_STRUCT__entry(__field(uid_t, ruid) __field(uid_t, euid)),
+       TP_fast_assign(tp_assign(ruid, ruid) tp_assign(euid, euid)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_64_sys_setregid
+SC_TRACE_EVENT(sys_setregid,
+       TP_PROTO(gid_t rgid, gid_t egid),
+       TP_ARGS(rgid, egid),
+       TP_STRUCT__entry(__field(gid_t, rgid) __field(gid_t, egid)),
+       TP_fast_assign(tp_assign(rgid, rgid) tp_assign(egid, egid)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_64_sys_getpriority
+SC_TRACE_EVENT(sys_getpriority,
+       TP_PROTO(int which, int who),
+       TP_ARGS(which, who),
+       TP_STRUCT__entry(__field(int, which) __field(int, who)),
+       TP_fast_assign(tp_assign(which, which) tp_assign(who, who)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_64_sys_mlock
+SC_TRACE_EVENT(sys_mlock,
+       TP_PROTO(unsigned long start, size_t len),
+       TP_ARGS(start, len),
+       TP_STRUCT__entry(__field(unsigned long, start) __field(size_t, len)),
+       TP_fast_assign(tp_assign(start, start) tp_assign(len, len)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_64_sys_munlock
+SC_TRACE_EVENT(sys_munlock,
+       TP_PROTO(unsigned long start, size_t len),
+       TP_ARGS(start, len),
+       TP_STRUCT__entry(__field(unsigned long, start) __field(size_t, len)),
+       TP_fast_assign(tp_assign(start, start) tp_assign(len, len)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_64_sys_tkill
+SC_TRACE_EVENT(sys_tkill,
+       TP_PROTO(pid_t pid, int sig),
+       TP_ARGS(pid, sig),
+       TP_STRUCT__entry(__field(pid_t, pid) __field(int, sig)),
+       TP_fast_assign(tp_assign(pid, pid) tp_assign(sig, sig)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_64_sys_inotify_rm_watch
+SC_TRACE_EVENT(sys_inotify_rm_watch,
+       TP_PROTO(int fd, __s32 wd),
+       TP_ARGS(fd, wd),
+       TP_STRUCT__entry(__field(int, fd) __field(__s32, wd)),
+       TP_fast_assign(tp_assign(fd, fd) tp_assign(wd, wd)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_64_sys_ioprio_get
+SC_TRACE_EVENT(sys_ioprio_get,
+       TP_PROTO(int which, int who),
+       TP_ARGS(which, who),
+       TP_STRUCT__entry(__field(int, which) __field(int, who)),
+       TP_fast_assign(tp_assign(which, which) tp_assign(who, who)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_64_sys_timerfd_create
+SC_TRACE_EVENT(sys_timerfd_create,
+       TP_PROTO(int clockid, int flags),
+       TP_ARGS(clockid, flags),
+       TP_STRUCT__entry(__field(int, clockid) __field(int, flags)),
+       TP_fast_assign(tp_assign(clockid, clockid) tp_assign(flags, flags)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_64_sys_eventfd2
+SC_TRACE_EVENT(sys_eventfd2,
+       TP_PROTO(unsigned int count, int flags),
+       TP_ARGS(count, flags),
+       TP_STRUCT__entry(__field(unsigned int, count) __field(int, flags)),
+       TP_fast_assign(tp_assign(count, count) tp_assign(flags, flags)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_64_sys_setns
+SC_TRACE_EVENT(sys_setns,
+       TP_PROTO(int fd, int nstype),
+       TP_ARGS(fd, nstype),
+       TP_STRUCT__entry(__field(int, fd) __field(int, nstype)),
+       TP_fast_assign(tp_assign(fd, fd) tp_assign(nstype, nstype)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_64_sys_ioctl
+SC_TRACE_EVENT(sys_ioctl,
+       TP_PROTO(unsigned int fd, unsigned int cmd, unsigned long arg),
+       TP_ARGS(fd, cmd, arg),
+       TP_STRUCT__entry(__field(unsigned int, fd) __field(unsigned int, cmd) __field(unsigned long, arg)),
+       TP_fast_assign(tp_assign(fd, fd) tp_assign(cmd, cmd) tp_assign(arg, arg)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_64_sys_fcntl
+SC_TRACE_EVENT(sys_fcntl,
+       TP_PROTO(unsigned int fd, unsigned int cmd, unsigned long arg),
+       TP_ARGS(fd, cmd, arg),
+       TP_STRUCT__entry(__field(unsigned int, fd) __field(unsigned int, cmd) __field(unsigned long, arg)),
+       TP_fast_assign(tp_assign(fd, fd) tp_assign(cmd, cmd) tp_assign(arg, arg)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_64_sys_lseek
+SC_TRACE_EVENT(sys_lseek,
+       TP_PROTO(unsigned int fd, off_t offset, unsigned int origin),
+       TP_ARGS(fd, offset, origin),
+       TP_STRUCT__entry(__field(unsigned int, fd) __field(off_t, offset) __field(unsigned int, origin)),
+       TP_fast_assign(tp_assign(fd, fd) tp_assign(offset, offset) tp_assign(origin, origin)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_64_sys_mprotect
+SC_TRACE_EVENT(sys_mprotect,
+       TP_PROTO(unsigned long start, size_t len, unsigned long prot),
+       TP_ARGS(start, len, prot),
+       TP_STRUCT__entry(__field(unsigned long, start) __field(size_t, len) __field(unsigned long, prot)),
+       TP_fast_assign(tp_assign(start, start) tp_assign(len, len) tp_assign(prot, prot)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_64_sys_msync
+SC_TRACE_EVENT(sys_msync,
+       TP_PROTO(unsigned long start, size_t len, int flags),
+       TP_ARGS(start, len, flags),
+       TP_STRUCT__entry(__field(unsigned long, start) __field(size_t, len) __field(int, flags)),
+       TP_fast_assign(tp_assign(start, start) tp_assign(len, len) tp_assign(flags, flags)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_64_sys_madvise
+SC_TRACE_EVENT(sys_madvise,
+       TP_PROTO(unsigned long start, size_t len_in, int behavior),
+       TP_ARGS(start, len_in, behavior),
+       TP_STRUCT__entry(__field(unsigned long, start) __field(size_t, len_in) __field(int, behavior)),
+       TP_fast_assign(tp_assign(start, start) tp_assign(len_in, len_in) tp_assign(behavior, behavior)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_64_sys_shmget
+SC_TRACE_EVENT(sys_shmget,
+       TP_PROTO(key_t key, size_t size, int shmflg),
+       TP_ARGS(key, size, shmflg),
+       TP_STRUCT__entry(__field(key_t, key) __field(size_t, size) __field(int, shmflg)),
+       TP_fast_assign(tp_assign(key, key) tp_assign(size, size) tp_assign(shmflg, shmflg)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_64_sys_socket
+SC_TRACE_EVENT(sys_socket,
+       TP_PROTO(int family, int type, int protocol),
+       TP_ARGS(family, type, protocol),
+       TP_STRUCT__entry(__field(int, family) __field(int, type) __field(int, protocol)),
+       TP_fast_assign(tp_assign(family, family) tp_assign(type, type) tp_assign(protocol, protocol)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_64_sys_semget
+SC_TRACE_EVENT(sys_semget,
+       TP_PROTO(key_t key, int nsems, int semflg),
+       TP_ARGS(key, nsems, semflg),
+       TP_STRUCT__entry(__field(key_t, key) __field(int, nsems) __field(int, semflg)),
+       TP_fast_assign(tp_assign(key, key) tp_assign(nsems, nsems) tp_assign(semflg, semflg)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_64_sys_fchown
+SC_TRACE_EVENT(sys_fchown,
+       TP_PROTO(unsigned int fd, uid_t user, gid_t group),
+       TP_ARGS(fd, user, group),
+       TP_STRUCT__entry(__field(unsigned int, fd) __field(uid_t, user) __field(gid_t, group)),
+       TP_fast_assign(tp_assign(fd, fd) tp_assign(user, user) tp_assign(group, group)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_64_sys_setresuid
+SC_TRACE_EVENT(sys_setresuid,
+       TP_PROTO(uid_t ruid, uid_t euid, uid_t suid),
+       TP_ARGS(ruid, euid, suid),
+       TP_STRUCT__entry(__field(uid_t, ruid) __field(uid_t, euid) __field(uid_t, suid)),
+       TP_fast_assign(tp_assign(ruid, ruid) tp_assign(euid, euid) tp_assign(suid, suid)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_64_sys_setresgid
+SC_TRACE_EVENT(sys_setresgid,
+       TP_PROTO(gid_t rgid, gid_t egid, gid_t sgid),
+       TP_ARGS(rgid, egid, sgid),
+       TP_STRUCT__entry(__field(gid_t, rgid) __field(gid_t, egid) __field(gid_t, sgid)),
+       TP_fast_assign(tp_assign(rgid, rgid) tp_assign(egid, egid) tp_assign(sgid, sgid)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_64_sys_sysfs
+SC_TRACE_EVENT(sys_sysfs,
+       TP_PROTO(int option, unsigned long arg1, unsigned long arg2),
+       TP_ARGS(option, arg1, arg2),
+       TP_STRUCT__entry(__field(int, option) __field(unsigned long, arg1) __field(unsigned long, arg2)),
+       TP_fast_assign(tp_assign(option, option) tp_assign(arg1, arg1) tp_assign(arg2, arg2)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_64_sys_setpriority
+SC_TRACE_EVENT(sys_setpriority,
+       TP_PROTO(int which, int who, int niceval),
+       TP_ARGS(which, who, niceval),
+       TP_STRUCT__entry(__field(int, which) __field(int, who) __field(int, niceval)),
+       TP_fast_assign(tp_assign(which, which) tp_assign(who, who) tp_assign(niceval, niceval)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_64_sys_cacheflush
+SC_TRACE_EVENT(sys_cacheflush,
+       TP_PROTO(unsigned long addr, unsigned long bytes, unsigned int cache),
+       TP_ARGS(addr, bytes, cache),
+       TP_STRUCT__entry(__field_hex(unsigned long, addr) __field(unsigned long, bytes) __field(unsigned int, cache)),
+       TP_fast_assign(tp_assign(addr, addr) tp_assign(bytes, bytes) tp_assign(cache, cache)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_64_sys_tgkill
+SC_TRACE_EVENT(sys_tgkill,
+       TP_PROTO(pid_t tgid, pid_t pid, int sig),
+       TP_ARGS(tgid, pid, sig),
+       TP_STRUCT__entry(__field(pid_t, tgid) __field(pid_t, pid) __field(int, sig)),
+       TP_fast_assign(tp_assign(tgid, tgid) tp_assign(pid, pid) tp_assign(sig, sig)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_64_sys_ioprio_set
+SC_TRACE_EVENT(sys_ioprio_set,
+       TP_PROTO(int which, int who, int ioprio),
+       TP_ARGS(which, who, ioprio),
+       TP_STRUCT__entry(__field(int, which) __field(int, who) __field(int, ioprio)),
+       TP_fast_assign(tp_assign(which, which) tp_assign(who, who) tp_assign(ioprio, ioprio)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_64_sys_dup3
+SC_TRACE_EVENT(sys_dup3,
+       TP_PROTO(unsigned int oldfd, unsigned int newfd, int flags),
+       TP_ARGS(oldfd, newfd, flags),
+       TP_STRUCT__entry(__field(unsigned int, oldfd) __field(unsigned int, newfd) __field(int, flags)),
+       TP_fast_assign(tp_assign(oldfd, oldfd) tp_assign(newfd, newfd) tp_assign(flags, flags)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_64_sys_32_ftruncate64
+SC_TRACE_EVENT(sys_32_ftruncate64,
+       TP_PROTO(unsigned long fd, unsigned long __dummy, unsigned long a2, unsigned long a3),
+       TP_ARGS(fd, __dummy, a2, a3),
+       TP_STRUCT__entry(__field(unsigned long, fd) __field(unsigned long, __dummy) __field(unsigned long, a2) __field(unsigned long, a3)),
+       TP_fast_assign(tp_assign(fd, fd) tp_assign(__dummy, __dummy) tp_assign(a2, a2) tp_assign(a3, a3)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_64_sys_ptrace
+SC_TRACE_EVENT(sys_ptrace,
+       TP_PROTO(long request, long pid, unsigned long addr, unsigned long data),
+       TP_ARGS(request, pid, addr, data),
+       TP_STRUCT__entry(__field(long, request) __field(long, pid) __field_hex(unsigned long, addr) __field(unsigned long, data)),
+       TP_fast_assign(tp_assign(request, request) tp_assign(pid, pid) tp_assign(addr, addr) tp_assign(data, data)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_64_sys_n32_semctl
+SC_TRACE_EVENT(sys_n32_semctl,
+       TP_PROTO(int semid, int semnum, int cmd, u32 arg),
+       TP_ARGS(semid, semnum, cmd, arg),
+       TP_STRUCT__entry(__field(int, semid) __field(int, semnum) __field(int, cmd) __field(u32, arg)),
+       TP_fast_assign(tp_assign(semid, semid) tp_assign(semnum, semnum) tp_assign(cmd, cmd) tp_assign(arg, arg)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_64_sys_n32_msgsnd
+SC_TRACE_EVENT(sys_n32_msgsnd,
+       TP_PROTO(int msqid, u32 msgp, unsigned int msgsz, int msgflg),
+       TP_ARGS(msqid, msgp, msgsz, msgflg),
+       TP_STRUCT__entry(__field(int, msqid) __field(u32, msgp) __field(unsigned int, msgsz) __field(int, msgflg)),
+       TP_fast_assign(tp_assign(msqid, msqid) tp_assign(msgp, msgp) tp_assign(msgsz, msgsz) tp_assign(msgflg, msgflg)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_64_sys_tee
+SC_TRACE_EVENT(sys_tee,
+       TP_PROTO(int fdin, int fdout, size_t len, unsigned int flags),
+       TP_ARGS(fdin, fdout, len, flags),
+       TP_STRUCT__entry(__field(int, fdin) __field(int, fdout) __field(size_t, len) __field(unsigned int, flags)),
+       TP_fast_assign(tp_assign(fdin, fdin) tp_assign(fdout, fdout) tp_assign(len, len) tp_assign(flags, flags)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_64_sys_mremap
+SC_TRACE_EVENT(sys_mremap,
+       TP_PROTO(unsigned long addr, unsigned long old_len, unsigned long new_len, unsigned long flags, unsigned long new_addr),
+       TP_ARGS(addr, old_len, new_len, flags, new_addr),
+       TP_STRUCT__entry(__field_hex(unsigned long, addr) __field(unsigned long, old_len) __field(unsigned long, new_len) __field(unsigned long, flags) __field_hex(unsigned long, new_addr)),
+       TP_fast_assign(tp_assign(addr, addr) tp_assign(old_len, old_len) tp_assign(new_len, new_len) tp_assign(flags, flags) tp_assign(new_addr, new_addr)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_64_sys_n32_msgrcv
+SC_TRACE_EVENT(sys_n32_msgrcv,
+       TP_PROTO(int msqid, u32 msgp, size_t msgsz, int msgtyp, int msgflg),
+       TP_ARGS(msqid, msgp, msgsz, msgtyp, msgflg),
+       TP_STRUCT__entry(__field(int, msqid) __field(u32, msgp) __field(size_t, msgsz) __field(int, msgtyp) __field(int, msgflg)),
+       TP_fast_assign(tp_assign(msqid, msqid) tp_assign(msgp, msgp) tp_assign(msgsz, msgsz) tp_assign(msgtyp, msgtyp) tp_assign(msgflg, msgflg)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_64_sys_prctl
+SC_TRACE_EVENT(sys_prctl,
+       TP_PROTO(int option, unsigned long arg2, unsigned long arg3, unsigned long arg4, unsigned long arg5),
+       TP_ARGS(option, arg2, arg3, arg4, arg5),
+       TP_STRUCT__entry(__field(int, option) __field(unsigned long, arg2) __field(unsigned long, arg3) __field(unsigned long, arg4) __field(unsigned long, arg5)),
+       TP_fast_assign(tp_assign(option, option) tp_assign(arg2, arg2) tp_assign(arg3, arg3) tp_assign(arg4, arg4) tp_assign(arg5, arg5)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_64_sys_remap_file_pages
+SC_TRACE_EVENT(sys_remap_file_pages,
+       TP_PROTO(unsigned long start, unsigned long size, unsigned long prot, unsigned long pgoff, unsigned long flags),
+       TP_ARGS(start, size, prot, pgoff, flags),
+       TP_STRUCT__entry(__field(unsigned long, start) __field(unsigned long, size) __field(unsigned long, prot) __field(unsigned long, pgoff) __field(unsigned long, flags)),
+       TP_fast_assign(tp_assign(start, start) tp_assign(size, size) tp_assign(prot, prot) tp_assign(pgoff, pgoff) tp_assign(flags, flags)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_64_sys_32_ipc
+SC_TRACE_EVENT(sys_32_ipc,
+       TP_PROTO(u32 call, long first, long second, long third, unsigned long ptr, unsigned long fifth),
+       TP_ARGS(call, first, second, third, ptr, fifth),
+       TP_STRUCT__entry(__field(u32, call) __field(long, first) __field(long, second) __field(long, third) __field_hex(unsigned long, ptr) __field(unsigned long, fifth)),
+       TP_fast_assign(tp_assign(call, call) tp_assign(first, first) tp_assign(second, second) tp_assign(third, third) tp_assign(ptr, ptr) tp_assign(fifth, fifth)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_64_sys_mips_mmap2
+SC_TRACE_EVENT(sys_mips_mmap2,
+       TP_PROTO(unsigned long addr, unsigned long len, unsigned long prot, unsigned long flags, unsigned long fd, unsigned long pgoff),
+       TP_ARGS(addr, len, prot, flags, fd, pgoff),
+       TP_STRUCT__entry(__field_hex(unsigned long, addr) __field(unsigned long, len) __field(unsigned long, prot) __field(unsigned long, flags) __field(unsigned long, fd) __field(unsigned long, pgoff)),
+       TP_fast_assign(tp_assign(addr, addr) tp_assign(len, len) tp_assign(prot, prot) tp_assign(flags, flags) tp_assign(fd, fd) tp_assign(pgoff, pgoff)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_64_sys_mips_mmap
+SC_TRACE_EVENT(sys_mips_mmap,
+       TP_PROTO(unsigned long addr, unsigned long len, unsigned long prot, unsigned long flags, unsigned long fd, off_t offset),
+       TP_ARGS(addr, len, prot, flags, fd, offset),
+       TP_STRUCT__entry(__field_hex(unsigned long, addr) __field(unsigned long, len) __field(unsigned long, prot) __field(unsigned long, flags) __field(unsigned long, fd) __field(off_t, offset)),
+       TP_fast_assign(tp_assign(addr, addr) tp_assign(len, len) tp_assign(prot, prot) tp_assign(flags, flags) tp_assign(fd, fd) tp_assign(offset, offset)),
+       TP_printk()
+)
+#endif
+
+#endif /*  _TRACE_SYSCALLS_INTEGERS_H */
+
+/* This part must be outside protection */
+#include "../../../probes/define_trace.h"
+
+#else /* CREATE_SYSCALL_TABLE */
+
+#include "mips-64-syscalls-3.5.0_integers_override.h"
+#include "syscalls_integers_override.h"
+
+#ifndef OVERRIDE_TABLE_64_sys_sgetmask
+TRACE_SYSCALL_TABLE(syscalls_noargs, sys_sgetmask, 4068, 0)
+#endif
+#ifndef OVERRIDE_TABLE_64_sys_sched_yield
+TRACE_SYSCALL_TABLE(syscalls_noargs, sys_sched_yield, 6023, 0)
+#endif
+#ifndef OVERRIDE_TABLE_64_sys_pause
+TRACE_SYSCALL_TABLE(syscalls_noargs, sys_pause, 6033, 0)
+#endif
+#ifndef OVERRIDE_TABLE_64_sys_getpid
+TRACE_SYSCALL_TABLE(syscalls_noargs, sys_getpid, 6038, 0)
+#endif
+#ifndef OVERRIDE_TABLE_64_sys_getuid
+TRACE_SYSCALL_TABLE(syscalls_noargs, sys_getuid, 6100, 0)
+#endif
+#ifndef OVERRIDE_TABLE_64_sys_getgid
+TRACE_SYSCALL_TABLE(syscalls_noargs, sys_getgid, 6102, 0)
+#endif
+#ifndef OVERRIDE_TABLE_64_sys_geteuid
+TRACE_SYSCALL_TABLE(syscalls_noargs, sys_geteuid, 6105, 0)
+#endif
+#ifndef OVERRIDE_TABLE_64_sys_getegid
+TRACE_SYSCALL_TABLE(syscalls_noargs, sys_getegid, 6106, 0)
+#endif
+#ifndef OVERRIDE_TABLE_64_sys_getppid
+TRACE_SYSCALL_TABLE(syscalls_noargs, sys_getppid, 6108, 0)
+#endif
+#ifndef OVERRIDE_TABLE_64_sys_getpgrp
+TRACE_SYSCALL_TABLE(syscalls_noargs, sys_getpgrp, 6109, 0)
+#endif
+#ifndef OVERRIDE_TABLE_64_sys_setsid
+TRACE_SYSCALL_TABLE(syscalls_noargs, sys_setsid, 6110, 0)
+#endif
+#ifndef OVERRIDE_TABLE_64_sys_munlockall
+TRACE_SYSCALL_TABLE(syscalls_noargs, sys_munlockall, 6149, 0)
+#endif
+#ifndef OVERRIDE_TABLE_64_sys_vhangup
+TRACE_SYSCALL_TABLE(syscalls_noargs, sys_vhangup, 6150, 0)
+#endif
+#ifndef OVERRIDE_TABLE_64_sys_sync
+TRACE_SYSCALL_TABLE(syscalls_noargs, sys_sync, 6157, 0)
+#endif
+#ifndef OVERRIDE_TABLE_64_sys_gettid
+TRACE_SYSCALL_TABLE(syscalls_noargs, sys_gettid, 6178, 0)
+#endif
+#ifndef OVERRIDE_TABLE_64_sys_restart_syscall
+TRACE_SYSCALL_TABLE(syscalls_noargs, sys_restart_syscall, 6214, 0)
+#endif
+#ifndef OVERRIDE_TABLE_64_sys_inotify_init
+TRACE_SYSCALL_TABLE(syscalls_noargs, sys_inotify_init, 6247, 0)
+#endif
+#ifndef OVERRIDE_TABLE_64_sys_nice
+TRACE_SYSCALL_TABLE(sys_nice, sys_nice, 4034, 1)
+#endif
+#ifndef OVERRIDE_TABLE_64_sys_ssetmask
+TRACE_SYSCALL_TABLE(sys_ssetmask, sys_ssetmask, 4069, 1)
+#endif
+#ifndef OVERRIDE_TABLE_64_sys_32_ipc
+TRACE_SYSCALL_TABLE(sys_32_ipc, sys_32_ipc, 4117, 6)
+#endif
+#ifndef OVERRIDE_TABLE_64_sys_bdflush
+TRACE_SYSCALL_TABLE(sys_bdflush, sys_bdflush, 4134, 2)
+#endif
+#ifndef OVERRIDE_TABLE_64_sys_mips_mmap2
+TRACE_SYSCALL_TABLE(sys_mips_mmap2, sys_mips_mmap2, 4210, 6)
+#endif
+#ifndef OVERRIDE_TABLE_64_sys_32_ftruncate64
+TRACE_SYSCALL_TABLE(sys_32_ftruncate64, sys_32_ftruncate64, 4212, 4)
+#endif
+#ifndef OVERRIDE_TABLE_64_sys_ioctl
+TRACE_SYSCALL_TABLE(sys_ioctl, sys_ioctl, 5015, 3)
+#endif
+#ifndef OVERRIDE_TABLE_64_sys_fcntl
+TRACE_SYSCALL_TABLE(sys_fcntl, sys_fcntl, 5070, 3)
+#endif
+#ifndef OVERRIDE_TABLE_64_sys_ptrace
+TRACE_SYSCALL_TABLE(sys_ptrace, sys_ptrace, 5099, 4)
+#endif
+#ifndef OVERRIDE_TABLE_64_sys_personality
+TRACE_SYSCALL_TABLE(sys_personality, sys_personality, 5132, 1)
+#endif
+#ifndef OVERRIDE_TABLE_64_sys_close
+TRACE_SYSCALL_TABLE(sys_close, sys_close, 6003, 1)
+#endif
+#ifndef OVERRIDE_TABLE_64_sys_lseek
+TRACE_SYSCALL_TABLE(sys_lseek, sys_lseek, 6008, 3)
+#endif
+#ifndef OVERRIDE_TABLE_64_sys_mips_mmap
+TRACE_SYSCALL_TABLE(sys_mips_mmap, sys_mips_mmap, 6009, 6)
+#endif
+#ifndef OVERRIDE_TABLE_64_sys_mprotect
+TRACE_SYSCALL_TABLE(sys_mprotect, sys_mprotect, 6010, 3)
+#endif
+#ifndef OVERRIDE_TABLE_64_sys_munmap
+TRACE_SYSCALL_TABLE(sys_munmap, sys_munmap, 6011, 2)
+#endif
+#ifndef OVERRIDE_TABLE_64_sys_brk
+TRACE_SYSCALL_TABLE(sys_brk, sys_brk, 6012, 1)
+#endif
+#ifndef OVERRIDE_TABLE_64_sys_mremap
+TRACE_SYSCALL_TABLE(sys_mremap, sys_mremap, 6024, 5)
+#endif
+#ifndef OVERRIDE_TABLE_64_sys_msync
+TRACE_SYSCALL_TABLE(sys_msync, sys_msync, 6025, 3)
+#endif
+#ifndef OVERRIDE_TABLE_64_sys_madvise
+TRACE_SYSCALL_TABLE(sys_madvise, sys_madvise, 6027, 3)
+#endif
+#ifndef OVERRIDE_TABLE_64_sys_shmget
+TRACE_SYSCALL_TABLE(sys_shmget, sys_shmget, 6028, 3)
+#endif
+#ifndef OVERRIDE_TABLE_64_sys_dup
+TRACE_SYSCALL_TABLE(sys_dup, sys_dup, 6031, 1)
+#endif
+#ifndef OVERRIDE_TABLE_64_sys_dup2
+TRACE_SYSCALL_TABLE(sys_dup2, sys_dup2, 6032, 2)
+#endif
+#ifndef OVERRIDE_TABLE_64_sys_alarm
+TRACE_SYSCALL_TABLE(sys_alarm, sys_alarm, 6037, 1)
+#endif
+#ifndef OVERRIDE_TABLE_64_sys_socket
+TRACE_SYSCALL_TABLE(sys_socket, sys_socket, 6040, 3)
+#endif
+#ifndef OVERRIDE_TABLE_64_sys_shutdown
+TRACE_SYSCALL_TABLE(sys_shutdown, sys_shutdown, 6047, 2)
+#endif
+#ifndef OVERRIDE_TABLE_64_sys_listen
+TRACE_SYSCALL_TABLE(sys_listen, sys_listen, 6049, 2)
+#endif
+#ifndef OVERRIDE_TABLE_64_sys_exit
+TRACE_SYSCALL_TABLE(sys_exit, sys_exit, 6058, 1)
+#endif
+#ifndef OVERRIDE_TABLE_64_sys_kill
+TRACE_SYSCALL_TABLE(sys_kill, sys_kill, 6060, 2)
+#endif
+#ifndef OVERRIDE_TABLE_64_sys_semget
+TRACE_SYSCALL_TABLE(sys_semget, sys_semget, 6062, 3)
+#endif
+#ifndef OVERRIDE_TABLE_64_sys_n32_semctl
+TRACE_SYSCALL_TABLE(sys_n32_semctl, sys_n32_semctl, 6064, 4)
+#endif
+#ifndef OVERRIDE_TABLE_64_sys_msgget
+TRACE_SYSCALL_TABLE(sys_msgget, sys_msgget, 6066, 2)
+#endif
+#ifndef OVERRIDE_TABLE_64_sys_n32_msgsnd
+TRACE_SYSCALL_TABLE(sys_n32_msgsnd, sys_n32_msgsnd, 6067, 4)
+#endif
+#ifndef OVERRIDE_TABLE_64_sys_n32_msgrcv
+TRACE_SYSCALL_TABLE(sys_n32_msgrcv, sys_n32_msgrcv, 6068, 5)
+#endif
+#ifndef OVERRIDE_TABLE_64_sys_flock
+TRACE_SYSCALL_TABLE(sys_flock, sys_flock, 6071, 2)
+#endif
+#ifndef OVERRIDE_TABLE_64_sys_fsync
+TRACE_SYSCALL_TABLE(sys_fsync, sys_fsync, 6072, 1)
+#endif
+#ifndef OVERRIDE_TABLE_64_sys_fdatasync
+TRACE_SYSCALL_TABLE(sys_fdatasync, sys_fdatasync, 6073, 1)
+#endif
+#ifndef OVERRIDE_TABLE_64_sys_ftruncate
+TRACE_SYSCALL_TABLE(sys_ftruncate, sys_ftruncate, 6075, 2)
+#endif
+#ifndef OVERRIDE_TABLE_64_sys_fchdir
+TRACE_SYSCALL_TABLE(sys_fchdir, sys_fchdir, 6079, 1)
+#endif
+#ifndef OVERRIDE_TABLE_64_sys_fchmod
+TRACE_SYSCALL_TABLE(sys_fchmod, sys_fchmod, 6089, 2)
+#endif
+#ifndef OVERRIDE_TABLE_64_sys_fchown
+TRACE_SYSCALL_TABLE(sys_fchown, sys_fchown, 6091, 3)
+#endif
+#ifndef OVERRIDE_TABLE_64_sys_umask
+TRACE_SYSCALL_TABLE(sys_umask, sys_umask, 6093, 1)
+#endif
+#ifndef OVERRIDE_TABLE_64_sys_setuid
+TRACE_SYSCALL_TABLE(sys_setuid, sys_setuid, 6103, 1)
+#endif
+#ifndef OVERRIDE_TABLE_64_sys_setgid
+TRACE_SYSCALL_TABLE(sys_setgid, sys_setgid, 6104, 1)
+#endif
+#ifndef OVERRIDE_TABLE_64_sys_setpgid
+TRACE_SYSCALL_TABLE(sys_setpgid, sys_setpgid, 6107, 2)
+#endif
+#ifndef OVERRIDE_TABLE_64_sys_setreuid
+TRACE_SYSCALL_TABLE(sys_setreuid, sys_setreuid, 6111, 2)
+#endif
+#ifndef OVERRIDE_TABLE_64_sys_setregid
+TRACE_SYSCALL_TABLE(sys_setregid, sys_setregid, 6112, 2)
+#endif
+#ifndef OVERRIDE_TABLE_64_sys_setresuid
+TRACE_SYSCALL_TABLE(sys_setresuid, sys_setresuid, 6115, 3)
+#endif
+#ifndef OVERRIDE_TABLE_64_sys_setresgid
+TRACE_SYSCALL_TABLE(sys_setresgid, sys_setresgid, 6117, 3)
+#endif
+#ifndef OVERRIDE_TABLE_64_sys_getpgid
+TRACE_SYSCALL_TABLE(sys_getpgid, sys_getpgid, 6119, 1)
+#endif
+#ifndef OVERRIDE_TABLE_64_sys_setfsuid
+TRACE_SYSCALL_TABLE(sys_setfsuid, sys_setfsuid, 6120, 1)
+#endif
+#ifndef OVERRIDE_TABLE_64_sys_setfsgid
+TRACE_SYSCALL_TABLE(sys_setfsgid, sys_setfsgid, 6121, 1)
+#endif
+#ifndef OVERRIDE_TABLE_64_sys_getsid
+TRACE_SYSCALL_TABLE(sys_getsid, sys_getsid, 6122, 1)
+#endif
+#ifndef OVERRIDE_TABLE_64_sys_32_personality
+TRACE_SYSCALL_TABLE(sys_32_personality, sys_32_personality, 6132, 1)
+#endif
+#ifndef OVERRIDE_TABLE_64_sys_sysfs
+TRACE_SYSCALL_TABLE(sys_sysfs, sys_sysfs, 6136, 3)
+#endif
+#ifndef OVERRIDE_TABLE_64_sys_getpriority
+TRACE_SYSCALL_TABLE(sys_getpriority, sys_getpriority, 6137, 2)
+#endif
+#ifndef OVERRIDE_TABLE_64_sys_setpriority
+TRACE_SYSCALL_TABLE(sys_setpriority, sys_setpriority, 6138, 3)
+#endif
+#ifndef OVERRIDE_TABLE_64_sys_sched_getscheduler
+TRACE_SYSCALL_TABLE(sys_sched_getscheduler, sys_sched_getscheduler, 6142, 1)
+#endif
+#ifndef OVERRIDE_TABLE_64_sys_sched_get_priority_max
+TRACE_SYSCALL_TABLE(sys_sched_get_priority_max, sys_sched_get_priority_max, 6143, 1)
+#endif
+#ifndef OVERRIDE_TABLE_64_sys_sched_get_priority_min
+TRACE_SYSCALL_TABLE(sys_sched_get_priority_min, sys_sched_get_priority_min, 6144, 1)
+#endif
+#ifndef OVERRIDE_TABLE_64_sys_mlock
+TRACE_SYSCALL_TABLE(sys_mlock, sys_mlock, 6146, 2)
+#endif
+#ifndef OVERRIDE_TABLE_64_sys_munlock
+TRACE_SYSCALL_TABLE(sys_munlock, sys_munlock, 6147, 2)
+#endif
+#ifndef OVERRIDE_TABLE_64_sys_mlockall
+TRACE_SYSCALL_TABLE(sys_mlockall, sys_mlockall, 6148, 1)
+#endif
+#ifndef OVERRIDE_TABLE_64_sys_prctl
+TRACE_SYSCALL_TABLE(sys_prctl, sys_prctl, 6153, 5)
+#endif
+#ifndef OVERRIDE_TABLE_64_sys_tkill
+TRACE_SYSCALL_TABLE(sys_tkill, sys_tkill, 6192, 2)
+#endif
+#ifndef OVERRIDE_TABLE_64_sys_cacheflush
+TRACE_SYSCALL_TABLE(sys_cacheflush, sys_cacheflush, 6197, 3)
+#endif
+#ifndef OVERRIDE_TABLE_64_sys_io_destroy
+TRACE_SYSCALL_TABLE(sys_io_destroy, sys_io_destroy, 6201, 1)
+#endif
+#ifndef OVERRIDE_TABLE_64_sys_exit_group
+TRACE_SYSCALL_TABLE(sys_exit_group, sys_exit_group, 6205, 1)
+#endif
+#ifndef OVERRIDE_TABLE_64_sys_epoll_create
+TRACE_SYSCALL_TABLE(sys_epoll_create, sys_epoll_create, 6207, 1)
+#endif
+#ifndef OVERRIDE_TABLE_64_sys_remap_file_pages
+TRACE_SYSCALL_TABLE(sys_remap_file_pages, sys_remap_file_pages, 6210, 5)
+#endif
+#ifndef OVERRIDE_TABLE_64_sys_timer_getoverrun
+TRACE_SYSCALL_TABLE(sys_timer_getoverrun, sys_timer_getoverrun, 6223, 1)
+#endif
+#ifndef OVERRIDE_TABLE_64_sys_timer_delete
+TRACE_SYSCALL_TABLE(sys_timer_delete, sys_timer_delete, 6224, 1)
+#endif
+#ifndef OVERRIDE_TABLE_64_sys_tgkill
+TRACE_SYSCALL_TABLE(sys_tgkill, sys_tgkill, 6229, 3)
+#endif
+#ifndef OVERRIDE_TABLE_64_sys_set_thread_area
+TRACE_SYSCALL_TABLE(sys_set_thread_area, sys_set_thread_area, 6246, 1)
+#endif
+#ifndef OVERRIDE_TABLE_64_sys_inotify_rm_watch
+TRACE_SYSCALL_TABLE(sys_inotify_rm_watch, sys_inotify_rm_watch, 6249, 2)
+#endif
+#ifndef OVERRIDE_TABLE_64_sys_unshare
+TRACE_SYSCALL_TABLE(sys_unshare, sys_unshare, 6266, 1)
+#endif
+#ifndef OVERRIDE_TABLE_64_sys_tee
+TRACE_SYSCALL_TABLE(sys_tee, sys_tee, 6269, 4)
+#endif
+#ifndef OVERRIDE_TABLE_64_sys_ioprio_set
+TRACE_SYSCALL_TABLE(sys_ioprio_set, sys_ioprio_set, 6277, 3)
+#endif
+#ifndef OVERRIDE_TABLE_64_sys_ioprio_get
+TRACE_SYSCALL_TABLE(sys_ioprio_get, sys_ioprio_get, 6278, 2)
+#endif
+#ifndef OVERRIDE_TABLE_64_sys_eventfd
+TRACE_SYSCALL_TABLE(sys_eventfd, sys_eventfd, 6282, 1)
+#endif
+#ifndef OVERRIDE_TABLE_64_sys_timerfd_create
+TRACE_SYSCALL_TABLE(sys_timerfd_create, sys_timerfd_create, 6284, 2)
+#endif
+#ifndef OVERRIDE_TABLE_64_sys_eventfd2
+TRACE_SYSCALL_TABLE(sys_eventfd2, sys_eventfd2, 6288, 2)
+#endif
+#ifndef OVERRIDE_TABLE_64_sys_epoll_create1
+TRACE_SYSCALL_TABLE(sys_epoll_create1, sys_epoll_create1, 6289, 1)
+#endif
+#ifndef OVERRIDE_TABLE_64_sys_dup3
+TRACE_SYSCALL_TABLE(sys_dup3, sys_dup3, 6290, 3)
+#endif
+#ifndef OVERRIDE_TABLE_64_sys_inotify_init1
+TRACE_SYSCALL_TABLE(sys_inotify_init1, sys_inotify_init1, 6292, 1)
+#endif
+#ifndef OVERRIDE_TABLE_64_sys_syncfs
+TRACE_SYSCALL_TABLE(sys_syncfs, sys_syncfs, 6306, 1)
+#endif
+#ifndef OVERRIDE_TABLE_64_sys_setns
+TRACE_SYSCALL_TABLE(sys_setns, sys_setns, 6308, 2)
+#endif
+
+#endif /* CREATE_SYSCALL_TABLE */
diff --git a/drivers/staging/lttng/instrumentation/syscalls/headers/mips-64-syscalls-3.5.0_integers_override.h b/drivers/staging/lttng/instrumentation/syscalls/headers/mips-64-syscalls-3.5.0_integers_override.h
new file mode 100644 (file)
index 0000000..49b485b
--- /dev/null
@@ -0,0 +1,3 @@
+/*
+ * this is a place-holder for MIPS integer syscall definition override.
+ */
diff --git a/drivers/staging/lttng/instrumentation/syscalls/headers/mips-64-syscalls-3.5.0_pointers.h b/drivers/staging/lttng/instrumentation/syscalls/headers/mips-64-syscalls-3.5.0_pointers.h
new file mode 100644 (file)
index 0000000..ad65c05
--- /dev/null
@@ -0,0 +1,2232 @@
+/* THIS FILE IS AUTO-GENERATED. DO NOT EDIT */
+#ifndef CREATE_SYSCALL_TABLE
+
+#if !defined(_TRACE_SYSCALLS_POINTERS_H) || defined(TRACE_HEADER_MULTI_READ)
+#define _TRACE_SYSCALLS_POINTERS_H
+
+#include <linux/tracepoint.h>
+#include <linux/syscalls.h>
+#include "mips-64-syscalls-3.5.0_pointers_override.h"
+#include "syscalls_pointers_override.h"
+
+#ifndef OVERRIDE_64_sys_oldumount
+SC_TRACE_EVENT(sys_oldumount,
+       TP_PROTO(char * name),
+       TP_ARGS(name),
+       TP_STRUCT__entry(__string_from_user(name, name)),
+       TP_fast_assign(tp_copy_string_from_user(name, name)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_64_sys_olduname
+SC_TRACE_EVENT(sys_olduname,
+       TP_PROTO(struct oldold_utsname * name),
+       TP_ARGS(name),
+       TP_STRUCT__entry(__field_hex(struct oldold_utsname *, name)),
+       TP_fast_assign(tp_assign(name, name)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_64_sys_uselib
+SC_TRACE_EVENT(sys_uselib,
+       TP_PROTO(const char * library),
+       TP_ARGS(library),
+       TP_STRUCT__entry(__field_hex(const char *, library)),
+       TP_fast_assign(tp_assign(library, library)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_64_sys_uname
+SC_TRACE_EVENT(sys_uname,
+       TP_PROTO(struct old_utsname * name),
+       TP_ARGS(name),
+       TP_STRUCT__entry(__field_hex(struct old_utsname *, name)),
+       TP_fast_assign(tp_assign(name, name)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_64_sys_sysinfo
+SC_TRACE_EVENT(sys_sysinfo,
+       TP_PROTO(struct sysinfo * info),
+       TP_ARGS(info),
+       TP_STRUCT__entry(__field_hex(struct sysinfo *, info)),
+       TP_fast_assign(tp_assign(info, info)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_64_sys_times
+SC_TRACE_EVENT(sys_times,
+       TP_PROTO(struct tms * tbuf),
+       TP_ARGS(tbuf),
+       TP_STRUCT__entry(__field_hex(struct tms *, tbuf)),
+       TP_fast_assign(tp_assign(tbuf, tbuf)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_64_sys_sysctl
+SC_TRACE_EVENT(sys_sysctl,
+       TP_PROTO(struct __sysctl_args * args),
+       TP_ARGS(args),
+       TP_STRUCT__entry(__field_hex(struct __sysctl_args *, args)),
+       TP_fast_assign(tp_assign(args, args)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_64_sys_adjtimex
+SC_TRACE_EVENT(sys_adjtimex,
+       TP_PROTO(struct timex * txc_p),
+       TP_ARGS(txc_p),
+       TP_STRUCT__entry(__field_hex(struct timex *, txc_p)),
+       TP_fast_assign(tp_assign(txc_p, txc_p)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_64_sys_newuname
+SC_TRACE_EVENT(sys_newuname,
+       TP_PROTO(struct new_utsname * name),
+       TP_ARGS(name),
+       TP_STRUCT__entry(__field_hex(struct new_utsname *, name)),
+       TP_fast_assign(tp_assign(name, name)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_64_sys_shmdt
+SC_TRACE_EVENT(sys_shmdt,
+       TP_PROTO(char * shmaddr),
+       TP_ARGS(shmaddr),
+       TP_STRUCT__entry(__field_hex(char *, shmaddr)),
+       TP_fast_assign(tp_assign(shmaddr, shmaddr)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_64_sys_chdir
+SC_TRACE_EVENT(sys_chdir,
+       TP_PROTO(const char * filename),
+       TP_ARGS(filename),
+       TP_STRUCT__entry(__string_from_user(filename, filename)),
+       TP_fast_assign(tp_copy_string_from_user(filename, filename)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_64_sys_rmdir
+SC_TRACE_EVENT(sys_rmdir,
+       TP_PROTO(const char * pathname),
+       TP_ARGS(pathname),
+       TP_STRUCT__entry(__string_from_user(pathname, pathname)),
+       TP_fast_assign(tp_copy_string_from_user(pathname, pathname)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_64_sys_unlink
+SC_TRACE_EVENT(sys_unlink,
+       TP_PROTO(const char * pathname),
+       TP_ARGS(pathname),
+       TP_STRUCT__entry(__string_from_user(pathname, pathname)),
+       TP_fast_assign(tp_copy_string_from_user(pathname, pathname)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_64_sys_chroot
+SC_TRACE_EVENT(sys_chroot,
+       TP_PROTO(const char * filename),
+       TP_ARGS(filename),
+       TP_STRUCT__entry(__string_from_user(filename, filename)),
+       TP_fast_assign(tp_copy_string_from_user(filename, filename)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_64_sys_swapoff
+SC_TRACE_EVENT(sys_swapoff,
+       TP_PROTO(const char * specialfile),
+       TP_ARGS(specialfile),
+       TP_STRUCT__entry(__string_from_user(specialfile, specialfile)),
+       TP_fast_assign(tp_copy_string_from_user(specialfile, specialfile)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_64_sys_set_tid_address
+SC_TRACE_EVENT(sys_set_tid_address,
+       TP_PROTO(int * tidptr),
+       TP_ARGS(tidptr),
+       TP_STRUCT__entry(__field_hex(int *, tidptr)),
+       TP_fast_assign(tp_assign(tidptr, tidptr)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_64_sys_nanosleep
+SC_TRACE_EVENT(sys_nanosleep,
+       TP_PROTO(struct timespec * rqtp, struct timespec * rmtp),
+       TP_ARGS(rqtp, rmtp),
+       TP_STRUCT__entry(__field_hex(struct timespec *, rqtp) __field_hex(struct timespec *, rmtp)),
+       TP_fast_assign(tp_assign(rqtp, rqtp) tp_assign(rmtp, rmtp)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_64_sys_getitimer
+SC_TRACE_EVENT(sys_getitimer,
+       TP_PROTO(int which, struct itimerval * value),
+       TP_ARGS(which, value),
+       TP_STRUCT__entry(__field(int, which) __field_hex(struct itimerval *, value)),
+       TP_fast_assign(tp_assign(which, which) tp_assign(value, value)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_64_sys_gettimeofday
+SC_TRACE_EVENT(sys_gettimeofday,
+       TP_PROTO(struct timeval * tv, struct timezone * tz),
+       TP_ARGS(tv, tz),
+       TP_STRUCT__entry(__field_hex(struct timeval *, tv) __field_hex(struct timezone *, tz)),
+       TP_fast_assign(tp_assign(tv, tv) tp_assign(tz, tz)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_64_sys_getrlimit
+SC_TRACE_EVENT(sys_getrlimit,
+       TP_PROTO(unsigned int resource, struct rlimit * rlim),
+       TP_ARGS(resource, rlim),
+       TP_STRUCT__entry(__field(unsigned int, resource) __field_hex(struct rlimit *, rlim)),
+       TP_fast_assign(tp_assign(resource, resource) tp_assign(rlim, rlim)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_64_sys_getrusage
+SC_TRACE_EVENT(sys_getrusage,
+       TP_PROTO(int who, struct rusage * ru),
+       TP_ARGS(who, ru),
+       TP_STRUCT__entry(__field(int, who) __field_hex(struct rusage *, ru)),
+       TP_fast_assign(tp_assign(who, who) tp_assign(ru, ru)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_64_sys_rt_sigpending
+SC_TRACE_EVENT(sys_rt_sigpending,
+       TP_PROTO(sigset_t * set, size_t sigsetsize),
+       TP_ARGS(set, sigsetsize),
+       TP_STRUCT__entry(__field_hex(sigset_t *, set) __field(size_t, sigsetsize)),
+       TP_fast_assign(tp_assign(set, set) tp_assign(sigsetsize, sigsetsize)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_64_sys_utime
+SC_TRACE_EVENT(sys_utime,
+       TP_PROTO(char * filename, struct utimbuf * times),
+       TP_ARGS(filename, times),
+       TP_STRUCT__entry(__string_from_user(filename, filename) __field_hex(struct utimbuf *, times)),
+       TP_fast_assign(tp_copy_string_from_user(filename, filename) tp_assign(times, times)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_64_sys_ustat
+SC_TRACE_EVENT(sys_ustat,
+       TP_PROTO(unsigned dev, struct ustat * ubuf),
+       TP_ARGS(dev, ubuf),
+       TP_STRUCT__entry(__field(unsigned, dev) __field_hex(struct ustat *, ubuf)),
+       TP_fast_assign(tp_assign(dev, dev) tp_assign(ubuf, ubuf)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_64_sys_statfs
+SC_TRACE_EVENT(sys_statfs,
+       TP_PROTO(const char * pathname, struct statfs * buf),
+       TP_ARGS(pathname, buf),
+       TP_STRUCT__entry(__string_from_user(pathname, pathname) __field_hex(struct statfs *, buf)),
+       TP_fast_assign(tp_copy_string_from_user(pathname, pathname) tp_assign(buf, buf)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_64_sys_fstatfs
+SC_TRACE_EVENT(sys_fstatfs,
+       TP_PROTO(unsigned int fd, struct statfs * buf),
+       TP_ARGS(fd, buf),
+       TP_STRUCT__entry(__field(unsigned int, fd) __field_hex(struct statfs *, buf)),
+       TP_fast_assign(tp_assign(fd, fd) tp_assign(buf, buf)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_64_sys_sched_rr_get_interval
+SC_TRACE_EVENT(sys_sched_rr_get_interval,
+       TP_PROTO(pid_t pid, struct timespec * interval),
+       TP_ARGS(pid, interval),
+       TP_STRUCT__entry(__field(pid_t, pid) __field_hex(struct timespec *, interval)),
+       TP_fast_assign(tp_assign(pid, pid) tp_assign(interval, interval)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_64_sys_setrlimit
+SC_TRACE_EVENT(sys_setrlimit,
+       TP_PROTO(unsigned int resource, struct rlimit * rlim),
+       TP_ARGS(resource, rlim),
+       TP_STRUCT__entry(__field(unsigned int, resource) __field_hex(struct rlimit *, rlim)),
+       TP_fast_assign(tp_assign(resource, resource) tp_assign(rlim, rlim)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_64_sys_settimeofday
+SC_TRACE_EVENT(sys_settimeofday,
+       TP_PROTO(struct timeval * tv, struct timezone * tz),
+       TP_ARGS(tv, tz),
+       TP_STRUCT__entry(__field_hex(struct timeval *, tv) __field_hex(struct timezone *, tz)),
+       TP_fast_assign(tp_assign(tv, tv) tp_assign(tz, tz)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_64_sys_io_setup
+SC_TRACE_EVENT(sys_io_setup,
+       TP_PROTO(unsigned nr_events, aio_context_t * ctxp),
+       TP_ARGS(nr_events, ctxp),
+       TP_STRUCT__entry(__field(unsigned, nr_events) __field_hex(aio_context_t *, ctxp)),
+       TP_fast_assign(tp_assign(nr_events, nr_events) tp_assign(ctxp, ctxp)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_64_sys_timer_gettime
+SC_TRACE_EVENT(sys_timer_gettime,
+       TP_PROTO(timer_t timer_id, struct itimerspec * setting),
+       TP_ARGS(timer_id, setting),
+       TP_STRUCT__entry(__field(timer_t, timer_id) __field_hex(struct itimerspec *, setting)),
+       TP_fast_assign(tp_assign(timer_id, timer_id) tp_assign(setting, setting)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_64_sys_clock_settime
+SC_TRACE_EVENT(sys_clock_settime,
+       TP_PROTO(const clockid_t which_clock, const struct timespec * tp),
+       TP_ARGS(which_clock, tp),
+       TP_STRUCT__entry(__field(const clockid_t, which_clock) __field_hex(const struct timespec *, tp)),
+       TP_fast_assign(tp_assign(which_clock, which_clock) tp_assign(tp, tp)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_64_sys_clock_gettime
+SC_TRACE_EVENT(sys_clock_gettime,
+       TP_PROTO(const clockid_t which_clock, struct timespec * tp),
+       TP_ARGS(which_clock, tp),
+       TP_STRUCT__entry(__field(const clockid_t, which_clock) __field_hex(struct timespec *, tp)),
+       TP_fast_assign(tp_assign(which_clock, which_clock) tp_assign(tp, tp)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_64_sys_clock_getres
+SC_TRACE_EVENT(sys_clock_getres,
+       TP_PROTO(const clockid_t which_clock, struct timespec * tp),
+       TP_ARGS(which_clock, tp),
+       TP_STRUCT__entry(__field(const clockid_t, which_clock) __field_hex(struct timespec *, tp)),
+       TP_fast_assign(tp_assign(which_clock, which_clock) tp_assign(tp, tp)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_64_sys_utimes
+SC_TRACE_EVENT(sys_utimes,
+       TP_PROTO(char * filename, struct timeval * utimes),
+       TP_ARGS(filename, utimes),
+       TP_STRUCT__entry(__string_from_user(filename, filename) __field_hex(struct timeval *, utimes)),
+       TP_fast_assign(tp_copy_string_from_user(filename, filename) tp_assign(utimes, utimes)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_64_sys_set_robust_list
+SC_TRACE_EVENT(sys_set_robust_list,
+       TP_PROTO(struct robust_list_head * head, size_t len),
+       TP_ARGS(head, len),
+       TP_STRUCT__entry(__field_hex(struct robust_list_head *, head) __field(size_t, len)),
+       TP_fast_assign(tp_assign(head, head) tp_assign(len, len)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_64_sys_timerfd_gettime
+SC_TRACE_EVENT(sys_timerfd_gettime,
+       TP_PROTO(int ufd, struct itimerspec * otmr),
+       TP_ARGS(ufd, otmr),
+       TP_STRUCT__entry(__field(int, ufd) __field_hex(struct itimerspec *, otmr)),
+       TP_fast_assign(tp_assign(ufd, ufd) tp_assign(otmr, otmr)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_64_sys_clock_adjtime
+SC_TRACE_EVENT(sys_clock_adjtime,
+       TP_PROTO(const clockid_t which_clock, struct timex * utx),
+       TP_ARGS(which_clock, utx),
+       TP_STRUCT__entry(__field(const clockid_t, which_clock) __field_hex(struct timex *, utx)),
+       TP_fast_assign(tp_assign(which_clock, which_clock) tp_assign(utx, utx)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_64_sys_newstat
+SC_TRACE_EVENT(sys_newstat,
+       TP_PROTO(const char * filename, struct stat * statbuf),
+       TP_ARGS(filename, statbuf),
+       TP_STRUCT__entry(__string_from_user(filename, filename) __field_hex(struct stat *, statbuf)),
+       TP_fast_assign(tp_copy_string_from_user(filename, filename) tp_assign(statbuf, statbuf)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_64_sys_newfstat
+SC_TRACE_EVENT(sys_newfstat,
+       TP_PROTO(unsigned int fd, struct stat * statbuf),
+       TP_ARGS(fd, statbuf),
+       TP_STRUCT__entry(__field(unsigned int, fd) __field_hex(struct stat *, statbuf)),
+       TP_fast_assign(tp_assign(fd, fd) tp_assign(statbuf, statbuf)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_64_sys_newlstat
+SC_TRACE_EVENT(sys_newlstat,
+       TP_PROTO(const char * filename, struct stat * statbuf),
+       TP_ARGS(filename, statbuf),
+       TP_STRUCT__entry(__string_from_user(filename, filename) __field_hex(struct stat *, statbuf)),
+       TP_fast_assign(tp_copy_string_from_user(filename, filename) tp_assign(statbuf, statbuf)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_64_sys_access
+SC_TRACE_EVENT(sys_access,
+       TP_PROTO(const char * filename, int mode),
+       TP_ARGS(filename, mode),
+       TP_STRUCT__entry(__string_from_user(filename, filename) __field(int, mode)),
+       TP_fast_assign(tp_copy_string_from_user(filename, filename) tp_assign(mode, mode)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_64_sys_truncate
+SC_TRACE_EVENT(sys_truncate,
+       TP_PROTO(const char * path, long length),
+       TP_ARGS(path, length),
+       TP_STRUCT__entry(__string_from_user(path, path) __field(long, length)),
+       TP_fast_assign(tp_copy_string_from_user(path, path) tp_assign(length, length)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_64_sys_getcwd
+SC_TRACE_EVENT(sys_getcwd,
+       TP_PROTO(char * buf, unsigned long size),
+       TP_ARGS(buf, size),
+       TP_STRUCT__entry(__field_hex(char *, buf) __field(unsigned long, size)),
+       TP_fast_assign(tp_assign(buf, buf) tp_assign(size, size)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_64_sys_rename
+SC_TRACE_EVENT(sys_rename,
+       TP_PROTO(const char * oldname, const char * newname),
+       TP_ARGS(oldname, newname),
+       TP_STRUCT__entry(__string_from_user(oldname, oldname) __string_from_user(newname, newname)),
+       TP_fast_assign(tp_copy_string_from_user(oldname, oldname) tp_copy_string_from_user(newname, newname)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_64_sys_mkdir
+SC_TRACE_EVENT(sys_mkdir,
+       TP_PROTO(const char * pathname, umode_t mode),
+       TP_ARGS(pathname, mode),
+       TP_STRUCT__entry(__string_from_user(pathname, pathname) __field(umode_t, mode)),
+       TP_fast_assign(tp_copy_string_from_user(pathname, pathname) tp_assign(mode, mode)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_64_sys_creat
+SC_TRACE_EVENT(sys_creat,
+       TP_PROTO(const char * pathname, umode_t mode),
+       TP_ARGS(pathname, mode),
+       TP_STRUCT__entry(__string_from_user(pathname, pathname) __field(umode_t, mode)),
+       TP_fast_assign(tp_copy_string_from_user(pathname, pathname) tp_assign(mode, mode)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_64_sys_link
+SC_TRACE_EVENT(sys_link,
+       TP_PROTO(const char * oldname, const char * newname),
+       TP_ARGS(oldname, newname),
+       TP_STRUCT__entry(__string_from_user(oldname, oldname) __string_from_user(newname, newname)),
+       TP_fast_assign(tp_copy_string_from_user(oldname, oldname) tp_copy_string_from_user(newname, newname)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_64_sys_symlink
+SC_TRACE_EVENT(sys_symlink,
+       TP_PROTO(const char * oldname, const char * newname),
+       TP_ARGS(oldname, newname),
+       TP_STRUCT__entry(__string_from_user(oldname, oldname) __string_from_user(newname, newname)),
+       TP_fast_assign(tp_copy_string_from_user(oldname, oldname) tp_copy_string_from_user(newname, newname)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_64_sys_chmod
+SC_TRACE_EVENT(sys_chmod,
+       TP_PROTO(const char * filename, umode_t mode),
+       TP_ARGS(filename, mode),
+       TP_STRUCT__entry(__string_from_user(filename, filename) __field(umode_t, mode)),
+       TP_fast_assign(tp_copy_string_from_user(filename, filename) tp_assign(mode, mode)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_64_sys_getgroups
+SC_TRACE_EVENT(sys_getgroups,
+       TP_PROTO(int gidsetsize, gid_t * grouplist),
+       TP_ARGS(gidsetsize, grouplist),
+       TP_STRUCT__entry(__field(int, gidsetsize) __field_hex(gid_t *, grouplist)),
+       TP_fast_assign(tp_assign(gidsetsize, gidsetsize) tp_assign(grouplist, grouplist)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_64_sys_setgroups
+SC_TRACE_EVENT(sys_setgroups,
+       TP_PROTO(int gidsetsize, gid_t * grouplist),
+       TP_ARGS(gidsetsize, grouplist),
+       TP_STRUCT__entry(__field(int, gidsetsize) __field_hex(gid_t *, grouplist)),
+       TP_fast_assign(tp_assign(gidsetsize, gidsetsize) tp_assign(grouplist, grouplist)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_64_sys_32_rt_sigpending
+SC_TRACE_EVENT(sys_32_rt_sigpending,
+       TP_PROTO(compat_sigset_t * uset, unsigned int sigsetsize),
+       TP_ARGS(uset, sigsetsize),
+       TP_STRUCT__entry(__field_hex(compat_sigset_t *, uset) __field(unsigned int, sigsetsize)),
+       TP_fast_assign(tp_assign(uset, uset) tp_assign(sigsetsize, sigsetsize)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_64_sys_sched_setparam
+SC_TRACE_EVENT(sys_sched_setparam,
+       TP_PROTO(pid_t pid, struct sched_param * param),
+       TP_ARGS(pid, param),
+       TP_STRUCT__entry(__field(pid_t, pid) __field_hex(struct sched_param *, param)),
+       TP_fast_assign(tp_assign(pid, pid) tp_assign(param, param)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_64_sys_sched_getparam
+SC_TRACE_EVENT(sys_sched_getparam,
+       TP_PROTO(pid_t pid, struct sched_param * param),
+       TP_ARGS(pid, param),
+       TP_STRUCT__entry(__field(pid_t, pid) __field_hex(struct sched_param *, param)),
+       TP_fast_assign(tp_assign(pid, pid) tp_assign(param, param)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_64_sys_32_sched_rr_get_interval
+SC_TRACE_EVENT(sys_32_sched_rr_get_interval,
+       TP_PROTO(compat_pid_t pid, struct compat_timespec * interval),
+       TP_ARGS(pid, interval),
+       TP_STRUCT__entry(__field(compat_pid_t, pid) __field_hex(struct compat_timespec *, interval)),
+       TP_fast_assign(tp_assign(pid, pid) tp_assign(interval, interval)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_64_sys_pivot_root
+SC_TRACE_EVENT(sys_pivot_root,
+       TP_PROTO(const char * new_root, const char * put_old),
+       TP_ARGS(new_root, put_old),
+       TP_STRUCT__entry(__string_from_user(new_root, new_root) __string_from_user(put_old, put_old)),
+       TP_fast_assign(tp_copy_string_from_user(new_root, new_root) tp_copy_string_from_user(put_old, put_old)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_64_sys_umount
+SC_TRACE_EVENT(sys_umount,
+       TP_PROTO(char * name, int flags),
+       TP_ARGS(name, flags),
+       TP_STRUCT__entry(__string_from_user(name, name) __field(int, flags)),
+       TP_fast_assign(tp_copy_string_from_user(name, name) tp_assign(flags, flags)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_64_sys_swapon
+SC_TRACE_EVENT(sys_swapon,
+       TP_PROTO(const char * specialfile, int swap_flags),
+       TP_ARGS(specialfile, swap_flags),
+       TP_STRUCT__entry(__string_from_user(specialfile, specialfile) __field(int, swap_flags)),
+       TP_fast_assign(tp_copy_string_from_user(specialfile, specialfile) tp_assign(swap_flags, swap_flags)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_64_sys_sethostname
+SC_TRACE_EVENT(sys_sethostname,
+       TP_PROTO(char * name, int len),
+       TP_ARGS(name, len),
+       TP_STRUCT__entry(__string_from_user(name, name) __field(int, len)),
+       TP_fast_assign(tp_copy_string_from_user(name, name) tp_assign(len, len)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_64_sys_setdomainname
+SC_TRACE_EVENT(sys_setdomainname,
+       TP_PROTO(char * name, int len),
+       TP_ARGS(name, len),
+       TP_STRUCT__entry(__string_from_user(name, name) __field(int, len)),
+       TP_fast_assign(tp_copy_string_from_user(name, name) tp_assign(len, len)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_64_sys_delete_module
+SC_TRACE_EVENT(sys_delete_module,
+       TP_PROTO(const char * name_user, unsigned int flags),
+       TP_ARGS(name_user, flags),
+       TP_STRUCT__entry(__string_from_user(name_user, name_user) __field(unsigned int, flags)),
+       TP_fast_assign(tp_copy_string_from_user(name_user, name_user) tp_assign(flags, flags)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_64_sys_removexattr
+SC_TRACE_EVENT(sys_removexattr,
+       TP_PROTO(const char * pathname, const char * name),
+       TP_ARGS(pathname, name),
+       TP_STRUCT__entry(__string_from_user(pathname, pathname) __string_from_user(name, name)),
+       TP_fast_assign(tp_copy_string_from_user(pathname, pathname) tp_copy_string_from_user(name, name)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_64_sys_lremovexattr
+SC_TRACE_EVENT(sys_lremovexattr,
+       TP_PROTO(const char * pathname, const char * name),
+       TP_ARGS(pathname, name),
+       TP_STRUCT__entry(__string_from_user(pathname, pathname) __string_from_user(name, name)),
+       TP_fast_assign(tp_copy_string_from_user(pathname, pathname) tp_copy_string_from_user(name, name)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_64_sys_fremovexattr
+SC_TRACE_EVENT(sys_fremovexattr,
+       TP_PROTO(int fd, const char * name),
+       TP_ARGS(fd, name),
+       TP_STRUCT__entry(__field(int, fd) __string_from_user(name, name)),
+       TP_fast_assign(tp_assign(fd, fd) tp_copy_string_from_user(name, name)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_64_sys_pipe2
+SC_TRACE_EVENT(sys_pipe2,
+       TP_PROTO(int * fildes, int flags),
+       TP_ARGS(fildes, flags),
+       TP_STRUCT__entry(__field_hex(int *, fildes) __field(int, flags)),
+       TP_fast_assign(tp_assign(fildes, fildes) tp_assign(flags, flags)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_64_sys_waitpid
+SC_TRACE_EVENT(sys_waitpid,
+       TP_PROTO(pid_t pid, int * stat_addr, int options),
+       TP_ARGS(pid, stat_addr, options),
+       TP_STRUCT__entry(__field(pid_t, pid) __field_hex(int *, stat_addr) __field(int, options)),
+       TP_fast_assign(tp_assign(pid, pid) tp_assign(stat_addr, stat_addr) tp_assign(options, options)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_64_sys_32_sigaction
+SC_TRACE_EVENT(sys_32_sigaction,
+       TP_PROTO(long sig, const struct sigaction32 * act, struct sigaction32 * oact),
+       TP_ARGS(sig, act, oact),
+       TP_STRUCT__entry(__field(long, sig) __field_hex(const struct sigaction32 *, act) __field_hex(struct sigaction32 *, oact)),
+       TP_fast_assign(tp_assign(sig, sig) tp_assign(act, act) tp_assign(oact, oact)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_64_sys_readv
+SC_TRACE_EVENT(sys_readv,
+       TP_PROTO(unsigned long fd, const struct iovec * vec, unsigned long vlen),
+       TP_ARGS(fd, vec, vlen),
+       TP_STRUCT__entry(__field(unsigned long, fd) __field_hex(const struct iovec *, vec) __field(unsigned long, vlen)),
+       TP_fast_assign(tp_assign(fd, fd) tp_assign(vec, vec) tp_assign(vlen, vlen)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_64_sys_writev
+SC_TRACE_EVENT(sys_writev,
+       TP_PROTO(unsigned long fd, const struct iovec * vec, unsigned long vlen),
+       TP_ARGS(fd, vec, vlen),
+       TP_STRUCT__entry(__field(unsigned long, fd) __field_hex(const struct iovec *, vec) __field(unsigned long, vlen)),
+       TP_fast_assign(tp_assign(fd, fd) tp_assign(vec, vec) tp_assign(vlen, vlen)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_64_sys_shmctl
+SC_TRACE_EVENT(sys_shmctl,
+       TP_PROTO(int shmid, int cmd, struct shmid_ds * buf),
+       TP_ARGS(shmid, cmd, buf),
+       TP_STRUCT__entry(__field(int, shmid) __field(int, cmd) __field_hex(struct shmid_ds *, buf)),
+       TP_fast_assign(tp_assign(shmid, shmid) tp_assign(cmd, cmd) tp_assign(buf, buf)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_64_sys_setitimer
+SC_TRACE_EVENT(sys_setitimer,
+       TP_PROTO(int which, struct itimerval * value, struct itimerval * ovalue),
+       TP_ARGS(which, value, ovalue),
+       TP_STRUCT__entry(__field(int, which) __field_hex(struct itimerval *, value) __field_hex(struct itimerval *, ovalue)),
+       TP_fast_assign(tp_assign(which, which) tp_assign(value, value) tp_assign(ovalue, ovalue)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_64_sys_sendmsg
+SC_TRACE_EVENT(sys_sendmsg,
+       TP_PROTO(int fd, struct msghdr * msg, unsigned int flags),
+       TP_ARGS(fd, msg, flags),
+       TP_STRUCT__entry(__field(int, fd) __field_hex(struct msghdr *, msg) __field(unsigned int, flags)),
+       TP_fast_assign(tp_assign(fd, fd) tp_assign(msg, msg) tp_assign(flags, flags)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_64_sys_recvmsg
+SC_TRACE_EVENT(sys_recvmsg,
+       TP_PROTO(int fd, struct msghdr * msg, unsigned int flags),
+       TP_ARGS(fd, msg, flags),
+       TP_STRUCT__entry(__field(int, fd) __field_hex(struct msghdr *, msg) __field(unsigned int, flags)),
+       TP_fast_assign(tp_assign(fd, fd) tp_assign(msg, msg) tp_assign(flags, flags)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_64_sys_msgctl
+SC_TRACE_EVENT(sys_msgctl,
+       TP_PROTO(int msqid, int cmd, struct msqid_ds * buf),
+       TP_ARGS(msqid, cmd, buf),
+       TP_STRUCT__entry(__field(int, msqid) __field(int, cmd) __field_hex(struct msqid_ds *, buf)),
+       TP_fast_assign(tp_assign(msqid, msqid) tp_assign(cmd, cmd) tp_assign(buf, buf)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_64_sys_getdents
+SC_TRACE_EVENT(sys_getdents,
+       TP_PROTO(unsigned int fd, struct linux_dirent * dirent, unsigned int count),
+       TP_ARGS(fd, dirent, count),
+       TP_STRUCT__entry(__field(unsigned int, fd) __field_hex(struct linux_dirent *, dirent) __field(unsigned int, count)),
+       TP_fast_assign(tp_assign(fd, fd) tp_assign(dirent, dirent) tp_assign(count, count)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_64_sys_rt_sigqueueinfo
+SC_TRACE_EVENT(sys_rt_sigqueueinfo,
+       TP_PROTO(pid_t pid, int sig, siginfo_t * uinfo),
+       TP_ARGS(pid, sig, uinfo),
+       TP_STRUCT__entry(__field(pid_t, pid) __field(int, sig) __field_hex(siginfo_t *, uinfo)),
+       TP_fast_assign(tp_assign(pid, pid) tp_assign(sig, sig) tp_assign(uinfo, uinfo)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_64_sys_sched_setaffinity
+SC_TRACE_EVENT(sys_sched_setaffinity,
+       TP_PROTO(pid_t pid, unsigned int len, unsigned long * user_mask_ptr),
+       TP_ARGS(pid, len, user_mask_ptr),
+       TP_STRUCT__entry(__field(pid_t, pid) __field(unsigned int, len) __field_hex(unsigned long *, user_mask_ptr)),
+       TP_fast_assign(tp_assign(pid, pid) tp_assign(len, len) tp_assign(user_mask_ptr, user_mask_ptr)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_64_sys_sched_getaffinity
+SC_TRACE_EVENT(sys_sched_getaffinity,
+       TP_PROTO(pid_t pid, unsigned int len, unsigned long * user_mask_ptr),
+       TP_ARGS(pid, len, user_mask_ptr),
+       TP_STRUCT__entry(__field(pid_t, pid) __field(unsigned int, len) __field_hex(unsigned long *, user_mask_ptr)),
+       TP_fast_assign(tp_assign(pid, pid) tp_assign(len, len) tp_assign(user_mask_ptr, user_mask_ptr)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_64_sys_io_submit
+SC_TRACE_EVENT(sys_io_submit,
+       TP_PROTO(aio_context_t ctx_id, long nr, struct iocb * * iocbpp),
+       TP_ARGS(ctx_id, nr, iocbpp),
+       TP_STRUCT__entry(__field(aio_context_t, ctx_id) __field(long, nr) __field_hex(struct iocb * *, iocbpp)),
+       TP_fast_assign(tp_assign(ctx_id, ctx_id) tp_assign(nr, nr) tp_assign(iocbpp, iocbpp)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_64_sys_timer_create
+SC_TRACE_EVENT(sys_timer_create,
+       TP_PROTO(const clockid_t which_clock, struct sigevent * timer_event_spec, timer_t * created_timer_id),
+       TP_ARGS(which_clock, timer_event_spec, created_timer_id),
+       TP_STRUCT__entry(__field(const clockid_t, which_clock) __field_hex(struct sigevent *, timer_event_spec) __field_hex(timer_t *, created_timer_id)),
+       TP_fast_assign(tp_assign(which_clock, which_clock) tp_assign(timer_event_spec, timer_event_spec) tp_assign(created_timer_id, created_timer_id)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_64_sys_futimesat
+SC_TRACE_EVENT(sys_futimesat,
+       TP_PROTO(int dfd, const char * filename, struct timeval * utimes),
+       TP_ARGS(dfd, filename, utimes),
+       TP_STRUCT__entry(__field(int, dfd) __string_from_user(filename, filename) __field_hex(struct timeval *, utimes)),
+       TP_fast_assign(tp_assign(dfd, dfd) tp_copy_string_from_user(filename, filename) tp_assign(utimes, utimes)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_64_sys_get_robust_list
+SC_TRACE_EVENT(sys_get_robust_list,
+       TP_PROTO(int pid, struct robust_list_head * * head_ptr, size_t * len_ptr),
+       TP_ARGS(pid, head_ptr, len_ptr),
+       TP_STRUCT__entry(__field(int, pid) __field_hex(struct robust_list_head * *, head_ptr) __field_hex(size_t *, len_ptr)),
+       TP_fast_assign(tp_assign(pid, pid) tp_assign(head_ptr, head_ptr) tp_assign(len_ptr, len_ptr)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_64_sys_signalfd
+SC_TRACE_EVENT(sys_signalfd,
+       TP_PROTO(int ufd, sigset_t * user_mask, size_t sizemask),
+       TP_ARGS(ufd, user_mask, sizemask),
+       TP_STRUCT__entry(__field(int, ufd) __field_hex(sigset_t *, user_mask) __field(size_t, sizemask)),
+       TP_fast_assign(tp_assign(ufd, ufd) tp_assign(user_mask, user_mask) tp_assign(sizemask, sizemask)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_64_sys_read
+SC_TRACE_EVENT(sys_read,
+       TP_PROTO(unsigned int fd, char * buf, size_t count),
+       TP_ARGS(fd, buf, count),
+       TP_STRUCT__entry(__field(unsigned int, fd) __field_hex(char *, buf) __field(size_t, count)),
+       TP_fast_assign(tp_assign(fd, fd) tp_assign(buf, buf) tp_assign(count, count)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_64_sys_write
+SC_TRACE_EVENT(sys_write,
+       TP_PROTO(unsigned int fd, const char * buf, size_t count),
+       TP_ARGS(fd, buf, count),
+       TP_STRUCT__entry(__field(unsigned int, fd) __field_hex(const char *, buf) __field(size_t, count)),
+       TP_fast_assign(tp_assign(fd, fd) tp_assign(buf, buf) tp_assign(count, count)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_64_sys_open
+SC_TRACE_EVENT(sys_open,
+       TP_PROTO(const char * filename, int flags, umode_t mode),
+       TP_ARGS(filename, flags, mode),
+       TP_STRUCT__entry(__string_from_user(filename, filename) __field(int, flags) __field(umode_t, mode)),
+       TP_fast_assign(tp_copy_string_from_user(filename, filename) tp_assign(flags, flags) tp_assign(mode, mode)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_64_sys_poll
+SC_TRACE_EVENT(sys_poll,
+       TP_PROTO(struct pollfd * ufds, unsigned int nfds, int timeout_msecs),
+       TP_ARGS(ufds, nfds, timeout_msecs),
+       TP_STRUCT__entry(__field_hex(struct pollfd *, ufds) __field(unsigned int, nfds) __field(int, timeout_msecs)),
+       TP_fast_assign(tp_assign(ufds, ufds) tp_assign(nfds, nfds) tp_assign(timeout_msecs, timeout_msecs)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_64_sys_mincore
+SC_TRACE_EVENT(sys_mincore,
+       TP_PROTO(unsigned long start, size_t len, unsigned char * vec),
+       TP_ARGS(start, len, vec),
+       TP_STRUCT__entry(__field(unsigned long, start) __field(size_t, len) __field_hex(unsigned char *, vec)),
+       TP_fast_assign(tp_assign(start, start) tp_assign(len, len) tp_assign(vec, vec)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_64_sys_shmat
+SC_TRACE_EVENT(sys_shmat,
+       TP_PROTO(int shmid, char * shmaddr, int shmflg),
+       TP_ARGS(shmid, shmaddr, shmflg),
+       TP_STRUCT__entry(__field(int, shmid) __field_hex(char *, shmaddr) __field(int, shmflg)),
+       TP_fast_assign(tp_assign(shmid, shmid) tp_assign(shmaddr, shmaddr) tp_assign(shmflg, shmflg)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_64_sys_connect
+SC_TRACE_EVENT(sys_connect,
+       TP_PROTO(int fd, struct sockaddr * uservaddr, int addrlen),
+       TP_ARGS(fd, uservaddr, addrlen),
+       TP_STRUCT__entry(__field(int, fd) __field_hex(struct sockaddr *, uservaddr) __field_hex(int, addrlen)),
+       TP_fast_assign(tp_assign(fd, fd) tp_assign(uservaddr, uservaddr) tp_assign(addrlen, addrlen)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_64_sys_accept
+SC_TRACE_EVENT(sys_accept,
+       TP_PROTO(int fd, struct sockaddr * upeer_sockaddr, int * upeer_addrlen),
+       TP_ARGS(fd, upeer_sockaddr, upeer_addrlen),
+       TP_STRUCT__entry(__field(int, fd) __field_hex(struct sockaddr *, upeer_sockaddr) __field_hex(int *, upeer_addrlen)),
+       TP_fast_assign(tp_assign(fd, fd) tp_assign(upeer_sockaddr, upeer_sockaddr) tp_assign(upeer_addrlen, upeer_addrlen)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_64_sys_bind
+SC_TRACE_EVENT(sys_bind,
+       TP_PROTO(int fd, struct sockaddr * umyaddr, int addrlen),
+       TP_ARGS(fd, umyaddr, addrlen),
+       TP_STRUCT__entry(__field(int, fd) __field_hex(struct sockaddr *, umyaddr) __field_hex(int, addrlen)),
+       TP_fast_assign(tp_assign(fd, fd) tp_assign(umyaddr, umyaddr) tp_assign(addrlen, addrlen)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_64_sys_getsockname
+SC_TRACE_EVENT(sys_getsockname,
+       TP_PROTO(int fd, struct sockaddr * usockaddr, int * usockaddr_len),
+       TP_ARGS(fd, usockaddr, usockaddr_len),
+       TP_STRUCT__entry(__field(int, fd) __field_hex(struct sockaddr *, usockaddr) __field_hex(int *, usockaddr_len)),
+       TP_fast_assign(tp_assign(fd, fd) tp_assign(usockaddr, usockaddr) tp_assign(usockaddr_len, usockaddr_len)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_64_sys_getpeername
+SC_TRACE_EVENT(sys_getpeername,
+       TP_PROTO(int fd, struct sockaddr * usockaddr, int * usockaddr_len),
+       TP_ARGS(fd, usockaddr, usockaddr_len),
+       TP_STRUCT__entry(__field(int, fd) __field_hex(struct sockaddr *, usockaddr) __field_hex(int *, usockaddr_len)),
+       TP_fast_assign(tp_assign(fd, fd) tp_assign(usockaddr, usockaddr) tp_assign(usockaddr_len, usockaddr_len)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_64_sys_semop
+SC_TRACE_EVENT(sys_semop,
+       TP_PROTO(int semid, struct sembuf * tsops, unsigned nsops),
+       TP_ARGS(semid, tsops, nsops),
+       TP_STRUCT__entry(__field(int, semid) __field_hex(struct sembuf *, tsops) __field(unsigned, nsops)),
+       TP_fast_assign(tp_assign(semid, semid) tp_assign(tsops, tsops) tp_assign(nsops, nsops)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_64_sys_readlink
+SC_TRACE_EVENT(sys_readlink,
+       TP_PROTO(const char * path, char * buf, int bufsiz),
+       TP_ARGS(path, buf, bufsiz),
+       TP_STRUCT__entry(__string_from_user(path, path) __field_hex(char *, buf) __field(int, bufsiz)),
+       TP_fast_assign(tp_copy_string_from_user(path, path) tp_assign(buf, buf) tp_assign(bufsiz, bufsiz)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_64_sys_chown
+SC_TRACE_EVENT(sys_chown,
+       TP_PROTO(const char * filename, uid_t user, gid_t group),
+       TP_ARGS(filename, user, group),
+       TP_STRUCT__entry(__string_from_user(filename, filename) __field(uid_t, user) __field(gid_t, group)),
+       TP_fast_assign(tp_copy_string_from_user(filename, filename) tp_assign(user, user) tp_assign(group, group)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_64_sys_lchown
+SC_TRACE_EVENT(sys_lchown,
+       TP_PROTO(const char * filename, uid_t user, gid_t group),
+       TP_ARGS(filename, user, group),
+       TP_STRUCT__entry(__string_from_user(filename, filename) __field(uid_t, user) __field(gid_t, group)),
+       TP_fast_assign(tp_copy_string_from_user(filename, filename) tp_assign(user, user) tp_assign(group, group)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_64_sys_syslog
+SC_TRACE_EVENT(sys_syslog,
+       TP_PROTO(int type, char * buf, int len),
+       TP_ARGS(type, buf, len),
+       TP_STRUCT__entry(__field(int, type) __field_hex(char *, buf) __field(int, len)),
+       TP_fast_assign(tp_assign(type, type) tp_assign(buf, buf) tp_assign(len, len)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_64_sys_getresuid
+SC_TRACE_EVENT(sys_getresuid,
+       TP_PROTO(uid_t * ruidp, uid_t * euidp, uid_t * suidp),
+       TP_ARGS(ruidp, euidp, suidp),
+       TP_STRUCT__entry(__field_hex(uid_t *, ruidp) __field_hex(uid_t *, euidp) __field_hex(uid_t *, suidp)),
+       TP_fast_assign(tp_assign(ruidp, ruidp) tp_assign(euidp, euidp) tp_assign(suidp, suidp)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_64_sys_getresgid
+SC_TRACE_EVENT(sys_getresgid,
+       TP_PROTO(gid_t * rgidp, gid_t * egidp, gid_t * sgidp),
+       TP_ARGS(rgidp, egidp, sgidp),
+       TP_STRUCT__entry(__field_hex(gid_t *, rgidp) __field_hex(gid_t *, egidp) __field_hex(gid_t *, sgidp)),
+       TP_fast_assign(tp_assign(rgidp, rgidp) tp_assign(egidp, egidp) tp_assign(sgidp, sgidp)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_64_sys_32_rt_sigqueueinfo
+SC_TRACE_EVENT(sys_32_rt_sigqueueinfo,
+       TP_PROTO(int pid, int sig, compat_siginfo_t * uinfo),
+       TP_ARGS(pid, sig, uinfo),
+       TP_STRUCT__entry(__field(int, pid) __field(int, sig) __field_hex(compat_siginfo_t *, uinfo)),
+       TP_fast_assign(tp_assign(pid, pid) tp_assign(sig, sig) tp_assign(uinfo, uinfo)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_64_sys_mknod
+SC_TRACE_EVENT(sys_mknod,
+       TP_PROTO(const char * filename, umode_t mode, unsigned dev),
+       TP_ARGS(filename, mode, dev),
+       TP_STRUCT__entry(__string_from_user(filename, filename) __field(umode_t, mode) __field(unsigned, dev)),
+       TP_fast_assign(tp_copy_string_from_user(filename, filename) tp_assign(mode, mode) tp_assign(dev, dev)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_64_sys_sched_setscheduler
+SC_TRACE_EVENT(sys_sched_setscheduler,
+       TP_PROTO(pid_t pid, int policy, struct sched_param * param),
+       TP_ARGS(pid, policy, param),
+       TP_STRUCT__entry(__field(pid_t, pid) __field(int, policy) __field_hex(struct sched_param *, param)),
+       TP_fast_assign(tp_assign(pid, pid) tp_assign(policy, policy) tp_assign(param, param)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_64_sys_init_module
+SC_TRACE_EVENT(sys_init_module,
+       TP_PROTO(void * umod, unsigned long len, const char * uargs),
+       TP_ARGS(umod, len, uargs),
+       TP_STRUCT__entry(__field_hex(void *, umod) __field(unsigned long, len) __field_hex(const char *, uargs)),
+       TP_fast_assign(tp_assign(umod, umod) tp_assign(len, len) tp_assign(uargs, uargs)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_64_sys_listxattr
+SC_TRACE_EVENT(sys_listxattr,
+       TP_PROTO(const char * pathname, char * list, size_t size),
+       TP_ARGS(pathname, list, size),
+       TP_STRUCT__entry(__string_from_user(pathname, pathname) __field_hex(char *, list) __field(size_t, size)),
+       TP_fast_assign(tp_copy_string_from_user(pathname, pathname) tp_assign(list, list) tp_assign(size, size)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_64_sys_llistxattr
+SC_TRACE_EVENT(sys_llistxattr,
+       TP_PROTO(const char * pathname, char * list, size_t size),
+       TP_ARGS(pathname, list, size),
+       TP_STRUCT__entry(__string_from_user(pathname, pathname) __field_hex(char *, list) __field(size_t, size)),
+       TP_fast_assign(tp_copy_string_from_user(pathname, pathname) tp_assign(list, list) tp_assign(size, size)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_64_sys_flistxattr
+SC_TRACE_EVENT(sys_flistxattr,
+       TP_PROTO(int fd, char * list, size_t size),
+       TP_ARGS(fd, list, size),
+       TP_STRUCT__entry(__field(int, fd) __field_hex(char *, list) __field(size_t, size)),
+       TP_fast_assign(tp_assign(fd, fd) tp_assign(list, list) tp_assign(size, size)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_64_sys_cachectl
+SC_TRACE_EVENT(sys_cachectl,
+       TP_PROTO(char * addr, int nbytes, int op),
+       TP_ARGS(addr, nbytes, op),
+       TP_STRUCT__entry(__field_hex(char *, addr) __field(int, nbytes) __field(int, op)),
+       TP_fast_assign(tp_assign(addr, addr) tp_assign(nbytes, nbytes) tp_assign(op, op)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_64_sys_io_cancel
+SC_TRACE_EVENT(sys_io_cancel,
+       TP_PROTO(aio_context_t ctx_id, struct iocb * iocb, struct io_event * result),
+       TP_ARGS(ctx_id, iocb, result),
+       TP_STRUCT__entry(__field(aio_context_t, ctx_id) __field_hex(struct iocb *, iocb) __field_hex(struct io_event *, result)),
+       TP_fast_assign(tp_assign(ctx_id, ctx_id) tp_assign(iocb, iocb) tp_assign(result, result)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_64_sys_inotify_add_watch
+SC_TRACE_EVENT(sys_inotify_add_watch,
+       TP_PROTO(int fd, const char * pathname, u32 mask),
+       TP_ARGS(fd, pathname, mask),
+       TP_STRUCT__entry(__field(int, fd) __string_from_user(pathname, pathname) __field(u32, mask)),
+       TP_fast_assign(tp_assign(fd, fd) tp_copy_string_from_user(pathname, pathname) tp_assign(mask, mask)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_64_sys_mkdirat
+SC_TRACE_EVENT(sys_mkdirat,
+       TP_PROTO(int dfd, const char * pathname, umode_t mode),
+       TP_ARGS(dfd, pathname, mode),
+       TP_STRUCT__entry(__field(int, dfd) __string_from_user(pathname, pathname) __field(umode_t, mode)),
+       TP_fast_assign(tp_assign(dfd, dfd) tp_copy_string_from_user(pathname, pathname) tp_assign(mode, mode)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_64_sys_unlinkat
+SC_TRACE_EVENT(sys_unlinkat,
+       TP_PROTO(int dfd, const char * pathname, int flag),
+       TP_ARGS(dfd, pathname, flag),
+       TP_STRUCT__entry(__field(int, dfd) __string_from_user(pathname, pathname) __field(int, flag)),
+       TP_fast_assign(tp_assign(dfd, dfd) tp_copy_string_from_user(pathname, pathname) tp_assign(flag, flag)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_64_sys_symlinkat
+SC_TRACE_EVENT(sys_symlinkat,
+       TP_PROTO(const char * oldname, int newdfd, const char * newname),
+       TP_ARGS(oldname, newdfd, newname),
+       TP_STRUCT__entry(__string_from_user(oldname, oldname) __field(int, newdfd) __string_from_user(newname, newname)),
+       TP_fast_assign(tp_copy_string_from_user(oldname, oldname) tp_assign(newdfd, newdfd) tp_copy_string_from_user(newname, newname)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_64_sys_fchmodat
+SC_TRACE_EVENT(sys_fchmodat,
+       TP_PROTO(int dfd, const char * filename, umode_t mode),
+       TP_ARGS(dfd, filename, mode),
+       TP_STRUCT__entry(__field(int, dfd) __string_from_user(filename, filename) __field(umode_t, mode)),
+       TP_fast_assign(tp_assign(dfd, dfd) tp_copy_string_from_user(filename, filename) tp_assign(mode, mode)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_64_sys_faccessat
+SC_TRACE_EVENT(sys_faccessat,
+       TP_PROTO(int dfd, const char * filename, int mode),
+       TP_ARGS(dfd, filename, mode),
+       TP_STRUCT__entry(__field(int, dfd) __string_from_user(filename, filename) __field(int, mode)),
+       TP_fast_assign(tp_assign(dfd, dfd) tp_copy_string_from_user(filename, filename) tp_assign(mode, mode)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_64_sys_getcpu
+SC_TRACE_EVENT(sys_getcpu,
+       TP_PROTO(unsigned * cpup, unsigned * nodep, struct getcpu_cache * unused),
+       TP_ARGS(cpup, nodep, unused),
+       TP_STRUCT__entry(__field_hex(unsigned *, cpup) __field_hex(unsigned *, nodep) __field_hex(struct getcpu_cache *, unused)),
+       TP_fast_assign(tp_assign(cpup, cpup) tp_assign(nodep, nodep) tp_assign(unused, unused)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_64_sys_getdents64
+SC_TRACE_EVENT(sys_getdents64,
+       TP_PROTO(unsigned int fd, struct linux_dirent64 * dirent, unsigned int count),
+       TP_ARGS(fd, dirent, count),
+       TP_STRUCT__entry(__field(unsigned int, fd) __field_hex(struct linux_dirent64 *, dirent) __field(unsigned int, count)),
+       TP_fast_assign(tp_assign(fd, fd) tp_assign(dirent, dirent) tp_assign(count, count)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_64_sys_send
+SC_TRACE_EVENT(sys_send,
+       TP_PROTO(int fd, void * buff, size_t len, unsigned int flags),
+       TP_ARGS(fd, buff, len, flags),
+       TP_STRUCT__entry(__field(int, fd) __field_hex(void *, buff) __field(size_t, len) __field(unsigned int, flags)),
+       TP_fast_assign(tp_assign(fd, fd) tp_assign(buff, buff) tp_assign(len, len) tp_assign(flags, flags)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_64_sys_32_truncate64
+SC_TRACE_EVENT(sys_32_truncate64,
+       TP_PROTO(const char * path, unsigned long __dummy, unsigned long a2, unsigned long a3),
+       TP_ARGS(path, __dummy, a2, a3),
+       TP_STRUCT__entry(__string_from_user(path, path) __field(unsigned long, __dummy) __field(unsigned long, a2) __field(unsigned long, a3)),
+       TP_fast_assign(tp_copy_string_from_user(path, path) tp_assign(__dummy, __dummy) tp_assign(a2, a2) tp_assign(a3, a3)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_64_sys_rt_sigaction
+SC_TRACE_EVENT(sys_rt_sigaction,
+       TP_PROTO(int sig, const struct sigaction * act, struct sigaction * oact, size_t sigsetsize),
+       TP_ARGS(sig, act, oact, sigsetsize),
+       TP_STRUCT__entry(__field(int, sig) __field_hex(const struct sigaction *, act) __field_hex(struct sigaction *, oact) __field(size_t, sigsetsize)),
+       TP_fast_assign(tp_assign(sig, sig) tp_assign(act, act) tp_assign(oact, oact) tp_assign(sigsetsize, sigsetsize)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_64_sys_rt_sigprocmask
+SC_TRACE_EVENT(sys_rt_sigprocmask,
+       TP_PROTO(int how, sigset_t * nset, sigset_t * oset, size_t sigsetsize),
+       TP_ARGS(how, nset, oset, sigsetsize),
+       TP_STRUCT__entry(__field(int, how) __field_hex(sigset_t *, nset) __field_hex(sigset_t *, oset) __field(size_t, sigsetsize)),
+       TP_fast_assign(tp_assign(how, how) tp_assign(nset, nset) tp_assign(oset, oset) tp_assign(sigsetsize, sigsetsize)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_64_sys_wait4
+SC_TRACE_EVENT(sys_wait4,
+       TP_PROTO(pid_t upid, int * stat_addr, int options, struct rusage * ru),
+       TP_ARGS(upid, stat_addr, options, ru),
+       TP_STRUCT__entry(__field(pid_t, upid) __field_hex(int *, stat_addr) __field(int, options) __field_hex(struct rusage *, ru)),
+       TP_fast_assign(tp_assign(upid, upid) tp_assign(stat_addr, stat_addr) tp_assign(options, options) tp_assign(ru, ru)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_64_sys_msgsnd
+SC_TRACE_EVENT(sys_msgsnd,
+       TP_PROTO(int msqid, struct msgbuf * msgp, size_t msgsz, int msgflg),
+       TP_ARGS(msqid, msgp, msgsz, msgflg),
+       TP_STRUCT__entry(__field(int, msqid) __field_hex(struct msgbuf *, msgp) __field(size_t, msgsz) __field(int, msgflg)),
+       TP_fast_assign(tp_assign(msqid, msqid) tp_assign(msgp, msgp) tp_assign(msgsz, msgsz) tp_assign(msgflg, msgflg)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_64_sys_rt_sigtimedwait
+SC_TRACE_EVENT(sys_rt_sigtimedwait,
+       TP_PROTO(const sigset_t * uthese, siginfo_t * uinfo, const struct timespec * uts, size_t sigsetsize),
+       TP_ARGS(uthese, uinfo, uts, sigsetsize),
+       TP_STRUCT__entry(__field_hex(const sigset_t *, uthese) __field_hex(siginfo_t *, uinfo) __field_hex(const struct timespec *, uts) __field(size_t, sigsetsize)),
+       TP_fast_assign(tp_assign(uthese, uthese) tp_assign(uinfo, uinfo) tp_assign(uts, uts) tp_assign(sigsetsize, sigsetsize)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_64_sys_semtimedop
+SC_TRACE_EVENT(sys_semtimedop,
+       TP_PROTO(int semid, struct sembuf * tsops, unsigned nsops, const struct timespec * timeout),
+       TP_ARGS(semid, tsops, nsops, timeout),
+       TP_STRUCT__entry(__field(int, semid) __field_hex(struct sembuf *, tsops) __field(unsigned, nsops) __field_hex(const struct timespec *, timeout)),
+       TP_fast_assign(tp_assign(semid, semid) tp_assign(tsops, tsops) tp_assign(nsops, nsops) tp_assign(timeout, timeout)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_64_sys_timer_settime
+SC_TRACE_EVENT(sys_timer_settime,
+       TP_PROTO(timer_t timer_id, int flags, const struct itimerspec * new_setting, struct itimerspec * old_setting),
+       TP_ARGS(timer_id, flags, new_setting, old_setting),
+       TP_STRUCT__entry(__field(timer_t, timer_id) __field(int, flags) __field_hex(const struct itimerspec *, new_setting) __field_hex(struct itimerspec *, old_setting)),
+       TP_fast_assign(tp_assign(timer_id, timer_id) tp_assign(flags, flags) tp_assign(new_setting, new_setting) tp_assign(old_setting, old_setting)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_64_sys_clock_nanosleep
+SC_TRACE_EVENT(sys_clock_nanosleep,
+       TP_PROTO(const clockid_t which_clock, int flags, const struct timespec * rqtp, struct timespec * rmtp),
+       TP_ARGS(which_clock, flags, rqtp, rmtp),
+       TP_STRUCT__entry(__field(const clockid_t, which_clock) __field(int, flags) __field_hex(const struct timespec *, rqtp) __field_hex(struct timespec *, rmtp)),
+       TP_fast_assign(tp_assign(which_clock, which_clock) tp_assign(flags, flags) tp_assign(rqtp, rqtp) tp_assign(rmtp, rmtp)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_64_sys_vmsplice
+SC_TRACE_EVENT(sys_vmsplice,
+       TP_PROTO(int fd, const struct iovec * iov, unsigned long nr_segs, unsigned int flags),
+       TP_ARGS(fd, iov, nr_segs, flags),
+       TP_STRUCT__entry(__field(int, fd) __field_hex(const struct iovec *, iov) __field(unsigned long, nr_segs) __field(unsigned int, flags)),
+       TP_fast_assign(tp_assign(fd, fd) tp_assign(iov, iov) tp_assign(nr_segs, nr_segs) tp_assign(flags, flags)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_64_sys_utimensat
+SC_TRACE_EVENT(sys_utimensat,
+       TP_PROTO(int dfd, const char * filename, struct timespec * utimes, int flags),
+       TP_ARGS(dfd, filename, utimes, flags),
+       TP_STRUCT__entry(__field(int, dfd) __string_from_user(filename, filename) __field_hex(struct timespec *, utimes) __field(int, flags)),
+       TP_fast_assign(tp_assign(dfd, dfd) tp_copy_string_from_user(filename, filename) tp_assign(utimes, utimes) tp_assign(flags, flags)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_64_sys_timerfd_settime
+SC_TRACE_EVENT(sys_timerfd_settime,
+       TP_PROTO(int ufd, int flags, const struct itimerspec * utmr, struct itimerspec * otmr),
+       TP_ARGS(ufd, flags, utmr, otmr),
+       TP_STRUCT__entry(__field(int, ufd) __field(int, flags) __field_hex(const struct itimerspec *, utmr) __field_hex(struct itimerspec *, otmr)),
+       TP_fast_assign(tp_assign(ufd, ufd) tp_assign(flags, flags) tp_assign(utmr, utmr) tp_assign(otmr, otmr)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_64_sys_rt_tgsigqueueinfo
+SC_TRACE_EVENT(sys_rt_tgsigqueueinfo,
+       TP_PROTO(pid_t tgid, pid_t pid, int sig, siginfo_t * uinfo),
+       TP_ARGS(tgid, pid, sig, uinfo),
+       TP_STRUCT__entry(__field(pid_t, tgid) __field(pid_t, pid) __field(int, sig) __field_hex(siginfo_t *, uinfo)),
+       TP_fast_assign(tp_assign(tgid, tgid) tp_assign(pid, pid) tp_assign(sig, sig) tp_assign(uinfo, uinfo)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_64_sys_sendmmsg
+SC_TRACE_EVENT(sys_sendmmsg,
+       TP_PROTO(int fd, struct mmsghdr * mmsg, unsigned int vlen, unsigned int flags),
+       TP_ARGS(fd, mmsg, vlen, flags),
+       TP_STRUCT__entry(__field(int, fd) __field_hex(struct mmsghdr *, mmsg) __field(unsigned int, vlen) __field(unsigned int, flags)),
+       TP_fast_assign(tp_assign(fd, fd) tp_assign(mmsg, mmsg) tp_assign(vlen, vlen) tp_assign(flags, flags)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_64_sys_32_rt_sigaction
+SC_TRACE_EVENT(sys_32_rt_sigaction,
+       TP_PROTO(int sig, const struct sigaction32 * act, struct sigaction32 * oact, unsigned int sigsetsize),
+       TP_ARGS(sig, act, oact, sigsetsize),
+       TP_STRUCT__entry(__field(int, sig) __field_hex(const struct sigaction32 *, act) __field_hex(struct sigaction32 *, oact) __field(unsigned int, sigsetsize)),
+       TP_fast_assign(tp_assign(sig, sig) tp_assign(act, act) tp_assign(oact, oact) tp_assign(sigsetsize, sigsetsize)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_64_sys_32_rt_sigprocmask
+SC_TRACE_EVENT(sys_32_rt_sigprocmask,
+       TP_PROTO(int how, compat_sigset_t * set, compat_sigset_t * oset, unsigned int sigsetsize),
+       TP_ARGS(how, set, oset, sigsetsize),
+       TP_STRUCT__entry(__field(int, how) __field_hex(compat_sigset_t *, set) __field_hex(compat_sigset_t *, oset) __field(unsigned int, sigsetsize)),
+       TP_fast_assign(tp_assign(how, how) tp_assign(set, set) tp_assign(oset, oset) tp_assign(sigsetsize, sigsetsize)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_64_sys_32_sendfile
+SC_TRACE_EVENT(sys_32_sendfile,
+       TP_PROTO(long out_fd, long in_fd, compat_off_t * offset, s32 count),
+       TP_ARGS(out_fd, in_fd, offset, count),
+       TP_STRUCT__entry(__field(long, out_fd) __field(long, in_fd) __field_hex(compat_off_t *, offset) __field(s32, count)),
+       TP_fast_assign(tp_assign(out_fd, out_fd) tp_assign(in_fd, in_fd) tp_assign(offset, offset) tp_assign(count, count)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_64_sys_socketpair
+SC_TRACE_EVENT(sys_socketpair,
+       TP_PROTO(int family, int type, int protocol, int * usockvec),
+       TP_ARGS(family, type, protocol, usockvec),
+       TP_STRUCT__entry(__field(int, family) __field(int, type) __field(int, protocol) __field_hex(int *, usockvec)),
+       TP_fast_assign(tp_assign(family, family) tp_assign(type, type) tp_assign(protocol, protocol) tp_assign(usockvec, usockvec)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_64_sys_reboot
+SC_TRACE_EVENT(sys_reboot,
+       TP_PROTO(int magic1, int magic2, unsigned int cmd, void * arg),
+       TP_ARGS(magic1, magic2, cmd, arg),
+       TP_STRUCT__entry(__field(int, magic1) __field(int, magic2) __field(unsigned int, cmd) __field_hex(void *, arg)),
+       TP_fast_assign(tp_assign(magic1, magic1) tp_assign(magic2, magic2) tp_assign(cmd, cmd) tp_assign(arg, arg)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_64_sys_quotactl
+SC_TRACE_EVENT(sys_quotactl,
+       TP_PROTO(unsigned int cmd, const char * special, qid_t id, void * addr),
+       TP_ARGS(cmd, special, id, addr),
+       TP_STRUCT__entry(__field(unsigned int, cmd) __field_hex(const char *, special) __field(qid_t, id) __field_hex(void *, addr)),
+       TP_fast_assign(tp_assign(cmd, cmd) tp_assign(special, special) tp_assign(id, id) tp_assign(addr, addr)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_64_sys_getxattr
+SC_TRACE_EVENT(sys_getxattr,
+       TP_PROTO(const char * pathname, const char * name, void * value, size_t size),
+       TP_ARGS(pathname, name, value, size),
+       TP_STRUCT__entry(__string_from_user(pathname, pathname) __string_from_user(name, name) __field_hex(void *, value) __field(size_t, size)),
+       TP_fast_assign(tp_copy_string_from_user(pathname, pathname) tp_copy_string_from_user(name, name) tp_assign(value, value) tp_assign(size, size)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_64_sys_lgetxattr
+SC_TRACE_EVENT(sys_lgetxattr,
+       TP_PROTO(const char * pathname, const char * name, void * value, size_t size),
+       TP_ARGS(pathname, name, value, size),
+       TP_STRUCT__entry(__string_from_user(pathname, pathname) __string_from_user(name, name) __field_hex(void *, value) __field(size_t, size)),
+       TP_fast_assign(tp_copy_string_from_user(pathname, pathname) tp_copy_string_from_user(name, name) tp_assign(value, value) tp_assign(size, size)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_64_sys_fgetxattr
+SC_TRACE_EVENT(sys_fgetxattr,
+       TP_PROTO(int fd, const char * name, void * value, size_t size),
+       TP_ARGS(fd, name, value, size),
+       TP_STRUCT__entry(__field(int, fd) __string_from_user(name, name) __field_hex(void *, value) __field(size_t, size)),
+       TP_fast_assign(tp_assign(fd, fd) tp_copy_string_from_user(name, name) tp_assign(value, value) tp_assign(size, size)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_64_sys_epoll_ctl
+SC_TRACE_EVENT(sys_epoll_ctl,
+       TP_PROTO(int epfd, int op, int fd, struct epoll_event * event),
+       TP_ARGS(epfd, op, fd, event),
+       TP_STRUCT__entry(__field(int, epfd) __field(int, op) __field(int, fd) __field_hex(struct epoll_event *, event)),
+       TP_fast_assign(tp_assign(epfd, epfd) tp_assign(op, op) tp_assign(fd, fd) tp_assign(event, event)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_64_sys_epoll_wait
+SC_TRACE_EVENT(sys_epoll_wait,
+       TP_PROTO(int epfd, struct epoll_event * events, int maxevents, int timeout),
+       TP_ARGS(epfd, events, maxevents, timeout),
+       TP_STRUCT__entry(__field(int, epfd) __field_hex(struct epoll_event *, events) __field(int, maxevents) __field(int, timeout)),
+       TP_fast_assign(tp_assign(epfd, epfd) tp_assign(events, events) tp_assign(maxevents, maxevents) tp_assign(timeout, timeout)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_64_sys_sendfile64
+SC_TRACE_EVENT(sys_sendfile64,
+       TP_PROTO(int out_fd, int in_fd, loff_t * offset, size_t count),
+       TP_ARGS(out_fd, in_fd, offset, count),
+       TP_STRUCT__entry(__field(int, out_fd) __field(int, in_fd) __field_hex(loff_t *, offset) __field(size_t, count)),
+       TP_fast_assign(tp_assign(out_fd, out_fd) tp_assign(in_fd, in_fd) tp_assign(offset, offset) tp_assign(count, count)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_64_sys_openat
+SC_TRACE_EVENT(sys_openat,
+       TP_PROTO(int dfd, const char * filename, int flags, umode_t mode),
+       TP_ARGS(dfd, filename, flags, mode),
+       TP_STRUCT__entry(__field(int, dfd) __string_from_user(filename, filename) __field(int, flags) __field(umode_t, mode)),
+       TP_fast_assign(tp_assign(dfd, dfd) tp_copy_string_from_user(filename, filename) tp_assign(flags, flags) tp_assign(mode, mode)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_64_sys_mknodat
+SC_TRACE_EVENT(sys_mknodat,
+       TP_PROTO(int dfd, const char * filename, umode_t mode, unsigned dev),
+       TP_ARGS(dfd, filename, mode, dev),
+       TP_STRUCT__entry(__field(int, dfd) __string_from_user(filename, filename) __field(umode_t, mode) __field(unsigned, dev)),
+       TP_fast_assign(tp_assign(dfd, dfd) tp_copy_string_from_user(filename, filename) tp_assign(mode, mode) tp_assign(dev, dev)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_64_sys_newfstatat
+SC_TRACE_EVENT(sys_newfstatat,
+       TP_PROTO(int dfd, const char * filename, struct stat * statbuf, int flag),
+       TP_ARGS(dfd, filename, statbuf, flag),
+       TP_STRUCT__entry(__field(int, dfd) __string_from_user(filename, filename) __field_hex(struct stat *, statbuf) __field(int, flag)),
+       TP_fast_assign(tp_assign(dfd, dfd) tp_copy_string_from_user(filename, filename) tp_assign(statbuf, statbuf) tp_assign(flag, flag)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_64_sys_renameat
+SC_TRACE_EVENT(sys_renameat,
+       TP_PROTO(int olddfd, const char * oldname, int newdfd, const char * newname),
+       TP_ARGS(olddfd, oldname, newdfd, newname),
+       TP_STRUCT__entry(__field(int, olddfd) __string_from_user(oldname, oldname) __field(int, newdfd) __string_from_user(newname, newname)),
+       TP_fast_assign(tp_assign(olddfd, olddfd) tp_copy_string_from_user(oldname, oldname) tp_assign(newdfd, newdfd) tp_copy_string_from_user(newname, newname)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_64_sys_readlinkat
+SC_TRACE_EVENT(sys_readlinkat,
+       TP_PROTO(int dfd, const char * pathname, char * buf, int bufsiz),
+       TP_ARGS(dfd, pathname, buf, bufsiz),
+       TP_STRUCT__entry(__field(int, dfd) __string_from_user(pathname, pathname) __field_hex(char *, buf) __field(int, bufsiz)),
+       TP_fast_assign(tp_assign(dfd, dfd) tp_copy_string_from_user(pathname, pathname) tp_assign(buf, buf) tp_assign(bufsiz, bufsiz)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_64_sys_signalfd4
+SC_TRACE_EVENT(sys_signalfd4,
+       TP_PROTO(int ufd, sigset_t * user_mask, size_t sizemask, int flags),
+       TP_ARGS(ufd, user_mask, sizemask, flags),
+       TP_STRUCT__entry(__field(int, ufd) __field_hex(sigset_t *, user_mask) __field(size_t, sizemask) __field(int, flags)),
+       TP_fast_assign(tp_assign(ufd, ufd) tp_assign(user_mask, user_mask) tp_assign(sizemask, sizemask) tp_assign(flags, flags)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_64_sys_accept4
+SC_TRACE_EVENT(sys_accept4,
+       TP_PROTO(int fd, struct sockaddr * upeer_sockaddr, int * upeer_addrlen, int flags),
+       TP_ARGS(fd, upeer_sockaddr, upeer_addrlen, flags),
+       TP_STRUCT__entry(__field(int, fd) __field_hex(struct sockaddr *, upeer_sockaddr) __field_hex(int *, upeer_addrlen) __field(int, flags)),
+       TP_fast_assign(tp_assign(fd, fd) tp_assign(upeer_sockaddr, upeer_sockaddr) tp_assign(upeer_addrlen, upeer_addrlen) tp_assign(flags, flags)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_64_sys_prlimit64
+SC_TRACE_EVENT(sys_prlimit64,
+       TP_PROTO(pid_t pid, unsigned int resource, const struct rlimit64 * new_rlim, struct rlimit64 * old_rlim),
+       TP_ARGS(pid, resource, new_rlim, old_rlim),
+       TP_STRUCT__entry(__field(pid_t, pid) __field(unsigned int, resource) __field_hex(const struct rlimit64 *, new_rlim) __field_hex(struct rlimit64 *, old_rlim)),
+       TP_fast_assign(tp_assign(pid, pid) tp_assign(resource, resource) tp_assign(new_rlim, new_rlim) tp_assign(old_rlim, old_rlim)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_64_sys_32_llseek
+SC_TRACE_EVENT(sys_32_llseek,
+       TP_PROTO(unsigned int fd, unsigned int offset_high, unsigned int offset_low, loff_t * result, unsigned int origin),
+       TP_ARGS(fd, offset_high, offset_low, result, origin),
+       TP_STRUCT__entry(__field(unsigned int, fd) __field(unsigned int, offset_high) __field(unsigned int, offset_low) __field_hex(loff_t *, result) __field(unsigned int, origin)),
+       TP_fast_assign(tp_assign(fd, fd) tp_assign(offset_high, offset_high) tp_assign(offset_low, offset_low) tp_assign(result, result) tp_assign(origin, origin)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_64_sys_32_waitid
+SC_TRACE_EVENT(sys_32_waitid,
+       TP_PROTO(int which, compat_pid_t pid, compat_siginfo_t * uinfo, int options, struct compat_rusage * uru),
+       TP_ARGS(which, pid, uinfo, options, uru),
+       TP_STRUCT__entry(__field(int, which) __field(compat_pid_t, pid) __field_hex(compat_siginfo_t *, uinfo) __field(int, options) __field_hex(struct compat_rusage *, uru)),
+       TP_fast_assign(tp_assign(which, which) tp_assign(pid, pid) tp_assign(uinfo, uinfo) tp_assign(options, options) tp_assign(uru, uru)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_64_sys_select
+SC_TRACE_EVENT(sys_select,
+       TP_PROTO(int n, fd_set * inp, fd_set * outp, fd_set * exp, struct timeval * tvp),
+       TP_ARGS(n, inp, outp, exp, tvp),
+       TP_STRUCT__entry(__field(int, n) __field_hex(fd_set *, inp) __field_hex(fd_set *, outp) __field_hex(fd_set *, exp) __field_hex(struct timeval *, tvp)),
+       TP_fast_assign(tp_assign(n, n) tp_assign(inp, inp) tp_assign(outp, outp) tp_assign(exp, exp) tp_assign(tvp, tvp)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_64_sys_setsockopt
+SC_TRACE_EVENT(sys_setsockopt,
+       TP_PROTO(int fd, int level, int optname, char * optval, int optlen),
+       TP_ARGS(fd, level, optname, optval, optlen),
+       TP_STRUCT__entry(__field(int, fd) __field(int, level) __field(int, optname) __field_hex(char *, optval) __field(int, optlen)),
+       TP_fast_assign(tp_assign(fd, fd) tp_assign(level, level) tp_assign(optname, optname) tp_assign(optval, optval) tp_assign(optlen, optlen)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_64_sys_msgrcv
+SC_TRACE_EVENT(sys_msgrcv,
+       TP_PROTO(int msqid, struct msgbuf * msgp, size_t msgsz, long msgtyp, int msgflg),
+       TP_ARGS(msqid, msgp, msgsz, msgtyp, msgflg),
+       TP_STRUCT__entry(__field(int, msqid) __field_hex(struct msgbuf *, msgp) __field(size_t, msgsz) __field(long, msgtyp) __field(int, msgflg)),
+       TP_fast_assign(tp_assign(msqid, msqid) tp_assign(msgp, msgp) tp_assign(msgsz, msgsz) tp_assign(msgtyp, msgtyp) tp_assign(msgflg, msgflg)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_64_sys_mount
+SC_TRACE_EVENT(sys_mount,
+       TP_PROTO(char * dev_name, char * dir_name, char * type, unsigned long flags, void * data),
+       TP_ARGS(dev_name, dir_name, type, flags, data),
+       TP_STRUCT__entry(__string_from_user(dev_name, dev_name) __string_from_user(dir_name, dir_name) __string_from_user(type, type) __field(unsigned long, flags) __field_hex(void *, data)),
+       TP_fast_assign(tp_copy_string_from_user(dev_name, dev_name) tp_copy_string_from_user(dir_name, dir_name) tp_copy_string_from_user(type, type) tp_assign(flags, flags) tp_assign(data, data)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_64_sys_io_getevents
+SC_TRACE_EVENT(sys_io_getevents,
+       TP_PROTO(aio_context_t ctx_id, long min_nr, long nr, struct io_event * events, struct timespec * timeout),
+       TP_ARGS(ctx_id, min_nr, nr, events, timeout),
+       TP_STRUCT__entry(__field(aio_context_t, ctx_id) __field(long, min_nr) __field(long, nr) __field_hex(struct io_event *, events) __field_hex(struct timespec *, timeout)),
+       TP_fast_assign(tp_assign(ctx_id, ctx_id) tp_assign(min_nr, min_nr) tp_assign(nr, nr) tp_assign(events, events) tp_assign(timeout, timeout)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_64_sys_waitid
+SC_TRACE_EVENT(sys_waitid,
+       TP_PROTO(int which, pid_t upid, struct siginfo * infop, int options, struct rusage * ru),
+       TP_ARGS(which, upid, infop, options, ru),
+       TP_STRUCT__entry(__field(int, which) __field(pid_t, upid) __field_hex(struct siginfo *, infop) __field(int, options) __field_hex(struct rusage *, ru)),
+       TP_fast_assign(tp_assign(which, which) tp_assign(upid, upid) tp_assign(infop, infop) tp_assign(options, options) tp_assign(ru, ru)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_64_sys_ppoll
+SC_TRACE_EVENT(sys_ppoll,
+       TP_PROTO(struct pollfd * ufds, unsigned int nfds, struct timespec * tsp, const sigset_t * sigmask, size_t sigsetsize),
+       TP_ARGS(ufds, nfds, tsp, sigmask, sigsetsize),
+       TP_STRUCT__entry(__field_hex(struct pollfd *, ufds) __field(unsigned int, nfds) __field_hex(struct timespec *, tsp) __field_hex(const sigset_t *, sigmask) __field(size_t, sigsetsize)),
+       TP_fast_assign(tp_assign(ufds, ufds) tp_assign(nfds, nfds) tp_assign(tsp, tsp) tp_assign(sigmask, sigmask) tp_assign(sigsetsize, sigsetsize)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_64_sys_recvmmsg
+SC_TRACE_EVENT(sys_recvmmsg,
+       TP_PROTO(int fd, struct mmsghdr * mmsg, unsigned int vlen, unsigned int flags, struct timespec * timeout),
+       TP_ARGS(fd, mmsg, vlen, flags, timeout),
+       TP_STRUCT__entry(__field(int, fd) __field_hex(struct mmsghdr *, mmsg) __field(unsigned int, vlen) __field(unsigned int, flags) __field_hex(struct timespec *, timeout)),
+       TP_fast_assign(tp_assign(fd, fd) tp_assign(mmsg, mmsg) tp_assign(vlen, vlen) tp_assign(flags, flags) tp_assign(timeout, timeout)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_64_sys_getsockopt
+SC_TRACE_EVENT(sys_getsockopt,
+       TP_PROTO(int fd, int level, int optname, char * optval, int * optlen),
+       TP_ARGS(fd, level, optname, optval, optlen),
+       TP_STRUCT__entry(__field(int, fd) __field(int, level) __field(int, optname) __field_hex(char *, optval) __field_hex(int *, optlen)),
+       TP_fast_assign(tp_assign(fd, fd) tp_assign(level, level) tp_assign(optname, optname) tp_assign(optval, optval) tp_assign(optlen, optlen)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_64_sys_setxattr
+SC_TRACE_EVENT(sys_setxattr,
+       TP_PROTO(const char * pathname, const char * name, const void * value, size_t size, int flags),
+       TP_ARGS(pathname, name, value, size, flags),
+       TP_STRUCT__entry(__string_from_user(pathname, pathname) __string_from_user(name, name) __field_hex(const void *, value) __field(size_t, size) __field(int, flags)),
+       TP_fast_assign(tp_copy_string_from_user(pathname, pathname) tp_copy_string_from_user(name, name) tp_assign(value, value) tp_assign(size, size) tp_assign(flags, flags)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_64_sys_lsetxattr
+SC_TRACE_EVENT(sys_lsetxattr,
+       TP_PROTO(const char * pathname, const char * name, const void * value, size_t size, int flags),
+       TP_ARGS(pathname, name, value, size, flags),
+       TP_STRUCT__entry(__string_from_user(pathname, pathname) __string_from_user(name, name) __field_hex(const void *, value) __field(size_t, size) __field(int, flags)),
+       TP_fast_assign(tp_copy_string_from_user(pathname, pathname) tp_copy_string_from_user(name, name) tp_assign(value, value) tp_assign(size, size) tp_assign(flags, flags)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_64_sys_fsetxattr
+SC_TRACE_EVENT(sys_fsetxattr,
+       TP_PROTO(int fd, const char * name, const void * value, size_t size, int flags),
+       TP_ARGS(fd, name, value, size, flags),
+       TP_STRUCT__entry(__field(int, fd) __string_from_user(name, name) __field_hex(const void *, value) __field(size_t, size) __field(int, flags)),
+       TP_fast_assign(tp_assign(fd, fd) tp_copy_string_from_user(name, name) tp_assign(value, value) tp_assign(size, size) tp_assign(flags, flags)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_64_sys_fchownat
+SC_TRACE_EVENT(sys_fchownat,
+       TP_PROTO(int dfd, const char * filename, uid_t user, gid_t group, int flag),
+       TP_ARGS(dfd, filename, user, group, flag),
+       TP_STRUCT__entry(__field(int, dfd) __string_from_user(filename, filename) __field(uid_t, user) __field(gid_t, group) __field(int, flag)),
+       TP_fast_assign(tp_assign(dfd, dfd) tp_copy_string_from_user(filename, filename) tp_assign(user, user) tp_assign(group, group) tp_assign(flag, flag)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_64_sys_linkat
+SC_TRACE_EVENT(sys_linkat,
+       TP_PROTO(int olddfd, const char * oldname, int newdfd, const char * newname, int flags),
+       TP_ARGS(olddfd, oldname, newdfd, newname, flags),
+       TP_STRUCT__entry(__field(int, olddfd) __string_from_user(oldname, oldname) __field(int, newdfd) __string_from_user(newname, newname) __field(int, flags)),
+       TP_fast_assign(tp_assign(olddfd, olddfd) tp_copy_string_from_user(oldname, oldname) tp_assign(newdfd, newdfd) tp_copy_string_from_user(newname, newname) tp_assign(flags, flags)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_64_sys_preadv
+SC_TRACE_EVENT(sys_preadv,
+       TP_PROTO(unsigned long fd, const struct iovec * vec, unsigned long vlen, unsigned long pos_l, unsigned long pos_h),
+       TP_ARGS(fd, vec, vlen, pos_l, pos_h),
+       TP_STRUCT__entry(__field(unsigned long, fd) __field_hex(const struct iovec *, vec) __field(unsigned long, vlen) __field(unsigned long, pos_l) __field(unsigned long, pos_h)),
+       TP_fast_assign(tp_assign(fd, fd) tp_assign(vec, vec) tp_assign(vlen, vlen) tp_assign(pos_l, pos_l) tp_assign(pos_h, pos_h)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_64_sys_pwritev
+SC_TRACE_EVENT(sys_pwritev,
+       TP_PROTO(unsigned long fd, const struct iovec * vec, unsigned long vlen, unsigned long pos_l, unsigned long pos_h),
+       TP_ARGS(fd, vec, vlen, pos_l, pos_h),
+       TP_STRUCT__entry(__field(unsigned long, fd) __field_hex(const struct iovec *, vec) __field(unsigned long, vlen) __field(unsigned long, pos_l) __field(unsigned long, pos_h)),
+       TP_fast_assign(tp_assign(fd, fd) tp_assign(vec, vec) tp_assign(vlen, vlen) tp_assign(pos_l, pos_l) tp_assign(pos_h, pos_h)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_64_sys_32_pread
+SC_TRACE_EVENT(sys_32_pread,
+       TP_PROTO(unsigned long fd, char * buf, size_t count, unsigned long unused, unsigned long a4, unsigned long a5),
+       TP_ARGS(fd, buf, count, unused, a4, a5),
+       TP_STRUCT__entry(__field(unsigned long, fd) __field_hex(char *, buf) __field(size_t, count) __field(unsigned long, unused) __field(unsigned long, a4) __field(unsigned long, a5)),
+       TP_fast_assign(tp_assign(fd, fd) tp_assign(buf, buf) tp_assign(count, count) tp_assign(unused, unused) tp_assign(a4, a4) tp_assign(a5, a5)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_64_sys_32_pwrite
+SC_TRACE_EVENT(sys_32_pwrite,
+       TP_PROTO(unsigned int fd, const char * buf, size_t count, u32 unused, u64 a4, u64 a5),
+       TP_ARGS(fd, buf, count, unused, a4, a5),
+       TP_STRUCT__entry(__field(unsigned int, fd) __field_hex(const char *, buf) __field(size_t, count) __field(u32, unused) __field(u64, a4) __field(u64, a5)),
+       TP_fast_assign(tp_assign(fd, fd) tp_assign(buf, buf) tp_assign(count, count) tp_assign(unused, unused) tp_assign(a4, a4) tp_assign(a5, a5)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_64_sys_32_fanotify_mark
+SC_TRACE_EVENT(sys_32_fanotify_mark,
+       TP_PROTO(int fanotify_fd, unsigned int flags, u64 a3, u64 a4, int dfd, const char * pathname),
+       TP_ARGS(fanotify_fd, flags, a3, a4, dfd, pathname),
+       TP_STRUCT__entry(__field(int, fanotify_fd) __field(unsigned int, flags) __field(u64, a3) __field(u64, a4) __field(int, dfd) __string_from_user(pathname, pathname)),
+       TP_fast_assign(tp_assign(fanotify_fd, fanotify_fd) tp_assign(flags, flags) tp_assign(a3, a3) tp_assign(a4, a4) tp_assign(dfd, dfd) tp_copy_string_from_user(pathname, pathname)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_64_sys_recvfrom
+SC_TRACE_EVENT(sys_recvfrom,
+       TP_PROTO(int fd, void * ubuf, size_t size, unsigned int flags, struct sockaddr * addr, int * addr_len),
+       TP_ARGS(fd, ubuf, size, flags, addr, addr_len),
+       TP_STRUCT__entry(__field(int, fd) __field_hex(void *, ubuf) __field(size_t, size) __field(unsigned int, flags) __field_hex(struct sockaddr *, addr) __field_hex(int *, addr_len)),
+       TP_fast_assign(tp_assign(fd, fd) tp_assign(ubuf, ubuf) tp_assign(size, size) tp_assign(flags, flags) tp_assign(addr, addr) tp_assign(addr_len, addr_len)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_64_sys_futex
+SC_TRACE_EVENT(sys_futex,
+       TP_PROTO(u32 * uaddr, int op, u32 val, struct timespec * utime, u32 * uaddr2, u32 val3),
+       TP_ARGS(uaddr, op, val, utime, uaddr2, val3),
+       TP_STRUCT__entry(__field_hex(u32 *, uaddr) __field(int, op) __field(u32, val) __field_hex(struct timespec *, utime) __field_hex(u32 *, uaddr2) __field(u32, val3)),
+       TP_fast_assign(tp_assign(uaddr, uaddr) tp_assign(op, op) tp_assign(val, val) tp_assign(utime, utime) tp_assign(uaddr2, uaddr2) tp_assign(val3, val3)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_64_sys_pselect6
+SC_TRACE_EVENT(sys_pselect6,
+       TP_PROTO(int n, fd_set * inp, fd_set * outp, fd_set * exp, struct timespec * tsp, void * sig),
+       TP_ARGS(n, inp, outp, exp, tsp, sig),
+       TP_STRUCT__entry(__field(int, n) __field_hex(fd_set *, inp) __field_hex(fd_set *, outp) __field_hex(fd_set *, exp) __field_hex(struct timespec *, tsp) __field_hex(void *, sig)),
+       TP_fast_assign(tp_assign(n, n) tp_assign(inp, inp) tp_assign(outp, outp) tp_assign(exp, exp) tp_assign(tsp, tsp) tp_assign(sig, sig)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_64_sys_epoll_pwait
+SC_TRACE_EVENT(sys_epoll_pwait,
+       TP_PROTO(int epfd, struct epoll_event * events, int maxevents, int timeout, const sigset_t * sigmask, size_t sigsetsize),
+       TP_ARGS(epfd, events, maxevents, timeout, sigmask, sigsetsize),
+       TP_STRUCT__entry(__field(int, epfd) __field_hex(struct epoll_event *, events) __field(int, maxevents) __field(int, timeout) __field_hex(const sigset_t *, sigmask) __field(size_t, sigsetsize)),
+       TP_fast_assign(tp_assign(epfd, epfd) tp_assign(events, events) tp_assign(maxevents, maxevents) tp_assign(timeout, timeout) tp_assign(sigmask, sigmask) tp_assign(sigsetsize, sigsetsize)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_64_sys_process_vm_readv
+SC_TRACE_EVENT(sys_process_vm_readv,
+       TP_PROTO(pid_t pid, const struct iovec * lvec, unsigned long liovcnt, const struct iovec * rvec, unsigned long riovcnt, unsigned long flags),
+       TP_ARGS(pid, lvec, liovcnt, rvec, riovcnt, flags),
+       TP_STRUCT__entry(__field(pid_t, pid) __field_hex(const struct iovec *, lvec) __field(unsigned long, liovcnt) __field_hex(const struct iovec *, rvec) __field(unsigned long, riovcnt) __field(unsigned long, flags)),
+       TP_fast_assign(tp_assign(pid, pid) tp_assign(lvec, lvec) tp_assign(liovcnt, liovcnt) tp_assign(rvec, rvec) tp_assign(riovcnt, riovcnt) tp_assign(flags, flags)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_64_sys_process_vm_writev
+SC_TRACE_EVENT(sys_process_vm_writev,
+       TP_PROTO(pid_t pid, const struct iovec * lvec, unsigned long liovcnt, const struct iovec * rvec, unsigned long riovcnt, unsigned long flags),
+       TP_ARGS(pid, lvec, liovcnt, rvec, riovcnt, flags),
+       TP_STRUCT__entry(__field(pid_t, pid) __field_hex(const struct iovec *, lvec) __field(unsigned long, liovcnt) __field_hex(const struct iovec *, rvec) __field(unsigned long, riovcnt) __field(unsigned long, flags)),
+       TP_fast_assign(tp_assign(pid, pid) tp_assign(lvec, lvec) tp_assign(liovcnt, liovcnt) tp_assign(rvec, rvec) tp_assign(riovcnt, riovcnt) tp_assign(flags, flags)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_64_sys_sendto
+SC_TRACE_EVENT(sys_sendto,
+       TP_PROTO(int fd, void * buff, size_t len, unsigned int flags, struct sockaddr * addr, int addr_len),
+       TP_ARGS(fd, buff, len, flags, addr, addr_len),
+       TP_STRUCT__entry(__field(int, fd) __field_hex(void *, buff) __field(size_t, len) __field(unsigned int, flags) __field_hex(struct sockaddr *, addr) __field_hex(int, addr_len)),
+       TP_fast_assign(tp_assign(fd, fd) tp_assign(buff, buff) tp_assign(len, len) tp_assign(flags, flags) tp_assign(addr, addr) tp_assign(addr_len, addr_len)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_64_sys_32_futex
+SC_TRACE_EVENT(sys_32_futex,
+       TP_PROTO(u32 * uaddr, int op, u32 val, struct compat_timespec * utime, u32 * uaddr2, u32 val3),
+       TP_ARGS(uaddr, op, val, utime, uaddr2, val3),
+       TP_STRUCT__entry(__field_hex(u32 *, uaddr) __field(int, op) __field(u32, val) __field_hex(struct compat_timespec *, utime) __field_hex(u32 *, uaddr2) __field(u32, val3)),
+       TP_fast_assign(tp_assign(uaddr, uaddr) tp_assign(op, op) tp_assign(val, val) tp_assign(utime, utime) tp_assign(uaddr2, uaddr2) tp_assign(val3, val3)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_64_sys_splice
+SC_TRACE_EVENT(sys_splice,
+       TP_PROTO(int fd_in, loff_t * off_in, int fd_out, loff_t * off_out, size_t len, unsigned int flags),
+       TP_ARGS(fd_in, off_in, fd_out, off_out, len, flags),
+       TP_STRUCT__entry(__field(int, fd_in) __field_hex(loff_t *, off_in) __field(int, fd_out) __field_hex(loff_t *, off_out) __field(size_t, len) __field(unsigned int, flags)),
+       TP_fast_assign(tp_assign(fd_in, fd_in) tp_assign(off_in, off_in) tp_assign(fd_out, fd_out) tp_assign(off_out, off_out) tp_assign(len, len) tp_assign(flags, flags)),
+       TP_printk()
+)
+#endif
+
+#endif /*  _TRACE_SYSCALLS_POINTERS_H */
+
+/* This part must be outside protection */
+#include "../../../probes/define_trace.h"
+
+#else /* CREATE_SYSCALL_TABLE */
+
+#include "mips-64-syscalls-3.5.0_pointers_override.h"
+#include "syscalls_pointers_override.h"
+
+#ifndef OVERRIDE_TABLE_64_sys_waitpid
+TRACE_SYSCALL_TABLE(sys_waitpid, sys_waitpid, 4007, 3)
+#endif
+#ifndef OVERRIDE_TABLE_64_sys_oldumount
+TRACE_SYSCALL_TABLE(sys_oldumount, sys_oldumount, 4022, 1)
+#endif
+#ifndef OVERRIDE_TABLE_64_sys_olduname
+TRACE_SYSCALL_TABLE(sys_olduname, sys_olduname, 4059, 1)
+#endif
+#ifndef OVERRIDE_TABLE_64_sys_32_sigaction
+TRACE_SYSCALL_TABLE(sys_32_sigaction, sys_32_sigaction, 4067, 3)
+#endif
+#ifndef OVERRIDE_TABLE_64_sys_uselib
+TRACE_SYSCALL_TABLE(sys_uselib, sys_uselib, 4086, 1)
+#endif
+#ifndef OVERRIDE_TABLE_64_sys_uname
+TRACE_SYSCALL_TABLE(sys_uname, sys_uname, 4109, 1)
+#endif
+#ifndef OVERRIDE_TABLE_64_sys_32_llseek
+TRACE_SYSCALL_TABLE(sys_32_llseek, sys_32_llseek, 4140, 5)
+#endif
+#ifndef OVERRIDE_TABLE_64_sys_send
+TRACE_SYSCALL_TABLE(sys_send, sys_send, 4178, 4)
+#endif
+#ifndef OVERRIDE_TABLE_64_sys_32_pread
+TRACE_SYSCALL_TABLE(sys_32_pread, sys_32_pread, 4200, 6)
+#endif
+#ifndef OVERRIDE_TABLE_64_sys_32_pwrite
+TRACE_SYSCALL_TABLE(sys_32_pwrite, sys_32_pwrite, 4201, 6)
+#endif
+#ifndef OVERRIDE_TABLE_64_sys_32_truncate64
+TRACE_SYSCALL_TABLE(sys_32_truncate64, sys_32_truncate64, 4211, 4)
+#endif
+#ifndef OVERRIDE_TABLE_64_sys_32_waitid
+TRACE_SYSCALL_TABLE(sys_32_waitid, sys_32_waitid, 4278, 5)
+#endif
+#ifndef OVERRIDE_TABLE_64_sys_32_fanotify_mark
+TRACE_SYSCALL_TABLE(sys_32_fanotify_mark, sys_32_fanotify_mark, 4337, 6)
+#endif
+#ifndef OVERRIDE_TABLE_64_sys_rt_sigaction
+TRACE_SYSCALL_TABLE(sys_rt_sigaction, sys_rt_sigaction, 5013, 4)
+#endif
+#ifndef OVERRIDE_TABLE_64_sys_rt_sigprocmask
+TRACE_SYSCALL_TABLE(sys_rt_sigprocmask, sys_rt_sigprocmask, 5014, 4)
+#endif
+#ifndef OVERRIDE_TABLE_64_sys_readv
+TRACE_SYSCALL_TABLE(sys_readv, sys_readv, 5018, 3)
+#endif
+#ifndef OVERRIDE_TABLE_64_sys_writev
+TRACE_SYSCALL_TABLE(sys_writev, sys_writev, 5019, 3)
+#endif
+#ifndef OVERRIDE_TABLE_64_sys_select
+TRACE_SYSCALL_TABLE(sys_select, sys_select, 5022, 5)
+#endif
+#ifndef OVERRIDE_TABLE_64_sys_shmctl
+TRACE_SYSCALL_TABLE(sys_shmctl, sys_shmctl, 5030, 3)
+#endif
+#ifndef OVERRIDE_TABLE_64_sys_nanosleep
+TRACE_SYSCALL_TABLE(sys_nanosleep, sys_nanosleep, 5034, 2)
+#endif
+#ifndef OVERRIDE_TABLE_64_sys_getitimer
+TRACE_SYSCALL_TABLE(sys_getitimer, sys_getitimer, 5035, 2)
+#endif
+#ifndef OVERRIDE_TABLE_64_sys_setitimer
+TRACE_SYSCALL_TABLE(sys_setitimer, sys_setitimer, 5036, 3)
+#endif
+#ifndef OVERRIDE_TABLE_64_sys_recvfrom
+TRACE_SYSCALL_TABLE(sys_recvfrom, sys_recvfrom, 5044, 6)
+#endif
+#ifndef OVERRIDE_TABLE_64_sys_sendmsg
+TRACE_SYSCALL_TABLE(sys_sendmsg, sys_sendmsg, 5045, 3)
+#endif
+#ifndef OVERRIDE_TABLE_64_sys_recvmsg
+TRACE_SYSCALL_TABLE(sys_recvmsg, sys_recvmsg, 5046, 3)
+#endif
+#ifndef OVERRIDE_TABLE_64_sys_setsockopt
+TRACE_SYSCALL_TABLE(sys_setsockopt, sys_setsockopt, 5053, 5)
+#endif
+#ifndef OVERRIDE_TABLE_64_sys_wait4
+TRACE_SYSCALL_TABLE(sys_wait4, sys_wait4, 5059, 4)
+#endif
+#ifndef OVERRIDE_TABLE_64_sys_msgsnd
+TRACE_SYSCALL_TABLE(sys_msgsnd, sys_msgsnd, 5067, 4)
+#endif
+#ifndef OVERRIDE_TABLE_64_sys_msgrcv
+TRACE_SYSCALL_TABLE(sys_msgrcv, sys_msgrcv, 5068, 5)
+#endif
+#ifndef OVERRIDE_TABLE_64_sys_msgctl
+TRACE_SYSCALL_TABLE(sys_msgctl, sys_msgctl, 5069, 3)
+#endif
+#ifndef OVERRIDE_TABLE_64_sys_getdents
+TRACE_SYSCALL_TABLE(sys_getdents, sys_getdents, 5076, 3)
+#endif
+#ifndef OVERRIDE_TABLE_64_sys_gettimeofday
+TRACE_SYSCALL_TABLE(sys_gettimeofday, sys_gettimeofday, 5094, 2)
+#endif
+#ifndef OVERRIDE_TABLE_64_sys_getrlimit
+TRACE_SYSCALL_TABLE(sys_getrlimit, sys_getrlimit, 5095, 2)
+#endif
+#ifndef OVERRIDE_TABLE_64_sys_getrusage
+TRACE_SYSCALL_TABLE(sys_getrusage, sys_getrusage, 5096, 2)
+#endif
+#ifndef OVERRIDE_TABLE_64_sys_sysinfo
+TRACE_SYSCALL_TABLE(sys_sysinfo, sys_sysinfo, 5097, 1)
+#endif
+#ifndef OVERRIDE_TABLE_64_sys_times
+TRACE_SYSCALL_TABLE(sys_times, sys_times, 5098, 1)
+#endif
+#ifndef OVERRIDE_TABLE_64_sys_rt_sigpending
+TRACE_SYSCALL_TABLE(sys_rt_sigpending, sys_rt_sigpending, 5125, 2)
+#endif
+#ifndef OVERRIDE_TABLE_64_sys_rt_sigtimedwait
+TRACE_SYSCALL_TABLE(sys_rt_sigtimedwait, sys_rt_sigtimedwait, 5126, 4)
+#endif
+#ifndef OVERRIDE_TABLE_64_sys_rt_sigqueueinfo
+TRACE_SYSCALL_TABLE(sys_rt_sigqueueinfo, sys_rt_sigqueueinfo, 5127, 3)
+#endif
+#ifndef OVERRIDE_TABLE_64_sys_utime
+TRACE_SYSCALL_TABLE(sys_utime, sys_utime, 5130, 2)
+#endif
+#ifndef OVERRIDE_TABLE_64_sys_ustat
+TRACE_SYSCALL_TABLE(sys_ustat, sys_ustat, 5133, 2)
+#endif
+#ifndef OVERRIDE_TABLE_64_sys_statfs
+TRACE_SYSCALL_TABLE(sys_statfs, sys_statfs, 5134, 2)
+#endif
+#ifndef OVERRIDE_TABLE_64_sys_fstatfs
+TRACE_SYSCALL_TABLE(sys_fstatfs, sys_fstatfs, 5135, 2)
+#endif
+#ifndef OVERRIDE_TABLE_64_sys_sched_rr_get_interval
+TRACE_SYSCALL_TABLE(sys_sched_rr_get_interval, sys_sched_rr_get_interval, 5145, 2)
+#endif
+#ifndef OVERRIDE_TABLE_64_sys_sysctl
+TRACE_SYSCALL_TABLE(sys_sysctl, sys_sysctl, 5152, 1)
+#endif
+#ifndef OVERRIDE_TABLE_64_sys_adjtimex
+TRACE_SYSCALL_TABLE(sys_adjtimex, sys_adjtimex, 5154, 1)
+#endif
+#ifndef OVERRIDE_TABLE_64_sys_setrlimit
+TRACE_SYSCALL_TABLE(sys_setrlimit, sys_setrlimit, 5155, 2)
+#endif
+#ifndef OVERRIDE_TABLE_64_sys_settimeofday
+TRACE_SYSCALL_TABLE(sys_settimeofday, sys_settimeofday, 5159, 2)
+#endif
+#ifndef OVERRIDE_TABLE_64_sys_mount
+TRACE_SYSCALL_TABLE(sys_mount, sys_mount, 5160, 5)
+#endif
+#ifndef OVERRIDE_TABLE_64_sys_futex
+TRACE_SYSCALL_TABLE(sys_futex, sys_futex, 5194, 6)
+#endif
+#ifndef OVERRIDE_TABLE_64_sys_sched_setaffinity
+TRACE_SYSCALL_TABLE(sys_sched_setaffinity, sys_sched_setaffinity, 5195, 3)
+#endif
+#ifndef OVERRIDE_TABLE_64_sys_sched_getaffinity
+TRACE_SYSCALL_TABLE(sys_sched_getaffinity, sys_sched_getaffinity, 5196, 3)
+#endif
+#ifndef OVERRIDE_TABLE_64_sys_io_setup
+TRACE_SYSCALL_TABLE(sys_io_setup, sys_io_setup, 5200, 2)
+#endif
+#ifndef OVERRIDE_TABLE_64_sys_io_getevents
+TRACE_SYSCALL_TABLE(sys_io_getevents, sys_io_getevents, 5202, 5)
+#endif
+#ifndef OVERRIDE_TABLE_64_sys_io_submit
+TRACE_SYSCALL_TABLE(sys_io_submit, sys_io_submit, 5203, 3)
+#endif
+#ifndef OVERRIDE_TABLE_64_sys_semtimedop
+TRACE_SYSCALL_TABLE(sys_semtimedop, sys_semtimedop, 5214, 4)
+#endif
+#ifndef OVERRIDE_TABLE_64_sys_timer_create
+TRACE_SYSCALL_TABLE(sys_timer_create, sys_timer_create, 5216, 3)
+#endif
+#ifndef OVERRIDE_TABLE_64_sys_timer_settime
+TRACE_SYSCALL_TABLE(sys_timer_settime, sys_timer_settime, 5217, 4)
+#endif
+#ifndef OVERRIDE_TABLE_64_sys_timer_gettime
+TRACE_SYSCALL_TABLE(sys_timer_gettime, sys_timer_gettime, 5218, 2)
+#endif
+#ifndef OVERRIDE_TABLE_64_sys_clock_settime
+TRACE_SYSCALL_TABLE(sys_clock_settime, sys_clock_settime, 5221, 2)
+#endif
+#ifndef OVERRIDE_TABLE_64_sys_clock_gettime
+TRACE_SYSCALL_TABLE(sys_clock_gettime, sys_clock_gettime, 5222, 2)
+#endif
+#ifndef OVERRIDE_TABLE_64_sys_clock_getres
+TRACE_SYSCALL_TABLE(sys_clock_getres, sys_clock_getres, 5223, 2)
+#endif
+#ifndef OVERRIDE_TABLE_64_sys_clock_nanosleep
+TRACE_SYSCALL_TABLE(sys_clock_nanosleep, sys_clock_nanosleep, 5224, 4)
+#endif
+#ifndef OVERRIDE_TABLE_64_sys_utimes
+TRACE_SYSCALL_TABLE(sys_utimes, sys_utimes, 5226, 2)
+#endif
+#ifndef OVERRIDE_TABLE_64_sys_waitid
+TRACE_SYSCALL_TABLE(sys_waitid, sys_waitid, 5237, 5)
+#endif
+#ifndef OVERRIDE_TABLE_64_sys_futimesat
+TRACE_SYSCALL_TABLE(sys_futimesat, sys_futimesat, 5251, 3)
+#endif
+#ifndef OVERRIDE_TABLE_64_sys_pselect6
+TRACE_SYSCALL_TABLE(sys_pselect6, sys_pselect6, 5260, 6)
+#endif
+#ifndef OVERRIDE_TABLE_64_sys_ppoll
+TRACE_SYSCALL_TABLE(sys_ppoll, sys_ppoll, 5261, 5)
+#endif
+#ifndef OVERRIDE_TABLE_64_sys_vmsplice
+TRACE_SYSCALL_TABLE(sys_vmsplice, sys_vmsplice, 5266, 4)
+#endif
+#ifndef OVERRIDE_TABLE_64_sys_set_robust_list
+TRACE_SYSCALL_TABLE(sys_set_robust_list, sys_set_robust_list, 5268, 2)
+#endif
+#ifndef OVERRIDE_TABLE_64_sys_get_robust_list
+TRACE_SYSCALL_TABLE(sys_get_robust_list, sys_get_robust_list, 5269, 3)
+#endif
+#ifndef OVERRIDE_TABLE_64_sys_epoll_pwait
+TRACE_SYSCALL_TABLE(sys_epoll_pwait, sys_epoll_pwait, 5272, 6)
+#endif
+#ifndef OVERRIDE_TABLE_64_sys_utimensat
+TRACE_SYSCALL_TABLE(sys_utimensat, sys_utimensat, 5275, 4)
+#endif
+#ifndef OVERRIDE_TABLE_64_sys_signalfd
+TRACE_SYSCALL_TABLE(sys_signalfd, sys_signalfd, 5276, 3)
+#endif
+#ifndef OVERRIDE_TABLE_64_sys_timerfd_gettime
+TRACE_SYSCALL_TABLE(sys_timerfd_gettime, sys_timerfd_gettime, 5281, 2)
+#endif
+#ifndef OVERRIDE_TABLE_64_sys_timerfd_settime
+TRACE_SYSCALL_TABLE(sys_timerfd_settime, sys_timerfd_settime, 5282, 4)
+#endif
+#ifndef OVERRIDE_TABLE_64_sys_rt_tgsigqueueinfo
+TRACE_SYSCALL_TABLE(sys_rt_tgsigqueueinfo, sys_rt_tgsigqueueinfo, 5291, 4)
+#endif
+#ifndef OVERRIDE_TABLE_64_sys_recvmmsg
+TRACE_SYSCALL_TABLE(sys_recvmmsg, sys_recvmmsg, 5294, 5)
+#endif
+#ifndef OVERRIDE_TABLE_64_sys_clock_adjtime
+TRACE_SYSCALL_TABLE(sys_clock_adjtime, sys_clock_adjtime, 5300, 2)
+#endif
+#ifndef OVERRIDE_TABLE_64_sys_sendmmsg
+TRACE_SYSCALL_TABLE(sys_sendmmsg, sys_sendmmsg, 5302, 4)
+#endif
+#ifndef OVERRIDE_TABLE_64_sys_process_vm_readv
+TRACE_SYSCALL_TABLE(sys_process_vm_readv, sys_process_vm_readv, 5304, 6)
+#endif
+#ifndef OVERRIDE_TABLE_64_sys_process_vm_writev
+TRACE_SYSCALL_TABLE(sys_process_vm_writev, sys_process_vm_writev, 5305, 6)
+#endif
+#ifndef OVERRIDE_TABLE_64_sys_read
+TRACE_SYSCALL_TABLE(sys_read, sys_read, 6000, 3)
+#endif
+#ifndef OVERRIDE_TABLE_64_sys_write
+TRACE_SYSCALL_TABLE(sys_write, sys_write, 6001, 3)
+#endif
+#ifndef OVERRIDE_TABLE_64_sys_open
+TRACE_SYSCALL_TABLE(sys_open, sys_open, 6002, 3)
+#endif
+#ifndef OVERRIDE_TABLE_64_sys_newstat
+TRACE_SYSCALL_TABLE(sys_newstat, sys_newstat, 6004, 2)
+#endif
+#ifndef OVERRIDE_TABLE_64_sys_newfstat
+TRACE_SYSCALL_TABLE(sys_newfstat, sys_newfstat, 6005, 2)
+#endif
+#ifndef OVERRIDE_TABLE_64_sys_newlstat
+TRACE_SYSCALL_TABLE(sys_newlstat, sys_newlstat, 6006, 2)
+#endif
+#ifndef OVERRIDE_TABLE_64_sys_poll
+TRACE_SYSCALL_TABLE(sys_poll, sys_poll, 6007, 3)
+#endif
+#ifndef OVERRIDE_TABLE_64_sys_32_rt_sigaction
+TRACE_SYSCALL_TABLE(sys_32_rt_sigaction, sys_32_rt_sigaction, 6013, 4)
+#endif
+#ifndef OVERRIDE_TABLE_64_sys_32_rt_sigprocmask
+TRACE_SYSCALL_TABLE(sys_32_rt_sigprocmask, sys_32_rt_sigprocmask, 6014, 4)
+#endif
+#ifndef OVERRIDE_TABLE_64_sys_access
+TRACE_SYSCALL_TABLE(sys_access, sys_access, 6020, 2)
+#endif
+#ifndef OVERRIDE_TABLE_64_sys_mincore
+TRACE_SYSCALL_TABLE(sys_mincore, sys_mincore, 6026, 3)
+#endif
+#ifndef OVERRIDE_TABLE_64_sys_shmat
+TRACE_SYSCALL_TABLE(sys_shmat, sys_shmat, 6029, 3)
+#endif
+#ifndef OVERRIDE_TABLE_64_sys_32_sendfile
+TRACE_SYSCALL_TABLE(sys_32_sendfile, sys_32_sendfile, 6039, 4)
+#endif
+#ifndef OVERRIDE_TABLE_64_sys_connect
+TRACE_SYSCALL_TABLE(sys_connect, sys_connect, 6041, 3)
+#endif
+#ifndef OVERRIDE_TABLE_64_sys_accept
+TRACE_SYSCALL_TABLE(sys_accept, sys_accept, 6042, 3)
+#endif
+#ifndef OVERRIDE_TABLE_64_sys_sendto
+TRACE_SYSCALL_TABLE(sys_sendto, sys_sendto, 6043, 6)
+#endif
+#ifndef OVERRIDE_TABLE_64_sys_bind
+TRACE_SYSCALL_TABLE(sys_bind, sys_bind, 6048, 3)
+#endif
+#ifndef OVERRIDE_TABLE_64_sys_getsockname
+TRACE_SYSCALL_TABLE(sys_getsockname, sys_getsockname, 6050, 3)
+#endif
+#ifndef OVERRIDE_TABLE_64_sys_getpeername
+TRACE_SYSCALL_TABLE(sys_getpeername, sys_getpeername, 6051, 3)
+#endif
+#ifndef OVERRIDE_TABLE_64_sys_socketpair
+TRACE_SYSCALL_TABLE(sys_socketpair, sys_socketpair, 6052, 4)
+#endif
+#ifndef OVERRIDE_TABLE_64_sys_getsockopt
+TRACE_SYSCALL_TABLE(sys_getsockopt, sys_getsockopt, 6054, 5)
+#endif
+#ifndef OVERRIDE_TABLE_64_sys_newuname
+TRACE_SYSCALL_TABLE(sys_newuname, sys_newuname, 6061, 1)
+#endif
+#ifndef OVERRIDE_TABLE_64_sys_semop
+TRACE_SYSCALL_TABLE(sys_semop, sys_semop, 6063, 3)
+#endif
+#ifndef OVERRIDE_TABLE_64_sys_shmdt
+TRACE_SYSCALL_TABLE(sys_shmdt, sys_shmdt, 6065, 1)
+#endif
+#ifndef OVERRIDE_TABLE_64_sys_truncate
+TRACE_SYSCALL_TABLE(sys_truncate, sys_truncate, 6074, 2)
+#endif
+#ifndef OVERRIDE_TABLE_64_sys_getcwd
+TRACE_SYSCALL_TABLE(sys_getcwd, sys_getcwd, 6077, 2)
+#endif
+#ifndef OVERRIDE_TABLE_64_sys_chdir
+TRACE_SYSCALL_TABLE(sys_chdir, sys_chdir, 6078, 1)
+#endif
+#ifndef OVERRIDE_TABLE_64_sys_rename
+TRACE_SYSCALL_TABLE(sys_rename, sys_rename, 6080, 2)
+#endif
+#ifndef OVERRIDE_TABLE_64_sys_mkdir
+TRACE_SYSCALL_TABLE(sys_mkdir, sys_mkdir, 6081, 2)
+#endif
+#ifndef OVERRIDE_TABLE_64_sys_rmdir
+TRACE_SYSCALL_TABLE(sys_rmdir, sys_rmdir, 6082, 1)
+#endif
+#ifndef OVERRIDE_TABLE_64_sys_creat
+TRACE_SYSCALL_TABLE(sys_creat, sys_creat, 6083, 2)
+#endif
+#ifndef OVERRIDE_TABLE_64_sys_link
+TRACE_SYSCALL_TABLE(sys_link, sys_link, 6084, 2)
+#endif
+#ifndef OVERRIDE_TABLE_64_sys_unlink
+TRACE_SYSCALL_TABLE(sys_unlink, sys_unlink, 6085, 1)
+#endif
+#ifndef OVERRIDE_TABLE_64_sys_symlink
+TRACE_SYSCALL_TABLE(sys_symlink, sys_symlink, 6086, 2)
+#endif
+#ifndef OVERRIDE_TABLE_64_sys_readlink
+TRACE_SYSCALL_TABLE(sys_readlink, sys_readlink, 6087, 3)
+#endif
+#ifndef OVERRIDE_TABLE_64_sys_chmod
+TRACE_SYSCALL_TABLE(sys_chmod, sys_chmod, 6088, 2)
+#endif
+#ifndef OVERRIDE_TABLE_64_sys_chown
+TRACE_SYSCALL_TABLE(sys_chown, sys_chown, 6090, 3)
+#endif
+#ifndef OVERRIDE_TABLE_64_sys_lchown
+TRACE_SYSCALL_TABLE(sys_lchown, sys_lchown, 6092, 3)
+#endif
+#ifndef OVERRIDE_TABLE_64_sys_syslog
+TRACE_SYSCALL_TABLE(sys_syslog, sys_syslog, 6101, 3)
+#endif
+#ifndef OVERRIDE_TABLE_64_sys_getgroups
+TRACE_SYSCALL_TABLE(sys_getgroups, sys_getgroups, 6113, 2)
+#endif
+#ifndef OVERRIDE_TABLE_64_sys_setgroups
+TRACE_SYSCALL_TABLE(sys_setgroups, sys_setgroups, 6114, 2)
+#endif
+#ifndef OVERRIDE_TABLE_64_sys_getresuid
+TRACE_SYSCALL_TABLE(sys_getresuid, sys_getresuid, 6116, 3)
+#endif
+#ifndef OVERRIDE_TABLE_64_sys_getresgid
+TRACE_SYSCALL_TABLE(sys_getresgid, sys_getresgid, 6118, 3)
+#endif
+#ifndef OVERRIDE_TABLE_64_sys_32_rt_sigpending
+TRACE_SYSCALL_TABLE(sys_32_rt_sigpending, sys_32_rt_sigpending, 6125, 2)
+#endif
+#ifndef OVERRIDE_TABLE_64_sys_32_rt_sigqueueinfo
+TRACE_SYSCALL_TABLE(sys_32_rt_sigqueueinfo, sys_32_rt_sigqueueinfo, 6127, 3)
+#endif
+#ifndef OVERRIDE_TABLE_64_sys_mknod
+TRACE_SYSCALL_TABLE(sys_mknod, sys_mknod, 6131, 3)
+#endif
+#ifndef OVERRIDE_TABLE_64_sys_sched_setparam
+TRACE_SYSCALL_TABLE(sys_sched_setparam, sys_sched_setparam, 6139, 2)
+#endif
+#ifndef OVERRIDE_TABLE_64_sys_sched_getparam
+TRACE_SYSCALL_TABLE(sys_sched_getparam, sys_sched_getparam, 6140, 2)
+#endif
+#ifndef OVERRIDE_TABLE_64_sys_sched_setscheduler
+TRACE_SYSCALL_TABLE(sys_sched_setscheduler, sys_sched_setscheduler, 6141, 3)
+#endif
+#ifndef OVERRIDE_TABLE_64_sys_32_sched_rr_get_interval
+TRACE_SYSCALL_TABLE(sys_32_sched_rr_get_interval, sys_32_sched_rr_get_interval, 6145, 2)
+#endif
+#ifndef OVERRIDE_TABLE_64_sys_pivot_root
+TRACE_SYSCALL_TABLE(sys_pivot_root, sys_pivot_root, 6151, 2)
+#endif
+#ifndef OVERRIDE_TABLE_64_sys_chroot
+TRACE_SYSCALL_TABLE(sys_chroot, sys_chroot, 6156, 1)
+#endif
+#ifndef OVERRIDE_TABLE_64_sys_umount
+TRACE_SYSCALL_TABLE(sys_umount, sys_umount, 6161, 2)
+#endif
+#ifndef OVERRIDE_TABLE_64_sys_swapon
+TRACE_SYSCALL_TABLE(sys_swapon, sys_swapon, 6162, 2)
+#endif
+#ifndef OVERRIDE_TABLE_64_sys_swapoff
+TRACE_SYSCALL_TABLE(sys_swapoff, sys_swapoff, 6163, 1)
+#endif
+#ifndef OVERRIDE_TABLE_64_sys_reboot
+TRACE_SYSCALL_TABLE(sys_reboot, sys_reboot, 6164, 4)
+#endif
+#ifndef OVERRIDE_TABLE_64_sys_sethostname
+TRACE_SYSCALL_TABLE(sys_sethostname, sys_sethostname, 6165, 2)
+#endif
+#ifndef OVERRIDE_TABLE_64_sys_setdomainname
+TRACE_SYSCALL_TABLE(sys_setdomainname, sys_setdomainname, 6166, 2)
+#endif
+#ifndef OVERRIDE_TABLE_64_sys_init_module
+TRACE_SYSCALL_TABLE(sys_init_module, sys_init_module, 6168, 3)
+#endif
+#ifndef OVERRIDE_TABLE_64_sys_delete_module
+TRACE_SYSCALL_TABLE(sys_delete_module, sys_delete_module, 6169, 2)
+#endif
+#ifndef OVERRIDE_TABLE_64_sys_quotactl
+TRACE_SYSCALL_TABLE(sys_quotactl, sys_quotactl, 6172, 4)
+#endif
+#ifndef OVERRIDE_TABLE_64_sys_setxattr
+TRACE_SYSCALL_TABLE(sys_setxattr, sys_setxattr, 6180, 5)
+#endif
+#ifndef OVERRIDE_TABLE_64_sys_lsetxattr
+TRACE_SYSCALL_TABLE(sys_lsetxattr, sys_lsetxattr, 6181, 5)
+#endif
+#ifndef OVERRIDE_TABLE_64_sys_fsetxattr
+TRACE_SYSCALL_TABLE(sys_fsetxattr, sys_fsetxattr, 6182, 5)
+#endif
+#ifndef OVERRIDE_TABLE_64_sys_getxattr
+TRACE_SYSCALL_TABLE(sys_getxattr, sys_getxattr, 6183, 4)
+#endif
+#ifndef OVERRIDE_TABLE_64_sys_lgetxattr
+TRACE_SYSCALL_TABLE(sys_lgetxattr, sys_lgetxattr, 6184, 4)
+#endif
+#ifndef OVERRIDE_TABLE_64_sys_fgetxattr
+TRACE_SYSCALL_TABLE(sys_fgetxattr, sys_fgetxattr, 6185, 4)
+#endif
+#ifndef OVERRIDE_TABLE_64_sys_listxattr
+TRACE_SYSCALL_TABLE(sys_listxattr, sys_listxattr, 6186, 3)
+#endif
+#ifndef OVERRIDE_TABLE_64_sys_llistxattr
+TRACE_SYSCALL_TABLE(sys_llistxattr, sys_llistxattr, 6187, 3)
+#endif
+#ifndef OVERRIDE_TABLE_64_sys_flistxattr
+TRACE_SYSCALL_TABLE(sys_flistxattr, sys_flistxattr, 6188, 3)
+#endif
+#ifndef OVERRIDE_TABLE_64_sys_removexattr
+TRACE_SYSCALL_TABLE(sys_removexattr, sys_removexattr, 6189, 2)
+#endif
+#ifndef OVERRIDE_TABLE_64_sys_lremovexattr
+TRACE_SYSCALL_TABLE(sys_lremovexattr, sys_lremovexattr, 6190, 2)
+#endif
+#ifndef OVERRIDE_TABLE_64_sys_fremovexattr
+TRACE_SYSCALL_TABLE(sys_fremovexattr, sys_fremovexattr, 6191, 2)
+#endif
+#ifndef OVERRIDE_TABLE_64_sys_32_futex
+TRACE_SYSCALL_TABLE(sys_32_futex, sys_32_futex, 6194, 6)
+#endif
+#ifndef OVERRIDE_TABLE_64_sys_cachectl
+TRACE_SYSCALL_TABLE(sys_cachectl, sys_cachectl, 6198, 3)
+#endif
+#ifndef OVERRIDE_TABLE_64_sys_io_cancel
+TRACE_SYSCALL_TABLE(sys_io_cancel, sys_io_cancel, 6204, 3)
+#endif
+#ifndef OVERRIDE_TABLE_64_sys_epoll_ctl
+TRACE_SYSCALL_TABLE(sys_epoll_ctl, sys_epoll_ctl, 6208, 4)
+#endif
+#ifndef OVERRIDE_TABLE_64_sys_epoll_wait
+TRACE_SYSCALL_TABLE(sys_epoll_wait, sys_epoll_wait, 6209, 4)
+#endif
+#ifndef OVERRIDE_TABLE_64_sys_set_tid_address
+TRACE_SYSCALL_TABLE(sys_set_tid_address, sys_set_tid_address, 6213, 1)
+#endif
+#ifndef OVERRIDE_TABLE_64_sys_sendfile64
+TRACE_SYSCALL_TABLE(sys_sendfile64, sys_sendfile64, 6219, 4)
+#endif
+#ifndef OVERRIDE_TABLE_64_sys_inotify_add_watch
+TRACE_SYSCALL_TABLE(sys_inotify_add_watch, sys_inotify_add_watch, 6248, 3)
+#endif
+#ifndef OVERRIDE_TABLE_64_sys_openat
+TRACE_SYSCALL_TABLE(sys_openat, sys_openat, 6251, 4)
+#endif
+#ifndef OVERRIDE_TABLE_64_sys_mkdirat
+TRACE_SYSCALL_TABLE(sys_mkdirat, sys_mkdirat, 6252, 3)
+#endif
+#ifndef OVERRIDE_TABLE_64_sys_mknodat
+TRACE_SYSCALL_TABLE(sys_mknodat, sys_mknodat, 6253, 4)
+#endif
+#ifndef OVERRIDE_TABLE_64_sys_fchownat
+TRACE_SYSCALL_TABLE(sys_fchownat, sys_fchownat, 6254, 5)
+#endif
+#ifndef OVERRIDE_TABLE_64_sys_newfstatat
+TRACE_SYSCALL_TABLE(sys_newfstatat, sys_newfstatat, 6256, 4)
+#endif
+#ifndef OVERRIDE_TABLE_64_sys_unlinkat
+TRACE_SYSCALL_TABLE(sys_unlinkat, sys_unlinkat, 6257, 3)
+#endif
+#ifndef OVERRIDE_TABLE_64_sys_renameat
+TRACE_SYSCALL_TABLE(sys_renameat, sys_renameat, 6258, 4)
+#endif
+#ifndef OVERRIDE_TABLE_64_sys_linkat
+TRACE_SYSCALL_TABLE(sys_linkat, sys_linkat, 6259, 5)
+#endif
+#ifndef OVERRIDE_TABLE_64_sys_symlinkat
+TRACE_SYSCALL_TABLE(sys_symlinkat, sys_symlinkat, 6260, 3)
+#endif
+#ifndef OVERRIDE_TABLE_64_sys_readlinkat
+TRACE_SYSCALL_TABLE(sys_readlinkat, sys_readlinkat, 6261, 4)
+#endif
+#ifndef OVERRIDE_TABLE_64_sys_fchmodat
+TRACE_SYSCALL_TABLE(sys_fchmodat, sys_fchmodat, 6262, 3)
+#endif
+#ifndef OVERRIDE_TABLE_64_sys_faccessat
+TRACE_SYSCALL_TABLE(sys_faccessat, sys_faccessat, 6263, 3)
+#endif
+#ifndef OVERRIDE_TABLE_64_sys_splice
+TRACE_SYSCALL_TABLE(sys_splice, sys_splice, 6267, 6)
+#endif
+#ifndef OVERRIDE_TABLE_64_sys_getcpu
+TRACE_SYSCALL_TABLE(sys_getcpu, sys_getcpu, 6275, 3)
+#endif
+#ifndef OVERRIDE_TABLE_64_sys_signalfd4
+TRACE_SYSCALL_TABLE(sys_signalfd4, sys_signalfd4, 6287, 4)
+#endif
+#ifndef OVERRIDE_TABLE_64_sys_pipe2
+TRACE_SYSCALL_TABLE(sys_pipe2, sys_pipe2, 6291, 2)
+#endif
+#ifndef OVERRIDE_TABLE_64_sys_preadv
+TRACE_SYSCALL_TABLE(sys_preadv, sys_preadv, 6293, 5)
+#endif
+#ifndef OVERRIDE_TABLE_64_sys_pwritev
+TRACE_SYSCALL_TABLE(sys_pwritev, sys_pwritev, 6294, 5)
+#endif
+#ifndef OVERRIDE_TABLE_64_sys_accept4
+TRACE_SYSCALL_TABLE(sys_accept4, sys_accept4, 6297, 4)
+#endif
+#ifndef OVERRIDE_TABLE_64_sys_getdents64
+TRACE_SYSCALL_TABLE(sys_getdents64, sys_getdents64, 6299, 3)
+#endif
+#ifndef OVERRIDE_TABLE_64_sys_prlimit64
+TRACE_SYSCALL_TABLE(sys_prlimit64, sys_prlimit64, 6302, 4)
+#endif
+
+#endif /* CREATE_SYSCALL_TABLE */
diff --git a/drivers/staging/lttng/instrumentation/syscalls/headers/mips-64-syscalls-3.5.0_pointers_override.h b/drivers/staging/lttng/instrumentation/syscalls/headers/mips-64-syscalls-3.5.0_pointers_override.h
new file mode 100644 (file)
index 0000000..53f92db
--- /dev/null
@@ -0,0 +1,8 @@
+#ifndef CREATE_SYSCALL_TABLE
+
+#else  /* CREATE_SYSCALL_TABLE */
+
+#define OVERRIDE_TABLE_64_sys_clone
+TRACE_SYSCALL_TABLE(sys_clone, sys_clone, 5055, 0)
+
+#endif /* CREATE_SYSCALL_TABLE */
diff --git a/drivers/staging/lttng/instrumentation/syscalls/headers/powerpc-32-syscalls-3.0.34_integers.h b/drivers/staging/lttng/instrumentation/syscalls/headers/powerpc-32-syscalls-3.0.34_integers.h
new file mode 100644 (file)
index 0000000..d61d044
--- /dev/null
@@ -0,0 +1,1043 @@
+/* THIS FILE IS AUTO-GENERATED. DO NOT EDIT */
+#ifndef CREATE_SYSCALL_TABLE
+
+#if !defined(_TRACE_SYSCALLS_INTEGERS_H) || defined(TRACE_HEADER_MULTI_READ)
+#define _TRACE_SYSCALLS_INTEGERS_H
+
+#include <linux/tracepoint.h>
+#include <linux/syscalls.h>
+#include "powerpc-32-syscalls-3.0.34_integers_override.h"
+#include "syscalls_integers_override.h"
+
+SC_DECLARE_EVENT_CLASS_NOARGS(syscalls_noargs,
+       TP_STRUCT__entry(),
+       TP_fast_assign(),
+       TP_printk()
+)
+#ifndef OVERRIDE_32_sys_restart_syscall
+SC_DEFINE_EVENT_NOARGS(syscalls_noargs, sys_restart_syscall)
+#endif
+#ifndef OVERRIDE_32_sys_getpid
+SC_DEFINE_EVENT_NOARGS(syscalls_noargs, sys_getpid)
+#endif
+#ifndef OVERRIDE_32_sys_getuid
+SC_DEFINE_EVENT_NOARGS(syscalls_noargs, sys_getuid)
+#endif
+#ifndef OVERRIDE_32_sys_pause
+SC_DEFINE_EVENT_NOARGS(syscalls_noargs, sys_pause)
+#endif
+#ifndef OVERRIDE_32_sys_sync
+SC_DEFINE_EVENT_NOARGS(syscalls_noargs, sys_sync)
+#endif
+#ifndef OVERRIDE_32_sys_getgid
+SC_DEFINE_EVENT_NOARGS(syscalls_noargs, sys_getgid)
+#endif
+#ifndef OVERRIDE_32_sys_geteuid
+SC_DEFINE_EVENT_NOARGS(syscalls_noargs, sys_geteuid)
+#endif
+#ifndef OVERRIDE_32_sys_getegid
+SC_DEFINE_EVENT_NOARGS(syscalls_noargs, sys_getegid)
+#endif
+#ifndef OVERRIDE_32_sys_getppid
+SC_DEFINE_EVENT_NOARGS(syscalls_noargs, sys_getppid)
+#endif
+#ifndef OVERRIDE_32_sys_getpgrp
+SC_DEFINE_EVENT_NOARGS(syscalls_noargs, sys_getpgrp)
+#endif
+#ifndef OVERRIDE_32_sys_setsid
+SC_DEFINE_EVENT_NOARGS(syscalls_noargs, sys_setsid)
+#endif
+#ifndef OVERRIDE_32_sys_sgetmask
+SC_DEFINE_EVENT_NOARGS(syscalls_noargs, sys_sgetmask)
+#endif
+#ifndef OVERRIDE_32_sys_vhangup
+SC_DEFINE_EVENT_NOARGS(syscalls_noargs, sys_vhangup)
+#endif
+#ifndef OVERRIDE_32_sys_munlockall
+SC_DEFINE_EVENT_NOARGS(syscalls_noargs, sys_munlockall)
+#endif
+#ifndef OVERRIDE_32_sys_sched_yield
+SC_DEFINE_EVENT_NOARGS(syscalls_noargs, sys_sched_yield)
+#endif
+#ifndef OVERRIDE_32_sys_gettid
+SC_DEFINE_EVENT_NOARGS(syscalls_noargs, sys_gettid)
+#endif
+#ifndef OVERRIDE_32_sys_inotify_init
+SC_DEFINE_EVENT_NOARGS(syscalls_noargs, sys_inotify_init)
+#endif
+#ifndef OVERRIDE_32_sys_exit
+SC_TRACE_EVENT(sys_exit,
+       TP_PROTO(int error_code),
+       TP_ARGS(error_code),
+       TP_STRUCT__entry(__field(int, error_code)),
+       TP_fast_assign(tp_assign(error_code, error_code)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_close
+SC_TRACE_EVENT(sys_close,
+       TP_PROTO(unsigned int fd),
+       TP_ARGS(fd),
+       TP_STRUCT__entry(__field(unsigned int, fd)),
+       TP_fast_assign(tp_assign(fd, fd)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_setuid
+SC_TRACE_EVENT(sys_setuid,
+       TP_PROTO(uid_t uid),
+       TP_ARGS(uid),
+       TP_STRUCT__entry(__field(uid_t, uid)),
+       TP_fast_assign(tp_assign(uid, uid)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_alarm
+SC_TRACE_EVENT(sys_alarm,
+       TP_PROTO(unsigned int seconds),
+       TP_ARGS(seconds),
+       TP_STRUCT__entry(__field(unsigned int, seconds)),
+       TP_fast_assign(tp_assign(seconds, seconds)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_nice
+SC_TRACE_EVENT(sys_nice,
+       TP_PROTO(int increment),
+       TP_ARGS(increment),
+       TP_STRUCT__entry(__field(int, increment)),
+       TP_fast_assign(tp_assign(increment, increment)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_dup
+SC_TRACE_EVENT(sys_dup,
+       TP_PROTO(unsigned int fildes),
+       TP_ARGS(fildes),
+       TP_STRUCT__entry(__field(unsigned int, fildes)),
+       TP_fast_assign(tp_assign(fildes, fildes)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_brk
+SC_TRACE_EVENT(sys_brk,
+       TP_PROTO(unsigned long brk),
+       TP_ARGS(brk),
+       TP_STRUCT__entry(__field(unsigned long, brk)),
+       TP_fast_assign(tp_assign(brk, brk)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_setgid
+SC_TRACE_EVENT(sys_setgid,
+       TP_PROTO(gid_t gid),
+       TP_ARGS(gid),
+       TP_STRUCT__entry(__field(gid_t, gid)),
+       TP_fast_assign(tp_assign(gid, gid)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_umask
+SC_TRACE_EVENT(sys_umask,
+       TP_PROTO(int mask),
+       TP_ARGS(mask),
+       TP_STRUCT__entry(__field(int, mask)),
+       TP_fast_assign(tp_assign(mask, mask)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_ssetmask
+SC_TRACE_EVENT(sys_ssetmask,
+       TP_PROTO(int newmask),
+       TP_ARGS(newmask),
+       TP_STRUCT__entry(__field(int, newmask)),
+       TP_fast_assign(tp_assign(newmask, newmask)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_fsync
+SC_TRACE_EVENT(sys_fsync,
+       TP_PROTO(unsigned int fd),
+       TP_ARGS(fd),
+       TP_STRUCT__entry(__field(unsigned int, fd)),
+       TP_fast_assign(tp_assign(fd, fd)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_getpgid
+SC_TRACE_EVENT(sys_getpgid,
+       TP_PROTO(pid_t pid),
+       TP_ARGS(pid),
+       TP_STRUCT__entry(__field(pid_t, pid)),
+       TP_fast_assign(tp_assign(pid, pid)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_fchdir
+SC_TRACE_EVENT(sys_fchdir,
+       TP_PROTO(unsigned int fd),
+       TP_ARGS(fd),
+       TP_STRUCT__entry(__field(unsigned int, fd)),
+       TP_fast_assign(tp_assign(fd, fd)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_personality
+SC_TRACE_EVENT(sys_personality,
+       TP_PROTO(unsigned int personality),
+       TP_ARGS(personality),
+       TP_STRUCT__entry(__field(unsigned int, personality)),
+       TP_fast_assign(tp_assign(personality, personality)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_setfsuid
+SC_TRACE_EVENT(sys_setfsuid,
+       TP_PROTO(uid_t uid),
+       TP_ARGS(uid),
+       TP_STRUCT__entry(__field(uid_t, uid)),
+       TP_fast_assign(tp_assign(uid, uid)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_setfsgid
+SC_TRACE_EVENT(sys_setfsgid,
+       TP_PROTO(gid_t gid),
+       TP_ARGS(gid),
+       TP_STRUCT__entry(__field(gid_t, gid)),
+       TP_fast_assign(tp_assign(gid, gid)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_getsid
+SC_TRACE_EVENT(sys_getsid,
+       TP_PROTO(pid_t pid),
+       TP_ARGS(pid),
+       TP_STRUCT__entry(__field(pid_t, pid)),
+       TP_fast_assign(tp_assign(pid, pid)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_fdatasync
+SC_TRACE_EVENT(sys_fdatasync,
+       TP_PROTO(unsigned int fd),
+       TP_ARGS(fd),
+       TP_STRUCT__entry(__field(unsigned int, fd)),
+       TP_fast_assign(tp_assign(fd, fd)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_mlockall
+SC_TRACE_EVENT(sys_mlockall,
+       TP_PROTO(int flags),
+       TP_ARGS(flags),
+       TP_STRUCT__entry(__field(int, flags)),
+       TP_fast_assign(tp_assign(flags, flags)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_sched_getscheduler
+SC_TRACE_EVENT(sys_sched_getscheduler,
+       TP_PROTO(pid_t pid),
+       TP_ARGS(pid),
+       TP_STRUCT__entry(__field(pid_t, pid)),
+       TP_fast_assign(tp_assign(pid, pid)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_sched_get_priority_max
+SC_TRACE_EVENT(sys_sched_get_priority_max,
+       TP_PROTO(int policy),
+       TP_ARGS(policy),
+       TP_STRUCT__entry(__field(int, policy)),
+       TP_fast_assign(tp_assign(policy, policy)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_sched_get_priority_min
+SC_TRACE_EVENT(sys_sched_get_priority_min,
+       TP_PROTO(int policy),
+       TP_ARGS(policy),
+       TP_STRUCT__entry(__field(int, policy)),
+       TP_fast_assign(tp_assign(policy, policy)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_io_destroy
+SC_TRACE_EVENT(sys_io_destroy,
+       TP_PROTO(aio_context_t ctx),
+       TP_ARGS(ctx),
+       TP_STRUCT__entry(__field(aio_context_t, ctx)),
+       TP_fast_assign(tp_assign(ctx, ctx)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_exit_group
+SC_TRACE_EVENT(sys_exit_group,
+       TP_PROTO(int error_code),
+       TP_ARGS(error_code),
+       TP_STRUCT__entry(__field(int, error_code)),
+       TP_fast_assign(tp_assign(error_code, error_code)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_epoll_create
+SC_TRACE_EVENT(sys_epoll_create,
+       TP_PROTO(int size),
+       TP_ARGS(size),
+       TP_STRUCT__entry(__field(int, size)),
+       TP_fast_assign(tp_assign(size, size)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_timer_getoverrun
+SC_TRACE_EVENT(sys_timer_getoverrun,
+       TP_PROTO(timer_t timer_id),
+       TP_ARGS(timer_id),
+       TP_STRUCT__entry(__field(timer_t, timer_id)),
+       TP_fast_assign(tp_assign(timer_id, timer_id)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_timer_delete
+SC_TRACE_EVENT(sys_timer_delete,
+       TP_PROTO(timer_t timer_id),
+       TP_ARGS(timer_id),
+       TP_STRUCT__entry(__field(timer_t, timer_id)),
+       TP_fast_assign(tp_assign(timer_id, timer_id)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_unshare
+SC_TRACE_EVENT(sys_unshare,
+       TP_PROTO(unsigned long unshare_flags),
+       TP_ARGS(unshare_flags),
+       TP_STRUCT__entry(__field(unsigned long, unshare_flags)),
+       TP_fast_assign(tp_assign(unshare_flags, unshare_flags)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_eventfd
+SC_TRACE_EVENT(sys_eventfd,
+       TP_PROTO(unsigned int count),
+       TP_ARGS(count),
+       TP_STRUCT__entry(__field(unsigned int, count)),
+       TP_fast_assign(tp_assign(count, count)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_epoll_create1
+SC_TRACE_EVENT(sys_epoll_create1,
+       TP_PROTO(int flags),
+       TP_ARGS(flags),
+       TP_STRUCT__entry(__field(int, flags)),
+       TP_fast_assign(tp_assign(flags, flags)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_inotify_init1
+SC_TRACE_EVENT(sys_inotify_init1,
+       TP_PROTO(int flags),
+       TP_ARGS(flags),
+       TP_STRUCT__entry(__field(int, flags)),
+       TP_fast_assign(tp_assign(flags, flags)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_syncfs
+SC_TRACE_EVENT(sys_syncfs,
+       TP_PROTO(int fd),
+       TP_ARGS(fd),
+       TP_STRUCT__entry(__field(int, fd)),
+       TP_fast_assign(tp_assign(fd, fd)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_kill
+SC_TRACE_EVENT(sys_kill,
+       TP_PROTO(pid_t pid, int sig),
+       TP_ARGS(pid, sig),
+       TP_STRUCT__entry(__field(pid_t, pid) __field(int, sig)),
+       TP_fast_assign(tp_assign(pid, pid) tp_assign(sig, sig)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_signal
+SC_TRACE_EVENT(sys_signal,
+       TP_PROTO(int sig, __sighandler_t handler),
+       TP_ARGS(sig, handler),
+       TP_STRUCT__entry(__field(int, sig) __field(__sighandler_t, handler)),
+       TP_fast_assign(tp_assign(sig, sig) tp_assign(handler, handler)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_setpgid
+SC_TRACE_EVENT(sys_setpgid,
+       TP_PROTO(pid_t pid, pid_t pgid),
+       TP_ARGS(pid, pgid),
+       TP_STRUCT__entry(__field(pid_t, pid) __field(pid_t, pgid)),
+       TP_fast_assign(tp_assign(pid, pid) tp_assign(pgid, pgid)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_dup2
+SC_TRACE_EVENT(sys_dup2,
+       TP_PROTO(unsigned int oldfd, unsigned int newfd),
+       TP_ARGS(oldfd, newfd),
+       TP_STRUCT__entry(__field(unsigned int, oldfd) __field(unsigned int, newfd)),
+       TP_fast_assign(tp_assign(oldfd, oldfd) tp_assign(newfd, newfd)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_setreuid
+SC_TRACE_EVENT(sys_setreuid,
+       TP_PROTO(uid_t ruid, uid_t euid),
+       TP_ARGS(ruid, euid),
+       TP_STRUCT__entry(__field(uid_t, ruid) __field(uid_t, euid)),
+       TP_fast_assign(tp_assign(ruid, ruid) tp_assign(euid, euid)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_setregid
+SC_TRACE_EVENT(sys_setregid,
+       TP_PROTO(gid_t rgid, gid_t egid),
+       TP_ARGS(rgid, egid),
+       TP_STRUCT__entry(__field(gid_t, rgid) __field(gid_t, egid)),
+       TP_fast_assign(tp_assign(rgid, rgid) tp_assign(egid, egid)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_munmap
+SC_TRACE_EVENT(sys_munmap,
+       TP_PROTO(unsigned long addr, size_t len),
+       TP_ARGS(addr, len),
+       TP_STRUCT__entry(__field_hex(unsigned long, addr) __field(size_t, len)),
+       TP_fast_assign(tp_assign(addr, addr) tp_assign(len, len)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_ftruncate
+SC_TRACE_EVENT(sys_ftruncate,
+       TP_PROTO(unsigned int fd, unsigned long length),
+       TP_ARGS(fd, length),
+       TP_STRUCT__entry(__field(unsigned int, fd) __field(unsigned long, length)),
+       TP_fast_assign(tp_assign(fd, fd) tp_assign(length, length)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_fchmod
+SC_TRACE_EVENT(sys_fchmod,
+       TP_PROTO(unsigned int fd, mode_t mode),
+       TP_ARGS(fd, mode),
+       TP_STRUCT__entry(__field(unsigned int, fd) __field(mode_t, mode)),
+       TP_fast_assign(tp_assign(fd, fd) tp_assign(mode, mode)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_getpriority
+SC_TRACE_EVENT(sys_getpriority,
+       TP_PROTO(int which, int who),
+       TP_ARGS(which, who),
+       TP_STRUCT__entry(__field(int, which) __field(int, who)),
+       TP_fast_assign(tp_assign(which, which) tp_assign(who, who)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_bdflush
+SC_TRACE_EVENT(sys_bdflush,
+       TP_PROTO(int func, long data),
+       TP_ARGS(func, data),
+       TP_STRUCT__entry(__field(int, func) __field(long, data)),
+       TP_fast_assign(tp_assign(func, func) tp_assign(data, data)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_flock
+SC_TRACE_EVENT(sys_flock,
+       TP_PROTO(unsigned int fd, unsigned int cmd),
+       TP_ARGS(fd, cmd),
+       TP_STRUCT__entry(__field(unsigned int, fd) __field(unsigned int, cmd)),
+       TP_fast_assign(tp_assign(fd, fd) tp_assign(cmd, cmd)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_mlock
+SC_TRACE_EVENT(sys_mlock,
+       TP_PROTO(unsigned long start, size_t len),
+       TP_ARGS(start, len),
+       TP_STRUCT__entry(__field(unsigned long, start) __field(size_t, len)),
+       TP_fast_assign(tp_assign(start, start) tp_assign(len, len)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_munlock
+SC_TRACE_EVENT(sys_munlock,
+       TP_PROTO(unsigned long start, size_t len),
+       TP_ARGS(start, len),
+       TP_STRUCT__entry(__field(unsigned long, start) __field(size_t, len)),
+       TP_fast_assign(tp_assign(start, start) tp_assign(len, len)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_tkill
+SC_TRACE_EVENT(sys_tkill,
+       TP_PROTO(pid_t pid, int sig),
+       TP_ARGS(pid, sig),
+       TP_STRUCT__entry(__field(pid_t, pid) __field(int, sig)),
+       TP_fast_assign(tp_assign(pid, pid) tp_assign(sig, sig)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_ioprio_get
+SC_TRACE_EVENT(sys_ioprio_get,
+       TP_PROTO(int which, int who),
+       TP_ARGS(which, who),
+       TP_STRUCT__entry(__field(int, which) __field(int, who)),
+       TP_fast_assign(tp_assign(which, which) tp_assign(who, who)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_inotify_rm_watch
+SC_TRACE_EVENT(sys_inotify_rm_watch,
+       TP_PROTO(int fd, __s32 wd),
+       TP_ARGS(fd, wd),
+       TP_STRUCT__entry(__field(int, fd) __field(__s32, wd)),
+       TP_fast_assign(tp_assign(fd, fd) tp_assign(wd, wd)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_timerfd_create
+SC_TRACE_EVENT(sys_timerfd_create,
+       TP_PROTO(int clockid, int flags),
+       TP_ARGS(clockid, flags),
+       TP_STRUCT__entry(__field(int, clockid) __field(int, flags)),
+       TP_fast_assign(tp_assign(clockid, clockid) tp_assign(flags, flags)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_eventfd2
+SC_TRACE_EVENT(sys_eventfd2,
+       TP_PROTO(unsigned int count, int flags),
+       TP_ARGS(count, flags),
+       TP_STRUCT__entry(__field(unsigned int, count) __field(int, flags)),
+       TP_fast_assign(tp_assign(count, count) tp_assign(flags, flags)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_listen
+SC_TRACE_EVENT(sys_listen,
+       TP_PROTO(int fd, int backlog),
+       TP_ARGS(fd, backlog),
+       TP_STRUCT__entry(__field(int, fd) __field(int, backlog)),
+       TP_fast_assign(tp_assign(fd, fd) tp_assign(backlog, backlog)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_shutdown
+SC_TRACE_EVENT(sys_shutdown,
+       TP_PROTO(int fd, int how),
+       TP_ARGS(fd, how),
+       TP_STRUCT__entry(__field(int, fd) __field(int, how)),
+       TP_fast_assign(tp_assign(fd, fd) tp_assign(how, how)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_setns
+SC_TRACE_EVENT(sys_setns,
+       TP_PROTO(int fd, int nstype),
+       TP_ARGS(fd, nstype),
+       TP_STRUCT__entry(__field(int, fd) __field(int, nstype)),
+       TP_fast_assign(tp_assign(fd, fd) tp_assign(nstype, nstype)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_lseek
+SC_TRACE_EVENT(sys_lseek,
+       TP_PROTO(unsigned int fd, off_t offset, unsigned int origin),
+       TP_ARGS(fd, offset, origin),
+       TP_STRUCT__entry(__field(unsigned int, fd) __field(off_t, offset) __field(unsigned int, origin)),
+       TP_fast_assign(tp_assign(fd, fd) tp_assign(offset, offset) tp_assign(origin, origin)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_ioctl
+SC_TRACE_EVENT(sys_ioctl,
+       TP_PROTO(unsigned int fd, unsigned int cmd, unsigned long arg),
+       TP_ARGS(fd, cmd, arg),
+       TP_STRUCT__entry(__field(unsigned int, fd) __field(unsigned int, cmd) __field(unsigned long, arg)),
+       TP_fast_assign(tp_assign(fd, fd) tp_assign(cmd, cmd) tp_assign(arg, arg)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_fcntl
+SC_TRACE_EVENT(sys_fcntl,
+       TP_PROTO(unsigned int fd, unsigned int cmd, unsigned long arg),
+       TP_ARGS(fd, cmd, arg),
+       TP_STRUCT__entry(__field(unsigned int, fd) __field(unsigned int, cmd) __field(unsigned long, arg)),
+       TP_fast_assign(tp_assign(fd, fd) tp_assign(cmd, cmd) tp_assign(arg, arg)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_fchown
+SC_TRACE_EVENT(sys_fchown,
+       TP_PROTO(unsigned int fd, uid_t user, gid_t group),
+       TP_ARGS(fd, user, group),
+       TP_STRUCT__entry(__field(unsigned int, fd) __field(uid_t, user) __field(gid_t, group)),
+       TP_fast_assign(tp_assign(fd, fd) tp_assign(user, user) tp_assign(group, group)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_setpriority
+SC_TRACE_EVENT(sys_setpriority,
+       TP_PROTO(int which, int who, int niceval),
+       TP_ARGS(which, who, niceval),
+       TP_STRUCT__entry(__field(int, which) __field(int, who) __field(int, niceval)),
+       TP_fast_assign(tp_assign(which, which) tp_assign(who, who) tp_assign(niceval, niceval)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_mprotect
+SC_TRACE_EVENT(sys_mprotect,
+       TP_PROTO(unsigned long start, size_t len, unsigned long prot),
+       TP_ARGS(start, len, prot),
+       TP_STRUCT__entry(__field(unsigned long, start) __field(size_t, len) __field(unsigned long, prot)),
+       TP_fast_assign(tp_assign(start, start) tp_assign(len, len) tp_assign(prot, prot)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_sysfs
+SC_TRACE_EVENT(sys_sysfs,
+       TP_PROTO(int option, unsigned long arg1, unsigned long arg2),
+       TP_ARGS(option, arg1, arg2),
+       TP_STRUCT__entry(__field(int, option) __field(unsigned long, arg1) __field(unsigned long, arg2)),
+       TP_fast_assign(tp_assign(option, option) tp_assign(arg1, arg1) tp_assign(arg2, arg2)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_msync
+SC_TRACE_EVENT(sys_msync,
+       TP_PROTO(unsigned long start, size_t len, int flags),
+       TP_ARGS(start, len, flags),
+       TP_STRUCT__entry(__field(unsigned long, start) __field(size_t, len) __field(int, flags)),
+       TP_fast_assign(tp_assign(start, start) tp_assign(len, len) tp_assign(flags, flags)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_setresuid
+SC_TRACE_EVENT(sys_setresuid,
+       TP_PROTO(uid_t ruid, uid_t euid, uid_t suid),
+       TP_ARGS(ruid, euid, suid),
+       TP_STRUCT__entry(__field(uid_t, ruid) __field(uid_t, euid) __field(uid_t, suid)),
+       TP_fast_assign(tp_assign(ruid, ruid) tp_assign(euid, euid) tp_assign(suid, suid)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_setresgid
+SC_TRACE_EVENT(sys_setresgid,
+       TP_PROTO(gid_t rgid, gid_t egid, gid_t sgid),
+       TP_ARGS(rgid, egid, sgid),
+       TP_STRUCT__entry(__field(gid_t, rgid) __field(gid_t, egid) __field(gid_t, sgid)),
+       TP_fast_assign(tp_assign(rgid, rgid) tp_assign(egid, egid) tp_assign(sgid, sgid)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_fcntl64
+SC_TRACE_EVENT(sys_fcntl64,
+       TP_PROTO(unsigned int fd, unsigned int cmd, unsigned long arg),
+       TP_ARGS(fd, cmd, arg),
+       TP_STRUCT__entry(__field(unsigned int, fd) __field(unsigned int, cmd) __field(unsigned long, arg)),
+       TP_fast_assign(tp_assign(fd, fd) tp_assign(cmd, cmd) tp_assign(arg, arg)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_madvise
+SC_TRACE_EVENT(sys_madvise,
+       TP_PROTO(unsigned long start, size_t len_in, int behavior),
+       TP_ARGS(start, len_in, behavior),
+       TP_STRUCT__entry(__field(unsigned long, start) __field(size_t, len_in) __field(int, behavior)),
+       TP_fast_assign(tp_assign(start, start) tp_assign(len_in, len_in) tp_assign(behavior, behavior)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_tgkill
+SC_TRACE_EVENT(sys_tgkill,
+       TP_PROTO(pid_t tgid, pid_t pid, int sig),
+       TP_ARGS(tgid, pid, sig),
+       TP_STRUCT__entry(__field(pid_t, tgid) __field(pid_t, pid) __field(int, sig)),
+       TP_fast_assign(tp_assign(tgid, tgid) tp_assign(pid, pid) tp_assign(sig, sig)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_ioprio_set
+SC_TRACE_EVENT(sys_ioprio_set,
+       TP_PROTO(int which, int who, int ioprio),
+       TP_ARGS(which, who, ioprio),
+       TP_STRUCT__entry(__field(int, which) __field(int, who) __field(int, ioprio)),
+       TP_fast_assign(tp_assign(which, which) tp_assign(who, who) tp_assign(ioprio, ioprio)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_dup3
+SC_TRACE_EVENT(sys_dup3,
+       TP_PROTO(unsigned int oldfd, unsigned int newfd, int flags),
+       TP_ARGS(oldfd, newfd, flags),
+       TP_STRUCT__entry(__field(unsigned int, oldfd) __field(unsigned int, newfd) __field(int, flags)),
+       TP_fast_assign(tp_assign(oldfd, oldfd) tp_assign(newfd, newfd) tp_assign(flags, flags)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_socket
+SC_TRACE_EVENT(sys_socket,
+       TP_PROTO(int family, int type, int protocol),
+       TP_ARGS(family, type, protocol),
+       TP_STRUCT__entry(__field(int, family) __field(int, type) __field(int, protocol)),
+       TP_fast_assign(tp_assign(family, family) tp_assign(type, type) tp_assign(protocol, protocol)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_ptrace
+SC_TRACE_EVENT(sys_ptrace,
+       TP_PROTO(long request, long pid, unsigned long addr, unsigned long data),
+       TP_ARGS(request, pid, addr, data),
+       TP_STRUCT__entry(__field(long, request) __field(long, pid) __field_hex(unsigned long, addr) __field(unsigned long, data)),
+       TP_fast_assign(tp_assign(request, request) tp_assign(pid, pid) tp_assign(addr, addr) tp_assign(data, data)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_tee
+SC_TRACE_EVENT(sys_tee,
+       TP_PROTO(int fdin, int fdout, size_t len, unsigned int flags),
+       TP_ARGS(fdin, fdout, len, flags),
+       TP_STRUCT__entry(__field(int, fdin) __field(int, fdout) __field(size_t, len) __field(unsigned int, flags)),
+       TP_fast_assign(tp_assign(fdin, fdin) tp_assign(fdout, fdout) tp_assign(len, len) tp_assign(flags, flags)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_mremap
+SC_TRACE_EVENT(sys_mremap,
+       TP_PROTO(unsigned long addr, unsigned long old_len, unsigned long new_len, unsigned long flags, unsigned long new_addr),
+       TP_ARGS(addr, old_len, new_len, flags, new_addr),
+       TP_STRUCT__entry(__field_hex(unsigned long, addr) __field(unsigned long, old_len) __field(unsigned long, new_len) __field(unsigned long, flags) __field_hex(unsigned long, new_addr)),
+       TP_fast_assign(tp_assign(addr, addr) tp_assign(old_len, old_len) tp_assign(new_len, new_len) tp_assign(flags, flags) tp_assign(new_addr, new_addr)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_prctl
+SC_TRACE_EVENT(sys_prctl,
+       TP_PROTO(int option, unsigned long arg2, unsigned long arg3, unsigned long arg4, unsigned long arg5),
+       TP_ARGS(option, arg2, arg3, arg4, arg5),
+       TP_STRUCT__entry(__field(int, option) __field(unsigned long, arg2) __field(unsigned long, arg3) __field(unsigned long, arg4) __field(unsigned long, arg5)),
+       TP_fast_assign(tp_assign(option, option) tp_assign(arg2, arg2) tp_assign(arg3, arg3) tp_assign(arg4, arg4) tp_assign(arg5, arg5)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_remap_file_pages
+SC_TRACE_EVENT(sys_remap_file_pages,
+       TP_PROTO(unsigned long start, unsigned long size, unsigned long prot, unsigned long pgoff, unsigned long flags),
+       TP_ARGS(start, size, prot, pgoff, flags),
+       TP_STRUCT__entry(__field(unsigned long, start) __field(unsigned long, size) __field(unsigned long, prot) __field(unsigned long, pgoff) __field(unsigned long, flags)),
+       TP_fast_assign(tp_assign(start, start) tp_assign(size, size) tp_assign(prot, prot) tp_assign(pgoff, pgoff) tp_assign(flags, flags)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_keyctl
+SC_TRACE_EVENT(sys_keyctl,
+       TP_PROTO(int option, unsigned long arg2, unsigned long arg3, unsigned long arg4, unsigned long arg5),
+       TP_ARGS(option, arg2, arg3, arg4, arg5),
+       TP_STRUCT__entry(__field(int, option) __field(unsigned long, arg2) __field(unsigned long, arg3) __field(unsigned long, arg4) __field(unsigned long, arg5)),
+       TP_fast_assign(tp_assign(option, option) tp_assign(arg2, arg2) tp_assign(arg3, arg3) tp_assign(arg4, arg4) tp_assign(arg5, arg5)),
+       TP_printk()
+)
+#endif
+
+#endif /*  _TRACE_SYSCALLS_INTEGERS_H */
+
+/* This part must be outside protection */
+#include "../../../probes/define_trace.h"
+
+#else /* CREATE_SYSCALL_TABLE */
+
+#include "powerpc-32-syscalls-3.0.34_integers_override.h"
+#include "syscalls_integers_override.h"
+
+#ifndef OVERRIDE_TABLE_32_sys_restart_syscall
+TRACE_SYSCALL_TABLE(syscalls_noargs, sys_restart_syscall, 0, 0)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_getpid
+TRACE_SYSCALL_TABLE(syscalls_noargs, sys_getpid, 20, 0)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_getuid
+TRACE_SYSCALL_TABLE(syscalls_noargs, sys_getuid, 24, 0)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_pause
+TRACE_SYSCALL_TABLE(syscalls_noargs, sys_pause, 29, 0)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_sync
+TRACE_SYSCALL_TABLE(syscalls_noargs, sys_sync, 36, 0)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_getgid
+TRACE_SYSCALL_TABLE(syscalls_noargs, sys_getgid, 47, 0)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_geteuid
+TRACE_SYSCALL_TABLE(syscalls_noargs, sys_geteuid, 49, 0)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_getegid
+TRACE_SYSCALL_TABLE(syscalls_noargs, sys_getegid, 50, 0)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_getppid
+TRACE_SYSCALL_TABLE(syscalls_noargs, sys_getppid, 64, 0)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_getpgrp
+TRACE_SYSCALL_TABLE(syscalls_noargs, sys_getpgrp, 65, 0)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_setsid
+TRACE_SYSCALL_TABLE(syscalls_noargs, sys_setsid, 66, 0)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_sgetmask
+TRACE_SYSCALL_TABLE(syscalls_noargs, sys_sgetmask, 68, 0)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_vhangup
+TRACE_SYSCALL_TABLE(syscalls_noargs, sys_vhangup, 111, 0)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_munlockall
+TRACE_SYSCALL_TABLE(syscalls_noargs, sys_munlockall, 153, 0)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_sched_yield
+TRACE_SYSCALL_TABLE(syscalls_noargs, sys_sched_yield, 158, 0)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_gettid
+TRACE_SYSCALL_TABLE(syscalls_noargs, sys_gettid, 207, 0)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_inotify_init
+TRACE_SYSCALL_TABLE(syscalls_noargs, sys_inotify_init, 275, 0)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_exit
+TRACE_SYSCALL_TABLE(sys_exit, sys_exit, 1, 1)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_close
+TRACE_SYSCALL_TABLE(sys_close, sys_close, 6, 1)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_lseek
+TRACE_SYSCALL_TABLE(sys_lseek, sys_lseek, 19, 3)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_setuid
+TRACE_SYSCALL_TABLE(sys_setuid, sys_setuid, 23, 1)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_ptrace
+TRACE_SYSCALL_TABLE(sys_ptrace, sys_ptrace, 26, 4)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_alarm
+TRACE_SYSCALL_TABLE(sys_alarm, sys_alarm, 27, 1)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_nice
+TRACE_SYSCALL_TABLE(sys_nice, sys_nice, 34, 1)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_kill
+TRACE_SYSCALL_TABLE(sys_kill, sys_kill, 37, 2)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_dup
+TRACE_SYSCALL_TABLE(sys_dup, sys_dup, 41, 1)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_brk
+TRACE_SYSCALL_TABLE(sys_brk, sys_brk, 45, 1)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_setgid
+TRACE_SYSCALL_TABLE(sys_setgid, sys_setgid, 46, 1)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_signal
+TRACE_SYSCALL_TABLE(sys_signal, sys_signal, 48, 2)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_ioctl
+TRACE_SYSCALL_TABLE(sys_ioctl, sys_ioctl, 54, 3)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_fcntl
+TRACE_SYSCALL_TABLE(sys_fcntl, sys_fcntl, 55, 3)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_setpgid
+TRACE_SYSCALL_TABLE(sys_setpgid, sys_setpgid, 57, 2)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_umask
+TRACE_SYSCALL_TABLE(sys_umask, sys_umask, 60, 1)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_dup2
+TRACE_SYSCALL_TABLE(sys_dup2, sys_dup2, 63, 2)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_ssetmask
+TRACE_SYSCALL_TABLE(sys_ssetmask, sys_ssetmask, 69, 1)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_setreuid
+TRACE_SYSCALL_TABLE(sys_setreuid, sys_setreuid, 70, 2)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_setregid
+TRACE_SYSCALL_TABLE(sys_setregid, sys_setregid, 71, 2)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_munmap
+TRACE_SYSCALL_TABLE(sys_munmap, sys_munmap, 91, 2)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_ftruncate
+TRACE_SYSCALL_TABLE(sys_ftruncate, sys_ftruncate, 93, 2)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_fchmod
+TRACE_SYSCALL_TABLE(sys_fchmod, sys_fchmod, 94, 2)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_fchown
+TRACE_SYSCALL_TABLE(sys_fchown, sys_fchown, 95, 3)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_getpriority
+TRACE_SYSCALL_TABLE(sys_getpriority, sys_getpriority, 96, 2)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_setpriority
+TRACE_SYSCALL_TABLE(sys_setpriority, sys_setpriority, 97, 3)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_fsync
+TRACE_SYSCALL_TABLE(sys_fsync, sys_fsync, 118, 1)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_mprotect
+TRACE_SYSCALL_TABLE(sys_mprotect, sys_mprotect, 125, 3)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_getpgid
+TRACE_SYSCALL_TABLE(sys_getpgid, sys_getpgid, 132, 1)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_fchdir
+TRACE_SYSCALL_TABLE(sys_fchdir, sys_fchdir, 133, 1)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_bdflush
+TRACE_SYSCALL_TABLE(sys_bdflush, sys_bdflush, 134, 2)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_sysfs
+TRACE_SYSCALL_TABLE(sys_sysfs, sys_sysfs, 135, 3)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_personality
+TRACE_SYSCALL_TABLE(sys_personality, sys_personality, 136, 1)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_setfsuid
+TRACE_SYSCALL_TABLE(sys_setfsuid, sys_setfsuid, 138, 1)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_setfsgid
+TRACE_SYSCALL_TABLE(sys_setfsgid, sys_setfsgid, 139, 1)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_flock
+TRACE_SYSCALL_TABLE(sys_flock, sys_flock, 143, 2)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_msync
+TRACE_SYSCALL_TABLE(sys_msync, sys_msync, 144, 3)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_getsid
+TRACE_SYSCALL_TABLE(sys_getsid, sys_getsid, 147, 1)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_fdatasync
+TRACE_SYSCALL_TABLE(sys_fdatasync, sys_fdatasync, 148, 1)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_mlock
+TRACE_SYSCALL_TABLE(sys_mlock, sys_mlock, 150, 2)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_munlock
+TRACE_SYSCALL_TABLE(sys_munlock, sys_munlock, 151, 2)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_mlockall
+TRACE_SYSCALL_TABLE(sys_mlockall, sys_mlockall, 152, 1)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_sched_getscheduler
+TRACE_SYSCALL_TABLE(sys_sched_getscheduler, sys_sched_getscheduler, 157, 1)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_sched_get_priority_max
+TRACE_SYSCALL_TABLE(sys_sched_get_priority_max, sys_sched_get_priority_max, 159, 1)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_sched_get_priority_min
+TRACE_SYSCALL_TABLE(sys_sched_get_priority_min, sys_sched_get_priority_min, 160, 1)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_mremap
+TRACE_SYSCALL_TABLE(sys_mremap, sys_mremap, 163, 5)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_setresuid
+TRACE_SYSCALL_TABLE(sys_setresuid, sys_setresuid, 164, 3)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_setresgid
+TRACE_SYSCALL_TABLE(sys_setresgid, sys_setresgid, 169, 3)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_prctl
+TRACE_SYSCALL_TABLE(sys_prctl, sys_prctl, 171, 5)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_fcntl64
+TRACE_SYSCALL_TABLE(sys_fcntl64, sys_fcntl64, 204, 3)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_madvise
+TRACE_SYSCALL_TABLE(sys_madvise, sys_madvise, 205, 3)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_tkill
+TRACE_SYSCALL_TABLE(sys_tkill, sys_tkill, 208, 2)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_io_destroy
+TRACE_SYSCALL_TABLE(sys_io_destroy, sys_io_destroy, 228, 1)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_exit_group
+TRACE_SYSCALL_TABLE(sys_exit_group, sys_exit_group, 234, 1)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_epoll_create
+TRACE_SYSCALL_TABLE(sys_epoll_create, sys_epoll_create, 236, 1)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_remap_file_pages
+TRACE_SYSCALL_TABLE(sys_remap_file_pages, sys_remap_file_pages, 239, 5)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_timer_getoverrun
+TRACE_SYSCALL_TABLE(sys_timer_getoverrun, sys_timer_getoverrun, 243, 1)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_timer_delete
+TRACE_SYSCALL_TABLE(sys_timer_delete, sys_timer_delete, 244, 1)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_tgkill
+TRACE_SYSCALL_TABLE(sys_tgkill, sys_tgkill, 250, 3)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_keyctl
+TRACE_SYSCALL_TABLE(sys_keyctl, sys_keyctl, 271, 5)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_ioprio_set
+TRACE_SYSCALL_TABLE(sys_ioprio_set, sys_ioprio_set, 273, 3)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_ioprio_get
+TRACE_SYSCALL_TABLE(sys_ioprio_get, sys_ioprio_get, 274, 2)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_inotify_rm_watch
+TRACE_SYSCALL_TABLE(sys_inotify_rm_watch, sys_inotify_rm_watch, 277, 2)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_unshare
+TRACE_SYSCALL_TABLE(sys_unshare, sys_unshare, 282, 1)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_tee
+TRACE_SYSCALL_TABLE(sys_tee, sys_tee, 284, 4)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_timerfd_create
+TRACE_SYSCALL_TABLE(sys_timerfd_create, sys_timerfd_create, 306, 2)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_eventfd
+TRACE_SYSCALL_TABLE(sys_eventfd, sys_eventfd, 307, 1)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_eventfd2
+TRACE_SYSCALL_TABLE(sys_eventfd2, sys_eventfd2, 314, 2)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_epoll_create1
+TRACE_SYSCALL_TABLE(sys_epoll_create1, sys_epoll_create1, 315, 1)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_dup3
+TRACE_SYSCALL_TABLE(sys_dup3, sys_dup3, 316, 3)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_inotify_init1
+TRACE_SYSCALL_TABLE(sys_inotify_init1, sys_inotify_init1, 318, 1)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_socket
+TRACE_SYSCALL_TABLE(sys_socket, sys_socket, 326, 3)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_listen
+TRACE_SYSCALL_TABLE(sys_listen, sys_listen, 329, 2)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_shutdown
+TRACE_SYSCALL_TABLE(sys_shutdown, sys_shutdown, 338, 2)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_syncfs
+TRACE_SYSCALL_TABLE(sys_syncfs, sys_syncfs, 348, 1)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_setns
+TRACE_SYSCALL_TABLE(sys_setns, sys_setns, 350, 2)
+#endif
+
+#endif /* CREATE_SYSCALL_TABLE */
diff --git a/drivers/staging/lttng/instrumentation/syscalls/headers/powerpc-32-syscalls-3.0.34_integers_override.h b/drivers/staging/lttng/instrumentation/syscalls/headers/powerpc-32-syscalls-3.0.34_integers_override.h
new file mode 100644 (file)
index 0000000..6696f43
--- /dev/null
@@ -0,0 +1,9 @@
+#ifndef CREATE_SYSCALL_TABLE
+
+#else  /* CREATE_SYSCALL_TABLE */
+
+#define OVVERRIDE_TABLE_32_sys_mmap
+TRACE_SYSCALL_TABLE(sys_mmap, sys_mmap, 90, 6)
+
+#endif /* CREATE_SYSCALL_TABLE */
+
diff --git a/drivers/staging/lttng/instrumentation/syscalls/headers/powerpc-32-syscalls-3.0.34_pointers.h b/drivers/staging/lttng/instrumentation/syscalls/headers/powerpc-32-syscalls-3.0.34_pointers.h
new file mode 100644 (file)
index 0000000..ba44837
--- /dev/null
@@ -0,0 +1,2316 @@
+/* THIS FILE IS AUTO-GENERATED. DO NOT EDIT */
+#ifndef CREATE_SYSCALL_TABLE
+
+#if !defined(_TRACE_SYSCALLS_POINTERS_H) || defined(TRACE_HEADER_MULTI_READ)
+#define _TRACE_SYSCALLS_POINTERS_H
+
+#include <linux/tracepoint.h>
+#include <linux/syscalls.h>
+#include "powerpc-32-syscalls-3.0.34_pointers_override.h"
+#include "syscalls_pointers_override.h"
+
+#ifndef OVERRIDE_32_sys_unlink
+SC_TRACE_EVENT(sys_unlink,
+       TP_PROTO(const char * pathname),
+       TP_ARGS(pathname),
+       TP_STRUCT__entry(__string_from_user(pathname, pathname)),
+       TP_fast_assign(tp_copy_string_from_user(pathname, pathname)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_chdir
+SC_TRACE_EVENT(sys_chdir,
+       TP_PROTO(const char * filename),
+       TP_ARGS(filename),
+       TP_STRUCT__entry(__string_from_user(filename, filename)),
+       TP_fast_assign(tp_copy_string_from_user(filename, filename)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_time
+SC_TRACE_EVENT(sys_time,
+       TP_PROTO(time_t * tloc),
+       TP_ARGS(tloc),
+       TP_STRUCT__entry(__field_hex(time_t *, tloc)),
+       TP_fast_assign(tp_assign(tloc, tloc)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_oldumount
+SC_TRACE_EVENT(sys_oldumount,
+       TP_PROTO(char * name),
+       TP_ARGS(name),
+       TP_STRUCT__entry(__string_from_user(name, name)),
+       TP_fast_assign(tp_copy_string_from_user(name, name)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_stime
+SC_TRACE_EVENT(sys_stime,
+       TP_PROTO(time_t * tptr),
+       TP_ARGS(tptr),
+       TP_STRUCT__entry(__field_hex(time_t *, tptr)),
+       TP_fast_assign(tp_assign(tptr, tptr)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_rmdir
+SC_TRACE_EVENT(sys_rmdir,
+       TP_PROTO(const char * pathname),
+       TP_ARGS(pathname),
+       TP_STRUCT__entry(__string_from_user(pathname, pathname)),
+       TP_fast_assign(tp_copy_string_from_user(pathname, pathname)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_pipe
+SC_TRACE_EVENT(sys_pipe,
+       TP_PROTO(int * fildes),
+       TP_ARGS(fildes),
+       TP_STRUCT__entry(__field_hex(int *, fildes)),
+       TP_fast_assign(tp_assign(fildes, fildes)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_times
+SC_TRACE_EVENT(sys_times,
+       TP_PROTO(struct tms * tbuf),
+       TP_ARGS(tbuf),
+       TP_STRUCT__entry(__field_hex(struct tms *, tbuf)),
+       TP_fast_assign(tp_assign(tbuf, tbuf)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_acct
+SC_TRACE_EVENT(sys_acct,
+       TP_PROTO(const char * name),
+       TP_ARGS(name),
+       TP_STRUCT__entry(__string_from_user(name, name)),
+       TP_fast_assign(tp_copy_string_from_user(name, name)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_olduname
+SC_TRACE_EVENT(sys_olduname,
+       TP_PROTO(struct oldold_utsname * name),
+       TP_ARGS(name),
+       TP_STRUCT__entry(__field_hex(struct oldold_utsname *, name)),
+       TP_fast_assign(tp_assign(name, name)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_chroot
+SC_TRACE_EVENT(sys_chroot,
+       TP_PROTO(const char * filename),
+       TP_ARGS(filename),
+       TP_STRUCT__entry(__string_from_user(filename, filename)),
+       TP_fast_assign(tp_copy_string_from_user(filename, filename)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_sigpending
+SC_TRACE_EVENT(sys_sigpending,
+       TP_PROTO(old_sigset_t * set),
+       TP_ARGS(set),
+       TP_STRUCT__entry(__field_hex(old_sigset_t *, set)),
+       TP_fast_assign(tp_assign(set, set)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_uselib
+SC_TRACE_EVENT(sys_uselib,
+       TP_PROTO(const char * library),
+       TP_ARGS(library),
+       TP_STRUCT__entry(__field_hex(const char *, library)),
+       TP_fast_assign(tp_assign(library, library)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_uname
+SC_TRACE_EVENT(sys_uname,
+       TP_PROTO(struct old_utsname * name),
+       TP_ARGS(name),
+       TP_STRUCT__entry(__field_hex(struct old_utsname *, name)),
+       TP_fast_assign(tp_assign(name, name)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_swapoff
+SC_TRACE_EVENT(sys_swapoff,
+       TP_PROTO(const char * specialfile),
+       TP_ARGS(specialfile),
+       TP_STRUCT__entry(__string_from_user(specialfile, specialfile)),
+       TP_fast_assign(tp_copy_string_from_user(specialfile, specialfile)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_sysinfo
+SC_TRACE_EVENT(sys_sysinfo,
+       TP_PROTO(struct sysinfo * info),
+       TP_ARGS(info),
+       TP_STRUCT__entry(__field_hex(struct sysinfo *, info)),
+       TP_fast_assign(tp_assign(info, info)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_newuname
+SC_TRACE_EVENT(sys_newuname,
+       TP_PROTO(struct new_utsname * name),
+       TP_ARGS(name),
+       TP_STRUCT__entry(__field_hex(struct new_utsname *, name)),
+       TP_fast_assign(tp_assign(name, name)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_adjtimex
+SC_TRACE_EVENT(sys_adjtimex,
+       TP_PROTO(struct timex * txc_p),
+       TP_ARGS(txc_p),
+       TP_STRUCT__entry(__field_hex(struct timex *, txc_p)),
+       TP_fast_assign(tp_assign(txc_p, txc_p)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_sysctl
+SC_TRACE_EVENT(sys_sysctl,
+       TP_PROTO(struct __sysctl_args * args),
+       TP_ARGS(args),
+       TP_STRUCT__entry(__field_hex(struct __sysctl_args *, args)),
+       TP_fast_assign(tp_assign(args, args)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_set_tid_address
+SC_TRACE_EVENT(sys_set_tid_address,
+       TP_PROTO(int * tidptr),
+       TP_ARGS(tidptr),
+       TP_STRUCT__entry(__field_hex(int *, tidptr)),
+       TP_fast_assign(tp_assign(tidptr, tidptr)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_mq_unlink
+SC_TRACE_EVENT(sys_mq_unlink,
+       TP_PROTO(const char * u_name),
+       TP_ARGS(u_name),
+       TP_STRUCT__entry(__string_from_user(u_name, u_name)),
+       TP_fast_assign(tp_copy_string_from_user(u_name, u_name)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_creat
+SC_TRACE_EVENT(sys_creat,
+       TP_PROTO(const char * pathname, int mode),
+       TP_ARGS(pathname, mode),
+       TP_STRUCT__entry(__string_from_user(pathname, pathname) __field(int, mode)),
+       TP_fast_assign(tp_copy_string_from_user(pathname, pathname) tp_assign(mode, mode)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_link
+SC_TRACE_EVENT(sys_link,
+       TP_PROTO(const char * oldname, const char * newname),
+       TP_ARGS(oldname, newname),
+       TP_STRUCT__entry(__string_from_user(oldname, oldname) __string_from_user(newname, newname)),
+       TP_fast_assign(tp_copy_string_from_user(oldname, oldname) tp_copy_string_from_user(newname, newname)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_chmod
+SC_TRACE_EVENT(sys_chmod,
+       TP_PROTO(const char * filename, mode_t mode),
+       TP_ARGS(filename, mode),
+       TP_STRUCT__entry(__string_from_user(filename, filename) __field(mode_t, mode)),
+       TP_fast_assign(tp_copy_string_from_user(filename, filename) tp_assign(mode, mode)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_stat
+SC_TRACE_EVENT(sys_stat,
+       TP_PROTO(const char * filename, struct __old_kernel_stat * statbuf),
+       TP_ARGS(filename, statbuf),
+       TP_STRUCT__entry(__string_from_user(filename, filename) __field_hex(struct __old_kernel_stat *, statbuf)),
+       TP_fast_assign(tp_copy_string_from_user(filename, filename) tp_assign(statbuf, statbuf)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_fstat
+SC_TRACE_EVENT(sys_fstat,
+       TP_PROTO(unsigned int fd, struct __old_kernel_stat * statbuf),
+       TP_ARGS(fd, statbuf),
+       TP_STRUCT__entry(__field(unsigned int, fd) __field_hex(struct __old_kernel_stat *, statbuf)),
+       TP_fast_assign(tp_assign(fd, fd) tp_assign(statbuf, statbuf)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_utime
+SC_TRACE_EVENT(sys_utime,
+       TP_PROTO(char * filename, struct utimbuf * times),
+       TP_ARGS(filename, times),
+       TP_STRUCT__entry(__string_from_user(filename, filename) __field_hex(struct utimbuf *, times)),
+       TP_fast_assign(tp_copy_string_from_user(filename, filename) tp_assign(times, times)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_access
+SC_TRACE_EVENT(sys_access,
+       TP_PROTO(const char * filename, int mode),
+       TP_ARGS(filename, mode),
+       TP_STRUCT__entry(__string_from_user(filename, filename) __field(int, mode)),
+       TP_fast_assign(tp_copy_string_from_user(filename, filename) tp_assign(mode, mode)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_rename
+SC_TRACE_EVENT(sys_rename,
+       TP_PROTO(const char * oldname, const char * newname),
+       TP_ARGS(oldname, newname),
+       TP_STRUCT__entry(__string_from_user(oldname, oldname) __string_from_user(newname, newname)),
+       TP_fast_assign(tp_copy_string_from_user(oldname, oldname) tp_copy_string_from_user(newname, newname)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_mkdir
+SC_TRACE_EVENT(sys_mkdir,
+       TP_PROTO(const char * pathname, int mode),
+       TP_ARGS(pathname, mode),
+       TP_STRUCT__entry(__string_from_user(pathname, pathname) __field(int, mode)),
+       TP_fast_assign(tp_copy_string_from_user(pathname, pathname) tp_assign(mode, mode)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_umount
+SC_TRACE_EVENT(sys_umount,
+       TP_PROTO(char * name, int flags),
+       TP_ARGS(name, flags),
+       TP_STRUCT__entry(__string_from_user(name, name) __field(int, flags)),
+       TP_fast_assign(tp_copy_string_from_user(name, name) tp_assign(flags, flags)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_ustat
+SC_TRACE_EVENT(sys_ustat,
+       TP_PROTO(unsigned dev, struct ustat * ubuf),
+       TP_ARGS(dev, ubuf),
+       TP_STRUCT__entry(__field(unsigned, dev) __field_hex(struct ustat *, ubuf)),
+       TP_fast_assign(tp_assign(dev, dev) tp_assign(ubuf, ubuf)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_sethostname
+SC_TRACE_EVENT(sys_sethostname,
+       TP_PROTO(char * name, int len),
+       TP_ARGS(name, len),
+       TP_STRUCT__entry(__string_from_user(name, name) __field(int, len)),
+       TP_fast_assign(tp_copy_string_from_user(name, name) tp_assign(len, len)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_setrlimit
+SC_TRACE_EVENT(sys_setrlimit,
+       TP_PROTO(unsigned int resource, struct rlimit * rlim),
+       TP_ARGS(resource, rlim),
+       TP_STRUCT__entry(__field(unsigned int, resource) __field_hex(struct rlimit *, rlim)),
+       TP_fast_assign(tp_assign(resource, resource) tp_assign(rlim, rlim)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_old_getrlimit
+SC_TRACE_EVENT(sys_old_getrlimit,
+       TP_PROTO(unsigned int resource, struct rlimit * rlim),
+       TP_ARGS(resource, rlim),
+       TP_STRUCT__entry(__field(unsigned int, resource) __field_hex(struct rlimit *, rlim)),
+       TP_fast_assign(tp_assign(resource, resource) tp_assign(rlim, rlim)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_getrusage
+SC_TRACE_EVENT(sys_getrusage,
+       TP_PROTO(int who, struct rusage * ru),
+       TP_ARGS(who, ru),
+       TP_STRUCT__entry(__field(int, who) __field_hex(struct rusage *, ru)),
+       TP_fast_assign(tp_assign(who, who) tp_assign(ru, ru)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_gettimeofday
+SC_TRACE_EVENT(sys_gettimeofday,
+       TP_PROTO(struct timeval * tv, struct timezone * tz),
+       TP_ARGS(tv, tz),
+       TP_STRUCT__entry(__field_hex(struct timeval *, tv) __field_hex(struct timezone *, tz)),
+       TP_fast_assign(tp_assign(tv, tv) tp_assign(tz, tz)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_settimeofday
+SC_TRACE_EVENT(sys_settimeofday,
+       TP_PROTO(struct timeval * tv, struct timezone * tz),
+       TP_ARGS(tv, tz),
+       TP_STRUCT__entry(__field_hex(struct timeval *, tv) __field_hex(struct timezone *, tz)),
+       TP_fast_assign(tp_assign(tv, tv) tp_assign(tz, tz)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_getgroups
+SC_TRACE_EVENT(sys_getgroups,
+       TP_PROTO(int gidsetsize, gid_t * grouplist),
+       TP_ARGS(gidsetsize, grouplist),
+       TP_STRUCT__entry(__field(int, gidsetsize) __field_hex(gid_t *, grouplist)),
+       TP_fast_assign(tp_assign(gidsetsize, gidsetsize) tp_assign(grouplist, grouplist)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_setgroups
+SC_TRACE_EVENT(sys_setgroups,
+       TP_PROTO(int gidsetsize, gid_t * grouplist),
+       TP_ARGS(gidsetsize, grouplist),
+       TP_STRUCT__entry(__field(int, gidsetsize) __field_hex(gid_t *, grouplist)),
+       TP_fast_assign(tp_assign(gidsetsize, gidsetsize) tp_assign(grouplist, grouplist)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_symlink
+SC_TRACE_EVENT(sys_symlink,
+       TP_PROTO(const char * oldname, const char * newname),
+       TP_ARGS(oldname, newname),
+       TP_STRUCT__entry(__string_from_user(oldname, oldname) __string_from_user(newname, newname)),
+       TP_fast_assign(tp_copy_string_from_user(oldname, oldname) tp_copy_string_from_user(newname, newname)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_lstat
+SC_TRACE_EVENT(sys_lstat,
+       TP_PROTO(const char * filename, struct __old_kernel_stat * statbuf),
+       TP_ARGS(filename, statbuf),
+       TP_STRUCT__entry(__string_from_user(filename, filename) __field_hex(struct __old_kernel_stat *, statbuf)),
+       TP_fast_assign(tp_copy_string_from_user(filename, filename) tp_assign(statbuf, statbuf)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_swapon
+SC_TRACE_EVENT(sys_swapon,
+       TP_PROTO(const char * specialfile, int swap_flags),
+       TP_ARGS(specialfile, swap_flags),
+       TP_STRUCT__entry(__string_from_user(specialfile, specialfile) __field(int, swap_flags)),
+       TP_fast_assign(tp_copy_string_from_user(specialfile, specialfile) tp_assign(swap_flags, swap_flags)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_truncate
+SC_TRACE_EVENT(sys_truncate,
+       TP_PROTO(const char * path, long length),
+       TP_ARGS(path, length),
+       TP_STRUCT__entry(__string_from_user(path, path) __field(long, length)),
+       TP_fast_assign(tp_copy_string_from_user(path, path) tp_assign(length, length)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_statfs
+SC_TRACE_EVENT(sys_statfs,
+       TP_PROTO(const char * pathname, struct statfs * buf),
+       TP_ARGS(pathname, buf),
+       TP_STRUCT__entry(__string_from_user(pathname, pathname) __field_hex(struct statfs *, buf)),
+       TP_fast_assign(tp_copy_string_from_user(pathname, pathname) tp_assign(buf, buf)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_fstatfs
+SC_TRACE_EVENT(sys_fstatfs,
+       TP_PROTO(unsigned int fd, struct statfs * buf),
+       TP_ARGS(fd, buf),
+       TP_STRUCT__entry(__field(unsigned int, fd) __field_hex(struct statfs *, buf)),
+       TP_fast_assign(tp_assign(fd, fd) tp_assign(buf, buf)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_socketcall
+SC_TRACE_EVENT(sys_socketcall,
+       TP_PROTO(int call, unsigned long * args),
+       TP_ARGS(call, args),
+       TP_STRUCT__entry(__field(int, call) __field_hex(unsigned long *, args)),
+       TP_fast_assign(tp_assign(call, call) tp_assign(args, args)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_getitimer
+SC_TRACE_EVENT(sys_getitimer,
+       TP_PROTO(int which, struct itimerval * value),
+       TP_ARGS(which, value),
+       TP_STRUCT__entry(__field(int, which) __field_hex(struct itimerval *, value)),
+       TP_fast_assign(tp_assign(which, which) tp_assign(value, value)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_newstat
+SC_TRACE_EVENT(sys_newstat,
+       TP_PROTO(const char * filename, struct stat * statbuf),
+       TP_ARGS(filename, statbuf),
+       TP_STRUCT__entry(__string_from_user(filename, filename) __field_hex(struct stat *, statbuf)),
+       TP_fast_assign(tp_copy_string_from_user(filename, filename) tp_assign(statbuf, statbuf)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_newlstat
+SC_TRACE_EVENT(sys_newlstat,
+       TP_PROTO(const char * filename, struct stat * statbuf),
+       TP_ARGS(filename, statbuf),
+       TP_STRUCT__entry(__string_from_user(filename, filename) __field_hex(struct stat *, statbuf)),
+       TP_fast_assign(tp_copy_string_from_user(filename, filename) tp_assign(statbuf, statbuf)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_newfstat
+SC_TRACE_EVENT(sys_newfstat,
+       TP_PROTO(unsigned int fd, struct stat * statbuf),
+       TP_ARGS(fd, statbuf),
+       TP_STRUCT__entry(__field(unsigned int, fd) __field_hex(struct stat *, statbuf)),
+       TP_fast_assign(tp_assign(fd, fd) tp_assign(statbuf, statbuf)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_setdomainname
+SC_TRACE_EVENT(sys_setdomainname,
+       TP_PROTO(char * name, int len),
+       TP_ARGS(name, len),
+       TP_STRUCT__entry(__string_from_user(name, name) __field(int, len)),
+       TP_fast_assign(tp_copy_string_from_user(name, name) tp_assign(len, len)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_delete_module
+SC_TRACE_EVENT(sys_delete_module,
+       TP_PROTO(const char * name_user, unsigned int flags),
+       TP_ARGS(name_user, flags),
+       TP_STRUCT__entry(__string_from_user(name_user, name_user) __field(unsigned int, flags)),
+       TP_fast_assign(tp_copy_string_from_user(name_user, name_user) tp_assign(flags, flags)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_sched_setparam
+SC_TRACE_EVENT(sys_sched_setparam,
+       TP_PROTO(pid_t pid, struct sched_param * param),
+       TP_ARGS(pid, param),
+       TP_STRUCT__entry(__field(pid_t, pid) __field_hex(struct sched_param *, param)),
+       TP_fast_assign(tp_assign(pid, pid) tp_assign(param, param)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_sched_getparam
+SC_TRACE_EVENT(sys_sched_getparam,
+       TP_PROTO(pid_t pid, struct sched_param * param),
+       TP_ARGS(pid, param),
+       TP_STRUCT__entry(__field(pid_t, pid) __field_hex(struct sched_param *, param)),
+       TP_fast_assign(tp_assign(pid, pid) tp_assign(param, param)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_sched_rr_get_interval
+SC_TRACE_EVENT(sys_sched_rr_get_interval,
+       TP_PROTO(pid_t pid, struct timespec * interval),
+       TP_ARGS(pid, interval),
+       TP_STRUCT__entry(__field(pid_t, pid) __field_hex(struct timespec *, interval)),
+       TP_fast_assign(tp_assign(pid, pid) tp_assign(interval, interval)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_nanosleep
+SC_TRACE_EVENT(sys_nanosleep,
+       TP_PROTO(struct timespec * rqtp, struct timespec * rmtp),
+       TP_ARGS(rqtp, rmtp),
+       TP_STRUCT__entry(__field_hex(struct timespec *, rqtp) __field_hex(struct timespec *, rmtp)),
+       TP_fast_assign(tp_assign(rqtp, rqtp) tp_assign(rmtp, rmtp)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_rt_sigpending
+SC_TRACE_EVENT(sys_rt_sigpending,
+       TP_PROTO(sigset_t * set, size_t sigsetsize),
+       TP_ARGS(set, sigsetsize),
+       TP_STRUCT__entry(__field_hex(sigset_t *, set) __field(size_t, sigsetsize)),
+       TP_fast_assign(tp_assign(set, set) tp_assign(sigsetsize, sigsetsize)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_rt_sigsuspend
+SC_TRACE_EVENT(sys_rt_sigsuspend,
+       TP_PROTO(sigset_t * unewset, size_t sigsetsize),
+       TP_ARGS(unewset, sigsetsize),
+       TP_STRUCT__entry(__field_hex(sigset_t *, unewset) __field(size_t, sigsetsize)),
+       TP_fast_assign(tp_assign(unewset, unewset) tp_assign(sigsetsize, sigsetsize)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_getcwd
+SC_TRACE_EVENT(sys_getcwd,
+       TP_PROTO(char * buf, unsigned long size),
+       TP_ARGS(buf, size),
+       TP_STRUCT__entry(__field_hex(char *, buf) __field(unsigned long, size)),
+       TP_fast_assign(tp_assign(buf, buf) tp_assign(size, size)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_getrlimit
+SC_TRACE_EVENT(sys_getrlimit,
+       TP_PROTO(unsigned int resource, struct rlimit * rlim),
+       TP_ARGS(resource, rlim),
+       TP_STRUCT__entry(__field(unsigned int, resource) __field_hex(struct rlimit *, rlim)),
+       TP_fast_assign(tp_assign(resource, resource) tp_assign(rlim, rlim)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_stat64
+SC_TRACE_EVENT(sys_stat64,
+       TP_PROTO(const char * filename, struct stat64 * statbuf),
+       TP_ARGS(filename, statbuf),
+       TP_STRUCT__entry(__string_from_user(filename, filename) __field_hex(struct stat64 *, statbuf)),
+       TP_fast_assign(tp_copy_string_from_user(filename, filename) tp_assign(statbuf, statbuf)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_lstat64
+SC_TRACE_EVENT(sys_lstat64,
+       TP_PROTO(const char * filename, struct stat64 * statbuf),
+       TP_ARGS(filename, statbuf),
+       TP_STRUCT__entry(__string_from_user(filename, filename) __field_hex(struct stat64 *, statbuf)),
+       TP_fast_assign(tp_copy_string_from_user(filename, filename) tp_assign(statbuf, statbuf)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_fstat64
+SC_TRACE_EVENT(sys_fstat64,
+       TP_PROTO(unsigned long fd, struct stat64 * statbuf),
+       TP_ARGS(fd, statbuf),
+       TP_STRUCT__entry(__field(unsigned long, fd) __field_hex(struct stat64 *, statbuf)),
+       TP_fast_assign(tp_assign(fd, fd) tp_assign(statbuf, statbuf)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_pivot_root
+SC_TRACE_EVENT(sys_pivot_root,
+       TP_PROTO(const char * new_root, const char * put_old),
+       TP_ARGS(new_root, put_old),
+       TP_STRUCT__entry(__string_from_user(new_root, new_root) __string_from_user(put_old, put_old)),
+       TP_fast_assign(tp_copy_string_from_user(new_root, new_root) tp_copy_string_from_user(put_old, put_old)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_removexattr
+SC_TRACE_EVENT(sys_removexattr,
+       TP_PROTO(const char * pathname, const char * name),
+       TP_ARGS(pathname, name),
+       TP_STRUCT__entry(__string_from_user(pathname, pathname) __string_from_user(name, name)),
+       TP_fast_assign(tp_copy_string_from_user(pathname, pathname) tp_copy_string_from_user(name, name)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_lremovexattr
+SC_TRACE_EVENT(sys_lremovexattr,
+       TP_PROTO(const char * pathname, const char * name),
+       TP_ARGS(pathname, name),
+       TP_STRUCT__entry(__string_from_user(pathname, pathname) __string_from_user(name, name)),
+       TP_fast_assign(tp_copy_string_from_user(pathname, pathname) tp_copy_string_from_user(name, name)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_fremovexattr
+SC_TRACE_EVENT(sys_fremovexattr,
+       TP_PROTO(int fd, const char * name),
+       TP_ARGS(fd, name),
+       TP_STRUCT__entry(__field(int, fd) __string_from_user(name, name)),
+       TP_fast_assign(tp_assign(fd, fd) tp_copy_string_from_user(name, name)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_io_setup
+SC_TRACE_EVENT(sys_io_setup,
+       TP_PROTO(unsigned nr_events, aio_context_t * ctxp),
+       TP_ARGS(nr_events, ctxp),
+       TP_STRUCT__entry(__field(unsigned, nr_events) __field_hex(aio_context_t *, ctxp)),
+       TP_fast_assign(tp_assign(nr_events, nr_events) tp_assign(ctxp, ctxp)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_timer_gettime
+SC_TRACE_EVENT(sys_timer_gettime,
+       TP_PROTO(timer_t timer_id, struct itimerspec * setting),
+       TP_ARGS(timer_id, setting),
+       TP_STRUCT__entry(__field(timer_t, timer_id) __field_hex(struct itimerspec *, setting)),
+       TP_fast_assign(tp_assign(timer_id, timer_id) tp_assign(setting, setting)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_clock_settime
+SC_TRACE_EVENT(sys_clock_settime,
+       TP_PROTO(const clockid_t which_clock, const struct timespec * tp),
+       TP_ARGS(which_clock, tp),
+       TP_STRUCT__entry(__field(const clockid_t, which_clock) __field_hex(const struct timespec *, tp)),
+       TP_fast_assign(tp_assign(which_clock, which_clock) tp_assign(tp, tp)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_clock_gettime
+SC_TRACE_EVENT(sys_clock_gettime,
+       TP_PROTO(const clockid_t which_clock, struct timespec * tp),
+       TP_ARGS(which_clock, tp),
+       TP_STRUCT__entry(__field(const clockid_t, which_clock) __field_hex(struct timespec *, tp)),
+       TP_fast_assign(tp_assign(which_clock, which_clock) tp_assign(tp, tp)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_clock_getres
+SC_TRACE_EVENT(sys_clock_getres,
+       TP_PROTO(const clockid_t which_clock, struct timespec * tp),
+       TP_ARGS(which_clock, tp),
+       TP_STRUCT__entry(__field(const clockid_t, which_clock) __field_hex(struct timespec *, tp)),
+       TP_fast_assign(tp_assign(which_clock, which_clock) tp_assign(tp, tp)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_utimes
+SC_TRACE_EVENT(sys_utimes,
+       TP_PROTO(char * filename, struct timeval * utimes),
+       TP_ARGS(filename, utimes),
+       TP_STRUCT__entry(__string_from_user(filename, filename) __field_hex(struct timeval *, utimes)),
+       TP_fast_assign(tp_copy_string_from_user(filename, filename) tp_assign(utimes, utimes)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_mq_notify
+SC_TRACE_EVENT(sys_mq_notify,
+       TP_PROTO(mqd_t mqdes, const struct sigevent * u_notification),
+       TP_ARGS(mqdes, u_notification),
+       TP_STRUCT__entry(__field(mqd_t, mqdes) __field_hex(const struct sigevent *, u_notification)),
+       TP_fast_assign(tp_assign(mqdes, mqdes) tp_assign(u_notification, u_notification)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_set_robust_list
+SC_TRACE_EVENT(sys_set_robust_list,
+       TP_PROTO(struct robust_list_head * head, size_t len),
+       TP_ARGS(head, len),
+       TP_STRUCT__entry(__field_hex(struct robust_list_head *, head) __field(size_t, len)),
+       TP_fast_assign(tp_assign(head, head) tp_assign(len, len)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_timerfd_gettime
+SC_TRACE_EVENT(sys_timerfd_gettime,
+       TP_PROTO(int ufd, struct itimerspec * otmr),
+       TP_ARGS(ufd, otmr),
+       TP_STRUCT__entry(__field(int, ufd) __field_hex(struct itimerspec *, otmr)),
+       TP_fast_assign(tp_assign(ufd, ufd) tp_assign(otmr, otmr)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_pipe2
+SC_TRACE_EVENT(sys_pipe2,
+       TP_PROTO(int * fildes, int flags),
+       TP_ARGS(fildes, flags),
+       TP_STRUCT__entry(__field_hex(int *, fildes) __field(int, flags)),
+       TP_fast_assign(tp_assign(fildes, fildes) tp_assign(flags, flags)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_clock_adjtime
+SC_TRACE_EVENT(sys_clock_adjtime,
+       TP_PROTO(const clockid_t which_clock, struct timex * utx),
+       TP_ARGS(which_clock, utx),
+       TP_STRUCT__entry(__field(const clockid_t, which_clock) __field_hex(struct timex *, utx)),
+       TP_fast_assign(tp_assign(which_clock, which_clock) tp_assign(utx, utx)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_read
+SC_TRACE_EVENT(sys_read,
+       TP_PROTO(unsigned int fd, char * buf, size_t count),
+       TP_ARGS(fd, buf, count),
+       TP_STRUCT__entry(__field(unsigned int, fd) __field_hex(char *, buf) __field(size_t, count)),
+       TP_fast_assign(tp_assign(fd, fd) tp_assign(buf, buf) tp_assign(count, count)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_write
+SC_TRACE_EVENT(sys_write,
+       TP_PROTO(unsigned int fd, const char * buf, size_t count),
+       TP_ARGS(fd, buf, count),
+       TP_STRUCT__entry(__field(unsigned int, fd) __field_hex(const char *, buf) __field(size_t, count)),
+       TP_fast_assign(tp_assign(fd, fd) tp_assign(buf, buf) tp_assign(count, count)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_open
+SC_TRACE_EVENT(sys_open,
+       TP_PROTO(const char * filename, int flags, int mode),
+       TP_ARGS(filename, flags, mode),
+       TP_STRUCT__entry(__string_from_user(filename, filename) __field(int, flags) __field(int, mode)),
+       TP_fast_assign(tp_copy_string_from_user(filename, filename) tp_assign(flags, flags) tp_assign(mode, mode)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_waitpid
+SC_TRACE_EVENT(sys_waitpid,
+       TP_PROTO(pid_t pid, int * stat_addr, int options),
+       TP_ARGS(pid, stat_addr, options),
+       TP_STRUCT__entry(__field(pid_t, pid) __field_hex(int *, stat_addr) __field(int, options)),
+       TP_fast_assign(tp_assign(pid, pid) tp_assign(stat_addr, stat_addr) tp_assign(options, options)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_mknod
+SC_TRACE_EVENT(sys_mknod,
+       TP_PROTO(const char * filename, int mode, unsigned dev),
+       TP_ARGS(filename, mode, dev),
+       TP_STRUCT__entry(__string_from_user(filename, filename) __field(int, mode) __field(unsigned, dev)),
+       TP_fast_assign(tp_copy_string_from_user(filename, filename) tp_assign(mode, mode) tp_assign(dev, dev)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_lchown
+SC_TRACE_EVENT(sys_lchown,
+       TP_PROTO(const char * filename, uid_t user, gid_t group),
+       TP_ARGS(filename, user, group),
+       TP_STRUCT__entry(__string_from_user(filename, filename) __field(uid_t, user) __field(gid_t, group)),
+       TP_fast_assign(tp_copy_string_from_user(filename, filename) tp_assign(user, user) tp_assign(group, group)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_readlink
+SC_TRACE_EVENT(sys_readlink,
+       TP_PROTO(const char * path, char * buf, int bufsiz),
+       TP_ARGS(path, buf, bufsiz),
+       TP_STRUCT__entry(__string_from_user(path, path) __field_hex(char *, buf) __field(int, bufsiz)),
+       TP_fast_assign(tp_copy_string_from_user(path, path) tp_assign(buf, buf) tp_assign(bufsiz, bufsiz)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_old_readdir
+SC_TRACE_EVENT(sys_old_readdir,
+       TP_PROTO(unsigned int fd, struct old_linux_dirent * dirent, unsigned int count),
+       TP_ARGS(fd, dirent, count),
+       TP_STRUCT__entry(__field(unsigned int, fd) __field_hex(struct old_linux_dirent *, dirent) __field(unsigned int, count)),
+       TP_fast_assign(tp_assign(fd, fd) tp_assign(dirent, dirent) tp_assign(count, count)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_syslog
+SC_TRACE_EVENT(sys_syslog,
+       TP_PROTO(int type, char * buf, int len),
+       TP_ARGS(type, buf, len),
+       TP_STRUCT__entry(__field(int, type) __field_hex(char *, buf) __field(int, len)),
+       TP_fast_assign(tp_assign(type, type) tp_assign(buf, buf) tp_assign(len, len)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_setitimer
+SC_TRACE_EVENT(sys_setitimer,
+       TP_PROTO(int which, struct itimerval * value, struct itimerval * ovalue),
+       TP_ARGS(which, value, ovalue),
+       TP_STRUCT__entry(__field(int, which) __field_hex(struct itimerval *, value) __field_hex(struct itimerval *, ovalue)),
+       TP_fast_assign(tp_assign(which, which) tp_assign(value, value) tp_assign(ovalue, ovalue)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_sigprocmask
+SC_TRACE_EVENT(sys_sigprocmask,
+       TP_PROTO(int how, old_sigset_t * nset, old_sigset_t * oset),
+       TP_ARGS(how, nset, oset),
+       TP_STRUCT__entry(__field(int, how) __field_hex(old_sigset_t *, nset) __field_hex(old_sigset_t *, oset)),
+       TP_fast_assign(tp_assign(how, how) tp_assign(nset, nset) tp_assign(oset, oset)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_init_module
+SC_TRACE_EVENT(sys_init_module,
+       TP_PROTO(void * umod, unsigned long len, const char * uargs),
+       TP_ARGS(umod, len, uargs),
+       TP_STRUCT__entry(__field_hex(void *, umod) __field(unsigned long, len) __field_hex(const char *, uargs)),
+       TP_fast_assign(tp_assign(umod, umod) tp_assign(len, len) tp_assign(uargs, uargs)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_getdents
+SC_TRACE_EVENT(sys_getdents,
+       TP_PROTO(unsigned int fd, struct linux_dirent * dirent, unsigned int count),
+       TP_ARGS(fd, dirent, count),
+       TP_STRUCT__entry(__field(unsigned int, fd) __field_hex(struct linux_dirent *, dirent) __field(unsigned int, count)),
+       TP_fast_assign(tp_assign(fd, fd) tp_assign(dirent, dirent) tp_assign(count, count)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_readv
+SC_TRACE_EVENT(sys_readv,
+       TP_PROTO(unsigned long fd, const struct iovec * vec, unsigned long vlen),
+       TP_ARGS(fd, vec, vlen),
+       TP_STRUCT__entry(__field(unsigned long, fd) __field_hex(const struct iovec *, vec) __field(unsigned long, vlen)),
+       TP_fast_assign(tp_assign(fd, fd) tp_assign(vec, vec) tp_assign(vlen, vlen)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_writev
+SC_TRACE_EVENT(sys_writev,
+       TP_PROTO(unsigned long fd, const struct iovec * vec, unsigned long vlen),
+       TP_ARGS(fd, vec, vlen),
+       TP_STRUCT__entry(__field(unsigned long, fd) __field_hex(const struct iovec *, vec) __field(unsigned long, vlen)),
+       TP_fast_assign(tp_assign(fd, fd) tp_assign(vec, vec) tp_assign(vlen, vlen)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_sched_setscheduler
+SC_TRACE_EVENT(sys_sched_setscheduler,
+       TP_PROTO(pid_t pid, int policy, struct sched_param * param),
+       TP_ARGS(pid, policy, param),
+       TP_STRUCT__entry(__field(pid_t, pid) __field(int, policy) __field_hex(struct sched_param *, param)),
+       TP_fast_assign(tp_assign(pid, pid) tp_assign(policy, policy) tp_assign(param, param)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_getresuid
+SC_TRACE_EVENT(sys_getresuid,
+       TP_PROTO(uid_t * ruid, uid_t * euid, uid_t * suid),
+       TP_ARGS(ruid, euid, suid),
+       TP_STRUCT__entry(__field_hex(uid_t *, ruid) __field_hex(uid_t *, euid) __field_hex(uid_t *, suid)),
+       TP_fast_assign(tp_assign(ruid, ruid) tp_assign(euid, euid) tp_assign(suid, suid)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_poll
+SC_TRACE_EVENT(sys_poll,
+       TP_PROTO(struct pollfd * ufds, unsigned int nfds, long timeout_msecs),
+       TP_ARGS(ufds, nfds, timeout_msecs),
+       TP_STRUCT__entry(__field_hex(struct pollfd *, ufds) __field(unsigned int, nfds) __field(long, timeout_msecs)),
+       TP_fast_assign(tp_assign(ufds, ufds) tp_assign(nfds, nfds) tp_assign(timeout_msecs, timeout_msecs)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_nfsservctl
+SC_TRACE_EVENT(sys_nfsservctl,
+       TP_PROTO(int cmd, struct nfsctl_arg * arg, void * res),
+       TP_ARGS(cmd, arg, res),
+       TP_STRUCT__entry(__field(int, cmd) __field_hex(struct nfsctl_arg *, arg) __field_hex(void *, res)),
+       TP_fast_assign(tp_assign(cmd, cmd) tp_assign(arg, arg) tp_assign(res, res)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_getresgid
+SC_TRACE_EVENT(sys_getresgid,
+       TP_PROTO(gid_t * rgid, gid_t * egid, gid_t * sgid),
+       TP_ARGS(rgid, egid, sgid),
+       TP_STRUCT__entry(__field_hex(gid_t *, rgid) __field_hex(gid_t *, egid) __field_hex(gid_t *, sgid)),
+       TP_fast_assign(tp_assign(rgid, rgid) tp_assign(egid, egid) tp_assign(sgid, sgid)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_rt_sigqueueinfo
+SC_TRACE_EVENT(sys_rt_sigqueueinfo,
+       TP_PROTO(pid_t pid, int sig, siginfo_t * uinfo),
+       TP_ARGS(pid, sig, uinfo),
+       TP_STRUCT__entry(__field(pid_t, pid) __field(int, sig) __field_hex(siginfo_t *, uinfo)),
+       TP_fast_assign(tp_assign(pid, pid) tp_assign(sig, sig) tp_assign(uinfo, uinfo)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_chown
+SC_TRACE_EVENT(sys_chown,
+       TP_PROTO(const char * filename, uid_t user, gid_t group),
+       TP_ARGS(filename, user, group),
+       TP_STRUCT__entry(__string_from_user(filename, filename) __field(uid_t, user) __field(gid_t, group)),
+       TP_fast_assign(tp_copy_string_from_user(filename, filename) tp_assign(user, user) tp_assign(group, group)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_getdents64
+SC_TRACE_EVENT(sys_getdents64,
+       TP_PROTO(unsigned int fd, struct linux_dirent64 * dirent, unsigned int count),
+       TP_ARGS(fd, dirent, count),
+       TP_STRUCT__entry(__field(unsigned int, fd) __field_hex(struct linux_dirent64 *, dirent) __field(unsigned int, count)),
+       TP_fast_assign(tp_assign(fd, fd) tp_assign(dirent, dirent) tp_assign(count, count)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_mincore
+SC_TRACE_EVENT(sys_mincore,
+       TP_PROTO(unsigned long start, size_t len, unsigned char * vec),
+       TP_ARGS(start, len, vec),
+       TP_STRUCT__entry(__field(unsigned long, start) __field(size_t, len) __field_hex(unsigned char *, vec)),
+       TP_fast_assign(tp_assign(start, start) tp_assign(len, len) tp_assign(vec, vec)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_listxattr
+SC_TRACE_EVENT(sys_listxattr,
+       TP_PROTO(const char * pathname, char * list, size_t size),
+       TP_ARGS(pathname, list, size),
+       TP_STRUCT__entry(__string_from_user(pathname, pathname) __field_hex(char *, list) __field(size_t, size)),
+       TP_fast_assign(tp_copy_string_from_user(pathname, pathname) tp_assign(list, list) tp_assign(size, size)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_llistxattr
+SC_TRACE_EVENT(sys_llistxattr,
+       TP_PROTO(const char * pathname, char * list, size_t size),
+       TP_ARGS(pathname, list, size),
+       TP_STRUCT__entry(__string_from_user(pathname, pathname) __field_hex(char *, list) __field(size_t, size)),
+       TP_fast_assign(tp_copy_string_from_user(pathname, pathname) tp_assign(list, list) tp_assign(size, size)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_flistxattr
+SC_TRACE_EVENT(sys_flistxattr,
+       TP_PROTO(int fd, char * list, size_t size),
+       TP_ARGS(fd, list, size),
+       TP_STRUCT__entry(__field(int, fd) __field_hex(char *, list) __field(size_t, size)),
+       TP_fast_assign(tp_assign(fd, fd) tp_assign(list, list) tp_assign(size, size)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_sched_setaffinity
+SC_TRACE_EVENT(sys_sched_setaffinity,
+       TP_PROTO(pid_t pid, unsigned int len, unsigned long * user_mask_ptr),
+       TP_ARGS(pid, len, user_mask_ptr),
+       TP_STRUCT__entry(__field(pid_t, pid) __field(unsigned int, len) __field_hex(unsigned long *, user_mask_ptr)),
+       TP_fast_assign(tp_assign(pid, pid) tp_assign(len, len) tp_assign(user_mask_ptr, user_mask_ptr)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_sched_getaffinity
+SC_TRACE_EVENT(sys_sched_getaffinity,
+       TP_PROTO(pid_t pid, unsigned int len, unsigned long * user_mask_ptr),
+       TP_ARGS(pid, len, user_mask_ptr),
+       TP_STRUCT__entry(__field(pid_t, pid) __field(unsigned int, len) __field_hex(unsigned long *, user_mask_ptr)),
+       TP_fast_assign(tp_assign(pid, pid) tp_assign(len, len) tp_assign(user_mask_ptr, user_mask_ptr)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_io_submit
+SC_TRACE_EVENT(sys_io_submit,
+       TP_PROTO(aio_context_t ctx_id, long nr, struct iocb * * iocbpp),
+       TP_ARGS(ctx_id, nr, iocbpp),
+       TP_STRUCT__entry(__field(aio_context_t, ctx_id) __field(long, nr) __field_hex(struct iocb * *, iocbpp)),
+       TP_fast_assign(tp_assign(ctx_id, ctx_id) tp_assign(nr, nr) tp_assign(iocbpp, iocbpp)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_io_cancel
+SC_TRACE_EVENT(sys_io_cancel,
+       TP_PROTO(aio_context_t ctx_id, struct iocb * iocb, struct io_event * result),
+       TP_ARGS(ctx_id, iocb, result),
+       TP_STRUCT__entry(__field(aio_context_t, ctx_id) __field_hex(struct iocb *, iocb) __field_hex(struct io_event *, result)),
+       TP_fast_assign(tp_assign(ctx_id, ctx_id) tp_assign(iocb, iocb) tp_assign(result, result)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_timer_create
+SC_TRACE_EVENT(sys_timer_create,
+       TP_PROTO(const clockid_t which_clock, struct sigevent * timer_event_spec, timer_t * created_timer_id),
+       TP_ARGS(which_clock, timer_event_spec, created_timer_id),
+       TP_STRUCT__entry(__field(const clockid_t, which_clock) __field_hex(struct sigevent *, timer_event_spec) __field_hex(timer_t *, created_timer_id)),
+       TP_fast_assign(tp_assign(which_clock, which_clock) tp_assign(timer_event_spec, timer_event_spec) tp_assign(created_timer_id, created_timer_id)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_statfs64
+SC_TRACE_EVENT(sys_statfs64,
+       TP_PROTO(const char * pathname, size_t sz, struct statfs64 * buf),
+       TP_ARGS(pathname, sz, buf),
+       TP_STRUCT__entry(__string_from_user(pathname, pathname) __field(size_t, sz) __field_hex(struct statfs64 *, buf)),
+       TP_fast_assign(tp_copy_string_from_user(pathname, pathname) tp_assign(sz, sz) tp_assign(buf, buf)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_fstatfs64
+SC_TRACE_EVENT(sys_fstatfs64,
+       TP_PROTO(unsigned int fd, size_t sz, struct statfs64 * buf),
+       TP_ARGS(fd, sz, buf),
+       TP_STRUCT__entry(__field(unsigned int, fd) __field(size_t, sz) __field_hex(struct statfs64 *, buf)),
+       TP_fast_assign(tp_assign(fd, fd) tp_assign(sz, sz) tp_assign(buf, buf)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_mq_getsetattr
+SC_TRACE_EVENT(sys_mq_getsetattr,
+       TP_PROTO(mqd_t mqdes, const struct mq_attr * u_mqstat, struct mq_attr * u_omqstat),
+       TP_ARGS(mqdes, u_mqstat, u_omqstat),
+       TP_STRUCT__entry(__field(mqd_t, mqdes) __field_hex(const struct mq_attr *, u_mqstat) __field_hex(struct mq_attr *, u_omqstat)),
+       TP_fast_assign(tp_assign(mqdes, mqdes) tp_assign(u_mqstat, u_mqstat) tp_assign(u_omqstat, u_omqstat)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_inotify_add_watch
+SC_TRACE_EVENT(sys_inotify_add_watch,
+       TP_PROTO(int fd, const char * pathname, u32 mask),
+       TP_ARGS(fd, pathname, mask),
+       TP_STRUCT__entry(__field(int, fd) __string_from_user(pathname, pathname) __field(u32, mask)),
+       TP_fast_assign(tp_assign(fd, fd) tp_copy_string_from_user(pathname, pathname) tp_assign(mask, mask)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_mkdirat
+SC_TRACE_EVENT(sys_mkdirat,
+       TP_PROTO(int dfd, const char * pathname, int mode),
+       TP_ARGS(dfd, pathname, mode),
+       TP_STRUCT__entry(__field(int, dfd) __string_from_user(pathname, pathname) __field(int, mode)),
+       TP_fast_assign(tp_assign(dfd, dfd) tp_copy_string_from_user(pathname, pathname) tp_assign(mode, mode)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_futimesat
+SC_TRACE_EVENT(sys_futimesat,
+       TP_PROTO(int dfd, const char * filename, struct timeval * utimes),
+       TP_ARGS(dfd, filename, utimes),
+       TP_STRUCT__entry(__field(int, dfd) __string_from_user(filename, filename) __field_hex(struct timeval *, utimes)),
+       TP_fast_assign(tp_assign(dfd, dfd) tp_copy_string_from_user(filename, filename) tp_assign(utimes, utimes)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_unlinkat
+SC_TRACE_EVENT(sys_unlinkat,
+       TP_PROTO(int dfd, const char * pathname, int flag),
+       TP_ARGS(dfd, pathname, flag),
+       TP_STRUCT__entry(__field(int, dfd) __string_from_user(pathname, pathname) __field(int, flag)),
+       TP_fast_assign(tp_assign(dfd, dfd) tp_copy_string_from_user(pathname, pathname) tp_assign(flag, flag)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_symlinkat
+SC_TRACE_EVENT(sys_symlinkat,
+       TP_PROTO(const char * oldname, int newdfd, const char * newname),
+       TP_ARGS(oldname, newdfd, newname),
+       TP_STRUCT__entry(__string_from_user(oldname, oldname) __field(int, newdfd) __string_from_user(newname, newname)),
+       TP_fast_assign(tp_copy_string_from_user(oldname, oldname) tp_assign(newdfd, newdfd) tp_copy_string_from_user(newname, newname)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_fchmodat
+SC_TRACE_EVENT(sys_fchmodat,
+       TP_PROTO(int dfd, const char * filename, mode_t mode),
+       TP_ARGS(dfd, filename, mode),
+       TP_STRUCT__entry(__field(int, dfd) __string_from_user(filename, filename) __field(mode_t, mode)),
+       TP_fast_assign(tp_assign(dfd, dfd) tp_copy_string_from_user(filename, filename) tp_assign(mode, mode)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_faccessat
+SC_TRACE_EVENT(sys_faccessat,
+       TP_PROTO(int dfd, const char * filename, int mode),
+       TP_ARGS(dfd, filename, mode),
+       TP_STRUCT__entry(__field(int, dfd) __string_from_user(filename, filename) __field(int, mode)),
+       TP_fast_assign(tp_assign(dfd, dfd) tp_copy_string_from_user(filename, filename) tp_assign(mode, mode)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_get_robust_list
+SC_TRACE_EVENT(sys_get_robust_list,
+       TP_PROTO(int pid, struct robust_list_head * * head_ptr, size_t * len_ptr),
+       TP_ARGS(pid, head_ptr, len_ptr),
+       TP_STRUCT__entry(__field(int, pid) __field_hex(struct robust_list_head * *, head_ptr) __field_hex(size_t *, len_ptr)),
+       TP_fast_assign(tp_assign(pid, pid) tp_assign(head_ptr, head_ptr) tp_assign(len_ptr, len_ptr)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_getcpu
+SC_TRACE_EVENT(sys_getcpu,
+       TP_PROTO(unsigned * cpup, unsigned * nodep, struct getcpu_cache * unused),
+       TP_ARGS(cpup, nodep, unused),
+       TP_STRUCT__entry(__field_hex(unsigned *, cpup) __field_hex(unsigned *, nodep) __field_hex(struct getcpu_cache *, unused)),
+       TP_fast_assign(tp_assign(cpup, cpup) tp_assign(nodep, nodep) tp_assign(unused, unused)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_signalfd
+SC_TRACE_EVENT(sys_signalfd,
+       TP_PROTO(int ufd, sigset_t * user_mask, size_t sizemask),
+       TP_ARGS(ufd, user_mask, sizemask),
+       TP_STRUCT__entry(__field(int, ufd) __field_hex(sigset_t *, user_mask) __field(size_t, sizemask)),
+       TP_fast_assign(tp_assign(ufd, ufd) tp_assign(user_mask, user_mask) tp_assign(sizemask, sizemask)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_bind
+SC_TRACE_EVENT(sys_bind,
+       TP_PROTO(int fd, struct sockaddr * umyaddr, int addrlen),
+       TP_ARGS(fd, umyaddr, addrlen),
+       TP_STRUCT__entry(__field(int, fd) __field_hex(struct sockaddr *, umyaddr) __field_hex(int, addrlen)),
+       TP_fast_assign(tp_assign(fd, fd) tp_assign(umyaddr, umyaddr) tp_assign(addrlen, addrlen)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_connect
+SC_TRACE_EVENT(sys_connect,
+       TP_PROTO(int fd, struct sockaddr * uservaddr, int addrlen),
+       TP_ARGS(fd, uservaddr, addrlen),
+       TP_STRUCT__entry(__field(int, fd) __field_hex(struct sockaddr *, uservaddr) __field_hex(int, addrlen)),
+       TP_fast_assign(tp_assign(fd, fd) tp_assign(uservaddr, uservaddr) tp_assign(addrlen, addrlen)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_accept
+SC_TRACE_EVENT(sys_accept,
+       TP_PROTO(int fd, struct sockaddr * upeer_sockaddr, int * upeer_addrlen),
+       TP_ARGS(fd, upeer_sockaddr, upeer_addrlen),
+       TP_STRUCT__entry(__field(int, fd) __field_hex(struct sockaddr *, upeer_sockaddr) __field_hex(int *, upeer_addrlen)),
+       TP_fast_assign(tp_assign(fd, fd) tp_assign(upeer_sockaddr, upeer_sockaddr) tp_assign(upeer_addrlen, upeer_addrlen)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_getsockname
+SC_TRACE_EVENT(sys_getsockname,
+       TP_PROTO(int fd, struct sockaddr * usockaddr, int * usockaddr_len),
+       TP_ARGS(fd, usockaddr, usockaddr_len),
+       TP_STRUCT__entry(__field(int, fd) __field_hex(struct sockaddr *, usockaddr) __field_hex(int *, usockaddr_len)),
+       TP_fast_assign(tp_assign(fd, fd) tp_assign(usockaddr, usockaddr) tp_assign(usockaddr_len, usockaddr_len)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_getpeername
+SC_TRACE_EVENT(sys_getpeername,
+       TP_PROTO(int fd, struct sockaddr * usockaddr, int * usockaddr_len),
+       TP_ARGS(fd, usockaddr, usockaddr_len),
+       TP_STRUCT__entry(__field(int, fd) __field_hex(struct sockaddr *, usockaddr) __field_hex(int *, usockaddr_len)),
+       TP_fast_assign(tp_assign(fd, fd) tp_assign(usockaddr, usockaddr) tp_assign(usockaddr_len, usockaddr_len)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_sendmsg
+SC_TRACE_EVENT(sys_sendmsg,
+       TP_PROTO(int fd, struct msghdr * msg, unsigned flags),
+       TP_ARGS(fd, msg, flags),
+       TP_STRUCT__entry(__field(int, fd) __field_hex(struct msghdr *, msg) __field(unsigned, flags)),
+       TP_fast_assign(tp_assign(fd, fd) tp_assign(msg, msg) tp_assign(flags, flags)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_recvmsg
+SC_TRACE_EVENT(sys_recvmsg,
+       TP_PROTO(int fd, struct msghdr * msg, unsigned int flags),
+       TP_ARGS(fd, msg, flags),
+       TP_STRUCT__entry(__field(int, fd) __field_hex(struct msghdr *, msg) __field(unsigned int, flags)),
+       TP_fast_assign(tp_assign(fd, fd) tp_assign(msg, msg) tp_assign(flags, flags)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_reboot
+SC_TRACE_EVENT(sys_reboot,
+       TP_PROTO(int magic1, int magic2, unsigned int cmd, void * arg),
+       TP_ARGS(magic1, magic2, cmd, arg),
+       TP_STRUCT__entry(__field(int, magic1) __field(int, magic2) __field(unsigned int, cmd) __field_hex(void *, arg)),
+       TP_fast_assign(tp_assign(magic1, magic1) tp_assign(magic2, magic2) tp_assign(cmd, cmd) tp_assign(arg, arg)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_wait4
+SC_TRACE_EVENT(sys_wait4,
+       TP_PROTO(pid_t upid, int * stat_addr, int options, struct rusage * ru),
+       TP_ARGS(upid, stat_addr, options, ru),
+       TP_STRUCT__entry(__field(pid_t, upid) __field_hex(int *, stat_addr) __field(int, options) __field_hex(struct rusage *, ru)),
+       TP_fast_assign(tp_assign(upid, upid) tp_assign(stat_addr, stat_addr) tp_assign(options, options) tp_assign(ru, ru)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_rt_sigaction
+SC_TRACE_EVENT(sys_rt_sigaction,
+       TP_PROTO(int sig, const struct sigaction * act, struct sigaction * oact, size_t sigsetsize),
+       TP_ARGS(sig, act, oact, sigsetsize),
+       TP_STRUCT__entry(__field(int, sig) __field_hex(const struct sigaction *, act) __field_hex(struct sigaction *, oact) __field(size_t, sigsetsize)),
+       TP_fast_assign(tp_assign(sig, sig) tp_assign(act, act) tp_assign(oact, oact) tp_assign(sigsetsize, sigsetsize)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_rt_sigprocmask
+SC_TRACE_EVENT(sys_rt_sigprocmask,
+       TP_PROTO(int how, sigset_t * nset, sigset_t * oset, size_t sigsetsize),
+       TP_ARGS(how, nset, oset, sigsetsize),
+       TP_STRUCT__entry(__field(int, how) __field_hex(sigset_t *, nset) __field_hex(sigset_t *, oset) __field(size_t, sigsetsize)),
+       TP_fast_assign(tp_assign(how, how) tp_assign(nset, nset) tp_assign(oset, oset) tp_assign(sigsetsize, sigsetsize)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_rt_sigtimedwait
+SC_TRACE_EVENT(sys_rt_sigtimedwait,
+       TP_PROTO(const sigset_t * uthese, siginfo_t * uinfo, const struct timespec * uts, size_t sigsetsize),
+       TP_ARGS(uthese, uinfo, uts, sigsetsize),
+       TP_STRUCT__entry(__field_hex(const sigset_t *, uthese) __field_hex(siginfo_t *, uinfo) __field_hex(const struct timespec *, uts) __field(size_t, sigsetsize)),
+       TP_fast_assign(tp_assign(uthese, uthese) tp_assign(uinfo, uinfo) tp_assign(uts, uts) tp_assign(sigsetsize, sigsetsize)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_sendfile
+SC_TRACE_EVENT(sys_sendfile,
+       TP_PROTO(int out_fd, int in_fd, off_t * offset, size_t count),
+       TP_ARGS(out_fd, in_fd, offset, count),
+       TP_STRUCT__entry(__field(int, out_fd) __field(int, in_fd) __field_hex(off_t *, offset) __field(size_t, count)),
+       TP_fast_assign(tp_assign(out_fd, out_fd) tp_assign(in_fd, in_fd) tp_assign(offset, offset) tp_assign(count, count)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_getxattr
+SC_TRACE_EVENT(sys_getxattr,
+       TP_PROTO(const char * pathname, const char * name, void * value, size_t size),
+       TP_ARGS(pathname, name, value, size),
+       TP_STRUCT__entry(__string_from_user(pathname, pathname) __string_from_user(name, name) __field_hex(void *, value) __field(size_t, size)),
+       TP_fast_assign(tp_copy_string_from_user(pathname, pathname) tp_copy_string_from_user(name, name) tp_assign(value, value) tp_assign(size, size)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_lgetxattr
+SC_TRACE_EVENT(sys_lgetxattr,
+       TP_PROTO(const char * pathname, const char * name, void * value, size_t size),
+       TP_ARGS(pathname, name, value, size),
+       TP_STRUCT__entry(__string_from_user(pathname, pathname) __string_from_user(name, name) __field_hex(void *, value) __field(size_t, size)),
+       TP_fast_assign(tp_copy_string_from_user(pathname, pathname) tp_copy_string_from_user(name, name) tp_assign(value, value) tp_assign(size, size)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_fgetxattr
+SC_TRACE_EVENT(sys_fgetxattr,
+       TP_PROTO(int fd, const char * name, void * value, size_t size),
+       TP_ARGS(fd, name, value, size),
+       TP_STRUCT__entry(__field(int, fd) __string_from_user(name, name) __field_hex(void *, value) __field(size_t, size)),
+       TP_fast_assign(tp_assign(fd, fd) tp_copy_string_from_user(name, name) tp_assign(value, value) tp_assign(size, size)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_sendfile64
+SC_TRACE_EVENT(sys_sendfile64,
+       TP_PROTO(int out_fd, int in_fd, loff_t * offset, size_t count),
+       TP_ARGS(out_fd, in_fd, offset, count),
+       TP_STRUCT__entry(__field(int, out_fd) __field(int, in_fd) __field_hex(loff_t *, offset) __field(size_t, count)),
+       TP_fast_assign(tp_assign(out_fd, out_fd) tp_assign(in_fd, in_fd) tp_assign(offset, offset) tp_assign(count, count)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_epoll_ctl
+SC_TRACE_EVENT(sys_epoll_ctl,
+       TP_PROTO(int epfd, int op, int fd, struct epoll_event * event),
+       TP_ARGS(epfd, op, fd, event),
+       TP_STRUCT__entry(__field(int, epfd) __field(int, op) __field(int, fd) __field_hex(struct epoll_event *, event)),
+       TP_fast_assign(tp_assign(epfd, epfd) tp_assign(op, op) tp_assign(fd, fd) tp_assign(event, event)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_epoll_wait
+SC_TRACE_EVENT(sys_epoll_wait,
+       TP_PROTO(int epfd, struct epoll_event * events, int maxevents, int timeout),
+       TP_ARGS(epfd, events, maxevents, timeout),
+       TP_STRUCT__entry(__field(int, epfd) __field_hex(struct epoll_event *, events) __field(int, maxevents) __field(int, timeout)),
+       TP_fast_assign(tp_assign(epfd, epfd) tp_assign(events, events) tp_assign(maxevents, maxevents) tp_assign(timeout, timeout)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_timer_settime
+SC_TRACE_EVENT(sys_timer_settime,
+       TP_PROTO(timer_t timer_id, int flags, const struct itimerspec * new_setting, struct itimerspec * old_setting),
+       TP_ARGS(timer_id, flags, new_setting, old_setting),
+       TP_STRUCT__entry(__field(timer_t, timer_id) __field(int, flags) __field_hex(const struct itimerspec *, new_setting) __field_hex(struct itimerspec *, old_setting)),
+       TP_fast_assign(tp_assign(timer_id, timer_id) tp_assign(flags, flags) tp_assign(new_setting, new_setting) tp_assign(old_setting, old_setting)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_clock_nanosleep
+SC_TRACE_EVENT(sys_clock_nanosleep,
+       TP_PROTO(const clockid_t which_clock, int flags, const struct timespec * rqtp, struct timespec * rmtp),
+       TP_ARGS(which_clock, flags, rqtp, rmtp),
+       TP_STRUCT__entry(__field(const clockid_t, which_clock) __field(int, flags) __field_hex(const struct timespec *, rqtp) __field_hex(struct timespec *, rmtp)),
+       TP_fast_assign(tp_assign(which_clock, which_clock) tp_assign(flags, flags) tp_assign(rqtp, rqtp) tp_assign(rmtp, rmtp)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_mq_open
+SC_TRACE_EVENT(sys_mq_open,
+       TP_PROTO(const char * u_name, int oflag, mode_t mode, struct mq_attr * u_attr),
+       TP_ARGS(u_name, oflag, mode, u_attr),
+       TP_STRUCT__entry(__string_from_user(u_name, u_name) __field(int, oflag) __field(mode_t, mode) __field_hex(struct mq_attr *, u_attr)),
+       TP_fast_assign(tp_copy_string_from_user(u_name, u_name) tp_assign(oflag, oflag) tp_assign(mode, mode) tp_assign(u_attr, u_attr)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_request_key
+SC_TRACE_EVENT(sys_request_key,
+       TP_PROTO(const char * _type, const char * _description, const char * _callout_info, key_serial_t destringid),
+       TP_ARGS(_type, _description, _callout_info, destringid),
+       TP_STRUCT__entry(__string_from_user(_type, _type) __field_hex(const char *, _description) __field_hex(const char *, _callout_info) __field(key_serial_t, destringid)),
+       TP_fast_assign(tp_copy_string_from_user(_type, _type) tp_assign(_description, _description) tp_assign(_callout_info, _callout_info) tp_assign(destringid, destringid)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_vmsplice
+SC_TRACE_EVENT(sys_vmsplice,
+       TP_PROTO(int fd, const struct iovec * iov, unsigned long nr_segs, unsigned int flags),
+       TP_ARGS(fd, iov, nr_segs, flags),
+       TP_STRUCT__entry(__field(int, fd) __field_hex(const struct iovec *, iov) __field(unsigned long, nr_segs) __field(unsigned int, flags)),
+       TP_fast_assign(tp_assign(fd, fd) tp_assign(iov, iov) tp_assign(nr_segs, nr_segs) tp_assign(flags, flags)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_openat
+SC_TRACE_EVENT(sys_openat,
+       TP_PROTO(int dfd, const char * filename, int flags, int mode),
+       TP_ARGS(dfd, filename, flags, mode),
+       TP_STRUCT__entry(__field(int, dfd) __string_from_user(filename, filename) __field(int, flags) __field(int, mode)),
+       TP_fast_assign(tp_assign(dfd, dfd) tp_copy_string_from_user(filename, filename) tp_assign(flags, flags) tp_assign(mode, mode)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_mknodat
+SC_TRACE_EVENT(sys_mknodat,
+       TP_PROTO(int dfd, const char * filename, int mode, unsigned dev),
+       TP_ARGS(dfd, filename, mode, dev),
+       TP_STRUCT__entry(__field(int, dfd) __string_from_user(filename, filename) __field(int, mode) __field(unsigned, dev)),
+       TP_fast_assign(tp_assign(dfd, dfd) tp_copy_string_from_user(filename, filename) tp_assign(mode, mode) tp_assign(dev, dev)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_fstatat64
+SC_TRACE_EVENT(sys_fstatat64,
+       TP_PROTO(int dfd, const char * filename, struct stat64 * statbuf, int flag),
+       TP_ARGS(dfd, filename, statbuf, flag),
+       TP_STRUCT__entry(__field(int, dfd) __string_from_user(filename, filename) __field_hex(struct stat64 *, statbuf) __field(int, flag)),
+       TP_fast_assign(tp_assign(dfd, dfd) tp_copy_string_from_user(filename, filename) tp_assign(statbuf, statbuf) tp_assign(flag, flag)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_renameat
+SC_TRACE_EVENT(sys_renameat,
+       TP_PROTO(int olddfd, const char * oldname, int newdfd, const char * newname),
+       TP_ARGS(olddfd, oldname, newdfd, newname),
+       TP_STRUCT__entry(__field(int, olddfd) __string_from_user(oldname, oldname) __field(int, newdfd) __string_from_user(newname, newname)),
+       TP_fast_assign(tp_assign(olddfd, olddfd) tp_copy_string_from_user(oldname, oldname) tp_assign(newdfd, newdfd) tp_copy_string_from_user(newname, newname)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_readlinkat
+SC_TRACE_EVENT(sys_readlinkat,
+       TP_PROTO(int dfd, const char * pathname, char * buf, int bufsiz),
+       TP_ARGS(dfd, pathname, buf, bufsiz),
+       TP_STRUCT__entry(__field(int, dfd) __string_from_user(pathname, pathname) __field_hex(char *, buf) __field(int, bufsiz)),
+       TP_fast_assign(tp_assign(dfd, dfd) tp_copy_string_from_user(pathname, pathname) tp_assign(buf, buf) tp_assign(bufsiz, bufsiz)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_utimensat
+SC_TRACE_EVENT(sys_utimensat,
+       TP_PROTO(int dfd, const char * filename, struct timespec * utimes, int flags),
+       TP_ARGS(dfd, filename, utimes, flags),
+       TP_STRUCT__entry(__field(int, dfd) __string_from_user(filename, filename) __field_hex(struct timespec *, utimes) __field(int, flags)),
+       TP_fast_assign(tp_assign(dfd, dfd) tp_copy_string_from_user(filename, filename) tp_assign(utimes, utimes) tp_assign(flags, flags)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_timerfd_settime
+SC_TRACE_EVENT(sys_timerfd_settime,
+       TP_PROTO(int ufd, int flags, const struct itimerspec * utmr, struct itimerspec * otmr),
+       TP_ARGS(ufd, flags, utmr, otmr),
+       TP_STRUCT__entry(__field(int, ufd) __field(int, flags) __field_hex(const struct itimerspec *, utmr) __field_hex(struct itimerspec *, otmr)),
+       TP_fast_assign(tp_assign(ufd, ufd) tp_assign(flags, flags) tp_assign(utmr, utmr) tp_assign(otmr, otmr)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_signalfd4
+SC_TRACE_EVENT(sys_signalfd4,
+       TP_PROTO(int ufd, sigset_t * user_mask, size_t sizemask, int flags),
+       TP_ARGS(ufd, user_mask, sizemask, flags),
+       TP_STRUCT__entry(__field(int, ufd) __field_hex(sigset_t *, user_mask) __field(size_t, sizemask) __field(int, flags)),
+       TP_fast_assign(tp_assign(ufd, ufd) tp_assign(user_mask, user_mask) tp_assign(sizemask, sizemask) tp_assign(flags, flags)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_rt_tgsigqueueinfo
+SC_TRACE_EVENT(sys_rt_tgsigqueueinfo,
+       TP_PROTO(pid_t tgid, pid_t pid, int sig, siginfo_t * uinfo),
+       TP_ARGS(tgid, pid, sig, uinfo),
+       TP_STRUCT__entry(__field(pid_t, tgid) __field(pid_t, pid) __field(int, sig) __field_hex(siginfo_t *, uinfo)),
+       TP_fast_assign(tp_assign(tgid, tgid) tp_assign(pid, pid) tp_assign(sig, sig) tp_assign(uinfo, uinfo)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_prlimit64
+SC_TRACE_EVENT(sys_prlimit64,
+       TP_PROTO(pid_t pid, unsigned int resource, const struct rlimit64 * new_rlim, struct rlimit64 * old_rlim),
+       TP_ARGS(pid, resource, new_rlim, old_rlim),
+       TP_STRUCT__entry(__field(pid_t, pid) __field(unsigned int, resource) __field_hex(const struct rlimit64 *, new_rlim) __field_hex(struct rlimit64 *, old_rlim)),
+       TP_fast_assign(tp_assign(pid, pid) tp_assign(resource, resource) tp_assign(new_rlim, new_rlim) tp_assign(old_rlim, old_rlim)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_socketpair
+SC_TRACE_EVENT(sys_socketpair,
+       TP_PROTO(int family, int type, int protocol, int * usockvec),
+       TP_ARGS(family, type, protocol, usockvec),
+       TP_STRUCT__entry(__field(int, family) __field(int, type) __field(int, protocol) __field_hex(int *, usockvec)),
+       TP_fast_assign(tp_assign(family, family) tp_assign(type, type) tp_assign(protocol, protocol) tp_assign(usockvec, usockvec)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_send
+SC_TRACE_EVENT(sys_send,
+       TP_PROTO(int fd, void * buff, size_t len, unsigned flags),
+       TP_ARGS(fd, buff, len, flags),
+       TP_STRUCT__entry(__field(int, fd) __field_hex(void *, buff) __field(size_t, len) __field(unsigned, flags)),
+       TP_fast_assign(tp_assign(fd, fd) tp_assign(buff, buff) tp_assign(len, len) tp_assign(flags, flags)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_accept4
+SC_TRACE_EVENT(sys_accept4,
+       TP_PROTO(int fd, struct sockaddr * upeer_sockaddr, int * upeer_addrlen, int flags),
+       TP_ARGS(fd, upeer_sockaddr, upeer_addrlen, flags),
+       TP_STRUCT__entry(__field(int, fd) __field_hex(struct sockaddr *, upeer_sockaddr) __field_hex(int *, upeer_addrlen) __field(int, flags)),
+       TP_fast_assign(tp_assign(fd, fd) tp_assign(upeer_sockaddr, upeer_sockaddr) tp_assign(upeer_addrlen, upeer_addrlen) tp_assign(flags, flags)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_sendmmsg
+SC_TRACE_EVENT(sys_sendmmsg,
+       TP_PROTO(int fd, struct mmsghdr * mmsg, unsigned int vlen, unsigned int flags),
+       TP_ARGS(fd, mmsg, vlen, flags),
+       TP_STRUCT__entry(__field(int, fd) __field_hex(struct mmsghdr *, mmsg) __field(unsigned int, vlen) __field(unsigned int, flags)),
+       TP_fast_assign(tp_assign(fd, fd) tp_assign(mmsg, mmsg) tp_assign(vlen, vlen) tp_assign(flags, flags)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_mount
+SC_TRACE_EVENT(sys_mount,
+       TP_PROTO(char * dev_name, char * dir_name, char * type, unsigned long flags, void * data),
+       TP_ARGS(dev_name, dir_name, type, flags, data),
+       TP_STRUCT__entry(__string_from_user(dev_name, dev_name) __string_from_user(dir_name, dir_name) __string_from_user(type, type) __field(unsigned long, flags) __field_hex(void *, data)),
+       TP_fast_assign(tp_copy_string_from_user(dev_name, dev_name) tp_copy_string_from_user(dir_name, dir_name) tp_copy_string_from_user(type, type) tp_assign(flags, flags) tp_assign(data, data)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_llseek
+SC_TRACE_EVENT(sys_llseek,
+       TP_PROTO(unsigned int fd, unsigned long offset_high, unsigned long offset_low, loff_t * result, unsigned int origin),
+       TP_ARGS(fd, offset_high, offset_low, result, origin),
+       TP_STRUCT__entry(__field(unsigned int, fd) __field(unsigned long, offset_high) __field(unsigned long, offset_low) __field_hex(loff_t *, result) __field(unsigned int, origin)),
+       TP_fast_assign(tp_assign(fd, fd) tp_assign(offset_high, offset_high) tp_assign(offset_low, offset_low) tp_assign(result, result) tp_assign(origin, origin)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_select
+SC_TRACE_EVENT(sys_select,
+       TP_PROTO(int n, fd_set * inp, fd_set * outp, fd_set * exp, struct timeval * tvp),
+       TP_ARGS(n, inp, outp, exp, tvp),
+       TP_STRUCT__entry(__field(int, n) __field_hex(fd_set *, inp) __field_hex(fd_set *, outp) __field_hex(fd_set *, exp) __field_hex(struct timeval *, tvp)),
+       TP_fast_assign(tp_assign(n, n) tp_assign(inp, inp) tp_assign(outp, outp) tp_assign(exp, exp) tp_assign(tvp, tvp)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_pciconfig_read
+SC_TRACE_EVENT(sys_pciconfig_read,
+       TP_PROTO(unsigned long bus, unsigned long dfn, unsigned long off, unsigned long len, void * buf),
+       TP_ARGS(bus, dfn, off, len, buf),
+       TP_STRUCT__entry(__field(unsigned long, bus) __field(unsigned long, dfn) __field(unsigned long, off) __field(unsigned long, len) __field_hex(void *, buf)),
+       TP_fast_assign(tp_assign(bus, bus) tp_assign(dfn, dfn) tp_assign(off, off) tp_assign(len, len) tp_assign(buf, buf)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_pciconfig_write
+SC_TRACE_EVENT(sys_pciconfig_write,
+       TP_PROTO(unsigned long bus, unsigned long dfn, unsigned long off, unsigned long len, void * buf),
+       TP_ARGS(bus, dfn, off, len, buf),
+       TP_STRUCT__entry(__field(unsigned long, bus) __field(unsigned long, dfn) __field(unsigned long, off) __field(unsigned long, len) __field_hex(void *, buf)),
+       TP_fast_assign(tp_assign(bus, bus) tp_assign(dfn, dfn) tp_assign(off, off) tp_assign(len, len) tp_assign(buf, buf)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_setxattr
+SC_TRACE_EVENT(sys_setxattr,
+       TP_PROTO(const char * pathname, const char * name, const void * value, size_t size, int flags),
+       TP_ARGS(pathname, name, value, size, flags),
+       TP_STRUCT__entry(__string_from_user(pathname, pathname) __string_from_user(name, name) __field_hex(const void *, value) __field(size_t, size) __field(int, flags)),
+       TP_fast_assign(tp_copy_string_from_user(pathname, pathname) tp_copy_string_from_user(name, name) tp_assign(value, value) tp_assign(size, size) tp_assign(flags, flags)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_lsetxattr
+SC_TRACE_EVENT(sys_lsetxattr,
+       TP_PROTO(const char * pathname, const char * name, const void * value, size_t size, int flags),
+       TP_ARGS(pathname, name, value, size, flags),
+       TP_STRUCT__entry(__string_from_user(pathname, pathname) __string_from_user(name, name) __field_hex(const void *, value) __field(size_t, size) __field(int, flags)),
+       TP_fast_assign(tp_copy_string_from_user(pathname, pathname) tp_copy_string_from_user(name, name) tp_assign(value, value) tp_assign(size, size) tp_assign(flags, flags)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_fsetxattr
+SC_TRACE_EVENT(sys_fsetxattr,
+       TP_PROTO(int fd, const char * name, const void * value, size_t size, int flags),
+       TP_ARGS(fd, name, value, size, flags),
+       TP_STRUCT__entry(__field(int, fd) __string_from_user(name, name) __field_hex(const void *, value) __field(size_t, size) __field(int, flags)),
+       TP_fast_assign(tp_assign(fd, fd) tp_copy_string_from_user(name, name) tp_assign(value, value) tp_assign(size, size) tp_assign(flags, flags)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_io_getevents
+SC_TRACE_EVENT(sys_io_getevents,
+       TP_PROTO(aio_context_t ctx_id, long min_nr, long nr, struct io_event * events, struct timespec * timeout),
+       TP_ARGS(ctx_id, min_nr, nr, events, timeout),
+       TP_STRUCT__entry(__field(aio_context_t, ctx_id) __field(long, min_nr) __field(long, nr) __field_hex(struct io_event *, events) __field_hex(struct timespec *, timeout)),
+       TP_fast_assign(tp_assign(ctx_id, ctx_id) tp_assign(min_nr, min_nr) tp_assign(nr, nr) tp_assign(events, events) tp_assign(timeout, timeout)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_mq_timedsend
+SC_TRACE_EVENT(sys_mq_timedsend,
+       TP_PROTO(mqd_t mqdes, const char * u_msg_ptr, size_t msg_len, unsigned int msg_prio, const struct timespec * u_abs_timeout),
+       TP_ARGS(mqdes, u_msg_ptr, msg_len, msg_prio, u_abs_timeout),
+       TP_STRUCT__entry(__field(mqd_t, mqdes) __field_hex(const char *, u_msg_ptr) __field(size_t, msg_len) __field(unsigned int, msg_prio) __field_hex(const struct timespec *, u_abs_timeout)),
+       TP_fast_assign(tp_assign(mqdes, mqdes) tp_assign(u_msg_ptr, u_msg_ptr) tp_assign(msg_len, msg_len) tp_assign(msg_prio, msg_prio) tp_assign(u_abs_timeout, u_abs_timeout)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_mq_timedreceive
+SC_TRACE_EVENT(sys_mq_timedreceive,
+       TP_PROTO(mqd_t mqdes, char * u_msg_ptr, size_t msg_len, unsigned int * u_msg_prio, const struct timespec * u_abs_timeout),
+       TP_ARGS(mqdes, u_msg_ptr, msg_len, u_msg_prio, u_abs_timeout),
+       TP_STRUCT__entry(__field(mqd_t, mqdes) __field_hex(char *, u_msg_ptr) __field(size_t, msg_len) __field_hex(unsigned int *, u_msg_prio) __field_hex(const struct timespec *, u_abs_timeout)),
+       TP_fast_assign(tp_assign(mqdes, mqdes) tp_assign(u_msg_ptr, u_msg_ptr) tp_assign(msg_len, msg_len) tp_assign(u_msg_prio, u_msg_prio) tp_assign(u_abs_timeout, u_abs_timeout)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_add_key
+SC_TRACE_EVENT(sys_add_key,
+       TP_PROTO(const char * _type, const char * _description, const void * _payload, size_t plen, key_serial_t ringid),
+       TP_ARGS(_type, _description, _payload, plen, ringid),
+       TP_STRUCT__entry(__string_from_user(_type, _type) __field_hex(const char *, _description) __field_hex(const void *, _payload) __field(size_t, plen) __field(key_serial_t, ringid)),
+       TP_fast_assign(tp_copy_string_from_user(_type, _type) tp_assign(_description, _description) tp_assign(_payload, _payload) tp_assign(plen, plen) tp_assign(ringid, ringid)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_waitid
+SC_TRACE_EVENT(sys_waitid,
+       TP_PROTO(int which, pid_t upid, struct siginfo * infop, int options, struct rusage * ru),
+       TP_ARGS(which, upid, infop, options, ru),
+       TP_STRUCT__entry(__field(int, which) __field(pid_t, upid) __field_hex(struct siginfo *, infop) __field(int, options) __field_hex(struct rusage *, ru)),
+       TP_fast_assign(tp_assign(which, which) tp_assign(upid, upid) tp_assign(infop, infop) tp_assign(options, options) tp_assign(ru, ru)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_ppoll
+SC_TRACE_EVENT(sys_ppoll,
+       TP_PROTO(struct pollfd * ufds, unsigned int nfds, struct timespec * tsp, const sigset_t * sigmask, size_t sigsetsize),
+       TP_ARGS(ufds, nfds, tsp, sigmask, sigsetsize),
+       TP_STRUCT__entry(__field_hex(struct pollfd *, ufds) __field(unsigned int, nfds) __field_hex(struct timespec *, tsp) __field_hex(const sigset_t *, sigmask) __field(size_t, sigsetsize)),
+       TP_fast_assign(tp_assign(ufds, ufds) tp_assign(nfds, nfds) tp_assign(tsp, tsp) tp_assign(sigmask, sigmask) tp_assign(sigsetsize, sigsetsize)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_fchownat
+SC_TRACE_EVENT(sys_fchownat,
+       TP_PROTO(int dfd, const char * filename, uid_t user, gid_t group, int flag),
+       TP_ARGS(dfd, filename, user, group, flag),
+       TP_STRUCT__entry(__field(int, dfd) __string_from_user(filename, filename) __field(uid_t, user) __field(gid_t, group) __field(int, flag)),
+       TP_fast_assign(tp_assign(dfd, dfd) tp_copy_string_from_user(filename, filename) tp_assign(user, user) tp_assign(group, group) tp_assign(flag, flag)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_linkat
+SC_TRACE_EVENT(sys_linkat,
+       TP_PROTO(int olddfd, const char * oldname, int newdfd, const char * newname, int flags),
+       TP_ARGS(olddfd, oldname, newdfd, newname, flags),
+       TP_STRUCT__entry(__field(int, olddfd) __string_from_user(oldname, oldname) __field(int, newdfd) __string_from_user(newname, newname) __field(int, flags)),
+       TP_fast_assign(tp_assign(olddfd, olddfd) tp_copy_string_from_user(oldname, oldname) tp_assign(newdfd, newdfd) tp_copy_string_from_user(newname, newname) tp_assign(flags, flags)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_perf_event_open
+SC_TRACE_EVENT(sys_perf_event_open,
+       TP_PROTO(struct perf_event_attr * attr_uptr, pid_t pid, int cpu, int group_fd, unsigned long flags),
+       TP_ARGS(attr_uptr, pid, cpu, group_fd, flags),
+       TP_STRUCT__entry(__field_hex(struct perf_event_attr *, attr_uptr) __field(pid_t, pid) __field(int, cpu) __field(int, group_fd) __field(unsigned long, flags)),
+       TP_fast_assign(tp_assign(attr_uptr, attr_uptr) tp_assign(pid, pid) tp_assign(cpu, cpu) tp_assign(group_fd, group_fd) tp_assign(flags, flags)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_preadv
+SC_TRACE_EVENT(sys_preadv,
+       TP_PROTO(unsigned long fd, const struct iovec * vec, unsigned long vlen, unsigned long pos_l, unsigned long pos_h),
+       TP_ARGS(fd, vec, vlen, pos_l, pos_h),
+       TP_STRUCT__entry(__field(unsigned long, fd) __field_hex(const struct iovec *, vec) __field(unsigned long, vlen) __field(unsigned long, pos_l) __field(unsigned long, pos_h)),
+       TP_fast_assign(tp_assign(fd, fd) tp_assign(vec, vec) tp_assign(vlen, vlen) tp_assign(pos_l, pos_l) tp_assign(pos_h, pos_h)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_pwritev
+SC_TRACE_EVENT(sys_pwritev,
+       TP_PROTO(unsigned long fd, const struct iovec * vec, unsigned long vlen, unsigned long pos_l, unsigned long pos_h),
+       TP_ARGS(fd, vec, vlen, pos_l, pos_h),
+       TP_STRUCT__entry(__field(unsigned long, fd) __field_hex(const struct iovec *, vec) __field(unsigned long, vlen) __field(unsigned long, pos_l) __field(unsigned long, pos_h)),
+       TP_fast_assign(tp_assign(fd, fd) tp_assign(vec, vec) tp_assign(vlen, vlen) tp_assign(pos_l, pos_l) tp_assign(pos_h, pos_h)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_setsockopt
+SC_TRACE_EVENT(sys_setsockopt,
+       TP_PROTO(int fd, int level, int optname, char * optval, int optlen),
+       TP_ARGS(fd, level, optname, optval, optlen),
+       TP_STRUCT__entry(__field(int, fd) __field(int, level) __field(int, optname) __field_hex(char *, optval) __field(int, optlen)),
+       TP_fast_assign(tp_assign(fd, fd) tp_assign(level, level) tp_assign(optname, optname) tp_assign(optval, optval) tp_assign(optlen, optlen)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_getsockopt
+SC_TRACE_EVENT(sys_getsockopt,
+       TP_PROTO(int fd, int level, int optname, char * optval, int * optlen),
+       TP_ARGS(fd, level, optname, optval, optlen),
+       TP_STRUCT__entry(__field(int, fd) __field(int, level) __field(int, optname) __field_hex(char *, optval) __field_hex(int *, optlen)),
+       TP_fast_assign(tp_assign(fd, fd) tp_assign(level, level) tp_assign(optname, optname) tp_assign(optval, optval) tp_assign(optlen, optlen)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_recvmmsg
+SC_TRACE_EVENT(sys_recvmmsg,
+       TP_PROTO(int fd, struct mmsghdr * mmsg, unsigned int vlen, unsigned int flags, struct timespec * timeout),
+       TP_ARGS(fd, mmsg, vlen, flags, timeout),
+       TP_STRUCT__entry(__field(int, fd) __field_hex(struct mmsghdr *, mmsg) __field(unsigned int, vlen) __field(unsigned int, flags) __field_hex(struct timespec *, timeout)),
+       TP_fast_assign(tp_assign(fd, fd) tp_assign(mmsg, mmsg) tp_assign(vlen, vlen) tp_assign(flags, flags) tp_assign(timeout, timeout)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_ipc
+SC_TRACE_EVENT(sys_ipc,
+       TP_PROTO(unsigned int call, int first, unsigned long second, unsigned long third, void * ptr, long fifth),
+       TP_ARGS(call, first, second, third, ptr, fifth),
+       TP_STRUCT__entry(__field(unsigned int, call) __field(int, first) __field(unsigned long, second) __field(unsigned long, third) __field_hex(void *, ptr) __field(long, fifth)),
+       TP_fast_assign(tp_assign(call, call) tp_assign(first, first) tp_assign(second, second) tp_assign(third, third) tp_assign(ptr, ptr) tp_assign(fifth, fifth)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_futex
+SC_TRACE_EVENT(sys_futex,
+       TP_PROTO(u32 * uaddr, int op, u32 val, struct timespec * utime, u32 * uaddr2, u32 val3),
+       TP_ARGS(uaddr, op, val, utime, uaddr2, val3),
+       TP_STRUCT__entry(__field_hex(u32 *, uaddr) __field(int, op) __field(u32, val) __field_hex(struct timespec *, utime) __field_hex(u32 *, uaddr2) __field(u32, val3)),
+       TP_fast_assign(tp_assign(uaddr, uaddr) tp_assign(op, op) tp_assign(val, val) tp_assign(utime, utime) tp_assign(uaddr2, uaddr2) tp_assign(val3, val3)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_pselect6
+SC_TRACE_EVENT(sys_pselect6,
+       TP_PROTO(int n, fd_set * inp, fd_set * outp, fd_set * exp, struct timespec * tsp, void * sig),
+       TP_ARGS(n, inp, outp, exp, tsp, sig),
+       TP_STRUCT__entry(__field(int, n) __field_hex(fd_set *, inp) __field_hex(fd_set *, outp) __field_hex(fd_set *, exp) __field_hex(struct timespec *, tsp) __field_hex(void *, sig)),
+       TP_fast_assign(tp_assign(n, n) tp_assign(inp, inp) tp_assign(outp, outp) tp_assign(exp, exp) tp_assign(tsp, tsp) tp_assign(sig, sig)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_splice
+SC_TRACE_EVENT(sys_splice,
+       TP_PROTO(int fd_in, loff_t * off_in, int fd_out, loff_t * off_out, size_t len, unsigned int flags),
+       TP_ARGS(fd_in, off_in, fd_out, off_out, len, flags),
+       TP_STRUCT__entry(__field(int, fd_in) __field_hex(loff_t *, off_in) __field(int, fd_out) __field_hex(loff_t *, off_out) __field(size_t, len) __field(unsigned int, flags)),
+       TP_fast_assign(tp_assign(fd_in, fd_in) tp_assign(off_in, off_in) tp_assign(fd_out, fd_out) tp_assign(off_out, off_out) tp_assign(len, len) tp_assign(flags, flags)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_epoll_pwait
+SC_TRACE_EVENT(sys_epoll_pwait,
+       TP_PROTO(int epfd, struct epoll_event * events, int maxevents, int timeout, const sigset_t * sigmask, size_t sigsetsize),
+       TP_ARGS(epfd, events, maxevents, timeout, sigmask, sigsetsize),
+       TP_STRUCT__entry(__field(int, epfd) __field_hex(struct epoll_event *, events) __field(int, maxevents) __field(int, timeout) __field_hex(const sigset_t *, sigmask) __field(size_t, sigsetsize)),
+       TP_fast_assign(tp_assign(epfd, epfd) tp_assign(events, events) tp_assign(maxevents, maxevents) tp_assign(timeout, timeout) tp_assign(sigmask, sigmask) tp_assign(sigsetsize, sigsetsize)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_sendto
+SC_TRACE_EVENT(sys_sendto,
+       TP_PROTO(int fd, void * buff, size_t len, unsigned flags, struct sockaddr * addr, int addr_len),
+       TP_ARGS(fd, buff, len, flags, addr, addr_len),
+       TP_STRUCT__entry(__field(int, fd) __field_hex(void *, buff) __field(size_t, len) __field(unsigned, flags) __field_hex(struct sockaddr *, addr) __field_hex(int, addr_len)),
+       TP_fast_assign(tp_assign(fd, fd) tp_assign(buff, buff) tp_assign(len, len) tp_assign(flags, flags) tp_assign(addr, addr) tp_assign(addr_len, addr_len)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_recvfrom
+SC_TRACE_EVENT(sys_recvfrom,
+       TP_PROTO(int fd, void * ubuf, size_t size, unsigned flags, struct sockaddr * addr, int * addr_len),
+       TP_ARGS(fd, ubuf, size, flags, addr, addr_len),
+       TP_STRUCT__entry(__field(int, fd) __field_hex(void *, ubuf) __field(size_t, size) __field(unsigned, flags) __field_hex(struct sockaddr *, addr) __field_hex(int *, addr_len)),
+       TP_fast_assign(tp_assign(fd, fd) tp_assign(ubuf, ubuf) tp_assign(size, size) tp_assign(flags, flags) tp_assign(addr, addr) tp_assign(addr_len, addr_len)),
+       TP_printk()
+)
+#endif
+
+#endif /*  _TRACE_SYSCALLS_POINTERS_H */
+
+/* This part must be outside protection */
+#include "../../../probes/define_trace.h"
+
+#else /* CREATE_SYSCALL_TABLE */
+
+#include "powerpc-32-syscalls-3.0.34_pointers_override.h"
+#include "syscalls_pointers_override.h"
+
+#ifndef OVERRIDE_TABLE_32_sys_read
+TRACE_SYSCALL_TABLE(sys_read, sys_read, 3, 3)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_write
+TRACE_SYSCALL_TABLE(sys_write, sys_write, 4, 3)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_open
+TRACE_SYSCALL_TABLE(sys_open, sys_open, 5, 3)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_waitpid
+TRACE_SYSCALL_TABLE(sys_waitpid, sys_waitpid, 7, 3)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_creat
+TRACE_SYSCALL_TABLE(sys_creat, sys_creat, 8, 2)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_link
+TRACE_SYSCALL_TABLE(sys_link, sys_link, 9, 2)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_unlink
+TRACE_SYSCALL_TABLE(sys_unlink, sys_unlink, 10, 1)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_chdir
+TRACE_SYSCALL_TABLE(sys_chdir, sys_chdir, 12, 1)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_time
+TRACE_SYSCALL_TABLE(sys_time, sys_time, 13, 1)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_mknod
+TRACE_SYSCALL_TABLE(sys_mknod, sys_mknod, 14, 3)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_chmod
+TRACE_SYSCALL_TABLE(sys_chmod, sys_chmod, 15, 2)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_lchown
+TRACE_SYSCALL_TABLE(sys_lchown, sys_lchown, 16, 3)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_stat
+TRACE_SYSCALL_TABLE(sys_stat, sys_stat, 18, 2)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_mount
+TRACE_SYSCALL_TABLE(sys_mount, sys_mount, 21, 5)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_oldumount
+TRACE_SYSCALL_TABLE(sys_oldumount, sys_oldumount, 22, 1)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_stime
+TRACE_SYSCALL_TABLE(sys_stime, sys_stime, 25, 1)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_fstat
+TRACE_SYSCALL_TABLE(sys_fstat, sys_fstat, 28, 2)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_utime
+TRACE_SYSCALL_TABLE(sys_utime, sys_utime, 30, 2)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_access
+TRACE_SYSCALL_TABLE(sys_access, sys_access, 33, 2)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_rename
+TRACE_SYSCALL_TABLE(sys_rename, sys_rename, 38, 2)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_mkdir
+TRACE_SYSCALL_TABLE(sys_mkdir, sys_mkdir, 39, 2)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_rmdir
+TRACE_SYSCALL_TABLE(sys_rmdir, sys_rmdir, 40, 1)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_pipe
+TRACE_SYSCALL_TABLE(sys_pipe, sys_pipe, 42, 1)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_times
+TRACE_SYSCALL_TABLE(sys_times, sys_times, 43, 1)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_acct
+TRACE_SYSCALL_TABLE(sys_acct, sys_acct, 51, 1)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_umount
+TRACE_SYSCALL_TABLE(sys_umount, sys_umount, 52, 2)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_olduname
+TRACE_SYSCALL_TABLE(sys_olduname, sys_olduname, 59, 1)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_chroot
+TRACE_SYSCALL_TABLE(sys_chroot, sys_chroot, 61, 1)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_ustat
+TRACE_SYSCALL_TABLE(sys_ustat, sys_ustat, 62, 2)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_sigpending
+TRACE_SYSCALL_TABLE(sys_sigpending, sys_sigpending, 73, 1)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_sethostname
+TRACE_SYSCALL_TABLE(sys_sethostname, sys_sethostname, 74, 2)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_setrlimit
+TRACE_SYSCALL_TABLE(sys_setrlimit, sys_setrlimit, 75, 2)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_old_getrlimit
+TRACE_SYSCALL_TABLE(sys_old_getrlimit, sys_old_getrlimit, 76, 2)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_getrusage
+TRACE_SYSCALL_TABLE(sys_getrusage, sys_getrusage, 77, 2)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_gettimeofday
+TRACE_SYSCALL_TABLE(sys_gettimeofday, sys_gettimeofday, 78, 2)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_settimeofday
+TRACE_SYSCALL_TABLE(sys_settimeofday, sys_settimeofday, 79, 2)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_getgroups
+TRACE_SYSCALL_TABLE(sys_getgroups, sys_getgroups, 80, 2)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_setgroups
+TRACE_SYSCALL_TABLE(sys_setgroups, sys_setgroups, 81, 2)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_symlink
+TRACE_SYSCALL_TABLE(sys_symlink, sys_symlink, 83, 2)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_lstat
+TRACE_SYSCALL_TABLE(sys_lstat, sys_lstat, 84, 2)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_readlink
+TRACE_SYSCALL_TABLE(sys_readlink, sys_readlink, 85, 3)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_uselib
+TRACE_SYSCALL_TABLE(sys_uselib, sys_uselib, 86, 1)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_swapon
+TRACE_SYSCALL_TABLE(sys_swapon, sys_swapon, 87, 2)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_reboot
+TRACE_SYSCALL_TABLE(sys_reboot, sys_reboot, 88, 4)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_old_readdir
+TRACE_SYSCALL_TABLE(sys_old_readdir, sys_old_readdir, 89, 3)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_truncate
+TRACE_SYSCALL_TABLE(sys_truncate, sys_truncate, 92, 2)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_statfs
+TRACE_SYSCALL_TABLE(sys_statfs, sys_statfs, 99, 2)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_fstatfs
+TRACE_SYSCALL_TABLE(sys_fstatfs, sys_fstatfs, 100, 2)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_socketcall
+TRACE_SYSCALL_TABLE(sys_socketcall, sys_socketcall, 102, 2)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_syslog
+TRACE_SYSCALL_TABLE(sys_syslog, sys_syslog, 103, 3)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_setitimer
+TRACE_SYSCALL_TABLE(sys_setitimer, sys_setitimer, 104, 3)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_getitimer
+TRACE_SYSCALL_TABLE(sys_getitimer, sys_getitimer, 105, 2)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_newstat
+TRACE_SYSCALL_TABLE(sys_newstat, sys_newstat, 106, 2)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_newlstat
+TRACE_SYSCALL_TABLE(sys_newlstat, sys_newlstat, 107, 2)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_newfstat
+TRACE_SYSCALL_TABLE(sys_newfstat, sys_newfstat, 108, 2)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_uname
+TRACE_SYSCALL_TABLE(sys_uname, sys_uname, 109, 1)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_wait4
+TRACE_SYSCALL_TABLE(sys_wait4, sys_wait4, 114, 4)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_swapoff
+TRACE_SYSCALL_TABLE(sys_swapoff, sys_swapoff, 115, 1)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_sysinfo
+TRACE_SYSCALL_TABLE(sys_sysinfo, sys_sysinfo, 116, 1)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_ipc
+TRACE_SYSCALL_TABLE(sys_ipc, sys_ipc, 117, 6)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_setdomainname
+TRACE_SYSCALL_TABLE(sys_setdomainname, sys_setdomainname, 121, 2)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_newuname
+TRACE_SYSCALL_TABLE(sys_newuname, sys_newuname, 122, 1)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_adjtimex
+TRACE_SYSCALL_TABLE(sys_adjtimex, sys_adjtimex, 124, 1)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_sigprocmask
+TRACE_SYSCALL_TABLE(sys_sigprocmask, sys_sigprocmask, 126, 3)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_init_module
+TRACE_SYSCALL_TABLE(sys_init_module, sys_init_module, 128, 3)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_delete_module
+TRACE_SYSCALL_TABLE(sys_delete_module, sys_delete_module, 129, 2)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_llseek
+TRACE_SYSCALL_TABLE(sys_llseek, sys_llseek, 140, 5)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_getdents
+TRACE_SYSCALL_TABLE(sys_getdents, sys_getdents, 141, 3)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_select
+TRACE_SYSCALL_TABLE(sys_select, sys_select, 142, 5)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_readv
+TRACE_SYSCALL_TABLE(sys_readv, sys_readv, 145, 3)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_writev
+TRACE_SYSCALL_TABLE(sys_writev, sys_writev, 146, 3)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_sysctl
+TRACE_SYSCALL_TABLE(sys_sysctl, sys_sysctl, 149, 1)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_sched_setparam
+TRACE_SYSCALL_TABLE(sys_sched_setparam, sys_sched_setparam, 154, 2)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_sched_getparam
+TRACE_SYSCALL_TABLE(sys_sched_getparam, sys_sched_getparam, 155, 2)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_sched_setscheduler
+TRACE_SYSCALL_TABLE(sys_sched_setscheduler, sys_sched_setscheduler, 156, 3)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_sched_rr_get_interval
+TRACE_SYSCALL_TABLE(sys_sched_rr_get_interval, sys_sched_rr_get_interval, 161, 2)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_nanosleep
+TRACE_SYSCALL_TABLE(sys_nanosleep, sys_nanosleep, 162, 2)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_getresuid
+TRACE_SYSCALL_TABLE(sys_getresuid, sys_getresuid, 165, 3)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_poll
+TRACE_SYSCALL_TABLE(sys_poll, sys_poll, 167, 3)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_nfsservctl
+TRACE_SYSCALL_TABLE(sys_nfsservctl, sys_nfsservctl, 168, 3)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_getresgid
+TRACE_SYSCALL_TABLE(sys_getresgid, sys_getresgid, 170, 3)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_rt_sigaction
+TRACE_SYSCALL_TABLE(sys_rt_sigaction, sys_rt_sigaction, 173, 4)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_rt_sigprocmask
+TRACE_SYSCALL_TABLE(sys_rt_sigprocmask, sys_rt_sigprocmask, 174, 4)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_rt_sigpending
+TRACE_SYSCALL_TABLE(sys_rt_sigpending, sys_rt_sigpending, 175, 2)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_rt_sigtimedwait
+TRACE_SYSCALL_TABLE(sys_rt_sigtimedwait, sys_rt_sigtimedwait, 176, 4)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_rt_sigqueueinfo
+TRACE_SYSCALL_TABLE(sys_rt_sigqueueinfo, sys_rt_sigqueueinfo, 177, 3)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_rt_sigsuspend
+TRACE_SYSCALL_TABLE(sys_rt_sigsuspend, sys_rt_sigsuspend, 178, 2)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_chown
+TRACE_SYSCALL_TABLE(sys_chown, sys_chown, 181, 3)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_getcwd
+TRACE_SYSCALL_TABLE(sys_getcwd, sys_getcwd, 182, 2)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_sendfile
+TRACE_SYSCALL_TABLE(sys_sendfile, sys_sendfile, 186, 4)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_getrlimit
+TRACE_SYSCALL_TABLE(sys_getrlimit, sys_getrlimit, 190, 2)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_stat64
+TRACE_SYSCALL_TABLE(sys_stat64, sys_stat64, 195, 2)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_lstat64
+TRACE_SYSCALL_TABLE(sys_lstat64, sys_lstat64, 196, 2)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_fstat64
+TRACE_SYSCALL_TABLE(sys_fstat64, sys_fstat64, 197, 2)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_pciconfig_read
+TRACE_SYSCALL_TABLE(sys_pciconfig_read, sys_pciconfig_read, 198, 5)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_pciconfig_write
+TRACE_SYSCALL_TABLE(sys_pciconfig_write, sys_pciconfig_write, 199, 5)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_getdents64
+TRACE_SYSCALL_TABLE(sys_getdents64, sys_getdents64, 202, 3)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_pivot_root
+TRACE_SYSCALL_TABLE(sys_pivot_root, sys_pivot_root, 203, 2)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_mincore
+TRACE_SYSCALL_TABLE(sys_mincore, sys_mincore, 206, 3)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_setxattr
+TRACE_SYSCALL_TABLE(sys_setxattr, sys_setxattr, 209, 5)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_lsetxattr
+TRACE_SYSCALL_TABLE(sys_lsetxattr, sys_lsetxattr, 210, 5)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_fsetxattr
+TRACE_SYSCALL_TABLE(sys_fsetxattr, sys_fsetxattr, 211, 5)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_getxattr
+TRACE_SYSCALL_TABLE(sys_getxattr, sys_getxattr, 212, 4)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_lgetxattr
+TRACE_SYSCALL_TABLE(sys_lgetxattr, sys_lgetxattr, 213, 4)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_fgetxattr
+TRACE_SYSCALL_TABLE(sys_fgetxattr, sys_fgetxattr, 214, 4)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_listxattr
+TRACE_SYSCALL_TABLE(sys_listxattr, sys_listxattr, 215, 3)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_llistxattr
+TRACE_SYSCALL_TABLE(sys_llistxattr, sys_llistxattr, 216, 3)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_flistxattr
+TRACE_SYSCALL_TABLE(sys_flistxattr, sys_flistxattr, 217, 3)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_removexattr
+TRACE_SYSCALL_TABLE(sys_removexattr, sys_removexattr, 218, 2)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_lremovexattr
+TRACE_SYSCALL_TABLE(sys_lremovexattr, sys_lremovexattr, 219, 2)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_fremovexattr
+TRACE_SYSCALL_TABLE(sys_fremovexattr, sys_fremovexattr, 220, 2)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_futex
+TRACE_SYSCALL_TABLE(sys_futex, sys_futex, 221, 6)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_sched_setaffinity
+TRACE_SYSCALL_TABLE(sys_sched_setaffinity, sys_sched_setaffinity, 222, 3)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_sched_getaffinity
+TRACE_SYSCALL_TABLE(sys_sched_getaffinity, sys_sched_getaffinity, 223, 3)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_sendfile64
+TRACE_SYSCALL_TABLE(sys_sendfile64, sys_sendfile64, 226, 4)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_io_setup
+TRACE_SYSCALL_TABLE(sys_io_setup, sys_io_setup, 227, 2)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_io_getevents
+TRACE_SYSCALL_TABLE(sys_io_getevents, sys_io_getevents, 229, 5)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_io_submit
+TRACE_SYSCALL_TABLE(sys_io_submit, sys_io_submit, 230, 3)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_io_cancel
+TRACE_SYSCALL_TABLE(sys_io_cancel, sys_io_cancel, 231, 3)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_set_tid_address
+TRACE_SYSCALL_TABLE(sys_set_tid_address, sys_set_tid_address, 232, 1)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_epoll_ctl
+TRACE_SYSCALL_TABLE(sys_epoll_ctl, sys_epoll_ctl, 237, 4)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_epoll_wait
+TRACE_SYSCALL_TABLE(sys_epoll_wait, sys_epoll_wait, 238, 4)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_timer_create
+TRACE_SYSCALL_TABLE(sys_timer_create, sys_timer_create, 240, 3)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_timer_settime
+TRACE_SYSCALL_TABLE(sys_timer_settime, sys_timer_settime, 241, 4)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_timer_gettime
+TRACE_SYSCALL_TABLE(sys_timer_gettime, sys_timer_gettime, 242, 2)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_clock_settime
+TRACE_SYSCALL_TABLE(sys_clock_settime, sys_clock_settime, 245, 2)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_clock_gettime
+TRACE_SYSCALL_TABLE(sys_clock_gettime, sys_clock_gettime, 246, 2)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_clock_getres
+TRACE_SYSCALL_TABLE(sys_clock_getres, sys_clock_getres, 247, 2)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_clock_nanosleep
+TRACE_SYSCALL_TABLE(sys_clock_nanosleep, sys_clock_nanosleep, 248, 4)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_utimes
+TRACE_SYSCALL_TABLE(sys_utimes, sys_utimes, 251, 2)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_statfs64
+TRACE_SYSCALL_TABLE(sys_statfs64, sys_statfs64, 252, 3)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_fstatfs64
+TRACE_SYSCALL_TABLE(sys_fstatfs64, sys_fstatfs64, 253, 3)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_mq_open
+TRACE_SYSCALL_TABLE(sys_mq_open, sys_mq_open, 262, 4)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_mq_unlink
+TRACE_SYSCALL_TABLE(sys_mq_unlink, sys_mq_unlink, 263, 1)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_mq_timedsend
+TRACE_SYSCALL_TABLE(sys_mq_timedsend, sys_mq_timedsend, 264, 5)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_mq_timedreceive
+TRACE_SYSCALL_TABLE(sys_mq_timedreceive, sys_mq_timedreceive, 265, 5)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_mq_notify
+TRACE_SYSCALL_TABLE(sys_mq_notify, sys_mq_notify, 266, 2)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_mq_getsetattr
+TRACE_SYSCALL_TABLE(sys_mq_getsetattr, sys_mq_getsetattr, 267, 3)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_add_key
+TRACE_SYSCALL_TABLE(sys_add_key, sys_add_key, 269, 5)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_request_key
+TRACE_SYSCALL_TABLE(sys_request_key, sys_request_key, 270, 4)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_waitid
+TRACE_SYSCALL_TABLE(sys_waitid, sys_waitid, 272, 5)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_inotify_add_watch
+TRACE_SYSCALL_TABLE(sys_inotify_add_watch, sys_inotify_add_watch, 276, 3)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_pselect6
+TRACE_SYSCALL_TABLE(sys_pselect6, sys_pselect6, 280, 6)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_ppoll
+TRACE_SYSCALL_TABLE(sys_ppoll, sys_ppoll, 281, 5)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_splice
+TRACE_SYSCALL_TABLE(sys_splice, sys_splice, 283, 6)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_vmsplice
+TRACE_SYSCALL_TABLE(sys_vmsplice, sys_vmsplice, 285, 4)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_openat
+TRACE_SYSCALL_TABLE(sys_openat, sys_openat, 286, 4)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_mkdirat
+TRACE_SYSCALL_TABLE(sys_mkdirat, sys_mkdirat, 287, 3)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_mknodat
+TRACE_SYSCALL_TABLE(sys_mknodat, sys_mknodat, 288, 4)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_fchownat
+TRACE_SYSCALL_TABLE(sys_fchownat, sys_fchownat, 289, 5)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_futimesat
+TRACE_SYSCALL_TABLE(sys_futimesat, sys_futimesat, 290, 3)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_fstatat64
+TRACE_SYSCALL_TABLE(sys_fstatat64, sys_fstatat64, 291, 4)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_unlinkat
+TRACE_SYSCALL_TABLE(sys_unlinkat, sys_unlinkat, 292, 3)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_renameat
+TRACE_SYSCALL_TABLE(sys_renameat, sys_renameat, 293, 4)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_linkat
+TRACE_SYSCALL_TABLE(sys_linkat, sys_linkat, 294, 5)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_symlinkat
+TRACE_SYSCALL_TABLE(sys_symlinkat, sys_symlinkat, 295, 3)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_readlinkat
+TRACE_SYSCALL_TABLE(sys_readlinkat, sys_readlinkat, 296, 4)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_fchmodat
+TRACE_SYSCALL_TABLE(sys_fchmodat, sys_fchmodat, 297, 3)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_faccessat
+TRACE_SYSCALL_TABLE(sys_faccessat, sys_faccessat, 298, 3)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_get_robust_list
+TRACE_SYSCALL_TABLE(sys_get_robust_list, sys_get_robust_list, 299, 3)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_set_robust_list
+TRACE_SYSCALL_TABLE(sys_set_robust_list, sys_set_robust_list, 300, 2)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_getcpu
+TRACE_SYSCALL_TABLE(sys_getcpu, sys_getcpu, 302, 3)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_epoll_pwait
+TRACE_SYSCALL_TABLE(sys_epoll_pwait, sys_epoll_pwait, 303, 6)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_utimensat
+TRACE_SYSCALL_TABLE(sys_utimensat, sys_utimensat, 304, 4)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_signalfd
+TRACE_SYSCALL_TABLE(sys_signalfd, sys_signalfd, 305, 3)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_timerfd_settime
+TRACE_SYSCALL_TABLE(sys_timerfd_settime, sys_timerfd_settime, 311, 4)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_timerfd_gettime
+TRACE_SYSCALL_TABLE(sys_timerfd_gettime, sys_timerfd_gettime, 312, 2)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_signalfd4
+TRACE_SYSCALL_TABLE(sys_signalfd4, sys_signalfd4, 313, 4)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_pipe2
+TRACE_SYSCALL_TABLE(sys_pipe2, sys_pipe2, 317, 2)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_perf_event_open
+TRACE_SYSCALL_TABLE(sys_perf_event_open, sys_perf_event_open, 319, 5)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_preadv
+TRACE_SYSCALL_TABLE(sys_preadv, sys_preadv, 320, 5)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_pwritev
+TRACE_SYSCALL_TABLE(sys_pwritev, sys_pwritev, 321, 5)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_rt_tgsigqueueinfo
+TRACE_SYSCALL_TABLE(sys_rt_tgsigqueueinfo, sys_rt_tgsigqueueinfo, 322, 4)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_prlimit64
+TRACE_SYSCALL_TABLE(sys_prlimit64, sys_prlimit64, 325, 4)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_bind
+TRACE_SYSCALL_TABLE(sys_bind, sys_bind, 327, 3)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_connect
+TRACE_SYSCALL_TABLE(sys_connect, sys_connect, 328, 3)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_accept
+TRACE_SYSCALL_TABLE(sys_accept, sys_accept, 330, 3)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_getsockname
+TRACE_SYSCALL_TABLE(sys_getsockname, sys_getsockname, 331, 3)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_getpeername
+TRACE_SYSCALL_TABLE(sys_getpeername, sys_getpeername, 332, 3)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_socketpair
+TRACE_SYSCALL_TABLE(sys_socketpair, sys_socketpair, 333, 4)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_send
+TRACE_SYSCALL_TABLE(sys_send, sys_send, 334, 4)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_sendto
+TRACE_SYSCALL_TABLE(sys_sendto, sys_sendto, 335, 6)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_recvfrom
+TRACE_SYSCALL_TABLE(sys_recvfrom, sys_recvfrom, 337, 6)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_setsockopt
+TRACE_SYSCALL_TABLE(sys_setsockopt, sys_setsockopt, 339, 5)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_getsockopt
+TRACE_SYSCALL_TABLE(sys_getsockopt, sys_getsockopt, 340, 5)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_sendmsg
+TRACE_SYSCALL_TABLE(sys_sendmsg, sys_sendmsg, 341, 3)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_recvmsg
+TRACE_SYSCALL_TABLE(sys_recvmsg, sys_recvmsg, 342, 3)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_recvmmsg
+TRACE_SYSCALL_TABLE(sys_recvmmsg, sys_recvmmsg, 343, 5)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_accept4
+TRACE_SYSCALL_TABLE(sys_accept4, sys_accept4, 344, 4)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_clock_adjtime
+TRACE_SYSCALL_TABLE(sys_clock_adjtime, sys_clock_adjtime, 347, 2)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_sendmmsg
+TRACE_SYSCALL_TABLE(sys_sendmmsg, sys_sendmmsg, 349, 4)
+#endif
+
+#endif /* CREATE_SYSCALL_TABLE */
diff --git a/drivers/staging/lttng/instrumentation/syscalls/headers/powerpc-32-syscalls-3.0.34_pointers_override.h b/drivers/staging/lttng/instrumentation/syscalls/headers/powerpc-32-syscalls-3.0.34_pointers_override.h
new file mode 100644 (file)
index 0000000..7a5d134
--- /dev/null
@@ -0,0 +1,36 @@
+#define OVERRIDE_TABLE_32_sys_mmap2
+
+#ifndef CREATE_SYSCALL_TABLE
+
+SC_TRACE_EVENT(sys_mmap2,
+       TP_PROTO(void *addr, size_t len, int prot,
+                 int flags, int fd, off_t pgoff),
+       TP_ARGS(addr, len, prot, flags, fd, pgoff),
+       TP_STRUCT__entry(
+               __field_hex(void *, addr)
+               __field(size_t, len)
+               __field(int, prot)
+               __field(int, flags)
+               __field(int, fd)
+               __field(off_t, pgoff)),
+       TP_fast_assign(
+               tp_assign(addr, addr)
+               tp_assign(len, len)
+               tp_assign(prot, prot)
+               tp_assign(flags, flags)
+               tp_assign(fd, fd)
+               tp_assign(pgoff, pgoff)),
+       TP_printk()
+)
+
+#else  /* CREATE_SYSCALL_TABLE */
+
+#define OVERRIDE_TABLE_32_sys_execve
+TRACE_SYSCALL_TABLE(sys_execve, sys_execve, 11, 3)
+#define OVERRIDE_TABLE_32_sys_clone
+TRACE_SYSCALL_TABLE(sys_clone, sys_clone, 120, 5)
+#define OVERRIDE_TABLE_32_sys_mmap2
+TRACE_SYSCALL_TABLE(sys_mmap2, sys_mmap2, 192, 6)
+
+#endif /* CREATE_SYSCALL_TABLE */
+
diff --git a/drivers/staging/lttng/instrumentation/syscalls/headers/syscalls_integers.h b/drivers/staging/lttng/instrumentation/syscalls/headers/syscalls_integers.h
new file mode 100644 (file)
index 0000000..ce0409f
--- /dev/null
@@ -0,0 +1,15 @@
+#ifdef CONFIG_X86_64
+#include "x86-64-syscalls-3.10.0-rc7_integers.h"
+#endif
+
+#ifdef CONFIG_X86_32
+#include "x86-32-syscalls-3.1.0-rc6_integers.h"
+#endif
+
+#ifdef CONFIG_ARM
+#include "arm-32-syscalls-3.4.25_integers.h"
+#endif
+
+#ifdef CONFIG_PPC
+#include "powerpc-32-syscalls-3.0.34_integers.h"
+#endif
diff --git a/drivers/staging/lttng/instrumentation/syscalls/headers/syscalls_integers_override.h b/drivers/staging/lttng/instrumentation/syscalls/headers/syscalls_integers_override.h
new file mode 100644 (file)
index 0000000..276d9a6
--- /dev/null
@@ -0,0 +1,14 @@
+#define OVERRIDE_32_sys_mmap
+#define OVERRIDE_64_sys_mmap
+
+#ifndef CREATE_SYSCALL_TABLE
+
+SC_TRACE_EVENT(sys_mmap,
+       TP_PROTO(unsigned long addr, unsigned long len, unsigned long prot, unsigned long flags, unsigned long fd, unsigned long off),
+       TP_ARGS(addr, len, prot, flags, fd, off),
+       TP_STRUCT__entry(__field_hex(unsigned long, addr) __field(size_t, len) __field(int, prot) __field(int, flags) __field(int, fd) __field(off_t, offset)),
+       TP_fast_assign(tp_assign(addr, addr) tp_assign(len, len) tp_assign(prot, prot) tp_assign(flags, flags) tp_assign(fd, fd) tp_assign(offset, off)),
+       TP_printk()
+)
+
+#endif /* CREATE_SYSCALL_TABLE */
diff --git a/drivers/staging/lttng/instrumentation/syscalls/headers/syscalls_pointers.h b/drivers/staging/lttng/instrumentation/syscalls/headers/syscalls_pointers.h
new file mode 100644 (file)
index 0000000..f5ca566
--- /dev/null
@@ -0,0 +1,15 @@
+#ifdef CONFIG_X86_64
+#include "x86-64-syscalls-3.10.0-rc7_pointers.h"
+#endif
+
+#ifdef CONFIG_X86_32
+#include "x86-32-syscalls-3.1.0-rc6_pointers.h"
+#endif
+
+#ifdef CONFIG_ARM
+#include "arm-32-syscalls-3.4.25_pointers.h"
+#endif
+
+#ifdef CONFIG_PPC
+#include "powerpc-32-syscalls-3.0.34_pointers.h"
+#endif
diff --git a/drivers/staging/lttng/instrumentation/syscalls/headers/syscalls_pointers_override.h b/drivers/staging/lttng/instrumentation/syscalls/headers/syscalls_pointers_override.h
new file mode 100644 (file)
index 0000000..a24c4d3
--- /dev/null
@@ -0,0 +1,53 @@
+#define OVERRIDE_32_sys_execve
+#define OVERRIDE_64_sys_execve
+
+#ifndef CREATE_SYSCALL_TABLE
+
+SC_TRACE_EVENT(sys_execve,
+       TP_PROTO(const char *filename, char *const *argv, char *const *envp),
+       TP_ARGS(filename, argv, envp),
+       TP_STRUCT__entry(__string_from_user(filename, filename)
+               __field_hex(char *const *, argv)
+               __field_hex(char *const *, envp)),
+       TP_fast_assign(tp_copy_string_from_user(filename, filename)
+               tp_assign(argv, argv)
+               tp_assign(envp, envp)),
+       TP_printk()
+)
+
+SC_TRACE_EVENT(sys_clone,
+       TP_PROTO(unsigned long clone_flags, unsigned long newsp,
+               void __user *parent_tid,
+               void __user *child_tid),
+       TP_ARGS(clone_flags, newsp, parent_tid, child_tid),
+       TP_STRUCT__entry(
+               __field_hex(unsigned long, clone_flags)
+               __field_hex(unsigned long, newsp)
+               __field_hex(void *, parent_tid)
+               __field_hex(void *, child_tid)),
+       TP_fast_assign(
+               tp_assign(clone_flags, clone_flags)
+               tp_assign(newsp, newsp)
+               tp_assign(parent_tid, parent_tid)
+               tp_assign(child_tid, child_tid)),
+       TP_printk()
+)
+
+/* present in 32, missing in 64 due to old kernel headers */
+#define OVERRIDE_32_sys_getcpu
+#define OVERRIDE_64_sys_getcpu
+SC_TRACE_EVENT(sys_getcpu,
+       TP_PROTO(unsigned __user *cpup, unsigned __user *nodep, void *tcache),
+       TP_ARGS(cpup, nodep, tcache),
+       TP_STRUCT__entry(
+               __field_hex(unsigned *, cpup)
+               __field_hex(unsigned *, nodep)
+               __field_hex(void *, tcache)),
+       TP_fast_assign(
+               tp_assign(cpup, cpup)
+               tp_assign(nodep, nodep)
+               tp_assign(tcache, tcache)),
+       TP_printk()
+)
+
+#endif /* CREATE_SYSCALL_TABLE */
diff --git a/drivers/staging/lttng/instrumentation/syscalls/headers/syscalls_unknown.h b/drivers/staging/lttng/instrumentation/syscalls/headers/syscalls_unknown.h
new file mode 100644 (file)
index 0000000..4e2e949
--- /dev/null
@@ -0,0 +1,55 @@
+#if !defined(_TRACE_SYSCALLS_UNKNOWN_H) || defined(TRACE_HEADER_MULTI_READ)
+#define _TRACE_SYSCALLS_UNKNOWN_H
+
+#include <linux/tracepoint.h>
+#include <linux/syscalls.h>
+
+#define UNKNOWN_SYSCALL_NRARGS 6
+
+TRACE_EVENT(sys_unknown,
+       TP_PROTO(unsigned int id, unsigned long *args),
+       TP_ARGS(id, args),
+       TP_STRUCT__entry(
+               __field(unsigned int, id)
+               __array(unsigned long, args, UNKNOWN_SYSCALL_NRARGS)
+       ),
+       TP_fast_assign(
+               tp_assign(id, id)
+               tp_memcpy(args, args, UNKNOWN_SYSCALL_NRARGS * sizeof(*args))
+       ),
+       TP_printk()
+)
+TRACE_EVENT(compat_sys_unknown,
+       TP_PROTO(unsigned int id, unsigned long *args),
+       TP_ARGS(id, args),
+       TP_STRUCT__entry(
+               __field(unsigned int, id)
+               __array(unsigned long, args, UNKNOWN_SYSCALL_NRARGS)
+       ),
+       TP_fast_assign(
+               tp_assign(id, id)
+               tp_memcpy(args, args, UNKNOWN_SYSCALL_NRARGS * sizeof(*args))
+       ),
+       TP_printk()
+)
+/*
+ * This is going to hook on sys_exit in the kernel.
+ * We change the name so we don't clash with the sys_exit syscall entry
+ * event.
+ */
+TRACE_EVENT(exit_syscall,
+       TP_PROTO(struct pt_regs *regs, long ret),
+       TP_ARGS(regs, ret),
+       TP_STRUCT__entry(
+               __field(long, ret)
+       ),
+       TP_fast_assign(
+               tp_assign(ret, ret)
+       ),
+       TP_printk()
+)
+
+#endif /*  _TRACE_SYSCALLS_UNKNOWN_H */
+
+/* This part must be outside protection */
+#include "../../../probes/define_trace.h"
diff --git a/drivers/staging/lttng/instrumentation/syscalls/headers/x86-32-syscalls-3.1.0-rc6_integers.h b/drivers/staging/lttng/instrumentation/syscalls/headers/x86-32-syscalls-3.1.0-rc6_integers.h
new file mode 100644 (file)
index 0000000..f4ee16c
--- /dev/null
@@ -0,0 +1,1163 @@
+/* THIS FILE IS AUTO-GENERATED. DO NOT EDIT */
+#ifndef CREATE_SYSCALL_TABLE
+
+#if !defined(_TRACE_SYSCALLS_INTEGERS_H) || defined(TRACE_HEADER_MULTI_READ)
+#define _TRACE_SYSCALLS_INTEGERS_H
+
+#include <linux/tracepoint.h>
+#include <linux/syscalls.h>
+#include "x86-32-syscalls-3.1.0-rc6_integers_override.h"
+#include "syscalls_integers_override.h"
+
+SC_DECLARE_EVENT_CLASS_NOARGS(syscalls_noargs,
+       TP_STRUCT__entry(),
+       TP_fast_assign(),
+       TP_printk()
+)
+#ifndef OVERRIDE_32_sys_restart_syscall
+SC_DEFINE_EVENT_NOARGS(syscalls_noargs, sys_restart_syscall)
+#endif
+#ifndef OVERRIDE_32_sys_getpid
+SC_DEFINE_EVENT_NOARGS(syscalls_noargs, sys_getpid)
+#endif
+#ifndef OVERRIDE_32_sys_getuid16
+SC_DEFINE_EVENT_NOARGS(syscalls_noargs, sys_getuid16)
+#endif
+#ifndef OVERRIDE_32_sys_pause
+SC_DEFINE_EVENT_NOARGS(syscalls_noargs, sys_pause)
+#endif
+#ifndef OVERRIDE_32_sys_sync
+SC_DEFINE_EVENT_NOARGS(syscalls_noargs, sys_sync)
+#endif
+#ifndef OVERRIDE_32_sys_getgid16
+SC_DEFINE_EVENT_NOARGS(syscalls_noargs, sys_getgid16)
+#endif
+#ifndef OVERRIDE_32_sys_geteuid16
+SC_DEFINE_EVENT_NOARGS(syscalls_noargs, sys_geteuid16)
+#endif
+#ifndef OVERRIDE_32_sys_getegid16
+SC_DEFINE_EVENT_NOARGS(syscalls_noargs, sys_getegid16)
+#endif
+#ifndef OVERRIDE_32_sys_getppid
+SC_DEFINE_EVENT_NOARGS(syscalls_noargs, sys_getppid)
+#endif
+#ifndef OVERRIDE_32_sys_getpgrp
+SC_DEFINE_EVENT_NOARGS(syscalls_noargs, sys_getpgrp)
+#endif
+#ifndef OVERRIDE_32_sys_setsid
+SC_DEFINE_EVENT_NOARGS(syscalls_noargs, sys_setsid)
+#endif
+#ifndef OVERRIDE_32_sys_sgetmask
+SC_DEFINE_EVENT_NOARGS(syscalls_noargs, sys_sgetmask)
+#endif
+#ifndef OVERRIDE_32_sys_vhangup
+SC_DEFINE_EVENT_NOARGS(syscalls_noargs, sys_vhangup)
+#endif
+#ifndef OVERRIDE_32_sys_munlockall
+SC_DEFINE_EVENT_NOARGS(syscalls_noargs, sys_munlockall)
+#endif
+#ifndef OVERRIDE_32_sys_sched_yield
+SC_DEFINE_EVENT_NOARGS(syscalls_noargs, sys_sched_yield)
+#endif
+#ifndef OVERRIDE_32_sys_getuid
+SC_DEFINE_EVENT_NOARGS(syscalls_noargs, sys_getuid)
+#endif
+#ifndef OVERRIDE_32_sys_getgid
+SC_DEFINE_EVENT_NOARGS(syscalls_noargs, sys_getgid)
+#endif
+#ifndef OVERRIDE_32_sys_geteuid
+SC_DEFINE_EVENT_NOARGS(syscalls_noargs, sys_geteuid)
+#endif
+#ifndef OVERRIDE_32_sys_getegid
+SC_DEFINE_EVENT_NOARGS(syscalls_noargs, sys_getegid)
+#endif
+#ifndef OVERRIDE_32_sys_gettid
+SC_DEFINE_EVENT_NOARGS(syscalls_noargs, sys_gettid)
+#endif
+#ifndef OVERRIDE_32_sys_inotify_init
+SC_DEFINE_EVENT_NOARGS(syscalls_noargs, sys_inotify_init)
+#endif
+#ifndef OVERRIDE_32_sys_exit
+SC_TRACE_EVENT(sys_exit,
+       TP_PROTO(int error_code),
+       TP_ARGS(error_code),
+       TP_STRUCT__entry(__field(int, error_code)),
+       TP_fast_assign(tp_assign(error_code, error_code)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_close
+SC_TRACE_EVENT(sys_close,
+       TP_PROTO(unsigned int fd),
+       TP_ARGS(fd),
+       TP_STRUCT__entry(__field(unsigned int, fd)),
+       TP_fast_assign(tp_assign(fd, fd)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_setuid16
+SC_TRACE_EVENT(sys_setuid16,
+       TP_PROTO(old_uid_t uid),
+       TP_ARGS(uid),
+       TP_STRUCT__entry(__field(old_uid_t, uid)),
+       TP_fast_assign(tp_assign(uid, uid)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_alarm
+SC_TRACE_EVENT(sys_alarm,
+       TP_PROTO(unsigned int seconds),
+       TP_ARGS(seconds),
+       TP_STRUCT__entry(__field(unsigned int, seconds)),
+       TP_fast_assign(tp_assign(seconds, seconds)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_nice
+SC_TRACE_EVENT(sys_nice,
+       TP_PROTO(int increment),
+       TP_ARGS(increment),
+       TP_STRUCT__entry(__field(int, increment)),
+       TP_fast_assign(tp_assign(increment, increment)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_dup
+SC_TRACE_EVENT(sys_dup,
+       TP_PROTO(unsigned int fildes),
+       TP_ARGS(fildes),
+       TP_STRUCT__entry(__field(unsigned int, fildes)),
+       TP_fast_assign(tp_assign(fildes, fildes)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_brk
+SC_TRACE_EVENT(sys_brk,
+       TP_PROTO(unsigned long brk),
+       TP_ARGS(brk),
+       TP_STRUCT__entry(__field(unsigned long, brk)),
+       TP_fast_assign(tp_assign(brk, brk)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_setgid16
+SC_TRACE_EVENT(sys_setgid16,
+       TP_PROTO(old_gid_t gid),
+       TP_ARGS(gid),
+       TP_STRUCT__entry(__field(old_gid_t, gid)),
+       TP_fast_assign(tp_assign(gid, gid)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_umask
+SC_TRACE_EVENT(sys_umask,
+       TP_PROTO(int mask),
+       TP_ARGS(mask),
+       TP_STRUCT__entry(__field(int, mask)),
+       TP_fast_assign(tp_assign(mask, mask)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_ssetmask
+SC_TRACE_EVENT(sys_ssetmask,
+       TP_PROTO(int newmask),
+       TP_ARGS(newmask),
+       TP_STRUCT__entry(__field(int, newmask)),
+       TP_fast_assign(tp_assign(newmask, newmask)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_fsync
+SC_TRACE_EVENT(sys_fsync,
+       TP_PROTO(unsigned int fd),
+       TP_ARGS(fd),
+       TP_STRUCT__entry(__field(unsigned int, fd)),
+       TP_fast_assign(tp_assign(fd, fd)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_getpgid
+SC_TRACE_EVENT(sys_getpgid,
+       TP_PROTO(pid_t pid),
+       TP_ARGS(pid),
+       TP_STRUCT__entry(__field(pid_t, pid)),
+       TP_fast_assign(tp_assign(pid, pid)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_fchdir
+SC_TRACE_EVENT(sys_fchdir,
+       TP_PROTO(unsigned int fd),
+       TP_ARGS(fd),
+       TP_STRUCT__entry(__field(unsigned int, fd)),
+       TP_fast_assign(tp_assign(fd, fd)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_personality
+SC_TRACE_EVENT(sys_personality,
+       TP_PROTO(unsigned int personality),
+       TP_ARGS(personality),
+       TP_STRUCT__entry(__field(unsigned int, personality)),
+       TP_fast_assign(tp_assign(personality, personality)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_setfsuid16
+SC_TRACE_EVENT(sys_setfsuid16,
+       TP_PROTO(old_uid_t uid),
+       TP_ARGS(uid),
+       TP_STRUCT__entry(__field(old_uid_t, uid)),
+       TP_fast_assign(tp_assign(uid, uid)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_setfsgid16
+SC_TRACE_EVENT(sys_setfsgid16,
+       TP_PROTO(old_gid_t gid),
+       TP_ARGS(gid),
+       TP_STRUCT__entry(__field(old_gid_t, gid)),
+       TP_fast_assign(tp_assign(gid, gid)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_getsid
+SC_TRACE_EVENT(sys_getsid,
+       TP_PROTO(pid_t pid),
+       TP_ARGS(pid),
+       TP_STRUCT__entry(__field(pid_t, pid)),
+       TP_fast_assign(tp_assign(pid, pid)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_fdatasync
+SC_TRACE_EVENT(sys_fdatasync,
+       TP_PROTO(unsigned int fd),
+       TP_ARGS(fd),
+       TP_STRUCT__entry(__field(unsigned int, fd)),
+       TP_fast_assign(tp_assign(fd, fd)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_mlockall
+SC_TRACE_EVENT(sys_mlockall,
+       TP_PROTO(int flags),
+       TP_ARGS(flags),
+       TP_STRUCT__entry(__field(int, flags)),
+       TP_fast_assign(tp_assign(flags, flags)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_sched_getscheduler
+SC_TRACE_EVENT(sys_sched_getscheduler,
+       TP_PROTO(pid_t pid),
+       TP_ARGS(pid),
+       TP_STRUCT__entry(__field(pid_t, pid)),
+       TP_fast_assign(tp_assign(pid, pid)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_sched_get_priority_max
+SC_TRACE_EVENT(sys_sched_get_priority_max,
+       TP_PROTO(int policy),
+       TP_ARGS(policy),
+       TP_STRUCT__entry(__field(int, policy)),
+       TP_fast_assign(tp_assign(policy, policy)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_sched_get_priority_min
+SC_TRACE_EVENT(sys_sched_get_priority_min,
+       TP_PROTO(int policy),
+       TP_ARGS(policy),
+       TP_STRUCT__entry(__field(int, policy)),
+       TP_fast_assign(tp_assign(policy, policy)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_setuid
+SC_TRACE_EVENT(sys_setuid,
+       TP_PROTO(uid_t uid),
+       TP_ARGS(uid),
+       TP_STRUCT__entry(__field(uid_t, uid)),
+       TP_fast_assign(tp_assign(uid, uid)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_setgid
+SC_TRACE_EVENT(sys_setgid,
+       TP_PROTO(gid_t gid),
+       TP_ARGS(gid),
+       TP_STRUCT__entry(__field(gid_t, gid)),
+       TP_fast_assign(tp_assign(gid, gid)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_setfsuid
+SC_TRACE_EVENT(sys_setfsuid,
+       TP_PROTO(uid_t uid),
+       TP_ARGS(uid),
+       TP_STRUCT__entry(__field(uid_t, uid)),
+       TP_fast_assign(tp_assign(uid, uid)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_setfsgid
+SC_TRACE_EVENT(sys_setfsgid,
+       TP_PROTO(gid_t gid),
+       TP_ARGS(gid),
+       TP_STRUCT__entry(__field(gid_t, gid)),
+       TP_fast_assign(tp_assign(gid, gid)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_io_destroy
+SC_TRACE_EVENT(sys_io_destroy,
+       TP_PROTO(aio_context_t ctx),
+       TP_ARGS(ctx),
+       TP_STRUCT__entry(__field(aio_context_t, ctx)),
+       TP_fast_assign(tp_assign(ctx, ctx)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_exit_group
+SC_TRACE_EVENT(sys_exit_group,
+       TP_PROTO(int error_code),
+       TP_ARGS(error_code),
+       TP_STRUCT__entry(__field(int, error_code)),
+       TP_fast_assign(tp_assign(error_code, error_code)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_epoll_create
+SC_TRACE_EVENT(sys_epoll_create,
+       TP_PROTO(int size),
+       TP_ARGS(size),
+       TP_STRUCT__entry(__field(int, size)),
+       TP_fast_assign(tp_assign(size, size)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_timer_getoverrun
+SC_TRACE_EVENT(sys_timer_getoverrun,
+       TP_PROTO(timer_t timer_id),
+       TP_ARGS(timer_id),
+       TP_STRUCT__entry(__field(timer_t, timer_id)),
+       TP_fast_assign(tp_assign(timer_id, timer_id)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_timer_delete
+SC_TRACE_EVENT(sys_timer_delete,
+       TP_PROTO(timer_t timer_id),
+       TP_ARGS(timer_id),
+       TP_STRUCT__entry(__field(timer_t, timer_id)),
+       TP_fast_assign(tp_assign(timer_id, timer_id)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_unshare
+SC_TRACE_EVENT(sys_unshare,
+       TP_PROTO(unsigned long unshare_flags),
+       TP_ARGS(unshare_flags),
+       TP_STRUCT__entry(__field(unsigned long, unshare_flags)),
+       TP_fast_assign(tp_assign(unshare_flags, unshare_flags)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_eventfd
+SC_TRACE_EVENT(sys_eventfd,
+       TP_PROTO(unsigned int count),
+       TP_ARGS(count),
+       TP_STRUCT__entry(__field(unsigned int, count)),
+       TP_fast_assign(tp_assign(count, count)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_epoll_create1
+SC_TRACE_EVENT(sys_epoll_create1,
+       TP_PROTO(int flags),
+       TP_ARGS(flags),
+       TP_STRUCT__entry(__field(int, flags)),
+       TP_fast_assign(tp_assign(flags, flags)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_inotify_init1
+SC_TRACE_EVENT(sys_inotify_init1,
+       TP_PROTO(int flags),
+       TP_ARGS(flags),
+       TP_STRUCT__entry(__field(int, flags)),
+       TP_fast_assign(tp_assign(flags, flags)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_syncfs
+SC_TRACE_EVENT(sys_syncfs,
+       TP_PROTO(int fd),
+       TP_ARGS(fd),
+       TP_STRUCT__entry(__field(int, fd)),
+       TP_fast_assign(tp_assign(fd, fd)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_kill
+SC_TRACE_EVENT(sys_kill,
+       TP_PROTO(pid_t pid, int sig),
+       TP_ARGS(pid, sig),
+       TP_STRUCT__entry(__field(pid_t, pid) __field(int, sig)),
+       TP_fast_assign(tp_assign(pid, pid) tp_assign(sig, sig)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_signal
+SC_TRACE_EVENT(sys_signal,
+       TP_PROTO(int sig, __sighandler_t handler),
+       TP_ARGS(sig, handler),
+       TP_STRUCT__entry(__field(int, sig) __field(__sighandler_t, handler)),
+       TP_fast_assign(tp_assign(sig, sig) tp_assign(handler, handler)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_setpgid
+SC_TRACE_EVENT(sys_setpgid,
+       TP_PROTO(pid_t pid, pid_t pgid),
+       TP_ARGS(pid, pgid),
+       TP_STRUCT__entry(__field(pid_t, pid) __field(pid_t, pgid)),
+       TP_fast_assign(tp_assign(pid, pid) tp_assign(pgid, pgid)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_dup2
+SC_TRACE_EVENT(sys_dup2,
+       TP_PROTO(unsigned int oldfd, unsigned int newfd),
+       TP_ARGS(oldfd, newfd),
+       TP_STRUCT__entry(__field(unsigned int, oldfd) __field(unsigned int, newfd)),
+       TP_fast_assign(tp_assign(oldfd, oldfd) tp_assign(newfd, newfd)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_setreuid16
+SC_TRACE_EVENT(sys_setreuid16,
+       TP_PROTO(old_uid_t ruid, old_uid_t euid),
+       TP_ARGS(ruid, euid),
+       TP_STRUCT__entry(__field(old_uid_t, ruid) __field(old_uid_t, euid)),
+       TP_fast_assign(tp_assign(ruid, ruid) tp_assign(euid, euid)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_setregid16
+SC_TRACE_EVENT(sys_setregid16,
+       TP_PROTO(old_gid_t rgid, old_gid_t egid),
+       TP_ARGS(rgid, egid),
+       TP_STRUCT__entry(__field(old_gid_t, rgid) __field(old_gid_t, egid)),
+       TP_fast_assign(tp_assign(rgid, rgid) tp_assign(egid, egid)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_munmap
+SC_TRACE_EVENT(sys_munmap,
+       TP_PROTO(unsigned long addr, size_t len),
+       TP_ARGS(addr, len),
+       TP_STRUCT__entry(__field_hex(unsigned long, addr) __field(size_t, len)),
+       TP_fast_assign(tp_assign(addr, addr) tp_assign(len, len)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_ftruncate
+SC_TRACE_EVENT(sys_ftruncate,
+       TP_PROTO(unsigned int fd, unsigned long length),
+       TP_ARGS(fd, length),
+       TP_STRUCT__entry(__field(unsigned int, fd) __field(unsigned long, length)),
+       TP_fast_assign(tp_assign(fd, fd) tp_assign(length, length)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_fchmod
+SC_TRACE_EVENT(sys_fchmod,
+       TP_PROTO(unsigned int fd, mode_t mode),
+       TP_ARGS(fd, mode),
+       TP_STRUCT__entry(__field(unsigned int, fd) __field(mode_t, mode)),
+       TP_fast_assign(tp_assign(fd, fd) tp_assign(mode, mode)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_getpriority
+SC_TRACE_EVENT(sys_getpriority,
+       TP_PROTO(int which, int who),
+       TP_ARGS(which, who),
+       TP_STRUCT__entry(__field(int, which) __field(int, who)),
+       TP_fast_assign(tp_assign(which, which) tp_assign(who, who)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_bdflush
+SC_TRACE_EVENT(sys_bdflush,
+       TP_PROTO(int func, long data),
+       TP_ARGS(func, data),
+       TP_STRUCT__entry(__field(int, func) __field(long, data)),
+       TP_fast_assign(tp_assign(func, func) tp_assign(data, data)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_flock
+SC_TRACE_EVENT(sys_flock,
+       TP_PROTO(unsigned int fd, unsigned int cmd),
+       TP_ARGS(fd, cmd),
+       TP_STRUCT__entry(__field(unsigned int, fd) __field(unsigned int, cmd)),
+       TP_fast_assign(tp_assign(fd, fd) tp_assign(cmd, cmd)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_mlock
+SC_TRACE_EVENT(sys_mlock,
+       TP_PROTO(unsigned long start, size_t len),
+       TP_ARGS(start, len),
+       TP_STRUCT__entry(__field(unsigned long, start) __field(size_t, len)),
+       TP_fast_assign(tp_assign(start, start) tp_assign(len, len)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_munlock
+SC_TRACE_EVENT(sys_munlock,
+       TP_PROTO(unsigned long start, size_t len),
+       TP_ARGS(start, len),
+       TP_STRUCT__entry(__field(unsigned long, start) __field(size_t, len)),
+       TP_fast_assign(tp_assign(start, start) tp_assign(len, len)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_setreuid
+SC_TRACE_EVENT(sys_setreuid,
+       TP_PROTO(uid_t ruid, uid_t euid),
+       TP_ARGS(ruid, euid),
+       TP_STRUCT__entry(__field(uid_t, ruid) __field(uid_t, euid)),
+       TP_fast_assign(tp_assign(ruid, ruid) tp_assign(euid, euid)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_setregid
+SC_TRACE_EVENT(sys_setregid,
+       TP_PROTO(gid_t rgid, gid_t egid),
+       TP_ARGS(rgid, egid),
+       TP_STRUCT__entry(__field(gid_t, rgid) __field(gid_t, egid)),
+       TP_fast_assign(tp_assign(rgid, rgid) tp_assign(egid, egid)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_tkill
+SC_TRACE_EVENT(sys_tkill,
+       TP_PROTO(pid_t pid, int sig),
+       TP_ARGS(pid, sig),
+       TP_STRUCT__entry(__field(pid_t, pid) __field(int, sig)),
+       TP_fast_assign(tp_assign(pid, pid) tp_assign(sig, sig)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_ioprio_get
+SC_TRACE_EVENT(sys_ioprio_get,
+       TP_PROTO(int which, int who),
+       TP_ARGS(which, who),
+       TP_STRUCT__entry(__field(int, which) __field(int, who)),
+       TP_fast_assign(tp_assign(which, which) tp_assign(who, who)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_inotify_rm_watch
+SC_TRACE_EVENT(sys_inotify_rm_watch,
+       TP_PROTO(int fd, __s32 wd),
+       TP_ARGS(fd, wd),
+       TP_STRUCT__entry(__field(int, fd) __field(__s32, wd)),
+       TP_fast_assign(tp_assign(fd, fd) tp_assign(wd, wd)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_timerfd_create
+SC_TRACE_EVENT(sys_timerfd_create,
+       TP_PROTO(int clockid, int flags),
+       TP_ARGS(clockid, flags),
+       TP_STRUCT__entry(__field(int, clockid) __field(int, flags)),
+       TP_fast_assign(tp_assign(clockid, clockid) tp_assign(flags, flags)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_eventfd2
+SC_TRACE_EVENT(sys_eventfd2,
+       TP_PROTO(unsigned int count, int flags),
+       TP_ARGS(count, flags),
+       TP_STRUCT__entry(__field(unsigned int, count) __field(int, flags)),
+       TP_fast_assign(tp_assign(count, count) tp_assign(flags, flags)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_fanotify_init
+SC_TRACE_EVENT(sys_fanotify_init,
+       TP_PROTO(unsigned int flags, unsigned int event_f_flags),
+       TP_ARGS(flags, event_f_flags),
+       TP_STRUCT__entry(__field(unsigned int, flags) __field(unsigned int, event_f_flags)),
+       TP_fast_assign(tp_assign(flags, flags) tp_assign(event_f_flags, event_f_flags)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_setns
+SC_TRACE_EVENT(sys_setns,
+       TP_PROTO(int fd, int nstype),
+       TP_ARGS(fd, nstype),
+       TP_STRUCT__entry(__field(int, fd) __field(int, nstype)),
+       TP_fast_assign(tp_assign(fd, fd) tp_assign(nstype, nstype)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_lseek
+SC_TRACE_EVENT(sys_lseek,
+       TP_PROTO(unsigned int fd, off_t offset, unsigned int origin),
+       TP_ARGS(fd, offset, origin),
+       TP_STRUCT__entry(__field(unsigned int, fd) __field(off_t, offset) __field(unsigned int, origin)),
+       TP_fast_assign(tp_assign(fd, fd) tp_assign(offset, offset) tp_assign(origin, origin)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_ioctl
+SC_TRACE_EVENT(sys_ioctl,
+       TP_PROTO(unsigned int fd, unsigned int cmd, unsigned long arg),
+       TP_ARGS(fd, cmd, arg),
+       TP_STRUCT__entry(__field(unsigned int, fd) __field(unsigned int, cmd) __field(unsigned long, arg)),
+       TP_fast_assign(tp_assign(fd, fd) tp_assign(cmd, cmd) tp_assign(arg, arg)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_fcntl
+SC_TRACE_EVENT(sys_fcntl,
+       TP_PROTO(unsigned int fd, unsigned int cmd, unsigned long arg),
+       TP_ARGS(fd, cmd, arg),
+       TP_STRUCT__entry(__field(unsigned int, fd) __field(unsigned int, cmd) __field(unsigned long, arg)),
+       TP_fast_assign(tp_assign(fd, fd) tp_assign(cmd, cmd) tp_assign(arg, arg)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_fchown16
+SC_TRACE_EVENT(sys_fchown16,
+       TP_PROTO(unsigned int fd, old_uid_t user, old_gid_t group),
+       TP_ARGS(fd, user, group),
+       TP_STRUCT__entry(__field(unsigned int, fd) __field(old_uid_t, user) __field(old_gid_t, group)),
+       TP_fast_assign(tp_assign(fd, fd) tp_assign(user, user) tp_assign(group, group)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_setpriority
+SC_TRACE_EVENT(sys_setpriority,
+       TP_PROTO(int which, int who, int niceval),
+       TP_ARGS(which, who, niceval),
+       TP_STRUCT__entry(__field(int, which) __field(int, who) __field(int, niceval)),
+       TP_fast_assign(tp_assign(which, which) tp_assign(who, who) tp_assign(niceval, niceval)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_mprotect
+SC_TRACE_EVENT(sys_mprotect,
+       TP_PROTO(unsigned long start, size_t len, unsigned long prot),
+       TP_ARGS(start, len, prot),
+       TP_STRUCT__entry(__field(unsigned long, start) __field(size_t, len) __field(unsigned long, prot)),
+       TP_fast_assign(tp_assign(start, start) tp_assign(len, len) tp_assign(prot, prot)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_sysfs
+SC_TRACE_EVENT(sys_sysfs,
+       TP_PROTO(int option, unsigned long arg1, unsigned long arg2),
+       TP_ARGS(option, arg1, arg2),
+       TP_STRUCT__entry(__field(int, option) __field(unsigned long, arg1) __field(unsigned long, arg2)),
+       TP_fast_assign(tp_assign(option, option) tp_assign(arg1, arg1) tp_assign(arg2, arg2)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_msync
+SC_TRACE_EVENT(sys_msync,
+       TP_PROTO(unsigned long start, size_t len, int flags),
+       TP_ARGS(start, len, flags),
+       TP_STRUCT__entry(__field(unsigned long, start) __field(size_t, len) __field(int, flags)),
+       TP_fast_assign(tp_assign(start, start) tp_assign(len, len) tp_assign(flags, flags)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_setresuid16
+SC_TRACE_EVENT(sys_setresuid16,
+       TP_PROTO(old_uid_t ruid, old_uid_t euid, old_uid_t suid),
+       TP_ARGS(ruid, euid, suid),
+       TP_STRUCT__entry(__field(old_uid_t, ruid) __field(old_uid_t, euid) __field(old_uid_t, suid)),
+       TP_fast_assign(tp_assign(ruid, ruid) tp_assign(euid, euid) tp_assign(suid, suid)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_setresgid16
+SC_TRACE_EVENT(sys_setresgid16,
+       TP_PROTO(old_gid_t rgid, old_gid_t egid, old_gid_t sgid),
+       TP_ARGS(rgid, egid, sgid),
+       TP_STRUCT__entry(__field(old_gid_t, rgid) __field(old_gid_t, egid) __field(old_gid_t, sgid)),
+       TP_fast_assign(tp_assign(rgid, rgid) tp_assign(egid, egid) tp_assign(sgid, sgid)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_fchown
+SC_TRACE_EVENT(sys_fchown,
+       TP_PROTO(unsigned int fd, uid_t user, gid_t group),
+       TP_ARGS(fd, user, group),
+       TP_STRUCT__entry(__field(unsigned int, fd) __field(uid_t, user) __field(gid_t, group)),
+       TP_fast_assign(tp_assign(fd, fd) tp_assign(user, user) tp_assign(group, group)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_setresuid
+SC_TRACE_EVENT(sys_setresuid,
+       TP_PROTO(uid_t ruid, uid_t euid, uid_t suid),
+       TP_ARGS(ruid, euid, suid),
+       TP_STRUCT__entry(__field(uid_t, ruid) __field(uid_t, euid) __field(uid_t, suid)),
+       TP_fast_assign(tp_assign(ruid, ruid) tp_assign(euid, euid) tp_assign(suid, suid)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_setresgid
+SC_TRACE_EVENT(sys_setresgid,
+       TP_PROTO(gid_t rgid, gid_t egid, gid_t sgid),
+       TP_ARGS(rgid, egid, sgid),
+       TP_STRUCT__entry(__field(gid_t, rgid) __field(gid_t, egid) __field(gid_t, sgid)),
+       TP_fast_assign(tp_assign(rgid, rgid) tp_assign(egid, egid) tp_assign(sgid, sgid)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_madvise
+SC_TRACE_EVENT(sys_madvise,
+       TP_PROTO(unsigned long start, size_t len_in, int behavior),
+       TP_ARGS(start, len_in, behavior),
+       TP_STRUCT__entry(__field(unsigned long, start) __field(size_t, len_in) __field(int, behavior)),
+       TP_fast_assign(tp_assign(start, start) tp_assign(len_in, len_in) tp_assign(behavior, behavior)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_fcntl64
+SC_TRACE_EVENT(sys_fcntl64,
+       TP_PROTO(unsigned int fd, unsigned int cmd, unsigned long arg),
+       TP_ARGS(fd, cmd, arg),
+       TP_STRUCT__entry(__field(unsigned int, fd) __field(unsigned int, cmd) __field(unsigned long, arg)),
+       TP_fast_assign(tp_assign(fd, fd) tp_assign(cmd, cmd) tp_assign(arg, arg)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_tgkill
+SC_TRACE_EVENT(sys_tgkill,
+       TP_PROTO(pid_t tgid, pid_t pid, int sig),
+       TP_ARGS(tgid, pid, sig),
+       TP_STRUCT__entry(__field(pid_t, tgid) __field(pid_t, pid) __field(int, sig)),
+       TP_fast_assign(tp_assign(tgid, tgid) tp_assign(pid, pid) tp_assign(sig, sig)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_ioprio_set
+SC_TRACE_EVENT(sys_ioprio_set,
+       TP_PROTO(int which, int who, int ioprio),
+       TP_ARGS(which, who, ioprio),
+       TP_STRUCT__entry(__field(int, which) __field(int, who) __field(int, ioprio)),
+       TP_fast_assign(tp_assign(which, which) tp_assign(who, who) tp_assign(ioprio, ioprio)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_dup3
+SC_TRACE_EVENT(sys_dup3,
+       TP_PROTO(unsigned int oldfd, unsigned int newfd, int flags),
+       TP_ARGS(oldfd, newfd, flags),
+       TP_STRUCT__entry(__field(unsigned int, oldfd) __field(unsigned int, newfd) __field(int, flags)),
+       TP_fast_assign(tp_assign(oldfd, oldfd) tp_assign(newfd, newfd) tp_assign(flags, flags)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_ptrace
+SC_TRACE_EVENT(sys_ptrace,
+       TP_PROTO(long request, long pid, unsigned long addr, unsigned long data),
+       TP_ARGS(request, pid, addr, data),
+       TP_STRUCT__entry(__field(long, request) __field(long, pid) __field_hex(unsigned long, addr) __field(unsigned long, data)),
+       TP_fast_assign(tp_assign(request, request) tp_assign(pid, pid) tp_assign(addr, addr) tp_assign(data, data)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_tee
+SC_TRACE_EVENT(sys_tee,
+       TP_PROTO(int fdin, int fdout, size_t len, unsigned int flags),
+       TP_ARGS(fdin, fdout, len, flags),
+       TP_STRUCT__entry(__field(int, fdin) __field(int, fdout) __field(size_t, len) __field(unsigned int, flags)),
+       TP_fast_assign(tp_assign(fdin, fdin) tp_assign(fdout, fdout) tp_assign(len, len) tp_assign(flags, flags)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_mremap
+SC_TRACE_EVENT(sys_mremap,
+       TP_PROTO(unsigned long addr, unsigned long old_len, unsigned long new_len, unsigned long flags, unsigned long new_addr),
+       TP_ARGS(addr, old_len, new_len, flags, new_addr),
+       TP_STRUCT__entry(__field_hex(unsigned long, addr) __field(unsigned long, old_len) __field(unsigned long, new_len) __field(unsigned long, flags) __field_hex(unsigned long, new_addr)),
+       TP_fast_assign(tp_assign(addr, addr) tp_assign(old_len, old_len) tp_assign(new_len, new_len) tp_assign(flags, flags) tp_assign(new_addr, new_addr)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_prctl
+SC_TRACE_EVENT(sys_prctl,
+       TP_PROTO(int option, unsigned long arg2, unsigned long arg3, unsigned long arg4, unsigned long arg5),
+       TP_ARGS(option, arg2, arg3, arg4, arg5),
+       TP_STRUCT__entry(__field(int, option) __field(unsigned long, arg2) __field(unsigned long, arg3) __field(unsigned long, arg4) __field(unsigned long, arg5)),
+       TP_fast_assign(tp_assign(option, option) tp_assign(arg2, arg2) tp_assign(arg3, arg3) tp_assign(arg4, arg4) tp_assign(arg5, arg5)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_remap_file_pages
+SC_TRACE_EVENT(sys_remap_file_pages,
+       TP_PROTO(unsigned long start, unsigned long size, unsigned long prot, unsigned long pgoff, unsigned long flags),
+       TP_ARGS(start, size, prot, pgoff, flags),
+       TP_STRUCT__entry(__field(unsigned long, start) __field(unsigned long, size) __field(unsigned long, prot) __field(unsigned long, pgoff) __field(unsigned long, flags)),
+       TP_fast_assign(tp_assign(start, start) tp_assign(size, size) tp_assign(prot, prot) tp_assign(pgoff, pgoff) tp_assign(flags, flags)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_keyctl
+SC_TRACE_EVENT(sys_keyctl,
+       TP_PROTO(int option, unsigned long arg2, unsigned long arg3, unsigned long arg4, unsigned long arg5),
+       TP_ARGS(option, arg2, arg3, arg4, arg5),
+       TP_STRUCT__entry(__field(int, option) __field(unsigned long, arg2) __field(unsigned long, arg3) __field(unsigned long, arg4) __field(unsigned long, arg5)),
+       TP_fast_assign(tp_assign(option, option) tp_assign(arg2, arg2) tp_assign(arg3, arg3) tp_assign(arg4, arg4) tp_assign(arg5, arg5)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_mmap_pgoff
+SC_TRACE_EVENT(sys_mmap_pgoff,
+       TP_PROTO(unsigned long addr, unsigned long len, unsigned long prot, unsigned long flags, unsigned long fd, unsigned long pgoff),
+       TP_ARGS(addr, len, prot, flags, fd, pgoff),
+       TP_STRUCT__entry(__field_hex(unsigned long, addr) __field(unsigned long, len) __field(unsigned long, prot) __field(unsigned long, flags) __field(unsigned long, fd) __field(unsigned long, pgoff)),
+       TP_fast_assign(tp_assign(addr, addr) tp_assign(len, len) tp_assign(prot, prot) tp_assign(flags, flags) tp_assign(fd, fd) tp_assign(pgoff, pgoff)),
+       TP_printk()
+)
+#endif
+
+#endif /*  _TRACE_SYSCALLS_INTEGERS_H */
+
+/* This part must be outside protection */
+#include "../../../probes/define_trace.h"
+
+#else /* CREATE_SYSCALL_TABLE */
+
+#include "x86-32-syscalls-3.1.0-rc6_integers_override.h"
+#include "syscalls_integers_override.h"
+
+#ifndef OVERRIDE_TABLE_32_sys_restart_syscall
+TRACE_SYSCALL_TABLE(syscalls_noargs, sys_restart_syscall, 0, 0)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_getpid
+TRACE_SYSCALL_TABLE(syscalls_noargs, sys_getpid, 20, 0)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_getuid16
+TRACE_SYSCALL_TABLE(syscalls_noargs, sys_getuid16, 24, 0)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_pause
+TRACE_SYSCALL_TABLE(syscalls_noargs, sys_pause, 29, 0)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_sync
+TRACE_SYSCALL_TABLE(syscalls_noargs, sys_sync, 36, 0)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_getgid16
+TRACE_SYSCALL_TABLE(syscalls_noargs, sys_getgid16, 47, 0)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_geteuid16
+TRACE_SYSCALL_TABLE(syscalls_noargs, sys_geteuid16, 49, 0)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_getegid16
+TRACE_SYSCALL_TABLE(syscalls_noargs, sys_getegid16, 50, 0)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_getppid
+TRACE_SYSCALL_TABLE(syscalls_noargs, sys_getppid, 64, 0)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_getpgrp
+TRACE_SYSCALL_TABLE(syscalls_noargs, sys_getpgrp, 65, 0)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_setsid
+TRACE_SYSCALL_TABLE(syscalls_noargs, sys_setsid, 66, 0)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_sgetmask
+TRACE_SYSCALL_TABLE(syscalls_noargs, sys_sgetmask, 68, 0)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_vhangup
+TRACE_SYSCALL_TABLE(syscalls_noargs, sys_vhangup, 111, 0)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_munlockall
+TRACE_SYSCALL_TABLE(syscalls_noargs, sys_munlockall, 153, 0)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_sched_yield
+TRACE_SYSCALL_TABLE(syscalls_noargs, sys_sched_yield, 158, 0)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_getuid
+TRACE_SYSCALL_TABLE(syscalls_noargs, sys_getuid, 199, 0)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_getgid
+TRACE_SYSCALL_TABLE(syscalls_noargs, sys_getgid, 200, 0)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_geteuid
+TRACE_SYSCALL_TABLE(syscalls_noargs, sys_geteuid, 201, 0)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_getegid
+TRACE_SYSCALL_TABLE(syscalls_noargs, sys_getegid, 202, 0)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_gettid
+TRACE_SYSCALL_TABLE(syscalls_noargs, sys_gettid, 224, 0)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_inotify_init
+TRACE_SYSCALL_TABLE(syscalls_noargs, sys_inotify_init, 291, 0)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_exit
+TRACE_SYSCALL_TABLE(sys_exit, sys_exit, 1, 1)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_close
+TRACE_SYSCALL_TABLE(sys_close, sys_close, 6, 1)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_lseek
+TRACE_SYSCALL_TABLE(sys_lseek, sys_lseek, 19, 3)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_setuid16
+TRACE_SYSCALL_TABLE(sys_setuid16, sys_setuid16, 23, 1)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_ptrace
+TRACE_SYSCALL_TABLE(sys_ptrace, sys_ptrace, 26, 4)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_alarm
+TRACE_SYSCALL_TABLE(sys_alarm, sys_alarm, 27, 1)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_nice
+TRACE_SYSCALL_TABLE(sys_nice, sys_nice, 34, 1)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_kill
+TRACE_SYSCALL_TABLE(sys_kill, sys_kill, 37, 2)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_dup
+TRACE_SYSCALL_TABLE(sys_dup, sys_dup, 41, 1)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_brk
+TRACE_SYSCALL_TABLE(sys_brk, sys_brk, 45, 1)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_setgid16
+TRACE_SYSCALL_TABLE(sys_setgid16, sys_setgid16, 46, 1)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_signal
+TRACE_SYSCALL_TABLE(sys_signal, sys_signal, 48, 2)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_ioctl
+TRACE_SYSCALL_TABLE(sys_ioctl, sys_ioctl, 54, 3)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_fcntl
+TRACE_SYSCALL_TABLE(sys_fcntl, sys_fcntl, 55, 3)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_setpgid
+TRACE_SYSCALL_TABLE(sys_setpgid, sys_setpgid, 57, 2)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_umask
+TRACE_SYSCALL_TABLE(sys_umask, sys_umask, 60, 1)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_dup2
+TRACE_SYSCALL_TABLE(sys_dup2, sys_dup2, 63, 2)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_ssetmask
+TRACE_SYSCALL_TABLE(sys_ssetmask, sys_ssetmask, 69, 1)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_setreuid16
+TRACE_SYSCALL_TABLE(sys_setreuid16, sys_setreuid16, 70, 2)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_setregid16
+TRACE_SYSCALL_TABLE(sys_setregid16, sys_setregid16, 71, 2)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_munmap
+TRACE_SYSCALL_TABLE(sys_munmap, sys_munmap, 91, 2)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_ftruncate
+TRACE_SYSCALL_TABLE(sys_ftruncate, sys_ftruncate, 93, 2)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_fchmod
+TRACE_SYSCALL_TABLE(sys_fchmod, sys_fchmod, 94, 2)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_fchown16
+TRACE_SYSCALL_TABLE(sys_fchown16, sys_fchown16, 95, 3)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_getpriority
+TRACE_SYSCALL_TABLE(sys_getpriority, sys_getpriority, 96, 2)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_setpriority
+TRACE_SYSCALL_TABLE(sys_setpriority, sys_setpriority, 97, 3)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_fsync
+TRACE_SYSCALL_TABLE(sys_fsync, sys_fsync, 118, 1)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_mprotect
+TRACE_SYSCALL_TABLE(sys_mprotect, sys_mprotect, 125, 3)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_getpgid
+TRACE_SYSCALL_TABLE(sys_getpgid, sys_getpgid, 132, 1)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_fchdir
+TRACE_SYSCALL_TABLE(sys_fchdir, sys_fchdir, 133, 1)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_bdflush
+TRACE_SYSCALL_TABLE(sys_bdflush, sys_bdflush, 134, 2)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_sysfs
+TRACE_SYSCALL_TABLE(sys_sysfs, sys_sysfs, 135, 3)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_personality
+TRACE_SYSCALL_TABLE(sys_personality, sys_personality, 136, 1)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_setfsuid16
+TRACE_SYSCALL_TABLE(sys_setfsuid16, sys_setfsuid16, 138, 1)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_setfsgid16
+TRACE_SYSCALL_TABLE(sys_setfsgid16, sys_setfsgid16, 139, 1)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_flock
+TRACE_SYSCALL_TABLE(sys_flock, sys_flock, 143, 2)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_msync
+TRACE_SYSCALL_TABLE(sys_msync, sys_msync, 144, 3)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_getsid
+TRACE_SYSCALL_TABLE(sys_getsid, sys_getsid, 147, 1)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_fdatasync
+TRACE_SYSCALL_TABLE(sys_fdatasync, sys_fdatasync, 148, 1)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_mlock
+TRACE_SYSCALL_TABLE(sys_mlock, sys_mlock, 150, 2)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_munlock
+TRACE_SYSCALL_TABLE(sys_munlock, sys_munlock, 151, 2)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_mlockall
+TRACE_SYSCALL_TABLE(sys_mlockall, sys_mlockall, 152, 1)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_sched_getscheduler
+TRACE_SYSCALL_TABLE(sys_sched_getscheduler, sys_sched_getscheduler, 157, 1)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_sched_get_priority_max
+TRACE_SYSCALL_TABLE(sys_sched_get_priority_max, sys_sched_get_priority_max, 159, 1)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_sched_get_priority_min
+TRACE_SYSCALL_TABLE(sys_sched_get_priority_min, sys_sched_get_priority_min, 160, 1)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_mremap
+TRACE_SYSCALL_TABLE(sys_mremap, sys_mremap, 163, 5)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_setresuid16
+TRACE_SYSCALL_TABLE(sys_setresuid16, sys_setresuid16, 164, 3)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_setresgid16
+TRACE_SYSCALL_TABLE(sys_setresgid16, sys_setresgid16, 170, 3)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_prctl
+TRACE_SYSCALL_TABLE(sys_prctl, sys_prctl, 172, 5)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_mmap_pgoff
+TRACE_SYSCALL_TABLE(sys_mmap_pgoff, sys_mmap_pgoff, 192, 6)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_setreuid
+TRACE_SYSCALL_TABLE(sys_setreuid, sys_setreuid, 203, 2)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_setregid
+TRACE_SYSCALL_TABLE(sys_setregid, sys_setregid, 204, 2)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_fchown
+TRACE_SYSCALL_TABLE(sys_fchown, sys_fchown, 207, 3)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_setresuid
+TRACE_SYSCALL_TABLE(sys_setresuid, sys_setresuid, 208, 3)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_setresgid
+TRACE_SYSCALL_TABLE(sys_setresgid, sys_setresgid, 210, 3)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_setuid
+TRACE_SYSCALL_TABLE(sys_setuid, sys_setuid, 213, 1)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_setgid
+TRACE_SYSCALL_TABLE(sys_setgid, sys_setgid, 214, 1)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_setfsuid
+TRACE_SYSCALL_TABLE(sys_setfsuid, sys_setfsuid, 215, 1)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_setfsgid
+TRACE_SYSCALL_TABLE(sys_setfsgid, sys_setfsgid, 216, 1)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_madvise
+TRACE_SYSCALL_TABLE(sys_madvise, sys_madvise, 219, 3)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_fcntl64
+TRACE_SYSCALL_TABLE(sys_fcntl64, sys_fcntl64, 221, 3)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_tkill
+TRACE_SYSCALL_TABLE(sys_tkill, sys_tkill, 238, 2)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_io_destroy
+TRACE_SYSCALL_TABLE(sys_io_destroy, sys_io_destroy, 246, 1)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_exit_group
+TRACE_SYSCALL_TABLE(sys_exit_group, sys_exit_group, 252, 1)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_epoll_create
+TRACE_SYSCALL_TABLE(sys_epoll_create, sys_epoll_create, 254, 1)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_remap_file_pages
+TRACE_SYSCALL_TABLE(sys_remap_file_pages, sys_remap_file_pages, 257, 5)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_timer_getoverrun
+TRACE_SYSCALL_TABLE(sys_timer_getoverrun, sys_timer_getoverrun, 262, 1)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_timer_delete
+TRACE_SYSCALL_TABLE(sys_timer_delete, sys_timer_delete, 263, 1)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_tgkill
+TRACE_SYSCALL_TABLE(sys_tgkill, sys_tgkill, 270, 3)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_keyctl
+TRACE_SYSCALL_TABLE(sys_keyctl, sys_keyctl, 288, 5)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_ioprio_set
+TRACE_SYSCALL_TABLE(sys_ioprio_set, sys_ioprio_set, 289, 3)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_ioprio_get
+TRACE_SYSCALL_TABLE(sys_ioprio_get, sys_ioprio_get, 290, 2)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_inotify_rm_watch
+TRACE_SYSCALL_TABLE(sys_inotify_rm_watch, sys_inotify_rm_watch, 293, 2)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_unshare
+TRACE_SYSCALL_TABLE(sys_unshare, sys_unshare, 310, 1)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_tee
+TRACE_SYSCALL_TABLE(sys_tee, sys_tee, 315, 4)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_timerfd_create
+TRACE_SYSCALL_TABLE(sys_timerfd_create, sys_timerfd_create, 322, 2)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_eventfd
+TRACE_SYSCALL_TABLE(sys_eventfd, sys_eventfd, 323, 1)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_eventfd2
+TRACE_SYSCALL_TABLE(sys_eventfd2, sys_eventfd2, 328, 2)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_epoll_create1
+TRACE_SYSCALL_TABLE(sys_epoll_create1, sys_epoll_create1, 329, 1)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_dup3
+TRACE_SYSCALL_TABLE(sys_dup3, sys_dup3, 330, 3)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_inotify_init1
+TRACE_SYSCALL_TABLE(sys_inotify_init1, sys_inotify_init1, 332, 1)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_fanotify_init
+TRACE_SYSCALL_TABLE(sys_fanotify_init, sys_fanotify_init, 338, 2)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_syncfs
+TRACE_SYSCALL_TABLE(sys_syncfs, sys_syncfs, 344, 1)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_setns
+TRACE_SYSCALL_TABLE(sys_setns, sys_setns, 346, 2)
+#endif
+
+#endif /* CREATE_SYSCALL_TABLE */
diff --git a/drivers/staging/lttng/instrumentation/syscalls/headers/x86-32-syscalls-3.1.0-rc6_integers_override.h b/drivers/staging/lttng/instrumentation/syscalls/headers/x86-32-syscalls-3.1.0-rc6_integers_override.h
new file mode 100644 (file)
index 0000000..ed2cf1f
--- /dev/null
@@ -0,0 +1,38 @@
+#ifndef CONFIG_UID16
+
+#define OVERRIDE_32_sys_getuid16
+#define OVERRIDE_32_sys_getgid16
+#define OVERRIDE_32_sys_geteuid16
+#define OVERRIDE_32_sys_getegid16
+#define OVERRIDE_32_sys_setuid16
+#define OVERRIDE_32_sys_setgid16
+#define OVERRIDE_32_sys_setfsuid16
+#define OVERRIDE_32_sys_setfsgid16
+#define OVERRIDE_32_sys_setreuid16
+#define OVERRIDE_32_sys_setregid16
+#define OVERRIDE_32_sys_fchown16
+#define OVERRIDE_32_sys_setresuid16
+#define OVERRIDE_32_sys_setresgid16
+
+#define OVERRIDE_TABLE_32_sys_getuid16
+#define OVERRIDE_TABLE_32_sys_getgid16
+#define OVERRIDE_TABLE_32_sys_geteuid16
+#define OVERRIDE_TABLE_32_sys_getegid16
+#define OVERRIDE_TABLE_32_sys_setuid16
+#define OVERRIDE_TABLE_32_sys_setgid16
+#define OVERRIDE_TABLE_32_sys_setreuid16
+#define OVERRIDE_TABLE_32_sys_setregid16
+#define OVERRIDE_TABLE_32_sys_fchown16
+#define OVERRIDE_TABLE_32_sys_setfsuid16
+#define OVERRIDE_TABLE_32_sys_setfsgid16
+#define OVERRIDE_TABLE_32_sys_setresuid16
+#define OVERRIDE_TABLE_32_sys_setresgid16
+
+#endif
+
+#ifdef CREATE_SYSCALL_TABLE
+
+#define OVERRIDE_TABLE_32_sys_mmap
+TRACE_SYSCALL_TABLE(sys_mmap, sys_mmap, 90, 6)
+
+#endif
diff --git a/drivers/staging/lttng/instrumentation/syscalls/headers/x86-32-syscalls-3.1.0-rc6_pointers.h b/drivers/staging/lttng/instrumentation/syscalls/headers/x86-32-syscalls-3.1.0-rc6_pointers.h
new file mode 100644 (file)
index 0000000..ec5b301
--- /dev/null
@@ -0,0 +1,2232 @@
+/* THIS FILE IS AUTO-GENERATED. DO NOT EDIT */
+#ifndef CREATE_SYSCALL_TABLE
+
+#if !defined(_TRACE_SYSCALLS_POINTERS_H) || defined(TRACE_HEADER_MULTI_READ)
+#define _TRACE_SYSCALLS_POINTERS_H
+
+#include <linux/tracepoint.h>
+#include <linux/syscalls.h>
+#include "x86-32-syscalls-3.1.0-rc6_pointers_override.h"
+#include "syscalls_pointers_override.h"
+
+#ifndef OVERRIDE_32_sys_unlink
+SC_TRACE_EVENT(sys_unlink,
+       TP_PROTO(const char * pathname),
+       TP_ARGS(pathname),
+       TP_STRUCT__entry(__string_from_user(pathname, pathname)),
+       TP_fast_assign(tp_copy_string_from_user(pathname, pathname)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_chdir
+SC_TRACE_EVENT(sys_chdir,
+       TP_PROTO(const char * filename),
+       TP_ARGS(filename),
+       TP_STRUCT__entry(__string_from_user(filename, filename)),
+       TP_fast_assign(tp_copy_string_from_user(filename, filename)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_time
+SC_TRACE_EVENT(sys_time,
+       TP_PROTO(time_t * tloc),
+       TP_ARGS(tloc),
+       TP_STRUCT__entry(__field_hex(time_t *, tloc)),
+       TP_fast_assign(tp_assign(tloc, tloc)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_oldumount
+SC_TRACE_EVENT(sys_oldumount,
+       TP_PROTO(char * name),
+       TP_ARGS(name),
+       TP_STRUCT__entry(__string_from_user(name, name)),
+       TP_fast_assign(tp_copy_string_from_user(name, name)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_stime
+SC_TRACE_EVENT(sys_stime,
+       TP_PROTO(time_t * tptr),
+       TP_ARGS(tptr),
+       TP_STRUCT__entry(__field_hex(time_t *, tptr)),
+       TP_fast_assign(tp_assign(tptr, tptr)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_rmdir
+SC_TRACE_EVENT(sys_rmdir,
+       TP_PROTO(const char * pathname),
+       TP_ARGS(pathname),
+       TP_STRUCT__entry(__string_from_user(pathname, pathname)),
+       TP_fast_assign(tp_copy_string_from_user(pathname, pathname)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_pipe
+SC_TRACE_EVENT(sys_pipe,
+       TP_PROTO(int * fildes),
+       TP_ARGS(fildes),
+       TP_STRUCT__entry(__field_hex(int *, fildes)),
+       TP_fast_assign(tp_assign(fildes, fildes)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_times
+SC_TRACE_EVENT(sys_times,
+       TP_PROTO(struct tms * tbuf),
+       TP_ARGS(tbuf),
+       TP_STRUCT__entry(__field_hex(struct tms *, tbuf)),
+       TP_fast_assign(tp_assign(tbuf, tbuf)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_acct
+SC_TRACE_EVENT(sys_acct,
+       TP_PROTO(const char * name),
+       TP_ARGS(name),
+       TP_STRUCT__entry(__string_from_user(name, name)),
+       TP_fast_assign(tp_copy_string_from_user(name, name)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_olduname
+SC_TRACE_EVENT(sys_olduname,
+       TP_PROTO(struct oldold_utsname * name),
+       TP_ARGS(name),
+       TP_STRUCT__entry(__field_hex(struct oldold_utsname *, name)),
+       TP_fast_assign(tp_assign(name, name)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_chroot
+SC_TRACE_EVENT(sys_chroot,
+       TP_PROTO(const char * filename),
+       TP_ARGS(filename),
+       TP_STRUCT__entry(__string_from_user(filename, filename)),
+       TP_fast_assign(tp_copy_string_from_user(filename, filename)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_sigpending
+SC_TRACE_EVENT(sys_sigpending,
+       TP_PROTO(old_sigset_t * set),
+       TP_ARGS(set),
+       TP_STRUCT__entry(__field_hex(old_sigset_t *, set)),
+       TP_fast_assign(tp_assign(set, set)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_old_select
+SC_TRACE_EVENT(sys_old_select,
+       TP_PROTO(struct sel_arg_struct * arg),
+       TP_ARGS(arg),
+       TP_STRUCT__entry(__field_hex(struct sel_arg_struct *, arg)),
+       TP_fast_assign(tp_assign(arg, arg)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_uselib
+SC_TRACE_EVENT(sys_uselib,
+       TP_PROTO(const char * library),
+       TP_ARGS(library),
+       TP_STRUCT__entry(__field_hex(const char *, library)),
+       TP_fast_assign(tp_assign(library, library)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_old_mmap
+SC_TRACE_EVENT(sys_old_mmap,
+       TP_PROTO(struct mmap_arg_struct * arg),
+       TP_ARGS(arg),
+       TP_STRUCT__entry(__field_hex(struct mmap_arg_struct *, arg)),
+       TP_fast_assign(tp_assign(arg, arg)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_uname
+SC_TRACE_EVENT(sys_uname,
+       TP_PROTO(struct old_utsname * name),
+       TP_ARGS(name),
+       TP_STRUCT__entry(__field_hex(struct old_utsname *, name)),
+       TP_fast_assign(tp_assign(name, name)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_swapoff
+SC_TRACE_EVENT(sys_swapoff,
+       TP_PROTO(const char * specialfile),
+       TP_ARGS(specialfile),
+       TP_STRUCT__entry(__string_from_user(specialfile, specialfile)),
+       TP_fast_assign(tp_copy_string_from_user(specialfile, specialfile)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_sysinfo
+SC_TRACE_EVENT(sys_sysinfo,
+       TP_PROTO(struct sysinfo * info),
+       TP_ARGS(info),
+       TP_STRUCT__entry(__field_hex(struct sysinfo *, info)),
+       TP_fast_assign(tp_assign(info, info)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_newuname
+SC_TRACE_EVENT(sys_newuname,
+       TP_PROTO(struct new_utsname * name),
+       TP_ARGS(name),
+       TP_STRUCT__entry(__field_hex(struct new_utsname *, name)),
+       TP_fast_assign(tp_assign(name, name)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_adjtimex
+SC_TRACE_EVENT(sys_adjtimex,
+       TP_PROTO(struct timex * txc_p),
+       TP_ARGS(txc_p),
+       TP_STRUCT__entry(__field_hex(struct timex *, txc_p)),
+       TP_fast_assign(tp_assign(txc_p, txc_p)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_sysctl
+SC_TRACE_EVENT(sys_sysctl,
+       TP_PROTO(struct __sysctl_args * args),
+       TP_ARGS(args),
+       TP_STRUCT__entry(__field_hex(struct __sysctl_args *, args)),
+       TP_fast_assign(tp_assign(args, args)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_set_tid_address
+SC_TRACE_EVENT(sys_set_tid_address,
+       TP_PROTO(int * tidptr),
+       TP_ARGS(tidptr),
+       TP_STRUCT__entry(__field_hex(int *, tidptr)),
+       TP_fast_assign(tp_assign(tidptr, tidptr)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_mq_unlink
+SC_TRACE_EVENT(sys_mq_unlink,
+       TP_PROTO(const char * u_name),
+       TP_ARGS(u_name),
+       TP_STRUCT__entry(__string_from_user(u_name, u_name)),
+       TP_fast_assign(tp_copy_string_from_user(u_name, u_name)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_creat
+SC_TRACE_EVENT(sys_creat,
+       TP_PROTO(const char * pathname, int mode),
+       TP_ARGS(pathname, mode),
+       TP_STRUCT__entry(__string_from_user(pathname, pathname) __field(int, mode)),
+       TP_fast_assign(tp_copy_string_from_user(pathname, pathname) tp_assign(mode, mode)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_link
+SC_TRACE_EVENT(sys_link,
+       TP_PROTO(const char * oldname, const char * newname),
+       TP_ARGS(oldname, newname),
+       TP_STRUCT__entry(__string_from_user(oldname, oldname) __string_from_user(newname, newname)),
+       TP_fast_assign(tp_copy_string_from_user(oldname, oldname) tp_copy_string_from_user(newname, newname)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_chmod
+SC_TRACE_EVENT(sys_chmod,
+       TP_PROTO(const char * filename, mode_t mode),
+       TP_ARGS(filename, mode),
+       TP_STRUCT__entry(__string_from_user(filename, filename) __field(mode_t, mode)),
+       TP_fast_assign(tp_copy_string_from_user(filename, filename) tp_assign(mode, mode)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_stat
+SC_TRACE_EVENT(sys_stat,
+       TP_PROTO(const char * filename, struct __old_kernel_stat * statbuf),
+       TP_ARGS(filename, statbuf),
+       TP_STRUCT__entry(__string_from_user(filename, filename) __field_hex(struct __old_kernel_stat *, statbuf)),
+       TP_fast_assign(tp_copy_string_from_user(filename, filename) tp_assign(statbuf, statbuf)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_fstat
+SC_TRACE_EVENT(sys_fstat,
+       TP_PROTO(unsigned int fd, struct __old_kernel_stat * statbuf),
+       TP_ARGS(fd, statbuf),
+       TP_STRUCT__entry(__field(unsigned int, fd) __field_hex(struct __old_kernel_stat *, statbuf)),
+       TP_fast_assign(tp_assign(fd, fd) tp_assign(statbuf, statbuf)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_utime
+SC_TRACE_EVENT(sys_utime,
+       TP_PROTO(char * filename, struct utimbuf * times),
+       TP_ARGS(filename, times),
+       TP_STRUCT__entry(__string_from_user(filename, filename) __field_hex(struct utimbuf *, times)),
+       TP_fast_assign(tp_copy_string_from_user(filename, filename) tp_assign(times, times)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_access
+SC_TRACE_EVENT(sys_access,
+       TP_PROTO(const char * filename, int mode),
+       TP_ARGS(filename, mode),
+       TP_STRUCT__entry(__string_from_user(filename, filename) __field(int, mode)),
+       TP_fast_assign(tp_copy_string_from_user(filename, filename) tp_assign(mode, mode)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_rename
+SC_TRACE_EVENT(sys_rename,
+       TP_PROTO(const char * oldname, const char * newname),
+       TP_ARGS(oldname, newname),
+       TP_STRUCT__entry(__string_from_user(oldname, oldname) __string_from_user(newname, newname)),
+       TP_fast_assign(tp_copy_string_from_user(oldname, oldname) tp_copy_string_from_user(newname, newname)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_mkdir
+SC_TRACE_EVENT(sys_mkdir,
+       TP_PROTO(const char * pathname, int mode),
+       TP_ARGS(pathname, mode),
+       TP_STRUCT__entry(__string_from_user(pathname, pathname) __field(int, mode)),
+       TP_fast_assign(tp_copy_string_from_user(pathname, pathname) tp_assign(mode, mode)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_umount
+SC_TRACE_EVENT(sys_umount,
+       TP_PROTO(char * name, int flags),
+       TP_ARGS(name, flags),
+       TP_STRUCT__entry(__string_from_user(name, name) __field(int, flags)),
+       TP_fast_assign(tp_copy_string_from_user(name, name) tp_assign(flags, flags)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_ustat
+SC_TRACE_EVENT(sys_ustat,
+       TP_PROTO(unsigned dev, struct ustat * ubuf),
+       TP_ARGS(dev, ubuf),
+       TP_STRUCT__entry(__field(unsigned, dev) __field_hex(struct ustat *, ubuf)),
+       TP_fast_assign(tp_assign(dev, dev) tp_assign(ubuf, ubuf)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_sethostname
+SC_TRACE_EVENT(sys_sethostname,
+       TP_PROTO(char * name, int len),
+       TP_ARGS(name, len),
+       TP_STRUCT__entry(__string_from_user(name, name) __field(int, len)),
+       TP_fast_assign(tp_copy_string_from_user(name, name) tp_assign(len, len)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_setrlimit
+SC_TRACE_EVENT(sys_setrlimit,
+       TP_PROTO(unsigned int resource, struct rlimit * rlim),
+       TP_ARGS(resource, rlim),
+       TP_STRUCT__entry(__field(unsigned int, resource) __field_hex(struct rlimit *, rlim)),
+       TP_fast_assign(tp_assign(resource, resource) tp_assign(rlim, rlim)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_old_getrlimit
+SC_TRACE_EVENT(sys_old_getrlimit,
+       TP_PROTO(unsigned int resource, struct rlimit * rlim),
+       TP_ARGS(resource, rlim),
+       TP_STRUCT__entry(__field(unsigned int, resource) __field_hex(struct rlimit *, rlim)),
+       TP_fast_assign(tp_assign(resource, resource) tp_assign(rlim, rlim)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_getrusage
+SC_TRACE_EVENT(sys_getrusage,
+       TP_PROTO(int who, struct rusage * ru),
+       TP_ARGS(who, ru),
+       TP_STRUCT__entry(__field(int, who) __field_hex(struct rusage *, ru)),
+       TP_fast_assign(tp_assign(who, who) tp_assign(ru, ru)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_gettimeofday
+SC_TRACE_EVENT(sys_gettimeofday,
+       TP_PROTO(struct timeval * tv, struct timezone * tz),
+       TP_ARGS(tv, tz),
+       TP_STRUCT__entry(__field_hex(struct timeval *, tv) __field_hex(struct timezone *, tz)),
+       TP_fast_assign(tp_assign(tv, tv) tp_assign(tz, tz)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_settimeofday
+SC_TRACE_EVENT(sys_settimeofday,
+       TP_PROTO(struct timeval * tv, struct timezone * tz),
+       TP_ARGS(tv, tz),
+       TP_STRUCT__entry(__field_hex(struct timeval *, tv) __field_hex(struct timezone *, tz)),
+       TP_fast_assign(tp_assign(tv, tv) tp_assign(tz, tz)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_getgroups16
+SC_TRACE_EVENT(sys_getgroups16,
+       TP_PROTO(int gidsetsize, old_gid_t * grouplist),
+       TP_ARGS(gidsetsize, grouplist),
+       TP_STRUCT__entry(__field(int, gidsetsize) __field_hex(old_gid_t *, grouplist)),
+       TP_fast_assign(tp_assign(gidsetsize, gidsetsize) tp_assign(grouplist, grouplist)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_setgroups16
+SC_TRACE_EVENT(sys_setgroups16,
+       TP_PROTO(int gidsetsize, old_gid_t * grouplist),
+       TP_ARGS(gidsetsize, grouplist),
+       TP_STRUCT__entry(__field(int, gidsetsize) __field_hex(old_gid_t *, grouplist)),
+       TP_fast_assign(tp_assign(gidsetsize, gidsetsize) tp_assign(grouplist, grouplist)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_symlink
+SC_TRACE_EVENT(sys_symlink,
+       TP_PROTO(const char * oldname, const char * newname),
+       TP_ARGS(oldname, newname),
+       TP_STRUCT__entry(__string_from_user(oldname, oldname) __string_from_user(newname, newname)),
+       TP_fast_assign(tp_copy_string_from_user(oldname, oldname) tp_copy_string_from_user(newname, newname)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_lstat
+SC_TRACE_EVENT(sys_lstat,
+       TP_PROTO(const char * filename, struct __old_kernel_stat * statbuf),
+       TP_ARGS(filename, statbuf),
+       TP_STRUCT__entry(__string_from_user(filename, filename) __field_hex(struct __old_kernel_stat *, statbuf)),
+       TP_fast_assign(tp_copy_string_from_user(filename, filename) tp_assign(statbuf, statbuf)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_swapon
+SC_TRACE_EVENT(sys_swapon,
+       TP_PROTO(const char * specialfile, int swap_flags),
+       TP_ARGS(specialfile, swap_flags),
+       TP_STRUCT__entry(__string_from_user(specialfile, specialfile) __field(int, swap_flags)),
+       TP_fast_assign(tp_copy_string_from_user(specialfile, specialfile) tp_assign(swap_flags, swap_flags)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_truncate
+SC_TRACE_EVENT(sys_truncate,
+       TP_PROTO(const char * path, long length),
+       TP_ARGS(path, length),
+       TP_STRUCT__entry(__string_from_user(path, path) __field(long, length)),
+       TP_fast_assign(tp_copy_string_from_user(path, path) tp_assign(length, length)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_statfs
+SC_TRACE_EVENT(sys_statfs,
+       TP_PROTO(const char * pathname, struct statfs * buf),
+       TP_ARGS(pathname, buf),
+       TP_STRUCT__entry(__string_from_user(pathname, pathname) __field_hex(struct statfs *, buf)),
+       TP_fast_assign(tp_copy_string_from_user(pathname, pathname) tp_assign(buf, buf)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_fstatfs
+SC_TRACE_EVENT(sys_fstatfs,
+       TP_PROTO(unsigned int fd, struct statfs * buf),
+       TP_ARGS(fd, buf),
+       TP_STRUCT__entry(__field(unsigned int, fd) __field_hex(struct statfs *, buf)),
+       TP_fast_assign(tp_assign(fd, fd) tp_assign(buf, buf)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_socketcall
+SC_TRACE_EVENT(sys_socketcall,
+       TP_PROTO(int call, unsigned long * args),
+       TP_ARGS(call, args),
+       TP_STRUCT__entry(__field(int, call) __field_hex(unsigned long *, args)),
+       TP_fast_assign(tp_assign(call, call) tp_assign(args, args)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_getitimer
+SC_TRACE_EVENT(sys_getitimer,
+       TP_PROTO(int which, struct itimerval * value),
+       TP_ARGS(which, value),
+       TP_STRUCT__entry(__field(int, which) __field_hex(struct itimerval *, value)),
+       TP_fast_assign(tp_assign(which, which) tp_assign(value, value)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_newstat
+SC_TRACE_EVENT(sys_newstat,
+       TP_PROTO(const char * filename, struct stat * statbuf),
+       TP_ARGS(filename, statbuf),
+       TP_STRUCT__entry(__string_from_user(filename, filename) __field_hex(struct stat *, statbuf)),
+       TP_fast_assign(tp_copy_string_from_user(filename, filename) tp_assign(statbuf, statbuf)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_newlstat
+SC_TRACE_EVENT(sys_newlstat,
+       TP_PROTO(const char * filename, struct stat * statbuf),
+       TP_ARGS(filename, statbuf),
+       TP_STRUCT__entry(__string_from_user(filename, filename) __field_hex(struct stat *, statbuf)),
+       TP_fast_assign(tp_copy_string_from_user(filename, filename) tp_assign(statbuf, statbuf)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_newfstat
+SC_TRACE_EVENT(sys_newfstat,
+       TP_PROTO(unsigned int fd, struct stat * statbuf),
+       TP_ARGS(fd, statbuf),
+       TP_STRUCT__entry(__field(unsigned int, fd) __field_hex(struct stat *, statbuf)),
+       TP_fast_assign(tp_assign(fd, fd) tp_assign(statbuf, statbuf)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_setdomainname
+SC_TRACE_EVENT(sys_setdomainname,
+       TP_PROTO(char * name, int len),
+       TP_ARGS(name, len),
+       TP_STRUCT__entry(__string_from_user(name, name) __field(int, len)),
+       TP_fast_assign(tp_copy_string_from_user(name, name) tp_assign(len, len)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_delete_module
+SC_TRACE_EVENT(sys_delete_module,
+       TP_PROTO(const char * name_user, unsigned int flags),
+       TP_ARGS(name_user, flags),
+       TP_STRUCT__entry(__string_from_user(name_user, name_user) __field(unsigned int, flags)),
+       TP_fast_assign(tp_copy_string_from_user(name_user, name_user) tp_assign(flags, flags)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_sched_setparam
+SC_TRACE_EVENT(sys_sched_setparam,
+       TP_PROTO(pid_t pid, struct sched_param * param),
+       TP_ARGS(pid, param),
+       TP_STRUCT__entry(__field(pid_t, pid) __field_hex(struct sched_param *, param)),
+       TP_fast_assign(tp_assign(pid, pid) tp_assign(param, param)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_sched_getparam
+SC_TRACE_EVENT(sys_sched_getparam,
+       TP_PROTO(pid_t pid, struct sched_param * param),
+       TP_ARGS(pid, param),
+       TP_STRUCT__entry(__field(pid_t, pid) __field_hex(struct sched_param *, param)),
+       TP_fast_assign(tp_assign(pid, pid) tp_assign(param, param)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_sched_rr_get_interval
+SC_TRACE_EVENT(sys_sched_rr_get_interval,
+       TP_PROTO(pid_t pid, struct timespec * interval),
+       TP_ARGS(pid, interval),
+       TP_STRUCT__entry(__field(pid_t, pid) __field_hex(struct timespec *, interval)),
+       TP_fast_assign(tp_assign(pid, pid) tp_assign(interval, interval)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_nanosleep
+SC_TRACE_EVENT(sys_nanosleep,
+       TP_PROTO(struct timespec * rqtp, struct timespec * rmtp),
+       TP_ARGS(rqtp, rmtp),
+       TP_STRUCT__entry(__field_hex(struct timespec *, rqtp) __field_hex(struct timespec *, rmtp)),
+       TP_fast_assign(tp_assign(rqtp, rqtp) tp_assign(rmtp, rmtp)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_rt_sigpending
+SC_TRACE_EVENT(sys_rt_sigpending,
+       TP_PROTO(sigset_t * set, size_t sigsetsize),
+       TP_ARGS(set, sigsetsize),
+       TP_STRUCT__entry(__field_hex(sigset_t *, set) __field(size_t, sigsetsize)),
+       TP_fast_assign(tp_assign(set, set) tp_assign(sigsetsize, sigsetsize)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_rt_sigsuspend
+SC_TRACE_EVENT(sys_rt_sigsuspend,
+       TP_PROTO(sigset_t * unewset, size_t sigsetsize),
+       TP_ARGS(unewset, sigsetsize),
+       TP_STRUCT__entry(__field_hex(sigset_t *, unewset) __field(size_t, sigsetsize)),
+       TP_fast_assign(tp_assign(unewset, unewset) tp_assign(sigsetsize, sigsetsize)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_getcwd
+SC_TRACE_EVENT(sys_getcwd,
+       TP_PROTO(char * buf, unsigned long size),
+       TP_ARGS(buf, size),
+       TP_STRUCT__entry(__field_hex(char *, buf) __field(unsigned long, size)),
+       TP_fast_assign(tp_assign(buf, buf) tp_assign(size, size)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_getrlimit
+SC_TRACE_EVENT(sys_getrlimit,
+       TP_PROTO(unsigned int resource, struct rlimit * rlim),
+       TP_ARGS(resource, rlim),
+       TP_STRUCT__entry(__field(unsigned int, resource) __field_hex(struct rlimit *, rlim)),
+       TP_fast_assign(tp_assign(resource, resource) tp_assign(rlim, rlim)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_stat64
+SC_TRACE_EVENT(sys_stat64,
+       TP_PROTO(const char * filename, struct stat64 * statbuf),
+       TP_ARGS(filename, statbuf),
+       TP_STRUCT__entry(__string_from_user(filename, filename) __field_hex(struct stat64 *, statbuf)),
+       TP_fast_assign(tp_copy_string_from_user(filename, filename) tp_assign(statbuf, statbuf)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_lstat64
+SC_TRACE_EVENT(sys_lstat64,
+       TP_PROTO(const char * filename, struct stat64 * statbuf),
+       TP_ARGS(filename, statbuf),
+       TP_STRUCT__entry(__string_from_user(filename, filename) __field_hex(struct stat64 *, statbuf)),
+       TP_fast_assign(tp_copy_string_from_user(filename, filename) tp_assign(statbuf, statbuf)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_fstat64
+SC_TRACE_EVENT(sys_fstat64,
+       TP_PROTO(unsigned long fd, struct stat64 * statbuf),
+       TP_ARGS(fd, statbuf),
+       TP_STRUCT__entry(__field(unsigned long, fd) __field_hex(struct stat64 *, statbuf)),
+       TP_fast_assign(tp_assign(fd, fd) tp_assign(statbuf, statbuf)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_getgroups
+SC_TRACE_EVENT(sys_getgroups,
+       TP_PROTO(int gidsetsize, gid_t * grouplist),
+       TP_ARGS(gidsetsize, grouplist),
+       TP_STRUCT__entry(__field(int, gidsetsize) __field_hex(gid_t *, grouplist)),
+       TP_fast_assign(tp_assign(gidsetsize, gidsetsize) tp_assign(grouplist, grouplist)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_setgroups
+SC_TRACE_EVENT(sys_setgroups,
+       TP_PROTO(int gidsetsize, gid_t * grouplist),
+       TP_ARGS(gidsetsize, grouplist),
+       TP_STRUCT__entry(__field(int, gidsetsize) __field_hex(gid_t *, grouplist)),
+       TP_fast_assign(tp_assign(gidsetsize, gidsetsize) tp_assign(grouplist, grouplist)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_pivot_root
+SC_TRACE_EVENT(sys_pivot_root,
+       TP_PROTO(const char * new_root, const char * put_old),
+       TP_ARGS(new_root, put_old),
+       TP_STRUCT__entry(__string_from_user(new_root, new_root) __string_from_user(put_old, put_old)),
+       TP_fast_assign(tp_copy_string_from_user(new_root, new_root) tp_copy_string_from_user(put_old, put_old)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_removexattr
+SC_TRACE_EVENT(sys_removexattr,
+       TP_PROTO(const char * pathname, const char * name),
+       TP_ARGS(pathname, name),
+       TP_STRUCT__entry(__string_from_user(pathname, pathname) __string_from_user(name, name)),
+       TP_fast_assign(tp_copy_string_from_user(pathname, pathname) tp_copy_string_from_user(name, name)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_lremovexattr
+SC_TRACE_EVENT(sys_lremovexattr,
+       TP_PROTO(const char * pathname, const char * name),
+       TP_ARGS(pathname, name),
+       TP_STRUCT__entry(__string_from_user(pathname, pathname) __string_from_user(name, name)),
+       TP_fast_assign(tp_copy_string_from_user(pathname, pathname) tp_copy_string_from_user(name, name)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_fremovexattr
+SC_TRACE_EVENT(sys_fremovexattr,
+       TP_PROTO(int fd, const char * name),
+       TP_ARGS(fd, name),
+       TP_STRUCT__entry(__field(int, fd) __string_from_user(name, name)),
+       TP_fast_assign(tp_assign(fd, fd) tp_copy_string_from_user(name, name)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_io_setup
+SC_TRACE_EVENT(sys_io_setup,
+       TP_PROTO(unsigned nr_events, aio_context_t * ctxp),
+       TP_ARGS(nr_events, ctxp),
+       TP_STRUCT__entry(__field(unsigned, nr_events) __field_hex(aio_context_t *, ctxp)),
+       TP_fast_assign(tp_assign(nr_events, nr_events) tp_assign(ctxp, ctxp)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_timer_gettime
+SC_TRACE_EVENT(sys_timer_gettime,
+       TP_PROTO(timer_t timer_id, struct itimerspec * setting),
+       TP_ARGS(timer_id, setting),
+       TP_STRUCT__entry(__field(timer_t, timer_id) __field_hex(struct itimerspec *, setting)),
+       TP_fast_assign(tp_assign(timer_id, timer_id) tp_assign(setting, setting)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_clock_settime
+SC_TRACE_EVENT(sys_clock_settime,
+       TP_PROTO(const clockid_t which_clock, const struct timespec * tp),
+       TP_ARGS(which_clock, tp),
+       TP_STRUCT__entry(__field(const clockid_t, which_clock) __field_hex(const struct timespec *, tp)),
+       TP_fast_assign(tp_assign(which_clock, which_clock) tp_assign(tp, tp)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_clock_gettime
+SC_TRACE_EVENT(sys_clock_gettime,
+       TP_PROTO(const clockid_t which_clock, struct timespec * tp),
+       TP_ARGS(which_clock, tp),
+       TP_STRUCT__entry(__field(const clockid_t, which_clock) __field_hex(struct timespec *, tp)),
+       TP_fast_assign(tp_assign(which_clock, which_clock) tp_assign(tp, tp)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_clock_getres
+SC_TRACE_EVENT(sys_clock_getres,
+       TP_PROTO(const clockid_t which_clock, struct timespec * tp),
+       TP_ARGS(which_clock, tp),
+       TP_STRUCT__entry(__field(const clockid_t, which_clock) __field_hex(struct timespec *, tp)),
+       TP_fast_assign(tp_assign(which_clock, which_clock) tp_assign(tp, tp)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_utimes
+SC_TRACE_EVENT(sys_utimes,
+       TP_PROTO(char * filename, struct timeval * utimes),
+       TP_ARGS(filename, utimes),
+       TP_STRUCT__entry(__string_from_user(filename, filename) __field_hex(struct timeval *, utimes)),
+       TP_fast_assign(tp_copy_string_from_user(filename, filename) tp_assign(utimes, utimes)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_mq_notify
+SC_TRACE_EVENT(sys_mq_notify,
+       TP_PROTO(mqd_t mqdes, const struct sigevent * u_notification),
+       TP_ARGS(mqdes, u_notification),
+       TP_STRUCT__entry(__field(mqd_t, mqdes) __field_hex(const struct sigevent *, u_notification)),
+       TP_fast_assign(tp_assign(mqdes, mqdes) tp_assign(u_notification, u_notification)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_set_robust_list
+SC_TRACE_EVENT(sys_set_robust_list,
+       TP_PROTO(struct robust_list_head * head, size_t len),
+       TP_ARGS(head, len),
+       TP_STRUCT__entry(__field_hex(struct robust_list_head *, head) __field(size_t, len)),
+       TP_fast_assign(tp_assign(head, head) tp_assign(len, len)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_timerfd_gettime
+SC_TRACE_EVENT(sys_timerfd_gettime,
+       TP_PROTO(int ufd, struct itimerspec * otmr),
+       TP_ARGS(ufd, otmr),
+       TP_STRUCT__entry(__field(int, ufd) __field_hex(struct itimerspec *, otmr)),
+       TP_fast_assign(tp_assign(ufd, ufd) tp_assign(otmr, otmr)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_pipe2
+SC_TRACE_EVENT(sys_pipe2,
+       TP_PROTO(int * fildes, int flags),
+       TP_ARGS(fildes, flags),
+       TP_STRUCT__entry(__field_hex(int *, fildes) __field(int, flags)),
+       TP_fast_assign(tp_assign(fildes, fildes) tp_assign(flags, flags)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_clock_adjtime
+SC_TRACE_EVENT(sys_clock_adjtime,
+       TP_PROTO(const clockid_t which_clock, struct timex * utx),
+       TP_ARGS(which_clock, utx),
+       TP_STRUCT__entry(__field(const clockid_t, which_clock) __field_hex(struct timex *, utx)),
+       TP_fast_assign(tp_assign(which_clock, which_clock) tp_assign(utx, utx)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_read
+SC_TRACE_EVENT(sys_read,
+       TP_PROTO(unsigned int fd, char * buf, size_t count),
+       TP_ARGS(fd, buf, count),
+       TP_STRUCT__entry(__field(unsigned int, fd) __field_hex(char *, buf) __field(size_t, count)),
+       TP_fast_assign(tp_assign(fd, fd) tp_assign(buf, buf) tp_assign(count, count)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_write
+SC_TRACE_EVENT(sys_write,
+       TP_PROTO(unsigned int fd, const char * buf, size_t count),
+       TP_ARGS(fd, buf, count),
+       TP_STRUCT__entry(__field(unsigned int, fd) __field_hex(const char *, buf) __field(size_t, count)),
+       TP_fast_assign(tp_assign(fd, fd) tp_assign(buf, buf) tp_assign(count, count)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_open
+SC_TRACE_EVENT(sys_open,
+       TP_PROTO(const char * filename, int flags, int mode),
+       TP_ARGS(filename, flags, mode),
+       TP_STRUCT__entry(__string_from_user(filename, filename) __field(int, flags) __field(int, mode)),
+       TP_fast_assign(tp_copy_string_from_user(filename, filename) tp_assign(flags, flags) tp_assign(mode, mode)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_waitpid
+SC_TRACE_EVENT(sys_waitpid,
+       TP_PROTO(pid_t pid, int * stat_addr, int options),
+       TP_ARGS(pid, stat_addr, options),
+       TP_STRUCT__entry(__field(pid_t, pid) __field_hex(int *, stat_addr) __field(int, options)),
+       TP_fast_assign(tp_assign(pid, pid) tp_assign(stat_addr, stat_addr) tp_assign(options, options)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_mknod
+SC_TRACE_EVENT(sys_mknod,
+       TP_PROTO(const char * filename, int mode, unsigned dev),
+       TP_ARGS(filename, mode, dev),
+       TP_STRUCT__entry(__string_from_user(filename, filename) __field(int, mode) __field(unsigned, dev)),
+       TP_fast_assign(tp_copy_string_from_user(filename, filename) tp_assign(mode, mode) tp_assign(dev, dev)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_lchown16
+SC_TRACE_EVENT(sys_lchown16,
+       TP_PROTO(const char * filename, old_uid_t user, old_gid_t group),
+       TP_ARGS(filename, user, group),
+       TP_STRUCT__entry(__string_from_user(filename, filename) __field(old_uid_t, user) __field(old_gid_t, group)),
+       TP_fast_assign(tp_copy_string_from_user(filename, filename) tp_assign(user, user) tp_assign(group, group)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_readlink
+SC_TRACE_EVENT(sys_readlink,
+       TP_PROTO(const char * path, char * buf, int bufsiz),
+       TP_ARGS(path, buf, bufsiz),
+       TP_STRUCT__entry(__string_from_user(path, path) __field_hex(char *, buf) __field(int, bufsiz)),
+       TP_fast_assign(tp_copy_string_from_user(path, path) tp_assign(buf, buf) tp_assign(bufsiz, bufsiz)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_old_readdir
+SC_TRACE_EVENT(sys_old_readdir,
+       TP_PROTO(unsigned int fd, struct old_linux_dirent * dirent, unsigned int count),
+       TP_ARGS(fd, dirent, count),
+       TP_STRUCT__entry(__field(unsigned int, fd) __field_hex(struct old_linux_dirent *, dirent) __field(unsigned int, count)),
+       TP_fast_assign(tp_assign(fd, fd) tp_assign(dirent, dirent) tp_assign(count, count)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_syslog
+SC_TRACE_EVENT(sys_syslog,
+       TP_PROTO(int type, char * buf, int len),
+       TP_ARGS(type, buf, len),
+       TP_STRUCT__entry(__field(int, type) __field_hex(char *, buf) __field(int, len)),
+       TP_fast_assign(tp_assign(type, type) tp_assign(buf, buf) tp_assign(len, len)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_setitimer
+SC_TRACE_EVENT(sys_setitimer,
+       TP_PROTO(int which, struct itimerval * value, struct itimerval * ovalue),
+       TP_ARGS(which, value, ovalue),
+       TP_STRUCT__entry(__field(int, which) __field_hex(struct itimerval *, value) __field_hex(struct itimerval *, ovalue)),
+       TP_fast_assign(tp_assign(which, which) tp_assign(value, value) tp_assign(ovalue, ovalue)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_sigprocmask
+SC_TRACE_EVENT(sys_sigprocmask,
+       TP_PROTO(int how, old_sigset_t * nset, old_sigset_t * oset),
+       TP_ARGS(how, nset, oset),
+       TP_STRUCT__entry(__field(int, how) __field_hex(old_sigset_t *, nset) __field_hex(old_sigset_t *, oset)),
+       TP_fast_assign(tp_assign(how, how) tp_assign(nset, nset) tp_assign(oset, oset)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_init_module
+SC_TRACE_EVENT(sys_init_module,
+       TP_PROTO(void * umod, unsigned long len, const char * uargs),
+       TP_ARGS(umod, len, uargs),
+       TP_STRUCT__entry(__field_hex(void *, umod) __field(unsigned long, len) __field_hex(const char *, uargs)),
+       TP_fast_assign(tp_assign(umod, umod) tp_assign(len, len) tp_assign(uargs, uargs)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_getdents
+SC_TRACE_EVENT(sys_getdents,
+       TP_PROTO(unsigned int fd, struct linux_dirent * dirent, unsigned int count),
+       TP_ARGS(fd, dirent, count),
+       TP_STRUCT__entry(__field(unsigned int, fd) __field_hex(struct linux_dirent *, dirent) __field(unsigned int, count)),
+       TP_fast_assign(tp_assign(fd, fd) tp_assign(dirent, dirent) tp_assign(count, count)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_readv
+SC_TRACE_EVENT(sys_readv,
+       TP_PROTO(unsigned long fd, const struct iovec * vec, unsigned long vlen),
+       TP_ARGS(fd, vec, vlen),
+       TP_STRUCT__entry(__field(unsigned long, fd) __field_hex(const struct iovec *, vec) __field(unsigned long, vlen)),
+       TP_fast_assign(tp_assign(fd, fd) tp_assign(vec, vec) tp_assign(vlen, vlen)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_writev
+SC_TRACE_EVENT(sys_writev,
+       TP_PROTO(unsigned long fd, const struct iovec * vec, unsigned long vlen),
+       TP_ARGS(fd, vec, vlen),
+       TP_STRUCT__entry(__field(unsigned long, fd) __field_hex(const struct iovec *, vec) __field(unsigned long, vlen)),
+       TP_fast_assign(tp_assign(fd, fd) tp_assign(vec, vec) tp_assign(vlen, vlen)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_sched_setscheduler
+SC_TRACE_EVENT(sys_sched_setscheduler,
+       TP_PROTO(pid_t pid, int policy, struct sched_param * param),
+       TP_ARGS(pid, policy, param),
+       TP_STRUCT__entry(__field(pid_t, pid) __field(int, policy) __field_hex(struct sched_param *, param)),
+       TP_fast_assign(tp_assign(pid, pid) tp_assign(policy, policy) tp_assign(param, param)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_getresuid16
+SC_TRACE_EVENT(sys_getresuid16,
+       TP_PROTO(old_uid_t * ruid, old_uid_t * euid, old_uid_t * suid),
+       TP_ARGS(ruid, euid, suid),
+       TP_STRUCT__entry(__field_hex(old_uid_t *, ruid) __field_hex(old_uid_t *, euid) __field_hex(old_uid_t *, suid)),
+       TP_fast_assign(tp_assign(ruid, ruid) tp_assign(euid, euid) tp_assign(suid, suid)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_poll
+SC_TRACE_EVENT(sys_poll,
+       TP_PROTO(struct pollfd * ufds, unsigned int nfds, long timeout_msecs),
+       TP_ARGS(ufds, nfds, timeout_msecs),
+       TP_STRUCT__entry(__field_hex(struct pollfd *, ufds) __field(unsigned int, nfds) __field(long, timeout_msecs)),
+       TP_fast_assign(tp_assign(ufds, ufds) tp_assign(nfds, nfds) tp_assign(timeout_msecs, timeout_msecs)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_getresgid16
+SC_TRACE_EVENT(sys_getresgid16,
+       TP_PROTO(old_gid_t * rgid, old_gid_t * egid, old_gid_t * sgid),
+       TP_ARGS(rgid, egid, sgid),
+       TP_STRUCT__entry(__field_hex(old_gid_t *, rgid) __field_hex(old_gid_t *, egid) __field_hex(old_gid_t *, sgid)),
+       TP_fast_assign(tp_assign(rgid, rgid) tp_assign(egid, egid) tp_assign(sgid, sgid)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_rt_sigqueueinfo
+SC_TRACE_EVENT(sys_rt_sigqueueinfo,
+       TP_PROTO(pid_t pid, int sig, siginfo_t * uinfo),
+       TP_ARGS(pid, sig, uinfo),
+       TP_STRUCT__entry(__field(pid_t, pid) __field(int, sig) __field_hex(siginfo_t *, uinfo)),
+       TP_fast_assign(tp_assign(pid, pid) tp_assign(sig, sig) tp_assign(uinfo, uinfo)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_chown16
+SC_TRACE_EVENT(sys_chown16,
+       TP_PROTO(const char * filename, old_uid_t user, old_gid_t group),
+       TP_ARGS(filename, user, group),
+       TP_STRUCT__entry(__string_from_user(filename, filename) __field(old_uid_t, user) __field(old_gid_t, group)),
+       TP_fast_assign(tp_copy_string_from_user(filename, filename) tp_assign(user, user) tp_assign(group, group)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_lchown
+SC_TRACE_EVENT(sys_lchown,
+       TP_PROTO(const char * filename, uid_t user, gid_t group),
+       TP_ARGS(filename, user, group),
+       TP_STRUCT__entry(__string_from_user(filename, filename) __field(uid_t, user) __field(gid_t, group)),
+       TP_fast_assign(tp_copy_string_from_user(filename, filename) tp_assign(user, user) tp_assign(group, group)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_getresuid
+SC_TRACE_EVENT(sys_getresuid,
+       TP_PROTO(uid_t * ruid, uid_t * euid, uid_t * suid),
+       TP_ARGS(ruid, euid, suid),
+       TP_STRUCT__entry(__field_hex(uid_t *, ruid) __field_hex(uid_t *, euid) __field_hex(uid_t *, suid)),
+       TP_fast_assign(tp_assign(ruid, ruid) tp_assign(euid, euid) tp_assign(suid, suid)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_getresgid
+SC_TRACE_EVENT(sys_getresgid,
+       TP_PROTO(gid_t * rgid, gid_t * egid, gid_t * sgid),
+       TP_ARGS(rgid, egid, sgid),
+       TP_STRUCT__entry(__field_hex(gid_t *, rgid) __field_hex(gid_t *, egid) __field_hex(gid_t *, sgid)),
+       TP_fast_assign(tp_assign(rgid, rgid) tp_assign(egid, egid) tp_assign(sgid, sgid)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_chown
+SC_TRACE_EVENT(sys_chown,
+       TP_PROTO(const char * filename, uid_t user, gid_t group),
+       TP_ARGS(filename, user, group),
+       TP_STRUCT__entry(__string_from_user(filename, filename) __field(uid_t, user) __field(gid_t, group)),
+       TP_fast_assign(tp_copy_string_from_user(filename, filename) tp_assign(user, user) tp_assign(group, group)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_mincore
+SC_TRACE_EVENT(sys_mincore,
+       TP_PROTO(unsigned long start, size_t len, unsigned char * vec),
+       TP_ARGS(start, len, vec),
+       TP_STRUCT__entry(__field(unsigned long, start) __field(size_t, len) __field_hex(unsigned char *, vec)),
+       TP_fast_assign(tp_assign(start, start) tp_assign(len, len) tp_assign(vec, vec)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_getdents64
+SC_TRACE_EVENT(sys_getdents64,
+       TP_PROTO(unsigned int fd, struct linux_dirent64 * dirent, unsigned int count),
+       TP_ARGS(fd, dirent, count),
+       TP_STRUCT__entry(__field(unsigned int, fd) __field_hex(struct linux_dirent64 *, dirent) __field(unsigned int, count)),
+       TP_fast_assign(tp_assign(fd, fd) tp_assign(dirent, dirent) tp_assign(count, count)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_listxattr
+SC_TRACE_EVENT(sys_listxattr,
+       TP_PROTO(const char * pathname, char * list, size_t size),
+       TP_ARGS(pathname, list, size),
+       TP_STRUCT__entry(__string_from_user(pathname, pathname) __field_hex(char *, list) __field(size_t, size)),
+       TP_fast_assign(tp_copy_string_from_user(pathname, pathname) tp_assign(list, list) tp_assign(size, size)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_llistxattr
+SC_TRACE_EVENT(sys_llistxattr,
+       TP_PROTO(const char * pathname, char * list, size_t size),
+       TP_ARGS(pathname, list, size),
+       TP_STRUCT__entry(__string_from_user(pathname, pathname) __field_hex(char *, list) __field(size_t, size)),
+       TP_fast_assign(tp_copy_string_from_user(pathname, pathname) tp_assign(list, list) tp_assign(size, size)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_flistxattr
+SC_TRACE_EVENT(sys_flistxattr,
+       TP_PROTO(int fd, char * list, size_t size),
+       TP_ARGS(fd, list, size),
+       TP_STRUCT__entry(__field(int, fd) __field_hex(char *, list) __field(size_t, size)),
+       TP_fast_assign(tp_assign(fd, fd) tp_assign(list, list) tp_assign(size, size)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_sched_setaffinity
+SC_TRACE_EVENT(sys_sched_setaffinity,
+       TP_PROTO(pid_t pid, unsigned int len, unsigned long * user_mask_ptr),
+       TP_ARGS(pid, len, user_mask_ptr),
+       TP_STRUCT__entry(__field(pid_t, pid) __field(unsigned int, len) __field_hex(unsigned long *, user_mask_ptr)),
+       TP_fast_assign(tp_assign(pid, pid) tp_assign(len, len) tp_assign(user_mask_ptr, user_mask_ptr)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_sched_getaffinity
+SC_TRACE_EVENT(sys_sched_getaffinity,
+       TP_PROTO(pid_t pid, unsigned int len, unsigned long * user_mask_ptr),
+       TP_ARGS(pid, len, user_mask_ptr),
+       TP_STRUCT__entry(__field(pid_t, pid) __field(unsigned int, len) __field_hex(unsigned long *, user_mask_ptr)),
+       TP_fast_assign(tp_assign(pid, pid) tp_assign(len, len) tp_assign(user_mask_ptr, user_mask_ptr)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_io_submit
+SC_TRACE_EVENT(sys_io_submit,
+       TP_PROTO(aio_context_t ctx_id, long nr, struct iocb * * iocbpp),
+       TP_ARGS(ctx_id, nr, iocbpp),
+       TP_STRUCT__entry(__field(aio_context_t, ctx_id) __field(long, nr) __field_hex(struct iocb * *, iocbpp)),
+       TP_fast_assign(tp_assign(ctx_id, ctx_id) tp_assign(nr, nr) tp_assign(iocbpp, iocbpp)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_io_cancel
+SC_TRACE_EVENT(sys_io_cancel,
+       TP_PROTO(aio_context_t ctx_id, struct iocb * iocb, struct io_event * result),
+       TP_ARGS(ctx_id, iocb, result),
+       TP_STRUCT__entry(__field(aio_context_t, ctx_id) __field_hex(struct iocb *, iocb) __field_hex(struct io_event *, result)),
+       TP_fast_assign(tp_assign(ctx_id, ctx_id) tp_assign(iocb, iocb) tp_assign(result, result)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_timer_create
+SC_TRACE_EVENT(sys_timer_create,
+       TP_PROTO(const clockid_t which_clock, struct sigevent * timer_event_spec, timer_t * created_timer_id),
+       TP_ARGS(which_clock, timer_event_spec, created_timer_id),
+       TP_STRUCT__entry(__field(const clockid_t, which_clock) __field_hex(struct sigevent *, timer_event_spec) __field_hex(timer_t *, created_timer_id)),
+       TP_fast_assign(tp_assign(which_clock, which_clock) tp_assign(timer_event_spec, timer_event_spec) tp_assign(created_timer_id, created_timer_id)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_statfs64
+SC_TRACE_EVENT(sys_statfs64,
+       TP_PROTO(const char * pathname, size_t sz, struct statfs64 * buf),
+       TP_ARGS(pathname, sz, buf),
+       TP_STRUCT__entry(__string_from_user(pathname, pathname) __field(size_t, sz) __field_hex(struct statfs64 *, buf)),
+       TP_fast_assign(tp_copy_string_from_user(pathname, pathname) tp_assign(sz, sz) tp_assign(buf, buf)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_fstatfs64
+SC_TRACE_EVENT(sys_fstatfs64,
+       TP_PROTO(unsigned int fd, size_t sz, struct statfs64 * buf),
+       TP_ARGS(fd, sz, buf),
+       TP_STRUCT__entry(__field(unsigned int, fd) __field(size_t, sz) __field_hex(struct statfs64 *, buf)),
+       TP_fast_assign(tp_assign(fd, fd) tp_assign(sz, sz) tp_assign(buf, buf)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_mq_getsetattr
+SC_TRACE_EVENT(sys_mq_getsetattr,
+       TP_PROTO(mqd_t mqdes, const struct mq_attr * u_mqstat, struct mq_attr * u_omqstat),
+       TP_ARGS(mqdes, u_mqstat, u_omqstat),
+       TP_STRUCT__entry(__field(mqd_t, mqdes) __field_hex(const struct mq_attr *, u_mqstat) __field_hex(struct mq_attr *, u_omqstat)),
+       TP_fast_assign(tp_assign(mqdes, mqdes) tp_assign(u_mqstat, u_mqstat) tp_assign(u_omqstat, u_omqstat)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_inotify_add_watch
+SC_TRACE_EVENT(sys_inotify_add_watch,
+       TP_PROTO(int fd, const char * pathname, u32 mask),
+       TP_ARGS(fd, pathname, mask),
+       TP_STRUCT__entry(__field(int, fd) __string_from_user(pathname, pathname) __field(u32, mask)),
+       TP_fast_assign(tp_assign(fd, fd) tp_copy_string_from_user(pathname, pathname) tp_assign(mask, mask)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_mkdirat
+SC_TRACE_EVENT(sys_mkdirat,
+       TP_PROTO(int dfd, const char * pathname, int mode),
+       TP_ARGS(dfd, pathname, mode),
+       TP_STRUCT__entry(__field(int, dfd) __string_from_user(pathname, pathname) __field(int, mode)),
+       TP_fast_assign(tp_assign(dfd, dfd) tp_copy_string_from_user(pathname, pathname) tp_assign(mode, mode)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_futimesat
+SC_TRACE_EVENT(sys_futimesat,
+       TP_PROTO(int dfd, const char * filename, struct timeval * utimes),
+       TP_ARGS(dfd, filename, utimes),
+       TP_STRUCT__entry(__field(int, dfd) __string_from_user(filename, filename) __field_hex(struct timeval *, utimes)),
+       TP_fast_assign(tp_assign(dfd, dfd) tp_copy_string_from_user(filename, filename) tp_assign(utimes, utimes)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_unlinkat
+SC_TRACE_EVENT(sys_unlinkat,
+       TP_PROTO(int dfd, const char * pathname, int flag),
+       TP_ARGS(dfd, pathname, flag),
+       TP_STRUCT__entry(__field(int, dfd) __string_from_user(pathname, pathname) __field(int, flag)),
+       TP_fast_assign(tp_assign(dfd, dfd) tp_copy_string_from_user(pathname, pathname) tp_assign(flag, flag)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_symlinkat
+SC_TRACE_EVENT(sys_symlinkat,
+       TP_PROTO(const char * oldname, int newdfd, const char * newname),
+       TP_ARGS(oldname, newdfd, newname),
+       TP_STRUCT__entry(__string_from_user(oldname, oldname) __field(int, newdfd) __string_from_user(newname, newname)),
+       TP_fast_assign(tp_copy_string_from_user(oldname, oldname) tp_assign(newdfd, newdfd) tp_copy_string_from_user(newname, newname)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_fchmodat
+SC_TRACE_EVENT(sys_fchmodat,
+       TP_PROTO(int dfd, const char * filename, mode_t mode),
+       TP_ARGS(dfd, filename, mode),
+       TP_STRUCT__entry(__field(int, dfd) __string_from_user(filename, filename) __field(mode_t, mode)),
+       TP_fast_assign(tp_assign(dfd, dfd) tp_copy_string_from_user(filename, filename) tp_assign(mode, mode)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_faccessat
+SC_TRACE_EVENT(sys_faccessat,
+       TP_PROTO(int dfd, const char * filename, int mode),
+       TP_ARGS(dfd, filename, mode),
+       TP_STRUCT__entry(__field(int, dfd) __string_from_user(filename, filename) __field(int, mode)),
+       TP_fast_assign(tp_assign(dfd, dfd) tp_copy_string_from_user(filename, filename) tp_assign(mode, mode)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_get_robust_list
+SC_TRACE_EVENT(sys_get_robust_list,
+       TP_PROTO(int pid, struct robust_list_head * * head_ptr, size_t * len_ptr),
+       TP_ARGS(pid, head_ptr, len_ptr),
+       TP_STRUCT__entry(__field(int, pid) __field_hex(struct robust_list_head * *, head_ptr) __field_hex(size_t *, len_ptr)),
+       TP_fast_assign(tp_assign(pid, pid) tp_assign(head_ptr, head_ptr) tp_assign(len_ptr, len_ptr)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_getcpu
+SC_TRACE_EVENT(sys_getcpu,
+       TP_PROTO(unsigned * cpup, unsigned * nodep, struct getcpu_cache * unused),
+       TP_ARGS(cpup, nodep, unused),
+       TP_STRUCT__entry(__field_hex(unsigned *, cpup) __field_hex(unsigned *, nodep) __field_hex(struct getcpu_cache *, unused)),
+       TP_fast_assign(tp_assign(cpup, cpup) tp_assign(nodep, nodep) tp_assign(unused, unused)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_signalfd
+SC_TRACE_EVENT(sys_signalfd,
+       TP_PROTO(int ufd, sigset_t * user_mask, size_t sizemask),
+       TP_ARGS(ufd, user_mask, sizemask),
+       TP_STRUCT__entry(__field(int, ufd) __field_hex(sigset_t *, user_mask) __field(size_t, sizemask)),
+       TP_fast_assign(tp_assign(ufd, ufd) tp_assign(user_mask, user_mask) tp_assign(sizemask, sizemask)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_reboot
+SC_TRACE_EVENT(sys_reboot,
+       TP_PROTO(int magic1, int magic2, unsigned int cmd, void * arg),
+       TP_ARGS(magic1, magic2, cmd, arg),
+       TP_STRUCT__entry(__field(int, magic1) __field(int, magic2) __field(unsigned int, cmd) __field_hex(void *, arg)),
+       TP_fast_assign(tp_assign(magic1, magic1) tp_assign(magic2, magic2) tp_assign(cmd, cmd) tp_assign(arg, arg)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_wait4
+SC_TRACE_EVENT(sys_wait4,
+       TP_PROTO(pid_t upid, int * stat_addr, int options, struct rusage * ru),
+       TP_ARGS(upid, stat_addr, options, ru),
+       TP_STRUCT__entry(__field(pid_t, upid) __field_hex(int *, stat_addr) __field(int, options) __field_hex(struct rusage *, ru)),
+       TP_fast_assign(tp_assign(upid, upid) tp_assign(stat_addr, stat_addr) tp_assign(options, options) tp_assign(ru, ru)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_quotactl
+SC_TRACE_EVENT(sys_quotactl,
+       TP_PROTO(unsigned int cmd, const char * special, qid_t id, void * addr),
+       TP_ARGS(cmd, special, id, addr),
+       TP_STRUCT__entry(__field(unsigned int, cmd) __field_hex(const char *, special) __field(qid_t, id) __field_hex(void *, addr)),
+       TP_fast_assign(tp_assign(cmd, cmd) tp_assign(special, special) tp_assign(id, id) tp_assign(addr, addr)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_rt_sigaction
+SC_TRACE_EVENT(sys_rt_sigaction,
+       TP_PROTO(int sig, const struct sigaction * act, struct sigaction * oact, size_t sigsetsize),
+       TP_ARGS(sig, act, oact, sigsetsize),
+       TP_STRUCT__entry(__field(int, sig) __field_hex(const struct sigaction *, act) __field_hex(struct sigaction *, oact) __field(size_t, sigsetsize)),
+       TP_fast_assign(tp_assign(sig, sig) tp_assign(act, act) tp_assign(oact, oact) tp_assign(sigsetsize, sigsetsize)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_rt_sigprocmask
+SC_TRACE_EVENT(sys_rt_sigprocmask,
+       TP_PROTO(int how, sigset_t * nset, sigset_t * oset, size_t sigsetsize),
+       TP_ARGS(how, nset, oset, sigsetsize),
+       TP_STRUCT__entry(__field(int, how) __field_hex(sigset_t *, nset) __field_hex(sigset_t *, oset) __field(size_t, sigsetsize)),
+       TP_fast_assign(tp_assign(how, how) tp_assign(nset, nset) tp_assign(oset, oset) tp_assign(sigsetsize, sigsetsize)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_rt_sigtimedwait
+SC_TRACE_EVENT(sys_rt_sigtimedwait,
+       TP_PROTO(const sigset_t * uthese, siginfo_t * uinfo, const struct timespec * uts, size_t sigsetsize),
+       TP_ARGS(uthese, uinfo, uts, sigsetsize),
+       TP_STRUCT__entry(__field_hex(const sigset_t *, uthese) __field_hex(siginfo_t *, uinfo) __field_hex(const struct timespec *, uts) __field(size_t, sigsetsize)),
+       TP_fast_assign(tp_assign(uthese, uthese) tp_assign(uinfo, uinfo) tp_assign(uts, uts) tp_assign(sigsetsize, sigsetsize)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_sendfile
+SC_TRACE_EVENT(sys_sendfile,
+       TP_PROTO(int out_fd, int in_fd, off_t * offset, size_t count),
+       TP_ARGS(out_fd, in_fd, offset, count),
+       TP_STRUCT__entry(__field(int, out_fd) __field(int, in_fd) __field_hex(off_t *, offset) __field(size_t, count)),
+       TP_fast_assign(tp_assign(out_fd, out_fd) tp_assign(in_fd, in_fd) tp_assign(offset, offset) tp_assign(count, count)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_getxattr
+SC_TRACE_EVENT(sys_getxattr,
+       TP_PROTO(const char * pathname, const char * name, void * value, size_t size),
+       TP_ARGS(pathname, name, value, size),
+       TP_STRUCT__entry(__string_from_user(pathname, pathname) __string_from_user(name, name) __field_hex(void *, value) __field(size_t, size)),
+       TP_fast_assign(tp_copy_string_from_user(pathname, pathname) tp_copy_string_from_user(name, name) tp_assign(value, value) tp_assign(size, size)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_lgetxattr
+SC_TRACE_EVENT(sys_lgetxattr,
+       TP_PROTO(const char * pathname, const char * name, void * value, size_t size),
+       TP_ARGS(pathname, name, value, size),
+       TP_STRUCT__entry(__string_from_user(pathname, pathname) __string_from_user(name, name) __field_hex(void *, value) __field(size_t, size)),
+       TP_fast_assign(tp_copy_string_from_user(pathname, pathname) tp_copy_string_from_user(name, name) tp_assign(value, value) tp_assign(size, size)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_fgetxattr
+SC_TRACE_EVENT(sys_fgetxattr,
+       TP_PROTO(int fd, const char * name, void * value, size_t size),
+       TP_ARGS(fd, name, value, size),
+       TP_STRUCT__entry(__field(int, fd) __string_from_user(name, name) __field_hex(void *, value) __field(size_t, size)),
+       TP_fast_assign(tp_assign(fd, fd) tp_copy_string_from_user(name, name) tp_assign(value, value) tp_assign(size, size)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_sendfile64
+SC_TRACE_EVENT(sys_sendfile64,
+       TP_PROTO(int out_fd, int in_fd, loff_t * offset, size_t count),
+       TP_ARGS(out_fd, in_fd, offset, count),
+       TP_STRUCT__entry(__field(int, out_fd) __field(int, in_fd) __field_hex(loff_t *, offset) __field(size_t, count)),
+       TP_fast_assign(tp_assign(out_fd, out_fd) tp_assign(in_fd, in_fd) tp_assign(offset, offset) tp_assign(count, count)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_epoll_ctl
+SC_TRACE_EVENT(sys_epoll_ctl,
+       TP_PROTO(int epfd, int op, int fd, struct epoll_event * event),
+       TP_ARGS(epfd, op, fd, event),
+       TP_STRUCT__entry(__field(int, epfd) __field(int, op) __field(int, fd) __field_hex(struct epoll_event *, event)),
+       TP_fast_assign(tp_assign(epfd, epfd) tp_assign(op, op) tp_assign(fd, fd) tp_assign(event, event)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_epoll_wait
+SC_TRACE_EVENT(sys_epoll_wait,
+       TP_PROTO(int epfd, struct epoll_event * events, int maxevents, int timeout),
+       TP_ARGS(epfd, events, maxevents, timeout),
+       TP_STRUCT__entry(__field(int, epfd) __field_hex(struct epoll_event *, events) __field(int, maxevents) __field(int, timeout)),
+       TP_fast_assign(tp_assign(epfd, epfd) tp_assign(events, events) tp_assign(maxevents, maxevents) tp_assign(timeout, timeout)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_timer_settime
+SC_TRACE_EVENT(sys_timer_settime,
+       TP_PROTO(timer_t timer_id, int flags, const struct itimerspec * new_setting, struct itimerspec * old_setting),
+       TP_ARGS(timer_id, flags, new_setting, old_setting),
+       TP_STRUCT__entry(__field(timer_t, timer_id) __field(int, flags) __field_hex(const struct itimerspec *, new_setting) __field_hex(struct itimerspec *, old_setting)),
+       TP_fast_assign(tp_assign(timer_id, timer_id) tp_assign(flags, flags) tp_assign(new_setting, new_setting) tp_assign(old_setting, old_setting)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_clock_nanosleep
+SC_TRACE_EVENT(sys_clock_nanosleep,
+       TP_PROTO(const clockid_t which_clock, int flags, const struct timespec * rqtp, struct timespec * rmtp),
+       TP_ARGS(which_clock, flags, rqtp, rmtp),
+       TP_STRUCT__entry(__field(const clockid_t, which_clock) __field(int, flags) __field_hex(const struct timespec *, rqtp) __field_hex(struct timespec *, rmtp)),
+       TP_fast_assign(tp_assign(which_clock, which_clock) tp_assign(flags, flags) tp_assign(rqtp, rqtp) tp_assign(rmtp, rmtp)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_mq_open
+SC_TRACE_EVENT(sys_mq_open,
+       TP_PROTO(const char * u_name, int oflag, mode_t mode, struct mq_attr * u_attr),
+       TP_ARGS(u_name, oflag, mode, u_attr),
+       TP_STRUCT__entry(__string_from_user(u_name, u_name) __field(int, oflag) __field(mode_t, mode) __field_hex(struct mq_attr *, u_attr)),
+       TP_fast_assign(tp_copy_string_from_user(u_name, u_name) tp_assign(oflag, oflag) tp_assign(mode, mode) tp_assign(u_attr, u_attr)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_kexec_load
+SC_TRACE_EVENT(sys_kexec_load,
+       TP_PROTO(unsigned long entry, unsigned long nr_segments, struct kexec_segment * segments, unsigned long flags),
+       TP_ARGS(entry, nr_segments, segments, flags),
+       TP_STRUCT__entry(__field(unsigned long, entry) __field(unsigned long, nr_segments) __field_hex(struct kexec_segment *, segments) __field(unsigned long, flags)),
+       TP_fast_assign(tp_assign(entry, entry) tp_assign(nr_segments, nr_segments) tp_assign(segments, segments) tp_assign(flags, flags)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_request_key
+SC_TRACE_EVENT(sys_request_key,
+       TP_PROTO(const char * _type, const char * _description, const char * _callout_info, key_serial_t destringid),
+       TP_ARGS(_type, _description, _callout_info, destringid),
+       TP_STRUCT__entry(__string_from_user(_type, _type) __field_hex(const char *, _description) __field_hex(const char *, _callout_info) __field(key_serial_t, destringid)),
+       TP_fast_assign(tp_copy_string_from_user(_type, _type) tp_assign(_description, _description) tp_assign(_callout_info, _callout_info) tp_assign(destringid, destringid)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_openat
+SC_TRACE_EVENT(sys_openat,
+       TP_PROTO(int dfd, const char * filename, int flags, int mode),
+       TP_ARGS(dfd, filename, flags, mode),
+       TP_STRUCT__entry(__field(int, dfd) __string_from_user(filename, filename) __field(int, flags) __field(int, mode)),
+       TP_fast_assign(tp_assign(dfd, dfd) tp_copy_string_from_user(filename, filename) tp_assign(flags, flags) tp_assign(mode, mode)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_mknodat
+SC_TRACE_EVENT(sys_mknodat,
+       TP_PROTO(int dfd, const char * filename, int mode, unsigned dev),
+       TP_ARGS(dfd, filename, mode, dev),
+       TP_STRUCT__entry(__field(int, dfd) __string_from_user(filename, filename) __field(int, mode) __field(unsigned, dev)),
+       TP_fast_assign(tp_assign(dfd, dfd) tp_copy_string_from_user(filename, filename) tp_assign(mode, mode) tp_assign(dev, dev)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_fstatat64
+SC_TRACE_EVENT(sys_fstatat64,
+       TP_PROTO(int dfd, const char * filename, struct stat64 * statbuf, int flag),
+       TP_ARGS(dfd, filename, statbuf, flag),
+       TP_STRUCT__entry(__field(int, dfd) __string_from_user(filename, filename) __field_hex(struct stat64 *, statbuf) __field(int, flag)),
+       TP_fast_assign(tp_assign(dfd, dfd) tp_copy_string_from_user(filename, filename) tp_assign(statbuf, statbuf) tp_assign(flag, flag)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_renameat
+SC_TRACE_EVENT(sys_renameat,
+       TP_PROTO(int olddfd, const char * oldname, int newdfd, const char * newname),
+       TP_ARGS(olddfd, oldname, newdfd, newname),
+       TP_STRUCT__entry(__field(int, olddfd) __string_from_user(oldname, oldname) __field(int, newdfd) __string_from_user(newname, newname)),
+       TP_fast_assign(tp_assign(olddfd, olddfd) tp_copy_string_from_user(oldname, oldname) tp_assign(newdfd, newdfd) tp_copy_string_from_user(newname, newname)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_readlinkat
+SC_TRACE_EVENT(sys_readlinkat,
+       TP_PROTO(int dfd, const char * pathname, char * buf, int bufsiz),
+       TP_ARGS(dfd, pathname, buf, bufsiz),
+       TP_STRUCT__entry(__field(int, dfd) __string_from_user(pathname, pathname) __field_hex(char *, buf) __field(int, bufsiz)),
+       TP_fast_assign(tp_assign(dfd, dfd) tp_copy_string_from_user(pathname, pathname) tp_assign(buf, buf) tp_assign(bufsiz, bufsiz)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_vmsplice
+SC_TRACE_EVENT(sys_vmsplice,
+       TP_PROTO(int fd, const struct iovec * iov, unsigned long nr_segs, unsigned int flags),
+       TP_ARGS(fd, iov, nr_segs, flags),
+       TP_STRUCT__entry(__field(int, fd) __field_hex(const struct iovec *, iov) __field(unsigned long, nr_segs) __field(unsigned int, flags)),
+       TP_fast_assign(tp_assign(fd, fd) tp_assign(iov, iov) tp_assign(nr_segs, nr_segs) tp_assign(flags, flags)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_utimensat
+SC_TRACE_EVENT(sys_utimensat,
+       TP_PROTO(int dfd, const char * filename, struct timespec * utimes, int flags),
+       TP_ARGS(dfd, filename, utimes, flags),
+       TP_STRUCT__entry(__field(int, dfd) __string_from_user(filename, filename) __field_hex(struct timespec *, utimes) __field(int, flags)),
+       TP_fast_assign(tp_assign(dfd, dfd) tp_copy_string_from_user(filename, filename) tp_assign(utimes, utimes) tp_assign(flags, flags)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_timerfd_settime
+SC_TRACE_EVENT(sys_timerfd_settime,
+       TP_PROTO(int ufd, int flags, const struct itimerspec * utmr, struct itimerspec * otmr),
+       TP_ARGS(ufd, flags, utmr, otmr),
+       TP_STRUCT__entry(__field(int, ufd) __field(int, flags) __field_hex(const struct itimerspec *, utmr) __field_hex(struct itimerspec *, otmr)),
+       TP_fast_assign(tp_assign(ufd, ufd) tp_assign(flags, flags) tp_assign(utmr, utmr) tp_assign(otmr, otmr)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_signalfd4
+SC_TRACE_EVENT(sys_signalfd4,
+       TP_PROTO(int ufd, sigset_t * user_mask, size_t sizemask, int flags),
+       TP_ARGS(ufd, user_mask, sizemask, flags),
+       TP_STRUCT__entry(__field(int, ufd) __field_hex(sigset_t *, user_mask) __field(size_t, sizemask) __field(int, flags)),
+       TP_fast_assign(tp_assign(ufd, ufd) tp_assign(user_mask, user_mask) tp_assign(sizemask, sizemask) tp_assign(flags, flags)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_rt_tgsigqueueinfo
+SC_TRACE_EVENT(sys_rt_tgsigqueueinfo,
+       TP_PROTO(pid_t tgid, pid_t pid, int sig, siginfo_t * uinfo),
+       TP_ARGS(tgid, pid, sig, uinfo),
+       TP_STRUCT__entry(__field(pid_t, tgid) __field(pid_t, pid) __field(int, sig) __field_hex(siginfo_t *, uinfo)),
+       TP_fast_assign(tp_assign(tgid, tgid) tp_assign(pid, pid) tp_assign(sig, sig) tp_assign(uinfo, uinfo)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_prlimit64
+SC_TRACE_EVENT(sys_prlimit64,
+       TP_PROTO(pid_t pid, unsigned int resource, const struct rlimit64 * new_rlim, struct rlimit64 * old_rlim),
+       TP_ARGS(pid, resource, new_rlim, old_rlim),
+       TP_STRUCT__entry(__field(pid_t, pid) __field(unsigned int, resource) __field_hex(const struct rlimit64 *, new_rlim) __field_hex(struct rlimit64 *, old_rlim)),
+       TP_fast_assign(tp_assign(pid, pid) tp_assign(resource, resource) tp_assign(new_rlim, new_rlim) tp_assign(old_rlim, old_rlim)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_sendmmsg
+SC_TRACE_EVENT(sys_sendmmsg,
+       TP_PROTO(int fd, struct mmsghdr * mmsg, unsigned int vlen, unsigned int flags),
+       TP_ARGS(fd, mmsg, vlen, flags),
+       TP_STRUCT__entry(__field(int, fd) __field_hex(struct mmsghdr *, mmsg) __field(unsigned int, vlen) __field(unsigned int, flags)),
+       TP_fast_assign(tp_assign(fd, fd) tp_assign(mmsg, mmsg) tp_assign(vlen, vlen) tp_assign(flags, flags)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_mount
+SC_TRACE_EVENT(sys_mount,
+       TP_PROTO(char * dev_name, char * dir_name, char * type, unsigned long flags, void * data),
+       TP_ARGS(dev_name, dir_name, type, flags, data),
+       TP_STRUCT__entry(__string_from_user(dev_name, dev_name) __string_from_user(dir_name, dir_name) __string_from_user(type, type) __field(unsigned long, flags) __field_hex(void *, data)),
+       TP_fast_assign(tp_copy_string_from_user(dev_name, dev_name) tp_copy_string_from_user(dir_name, dir_name) tp_copy_string_from_user(type, type) tp_assign(flags, flags) tp_assign(data, data)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_llseek
+SC_TRACE_EVENT(sys_llseek,
+       TP_PROTO(unsigned int fd, unsigned long offset_high, unsigned long offset_low, loff_t * result, unsigned int origin),
+       TP_ARGS(fd, offset_high, offset_low, result, origin),
+       TP_STRUCT__entry(__field(unsigned int, fd) __field(unsigned long, offset_high) __field(unsigned long, offset_low) __field_hex(loff_t *, result) __field(unsigned int, origin)),
+       TP_fast_assign(tp_assign(fd, fd) tp_assign(offset_high, offset_high) tp_assign(offset_low, offset_low) tp_assign(result, result) tp_assign(origin, origin)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_select
+SC_TRACE_EVENT(sys_select,
+       TP_PROTO(int n, fd_set * inp, fd_set * outp, fd_set * exp, struct timeval * tvp),
+       TP_ARGS(n, inp, outp, exp, tvp),
+       TP_STRUCT__entry(__field(int, n) __field_hex(fd_set *, inp) __field_hex(fd_set *, outp) __field_hex(fd_set *, exp) __field_hex(struct timeval *, tvp)),
+       TP_fast_assign(tp_assign(n, n) tp_assign(inp, inp) tp_assign(outp, outp) tp_assign(exp, exp) tp_assign(tvp, tvp)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_setxattr
+SC_TRACE_EVENT(sys_setxattr,
+       TP_PROTO(const char * pathname, const char * name, const void * value, size_t size, int flags),
+       TP_ARGS(pathname, name, value, size, flags),
+       TP_STRUCT__entry(__string_from_user(pathname, pathname) __string_from_user(name, name) __field_hex(const void *, value) __field(size_t, size) __field(int, flags)),
+       TP_fast_assign(tp_copy_string_from_user(pathname, pathname) tp_copy_string_from_user(name, name) tp_assign(value, value) tp_assign(size, size) tp_assign(flags, flags)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_lsetxattr
+SC_TRACE_EVENT(sys_lsetxattr,
+       TP_PROTO(const char * pathname, const char * name, const void * value, size_t size, int flags),
+       TP_ARGS(pathname, name, value, size, flags),
+       TP_STRUCT__entry(__string_from_user(pathname, pathname) __string_from_user(name, name) __field_hex(const void *, value) __field(size_t, size) __field(int, flags)),
+       TP_fast_assign(tp_copy_string_from_user(pathname, pathname) tp_copy_string_from_user(name, name) tp_assign(value, value) tp_assign(size, size) tp_assign(flags, flags)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_fsetxattr
+SC_TRACE_EVENT(sys_fsetxattr,
+       TP_PROTO(int fd, const char * name, const void * value, size_t size, int flags),
+       TP_ARGS(fd, name, value, size, flags),
+       TP_STRUCT__entry(__field(int, fd) __string_from_user(name, name) __field_hex(const void *, value) __field(size_t, size) __field(int, flags)),
+       TP_fast_assign(tp_assign(fd, fd) tp_copy_string_from_user(name, name) tp_assign(value, value) tp_assign(size, size) tp_assign(flags, flags)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_io_getevents
+SC_TRACE_EVENT(sys_io_getevents,
+       TP_PROTO(aio_context_t ctx_id, long min_nr, long nr, struct io_event * events, struct timespec * timeout),
+       TP_ARGS(ctx_id, min_nr, nr, events, timeout),
+       TP_STRUCT__entry(__field(aio_context_t, ctx_id) __field(long, min_nr) __field(long, nr) __field_hex(struct io_event *, events) __field_hex(struct timespec *, timeout)),
+       TP_fast_assign(tp_assign(ctx_id, ctx_id) tp_assign(min_nr, min_nr) tp_assign(nr, nr) tp_assign(events, events) tp_assign(timeout, timeout)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_mq_timedsend
+SC_TRACE_EVENT(sys_mq_timedsend,
+       TP_PROTO(mqd_t mqdes, const char * u_msg_ptr, size_t msg_len, unsigned int msg_prio, const struct timespec * u_abs_timeout),
+       TP_ARGS(mqdes, u_msg_ptr, msg_len, msg_prio, u_abs_timeout),
+       TP_STRUCT__entry(__field(mqd_t, mqdes) __field_hex(const char *, u_msg_ptr) __field(size_t, msg_len) __field(unsigned int, msg_prio) __field_hex(const struct timespec *, u_abs_timeout)),
+       TP_fast_assign(tp_assign(mqdes, mqdes) tp_assign(u_msg_ptr, u_msg_ptr) tp_assign(msg_len, msg_len) tp_assign(msg_prio, msg_prio) tp_assign(u_abs_timeout, u_abs_timeout)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_mq_timedreceive
+SC_TRACE_EVENT(sys_mq_timedreceive,
+       TP_PROTO(mqd_t mqdes, char * u_msg_ptr, size_t msg_len, unsigned int * u_msg_prio, const struct timespec * u_abs_timeout),
+       TP_ARGS(mqdes, u_msg_ptr, msg_len, u_msg_prio, u_abs_timeout),
+       TP_STRUCT__entry(__field(mqd_t, mqdes) __field_hex(char *, u_msg_ptr) __field(size_t, msg_len) __field_hex(unsigned int *, u_msg_prio) __field_hex(const struct timespec *, u_abs_timeout)),
+       TP_fast_assign(tp_assign(mqdes, mqdes) tp_assign(u_msg_ptr, u_msg_ptr) tp_assign(msg_len, msg_len) tp_assign(u_msg_prio, u_msg_prio) tp_assign(u_abs_timeout, u_abs_timeout)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_waitid
+SC_TRACE_EVENT(sys_waitid,
+       TP_PROTO(int which, pid_t upid, struct siginfo * infop, int options, struct rusage * ru),
+       TP_ARGS(which, upid, infop, options, ru),
+       TP_STRUCT__entry(__field(int, which) __field(pid_t, upid) __field_hex(struct siginfo *, infop) __field(int, options) __field_hex(struct rusage *, ru)),
+       TP_fast_assign(tp_assign(which, which) tp_assign(upid, upid) tp_assign(infop, infop) tp_assign(options, options) tp_assign(ru, ru)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_add_key
+SC_TRACE_EVENT(sys_add_key,
+       TP_PROTO(const char * _type, const char * _description, const void * _payload, size_t plen, key_serial_t ringid),
+       TP_ARGS(_type, _description, _payload, plen, ringid),
+       TP_STRUCT__entry(__string_from_user(_type, _type) __field_hex(const char *, _description) __field_hex(const void *, _payload) __field(size_t, plen) __field(key_serial_t, ringid)),
+       TP_fast_assign(tp_copy_string_from_user(_type, _type) tp_assign(_description, _description) tp_assign(_payload, _payload) tp_assign(plen, plen) tp_assign(ringid, ringid)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_fchownat
+SC_TRACE_EVENT(sys_fchownat,
+       TP_PROTO(int dfd, const char * filename, uid_t user, gid_t group, int flag),
+       TP_ARGS(dfd, filename, user, group, flag),
+       TP_STRUCT__entry(__field(int, dfd) __string_from_user(filename, filename) __field(uid_t, user) __field(gid_t, group) __field(int, flag)),
+       TP_fast_assign(tp_assign(dfd, dfd) tp_copy_string_from_user(filename, filename) tp_assign(user, user) tp_assign(group, group) tp_assign(flag, flag)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_linkat
+SC_TRACE_EVENT(sys_linkat,
+       TP_PROTO(int olddfd, const char * oldname, int newdfd, const char * newname, int flags),
+       TP_ARGS(olddfd, oldname, newdfd, newname, flags),
+       TP_STRUCT__entry(__field(int, olddfd) __string_from_user(oldname, oldname) __field(int, newdfd) __string_from_user(newname, newname) __field(int, flags)),
+       TP_fast_assign(tp_assign(olddfd, olddfd) tp_copy_string_from_user(oldname, oldname) tp_assign(newdfd, newdfd) tp_copy_string_from_user(newname, newname) tp_assign(flags, flags)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_ppoll
+SC_TRACE_EVENT(sys_ppoll,
+       TP_PROTO(struct pollfd * ufds, unsigned int nfds, struct timespec * tsp, const sigset_t * sigmask, size_t sigsetsize),
+       TP_ARGS(ufds, nfds, tsp, sigmask, sigsetsize),
+       TP_STRUCT__entry(__field_hex(struct pollfd *, ufds) __field(unsigned int, nfds) __field_hex(struct timespec *, tsp) __field_hex(const sigset_t *, sigmask) __field(size_t, sigsetsize)),
+       TP_fast_assign(tp_assign(ufds, ufds) tp_assign(nfds, nfds) tp_assign(tsp, tsp) tp_assign(sigmask, sigmask) tp_assign(sigsetsize, sigsetsize)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_preadv
+SC_TRACE_EVENT(sys_preadv,
+       TP_PROTO(unsigned long fd, const struct iovec * vec, unsigned long vlen, unsigned long pos_l, unsigned long pos_h),
+       TP_ARGS(fd, vec, vlen, pos_l, pos_h),
+       TP_STRUCT__entry(__field(unsigned long, fd) __field_hex(const struct iovec *, vec) __field(unsigned long, vlen) __field(unsigned long, pos_l) __field(unsigned long, pos_h)),
+       TP_fast_assign(tp_assign(fd, fd) tp_assign(vec, vec) tp_assign(vlen, vlen) tp_assign(pos_l, pos_l) tp_assign(pos_h, pos_h)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_pwritev
+SC_TRACE_EVENT(sys_pwritev,
+       TP_PROTO(unsigned long fd, const struct iovec * vec, unsigned long vlen, unsigned long pos_l, unsigned long pos_h),
+       TP_ARGS(fd, vec, vlen, pos_l, pos_h),
+       TP_STRUCT__entry(__field(unsigned long, fd) __field_hex(const struct iovec *, vec) __field(unsigned long, vlen) __field(unsigned long, pos_l) __field(unsigned long, pos_h)),
+       TP_fast_assign(tp_assign(fd, fd) tp_assign(vec, vec) tp_assign(vlen, vlen) tp_assign(pos_l, pos_l) tp_assign(pos_h, pos_h)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_perf_event_open
+SC_TRACE_EVENT(sys_perf_event_open,
+       TP_PROTO(struct perf_event_attr * attr_uptr, pid_t pid, int cpu, int group_fd, unsigned long flags),
+       TP_ARGS(attr_uptr, pid, cpu, group_fd, flags),
+       TP_STRUCT__entry(__field_hex(struct perf_event_attr *, attr_uptr) __field(pid_t, pid) __field(int, cpu) __field(int, group_fd) __field(unsigned long, flags)),
+       TP_fast_assign(tp_assign(attr_uptr, attr_uptr) tp_assign(pid, pid) tp_assign(cpu, cpu) tp_assign(group_fd, group_fd) tp_assign(flags, flags)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_recvmmsg
+SC_TRACE_EVENT(sys_recvmmsg,
+       TP_PROTO(int fd, struct mmsghdr * mmsg, unsigned int vlen, unsigned int flags, struct timespec * timeout),
+       TP_ARGS(fd, mmsg, vlen, flags, timeout),
+       TP_STRUCT__entry(__field(int, fd) __field_hex(struct mmsghdr *, mmsg) __field(unsigned int, vlen) __field(unsigned int, flags) __field_hex(struct timespec *, timeout)),
+       TP_fast_assign(tp_assign(fd, fd) tp_assign(mmsg, mmsg) tp_assign(vlen, vlen) tp_assign(flags, flags) tp_assign(timeout, timeout)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_ipc
+SC_TRACE_EVENT(sys_ipc,
+       TP_PROTO(unsigned int call, int first, unsigned long second, unsigned long third, void * ptr, long fifth),
+       TP_ARGS(call, first, second, third, ptr, fifth),
+       TP_STRUCT__entry(__field(unsigned int, call) __field(int, first) __field(unsigned long, second) __field(unsigned long, third) __field_hex(void *, ptr) __field(long, fifth)),
+       TP_fast_assign(tp_assign(call, call) tp_assign(first, first) tp_assign(second, second) tp_assign(third, third) tp_assign(ptr, ptr) tp_assign(fifth, fifth)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_futex
+SC_TRACE_EVENT(sys_futex,
+       TP_PROTO(u32 * uaddr, int op, u32 val, struct timespec * utime, u32 * uaddr2, u32 val3),
+       TP_ARGS(uaddr, op, val, utime, uaddr2, val3),
+       TP_STRUCT__entry(__field_hex(u32 *, uaddr) __field(int, op) __field(u32, val) __field_hex(struct timespec *, utime) __field_hex(u32 *, uaddr2) __field(u32, val3)),
+       TP_fast_assign(tp_assign(uaddr, uaddr) tp_assign(op, op) tp_assign(val, val) tp_assign(utime, utime) tp_assign(uaddr2, uaddr2) tp_assign(val3, val3)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_pselect6
+SC_TRACE_EVENT(sys_pselect6,
+       TP_PROTO(int n, fd_set * inp, fd_set * outp, fd_set * exp, struct timespec * tsp, void * sig),
+       TP_ARGS(n, inp, outp, exp, tsp, sig),
+       TP_STRUCT__entry(__field(int, n) __field_hex(fd_set *, inp) __field_hex(fd_set *, outp) __field_hex(fd_set *, exp) __field_hex(struct timespec *, tsp) __field_hex(void *, sig)),
+       TP_fast_assign(tp_assign(n, n) tp_assign(inp, inp) tp_assign(outp, outp) tp_assign(exp, exp) tp_assign(tsp, tsp) tp_assign(sig, sig)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_splice
+SC_TRACE_EVENT(sys_splice,
+       TP_PROTO(int fd_in, loff_t * off_in, int fd_out, loff_t * off_out, size_t len, unsigned int flags),
+       TP_ARGS(fd_in, off_in, fd_out, off_out, len, flags),
+       TP_STRUCT__entry(__field(int, fd_in) __field_hex(loff_t *, off_in) __field(int, fd_out) __field_hex(loff_t *, off_out) __field(size_t, len) __field(unsigned int, flags)),
+       TP_fast_assign(tp_assign(fd_in, fd_in) tp_assign(off_in, off_in) tp_assign(fd_out, fd_out) tp_assign(off_out, off_out) tp_assign(len, len) tp_assign(flags, flags)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_32_sys_epoll_pwait
+SC_TRACE_EVENT(sys_epoll_pwait,
+       TP_PROTO(int epfd, struct epoll_event * events, int maxevents, int timeout, const sigset_t * sigmask, size_t sigsetsize),
+       TP_ARGS(epfd, events, maxevents, timeout, sigmask, sigsetsize),
+       TP_STRUCT__entry(__field(int, epfd) __field_hex(struct epoll_event *, events) __field(int, maxevents) __field(int, timeout) __field_hex(const sigset_t *, sigmask) __field(size_t, sigsetsize)),
+       TP_fast_assign(tp_assign(epfd, epfd) tp_assign(events, events) tp_assign(maxevents, maxevents) tp_assign(timeout, timeout) tp_assign(sigmask, sigmask) tp_assign(sigsetsize, sigsetsize)),
+       TP_printk()
+)
+#endif
+
+#endif /*  _TRACE_SYSCALLS_POINTERS_H */
+
+/* This part must be outside protection */
+#include "../../../probes/define_trace.h"
+
+#else /* CREATE_SYSCALL_TABLE */
+
+#include "x86-32-syscalls-3.1.0-rc6_pointers_override.h"
+#include "syscalls_pointers_override.h"
+
+#ifndef OVERRIDE_TABLE_32_sys_read
+TRACE_SYSCALL_TABLE(sys_read, sys_read, 3, 3)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_write
+TRACE_SYSCALL_TABLE(sys_write, sys_write, 4, 3)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_open
+TRACE_SYSCALL_TABLE(sys_open, sys_open, 5, 3)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_waitpid
+TRACE_SYSCALL_TABLE(sys_waitpid, sys_waitpid, 7, 3)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_creat
+TRACE_SYSCALL_TABLE(sys_creat, sys_creat, 8, 2)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_link
+TRACE_SYSCALL_TABLE(sys_link, sys_link, 9, 2)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_unlink
+TRACE_SYSCALL_TABLE(sys_unlink, sys_unlink, 10, 1)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_chdir
+TRACE_SYSCALL_TABLE(sys_chdir, sys_chdir, 12, 1)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_time
+TRACE_SYSCALL_TABLE(sys_time, sys_time, 13, 1)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_mknod
+TRACE_SYSCALL_TABLE(sys_mknod, sys_mknod, 14, 3)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_chmod
+TRACE_SYSCALL_TABLE(sys_chmod, sys_chmod, 15, 2)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_lchown16
+TRACE_SYSCALL_TABLE(sys_lchown16, sys_lchown16, 16, 3)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_stat
+TRACE_SYSCALL_TABLE(sys_stat, sys_stat, 18, 2)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_mount
+TRACE_SYSCALL_TABLE(sys_mount, sys_mount, 21, 5)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_oldumount
+TRACE_SYSCALL_TABLE(sys_oldumount, sys_oldumount, 22, 1)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_stime
+TRACE_SYSCALL_TABLE(sys_stime, sys_stime, 25, 1)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_fstat
+TRACE_SYSCALL_TABLE(sys_fstat, sys_fstat, 28, 2)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_utime
+TRACE_SYSCALL_TABLE(sys_utime, sys_utime, 30, 2)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_access
+TRACE_SYSCALL_TABLE(sys_access, sys_access, 33, 2)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_rename
+TRACE_SYSCALL_TABLE(sys_rename, sys_rename, 38, 2)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_mkdir
+TRACE_SYSCALL_TABLE(sys_mkdir, sys_mkdir, 39, 2)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_rmdir
+TRACE_SYSCALL_TABLE(sys_rmdir, sys_rmdir, 40, 1)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_pipe
+TRACE_SYSCALL_TABLE(sys_pipe, sys_pipe, 42, 1)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_times
+TRACE_SYSCALL_TABLE(sys_times, sys_times, 43, 1)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_acct
+TRACE_SYSCALL_TABLE(sys_acct, sys_acct, 51, 1)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_umount
+TRACE_SYSCALL_TABLE(sys_umount, sys_umount, 52, 2)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_olduname
+TRACE_SYSCALL_TABLE(sys_olduname, sys_olduname, 59, 1)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_chroot
+TRACE_SYSCALL_TABLE(sys_chroot, sys_chroot, 61, 1)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_ustat
+TRACE_SYSCALL_TABLE(sys_ustat, sys_ustat, 62, 2)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_sigpending
+TRACE_SYSCALL_TABLE(sys_sigpending, sys_sigpending, 73, 1)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_sethostname
+TRACE_SYSCALL_TABLE(sys_sethostname, sys_sethostname, 74, 2)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_setrlimit
+TRACE_SYSCALL_TABLE(sys_setrlimit, sys_setrlimit, 75, 2)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_old_getrlimit
+TRACE_SYSCALL_TABLE(sys_old_getrlimit, sys_old_getrlimit, 76, 2)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_getrusage
+TRACE_SYSCALL_TABLE(sys_getrusage, sys_getrusage, 77, 2)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_gettimeofday
+TRACE_SYSCALL_TABLE(sys_gettimeofday, sys_gettimeofday, 78, 2)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_settimeofday
+TRACE_SYSCALL_TABLE(sys_settimeofday, sys_settimeofday, 79, 2)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_getgroups16
+TRACE_SYSCALL_TABLE(sys_getgroups16, sys_getgroups16, 80, 2)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_setgroups16
+TRACE_SYSCALL_TABLE(sys_setgroups16, sys_setgroups16, 81, 2)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_old_select
+TRACE_SYSCALL_TABLE(sys_old_select, sys_old_select, 82, 1)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_symlink
+TRACE_SYSCALL_TABLE(sys_symlink, sys_symlink, 83, 2)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_lstat
+TRACE_SYSCALL_TABLE(sys_lstat, sys_lstat, 84, 2)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_readlink
+TRACE_SYSCALL_TABLE(sys_readlink, sys_readlink, 85, 3)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_uselib
+TRACE_SYSCALL_TABLE(sys_uselib, sys_uselib, 86, 1)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_swapon
+TRACE_SYSCALL_TABLE(sys_swapon, sys_swapon, 87, 2)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_reboot
+TRACE_SYSCALL_TABLE(sys_reboot, sys_reboot, 88, 4)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_old_readdir
+TRACE_SYSCALL_TABLE(sys_old_readdir, sys_old_readdir, 89, 3)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_old_mmap
+TRACE_SYSCALL_TABLE(sys_old_mmap, sys_old_mmap, 90, 1)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_truncate
+TRACE_SYSCALL_TABLE(sys_truncate, sys_truncate, 92, 2)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_statfs
+TRACE_SYSCALL_TABLE(sys_statfs, sys_statfs, 99, 2)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_fstatfs
+TRACE_SYSCALL_TABLE(sys_fstatfs, sys_fstatfs, 100, 2)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_socketcall
+TRACE_SYSCALL_TABLE(sys_socketcall, sys_socketcall, 102, 2)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_syslog
+TRACE_SYSCALL_TABLE(sys_syslog, sys_syslog, 103, 3)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_setitimer
+TRACE_SYSCALL_TABLE(sys_setitimer, sys_setitimer, 104, 3)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_getitimer
+TRACE_SYSCALL_TABLE(sys_getitimer, sys_getitimer, 105, 2)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_newstat
+TRACE_SYSCALL_TABLE(sys_newstat, sys_newstat, 106, 2)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_newlstat
+TRACE_SYSCALL_TABLE(sys_newlstat, sys_newlstat, 107, 2)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_newfstat
+TRACE_SYSCALL_TABLE(sys_newfstat, sys_newfstat, 108, 2)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_uname
+TRACE_SYSCALL_TABLE(sys_uname, sys_uname, 109, 1)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_wait4
+TRACE_SYSCALL_TABLE(sys_wait4, sys_wait4, 114, 4)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_swapoff
+TRACE_SYSCALL_TABLE(sys_swapoff, sys_swapoff, 115, 1)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_sysinfo
+TRACE_SYSCALL_TABLE(sys_sysinfo, sys_sysinfo, 116, 1)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_ipc
+TRACE_SYSCALL_TABLE(sys_ipc, sys_ipc, 117, 6)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_setdomainname
+TRACE_SYSCALL_TABLE(sys_setdomainname, sys_setdomainname, 121, 2)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_newuname
+TRACE_SYSCALL_TABLE(sys_newuname, sys_newuname, 122, 1)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_adjtimex
+TRACE_SYSCALL_TABLE(sys_adjtimex, sys_adjtimex, 124, 1)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_sigprocmask
+TRACE_SYSCALL_TABLE(sys_sigprocmask, sys_sigprocmask, 126, 3)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_init_module
+TRACE_SYSCALL_TABLE(sys_init_module, sys_init_module, 128, 3)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_delete_module
+TRACE_SYSCALL_TABLE(sys_delete_module, sys_delete_module, 129, 2)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_quotactl
+TRACE_SYSCALL_TABLE(sys_quotactl, sys_quotactl, 131, 4)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_llseek
+TRACE_SYSCALL_TABLE(sys_llseek, sys_llseek, 140, 5)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_getdents
+TRACE_SYSCALL_TABLE(sys_getdents, sys_getdents, 141, 3)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_select
+TRACE_SYSCALL_TABLE(sys_select, sys_select, 142, 5)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_readv
+TRACE_SYSCALL_TABLE(sys_readv, sys_readv, 145, 3)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_writev
+TRACE_SYSCALL_TABLE(sys_writev, sys_writev, 146, 3)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_sysctl
+TRACE_SYSCALL_TABLE(sys_sysctl, sys_sysctl, 149, 1)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_sched_setparam
+TRACE_SYSCALL_TABLE(sys_sched_setparam, sys_sched_setparam, 154, 2)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_sched_getparam
+TRACE_SYSCALL_TABLE(sys_sched_getparam, sys_sched_getparam, 155, 2)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_sched_setscheduler
+TRACE_SYSCALL_TABLE(sys_sched_setscheduler, sys_sched_setscheduler, 156, 3)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_sched_rr_get_interval
+TRACE_SYSCALL_TABLE(sys_sched_rr_get_interval, sys_sched_rr_get_interval, 161, 2)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_nanosleep
+TRACE_SYSCALL_TABLE(sys_nanosleep, sys_nanosleep, 162, 2)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_getresuid16
+TRACE_SYSCALL_TABLE(sys_getresuid16, sys_getresuid16, 165, 3)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_poll
+TRACE_SYSCALL_TABLE(sys_poll, sys_poll, 168, 3)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_getresgid16
+TRACE_SYSCALL_TABLE(sys_getresgid16, sys_getresgid16, 171, 3)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_rt_sigaction
+TRACE_SYSCALL_TABLE(sys_rt_sigaction, sys_rt_sigaction, 174, 4)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_rt_sigprocmask
+TRACE_SYSCALL_TABLE(sys_rt_sigprocmask, sys_rt_sigprocmask, 175, 4)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_rt_sigpending
+TRACE_SYSCALL_TABLE(sys_rt_sigpending, sys_rt_sigpending, 176, 2)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_rt_sigtimedwait
+TRACE_SYSCALL_TABLE(sys_rt_sigtimedwait, sys_rt_sigtimedwait, 177, 4)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_rt_sigqueueinfo
+TRACE_SYSCALL_TABLE(sys_rt_sigqueueinfo, sys_rt_sigqueueinfo, 178, 3)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_rt_sigsuspend
+TRACE_SYSCALL_TABLE(sys_rt_sigsuspend, sys_rt_sigsuspend, 179, 2)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_chown16
+TRACE_SYSCALL_TABLE(sys_chown16, sys_chown16, 182, 3)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_getcwd
+TRACE_SYSCALL_TABLE(sys_getcwd, sys_getcwd, 183, 2)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_sendfile
+TRACE_SYSCALL_TABLE(sys_sendfile, sys_sendfile, 187, 4)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_getrlimit
+TRACE_SYSCALL_TABLE(sys_getrlimit, sys_getrlimit, 191, 2)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_stat64
+TRACE_SYSCALL_TABLE(sys_stat64, sys_stat64, 195, 2)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_lstat64
+TRACE_SYSCALL_TABLE(sys_lstat64, sys_lstat64, 196, 2)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_fstat64
+TRACE_SYSCALL_TABLE(sys_fstat64, sys_fstat64, 197, 2)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_lchown
+TRACE_SYSCALL_TABLE(sys_lchown, sys_lchown, 198, 3)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_getgroups
+TRACE_SYSCALL_TABLE(sys_getgroups, sys_getgroups, 205, 2)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_setgroups
+TRACE_SYSCALL_TABLE(sys_setgroups, sys_setgroups, 206, 2)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_getresuid
+TRACE_SYSCALL_TABLE(sys_getresuid, sys_getresuid, 209, 3)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_getresgid
+TRACE_SYSCALL_TABLE(sys_getresgid, sys_getresgid, 211, 3)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_chown
+TRACE_SYSCALL_TABLE(sys_chown, sys_chown, 212, 3)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_pivot_root
+TRACE_SYSCALL_TABLE(sys_pivot_root, sys_pivot_root, 217, 2)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_mincore
+TRACE_SYSCALL_TABLE(sys_mincore, sys_mincore, 218, 3)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_getdents64
+TRACE_SYSCALL_TABLE(sys_getdents64, sys_getdents64, 220, 3)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_setxattr
+TRACE_SYSCALL_TABLE(sys_setxattr, sys_setxattr, 226, 5)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_lsetxattr
+TRACE_SYSCALL_TABLE(sys_lsetxattr, sys_lsetxattr, 227, 5)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_fsetxattr
+TRACE_SYSCALL_TABLE(sys_fsetxattr, sys_fsetxattr, 228, 5)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_getxattr
+TRACE_SYSCALL_TABLE(sys_getxattr, sys_getxattr, 229, 4)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_lgetxattr
+TRACE_SYSCALL_TABLE(sys_lgetxattr, sys_lgetxattr, 230, 4)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_fgetxattr
+TRACE_SYSCALL_TABLE(sys_fgetxattr, sys_fgetxattr, 231, 4)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_listxattr
+TRACE_SYSCALL_TABLE(sys_listxattr, sys_listxattr, 232, 3)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_llistxattr
+TRACE_SYSCALL_TABLE(sys_llistxattr, sys_llistxattr, 233, 3)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_flistxattr
+TRACE_SYSCALL_TABLE(sys_flistxattr, sys_flistxattr, 234, 3)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_removexattr
+TRACE_SYSCALL_TABLE(sys_removexattr, sys_removexattr, 235, 2)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_lremovexattr
+TRACE_SYSCALL_TABLE(sys_lremovexattr, sys_lremovexattr, 236, 2)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_fremovexattr
+TRACE_SYSCALL_TABLE(sys_fremovexattr, sys_fremovexattr, 237, 2)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_sendfile64
+TRACE_SYSCALL_TABLE(sys_sendfile64, sys_sendfile64, 239, 4)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_futex
+TRACE_SYSCALL_TABLE(sys_futex, sys_futex, 240, 6)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_sched_setaffinity
+TRACE_SYSCALL_TABLE(sys_sched_setaffinity, sys_sched_setaffinity, 241, 3)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_sched_getaffinity
+TRACE_SYSCALL_TABLE(sys_sched_getaffinity, sys_sched_getaffinity, 242, 3)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_io_setup
+TRACE_SYSCALL_TABLE(sys_io_setup, sys_io_setup, 245, 2)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_io_getevents
+TRACE_SYSCALL_TABLE(sys_io_getevents, sys_io_getevents, 247, 5)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_io_submit
+TRACE_SYSCALL_TABLE(sys_io_submit, sys_io_submit, 248, 3)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_io_cancel
+TRACE_SYSCALL_TABLE(sys_io_cancel, sys_io_cancel, 249, 3)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_epoll_ctl
+TRACE_SYSCALL_TABLE(sys_epoll_ctl, sys_epoll_ctl, 255, 4)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_epoll_wait
+TRACE_SYSCALL_TABLE(sys_epoll_wait, sys_epoll_wait, 256, 4)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_set_tid_address
+TRACE_SYSCALL_TABLE(sys_set_tid_address, sys_set_tid_address, 258, 1)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_timer_create
+TRACE_SYSCALL_TABLE(sys_timer_create, sys_timer_create, 259, 3)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_timer_settime
+TRACE_SYSCALL_TABLE(sys_timer_settime, sys_timer_settime, 260, 4)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_timer_gettime
+TRACE_SYSCALL_TABLE(sys_timer_gettime, sys_timer_gettime, 261, 2)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_clock_settime
+TRACE_SYSCALL_TABLE(sys_clock_settime, sys_clock_settime, 264, 2)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_clock_gettime
+TRACE_SYSCALL_TABLE(sys_clock_gettime, sys_clock_gettime, 265, 2)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_clock_getres
+TRACE_SYSCALL_TABLE(sys_clock_getres, sys_clock_getres, 266, 2)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_clock_nanosleep
+TRACE_SYSCALL_TABLE(sys_clock_nanosleep, sys_clock_nanosleep, 267, 4)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_statfs64
+TRACE_SYSCALL_TABLE(sys_statfs64, sys_statfs64, 268, 3)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_fstatfs64
+TRACE_SYSCALL_TABLE(sys_fstatfs64, sys_fstatfs64, 269, 3)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_utimes
+TRACE_SYSCALL_TABLE(sys_utimes, sys_utimes, 271, 2)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_mq_open
+TRACE_SYSCALL_TABLE(sys_mq_open, sys_mq_open, 277, 4)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_mq_unlink
+TRACE_SYSCALL_TABLE(sys_mq_unlink, sys_mq_unlink, 278, 1)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_mq_timedsend
+TRACE_SYSCALL_TABLE(sys_mq_timedsend, sys_mq_timedsend, 279, 5)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_mq_timedreceive
+TRACE_SYSCALL_TABLE(sys_mq_timedreceive, sys_mq_timedreceive, 280, 5)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_mq_notify
+TRACE_SYSCALL_TABLE(sys_mq_notify, sys_mq_notify, 281, 2)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_mq_getsetattr
+TRACE_SYSCALL_TABLE(sys_mq_getsetattr, sys_mq_getsetattr, 282, 3)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_kexec_load
+TRACE_SYSCALL_TABLE(sys_kexec_load, sys_kexec_load, 283, 4)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_waitid
+TRACE_SYSCALL_TABLE(sys_waitid, sys_waitid, 284, 5)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_add_key
+TRACE_SYSCALL_TABLE(sys_add_key, sys_add_key, 286, 5)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_request_key
+TRACE_SYSCALL_TABLE(sys_request_key, sys_request_key, 287, 4)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_inotify_add_watch
+TRACE_SYSCALL_TABLE(sys_inotify_add_watch, sys_inotify_add_watch, 292, 3)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_openat
+TRACE_SYSCALL_TABLE(sys_openat, sys_openat, 295, 4)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_mkdirat
+TRACE_SYSCALL_TABLE(sys_mkdirat, sys_mkdirat, 296, 3)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_mknodat
+TRACE_SYSCALL_TABLE(sys_mknodat, sys_mknodat, 297, 4)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_fchownat
+TRACE_SYSCALL_TABLE(sys_fchownat, sys_fchownat, 298, 5)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_futimesat
+TRACE_SYSCALL_TABLE(sys_futimesat, sys_futimesat, 299, 3)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_fstatat64
+TRACE_SYSCALL_TABLE(sys_fstatat64, sys_fstatat64, 300, 4)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_unlinkat
+TRACE_SYSCALL_TABLE(sys_unlinkat, sys_unlinkat, 301, 3)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_renameat
+TRACE_SYSCALL_TABLE(sys_renameat, sys_renameat, 302, 4)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_linkat
+TRACE_SYSCALL_TABLE(sys_linkat, sys_linkat, 303, 5)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_symlinkat
+TRACE_SYSCALL_TABLE(sys_symlinkat, sys_symlinkat, 304, 3)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_readlinkat
+TRACE_SYSCALL_TABLE(sys_readlinkat, sys_readlinkat, 305, 4)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_fchmodat
+TRACE_SYSCALL_TABLE(sys_fchmodat, sys_fchmodat, 306, 3)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_faccessat
+TRACE_SYSCALL_TABLE(sys_faccessat, sys_faccessat, 307, 3)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_pselect6
+TRACE_SYSCALL_TABLE(sys_pselect6, sys_pselect6, 308, 6)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_ppoll
+TRACE_SYSCALL_TABLE(sys_ppoll, sys_ppoll, 309, 5)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_set_robust_list
+TRACE_SYSCALL_TABLE(sys_set_robust_list, sys_set_robust_list, 311, 2)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_get_robust_list
+TRACE_SYSCALL_TABLE(sys_get_robust_list, sys_get_robust_list, 312, 3)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_splice
+TRACE_SYSCALL_TABLE(sys_splice, sys_splice, 313, 6)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_vmsplice
+TRACE_SYSCALL_TABLE(sys_vmsplice, sys_vmsplice, 316, 4)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_getcpu
+TRACE_SYSCALL_TABLE(sys_getcpu, sys_getcpu, 318, 3)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_epoll_pwait
+TRACE_SYSCALL_TABLE(sys_epoll_pwait, sys_epoll_pwait, 319, 6)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_utimensat
+TRACE_SYSCALL_TABLE(sys_utimensat, sys_utimensat, 320, 4)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_signalfd
+TRACE_SYSCALL_TABLE(sys_signalfd, sys_signalfd, 321, 3)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_timerfd_settime
+TRACE_SYSCALL_TABLE(sys_timerfd_settime, sys_timerfd_settime, 325, 4)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_timerfd_gettime
+TRACE_SYSCALL_TABLE(sys_timerfd_gettime, sys_timerfd_gettime, 326, 2)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_signalfd4
+TRACE_SYSCALL_TABLE(sys_signalfd4, sys_signalfd4, 327, 4)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_pipe2
+TRACE_SYSCALL_TABLE(sys_pipe2, sys_pipe2, 331, 2)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_preadv
+TRACE_SYSCALL_TABLE(sys_preadv, sys_preadv, 333, 5)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_pwritev
+TRACE_SYSCALL_TABLE(sys_pwritev, sys_pwritev, 334, 5)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_rt_tgsigqueueinfo
+TRACE_SYSCALL_TABLE(sys_rt_tgsigqueueinfo, sys_rt_tgsigqueueinfo, 335, 4)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_perf_event_open
+TRACE_SYSCALL_TABLE(sys_perf_event_open, sys_perf_event_open, 336, 5)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_recvmmsg
+TRACE_SYSCALL_TABLE(sys_recvmmsg, sys_recvmmsg, 337, 5)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_prlimit64
+TRACE_SYSCALL_TABLE(sys_prlimit64, sys_prlimit64, 340, 4)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_clock_adjtime
+TRACE_SYSCALL_TABLE(sys_clock_adjtime, sys_clock_adjtime, 343, 2)
+#endif
+#ifndef OVERRIDE_TABLE_32_sys_sendmmsg
+TRACE_SYSCALL_TABLE(sys_sendmmsg, sys_sendmmsg, 345, 4)
+#endif
+
+#endif /* CREATE_SYSCALL_TABLE */
diff --git a/drivers/staging/lttng/instrumentation/syscalls/headers/x86-32-syscalls-3.1.0-rc6_pointers_override.h b/drivers/staging/lttng/instrumentation/syscalls/headers/x86-32-syscalls-3.1.0-rc6_pointers_override.h
new file mode 100644 (file)
index 0000000..4ee3ca3
--- /dev/null
@@ -0,0 +1,33 @@
+
+#ifndef CREATE_SYSCALL_TABLE
+
+# ifndef CONFIG_UID16
+#  define OVERRIDE_32_sys_getgroups16
+#  define OVERRIDE_32_sys_setgroups16
+#  define OVERRIDE_32_sys_lchown16
+#  define OVERRIDE_32_sys_getresuid16
+#  define OVERRIDE_32_sys_getresgid16
+#  define OVERRIDE_32_sys_chown16
+# endif
+
+#else  /* CREATE_SYSCALL_TABLE */
+
+# ifndef CONFIG_UID16
+#  define OVERRIDE_TABLE_32_sys_getgroups16
+#  define OVERRIDE_TABLE_32_sys_setgroups16
+#  define OVERRIDE_TABLE_32_sys_lchown16
+#  define OVERRIDE_TABLE_32_sys_getresuid16
+#  define OVERRIDE_TABLE_32_sys_getresgid16
+#  define OVERRIDE_TABLE_32_sys_chown16
+# endif
+
+#define OVERRIDE_TABLE_32_sys_execve
+TRACE_SYSCALL_TABLE(sys_execve, sys_execve, 11, 3)
+#define OVERRIDE_TABLE_32_sys_clone
+TRACE_SYSCALL_TABLE(sys_clone, sys_clone, 120, 5)
+#define OVERRIDE_TABLE_32_sys_getcpu
+TRACE_SYSCALL_TABLE(sys_getcpu, sys_getcpu, 318, 3)
+
+#endif /* CREATE_SYSCALL_TABLE */
+
+
diff --git a/drivers/staging/lttng/instrumentation/syscalls/headers/x86-64-syscalls-3.10.0-rc7_integers.h b/drivers/staging/lttng/instrumentation/syscalls/headers/x86-64-syscalls-3.10.0-rc7_integers.h
new file mode 100644 (file)
index 0000000..ccef058
--- /dev/null
@@ -0,0 +1,1097 @@
+/* THIS FILE IS AUTO-GENERATED. DO NOT EDIT */
+#ifndef CREATE_SYSCALL_TABLE
+
+#if !defined(_TRACE_SYSCALLS_INTEGERS_H) || defined(TRACE_HEADER_MULTI_READ)
+#define _TRACE_SYSCALLS_INTEGERS_H
+
+#include <linux/tracepoint.h>
+#include <linux/syscalls.h>
+#include "x86-64-syscalls-3.10.0-rc7_integers_override.h"
+#include "syscalls_integers_override.h"
+
+SC_DECLARE_EVENT_CLASS_NOARGS(syscalls_noargs,
+       TP_STRUCT__entry(),
+       TP_fast_assign(),
+       TP_printk()
+)
+#ifndef OVERRIDE_64_sys_sched_yield
+SC_DEFINE_EVENT_NOARGS(syscalls_noargs, sys_sched_yield)
+#endif
+#ifndef OVERRIDE_64_sys_pause
+SC_DEFINE_EVENT_NOARGS(syscalls_noargs, sys_pause)
+#endif
+#ifndef OVERRIDE_64_sys_getpid
+SC_DEFINE_EVENT_NOARGS(syscalls_noargs, sys_getpid)
+#endif
+#ifndef OVERRIDE_64_sys_getuid
+SC_DEFINE_EVENT_NOARGS(syscalls_noargs, sys_getuid)
+#endif
+#ifndef OVERRIDE_64_sys_getgid
+SC_DEFINE_EVENT_NOARGS(syscalls_noargs, sys_getgid)
+#endif
+#ifndef OVERRIDE_64_sys_geteuid
+SC_DEFINE_EVENT_NOARGS(syscalls_noargs, sys_geteuid)
+#endif
+#ifndef OVERRIDE_64_sys_getegid
+SC_DEFINE_EVENT_NOARGS(syscalls_noargs, sys_getegid)
+#endif
+#ifndef OVERRIDE_64_sys_getppid
+SC_DEFINE_EVENT_NOARGS(syscalls_noargs, sys_getppid)
+#endif
+#ifndef OVERRIDE_64_sys_getpgrp
+SC_DEFINE_EVENT_NOARGS(syscalls_noargs, sys_getpgrp)
+#endif
+#ifndef OVERRIDE_64_sys_setsid
+SC_DEFINE_EVENT_NOARGS(syscalls_noargs, sys_setsid)
+#endif
+#ifndef OVERRIDE_64_sys_munlockall
+SC_DEFINE_EVENT_NOARGS(syscalls_noargs, sys_munlockall)
+#endif
+#ifndef OVERRIDE_64_sys_vhangup
+SC_DEFINE_EVENT_NOARGS(syscalls_noargs, sys_vhangup)
+#endif
+#ifndef OVERRIDE_64_sys_sync
+SC_DEFINE_EVENT_NOARGS(syscalls_noargs, sys_sync)
+#endif
+#ifndef OVERRIDE_64_sys_gettid
+SC_DEFINE_EVENT_NOARGS(syscalls_noargs, sys_gettid)
+#endif
+#ifndef OVERRIDE_64_sys_restart_syscall
+SC_DEFINE_EVENT_NOARGS(syscalls_noargs, sys_restart_syscall)
+#endif
+#ifndef OVERRIDE_64_sys_inotify_init
+SC_DEFINE_EVENT_NOARGS(syscalls_noargs, sys_inotify_init)
+#endif
+#ifndef OVERRIDE_64_sys_close
+SC_TRACE_EVENT(sys_close,
+       TP_PROTO(unsigned int fd),
+       TP_ARGS(fd),
+       TP_STRUCT__entry(__field(unsigned int, fd)),
+       TP_fast_assign(tp_assign(fd, fd)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_64_sys_brk
+SC_TRACE_EVENT(sys_brk,
+       TP_PROTO(unsigned long brk),
+       TP_ARGS(brk),
+       TP_STRUCT__entry(__field(unsigned long, brk)),
+       TP_fast_assign(tp_assign(brk, brk)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_64_sys_dup
+SC_TRACE_EVENT(sys_dup,
+       TP_PROTO(unsigned int fildes),
+       TP_ARGS(fildes),
+       TP_STRUCT__entry(__field(unsigned int, fildes)),
+       TP_fast_assign(tp_assign(fildes, fildes)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_64_sys_alarm
+SC_TRACE_EVENT(sys_alarm,
+       TP_PROTO(unsigned int seconds),
+       TP_ARGS(seconds),
+       TP_STRUCT__entry(__field(unsigned int, seconds)),
+       TP_fast_assign(tp_assign(seconds, seconds)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_64_sys_exit
+SC_TRACE_EVENT(sys_exit,
+       TP_PROTO(int error_code),
+       TP_ARGS(error_code),
+       TP_STRUCT__entry(__field(int, error_code)),
+       TP_fast_assign(tp_assign(error_code, error_code)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_64_sys_fsync
+SC_TRACE_EVENT(sys_fsync,
+       TP_PROTO(unsigned int fd),
+       TP_ARGS(fd),
+       TP_STRUCT__entry(__field(unsigned int, fd)),
+       TP_fast_assign(tp_assign(fd, fd)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_64_sys_fdatasync
+SC_TRACE_EVENT(sys_fdatasync,
+       TP_PROTO(unsigned int fd),
+       TP_ARGS(fd),
+       TP_STRUCT__entry(__field(unsigned int, fd)),
+       TP_fast_assign(tp_assign(fd, fd)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_64_sys_fchdir
+SC_TRACE_EVENT(sys_fchdir,
+       TP_PROTO(unsigned int fd),
+       TP_ARGS(fd),
+       TP_STRUCT__entry(__field(unsigned int, fd)),
+       TP_fast_assign(tp_assign(fd, fd)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_64_sys_umask
+SC_TRACE_EVENT(sys_umask,
+       TP_PROTO(int mask),
+       TP_ARGS(mask),
+       TP_STRUCT__entry(__field(int, mask)),
+       TP_fast_assign(tp_assign(mask, mask)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_64_sys_setuid
+SC_TRACE_EVENT(sys_setuid,
+       TP_PROTO(uid_t uid),
+       TP_ARGS(uid),
+       TP_STRUCT__entry(__field(uid_t, uid)),
+       TP_fast_assign(tp_assign(uid, uid)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_64_sys_setgid
+SC_TRACE_EVENT(sys_setgid,
+       TP_PROTO(gid_t gid),
+       TP_ARGS(gid),
+       TP_STRUCT__entry(__field(gid_t, gid)),
+       TP_fast_assign(tp_assign(gid, gid)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_64_sys_getpgid
+SC_TRACE_EVENT(sys_getpgid,
+       TP_PROTO(pid_t pid),
+       TP_ARGS(pid),
+       TP_STRUCT__entry(__field(pid_t, pid)),
+       TP_fast_assign(tp_assign(pid, pid)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_64_sys_setfsuid
+SC_TRACE_EVENT(sys_setfsuid,
+       TP_PROTO(uid_t uid),
+       TP_ARGS(uid),
+       TP_STRUCT__entry(__field(uid_t, uid)),
+       TP_fast_assign(tp_assign(uid, uid)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_64_sys_setfsgid
+SC_TRACE_EVENT(sys_setfsgid,
+       TP_PROTO(gid_t gid),
+       TP_ARGS(gid),
+       TP_STRUCT__entry(__field(gid_t, gid)),
+       TP_fast_assign(tp_assign(gid, gid)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_64_sys_getsid
+SC_TRACE_EVENT(sys_getsid,
+       TP_PROTO(pid_t pid),
+       TP_ARGS(pid),
+       TP_STRUCT__entry(__field(pid_t, pid)),
+       TP_fast_assign(tp_assign(pid, pid)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_64_sys_personality
+SC_TRACE_EVENT(sys_personality,
+       TP_PROTO(unsigned int personality),
+       TP_ARGS(personality),
+       TP_STRUCT__entry(__field(unsigned int, personality)),
+       TP_fast_assign(tp_assign(personality, personality)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_64_sys_sched_getscheduler
+SC_TRACE_EVENT(sys_sched_getscheduler,
+       TP_PROTO(pid_t pid),
+       TP_ARGS(pid),
+       TP_STRUCT__entry(__field(pid_t, pid)),
+       TP_fast_assign(tp_assign(pid, pid)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_64_sys_sched_get_priority_max
+SC_TRACE_EVENT(sys_sched_get_priority_max,
+       TP_PROTO(int policy),
+       TP_ARGS(policy),
+       TP_STRUCT__entry(__field(int, policy)),
+       TP_fast_assign(tp_assign(policy, policy)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_64_sys_sched_get_priority_min
+SC_TRACE_EVENT(sys_sched_get_priority_min,
+       TP_PROTO(int policy),
+       TP_ARGS(policy),
+       TP_STRUCT__entry(__field(int, policy)),
+       TP_fast_assign(tp_assign(policy, policy)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_64_sys_mlockall
+SC_TRACE_EVENT(sys_mlockall,
+       TP_PROTO(int flags),
+       TP_ARGS(flags),
+       TP_STRUCT__entry(__field(int, flags)),
+       TP_fast_assign(tp_assign(flags, flags)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_64_sys_io_destroy
+SC_TRACE_EVENT(sys_io_destroy,
+       TP_PROTO(aio_context_t ctx),
+       TP_ARGS(ctx),
+       TP_STRUCT__entry(__field(aio_context_t, ctx)),
+       TP_fast_assign(tp_assign(ctx, ctx)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_64_sys_epoll_create
+SC_TRACE_EVENT(sys_epoll_create,
+       TP_PROTO(int size),
+       TP_ARGS(size),
+       TP_STRUCT__entry(__field(int, size)),
+       TP_fast_assign(tp_assign(size, size)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_64_sys_timer_getoverrun
+SC_TRACE_EVENT(sys_timer_getoverrun,
+       TP_PROTO(timer_t timer_id),
+       TP_ARGS(timer_id),
+       TP_STRUCT__entry(__field(timer_t, timer_id)),
+       TP_fast_assign(tp_assign(timer_id, timer_id)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_64_sys_timer_delete
+SC_TRACE_EVENT(sys_timer_delete,
+       TP_PROTO(timer_t timer_id),
+       TP_ARGS(timer_id),
+       TP_STRUCT__entry(__field(timer_t, timer_id)),
+       TP_fast_assign(tp_assign(timer_id, timer_id)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_64_sys_exit_group
+SC_TRACE_EVENT(sys_exit_group,
+       TP_PROTO(int error_code),
+       TP_ARGS(error_code),
+       TP_STRUCT__entry(__field(int, error_code)),
+       TP_fast_assign(tp_assign(error_code, error_code)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_64_sys_unshare
+SC_TRACE_EVENT(sys_unshare,
+       TP_PROTO(unsigned long unshare_flags),
+       TP_ARGS(unshare_flags),
+       TP_STRUCT__entry(__field(unsigned long, unshare_flags)),
+       TP_fast_assign(tp_assign(unshare_flags, unshare_flags)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_64_sys_eventfd
+SC_TRACE_EVENT(sys_eventfd,
+       TP_PROTO(unsigned int count),
+       TP_ARGS(count),
+       TP_STRUCT__entry(__field(unsigned int, count)),
+       TP_fast_assign(tp_assign(count, count)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_64_sys_epoll_create1
+SC_TRACE_EVENT(sys_epoll_create1,
+       TP_PROTO(int flags),
+       TP_ARGS(flags),
+       TP_STRUCT__entry(__field(int, flags)),
+       TP_fast_assign(tp_assign(flags, flags)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_64_sys_inotify_init1
+SC_TRACE_EVENT(sys_inotify_init1,
+       TP_PROTO(int flags),
+       TP_ARGS(flags),
+       TP_STRUCT__entry(__field(int, flags)),
+       TP_fast_assign(tp_assign(flags, flags)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_64_sys_syncfs
+SC_TRACE_EVENT(sys_syncfs,
+       TP_PROTO(int fd),
+       TP_ARGS(fd),
+       TP_STRUCT__entry(__field(int, fd)),
+       TP_fast_assign(tp_assign(fd, fd)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_64_sys_munmap
+SC_TRACE_EVENT(sys_munmap,
+       TP_PROTO(unsigned long addr, size_t len),
+       TP_ARGS(addr, len),
+       TP_STRUCT__entry(__field_hex(unsigned long, addr) __field(size_t, len)),
+       TP_fast_assign(tp_assign(addr, addr) tp_assign(len, len)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_64_sys_dup2
+SC_TRACE_EVENT(sys_dup2,
+       TP_PROTO(unsigned int oldfd, unsigned int newfd),
+       TP_ARGS(oldfd, newfd),
+       TP_STRUCT__entry(__field(unsigned int, oldfd) __field(unsigned int, newfd)),
+       TP_fast_assign(tp_assign(oldfd, oldfd) tp_assign(newfd, newfd)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_64_sys_shutdown
+SC_TRACE_EVENT(sys_shutdown,
+       TP_PROTO(int fd, int how),
+       TP_ARGS(fd, how),
+       TP_STRUCT__entry(__field(int, fd) __field(int, how)),
+       TP_fast_assign(tp_assign(fd, fd) tp_assign(how, how)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_64_sys_listen
+SC_TRACE_EVENT(sys_listen,
+       TP_PROTO(int fd, int backlog),
+       TP_ARGS(fd, backlog),
+       TP_STRUCT__entry(__field(int, fd) __field(int, backlog)),
+       TP_fast_assign(tp_assign(fd, fd) tp_assign(backlog, backlog)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_64_sys_kill
+SC_TRACE_EVENT(sys_kill,
+       TP_PROTO(pid_t pid, int sig),
+       TP_ARGS(pid, sig),
+       TP_STRUCT__entry(__field(pid_t, pid) __field(int, sig)),
+       TP_fast_assign(tp_assign(pid, pid) tp_assign(sig, sig)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_64_sys_msgget
+SC_TRACE_EVENT(sys_msgget,
+       TP_PROTO(key_t key, int msgflg),
+       TP_ARGS(key, msgflg),
+       TP_STRUCT__entry(__field(key_t, key) __field(int, msgflg)),
+       TP_fast_assign(tp_assign(key, key) tp_assign(msgflg, msgflg)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_64_sys_flock
+SC_TRACE_EVENT(sys_flock,
+       TP_PROTO(unsigned int fd, unsigned int cmd),
+       TP_ARGS(fd, cmd),
+       TP_STRUCT__entry(__field(unsigned int, fd) __field(unsigned int, cmd)),
+       TP_fast_assign(tp_assign(fd, fd) tp_assign(cmd, cmd)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_64_sys_ftruncate
+SC_TRACE_EVENT(sys_ftruncate,
+       TP_PROTO(unsigned int fd, unsigned long length),
+       TP_ARGS(fd, length),
+       TP_STRUCT__entry(__field(unsigned int, fd) __field(unsigned long, length)),
+       TP_fast_assign(tp_assign(fd, fd) tp_assign(length, length)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_64_sys_fchmod
+SC_TRACE_EVENT(sys_fchmod,
+       TP_PROTO(unsigned int fd, umode_t mode),
+       TP_ARGS(fd, mode),
+       TP_STRUCT__entry(__field(unsigned int, fd) __field(umode_t, mode)),
+       TP_fast_assign(tp_assign(fd, fd) tp_assign(mode, mode)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_64_sys_setpgid
+SC_TRACE_EVENT(sys_setpgid,
+       TP_PROTO(pid_t pid, pid_t pgid),
+       TP_ARGS(pid, pgid),
+       TP_STRUCT__entry(__field(pid_t, pid) __field(pid_t, pgid)),
+       TP_fast_assign(tp_assign(pid, pid) tp_assign(pgid, pgid)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_64_sys_setreuid
+SC_TRACE_EVENT(sys_setreuid,
+       TP_PROTO(uid_t ruid, uid_t euid),
+       TP_ARGS(ruid, euid),
+       TP_STRUCT__entry(__field(uid_t, ruid) __field(uid_t, euid)),
+       TP_fast_assign(tp_assign(ruid, ruid) tp_assign(euid, euid)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_64_sys_setregid
+SC_TRACE_EVENT(sys_setregid,
+       TP_PROTO(gid_t rgid, gid_t egid),
+       TP_ARGS(rgid, egid),
+       TP_STRUCT__entry(__field(gid_t, rgid) __field(gid_t, egid)),
+       TP_fast_assign(tp_assign(rgid, rgid) tp_assign(egid, egid)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_64_sys_getpriority
+SC_TRACE_EVENT(sys_getpriority,
+       TP_PROTO(int which, int who),
+       TP_ARGS(which, who),
+       TP_STRUCT__entry(__field(int, which) __field(int, who)),
+       TP_fast_assign(tp_assign(which, which) tp_assign(who, who)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_64_sys_mlock
+SC_TRACE_EVENT(sys_mlock,
+       TP_PROTO(unsigned long start, size_t len),
+       TP_ARGS(start, len),
+       TP_STRUCT__entry(__field(unsigned long, start) __field(size_t, len)),
+       TP_fast_assign(tp_assign(start, start) tp_assign(len, len)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_64_sys_munlock
+SC_TRACE_EVENT(sys_munlock,
+       TP_PROTO(unsigned long start, size_t len),
+       TP_ARGS(start, len),
+       TP_STRUCT__entry(__field(unsigned long, start) __field(size_t, len)),
+       TP_fast_assign(tp_assign(start, start) tp_assign(len, len)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_64_sys_tkill
+SC_TRACE_EVENT(sys_tkill,
+       TP_PROTO(pid_t pid, int sig),
+       TP_ARGS(pid, sig),
+       TP_STRUCT__entry(__field(pid_t, pid) __field(int, sig)),
+       TP_fast_assign(tp_assign(pid, pid) tp_assign(sig, sig)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_64_sys_ioprio_get
+SC_TRACE_EVENT(sys_ioprio_get,
+       TP_PROTO(int which, int who),
+       TP_ARGS(which, who),
+       TP_STRUCT__entry(__field(int, which) __field(int, who)),
+       TP_fast_assign(tp_assign(which, which) tp_assign(who, who)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_64_sys_inotify_rm_watch
+SC_TRACE_EVENT(sys_inotify_rm_watch,
+       TP_PROTO(int fd, __s32 wd),
+       TP_ARGS(fd, wd),
+       TP_STRUCT__entry(__field(int, fd) __field(__s32, wd)),
+       TP_fast_assign(tp_assign(fd, fd) tp_assign(wd, wd)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_64_sys_timerfd_create
+SC_TRACE_EVENT(sys_timerfd_create,
+       TP_PROTO(int clockid, int flags),
+       TP_ARGS(clockid, flags),
+       TP_STRUCT__entry(__field(int, clockid) __field(int, flags)),
+       TP_fast_assign(tp_assign(clockid, clockid) tp_assign(flags, flags)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_64_sys_eventfd2
+SC_TRACE_EVENT(sys_eventfd2,
+       TP_PROTO(unsigned int count, int flags),
+       TP_ARGS(count, flags),
+       TP_STRUCT__entry(__field(unsigned int, count) __field(int, flags)),
+       TP_fast_assign(tp_assign(count, count) tp_assign(flags, flags)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_64_sys_fanotify_init
+SC_TRACE_EVENT(sys_fanotify_init,
+       TP_PROTO(unsigned int flags, unsigned int event_f_flags),
+       TP_ARGS(flags, event_f_flags),
+       TP_STRUCT__entry(__field(unsigned int, flags) __field(unsigned int, event_f_flags)),
+       TP_fast_assign(tp_assign(flags, flags) tp_assign(event_f_flags, event_f_flags)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_64_sys_setns
+SC_TRACE_EVENT(sys_setns,
+       TP_PROTO(int fd, int nstype),
+       TP_ARGS(fd, nstype),
+       TP_STRUCT__entry(__field(int, fd) __field(int, nstype)),
+       TP_fast_assign(tp_assign(fd, fd) tp_assign(nstype, nstype)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_64_sys_lseek
+SC_TRACE_EVENT(sys_lseek,
+       TP_PROTO(unsigned int fd, off_t offset, unsigned int whence),
+       TP_ARGS(fd, offset, whence),
+       TP_STRUCT__entry(__field(unsigned int, fd) __field(off_t, offset) __field(unsigned int, whence)),
+       TP_fast_assign(tp_assign(fd, fd) tp_assign(offset, offset) tp_assign(whence, whence)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_64_sys_mprotect
+SC_TRACE_EVENT(sys_mprotect,
+       TP_PROTO(unsigned long start, size_t len, unsigned long prot),
+       TP_ARGS(start, len, prot),
+       TP_STRUCT__entry(__field(unsigned long, start) __field(size_t, len) __field(unsigned long, prot)),
+       TP_fast_assign(tp_assign(start, start) tp_assign(len, len) tp_assign(prot, prot)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_64_sys_ioctl
+SC_TRACE_EVENT(sys_ioctl,
+       TP_PROTO(unsigned int fd, unsigned int cmd, unsigned long arg),
+       TP_ARGS(fd, cmd, arg),
+       TP_STRUCT__entry(__field(unsigned int, fd) __field(unsigned int, cmd) __field(unsigned long, arg)),
+       TP_fast_assign(tp_assign(fd, fd) tp_assign(cmd, cmd) tp_assign(arg, arg)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_64_sys_msync
+SC_TRACE_EVENT(sys_msync,
+       TP_PROTO(unsigned long start, size_t len, int flags),
+       TP_ARGS(start, len, flags),
+       TP_STRUCT__entry(__field(unsigned long, start) __field(size_t, len) __field(int, flags)),
+       TP_fast_assign(tp_assign(start, start) tp_assign(len, len) tp_assign(flags, flags)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_64_sys_madvise
+SC_TRACE_EVENT(sys_madvise,
+       TP_PROTO(unsigned long start, size_t len_in, int behavior),
+       TP_ARGS(start, len_in, behavior),
+       TP_STRUCT__entry(__field(unsigned long, start) __field(size_t, len_in) __field(int, behavior)),
+       TP_fast_assign(tp_assign(start, start) tp_assign(len_in, len_in) tp_assign(behavior, behavior)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_64_sys_shmget
+SC_TRACE_EVENT(sys_shmget,
+       TP_PROTO(key_t key, size_t size, int shmflg),
+       TP_ARGS(key, size, shmflg),
+       TP_STRUCT__entry(__field(key_t, key) __field(size_t, size) __field(int, shmflg)),
+       TP_fast_assign(tp_assign(key, key) tp_assign(size, size) tp_assign(shmflg, shmflg)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_64_sys_socket
+SC_TRACE_EVENT(sys_socket,
+       TP_PROTO(int family, int type, int protocol),
+       TP_ARGS(family, type, protocol),
+       TP_STRUCT__entry(__field(int, family) __field(int, type) __field(int, protocol)),
+       TP_fast_assign(tp_assign(family, family) tp_assign(type, type) tp_assign(protocol, protocol)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_64_sys_semget
+SC_TRACE_EVENT(sys_semget,
+       TP_PROTO(key_t key, int nsems, int semflg),
+       TP_ARGS(key, nsems, semflg),
+       TP_STRUCT__entry(__field(key_t, key) __field(int, nsems) __field(int, semflg)),
+       TP_fast_assign(tp_assign(key, key) tp_assign(nsems, nsems) tp_assign(semflg, semflg)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_64_sys_fcntl
+SC_TRACE_EVENT(sys_fcntl,
+       TP_PROTO(unsigned int fd, unsigned int cmd, unsigned long arg),
+       TP_ARGS(fd, cmd, arg),
+       TP_STRUCT__entry(__field(unsigned int, fd) __field(unsigned int, cmd) __field(unsigned long, arg)),
+       TP_fast_assign(tp_assign(fd, fd) tp_assign(cmd, cmd) tp_assign(arg, arg)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_64_sys_fchown
+SC_TRACE_EVENT(sys_fchown,
+       TP_PROTO(unsigned int fd, uid_t user, gid_t group),
+       TP_ARGS(fd, user, group),
+       TP_STRUCT__entry(__field(unsigned int, fd) __field(uid_t, user) __field(gid_t, group)),
+       TP_fast_assign(tp_assign(fd, fd) tp_assign(user, user) tp_assign(group, group)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_64_sys_setresuid
+SC_TRACE_EVENT(sys_setresuid,
+       TP_PROTO(uid_t ruid, uid_t euid, uid_t suid),
+       TP_ARGS(ruid, euid, suid),
+       TP_STRUCT__entry(__field(uid_t, ruid) __field(uid_t, euid) __field(uid_t, suid)),
+       TP_fast_assign(tp_assign(ruid, ruid) tp_assign(euid, euid) tp_assign(suid, suid)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_64_sys_setresgid
+SC_TRACE_EVENT(sys_setresgid,
+       TP_PROTO(gid_t rgid, gid_t egid, gid_t sgid),
+       TP_ARGS(rgid, egid, sgid),
+       TP_STRUCT__entry(__field(gid_t, rgid) __field(gid_t, egid) __field(gid_t, sgid)),
+       TP_fast_assign(tp_assign(rgid, rgid) tp_assign(egid, egid) tp_assign(sgid, sgid)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_64_sys_sysfs
+SC_TRACE_EVENT(sys_sysfs,
+       TP_PROTO(int option, unsigned long arg1, unsigned long arg2),
+       TP_ARGS(option, arg1, arg2),
+       TP_STRUCT__entry(__field(int, option) __field(unsigned long, arg1) __field(unsigned long, arg2)),
+       TP_fast_assign(tp_assign(option, option) tp_assign(arg1, arg1) tp_assign(arg2, arg2)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_64_sys_setpriority
+SC_TRACE_EVENT(sys_setpriority,
+       TP_PROTO(int which, int who, int niceval),
+       TP_ARGS(which, who, niceval),
+       TP_STRUCT__entry(__field(int, which) __field(int, who) __field(int, niceval)),
+       TP_fast_assign(tp_assign(which, which) tp_assign(who, who) tp_assign(niceval, niceval)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_64_sys_readahead
+SC_TRACE_EVENT(sys_readahead,
+       TP_PROTO(int fd, loff_t offset, size_t count),
+       TP_ARGS(fd, offset, count),
+       TP_STRUCT__entry(__field(int, fd) __field(loff_t, offset) __field(size_t, count)),
+       TP_fast_assign(tp_assign(fd, fd) tp_assign(offset, offset) tp_assign(count, count)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_64_sys_tgkill
+SC_TRACE_EVENT(sys_tgkill,
+       TP_PROTO(pid_t tgid, pid_t pid, int sig),
+       TP_ARGS(tgid, pid, sig),
+       TP_STRUCT__entry(__field(pid_t, tgid) __field(pid_t, pid) __field(int, sig)),
+       TP_fast_assign(tp_assign(tgid, tgid) tp_assign(pid, pid) tp_assign(sig, sig)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_64_sys_ioprio_set
+SC_TRACE_EVENT(sys_ioprio_set,
+       TP_PROTO(int which, int who, int ioprio),
+       TP_ARGS(which, who, ioprio),
+       TP_STRUCT__entry(__field(int, which) __field(int, who) __field(int, ioprio)),
+       TP_fast_assign(tp_assign(which, which) tp_assign(who, who) tp_assign(ioprio, ioprio)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_64_sys_dup3
+SC_TRACE_EVENT(sys_dup3,
+       TP_PROTO(unsigned int oldfd, unsigned int newfd, int flags),
+       TP_ARGS(oldfd, newfd, flags),
+       TP_STRUCT__entry(__field(unsigned int, oldfd) __field(unsigned int, newfd) __field(int, flags)),
+       TP_fast_assign(tp_assign(oldfd, oldfd) tp_assign(newfd, newfd) tp_assign(flags, flags)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_64_sys_semctl
+SC_TRACE_EVENT(sys_semctl,
+       TP_PROTO(int semid, int semnum, int cmd, unsigned long arg),
+       TP_ARGS(semid, semnum, cmd, arg),
+       TP_STRUCT__entry(__field(int, semid) __field(int, semnum) __field(int, cmd) __field(unsigned long, arg)),
+       TP_fast_assign(tp_assign(semid, semid) tp_assign(semnum, semnum) tp_assign(cmd, cmd) tp_assign(arg, arg)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_64_sys_ptrace
+SC_TRACE_EVENT(sys_ptrace,
+       TP_PROTO(long request, long pid, unsigned long addr, unsigned long data),
+       TP_ARGS(request, pid, addr, data),
+       TP_STRUCT__entry(__field(long, request) __field(long, pid) __field_hex(unsigned long, addr) __field(unsigned long, data)),
+       TP_fast_assign(tp_assign(request, request) tp_assign(pid, pid) tp_assign(addr, addr) tp_assign(data, data)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_64_sys_fadvise64
+SC_TRACE_EVENT(sys_fadvise64,
+       TP_PROTO(int fd, loff_t offset, size_t len, int advice),
+       TP_ARGS(fd, offset, len, advice),
+       TP_STRUCT__entry(__field(int, fd) __field(loff_t, offset) __field(size_t, len) __field(int, advice)),
+       TP_fast_assign(tp_assign(fd, fd) tp_assign(offset, offset) tp_assign(len, len) tp_assign(advice, advice)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_64_sys_tee
+SC_TRACE_EVENT(sys_tee,
+       TP_PROTO(int fdin, int fdout, size_t len, unsigned int flags),
+       TP_ARGS(fdin, fdout, len, flags),
+       TP_STRUCT__entry(__field(int, fdin) __field(int, fdout) __field(size_t, len) __field(unsigned int, flags)),
+       TP_fast_assign(tp_assign(fdin, fdin) tp_assign(fdout, fdout) tp_assign(len, len) tp_assign(flags, flags)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_64_sys_sync_file_range
+SC_TRACE_EVENT(sys_sync_file_range,
+       TP_PROTO(int fd, loff_t offset, loff_t nbytes, unsigned int flags),
+       TP_ARGS(fd, offset, nbytes, flags),
+       TP_STRUCT__entry(__field(int, fd) __field(loff_t, offset) __field(loff_t, nbytes) __field(unsigned int, flags)),
+       TP_fast_assign(tp_assign(fd, fd) tp_assign(offset, offset) tp_assign(nbytes, nbytes) tp_assign(flags, flags)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_64_sys_fallocate
+SC_TRACE_EVENT(sys_fallocate,
+       TP_PROTO(int fd, int mode, loff_t offset, loff_t len),
+       TP_ARGS(fd, mode, offset, len),
+       TP_STRUCT__entry(__field(int, fd) __field(int, mode) __field(loff_t, offset) __field(loff_t, len)),
+       TP_fast_assign(tp_assign(fd, fd) tp_assign(mode, mode) tp_assign(offset, offset) tp_assign(len, len)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_64_sys_mremap
+SC_TRACE_EVENT(sys_mremap,
+       TP_PROTO(unsigned long addr, unsigned long old_len, unsigned long new_len, unsigned long flags, unsigned long new_addr),
+       TP_ARGS(addr, old_len, new_len, flags, new_addr),
+       TP_STRUCT__entry(__field_hex(unsigned long, addr) __field(unsigned long, old_len) __field(unsigned long, new_len) __field(unsigned long, flags) __field_hex(unsigned long, new_addr)),
+       TP_fast_assign(tp_assign(addr, addr) tp_assign(old_len, old_len) tp_assign(new_len, new_len) tp_assign(flags, flags) tp_assign(new_addr, new_addr)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_64_sys_prctl
+SC_TRACE_EVENT(sys_prctl,
+       TP_PROTO(int option, unsigned long arg2, unsigned long arg3, unsigned long arg4, unsigned long arg5),
+       TP_ARGS(option, arg2, arg3, arg4, arg5),
+       TP_STRUCT__entry(__field(int, option) __field(unsigned long, arg2) __field(unsigned long, arg3) __field(unsigned long, arg4) __field(unsigned long, arg5)),
+       TP_fast_assign(tp_assign(option, option) tp_assign(arg2, arg2) tp_assign(arg3, arg3) tp_assign(arg4, arg4) tp_assign(arg5, arg5)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_64_sys_remap_file_pages
+SC_TRACE_EVENT(sys_remap_file_pages,
+       TP_PROTO(unsigned long start, unsigned long size, unsigned long prot, unsigned long pgoff, unsigned long flags),
+       TP_ARGS(start, size, prot, pgoff, flags),
+       TP_STRUCT__entry(__field(unsigned long, start) __field(unsigned long, size) __field(unsigned long, prot) __field(unsigned long, pgoff) __field(unsigned long, flags)),
+       TP_fast_assign(tp_assign(start, start) tp_assign(size, size) tp_assign(prot, prot) tp_assign(pgoff, pgoff) tp_assign(flags, flags)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_64_sys_keyctl
+SC_TRACE_EVENT(sys_keyctl,
+       TP_PROTO(int option, unsigned long arg2, unsigned long arg3, unsigned long arg4, unsigned long arg5),
+       TP_ARGS(option, arg2, arg3, arg4, arg5),
+       TP_STRUCT__entry(__field(int, option) __field(unsigned long, arg2) __field(unsigned long, arg3) __field(unsigned long, arg4) __field(unsigned long, arg5)),
+       TP_fast_assign(tp_assign(option, option) tp_assign(arg2, arg2) tp_assign(arg3, arg3) tp_assign(arg4, arg4) tp_assign(arg5, arg5)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_64_sys_mmap
+SC_TRACE_EVENT(sys_mmap,
+       TP_PROTO(unsigned long addr, unsigned long len, unsigned long prot, unsigned long flags, unsigned long fd, unsigned long off),
+       TP_ARGS(addr, len, prot, flags, fd, off),
+       TP_STRUCT__entry(__field_hex(unsigned long, addr) __field(unsigned long, len) __field(unsigned long, prot) __field(unsigned long, flags) __field(unsigned long, fd) __field(unsigned long, off)),
+       TP_fast_assign(tp_assign(addr, addr) tp_assign(len, len) tp_assign(prot, prot) tp_assign(flags, flags) tp_assign(fd, fd) tp_assign(off, off)),
+       TP_printk()
+)
+#endif
+
+#endif /*  _TRACE_SYSCALLS_INTEGERS_H */
+
+/* This part must be outside protection */
+#include "../../../probes/define_trace.h"
+
+#else /* CREATE_SYSCALL_TABLE */
+
+#include "x86-64-syscalls-3.10.0-rc7_integers_override.h"
+#include "syscalls_integers_override.h"
+
+#ifndef OVERRIDE_TABLE_64_sys_sched_yield
+TRACE_SYSCALL_TABLE(syscalls_noargs, sys_sched_yield, 24, 0)
+#endif
+#ifndef OVERRIDE_TABLE_64_sys_pause
+TRACE_SYSCALL_TABLE(syscalls_noargs, sys_pause, 34, 0)
+#endif
+#ifndef OVERRIDE_TABLE_64_sys_getpid
+TRACE_SYSCALL_TABLE(syscalls_noargs, sys_getpid, 39, 0)
+#endif
+#ifndef OVERRIDE_TABLE_64_sys_getuid
+TRACE_SYSCALL_TABLE(syscalls_noargs, sys_getuid, 102, 0)
+#endif
+#ifndef OVERRIDE_TABLE_64_sys_getgid
+TRACE_SYSCALL_TABLE(syscalls_noargs, sys_getgid, 104, 0)
+#endif
+#ifndef OVERRIDE_TABLE_64_sys_geteuid
+TRACE_SYSCALL_TABLE(syscalls_noargs, sys_geteuid, 107, 0)
+#endif
+#ifndef OVERRIDE_TABLE_64_sys_getegid
+TRACE_SYSCALL_TABLE(syscalls_noargs, sys_getegid, 108, 0)
+#endif
+#ifndef OVERRIDE_TABLE_64_sys_getppid
+TRACE_SYSCALL_TABLE(syscalls_noargs, sys_getppid, 110, 0)
+#endif
+#ifndef OVERRIDE_TABLE_64_sys_getpgrp
+TRACE_SYSCALL_TABLE(syscalls_noargs, sys_getpgrp, 111, 0)
+#endif
+#ifndef OVERRIDE_TABLE_64_sys_setsid
+TRACE_SYSCALL_TABLE(syscalls_noargs, sys_setsid, 112, 0)
+#endif
+#ifndef OVERRIDE_TABLE_64_sys_munlockall
+TRACE_SYSCALL_TABLE(syscalls_noargs, sys_munlockall, 152, 0)
+#endif
+#ifndef OVERRIDE_TABLE_64_sys_vhangup
+TRACE_SYSCALL_TABLE(syscalls_noargs, sys_vhangup, 153, 0)
+#endif
+#ifndef OVERRIDE_TABLE_64_sys_sync
+TRACE_SYSCALL_TABLE(syscalls_noargs, sys_sync, 162, 0)
+#endif
+#ifndef OVERRIDE_TABLE_64_sys_gettid
+TRACE_SYSCALL_TABLE(syscalls_noargs, sys_gettid, 186, 0)
+#endif
+#ifndef OVERRIDE_TABLE_64_sys_restart_syscall
+TRACE_SYSCALL_TABLE(syscalls_noargs, sys_restart_syscall, 219, 0)
+#endif
+#ifndef OVERRIDE_TABLE_64_sys_inotify_init
+TRACE_SYSCALL_TABLE(syscalls_noargs, sys_inotify_init, 253, 0)
+#endif
+#ifndef OVERRIDE_TABLE_64_sys_close
+TRACE_SYSCALL_TABLE(sys_close, sys_close, 3, 1)
+#endif
+#ifndef OVERRIDE_TABLE_64_sys_lseek
+TRACE_SYSCALL_TABLE(sys_lseek, sys_lseek, 8, 3)
+#endif
+#ifndef OVERRIDE_TABLE_64_sys_mmap
+TRACE_SYSCALL_TABLE(sys_mmap, sys_mmap, 9, 6)
+#endif
+#ifndef OVERRIDE_TABLE_64_sys_mprotect
+TRACE_SYSCALL_TABLE(sys_mprotect, sys_mprotect, 10, 3)
+#endif
+#ifndef OVERRIDE_TABLE_64_sys_munmap
+TRACE_SYSCALL_TABLE(sys_munmap, sys_munmap, 11, 2)
+#endif
+#ifndef OVERRIDE_TABLE_64_sys_brk
+TRACE_SYSCALL_TABLE(sys_brk, sys_brk, 12, 1)
+#endif
+#ifndef OVERRIDE_TABLE_64_sys_ioctl
+TRACE_SYSCALL_TABLE(sys_ioctl, sys_ioctl, 16, 3)
+#endif
+#ifndef OVERRIDE_TABLE_64_sys_mremap
+TRACE_SYSCALL_TABLE(sys_mremap, sys_mremap, 25, 5)
+#endif
+#ifndef OVERRIDE_TABLE_64_sys_msync
+TRACE_SYSCALL_TABLE(sys_msync, sys_msync, 26, 3)
+#endif
+#ifndef OVERRIDE_TABLE_64_sys_madvise
+TRACE_SYSCALL_TABLE(sys_madvise, sys_madvise, 28, 3)
+#endif
+#ifndef OVERRIDE_TABLE_64_sys_shmget
+TRACE_SYSCALL_TABLE(sys_shmget, sys_shmget, 29, 3)
+#endif
+#ifndef OVERRIDE_TABLE_64_sys_dup
+TRACE_SYSCALL_TABLE(sys_dup, sys_dup, 32, 1)
+#endif
+#ifndef OVERRIDE_TABLE_64_sys_dup2
+TRACE_SYSCALL_TABLE(sys_dup2, sys_dup2, 33, 2)
+#endif
+#ifndef OVERRIDE_TABLE_64_sys_alarm
+TRACE_SYSCALL_TABLE(sys_alarm, sys_alarm, 37, 1)
+#endif
+#ifndef OVERRIDE_TABLE_64_sys_socket
+TRACE_SYSCALL_TABLE(sys_socket, sys_socket, 41, 3)
+#endif
+#ifndef OVERRIDE_TABLE_64_sys_shutdown
+TRACE_SYSCALL_TABLE(sys_shutdown, sys_shutdown, 48, 2)
+#endif
+#ifndef OVERRIDE_TABLE_64_sys_listen
+TRACE_SYSCALL_TABLE(sys_listen, sys_listen, 50, 2)
+#endif
+#ifndef OVERRIDE_TABLE_64_sys_exit
+TRACE_SYSCALL_TABLE(sys_exit, sys_exit, 60, 1)
+#endif
+#ifndef OVERRIDE_TABLE_64_sys_kill
+TRACE_SYSCALL_TABLE(sys_kill, sys_kill, 62, 2)
+#endif
+#ifndef OVERRIDE_TABLE_64_sys_semget
+TRACE_SYSCALL_TABLE(sys_semget, sys_semget, 64, 3)
+#endif
+#ifndef OVERRIDE_TABLE_64_sys_semctl
+TRACE_SYSCALL_TABLE(sys_semctl, sys_semctl, 66, 4)
+#endif
+#ifndef OVERRIDE_TABLE_64_sys_msgget
+TRACE_SYSCALL_TABLE(sys_msgget, sys_msgget, 68, 2)
+#endif
+#ifndef OVERRIDE_TABLE_64_sys_fcntl
+TRACE_SYSCALL_TABLE(sys_fcntl, sys_fcntl, 72, 3)
+#endif
+#ifndef OVERRIDE_TABLE_64_sys_flock
+TRACE_SYSCALL_TABLE(sys_flock, sys_flock, 73, 2)
+#endif
+#ifndef OVERRIDE_TABLE_64_sys_fsync
+TRACE_SYSCALL_TABLE(sys_fsync, sys_fsync, 74, 1)
+#endif
+#ifndef OVERRIDE_TABLE_64_sys_fdatasync
+TRACE_SYSCALL_TABLE(sys_fdatasync, sys_fdatasync, 75, 1)
+#endif
+#ifndef OVERRIDE_TABLE_64_sys_ftruncate
+TRACE_SYSCALL_TABLE(sys_ftruncate, sys_ftruncate, 77, 2)
+#endif
+#ifndef OVERRIDE_TABLE_64_sys_fchdir
+TRACE_SYSCALL_TABLE(sys_fchdir, sys_fchdir, 81, 1)
+#endif
+#ifndef OVERRIDE_TABLE_64_sys_fchmod
+TRACE_SYSCALL_TABLE(sys_fchmod, sys_fchmod, 91, 2)
+#endif
+#ifndef OVERRIDE_TABLE_64_sys_fchown
+TRACE_SYSCALL_TABLE(sys_fchown, sys_fchown, 93, 3)
+#endif
+#ifndef OVERRIDE_TABLE_64_sys_umask
+TRACE_SYSCALL_TABLE(sys_umask, sys_umask, 95, 1)
+#endif
+#ifndef OVERRIDE_TABLE_64_sys_ptrace
+TRACE_SYSCALL_TABLE(sys_ptrace, sys_ptrace, 101, 4)
+#endif
+#ifndef OVERRIDE_TABLE_64_sys_setuid
+TRACE_SYSCALL_TABLE(sys_setuid, sys_setuid, 105, 1)
+#endif
+#ifndef OVERRIDE_TABLE_64_sys_setgid
+TRACE_SYSCALL_TABLE(sys_setgid, sys_setgid, 106, 1)
+#endif
+#ifndef OVERRIDE_TABLE_64_sys_setpgid
+TRACE_SYSCALL_TABLE(sys_setpgid, sys_setpgid, 109, 2)
+#endif
+#ifndef OVERRIDE_TABLE_64_sys_setreuid
+TRACE_SYSCALL_TABLE(sys_setreuid, sys_setreuid, 113, 2)
+#endif
+#ifndef OVERRIDE_TABLE_64_sys_setregid
+TRACE_SYSCALL_TABLE(sys_setregid, sys_setregid, 114, 2)
+#endif
+#ifndef OVERRIDE_TABLE_64_sys_setresuid
+TRACE_SYSCALL_TABLE(sys_setresuid, sys_setresuid, 117, 3)
+#endif
+#ifndef OVERRIDE_TABLE_64_sys_setresgid
+TRACE_SYSCALL_TABLE(sys_setresgid, sys_setresgid, 119, 3)
+#endif
+#ifndef OVERRIDE_TABLE_64_sys_getpgid
+TRACE_SYSCALL_TABLE(sys_getpgid, sys_getpgid, 121, 1)
+#endif
+#ifndef OVERRIDE_TABLE_64_sys_setfsuid
+TRACE_SYSCALL_TABLE(sys_setfsuid, sys_setfsuid, 122, 1)
+#endif
+#ifndef OVERRIDE_TABLE_64_sys_setfsgid
+TRACE_SYSCALL_TABLE(sys_setfsgid, sys_setfsgid, 123, 1)
+#endif
+#ifndef OVERRIDE_TABLE_64_sys_getsid
+TRACE_SYSCALL_TABLE(sys_getsid, sys_getsid, 124, 1)
+#endif
+#ifndef OVERRIDE_TABLE_64_sys_personality
+TRACE_SYSCALL_TABLE(sys_personality, sys_personality, 135, 1)
+#endif
+#ifndef OVERRIDE_TABLE_64_sys_sysfs
+TRACE_SYSCALL_TABLE(sys_sysfs, sys_sysfs, 139, 3)
+#endif
+#ifndef OVERRIDE_TABLE_64_sys_getpriority
+TRACE_SYSCALL_TABLE(sys_getpriority, sys_getpriority, 140, 2)
+#endif
+#ifndef OVERRIDE_TABLE_64_sys_setpriority
+TRACE_SYSCALL_TABLE(sys_setpriority, sys_setpriority, 141, 3)
+#endif
+#ifndef OVERRIDE_TABLE_64_sys_sched_getscheduler
+TRACE_SYSCALL_TABLE(sys_sched_getscheduler, sys_sched_getscheduler, 145, 1)
+#endif
+#ifndef OVERRIDE_TABLE_64_sys_sched_get_priority_max
+TRACE_SYSCALL_TABLE(sys_sched_get_priority_max, sys_sched_get_priority_max, 146, 1)
+#endif
+#ifndef OVERRIDE_TABLE_64_sys_sched_get_priority_min
+TRACE_SYSCALL_TABLE(sys_sched_get_priority_min, sys_sched_get_priority_min, 147, 1)
+#endif
+#ifndef OVERRIDE_TABLE_64_sys_mlock
+TRACE_SYSCALL_TABLE(sys_mlock, sys_mlock, 149, 2)
+#endif
+#ifndef OVERRIDE_TABLE_64_sys_munlock
+TRACE_SYSCALL_TABLE(sys_munlock, sys_munlock, 150, 2)
+#endif
+#ifndef OVERRIDE_TABLE_64_sys_mlockall
+TRACE_SYSCALL_TABLE(sys_mlockall, sys_mlockall, 151, 1)
+#endif
+#ifndef OVERRIDE_TABLE_64_sys_prctl
+TRACE_SYSCALL_TABLE(sys_prctl, sys_prctl, 157, 5)
+#endif
+#ifndef OVERRIDE_TABLE_64_sys_readahead
+TRACE_SYSCALL_TABLE(sys_readahead, sys_readahead, 187, 3)
+#endif
+#ifndef OVERRIDE_TABLE_64_sys_tkill
+TRACE_SYSCALL_TABLE(sys_tkill, sys_tkill, 200, 2)
+#endif
+#ifndef OVERRIDE_TABLE_64_sys_io_destroy
+TRACE_SYSCALL_TABLE(sys_io_destroy, sys_io_destroy, 207, 1)
+#endif
+#ifndef OVERRIDE_TABLE_64_sys_epoll_create
+TRACE_SYSCALL_TABLE(sys_epoll_create, sys_epoll_create, 213, 1)
+#endif
+#ifndef OVERRIDE_TABLE_64_sys_remap_file_pages
+TRACE_SYSCALL_TABLE(sys_remap_file_pages, sys_remap_file_pages, 216, 5)
+#endif
+#ifndef OVERRIDE_TABLE_64_sys_fadvise64
+TRACE_SYSCALL_TABLE(sys_fadvise64, sys_fadvise64, 221, 4)
+#endif
+#ifndef OVERRIDE_TABLE_64_sys_timer_getoverrun
+TRACE_SYSCALL_TABLE(sys_timer_getoverrun, sys_timer_getoverrun, 225, 1)
+#endif
+#ifndef OVERRIDE_TABLE_64_sys_timer_delete
+TRACE_SYSCALL_TABLE(sys_timer_delete, sys_timer_delete, 226, 1)
+#endif
+#ifndef OVERRIDE_TABLE_64_sys_exit_group
+TRACE_SYSCALL_TABLE(sys_exit_group, sys_exit_group, 231, 1)
+#endif
+#ifndef OVERRIDE_TABLE_64_sys_tgkill
+TRACE_SYSCALL_TABLE(sys_tgkill, sys_tgkill, 234, 3)
+#endif
+#ifndef OVERRIDE_TABLE_64_sys_keyctl
+TRACE_SYSCALL_TABLE(sys_keyctl, sys_keyctl, 250, 5)
+#endif
+#ifndef OVERRIDE_TABLE_64_sys_ioprio_set
+TRACE_SYSCALL_TABLE(sys_ioprio_set, sys_ioprio_set, 251, 3)
+#endif
+#ifndef OVERRIDE_TABLE_64_sys_ioprio_get
+TRACE_SYSCALL_TABLE(sys_ioprio_get, sys_ioprio_get, 252, 2)
+#endif
+#ifndef OVERRIDE_TABLE_64_sys_inotify_rm_watch
+TRACE_SYSCALL_TABLE(sys_inotify_rm_watch, sys_inotify_rm_watch, 255, 2)
+#endif
+#ifndef OVERRIDE_TABLE_64_sys_unshare
+TRACE_SYSCALL_TABLE(sys_unshare, sys_unshare, 272, 1)
+#endif
+#ifndef OVERRIDE_TABLE_64_sys_tee
+TRACE_SYSCALL_TABLE(sys_tee, sys_tee, 276, 4)
+#endif
+#ifndef OVERRIDE_TABLE_64_sys_sync_file_range
+TRACE_SYSCALL_TABLE(sys_sync_file_range, sys_sync_file_range, 277, 4)
+#endif
+#ifndef OVERRIDE_TABLE_64_sys_timerfd_create
+TRACE_SYSCALL_TABLE(sys_timerfd_create, sys_timerfd_create, 283, 2)
+#endif
+#ifndef OVERRIDE_TABLE_64_sys_eventfd
+TRACE_SYSCALL_TABLE(sys_eventfd, sys_eventfd, 284, 1)
+#endif
+#ifndef OVERRIDE_TABLE_64_sys_fallocate
+TRACE_SYSCALL_TABLE(sys_fallocate, sys_fallocate, 285, 4)
+#endif
+#ifndef OVERRIDE_TABLE_64_sys_eventfd2
+TRACE_SYSCALL_TABLE(sys_eventfd2, sys_eventfd2, 290, 2)
+#endif
+#ifndef OVERRIDE_TABLE_64_sys_epoll_create1
+TRACE_SYSCALL_TABLE(sys_epoll_create1, sys_epoll_create1, 291, 1)
+#endif
+#ifndef OVERRIDE_TABLE_64_sys_dup3
+TRACE_SYSCALL_TABLE(sys_dup3, sys_dup3, 292, 3)
+#endif
+#ifndef OVERRIDE_TABLE_64_sys_inotify_init1
+TRACE_SYSCALL_TABLE(sys_inotify_init1, sys_inotify_init1, 294, 1)
+#endif
+#ifndef OVERRIDE_TABLE_64_sys_fanotify_init
+TRACE_SYSCALL_TABLE(sys_fanotify_init, sys_fanotify_init, 300, 2)
+#endif
+#ifndef OVERRIDE_TABLE_64_sys_syncfs
+TRACE_SYSCALL_TABLE(sys_syncfs, sys_syncfs, 306, 1)
+#endif
+#ifndef OVERRIDE_TABLE_64_sys_setns
+TRACE_SYSCALL_TABLE(sys_setns, sys_setns, 308, 2)
+#endif
+
+#endif /* CREATE_SYSCALL_TABLE */
diff --git a/drivers/staging/lttng/instrumentation/syscalls/headers/x86-64-syscalls-3.10.0-rc7_integers_override.h b/drivers/staging/lttng/instrumentation/syscalls/headers/x86-64-syscalls-3.10.0-rc7_integers_override.h
new file mode 100644 (file)
index 0000000..5f971e7
--- /dev/null
@@ -0,0 +1,3 @@
+/*
+ * this is a place-holder for x86_64 integer syscall definition override.
+ */
diff --git a/drivers/staging/lttng/instrumentation/syscalls/headers/x86-64-syscalls-3.10.0-rc7_pointers.h b/drivers/staging/lttng/instrumentation/syscalls/headers/x86-64-syscalls-3.10.0-rc7_pointers.h
new file mode 100644 (file)
index 0000000..d900dc7
--- /dev/null
@@ -0,0 +1,2304 @@
+/* THIS FILE IS AUTO-GENERATED. DO NOT EDIT */
+#ifndef CREATE_SYSCALL_TABLE
+
+#if !defined(_TRACE_SYSCALLS_POINTERS_H) || defined(TRACE_HEADER_MULTI_READ)
+#define _TRACE_SYSCALLS_POINTERS_H
+
+#include <linux/tracepoint.h>
+#include <linux/syscalls.h>
+#include "x86-64-syscalls-3.10.0-rc7_pointers_override.h"
+#include "syscalls_pointers_override.h"
+
+#ifndef OVERRIDE_64_sys_pipe
+SC_TRACE_EVENT(sys_pipe,
+       TP_PROTO(int * fildes),
+       TP_ARGS(fildes),
+       TP_STRUCT__entry(__field_hex(int *, fildes)),
+       TP_fast_assign(tp_assign(fildes, fildes)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_64_sys_newuname
+SC_TRACE_EVENT(sys_newuname,
+       TP_PROTO(struct new_utsname * name),
+       TP_ARGS(name),
+       TP_STRUCT__entry(__field_hex(struct new_utsname *, name)),
+       TP_fast_assign(tp_assign(name, name)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_64_sys_shmdt
+SC_TRACE_EVENT(sys_shmdt,
+       TP_PROTO(char * shmaddr),
+       TP_ARGS(shmaddr),
+       TP_STRUCT__entry(__field_hex(char *, shmaddr)),
+       TP_fast_assign(tp_assign(shmaddr, shmaddr)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_64_sys_chdir
+SC_TRACE_EVENT(sys_chdir,
+       TP_PROTO(const char * filename),
+       TP_ARGS(filename),
+       TP_STRUCT__entry(__string_from_user(filename, filename)),
+       TP_fast_assign(tp_copy_string_from_user(filename, filename)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_64_sys_rmdir
+SC_TRACE_EVENT(sys_rmdir,
+       TP_PROTO(const char * pathname),
+       TP_ARGS(pathname),
+       TP_STRUCT__entry(__string_from_user(pathname, pathname)),
+       TP_fast_assign(tp_copy_string_from_user(pathname, pathname)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_64_sys_unlink
+SC_TRACE_EVENT(sys_unlink,
+       TP_PROTO(const char * pathname),
+       TP_ARGS(pathname),
+       TP_STRUCT__entry(__string_from_user(pathname, pathname)),
+       TP_fast_assign(tp_copy_string_from_user(pathname, pathname)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_64_sys_sysinfo
+SC_TRACE_EVENT(sys_sysinfo,
+       TP_PROTO(struct sysinfo * info),
+       TP_ARGS(info),
+       TP_STRUCT__entry(__field_hex(struct sysinfo *, info)),
+       TP_fast_assign(tp_assign(info, info)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_64_sys_times
+SC_TRACE_EVENT(sys_times,
+       TP_PROTO(struct tms * tbuf),
+       TP_ARGS(tbuf),
+       TP_STRUCT__entry(__field_hex(struct tms *, tbuf)),
+       TP_fast_assign(tp_assign(tbuf, tbuf)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_64_sys_sysctl
+SC_TRACE_EVENT(sys_sysctl,
+       TP_PROTO(struct __sysctl_args * args),
+       TP_ARGS(args),
+       TP_STRUCT__entry(__field_hex(struct __sysctl_args *, args)),
+       TP_fast_assign(tp_assign(args, args)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_64_sys_adjtimex
+SC_TRACE_EVENT(sys_adjtimex,
+       TP_PROTO(struct timex * txc_p),
+       TP_ARGS(txc_p),
+       TP_STRUCT__entry(__field_hex(struct timex *, txc_p)),
+       TP_fast_assign(tp_assign(txc_p, txc_p)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_64_sys_chroot
+SC_TRACE_EVENT(sys_chroot,
+       TP_PROTO(const char * filename),
+       TP_ARGS(filename),
+       TP_STRUCT__entry(__string_from_user(filename, filename)),
+       TP_fast_assign(tp_copy_string_from_user(filename, filename)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_64_sys_acct
+SC_TRACE_EVENT(sys_acct,
+       TP_PROTO(const char * name),
+       TP_ARGS(name),
+       TP_STRUCT__entry(__string_from_user(name, name)),
+       TP_fast_assign(tp_copy_string_from_user(name, name)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_64_sys_swapoff
+SC_TRACE_EVENT(sys_swapoff,
+       TP_PROTO(const char * specialfile),
+       TP_ARGS(specialfile),
+       TP_STRUCT__entry(__string_from_user(specialfile, specialfile)),
+       TP_fast_assign(tp_copy_string_from_user(specialfile, specialfile)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_64_sys_time
+SC_TRACE_EVENT(sys_time,
+       TP_PROTO(time_t * tloc),
+       TP_ARGS(tloc),
+       TP_STRUCT__entry(__field_hex(time_t *, tloc)),
+       TP_fast_assign(tp_assign(tloc, tloc)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_64_sys_set_tid_address
+SC_TRACE_EVENT(sys_set_tid_address,
+       TP_PROTO(int * tidptr),
+       TP_ARGS(tidptr),
+       TP_STRUCT__entry(__field_hex(int *, tidptr)),
+       TP_fast_assign(tp_assign(tidptr, tidptr)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_64_sys_mq_unlink
+SC_TRACE_EVENT(sys_mq_unlink,
+       TP_PROTO(const char * u_name),
+       TP_ARGS(u_name),
+       TP_STRUCT__entry(__string_from_user(u_name, u_name)),
+       TP_fast_assign(tp_copy_string_from_user(u_name, u_name)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_64_sys_newstat
+SC_TRACE_EVENT(sys_newstat,
+       TP_PROTO(const char * filename, struct stat * statbuf),
+       TP_ARGS(filename, statbuf),
+       TP_STRUCT__entry(__string_from_user(filename, filename) __field_hex(struct stat *, statbuf)),
+       TP_fast_assign(tp_copy_string_from_user(filename, filename) tp_assign(statbuf, statbuf)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_64_sys_newfstat
+SC_TRACE_EVENT(sys_newfstat,
+       TP_PROTO(unsigned int fd, struct stat * statbuf),
+       TP_ARGS(fd, statbuf),
+       TP_STRUCT__entry(__field(unsigned int, fd) __field_hex(struct stat *, statbuf)),
+       TP_fast_assign(tp_assign(fd, fd) tp_assign(statbuf, statbuf)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_64_sys_newlstat
+SC_TRACE_EVENT(sys_newlstat,
+       TP_PROTO(const char * filename, struct stat * statbuf),
+       TP_ARGS(filename, statbuf),
+       TP_STRUCT__entry(__string_from_user(filename, filename) __field_hex(struct stat *, statbuf)),
+       TP_fast_assign(tp_copy_string_from_user(filename, filename) tp_assign(statbuf, statbuf)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_64_sys_access
+SC_TRACE_EVENT(sys_access,
+       TP_PROTO(const char * filename, int mode),
+       TP_ARGS(filename, mode),
+       TP_STRUCT__entry(__string_from_user(filename, filename) __field(int, mode)),
+       TP_fast_assign(tp_copy_string_from_user(filename, filename) tp_assign(mode, mode)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_64_sys_nanosleep
+SC_TRACE_EVENT(sys_nanosleep,
+       TP_PROTO(struct timespec * rqtp, struct timespec * rmtp),
+       TP_ARGS(rqtp, rmtp),
+       TP_STRUCT__entry(__field_hex(struct timespec *, rqtp) __field_hex(struct timespec *, rmtp)),
+       TP_fast_assign(tp_assign(rqtp, rqtp) tp_assign(rmtp, rmtp)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_64_sys_getitimer
+SC_TRACE_EVENT(sys_getitimer,
+       TP_PROTO(int which, struct itimerval * value),
+       TP_ARGS(which, value),
+       TP_STRUCT__entry(__field(int, which) __field_hex(struct itimerval *, value)),
+       TP_fast_assign(tp_assign(which, which) tp_assign(value, value)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_64_sys_truncate
+SC_TRACE_EVENT(sys_truncate,
+       TP_PROTO(const char * path, long length),
+       TP_ARGS(path, length),
+       TP_STRUCT__entry(__string_from_user(path, path) __field(long, length)),
+       TP_fast_assign(tp_copy_string_from_user(path, path) tp_assign(length, length)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_64_sys_getcwd
+SC_TRACE_EVENT(sys_getcwd,
+       TP_PROTO(char * buf, unsigned long size),
+       TP_ARGS(buf, size),
+       TP_STRUCT__entry(__field_hex(char *, buf) __field(unsigned long, size)),
+       TP_fast_assign(tp_assign(buf, buf) tp_assign(size, size)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_64_sys_rename
+SC_TRACE_EVENT(sys_rename,
+       TP_PROTO(const char * oldname, const char * newname),
+       TP_ARGS(oldname, newname),
+       TP_STRUCT__entry(__string_from_user(oldname, oldname) __string_from_user(newname, newname)),
+       TP_fast_assign(tp_copy_string_from_user(oldname, oldname) tp_copy_string_from_user(newname, newname)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_64_sys_mkdir
+SC_TRACE_EVENT(sys_mkdir,
+       TP_PROTO(const char * pathname, umode_t mode),
+       TP_ARGS(pathname, mode),
+       TP_STRUCT__entry(__string_from_user(pathname, pathname) __field(umode_t, mode)),
+       TP_fast_assign(tp_copy_string_from_user(pathname, pathname) tp_assign(mode, mode)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_64_sys_creat
+SC_TRACE_EVENT(sys_creat,
+       TP_PROTO(const char * pathname, umode_t mode),
+       TP_ARGS(pathname, mode),
+       TP_STRUCT__entry(__string_from_user(pathname, pathname) __field(umode_t, mode)),
+       TP_fast_assign(tp_copy_string_from_user(pathname, pathname) tp_assign(mode, mode)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_64_sys_link
+SC_TRACE_EVENT(sys_link,
+       TP_PROTO(const char * oldname, const char * newname),
+       TP_ARGS(oldname, newname),
+       TP_STRUCT__entry(__string_from_user(oldname, oldname) __string_from_user(newname, newname)),
+       TP_fast_assign(tp_copy_string_from_user(oldname, oldname) tp_copy_string_from_user(newname, newname)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_64_sys_symlink
+SC_TRACE_EVENT(sys_symlink,
+       TP_PROTO(const char * oldname, const char * newname),
+       TP_ARGS(oldname, newname),
+       TP_STRUCT__entry(__string_from_user(oldname, oldname) __string_from_user(newname, newname)),
+       TP_fast_assign(tp_copy_string_from_user(oldname, oldname) tp_copy_string_from_user(newname, newname)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_64_sys_chmod
+SC_TRACE_EVENT(sys_chmod,
+       TP_PROTO(const char * filename, umode_t mode),
+       TP_ARGS(filename, mode),
+       TP_STRUCT__entry(__string_from_user(filename, filename) __field(umode_t, mode)),
+       TP_fast_assign(tp_copy_string_from_user(filename, filename) tp_assign(mode, mode)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_64_sys_gettimeofday
+SC_TRACE_EVENT(sys_gettimeofday,
+       TP_PROTO(struct timeval * tv, struct timezone * tz),
+       TP_ARGS(tv, tz),
+       TP_STRUCT__entry(__field_hex(struct timeval *, tv) __field_hex(struct timezone *, tz)),
+       TP_fast_assign(tp_assign(tv, tv) tp_assign(tz, tz)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_64_sys_getrlimit
+SC_TRACE_EVENT(sys_getrlimit,
+       TP_PROTO(unsigned int resource, struct rlimit * rlim),
+       TP_ARGS(resource, rlim),
+       TP_STRUCT__entry(__field(unsigned int, resource) __field_hex(struct rlimit *, rlim)),
+       TP_fast_assign(tp_assign(resource, resource) tp_assign(rlim, rlim)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_64_sys_getrusage
+SC_TRACE_EVENT(sys_getrusage,
+       TP_PROTO(int who, struct rusage * ru),
+       TP_ARGS(who, ru),
+       TP_STRUCT__entry(__field(int, who) __field_hex(struct rusage *, ru)),
+       TP_fast_assign(tp_assign(who, who) tp_assign(ru, ru)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_64_sys_getgroups
+SC_TRACE_EVENT(sys_getgroups,
+       TP_PROTO(int gidsetsize, gid_t * grouplist),
+       TP_ARGS(gidsetsize, grouplist),
+       TP_STRUCT__entry(__field(int, gidsetsize) __field_hex(gid_t *, grouplist)),
+       TP_fast_assign(tp_assign(gidsetsize, gidsetsize) tp_assign(grouplist, grouplist)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_64_sys_setgroups
+SC_TRACE_EVENT(sys_setgroups,
+       TP_PROTO(int gidsetsize, gid_t * grouplist),
+       TP_ARGS(gidsetsize, grouplist),
+       TP_STRUCT__entry(__field(int, gidsetsize) __field_hex(gid_t *, grouplist)),
+       TP_fast_assign(tp_assign(gidsetsize, gidsetsize) tp_assign(grouplist, grouplist)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_64_sys_rt_sigpending
+SC_TRACE_EVENT(sys_rt_sigpending,
+       TP_PROTO(sigset_t * uset, size_t sigsetsize),
+       TP_ARGS(uset, sigsetsize),
+       TP_STRUCT__entry(__field_hex(sigset_t *, uset) __field(size_t, sigsetsize)),
+       TP_fast_assign(tp_assign(uset, uset) tp_assign(sigsetsize, sigsetsize)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_64_sys_rt_sigsuspend
+SC_TRACE_EVENT(sys_rt_sigsuspend,
+       TP_PROTO(sigset_t * unewset, size_t sigsetsize),
+       TP_ARGS(unewset, sigsetsize),
+       TP_STRUCT__entry(__field_hex(sigset_t *, unewset) __field(size_t, sigsetsize)),
+       TP_fast_assign(tp_assign(unewset, unewset) tp_assign(sigsetsize, sigsetsize)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_64_sys_sigaltstack
+SC_TRACE_EVENT(sys_sigaltstack,
+       TP_PROTO(const stack_t * uss, stack_t * uoss),
+       TP_ARGS(uss, uoss),
+       TP_STRUCT__entry(__field_hex(const stack_t *, uss) __field_hex(stack_t *, uoss)),
+       TP_fast_assign(tp_assign(uss, uss) tp_assign(uoss, uoss)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_64_sys_utime
+SC_TRACE_EVENT(sys_utime,
+       TP_PROTO(char * filename, struct utimbuf * times),
+       TP_ARGS(filename, times),
+       TP_STRUCT__entry(__string_from_user(filename, filename) __field_hex(struct utimbuf *, times)),
+       TP_fast_assign(tp_copy_string_from_user(filename, filename) tp_assign(times, times)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_64_sys_ustat
+SC_TRACE_EVENT(sys_ustat,
+       TP_PROTO(unsigned dev, struct ustat * ubuf),
+       TP_ARGS(dev, ubuf),
+       TP_STRUCT__entry(__field(unsigned, dev) __field_hex(struct ustat *, ubuf)),
+       TP_fast_assign(tp_assign(dev, dev) tp_assign(ubuf, ubuf)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_64_sys_statfs
+SC_TRACE_EVENT(sys_statfs,
+       TP_PROTO(const char * pathname, struct statfs * buf),
+       TP_ARGS(pathname, buf),
+       TP_STRUCT__entry(__string_from_user(pathname, pathname) __field_hex(struct statfs *, buf)),
+       TP_fast_assign(tp_copy_string_from_user(pathname, pathname) tp_assign(buf, buf)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_64_sys_fstatfs
+SC_TRACE_EVENT(sys_fstatfs,
+       TP_PROTO(unsigned int fd, struct statfs * buf),
+       TP_ARGS(fd, buf),
+       TP_STRUCT__entry(__field(unsigned int, fd) __field_hex(struct statfs *, buf)),
+       TP_fast_assign(tp_assign(fd, fd) tp_assign(buf, buf)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_64_sys_sched_setparam
+SC_TRACE_EVENT(sys_sched_setparam,
+       TP_PROTO(pid_t pid, struct sched_param * param),
+       TP_ARGS(pid, param),
+       TP_STRUCT__entry(__field(pid_t, pid) __field_hex(struct sched_param *, param)),
+       TP_fast_assign(tp_assign(pid, pid) tp_assign(param, param)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_64_sys_sched_getparam
+SC_TRACE_EVENT(sys_sched_getparam,
+       TP_PROTO(pid_t pid, struct sched_param * param),
+       TP_ARGS(pid, param),
+       TP_STRUCT__entry(__field(pid_t, pid) __field_hex(struct sched_param *, param)),
+       TP_fast_assign(tp_assign(pid, pid) tp_assign(param, param)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_64_sys_sched_rr_get_interval
+SC_TRACE_EVENT(sys_sched_rr_get_interval,
+       TP_PROTO(pid_t pid, struct timespec * interval),
+       TP_ARGS(pid, interval),
+       TP_STRUCT__entry(__field(pid_t, pid) __field_hex(struct timespec *, interval)),
+       TP_fast_assign(tp_assign(pid, pid) tp_assign(interval, interval)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_64_sys_pivot_root
+SC_TRACE_EVENT(sys_pivot_root,
+       TP_PROTO(const char * new_root, const char * put_old),
+       TP_ARGS(new_root, put_old),
+       TP_STRUCT__entry(__string_from_user(new_root, new_root) __string_from_user(put_old, put_old)),
+       TP_fast_assign(tp_copy_string_from_user(new_root, new_root) tp_copy_string_from_user(put_old, put_old)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_64_sys_setrlimit
+SC_TRACE_EVENT(sys_setrlimit,
+       TP_PROTO(unsigned int resource, struct rlimit * rlim),
+       TP_ARGS(resource, rlim),
+       TP_STRUCT__entry(__field(unsigned int, resource) __field_hex(struct rlimit *, rlim)),
+       TP_fast_assign(tp_assign(resource, resource) tp_assign(rlim, rlim)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_64_sys_settimeofday
+SC_TRACE_EVENT(sys_settimeofday,
+       TP_PROTO(struct timeval * tv, struct timezone * tz),
+       TP_ARGS(tv, tz),
+       TP_STRUCT__entry(__field_hex(struct timeval *, tv) __field_hex(struct timezone *, tz)),
+       TP_fast_assign(tp_assign(tv, tv) tp_assign(tz, tz)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_64_sys_umount
+SC_TRACE_EVENT(sys_umount,
+       TP_PROTO(char * name, int flags),
+       TP_ARGS(name, flags),
+       TP_STRUCT__entry(__string_from_user(name, name) __field(int, flags)),
+       TP_fast_assign(tp_copy_string_from_user(name, name) tp_assign(flags, flags)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_64_sys_swapon
+SC_TRACE_EVENT(sys_swapon,
+       TP_PROTO(const char * specialfile, int swap_flags),
+       TP_ARGS(specialfile, swap_flags),
+       TP_STRUCT__entry(__string_from_user(specialfile, specialfile) __field(int, swap_flags)),
+       TP_fast_assign(tp_copy_string_from_user(specialfile, specialfile) tp_assign(swap_flags, swap_flags)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_64_sys_sethostname
+SC_TRACE_EVENT(sys_sethostname,
+       TP_PROTO(char * name, int len),
+       TP_ARGS(name, len),
+       TP_STRUCT__entry(__string_from_user(name, name) __field(int, len)),
+       TP_fast_assign(tp_copy_string_from_user(name, name) tp_assign(len, len)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_64_sys_setdomainname
+SC_TRACE_EVENT(sys_setdomainname,
+       TP_PROTO(char * name, int len),
+       TP_ARGS(name, len),
+       TP_STRUCT__entry(__string_from_user(name, name) __field(int, len)),
+       TP_fast_assign(tp_copy_string_from_user(name, name) tp_assign(len, len)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_64_sys_delete_module
+SC_TRACE_EVENT(sys_delete_module,
+       TP_PROTO(const char * name_user, unsigned int flags),
+       TP_ARGS(name_user, flags),
+       TP_STRUCT__entry(__string_from_user(name_user, name_user) __field(unsigned int, flags)),
+       TP_fast_assign(tp_copy_string_from_user(name_user, name_user) tp_assign(flags, flags)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_64_sys_removexattr
+SC_TRACE_EVENT(sys_removexattr,
+       TP_PROTO(const char * pathname, const char * name),
+       TP_ARGS(pathname, name),
+       TP_STRUCT__entry(__string_from_user(pathname, pathname) __string_from_user(name, name)),
+       TP_fast_assign(tp_copy_string_from_user(pathname, pathname) tp_copy_string_from_user(name, name)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_64_sys_lremovexattr
+SC_TRACE_EVENT(sys_lremovexattr,
+       TP_PROTO(const char * pathname, const char * name),
+       TP_ARGS(pathname, name),
+       TP_STRUCT__entry(__string_from_user(pathname, pathname) __string_from_user(name, name)),
+       TP_fast_assign(tp_copy_string_from_user(pathname, pathname) tp_copy_string_from_user(name, name)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_64_sys_fremovexattr
+SC_TRACE_EVENT(sys_fremovexattr,
+       TP_PROTO(int fd, const char * name),
+       TP_ARGS(fd, name),
+       TP_STRUCT__entry(__field(int, fd) __string_from_user(name, name)),
+       TP_fast_assign(tp_assign(fd, fd) tp_copy_string_from_user(name, name)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_64_sys_io_setup
+SC_TRACE_EVENT(sys_io_setup,
+       TP_PROTO(unsigned nr_events, aio_context_t * ctxp),
+       TP_ARGS(nr_events, ctxp),
+       TP_STRUCT__entry(__field(unsigned, nr_events) __field_hex(aio_context_t *, ctxp)),
+       TP_fast_assign(tp_assign(nr_events, nr_events) tp_assign(ctxp, ctxp)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_64_sys_timer_gettime
+SC_TRACE_EVENT(sys_timer_gettime,
+       TP_PROTO(timer_t timer_id, struct itimerspec * setting),
+       TP_ARGS(timer_id, setting),
+       TP_STRUCT__entry(__field(timer_t, timer_id) __field_hex(struct itimerspec *, setting)),
+       TP_fast_assign(tp_assign(timer_id, timer_id) tp_assign(setting, setting)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_64_sys_clock_settime
+SC_TRACE_EVENT(sys_clock_settime,
+       TP_PROTO(const clockid_t which_clock, const struct timespec * tp),
+       TP_ARGS(which_clock, tp),
+       TP_STRUCT__entry(__field(const clockid_t, which_clock) __field_hex(const struct timespec *, tp)),
+       TP_fast_assign(tp_assign(which_clock, which_clock) tp_assign(tp, tp)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_64_sys_clock_gettime
+SC_TRACE_EVENT(sys_clock_gettime,
+       TP_PROTO(const clockid_t which_clock, struct timespec * tp),
+       TP_ARGS(which_clock, tp),
+       TP_STRUCT__entry(__field(const clockid_t, which_clock) __field_hex(struct timespec *, tp)),
+       TP_fast_assign(tp_assign(which_clock, which_clock) tp_assign(tp, tp)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_64_sys_clock_getres
+SC_TRACE_EVENT(sys_clock_getres,
+       TP_PROTO(const clockid_t which_clock, struct timespec * tp),
+       TP_ARGS(which_clock, tp),
+       TP_STRUCT__entry(__field(const clockid_t, which_clock) __field_hex(struct timespec *, tp)),
+       TP_fast_assign(tp_assign(which_clock, which_clock) tp_assign(tp, tp)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_64_sys_utimes
+SC_TRACE_EVENT(sys_utimes,
+       TP_PROTO(char * filename, struct timeval * utimes),
+       TP_ARGS(filename, utimes),
+       TP_STRUCT__entry(__string_from_user(filename, filename) __field_hex(struct timeval *, utimes)),
+       TP_fast_assign(tp_copy_string_from_user(filename, filename) tp_assign(utimes, utimes)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_64_sys_mq_notify
+SC_TRACE_EVENT(sys_mq_notify,
+       TP_PROTO(mqd_t mqdes, const struct sigevent * u_notification),
+       TP_ARGS(mqdes, u_notification),
+       TP_STRUCT__entry(__field(mqd_t, mqdes) __field_hex(const struct sigevent *, u_notification)),
+       TP_fast_assign(tp_assign(mqdes, mqdes) tp_assign(u_notification, u_notification)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_64_sys_set_robust_list
+SC_TRACE_EVENT(sys_set_robust_list,
+       TP_PROTO(struct robust_list_head * head, size_t len),
+       TP_ARGS(head, len),
+       TP_STRUCT__entry(__field_hex(struct robust_list_head *, head) __field(size_t, len)),
+       TP_fast_assign(tp_assign(head, head) tp_assign(len, len)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_64_sys_timerfd_gettime
+SC_TRACE_EVENT(sys_timerfd_gettime,
+       TP_PROTO(int ufd, struct itimerspec * otmr),
+       TP_ARGS(ufd, otmr),
+       TP_STRUCT__entry(__field(int, ufd) __field_hex(struct itimerspec *, otmr)),
+       TP_fast_assign(tp_assign(ufd, ufd) tp_assign(otmr, otmr)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_64_sys_pipe2
+SC_TRACE_EVENT(sys_pipe2,
+       TP_PROTO(int * fildes, int flags),
+       TP_ARGS(fildes, flags),
+       TP_STRUCT__entry(__field_hex(int *, fildes) __field(int, flags)),
+       TP_fast_assign(tp_assign(fildes, fildes) tp_assign(flags, flags)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_64_sys_clock_adjtime
+SC_TRACE_EVENT(sys_clock_adjtime,
+       TP_PROTO(const clockid_t which_clock, struct timex * utx),
+       TP_ARGS(which_clock, utx),
+       TP_STRUCT__entry(__field(const clockid_t, which_clock) __field_hex(struct timex *, utx)),
+       TP_fast_assign(tp_assign(which_clock, which_clock) tp_assign(utx, utx)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_64_sys_read
+SC_TRACE_EVENT(sys_read,
+       TP_PROTO(unsigned int fd, char * buf, size_t count),
+       TP_ARGS(fd, buf, count),
+       TP_STRUCT__entry(__field(unsigned int, fd) __field_hex(char *, buf) __field(size_t, count)),
+       TP_fast_assign(tp_assign(fd, fd) tp_assign(buf, buf) tp_assign(count, count)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_64_sys_write
+SC_TRACE_EVENT(sys_write,
+       TP_PROTO(unsigned int fd, const char * buf, size_t count),
+       TP_ARGS(fd, buf, count),
+       TP_STRUCT__entry(__field(unsigned int, fd) __field_hex(const char *, buf) __field(size_t, count)),
+       TP_fast_assign(tp_assign(fd, fd) tp_assign(buf, buf) tp_assign(count, count)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_64_sys_open
+SC_TRACE_EVENT(sys_open,
+       TP_PROTO(const char * filename, int flags, umode_t mode),
+       TP_ARGS(filename, flags, mode),
+       TP_STRUCT__entry(__string_from_user(filename, filename) __field(int, flags) __field(umode_t, mode)),
+       TP_fast_assign(tp_copy_string_from_user(filename, filename) tp_assign(flags, flags) tp_assign(mode, mode)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_64_sys_poll
+SC_TRACE_EVENT(sys_poll,
+       TP_PROTO(struct pollfd * ufds, unsigned int nfds, int timeout_msecs),
+       TP_ARGS(ufds, nfds, timeout_msecs),
+       TP_STRUCT__entry(__field_hex(struct pollfd *, ufds) __field(unsigned int, nfds) __field(int, timeout_msecs)),
+       TP_fast_assign(tp_assign(ufds, ufds) tp_assign(nfds, nfds) tp_assign(timeout_msecs, timeout_msecs)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_64_sys_readv
+SC_TRACE_EVENT(sys_readv,
+       TP_PROTO(unsigned long fd, const struct iovec * vec, unsigned long vlen),
+       TP_ARGS(fd, vec, vlen),
+       TP_STRUCT__entry(__field(unsigned long, fd) __field_hex(const struct iovec *, vec) __field(unsigned long, vlen)),
+       TP_fast_assign(tp_assign(fd, fd) tp_assign(vec, vec) tp_assign(vlen, vlen)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_64_sys_writev
+SC_TRACE_EVENT(sys_writev,
+       TP_PROTO(unsigned long fd, const struct iovec * vec, unsigned long vlen),
+       TP_ARGS(fd, vec, vlen),
+       TP_STRUCT__entry(__field(unsigned long, fd) __field_hex(const struct iovec *, vec) __field(unsigned long, vlen)),
+       TP_fast_assign(tp_assign(fd, fd) tp_assign(vec, vec) tp_assign(vlen, vlen)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_64_sys_mincore
+SC_TRACE_EVENT(sys_mincore,
+       TP_PROTO(unsigned long start, size_t len, unsigned char * vec),
+       TP_ARGS(start, len, vec),
+       TP_STRUCT__entry(__field(unsigned long, start) __field(size_t, len) __field_hex(unsigned char *, vec)),
+       TP_fast_assign(tp_assign(start, start) tp_assign(len, len) tp_assign(vec, vec)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_64_sys_shmat
+SC_TRACE_EVENT(sys_shmat,
+       TP_PROTO(int shmid, char * shmaddr, int shmflg),
+       TP_ARGS(shmid, shmaddr, shmflg),
+       TP_STRUCT__entry(__field(int, shmid) __field_hex(char *, shmaddr) __field(int, shmflg)),
+       TP_fast_assign(tp_assign(shmid, shmid) tp_assign(shmaddr, shmaddr) tp_assign(shmflg, shmflg)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_64_sys_shmctl
+SC_TRACE_EVENT(sys_shmctl,
+       TP_PROTO(int shmid, int cmd, struct shmid_ds * buf),
+       TP_ARGS(shmid, cmd, buf),
+       TP_STRUCT__entry(__field(int, shmid) __field(int, cmd) __field_hex(struct shmid_ds *, buf)),
+       TP_fast_assign(tp_assign(shmid, shmid) tp_assign(cmd, cmd) tp_assign(buf, buf)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_64_sys_setitimer
+SC_TRACE_EVENT(sys_setitimer,
+       TP_PROTO(int which, struct itimerval * value, struct itimerval * ovalue),
+       TP_ARGS(which, value, ovalue),
+       TP_STRUCT__entry(__field(int, which) __field_hex(struct itimerval *, value) __field_hex(struct itimerval *, ovalue)),
+       TP_fast_assign(tp_assign(which, which) tp_assign(value, value) tp_assign(ovalue, ovalue)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_64_sys_connect
+SC_TRACE_EVENT(sys_connect,
+       TP_PROTO(int fd, struct sockaddr * uservaddr, int addrlen),
+       TP_ARGS(fd, uservaddr, addrlen),
+       TP_STRUCT__entry(__field(int, fd) __field_hex(struct sockaddr *, uservaddr) __field_hex(int, addrlen)),
+       TP_fast_assign(tp_assign(fd, fd) tp_assign(uservaddr, uservaddr) tp_assign(addrlen, addrlen)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_64_sys_accept
+SC_TRACE_EVENT(sys_accept,
+       TP_PROTO(int fd, struct sockaddr * upeer_sockaddr, int * upeer_addrlen),
+       TP_ARGS(fd, upeer_sockaddr, upeer_addrlen),
+       TP_STRUCT__entry(__field(int, fd) __field_hex(struct sockaddr *, upeer_sockaddr) __field_hex(int *, upeer_addrlen)),
+       TP_fast_assign(tp_assign(fd, fd) tp_assign(upeer_sockaddr, upeer_sockaddr) tp_assign(upeer_addrlen, upeer_addrlen)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_64_sys_sendmsg
+SC_TRACE_EVENT(sys_sendmsg,
+       TP_PROTO(int fd, struct msghdr * msg, unsigned int flags),
+       TP_ARGS(fd, msg, flags),
+       TP_STRUCT__entry(__field(int, fd) __field_hex(struct msghdr *, msg) __field(unsigned int, flags)),
+       TP_fast_assign(tp_assign(fd, fd) tp_assign(msg, msg) tp_assign(flags, flags)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_64_sys_recvmsg
+SC_TRACE_EVENT(sys_recvmsg,
+       TP_PROTO(int fd, struct msghdr * msg, unsigned int flags),
+       TP_ARGS(fd, msg, flags),
+       TP_STRUCT__entry(__field(int, fd) __field_hex(struct msghdr *, msg) __field(unsigned int, flags)),
+       TP_fast_assign(tp_assign(fd, fd) tp_assign(msg, msg) tp_assign(flags, flags)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_64_sys_bind
+SC_TRACE_EVENT(sys_bind,
+       TP_PROTO(int fd, struct sockaddr * umyaddr, int addrlen),
+       TP_ARGS(fd, umyaddr, addrlen),
+       TP_STRUCT__entry(__field(int, fd) __field_hex(struct sockaddr *, umyaddr) __field_hex(int, addrlen)),
+       TP_fast_assign(tp_assign(fd, fd) tp_assign(umyaddr, umyaddr) tp_assign(addrlen, addrlen)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_64_sys_getsockname
+SC_TRACE_EVENT(sys_getsockname,
+       TP_PROTO(int fd, struct sockaddr * usockaddr, int * usockaddr_len),
+       TP_ARGS(fd, usockaddr, usockaddr_len),
+       TP_STRUCT__entry(__field(int, fd) __field_hex(struct sockaddr *, usockaddr) __field_hex(int *, usockaddr_len)),
+       TP_fast_assign(tp_assign(fd, fd) tp_assign(usockaddr, usockaddr) tp_assign(usockaddr_len, usockaddr_len)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_64_sys_getpeername
+SC_TRACE_EVENT(sys_getpeername,
+       TP_PROTO(int fd, struct sockaddr * usockaddr, int * usockaddr_len),
+       TP_ARGS(fd, usockaddr, usockaddr_len),
+       TP_STRUCT__entry(__field(int, fd) __field_hex(struct sockaddr *, usockaddr) __field_hex(int *, usockaddr_len)),
+       TP_fast_assign(tp_assign(fd, fd) tp_assign(usockaddr, usockaddr) tp_assign(usockaddr_len, usockaddr_len)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_64_sys_semop
+SC_TRACE_EVENT(sys_semop,
+       TP_PROTO(int semid, struct sembuf * tsops, unsigned nsops),
+       TP_ARGS(semid, tsops, nsops),
+       TP_STRUCT__entry(__field(int, semid) __field_hex(struct sembuf *, tsops) __field(unsigned, nsops)),
+       TP_fast_assign(tp_assign(semid, semid) tp_assign(tsops, tsops) tp_assign(nsops, nsops)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_64_sys_msgctl
+SC_TRACE_EVENT(sys_msgctl,
+       TP_PROTO(int msqid, int cmd, struct msqid_ds * buf),
+       TP_ARGS(msqid, cmd, buf),
+       TP_STRUCT__entry(__field(int, msqid) __field(int, cmd) __field_hex(struct msqid_ds *, buf)),
+       TP_fast_assign(tp_assign(msqid, msqid) tp_assign(cmd, cmd) tp_assign(buf, buf)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_64_sys_getdents
+SC_TRACE_EVENT(sys_getdents,
+       TP_PROTO(unsigned int fd, struct linux_dirent * dirent, unsigned int count),
+       TP_ARGS(fd, dirent, count),
+       TP_STRUCT__entry(__field(unsigned int, fd) __field_hex(struct linux_dirent *, dirent) __field(unsigned int, count)),
+       TP_fast_assign(tp_assign(fd, fd) tp_assign(dirent, dirent) tp_assign(count, count)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_64_sys_readlink
+SC_TRACE_EVENT(sys_readlink,
+       TP_PROTO(const char * path, char * buf, int bufsiz),
+       TP_ARGS(path, buf, bufsiz),
+       TP_STRUCT__entry(__string_from_user(path, path) __field_hex(char *, buf) __field(int, bufsiz)),
+       TP_fast_assign(tp_copy_string_from_user(path, path) tp_assign(buf, buf) tp_assign(bufsiz, bufsiz)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_64_sys_chown
+SC_TRACE_EVENT(sys_chown,
+       TP_PROTO(const char * filename, uid_t user, gid_t group),
+       TP_ARGS(filename, user, group),
+       TP_STRUCT__entry(__string_from_user(filename, filename) __field(uid_t, user) __field(gid_t, group)),
+       TP_fast_assign(tp_copy_string_from_user(filename, filename) tp_assign(user, user) tp_assign(group, group)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_64_sys_lchown
+SC_TRACE_EVENT(sys_lchown,
+       TP_PROTO(const char * filename, uid_t user, gid_t group),
+       TP_ARGS(filename, user, group),
+       TP_STRUCT__entry(__string_from_user(filename, filename) __field(uid_t, user) __field(gid_t, group)),
+       TP_fast_assign(tp_copy_string_from_user(filename, filename) tp_assign(user, user) tp_assign(group, group)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_64_sys_syslog
+SC_TRACE_EVENT(sys_syslog,
+       TP_PROTO(int type, char * buf, int len),
+       TP_ARGS(type, buf, len),
+       TP_STRUCT__entry(__field(int, type) __field_hex(char *, buf) __field(int, len)),
+       TP_fast_assign(tp_assign(type, type) tp_assign(buf, buf) tp_assign(len, len)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_64_sys_getresuid
+SC_TRACE_EVENT(sys_getresuid,
+       TP_PROTO(uid_t * ruidp, uid_t * euidp, uid_t * suidp),
+       TP_ARGS(ruidp, euidp, suidp),
+       TP_STRUCT__entry(__field_hex(uid_t *, ruidp) __field_hex(uid_t *, euidp) __field_hex(uid_t *, suidp)),
+       TP_fast_assign(tp_assign(ruidp, ruidp) tp_assign(euidp, euidp) tp_assign(suidp, suidp)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_64_sys_getresgid
+SC_TRACE_EVENT(sys_getresgid,
+       TP_PROTO(gid_t * rgidp, gid_t * egidp, gid_t * sgidp),
+       TP_ARGS(rgidp, egidp, sgidp),
+       TP_STRUCT__entry(__field_hex(gid_t *, rgidp) __field_hex(gid_t *, egidp) __field_hex(gid_t *, sgidp)),
+       TP_fast_assign(tp_assign(rgidp, rgidp) tp_assign(egidp, egidp) tp_assign(sgidp, sgidp)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_64_sys_rt_sigqueueinfo
+SC_TRACE_EVENT(sys_rt_sigqueueinfo,
+       TP_PROTO(pid_t pid, int sig, siginfo_t * uinfo),
+       TP_ARGS(pid, sig, uinfo),
+       TP_STRUCT__entry(__field(pid_t, pid) __field(int, sig) __field_hex(siginfo_t *, uinfo)),
+       TP_fast_assign(tp_assign(pid, pid) tp_assign(sig, sig) tp_assign(uinfo, uinfo)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_64_sys_mknod
+SC_TRACE_EVENT(sys_mknod,
+       TP_PROTO(const char * filename, umode_t mode, unsigned dev),
+       TP_ARGS(filename, mode, dev),
+       TP_STRUCT__entry(__string_from_user(filename, filename) __field(umode_t, mode) __field(unsigned, dev)),
+       TP_fast_assign(tp_copy_string_from_user(filename, filename) tp_assign(mode, mode) tp_assign(dev, dev)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_64_sys_sched_setscheduler
+SC_TRACE_EVENT(sys_sched_setscheduler,
+       TP_PROTO(pid_t pid, int policy, struct sched_param * param),
+       TP_ARGS(pid, policy, param),
+       TP_STRUCT__entry(__field(pid_t, pid) __field(int, policy) __field_hex(struct sched_param *, param)),
+       TP_fast_assign(tp_assign(pid, pid) tp_assign(policy, policy) tp_assign(param, param)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_64_sys_init_module
+SC_TRACE_EVENT(sys_init_module,
+       TP_PROTO(void * umod, unsigned long len, const char * uargs),
+       TP_ARGS(umod, len, uargs),
+       TP_STRUCT__entry(__field_hex(void *, umod) __field(unsigned long, len) __field_hex(const char *, uargs)),
+       TP_fast_assign(tp_assign(umod, umod) tp_assign(len, len) tp_assign(uargs, uargs)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_64_sys_listxattr
+SC_TRACE_EVENT(sys_listxattr,
+       TP_PROTO(const char * pathname, char * list, size_t size),
+       TP_ARGS(pathname, list, size),
+       TP_STRUCT__entry(__string_from_user(pathname, pathname) __field_hex(char *, list) __field(size_t, size)),
+       TP_fast_assign(tp_copy_string_from_user(pathname, pathname) tp_assign(list, list) tp_assign(size, size)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_64_sys_llistxattr
+SC_TRACE_EVENT(sys_llistxattr,
+       TP_PROTO(const char * pathname, char * list, size_t size),
+       TP_ARGS(pathname, list, size),
+       TP_STRUCT__entry(__string_from_user(pathname, pathname) __field_hex(char *, list) __field(size_t, size)),
+       TP_fast_assign(tp_copy_string_from_user(pathname, pathname) tp_assign(list, list) tp_assign(size, size)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_64_sys_flistxattr
+SC_TRACE_EVENT(sys_flistxattr,
+       TP_PROTO(int fd, char * list, size_t size),
+       TP_ARGS(fd, list, size),
+       TP_STRUCT__entry(__field(int, fd) __field_hex(char *, list) __field(size_t, size)),
+       TP_fast_assign(tp_assign(fd, fd) tp_assign(list, list) tp_assign(size, size)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_64_sys_sched_setaffinity
+SC_TRACE_EVENT(sys_sched_setaffinity,
+       TP_PROTO(pid_t pid, unsigned int len, unsigned long * user_mask_ptr),
+       TP_ARGS(pid, len, user_mask_ptr),
+       TP_STRUCT__entry(__field(pid_t, pid) __field(unsigned int, len) __field_hex(unsigned long *, user_mask_ptr)),
+       TP_fast_assign(tp_assign(pid, pid) tp_assign(len, len) tp_assign(user_mask_ptr, user_mask_ptr)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_64_sys_sched_getaffinity
+SC_TRACE_EVENT(sys_sched_getaffinity,
+       TP_PROTO(pid_t pid, unsigned int len, unsigned long * user_mask_ptr),
+       TP_ARGS(pid, len, user_mask_ptr),
+       TP_STRUCT__entry(__field(pid_t, pid) __field(unsigned int, len) __field_hex(unsigned long *, user_mask_ptr)),
+       TP_fast_assign(tp_assign(pid, pid) tp_assign(len, len) tp_assign(user_mask_ptr, user_mask_ptr)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_64_sys_io_submit
+SC_TRACE_EVENT(sys_io_submit,
+       TP_PROTO(aio_context_t ctx_id, long nr, struct iocb * * iocbpp),
+       TP_ARGS(ctx_id, nr, iocbpp),
+       TP_STRUCT__entry(__field(aio_context_t, ctx_id) __field(long, nr) __field_hex(struct iocb * *, iocbpp)),
+       TP_fast_assign(tp_assign(ctx_id, ctx_id) tp_assign(nr, nr) tp_assign(iocbpp, iocbpp)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_64_sys_io_cancel
+SC_TRACE_EVENT(sys_io_cancel,
+       TP_PROTO(aio_context_t ctx_id, struct iocb * iocb, struct io_event * result),
+       TP_ARGS(ctx_id, iocb, result),
+       TP_STRUCT__entry(__field(aio_context_t, ctx_id) __field_hex(struct iocb *, iocb) __field_hex(struct io_event *, result)),
+       TP_fast_assign(tp_assign(ctx_id, ctx_id) tp_assign(iocb, iocb) tp_assign(result, result)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_64_sys_lookup_dcookie
+SC_TRACE_EVENT(sys_lookup_dcookie,
+       TP_PROTO(u64 cookie64, char * buf, size_t len),
+       TP_ARGS(cookie64, buf, len),
+       TP_STRUCT__entry(__field(u64, cookie64) __field_hex(char *, buf) __field(size_t, len)),
+       TP_fast_assign(tp_assign(cookie64, cookie64) tp_assign(buf, buf) tp_assign(len, len)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_64_sys_getdents64
+SC_TRACE_EVENT(sys_getdents64,
+       TP_PROTO(unsigned int fd, struct linux_dirent64 * dirent, unsigned int count),
+       TP_ARGS(fd, dirent, count),
+       TP_STRUCT__entry(__field(unsigned int, fd) __field_hex(struct linux_dirent64 *, dirent) __field(unsigned int, count)),
+       TP_fast_assign(tp_assign(fd, fd) tp_assign(dirent, dirent) tp_assign(count, count)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_64_sys_timer_create
+SC_TRACE_EVENT(sys_timer_create,
+       TP_PROTO(const clockid_t which_clock, struct sigevent * timer_event_spec, timer_t * created_timer_id),
+       TP_ARGS(which_clock, timer_event_spec, created_timer_id),
+       TP_STRUCT__entry(__field(const clockid_t, which_clock) __field_hex(struct sigevent *, timer_event_spec) __field_hex(timer_t *, created_timer_id)),
+       TP_fast_assign(tp_assign(which_clock, which_clock) tp_assign(timer_event_spec, timer_event_spec) tp_assign(created_timer_id, created_timer_id)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_64_sys_set_mempolicy
+SC_TRACE_EVENT(sys_set_mempolicy,
+       TP_PROTO(int mode, unsigned long * nmask, unsigned long maxnode),
+       TP_ARGS(mode, nmask, maxnode),
+       TP_STRUCT__entry(__field(int, mode) __field_hex(unsigned long *, nmask) __field(unsigned long, maxnode)),
+       TP_fast_assign(tp_assign(mode, mode) tp_assign(nmask, nmask) tp_assign(maxnode, maxnode)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_64_sys_mq_getsetattr
+SC_TRACE_EVENT(sys_mq_getsetattr,
+       TP_PROTO(mqd_t mqdes, const struct mq_attr * u_mqstat, struct mq_attr * u_omqstat),
+       TP_ARGS(mqdes, u_mqstat, u_omqstat),
+       TP_STRUCT__entry(__field(mqd_t, mqdes) __field_hex(const struct mq_attr *, u_mqstat) __field_hex(struct mq_attr *, u_omqstat)),
+       TP_fast_assign(tp_assign(mqdes, mqdes) tp_assign(u_mqstat, u_mqstat) tp_assign(u_omqstat, u_omqstat)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_64_sys_inotify_add_watch
+SC_TRACE_EVENT(sys_inotify_add_watch,
+       TP_PROTO(int fd, const char * pathname, u32 mask),
+       TP_ARGS(fd, pathname, mask),
+       TP_STRUCT__entry(__field(int, fd) __string_from_user(pathname, pathname) __field(u32, mask)),
+       TP_fast_assign(tp_assign(fd, fd) tp_copy_string_from_user(pathname, pathname) tp_assign(mask, mask)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_64_sys_mkdirat
+SC_TRACE_EVENT(sys_mkdirat,
+       TP_PROTO(int dfd, const char * pathname, umode_t mode),
+       TP_ARGS(dfd, pathname, mode),
+       TP_STRUCT__entry(__field(int, dfd) __string_from_user(pathname, pathname) __field(umode_t, mode)),
+       TP_fast_assign(tp_assign(dfd, dfd) tp_copy_string_from_user(pathname, pathname) tp_assign(mode, mode)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_64_sys_futimesat
+SC_TRACE_EVENT(sys_futimesat,
+       TP_PROTO(int dfd, const char * filename, struct timeval * utimes),
+       TP_ARGS(dfd, filename, utimes),
+       TP_STRUCT__entry(__field(int, dfd) __string_from_user(filename, filename) __field_hex(struct timeval *, utimes)),
+       TP_fast_assign(tp_assign(dfd, dfd) tp_copy_string_from_user(filename, filename) tp_assign(utimes, utimes)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_64_sys_unlinkat
+SC_TRACE_EVENT(sys_unlinkat,
+       TP_PROTO(int dfd, const char * pathname, int flag),
+       TP_ARGS(dfd, pathname, flag),
+       TP_STRUCT__entry(__field(int, dfd) __string_from_user(pathname, pathname) __field(int, flag)),
+       TP_fast_assign(tp_assign(dfd, dfd) tp_copy_string_from_user(pathname, pathname) tp_assign(flag, flag)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_64_sys_symlinkat
+SC_TRACE_EVENT(sys_symlinkat,
+       TP_PROTO(const char * oldname, int newdfd, const char * newname),
+       TP_ARGS(oldname, newdfd, newname),
+       TP_STRUCT__entry(__string_from_user(oldname, oldname) __field(int, newdfd) __string_from_user(newname, newname)),
+       TP_fast_assign(tp_copy_string_from_user(oldname, oldname) tp_assign(newdfd, newdfd) tp_copy_string_from_user(newname, newname)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_64_sys_fchmodat
+SC_TRACE_EVENT(sys_fchmodat,
+       TP_PROTO(int dfd, const char * filename, umode_t mode),
+       TP_ARGS(dfd, filename, mode),
+       TP_STRUCT__entry(__field(int, dfd) __string_from_user(filename, filename) __field(umode_t, mode)),
+       TP_fast_assign(tp_assign(dfd, dfd) tp_copy_string_from_user(filename, filename) tp_assign(mode, mode)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_64_sys_faccessat
+SC_TRACE_EVENT(sys_faccessat,
+       TP_PROTO(int dfd, const char * filename, int mode),
+       TP_ARGS(dfd, filename, mode),
+       TP_STRUCT__entry(__field(int, dfd) __string_from_user(filename, filename) __field(int, mode)),
+       TP_fast_assign(tp_assign(dfd, dfd) tp_copy_string_from_user(filename, filename) tp_assign(mode, mode)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_64_sys_get_robust_list
+SC_TRACE_EVENT(sys_get_robust_list,
+       TP_PROTO(int pid, struct robust_list_head * * head_ptr, size_t * len_ptr),
+       TP_ARGS(pid, head_ptr, len_ptr),
+       TP_STRUCT__entry(__field(int, pid) __field_hex(struct robust_list_head * *, head_ptr) __field_hex(size_t *, len_ptr)),
+       TP_fast_assign(tp_assign(pid, pid) tp_assign(head_ptr, head_ptr) tp_assign(len_ptr, len_ptr)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_64_sys_signalfd
+SC_TRACE_EVENT(sys_signalfd,
+       TP_PROTO(int ufd, sigset_t * user_mask, size_t sizemask),
+       TP_ARGS(ufd, user_mask, sizemask),
+       TP_STRUCT__entry(__field(int, ufd) __field_hex(sigset_t *, user_mask) __field(size_t, sizemask)),
+       TP_fast_assign(tp_assign(ufd, ufd) tp_assign(user_mask, user_mask) tp_assign(sizemask, sizemask)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_64_sys_open_by_handle_at
+SC_TRACE_EVENT(sys_open_by_handle_at,
+       TP_PROTO(int mountdirfd, struct file_handle * handle, int flags),
+       TP_ARGS(mountdirfd, handle, flags),
+       TP_STRUCT__entry(__field(int, mountdirfd) __field_hex(struct file_handle *, handle) __field(int, flags)),
+       TP_fast_assign(tp_assign(mountdirfd, mountdirfd) tp_assign(handle, handle) tp_assign(flags, flags)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_64_sys_getcpu
+SC_TRACE_EVENT(sys_getcpu,
+       TP_PROTO(unsigned * cpup, unsigned * nodep, struct getcpu_cache * unused),
+       TP_ARGS(cpup, nodep, unused),
+       TP_STRUCT__entry(__field_hex(unsigned *, cpup) __field_hex(unsigned *, nodep) __field_hex(struct getcpu_cache *, unused)),
+       TP_fast_assign(tp_assign(cpup, cpup) tp_assign(nodep, nodep) tp_assign(unused, unused)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_64_sys_finit_module
+SC_TRACE_EVENT(sys_finit_module,
+       TP_PROTO(int fd, const char * uargs, int flags),
+       TP_ARGS(fd, uargs, flags),
+       TP_STRUCT__entry(__field(int, fd) __field_hex(const char *, uargs) __field(int, flags)),
+       TP_fast_assign(tp_assign(fd, fd) tp_assign(uargs, uargs) tp_assign(flags, flags)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_64_sys_rt_sigaction
+SC_TRACE_EVENT(sys_rt_sigaction,
+       TP_PROTO(int sig, const struct sigaction * act, struct sigaction * oact, size_t sigsetsize),
+       TP_ARGS(sig, act, oact, sigsetsize),
+       TP_STRUCT__entry(__field(int, sig) __field_hex(const struct sigaction *, act) __field_hex(struct sigaction *, oact) __field(size_t, sigsetsize)),
+       TP_fast_assign(tp_assign(sig, sig) tp_assign(act, act) tp_assign(oact, oact) tp_assign(sigsetsize, sigsetsize)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_64_sys_rt_sigprocmask
+SC_TRACE_EVENT(sys_rt_sigprocmask,
+       TP_PROTO(int how, sigset_t * nset, sigset_t * oset, size_t sigsetsize),
+       TP_ARGS(how, nset, oset, sigsetsize),
+       TP_STRUCT__entry(__field(int, how) __field_hex(sigset_t *, nset) __field_hex(sigset_t *, oset) __field(size_t, sigsetsize)),
+       TP_fast_assign(tp_assign(how, how) tp_assign(nset, nset) tp_assign(oset, oset) tp_assign(sigsetsize, sigsetsize)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_64_sys_pread64
+SC_TRACE_EVENT(sys_pread64,
+       TP_PROTO(unsigned int fd, char * buf, size_t count, loff_t pos),
+       TP_ARGS(fd, buf, count, pos),
+       TP_STRUCT__entry(__field(unsigned int, fd) __field_hex(char *, buf) __field(size_t, count) __field(loff_t, pos)),
+       TP_fast_assign(tp_assign(fd, fd) tp_assign(buf, buf) tp_assign(count, count) tp_assign(pos, pos)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_64_sys_pwrite64
+SC_TRACE_EVENT(sys_pwrite64,
+       TP_PROTO(unsigned int fd, const char * buf, size_t count, loff_t pos),
+       TP_ARGS(fd, buf, count, pos),
+       TP_STRUCT__entry(__field(unsigned int, fd) __field_hex(const char *, buf) __field(size_t, count) __field(loff_t, pos)),
+       TP_fast_assign(tp_assign(fd, fd) tp_assign(buf, buf) tp_assign(count, count) tp_assign(pos, pos)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_64_sys_sendfile64
+SC_TRACE_EVENT(sys_sendfile64,
+       TP_PROTO(int out_fd, int in_fd, loff_t * offset, size_t count),
+       TP_ARGS(out_fd, in_fd, offset, count),
+       TP_STRUCT__entry(__field(int, out_fd) __field(int, in_fd) __field_hex(loff_t *, offset) __field(size_t, count)),
+       TP_fast_assign(tp_assign(out_fd, out_fd) tp_assign(in_fd, in_fd) tp_assign(offset, offset) tp_assign(count, count)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_64_sys_socketpair
+SC_TRACE_EVENT(sys_socketpair,
+       TP_PROTO(int family, int type, int protocol, int * usockvec),
+       TP_ARGS(family, type, protocol, usockvec),
+       TP_STRUCT__entry(__field(int, family) __field(int, type) __field(int, protocol) __field_hex(int *, usockvec)),
+       TP_fast_assign(tp_assign(family, family) tp_assign(type, type) tp_assign(protocol, protocol) tp_assign(usockvec, usockvec)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_64_sys_wait4
+SC_TRACE_EVENT(sys_wait4,
+       TP_PROTO(pid_t upid, int * stat_addr, int options, struct rusage * ru),
+       TP_ARGS(upid, stat_addr, options, ru),
+       TP_STRUCT__entry(__field(pid_t, upid) __field_hex(int *, stat_addr) __field(int, options) __field_hex(struct rusage *, ru)),
+       TP_fast_assign(tp_assign(upid, upid) tp_assign(stat_addr, stat_addr) tp_assign(options, options) tp_assign(ru, ru)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_64_sys_msgsnd
+SC_TRACE_EVENT(sys_msgsnd,
+       TP_PROTO(int msqid, struct msgbuf * msgp, size_t msgsz, int msgflg),
+       TP_ARGS(msqid, msgp, msgsz, msgflg),
+       TP_STRUCT__entry(__field(int, msqid) __field_hex(struct msgbuf *, msgp) __field(size_t, msgsz) __field(int, msgflg)),
+       TP_fast_assign(tp_assign(msqid, msqid) tp_assign(msgp, msgp) tp_assign(msgsz, msgsz) tp_assign(msgflg, msgflg)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_64_sys_rt_sigtimedwait
+SC_TRACE_EVENT(sys_rt_sigtimedwait,
+       TP_PROTO(const sigset_t * uthese, siginfo_t * uinfo, const struct timespec * uts, size_t sigsetsize),
+       TP_ARGS(uthese, uinfo, uts, sigsetsize),
+       TP_STRUCT__entry(__field_hex(const sigset_t *, uthese) __field_hex(siginfo_t *, uinfo) __field_hex(const struct timespec *, uts) __field(size_t, sigsetsize)),
+       TP_fast_assign(tp_assign(uthese, uthese) tp_assign(uinfo, uinfo) tp_assign(uts, uts) tp_assign(sigsetsize, sigsetsize)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_64_sys_reboot
+SC_TRACE_EVENT(sys_reboot,
+       TP_PROTO(int magic1, int magic2, unsigned int cmd, void * arg),
+       TP_ARGS(magic1, magic2, cmd, arg),
+       TP_STRUCT__entry(__field(int, magic1) __field(int, magic2) __field(unsigned int, cmd) __field_hex(void *, arg)),
+       TP_fast_assign(tp_assign(magic1, magic1) tp_assign(magic2, magic2) tp_assign(cmd, cmd) tp_assign(arg, arg)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_64_sys_quotactl
+SC_TRACE_EVENT(sys_quotactl,
+       TP_PROTO(unsigned int cmd, const char * special, qid_t id, void * addr),
+       TP_ARGS(cmd, special, id, addr),
+       TP_STRUCT__entry(__field(unsigned int, cmd) __field_hex(const char *, special) __field(qid_t, id) __field_hex(void *, addr)),
+       TP_fast_assign(tp_assign(cmd, cmd) tp_assign(special, special) tp_assign(id, id) tp_assign(addr, addr)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_64_sys_getxattr
+SC_TRACE_EVENT(sys_getxattr,
+       TP_PROTO(const char * pathname, const char * name, void * value, size_t size),
+       TP_ARGS(pathname, name, value, size),
+       TP_STRUCT__entry(__string_from_user(pathname, pathname) __string_from_user(name, name) __field_hex(void *, value) __field(size_t, size)),
+       TP_fast_assign(tp_copy_string_from_user(pathname, pathname) tp_copy_string_from_user(name, name) tp_assign(value, value) tp_assign(size, size)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_64_sys_lgetxattr
+SC_TRACE_EVENT(sys_lgetxattr,
+       TP_PROTO(const char * pathname, const char * name, void * value, size_t size),
+       TP_ARGS(pathname, name, value, size),
+       TP_STRUCT__entry(__string_from_user(pathname, pathname) __string_from_user(name, name) __field_hex(void *, value) __field(size_t, size)),
+       TP_fast_assign(tp_copy_string_from_user(pathname, pathname) tp_copy_string_from_user(name, name) tp_assign(value, value) tp_assign(size, size)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_64_sys_fgetxattr
+SC_TRACE_EVENT(sys_fgetxattr,
+       TP_PROTO(int fd, const char * name, void * value, size_t size),
+       TP_ARGS(fd, name, value, size),
+       TP_STRUCT__entry(__field(int, fd) __string_from_user(name, name) __field_hex(void *, value) __field(size_t, size)),
+       TP_fast_assign(tp_assign(fd, fd) tp_copy_string_from_user(name, name) tp_assign(value, value) tp_assign(size, size)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_64_sys_semtimedop
+SC_TRACE_EVENT(sys_semtimedop,
+       TP_PROTO(int semid, struct sembuf * tsops, unsigned nsops, const struct timespec * timeout),
+       TP_ARGS(semid, tsops, nsops, timeout),
+       TP_STRUCT__entry(__field(int, semid) __field_hex(struct sembuf *, tsops) __field(unsigned, nsops) __field_hex(const struct timespec *, timeout)),
+       TP_fast_assign(tp_assign(semid, semid) tp_assign(tsops, tsops) tp_assign(nsops, nsops) tp_assign(timeout, timeout)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_64_sys_timer_settime
+SC_TRACE_EVENT(sys_timer_settime,
+       TP_PROTO(timer_t timer_id, int flags, const struct itimerspec * new_setting, struct itimerspec * old_setting),
+       TP_ARGS(timer_id, flags, new_setting, old_setting),
+       TP_STRUCT__entry(__field(timer_t, timer_id) __field(int, flags) __field_hex(const struct itimerspec *, new_setting) __field_hex(struct itimerspec *, old_setting)),
+       TP_fast_assign(tp_assign(timer_id, timer_id) tp_assign(flags, flags) tp_assign(new_setting, new_setting) tp_assign(old_setting, old_setting)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_64_sys_clock_nanosleep
+SC_TRACE_EVENT(sys_clock_nanosleep,
+       TP_PROTO(const clockid_t which_clock, int flags, const struct timespec * rqtp, struct timespec * rmtp),
+       TP_ARGS(which_clock, flags, rqtp, rmtp),
+       TP_STRUCT__entry(__field(const clockid_t, which_clock) __field(int, flags) __field_hex(const struct timespec *, rqtp) __field_hex(struct timespec *, rmtp)),
+       TP_fast_assign(tp_assign(which_clock, which_clock) tp_assign(flags, flags) tp_assign(rqtp, rqtp) tp_assign(rmtp, rmtp)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_64_sys_epoll_wait
+SC_TRACE_EVENT(sys_epoll_wait,
+       TP_PROTO(int epfd, struct epoll_event * events, int maxevents, int timeout),
+       TP_ARGS(epfd, events, maxevents, timeout),
+       TP_STRUCT__entry(__field(int, epfd) __field_hex(struct epoll_event *, events) __field(int, maxevents) __field(int, timeout)),
+       TP_fast_assign(tp_assign(epfd, epfd) tp_assign(events, events) tp_assign(maxevents, maxevents) tp_assign(timeout, timeout)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_64_sys_epoll_ctl
+SC_TRACE_EVENT(sys_epoll_ctl,
+       TP_PROTO(int epfd, int op, int fd, struct epoll_event * event),
+       TP_ARGS(epfd, op, fd, event),
+       TP_STRUCT__entry(__field(int, epfd) __field(int, op) __field(int, fd) __field_hex(struct epoll_event *, event)),
+       TP_fast_assign(tp_assign(epfd, epfd) tp_assign(op, op) tp_assign(fd, fd) tp_assign(event, event)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_64_sys_mq_open
+SC_TRACE_EVENT(sys_mq_open,
+       TP_PROTO(const char * u_name, int oflag, umode_t mode, struct mq_attr * u_attr),
+       TP_ARGS(u_name, oflag, mode, u_attr),
+       TP_STRUCT__entry(__string_from_user(u_name, u_name) __field(int, oflag) __field(umode_t, mode) __field_hex(struct mq_attr *, u_attr)),
+       TP_fast_assign(tp_copy_string_from_user(u_name, u_name) tp_assign(oflag, oflag) tp_assign(mode, mode) tp_assign(u_attr, u_attr)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_64_sys_kexec_load
+SC_TRACE_EVENT(sys_kexec_load,
+       TP_PROTO(unsigned long entry, unsigned long nr_segments, struct kexec_segment * segments, unsigned long flags),
+       TP_ARGS(entry, nr_segments, segments, flags),
+       TP_STRUCT__entry(__field(unsigned long, entry) __field(unsigned long, nr_segments) __field_hex(struct kexec_segment *, segments) __field(unsigned long, flags)),
+       TP_fast_assign(tp_assign(entry, entry) tp_assign(nr_segments, nr_segments) tp_assign(segments, segments) tp_assign(flags, flags)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_64_sys_request_key
+SC_TRACE_EVENT(sys_request_key,
+       TP_PROTO(const char * _type, const char * _description, const char * _callout_info, key_serial_t destringid),
+       TP_ARGS(_type, _description, _callout_info, destringid),
+       TP_STRUCT__entry(__string_from_user(_type, _type) __field_hex(const char *, _description) __field_hex(const char *, _callout_info) __field(key_serial_t, destringid)),
+       TP_fast_assign(tp_copy_string_from_user(_type, _type) tp_assign(_description, _description) tp_assign(_callout_info, _callout_info) tp_assign(destringid, destringid)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_64_sys_migrate_pages
+SC_TRACE_EVENT(sys_migrate_pages,
+       TP_PROTO(pid_t pid, unsigned long maxnode, const unsigned long * old_nodes, const unsigned long * new_nodes),
+       TP_ARGS(pid, maxnode, old_nodes, new_nodes),
+       TP_STRUCT__entry(__field(pid_t, pid) __field(unsigned long, maxnode) __field_hex(const unsigned long *, old_nodes) __field_hex(const unsigned long *, new_nodes)),
+       TP_fast_assign(tp_assign(pid, pid) tp_assign(maxnode, maxnode) tp_assign(old_nodes, old_nodes) tp_assign(new_nodes, new_nodes)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_64_sys_openat
+SC_TRACE_EVENT(sys_openat,
+       TP_PROTO(int dfd, const char * filename, int flags, umode_t mode),
+       TP_ARGS(dfd, filename, flags, mode),
+       TP_STRUCT__entry(__field(int, dfd) __string_from_user(filename, filename) __field(int, flags) __field(umode_t, mode)),
+       TP_fast_assign(tp_assign(dfd, dfd) tp_copy_string_from_user(filename, filename) tp_assign(flags, flags) tp_assign(mode, mode)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_64_sys_mknodat
+SC_TRACE_EVENT(sys_mknodat,
+       TP_PROTO(int dfd, const char * filename, umode_t mode, unsigned dev),
+       TP_ARGS(dfd, filename, mode, dev),
+       TP_STRUCT__entry(__field(int, dfd) __string_from_user(filename, filename) __field(umode_t, mode) __field(unsigned, dev)),
+       TP_fast_assign(tp_assign(dfd, dfd) tp_copy_string_from_user(filename, filename) tp_assign(mode, mode) tp_assign(dev, dev)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_64_sys_newfstatat
+SC_TRACE_EVENT(sys_newfstatat,
+       TP_PROTO(int dfd, const char * filename, struct stat * statbuf, int flag),
+       TP_ARGS(dfd, filename, statbuf, flag),
+       TP_STRUCT__entry(__field(int, dfd) __string_from_user(filename, filename) __field_hex(struct stat *, statbuf) __field(int, flag)),
+       TP_fast_assign(tp_assign(dfd, dfd) tp_copy_string_from_user(filename, filename) tp_assign(statbuf, statbuf) tp_assign(flag, flag)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_64_sys_renameat
+SC_TRACE_EVENT(sys_renameat,
+       TP_PROTO(int olddfd, const char * oldname, int newdfd, const char * newname),
+       TP_ARGS(olddfd, oldname, newdfd, newname),
+       TP_STRUCT__entry(__field(int, olddfd) __string_from_user(oldname, oldname) __field(int, newdfd) __string_from_user(newname, newname)),
+       TP_fast_assign(tp_assign(olddfd, olddfd) tp_copy_string_from_user(oldname, oldname) tp_assign(newdfd, newdfd) tp_copy_string_from_user(newname, newname)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_64_sys_readlinkat
+SC_TRACE_EVENT(sys_readlinkat,
+       TP_PROTO(int dfd, const char * pathname, char * buf, int bufsiz),
+       TP_ARGS(dfd, pathname, buf, bufsiz),
+       TP_STRUCT__entry(__field(int, dfd) __string_from_user(pathname, pathname) __field_hex(char *, buf) __field(int, bufsiz)),
+       TP_fast_assign(tp_assign(dfd, dfd) tp_copy_string_from_user(pathname, pathname) tp_assign(buf, buf) tp_assign(bufsiz, bufsiz)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_64_sys_vmsplice
+SC_TRACE_EVENT(sys_vmsplice,
+       TP_PROTO(int fd, const struct iovec * iov, unsigned long nr_segs, unsigned int flags),
+       TP_ARGS(fd, iov, nr_segs, flags),
+       TP_STRUCT__entry(__field(int, fd) __field_hex(const struct iovec *, iov) __field(unsigned long, nr_segs) __field(unsigned int, flags)),
+       TP_fast_assign(tp_assign(fd, fd) tp_assign(iov, iov) tp_assign(nr_segs, nr_segs) tp_assign(flags, flags)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_64_sys_utimensat
+SC_TRACE_EVENT(sys_utimensat,
+       TP_PROTO(int dfd, const char * filename, struct timespec * utimes, int flags),
+       TP_ARGS(dfd, filename, utimes, flags),
+       TP_STRUCT__entry(__field(int, dfd) __string_from_user(filename, filename) __field_hex(struct timespec *, utimes) __field(int, flags)),
+       TP_fast_assign(tp_assign(dfd, dfd) tp_copy_string_from_user(filename, filename) tp_assign(utimes, utimes) tp_assign(flags, flags)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_64_sys_timerfd_settime
+SC_TRACE_EVENT(sys_timerfd_settime,
+       TP_PROTO(int ufd, int flags, const struct itimerspec * utmr, struct itimerspec * otmr),
+       TP_ARGS(ufd, flags, utmr, otmr),
+       TP_STRUCT__entry(__field(int, ufd) __field(int, flags) __field_hex(const struct itimerspec *, utmr) __field_hex(struct itimerspec *, otmr)),
+       TP_fast_assign(tp_assign(ufd, ufd) tp_assign(flags, flags) tp_assign(utmr, utmr) tp_assign(otmr, otmr)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_64_sys_accept4
+SC_TRACE_EVENT(sys_accept4,
+       TP_PROTO(int fd, struct sockaddr * upeer_sockaddr, int * upeer_addrlen, int flags),
+       TP_ARGS(fd, upeer_sockaddr, upeer_addrlen, flags),
+       TP_STRUCT__entry(__field(int, fd) __field_hex(struct sockaddr *, upeer_sockaddr) __field_hex(int *, upeer_addrlen) __field(int, flags)),
+       TP_fast_assign(tp_assign(fd, fd) tp_assign(upeer_sockaddr, upeer_sockaddr) tp_assign(upeer_addrlen, upeer_addrlen) tp_assign(flags, flags)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_64_sys_signalfd4
+SC_TRACE_EVENT(sys_signalfd4,
+       TP_PROTO(int ufd, sigset_t * user_mask, size_t sizemask, int flags),
+       TP_ARGS(ufd, user_mask, sizemask, flags),
+       TP_STRUCT__entry(__field(int, ufd) __field_hex(sigset_t *, user_mask) __field(size_t, sizemask) __field(int, flags)),
+       TP_fast_assign(tp_assign(ufd, ufd) tp_assign(user_mask, user_mask) tp_assign(sizemask, sizemask) tp_assign(flags, flags)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_64_sys_rt_tgsigqueueinfo
+SC_TRACE_EVENT(sys_rt_tgsigqueueinfo,
+       TP_PROTO(pid_t tgid, pid_t pid, int sig, siginfo_t * uinfo),
+       TP_ARGS(tgid, pid, sig, uinfo),
+       TP_STRUCT__entry(__field(pid_t, tgid) __field(pid_t, pid) __field(int, sig) __field_hex(siginfo_t *, uinfo)),
+       TP_fast_assign(tp_assign(tgid, tgid) tp_assign(pid, pid) tp_assign(sig, sig) tp_assign(uinfo, uinfo)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_64_sys_prlimit64
+SC_TRACE_EVENT(sys_prlimit64,
+       TP_PROTO(pid_t pid, unsigned int resource, const struct rlimit64 * new_rlim, struct rlimit64 * old_rlim),
+       TP_ARGS(pid, resource, new_rlim, old_rlim),
+       TP_STRUCT__entry(__field(pid_t, pid) __field(unsigned int, resource) __field_hex(const struct rlimit64 *, new_rlim) __field_hex(struct rlimit64 *, old_rlim)),
+       TP_fast_assign(tp_assign(pid, pid) tp_assign(resource, resource) tp_assign(new_rlim, new_rlim) tp_assign(old_rlim, old_rlim)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_64_sys_sendmmsg
+SC_TRACE_EVENT(sys_sendmmsg,
+       TP_PROTO(int fd, struct mmsghdr * mmsg, unsigned int vlen, unsigned int flags),
+       TP_ARGS(fd, mmsg, vlen, flags),
+       TP_STRUCT__entry(__field(int, fd) __field_hex(struct mmsghdr *, mmsg) __field(unsigned int, vlen) __field(unsigned int, flags)),
+       TP_fast_assign(tp_assign(fd, fd) tp_assign(mmsg, mmsg) tp_assign(vlen, vlen) tp_assign(flags, flags)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_64_sys_select
+SC_TRACE_EVENT(sys_select,
+       TP_PROTO(int n, fd_set * inp, fd_set * outp, fd_set * exp, struct timeval * tvp),
+       TP_ARGS(n, inp, outp, exp, tvp),
+       TP_STRUCT__entry(__field(int, n) __field_hex(fd_set *, inp) __field_hex(fd_set *, outp) __field_hex(fd_set *, exp) __field_hex(struct timeval *, tvp)),
+       TP_fast_assign(tp_assign(n, n) tp_assign(inp, inp) tp_assign(outp, outp) tp_assign(exp, exp) tp_assign(tvp, tvp)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_64_sys_setsockopt
+SC_TRACE_EVENT(sys_setsockopt,
+       TP_PROTO(int fd, int level, int optname, char * optval, int optlen),
+       TP_ARGS(fd, level, optname, optval, optlen),
+       TP_STRUCT__entry(__field(int, fd) __field(int, level) __field(int, optname) __field_hex(char *, optval) __field(int, optlen)),
+       TP_fast_assign(tp_assign(fd, fd) tp_assign(level, level) tp_assign(optname, optname) tp_assign(optval, optval) tp_assign(optlen, optlen)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_64_sys_getsockopt
+SC_TRACE_EVENT(sys_getsockopt,
+       TP_PROTO(int fd, int level, int optname, char * optval, int * optlen),
+       TP_ARGS(fd, level, optname, optval, optlen),
+       TP_STRUCT__entry(__field(int, fd) __field(int, level) __field(int, optname) __field_hex(char *, optval) __field_hex(int *, optlen)),
+       TP_fast_assign(tp_assign(fd, fd) tp_assign(level, level) tp_assign(optname, optname) tp_assign(optval, optval) tp_assign(optlen, optlen)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_64_sys_msgrcv
+SC_TRACE_EVENT(sys_msgrcv,
+       TP_PROTO(int msqid, struct msgbuf * msgp, size_t msgsz, long msgtyp, int msgflg),
+       TP_ARGS(msqid, msgp, msgsz, msgtyp, msgflg),
+       TP_STRUCT__entry(__field(int, msqid) __field_hex(struct msgbuf *, msgp) __field(size_t, msgsz) __field(long, msgtyp) __field(int, msgflg)),
+       TP_fast_assign(tp_assign(msqid, msqid) tp_assign(msgp, msgp) tp_assign(msgsz, msgsz) tp_assign(msgtyp, msgtyp) tp_assign(msgflg, msgflg)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_64_sys_mount
+SC_TRACE_EVENT(sys_mount,
+       TP_PROTO(char * dev_name, char * dir_name, char * type, unsigned long flags, void * data),
+       TP_ARGS(dev_name, dir_name, type, flags, data),
+       TP_STRUCT__entry(__string_from_user(dev_name, dev_name) __string_from_user(dir_name, dir_name) __string_from_user(type, type) __field(unsigned long, flags) __field_hex(void *, data)),
+       TP_fast_assign(tp_copy_string_from_user(dev_name, dev_name) tp_copy_string_from_user(dir_name, dir_name) tp_copy_string_from_user(type, type) tp_assign(flags, flags) tp_assign(data, data)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_64_sys_setxattr
+SC_TRACE_EVENT(sys_setxattr,
+       TP_PROTO(const char * pathname, const char * name, const void * value, size_t size, int flags),
+       TP_ARGS(pathname, name, value, size, flags),
+       TP_STRUCT__entry(__string_from_user(pathname, pathname) __string_from_user(name, name) __field_hex(const void *, value) __field(size_t, size) __field(int, flags)),
+       TP_fast_assign(tp_copy_string_from_user(pathname, pathname) tp_copy_string_from_user(name, name) tp_assign(value, value) tp_assign(size, size) tp_assign(flags, flags)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_64_sys_lsetxattr
+SC_TRACE_EVENT(sys_lsetxattr,
+       TP_PROTO(const char * pathname, const char * name, const void * value, size_t size, int flags),
+       TP_ARGS(pathname, name, value, size, flags),
+       TP_STRUCT__entry(__string_from_user(pathname, pathname) __string_from_user(name, name) __field_hex(const void *, value) __field(size_t, size) __field(int, flags)),
+       TP_fast_assign(tp_copy_string_from_user(pathname, pathname) tp_copy_string_from_user(name, name) tp_assign(value, value) tp_assign(size, size) tp_assign(flags, flags)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_64_sys_fsetxattr
+SC_TRACE_EVENT(sys_fsetxattr,
+       TP_PROTO(int fd, const char * name, const void * value, size_t size, int flags),
+       TP_ARGS(fd, name, value, size, flags),
+       TP_STRUCT__entry(__field(int, fd) __string_from_user(name, name) __field_hex(const void *, value) __field(size_t, size) __field(int, flags)),
+       TP_fast_assign(tp_assign(fd, fd) tp_copy_string_from_user(name, name) tp_assign(value, value) tp_assign(size, size) tp_assign(flags, flags)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_64_sys_io_getevents
+SC_TRACE_EVENT(sys_io_getevents,
+       TP_PROTO(aio_context_t ctx_id, long min_nr, long nr, struct io_event * events, struct timespec * timeout),
+       TP_ARGS(ctx_id, min_nr, nr, events, timeout),
+       TP_STRUCT__entry(__field(aio_context_t, ctx_id) __field(long, min_nr) __field(long, nr) __field_hex(struct io_event *, events) __field_hex(struct timespec *, timeout)),
+       TP_fast_assign(tp_assign(ctx_id, ctx_id) tp_assign(min_nr, min_nr) tp_assign(nr, nr) tp_assign(events, events) tp_assign(timeout, timeout)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_64_sys_get_mempolicy
+SC_TRACE_EVENT(sys_get_mempolicy,
+       TP_PROTO(int * policy, unsigned long * nmask, unsigned long maxnode, unsigned long addr, unsigned long flags),
+       TP_ARGS(policy, nmask, maxnode, addr, flags),
+       TP_STRUCT__entry(__field_hex(int *, policy) __field_hex(unsigned long *, nmask) __field(unsigned long, maxnode) __field_hex(unsigned long, addr) __field(unsigned long, flags)),
+       TP_fast_assign(tp_assign(policy, policy) tp_assign(nmask, nmask) tp_assign(maxnode, maxnode) tp_assign(addr, addr) tp_assign(flags, flags)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_64_sys_mq_timedsend
+SC_TRACE_EVENT(sys_mq_timedsend,
+       TP_PROTO(mqd_t mqdes, const char * u_msg_ptr, size_t msg_len, unsigned int msg_prio, const struct timespec * u_abs_timeout),
+       TP_ARGS(mqdes, u_msg_ptr, msg_len, msg_prio, u_abs_timeout),
+       TP_STRUCT__entry(__field(mqd_t, mqdes) __field_hex(const char *, u_msg_ptr) __field(size_t, msg_len) __field(unsigned int, msg_prio) __field_hex(const struct timespec *, u_abs_timeout)),
+       TP_fast_assign(tp_assign(mqdes, mqdes) tp_assign(u_msg_ptr, u_msg_ptr) tp_assign(msg_len, msg_len) tp_assign(msg_prio, msg_prio) tp_assign(u_abs_timeout, u_abs_timeout)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_64_sys_mq_timedreceive
+SC_TRACE_EVENT(sys_mq_timedreceive,
+       TP_PROTO(mqd_t mqdes, char * u_msg_ptr, size_t msg_len, unsigned int * u_msg_prio, const struct timespec * u_abs_timeout),
+       TP_ARGS(mqdes, u_msg_ptr, msg_len, u_msg_prio, u_abs_timeout),
+       TP_STRUCT__entry(__field(mqd_t, mqdes) __field_hex(char *, u_msg_ptr) __field(size_t, msg_len) __field_hex(unsigned int *, u_msg_prio) __field_hex(const struct timespec *, u_abs_timeout)),
+       TP_fast_assign(tp_assign(mqdes, mqdes) tp_assign(u_msg_ptr, u_msg_ptr) tp_assign(msg_len, msg_len) tp_assign(u_msg_prio, u_msg_prio) tp_assign(u_abs_timeout, u_abs_timeout)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_64_sys_waitid
+SC_TRACE_EVENT(sys_waitid,
+       TP_PROTO(int which, pid_t upid, struct siginfo * infop, int options, struct rusage * ru),
+       TP_ARGS(which, upid, infop, options, ru),
+       TP_STRUCT__entry(__field(int, which) __field(pid_t, upid) __field_hex(struct siginfo *, infop) __field(int, options) __field_hex(struct rusage *, ru)),
+       TP_fast_assign(tp_assign(which, which) tp_assign(upid, upid) tp_assign(infop, infop) tp_assign(options, options) tp_assign(ru, ru)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_64_sys_add_key
+SC_TRACE_EVENT(sys_add_key,
+       TP_PROTO(const char * _type, const char * _description, const void * _payload, size_t plen, key_serial_t ringid),
+       TP_ARGS(_type, _description, _payload, plen, ringid),
+       TP_STRUCT__entry(__string_from_user(_type, _type) __field_hex(const char *, _description) __field_hex(const void *, _payload) __field(size_t, plen) __field(key_serial_t, ringid)),
+       TP_fast_assign(tp_copy_string_from_user(_type, _type) tp_assign(_description, _description) tp_assign(_payload, _payload) tp_assign(plen, plen) tp_assign(ringid, ringid)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_64_sys_fchownat
+SC_TRACE_EVENT(sys_fchownat,
+       TP_PROTO(int dfd, const char * filename, uid_t user, gid_t group, int flag),
+       TP_ARGS(dfd, filename, user, group, flag),
+       TP_STRUCT__entry(__field(int, dfd) __string_from_user(filename, filename) __field(uid_t, user) __field(gid_t, group) __field(int, flag)),
+       TP_fast_assign(tp_assign(dfd, dfd) tp_copy_string_from_user(filename, filename) tp_assign(user, user) tp_assign(group, group) tp_assign(flag, flag)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_64_sys_linkat
+SC_TRACE_EVENT(sys_linkat,
+       TP_PROTO(int olddfd, const char * oldname, int newdfd, const char * newname, int flags),
+       TP_ARGS(olddfd, oldname, newdfd, newname, flags),
+       TP_STRUCT__entry(__field(int, olddfd) __string_from_user(oldname, oldname) __field(int, newdfd) __string_from_user(newname, newname) __field(int, flags)),
+       TP_fast_assign(tp_assign(olddfd, olddfd) tp_copy_string_from_user(oldname, oldname) tp_assign(newdfd, newdfd) tp_copy_string_from_user(newname, newname) tp_assign(flags, flags)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_64_sys_ppoll
+SC_TRACE_EVENT(sys_ppoll,
+       TP_PROTO(struct pollfd * ufds, unsigned int nfds, struct timespec * tsp, const sigset_t * sigmask, size_t sigsetsize),
+       TP_ARGS(ufds, nfds, tsp, sigmask, sigsetsize),
+       TP_STRUCT__entry(__field_hex(struct pollfd *, ufds) __field(unsigned int, nfds) __field_hex(struct timespec *, tsp) __field_hex(const sigset_t *, sigmask) __field(size_t, sigsetsize)),
+       TP_fast_assign(tp_assign(ufds, ufds) tp_assign(nfds, nfds) tp_assign(tsp, tsp) tp_assign(sigmask, sigmask) tp_assign(sigsetsize, sigsetsize)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_64_sys_preadv
+SC_TRACE_EVENT(sys_preadv,
+       TP_PROTO(unsigned long fd, const struct iovec * vec, unsigned long vlen, unsigned long pos_l, unsigned long pos_h),
+       TP_ARGS(fd, vec, vlen, pos_l, pos_h),
+       TP_STRUCT__entry(__field(unsigned long, fd) __field_hex(const struct iovec *, vec) __field(unsigned long, vlen) __field(unsigned long, pos_l) __field(unsigned long, pos_h)),
+       TP_fast_assign(tp_assign(fd, fd) tp_assign(vec, vec) tp_assign(vlen, vlen) tp_assign(pos_l, pos_l) tp_assign(pos_h, pos_h)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_64_sys_pwritev
+SC_TRACE_EVENT(sys_pwritev,
+       TP_PROTO(unsigned long fd, const struct iovec * vec, unsigned long vlen, unsigned long pos_l, unsigned long pos_h),
+       TP_ARGS(fd, vec, vlen, pos_l, pos_h),
+       TP_STRUCT__entry(__field(unsigned long, fd) __field_hex(const struct iovec *, vec) __field(unsigned long, vlen) __field(unsigned long, pos_l) __field(unsigned long, pos_h)),
+       TP_fast_assign(tp_assign(fd, fd) tp_assign(vec, vec) tp_assign(vlen, vlen) tp_assign(pos_l, pos_l) tp_assign(pos_h, pos_h)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_64_sys_perf_event_open
+SC_TRACE_EVENT(sys_perf_event_open,
+       TP_PROTO(struct perf_event_attr * attr_uptr, pid_t pid, int cpu, int group_fd, unsigned long flags),
+       TP_ARGS(attr_uptr, pid, cpu, group_fd, flags),
+       TP_STRUCT__entry(__field_hex(struct perf_event_attr *, attr_uptr) __field(pid_t, pid) __field(int, cpu) __field(int, group_fd) __field(unsigned long, flags)),
+       TP_fast_assign(tp_assign(attr_uptr, attr_uptr) tp_assign(pid, pid) tp_assign(cpu, cpu) tp_assign(group_fd, group_fd) tp_assign(flags, flags)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_64_sys_recvmmsg
+SC_TRACE_EVENT(sys_recvmmsg,
+       TP_PROTO(int fd, struct mmsghdr * mmsg, unsigned int vlen, unsigned int flags, struct timespec * timeout),
+       TP_ARGS(fd, mmsg, vlen, flags, timeout),
+       TP_STRUCT__entry(__field(int, fd) __field_hex(struct mmsghdr *, mmsg) __field(unsigned int, vlen) __field(unsigned int, flags) __field_hex(struct timespec *, timeout)),
+       TP_fast_assign(tp_assign(fd, fd) tp_assign(mmsg, mmsg) tp_assign(vlen, vlen) tp_assign(flags, flags) tp_assign(timeout, timeout)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_64_sys_fanotify_mark
+SC_TRACE_EVENT(sys_fanotify_mark,
+       TP_PROTO(int fanotify_fd, unsigned int flags, __u64 mask, int dfd, const char * pathname),
+       TP_ARGS(fanotify_fd, flags, mask, dfd, pathname),
+       TP_STRUCT__entry(__field(int, fanotify_fd) __field(unsigned int, flags) __field(__u64, mask) __field(int, dfd) __string_from_user(pathname, pathname)),
+       TP_fast_assign(tp_assign(fanotify_fd, fanotify_fd) tp_assign(flags, flags) tp_assign(mask, mask) tp_assign(dfd, dfd) tp_copy_string_from_user(pathname, pathname)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_64_sys_name_to_handle_at
+SC_TRACE_EVENT(sys_name_to_handle_at,
+       TP_PROTO(int dfd, const char * name, struct file_handle * handle, int * mnt_id, int flag),
+       TP_ARGS(dfd, name, handle, mnt_id, flag),
+       TP_STRUCT__entry(__field(int, dfd) __string_from_user(name, name) __field_hex(struct file_handle *, handle) __field_hex(int *, mnt_id) __field(int, flag)),
+       TP_fast_assign(tp_assign(dfd, dfd) tp_copy_string_from_user(name, name) tp_assign(handle, handle) tp_assign(mnt_id, mnt_id) tp_assign(flag, flag)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_64_sys_sendto
+SC_TRACE_EVENT(sys_sendto,
+       TP_PROTO(int fd, void * buff, size_t len, unsigned int flags, struct sockaddr * addr, int addr_len),
+       TP_ARGS(fd, buff, len, flags, addr, addr_len),
+       TP_STRUCT__entry(__field(int, fd) __field_hex(void *, buff) __field(size_t, len) __field(unsigned int, flags) __field_hex(struct sockaddr *, addr) __field_hex(int, addr_len)),
+       TP_fast_assign(tp_assign(fd, fd) tp_assign(buff, buff) tp_assign(len, len) tp_assign(flags, flags) tp_assign(addr, addr) tp_assign(addr_len, addr_len)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_64_sys_recvfrom
+SC_TRACE_EVENT(sys_recvfrom,
+       TP_PROTO(int fd, void * ubuf, size_t size, unsigned int flags, struct sockaddr * addr, int * addr_len),
+       TP_ARGS(fd, ubuf, size, flags, addr, addr_len),
+       TP_STRUCT__entry(__field(int, fd) __field_hex(void *, ubuf) __field(size_t, size) __field(unsigned int, flags) __field_hex(struct sockaddr *, addr) __field_hex(int *, addr_len)),
+       TP_fast_assign(tp_assign(fd, fd) tp_assign(ubuf, ubuf) tp_assign(size, size) tp_assign(flags, flags) tp_assign(addr, addr) tp_assign(addr_len, addr_len)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_64_sys_futex
+SC_TRACE_EVENT(sys_futex,
+       TP_PROTO(u32 * uaddr, int op, u32 val, struct timespec * utime, u32 * uaddr2, u32 val3),
+       TP_ARGS(uaddr, op, val, utime, uaddr2, val3),
+       TP_STRUCT__entry(__field_hex(u32 *, uaddr) __field(int, op) __field(u32, val) __field_hex(struct timespec *, utime) __field_hex(u32 *, uaddr2) __field(u32, val3)),
+       TP_fast_assign(tp_assign(uaddr, uaddr) tp_assign(op, op) tp_assign(val, val) tp_assign(utime, utime) tp_assign(uaddr2, uaddr2) tp_assign(val3, val3)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_64_sys_mbind
+SC_TRACE_EVENT(sys_mbind,
+       TP_PROTO(unsigned long start, unsigned long len, unsigned long mode, unsigned long * nmask, unsigned long maxnode, unsigned flags),
+       TP_ARGS(start, len, mode, nmask, maxnode, flags),
+       TP_STRUCT__entry(__field(unsigned long, start) __field(unsigned long, len) __field(unsigned long, mode) __field_hex(unsigned long *, nmask) __field(unsigned long, maxnode) __field(unsigned, flags)),
+       TP_fast_assign(tp_assign(start, start) tp_assign(len, len) tp_assign(mode, mode) tp_assign(nmask, nmask) tp_assign(maxnode, maxnode) tp_assign(flags, flags)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_64_sys_pselect6
+SC_TRACE_EVENT(sys_pselect6,
+       TP_PROTO(int n, fd_set * inp, fd_set * outp, fd_set * exp, struct timespec * tsp, void * sig),
+       TP_ARGS(n, inp, outp, exp, tsp, sig),
+       TP_STRUCT__entry(__field(int, n) __field_hex(fd_set *, inp) __field_hex(fd_set *, outp) __field_hex(fd_set *, exp) __field_hex(struct timespec *, tsp) __field_hex(void *, sig)),
+       TP_fast_assign(tp_assign(n, n) tp_assign(inp, inp) tp_assign(outp, outp) tp_assign(exp, exp) tp_assign(tsp, tsp) tp_assign(sig, sig)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_64_sys_splice
+SC_TRACE_EVENT(sys_splice,
+       TP_PROTO(int fd_in, loff_t * off_in, int fd_out, loff_t * off_out, size_t len, unsigned int flags),
+       TP_ARGS(fd_in, off_in, fd_out, off_out, len, flags),
+       TP_STRUCT__entry(__field(int, fd_in) __field_hex(loff_t *, off_in) __field(int, fd_out) __field_hex(loff_t *, off_out) __field(size_t, len) __field(unsigned int, flags)),
+       TP_fast_assign(tp_assign(fd_in, fd_in) tp_assign(off_in, off_in) tp_assign(fd_out, fd_out) tp_assign(off_out, off_out) tp_assign(len, len) tp_assign(flags, flags)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_64_sys_move_pages
+SC_TRACE_EVENT(sys_move_pages,
+       TP_PROTO(pid_t pid, unsigned long nr_pages, const void * * pages, const int * nodes, int * status, int flags),
+       TP_ARGS(pid, nr_pages, pages, nodes, status, flags),
+       TP_STRUCT__entry(__field(pid_t, pid) __field(unsigned long, nr_pages) __field_hex(const void * *, pages) __field_hex(const int *, nodes) __field_hex(int *, status) __field(int, flags)),
+       TP_fast_assign(tp_assign(pid, pid) tp_assign(nr_pages, nr_pages) tp_assign(pages, pages) tp_assign(nodes, nodes) tp_assign(status, status) tp_assign(flags, flags)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_64_sys_epoll_pwait
+SC_TRACE_EVENT(sys_epoll_pwait,
+       TP_PROTO(int epfd, struct epoll_event * events, int maxevents, int timeout, const sigset_t * sigmask, size_t sigsetsize),
+       TP_ARGS(epfd, events, maxevents, timeout, sigmask, sigsetsize),
+       TP_STRUCT__entry(__field(int, epfd) __field_hex(struct epoll_event *, events) __field(int, maxevents) __field(int, timeout) __field_hex(const sigset_t *, sigmask) __field(size_t, sigsetsize)),
+       TP_fast_assign(tp_assign(epfd, epfd) tp_assign(events, events) tp_assign(maxevents, maxevents) tp_assign(timeout, timeout) tp_assign(sigmask, sigmask) tp_assign(sigsetsize, sigsetsize)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_64_sys_process_vm_readv
+SC_TRACE_EVENT(sys_process_vm_readv,
+       TP_PROTO(pid_t pid, const struct iovec * lvec, unsigned long liovcnt, const struct iovec * rvec, unsigned long riovcnt, unsigned long flags),
+       TP_ARGS(pid, lvec, liovcnt, rvec, riovcnt, flags),
+       TP_STRUCT__entry(__field(pid_t, pid) __field_hex(const struct iovec *, lvec) __field(unsigned long, liovcnt) __field_hex(const struct iovec *, rvec) __field(unsigned long, riovcnt) __field(unsigned long, flags)),
+       TP_fast_assign(tp_assign(pid, pid) tp_assign(lvec, lvec) tp_assign(liovcnt, liovcnt) tp_assign(rvec, rvec) tp_assign(riovcnt, riovcnt) tp_assign(flags, flags)),
+       TP_printk()
+)
+#endif
+#ifndef OVERRIDE_64_sys_process_vm_writev
+SC_TRACE_EVENT(sys_process_vm_writev,
+       TP_PROTO(pid_t pid, const struct iovec * lvec, unsigned long liovcnt, const struct iovec * rvec, unsigned long riovcnt, unsigned long flags),
+       TP_ARGS(pid, lvec, liovcnt, rvec, riovcnt, flags),
+       TP_STRUCT__entry(__field(pid_t, pid) __field_hex(const struct iovec *, lvec) __field(unsigned long, liovcnt) __field_hex(const struct iovec *, rvec) __field(unsigned long, riovcnt) __field(unsigned long, flags)),
+       TP_fast_assign(tp_assign(pid, pid) tp_assign(lvec, lvec) tp_assign(liovcnt, liovcnt) tp_assign(rvec, rvec) tp_assign(riovcnt, riovcnt) tp_assign(flags, flags)),
+       TP_printk()
+)
+#endif
+
+#endif /*  _TRACE_SYSCALLS_POINTERS_H */
+
+/* This part must be outside protection */
+#include "../../../probes/define_trace.h"
+
+#else /* CREATE_SYSCALL_TABLE */
+
+#include "x86-64-syscalls-3.10.0-rc7_pointers_override.h"
+#include "syscalls_pointers_override.h"
+
+#ifndef OVERRIDE_TABLE_64_sys_read
+TRACE_SYSCALL_TABLE(sys_read, sys_read, 0, 3)
+#endif
+#ifndef OVERRIDE_TABLE_64_sys_write
+TRACE_SYSCALL_TABLE(sys_write, sys_write, 1, 3)
+#endif
+#ifndef OVERRIDE_TABLE_64_sys_open
+TRACE_SYSCALL_TABLE(sys_open, sys_open, 2, 3)
+#endif
+#ifndef OVERRIDE_TABLE_64_sys_newstat
+TRACE_SYSCALL_TABLE(sys_newstat, sys_newstat, 4, 2)
+#endif
+#ifndef OVERRIDE_TABLE_64_sys_newfstat
+TRACE_SYSCALL_TABLE(sys_newfstat, sys_newfstat, 5, 2)
+#endif
+#ifndef OVERRIDE_TABLE_64_sys_newlstat
+TRACE_SYSCALL_TABLE(sys_newlstat, sys_newlstat, 6, 2)
+#endif
+#ifndef OVERRIDE_TABLE_64_sys_poll
+TRACE_SYSCALL_TABLE(sys_poll, sys_poll, 7, 3)
+#endif
+#ifndef OVERRIDE_TABLE_64_sys_rt_sigaction
+TRACE_SYSCALL_TABLE(sys_rt_sigaction, sys_rt_sigaction, 13, 4)
+#endif
+#ifndef OVERRIDE_TABLE_64_sys_rt_sigprocmask
+TRACE_SYSCALL_TABLE(sys_rt_sigprocmask, sys_rt_sigprocmask, 14, 4)
+#endif
+#ifndef OVERRIDE_TABLE_64_sys_pread64
+TRACE_SYSCALL_TABLE(sys_pread64, sys_pread64, 17, 4)
+#endif
+#ifndef OVERRIDE_TABLE_64_sys_pwrite64
+TRACE_SYSCALL_TABLE(sys_pwrite64, sys_pwrite64, 18, 4)
+#endif
+#ifndef OVERRIDE_TABLE_64_sys_readv
+TRACE_SYSCALL_TABLE(sys_readv, sys_readv, 19, 3)
+#endif
+#ifndef OVERRIDE_TABLE_64_sys_writev
+TRACE_SYSCALL_TABLE(sys_writev, sys_writev, 20, 3)
+#endif
+#ifndef OVERRIDE_TABLE_64_sys_access
+TRACE_SYSCALL_TABLE(sys_access, sys_access, 21, 2)
+#endif
+#ifndef OVERRIDE_TABLE_64_sys_pipe
+TRACE_SYSCALL_TABLE(sys_pipe, sys_pipe, 22, 1)
+#endif
+#ifndef OVERRIDE_TABLE_64_sys_select
+TRACE_SYSCALL_TABLE(sys_select, sys_select, 23, 5)
+#endif
+#ifndef OVERRIDE_TABLE_64_sys_mincore
+TRACE_SYSCALL_TABLE(sys_mincore, sys_mincore, 27, 3)
+#endif
+#ifndef OVERRIDE_TABLE_64_sys_shmat
+TRACE_SYSCALL_TABLE(sys_shmat, sys_shmat, 30, 3)
+#endif
+#ifndef OVERRIDE_TABLE_64_sys_shmctl
+TRACE_SYSCALL_TABLE(sys_shmctl, sys_shmctl, 31, 3)
+#endif
+#ifndef OVERRIDE_TABLE_64_sys_nanosleep
+TRACE_SYSCALL_TABLE(sys_nanosleep, sys_nanosleep, 35, 2)
+#endif
+#ifndef OVERRIDE_TABLE_64_sys_getitimer
+TRACE_SYSCALL_TABLE(sys_getitimer, sys_getitimer, 36, 2)
+#endif
+#ifndef OVERRIDE_TABLE_64_sys_setitimer
+TRACE_SYSCALL_TABLE(sys_setitimer, sys_setitimer, 38, 3)
+#endif
+#ifndef OVERRIDE_TABLE_64_sys_sendfile64
+TRACE_SYSCALL_TABLE(sys_sendfile64, sys_sendfile64, 40, 4)
+#endif
+#ifndef OVERRIDE_TABLE_64_sys_connect
+TRACE_SYSCALL_TABLE(sys_connect, sys_connect, 42, 3)
+#endif
+#ifndef OVERRIDE_TABLE_64_sys_accept
+TRACE_SYSCALL_TABLE(sys_accept, sys_accept, 43, 3)
+#endif
+#ifndef OVERRIDE_TABLE_64_sys_sendto
+TRACE_SYSCALL_TABLE(sys_sendto, sys_sendto, 44, 6)
+#endif
+#ifndef OVERRIDE_TABLE_64_sys_recvfrom
+TRACE_SYSCALL_TABLE(sys_recvfrom, sys_recvfrom, 45, 6)
+#endif
+#ifndef OVERRIDE_TABLE_64_sys_sendmsg
+TRACE_SYSCALL_TABLE(sys_sendmsg, sys_sendmsg, 46, 3)
+#endif
+#ifndef OVERRIDE_TABLE_64_sys_recvmsg
+TRACE_SYSCALL_TABLE(sys_recvmsg, sys_recvmsg, 47, 3)
+#endif
+#ifndef OVERRIDE_TABLE_64_sys_bind
+TRACE_SYSCALL_TABLE(sys_bind, sys_bind, 49, 3)
+#endif
+#ifndef OVERRIDE_TABLE_64_sys_getsockname
+TRACE_SYSCALL_TABLE(sys_getsockname, sys_getsockname, 51, 3)
+#endif
+#ifndef OVERRIDE_TABLE_64_sys_getpeername
+TRACE_SYSCALL_TABLE(sys_getpeername, sys_getpeername, 52, 3)
+#endif
+#ifndef OVERRIDE_TABLE_64_sys_socketpair
+TRACE_SYSCALL_TABLE(sys_socketpair, sys_socketpair, 53, 4)
+#endif
+#ifndef OVERRIDE_TABLE_64_sys_setsockopt
+TRACE_SYSCALL_TABLE(sys_setsockopt, sys_setsockopt, 54, 5)
+#endif
+#ifndef OVERRIDE_TABLE_64_sys_getsockopt
+TRACE_SYSCALL_TABLE(sys_getsockopt, sys_getsockopt, 55, 5)
+#endif
+#ifndef OVERRIDE_TABLE_64_sys_wait4
+TRACE_SYSCALL_TABLE(sys_wait4, sys_wait4, 61, 4)
+#endif
+#ifndef OVERRIDE_TABLE_64_sys_newuname
+TRACE_SYSCALL_TABLE(sys_newuname, sys_newuname, 63, 1)
+#endif
+#ifndef OVERRIDE_TABLE_64_sys_semop
+TRACE_SYSCALL_TABLE(sys_semop, sys_semop, 65, 3)
+#endif
+#ifndef OVERRIDE_TABLE_64_sys_shmdt
+TRACE_SYSCALL_TABLE(sys_shmdt, sys_shmdt, 67, 1)
+#endif
+#ifndef OVERRIDE_TABLE_64_sys_msgsnd
+TRACE_SYSCALL_TABLE(sys_msgsnd, sys_msgsnd, 69, 4)
+#endif
+#ifndef OVERRIDE_TABLE_64_sys_msgrcv
+TRACE_SYSCALL_TABLE(sys_msgrcv, sys_msgrcv, 70, 5)
+#endif
+#ifndef OVERRIDE_TABLE_64_sys_msgctl
+TRACE_SYSCALL_TABLE(sys_msgctl, sys_msgctl, 71, 3)
+#endif
+#ifndef OVERRIDE_TABLE_64_sys_truncate
+TRACE_SYSCALL_TABLE(sys_truncate, sys_truncate, 76, 2)
+#endif
+#ifndef OVERRIDE_TABLE_64_sys_getdents
+TRACE_SYSCALL_TABLE(sys_getdents, sys_getdents, 78, 3)
+#endif
+#ifndef OVERRIDE_TABLE_64_sys_getcwd
+TRACE_SYSCALL_TABLE(sys_getcwd, sys_getcwd, 79, 2)
+#endif
+#ifndef OVERRIDE_TABLE_64_sys_chdir
+TRACE_SYSCALL_TABLE(sys_chdir, sys_chdir, 80, 1)
+#endif
+#ifndef OVERRIDE_TABLE_64_sys_rename
+TRACE_SYSCALL_TABLE(sys_rename, sys_rename, 82, 2)
+#endif
+#ifndef OVERRIDE_TABLE_64_sys_mkdir
+TRACE_SYSCALL_TABLE(sys_mkdir, sys_mkdir, 83, 2)
+#endif
+#ifndef OVERRIDE_TABLE_64_sys_rmdir
+TRACE_SYSCALL_TABLE(sys_rmdir, sys_rmdir, 84, 1)
+#endif
+#ifndef OVERRIDE_TABLE_64_sys_creat
+TRACE_SYSCALL_TABLE(sys_creat, sys_creat, 85, 2)
+#endif
+#ifndef OVERRIDE_TABLE_64_sys_link
+TRACE_SYSCALL_TABLE(sys_link, sys_link, 86, 2)
+#endif
+#ifndef OVERRIDE_TABLE_64_sys_unlink
+TRACE_SYSCALL_TABLE(sys_unlink, sys_unlink, 87, 1)
+#endif
+#ifndef OVERRIDE_TABLE_64_sys_symlink
+TRACE_SYSCALL_TABLE(sys_symlink, sys_symlink, 88, 2)
+#endif
+#ifndef OVERRIDE_TABLE_64_sys_readlink
+TRACE_SYSCALL_TABLE(sys_readlink, sys_readlink, 89, 3)
+#endif
+#ifndef OVERRIDE_TABLE_64_sys_chmod
+TRACE_SYSCALL_TABLE(sys_chmod, sys_chmod, 90, 2)
+#endif
+#ifndef OVERRIDE_TABLE_64_sys_chown
+TRACE_SYSCALL_TABLE(sys_chown, sys_chown, 92, 3)
+#endif
+#ifndef OVERRIDE_TABLE_64_sys_lchown
+TRACE_SYSCALL_TABLE(sys_lchown, sys_lchown, 94, 3)
+#endif
+#ifndef OVERRIDE_TABLE_64_sys_gettimeofday
+TRACE_SYSCALL_TABLE(sys_gettimeofday, sys_gettimeofday, 96, 2)
+#endif
+#ifndef OVERRIDE_TABLE_64_sys_getrlimit
+TRACE_SYSCALL_TABLE(sys_getrlimit, sys_getrlimit, 97, 2)
+#endif
+#ifndef OVERRIDE_TABLE_64_sys_getrusage
+TRACE_SYSCALL_TABLE(sys_getrusage, sys_getrusage, 98, 2)
+#endif
+#ifndef OVERRIDE_TABLE_64_sys_sysinfo
+TRACE_SYSCALL_TABLE(sys_sysinfo, sys_sysinfo, 99, 1)
+#endif
+#ifndef OVERRIDE_TABLE_64_sys_times
+TRACE_SYSCALL_TABLE(sys_times, sys_times, 100, 1)
+#endif
+#ifndef OVERRIDE_TABLE_64_sys_syslog
+TRACE_SYSCALL_TABLE(sys_syslog, sys_syslog, 103, 3)
+#endif
+#ifndef OVERRIDE_TABLE_64_sys_getgroups
+TRACE_SYSCALL_TABLE(sys_getgroups, sys_getgroups, 115, 2)
+#endif
+#ifndef OVERRIDE_TABLE_64_sys_setgroups
+TRACE_SYSCALL_TABLE(sys_setgroups, sys_setgroups, 116, 2)
+#endif
+#ifndef OVERRIDE_TABLE_64_sys_getresuid
+TRACE_SYSCALL_TABLE(sys_getresuid, sys_getresuid, 118, 3)
+#endif
+#ifndef OVERRIDE_TABLE_64_sys_getresgid
+TRACE_SYSCALL_TABLE(sys_getresgid, sys_getresgid, 120, 3)
+#endif
+#ifndef OVERRIDE_TABLE_64_sys_rt_sigpending
+TRACE_SYSCALL_TABLE(sys_rt_sigpending, sys_rt_sigpending, 127, 2)
+#endif
+#ifndef OVERRIDE_TABLE_64_sys_rt_sigtimedwait
+TRACE_SYSCALL_TABLE(sys_rt_sigtimedwait, sys_rt_sigtimedwait, 128, 4)
+#endif
+#ifndef OVERRIDE_TABLE_64_sys_rt_sigqueueinfo
+TRACE_SYSCALL_TABLE(sys_rt_sigqueueinfo, sys_rt_sigqueueinfo, 129, 3)
+#endif
+#ifndef OVERRIDE_TABLE_64_sys_rt_sigsuspend
+TRACE_SYSCALL_TABLE(sys_rt_sigsuspend, sys_rt_sigsuspend, 130, 2)
+#endif
+#ifndef OVERRIDE_TABLE_64_sys_sigaltstack
+TRACE_SYSCALL_TABLE(sys_sigaltstack, sys_sigaltstack, 131, 2)
+#endif
+#ifndef OVERRIDE_TABLE_64_sys_utime
+TRACE_SYSCALL_TABLE(sys_utime, sys_utime, 132, 2)
+#endif
+#ifndef OVERRIDE_TABLE_64_sys_mknod
+TRACE_SYSCALL_TABLE(sys_mknod, sys_mknod, 133, 3)
+#endif
+#ifndef OVERRIDE_TABLE_64_sys_ustat
+TRACE_SYSCALL_TABLE(sys_ustat, sys_ustat, 136, 2)
+#endif
+#ifndef OVERRIDE_TABLE_64_sys_statfs
+TRACE_SYSCALL_TABLE(sys_statfs, sys_statfs, 137, 2)
+#endif
+#ifndef OVERRIDE_TABLE_64_sys_fstatfs
+TRACE_SYSCALL_TABLE(sys_fstatfs, sys_fstatfs, 138, 2)
+#endif
+#ifndef OVERRIDE_TABLE_64_sys_sched_setparam
+TRACE_SYSCALL_TABLE(sys_sched_setparam, sys_sched_setparam, 142, 2)
+#endif
+#ifndef OVERRIDE_TABLE_64_sys_sched_getparam
+TRACE_SYSCALL_TABLE(sys_sched_getparam, sys_sched_getparam, 143, 2)
+#endif
+#ifndef OVERRIDE_TABLE_64_sys_sched_setscheduler
+TRACE_SYSCALL_TABLE(sys_sched_setscheduler, sys_sched_setscheduler, 144, 3)
+#endif
+#ifndef OVERRIDE_TABLE_64_sys_sched_rr_get_interval
+TRACE_SYSCALL_TABLE(sys_sched_rr_get_interval, sys_sched_rr_get_interval, 148, 2)
+#endif
+#ifndef OVERRIDE_TABLE_64_sys_pivot_root
+TRACE_SYSCALL_TABLE(sys_pivot_root, sys_pivot_root, 155, 2)
+#endif
+#ifndef OVERRIDE_TABLE_64_sys_sysctl
+TRACE_SYSCALL_TABLE(sys_sysctl, sys_sysctl, 156, 1)
+#endif
+#ifndef OVERRIDE_TABLE_64_sys_adjtimex
+TRACE_SYSCALL_TABLE(sys_adjtimex, sys_adjtimex, 159, 1)
+#endif
+#ifndef OVERRIDE_TABLE_64_sys_setrlimit
+TRACE_SYSCALL_TABLE(sys_setrlimit, sys_setrlimit, 160, 2)
+#endif
+#ifndef OVERRIDE_TABLE_64_sys_chroot
+TRACE_SYSCALL_TABLE(sys_chroot, sys_chroot, 161, 1)
+#endif
+#ifndef OVERRIDE_TABLE_64_sys_acct
+TRACE_SYSCALL_TABLE(sys_acct, sys_acct, 163, 1)
+#endif
+#ifndef OVERRIDE_TABLE_64_sys_settimeofday
+TRACE_SYSCALL_TABLE(sys_settimeofday, sys_settimeofday, 164, 2)
+#endif
+#ifndef OVERRIDE_TABLE_64_sys_mount
+TRACE_SYSCALL_TABLE(sys_mount, sys_mount, 165, 5)
+#endif
+#ifndef OVERRIDE_TABLE_64_sys_umount
+TRACE_SYSCALL_TABLE(sys_umount, sys_umount, 166, 2)
+#endif
+#ifndef OVERRIDE_TABLE_64_sys_swapon
+TRACE_SYSCALL_TABLE(sys_swapon, sys_swapon, 167, 2)
+#endif
+#ifndef OVERRIDE_TABLE_64_sys_swapoff
+TRACE_SYSCALL_TABLE(sys_swapoff, sys_swapoff, 168, 1)
+#endif
+#ifndef OVERRIDE_TABLE_64_sys_reboot
+TRACE_SYSCALL_TABLE(sys_reboot, sys_reboot, 169, 4)
+#endif
+#ifndef OVERRIDE_TABLE_64_sys_sethostname
+TRACE_SYSCALL_TABLE(sys_sethostname, sys_sethostname, 170, 2)
+#endif
+#ifndef OVERRIDE_TABLE_64_sys_setdomainname
+TRACE_SYSCALL_TABLE(sys_setdomainname, sys_setdomainname, 171, 2)
+#endif
+#ifndef OVERRIDE_TABLE_64_sys_init_module
+TRACE_SYSCALL_TABLE(sys_init_module, sys_init_module, 175, 3)
+#endif
+#ifndef OVERRIDE_TABLE_64_sys_delete_module
+TRACE_SYSCALL_TABLE(sys_delete_module, sys_delete_module, 176, 2)
+#endif
+#ifndef OVERRIDE_TABLE_64_sys_quotactl
+TRACE_SYSCALL_TABLE(sys_quotactl, sys_quotactl, 179, 4)
+#endif
+#ifndef OVERRIDE_TABLE_64_sys_setxattr
+TRACE_SYSCALL_TABLE(sys_setxattr, sys_setxattr, 188, 5)
+#endif
+#ifndef OVERRIDE_TABLE_64_sys_lsetxattr
+TRACE_SYSCALL_TABLE(sys_lsetxattr, sys_lsetxattr, 189, 5)
+#endif
+#ifndef OVERRIDE_TABLE_64_sys_fsetxattr
+TRACE_SYSCALL_TABLE(sys_fsetxattr, sys_fsetxattr, 190, 5)
+#endif
+#ifndef OVERRIDE_TABLE_64_sys_getxattr
+TRACE_SYSCALL_TABLE(sys_getxattr, sys_getxattr, 191, 4)
+#endif
+#ifndef OVERRIDE_TABLE_64_sys_lgetxattr
+TRACE_SYSCALL_TABLE(sys_lgetxattr, sys_lgetxattr, 192, 4)
+#endif
+#ifndef OVERRIDE_TABLE_64_sys_fgetxattr
+TRACE_SYSCALL_TABLE(sys_fgetxattr, sys_fgetxattr, 193, 4)
+#endif
+#ifndef OVERRIDE_TABLE_64_sys_listxattr
+TRACE_SYSCALL_TABLE(sys_listxattr, sys_listxattr, 194, 3)
+#endif
+#ifndef OVERRIDE_TABLE_64_sys_llistxattr
+TRACE_SYSCALL_TABLE(sys_llistxattr, sys_llistxattr, 195, 3)
+#endif
+#ifndef OVERRIDE_TABLE_64_sys_flistxattr
+TRACE_SYSCALL_TABLE(sys_flistxattr, sys_flistxattr, 196, 3)
+#endif
+#ifndef OVERRIDE_TABLE_64_sys_removexattr
+TRACE_SYSCALL_TABLE(sys_removexattr, sys_removexattr, 197, 2)
+#endif
+#ifndef OVERRIDE_TABLE_64_sys_lremovexattr
+TRACE_SYSCALL_TABLE(sys_lremovexattr, sys_lremovexattr, 198, 2)
+#endif
+#ifndef OVERRIDE_TABLE_64_sys_fremovexattr
+TRACE_SYSCALL_TABLE(sys_fremovexattr, sys_fremovexattr, 199, 2)
+#endif
+#ifndef OVERRIDE_TABLE_64_sys_time
+TRACE_SYSCALL_TABLE(sys_time, sys_time, 201, 1)
+#endif
+#ifndef OVERRIDE_TABLE_64_sys_futex
+TRACE_SYSCALL_TABLE(sys_futex, sys_futex, 202, 6)
+#endif
+#ifndef OVERRIDE_TABLE_64_sys_sched_setaffinity
+TRACE_SYSCALL_TABLE(sys_sched_setaffinity, sys_sched_setaffinity, 203, 3)
+#endif
+#ifndef OVERRIDE_TABLE_64_sys_sched_getaffinity
+TRACE_SYSCALL_TABLE(sys_sched_getaffinity, sys_sched_getaffinity, 204, 3)
+#endif
+#ifndef OVERRIDE_TABLE_64_sys_io_setup
+TRACE_SYSCALL_TABLE(sys_io_setup, sys_io_setup, 206, 2)
+#endif
+#ifndef OVERRIDE_TABLE_64_sys_io_getevents
+TRACE_SYSCALL_TABLE(sys_io_getevents, sys_io_getevents, 208, 5)
+#endif
+#ifndef OVERRIDE_TABLE_64_sys_io_submit
+TRACE_SYSCALL_TABLE(sys_io_submit, sys_io_submit, 209, 3)
+#endif
+#ifndef OVERRIDE_TABLE_64_sys_io_cancel
+TRACE_SYSCALL_TABLE(sys_io_cancel, sys_io_cancel, 210, 3)
+#endif
+#ifndef OVERRIDE_TABLE_64_sys_lookup_dcookie
+TRACE_SYSCALL_TABLE(sys_lookup_dcookie, sys_lookup_dcookie, 212, 3)
+#endif
+#ifndef OVERRIDE_TABLE_64_sys_getdents64
+TRACE_SYSCALL_TABLE(sys_getdents64, sys_getdents64, 217, 3)
+#endif
+#ifndef OVERRIDE_TABLE_64_sys_set_tid_address
+TRACE_SYSCALL_TABLE(sys_set_tid_address, sys_set_tid_address, 218, 1)
+#endif
+#ifndef OVERRIDE_TABLE_64_sys_semtimedop
+TRACE_SYSCALL_TABLE(sys_semtimedop, sys_semtimedop, 220, 4)
+#endif
+#ifndef OVERRIDE_TABLE_64_sys_timer_create
+TRACE_SYSCALL_TABLE(sys_timer_create, sys_timer_create, 222, 3)
+#endif
+#ifndef OVERRIDE_TABLE_64_sys_timer_settime
+TRACE_SYSCALL_TABLE(sys_timer_settime, sys_timer_settime, 223, 4)
+#endif
+#ifndef OVERRIDE_TABLE_64_sys_timer_gettime
+TRACE_SYSCALL_TABLE(sys_timer_gettime, sys_timer_gettime, 224, 2)
+#endif
+#ifndef OVERRIDE_TABLE_64_sys_clock_settime
+TRACE_SYSCALL_TABLE(sys_clock_settime, sys_clock_settime, 227, 2)
+#endif
+#ifndef OVERRIDE_TABLE_64_sys_clock_gettime
+TRACE_SYSCALL_TABLE(sys_clock_gettime, sys_clock_gettime, 228, 2)
+#endif
+#ifndef OVERRIDE_TABLE_64_sys_clock_getres
+TRACE_SYSCALL_TABLE(sys_clock_getres, sys_clock_getres, 229, 2)
+#endif
+#ifndef OVERRIDE_TABLE_64_sys_clock_nanosleep
+TRACE_SYSCALL_TABLE(sys_clock_nanosleep, sys_clock_nanosleep, 230, 4)
+#endif
+#ifndef OVERRIDE_TABLE_64_sys_epoll_wait
+TRACE_SYSCALL_TABLE(sys_epoll_wait, sys_epoll_wait, 232, 4)
+#endif
+#ifndef OVERRIDE_TABLE_64_sys_epoll_ctl
+TRACE_SYSCALL_TABLE(sys_epoll_ctl, sys_epoll_ctl, 233, 4)
+#endif
+#ifndef OVERRIDE_TABLE_64_sys_utimes
+TRACE_SYSCALL_TABLE(sys_utimes, sys_utimes, 235, 2)
+#endif
+#ifndef OVERRIDE_TABLE_64_sys_mbind
+TRACE_SYSCALL_TABLE(sys_mbind, sys_mbind, 237, 6)
+#endif
+#ifndef OVERRIDE_TABLE_64_sys_set_mempolicy
+TRACE_SYSCALL_TABLE(sys_set_mempolicy, sys_set_mempolicy, 238, 3)
+#endif
+#ifndef OVERRIDE_TABLE_64_sys_get_mempolicy
+TRACE_SYSCALL_TABLE(sys_get_mempolicy, sys_get_mempolicy, 239, 5)
+#endif
+#ifndef OVERRIDE_TABLE_64_sys_mq_open
+TRACE_SYSCALL_TABLE(sys_mq_open, sys_mq_open, 240, 4)
+#endif
+#ifndef OVERRIDE_TABLE_64_sys_mq_unlink
+TRACE_SYSCALL_TABLE(sys_mq_unlink, sys_mq_unlink, 241, 1)
+#endif
+#ifndef OVERRIDE_TABLE_64_sys_mq_timedsend
+TRACE_SYSCALL_TABLE(sys_mq_timedsend, sys_mq_timedsend, 242, 5)
+#endif
+#ifndef OVERRIDE_TABLE_64_sys_mq_timedreceive
+TRACE_SYSCALL_TABLE(sys_mq_timedreceive, sys_mq_timedreceive, 243, 5)
+#endif
+#ifndef OVERRIDE_TABLE_64_sys_mq_notify
+TRACE_SYSCALL_TABLE(sys_mq_notify, sys_mq_notify, 244, 2)
+#endif
+#ifndef OVERRIDE_TABLE_64_sys_mq_getsetattr
+TRACE_SYSCALL_TABLE(sys_mq_getsetattr, sys_mq_getsetattr, 245, 3)
+#endif
+#ifndef OVERRIDE_TABLE_64_sys_kexec_load
+TRACE_SYSCALL_TABLE(sys_kexec_load, sys_kexec_load, 246, 4)
+#endif
+#ifndef OVERRIDE_TABLE_64_sys_waitid
+TRACE_SYSCALL_TABLE(sys_waitid, sys_waitid, 247, 5)
+#endif
+#ifndef OVERRIDE_TABLE_64_sys_add_key
+TRACE_SYSCALL_TABLE(sys_add_key, sys_add_key, 248, 5)
+#endif
+#ifndef OVERRIDE_TABLE_64_sys_request_key
+TRACE_SYSCALL_TABLE(sys_request_key, sys_request_key, 249, 4)
+#endif
+#ifndef OVERRIDE_TABLE_64_sys_inotify_add_watch
+TRACE_SYSCALL_TABLE(sys_inotify_add_watch, sys_inotify_add_watch, 254, 3)
+#endif
+#ifndef OVERRIDE_TABLE_64_sys_migrate_pages
+TRACE_SYSCALL_TABLE(sys_migrate_pages, sys_migrate_pages, 256, 4)
+#endif
+#ifndef OVERRIDE_TABLE_64_sys_openat
+TRACE_SYSCALL_TABLE(sys_openat, sys_openat, 257, 4)
+#endif
+#ifndef OVERRIDE_TABLE_64_sys_mkdirat
+TRACE_SYSCALL_TABLE(sys_mkdirat, sys_mkdirat, 258, 3)
+#endif
+#ifndef OVERRIDE_TABLE_64_sys_mknodat
+TRACE_SYSCALL_TABLE(sys_mknodat, sys_mknodat, 259, 4)
+#endif
+#ifndef OVERRIDE_TABLE_64_sys_fchownat
+TRACE_SYSCALL_TABLE(sys_fchownat, sys_fchownat, 260, 5)
+#endif
+#ifndef OVERRIDE_TABLE_64_sys_futimesat
+TRACE_SYSCALL_TABLE(sys_futimesat, sys_futimesat, 261, 3)
+#endif
+#ifndef OVERRIDE_TABLE_64_sys_newfstatat
+TRACE_SYSCALL_TABLE(sys_newfstatat, sys_newfstatat, 262, 4)
+#endif
+#ifndef OVERRIDE_TABLE_64_sys_unlinkat
+TRACE_SYSCALL_TABLE(sys_unlinkat, sys_unlinkat, 263, 3)
+#endif
+#ifndef OVERRIDE_TABLE_64_sys_renameat
+TRACE_SYSCALL_TABLE(sys_renameat, sys_renameat, 264, 4)
+#endif
+#ifndef OVERRIDE_TABLE_64_sys_linkat
+TRACE_SYSCALL_TABLE(sys_linkat, sys_linkat, 265, 5)
+#endif
+#ifndef OVERRIDE_TABLE_64_sys_symlinkat
+TRACE_SYSCALL_TABLE(sys_symlinkat, sys_symlinkat, 266, 3)
+#endif
+#ifndef OVERRIDE_TABLE_64_sys_readlinkat
+TRACE_SYSCALL_TABLE(sys_readlinkat, sys_readlinkat, 267, 4)
+#endif
+#ifndef OVERRIDE_TABLE_64_sys_fchmodat
+TRACE_SYSCALL_TABLE(sys_fchmodat, sys_fchmodat, 268, 3)
+#endif
+#ifndef OVERRIDE_TABLE_64_sys_faccessat
+TRACE_SYSCALL_TABLE(sys_faccessat, sys_faccessat, 269, 3)
+#endif
+#ifndef OVERRIDE_TABLE_64_sys_pselect6
+TRACE_SYSCALL_TABLE(sys_pselect6, sys_pselect6, 270, 6)
+#endif
+#ifndef OVERRIDE_TABLE_64_sys_ppoll
+TRACE_SYSCALL_TABLE(sys_ppoll, sys_ppoll, 271, 5)
+#endif
+#ifndef OVERRIDE_TABLE_64_sys_set_robust_list
+TRACE_SYSCALL_TABLE(sys_set_robust_list, sys_set_robust_list, 273, 2)
+#endif
+#ifndef OVERRIDE_TABLE_64_sys_get_robust_list
+TRACE_SYSCALL_TABLE(sys_get_robust_list, sys_get_robust_list, 274, 3)
+#endif
+#ifndef OVERRIDE_TABLE_64_sys_splice
+TRACE_SYSCALL_TABLE(sys_splice, sys_splice, 275, 6)
+#endif
+#ifndef OVERRIDE_TABLE_64_sys_vmsplice
+TRACE_SYSCALL_TABLE(sys_vmsplice, sys_vmsplice, 278, 4)
+#endif
+#ifndef OVERRIDE_TABLE_64_sys_move_pages
+TRACE_SYSCALL_TABLE(sys_move_pages, sys_move_pages, 279, 6)
+#endif
+#ifndef OVERRIDE_TABLE_64_sys_utimensat
+TRACE_SYSCALL_TABLE(sys_utimensat, sys_utimensat, 280, 4)
+#endif
+#ifndef OVERRIDE_TABLE_64_sys_epoll_pwait
+TRACE_SYSCALL_TABLE(sys_epoll_pwait, sys_epoll_pwait, 281, 6)
+#endif
+#ifndef OVERRIDE_TABLE_64_sys_signalfd
+TRACE_SYSCALL_TABLE(sys_signalfd, sys_signalfd, 282, 3)
+#endif
+#ifndef OVERRIDE_TABLE_64_sys_timerfd_settime
+TRACE_SYSCALL_TABLE(sys_timerfd_settime, sys_timerfd_settime, 286, 4)
+#endif
+#ifndef OVERRIDE_TABLE_64_sys_timerfd_gettime
+TRACE_SYSCALL_TABLE(sys_timerfd_gettime, sys_timerfd_gettime, 287, 2)
+#endif
+#ifndef OVERRIDE_TABLE_64_sys_accept4
+TRACE_SYSCALL_TABLE(sys_accept4, sys_accept4, 288, 4)
+#endif
+#ifndef OVERRIDE_TABLE_64_sys_signalfd4
+TRACE_SYSCALL_TABLE(sys_signalfd4, sys_signalfd4, 289, 4)
+#endif
+#ifndef OVERRIDE_TABLE_64_sys_pipe2
+TRACE_SYSCALL_TABLE(sys_pipe2, sys_pipe2, 293, 2)
+#endif
+#ifndef OVERRIDE_TABLE_64_sys_preadv
+TRACE_SYSCALL_TABLE(sys_preadv, sys_preadv, 295, 5)
+#endif
+#ifndef OVERRIDE_TABLE_64_sys_pwritev
+TRACE_SYSCALL_TABLE(sys_pwritev, sys_pwritev, 296, 5)
+#endif
+#ifndef OVERRIDE_TABLE_64_sys_rt_tgsigqueueinfo
+TRACE_SYSCALL_TABLE(sys_rt_tgsigqueueinfo, sys_rt_tgsigqueueinfo, 297, 4)
+#endif
+#ifndef OVERRIDE_TABLE_64_sys_perf_event_open
+TRACE_SYSCALL_TABLE(sys_perf_event_open, sys_perf_event_open, 298, 5)
+#endif
+#ifndef OVERRIDE_TABLE_64_sys_recvmmsg
+TRACE_SYSCALL_TABLE(sys_recvmmsg, sys_recvmmsg, 299, 5)
+#endif
+#ifndef OVERRIDE_TABLE_64_sys_fanotify_mark
+TRACE_SYSCALL_TABLE(sys_fanotify_mark, sys_fanotify_mark, 301, 5)
+#endif
+#ifndef OVERRIDE_TABLE_64_sys_prlimit64
+TRACE_SYSCALL_TABLE(sys_prlimit64, sys_prlimit64, 302, 4)
+#endif
+#ifndef OVERRIDE_TABLE_64_sys_name_to_handle_at
+TRACE_SYSCALL_TABLE(sys_name_to_handle_at, sys_name_to_handle_at, 303, 5)
+#endif
+#ifndef OVERRIDE_TABLE_64_sys_open_by_handle_at
+TRACE_SYSCALL_TABLE(sys_open_by_handle_at, sys_open_by_handle_at, 304, 3)
+#endif
+#ifndef OVERRIDE_TABLE_64_sys_clock_adjtime
+TRACE_SYSCALL_TABLE(sys_clock_adjtime, sys_clock_adjtime, 305, 2)
+#endif
+#ifndef OVERRIDE_TABLE_64_sys_sendmmsg
+TRACE_SYSCALL_TABLE(sys_sendmmsg, sys_sendmmsg, 307, 4)
+#endif
+#ifndef OVERRIDE_TABLE_64_sys_getcpu
+TRACE_SYSCALL_TABLE(sys_getcpu, sys_getcpu, 309, 3)
+#endif
+#ifndef OVERRIDE_TABLE_64_sys_process_vm_readv
+TRACE_SYSCALL_TABLE(sys_process_vm_readv, sys_process_vm_readv, 310, 6)
+#endif
+#ifndef OVERRIDE_TABLE_64_sys_process_vm_writev
+TRACE_SYSCALL_TABLE(sys_process_vm_writev, sys_process_vm_writev, 311, 6)
+#endif
+#ifndef OVERRIDE_TABLE_64_sys_finit_module
+TRACE_SYSCALL_TABLE(sys_finit_module, sys_finit_module, 313, 3)
+#endif
+
+#endif /* CREATE_SYSCALL_TABLE */
diff --git a/drivers/staging/lttng/instrumentation/syscalls/headers/x86-64-syscalls-3.10.0-rc7_pointers_override.h b/drivers/staging/lttng/instrumentation/syscalls/headers/x86-64-syscalls-3.10.0-rc7_pointers_override.h
new file mode 100644 (file)
index 0000000..8aa2abc
--- /dev/null
@@ -0,0 +1,12 @@
+#ifndef CREATE_SYSCALL_TABLE
+
+#else  /* CREATE_SYSCALL_TABLE */
+
+#define OVERRIDE_TABLE_64_sys_clone
+TRACE_SYSCALL_TABLE(sys_clone, sys_clone, 56, 5)
+#define OVERRIDE_TABLE_64_sys_execve
+TRACE_SYSCALL_TABLE(sys_execve, sys_execve, 59, 3)
+#define OVERRIDE_TABLE_64_sys_getcpu
+TRACE_SYSCALL_TABLE(sys_getcpu, sys_getcpu, 309, 3)
+
+#endif /* CREATE_SYSCALL_TABLE */
diff --git a/drivers/staging/lttng/instrumentation/syscalls/lttng-syscalls-extractor/Makefile b/drivers/staging/lttng/instrumentation/syscalls/lttng-syscalls-extractor/Makefile
new file mode 100644 (file)
index 0000000..4beb88c
--- /dev/null
@@ -0,0 +1 @@
+obj-m += lttng-syscalls-extractor.o
diff --git a/drivers/staging/lttng/instrumentation/syscalls/lttng-syscalls-extractor/lttng-syscalls-extractor.c b/drivers/staging/lttng/instrumentation/syscalls/lttng-syscalls-extractor/lttng-syscalls-extractor.c
new file mode 100644 (file)
index 0000000..4b77d8c
--- /dev/null
@@ -0,0 +1,100 @@
+/*
+ * lttng-syscalls-extractor.c
+ *
+ * Dump syscall metadata to console.
+ *
+ * Copyright 2011 - Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
+ * Copyright 2011 - Julien Desfossez <julien.desfossez@polymtl.ca>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+
+#include <linux/module.h>
+#include <linux/kernel.h>
+#include <linux/types.h>
+#include <linux/list.h>
+#include <linux/err.h>
+#include <linux/slab.h>
+#include <linux/kallsyms.h>
+#include <linux/dcache.h>
+#include <linux/ftrace_event.h>
+#include <trace/syscall.h>
+#include <asm/syscall.h>
+
+#ifndef CONFIG_FTRACE_SYSCALLS
+#error "You need to set CONFIG_FTRACE_SYSCALLS=y"
+#endif
+
+#ifndef CONFIG_KALLSYMS_ALL
+#error "You need to set CONFIG_KALLSYMS_ALL=y"
+#endif
+
+static struct syscall_metadata **__start_syscalls_metadata;
+static struct syscall_metadata **__stop_syscalls_metadata;
+
+static __init
+struct syscall_metadata *find_syscall_meta(unsigned long syscall)
+{
+       struct syscall_metadata **iter;
+
+       for (iter = __start_syscalls_metadata;
+                       iter < __stop_syscalls_metadata; iter++) {
+               if ((*iter)->syscall_nr == syscall)
+                       return (*iter);
+       }
+       return NULL;
+}
+
+int init_module(void)
+{
+       struct syscall_metadata *meta;
+       int i;
+
+       __start_syscalls_metadata = (void *) kallsyms_lookup_name("__start_syscalls_metadata");
+       __stop_syscalls_metadata = (void *) kallsyms_lookup_name("__stop_syscalls_metadata");
+
+       for (i = 0; i < NR_syscalls; i++) {
+               int j;
+
+               meta = find_syscall_meta(i);
+               if (!meta)
+                       continue;
+               printk("syscall %s nr %d nbargs %d ",
+                       meta->name, meta->syscall_nr, meta->nb_args);
+               printk("types: (");
+               for (j = 0; j < meta->nb_args; j++) {
+                       if (j > 0)
+                               printk(", ");
+                       printk("%s", meta->types[j]);
+               }
+               printk(") ");
+               printk("args: (");
+               for (j = 0; j < meta->nb_args; j++) {
+                       if (j > 0)
+                               printk(", ");
+                       printk("%s", meta->args[j]);
+               }
+               printk(")\n");
+       }
+       printk("SUCCESS\n");
+
+       return -1;
+}
+
+void cleanup_module(void)
+{
+}
+
+MODULE_LICENSE("GPL");
diff --git a/drivers/staging/lttng/instrumentation/syscalls/lttng-syscalls-generate-headers.sh b/drivers/staging/lttng/instrumentation/syscalls/lttng-syscalls-generate-headers.sh
new file mode 100644 (file)
index 0000000..30050c2
--- /dev/null
@@ -0,0 +1,279 @@
+#!/bin/sh
+
+# Generate system call probe description macros from syscall metadata dump file.
+# The resulting header will be written in the headers subdirectory, in a file name
+# based on the name of the input file.
+#
+# example usage:
+#
+# lttng-syscalls-generate-headers.sh <type> <input_dir> <input_filename_in_dir> <bitness>
+# lttng-syscalls-generate-headers.sh integers 3.0.4 x86-64-syscalls-3.0.4 64
+# lttng-syscalls-generate-headers.sh pointers 3.0.4 x86-64-syscalls-3.0.4 64
+
+CLASS=$1
+INPUTDIR=$2
+INPUTFILE=$3
+BITNESS=$4
+INPUT=${INPUTDIR}/${INPUTFILE}
+SRCFILE=gen.tmp.0
+TMPFILE=gen.tmp.1
+HEADER=headers/${INPUTFILE}_${CLASS}.h
+
+cp ${INPUT} ${SRCFILE}
+
+#Cleanup
+perl -p -e 's/^\[.*\] //g' ${SRCFILE} > ${TMPFILE}
+mv ${TMPFILE} ${SRCFILE}
+
+perl -p -e 's/^syscall sys_([^ ]*)/syscall $1/g' ${SRCFILE} > ${TMPFILE}
+mv ${TMPFILE} ${SRCFILE}
+
+#Filter
+
+if [ "$CLASS" = integers ]; then
+       #select integers and no-args.
+       CLASSCAP=INTEGERS
+       grep -v "\\*\|cap_user_header_t" ${SRCFILE} > ${TMPFILE}
+       mv ${TMPFILE} ${SRCFILE}
+fi
+
+
+if [ "$CLASS" = pointers ]; then
+       #select system calls using pointers.
+       CLASSCAP=POINTERS
+       grep "\\*\|cap_#user_header_t" ${SRCFILE} > ${TMPFILE}
+       mv ${TMPFILE} ${SRCFILE}
+fi
+
+echo "/* THIS FILE IS AUTO-GENERATED. DO NOT EDIT */" > ${HEADER}
+
+echo \
+"#ifndef CREATE_SYSCALL_TABLE
+
+#if !defined(_TRACE_SYSCALLS_${CLASSCAP}_H) || defined(TRACE_HEADER_MULTI_READ)
+#define _TRACE_SYSCALLS_${CLASSCAP}_H
+
+#include <linux/tracepoint.h>
+#include <linux/syscalls.h>
+#include \"${INPUTFILE}_${CLASS}_override.h\"
+#include \"syscalls_${CLASS}_override.h\"
+" >> ${HEADER}
+
+if [ "$CLASS" = integers ]; then
+
+NRARGS=0
+
+printf \
+'SC_DECLARE_EVENT_CLASS_NOARGS(syscalls_noargs,\n'\
+'      TP_STRUCT__entry(),\n'\
+'      TP_fast_assign(),\n'\
+'      TP_printk()\n'\
+')'\
+       >> ${HEADER}
+
+grep "^syscall [^ ]* nr [^ ]* nbargs ${NRARGS} " ${SRCFILE} > ${TMPFILE}
+perl -p -e 's/^syscall ([^ ]*) nr ([^ ]*) nbargs ([^ ]*) '\
+'types: \(([^)]*)\) '\
+'args: \(([^)]*)\)/'\
+'#ifndef OVERRIDE_'"${BITNESS}"'_sys_$1\n'\
+'SC_DEFINE_EVENT_NOARGS(syscalls_noargs, sys_$1)\n'\
+'#endif/g'\
+       ${TMPFILE} >> ${HEADER}
+
+fi
+
+
+# types: 4
+# args   5
+
+NRARGS=1
+grep "^syscall [^ ]* nr [^ ]* nbargs ${NRARGS} " ${SRCFILE} > ${TMPFILE}
+perl -p -e 's/^syscall ([^ ]*) nr ([^ ]*) nbargs ([^ ]*) '\
+'types: \(([^)]*)\) '\
+'args: \(([^)]*)\)/'\
+'#ifndef OVERRIDE_'"${BITNESS}"'_sys_$1\n'\
+'SC_TRACE_EVENT(sys_$1,\n'\
+'      TP_PROTO($4 $5),\n'\
+'      TP_ARGS($5),\n'\
+'      TP_STRUCT__entry(__field($4, $5)),\n'\
+'      TP_fast_assign(tp_assign($4, $5, $5)),\n'\
+'      TP_printk()\n'\
+')\n'\
+'#endif/g'\
+       ${TMPFILE} >> ${HEADER}
+
+# types: 4 5
+# args   6 7
+
+NRARGS=2
+grep "^syscall [^ ]* nr [^ ]* nbargs ${NRARGS} " ${SRCFILE} > ${TMPFILE}
+perl -p -e 's/^syscall ([^ ]*) nr ([^ ]*) nbargs ([^ ]*) '\
+'types: \(([^,]*), ([^)]*)\) '\
+'args: \(([^,]*), ([^)]*)\)/'\
+'#ifndef OVERRIDE_'"${BITNESS}"'_sys_$1\n'\
+'SC_TRACE_EVENT(sys_$1,\n'\
+'      TP_PROTO($4 $6, $5 $7),\n'\
+'      TP_ARGS($6, $7),\n'\
+'      TP_STRUCT__entry(__field($4, $6) __field($5, $7)),\n'\
+'      TP_fast_assign(tp_assign($4, $6, $6) tp_assign($5, $7, $7)),\n'\
+'      TP_printk()\n'\
+')\n'\
+'#endif/g'\
+       ${TMPFILE} >> ${HEADER}
+
+# types: 4 5 6
+# args   7 8 9
+
+NRARGS=3
+grep "^syscall [^ ]* nr [^ ]* nbargs ${NRARGS} " ${SRCFILE} > ${TMPFILE}
+perl -p -e 's/^syscall ([^ ]*) nr ([^ ]*) nbargs ([^ ]*) '\
+'types: \(([^,]*), ([^,]*), ([^)]*)\) '\
+'args: \(([^,]*), ([^,]*), ([^)]*)\)/'\
+'#ifndef OVERRIDE_'"${BITNESS}"'_sys_$1\n'\
+'SC_TRACE_EVENT(sys_$1,\n'\
+'      TP_PROTO($4 $7, $5 $8, $6 $9),\n'\
+'      TP_ARGS($7, $8, $9),\n'\
+'      TP_STRUCT__entry(__field($4, $7) __field($5, $8) __field($6, $9)),\n'\
+'      TP_fast_assign(tp_assign($4, $7, $7) tp_assign($5, $8, $8) tp_assign($6, $9, $9)),\n'\
+'      TP_printk()\n'\
+')\n'\
+'#endif/g'\
+       ${TMPFILE} >> ${HEADER}
+
+
+# types: 4 5  6  7
+# args   8 9 10 11
+
+NRARGS=4
+grep "^syscall [^ ]* nr [^ ]* nbargs ${NRARGS} " ${SRCFILE} > ${TMPFILE}
+perl -p -e 's/^syscall ([^ ]*) nr ([^ ]*) nbargs ([^ ]*) '\
+'types: \(([^,]*), ([^,]*), ([^,]*), ([^)]*)\) '\
+'args: \(([^,]*), ([^,]*), ([^,]*), ([^)]*)\)/'\
+'#ifndef OVERRIDE_'"${BITNESS}"'_sys_$1\n'\
+'SC_TRACE_EVENT(sys_$1,\n'\
+'      TP_PROTO($4 $8, $5 $9, $6 $10, $7 $11),\n'\
+'      TP_ARGS($8, $9, $10, $11),\n'\
+'      TP_STRUCT__entry(__field($4, $8) __field($5, $9) __field($6, $10) __field($7, $11)),\n'\
+'      TP_fast_assign(tp_assign($4, $8, $8) tp_assign($5, $9, $9) tp_assign($6, $10, $10) tp_assign($7, $11, $11)),\n'\
+'      TP_printk()\n'\
+')\n'\
+'#endif/g'\
+       ${TMPFILE} >> ${HEADER}
+
+# types: 4  5  6  7  8
+# args   9 10 11 12 13
+
+NRARGS=5
+grep "^syscall [^ ]* nr [^ ]* nbargs ${NRARGS} " ${SRCFILE} > ${TMPFILE}
+perl -p -e 's/^syscall ([^ ]*) nr ([^ ]*) nbargs ([^ ]*) '\
+'types: \(([^,]*), ([^,]*), ([^,]*), ([^,]*), ([^)]*)\) '\
+'args: \(([^,]*), ([^,]*), ([^,]*), ([^,]*), ([^)]*)\)/'\
+'#ifndef OVERRIDE_'"${BITNESS}"'_sys_$1\n'\
+'SC_TRACE_EVENT(sys_$1,\n'\
+'      TP_PROTO($4 $9, $5 $10, $6 $11, $7 $12, $8 $13),\n'\
+'      TP_ARGS($9, $10, $11, $12, $13),\n'\
+'      TP_STRUCT__entry(__field($4, $9) __field($5, $10) __field($6, $11) __field($7, $12) __field($8, $13)),\n'\
+'      TP_fast_assign(tp_assign($4, $9, $9) tp_assign($5, $10, $10) tp_assign($6, $11, $11) tp_assign($7, $12, $12) tp_assign($8, $13, $13)),\n'\
+'      TP_printk()\n'\
+')\n'\
+'#endif/g'\
+       ${TMPFILE} >> ${HEADER}
+
+
+# types: 4   5  6  7  8  9
+# args   10 11 12 13 14 15
+
+NRARGS=6
+grep "^syscall [^ ]* nr [^ ]* nbargs ${NRARGS} " ${SRCFILE} > ${TMPFILE}
+perl -p -e 's/^syscall ([^ ]*) nr ([^ ]*) nbargs ([^ ]*) '\
+'types: \(([^,]*), ([^,]*), ([^,]*), ([^,]*), ([^,]*), ([^\)]*)\) '\
+'args: \(([^,]*), ([^,]*), ([^,]*), ([^,]*), ([^,]*), ([^\)]*)\)/'\
+'#ifndef OVERRIDE_'"${BITNESS}"'_sys_$1\n'\
+'SC_TRACE_EVENT(sys_$1,\n'\
+'      TP_PROTO($4 $10, $5 $11, $6 $12, $7 $13, $8 $14, $9 $15),\n'\
+'      TP_ARGS($10, $11, $12, $13, $14, $15),\n'\
+'      TP_STRUCT__entry(__field($4, $10) __field($5, $11) __field($6, $12) __field($7, $13) __field($8, $14) __field($9, $15)),\n'\
+'      TP_fast_assign(tp_assign($4, $10, $10) tp_assign($5, $11, $11) tp_assign($6, $12, $12) tp_assign($7, $13, $13) tp_assign($8, $14, $14) tp_assign($9, $15, $15)),\n'\
+'      TP_printk()\n'\
+')\n'\
+'#endif/g'\
+       ${TMPFILE} >> ${HEADER}
+
+# Macro for tracing syscall table
+
+rm -f ${TMPFILE}
+for NRARGS in $(seq 0 6); do
+       grep "^syscall [^ ]* nr [^ ]* nbargs ${NRARGS} " ${SRCFILE} >> ${TMPFILE}
+done
+
+echo \
+"
+#endif /*  _TRACE_SYSCALLS_${CLASSCAP}_H */
+
+/* This part must be outside protection */
+#include \"../../../probes/define_trace.h\"
+
+#else /* CREATE_SYSCALL_TABLE */
+
+#include \"${INPUTFILE}_${CLASS}_override.h\"
+#include \"syscalls_${CLASS}_override.h\"
+" >> ${HEADER}
+
+NRARGS=0
+
+if [ "$CLASS" = integers ]; then
+#noargs
+grep "^syscall [^ ]* nr [^ ]* nbargs ${NRARGS} " ${SRCFILE} > ${TMPFILE}
+perl -p -e 's/^syscall ([^ ]*) nr ([^ ]*) nbargs ([^ ]*) .*$/'\
+'#ifndef OVERRIDE_TABLE_'"${BITNESS}"'_sys_$1\n'\
+'TRACE_SYSCALL_TABLE\(syscalls_noargs, sys_$1, $2, $3\)\n'\
+'#endif/g'\
+       ${TMPFILE} >> ${HEADER}
+fi
+
+#others.
+grep -v "^syscall [^ ]* nr [^ ]* nbargs ${NRARGS} " ${SRCFILE} > ${TMPFILE}
+perl -p -e 's/^syscall ([^ ]*) nr ([^ ]*) nbargs ([^ ]*) .*$/'\
+'#ifndef OVERRIDE_TABLE_'"${BITNESS}"'_sys_$1\n'\
+'TRACE_SYSCALL_TABLE(sys_$1, sys_$1, $2, $3)\n'\
+'#endif/g'\
+       ${TMPFILE} >> ${HEADER}
+
+echo -n \
+"
+#endif /* CREATE_SYSCALL_TABLE */
+" >> ${HEADER}
+
+#fields names: ...char * type with *name* or *file* or *path* or *root*
+# or *put_old* or *type*
+cp -f ${HEADER} ${TMPFILE}
+rm -f ${HEADER}
+perl -p -e 's/__field\(([^,)]*char \*), ([^\)]*)(name|file|path|root|put_old|type)([^\)]*)\)/__string_from_user($2$3$4, $2$3$4)/g'\
+       ${TMPFILE} >> ${HEADER}
+cp -f ${HEADER} ${TMPFILE}
+rm -f ${HEADER}
+perl -p -e 's/tp_assign\(([^,)]*char \*), ([^,]*)(name|file|path|root|put_old|type)([^,]*), ([^\)]*)\)/tp_copy_string_from_user($2$3$4, $5)/g'\
+       ${TMPFILE} >> ${HEADER}
+
+#prettify addresses heuristics.
+#field names with addr or ptr
+cp -f ${HEADER} ${TMPFILE}
+rm -f ${HEADER}
+perl -p -e 's/__field\(([^,)]*), ([^,)]*addr|[^,)]*ptr)([^),]*)\)/__field_hex($1, $2$3)/g'\
+       ${TMPFILE} >> ${HEADER}
+
+#field types ending with '*'
+cp -f ${HEADER} ${TMPFILE}
+rm -f ${HEADER}
+perl -p -e 's/__field\(([^,)]*\*), ([^),]*)\)/__field_hex($1, $2)/g'\
+       ${TMPFILE} >> ${HEADER}
+
+#strip the extra type information from tp_assign.
+cp -f ${HEADER} ${TMPFILE}
+rm -f ${HEADER}
+perl -p -e 's/tp_assign\(([^,)]*), ([^,]*), ([^\)]*)\)/tp_assign($2, $3)/g'\
+       ${TMPFILE} >> ${HEADER}
+
+rm -f ${INPUTFILE}.tmp
+rm -f ${TMPFILE}
+rm -f ${SRCFILE}
diff --git a/drivers/staging/lttng/lib/Makefile b/drivers/staging/lttng/lib/Makefile
new file mode 100644 (file)
index 0000000..5f092f5
--- /dev/null
@@ -0,0 +1,11 @@
+obj-m += lttng-lib-ring-buffer.o
+
+lttng-lib-ring-buffer-objs := \
+       ringbuffer/ring_buffer_backend.o \
+       ringbuffer/ring_buffer_frontend.o \
+       ringbuffer/ring_buffer_iterator.o \
+       ringbuffer/ring_buffer_vfs.o \
+       ringbuffer/ring_buffer_splice.o \
+       ringbuffer/ring_buffer_mmap.o \
+       prio_heap/lttng_prio_heap.o \
+       ../wrapper/splice.o
diff --git a/drivers/staging/lttng/lib/align.h b/drivers/staging/lttng/lib/align.h
new file mode 100644 (file)
index 0000000..4929c51
--- /dev/null
@@ -0,0 +1,73 @@
+#ifndef _LTTNG_ALIGN_H
+#define _LTTNG_ALIGN_H
+
+/*
+ * lib/align.h
+ *
+ * Copyright (C) 2010-2012 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; only
+ * version 2.1 of the License.
+ *
+ * This library 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
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#ifdef __KERNEL__
+
+#include <linux/types.h>
+#include "bug.h"
+
+#define ALIGN_FLOOR(x, a)      __ALIGN_FLOOR_MASK(x, (typeof(x)) (a) - 1)
+#define __ALIGN_FLOOR_MASK(x, mask)    ((x) & ~(mask))
+#define PTR_ALIGN_FLOOR(p, a) \
+                       ((typeof(p)) ALIGN_FLOOR((unsigned long) (p), a))
+
+/*
+ * Align pointer on natural object alignment.
+ */
+#define object_align(obj)      PTR_ALIGN(obj, __alignof__(*(obj)))
+#define object_align_floor(obj)        PTR_ALIGN_FLOOR(obj, __alignof__(*(obj)))
+
+/**
+ * offset_align - Calculate the offset needed to align an object on its natural
+ *                alignment towards higher addresses.
+ * @align_drift:  object offset from an "alignment"-aligned address.
+ * @alignment:    natural object alignment. Must be non-zero, power of 2.
+ *
+ * Returns the offset that must be added to align towards higher
+ * addresses.
+ */
+#define offset_align(align_drift, alignment)                                  \
+       ({                                                                     \
+               BUILD_RUNTIME_BUG_ON((alignment) == 0                          \
+                                  || ((alignment) & ((alignment) - 1)));      \
+               (((alignment) - (align_drift)) & ((alignment) - 1));           \
+       })
+
+/**
+ * offset_align_floor - Calculate the offset needed to align an object
+ *                      on its natural alignment towards lower addresses.
+ * @align_drift:  object offset from an "alignment"-aligned address.
+ * @alignment:    natural object alignment. Must be non-zero, power of 2.
+ *
+ * Returns the offset that must be substracted to align towards lower addresses.
+ */
+#define offset_align_floor(align_drift, alignment)                            \
+       ({                                                                     \
+               BUILD_RUNTIME_BUG_ON((alignment) == 0                          \
+                                  || ((alignment) & ((alignment) - 1)));      \
+               (((align_drift) - (alignment)) & ((alignment) - 1);            \
+       })
+
+#endif /* __KERNEL__ */
+
+#endif
diff --git a/drivers/staging/lttng/lib/bitfield.h b/drivers/staging/lttng/lib/bitfield.h
new file mode 100644 (file)
index 0000000..4d8d305
--- /dev/null
@@ -0,0 +1,408 @@
+#ifndef _BABELTRACE_BITFIELD_H
+#define _BABELTRACE_BITFIELD_H
+
+/*
+ * BabelTrace
+ *
+ * Bitfields read/write functions.
+ *
+ * Copyright 2010 - Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+#include "../lttng-endian.h"
+
+#ifndef CHAR_BIT
+#define CHAR_BIT 8
+#endif
+
+/* We can't shift a int from 32 bit, >> 32 and << 32 on int is undefined */
+#define _bt_piecewise_rshift(_v, _shift)                               \
+({                                                                     \
+       typeof(_v) ___v = (_v);                                         \
+       typeof(_shift) ___shift = (_shift);                             \
+       unsigned long sb = (___shift) / (sizeof(___v) * CHAR_BIT - 1);  \
+       unsigned long final = (___shift) % (sizeof(___v) * CHAR_BIT - 1); \
+                                                                       \
+       for (; sb; sb--)                                                \
+               ___v >>= sizeof(___v) * CHAR_BIT - 1;                   \
+       ___v >>= final;                                                 \
+})
+
+#define _bt_piecewise_lshift(_v, _shift)                               \
+({                                                                     \
+       typeof(_v) ___v = (_v);                                         \
+       typeof(_shift) ___shift = (_shift);                             \
+       unsigned long sb = (___shift) / (sizeof(___v) * CHAR_BIT - 1);  \
+       unsigned long final = (___shift) % (sizeof(___v) * CHAR_BIT - 1); \
+                                                                       \
+       for (; sb; sb--)                                                \
+               ___v <<= sizeof(___v) * CHAR_BIT - 1;                   \
+       ___v <<= final;                                                 \
+})
+
+#define _bt_is_signed_type(type)       (((type)(-1)) < 0)
+
+#define _bt_unsigned_cast(type, v)                                     \
+({                                                                     \
+       (sizeof(v) < sizeof(type)) ?                                    \
+               ((type) (v)) & (~(~(type) 0 << (sizeof(v) * CHAR_BIT))) : \
+               (type) (v);                                             \
+})
+
+/*
+ * bt_bitfield_write - write integer to a bitfield in native endianness
+ *
+ * Save integer to the bitfield, which starts at the "start" bit, has "len"
+ * bits.
+ * The inside of a bitfield is from high bits to low bits.
+ * Uses native endianness.
+ * For unsigned "v", pad MSB with 0 if bitfield is larger than v.
+ * For signed "v", sign-extend v if bitfield is larger than v.
+ *
+ * On little endian, bytes are placed from the less significant to the most
+ * significant. Also, consecutive bitfields are placed from lower bits to higher
+ * bits.
+ *
+ * On big endian, bytes are places from most significant to less significant.
+ * Also, consecutive bitfields are placed from higher to lower bits.
+ */
+
+#define _bt_bitfield_write_le(_ptr, type, _start, _length, _v)         \
+do {                                                                   \
+       typeof(_v) __v = (_v);                                          \
+       type *__ptr = (void *) (_ptr);                                  \
+       unsigned long __start = (_start), __length = (_length);         \
+       type mask, cmask;                                               \
+       unsigned long ts = sizeof(type) * CHAR_BIT; /* type size */     \
+       unsigned long start_unit, end_unit, this_unit;                  \
+       unsigned long end, cshift; /* cshift is "complement shift" */   \
+                                                                       \
+       if (!__length)                                                  \
+               break;                                                  \
+                                                                       \
+       end = __start + __length;                                       \
+       start_unit = __start / ts;                                      \
+       end_unit = (end + (ts - 1)) / ts;                               \
+                                                                       \
+       /* Trim v high bits */                                          \
+       if (__length < sizeof(__v) * CHAR_BIT)                          \
+               __v &= ~((~(typeof(__v)) 0) << __length);               \
+                                                                       \
+       /* We can now append v with a simple "or", shift it piece-wise */ \
+       this_unit = start_unit;                                         \
+       if (start_unit == end_unit - 1) {                               \
+               mask = ~((~(type) 0) << (__start % ts));                \
+               if (end % ts)                                           \
+                       mask |= (~(type) 0) << (end % ts);              \
+               cmask = (type) __v << (__start % ts);                   \
+               cmask &= ~mask;                                         \
+               __ptr[this_unit] &= mask;                               \
+               __ptr[this_unit] |= cmask;                              \
+               break;                                                  \
+       }                                                               \
+       if (__start % ts) {                                             \
+               cshift = __start % ts;                                  \
+               mask = ~((~(type) 0) << cshift);                        \
+               cmask = (type) __v << cshift;                           \
+               cmask &= ~mask;                                         \
+               __ptr[this_unit] &= mask;                               \
+               __ptr[this_unit] |= cmask;                              \
+               __v = _bt_piecewise_rshift(__v, ts - cshift);           \
+               __start += ts - cshift;                                 \
+               this_unit++;                                            \
+       }                                                               \
+       for (; this_unit < end_unit - 1; this_unit++) {                 \
+               __ptr[this_unit] = (type) __v;                          \
+               __v = _bt_piecewise_rshift(__v, ts);                    \
+               __start += ts;                                          \
+       }                                                               \
+       if (end % ts) {                                                 \
+               mask = (~(type) 0) << (end % ts);                       \
+               cmask = (type) __v;                                     \
+               cmask &= ~mask;                                         \
+               __ptr[this_unit] &= mask;                               \
+               __ptr[this_unit] |= cmask;                              \
+       } else                                                          \
+               __ptr[this_unit] = (type) __v;                          \
+} while (0)
+
+#define _bt_bitfield_write_be(_ptr, type, _start, _length, _v)         \
+do {                                                                   \
+       typeof(_v) __v = (_v);                                          \
+       type *__ptr = (void *) (_ptr);                                  \
+       unsigned long __start = (_start), __length = (_length);         \
+       type mask, cmask;                                               \
+       unsigned long ts = sizeof(type) * CHAR_BIT; /* type size */     \
+       unsigned long start_unit, end_unit, this_unit;                  \
+       unsigned long end, cshift; /* cshift is "complement shift" */   \
+                                                                       \
+       if (!__length)                                                  \
+               break;                                                  \
+                                                                       \
+       end = __start + __length;                                       \
+       start_unit = __start / ts;                                      \
+       end_unit = (end + (ts - 1)) / ts;                               \
+                                                                       \
+       /* Trim v high bits */                                          \
+       if (__length < sizeof(__v) * CHAR_BIT)                          \
+               __v &= ~((~(typeof(__v)) 0) << __length);               \
+                                                                       \
+       /* We can now append v with a simple "or", shift it piece-wise */ \
+       this_unit = end_unit - 1;                                       \
+       if (start_unit == end_unit - 1) {                               \
+               mask = ~((~(type) 0) << ((ts - (end % ts)) % ts));      \
+               if (__start % ts)                                       \
+                       mask |= (~((type) 0)) << (ts - (__start % ts)); \
+               cmask = (type) __v << ((ts - (end % ts)) % ts);         \
+               cmask &= ~mask;                                         \
+               __ptr[this_unit] &= mask;                               \
+               __ptr[this_unit] |= cmask;                              \
+               break;                                                  \
+       }                                                               \
+       if (end % ts) {                                                 \
+               cshift = end % ts;                                      \
+               mask = ~((~(type) 0) << (ts - cshift));                 \
+               cmask = (type) __v << (ts - cshift);                    \
+               cmask &= ~mask;                                         \
+               __ptr[this_unit] &= mask;                               \
+               __ptr[this_unit] |= cmask;                              \
+               __v = _bt_piecewise_rshift(__v, cshift);                \
+               end -= cshift;                                          \
+               this_unit--;                                            \
+       }                                                               \
+       for (; (long) this_unit >= (long) start_unit + 1; this_unit--) { \
+               __ptr[this_unit] = (type) __v;                          \
+               __v = _bt_piecewise_rshift(__v, ts);                    \
+               end -= ts;                                              \
+       }                                                               \
+       if (__start % ts) {                                             \
+               mask = (~(type) 0) << (ts - (__start % ts));            \
+               cmask = (type) __v;                                     \
+               cmask &= ~mask;                                         \
+               __ptr[this_unit] &= mask;                               \
+               __ptr[this_unit] |= cmask;                              \
+       } else                                                          \
+               __ptr[this_unit] = (type) __v;                          \
+} while (0)
+
+/*
+ * bt_bitfield_write - write integer to a bitfield in native endianness
+ * bt_bitfield_write_le - write integer to a bitfield in little endian
+ * bt_bitfield_write_be - write integer to a bitfield in big endian
+ */
+
+#if (__BYTE_ORDER == __LITTLE_ENDIAN)
+
+#define bt_bitfield_write(ptr, type, _start, _length, _v)              \
+       _bt_bitfield_write_le(ptr, type, _start, _length, _v)
+
+#define bt_bitfield_write_le(ptr, type, _start, _length, _v)           \
+       _bt_bitfield_write_le(ptr, type, _start, _length, _v)
+
+#define bt_bitfield_write_be(ptr, type, _start, _length, _v)           \
+       _bt_bitfield_write_be(ptr, unsigned char, _start, _length, _v)
+
+#elif (__BYTE_ORDER == __BIG_ENDIAN)
+
+#define bt_bitfield_write(ptr, type, _start, _length, _v)              \
+       _bt_bitfield_write_be(ptr, type, _start, _length, _v)
+
+#define bt_bitfield_write_le(ptr, type, _start, _length, _v)           \
+       _bt_bitfield_write_le(ptr, unsigned char, _start, _length, _v)
+
+#define bt_bitfield_write_be(ptr, type, _start, _length, _v)           \
+       _bt_bitfield_write_be(ptr, type, _start, _length, _v)
+
+#else /* (BYTE_ORDER == PDP_ENDIAN) */
+
+#error "Byte order not supported"
+
+#endif
+
+#define _bt_bitfield_read_le(_ptr, type, _start, _length, _vptr)       \
+do {                                                                   \
+       typeof(*(_vptr)) *__vptr = (_vptr);                             \
+       typeof(*__vptr) __v;                                            \
+       type *__ptr = (void *) (_ptr);                                  \
+       unsigned long __start = (_start), __length = (_length);         \
+       type mask, cmask;                                               \
+       unsigned long ts = sizeof(type) * CHAR_BIT; /* type size */     \
+       unsigned long start_unit, end_unit, this_unit;                  \
+       unsigned long end, cshift; /* cshift is "complement shift" */   \
+                                                                       \
+       if (!__length) {                                                \
+               *__vptr = 0;                                            \
+               break;                                                  \
+       }                                                               \
+                                                                       \
+       end = __start + __length;                                       \
+       start_unit = __start / ts;                                      \
+       end_unit = (end + (ts - 1)) / ts;                               \
+                                                                       \
+       this_unit = end_unit - 1;                                       \
+       if (_bt_is_signed_type(typeof(__v))                             \
+           && (__ptr[this_unit] & ((type) 1 << ((end % ts ? : ts) - 1)))) \
+               __v = ~(typeof(__v)) 0;                                 \
+       else                                                            \
+               __v = 0;                                                \
+       if (start_unit == end_unit - 1) {                               \
+               cmask = __ptr[this_unit];                               \
+               cmask >>= (__start % ts);                               \
+               if ((end - __start) % ts) {                             \
+                       mask = ~((~(type) 0) << (end - __start));       \
+                       cmask &= mask;                                  \
+               }                                                       \
+               __v = _bt_piecewise_lshift(__v, end - __start);         \
+               __v |= _bt_unsigned_cast(typeof(__v), cmask);           \
+               *__vptr = __v;                                          \
+               break;                                                  \
+       }                                                               \
+       if (end % ts) {                                                 \
+               cshift = end % ts;                                      \
+               mask = ~((~(type) 0) << cshift);                        \
+               cmask = __ptr[this_unit];                               \
+               cmask &= mask;                                          \
+               __v = _bt_piecewise_lshift(__v, cshift);                \
+               __v |= _bt_unsigned_cast(typeof(__v), cmask);           \
+               end -= cshift;                                          \
+               this_unit--;                                            \
+       }                                                               \
+       for (; (long) this_unit >= (long) start_unit + 1; this_unit--) { \
+               __v = _bt_piecewise_lshift(__v, ts);                    \
+               __v |= _bt_unsigned_cast(typeof(__v), __ptr[this_unit]);\
+               end -= ts;                                              \
+       }                                                               \
+       if (__start % ts) {                                             \
+               mask = ~((~(type) 0) << (ts - (__start % ts)));         \
+               cmask = __ptr[this_unit];                               \
+               cmask >>= (__start % ts);                               \
+               cmask &= mask;                                          \
+               __v = _bt_piecewise_lshift(__v, ts - (__start % ts));   \
+               __v |= _bt_unsigned_cast(typeof(__v), cmask);           \
+       } else {                                                        \
+               __v = _bt_piecewise_lshift(__v, ts);                    \
+               __v |= _bt_unsigned_cast(typeof(__v), __ptr[this_unit]);\
+       }                                                               \
+       *__vptr = __v;                                                  \
+} while (0)
+
+#define _bt_bitfield_read_be(_ptr, type, _start, _length, _vptr)       \
+do {                                                                   \
+       typeof(*(_vptr)) *__vptr = (_vptr);                             \
+       typeof(*__vptr) __v;                                            \
+       type *__ptr = (void *) (_ptr);                                  \
+       unsigned long __start = (_start), __length = (_length);         \
+       type mask, cmask;                                               \
+       unsigned long ts = sizeof(type) * CHAR_BIT; /* type size */     \
+       unsigned long start_unit, end_unit, this_unit;                  \
+       unsigned long end, cshift; /* cshift is "complement shift" */   \
+                                                                       \
+       if (!__length) {                                                \
+               *__vptr = 0;                                            \
+               break;                                                  \
+       }                                                               \
+                                                                       \
+       end = __start + __length;                                       \
+       start_unit = __start / ts;                                      \
+       end_unit = (end + (ts - 1)) / ts;                               \
+                                                                       \
+       this_unit = start_unit;                                         \
+       if (_bt_is_signed_type(typeof(__v))                             \
+           && (__ptr[this_unit] & ((type) 1 << (ts - (__start % ts) - 1)))) \
+               __v = ~(typeof(__v)) 0;                                 \
+       else                                                            \
+               __v = 0;                                                \
+       if (start_unit == end_unit - 1) {                               \
+               cmask = __ptr[this_unit];                               \
+               cmask >>= (ts - (end % ts)) % ts;                       \
+               if ((end - __start) % ts) {                             \
+                       mask = ~((~(type) 0) << (end - __start));       \
+                       cmask &= mask;                                  \
+               }                                                       \
+               __v = _bt_piecewise_lshift(__v, end - __start);         \
+               __v |= _bt_unsigned_cast(typeof(__v), cmask);           \
+               *__vptr = __v;                                          \
+               break;                                                  \
+       }                                                               \
+       if (__start % ts) {                                             \
+               cshift = __start % ts;                                  \
+               mask = ~((~(type) 0) << (ts - cshift));                 \
+               cmask = __ptr[this_unit];                               \
+               cmask &= mask;                                          \
+               __v = _bt_piecewise_lshift(__v, ts - cshift);           \
+               __v |= _bt_unsigned_cast(typeof(__v), cmask);           \
+               __start += ts - cshift;                                 \
+               this_unit++;                                            \
+       }                                                               \
+       for (; this_unit < end_unit - 1; this_unit++) {                 \
+               __v = _bt_piecewise_lshift(__v, ts);                    \
+               __v |= _bt_unsigned_cast(typeof(__v), __ptr[this_unit]);\
+               __start += ts;                                          \
+       }                                                               \
+       if (end % ts) {                                                 \
+               mask = ~((~(type) 0) << (end % ts));                    \
+               cmask = __ptr[this_unit];                               \
+               cmask >>= ts - (end % ts);                              \
+               cmask &= mask;                                          \
+               __v = _bt_piecewise_lshift(__v, end % ts);              \
+               __v |= _bt_unsigned_cast(typeof(__v), cmask);           \
+       } else {                                                        \
+               __v = _bt_piecewise_lshift(__v, ts);                    \
+               __v |= _bt_unsigned_cast(typeof(__v), __ptr[this_unit]);\
+       }                                                               \
+       *__vptr = __v;                                                  \
+} while (0)
+
+/*
+ * bt_bitfield_read - read integer from a bitfield in native endianness
+ * bt_bitfield_read_le - read integer from a bitfield in little endian
+ * bt_bitfield_read_be - read integer from a bitfield in big endian
+ */
+
+#if (__BYTE_ORDER == __LITTLE_ENDIAN)
+
+#define bt_bitfield_read(_ptr, type, _start, _length, _vptr)           \
+       _bt_bitfield_read_le(_ptr, type, _start, _length, _vptr)
+
+#define bt_bitfield_read_le(_ptr, type, _start, _length, _vptr)                \
+       _bt_bitfield_read_le(_ptr, type, _start, _length, _vptr)
+
+#define bt_bitfield_read_be(_ptr, type, _start, _length, _vptr)                \
+       _bt_bitfield_read_be(_ptr, unsigned char, _start, _length, _vptr)
+
+#elif (__BYTE_ORDER == __BIG_ENDIAN)
+
+#define bt_bitfield_read(_ptr, type, _start, _length, _vptr)           \
+       _bt_bitfield_read_be(_ptr, type, _start, _length, _vptr)
+
+#define bt_bitfield_read_le(_ptr, type, _start, _length, _vptr)                \
+       _bt_bitfield_read_le(_ptr, unsigned char, _start, _length, _vptr)
+
+#define bt_bitfield_read_be(_ptr, type, _start, _length, _vptr)                \
+       _bt_bitfield_read_be(_ptr, type, _start, _length, _vptr)
+
+#else /* (__BYTE_ORDER == __PDP_ENDIAN) */
+
+#error "Byte order not supported"
+
+#endif
+
+#endif /* _BABELTRACE_BITFIELD_H */
diff --git a/drivers/staging/lttng/lib/bug.h b/drivers/staging/lttng/lib/bug.h
new file mode 100644 (file)
index 0000000..ecd4928
--- /dev/null
@@ -0,0 +1,41 @@
+#ifndef _LTTNG_BUG_H
+#define _LTTNG_BUG_H
+
+/*
+ * lib/bug.h
+ *
+ * Copyright (C) 2010-2012 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; only
+ * version 2.1 of the License.
+ *
+ * This library 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
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+/**
+ * BUILD_RUNTIME_BUG_ON - check condition at build (if constant) or runtime
+ * @condition: the condition which should be false.
+ *
+ * If the condition is a constant and true, the compiler will generate a build
+ * error. If the condition is not constant, a BUG will be triggered at runtime
+ * if the condition is ever true. If the condition is constant and false, no
+ * code is emitted.
+ */
+#define BUILD_RUNTIME_BUG_ON(condition)                                \
+       do {                                                    \
+               if (__builtin_constant_p(condition))            \
+                       BUILD_BUG_ON(condition);                \
+               else                                            \
+                       BUG_ON(condition);                      \
+       } while (0)
+
+#endif
diff --git a/drivers/staging/lttng/lib/prio_heap/lttng_prio_heap.c b/drivers/staging/lttng/lib/prio_heap/lttng_prio_heap.c
new file mode 100644 (file)
index 0000000..d296da0
--- /dev/null
@@ -0,0 +1,215 @@
+/*
+ * lttng_prio_heap.c
+ *
+ * Priority heap containing pointers. Based on CLRS, chapter 6.
+ *
+ * Copyright 2011 - Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+#include <linux/slab.h>
+#include "lttng_prio_heap.h"
+
+#ifdef DEBUG_HEAP
+void lttng_check_heap(const struct lttng_ptr_heap *heap)
+{
+       size_t i;
+
+       if (!heap->len)
+               return;
+
+       for (i = 1; i < heap->len; i++)
+               WARN_ON_ONCE(!heap->gt(heap->ptrs[i], heap->ptrs[0]));
+}
+#endif
+
+static
+size_t parent(size_t i)
+{
+       return (i -1) >> 1;
+}
+
+static
+size_t left(size_t i)
+{
+       return (i << 1) + 1;
+}
+
+static
+size_t right(size_t i)
+{
+       return (i << 1) + 2;
+}
+
+/*
+ * Copy of heap->ptrs pointer is invalid after heap_grow.
+ */
+static
+int heap_grow(struct lttng_ptr_heap *heap, size_t new_len)
+{
+       void **new_ptrs;
+
+       if (heap->alloc_len >= new_len)
+               return 0;
+
+       heap->alloc_len = max_t(size_t, new_len, heap->alloc_len << 1);
+       new_ptrs = kmalloc(heap->alloc_len * sizeof(void *), heap->gfpmask);
+       if (!new_ptrs)
+               return -ENOMEM;
+       if (heap->ptrs)
+               memcpy(new_ptrs, heap->ptrs, heap->len * sizeof(void *));
+       kfree(heap->ptrs);
+       heap->ptrs = new_ptrs;
+       return 0;
+}
+
+static
+int heap_set_len(struct lttng_ptr_heap *heap, size_t new_len)
+{
+       int ret;
+
+       ret = heap_grow(heap, new_len);
+       if (ret)
+               return ret;
+       heap->len = new_len;
+       return 0;
+}
+
+int lttng_heap_init(struct lttng_ptr_heap *heap, size_t alloc_len,
+             gfp_t gfpmask, int gt(void *a, void *b))
+{
+       heap->ptrs = NULL;
+       heap->len = 0;
+       heap->alloc_len = 0;
+       heap->gt = gt;
+       heap->gfpmask = gfpmask;
+       /*
+        * Minimum size allocated is 1 entry to ensure memory allocation
+        * never fails within heap_replace_max.
+        */
+       return heap_grow(heap, max_t(size_t, 1, alloc_len));
+}
+
+void lttng_heap_free(struct lttng_ptr_heap *heap)
+{
+       kfree(heap->ptrs);
+}
+
+static void heapify(struct lttng_ptr_heap *heap, size_t i)
+{
+       void **ptrs = heap->ptrs;
+       size_t l, r, largest;
+
+       for (;;) {
+               void *tmp;
+
+               l = left(i);
+               r = right(i);
+               if (l < heap->len && heap->gt(ptrs[l], ptrs[i]))
+                       largest = l;
+               else
+                       largest = i;
+               if (r < heap->len && heap->gt(ptrs[r], ptrs[largest]))
+                       largest = r;
+               if (largest == i)
+                       break;
+               tmp = ptrs[i];
+               ptrs[i] = ptrs[largest];
+               ptrs[largest] = tmp;
+               i = largest;
+       }
+       lttng_check_heap(heap);
+}
+
+void *lttng_heap_replace_max(struct lttng_ptr_heap *heap, void *p)
+{
+       void *res;
+
+       if (!heap->len) {
+               (void) heap_set_len(heap, 1);
+               heap->ptrs[0] = p;
+               lttng_check_heap(heap);
+               return NULL;
+       }
+
+       /* Replace the current max and heapify */
+       res = heap->ptrs[0];
+       heap->ptrs[0] = p;
+       heapify(heap, 0);
+       return res;
+}
+
+int lttng_heap_insert(struct lttng_ptr_heap *heap, void *p)
+{
+       void **ptrs;
+       size_t pos;
+       int ret;
+
+       ret = heap_set_len(heap, heap->len + 1);
+       if (ret)
+               return ret;
+       ptrs = heap->ptrs;
+       pos = heap->len - 1;
+       while (pos > 0 && heap->gt(p, ptrs[parent(pos)])) {
+               /* Move parent down until we find the right spot */
+               ptrs[pos] = ptrs[parent(pos)];
+               pos = parent(pos);
+       }
+       ptrs[pos] = p;
+       lttng_check_heap(heap);
+       return 0;
+}
+
+void *lttng_heap_remove(struct lttng_ptr_heap *heap)
+{
+       switch (heap->len) {
+       case 0:
+               return NULL;
+       case 1:
+               (void) heap_set_len(heap, 0);
+               return heap->ptrs[0];
+       }
+       /* Shrink, replace the current max by previous last entry and heapify */
+       heap_set_len(heap, heap->len - 1);
+       /* len changed. previous last entry is at heap->len */
+       return lttng_heap_replace_max(heap, heap->ptrs[heap->len]);
+}
+
+void *lttng_heap_cherrypick(struct lttng_ptr_heap *heap, void *p)
+{
+       size_t pos, len = heap->len;
+
+       for (pos = 0; pos < len; pos++)
+               if (heap->ptrs[pos] == p)
+                       goto found;
+       return NULL;
+found:
+       if (heap->len == 1) {
+               (void) heap_set_len(heap, 0);
+               lttng_check_heap(heap);
+               return heap->ptrs[0];
+       }
+       /* Replace p with previous last entry and heapify. */
+       heap_set_len(heap, heap->len - 1);
+       /* len changed. previous last entry is at heap->len */
+       heap->ptrs[pos] = heap->ptrs[heap->len];
+       heapify(heap, pos);
+       return p;
+}
diff --git a/drivers/staging/lttng/lib/prio_heap/lttng_prio_heap.h b/drivers/staging/lttng/lib/prio_heap/lttng_prio_heap.h
new file mode 100644 (file)
index 0000000..6d58455
--- /dev/null
@@ -0,0 +1,125 @@
+#ifndef _LTTNG_PRIO_HEAP_H
+#define _LTTNG_PRIO_HEAP_H
+
+/*
+ * lttng_prio_heap.h
+ *
+ * Priority heap containing pointers. Based on CLRS, chapter 6.
+ *
+ * Copyright 2011 - Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+#include <linux/gfp.h>
+
+struct lttng_ptr_heap {
+       size_t len, alloc_len;
+       void **ptrs;
+       int (*gt)(void *a, void *b);
+       gfp_t gfpmask;
+};
+
+#ifdef DEBUG_HEAP
+void lttng_check_heap(const struct lttng_ptr_heap *heap);
+#else
+static inline
+void lttng_check_heap(const struct lttng_ptr_heap *heap)
+{
+}
+#endif
+
+/**
+ * lttng_heap_maximum - return the largest element in the heap
+ * @heap: the heap to be operated on
+ *
+ * Returns the largest element in the heap, without performing any modification
+ * to the heap structure. Returns NULL if the heap is empty.
+ */
+static inline void *lttng_heap_maximum(const struct lttng_ptr_heap *heap)
+{
+       lttng_check_heap(heap);
+       return heap->len ? heap->ptrs[0] : NULL;
+}
+
+/**
+ * lttng_heap_init - initialize the heap
+ * @heap: the heap to initialize
+ * @alloc_len: number of elements initially allocated
+ * @gfp: allocation flags
+ * @gt: function to compare the elements
+ *
+ * Returns -ENOMEM if out of memory.
+ */
+extern int lttng_heap_init(struct lttng_ptr_heap *heap,
+                    size_t alloc_len, gfp_t gfpmask,
+                    int gt(void *a, void *b));
+
+/**
+ * lttng_heap_free - free the heap
+ * @heap: the heap to free
+ */
+extern void lttng_heap_free(struct lttng_ptr_heap *heap);
+
+/**
+ * lttng_heap_insert - insert an element into the heap
+ * @heap: the heap to be operated on
+ * @p: the element to add
+ *
+ * Insert an element into the heap.
+ *
+ * Returns -ENOMEM if out of memory.
+ */
+extern int lttng_heap_insert(struct lttng_ptr_heap *heap, void *p);
+
+/**
+ * lttng_heap_remove - remove the largest element from the heap
+ * @heap: the heap to be operated on
+ *
+ * Returns the largest element in the heap. It removes this element from the
+ * heap. Returns NULL if the heap is empty.
+ */
+extern void *lttng_heap_remove(struct lttng_ptr_heap *heap);
+
+/**
+ * lttng_heap_cherrypick - remove a given element from the heap
+ * @heap: the heap to be operated on
+ * @p: the element
+ *
+ * Remove the given element from the heap. Return the element if present, else
+ * return NULL. This algorithm has a complexity of O(n), which is higher than
+ * O(log(n)) provided by the rest of this API.
+ */
+extern void *lttng_heap_cherrypick(struct lttng_ptr_heap *heap, void *p);
+
+/**
+ * lttng_heap_replace_max - replace the the largest element from the heap
+ * @heap: the heap to be operated on
+ * @p: the pointer to be inserted as topmost element replacement
+ *
+ * Returns the largest element in the heap. It removes this element from the
+ * heap. The heap is rebalanced only once after the insertion. Returns NULL if
+ * the heap is empty.
+ *
+ * This is the equivalent of calling heap_remove() and then heap_insert(), but
+ * it only rebalances the heap once. It never allocates memory.
+ */
+extern void *lttng_heap_replace_max(struct lttng_ptr_heap *heap, void *p);
+
+#endif /* _LTTNG_PRIO_HEAP_H */
diff --git a/drivers/staging/lttng/lib/ringbuffer/api.h b/drivers/staging/lttng/lib/ringbuffer/api.h
new file mode 100644 (file)
index 0000000..fbac711
--- /dev/null
@@ -0,0 +1,37 @@
+#ifndef _LIB_RING_BUFFER_API_H
+#define _LIB_RING_BUFFER_API_H
+
+/*
+ * lib/ringbuffer/api.h
+ *
+ * Ring Buffer API.
+ *
+ * Copyright (C) 2010-2012 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; only
+ * version 2.1 of the License.
+ *
+ * This library 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
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include "../../wrapper/ringbuffer/backend.h"
+#include "../../wrapper/ringbuffer/frontend.h"
+#include "../../wrapper/ringbuffer/vfs.h"
+
+/*
+ * ring_buffer_frontend_api.h contains static inline functions that depend on
+ * client static inlines. Hence the inclusion of this "api" header only
+ * within the client.
+ */
+#include "../../wrapper/ringbuffer/frontend_api.h"
+
+#endif /* _LIB_RING_BUFFER_API_H */
diff --git a/drivers/staging/lttng/lib/ringbuffer/backend.h b/drivers/staging/lttng/lib/ringbuffer/backend.h
new file mode 100644 (file)
index 0000000..bbbc80d
--- /dev/null
@@ -0,0 +1,272 @@
+#ifndef _LIB_RING_BUFFER_BACKEND_H
+#define _LIB_RING_BUFFER_BACKEND_H
+
+/*
+ * lib/ringbuffer/backend.h
+ *
+ * Ring buffer backend (API).
+ *
+ * Copyright (C) 2010-2012 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; only
+ * version 2.1 of the License.
+ *
+ * This library 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
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ * Credits to Steven Rostedt for proposing to use an extra-subbuffer owned by
+ * the reader in flight recorder mode.
+ */
+
+#include <linux/types.h>
+#include <linux/sched.h>
+#include <linux/timer.h>
+#include <linux/wait.h>
+#include <linux/poll.h>
+#include <linux/list.h>
+#include <linux/fs.h>
+#include <linux/mm.h>
+#include <linux/uaccess.h>
+
+/* Internal helpers */
+#include "../../wrapper/ringbuffer/backend_internal.h"
+#include "../../wrapper/ringbuffer/frontend_internal.h"
+
+/* Ring buffer backend API */
+
+/* Ring buffer backend access (read/write) */
+
+extern size_t lib_ring_buffer_read(struct lib_ring_buffer_backend *bufb,
+                                  size_t offset, void *dest, size_t len);
+
+extern int __lib_ring_buffer_copy_to_user(struct lib_ring_buffer_backend *bufb,
+                                         size_t offset, void __user *dest,
+                                         size_t len);
+
+extern int lib_ring_buffer_read_cstr(struct lib_ring_buffer_backend *bufb,
+                                    size_t offset, void *dest, size_t len);
+
+extern struct page **
+lib_ring_buffer_read_get_page(struct lib_ring_buffer_backend *bufb, size_t offset,
+                             void ***virt);
+
+/*
+ * Return the address where a given offset is located.
+ * Should be used to get the current subbuffer header pointer. Given we know
+ * it's never on a page boundary, it's safe to write directly to this address,
+ * as long as the write is never bigger than a page size.
+ */
+extern void *
+lib_ring_buffer_offset_address(struct lib_ring_buffer_backend *bufb,
+                              size_t offset);
+extern void *
+lib_ring_buffer_read_offset_address(struct lib_ring_buffer_backend *bufb,
+                                   size_t offset);
+
+/**
+ * lib_ring_buffer_write - write data to a buffer backend
+ * @config : ring buffer instance configuration
+ * @ctx: ring buffer context. (input arguments only)
+ * @src : source pointer to copy from
+ * @len : length of data to copy
+ *
+ * This function copies "len" bytes of data from a source pointer to a buffer
+ * backend, at the current context offset. This is more or less a buffer
+ * backend-specific memcpy() operation. Calls the slow path (_ring_buffer_write)
+ * if copy is crossing a page boundary.
+ */
+static inline
+void lib_ring_buffer_write(const struct lib_ring_buffer_config *config,
+                          struct lib_ring_buffer_ctx *ctx,
+                          const void *src, size_t len)
+{
+       struct lib_ring_buffer_backend *bufb = &ctx->buf->backend;
+       struct channel_backend *chanb = &ctx->chan->backend;
+       size_t sbidx, index;
+       size_t offset = ctx->buf_offset;
+       ssize_t pagecpy;
+       struct lib_ring_buffer_backend_pages *rpages;
+       unsigned long sb_bindex, id;
+
+       if (unlikely(!len))
+               return;
+       offset &= chanb->buf_size - 1;
+       sbidx = offset >> chanb->subbuf_size_order;
+       index = (offset & (chanb->subbuf_size - 1)) >> PAGE_SHIFT;
+       pagecpy = min_t(size_t, len, (-offset) & ~PAGE_MASK);
+       id = bufb->buf_wsb[sbidx].id;
+       sb_bindex = subbuffer_id_get_index(config, id);
+       rpages = bufb->array[sb_bindex];
+       CHAN_WARN_ON(ctx->chan,
+                    config->mode == RING_BUFFER_OVERWRITE
+                    && subbuffer_id_is_noref(config, id));
+       if (likely(pagecpy == len))
+               lib_ring_buffer_do_copy(config,
+                                       rpages->p[index].virt
+                                           + (offset & ~PAGE_MASK),
+                                       src, len);
+       else
+               _lib_ring_buffer_write(bufb, offset, src, len, 0);
+       ctx->buf_offset += len;
+}
+
+/**
+ * lib_ring_buffer_memset - write len bytes of c to a buffer backend
+ * @config : ring buffer instance configuration
+ * @bufb : ring buffer backend
+ * @offset : offset within the buffer
+ * @c : the byte to copy
+ * @len : number of bytes to copy
+ *
+ * This function writes "len" bytes of "c" to a buffer backend, at a specific
+ * offset. This is more or less a buffer backend-specific memset() operation.
+ * Calls the slow path (_ring_buffer_memset) if write is crossing a page
+ * boundary.
+ */
+static inline
+void lib_ring_buffer_memset(const struct lib_ring_buffer_config *config,
+                           struct lib_ring_buffer_ctx *ctx, int c, size_t len)
+{
+
+       struct lib_ring_buffer_backend *bufb = &ctx->buf->backend;
+       struct channel_backend *chanb = &ctx->chan->backend;
+       size_t sbidx, index;
+       size_t offset = ctx->buf_offset;
+       ssize_t pagecpy;
+       struct lib_ring_buffer_backend_pages *rpages;
+       unsigned long sb_bindex, id;
+
+       if (unlikely(!len))
+               return;
+       offset &= chanb->buf_size - 1;
+       sbidx = offset >> chanb->subbuf_size_order;
+       index = (offset & (chanb->subbuf_size - 1)) >> PAGE_SHIFT;
+       pagecpy = min_t(size_t, len, (-offset) & ~PAGE_MASK);
+       id = bufb->buf_wsb[sbidx].id;
+       sb_bindex = subbuffer_id_get_index(config, id);
+       rpages = bufb->array[sb_bindex];
+       CHAN_WARN_ON(ctx->chan,
+                    config->mode == RING_BUFFER_OVERWRITE
+                    && subbuffer_id_is_noref(config, id));
+       if (likely(pagecpy == len))
+               lib_ring_buffer_do_memset(rpages->p[index].virt
+                                         + (offset & ~PAGE_MASK),
+                                         c, len);
+       else
+               _lib_ring_buffer_memset(bufb, offset, c, len, 0);
+       ctx->buf_offset += len;
+}
+
+/**
+ * lib_ring_buffer_copy_from_user_inatomic - write userspace data to a buffer backend
+ * @config : ring buffer instance configuration
+ * @ctx: ring buffer context. (input arguments only)
+ * @src : userspace source pointer to copy from
+ * @len : length of data to copy
+ *
+ * This function copies "len" bytes of data from a userspace pointer to a
+ * buffer backend, at the current context offset. This is more or less a buffer
+ * backend-specific memcpy() operation. Calls the slow path
+ * (_ring_buffer_write_from_user_inatomic) if copy is crossing a page boundary.
+ * Disable the page fault handler to ensure we never try to take the mmap_sem.
+ */
+static inline
+void lib_ring_buffer_copy_from_user_inatomic(const struct lib_ring_buffer_config *config,
+                                   struct lib_ring_buffer_ctx *ctx,
+                                   const void __user *src, size_t len)
+{
+       struct lib_ring_buffer_backend *bufb = &ctx->buf->backend;
+       struct channel_backend *chanb = &ctx->chan->backend;
+       size_t sbidx, index;
+       size_t offset = ctx->buf_offset;
+       ssize_t pagecpy;
+       struct lib_ring_buffer_backend_pages *rpages;
+       unsigned long sb_bindex, id;
+       unsigned long ret;
+       mm_segment_t old_fs = get_fs();
+
+       if (unlikely(!len))
+               return;
+       offset &= chanb->buf_size - 1;
+       sbidx = offset >> chanb->subbuf_size_order;
+       index = (offset & (chanb->subbuf_size - 1)) >> PAGE_SHIFT;
+       pagecpy = min_t(size_t, len, (-offset) & ~PAGE_MASK);
+       id = bufb->buf_wsb[sbidx].id;
+       sb_bindex = subbuffer_id_get_index(config, id);
+       rpages = bufb->array[sb_bindex];
+       CHAN_WARN_ON(ctx->chan,
+                    config->mode == RING_BUFFER_OVERWRITE
+                    && subbuffer_id_is_noref(config, id));
+
+       set_fs(KERNEL_DS);
+       pagefault_disable();
+       if (unlikely(!access_ok(VERIFY_READ, src, len)))
+               goto fill_buffer;
+
+       if (likely(pagecpy == len)) {
+               ret = lib_ring_buffer_do_copy_from_user_inatomic(
+                       rpages->p[index].virt + (offset & ~PAGE_MASK),
+                       src, len);
+               if (unlikely(ret > 0)) {
+                       len -= (pagecpy - ret);
+                       offset += (pagecpy - ret);
+                       goto fill_buffer;
+               }
+       } else {
+               _lib_ring_buffer_copy_from_user_inatomic(bufb, offset, src, len, 0);
+       }
+       pagefault_enable();
+       set_fs(old_fs);
+       ctx->buf_offset += len;
+
+       return;
+
+fill_buffer:
+       pagefault_enable();
+       set_fs(old_fs);
+       /*
+        * In the error path we call the slow path version to avoid
+        * the pollution of static inline code.
+        */
+       _lib_ring_buffer_memset(bufb, offset, 0, len, 0);
+}
+
+/*
+ * This accessor counts the number of unread records in a buffer.
+ * It only provides a consistent value if no reads not writes are performed
+ * concurrently.
+ */
+static inline
+unsigned long lib_ring_buffer_get_records_unread(
+                               const struct lib_ring_buffer_config *config,
+                               struct lib_ring_buffer *buf)
+{
+       struct lib_ring_buffer_backend *bufb = &buf->backend;
+       struct lib_ring_buffer_backend_pages *pages;
+       unsigned long records_unread = 0, sb_bindex, id;
+       unsigned int i;
+
+       for (i = 0; i < bufb->chan->backend.num_subbuf; i++) {
+               id = bufb->buf_wsb[i].id;
+               sb_bindex = subbuffer_id_get_index(config, id);
+               pages = bufb->array[sb_bindex];
+               records_unread += v_read(config, &pages->records_unread);
+       }
+       if (config->mode == RING_BUFFER_OVERWRITE) {
+               id = bufb->buf_rsb.id;
+               sb_bindex = subbuffer_id_get_index(config, id);
+               pages = bufb->array[sb_bindex];
+               records_unread += v_read(config, &pages->records_unread);
+       }
+       return records_unread;
+}
+
+#endif /* _LIB_RING_BUFFER_BACKEND_H */
diff --git a/drivers/staging/lttng/lib/ringbuffer/backend_internal.h b/drivers/staging/lttng/lib/ringbuffer/backend_internal.h
new file mode 100644 (file)
index 0000000..e048365
--- /dev/null
@@ -0,0 +1,461 @@
+#ifndef _LIB_RING_BUFFER_BACKEND_INTERNAL_H
+#define _LIB_RING_BUFFER_BACKEND_INTERNAL_H
+
+/*
+ * lib/ringbuffer/backend_internal.h
+ *
+ * Ring buffer backend (internal helpers).
+ *
+ * Copyright (C) 2008-2012 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; only
+ * version 2.1 of the License.
+ *
+ * This library 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
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include "../../wrapper/ringbuffer/config.h"
+#include "../../wrapper/ringbuffer/backend_types.h"
+#include "../../wrapper/ringbuffer/frontend_types.h"
+#include <linux/string.h>
+#include <linux/uaccess.h>
+
+/* Ring buffer backend API presented to the frontend */
+
+/* Ring buffer and channel backend create/free */
+
+int lib_ring_buffer_backend_create(struct lib_ring_buffer_backend *bufb,
+                                  struct channel_backend *chan, int cpu);
+void channel_backend_unregister_notifiers(struct channel_backend *chanb);
+void lib_ring_buffer_backend_free(struct lib_ring_buffer_backend *bufb);
+int channel_backend_init(struct channel_backend *chanb,
+                        const char *name,
+                        const struct lib_ring_buffer_config *config,
+                        void *priv, size_t subbuf_size,
+                        size_t num_subbuf);
+void channel_backend_free(struct channel_backend *chanb);
+
+void lib_ring_buffer_backend_reset(struct lib_ring_buffer_backend *bufb);
+void channel_backend_reset(struct channel_backend *chanb);
+
+int lib_ring_buffer_backend_init(void);
+void lib_ring_buffer_backend_exit(void);
+
+extern void _lib_ring_buffer_write(struct lib_ring_buffer_backend *bufb,
+                                  size_t offset, const void *src, size_t len,
+                                  ssize_t pagecpy);
+extern void _lib_ring_buffer_memset(struct lib_ring_buffer_backend *bufb,
+                                   size_t offset, int c, size_t len,
+                                   ssize_t pagecpy);
+extern void _lib_ring_buffer_copy_from_user_inatomic(struct lib_ring_buffer_backend *bufb,
+                                           size_t offset, const void *src,
+                                           size_t len, ssize_t pagecpy);
+
+/*
+ * Subbuffer ID bits for overwrite mode. Need to fit within a single word to be
+ * exchanged atomically.
+ *
+ * Top half word, except lowest bit, belongs to "offset", which is used to keep
+ * to count the produced buffers.  For overwrite mode, this provides the
+ * consumer with the capacity to read subbuffers in order, handling the
+ * situation where producers would write up to 2^15 buffers (or 2^31 for 64-bit
+ * systems) concurrently with a single execution of get_subbuf (between offset
+ * sampling and subbuffer ID exchange).
+ */
+
+#define HALF_ULONG_BITS                (BITS_PER_LONG >> 1)
+
+#define SB_ID_OFFSET_SHIFT     (HALF_ULONG_BITS + 1)
+#define SB_ID_OFFSET_COUNT     (1UL << SB_ID_OFFSET_SHIFT)
+#define SB_ID_OFFSET_MASK      (~(SB_ID_OFFSET_COUNT - 1))
+/*
+ * Lowest bit of top word half belongs to noref. Used only for overwrite mode.
+ */
+#define SB_ID_NOREF_SHIFT      (SB_ID_OFFSET_SHIFT - 1)
+#define SB_ID_NOREF_COUNT      (1UL << SB_ID_NOREF_SHIFT)
+#define SB_ID_NOREF_MASK       SB_ID_NOREF_COUNT
+/*
+ * In overwrite mode: lowest half of word is used for index.
+ * Limit of 2^16 subbuffers per buffer on 32-bit, 2^32 on 64-bit.
+ * In producer-consumer mode: whole word used for index.
+ */
+#define SB_ID_INDEX_SHIFT      0
+#define SB_ID_INDEX_COUNT      (1UL << SB_ID_INDEX_SHIFT)
+#define SB_ID_INDEX_MASK       (SB_ID_NOREF_COUNT - 1)
+
+/*
+ * Construct the subbuffer id from offset, index and noref. Use only the index
+ * for producer-consumer mode (offset and noref are only used in overwrite
+ * mode).
+ */
+static inline
+unsigned long subbuffer_id(const struct lib_ring_buffer_config *config,
+                          unsigned long offset, unsigned long noref,
+                          unsigned long index)
+{
+       if (config->mode == RING_BUFFER_OVERWRITE)
+               return (offset << SB_ID_OFFSET_SHIFT)
+                      | (noref << SB_ID_NOREF_SHIFT)
+                      | index;
+       else
+               return index;
+}
+
+/*
+ * Compare offset with the offset contained within id. Return 1 if the offset
+ * bits are identical, else 0.
+ */
+static inline
+int subbuffer_id_compare_offset(const struct lib_ring_buffer_config *config,
+                               unsigned long id, unsigned long offset)
+{
+       return (id & SB_ID_OFFSET_MASK) == (offset << SB_ID_OFFSET_SHIFT);
+}
+
+static inline
+unsigned long subbuffer_id_get_index(const struct lib_ring_buffer_config *config,
+                                    unsigned long id)
+{
+       if (config->mode == RING_BUFFER_OVERWRITE)
+               return id & SB_ID_INDEX_MASK;
+       else
+               return id;
+}
+
+static inline
+unsigned long subbuffer_id_is_noref(const struct lib_ring_buffer_config *config,
+                                   unsigned long id)
+{
+       if (config->mode == RING_BUFFER_OVERWRITE)
+               return !!(id & SB_ID_NOREF_MASK);
+       else
+               return 1;
+}
+
+/*
+ * Only used by reader on subbuffer ID it has exclusive access to. No volatile
+ * needed.
+ */
+static inline
+void subbuffer_id_set_noref(const struct lib_ring_buffer_config *config,
+                           unsigned long *id)
+{
+       if (config->mode == RING_BUFFER_OVERWRITE)
+               *id |= SB_ID_NOREF_MASK;
+}
+
+static inline
+void subbuffer_id_set_noref_offset(const struct lib_ring_buffer_config *config,
+                                  unsigned long *id, unsigned long offset)
+{
+       unsigned long tmp;
+
+       if (config->mode == RING_BUFFER_OVERWRITE) {
+               tmp = *id;
+               tmp &= ~SB_ID_OFFSET_MASK;
+               tmp |= offset << SB_ID_OFFSET_SHIFT;
+               tmp |= SB_ID_NOREF_MASK;
+               /* Volatile store, read concurrently by readers. */
+               ACCESS_ONCE(*id) = tmp;
+       }
+}
+
+/* No volatile access, since already used locally */
+static inline
+void subbuffer_id_clear_noref(const struct lib_ring_buffer_config *config,
+                             unsigned long *id)
+{
+       if (config->mode == RING_BUFFER_OVERWRITE)
+               *id &= ~SB_ID_NOREF_MASK;
+}
+
+/*
+ * For overwrite mode, cap the number of subbuffers per buffer to:
+ * 2^16 on 32-bit architectures
+ * 2^32 on 64-bit architectures
+ * This is required to fit in the index part of the ID. Return 0 on success,
+ * -EPERM on failure.
+ */
+static inline
+int subbuffer_id_check_index(const struct lib_ring_buffer_config *config,
+                            unsigned long num_subbuf)
+{
+       if (config->mode == RING_BUFFER_OVERWRITE)
+               return (num_subbuf > (1UL << HALF_ULONG_BITS)) ? -EPERM : 0;
+       else
+               return 0;
+}
+
+static inline
+void subbuffer_count_record(const struct lib_ring_buffer_config *config,
+                           struct lib_ring_buffer_backend *bufb,
+                           unsigned long idx)
+{
+       unsigned long sb_bindex;
+
+       sb_bindex = subbuffer_id_get_index(config, bufb->buf_wsb[idx].id);
+       v_inc(config, &bufb->array[sb_bindex]->records_commit);
+}
+
+/*
+ * Reader has exclusive subbuffer access for record consumption. No need to
+ * perform the decrement atomically.
+ */
+static inline
+void subbuffer_consume_record(const struct lib_ring_buffer_config *config,
+                             struct lib_ring_buffer_backend *bufb)
+{
+       unsigned long sb_bindex;
+
+       sb_bindex = subbuffer_id_get_index(config, bufb->buf_rsb.id);
+       CHAN_WARN_ON(bufb->chan,
+                    !v_read(config, &bufb->array[sb_bindex]->records_unread));
+       /* Non-atomic decrement protected by exclusive subbuffer access */
+       _v_dec(config, &bufb->array[sb_bindex]->records_unread);
+       v_inc(config, &bufb->records_read);
+}
+
+static inline
+unsigned long subbuffer_get_records_count(
+                               const struct lib_ring_buffer_config *config,
+                               struct lib_ring_buffer_backend *bufb,
+                               unsigned long idx)
+{
+       unsigned long sb_bindex;
+
+       sb_bindex = subbuffer_id_get_index(config, bufb->buf_wsb[idx].id);
+       return v_read(config, &bufb->array[sb_bindex]->records_commit);
+}
+
+/*
+ * Must be executed at subbuffer delivery when the writer has _exclusive_
+ * subbuffer access. See ring_buffer_check_deliver() for details.
+ * ring_buffer_get_records_count() must be called to get the records count
+ * before this function, because it resets the records_commit count.
+ */
+static inline
+unsigned long subbuffer_count_records_overrun(
+                               const struct lib_ring_buffer_config *config,
+                               struct lib_ring_buffer_backend *bufb,
+                               unsigned long idx)
+{
+       struct lib_ring_buffer_backend_pages *pages;
+       unsigned long overruns, sb_bindex;
+
+       sb_bindex = subbuffer_id_get_index(config, bufb->buf_wsb[idx].id);
+       pages = bufb->array[sb_bindex];
+       overruns = v_read(config, &pages->records_unread);
+       v_set(config, &pages->records_unread,
+             v_read(config, &pages->records_commit));
+       v_set(config, &pages->records_commit, 0);
+
+       return overruns;
+}
+
+static inline
+void subbuffer_set_data_size(const struct lib_ring_buffer_config *config,
+                            struct lib_ring_buffer_backend *bufb,
+                            unsigned long idx,
+                            unsigned long data_size)
+{
+       struct lib_ring_buffer_backend_pages *pages;
+       unsigned long sb_bindex;
+
+       sb_bindex = subbuffer_id_get_index(config, bufb->buf_wsb[idx].id);
+       pages = bufb->array[sb_bindex];
+       pages->data_size = data_size;
+}
+
+static inline
+unsigned long subbuffer_get_read_data_size(
+                               const struct lib_ring_buffer_config *config,
+                               struct lib_ring_buffer_backend *bufb)
+{
+       struct lib_ring_buffer_backend_pages *pages;
+       unsigned long sb_bindex;
+
+       sb_bindex = subbuffer_id_get_index(config, bufb->buf_rsb.id);
+       pages = bufb->array[sb_bindex];
+       return pages->data_size;
+}
+
+static inline
+unsigned long subbuffer_get_data_size(
+                               const struct lib_ring_buffer_config *config,
+                               struct lib_ring_buffer_backend *bufb,
+                               unsigned long idx)
+{
+       struct lib_ring_buffer_backend_pages *pages;
+       unsigned long sb_bindex;
+
+       sb_bindex = subbuffer_id_get_index(config, bufb->buf_wsb[idx].id);
+       pages = bufb->array[sb_bindex];
+       return pages->data_size;
+}
+
+/**
+ * lib_ring_buffer_clear_noref - Clear the noref subbuffer flag, called by
+ *                               writer.
+ */
+static inline
+void lib_ring_buffer_clear_noref(const struct lib_ring_buffer_config *config,
+                                struct lib_ring_buffer_backend *bufb,
+                                unsigned long idx)
+{
+       unsigned long id, new_id;
+
+       if (config->mode != RING_BUFFER_OVERWRITE)
+               return;
+
+       /*
+        * Performing a volatile access to read the sb_pages, because we want to
+        * read a coherent version of the pointer and the associated noref flag.
+        */
+       id = ACCESS_ONCE(bufb->buf_wsb[idx].id);
+       for (;;) {
+               /* This check is called on the fast path for each record. */
+               if (likely(!subbuffer_id_is_noref(config, id))) {
+                       /*
+                        * Store after load dependency ordering the writes to
+                        * the subbuffer after load and test of the noref flag
+                        * matches the memory barrier implied by the cmpxchg()
+                        * in update_read_sb_index().
+                        */
+                       return; /* Already writing to this buffer */
+               }
+               new_id = id;
+               subbuffer_id_clear_noref(config, &new_id);
+               new_id = cmpxchg(&bufb->buf_wsb[idx].id, id, new_id);
+               if (likely(new_id == id))
+                       break;
+               id = new_id;
+       }
+}
+
+/**
+ * lib_ring_buffer_set_noref_offset - Set the noref subbuffer flag and offset,
+ *                                    called by writer.
+ */
+static inline
+void lib_ring_buffer_set_noref_offset(const struct lib_ring_buffer_config *config,
+                                     struct lib_ring_buffer_backend *bufb,
+                                     unsigned long idx, unsigned long offset)
+{
+       if (config->mode != RING_BUFFER_OVERWRITE)
+               return;
+
+       /*
+        * Because ring_buffer_set_noref() is only called by a single thread
+        * (the one which updated the cc_sb value), there are no concurrent
+        * updates to take care of: other writers have not updated cc_sb, so
+        * they cannot set the noref flag, and concurrent readers cannot modify
+        * the pointer because the noref flag is not set yet.
+        * The smp_wmb() in ring_buffer_commit() takes care of ordering writes
+        * to the subbuffer before this set noref operation.
+        * subbuffer_set_noref() uses a volatile store to deal with concurrent
+        * readers of the noref flag.
+        */
+       CHAN_WARN_ON(bufb->chan,
+                    subbuffer_id_is_noref(config, bufb->buf_wsb[idx].id));
+       /*
+        * Memory barrier that ensures counter stores are ordered before set
+        * noref and offset.
+        */
+       smp_mb();
+       subbuffer_id_set_noref_offset(config, &bufb->buf_wsb[idx].id, offset);
+}
+
+/**
+ * update_read_sb_index - Read-side subbuffer index update.
+ */
+static inline
+int update_read_sb_index(const struct lib_ring_buffer_config *config,
+                        struct lib_ring_buffer_backend *bufb,
+                        struct channel_backend *chanb,
+                        unsigned long consumed_idx,
+                        unsigned long consumed_count)
+{
+       unsigned long old_id, new_id;
+
+       if (config->mode == RING_BUFFER_OVERWRITE) {
+               /*
+                * Exchange the target writer subbuffer with our own unused
+                * subbuffer. No need to use ACCESS_ONCE() here to read the
+                * old_wpage, because the value read will be confirmed by the
+                * following cmpxchg().
+                */
+               old_id = bufb->buf_wsb[consumed_idx].id;
+               if (unlikely(!subbuffer_id_is_noref(config, old_id)))
+                       return -EAGAIN;
+               /*
+                * Make sure the offset count we are expecting matches the one
+                * indicated by the writer.
+                */
+               if (unlikely(!subbuffer_id_compare_offset(config, old_id,
+                                                         consumed_count)))
+                       return -EAGAIN;
+               CHAN_WARN_ON(bufb->chan,
+                            !subbuffer_id_is_noref(config, bufb->buf_rsb.id));
+               subbuffer_id_set_noref_offset(config, &bufb->buf_rsb.id,
+                                             consumed_count);
+               new_id = cmpxchg(&bufb->buf_wsb[consumed_idx].id, old_id,
+                                bufb->buf_rsb.id);
+               if (unlikely(old_id != new_id))
+                       return -EAGAIN;
+               bufb->buf_rsb.id = new_id;
+       } else {
+               /* No page exchange, use the writer page directly */
+               bufb->buf_rsb.id = bufb->buf_wsb[consumed_idx].id;
+       }
+       return 0;
+}
+
+/*
+ * Use the architecture-specific memcpy implementation for constant-sized
+ * inputs, but rely on an inline memcpy for length statically unknown.
+ * The function call to memcpy is just way too expensive for a fast path.
+ */
+#define lib_ring_buffer_do_copy(config, dest, src, len)                \
+do {                                                           \
+       size_t __len = (len);                                   \
+       if (__builtin_constant_p(len))                          \
+               memcpy(dest, src, __len);                       \
+       else                                                    \
+               inline_memcpy(dest, src, __len);                \
+} while (0)
+
+/*
+ * We use __copy_from_user_inatomic to copy userspace data since we already
+ * did the access_ok for the whole range.
+ */
+static inline
+unsigned long lib_ring_buffer_do_copy_from_user_inatomic(void *dest,
+                                               const void __user *src,
+                                               unsigned long len)
+{
+       return __copy_from_user_inatomic(dest, src, len);
+}
+
+/*
+ * write len bytes to dest with c
+ */
+static inline
+void lib_ring_buffer_do_memset(char *dest, int c,
+       unsigned long len)
+{
+       unsigned long i;
+
+       for (i = 0; i < len; i++)
+               dest[i] = c;
+}
+
+#endif /* _LIB_RING_BUFFER_BACKEND_INTERNAL_H */
diff --git a/drivers/staging/lttng/lib/ringbuffer/backend_types.h b/drivers/staging/lttng/lib/ringbuffer/backend_types.h
new file mode 100644 (file)
index 0000000..6813dd8
--- /dev/null
@@ -0,0 +1,97 @@
+#ifndef _LIB_RING_BUFFER_BACKEND_TYPES_H
+#define _LIB_RING_BUFFER_BACKEND_TYPES_H
+
+/*
+ * lib/ringbuffer/backend_types.h
+ *
+ * Ring buffer backend (types).
+ *
+ * Copyright (C) 2008-2012 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; only
+ * version 2.1 of the License.
+ *
+ * This library 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
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include <linux/cpumask.h>
+#include <linux/types.h>
+
+struct lib_ring_buffer_backend_page {
+       void *virt;                     /* page virtual address (cached) */
+       struct page *page;              /* pointer to page structure */
+};
+
+struct lib_ring_buffer_backend_pages {
+       unsigned long mmap_offset;      /* offset of the subbuffer in mmap */
+       union v_atomic records_commit;  /* current records committed count */
+       union v_atomic records_unread;  /* records to read */
+       unsigned long data_size;        /* Amount of data to read from subbuf */
+       struct lib_ring_buffer_backend_page p[];
+};
+
+struct lib_ring_buffer_backend_subbuffer {
+       /* Identifier for subbuf backend pages. Exchanged atomically. */
+       unsigned long id;               /* backend subbuffer identifier */
+};
+
+/*
+ * Forward declaration of frontend-specific channel and ring_buffer.
+ */
+struct channel;
+struct lib_ring_buffer;
+
+struct lib_ring_buffer_backend {
+       /* Array of ring_buffer_backend_subbuffer for writer */
+       struct lib_ring_buffer_backend_subbuffer *buf_wsb;
+       /* ring_buffer_backend_subbuffer for reader */
+       struct lib_ring_buffer_backend_subbuffer buf_rsb;
+       /*
+        * Pointer array of backend pages, for whole buffer.
+        * Indexed by ring_buffer_backend_subbuffer identifier (id) index.
+        */
+       struct lib_ring_buffer_backend_pages **array;
+       unsigned int num_pages_per_subbuf;
+
+       struct channel *chan;           /* Associated channel */
+       int cpu;                        /* This buffer's cpu. -1 if global. */
+       union v_atomic records_read;    /* Number of records read */
+       unsigned int allocated:1;       /* is buffer allocated ? */
+};
+
+struct channel_backend {
+       unsigned long buf_size;         /* Size of the buffer */
+       unsigned long subbuf_size;      /* Sub-buffer size */
+       unsigned int subbuf_size_order; /* Order of sub-buffer size */
+       unsigned int num_subbuf_order;  /*
+                                        * Order of number of sub-buffers/buffer
+                                        * for writer.
+                                        */
+       unsigned int buf_size_order;    /* Order of buffer size */
+       unsigned int extra_reader_sb:1; /* has extra reader subbuffer ? */
+       struct lib_ring_buffer *buf;    /* Channel per-cpu buffers */
+
+       unsigned long num_subbuf;       /* Number of sub-buffers for writer */
+       u64 start_tsc;                  /* Channel creation TSC value */
+       void *priv;                     /* Client-specific information */
+       struct notifier_block cpu_hp_notifier;   /* CPU hotplug notifier */
+       /*
+        * We need to copy config because the module containing the
+        * source config can vanish before the last reference to this
+        * channel's streams is released.
+        */
+       struct lib_ring_buffer_config config; /* Ring buffer configuration */
+       cpumask_var_t cpumask;          /* Allocated per-cpu buffers cpumask */
+       char name[NAME_MAX];            /* Channel name */
+};
+
+#endif /* _LIB_RING_BUFFER_BACKEND_TYPES_H */
diff --git a/drivers/staging/lttng/lib/ringbuffer/config.h b/drivers/staging/lttng/lib/ringbuffer/config.h
new file mode 100644 (file)
index 0000000..67caba0
--- /dev/null
@@ -0,0 +1,315 @@
+#ifndef _LIB_RING_BUFFER_CONFIG_H
+#define _LIB_RING_BUFFER_CONFIG_H
+
+/*
+ * lib/ringbuffer/config.h
+ *
+ * Ring buffer configuration header. Note: after declaring the standard inline
+ * functions, clients should also include linux/ringbuffer/api.h.
+ *
+ * Copyright (C) 2010-2012 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; only
+ * version 2.1 of the License.
+ *
+ * This library 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
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include <linux/types.h>
+#include <linux/percpu.h>
+#include "../align.h"
+#include "../../lttng-tracer-core.h"
+
+struct lib_ring_buffer;
+struct channel;
+struct lib_ring_buffer_config;
+struct lib_ring_buffer_ctx;
+
+/*
+ * Ring buffer client callbacks. Only used by slow path, never on fast path.
+ * For the fast path, record_header_size(), ring_buffer_clock_read() should be
+ * provided as inline functions too.  These may simply return 0 if not used by
+ * the client.
+ */
+struct lib_ring_buffer_client_cb {
+       /* Mandatory callbacks */
+
+       /* A static inline version is also required for fast path */
+       u64 (*ring_buffer_clock_read) (struct channel *chan);
+       size_t (*record_header_size) (const struct lib_ring_buffer_config *config,
+                                     struct channel *chan, size_t offset,
+                                     size_t *pre_header_padding,
+                                     struct lib_ring_buffer_ctx *ctx);
+
+       /* Slow path only, at subbuffer switch */
+       size_t (*subbuffer_header_size) (void);
+       void (*buffer_begin) (struct lib_ring_buffer *buf, u64 tsc,
+                             unsigned int subbuf_idx);
+       void (*buffer_end) (struct lib_ring_buffer *buf, u64 tsc,
+                           unsigned int subbuf_idx, unsigned long data_size);
+
+       /* Optional callbacks (can be set to NULL) */
+
+       /* Called at buffer creation/finalize */
+       int (*buffer_create) (struct lib_ring_buffer *buf, void *priv,
+                             int cpu, const char *name);
+       /*
+        * Clients should guarantee that no new reader handle can be opened
+        * after finalize.
+        */
+       void (*buffer_finalize) (struct lib_ring_buffer *buf, void *priv, int cpu);
+
+       /*
+        * Extract header length, payload length and timestamp from event
+        * record. Used by buffer iterators. Timestamp is only used by channel
+        * iterator.
+        */
+       void (*record_get) (const struct lib_ring_buffer_config *config,
+                           struct channel *chan, struct lib_ring_buffer *buf,
+                           size_t offset, size_t *header_len,
+                           size_t *payload_len, u64 *timestamp);
+};
+
+/*
+ * Ring buffer instance configuration.
+ *
+ * Declare as "static const" within the client object to ensure the inline fast
+ * paths can be optimized.
+ *
+ * alloc/sync pairs:
+ *
+ * RING_BUFFER_ALLOC_PER_CPU and RING_BUFFER_SYNC_PER_CPU :
+ *   Per-cpu buffers with per-cpu synchronization. Tracing must be performed
+ *   with preemption disabled (lib_ring_buffer_get_cpu() and
+ *   lib_ring_buffer_put_cpu()).
+ *
+ * RING_BUFFER_ALLOC_PER_CPU and RING_BUFFER_SYNC_GLOBAL :
+ *   Per-cpu buffer with global synchronization. Tracing can be performed with
+ *   preemption enabled, statistically stays on the local buffers.
+ *
+ * RING_BUFFER_ALLOC_GLOBAL and RING_BUFFER_SYNC_PER_CPU :
+ *   Should only be used for buffers belonging to a single thread or protected
+ *   by mutual exclusion by the client. Note that periodical sub-buffer switch
+ *   should be disabled in this kind of configuration.
+ *
+ * RING_BUFFER_ALLOC_GLOBAL and RING_BUFFER_SYNC_GLOBAL :
+ *   Global shared buffer with global synchronization.
+ *
+ * wakeup:
+ *
+ * RING_BUFFER_WAKEUP_BY_TIMER uses per-cpu deferrable timers to poll the
+ * buffers and wake up readers if data is ready. Mainly useful for tracers which
+ * don't want to call into the wakeup code on the tracing path. Use in
+ * combination with "read_timer_interval" channel_create() argument.
+ *
+ * RING_BUFFER_WAKEUP_BY_WRITER directly wakes up readers when a subbuffer is
+ * ready to read. Lower latencies before the reader is woken up. Mainly suitable
+ * for drivers.
+ *
+ * RING_BUFFER_WAKEUP_NONE does not perform any wakeup whatsoever. The client
+ * has the responsibility to perform wakeups.
+ */
+struct lib_ring_buffer_config {
+       enum {
+               RING_BUFFER_ALLOC_PER_CPU,
+               RING_BUFFER_ALLOC_GLOBAL,
+       } alloc;
+       enum {
+               RING_BUFFER_SYNC_PER_CPU,       /* Wait-free */
+               RING_BUFFER_SYNC_GLOBAL,        /* Lock-free */
+       } sync;
+       enum {
+               RING_BUFFER_OVERWRITE,          /* Overwrite when buffer full */
+               RING_BUFFER_DISCARD,            /* Discard when buffer full */
+       } mode;
+       enum {
+               RING_BUFFER_SPLICE,
+               RING_BUFFER_MMAP,
+               RING_BUFFER_READ,               /* TODO */
+               RING_BUFFER_ITERATOR,
+               RING_BUFFER_NONE,
+       } output;
+       enum {
+               RING_BUFFER_PAGE,
+               RING_BUFFER_VMAP,               /* TODO */
+               RING_BUFFER_STATIC,             /* TODO */
+       } backend;
+       enum {
+               RING_BUFFER_NO_OOPS_CONSISTENCY,
+               RING_BUFFER_OOPS_CONSISTENCY,
+       } oops;
+       enum {
+               RING_BUFFER_IPI_BARRIER,
+               RING_BUFFER_NO_IPI_BARRIER,
+       } ipi;
+       enum {
+               RING_BUFFER_WAKEUP_BY_TIMER,    /* wake up performed by timer */
+               RING_BUFFER_WAKEUP_BY_WRITER,   /*
+                                                * writer wakes up reader,
+                                                * not lock-free
+                                                * (takes spinlock).
+                                                */
+       } wakeup;
+       /*
+        * tsc_bits: timestamp bits saved at each record.
+        *   0 and 64 disable the timestamp compression scheme.
+        */
+       unsigned int tsc_bits;
+       struct lib_ring_buffer_client_cb cb;
+};
+
+/*
+ * ring buffer context
+ *
+ * Context passed to lib_ring_buffer_reserve(), lib_ring_buffer_commit(),
+ * lib_ring_buffer_try_discard_reserve(), lib_ring_buffer_align_ctx() and
+ * lib_ring_buffer_write().
+ */
+struct lib_ring_buffer_ctx {
+       /* input received by lib_ring_buffer_reserve(), saved here. */
+       struct channel *chan;           /* channel */
+       void *priv;                     /* client private data */
+       size_t data_size;               /* size of payload */
+       int largest_align;              /*
+                                        * alignment of the largest element
+                                        * in the payload
+                                        */
+       int cpu;                        /* processor id */
+
+       /* output from lib_ring_buffer_reserve() */
+       struct lib_ring_buffer *buf;    /*
+                                        * buffer corresponding to processor id
+                                        * for this channel
+                                        */
+       size_t slot_size;               /* size of the reserved slot */
+       unsigned long buf_offset;       /* offset following the record header */
+       unsigned long pre_offset;       /*
+                                        * Initial offset position _before_
+                                        * the record is written. Positioned
+                                        * prior to record header alignment
+                                        * padding.
+                                        */
+       u64 tsc;                        /* time-stamp counter value */
+       unsigned int rflags;            /* reservation flags */
+};
+
+/**
+ * lib_ring_buffer_ctx_init - initialize ring buffer context
+ * @ctx: ring buffer context to initialize
+ * @chan: channel
+ * @priv: client private data
+ * @data_size: size of record data payload. It must be greater than 0.
+ * @largest_align: largest alignment within data payload types
+ * @cpu: processor id
+ */
+static inline
+void lib_ring_buffer_ctx_init(struct lib_ring_buffer_ctx *ctx,
+                             struct channel *chan, void *priv,
+                             size_t data_size, int largest_align,
+                             int cpu)
+{
+       ctx->chan = chan;
+       ctx->priv = priv;
+       ctx->data_size = data_size;
+       ctx->largest_align = largest_align;
+       ctx->cpu = cpu;
+       ctx->rflags = 0;
+}
+
+/*
+ * Reservation flags.
+ *
+ * RING_BUFFER_RFLAG_FULL_TSC
+ *
+ * This flag is passed to record_header_size() and to the primitive used to
+ * write the record header. It indicates that the full 64-bit time value is
+ * needed in the record header. If this flag is not set, the record header needs
+ * only to contain "tsc_bits" bit of time value.
+ *
+ * Reservation flags can be added by the client, starting from
+ * "(RING_BUFFER_FLAGS_END << 0)". It can be used to pass information from
+ * record_header_size() to lib_ring_buffer_write_record_header().
+ */
+#define        RING_BUFFER_RFLAG_FULL_TSC              (1U << 0)
+#define RING_BUFFER_RFLAG_END                  (1U << 1)
+
+#ifndef LTTNG_TRACER_CORE_H
+#error "lttng-tracer-core.h is needed for RING_BUFFER_ALIGN define"
+#endif
+
+/*
+ * We need to define RING_BUFFER_ALIGN_ATTR so it is known early at
+ * compile-time. We have to duplicate the "config->align" information and the
+ * definition here because config->align is used both in the slow and fast
+ * paths, but RING_BUFFER_ALIGN_ATTR is only available for the client code.
+ */
+#ifdef RING_BUFFER_ALIGN
+
+# define RING_BUFFER_ALIGN_ATTR                /* Default arch alignment */
+
+/*
+ * Calculate the offset needed to align the type.
+ * size_of_type must be non-zero.
+ */
+static inline
+unsigned int lib_ring_buffer_align(size_t align_drift, size_t size_of_type)
+{
+       return offset_align(align_drift, size_of_type);
+}
+
+#else
+
+# define RING_BUFFER_ALIGN_ATTR __attribute__((packed))
+
+/*
+ * Calculate the offset needed to align the type.
+ * size_of_type must be non-zero.
+ */
+static inline
+unsigned int lib_ring_buffer_align(size_t align_drift, size_t size_of_type)
+{
+       return 0;
+}
+
+#endif
+
+/**
+ * lib_ring_buffer_align_ctx - Align context offset on "alignment"
+ * @ctx: ring buffer context.
+ */
+static inline
+void lib_ring_buffer_align_ctx(struct lib_ring_buffer_ctx *ctx,
+                          size_t alignment)
+{
+       ctx->buf_offset += lib_ring_buffer_align(ctx->buf_offset,
+                                                alignment);
+}
+
+/*
+ * lib_ring_buffer_check_config() returns 0 on success.
+ * Used internally to check for valid configurations at channel creation.
+ */
+static inline
+int lib_ring_buffer_check_config(const struct lib_ring_buffer_config *config,
+                            unsigned int switch_timer_interval,
+                            unsigned int read_timer_interval)
+{
+       if (config->alloc == RING_BUFFER_ALLOC_GLOBAL
+           && config->sync == RING_BUFFER_SYNC_PER_CPU
+           && switch_timer_interval)
+               return -EINVAL;
+       return 0;
+}
+
+#include "../../wrapper/ringbuffer/vatomic.h"
+
+#endif /* _LIB_RING_BUFFER_CONFIG_H */
diff --git a/drivers/staging/lttng/lib/ringbuffer/frontend.h b/drivers/staging/lttng/lib/ringbuffer/frontend.h
new file mode 100644 (file)
index 0000000..4473e86
--- /dev/null
@@ -0,0 +1,240 @@
+#ifndef _LIB_RING_BUFFER_FRONTEND_H
+#define _LIB_RING_BUFFER_FRONTEND_H
+
+/*
+ * lib/ringbuffer/frontend.h
+ *
+ * Ring Buffer Library Synchronization Header (API).
+ *
+ * Copyright (C) 2005-2012 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; only
+ * version 2.1 of the License.
+ *
+ * This library 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
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ * Author:
+ *     Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
+ *
+ * See ring_buffer_frontend.c for more information on wait-free algorithms.
+ */
+
+#include <linux/pipe_fs_i.h>
+#include <linux/rcupdate.h>
+#include <linux/cpumask.h>
+#include <linux/module.h>
+#include <linux/bitops.h>
+#include <linux/splice.h>
+#include <linux/string.h>
+#include <linux/timer.h>
+#include <linux/sched.h>
+#include <linux/cache.h>
+#include <linux/time.h>
+#include <linux/slab.h>
+#include <linux/init.h>
+#include <linux/stat.h>
+#include <linux/cpu.h>
+#include <linux/fs.h>
+
+#include <asm/atomic.h>
+#include <asm/local.h>
+
+/* Internal helpers */
+#include "../../wrapper/ringbuffer/frontend_internal.h"
+
+/* Buffer creation/removal and setup operations */
+
+/*
+ * switch_timer_interval is the time interval (in us) to fill sub-buffers with
+ * padding to let readers get those sub-buffers.  Used for live streaming.
+ *
+ * read_timer_interval is the time interval (in us) to wake up pending readers.
+ *
+ * buf_addr is a pointer the the beginning of the preallocated buffer contiguous
+ * address mapping. It is used only by RING_BUFFER_STATIC configuration. It can
+ * be set to NULL for other backends.
+ */
+
+extern
+struct channel *channel_create(const struct lib_ring_buffer_config *config,
+                              const char *name, void *priv,
+                              void *buf_addr,
+                              size_t subbuf_size, size_t num_subbuf,
+                              unsigned int switch_timer_interval,
+                              unsigned int read_timer_interval);
+
+/*
+ * channel_destroy returns the private data pointer. It finalizes all channel's
+ * buffers, waits for readers to release all references, and destroys the
+ * channel.
+ */
+extern
+void *channel_destroy(struct channel *chan);
+
+
+/* Buffer read operations */
+
+/*
+ * Iteration on channel cpumask needs to issue a read barrier to match the write
+ * barrier in cpu hotplug. It orders the cpumask read before read of per-cpu
+ * buffer data. The per-cpu buffer is never removed by cpu hotplug; teardown is
+ * only performed at channel destruction.
+ */
+#define for_each_channel_cpu(cpu, chan)                                        \
+       for ((cpu) = -1;                                                \
+               ({ (cpu) = cpumask_next(cpu, (chan)->backend.cpumask);  \
+                  smp_read_barrier_depends(); (cpu) < nr_cpu_ids; });)
+
+extern struct lib_ring_buffer *channel_get_ring_buffer(
+                               const struct lib_ring_buffer_config *config,
+                               struct channel *chan, int cpu);
+extern int lib_ring_buffer_open_read(struct lib_ring_buffer *buf);
+extern void lib_ring_buffer_release_read(struct lib_ring_buffer *buf);
+
+/*
+ * Read sequence: snapshot, many get_subbuf/put_subbuf, move_consumer.
+ */
+extern int lib_ring_buffer_snapshot(struct lib_ring_buffer *buf,
+                                   unsigned long *consumed,
+                                   unsigned long *produced);
+extern void lib_ring_buffer_move_consumer(struct lib_ring_buffer *buf,
+                                         unsigned long consumed_new);
+
+extern int lib_ring_buffer_get_subbuf(struct lib_ring_buffer *buf,
+                                     unsigned long consumed);
+extern void lib_ring_buffer_put_subbuf(struct lib_ring_buffer *buf);
+
+/*
+ * lib_ring_buffer_get_next_subbuf/lib_ring_buffer_put_next_subbuf are helpers
+ * to read sub-buffers sequentially.
+ */
+static inline int lib_ring_buffer_get_next_subbuf(struct lib_ring_buffer *buf)
+{
+       int ret;
+
+       ret = lib_ring_buffer_snapshot(buf, &buf->cons_snapshot,
+                                      &buf->prod_snapshot);
+       if (ret)
+               return ret;
+       ret = lib_ring_buffer_get_subbuf(buf, buf->cons_snapshot);
+       return ret;
+}
+
+static inline void lib_ring_buffer_put_next_subbuf(struct lib_ring_buffer *buf)
+{
+       lib_ring_buffer_put_subbuf(buf);
+       lib_ring_buffer_move_consumer(buf, subbuf_align(buf->cons_snapshot,
+                                                   buf->backend.chan));
+}
+
+extern void channel_reset(struct channel *chan);
+extern void lib_ring_buffer_reset(struct lib_ring_buffer *buf);
+
+static inline
+unsigned long lib_ring_buffer_get_offset(const struct lib_ring_buffer_config *config,
+                                        struct lib_ring_buffer *buf)
+{
+       return v_read(config, &buf->offset);
+}
+
+static inline
+unsigned long lib_ring_buffer_get_consumed(const struct lib_ring_buffer_config *config,
+                                          struct lib_ring_buffer *buf)
+{
+       return atomic_long_read(&buf->consumed);
+}
+
+/*
+ * Must call lib_ring_buffer_is_finalized before reading counters (memory
+ * ordering enforced with respect to trace teardown).
+ */
+static inline
+int lib_ring_buffer_is_finalized(const struct lib_ring_buffer_config *config,
+                                struct lib_ring_buffer *buf)
+{
+       int finalized = ACCESS_ONCE(buf->finalized);
+       /*
+        * Read finalized before counters.
+        */
+       smp_rmb();
+       return finalized;
+}
+
+static inline
+int lib_ring_buffer_channel_is_finalized(const struct channel *chan)
+{
+       return chan->finalized;
+}
+
+static inline
+int lib_ring_buffer_channel_is_disabled(const struct channel *chan)
+{
+       return atomic_read(&chan->record_disabled);
+}
+
+static inline
+unsigned long lib_ring_buffer_get_read_data_size(
+                               const struct lib_ring_buffer_config *config,
+                               struct lib_ring_buffer *buf)
+{
+       return subbuffer_get_read_data_size(config, &buf->backend);
+}
+
+static inline
+unsigned long lib_ring_buffer_get_records_count(
+                               const struct lib_ring_buffer_config *config,
+                               struct lib_ring_buffer *buf)
+{
+       return v_read(config, &buf->records_count);
+}
+
+static inline
+unsigned long lib_ring_buffer_get_records_overrun(
+                               const struct lib_ring_buffer_config *config,
+                               struct lib_ring_buffer *buf)
+{
+       return v_read(config, &buf->records_overrun);
+}
+
+static inline
+unsigned long lib_ring_buffer_get_records_lost_full(
+                               const struct lib_ring_buffer_config *config,
+                               struct lib_ring_buffer *buf)
+{
+       return v_read(config, &buf->records_lost_full);
+}
+
+static inline
+unsigned long lib_ring_buffer_get_records_lost_wrap(
+                               const struct lib_ring_buffer_config *config,
+                               struct lib_ring_buffer *buf)
+{
+       return v_read(config, &buf->records_lost_wrap);
+}
+
+static inline
+unsigned long lib_ring_buffer_get_records_lost_big(
+                               const struct lib_ring_buffer_config *config,
+                               struct lib_ring_buffer *buf)
+{
+       return v_read(config, &buf->records_lost_big);
+}
+
+static inline
+unsigned long lib_ring_buffer_get_records_read(
+                               const struct lib_ring_buffer_config *config,
+                               struct lib_ring_buffer *buf)
+{
+       return v_read(config, &buf->backend.records_read);
+}
+
+#endif /* _LIB_RING_BUFFER_FRONTEND_H */
diff --git a/drivers/staging/lttng/lib/ringbuffer/frontend_api.h b/drivers/staging/lttng/lib/ringbuffer/frontend_api.h
new file mode 100644 (file)
index 0000000..31ccbfa
--- /dev/null
@@ -0,0 +1,371 @@
+#ifndef _LIB_RING_BUFFER_FRONTEND_API_H
+#define _LIB_RING_BUFFER_FRONTEND_API_H
+
+/*
+ * lib/ringbuffer/frontend_api.h
+ *
+ * Ring Buffer Library Synchronization Header (buffer write API).
+ *
+ * Copyright (C) 2005-2012 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; only
+ * version 2.1 of the License.
+ *
+ * This library 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
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ * Author:
+ *     Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
+ *
+ * See ring_buffer_frontend.c for more information on wait-free algorithms.
+ * See linux/ringbuffer/frontend.h for channel allocation and read-side API.
+ */
+
+#include "../../wrapper/ringbuffer/frontend.h"
+#include <linux/errno.h>
+#include <linux/prefetch.h>
+
+/**
+ * lib_ring_buffer_get_cpu - Precedes ring buffer reserve/commit.
+ *
+ * Disables preemption (acts as a RCU read-side critical section) and keeps a
+ * ring buffer nesting count as supplementary safety net to ensure tracer client
+ * code will never trigger an endless recursion. Returns the processor ID on
+ * success, -EPERM on failure (nesting count too high).
+ *
+ * asm volatile and "memory" clobber prevent the compiler from moving
+ * instructions out of the ring buffer nesting count. This is required to ensure
+ * that probe side-effects which can cause recursion (e.g. unforeseen traps,
+ * divisions by 0, ...) are triggered within the incremented nesting count
+ * section.
+ */
+static inline
+int lib_ring_buffer_get_cpu(const struct lib_ring_buffer_config *config)
+{
+       int cpu, nesting;
+
+       rcu_read_lock_sched_notrace();
+       cpu = smp_processor_id();
+       nesting = ++per_cpu(lib_ring_buffer_nesting, cpu);
+       barrier();
+
+       if (unlikely(nesting > 4)) {
+               WARN_ON_ONCE(1);
+               per_cpu(lib_ring_buffer_nesting, cpu)--;
+               rcu_read_unlock_sched_notrace();
+               return -EPERM;
+       } else
+               return cpu;
+}
+
+/**
+ * lib_ring_buffer_put_cpu - Follows ring buffer reserve/commit.
+ */
+static inline
+void lib_ring_buffer_put_cpu(const struct lib_ring_buffer_config *config)
+{
+       barrier();
+       __get_cpu_var(lib_ring_buffer_nesting)--;
+       rcu_read_unlock_sched_notrace();
+}
+
+/*
+ * lib_ring_buffer_try_reserve is called by lib_ring_buffer_reserve(). It is not
+ * part of the API per se.
+ *
+ * returns 0 if reserve ok, or 1 if the slow path must be taken.
+ */
+static inline
+int lib_ring_buffer_try_reserve(const struct lib_ring_buffer_config *config,
+                               struct lib_ring_buffer_ctx *ctx,
+                               unsigned long *o_begin, unsigned long *o_end,
+                               unsigned long *o_old, size_t *before_hdr_pad)
+{
+       struct channel *chan = ctx->chan;
+       struct lib_ring_buffer *buf = ctx->buf;
+       *o_begin = v_read(config, &buf->offset);
+       *o_old = *o_begin;
+
+       ctx->tsc = lib_ring_buffer_clock_read(chan);
+       if ((int64_t) ctx->tsc == -EIO)
+               return 1;
+
+       /*
+        * Prefetch cacheline for read because we have to read the previous
+        * commit counter to increment it and commit seq value to compare it to
+        * the commit counter.
+        */
+       prefetch(&buf->commit_hot[subbuf_index(*o_begin, chan)]);
+
+       if (last_tsc_overflow(config, buf, ctx->tsc))
+               ctx->rflags |= RING_BUFFER_RFLAG_FULL_TSC;
+
+       if (unlikely(subbuf_offset(*o_begin, chan) == 0))
+               return 1;
+
+       ctx->slot_size = record_header_size(config, chan, *o_begin,
+                                           before_hdr_pad, ctx);
+       ctx->slot_size +=
+               lib_ring_buffer_align(*o_begin + ctx->slot_size,
+                                     ctx->largest_align) + ctx->data_size;
+       if (unlikely((subbuf_offset(*o_begin, chan) + ctx->slot_size)
+                    > chan->backend.subbuf_size))
+               return 1;
+
+       /*
+        * Record fits in the current buffer and we are not on a switch
+        * boundary. It's safe to write.
+        */
+       *o_end = *o_begin + ctx->slot_size;
+
+       if (unlikely((subbuf_offset(*o_end, chan)) == 0))
+               /*
+                * The offset_end will fall at the very beginning of the next
+                * subbuffer.
+                */
+               return 1;
+
+       return 0;
+}
+
+/**
+ * lib_ring_buffer_reserve - Reserve space in a ring buffer.
+ * @config: ring buffer instance configuration.
+ * @ctx: ring buffer context. (input and output) Must be already initialized.
+ *
+ * Atomic wait-free slot reservation. The reserved space starts at the context
+ * "pre_offset". Its length is "slot_size". The associated time-stamp is "tsc".
+ *
+ * Return :
+ *  0 on success.
+ * -EAGAIN if channel is disabled.
+ * -ENOSPC if event size is too large for packet.
+ * -ENOBUFS if there is currently not enough space in buffer for the event.
+ * -EIO if data cannot be written into the buffer for any other reason.
+ */
+
+static inline
+int lib_ring_buffer_reserve(const struct lib_ring_buffer_config *config,
+                           struct lib_ring_buffer_ctx *ctx)
+{
+       struct channel *chan = ctx->chan;
+       struct lib_ring_buffer *buf;
+       unsigned long o_begin, o_end, o_old;
+       size_t before_hdr_pad = 0;
+
+       if (atomic_read(&chan->record_disabled))
+               return -EAGAIN;
+
+       if (config->alloc == RING_BUFFER_ALLOC_PER_CPU)
+               buf = per_cpu_ptr(chan->backend.buf, ctx->cpu);
+       else
+               buf = chan->backend.buf;
+       if (atomic_read(&buf->record_disabled))
+               return -EAGAIN;
+       ctx->buf = buf;
+
+       /*
+        * Perform retryable operations.
+        */
+       if (unlikely(lib_ring_buffer_try_reserve(config, ctx, &o_begin,
+                                                &o_end, &o_old, &before_hdr_pad)))
+               goto slow_path;
+
+       if (unlikely(v_cmpxchg(config, &ctx->buf->offset, o_old, o_end)
+                    != o_old))
+               goto slow_path;
+
+       /*
+        * Atomically update last_tsc. This update races against concurrent
+        * atomic updates, but the race will always cause supplementary full TSC
+        * record headers, never the opposite (missing a full TSC record header
+        * when it would be needed).
+        */
+       save_last_tsc(config, ctx->buf, ctx->tsc);
+
+       /*
+        * Push the reader if necessary
+        */
+       lib_ring_buffer_reserve_push_reader(ctx->buf, chan, o_end - 1);
+
+       /*
+        * Clear noref flag for this subbuffer.
+        */
+       lib_ring_buffer_clear_noref(config, &ctx->buf->backend,
+                               subbuf_index(o_end - 1, chan));
+
+       ctx->pre_offset = o_begin;
+       ctx->buf_offset = o_begin + before_hdr_pad;
+       return 0;
+slow_path:
+       return lib_ring_buffer_reserve_slow(ctx);
+}
+
+/**
+ * lib_ring_buffer_switch - Perform a sub-buffer switch for a per-cpu buffer.
+ * @config: ring buffer instance configuration.
+ * @buf: buffer
+ * @mode: buffer switch mode (SWITCH_ACTIVE or SWITCH_FLUSH)
+ *
+ * This operation is completely reentrant : can be called while tracing is
+ * active with absolutely no lock held.
+ *
+ * Note, however, that as a v_cmpxchg is used for some atomic operations and
+ * requires to be executed locally for per-CPU buffers, this function must be
+ * called from the CPU which owns the buffer for a ACTIVE flush, with preemption
+ * disabled, for RING_BUFFER_SYNC_PER_CPU configuration.
+ */
+static inline
+void lib_ring_buffer_switch(const struct lib_ring_buffer_config *config,
+                           struct lib_ring_buffer *buf, enum switch_mode mode)
+{
+       lib_ring_buffer_switch_slow(buf, mode);
+}
+
+/* See ring_buffer_frontend_api.h for lib_ring_buffer_reserve(). */
+
+/**
+ * lib_ring_buffer_commit - Commit an record.
+ * @config: ring buffer instance configuration.
+ * @ctx: ring buffer context. (input arguments only)
+ *
+ * Atomic unordered slot commit. Increments the commit count in the
+ * specified sub-buffer, and delivers it if necessary.
+ */
+static inline
+void lib_ring_buffer_commit(const struct lib_ring_buffer_config *config,
+                           const struct lib_ring_buffer_ctx *ctx)
+{
+       struct channel *chan = ctx->chan;
+       struct lib_ring_buffer *buf = ctx->buf;
+       unsigned long offset_end = ctx->buf_offset;
+       unsigned long endidx = subbuf_index(offset_end - 1, chan);
+       unsigned long commit_count;
+
+       /*
+        * Must count record before incrementing the commit count.
+        */
+       subbuffer_count_record(config, &buf->backend, endidx);
+
+       /*
+        * Order all writes to buffer before the commit count update that will
+        * determine that the subbuffer is full.
+        */
+       if (config->ipi == RING_BUFFER_IPI_BARRIER) {
+               /*
+                * Must write slot data before incrementing commit count.  This
+                * compiler barrier is upgraded into a smp_mb() by the IPI sent
+                * by get_subbuf().
+                */
+               barrier();
+       } else
+               smp_wmb();
+
+       v_add(config, ctx->slot_size, &buf->commit_hot[endidx].cc);
+
+       /*
+        * commit count read can race with concurrent OOO commit count updates.
+        * This is only needed for lib_ring_buffer_check_deliver (for
+        * non-polling delivery only) and for
+        * lib_ring_buffer_write_commit_counter.  The race can only cause the
+        * counter to be read with the same value more than once, which could
+        * cause :
+        * - Multiple delivery for the same sub-buffer (which is handled
+        *   gracefully by the reader code) if the value is for a full
+        *   sub-buffer. It's important that we can never miss a sub-buffer
+        *   delivery. Re-reading the value after the v_add ensures this.
+        * - Reading a commit_count with a higher value that what was actually
+        *   added to it for the lib_ring_buffer_write_commit_counter call
+        *   (again caused by a concurrent committer). It does not matter,
+        *   because this function is interested in the fact that the commit
+        *   count reaches back the reserve offset for a specific sub-buffer,
+        *   which is completely independent of the order.
+        */
+       commit_count = v_read(config, &buf->commit_hot[endidx].cc);
+
+       lib_ring_buffer_check_deliver(config, buf, chan, offset_end - 1,
+                                     commit_count, endidx, ctx->tsc);
+       /*
+        * Update used size at each commit. It's needed only for extracting
+        * ring_buffer buffers from vmcore, after crash.
+        */
+       lib_ring_buffer_write_commit_counter(config, buf, chan, endidx,
+                                            ctx->buf_offset, commit_count,
+                                        ctx->slot_size);
+}
+
+/**
+ * lib_ring_buffer_try_discard_reserve - Try discarding a record.
+ * @config: ring buffer instance configuration.
+ * @ctx: ring buffer context. (input arguments only)
+ *
+ * Only succeeds if no other record has been written after the record to
+ * discard. If discard fails, the record must be committed to the buffer.
+ *
+ * Returns 0 upon success, -EPERM if the record cannot be discarded.
+ */
+static inline
+int lib_ring_buffer_try_discard_reserve(const struct lib_ring_buffer_config *config,
+                                       const struct lib_ring_buffer_ctx *ctx)
+{
+       struct lib_ring_buffer *buf = ctx->buf;
+       unsigned long end_offset = ctx->pre_offset + ctx->slot_size;
+
+       /*
+        * We need to ensure that if the cmpxchg succeeds and discards the
+        * record, the next record will record a full TSC, because it cannot
+        * rely on the last_tsc associated with the discarded record to detect
+        * overflows. The only way to ensure this is to set the last_tsc to 0
+        * (assuming no 64-bit TSC overflow), which forces to write a 64-bit
+        * timestamp in the next record.
+        *
+        * Note: if discard fails, we must leave the TSC in the record header.
+        * It is needed to keep track of TSC overflows for the following
+        * records.
+        */
+       save_last_tsc(config, buf, 0ULL);
+
+       if (likely(v_cmpxchg(config, &buf->offset, end_offset, ctx->pre_offset)
+                  != end_offset))
+               return -EPERM;
+       else
+               return 0;
+}
+
+static inline
+void channel_record_disable(const struct lib_ring_buffer_config *config,
+                           struct channel *chan)
+{
+       atomic_inc(&chan->record_disabled);
+}
+
+static inline
+void channel_record_enable(const struct lib_ring_buffer_config *config,
+                          struct channel *chan)
+{
+       atomic_dec(&chan->record_disabled);
+}
+
+static inline
+void lib_ring_buffer_record_disable(const struct lib_ring_buffer_config *config,
+                                   struct lib_ring_buffer *buf)
+{
+       atomic_inc(&buf->record_disabled);
+}
+
+static inline
+void lib_ring_buffer_record_enable(const struct lib_ring_buffer_config *config,
+                                  struct lib_ring_buffer *buf)
+{
+       atomic_dec(&buf->record_disabled);
+}
+
+#endif /* _LIB_RING_BUFFER_FRONTEND_API_H */
diff --git a/drivers/staging/lttng/lib/ringbuffer/frontend_internal.h b/drivers/staging/lttng/lib/ringbuffer/frontend_internal.h
new file mode 100644 (file)
index 0000000..eda800d
--- /dev/null
@@ -0,0 +1,456 @@
+#ifndef _LIB_RING_BUFFER_FRONTEND_INTERNAL_H
+#define _LIB_RING_BUFFER_FRONTEND_INTERNAL_H
+
+/*
+ * linux/ringbuffer/frontend_internal.h
+ *
+ * Ring Buffer Library Synchronization Header (internal helpers).
+ *
+ * Copyright (C) 2005-2012 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; only
+ * version 2.1 of the License.
+ *
+ * This library 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
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ * Author:
+ *     Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
+ *
+ * See ring_buffer_frontend.c for more information on wait-free algorithms.
+ */
+
+#include "../../wrapper/ringbuffer/config.h"
+#include "../../wrapper/ringbuffer/backend_types.h"
+#include "../../wrapper/ringbuffer/frontend_types.h"
+#include "../../lib/prio_heap/lttng_prio_heap.h"       /* For per-CPU read-side iterator */
+
+/* Buffer offset macros */
+
+/* buf_trunc mask selects only the buffer number. */
+static inline
+unsigned long buf_trunc(unsigned long offset, struct channel *chan)
+{
+       return offset & ~(chan->backend.buf_size - 1);
+
+}
+
+/* Select the buffer number value (counter). */
+static inline
+unsigned long buf_trunc_val(unsigned long offset, struct channel *chan)
+{
+       return buf_trunc(offset, chan) >> chan->backend.buf_size_order;
+}
+
+/* buf_offset mask selects only the offset within the current buffer. */
+static inline
+unsigned long buf_offset(unsigned long offset, struct channel *chan)
+{
+       return offset & (chan->backend.buf_size - 1);
+}
+
+/* subbuf_offset mask selects the offset within the current subbuffer. */
+static inline
+unsigned long subbuf_offset(unsigned long offset, struct channel *chan)
+{
+       return offset & (chan->backend.subbuf_size - 1);
+}
+
+/* subbuf_trunc mask selects the subbuffer number. */
+static inline
+unsigned long subbuf_trunc(unsigned long offset, struct channel *chan)
+{
+       return offset & ~(chan->backend.subbuf_size - 1);
+}
+
+/* subbuf_align aligns the offset to the next subbuffer. */
+static inline
+unsigned long subbuf_align(unsigned long offset, struct channel *chan)
+{
+       return (offset + chan->backend.subbuf_size)
+              & ~(chan->backend.subbuf_size - 1);
+}
+
+/* subbuf_index returns the index of the current subbuffer within the buffer. */
+static inline
+unsigned long subbuf_index(unsigned long offset, struct channel *chan)
+{
+       return buf_offset(offset, chan) >> chan->backend.subbuf_size_order;
+}
+
+/*
+ * Last TSC comparison functions. Check if the current TSC overflows tsc_bits
+ * bits from the last TSC read. When overflows are detected, the full 64-bit
+ * timestamp counter should be written in the record header. Reads and writes
+ * last_tsc atomically.
+ */
+
+#if (BITS_PER_LONG == 32)
+static inline
+void save_last_tsc(const struct lib_ring_buffer_config *config,
+                  struct lib_ring_buffer *buf, u64 tsc)
+{
+       if (config->tsc_bits == 0 || config->tsc_bits == 64)
+               return;
+
+       /*
+        * Ensure the compiler performs this update in a single instruction.
+        */
+       v_set(config, &buf->last_tsc, (unsigned long)(tsc >> config->tsc_bits));
+}
+
+static inline
+int last_tsc_overflow(const struct lib_ring_buffer_config *config,
+                     struct lib_ring_buffer *buf, u64 tsc)
+{
+       unsigned long tsc_shifted;
+
+       if (config->tsc_bits == 0 || config->tsc_bits == 64)
+               return 0;
+
+       tsc_shifted = (unsigned long)(tsc >> config->tsc_bits);
+       if (unlikely(tsc_shifted
+                    - (unsigned long)v_read(config, &buf->last_tsc)))
+               return 1;
+       else
+               return 0;
+}
+#else
+static inline
+void save_last_tsc(const struct lib_ring_buffer_config *config,
+                  struct lib_ring_buffer *buf, u64 tsc)
+{
+       if (config->tsc_bits == 0 || config->tsc_bits == 64)
+               return;
+
+       v_set(config, &buf->last_tsc, (unsigned long)tsc);
+}
+
+static inline
+int last_tsc_overflow(const struct lib_ring_buffer_config *config,
+                     struct lib_ring_buffer *buf, u64 tsc)
+{
+       if (config->tsc_bits == 0 || config->tsc_bits == 64)
+               return 0;
+
+       if (unlikely((tsc - v_read(config, &buf->last_tsc))
+                    >> config->tsc_bits))
+               return 1;
+       else
+               return 0;
+}
+#endif
+
+extern
+int lib_ring_buffer_reserve_slow(struct lib_ring_buffer_ctx *ctx);
+
+extern
+void lib_ring_buffer_switch_slow(struct lib_ring_buffer *buf,
+                                enum switch_mode mode);
+
+extern
+void lib_ring_buffer_switch_remote(struct lib_ring_buffer *buf);
+
+/* Buffer write helpers */
+
+static inline
+void lib_ring_buffer_reserve_push_reader(struct lib_ring_buffer *buf,
+                                        struct channel *chan,
+                                        unsigned long offset)
+{
+       unsigned long consumed_old, consumed_new;
+
+       do {
+               consumed_old = atomic_long_read(&buf->consumed);
+               /*
+                * If buffer is in overwrite mode, push the reader consumed
+                * count if the write position has reached it and we are not
+                * at the first iteration (don't push the reader farther than
+                * the writer). This operation can be done concurrently by many
+                * writers in the same buffer, the writer being at the farthest
+                * write position sub-buffer index in the buffer being the one
+                * which will win this loop.
+                */
+               if (unlikely(subbuf_trunc(offset, chan)
+                             - subbuf_trunc(consumed_old, chan)
+                            >= chan->backend.buf_size))
+                       consumed_new = subbuf_align(consumed_old, chan);
+               else
+                       return;
+       } while (unlikely(atomic_long_cmpxchg(&buf->consumed, consumed_old,
+                                             consumed_new) != consumed_old));
+}
+
+static inline
+void lib_ring_buffer_vmcore_check_deliver(const struct lib_ring_buffer_config *config,
+                                         struct lib_ring_buffer *buf,
+                                         unsigned long commit_count,
+                                         unsigned long idx)
+{
+       if (config->oops == RING_BUFFER_OOPS_CONSISTENCY)
+               v_set(config, &buf->commit_hot[idx].seq, commit_count);
+}
+
+static inline
+int lib_ring_buffer_poll_deliver(const struct lib_ring_buffer_config *config,
+                                struct lib_ring_buffer *buf,
+                                struct channel *chan)
+{
+       unsigned long consumed_old, consumed_idx, commit_count, write_offset;
+
+       consumed_old = atomic_long_read(&buf->consumed);
+       consumed_idx = subbuf_index(consumed_old, chan);
+       commit_count = v_read(config, &buf->commit_cold[consumed_idx].cc_sb);
+       /*
+        * No memory barrier here, since we are only interested
+        * in a statistically correct polling result. The next poll will
+        * get the data is we are racing. The mb() that ensures correct
+        * memory order is in get_subbuf.
+        */
+       write_offset = v_read(config, &buf->offset);
+
+       /*
+        * Check that the subbuffer we are trying to consume has been
+        * already fully committed.
+        */
+
+       if (((commit_count - chan->backend.subbuf_size)
+            & chan->commit_count_mask)
+           - (buf_trunc(consumed_old, chan)
+              >> chan->backend.num_subbuf_order)
+           != 0)
+               return 0;
+
+       /*
+        * Check that we are not about to read the same subbuffer in
+        * which the writer head is.
+        */
+       if (subbuf_trunc(write_offset, chan) - subbuf_trunc(consumed_old, chan)
+           == 0)
+               return 0;
+
+       return 1;
+
+}
+
+static inline
+int lib_ring_buffer_pending_data(const struct lib_ring_buffer_config *config,
+                                struct lib_ring_buffer *buf,
+                                struct channel *chan)
+{
+       return !!subbuf_offset(v_read(config, &buf->offset), chan);
+}
+
+static inline
+unsigned long lib_ring_buffer_get_data_size(const struct lib_ring_buffer_config *config,
+                                           struct lib_ring_buffer *buf,
+                                           unsigned long idx)
+{
+       return subbuffer_get_data_size(config, &buf->backend, idx);
+}
+
+/*
+ * Check if all space reservation in a buffer have been committed. This helps
+ * knowing if an execution context is nested (for per-cpu buffers only).
+ * This is a very specific ftrace use-case, so we keep this as "internal" API.
+ */
+static inline
+int lib_ring_buffer_reserve_committed(const struct lib_ring_buffer_config *config,
+                                     struct lib_ring_buffer *buf,
+                                     struct channel *chan)
+{
+       unsigned long offset, idx, commit_count;
+
+       CHAN_WARN_ON(chan, config->alloc != RING_BUFFER_ALLOC_PER_CPU);
+       CHAN_WARN_ON(chan, config->sync != RING_BUFFER_SYNC_PER_CPU);
+
+       /*
+        * Read offset and commit count in a loop so they are both read
+        * atomically wrt interrupts. By deal with interrupt concurrency by
+        * restarting both reads if the offset has been pushed. Note that given
+        * we only have to deal with interrupt concurrency here, an interrupt
+        * modifying the commit count will also modify "offset", so it is safe
+        * to only check for offset modifications.
+        */
+       do {
+               offset = v_read(config, &buf->offset);
+               idx = subbuf_index(offset, chan);
+               commit_count = v_read(config, &buf->commit_hot[idx].cc);
+       } while (offset != v_read(config, &buf->offset));
+
+       return ((buf_trunc(offset, chan) >> chan->backend.num_subbuf_order)
+                    - (commit_count & chan->commit_count_mask) == 0);
+}
+
+/*
+ * Receive end of subbuffer TSC as parameter. It has been read in the
+ * space reservation loop of either reserve or switch, which ensures it
+ * progresses monotonically with event records in the buffer. Therefore,
+ * it ensures that the end timestamp of a subbuffer is <= begin
+ * timestamp of the following subbuffers.
+ */
+static inline
+void lib_ring_buffer_check_deliver(const struct lib_ring_buffer_config *config,
+                                  struct lib_ring_buffer *buf,
+                                  struct channel *chan,
+                                  unsigned long offset,
+                                  unsigned long commit_count,
+                                  unsigned long idx,
+                                  u64 tsc)
+{
+       unsigned long old_commit_count = commit_count
+                                        - chan->backend.subbuf_size;
+
+       /* Check if all commits have been done */
+       if (unlikely((buf_trunc(offset, chan) >> chan->backend.num_subbuf_order)
+                    - (old_commit_count & chan->commit_count_mask) == 0)) {
+               /*
+                * If we succeeded at updating cc_sb below, we are the subbuffer
+                * writer delivering the subbuffer. Deals with concurrent
+                * updates of the "cc" value without adding a add_return atomic
+                * operation to the fast path.
+                *
+                * We are doing the delivery in two steps:
+                * - First, we cmpxchg() cc_sb to the new value
+                *   old_commit_count + 1. This ensures that we are the only
+                *   subbuffer user successfully filling the subbuffer, but we
+                *   do _not_ set the cc_sb value to "commit_count" yet.
+                *   Therefore, other writers that would wrap around the ring
+                *   buffer and try to start writing to our subbuffer would
+                *   have to drop records, because it would appear as
+                *   non-filled.
+                *   We therefore have exclusive access to the subbuffer control
+                *   structures.  This mutual exclusion with other writers is
+                *   crucially important to perform record overruns count in
+                *   flight recorder mode locklessly.
+                * - When we are ready to release the subbuffer (either for
+                *   reading or for overrun by other writers), we simply set the
+                *   cc_sb value to "commit_count" and perform delivery.
+                *
+                * The subbuffer size is least 2 bytes (minimum size: 1 page).
+                * This guarantees that old_commit_count + 1 != commit_count.
+                */
+
+               /*
+                * Order prior updates to reserve count prior to the
+                * commit_cold cc_sb update.
+                */
+               smp_wmb();
+               if (likely(v_cmpxchg(config, &buf->commit_cold[idx].cc_sb,
+                                        old_commit_count, old_commit_count + 1)
+                          == old_commit_count)) {
+                       /*
+                        * Start of exclusive subbuffer access. We are
+                        * guaranteed to be the last writer in this subbuffer
+                        * and any other writer trying to access this subbuffer
+                        * in this state is required to drop records.
+                        */
+                       v_add(config,
+                             subbuffer_get_records_count(config,
+                                                         &buf->backend, idx),
+                             &buf->records_count);
+                       v_add(config,
+                             subbuffer_count_records_overrun(config,
+                                                             &buf->backend,
+                                                             idx),
+                             &buf->records_overrun);
+                       config->cb.buffer_end(buf, tsc, idx,
+                                             lib_ring_buffer_get_data_size(config,
+                                                                       buf,
+                                                                       idx));
+
+                       /*
+                        * Set noref flag and offset for this subbuffer id.
+                        * Contains a memory barrier that ensures counter stores
+                        * are ordered before set noref and offset.
+                        */
+                       lib_ring_buffer_set_noref_offset(config, &buf->backend, idx,
+                                                        buf_trunc_val(offset, chan));
+
+                       /*
+                        * Order set_noref and record counter updates before the
+                        * end of subbuffer exclusive access. Orders with
+                        * respect to writers coming into the subbuffer after
+                        * wrap around, and also order wrt concurrent readers.
+                        */
+                       smp_mb();
+                       /* End of exclusive subbuffer access */
+                       v_set(config, &buf->commit_cold[idx].cc_sb,
+                             commit_count);
+                       /*
+                        * Order later updates to reserve count after
+                        * the commit_cold cc_sb update.
+                        */
+                       smp_wmb();
+                       lib_ring_buffer_vmcore_check_deliver(config, buf,
+                                                        commit_count, idx);
+
+                       /*
+                        * RING_BUFFER_WAKEUP_BY_WRITER wakeup is not lock-free.
+                        */
+                       if (config->wakeup == RING_BUFFER_WAKEUP_BY_WRITER
+                           && atomic_long_read(&buf->active_readers)
+                           && lib_ring_buffer_poll_deliver(config, buf, chan)) {
+                               wake_up_interruptible(&buf->read_wait);
+                               wake_up_interruptible(&chan->read_wait);
+                       }
+
+               }
+       }
+}
+
+/*
+ * lib_ring_buffer_write_commit_counter
+ *
+ * For flight recording. must be called after commit.
+ * This function increments the subbuffer's commit_seq counter each time the
+ * commit count reaches back the reserve offset (modulo subbuffer size). It is
+ * useful for crash dump.
+ */
+static inline
+void lib_ring_buffer_write_commit_counter(const struct lib_ring_buffer_config *config,
+                                         struct lib_ring_buffer *buf,
+                                         struct channel *chan,
+                                         unsigned long idx,
+                                         unsigned long buf_offset,
+                                         unsigned long commit_count,
+                                         size_t slot_size)
+{
+       unsigned long offset, commit_seq_old;
+
+       if (config->oops != RING_BUFFER_OOPS_CONSISTENCY)
+               return;
+
+       offset = buf_offset + slot_size;
+
+       /*
+        * subbuf_offset includes commit_count_mask. We can simply
+        * compare the offsets within the subbuffer without caring about
+        * buffer full/empty mismatch because offset is never zero here
+        * (subbuffer header and record headers have non-zero length).
+        */
+       if (unlikely(subbuf_offset(offset - commit_count, chan)))
+               return;
+
+       commit_seq_old = v_read(config, &buf->commit_hot[idx].seq);
+       while ((long) (commit_seq_old - commit_count) < 0)
+               commit_seq_old = v_cmpxchg(config, &buf->commit_hot[idx].seq,
+                                          commit_seq_old, commit_count);
+}
+
+extern int lib_ring_buffer_create(struct lib_ring_buffer *buf,
+                                 struct channel_backend *chanb, int cpu);
+extern void lib_ring_buffer_free(struct lib_ring_buffer *buf);
+
+/* Keep track of trap nesting inside ring buffer code */
+DECLARE_PER_CPU(unsigned int, lib_ring_buffer_nesting);
+
+#endif /* _LIB_RING_BUFFER_FRONTEND_INTERNAL_H */
diff --git a/drivers/staging/lttng/lib/ringbuffer/frontend_types.h b/drivers/staging/lttng/lib/ringbuffer/frontend_types.h
new file mode 100644 (file)
index 0000000..9fc3a30
--- /dev/null
@@ -0,0 +1,188 @@
+#ifndef _LIB_RING_BUFFER_FRONTEND_TYPES_H
+#define _LIB_RING_BUFFER_FRONTEND_TYPES_H
+
+/*
+ * lib/ringbuffer/frontend_types.h
+ *
+ * Ring Buffer Library Synchronization Header (types).
+ *
+ * Copyright (C) 2010-2012 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; only
+ * version 2.1 of the License.
+ *
+ * This library 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
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ * Author:
+ *     Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
+ *
+ * See ring_buffer_frontend.c for more information on wait-free algorithms.
+ */
+
+#include <linux/kref.h>
+#include "../../wrapper/ringbuffer/config.h"
+#include "../../wrapper/ringbuffer/backend_types.h"
+#include "../../wrapper/spinlock.h"
+#include "../../lib/prio_heap/lttng_prio_heap.h"       /* For per-CPU read-side iterator */
+
+/*
+ * A switch is done during tracing or as a final flush after tracing (so it
+ * won't write in the new sub-buffer).
+ */
+enum switch_mode { SWITCH_ACTIVE, SWITCH_FLUSH };
+
+/* channel-level read-side iterator */
+struct channel_iter {
+       /* Prio heap of buffers. Lowest timestamps at the top. */
+       struct lttng_ptr_heap heap;     /* Heap of struct lib_ring_buffer ptrs */
+       struct list_head empty_head;    /* Empty buffers linked-list head */
+       int read_open;                  /* Opened for reading ? */
+       u64 last_qs;                    /* Last quiescent state timestamp */
+       u64 last_timestamp;             /* Last timestamp (for WARN_ON) */
+       int last_cpu;                   /* Last timestamp cpu */
+       /*
+        * read() file operation state.
+        */
+       unsigned long len_left;
+};
+
+/* channel: collection of per-cpu ring buffers. */
+struct channel {
+       atomic_t record_disabled;
+       unsigned long commit_count_mask;        /*
+                                                * Commit count mask, removing
+                                                * the MSBs corresponding to
+                                                * bits used to represent the
+                                                * subbuffer index.
+                                                */
+
+       struct channel_backend backend;         /* Associated backend */
+
+       unsigned long switch_timer_interval;    /* Buffer flush (jiffies) */
+       unsigned long read_timer_interval;      /* Reader wakeup (jiffies) */
+       struct notifier_block cpu_hp_notifier;  /* CPU hotplug notifier */
+       struct notifier_block tick_nohz_notifier; /* CPU nohz notifier */
+       struct notifier_block hp_iter_notifier; /* hotplug iterator notifier */
+       unsigned int cpu_hp_enable:1;           /* Enable CPU hotplug notif. */
+       unsigned int hp_iter_enable:1;          /* Enable hp iter notif. */
+       wait_queue_head_t read_wait;            /* reader wait queue */
+       wait_queue_head_t hp_wait;              /* CPU hotplug wait queue */
+       int finalized;                          /* Has channel been finalized */
+       struct channel_iter iter;               /* Channel read-side iterator */
+       struct kref ref;                        /* Reference count */
+};
+
+/* Per-subbuffer commit counters used on the hot path */
+struct commit_counters_hot {
+       union v_atomic cc;              /* Commit counter */
+       union v_atomic seq;             /* Consecutive commits */
+};
+
+/* Per-subbuffer commit counters used only on cold paths */
+struct commit_counters_cold {
+       union v_atomic cc_sb;           /* Incremented _once_ at sb switch */
+};
+
+/* Per-buffer read iterator */
+struct lib_ring_buffer_iter {
+       u64 timestamp;                  /* Current record timestamp */
+       size_t header_len;              /* Current record header length */
+       size_t payload_len;             /* Current record payload length */
+
+       struct list_head empty_node;    /* Linked list of empty buffers */
+       unsigned long consumed, read_offset, data_size;
+       enum {
+               ITER_GET_SUBBUF = 0,
+               ITER_TEST_RECORD,
+               ITER_NEXT_RECORD,
+               ITER_PUT_SUBBUF,
+       } state;
+       unsigned int allocated:1;
+       unsigned int read_open:1;       /* Opened for reading ? */
+};
+
+/* ring buffer state */
+struct lib_ring_buffer {
+       /* First 32 bytes cache-hot cacheline */
+       union v_atomic offset;          /* Current offset in the buffer */
+       struct commit_counters_hot *commit_hot;
+                                       /* Commit count per sub-buffer */
+       atomic_long_t consumed;         /*
+                                        * Current offset in the buffer
+                                        * standard atomic access (shared)
+                                        */
+       atomic_t record_disabled;
+       /* End of first 32 bytes cacheline */
+       union v_atomic last_tsc;        /*
+                                        * Last timestamp written in the buffer.
+                                        */
+
+       struct lib_ring_buffer_backend backend; /* Associated backend */
+
+       struct commit_counters_cold *commit_cold;
+                                       /* Commit count per sub-buffer */
+       atomic_long_t active_readers;   /*
+                                        * Active readers count
+                                        * standard atomic access (shared)
+                                        */
+                                       /* Dropped records */
+       union v_atomic records_lost_full;       /* Buffer full */
+       union v_atomic records_lost_wrap;       /* Nested wrap-around */
+       union v_atomic records_lost_big;        /* Events too big */
+       union v_atomic records_count;   /* Number of records written */
+       union v_atomic records_overrun; /* Number of overwritten records */
+       wait_queue_head_t read_wait;    /* reader buffer-level wait queue */
+       wait_queue_head_t write_wait;   /* writer buffer-level wait queue (for metadata only) */
+       int finalized;                  /* buffer has been finalized */
+       struct timer_list switch_timer; /* timer for periodical switch */
+       struct timer_list read_timer;   /* timer for read poll */
+       raw_spinlock_t raw_tick_nohz_spinlock;  /* nohz entry lock/trylock */
+       struct lib_ring_buffer_iter iter;       /* read-side iterator */
+       unsigned long get_subbuf_consumed;      /* Read-side consumed */
+       unsigned long prod_snapshot;    /* Producer count snapshot */
+       unsigned long cons_snapshot;    /* Consumer count snapshot */
+       unsigned int get_subbuf:1,      /* Sub-buffer being held by reader */
+               switch_timer_enabled:1, /* Protected by ring_buffer_nohz_lock */
+               read_timer_enabled:1;   /* Protected by ring_buffer_nohz_lock */
+};
+
+static inline
+void *channel_get_private(struct channel *chan)
+{
+       return chan->backend.priv;
+}
+
+/*
+ * Issue warnings and disable channels upon internal error.
+ * Can receive struct lib_ring_buffer or struct lib_ring_buffer_backend
+ * parameters.
+ */
+#define CHAN_WARN_ON(c, cond)                                          \
+       ({                                                              \
+               struct channel *__chan;                                 \
+               int _____ret = unlikely(cond);                          \
+               if (_____ret) {                                         \
+                       if (__same_type(*(c), struct channel_backend))  \
+                               __chan = container_of((void *) (c),     \
+                                                       struct channel, \
+                                                       backend);       \
+                       else if (__same_type(*(c), struct channel))     \
+                               __chan = (void *) (c);                  \
+                       else                                            \
+                               BUG_ON(1);                              \
+                       atomic_inc(&__chan->record_disabled);           \
+                       WARN_ON(1);                                     \
+               }                                                       \
+               _____ret;                                               \
+       })
+
+#endif /* _LIB_RING_BUFFER_FRONTEND_TYPES_H */
diff --git a/drivers/staging/lttng/lib/ringbuffer/iterator.h b/drivers/staging/lttng/lib/ringbuffer/iterator.h
new file mode 100644 (file)
index 0000000..b0e1764
--- /dev/null
@@ -0,0 +1,83 @@
+#ifndef _LIB_RING_BUFFER_ITERATOR_H
+#define _LIB_RING_BUFFER_ITERATOR_H
+
+/*
+ * lib/ringbuffer/iterator.h
+ *
+ * Ring buffer and channel iterators.
+ *
+ * Copyright (C) 2010-2012 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; only
+ * version 2.1 of the License.
+ *
+ * This library 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
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ * Author:
+ *     Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
+ */
+
+#include "../../wrapper/ringbuffer/backend.h"
+#include "../../wrapper/ringbuffer/frontend.h"
+#include "../../wrapper/ringbuffer/vfs.h"
+
+/*
+ * lib_ring_buffer_get_next_record advances the buffer read position to the next
+ * record. It returns either the size of the next record, -EAGAIN if there is
+ * currently no data available, or -ENODATA if no data is available and buffer
+ * is finalized.
+ */
+extern ssize_t lib_ring_buffer_get_next_record(struct channel *chan,
+                                              struct lib_ring_buffer *buf);
+
+/*
+ * channel_get_next_record advances the buffer read position to the next record.
+ * It returns either the size of the next record, -EAGAIN if there is currently
+ * no data available, or -ENODATA if no data is available and buffer is
+ * finalized.
+ * Returns the current buffer in ret_buf.
+ */
+extern ssize_t channel_get_next_record(struct channel *chan,
+                                      struct lib_ring_buffer **ret_buf);
+
+/**
+ * read_current_record - copy the buffer current record into dest.
+ * @buf: ring buffer
+ * @dest: destination where the record should be copied
+ *
+ * dest should be large enough to contain the record. Returns the number of
+ * bytes copied.
+ */
+static inline size_t read_current_record(struct lib_ring_buffer *buf, void *dest)
+{
+       return lib_ring_buffer_read(&buf->backend, buf->iter.read_offset,
+                                   dest, buf->iter.payload_len);
+}
+
+extern int lib_ring_buffer_iterator_open(struct lib_ring_buffer *buf);
+extern void lib_ring_buffer_iterator_release(struct lib_ring_buffer *buf);
+extern int channel_iterator_open(struct channel *chan);
+extern void channel_iterator_release(struct channel *chan);
+
+extern const struct file_operations channel_payload_file_operations;
+extern const struct file_operations lib_ring_buffer_payload_file_operations;
+
+/*
+ * Used internally.
+ */
+int channel_iterator_init(struct channel *chan);
+void channel_iterator_unregister_notifiers(struct channel *chan);
+void channel_iterator_free(struct channel *chan);
+void channel_iterator_reset(struct channel *chan);
+void lib_ring_buffer_iterator_reset(struct lib_ring_buffer *buf);
+
+#endif /* _LIB_RING_BUFFER_ITERATOR_H */
diff --git a/drivers/staging/lttng/lib/ringbuffer/nohz.h b/drivers/staging/lttng/lib/ringbuffer/nohz.h
new file mode 100644 (file)
index 0000000..a645764
--- /dev/null
@@ -0,0 +1,42 @@
+#ifndef _LIB_RING_BUFFER_NOHZ_H
+#define _LIB_RING_BUFFER_NOHZ_H
+
+/*
+ * lib/ringbuffer/nohz.h
+ *
+ * Copyright (C) 2011-2012 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; only
+ * version 2.1 of the License.
+ *
+ * This library 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
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#ifdef CONFIG_LIB_RING_BUFFER
+void lib_ring_buffer_tick_nohz_flush(void);
+void lib_ring_buffer_tick_nohz_stop(void);
+void lib_ring_buffer_tick_nohz_restart(void);
+#else
+static inline void lib_ring_buffer_tick_nohz_flush(void)
+{
+}
+
+static inline void lib_ring_buffer_tick_nohz_stop(void)
+{
+}
+
+static inline void lib_ring_buffer_tick_nohz_restart(void)
+{
+}
+#endif
+
+#endif /* _LIB_RING_BUFFER_NOHZ_H */
diff --git a/drivers/staging/lttng/lib/ringbuffer/ring_buffer_backend.c b/drivers/staging/lttng/lib/ringbuffer/ring_buffer_backend.c
new file mode 100644 (file)
index 0000000..8c9d2b7
--- /dev/null
@@ -0,0 +1,869 @@
+/*
+ * ring_buffer_backend.c
+ *
+ * Copyright (C) 2005-2012 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; only
+ * version 2.1 of the License.
+ *
+ * This library 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
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include <linux/stddef.h>
+#include <linux/module.h>
+#include <linux/string.h>
+#include <linux/bitops.h>
+#include <linux/delay.h>
+#include <linux/errno.h>
+#include <linux/slab.h>
+#include <linux/cpu.h>
+#include <linux/mm.h>
+
+#include "../../wrapper/vmalloc.h"     /* for wrapper_vmalloc_sync_all() */
+#include "../../wrapper/ringbuffer/config.h"
+#include "../../wrapper/ringbuffer/backend.h"
+#include "../../wrapper/ringbuffer/frontend.h"
+
+/**
+ * lib_ring_buffer_backend_allocate - allocate a channel buffer
+ * @config: ring buffer instance configuration
+ * @buf: the buffer struct
+ * @size: total size of the buffer
+ * @num_subbuf: number of subbuffers
+ * @extra_reader_sb: need extra subbuffer for reader
+ */
+static
+int lib_ring_buffer_backend_allocate(const struct lib_ring_buffer_config *config,
+                                    struct lib_ring_buffer_backend *bufb,
+                                    size_t size, size_t num_subbuf,
+                                    int extra_reader_sb)
+{
+       struct channel_backend *chanb = &bufb->chan->backend;
+       unsigned long j, num_pages, num_pages_per_subbuf, page_idx = 0;
+       unsigned long subbuf_size, mmap_offset = 0;
+       unsigned long num_subbuf_alloc;
+       struct page **pages;
+       void **virt;
+       unsigned long i;
+
+       num_pages = size >> PAGE_SHIFT;
+       num_pages_per_subbuf = num_pages >> get_count_order(num_subbuf);
+       subbuf_size = chanb->subbuf_size;
+       num_subbuf_alloc = num_subbuf;
+
+       if (extra_reader_sb) {
+               num_pages += num_pages_per_subbuf; /* Add pages for reader */
+               num_subbuf_alloc++;
+       }
+
+       pages = kmalloc_node(ALIGN(sizeof(*pages) * num_pages,
+                                  1 << INTERNODE_CACHE_SHIFT),
+                       GFP_KERNEL, cpu_to_node(max(bufb->cpu, 0)));
+       if (unlikely(!pages))
+               goto pages_error;
+
+       virt = kmalloc_node(ALIGN(sizeof(*virt) * num_pages,
+                                 1 << INTERNODE_CACHE_SHIFT),
+                       GFP_KERNEL, cpu_to_node(max(bufb->cpu, 0)));
+       if (unlikely(!virt))
+               goto virt_error;
+
+       bufb->array = kmalloc_node(ALIGN(sizeof(*bufb->array)
+                                        * num_subbuf_alloc,
+                                 1 << INTERNODE_CACHE_SHIFT),
+                       GFP_KERNEL, cpu_to_node(max(bufb->cpu, 0)));
+       if (unlikely(!bufb->array))
+               goto array_error;
+
+       for (i = 0; i < num_pages; i++) {
+               pages[i] = alloc_pages_node(cpu_to_node(max(bufb->cpu, 0)),
+                                           GFP_KERNEL | __GFP_ZERO, 0);
+               if (unlikely(!pages[i]))
+                       goto depopulate;
+               virt[i] = page_address(pages[i]);
+       }
+       bufb->num_pages_per_subbuf = num_pages_per_subbuf;
+
+       /* Allocate backend pages array elements */
+       for (i = 0; i < num_subbuf_alloc; i++) {
+               bufb->array[i] =
+                       kzalloc_node(ALIGN(
+                               sizeof(struct lib_ring_buffer_backend_pages) +
+                               sizeof(struct lib_ring_buffer_backend_page)
+                               * num_pages_per_subbuf,
+                               1 << INTERNODE_CACHE_SHIFT),
+                               GFP_KERNEL, cpu_to_node(max(bufb->cpu, 0)));
+               if (!bufb->array[i])
+                       goto free_array;
+       }
+
+       /* Allocate write-side subbuffer table */
+       bufb->buf_wsb = kzalloc_node(ALIGN(
+                               sizeof(struct lib_ring_buffer_backend_subbuffer)
+                               * num_subbuf,
+                               1 << INTERNODE_CACHE_SHIFT),
+                               GFP_KERNEL, cpu_to_node(max(bufb->cpu, 0)));
+       if (unlikely(!bufb->buf_wsb))
+               goto free_array;
+
+       for (i = 0; i < num_subbuf; i++)
+               bufb->buf_wsb[i].id = subbuffer_id(config, 0, 1, i);
+
+       /* Assign read-side subbuffer table */
+       if (extra_reader_sb)
+               bufb->buf_rsb.id = subbuffer_id(config, 0, 1,
+                                               num_subbuf_alloc - 1);
+       else
+               bufb->buf_rsb.id = subbuffer_id(config, 0, 1, 0);
+
+       /* Assign pages to page index */
+       for (i = 0; i < num_subbuf_alloc; i++) {
+               for (j = 0; j < num_pages_per_subbuf; j++) {
+                       CHAN_WARN_ON(chanb, page_idx > num_pages);
+                       bufb->array[i]->p[j].virt = virt[page_idx];
+                       bufb->array[i]->p[j].page = pages[page_idx];
+                       page_idx++;
+               }
+               if (config->output == RING_BUFFER_MMAP) {
+                       bufb->array[i]->mmap_offset = mmap_offset;
+                       mmap_offset += subbuf_size;
+               }
+       }
+
+       /*
+        * If kmalloc ever uses vmalloc underneath, make sure the buffer pages
+        * will not fault.
+        */
+       wrapper_vmalloc_sync_all();
+       kfree(virt);
+       kfree(pages);
+       return 0;
+
+free_array:
+       for (i = 0; (i < num_subbuf_alloc && bufb->array[i]); i++)
+               kfree(bufb->array[i]);
+depopulate:
+       /* Free all allocated pages */
+       for (i = 0; (i < num_pages && pages[i]); i++)
+               __free_page(pages[i]);
+       kfree(bufb->array);
+array_error:
+       kfree(virt);
+virt_error:
+       kfree(pages);
+pages_error:
+       return -ENOMEM;
+}
+
+int lib_ring_buffer_backend_create(struct lib_ring_buffer_backend *bufb,
+                                  struct channel_backend *chanb, int cpu)
+{
+       const struct lib_ring_buffer_config *config = &chanb->config;
+
+       bufb->chan = container_of(chanb, struct channel, backend);
+       bufb->cpu = cpu;
+
+       return lib_ring_buffer_backend_allocate(config, bufb, chanb->buf_size,
+                                               chanb->num_subbuf,
+                                               chanb->extra_reader_sb);
+}
+
+void lib_ring_buffer_backend_free(struct lib_ring_buffer_backend *bufb)
+{
+       struct channel_backend *chanb = &bufb->chan->backend;
+       unsigned long i, j, num_subbuf_alloc;
+
+       num_subbuf_alloc = chanb->num_subbuf;
+       if (chanb->extra_reader_sb)
+               num_subbuf_alloc++;
+
+       kfree(bufb->buf_wsb);
+       for (i = 0; i < num_subbuf_alloc; i++) {
+               for (j = 0; j < bufb->num_pages_per_subbuf; j++)
+                       __free_page(bufb->array[i]->p[j].page);
+               kfree(bufb->array[i]);
+       }
+       kfree(bufb->array);
+       bufb->allocated = 0;
+}
+
+void lib_ring_buffer_backend_reset(struct lib_ring_buffer_backend *bufb)
+{
+       struct channel_backend *chanb = &bufb->chan->backend;
+       const struct lib_ring_buffer_config *config = &chanb->config;
+       unsigned long num_subbuf_alloc;
+       unsigned int i;
+
+       num_subbuf_alloc = chanb->num_subbuf;
+       if (chanb->extra_reader_sb)
+               num_subbuf_alloc++;
+
+       for (i = 0; i < chanb->num_subbuf; i++)
+               bufb->buf_wsb[i].id = subbuffer_id(config, 0, 1, i);
+       if (chanb->extra_reader_sb)
+               bufb->buf_rsb.id = subbuffer_id(config, 0, 1,
+                                               num_subbuf_alloc - 1);
+       else
+               bufb->buf_rsb.id = subbuffer_id(config, 0, 1, 0);
+
+       for (i = 0; i < num_subbuf_alloc; i++) {
+               /* Don't reset mmap_offset */
+               v_set(config, &bufb->array[i]->records_commit, 0);
+               v_set(config, &bufb->array[i]->records_unread, 0);
+               bufb->array[i]->data_size = 0;
+               /* Don't reset backend page and virt addresses */
+       }
+       /* Don't reset num_pages_per_subbuf, cpu, allocated */
+       v_set(config, &bufb->records_read, 0);
+}
+
+/*
+ * The frontend is responsible for also calling ring_buffer_backend_reset for
+ * each buffer when calling channel_backend_reset.
+ */
+void channel_backend_reset(struct channel_backend *chanb)
+{
+       struct channel *chan = container_of(chanb, struct channel, backend);
+       const struct lib_ring_buffer_config *config = &chanb->config;
+
+       /*
+        * Don't reset buf_size, subbuf_size, subbuf_size_order,
+        * num_subbuf_order, buf_size_order, extra_reader_sb, num_subbuf,
+        * priv, notifiers, config, cpumask and name.
+        */
+       chanb->start_tsc = config->cb.ring_buffer_clock_read(chan);
+}
+
+#ifdef CONFIG_HOTPLUG_CPU
+/**
+ *     lib_ring_buffer_cpu_hp_callback - CPU hotplug callback
+ *     @nb: notifier block
+ *     @action: hotplug action to take
+ *     @hcpu: CPU number
+ *
+ *     Returns the success/failure of the operation. (%NOTIFY_OK, %NOTIFY_BAD)
+ */
+static
+int lib_ring_buffer_cpu_hp_callback(struct notifier_block *nb,
+                                             unsigned long action,
+                                             void *hcpu)
+{
+       unsigned int cpu = (unsigned long)hcpu;
+       struct channel_backend *chanb = container_of(nb, struct channel_backend,
+                                                    cpu_hp_notifier);
+       const struct lib_ring_buffer_config *config = &chanb->config;
+       struct lib_ring_buffer *buf;
+       int ret;
+
+       CHAN_WARN_ON(chanb, config->alloc == RING_BUFFER_ALLOC_GLOBAL);
+
+       switch (action) {
+       case CPU_UP_PREPARE:
+       case CPU_UP_PREPARE_FROZEN:
+               buf = per_cpu_ptr(chanb->buf, cpu);
+               ret = lib_ring_buffer_create(buf, chanb, cpu);
+               if (ret) {
+                       printk(KERN_ERR
+                         "ring_buffer_cpu_hp_callback: cpu %d "
+                         "buffer creation failed\n", cpu);
+                       return NOTIFY_BAD;
+               }
+               break;
+       case CPU_DEAD:
+       case CPU_DEAD_FROZEN:
+               /* No need to do a buffer switch here, because it will happen
+                * when tracing is stopped, or will be done by switch timer CPU
+                * DEAD callback. */
+               break;
+       }
+       return NOTIFY_OK;
+}
+#endif
+
+/**
+ * channel_backend_init - initialize a channel backend
+ * @chanb: channel backend
+ * @name: channel name
+ * @config: client ring buffer configuration
+ * @priv: client private data
+ * @parent: dentry of parent directory, %NULL for root directory
+ * @subbuf_size: size of sub-buffers (> PAGE_SIZE, power of 2)
+ * @num_subbuf: number of sub-buffers (power of 2)
+ *
+ * Returns channel pointer if successful, %NULL otherwise.
+ *
+ * Creates per-cpu channel buffers using the sizes and attributes
+ * specified.  The created channel buffer files will be named
+ * name_0...name_N-1.  File permissions will be %S_IRUSR.
+ *
+ * Called with CPU hotplug disabled.
+ */
+int channel_backend_init(struct channel_backend *chanb,
+                        const char *name,
+                        const struct lib_ring_buffer_config *config,
+                        void *priv, size_t subbuf_size, size_t num_subbuf)
+{
+       struct channel *chan = container_of(chanb, struct channel, backend);
+       unsigned int i;
+       int ret;
+
+       if (!name)
+               return -EPERM;
+
+       /* Check that the subbuffer size is larger than a page. */
+       if (subbuf_size < PAGE_SIZE)
+               return -EINVAL;
+
+       /*
+        * Make sure the number of subbuffers and subbuffer size are
+        * power of 2 and nonzero.
+        */
+       if (!subbuf_size || (subbuf_size & (subbuf_size - 1)))
+               return -EINVAL;
+       if (!num_subbuf || (num_subbuf & (num_subbuf - 1)))
+               return -EINVAL;
+
+       ret = subbuffer_id_check_index(config, num_subbuf);
+       if (ret)
+               return ret;
+
+       chanb->priv = priv;
+       chanb->buf_size = num_subbuf * subbuf_size;
+       chanb->subbuf_size = subbuf_size;
+       chanb->buf_size_order = get_count_order(chanb->buf_size);
+       chanb->subbuf_size_order = get_count_order(subbuf_size);
+       chanb->num_subbuf_order = get_count_order(num_subbuf);
+       chanb->extra_reader_sb =
+                       (config->mode == RING_BUFFER_OVERWRITE) ? 1 : 0;
+       chanb->num_subbuf = num_subbuf;
+       strlcpy(chanb->name, name, NAME_MAX);
+       memcpy(&chanb->config, config, sizeof(chanb->config));
+
+       if (config->alloc == RING_BUFFER_ALLOC_PER_CPU) {
+               if (!zalloc_cpumask_var(&chanb->cpumask, GFP_KERNEL))
+                       return -ENOMEM;
+       }
+
+       if (config->alloc == RING_BUFFER_ALLOC_PER_CPU) {
+               /* Allocating the buffer per-cpu structures */
+               chanb->buf = alloc_percpu(struct lib_ring_buffer);
+               if (!chanb->buf)
+                       goto free_cpumask;
+
+               /*
+                * In case of non-hotplug cpu, if the ring-buffer is allocated
+                * in early initcall, it will not be notified of secondary cpus.
+                * In that off case, we need to allocate for all possible cpus.
+                */
+#ifdef CONFIG_HOTPLUG_CPU
+               /*
+                * buf->backend.allocated test takes care of concurrent CPU
+                * hotplug.
+                * Priority higher than frontend, so we create the ring buffer
+                * before we start the timer.
+                */
+               chanb->cpu_hp_notifier.notifier_call =
+                               lib_ring_buffer_cpu_hp_callback;
+               chanb->cpu_hp_notifier.priority = 5;
+               register_hotcpu_notifier(&chanb->cpu_hp_notifier);
+
+               get_online_cpus();
+               for_each_online_cpu(i) {
+                       ret = lib_ring_buffer_create(per_cpu_ptr(chanb->buf, i),
+                                                chanb, i);
+                       if (ret)
+                               goto free_bufs; /* cpu hotplug locked */
+               }
+               put_online_cpus();
+#else
+               for_each_possible_cpu(i) {
+                       ret = lib_ring_buffer_create(per_cpu_ptr(chanb->buf, i),
+                                                chanb, i);
+                       if (ret)
+                               goto free_bufs; /* cpu hotplug locked */
+               }
+#endif
+       } else {
+               chanb->buf = kzalloc(sizeof(struct lib_ring_buffer), GFP_KERNEL);
+               if (!chanb->buf)
+                       goto free_cpumask;
+               ret = lib_ring_buffer_create(chanb->buf, chanb, -1);
+               if (ret)
+                       goto free_bufs;
+       }
+       chanb->start_tsc = config->cb.ring_buffer_clock_read(chan);
+
+       return 0;
+
+free_bufs:
+       if (config->alloc == RING_BUFFER_ALLOC_PER_CPU) {
+               for_each_possible_cpu(i) {
+                       struct lib_ring_buffer *buf = per_cpu_ptr(chanb->buf, i);
+
+                       if (!buf->backend.allocated)
+                               continue;
+                       lib_ring_buffer_free(buf);
+               }
+#ifdef CONFIG_HOTPLUG_CPU
+               put_online_cpus();
+#endif
+               free_percpu(chanb->buf);
+       } else
+               kfree(chanb->buf);
+free_cpumask:
+       if (config->alloc == RING_BUFFER_ALLOC_PER_CPU)
+               free_cpumask_var(chanb->cpumask);
+       return -ENOMEM;
+}
+
+/**
+ * channel_backend_unregister_notifiers - unregister notifiers
+ * @chan: the channel
+ *
+ * Holds CPU hotplug.
+ */
+void channel_backend_unregister_notifiers(struct channel_backend *chanb)
+{
+       const struct lib_ring_buffer_config *config = &chanb->config;
+
+       if (config->alloc == RING_BUFFER_ALLOC_PER_CPU)
+               unregister_hotcpu_notifier(&chanb->cpu_hp_notifier);
+}
+
+/**
+ * channel_backend_free - destroy the channel
+ * @chan: the channel
+ *
+ * Destroy all channel buffers and frees the channel.
+ */
+void channel_backend_free(struct channel_backend *chanb)
+{
+       const struct lib_ring_buffer_config *config = &chanb->config;
+       unsigned int i;
+
+       if (config->alloc == RING_BUFFER_ALLOC_PER_CPU) {
+               for_each_possible_cpu(i) {
+                       struct lib_ring_buffer *buf = per_cpu_ptr(chanb->buf, i);
+
+                       if (!buf->backend.allocated)
+                               continue;
+                       lib_ring_buffer_free(buf);
+               }
+               free_cpumask_var(chanb->cpumask);
+               free_percpu(chanb->buf);
+       } else {
+               struct lib_ring_buffer *buf = chanb->buf;
+
+               CHAN_WARN_ON(chanb, !buf->backend.allocated);
+               lib_ring_buffer_free(buf);
+               kfree(buf);
+       }
+}
+
+/**
+ * lib_ring_buffer_write - write data to a ring_buffer buffer.
+ * @bufb : buffer backend
+ * @offset : offset within the buffer
+ * @src : source address
+ * @len : length to write
+ * @pagecpy : page size copied so far
+ */
+void _lib_ring_buffer_write(struct lib_ring_buffer_backend *bufb, size_t offset,
+                           const void *src, size_t len, ssize_t pagecpy)
+{
+       struct channel_backend *chanb = &bufb->chan->backend;
+       const struct lib_ring_buffer_config *config = &chanb->config;
+       size_t sbidx, index;
+       struct lib_ring_buffer_backend_pages *rpages;
+       unsigned long sb_bindex, id;
+
+       do {
+               len -= pagecpy;
+               src += pagecpy;
+               offset += pagecpy;
+               sbidx = offset >> chanb->subbuf_size_order;
+               index = (offset & (chanb->subbuf_size - 1)) >> PAGE_SHIFT;
+
+               /*
+                * Underlying layer should never ask for writes across
+                * subbuffers.
+                */
+               CHAN_WARN_ON(chanb, offset >= chanb->buf_size);
+
+               pagecpy = min_t(size_t, len, PAGE_SIZE - (offset & ~PAGE_MASK));
+               id = bufb->buf_wsb[sbidx].id;
+               sb_bindex = subbuffer_id_get_index(config, id);
+               rpages = bufb->array[sb_bindex];
+               CHAN_WARN_ON(chanb, config->mode == RING_BUFFER_OVERWRITE
+                            && subbuffer_id_is_noref(config, id));
+               lib_ring_buffer_do_copy(config,
+                                       rpages->p[index].virt
+                                               + (offset & ~PAGE_MASK),
+                                       src, pagecpy);
+       } while (unlikely(len != pagecpy));
+}
+EXPORT_SYMBOL_GPL(_lib_ring_buffer_write);
+
+
+/**
+ * lib_ring_buffer_memset - write len bytes of c to a ring_buffer buffer.
+ * @bufb : buffer backend
+ * @offset : offset within the buffer
+ * @c : the byte to write
+ * @len : length to write
+ * @pagecpy : page size copied so far
+ */
+void _lib_ring_buffer_memset(struct lib_ring_buffer_backend *bufb,
+                            size_t offset,
+                            int c, size_t len, ssize_t pagecpy)
+{
+       struct channel_backend *chanb = &bufb->chan->backend;
+       const struct lib_ring_buffer_config *config = &chanb->config;
+       size_t sbidx, index;
+       struct lib_ring_buffer_backend_pages *rpages;
+       unsigned long sb_bindex, id;
+
+       do {
+               len -= pagecpy;
+               offset += pagecpy;
+               sbidx = offset >> chanb->subbuf_size_order;
+               index = (offset & (chanb->subbuf_size - 1)) >> PAGE_SHIFT;
+
+               /*
+                * Underlying layer should never ask for writes across
+                * subbuffers.
+                */
+               CHAN_WARN_ON(chanb, offset >= chanb->buf_size);
+
+               pagecpy = min_t(size_t, len, PAGE_SIZE - (offset & ~PAGE_MASK));
+               id = bufb->buf_wsb[sbidx].id;
+               sb_bindex = subbuffer_id_get_index(config, id);
+               rpages = bufb->array[sb_bindex];
+               CHAN_WARN_ON(chanb, config->mode == RING_BUFFER_OVERWRITE
+                            && subbuffer_id_is_noref(config, id));
+               lib_ring_buffer_do_memset(rpages->p[index].virt
+                                         + (offset & ~PAGE_MASK),
+                                         c, pagecpy);
+       } while (unlikely(len != pagecpy));
+}
+EXPORT_SYMBOL_GPL(_lib_ring_buffer_memset);
+
+
+/**
+ * lib_ring_buffer_copy_from_user_inatomic - write user data to a ring_buffer buffer.
+ * @bufb : buffer backend
+ * @offset : offset within the buffer
+ * @src : source address
+ * @len : length to write
+ * @pagecpy : page size copied so far
+ *
+ * This function deals with userspace pointers, it should never be called
+ * directly without having the src pointer checked with access_ok()
+ * previously.
+ */
+void _lib_ring_buffer_copy_from_user_inatomic(struct lib_ring_buffer_backend *bufb,
+                                     size_t offset,
+                                     const void __user *src, size_t len,
+                                     ssize_t pagecpy)
+{
+       struct channel_backend *chanb = &bufb->chan->backend;
+       const struct lib_ring_buffer_config *config = &chanb->config;
+       size_t sbidx, index;
+       struct lib_ring_buffer_backend_pages *rpages;
+       unsigned long sb_bindex, id;
+       int ret;
+
+       do {
+               len -= pagecpy;
+               src += pagecpy;
+               offset += pagecpy;
+               sbidx = offset >> chanb->subbuf_size_order;
+               index = (offset & (chanb->subbuf_size - 1)) >> PAGE_SHIFT;
+
+               /*
+                * Underlying layer should never ask for writes across
+                * subbuffers.
+                */
+               CHAN_WARN_ON(chanb, offset >= chanb->buf_size);
+
+               pagecpy = min_t(size_t, len, PAGE_SIZE - (offset & ~PAGE_MASK));
+               id = bufb->buf_wsb[sbidx].id;
+               sb_bindex = subbuffer_id_get_index(config, id);
+               rpages = bufb->array[sb_bindex];
+               CHAN_WARN_ON(chanb, config->mode == RING_BUFFER_OVERWRITE
+                               && subbuffer_id_is_noref(config, id));
+               ret = lib_ring_buffer_do_copy_from_user_inatomic(rpages->p[index].virt
+                                                       + (offset & ~PAGE_MASK),
+                                                       src, pagecpy) != 0;
+               if (ret > 0) {
+                       offset += (pagecpy - ret);
+                       len -= (pagecpy - ret);
+                       _lib_ring_buffer_memset(bufb, offset, 0, len, 0);
+                       break; /* stop copy */
+               }
+       } while (unlikely(len != pagecpy));
+}
+EXPORT_SYMBOL_GPL(_lib_ring_buffer_copy_from_user_inatomic);
+
+/**
+ * lib_ring_buffer_read - read data from ring_buffer_buffer.
+ * @bufb : buffer backend
+ * @offset : offset within the buffer
+ * @dest : destination address
+ * @len : length to copy to destination
+ *
+ * Should be protected by get_subbuf/put_subbuf.
+ * Returns the length copied.
+ */
+size_t lib_ring_buffer_read(struct lib_ring_buffer_backend *bufb, size_t offset,
+                           void *dest, size_t len)
+{
+       struct channel_backend *chanb = &bufb->chan->backend;
+       const struct lib_ring_buffer_config *config = &chanb->config;
+       size_t index;
+       ssize_t pagecpy, orig_len;
+       struct lib_ring_buffer_backend_pages *rpages;
+       unsigned long sb_bindex, id;
+
+       orig_len = len;
+       offset &= chanb->buf_size - 1;
+       index = (offset & (chanb->subbuf_size - 1)) >> PAGE_SHIFT;
+       if (unlikely(!len))
+               return 0;
+       for (;;) {
+               pagecpy = min_t(size_t, len, PAGE_SIZE - (offset & ~PAGE_MASK));
+               id = bufb->buf_rsb.id;
+               sb_bindex = subbuffer_id_get_index(config, id);
+               rpages = bufb->array[sb_bindex];
+               CHAN_WARN_ON(chanb, config->mode == RING_BUFFER_OVERWRITE
+                            && subbuffer_id_is_noref(config, id));
+               memcpy(dest, rpages->p[index].virt + (offset & ~PAGE_MASK),
+                      pagecpy);
+               len -= pagecpy;
+               if (likely(!len))
+                       break;
+               dest += pagecpy;
+               offset += pagecpy;
+               index = (offset & (chanb->subbuf_size - 1)) >> PAGE_SHIFT;
+               /*
+                * Underlying layer should never ask for reads across
+                * subbuffers.
+                */
+               CHAN_WARN_ON(chanb, offset >= chanb->buf_size);
+       }
+       return orig_len;
+}
+EXPORT_SYMBOL_GPL(lib_ring_buffer_read);
+
+/**
+ * __lib_ring_buffer_copy_to_user - read data from ring_buffer to userspace
+ * @bufb : buffer backend
+ * @offset : offset within the buffer
+ * @dest : destination userspace address
+ * @len : length to copy to destination
+ *
+ * Should be protected by get_subbuf/put_subbuf.
+ * access_ok() must have been performed on dest addresses prior to call this
+ * function.
+ * Returns -EFAULT on error, 0 if ok.
+ */
+int __lib_ring_buffer_copy_to_user(struct lib_ring_buffer_backend *bufb,
+                                  size_t offset, void __user *dest, size_t len)
+{
+       struct channel_backend *chanb = &bufb->chan->backend;
+       const struct lib_ring_buffer_config *config = &chanb->config;
+       size_t index;
+       ssize_t pagecpy;
+       struct lib_ring_buffer_backend_pages *rpages;
+       unsigned long sb_bindex, id;
+
+       offset &= chanb->buf_size - 1;
+       index = (offset & (chanb->subbuf_size - 1)) >> PAGE_SHIFT;
+       if (unlikely(!len))
+               return 0;
+       for (;;) {
+               pagecpy = min_t(size_t, len, PAGE_SIZE - (offset & ~PAGE_MASK));
+               id = bufb->buf_rsb.id;
+               sb_bindex = subbuffer_id_get_index(config, id);
+               rpages = bufb->array[sb_bindex];
+               CHAN_WARN_ON(chanb, config->mode == RING_BUFFER_OVERWRITE
+                            && subbuffer_id_is_noref(config, id));
+               if (__copy_to_user(dest,
+                              rpages->p[index].virt + (offset & ~PAGE_MASK),
+                              pagecpy))
+                       return -EFAULT;
+               len -= pagecpy;
+               if (likely(!len))
+                       break;
+               dest += pagecpy;
+               offset += pagecpy;
+               index = (offset & (chanb->subbuf_size - 1)) >> PAGE_SHIFT;
+               /*
+                * Underlying layer should never ask for reads across
+                * subbuffers.
+                */
+               CHAN_WARN_ON(chanb, offset >= chanb->buf_size);
+       }
+       return 0;
+}
+EXPORT_SYMBOL_GPL(__lib_ring_buffer_copy_to_user);
+
+/**
+ * lib_ring_buffer_read_cstr - read a C-style string from ring_buffer.
+ * @bufb : buffer backend
+ * @offset : offset within the buffer
+ * @dest : destination address
+ * @len : destination's length
+ *
+ * Return string's length, or -EINVAL on error.
+ * Should be protected by get_subbuf/put_subbuf.
+ * Destination length should be at least 1 to hold '\0'.
+ */
+int lib_ring_buffer_read_cstr(struct lib_ring_buffer_backend *bufb, size_t offset,
+                             void *dest, size_t len)
+{
+       struct channel_backend *chanb = &bufb->chan->backend;
+       const struct lib_ring_buffer_config *config = &chanb->config;
+       size_t index;
+       ssize_t pagecpy, pagelen, strpagelen, orig_offset;
+       char *str;
+       struct lib_ring_buffer_backend_pages *rpages;
+       unsigned long sb_bindex, id;
+
+       offset &= chanb->buf_size - 1;
+       index = (offset & (chanb->subbuf_size - 1)) >> PAGE_SHIFT;
+       orig_offset = offset;
+       if (unlikely(!len))
+               return -EINVAL;
+       for (;;) {
+               id = bufb->buf_rsb.id;
+               sb_bindex = subbuffer_id_get_index(config, id);
+               rpages = bufb->array[sb_bindex];
+               CHAN_WARN_ON(chanb, config->mode == RING_BUFFER_OVERWRITE
+                            && subbuffer_id_is_noref(config, id));
+               str = (char *)rpages->p[index].virt + (offset & ~PAGE_MASK);
+               pagelen = PAGE_SIZE - (offset & ~PAGE_MASK);
+               strpagelen = strnlen(str, pagelen);
+               if (len) {
+                       pagecpy = min_t(size_t, len, strpagelen);
+                       if (dest) {
+                               memcpy(dest, str, pagecpy);
+                               dest += pagecpy;
+                       }
+                       len -= pagecpy;
+               }
+               offset += strpagelen;
+               index = (offset & (chanb->subbuf_size - 1)) >> PAGE_SHIFT;
+               if (strpagelen < pagelen)
+                       break;
+               /*
+                * Underlying layer should never ask for reads across
+                * subbuffers.
+                */
+               CHAN_WARN_ON(chanb, offset >= chanb->buf_size);
+       }
+       if (dest && len)
+               ((char *)dest)[0] = 0;
+       return offset - orig_offset;
+}
+EXPORT_SYMBOL_GPL(lib_ring_buffer_read_cstr);
+
+/**
+ * lib_ring_buffer_read_get_page - Get a whole page to read from
+ * @bufb : buffer backend
+ * @offset : offset within the buffer
+ * @virt : pointer to page address (output)
+ *
+ * Should be protected by get_subbuf/put_subbuf.
+ * Returns the pointer to the page struct pointer.
+ */
+struct page **lib_ring_buffer_read_get_page(struct lib_ring_buffer_backend *bufb,
+                                           size_t offset, void ***virt)
+{
+       size_t index;
+       struct lib_ring_buffer_backend_pages *rpages;
+       struct channel_backend *chanb = &bufb->chan->backend;
+       const struct lib_ring_buffer_config *config = &chanb->config;
+       unsigned long sb_bindex, id;
+
+       offset &= chanb->buf_size - 1;
+       index = (offset & (chanb->subbuf_size - 1)) >> PAGE_SHIFT;
+       id = bufb->buf_rsb.id;
+       sb_bindex = subbuffer_id_get_index(config, id);
+       rpages = bufb->array[sb_bindex];
+       CHAN_WARN_ON(chanb, config->mode == RING_BUFFER_OVERWRITE
+                    && subbuffer_id_is_noref(config, id));
+       *virt = &rpages->p[index].virt;
+       return &rpages->p[index].page;
+}
+EXPORT_SYMBOL_GPL(lib_ring_buffer_read_get_page);
+
+/**
+ * lib_ring_buffer_read_offset_address - get address of a buffer location
+ * @bufb : buffer backend
+ * @offset : offset within the buffer.
+ *
+ * Return the address where a given offset is located (for read).
+ * Should be used to get the current subbuffer header pointer. Given we know
+ * it's never on a page boundary, it's safe to write directly to this address,
+ * as long as the write is never bigger than a page size.
+ */
+void *lib_ring_buffer_read_offset_address(struct lib_ring_buffer_backend *bufb,
+                                         size_t offset)
+{
+       size_t index;
+       struct lib_ring_buffer_backend_pages *rpages;
+       struct channel_backend *chanb = &bufb->chan->backend;
+       const struct lib_ring_buffer_config *config = &chanb->config;
+       unsigned long sb_bindex, id;
+
+       offset &= chanb->buf_size - 1;
+       index = (offset & (chanb->subbuf_size - 1)) >> PAGE_SHIFT;
+       id = bufb->buf_rsb.id;
+       sb_bindex = subbuffer_id_get_index(config, id);
+       rpages = bufb->array[sb_bindex];
+       CHAN_WARN_ON(chanb, config->mode == RING_BUFFER_OVERWRITE
+                    && subbuffer_id_is_noref(config, id));
+       return rpages->p[index].virt + (offset & ~PAGE_MASK);
+}
+EXPORT_SYMBOL_GPL(lib_ring_buffer_read_offset_address);
+
+/**
+ * lib_ring_buffer_offset_address - get address of a location within the buffer
+ * @bufb : buffer backend
+ * @offset : offset within the buffer.
+ *
+ * Return the address where a given offset is located.
+ * Should be used to get the current subbuffer header pointer. Given we know
+ * it's always at the beginning of a page, it's safe to write directly to this
+ * address, as long as the write is never bigger than a page size.
+ */
+void *lib_ring_buffer_offset_address(struct lib_ring_buffer_backend *bufb,
+                                    size_t offset)
+{
+       size_t sbidx, index;
+       struct lib_ring_buffer_backend_pages *rpages;
+       struct channel_backend *chanb = &bufb->chan->backend;
+       const struct lib_ring_buffer_config *config = &chanb->config;
+       unsigned long sb_bindex, id;
+
+       offset &= chanb->buf_size - 1;
+       sbidx = offset >> chanb->subbuf_size_order;
+       index = (offset & (chanb->subbuf_size - 1)) >> PAGE_SHIFT;
+       id = bufb->buf_wsb[sbidx].id;
+       sb_bindex = subbuffer_id_get_index(config, id);
+       rpages = bufb->array[sb_bindex];
+       CHAN_WARN_ON(chanb, config->mode == RING_BUFFER_OVERWRITE
+                    && subbuffer_id_is_noref(config, id));
+       return rpages->p[index].virt + (offset & ~PAGE_MASK);
+}
+EXPORT_SYMBOL_GPL(lib_ring_buffer_offset_address);
diff --git a/drivers/staging/lttng/lib/ringbuffer/ring_buffer_frontend.c b/drivers/staging/lttng/lib/ringbuffer/ring_buffer_frontend.c
new file mode 100644 (file)
index 0000000..9bb4184
--- /dev/null
@@ -0,0 +1,1830 @@
+/*
+ * ring_buffer_frontend.c
+ *
+ * Copyright (C) 2005-2012 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; only
+ * version 2.1 of the License.
+ *
+ * This library 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
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ *
+ * Ring buffer wait-free buffer synchronization. Producer-consumer and flight
+ * recorder (overwrite) modes. See thesis:
+ *
+ * Desnoyers, Mathieu (2009), "Low-Impact Operating System Tracing", Ph.D.
+ * dissertation, Ecole Polytechnique de Montreal.
+ * http://www.lttng.org/pub/thesis/desnoyers-dissertation-2009-12.pdf
+ *
+ * - Algorithm presentation in Chapter 5:
+ *     "Lockless Multi-Core High-Throughput Buffering".
+ * - Algorithm formal verification in Section 8.6:
+ *     "Formal verification of LTTng"
+ *
+ * Author:
+ *     Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
+ *
+ * Inspired from LTT and RelayFS:
+ *  Karim Yaghmour <karim@opersys.com>
+ *  Tom Zanussi <zanussi@us.ibm.com>
+ *  Bob Wisniewski <bob@watson.ibm.com>
+ * And from K42 :
+ *  Bob Wisniewski <bob@watson.ibm.com>
+ *
+ * Buffer reader semantic :
+ *
+ * - get_subbuf_size
+ * while buffer is not finalized and empty
+ *   - get_subbuf
+ *     - if return value != 0, continue
+ *   - splice one subbuffer worth of data to a pipe
+ *   - splice the data from pipe to disk/network
+ *   - put_subbuf
+ */
+
+#include <linux/delay.h>
+#include <linux/module.h>
+#include <linux/percpu.h>
+
+#include "../../wrapper/ringbuffer/config.h"
+#include "../../wrapper/ringbuffer/backend.h"
+#include "../../wrapper/ringbuffer/frontend.h"
+#include "../../wrapper/ringbuffer/iterator.h"
+#include "../../wrapper/ringbuffer/nohz.h"
+
+/*
+ * Internal structure representing offsets to use at a sub-buffer switch.
+ */
+struct switch_offsets {
+       unsigned long begin, end, old;
+       size_t pre_header_padding, size;
+       unsigned int switch_new_start:1, switch_new_end:1, switch_old_start:1,
+                    switch_old_end:1;
+};
+
+#ifdef CONFIG_NO_HZ
+enum tick_nohz_val {
+       TICK_NOHZ_STOP,
+       TICK_NOHZ_FLUSH,
+       TICK_NOHZ_RESTART,
+};
+
+static ATOMIC_NOTIFIER_HEAD(tick_nohz_notifier);
+#endif /* CONFIG_NO_HZ */
+
+static DEFINE_PER_CPU(spinlock_t, ring_buffer_nohz_lock);
+
+DEFINE_PER_CPU(unsigned int, lib_ring_buffer_nesting);
+EXPORT_PER_CPU_SYMBOL(lib_ring_buffer_nesting);
+
+static
+void lib_ring_buffer_print_errors(struct channel *chan,
+                                 struct lib_ring_buffer *buf, int cpu);
+
+/*
+ * Must be called under cpu hotplug protection.
+ */
+void lib_ring_buffer_free(struct lib_ring_buffer *buf)
+{
+       struct channel *chan = buf->backend.chan;
+
+       lib_ring_buffer_print_errors(chan, buf, buf->backend.cpu);
+       kfree(buf->commit_hot);
+       kfree(buf->commit_cold);
+
+       lib_ring_buffer_backend_free(&buf->backend);
+}
+
+/**
+ * lib_ring_buffer_reset - Reset ring buffer to initial values.
+ * @buf: Ring buffer.
+ *
+ * Effectively empty the ring buffer. Should be called when the buffer is not
+ * used for writing. The ring buffer can be opened for reading, but the reader
+ * should not be using the iterator concurrently with reset. The previous
+ * current iterator record is reset.
+ */
+void lib_ring_buffer_reset(struct lib_ring_buffer *buf)
+{
+       struct channel *chan = buf->backend.chan;
+       const struct lib_ring_buffer_config *config = &chan->backend.config;
+       unsigned int i;
+
+       /*
+        * Reset iterator first. It will put the subbuffer if it currently holds
+        * it.
+        */
+       lib_ring_buffer_iterator_reset(buf);
+       v_set(config, &buf->offset, 0);
+       for (i = 0; i < chan->backend.num_subbuf; i++) {
+               v_set(config, &buf->commit_hot[i].cc, 0);
+               v_set(config, &buf->commit_hot[i].seq, 0);
+               v_set(config, &buf->commit_cold[i].cc_sb, 0);
+       }
+       atomic_long_set(&buf->consumed, 0);
+       atomic_set(&buf->record_disabled, 0);
+       v_set(config, &buf->last_tsc, 0);
+       lib_ring_buffer_backend_reset(&buf->backend);
+       /* Don't reset number of active readers */
+       v_set(config, &buf->records_lost_full, 0);
+       v_set(config, &buf->records_lost_wrap, 0);
+       v_set(config, &buf->records_lost_big, 0);
+       v_set(config, &buf->records_count, 0);
+       v_set(config, &buf->records_overrun, 0);
+       buf->finalized = 0;
+}
+EXPORT_SYMBOL_GPL(lib_ring_buffer_reset);
+
+/**
+ * channel_reset - Reset channel to initial values.
+ * @chan: Channel.
+ *
+ * Effectively empty the channel. Should be called when the channel is not used
+ * for writing. The channel can be opened for reading, but the reader should not
+ * be using the iterator concurrently with reset. The previous current iterator
+ * record is reset.
+ */
+void channel_reset(struct channel *chan)
+{
+       /*
+        * Reset iterators first. Will put the subbuffer if held for reading.
+        */
+       channel_iterator_reset(chan);
+       atomic_set(&chan->record_disabled, 0);
+       /* Don't reset commit_count_mask, still valid */
+       channel_backend_reset(&chan->backend);
+       /* Don't reset switch/read timer interval */
+       /* Don't reset notifiers and notifier enable bits */
+       /* Don't reset reader reference count */
+}
+EXPORT_SYMBOL_GPL(channel_reset);
+
+/*
+ * Must be called under cpu hotplug protection.
+ */
+int lib_ring_buffer_create(struct lib_ring_buffer *buf,
+                          struct channel_backend *chanb, int cpu)
+{
+       const struct lib_ring_buffer_config *config = &chanb->config;
+       struct channel *chan = container_of(chanb, struct channel, backend);
+       void *priv = chanb->priv;
+       size_t subbuf_header_size;
+       u64 tsc;
+       int ret;
+
+       /* Test for cpu hotplug */
+       if (buf->backend.allocated)
+               return 0;
+
+       /*
+        * Paranoia: per cpu dynamic allocation is not officially documented as
+        * zeroing the memory, so let's do it here too, just in case.
+        */
+       memset(buf, 0, sizeof(*buf));
+
+       ret = lib_ring_buffer_backend_create(&buf->backend, &chan->backend, cpu);
+       if (ret)
+               return ret;
+
+       buf->commit_hot =
+               kzalloc_node(ALIGN(sizeof(*buf->commit_hot)
+                                  * chan->backend.num_subbuf,
+                                  1 << INTERNODE_CACHE_SHIFT),
+                       GFP_KERNEL, cpu_to_node(max(cpu, 0)));
+       if (!buf->commit_hot) {
+               ret = -ENOMEM;
+               goto free_chanbuf;
+       }
+
+       buf->commit_cold =
+               kzalloc_node(ALIGN(sizeof(*buf->commit_cold)
+                                  * chan->backend.num_subbuf,
+                                  1 << INTERNODE_CACHE_SHIFT),
+                       GFP_KERNEL, cpu_to_node(max(cpu, 0)));
+       if (!buf->commit_cold) {
+               ret = -ENOMEM;
+               goto free_commit;
+       }
+
+       init_waitqueue_head(&buf->read_wait);
+       init_waitqueue_head(&buf->write_wait);
+       raw_spin_lock_init(&buf->raw_tick_nohz_spinlock);
+
+       /*
+        * Write the subbuffer header for first subbuffer so we know the total
+        * duration of data gathering.
+        */
+       subbuf_header_size = config->cb.subbuffer_header_size();
+       v_set(config, &buf->offset, subbuf_header_size);
+       subbuffer_id_clear_noref(config, &buf->backend.buf_wsb[0].id);
+       tsc = config->cb.ring_buffer_clock_read(buf->backend.chan);
+       config->cb.buffer_begin(buf, tsc, 0);
+       v_add(config, subbuf_header_size, &buf->commit_hot[0].cc);
+
+       if (config->cb.buffer_create) {
+               ret = config->cb.buffer_create(buf, priv, cpu, chanb->name);
+               if (ret)
+                       goto free_init;
+       }
+
+       /*
+        * Ensure the buffer is ready before setting it to allocated and setting
+        * the cpumask.
+        * Used for cpu hotplug vs cpumask iteration.
+        */
+       smp_wmb();
+       buf->backend.allocated = 1;
+
+       if (config->alloc == RING_BUFFER_ALLOC_PER_CPU) {
+               CHAN_WARN_ON(chan, cpumask_test_cpu(cpu,
+                            chan->backend.cpumask));
+               cpumask_set_cpu(cpu, chan->backend.cpumask);
+       }
+
+       return 0;
+
+       /* Error handling */
+free_init:
+       kfree(buf->commit_cold);
+free_commit:
+       kfree(buf->commit_hot);
+free_chanbuf:
+       lib_ring_buffer_backend_free(&buf->backend);
+       return ret;
+}
+
+static void switch_buffer_timer(unsigned long data)
+{
+       struct lib_ring_buffer *buf = (struct lib_ring_buffer *)data;
+       struct channel *chan = buf->backend.chan;
+       const struct lib_ring_buffer_config *config = &chan->backend.config;
+
+       /*
+        * Only flush buffers periodically if readers are active.
+        */
+       if (atomic_long_read(&buf->active_readers))
+               lib_ring_buffer_switch_slow(buf, SWITCH_ACTIVE);
+
+       if (config->alloc == RING_BUFFER_ALLOC_PER_CPU)
+               mod_timer_pinned(&buf->switch_timer,
+                                jiffies + chan->switch_timer_interval);
+       else
+               mod_timer(&buf->switch_timer,
+                         jiffies + chan->switch_timer_interval);
+}
+
+/*
+ * Called with ring_buffer_nohz_lock held for per-cpu buffers.
+ */
+static void lib_ring_buffer_start_switch_timer(struct lib_ring_buffer *buf)
+{
+       struct channel *chan = buf->backend.chan;
+       const struct lib_ring_buffer_config *config = &chan->backend.config;
+
+       if (!chan->switch_timer_interval || buf->switch_timer_enabled)
+               return;
+       init_timer(&buf->switch_timer);
+       buf->switch_timer.function = switch_buffer_timer;
+       buf->switch_timer.expires = jiffies + chan->switch_timer_interval;
+       buf->switch_timer.data = (unsigned long)buf;
+       if (config->alloc == RING_BUFFER_ALLOC_PER_CPU)
+               add_timer_on(&buf->switch_timer, buf->backend.cpu);
+       else
+               add_timer(&buf->switch_timer);
+       buf->switch_timer_enabled = 1;
+}
+
+/*
+ * Called with ring_buffer_nohz_lock held for per-cpu buffers.
+ */
+static void lib_ring_buffer_stop_switch_timer(struct lib_ring_buffer *buf)
+{
+       struct channel *chan = buf->backend.chan;
+
+       if (!chan->switch_timer_interval || !buf->switch_timer_enabled)
+               return;
+
+       del_timer_sync(&buf->switch_timer);
+       buf->switch_timer_enabled = 0;
+}
+
+/*
+ * Polling timer to check the channels for data.
+ */
+static void read_buffer_timer(unsigned long data)
+{
+       struct lib_ring_buffer *buf = (struct lib_ring_buffer *)data;
+       struct channel *chan = buf->backend.chan;
+       const struct lib_ring_buffer_config *config = &chan->backend.config;
+
+       CHAN_WARN_ON(chan, !buf->backend.allocated);
+
+       if (atomic_long_read(&buf->active_readers)
+           && lib_ring_buffer_poll_deliver(config, buf, chan)) {
+               wake_up_interruptible(&buf->read_wait);
+               wake_up_interruptible(&chan->read_wait);
+       }
+
+       if (config->alloc == RING_BUFFER_ALLOC_PER_CPU)
+               mod_timer_pinned(&buf->read_timer,
+                                jiffies + chan->read_timer_interval);
+       else
+               mod_timer(&buf->read_timer,
+                         jiffies + chan->read_timer_interval);
+}
+
+/*
+ * Called with ring_buffer_nohz_lock held for per-cpu buffers.
+ */
+static void lib_ring_buffer_start_read_timer(struct lib_ring_buffer *buf)
+{
+       struct channel *chan = buf->backend.chan;
+       const struct lib_ring_buffer_config *config = &chan->backend.config;
+
+       if (config->wakeup != RING_BUFFER_WAKEUP_BY_TIMER
+           || !chan->read_timer_interval
+           || buf->read_timer_enabled)
+               return;
+
+       init_timer(&buf->read_timer);
+       buf->read_timer.function = read_buffer_timer;
+       buf->read_timer.expires = jiffies + chan->read_timer_interval;
+       buf->read_timer.data = (unsigned long)buf;
+
+       if (config->alloc == RING_BUFFER_ALLOC_PER_CPU)
+               add_timer_on(&buf->read_timer, buf->backend.cpu);
+       else
+               add_timer(&buf->read_timer);
+       buf->read_timer_enabled = 1;
+}
+
+/*
+ * Called with ring_buffer_nohz_lock held for per-cpu buffers.
+ */
+static void lib_ring_buffer_stop_read_timer(struct lib_ring_buffer *buf)
+{
+       struct channel *chan = buf->backend.chan;
+       const struct lib_ring_buffer_config *config = &chan->backend.config;
+
+       if (config->wakeup != RING_BUFFER_WAKEUP_BY_TIMER
+           || !chan->read_timer_interval
+           || !buf->read_timer_enabled)
+               return;
+
+       del_timer_sync(&buf->read_timer);
+       /*
+        * do one more check to catch data that has been written in the last
+        * timer period.
+        */
+       if (lib_ring_buffer_poll_deliver(config, buf, chan)) {
+               wake_up_interruptible(&buf->read_wait);
+               wake_up_interruptible(&chan->read_wait);
+       }
+       buf->read_timer_enabled = 0;
+}
+
+#ifdef CONFIG_HOTPLUG_CPU
+/**
+ *     lib_ring_buffer_cpu_hp_callback - CPU hotplug callback
+ *     @nb: notifier block
+ *     @action: hotplug action to take
+ *     @hcpu: CPU number
+ *
+ *     Returns the success/failure of the operation. (%NOTIFY_OK, %NOTIFY_BAD)
+ */
+static
+int lib_ring_buffer_cpu_hp_callback(struct notifier_block *nb,
+                                             unsigned long action,
+                                             void *hcpu)
+{
+       unsigned int cpu = (unsigned long)hcpu;
+       struct channel *chan = container_of(nb, struct channel,
+                                           cpu_hp_notifier);
+       struct lib_ring_buffer *buf = per_cpu_ptr(chan->backend.buf, cpu);
+       const struct lib_ring_buffer_config *config = &chan->backend.config;
+
+       if (!chan->cpu_hp_enable)
+               return NOTIFY_DONE;
+
+       CHAN_WARN_ON(chan, config->alloc == RING_BUFFER_ALLOC_GLOBAL);
+
+       switch (action) {
+       case CPU_DOWN_FAILED:
+       case CPU_DOWN_FAILED_FROZEN:
+       case CPU_ONLINE:
+       case CPU_ONLINE_FROZEN:
+               wake_up_interruptible(&chan->hp_wait);
+               lib_ring_buffer_start_switch_timer(buf);
+               lib_ring_buffer_start_read_timer(buf);
+               return NOTIFY_OK;
+
+       case CPU_DOWN_PREPARE:
+       case CPU_DOWN_PREPARE_FROZEN:
+               lib_ring_buffer_stop_switch_timer(buf);
+               lib_ring_buffer_stop_read_timer(buf);
+               return NOTIFY_OK;
+
+       case CPU_DEAD:
+       case CPU_DEAD_FROZEN:
+               /*
+                * Performing a buffer switch on a remote CPU. Performed by
+                * the CPU responsible for doing the hotunplug after the target
+                * CPU stopped running completely. Ensures that all data
+                * from that remote CPU is flushed.
+                */
+               lib_ring_buffer_switch_slow(buf, SWITCH_ACTIVE);
+               return NOTIFY_OK;
+
+       default:
+               return NOTIFY_DONE;
+       }
+}
+#endif
+
+#if defined(CONFIG_NO_HZ) && defined(CONFIG_LIB_RING_BUFFER)
+/*
+ * For per-cpu buffers, call the reader wakeups before switching the buffer, so
+ * that wake-up-tracing generated events are flushed before going idle (in
+ * tick_nohz). We test if the spinlock is locked to deal with the race where
+ * readers try to sample the ring buffer before we perform the switch. We let
+ * the readers retry in that case. If there is data in the buffer, the wake up
+ * is going to forbid the CPU running the reader thread from going idle.
+ */
+static int notrace ring_buffer_tick_nohz_callback(struct notifier_block *nb,
+                                                 unsigned long val,
+                                                 void *data)
+{
+       struct channel *chan = container_of(nb, struct channel,
+                                           tick_nohz_notifier);
+       const struct lib_ring_buffer_config *config = &chan->backend.config;
+       struct lib_ring_buffer *buf;
+       int cpu = smp_processor_id();
+
+       if (config->alloc != RING_BUFFER_ALLOC_PER_CPU) {
+               /*
+                * We don't support keeping the system idle with global buffers
+                * and streaming active. In order to do so, we would need to
+                * sample a non-nohz-cpumask racelessly with the nohz updates
+                * without adding synchronization overhead to nohz. Leave this
+                * use-case out for now.
+                */
+               return 0;
+       }
+
+       buf = channel_get_ring_buffer(config, chan, cpu);
+       switch (val) {
+       case TICK_NOHZ_FLUSH:
+               raw_spin_lock(&buf->raw_tick_nohz_spinlock);
+               if (config->wakeup == RING_BUFFER_WAKEUP_BY_TIMER
+                   && chan->read_timer_interval
+                   && atomic_long_read(&buf->active_readers)
+                   && (lib_ring_buffer_poll_deliver(config, buf, chan)
+                       || lib_ring_buffer_pending_data(config, buf, chan))) {
+                       wake_up_interruptible(&buf->read_wait);
+                       wake_up_interruptible(&chan->read_wait);
+               }
+               if (chan->switch_timer_interval)
+                       lib_ring_buffer_switch_slow(buf, SWITCH_ACTIVE);
+               raw_spin_unlock(&buf->raw_tick_nohz_spinlock);
+               break;
+       case TICK_NOHZ_STOP:
+               spin_lock(&__get_cpu_var(ring_buffer_nohz_lock));
+               lib_ring_buffer_stop_switch_timer(buf);
+               lib_ring_buffer_stop_read_timer(buf);
+               spin_unlock(&__get_cpu_var(ring_buffer_nohz_lock));
+               break;
+       case TICK_NOHZ_RESTART:
+               spin_lock(&__get_cpu_var(ring_buffer_nohz_lock));
+               lib_ring_buffer_start_read_timer(buf);
+               lib_ring_buffer_start_switch_timer(buf);
+               spin_unlock(&__get_cpu_var(ring_buffer_nohz_lock));
+               break;
+       }
+
+       return 0;
+}
+
+void notrace lib_ring_buffer_tick_nohz_flush(void)
+{
+       atomic_notifier_call_chain(&tick_nohz_notifier, TICK_NOHZ_FLUSH,
+                                  NULL);
+}
+
+void notrace lib_ring_buffer_tick_nohz_stop(void)
+{
+       atomic_notifier_call_chain(&tick_nohz_notifier, TICK_NOHZ_STOP,
+                                  NULL);
+}
+
+void notrace lib_ring_buffer_tick_nohz_restart(void)
+{
+       atomic_notifier_call_chain(&tick_nohz_notifier, TICK_NOHZ_RESTART,
+                                  NULL);
+}
+#endif /* defined(CONFIG_NO_HZ) && defined(CONFIG_LIB_RING_BUFFER) */
+
+/*
+ * Holds CPU hotplug.
+ */
+static void channel_unregister_notifiers(struct channel *chan)
+{
+       const struct lib_ring_buffer_config *config = &chan->backend.config;
+       int cpu;
+
+       channel_iterator_unregister_notifiers(chan);
+       if (config->alloc == RING_BUFFER_ALLOC_PER_CPU) {
+#ifdef CONFIG_NO_HZ
+               /*
+                * Remove the nohz notifier first, so we are certain we stop
+                * the timers.
+                */
+               atomic_notifier_chain_unregister(&tick_nohz_notifier,
+                                                &chan->tick_nohz_notifier);
+               /*
+                * ring_buffer_nohz_lock will not be needed below, because
+                * we just removed the notifiers, which were the only source of
+                * concurrency.
+                */
+#endif /* CONFIG_NO_HZ */
+#ifdef CONFIG_HOTPLUG_CPU
+               get_online_cpus();
+               chan->cpu_hp_enable = 0;
+               for_each_online_cpu(cpu) {
+                       struct lib_ring_buffer *buf = per_cpu_ptr(chan->backend.buf,
+                                                             cpu);
+                       lib_ring_buffer_stop_switch_timer(buf);
+                       lib_ring_buffer_stop_read_timer(buf);
+               }
+               put_online_cpus();
+               unregister_cpu_notifier(&chan->cpu_hp_notifier);
+#else
+               for_each_possible_cpu(cpu) {
+                       struct lib_ring_buffer *buf = per_cpu_ptr(chan->backend.buf,
+                                                             cpu);
+                       lib_ring_buffer_stop_switch_timer(buf);
+                       lib_ring_buffer_stop_read_timer(buf);
+               }
+#endif
+       } else {
+               struct lib_ring_buffer *buf = chan->backend.buf;
+
+               lib_ring_buffer_stop_switch_timer(buf);
+               lib_ring_buffer_stop_read_timer(buf);
+       }
+       channel_backend_unregister_notifiers(&chan->backend);
+}
+
+static void channel_free(struct channel *chan)
+{
+       channel_iterator_free(chan);
+       channel_backend_free(&chan->backend);
+       kfree(chan);
+}
+
+/**
+ * channel_create - Create channel.
+ * @config: ring buffer instance configuration
+ * @name: name of the channel
+ * @priv: ring buffer client private data
+ * @buf_addr: pointer the the beginning of the preallocated buffer contiguous
+ *            address mapping. It is used only by RING_BUFFER_STATIC
+ *            configuration. It can be set to NULL for other backends.
+ * @subbuf_size: subbuffer size
+ * @num_subbuf: number of subbuffers
+ * @switch_timer_interval: Time interval (in us) to fill sub-buffers with
+ *                         padding to let readers get those sub-buffers.
+ *                         Used for live streaming.
+ * @read_timer_interval: Time interval (in us) to wake up pending readers.
+ *
+ * Holds cpu hotplug.
+ * Returns NULL on failure.
+ */
+struct channel *channel_create(const struct lib_ring_buffer_config *config,
+                  const char *name, void *priv, void *buf_addr,
+                  size_t subbuf_size,
+                  size_t num_subbuf, unsigned int switch_timer_interval,
+                  unsigned int read_timer_interval)
+{
+       int ret, cpu;
+       struct channel *chan;
+
+       if (lib_ring_buffer_check_config(config, switch_timer_interval,
+                                        read_timer_interval))
+               return NULL;
+
+       chan = kzalloc(sizeof(struct channel), GFP_KERNEL);
+       if (!chan)
+               return NULL;
+
+       ret = channel_backend_init(&chan->backend, name, config, priv,
+                                  subbuf_size, num_subbuf);
+       if (ret)
+               goto error;
+
+       ret = channel_iterator_init(chan);
+       if (ret)
+               goto error_free_backend;
+
+       chan->commit_count_mask = (~0UL >> chan->backend.num_subbuf_order);
+       chan->switch_timer_interval = usecs_to_jiffies(switch_timer_interval);
+       chan->read_timer_interval = usecs_to_jiffies(read_timer_interval);
+       kref_init(&chan->ref);
+       init_waitqueue_head(&chan->read_wait);
+       init_waitqueue_head(&chan->hp_wait);
+
+       if (config->alloc == RING_BUFFER_ALLOC_PER_CPU) {
+#if defined(CONFIG_NO_HZ) && defined(CONFIG_LIB_RING_BUFFER)
+               /* Only benefit from NO_HZ idle with per-cpu buffers for now. */
+               chan->tick_nohz_notifier.notifier_call =
+                       ring_buffer_tick_nohz_callback;
+               chan->tick_nohz_notifier.priority = ~0U;
+               atomic_notifier_chain_register(&tick_nohz_notifier,
+                                      &chan->tick_nohz_notifier);
+#endif /* defined(CONFIG_NO_HZ) && defined(CONFIG_LIB_RING_BUFFER) */
+
+               /*
+                * In case of non-hotplug cpu, if the ring-buffer is allocated
+                * in early initcall, it will not be notified of secondary cpus.
+                * In that off case, we need to allocate for all possible cpus.
+                */
+#ifdef CONFIG_HOTPLUG_CPU
+               chan->cpu_hp_notifier.notifier_call =
+                               lib_ring_buffer_cpu_hp_callback;
+               chan->cpu_hp_notifier.priority = 6;
+               register_cpu_notifier(&chan->cpu_hp_notifier);
+
+               get_online_cpus();
+               for_each_online_cpu(cpu) {
+                       struct lib_ring_buffer *buf = per_cpu_ptr(chan->backend.buf,
+                                                              cpu);
+                       spin_lock(&per_cpu(ring_buffer_nohz_lock, cpu));
+                       lib_ring_buffer_start_switch_timer(buf);
+                       lib_ring_buffer_start_read_timer(buf);
+                       spin_unlock(&per_cpu(ring_buffer_nohz_lock, cpu));
+               }
+               chan->cpu_hp_enable = 1;
+               put_online_cpus();
+#else
+               for_each_possible_cpu(cpu) {
+                       struct lib_ring_buffer *buf = per_cpu_ptr(chan->backend.buf,
+                                                             cpu);
+                       spin_lock(&per_cpu(ring_buffer_nohz_lock, cpu));
+                       lib_ring_buffer_start_switch_timer(buf);
+                       lib_ring_buffer_start_read_timer(buf);
+                       spin_unlock(&per_cpu(ring_buffer_nohz_lock, cpu));
+               }
+#endif
+       } else {
+               struct lib_ring_buffer *buf = chan->backend.buf;
+
+               lib_ring_buffer_start_switch_timer(buf);
+               lib_ring_buffer_start_read_timer(buf);
+       }
+
+       return chan;
+
+error_free_backend:
+       channel_backend_free(&chan->backend);
+error:
+       kfree(chan);
+       return NULL;
+}
+EXPORT_SYMBOL_GPL(channel_create);
+
+static
+void channel_release(struct kref *kref)
+{
+       struct channel *chan = container_of(kref, struct channel, ref);
+       channel_free(chan);
+}
+
+/**
+ * channel_destroy - Finalize, wait for q.s. and destroy channel.
+ * @chan: channel to destroy
+ *
+ * Holds cpu hotplug.
+ * Call "destroy" callback, finalize channels, and then decrement the
+ * channel reference count.  Note that when readers have completed data
+ * consumption of finalized channels, get_subbuf() will return -ENODATA.
+ * They should release their handle at that point.  Returns the private
+ * data pointer.
+ */
+void *channel_destroy(struct channel *chan)
+{
+       int cpu;
+       const struct lib_ring_buffer_config *config = &chan->backend.config;
+       void *priv;
+
+       channel_unregister_notifiers(chan);
+
+       if (config->alloc == RING_BUFFER_ALLOC_PER_CPU) {
+               /*
+                * No need to hold cpu hotplug, because all notifiers have been
+                * unregistered.
+                */
+               for_each_channel_cpu(cpu, chan) {
+                       struct lib_ring_buffer *buf = per_cpu_ptr(chan->backend.buf,
+                                                             cpu);
+
+                       if (config->cb.buffer_finalize)
+                               config->cb.buffer_finalize(buf,
+                                                          chan->backend.priv,
+                                                          cpu);
+                       if (buf->backend.allocated)
+                               lib_ring_buffer_switch_slow(buf, SWITCH_FLUSH);
+                       /*
+                        * Perform flush before writing to finalized.
+                        */
+                       smp_wmb();
+                       ACCESS_ONCE(buf->finalized) = 1;
+                       wake_up_interruptible(&buf->read_wait);
+               }
+       } else {
+               struct lib_ring_buffer *buf = chan->backend.buf;
+
+               if (config->cb.buffer_finalize)
+                       config->cb.buffer_finalize(buf, chan->backend.priv, -1);
+               if (buf->backend.allocated)
+                       lib_ring_buffer_switch_slow(buf, SWITCH_FLUSH);
+               /*
+                * Perform flush before writing to finalized.
+                */
+               smp_wmb();
+               ACCESS_ONCE(buf->finalized) = 1;
+               wake_up_interruptible(&buf->read_wait);
+       }
+       ACCESS_ONCE(chan->finalized) = 1;
+       wake_up_interruptible(&chan->hp_wait);
+       wake_up_interruptible(&chan->read_wait);
+       priv = chan->backend.priv;
+       kref_put(&chan->ref, channel_release);
+       return priv;
+}
+EXPORT_SYMBOL_GPL(channel_destroy);
+
+struct lib_ring_buffer *channel_get_ring_buffer(
+                                       const struct lib_ring_buffer_config *config,
+                                       struct channel *chan, int cpu)
+{
+       if (config->alloc == RING_BUFFER_ALLOC_GLOBAL)
+               return chan->backend.buf;
+       else
+               return per_cpu_ptr(chan->backend.buf, cpu);
+}
+EXPORT_SYMBOL_GPL(channel_get_ring_buffer);
+
+int lib_ring_buffer_open_read(struct lib_ring_buffer *buf)
+{
+       struct channel *chan = buf->backend.chan;
+
+       if (!atomic_long_add_unless(&buf->active_readers, 1, 1))
+               return -EBUSY;
+       kref_get(&chan->ref);
+       smp_mb__after_atomic_inc();
+       return 0;
+}
+EXPORT_SYMBOL_GPL(lib_ring_buffer_open_read);
+
+void lib_ring_buffer_release_read(struct lib_ring_buffer *buf)
+{
+       struct channel *chan = buf->backend.chan;
+
+       CHAN_WARN_ON(chan, atomic_long_read(&buf->active_readers) != 1);
+       smp_mb__before_atomic_dec();
+       atomic_long_dec(&buf->active_readers);
+       kref_put(&chan->ref, channel_release);
+}
+EXPORT_SYMBOL_GPL(lib_ring_buffer_release_read);
+
+/*
+ * Promote compiler barrier to a smp_mb().
+ * For the specific ring buffer case, this IPI call should be removed if the
+ * architecture does not reorder writes.  This should eventually be provided by
+ * a separate architecture-specific infrastructure.
+ */
+static void remote_mb(void *info)
+{
+       smp_mb();
+}
+
+/**
+ * lib_ring_buffer_snapshot - save subbuffer position snapshot (for read)
+ * @buf: ring buffer
+ * @consumed: consumed count indicating the position where to read
+ * @produced: produced count, indicates position when to stop reading
+ *
+ * Returns -ENODATA if buffer is finalized, -EAGAIN if there is currently no
+ * data to read at consumed position, or 0 if the get operation succeeds.
+ * Busy-loop trying to get data if the tick_nohz sequence lock is held.
+ */
+
+int lib_ring_buffer_snapshot(struct lib_ring_buffer *buf,
+                            unsigned long *consumed, unsigned long *produced)
+{
+       struct channel *chan = buf->backend.chan;
+       const struct lib_ring_buffer_config *config = &chan->backend.config;
+       unsigned long consumed_cur, write_offset;
+       int finalized;
+
+retry:
+       finalized = ACCESS_ONCE(buf->finalized);
+       /*
+        * Read finalized before counters.
+        */
+       smp_rmb();
+       consumed_cur = atomic_long_read(&buf->consumed);
+       /*
+        * No need to issue a memory barrier between consumed count read and
+        * write offset read, because consumed count can only change
+        * concurrently in overwrite mode, and we keep a sequence counter
+        * identifier derived from the write offset to check we are getting
+        * the same sub-buffer we are expecting (the sub-buffers are atomically
+        * "tagged" upon writes, tags are checked upon read).
+        */
+       write_offset = v_read(config, &buf->offset);
+
+       /*
+        * Check that we are not about to read the same subbuffer in
+        * which the writer head is.
+        */
+       if (subbuf_trunc(write_offset, chan) - subbuf_trunc(consumed_cur, chan)
+           == 0)
+               goto nodata;
+
+       *consumed = consumed_cur;
+       *produced = subbuf_trunc(write_offset, chan);
+
+       return 0;
+
+nodata:
+       /*
+        * The memory barriers __wait_event()/wake_up_interruptible() take care
+        * of "raw_spin_is_locked" memory ordering.
+        */
+       if (finalized)
+               return -ENODATA;
+       else if (raw_spin_is_locked(&buf->raw_tick_nohz_spinlock))
+               goto retry;
+       else
+               return -EAGAIN;
+}
+EXPORT_SYMBOL_GPL(lib_ring_buffer_snapshot);
+
+/**
+ * lib_ring_buffer_put_snapshot - move consumed counter forward
+ *
+ * Should only be called from consumer context.
+ * @buf: ring buffer
+ * @consumed_new: new consumed count value
+ */
+void lib_ring_buffer_move_consumer(struct lib_ring_buffer *buf,
+                                  unsigned long consumed_new)
+{
+       struct lib_ring_buffer_backend *bufb = &buf->backend;
+       struct channel *chan = bufb->chan;
+       unsigned long consumed;
+
+       CHAN_WARN_ON(chan, atomic_long_read(&buf->active_readers) != 1);
+
+       /*
+        * Only push the consumed value forward.
+        * If the consumed cmpxchg fails, this is because we have been pushed by
+        * the writer in flight recorder mode.
+        */
+       consumed = atomic_long_read(&buf->consumed);
+       while ((long) consumed - (long) consumed_new < 0)
+               consumed = atomic_long_cmpxchg(&buf->consumed, consumed,
+                                              consumed_new);
+       /* Wake-up the metadata producer */
+       wake_up_interruptible(&buf->write_wait);
+}
+EXPORT_SYMBOL_GPL(lib_ring_buffer_move_consumer);
+
+/**
+ * lib_ring_buffer_get_subbuf - get exclusive access to subbuffer for reading
+ * @buf: ring buffer
+ * @consumed: consumed count indicating the position where to read
+ *
+ * Returns -ENODATA if buffer is finalized, -EAGAIN if there is currently no
+ * data to read at consumed position, or 0 if the get operation succeeds.
+ * Busy-loop trying to get data if the tick_nohz sequence lock is held.
+ */
+int lib_ring_buffer_get_subbuf(struct lib_ring_buffer *buf,
+                              unsigned long consumed)
+{
+       struct channel *chan = buf->backend.chan;
+       const struct lib_ring_buffer_config *config = &chan->backend.config;
+       unsigned long consumed_cur, consumed_idx, commit_count, write_offset;
+       int ret;
+       int finalized;
+
+       if (buf->get_subbuf) {
+               /*
+                * Reader is trying to get a subbuffer twice.
+                */
+               CHAN_WARN_ON(chan, 1);
+               return -EBUSY;
+       }
+retry:
+       finalized = ACCESS_ONCE(buf->finalized);
+       /*
+        * Read finalized before counters.
+        */
+       smp_rmb();
+       consumed_cur = atomic_long_read(&buf->consumed);
+       consumed_idx = subbuf_index(consumed, chan);
+       commit_count = v_read(config, &buf->commit_cold[consumed_idx].cc_sb);
+       /*
+        * Make sure we read the commit count before reading the buffer
+        * data and the write offset. Correct consumed offset ordering
+        * wrt commit count is insured by the use of cmpxchg to update
+        * the consumed offset.
+        * smp_call_function_single can fail if the remote CPU is offline,
+        * this is OK because then there is no wmb to execute there.
+        * If our thread is executing on the same CPU as the on the buffers
+        * belongs to, we don't have to synchronize it at all. If we are
+        * migrated, the scheduler will take care of the memory barriers.
+        * Normally, smp_call_function_single() should ensure program order when
+        * executing the remote function, which implies that it surrounds the
+        * function execution with :
+        * smp_mb()
+        * send IPI
+        * csd_lock_wait
+        *                recv IPI
+        *                smp_mb()
+        *                exec. function
+        *                smp_mb()
+        *                csd unlock
+        * smp_mb()
+        *
+        * However, smp_call_function_single() does not seem to clearly execute
+        * such barriers. It depends on spinlock semantic to provide the barrier
+        * before executing the IPI and, when busy-looping, csd_lock_wait only
+        * executes smp_mb() when it has to wait for the other CPU.
+        *
+        * I don't trust this code. Therefore, let's add the smp_mb() sequence
+        * required ourself, even if duplicated. It has no performance impact
+        * anyway.
+        *
+        * smp_mb() is needed because smp_rmb() and smp_wmb() only order read vs
+        * read and write vs write. They do not ensure core synchronization. We
+        * really have to ensure total order between the 3 barriers running on
+        * the 2 CPUs.
+        */
+       if (config->ipi == RING_BUFFER_IPI_BARRIER) {
+               if (config->sync == RING_BUFFER_SYNC_PER_CPU
+                   && config->alloc == RING_BUFFER_ALLOC_PER_CPU) {
+                       if (raw_smp_processor_id() != buf->backend.cpu) {
+                               /* Total order with IPI handler smp_mb() */
+                               smp_mb();
+                               smp_call_function_single(buf->backend.cpu,
+                                                        remote_mb, NULL, 1);
+                               /* Total order with IPI handler smp_mb() */
+                               smp_mb();
+                       }
+               } else {
+                       /* Total order with IPI handler smp_mb() */
+                       smp_mb();
+                       smp_call_function(remote_mb, NULL, 1);
+                       /* Total order with IPI handler smp_mb() */
+                       smp_mb();
+               }
+       } else {
+               /*
+                * Local rmb to match the remote wmb to read the commit count
+                * before the buffer data and the write offset.
+                */
+               smp_rmb();
+       }
+
+       write_offset = v_read(config, &buf->offset);
+
+       /*
+        * Check that the buffer we are getting is after or at consumed_cur
+        * position.
+        */
+       if ((long) subbuf_trunc(consumed, chan)
+           - (long) subbuf_trunc(consumed_cur, chan) < 0)
+               goto nodata;
+
+       /*
+        * Check that the subbuffer we are trying to consume has been
+        * already fully committed.
+        */
+       if (((commit_count - chan->backend.subbuf_size)
+            & chan->commit_count_mask)
+           - (buf_trunc(consumed, chan)
+              >> chan->backend.num_subbuf_order)
+           != 0)
+               goto nodata;
+
+       /*
+        * Check that we are not about to read the same subbuffer in
+        * which the writer head is.
+        */
+       if (subbuf_trunc(write_offset, chan) - subbuf_trunc(consumed, chan)
+           == 0)
+               goto nodata;
+
+       /*
+        * Failure to get the subbuffer causes a busy-loop retry without going
+        * to a wait queue. These are caused by short-lived race windows where
+        * the writer is getting access to a subbuffer we were trying to get
+        * access to. Also checks that the "consumed" buffer count we are
+        * looking for matches the one contained in the subbuffer id.
+        */
+       ret = update_read_sb_index(config, &buf->backend, &chan->backend,
+                                  consumed_idx, buf_trunc_val(consumed, chan));
+       if (ret)
+               goto retry;
+       subbuffer_id_clear_noref(config, &buf->backend.buf_rsb.id);
+
+       buf->get_subbuf_consumed = consumed;
+       buf->get_subbuf = 1;
+
+       return 0;
+
+nodata:
+       /*
+        * The memory barriers __wait_event()/wake_up_interruptible() take care
+        * of "raw_spin_is_locked" memory ordering.
+        */
+       if (finalized)
+               return -ENODATA;
+       else if (raw_spin_is_locked(&buf->raw_tick_nohz_spinlock))
+               goto retry;
+       else
+               return -EAGAIN;
+}
+EXPORT_SYMBOL_GPL(lib_ring_buffer_get_subbuf);
+
+/**
+ * lib_ring_buffer_put_subbuf - release exclusive subbuffer access
+ * @buf: ring buffer
+ */
+void lib_ring_buffer_put_subbuf(struct lib_ring_buffer *buf)
+{
+       struct lib_ring_buffer_backend *bufb = &buf->backend;
+       struct channel *chan = bufb->chan;
+       const struct lib_ring_buffer_config *config = &chan->backend.config;
+       unsigned long read_sb_bindex, consumed_idx, consumed;
+
+       CHAN_WARN_ON(chan, atomic_long_read(&buf->active_readers) != 1);
+
+       if (!buf->get_subbuf) {
+               /*
+                * Reader puts a subbuffer it did not get.
+                */
+               CHAN_WARN_ON(chan, 1);
+               return;
+       }
+       consumed = buf->get_subbuf_consumed;
+       buf->get_subbuf = 0;
+
+       /*
+        * Clear the records_unread counter. (overruns counter)
+        * Can still be non-zero if a file reader simply grabbed the data
+        * without using iterators.
+        * Can be below zero if an iterator is used on a snapshot more than
+        * once.
+        */
+       read_sb_bindex = subbuffer_id_get_index(config, bufb->buf_rsb.id);
+       v_add(config, v_read(config,
+                            &bufb->array[read_sb_bindex]->records_unread),
+             &bufb->records_read);
+       v_set(config, &bufb->array[read_sb_bindex]->records_unread, 0);
+       CHAN_WARN_ON(chan, config->mode == RING_BUFFER_OVERWRITE
+                    && subbuffer_id_is_noref(config, bufb->buf_rsb.id));
+       subbuffer_id_set_noref(config, &bufb->buf_rsb.id);
+
+       /*
+        * Exchange the reader subbuffer with the one we put in its place in the
+        * writer subbuffer table. Expect the original consumed count. If
+        * update_read_sb_index fails, this is because the writer updated the
+        * subbuffer concurrently. We should therefore keep the subbuffer we
+        * currently have: it has become invalid to try reading this sub-buffer
+        * consumed count value anyway.
+        */
+       consumed_idx = subbuf_index(consumed, chan);
+       update_read_sb_index(config, &buf->backend, &chan->backend,
+                            consumed_idx, buf_trunc_val(consumed, chan));
+       /*
+        * update_read_sb_index return value ignored. Don't exchange sub-buffer
+        * if the writer concurrently updated it.
+        */
+}
+EXPORT_SYMBOL_GPL(lib_ring_buffer_put_subbuf);
+
+/*
+ * cons_offset is an iterator on all subbuffer offsets between the reader
+ * position and the writer position. (inclusive)
+ */
+static
+void lib_ring_buffer_print_subbuffer_errors(struct lib_ring_buffer *buf,
+                                           struct channel *chan,
+                                           unsigned long cons_offset,
+                                           int cpu)
+{
+       const struct lib_ring_buffer_config *config = &chan->backend.config;
+       unsigned long cons_idx, commit_count, commit_count_sb;
+
+       cons_idx = subbuf_index(cons_offset, chan);
+       commit_count = v_read(config, &buf->commit_hot[cons_idx].cc);
+       commit_count_sb = v_read(config, &buf->commit_cold[cons_idx].cc_sb);
+
+       if (subbuf_offset(commit_count, chan) != 0)
+               printk(KERN_WARNING
+                      "ring buffer %s, cpu %d: "
+                      "commit count in subbuffer %lu,\n"
+                      "expecting multiples of %lu bytes\n"
+                      "  [ %lu bytes committed, %lu bytes reader-visible ]\n",
+                      chan->backend.name, cpu, cons_idx,
+                      chan->backend.subbuf_size,
+                      commit_count, commit_count_sb);
+
+       printk(KERN_DEBUG "ring buffer: %s, cpu %d: %lu bytes committed\n",
+              chan->backend.name, cpu, commit_count);
+}
+
+static
+void lib_ring_buffer_print_buffer_errors(struct lib_ring_buffer *buf,
+                                        struct channel *chan,
+                                        void *priv, int cpu)
+{
+       const struct lib_ring_buffer_config *config = &chan->backend.config;
+       unsigned long write_offset, cons_offset;
+
+       /*
+        * No need to order commit_count, write_offset and cons_offset reads
+        * because we execute at teardown when no more writer nor reader
+        * references are left.
+        */
+       write_offset = v_read(config, &buf->offset);
+       cons_offset = atomic_long_read(&buf->consumed);
+       if (write_offset != cons_offset)
+               printk(KERN_DEBUG
+                      "ring buffer %s, cpu %d: "
+                      "non-consumed data\n"
+                      "  [ %lu bytes written, %lu bytes read ]\n",
+                      chan->backend.name, cpu, write_offset, cons_offset);
+
+       for (cons_offset = atomic_long_read(&buf->consumed);
+            (long) (subbuf_trunc((unsigned long) v_read(config, &buf->offset),
+                                 chan)
+                    - cons_offset) > 0;
+            cons_offset = subbuf_align(cons_offset, chan))
+               lib_ring_buffer_print_subbuffer_errors(buf, chan, cons_offset,
+                                                      cpu);
+}
+
+static
+void lib_ring_buffer_print_errors(struct channel *chan,
+                                 struct lib_ring_buffer *buf, int cpu)
+{
+       const struct lib_ring_buffer_config *config = &chan->backend.config;
+       void *priv = chan->backend.priv;
+
+       if (!strcmp(chan->backend.name, "relay-metadata")) {
+               printk(KERN_DEBUG "ring buffer %s: %lu records written, "
+                       "%lu records overrun\n",
+                       chan->backend.name,
+                       v_read(config, &buf->records_count),
+                       v_read(config, &buf->records_overrun));
+       } else {
+               printk(KERN_DEBUG "ring buffer %s, cpu %d: %lu records written, "
+                       "%lu records overrun\n",
+                       chan->backend.name, cpu,
+                       v_read(config, &buf->records_count),
+                       v_read(config, &buf->records_overrun));
+
+               if (v_read(config, &buf->records_lost_full)
+                   || v_read(config, &buf->records_lost_wrap)
+                   || v_read(config, &buf->records_lost_big))
+                       printk(KERN_WARNING
+                               "ring buffer %s, cpu %d: records were lost. Caused by:\n"
+                               "  [ %lu buffer full, %lu nest buffer wrap-around, "
+                               "%lu event too big ]\n",
+                               chan->backend.name, cpu,
+                               v_read(config, &buf->records_lost_full),
+                               v_read(config, &buf->records_lost_wrap),
+                               v_read(config, &buf->records_lost_big));
+       }
+       lib_ring_buffer_print_buffer_errors(buf, chan, priv, cpu);
+}
+
+/*
+ * lib_ring_buffer_switch_old_start: Populate old subbuffer header.
+ *
+ * Only executed when the buffer is finalized, in SWITCH_FLUSH.
+ */
+static
+void lib_ring_buffer_switch_old_start(struct lib_ring_buffer *buf,
+                                     struct channel *chan,
+                                     struct switch_offsets *offsets,
+                                     u64 tsc)
+{
+       const struct lib_ring_buffer_config *config = &chan->backend.config;
+       unsigned long oldidx = subbuf_index(offsets->old, chan);
+       unsigned long commit_count;
+
+       config->cb.buffer_begin(buf, tsc, oldidx);
+
+       /*
+        * Order all writes to buffer before the commit count update that will
+        * determine that the subbuffer is full.
+        */
+       if (config->ipi == RING_BUFFER_IPI_BARRIER) {
+               /*
+                * Must write slot data before incrementing commit count.  This
+                * compiler barrier is upgraded into a smp_mb() by the IPI sent
+                * by get_subbuf().
+                */
+               barrier();
+       } else
+               smp_wmb();
+       v_add(config, config->cb.subbuffer_header_size(),
+             &buf->commit_hot[oldidx].cc);
+       commit_count = v_read(config, &buf->commit_hot[oldidx].cc);
+       /* Check if the written buffer has to be delivered */
+       lib_ring_buffer_check_deliver(config, buf, chan, offsets->old,
+                                     commit_count, oldidx, tsc);
+       lib_ring_buffer_write_commit_counter(config, buf, chan, oldidx,
+                                            offsets->old, commit_count,
+                                            config->cb.subbuffer_header_size());
+}
+
+/*
+ * lib_ring_buffer_switch_old_end: switch old subbuffer
+ *
+ * Note : offset_old should never be 0 here. It is ok, because we never perform
+ * buffer switch on an empty subbuffer in SWITCH_ACTIVE mode. The caller
+ * increments the offset_old value when doing a SWITCH_FLUSH on an empty
+ * subbuffer.
+ */
+static
+void lib_ring_buffer_switch_old_end(struct lib_ring_buffer *buf,
+                                   struct channel *chan,
+                                   struct switch_offsets *offsets,
+                                   u64 tsc)
+{
+       const struct lib_ring_buffer_config *config = &chan->backend.config;
+       unsigned long oldidx = subbuf_index(offsets->old - 1, chan);
+       unsigned long commit_count, padding_size, data_size;
+
+       data_size = subbuf_offset(offsets->old - 1, chan) + 1;
+       padding_size = chan->backend.subbuf_size - data_size;
+       subbuffer_set_data_size(config, &buf->backend, oldidx, data_size);
+
+       /*
+        * Order all writes to buffer before the commit count update that will
+        * determine that the subbuffer is full.
+        */
+       if (config->ipi == RING_BUFFER_IPI_BARRIER) {
+               /*
+                * Must write slot data before incrementing commit count.  This
+                * compiler barrier is upgraded into a smp_mb() by the IPI sent
+                * by get_subbuf().
+                */
+               barrier();
+       } else
+               smp_wmb();
+       v_add(config, padding_size, &buf->commit_hot[oldidx].cc);
+       commit_count = v_read(config, &buf->commit_hot[oldidx].cc);
+       lib_ring_buffer_check_deliver(config, buf, chan, offsets->old - 1,
+                                     commit_count, oldidx, tsc);
+       lib_ring_buffer_write_commit_counter(config, buf, chan, oldidx,
+                                            offsets->old, commit_count,
+                                            padding_size);
+}
+
+/*
+ * lib_ring_buffer_switch_new_start: Populate new subbuffer.
+ *
+ * This code can be executed unordered : writers may already have written to the
+ * sub-buffer before this code gets executed, caution.  The commit makes sure
+ * that this code is executed before the deliver of this sub-buffer.
+ */
+static
+void lib_ring_buffer_switch_new_start(struct lib_ring_buffer *buf,
+                                     struct channel *chan,
+                                     struct switch_offsets *offsets,
+                                     u64 tsc)
+{
+       const struct lib_ring_buffer_config *config = &chan->backend.config;
+       unsigned long beginidx = subbuf_index(offsets->begin, chan);
+       unsigned long commit_count;
+
+       config->cb.buffer_begin(buf, tsc, beginidx);
+
+       /*
+        * Order all writes to buffer before the commit count update that will
+        * determine that the subbuffer is full.
+        */
+       if (config->ipi == RING_BUFFER_IPI_BARRIER) {
+               /*
+                * Must write slot data before incrementing commit count.  This
+                * compiler barrier is upgraded into a smp_mb() by the IPI sent
+                * by get_subbuf().
+                */
+               barrier();
+       } else
+               smp_wmb();
+       v_add(config, config->cb.subbuffer_header_size(),
+             &buf->commit_hot[beginidx].cc);
+       commit_count = v_read(config, &buf->commit_hot[beginidx].cc);
+       /* Check if the written buffer has to be delivered */
+       lib_ring_buffer_check_deliver(config, buf, chan, offsets->begin,
+                                     commit_count, beginidx, tsc);
+       lib_ring_buffer_write_commit_counter(config, buf, chan, beginidx,
+                                            offsets->begin, commit_count,
+                                            config->cb.subbuffer_header_size());
+}
+
+/*
+ * lib_ring_buffer_switch_new_end: finish switching current subbuffer
+ *
+ * Calls subbuffer_set_data_size() to set the data size of the current
+ * sub-buffer. We do not need to perform check_deliver nor commit here,
+ * since this task will be done by the "commit" of the event for which
+ * we are currently doing the space reservation.
+ */
+static
+void lib_ring_buffer_switch_new_end(struct lib_ring_buffer *buf,
+                                           struct channel *chan,
+                                           struct switch_offsets *offsets,
+                                           u64 tsc)
+{
+       const struct lib_ring_buffer_config *config = &chan->backend.config;
+       unsigned long endidx, data_size;
+
+       endidx = subbuf_index(offsets->end - 1, chan);
+       data_size = subbuf_offset(offsets->end - 1, chan) + 1;
+       subbuffer_set_data_size(config, &buf->backend, endidx, data_size);
+}
+
+/*
+ * Returns :
+ * 0 if ok
+ * !0 if execution must be aborted.
+ */
+static
+int lib_ring_buffer_try_switch_slow(enum switch_mode mode,
+                                   struct lib_ring_buffer *buf,
+                                   struct channel *chan,
+                                   struct switch_offsets *offsets,
+                                   u64 *tsc)
+{
+       const struct lib_ring_buffer_config *config = &chan->backend.config;
+       unsigned long off, reserve_commit_diff;
+
+       offsets->begin = v_read(config, &buf->offset);
+       offsets->old = offsets->begin;
+       offsets->switch_old_start = 0;
+       off = subbuf_offset(offsets->begin, chan);
+
+       *tsc = config->cb.ring_buffer_clock_read(chan);
+
+       /*
+        * Ensure we flush the header of an empty subbuffer when doing the
+        * finalize (SWITCH_FLUSH). This ensures that we end up knowing the
+        * total data gathering duration even if there were no records saved
+        * after the last buffer switch.
+        * In SWITCH_ACTIVE mode, switch the buffer when it contains events.
+        * SWITCH_ACTIVE only flushes the current subbuffer, dealing with end of
+        * subbuffer header as appropriate.
+        * The next record that reserves space will be responsible for
+        * populating the following subbuffer header. We choose not to populate
+        * the next subbuffer header here because we want to be able to use
+        * SWITCH_ACTIVE for periodical buffer flush and CPU tick_nohz stop
+        * buffer flush, which must guarantee that all the buffer content
+        * (records and header timestamps) are visible to the reader. This is
+        * required for quiescence guarantees for the fusion merge.
+        */
+       if (mode != SWITCH_FLUSH && !off)
+               return -1;      /* we do not have to switch : buffer is empty */
+
+       if (unlikely(off == 0)) {
+               unsigned long sb_index, commit_count;
+
+               /*
+                * We are performing a SWITCH_FLUSH. At this stage, there are no
+                * concurrent writes into the buffer.
+                *
+                * The client does not save any header information.  Don't
+                * switch empty subbuffer on finalize, because it is invalid to
+                * deliver a completely empty subbuffer.
+                */
+               if (!config->cb.subbuffer_header_size())
+                       return -1;
+
+               /* Test new buffer integrity */
+               sb_index = subbuf_index(offsets->begin, chan);
+               commit_count = v_read(config,
+                               &buf->commit_cold[sb_index].cc_sb);
+               reserve_commit_diff =
+                 (buf_trunc(offsets->begin, chan)
+                  >> chan->backend.num_subbuf_order)
+                 - (commit_count & chan->commit_count_mask);
+               if (likely(reserve_commit_diff == 0)) {
+                       /* Next subbuffer not being written to. */
+                       if (unlikely(config->mode != RING_BUFFER_OVERWRITE &&
+                               subbuf_trunc(offsets->begin, chan)
+                                - subbuf_trunc((unsigned long)
+                                    atomic_long_read(&buf->consumed), chan)
+                               >= chan->backend.buf_size)) {
+                               /*
+                                * We do not overwrite non consumed buffers
+                                * and we are full : don't switch.
+                                */
+                               return -1;
+                       } else {
+                               /*
+                                * Next subbuffer not being written to, and we
+                                * are either in overwrite mode or the buffer is
+                                * not full. It's safe to write in this new
+                                * subbuffer.
+                                */
+                       }
+               } else {
+                       /*
+                        * Next subbuffer reserve offset does not match the
+                        * commit offset. Don't perform switch in
+                        * producer-consumer and overwrite mode.  Caused by
+                        * either a writer OOPS or too many nested writes over a
+                        * reserve/commit pair.
+                        */
+                       return -1;
+               }
+
+               /*
+                * Need to write the subbuffer start header on finalize.
+                */
+               offsets->switch_old_start = 1;
+       }
+       offsets->begin = subbuf_align(offsets->begin, chan);
+       /* Note: old points to the next subbuf at offset 0 */
+       offsets->end = offsets->begin;
+       return 0;
+}
+
+/*
+ * Force a sub-buffer switch. This operation is completely reentrant : can be
+ * called while tracing is active with absolutely no lock held.
+ *
+ * Note, however, that as a v_cmpxchg is used for some atomic
+ * operations, this function must be called from the CPU which owns the buffer
+ * for a ACTIVE flush.
+ */
+void lib_ring_buffer_switch_slow(struct lib_ring_buffer *buf, enum switch_mode mode)
+{
+       struct channel *chan = buf->backend.chan;
+       const struct lib_ring_buffer_config *config = &chan->backend.config;
+       struct switch_offsets offsets;
+       unsigned long oldidx;
+       u64 tsc;
+
+       offsets.size = 0;
+
+       /*
+        * Perform retryable operations.
+        */
+       do {
+               if (lib_ring_buffer_try_switch_slow(mode, buf, chan, &offsets,
+                                                   &tsc))
+                       return; /* Switch not needed */
+       } while (v_cmpxchg(config, &buf->offset, offsets.old, offsets.end)
+                != offsets.old);
+
+       /*
+        * Atomically update last_tsc. This update races against concurrent
+        * atomic updates, but the race will always cause supplementary full TSC
+        * records, never the opposite (missing a full TSC record when it would
+        * be needed).
+        */
+       save_last_tsc(config, buf, tsc);
+
+       /*
+        * Push the reader if necessary
+        */
+       lib_ring_buffer_reserve_push_reader(buf, chan, offsets.old);
+
+       oldidx = subbuf_index(offsets.old, chan);
+       lib_ring_buffer_clear_noref(config, &buf->backend, oldidx);
+
+       /*
+        * May need to populate header start on SWITCH_FLUSH.
+        */
+       if (offsets.switch_old_start) {
+               lib_ring_buffer_switch_old_start(buf, chan, &offsets, tsc);
+               offsets.old += config->cb.subbuffer_header_size();
+       }
+
+       /*
+        * Switch old subbuffer.
+        */
+       lib_ring_buffer_switch_old_end(buf, chan, &offsets, tsc);
+}
+EXPORT_SYMBOL_GPL(lib_ring_buffer_switch_slow);
+
+static void remote_switch(void *info)
+{
+       struct lib_ring_buffer *buf = info;
+
+       lib_ring_buffer_switch_slow(buf, SWITCH_ACTIVE);
+}
+
+void lib_ring_buffer_switch_remote(struct lib_ring_buffer *buf)
+{
+       struct channel *chan = buf->backend.chan;
+       const struct lib_ring_buffer_config *config = &chan->backend.config;
+       int ret;
+
+       /*
+        * With global synchronization we don't need to use the IPI scheme.
+        */
+       if (config->sync == RING_BUFFER_SYNC_GLOBAL) {
+               lib_ring_buffer_switch_slow(buf, SWITCH_ACTIVE);
+               return;
+       }
+
+       /*
+        * Taking lock on CPU hotplug to ensure two things: first, that the
+        * target cpu is not taken concurrently offline while we are within
+        * smp_call_function_single() (I don't trust that get_cpu() on the
+        * _local_ CPU actually inhibit CPU hotplug for the _remote_ CPU (to be
+        * confirmed)). Secondly, if it happens that the CPU is not online, our
+        * own call to lib_ring_buffer_switch_slow() needs to be protected from
+        * CPU hotplug handlers, which can also perform a remote subbuffer
+        * switch.
+        */
+       get_online_cpus();
+       ret = smp_call_function_single(buf->backend.cpu,
+                                remote_switch, buf, 1);
+       if (ret) {
+               /* Remote CPU is offline, do it ourself. */
+               lib_ring_buffer_switch_slow(buf, SWITCH_ACTIVE);
+       }
+       put_online_cpus();
+}
+EXPORT_SYMBOL_GPL(lib_ring_buffer_switch_remote);
+
+/*
+ * Returns :
+ * 0 if ok
+ * -ENOSPC if event size is too large for packet.
+ * -ENOBUFS if there is currently not enough space in buffer for the event.
+ * -EIO if data cannot be written into the buffer for any other reason.
+ */
+static
+int lib_ring_buffer_try_reserve_slow(struct lib_ring_buffer *buf,
+                                    struct channel *chan,
+                                    struct switch_offsets *offsets,
+                                    struct lib_ring_buffer_ctx *ctx)
+{
+       const struct lib_ring_buffer_config *config = &chan->backend.config;
+       unsigned long reserve_commit_diff, offset_cmp;
+
+retry:
+       offsets->begin = offset_cmp = v_read(config, &buf->offset);
+       offsets->old = offsets->begin;
+       offsets->switch_new_start = 0;
+       offsets->switch_new_end = 0;
+       offsets->switch_old_end = 0;
+       offsets->pre_header_padding = 0;
+
+       ctx->tsc = config->cb.ring_buffer_clock_read(chan);
+       if ((int64_t) ctx->tsc == -EIO)
+               return -EIO;
+
+       if (last_tsc_overflow(config, buf, ctx->tsc))
+               ctx->rflags |= RING_BUFFER_RFLAG_FULL_TSC;
+
+       if (unlikely(subbuf_offset(offsets->begin, ctx->chan) == 0)) {
+               offsets->switch_new_start = 1;          /* For offsets->begin */
+       } else {
+               offsets->size = config->cb.record_header_size(config, chan,
+                                               offsets->begin,
+                                               &offsets->pre_header_padding,
+                                               ctx);
+               offsets->size +=
+                       lib_ring_buffer_align(offsets->begin + offsets->size,
+                                             ctx->largest_align)
+                       + ctx->data_size;
+               if (unlikely(subbuf_offset(offsets->begin, chan) +
+                            offsets->size > chan->backend.subbuf_size)) {
+                       offsets->switch_old_end = 1;    /* For offsets->old */
+                       offsets->switch_new_start = 1;  /* For offsets->begin */
+               }
+       }
+       if (unlikely(offsets->switch_new_start)) {
+               unsigned long sb_index, commit_count;
+
+               /*
+                * We are typically not filling the previous buffer completely.
+                */
+               if (likely(offsets->switch_old_end))
+                       offsets->begin = subbuf_align(offsets->begin, chan);
+               offsets->begin = offsets->begin
+                                + config->cb.subbuffer_header_size();
+               /* Test new buffer integrity */
+               sb_index = subbuf_index(offsets->begin, chan);
+               /*
+                * Read buf->offset before buf->commit_cold[sb_index].cc_sb.
+                * lib_ring_buffer_check_deliver() has the matching
+                * memory barriers required around commit_cold cc_sb
+                * updates to ensure reserve and commit counter updates
+                * are not seen reordered when updated by another CPU.
+                */
+               smp_rmb();
+               commit_count = v_read(config,
+                               &buf->commit_cold[sb_index].cc_sb);
+               /* Read buf->commit_cold[sb_index].cc_sb before buf->offset. */
+               smp_rmb();
+               if (unlikely(offset_cmp != v_read(config, &buf->offset))) {
+                       /*
+                        * The reserve counter have been concurrently updated
+                        * while we read the commit counter. This means the
+                        * commit counter we read might not match buf->offset
+                        * due to concurrent update. We therefore need to retry.
+                        */
+                       goto retry;
+               }
+               reserve_commit_diff =
+                 (buf_trunc(offsets->begin, chan)
+                  >> chan->backend.num_subbuf_order)
+                 - (commit_count & chan->commit_count_mask);
+               if (likely(reserve_commit_diff == 0)) {
+                       /* Next subbuffer not being written to. */
+                       if (unlikely(config->mode != RING_BUFFER_OVERWRITE &&
+                               subbuf_trunc(offsets->begin, chan)
+                                - subbuf_trunc((unsigned long)
+                                    atomic_long_read(&buf->consumed), chan)
+                               >= chan->backend.buf_size)) {
+                               /*
+                                * We do not overwrite non consumed buffers
+                                * and we are full : record is lost.
+                                */
+                               v_inc(config, &buf->records_lost_full);
+                               return -ENOBUFS;
+                       } else {
+                               /*
+                                * Next subbuffer not being written to, and we
+                                * are either in overwrite mode or the buffer is
+                                * not full. It's safe to write in this new
+                                * subbuffer.
+                                */
+                       }
+               } else {
+                       /*
+                        * Next subbuffer reserve offset does not match the
+                        * commit offset, and this did not involve update to the
+                        * reserve counter. Drop record in producer-consumer and
+                        * overwrite mode.  Caused by either a writer OOPS or
+                        * too many nested writes over a reserve/commit pair.
+                        */
+                       v_inc(config, &buf->records_lost_wrap);
+                       return -EIO;
+               }
+               offsets->size =
+                       config->cb.record_header_size(config, chan,
+                                               offsets->begin,
+                                               &offsets->pre_header_padding,
+                                               ctx);
+               offsets->size +=
+                       lib_ring_buffer_align(offsets->begin + offsets->size,
+                                             ctx->largest_align)
+                       + ctx->data_size;
+               if (unlikely(subbuf_offset(offsets->begin, chan)
+                            + offsets->size > chan->backend.subbuf_size)) {
+                       /*
+                        * Record too big for subbuffers, report error, don't
+                        * complete the sub-buffer switch.
+                        */
+                       v_inc(config, &buf->records_lost_big);
+                       return -ENOSPC;
+               } else {
+                       /*
+                        * We just made a successful buffer switch and the
+                        * record fits in the new subbuffer. Let's write.
+                        */
+               }
+       } else {
+               /*
+                * Record fits in the current buffer and we are not on a switch
+                * boundary. It's safe to write.
+                */
+       }
+       offsets->end = offsets->begin + offsets->size;
+
+       if (unlikely(subbuf_offset(offsets->end, chan) == 0)) {
+               /*
+                * The offset_end will fall at the very beginning of the next
+                * subbuffer.
+                */
+               offsets->switch_new_end = 1;    /* For offsets->begin */
+       }
+       return 0;
+}
+
+/**
+ * lib_ring_buffer_reserve_slow - Atomic slot reservation in a buffer.
+ * @ctx: ring buffer context.
+ *
+ * Return : -NOBUFS if not enough space, -ENOSPC if event size too large,
+ * -EIO for other errors, else returns 0.
+ * It will take care of sub-buffer switching.
+ */
+int lib_ring_buffer_reserve_slow(struct lib_ring_buffer_ctx *ctx)
+{
+       struct channel *chan = ctx->chan;
+       const struct lib_ring_buffer_config *config = &chan->backend.config;
+       struct lib_ring_buffer *buf;
+       struct switch_offsets offsets;
+       int ret;
+
+       if (config->alloc == RING_BUFFER_ALLOC_PER_CPU)
+               buf = per_cpu_ptr(chan->backend.buf, ctx->cpu);
+       else
+               buf = chan->backend.buf;
+       ctx->buf = buf;
+
+       offsets.size = 0;
+
+       do {
+               ret = lib_ring_buffer_try_reserve_slow(buf, chan, &offsets,
+                                                      ctx);
+               if (unlikely(ret))
+                       return ret;
+       } while (unlikely(v_cmpxchg(config, &buf->offset, offsets.old,
+                                   offsets.end)
+                         != offsets.old));
+
+       /*
+        * Atomically update last_tsc. This update races against concurrent
+        * atomic updates, but the race will always cause supplementary full TSC
+        * records, never the opposite (missing a full TSC record when it would
+        * be needed).
+        */
+       save_last_tsc(config, buf, ctx->tsc);
+
+       /*
+        * Push the reader if necessary
+        */
+       lib_ring_buffer_reserve_push_reader(buf, chan, offsets.end - 1);
+
+       /*
+        * Clear noref flag for this subbuffer.
+        */
+       lib_ring_buffer_clear_noref(config, &buf->backend,
+                                   subbuf_index(offsets.end - 1, chan));
+
+       /*
+        * Switch old subbuffer if needed.
+        */
+       if (unlikely(offsets.switch_old_end)) {
+               lib_ring_buffer_clear_noref(config, &buf->backend,
+                                           subbuf_index(offsets.old - 1, chan));
+               lib_ring_buffer_switch_old_end(buf, chan, &offsets, ctx->tsc);
+       }
+
+       /*
+        * Populate new subbuffer.
+        */
+       if (unlikely(offsets.switch_new_start))
+               lib_ring_buffer_switch_new_start(buf, chan, &offsets, ctx->tsc);
+
+       if (unlikely(offsets.switch_new_end))
+               lib_ring_buffer_switch_new_end(buf, chan, &offsets, ctx->tsc);
+
+       ctx->slot_size = offsets.size;
+       ctx->pre_offset = offsets.begin;
+       ctx->buf_offset = offsets.begin + offsets.pre_header_padding;
+       return 0;
+}
+EXPORT_SYMBOL_GPL(lib_ring_buffer_reserve_slow);
+
+int __init init_lib_ring_buffer_frontend(void)
+{
+       int cpu;
+
+       for_each_possible_cpu(cpu)
+               spin_lock_init(&per_cpu(ring_buffer_nohz_lock, cpu));
+       return 0;
+}
+
+module_init(init_lib_ring_buffer_frontend);
+
+void __exit exit_lib_ring_buffer_frontend(void)
+{
+}
+
+module_exit(exit_lib_ring_buffer_frontend);
diff --git a/drivers/staging/lttng/lib/ringbuffer/ring_buffer_iterator.c b/drivers/staging/lttng/lib/ringbuffer/ring_buffer_iterator.c
new file mode 100644 (file)
index 0000000..290466f
--- /dev/null
@@ -0,0 +1,810 @@
+/*
+ * ring_buffer_iterator.c
+ *
+ * Ring buffer and channel iterators. Get each event of a channel in order. Uses
+ * a prio heap for per-cpu buffers, giving a O(log(NR_CPUS)) algorithmic
+ * complexity for the "get next event" operation.
+ *
+ * Copyright (C) 2010-2012 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; only
+ * version 2.1 of the License.
+ *
+ * This library 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
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ * Author:
+ *     Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
+ */
+
+#include "../../wrapper/ringbuffer/iterator.h"
+#include <linux/jiffies.h>
+#include <linux/delay.h>
+#include <linux/module.h>
+
+/*
+ * Safety factor taking into account internal kernel interrupt latency.
+ * Assuming 250ms worse-case latency.
+ */
+#define MAX_SYSTEM_LATENCY     250
+
+/*
+ * Maximum delta expected between trace clocks. At most 1 jiffy delta.
+ */
+#define MAX_CLOCK_DELTA                (jiffies_to_usecs(1) * 1000)
+
+/**
+ * lib_ring_buffer_get_next_record - Get the next record in a buffer.
+ * @chan: channel
+ * @buf: buffer
+ *
+ * Returns the size of the event read, -EAGAIN if buffer is empty, -ENODATA if
+ * buffer is empty and finalized. The buffer must already be opened for reading.
+ */
+ssize_t lib_ring_buffer_get_next_record(struct channel *chan,
+                                       struct lib_ring_buffer *buf)
+{
+       const struct lib_ring_buffer_config *config = &chan->backend.config;
+       struct lib_ring_buffer_iter *iter = &buf->iter;
+       int ret;
+
+restart:
+       switch (iter->state) {
+       case ITER_GET_SUBBUF:
+               ret = lib_ring_buffer_get_next_subbuf(buf);
+               if (ret && !ACCESS_ONCE(buf->finalized)
+                   && config->alloc == RING_BUFFER_ALLOC_GLOBAL) {
+                       /*
+                        * Use "pull" scheme for global buffers. The reader
+                        * itself flushes the buffer to "pull" data not visible
+                        * to readers yet. Flush current subbuffer and re-try.
+                        *
+                        * Per-CPU buffers rather use a "push" scheme because
+                        * the IPI needed to flush all CPU's buffers is too
+                        * costly. In the "push" scheme, the reader waits for
+                        * the writer periodic deferrable timer to flush the
+                        * buffers (keeping track of a quiescent state
+                        * timestamp). Therefore, the writer "pushes" data out
+                        * of the buffers rather than letting the reader "pull"
+                        * data from the buffer.
+                        */
+                       lib_ring_buffer_switch_slow(buf, SWITCH_ACTIVE);
+                       ret = lib_ring_buffer_get_next_subbuf(buf);
+               }
+               if (ret)
+                       return ret;
+               iter->consumed = buf->cons_snapshot;
+               iter->data_size = lib_ring_buffer_get_read_data_size(config, buf);
+               iter->read_offset = iter->consumed;
+               /* skip header */
+               iter->read_offset += config->cb.subbuffer_header_size();
+               iter->state = ITER_TEST_RECORD;
+               goto restart;
+       case ITER_TEST_RECORD:
+               if (iter->read_offset - iter->consumed >= iter->data_size) {
+                       iter->state = ITER_PUT_SUBBUF;
+               } else {
+                       CHAN_WARN_ON(chan, !config->cb.record_get);
+                       config->cb.record_get(config, chan, buf,
+                                             iter->read_offset,
+                                             &iter->header_len,
+                                             &iter->payload_len,
+                                             &iter->timestamp);
+                       iter->read_offset += iter->header_len;
+                       subbuffer_consume_record(config, &buf->backend);
+                       iter->state = ITER_NEXT_RECORD;
+                       return iter->payload_len;
+               }
+               goto restart;
+       case ITER_NEXT_RECORD:
+               iter->read_offset += iter->payload_len;
+               iter->state = ITER_TEST_RECORD;
+               goto restart;
+       case ITER_PUT_SUBBUF:
+               lib_ring_buffer_put_next_subbuf(buf);
+               iter->state = ITER_GET_SUBBUF;
+               goto restart;
+       default:
+               CHAN_WARN_ON(chan, 1);  /* Should not happen */
+               return -EPERM;
+       }
+}
+EXPORT_SYMBOL_GPL(lib_ring_buffer_get_next_record);
+
+static int buf_is_higher(void *a, void *b)
+{
+       struct lib_ring_buffer *bufa = a;
+       struct lib_ring_buffer *bufb = b;
+
+       /* Consider lowest timestamps to be at the top of the heap */
+       return (bufa->iter.timestamp < bufb->iter.timestamp);
+}
+
+static
+void lib_ring_buffer_get_empty_buf_records(const struct lib_ring_buffer_config *config,
+                                          struct channel *chan)
+{
+       struct lttng_ptr_heap *heap = &chan->iter.heap;
+       struct lib_ring_buffer *buf, *tmp;
+       ssize_t len;
+
+       list_for_each_entry_safe(buf, tmp, &chan->iter.empty_head,
+                                iter.empty_node) {
+               len = lib_ring_buffer_get_next_record(chan, buf);
+
+               /*
+                * Deal with -EAGAIN and -ENODATA.
+                * len >= 0 means record contains data.
+                * -EBUSY should never happen, because we support only one
+                * reader.
+                */
+               switch (len) {
+               case -EAGAIN:
+                       /* Keep node in empty list */
+                       break;
+               case -ENODATA:
+                       /*
+                        * Buffer is finalized. Don't add to list of empty
+                        * buffer, because it has no more data to provide, ever.
+                        */
+                       list_del(&buf->iter.empty_node);
+                       break;
+               case -EBUSY:
+                       CHAN_WARN_ON(chan, 1);
+                       break;
+               default:
+                       /*
+                        * Insert buffer into the heap, remove from empty buffer
+                        * list.
+                        */
+                       CHAN_WARN_ON(chan, len < 0);
+                       list_del(&buf->iter.empty_node);
+                       CHAN_WARN_ON(chan, lttng_heap_insert(heap, buf));
+               }
+       }
+}
+
+static
+void lib_ring_buffer_wait_for_qs(const struct lib_ring_buffer_config *config,
+                                struct channel *chan)
+{
+       u64 timestamp_qs;
+       unsigned long wait_msecs;
+
+       /*
+        * No need to wait if no empty buffers are present.
+        */
+       if (list_empty(&chan->iter.empty_head))
+               return;
+
+       timestamp_qs = config->cb.ring_buffer_clock_read(chan);
+       /*
+        * We need to consider previously empty buffers.
+        * Do a get next buf record on each of them. Add them to
+        * the heap if they have data. If at least one of them
+        * don't have data, we need to wait for
+        * switch_timer_interval + MAX_SYSTEM_LATENCY (so we are sure the
+        * buffers have been switched either by the timer or idle entry) and
+        * check them again, adding them if they have data.
+        */
+       lib_ring_buffer_get_empty_buf_records(config, chan);
+
+       /*
+        * No need to wait if no empty buffers are present.
+        */
+       if (list_empty(&chan->iter.empty_head))
+               return;
+
+       /*
+        * We need to wait for the buffer switch timer to run. If the
+        * CPU is idle, idle entry performed the switch.
+        * TODO: we could optimize further by skipping the sleep if all
+        * empty buffers belong to idle or offline cpus.
+        */
+       wait_msecs = jiffies_to_msecs(chan->switch_timer_interval);
+       wait_msecs += MAX_SYSTEM_LATENCY;
+       msleep(wait_msecs);
+       lib_ring_buffer_get_empty_buf_records(config, chan);
+       /*
+        * Any buffer still in the empty list here cannot possibly
+        * contain an event with a timestamp prior to "timestamp_qs".
+        * The new quiescent state timestamp is the one we grabbed
+        * before waiting for buffer data.  It is therefore safe to
+        * ignore empty buffers up to last_qs timestamp for fusion
+        * merge.
+        */
+       chan->iter.last_qs = timestamp_qs;
+}
+
+/**
+ * channel_get_next_record - Get the next record in a channel.
+ * @chan: channel
+ * @ret_buf: the buffer in which the event is located (output)
+ *
+ * Returns the size of new current event, -EAGAIN if all buffers are empty,
+ * -ENODATA if all buffers are empty and finalized. The channel must already be
+ * opened for reading.
+ */
+
+ssize_t channel_get_next_record(struct channel *chan,
+                               struct lib_ring_buffer **ret_buf)
+{
+       const struct lib_ring_buffer_config *config = &chan->backend.config;
+       struct lib_ring_buffer *buf;
+       struct lttng_ptr_heap *heap;
+       ssize_t len;
+
+       if (config->alloc == RING_BUFFER_ALLOC_GLOBAL) {
+               *ret_buf = channel_get_ring_buffer(config, chan, 0);
+               return lib_ring_buffer_get_next_record(chan, *ret_buf);
+       }
+
+       heap = &chan->iter.heap;
+
+       /*
+        * get next record for topmost buffer.
+        */
+       buf = lttng_heap_maximum(heap);
+       if (buf) {
+               len = lib_ring_buffer_get_next_record(chan, buf);
+               /*
+                * Deal with -EAGAIN and -ENODATA.
+                * len >= 0 means record contains data.
+                */
+               switch (len) {
+               case -EAGAIN:
+                       buf->iter.timestamp = 0;
+                       list_add(&buf->iter.empty_node, &chan->iter.empty_head);
+                       /* Remove topmost buffer from the heap */
+                       CHAN_WARN_ON(chan, lttng_heap_remove(heap) != buf);
+                       break;
+               case -ENODATA:
+                       /*
+                        * Buffer is finalized. Remove buffer from heap and
+                        * don't add to list of empty buffer, because it has no
+                        * more data to provide, ever.
+                        */
+                       CHAN_WARN_ON(chan, lttng_heap_remove(heap) != buf);
+                       break;
+               case -EBUSY:
+                       CHAN_WARN_ON(chan, 1);
+                       break;
+               default:
+                       /*
+                        * Reinsert buffer into the heap. Note that heap can be
+                        * partially empty, so we need to use
+                        * lttng_heap_replace_max().
+                        */
+                       CHAN_WARN_ON(chan, len < 0);
+                       CHAN_WARN_ON(chan, lttng_heap_replace_max(heap, buf) != buf);
+                       break;
+               }
+       }
+
+       buf = lttng_heap_maximum(heap);
+       if (!buf || buf->iter.timestamp > chan->iter.last_qs) {
+               /*
+                * Deal with buffers previously showing no data.
+                * Add buffers containing data to the heap, update
+                * last_qs.
+                */
+               lib_ring_buffer_wait_for_qs(config, chan);
+       }
+
+       *ret_buf = buf = lttng_heap_maximum(heap);
+       if (buf) {
+               /*
+                * If this warning triggers, you probably need to check your
+                * system interrupt latency. Typical causes: too many printk()
+                * output going to a serial console with interrupts off.
+                * Allow for MAX_CLOCK_DELTA ns timestamp delta going backward.
+                * Observed on SMP KVM setups with trace_clock().
+                */
+               if (chan->iter.last_timestamp
+                   > (buf->iter.timestamp + MAX_CLOCK_DELTA)) {
+                       printk(KERN_WARNING "ring_buffer: timestamps going "
+                              "backward. Last time %llu ns, cpu %d, "
+                              "current time %llu ns, cpu %d, "
+                              "delta %llu ns.\n",
+                              chan->iter.last_timestamp, chan->iter.last_cpu,
+                              buf->iter.timestamp, buf->backend.cpu,
+                              chan->iter.last_timestamp - buf->iter.timestamp);
+                       CHAN_WARN_ON(chan, 1);
+               }
+               chan->iter.last_timestamp = buf->iter.timestamp;
+               chan->iter.last_cpu = buf->backend.cpu;
+               return buf->iter.payload_len;
+       } else {
+               /* Heap is empty */
+               if (list_empty(&chan->iter.empty_head))
+                       return -ENODATA;        /* All buffers finalized */
+               else
+                       return -EAGAIN;         /* Temporarily empty */
+       }
+}
+EXPORT_SYMBOL_GPL(channel_get_next_record);
+
+static
+void lib_ring_buffer_iterator_init(struct channel *chan, struct lib_ring_buffer *buf)
+{
+       if (buf->iter.allocated)
+               return;
+
+       buf->iter.allocated = 1;
+       if (chan->iter.read_open && !buf->iter.read_open) {
+               CHAN_WARN_ON(chan, lib_ring_buffer_open_read(buf) != 0);
+               buf->iter.read_open = 1;
+       }
+
+       /* Add to list of buffers without any current record */
+       if (chan->backend.config.alloc == RING_BUFFER_ALLOC_PER_CPU)
+               list_add(&buf->iter.empty_node, &chan->iter.empty_head);
+}
+
+#ifdef CONFIG_HOTPLUG_CPU
+static
+int channel_iterator_cpu_hotplug(struct notifier_block *nb,
+                                          unsigned long action,
+                                          void *hcpu)
+{
+       unsigned int cpu = (unsigned long)hcpu;
+       struct channel *chan = container_of(nb, struct channel,
+                                           hp_iter_notifier);
+       struct lib_ring_buffer *buf = per_cpu_ptr(chan->backend.buf, cpu);
+       const struct lib_ring_buffer_config *config = &chan->backend.config;
+
+       if (!chan->hp_iter_enable)
+               return NOTIFY_DONE;
+
+       CHAN_WARN_ON(chan, config->alloc == RING_BUFFER_ALLOC_GLOBAL);
+
+       switch (action) {
+       case CPU_DOWN_FAILED:
+       case CPU_DOWN_FAILED_FROZEN:
+       case CPU_ONLINE:
+       case CPU_ONLINE_FROZEN:
+               lib_ring_buffer_iterator_init(chan, buf);
+               return NOTIFY_OK;
+       default:
+               return NOTIFY_DONE;
+       }
+}
+#endif
+
+int channel_iterator_init(struct channel *chan)
+{
+       const struct lib_ring_buffer_config *config = &chan->backend.config;
+       struct lib_ring_buffer *buf;
+
+       if (config->alloc == RING_BUFFER_ALLOC_PER_CPU) {
+               int cpu, ret;
+
+               INIT_LIST_HEAD(&chan->iter.empty_head);
+               ret = lttng_heap_init(&chan->iter.heap,
+                               num_possible_cpus(),
+                               GFP_KERNEL, buf_is_higher);
+               if (ret)
+                       return ret;
+               /*
+                * In case of non-hotplug cpu, if the ring-buffer is allocated
+                * in early initcall, it will not be notified of secondary cpus.
+                * In that off case, we need to allocate for all possible cpus.
+                */
+#ifdef CONFIG_HOTPLUG_CPU
+               chan->hp_iter_notifier.notifier_call =
+                       channel_iterator_cpu_hotplug;
+               chan->hp_iter_notifier.priority = 10;
+               register_cpu_notifier(&chan->hp_iter_notifier);
+               get_online_cpus();
+               for_each_online_cpu(cpu) {
+                       buf = per_cpu_ptr(chan->backend.buf, cpu);
+                       lib_ring_buffer_iterator_init(chan, buf);
+               }
+               chan->hp_iter_enable = 1;
+               put_online_cpus();
+#else
+               for_each_possible_cpu(cpu) {
+                       buf = per_cpu_ptr(chan->backend.buf, cpu);
+                       lib_ring_buffer_iterator_init(chan, buf);
+               }
+#endif
+       } else {
+               buf = channel_get_ring_buffer(config, chan, 0);
+               lib_ring_buffer_iterator_init(chan, buf);
+       }
+       return 0;
+}
+
+void channel_iterator_unregister_notifiers(struct channel *chan)
+{
+       const struct lib_ring_buffer_config *config = &chan->backend.config;
+
+       if (config->alloc == RING_BUFFER_ALLOC_PER_CPU) {
+               chan->hp_iter_enable = 0;
+               unregister_cpu_notifier(&chan->hp_iter_notifier);
+       }
+}
+
+void channel_iterator_free(struct channel *chan)
+{
+       const struct lib_ring_buffer_config *config = &chan->backend.config;
+
+       if (config->alloc == RING_BUFFER_ALLOC_PER_CPU)
+               lttng_heap_free(&chan->iter.heap);
+}
+
+int lib_ring_buffer_iterator_open(struct lib_ring_buffer *buf)
+{
+       struct channel *chan = buf->backend.chan;
+       const struct lib_ring_buffer_config *config = &chan->backend.config;
+       CHAN_WARN_ON(chan, config->output != RING_BUFFER_ITERATOR);
+       return lib_ring_buffer_open_read(buf);
+}
+EXPORT_SYMBOL_GPL(lib_ring_buffer_iterator_open);
+
+/*
+ * Note: Iterators must not be mixed with other types of outputs, because an
+ * iterator can leave the buffer in "GET" state, which is not consistent with
+ * other types of output (mmap, splice, raw data read).
+ */
+void lib_ring_buffer_iterator_release(struct lib_ring_buffer *buf)
+{
+       lib_ring_buffer_release_read(buf);
+}
+EXPORT_SYMBOL_GPL(lib_ring_buffer_iterator_release);
+
+int channel_iterator_open(struct channel *chan)
+{
+       const struct lib_ring_buffer_config *config = &chan->backend.config;
+       struct lib_ring_buffer *buf;
+       int ret = 0, cpu;
+
+       CHAN_WARN_ON(chan, config->output != RING_BUFFER_ITERATOR);
+
+       if (config->alloc == RING_BUFFER_ALLOC_PER_CPU) {
+               get_online_cpus();
+               /* Allow CPU hotplug to keep track of opened reader */
+               chan->iter.read_open = 1;
+               for_each_channel_cpu(cpu, chan) {
+                       buf = channel_get_ring_buffer(config, chan, cpu);
+                       ret = lib_ring_buffer_iterator_open(buf);
+                       if (ret)
+                               goto error;
+                       buf->iter.read_open = 1;
+               }
+               put_online_cpus();
+       } else {
+               buf = channel_get_ring_buffer(config, chan, 0);
+               ret = lib_ring_buffer_iterator_open(buf);
+       }
+       return ret;
+error:
+       /* Error should always happen on CPU 0, hence no close is required. */
+       CHAN_WARN_ON(chan, cpu != 0);
+       put_online_cpus();
+       return ret;
+}
+EXPORT_SYMBOL_GPL(channel_iterator_open);
+
+void channel_iterator_release(struct channel *chan)
+{
+       const struct lib_ring_buffer_config *config = &chan->backend.config;
+       struct lib_ring_buffer *buf;
+       int cpu;
+
+       if (config->alloc == RING_BUFFER_ALLOC_PER_CPU) {
+               get_online_cpus();
+               for_each_channel_cpu(cpu, chan) {
+                       buf = channel_get_ring_buffer(config, chan, cpu);
+                       if (buf->iter.read_open) {
+                               lib_ring_buffer_iterator_release(buf);
+                               buf->iter.read_open = 0;
+                       }
+               }
+               chan->iter.read_open = 0;
+               put_online_cpus();
+       } else {
+               buf = channel_get_ring_buffer(config, chan, 0);
+               lib_ring_buffer_iterator_release(buf);
+       }
+}
+EXPORT_SYMBOL_GPL(channel_iterator_release);
+
+void lib_ring_buffer_iterator_reset(struct lib_ring_buffer *buf)
+{
+       struct channel *chan = buf->backend.chan;
+
+       if (buf->iter.state != ITER_GET_SUBBUF)
+               lib_ring_buffer_put_next_subbuf(buf);
+       buf->iter.state = ITER_GET_SUBBUF;
+       /* Remove from heap (if present). */
+       if (lttng_heap_cherrypick(&chan->iter.heap, buf))
+               list_add(&buf->iter.empty_node, &chan->iter.empty_head);
+       buf->iter.timestamp = 0;
+       buf->iter.header_len = 0;
+       buf->iter.payload_len = 0;
+       buf->iter.consumed = 0;
+       buf->iter.read_offset = 0;
+       buf->iter.data_size = 0;
+       /* Don't reset allocated and read_open */
+}
+
+void channel_iterator_reset(struct channel *chan)
+{
+       const struct lib_ring_buffer_config *config = &chan->backend.config;
+       struct lib_ring_buffer *buf;
+       int cpu;
+
+       /* Empty heap, put into empty_head */
+       while ((buf = lttng_heap_remove(&chan->iter.heap)) != NULL)
+               list_add(&buf->iter.empty_node, &chan->iter.empty_head);
+
+       for_each_channel_cpu(cpu, chan) {
+               buf = channel_get_ring_buffer(config, chan, cpu);
+               lib_ring_buffer_iterator_reset(buf);
+       }
+       /* Don't reset read_open */
+       chan->iter.last_qs = 0;
+       chan->iter.last_timestamp = 0;
+       chan->iter.last_cpu = 0;
+       chan->iter.len_left = 0;
+}
+
+/*
+ * Ring buffer payload extraction read() implementation.
+ */
+static
+ssize_t channel_ring_buffer_file_read(struct file *filp,
+                                     char __user *user_buf,
+                                     size_t count,
+                                     loff_t *ppos,
+                                     struct channel *chan,
+                                     struct lib_ring_buffer *buf,
+                                     int fusionmerge)
+{
+       const struct lib_ring_buffer_config *config = &chan->backend.config;
+       size_t read_count = 0, read_offset;
+       ssize_t len;
+
+       might_sleep();
+       if (!access_ok(VERIFY_WRITE, user_buf, count))
+               return -EFAULT;
+
+       /* Finish copy of previous record */
+       if (*ppos != 0) {
+               if (read_count < count) {
+                       len = chan->iter.len_left;
+                       read_offset = *ppos;
+                       if (config->alloc == RING_BUFFER_ALLOC_PER_CPU
+                           && fusionmerge)
+                               buf = lttng_heap_maximum(&chan->iter.heap);
+                       CHAN_WARN_ON(chan, !buf);
+                       goto skip_get_next;
+               }
+       }
+
+       while (read_count < count) {
+               size_t copy_len, space_left;
+
+               if (fusionmerge)
+                       len = channel_get_next_record(chan, &buf);
+               else
+                       len = lib_ring_buffer_get_next_record(chan, buf);
+len_test:
+               if (len < 0) {
+                       /*
+                        * Check if buffer is finalized (end of file).
+                        */
+                       if (len == -ENODATA) {
+                               /* A 0 read_count will tell about end of file */
+                               goto nodata;
+                       }
+                       if (filp->f_flags & O_NONBLOCK) {
+                               if (!read_count)
+                                       read_count = -EAGAIN;
+                               goto nodata;
+                       } else {
+                               int error;
+
+                               /*
+                                * No data available at the moment, return what
+                                * we got.
+                                */
+                               if (read_count)
+                                       goto nodata;
+
+                               /*
+                                * Wait for returned len to be >= 0 or -ENODATA.
+                                */
+                               if (fusionmerge)
+                                       error = wait_event_interruptible(
+                                         chan->read_wait,
+                                         ((len = channel_get_next_record(chan,
+                                               &buf)), len != -EAGAIN));
+                               else
+                                       error = wait_event_interruptible(
+                                         buf->read_wait,
+                                         ((len = lib_ring_buffer_get_next_record(
+                                                 chan, buf)), len != -EAGAIN));
+                               CHAN_WARN_ON(chan, len == -EBUSY);
+                               if (error) {
+                                       read_count = error;
+                                       goto nodata;
+                               }
+                               CHAN_WARN_ON(chan, len < 0 && len != -ENODATA);
+                               goto len_test;
+                       }
+               }
+               read_offset = buf->iter.read_offset;
+skip_get_next:
+               space_left = count - read_count;
+               if (len <= space_left) {
+                       copy_len = len;
+                       chan->iter.len_left = 0;
+                       *ppos = 0;
+               } else {
+                       copy_len = space_left;
+                       chan->iter.len_left = len - copy_len;
+                       *ppos = read_offset + copy_len;
+               }
+               if (__lib_ring_buffer_copy_to_user(&buf->backend, read_offset,
+                                              &user_buf[read_count],
+                                              copy_len)) {
+                       /*
+                        * Leave the len_left and ppos values at their current
+                        * state, as we currently have a valid event to read.
+                        */
+                       return -EFAULT;
+               }
+               read_count += copy_len;
+       };
+       return read_count;
+
+nodata:
+       *ppos = 0;
+       chan->iter.len_left = 0;
+       return read_count;
+}
+
+/**
+ * lib_ring_buffer_file_read - Read buffer record payload.
+ * @filp: file structure pointer.
+ * @buffer: user buffer to read data into.
+ * @count: number of bytes to read.
+ * @ppos: file read position.
+ *
+ * Returns a negative value on error, or the number of bytes read on success.
+ * ppos is used to save the position _within the current record_ between calls
+ * to read().
+ */
+static
+ssize_t lib_ring_buffer_file_read(struct file *filp,
+                                 char __user *user_buf,
+                                 size_t count,
+                                 loff_t *ppos)
+{
+       struct inode *inode = filp->f_dentry->d_inode;
+       struct lib_ring_buffer *buf = inode->i_private;
+       struct channel *chan = buf->backend.chan;
+
+       return channel_ring_buffer_file_read(filp, user_buf, count, ppos,
+                                            chan, buf, 0);
+}
+
+/**
+ * channel_file_read - Read channel record payload.
+ * @filp: file structure pointer.
+ * @buffer: user buffer to read data into.
+ * @count: number of bytes to read.
+ * @ppos: file read position.
+ *
+ * Returns a negative value on error, or the number of bytes read on success.
+ * ppos is used to save the position _within the current record_ between calls
+ * to read().
+ */
+static
+ssize_t channel_file_read(struct file *filp,
+                         char __user *user_buf,
+                         size_t count,
+                         loff_t *ppos)
+{
+       struct inode *inode = filp->f_dentry->d_inode;
+       struct channel *chan = inode->i_private;
+       const struct lib_ring_buffer_config *config = &chan->backend.config;
+
+       if (config->alloc == RING_BUFFER_ALLOC_PER_CPU)
+               return channel_ring_buffer_file_read(filp, user_buf, count,
+                                                    ppos, chan, NULL, 1);
+       else {
+               struct lib_ring_buffer *buf =
+                       channel_get_ring_buffer(config, chan, 0);
+               return channel_ring_buffer_file_read(filp, user_buf, count,
+                                                    ppos, chan, buf, 0);
+       }
+}
+
+static
+int lib_ring_buffer_file_open(struct inode *inode, struct file *file)
+{
+       struct lib_ring_buffer *buf = inode->i_private;
+       int ret;
+
+       ret = lib_ring_buffer_iterator_open(buf);
+       if (ret)
+               return ret;
+
+       file->private_data = buf;
+       ret = nonseekable_open(inode, file);
+       if (ret)
+               goto release_iter;
+       return 0;
+
+release_iter:
+       lib_ring_buffer_iterator_release(buf);
+       return ret;
+}
+
+static
+int lib_ring_buffer_file_release(struct inode *inode, struct file *file)
+{
+       struct lib_ring_buffer *buf = inode->i_private;
+
+       lib_ring_buffer_iterator_release(buf);
+       return 0;
+}
+
+static
+int channel_file_open(struct inode *inode, struct file *file)
+{
+       struct channel *chan = inode->i_private;
+       int ret;
+
+       ret = channel_iterator_open(chan);
+       if (ret)
+               return ret;
+
+       file->private_data = chan;
+       ret = nonseekable_open(inode, file);
+       if (ret)
+               goto release_iter;
+       return 0;
+
+release_iter:
+       channel_iterator_release(chan);
+       return ret;
+}
+
+static
+int channel_file_release(struct inode *inode, struct file *file)
+{
+       struct channel *chan = inode->i_private;
+
+       channel_iterator_release(chan);
+       return 0;
+}
+
+const struct file_operations channel_payload_file_operations = {
+       .owner = THIS_MODULE,
+       .open = channel_file_open,
+       .release = channel_file_release,
+       .read = channel_file_read,
+       .llseek = vfs_lib_ring_buffer_no_llseek,
+};
+EXPORT_SYMBOL_GPL(channel_payload_file_operations);
+
+const struct file_operations lib_ring_buffer_payload_file_operations = {
+       .owner = THIS_MODULE,
+       .open = lib_ring_buffer_file_open,
+       .release = lib_ring_buffer_file_release,
+       .read = lib_ring_buffer_file_read,
+       .llseek = vfs_lib_ring_buffer_no_llseek,
+};
+EXPORT_SYMBOL_GPL(lib_ring_buffer_payload_file_operations);
diff --git a/drivers/staging/lttng/lib/ringbuffer/ring_buffer_mmap.c b/drivers/staging/lttng/lib/ringbuffer/ring_buffer_mmap.c
new file mode 100644 (file)
index 0000000..c172fee
--- /dev/null
@@ -0,0 +1,128 @@
+/*
+ * ring_buffer_mmap.c
+ *
+ * Copyright (C) 2002-2005 - Tom Zanussi <zanussi@us.ibm.com>, IBM Corp
+ * Copyright (C) 1999-2005 - Karim Yaghmour <karim@opersys.com>
+ * Copyright (C) 2008-2012 - Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; only version 2 of the License.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Re-using code from kernel/relay.c, hence the GPLv2 license for this
+ * file.
+ */
+
+#include <linux/module.h>
+#include <linux/mm.h>
+
+#include "../../wrapper/ringbuffer/backend.h"
+#include "../../wrapper/ringbuffer/frontend.h"
+#include "../../wrapper/ringbuffer/vfs.h"
+
+/*
+ * fault() vm_op implementation for ring buffer file mapping.
+ */
+static int lib_ring_buffer_fault(struct vm_area_struct *vma, struct vm_fault *vmf)
+{
+       struct lib_ring_buffer *buf = vma->vm_private_data;
+       struct channel *chan = buf->backend.chan;
+       const struct lib_ring_buffer_config *config = &chan->backend.config;
+       pgoff_t pgoff = vmf->pgoff;
+       struct page **page;
+       void **virt;
+       unsigned long offset, sb_bindex;
+
+       /*
+        * Verify that faults are only done on the range of pages owned by the
+        * reader.
+        */
+       offset = pgoff << PAGE_SHIFT;
+       sb_bindex = subbuffer_id_get_index(config, buf->backend.buf_rsb.id);
+       if (!(offset >= buf->backend.array[sb_bindex]->mmap_offset
+             && offset < buf->backend.array[sb_bindex]->mmap_offset +
+                         buf->backend.chan->backend.subbuf_size))
+               return VM_FAULT_SIGBUS;
+       /*
+        * ring_buffer_read_get_page() gets the page in the current reader's
+        * pages.
+        */
+       page = lib_ring_buffer_read_get_page(&buf->backend, offset, &virt);
+       if (!*page)
+               return VM_FAULT_SIGBUS;
+       get_page(*page);
+       vmf->page = *page;
+
+       return 0;
+}
+
+/*
+ * vm_ops for ring buffer file mappings.
+ */
+static const struct vm_operations_struct lib_ring_buffer_mmap_ops = {
+       .fault = lib_ring_buffer_fault,
+};
+
+/**
+ *     lib_ring_buffer_mmap_buf: - mmap channel buffer to process address space
+ *     @buf: ring buffer to map
+ *     @vma: vm_area_struct describing memory to be mapped
+ *
+ *     Returns 0 if ok, negative on error
+ *
+ *     Caller should already have grabbed mmap_sem.
+ */
+static int lib_ring_buffer_mmap_buf(struct lib_ring_buffer *buf,
+                                   struct vm_area_struct *vma)
+{
+       unsigned long length = vma->vm_end - vma->vm_start;
+       struct channel *chan = buf->backend.chan;
+       const struct lib_ring_buffer_config *config = &chan->backend.config;
+       unsigned long mmap_buf_len;
+
+       if (config->output != RING_BUFFER_MMAP)
+               return -EINVAL;
+
+       mmap_buf_len = chan->backend.buf_size;
+       if (chan->backend.extra_reader_sb)
+               mmap_buf_len += chan->backend.subbuf_size;
+
+       if (length != mmap_buf_len)
+               return -EINVAL;
+
+       vma->vm_ops = &lib_ring_buffer_mmap_ops;
+       vma->vm_flags |= VM_DONTEXPAND;
+       vma->vm_private_data = buf;
+
+       return 0;
+}
+
+int lib_ring_buffer_mmap(struct file *filp, struct vm_area_struct *vma,
+               struct lib_ring_buffer *buf)
+{
+       return lib_ring_buffer_mmap_buf(buf, vma);
+}
+EXPORT_SYMBOL_GPL(lib_ring_buffer_mmap);
+
+/**
+ *     vfs_lib_ring_buffer_mmap - mmap file op
+ *     @filp: the file
+ *     @vma: the vma describing what to map
+ *
+ *     Calls upon lib_ring_buffer_mmap_buf() to map the file into user space.
+ */
+int vfs_lib_ring_buffer_mmap(struct file *filp, struct vm_area_struct *vma)
+{
+       struct lib_ring_buffer *buf = filp->private_data;
+       return lib_ring_buffer_mmap(filp, vma, buf);
+}
+EXPORT_SYMBOL_GPL(vfs_lib_ring_buffer_mmap);
diff --git a/drivers/staging/lttng/lib/ringbuffer/ring_buffer_splice.c b/drivers/staging/lttng/lib/ringbuffer/ring_buffer_splice.c
new file mode 100644 (file)
index 0000000..3a7ff0c
--- /dev/null
@@ -0,0 +1,227 @@
+/*
+ * ring_buffer_splice.c
+ *
+ * Copyright (C) 2002-2005 - Tom Zanussi <zanussi@us.ibm.com>, IBM Corp
+ * Copyright (C) 1999-2005 - Karim Yaghmour <karim@opersys.com>
+ * Copyright (C) 2008-2012 - Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; only
+ * version 2.1 of the License.
+ *
+ * This library 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
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ * Re-using code from kernel/relay.c, which is why it is licensed under
+ * the GPLv2.
+ */
+
+#include <linux/module.h>
+#include <linux/fs.h>
+
+#include "../../wrapper/splice.h"
+#include "../../wrapper/ringbuffer/backend.h"
+#include "../../wrapper/ringbuffer/frontend.h"
+#include "../../wrapper/ringbuffer/vfs.h"
+
+#if 0
+#define printk_dbg(fmt, args...) printk(fmt, args)
+#else
+#define printk_dbg(fmt, args...)
+#endif
+
+loff_t vfs_lib_ring_buffer_no_llseek(struct file *file, loff_t offset,
+               int origin)
+{
+       return -ESPIPE;
+}
+EXPORT_SYMBOL_GPL(vfs_lib_ring_buffer_no_llseek);
+
+/*
+ * Release pages from the buffer so splice pipe_to_file can move them.
+ * Called after the pipe has been populated with buffer pages.
+ */
+static void lib_ring_buffer_pipe_buf_release(struct pipe_inode_info *pipe,
+                                            struct pipe_buffer *pbuf)
+{
+       __free_page(pbuf->page);
+}
+
+static const struct pipe_buf_operations ring_buffer_pipe_buf_ops = {
+       .can_merge = 0,
+       .map = generic_pipe_buf_map,
+       .unmap = generic_pipe_buf_unmap,
+       .confirm = generic_pipe_buf_confirm,
+       .release = lib_ring_buffer_pipe_buf_release,
+       .steal = generic_pipe_buf_steal,
+       .get = generic_pipe_buf_get,
+};
+
+/*
+ * Page release operation after splice pipe_to_file ends.
+ */
+static void lib_ring_buffer_page_release(struct splice_pipe_desc *spd,
+                                        unsigned int i)
+{
+       __free_page(spd->pages[i]);
+}
+
+/*
+ *     subbuf_splice_actor - splice up to one subbuf's worth of data
+ */
+static int subbuf_splice_actor(struct file *in,
+                              loff_t *ppos,
+                              struct pipe_inode_info *pipe,
+                              size_t len,
+                              unsigned int flags,
+                              struct lib_ring_buffer *buf)
+{
+       struct channel *chan = buf->backend.chan;
+       const struct lib_ring_buffer_config *config = &chan->backend.config;
+       unsigned int poff, subbuf_pages, nr_pages;
+       struct page *pages[PIPE_DEF_BUFFERS];
+       struct partial_page partial[PIPE_DEF_BUFFERS];
+       struct splice_pipe_desc spd = {
+               .pages = pages,
+               .nr_pages = 0,
+               .partial = partial,
+               .flags = flags,
+               .ops = &ring_buffer_pipe_buf_ops,
+               .spd_release = lib_ring_buffer_page_release,
+       };
+       unsigned long consumed_old, roffset;
+       unsigned long bytes_avail;
+
+       /*
+        * Check that a GET_SUBBUF ioctl has been done before.
+        */
+       WARN_ON(atomic_long_read(&buf->active_readers) != 1);
+       consumed_old = lib_ring_buffer_get_consumed(config, buf);
+       consumed_old += *ppos;
+
+       /*
+        * Adjust read len, if longer than what is available.
+        * Max read size is 1 subbuffer due to get_subbuf/put_subbuf for
+        * protection.
+        */
+       bytes_avail = chan->backend.subbuf_size;
+       WARN_ON(bytes_avail > chan->backend.buf_size);
+       len = min_t(size_t, len, bytes_avail);
+       subbuf_pages = bytes_avail >> PAGE_SHIFT;
+       nr_pages = min_t(unsigned int, subbuf_pages, PIPE_DEF_BUFFERS);
+       roffset = consumed_old & PAGE_MASK;
+       poff = consumed_old & ~PAGE_MASK;
+       printk_dbg(KERN_DEBUG "SPLICE actor len %zu pos %zd write_pos %ld\n",
+                  len, (ssize_t)*ppos, lib_ring_buffer_get_offset(config, buf));
+
+       for (; spd.nr_pages < nr_pages; spd.nr_pages++) {
+               unsigned int this_len;
+               struct page **page, *new_page;
+               void **virt;
+
+               if (!len)
+                       break;
+               printk_dbg(KERN_DEBUG "SPLICE actor loop len %zu roffset %ld\n",
+                          len, roffset);
+
+               /*
+                * We have to replace the page we are moving into the splice
+                * pipe.
+                */
+               new_page = alloc_pages_node(cpu_to_node(max(buf->backend.cpu,
+                                                           0)),
+                                           GFP_KERNEL | __GFP_ZERO, 0);
+               if (!new_page)
+                       break;
+
+               this_len = PAGE_SIZE - poff;
+               page = lib_ring_buffer_read_get_page(&buf->backend, roffset, &virt);
+               spd.pages[spd.nr_pages] = *page;
+               *page = new_page;
+               *virt = page_address(new_page);
+               spd.partial[spd.nr_pages].offset = poff;
+               spd.partial[spd.nr_pages].len = this_len;
+
+               poff = 0;
+               roffset += PAGE_SIZE;
+               len -= this_len;
+       }
+
+       if (!spd.nr_pages)
+               return 0;
+
+       return wrapper_splice_to_pipe(pipe, &spd);
+}
+
+ssize_t lib_ring_buffer_splice_read(struct file *in, loff_t *ppos,
+                                   struct pipe_inode_info *pipe, size_t len,
+                                   unsigned int flags,
+                                   struct lib_ring_buffer *buf)
+{
+       struct channel *chan = buf->backend.chan;
+       const struct lib_ring_buffer_config *config = &chan->backend.config;
+       ssize_t spliced;
+       int ret;
+
+       if (config->output != RING_BUFFER_SPLICE)
+               return -EINVAL;
+
+       /*
+        * We require ppos and length to be page-aligned for performance reasons
+        * (no page copy). Size is known using the ioctl
+        * RING_BUFFER_GET_PADDED_SUBBUF_SIZE, which is page-size padded.
+        * We fail when the ppos or len passed is not page-sized, because splice
+        * is not allowed to copy more than the length passed as parameter (so
+        * the ABI does not let us silently copy more than requested to include
+        * padding).
+        */
+       if (*ppos != PAGE_ALIGN(*ppos) || len != PAGE_ALIGN(len))
+               return -EINVAL;
+
+       ret = 0;
+       spliced = 0;
+
+       printk_dbg(KERN_DEBUG "SPLICE read len %zu pos %zd\n", len,
+                  (ssize_t)*ppos);
+       while (len && !spliced) {
+               ret = subbuf_splice_actor(in, ppos, pipe, len, flags, buf);
+               printk_dbg(KERN_DEBUG "SPLICE read loop ret %d\n", ret);
+               if (ret < 0)
+                       break;
+               else if (!ret) {
+                       if (flags & SPLICE_F_NONBLOCK)
+                               ret = -EAGAIN;
+                       break;
+               }
+
+               *ppos += ret;
+               if (ret > len)
+                       len = 0;
+               else
+                       len -= ret;
+               spliced += ret;
+       }
+
+       if (spliced)
+               return spliced;
+
+       return ret;
+}
+EXPORT_SYMBOL_GPL(lib_ring_buffer_splice_read);
+
+ssize_t vfs_lib_ring_buffer_splice_read(struct file *in, loff_t *ppos,
+                                   struct pipe_inode_info *pipe, size_t len,
+                                   unsigned int flags)
+{
+       struct lib_ring_buffer *buf = in->private_data;
+
+       return lib_ring_buffer_splice_read(in, ppos, pipe, len, flags, buf);
+}
+EXPORT_SYMBOL_GPL(vfs_lib_ring_buffer_splice_read);
diff --git a/drivers/staging/lttng/lib/ringbuffer/ring_buffer_vfs.c b/drivers/staging/lttng/lib/ringbuffer/ring_buffer_vfs.c
new file mode 100644 (file)
index 0000000..dae73de
--- /dev/null
@@ -0,0 +1,450 @@
+/*
+ * ring_buffer_vfs.c
+ *
+ * Ring Buffer VFS file operations.
+ *
+ * Copyright (C) 2010-2012 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; only
+ * version 2.1 of the License.
+ *
+ * This library 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
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include <linux/module.h>
+#include <linux/fs.h>
+#include <linux/compat.h>
+
+#include "../../wrapper/ringbuffer/backend.h"
+#include "../../wrapper/ringbuffer/frontend.h"
+#include "../../wrapper/ringbuffer/vfs.h"
+#include "../../wrapper/poll.h"
+
+static int put_ulong(unsigned long val, unsigned long arg)
+{
+       return put_user(val, (unsigned long __user *)arg);
+}
+
+#ifdef CONFIG_COMPAT
+static int compat_put_ulong(compat_ulong_t val, unsigned long arg)
+{
+       return put_user(val, (compat_ulong_t __user *)compat_ptr(arg));
+}
+#endif
+
+/*
+ * This is not used by anonymous file descriptors. This code is left
+ * there if we ever want to implement an inode with open() operation.
+ */
+int lib_ring_buffer_open(struct inode *inode, struct file *file,
+               struct lib_ring_buffer *buf)
+{
+       int ret;
+
+       if (!buf)
+               return -EINVAL;
+
+       ret = lib_ring_buffer_open_read(buf);
+       if (ret)
+               return ret;
+
+       ret = nonseekable_open(inode, file);
+       if (ret)
+               goto release_read;
+       return 0;
+
+release_read:
+       lib_ring_buffer_release_read(buf);
+       return ret;
+}
+EXPORT_SYMBOL_GPL(lib_ring_buffer_open);
+
+/**
+ *     vfs_lib_ring_buffer_open - ring buffer open file operation
+ *     @inode: opened inode
+ *     @file: opened file
+ *
+ *     Open implementation. Makes sure only one open instance of a buffer is
+ *     done at a given moment.
+ */
+static
+int vfs_lib_ring_buffer_open(struct inode *inode, struct file *file)
+{
+       struct lib_ring_buffer *buf = inode->i_private;
+
+       file->private_data = buf;
+       return lib_ring_buffer_open(inode, file, buf);
+}
+
+int lib_ring_buffer_release(struct inode *inode, struct file *file,
+               struct lib_ring_buffer *buf)
+{
+       lib_ring_buffer_release_read(buf);
+
+       return 0;
+}
+EXPORT_SYMBOL_GPL(lib_ring_buffer_release);
+
+/**
+ *     vfs_lib_ring_buffer_release - ring buffer release file operation
+ *     @inode: opened inode
+ *     @file: opened file
+ *
+ *     Release implementation.
+ */
+static
+int vfs_lib_ring_buffer_release(struct inode *inode, struct file *file)
+{
+       struct lib_ring_buffer *buf = file->private_data;
+
+       return lib_ring_buffer_release(inode, file, buf);
+}
+
+unsigned int lib_ring_buffer_poll(struct file *filp, poll_table *wait,
+               struct lib_ring_buffer *buf)
+{
+       unsigned int mask = 0;
+       struct channel *chan = buf->backend.chan;
+       const struct lib_ring_buffer_config *config = &chan->backend.config;
+       int finalized, disabled;
+
+       if (filp->f_mode & FMODE_READ) {
+               poll_wait_set_exclusive(wait);
+               poll_wait(filp, &buf->read_wait, wait);
+
+               finalized = lib_ring_buffer_is_finalized(config, buf);
+               disabled = lib_ring_buffer_channel_is_disabled(chan);
+
+               /*
+                * lib_ring_buffer_is_finalized() contains a smp_rmb() ordering
+                * finalized load before offsets loads.
+                */
+               WARN_ON(atomic_long_read(&buf->active_readers) != 1);
+retry:
+               if (disabled)
+                       return POLLERR;
+
+               if (subbuf_trunc(lib_ring_buffer_get_offset(config, buf), chan)
+                 - subbuf_trunc(lib_ring_buffer_get_consumed(config, buf), chan)
+                 == 0) {
+                       if (finalized)
+                               return POLLHUP;
+                       else {
+                               /*
+                                * The memory barriers
+                                * __wait_event()/wake_up_interruptible() take
+                                * care of "raw_spin_is_locked" memory ordering.
+                                */
+                               if (raw_spin_is_locked(&buf->raw_tick_nohz_spinlock))
+                                       goto retry;
+                               else
+                                       return 0;
+                       }
+               } else {
+                       if (subbuf_trunc(lib_ring_buffer_get_offset(config, buf),
+                                        chan)
+                         - subbuf_trunc(lib_ring_buffer_get_consumed(config, buf),
+                                        chan)
+                         >= chan->backend.buf_size)
+                               return POLLPRI | POLLRDBAND;
+                       else
+                               return POLLIN | POLLRDNORM;
+               }
+       }
+       return mask;
+}
+EXPORT_SYMBOL_GPL(lib_ring_buffer_poll);
+
+/**
+ *     vfs_lib_ring_buffer_poll - ring buffer poll file operation
+ *     @filp: the file
+ *     @wait: poll table
+ *
+ *     Poll implementation.
+ */
+static
+unsigned int vfs_lib_ring_buffer_poll(struct file *filp, poll_table *wait)
+{
+       struct lib_ring_buffer *buf = filp->private_data;
+
+       return lib_ring_buffer_poll(filp, wait, buf);
+}
+
+long lib_ring_buffer_ioctl(struct file *filp, unsigned int cmd,
+               unsigned long arg, struct lib_ring_buffer *buf)
+{
+       struct channel *chan = buf->backend.chan;
+       const struct lib_ring_buffer_config *config = &chan->backend.config;
+
+       if (lib_ring_buffer_channel_is_disabled(chan))
+               return -EIO;
+
+       switch (cmd) {
+       case RING_BUFFER_SNAPSHOT:
+               return lib_ring_buffer_snapshot(buf, &buf->cons_snapshot,
+                                           &buf->prod_snapshot);
+       case RING_BUFFER_SNAPSHOT_GET_CONSUMED:
+               return put_ulong(buf->cons_snapshot, arg);
+       case RING_BUFFER_SNAPSHOT_GET_PRODUCED:
+               return put_ulong(buf->prod_snapshot, arg);
+       case RING_BUFFER_GET_SUBBUF:
+       {
+               unsigned long uconsume;
+               long ret;
+
+               ret = get_user(uconsume, (unsigned long __user *) arg);
+               if (ret)
+                       return ret; /* will return -EFAULT */
+               ret = lib_ring_buffer_get_subbuf(buf, uconsume);
+               if (!ret) {
+                       /* Set file position to zero at each successful "get" */
+                       filp->f_pos = 0;
+               }
+               return ret;
+       }
+       case RING_BUFFER_PUT_SUBBUF:
+               lib_ring_buffer_put_subbuf(buf);
+               return 0;
+
+       case RING_BUFFER_GET_NEXT_SUBBUF:
+       {
+               long ret;
+
+               ret = lib_ring_buffer_get_next_subbuf(buf);
+               if (!ret) {
+                       /* Set file position to zero at each successful "get" */
+                       filp->f_pos = 0;
+               }
+               return ret;
+       }
+       case RING_BUFFER_PUT_NEXT_SUBBUF:
+               lib_ring_buffer_put_next_subbuf(buf);
+               return 0;
+       case RING_BUFFER_GET_SUBBUF_SIZE:
+               return put_ulong(lib_ring_buffer_get_read_data_size(config, buf),
+                                arg);
+       case RING_BUFFER_GET_PADDED_SUBBUF_SIZE:
+       {
+               unsigned long size;
+
+               size = lib_ring_buffer_get_read_data_size(config, buf);
+               size = PAGE_ALIGN(size);
+               return put_ulong(size, arg);
+       }
+       case RING_BUFFER_GET_MAX_SUBBUF_SIZE:
+               return put_ulong(chan->backend.subbuf_size, arg);
+       case RING_BUFFER_GET_MMAP_LEN:
+       {
+               unsigned long mmap_buf_len;
+
+               if (config->output != RING_BUFFER_MMAP)
+                       return -EINVAL;
+               mmap_buf_len = chan->backend.buf_size;
+               if (chan->backend.extra_reader_sb)
+                       mmap_buf_len += chan->backend.subbuf_size;
+               if (mmap_buf_len > INT_MAX)
+                       return -EFBIG;
+               return put_ulong(mmap_buf_len, arg);
+       }
+       case RING_BUFFER_GET_MMAP_READ_OFFSET:
+       {
+               unsigned long sb_bindex;
+
+               if (config->output != RING_BUFFER_MMAP)
+                       return -EINVAL;
+               sb_bindex = subbuffer_id_get_index(config,
+                                                  buf->backend.buf_rsb.id);
+               return put_ulong(buf->backend.array[sb_bindex]->mmap_offset,
+                                arg);
+       }
+       case RING_BUFFER_FLUSH:
+               lib_ring_buffer_switch_remote(buf);
+               return 0;
+       default:
+               return -ENOIOCTLCMD;
+       }
+}
+EXPORT_SYMBOL_GPL(lib_ring_buffer_ioctl);
+
+/**
+ *     vfs_lib_ring_buffer_ioctl - control ring buffer reader synchronization
+ *
+ *     @filp: the file
+ *     @cmd: the command
+ *     @arg: command arg
+ *
+ *     This ioctl implements commands necessary for producer/consumer
+ *     and flight recorder reader interaction :
+ *     RING_BUFFER_GET_NEXT_SUBBUF
+ *             Get the next sub-buffer that can be read. It never blocks.
+ *     RING_BUFFER_PUT_NEXT_SUBBUF
+ *             Release the currently read sub-buffer.
+ *     RING_BUFFER_GET_SUBBUF_SIZE
+ *             returns the size of the current sub-buffer.
+ *     RING_BUFFER_GET_MAX_SUBBUF_SIZE
+ *             returns the maximum size for sub-buffers.
+ *     RING_BUFFER_GET_NUM_SUBBUF
+ *             returns the number of reader-visible sub-buffers in the per cpu
+ *              channel (for mmap).
+ *      RING_BUFFER_GET_MMAP_READ_OFFSET
+ *              returns the offset of the subbuffer belonging to the reader.
+ *              Should only be used for mmap clients.
+ */
+static
+long vfs_lib_ring_buffer_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
+{
+       struct lib_ring_buffer *buf = filp->private_data;
+
+       return lib_ring_buffer_ioctl(filp, cmd, arg, buf);
+}
+
+#ifdef CONFIG_COMPAT
+long lib_ring_buffer_compat_ioctl(struct file *filp, unsigned int cmd,
+               unsigned long arg, struct lib_ring_buffer *buf)
+{
+       struct channel *chan = buf->backend.chan;
+       const struct lib_ring_buffer_config *config = &chan->backend.config;
+
+       if (lib_ring_buffer_channel_is_disabled(chan))
+               return -EIO;
+
+       switch (cmd) {
+       case RING_BUFFER_COMPAT_SNAPSHOT:
+               return lib_ring_buffer_snapshot(buf, &buf->cons_snapshot,
+                                               &buf->prod_snapshot);
+       case RING_BUFFER_COMPAT_SNAPSHOT_GET_CONSUMED:
+               return compat_put_ulong(buf->cons_snapshot, arg);
+       case RING_BUFFER_COMPAT_SNAPSHOT_GET_PRODUCED:
+               return compat_put_ulong(buf->prod_snapshot, arg);
+       case RING_BUFFER_COMPAT_GET_SUBBUF:
+       {
+               __u32 uconsume;
+               unsigned long consume;
+               long ret;
+
+               ret = get_user(uconsume, (__u32 __user *) arg);
+               if (ret)
+                       return ret; /* will return -EFAULT */
+               consume = buf->cons_snapshot;
+               consume &= ~0xFFFFFFFFL;
+               consume |= uconsume;
+               ret = lib_ring_buffer_get_subbuf(buf, consume);
+               if (!ret) {
+                       /* Set file position to zero at each successful "get" */
+                       filp->f_pos = 0;
+               }
+               return ret;
+       }
+       case RING_BUFFER_COMPAT_PUT_SUBBUF:
+               lib_ring_buffer_put_subbuf(buf);
+               return 0;
+
+       case RING_BUFFER_COMPAT_GET_NEXT_SUBBUF:
+       {
+               long ret;
+
+               ret = lib_ring_buffer_get_next_subbuf(buf);
+               if (!ret) {
+                       /* Set file position to zero at each successful "get" */
+                       filp->f_pos = 0;
+               }
+               return ret;
+       }
+       case RING_BUFFER_COMPAT_PUT_NEXT_SUBBUF:
+               lib_ring_buffer_put_next_subbuf(buf);
+               return 0;
+       case RING_BUFFER_COMPAT_GET_SUBBUF_SIZE:
+       {
+               unsigned long data_size;
+
+               data_size = lib_ring_buffer_get_read_data_size(config, buf);
+               if (data_size > UINT_MAX)
+                       return -EFBIG;
+               return compat_put_ulong(data_size, arg);
+       }
+       case RING_BUFFER_COMPAT_GET_PADDED_SUBBUF_SIZE:
+       {
+               unsigned long size;
+
+               size = lib_ring_buffer_get_read_data_size(config, buf);
+               size = PAGE_ALIGN(size);
+               if (size > UINT_MAX)
+                       return -EFBIG;
+               return compat_put_ulong(size, arg);
+       }
+       case RING_BUFFER_COMPAT_GET_MAX_SUBBUF_SIZE:
+               if (chan->backend.subbuf_size > UINT_MAX)
+                       return -EFBIG;
+               return compat_put_ulong(chan->backend.subbuf_size, arg);
+       case RING_BUFFER_COMPAT_GET_MMAP_LEN:
+       {
+               unsigned long mmap_buf_len;
+
+               if (config->output != RING_BUFFER_MMAP)
+                       return -EINVAL;
+               mmap_buf_len = chan->backend.buf_size;
+               if (chan->backend.extra_reader_sb)
+                       mmap_buf_len += chan->backend.subbuf_size;
+               if (mmap_buf_len > UINT_MAX)
+                       return -EFBIG;
+               return compat_put_ulong(mmap_buf_len, arg);
+       }
+       case RING_BUFFER_COMPAT_GET_MMAP_READ_OFFSET:
+       {
+               unsigned long sb_bindex, read_offset;
+
+               if (config->output != RING_BUFFER_MMAP)
+                       return -EINVAL;
+               sb_bindex = subbuffer_id_get_index(config,
+                                                  buf->backend.buf_rsb.id);
+               read_offset = buf->backend.array[sb_bindex]->mmap_offset;
+               if (read_offset > UINT_MAX)
+                       return -EINVAL;
+               return compat_put_ulong(read_offset, arg);
+       }
+       case RING_BUFFER_COMPAT_FLUSH:
+               lib_ring_buffer_switch_remote(buf);
+               return 0;
+       default:
+               return -ENOIOCTLCMD;
+       }
+}
+EXPORT_SYMBOL_GPL(lib_ring_buffer_compat_ioctl);
+
+static
+long vfs_lib_ring_buffer_compat_ioctl(struct file *filp, unsigned int cmd,
+                                 unsigned long arg)
+{
+       struct lib_ring_buffer *buf = filp->private_data;
+
+       return lib_ring_buffer_compat_ioctl(filp, cmd, arg, buf);
+}
+#endif
+
+const struct file_operations lib_ring_buffer_file_operations = {
+       .owner = THIS_MODULE,
+       .open = vfs_lib_ring_buffer_open,
+       .release = vfs_lib_ring_buffer_release,
+       .poll = vfs_lib_ring_buffer_poll,
+       .splice_read = vfs_lib_ring_buffer_splice_read,
+       .mmap = vfs_lib_ring_buffer_mmap,
+       .unlocked_ioctl = vfs_lib_ring_buffer_ioctl,
+       .llseek = vfs_lib_ring_buffer_no_llseek,
+#ifdef CONFIG_COMPAT
+       .compat_ioctl = vfs_lib_ring_buffer_compat_ioctl,
+#endif
+};
+EXPORT_SYMBOL_GPL(lib_ring_buffer_file_operations);
+
+MODULE_LICENSE("GPL and additional rights");
+MODULE_AUTHOR("Mathieu Desnoyers");
+MODULE_DESCRIPTION("Ring Buffer Library VFS");
diff --git a/drivers/staging/lttng/lib/ringbuffer/vatomic.h b/drivers/staging/lttng/lib/ringbuffer/vatomic.h
new file mode 100644 (file)
index 0000000..1a3eaaa
--- /dev/null
@@ -0,0 +1,97 @@
+#ifndef _LIB_RING_BUFFER_VATOMIC_H
+#define _LIB_RING_BUFFER_VATOMIC_H
+
+/*
+ * lib/ringbuffer/vatomic.h
+ *
+ * Copyright (C) 2010-2012 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; only
+ * version 2.1 of the License.
+ *
+ * This library 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
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include <asm/atomic.h>
+#include <asm/local.h>
+
+/*
+ * Same data type (long) accessed differently depending on configuration.
+ * v field is for non-atomic access (protected by mutual exclusion).
+ * In the fast-path, the ring_buffer_config structure is constant, so the
+ * compiler can statically select the appropriate branch.
+ * local_t is used for per-cpu and per-thread buffers.
+ * atomic_long_t is used for globally shared buffers.
+ */
+union v_atomic {
+       local_t l;
+       atomic_long_t a;
+       long v;
+};
+
+static inline
+long v_read(const struct lib_ring_buffer_config *config, union v_atomic *v_a)
+{
+       if (config->sync == RING_BUFFER_SYNC_PER_CPU)
+               return local_read(&v_a->l);
+       else
+               return atomic_long_read(&v_a->a);
+}
+
+static inline
+void v_set(const struct lib_ring_buffer_config *config, union v_atomic *v_a,
+          long v)
+{
+       if (config->sync == RING_BUFFER_SYNC_PER_CPU)
+               local_set(&v_a->l, v);
+       else
+               atomic_long_set(&v_a->a, v);
+}
+
+static inline
+void v_add(const struct lib_ring_buffer_config *config, long v, union v_atomic *v_a)
+{
+       if (config->sync == RING_BUFFER_SYNC_PER_CPU)
+               local_add(v, &v_a->l);
+       else
+               atomic_long_add(v, &v_a->a);
+}
+
+static inline
+void v_inc(const struct lib_ring_buffer_config *config, union v_atomic *v_a)
+{
+       if (config->sync == RING_BUFFER_SYNC_PER_CPU)
+               local_inc(&v_a->l);
+       else
+               atomic_long_inc(&v_a->a);
+}
+
+/*
+ * Non-atomic decrement. Only used by reader, apply to reader-owned subbuffer.
+ */
+static inline
+void _v_dec(const struct lib_ring_buffer_config *config, union v_atomic *v_a)
+{
+       --v_a->v;
+}
+
+static inline
+long v_cmpxchg(const struct lib_ring_buffer_config *config, union v_atomic *v_a,
+              long old, long _new)
+{
+       if (config->sync == RING_BUFFER_SYNC_PER_CPU)
+               return local_cmpxchg(&v_a->l, old, _new);
+       else
+               return atomic_long_cmpxchg(&v_a->a, old, _new);
+}
+
+#endif /* _LIB_RING_BUFFER_VATOMIC_H */
diff --git a/drivers/staging/lttng/lib/ringbuffer/vfs.h b/drivers/staging/lttng/lib/ringbuffer/vfs.h
new file mode 100644 (file)
index 0000000..ea317a1
--- /dev/null
@@ -0,0 +1,150 @@
+#ifndef _LIB_RING_BUFFER_VFS_H
+#define _LIB_RING_BUFFER_VFS_H
+
+/*
+ * lib/ringbuffer/vfs.h
+ *
+ * Wait-free ring buffer VFS file operations.
+ *
+ * Copyright (C) 2005-2012 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; only
+ * version 2.1 of the License.
+ *
+ * This library 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
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ * Author:
+ *     Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
+ */
+
+#include <linux/fs.h>
+#include <linux/poll.h>
+
+/* VFS API */
+
+extern const struct file_operations lib_ring_buffer_file_operations;
+
+/*
+ * Internal file operations.
+ */
+
+struct lib_ring_buffer;
+
+int lib_ring_buffer_open(struct inode *inode, struct file *file,
+               struct lib_ring_buffer *buf);
+int lib_ring_buffer_release(struct inode *inode, struct file *file,
+               struct lib_ring_buffer *buf);
+unsigned int lib_ring_buffer_poll(struct file *filp, poll_table *wait,
+               struct lib_ring_buffer *buf);
+ssize_t lib_ring_buffer_splice_read(struct file *in, loff_t *ppos,
+               struct pipe_inode_info *pipe, size_t len,
+               unsigned int flags, struct lib_ring_buffer *buf);
+int lib_ring_buffer_mmap(struct file *filp, struct vm_area_struct *vma,
+               struct lib_ring_buffer *buf);
+
+/* Ring Buffer ioctl() and ioctl numbers */
+long lib_ring_buffer_ioctl(struct file *filp, unsigned int cmd,
+               unsigned long arg, struct lib_ring_buffer *buf);
+#ifdef CONFIG_COMPAT
+long lib_ring_buffer_compat_ioctl(struct file *filp, unsigned int cmd,
+               unsigned long arg, struct lib_ring_buffer *buf);
+#endif
+
+ssize_t vfs_lib_ring_buffer_file_splice_read(struct file *in, loff_t *ppos,
+               struct pipe_inode_info *pipe, size_t len, unsigned int flags);
+loff_t vfs_lib_ring_buffer_no_llseek(struct file *file, loff_t offset,
+               int origin);
+int vfs_lib_ring_buffer_mmap(struct file *filp, struct vm_area_struct *vma);
+ssize_t vfs_lib_ring_buffer_splice_read(struct file *in, loff_t *ppos,
+               struct pipe_inode_info *pipe, size_t len,
+               unsigned int flags);
+
+/*
+ * Use RING_BUFFER_GET_NEXT_SUBBUF / RING_BUFFER_PUT_NEXT_SUBBUF to read and
+ * consume sub-buffers sequentially.
+ *
+ * Reading sub-buffers without consuming them can be performed with:
+ *
+ * RING_BUFFER_SNAPSHOT
+ * RING_BUFFER_SNAPSHOT_GET_CONSUMED
+ * RING_BUFFER_SNAPSHOT_GET_PRODUCED
+ *
+ * to get the offset range to consume, and then by passing each sub-buffer
+ * offset to RING_BUFFER_GET_SUBBUF, read the sub-buffer, and then release it
+ * with RING_BUFFER_PUT_SUBBUF.
+ *
+ * Note that the "snapshot" API can be used to read the sub-buffer in reverse
+ * order, which is useful for flight recorder snapshots.
+ */
+
+/* Get a snapshot of the current ring buffer producer and consumer positions */
+#define RING_BUFFER_SNAPSHOT                   _IO(0xF6, 0x00)
+/* Get the consumer position (iteration start) */
+#define RING_BUFFER_SNAPSHOT_GET_CONSUMED      _IOR(0xF6, 0x01, unsigned long)
+/* Get the producer position (iteration end) */
+#define RING_BUFFER_SNAPSHOT_GET_PRODUCED      _IOR(0xF6, 0x02, unsigned long)
+/* Get exclusive read access to the specified sub-buffer position */
+#define RING_BUFFER_GET_SUBBUF                 _IOW(0xF6, 0x03, unsigned long)
+/* Release exclusive sub-buffer access */
+#define RING_BUFFER_PUT_SUBBUF                 _IO(0xF6, 0x04)
+
+/* Get exclusive read access to the next sub-buffer that can be read. */
+#define RING_BUFFER_GET_NEXT_SUBBUF            _IO(0xF6, 0x05)
+/* Release exclusive sub-buffer access, move consumer forward. */
+#define RING_BUFFER_PUT_NEXT_SUBBUF            _IO(0xF6, 0x06)
+/* returns the size of the current sub-buffer, without padding (for mmap). */
+#define RING_BUFFER_GET_SUBBUF_SIZE            _IOR(0xF6, 0x07, unsigned long)
+/* returns the size of the current sub-buffer, with padding (for splice). */
+#define RING_BUFFER_GET_PADDED_SUBBUF_SIZE     _IOR(0xF6, 0x08, unsigned long)
+/* returns the maximum size for sub-buffers. */
+#define RING_BUFFER_GET_MAX_SUBBUF_SIZE                _IOR(0xF6, 0x09, unsigned long)
+/* returns the length to mmap. */
+#define RING_BUFFER_GET_MMAP_LEN               _IOR(0xF6, 0x0A, unsigned long)
+/* returns the offset of the subbuffer belonging to the mmap reader. */
+#define RING_BUFFER_GET_MMAP_READ_OFFSET       _IOR(0xF6, 0x0B, unsigned long)
+/* flush the current sub-buffer */
+#define RING_BUFFER_FLUSH                      _IO(0xF6, 0x0C)
+
+#ifdef CONFIG_COMPAT
+/* Get a snapshot of the current ring buffer producer and consumer positions */
+#define RING_BUFFER_COMPAT_SNAPSHOT            RING_BUFFER_SNAPSHOT
+/* Get the consumer position (iteration start) */
+#define RING_BUFFER_COMPAT_SNAPSHOT_GET_CONSUMED \
+       _IOR(0xF6, 0x01, compat_ulong_t)
+/* Get the producer position (iteration end) */
+#define RING_BUFFER_COMPAT_SNAPSHOT_GET_PRODUCED \
+       _IOR(0xF6, 0x02, compat_ulong_t)
+/* Get exclusive read access to the specified sub-buffer position */
+#define RING_BUFFER_COMPAT_GET_SUBBUF          _IOW(0xF6, 0x03, compat_ulong_t)
+/* Release exclusive sub-buffer access */
+#define RING_BUFFER_COMPAT_PUT_SUBBUF          RING_BUFFER_PUT_SUBBUF
+
+/* Get exclusive read access to the next sub-buffer that can be read. */
+#define RING_BUFFER_COMPAT_GET_NEXT_SUBBUF     RING_BUFFER_GET_NEXT_SUBBUF
+/* Release exclusive sub-buffer access, move consumer forward. */
+#define RING_BUFFER_COMPAT_PUT_NEXT_SUBBUF     RING_BUFFER_PUT_NEXT_SUBBUF
+/* returns the size of the current sub-buffer, without padding (for mmap). */
+#define RING_BUFFER_COMPAT_GET_SUBBUF_SIZE     _IOR(0xF6, 0x07, compat_ulong_t)
+/* returns the size of the current sub-buffer, with padding (for splice). */
+#define RING_BUFFER_COMPAT_GET_PADDED_SUBBUF_SIZE \
+       _IOR(0xF6, 0x08, compat_ulong_t)
+/* returns the maximum size for sub-buffers. */
+#define RING_BUFFER_COMPAT_GET_MAX_SUBBUF_SIZE _IOR(0xF6, 0x09, compat_ulong_t)
+/* returns the length to mmap. */
+#define RING_BUFFER_COMPAT_GET_MMAP_LEN                _IOR(0xF6, 0x0A, compat_ulong_t)
+/* returns the offset of the subbuffer belonging to the mmap reader. */
+#define RING_BUFFER_COMPAT_GET_MMAP_READ_OFFSET        _IOR(0xF6, 0x0B, compat_ulong_t)
+/* flush the current sub-buffer */
+#define RING_BUFFER_COMPAT_FLUSH               RING_BUFFER_FLUSH
+#endif /* CONFIG_COMPAT */
+
+#endif /* _LIB_RING_BUFFER_VFS_H */
diff --git a/drivers/staging/lttng/lttng-abi-old.h b/drivers/staging/lttng/lttng-abi-old.h
new file mode 100644 (file)
index 0000000..3e6b328
--- /dev/null
@@ -0,0 +1,141 @@
+#ifndef _LTTNG_ABI_OLD_H
+#define _LTTNG_ABI_OLD_H
+
+/*
+ * lttng-abi-old.h
+ *
+ * LTTng old ABI header (without support for compat 32/64 bits)
+ *
+ * Copyright (C) 2010-2012 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; only
+ * version 2.1 of the License.
+ *
+ * This library 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
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include <linux/fs.h>
+#include "lttng-abi.h"
+
+/*
+ * LTTng DebugFS ABI structures.
+ */
+#define LTTNG_KERNEL_OLD_CHANNEL_PADDING       LTTNG_KERNEL_SYM_NAME_LEN + 32
+struct lttng_kernel_old_channel {
+       int overwrite;                          /* 1: overwrite, 0: discard */
+       uint64_t subbuf_size;                   /* in bytes */
+       uint64_t num_subbuf;
+       unsigned int switch_timer_interval;     /* usecs */
+       unsigned int read_timer_interval;       /* usecs */
+       enum lttng_kernel_output output;        /* splice, mmap */
+       char padding[LTTNG_KERNEL_OLD_CHANNEL_PADDING];
+};
+
+struct lttng_kernel_old_kretprobe {
+       uint64_t addr;
+
+       uint64_t offset;
+       char symbol_name[LTTNG_KERNEL_SYM_NAME_LEN];
+};
+
+/*
+ * Either addr is used, or symbol_name and offset.
+ */
+struct lttng_kernel_old_kprobe {
+       uint64_t addr;
+
+       uint64_t offset;
+       char symbol_name[LTTNG_KERNEL_SYM_NAME_LEN];
+};
+
+struct lttng_kernel_old_function_tracer {
+       char symbol_name[LTTNG_KERNEL_SYM_NAME_LEN];
+};
+
+/*
+ * For syscall tracing, name = '\0' means "enable all".
+ */
+#define LTTNG_KERNEL_OLD_EVENT_PADDING1        16
+#define LTTNG_KERNEL_OLD_EVENT_PADDING2        LTTNG_KERNEL_SYM_NAME_LEN + 32
+struct lttng_kernel_old_event {
+       char name[LTTNG_KERNEL_SYM_NAME_LEN];   /* event name */
+       enum lttng_kernel_instrumentation instrumentation;
+       char padding[LTTNG_KERNEL_OLD_EVENT_PADDING1];
+
+       /* Per instrumentation type configuration */
+       union {
+               struct lttng_kernel_old_kretprobe kretprobe;
+               struct lttng_kernel_old_kprobe kprobe;
+               struct lttng_kernel_old_function_tracer ftrace;
+               char padding[LTTNG_KERNEL_OLD_EVENT_PADDING2];
+       } u;
+};
+
+struct lttng_kernel_old_tracer_version {
+       uint32_t major;
+       uint32_t minor;
+       uint32_t patchlevel;
+};
+
+struct lttng_kernel_old_calibrate {
+       enum lttng_kernel_calibrate_type type;  /* type (input) */
+};
+
+struct lttng_kernel_old_perf_counter_ctx {
+       uint32_t type;
+       uint64_t config;
+       char name[LTTNG_KERNEL_SYM_NAME_LEN];
+};
+
+#define LTTNG_KERNEL_OLD_CONTEXT_PADDING1      16
+#define LTTNG_KERNEL_OLD_CONTEXT_PADDING2      LTTNG_KERNEL_SYM_NAME_LEN + 32
+struct lttng_kernel_old_context {
+       enum lttng_kernel_context_type ctx;
+       char padding[LTTNG_KERNEL_OLD_CONTEXT_PADDING1];
+
+       union {
+               struct lttng_kernel_old_perf_counter_ctx perf_counter;
+               char padding[LTTNG_KERNEL_OLD_CONTEXT_PADDING2];
+       } u;
+};
+
+/* LTTng file descriptor ioctl */
+#define LTTNG_KERNEL_OLD_SESSION               _IO(0xF6, 0x40)
+#define LTTNG_KERNEL_OLD_TRACER_VERSION                \
+       _IOR(0xF6, 0x41, struct lttng_kernel_old_tracer_version)
+#define LTTNG_KERNEL_OLD_TRACEPOINT_LIST       _IO(0xF6, 0x42)
+#define LTTNG_KERNEL_OLD_WAIT_QUIESCENT                _IO(0xF6, 0x43)
+#define LTTNG_KERNEL_OLD_CALIBRATE             \
+       _IOWR(0xF6, 0x44, struct lttng_kernel_old_calibrate)
+
+/* Session FD ioctl */
+#define LTTNG_KERNEL_OLD_METADATA              \
+       _IOW(0xF6, 0x50, struct lttng_kernel_old_channel)
+#define LTTNG_KERNEL_OLD_CHANNEL               \
+       _IOW(0xF6, 0x51, struct lttng_kernel_old_channel)
+#define LTTNG_KERNEL_OLD_SESSION_START         _IO(0xF6, 0x52)
+#define LTTNG_KERNEL_OLD_SESSION_STOP          _IO(0xF6, 0x53)
+
+/* Channel FD ioctl */
+#define LTTNG_KERNEL_OLD_STREAM                        _IO(0xF6, 0x60)
+#define LTTNG_KERNEL_OLD_EVENT                 \
+       _IOW(0xF6, 0x61, struct lttng_kernel_old_event)
+
+/* Event and Channel FD ioctl */
+#define LTTNG_KERNEL_OLD_CONTEXT               \
+       _IOW(0xF6, 0x70, struct lttng_kernel_old_context)
+
+/* Event, Channel and Session ioctl */
+#define LTTNG_KERNEL_OLD_ENABLE                        _IO(0xF6, 0x80)
+#define LTTNG_KERNEL_OLD_DISABLE               _IO(0xF6, 0x81)
+
+#endif /* _LTTNG_ABI_OLD_H */
diff --git a/drivers/staging/lttng/lttng-abi.c b/drivers/staging/lttng/lttng-abi.c
new file mode 100644 (file)
index 0000000..d1ea052
--- /dev/null
@@ -0,0 +1,1346 @@
+/*
+ * lttng-abi.c
+ *
+ * LTTng ABI
+ *
+ * Copyright (C) 2010-2012 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; only
+ * version 2.1 of the License.
+ *
+ * This library 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
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ *
+ * Mimic system calls for:
+ * - session creation, returns a file descriptor or failure.
+ *   - channel creation, returns a file descriptor or failure.
+ *     - Operates on a session file descriptor
+ *     - Takes all channel options as parameters.
+ *   - stream get, returns a file descriptor or failure.
+ *     - Operates on a channel file descriptor.
+ *   - stream notifier get, returns a file descriptor or failure.
+ *     - Operates on a channel file descriptor.
+ *   - event creation, returns a file descriptor or failure.
+ *     - Operates on a channel file descriptor
+ *     - Takes an event name as parameter
+ *     - Takes an instrumentation source as parameter
+ *       - e.g. tracepoints, dynamic_probes...
+ *     - Takes instrumentation source specific arguments.
+ */
+
+#include <linux/module.h>
+#include <linux/proc_fs.h>
+#include <linux/anon_inodes.h>
+#include <linux/file.h>
+#include <linux/uaccess.h>
+#include <linux/slab.h>
+#include "wrapper/vmalloc.h"   /* for wrapper_vmalloc_sync_all() */
+#include "wrapper/ringbuffer/vfs.h"
+#include "wrapper/ringbuffer/backend.h"
+#include "wrapper/ringbuffer/frontend.h"
+#include "wrapper/poll.h"
+#include "lttng-abi.h"
+#include "lttng-abi-old.h"
+#include "lttng-events.h"
+#include "lttng-tracer.h"
+
+/*
+ * This is LTTng's own personal way to create a system call as an external
+ * module. We use ioctl() on /proc/lttng.
+ */
+
+static struct proc_dir_entry *lttng_proc_dentry;
+static const struct file_operations lttng_fops;
+static const struct file_operations lttng_session_fops;
+static const struct file_operations lttng_channel_fops;
+static const struct file_operations lttng_metadata_fops;
+static const struct file_operations lttng_event_fops;
+
+/*
+ * Teardown management: opened file descriptors keep a refcount on the module,
+ * so it can only exit when all file descriptors are closed.
+ */
+
+static
+int lttng_abi_create_session(void)
+{
+       struct lttng_session *session;
+       struct file *session_file;
+       int session_fd, ret;
+
+       session = lttng_session_create();
+       if (!session)
+               return -ENOMEM;
+       session_fd = get_unused_fd();
+       if (session_fd < 0) {
+               ret = session_fd;
+               goto fd_error;
+       }
+       session_file = anon_inode_getfile("[lttng_session]",
+                                         &lttng_session_fops,
+                                         session, O_RDWR);
+       if (IS_ERR(session_file)) {
+               ret = PTR_ERR(session_file);
+               goto file_error;
+       }
+       session->file = session_file;
+       fd_install(session_fd, session_file);
+       return session_fd;
+
+file_error:
+       put_unused_fd(session_fd);
+fd_error:
+       lttng_session_destroy(session);
+       return ret;
+}
+
+static
+int lttng_abi_tracepoint_list(void)
+{
+       struct file *tracepoint_list_file;
+       int file_fd, ret;
+
+       file_fd = get_unused_fd();
+       if (file_fd < 0) {
+               ret = file_fd;
+               goto fd_error;
+       }
+
+       tracepoint_list_file = anon_inode_getfile("[lttng_session]",
+                                         &lttng_tracepoint_list_fops,
+                                         NULL, O_RDWR);
+       if (IS_ERR(tracepoint_list_file)) {
+               ret = PTR_ERR(tracepoint_list_file);
+               goto file_error;
+       }
+       ret = lttng_tracepoint_list_fops.open(NULL, tracepoint_list_file);
+       if (ret < 0)
+               goto open_error;
+       fd_install(file_fd, tracepoint_list_file);
+       if (file_fd < 0) {
+               ret = file_fd;
+               goto fd_error;
+       }
+       return file_fd;
+
+open_error:
+       fput(tracepoint_list_file);
+file_error:
+       put_unused_fd(file_fd);
+fd_error:
+       return ret;
+}
+
+static
+void lttng_abi_tracer_version(struct lttng_kernel_tracer_version *v)
+{
+       v->major = LTTNG_MODULES_MAJOR_VERSION;
+       v->minor = LTTNG_MODULES_MINOR_VERSION;
+       v->patchlevel = LTTNG_MODULES_PATCHLEVEL_VERSION;
+}
+
+static
+long lttng_abi_add_context(struct file *file,
+       struct lttng_kernel_context *context_param,
+       struct lttng_ctx **ctx, struct lttng_session *session)
+{
+
+       if (session->been_active)
+               return -EPERM;
+
+       switch (context_param->ctx) {
+       case LTTNG_KERNEL_CONTEXT_PID:
+               return lttng_add_pid_to_ctx(ctx);
+       case LTTNG_KERNEL_CONTEXT_PRIO:
+               return lttng_add_prio_to_ctx(ctx);
+       case LTTNG_KERNEL_CONTEXT_NICE:
+               return lttng_add_nice_to_ctx(ctx);
+       case LTTNG_KERNEL_CONTEXT_VPID:
+               return lttng_add_vpid_to_ctx(ctx);
+       case LTTNG_KERNEL_CONTEXT_TID:
+               return lttng_add_tid_to_ctx(ctx);
+       case LTTNG_KERNEL_CONTEXT_VTID:
+               return lttng_add_vtid_to_ctx(ctx);
+       case LTTNG_KERNEL_CONTEXT_PPID:
+               return lttng_add_ppid_to_ctx(ctx);
+       case LTTNG_KERNEL_CONTEXT_VPPID:
+               return lttng_add_vppid_to_ctx(ctx);
+       case LTTNG_KERNEL_CONTEXT_PERF_COUNTER:
+               context_param->u.perf_counter.name[LTTNG_KERNEL_SYM_NAME_LEN - 1] = '\0';
+               return lttng_add_perf_counter_to_ctx(context_param->u.perf_counter.type,
+                               context_param->u.perf_counter.config,
+                               context_param->u.perf_counter.name,
+                               ctx);
+       case LTTNG_KERNEL_CONTEXT_PROCNAME:
+               return lttng_add_procname_to_ctx(ctx);
+       case LTTNG_KERNEL_CONTEXT_HOSTNAME:
+               return lttng_add_hostname_to_ctx(ctx);
+       default:
+               return -EINVAL;
+       }
+}
+
+/**
+ *     lttng_ioctl - lttng syscall through ioctl
+ *
+ *     @file: the file
+ *     @cmd: the command
+ *     @arg: command arg
+ *
+ *     This ioctl implements lttng commands:
+ *     LTTNG_KERNEL_SESSION
+ *             Returns a LTTng trace session file descriptor
+ *     LTTNG_KERNEL_TRACER_VERSION
+ *             Returns the LTTng kernel tracer version
+ *     LTTNG_KERNEL_TRACEPOINT_LIST
+ *             Returns a file descriptor listing available tracepoints
+ *     LTTNG_KERNEL_WAIT_QUIESCENT
+ *             Returns after all previously running probes have completed
+ *
+ * The returned session will be deleted when its file descriptor is closed.
+ */
+static
+long lttng_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
+{
+       switch (cmd) {
+       case LTTNG_KERNEL_OLD_SESSION:
+       case LTTNG_KERNEL_SESSION:
+               return lttng_abi_create_session();
+       case LTTNG_KERNEL_OLD_TRACER_VERSION:
+       {
+               struct lttng_kernel_tracer_version v;
+               struct lttng_kernel_old_tracer_version oldv;
+               struct lttng_kernel_old_tracer_version *uversion =
+                       (struct lttng_kernel_old_tracer_version __user *) arg;
+
+               lttng_abi_tracer_version(&v);
+               oldv.major = v.major;
+               oldv.minor = v.minor;
+               oldv.patchlevel = v.patchlevel;
+
+               if (copy_to_user(uversion, &oldv, sizeof(oldv)))
+                       return -EFAULT;
+               return 0;
+       }
+       case LTTNG_KERNEL_TRACER_VERSION:
+       {
+               struct lttng_kernel_tracer_version version;
+               struct lttng_kernel_tracer_version *uversion =
+                       (struct lttng_kernel_tracer_version __user *) arg;
+
+               lttng_abi_tracer_version(&version);
+
+               if (copy_to_user(uversion, &version, sizeof(version)))
+                       return -EFAULT;
+               return 0;
+       }
+       case LTTNG_KERNEL_OLD_TRACEPOINT_LIST:
+       case LTTNG_KERNEL_TRACEPOINT_LIST:
+               return lttng_abi_tracepoint_list();
+       case LTTNG_KERNEL_OLD_WAIT_QUIESCENT:
+       case LTTNG_KERNEL_WAIT_QUIESCENT:
+               synchronize_trace();
+               return 0;
+       case LTTNG_KERNEL_OLD_CALIBRATE:
+       {
+               struct lttng_kernel_old_calibrate __user *ucalibrate =
+                       (struct lttng_kernel_old_calibrate __user *) arg;
+               struct lttng_kernel_old_calibrate old_calibrate;
+               struct lttng_kernel_calibrate calibrate;
+               int ret;
+
+               if (copy_from_user(&old_calibrate, ucalibrate, sizeof(old_calibrate)))
+                       return -EFAULT;
+               calibrate.type = old_calibrate.type;
+               ret = lttng_calibrate(&calibrate);
+               if (copy_to_user(ucalibrate, &old_calibrate, sizeof(old_calibrate)))
+                       return -EFAULT;
+               return ret;
+       }
+       case LTTNG_KERNEL_CALIBRATE:
+       {
+               struct lttng_kernel_calibrate __user *ucalibrate =
+                       (struct lttng_kernel_calibrate __user *) arg;
+               struct lttng_kernel_calibrate calibrate;
+               int ret;
+
+               if (copy_from_user(&calibrate, ucalibrate, sizeof(calibrate)))
+                       return -EFAULT;
+               ret = lttng_calibrate(&calibrate);
+               if (copy_to_user(ucalibrate, &calibrate, sizeof(calibrate)))
+                       return -EFAULT;
+               return ret;
+       }
+       default:
+               return -ENOIOCTLCMD;
+       }
+}
+
+static const struct file_operations lttng_fops = {
+       .owner = THIS_MODULE,
+       .unlocked_ioctl = lttng_ioctl,
+#ifdef CONFIG_COMPAT
+       .compat_ioctl = lttng_ioctl,
+#endif
+};
+
+static
+int lttng_abi_create_channel(struct file *session_file,
+                            struct lttng_kernel_channel *chan_param,
+                            enum channel_type channel_type)
+{
+       struct lttng_session *session = session_file->private_data;
+       const struct file_operations *fops = NULL;
+       const char *transport_name;
+       struct lttng_channel *chan;
+       struct file *chan_file;
+       int chan_fd;
+       int ret = 0;
+
+       chan_fd = get_unused_fd();
+       if (chan_fd < 0) {
+               ret = chan_fd;
+               goto fd_error;
+       }
+       switch (channel_type) {
+       case PER_CPU_CHANNEL:
+               fops = &lttng_channel_fops;
+               break;
+       case METADATA_CHANNEL:
+               fops = &lttng_metadata_fops;
+               break;
+       }
+
+       chan_file = anon_inode_getfile("[lttng_channel]",
+                                      fops,
+                                      NULL, O_RDWR);
+       if (IS_ERR(chan_file)) {
+               ret = PTR_ERR(chan_file);
+               goto file_error;
+       }
+       switch (channel_type) {
+       case PER_CPU_CHANNEL:
+               if (chan_param->output == LTTNG_KERNEL_SPLICE) {
+                       transport_name = chan_param->overwrite ?
+                               "relay-overwrite" : "relay-discard";
+               } else if (chan_param->output == LTTNG_KERNEL_MMAP) {
+                       transport_name = chan_param->overwrite ?
+                               "relay-overwrite-mmap" : "relay-discard-mmap";
+               } else {
+                       return -EINVAL;
+               }
+               break;
+       case METADATA_CHANNEL:
+               if (chan_param->output == LTTNG_KERNEL_SPLICE)
+                       transport_name = "relay-metadata";
+               else if (chan_param->output == LTTNG_KERNEL_MMAP)
+                       transport_name = "relay-metadata-mmap";
+               else
+                       return -EINVAL;
+               break;
+       default:
+               transport_name = "<unknown>";
+               break;
+       }
+       /*
+        * We tolerate no failure path after channel creation. It will stay
+        * invariant for the rest of the session.
+        */
+       chan = lttng_channel_create(session, transport_name, NULL,
+                                 chan_param->subbuf_size,
+                                 chan_param->num_subbuf,
+                                 chan_param->switch_timer_interval,
+                                 chan_param->read_timer_interval,
+                                 channel_type);
+       if (!chan) {
+               ret = -EINVAL;
+               goto chan_error;
+       }
+       chan->file = chan_file;
+       chan_file->private_data = chan;
+       fd_install(chan_fd, chan_file);
+       atomic_long_inc(&session_file->f_count);
+
+       return chan_fd;
+
+chan_error:
+       fput(chan_file);
+file_error:
+       put_unused_fd(chan_fd);
+fd_error:
+       return ret;
+}
+
+/**
+ *     lttng_session_ioctl - lttng session fd ioctl
+ *
+ *     @file: the file
+ *     @cmd: the command
+ *     @arg: command arg
+ *
+ *     This ioctl implements lttng commands:
+ *     LTTNG_KERNEL_CHANNEL
+ *             Returns a LTTng channel file descriptor
+ *     LTTNG_KERNEL_ENABLE
+ *             Enables tracing for a session (weak enable)
+ *     LTTNG_KERNEL_DISABLE
+ *             Disables tracing for a session (strong disable)
+ *     LTTNG_KERNEL_METADATA
+ *             Returns a LTTng metadata file descriptor
+ *
+ * The returned channel will be deleted when its file descriptor is closed.
+ */
+static
+long lttng_session_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
+{
+       struct lttng_session *session = file->private_data;
+
+       switch (cmd) {
+       case LTTNG_KERNEL_OLD_CHANNEL:
+       {
+               struct lttng_kernel_channel chan_param;
+               struct lttng_kernel_old_channel old_chan_param;
+
+               if (copy_from_user(&old_chan_param,
+                               (struct lttng_kernel_old_channel __user *) arg,
+                               sizeof(struct lttng_kernel_old_channel)))
+                       return -EFAULT;
+               chan_param.overwrite = old_chan_param.overwrite;
+               chan_param.subbuf_size = old_chan_param.subbuf_size;
+               chan_param.num_subbuf = old_chan_param.num_subbuf;
+               chan_param.switch_timer_interval = old_chan_param.switch_timer_interval;
+               chan_param.read_timer_interval = old_chan_param.read_timer_interval;
+               chan_param.output = old_chan_param.output;
+
+               return lttng_abi_create_channel(file, &chan_param,
+                               PER_CPU_CHANNEL);
+       }
+       case LTTNG_KERNEL_CHANNEL:
+       {
+               struct lttng_kernel_channel chan_param;
+
+               if (copy_from_user(&chan_param,
+                               (struct lttng_kernel_channel __user *) arg,
+                               sizeof(struct lttng_kernel_channel)))
+                       return -EFAULT;
+               return lttng_abi_create_channel(file, &chan_param,
+                               PER_CPU_CHANNEL);
+       }
+       case LTTNG_KERNEL_OLD_SESSION_START:
+       case LTTNG_KERNEL_OLD_ENABLE:
+       case LTTNG_KERNEL_SESSION_START:
+       case LTTNG_KERNEL_ENABLE:
+               return lttng_session_enable(session);
+       case LTTNG_KERNEL_OLD_SESSION_STOP:
+       case LTTNG_KERNEL_OLD_DISABLE:
+       case LTTNG_KERNEL_SESSION_STOP:
+       case LTTNG_KERNEL_DISABLE:
+               return lttng_session_disable(session);
+       case LTTNG_KERNEL_OLD_METADATA:
+       {
+               struct lttng_kernel_channel chan_param;
+               struct lttng_kernel_old_channel old_chan_param;
+
+               if (copy_from_user(&old_chan_param,
+                               (struct lttng_kernel_old_channel __user *) arg,
+                               sizeof(struct lttng_kernel_old_channel)))
+                       return -EFAULT;
+               chan_param.overwrite = old_chan_param.overwrite;
+               chan_param.subbuf_size = old_chan_param.subbuf_size;
+               chan_param.num_subbuf = old_chan_param.num_subbuf;
+               chan_param.switch_timer_interval = old_chan_param.switch_timer_interval;
+               chan_param.read_timer_interval = old_chan_param.read_timer_interval;
+               chan_param.output = old_chan_param.output;
+
+               return lttng_abi_create_channel(file, &chan_param,
+                               METADATA_CHANNEL);
+       }
+       case LTTNG_KERNEL_METADATA:
+       {
+               struct lttng_kernel_channel chan_param;
+
+               if (copy_from_user(&chan_param,
+                                       (struct lttng_kernel_channel __user *) arg,
+                                       sizeof(struct lttng_kernel_channel)))
+                       return -EFAULT;
+               return lttng_abi_create_channel(file, &chan_param,
+                               METADATA_CHANNEL);
+       }
+       default:
+               return -ENOIOCTLCMD;
+       }
+}
+
+/*
+ * Called when the last file reference is dropped.
+ *
+ * Big fat note: channels and events are invariant for the whole session after
+ * their creation. So this session destruction also destroys all channel and
+ * event structures specific to this session (they are not destroyed when their
+ * individual file is released).
+ */
+static
+int lttng_session_release(struct inode *inode, struct file *file)
+{
+       struct lttng_session *session = file->private_data;
+
+       if (session)
+               lttng_session_destroy(session);
+       return 0;
+}
+
+static const struct file_operations lttng_session_fops = {
+       .owner = THIS_MODULE,
+       .release = lttng_session_release,
+       .unlocked_ioctl = lttng_session_ioctl,
+#ifdef CONFIG_COMPAT
+       .compat_ioctl = lttng_session_ioctl,
+#endif
+};
+
+/**
+ *     lttng_metadata_ring_buffer_poll - LTTng ring buffer poll file operation
+ *     @filp: the file
+ *     @wait: poll table
+ *
+ *     Handles the poll operations for the metadata channels.
+ */
+static
+unsigned int lttng_metadata_ring_buffer_poll(struct file *filp,
+               poll_table *wait)
+{
+       struct lttng_metadata_stream *stream = filp->private_data;
+       struct lib_ring_buffer *buf = stream->priv;
+       int finalized;
+       unsigned int mask = 0;
+
+       if (filp->f_mode & FMODE_READ) {
+               poll_wait_set_exclusive(wait);
+               poll_wait(filp, &stream->read_wait, wait);
+
+               finalized = stream->finalized;
+
+               /*
+                * lib_ring_buffer_is_finalized() contains a smp_rmb()
+                * ordering finalized load before offsets loads.
+                */
+               WARN_ON(atomic_long_read(&buf->active_readers) != 1);
+
+               if (finalized)
+                       mask |= POLLHUP;
+
+               if (stream->metadata_cache->metadata_written >
+                               stream->metadata_out)
+                       mask |= POLLIN;
+       }
+
+       return mask;
+}
+
+static
+int lttng_metadata_ring_buffer_ioctl_get_next_subbuf(struct file *filp,
+               unsigned int cmd, unsigned long arg)
+{
+       struct lttng_metadata_stream *stream = filp->private_data;
+       struct lib_ring_buffer *buf = stream->priv;
+       struct channel *chan = buf->backend.chan;
+       int ret;
+
+       ret = lttng_metadata_output_channel(stream, chan);
+       if (ret > 0) {
+               lib_ring_buffer_switch_slow(buf, SWITCH_ACTIVE);
+               ret = 0;
+       }
+       return ret;
+}
+
+static
+void lttng_metadata_ring_buffer_ioctl_put_next_subbuf(struct file *filp,
+               unsigned int cmd, unsigned long arg)
+{
+       struct lttng_metadata_stream *stream = filp->private_data;
+
+       stream->metadata_out = stream->metadata_in;
+}
+
+static
+long lttng_metadata_ring_buffer_ioctl(struct file *filp,
+               unsigned int cmd, unsigned long arg)
+{
+       int ret;
+       struct lttng_metadata_stream *stream = filp->private_data;
+       struct lib_ring_buffer *buf = stream->priv;
+
+       switch (cmd) {
+       case RING_BUFFER_GET_NEXT_SUBBUF:
+       {
+               ret = lttng_metadata_ring_buffer_ioctl_get_next_subbuf(filp,
+                               cmd, arg);
+               if (ret < 0)
+                       goto err;
+               break;
+       }
+       case RING_BUFFER_GET_SUBBUF:
+       {
+               /*
+                * Random access is not allowed for metadata channel.
+                */
+               return -ENOSYS;
+       }
+       default:
+               break;
+       }
+       /* PUT_SUBBUF is the one from lib ring buffer, unmodified. */
+
+       /* Performing lib ring buffer ioctl after our own. */
+       ret = lib_ring_buffer_ioctl(filp, cmd, arg, buf);
+       if (ret < 0)
+               goto err;
+
+       switch (cmd) {
+       case RING_BUFFER_PUT_NEXT_SUBBUF:
+       {
+               lttng_metadata_ring_buffer_ioctl_put_next_subbuf(filp,
+                               cmd, arg);
+               break;
+       }
+       default:
+               break;
+       }
+err:
+       return ret;
+}
+
+#ifdef CONFIG_COMPAT
+static
+long lttng_metadata_ring_buffer_compat_ioctl(struct file *filp,
+               unsigned int cmd, unsigned long arg)
+{
+       int ret;
+       struct lttng_metadata_stream *stream = filp->private_data;
+       struct lib_ring_buffer *buf = stream->priv;
+
+       switch (cmd) {
+       case RING_BUFFER_GET_NEXT_SUBBUF:
+       {
+               ret = lttng_metadata_ring_buffer_ioctl_get_next_subbuf(filp,
+                               cmd, arg);
+               if (ret < 0)
+                       goto err;
+               break;
+       }
+       case RING_BUFFER_GET_SUBBUF:
+       {
+               /*
+                * Random access is not allowed for metadata channel.
+                */
+               return -ENOSYS;
+       }
+       default:
+               break;
+       }
+       /* PUT_SUBBUF is the one from lib ring buffer, unmodified. */
+
+       /* Performing lib ring buffer ioctl after our own. */
+       ret = lib_ring_buffer_compat_ioctl(filp, cmd, arg, buf);
+       if (ret < 0)
+               goto err;
+
+       switch (cmd) {
+       case RING_BUFFER_PUT_NEXT_SUBBUF:
+       {
+               lttng_metadata_ring_buffer_ioctl_put_next_subbuf(filp,
+                               cmd, arg);
+               break;
+       }
+       default:
+               break;
+       }
+err:
+       return ret;
+}
+#endif
+
+/*
+ * This is not used by anonymous file descriptors. This code is left
+ * there if we ever want to implement an inode with open() operation.
+ */
+static
+int lttng_metadata_ring_buffer_open(struct inode *inode, struct file *file)
+{
+       struct lttng_metadata_stream *stream = inode->i_private;
+       struct lib_ring_buffer *buf = stream->priv;
+
+       file->private_data = buf;
+       /*
+        * Since life-time of metadata cache differs from that of
+        * session, we need to keep our own reference on the transport.
+        */
+       if (!try_module_get(stream->transport->owner)) {
+               printk(KERN_WARNING "LTT : Can't lock transport module.\n");
+               return -EBUSY;
+       }
+       return lib_ring_buffer_open(inode, file, buf);
+}
+
+static
+int lttng_metadata_ring_buffer_release(struct inode *inode, struct file *file)
+{
+       struct lttng_metadata_stream *stream = file->private_data;
+       struct lib_ring_buffer *buf = stream->priv;
+
+       kref_put(&stream->metadata_cache->refcount, metadata_cache_destroy);
+       module_put(stream->transport->owner);
+       return lib_ring_buffer_release(inode, file, buf);
+}
+
+static
+ssize_t lttng_metadata_ring_buffer_splice_read(struct file *in, loff_t *ppos,
+               struct pipe_inode_info *pipe, size_t len,
+               unsigned int flags)
+{
+       struct lttng_metadata_stream *stream = in->private_data;
+       struct lib_ring_buffer *buf = stream->priv;
+
+       return lib_ring_buffer_splice_read(in, ppos, pipe, len,
+                       flags, buf);
+}
+
+static
+int lttng_metadata_ring_buffer_mmap(struct file *filp,
+               struct vm_area_struct *vma)
+{
+       struct lttng_metadata_stream *stream = filp->private_data;
+       struct lib_ring_buffer *buf = stream->priv;
+
+       return lib_ring_buffer_mmap(filp, vma, buf);
+}
+
+static
+const struct file_operations lttng_metadata_ring_buffer_file_operations = {
+       .owner = THIS_MODULE,
+       .open = lttng_metadata_ring_buffer_open,
+       .release = lttng_metadata_ring_buffer_release,
+       .poll = lttng_metadata_ring_buffer_poll,
+       .splice_read = lttng_metadata_ring_buffer_splice_read,
+       .mmap = lttng_metadata_ring_buffer_mmap,
+       .unlocked_ioctl = lttng_metadata_ring_buffer_ioctl,
+       .llseek = vfs_lib_ring_buffer_no_llseek,
+#ifdef CONFIG_COMPAT
+       .compat_ioctl = lttng_metadata_ring_buffer_compat_ioctl,
+#endif
+};
+
+static
+int lttng_abi_create_stream_fd(struct file *channel_file, void *stream_priv,
+               const struct file_operations *fops)
+{
+       int stream_fd, ret;
+       struct file *stream_file;
+
+       stream_fd = get_unused_fd();
+       if (stream_fd < 0) {
+               ret = stream_fd;
+               goto fd_error;
+       }
+       stream_file = anon_inode_getfile("[lttng_stream]", fops,
+                       stream_priv, O_RDWR);
+       if (IS_ERR(stream_file)) {
+               ret = PTR_ERR(stream_file);
+               goto file_error;
+       }
+       /*
+        * OPEN_FMODE, called within anon_inode_getfile/alloc_file, don't honor
+        * FMODE_LSEEK, FMODE_PREAD nor FMODE_PWRITE. We need to read from this
+        * file descriptor, so we set FMODE_PREAD here.
+        */
+       stream_file->f_mode |= FMODE_PREAD;
+       fd_install(stream_fd, stream_file);
+       /*
+        * The stream holds a reference to the channel within the generic ring
+        * buffer library, so no need to hold a refcount on the channel and
+        * session files here.
+        */
+       return stream_fd;
+
+file_error:
+       put_unused_fd(stream_fd);
+fd_error:
+       return ret;
+}
+
+static
+int lttng_abi_open_stream(struct file *channel_file)
+{
+       struct lttng_channel *channel = channel_file->private_data;
+       struct lib_ring_buffer *buf;
+       int ret;
+       void *stream_priv;
+
+       buf = channel->ops->buffer_read_open(channel->chan);
+       if (!buf)
+               return -ENOENT;
+
+       stream_priv = buf;
+       ret = lttng_abi_create_stream_fd(channel_file, stream_priv,
+                       &lib_ring_buffer_file_operations);
+       if (ret < 0)
+               goto fd_error;
+
+       return ret;
+
+fd_error:
+       channel->ops->buffer_read_close(buf);
+       return ret;
+}
+
+static
+int lttng_abi_open_metadata_stream(struct file *channel_file)
+{
+       struct lttng_channel *channel = channel_file->private_data;
+       struct lttng_session *session = channel->session;
+       struct lib_ring_buffer *buf;
+       int ret;
+       struct lttng_metadata_stream *metadata_stream;
+       void *stream_priv;
+
+       buf = channel->ops->buffer_read_open(channel->chan);
+       if (!buf)
+               return -ENOENT;
+
+       metadata_stream = kzalloc(sizeof(struct lttng_metadata_stream),
+                       GFP_KERNEL);
+       if (!metadata_stream) {
+               ret = -ENOMEM;
+               goto nomem;
+       }
+       metadata_stream->metadata_cache = session->metadata_cache;
+       init_waitqueue_head(&metadata_stream->read_wait);
+       metadata_stream->priv = buf;
+       stream_priv = metadata_stream;
+       metadata_stream->transport = channel->transport;
+
+       /*
+        * Since life-time of metadata cache differs from that of
+        * session, we need to keep our own reference on the transport.
+        */
+       if (!try_module_get(metadata_stream->transport->owner)) {
+               printk(KERN_WARNING "LTT : Can't lock transport module.\n");
+               ret = -EINVAL;
+               goto notransport;
+       }
+
+       ret = lttng_abi_create_stream_fd(channel_file, stream_priv,
+                       &lttng_metadata_ring_buffer_file_operations);
+       if (ret < 0)
+               goto fd_error;
+
+       kref_get(&session->metadata_cache->refcount);
+       list_add(&metadata_stream->list,
+               &session->metadata_cache->metadata_stream);
+       return ret;
+
+fd_error:
+       module_put(metadata_stream->transport->owner);
+notransport:
+       kfree(metadata_stream);
+nomem:
+       channel->ops->buffer_read_close(buf);
+       return ret;
+}
+
+static
+int lttng_abi_create_event(struct file *channel_file,
+                          struct lttng_kernel_event *event_param)
+{
+       struct lttng_channel *channel = channel_file->private_data;
+       struct lttng_event *event;
+       int event_fd, ret;
+       struct file *event_file;
+
+       event_param->name[LTTNG_KERNEL_SYM_NAME_LEN - 1] = '\0';
+       switch (event_param->instrumentation) {
+       case LTTNG_KERNEL_KRETPROBE:
+               event_param->u.kretprobe.symbol_name[LTTNG_KERNEL_SYM_NAME_LEN - 1] = '\0';
+               break;
+       case LTTNG_KERNEL_KPROBE:
+               event_param->u.kprobe.symbol_name[LTTNG_KERNEL_SYM_NAME_LEN - 1] = '\0';
+               break;
+       case LTTNG_KERNEL_FUNCTION:
+               event_param->u.ftrace.symbol_name[LTTNG_KERNEL_SYM_NAME_LEN - 1] = '\0';
+               break;
+       default:
+               break;
+       }
+       switch (event_param->instrumentation) {
+       default:
+               event_fd = get_unused_fd();
+               if (event_fd < 0) {
+                       ret = event_fd;
+                       goto fd_error;
+               }
+               event_file = anon_inode_getfile("[lttng_event]",
+                                               &lttng_event_fops,
+                                               NULL, O_RDWR);
+               if (IS_ERR(event_file)) {
+                       ret = PTR_ERR(event_file);
+                       goto file_error;
+               }
+               /*
+                * We tolerate no failure path after event creation. It
+                * will stay invariant for the rest of the session.
+                */
+               event = lttng_event_create(channel, event_param, NULL, NULL);
+               if (!event) {
+                       ret = -EINVAL;
+                       goto event_error;
+               }
+               event_file->private_data = event;
+               fd_install(event_fd, event_file);
+               /* The event holds a reference on the channel */
+               atomic_long_inc(&channel_file->f_count);
+               break;
+       case LTTNG_KERNEL_SYSCALL:
+               /*
+                * Only all-syscall tracing supported for now.
+                */
+               if (event_param->name[0] != '\0')
+                       return -EINVAL;
+               ret = lttng_syscalls_register(channel, NULL);
+               if (ret)
+                       goto fd_error;
+               event_fd = 0;
+               break;
+       }
+       return event_fd;
+
+event_error:
+       fput(event_file);
+file_error:
+       put_unused_fd(event_fd);
+fd_error:
+       return ret;
+}
+
+/**
+ *     lttng_channel_ioctl - lttng syscall through ioctl
+ *
+ *     @file: the file
+ *     @cmd: the command
+ *     @arg: command arg
+ *
+ *     This ioctl implements lttng commands:
+ *      LTTNG_KERNEL_STREAM
+ *              Returns an event stream file descriptor or failure.
+ *              (typically, one event stream records events from one CPU)
+ *     LTTNG_KERNEL_EVENT
+ *             Returns an event file descriptor or failure.
+ *     LTTNG_KERNEL_CONTEXT
+ *             Prepend a context field to each event in the channel
+ *     LTTNG_KERNEL_ENABLE
+ *             Enable recording for events in this channel (weak enable)
+ *     LTTNG_KERNEL_DISABLE
+ *             Disable recording for events in this channel (strong disable)
+ *
+ * Channel and event file descriptors also hold a reference on the session.
+ */
+static
+long lttng_channel_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
+{
+       struct lttng_channel *channel = file->private_data;
+
+       switch (cmd) {
+       case LTTNG_KERNEL_OLD_STREAM:
+       case LTTNG_KERNEL_STREAM:
+               return lttng_abi_open_stream(file);
+       case LTTNG_KERNEL_OLD_EVENT:
+       {
+               struct lttng_kernel_event *uevent_param;
+               struct lttng_kernel_old_event *old_uevent_param;
+               int ret;
+
+               uevent_param = kmalloc(sizeof(struct lttng_kernel_event),
+                               GFP_KERNEL);
+               if (!uevent_param) {
+                       ret = -ENOMEM;
+                       goto old_event_end;
+               }
+               old_uevent_param = kmalloc(
+                               sizeof(struct lttng_kernel_old_event),
+                               GFP_KERNEL);
+               if (!old_uevent_param) {
+                       ret = -ENOMEM;
+                       goto old_event_error_free_param;
+               }
+               if (copy_from_user(old_uevent_param,
+                               (struct lttng_kernel_old_event __user *) arg,
+                               sizeof(struct lttng_kernel_old_event))) {
+                       ret = -EFAULT;
+                       goto old_event_error_free_old_param;
+               }
+
+               memcpy(uevent_param->name, old_uevent_param->name,
+                               sizeof(uevent_param->name));
+               uevent_param->instrumentation =
+                       old_uevent_param->instrumentation;
+
+               switch (old_uevent_param->instrumentation) {
+               case LTTNG_KERNEL_KPROBE:
+                       uevent_param->u.kprobe.addr =
+                               old_uevent_param->u.kprobe.addr;
+                       uevent_param->u.kprobe.offset =
+                               old_uevent_param->u.kprobe.offset;
+                       memcpy(uevent_param->u.kprobe.symbol_name,
+                               old_uevent_param->u.kprobe.symbol_name,
+                               sizeof(uevent_param->u.kprobe.symbol_name));
+                       break;
+               case LTTNG_KERNEL_KRETPROBE:
+                       uevent_param->u.kretprobe.addr =
+                               old_uevent_param->u.kretprobe.addr;
+                       uevent_param->u.kretprobe.offset =
+                               old_uevent_param->u.kretprobe.offset;
+                       memcpy(uevent_param->u.kretprobe.symbol_name,
+                               old_uevent_param->u.kretprobe.symbol_name,
+                               sizeof(uevent_param->u.kretprobe.symbol_name));
+                       break;
+               case LTTNG_KERNEL_FUNCTION:
+                       memcpy(uevent_param->u.ftrace.symbol_name,
+                                       old_uevent_param->u.ftrace.symbol_name,
+                                       sizeof(uevent_param->u.ftrace.symbol_name));
+                       break;
+               default:
+                       break;
+               }
+               ret = lttng_abi_create_event(file, uevent_param);
+
+old_event_error_free_old_param:
+               kfree(old_uevent_param);
+old_event_error_free_param:
+               kfree(uevent_param);
+old_event_end:
+               return ret;
+       }
+       case LTTNG_KERNEL_EVENT:
+       {
+               struct lttng_kernel_event uevent_param;
+
+               if (copy_from_user(&uevent_param,
+                               (struct lttng_kernel_event __user *) arg,
+                               sizeof(uevent_param)))
+                       return -EFAULT;
+               return lttng_abi_create_event(file, &uevent_param);
+       }
+       case LTTNG_KERNEL_OLD_CONTEXT:
+       {
+               struct lttng_kernel_context *ucontext_param;
+               struct lttng_kernel_old_context *old_ucontext_param;
+               int ret;
+
+               ucontext_param = kmalloc(sizeof(struct lttng_kernel_context),
+                               GFP_KERNEL);
+               if (!ucontext_param) {
+                       ret = -ENOMEM;
+                       goto old_ctx_end;
+               }
+               old_ucontext_param = kmalloc(sizeof(struct lttng_kernel_old_context),
+                               GFP_KERNEL);
+               if (!old_ucontext_param) {
+                       ret = -ENOMEM;
+                       goto old_ctx_error_free_param;
+               }
+
+               if (copy_from_user(old_ucontext_param,
+                               (struct lttng_kernel_old_context __user *) arg,
+                               sizeof(struct lttng_kernel_old_context))) {
+                       ret = -EFAULT;
+                       goto old_ctx_error_free_old_param;
+               }
+               ucontext_param->ctx = old_ucontext_param->ctx;
+               memcpy(ucontext_param->padding, old_ucontext_param->padding,
+                               sizeof(ucontext_param->padding));
+               /* only type that uses the union */
+               if (old_ucontext_param->ctx == LTTNG_KERNEL_CONTEXT_PERF_COUNTER) {
+                       ucontext_param->u.perf_counter.type =
+                               old_ucontext_param->u.perf_counter.type;
+                       ucontext_param->u.perf_counter.config =
+                               old_ucontext_param->u.perf_counter.config;
+                       memcpy(ucontext_param->u.perf_counter.name,
+                               old_ucontext_param->u.perf_counter.name,
+                               sizeof(ucontext_param->u.perf_counter.name));
+               }
+
+               ret = lttng_abi_add_context(file,
+                               ucontext_param,
+                               &channel->ctx, channel->session);
+
+old_ctx_error_free_old_param:
+               kfree(old_ucontext_param);
+old_ctx_error_free_param:
+               kfree(ucontext_param);
+old_ctx_end:
+               return ret;
+       }
+       case LTTNG_KERNEL_CONTEXT:
+       {
+               struct lttng_kernel_context ucontext_param;
+
+               if (copy_from_user(&ucontext_param,
+                               (struct lttng_kernel_context __user *) arg,
+                               sizeof(ucontext_param)))
+                       return -EFAULT;
+               return lttng_abi_add_context(file,
+                               &ucontext_param,
+                               &channel->ctx, channel->session);
+       }
+       case LTTNG_KERNEL_OLD_ENABLE:
+       case LTTNG_KERNEL_ENABLE:
+               return lttng_channel_enable(channel);
+       case LTTNG_KERNEL_OLD_DISABLE:
+       case LTTNG_KERNEL_DISABLE:
+               return lttng_channel_disable(channel);
+       default:
+               return -ENOIOCTLCMD;
+       }
+
+}
+
+/**
+ *     lttng_metadata_ioctl - lttng syscall through ioctl
+ *
+ *     @file: the file
+ *     @cmd: the command
+ *     @arg: command arg
+ *
+ *     This ioctl implements lttng commands:
+ *      LTTNG_KERNEL_STREAM
+ *              Returns an event stream file descriptor or failure.
+ *
+ * Channel and event file descriptors also hold a reference on the session.
+ */
+static
+long lttng_metadata_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
+{
+       switch (cmd) {
+       case LTTNG_KERNEL_OLD_STREAM:
+       case LTTNG_KERNEL_STREAM:
+               return lttng_abi_open_metadata_stream(file);
+       default:
+               return -ENOIOCTLCMD;
+       }
+}
+
+/**
+ *     lttng_channel_poll - lttng stream addition/removal monitoring
+ *
+ *     @file: the file
+ *     @wait: poll table
+ */
+unsigned int lttng_channel_poll(struct file *file, poll_table *wait)
+{
+       struct lttng_channel *channel = file->private_data;
+       unsigned int mask = 0;
+
+       if (file->f_mode & FMODE_READ) {
+               poll_wait_set_exclusive(wait);
+               poll_wait(file, channel->ops->get_hp_wait_queue(channel->chan),
+                         wait);
+
+               if (channel->ops->is_disabled(channel->chan))
+                       return POLLERR;
+               if (channel->ops->is_finalized(channel->chan))
+                       return POLLHUP;
+               if (channel->ops->buffer_has_read_closed_stream(channel->chan))
+                       return POLLIN | POLLRDNORM;
+               return 0;
+       }
+       return mask;
+
+}
+
+static
+int lttng_channel_release(struct inode *inode, struct file *file)
+{
+       struct lttng_channel *channel = file->private_data;
+
+       if (channel)
+               fput(channel->session->file);
+       return 0;
+}
+
+static
+int lttng_metadata_channel_release(struct inode *inode, struct file *file)
+{
+       struct lttng_channel *channel = file->private_data;
+
+       if (channel) {
+               lttng_metadata_channel_destroy(channel);
+               fput(channel->session->file);
+       }
+
+       return 0;
+}
+
+static const struct file_operations lttng_channel_fops = {
+       .owner = THIS_MODULE,
+       .release = lttng_channel_release,
+       .poll = lttng_channel_poll,
+       .unlocked_ioctl = lttng_channel_ioctl,
+#ifdef CONFIG_COMPAT
+       .compat_ioctl = lttng_channel_ioctl,
+#endif
+};
+
+static const struct file_operations lttng_metadata_fops = {
+       .owner = THIS_MODULE,
+       .release = lttng_metadata_channel_release,
+       .unlocked_ioctl = lttng_metadata_ioctl,
+#ifdef CONFIG_COMPAT
+       .compat_ioctl = lttng_metadata_ioctl,
+#endif
+};
+
+/**
+ *     lttng_event_ioctl - lttng syscall through ioctl
+ *
+ *     @file: the file
+ *     @cmd: the command
+ *     @arg: command arg
+ *
+ *     This ioctl implements lttng commands:
+ *     LTTNG_KERNEL_CONTEXT
+ *             Prepend a context field to each record of this event
+ *     LTTNG_KERNEL_ENABLE
+ *             Enable recording for this event (weak enable)
+ *     LTTNG_KERNEL_DISABLE
+ *             Disable recording for this event (strong disable)
+ */
+static
+long lttng_event_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
+{
+       struct lttng_event *event = file->private_data;
+
+       switch (cmd) {
+       case LTTNG_KERNEL_OLD_CONTEXT:
+       {
+               struct lttng_kernel_context *ucontext_param;
+               struct lttng_kernel_old_context *old_ucontext_param;
+               int ret;
+
+               ucontext_param = kmalloc(sizeof(struct lttng_kernel_context),
+                               GFP_KERNEL);
+               if (!ucontext_param) {
+                       ret = -ENOMEM;
+                       goto old_ctx_end;
+               }
+               old_ucontext_param = kmalloc(sizeof(struct lttng_kernel_old_context),
+                               GFP_KERNEL);
+               if (!old_ucontext_param) {
+                       ret = -ENOMEM;
+                       goto old_ctx_error_free_param;
+               }
+
+               if (copy_from_user(old_ucontext_param,
+                                       (struct lttng_kernel_old_context __user *) arg,
+                                       sizeof(struct lttng_kernel_old_context))) {
+                       ret = -EFAULT;
+                       goto old_ctx_error_free_old_param;
+               }
+               ucontext_param->ctx = old_ucontext_param->ctx;
+               memcpy(ucontext_param->padding, old_ucontext_param->padding,
+                               sizeof(ucontext_param->padding));
+               /* only type that uses the union */
+               if (old_ucontext_param->ctx == LTTNG_KERNEL_CONTEXT_PERF_COUNTER) {
+                       ucontext_param->u.perf_counter.type =
+                               old_ucontext_param->u.perf_counter.type;
+                       ucontext_param->u.perf_counter.config =
+                               old_ucontext_param->u.perf_counter.config;
+                       memcpy(ucontext_param->u.perf_counter.name,
+                                       old_ucontext_param->u.perf_counter.name,
+                                       sizeof(ucontext_param->u.perf_counter.name));
+               }
+
+               ret = lttng_abi_add_context(file,
+                               ucontext_param,
+                               &event->ctx, event->chan->session);
+
+old_ctx_error_free_old_param:
+               kfree(old_ucontext_param);
+old_ctx_error_free_param:
+               kfree(ucontext_param);
+old_ctx_end:
+               return ret;
+       }
+       case LTTNG_KERNEL_CONTEXT:
+       {
+               struct lttng_kernel_context ucontext_param;
+
+               if (copy_from_user(&ucontext_param,
+                                       (struct lttng_kernel_context __user *) arg,
+                                       sizeof(ucontext_param)))
+                       return -EFAULT;
+               return lttng_abi_add_context(file,
+                               &ucontext_param,
+                               &event->ctx, event->chan->session);
+       }
+       case LTTNG_KERNEL_OLD_ENABLE:
+       case LTTNG_KERNEL_ENABLE:
+               return lttng_event_enable(event);
+       case LTTNG_KERNEL_OLD_DISABLE:
+       case LTTNG_KERNEL_DISABLE:
+               return lttng_event_disable(event);
+       default:
+               return -ENOIOCTLCMD;
+       }
+}
+
+static
+int lttng_event_release(struct inode *inode, struct file *file)
+{
+       struct lttng_event *event = file->private_data;
+
+       if (event)
+               fput(event->chan->file);
+       return 0;
+}
+
+/* TODO: filter control ioctl */
+static const struct file_operations lttng_event_fops = {
+       .owner = THIS_MODULE,
+       .release = lttng_event_release,
+       .unlocked_ioctl = lttng_event_ioctl,
+#ifdef CONFIG_COMPAT
+       .compat_ioctl = lttng_event_ioctl,
+#endif
+};
+
+int __init lttng_abi_init(void)
+{
+       int ret = 0;
+
+       wrapper_vmalloc_sync_all();
+       lttng_proc_dentry = proc_create_data("lttng", S_IRUSR | S_IWUSR, NULL,
+                                       &lttng_fops, NULL);
+
+       if (!lttng_proc_dentry) {
+               printk(KERN_ERR "Error creating LTTng control file\n");
+               ret = -ENOMEM;
+               goto error;
+       }
+error:
+       return ret;
+}
+
+void __exit lttng_abi_exit(void)
+{
+       if (lttng_proc_dentry)
+               remove_proc_entry("lttng", NULL);
+}
diff --git a/drivers/staging/lttng/lttng-abi.h b/drivers/staging/lttng/lttng-abi.h
new file mode 100644 (file)
index 0000000..8d3ecdd
--- /dev/null
@@ -0,0 +1,177 @@
+#ifndef _LTTNG_ABI_H
+#define _LTTNG_ABI_H
+
+/*
+ * lttng-abi.h
+ *
+ * LTTng ABI header
+ *
+ * Copyright (C) 2010-2012 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; only
+ * version 2.1 of the License.
+ *
+ * This library 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
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include <linux/fs.h>
+
+#define LTTNG_KERNEL_SYM_NAME_LEN      256
+
+enum lttng_kernel_instrumentation {
+       LTTNG_KERNEL_TRACEPOINT = 0,
+       LTTNG_KERNEL_KPROBE     = 1,
+       LTTNG_KERNEL_FUNCTION   = 2,
+       LTTNG_KERNEL_KRETPROBE  = 3,
+       LTTNG_KERNEL_NOOP       = 4,    /* not hooked */
+       LTTNG_KERNEL_SYSCALL    = 5,
+};
+
+/*
+ * LTTng consumer mode
+ */
+enum lttng_kernel_output {
+       LTTNG_KERNEL_SPLICE     = 0,
+       LTTNG_KERNEL_MMAP       = 1,
+};
+
+/*
+ * LTTng DebugFS ABI structures.
+ */
+#define LTTNG_KERNEL_CHANNEL_PADDING   LTTNG_KERNEL_SYM_NAME_LEN + 32
+struct lttng_kernel_channel {
+       uint64_t subbuf_size;                   /* in bytes */
+       uint64_t num_subbuf;
+       unsigned int switch_timer_interval;     /* usecs */
+       unsigned int read_timer_interval;       /* usecs */
+       enum lttng_kernel_output output;        /* splice, mmap */
+       int overwrite;                          /* 1: overwrite, 0: discard */
+       char padding[LTTNG_KERNEL_CHANNEL_PADDING];
+}__attribute__((packed));
+
+struct lttng_kernel_kretprobe {
+       uint64_t addr;
+
+       uint64_t offset;
+       char symbol_name[LTTNG_KERNEL_SYM_NAME_LEN];
+}__attribute__((packed));
+
+/*
+ * Either addr is used, or symbol_name and offset.
+ */
+struct lttng_kernel_kprobe {
+       uint64_t addr;
+
+       uint64_t offset;
+       char symbol_name[LTTNG_KERNEL_SYM_NAME_LEN];
+}__attribute__((packed));
+
+struct lttng_kernel_function_tracer {
+       char symbol_name[LTTNG_KERNEL_SYM_NAME_LEN];
+}__attribute__((packed));
+
+/*
+ * For syscall tracing, name = '\0' means "enable all".
+ */
+#define LTTNG_KERNEL_EVENT_PADDING1    16
+#define LTTNG_KERNEL_EVENT_PADDING2    LTTNG_KERNEL_SYM_NAME_LEN + 32
+struct lttng_kernel_event {
+       char name[LTTNG_KERNEL_SYM_NAME_LEN];   /* event name */
+       enum lttng_kernel_instrumentation instrumentation;
+       char padding[LTTNG_KERNEL_EVENT_PADDING1];
+
+       /* Per instrumentation type configuration */
+       union {
+               struct lttng_kernel_kretprobe kretprobe;
+               struct lttng_kernel_kprobe kprobe;
+               struct lttng_kernel_function_tracer ftrace;
+               char padding[LTTNG_KERNEL_EVENT_PADDING2];
+       } u;
+}__attribute__((packed));
+
+struct lttng_kernel_tracer_version {
+       uint32_t major;
+       uint32_t minor;
+       uint32_t patchlevel;
+}__attribute__((packed));
+
+enum lttng_kernel_calibrate_type {
+       LTTNG_KERNEL_CALIBRATE_KRETPROBE,
+};
+
+struct lttng_kernel_calibrate {
+       enum lttng_kernel_calibrate_type type;  /* type (input) */
+}__attribute__((packed));
+
+enum lttng_kernel_context_type {
+       LTTNG_KERNEL_CONTEXT_PID                = 0,
+       LTTNG_KERNEL_CONTEXT_PERF_COUNTER       = 1,
+       LTTNG_KERNEL_CONTEXT_PROCNAME           = 2,
+       LTTNG_KERNEL_CONTEXT_PRIO               = 3,
+       LTTNG_KERNEL_CONTEXT_NICE               = 4,
+       LTTNG_KERNEL_CONTEXT_VPID               = 5,
+       LTTNG_KERNEL_CONTEXT_TID                = 6,
+       LTTNG_KERNEL_CONTEXT_VTID               = 7,
+       LTTNG_KERNEL_CONTEXT_PPID               = 8,
+       LTTNG_KERNEL_CONTEXT_VPPID              = 9,
+       LTTNG_KERNEL_CONTEXT_HOSTNAME           = 10,
+};
+
+struct lttng_kernel_perf_counter_ctx {
+       uint32_t type;
+       uint64_t config;
+       char name[LTTNG_KERNEL_SYM_NAME_LEN];
+}__attribute__((packed));
+
+#define LTTNG_KERNEL_CONTEXT_PADDING1  16
+#define LTTNG_KERNEL_CONTEXT_PADDING2  LTTNG_KERNEL_SYM_NAME_LEN + 32
+struct lttng_kernel_context {
+       enum lttng_kernel_context_type ctx;
+       char padding[LTTNG_KERNEL_CONTEXT_PADDING1];
+
+       union {
+               struct lttng_kernel_perf_counter_ctx perf_counter;
+               char padding[LTTNG_KERNEL_CONTEXT_PADDING2];
+       } u;
+}__attribute__((packed));
+
+/* LTTng file descriptor ioctl */
+#define LTTNG_KERNEL_SESSION                   _IO(0xF6, 0x45)
+#define LTTNG_KERNEL_TRACER_VERSION            \
+       _IOR(0xF6, 0x46, struct lttng_kernel_tracer_version)
+#define LTTNG_KERNEL_TRACEPOINT_LIST           _IO(0xF6, 0x47)
+#define LTTNG_KERNEL_WAIT_QUIESCENT            _IO(0xF6, 0x48)
+#define LTTNG_KERNEL_CALIBRATE                 \
+       _IOWR(0xF6, 0x49, struct lttng_kernel_calibrate)
+
+/* Session FD ioctl */
+#define LTTNG_KERNEL_METADATA                  \
+       _IOW(0xF6, 0x54, struct lttng_kernel_channel)
+#define LTTNG_KERNEL_CHANNEL                   \
+       _IOW(0xF6, 0x55, struct lttng_kernel_channel)
+#define LTTNG_KERNEL_SESSION_START             _IO(0xF6, 0x56)
+#define LTTNG_KERNEL_SESSION_STOP              _IO(0xF6, 0x57)
+
+/* Channel FD ioctl */
+#define LTTNG_KERNEL_STREAM                    _IO(0xF6, 0x62)
+#define LTTNG_KERNEL_EVENT                     \
+       _IOW(0xF6, 0x63, struct lttng_kernel_event)
+
+/* Event and Channel FD ioctl */
+#define LTTNG_KERNEL_CONTEXT                   \
+       _IOW(0xF6, 0x71, struct lttng_kernel_context)
+
+/* Event, Channel and Session ioctl */
+#define LTTNG_KERNEL_ENABLE                    _IO(0xF6, 0x82)
+#define LTTNG_KERNEL_DISABLE                   _IO(0xF6, 0x83)
+
+#endif /* _LTTNG_ABI_H */
diff --git a/drivers/staging/lttng/lttng-calibrate.c b/drivers/staging/lttng/lttng-calibrate.c
new file mode 100644 (file)
index 0000000..6f8915e
--- /dev/null
@@ -0,0 +1,42 @@
+/*
+ * lttng-calibrate.c
+ *
+ * LTTng probe calibration.
+ *
+ * Copyright (C) 2010-2012 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; only
+ * version 2.1 of the License.
+ *
+ * This library 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
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include "lttng-abi.h"
+#include "lttng-events.h"
+
+noinline
+void lttng_calibrate_kretprobe(void)
+{
+       asm volatile ("");
+}
+
+int lttng_calibrate(struct lttng_kernel_calibrate *calibrate)
+{
+       switch (calibrate->type) {
+       case LTTNG_KERNEL_CALIBRATE_KRETPROBE:
+               lttng_calibrate_kretprobe();
+               break;
+       default:
+               return -EINVAL;
+       }
+       return 0;
+}
diff --git a/drivers/staging/lttng/lttng-context-hostname.c b/drivers/staging/lttng/lttng-context-hostname.c
new file mode 100644 (file)
index 0000000..7cf7f7c
--- /dev/null
@@ -0,0 +1,99 @@
+/*
+ * lttng-context-hostname.c
+ *
+ * LTTng hostname context.
+ *
+ * Copyright (C) 2009-2012 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; only
+ * version 2.1 of the License.
+ *
+ * This library 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
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include <linux/module.h>
+#include <linux/slab.h>
+#include <linux/sched.h>
+#include <linux/utsname.h>
+#include "lttng-events.h"
+#include "wrapper/ringbuffer/frontend_types.h"
+#include "wrapper/vmalloc.h"
+#include "lttng-tracer.h"
+
+#define LTTNG_HOSTNAME_CTX_LEN (__NEW_UTS_LEN + 1)
+
+static
+size_t hostname_get_size(size_t offset)
+{
+       size_t size = 0;
+
+       size += LTTNG_HOSTNAME_CTX_LEN;
+       return size;
+}
+
+static
+void hostname_record(struct lttng_ctx_field *field,
+                struct lib_ring_buffer_ctx *ctx,
+                struct lttng_channel *chan)
+{
+       struct nsproxy *nsproxy;
+       struct uts_namespace *ns;
+       char *hostname;
+
+       /*
+        * No need to take the RCU read-side lock to read current
+        * nsproxy. (documented in nsproxy.h)
+        */
+       nsproxy = current->nsproxy;
+       if (nsproxy) {
+               ns = nsproxy->uts_ns;
+               hostname = ns->name.nodename;
+               chan->ops->event_write(ctx, hostname,
+                               LTTNG_HOSTNAME_CTX_LEN);
+       } else {
+               chan->ops->event_memset(ctx, 0,
+                               LTTNG_HOSTNAME_CTX_LEN);
+       }
+}
+
+int lttng_add_hostname_to_ctx(struct lttng_ctx **ctx)
+{
+       struct lttng_ctx_field *field;
+
+       field = lttng_append_context(ctx);
+       if (!field)
+               return -ENOMEM;
+       if (lttng_find_context(*ctx, "hostname")) {
+               lttng_remove_context_field(ctx, field);
+               return -EEXIST;
+       }
+       field->event_field.name = "hostname";
+       field->event_field.type.atype = atype_array;
+       field->event_field.type.u.array.elem_type.atype = atype_integer;
+       field->event_field.type.u.array.elem_type.u.basic.integer.size = sizeof(char) * CHAR_BIT;
+       field->event_field.type.u.array.elem_type.u.basic.integer.alignment = lttng_alignof(char) * CHAR_BIT;
+       field->event_field.type.u.array.elem_type.u.basic.integer.signedness = lttng_is_signed_type(char);
+       field->event_field.type.u.array.elem_type.u.basic.integer.reverse_byte_order = 0;
+       field->event_field.type.u.array.elem_type.u.basic.integer.base = 10;
+       field->event_field.type.u.array.elem_type.u.basic.integer.encoding = lttng_encode_UTF8;
+       field->event_field.type.u.array.length = LTTNG_HOSTNAME_CTX_LEN;
+
+       field->get_size = hostname_get_size;
+       field->record = hostname_record;
+       wrapper_vmalloc_sync_all();
+       return 0;
+}
+EXPORT_SYMBOL_GPL(lttng_add_hostname_to_ctx);
+
+MODULE_LICENSE("GPL and additional rights");
+MODULE_AUTHOR("Mathieu Desnoyers");
+MODULE_DESCRIPTION("Linux Trace Toolkit Perf Support");
diff --git a/drivers/staging/lttng/lttng-context-nice.c b/drivers/staging/lttng/lttng-context-nice.c
new file mode 100644 (file)
index 0000000..974910d
--- /dev/null
@@ -0,0 +1,81 @@
+/*
+ * lttng-context-nice.c
+ *
+ * LTTng nice context.
+ *
+ * Copyright (C) 2009-2012 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; only
+ * version 2.1 of the License.
+ *
+ * This library 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
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include <linux/module.h>
+#include <linux/slab.h>
+#include <linux/sched.h>
+#include "lttng-events.h"
+#include "wrapper/ringbuffer/frontend_types.h"
+#include "wrapper/vmalloc.h"
+#include "lttng-tracer.h"
+
+static
+size_t nice_get_size(size_t offset)
+{
+       size_t size = 0;
+
+       size += lib_ring_buffer_align(offset, lttng_alignof(int));
+       size += sizeof(int);
+       return size;
+}
+
+static
+void nice_record(struct lttng_ctx_field *field,
+               struct lib_ring_buffer_ctx *ctx,
+               struct lttng_channel *chan)
+{
+       int nice;
+
+       nice = task_nice(current);
+       lib_ring_buffer_align_ctx(ctx, lttng_alignof(nice));
+       chan->ops->event_write(ctx, &nice, sizeof(nice));
+}
+
+int lttng_add_nice_to_ctx(struct lttng_ctx **ctx)
+{
+       struct lttng_ctx_field *field;
+
+       field = lttng_append_context(ctx);
+       if (!field)
+               return -ENOMEM;
+       if (lttng_find_context(*ctx, "nice")) {
+               lttng_remove_context_field(ctx, field);
+               return -EEXIST;
+       }
+       field->event_field.name = "nice";
+       field->event_field.type.atype = atype_integer;
+       field->event_field.type.u.basic.integer.size = sizeof(int) * CHAR_BIT;
+       field->event_field.type.u.basic.integer.alignment = lttng_alignof(int) * CHAR_BIT;
+       field->event_field.type.u.basic.integer.signedness = lttng_is_signed_type(int);
+       field->event_field.type.u.basic.integer.reverse_byte_order = 0;
+       field->event_field.type.u.basic.integer.base = 10;
+       field->event_field.type.u.basic.integer.encoding = lttng_encode_none;
+       field->get_size = nice_get_size;
+       field->record = nice_record;
+       wrapper_vmalloc_sync_all();
+       return 0;
+}
+EXPORT_SYMBOL_GPL(lttng_add_nice_to_ctx);
+
+MODULE_LICENSE("GPL and additional rights");
+MODULE_AUTHOR("Mathieu Desnoyers");
+MODULE_DESCRIPTION("Linux Trace Toolkit Nice Context");
diff --git a/drivers/staging/lttng/lttng-context-perf-counters.c b/drivers/staging/lttng/lttng-context-perf-counters.c
new file mode 100644 (file)
index 0000000..d65f690
--- /dev/null
@@ -0,0 +1,285 @@
+/*
+ * lttng-context-perf-counters.c
+ *
+ * LTTng performance monitoring counters (perf-counters) integration module.
+ *
+ * Copyright (C) 2009-2012 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; only
+ * version 2.1 of the License.
+ *
+ * This library 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
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include <linux/module.h>
+#include <linux/slab.h>
+#include <linux/perf_event.h>
+#include <linux/list.h>
+#include <linux/string.h>
+#include <linux/cpu.h>
+#include "lttng-events.h"
+#include "wrapper/ringbuffer/frontend_types.h"
+#include "wrapper/vmalloc.h"
+#include "wrapper/perf.h"
+#include "lttng-tracer.h"
+
+static
+size_t perf_counter_get_size(size_t offset)
+{
+       size_t size = 0;
+
+       size += lib_ring_buffer_align(offset, lttng_alignof(uint64_t));
+       size += sizeof(uint64_t);
+       return size;
+}
+
+static
+void perf_counter_record(struct lttng_ctx_field *field,
+                        struct lib_ring_buffer_ctx *ctx,
+                        struct lttng_channel *chan)
+{
+       struct perf_event *event;
+       uint64_t value;
+
+       event = field->u.perf_counter->e[ctx->cpu];
+       if (likely(event)) {
+               if (unlikely(event->state == PERF_EVENT_STATE_ERROR)) {
+                       value = 0;
+               } else {
+                       event->pmu->read(event);
+                       value = local64_read(&event->count);
+               }
+       } else {
+               /*
+                * Perf chooses not to be clever and not to support enabling a
+                * perf counter before the cpu is brought up. Therefore, we need
+                * to support having events coming (e.g. scheduler events)
+                * before the counter is setup. Write an arbitrary 0 in this
+                * case.
+                */
+               value = 0;
+       }
+       lib_ring_buffer_align_ctx(ctx, lttng_alignof(value));
+       chan->ops->event_write(ctx, &value, sizeof(value));
+}
+
+#if defined(CONFIG_PERF_EVENTS) && (LINUX_VERSION_CODE >= KERNEL_VERSION(3,0,99))
+static
+void overflow_callback(struct perf_event *event,
+                      struct perf_sample_data *data,
+                      struct pt_regs *regs)
+{
+}
+#else
+static
+void overflow_callback(struct perf_event *event, int nmi,
+                      struct perf_sample_data *data,
+                      struct pt_regs *regs)
+{
+}
+#endif
+
+static
+void lttng_destroy_perf_counter_field(struct lttng_ctx_field *field)
+{
+       struct perf_event **events = field->u.perf_counter->e;
+       int cpu;
+
+       get_online_cpus();
+       for_each_online_cpu(cpu)
+               perf_event_release_kernel(events[cpu]);
+       put_online_cpus();
+#ifdef CONFIG_HOTPLUG_CPU
+       unregister_cpu_notifier(&field->u.perf_counter->nb);
+#endif
+       kfree(field->event_field.name);
+       kfree(field->u.perf_counter->attr);
+       kfree(events);
+       kfree(field->u.perf_counter);
+}
+
+#ifdef CONFIG_HOTPLUG_CPU
+
+/**
+ *     lttng_perf_counter_hp_callback - CPU hotplug callback
+ *     @nb: notifier block
+ *     @action: hotplug action to take
+ *     @hcpu: CPU number
+ *
+ *     Returns the success/failure of the operation. (%NOTIFY_OK, %NOTIFY_BAD)
+ *
+ * We can setup perf counters when the cpu is online (up prepare seems to be too
+ * soon).
+ */
+static
+int lttng_perf_counter_cpu_hp_callback(struct notifier_block *nb,
+                                                unsigned long action,
+                                                void *hcpu)
+{
+       unsigned int cpu = (unsigned long) hcpu;
+       struct lttng_perf_counter_field *perf_field =
+               container_of(nb, struct lttng_perf_counter_field, nb);
+       struct perf_event **events = perf_field->e;
+       struct perf_event_attr *attr = perf_field->attr;
+       struct perf_event *pevent;
+
+       if (!perf_field->hp_enable)
+               return NOTIFY_OK;
+
+       switch (action) {
+       case CPU_ONLINE:
+       case CPU_ONLINE_FROZEN:
+               pevent = wrapper_perf_event_create_kernel_counter(attr,
+                               cpu, NULL, overflow_callback);
+               if (!pevent || IS_ERR(pevent))
+                       return NOTIFY_BAD;
+               if (pevent->state == PERF_EVENT_STATE_ERROR) {
+                       perf_event_release_kernel(pevent);
+                       return NOTIFY_BAD;
+               }
+               barrier();      /* Create perf counter before setting event */
+               events[cpu] = pevent;
+               break;
+       case CPU_UP_CANCELED:
+       case CPU_UP_CANCELED_FROZEN:
+       case CPU_DEAD:
+       case CPU_DEAD_FROZEN:
+               pevent = events[cpu];
+               events[cpu] = NULL;
+               barrier();      /* NULLify event before perf counter teardown */
+               perf_event_release_kernel(pevent);
+               break;
+       }
+       return NOTIFY_OK;
+}
+
+#endif
+
+int lttng_add_perf_counter_to_ctx(uint32_t type,
+                                 uint64_t config,
+                                 const char *name,
+                                 struct lttng_ctx **ctx)
+{
+       struct lttng_ctx_field *field;
+       struct lttng_perf_counter_field *perf_field;
+       struct perf_event **events;
+       struct perf_event_attr *attr;
+       int ret;
+       int cpu;
+       char *name_alloc;
+
+       events = kzalloc(num_possible_cpus() * sizeof(*events), GFP_KERNEL);
+       if (!events)
+               return -ENOMEM;
+
+       attr = kzalloc(sizeof(struct perf_event_attr), GFP_KERNEL);
+       if (!attr) {
+               ret = -ENOMEM;
+               goto error_attr;
+       }
+
+       attr->type = type;
+       attr->config = config;
+       attr->size = sizeof(struct perf_event_attr);
+       attr->pinned = 1;
+       attr->disabled = 0;
+
+       perf_field = kzalloc(sizeof(struct lttng_perf_counter_field), GFP_KERNEL);
+       if (!perf_field) {
+               ret = -ENOMEM;
+               goto error_alloc_perf_field;
+       }
+       perf_field->e = events;
+       perf_field->attr = attr;
+
+       name_alloc = kstrdup(name, GFP_KERNEL);
+       if (!name_alloc) {
+               ret = -ENOMEM;
+               goto name_alloc_error;
+       }
+
+       field = lttng_append_context(ctx);
+       if (!field) {
+               ret = -ENOMEM;
+               goto append_context_error;
+       }
+       if (lttng_find_context(*ctx, name_alloc)) {
+               ret = -EEXIST;
+               goto find_error;
+       }
+
+#ifdef CONFIG_HOTPLUG_CPU
+       perf_field->nb.notifier_call =
+               lttng_perf_counter_cpu_hp_callback;
+       perf_field->nb.priority = 0;
+       register_cpu_notifier(&perf_field->nb);
+#endif
+
+       get_online_cpus();
+       for_each_online_cpu(cpu) {
+               events[cpu] = wrapper_perf_event_create_kernel_counter(attr,
+                                       cpu, NULL, overflow_callback);
+               if (!events[cpu] || IS_ERR(events[cpu])) {
+                       ret = -EINVAL;
+                       goto counter_error;
+               }
+               if (events[cpu]->state == PERF_EVENT_STATE_ERROR) {
+                       ret = -EBUSY;
+                       goto counter_busy;
+               }
+       }
+       put_online_cpus();
+
+       field->destroy = lttng_destroy_perf_counter_field;
+
+       field->event_field.name = name_alloc;
+       field->event_field.type.atype = atype_integer;
+       field->event_field.type.u.basic.integer.size = sizeof(uint64_t) * CHAR_BIT;
+       field->event_field.type.u.basic.integer.alignment = lttng_alignof(uint64_t) * CHAR_BIT;
+       field->event_field.type.u.basic.integer.signedness = lttng_is_signed_type(uint64_t);
+       field->event_field.type.u.basic.integer.reverse_byte_order = 0;
+       field->event_field.type.u.basic.integer.base = 10;
+       field->event_field.type.u.basic.integer.encoding = lttng_encode_none;
+       field->get_size = perf_counter_get_size;
+       field->record = perf_counter_record;
+       field->u.perf_counter = perf_field;
+       perf_field->hp_enable = 1;
+
+       wrapper_vmalloc_sync_all();
+       return 0;
+
+counter_busy:
+counter_error:
+       for_each_online_cpu(cpu) {
+               if (events[cpu] && !IS_ERR(events[cpu]))
+                       perf_event_release_kernel(events[cpu]);
+       }
+       put_online_cpus();
+#ifdef CONFIG_HOTPLUG_CPU
+       unregister_cpu_notifier(&perf_field->nb);
+#endif
+find_error:
+       lttng_remove_context_field(ctx, field);
+append_context_error:
+       kfree(name_alloc);
+name_alloc_error:
+       kfree(perf_field);
+error_alloc_perf_field:
+       kfree(attr);
+error_attr:
+       kfree(events);
+       return ret;
+}
+
+MODULE_LICENSE("GPL and additional rights");
+MODULE_AUTHOR("Mathieu Desnoyers");
+MODULE_DESCRIPTION("Linux Trace Toolkit Perf Support");
diff --git a/drivers/staging/lttng/lttng-context-pid.c b/drivers/staging/lttng/lttng-context-pid.c
new file mode 100644 (file)
index 0000000..cb64ff1
--- /dev/null
@@ -0,0 +1,81 @@
+/*
+ * lttng-context-pid.c
+ *
+ * LTTng PID context.
+ *
+ * Copyright (C) 2009-2012 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; only
+ * version 2.1 of the License.
+ *
+ * This library 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
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include <linux/module.h>
+#include <linux/slab.h>
+#include <linux/sched.h>
+#include "lttng-events.h"
+#include "wrapper/ringbuffer/frontend_types.h"
+#include "wrapper/vmalloc.h"
+#include "lttng-tracer.h"
+
+static
+size_t pid_get_size(size_t offset)
+{
+       size_t size = 0;
+
+       size += lib_ring_buffer_align(offset, lttng_alignof(pid_t));
+       size += sizeof(pid_t);
+       return size;
+}
+
+static
+void pid_record(struct lttng_ctx_field *field,
+               struct lib_ring_buffer_ctx *ctx,
+               struct lttng_channel *chan)
+{
+       pid_t pid;
+
+       pid = task_tgid_nr(current);
+       lib_ring_buffer_align_ctx(ctx, lttng_alignof(pid));
+       chan->ops->event_write(ctx, &pid, sizeof(pid));
+}
+
+int lttng_add_pid_to_ctx(struct lttng_ctx **ctx)
+{
+       struct lttng_ctx_field *field;
+
+       field = lttng_append_context(ctx);
+       if (!field)
+               return -ENOMEM;
+       if (lttng_find_context(*ctx, "pid")) {
+               lttng_remove_context_field(ctx, field);
+               return -EEXIST;
+       }
+       field->event_field.name = "pid";
+       field->event_field.type.atype = atype_integer;
+       field->event_field.type.u.basic.integer.size = sizeof(pid_t) * CHAR_BIT;
+       field->event_field.type.u.basic.integer.alignment = lttng_alignof(pid_t) * CHAR_BIT;
+       field->event_field.type.u.basic.integer.signedness = lttng_is_signed_type(pid_t);
+       field->event_field.type.u.basic.integer.reverse_byte_order = 0;
+       field->event_field.type.u.basic.integer.base = 10;
+       field->event_field.type.u.basic.integer.encoding = lttng_encode_none;
+       field->get_size = pid_get_size;
+       field->record = pid_record;
+       wrapper_vmalloc_sync_all();
+       return 0;
+}
+EXPORT_SYMBOL_GPL(lttng_add_pid_to_ctx);
+
+MODULE_LICENSE("GPL and additional rights");
+MODULE_AUTHOR("Mathieu Desnoyers");
+MODULE_DESCRIPTION("Linux Trace Toolkit PID Context");
diff --git a/drivers/staging/lttng/lttng-context-ppid.c b/drivers/staging/lttng/lttng-context-ppid.c
new file mode 100644 (file)
index 0000000..878c688
--- /dev/null
@@ -0,0 +1,93 @@
+/*
+ * lttng-context-ppid.c
+ *
+ * LTTng PPID context.
+ *
+ * Copyright (C) 2009-2012 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; only
+ * version 2.1 of the License.
+ *
+ * This library 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
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include <linux/module.h>
+#include <linux/slab.h>
+#include <linux/sched.h>
+#include <linux/syscalls.h>
+#include "lttng-events.h"
+#include "wrapper/ringbuffer/frontend_types.h"
+#include "wrapper/vmalloc.h"
+#include "lttng-tracer.h"
+
+static
+size_t ppid_get_size(size_t offset)
+{
+       size_t size = 0;
+
+       size += lib_ring_buffer_align(offset, lttng_alignof(pid_t));
+       size += sizeof(pid_t);
+       return size;
+}
+
+static
+void ppid_record(struct lttng_ctx_field *field,
+                struct lib_ring_buffer_ctx *ctx,
+                struct lttng_channel *chan)
+{
+       pid_t ppid;
+
+
+       /*
+        * TODO: when we eventually add RCU subsystem instrumentation,
+        * taking the rcu read lock here will trigger RCU tracing
+        * recursively. We should modify the kernel synchronization so
+        * it synchronizes both for RCU and RCU sched, and rely on
+        * rcu_read_lock_sched_notrace.
+        */
+
+       rcu_read_lock();
+       ppid = task_tgid_nr(current->real_parent);
+       rcu_read_unlock();
+       lib_ring_buffer_align_ctx(ctx, lttng_alignof(ppid));
+       chan->ops->event_write(ctx, &ppid, sizeof(ppid));
+}
+
+int lttng_add_ppid_to_ctx(struct lttng_ctx **ctx)
+{
+       struct lttng_ctx_field *field;
+
+       field = lttng_append_context(ctx);
+       if (!field)
+               return -ENOMEM;
+       if (lttng_find_context(*ctx, "ppid")) {
+               lttng_remove_context_field(ctx, field);
+               return -EEXIST;
+       }
+       field->event_field.name = "ppid";
+       field->event_field.type.atype = atype_integer;
+       field->event_field.type.u.basic.integer.size = sizeof(pid_t) * CHAR_BIT;
+       field->event_field.type.u.basic.integer.alignment = lttng_alignof(pid_t) * CHAR_BIT;
+       field->event_field.type.u.basic.integer.signedness = lttng_is_signed_type(pid_t);
+       field->event_field.type.u.basic.integer.reverse_byte_order = 0;
+       field->event_field.type.u.basic.integer.base = 10;
+       field->event_field.type.u.basic.integer.encoding = lttng_encode_none;
+       field->get_size = ppid_get_size;
+       field->record = ppid_record;
+       wrapper_vmalloc_sync_all();
+       return 0;
+}
+EXPORT_SYMBOL_GPL(lttng_add_ppid_to_ctx);
+
+MODULE_LICENSE("GPL and additional rights");
+MODULE_AUTHOR("Mathieu Desnoyers");
+MODULE_DESCRIPTION("Linux Trace Toolkit PPID Context");
diff --git a/drivers/staging/lttng/lttng-context-prio.c b/drivers/staging/lttng/lttng-context-prio.c
new file mode 100644 (file)
index 0000000..fa30ab5
--- /dev/null
@@ -0,0 +1,102 @@
+/*
+ * lttng-context-prio.c
+ *
+ * LTTng priority context.
+ *
+ * Copyright (C) 2009-2012 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; only
+ * version 2.1 of the License.
+ *
+ * This library 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
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include <linux/module.h>
+#include <linux/slab.h>
+#include <linux/sched.h>
+#include "lttng-events.h"
+#include "wrapper/ringbuffer/frontend_types.h"
+#include "wrapper/vmalloc.h"
+#include "wrapper/kallsyms.h"
+#include "lttng-tracer.h"
+
+static
+int (*wrapper_task_prio_sym)(struct task_struct *t);
+
+int wrapper_task_prio_init(void)
+{
+       wrapper_task_prio_sym = (void *) kallsyms_lookup_funcptr("task_prio");
+       if (!wrapper_task_prio_sym) {
+               printk(KERN_WARNING "LTTng: task_prio symbol lookup failed.\n");
+               return -EINVAL;
+       }
+       return 0;
+}
+
+static
+size_t prio_get_size(size_t offset)
+{
+       size_t size = 0;
+
+       size += lib_ring_buffer_align(offset, lttng_alignof(int));
+       size += sizeof(int);
+       return size;
+}
+
+static
+void prio_record(struct lttng_ctx_field *field,
+               struct lib_ring_buffer_ctx *ctx,
+               struct lttng_channel *chan)
+{
+       int prio;
+
+       prio = wrapper_task_prio_sym(current);
+       lib_ring_buffer_align_ctx(ctx, lttng_alignof(prio));
+       chan->ops->event_write(ctx, &prio, sizeof(prio));
+}
+
+int lttng_add_prio_to_ctx(struct lttng_ctx **ctx)
+{
+       struct lttng_ctx_field *field;
+       int ret;
+
+       if (!wrapper_task_prio_sym) {
+               ret = wrapper_task_prio_init();
+               if (ret)
+                       return ret;
+       }
+
+       field = lttng_append_context(ctx);
+       if (!field)
+               return -ENOMEM;
+       if (lttng_find_context(*ctx, "prio")) {
+               lttng_remove_context_field(ctx, field);
+               return -EEXIST;
+       }
+       field->event_field.name = "prio";
+       field->event_field.type.atype = atype_integer;
+       field->event_field.type.u.basic.integer.size = sizeof(int) * CHAR_BIT;
+       field->event_field.type.u.basic.integer.alignment = lttng_alignof(int) * CHAR_BIT;
+       field->event_field.type.u.basic.integer.signedness = lttng_is_signed_type(int);
+       field->event_field.type.u.basic.integer.reverse_byte_order = 0;
+       field->event_field.type.u.basic.integer.base = 10;
+       field->event_field.type.u.basic.integer.encoding = lttng_encode_none;
+       field->get_size = prio_get_size;
+       field->record = prio_record;
+       wrapper_vmalloc_sync_all();
+       return 0;
+}
+EXPORT_SYMBOL_GPL(lttng_add_prio_to_ctx);
+
+MODULE_LICENSE("GPL and additional rights");
+MODULE_AUTHOR("Mathieu Desnoyers");
+MODULE_DESCRIPTION("Linux Trace Toolkit Priority Context");
diff --git a/drivers/staging/lttng/lttng-context-procname.c b/drivers/staging/lttng/lttng-context-procname.c
new file mode 100644 (file)
index 0000000..e9f33a1
--- /dev/null
@@ -0,0 +1,85 @@
+/*
+ * lttng-context-procname.c
+ *
+ * LTTng procname context.
+ *
+ * Copyright (C) 2009-2012 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; only
+ * version 2.1 of the License.
+ *
+ * This library 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
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include <linux/module.h>
+#include <linux/slab.h>
+#include <linux/sched.h>
+#include "lttng-events.h"
+#include "wrapper/ringbuffer/frontend_types.h"
+#include "wrapper/vmalloc.h"
+#include "lttng-tracer.h"
+
+static
+size_t procname_get_size(size_t offset)
+{
+       size_t size = 0;
+
+       size += sizeof(current->comm);
+       return size;
+}
+
+/*
+ * Racy read of procname. We simply copy its whole array size.
+ * Races with /proc/<task>/procname write only.
+ * Otherwise having to take a mutex for each event is cumbersome and
+ * could lead to crash in IRQ context and deadlock of the lockdep tracer.
+ */
+static
+void procname_record(struct lttng_ctx_field *field,
+                struct lib_ring_buffer_ctx *ctx,
+                struct lttng_channel *chan)
+{
+       chan->ops->event_write(ctx, current->comm, sizeof(current->comm));
+}
+
+int lttng_add_procname_to_ctx(struct lttng_ctx **ctx)
+{
+       struct lttng_ctx_field *field;
+
+       field = lttng_append_context(ctx);
+       if (!field)
+               return -ENOMEM;
+       if (lttng_find_context(*ctx, "procname")) {
+               lttng_remove_context_field(ctx, field);
+               return -EEXIST;
+       }
+       field->event_field.name = "procname";
+       field->event_field.type.atype = atype_array;
+       field->event_field.type.u.array.elem_type.atype = atype_integer;
+       field->event_field.type.u.array.elem_type.u.basic.integer.size = sizeof(char) * CHAR_BIT;
+       field->event_field.type.u.array.elem_type.u.basic.integer.alignment = lttng_alignof(char) * CHAR_BIT;
+       field->event_field.type.u.array.elem_type.u.basic.integer.signedness = lttng_is_signed_type(char);
+       field->event_field.type.u.array.elem_type.u.basic.integer.reverse_byte_order = 0;
+       field->event_field.type.u.array.elem_type.u.basic.integer.base = 10;
+       field->event_field.type.u.array.elem_type.u.basic.integer.encoding = lttng_encode_UTF8;
+       field->event_field.type.u.array.length = sizeof(current->comm);
+
+       field->get_size = procname_get_size;
+       field->record = procname_record;
+       wrapper_vmalloc_sync_all();
+       return 0;
+}
+EXPORT_SYMBOL_GPL(lttng_add_procname_to_ctx);
+
+MODULE_LICENSE("GPL and additional rights");
+MODULE_AUTHOR("Mathieu Desnoyers");
+MODULE_DESCRIPTION("Linux Trace Toolkit Perf Support");
diff --git a/drivers/staging/lttng/lttng-context-tid.c b/drivers/staging/lttng/lttng-context-tid.c
new file mode 100644 (file)
index 0000000..de745de
--- /dev/null
@@ -0,0 +1,81 @@
+/*
+ * lttng-context-tid.c
+ *
+ * LTTng TID context.
+ *
+ * Copyright (C) 2009-2012 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; only
+ * version 2.1 of the License.
+ *
+ * This library 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
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include <linux/module.h>
+#include <linux/slab.h>
+#include <linux/sched.h>
+#include "lttng-events.h"
+#include "wrapper/ringbuffer/frontend_types.h"
+#include "wrapper/vmalloc.h"
+#include "lttng-tracer.h"
+
+static
+size_t tid_get_size(size_t offset)
+{
+       size_t size = 0;
+
+       size += lib_ring_buffer_align(offset, lttng_alignof(pid_t));
+       size += sizeof(pid_t);
+       return size;
+}
+
+static
+void tid_record(struct lttng_ctx_field *field,
+                struct lib_ring_buffer_ctx *ctx,
+                struct lttng_channel *chan)
+{
+       pid_t tid;
+
+       tid = task_pid_nr(current);
+       lib_ring_buffer_align_ctx(ctx, lttng_alignof(tid));
+       chan->ops->event_write(ctx, &tid, sizeof(tid));
+}
+
+int lttng_add_tid_to_ctx(struct lttng_ctx **ctx)
+{
+       struct lttng_ctx_field *field;
+
+       field = lttng_append_context(ctx);
+       if (!field)
+               return -ENOMEM;
+       if (lttng_find_context(*ctx, "tid")) {
+               lttng_remove_context_field(ctx, field);
+               return -EEXIST;
+       }
+       field->event_field.name = "tid";
+       field->event_field.type.atype = atype_integer;
+       field->event_field.type.u.basic.integer.size = sizeof(pid_t) * CHAR_BIT;
+       field->event_field.type.u.basic.integer.alignment = lttng_alignof(pid_t) * CHAR_BIT;
+       field->event_field.type.u.basic.integer.signedness = lttng_is_signed_type(pid_t);
+       field->event_field.type.u.basic.integer.reverse_byte_order = 0;
+       field->event_field.type.u.basic.integer.base = 10;
+       field->event_field.type.u.basic.integer.encoding = lttng_encode_none;
+       field->get_size = tid_get_size;
+       field->record = tid_record;
+       wrapper_vmalloc_sync_all();
+       return 0;
+}
+EXPORT_SYMBOL_GPL(lttng_add_tid_to_ctx);
+
+MODULE_LICENSE("GPL and additional rights");
+MODULE_AUTHOR("Mathieu Desnoyers");
+MODULE_DESCRIPTION("Linux Trace Toolkit TID Context");
diff --git a/drivers/staging/lttng/lttng-context-vpid.c b/drivers/staging/lttng/lttng-context-vpid.c
new file mode 100644 (file)
index 0000000..14364b3
--- /dev/null
@@ -0,0 +1,87 @@
+/*
+ * lttng-context-vpid.c
+ *
+ * LTTng vPID context.
+ *
+ * Copyright (C) 2009-2012 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; only
+ * version 2.1 of the License.
+ *
+ * This library 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
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include <linux/module.h>
+#include <linux/slab.h>
+#include <linux/sched.h>
+#include "lttng-events.h"
+#include "wrapper/ringbuffer/frontend_types.h"
+#include "wrapper/vmalloc.h"
+#include "lttng-tracer.h"
+
+static
+size_t vpid_get_size(size_t offset)
+{
+       size_t size = 0;
+
+       size += lib_ring_buffer_align(offset, lttng_alignof(pid_t));
+       size += sizeof(pid_t);
+       return size;
+}
+
+static
+void vpid_record(struct lttng_ctx_field *field,
+                struct lib_ring_buffer_ctx *ctx,
+                struct lttng_channel *chan)
+{
+       pid_t vpid;
+
+       /*
+        * nsproxy can be NULL when scheduled out of exit.
+        */
+       if (!current->nsproxy)
+               vpid = 0;
+       else
+               vpid = task_tgid_vnr(current);
+       lib_ring_buffer_align_ctx(ctx, lttng_alignof(vpid));
+       chan->ops->event_write(ctx, &vpid, sizeof(vpid));
+}
+
+int lttng_add_vpid_to_ctx(struct lttng_ctx **ctx)
+{
+       struct lttng_ctx_field *field;
+
+       field = lttng_append_context(ctx);
+       if (!field)
+               return -ENOMEM;
+       if (lttng_find_context(*ctx, "vpid")) {
+               lttng_remove_context_field(ctx, field);
+               return -EEXIST;
+       }
+       field->event_field.name = "vpid";
+       field->event_field.type.atype = atype_integer;
+       field->event_field.type.u.basic.integer.size = sizeof(pid_t) * CHAR_BIT;
+       field->event_field.type.u.basic.integer.alignment = lttng_alignof(pid_t) * CHAR_BIT;
+       field->event_field.type.u.basic.integer.signedness = lttng_is_signed_type(pid_t);
+       field->event_field.type.u.basic.integer.reverse_byte_order = 0;
+       field->event_field.type.u.basic.integer.base = 10;
+       field->event_field.type.u.basic.integer.encoding = lttng_encode_none;
+       field->get_size = vpid_get_size;
+       field->record = vpid_record;
+       wrapper_vmalloc_sync_all();
+       return 0;
+}
+EXPORT_SYMBOL_GPL(lttng_add_vpid_to_ctx);
+
+MODULE_LICENSE("GPL and additional rights");
+MODULE_AUTHOR("Mathieu Desnoyers");
+MODULE_DESCRIPTION("Linux Trace Toolkit vPID Context");
diff --git a/drivers/staging/lttng/lttng-context-vppid.c b/drivers/staging/lttng/lttng-context-vppid.c
new file mode 100644 (file)
index 0000000..e36b555
--- /dev/null
@@ -0,0 +1,102 @@
+/*
+ * lttng-context-vppid.c
+ *
+ * LTTng vPPID context.
+ *
+ * Copyright (C) 2009-2012 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; only
+ * version 2.1 of the License.
+ *
+ * This library 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
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include <linux/module.h>
+#include <linux/slab.h>
+#include <linux/sched.h>
+#include <linux/syscalls.h>
+#include "lttng-events.h"
+#include "wrapper/ringbuffer/frontend_types.h"
+#include "wrapper/vmalloc.h"
+#include "lttng-tracer.h"
+
+static
+size_t vppid_get_size(size_t offset)
+{
+       size_t size = 0;
+
+       size += lib_ring_buffer_align(offset, lttng_alignof(pid_t));
+       size += sizeof(pid_t);
+       return size;
+}
+
+static
+void vppid_record(struct lttng_ctx_field *field,
+                 struct lib_ring_buffer_ctx *ctx,
+                 struct lttng_channel *chan)
+{
+       struct task_struct *parent;
+       pid_t vppid;
+
+       /*
+        * current nsproxy can be NULL when scheduled out of exit. pid_vnr uses
+        * the current thread nsproxy to perform the lookup.
+        */
+
+       /*
+        * TODO: when we eventually add RCU subsystem instrumentation,
+        * taking the rcu read lock here will trigger RCU tracing
+        * recursively. We should modify the kernel synchronization so
+        * it synchronizes both for RCU and RCU sched, and rely on
+        * rcu_read_lock_sched_notrace.
+        */
+
+       rcu_read_lock();
+       parent = rcu_dereference(current->real_parent);
+       if (!current->nsproxy)
+               vppid = 0;
+       else
+               vppid = task_tgid_vnr(parent);
+       rcu_read_unlock();
+       lib_ring_buffer_align_ctx(ctx, lttng_alignof(vppid));
+       chan->ops->event_write(ctx, &vppid, sizeof(vppid));
+}
+
+int lttng_add_vppid_to_ctx(struct lttng_ctx **ctx)
+{
+       struct lttng_ctx_field *field;
+
+       field = lttng_append_context(ctx);
+       if (!field)
+               return -ENOMEM;
+       if (lttng_find_context(*ctx, "vppid")) {
+               lttng_remove_context_field(ctx, field);
+               return -EEXIST;
+       }
+       field->event_field.name = "vppid";
+       field->event_field.type.atype = atype_integer;
+       field->event_field.type.u.basic.integer.size = sizeof(pid_t) * CHAR_BIT;
+       field->event_field.type.u.basic.integer.alignment = lttng_alignof(pid_t) * CHAR_BIT;
+       field->event_field.type.u.basic.integer.signedness = lttng_is_signed_type(pid_t);
+       field->event_field.type.u.basic.integer.reverse_byte_order = 0;
+       field->event_field.type.u.basic.integer.base = 10;
+       field->event_field.type.u.basic.integer.encoding = lttng_encode_none;
+       field->get_size = vppid_get_size;
+       field->record = vppid_record;
+       wrapper_vmalloc_sync_all();
+       return 0;
+}
+EXPORT_SYMBOL_GPL(lttng_add_vppid_to_ctx);
+
+MODULE_LICENSE("GPL and additional rights");
+MODULE_AUTHOR("Mathieu Desnoyers");
+MODULE_DESCRIPTION("Linux Trace Toolkit vPPID Context");
diff --git a/drivers/staging/lttng/lttng-context-vtid.c b/drivers/staging/lttng/lttng-context-vtid.c
new file mode 100644 (file)
index 0000000..c98bdf1
--- /dev/null
@@ -0,0 +1,87 @@
+/*
+ * lttng-context-vtid.c
+ *
+ * LTTng vTID context.
+ *
+ * Copyright (C) 2009-2012 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; only
+ * version 2.1 of the License.
+ *
+ * This library 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
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include <linux/module.h>
+#include <linux/slab.h>
+#include <linux/sched.h>
+#include "lttng-events.h"
+#include "wrapper/ringbuffer/frontend_types.h"
+#include "wrapper/vmalloc.h"
+#include "lttng-tracer.h"
+
+static
+size_t vtid_get_size(size_t offset)
+{
+       size_t size = 0;
+
+       size += lib_ring_buffer_align(offset, lttng_alignof(pid_t));
+       size += sizeof(pid_t);
+       return size;
+}
+
+static
+void vtid_record(struct lttng_ctx_field *field,
+                struct lib_ring_buffer_ctx *ctx,
+                struct lttng_channel *chan)
+{
+       pid_t vtid;
+
+       /*
+        * nsproxy can be NULL when scheduled out of exit.
+        */
+       if (!current->nsproxy)
+               vtid = 0;
+       else
+               vtid = task_pid_vnr(current);
+       lib_ring_buffer_align_ctx(ctx, lttng_alignof(vtid));
+       chan->ops->event_write(ctx, &vtid, sizeof(vtid));
+}
+
+int lttng_add_vtid_to_ctx(struct lttng_ctx **ctx)
+{
+       struct lttng_ctx_field *field;
+
+       field = lttng_append_context(ctx);
+       if (!field)
+               return -ENOMEM;
+       if (lttng_find_context(*ctx, "vtid")) {
+               lttng_remove_context_field(ctx, field);
+               return -EEXIST;
+       }
+       field->event_field.name = "vtid";
+       field->event_field.type.atype = atype_integer;
+       field->event_field.type.u.basic.integer.size = sizeof(pid_t) * CHAR_BIT;
+       field->event_field.type.u.basic.integer.alignment = lttng_alignof(pid_t) * CHAR_BIT;
+       field->event_field.type.u.basic.integer.signedness = lttng_is_signed_type(pid_t);
+       field->event_field.type.u.basic.integer.reverse_byte_order = 0;
+       field->event_field.type.u.basic.integer.base = 10;
+       field->event_field.type.u.basic.integer.encoding = lttng_encode_none;
+       field->get_size = vtid_get_size;
+       field->record = vtid_record;
+       wrapper_vmalloc_sync_all();
+       return 0;
+}
+EXPORT_SYMBOL_GPL(lttng_add_vtid_to_ctx);
+
+MODULE_LICENSE("GPL and additional rights");
+MODULE_AUTHOR("Mathieu Desnoyers");
+MODULE_DESCRIPTION("Linux Trace Toolkit vTID Context");
diff --git a/drivers/staging/lttng/lttng-context.c b/drivers/staging/lttng/lttng-context.c
new file mode 100644 (file)
index 0000000..17d819d
--- /dev/null
@@ -0,0 +1,105 @@
+/*
+ * lttng-context.c
+ *
+ * LTTng trace/channel/event context management.
+ *
+ * Copyright (C) 2011-2012 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; only
+ * version 2.1 of the License.
+ *
+ * This library 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
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include <linux/module.h>
+#include <linux/list.h>
+#include <linux/mutex.h>
+#include <linux/slab.h>
+#include "wrapper/vmalloc.h"   /* for wrapper_vmalloc_sync_all() */
+#include "lttng-events.h"
+#include "lttng-tracer.h"
+
+int lttng_find_context(struct lttng_ctx *ctx, const char *name)
+{
+       unsigned int i;
+
+       for (i = 0; i < ctx->nr_fields; i++) {
+               /* Skip allocated (but non-initialized) contexts */
+               if (!ctx->fields[i].event_field.name)
+                       continue;
+               if (!strcmp(ctx->fields[i].event_field.name, name))
+                       return 1;
+       }
+       return 0;
+}
+EXPORT_SYMBOL_GPL(lttng_find_context);
+
+/*
+ * Note: as we append context information, the pointer location may change.
+ */
+struct lttng_ctx_field *lttng_append_context(struct lttng_ctx **ctx_p)
+{
+       struct lttng_ctx_field *field;
+       struct lttng_ctx *ctx;
+
+       if (!*ctx_p) {
+               *ctx_p = kzalloc(sizeof(struct lttng_ctx), GFP_KERNEL);
+               if (!*ctx_p)
+                       return NULL;
+       }
+       ctx = *ctx_p;
+       if (ctx->nr_fields + 1 > ctx->allocated_fields) {
+               struct lttng_ctx_field *new_fields;
+
+               ctx->allocated_fields = max_t(size_t, 1, 2 * ctx->allocated_fields);
+               new_fields = kzalloc(ctx->allocated_fields * sizeof(struct lttng_ctx_field), GFP_KERNEL);
+               if (!new_fields)
+                       return NULL;
+               if (ctx->fields)
+                       memcpy(new_fields, ctx->fields, sizeof(*ctx->fields) * ctx->nr_fields);
+               kfree(ctx->fields);
+               ctx->fields = new_fields;
+       }
+       field = &ctx->fields[ctx->nr_fields];
+       ctx->nr_fields++;
+       return field;
+}
+EXPORT_SYMBOL_GPL(lttng_append_context);
+
+/*
+ * Remove last context field.
+ */
+void lttng_remove_context_field(struct lttng_ctx **ctx_p,
+                               struct lttng_ctx_field *field)
+{
+       struct lttng_ctx *ctx;
+
+       ctx = *ctx_p;
+       ctx->nr_fields--;
+       WARN_ON_ONCE(&ctx->fields[ctx->nr_fields] != field);
+       memset(&ctx->fields[ctx->nr_fields], 0, sizeof(struct lttng_ctx_field));
+}
+EXPORT_SYMBOL_GPL(lttng_remove_context_field);
+
+void lttng_destroy_context(struct lttng_ctx *ctx)
+{
+       int i;
+
+       if (!ctx)
+               return;
+       for (i = 0; i < ctx->nr_fields; i++) {
+               if (ctx->fields[i].destroy)
+                       ctx->fields[i].destroy(&ctx->fields[i]);
+       }
+       kfree(ctx->fields);
+       kfree(ctx);
+}
diff --git a/drivers/staging/lttng/lttng-endian.h b/drivers/staging/lttng/lttng-endian.h
new file mode 100644 (file)
index 0000000..f88d974
--- /dev/null
@@ -0,0 +1,43 @@
+#ifndef _LTTNG_ENDIAN_H
+#define _LTTNG_ENDIAN_H
+
+/*
+ * lttng-endian.h
+ *
+ * Copyright (C) 2010-2012 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; only
+ * version 2.1 of the License.
+ *
+ * This library 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
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#ifdef __KERNEL__
+# include <asm/byteorder.h>
+# ifdef __BIG_ENDIAN
+#  define __BYTE_ORDER __BIG_ENDIAN
+# elif defined(__LITTLE_ENDIAN)
+#  define __BYTE_ORDER __LITTLE_ENDIAN
+# else
+#  error "unknown endianness"
+# endif
+#ifndef __BIG_ENDIAN
+# define __BIG_ENDIAN 4321
+#endif
+#ifndef __LITTLE_ENDIAN
+# define __LITTLE_ENDIAN 1234
+#endif
+#else
+# include <endian.h>
+#endif
+
+#endif /* _LTTNG_ENDIAN_H */
diff --git a/drivers/staging/lttng/lttng-events.c b/drivers/staging/lttng/lttng-events.c
new file mode 100644 (file)
index 0000000..41e4dac
--- /dev/null
@@ -0,0 +1,1260 @@
+/*
+ * lttng-events.c
+ *
+ * Holds LTTng per-session event registry.
+ *
+ * Copyright (C) 2010-2012 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; only
+ * version 2.1 of the License.
+ *
+ * This library 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
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include <linux/module.h>
+#include <linux/list.h>
+#include <linux/mutex.h>
+#include <linux/sched.h>
+#include <linux/slab.h>
+#include <linux/jiffies.h>
+#include <linux/utsname.h>
+#include "wrapper/uuid.h"
+#include "wrapper/vmalloc.h"   /* for wrapper_vmalloc_sync_all() */
+#include "wrapper/random.h"
+#include "wrapper/tracepoint.h"
+#include "lttng-kernel-version.h"
+#include "lttng-events.h"
+#include "lttng-tracer.h"
+#include "lttng-abi-old.h"
+
+#define METADATA_CACHE_DEFAULT_SIZE 4096
+
+static LIST_HEAD(sessions);
+static LIST_HEAD(lttng_transport_list);
+/*
+ * Protect the sessions and metadata caches.
+ */
+static DEFINE_MUTEX(sessions_mutex);
+static struct kmem_cache *event_cache;
+
+static void _lttng_event_destroy(struct lttng_event *event);
+static void _lttng_channel_destroy(struct lttng_channel *chan);
+static int _lttng_event_unregister(struct lttng_event *event);
+static
+int _lttng_event_metadata_statedump(struct lttng_session *session,
+                                 struct lttng_channel *chan,
+                                 struct lttng_event *event);
+static
+int _lttng_session_metadata_statedump(struct lttng_session *session);
+static
+void _lttng_metadata_channel_hangup(struct lttng_metadata_stream *stream);
+
+void synchronize_trace(void)
+{
+       synchronize_sched();
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,4,0))
+#ifdef CONFIG_PREEMPT_RT_FULL
+       synchronize_rcu();
+#endif
+#else /* (LINUX_VERSION_CODE >= KERNEL_VERSION(3,4,0)) */
+#ifdef CONFIG_PREEMPT_RT
+       synchronize_rcu();
+#endif
+#endif /* (LINUX_VERSION_CODE >= KERNEL_VERSION(3,4,0)) */
+}
+
+struct lttng_session *lttng_session_create(void)
+{
+       struct lttng_session *session;
+       struct lttng_metadata_cache *metadata_cache;
+
+       mutex_lock(&sessions_mutex);
+       session = kzalloc(sizeof(struct lttng_session), GFP_KERNEL);
+       if (!session)
+               goto err;
+       INIT_LIST_HEAD(&session->chan);
+       INIT_LIST_HEAD(&session->events);
+       uuid_le_gen(&session->uuid);
+
+       metadata_cache = kzalloc(sizeof(struct lttng_metadata_cache),
+                       GFP_KERNEL);
+       if (!metadata_cache)
+               goto err_free_session;
+       metadata_cache->data = kzalloc(METADATA_CACHE_DEFAULT_SIZE,
+                       GFP_KERNEL);
+       if (!metadata_cache->data)
+               goto err_free_cache;
+       metadata_cache->cache_alloc = METADATA_CACHE_DEFAULT_SIZE;
+       kref_init(&metadata_cache->refcount);
+       session->metadata_cache = metadata_cache;
+       INIT_LIST_HEAD(&metadata_cache->metadata_stream);
+       list_add(&session->list, &sessions);
+       mutex_unlock(&sessions_mutex);
+       return session;
+
+err_free_cache:
+       kfree(metadata_cache);
+err_free_session:
+       kfree(session);
+err:
+       mutex_unlock(&sessions_mutex);
+       return NULL;
+}
+
+void metadata_cache_destroy(struct kref *kref)
+{
+       struct lttng_metadata_cache *cache =
+               container_of(kref, struct lttng_metadata_cache, refcount);
+       kfree(cache->data);
+       kfree(cache);
+}
+
+void lttng_session_destroy(struct lttng_session *session)
+{
+       struct lttng_channel *chan, *tmpchan;
+       struct lttng_event *event, *tmpevent;
+       struct lttng_metadata_stream *metadata_stream;
+       int ret;
+
+       mutex_lock(&sessions_mutex);
+       ACCESS_ONCE(session->active) = 0;
+       list_for_each_entry(chan, &session->chan, list) {
+               ret = lttng_syscalls_unregister(chan);
+               WARN_ON(ret);
+       }
+       list_for_each_entry(event, &session->events, list) {
+               ret = _lttng_event_unregister(event);
+               WARN_ON(ret);
+       }
+       synchronize_trace();    /* Wait for in-flight events to complete */
+       list_for_each_entry_safe(event, tmpevent, &session->events, list)
+               _lttng_event_destroy(event);
+       list_for_each_entry_safe(chan, tmpchan, &session->chan, list) {
+               BUG_ON(chan->channel_type == METADATA_CHANNEL);
+               _lttng_channel_destroy(chan);
+       }
+       list_for_each_entry(metadata_stream, &session->metadata_cache->metadata_stream, list)
+               _lttng_metadata_channel_hangup(metadata_stream);
+       kref_put(&session->metadata_cache->refcount, metadata_cache_destroy);
+       list_del(&session->list);
+       mutex_unlock(&sessions_mutex);
+       kfree(session);
+}
+
+int lttng_session_enable(struct lttng_session *session)
+{
+       int ret = 0;
+       struct lttng_channel *chan;
+
+       mutex_lock(&sessions_mutex);
+       if (session->active) {
+               ret = -EBUSY;
+               goto end;
+       }
+
+       /*
+        * Snapshot the number of events per channel to know the type of header
+        * we need to use.
+        */
+       list_for_each_entry(chan, &session->chan, list) {
+               if (chan->header_type)
+                       continue;               /* don't change it if session stop/restart */
+               if (chan->free_event_id < 31)
+                       chan->header_type = 1;  /* compact */
+               else
+                       chan->header_type = 2;  /* large */
+       }
+
+       ACCESS_ONCE(session->active) = 1;
+       ACCESS_ONCE(session->been_active) = 1;
+       ret = _lttng_session_metadata_statedump(session);
+       if (ret) {
+               ACCESS_ONCE(session->active) = 0;
+               goto end;
+       }
+       ret = lttng_statedump_start(session);
+       if (ret)
+               ACCESS_ONCE(session->active) = 0;
+end:
+       mutex_unlock(&sessions_mutex);
+       return ret;
+}
+
+int lttng_session_disable(struct lttng_session *session)
+{
+       int ret = 0;
+
+       mutex_lock(&sessions_mutex);
+       if (!session->active) {
+               ret = -EBUSY;
+               goto end;
+       }
+       ACCESS_ONCE(session->active) = 0;
+end:
+       mutex_unlock(&sessions_mutex);
+       return ret;
+}
+
+int lttng_channel_enable(struct lttng_channel *channel)
+{
+       int old;
+
+       if (channel->channel_type == METADATA_CHANNEL)
+               return -EPERM;
+       old = xchg(&channel->enabled, 1);
+       if (old)
+               return -EEXIST;
+       return 0;
+}
+
+int lttng_channel_disable(struct lttng_channel *channel)
+{
+       int old;
+
+       if (channel->channel_type == METADATA_CHANNEL)
+               return -EPERM;
+       old = xchg(&channel->enabled, 0);
+       if (!old)
+               return -EEXIST;
+       return 0;
+}
+
+int lttng_event_enable(struct lttng_event *event)
+{
+       int old;
+
+       if (event->chan->channel_type == METADATA_CHANNEL)
+               return -EPERM;
+       old = xchg(&event->enabled, 1);
+       if (old)
+               return -EEXIST;
+       return 0;
+}
+
+int lttng_event_disable(struct lttng_event *event)
+{
+       int old;
+
+       if (event->chan->channel_type == METADATA_CHANNEL)
+               return -EPERM;
+       old = xchg(&event->enabled, 0);
+       if (!old)
+               return -EEXIST;
+       return 0;
+}
+
+static struct lttng_transport *lttng_transport_find(const char *name)
+{
+       struct lttng_transport *transport;
+
+       list_for_each_entry(transport, &lttng_transport_list, node) {
+               if (!strcmp(transport->name, name))
+                       return transport;
+       }
+       return NULL;
+}
+
+struct lttng_channel *lttng_channel_create(struct lttng_session *session,
+                                      const char *transport_name,
+                                      void *buf_addr,
+                                      size_t subbuf_size, size_t num_subbuf,
+                                      unsigned int switch_timer_interval,
+                                      unsigned int read_timer_interval,
+                                      enum channel_type channel_type)
+{
+       struct lttng_channel *chan;
+       struct lttng_transport *transport = NULL;
+
+       mutex_lock(&sessions_mutex);
+       if (session->been_active && channel_type != METADATA_CHANNEL)
+               goto active;    /* Refuse to add channel to active session */
+       transport = lttng_transport_find(transport_name);
+       if (!transport) {
+               printk(KERN_WARNING "LTTng transport %s not found\n",
+                      transport_name);
+               goto notransport;
+       }
+       if (!try_module_get(transport->owner)) {
+               printk(KERN_WARNING "LTT : Can't lock transport module.\n");
+               goto notransport;
+       }
+       chan = kzalloc(sizeof(struct lttng_channel), GFP_KERNEL);
+       if (!chan)
+               goto nomem;
+       chan->session = session;
+       chan->id = session->free_chan_id++;
+       /*
+        * Note: the channel creation op already writes into the packet
+        * headers. Therefore the "chan" information used as input
+        * should be already accessible.
+        */
+       chan->chan = transport->ops.channel_create(transport_name,
+                       chan, buf_addr, subbuf_size, num_subbuf,
+                       switch_timer_interval, read_timer_interval);
+       if (!chan->chan)
+               goto create_error;
+       chan->enabled = 1;
+       chan->ops = &transport->ops;
+       chan->transport = transport;
+       chan->channel_type = channel_type;
+       list_add(&chan->list, &session->chan);
+       mutex_unlock(&sessions_mutex);
+       return chan;
+
+create_error:
+       kfree(chan);
+nomem:
+       if (transport)
+               module_put(transport->owner);
+notransport:
+active:
+       mutex_unlock(&sessions_mutex);
+       return NULL;
+}
+
+/*
+ * Only used internally at session destruction for per-cpu channels, and
+ * when metadata channel is released.
+ * Needs to be called with sessions mutex held.
+ */
+static
+void _lttng_channel_destroy(struct lttng_channel *chan)
+{
+       chan->ops->channel_destroy(chan->chan);
+       module_put(chan->transport->owner);
+       list_del(&chan->list);
+       lttng_destroy_context(chan->ctx);
+       kfree(chan);
+}
+
+void lttng_metadata_channel_destroy(struct lttng_channel *chan)
+{
+       BUG_ON(chan->channel_type != METADATA_CHANNEL);
+
+       /* Protect the metadata cache with the sessions_mutex. */
+       mutex_lock(&sessions_mutex);
+       _lttng_channel_destroy(chan);
+       mutex_unlock(&sessions_mutex);
+}
+EXPORT_SYMBOL_GPL(lttng_metadata_channel_destroy);
+
+static
+void _lttng_metadata_channel_hangup(struct lttng_metadata_stream *stream)
+{
+       stream->finalized = 1;
+       wake_up_interruptible(&stream->read_wait);
+}
+
+/*
+ * Supports event creation while tracing session is active.
+ */
+struct lttng_event *lttng_event_create(struct lttng_channel *chan,
+                                  struct lttng_kernel_event *event_param,
+                                  void *filter,
+                                  const struct lttng_event_desc *internal_desc)
+{
+       struct lttng_event *event;
+       int ret;
+
+       mutex_lock(&sessions_mutex);
+       if (chan->free_event_id == -1U)
+               goto full;
+       /*
+        * This is O(n^2) (for each event, the loop is called at event
+        * creation). Might require a hash if we have lots of events.
+        */
+       list_for_each_entry(event, &chan->session->events, list)
+               if (!strcmp(event->desc->name, event_param->name))
+                       goto exist;
+       event = kmem_cache_zalloc(event_cache, GFP_KERNEL);
+       if (!event)
+               goto cache_error;
+       event->chan = chan;
+       event->filter = filter;
+       event->id = chan->free_event_id++;
+       event->enabled = 1;
+       event->instrumentation = event_param->instrumentation;
+       /* Populate lttng_event structure before tracepoint registration. */
+       smp_wmb();
+       switch (event_param->instrumentation) {
+       case LTTNG_KERNEL_TRACEPOINT:
+               event->desc = lttng_event_get(event_param->name);
+               if (!event->desc)
+                       goto register_error;
+               ret = kabi_2635_tracepoint_probe_register(event_param->name,
+                               event->desc->probe_callback,
+                               event);
+               if (ret)
+                       goto register_error;
+               break;
+       case LTTNG_KERNEL_KPROBE:
+               ret = lttng_kprobes_register(event_param->name,
+                               event_param->u.kprobe.symbol_name,
+                               event_param->u.kprobe.offset,
+                               event_param->u.kprobe.addr,
+                               event);
+               if (ret)
+                       goto register_error;
+               ret = try_module_get(event->desc->owner);
+               WARN_ON_ONCE(!ret);
+               break;
+       case LTTNG_KERNEL_KRETPROBE:
+       {
+               struct lttng_event *event_return;
+
+               /* kretprobe defines 2 events */
+               event_return =
+                       kmem_cache_zalloc(event_cache, GFP_KERNEL);
+               if (!event_return)
+                       goto register_error;
+               event_return->chan = chan;
+               event_return->filter = filter;
+               event_return->id = chan->free_event_id++;
+               event_return->enabled = 1;
+               event_return->instrumentation = event_param->instrumentation;
+               /*
+                * Populate lttng_event structure before kretprobe registration.
+                */
+               smp_wmb();
+               ret = lttng_kretprobes_register(event_param->name,
+                               event_param->u.kretprobe.symbol_name,
+                               event_param->u.kretprobe.offset,
+                               event_param->u.kretprobe.addr,
+                               event, event_return);
+               if (ret) {
+                       kmem_cache_free(event_cache, event_return);
+                       goto register_error;
+               }
+               /* Take 2 refs on the module: one per event. */
+               ret = try_module_get(event->desc->owner);
+               WARN_ON_ONCE(!ret);
+               ret = try_module_get(event->desc->owner);
+               WARN_ON_ONCE(!ret);
+               ret = _lttng_event_metadata_statedump(chan->session, chan,
+                                                   event_return);
+               if (ret) {
+                       kmem_cache_free(event_cache, event_return);
+                       module_put(event->desc->owner);
+                       module_put(event->desc->owner);
+                       goto statedump_error;
+               }
+               list_add(&event_return->list, &chan->session->events);
+               break;
+       }
+       case LTTNG_KERNEL_FUNCTION:
+               ret = lttng_ftrace_register(event_param->name,
+                               event_param->u.ftrace.symbol_name,
+                               event);
+               if (ret)
+                       goto register_error;
+               ret = try_module_get(event->desc->owner);
+               WARN_ON_ONCE(!ret);
+               break;
+       case LTTNG_KERNEL_NOOP:
+               event->desc = internal_desc;
+               if (!event->desc)
+                       goto register_error;
+               break;
+       default:
+               WARN_ON_ONCE(1);
+               goto register_error;
+       }
+       ret = _lttng_event_metadata_statedump(chan->session, chan, event);
+       if (ret)
+               goto statedump_error;
+       list_add(&event->list, &chan->session->events);
+       mutex_unlock(&sessions_mutex);
+       return event;
+
+statedump_error:
+       /* If a statedump error occurs, events will not be readable. */
+register_error:
+       kmem_cache_free(event_cache, event);
+cache_error:
+exist:
+full:
+       mutex_unlock(&sessions_mutex);
+       return NULL;
+}
+
+/*
+ * Only used internally at session destruction.
+ */
+int _lttng_event_unregister(struct lttng_event *event)
+{
+       int ret = -EINVAL;
+
+       switch (event->instrumentation) {
+       case LTTNG_KERNEL_TRACEPOINT:
+               ret = kabi_2635_tracepoint_probe_unregister(event->desc->name,
+                                                 event->desc->probe_callback,
+                                                 event);
+               if (ret)
+                       return ret;
+               break;
+       case LTTNG_KERNEL_KPROBE:
+               lttng_kprobes_unregister(event);
+               ret = 0;
+               break;
+       case LTTNG_KERNEL_KRETPROBE:
+               lttng_kretprobes_unregister(event);
+               ret = 0;
+               break;
+       case LTTNG_KERNEL_FUNCTION:
+               lttng_ftrace_unregister(event);
+               ret = 0;
+               break;
+       case LTTNG_KERNEL_NOOP:
+               ret = 0;
+               break;
+       default:
+               WARN_ON_ONCE(1);
+       }
+       return ret;
+}
+
+/*
+ * Only used internally at session destruction.
+ */
+static
+void _lttng_event_destroy(struct lttng_event *event)
+{
+       switch (event->instrumentation) {
+       case LTTNG_KERNEL_TRACEPOINT:
+               lttng_event_put(event->desc);
+               break;
+       case LTTNG_KERNEL_KPROBE:
+               module_put(event->desc->owner);
+               lttng_kprobes_destroy_private(event);
+               break;
+       case LTTNG_KERNEL_KRETPROBE:
+               module_put(event->desc->owner);
+               lttng_kretprobes_destroy_private(event);
+               break;
+       case LTTNG_KERNEL_FUNCTION:
+               module_put(event->desc->owner);
+               lttng_ftrace_destroy_private(event);
+               break;
+       case LTTNG_KERNEL_NOOP:
+               break;
+       default:
+               WARN_ON_ONCE(1);
+       }
+       list_del(&event->list);
+       lttng_destroy_context(event->ctx);
+       kmem_cache_free(event_cache, event);
+}
+
+/*
+ * Serialize at most one packet worth of metadata into a metadata
+ * channel.
+ * We have exclusive access to our metadata buffer (protected by the
+ * sessions_mutex), so we can do racy operations such as looking for
+ * remaining space left in packet and write, since mutual exclusion
+ * protects us from concurrent writes.
+ */
+int lttng_metadata_output_channel(struct lttng_metadata_stream *stream,
+               struct channel *chan)
+{
+       struct lib_ring_buffer_ctx ctx;
+       int ret = 0;
+       size_t len, reserve_len;
+
+       /*
+        * Ensure we support mutiple get_next / put sequences followed
+        * by put_next.
+        */
+       WARN_ON(stream->metadata_in < stream->metadata_out);
+       if (stream->metadata_in != stream->metadata_out)
+               return 0;
+
+       len = stream->metadata_cache->metadata_written -
+               stream->metadata_in;
+       if (!len)
+               return 0;
+       reserve_len = min_t(size_t,
+                       stream->transport->ops.packet_avail_size(chan),
+                       len);
+       lib_ring_buffer_ctx_init(&ctx, chan, NULL, reserve_len,
+                       sizeof(char), -1);
+       /*
+        * If reservation failed, return an error to the caller.
+        */
+       ret = stream->transport->ops.event_reserve(&ctx, 0);
+       if (ret != 0) {
+               printk(KERN_WARNING "LTTng: Metadata event reservation failed\n");
+               goto end;
+       }
+       stream->transport->ops.event_write(&ctx,
+                       stream->metadata_cache->data + stream->metadata_in,
+                       reserve_len);
+       stream->transport->ops.event_commit(&ctx);
+       stream->metadata_in += reserve_len;
+       ret = reserve_len;
+
+end:
+       return ret;
+}
+
+/*
+ * Write the metadata to the metadata cache.
+ * Must be called with sessions_mutex held.
+ */
+int lttng_metadata_printf(struct lttng_session *session,
+                         const char *fmt, ...)
+{
+       char *str;
+       size_t len;
+       va_list ap;
+       struct lttng_metadata_stream *stream;
+
+       WARN_ON_ONCE(!ACCESS_ONCE(session->active));
+
+       va_start(ap, fmt);
+       str = kvasprintf(GFP_KERNEL, fmt, ap);
+       va_end(ap);
+       if (!str)
+               return -ENOMEM;
+
+       len = strlen(str);
+       if (session->metadata_cache->metadata_written + len >
+                       session->metadata_cache->cache_alloc) {
+               char *tmp_cache_realloc;
+               unsigned int tmp_cache_alloc_size;
+
+               tmp_cache_alloc_size = max_t(unsigned int,
+                               session->metadata_cache->cache_alloc + len,
+                               session->metadata_cache->cache_alloc << 1);
+               tmp_cache_realloc = krealloc(session->metadata_cache->data,
+                               tmp_cache_alloc_size, GFP_KERNEL);
+               if (!tmp_cache_realloc)
+                       goto err;
+               session->metadata_cache->cache_alloc = tmp_cache_alloc_size;
+               session->metadata_cache->data = tmp_cache_realloc;
+       }
+       memcpy(session->metadata_cache->data +
+                       session->metadata_cache->metadata_written,
+                       str, len);
+       session->metadata_cache->metadata_written += len;
+       kfree(str);
+
+       list_for_each_entry(stream, &session->metadata_cache->metadata_stream, list)
+               wake_up_interruptible(&stream->read_wait);
+
+       return 0;
+
+err:
+       kfree(str);
+       return -ENOMEM;
+}
+
+/*
+ * Must be called with sessions_mutex held.
+ */
+static
+int _lttng_field_statedump(struct lttng_session *session,
+                        const struct lttng_event_field *field)
+{
+       int ret = 0;
+
+       switch (field->type.atype) {
+       case atype_integer:
+               ret = lttng_metadata_printf(session,
+                       "               integer { size = %u; align = %u; signed = %u; encoding = %s; base = %u;%s } _%s;\n",
+                       field->type.u.basic.integer.size,
+                       field->type.u.basic.integer.alignment,
+                       field->type.u.basic.integer.signedness,
+                       (field->type.u.basic.integer.encoding == lttng_encode_none)
+                               ? "none"
+                               : (field->type.u.basic.integer.encoding == lttng_encode_UTF8)
+                                       ? "UTF8"
+                                       : "ASCII",
+                       field->type.u.basic.integer.base,
+#ifdef __BIG_ENDIAN
+                       field->type.u.basic.integer.reverse_byte_order ? " byte_order = le;" : "",
+#else
+                       field->type.u.basic.integer.reverse_byte_order ? " byte_order = be;" : "",
+#endif
+                       field->name);
+               break;
+       case atype_enum:
+               ret = lttng_metadata_printf(session,
+                       "               %s _%s;\n",
+                       field->type.u.basic.enumeration.name,
+                       field->name);
+               break;
+       case atype_array:
+       {
+               const struct lttng_basic_type *elem_type;
+
+               elem_type = &field->type.u.array.elem_type;
+               ret = lttng_metadata_printf(session,
+                       "               integer { size = %u; align = %u; signed = %u; encoding = %s; base = %u;%s } _%s[%u];\n",
+                       elem_type->u.basic.integer.size,
+                       elem_type->u.basic.integer.alignment,
+                       elem_type->u.basic.integer.signedness,
+                       (elem_type->u.basic.integer.encoding == lttng_encode_none)
+                               ? "none"
+                               : (elem_type->u.basic.integer.encoding == lttng_encode_UTF8)
+                                       ? "UTF8"
+                                       : "ASCII",
+                       elem_type->u.basic.integer.base,
+#ifdef __BIG_ENDIAN
+                       elem_type->u.basic.integer.reverse_byte_order ? " byte_order = le;" : "",
+#else
+                       elem_type->u.basic.integer.reverse_byte_order ? " byte_order = be;" : "",
+#endif
+                       field->name, field->type.u.array.length);
+               break;
+       }
+       case atype_sequence:
+       {
+               const struct lttng_basic_type *elem_type;
+               const struct lttng_basic_type *length_type;
+
+               elem_type = &field->type.u.sequence.elem_type;
+               length_type = &field->type.u.sequence.length_type;
+               ret = lttng_metadata_printf(session,
+                       "               integer { size = %u; align = %u; signed = %u; encoding = %s; base = %u;%s } __%s_length;\n",
+                       length_type->u.basic.integer.size,
+                       (unsigned int) length_type->u.basic.integer.alignment,
+                       length_type->u.basic.integer.signedness,
+                       (length_type->u.basic.integer.encoding == lttng_encode_none)
+                               ? "none"
+                               : ((length_type->u.basic.integer.encoding == lttng_encode_UTF8)
+                                       ? "UTF8"
+                                       : "ASCII"),
+                       length_type->u.basic.integer.base,
+#ifdef __BIG_ENDIAN
+                       length_type->u.basic.integer.reverse_byte_order ? " byte_order = le;" : "",
+#else
+                       length_type->u.basic.integer.reverse_byte_order ? " byte_order = be;" : "",
+#endif
+                       field->name);
+               if (ret)
+                       return ret;
+
+               ret = lttng_metadata_printf(session,
+                       "               integer { size = %u; align = %u; signed = %u; encoding = %s; base = %u;%s } _%s[ __%s_length ];\n",
+                       elem_type->u.basic.integer.size,
+                       (unsigned int) elem_type->u.basic.integer.alignment,
+                       elem_type->u.basic.integer.signedness,
+                       (elem_type->u.basic.integer.encoding == lttng_encode_none)
+                               ? "none"
+                               : ((elem_type->u.basic.integer.encoding == lttng_encode_UTF8)
+                                       ? "UTF8"
+                                       : "ASCII"),
+                       elem_type->u.basic.integer.base,
+#ifdef __BIG_ENDIAN
+                       elem_type->u.basic.integer.reverse_byte_order ? " byte_order = le;" : "",
+#else
+                       elem_type->u.basic.integer.reverse_byte_order ? " byte_order = be;" : "",
+#endif
+                       field->name,
+                       field->name);
+               break;
+       }
+
+       case atype_string:
+               /* Default encoding is UTF8 */
+               ret = lttng_metadata_printf(session,
+                       "               string%s _%s;\n",
+                       field->type.u.basic.string.encoding == lttng_encode_ASCII ?
+                               " { encoding = ASCII; }" : "",
+                       field->name);
+               break;
+       default:
+               WARN_ON_ONCE(1);
+               return -EINVAL;
+       }
+       return ret;
+}
+
+static
+int _lttng_context_metadata_statedump(struct lttng_session *session,
+                                   struct lttng_ctx *ctx)
+{
+       int ret = 0;
+       int i;
+
+       if (!ctx)
+               return 0;
+       for (i = 0; i < ctx->nr_fields; i++) {
+               const struct lttng_ctx_field *field = &ctx->fields[i];
+
+               ret = _lttng_field_statedump(session, &field->event_field);
+               if (ret)
+                       return ret;
+       }
+       return ret;
+}
+
+static
+int _lttng_fields_metadata_statedump(struct lttng_session *session,
+                                  struct lttng_event *event)
+{
+       const struct lttng_event_desc *desc = event->desc;
+       int ret = 0;
+       int i;
+
+       for (i = 0; i < desc->nr_fields; i++) {
+               const struct lttng_event_field *field = &desc->fields[i];
+
+               ret = _lttng_field_statedump(session, field);
+               if (ret)
+                       return ret;
+       }
+       return ret;
+}
+
+/*
+ * Must be called with sessions_mutex held.
+ */
+static
+int _lttng_event_metadata_statedump(struct lttng_session *session,
+                                 struct lttng_channel *chan,
+                                 struct lttng_event *event)
+{
+       int ret = 0;
+
+       if (event->metadata_dumped || !ACCESS_ONCE(session->active))
+               return 0;
+       if (chan->channel_type == METADATA_CHANNEL)
+               return 0;
+
+       ret = lttng_metadata_printf(session,
+               "event {\n"
+               "       name = %s;\n"
+               "       id = %u;\n"
+               "       stream_id = %u;\n",
+               event->desc->name,
+               event->id,
+               event->chan->id);
+       if (ret)
+               goto end;
+
+       if (event->ctx) {
+               ret = lttng_metadata_printf(session,
+                       "       context := struct {\n");
+               if (ret)
+                       goto end;
+       }
+       ret = _lttng_context_metadata_statedump(session, event->ctx);
+       if (ret)
+               goto end;
+       if (event->ctx) {
+               ret = lttng_metadata_printf(session,
+                       "       };\n");
+               if (ret)
+                       goto end;
+       }
+
+       ret = lttng_metadata_printf(session,
+               "       fields := struct {\n"
+               );
+       if (ret)
+               goto end;
+
+       ret = _lttng_fields_metadata_statedump(session, event);
+       if (ret)
+               goto end;
+
+       /*
+        * LTTng space reservation can only reserve multiples of the
+        * byte size.
+        */
+       ret = lttng_metadata_printf(session,
+               "       };\n"
+               "};\n\n");
+       if (ret)
+               goto end;
+
+       event->metadata_dumped = 1;
+end:
+       return ret;
+
+}
+
+/*
+ * Must be called with sessions_mutex held.
+ */
+static
+int _lttng_channel_metadata_statedump(struct lttng_session *session,
+                                   struct lttng_channel *chan)
+{
+       int ret = 0;
+
+       if (chan->metadata_dumped || !ACCESS_ONCE(session->active))
+               return 0;
+
+       if (chan->channel_type == METADATA_CHANNEL)
+               return 0;
+
+       WARN_ON_ONCE(!chan->header_type);
+       ret = lttng_metadata_printf(session,
+               "stream {\n"
+               "       id = %u;\n"
+               "       event.header := %s;\n"
+               "       packet.context := struct packet_context;\n",
+               chan->id,
+               chan->header_type == 1 ? "struct event_header_compact" :
+                       "struct event_header_large");
+       if (ret)
+               goto end;
+
+       if (chan->ctx) {
+               ret = lttng_metadata_printf(session,
+                       "       event.context := struct {\n");
+               if (ret)
+                       goto end;
+       }
+       ret = _lttng_context_metadata_statedump(session, chan->ctx);
+       if (ret)
+               goto end;
+       if (chan->ctx) {
+               ret = lttng_metadata_printf(session,
+                       "       };\n");
+               if (ret)
+                       goto end;
+       }
+
+       ret = lttng_metadata_printf(session,
+               "};\n\n");
+
+       chan->metadata_dumped = 1;
+end:
+       return ret;
+}
+
+/*
+ * Must be called with sessions_mutex held.
+ */
+static
+int _lttng_stream_packet_context_declare(struct lttng_session *session)
+{
+       return lttng_metadata_printf(session,
+               "struct packet_context {\n"
+               "       uint64_clock_monotonic_t timestamp_begin;\n"
+               "       uint64_clock_monotonic_t timestamp_end;\n"
+               "       uint64_t content_size;\n"
+               "       uint64_t packet_size;\n"
+               "       unsigned long events_discarded;\n"
+               "       uint32_t cpu_id;\n"
+               "};\n\n"
+               );
+}
+
+/*
+ * Compact header:
+ * id: range: 0 - 30.
+ * id 31 is reserved to indicate an extended header.
+ *
+ * Large header:
+ * id: range: 0 - 65534.
+ * id 65535 is reserved to indicate an extended header.
+ *
+ * Must be called with sessions_mutex held.
+ */
+static
+int _lttng_event_header_declare(struct lttng_session *session)
+{
+       return lttng_metadata_printf(session,
+       "struct event_header_compact {\n"
+       "       enum : uint5_t { compact = 0 ... 30, extended = 31 } id;\n"
+       "       variant <id> {\n"
+       "               struct {\n"
+       "                       uint27_clock_monotonic_t timestamp;\n"
+       "               } compact;\n"
+       "               struct {\n"
+       "                       uint32_t id;\n"
+       "                       uint64_clock_monotonic_t timestamp;\n"
+       "               } extended;\n"
+       "       } v;\n"
+       "} align(%u);\n"
+       "\n"
+       "struct event_header_large {\n"
+       "       enum : uint16_t { compact = 0 ... 65534, extended = 65535 } id;\n"
+       "       variant <id> {\n"
+       "               struct {\n"
+       "                       uint32_clock_monotonic_t timestamp;\n"
+       "               } compact;\n"
+       "               struct {\n"
+       "                       uint32_t id;\n"
+       "                       uint64_clock_monotonic_t timestamp;\n"
+       "               } extended;\n"
+       "       } v;\n"
+       "} align(%u);\n\n",
+       lttng_alignof(uint32_t) * CHAR_BIT,
+       lttng_alignof(uint16_t) * CHAR_BIT
+       );
+}
+
+ /*
+ * Approximation of NTP time of day to clock monotonic correlation,
+ * taken at start of trace.
+ * Yes, this is only an approximation. Yes, we can (and will) do better
+ * in future versions.
+ */
+static
+uint64_t measure_clock_offset(void)
+{
+       uint64_t offset, monotonic[2], realtime;
+       struct timespec rts = { 0, 0 };
+       unsigned long flags;
+
+       /* Disable interrupts to increase correlation precision. */
+       local_irq_save(flags);
+       monotonic[0] = trace_clock_read64();
+       getnstimeofday(&rts);
+       monotonic[1] = trace_clock_read64();
+       local_irq_restore(flags);
+
+       offset = (monotonic[0] + monotonic[1]) >> 1;
+       realtime = (uint64_t) rts.tv_sec * NSEC_PER_SEC;
+       realtime += rts.tv_nsec;
+       offset = realtime - offset;
+       return offset;
+}
+
+/*
+ * Output metadata into this session's metadata buffers.
+ * Must be called with sessions_mutex held.
+ */
+static
+int _lttng_session_metadata_statedump(struct lttng_session *session)
+{
+       unsigned char *uuid_c = session->uuid.b;
+       unsigned char uuid_s[37], clock_uuid_s[BOOT_ID_LEN];
+       struct lttng_channel *chan;
+       struct lttng_event *event;
+       int ret = 0;
+
+       if (!ACCESS_ONCE(session->active))
+               return 0;
+       if (session->metadata_dumped)
+               goto skip_session;
+
+       snprintf(uuid_s, sizeof(uuid_s),
+               "%02x%02x%02x%02x-%02x%02x-%02x%02x-%02x%02x-%02x%02x%02x%02x%02x%02x",
+               uuid_c[0], uuid_c[1], uuid_c[2], uuid_c[3],
+               uuid_c[4], uuid_c[5], uuid_c[6], uuid_c[7],
+               uuid_c[8], uuid_c[9], uuid_c[10], uuid_c[11],
+               uuid_c[12], uuid_c[13], uuid_c[14], uuid_c[15]);
+
+       ret = lttng_metadata_printf(session,
+               "typealias integer { size = 8; align = %u; signed = false; } := uint8_t;\n"
+               "typealias integer { size = 16; align = %u; signed = false; } := uint16_t;\n"
+               "typealias integer { size = 32; align = %u; signed = false; } := uint32_t;\n"
+               "typealias integer { size = 64; align = %u; signed = false; } := uint64_t;\n"
+               "typealias integer { size = %u; align = %u; signed = false; } := unsigned long;\n"
+               "typealias integer { size = 5; align = 1; signed = false; } := uint5_t;\n"
+               "typealias integer { size = 27; align = 1; signed = false; } := uint27_t;\n"
+               "\n"
+               "trace {\n"
+               "       major = %u;\n"
+               "       minor = %u;\n"
+               "       uuid = \"%s\";\n"
+               "       byte_order = %s;\n"
+               "       packet.header := struct {\n"
+               "               uint32_t magic;\n"
+               "               uint8_t  uuid[16];\n"
+               "               uint32_t stream_id;\n"
+               "       };\n"
+               "};\n\n",
+               lttng_alignof(uint8_t) * CHAR_BIT,
+               lttng_alignof(uint16_t) * CHAR_BIT,
+               lttng_alignof(uint32_t) * CHAR_BIT,
+               lttng_alignof(uint64_t) * CHAR_BIT,
+               sizeof(unsigned long) * CHAR_BIT,
+               lttng_alignof(unsigned long) * CHAR_BIT,
+               CTF_SPEC_MAJOR,
+               CTF_SPEC_MINOR,
+               uuid_s,
+#ifdef __BIG_ENDIAN
+               "be"
+#else
+               "le"
+#endif
+               );
+       if (ret)
+               goto end;
+
+       ret = lttng_metadata_printf(session,
+               "env {\n"
+               "       hostname = \"%s\";\n"
+               "       domain = \"kernel\";\n"
+               "       sysname = \"%s\";\n"
+               "       kernel_release = \"%s\";\n"
+               "       kernel_version = \"%s\";\n"
+               "       tracer_name = \"lttng-modules\";\n"
+               "       tracer_major = %d;\n"
+               "       tracer_minor = %d;\n"
+               "       tracer_patchlevel = %d;\n"
+               "};\n\n",
+               current->nsproxy->uts_ns->name.nodename,
+               utsname()->sysname,
+               utsname()->release,
+               utsname()->version,
+               LTTNG_MODULES_MAJOR_VERSION,
+               LTTNG_MODULES_MINOR_VERSION,
+               LTTNG_MODULES_PATCHLEVEL_VERSION
+               );
+       if (ret)
+               goto end;
+
+       ret = lttng_metadata_printf(session,
+               "clock {\n"
+               "       name = %s;\n",
+               "monotonic"
+               );
+       if (ret)
+               goto end;
+
+       if (!trace_clock_uuid(clock_uuid_s)) {
+               ret = lttng_metadata_printf(session,
+                       "       uuid = \"%s\";\n",
+                       clock_uuid_s
+                       );
+               if (ret)
+                       goto end;
+       }
+
+       ret = lttng_metadata_printf(session,
+               "       description = \"Monotonic Clock\";\n"
+               "       freq = %llu; /* Frequency, in Hz */\n"
+               "       /* clock value offset from Epoch is: offset * (1/freq) */\n"
+               "       offset = %llu;\n"
+               "};\n\n",
+               (unsigned long long) trace_clock_freq(),
+               (unsigned long long) measure_clock_offset()
+               );
+       if (ret)
+               goto end;
+
+       ret = lttng_metadata_printf(session,
+               "typealias integer {\n"
+               "       size = 27; align = 1; signed = false;\n"
+               "       map = clock.monotonic.value;\n"
+               "} := uint27_clock_monotonic_t;\n"
+               "\n"
+               "typealias integer {\n"
+               "       size = 32; align = %u; signed = false;\n"
+               "       map = clock.monotonic.value;\n"
+               "} := uint32_clock_monotonic_t;\n"
+               "\n"
+               "typealias integer {\n"
+               "       size = 64; align = %u; signed = false;\n"
+               "       map = clock.monotonic.value;\n"
+               "} := uint64_clock_monotonic_t;\n\n",
+               lttng_alignof(uint32_t) * CHAR_BIT,
+               lttng_alignof(uint64_t) * CHAR_BIT
+               );
+       if (ret)
+               goto end;
+
+       ret = _lttng_stream_packet_context_declare(session);
+       if (ret)
+               goto end;
+
+       ret = _lttng_event_header_declare(session);
+       if (ret)
+               goto end;
+
+skip_session:
+       list_for_each_entry(chan, &session->chan, list) {
+               ret = _lttng_channel_metadata_statedump(session, chan);
+               if (ret)
+                       goto end;
+       }
+
+       list_for_each_entry(event, &session->events, list) {
+               ret = _lttng_event_metadata_statedump(session, event->chan, event);
+               if (ret)
+                       goto end;
+       }
+       session->metadata_dumped = 1;
+end:
+       return ret;
+}
+
+/**
+ * lttng_transport_register - LTT transport registration
+ * @transport: transport structure
+ *
+ * Registers a transport which can be used as output to extract the data out of
+ * LTTng. The module calling this registration function must ensure that no
+ * trap-inducing code will be executed by the transport functions. E.g.
+ * vmalloc_sync_all() must be called between a vmalloc and the moment the memory
+ * is made visible to the transport function. This registration acts as a
+ * vmalloc_sync_all. Therefore, only if the module allocates virtual memory
+ * after its registration must it synchronize the TLBs.
+ */
+void lttng_transport_register(struct lttng_transport *transport)
+{
+       /*
+        * Make sure no page fault can be triggered by the module about to be
+        * registered. We deal with this here so we don't have to call
+        * vmalloc_sync_all() in each module's init.
+        */
+       wrapper_vmalloc_sync_all();
+
+       mutex_lock(&sessions_mutex);
+       list_add_tail(&transport->node, &lttng_transport_list);
+       mutex_unlock(&sessions_mutex);
+}
+EXPORT_SYMBOL_GPL(lttng_transport_register);
+
+/**
+ * lttng_transport_unregister - LTT transport unregistration
+ * @transport: transport structure
+ */
+void lttng_transport_unregister(struct lttng_transport *transport)
+{
+       mutex_lock(&sessions_mutex);
+       list_del(&transport->node);
+       mutex_unlock(&sessions_mutex);
+}
+EXPORT_SYMBOL_GPL(lttng_transport_unregister);
+
+static int __init lttng_events_init(void)
+{
+       int ret;
+
+       event_cache = KMEM_CACHE(lttng_event, 0);
+       if (!event_cache)
+               return -ENOMEM;
+       ret = lttng_abi_init();
+       if (ret)
+               goto error_abi;
+       return 0;
+error_abi:
+       kmem_cache_destroy(event_cache);
+       return ret;
+}
+
+module_init(lttng_events_init);
+
+static void __exit lttng_events_exit(void)
+{
+       struct lttng_session *session, *tmpsession;
+
+       lttng_abi_exit();
+       list_for_each_entry_safe(session, tmpsession, &sessions, list)
+               lttng_session_destroy(session);
+       kmem_cache_destroy(event_cache);
+}
+
+module_exit(lttng_events_exit);
+
+MODULE_LICENSE("GPL and additional rights");
+MODULE_AUTHOR("Mathieu Desnoyers <mathieu.desnoyers@efficios.com>");
+MODULE_DESCRIPTION("LTTng Events");
diff --git a/drivers/staging/lttng/lttng-events.h b/drivers/staging/lttng/lttng-events.h
new file mode 100644 (file)
index 0000000..bc5cd9f
--- /dev/null
@@ -0,0 +1,507 @@
+#ifndef _LTTNG_EVENTS_H
+#define _LTTNG_EVENTS_H
+
+/*
+ * lttng-events.h
+ *
+ * Holds LTTng per-session event registry.
+ *
+ * Copyright (C) 2010-2012 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; only
+ * version 2.1 of the License.
+ *
+ * This library 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
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include <linux/version.h>
+#include <linux/list.h>
+#include <linux/kprobes.h>
+#include <linux/kref.h>
+#include "wrapper/uuid.h"
+#include "lttng-abi.h"
+#include "lttng-abi-old.h"
+
+#define lttng_is_signed_type(type)     (((type)(-1)) < 0)
+
+struct lttng_channel;
+struct lttng_session;
+struct lttng_metadata_cache;
+struct lib_ring_buffer_ctx;
+struct perf_event;
+struct perf_event_attr;
+
+/* Type description */
+
+/* Update the astract_types name table in lttng-types.c along with this enum */
+enum abstract_types {
+       atype_integer,
+       atype_enum,
+       atype_array,
+       atype_sequence,
+       atype_string,
+       NR_ABSTRACT_TYPES,
+};
+
+/* Update the string_encodings name table in lttng-types.c along with this enum */
+enum lttng_string_encodings {
+       lttng_encode_none = 0,
+       lttng_encode_UTF8 = 1,
+       lttng_encode_ASCII = 2,
+       NR_STRING_ENCODINGS,
+};
+
+enum channel_type {
+       PER_CPU_CHANNEL,
+       METADATA_CHANNEL,
+};
+
+struct lttng_enum_entry {
+       unsigned long long start, end;  /* start and end are inclusive */
+       const char *string;
+};
+
+#define __type_integer(_type, _byte_order, _base, _encoding)   \
+       {                                                       \
+           .atype = atype_integer,                             \
+           .u.basic.integer =                                  \
+               {                                               \
+                 .size = sizeof(_type) * CHAR_BIT,             \
+                 .alignment = lttng_alignof(_type) * CHAR_BIT, \
+                 .signedness = lttng_is_signed_type(_type),    \
+                 .reverse_byte_order = _byte_order != __BYTE_ORDER,    \
+                 .base = _base,                                \
+                 .encoding = lttng_encode_##_encoding,         \
+               },                                              \
+       }                                                       \
+
+struct lttng_integer_type {
+       unsigned int size;              /* in bits */
+       unsigned short alignment;       /* in bits */
+       unsigned int signedness:1,
+               reverse_byte_order:1;
+       unsigned int base;              /* 2, 8, 10, 16, for pretty print */
+       enum lttng_string_encodings encoding;
+};
+
+union _lttng_basic_type {
+       struct lttng_integer_type integer;
+       struct {
+               const char *name;
+       } enumeration;
+       struct {
+               enum lttng_string_encodings encoding;
+       } string;
+};
+
+struct lttng_basic_type {
+       enum abstract_types atype;
+       union {
+               union _lttng_basic_type basic;
+       } u;
+};
+
+struct lttng_type {
+       enum abstract_types atype;
+       union {
+               union _lttng_basic_type basic;
+               struct {
+                       struct lttng_basic_type elem_type;
+                       unsigned int length;            /* num. elems. */
+               } array;
+               struct {
+                       struct lttng_basic_type length_type;
+                       struct lttng_basic_type elem_type;
+               } sequence;
+       } u;
+};
+
+struct lttng_enum {
+       const char *name;
+       struct lttng_type container_type;
+       const struct lttng_enum_entry *entries;
+       unsigned int len;
+};
+
+/* Event field description */
+
+struct lttng_event_field {
+       const char *name;
+       struct lttng_type type;
+};
+
+/*
+ * We need to keep this perf counter field separately from struct
+ * lttng_ctx_field because cpu hotplug needs fixed-location addresses.
+ */
+struct lttng_perf_counter_field {
+       struct notifier_block nb;
+       int hp_enable;
+       struct perf_event_attr *attr;
+       struct perf_event **e;  /* per-cpu array */
+};
+
+struct lttng_ctx_field {
+       struct lttng_event_field event_field;
+       size_t (*get_size)(size_t offset);
+       void (*record)(struct lttng_ctx_field *field,
+                      struct lib_ring_buffer_ctx *ctx,
+                      struct lttng_channel *chan);
+       union {
+               struct lttng_perf_counter_field *perf_counter;
+       } u;
+       void (*destroy)(struct lttng_ctx_field *field);
+};
+
+struct lttng_ctx {
+       struct lttng_ctx_field *fields;
+       unsigned int nr_fields;
+       unsigned int allocated_fields;
+};
+
+struct lttng_event_desc {
+       const char *name;
+       void *probe_callback;
+       const struct lttng_event_ctx *ctx;      /* context */
+       const struct lttng_event_field *fields; /* event payload */
+       unsigned int nr_fields;
+       struct module *owner;
+};
+
+struct lttng_probe_desc {
+       const struct lttng_event_desc **event_desc;
+       unsigned int nr_events;
+       struct list_head head;                  /* chain registered probes */
+};
+
+struct lttng_krp;                              /* Kretprobe handling */
+
+/*
+ * lttng_event structure is referred to by the tracing fast path. It must be
+ * kept small.
+ */
+struct lttng_event {
+       unsigned int id;
+       struct lttng_channel *chan;
+       int enabled;
+       const struct lttng_event_desc *desc;
+       void *filter;
+       struct lttng_ctx *ctx;
+       enum lttng_kernel_instrumentation instrumentation;
+       union {
+               struct {
+                       struct kprobe kp;
+                       char *symbol_name;
+               } kprobe;
+               struct {
+                       struct lttng_krp *lttng_krp;
+                       char *symbol_name;
+               } kretprobe;
+               struct {
+                       char *symbol_name;
+               } ftrace;
+       } u;
+       struct list_head list;          /* Event list */
+       unsigned int metadata_dumped:1;
+};
+
+struct lttng_channel_ops {
+       struct channel *(*channel_create)(const char *name,
+                               struct lttng_channel *lttng_chan,
+                               void *buf_addr,
+                               size_t subbuf_size, size_t num_subbuf,
+                               unsigned int switch_timer_interval,
+                               unsigned int read_timer_interval);
+       void (*channel_destroy)(struct channel *chan);
+       struct lib_ring_buffer *(*buffer_read_open)(struct channel *chan);
+       int (*buffer_has_read_closed_stream)(struct channel *chan);
+       void (*buffer_read_close)(struct lib_ring_buffer *buf);
+       int (*event_reserve)(struct lib_ring_buffer_ctx *ctx,
+                            uint32_t event_id);
+       void (*event_commit)(struct lib_ring_buffer_ctx *ctx);
+       void (*event_write)(struct lib_ring_buffer_ctx *ctx, const void *src,
+                           size_t len);
+       void (*event_write_from_user)(struct lib_ring_buffer_ctx *ctx,
+                                     const void *src, size_t len);
+       void (*event_memset)(struct lib_ring_buffer_ctx *ctx,
+                            int c, size_t len);
+       /*
+        * packet_avail_size returns the available size in the current
+        * packet. Note that the size returned is only a hint, since it
+        * may change due to concurrent writes.
+        */
+       size_t (*packet_avail_size)(struct channel *chan);
+       wait_queue_head_t *(*get_writer_buf_wait_queue)(struct channel *chan, int cpu);
+       wait_queue_head_t *(*get_hp_wait_queue)(struct channel *chan);
+       int (*is_finalized)(struct channel *chan);
+       int (*is_disabled)(struct channel *chan);
+};
+
+struct lttng_transport {
+       char *name;
+       struct module *owner;
+       struct list_head node;
+       struct lttng_channel_ops ops;
+};
+
+struct lttng_channel {
+       unsigned int id;
+       struct channel *chan;           /* Channel buffers */
+       int enabled;
+       struct lttng_ctx *ctx;
+       /* Event ID management */
+       struct lttng_session *session;
+       struct file *file;              /* File associated to channel */
+       unsigned int free_event_id;     /* Next event ID to allocate */
+       struct list_head list;          /* Channel list */
+       struct lttng_channel_ops *ops;
+       struct lttng_transport *transport;
+       struct lttng_event **sc_table;  /* for syscall tracing */
+       struct lttng_event **compat_sc_table;
+       struct lttng_event *sc_unknown; /* for unknown syscalls */
+       struct lttng_event *sc_compat_unknown;
+       struct lttng_event *sc_exit;    /* for syscall exit */
+       int header_type;                /* 0: unset, 1: compact, 2: large */
+       enum channel_type channel_type;
+       unsigned int metadata_dumped:1;
+};
+
+struct lttng_metadata_stream {
+       void *priv;                     /* Ring buffer private data */
+       struct lttng_metadata_cache *metadata_cache;
+       unsigned int metadata_in;       /* Bytes read from the cache */
+       unsigned int metadata_out;      /* Bytes consumed from stream */
+       int finalized;                  /* Has channel been finalized */
+       wait_queue_head_t read_wait;    /* Reader buffer-level wait queue */
+       struct list_head list;          /* Stream list */
+       struct lttng_transport *transport;
+};
+
+struct lttng_session {
+       int active;                     /* Is trace session active ? */
+       int been_active;                /* Has trace session been active ? */
+       struct file *file;              /* File associated to session */
+       struct list_head chan;          /* Channel list head */
+       struct list_head events;        /* Event list head */
+       struct list_head list;          /* Session list */
+       unsigned int free_chan_id;      /* Next chan ID to allocate */
+       uuid_le uuid;                   /* Trace session unique ID */
+       struct lttng_metadata_cache *metadata_cache;
+       unsigned int metadata_dumped:1;
+};
+
+struct lttng_metadata_cache {
+       char *data;                     /* Metadata cache */
+       unsigned int cache_alloc;       /* Metadata allocated size (bytes) */
+       unsigned int metadata_written;  /* Number of bytes written in metadata cache */
+       struct kref refcount;           /* Metadata cache usage */
+       struct list_head metadata_stream;       /* Metadata stream list */
+};
+
+struct lttng_session *lttng_session_create(void);
+int lttng_session_enable(struct lttng_session *session);
+int lttng_session_disable(struct lttng_session *session);
+void lttng_session_destroy(struct lttng_session *session);
+void metadata_cache_destroy(struct kref *kref);
+
+struct lttng_channel *lttng_channel_create(struct lttng_session *session,
+                                      const char *transport_name,
+                                      void *buf_addr,
+                                      size_t subbuf_size, size_t num_subbuf,
+                                      unsigned int switch_timer_interval,
+                                      unsigned int read_timer_interval,
+                                      enum channel_type channel_type);
+struct lttng_channel *lttng_global_channel_create(struct lttng_session *session,
+                                      int overwrite, void *buf_addr,
+                                      size_t subbuf_size, size_t num_subbuf,
+                                      unsigned int switch_timer_interval,
+                                      unsigned int read_timer_interval);
+
+void lttng_metadata_channel_destroy(struct lttng_channel *chan);
+struct lttng_event *lttng_event_create(struct lttng_channel *chan,
+                                  struct lttng_kernel_event *event_param,
+                                  void *filter,
+                                  const struct lttng_event_desc *internal_desc);
+struct lttng_event *lttng_event_compat_old_create(struct lttng_channel *chan,
+               struct lttng_kernel_old_event *old_event_param,
+               void *filter,
+               const struct lttng_event_desc *internal_desc);
+
+int lttng_channel_enable(struct lttng_channel *channel);
+int lttng_channel_disable(struct lttng_channel *channel);
+int lttng_event_enable(struct lttng_event *event);
+int lttng_event_disable(struct lttng_event *event);
+
+void lttng_transport_register(struct lttng_transport *transport);
+void lttng_transport_unregister(struct lttng_transport *transport);
+
+void synchronize_trace(void);
+int lttng_abi_init(void);
+int lttng_abi_compat_old_init(void);
+void lttng_abi_exit(void);
+void lttng_abi_compat_old_exit(void);
+
+int lttng_probe_register(struct lttng_probe_desc *desc);
+void lttng_probe_unregister(struct lttng_probe_desc *desc);
+const struct lttng_event_desc *lttng_event_get(const char *name);
+void lttng_event_put(const struct lttng_event_desc *desc);
+int lttng_probes_init(void);
+void lttng_probes_exit(void);
+
+int lttng_metadata_output_channel(struct lttng_metadata_stream *stream,
+               struct channel *chan);
+
+#if defined(CONFIG_HAVE_SYSCALL_TRACEPOINTS)
+int lttng_syscalls_register(struct lttng_channel *chan, void *filter);
+int lttng_syscalls_unregister(struct lttng_channel *chan);
+#else
+static inline int lttng_syscalls_register(struct lttng_channel *chan, void *filter)
+{
+       return -ENOSYS;
+}
+
+static inline int lttng_syscalls_unregister(struct lttng_channel *chan)
+{
+       return 0;
+}
+#endif
+
+struct lttng_ctx_field *lttng_append_context(struct lttng_ctx **ctx);
+int lttng_find_context(struct lttng_ctx *ctx, const char *name);
+void lttng_remove_context_field(struct lttng_ctx **ctx,
+                               struct lttng_ctx_field *field);
+void lttng_destroy_context(struct lttng_ctx *ctx);
+int lttng_add_pid_to_ctx(struct lttng_ctx **ctx);
+int lttng_add_procname_to_ctx(struct lttng_ctx **ctx);
+int lttng_add_prio_to_ctx(struct lttng_ctx **ctx);
+int lttng_add_nice_to_ctx(struct lttng_ctx **ctx);
+int lttng_add_vpid_to_ctx(struct lttng_ctx **ctx);
+int lttng_add_tid_to_ctx(struct lttng_ctx **ctx);
+int lttng_add_vtid_to_ctx(struct lttng_ctx **ctx);
+int lttng_add_ppid_to_ctx(struct lttng_ctx **ctx);
+int lttng_add_vppid_to_ctx(struct lttng_ctx **ctx);
+int lttng_add_hostname_to_ctx(struct lttng_ctx **ctx);
+#if defined(CONFIG_PERF_EVENTS) && (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,33))
+int lttng_add_perf_counter_to_ctx(uint32_t type,
+                                 uint64_t config,
+                                 const char *name,
+                                 struct lttng_ctx **ctx);
+#else
+static inline
+int lttng_add_perf_counter_to_ctx(uint32_t type,
+                                 uint64_t config,
+                                 const char *name,
+                                 struct lttng_ctx **ctx)
+{
+       return -ENOSYS;
+}
+#endif
+
+extern int lttng_statedump_start(struct lttng_session *session);
+
+#ifdef CONFIG_KPROBES
+int lttng_kprobes_register(const char *name,
+               const char *symbol_name,
+               uint64_t offset,
+               uint64_t addr,
+               struct lttng_event *event);
+void lttng_kprobes_unregister(struct lttng_event *event);
+void lttng_kprobes_destroy_private(struct lttng_event *event);
+#else
+static inline
+int lttng_kprobes_register(const char *name,
+               const char *symbol_name,
+               uint64_t offset,
+               uint64_t addr,
+               struct lttng_event *event)
+{
+       return -ENOSYS;
+}
+
+static inline
+void lttng_kprobes_unregister(struct lttng_event *event)
+{
+}
+
+static inline
+void lttng_kprobes_destroy_private(struct lttng_event *event)
+{
+}
+#endif
+
+#ifdef CONFIG_KRETPROBES
+int lttng_kretprobes_register(const char *name,
+               const char *symbol_name,
+               uint64_t offset,
+               uint64_t addr,
+               struct lttng_event *event_entry,
+               struct lttng_event *event_exit);
+void lttng_kretprobes_unregister(struct lttng_event *event);
+void lttng_kretprobes_destroy_private(struct lttng_event *event);
+#else
+static inline
+int lttng_kretprobes_register(const char *name,
+               const char *symbol_name,
+               uint64_t offset,
+               uint64_t addr,
+               struct lttng_event *event_entry,
+               struct lttng_event *event_exit)
+{
+       return -ENOSYS;
+}
+
+static inline
+void lttng_kretprobes_unregister(struct lttng_event *event)
+{
+}
+
+static inline
+void lttng_kretprobes_destroy_private(struct lttng_event *event)
+{
+}
+#endif
+
+#ifdef CONFIG_DYNAMIC_FTRACE
+int lttng_ftrace_register(const char *name,
+                         const char *symbol_name,
+                         struct lttng_event *event);
+void lttng_ftrace_unregister(struct lttng_event *event);
+void lttng_ftrace_destroy_private(struct lttng_event *event);
+#else
+static inline
+int lttng_ftrace_register(const char *name,
+                         const char *symbol_name,
+                         struct lttng_event *event)
+{
+       return -ENOSYS;
+}
+
+static inline
+void lttng_ftrace_unregister(struct lttng_event *event)
+{
+}
+
+static inline
+void lttng_ftrace_destroy_private(struct lttng_event *event)
+{
+}
+#endif
+
+int lttng_calibrate(struct lttng_kernel_calibrate *calibrate);
+
+extern const struct file_operations lttng_tracepoint_list_fops;
+
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,35))
+#define TRACEPOINT_HAS_DATA_ARG
+#endif
+
+#endif /* _LTTNG_EVENTS_H */
diff --git a/drivers/staging/lttng/lttng-kernel-version.h b/drivers/staging/lttng/lttng-kernel-version.h
new file mode 100644 (file)
index 0000000..0eb56b3
--- /dev/null
@@ -0,0 +1,36 @@
+#ifndef _LTTNG_KERNEL_VERSION_H
+#define _LTTNG_KERNEL_VERSION_H
+
+/*
+ * lttng-kernel-version.h
+ *
+ * Contains helpers to check more complex kernel version conditions.
+ *
+ * Copyright (C) 2012 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; only
+ * version 2.1 of the License.
+ *
+ * This library 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
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include <linux/version.h>
+
+/*
+ * This macro checks if the kernel version is between the two specified
+ * versions (lower limit inclusive, upper limit exclusive).
+ */
+#define LTTNG_KERNEL_RANGE(a_low, b_low, c_low, a_high, b_high, c_high) \
+       (LINUX_VERSION_CODE >= KERNEL_VERSION(a_low, b_low, c_low) && \
+        LINUX_VERSION_CODE < KERNEL_VERSION(a_high, b_high, c_high))
+
+#endif /* _LTTNG_KERNEL_VERSION_H */
diff --git a/drivers/staging/lttng/lttng-probes.c b/drivers/staging/lttng/lttng-probes.c
new file mode 100644 (file)
index 0000000..d6a6cf2
--- /dev/null
@@ -0,0 +1,171 @@
+/*
+ * lttng-probes.c
+ *
+ * Holds LTTng probes registry.
+ *
+ * Copyright (C) 2010-2012 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; only
+ * version 2.1 of the License.
+ *
+ * This library 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
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include <linux/module.h>
+#include <linux/list.h>
+#include <linux/mutex.h>
+#include <linux/seq_file.h>
+
+#include "lttng-events.h"
+
+static LIST_HEAD(probe_list);
+static DEFINE_MUTEX(probe_mutex);
+
+static
+const struct lttng_event_desc *find_event(const char *name)
+{
+       struct lttng_probe_desc *probe_desc;
+       int i;
+
+       list_for_each_entry(probe_desc, &probe_list, head) {
+               for (i = 0; i < probe_desc->nr_events; i++) {
+                       if (!strcmp(probe_desc->event_desc[i]->name, name))
+                               return probe_desc->event_desc[i];
+               }
+       }
+       return NULL;
+}
+
+int lttng_probe_register(struct lttng_probe_desc *desc)
+{
+       int ret = 0;
+       int i;
+
+       mutex_lock(&probe_mutex);
+       /*
+        * TODO: This is O(N^2). Turn into a hash table when probe registration
+        * overhead becomes an issue.
+        */
+       for (i = 0; i < desc->nr_events; i++) {
+               if (find_event(desc->event_desc[i]->name)) {
+                       ret = -EEXIST;
+                       goto end;
+               }
+       }
+       list_add(&desc->head, &probe_list);
+end:
+       mutex_unlock(&probe_mutex);
+       return ret;
+}
+EXPORT_SYMBOL_GPL(lttng_probe_register);
+
+void lttng_probe_unregister(struct lttng_probe_desc *desc)
+{
+       mutex_lock(&probe_mutex);
+       list_del(&desc->head);
+       mutex_unlock(&probe_mutex);
+}
+EXPORT_SYMBOL_GPL(lttng_probe_unregister);
+
+const struct lttng_event_desc *lttng_event_get(const char *name)
+{
+       const struct lttng_event_desc *event;
+       int ret;
+
+       mutex_lock(&probe_mutex);
+       event = find_event(name);
+       mutex_unlock(&probe_mutex);
+       if (!event)
+               return NULL;
+       ret = try_module_get(event->owner);
+       WARN_ON_ONCE(!ret);
+       return event;
+}
+EXPORT_SYMBOL_GPL(lttng_event_get);
+
+void lttng_event_put(const struct lttng_event_desc *event)
+{
+       module_put(event->owner);
+}
+EXPORT_SYMBOL_GPL(lttng_event_put);
+
+static
+void *tp_list_start(struct seq_file *m, loff_t *pos)
+{
+       struct lttng_probe_desc *probe_desc;
+       int iter = 0, i;
+
+       mutex_lock(&probe_mutex);
+       list_for_each_entry(probe_desc, &probe_list, head) {
+               for (i = 0; i < probe_desc->nr_events; i++) {
+                       if (iter++ >= *pos)
+                               return (void *) probe_desc->event_desc[i];
+               }
+       }
+       /* End of list */
+       return NULL;
+}
+
+static
+void *tp_list_next(struct seq_file *m, void *p, loff_t *ppos)
+{
+       struct lttng_probe_desc *probe_desc;
+       int iter = 0, i;
+
+       (*ppos)++;
+       list_for_each_entry(probe_desc, &probe_list, head) {
+               for (i = 0; i < probe_desc->nr_events; i++) {
+                       if (iter++ >= *ppos)
+                               return (void *) probe_desc->event_desc[i];
+               }
+       }
+       /* End of list */
+       return NULL;
+}
+
+static
+void tp_list_stop(struct seq_file *m, void *p)
+{
+       mutex_unlock(&probe_mutex);
+}
+
+static
+int tp_list_show(struct seq_file *m, void *p)
+{
+       const struct lttng_event_desc *probe_desc = p;
+
+       seq_printf(m,   "event { name = %s; };\n",
+                  probe_desc->name);
+       return 0;
+}
+
+static
+const struct seq_operations lttng_tracepoint_list_seq_ops = {
+       .start = tp_list_start,
+       .next = tp_list_next,
+       .stop = tp_list_stop,
+       .show = tp_list_show,
+};
+
+static
+int lttng_tracepoint_list_open(struct inode *inode, struct file *file)
+{
+       return seq_open(file, &lttng_tracepoint_list_seq_ops);
+}
+
+const struct file_operations lttng_tracepoint_list_fops = {
+       .owner = THIS_MODULE,
+       .open = lttng_tracepoint_list_open,
+       .read = seq_read,
+       .llseek = seq_lseek,
+       .release = seq_release,
+};
diff --git a/drivers/staging/lttng/lttng-ring-buffer-client-discard.c b/drivers/staging/lttng/lttng-ring-buffer-client-discard.c
new file mode 100644 (file)
index 0000000..52eb811
--- /dev/null
@@ -0,0 +1,33 @@
+/*
+ * lttng-ring-buffer-client-discard.c
+ *
+ * LTTng lib ring buffer client (discard mode).
+ *
+ * Copyright (C) 2010-2012 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; only
+ * version 2.1 of the License.
+ *
+ * This library 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
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include <linux/module.h>
+#include "lttng-tracer.h"
+
+#define RING_BUFFER_MODE_TEMPLATE              RING_BUFFER_DISCARD
+#define RING_BUFFER_MODE_TEMPLATE_STRING       "discard"
+#define RING_BUFFER_OUTPUT_TEMPLATE            RING_BUFFER_SPLICE
+#include "lttng-ring-buffer-client.h"
+
+MODULE_LICENSE("GPL and additional rights");
+MODULE_AUTHOR("Mathieu Desnoyers");
+MODULE_DESCRIPTION("LTTng Ring Buffer Client Discard Mode");
diff --git a/drivers/staging/lttng/lttng-ring-buffer-client-mmap-discard.c b/drivers/staging/lttng/lttng-ring-buffer-client-mmap-discard.c
new file mode 100644 (file)
index 0000000..11d0449
--- /dev/null
@@ -0,0 +1,33 @@
+/*
+ * lttng-ring-buffer-client-discard.c
+ *
+ * LTTng lib ring buffer client (discard mode).
+ *
+ * Copyright (C) 2010-2012 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; only
+ * version 2.1 of the License.
+ *
+ * This library 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
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include <linux/module.h>
+#include "lttng-tracer.h"
+
+#define RING_BUFFER_MODE_TEMPLATE              RING_BUFFER_DISCARD
+#define RING_BUFFER_MODE_TEMPLATE_STRING       "discard-mmap"
+#define RING_BUFFER_OUTPUT_TEMPLATE            RING_BUFFER_MMAP
+#include "lttng-ring-buffer-client.h"
+
+MODULE_LICENSE("GPL and additional rights");
+MODULE_AUTHOR("Mathieu Desnoyers");
+MODULE_DESCRIPTION("LTTng Ring Buffer Client Discard Mode");
diff --git a/drivers/staging/lttng/lttng-ring-buffer-client-mmap-overwrite.c b/drivers/staging/lttng/lttng-ring-buffer-client-mmap-overwrite.c
new file mode 100644 (file)
index 0000000..d68847a
--- /dev/null
@@ -0,0 +1,33 @@
+/*
+ * lttng-ring-buffer-client-overwrite.c
+ *
+ * LTTng lib ring buffer client (overwrite mode).
+ *
+ * Copyright (C) 2010-2012 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; only
+ * version 2.1 of the License.
+ *
+ * This library 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
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include <linux/module.h>
+#include "lttng-tracer.h"
+
+#define RING_BUFFER_MODE_TEMPLATE              RING_BUFFER_OVERWRITE
+#define RING_BUFFER_MODE_TEMPLATE_STRING       "overwrite-mmap"
+#define RING_BUFFER_OUTPUT_TEMPLATE            RING_BUFFER_MMAP
+#include "lttng-ring-buffer-client.h"
+
+MODULE_LICENSE("GPL and additional rights");
+MODULE_AUTHOR("Mathieu Desnoyers");
+MODULE_DESCRIPTION("LTTng Ring Buffer Client Overwrite Mode");
diff --git a/drivers/staging/lttng/lttng-ring-buffer-client-overwrite.c b/drivers/staging/lttng/lttng-ring-buffer-client-overwrite.c
new file mode 100644 (file)
index 0000000..10de68f
--- /dev/null
@@ -0,0 +1,33 @@
+/*
+ * lttng-ring-buffer-client-overwrite.c
+ *
+ * LTTng lib ring buffer client (overwrite mode).
+ *
+ * Copyright (C) 2010-2012 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; only
+ * version 2.1 of the License.
+ *
+ * This library 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
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include <linux/module.h>
+#include "lttng-tracer.h"
+
+#define RING_BUFFER_MODE_TEMPLATE              RING_BUFFER_OVERWRITE
+#define RING_BUFFER_MODE_TEMPLATE_STRING       "overwrite"
+#define RING_BUFFER_OUTPUT_TEMPLATE            RING_BUFFER_SPLICE
+#include "lttng-ring-buffer-client.h"
+
+MODULE_LICENSE("GPL and additional rights");
+MODULE_AUTHOR("Mathieu Desnoyers");
+MODULE_DESCRIPTION("LTTng Ring Buffer Client Overwrite Mode");
diff --git a/drivers/staging/lttng/lttng-ring-buffer-client.h b/drivers/staging/lttng/lttng-ring-buffer-client.h
new file mode 100644 (file)
index 0000000..0b05561
--- /dev/null
@@ -0,0 +1,600 @@
+/*
+ * lttng-ring-buffer-client.h
+ *
+ * LTTng lib ring buffer client template.
+ *
+ * Copyright (C) 2010-2012 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; only
+ * version 2.1 of the License.
+ *
+ * This library 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
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include <linux/module.h>
+#include <linux/types.h>
+#include "lib/bitfield.h"
+#include "wrapper/vmalloc.h"   /* for wrapper_vmalloc_sync_all() */
+#include "wrapper/trace-clock.h"
+#include "lttng-events.h"
+#include "lttng-tracer.h"
+#include "wrapper/ringbuffer/frontend_types.h"
+
+#define LTTNG_COMPACT_EVENT_BITS       5
+#define LTTNG_COMPACT_TSC_BITS         27
+
+/*
+ * Keep the natural field alignment for _each field_ within this structure if
+ * you ever add/remove a field from this header. Packed attribute is not used
+ * because gcc generates poor code on at least powerpc and mips. Don't ever
+ * let gcc add padding between the structure elements.
+ *
+ * The guarantee we have with timestamps is that all the events in a
+ * packet are included (inclusive) within the begin/end timestamps of
+ * the packet. Another guarantee we have is that the "timestamp begin",
+ * as well as the event timestamps, are monotonically increasing (never
+ * decrease) when moving forward in a stream (physically). But this
+ * guarantee does not apply to "timestamp end", because it is sampled at
+ * commit time, which is not ordered with respect to space reservation.
+ */
+
+struct packet_header {
+       /* Trace packet header */
+       uint32_t magic;                 /*
+                                        * Trace magic number.
+                                        * contains endianness information.
+                                        */
+       uint8_t uuid[16];
+       uint32_t stream_id;
+
+       struct {
+               /* Stream packet context */
+               uint64_t timestamp_begin;       /* Cycle count at subbuffer start */
+               uint64_t timestamp_end;         /* Cycle count at subbuffer end */
+               uint64_t content_size;          /* Size of data in subbuffer */
+               uint64_t packet_size;           /* Subbuffer size (include padding) */
+               unsigned long events_discarded; /*
+                                                * Events lost in this subbuffer since
+                                                * the beginning of the trace.
+                                                * (may overflow)
+                                                */
+               uint32_t cpu_id;                /* CPU id associated with stream */
+               uint8_t header_end;             /* End of header */
+       } ctx;
+};
+
+
+static inline notrace u64 lib_ring_buffer_clock_read(struct channel *chan)
+{
+       return trace_clock_read64();
+}
+
+static inline
+size_t ctx_get_size(size_t offset, struct lttng_ctx *ctx)
+{
+       int i;
+       size_t orig_offset = offset;
+
+       if (likely(!ctx))
+               return 0;
+       for (i = 0; i < ctx->nr_fields; i++)
+               offset += ctx->fields[i].get_size(offset);
+       return offset - orig_offset;
+}
+
+static inline
+void ctx_record(struct lib_ring_buffer_ctx *bufctx,
+               struct lttng_channel *chan,
+               struct lttng_ctx *ctx)
+{
+       int i;
+
+       if (likely(!ctx))
+               return;
+       for (i = 0; i < ctx->nr_fields; i++)
+               ctx->fields[i].record(&ctx->fields[i], bufctx, chan);
+}
+
+/*
+ * record_header_size - Calculate the header size and padding necessary.
+ * @config: ring buffer instance configuration
+ * @chan: channel
+ * @offset: offset in the write buffer
+ * @pre_header_padding: padding to add before the header (output)
+ * @ctx: reservation context
+ *
+ * Returns the event header size (including padding).
+ *
+ * The payload must itself determine its own alignment from the biggest type it
+ * contains.
+ */
+static __inline__
+unsigned char record_header_size(const struct lib_ring_buffer_config *config,
+                                struct channel *chan, size_t offset,
+                                size_t *pre_header_padding,
+                                struct lib_ring_buffer_ctx *ctx)
+{
+       struct lttng_channel *lttng_chan = channel_get_private(chan);
+       struct lttng_event *event = ctx->priv;
+       size_t orig_offset = offset;
+       size_t padding;
+
+       switch (lttng_chan->header_type) {
+       case 1: /* compact */
+               padding = lib_ring_buffer_align(offset, lttng_alignof(uint32_t));
+               offset += padding;
+               if (!(ctx->rflags & (RING_BUFFER_RFLAG_FULL_TSC | LTTNG_RFLAG_EXTENDED))) {
+                       offset += sizeof(uint32_t);     /* id and timestamp */
+               } else {
+                       /* Minimum space taken by LTTNG_COMPACT_EVENT_BITS id */
+                       offset += (LTTNG_COMPACT_EVENT_BITS + CHAR_BIT - 1) / CHAR_BIT;
+                       /* Align extended struct on largest member */
+                       offset += lib_ring_buffer_align(offset, lttng_alignof(uint64_t));
+                       offset += sizeof(uint32_t);     /* id */
+                       offset += lib_ring_buffer_align(offset, lttng_alignof(uint64_t));
+                       offset += sizeof(uint64_t);     /* timestamp */
+               }
+               break;
+       case 2: /* large */
+               padding = lib_ring_buffer_align(offset, lttng_alignof(uint16_t));
+               offset += padding;
+               offset += sizeof(uint16_t);
+               if (!(ctx->rflags & (RING_BUFFER_RFLAG_FULL_TSC | LTTNG_RFLAG_EXTENDED))) {
+                       offset += lib_ring_buffer_align(offset, lttng_alignof(uint32_t));
+                       offset += sizeof(uint32_t);     /* timestamp */
+               } else {
+                       /* Align extended struct on largest member */
+                       offset += lib_ring_buffer_align(offset, lttng_alignof(uint64_t));
+                       offset += sizeof(uint32_t);     /* id */
+                       offset += lib_ring_buffer_align(offset, lttng_alignof(uint64_t));
+                       offset += sizeof(uint64_t);     /* timestamp */
+               }
+               break;
+       default:
+               padding = 0;
+               WARN_ON_ONCE(1);
+       }
+       offset += ctx_get_size(offset, event->ctx);
+       offset += ctx_get_size(offset, lttng_chan->ctx);
+
+       *pre_header_padding = padding;
+       return offset - orig_offset;
+}
+
+#include "wrapper/ringbuffer/api.h"
+
+static
+void lttng_write_event_header_slow(const struct lib_ring_buffer_config *config,
+                                struct lib_ring_buffer_ctx *ctx,
+                                uint32_t event_id);
+
+/*
+ * lttng_write_event_header
+ *
+ * Writes the event header to the offset (already aligned on 32-bits).
+ *
+ * @config: ring buffer instance configuration
+ * @ctx: reservation context
+ * @event_id: event ID
+ */
+static __inline__
+void lttng_write_event_header(const struct lib_ring_buffer_config *config,
+                           struct lib_ring_buffer_ctx *ctx,
+                           uint32_t event_id)
+{
+       struct lttng_channel *lttng_chan = channel_get_private(ctx->chan);
+       struct lttng_event *event = ctx->priv;
+
+       if (unlikely(ctx->rflags))
+               goto slow_path;
+
+       switch (lttng_chan->header_type) {
+       case 1: /* compact */
+       {
+               uint32_t id_time = 0;
+
+               bt_bitfield_write(&id_time, uint32_t,
+                               0,
+                               LTTNG_COMPACT_EVENT_BITS,
+                               event_id);
+               bt_bitfield_write(&id_time, uint32_t,
+                               LTTNG_COMPACT_EVENT_BITS,
+                               LTTNG_COMPACT_TSC_BITS,
+                               ctx->tsc);
+               lib_ring_buffer_write(config, ctx, &id_time, sizeof(id_time));
+               break;
+       }
+       case 2: /* large */
+       {
+               uint32_t timestamp = (uint32_t) ctx->tsc;
+               uint16_t id = event_id;
+
+               lib_ring_buffer_write(config, ctx, &id, sizeof(id));
+               lib_ring_buffer_align_ctx(ctx, lttng_alignof(uint32_t));
+               lib_ring_buffer_write(config, ctx, &timestamp, sizeof(timestamp));
+               break;
+       }
+       default:
+               WARN_ON_ONCE(1);
+       }
+
+       ctx_record(ctx, lttng_chan, lttng_chan->ctx);
+       ctx_record(ctx, lttng_chan, event->ctx);
+       lib_ring_buffer_align_ctx(ctx, ctx->largest_align);
+
+       return;
+
+slow_path:
+       lttng_write_event_header_slow(config, ctx, event_id);
+}
+
+static
+void lttng_write_event_header_slow(const struct lib_ring_buffer_config *config,
+                                struct lib_ring_buffer_ctx *ctx,
+                                uint32_t event_id)
+{
+       struct lttng_channel *lttng_chan = channel_get_private(ctx->chan);
+       struct lttng_event *event = ctx->priv;
+
+       switch (lttng_chan->header_type) {
+       case 1: /* compact */
+               if (!(ctx->rflags & (RING_BUFFER_RFLAG_FULL_TSC | LTTNG_RFLAG_EXTENDED))) {
+                       uint32_t id_time = 0;
+
+                       bt_bitfield_write(&id_time, uint32_t,
+                                       0,
+                                       LTTNG_COMPACT_EVENT_BITS,
+                                       event_id);
+                       bt_bitfield_write(&id_time, uint32_t,
+                                       LTTNG_COMPACT_EVENT_BITS,
+                                       LTTNG_COMPACT_TSC_BITS, ctx->tsc);
+                       lib_ring_buffer_write(config, ctx, &id_time, sizeof(id_time));
+               } else {
+                       uint8_t id = 0;
+                       uint64_t timestamp = ctx->tsc;
+
+                       bt_bitfield_write(&id, uint8_t,
+                                       0,
+                                       LTTNG_COMPACT_EVENT_BITS,
+                                       31);
+                       lib_ring_buffer_write(config, ctx, &id, sizeof(id));
+                       /* Align extended struct on largest member */
+                       lib_ring_buffer_align_ctx(ctx, lttng_alignof(uint64_t));
+                       lib_ring_buffer_write(config, ctx, &event_id, sizeof(event_id));
+                       lib_ring_buffer_align_ctx(ctx, lttng_alignof(uint64_t));
+                       lib_ring_buffer_write(config, ctx, &timestamp, sizeof(timestamp));
+               }
+               break;
+       case 2: /* large */
+       {
+               if (!(ctx->rflags & (RING_BUFFER_RFLAG_FULL_TSC | LTTNG_RFLAG_EXTENDED))) {
+                       uint32_t timestamp = (uint32_t) ctx->tsc;
+                       uint16_t id = event_id;
+
+                       lib_ring_buffer_write(config, ctx, &id, sizeof(id));
+                       lib_ring_buffer_align_ctx(ctx, lttng_alignof(uint32_t));
+                       lib_ring_buffer_write(config, ctx, &timestamp, sizeof(timestamp));
+               } else {
+                       uint16_t id = 65535;
+                       uint64_t timestamp = ctx->tsc;
+
+                       lib_ring_buffer_write(config, ctx, &id, sizeof(id));
+                       /* Align extended struct on largest member */
+                       lib_ring_buffer_align_ctx(ctx, lttng_alignof(uint64_t));
+                       lib_ring_buffer_write(config, ctx, &event_id, sizeof(event_id));
+                       lib_ring_buffer_align_ctx(ctx, lttng_alignof(uint64_t));
+                       lib_ring_buffer_write(config, ctx, &timestamp, sizeof(timestamp));
+               }
+               break;
+       }
+       default:
+               WARN_ON_ONCE(1);
+       }
+       ctx_record(ctx, lttng_chan, lttng_chan->ctx);
+       ctx_record(ctx, lttng_chan, event->ctx);
+       lib_ring_buffer_align_ctx(ctx, ctx->largest_align);
+}
+
+static const struct lib_ring_buffer_config client_config;
+
+static u64 client_ring_buffer_clock_read(struct channel *chan)
+{
+       return lib_ring_buffer_clock_read(chan);
+}
+
+static
+size_t client_record_header_size(const struct lib_ring_buffer_config *config,
+                                struct channel *chan, size_t offset,
+                                size_t *pre_header_padding,
+                                struct lib_ring_buffer_ctx *ctx)
+{
+       return record_header_size(config, chan, offset,
+                                 pre_header_padding, ctx);
+}
+
+/**
+ * client_packet_header_size - called on buffer-switch to a new sub-buffer
+ *
+ * Return header size without padding after the structure. Don't use packed
+ * structure because gcc generates inefficient code on some architectures
+ * (powerpc, mips..)
+ */
+static size_t client_packet_header_size(void)
+{
+       return offsetof(struct packet_header, ctx.header_end);
+}
+
+static void client_buffer_begin(struct lib_ring_buffer *buf, u64 tsc,
+                               unsigned int subbuf_idx)
+{
+       struct channel *chan = buf->backend.chan;
+       struct packet_header *header =
+               (struct packet_header *)
+                       lib_ring_buffer_offset_address(&buf->backend,
+                               subbuf_idx * chan->backend.subbuf_size);
+       struct lttng_channel *lttng_chan = channel_get_private(chan);
+       struct lttng_session *session = lttng_chan->session;
+
+       header->magic = CTF_MAGIC_NUMBER;
+       memcpy(header->uuid, session->uuid.b, sizeof(session->uuid));
+       header->stream_id = lttng_chan->id;
+       header->ctx.timestamp_begin = tsc;
+       header->ctx.timestamp_end = 0;
+       header->ctx.content_size = ~0ULL; /* for debugging */
+       header->ctx.packet_size = ~0ULL;
+       header->ctx.events_discarded = 0;
+       header->ctx.cpu_id = buf->backend.cpu;
+}
+
+/*
+ * offset is assumed to never be 0 here : never deliver a completely empty
+ * subbuffer. data_size is between 1 and subbuf_size.
+ */
+static void client_buffer_end(struct lib_ring_buffer *buf, u64 tsc,
+                             unsigned int subbuf_idx, unsigned long data_size)
+{
+       struct channel *chan = buf->backend.chan;
+       struct packet_header *header =
+               (struct packet_header *)
+                       lib_ring_buffer_offset_address(&buf->backend,
+                               subbuf_idx * chan->backend.subbuf_size);
+       unsigned long records_lost = 0;
+
+       header->ctx.timestamp_end = tsc;
+       header->ctx.content_size =
+               (uint64_t) data_size * CHAR_BIT;                /* in bits */
+       header->ctx.packet_size =
+               (uint64_t) PAGE_ALIGN(data_size) * CHAR_BIT;    /* in bits */
+       records_lost += lib_ring_buffer_get_records_lost_full(&client_config, buf);
+       records_lost += lib_ring_buffer_get_records_lost_wrap(&client_config, buf);
+       records_lost += lib_ring_buffer_get_records_lost_big(&client_config, buf);
+       header->ctx.events_discarded = records_lost;
+}
+
+static int client_buffer_create(struct lib_ring_buffer *buf, void *priv,
+                               int cpu, const char *name)
+{
+       return 0;
+}
+
+static void client_buffer_finalize(struct lib_ring_buffer *buf, void *priv, int cpu)
+{
+}
+
+static const struct lib_ring_buffer_config client_config = {
+       .cb.ring_buffer_clock_read = client_ring_buffer_clock_read,
+       .cb.record_header_size = client_record_header_size,
+       .cb.subbuffer_header_size = client_packet_header_size,
+       .cb.buffer_begin = client_buffer_begin,
+       .cb.buffer_end = client_buffer_end,
+       .cb.buffer_create = client_buffer_create,
+       .cb.buffer_finalize = client_buffer_finalize,
+
+       .tsc_bits = LTTNG_COMPACT_TSC_BITS,
+       .alloc = RING_BUFFER_ALLOC_PER_CPU,
+       .sync = RING_BUFFER_SYNC_PER_CPU,
+       .mode = RING_BUFFER_MODE_TEMPLATE,
+       .backend = RING_BUFFER_PAGE,
+       .output = RING_BUFFER_OUTPUT_TEMPLATE,
+       .oops = RING_BUFFER_OOPS_CONSISTENCY,
+       .ipi = RING_BUFFER_IPI_BARRIER,
+       .wakeup = RING_BUFFER_WAKEUP_BY_TIMER,
+};
+
+static
+struct channel *_channel_create(const char *name,
+                               struct lttng_channel *lttng_chan, void *buf_addr,
+                               size_t subbuf_size, size_t num_subbuf,
+                               unsigned int switch_timer_interval,
+                               unsigned int read_timer_interval)
+{
+       return channel_create(&client_config, name, lttng_chan, buf_addr,
+                             subbuf_size, num_subbuf, switch_timer_interval,
+                             read_timer_interval);
+}
+
+static
+void lttng_channel_destroy(struct channel *chan)
+{
+       channel_destroy(chan);
+}
+
+static
+struct lib_ring_buffer *lttng_buffer_read_open(struct channel *chan)
+{
+       struct lib_ring_buffer *buf;
+       int cpu;
+
+       for_each_channel_cpu(cpu, chan) {
+               buf = channel_get_ring_buffer(&client_config, chan, cpu);
+               if (!lib_ring_buffer_open_read(buf))
+                       return buf;
+       }
+       return NULL;
+}
+
+static
+int lttng_buffer_has_read_closed_stream(struct channel *chan)
+{
+       struct lib_ring_buffer *buf;
+       int cpu;
+
+       for_each_channel_cpu(cpu, chan) {
+               buf = channel_get_ring_buffer(&client_config, chan, cpu);
+               if (!atomic_long_read(&buf->active_readers))
+                       return 1;
+       }
+       return 0;
+}
+
+static
+void lttng_buffer_read_close(struct lib_ring_buffer *buf)
+{
+       lib_ring_buffer_release_read(buf);
+}
+
+static
+int lttng_event_reserve(struct lib_ring_buffer_ctx *ctx,
+                     uint32_t event_id)
+{
+       struct lttng_channel *lttng_chan = channel_get_private(ctx->chan);
+       int ret, cpu;
+
+       cpu = lib_ring_buffer_get_cpu(&client_config);
+       if (cpu < 0)
+               return -EPERM;
+       ctx->cpu = cpu;
+
+       switch (lttng_chan->header_type) {
+       case 1: /* compact */
+               if (event_id > 30)
+                       ctx->rflags |= LTTNG_RFLAG_EXTENDED;
+               break;
+       case 2: /* large */
+               if (event_id > 65534)
+                       ctx->rflags |= LTTNG_RFLAG_EXTENDED;
+               break;
+       default:
+               WARN_ON_ONCE(1);
+       }
+
+       ret = lib_ring_buffer_reserve(&client_config, ctx);
+       if (ret)
+               goto put;
+       lttng_write_event_header(&client_config, ctx, event_id);
+       return 0;
+put:
+       lib_ring_buffer_put_cpu(&client_config);
+       return ret;
+}
+
+static
+void lttng_event_commit(struct lib_ring_buffer_ctx *ctx)
+{
+       lib_ring_buffer_commit(&client_config, ctx);
+       lib_ring_buffer_put_cpu(&client_config);
+}
+
+static
+void lttng_event_write(struct lib_ring_buffer_ctx *ctx, const void *src,
+                    size_t len)
+{
+       lib_ring_buffer_write(&client_config, ctx, src, len);
+}
+
+static
+void lttng_event_write_from_user(struct lib_ring_buffer_ctx *ctx,
+                              const void __user *src, size_t len)
+{
+       lib_ring_buffer_copy_from_user_inatomic(&client_config, ctx, src, len);
+}
+
+static
+void lttng_event_memset(struct lib_ring_buffer_ctx *ctx,
+               int c, size_t len)
+{
+       lib_ring_buffer_memset(&client_config, ctx, c, len);
+}
+
+static
+wait_queue_head_t *lttng_get_writer_buf_wait_queue(struct channel *chan, int cpu)
+{
+       struct lib_ring_buffer *buf = channel_get_ring_buffer(&client_config,
+                                       chan, cpu);
+       return &buf->write_wait;
+}
+
+static
+wait_queue_head_t *lttng_get_hp_wait_queue(struct channel *chan)
+{
+       return &chan->hp_wait;
+}
+
+static
+int lttng_is_finalized(struct channel *chan)
+{
+       return lib_ring_buffer_channel_is_finalized(chan);
+}
+
+static
+int lttng_is_disabled(struct channel *chan)
+{
+       return lib_ring_buffer_channel_is_disabled(chan);
+}
+
+static struct lttng_transport lttng_relay_transport = {
+       .name = "relay-" RING_BUFFER_MODE_TEMPLATE_STRING,
+       .owner = THIS_MODULE,
+       .ops = {
+               .channel_create = _channel_create,
+               .channel_destroy = lttng_channel_destroy,
+               .buffer_read_open = lttng_buffer_read_open,
+               .buffer_has_read_closed_stream =
+                       lttng_buffer_has_read_closed_stream,
+               .buffer_read_close = lttng_buffer_read_close,
+               .event_reserve = lttng_event_reserve,
+               .event_commit = lttng_event_commit,
+               .event_write = lttng_event_write,
+               .event_write_from_user = lttng_event_write_from_user,
+               .event_memset = lttng_event_memset,
+               .packet_avail_size = NULL,      /* Would be racy anyway */
+               .get_writer_buf_wait_queue = lttng_get_writer_buf_wait_queue,
+               .get_hp_wait_queue = lttng_get_hp_wait_queue,
+               .is_finalized = lttng_is_finalized,
+               .is_disabled = lttng_is_disabled,
+       },
+};
+
+static int __init lttng_ring_buffer_client_init(void)
+{
+       /*
+        * This vmalloc sync all also takes care of the lib ring buffer
+        * vmalloc'd module pages when it is built as a module into LTTng.
+        */
+       wrapper_vmalloc_sync_all();
+       lttng_transport_register(&lttng_relay_transport);
+       return 0;
+}
+
+module_init(lttng_ring_buffer_client_init);
+
+static void __exit lttng_ring_buffer_client_exit(void)
+{
+       lttng_transport_unregister(&lttng_relay_transport);
+}
+
+module_exit(lttng_ring_buffer_client_exit);
+
+MODULE_LICENSE("GPL and additional rights");
+MODULE_AUTHOR("Mathieu Desnoyers");
+MODULE_DESCRIPTION("LTTng ring buffer " RING_BUFFER_MODE_TEMPLATE_STRING
+                  " client");
diff --git a/drivers/staging/lttng/lttng-ring-buffer-metadata-client.c b/drivers/staging/lttng/lttng-ring-buffer-metadata-client.c
new file mode 100644 (file)
index 0000000..2ad3d4e
--- /dev/null
@@ -0,0 +1,33 @@
+/*
+ * lttng-ring-buffer-metadata-client.c
+ *
+ * LTTng lib ring buffer metadta client.
+ *
+ * Copyright (C) 2010-2012 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; only
+ * version 2.1 of the License.
+ *
+ * This library 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
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include <linux/module.h>
+#include "lttng-tracer.h"
+
+#define RING_BUFFER_MODE_TEMPLATE              RING_BUFFER_DISCARD
+#define RING_BUFFER_MODE_TEMPLATE_STRING       "metadata"
+#define RING_BUFFER_OUTPUT_TEMPLATE            RING_BUFFER_SPLICE
+#include "lttng-ring-buffer-metadata-client.h"
+
+MODULE_LICENSE("GPL and additional rights");
+MODULE_AUTHOR("Mathieu Desnoyers");
+MODULE_DESCRIPTION("LTTng Ring Buffer Metadata Client");
diff --git a/drivers/staging/lttng/lttng-ring-buffer-metadata-client.h b/drivers/staging/lttng/lttng-ring-buffer-metadata-client.h
new file mode 100644 (file)
index 0000000..f5a13c6
--- /dev/null
@@ -0,0 +1,342 @@
+/*
+ * lttng-ring-buffer-client.h
+ *
+ * LTTng lib ring buffer client template.
+ *
+ * Copyright (C) 2010-2012 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; only
+ * version 2.1 of the License.
+ *
+ * This library 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
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include <linux/module.h>
+#include <linux/types.h>
+#include "wrapper/vmalloc.h"   /* for wrapper_vmalloc_sync_all() */
+#include "lttng-events.h"
+#include "lttng-tracer.h"
+
+struct metadata_packet_header {
+       uint32_t magic;                 /* 0x75D11D57 */
+       uint8_t  uuid[16];              /* Unique Universal Identifier */
+       uint32_t checksum;              /* 0 if unused */
+       uint32_t content_size;          /* in bits */
+       uint32_t packet_size;           /* in bits */
+       uint8_t  compression_scheme;    /* 0 if unused */
+       uint8_t  encryption_scheme;     /* 0 if unused */
+       uint8_t  checksum_scheme;       /* 0 if unused */
+       uint8_t  major;                 /* CTF spec major version number */
+       uint8_t  minor;                 /* CTF spec minor version number */
+       uint8_t  header_end[0];
+};
+
+struct metadata_record_header {
+       uint8_t header_end[0];          /* End of header */
+};
+
+static const struct lib_ring_buffer_config client_config;
+
+static inline
+u64 lib_ring_buffer_clock_read(struct channel *chan)
+{
+       return 0;
+}
+
+static inline
+unsigned char record_header_size(const struct lib_ring_buffer_config *config,
+                                struct channel *chan, size_t offset,
+                                size_t *pre_header_padding,
+                                struct lib_ring_buffer_ctx *ctx)
+{
+       return 0;
+}
+
+#include "wrapper/ringbuffer/api.h"
+
+static u64 client_ring_buffer_clock_read(struct channel *chan)
+{
+       return 0;
+}
+
+static
+size_t client_record_header_size(const struct lib_ring_buffer_config *config,
+                                struct channel *chan, size_t offset,
+                                size_t *pre_header_padding,
+                                struct lib_ring_buffer_ctx *ctx)
+{
+       return 0;
+}
+
+/**
+ * client_packet_header_size - called on buffer-switch to a new sub-buffer
+ *
+ * Return header size without padding after the structure. Don't use packed
+ * structure because gcc generates inefficient code on some architectures
+ * (powerpc, mips..)
+ */
+static size_t client_packet_header_size(void)
+{
+       return offsetof(struct metadata_packet_header, header_end);
+}
+
+static void client_buffer_begin(struct lib_ring_buffer *buf, u64 tsc,
+                               unsigned int subbuf_idx)
+{
+       struct channel *chan = buf->backend.chan;
+       struct metadata_packet_header *header =
+               (struct metadata_packet_header *)
+                       lib_ring_buffer_offset_address(&buf->backend,
+                               subbuf_idx * chan->backend.subbuf_size);
+       struct lttng_channel *lttng_chan = channel_get_private(chan);
+       struct lttng_session *session = lttng_chan->session;
+
+       header->magic = TSDL_MAGIC_NUMBER;
+       memcpy(header->uuid, session->uuid.b, sizeof(session->uuid));
+       header->checksum = 0;           /* 0 if unused */
+       header->content_size = 0xFFFFFFFF; /* in bits, for debugging */
+       header->packet_size = 0xFFFFFFFF;  /* in bits, for debugging */
+       header->compression_scheme = 0; /* 0 if unused */
+       header->encryption_scheme = 0;  /* 0 if unused */
+       header->checksum_scheme = 0;    /* 0 if unused */
+       header->major = CTF_SPEC_MAJOR;
+       header->minor = CTF_SPEC_MINOR;
+}
+
+/*
+ * offset is assumed to never be 0 here : never deliver a completely empty
+ * subbuffer. data_size is between 1 and subbuf_size.
+ */
+static void client_buffer_end(struct lib_ring_buffer *buf, u64 tsc,
+                             unsigned int subbuf_idx, unsigned long data_size)
+{
+       struct channel *chan = buf->backend.chan;
+       struct metadata_packet_header *header =
+               (struct metadata_packet_header *)
+                       lib_ring_buffer_offset_address(&buf->backend,
+                               subbuf_idx * chan->backend.subbuf_size);
+       unsigned long records_lost = 0;
+
+       header->content_size = data_size * CHAR_BIT;            /* in bits */
+       header->packet_size = PAGE_ALIGN(data_size) * CHAR_BIT; /* in bits */
+       /*
+        * We do not care about the records lost count, because the metadata
+        * channel waits and retry.
+        */
+       (void) lib_ring_buffer_get_records_lost_full(&client_config, buf);
+       records_lost += lib_ring_buffer_get_records_lost_wrap(&client_config, buf);
+       records_lost += lib_ring_buffer_get_records_lost_big(&client_config, buf);
+       WARN_ON_ONCE(records_lost != 0);
+}
+
+static int client_buffer_create(struct lib_ring_buffer *buf, void *priv,
+                               int cpu, const char *name)
+{
+       return 0;
+}
+
+static void client_buffer_finalize(struct lib_ring_buffer *buf, void *priv, int cpu)
+{
+}
+
+static const struct lib_ring_buffer_config client_config = {
+       .cb.ring_buffer_clock_read = client_ring_buffer_clock_read,
+       .cb.record_header_size = client_record_header_size,
+       .cb.subbuffer_header_size = client_packet_header_size,
+       .cb.buffer_begin = client_buffer_begin,
+       .cb.buffer_end = client_buffer_end,
+       .cb.buffer_create = client_buffer_create,
+       .cb.buffer_finalize = client_buffer_finalize,
+
+       .tsc_bits = 0,
+       .alloc = RING_BUFFER_ALLOC_GLOBAL,
+       .sync = RING_BUFFER_SYNC_GLOBAL,
+       .mode = RING_BUFFER_MODE_TEMPLATE,
+       .backend = RING_BUFFER_PAGE,
+       .output = RING_BUFFER_OUTPUT_TEMPLATE,
+       .oops = RING_BUFFER_OOPS_CONSISTENCY,
+       .ipi = RING_BUFFER_IPI_BARRIER,
+       .wakeup = RING_BUFFER_WAKEUP_BY_TIMER,
+};
+
+static
+struct channel *_channel_create(const char *name,
+                               struct lttng_channel *lttng_chan, void *buf_addr,
+                               size_t subbuf_size, size_t num_subbuf,
+                               unsigned int switch_timer_interval,
+                               unsigned int read_timer_interval)
+{
+       return channel_create(&client_config, name, lttng_chan, buf_addr,
+                             subbuf_size, num_subbuf, switch_timer_interval,
+                             read_timer_interval);
+}
+
+static
+void lttng_channel_destroy(struct channel *chan)
+{
+       channel_destroy(chan);
+}
+
+static
+struct lib_ring_buffer *lttng_buffer_read_open(struct channel *chan)
+{
+       struct lib_ring_buffer *buf;
+
+       buf = channel_get_ring_buffer(&client_config, chan, 0);
+       if (!lib_ring_buffer_open_read(buf))
+               return buf;
+       return NULL;
+}
+
+static
+int lttng_buffer_has_read_closed_stream(struct channel *chan)
+{
+       struct lib_ring_buffer *buf;
+       int cpu;
+
+       for_each_channel_cpu(cpu, chan) {
+               buf = channel_get_ring_buffer(&client_config, chan, cpu);
+               if (!atomic_long_read(&buf->active_readers))
+                       return 1;
+       }
+       return 0;
+}
+
+static
+void lttng_buffer_read_close(struct lib_ring_buffer *buf)
+{
+       lib_ring_buffer_release_read(buf);
+}
+
+static
+int lttng_event_reserve(struct lib_ring_buffer_ctx *ctx, uint32_t event_id)
+{
+       return lib_ring_buffer_reserve(&client_config, ctx);
+}
+
+static
+void lttng_event_commit(struct lib_ring_buffer_ctx *ctx)
+{
+       lib_ring_buffer_commit(&client_config, ctx);
+}
+
+static
+void lttng_event_write(struct lib_ring_buffer_ctx *ctx, const void *src,
+                    size_t len)
+{
+       lib_ring_buffer_write(&client_config, ctx, src, len);
+}
+
+static
+void lttng_event_write_from_user(struct lib_ring_buffer_ctx *ctx,
+                              const void __user *src, size_t len)
+{
+       lib_ring_buffer_copy_from_user_inatomic(&client_config, ctx, src, len);
+}
+
+static
+void lttng_event_memset(struct lib_ring_buffer_ctx *ctx,
+               int c, size_t len)
+{
+       lib_ring_buffer_memset(&client_config, ctx, c, len);
+}
+
+static
+size_t lttng_packet_avail_size(struct channel *chan)
+
+{
+       unsigned long o_begin;
+       struct lib_ring_buffer *buf;
+
+       buf = chan->backend.buf;        /* Only for global buffer ! */
+       o_begin = v_read(&client_config, &buf->offset);
+       if (subbuf_offset(o_begin, chan) != 0) {
+               return chan->backend.subbuf_size - subbuf_offset(o_begin, chan);
+       } else {
+               return chan->backend.subbuf_size - subbuf_offset(o_begin, chan)
+                       - sizeof(struct metadata_packet_header);
+       }
+}
+
+static
+wait_queue_head_t *lttng_get_writer_buf_wait_queue(struct channel *chan, int cpu)
+{
+       struct lib_ring_buffer *buf = channel_get_ring_buffer(&client_config,
+                                       chan, cpu);
+       return &buf->write_wait;
+}
+
+static
+wait_queue_head_t *lttng_get_hp_wait_queue(struct channel *chan)
+{
+       return &chan->hp_wait;
+}
+
+static
+int lttng_is_finalized(struct channel *chan)
+{
+       return lib_ring_buffer_channel_is_finalized(chan);
+}
+
+static
+int lttng_is_disabled(struct channel *chan)
+{
+       return lib_ring_buffer_channel_is_disabled(chan);
+}
+
+static struct lttng_transport lttng_relay_transport = {
+       .name = "relay-" RING_BUFFER_MODE_TEMPLATE_STRING,
+       .owner = THIS_MODULE,
+       .ops = {
+               .channel_create = _channel_create,
+               .channel_destroy = lttng_channel_destroy,
+               .buffer_read_open = lttng_buffer_read_open,
+               .buffer_has_read_closed_stream =
+                       lttng_buffer_has_read_closed_stream,
+               .buffer_read_close = lttng_buffer_read_close,
+               .event_reserve = lttng_event_reserve,
+               .event_commit = lttng_event_commit,
+               .event_write_from_user = lttng_event_write_from_user,
+               .event_memset = lttng_event_memset,
+               .event_write = lttng_event_write,
+               .packet_avail_size = lttng_packet_avail_size,
+               .get_writer_buf_wait_queue = lttng_get_writer_buf_wait_queue,
+               .get_hp_wait_queue = lttng_get_hp_wait_queue,
+               .is_finalized = lttng_is_finalized,
+               .is_disabled = lttng_is_disabled,
+       },
+};
+
+static int __init lttng_ring_buffer_client_init(void)
+{
+       /*
+        * This vmalloc sync all also takes care of the lib ring buffer
+        * vmalloc'd module pages when it is built as a module into LTTng.
+        */
+       wrapper_vmalloc_sync_all();
+       lttng_transport_register(&lttng_relay_transport);
+       return 0;
+}
+
+module_init(lttng_ring_buffer_client_init);
+
+static void __exit lttng_ring_buffer_client_exit(void)
+{
+       lttng_transport_unregister(&lttng_relay_transport);
+}
+
+module_exit(lttng_ring_buffer_client_exit);
+
+MODULE_LICENSE("GPL and additional rights");
+MODULE_AUTHOR("Mathieu Desnoyers");
+MODULE_DESCRIPTION("LTTng ring buffer " RING_BUFFER_MODE_TEMPLATE_STRING
+                  " client");
diff --git a/drivers/staging/lttng/lttng-ring-buffer-metadata-mmap-client.c b/drivers/staging/lttng/lttng-ring-buffer-metadata-mmap-client.c
new file mode 100644 (file)
index 0000000..3c6e81f
--- /dev/null
@@ -0,0 +1,33 @@
+/*
+ * lttng-ring-buffer-metadata-client.c
+ *
+ * LTTng lib ring buffer metadta client.
+ *
+ * Copyright (C) 2010-2012 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; only
+ * version 2.1 of the License.
+ *
+ * This library 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
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include <linux/module.h>
+#include "lttng-tracer.h"
+
+#define RING_BUFFER_MODE_TEMPLATE              RING_BUFFER_DISCARD
+#define RING_BUFFER_MODE_TEMPLATE_STRING       "metadata-mmap"
+#define RING_BUFFER_OUTPUT_TEMPLATE            RING_BUFFER_MMAP
+#include "lttng-ring-buffer-metadata-client.h"
+
+MODULE_LICENSE("GPL and additional rights");
+MODULE_AUTHOR("Mathieu Desnoyers");
+MODULE_DESCRIPTION("LTTng Ring Buffer Metadata Client");
diff --git a/drivers/staging/lttng/lttng-statedump-impl.c b/drivers/staging/lttng/lttng-statedump-impl.c
new file mode 100644 (file)
index 0000000..1269a3e
--- /dev/null
@@ -0,0 +1,427 @@
+/*
+ * lttng-statedump.c
+ *
+ * Linux Trace Toolkit Next Generation Kernel State Dump
+ *
+ * Copyright 2005 Jean-Hugues Deschenes <jean-hugues.deschenes@polymtl.ca>
+ * Copyright 2006-2012 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; only
+ * version 2.1 of the License.
+ *
+ * This library 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
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ * Changes:
+ *     Eric Clement:                   Add listing of network IP interface
+ *     2006, 2007 Mathieu Desnoyers    Fix kernel threads
+ *                                     Various updates
+ */
+
+#include <linux/init.h>
+#include <linux/module.h>
+#include <linux/netlink.h>
+#include <linux/inet.h>
+#include <linux/ip.h>
+#include <linux/kthread.h>
+#include <linux/proc_fs.h>
+#include <linux/file.h>
+#include <linux/interrupt.h>
+#include <linux/irqnr.h>
+#include <linux/cpu.h>
+#include <linux/netdevice.h>
+#include <linux/inetdevice.h>
+#include <linux/sched.h>
+#include <linux/mm.h>
+#include <linux/fdtable.h>
+#include <linux/swap.h>
+#include <linux/wait.h>
+#include <linux/mutex.h>
+
+#include "lttng-events.h"
+#include "wrapper/irqdesc.h"
+#include "wrapper/spinlock.h"
+#include "wrapper/fdtable.h"
+#include "wrapper/nsproxy.h"
+#include "wrapper/irq.h"
+
+#ifdef CONFIG_LTTNG_HAS_LIST_IRQ
+#include <linux/irq.h>
+#endif
+
+/* Define the tracepoints, but do not build the probes */
+#define CREATE_TRACE_POINTS
+#define TRACE_INCLUDE_PATH ../instrumentation/events/lttng-module
+#define TRACE_INCLUDE_FILE lttng-statedump
+#include "instrumentation/events/lttng-module/lttng-statedump.h"
+
+struct lttng_fd_ctx {
+       char *page;
+       struct lttng_session *session;
+       struct task_struct *p;
+};
+
+/*
+ * Protected by the trace lock.
+ */
+static struct delayed_work cpu_work[NR_CPUS];
+static DECLARE_WAIT_QUEUE_HEAD(statedump_wq);
+static atomic_t kernel_threads_to_run;
+
+enum lttng_thread_type {
+       LTTNG_USER_THREAD = 0,
+       LTTNG_KERNEL_THREAD = 1,
+};
+
+enum lttng_execution_mode {
+       LTTNG_USER_MODE = 0,
+       LTTNG_SYSCALL = 1,
+       LTTNG_TRAP = 2,
+       LTTNG_IRQ = 3,
+       LTTNG_SOFTIRQ = 4,
+       LTTNG_MODE_UNKNOWN = 5,
+};
+
+enum lttng_execution_submode {
+       LTTNG_NONE = 0,
+       LTTNG_UNKNOWN = 1,
+};
+
+enum lttng_process_status {
+       LTTNG_UNNAMED = 0,
+       LTTNG_WAIT_FORK = 1,
+       LTTNG_WAIT_CPU = 2,
+       LTTNG_EXIT = 3,
+       LTTNG_ZOMBIE = 4,
+       LTTNG_WAIT = 5,
+       LTTNG_RUN = 6,
+       LTTNG_DEAD = 7,
+};
+
+#ifdef CONFIG_INET
+static
+void lttng_enumerate_device(struct lttng_session *session,
+               struct net_device *dev)
+{
+       struct in_device *in_dev;
+       struct in_ifaddr *ifa;
+
+       if (dev->flags & IFF_UP) {
+               in_dev = in_dev_get(dev);
+               if (in_dev) {
+                       for (ifa = in_dev->ifa_list; ifa != NULL;
+                            ifa = ifa->ifa_next) {
+                               trace_lttng_statedump_network_interface(
+                                       session, dev, ifa);
+                       }
+                       in_dev_put(in_dev);
+               }
+       } else {
+               trace_lttng_statedump_network_interface(
+                       session, dev, NULL);
+       }
+}
+
+static
+int lttng_enumerate_network_ip_interface(struct lttng_session *session)
+{
+       struct net_device *dev;
+
+       read_lock(&dev_base_lock);
+       for_each_netdev(&init_net, dev)
+               lttng_enumerate_device(session, dev);
+       read_unlock(&dev_base_lock);
+
+       return 0;
+}
+#else /* CONFIG_INET */
+static inline
+int lttng_enumerate_network_ip_interface(struct lttng_session *session)
+{
+       return 0;
+}
+#endif /* CONFIG_INET */
+
+static
+int lttng_dump_one_fd(const void *p, struct file *file, unsigned int fd)
+{
+       const struct lttng_fd_ctx *ctx = p;
+       const char *s = d_path(&file->f_path, ctx->page, PAGE_SIZE);
+
+       if (IS_ERR(s)) {
+               struct dentry *dentry = file->f_path.dentry;
+
+               /* Make sure we give at least some info */
+               spin_lock(&dentry->d_lock);
+               trace_lttng_statedump_file_descriptor(ctx->session, ctx->p, fd,
+                       dentry->d_name.name);
+               spin_unlock(&dentry->d_lock);
+               goto end;
+       }
+       trace_lttng_statedump_file_descriptor(ctx->session, ctx->p, fd, s);
+end:
+       return 0;
+}
+
+static
+void lttng_enumerate_task_fd(struct lttng_session *session,
+               struct task_struct *p, char *tmp)
+{
+       struct lttng_fd_ctx ctx = { .page = tmp, .session = session, .p = p };
+
+       task_lock(p);
+       lttng_iterate_fd(p->files, 0, lttng_dump_one_fd, &ctx);
+       task_unlock(p);
+}
+
+static
+int lttng_enumerate_file_descriptors(struct lttng_session *session)
+{
+       struct task_struct *p;
+       char *tmp = (char *) __get_free_page(GFP_KERNEL);
+
+       /* Enumerate active file descriptors */
+       rcu_read_lock();
+       for_each_process(p)
+               lttng_enumerate_task_fd(session, p, tmp);
+       rcu_read_unlock();
+       free_page((unsigned long) tmp);
+       return 0;
+}
+
+#if 0
+/*
+ * FIXME: we cannot take a mmap_sem while in a RCU read-side critical section
+ * (scheduling in atomic). Normally, the tasklist lock protects this kind of
+ * iteration, but it is not exported to modules.
+ */
+static
+void lttng_enumerate_task_vm_maps(struct lttng_session *session,
+               struct task_struct *p)
+{
+       struct mm_struct *mm;
+       struct vm_area_struct *map;
+       unsigned long ino;
+
+       /* get_task_mm does a task_lock... */
+       mm = get_task_mm(p);
+       if (!mm)
+               return;
+
+       map = mm->mmap;
+       if (map) {
+               down_read(&mm->mmap_sem);
+               while (map) {
+                       if (map->vm_file)
+                               ino = map->vm_file->f_dentry->d_inode->i_ino;
+                       else
+                               ino = 0;
+                       trace_lttng_statedump_vm_map(session, p, map, ino);
+                       map = map->vm_next;
+               }
+               up_read(&mm->mmap_sem);
+       }
+       mmput(mm);
+}
+
+static
+int lttng_enumerate_vm_maps(struct lttng_session *session)
+{
+       struct task_struct *p;
+
+       rcu_read_lock();
+       for_each_process(p)
+               lttng_enumerate_task_vm_maps(session, p);
+       rcu_read_unlock();
+       return 0;
+}
+#endif
+
+#ifdef CONFIG_LTTNG_HAS_LIST_IRQ
+
+#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,39))
+#define irq_desc_get_chip(desc) get_irq_desc_chip(desc)
+#endif
+
+static
+void lttng_list_interrupts(struct lttng_session *session)
+{
+       unsigned int irq;
+       unsigned long flags = 0;
+       struct irq_desc *desc;
+
+#define irq_to_desc    wrapper_irq_to_desc
+       /* needs irq_desc */
+       for_each_irq_desc(irq, desc) {
+               struct irqaction *action;
+               const char *irq_chip_name =
+                       irq_desc_get_chip(desc)->name ? : "unnamed_irq_chip";
+
+               local_irq_save(flags);
+               wrapper_desc_spin_lock(&desc->lock);
+               for (action = desc->action; action; action = action->next) {
+                       trace_lttng_statedump_interrupt(session,
+                               irq, irq_chip_name, action);
+               }
+               wrapper_desc_spin_unlock(&desc->lock);
+               local_irq_restore(flags);
+       }
+#undef irq_to_desc
+}
+#else
+static inline
+void lttng_list_interrupts(struct lttng_session *session)
+{
+}
+#endif
+
+static
+void lttng_statedump_process_ns(struct lttng_session *session,
+               struct task_struct *p,
+               enum lttng_thread_type type,
+               enum lttng_execution_mode mode,
+               enum lttng_execution_submode submode,
+               enum lttng_process_status status)
+{
+       struct nsproxy *proxy;
+       struct pid_namespace *pid_ns;
+
+       rcu_read_lock();
+       proxy = task_nsproxy(p);
+       if (proxy) {
+               pid_ns = lttng_get_proxy_pid_ns(proxy);
+               do {
+                       trace_lttng_statedump_process_state(session,
+                               p, type, mode, submode, status, pid_ns);
+                       pid_ns = pid_ns->parent;
+               } while (pid_ns);
+       } else {
+               trace_lttng_statedump_process_state(session,
+                       p, type, mode, submode, status, NULL);
+       }
+       rcu_read_unlock();
+}
+
+static
+int lttng_enumerate_process_states(struct lttng_session *session)
+{
+       struct task_struct *g, *p;
+
+       rcu_read_lock();
+       for_each_process(g) {
+               p = g;
+               do {
+                       enum lttng_execution_mode mode =
+                               LTTNG_MODE_UNKNOWN;
+                       enum lttng_execution_submode submode =
+                               LTTNG_UNKNOWN;
+                       enum lttng_process_status status;
+                       enum lttng_thread_type type;
+
+                       task_lock(p);
+                       if (p->exit_state == EXIT_ZOMBIE)
+                               status = LTTNG_ZOMBIE;
+                       else if (p->exit_state == EXIT_DEAD)
+                               status = LTTNG_DEAD;
+                       else if (p->state == TASK_RUNNING) {
+                               /* Is this a forked child that has not run yet? */
+                               if (list_empty(&p->rt.run_list))
+                                       status = LTTNG_WAIT_FORK;
+                               else
+                                       /*
+                                        * All tasks are considered as wait_cpu;
+                                        * the viewer will sort out if the task
+                                        * was really running at this time.
+                                        */
+                                       status = LTTNG_WAIT_CPU;
+                       } else if (p->state &
+                               (TASK_INTERRUPTIBLE | TASK_UNINTERRUPTIBLE)) {
+                               /* Task is waiting for something to complete */
+                               status = LTTNG_WAIT;
+                       } else
+                               status = LTTNG_UNNAMED;
+                       submode = LTTNG_NONE;
+
+                       /*
+                        * Verification of t->mm is to filter out kernel
+                        * threads; Viewer will further filter out if a
+                        * user-space thread was in syscall mode or not.
+                        */
+                       if (p->mm)
+                               type = LTTNG_USER_THREAD;
+                       else
+                               type = LTTNG_KERNEL_THREAD;
+                       lttng_statedump_process_ns(session,
+                               p, type, mode, submode, status);
+                       task_unlock(p);
+               } while_each_thread(g, p);
+       }
+       rcu_read_unlock();
+
+       return 0;
+}
+
+static
+void lttng_statedump_work_func(struct work_struct *work)
+{
+       if (atomic_dec_and_test(&kernel_threads_to_run))
+               /* If we are the last thread, wake up do_lttng_statedump */
+               wake_up(&statedump_wq);
+}
+
+static
+int do_lttng_statedump(struct lttng_session *session)
+{
+       int cpu;
+
+       trace_lttng_statedump_start(session);
+       lttng_enumerate_process_states(session);
+       lttng_enumerate_file_descriptors(session);
+       /* FIXME lttng_enumerate_vm_maps(session); */
+       lttng_list_interrupts(session);
+       lttng_enumerate_network_ip_interface(session);
+
+       /* TODO lttng_dump_idt_table(session); */
+       /* TODO lttng_dump_softirq_vec(session); */
+       /* TODO lttng_list_modules(session); */
+       /* TODO lttng_dump_swap_files(session); */
+
+       /*
+        * Fire off a work queue on each CPU. Their sole purpose in life
+        * is to guarantee that each CPU has been in a state where is was in
+        * syscall mode (i.e. not in a trap, an IRQ or a soft IRQ).
+        */
+       get_online_cpus();
+       atomic_set(&kernel_threads_to_run, num_online_cpus());
+       for_each_online_cpu(cpu) {
+               INIT_DELAYED_WORK(&cpu_work[cpu], lttng_statedump_work_func);
+               schedule_delayed_work_on(cpu, &cpu_work[cpu], 0);
+       }
+       /* Wait for all threads to run */
+       __wait_event(statedump_wq, (atomic_read(&kernel_threads_to_run) == 0));
+       put_online_cpus();
+       /* Our work is done */
+       trace_lttng_statedump_end(session);
+       return 0;
+}
+
+/*
+ * Called with session mutex held.
+ */
+int lttng_statedump_start(struct lttng_session *session)
+{
+       return do_lttng_statedump(session);
+}
+EXPORT_SYMBOL_GPL(lttng_statedump_start);
+
+MODULE_LICENSE("GPL and additional rights");
+MODULE_AUTHOR("Jean-Hugues Deschenes");
+MODULE_DESCRIPTION("Linux Trace Toolkit Next Generation Statedump");
diff --git a/drivers/staging/lttng/lttng-syscalls.c b/drivers/staging/lttng/lttng-syscalls.c
new file mode 100644 (file)
index 0000000..62ed24a
--- /dev/null
@@ -0,0 +1,459 @@
+/*
+ * lttng-syscalls.c
+ *
+ * LTTng syscall probes.
+ *
+ * Copyright (C) 2010-2012 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; only
+ * version 2.1 of the License.
+ *
+ * This library 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
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include <linux/module.h>
+#include <linux/slab.h>
+#include <linux/compat.h>
+#include <asm/ptrace.h>
+#include <asm/syscall.h>
+
+#include "wrapper/tracepoint.h"
+#include "lttng-events.h"
+
+#ifndef CONFIG_COMPAT
+# ifndef is_compat_task
+#  define is_compat_task()     (0)
+# endif
+#endif
+
+static
+void syscall_entry_probe(void *__data, struct pt_regs *regs, long id);
+
+/*
+ * Forward declarations for old kernels.
+ */
+struct mmsghdr;
+struct rlimit64;
+struct oldold_utsname;
+struct old_utsname;
+struct sel_arg_struct;
+struct mmap_arg_struct;
+
+/*
+ * Take care of NOARGS not supported by mainline.
+ */
+#define DECLARE_EVENT_CLASS_NOARGS(name, tstruct, assign, print)
+#define DEFINE_EVENT_NOARGS(template, name)
+#define TRACE_EVENT_NOARGS(name, struct, assign, print)
+
+/*
+ * Create LTTng tracepoint probes.
+ */
+#define LTTNG_PACKAGE_BUILD
+#define CREATE_TRACE_POINTS
+#define TP_MODULE_NOINIT
+#define TRACE_INCLUDE_PATH ../instrumentation/syscalls/headers
+
+#define PARAMS(args...)        args
+
+/* Hijack probe callback for system calls */
+#undef TP_PROBE_CB
+#define TP_PROBE_CB(_template)         &syscall_entry_probe
+#define SC_TRACE_EVENT(_name, _proto, _args, _struct, _assign, _printk)        \
+       TRACE_EVENT(_name, PARAMS(_proto), PARAMS(_args),\
+               PARAMS(_struct), PARAMS(_assign), PARAMS(_printk))
+#define SC_DECLARE_EVENT_CLASS_NOARGS(_name, _struct, _assign, _printk)        \
+       DECLARE_EVENT_CLASS_NOARGS(_name, PARAMS(_struct), PARAMS(_assign),\
+               PARAMS(_printk))
+#define SC_DEFINE_EVENT_NOARGS(_template, _name)                       \
+       DEFINE_EVENT_NOARGS(_template, _name)
+#undef TRACE_SYSTEM
+#define TRACE_SYSTEM syscalls_integers
+#include "instrumentation/syscalls/headers/syscalls_integers.h"
+#undef TRACE_SYSTEM
+#define TRACE_SYSTEM syscalls_pointers
+#include "instrumentation/syscalls/headers/syscalls_pointers.h"
+#undef TRACE_SYSTEM
+#undef SC_TRACE_EVENT
+#undef SC_DECLARE_EVENT_CLASS_NOARGS
+#undef SC_DEFINE_EVENT_NOARGS
+
+#define TRACE_SYSTEM syscalls_unknown
+#include "instrumentation/syscalls/headers/syscalls_unknown.h"
+#undef TRACE_SYSTEM
+
+/* For compat syscalls */
+#undef _TRACE_SYSCALLS_integers_H
+#undef _TRACE_SYSCALLS_pointers_H
+
+/* Hijack probe callback for system calls */
+#undef TP_PROBE_CB
+#define TP_PROBE_CB(_template)         &syscall_entry_probe
+#define SC_TRACE_EVENT(_name, _proto, _args, _struct, _assign, _printk)        \
+       TRACE_EVENT(compat_##_name, PARAMS(_proto), PARAMS(_args),      \
+               PARAMS(_struct), PARAMS(_assign),                       \
+               PARAMS(_printk))
+#define SC_DECLARE_EVENT_CLASS_NOARGS(_name, _struct, _assign, _printk) \
+       DECLARE_EVENT_CLASS_NOARGS(compat_##_name, PARAMS(_struct),     \
+               PARAMS(_assign), PARAMS(_printk))
+#define SC_DEFINE_EVENT_NOARGS(_template, _name)                       \
+       DEFINE_EVENT_NOARGS(compat_##_template, compat_##_name)
+#define TRACE_SYSTEM compat_syscalls_integers
+#include "instrumentation/syscalls/headers/compat_syscalls_integers.h"
+#undef TRACE_SYSTEM
+#define TRACE_SYSTEM compat_syscalls_pointers
+#include "instrumentation/syscalls/headers/compat_syscalls_pointers.h"
+#undef TRACE_SYSTEM
+#undef SC_TRACE_EVENT
+#undef SC_DECLARE_EVENT_CLASS_NOARGS
+#undef SC_DEFINE_EVENT_NOARGS
+#undef TP_PROBE_CB
+
+#undef TP_MODULE_NOINIT
+#undef LTTNG_PACKAGE_BUILD
+#undef CREATE_TRACE_POINTS
+
+struct trace_syscall_entry {
+       void *func;
+       const struct lttng_event_desc *desc;
+       const struct lttng_event_field *fields;
+       unsigned int nrargs;
+};
+
+#define CREATE_SYSCALL_TABLE
+
+#undef TRACE_SYSCALL_TABLE
+#define TRACE_SYSCALL_TABLE(_template, _name, _nr, _nrargs)    \
+       [ _nr ] = {                                             \
+               .func = __event_probe__##_template,             \
+               .nrargs = (_nrargs),                            \
+               .fields = __event_fields___##_template,         \
+               .desc = &__event_desc___##_name,                \
+       },
+
+static const struct trace_syscall_entry sc_table[] = {
+#include "instrumentation/syscalls/headers/syscalls_integers.h"
+#include "instrumentation/syscalls/headers/syscalls_pointers.h"
+};
+
+#undef TRACE_SYSCALL_TABLE
+#define TRACE_SYSCALL_TABLE(_template, _name, _nr, _nrargs)    \
+       [ _nr ] = {                                             \
+               .func = __event_probe__##compat_##_template,    \
+               .nrargs = (_nrargs),                            \
+               .fields = __event_fields___##compat_##_template,\
+               .desc = &__event_desc___##compat_##_name,       \
+       },
+
+/* Create compatibility syscall table */
+const struct trace_syscall_entry compat_sc_table[] = {
+#include "instrumentation/syscalls/headers/compat_syscalls_integers.h"
+#include "instrumentation/syscalls/headers/compat_syscalls_pointers.h"
+};
+
+#undef CREATE_SYSCALL_TABLE
+
+static void syscall_entry_unknown(struct lttng_event *event,
+       struct pt_regs *regs, unsigned int id)
+{
+       unsigned long args[UNKNOWN_SYSCALL_NRARGS];
+
+       syscall_get_arguments(current, regs, 0, UNKNOWN_SYSCALL_NRARGS, args);
+       if (unlikely(is_compat_task()))
+               __event_probe__compat_sys_unknown(event, id, args);
+       else
+               __event_probe__sys_unknown(event, id, args);
+}
+
+void syscall_entry_probe(void *__data, struct pt_regs *regs, long id)
+{
+       struct lttng_channel *chan = __data;
+       struct lttng_event *event, *unknown_event;
+       const struct trace_syscall_entry *table, *entry;
+       size_t table_len;
+
+       if (unlikely(is_compat_task())) {
+               table = compat_sc_table;
+               table_len = ARRAY_SIZE(compat_sc_table);
+               unknown_event = chan->sc_compat_unknown;
+       } else {
+               table = sc_table;
+               table_len = ARRAY_SIZE(sc_table);
+               unknown_event = chan->sc_unknown;
+       }
+       if (unlikely(id >= table_len)) {
+               syscall_entry_unknown(unknown_event, regs, id);
+               return;
+       }
+       if (unlikely(is_compat_task()))
+               event = chan->compat_sc_table[id];
+       else
+               event = chan->sc_table[id];
+       if (unlikely(!event)) {
+               syscall_entry_unknown(unknown_event, regs, id);
+               return;
+       }
+       entry = &table[id];
+       WARN_ON_ONCE(!entry);
+
+       switch (entry->nrargs) {
+       case 0:
+       {
+               void (*fptr)(void *__data) = entry->func;
+
+               fptr(event);
+               break;
+       }
+       case 1:
+       {
+               void (*fptr)(void *__data, unsigned long arg0) = entry->func;
+               unsigned long args[1];
+
+               syscall_get_arguments(current, regs, 0, entry->nrargs, args);
+               fptr(event, args[0]);
+               break;
+       }
+       case 2:
+       {
+               void (*fptr)(void *__data,
+                       unsigned long arg0,
+                       unsigned long arg1) = entry->func;
+               unsigned long args[2];
+
+               syscall_get_arguments(current, regs, 0, entry->nrargs, args);
+               fptr(event, args[0], args[1]);
+               break;
+       }
+       case 3:
+       {
+               void (*fptr)(void *__data,
+                       unsigned long arg0,
+                       unsigned long arg1,
+                       unsigned long arg2) = entry->func;
+               unsigned long args[3];
+
+               syscall_get_arguments(current, regs, 0, entry->nrargs, args);
+               fptr(event, args[0], args[1], args[2]);
+               break;
+       }
+       case 4:
+       {
+               void (*fptr)(void *__data,
+                       unsigned long arg0,
+                       unsigned long arg1,
+                       unsigned long arg2,
+                       unsigned long arg3) = entry->func;
+               unsigned long args[4];
+
+               syscall_get_arguments(current, regs, 0, entry->nrargs, args);
+               fptr(event, args[0], args[1], args[2], args[3]);
+               break;
+       }
+       case 5:
+       {
+               void (*fptr)(void *__data,
+                       unsigned long arg0,
+                       unsigned long arg1,
+                       unsigned long arg2,
+                       unsigned long arg3,
+                       unsigned long arg4) = entry->func;
+               unsigned long args[5];
+
+               syscall_get_arguments(current, regs, 0, entry->nrargs, args);
+               fptr(event, args[0], args[1], args[2], args[3], args[4]);
+               break;
+       }
+       case 6:
+       {
+               void (*fptr)(void *__data,
+                       unsigned long arg0,
+                       unsigned long arg1,
+                       unsigned long arg2,
+                       unsigned long arg3,
+                       unsigned long arg4,
+                       unsigned long arg5) = entry->func;
+               unsigned long args[6];
+
+               syscall_get_arguments(current, regs, 0, entry->nrargs, args);
+               fptr(event, args[0], args[1], args[2],
+                       args[3], args[4], args[5]);
+               break;
+       }
+       default:
+               break;
+       }
+}
+
+/* noinline to diminish caller stack size */
+static
+int fill_table(const struct trace_syscall_entry *table, size_t table_len,
+       struct lttng_event **chan_table, struct lttng_channel *chan, void *filter)
+{
+       const struct lttng_event_desc *desc;
+       unsigned int i;
+
+       /* Allocate events for each syscall, insert into table */
+       for (i = 0; i < table_len; i++) {
+               struct lttng_kernel_event ev;
+               desc = table[i].desc;
+
+               if (!desc) {
+                       /* Unknown syscall */
+                       continue;
+               }
+               /*
+                * Skip those already populated by previous failed
+                * register for this channel.
+                */
+               if (chan_table[i])
+                       continue;
+               memset(&ev, 0, sizeof(ev));
+               strncpy(ev.name, desc->name, LTTNG_KERNEL_SYM_NAME_LEN);
+               ev.name[LTTNG_KERNEL_SYM_NAME_LEN - 1] = '\0';
+               ev.instrumentation = LTTNG_KERNEL_NOOP;
+               chan_table[i] = lttng_event_create(chan, &ev, filter,
+                                               desc);
+               if (!chan_table[i]) {
+                       /*
+                        * If something goes wrong in event registration
+                        * after the first one, we have no choice but to
+                        * leave the previous events in there, until
+                        * deleted by session teardown.
+                        */
+                       return -EINVAL;
+               }
+       }
+       return 0;
+}
+
+int lttng_syscalls_register(struct lttng_channel *chan, void *filter)
+{
+       struct lttng_kernel_event ev;
+       int ret;
+
+       wrapper_vmalloc_sync_all();
+
+       if (!chan->sc_table) {
+               /* create syscall table mapping syscall to events */
+               chan->sc_table = kzalloc(sizeof(struct lttng_event *)
+                                       * ARRAY_SIZE(sc_table), GFP_KERNEL);
+               if (!chan->sc_table)
+                       return -ENOMEM;
+       }
+
+#ifdef CONFIG_COMPAT
+       if (!chan->compat_sc_table) {
+               /* create syscall table mapping compat syscall to events */
+               chan->compat_sc_table = kzalloc(sizeof(struct lttng_event *)
+                                       * ARRAY_SIZE(compat_sc_table), GFP_KERNEL);
+               if (!chan->compat_sc_table)
+                       return -ENOMEM;
+       }
+#endif
+       if (!chan->sc_unknown) {
+               const struct lttng_event_desc *desc =
+                       &__event_desc___sys_unknown;
+
+               memset(&ev, 0, sizeof(ev));
+               strncpy(ev.name, desc->name, LTTNG_KERNEL_SYM_NAME_LEN);
+               ev.name[LTTNG_KERNEL_SYM_NAME_LEN - 1] = '\0';
+               ev.instrumentation = LTTNG_KERNEL_NOOP;
+               chan->sc_unknown = lttng_event_create(chan, &ev, filter,
+                                                   desc);
+               if (!chan->sc_unknown) {
+                       return -EINVAL;
+               }
+       }
+
+       if (!chan->sc_compat_unknown) {
+               const struct lttng_event_desc *desc =
+                       &__event_desc___compat_sys_unknown;
+
+               memset(&ev, 0, sizeof(ev));
+               strncpy(ev.name, desc->name, LTTNG_KERNEL_SYM_NAME_LEN);
+               ev.name[LTTNG_KERNEL_SYM_NAME_LEN - 1] = '\0';
+               ev.instrumentation = LTTNG_KERNEL_NOOP;
+               chan->sc_compat_unknown = lttng_event_create(chan, &ev, filter,
+                                                          desc);
+               if (!chan->sc_compat_unknown) {
+                       return -EINVAL;
+               }
+       }
+
+       if (!chan->sc_exit) {
+               const struct lttng_event_desc *desc =
+                       &__event_desc___exit_syscall;
+
+               memset(&ev, 0, sizeof(ev));
+               strncpy(ev.name, desc->name, LTTNG_KERNEL_SYM_NAME_LEN);
+               ev.name[LTTNG_KERNEL_SYM_NAME_LEN - 1] = '\0';
+               ev.instrumentation = LTTNG_KERNEL_NOOP;
+               chan->sc_exit = lttng_event_create(chan, &ev, filter,
+                                                desc);
+               if (!chan->sc_exit) {
+                       return -EINVAL;
+               }
+       }
+
+       ret = fill_table(sc_table, ARRAY_SIZE(sc_table),
+                       chan->sc_table, chan, filter);
+       if (ret)
+               return ret;
+#ifdef CONFIG_COMPAT
+       ret = fill_table(compat_sc_table, ARRAY_SIZE(compat_sc_table),
+                       chan->compat_sc_table, chan, filter);
+       if (ret)
+               return ret;
+#endif
+       ret = kabi_2635_tracepoint_probe_register("sys_enter",
+                       (void *) syscall_entry_probe, chan);
+       if (ret)
+               return ret;
+       /*
+        * We change the name of sys_exit tracepoint due to namespace
+        * conflict with sys_exit syscall entry.
+        */
+       ret = kabi_2635_tracepoint_probe_register("sys_exit",
+                       (void *) __event_probe__exit_syscall,
+                       chan->sc_exit);
+       if (ret) {
+               WARN_ON_ONCE(kabi_2635_tracepoint_probe_unregister("sys_enter",
+                       (void *) syscall_entry_probe, chan));
+       }
+       return ret;
+}
+
+/*
+ * Only called at session destruction.
+ */
+int lttng_syscalls_unregister(struct lttng_channel *chan)
+{
+       int ret;
+
+       if (!chan->sc_table)
+               return 0;
+       ret = kabi_2635_tracepoint_probe_unregister("sys_exit",
+                       (void *) __event_probe__exit_syscall,
+                       chan->sc_exit);
+       if (ret)
+               return ret;
+       ret = kabi_2635_tracepoint_probe_unregister("sys_enter",
+                       (void *) syscall_entry_probe, chan);
+       if (ret)
+               return ret;
+       /* lttng_event destroy will be performed by lttng_session_destroy() */
+       kfree(chan->sc_table);
+#ifdef CONFIG_COMPAT
+       kfree(chan->compat_sc_table);
+#endif
+       return 0;
+}
diff --git a/drivers/staging/lttng/lttng-tracer-core.h b/drivers/staging/lttng/lttng-tracer-core.h
new file mode 100644 (file)
index 0000000..b946dce
--- /dev/null
@@ -0,0 +1,41 @@
+#ifndef LTTNG_TRACER_CORE_H
+#define LTTNG_TRACER_CORE_H
+
+/*
+ * lttng-tracer-core.h
+ *
+ * This contains the core definitions for the Linux Trace Toolkit Next
+ * Generation tracer.
+ *
+ * Copyright (C) 2005-2012 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; only
+ * version 2.1 of the License.
+ *
+ * This library 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
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include <linux/list.h>
+#include <linux/percpu.h>
+
+#ifndef CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS
+/* Align data on its natural alignment */
+#define RING_BUFFER_ALIGN
+#endif
+
+#include "wrapper/ringbuffer/config.h"
+
+struct lttng_session;
+struct lttng_channel;
+struct lttng_event;
+
+#endif /* LTTNG_TRACER_CORE_H */
diff --git a/drivers/staging/lttng/lttng-tracer.h b/drivers/staging/lttng/lttng-tracer.h
new file mode 100644 (file)
index 0000000..791140f
--- /dev/null
@@ -0,0 +1,81 @@
+#ifndef _LTTNG_TRACER_H
+#define _LTTNG_TRACER_H
+
+/*
+ * lttng-tracer.h
+ *
+ * This contains the definitions for the Linux Trace Toolkit Next
+ * Generation tracer.
+ *
+ * Copyright (C) 2005-2012 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; only
+ * version 2.1 of the License.
+ *
+ * This library 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
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include <stdarg.h>
+#include <linux/types.h>
+#include <linux/limits.h>
+#include <linux/list.h>
+#include <linux/cache.h>
+#include <linux/timex.h>
+#include <linux/wait.h>
+#include <asm/atomic.h>
+#include <asm/local.h>
+
+#include "wrapper/trace-clock.h"
+#include "wrapper/compiler.h"
+#include "lttng-tracer-core.h"
+#include "lttng-events.h"
+
+#define LTTNG_MODULES_MAJOR_VERSION 2
+#define LTTNG_MODULES_MINOR_VERSION 3
+#define LTTNG_MODULES_PATCHLEVEL_VERSION 4
+
+#define LTTNG_VERSION_NAME             "Dominus Vobiscum"
+#define LTTNG_VERSION_DESCRIPTION      \
+       "A very succulent line-up of beers brewed at Microbrasserie Charlevoix. Elaborated starting from special malts and fermented with a Belgian yeast. These beers are refermented in bottle and will make you discover the richness of wheat, amber and triple styles."
+
+#ifndef CHAR_BIT
+#define CHAR_BIT 8
+#endif
+
+/* Number of bytes to log with a read/write event */
+#define LTTNG_LOG_RW_SIZE              32L
+#define LTTNG_MAX_SMALL_SIZE           0xFFFFU
+
+#ifdef RING_BUFFER_ALIGN
+#define lttng_alignof(type)    __alignof__(type)
+#else
+#define lttng_alignof(type)    1
+#endif
+
+/* Tracer properties */
+#define CTF_MAGIC_NUMBER               0xC1FC1FC1
+#define TSDL_MAGIC_NUMBER              0x75D11D57
+
+/* CTF specification version followed */
+#define CTF_SPEC_MAJOR                 1
+#define CTF_SPEC_MINOR                 8
+
+/*
+ * Number of milliseconds to retry before failing metadata writes on buffer full
+ * condition. (10 seconds)
+ */
+#define LTTNG_METADATA_TIMEOUT_MSEC    10000
+
+#define LTTNG_RFLAG_EXTENDED           RING_BUFFER_RFLAG_END
+#define LTTNG_RFLAG_END                        (LTTNG_RFLAG_EXTENDED << 1)
+
+#endif /* _LTTNG_TRACER_H */
diff --git a/drivers/staging/lttng/probes/Makefile b/drivers/staging/lttng/probes/Makefile
new file mode 100644 (file)
index 0000000..63ca7ba
--- /dev/null
@@ -0,0 +1,240 @@
+#
+# Makefile for the LTT probes.
+# Only build from the package top-level directory. Never use with make directly.
+
+ifneq ($(KERNELRELEASE),)
+ifneq ($(CONFIG_TRACEPOINTS),)
+
+ccflags-y += -I$(PWD)/probes
+obj-m += lttng-types.o
+
+obj-m += lttng-probe-sched.o
+obj-m += lttng-probe-irq.o
+obj-m += lttng-probe-timer.o
+obj-m += lttng-probe-kmem.o
+obj-m += lttng-probe-module.o
+obj-m += lttng-probe-power.o
+
+obj-m += lttng-probe-statedump.o
+
+ifneq ($(CONFIG_KVM),)
+obj-m += lttng-probe-kvm.o
+ifneq ($(CONFIG_X86),)
+kvm_dep = $(srctree)/virt/kvm/iodev.h
+ifneq ($(wildcard $(kvm_dep)),)
+CFLAGS_lttng-probe-kvm-x86.o += -I$(srctree)/virt/kvm
+CFLAGS_lttng-probe-kvm-x86-mmu.o += -I$(srctree)/virt/kvm
+obj-m += lttng-probe-kvm-x86.o
+obj-m += lttng-probe-kvm-x86-mmu.o
+else
+$(warning File $(kvm_dep) not found. Probe "kvm" x86-specific is disabled. Use full kernel source tree to enable it.)
+endif
+endif
+endif
+
+obj-m +=  $(shell \
+       if [ $(VERSION) -ge 3 \
+               -o \( $(VERSION) -eq 2 -a $(PATCHLEVEL) -ge 6 -a $(SUBLEVEL) -ge 33 \) ] ; then \
+               echo "lttng-probe-signal.o" ; fi;)
+
+ifneq ($(CONFIG_BLOCK),)
+ifneq ($(CONFIG_EVENT_TRACING),)       # need blk_cmd_buf_len
+obj-m += lttng-probe-block.o
+endif
+endif
+
+ifneq ($(CONFIG_NET),)
+obj-m += lttng-probe-napi.o
+obj-m += lttng-probe-skb.o
+obj-m +=  $(shell \
+       if [ $(VERSION) -ge 3 \
+               -o \( $(VERSION) -eq 2 -a $(PATCHLEVEL) -ge 6 -a $(SUBLEVEL) -ge 37 \) ] ; then \
+               echo "lttng-probe-net.o" ; fi;)
+obj-m +=  $(shell \
+       if [ $(VERSION) -ge 3 -a $(PATCHLEVEL) -ge 1 ] ; then \
+               echo "lttng-probe-sock.o" ; fi;)
+obj-m +=  $(shell \
+       if [ $(VERSION) -ge 3 -a $(PATCHLEVEL) -ge 1 ] ; then \
+               echo "lttng-probe-udp.o" ; fi;)
+endif
+
+ifneq ($(CONFIG_SND_SOC),)
+obj-m +=  $(shell \
+       if [ $(VERSION) -ge 3 \
+               -o \( $(VERSION) -eq 2 -a $(PATCHLEVEL) -ge 6 -a $(SUBLEVEL) -ge 38 \) ] ; then \
+               echo "lttng-probe-asoc.o" ; fi;)
+endif
+
+ifneq ($(CONFIG_EXT3_FS),)
+ext3_dep = $(srctree)/fs/ext3/*.h
+ext3_dep_check = $(wildcard $(ext3_dep))
+ext3 = $(shell \
+       if [ $(VERSION) -ge 3 -a $(PATCHLEVEL) -ge 1 ] ; then \
+               if [ $(VERSION) -ge 3 -a $(PATCHLEVEL) -ge 4 -a \
+                       -z "$(ext3_dep_check)" ] ; then \
+                       echo "warn" ; \
+                       exit ; \
+               fi; \
+               echo "lttng-probe-ext3.o" ; \
+       fi;)
+ifeq ($(ext3),warn)
+$(warning Files $(ext3_dep) not found. Probe "ext3" is disabled. Use full kernel source tree to enable it.)
+ext3 =
+endif
+obj-m += $(ext3)
+endif
+
+ifneq ($(CONFIG_GPIOLIB),)
+obj-m +=  $(shell \
+       if [ $(VERSION) -ge 3 ] ; then \
+               echo "lttng-probe-gpio.o" ; fi;)
+endif
+
+ifneq ($(CONFIG_JBD2),)
+obj-m += lttng-probe-jbd2.o
+endif
+
+ifneq ($(CONFIG_JBD),)
+obj-m +=  $(shell \
+       if [ $(VERSION) -ge 3 -a $(PATCHLEVEL) -ge 1 ] ; then \
+               echo "lttng-probe-jbd.o" ; fi;)
+endif
+
+ifneq ($(CONFIG_REGULATOR),)
+obj-m +=  $(shell \
+       if [ $(VERSION) -ge 3 \
+               -o \( $(VERSION) -eq 2 -a $(PATCHLEVEL) -ge 6 -a $(SUBLEVEL) -ge 38 \) ] ; then \
+               echo "lttng-probe-regulator.o" ; fi;)
+endif
+
+ifneq ($(CONFIG_SCSI),)
+obj-m +=  $(shell \
+       if [ $(VERSION) -ge 3 \
+               -o \( $(VERSION) -eq 2 -a $(PATCHLEVEL) -ge 6 -a $(SUBLEVEL) -ge 35 \) ] ; then \
+               echo "lttng-probe-scsi.o" ; fi;)
+endif
+
+vmscan = $(shell \
+       if [ $(VERSION) -ge 3 \
+               -o \( $(VERSION) -eq 2 -a $(PATCHLEVEL) -ge 6 -a $(SUBLEVEL) -ge 36 \) ] ; then \
+               echo "lttng-probe-vmscan.o" ; fi;)
+ifneq ($(CONFIG_SWAP),)
+       obj-m += $(vmscan)
+else
+ifneq ($(CONFIG_CGROUP_MEM_RES_CTLR),)
+       obj-m += $(vmscan)
+endif
+endif
+
+# lock probe does not work, so disabling it for now
+#ifneq ($(CONFIG_LOCKDEP),)
+#obj-m += lttng-probe-lock.o
+#endif
+
+ifneq ($(CONFIG_BTRFS_FS),)
+btrfs_dep = $(srctree)/fs/btrfs/*.h
+btrfs = $(shell \
+       if [ $(VERSION) -ge 3 \
+               -o \( $(VERSION) -eq 2 -a $(PATCHLEVEL) -ge 6 -a $(SUBLEVEL) -ge 39 \) ] ; then \
+               echo "lttng-probe-btrfs.o" ; fi;)
+ifneq ($(btrfs),)
+ifeq ($(wildcard $(btrfs_dep)),)
+$(warning Files $(btrfs_dep) not found. Probe "btrfs" is disabled. Use full kernel source tree to enable it.)
+btrfs =
+endif
+endif
+obj-m += $(btrfs)
+endif
+
+obj-m +=  $(shell \
+       if [ $(VERSION) -ge 3 \
+               -o \( $(VERSION) -eq 2 -a $(PATCHLEVEL) -ge 6 -a $(SUBLEVEL) -ge 38 \) ] ; then \
+               echo "lttng-probe-compaction.o" ; fi;)
+
+ifneq ($(CONFIG_EXT4_FS),)
+ext4_dep = $(srctree)/fs/ext4/*.h
+ext4 = lttng-probe-ext4.o
+ifeq ($(wildcard $(ext4_dep)),)
+$(warning Files $(ext4_dep) not found. Probe "ext4" is disabled. Use full kernel source tree to enable it.)
+ext4 =
+endif
+obj-m += $(ext4)
+endif
+
+obj-m +=  $(shell \
+       if [ $(VERSION) -ge 3 -a $(PATCHLEVEL) -ge 4 ] ; then \
+               echo "lttng-probe-printk.o" ; fi;)
+ifneq ($(CONFIG_FRAME_WARN),0)
+CFLAGS_lttng-probe-printk.o += -Wframe-larger-than=2200
+endif
+
+obj-m +=  $(shell \
+       if [ \( $(VERSION) -eq 3 -a $(PATCHLEVEL) -ge 6 \) \
+               -o \( $(VERSION) -eq 3 -a $(PATCHLEVEL) -eq 5 -a $(SUBLEVEL) -ge 2 \) \
+               -o \( $(VERSION) -eq 3 -a $(PATCHLEVEL) -eq 4 -a $(SUBLEVEL) -ge 9 \) \
+               -o \( $(VERSION) -eq 3 -a $(PATCHLEVEL) -eq 0 -a $(SUBLEVEL) -ge 41 \) ] ; then \
+               echo "lttng-probe-random.o" ; fi;)
+
+obj-m +=  $(shell \
+       if [ $(VERSION) -ge 3 -a $(PATCHLEVEL) -ge 2 ] ; then \
+               echo "lttng-probe-rcu.o" ; fi;)
+
+ifneq ($(CONFIG_REGMAP),)
+obj-m +=  $(shell \
+       if [ $(VERSION) -ge 3 -a $(PATCHLEVEL) -ge 2 ] ; then \
+               echo "lttng-probe-regmap.o" ; fi;)
+endif
+
+ifneq ($(CONFIG_PM_RUNTIME),)
+obj-m +=  $(shell \
+       if [ $(VERSION) -ge 3 -a $(PATCHLEVEL) -ge 2 ] ; then \
+               echo "lttng-probe-rpm.o" ; fi;)
+endif
+
+ifneq ($(CONFIG_SUNRPC),)
+obj-m +=  $(shell \
+       if [ $(VERSION) -ge 3 -a $(PATCHLEVEL) -ge 4 ] ; then \
+               echo "lttng-probe-sunrpc.o" ; fi;)
+endif
+
+obj-m += lttng-probe-workqueue.o
+
+ifneq ($(CONFIG_KALLSYMS_ALL),)
+obj-m +=  $(shell \
+       if [ $(VERSION) -ge 3 \
+               -o \( $(VERSION) -eq 2 -a $(PATCHLEVEL) -ge 6 -a $(SUBLEVEL) -ge 36 \) ] ; then \
+               echo "lttng-probe-writeback.o" ; fi;)
+endif
+
+
+ifneq ($(CONFIG_KPROBES),)
+obj-m += lttng-kprobes.o
+endif
+
+
+ifneq ($(CONFIG_KRETPROBES),)
+obj-m += lttng-kretprobes.o
+endif
+
+ifneq ($(CONFIG_DYNAMIC_FTRACE),)
+obj-m += lttng-ftrace.o
+endif
+
+endif
+
+else
+       KERNELDIR ?= /lib/modules/$(shell uname -r)/build
+       PWD := $(shell pwd)
+       CFLAGS = $(EXTCFLAGS)
+
+default:
+       $(MAKE) -C $(KERNELDIR) M=$(PWD) modules
+
+modules_install:
+       $(MAKE) -C $(KERNELDIR) M=$(PWD) modules_install
+       /sbin/depmod -a
+
+clean:
+       $(MAKE) -C $(KERNELDIR) M=$(PWD) clean
+
+endif
diff --git a/drivers/staging/lttng/probes/define_trace.h b/drivers/staging/lttng/probes/define_trace.h
new file mode 100644 (file)
index 0000000..96d80a5
--- /dev/null
@@ -0,0 +1,180 @@
+/*
+ * define_trace.h
+ *
+ * Copyright (C) 2009 Steven Rostedt <rostedt@goodmis.org>
+ * Copyright (C) 2010-2012 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; only
+ * version 2.1 of the License.
+ *
+ * This library 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
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+/*
+ * Trace files that want to automate creationg of all tracepoints defined
+ * in their file should include this file. The following are macros that the
+ * trace file may define:
+ *
+ * TRACE_SYSTEM defines the system the tracepoint is for
+ *
+ * TRACE_INCLUDE_FILE if the file name is something other than TRACE_SYSTEM.h
+ *     This macro may be defined to tell define_trace.h what file to include.
+ *     Note, leave off the ".h".
+ *
+ * TRACE_INCLUDE_PATH if the path is something other than core kernel include/trace
+ *     then this macro can define the path to use. Note, the path is relative to
+ *     define_trace.h, not the file including it. Full path names for out of tree
+ *     modules must be used.
+ */
+
+#ifdef CREATE_TRACE_POINTS
+
+/* Prevent recursion */
+#undef CREATE_TRACE_POINTS
+
+#include <linux/stringify.h>
+/*
+ * module.h includes tracepoints, and because ftrace.h
+ * pulls in module.h:
+ *  trace/ftrace.h -> linux/ftrace_event.h -> linux/perf_event.h ->
+ *  linux/ftrace.h -> linux/module.h
+ * we must include module.h here before we play with any of
+ * the TRACE_EVENT() macros, otherwise the tracepoints included
+ * by module.h may break the build.
+ */
+#include <linux/module.h>
+
+#undef TRACE_EVENT_MAP
+#define TRACE_EVENT_MAP(name, map, proto, args, tstruct, assign, print)        \
+       DEFINE_TRACE(name)
+
+#undef TRACE_EVENT_CONDITION_MAP
+#define TRACE_EVENT_CONDITION_MAP(name, map, proto, args, cond, tstruct, assign, print) \
+       TRACE_EVENT(name,                                               \
+               PARAMS(proto),                                          \
+               PARAMS(args),                                           \
+               PARAMS(tstruct),                                        \
+               PARAMS(assign),                                         \
+               PARAMS(print))
+
+#undef TRACE_EVENT_FN_MAP
+#define TRACE_EVENT_FN_MAP(name, map, proto, args, tstruct,            \
+               assign, print, reg, unreg)                      \
+       DEFINE_TRACE_FN(name, reg, unreg)
+
+#undef DEFINE_EVENT_MAP
+#define DEFINE_EVENT_MAP(template, name, map, proto, args) \
+       DEFINE_TRACE(name)
+
+#undef DEFINE_EVENT_PRINT_MAP
+#define DEFINE_EVENT_PRINT_MAP(template, name, map, proto, args, print)        \
+       DEFINE_TRACE(name)
+
+#undef DEFINE_EVENT_CONDITION_MAP
+#define DEFINE_EVENT_CONDITION_MAP(template, name, map, proto, args, cond) \
+       DEFINE_EVENT(template, name, PARAMS(proto), PARAMS(args))
+
+
+#undef TRACE_EVENT
+#define TRACE_EVENT(name, proto, args, tstruct, assign, print) \
+       DEFINE_TRACE(name)
+
+#undef TRACE_EVENT_CONDITION
+#define TRACE_EVENT_CONDITION(name, proto, args, cond, tstruct, assign, print) \
+       TRACE_EVENT(name,                                               \
+               PARAMS(proto),                                          \
+               PARAMS(args),                                           \
+               PARAMS(tstruct),                                        \
+               PARAMS(assign),                                         \
+               PARAMS(print))
+
+#undef TRACE_EVENT_FN
+#define TRACE_EVENT_FN(name, proto, args, tstruct,             \
+               assign, print, reg, unreg)                      \
+       DEFINE_TRACE_FN(name, reg, unreg)
+
+#undef DEFINE_EVENT
+#define DEFINE_EVENT(template, name, proto, args) \
+       DEFINE_TRACE(name)
+
+#undef DEFINE_EVENT_PRINT
+#define DEFINE_EVENT_PRINT(template, name, proto, args, print) \
+       DEFINE_TRACE(name)
+
+#undef DEFINE_EVENT_CONDITION
+#define DEFINE_EVENT_CONDITION(template, name, proto, args, cond) \
+       DEFINE_EVENT(template, name, PARAMS(proto), PARAMS(args))
+
+#undef DECLARE_TRACE
+#define DECLARE_TRACE(name, proto, args)       \
+       DEFINE_TRACE(name)
+
+#undef TRACE_INCLUDE
+#undef __TRACE_INCLUDE
+
+#ifndef TRACE_INCLUDE_FILE
+# define TRACE_INCLUDE_FILE TRACE_SYSTEM
+# define UNDEF_TRACE_INCLUDE_FILE
+#endif
+
+#ifndef TRACE_INCLUDE_PATH
+# define __TRACE_INCLUDE(system) <trace/events/system.h>
+# define UNDEF_TRACE_INCLUDE_PATH
+#else
+# define __TRACE_INCLUDE(system) __stringify(TRACE_INCLUDE_PATH/system.h)
+#endif
+
+# define TRACE_INCLUDE(system) __TRACE_INCLUDE(system)
+
+/* Let the trace headers be reread */
+#define TRACE_HEADER_MULTI_READ
+
+#include TRACE_INCLUDE(TRACE_INCLUDE_FILE)
+
+/* Make all open coded DECLARE_TRACE nops */
+#undef DECLARE_TRACE
+#define DECLARE_TRACE(name, proto, args)
+
+#ifdef LTTNG_PACKAGE_BUILD
+#include "lttng-events.h"
+#endif
+
+#undef TRACE_EVENT
+#undef TRACE_EVENT_FN
+#undef TRACE_EVENT_CONDITION
+#undef DEFINE_EVENT
+#undef DEFINE_EVENT_PRINT
+#undef DEFINE_EVENT_CONDITION
+#undef TRACE_EVENT_MAP
+#undef TRACE_EVENT_FN_MAP
+#undef TRACE_EVENT_CONDITION_MAP
+#undef DECLARE_EVENT_CLASS
+#undef DEFINE_EVENT_MAP
+#undef DEFINE_EVENT_PRINT_MAP
+#undef DEFINE_EVENT_CONDITION_MAP
+#undef TRACE_HEADER_MULTI_READ
+
+/* Only undef what we defined in this file */
+#ifdef UNDEF_TRACE_INCLUDE_FILE
+# undef TRACE_INCLUDE_FILE
+# undef UNDEF_TRACE_INCLUDE_FILE
+#endif
+
+#ifdef UNDEF_TRACE_INCLUDE_PATH
+# undef TRACE_INCLUDE_PATH
+# undef UNDEF_TRACE_INCLUDE_PATH
+#endif
+
+/* We may be processing more files */
+#define CREATE_TRACE_POINTS
+
+#endif /* CREATE_TRACE_POINTS */
diff --git a/drivers/staging/lttng/probes/lttng-events-reset.h b/drivers/staging/lttng/probes/lttng-events-reset.h
new file mode 100644 (file)
index 0000000..b601e8d
--- /dev/null
@@ -0,0 +1,99 @@
+/*
+ * lttng-events-reset.h
+ *
+ * Copyright (C) 2010-2012 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; only
+ * version 2.1 of the License.
+ *
+ * This library 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
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+/* Reset macros used within TRACE_EVENT to "nothing" */
+
+#undef __field_full
+#define __field_full(_type, _item, _order, _base)
+
+#undef __array_enc_ext
+#define __array_enc_ext(_type, _item, _length, _order, _base, _encoding)
+
+#undef __dynamic_array_enc_ext
+#define __dynamic_array_enc_ext(_type, _item, _length, _order, _base, _encoding)
+
+#undef __dynamic_array_enc_ext_2
+#define __dynamic_array_enc_ext_2(_type, _item, _length1, _length2, _order, _base, _encoding)
+
+#undef __dynamic_array_len
+#define __dynamic_array_len(_type, _item, _length)
+
+#undef __string
+#define __string(_item, _src)
+
+#undef tp_assign
+#define tp_assign(dest, src)
+
+#undef tp_memcpy
+#define tp_memcpy(dest, src, len)
+
+#undef tp_memcpy_dyn
+#define tp_memcpy_dyn(dest, src, len)
+
+#undef tp_strcpy
+#define tp_strcpy(dest, src)
+
+#undef __get_str
+#define __get_str(field)
+
+#undef __get_dynamic_array
+#define __get_dynamic_array(field)
+
+#undef __get_dynamic_array_len
+#define __get_dynamic_array_len(field)
+
+#undef TP_PROTO
+#define TP_PROTO(args...)
+
+#undef TP_ARGS
+#define TP_ARGS(args...)
+
+#undef TP_STRUCT__entry
+#define TP_STRUCT__entry(args...)
+
+#undef TP_fast_assign
+#define TP_fast_assign(args...)
+
+#undef __perf_count
+#define __perf_count(args...)
+
+#undef __perf_addr
+#define __perf_addr(args...)
+
+#undef TP_perf_assign
+#define TP_perf_assign(args...)
+
+#undef TP_printk
+#define TP_printk(args...)
+
+#undef DECLARE_EVENT_CLASS
+#define DECLARE_EVENT_CLASS(_name, _proto, _args, _tstruct, _assign, _print)
+
+#undef DECLARE_EVENT_CLASS_NOARGS
+#define DECLARE_EVENT_CLASS_NOARGS(_name, _tstruct, _assign, _print)
+
+#undef DEFINE_EVENT_MAP
+#define DEFINE_EVENT_MAP(_template, _name, _map, _proto, _args)
+
+#undef DEFINE_EVENT_MAP_NOARGS
+#define DEFINE_EVENT_MAP_NOARGS(_template, _name, _map)
+
+#undef TRACE_EVENT_FLAGS
+#define TRACE_EVENT_FLAGS(name, value)
diff --git a/drivers/staging/lttng/probes/lttng-events.h b/drivers/staging/lttng/probes/lttng-events.h
new file mode 100644 (file)
index 0000000..bf2e2b9
--- /dev/null
@@ -0,0 +1,868 @@
+/*
+ * lttng-events.h
+ *
+ * Copyright (C) 2009 Steven Rostedt <rostedt@goodmis.org>
+ * Copyright (C) 2009-2012 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; only
+ * version 2.1 of the License.
+ *
+ * This library 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
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+#include <linux/uaccess.h>
+#include <linux/debugfs.h>
+#include "lttng.h"
+#include "lttng-types.h"
+#include "lttng-probe-user.h"
+#include "../wrapper/vmalloc.h"        /* for wrapper_vmalloc_sync_all() */
+#include "../wrapper/ringbuffer/frontend_types.h"
+#include "../lttng-events.h"
+#include "../lttng-tracer-core.h"
+
+/*
+ * Macro declarations used for all stages.
+ */
+
+/*
+ * LTTng name mapping macros. LTTng remaps some of the kernel events to
+ * enforce name-spacing.
+ */
+#undef TRACE_EVENT_MAP
+#define TRACE_EVENT_MAP(name, map, proto, args, tstruct, assign, print)        \
+       DECLARE_EVENT_CLASS(map,                                        \
+                            PARAMS(proto),                             \
+                            PARAMS(args),                              \
+                            PARAMS(tstruct),                           \
+                            PARAMS(assign),                            \
+                            PARAMS(print))                             \
+       DEFINE_EVENT_MAP(map, name, map, PARAMS(proto), PARAMS(args))
+
+#undef TRACE_EVENT_MAP_NOARGS
+#define TRACE_EVENT_MAP_NOARGS(name, map, tstruct, assign, print)      \
+       DECLARE_EVENT_CLASS_NOARGS(map,                                 \
+                            PARAMS(tstruct),                           \
+                            PARAMS(assign),                            \
+                            PARAMS(print))                             \
+       DEFINE_EVENT_MAP_NOARGS(map, name, map)
+
+#undef DEFINE_EVENT_PRINT_MAP
+#define DEFINE_EVENT_PRINT_MAP(template, name, map, proto, args, print)        \
+       DEFINE_EVENT_MAP(template, name, map, PARAMS(proto), PARAMS(args))
+
+/* Callbacks are meaningless to LTTng. */
+#undef TRACE_EVENT_FN_MAP
+#define TRACE_EVENT_FN_MAP(name, map, proto, args, tstruct,            \
+               assign, print, reg, unreg)                              \
+       TRACE_EVENT_MAP(name, map, PARAMS(proto), PARAMS(args),         \
+               PARAMS(tstruct), PARAMS(assign), PARAMS(print))         \
+
+#undef TRACE_EVENT_CONDITION_MAP
+#define TRACE_EVENT_CONDITION_MAP(name, map, proto, args, cond, tstruct, assign, print) \
+       TRACE_EVENT_MAP(name, map,                                      \
+               PARAMS(proto),                                          \
+               PARAMS(args),                                           \
+               PARAMS(tstruct),                                        \
+               PARAMS(assign),                                         \
+               PARAMS(print))
+
+/*
+ * DECLARE_EVENT_CLASS can be used to add a generic function
+ * handlers for events. That is, if all events have the same
+ * parameters and just have distinct trace points.
+ * Each tracepoint can be defined with DEFINE_EVENT and that
+ * will map the DECLARE_EVENT_CLASS to the tracepoint.
+ *
+ * TRACE_EVENT is a one to one mapping between tracepoint and template.
+ */
+
+#undef TRACE_EVENT
+#define TRACE_EVENT(name, proto, args, tstruct, assign, print) \
+       TRACE_EVENT_MAP(name, name,                             \
+                       PARAMS(proto),                          \
+                       PARAMS(args),                           \
+                       PARAMS(tstruct),                        \
+                       PARAMS(assign),                         \
+                       PARAMS(print))
+
+#undef TRACE_EVENT_NOARGS
+#define TRACE_EVENT_NOARGS(name, tstruct, assign, print)       \
+       TRACE_EVENT_MAP_NOARGS(name, name,                      \
+                       PARAMS(tstruct),                        \
+                       PARAMS(assign),                         \
+                       PARAMS(print))
+
+#undef DEFINE_EVENT_PRINT
+#define DEFINE_EVENT_PRINT(template, name, proto, args, print) \
+       DEFINE_EVENT_PRINT_MAP(template, name, name,            \
+                       PARAMS(proto), PARAMS(args), PARAMS(print_))
+
+#undef TRACE_EVENT_FN
+#define TRACE_EVENT_FN(name, proto, args, tstruct,                     \
+               assign, print, reg, unreg)                              \
+       TRACE_EVENT_FN_MAP(name, name, PARAMS(proto), PARAMS(args),     \
+               PARAMS(tstruct), PARAMS(assign), PARAMS(print),         \
+               PARAMS(reg), PARAMS(unreg))                             \
+
+#undef DEFINE_EVENT
+#define DEFINE_EVENT(template, name, proto, args)                      \
+       DEFINE_EVENT_MAP(template, name, name, PARAMS(proto), PARAMS(args))
+
+#undef DEFINE_EVENT_NOARGS
+#define DEFINE_EVENT_NOARGS(template, name)                            \
+       DEFINE_EVENT_MAP_NOARGS(template, name, name)
+
+#undef TRACE_EVENT_CONDITION
+#define TRACE_EVENT_CONDITION(name, proto, args, cond, tstruct, assign, print) \
+       TRACE_EVENT_CONDITION_MAP(name, name,                           \
+               PARAMS(proto),                                          \
+               PARAMS(args),                                           \
+               PARAMS(cond),                                           \
+               PARAMS(tstruct),                                        \
+               PARAMS(assign),                                         \
+               PARAMS(print))
+
+/*
+ * Stage 1 of the trace events.
+ *
+ * Create dummy trace calls for each events, verifying that the LTTng module
+ * TRACE_EVENT headers match the kernel arguments. Will be optimized out by the
+ * compiler.
+ */
+
+#include "lttng-events-reset.h"        /* Reset all macros within TRACE_EVENT */
+
+#undef TP_PROTO
+#define TP_PROTO(args...) args
+
+#undef TP_ARGS
+#define TP_ARGS(args...) args
+
+#undef DEFINE_EVENT_MAP
+#define DEFINE_EVENT_MAP(_template, _name, _map, _proto, _args)                \
+void trace_##_name(_proto);
+
+#undef DEFINE_EVENT_MAP_NOARGS
+#define DEFINE_EVENT_MAP_NOARGS(_template, _name, _map)                        \
+void trace_##_name(void *__data);
+
+#include TRACE_INCLUDE(TRACE_INCLUDE_FILE)
+
+/*
+ * Stage 2 of the trace events.
+ *
+ * Create event field type metadata section.
+ * Each event produce an array of fields.
+ */
+
+#include "lttng-events-reset.h"        /* Reset all macros within TRACE_EVENT */
+
+/* Named field types must be defined in lttng-types.h */
+
+#undef __field_full
+#define __field_full(_type, _item, _order, _base)              \
+       {                                                       \
+         .name = #_item,                                       \
+         .type = __type_integer(_type, _order, _base, none),   \
+       },
+
+#undef __field
+#define __field(_type, _item)                                  \
+       __field_full(_type, _item, __BYTE_ORDER, 10)
+
+#undef __field_ext
+#define __field_ext(_type, _item, _filter_type)                        \
+       __field(_type, _item)
+
+#undef __field_hex
+#define __field_hex(_type, _item)                              \
+       __field_full(_type, _item, __BYTE_ORDER, 16)
+
+#undef __field_network
+#define __field_network(_type, _item)                          \
+       __field_full(_type, _item, __BIG_ENDIAN, 10)
+
+#undef __field_network_hex
+#define __field_network_hex(_type, _item)                              \
+       __field_full(_type, _item, __BIG_ENDIAN, 16)
+
+#undef __array_enc_ext
+#define __array_enc_ext(_type, _item, _length, _order, _base, _encoding)\
+       {                                                       \
+         .name = #_item,                                       \
+         .type =                                               \
+               {                                               \
+                 .atype = atype_array,                         \
+                 .u.array =                                    \
+                       {                                       \
+                           .length = _length,                  \
+                           .elem_type = __type_integer(_type, _order, _base, _encoding), \
+                       },                                      \
+               },                                              \
+       },
+
+#undef __array
+#define __array(_type, _item, _length)                         \
+       __array_enc_ext(_type, _item, _length, __BYTE_ORDER, 10, none)
+
+#undef __array_text
+#define __array_text(_type, _item, _length)                    \
+       __array_enc_ext(_type, _item, _length, __BYTE_ORDER, 10, UTF8)
+
+#undef __array_hex
+#define __array_hex(_type, _item, _length)                     \
+       __array_enc_ext(_type, _item, _length, __BYTE_ORDER, 16, none)
+
+#undef __dynamic_array_enc_ext
+#define __dynamic_array_enc_ext(_type, _item, _length, _order, _base, _encoding) \
+       {                                                       \
+         .name = #_item,                                       \
+         .type =                                               \
+               {                                               \
+                 .atype = atype_sequence,                      \
+                 .u.sequence =                                 \
+                       {                                       \
+                           .length_type = __type_integer(u32, __BYTE_ORDER, 10, none), \
+                           .elem_type = __type_integer(_type, _order, _base, _encoding), \
+                       },                                      \
+               },                                              \
+       },
+
+#undef __dynamic_array_enc_ext_2
+#define __dynamic_array_enc_ext_2(_type, _item, _length1, _length2, _order, _base, _encoding) \
+       __dynamic_array_enc_ext(_type, _item, _length1 + _length2, _order, _base, _encoding)
+
+#undef __dynamic_array
+#define __dynamic_array(_type, _item, _length)                 \
+       __dynamic_array_enc_ext(_type, _item, _length, __BYTE_ORDER, 10, none)
+
+#undef __dynamic_array_text
+#define __dynamic_array_text(_type, _item, _length)            \
+       __dynamic_array_enc_ext(_type, _item, _length, __BYTE_ORDER, 10, UTF8)
+
+#undef __dynamic_array_hex
+#define __dynamic_array_hex(_type, _item, _length)             \
+       __dynamic_array_enc_ext(_type, _item, _length, __BYTE_ORDER, 16, none)
+
+#undef __dynamic_array_text_2
+#define __dynamic_array_text_2(_type, _item, _length1, _length2)       \
+       __dynamic_array_enc_ext_2(_type, _item, _length1, _length2, __BYTE_ORDER, 10, UTF8)
+
+#undef __string
+#define __string(_item, _src)                                  \
+       {                                                       \
+         .name = #_item,                                       \
+         .type =                                               \
+               {                                               \
+                 .atype = atype_string,                        \
+                 .u.basic.string.encoding = lttng_encode_UTF8, \
+               },                                              \
+       },
+
+#undef __string_from_user
+#define __string_from_user(_item, _src)                                \
+       __string(_item, _src)
+
+#undef TP_STRUCT__entry
+#define TP_STRUCT__entry(args...) args /* Only one used in this phase */
+
+#undef DECLARE_EVENT_CLASS_NOARGS
+#define DECLARE_EVENT_CLASS_NOARGS(_name, _tstruct, _assign, _print) \
+       static const struct lttng_event_field __event_fields___##_name[] = { \
+               _tstruct                                                     \
+       };
+
+#undef DECLARE_EVENT_CLASS
+#define DECLARE_EVENT_CLASS(_name, _proto, _args, _tstruct, _assign, _print) \
+       DECLARE_EVENT_CLASS_NOARGS(_name, PARAMS(_tstruct), PARAMS(_assign), \
+                       PARAMS(_print))
+
+#include TRACE_INCLUDE(TRACE_INCLUDE_FILE)
+
+/*
+ * Stage 3 of the trace events.
+ *
+ * Create probe callback prototypes.
+ */
+
+#include "lttng-events-reset.h"        /* Reset all macros within TRACE_EVENT */
+
+#undef TP_PROTO
+#define TP_PROTO(args...) args
+
+#undef DECLARE_EVENT_CLASS
+#define DECLARE_EVENT_CLASS(_name, _proto, _args, _tstruct, _assign, _print)  \
+static void __event_probe__##_name(void *__data, _proto);
+
+#undef DECLARE_EVENT_CLASS_NOARGS
+#define DECLARE_EVENT_CLASS_NOARGS(_name, _tstruct, _assign, _print)         \
+static void __event_probe__##_name(void *__data);
+
+#include TRACE_INCLUDE(TRACE_INCLUDE_FILE)
+
+/*
+ * Stage 3.9 of the trace events.
+ *
+ * Create event descriptions.
+ */
+
+/* Named field types must be defined in lttng-types.h */
+
+#include "lttng-events-reset.h"        /* Reset all macros within TRACE_EVENT */
+
+#ifndef TP_PROBE_CB
+#define TP_PROBE_CB(_template) &__event_probe__##_template
+#endif
+
+#undef DEFINE_EVENT_MAP_NOARGS
+#define DEFINE_EVENT_MAP_NOARGS(_template, _name, _map)                        \
+static const struct lttng_event_desc __event_desc___##_map = {         \
+       .fields = __event_fields___##_template,                         \
+       .name = #_map,                                                  \
+       .probe_callback = (void *) TP_PROBE_CB(_template),              \
+       .nr_fields = ARRAY_SIZE(__event_fields___##_template),          \
+       .owner = THIS_MODULE,                                           \
+};
+
+#undef DEFINE_EVENT_MAP
+#define DEFINE_EVENT_MAP(_template, _name, _map, _proto, _args)                \
+       DEFINE_EVENT_MAP_NOARGS(_template, _name, _map)
+
+#include TRACE_INCLUDE(TRACE_INCLUDE_FILE)
+
+
+/*
+ * Stage 4 of the trace events.
+ *
+ * Create an array of event description pointers.
+ */
+
+/* Named field types must be defined in lttng-types.h */
+
+#include "lttng-events-reset.h"        /* Reset all macros within TRACE_EVENT */
+
+#undef DEFINE_EVENT_MAP_NOARGS
+#define DEFINE_EVENT_MAP_NOARGS(_template, _name, _map)                               \
+               &__event_desc___##_map,
+
+#undef DEFINE_EVENT_MAP
+#define DEFINE_EVENT_MAP(_template, _name, _map, _proto, _args)                       \
+       DEFINE_EVENT_MAP_NOARGS(_template, _name, _map)
+
+#define TP_ID1(_token, _system)        _token##_system
+#define TP_ID(_token, _system) TP_ID1(_token, _system)
+
+static const struct lttng_event_desc *TP_ID(__event_desc___, TRACE_SYSTEM)[] = {
+#include TRACE_INCLUDE(TRACE_INCLUDE_FILE)
+};
+
+#undef TP_ID1
+#undef TP_ID
+
+
+/*
+ * Stage 5 of the trace events.
+ *
+ * Create a toplevel descriptor for the whole probe.
+ */
+
+#define TP_ID1(_token, _system)        _token##_system
+#define TP_ID(_token, _system) TP_ID1(_token, _system)
+
+/* non-const because list head will be modified when registered. */
+static __used struct lttng_probe_desc TP_ID(__probe_desc___, TRACE_SYSTEM) = {
+       .event_desc = TP_ID(__event_desc___, TRACE_SYSTEM),
+       .nr_events = ARRAY_SIZE(TP_ID(__event_desc___, TRACE_SYSTEM)),
+};
+
+#undef TP_ID1
+#undef TP_ID
+
+/*
+ * Stage 6 of the trace events.
+ *
+ * Create static inline function that calculates event size.
+ */
+
+#include "lttng-events-reset.h"        /* Reset all macros within TRACE_EVENT */
+
+/* Named field types must be defined in lttng-types.h */
+
+#undef __field_full
+#define __field_full(_type, _item, _order, _base)                             \
+       __event_len += lib_ring_buffer_align(__event_len, lttng_alignof(_type)); \
+       __event_len += sizeof(_type);
+
+#undef __array_enc_ext
+#define __array_enc_ext(_type, _item, _length, _order, _base, _encoding)       \
+       __event_len += lib_ring_buffer_align(__event_len, lttng_alignof(_type)); \
+       __event_len += sizeof(_type) * (_length);
+
+#undef __dynamic_array_enc_ext
+#define __dynamic_array_enc_ext(_type, _item, _length, _order, _base, _encoding)\
+       __event_len += lib_ring_buffer_align(__event_len, lttng_alignof(u32));   \
+       __event_len += sizeof(u32);                                            \
+       __event_len += lib_ring_buffer_align(__event_len, lttng_alignof(_type)); \
+       __dynamic_len[__dynamic_len_idx] = (_length);                          \
+       __event_len += sizeof(_type) * __dynamic_len[__dynamic_len_idx];       \
+       __dynamic_len_idx++;
+
+#undef __dynamic_array_enc_ext_2
+#define __dynamic_array_enc_ext_2(_type, _item, _length1, _length2, _order, _base, _encoding)\
+       __event_len += lib_ring_buffer_align(__event_len, lttng_alignof(u32));   \
+       __event_len += sizeof(u32);                                            \
+       __event_len += lib_ring_buffer_align(__event_len, lttng_alignof(_type)); \
+       __dynamic_len[__dynamic_len_idx] = (_length1);                         \
+       __event_len += sizeof(_type) * __dynamic_len[__dynamic_len_idx];       \
+       __dynamic_len_idx++;                                                   \
+       __dynamic_len[__dynamic_len_idx] = (_length2);                         \
+       __event_len += sizeof(_type) * __dynamic_len[__dynamic_len_idx];       \
+       __dynamic_len_idx++;
+
+#undef __string
+#define __string(_item, _src)                                                 \
+       __event_len += __dynamic_len[__dynamic_len_idx++] = strlen(_src) + 1;
+
+/*
+ * strlen_user includes \0. If returns 0, it faulted, so we set size to
+ * 1 (\0 only).
+ */
+#undef __string_from_user
+#define __string_from_user(_item, _src)                                               \
+       __event_len += __dynamic_len[__dynamic_len_idx++] =                    \
+               max_t(size_t, lttng_strlen_user_inatomic(_src), 1);
+
+#undef TP_PROTO
+#define TP_PROTO(args...) args
+
+#undef TP_STRUCT__entry
+#define TP_STRUCT__entry(args...) args
+
+#undef DECLARE_EVENT_CLASS
+#define DECLARE_EVENT_CLASS(_name, _proto, _args, _tstruct, _assign, _print)  \
+static inline size_t __event_get_size__##_name(size_t *__dynamic_len, _proto) \
+{                                                                            \
+       size_t __event_len = 0;                                               \
+       unsigned int __dynamic_len_idx = 0;                                   \
+                                                                             \
+       if (0)                                                                \
+               (void) __dynamic_len_idx;       /* don't warn if unused */    \
+       _tstruct                                                              \
+       return __event_len;                                                   \
+}
+
+#include TRACE_INCLUDE(TRACE_INCLUDE_FILE)
+
+/*
+ * Stage 7 of the trace events.
+ *
+ * Create static inline function that calculates event payload alignment.
+ */
+
+#include "lttng-events-reset.h"        /* Reset all macros within TRACE_EVENT */
+
+/* Named field types must be defined in lttng-types.h */
+
+#undef __field_full
+#define __field_full(_type, _item, _order, _base)                        \
+       __event_align = max_t(size_t, __event_align, lttng_alignof(_type));
+
+#undef __array_enc_ext
+#define __array_enc_ext(_type, _item, _length, _order, _base, _encoding)  \
+       __event_align = max_t(size_t, __event_align, lttng_alignof(_type));
+
+#undef __dynamic_array_enc_ext
+#define __dynamic_array_enc_ext(_type, _item, _length, _order, _base, _encoding)\
+       __event_align = max_t(size_t, __event_align, lttng_alignof(u32));         \
+       __event_align = max_t(size_t, __event_align, lttng_alignof(_type));
+
+#undef __dynamic_array_enc_ext_2
+#define __dynamic_array_enc_ext_2(_type, _item, _length1, _length2, _order, _base, _encoding)\
+       __dynamic_array_enc_ext(_type, _item, _length1 + _length2, _order, _base, _encoding)
+
+#undef __string
+#define __string(_item, _src)
+
+#undef __string_from_user
+#define __string_from_user(_item, _src)
+
+#undef TP_PROTO
+#define TP_PROTO(args...) args
+
+#undef TP_STRUCT__entry
+#define TP_STRUCT__entry(args...) args
+
+#undef DECLARE_EVENT_CLASS
+#define DECLARE_EVENT_CLASS(_name, _proto, _args, _tstruct, _assign, _print)  \
+static inline size_t __event_get_align__##_name(_proto)                              \
+{                                                                            \
+       size_t __event_align = 1;                                             \
+       _tstruct                                                              \
+       return __event_align;                                                 \
+}
+
+#include TRACE_INCLUDE(TRACE_INCLUDE_FILE)
+
+
+/*
+ * Stage 8 of the trace events.
+ *
+ * Create structure declaration that allows the "assign" macros to access the
+ * field types.
+ */
+
+#include "lttng-events-reset.h"        /* Reset all macros within TRACE_EVENT */
+
+/* Named field types must be defined in lttng-types.h */
+
+#undef __field_full
+#define __field_full(_type, _item, _order, _base)      _type   _item;
+
+#undef __array_enc_ext
+#define __array_enc_ext(_type, _item, _length, _order, _base, _encoding)  \
+       _type   _item;
+
+#undef __dynamic_array_enc_ext
+#define __dynamic_array_enc_ext(_type, _item, _length, _order, _base, _encoding)\
+       _type   _item;
+
+#undef __dynamic_array_enc_ext_2
+#define __dynamic_array_enc_ext_2(_type, _item, _length1, _length2, _order, _base, _encoding)\
+       __dynamic_array_enc_ext(_type, _item, _length1 + _length2, _order, _base, _encoding)
+
+#undef __string
+#define __string(_item, _src)                  char _item;
+
+#undef __string_from_user
+#define __string_from_user(_item, _src)                \
+       __string(_item, _src)
+
+#undef TP_STRUCT__entry
+#define TP_STRUCT__entry(args...) args
+
+#undef DECLARE_EVENT_CLASS
+#define DECLARE_EVENT_CLASS(_name, _proto, _args, _tstruct, _assign, _print)  \
+struct __event_typemap__##_name {                                            \
+       _tstruct                                                              \
+};
+
+#include TRACE_INCLUDE(TRACE_INCLUDE_FILE)
+
+
+/*
+ * Stage 9 of the trace events.
+ *
+ * Create the probe function : call even size calculation and write event data
+ * into the buffer.
+ *
+ * We use both the field and assignment macros to write the fields in the order
+ * defined in the field declaration. The field declarations control the
+ * execution order, jumping to the appropriate assignment block.
+ */
+
+#include "lttng-events-reset.h"        /* Reset all macros within TRACE_EVENT */
+
+#undef __field_full
+#define __field_full(_type, _item, _order, _base)                      \
+       goto __assign_##_item;                                          \
+__end_field_##_item:
+
+#undef __array_enc_ext
+#define __array_enc_ext(_type, _item, _length, _order, _base, _encoding)\
+       goto __assign_##_item;                                          \
+__end_field_##_item:
+
+#undef __dynamic_array_enc_ext
+#define __dynamic_array_enc_ext(_type, _item, _length, _order, _base, _encoding)\
+       goto __assign_##_item##_1;                                      \
+__end_field_##_item##_1:                                               \
+       goto __assign_##_item##_2;                                      \
+__end_field_##_item##_2:
+
+#undef __dynamic_array_enc_ext_2
+#define __dynamic_array_enc_ext_2(_type, _item, _length1, _length2, _order, _base, _encoding)\
+       goto __assign_##_item##_1;                                      \
+__end_field_##_item##_1:                                               \
+       goto __assign_##_item##_2;                                      \
+__end_field_##_item##_2:                                               \
+       goto __assign_##_item##_3;                                      \
+__end_field_##_item##_3:
+
+#undef __string
+#define __string(_item, _src)                                          \
+       goto __assign_##_item;                                          \
+__end_field_##_item:
+
+#undef __string_from_user
+#define __string_from_user(_item, _src)                                        \
+       __string(_item, _src)
+
+/*
+ * Macros mapping tp_assign() to "=", tp_memcpy() to memcpy() and tp_strcpy() to
+ * strcpy().
+ */
+#undef tp_assign
+#define tp_assign(dest, src)                                           \
+__assign_##dest:                                                       \
+       {                                                               \
+               __typeof__(__typemap.dest) __tmp = (src);               \
+               lib_ring_buffer_align_ctx(&__ctx, lttng_alignof(__tmp));        \
+               __chan->ops->event_write(&__ctx, &__tmp, sizeof(__tmp));\
+       }                                                               \
+       goto __end_field_##dest;
+
+/* fixed length array memcpy */
+#undef tp_memcpy_gen
+#define tp_memcpy_gen(write_ops, dest, src, len)                       \
+__assign_##dest:                                                       \
+       if (0)                                                          \
+               (void) __typemap.dest;                                  \
+       lib_ring_buffer_align_ctx(&__ctx, lttng_alignof(__typemap.dest));       \
+       __chan->ops->write_ops(&__ctx, src, len);                       \
+       goto __end_field_##dest;
+
+#undef tp_memcpy
+#define tp_memcpy(dest, src, len)                                      \
+       tp_memcpy_gen(event_write, dest, src, len)
+
+#undef tp_memcpy_from_user
+#define tp_memcpy_from_user(dest, src, len)                            \
+       tp_memcpy_gen(event_write_from_user, dest, src, len)
+
+/* variable length sequence memcpy */
+#undef tp_memcpy_dyn_gen
+#define tp_memcpy_dyn_gen(write_ops, dest, src)                                \
+__assign_##dest##_1:                                                   \
+       {                                                               \
+               u32 __tmpl = __dynamic_len[__dynamic_len_idx];          \
+               lib_ring_buffer_align_ctx(&__ctx, lttng_alignof(u32));  \
+               __chan->ops->event_write(&__ctx, &__tmpl, sizeof(u32)); \
+       }                                                               \
+       goto __end_field_##dest##_1;                                    \
+__assign_##dest##_2:                                                   \
+       lib_ring_buffer_align_ctx(&__ctx, lttng_alignof(__typemap.dest));       \
+       __chan->ops->write_ops(&__ctx, src,                             \
+               sizeof(__typemap.dest) * __get_dynamic_array_len(dest));\
+       goto __end_field_##dest##_2;
+
+#undef tp_memcpy_dyn_gen_2
+#define tp_memcpy_dyn_gen_2(write_ops, dest, src1, src2)               \
+__assign_##dest##_1:                                                   \
+       {                                                               \
+               u32 __tmpl = __dynamic_len[__dynamic_len_idx]           \
+                       + __dynamic_len[__dynamic_len_idx + 1];         \
+               lib_ring_buffer_align_ctx(&__ctx, lttng_alignof(u32));  \
+               __chan->ops->event_write(&__ctx, &__tmpl, sizeof(u32)); \
+       }                                                               \
+       goto __end_field_##dest##_1;                                    \
+__assign_##dest##_2:                                                   \
+       lib_ring_buffer_align_ctx(&__ctx, lttng_alignof(__typemap.dest));       \
+       __chan->ops->write_ops(&__ctx, src1,                            \
+               sizeof(__typemap.dest) * __get_dynamic_array_len(dest));\
+       goto __end_field_##dest##_2;                                    \
+__assign_##dest##_3:                                                   \
+       __chan->ops->write_ops(&__ctx, src2,                            \
+               sizeof(__typemap.dest) * __get_dynamic_array_len(dest));\
+       goto __end_field_##dest##_3;
+
+#undef tp_memcpy_dyn
+#define tp_memcpy_dyn(dest, src)                                       \
+       tp_memcpy_dyn_gen(event_write, dest, src)
+
+#undef tp_memcpy_dyn_2
+#define tp_memcpy_dyn_2(dest, src1, src2)                              \
+       tp_memcpy_dyn_gen_2(event_write, dest, src1, src2)
+
+#undef tp_memcpy_dyn_from_user
+#define tp_memcpy_dyn_from_user(dest, src)                             \
+       tp_memcpy_dyn_gen(event_write_from_user, dest, src)
+
+/*
+ * The string length including the final \0.
+ */
+#undef tp_copy_string_from_user
+#define tp_copy_string_from_user(dest, src)                            \
+       __assign_##dest:                                                \
+       {                                                               \
+               size_t __ustrlen;                                       \
+                                                                       \
+               if (0)                                                  \
+                       (void) __typemap.dest;                          \
+               lib_ring_buffer_align_ctx(&__ctx, lttng_alignof(__typemap.dest));\
+               __ustrlen = __get_dynamic_array_len(dest);              \
+               if (likely(__ustrlen > 1)) {                            \
+                       __chan->ops->event_write_from_user(&__ctx, src, \
+                               __ustrlen - 1);                         \
+               }                                                       \
+               __chan->ops->event_memset(&__ctx, 0, 1);                \
+       }                                                               \
+       goto __end_field_##dest;
+#undef tp_strcpy
+#define tp_strcpy(dest, src)                                           \
+       tp_memcpy(dest, src, __get_dynamic_array_len(dest))
+
+/* Named field types must be defined in lttng-types.h */
+
+#undef __get_str
+#define __get_str(field)               field
+
+#undef __get_dynamic_array
+#define __get_dynamic_array(field)     field
+
+/* Beware: this get len actually consumes the len value */
+#undef __get_dynamic_array_len
+#define __get_dynamic_array_len(field) __dynamic_len[__dynamic_len_idx++]
+
+#undef TP_PROTO
+#define TP_PROTO(args...) args
+
+#undef TP_ARGS
+#define TP_ARGS(args...) args
+
+#undef TP_STRUCT__entry
+#define TP_STRUCT__entry(args...) args
+
+#undef TP_fast_assign
+#define TP_fast_assign(args...) args
+
+/*
+ * For state dump, check that "session" argument (mandatory) matches the
+ * session this event belongs to. Ensures that we write state dump data only
+ * into the started session, not into all sessions.
+ */
+#ifdef TP_SESSION_CHECK
+#define _TP_SESSION_CHECK(session, csession)   (session == csession)
+#else /* TP_SESSION_CHECK */
+#define _TP_SESSION_CHECK(session, csession)   1
+#endif /* TP_SESSION_CHECK */
+
+/*
+ * __dynamic_len array length is twice the number of fields due to
+ * __dynamic_array_enc_ext_2() and tp_memcpy_dyn_2(), which are the
+ * worse case, needing 2 entries per field.
+ */
+#undef DECLARE_EVENT_CLASS
+#define DECLARE_EVENT_CLASS(_name, _proto, _args, _tstruct, _assign, _print)  \
+static void __event_probe__##_name(void *__data, _proto)                     \
+{                                                                            \
+       struct lttng_event *__event = __data;                                 \
+       struct lttng_channel *__chan = __event->chan;                         \
+       struct lib_ring_buffer_ctx __ctx;                                     \
+       size_t __event_len, __event_align;                                    \
+       size_t __dynamic_len_idx = 0;                                         \
+       size_t __dynamic_len[2 * ARRAY_SIZE(__event_fields___##_name)];       \
+       struct __event_typemap__##_name __typemap;                            \
+       int __ret;                                                            \
+                                                                             \
+       if (0) {                                                              \
+               (void) __dynamic_len_idx;       /* don't warn if unused */    \
+               (void) __typemap;               /* don't warn if unused */    \
+       }                                                                     \
+       if (!_TP_SESSION_CHECK(session, __chan->session))                     \
+               return;                                                       \
+       if (unlikely(!ACCESS_ONCE(__chan->session->active)))                  \
+               return;                                                       \
+       if (unlikely(!ACCESS_ONCE(__chan->enabled)))                          \
+               return;                                                       \
+       if (unlikely(!ACCESS_ONCE(__event->enabled)))                         \
+               return;                                                       \
+       __event_len = __event_get_size__##_name(__dynamic_len, _args);        \
+       __event_align = __event_get_align__##_name(_args);                    \
+       lib_ring_buffer_ctx_init(&__ctx, __chan->chan, __event, __event_len,  \
+                                __event_align, -1);                          \
+       __ret = __chan->ops->event_reserve(&__ctx, __event->id);              \
+       if (__ret < 0)                                                        \
+               return;                                                       \
+       /* Control code (field ordering) */                                   \
+       _tstruct                                                              \
+       __chan->ops->event_commit(&__ctx);                                    \
+       return;                                                               \
+       /* Copy code, steered by control code */                              \
+       _assign                                                               \
+}
+
+#undef DECLARE_EVENT_CLASS_NOARGS
+#define DECLARE_EVENT_CLASS_NOARGS(_name, _tstruct, _assign, _print)         \
+static void __event_probe__##_name(void *__data)                             \
+{                                                                            \
+       struct lttng_event *__event = __data;                                 \
+       struct lttng_channel *__chan = __event->chan;                         \
+       struct lib_ring_buffer_ctx __ctx;                                     \
+       size_t __event_len, __event_align;                                    \
+       int __ret;                                                            \
+                                                                             \
+       if (!_TP_SESSION_CHECK(session, __chan->session))                     \
+               return;                                                       \
+       if (unlikely(!ACCESS_ONCE(__chan->session->active)))                  \
+               return;                                                       \
+       if (unlikely(!ACCESS_ONCE(__chan->enabled)))                          \
+               return;                                                       \
+       if (unlikely(!ACCESS_ONCE(__event->enabled)))                         \
+               return;                                                       \
+       __event_len = 0;                                                      \
+       __event_align = 1;                                                    \
+       lib_ring_buffer_ctx_init(&__ctx, __chan->chan, __event, __event_len,  \
+                                __event_align, -1);                          \
+       __ret = __chan->ops->event_reserve(&__ctx, __event->id);              \
+       if (__ret < 0)                                                        \
+               return;                                                       \
+       /* Control code (field ordering) */                                   \
+       _tstruct                                                              \
+       __chan->ops->event_commit(&__ctx);                                    \
+       return;                                                               \
+       /* Copy code, steered by control code */                              \
+       _assign                                                               \
+}
+
+#include TRACE_INCLUDE(TRACE_INCLUDE_FILE)
+
+/*
+ * Stage 10 of the trace events.
+ *
+ * Register/unregister probes at module load/unload.
+ */
+
+#include "lttng-events-reset.h"        /* Reset all macros within TRACE_EVENT */
+
+#define TP_ID1(_token, _system)        _token##_system
+#define TP_ID(_token, _system) TP_ID1(_token, _system)
+#define module_init_eval1(_token, _system)     module_init(_token##_system)
+#define module_init_eval(_token, _system)      module_init_eval1(_token, _system)
+#define module_exit_eval1(_token, _system)     module_exit(_token##_system)
+#define module_exit_eval(_token, _system)      module_exit_eval1(_token, _system)
+
+#ifndef TP_MODULE_NOINIT
+static int TP_ID(__lttng_events_init__, TRACE_SYSTEM)(void)
+{
+       wrapper_vmalloc_sync_all();
+       return lttng_probe_register(&TP_ID(__probe_desc___, TRACE_SYSTEM));
+}
+
+static void TP_ID(__lttng_events_exit__, TRACE_SYSTEM)(void)
+{
+       lttng_probe_unregister(&TP_ID(__probe_desc___, TRACE_SYSTEM));
+}
+
+#ifndef TP_MODULE_NOAUTOLOAD
+module_init_eval(__lttng_events_init__, TRACE_SYSTEM);
+module_exit_eval(__lttng_events_exit__, TRACE_SYSTEM);
+#endif
+
+#endif
+
+#undef module_init_eval
+#undef module_exit_eval
+#undef TP_ID1
+#undef TP_ID
+
+#undef TP_PROTO
+#undef TP_ARGS
+#undef TRACE_EVENT_FLAGS
diff --git a/drivers/staging/lttng/probes/lttng-ftrace.c b/drivers/staging/lttng/probes/lttng-ftrace.c
new file mode 100644 (file)
index 0000000..bb70df6
--- /dev/null
@@ -0,0 +1,201 @@
+/*
+ * probes/lttng-ftrace.c
+ *
+ * LTTng function tracer integration module.
+ *
+ * Copyright (C) 2009-2012 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; only
+ * version 2.1 of the License.
+ *
+ * This library 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
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+/*
+ * Ftrace function tracer does not seem to provide synchronization between probe
+ * teardown and callback execution. Therefore, we make this module permanently
+ * loaded (unloadable).
+ *
+ * TODO: Move to register_ftrace_function() (which is exported for
+ * modules) for Linux >= 3.0. It is faster (only enables the selected
+ * functions), and will stay there.
+ */
+
+#include <linux/module.h>
+#include <linux/ftrace.h>
+#include <linux/slab.h>
+#include "../lttng-events.h"
+#include "../wrapper/ringbuffer/frontend_types.h"
+#include "../wrapper/ftrace.h"
+#include "../wrapper/vmalloc.h"
+#include "../lttng-tracer.h"
+
+static
+void lttng_ftrace_handler(unsigned long ip, unsigned long parent_ip, void **data)
+{
+       struct lttng_event *event = *data;
+       struct lttng_channel *chan = event->chan;
+       struct lib_ring_buffer_ctx ctx;
+       struct {
+               unsigned long ip;
+               unsigned long parent_ip;
+       } payload;
+       int ret;
+
+       if (unlikely(!ACCESS_ONCE(chan->session->active)))
+               return;
+       if (unlikely(!ACCESS_ONCE(chan->enabled)))
+               return;
+       if (unlikely(!ACCESS_ONCE(event->enabled)))
+               return;
+
+       lib_ring_buffer_ctx_init(&ctx, chan->chan, event,
+                                sizeof(payload), lttng_alignof(payload), -1);
+       ret = chan->ops->event_reserve(&ctx, event->id);
+       if (ret < 0)
+               return;
+       payload.ip = ip;
+       payload.parent_ip = parent_ip;
+       lib_ring_buffer_align_ctx(&ctx, lttng_alignof(payload));
+       chan->ops->event_write(&ctx, &payload, sizeof(payload));
+       chan->ops->event_commit(&ctx);
+       return;
+}
+
+/*
+ * Create event description
+ */
+static
+int lttng_create_ftrace_event(const char *name, struct lttng_event *event)
+{
+       struct lttng_event_field *fields;
+       struct lttng_event_desc *desc;
+       int ret;
+
+       desc = kzalloc(sizeof(*event->desc), GFP_KERNEL);
+       if (!desc)
+               return -ENOMEM;
+       desc->name = kstrdup(name, GFP_KERNEL);
+       if (!desc->name) {
+               ret = -ENOMEM;
+               goto error_str;
+       }
+       desc->nr_fields = 2;
+       desc->fields = fields =
+               kzalloc(2 * sizeof(struct lttng_event_field), GFP_KERNEL);
+       if (!desc->fields) {
+               ret = -ENOMEM;
+               goto error_fields;
+       }
+       fields[0].name = "ip";
+       fields[0].type.atype = atype_integer;
+       fields[0].type.u.basic.integer.size = sizeof(unsigned long) * CHAR_BIT;
+       fields[0].type.u.basic.integer.alignment = lttng_alignof(unsigned long) * CHAR_BIT;
+       fields[0].type.u.basic.integer.signedness = lttng_is_signed_type(unsigned long);
+       fields[0].type.u.basic.integer.reverse_byte_order = 0;
+       fields[0].type.u.basic.integer.base = 16;
+       fields[0].type.u.basic.integer.encoding = lttng_encode_none;
+
+       fields[1].name = "parent_ip";
+       fields[1].type.atype = atype_integer;
+       fields[1].type.u.basic.integer.size = sizeof(unsigned long) * CHAR_BIT;
+       fields[1].type.u.basic.integer.alignment = lttng_alignof(unsigned long) * CHAR_BIT;
+       fields[1].type.u.basic.integer.signedness = lttng_is_signed_type(unsigned long);
+       fields[1].type.u.basic.integer.reverse_byte_order = 0;
+       fields[1].type.u.basic.integer.base = 16;
+       fields[1].type.u.basic.integer.encoding = lttng_encode_none;
+
+       desc->owner = THIS_MODULE;
+       event->desc = desc;
+
+       return 0;
+
+error_fields:
+       kfree(desc->name);
+error_str:
+       kfree(desc);
+       return ret;
+}
+
+static
+struct ftrace_probe_ops lttng_ftrace_ops = {
+       .func = lttng_ftrace_handler,
+};
+
+int lttng_ftrace_register(const char *name,
+                         const char *symbol_name,
+                         struct lttng_event *event)
+{
+       int ret;
+
+       ret = lttng_create_ftrace_event(name, event);
+       if (ret)
+               goto error;
+
+       event->u.ftrace.symbol_name = kstrdup(symbol_name, GFP_KERNEL);
+       if (!event->u.ftrace.symbol_name)
+               goto name_error;
+
+       /* Ensure the memory we just allocated don't trigger page faults */
+       wrapper_vmalloc_sync_all();
+
+       ret = wrapper_register_ftrace_function_probe(event->u.ftrace.symbol_name,
+                       &lttng_ftrace_ops, event);
+       if (ret < 0)
+               goto register_error;
+       return 0;
+
+register_error:
+       kfree(event->u.ftrace.symbol_name);
+name_error:
+       kfree(event->desc->name);
+       kfree(event->desc);
+error:
+       return ret;
+}
+EXPORT_SYMBOL_GPL(lttng_ftrace_register);
+
+void lttng_ftrace_unregister(struct lttng_event *event)
+{
+       wrapper_unregister_ftrace_function_probe(event->u.ftrace.symbol_name,
+                       &lttng_ftrace_ops, event);
+}
+EXPORT_SYMBOL_GPL(lttng_ftrace_unregister);
+
+void lttng_ftrace_destroy_private(struct lttng_event *event)
+{
+       kfree(event->u.ftrace.symbol_name);
+       kfree(event->desc->fields);
+       kfree(event->desc->name);
+       kfree(event->desc);
+}
+EXPORT_SYMBOL_GPL(lttng_ftrace_destroy_private);
+
+int lttng_ftrace_init(void)
+{
+       wrapper_vmalloc_sync_all();
+       return 0;
+}
+module_init(lttng_ftrace_init)
+
+/*
+ * Ftrace takes care of waiting for a grace period (RCU sched) at probe
+ * unregistration, and disables preemption around probe call.
+ */
+void lttng_ftrace_exit(void)
+{
+}
+module_exit(lttng_ftrace_exit)
+
+MODULE_LICENSE("GPL and additional rights");
+MODULE_AUTHOR("Mathieu Desnoyers");
+MODULE_DESCRIPTION("Linux Trace Toolkit Ftrace Support");
diff --git a/drivers/staging/lttng/probes/lttng-kprobes.c b/drivers/staging/lttng/probes/lttng-kprobes.c
new file mode 100644 (file)
index 0000000..fbd24e1
--- /dev/null
@@ -0,0 +1,177 @@
+/*
+ * probes/lttng-kprobes.c
+ *
+ * LTTng kprobes integration module.
+ *
+ * Copyright (C) 2009-2012 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; only
+ * version 2.1 of the License.
+ *
+ * This library 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
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include <linux/module.h>
+#include <linux/kprobes.h>
+#include <linux/slab.h>
+#include "../lttng-events.h"
+#include "../wrapper/ringbuffer/frontend_types.h"
+#include "../wrapper/vmalloc.h"
+#include "../lttng-tracer.h"
+
+static
+int lttng_kprobes_handler_pre(struct kprobe *p, struct pt_regs *regs)
+{
+       struct lttng_event *event =
+               container_of(p, struct lttng_event, u.kprobe.kp);
+       struct lttng_channel *chan = event->chan;
+       struct lib_ring_buffer_ctx ctx;
+       int ret;
+       unsigned long data = (unsigned long) p->addr;
+
+       if (unlikely(!ACCESS_ONCE(chan->session->active)))
+               return 0;
+       if (unlikely(!ACCESS_ONCE(chan->enabled)))
+               return 0;
+       if (unlikely(!ACCESS_ONCE(event->enabled)))
+               return 0;
+
+       lib_ring_buffer_ctx_init(&ctx, chan->chan, event, sizeof(data),
+                                lttng_alignof(data), -1);
+       ret = chan->ops->event_reserve(&ctx, event->id);
+       if (ret < 0)
+               return 0;
+       lib_ring_buffer_align_ctx(&ctx, lttng_alignof(data));
+       chan->ops->event_write(&ctx, &data, sizeof(data));
+       chan->ops->event_commit(&ctx);
+       return 0;
+}
+
+/*
+ * Create event description
+ */
+static
+int lttng_create_kprobe_event(const char *name, struct lttng_event *event)
+{
+       struct lttng_event_field *field;
+       struct lttng_event_desc *desc;
+       int ret;
+
+       desc = kzalloc(sizeof(*event->desc), GFP_KERNEL);
+       if (!desc)
+               return -ENOMEM;
+       desc->name = kstrdup(name, GFP_KERNEL);
+       if (!desc->name) {
+               ret = -ENOMEM;
+               goto error_str;
+       }
+       desc->nr_fields = 1;
+       desc->fields = field =
+               kzalloc(1 * sizeof(struct lttng_event_field), GFP_KERNEL);
+       if (!field) {
+               ret = -ENOMEM;
+               goto error_field;
+       }
+       field->name = "ip";
+       field->type.atype = atype_integer;
+       field->type.u.basic.integer.size = sizeof(unsigned long) * CHAR_BIT;
+       field->type.u.basic.integer.alignment = lttng_alignof(unsigned long) * CHAR_BIT;
+       field->type.u.basic.integer.signedness = lttng_is_signed_type(unsigned long);
+       field->type.u.basic.integer.reverse_byte_order = 0;
+       field->type.u.basic.integer.base = 16;
+       field->type.u.basic.integer.encoding = lttng_encode_none;
+       desc->owner = THIS_MODULE;
+       event->desc = desc;
+
+       return 0;
+
+error_field:
+       kfree(desc->name);
+error_str:
+       kfree(desc);
+       return ret;
+}
+
+int lttng_kprobes_register(const char *name,
+                          const char *symbol_name,
+                          uint64_t offset,
+                          uint64_t addr,
+                          struct lttng_event *event)
+{
+       int ret;
+
+       /* Kprobes expects a NULL symbol name if unused */
+       if (symbol_name[0] == '\0')
+               symbol_name = NULL;
+
+       ret = lttng_create_kprobe_event(name, event);
+       if (ret)
+               goto error;
+       memset(&event->u.kprobe.kp, 0, sizeof(event->u.kprobe.kp));
+       event->u.kprobe.kp.pre_handler = lttng_kprobes_handler_pre;
+       if (symbol_name) {
+               event->u.kprobe.symbol_name =
+                       kzalloc(LTTNG_KERNEL_SYM_NAME_LEN * sizeof(char),
+                               GFP_KERNEL);
+               if (!event->u.kprobe.symbol_name) {
+                       ret = -ENOMEM;
+                       goto name_error;
+               }
+               memcpy(event->u.kprobe.symbol_name, symbol_name,
+                      LTTNG_KERNEL_SYM_NAME_LEN * sizeof(char));
+               event->u.kprobe.kp.symbol_name =
+                       event->u.kprobe.symbol_name;
+       }
+       event->u.kprobe.kp.offset = offset;
+       event->u.kprobe.kp.addr = (void *) (unsigned long) addr;
+
+       /*
+        * Ensure the memory we just allocated don't trigger page faults.
+        * Well.. kprobes itself puts the page fault handler on the blacklist,
+        * but we can never be too careful.
+        */
+       wrapper_vmalloc_sync_all();
+
+       ret = register_kprobe(&event->u.kprobe.kp);
+       if (ret)
+               goto register_error;
+       return 0;
+
+register_error:
+       kfree(event->u.kprobe.symbol_name);
+name_error:
+       kfree(event->desc->fields);
+       kfree(event->desc->name);
+       kfree(event->desc);
+error:
+       return ret;
+}
+EXPORT_SYMBOL_GPL(lttng_kprobes_register);
+
+void lttng_kprobes_unregister(struct lttng_event *event)
+{
+       unregister_kprobe(&event->u.kprobe.kp);
+}
+EXPORT_SYMBOL_GPL(lttng_kprobes_unregister);
+
+void lttng_kprobes_destroy_private(struct lttng_event *event)
+{
+       kfree(event->u.kprobe.symbol_name);
+       kfree(event->desc->fields);
+       kfree(event->desc->name);
+       kfree(event->desc);
+}
+EXPORT_SYMBOL_GPL(lttng_kprobes_destroy_private);
+
+MODULE_LICENSE("GPL and additional rights");
+MODULE_AUTHOR("Mathieu Desnoyers");
+MODULE_DESCRIPTION("Linux Trace Toolkit Kprobes Support");
diff --git a/drivers/staging/lttng/probes/lttng-kretprobes.c b/drivers/staging/lttng/probes/lttng-kretprobes.c
new file mode 100644 (file)
index 0000000..6b5e046
--- /dev/null
@@ -0,0 +1,290 @@
+/*
+ * probes/lttng-kretprobes.c
+ *
+ * LTTng kretprobes integration module.
+ *
+ * Copyright (C) 2009-2012 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; only
+ * version 2.1 of the License.
+ *
+ * This library 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
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include <linux/module.h>
+#include <linux/kprobes.h>
+#include <linux/slab.h>
+#include <linux/kref.h>
+#include "../lttng-events.h"
+#include "../wrapper/ringbuffer/frontend_types.h"
+#include "../wrapper/vmalloc.h"
+#include "../lttng-tracer.h"
+
+enum lttng_kretprobe_type {
+       EVENT_ENTRY = 0,
+       EVENT_RETURN = 1,
+};
+
+struct lttng_krp {
+       struct kretprobe krp;
+       struct lttng_event *event[2];   /* ENTRY and RETURN */
+       struct kref kref_register;
+       struct kref kref_alloc;
+};
+
+static
+int _lttng_kretprobes_handler(struct kretprobe_instance *krpi,
+                             struct pt_regs *regs,
+                             enum lttng_kretprobe_type type)
+{
+       struct lttng_krp *lttng_krp =
+               container_of(krpi->rp, struct lttng_krp, krp);
+       struct lttng_event *event =
+               lttng_krp->event[type];
+       struct lttng_channel *chan = event->chan;
+       struct lib_ring_buffer_ctx ctx;
+       int ret;
+       struct {
+               unsigned long ip;
+               unsigned long parent_ip;
+       } payload;
+
+       if (unlikely(!ACCESS_ONCE(chan->session->active)))
+               return 0;
+       if (unlikely(!ACCESS_ONCE(chan->enabled)))
+               return 0;
+       if (unlikely(!ACCESS_ONCE(event->enabled)))
+               return 0;
+
+       payload.ip = (unsigned long) krpi->rp->kp.addr;
+       payload.parent_ip = (unsigned long) krpi->ret_addr;
+
+       lib_ring_buffer_ctx_init(&ctx, chan->chan, event, sizeof(payload),
+                                lttng_alignof(payload), -1);
+       ret = chan->ops->event_reserve(&ctx, event->id);
+       if (ret < 0)
+               return 0;
+       lib_ring_buffer_align_ctx(&ctx, lttng_alignof(payload));
+       chan->ops->event_write(&ctx, &payload, sizeof(payload));
+       chan->ops->event_commit(&ctx);
+       return 0;
+}
+
+static
+int lttng_kretprobes_handler_entry(struct kretprobe_instance *krpi,
+                                  struct pt_regs *regs)
+{
+       return _lttng_kretprobes_handler(krpi, regs, EVENT_ENTRY);
+}
+
+static
+int lttng_kretprobes_handler_return(struct kretprobe_instance *krpi,
+                                   struct pt_regs *regs)
+{
+       return _lttng_kretprobes_handler(krpi, regs, EVENT_RETURN);
+}
+
+/*
+ * Create event description
+ */
+static
+int lttng_create_kprobe_event(const char *name, struct lttng_event *event,
+                             enum lttng_kretprobe_type type)
+{
+       struct lttng_event_field *fields;
+       struct lttng_event_desc *desc;
+       int ret;
+       char *alloc_name;
+       size_t name_len;
+       const char *suffix = NULL;
+
+       desc = kzalloc(sizeof(*event->desc), GFP_KERNEL);
+       if (!desc)
+               return -ENOMEM;
+       name_len = strlen(name);
+       switch (type) {
+       case EVENT_ENTRY:
+               suffix = "_entry";
+               break;
+       case EVENT_RETURN:
+               suffix = "_return";
+               break;
+       }
+       name_len += strlen(suffix);
+       alloc_name = kmalloc(name_len + 1, GFP_KERNEL);
+       if (!alloc_name) {
+               ret = -ENOMEM;
+               goto error_str;
+       }
+       strcpy(alloc_name, name);
+       strcat(alloc_name, suffix);
+       desc->name = alloc_name;
+       desc->nr_fields = 2;
+       desc->fields = fields =
+               kzalloc(2 * sizeof(struct lttng_event_field), GFP_KERNEL);
+       if (!desc->fields) {
+               ret = -ENOMEM;
+               goto error_fields;
+       }
+       fields[0].name = "ip";
+       fields[0].type.atype = atype_integer;
+       fields[0].type.u.basic.integer.size = sizeof(unsigned long) * CHAR_BIT;
+       fields[0].type.u.basic.integer.alignment = lttng_alignof(unsigned long) * CHAR_BIT;
+       fields[0].type.u.basic.integer.signedness = lttng_is_signed_type(unsigned long);
+       fields[0].type.u.basic.integer.reverse_byte_order = 0;
+       fields[0].type.u.basic.integer.base = 16;
+       fields[0].type.u.basic.integer.encoding = lttng_encode_none;
+
+       fields[1].name = "parent_ip";
+       fields[1].type.atype = atype_integer;
+       fields[1].type.u.basic.integer.size = sizeof(unsigned long) * CHAR_BIT;
+       fields[1].type.u.basic.integer.alignment = lttng_alignof(unsigned long) * CHAR_BIT;
+       fields[1].type.u.basic.integer.signedness = lttng_is_signed_type(unsigned long);
+       fields[1].type.u.basic.integer.reverse_byte_order = 0;
+       fields[1].type.u.basic.integer.base = 16;
+       fields[1].type.u.basic.integer.encoding = lttng_encode_none;
+
+       desc->owner = THIS_MODULE;
+       event->desc = desc;
+
+       return 0;
+
+error_fields:
+       kfree(desc->name);
+error_str:
+       kfree(desc);
+       return ret;
+}
+
+int lttng_kretprobes_register(const char *name,
+                          const char *symbol_name,
+                          uint64_t offset,
+                          uint64_t addr,
+                          struct lttng_event *event_entry,
+                          struct lttng_event *event_return)
+{
+       int ret;
+       struct lttng_krp *lttng_krp;
+
+       /* Kprobes expects a NULL symbol name if unused */
+       if (symbol_name[0] == '\0')
+               symbol_name = NULL;
+
+       ret = lttng_create_kprobe_event(name, event_entry, EVENT_ENTRY);
+       if (ret)
+               goto error;
+       ret = lttng_create_kprobe_event(name, event_return, EVENT_RETURN);
+       if (ret)
+               goto event_return_error;
+       lttng_krp = kzalloc(sizeof(*lttng_krp), GFP_KERNEL);
+       if (!lttng_krp)
+               goto krp_error;
+       lttng_krp->krp.entry_handler = lttng_kretprobes_handler_entry;
+       lttng_krp->krp.handler = lttng_kretprobes_handler_return;
+       if (symbol_name) {
+               char *alloc_symbol;
+
+               alloc_symbol = kstrdup(symbol_name, GFP_KERNEL);
+               if (!alloc_symbol) {
+                       ret = -ENOMEM;
+                       goto name_error;
+               }
+               lttng_krp->krp.kp.symbol_name =
+                       alloc_symbol;
+               event_entry->u.kretprobe.symbol_name =
+                       alloc_symbol;
+               event_return->u.kretprobe.symbol_name =
+                       alloc_symbol;
+       }
+       lttng_krp->krp.kp.offset = offset;
+       lttng_krp->krp.kp.addr = (void *) (unsigned long) addr;
+
+       /* Allow probe handler to find event structures */
+       lttng_krp->event[EVENT_ENTRY] = event_entry;
+       lttng_krp->event[EVENT_RETURN] = event_return;
+       event_entry->u.kretprobe.lttng_krp = lttng_krp;
+       event_return->u.kretprobe.lttng_krp = lttng_krp;
+
+       /*
+        * Both events must be unregistered before the kretprobe is
+        * unregistered. Same for memory allocation.
+        */
+       kref_init(&lttng_krp->kref_alloc);
+       kref_get(&lttng_krp->kref_alloc);       /* inc refcount to 2 */
+       kref_init(&lttng_krp->kref_register);
+       kref_get(&lttng_krp->kref_register);    /* inc refcount to 2 */
+
+       /*
+        * Ensure the memory we just allocated don't trigger page faults.
+        * Well.. kprobes itself puts the page fault handler on the blacklist,
+        * but we can never be too careful.
+        */
+       wrapper_vmalloc_sync_all();
+
+       ret = register_kretprobe(&lttng_krp->krp);
+       if (ret)
+               goto register_error;
+       return 0;
+
+register_error:
+       kfree(lttng_krp->krp.kp.symbol_name);
+name_error:
+       kfree(lttng_krp);
+krp_error:
+       kfree(event_return->desc->fields);
+       kfree(event_return->desc->name);
+       kfree(event_return->desc);
+event_return_error:
+       kfree(event_entry->desc->fields);
+       kfree(event_entry->desc->name);
+       kfree(event_entry->desc);
+error:
+       return ret;
+}
+EXPORT_SYMBOL_GPL(lttng_kretprobes_register);
+
+static
+void _lttng_kretprobes_unregister_release(struct kref *kref)
+{
+       struct lttng_krp *lttng_krp =
+               container_of(kref, struct lttng_krp, kref_register);
+       unregister_kretprobe(&lttng_krp->krp);
+}
+
+void lttng_kretprobes_unregister(struct lttng_event *event)
+{
+       kref_put(&event->u.kretprobe.lttng_krp->kref_register,
+               _lttng_kretprobes_unregister_release);
+}
+EXPORT_SYMBOL_GPL(lttng_kretprobes_unregister);
+
+static
+void _lttng_kretprobes_release(struct kref *kref)
+{
+       struct lttng_krp *lttng_krp =
+               container_of(kref, struct lttng_krp, kref_alloc);
+       kfree(lttng_krp->krp.kp.symbol_name);
+}
+
+void lttng_kretprobes_destroy_private(struct lttng_event *event)
+{
+       kfree(event->desc->fields);
+       kfree(event->desc->name);
+       kfree(event->desc);
+       kref_put(&event->u.kretprobe.lttng_krp->kref_alloc,
+               _lttng_kretprobes_release);
+}
+EXPORT_SYMBOL_GPL(lttng_kretprobes_destroy_private);
+
+MODULE_LICENSE("GPL and additional rights");
+MODULE_AUTHOR("Mathieu Desnoyers");
+MODULE_DESCRIPTION("Linux Trace Toolkit Kretprobes Support");
diff --git a/drivers/staging/lttng/probes/lttng-probe-asoc.c b/drivers/staging/lttng/probes/lttng-probe-asoc.c
new file mode 100644 (file)
index 0000000..ad54a37
--- /dev/null
@@ -0,0 +1,45 @@
+/*
+ * probes/lttng-probe-asoc.c
+ *
+ * LTTng asoc probes.
+ *
+ * Copyright (C) 2010-2012 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
+ * Copyright (C) 2012 Mentor Graphics Corp.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; only
+ * version 2.1 of the License.
+ *
+ * This library 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
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include <linux/module.h>
+#include <sound/jack.h>
+#include <sound/soc.h>
+
+/*
+ * Create the tracepoint static inlines from the kernel to validate that our
+ * trace event macros match the kernel we run on.
+ */
+#include <trace/events/asoc.h>
+
+/*
+ * Create LTTng tracepoint probes.
+ */
+#define LTTNG_PACKAGE_BUILD
+#define CREATE_TRACE_POINTS
+#define TRACE_INCLUDE_PATH ../instrumentation/events/lttng-module
+
+#include "../instrumentation/events/lttng-module/asoc.h"
+
+MODULE_LICENSE("GPL and additional rights");
+MODULE_AUTHOR("Wade Farnsworth <wade_farnsworth@mentor.com>, Paul Woegerer <paul_woegerer@mentor.com>, and Andrew Gabbasov <andrew_gabbasov@mentor.com>");
+MODULE_DESCRIPTION("LTTng asoc probes");
diff --git a/drivers/staging/lttng/probes/lttng-probe-block.c b/drivers/staging/lttng/probes/lttng-probe-block.c
new file mode 100644 (file)
index 0000000..3eb668f
--- /dev/null
@@ -0,0 +1,45 @@
+/*
+ * probes/lttng-probe-block.c
+ *
+ * LTTng block probes.
+ *
+ * Copyright (C) 2010-2012 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; only
+ * version 2.1 of the License.
+ *
+ * This library 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
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include <linux/module.h>
+#include <linux/blktrace_api.h>
+
+/*
+ * Create the tracepoint static inlines from the kernel to validate that our
+ * trace event macros match the kernel we run on.
+ */
+#include <trace/events/block.h>
+
+#include "../wrapper/tracepoint.h"
+
+/*
+ * Create LTTng tracepoint probes.
+ */
+#define LTTNG_PACKAGE_BUILD
+#define CREATE_TRACE_POINTS
+#define TRACE_INCLUDE_PATH ../instrumentation/events/lttng-module
+
+#include "../instrumentation/events/lttng-module/block.h"
+
+MODULE_LICENSE("GPL and additional rights");
+MODULE_AUTHOR("Mathieu Desnoyers <mathieu.desnoyers@efficios.com>");
+MODULE_DESCRIPTION("LTTng block probes");
diff --git a/drivers/staging/lttng/probes/lttng-probe-btrfs.c b/drivers/staging/lttng/probes/lttng-probe-btrfs.c
new file mode 100644 (file)
index 0000000..4b5f84e
--- /dev/null
@@ -0,0 +1,48 @@
+/*
+ * probes/lttng-probe-btrfs.c
+ *
+ * LTTng btrfs probes.
+ *
+ * Copyright (C) 2010-2012 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
+ * Copyright (C) 2012 Mentor Graphics Corp.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; only
+ * version 2.1 of the License.
+ *
+ * This library 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
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include <linux/module.h>
+#include <linux/fs.h>
+#include <../fs/btrfs/ctree.h>
+#include <../fs/btrfs/transaction.h>
+#include <../fs/btrfs/volumes.h>
+#include <linux/dcache.h>
+
+/*
+ * Create the tracepoint static inlines from the kernel to validate that our
+ * trace event macros match the kernel we run on.
+ */
+#include <trace/events/btrfs.h>
+
+/*
+ * Create LTTng tracepoint probes.
+ */
+#define LTTNG_PACKAGE_BUILD
+#define CREATE_TRACE_POINTS
+#define TRACE_INCLUDE_PATH ../instrumentation/events/lttng-module
+
+#include "../instrumentation/events/lttng-module/btrfs.h"
+
+MODULE_LICENSE("GPL and additional rights");
+MODULE_AUTHOR("Andrew Gabbasov <andrew_gabbasov@mentor.com>");
+MODULE_DESCRIPTION("LTTng btrfs probes");
diff --git a/drivers/staging/lttng/probes/lttng-probe-compaction.c b/drivers/staging/lttng/probes/lttng-probe-compaction.c
new file mode 100644 (file)
index 0000000..13b9959
--- /dev/null
@@ -0,0 +1,43 @@
+/*
+ * probes/lttng-probe-compaction.c
+ *
+ * LTTng compaction probes.
+ *
+ * Copyright (C) 2010-2012 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
+ * Copyright (C) 2012 Mentor Graphics Corp.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; only
+ * version 2.1 of the License.
+ *
+ * This library 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
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include <linux/module.h>
+
+/*
+ * Create the tracepoint static inlines from the kernel to validate that our
+ * trace event macros match the kernel we run on.
+ */
+#include <trace/events/compaction.h>
+
+/*
+ * Create LTTng tracepoint probes.
+ */
+#define LTTNG_PACKAGE_BUILD
+#define CREATE_TRACE_POINTS
+#define TRACE_INCLUDE_PATH ../instrumentation/events/lttng-module
+
+#include "../instrumentation/events/lttng-module/compaction.h"
+
+MODULE_LICENSE("GPL and additional rights");
+MODULE_AUTHOR("Andrew Gabbasov <andrew_gabbasov@mentor.com>");
+MODULE_DESCRIPTION("LTTng compaction probes");
diff --git a/drivers/staging/lttng/probes/lttng-probe-ext3.c b/drivers/staging/lttng/probes/lttng-probe-ext3.c
new file mode 100644 (file)
index 0000000..87c8cfb
--- /dev/null
@@ -0,0 +1,52 @@
+/*
+ * probes/lttng-probe-ext3.c
+ *
+ * LTTng ext3 probes.
+ *
+ * Copyright (C) 2010-2012 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
+ * Copyright (C) 2012 Mentor Graphics Corp.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; only
+ * version 2.1 of the License.
+ *
+ * This library 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
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include <linux/module.h>
+#include <linux/fs.h>
+#include <linux/dcache.h>
+#include <linux/version.h>
+
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,4,0))
+#include <../fs/ext3/ext3.h>
+#else
+#include <linux/ext3_fs_i.h>
+#endif
+
+/*
+ * Create the tracepoint static inlines from the kernel to validate that our
+ * trace event macros match the kernel we run on.
+ */
+#include <trace/events/ext3.h>
+
+/*
+ * Create LTTng tracepoint probes.
+ */
+#define LTTNG_PACKAGE_BUILD
+#define CREATE_TRACE_POINTS
+#define TRACE_INCLUDE_PATH ../instrumentation/events/lttng-module
+
+#include "../instrumentation/events/lttng-module/ext3.h"
+
+MODULE_LICENSE("GPL and additional rights");
+MODULE_AUTHOR("Wade Farnsworth <wade_farnsworth@mentor.com>, Paul Woegerer <paul_woegerer@mentor.com>, and Andrew Gabbasov <andrew_gabbasov@mentor.com>");
+MODULE_DESCRIPTION("LTTng ext3 probes");
diff --git a/drivers/staging/lttng/probes/lttng-probe-ext4.c b/drivers/staging/lttng/probes/lttng-probe-ext4.c
new file mode 100644 (file)
index 0000000..176186e
--- /dev/null
@@ -0,0 +1,51 @@
+/*
+ * probes/lttng-probe-ext4.c
+ *
+ * LTTng ext4 probes.
+ *
+ * Copyright (C) 2010-2012 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
+ * Copyright (C) 2012 Mentor Graphics Corp.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; only
+ * version 2.1 of the License.
+ *
+ * This library 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
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include <linux/module.h>
+#include <linux/fs.h>
+#include <../fs/ext4/ext4.h>
+#include <../fs/ext4/mballoc.h>
+#include <../fs/ext4/ext4_extents.h>
+#include <linux/dcache.h>
+
+/*
+ * Create the tracepoint static inlines from the kernel to validate that our
+ * trace event macros match the kernel we run on.
+ */
+#include <trace/events/ext4.h>
+
+#include "../lttng-kernel-version.h"
+#include "../wrapper/tracepoint.h"
+
+/*
+ * Create LTTng tracepoint probes.
+ */
+#define LTTNG_PACKAGE_BUILD
+#define CREATE_TRACE_POINTS
+#define TRACE_INCLUDE_PATH ../instrumentation/events/lttng-module
+
+#include "../instrumentation/events/lttng-module/ext4.h"
+
+MODULE_LICENSE("GPL and additional rights");
+MODULE_AUTHOR("Andrew Gabbasov <andrew_gabbasov@mentor.com>");
+MODULE_DESCRIPTION("LTTng ext4 probes");
diff --git a/drivers/staging/lttng/probes/lttng-probe-gpio.c b/drivers/staging/lttng/probes/lttng-probe-gpio.c
new file mode 100644 (file)
index 0000000..51692a7
--- /dev/null
@@ -0,0 +1,43 @@
+/*
+ * probes/lttng-probe-gpio.c
+ *
+ * LTTng gpio probes.
+ *
+ * Copyright (C) 2010-2012 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
+ * Copyright (C) 2012 Mentor Graphics Corp.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; only
+ * version 2.1 of the License.
+ *
+ * This library 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
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include <linux/module.h>
+
+/*
+ * Create the tracepoint static inlines from the kernel to validate that our
+ * trace event macros match the kernel we run on.
+ */
+#include <trace/events/gpio.h>
+
+/*
+ * Create LTTng tracepoint probes.
+ */
+#define LTTNG_PACKAGE_BUILD
+#define CREATE_TRACE_POINTS
+#define TRACE_INCLUDE_PATH ../instrumentation/events/lttng-module
+
+#include "../instrumentation/events/lttng-module/gpio.h"
+
+MODULE_LICENSE("GPL and additional rights");
+MODULE_AUTHOR("Wade Farnsworth <wade_farnsworth@mentor.com>");
+MODULE_DESCRIPTION("LTTng gpio probes");
diff --git a/drivers/staging/lttng/probes/lttng-probe-irq.c b/drivers/staging/lttng/probes/lttng-probe-irq.c
new file mode 100644 (file)
index 0000000..bdd78fb
--- /dev/null
@@ -0,0 +1,45 @@
+/*
+ * probes/lttng-probe-irq.c
+ *
+ * LTTng irq probes.
+ *
+ * Copyright (C) 2010-2012 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; only
+ * version 2.1 of the License.
+ *
+ * This library 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
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include <linux/module.h>
+#include <linux/interrupt.h>
+
+/*
+ * Create the tracepoint static inlines from the kernel to validate that our
+ * trace event macros match the kernel we run on.
+ */
+#include <trace/events/irq.h>
+
+#include "../wrapper/tracepoint.h"
+
+/*
+ * Create LTTng tracepoint probes.
+ */
+#define LTTNG_PACKAGE_BUILD
+#define CREATE_TRACE_POINTS
+#define TRACE_INCLUDE_PATH ../instrumentation/events/lttng-module
+
+#include "../instrumentation/events/lttng-module/irq.h"
+
+MODULE_LICENSE("GPL and additional rights");
+MODULE_AUTHOR("Mathieu Desnoyers <mathieu.desnoyers@efficios.com>");
+MODULE_DESCRIPTION("LTTng irq probes");
diff --git a/drivers/staging/lttng/probes/lttng-probe-jbd.c b/drivers/staging/lttng/probes/lttng-probe-jbd.c
new file mode 100644 (file)
index 0000000..dc94894
--- /dev/null
@@ -0,0 +1,43 @@
+/*
+ * probes/lttng-probe-jbd.c
+ *
+ * LTTng jbd probes.
+ *
+ * Copyright (C) 2010-2012 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
+ * Copyright (C) 2012 Mentor Graphics Corp.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; only
+ * version 2.1 of the License.
+ *
+ * This library 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
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include <linux/module.h>
+
+/*
+ * Create the tracepoint static inlines from the kernel to validate that our
+ * trace event macros match the kernel we run on.
+ */
+#include <trace/events/jbd.h>
+
+/*
+ * Create LTTng tracepoint probes.
+ */
+#define LTTNG_PACKAGE_BUILD
+#define CREATE_TRACE_POINTS
+#define TRACE_INCLUDE_PATH ../instrumentation/events/lttng-module
+
+#include "../instrumentation/events/lttng-module/jbd.h"
+
+MODULE_LICENSE("GPL and additional rights");
+MODULE_AUTHOR("Wade Farnsworth <wade_farnsworth@mentor.com>, Paul Woegerer <paul_woegerer@mentor.com>, and Andrew Gabbasov <andrew_gabbasov@mentor.com>");
+MODULE_DESCRIPTION("LTTng jbd probes");
diff --git a/drivers/staging/lttng/probes/lttng-probe-jbd2.c b/drivers/staging/lttng/probes/lttng-probe-jbd2.c
new file mode 100644 (file)
index 0000000..30ccf3f
--- /dev/null
@@ -0,0 +1,45 @@
+/*
+ * probes/lttng-probe-jbd2.c
+ *
+ * LTTng jbd2 probes.
+ *
+ * Copyright (C) 2010-2012 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
+ * Copyright (C) 2012 Mentor Graphics Corp.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; only
+ * version 2.1 of the License.
+ *
+ * This library 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
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include <linux/module.h>
+
+/*
+ * Create the tracepoint static inlines from the kernel to validate that our
+ * trace event macros match the kernel we run on.
+ */
+#include <trace/events/jbd2.h>
+
+#include "../wrapper/tracepoint.h"
+
+/*
+ * Create LTTng tracepoint probes.
+ */
+#define LTTNG_PACKAGE_BUILD
+#define CREATE_TRACE_POINTS
+#define TRACE_INCLUDE_PATH ../instrumentation/events/lttng-module
+
+#include "../instrumentation/events/lttng-module/jbd2.h"
+
+MODULE_LICENSE("GPL and additional rights");
+MODULE_AUTHOR("Wade Farnsworth <wade_farnsworth@mentor.com> and Andrew Gabbasov <andrew_gabbasov@mentor.com>");
+MODULE_DESCRIPTION("LTTng jbd2 probes");
diff --git a/drivers/staging/lttng/probes/lttng-probe-kmem.c b/drivers/staging/lttng/probes/lttng-probe-kmem.c
new file mode 100644 (file)
index 0000000..441df75
--- /dev/null
@@ -0,0 +1,45 @@
+/*
+ * probes/lttng-probe-kmem.c
+ *
+ * LTTng kmem probes.
+ *
+ * Copyright (C) 2010-2012 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
+ * Copyright (C) 2012 Mentor Graphics Corp.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; only
+ * version 2.1 of the License.
+ *
+ * This library 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
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include <linux/module.h>
+
+/*
+ * Create the tracepoint static inlines from the kernel to validate that our
+ * trace event macros match the kernel we run on.
+ */
+#include <trace/events/kmem.h>
+
+#include "../wrapper/tracepoint.h"
+
+/*
+ * Create LTTng tracepoint probes.
+ */
+#define LTTNG_PACKAGE_BUILD
+#define CREATE_TRACE_POINTS
+#define TRACE_INCLUDE_PATH ../instrumentation/events/lttng-module
+
+#include "../instrumentation/events/lttng-module/kmem.h"
+
+MODULE_LICENSE("GPL and additional rights");
+MODULE_AUTHOR("Wade Farnsworth <wade_farnsworth@mentor.com> and Andrew Gabbasov <andrew_gabbasov@mentor.com>");
+MODULE_DESCRIPTION("LTTng kmem probes");
diff --git a/drivers/staging/lttng/probes/lttng-probe-kvm-x86-mmu.c b/drivers/staging/lttng/probes/lttng-probe-kvm-x86-mmu.c
new file mode 100644 (file)
index 0000000..f0cbf88
--- /dev/null
@@ -0,0 +1,43 @@
+/*
+ * probes/lttng-probe-kvm.c
+ *
+ * LTTng kvm probes.
+ *
+ * Copyright (C) 2010-2012 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; only
+ * version 2.1 of the License.
+ *
+ * This library 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
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include <linux/module.h>
+#include <linux/kvm_host.h>
+
+/*
+ * Create the tracepoint static inlines from the kernel to validate that our
+ * trace event macros match the kernel we run on.
+ */
+#include "../wrapper/tracepoint.h"
+
+/*
+ * Create LTTng tracepoint probes.
+ */
+#define LTTNG_PACKAGE_BUILD
+#define CREATE_TRACE_POINTS
+
+#define TRACE_INCLUDE_PATH ../instrumentation/events/lttng-module/arch/x86/kvm
+#include "../instrumentation/events/lttng-module/arch/x86/kvm/mmutrace.h"
+
+MODULE_LICENSE("GPL and additional rights");
+MODULE_AUTHOR("Mathieu Desnoyers <mathieu.desnoyers@efficios.com>");
+MODULE_DESCRIPTION("LTTng kvm mmu probes");
diff --git a/drivers/staging/lttng/probes/lttng-probe-kvm-x86.c b/drivers/staging/lttng/probes/lttng-probe-kvm-x86.c
new file mode 100644 (file)
index 0000000..abc93a8
--- /dev/null
@@ -0,0 +1,45 @@
+/*
+ * probes/lttng-probe-kvm.c
+ *
+ * LTTng kvm probes.
+ *
+ * Copyright (C) 2010-2012 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; only
+ * version 2.1 of the License.
+ *
+ * This library 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
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include <linux/module.h>
+#include <linux/kvm_host.h>
+
+/*
+ * Create the tracepoint static inlines from the kernel to validate that our
+ * trace event macros match the kernel we run on.
+ */
+#include <trace/events/kvm.h>
+
+#include "../wrapper/tracepoint.h"
+
+/*
+ * Create LTTng tracepoint probes.
+ */
+#define LTTNG_PACKAGE_BUILD
+#define CREATE_TRACE_POINTS
+
+#define TRACE_INCLUDE_PATH ../instrumentation/events/lttng-module/arch/x86/kvm
+#include "../instrumentation/events/lttng-module/arch/x86/kvm/trace.h"
+
+MODULE_LICENSE("GPL and additional rights");
+MODULE_AUTHOR("Mathieu Desnoyers <mathieu.desnoyers@efficios.com>");
+MODULE_DESCRIPTION("LTTng kvm probes");
diff --git a/drivers/staging/lttng/probes/lttng-probe-kvm.c b/drivers/staging/lttng/probes/lttng-probe-kvm.c
new file mode 100644 (file)
index 0000000..bdec187
--- /dev/null
@@ -0,0 +1,45 @@
+/*
+ * probes/lttng-probe-kvm.c
+ *
+ * LTTng kvm probes.
+ *
+ * Copyright (C) 2010-2012 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; only
+ * version 2.1 of the License.
+ *
+ * This library 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
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include <linux/module.h>
+#include <linux/kvm_host.h>
+
+/*
+ * Create the tracepoint static inlines from the kernel to validate that our
+ * trace event macros match the kernel we run on.
+ */
+#include <trace/events/kvm.h>
+
+#include "../wrapper/tracepoint.h"
+
+/*
+ * Create LTTng tracepoint probes.
+ */
+#define LTTNG_PACKAGE_BUILD
+#define CREATE_TRACE_POINTS
+#define TRACE_INCLUDE_PATH ../instrumentation/events/lttng-module
+
+#include "../instrumentation/events/lttng-module/kvm.h"
+
+MODULE_LICENSE("GPL and additional rights");
+MODULE_AUTHOR("Mathieu Desnoyers <mathieu.desnoyers@efficios.com>");
+MODULE_DESCRIPTION("LTTng kvm probes");
diff --git a/drivers/staging/lttng/probes/lttng-probe-lock.c b/drivers/staging/lttng/probes/lttng-probe-lock.c
new file mode 100644 (file)
index 0000000..b95e0c5
--- /dev/null
@@ -0,0 +1,50 @@
+/*
+ * probes/lttng-probe-lock.c
+ *
+ * LTTng lock probes.
+ *
+ * Copyright (C) 2010-2012 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
+ * Copyright (C) 2012 Mentor Graphics Corp.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; only
+ * version 2.1 of the License.
+ *
+ * This library 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
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include <linux/module.h>
+#include <linux/version.h>
+
+/*
+ * Create the tracepoint static inlines from the kernel to validate that our
+ * trace event macros match the kernel we run on.
+ */
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,33))
+#include <trace/events/lock.h>
+#else
+#include <trace/events/lockdep.h>
+#endif
+
+#include "../wrapper/tracepoint.h"
+
+/*
+ * Create LTTng tracepoint probes.
+ */
+#define LTTNG_PACKAGE_BUILD
+#define CREATE_TRACE_POINTS
+#define TRACE_INCLUDE_PATH ../instrumentation/events/lttng-module
+
+#include "../instrumentation/events/lttng-module/lock.h"
+
+MODULE_LICENSE("GPL and additional rights");
+MODULE_AUTHOR("Wade Farnsworth <wade_farnsworth@mentor.com> and Andrew Gabbasov <andrew_gabbasov@mentor.com>");
+MODULE_DESCRIPTION("LTTng lock probes");
diff --git a/drivers/staging/lttng/probes/lttng-probe-module.c b/drivers/staging/lttng/probes/lttng-probe-module.c
new file mode 100644 (file)
index 0000000..3594001
--- /dev/null
@@ -0,0 +1,45 @@
+/*
+ * probes/lttng-probe-module.c
+ *
+ * LTTng module probes.
+ *
+ * Copyright (C) 2010-2012 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
+ * Copyright (C) 2012 Mentor Graphics Corp.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; only
+ * version 2.1 of the License.
+ *
+ * This library 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
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include <linux/module.h>
+
+/*
+ * Create the tracepoint static inlines from the kernel to validate that our
+ * trace event macros match the kernel we run on.
+ */
+#include <trace/events/module.h>
+
+#include "../wrapper/tracepoint.h"
+
+/*
+ * Create LTTng tracepoint probes.
+ */
+#define LTTNG_PACKAGE_BUILD
+#define CREATE_TRACE_POINTS
+#define TRACE_INCLUDE_PATH ../instrumentation/events/lttng-module
+
+#include "../instrumentation/events/lttng-module/module.h"
+
+MODULE_LICENSE("GPL and additional rights");
+MODULE_AUTHOR("Wade Farnsworth <wade_farnsworth@mentor.com> and Andrew Gabbasov <andrew_gabbasov@mentor.com>");
+MODULE_DESCRIPTION("LTTng module probes");
diff --git a/drivers/staging/lttng/probes/lttng-probe-napi.c b/drivers/staging/lttng/probes/lttng-probe-napi.c
new file mode 100644 (file)
index 0000000..47371a8
--- /dev/null
@@ -0,0 +1,45 @@
+/*
+ * probes/lttng-probe-napi.c
+ *
+ * LTTng napi probes.
+ *
+ * Copyright (C) 2010-2012 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
+ * Copyright (C) 2012 Mentor Graphics Corp.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; only
+ * version 2.1 of the License.
+ *
+ * This library 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
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include <linux/module.h>
+
+/*
+ * Create the tracepoint static inlines from the kernel to validate that our
+ * trace event macros match the kernel we run on.
+ */
+#include <trace/events/napi.h>
+
+#include "../wrapper/tracepoint.h"
+
+/*
+ * Create LTTng tracepoint probes.
+ */
+#define LTTNG_PACKAGE_BUILD
+#define CREATE_TRACE_POINTS
+#define TRACE_INCLUDE_PATH ../instrumentation/events/lttng-module
+
+#include "../instrumentation/events/lttng-module/napi.h"
+
+MODULE_LICENSE("GPL and additional rights");
+MODULE_AUTHOR("Wade Farnsworth <wade_farnsworth@mentor.com>");
+MODULE_DESCRIPTION("LTTng napi probes");
diff --git a/drivers/staging/lttng/probes/lttng-probe-net.c b/drivers/staging/lttng/probes/lttng-probe-net.c
new file mode 100644 (file)
index 0000000..54212be
--- /dev/null
@@ -0,0 +1,43 @@
+/*
+ * probes/lttng-probe-net.c
+ *
+ * LTTng net probes.
+ *
+ * Copyright (C) 2010-2012 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
+ * Copyright (C) 2012 Mentor Graphics Corp.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; only
+ * version 2.1 of the License.
+ *
+ * This library 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
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include <linux/module.h>
+
+/*
+ * Create the tracepoint static inlines from the kernel to validate that our
+ * trace event macros match the kernel we run on.
+ */
+#include <trace/events/net.h>
+
+/*
+ * Create LTTng tracepoint probes.
+ */
+#define LTTNG_PACKAGE_BUILD
+#define CREATE_TRACE_POINTS
+#define TRACE_INCLUDE_PATH ../instrumentation/events/lttng-module
+
+#include "../instrumentation/events/lttng-module/net.h"
+
+MODULE_LICENSE("GPL and additional rights");
+MODULE_AUTHOR("Wade Farnsworth <wade_farnsworth@mentor.com>");
+MODULE_DESCRIPTION("LTTng net probes");
diff --git a/drivers/staging/lttng/probes/lttng-probe-power.c b/drivers/staging/lttng/probes/lttng-probe-power.c
new file mode 100644 (file)
index 0000000..ff25a8a
--- /dev/null
@@ -0,0 +1,45 @@
+/*
+ * probes/lttng-probe-power.c
+ *
+ * LTTng power probes.
+ *
+ * Copyright (C) 2010-2012 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
+ * Copyright (C) 2012 Mentor Graphics Corp.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; only
+ * version 2.1 of the License.
+ *
+ * This library 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
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include <linux/module.h>
+
+/*
+ * Create the tracepoint static inlines from the kernel to validate that our
+ * trace event macros match the kernel we run on.
+ */
+#include <trace/events/power.h>
+
+#include "../wrapper/tracepoint.h"
+
+/*
+ * Create LTTng tracepoint probes.
+ */
+#define LTTNG_PACKAGE_BUILD
+#define CREATE_TRACE_POINTS
+#define TRACE_INCLUDE_PATH ../instrumentation/events/lttng-module
+
+#include "../instrumentation/events/lttng-module/power.h"
+
+MODULE_LICENSE("GPL and additional rights");
+MODULE_AUTHOR("Wade Farnsworth <wade_farnsworth@mentor.com> and Andrew Gabbasov <andrew_gabbasov@mentor.com>");
+MODULE_DESCRIPTION("LTTng power probes");
diff --git a/drivers/staging/lttng/probes/lttng-probe-printk.c b/drivers/staging/lttng/probes/lttng-probe-printk.c
new file mode 100644 (file)
index 0000000..1fe1f01
--- /dev/null
@@ -0,0 +1,43 @@
+/*
+ * probes/lttng-probe-printk.c
+ *
+ * LTTng printk probes.
+ *
+ * Copyright (C) 2010-2012 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
+ * Copyright (C) 2012 Mentor Graphics Corp.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; only
+ * version 2.1 of the License.
+ *
+ * This library 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
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include <linux/module.h>
+
+/*
+ * Create the tracepoint static inlines from the kernel to validate that our
+ * trace event macros match the kernel we run on.
+ */
+#include <trace/events/printk.h>
+
+/*
+ * Create LTTng tracepoint probes.
+ */
+#define LTTNG_PACKAGE_BUILD
+#define CREATE_TRACE_POINTS
+#define TRACE_INCLUDE_PATH ../instrumentation/events/lttng-module
+
+#include "../instrumentation/events/lttng-module/printk.h"
+
+MODULE_LICENSE("GPL and additional rights");
+MODULE_AUTHOR("Andrew Gabbasov <andrew_gabbasov@mentor.com>");
+MODULE_DESCRIPTION("LTTng printk probes");
diff --git a/drivers/staging/lttng/probes/lttng-probe-random.c b/drivers/staging/lttng/probes/lttng-probe-random.c
new file mode 100644 (file)
index 0000000..df9f551
--- /dev/null
@@ -0,0 +1,43 @@
+/*
+ * probes/lttng-probe-random.c
+ *
+ * LTTng random probes.
+ *
+ * Copyright (C) 2010-2012 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
+ * Copyright (C) 2012 Mentor Graphics Corp.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; only
+ * version 2.1 of the License.
+ *
+ * This library 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
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include <linux/module.h>
+
+/*
+ * Create the tracepoint static inlines from the kernel to validate that our
+ * trace event macros match the kernel we run on.
+ */
+#include <trace/events/random.h>
+
+/*
+ * Create LTTng tracepoint probes.
+ */
+#define LTTNG_PACKAGE_BUILD
+#define CREATE_TRACE_POINTS
+#define TRACE_INCLUDE_PATH ../instrumentation/events/lttng-module
+
+#include "../instrumentation/events/lttng-module/random.h"
+
+MODULE_LICENSE("GPL and additional rights");
+MODULE_AUTHOR("Andrew Gabbasov <andrew_gabbasov@mentor.com>");
+MODULE_DESCRIPTION("LTTng random probes");
diff --git a/drivers/staging/lttng/probes/lttng-probe-rcu.c b/drivers/staging/lttng/probes/lttng-probe-rcu.c
new file mode 100644 (file)
index 0000000..5216500
--- /dev/null
@@ -0,0 +1,44 @@
+/*
+ * probes/lttng-probe-rcu.c
+ *
+ * LTTng rcu probes.
+ *
+ * Copyright (C) 2010-2012 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
+ * Copyright (C) 2012 Mentor Graphics Corp.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; only
+ * version 2.1 of the License.
+ *
+ * This library 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
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include <linux/module.h>
+#include <linux/rcupdate.h>
+
+/*
+ * Create the tracepoint static inlines from the kernel to validate that our
+ * trace event macros match the kernel we run on.
+ */
+#include <trace/events/rcu.h>
+
+/*
+ * Create LTTng tracepoint probes.
+ */
+#define LTTNG_PACKAGE_BUILD
+#define CREATE_TRACE_POINTS
+#define TRACE_INCLUDE_PATH ../instrumentation/events/lttng-module
+
+#include "../instrumentation/events/lttng-module/rcu.h"
+
+MODULE_LICENSE("GPL and additional rights");
+MODULE_AUTHOR("Andrew Gabbasov <andrew_gabbasov@mentor.com>");
+MODULE_DESCRIPTION("LTTng rcu probes");
diff --git a/drivers/staging/lttng/probes/lttng-probe-regmap.c b/drivers/staging/lttng/probes/lttng-probe-regmap.c
new file mode 100644 (file)
index 0000000..7c1fd00
--- /dev/null
@@ -0,0 +1,44 @@
+/*
+ * probes/lttng-probe-regmap.c
+ *
+ * LTTng regmap probes.
+ *
+ * Copyright (C) 2010-2012 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
+ * Copyright (C) 2012 Mentor Graphics Corp.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; only
+ * version 2.1 of the License.
+ *
+ * This library 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
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include <linux/module.h>
+#include <linux/device.h>
+
+/*
+ * Create the tracepoint static inlines from the kernel to validate that our
+ * trace event macros match the kernel we run on.
+ */
+#include <trace/events/regmap.h>
+
+/*
+ * Create LTTng tracepoint probes.
+ */
+#define LTTNG_PACKAGE_BUILD
+#define CREATE_TRACE_POINTS
+#define TRACE_INCLUDE_PATH ../instrumentation/events/lttng-module
+
+#include "../instrumentation/events/lttng-module/regmap.h"
+
+MODULE_LICENSE("GPL and additional rights");
+MODULE_AUTHOR("Andrew Gabbasov <andrew_gabbasov@mentor.com>");
+MODULE_DESCRIPTION("LTTng regmap probes");
diff --git a/drivers/staging/lttng/probes/lttng-probe-regulator.c b/drivers/staging/lttng/probes/lttng-probe-regulator.c
new file mode 100644 (file)
index 0000000..7c8b7f9
--- /dev/null
@@ -0,0 +1,43 @@
+/*
+ * probes/lttng-probe-regulator.c
+ *
+ * LTTng regulator probes.
+ *
+ * Copyright (C) 2010-2012 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
+ * Copyright (C) 2012 Mentor Graphics Corp.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; only
+ * version 2.1 of the License.
+ *
+ * This library 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
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include <linux/module.h>
+
+/*
+ * Create the tracepoint static inlines from the kernel to validate that our
+ * trace event macros match the kernel we run on.
+ */
+#include <trace/events/regulator.h>
+
+/*
+ * Create LTTng tracepoint probes.
+ */
+#define LTTNG_PACKAGE_BUILD
+#define CREATE_TRACE_POINTS
+#define TRACE_INCLUDE_PATH ../instrumentation/events/lttng-module
+
+#include "../instrumentation/events/lttng-module/regulator.h"
+
+MODULE_LICENSE("GPL and additional rights");
+MODULE_AUTHOR("Wade Farnsworth <wade_farnsworth@mentor.com>");
+MODULE_DESCRIPTION("LTTng regulator probes");
diff --git a/drivers/staging/lttng/probes/lttng-probe-rpm.c b/drivers/staging/lttng/probes/lttng-probe-rpm.c
new file mode 100644 (file)
index 0000000..607e9e5
--- /dev/null
@@ -0,0 +1,44 @@
+/*
+ * probes/lttng-probe-rpm.c
+ *
+ * LTTng rpm probes.
+ *
+ * Copyright (C) 2010-2012 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
+ * Copyright (C) 2012 Mentor Graphics Corp.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; only
+ * version 2.1 of the License.
+ *
+ * This library 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
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include <linux/module.h>
+#include <linux/device.h>
+
+/*
+ * Create the tracepoint static inlines from the kernel to validate that our
+ * trace event macros match the kernel we run on.
+ */
+#include <trace/events/rpm.h>
+
+/*
+ * Create LTTng tracepoint probes.
+ */
+#define LTTNG_PACKAGE_BUILD
+#define CREATE_TRACE_POINTS
+#define TRACE_INCLUDE_PATH ../instrumentation/events/lttng-module
+
+#include "../instrumentation/events/lttng-module/rpm.h"
+
+MODULE_LICENSE("GPL and additional rights");
+MODULE_AUTHOR("Andrew Gabbasov <andrew_gabbasov@mentor.com>");
+MODULE_DESCRIPTION("LTTng rpm probes");
diff --git a/drivers/staging/lttng/probes/lttng-probe-sched.c b/drivers/staging/lttng/probes/lttng-probe-sched.c
new file mode 100644 (file)
index 0000000..8a72e14
--- /dev/null
@@ -0,0 +1,44 @@
+/*
+ * probes/lttng-probe-sched.c
+ *
+ * LTTng sched probes.
+ *
+ * Copyright (C) 2010-2012 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; only
+ * version 2.1 of the License.
+ *
+ * This library 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
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include <linux/module.h>
+
+/*
+ * Create the tracepoint static inlines from the kernel to validate that our
+ * trace event macros match the kernel we run on.
+ */
+#include <trace/events/sched.h>
+
+#include "../wrapper/tracepoint.h"
+
+/*
+ * Create LTTng tracepoint probes.
+ */
+#define LTTNG_PACKAGE_BUILD
+#define CREATE_TRACE_POINTS
+#define TRACE_INCLUDE_PATH ../instrumentation/events/lttng-module
+
+#include "../instrumentation/events/lttng-module/sched.h"
+
+MODULE_LICENSE("GPL and additional rights");
+MODULE_AUTHOR("Mathieu Desnoyers <mathieu.desnoyers@efficios.com>");
+MODULE_DESCRIPTION("LTTng sched probes");
diff --git a/drivers/staging/lttng/probes/lttng-probe-scsi.c b/drivers/staging/lttng/probes/lttng-probe-scsi.c
new file mode 100644 (file)
index 0000000..57677c6
--- /dev/null
@@ -0,0 +1,44 @@
+/*
+ * probes/lttng-probe-scsi.c
+ *
+ * LTTng scsi probes.
+ *
+ * Copyright (C) 2010-2012 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
+ * Copyright (C) 2012 Mentor Graphics Corp.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; only
+ * version 2.1 of the License.
+ *
+ * This library 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
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include <linux/module.h>
+#include <scsi/scsi_device.h>
+
+/*
+ * Create the tracepoint static inlines from the kernel to validate that our
+ * trace event macros match the kernel we run on.
+ */
+#include <trace/events/scsi.h>
+
+/*
+ * Create LTTng tracepoint probes.
+ */
+#define LTTNG_PACKAGE_BUILD
+#define CREATE_TRACE_POINTS
+#define TRACE_INCLUDE_PATH ../instrumentation/events/lttng-module
+
+#include "../instrumentation/events/lttng-module/scsi.h"
+
+MODULE_LICENSE("GPL and additional rights");
+MODULE_AUTHOR("Wade Farnsworth <wade_farnsworth@mentor.com> and Andrew Gabbasov <andrew_gabbasov@mentor.com>");
+MODULE_DESCRIPTION("LTTng scsi probes");
diff --git a/drivers/staging/lttng/probes/lttng-probe-signal.c b/drivers/staging/lttng/probes/lttng-probe-signal.c
new file mode 100644 (file)
index 0000000..44273a1
--- /dev/null
@@ -0,0 +1,42 @@
+/*
+ * probes/lttng-probe-signal.c
+ *
+ * LTTng signal probes.
+ *
+ * Copyright (C) 2010-2012 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; only
+ * version 2.1 of the License.
+ *
+ * This library 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
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include <linux/module.h>
+
+/*
+ * Create the tracepoint static inlines from the kernel to validate that our
+ * trace event macros match the kernel we run on.
+ */
+#include <trace/events/signal.h>
+
+/*
+ * Create LTTng tracepoint probes.
+ */
+#define LTTNG_PACKAGE_BUILD
+#define CREATE_TRACE_POINTS
+#define TRACE_INCLUDE_PATH ../instrumentation/events/lttng-module
+
+#include "../instrumentation/events/lttng-module/signal.h"
+
+MODULE_LICENSE("GPL and additional rights");
+MODULE_AUTHOR("Mathieu Desnoyers <mathieu.desnoyers@efficios.com>");
+MODULE_DESCRIPTION("LTTng signal probes");
diff --git a/drivers/staging/lttng/probes/lttng-probe-skb.c b/drivers/staging/lttng/probes/lttng-probe-skb.c
new file mode 100644 (file)
index 0000000..71e890d
--- /dev/null
@@ -0,0 +1,45 @@
+/*
+ * probes/lttng-probe-skb.c
+ *
+ * LTTng skb probes.
+ *
+ * Copyright (C) 2010-2012 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
+ * Copyright (C) 2012 Mentor Graphics Corp.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; only
+ * version 2.1 of the License.
+ *
+ * This library 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
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include <linux/module.h>
+
+/*
+ * Create the tracepoint static inlines from the kernel to validate that our
+ * trace event macros match the kernel we run on.
+ */
+#include <trace/events/skb.h>
+
+#include "../wrapper/tracepoint.h"
+
+/*
+ * Create LTTng tracepoint probes.
+ */
+#define LTTNG_PACKAGE_BUILD
+#define CREATE_TRACE_POINTS
+#define TRACE_INCLUDE_PATH ../instrumentation/events/lttng-module
+
+#include "../instrumentation/events/lttng-module/skb.h"
+
+MODULE_LICENSE("GPL and additional rights");
+MODULE_AUTHOR("Wade Farnsworth <wade_farnsworth@mentor.com> and Andrew Gabbasov <andrew_gabbasov@mentor.com>");
+MODULE_DESCRIPTION("LTTng skb probes");
diff --git a/drivers/staging/lttng/probes/lttng-probe-sock.c b/drivers/staging/lttng/probes/lttng-probe-sock.c
new file mode 100644 (file)
index 0000000..b3e699a
--- /dev/null
@@ -0,0 +1,43 @@
+/*
+ * probes/lttng-probe-sock.c
+ *
+ * LTTng sock probes.
+ *
+ * Copyright (C) 2010-2012 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
+ * Copyright (C) 2012 Mentor Graphics Corp.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; only
+ * version 2.1 of the License.
+ *
+ * This library 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
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include <linux/module.h>
+
+/*
+ * Create the tracepoint static inlines from the kernel to validate that our
+ * trace event macros match the kernel we run on.
+ */
+#include <trace/events/sock.h>
+
+/*
+ * Create LTTng tracepoint probes.
+ */
+#define LTTNG_PACKAGE_BUILD
+#define CREATE_TRACE_POINTS
+#define TRACE_INCLUDE_PATH ../instrumentation/events/lttng-module
+
+#include "../instrumentation/events/lttng-module/sock.h"
+
+MODULE_LICENSE("GPL and additional rights");
+MODULE_AUTHOR("Wade Farnsworth <wade_farnsworth@mentor.com>");
+MODULE_DESCRIPTION("LTTng sock probes");
diff --git a/drivers/staging/lttng/probes/lttng-probe-statedump.c b/drivers/staging/lttng/probes/lttng-probe-statedump.c
new file mode 100644 (file)
index 0000000..fc2af91
--- /dev/null
@@ -0,0 +1,46 @@
+/*
+ * probes/lttng-probe-statedump.c
+ *
+ * LTTng statedump probes.
+ *
+ * Copyright (C) 2010-2012 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; only
+ * version 2.1 of the License.
+ *
+ * This library 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
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include <linux/module.h>
+#include <linux/interrupt.h>
+#include <linux/netlink.h>
+#include <linux/inet.h>
+#include <linux/ip.h>
+#include <linux/netdevice.h>
+#include <linux/inetdevice.h>
+#include <linux/sched.h>
+#include "../lttng-events.h"
+
+/*
+ * Create LTTng tracepoint probes.
+ */
+#define LTTNG_PACKAGE_BUILD
+#define CREATE_TRACE_POINTS
+#define TP_SESSION_CHECK
+#define TRACE_INCLUDE_PATH ../instrumentation/events/lttng-module
+#define TRACE_INCLUDE_FILE lttng-statedump
+
+#include "../instrumentation/events/lttng-module/lttng-statedump.h"
+
+MODULE_LICENSE("GPL and additional rights");
+MODULE_AUTHOR("Mathieu Desnoyers <mathieu.desnoyers@efficios.com>");
+MODULE_DESCRIPTION("LTTng statedump probes");
diff --git a/drivers/staging/lttng/probes/lttng-probe-sunrpc.c b/drivers/staging/lttng/probes/lttng-probe-sunrpc.c
new file mode 100644 (file)
index 0000000..504413e
--- /dev/null
@@ -0,0 +1,43 @@
+/*
+ * probes/lttng-probe-sunrpc.c
+ *
+ * LTTng sunrpc probes.
+ *
+ * Copyright (C) 2010-2012 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
+ * Copyright (C) 2012 Mentor Graphics Corp.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; only
+ * version 2.1 of the License.
+ *
+ * This library 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
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include <linux/module.h>
+
+/*
+ * Create the tracepoint static inlines from the kernel to validate that our
+ * trace event macros match the kernel we run on.
+ */
+#include <trace/events/sunrpc.h>
+
+/*
+ * Create LTTng tracepoint probes.
+ */
+#define LTTNG_PACKAGE_BUILD
+#define CREATE_TRACE_POINTS
+#define TRACE_INCLUDE_PATH ../instrumentation/events/lttng-module
+
+#include "../instrumentation/events/lttng-module/sunrpc.h"
+
+MODULE_LICENSE("GPL and additional rights");
+MODULE_AUTHOR("Andrew Gabbasov <andrew_gabbasov@mentor.com>");
+MODULE_DESCRIPTION("LTTng sunrpc probes");
diff --git a/drivers/staging/lttng/probes/lttng-probe-timer.c b/drivers/staging/lttng/probes/lttng-probe-timer.c
new file mode 100644 (file)
index 0000000..299f630
--- /dev/null
@@ -0,0 +1,46 @@
+/*
+ * probes/lttng-probe-timer.c
+ *
+ * LTTng timer probes.
+ *
+ * Copyright (C) 2012 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; only
+ * version 2.1 of the License.
+ *
+ * This library 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
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include <linux/module.h>
+
+/*
+ * Create the tracepoint static inlines from the kernel to validate that our
+ * trace event macros match the kernel we run on.
+ */
+
+#include <linux/sched.h>
+#include <trace/events/timer.h>
+
+#include "../wrapper/tracepoint.h"
+
+/*
+ * Create LTTng tracepoint probes.
+ */
+#define LTTNG_PACKAGE_BUILD
+#define CREATE_TRACE_POINTS
+#define TRACE_INCLUDE_PATH ../instrumentation/events/lttng-module
+
+#include "../instrumentation/events/lttng-module/timer.h"
+
+MODULE_LICENSE("GPL and additional rights");
+MODULE_AUTHOR("Mathieu Desnoyers <mathieu.desnoyers@efficios.com>");
+MODULE_DESCRIPTION("LTTng timer probes");
diff --git a/drivers/staging/lttng/probes/lttng-probe-udp.c b/drivers/staging/lttng/probes/lttng-probe-udp.c
new file mode 100644 (file)
index 0000000..51ec3cb
--- /dev/null
@@ -0,0 +1,43 @@
+/*
+ * probes/lttng-probe-udp.c
+ *
+ * LTTng udp probes.
+ *
+ * Copyright (C) 2010-2012 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
+ * Copyright (C) 2012 Mentor Graphics Corp.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; only
+ * version 2.1 of the License.
+ *
+ * This library 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
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include <linux/module.h>
+
+/*
+ * Create the tracepoint static inlines from the kernel to validate that our
+ * trace event macros match the kernel we run on.
+ */
+#include <trace/events/udp.h>
+
+/*
+ * Create LTTng tracepoint probes.
+ */
+#define LTTNG_PACKAGE_BUILD
+#define CREATE_TRACE_POINTS
+#define TRACE_INCLUDE_PATH ../instrumentation/events/lttng-module
+
+#include "../instrumentation/events/lttng-module/udp.h"
+
+MODULE_LICENSE("GPL and additional rights");
+MODULE_AUTHOR("Wade Farnsworth <wade_farnsworth@mentor.com>");
+MODULE_DESCRIPTION("LTTng udp probes");
diff --git a/drivers/staging/lttng/probes/lttng-probe-user.c b/drivers/staging/lttng/probes/lttng-probe-user.c
new file mode 100644 (file)
index 0000000..d0b5cf2
--- /dev/null
@@ -0,0 +1,54 @@
+/*
+ * lttng-probe-user.c
+ *
+ * Copyright (C) 2012 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; only
+ * version 2.1 of the License.
+ *
+ * This library 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
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include <linux/uaccess.h>
+#include "lttng-probe-user.h"
+
+/*
+ * Calculate string length. Include final null terminating character if there is
+ * one, or ends at first fault. Disabling page faults ensures that we can safely
+ * call this from pretty much any context, including those where the caller
+ * holds mmap_sem, or any lock which nests in mmap_sem.
+ */
+long lttng_strlen_user_inatomic(const char *addr)
+{
+       long count = 0;
+       mm_segment_t old_fs = get_fs();
+
+       set_fs(KERNEL_DS);
+       pagefault_disable();
+       for (;;) {
+               char v;
+               unsigned long ret;
+
+               ret = __copy_from_user_inatomic(&v,
+                       (__force const char __user *)(addr),
+                       sizeof(v));
+               if (unlikely(ret > 0))
+                       break;
+               count++;
+               if (unlikely(!v))
+                       break;
+               addr++;
+       }
+       pagefault_enable();
+       set_fs(old_fs);
+       return count;
+}
diff --git a/drivers/staging/lttng/probes/lttng-probe-user.h b/drivers/staging/lttng/probes/lttng-probe-user.h
new file mode 100644 (file)
index 0000000..e03e4b0
--- /dev/null
@@ -0,0 +1,30 @@
+#ifndef _LTTNG_PROBE_USER_H
+#define _LTTNG_PROBE_USER_H
+
+/*
+ * lttng-probe-user.h
+ *
+ * Copyright (C) 2012 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; only
+ * version 2.1 of the License.
+ *
+ * This library 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
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+/*
+ * Calculate string length. Include final null terminating character if there is
+ * one, or ends at first fault.
+ */
+long lttng_strlen_user_inatomic(const char *addr);
+
+#endif /* _LTTNG_PROBE_USER_H */
diff --git a/drivers/staging/lttng/probes/lttng-probe-vmscan.c b/drivers/staging/lttng/probes/lttng-probe-vmscan.c
new file mode 100644 (file)
index 0000000..d5892a4
--- /dev/null
@@ -0,0 +1,45 @@
+/*
+ * probes/lttng-probe-vmscan.c
+ *
+ * LTTng vmscan probes.
+ *
+ * Copyright (C) 2010-2012 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
+ * Copyright (C) 2012 Mentor Graphics Corp.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; only
+ * version 2.1 of the License.
+ *
+ * This library 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
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include <linux/module.h>
+
+/*
+ * Create the tracepoint static inlines from the kernel to validate that our
+ * trace event macros match the kernel we run on.
+ */
+#include <trace/events/vmscan.h>
+
+#include "../lttng-kernel-version.h"
+
+/*
+ * Create LTTng tracepoint probes.
+ */
+#define LTTNG_PACKAGE_BUILD
+#define CREATE_TRACE_POINTS
+#define TRACE_INCLUDE_PATH ../instrumentation/events/lttng-module
+
+#include "../instrumentation/events/lttng-module/vmscan.h"
+
+MODULE_LICENSE("GPL and additional rights");
+MODULE_AUTHOR("Wade Farnsworth <wade_farnsworth@mentor.com>, Paul Woegerer <paul_woegerer@mentor.com>, and Andrew Gabbasov <andrew_gabbasov@mentor.com>");
+MODULE_DESCRIPTION("LTTng vmscan probes");
diff --git a/drivers/staging/lttng/probes/lttng-probe-workqueue.c b/drivers/staging/lttng/probes/lttng-probe-workqueue.c
new file mode 100644 (file)
index 0000000..f643476
--- /dev/null
@@ -0,0 +1,49 @@
+/*
+ * probes/lttng-probe-workqueue.c
+ *
+ * LTTng workqueue probes.
+ *
+ * Copyright (C) 2010-2012 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
+ * Copyright (C) 2012 Mentor Graphics Corp.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; only
+ * version 2.1 of the License.
+ *
+ * This library 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
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include <linux/module.h>
+#include <linux/idr.h>
+
+struct cpu_workqueue_struct;
+struct pool_workqueue;
+
+/*
+ * Create the tracepoint static inlines from the kernel to validate that our
+ * trace event macros match the kernel we run on.
+ */
+#include <trace/events/workqueue.h>
+
+#include "../wrapper/tracepoint.h"
+
+/*
+ * Create LTTng tracepoint probes.
+ */
+#define LTTNG_PACKAGE_BUILD
+#define CREATE_TRACE_POINTS
+#define TRACE_INCLUDE_PATH ../instrumentation/events/lttng-module
+
+#include "../instrumentation/events/lttng-module/workqueue.h"
+
+MODULE_LICENSE("GPL and additional rights");
+MODULE_AUTHOR("Andrew Gabbasov <andrew_gabbasov@mentor.com>");
+MODULE_DESCRIPTION("LTTng workqueue probes");
diff --git a/drivers/staging/lttng/probes/lttng-probe-writeback.c b/drivers/staging/lttng/probes/lttng-probe-writeback.c
new file mode 100644 (file)
index 0000000..5e421e5
--- /dev/null
@@ -0,0 +1,54 @@
+/*
+ * probes/lttng-probe-writeback.c
+ *
+ * LTTng writeback probes.
+ *
+ * Copyright (C) 2010-2012 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
+ * Copyright (C) 2012 Mentor Graphics Corp.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; only
+ * version 2.1 of the License.
+ *
+ * This library 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
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include <linux/module.h>
+#include <linux/device.h>
+#include <linux/mm.h>
+
+/*
+ * Create the tracepoint static inlines from the kernel to validate that our
+ * trace event macros match the kernel we run on.
+ */
+#include <trace/events/writeback.h>
+
+#include "../lttng-kernel-version.h"
+#include "../wrapper/writeback.h"
+
+/* #if <check version number if global_dirty_limit will be exported> */
+
+#define global_dirty_limit wrapper_global_dirty_limit()
+
+/* #endif <check version number> */
+
+/*
+ * Create LTTng tracepoint probes.
+ */
+#define LTTNG_PACKAGE_BUILD
+#define CREATE_TRACE_POINTS
+#define TRACE_INCLUDE_PATH ../instrumentation/events/lttng-module
+
+#include "../instrumentation/events/lttng-module/writeback.h"
+
+MODULE_LICENSE("GPL and additional rights");
+MODULE_AUTHOR("Andrew Gabbasov <andrew_gabbasov@mentor.com>");
+MODULE_DESCRIPTION("LTTng writeback probes");
diff --git a/drivers/staging/lttng/probes/lttng-type-list.h b/drivers/staging/lttng/probes/lttng-type-list.h
new file mode 100644 (file)
index 0000000..564a13f
--- /dev/null
@@ -0,0 +1,33 @@
+/*
+ * lttng-type-list.h
+ *
+ * Copyright (C) 2010-2012 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; only
+ * version 2.1 of the License.
+ *
+ * This library 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
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+/* Type list, used to create metadata */
+
+/* Enumerations */
+TRACE_EVENT_ENUM(hrtimer_mode,
+        V(HRTIMER_MODE_ABS),
+        V(HRTIMER_MODE_REL),
+        V(HRTIMER_MODE_PINNED),
+        V(HRTIMER_MODE_ABS_PINNED),
+        V(HRTIMER_MODE_REL_PINNED),
+       R(HRTIMER_MODE_UNDEFINED, 0x04, 0x20),  /* Example (to remove) */
+)
+
+TRACE_EVENT_TYPE(hrtimer_mode, enum, unsigned char)
diff --git a/drivers/staging/lttng/probes/lttng-types.c b/drivers/staging/lttng/probes/lttng-types.c
new file mode 100644 (file)
index 0000000..76519a8
--- /dev/null
@@ -0,0 +1,61 @@
+/*
+ * probes/lttng-types.c
+ *
+ * LTTng types.
+ *
+ * Copyright (C) 2010-2012 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; only
+ * version 2.1 of the License.
+ *
+ * This library 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
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include <linux/module.h>
+#include <linux/types.h>
+#include "../wrapper/vmalloc.h"        /* for wrapper_vmalloc_sync_all() */
+#include "../lttng-events.h"
+#include "lttng-types.h"
+#include <linux/hrtimer.h>
+
+#define STAGE_EXPORT_ENUMS
+#include "lttng-types.h"
+#include "lttng-type-list.h"
+#undef STAGE_EXPORT_ENUMS
+
+struct lttng_enum lttng_enums[] = {
+#define STAGE_EXPORT_TYPES
+#include "lttng-types.h"
+#include "lttng-type-list.h"
+#undef STAGE_EXPORT_TYPES
+};
+
+static int lttng_types_init(void)
+{
+       int ret = 0;
+
+       wrapper_vmalloc_sync_all();
+       /* TODO */
+       return ret;
+}
+
+module_init(lttng_types_init);
+
+static void lttng_types_exit(void)
+{
+}
+
+module_exit(lttng_types_exit);
+
+MODULE_LICENSE("GPL and additional rights");
+MODULE_AUTHOR("Mathieu Desnoyers <mathieu.desnoyers@efficios.com>");
+MODULE_DESCRIPTION("LTTng types");
diff --git a/drivers/staging/lttng/probes/lttng-types.h b/drivers/staging/lttng/probes/lttng-types.h
new file mode 100644 (file)
index 0000000..9376066
--- /dev/null
@@ -0,0 +1,84 @@
+/*
+ * Protect against multiple inclusion of structure declarations, but run the
+ * stages below each time.
+ */
+#ifndef _LTTNG_PROBES_LTTNG_TYPES_H
+#define _LTTNG_PROBES_LTTNG_TYPES_H
+
+/*
+ * probes/lttng-types.h
+ *
+ * LTTng types.
+ *
+ * Copyright (C) 2010-2012 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; only
+ * version 2.1 of the License.
+ *
+ * This library 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
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include <linux/seq_file.h>
+#include "lttng.h"
+#include "../lttng-events.h"
+#include "../lttng-tracer.h"
+#include "../lttng-endian.h"
+
+#endif /* _LTTNG_PROBES_LTTNG_TYPES_H */
+
+/* Export enumerations */
+
+#ifdef STAGE_EXPORT_ENUMS
+
+#undef TRACE_EVENT_TYPE
+#define TRACE_EVENT_TYPE(_name, _abstract_type, args...)
+
+#undef TRACE_EVENT_ENUM
+#define TRACE_EVENT_ENUM(_name, _entries...)                           \
+       const struct lttng_enum_entry __trace_event_enum_##_name[] = {  \
+               PARAMS(_entries)                                        \
+       };
+
+/* Enumeration entry (single value) */
+#undef V
+#define V(_string)             { _string, _string, #_string}
+
+/* Enumeration entry (range) */
+#undef R
+#define R(_string, _range_start, _range_end)                           \
+       { _range_start, _range_end, #_string }
+
+#endif /* STAGE_EXPORT_ENUMS */
+
+
+/* Export named types */
+
+#ifdef STAGE_EXPORT_TYPES
+
+#undef TRACE_EVENT_TYPE___enum
+#define TRACE_EVENT_TYPE___enum(_name, _container_type)                        \
+               {                                                       \
+                 .name = #_name,                                       \
+                 .container_type = __type_integer(_container_type, __BYTE_ORDER, 10, none), \
+                 .entries = __trace_event_enum_##_name, \
+                 .len = ARRAY_SIZE(__trace_event_enum_##_name), \
+               },
+
+/* Local declaration */
+#undef TRACE_EVENT_TYPE
+#define TRACE_EVENT_TYPE(_name, _abstract_type, args...)       \
+               TRACE_EVENT_TYPE___##_abstract_type(_name, args)
+
+#undef TRACE_EVENT_ENUM
+#define TRACE_EVENT_ENUM(_name, _entries...)
+
+#endif /* STAGE_EXPORT_TYPES */
diff --git a/drivers/staging/lttng/probes/lttng.h b/drivers/staging/lttng/probes/lttng.h
new file mode 100644 (file)
index 0000000..a198ed2
--- /dev/null
@@ -0,0 +1,27 @@
+#ifndef _LTTNG_PROBES_LTTNG_H
+#define _LTTNG_PROBES_LTTNG_H
+
+/*
+ * lttng.h
+ *
+ * Copyright (C) 2010-2012 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; only
+ * version 2.1 of the License.
+ *
+ * This library 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
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#undef PARAMS
+#define PARAMS(args...)                args
+
+#endif /* _LTTNG_PROBES_LTTNG_H */
diff --git a/drivers/staging/lttng/wrapper/compiler.h b/drivers/staging/lttng/wrapper/compiler.h
new file mode 100644 (file)
index 0000000..0c01632
--- /dev/null
@@ -0,0 +1,42 @@
+#ifndef _LTTNG_WRAPPER_COMPILER_H
+#define _LTTNG_WRAPPER_COMPILER_H
+
+/*
+ * wrapper/compiler.h
+ *
+ * Copyright (C) 2013 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; only
+ * version 2.1 of the License.
+ *
+ * This library 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
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include <linux/compiler.h>
+
+/*
+ * Don't allow compiling with buggy compiler.
+ */
+
+#ifdef GCC_VERSION
+
+/*
+ * http://gcc.gnu.org/bugzilla/show_bug.cgi?id=58854
+ */
+# ifdef __ARMEL__
+#  if GCC_VERSION >= 40800 && GCC_VERSION <= 40802
+#   error Your gcc version produces clobbered frame accesses
+#  endif
+# endif
+#endif
+
+#endif /* _LTTNG_WRAPPER_COMPILER_H */
diff --git a/drivers/staging/lttng/wrapper/fdtable.c b/drivers/staging/lttng/wrapper/fdtable.c
new file mode 100644 (file)
index 0000000..a44beb5
--- /dev/null
@@ -0,0 +1,57 @@
+/*
+ * wrapper/fdtable.c
+ *
+ * Copyright (C) 2013 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; only
+ * version 2.1 of the License.
+ *
+ * This library 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
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include <linux/version.h>
+#include <linux/spinlock.h>
+#include "fdtable.h"
+
+#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,7,0))
+
+/*
+ * Reimplementation of iterate_fd() for kernels between 2.6.32 and 3.6
+ * (inclusive).
+ */
+int lttng_iterate_fd(struct files_struct *files,
+               unsigned int first,
+               int (*cb)(const void *, struct file *, unsigned int),
+               const void *ctx)
+{
+       struct fdtable *fdt;
+       struct file *filp;
+       unsigned int i;
+       int res = 0;
+
+       if (!files)
+               return 0;
+       spin_lock(&files->file_lock);
+       fdt = files_fdtable(files);
+       for (i = 0; i < fdt->max_fds; i++) {
+               filp = fcheck_files(files, i);
+               if (!filp)
+                       continue;
+               res = cb(ctx, filp, i);
+               if (res)
+                       break;
+       }
+       spin_unlock(&files->file_lock);
+       return res;
+}
+
+#endif
diff --git a/drivers/staging/lttng/wrapper/fdtable.h b/drivers/staging/lttng/wrapper/fdtable.h
new file mode 100644 (file)
index 0000000..7e74290
--- /dev/null
@@ -0,0 +1,44 @@
+#ifndef _LTTNG_WRAPPER_FDTABLE_H
+#define _LTTNG_WRAPPER_FDTABLE_H
+
+/*
+ * wrapper/fdtable.h
+ *
+ * Copyright (C) 2013 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; only
+ * version 2.1 of the License.
+ *
+ * This library 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
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include <linux/version.h>
+#include <linux/fdtable.h>
+
+#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,7,0))
+
+int lttng_iterate_fd(struct files_struct *files,
+               unsigned int first,
+               int (*cb)(const void *, struct file *, unsigned int),
+               const void *ctx);
+
+#else
+
+/*
+ * iterate_fd() appeared at commit
+ * c3c073f808b22dfae15ef8412b6f7b998644139a in the Linux kernel (first
+ * released kernel: v3.7).
+ */
+#define lttng_iterate_fd       iterate_fd
+
+#endif
+#endif /* _LTTNG_WRAPPER_FDTABLE_H */
diff --git a/drivers/staging/lttng/wrapper/ftrace.h b/drivers/staging/lttng/wrapper/ftrace.h
new file mode 100644 (file)
index 0000000..064f9c7
--- /dev/null
@@ -0,0 +1,84 @@
+#ifndef _LTTNG_WRAPPER_FTRACE_H
+#define _LTTNG_WRAPPER_FTRACE_H
+
+/*
+ * wrapper/ftrace.h
+ *
+ * wrapper around vmalloc_sync_all. Using KALLSYMS to get its address when
+ * available, else we need to have a kernel that exports this function to GPL
+ * modules.
+ *
+ * Copyright (C) 2011-2012 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; only
+ * version 2.1 of the License.
+ *
+ * This library 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
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include <linux/ftrace.h>
+
+#ifdef CONFIG_KALLSYMS
+
+#include <linux/kallsyms.h>
+#include "kallsyms.h"
+
+static inline
+int wrapper_register_ftrace_function_probe(char *glob,
+               struct ftrace_probe_ops *ops, void *data)
+{
+       int (*register_ftrace_function_probe_sym)(char *glob,
+                       struct ftrace_probe_ops *ops, void *data);
+
+       register_ftrace_function_probe_sym = (void *) kallsyms_lookup_funcptr("register_ftrace_function_probe");
+       if (register_ftrace_function_probe_sym) {
+               return register_ftrace_function_probe_sym(glob, ops, data);
+       } else {
+               printk(KERN_WARNING "LTTng: register_ftrace_function_probe symbol lookup failed.\n");
+               return -EINVAL;
+       }
+}
+
+static inline
+void wrapper_unregister_ftrace_function_probe(char *glob,
+               struct ftrace_probe_ops *ops, void *data)
+{
+       void (*unregister_ftrace_function_probe_sym)(char *glob,
+                       struct ftrace_probe_ops *ops, void *data);
+
+       unregister_ftrace_function_probe_sym = (void *) kallsyms_lookup_funcptr("unregister_ftrace_function_probe");
+       if (unregister_ftrace_function_probe_sym) {
+               unregister_ftrace_function_probe_sym(glob, ops, data);
+       } else {
+               printk(KERN_WARNING "LTTng: unregister_ftrace_function_probe symbol lookup failed.\n");
+               WARN_ON(1);
+       }
+}
+
+#else
+
+static inline
+int wrapper_register_ftrace_function_probe(char *glob,
+               struct ftrace_probe_ops *ops, void *data)
+{
+       return register_ftrace_function_probe(glob, ops, data);
+}
+
+static inline
+void wrapper_unregister_ftrace_function_probe(char *glob,
+               struct ftrace_probe_ops *ops, void *data)
+{
+       return unregister_ftrace_function_probe(glob, ops, data);
+}
+#endif
+
+#endif /* _LTTNG_WRAPPER_FTRACE_H */
diff --git a/drivers/staging/lttng/wrapper/inline_memcpy.h b/drivers/staging/lttng/wrapper/inline_memcpy.h
new file mode 100644 (file)
index 0000000..6410748
--- /dev/null
@@ -0,0 +1,23 @@
+/*
+ * wrapper/inline_memcpy.h
+ *
+ * Copyright (C) 2010-2012 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; only
+ * version 2.1 of the License.
+ *
+ * This library 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
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#if !defined(__HAVE_ARCH_INLINE_MEMCPY) && !defined(inline_memcpy)
+#define inline_memcpy memcpy
+#endif
diff --git a/drivers/staging/lttng/wrapper/irq.h b/drivers/staging/lttng/wrapper/irq.h
new file mode 100644 (file)
index 0000000..b6feb0c
--- /dev/null
@@ -0,0 +1,38 @@
+#ifndef _LTTNG_WRAPPER_IRQ_H
+#define _LTTNG_WRAPPER_IRQ_H
+
+/*
+ * wrapper/irq.h
+ *
+ * wrapper around linux/irq.h.
+ *
+ * Copyright (C) 2013 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; only
+ * version 2.1 of the License.
+ *
+ * This library 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
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include <linux/version.h>
+
+/*
+ * Starting from the 3.12 Linux kernel, all architectures use the
+ * generic hard irqs system. More details can be seen at commit
+ * 0244ad004a54e39308d495fee0a2e637f8b5c317 in the Linux kernel GIT.
+ */
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,12,0) \
+       || defined(CONFIG_GENERIC_HARDIRQS))
+# define CONFIG_LTTNG_HAS_LIST_IRQ
+#endif
+
+#endif /* _LTTNG_WRAPPER_IRQ_H */
diff --git a/drivers/staging/lttng/wrapper/irqdesc.c b/drivers/staging/lttng/wrapper/irqdesc.c
new file mode 100644 (file)
index 0000000..6ae6a50
--- /dev/null
@@ -0,0 +1,58 @@
+/*
+ * wrapper/irqdesc.c
+ *
+ * wrapper around irq_to_desc. Using KALLSYMS to get its address when
+ * available, else we need to have a kernel that exports this function to GPL
+ * modules.
+ *
+ * Copyright (C) 2011-2012 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; only
+ * version 2.1 of the License.
+ *
+ * This library 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
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#ifdef CONFIG_KALLSYMS
+
+#include <linux/kallsyms.h>
+#include <linux/interrupt.h>
+#include <linux/irqnr.h>
+#include "kallsyms.h"
+#include "irqdesc.h"
+
+static
+struct irq_desc *(*irq_to_desc_sym)(unsigned int irq);
+
+struct irq_desc *wrapper_irq_to_desc(unsigned int irq)
+{
+       if (!irq_to_desc_sym)
+               irq_to_desc_sym = (void *) kallsyms_lookup_funcptr("irq_to_desc");
+       if (irq_to_desc_sym) {
+               return irq_to_desc_sym(irq);
+       } else {
+               printk(KERN_WARNING "LTTng: irq_to_desc symbol lookup failed.\n");
+               return NULL;
+       }
+}
+
+#else
+
+#include <linux/interrupt.h>
+#include <linux/irqnr.h>
+
+struct irq_desc *wrapper_irq_to_desc(unsigned int irq)
+{
+       return irq_to_desc(irq);
+}
+
+#endif
diff --git a/drivers/staging/lttng/wrapper/irqdesc.h b/drivers/staging/lttng/wrapper/irqdesc.h
new file mode 100644 (file)
index 0000000..d702de1
--- /dev/null
@@ -0,0 +1,33 @@
+#ifndef _LTTNG_WRAPPER_IRQDESC_H
+#define _LTTNG_WRAPPER_IRQDESC_H
+
+/*
+ * wrapper/irqdesc.h
+ *
+ * wrapper around irq_to_desc. Using KALLSYMS to get its address when
+ * available, else we need to have a kernel that exports this function to GPL
+ * modules.
+ *
+ * Copyright (C) 2011-2012 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; only
+ * version 2.1 of the License.
+ *
+ * This library 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
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include <linux/interrupt.h>
+#include <linux/irqnr.h>
+
+struct irq_desc *wrapper_irq_to_desc(unsigned int irq);
+
+#endif /* _LTTNG_WRAPPER_IRQDESC_H */
diff --git a/drivers/staging/lttng/wrapper/kallsyms.h b/drivers/staging/lttng/wrapper/kallsyms.h
new file mode 100644 (file)
index 0000000..ad9e1f2
--- /dev/null
@@ -0,0 +1,51 @@
+#ifndef _LTTNG_WRAPPER_KALLSYMS_H
+#define _LTTNG_WRAPPER_KALLSYMS_H
+
+/*
+ * wrapper/kallsyms.h
+ *
+ * wrapper around kallsyms_lookup_name. Implements arch-dependent code for
+ * arches where the address of the start of the function body is different
+ * from the pointer which can be used to call the function, e.g. ARM THUMB2.
+ *
+ * Copyright (C) 2011 Avik Sil (avik.sil@linaro.org)
+ * Copyright (C) 2011-2012 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; only
+ * version 2.1 of the License.
+ *
+ * This library 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
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include <linux/kallsyms.h>
+
+static inline
+unsigned long kallsyms_lookup_funcptr(const char *name)
+{
+       unsigned long addr;
+
+       addr = kallsyms_lookup_name(name);
+#ifdef CONFIG_ARM
+#ifdef CONFIG_THUMB2_KERNEL
+       if (addr)
+               addr |= 1; /* set bit 0 in address for thumb mode */
+#endif
+#endif
+       return addr;
+}
+
+static inline
+unsigned long kallsyms_lookup_dataptr(const char *name)
+{
+       return kallsyms_lookup_name(name);
+}
+#endif /* _LTTNG_WRAPPER_KALLSYMS_H */
diff --git a/drivers/staging/lttng/wrapper/nsproxy.h b/drivers/staging/lttng/wrapper/nsproxy.h
new file mode 100644 (file)
index 0000000..e9766ef
--- /dev/null
@@ -0,0 +1,42 @@
+#ifndef _LTTNG_WRAPPER_NSPROXY_H
+#define _LTTNG_WRAPPER_NSPROXY_H
+
+/*
+ * wrapper/nsproxy.h
+ *
+ * Copyright (C) 2011-2012 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; only
+ * version 2.1 of the License.
+ *
+ * This library 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
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include <linux/version.h>
+#include <linux/nsproxy.h>
+
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,11,0))
+static inline
+struct pid_namespace *lttng_get_proxy_pid_ns(struct nsproxy *proxy)
+{
+       return proxy->pid_ns_for_children;
+}
+#else
+static inline
+struct pid_namespace *lttng_get_proxy_pid_ns(struct nsproxy *proxy)
+{
+       return proxy->pid_ns;
+}
+#endif
+
+
+#endif /* _LTTNG_WRAPPER_NSPROXY_H */
diff --git a/drivers/staging/lttng/wrapper/perf.h b/drivers/staging/lttng/wrapper/perf.h
new file mode 100644 (file)
index 0000000..5de205c
--- /dev/null
@@ -0,0 +1,71 @@
+#ifndef _LTTNG_WRAPPER_PERF_H
+#define _LTTNG_WRAPPER_PERF_H
+
+/*
+ * wrapper/perf.h
+ *
+ * Copyright (C) 2010-2012 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; only
+ * version 2.1 of the License.
+ *
+ * This library 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
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include <linux/perf_event.h>
+
+#if defined(CONFIG_PERF_EVENTS) && (LINUX_VERSION_CODE >= KERNEL_VERSION(3,0,99))
+static inline struct perf_event *
+wrapper_perf_event_create_kernel_counter(struct perf_event_attr *attr,
+                               int cpu,
+                               struct task_struct *task,
+                               perf_overflow_handler_t callback)
+{
+       return perf_event_create_kernel_counter(attr, cpu, task, callback, NULL);
+}
+#else /* defined(CONFIG_PERF_EVENTS) && (LINUX_VERSION_CODE >= KERNEL_VERSION(3,0,99)) */
+
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,37))
+static inline struct perf_event *
+wrapper_perf_event_create_kernel_counter(struct perf_event_attr *attr,
+                               int cpu,
+                               struct task_struct *task,
+                               perf_overflow_handler_t callback)
+{
+       return perf_event_create_kernel_counter(attr, cpu, task, callback);
+}
+#else /* (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,37)) */
+static inline struct perf_event *
+wrapper_perf_event_create_kernel_counter(struct perf_event_attr *attr,
+                               int cpu,
+                               struct task_struct *task,
+                               perf_overflow_handler_t callback)
+{
+       pid_t pid;
+
+       if (!task)
+               pid = -1;
+       else
+               pid = task->pid;
+
+       return perf_event_create_kernel_counter(attr, cpu, pid, callback);
+}
+
+#endif /* (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,37)) */
+
+#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,36))
+#define local64_read(l)                atomic64_read(l)
+#endif
+
+#endif /* defined(CONFIG_PERF_EVENTS) && (LINUX_VERSION_CODE >= KERNEL_VERSION(3,0,99)) */
+
+#endif /* _LTTNG_WRAPPER_PERF_H */
diff --git a/drivers/staging/lttng/wrapper/poll.h b/drivers/staging/lttng/wrapper/poll.h
new file mode 100644 (file)
index 0000000..c26610e
--- /dev/null
@@ -0,0 +1,33 @@
+#ifndef _LTTNG_WRAPPER_POLL_H
+#define _LTTNG_WRAPPER_POLL_H
+
+/*
+ * wrapper/poll.h
+ *
+ * Copyright (C) 2011-2012 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; only
+ * version 2.1 of the License.
+ *
+ * This library 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
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include <linux/poll.h>
+
+/*
+ * Note: poll_wait_set_exclusive() is defined as no-op. Thundering herd
+ * effect can be noticed with large number of consumer threads.
+ */
+
+#define poll_wait_set_exclusive(poll_table)
+
+#endif /* _LTTNG_WRAPPER_POLL_H */
diff --git a/drivers/staging/lttng/wrapper/random.c b/drivers/staging/lttng/wrapper/random.c
new file mode 100644 (file)
index 0000000..4c27fb9
--- /dev/null
@@ -0,0 +1,77 @@
+/*
+ * wrapper/random.c
+ *
+ * wrapper around bootid read. Using KALLSYMS to get its address when
+ * available, else we need to have a kernel that exports this function to GPL
+ * modules.
+ *
+ * Copyright (C) 2011-2012 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; only
+ * version 2.1 of the License.
+ *
+ * This library 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
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+/* boot_id depends on sysctl */
+#if defined(CONFIG_SYSCTL)
+
+#include <linux/fs.h>
+#include <linux/file.h>
+#include <linux/sched.h>
+#include <linux/uaccess.h>
+#include "random.h"
+
+/*
+ * Returns string boot id.
+ */
+int wrapper_get_bootid(char *bootid)
+{
+       struct file *file;
+       int ret;
+       ssize_t len;
+       mm_segment_t old_fs;
+
+       file = filp_open("/proc/sys/kernel/random/boot_id", O_RDONLY, 0);
+       if (IS_ERR(file))
+               return PTR_ERR(file);
+
+       old_fs = get_fs();
+       set_fs(KERNEL_DS);
+
+       if (!file->f_op || !file->f_op->read) {
+               ret = -EINVAL;
+               goto end;
+       }
+
+       len = file->f_op->read(file, bootid, BOOT_ID_LEN - 1, &file->f_pos);
+       if (len != BOOT_ID_LEN - 1) {
+               ret = -EINVAL;
+               goto end;
+       }
+
+       bootid[BOOT_ID_LEN - 1] = '\0';
+       ret = 0;
+end:
+       set_fs(old_fs);
+       filp_close(file, current->files);
+       return ret;
+}
+
+#else
+
+int wrapper_get_bootid(char *bootid)
+{
+       return -ENOSYS;
+}
+
+#endif
diff --git a/drivers/staging/lttng/wrapper/random.h b/drivers/staging/lttng/wrapper/random.h
new file mode 100644 (file)
index 0000000..8f13c18
--- /dev/null
@@ -0,0 +1,32 @@
+#ifndef _LTTNG_WRAPPER_RANDOM_H
+#define _LTTNG_WRAPPER_RANDOM_H
+
+/*
+ * wrapper/random.h
+ *
+ * wrapper around bootid read. Using KALLSYMS to get its address when
+ * available, else we need to have a kernel that exports this function to GPL
+ * modules.
+ *
+ * Copyright (C) 2011-2012 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; only
+ * version 2.1 of the License.
+ *
+ * This library 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
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#define BOOT_ID_LEN    37
+
+int wrapper_get_bootid(char *bootid);
+
+#endif /* _LTTNG_WRAPPER_RANDOM_H */
diff --git a/drivers/staging/lttng/wrapper/ringbuffer/api.h b/drivers/staging/lttng/wrapper/ringbuffer/api.h
new file mode 100644 (file)
index 0000000..182bee2
--- /dev/null
@@ -0,0 +1 @@
+#include "../../lib/ringbuffer/api.h"
diff --git a/drivers/staging/lttng/wrapper/ringbuffer/backend.h b/drivers/staging/lttng/wrapper/ringbuffer/backend.h
new file mode 100644 (file)
index 0000000..bfdd39d
--- /dev/null
@@ -0,0 +1 @@
+#include "../../lib/ringbuffer/backend.h"
diff --git a/drivers/staging/lttng/wrapper/ringbuffer/backend_internal.h b/drivers/staging/lttng/wrapper/ringbuffer/backend_internal.h
new file mode 100644 (file)
index 0000000..00d45e4
--- /dev/null
@@ -0,0 +1,2 @@
+#include "../../wrapper/inline_memcpy.h"
+#include "../../lib/ringbuffer/backend_internal.h"
diff --git a/drivers/staging/lttng/wrapper/ringbuffer/backend_types.h b/drivers/staging/lttng/wrapper/ringbuffer/backend_types.h
new file mode 100644 (file)
index 0000000..c59effd
--- /dev/null
@@ -0,0 +1 @@
+#include "../../lib/ringbuffer/backend_types.h"
diff --git a/drivers/staging/lttng/wrapper/ringbuffer/config.h b/drivers/staging/lttng/wrapper/ringbuffer/config.h
new file mode 100644 (file)
index 0000000..0ce7a9d
--- /dev/null
@@ -0,0 +1 @@
+#include "../../lib/ringbuffer/config.h"
diff --git a/drivers/staging/lttng/wrapper/ringbuffer/frontend.h b/drivers/staging/lttng/wrapper/ringbuffer/frontend.h
new file mode 100644 (file)
index 0000000..7c6c070
--- /dev/null
@@ -0,0 +1 @@
+#include "../../lib/ringbuffer/frontend.h"
diff --git a/drivers/staging/lttng/wrapper/ringbuffer/frontend_api.h b/drivers/staging/lttng/wrapper/ringbuffer/frontend_api.h
new file mode 100644 (file)
index 0000000..b03c501
--- /dev/null
@@ -0,0 +1 @@
+#include "../../lib/ringbuffer/frontend_api.h"
diff --git a/drivers/staging/lttng/wrapper/ringbuffer/frontend_internal.h b/drivers/staging/lttng/wrapper/ringbuffer/frontend_internal.h
new file mode 100644 (file)
index 0000000..1899101
--- /dev/null
@@ -0,0 +1 @@
+#include "../../lib/ringbuffer/frontend_internal.h"
diff --git a/drivers/staging/lttng/wrapper/ringbuffer/frontend_types.h b/drivers/staging/lttng/wrapper/ringbuffer/frontend_types.h
new file mode 100644 (file)
index 0000000..0c23244
--- /dev/null
@@ -0,0 +1 @@
+#include "../../lib/ringbuffer/frontend_types.h"
diff --git a/drivers/staging/lttng/wrapper/ringbuffer/iterator.h b/drivers/staging/lttng/wrapper/ringbuffer/iterator.h
new file mode 100644 (file)
index 0000000..76e9edb
--- /dev/null
@@ -0,0 +1 @@
+#include "../../lib/ringbuffer/iterator.h"
diff --git a/drivers/staging/lttng/wrapper/ringbuffer/nohz.h b/drivers/staging/lttng/wrapper/ringbuffer/nohz.h
new file mode 100644 (file)
index 0000000..9fbb84d
--- /dev/null
@@ -0,0 +1 @@
+#include "../../lib/ringbuffer/nohz.h"
diff --git a/drivers/staging/lttng/wrapper/ringbuffer/vatomic.h b/drivers/staging/lttng/wrapper/ringbuffer/vatomic.h
new file mode 100644 (file)
index 0000000..d578445
--- /dev/null
@@ -0,0 +1 @@
+#include "../../lib/ringbuffer/vatomic.h"
diff --git a/drivers/staging/lttng/wrapper/ringbuffer/vfs.h b/drivers/staging/lttng/wrapper/ringbuffer/vfs.h
new file mode 100644 (file)
index 0000000..f8e9ed9
--- /dev/null
@@ -0,0 +1 @@
+#include "../../lib/ringbuffer/vfs.h"
diff --git a/drivers/staging/lttng/wrapper/spinlock.h b/drivers/staging/lttng/wrapper/spinlock.h
new file mode 100644 (file)
index 0000000..bc71b4f
--- /dev/null
@@ -0,0 +1,47 @@
+#ifndef _LTTNG_WRAPPER_SPINLOCK_H
+#define _LTTNG_WRAPPER_SPINLOCK_H
+
+/*
+ * wrapper/spinlock.h
+ *
+ * Copyright (C) 2011-2012 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; only
+ * version 2.1 of the License.
+ *
+ * This library 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
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include <linux/version.h>
+
+#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,33))
+
+#include <linux/string.h>
+
+#define raw_spin_lock_init(lock)                                       \
+       do {                                                            \
+               raw_spinlock_t __lock = __RAW_SPIN_LOCK_UNLOCKED;       \
+               memcpy(lock, &__lock, sizeof(lock));                    \
+       } while (0)
+
+#define raw_spin_is_locked(lock)       __raw_spin_is_locked(lock)
+
+#define wrapper_desc_spin_lock(lock)   spin_lock(lock)
+#define wrapper_desc_spin_unlock(lock) spin_unlock(lock)
+
+#else
+
+#define wrapper_desc_spin_lock(lock)   raw_spin_lock(lock)
+#define wrapper_desc_spin_unlock(lock) raw_spin_unlock(lock)
+
+#endif
+#endif /* _LTTNG_WRAPPER_SPINLOCK_H */
diff --git a/drivers/staging/lttng/wrapper/splice.c b/drivers/staging/lttng/wrapper/splice.c
new file mode 100644 (file)
index 0000000..e499660
--- /dev/null
@@ -0,0 +1,60 @@
+/*
+ * wrapper/splice.c
+ *
+ * wrapper around splice_to_pipe. Using KALLSYMS to get its address when
+ * available, else we need to have a kernel that exports this function to GPL
+ * modules.
+ *
+ * Copyright (C) 2011-2012 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; only
+ * version 2.1 of the License.
+ *
+ * This library 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
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#ifdef CONFIG_KALLSYMS
+
+#include <linux/kallsyms.h>
+#include <linux/fs.h>
+#include <linux/splice.h>
+#include "kallsyms.h"
+
+static
+ssize_t (*splice_to_pipe_sym)(struct pipe_inode_info *pipe,
+                             struct splice_pipe_desc *spd);
+
+ssize_t wrapper_splice_to_pipe(struct pipe_inode_info *pipe,
+                              struct splice_pipe_desc *spd)
+{
+       if (!splice_to_pipe_sym)
+               splice_to_pipe_sym = (void *) kallsyms_lookup_funcptr("splice_to_pipe");
+       if (splice_to_pipe_sym) {
+               return splice_to_pipe_sym(pipe, spd);
+       } else {
+               printk(KERN_WARNING "LTTng: splice_to_pipe symbol lookup failed.\n");
+               return -ENOSYS;
+       }
+}
+
+#else
+
+#include <linux/fs.h>
+#include <linux/splice.h>
+
+ssize_t wrapper_splice_to_pipe(struct pipe_inode_info *pipe,
+                              struct splice_pipe_desc *spd)
+{
+       return splice_to_pipe(pipe, spd);
+}
+
+#endif
diff --git a/drivers/staging/lttng/wrapper/splice.h b/drivers/staging/lttng/wrapper/splice.h
new file mode 100644 (file)
index 0000000..91eb864
--- /dev/null
@@ -0,0 +1,37 @@
+#ifndef _LTTNG_WRAPPER_SPLICE_H
+#define _LTTNG_WRAPPER_SPLICE_H
+
+/*
+ * wrapper/splice.h
+ *
+ * wrapper around splice_to_pipe. Using KALLSYMS to get its address when
+ * available, else we need to have a kernel that exports this function to GPL
+ * modules.
+ *
+ * Copyright (C) 2011-2012 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; only
+ * version 2.1 of the License.
+ *
+ * This library 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
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include <linux/splice.h>
+
+ssize_t wrapper_splice_to_pipe(struct pipe_inode_info *pipe,
+                              struct splice_pipe_desc *spd);
+
+#ifndef PIPE_DEF_BUFFERS
+#define PIPE_DEF_BUFFERS 16
+#endif
+
+#endif /* _LTTNG_WRAPPER_SPLICE_H */
diff --git a/drivers/staging/lttng/wrapper/trace-clock.h b/drivers/staging/lttng/wrapper/trace-clock.h
new file mode 100644 (file)
index 0000000..9c0c806
--- /dev/null
@@ -0,0 +1,102 @@
+#ifndef _LTTNG_TRACE_CLOCK_H
+#define _LTTNG_TRACE_CLOCK_H
+
+/*
+ * wrapper/trace-clock.h
+ *
+ * Contains LTTng trace clock mapping to LTTng trace clock or mainline monotonic
+ * clock. This wrapper depends on CONFIG_HIGH_RES_TIMERS=y.
+ *
+ * Copyright (C) 2011-2012 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; only
+ * version 2.1 of the License.
+ *
+ * This library 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
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#ifdef CONFIG_HAVE_TRACE_CLOCK
+#include <linux/trace-clock.h>
+#else /* CONFIG_HAVE_TRACE_CLOCK */
+
+#include <linux/hardirq.h>
+#include <linux/ktime.h>
+#include <linux/time.h>
+#include <linux/hrtimer.h>
+#include <linux/version.h>
+#include "../lttng-kernel-version.h"
+#include "random.h"
+
+#if LTTNG_KERNEL_RANGE(3,10,0, 3,10,14) || LTTNG_KERNEL_RANGE(3,11,0, 3,11,3)
+#error "Linux kernels 3.10 and 3.11 introduce a deadlock in the timekeeping subsystem. Fixed by commit 7bd36014460f793c19e7d6c94dab67b0afcfcb7f \"timekeeping: Fix HRTICK related deadlock from ntp lock changes\" in Linux."
+#endif
+
+static inline u64 trace_clock_monotonic_wrapper(void)
+{
+       ktime_t ktime;
+
+       /*
+        * Refuse to trace from NMIs with this wrapper, because an NMI could
+        * nest over the xtime write seqlock and deadlock.
+        */
+       if (in_nmi())
+               return (u64) -EIO;
+
+       ktime = ktime_get();
+       return ktime_to_ns(ktime);
+}
+
+static inline u32 trace_clock_read32(void)
+{
+       return (u32) trace_clock_monotonic_wrapper();
+}
+
+static inline u64 trace_clock_read64(void)
+{
+       return (u64) trace_clock_monotonic_wrapper();
+}
+
+static inline u64 trace_clock_freq(void)
+{
+       return (u64) NSEC_PER_SEC;
+}
+
+static inline int trace_clock_uuid(char *uuid)
+{
+       return wrapper_get_bootid(uuid);
+}
+
+static inline int get_trace_clock(void)
+{
+       /*
+        * LTTng: Using mainline kernel monotonic clock. NMIs will not be
+        * traced, and expect significant performance degradation compared to
+        * the LTTng trace clocks. Integration of the LTTng 0.x trace clocks
+        * into LTTng 2.0 is planned in a near future.
+        */
+       printk(KERN_WARNING "LTTng: Using mainline kernel monotonic clock.\n");
+       printk(KERN_WARNING "  * NMIs will not be traced,\n");
+       printk(KERN_WARNING "  * expect significant performance degradation compared to the\n");
+       printk(KERN_WARNING "    LTTng trace clocks.\n");
+       printk(KERN_WARNING "Integration of the LTTng 0.x trace clocks into LTTng 2.0 is planned\n");
+       printk(KERN_WARNING "in a near future.\n");
+
+       return 0;
+}
+
+static inline void put_trace_clock(void)
+{
+}
+
+#endif /* CONFIG_HAVE_TRACE_CLOCK */
+
+#endif /* _LTTNG_TRACE_CLOCK_H */
diff --git a/drivers/staging/lttng/wrapper/tracepoint.h b/drivers/staging/lttng/wrapper/tracepoint.h
new file mode 100644 (file)
index 0000000..798d785
--- /dev/null
@@ -0,0 +1,44 @@
+#ifndef _LTTNG_WRAPPER_TRACEPOINT_H
+#define _LTTNG_WRAPPER_TRACEPOINT_H
+
+/*
+ * wrapper/tracepoint.h
+ *
+ * wrapper around DECLARE_EVENT_CLASS.
+ *
+ * Copyright (C) 2011-2012 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; only
+ * version 2.1 of the License.
+ *
+ * This library 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
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include <linux/version.h>
+#include <linux/tracepoint.h>
+
+#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,35))
+
+#define DECLARE_EVENT_CLASS(name, proto, args, tstruct, assign, print)
+
+#endif
+
+#ifndef HAVE_KABI_2635_TRACEPOINT
+
+#define kabi_2635_tracepoint_probe_register tracepoint_probe_register
+#define kabi_2635_tracepoint_probe_unregister tracepoint_probe_unregister
+#define kabi_2635_tracepoint_probe_register_noupdate tracepoint_probe_register_noupdate
+#define kabi_2635_tracepoint_probe_unregister_noupdate tracepoint_probe_unregister_noupdate
+
+#endif /* HAVE_KABI_2635_TRACEPOINT */
+
+#endif /* _LTTNG_WRAPPER_TRACEPOINT_H */
diff --git a/drivers/staging/lttng/wrapper/uuid.h b/drivers/staging/lttng/wrapper/uuid.h
new file mode 100644 (file)
index 0000000..48b1a9f
--- /dev/null
@@ -0,0 +1,43 @@
+#ifndef _LTTNG_WRAPPER_UUID_H
+#define _LTTNG_WRAPPER_UUID_H
+
+/*
+ * wrapper/uuid.h
+ *
+ * Copyright (C) 2011-2012 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; only
+ * version 2.1 of the License.
+ *
+ * This library 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
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include <linux/version.h>
+
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,35))
+#include <linux/uuid.h>
+#else
+
+#include <linux/random.h>
+
+typedef struct {
+       __u8 b[16];
+} uuid_le;
+
+static inline
+void uuid_le_gen(uuid_le *u)
+{
+       generate_random_uuid(u->b);
+}
+
+#endif
+#endif /* _LTTNG_WRAPPER_UUID_H */
diff --git a/drivers/staging/lttng/wrapper/vmalloc.h b/drivers/staging/lttng/wrapper/vmalloc.h
new file mode 100644 (file)
index 0000000..cb755ee
--- /dev/null
@@ -0,0 +1,63 @@
+#ifndef _LTTNG_WRAPPER_VMALLOC_H
+#define _LTTNG_WRAPPER_VMALLOC_H
+
+/*
+ * wrapper/vmalloc.h
+ *
+ * wrapper around vmalloc_sync_all. Using KALLSYMS to get its address when
+ * available, else we need to have a kernel that exports this function to GPL
+ * modules.
+ *
+ * Copyright (C) 2011-2012 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; only
+ * version 2.1 of the License.
+ *
+ * This library 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
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#ifdef CONFIG_KALLSYMS
+
+#include <linux/kallsyms.h>
+#include "kallsyms.h"
+
+static inline
+void wrapper_vmalloc_sync_all(void)
+{
+       void (*vmalloc_sync_all_sym)(void);
+
+       vmalloc_sync_all_sym = (void *) kallsyms_lookup_funcptr("vmalloc_sync_all");
+       if (vmalloc_sync_all_sym) {
+               vmalloc_sync_all_sym();
+       } else {
+#ifdef CONFIG_X86
+               /*
+                * Only x86 needs vmalloc_sync_all to make sure LTTng does not
+                * trigger recursive page faults.
+                */
+               printk(KERN_WARNING "LTTng: vmalloc_sync_all symbol lookup failed.\n");
+               printk(KERN_WARNING "Page fault handler and NMI tracing might trigger faults.\n");
+#endif
+       }
+}
+#else
+
+#include <linux/vmalloc.h>
+
+static inline
+void wrapper_vmalloc_sync_all(void)
+{
+       return vmalloc_sync_all();
+}
+#endif
+
+#endif /* _LTTNG_WRAPPER_VMALLOC_H */
diff --git a/drivers/staging/lttng/wrapper/writeback.h b/drivers/staging/lttng/wrapper/writeback.h
new file mode 100644 (file)
index 0000000..492cb75
--- /dev/null
@@ -0,0 +1,61 @@
+#ifndef _LTTNG_WRAPPER_WRITEBACK_H
+#define _LTTNG_WRAPPER_WRITEBACK_H
+
+/*
+ * wrapper/writeback.h
+ *
+ * wrapper around global_dirty_limit read. Using KALLSYMS with KALLSYMS_ALL
+ * to get its address when available, else we need to have a kernel that
+ * exports this variable to GPL modules.
+ *
+ * Copyright (C) 2013 Mentor Graphics Corp.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; only
+ * version 2.1 of the License.
+ *
+ * This library 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
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#ifdef CONFIG_KALLSYMS_ALL
+
+#include <linux/kallsyms.h>
+#include "kallsyms.h"
+
+static unsigned long *global_dirty_limit_sym;
+
+static inline
+unsigned long wrapper_global_dirty_limit(void)
+{
+       if (!global_dirty_limit_sym)
+               global_dirty_limit_sym =
+                       (void *) kallsyms_lookup_dataptr("global_dirty_limit");
+       if (global_dirty_limit_sym) {
+               return *global_dirty_limit_sym;
+       } else {
+               printk(KERN_WARNING "LTTng: global_dirty_limit symbol lookup failed.\n");
+               return 0;
+       }
+}
+
+#else
+
+#include <linux/writeback.h>
+
+static inline
+unsigned long wrapper_global_dirty_limit(void)
+{
+       return global_dirty_limit;
+}
+
+#endif
+
+#endif /* _LTTNG_WRAPPER_WRITEBACK_H */
index 1f3b0f9..8c101cb 100644 (file)
@@ -1201,8 +1201,6 @@ static int vpfe_start_streaming(struct vb2_queue *vq, unsigned int count)
        unsigned long addr;
        int ret;
 
-       if (count == 0)
-               return -ENOBUFS;
        ret = mutex_lock_interruptible(&video->lock);
        if (ret)
                goto streamoff;
@@ -1327,6 +1325,7 @@ static int vpfe_reqbufs(struct file *file, void *priv,
        q->type = req_buf->type;
        q->io_modes = VB2_MMAP | VB2_USERPTR;
        q->drv_priv = fh;
+       q->min_buffers_needed = 1;
        q->ops = &video_qops;
        q->mem_ops = &vb2_dma_contig_memops;
        q->buf_struct_size = sizeof(struct vpfe_cap_buffer);
index 79a09d0..8803e69 100644 (file)
@@ -299,12 +299,17 @@ static void _rcar_thermal_irq_ctrl(struct rcar_thermal_priv *priv, int enable)
 static void rcar_thermal_work(struct work_struct *work)
 {
        struct rcar_thermal_priv *priv;
+       unsigned long cctemp, nctemp;
 
        priv = container_of(work, struct rcar_thermal_priv, work.work);
 
+       rcar_thermal_get_temp(priv->zone, &cctemp);
        rcar_thermal_update_temp(priv);
        rcar_thermal_irq_enable(priv);
-       thermal_zone_device_update(priv->zone);
+
+       rcar_thermal_get_temp(priv->zone, &nctemp);
+       if (nctemp != cctemp)
+               thermal_zone_device_update(priv->zone);
 }
 
 static u32 rcar_thermal_had_changed(struct rcar_thermal_priv *priv, u32 status)
@@ -313,7 +318,7 @@ static u32 rcar_thermal_had_changed(struct rcar_thermal_priv *priv, u32 status)
 
        status = (status >> rcar_id_to_shift(priv)) & 0x3;
 
-       if (status & 0x3) {
+       if (status) {
                dev_dbg(dev, "thermal%d %s%s\n",
                        priv->id,
                        (status & 0x2) ? "Rising " : "",
@@ -369,10 +374,8 @@ static int rcar_thermal_probe(struct platform_device *pdev)
        int idle = IDLE_INTERVAL;
 
        common = devm_kzalloc(dev, sizeof(*common), GFP_KERNEL);
-       if (!common) {
-               dev_err(dev, "Could not allocate common\n");
+       if (!common)
                return -ENOMEM;
-       }
 
        INIT_LIST_HEAD(&common->head);
        spin_lock_init(&common->lock);
@@ -418,7 +421,6 @@ static int rcar_thermal_probe(struct platform_device *pdev)
 
                priv = devm_kzalloc(dev, sizeof(*priv), GFP_KERNEL);
                if (!priv) {
-                       dev_err(dev, "Could not allocate priv\n");
                        ret = -ENOMEM;
                        goto error_unregister;
                }
@@ -465,7 +467,7 @@ error_unregister:
                        rcar_thermal_irq_disable(priv);
        }
 
-       pm_runtime_put_sync(dev);
+       pm_runtime_put(dev);
        pm_runtime_disable(dev);
 
        return ret;
@@ -483,7 +485,7 @@ static int rcar_thermal_remove(struct platform_device *pdev)
                        rcar_thermal_irq_disable(priv);
        }
 
-       pm_runtime_put_sync(dev);
+       pm_runtime_put(dev);
        pm_runtime_disable(dev);
 
        return 0;
index be33d2b..2888efb 100644 (file)
@@ -428,7 +428,7 @@ static int sci_probe_regmap(struct plat_sci_port *cfg)
                cfg->regtype = SCIx_HSCIF_REGTYPE;
                break;
        default:
-               printk(KERN_ERR "Can't probe register map for given port\n");
+               pr_err("Can't probe register map for given port\n");
                return -EINVAL;
        }
 
@@ -788,7 +788,7 @@ static int sci_handle_errors(struct uart_port *port)
                if (tty_insert_flip_char(tport, 0, TTY_OVERRUN))
                        copied++;
 
-               dev_notice(port->dev, "overrun error");
+               dev_notice(port->dev, "overrun error\n");
        }
 
        if (status & SCxSR_FER(port)) {
@@ -830,7 +830,7 @@ static int sci_handle_errors(struct uart_port *port)
                if (tty_insert_flip_char(tport, 0, TTY_PARITY))
                        copied++;
 
-               dev_notice(port->dev, "parity error");
+               dev_notice(port->dev, "parity error\n");
        }
 
        if (copied)
@@ -911,7 +911,7 @@ static irqreturn_t sci_rx_interrupt(int irq, void *ptr)
                /* Disable future Rx interrupts */
                if (port->type == PORT_SCIFA || port->type == PORT_SCIFB) {
                        disable_irq_nosync(irq);
-                       scr |= 0x4000;
+                       scr |= SCSCR_RDRQE;
                } else {
                        scr &= ~SCSCR_RIE;
                }
@@ -1041,8 +1041,7 @@ static int sci_notifier(struct notifier_block *self,
 
        sci_port = container_of(self, struct sci_port, freq_transition);
 
-       if ((phase == CPUFREQ_POSTCHANGE) ||
-           (phase == CPUFREQ_RESUMECHANGE)) {
+       if (phase == CPUFREQ_POSTCHANGE) {
                struct uart_port *port = &sci_port->port;
 
                spin_lock_irqsave(&port->lock, flags);
@@ -1200,7 +1199,9 @@ static void sci_set_mctrl(struct uart_port *port, unsigned int mctrl)
                 */
                reg = sci_getreg(port, SCFCR);
                if (reg->size)
-                       serial_port_out(port, SCFCR, serial_port_in(port, SCFCR) | 1);
+                       serial_port_out(port, SCFCR,
+                                       serial_port_in(port, SCFCR) |
+                                       SCFCR_LOOP);
        }
 }
 
@@ -1290,7 +1291,8 @@ static void sci_dma_rx_complete(void *arg)
        unsigned long flags;
        int count;
 
-       dev_dbg(port->dev, "%s(%d) active #%d\n", __func__, port->line, s->active_rx);
+       dev_dbg(port->dev, "%s(%d) active #%d\n",
+               __func__, port->line, s->active_rx);
 
        spin_lock_irqsave(&port->lock, flags);
 
@@ -1366,8 +1368,8 @@ static void sci_submit_rx(struct sci_port *s)
                        sci_rx_dma_release(s, true);
                        return;
                }
-               dev_dbg(s->port.dev, "%s(): cookie %d to #%d\n", __func__,
-                       s->cookie_rx[i], i);
+               dev_dbg(s->port.dev, "%s(): cookie %d to #%d\n",
+                       __func__, s->cookie_rx[i], i);
        }
 
        s->active_rx = s->cookie_rx[0];
@@ -1401,7 +1403,7 @@ static void work_fn_rx(struct work_struct *work)
                unsigned long flags;
                int count;
 
-               chan->device->device_control(chan, DMA_TERMINATE_ALL, 0);
+               dmaengine_terminate_all(chan);
                dev_dbg(port->dev, "Read %zu bytes with cookie %d\n",
                        sh_desc->partial, sh_desc->cookie);
 
@@ -1426,8 +1428,8 @@ static void work_fn_rx(struct work_struct *work)
 
        s->active_rx = s->cookie_rx[!new];
 
-       dev_dbg(port->dev, "%s: cookie %d #%d, new active #%d\n", __func__,
-               s->cookie_rx[new], new, s->active_rx);
+       dev_dbg(port->dev, "%s: cookie %d #%d, new active #%d\n",
+               __func__, s->cookie_rx[new], new, s->active_rx);
 }
 
 static void work_fn_tx(struct work_struct *work)
@@ -1480,8 +1482,8 @@ static void work_fn_tx(struct work_struct *work)
                return;
        }
 
-       dev_dbg(port->dev, "%s: %p: %d...%d, cookie %d\n", __func__,
-               xmit->buf, xmit->tail, xmit->head, s->cookie_tx);
+       dev_dbg(port->dev, "%s: %p: %d...%d, cookie %d\n",
+               __func__, xmit->buf, xmit->tail, xmit->head, s->cookie_tx);
 
        dma_async_issue_pending(chan);
 }
@@ -1496,9 +1498,9 @@ static void sci_start_tx(struct uart_port *port)
        if (port->type == PORT_SCIFA || port->type == PORT_SCIFB) {
                u16 new, scr = serial_port_in(port, SCSCR);
                if (s->chan_tx)
-                       new = scr | 0x8000;
+                       new = scr | SCSCR_TDRQE;
                else
-                       new = scr & ~0x8000;
+                       new = scr & ~SCSCR_TDRQE;
                if (new != scr)
                        serial_port_out(port, SCSCR, new);
        }
@@ -1525,7 +1527,7 @@ static void sci_stop_tx(struct uart_port *port)
        ctrl = serial_port_in(port, SCSCR);
 
        if (port->type == PORT_SCIFA || port->type == PORT_SCIFB)
-               ctrl &= ~0x8000;
+               ctrl &= ~SCSCR_TDRQE;
 
        ctrl &= ~SCSCR_TIE;
 
@@ -1539,7 +1541,7 @@ static void sci_start_rx(struct uart_port *port)
        ctrl = serial_port_in(port, SCSCR) | port_rx_irq_mask(port);
 
        if (port->type == PORT_SCIFA || port->type == PORT_SCIFB)
-               ctrl &= ~0x4000;
+               ctrl &= ~SCSCR_RDRQE;
 
        serial_port_out(port, SCSCR, ctrl);
 }
@@ -1551,7 +1553,7 @@ static void sci_stop_rx(struct uart_port *port)
        ctrl = serial_port_in(port, SCSCR);
 
        if (port->type == PORT_SCIFA || port->type == PORT_SCIFB)
-               ctrl &= ~0x4000;
+               ctrl &= ~SCSCR_RDRQE;
 
        ctrl &= ~port_rx_irq_mask(port);
 
@@ -1600,8 +1602,8 @@ static bool filter(struct dma_chan *chan, void *slave)
 {
        struct sh_dmae_slave *param = slave;
 
-       dev_dbg(chan->device->dev, "%s: slave ID %d\n", __func__,
-               param->shdma_slave.slave_id);
+       dev_dbg(chan->device->dev, "%s: slave ID %d\n",
+               __func__, param->shdma_slave.slave_id);
 
        chan->private = &param->shdma_slave;
        return true;
@@ -1614,7 +1616,7 @@ static void rx_timer_fn(unsigned long arg)
        u16 scr = serial_port_in(port, SCSCR);
 
        if (port->type == PORT_SCIFA || port->type == PORT_SCIFB) {
-               scr &= ~0x4000;
+               scr &= ~SCSCR_RDRQE;
                enable_irq(s->irqs[SCIx_RXI_IRQ]);
        }
        serial_port_out(port, SCSCR, scr | SCSCR_RIE);
@@ -1630,8 +1632,7 @@ static void sci_request_dma(struct uart_port *port)
        dma_cap_mask_t mask;
        int nent;
 
-       dev_dbg(port->dev, "%s: port %d\n", __func__,
-               port->line);
+       dev_dbg(port->dev, "%s: port %d\n", __func__, port->line);
 
        if (s->cfg->dma_slave_tx <= 0 || s->cfg->dma_slave_rx <= 0)
                return;
@@ -1659,7 +1660,8 @@ static void sci_request_dma(struct uart_port *port)
                if (!nent)
                        sci_tx_dma_release(s, false);
                else
-                       dev_dbg(port->dev, "%s: mapped %d@%p to %pad\n", __func__,
+                       dev_dbg(port->dev, "%s: mapped %d@%p to %pad\n",
+                               __func__,
                                sg_dma_len(&s->sg_tx), port->state->xmit.buf,
                                &sg_dma_address(&s->sg_tx));
 
@@ -1781,30 +1783,71 @@ static unsigned int sci_scbrr_calc(struct sci_port *s, unsigned int bps,
        return ((freq + 16 * bps) / (32 * bps) - 1);
 }
 
+/* calculate frame length from SMR */
+static int sci_baud_calc_frame_len(unsigned int smr_val)
+{
+       int len = 10;
+
+       if (smr_val & SCSMR_CHR)
+               len--;
+       if (smr_val & SCSMR_PE)
+               len++;
+       if (smr_val & SCSMR_STOP)
+               len++;
+
+       return len;
+}
+
+
 /* calculate sample rate, BRR, and clock select for HSCIF */
 static void sci_baud_calc_hscif(unsigned int bps, unsigned long freq,
                                int *brr, unsigned int *srr,
-                               unsigned int *cks)
+                               unsigned int *cks, int frame_len)
 {
-       int sr, c, br, err;
+       int sr, c, br, err, recv_margin;
        int min_err = 1000; /* 100% */
+       int recv_max_margin = 0;
 
        /* Find the combination of sample rate and clock select with the
           smallest deviation from the desired baud rate. */
        for (sr = 8; sr <= 32; sr++) {
                for (c = 0; c <= 3; c++) {
                        /* integerized formulas from HSCIF documentation */
-                       br = freq / (sr * (1 << (2 * c + 1)) * bps) - 1;
-                       if (br < 0 || br > 255)
+                       br = DIV_ROUND_CLOSEST(freq, (sr *
+                                             (1 << (2 * c + 1)) * bps)) - 1;
+                       br = clamp(br, 0, 255);
+                       err = DIV_ROUND_CLOSEST(freq, ((br + 1) * bps * sr *
+                                              (1 << (2 * c + 1)) / 1000)) -
+                                              1000;
+                       if (err < 0)
                                continue;
-                       err = freq / ((br + 1) * bps * sr *
-                             (1 << (2 * c + 1)) / 1000) - 1000;
+
+                       /* Calc recv margin
+                        * M: Receive margin (%)
+                        * N: Ratio of bit rate to clock (N = sampling rate)
+                        * D: Clock duty (D = 0 to 1.0)
+                        * L: Frame length (L = 9 to 12)
+                        * F: Absolute value of clock frequency deviation
+                        *
+                        *  M = |(0.5 - 1 / 2 * N) - ((L - 0.5) * F) -
+                        *      (|D - 0.5| / N * (1 + F))|
+                        *  NOTE: Usually, treat D for 0.5, F is 0 by this
+                        *        calculation.
+                        */
+                       recv_margin = abs((500 -
+                                       DIV_ROUND_CLOSEST(1000, sr << 1)) / 10);
                        if (min_err > err) {
                                min_err = err;
-                               *brr = br;
-                               *srr = sr - 1;
-                               *cks = c;
-                       }
+                               recv_max_margin = recv_margin;
+                       } else if ((min_err == err) &&
+                                  (recv_margin > recv_max_margin))
+                               recv_max_margin = recv_margin;
+                       else
+                               continue;
+
+                       *brr = br;
+                       *srr = sr - 1;
+                       *cks = c;
                }
        }
 
@@ -1838,10 +1881,19 @@ static void sci_set_termios(struct uart_port *port, struct ktermios *termios,
 {
        struct sci_port *s = to_sci_port(port);
        struct plat_sci_reg *reg;
-       unsigned int baud, smr_val, max_baud, cks = 0;
+       unsigned int baud, smr_val = 0, max_baud, cks = 0;
        int t = -1;
        unsigned int srr = 15;
 
+       if ((termios->c_cflag & CSIZE) == CS7)
+               smr_val |= SCSMR_CHR;
+       if (termios->c_cflag & PARENB)
+               smr_val |= SCSMR_PE;
+       if (termios->c_cflag & PARODD)
+               smr_val |= SCSMR_PE | SCSMR_ODD;
+       if (termios->c_cflag & CSTOPB)
+               smr_val |= SCSMR_STOP;
+
        /*
         * earlyprintk comes here early on with port->uartclk set to zero.
         * the clock framework is not up and running at this point so here
@@ -1855,8 +1907,9 @@ static void sci_set_termios(struct uart_port *port, struct ktermios *termios,
        baud = uart_get_baud_rate(port, termios, old, 0, max_baud);
        if (likely(baud && port->uartclk)) {
                if (s->cfg->type == PORT_HSCIF) {
+                       int frame_len = sci_baud_calc_frame_len(smr_val);
                        sci_baud_calc_hscif(baud, port->uartclk, &t, &srr,
-                                           &cks);
+                                           &cks, frame_len);
                } else {
                        t = sci_scbrr_calc(s, baud, port->uartclk);
                        for (cks = 0; t >= 256 && cks <= 3; cks++)
@@ -1868,16 +1921,7 @@ static void sci_set_termios(struct uart_port *port, struct ktermios *termios,
 
        sci_reset(port);
 
-       smr_val = serial_port_in(port, SCSMR) & 3;
-
-       if ((termios->c_cflag & CSIZE) == CS7)
-               smr_val |= 0x40;
-       if (termios->c_cflag & PARENB)
-               smr_val |= 0x20;
-       if (termios->c_cflag & PARODD)
-               smr_val |= 0x30;
-       if (termios->c_cflag & CSTOPB)
-               smr_val |= 0x08;
+       smr_val |= serial_port_in(port, SCSMR) & 3;
 
        uart_update_timeout(port, termios->c_cflag, baud);
 
@@ -1885,7 +1929,7 @@ static void sci_set_termios(struct uart_port *port, struct ktermios *termios,
                __func__, smr_val, cks, t, s->cfg->scscr);
 
        if (t >= 0) {
-               serial_port_out(port, SCSMR, (smr_val & ~3) | cks);
+               serial_port_out(port, SCSMR, (smr_val & ~SCSMR_CKS) | cks);
                serial_port_out(port, SCBRR, t);
                reg = sci_getreg(port, HSSRR);
                if (reg->size)
@@ -1933,8 +1977,7 @@ static void sci_set_termios(struct uart_port *port, struct ktermios *termios,
        if (s->chan_rx) {
                s->rx_timeout = (port->timeout - HZ / 50) * s->buf_len_rx * 3 /
                        port->fifosize / 2;
-               dev_dbg(port->dev,
-                       "DMA Rx t-out %ums, tty t-out %u jiffies\n",
+               dev_dbg(port->dev, "DMA Rx t-out %ums, tty t-out %u jiffies\n",
                        s->rx_timeout * 1000 / HZ, port->timeout);
                if (s->rx_timeout < msecs_to_jiffies(20))
                        s->rx_timeout = msecs_to_jiffies(20);
@@ -1953,7 +1996,7 @@ static void sci_pm(struct uart_port *port, unsigned int state,
        struct sci_port *sci_port = to_sci_port(port);
 
        switch (state) {
-       case 3:
+       case UART_PM_STATE_OFF:
                sci_port_disable(sci_port);
                break;
        default:
@@ -2018,7 +2061,7 @@ static int sci_remap_port(struct uart_port *port)
                 * need to do any remapping, just cast the cookie
                 * directly.
                 */
-               port->membase = (void __iomem *)port->mapbase;
+               port->membase = (void __iomem *)(uintptr_t)port->mapbase;
        }
 
        return 0;
@@ -2389,8 +2432,7 @@ static inline int sci_probe_earlyprintk(struct platform_device *pdev)
 
 #endif /* CONFIG_SERIAL_SH_SCI_CONSOLE */
 
-static char banner[] __initdata =
-       KERN_INFO "SuperH (H)SCI(F) driver initialized\n";
+static const char banner[] __initconst = "SuperH (H)SCI(F) driver initialized";
 
 static struct uart_driver sci_uart_driver = {
        .owner          = THIS_MODULE,
@@ -2424,25 +2466,25 @@ struct sci_port_info {
 static const struct of_device_id of_sci_match[] = {
        {
                .compatible = "renesas,scif",
-               .data = (void *)&(const struct sci_port_info) {
+               .data = &(const struct sci_port_info) {
                        .type = PORT_SCIF,
                        .regtype = SCIx_SH4_SCIF_REGTYPE,
                },
        }, {
                .compatible = "renesas,scifa",
-               .data = (void *)&(const struct sci_port_info) {
+               .data = &(const struct sci_port_info) {
                        .type = PORT_SCIFA,
                        .regtype = SCIx_SCIFA_REGTYPE,
                },
        }, {
                .compatible = "renesas,scifb",
-               .data = (void *)&(const struct sci_port_info) {
+               .data = &(const struct sci_port_info) {
                        .type = PORT_SCIFB,
                        .regtype = SCIx_SCIFB_REGTYPE,
                },
        }, {
                .compatible = "renesas,hscif",
-               .data = (void *)&(const struct sci_port_info) {
+               .data = &(const struct sci_port_info) {
                        .type = PORT_HSCIF,
                        .regtype = SCIx_HSCIF_REGTYPE,
                },
@@ -2502,11 +2544,9 @@ static int sci_probe_single(struct platform_device *dev,
 
        /* Sanity check */
        if (unlikely(index >= SCI_NPORTS)) {
-               dev_notice(&dev->dev, "Attempting to register port "
-                          "%d when only %d are available.\n",
+               dev_notice(&dev->dev, "Attempting to register port %d when only %d are available\n",
                           index+1, SCI_NPORTS);
-               dev_notice(&dev->dev, "Consider bumping "
-                          "CONFIG_SERIAL_SH_SCI_NR_UARTS!\n");
+               dev_notice(&dev->dev, "Consider bumping CONFIG_SERIAL_SH_SCI_NR_UARTS!\n");
                return -EINVAL;
        }
 
@@ -2564,6 +2604,7 @@ static int sci_probe(struct platform_device *dev)
        ret = cpufreq_register_notifier(&sp->freq_transition,
                                        CPUFREQ_TRANSITION_NOTIFIER);
        if (unlikely(ret < 0)) {
+               uart_remove_one_port(&sci_uart_driver, &sp->port);
                sci_cleanup_single(sp);
                return ret;
        }
@@ -2615,7 +2656,7 @@ static int __init sci_init(void)
 {
        int ret;
 
-       printk(banner);
+       pr_info("%s\n", banner);
 
        ret = uart_register_driver(&sci_uart_driver);
        if (likely(ret == 0)) {
index a9707da..eba5893 100644 (file)
@@ -29,6 +29,22 @@ if USB_XHCI_HCD
 config USB_XHCI_PLATFORM
        tristate
 
+config USB_XHCI_MVEBU
+       tristate "xHCI support for Marvell Armada 375/38x"
+       select USB_XHCI_PLATFORM
+       depends on ARCH_MVEBU || COMPILE_TEST
+       ---help---
+         Say 'Y' to enable the support for the xHCI host controller
+         found in Marvell Armada 375/38x ARM SOCs.
+
+config USB_XHCI_RCAR
+       tristate "xHCI support for Renesas R-Car SoCs"
+       select USB_XHCI_PLATFORM
+       depends on ARCH_SHMOBILE || COMPILE_TEST
+       ---help---
+         Say 'Y' to enable the support for the xHCI host controller
+         found in Renesas R-Car ARM SoCs.
+
 endif # USB_XHCI_HCD
 
 config USB_EHCI_HCD
index 7530468..b59ca3c 100644 (file)
@@ -19,6 +19,12 @@ xhci-hcd-$(CONFIG_PCI)       += xhci-pci.o
 
 ifneq ($(CONFIG_USB_XHCI_PLATFORM), )
        xhci-hcd-y              += xhci-plat.o
+ifneq ($(CONFIG_USB_XHCI_MVEBU), )
+       xhci-hcd-y              += xhci-mvebu.o
+endif
+ifneq ($(CONFIG_USB_XHCI_RCAR), )
+       xhci-hcd-y              += xhci-rcar.o
+endif
 endif
 
 obj-$(CONFIG_USB_WHCI_HCD)     += whci/
diff --git a/drivers/usb/host/xhci-mvebu.c b/drivers/usb/host/xhci-mvebu.c
new file mode 100644 (file)
index 0000000..1eefc98
--- /dev/null
@@ -0,0 +1,72 @@
+/*
+ * Copyright (C) 2014 Marvell
+ * Author: Gregory CLEMENT <gregory.clement@free-electrons.com>
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * version 2 as published by the Free Software Foundation.
+ */
+
+#include <linux/io.h>
+#include <linux/mbus.h>
+#include <linux/of.h>
+#include <linux/platform_device.h>
+
+#include "xhci-mvebu.h"
+
+#define USB3_MAX_WINDOWS       4
+#define USB3_WIN_CTRL(w)       (0x0 + ((w) * 8))
+#define USB3_WIN_BASE(w)       (0x4 + ((w) * 8))
+
+static void xhci_mvebu_mbus_config(void __iomem *base,
+                       const struct mbus_dram_target_info *dram)
+{
+       int win;
+
+       /* Clear all existing windows */
+       for (win = 0; win < USB3_MAX_WINDOWS; win++) {
+               writel(0, base + USB3_WIN_CTRL(win));
+               writel(0, base + USB3_WIN_BASE(win));
+       }
+
+       /* Program each DRAM CS in a seperate window */
+       for (win = 0; win < dram->num_cs; win++) {
+               const struct mbus_dram_window *cs = dram->cs + win;
+
+               writel(((cs->size - 1) & 0xffff0000) | (cs->mbus_attr << 8) |
+                      (dram->mbus_dram_target_id << 4) | 1,
+                      base + USB3_WIN_CTRL(win));
+
+               writel((cs->base & 0xffff0000), base + USB3_WIN_BASE(win));
+       }
+}
+
+int xhci_mvebu_mbus_init_quirk(struct platform_device *pdev)
+{
+       struct resource *res;
+       void __iomem *base;
+       const struct mbus_dram_target_info *dram;
+
+       res = platform_get_resource(pdev, IORESOURCE_MEM, 1);
+       if (!res)
+               return -ENODEV;
+
+       /*
+        * We don't use devm_ioremap() because this mapping should
+        * only exists for the duration of this probe function.
+        */
+       base = ioremap(res->start, resource_size(res));
+       if (!base)
+               return -ENODEV;
+
+       dram = mv_mbus_dram_info();
+       xhci_mvebu_mbus_config(base, dram);
+
+       /*
+        * This memory area was only needed to configure the MBus
+        * windows, and is therefore no longer useful.
+        */
+       iounmap(base);
+
+       return 0;
+}
diff --git a/drivers/usb/host/xhci-mvebu.h b/drivers/usb/host/xhci-mvebu.h
new file mode 100644 (file)
index 0000000..7ede92a
--- /dev/null
@@ -0,0 +1,21 @@
+/*
+ * Copyright (C) 2014 Marvell
+ *
+ * Gregory Clement <gregory.clement@free-electrons.com>
+ *
+ * This file is licensed under the terms of the GNU General Public
+ * License version 2.  This program is licensed "as is" without any
+ * warranty of any kind, whether express or implied.
+ */
+
+#ifndef __LINUX_XHCI_MVEBU_H
+#define __LINUX_XHCI_MVEBU_H
+#if IS_ENABLED(CONFIG_USB_XHCI_MVEBU)
+int xhci_mvebu_mbus_init_quirk(struct platform_device *pdev);
+#else
+static inline int xhci_mvebu_mbus_init_quirk(struct platform_device *pdev)
+{
+       return 0;
+}
+#endif
+#endif /* __LINUX_XHCI_MVEBU_H */
index 75cb1ff..7ebfe1c 100644 (file)
@@ -40,6 +40,8 @@
 
 static const char hcd_name[] = "xhci_hcd";
 
+static struct hc_driver __read_mostly xhci_pci_hc_driver;
+
 /* called after powerup, by probe or system-pm "wakeup" */
 static int xhci_pci_reinit(struct xhci_hcd *xhci, struct pci_dev *pdev)
 {
@@ -316,68 +318,6 @@ static int xhci_pci_resume(struct usb_hcd *hcd, bool hibernated)
 }
 #endif /* CONFIG_PM */
 
-static const struct hc_driver xhci_pci_hc_driver = {
-       .description =          hcd_name,
-       .product_desc =         "xHCI Host Controller",
-       .hcd_priv_size =        sizeof(struct xhci_hcd *),
-
-       /*
-        * generic hardware linkage
-        */
-       .irq =                  xhci_irq,
-       .flags =                HCD_MEMORY | HCD_USB3 | HCD_SHARED,
-
-       /*
-        * basic lifecycle operations
-        */
-       .reset =                xhci_pci_setup,
-       .start =                xhci_run,
-#ifdef CONFIG_PM
-       .pci_suspend =          xhci_pci_suspend,
-       .pci_resume =           xhci_pci_resume,
-#endif
-       .stop =                 xhci_stop,
-       .shutdown =             xhci_shutdown,
-
-       /*
-        * managing i/o requests and associated device resources
-        */
-       .urb_enqueue =          xhci_urb_enqueue,
-       .urb_dequeue =          xhci_urb_dequeue,
-       .alloc_dev =            xhci_alloc_dev,
-       .free_dev =             xhci_free_dev,
-       .alloc_streams =        xhci_alloc_streams,
-       .free_streams =         xhci_free_streams,
-       .add_endpoint =         xhci_add_endpoint,
-       .drop_endpoint =        xhci_drop_endpoint,
-       .endpoint_reset =       xhci_endpoint_reset,
-       .check_bandwidth =      xhci_check_bandwidth,
-       .reset_bandwidth =      xhci_reset_bandwidth,
-       .address_device =       xhci_address_device,
-       .enable_device =        xhci_enable_device,
-       .update_hub_device =    xhci_update_hub_device,
-       .reset_device =         xhci_discover_or_reset_device,
-
-       /*
-        * scheduling support
-        */
-       .get_frame_number =     xhci_get_frame,
-
-       /* Root hub support */
-       .hub_control =          xhci_hub_control,
-       .hub_status_data =      xhci_hub_status_data,
-       .bus_suspend =          xhci_bus_suspend,
-       .bus_resume =           xhci_bus_resume,
-       /*
-        * call back when device connected and addressed
-        */
-       .update_device =        xhci_update_device,
-       .set_usb2_hw_lpm =      xhci_set_usb2_hardware_lpm,
-       .enable_usb3_lpm_timeout =      xhci_enable_usb3_lpm_timeout,
-       .disable_usb3_lpm_timeout =     xhci_disable_usb3_lpm_timeout,
-       .find_raw_port_number = xhci_find_raw_port_number,
-};
-
 /*-------------------------------------------------------------------------*/
 
 /* PCI driver selection metadata; PCI hotplugging uses this */
@@ -409,6 +349,11 @@ static struct pci_driver xhci_pci_driver = {
 
 int __init xhci_register_pci(void)
 {
+       xhci_init_driver(&xhci_pci_hc_driver, xhci_pci_setup);
+#ifdef CONFIG_PM
+       xhci_pci_hc_driver.pci_suspend = xhci_pci_suspend;
+       xhci_pci_hc_driver.pci_resume = xhci_pci_resume;
+#endif
        return pci_register_driver(&xhci_pci_driver);
 }
 
index 8abda5c..feed721 100644 (file)
  * version 2 as published by the Free Software Foundation.
  */
 
-#include <linux/platform_device.h>
+#include <linux/clk.h>
+#include <linux/dma-mapping.h>
 #include <linux/module.h>
-#include <linux/slab.h>
 #include <linux/of.h>
-#include <linux/dma-mapping.h>
+#include <linux/platform_device.h>
+#include <linux/slab.h>
+#include <linux/usb/xhci_pdriver.h>
 
 #include "xhci.h"
+#include "xhci-mvebu.h"
+#include "xhci-rcar.h"
+
+static struct hc_driver __read_mostly xhci_plat_hc_driver;
 
 static void xhci_plat_quirks(struct device *dev, struct xhci_hcd *xhci)
 {
@@ -32,72 +38,46 @@ static void xhci_plat_quirks(struct device *dev, struct xhci_hcd *xhci)
 /* called during probe() after chip reset completes */
 static int xhci_plat_setup(struct usb_hcd *hcd)
 {
+       struct device_node *of_node = hcd->self.controller->of_node;
+       int ret;
+
+       if (of_device_is_compatible(of_node, "renesas,xhci-r8a7790") ||
+           of_device_is_compatible(of_node, "renesas,xhci-r8a7791")) {
+               ret = xhci_rcar_init_quirk(hcd);
+               if (ret)
+                       return ret;
+       }
+
        return xhci_gen_setup(hcd, xhci_plat_quirks);
 }
 
-static const struct hc_driver xhci_plat_xhci_driver = {
-       .description =          "xhci-hcd",
-       .product_desc =         "xHCI Host Controller",
-       .hcd_priv_size =        sizeof(struct xhci_hcd *),
-
-       /*
-        * generic hardware linkage
-        */
-       .irq =                  xhci_irq,
-       .flags =                HCD_MEMORY | HCD_USB3 | HCD_SHARED,
-
-       /*
-        * basic lifecycle operations
-        */
-       .reset =                xhci_plat_setup,
-       .start =                xhci_run,
-       .stop =                 xhci_stop,
-       .shutdown =             xhci_shutdown,
+static int xhci_plat_start(struct usb_hcd *hcd)
+{
+       struct device_node *of_node = hcd->self.controller->of_node;
 
-       /*
-        * managing i/o requests and associated device resources
-        */
-       .urb_enqueue =          xhci_urb_enqueue,
-       .urb_dequeue =          xhci_urb_dequeue,
-       .alloc_dev =            xhci_alloc_dev,
-       .free_dev =             xhci_free_dev,
-       .alloc_streams =        xhci_alloc_streams,
-       .free_streams =         xhci_free_streams,
-       .add_endpoint =         xhci_add_endpoint,
-       .drop_endpoint =        xhci_drop_endpoint,
-       .endpoint_reset =       xhci_endpoint_reset,
-       .check_bandwidth =      xhci_check_bandwidth,
-       .reset_bandwidth =      xhci_reset_bandwidth,
-       .address_device =       xhci_address_device,
-       .enable_device =        xhci_enable_device,
-       .update_hub_device =    xhci_update_hub_device,
-       .reset_device =         xhci_discover_or_reset_device,
+       if (of_device_is_compatible(of_node, "renesas,xhci-r8a7790") ||
+           of_device_is_compatible(of_node, "renesas,xhci-r8a7791"))
+               xhci_rcar_start(hcd);
 
-       /*
-        * scheduling support
-        */
-       .get_frame_number =     xhci_get_frame,
-
-       /* Root hub support */
-       .hub_control =          xhci_hub_control,
-       .hub_status_data =      xhci_hub_status_data,
-       .bus_suspend =          xhci_bus_suspend,
-       .bus_resume =           xhci_bus_resume,
-};
+       return xhci_run(hcd);
+}
 
 static int xhci_plat_probe(struct platform_device *pdev)
 {
+       struct device_node      *node = pdev->dev.of_node;
+       struct usb_xhci_pdata   *pdata = dev_get_platdata(&pdev->dev);
        const struct hc_driver  *driver;
        struct xhci_hcd         *xhci;
        struct resource         *res;
        struct usb_hcd          *hcd;
+       struct clk              *clk;
        int                     ret;
        int                     irq;
 
        if (usb_disabled())
                return -ENODEV;
 
-       driver = &xhci_plat_xhci_driver;
+       driver = &xhci_plat_hc_driver;
 
        irq = platform_get_irq(pdev, 0);
        if (irq < 0)
@@ -107,6 +87,15 @@ static int xhci_plat_probe(struct platform_device *pdev)
        if (!res)
                return -ENODEV;
 
+       if (of_device_is_compatible(pdev->dev.of_node,
+                                   "marvell,armada-375-xhci") ||
+           of_device_is_compatible(pdev->dev.of_node,
+                                   "marvell,armada-380-xhci")) {
+               ret = xhci_mvebu_mbus_init_quirk(pdev);
+               if (ret)
+                       return ret;
+       }
+
        /* Initialize dma_mask and coherent_dma_mask to 32-bits */
        ret = dma_set_coherent_mask(&pdev->dev, DMA_BIT_MASK(32));
        if (ret)
@@ -123,28 +112,33 @@ static int xhci_plat_probe(struct platform_device *pdev)
        hcd->rsrc_start = res->start;
        hcd->rsrc_len = resource_size(res);
 
-       if (!request_mem_region(hcd->rsrc_start, hcd->rsrc_len,
-                               driver->description)) {
-               dev_dbg(&pdev->dev, "controller already in use\n");
-               ret = -EBUSY;
+       hcd->regs = devm_ioremap_resource(&pdev->dev, res);
+       if (IS_ERR(hcd->regs)) {
+               ret = PTR_ERR(hcd->regs);
                goto put_hcd;
        }
 
-       hcd->regs = ioremap_nocache(hcd->rsrc_start, hcd->rsrc_len);
-       if (!hcd->regs) {
-               dev_dbg(&pdev->dev, "error mapping memory\n");
-               ret = -EFAULT;
-               goto release_mem_region;
+       /*
+        * Not all platforms have a clk so it is not an error if the
+        * clock does not exists.
+        */
+       clk = devm_clk_get(&pdev->dev, NULL);
+       if (!IS_ERR(clk)) {
+               ret = clk_prepare_enable(clk);
+               if (ret)
+                       goto put_hcd;
        }
 
        ret = usb_add_hcd(hcd, irq, IRQF_SHARED);
        if (ret)
-               goto unmap_registers;
+               goto disable_clk;
+
        device_wakeup_enable(hcd->self.controller);
 
        /* USB 2.0 roothub is stored in the platform_device now. */
        hcd = platform_get_drvdata(pdev);
        xhci = hcd_to_xhci(hcd);
+       xhci->clk = clk;
        xhci->shared_hcd = usb_create_shared_hcd(driver, &pdev->dev,
                        dev_name(&pdev->dev), hcd);
        if (!xhci->shared_hcd) {
@@ -152,6 +146,9 @@ static int xhci_plat_probe(struct platform_device *pdev)
                goto dealloc_usb2_hcd;
        }
 
+       if ((node && of_property_read_bool(node, "usb3-lpm-capable")) ||
+                       (pdata && pdata->usb3_lpm_capable))
+               xhci->quirks |= XHCI_LPM_SUPPORT;
        /*
         * Set the xHCI pointer before xhci_plat_setup() (aka hcd_driver.reset)
         * is called by usb_add_hcd().
@@ -170,11 +167,9 @@ put_usb3_hcd:
 dealloc_usb2_hcd:
        usb_remove_hcd(hcd);
 
-unmap_registers:
-       iounmap(hcd->regs);
-
-release_mem_region:
-       release_mem_region(hcd->rsrc_start, hcd->rsrc_len);
+disable_clk:
+       if (!IS_ERR(clk))
+               clk_disable_unprepare(clk);
 
 put_hcd:
        usb_put_hcd(hcd);
@@ -186,20 +181,21 @@ static int xhci_plat_remove(struct platform_device *dev)
 {
        struct usb_hcd  *hcd = platform_get_drvdata(dev);
        struct xhci_hcd *xhci = hcd_to_xhci(hcd);
+       struct clk *clk = xhci->clk;
 
        usb_remove_hcd(xhci->shared_hcd);
        usb_put_hcd(xhci->shared_hcd);
 
        usb_remove_hcd(hcd);
-       iounmap(hcd->regs);
-       release_mem_region(hcd->rsrc_start, hcd->rsrc_len);
+       if (!IS_ERR(clk))
+               clk_disable_unprepare(clk);
        usb_put_hcd(hcd);
        kfree(xhci);
 
        return 0;
 }
 
-#ifdef CONFIG_PM
+#ifdef CONFIG_PM_SLEEP
 static int xhci_plat_suspend(struct device *dev)
 {
        struct usb_hcd  *hcd = dev_get_drvdata(dev);
@@ -226,7 +222,12 @@ static const struct dev_pm_ops xhci_plat_pm_ops = {
 
 #ifdef CONFIG_OF
 static const struct of_device_id usb_xhci_of_match[] = {
+       { .compatible = "generic-xhci" },
        { .compatible = "xhci-platform" },
+       { .compatible = "marvell,armada-375-xhci"},
+       { .compatible = "marvell,armada-380-xhci"},
+       { .compatible = "renesas,xhci-r8a7790"},
+       { .compatible = "renesas,xhci-r8a7791"},
        { },
 };
 MODULE_DEVICE_TABLE(of, usb_xhci_of_match);
@@ -245,6 +246,8 @@ MODULE_ALIAS("platform:xhci-hcd");
 
 int xhci_register_plat(void)
 {
+       xhci_init_driver(&xhci_plat_hc_driver, xhci_plat_setup);
+       xhci_plat_hc_driver.start = xhci_plat_start;
        return platform_driver_register(&usb_xhci_driver);
 }
 
diff --git a/drivers/usb/host/xhci-rcar.c b/drivers/usb/host/xhci-rcar.c
new file mode 100644 (file)
index 0000000..ff0d1b4
--- /dev/null
@@ -0,0 +1,148 @@
+/*
+ * xHCI host controller driver for R-Car SoCs
+ *
+ * Copyright (C) 2014 Renesas Electronics Corporation
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * version 2 as published by the Free Software Foundation.
+ */
+
+#include <linux/firmware.h>
+#include <linux/module.h>
+#include <linux/platform_device.h>
+#include <linux/usb/phy.h>
+
+#include "xhci.h"
+#include "xhci-rcar.h"
+
+#define FIRMWARE_NAME          "r8a779x_usb3_v1.dlmem"
+MODULE_FIRMWARE(FIRMWARE_NAME);
+
+/*** Register Offset ***/
+#define RCAR_USB3_INT_ENA      0x224   /* Interrupt Enable */
+#define RCAR_USB3_DL_CTRL      0x250   /* FW Download Control & Status */
+#define RCAR_USB3_FW_DATA0     0x258   /* FW Data0 */
+
+#define RCAR_USB3_LCLK         0xa44   /* LCLK Select */
+#define RCAR_USB3_CONF1                0xa48   /* USB3.0 Configuration1 */
+#define RCAR_USB3_CONF2                0xa5c   /* USB3.0 Configuration2 */
+#define RCAR_USB3_CONF3                0xaa8   /* USB3.0 Configuration3 */
+#define RCAR_USB3_RX_POL       0xab0   /* USB3.0 RX Polarity */
+#define RCAR_USB3_TX_POL       0xab8   /* USB3.0 TX Polarity */
+
+/*** Register Settings ***/
+/* Interrupt Enable */
+#define RCAR_USB3_INT_XHC_ENA  0x00000001
+#define RCAR_USB3_INT_PME_ENA  0x00000002
+#define RCAR_USB3_INT_HSE_ENA  0x00000004
+#define RCAR_USB3_INT_ENA_VAL  (RCAR_USB3_INT_XHC_ENA | \
+                               RCAR_USB3_INT_PME_ENA | RCAR_USB3_INT_HSE_ENA)
+
+/* FW Download Control & Status */
+#define RCAR_USB3_DL_CTRL_ENABLE       0x00000001
+#define RCAR_USB3_DL_CTRL_FW_SUCCESS   0x00000010
+#define RCAR_USB3_DL_CTRL_FW_SET_DATA0 0x00000100
+
+/* LCLK Select */
+#define RCAR_USB3_LCLK_ENA_VAL 0x01030001
+
+/* USB3.0 Configuration */
+#define RCAR_USB3_CONF1_VAL    0x00030204
+#define RCAR_USB3_CONF2_VAL    0x00030300
+#define RCAR_USB3_CONF3_VAL    0x13802007
+
+/* USB3.0 Polarity */
+#define RCAR_USB3_RX_POL_VAL   BIT(21)
+#define RCAR_USB3_TX_POL_VAL   BIT(4)
+
+void xhci_rcar_start(struct usb_hcd *hcd)
+{
+       u32 temp;
+
+       if (hcd->regs != NULL) {
+               /* Interrupt Enable */
+               temp = readl(hcd->regs + RCAR_USB3_INT_ENA);
+               temp |= RCAR_USB3_INT_ENA_VAL;
+               writel(temp, hcd->regs + RCAR_USB3_INT_ENA);
+               /* LCLK Select */
+               writel(RCAR_USB3_LCLK_ENA_VAL, hcd->regs + RCAR_USB3_LCLK);
+               /* USB3.0 Configuration */
+               writel(RCAR_USB3_CONF1_VAL, hcd->regs + RCAR_USB3_CONF1);
+               writel(RCAR_USB3_CONF2_VAL, hcd->regs + RCAR_USB3_CONF2);
+               writel(RCAR_USB3_CONF3_VAL, hcd->regs + RCAR_USB3_CONF3);
+               /* USB3.0 Polarity */
+               writel(RCAR_USB3_RX_POL_VAL, hcd->regs + RCAR_USB3_RX_POL);
+               writel(RCAR_USB3_TX_POL_VAL, hcd->regs + RCAR_USB3_TX_POL);
+       }
+}
+
+static int xhci_rcar_download_firmware(struct device *dev, void __iomem *regs)
+{
+       const struct firmware *fw;
+       int retval, index, j, time;
+       int timeout = 10000;
+       u32 data, val, temp;
+
+       /* request R-Car USB3.0 firmware */
+       retval = request_firmware(&fw, FIRMWARE_NAME, dev);
+       if (retval)
+               return retval;
+
+       /* download R-Car USB3.0 firmware */
+       temp = readl(regs + RCAR_USB3_DL_CTRL);
+       temp |= RCAR_USB3_DL_CTRL_ENABLE;
+       writel(temp, regs + RCAR_USB3_DL_CTRL);
+
+       for (index = 0; index < fw->size; index += 4) {
+               /* to avoid reading beyond the end of the buffer */
+               for (data = 0, j = 3; j >= 0; j--) {
+                       if ((j + index) < fw->size)
+                               data |= fw->data[index + j] << (8 * j);
+               }
+               writel(data, regs + RCAR_USB3_FW_DATA0);
+               temp = readl(regs + RCAR_USB3_DL_CTRL);
+               temp |= RCAR_USB3_DL_CTRL_FW_SET_DATA0;
+               writel(temp, regs + RCAR_USB3_DL_CTRL);
+
+               for (time = 0; time < timeout; time++) {
+                       val = readl(regs + RCAR_USB3_DL_CTRL);
+                       if ((val & RCAR_USB3_DL_CTRL_FW_SET_DATA0) == 0)
+                               break;
+                       udelay(1);
+               }
+               if (time == timeout) {
+                       retval = -ETIMEDOUT;
+                       break;
+               }
+       }
+
+       temp = readl(regs + RCAR_USB3_DL_CTRL);
+       temp &= ~RCAR_USB3_DL_CTRL_ENABLE;
+       writel(temp, regs + RCAR_USB3_DL_CTRL);
+
+       for (time = 0; time < timeout; time++) {
+               val = readl(regs + RCAR_USB3_DL_CTRL);
+               if (val & RCAR_USB3_DL_CTRL_FW_SUCCESS) {
+                       retval = 0;
+                       break;
+               }
+               udelay(1);
+       }
+       if (time == timeout)
+               retval = -ETIMEDOUT;
+
+       release_firmware(fw);
+
+       return retval;
+}
+
+/* This function needs to initialize a "phy" of usb before */
+int xhci_rcar_init_quirk(struct usb_hcd *hcd)
+{
+       /* If hcd->regs is NULL, we don't just call the following function */
+       if (!hcd->regs)
+               return 0;
+
+       return xhci_rcar_download_firmware(hcd->self.controller, hcd->regs);
+}
diff --git a/drivers/usb/host/xhci-rcar.h b/drivers/usb/host/xhci-rcar.h
new file mode 100644 (file)
index 0000000..5850125
--- /dev/null
@@ -0,0 +1,27 @@
+/*
+ * drivers/usb/host/xhci-rcar.h
+ *
+ * Copyright (C) 2014 Renesas Electronics Corporation
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * version 2 as published by the Free Software Foundation.
+ */
+
+#ifndef _XHCI_RCAR_H
+#define _XHCI_RCAR_H
+
+#if IS_ENABLED(CONFIG_USB_XHCI_RCAR)
+void xhci_rcar_start(struct usb_hcd *hcd);
+int xhci_rcar_init_quirk(struct usb_hcd *hcd);
+#else
+static inline void xhci_rcar_start(struct usb_hcd *hcd)
+{
+}
+
+static inline int xhci_rcar_init_quirk(struct usb_hcd *hcd)
+{
+       return 0;
+}
+#endif
+#endif /* _XHCI_RCAR_H */
index 82b563f..5e8e87d 100644 (file)
@@ -4831,6 +4831,75 @@ error:
        return retval;
 }
 
+static const struct hc_driver xhci_hc_driver = {
+       .description =          "xhci-hcd",
+       .product_desc =         "xHCI Host Controller",
+       .hcd_priv_size =        sizeof(struct xhci_hcd *),
+
+       /*
+        * generic hardware linkage
+        */
+       .irq =                  xhci_irq,
+       .flags =                HCD_MEMORY | HCD_USB3 | HCD_SHARED,
+
+       /*
+        * basic lifecycle operations
+        */
+       .reset =                NULL, /* set in xhci_init_driver() */
+       .start =                xhci_run,
+       .stop =                 xhci_stop,
+       .shutdown =             xhci_shutdown,
+
+       /*
+        * managing i/o requests and associated device resources
+        */
+       .urb_enqueue =          xhci_urb_enqueue,
+       .urb_dequeue =          xhci_urb_dequeue,
+       .alloc_dev =            xhci_alloc_dev,
+       .free_dev =             xhci_free_dev,
+       .alloc_streams =        xhci_alloc_streams,
+       .free_streams =         xhci_free_streams,
+       .add_endpoint =         xhci_add_endpoint,
+       .drop_endpoint =        xhci_drop_endpoint,
+       .endpoint_reset =       xhci_endpoint_reset,
+       .check_bandwidth =      xhci_check_bandwidth,
+       .reset_bandwidth =      xhci_reset_bandwidth,
+       .address_device =       xhci_address_device,
+       .enable_device =        xhci_enable_device,
+       .update_hub_device =    xhci_update_hub_device,
+       .reset_device =         xhci_discover_or_reset_device,
+
+       /*
+        * scheduling support
+        */
+       .get_frame_number =     xhci_get_frame,
+
+       /*
+        * root hub support
+        */
+       .hub_control =          xhci_hub_control,
+       .hub_status_data =      xhci_hub_status_data,
+       .bus_suspend =          xhci_bus_suspend,
+       .bus_resume =           xhci_bus_resume,
+
+       /*
+        * call back when device connected and addressed
+        */
+       .update_device =        xhci_update_device,
+       .set_usb2_hw_lpm =      xhci_set_usb2_hardware_lpm,
+       .enable_usb3_lpm_timeout =      xhci_enable_usb3_lpm_timeout,
+       .disable_usb3_lpm_timeout =     xhci_disable_usb3_lpm_timeout,
+       .find_raw_port_number = xhci_find_raw_port_number,
+};
+
+void xhci_init_driver(struct hc_driver *drv, int (*setup_fn)(struct usb_hcd *))
+{
+       BUG_ON(!setup_fn);
+       *drv = xhci_hc_driver;
+       drv->reset = setup_fn;
+}
+EXPORT_SYMBOL_GPL(xhci_init_driver);
+
 MODULE_DESCRIPTION(DRIVER_DESC);
 MODULE_AUTHOR(DRIVER_AUTHOR);
 MODULE_LICENSE("GPL");
index 8faef64..6d13ec7 100644 (file)
@@ -1473,6 +1473,8 @@ struct xhci_hcd {
        /* msi-x vectors */
        int             msix_count;
        struct msix_entry       *msix_entries;
+       /* optional clock */
+       struct clk              *clk;
        /* data structures */
        struct xhci_device_context_array *dcbaa;
        struct xhci_ring        *cmd_ring;
@@ -1758,6 +1760,7 @@ int xhci_run(struct usb_hcd *hcd);
 void xhci_stop(struct usb_hcd *hcd);
 void xhci_shutdown(struct usb_hcd *hcd);
 int xhci_gen_setup(struct usb_hcd *hcd, xhci_get_quirks_t get_quirks);
+void xhci_init_driver(struct hc_driver *drv, int (*setup_fn)(struct usb_hcd *));
 
 #ifdef CONFIG_PM
 int xhci_suspend(struct xhci_hcd *xhci);
index 1c4195a..de83b9d 100644 (file)
@@ -5,6 +5,7 @@
 config USB_RENESAS_USBHS
        tristate 'Renesas USBHS controller'
        depends on USB_GADGET
+       depends on ARCH_SHMOBILE || SUPERH || COMPILE_TEST
        default n
        help
          Renesas USBHS is a discrete USB host and peripheral controller chip
index bc8aef4..9e47f47 100644 (file)
@@ -4,7 +4,7 @@
 
 obj-$(CONFIG_USB_RENESAS_USBHS)        += renesas_usbhs.o
 
-renesas_usbhs-y                        := common.o mod.o pipe.o fifo.o
+renesas_usbhs-y                        := common.o mod.o pipe.o fifo.o rcar2.o
 
 ifneq ($(CONFIG_USB_RENESAS_USBHS_HCD),)
        renesas_usbhs-y         += mod_host.o
index 17267b0..b3b6813 100644 (file)
  *
  */
 #include <linux/err.h>
+#include <linux/gpio.h>
 #include <linux/io.h>
 #include <linux/module.h>
+#include <linux/of_device.h>
+#include <linux/of_gpio.h>
 #include <linux/pm_runtime.h>
 #include <linux/slab.h>
 #include <linux/sysfs.h>
 #include "common.h"
+#include "rcar2.h"
 
 /*
  *             image of renesas_usbhs
@@ -284,6 +288,8 @@ static void usbhsc_set_buswait(struct usbhs_priv *priv)
 /*
  *             platform default param
  */
+
+/* commonly used on old SH-Mobile SoCs */
 static u32 usbhsc_default_pipe_type[] = {
                USB_ENDPOINT_XFER_CONTROL,
                USB_ENDPOINT_XFER_ISOC,
@@ -297,6 +303,26 @@ static u32 usbhsc_default_pipe_type[] = {
                USB_ENDPOINT_XFER_INT,
 };
 
+/* commonly used on newer SH-Mobile and R-Car SoCs */
+static u32 usbhsc_new_pipe_type[] = {
+               USB_ENDPOINT_XFER_CONTROL,
+               USB_ENDPOINT_XFER_ISOC,
+               USB_ENDPOINT_XFER_ISOC,
+               USB_ENDPOINT_XFER_BULK,
+               USB_ENDPOINT_XFER_BULK,
+               USB_ENDPOINT_XFER_BULK,
+               USB_ENDPOINT_XFER_INT,
+               USB_ENDPOINT_XFER_INT,
+               USB_ENDPOINT_XFER_INT,
+               USB_ENDPOINT_XFER_BULK,
+               USB_ENDPOINT_XFER_BULK,
+               USB_ENDPOINT_XFER_BULK,
+               USB_ENDPOINT_XFER_BULK,
+               USB_ENDPOINT_XFER_BULK,
+               USB_ENDPOINT_XFER_BULK,
+               USB_ENDPOINT_XFER_BULK,
+};
+
 /*
  *             power control
  */
@@ -414,6 +440,43 @@ static int usbhsc_drvcllbck_notify_hotplug(struct platform_device *pdev)
 /*
  *             platform functions
  */
+static const struct of_device_id usbhs_of_match[] = {
+       {
+               .compatible = "renesas,usbhs-r8a7790",
+               .data = (void *)USBHS_TYPE_R8A7790,
+       },
+       {
+               .compatible = "renesas,usbhs-r8a7791",
+               .data = (void *)USBHS_TYPE_R8A7791,
+       },
+       { },
+};
+MODULE_DEVICE_TABLE(of, usbhs_of_match);
+
+static struct renesas_usbhs_platform_info *usbhs_parse_dt(struct device *dev)
+{
+       struct renesas_usbhs_platform_info *info;
+       struct renesas_usbhs_driver_param *dparam;
+       const struct of_device_id *of_id = of_match_device(usbhs_of_match, dev);
+       u32 tmp;
+       int gpio;
+
+       info = devm_kzalloc(dev, sizeof(*info), GFP_KERNEL);
+       if (!info)
+               return NULL;
+
+       dparam = &info->driver_param;
+       dparam->type = of_id ? (u32)of_id->data : 0;
+       if (!of_property_read_u32(dev->of_node, "renesas,buswait", &tmp))
+               dparam->buswait_bwait = tmp;
+       gpio = of_get_named_gpio_flags(dev->of_node, "renesas,enable-gpio", 0,
+                                      NULL);
+       if (gpio > 0)
+               dparam->enable_gpio = gpio;
+
+       return info;
+}
+
 static int usbhs_probe(struct platform_device *pdev)
 {
        struct renesas_usbhs_platform_info *info = dev_get_platdata(&pdev->dev);
@@ -422,9 +485,12 @@ static int usbhs_probe(struct platform_device *pdev)
        struct resource *res, *irq_res;
        int ret;
 
+       /* check device node */
+       if (pdev->dev.of_node)
+               info = pdev->dev.platform_data = usbhs_parse_dt(&pdev->dev);
+
        /* check platform information */
-       if (!info ||
-           !info->platform_callback.get_id) {
+       if (!info) {
                dev_err(&pdev->dev, "no platform information\n");
                return -EINVAL;
        }
@@ -451,13 +517,32 @@ static int usbhs_probe(struct platform_device *pdev)
        /*
         * care platform info
         */
-       memcpy(&priv->pfunc,
-              &info->platform_callback,
-              sizeof(struct renesas_usbhs_platform_callback));
+
        memcpy(&priv->dparam,
               &info->driver_param,
               sizeof(struct renesas_usbhs_driver_param));
 
+       switch (priv->dparam.type) {
+       case USBHS_TYPE_R8A7790:
+       case USBHS_TYPE_R8A7791:
+               priv->pfunc = usbhs_rcar2_ops;
+               if (!priv->dparam.pipe_type) {
+                       priv->dparam.pipe_type = usbhsc_new_pipe_type;
+                       priv->dparam.pipe_size =
+                               ARRAY_SIZE(usbhsc_new_pipe_type);
+               }
+               break;
+       default:
+               if (!info->platform_callback.get_id) {
+                       dev_err(&pdev->dev, "no platform callbacks");
+                       return -EINVAL;
+               }
+               memcpy(&priv->pfunc,
+                      &info->platform_callback,
+                      sizeof(struct renesas_usbhs_platform_callback));
+               break;
+       }
+
        /* set driver callback functions for platform */
        dfunc                   = &info->driver_callback;
        dfunc->notify_hotplug   = usbhsc_drvcllbck_notify_hotplug;
@@ -507,6 +592,20 @@ static int usbhs_probe(struct platform_device *pdev)
         */
        usbhs_sys_clock_ctrl(priv, 0);
 
+       /* check GPIO determining if USB function should be enabled */
+       if (priv->dparam.enable_gpio) {
+               gpio_request_one(priv->dparam.enable_gpio, GPIOF_IN, NULL);
+               ret = !gpio_get_value(priv->dparam.enable_gpio);
+               gpio_free(priv->dparam.enable_gpio);
+               if (ret) {
+                       dev_warn(&pdev->dev,
+                                "USB function not selected (GPIO %d)\n",
+                                priv->dparam.enable_gpio);
+                       ret = -ENOTSUPP;
+                       goto probe_end_mod_exit;
+               }
+       }
+
        /*
         * platform call
         *
@@ -633,6 +732,7 @@ static struct platform_driver renesas_usbhs_driver = {
        .driver         = {
                .name   = "renesas_usbhs",
                .pm     = &usbhsc_pm_ops,
+               .of_match_table = of_match_ptr(usbhs_of_match),
        },
        .probe          = usbhs_probe,
        .remove         = usbhs_remove,
index c69dd2f..a7996da 100644 (file)
@@ -268,6 +268,8 @@ struct usbhs_priv {
         * fifo control
         */
        struct usbhs_fifo_info fifo_info;
+
+       struct usb_phy *phy;
 };
 
 /*
index d49f9c3..b0c97a3 100644 (file)
@@ -108,19 +108,45 @@ static struct usbhs_pkt *__usbhsf_pkt_get(struct usbhs_pipe *pipe)
        return list_first_entry(&pipe->list, struct usbhs_pkt, node);
 }
 
+static void usbhsf_fifo_clear(struct usbhs_pipe *pipe,
+                             struct usbhs_fifo *fifo);
+static void usbhsf_fifo_unselect(struct usbhs_pipe *pipe,
+                                struct usbhs_fifo *fifo);
+static struct dma_chan *usbhsf_dma_chan_get(struct usbhs_fifo *fifo,
+                                           struct usbhs_pkt *pkt);
+#define usbhsf_dma_map(p)      __usbhsf_dma_map_ctrl(p, 1)
+#define usbhsf_dma_unmap(p)    __usbhsf_dma_map_ctrl(p, 0)
+static int __usbhsf_dma_map_ctrl(struct usbhs_pkt *pkt, int map);
 struct usbhs_pkt *usbhs_pkt_pop(struct usbhs_pipe *pipe, struct usbhs_pkt *pkt)
 {
        struct usbhs_priv *priv = usbhs_pipe_to_priv(pipe);
+       struct usbhs_fifo *fifo = usbhs_pipe_to_fifo(pipe);
        unsigned long flags;
 
        /********************  spin lock ********************/
        usbhs_lock(priv, flags);
 
+       usbhs_pipe_disable(pipe);
+
        if (!pkt)
                pkt = __usbhsf_pkt_get(pipe);
 
-       if (pkt)
+       if (pkt) {
+               struct dma_chan *chan = NULL;
+
+               if (fifo)
+                       chan = usbhsf_dma_chan_get(fifo, pkt);
+               if (chan) {
+                       dmaengine_terminate_all(chan);
+                       usbhsf_fifo_clear(pipe, fifo);
+                       usbhsf_dma_unmap(pkt);
+               }
+
                __usbhsf_pkt_del(pkt);
+       }
+
+       if (fifo)
+               usbhsf_fifo_unselect(pipe, fifo);
 
        usbhs_unlock(priv, flags);
        /********************  spin unlock ******************/
@@ -544,6 +570,7 @@ static int usbhsf_pio_try_push(struct usbhs_pkt *pkt, int *is_done)
                usbhsf_send_terminator(pipe, fifo);
 
        usbhsf_tx_irq_ctrl(pipe, !*is_done);
+       usbhs_pipe_running(pipe, !*is_done);
        usbhs_pipe_enable(pipe);
 
        dev_dbg(dev, "  send %d (%d/ %d/ %d/ %d)\n",
@@ -570,12 +597,21 @@ usbhs_fifo_write_busy:
         * retry in interrupt
         */
        usbhsf_tx_irq_ctrl(pipe, 1);
+       usbhs_pipe_running(pipe, 1);
 
        return ret;
 }
 
+static int usbhsf_pio_prepare_push(struct usbhs_pkt *pkt, int *is_done)
+{
+       if (usbhs_pipe_is_running(pkt->pipe))
+               return 0;
+
+       return usbhsf_pio_try_push(pkt, is_done);
+}
+
 struct usbhs_pkt_handle usbhs_fifo_pio_push_handler = {
-       .prepare = usbhsf_pio_try_push,
+       .prepare = usbhsf_pio_prepare_push,
        .try_run = usbhsf_pio_try_push,
 };
 
@@ -589,6 +625,9 @@ static int usbhsf_prepare_pop(struct usbhs_pkt *pkt, int *is_done)
        if (usbhs_pipe_is_busy(pipe))
                return 0;
 
+       if (usbhs_pipe_is_running(pipe))
+               return 0;
+
        /*
         * pipe enable to prepare packet receive
         */
@@ -597,6 +636,7 @@ static int usbhsf_prepare_pop(struct usbhs_pkt *pkt, int *is_done)
 
        usbhs_pipe_set_trans_count_if_bulk(pipe, pkt->length);
        usbhs_pipe_enable(pipe);
+       usbhs_pipe_running(pipe, 1);
        usbhsf_rx_irq_ctrl(pipe, 1);
 
        return 0;
@@ -642,6 +682,7 @@ static int usbhsf_pio_try_pop(struct usbhs_pkt *pkt, int *is_done)
            (total_len < maxp)) {               /* short packet */
                *is_done = 1;
                usbhsf_rx_irq_ctrl(pipe, 0);
+               usbhs_pipe_running(pipe, 0);
                usbhs_pipe_disable(pipe);       /* disable pipe first */
        }
 
@@ -681,6 +722,14 @@ usbhs_fifo_read_end:
                usbhs_pipe_number(pipe),
                pkt->length, pkt->actual, *is_done, pkt->zero);
 
+       /*
+        * Transmission end
+        */
+       if (*is_done) {
+               if (usbhs_pipe_is_dcp(pipe))
+                       usbhs_dcp_control_transfer_done(pipe);
+       }
+
 usbhs_fifo_read_busy:
        usbhsf_fifo_unselect(pipe, fifo);
 
@@ -755,8 +804,6 @@ static void __usbhsf_dma_ctrl(struct usbhs_pipe *pipe,
        usbhs_bset(priv, fifo->sel, DREQE, dreqe);
 }
 
-#define usbhsf_dma_map(p)      __usbhsf_dma_map_ctrl(p, 1)
-#define usbhsf_dma_unmap(p)    __usbhsf_dma_map_ctrl(p, 0)
 static int __usbhsf_dma_map_ctrl(struct usbhs_pkt *pkt, int map)
 {
        struct usbhs_pipe *pipe = pkt->pipe;
@@ -797,6 +844,7 @@ static void xfer_work(struct work_struct *work)
        dev_dbg(dev, "  %s %d (%d/ %d)\n",
                fifo->name, usbhs_pipe_number(pipe), pkt->length, pkt->zero);
 
+       usbhs_pipe_running(pipe, 1);
        usbhs_pipe_set_trans_count_if_bulk(pipe, pkt->trans);
        usbhs_pipe_enable(pipe);
        usbhsf_dma_start(pipe, fifo);
@@ -828,6 +876,10 @@ static int usbhsf_dma_prepare_push(struct usbhs_pkt *pkt, int *is_done)
        if ((uintptr_t)(pkt->buf + pkt->actual) & 0x7) /* 8byte alignment */
                goto usbhsf_pio_prepare_push;
 
+       /* return at this time if the pipe is running */
+       if (usbhs_pipe_is_running(pipe))
+               return 0;
+
        /* get enable DMA fifo */
        fifo = usbhsf_get_dma_fifo(priv, pkt);
        if (!fifo)
@@ -861,15 +913,29 @@ usbhsf_pio_prepare_push:
 static int usbhsf_dma_push_done(struct usbhs_pkt *pkt, int *is_done)
 {
        struct usbhs_pipe *pipe = pkt->pipe;
+       int is_short = pkt->trans % usbhs_pipe_get_maxpacket(pipe);
+
+       pkt->actual += pkt->trans;
 
-       pkt->actual = pkt->trans;
+       if (pkt->actual < pkt->length)
+               *is_done = 0;           /* there are remainder data */
+       else if (is_short)
+               *is_done = 1;           /* short packet */
+       else
+               *is_done = !pkt->zero;  /* send zero packet? */
 
-       *is_done = !pkt->zero;  /* send zero packet ? */
+       usbhs_pipe_running(pipe, !*is_done);
 
        usbhsf_dma_stop(pipe, pipe->fifo);
        usbhsf_dma_unmap(pkt);
        usbhsf_fifo_unselect(pipe, pipe->fifo);
 
+       if (!*is_done) {
+               /* change handler to PIO */
+               pkt->handler = &usbhs_fifo_pio_push_handler;
+               return pkt->handler->try_run(pkt, is_done);
+       }
+
        return 0;
 }
 
@@ -964,8 +1030,10 @@ static int usbhsf_dma_pop_done(struct usbhs_pkt *pkt, int *is_done)
        if ((pkt->actual == pkt->length) ||     /* receive all data */
            (pkt->trans < maxp)) {              /* short packet */
                *is_done = 1;
+               usbhs_pipe_running(pipe, 0);
        } else {
                /* re-enable */
+               usbhs_pipe_running(pipe, 0);
                usbhsf_prepare_pop(pkt, is_done);
        }
 
index 6a030b9..9a705b1 100644 (file)
@@ -213,7 +213,10 @@ static int usbhs_status_get_each_irq(struct usbhs_priv *priv,
 {
        struct usbhs_mod *mod = usbhs_mod_get_current(priv);
        u16 intenb0, intenb1;
+       unsigned long flags;
 
+       /********************  spin lock ********************/
+       usbhs_lock(priv, flags);
        state->intsts0 = usbhs_read(priv, INTSTS0);
        state->intsts1 = usbhs_read(priv, INTSTS1);
 
@@ -229,6 +232,8 @@ static int usbhs_status_get_each_irq(struct usbhs_priv *priv,
                state->bempsts &= mod->irq_bempsts;
                state->brdysts &= mod->irq_brdysts;
        }
+       usbhs_unlock(priv, flags);
+       /********************  spin unlock ******************/
 
        /*
         * Check whether the irq enable registers and the irq status are set
index 458f376..04e6505 100644 (file)
@@ -600,8 +600,10 @@ static int usbhsg_ep_enable(struct usb_ep *ep,
 static int usbhsg_ep_disable(struct usb_ep *ep)
 {
        struct usbhsg_uep *uep = usbhsg_ep_to_uep(ep);
+       struct usbhs_pipe *pipe = usbhsg_uep_to_pipe(uep);
 
        usbhsg_pipe_disable(uep);
+       usbhs_pipe_free(pipe);
 
        uep->pipe->mod_private  = NULL;
        uep->pipe               = NULL;
index 7926e1c..040bcef 100644 (file)
@@ -578,6 +578,19 @@ int usbhs_pipe_is_dir_host(struct usbhs_pipe *pipe)
        return usbhsp_flags_has(pipe, IS_DIR_HOST);
 }
 
+int usbhs_pipe_is_running(struct usbhs_pipe *pipe)
+{
+       return usbhsp_flags_has(pipe, IS_RUNNING);
+}
+
+void usbhs_pipe_running(struct usbhs_pipe *pipe, int running)
+{
+       if (running)
+               usbhsp_flags_set(pipe, IS_RUNNING);
+       else
+               usbhsp_flags_clr(pipe, IS_RUNNING);
+}
+
 void usbhs_pipe_data_sequence(struct usbhs_pipe *pipe, int sequence)
 {
        u16 mask = (SQCLR | SQSET);
@@ -640,6 +653,11 @@ static struct usbhs_pipe *usbhsp_get_pipe(struct usbhs_priv *priv, u32 type)
        return pipe;
 }
 
+static void usbhsp_put_pipe(struct usbhs_pipe *pipe)
+{
+       usbhsp_flags_init(pipe);
+}
+
 void usbhs_pipe_init(struct usbhs_priv *priv,
                     int (*dma_map_ctrl)(struct usbhs_pkt *pkt, int map))
 {
@@ -710,6 +728,7 @@ struct usbhs_pipe *usbhs_pipe_malloc(struct usbhs_priv *priv,
        usbhsp_pipe_select(pipe);
        usbhsp_pipe_cfg_set(pipe, 0xFFFF, pipecfg);
        usbhsp_pipe_buf_set(pipe, 0xFFFF, pipebuf);
+       usbhs_pipe_clear(pipe);
 
        usbhs_pipe_sequence_data0(pipe);
 
@@ -726,6 +745,11 @@ struct usbhs_pipe *usbhs_pipe_malloc(struct usbhs_priv *priv,
        return pipe;
 }
 
+void usbhs_pipe_free(struct usbhs_pipe *pipe)
+{
+       usbhsp_put_pipe(pipe);
+}
+
 void usbhs_pipe_select_fifo(struct usbhs_pipe *pipe, struct usbhs_fifo *fifo)
 {
        if (pipe->fifo)
index 3e53498..d24a059 100644 (file)
@@ -36,6 +36,7 @@ struct usbhs_pipe {
 #define USBHS_PIPE_FLAGS_IS_USED               (1 << 0)
 #define USBHS_PIPE_FLAGS_IS_DIR_IN             (1 << 1)
 #define USBHS_PIPE_FLAGS_IS_DIR_HOST           (1 << 2)
+#define USBHS_PIPE_FLAGS_IS_RUNNING            (1 << 3)
 
        struct usbhs_pkt_handle *handler;
 
@@ -75,10 +76,14 @@ struct usbhs_pipe_info {
 char *usbhs_pipe_name(struct usbhs_pipe *pipe);
 struct usbhs_pipe
 *usbhs_pipe_malloc(struct usbhs_priv *priv, int endpoint_type, int dir_in);
+void usbhs_pipe_free(struct usbhs_pipe *pipe);
 int usbhs_pipe_probe(struct usbhs_priv *priv);
 void usbhs_pipe_remove(struct usbhs_priv *priv);
 int usbhs_pipe_is_dir_in(struct usbhs_pipe *pipe);
 int usbhs_pipe_is_dir_host(struct usbhs_pipe *pipe);
+int usbhs_pipe_is_running(struct usbhs_pipe *pipe);
+void usbhs_pipe_running(struct usbhs_pipe *pipe, int running);
+
 void usbhs_pipe_init(struct usbhs_priv *priv,
                     int (*dma_map_ctrl)(struct usbhs_pkt *pkt, int map));
 int usbhs_pipe_get_maxpacket(struct usbhs_pipe *pipe);
diff --git a/drivers/usb/renesas_usbhs/rcar2.c b/drivers/usb/renesas_usbhs/rcar2.c
new file mode 100644 (file)
index 0000000..e6b9dcc
--- /dev/null
@@ -0,0 +1,77 @@
+/*
+ * Renesas USB driver R-Car Gen. 2 initialization and power control
+ *
+ * Copyright (C) 2014 Ulrich Hecht
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ */
+
+#include <linux/gpio.h>
+#include <linux/of_gpio.h>
+#include <linux/platform_data/gpio-rcar.h>
+#include <linux/usb/phy.h>
+#include "common.h"
+#include "rcar2.h"
+
+static int usbhs_rcar2_hardware_init(struct platform_device *pdev)
+{
+       struct usbhs_priv *priv = usbhs_pdev_to_priv(pdev);
+       struct usb_phy *phy;
+
+       phy = usb_get_phy_dev(&pdev->dev, 0);
+       if (IS_ERR(phy))
+               return PTR_ERR(phy);
+
+       priv->phy = phy;
+       return 0;
+}
+
+static int usbhs_rcar2_hardware_exit(struct platform_device *pdev)
+{
+       struct usbhs_priv *priv = usbhs_pdev_to_priv(pdev);
+
+       if (!priv->phy)
+               return 0;
+
+       usb_put_phy(priv->phy);
+       priv->phy = NULL;
+
+       return 0;
+}
+
+static int usbhs_rcar2_power_ctrl(struct platform_device *pdev,
+                               void __iomem *base, int enable)
+{
+       struct usbhs_priv *priv = usbhs_pdev_to_priv(pdev);
+
+       if (!priv->phy)
+               return -ENODEV;
+
+       if (enable) {
+               int retval = usb_phy_init(priv->phy);
+
+               if (!retval)
+                       retval = usb_phy_set_suspend(priv->phy, 0);
+               return retval;
+       }
+
+       usb_phy_set_suspend(priv->phy, 1);
+       usb_phy_shutdown(priv->phy);
+       return 0;
+}
+
+static int usbhs_rcar2_get_id(struct platform_device *pdev)
+{
+       return USBHS_GADGET;
+}
+
+const struct renesas_usbhs_platform_callback usbhs_rcar2_ops = {
+       .hardware_init = usbhs_rcar2_hardware_init,
+       .hardware_exit = usbhs_rcar2_hardware_exit,
+       .power_ctrl = usbhs_rcar2_power_ctrl,
+       .get_id = usbhs_rcar2_get_id,
+};
diff --git a/drivers/usb/renesas_usbhs/rcar2.h b/drivers/usb/renesas_usbhs/rcar2.h
new file mode 100644 (file)
index 0000000..f07f10d
--- /dev/null
@@ -0,0 +1,4 @@
+#include "common.h"
+
+extern const struct renesas_usbhs_platform_callback
+       usbhs_rcar2_ops;
index d1d07f2..81cb138 100644 (file)
@@ -172,9 +172,9 @@ static struct platform_driver ep93xx_wdt_driver = {
 
 module_platform_driver(ep93xx_wdt_driver);
 
-MODULE_AUTHOR("Ray Lehtiniemi <rayl@mail.com>,"
-               "Alessandro Zummo <a.zummo@towertech.it>,"
-               "H Hartley Sweeten <hsweeten@visionengravers.com>");
+MODULE_AUTHOR("Ray Lehtiniemi <rayl@mail.com>");
+MODULE_AUTHOR("Alessandro Zummo <a.zummo@towertech.it>");
+MODULE_AUTHOR("H Hartley Sweeten <hsweeten@visionengravers.com>");
 MODULE_DESCRIPTION("EP93xx Watchdog");
 MODULE_LICENSE("GPL");
 MODULE_VERSION(WDT_VERSION);
index 04f8af6..0ba1b7c 100644 (file)
@@ -48,7 +48,7 @@
 
 /* Module and version information */
 #define DRV_NAME       "iTCO_wdt"
-#define DRV_VERSION    "1.10"
+#define DRV_VERSION    "1.11"
 
 /* Includes */
 #include <linux/module.h>              /* For module specific items */
@@ -92,9 +92,12 @@ static struct {              /* this is private data for the iTCO_wdt device */
        unsigned int iTCO_version;
        struct resource *tco_res;
        struct resource *smi_res;
-       struct resource *gcs_res;
-       /* NO_REBOOT flag is Memory-Mapped GCS register bit 5 (TCO version 2)*/
-       unsigned long __iomem *gcs;
+       /*
+        * NO_REBOOT flag is Memory-Mapped GCS register bit 5 (TCO version 2),
+        * or memory-mapped PMC register bit 4 (TCO version 3).
+        */
+       struct resource *gcs_pmc_res;
+       unsigned long __iomem *gcs_pmc;
        /* the lock for io operations */
        spinlock_t io_lock;
        struct platform_device *dev;
@@ -125,11 +128,19 @@ MODULE_PARM_DESC(turn_SMI_watchdog_clear_off,
  * Some TCO specific functions
  */
 
-static inline unsigned int seconds_to_ticks(int seconds)
+/*
+ * The iTCO v1 and v2's internal timer is stored as ticks which decrement
+ * every 0.6 seconds.  v3's internal timer is stored as seconds (some
+ * datasheets incorrectly state 0.6 seconds).
+ */
+static inline unsigned int seconds_to_ticks(int secs)
 {
-       /* the internal timer is stored as ticks which decrement
-        * every 0.6 seconds */
-       return (seconds * 10) / 6;
+       return iTCO_wdt_private.iTCO_version == 3 ? secs : (secs * 10) / 6;
+}
+
+static inline unsigned int ticks_to_seconds(int ticks)
+{
+       return iTCO_wdt_private.iTCO_version == 3 ? ticks : (ticks * 6) / 10;
 }
 
 static void iTCO_wdt_set_NO_REBOOT_bit(void)
@@ -137,10 +148,14 @@ static void iTCO_wdt_set_NO_REBOOT_bit(void)
        u32 val32;
 
        /* Set the NO_REBOOT bit: this disables reboots */
-       if (iTCO_wdt_private.iTCO_version == 2) {
-               val32 = readl(iTCO_wdt_private.gcs);
+       if (iTCO_wdt_private.iTCO_version == 3) {
+               val32 = readl(iTCO_wdt_private.gcs_pmc);
+               val32 |= 0x00000010;
+               writel(val32, iTCO_wdt_private.gcs_pmc);
+       } else if (iTCO_wdt_private.iTCO_version == 2) {
+               val32 = readl(iTCO_wdt_private.gcs_pmc);
                val32 |= 0x00000020;
-               writel(val32, iTCO_wdt_private.gcs);
+               writel(val32, iTCO_wdt_private.gcs_pmc);
        } else if (iTCO_wdt_private.iTCO_version == 1) {
                pci_read_config_dword(iTCO_wdt_private.pdev, 0xd4, &val32);
                val32 |= 0x00000002;
@@ -154,12 +169,20 @@ static int iTCO_wdt_unset_NO_REBOOT_bit(void)
        u32 val32;
 
        /* Unset the NO_REBOOT bit: this enables reboots */
-       if (iTCO_wdt_private.iTCO_version == 2) {
-               val32 = readl(iTCO_wdt_private.gcs);
+       if (iTCO_wdt_private.iTCO_version == 3) {
+               val32 = readl(iTCO_wdt_private.gcs_pmc);
+               val32 &= 0xffffffef;
+               writel(val32, iTCO_wdt_private.gcs_pmc);
+
+               val32 = readl(iTCO_wdt_private.gcs_pmc);
+               if (val32 & 0x00000010)
+                       ret = -EIO;
+       } else if (iTCO_wdt_private.iTCO_version == 2) {
+               val32 = readl(iTCO_wdt_private.gcs_pmc);
                val32 &= 0xffffffdf;
-               writel(val32, iTCO_wdt_private.gcs);
+               writel(val32, iTCO_wdt_private.gcs_pmc);
 
-               val32 = readl(iTCO_wdt_private.gcs);
+               val32 = readl(iTCO_wdt_private.gcs_pmc);
                if (val32 & 0x00000020)
                        ret = -EIO;
        } else if (iTCO_wdt_private.iTCO_version == 1) {
@@ -192,7 +215,7 @@ static int iTCO_wdt_start(struct watchdog_device *wd_dev)
 
        /* Force the timer to its reload value by writing to the TCO_RLD
           register */
-       if (iTCO_wdt_private.iTCO_version == 2)
+       if (iTCO_wdt_private.iTCO_version >= 2)
                outw(0x01, TCO_RLD);
        else if (iTCO_wdt_private.iTCO_version == 1)
                outb(0x01, TCO_RLD);
@@ -240,9 +263,9 @@ static int iTCO_wdt_ping(struct watchdog_device *wd_dev)
        iTCO_vendor_pre_keepalive(iTCO_wdt_private.smi_res, wd_dev->timeout);
 
        /* Reload the timer by writing to the TCO Timer Counter register */
-       if (iTCO_wdt_private.iTCO_version == 2)
+       if (iTCO_wdt_private.iTCO_version >= 2) {
                outw(0x01, TCO_RLD);
-       else if (iTCO_wdt_private.iTCO_version == 1) {
+       else if (iTCO_wdt_private.iTCO_version == 1) {
                /* Reset the timeout status bit so that the timer
                 * needs to count down twice again before rebooting */
                outw(0x0008, TCO1_STS); /* write 1 to clear bit */
@@ -270,14 +293,14 @@ static int iTCO_wdt_set_timeout(struct watchdog_device *wd_dev, unsigned int t)
        /* "Values of 0h-3h are ignored and should not be attempted" */
        if (tmrval < 0x04)
                return -EINVAL;
-       if (((iTCO_wdt_private.iTCO_version == 2) && (tmrval > 0x3ff)) ||
+       if (((iTCO_wdt_private.iTCO_version >= 2) && (tmrval > 0x3ff)) ||
            ((iTCO_wdt_private.iTCO_version == 1) && (tmrval > 0x03f)))
                return -EINVAL;
 
        iTCO_vendor_pre_set_heartbeat(tmrval);
 
        /* Write new heartbeat to watchdog */
-       if (iTCO_wdt_private.iTCO_version == 2) {
+       if (iTCO_wdt_private.iTCO_version >= 2) {
                spin_lock(&iTCO_wdt_private.io_lock);
                val16 = inw(TCOv2_TMR);
                val16 &= 0xfc00;
@@ -312,13 +335,13 @@ static unsigned int iTCO_wdt_get_timeleft(struct watchdog_device *wd_dev)
        unsigned int time_left = 0;
 
        /* read the TCO Timer */
-       if (iTCO_wdt_private.iTCO_version == 2) {
+       if (iTCO_wdt_private.iTCO_version >= 2) {
                spin_lock(&iTCO_wdt_private.io_lock);
                val16 = inw(TCO_RLD);
                val16 &= 0x3ff;
                spin_unlock(&iTCO_wdt_private.io_lock);
 
-               time_left = (val16 * 6) / 10;
+               time_left = ticks_to_seconds(val16);
        } else if (iTCO_wdt_private.iTCO_version == 1) {
                spin_lock(&iTCO_wdt_private.io_lock);
                val8 = inb(TCO_RLD);
@@ -327,7 +350,7 @@ static unsigned int iTCO_wdt_get_timeleft(struct watchdog_device *wd_dev)
                        val8 += (inb(TCOv1_TMR) & 0x3f);
                spin_unlock(&iTCO_wdt_private.io_lock);
 
-               time_left = (val8 * 6) / 10;
+               time_left = ticks_to_seconds(val8);
        }
        return time_left;
 }
@@ -347,15 +370,15 @@ static const struct watchdog_info ident = {
 static const struct watchdog_ops iTCO_wdt_ops = {
        .owner =                THIS_MODULE,
        .start =                iTCO_wdt_start,
-       .stop =                 iTCO_wdt_stop,
-       .ping =                 iTCO_wdt_ping,
+       .stop =                 iTCO_wdt_stop,
+       .ping =                 iTCO_wdt_ping,
        .set_timeout =          iTCO_wdt_set_timeout,
        .get_timeleft =         iTCO_wdt_get_timeleft,
 };
 
 static struct watchdog_device iTCO_wdt_watchdog_dev = {
        .info =         &ident,
-       .ops =          &iTCO_wdt_ops,
+       .ops =          &iTCO_wdt_ops,
 };
 
 /*
@@ -376,16 +399,16 @@ static void iTCO_wdt_cleanup(void)
                        resource_size(iTCO_wdt_private.tco_res));
        release_region(iTCO_wdt_private.smi_res->start,
                        resource_size(iTCO_wdt_private.smi_res));
-       if (iTCO_wdt_private.iTCO_version == 2) {
-               iounmap(iTCO_wdt_private.gcs);
-               release_mem_region(iTCO_wdt_private.gcs_res->start,
-                               resource_size(iTCO_wdt_private.gcs_res));
+       if (iTCO_wdt_private.iTCO_version >= 2) {
+               iounmap(iTCO_wdt_private.gcs_pmc);
+               release_mem_region(iTCO_wdt_private.gcs_pmc_res->start,
+                               resource_size(iTCO_wdt_private.gcs_pmc_res));
        }
 
        iTCO_wdt_private.tco_res = NULL;
        iTCO_wdt_private.smi_res = NULL;
-       iTCO_wdt_private.gcs_res = NULL;
-       iTCO_wdt_private.gcs = NULL;
+       iTCO_wdt_private.gcs_pmc_res = NULL;
+       iTCO_wdt_private.gcs_pmc = NULL;
 }
 
 static int iTCO_wdt_probe(struct platform_device *dev)
@@ -414,27 +437,27 @@ static int iTCO_wdt_probe(struct platform_device *dev)
        iTCO_wdt_private.pdev = to_pci_dev(dev->dev.parent);
 
        /*
-        * Get the Memory-Mapped GCS register, we need it for the
-        * NO_REBOOT flag (TCO v2).
+        * Get the Memory-Mapped GCS or PMC register, we need it for the
+        * NO_REBOOT flag (TCO v2 and v3).
         */
-       if (iTCO_wdt_private.iTCO_version == 2) {
-               iTCO_wdt_private.gcs_res = platform_get_resource(dev,
+       if (iTCO_wdt_private.iTCO_version >= 2) {
+               iTCO_wdt_private.gcs_pmc_res = platform_get_resource(dev,
                                                        IORESOURCE_MEM,
-                                                       ICH_RES_MEM_GCS);
+                                                       ICH_RES_MEM_GCS_PMC);
 
-               if (!iTCO_wdt_private.gcs_res)
+               if (!iTCO_wdt_private.gcs_pmc_res)
                        goto out;
 
-               if (!request_mem_region(iTCO_wdt_private.gcs_res->start,
-                       resource_size(iTCO_wdt_private.gcs_res), dev->name)) {
+               if (!request_mem_region(iTCO_wdt_private.gcs_pmc_res->start,
+                       resource_size(iTCO_wdt_private.gcs_pmc_res), dev->name)) {
                        ret = -EBUSY;
                        goto out;
                }
-               iTCO_wdt_private.gcs = ioremap(iTCO_wdt_private.gcs_res->start,
-                       resource_size(iTCO_wdt_private.gcs_res));
-               if (!iTCO_wdt_private.gcs) {
+               iTCO_wdt_private.gcs_pmc = ioremap(iTCO_wdt_private.gcs_pmc_res->start,
+                       resource_size(iTCO_wdt_private.gcs_pmc_res));
+               if (!iTCO_wdt_private.gcs_pmc) {
                        ret = -EIO;
-                       goto unreg_gcs;
+                       goto unreg_gcs_pmc;
                }
        }
 
@@ -442,7 +465,7 @@ static int iTCO_wdt_probe(struct platform_device *dev)
        if (iTCO_wdt_unset_NO_REBOOT_bit() && iTCO_vendor_check_noreboot_on()) {
                pr_info("unable to reset NO_REBOOT flag, device disabled by hardware/BIOS\n");
                ret = -ENODEV;  /* Cannot reset NO_REBOOT bit */
-               goto unmap_gcs;
+               goto unmap_gcs_pmc;
        }
 
        /* Set the NO_REBOOT bit to prevent later reboots, just for sure */
@@ -454,7 +477,7 @@ static int iTCO_wdt_probe(struct platform_device *dev)
                pr_err("I/O address 0x%04llx already in use, device disabled\n",
                       (u64)SMI_EN);
                ret = -EBUSY;
-               goto unmap_gcs;
+               goto unmap_gcs_pmc;
        }
        if (turn_SMI_watchdog_clear_off >= iTCO_wdt_private.iTCO_version) {
                /*
@@ -478,14 +501,18 @@ static int iTCO_wdt_probe(struct platform_device *dev)
                ich_info->name, ich_info->iTCO_version, (u64)TCOBASE);
 
        /* Clear out the (probably old) status */
-       outw(0x0008, TCO1_STS); /* Clear the Time Out Status bit */
-       outw(0x0002, TCO2_STS); /* Clear SECOND_TO_STS bit */
-       outw(0x0004, TCO2_STS); /* Clear BOOT_STS bit */
+       if (iTCO_wdt_private.iTCO_version == 3) {
+               outl(0x20008, TCO1_STS);
+       } else {
+               outw(0x0008, TCO1_STS); /* Clear the Time Out Status bit */
+               outw(0x0002, TCO2_STS); /* Clear SECOND_TO_STS bit */
+               outw(0x0004, TCO2_STS); /* Clear BOOT_STS bit */
+       }
 
        iTCO_wdt_watchdog_dev.bootstatus = 0;
        iTCO_wdt_watchdog_dev.timeout = WATCHDOG_TIMEOUT;
        watchdog_set_nowayout(&iTCO_wdt_watchdog_dev, nowayout);
-       iTCO_wdt_watchdog_dev.parent = dev->dev.parent;
+       iTCO_wdt_watchdog_dev.parent = &dev->dev;
 
        /* Make sure the watchdog is not running */
        iTCO_wdt_stop(&iTCO_wdt_watchdog_dev);
@@ -515,18 +542,18 @@ unreg_tco:
 unreg_smi:
        release_region(iTCO_wdt_private.smi_res->start,
                        resource_size(iTCO_wdt_private.smi_res));
-unmap_gcs:
-       if (iTCO_wdt_private.iTCO_version == 2)
-               iounmap(iTCO_wdt_private.gcs);
-unreg_gcs:
-       if (iTCO_wdt_private.iTCO_version == 2)
-               release_mem_region(iTCO_wdt_private.gcs_res->start,
-                               resource_size(iTCO_wdt_private.gcs_res));
+unmap_gcs_pmc:
+       if (iTCO_wdt_private.iTCO_version >= 2)
+               iounmap(iTCO_wdt_private.gcs_pmc);
+unreg_gcs_pmc:
+       if (iTCO_wdt_private.iTCO_version >= 2)
+               release_mem_region(iTCO_wdt_private.gcs_pmc_res->start,
+                               resource_size(iTCO_wdt_private.gcs_pmc_res));
 out:
        iTCO_wdt_private.tco_res = NULL;
        iTCO_wdt_private.smi_res = NULL;
-       iTCO_wdt_private.gcs_res = NULL;
-       iTCO_wdt_private.gcs = NULL;
+       iTCO_wdt_private.gcs_pmc_res = NULL;
+       iTCO_wdt_private.gcs_pmc = NULL;
 
        return ret;
 }
index db0a344..366b047 100644 (file)
@@ -360,7 +360,7 @@ struct ibmasr_id {
        int type;
 };
 
-static struct ibmasr_id __initdata ibmasr_id_table[] = {
+static struct ibmasr_id ibmasr_id_table[] __initdata = {
        { "IBM Automatic Server Restart - eserver xSeries 220", ASMTYPE_TOPAZ },
        { "IBM Automatic Server Restart - Machine Type 8673", ASMTYPE_PEARL },
        { "IBM Automatic Server Restart - Machine Type 8480", ASMTYPE_JASPER },
index 5211d56..9f15dd9 100644 (file)
@@ -512,9 +512,8 @@ static int __init pc87413_init(void)
                return -EBUSY;
 
        ret = register_reboot_notifier(&pc87413_notifier);
-       if (ret != 0) {
+       if (ret != 0)
                pr_err("cannot register reboot notifier (err=%d)\n", ret);
-       }
 
        ret = misc_register(&pc87413_miscdev);
        if (ret != 0) {
@@ -575,8 +574,8 @@ static void __exit pc87413_exit(void)
 module_init(pc87413_init);
 module_exit(pc87413_exit);
 
-MODULE_AUTHOR("Sven Anders <anders@anduras.de>, "
-               "Marcus Junker <junker@anduras.de>,");
+MODULE_AUTHOR("Sven Anders <anders@anduras.de>");
+MODULE_AUTHOR("Marcus Junker <junker@anduras.de>");
 MODULE_DESCRIPTION("PC87413 WDT driver");
 MODULE_LICENSE("GPL");
 
index c04a1aa..0dc5e32 100644 (file)
@@ -62,7 +62,7 @@ MODULE_PARM_DESC(nowayout,
                "Watchdog cannot be stopped once started (default="
                                __MODULE_STRING(WATCHDOG_NOWAYOUT) ")");
 
-static int soft_noboot = 0;
+static int soft_noboot;
 module_param(soft_noboot, int, 0);
 MODULE_PARM_DESC(soft_noboot,
        "Softdog action, set to 1 to ignore reboots, 0 to reboot (default=0)");
index 68b45fc..e9ea856 100644 (file)
@@ -455,6 +455,6 @@ module_init(wdt_init);
 module_exit(wdt_exit);
 
 MODULE_LICENSE("GPL");
-MODULE_AUTHOR("Marcus Junker <junker@anduras.de>, "
-               "Samuel Tardieu <sam@rfc1149.net>");
+MODULE_AUTHOR("Marcus Junker <junker@anduras.de>");
+MODULE_AUTHOR("Samuel Tardieu <sam@rfc1149.net>");
 MODULE_DESCRIPTION("w83697hf/hg WDT driver");
index d5afe96..975e1cc 100644 (file)
@@ -327,7 +327,7 @@ static inline void iounmap(void __iomem *addr)
 }
 #endif /* CONFIG_MMU */
 
-#ifdef CONFIG_HAS_IOPORT
+#ifdef CONFIG_HAS_IOPORT_MAP
 #ifndef CONFIG_GENERIC_IOMAP
 static inline void __iomem *ioport_map(unsigned long port, unsigned int nr)
 {
@@ -341,7 +341,7 @@ static inline void ioport_unmap(void __iomem *p)
 extern void __iomem *ioport_map(unsigned long port, unsigned int nr);
 extern void ioport_unmap(void __iomem *p);
 #endif /* CONFIG_GENERIC_IOMAP */
-#endif /* CONFIG_HAS_IOPORT */
+#endif /* CONFIG_HAS_IOPORT_MAP */
 
 #ifndef xlate_dev_kmem_ptr
 #define xlate_dev_kmem_ptr(p)  p
index 6afd7d6..1b41011 100644 (file)
@@ -56,7 +56,7 @@ extern void iowrite8_rep(void __iomem *port, const void *buf, unsigned long coun
 extern void iowrite16_rep(void __iomem *port, const void *buf, unsigned long count);
 extern void iowrite32_rep(void __iomem *port, const void *buf, unsigned long count);
 
-#ifdef CONFIG_HAS_IOPORT
+#ifdef CONFIG_HAS_IOPORT_MAP
 /* Create a virtual mapping cookie for an IO port range */
 extern void __iomem *ioport_map(unsigned long port, unsigned int nr);
 extern void ioport_unmap(void __iomem *);
diff --git a/include/dt-bindings/clock/r7s72100-clock.h b/include/dt-bindings/clock/r7s72100-clock.h
new file mode 100644 (file)
index 0000000..5128f4d
--- /dev/null
@@ -0,0 +1,41 @@
+/*
+ * Copyright (C) 2014 Renesas Solutions Corp.
+ * Copyright (C) 2014 Wolfram Sang, Sang Engineering <wsa@sang-engineering.com>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; version 2 of the License.
+ */
+
+#ifndef __DT_BINDINGS_CLOCK_R7S72100_H__
+#define __DT_BINDINGS_CLOCK_R7S72100_H__
+
+#define R7S72100_CLK_PLL       0
+
+/* MSTP3 */
+#define R7S72100_CLK_MTU2      3
+
+/* MSTP4 */
+#define R7S72100_CLK_SCIF0     7
+#define R7S72100_CLK_SCIF1     6
+#define R7S72100_CLK_SCIF2     5
+#define R7S72100_CLK_SCIF3     4
+#define R7S72100_CLK_SCIF4     3
+#define R7S72100_CLK_SCIF5     2
+#define R7S72100_CLK_SCIF6     1
+#define R7S72100_CLK_SCIF7     0
+
+/* MSTP9 */
+#define R7S72100_CLK_I2C0      7
+#define R7S72100_CLK_I2C1      6
+#define R7S72100_CLK_I2C2      5
+#define R7S72100_CLK_I2C3      4
+
+/* MSTP10 */
+#define R7S72100_CLK_SPI0      7
+#define R7S72100_CLK_SPI1      6
+#define R7S72100_CLK_SPI2      5
+#define R7S72100_CLK_SPI3      4
+#define R7S72100_CLK_SPI4      3
+
+#endif /* __DT_BINDINGS_CLOCK_R7S72100_H__ */
diff --git a/include/dt-bindings/clock/r8a7740-clock.h b/include/dt-bindings/clock/r8a7740-clock.h
new file mode 100644 (file)
index 0000000..f6b4b0f
--- /dev/null
@@ -0,0 +1,77 @@
+/*
+ * Copyright 2014 Ulrich Hecht
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ */
+
+#ifndef __DT_BINDINGS_CLOCK_R8A7740_H__
+#define __DT_BINDINGS_CLOCK_R8A7740_H__
+
+/* CPG */
+#define R8A7740_CLK_SYSTEM     0
+#define R8A7740_CLK_PLLC0      1
+#define R8A7740_CLK_PLLC1      2
+#define R8A7740_CLK_PLLC2      3
+#define R8A7740_CLK_R          4
+#define R8A7740_CLK_USB24S     5
+#define R8A7740_CLK_I          6
+#define R8A7740_CLK_ZG         7
+#define R8A7740_CLK_B          8
+#define R8A7740_CLK_M1         9
+#define R8A7740_CLK_HP         10
+#define R8A7740_CLK_HPP                11
+#define R8A7740_CLK_USBP       12
+#define R8A7740_CLK_S          13
+#define R8A7740_CLK_ZB         14
+#define R8A7740_CLK_M3         15
+#define R8A7740_CLK_CP         16
+
+/* MSTP1 */
+#define R8A7740_CLK_CEU21      28
+#define R8A7740_CLK_CEU20      27
+#define R8A7740_CLK_TMU0       25
+#define R8A7740_CLK_LCDC1      17
+#define R8A7740_CLK_IIC0       16
+#define R8A7740_CLK_TMU1       11
+#define R8A7740_CLK_LCDC0      0
+
+/* MSTP2 */
+#define R8A7740_CLK_SCIFA6     30
+#define R8A7740_CLK_SCIFA7     22
+#define R8A7740_CLK_DMAC1      18
+#define R8A7740_CLK_DMAC2      17
+#define R8A7740_CLK_DMAC3      16
+#define R8A7740_CLK_USBDMAC    14
+#define R8A7740_CLK_SCIFA5     7
+#define R8A7740_CLK_SCIFB      6
+#define R8A7740_CLK_SCIFA0     4
+#define R8A7740_CLK_SCIFA1     3
+#define R8A7740_CLK_SCIFA2     2
+#define R8A7740_CLK_SCIFA3     1
+#define R8A7740_CLK_SCIFA4     0
+
+/* MSTP3 */
+#define R8A7740_CLK_CMT1       29
+#define R8A7740_CLK_FSI                28
+#define R8A7740_CLK_IIC1       23
+#define R8A7740_CLK_USBF       20
+#define R8A7740_CLK_SDHI0      14
+#define R8A7740_CLK_SDHI1      13
+#define R8A7740_CLK_MMC                12
+#define R8A7740_CLK_GETHER     9
+#define R8A7740_CLK_TPU0       4
+
+/* MSTP4 */
+#define R8A7740_CLK_USBH       16
+#define R8A7740_CLK_SDHI2      15
+#define R8A7740_CLK_USBFUNC    7
+#define R8A7740_CLK_USBPHY     6
+
+/* SUBCK* */
+#define R8A7740_CLK_SUBCK      9
+#define R8A7740_CLK_SUBCK2     10
+
+#endif /* __DT_BINDINGS_CLOCK_R8A7740_H__ */
diff --git a/include/dt-bindings/clock/r8a7779-clock.h b/include/dt-bindings/clock/r8a7779-clock.h
new file mode 100644 (file)
index 0000000..381a611
--- /dev/null
@@ -0,0 +1,64 @@
+/*
+ * Copyright (C) 2013  Horms Solutions Ltd.
+ *
+ * Contact: Simon Horman <horms@verge.net.au>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ */
+
+#ifndef __DT_BINDINGS_CLOCK_R8A7779_H__
+#define __DT_BINDINGS_CLOCK_R8A7779_H__
+
+/* CPG */
+#define R8A7779_CLK_PLLA       0
+#define R8A7779_CLK_Z          1
+#define R8A7779_CLK_ZS         2
+#define R8A7779_CLK_S          3
+#define R8A7779_CLK_S1         4
+#define R8A7779_CLK_P          5
+#define R8A7779_CLK_B          6
+#define R8A7779_CLK_OUT                7
+
+/* MSTP 0 */
+#define R8A7779_CLK_HSPI       7
+#define R8A7779_CLK_TMU2       14
+#define R8A7779_CLK_TMU1       15
+#define R8A7779_CLK_TMU0       16
+#define R8A7779_CLK_HSCIF1     18
+#define R8A7779_CLK_HSCIF0     19
+#define R8A7779_CLK_SCIF5      21
+#define R8A7779_CLK_SCIF4      22
+#define R8A7779_CLK_SCIF3      23
+#define R8A7779_CLK_SCIF2      24
+#define R8A7779_CLK_SCIF1      25
+#define R8A7779_CLK_SCIF0      26
+#define R8A7779_CLK_I2C3       27
+#define R8A7779_CLK_I2C2       28
+#define R8A7779_CLK_I2C1       29
+#define R8A7779_CLK_I2C0       30
+
+/* MSTP 1 */
+#define R8A7779_CLK_USB01      0
+#define R8A7779_CLK_USB2       1
+#define R8A7779_CLK_DU         3
+#define R8A7779_CLK_VIN2       8
+#define R8A7779_CLK_VIN1       9
+#define R8A7779_CLK_VIN0       10
+#define R8A7779_CLK_ETHER      14
+#define R8A7779_CLK_SATA       15
+#define R8A7779_CLK_PCIE       16
+#define R8A7779_CLK_VIN3       20
+
+/* MSTP 3 */
+#define R8A7779_CLK_SDHI3      20
+#define R8A7779_CLK_SDHI2      21
+#define R8A7779_CLK_SDHI1      22
+#define R8A7779_CLK_SDHI0      23
+#define R8A7779_CLK_MMC1       30
+#define R8A7779_CLK_MMC0       31
+
+
+#endif /* __DT_BINDINGS_CLOCK_R8A7779_H__ */
index 859e9be..8ea7ab0 100644 (file)
@@ -26,6 +26,7 @@
 #define R8A7790_CLK_MSIOF0             0
 
 /* MSTP1 */
+#define R8A7790_CLK_JPU                6
 #define R8A7790_CLK_TMU1               11
 #define R8A7790_CLK_TMU3               21
 #define R8A7790_CLK_TMU2               22
@@ -33,8 +34,8 @@
 #define R8A7790_CLK_TMU0               25
 #define R8A7790_CLK_VSP1_DU1           27
 #define R8A7790_CLK_VSP1_DU0           28
-#define R8A7790_CLK_VSP1_RT            30
-#define R8A7790_CLK_VSP1_SY            31
+#define R8A7790_CLK_VSP1_R             30
+#define R8A7790_CLK_VSP1_S             31
 
 /* MSTP2 */
 #define R8A7790_CLK_SCIFA2             2
 #define R8A7790_CLK_MSIOF1             8
 #define R8A7790_CLK_MSIOF3             15
 #define R8A7790_CLK_SCIFB2             16
-#define R8A7790_CLK_SYS_DMAC0          18
-#define R8A7790_CLK_SYS_DMAC1          19
+#define R8A7790_CLK_SYS_DMAC1          18
+#define R8A7790_CLK_SYS_DMAC0          19
 
 /* MSTP3 */
+#define R8A7790_CLK_IIC2               0
 #define R8A7790_CLK_TPU0               4
 #define R8A7790_CLK_MMCIF1             5
 #define R8A7790_CLK_SDHI3              11
@@ -57,6 +59,9 @@
 #define R8A7790_CLK_SDHI1              13
 #define R8A7790_CLK_SDHI0              14
 #define R8A7790_CLK_MMCIF0             15
+#define R8A7790_CLK_IIC0               18
+#define R8A7790_CLK_PCIEC              19
+#define R8A7790_CLK_IIC1               23
 #define R8A7790_CLK_SSUSB              28
 #define R8A7790_CLK_CMT1               29
 #define R8A7790_CLK_USBDMAC0           30
 #define R8A7790_CLK_I2C1               30
 #define R8A7790_CLK_I2C0               31
 
+/* MSTP10 */
+#define R8A7790_CLK_SSI_ALL            5
+#define R8A7790_CLK_SSI9               6
+#define R8A7790_CLK_SSI8               7
+#define R8A7790_CLK_SSI7               8
+#define R8A7790_CLK_SSI6               9
+#define R8A7790_CLK_SSI5               10
+#define R8A7790_CLK_SSI4               11
+#define R8A7790_CLK_SSI3               12
+#define R8A7790_CLK_SSI2               13
+#define R8A7790_CLK_SSI1               14
+#define R8A7790_CLK_SSI0               15
+#define R8A7790_CLK_SCU_ALL            17
+#define R8A7790_CLK_SCU_DVC1           18
+#define R8A7790_CLK_SCU_DVC0           19
+#define R8A7790_CLK_SCU_SRC9           22
+#define R8A7790_CLK_SCU_SRC8           23
+#define R8A7790_CLK_SCU_SRC7           24
+#define R8A7790_CLK_SCU_SRC6           25
+#define R8A7790_CLK_SCU_SRC5           26
+#define R8A7790_CLK_SCU_SRC4           27
+#define R8A7790_CLK_SCU_SRC3           28
+#define R8A7790_CLK_SCU_SRC2           29
+#define R8A7790_CLK_SCU_SRC1           30
+#define R8A7790_CLK_SCU_SRC0           31
+
 #endif /* __DT_BINDINGS_CLOCK_R8A7790_H__ */
index 30f82f2..58c3f49 100644 (file)
@@ -25,6 +25,7 @@
 #define R8A7791_CLK_MSIOF0             0
 
 /* MSTP1 */
+#define R8A7791_CLK_JPU                6
 #define R8A7791_CLK_TMU1               11
 #define R8A7791_CLK_TMU3               21
 #define R8A7791_CLK_TMU2               22
@@ -32,7 +33,7 @@
 #define R8A7791_CLK_TMU0               25
 #define R8A7791_CLK_VSP1_DU1           27
 #define R8A7791_CLK_VSP1_DU0           28
-#define R8A7791_CLK_VSP1_SY            31
+#define R8A7791_CLK_VSP1_S             31
 
 /* MSTP2 */
 #define R8A7791_CLK_SCIFA2             2
@@ -43,7 +44,8 @@
 #define R8A7791_CLK_SCIFB1             7
 #define R8A7791_CLK_MSIOF1             8
 #define R8A7791_CLK_SCIFB2             16
-#define R8A7791_CLK_DMAC               18
+#define R8A7791_CLK_SYS_DMAC1          18
+#define R8A7791_CLK_SYS_DMAC0          19
 
 /* MSTP3 */
 #define R8A7791_CLK_TPU0               4
@@ -51,6 +53,9 @@
 #define R8A7791_CLK_SDHI1              12
 #define R8A7791_CLK_SDHI0              14
 #define R8A7791_CLK_MMCIF0             15
+#define R8A7791_CLK_IIC0               18
+#define R8A7791_CLK_PCIEC              19
+#define R8A7791_CLK_IIC1               23
 #define R8A7791_CLK_SSUSB              28
 #define R8A7791_CLK_CMT1               29
 #define R8A7791_CLK_USBDMAC0           30
@@ -61,6 +66,7 @@
 #define R8A7791_CLK_PWM                        23
 
 /* MSTP7 */
+#define R8A7791_CLK_EHCI               3
 #define R8A7791_CLK_HSUSB              4
 #define R8A7791_CLK_HSCIF2             13
 #define R8A7791_CLK_SCIF5              14
 #define R8A7791_CLK_I2C1               30
 #define R8A7791_CLK_I2C0               31
 
+/* MSTP10 */
+#define R8A7791_CLK_SSI_ALL            5
+#define R8A7791_CLK_SSI9               6
+#define R8A7791_CLK_SSI8               7
+#define R8A7791_CLK_SSI7               8
+#define R8A7791_CLK_SSI6               9
+#define R8A7791_CLK_SSI5               10
+#define R8A7791_CLK_SSI4               11
+#define R8A7791_CLK_SSI3               12
+#define R8A7791_CLK_SSI2               13
+#define R8A7791_CLK_SSI1               14
+#define R8A7791_CLK_SSI0               15
+#define R8A7791_CLK_SCU_ALL            17
+#define R8A7791_CLK_SCU_DVC1           18
+#define R8A7791_CLK_SCU_DVC0           19
+#define R8A7791_CLK_SCU_SRC9           22
+#define R8A7791_CLK_SCU_SRC8           23
+#define R8A7791_CLK_SCU_SRC7           24
+#define R8A7791_CLK_SCU_SRC6           25
+#define R8A7791_CLK_SCU_SRC5           26
+#define R8A7791_CLK_SCU_SRC4           27
+#define R8A7791_CLK_SCU_SRC3           28
+#define R8A7791_CLK_SCU_SRC2           29
+#define R8A7791_CLK_SCU_SRC1           30
+#define R8A7791_CLK_SCU_SRC0           31
+
 /* MSTP11 */
 #define R8A7791_CLK_SCIFA3             6
 #define R8A7791_CLK_SCIFA4             7
diff --git a/include/dt-bindings/clock/r8a7794-clock.h b/include/dt-bindings/clock/r8a7794-clock.h
new file mode 100644 (file)
index 0000000..9ac1043
--- /dev/null
@@ -0,0 +1,80 @@
+/*
+ * Copyright (C) 2014 Renesas Electronics Corporation
+ * Copyright 2013 Ideas On Board SPRL
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ */
+
+#ifndef __DT_BINDINGS_CLOCK_R8A7794_H__
+#define __DT_BINDINGS_CLOCK_R8A7794_H__
+
+/* CPG */
+#define R8A7794_CLK_MAIN               0
+#define R8A7794_CLK_PLL0               1
+#define R8A7794_CLK_PLL1               2
+#define R8A7794_CLK_PLL3               3
+#define R8A7794_CLK_LB                 4
+#define R8A7794_CLK_QSPI               5
+#define R8A7794_CLK_SDH                        6
+#define R8A7794_CLK_SD0                        7
+#define R8A7794_CLK_Z                  8
+
+/* MSTP0 */
+#define R8A7794_CLK_MSIOF0             0
+
+/* MSTP1 */
+#define R8A7794_CLK_TMU1               11
+#define R8A7794_CLK_TMU3               21
+#define R8A7794_CLK_TMU2               22
+#define R8A7794_CLK_CMT0               24
+#define R8A7794_CLK_TMU0               25
+
+/* MSTP2 */
+#define R8A7794_CLK_SCIFA2             2
+#define R8A7794_CLK_SCIFA1             3
+#define R8A7794_CLK_SCIFA0             4
+#define R8A7794_CLK_MSIOF2             5
+#define R8A7794_CLK_SCIFB0             6
+#define R8A7794_CLK_SCIFB1             7
+#define R8A7794_CLK_MSIOF1             8
+#define R8A7794_CLK_SCIFB2             16
+
+/* MSTP3 */
+#define R8A7794_CLK_CMT1               29
+
+/* MSTP5 */
+#define R8A7794_CLK_THERMAL            22
+#define R8A7794_CLK_PWM                        23
+
+/* MSTP7 */
+#define R8A7794_CLK_HSCIF2             13
+#define R8A7794_CLK_SCIF5              14
+#define R8A7794_CLK_SCIF4              15
+#define R8A7794_CLK_HSCIF1             16
+#define R8A7794_CLK_HSCIF0             17
+#define R8A7794_CLK_SCIF3              18
+#define R8A7794_CLK_SCIF2              19
+#define R8A7794_CLK_SCIF1              20
+#define R8A7794_CLK_SCIF0              21
+
+/* MSTP8 */
+#define R8A7794_CLK_ETHER              13
+
+/* MSTP9 */
+#define R8A7794_CLK_GPIO6              5
+#define R8A7794_CLK_GPIO5              7
+#define R8A7794_CLK_GPIO4              8
+#define R8A7794_CLK_GPIO3              9
+#define R8A7794_CLK_GPIO2              10
+#define R8A7794_CLK_GPIO1              11
+#define R8A7794_CLK_GPIO0              12
+
+/* MSTP11 */
+#define R8A7794_CLK_SCIFA3             6
+#define R8A7794_CLK_SCIFA4             7
+#define R8A7794_CLK_SCIFA5             8
+
+#endif /* __DT_BINDINGS_CLOCK_R8A7794_H__ */
index f9bf080..9f8a140 100644 (file)
@@ -1,7 +1,9 @@
 /*
  * Copyright 2013 Ideas On Board SPRL
+ * Copyright 2013, 2014 Horms Solutions Ltd.
  *
  * Contact: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
+ * Contact: Simon Horman <horms@verge.net.au>
  *
  * 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
@@ -14,6 +16,7 @@
 
 #include <linux/types.h>
 
+void r8a7779_clocks_init(u32 mode);
 void rcar_gen2_clocks_init(u32 mode);
 
 #endif
index 4d89e0e..c7b85ee 100644 (file)
@@ -306,8 +306,6 @@ cpufreq_verify_within_cpu_limits(struct cpufreq_policy *policy)
 /* Transition notifiers */
 #define CPUFREQ_PRECHANGE              (0)
 #define CPUFREQ_POSTCHANGE             (1)
-#define CPUFREQ_RESUMECHANGE           (8)
-#define CPUFREQ_SUSPENDCHANGE          (9)
 
 /* Policy Notifiers  */
 #define CPUFREQ_ADJUST                 (0)
@@ -448,6 +446,35 @@ struct cpufreq_frequency_table {
                                    * order */
 };
 
+static inline bool cpufreq_next_valid(struct cpufreq_frequency_table **pos)
+{
+       while ((*pos)->frequency != CPUFREQ_TABLE_END)
+               if ((*pos)->frequency != CPUFREQ_ENTRY_INVALID)
+                       return true;
+               else
+                       (*pos)++;
+       return false;
+}
+
+/*
+ * cpufreq_for_each_entry -    iterate over a cpufreq_frequency_table
+ * @pos:       the cpufreq_frequency_table * to use as a loop cursor.
+ * @table:     the cpufreq_frequency_table * to iterate over.
+ */
+
+#define cpufreq_for_each_entry(pos, table)     \
+       for (pos = table; pos->frequency != CPUFREQ_TABLE_END; pos++)
+
+/*
+ * cpufreq_for_each_valid_entry -     iterate over a cpufreq_frequency_table
+ *     excluding CPUFREQ_ENTRY_INVALID frequencies.
+ * @pos:        the cpufreq_frequency_table * to use as a loop cursor.
+ * @table:      the cpufreq_frequency_table * to iterate over.
+ */
+
+#define cpufreq_for_each_valid_entry(pos, table)       \
+       for (pos = table; cpufreq_next_valid(&pos); pos++)
+
 int cpufreq_frequency_table_cpuinfo(struct cpufreq_policy *policy,
                                    struct cpufreq_frequency_table *table);
 
index 952b010..28f1363 100644 (file)
@@ -609,6 +609,10 @@ extern int devres_release_group(struct device *dev, void *id);
 
 /* managed devm_k.alloc/kfree for device drivers */
 extern void *devm_kmalloc(struct device *dev, size_t size, gfp_t gfp);
+extern char *devm_kvasprintf(struct device *dev, gfp_t gfp, const char *fmt,
+                            va_list ap);
+extern __printf(3, 4)
+char *devm_kasprintf(struct device *dev, gfp_t gfp, const char *fmt, ...);
 static inline void *devm_kzalloc(struct device *dev, size_t size, gfp_t gfp)
 {
        return devm_kmalloc(dev, size, gfp | __GFP_ZERO);
index deddeb8..b556e0a 100644 (file)
@@ -487,6 +487,7 @@ void i2c_unlock_adapter(struct i2c_adapter *);
 #define I2C_CLASS_HWMON                (1<<0)  /* lm_sensors, ... */
 #define I2C_CLASS_DDC          (1<<3)  /* DDC bus on graphics adapters */
 #define I2C_CLASS_SPD          (1<<7)  /* Memory modules */
+#define I2C_CLASS_DEPRECATED   (1<<8)  /* Warn users that adapter will stop using classes */
 
 /* Internal numbers to terminate lists */
 #define I2C_CLIENT_END         0xfffeU
index f4f42fa..3e35c18 100644 (file)
@@ -41,7 +41,7 @@ static inline int ioremap_page_range(unsigned long addr, unsigned long end,
 /*
  * Managed iomap interface
  */
-#ifdef CONFIG_HAS_IOPORT
+#ifdef CONFIG_HAS_IOPORT_MAP
 void __iomem * devm_ioport_map(struct device *dev, unsigned long port,
                               unsigned int nr);
 void devm_ioport_unmap(struct device *dev, void __iomem *addr);
index 3e1df64..8feac78 100644 (file)
 #define LPC_ICH_H
 
 /* Watchdog resources */
-#define ICH_RES_IO_TCO 0
-#define ICH_RES_IO_SMI 1
-#define ICH_RES_MEM_OFF        2
-#define ICH_RES_MEM_GCS        0
+#define ICH_RES_IO_TCO         0
+#define ICH_RES_IO_SMI         1
+#define ICH_RES_MEM_OFF                2
+#define ICH_RES_MEM_GCS_PMC    0
 
 /* GPIO resources */
 #define ICH_RES_GPIO   0
 #define ICH_RES_GPE0   1
 
 /* GPIO compatibility */
-#define ICH_I3100_GPIO         0x401
-#define ICH_V5_GPIO            0x501
-#define ICH_V6_GPIO            0x601
-#define ICH_V7_GPIO            0x701
-#define ICH_V9_GPIO            0x801
-#define ICH_V10CORP_GPIO       0xa01
-#define ICH_V10CONS_GPIO       0xa11
+enum {
+       ICH_I3100_GPIO,
+       ICH_V5_GPIO,
+       ICH_V6_GPIO,
+       ICH_V7_GPIO,
+       ICH_V9_GPIO,
+       ICH_V10CORP_GPIO,
+       ICH_V10CONS_GPIO,
+       AVOTON_GPIO,
+};
 
 struct lpc_ich_info {
        char name[32];
index 8f6f2e9..5738817 100644 (file)
@@ -5,6 +5,7 @@
 #include <linux/fb.h>
 #include <linux/io.h>
 #include <linux/jiffies.h>
+#include <linux/mmc/card.h>
 #include <linux/platform_device.h>
 #include <linux/pm_runtime.h>
 
  */
 #define TMIO_MMC_HAVE_HIGH_REG         (1 << 6)
 
+/*
+ * Some controllers have CMD12 automatically
+ * issue/non-issue register
+ */
+#define TMIO_MMC_HAVE_CMD12_CTRL       (1 << 7)
+
+/*
+ * Some controllers needs to set 1 on SDIO status reserved bits
+ */
+#define TMIO_MMC_SDIO_STATUS_QUIRK     (1 << 8)
+
+/*
+ * Some controllers have DMA enable/disable register
+ */
+#define TMIO_MMC_HAVE_CTL_DMA_REG      (1 << 9)
+
+/*
+ * Some controllers allows to set SDx actual clock
+ */
+#define TMIO_MMC_CLK_ACTUAL            (1 << 10)
+
 int tmio_core_mmc_enable(void __iomem *cnf, int shift, unsigned long base);
 int tmio_core_mmc_resume(void __iomem *cnf, int shift, unsigned long base);
 void tmio_core_mmc_pwr(void __iomem *cnf, int shift, int state);
@@ -96,6 +118,7 @@ struct tmio_mmc_dma {
        int slave_id_tx;
        int slave_id_rx;
        int alignment_shift;
+       dma_addr_t dma_rx_offset;
        bool (*filter)(struct dma_chan *chan, void *arg);
 };
 
@@ -120,6 +143,8 @@ struct tmio_mmc_data {
        /* clock management callbacks */
        int (*clk_enable)(struct platform_device *pdev, unsigned int *f);
        void (*clk_disable)(struct platform_device *pdev);
+       int (*multi_io_quirk)(struct mmc_card *card,
+                             unsigned int direction, int blk_size);
 };
 
 /*
index 99f5709..6cfd7f0 100644 (file)
@@ -58,7 +58,8 @@ struct mmc_ios {
 #define MMC_TIMING_UHS_SDR50   5
 #define MMC_TIMING_UHS_SDR104  6
 #define MMC_TIMING_UHS_DDR50   7
-#define MMC_TIMING_MMC_HS200   8
+#define MMC_TIMING_MMC_DDR52   8
+#define MMC_TIMING_MMC_HS200   9
 
 #define MMC_SDR_MODE           0
 #define MMC_1_2V_DDR_MODE      1
@@ -139,6 +140,13 @@ struct mmc_host_ops {
        int     (*select_drive_strength)(unsigned int max_dtr, int host_drv, int card_drv);
        void    (*hw_reset)(struct mmc_host *host);
        void    (*card_event)(struct mmc_host *host);
+
+       /*
+        * Optional callback to support controllers with HW issues for multiple
+        * I/O. Returns the number of supported blocks for the request.
+        */
+       int     (*multi_io_quirk)(struct mmc_card *card,
+                                 unsigned int direction, int blk_size);
 };
 
 struct mmc_card;
index 3f8144d..ddd1774 100644 (file)
@@ -198,6 +198,8 @@ extern struct device_node *of_find_node_with_property(
 extern struct property *of_find_property(const struct device_node *np,
                                         const char *name,
                                         int *lenp);
+extern int of_property_count_elems_of_size(const struct device_node *np,
+                               const char *propname, int elem_size);
 extern int of_property_read_u32_index(const struct device_node *np,
                                       const char *propname,
                                       u32 index, u32 *out_value);
@@ -388,6 +390,12 @@ static inline struct device_node *of_find_compatible_node(
        return NULL;
 }
 
+static inline int of_property_count_elems_of_size(const struct device_node *np,
+                       const char *propname, int elem_size)
+{
+       return -ENOSYS;
+}
+
 static inline int of_property_read_u32_index(const struct device_node *np,
                        const char *propname, u32 index, u32 *out_value)
 {
@@ -592,6 +600,74 @@ static inline int of_property_read_string_index(struct device_node *np,
 }
 
 /**
+ * of_property_count_u8_elems - Count the number of u8 elements in a property
+ *
+ * @np:                device node from which the property value is to be read.
+ * @propname:  name of the property to be searched.
+ *
+ * Search for a property in a device node and count the number of u8 elements
+ * in it. Returns number of elements on sucess, -EINVAL if the property does
+ * not exist or its length does not match a multiple of u8 and -ENODATA if the
+ * property does not have a value.
+ */
+static inline int of_property_count_u8_elems(const struct device_node *np,
+                               const char *propname)
+{
+       return of_property_count_elems_of_size(np, propname, sizeof(u8));
+}
+
+/**
+ * of_property_count_u16_elems - Count the number of u16 elements in a property
+ *
+ * @np:                device node from which the property value is to be read.
+ * @propname:  name of the property to be searched.
+ *
+ * Search for a property in a device node and count the number of u16 elements
+ * in it. Returns number of elements on sucess, -EINVAL if the property does
+ * not exist or its length does not match a multiple of u16 and -ENODATA if the
+ * property does not have a value.
+ */
+static inline int of_property_count_u16_elems(const struct device_node *np,
+                               const char *propname)
+{
+       return of_property_count_elems_of_size(np, propname, sizeof(u16));
+}
+
+/**
+ * of_property_count_u32_elems - Count the number of u32 elements in a property
+ *
+ * @np:                device node from which the property value is to be read.
+ * @propname:  name of the property to be searched.
+ *
+ * Search for a property in a device node and count the number of u32 elements
+ * in it. Returns number of elements on sucess, -EINVAL if the property does
+ * not exist or its length does not match a multiple of u32 and -ENODATA if the
+ * property does not have a value.
+ */
+static inline int of_property_count_u32_elems(const struct device_node *np,
+                               const char *propname)
+{
+       return of_property_count_elems_of_size(np, propname, sizeof(u32));
+}
+
+/**
+ * of_property_count_u64_elems - Count the number of u64 elements in a property
+ *
+ * @np:                device node from which the property value is to be read.
+ * @propname:  name of the property to be searched.
+ *
+ * Search for a property in a device node and count the number of u64 elements
+ * in it. Returns number of elements on sucess, -EINVAL if the property does
+ * not exist or its length does not match a multiple of u64 and -ENODATA if the
+ * property does not have a value.
+ */
+static inline int of_property_count_u64_elems(const struct device_node *np,
+                               const char *propname)
+{
+       return of_property_count_elems_of_size(np, propname, sizeof(u64));
+}
+
+/**
  * of_property_read_bool - Findfrom a property
  * @np:                device node from which the property value is to be read.
  * @propname:  name of the property to be searched.
index 2b77058..5d9abdf 100644 (file)
@@ -66,7 +66,7 @@ extern char *of_fdt_get_string(struct boot_param_header *blob, u32 offset);
 extern void *of_fdt_get_property(struct boot_param_header *blob,
                                 unsigned long node,
                                 const char *name,
-                                unsigned long *size);
+                                int *size);
 extern int of_fdt_is_compatible(struct boot_param_header *blob,
                                unsigned long node,
                                const char *compat);
@@ -85,8 +85,8 @@ extern char *find_flat_dt_string(u32 offset);
 extern int of_scan_flat_dt(int (*it)(unsigned long node, const char *uname,
                                     int depth, void *data),
                           void *data);
-extern void *of_get_flat_dt_prop(unsigned long node, const char *name,
-                                unsigned long *size);
+extern const void *of_get_flat_dt_prop(unsigned long node, const char *name,
+                                      int *size);
 extern int of_flat_dt_is_compatible(unsigned long node, const char *name);
 extern int of_flat_dt_match(unsigned long node, const char *const *matches);
 extern unsigned long of_get_flat_dt_root(void);
@@ -100,7 +100,7 @@ extern int early_init_dt_scan_memory(unsigned long node, const char *uname,
                                     int depth, void *data);
 extern void early_init_dt_add_memory_arch(u64 base, u64 size);
 extern void * early_init_dt_alloc_memory_arch(u64 size, u64 align);
-extern u64 dt_mem_next_cell(int s, __be32 **cellp);
+extern u64 dt_mem_next_cell(int s, const __be32 **cellp);
 
 /* Early flat tree scan hooks */
 extern int early_init_dt_scan_root(unsigned long node, const char *uname,
diff --git a/include/linux/of_graph.h b/include/linux/of_graph.h
new file mode 100644 (file)
index 0000000..2b233db
--- /dev/null
@@ -0,0 +1,66 @@
+/*
+ * OF graph binding parsing helpers
+ *
+ * Copyright (C) 2012 - 2013 Samsung Electronics Co., Ltd.
+ * Author: Sylwester Nawrocki <s.nawrocki@samsung.com>
+ *
+ * Copyright (C) 2012 Renesas Electronics Corp.
+ * Author: Guennadi Liakhovetski <g.liakhovetski@gmx.de>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of version 2 of the GNU General Public License as
+ * published by the Free Software Foundation.
+ */
+#ifndef __LINUX_OF_GRAPH_H
+#define __LINUX_OF_GRAPH_H
+
+/**
+ * struct of_endpoint - the OF graph endpoint data structure
+ * @port: identifier (value of reg property) of a port this endpoint belongs to
+ * @id: identifier (value of reg property) of this endpoint
+ * @local_node: pointer to device_node of this endpoint
+ */
+struct of_endpoint {
+       unsigned int port;
+       unsigned int id;
+       const struct device_node *local_node;
+};
+
+#ifdef CONFIG_OF
+int of_graph_parse_endpoint(const struct device_node *node,
+                               struct of_endpoint *endpoint);
+struct device_node *of_graph_get_next_endpoint(const struct device_node *parent,
+                                       struct device_node *previous);
+struct device_node *of_graph_get_remote_port_parent(
+                                       const struct device_node *node);
+struct device_node *of_graph_get_remote_port(const struct device_node *node);
+#else
+
+static inline int of_graph_parse_endpoint(const struct device_node *node,
+                                       struct of_endpoint *endpoint);
+{
+       return -ENOSYS;
+}
+
+static inline struct device_node *of_graph_get_next_endpoint(
+                                       const struct device_node *parent,
+                                       struct device_node *previous)
+{
+       return NULL;
+}
+
+static inline struct device_node *of_graph_get_remote_port_parent(
+                                       const struct device_node *node)
+{
+       return NULL;
+}
+
+static inline struct device_node *of_graph_get_remote_port(
+                                       const struct device_node *node)
+{
+       return NULL;
+}
+
+#endif /* CONFIG_OF */
+
+#endif /* __LINUX_OF_GRAPH_H */
index a15f107..d578a60 100644 (file)
@@ -57,7 +57,7 @@
  *     which are then pulled up with an external resistor. Setting this
  *     config will enable open drain mode, the argument is ignored.
  * @PIN_CONFIG_DRIVE_OPEN_SOURCE: the pin will be driven with open source
- *     (open emitter). Setting this config will enable open drain mode, the
+ *     (open emitter). Setting this config will enable open source mode, the
  *     argument is ignored.
  * @PIN_CONFIG_DRIVE_STRENGTH: the pin will sink or source at most the current
  *     passed as argument. The argument is in mA.
diff --git a/include/linux/platform_data/dma-rcar-audmapp.h b/include/linux/platform_data/dma-rcar-audmapp.h
new file mode 100644 (file)
index 0000000..471fffe
--- /dev/null
@@ -0,0 +1,34 @@
+/*
+ * This is for Renesas R-Car Audio-DMAC-peri-peri.
+ *
+ * Copyright (C) 2014 Renesas Electronics Corporation
+ * Copyright (C) 2014 Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
+ *
+ * This file is based on the include/linux/sh_dma.h
+ *
+ * Header for the new SH dmaengine driver
+ *
+ * Copyright (C) 2010 Guennadi Liakhovetski <g.liakhovetski@gmx.de>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ */
+#ifndef SH_AUDMAPP_H
+#define SH_AUDMAPP_H
+
+#include <linux/dmaengine.h>
+
+struct audmapp_slave_config {
+       int             slave_id;
+       dma_addr_t      src;
+       dma_addr_t      dst;
+       u32             chcr;
+};
+
+struct audmapp_pdata {
+       struct audmapp_slave_config *slave;
+       int slave_num;
+};
+
+#endif /* SH_AUDMAPP_H */
index 1a2e990..a5f045e 100644 (file)
@@ -14,7 +14,7 @@
 #ifndef __RCAR_DU_H__
 #define __RCAR_DU_H__
 
-#include <drm/drm_mode.h>
+#include <video/videomode.h>
 
 enum rcar_du_output {
        RCAR_DU_OUTPUT_DPAD0,
@@ -35,7 +35,7 @@ enum rcar_du_encoder_type {
 struct rcar_du_panel_data {
        unsigned int width_mm;          /* Panel width in mm */
        unsigned int height_mm;         /* Panel height in mm */
-       struct drm_mode_modeinfo mode;
+       struct videomode mode;
 };
 
 struct rcar_du_connector_lvds_data {
index 16c9a62..2a5897a 100644 (file)
 #ifdef CONFIG_PM
 extern int pm_generic_runtime_suspend(struct device *dev);
 extern int pm_generic_runtime_resume(struct device *dev);
+extern int pm_runtime_force_suspend(struct device *dev);
+extern int pm_runtime_force_resume(struct device *dev);
 #else
 static inline int pm_generic_runtime_suspend(struct device *dev) { return 0; }
 static inline int pm_generic_runtime_resume(struct device *dev) { return 0; }
+static inline int pm_runtime_force_suspend(struct device *dev) { return 0; }
+static inline int pm_runtime_force_resume(struct device *dev) { return 0; }
 #endif
 
 #ifdef CONFIG_PM_RUNTIME
index f0feafd..e16ee37 100644 (file)
@@ -274,14 +274,18 @@ struct pwm_lookup {
        unsigned int index;
        const char *dev_id;
        const char *con_id;
+       unsigned int period;
+       enum pwm_polarity polarity;
 };
 
-#define PWM_LOOKUP(_provider, _index, _dev_id, _con_id)        \
+#define PWM_LOOKUP(_provider, _index, _dev_id, _con_id, _period, _polarity) \
        {                                               \
                .provider = _provider,                  \
                .index = _index,                        \
                .dev_id = _dev_id,                      \
                .con_id = _con_id,                      \
+               .period = _period,                      \
+               .polarity = _polarity                   \
        }
 
 #if IS_ENABLED(CONFIG_PWM)
index 22b3640..6c5e3bb 100644 (file)
 
 #define SCIx_NOT_SUPPORTED     (-1)
 
-#define SCSCR_TIE      (1 << 7)
-#define SCSCR_RIE      (1 << 6)
-#define SCSCR_TE       (1 << 5)
-#define SCSCR_RE       (1 << 4)
-#define SCSCR_REIE     (1 << 3)        /* not supported by all parts */
-#define SCSCR_TOIE     (1 << 2)        /* not supported by all parts */
-#define SCSCR_CKE1     (1 << 1)
-#define SCSCR_CKE0     (1 << 0)
-
-/* SCxSR SCI */
-#define SCI_TDRE  0x80
-#define SCI_RDRF  0x40
-#define SCI_ORER  0x20
-#define SCI_FER   0x10
-#define SCI_PER   0x08
-#define SCI_TEND  0x04
+/* SCSMR (Serial Mode Register) */
+#define SCSMR_CHR      (1 << 6)        /* 7-bit Character Length */
+#define SCSMR_PE       (1 << 5)        /* Parity Enable */
+#define SCSMR_ODD      (1 << 4)        /* Odd Parity */
+#define SCSMR_STOP     (1 << 3)        /* Stop Bit Length */
+#define SCSMR_CKS      0x0003          /* Clock Select */
+
+/* Serial Control Register (@ = not supported by all parts) */
+#define SCSCR_TIE      (1 << 7)        /* Transmit Interrupt Enable */
+#define SCSCR_RIE      (1 << 6)        /* Receive Interrupt Enable */
+#define SCSCR_TE       (1 << 5)        /* Transmit Enable */
+#define SCSCR_RE       (1 << 4)        /* Receive Enable */
+#define SCSCR_REIE     (1 << 3)        /* Receive Error Interrupt Enable @ */
+#define SCSCR_TOIE     (1 << 2)        /* Timeout Interrupt Enable @ */
+#define SCSCR_CKE1     (1 << 1)        /* Clock Enable 1 */
+#define SCSCR_CKE0     (1 << 0)        /* Clock Enable 0 */
+/* SCIFA/SCIFB only */
+#define SCSCR_TDRQE    (1 << 15)       /* Tx Data Transfer Request Enable */
+#define SCSCR_RDRQE    (1 << 14)       /* Rx Data Transfer Request Enable */
+
+/* SCxSR (Serial Status Register) on SCI */
+#define SCI_TDRE  0x80                 /* Transmit Data Register Empty */
+#define SCI_RDRF  0x40                 /* Receive Data Register Full */
+#define SCI_ORER  0x20                 /* Overrun Error */
+#define SCI_FER   0x10                 /* Framing Error */
+#define SCI_PER   0x08                 /* Parity Error */
+#define SCI_TEND  0x04                 /* Transmit End */
 
 #define SCI_DEFAULT_ERROR_MASK (SCI_PER | SCI_FER)
 
-/* SCxSR SCIF, HSCIF */
-#define SCIF_ER    0x0080
-#define SCIF_TEND  0x0040
-#define SCIF_TDFE  0x0020
-#define SCIF_BRK   0x0010
-#define SCIF_FER   0x0008
-#define SCIF_PER   0x0004
-#define SCIF_RDF   0x0002
-#define SCIF_DR    0x0001
+/* SCxSR (Serial Status Register) on SCIF, HSCIF */
+#define SCIF_ER    0x0080              /* Receive Error */
+#define SCIF_TEND  0x0040              /* Transmission End */
+#define SCIF_TDFE  0x0020              /* Transmit FIFO Data Empty */
+#define SCIF_BRK   0x0010              /* Break Detect */
+#define SCIF_FER   0x0008              /* Framing Error */
+#define SCIF_PER   0x0004              /* Parity Error */
+#define SCIF_RDF   0x0002              /* Receive FIFO Data Full */
+#define SCIF_DR    0x0001              /* Receive Data Ready */
 
 #define SCIF_DEFAULT_ERROR_MASK (SCIF_PER | SCIF_FER | SCIF_ER | SCIF_BRK)
 
-/* SCSPTR, optional */
-#define SCSPTR_RTSIO   (1 << 7)
-#define SCSPTR_CTSIO   (1 << 5)
-#define SCSPTR_SPB2IO  (1 << 1)
-#define SCSPTR_SPB2DT  (1 << 0)
+/* SCFCR (FIFO Control Register) */
+#define SCFCR_LOOP     (1 << 0)        /* Loopback Test */
+
+/* SCSPTR (Serial Port Register), optional */
+#define SCSPTR_RTSIO   (1 << 7)        /* Serial Port RTS Pin Input/Output */
+#define SCSPTR_CTSIO   (1 << 5)        /* Serial Port CTS Pin Input/Output */
+#define SCSPTR_SPB2IO  (1 << 1)        /* Serial Port Break Input/Output */
+#define SCSPTR_SPB2DT  (1 << 0)        /* Serial Port Break Data */
 
 /* HSSRR HSCIF */
-#define HSCIF_SRE      0x8000
+#define HSCIF_SRE      0x8000          /* Sampling Rate Register Enable */
 
 enum {
        SCIx_PROBE_REGTYPE,
@@ -73,10 +87,19 @@ enum {
  * Not all registers will exist on all parts.
  */
 enum {
-       SCSMR, SCBRR, SCSCR, SCxSR,
-       SCFCR, SCFDR, SCxTDR, SCxRDR,
-       SCLSR, SCTFDR, SCRFDR, SCSPTR,
-       HSSRR,
+       SCSMR,                          /* Serial Mode Register */
+       SCBRR,                          /* Bit Rate Register */
+       SCSCR,                          /* Serial Control Register */
+       SCxSR,                          /* Serial Status Register */
+       SCFCR,                          /* FIFO Control Register */
+       SCFDR,                          /* FIFO Data Count Register */
+       SCxTDR,                         /* Transmit (FIFO) Data Register */
+       SCxRDR,                         /* Receive (FIFO) Data Register */
+       SCLSR,                          /* Line Status Register */
+       SCTFDR,                         /* Transmit FIFO Data Count Register */
+       SCRFDR,                         /* Receive FIFO Data Count Register */
+       SCSPTR,                         /* Serial Port Register */
+       HSSRR,                          /* Sampling Rate Register */
 
        SCIx_NR_REGS,
 };
index 60c7239..1f208b2 100644 (file)
@@ -52,6 +52,7 @@ struct clk {
        unsigned long           flags;
 
        void __iomem            *enable_reg;
+       void __iomem            *status_reg;
        unsigned int            enable_bit;
        void __iomem            *mapped_reg;
 
@@ -116,22 +117,26 @@ long clk_round_parent(struct clk *clk, unsigned long target,
                      unsigned long *best_freq, unsigned long *parent_freq,
                      unsigned int div_min, unsigned int div_max);
 
-#define SH_CLK_MSTP(_parent, _enable_reg, _enable_bit, _flags)         \
+#define SH_CLK_MSTP(_parent, _enable_reg, _enable_bit, _status_reg, _flags) \
 {                                                                      \
        .parent         = _parent,                                      \
        .enable_reg     = (void __iomem *)_enable_reg,                  \
        .enable_bit     = _enable_bit,                                  \
+       .status_reg     = _status_reg,                                  \
        .flags          = _flags,                                       \
 }
 
-#define SH_CLK_MSTP32(_p, _r, _b, _f)                                  \
-       SH_CLK_MSTP(_p, _r, _b, _f | CLK_ENABLE_REG_32BIT)
+#define SH_CLK_MSTP32(_p, _r, _b, _f)                          \
+       SH_CLK_MSTP(_p, _r, _b, 0, _f | CLK_ENABLE_REG_32BIT)
 
-#define SH_CLK_MSTP16(_p, _r, _b, _f)                                  \
-       SH_CLK_MSTP(_p, _r, _b, _f | CLK_ENABLE_REG_16BIT)
+#define SH_CLK_MSTP32_STS(_p, _r, _b, _s, _f)                  \
+       SH_CLK_MSTP(_p, _r, _b, _s, _f | CLK_ENABLE_REG_32BIT)
 
-#define SH_CLK_MSTP8(_p, _r, _b, _f)                                   \
-       SH_CLK_MSTP(_p, _r, _b, _f | CLK_ENABLE_REG_8BIT)
+#define SH_CLK_MSTP16(_p, _r, _b, _f)                          \
+       SH_CLK_MSTP(_p, _r, _b, 0, _f | CLK_ENABLE_REG_16BIT)
+
+#define SH_CLK_MSTP8(_p, _r, _b, _f)                           \
+       SH_CLK_MSTP(_p, _r, _b, 0, _f | CLK_ENABLE_REG_8BIT)
 
 int sh_clk_mstp_register(struct clk *clks, int nr);
 
index b7b43b8..56b97ee 100644 (file)
@@ -95,19 +95,21 @@ struct sh_dmae_pdata {
 };
 
 /* DMAOR definitions */
-#define DMAOR_AE       0x00000004
+#define DMAOR_AE       0x00000004      /* Address Error Flag */
 #define DMAOR_NMIF     0x00000002
-#define DMAOR_DME      0x00000001
+#define DMAOR_DME      0x00000001      /* DMA Master Enable */
 
 /* Definitions for the SuperH DMAC */
-#define DM_INC 0x00004000
-#define DM_DEC 0x00008000
-#define DM_FIX 0x0000c000
-#define SM_INC 0x00001000
-#define SM_DEC 0x00002000
-#define SM_FIX 0x00003000
-#define CHCR_DE        0x00000001
-#define CHCR_TE        0x00000002
-#define CHCR_IE        0x00000004
+#define DM_INC 0x00004000      /* Destination addresses are incremented */
+#define DM_DEC 0x00008000      /* Destination addresses are decremented */
+#define DM_FIX 0x0000c000      /* Destination address is fixed */
+#define SM_INC 0x00001000      /* Source addresses are incremented */
+#define SM_DEC 0x00002000      /* Source addresses are decremented */
+#define SM_FIX 0x00003000      /* Source address is fixed */
+#define RS_AUTO        0x00000400      /* Auto Request */
+#define RS_ERS 0x00000800      /* DMA extended resource selector */
+#define CHCR_DE        0x00000001      /* DMA Enable */
+#define CHCR_TE        0x00000002      /* Transfer End Flag */
+#define CHCR_IE        0x00000004      /* Interrupt Enable */
 
 #endif
index 4d9dcd1..64638b0 100644 (file)
@@ -2,11 +2,7 @@
 #define __SH_TIMER_H__
 
 struct sh_timer_config {
-       char *name;
-       long channel_offset;
-       int timer_bit;
-       unsigned long clockevent_rating;
-       unsigned long clocksource_rating;
+       unsigned int channels_mask;
 };
 
 #endif /* __SH_TIMER_H__ */
index f92c0a4..abdf1f2 100644 (file)
@@ -54,6 +54,7 @@ struct shdma_desc {
        dma_cookie_t cookie;
        int chunks;
        int mark;
+       bool cyclic;                    /* used as cyclic transfer */
 };
 
 struct shdma_chan {
index a25bd6f..e546b2c 100644 (file)
@@ -25,8 +25,6 @@ struct rspi_plat_data {
        unsigned int dma_tx_id;
        unsigned int dma_rx_id;
 
-       unsigned dma_width_16bit:1;     /* DMAC read/write width = 16-bit */
-
        u16 num_chipselect;
 };
 
index 2e8db3d..88a14d8 100644 (file)
@@ -5,6 +5,8 @@ struct sh_msiof_spi_info {
        int tx_fifo_override;
        int rx_fifo_override;
        u16 num_chipselect;
+       unsigned int dma_tx_id;
+       unsigned int dma_rx_id;
 };
 
 #endif /* __SPI_SH_MSIOF_H__ */
index 4203c66..36c86ef 100644 (file)
@@ -24,6 +24,9 @@
 #include <linux/slab.h>
 #include <linux/kthread.h>
 #include <linux/completion.h>
+#include <linux/scatterlist.h>
+
+struct dma_chan;
 
 /*
  * INTERFACES between SPI master-side drivers and SPI infrastructure.
@@ -266,6 +269,7 @@ static inline void spi_unregister_driver(struct spi_driver *sdrv)
  * @auto_runtime_pm: the core should ensure a runtime PM reference is held
  *                   while the hardware is prepared, using the parent
  *                   device for the spidev
+ * @max_dma_len: Maximum length of a DMA transfer for the device.
  * @prepare_transfer_hardware: a message will soon arrive from the queue
  *     so the subsystem requests the driver to prepare the transfer hardware
  *     by issuing this call
@@ -348,6 +352,8 @@ struct spi_master {
 #define SPI_MASTER_HALF_DUPLEX BIT(0)          /* can't do full duplex */
 #define SPI_MASTER_NO_RX       BIT(1)          /* can't do buffer read */
 #define SPI_MASTER_NO_TX       BIT(2)          /* can't do buffer write */
+#define SPI_MASTER_MUST_RX      BIT(3)         /* requires rx */
+#define SPI_MASTER_MUST_TX      BIT(4)         /* requires tx */
 
        /* lock and mutex for SPI bus locking */
        spinlock_t              bus_lock_spinlock;
@@ -390,6 +396,17 @@ struct spi_master {
        void                    (*cleanup)(struct spi_device *spi);
 
        /*
+        * Used to enable core support for DMA handling, if can_dma()
+        * exists and returns true then the transfer will be mapped
+        * prior to transfer_one() being called.  The driver should
+        * not modify or store xfer and dma_tx and dma_rx must be set
+        * while the device is prepared.
+        */
+       bool                    (*can_dma)(struct spi_master *master,
+                                          struct spi_device *spi,
+                                          struct spi_transfer *xfer);
+
+       /*
         * These hooks are for drivers that want to use the generic
         * master transfer queueing mechanism. If these are used, the
         * transfer() function above must NOT be specified by the driver.
@@ -407,7 +424,9 @@ struct spi_master {
        bool                            rt;
        bool                            auto_runtime_pm;
        bool                            cur_msg_prepared;
+       bool                            cur_msg_mapped;
        struct completion               xfer_completion;
+       size_t                          max_dma_len;
 
        int (*prepare_transfer_hardware)(struct spi_master *master);
        int (*transfer_one_message)(struct spi_master *master,
@@ -428,6 +447,14 @@ struct spi_master {
 
        /* gpio chip select */
        int                     *cs_gpios;
+
+       /* DMA channels for use with core dmaengine helpers */
+       struct dma_chan         *dma_tx;
+       struct dma_chan         *dma_rx;
+
+       /* dummy data for full duplex devices */
+       void                    *dummy_rx;
+       void                    *dummy_tx;
 };
 
 static inline void *spi_master_get_devdata(struct spi_master *master)
@@ -512,6 +539,8 @@ extern struct spi_master *spi_busnum_to_master(u16 busnum);
  *     (optionally) changing the chipselect status, then starting
  *     the next transfer or completing this @spi_message.
  * @transfer_list: transfers are sequenced through @spi_message.transfers
+ * @tx_sg: Scatterlist for transmit, currently not for client use
+ * @rx_sg: Scatterlist for receive, currently not for client use
  *
  * SPI transfers always write the same number of bytes as they read.
  * Protocol drivers should always provide @rx_buf and/or @tx_buf.
@@ -579,6 +608,8 @@ struct spi_transfer {
 
        dma_addr_t      tx_dma;
        dma_addr_t      rx_dma;
+       struct sg_table tx_sg;
+       struct sg_table rx_sg;
 
        unsigned        cs_change:1;
        unsigned        tx_nbits:3;
index e452ba6..d5952bb 100644 (file)
@@ -153,6 +153,9 @@ struct renesas_usbhs_driver_param {
         */
        int pio_dma_border; /* default is 64byte */
 
+       u32 type;
+       u32 enable_gpio;
+
        /*
         * option:
         */
@@ -160,6 +163,9 @@ struct renesas_usbhs_driver_param {
        u32 has_sudmac:1; /* for SUDMAC */
 };
 
+#define USBHS_TYPE_R8A7790 1
+#define USBHS_TYPE_R8A7791 2
+
 /*
  * option:
  *
diff --git a/include/linux/usb/xhci_pdriver.h b/include/linux/usb/xhci_pdriver.h
new file mode 100644 (file)
index 0000000..376654b
--- /dev/null
@@ -0,0 +1,27 @@
+/*
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * for more details.
+ *
+ */
+
+#ifndef __USB_CORE_XHCI_PDRIVER_H
+#define __USB_CORE_XHCI_PDRIVER_H
+
+/**
+ * struct usb_xhci_pdata - platform_data for generic xhci platform driver
+ *
+ * @usb3_lpm_capable:  determines if this xhci platform supports USB3
+ *                     LPM capability
+ *
+ */
+struct usb_xhci_pdata {
+       unsigned        usb3_lpm_capable:1;
+};
+
+#endif /* __USB_CORE_XHCI_PDRIVER_H */
index 541cea4..70fa7b7 100644 (file)
@@ -17,6 +17,7 @@
 #include <linux/list.h>
 #include <linux/types.h>
 #include <linux/errno.h>
+#include <linux/of_graph.h>
 
 #include <media/v4l2-mediabus.h>
 
@@ -50,17 +51,13 @@ struct v4l2_of_bus_parallel {
 
 /**
  * struct v4l2_of_endpoint - the endpoint data structure
- * @port: identifier (value of reg property) of a port this endpoint belongs to
- * @id: identifier (value of reg property) of this endpoint
- * @local_node: pointer to device_node of this endpoint
+ * @base: struct of_endpoint containing port, id, and local of_node
  * @bus_type: bus type
  * @bus: bus configuration data structure
  * @head: list head for this structure
  */
 struct v4l2_of_endpoint {
-       unsigned int port;
-       unsigned int id;
-       const struct device_node *local_node;
+       struct of_endpoint base;
        enum v4l2_mbus_type bus_type;
        union {
                struct v4l2_of_bus_parallel parallel;
@@ -72,11 +69,6 @@ struct v4l2_of_endpoint {
 #ifdef CONFIG_OF
 int v4l2_of_parse_endpoint(const struct device_node *node,
                           struct v4l2_of_endpoint *endpoint);
-struct device_node *v4l2_of_get_next_endpoint(const struct device_node *parent,
-                                       struct device_node *previous);
-struct device_node *v4l2_of_get_remote_port_parent(
-                                       const struct device_node *node);
-struct device_node *v4l2_of_get_remote_port(const struct device_node *node);
 #else /* CONFIG_OF */
 
 static inline int v4l2_of_parse_endpoint(const struct device_node *node,
@@ -85,25 +77,6 @@ static inline int v4l2_of_parse_endpoint(const struct device_node *node,
        return -ENOSYS;
 }
 
-static inline struct device_node *v4l2_of_get_next_endpoint(
-                                       const struct device_node *parent,
-                                       struct device_node *previous)
-{
-       return NULL;
-}
-
-static inline struct device_node *v4l2_of_get_remote_port_parent(
-                                       const struct device_node *node)
-{
-       return NULL;
-}
-
-static inline struct device_node *v4l2_of_get_remote_port(
-                                       const struct device_node *node)
-{
-       return NULL;
-}
-
 #endif /* CONFIG_OF */
 
 #endif /* _V4L2_OF_H */
index b10682c..2e49a38 100644 (file)
@@ -315,20 +315,24 @@ struct v4l2_fh;
  * @gfp_flags: additional gfp flags used when allocating the buffers.
  *             Typically this is 0, but it may be e.g. GFP_DMA or __GFP_DMA32
  *             to force the buffer allocation to a specific memory zone.
+ * @min_buffers_needed: the minimum number of buffers needed before
+ *             start_streaming() can be called. Used when a DMA engine
+ *             cannot be started unless at least this number of buffers
+ *             have been queued into the driver.
  *
  * @memory:    current memory type used
  * @bufs:      videobuf buffer structures
  * @num_buffers: number of allocated/used buffers
  * @queued_list: list of buffers currently queued from userspace
- * @queued_count: number of buffers owned by the driver
+ * @queued_count: number of buffers queued and ready for streaming.
+ * @owned_by_drv_count: number of buffers owned by the driver
  * @done_list: list of buffers ready to be dequeued to userspace
  * @done_lock: lock to protect done_list list
  * @done_wq:   waitqueue for processes waiting for buffers ready to be dequeued
  * @alloc_ctx: memory type/allocator-specific contexts for each plane
  * @streaming: current streaming state
- * @retry_start_streaming: start_streaming() was called, but there were not enough
- *             buffers queued. If set, then retry calling start_streaming when
- *             queuing a new buffer.
+ * @start_streaming_called: start_streaming() was called successfully and we
+ *             started streaming.
  * @waiting_for_buffers: used in poll() to check if vb2 is still waiting for
  *             buffers. Only set for capture queues if qbuf has not yet been
  *             called since poll() needs to return POLLERR in that situation.
@@ -347,6 +351,7 @@ struct vb2_queue {
        unsigned int                    buf_struct_size;
        u32                             timestamp_type;
        gfp_t                           gfp_flags;
+       u32                             min_buffers_needed;
 
 /* private: internal use only */
        enum v4l2_memory                memory;
@@ -354,8 +359,9 @@ struct vb2_queue {
        unsigned int                    num_buffers;
 
        struct list_head                queued_list;
+       unsigned int                    queued_count;
 
-       atomic_t                        queued_count;
+       atomic_t                        owned_by_drv_count;
        struct list_head                done_list;
        spinlock_t                      done_lock;
        wait_queue_head_t               done_wq;
@@ -364,7 +370,7 @@ struct vb2_queue {
        unsigned int                    plane_sizes[VIDEO_MAX_PLANES];
 
        unsigned int                    streaming:1;
-       unsigned int                    retry_start_streaming:1;
+       unsigned int                    start_streaming_called:1;
        unsigned int                    waiting_for_buffers:1;
 
        struct vb2_fileio_data          *fileio;
index 6add6cc..d76412b 100644 (file)
  * B : SSI direction
  */
 #define RSND_SSI_CLK_PIN_SHARE         (1 << 31)
-#define RSND_SSI_SYNC                  (1 << 29) /* SSI34_sync etc */
+#define RSND_SSI_NO_BUSIF              (1 << 30) /* SSI+DMA without BUSIF */
 
-#define RSND_SSI_PLAY                  (1 << 24)
-
-#define RSND_SSI_SET(_dai_id, _dma_id, _pio_irq, _flags)       \
-{ .dai_id = _dai_id, .dma_id = _dma_id, .pio_irq = _pio_irq, .flags = _flags }
+#define RSND_SSI(_dma_id, _pio_irq, _flags)            \
+{ .dma_id = _dma_id, .pio_irq = _pio_irq, .flags = _flags }
 #define RSND_SSI_UNUSED \
-{ .dai_id = -1, .dma_id = -1, .pio_irq = -1, .flags = 0 }
+{ .dma_id = -1, .pio_irq = -1, .flags = 0 }
 
 struct rsnd_ssi_platform_info {
-       int dai_id;
        int dma_id;
        int pio_irq;
        u32 flags;
 };
 
+#define RSND_SRC(rate, _dma_id)                                                \
+{ .convert_rate = rate, .dma_id = _dma_id, }
+#define RSND_SRC_UNUSED                                \
+{ .convert_rate = 0, .dma_id = -1, }
+
+struct rsnd_src_platform_info {
+       u32 convert_rate; /* sampling rate convert */
+       int dma_id; /* for Gen2 SCU */
+};
+
 /*
  * flags
  */
-#define RSND_SCU_USE_HPBIF             (1 << 31) /* it needs RSND_SSI_DEPENDENT */
-
-struct rsnd_scu_platform_info {
+struct rsnd_dvc_platform_info {
        u32 flags;
-       u32 convert_rate; /* sampling rate convert */
+};
+
+struct rsnd_dai_path_info {
+       struct rsnd_ssi_platform_info *ssi;
+       struct rsnd_src_platform_info *src;
+       struct rsnd_dvc_platform_info *dvc;
+};
+
+struct rsnd_dai_platform_info {
+       struct rsnd_dai_path_info playback;
+       struct rsnd_dai_path_info capture;
 };
 
 /*
@@ -75,8 +90,12 @@ struct rcar_snd_info {
        u32 flags;
        struct rsnd_ssi_platform_info *ssi_info;
        int ssi_info_nr;
-       struct rsnd_scu_platform_info *scu_info;
-       int scu_info_nr;
+       struct rsnd_src_platform_info *src_info;
+       int src_info_nr;
+       struct rsnd_dvc_platform_info *dvc_info;
+       int dvc_info_nr;
+       struct rsnd_dai_platform_info *dai_info;
+       int dai_info_nr;
        int (*start)(int id);
        int (*stop)(int id);
 };
index 6c74527..9b0ac77 100644 (file)
@@ -18,6 +18,8 @@ struct asoc_simple_dai {
        const char *name;
        unsigned int fmt;
        unsigned int sysclk;
+       int slots;
+       int slot_width;
 };
 
 struct asoc_simple_card_info {
@@ -29,10 +31,6 @@ struct asoc_simple_card_info {
        unsigned int daifmt;
        struct asoc_simple_dai cpu_dai;
        struct asoc_simple_dai codec_dai;
-
-       /* used in simple-card.c */
-       struct snd_soc_dai_link snd_link;
-       struct snd_soc_card snd_card;
 };
 
 #endif /* __SIMPLE_CARD_H */
index 71f27c4..d86e0fc 100644 (file)
@@ -142,6 +142,8 @@ struct snd_soc_dai_ops {
         * Called by soc_card drivers, normally in their hw_params.
         */
        int (*set_fmt)(struct snd_soc_dai *dai, unsigned int fmt);
+       int (*of_xlate_tdm_slot_mask)(unsigned int slots,
+               unsigned int *tx_mask, unsigned int *rx_mask);
        int (*set_tdm_slot)(struct snd_soc_dai *dai,
                unsigned int tx_mask, unsigned int rx_mask,
                int slots, int slot_width);
index 9a00147..27bb5ab 100644 (file)
@@ -1173,10 +1173,17 @@ void snd_soc_util_exit(void);
 
 int snd_soc_of_parse_card_name(struct snd_soc_card *card,
                               const char *propname);
+int snd_soc_of_parse_audio_simple_widgets(struct snd_soc_card *card,
+                                         const char *propname);
+int snd_soc_of_parse_tdm_slot(struct device_node *np,
+                             unsigned int *slots,
+                             unsigned int *slot_width);
 int snd_soc_of_parse_audio_routing(struct snd_soc_card *card,
                                   const char *propname);
 unsigned int snd_soc_of_parse_daifmt(struct device_node *np,
-                                    const char *prefix);
+                                    const char *prefix,
+                                    struct device_node **bitclkmaster,
+                                    struct device_node **framemaster);
 int snd_soc_of_get_dai_name(struct device_node *of_node,
                            const char **dai_name);
 
index fe94bb9..8d6646e 100644 (file)
@@ -264,6 +264,7 @@ struct v4l2_capability {
 #define V4L2_CAP_RADIO                 0x00040000  /* is a radio device */
 #define V4L2_CAP_MODULATOR             0x00080000  /* has a modulator */
 
+#define V4L2_CAP_EXT_PIX_FORMAT                0x00200000  /* Supports the extended pixel format */
 #define V4L2_CAP_READWRITE              0x01000000  /* read/write systemcalls */
 #define V4L2_CAP_ASYNCIO                0x02000000  /* async I/O */
 #define V4L2_CAP_STREAMING              0x04000000  /* streaming I/O ioctls */
@@ -282,6 +283,7 @@ struct v4l2_pix_format {
        __u32                   sizeimage;
        __u32                   colorspace;     /* enum v4l2_colorspace */
        __u32                   priv;           /* private data, depends on pixelformat */
+       __u32                   flags;          /* format flags (V4L2_PIX_FMT_FLAG_*) */
 };
 
 /*      Pixel format         FOURCC                          depth  Description  */
@@ -289,7 +291,11 @@ struct v4l2_pix_format {
 /* RGB formats */
 #define V4L2_PIX_FMT_RGB332  v4l2_fourcc('R', 'G', 'B', '1') /*  8  RGB-3-3-2     */
 #define V4L2_PIX_FMT_RGB444  v4l2_fourcc('R', '4', '4', '4') /* 16  xxxxrrrr ggggbbbb */
+#define V4L2_PIX_FMT_ARGB444 v4l2_fourcc('A', 'R', '1', '2') /* 16  aaaarrrr ggggbbbb */
+#define V4L2_PIX_FMT_XRGB444 v4l2_fourcc('X', 'R', '1', '2') /* 16  xxxxrrrr ggggbbbb */
 #define V4L2_PIX_FMT_RGB555  v4l2_fourcc('R', 'G', 'B', 'O') /* 16  RGB-5-5-5     */
+#define V4L2_PIX_FMT_ARGB555 v4l2_fourcc('A', 'R', '1', '5') /* 16  ARGB-1-5-5-5  */
+#define V4L2_PIX_FMT_XRGB555 v4l2_fourcc('X', 'R', '1', '5') /* 16  XRGB-1-5-5-5  */
 #define V4L2_PIX_FMT_RGB565  v4l2_fourcc('R', 'G', 'B', 'P') /* 16  RGB-5-6-5     */
 #define V4L2_PIX_FMT_RGB555X v4l2_fourcc('R', 'G', 'B', 'Q') /* 16  RGB-5-5-5 BE  */
 #define V4L2_PIX_FMT_RGB565X v4l2_fourcc('R', 'G', 'B', 'R') /* 16  RGB-5-6-5 BE  */
@@ -297,7 +303,11 @@ struct v4l2_pix_format {
 #define V4L2_PIX_FMT_BGR24   v4l2_fourcc('B', 'G', 'R', '3') /* 24  BGR-8-8-8     */
 #define V4L2_PIX_FMT_RGB24   v4l2_fourcc('R', 'G', 'B', '3') /* 24  RGB-8-8-8     */
 #define V4L2_PIX_FMT_BGR32   v4l2_fourcc('B', 'G', 'R', '4') /* 32  BGR-8-8-8-8   */
+#define V4L2_PIX_FMT_ABGR32  v4l2_fourcc('A', 'R', '2', '4') /* 32  BGRA-8-8-8-8  */
+#define V4L2_PIX_FMT_XBGR32  v4l2_fourcc('X', 'R', '2', '4') /* 32  BGRX-8-8-8-8  */
 #define V4L2_PIX_FMT_RGB32   v4l2_fourcc('R', 'G', 'B', '4') /* 32  RGB-8-8-8-8   */
+#define V4L2_PIX_FMT_ARGB32  v4l2_fourcc('B', 'A', '2', '4') /* 32  ARGB-8-8-8-8  */
+#define V4L2_PIX_FMT_XRGB32  v4l2_fourcc('B', 'X', '2', '4') /* 32  XRGB-8-8-8-8  */
 
 /* Grey formats */
 #define V4L2_PIX_FMT_GREY    v4l2_fourcc('G', 'R', 'E', 'Y') /*  8  Greyscale     */
@@ -431,6 +441,12 @@ struct v4l2_pix_format {
 #define V4L2_PIX_FMT_SE401      v4l2_fourcc('S', '4', '0', '1') /* se401 janggu compressed rgb */
 #define V4L2_PIX_FMT_S5C_UYVY_JPG v4l2_fourcc('S', '5', 'C', 'I') /* S5C73M3 interleaved UYVY/JPEG */
 
+/* priv field value to indicates that subsequent fields are valid. */
+#define V4L2_PIX_FMT_PRIV_MAGIC                0xdeadbeef
+
+/* Flags */
+#define V4L2_PIX_FMT_FLAG_PREMUL_ALPHA 0x00000001
+
 /*
  *     F O R M A T   E N U M E R A T I O N
  */
@@ -724,7 +740,16 @@ struct v4l2_framebuffer {
 /* FIXME: in theory we should pass something like PCI device + memory
  * region + offset instead of some physical address */
        void                    *base;
-       struct v4l2_pix_format  fmt;
+       struct {
+               __u32           width;
+               __u32           height;
+               __u32           pixelformat;
+               __u32           field;          /* enum v4l2_field */
+               __u32           bytesperline;   /* for padding, zero if unused */
+               __u32           sizeimage;
+               __u32           colorspace;     /* enum v4l2_colorspace */
+               __u32           priv;           /* private data, depends on pixelformat */
+       } fmt;
 };
 /*  Flags for the 'capability' field. Read only */
 #define V4L2_FBUF_CAP_EXTERNOVERLAY    0x0001
@@ -1678,6 +1703,7 @@ struct v4l2_plane_pix_format {
  * @colorspace:                enum v4l2_colorspace; supplemental to pixelformat
  * @plane_fmt:         per-plane information
  * @num_planes:                number of planes for this format
+ * @flags:             format flags (V4L2_PIX_FMT_FLAG_*)
  */
 struct v4l2_pix_format_mplane {
        __u32                           width;
@@ -1688,7 +1714,8 @@ struct v4l2_pix_format_mplane {
 
        struct v4l2_plane_pix_format    plane_fmt[VIDEO_MAX_PLANES];
        __u8                            num_planes;
-       __u8                            reserved[11];
+       __u8                            flags;
+       __u8                            reserved[10];
 } __attribute__ ((packed));
 
 /**
index 991c98b..5d4984c 100644 (file)
@@ -342,9 +342,9 @@ config HAS_IOMEM
        select GENERIC_IO
        default y
 
-config HAS_IOPORT
+config HAS_IOPORT_MAP
        boolean
-       depends on HAS_IOMEM && !NO_IOPORT
+       depends on HAS_IOMEM && !NO_IOPORT_MAP
        default y
 
 config HAS_DMA
index 8235331..1023128 100644 (file)
@@ -168,7 +168,7 @@ void __iomem *devm_request_and_ioremap(struct device *device,
 }
 EXPORT_SYMBOL(devm_request_and_ioremap);
 
-#ifdef CONFIG_HAS_IOPORT
+#ifdef CONFIG_HAS_IOPORT_MAP
 /*
  * Generic iomap devres
  */
@@ -227,7 +227,7 @@ void devm_ioport_unmap(struct device *dev, void __iomem *addr)
                               devm_ioport_map_match, (void *)addr));
 }
 EXPORT_SYMBOL(devm_ioport_unmap);
-#endif /* CONFIG_HAS_IOPORT */
+#endif /* CONFIG_HAS_IOPORT_MAP */
 
 #ifdef CONFIG_PCI
 /*
index 2c08f36..fc3dcb4 100644 (file)
@@ -224,7 +224,7 @@ EXPORT_SYMBOL(iowrite8_rep);
 EXPORT_SYMBOL(iowrite16_rep);
 EXPORT_SYMBOL(iowrite32_rep);
 
-#ifdef CONFIG_HAS_IOPORT
+#ifdef CONFIG_HAS_IOPORT_MAP
 /* Create a virtual mapping cookie for an IO port range */
 void __iomem *ioport_map(unsigned long port, unsigned int nr)
 {
@@ -239,7 +239,7 @@ void ioport_unmap(void __iomem *addr)
 }
 EXPORT_SYMBOL(ioport_map);
 EXPORT_SYMBOL(ioport_unmap);
-#endif /* CONFIG_HAS_IOPORT */
+#endif /* CONFIG_HAS_IOPORT_MAP */
 
 #ifdef CONFIG_PCI
 /* Hide the details if this is a MMIO or PIO address space and just do what
index affa134..0216475 100644 (file)
@@ -191,7 +191,7 @@ config SND_ES18XX
 
 config SND_SC6000
        tristate "Gallant SC-6000/6600/7000 and Audio Excel DSP 16"
-       depends on HAS_IOPORT
+       depends on HAS_IOPORT_MAP
        select SND_WSS_LIB
        select SND_OPL3_LIB
        select SND_MPU401_UART
index 46e5630..8fcb10f 100644 (file)
@@ -689,7 +689,7 @@ config SND_LOLA
 
 config SND_LX6464ES
        tristate "Digigram LX6464ES"
-       depends on HAS_IOPORT
+       depends on HAS_IOPORT_MAP
        select SND_PCM
        help
          Say Y here to include support for Digigram LX6464ES boards.
index 1f646c6..7d86259 100644 (file)
@@ -98,7 +98,7 @@
 #define MGAIN0         (1 << 0) /* MIC amp gain*/
 
 /* TIMER */
-#define ZTM(param)     ((param & 0x3) << 4) /* ALC Zoro Crossing TimeOut */
+#define ZTM(param)     ((param & 0x3) << 4) /* ALC Zero Crossing TimeOut */
 #define WTM(param)     (((param & 0x4) << 4) | ((param & 0x3) << 2))
 
 /* ALC_CTL1 */
 /* MD_CTL4 */
 #define DACH           (1 << 0)
 
+struct ak4642_drvdata {
+       const struct regmap_config *regmap_config;
+       int extended_frequencies;
+};
+
+struct ak4642_priv {
+       const struct ak4642_drvdata *drvdata;
+};
+
 /*
  * Playback Volume (table 39)
  *
@@ -148,6 +157,8 @@ static const struct snd_kcontrol_new ak4642_snd_controls[] = {
 
        SOC_DOUBLE_R_TLV("Digital Playback Volume", L_DVC, R_DVC,
                         0, 0xFF, 1, out_tlv),
+       SOC_SINGLE("ALC Capture Switch", ALC_CTL1, 5, 1, 0),
+       SOC_SINGLE("ALC Capture ZC Switch", ALC_CTL1, 4, 1, 1),
 };
 
 static const struct snd_kcontrol_new ak4642_headphone_control =
@@ -287,7 +298,9 @@ static int ak4642_dai_set_sysclk(struct snd_soc_dai *codec_dai,
        int clk_id, unsigned int freq, int dir)
 {
        struct snd_soc_codec *codec = codec_dai->codec;
+       struct ak4642_priv *priv = snd_soc_codec_get_drvdata(codec);
        u8 pll;
+       int extended_freq = 0;
 
        switch (freq) {
        case 11289600:
@@ -308,9 +321,25 @@ static int ak4642_dai_set_sysclk(struct snd_soc_dai *codec_dai,
        case 27000000:
                pll = PLL3 | PLL2 | PLL0;
                break;
+       case 19200000:
+               pll = PLL3;
+               extended_freq = 1;
+               break;
+       case 13000000:
+               pll = PLL3 | PLL2 | PLL1;
+               extended_freq = 1;
+               break;
+       case 26000000:
+               pll = PLL3 | PLL2 | PLL1 | PLL0;
+               extended_freq = 1;
+               break;
        default:
                return -EINVAL;
        }
+
+       if (extended_freq && !priv->drvdata->extended_frequencies)
+               return -EINVAL;
+
        snd_soc_update_bits(codec, MD_CTL1, PLL_MASK, pll);
 
        return 0;
@@ -513,30 +542,52 @@ static const struct regmap_config ak4648_regmap = {
        .num_reg_defaults       = ARRAY_SIZE(ak4648_reg),
 };
 
-static struct of_device_id ak4642_of_match[];
+static const struct ak4642_drvdata ak4642_drvdata = {
+       .regmap_config = &ak4642_regmap,
+};
+
+static const struct ak4642_drvdata ak4643_drvdata = {
+       .regmap_config = &ak4642_regmap,
+};
+
+static const struct ak4642_drvdata ak4648_drvdata = {
+       .regmap_config = &ak4648_regmap,
+       .extended_frequencies = 1,
+};
+
+static const struct of_device_id ak4642_of_match[];
 static int ak4642_i2c_probe(struct i2c_client *i2c,
                            const struct i2c_device_id *id)
 {
        struct device_node *np = i2c->dev.of_node;
-       const struct regmap_config *regmap_config = NULL;
+       const struct ak4642_drvdata *drvdata = NULL;
        struct regmap *regmap;
+       struct ak4642_priv *priv;
 
        if (np) {
                const struct of_device_id *of_id;
 
                of_id = of_match_device(ak4642_of_match, &i2c->dev);
                if (of_id)
-                       regmap_config = of_id->data;
+                       drvdata = of_id->data;
        } else {
-               regmap_config = (const struct regmap_config *)id->driver_data;
+               drvdata = (const struct ak4642_drvdata *)id->driver_data;
        }
 
-       if (!regmap_config) {
+       if (!drvdata) {
                dev_err(&i2c->dev, "Unknown device type\n");
                return -EINVAL;
        }
 
-       regmap = devm_regmap_init_i2c(i2c, regmap_config);
+       priv = devm_kzalloc(&i2c->dev, sizeof(*priv), GFP_KERNEL);
+       if (!priv)
+               return -ENOMEM;
+
+       priv->drvdata = drvdata;
+
+       i2c_set_clientdata(i2c, priv);
+
+       regmap = devm_regmap_init_i2c(i2c, drvdata->regmap_config);
        if (IS_ERR(regmap))
                return PTR_ERR(regmap);
 
@@ -550,18 +601,18 @@ static int ak4642_i2c_remove(struct i2c_client *client)
        return 0;
 }
 
-static struct of_device_id ak4642_of_match[] = {
-       { .compatible = "asahi-kasei,ak4642",   .data = &ak4642_regmap},
-       { .compatible = "asahi-kasei,ak4643",   .data = &ak4642_regmap},
-       { .compatible = "asahi-kasei,ak4648",   .data = &ak4648_regmap},
+static const struct of_device_id ak4642_of_match[] = {
+       { .compatible = "asahi-kasei,ak4642",   .data = &ak4642_drvdata},
+       { .compatible = "asahi-kasei,ak4643",   .data = &ak4643_drvdata},
+       { .compatible = "asahi-kasei,ak4648",   .data = &ak4648_drvdata},
        {},
 };
 MODULE_DEVICE_TABLE(of, ak4642_of_match);
 
 static const struct i2c_device_id ak4642_i2c_id[] = {
-       { "ak4642", (kernel_ulong_t)&ak4642_regmap },
-       { "ak4643", (kernel_ulong_t)&ak4642_regmap },
-       { "ak4648", (kernel_ulong_t)&ak4648_regmap },
+       { "ak4642", (kernel_ulong_t)&ak4642_drvdata },
+       { "ak4643", (kernel_ulong_t)&ak4643_drvdata },
+       { "ak4648", (kernel_ulong_t)&ak4648_drvdata },
        { }
 };
 MODULE_DEVICE_TABLE(i2c, ak4642_i2c_id);
index 2a1b1b5..03a7fdc 100644 (file)
@@ -9,48 +9,99 @@
  * published by the Free Software Foundation.
  */
 #include <linux/clk.h>
+#include <linux/device.h>
 #include <linux/module.h>
 #include <linux/of.h>
 #include <linux/platform_device.h>
 #include <linux/string.h>
 #include <sound/simple_card.h>
+#include <sound/soc-dai.h>
+#include <sound/soc.h>
+
+struct simple_card_data {
+       struct snd_soc_card snd_card;
+       struct simple_dai_props {
+               struct asoc_simple_dai cpu_dai;
+               struct asoc_simple_dai codec_dai;
+       } *dai_props;
+       unsigned int mclk_fs;
+       struct snd_soc_dai_link dai_link[];     /* dynamically allocated */
+};
 
-static int __asoc_simple_card_dai_init(struct snd_soc_dai *dai,
-                                      struct asoc_simple_dai *set,
-                                      unsigned int daifmt)
+static int asoc_simple_card_hw_params(struct snd_pcm_substream *substream,
+                                     struct snd_pcm_hw_params *params)
 {
+       struct snd_soc_pcm_runtime *rtd = substream->private_data;
+       struct snd_soc_dai *codec_dai = rtd->codec_dai;
+       struct simple_card_data *priv = snd_soc_card_get_drvdata(rtd->card);
+       unsigned int mclk;
        int ret = 0;
 
-       daifmt |= set->fmt;
+       if (priv->mclk_fs) {
+               mclk = params_rate(params) * priv->mclk_fs;
+               ret = snd_soc_dai_set_sysclk(codec_dai, 0, mclk,
+                                            SND_SOC_CLOCK_IN);
+       }
 
-       if (daifmt)
-               ret = snd_soc_dai_set_fmt(dai, daifmt);
+       return ret;
+}
+
+static struct snd_soc_ops asoc_simple_card_ops = {
+       .hw_params = asoc_simple_card_hw_params,
+};
 
-       if (ret == -ENOTSUPP) {
-               dev_dbg(dai->dev, "ASoC: set_fmt is not supported\n");
-               ret = 0;
+static int __asoc_simple_card_dai_init(struct snd_soc_dai *dai,
+                                      struct asoc_simple_dai *set)
+{
+       int ret;
+
+       if (set->fmt) {
+               ret = snd_soc_dai_set_fmt(dai, set->fmt);
+               if (ret && ret != -ENOTSUPP) {
+                       dev_err(dai->dev, "simple-card: set_fmt error\n");
+                       goto err;
+               }
        }
 
-       if (!ret && set->sysclk)
+       if (set->sysclk) {
                ret = snd_soc_dai_set_sysclk(dai, 0, set->sysclk, 0);
+               if (ret && ret != -ENOTSUPP) {
+                       dev_err(dai->dev, "simple-card: set_sysclk error\n");
+                       goto err;
+               }
+       }
+
+       if (set->slots) {
+               ret = snd_soc_dai_set_tdm_slot(dai, 0, 0,
+                                               set->slots,
+                                               set->slot_width);
+               if (ret && ret != -ENOTSUPP) {
+                       dev_err(dai->dev, "simple-card: set_tdm_slot error\n");
+                       goto err;
+               }
+       }
+
+       ret = 0;
 
+err:
        return ret;
 }
 
 static int asoc_simple_card_dai_init(struct snd_soc_pcm_runtime *rtd)
 {
-       struct asoc_simple_card_info *info =
-                               snd_soc_card_get_drvdata(rtd->card);
+       struct simple_card_data *priv = snd_soc_card_get_drvdata(rtd->card);
        struct snd_soc_dai *codec = rtd->codec_dai;
        struct snd_soc_dai *cpu = rtd->cpu_dai;
-       unsigned int daifmt = info->daifmt;
-       int ret;
+       struct simple_dai_props *dai_props;
+       int num, ret;
 
-       ret = __asoc_simple_card_dai_init(codec, &info->codec_dai, daifmt);
+       num = rtd - rtd->card->rtd;
+       dai_props = &priv->dai_props[num];
+       ret = __asoc_simple_card_dai_init(codec, &dai_props->codec_dai);
        if (ret < 0)
                return ret;
 
-       ret = __asoc_simple_card_dai_init(cpu, &info->cpu_dai, daifmt);
+       ret = __asoc_simple_card_dai_init(cpu, &dai_props->cpu_dai);
        if (ret < 0)
                return ret;
 
@@ -60,8 +111,10 @@ static int asoc_simple_card_dai_init(struct snd_soc_pcm_runtime *rtd)
 static int
 asoc_simple_card_sub_parse_of(struct device_node *np,
                              struct asoc_simple_dai *dai,
-                             struct device_node **node)
+                             const struct device_node **p_node,
+                             const char **name)
 {
+       struct device_node *node;
        struct clk *clk;
        int ret;
 
@@ -69,21 +122,20 @@ asoc_simple_card_sub_parse_of(struct device_node *np,
         * get node via "sound-dai = <&phandle port>"
         * it will be used as xxx_of_node on soc_bind_dai_link()
         */
-       *node = of_parse_phandle(np, "sound-dai", 0);
-       if (!*node)
+       node = of_parse_phandle(np, "sound-dai", 0);
+       if (!node)
                return -ENODEV;
+       *p_node = node;
 
        /* get dai->name */
-       ret = snd_soc_of_get_dai_name(np, &dai->name);
+       ret = snd_soc_of_get_dai_name(np, name);
        if (ret < 0)
-               goto parse_error;
+               return ret;
 
-       /*
-        * bitclock-inversion, frame-inversion
-        * bitclock-master,    frame-master
-        * and specific "format" if it has
-        */
-       dai->fmt = snd_soc_of_parse_daifmt(np, NULL);
+       /* parse TDM slot */
+       ret = snd_soc_of_parse_tdm_slot(np, &dai->slots, &dai->slot_width);
+       if (ret)
+               return ret;
 
        /*
         * dai->sysclk come from
@@ -95,7 +147,7 @@ asoc_simple_card_sub_parse_of(struct device_node *np,
                clk = of_clk_get(np, 0);
                if (IS_ERR(clk)) {
                        ret = PTR_ERR(clk);
-                       goto parse_error;
+                       return ret;
                }
 
                dai->sysclk = clk_get_rate(clk);
@@ -104,164 +156,334 @@ asoc_simple_card_sub_parse_of(struct device_node *np,
                                     "system-clock-frequency",
                                     &dai->sysclk);
        } else {
-               clk = of_clk_get(*node, 0);
+               clk = of_clk_get(node, 0);
                if (!IS_ERR(clk))
                        dai->sysclk = clk_get_rate(clk);
        }
 
-       ret = 0;
+       return 0;
+}
+
+static int simple_card_dai_link_of(struct device_node *node,
+                                  struct device *dev,
+                                  struct snd_soc_dai_link *dai_link,
+                                  struct simple_dai_props *dai_props,
+                                  bool is_top_level_node)
+{
+       struct device_node *np = NULL;
+       struct device_node *bitclkmaster = NULL;
+       struct device_node *framemaster = NULL;
+       unsigned int daifmt;
+       char *name;
+       char prop[128];
+       char *prefix = "";
+       int ret;
+
+       if (is_top_level_node)
+               prefix = "simple-audio-card,";
+
+       daifmt = snd_soc_of_parse_daifmt(node, prefix,
+                                        &bitclkmaster, &framemaster);
+       daifmt &= ~SND_SOC_DAIFMT_MASTER_MASK;
+
+       snprintf(prop, sizeof(prop), "%scpu", prefix);
+       np = of_get_child_by_name(node, prop);
+       if (!np) {
+               ret = -EINVAL;
+               dev_err(dev, "%s: Can't find %s DT node\n", __func__, prop);
+               goto dai_link_of_err;
+       }
+
+       ret = asoc_simple_card_sub_parse_of(np, &dai_props->cpu_dai,
+                                           &dai_link->cpu_of_node,
+                                           &dai_link->cpu_dai_name);
+       if (ret < 0)
+               goto dai_link_of_err;
+
+       dai_props->cpu_dai.fmt = daifmt;
+       switch (((np == bitclkmaster) << 4) | (np == framemaster)) {
+       case 0x11:
+               dai_props->cpu_dai.fmt |= SND_SOC_DAIFMT_CBS_CFS;
+               break;
+       case 0x10:
+               dai_props->cpu_dai.fmt |= SND_SOC_DAIFMT_CBS_CFM;
+               break;
+       case 0x01:
+               dai_props->cpu_dai.fmt |= SND_SOC_DAIFMT_CBM_CFS;
+               break;
+       default:
+               dai_props->cpu_dai.fmt |= SND_SOC_DAIFMT_CBM_CFM;
+               break;
+       }
+
+       of_node_put(np);
+       snprintf(prop, sizeof(prop), "%scodec", prefix);
+       np = of_get_child_by_name(node, prop);
+       if (!np) {
+               ret = -EINVAL;
+               dev_err(dev, "%s: Can't find %s DT node\n", __func__, prop);
+               goto dai_link_of_err;
+       }
+
+       ret = asoc_simple_card_sub_parse_of(np, &dai_props->codec_dai,
+                                           &dai_link->codec_of_node,
+                                           &dai_link->codec_dai_name);
+       if (ret < 0)
+               goto dai_link_of_err;
+
+       if (strlen(prefix) && !bitclkmaster && !framemaster) {
+               /* No dai-link level and master setting was not found from
+                  sound node level, revert back to legacy DT parsing and
+                  take the settings from codec node. */
+               dev_dbg(dev, "%s: Revert to legacy daifmt parsing\n",
+                       __func__);
+               dai_props->cpu_dai.fmt = dai_props->codec_dai.fmt =
+                       snd_soc_of_parse_daifmt(np, NULL, NULL, NULL) |
+                       (daifmt & ~SND_SOC_DAIFMT_CLOCK_MASK);
+       } else {
+               dai_props->codec_dai.fmt = daifmt;
+               switch (((np == bitclkmaster) << 4) | (np == framemaster)) {
+               case 0x11:
+                       dai_props->codec_dai.fmt |= SND_SOC_DAIFMT_CBM_CFM;
+                       break;
+               case 0x10:
+                       dai_props->codec_dai.fmt |= SND_SOC_DAIFMT_CBM_CFS;
+                       break;
+               case 0x01:
+                       dai_props->codec_dai.fmt |= SND_SOC_DAIFMT_CBS_CFM;
+                       break;
+               default:
+                       dai_props->codec_dai.fmt |= SND_SOC_DAIFMT_CBS_CFS;
+                       break;
+               }
+       }
 
-parse_error:
-       of_node_put(*node);
+       if (!dai_link->cpu_dai_name || !dai_link->codec_dai_name) {
+               ret = -EINVAL;
+               goto dai_link_of_err;
+       }
+
+       /* simple-card assumes platform == cpu */
+       dai_link->platform_of_node = dai_link->cpu_of_node;
 
+       /* Link name is created from CPU/CODEC dai name */
+       name = devm_kzalloc(dev,
+                           strlen(dai_link->cpu_dai_name)   +
+                           strlen(dai_link->codec_dai_name) + 2,
+                           GFP_KERNEL);
+       sprintf(name, "%s-%s", dai_link->cpu_dai_name,
+                               dai_link->codec_dai_name);
+       dai_link->name = dai_link->stream_name = name;
+       dai_link->ops = &asoc_simple_card_ops;
+
+       dev_dbg(dev, "\tname : %s\n", dai_link->stream_name);
+       dev_dbg(dev, "\tcpu : %s / %04x / %d\n",
+               dai_link->cpu_dai_name,
+               dai_props->cpu_dai.fmt,
+               dai_props->cpu_dai.sysclk);
+       dev_dbg(dev, "\tcodec : %s / %04x / %d\n",
+               dai_link->codec_dai_name,
+               dai_props->codec_dai.fmt,
+               dai_props->codec_dai.sysclk);
+
+dai_link_of_err:
+       if (np)
+               of_node_put(np);
+       if (bitclkmaster)
+               of_node_put(bitclkmaster);
+       if (framemaster)
+               of_node_put(framemaster);
        return ret;
 }
 
 static int asoc_simple_card_parse_of(struct device_node *node,
-                                    struct asoc_simple_card_info *info,
+                                    struct simple_card_data *priv,
                                     struct device *dev,
-                                    struct device_node **of_cpu,
-                                    struct device_node **of_codec,
-                                    struct device_node **of_platform)
+                                    int multi)
 {
-       struct device_node *np;
-       char *name;
+       struct snd_soc_dai_link *dai_link = priv->snd_card.dai_link;
+       struct simple_dai_props *dai_props = priv->dai_props;
        int ret;
 
-       /* get CPU/CODEC common format via simple-audio-card,format */
-       info->daifmt = snd_soc_of_parse_daifmt(node, "simple-audio-card,") &
-               (SND_SOC_DAIFMT_FORMAT_MASK | SND_SOC_DAIFMT_INV_MASK);
+       /* parsing the card name from DT */
+       snd_soc_of_parse_card_name(&priv->snd_card, "simple-audio-card,name");
+
+       /* off-codec widgets */
+       if (of_property_read_bool(node, "simple-audio-card,widgets")) {
+               ret = snd_soc_of_parse_audio_simple_widgets(&priv->snd_card,
+                                       "simple-audio-card,widgets");
+               if (ret)
+                       return ret;
+       }
 
        /* DAPM routes */
        if (of_property_read_bool(node, "simple-audio-card,routing")) {
-               ret = snd_soc_of_parse_audio_routing(&info->snd_card,
+               ret = snd_soc_of_parse_audio_routing(&priv->snd_card,
                                        "simple-audio-card,routing");
                if (ret)
                        return ret;
        }
 
-       /* CPU sub-node */
-       ret = -EINVAL;
-       np = of_get_child_by_name(node, "simple-audio-card,cpu");
-       if (np)
-               ret = asoc_simple_card_sub_parse_of(np,
-                                                 &info->cpu_dai,
-                                                 of_cpu);
-       if (ret < 0)
-               return ret;
-
-       /* CODEC sub-node */
-       ret = -EINVAL;
-       np = of_get_child_by_name(node, "simple-audio-card,codec");
-       if (np)
-               ret = asoc_simple_card_sub_parse_of(np,
-                                                 &info->codec_dai,
-                                                 of_codec);
-       if (ret < 0)
-               return ret;
-
-       if (!info->cpu_dai.name || !info->codec_dai.name)
-               return -EINVAL;
+       /* Factor to mclk, used in hw_params() */
+       of_property_read_u32(node, "simple-audio-card,mclk-fs",
+                            &priv->mclk_fs);
+
+       dev_dbg(dev, "New simple-card: %s\n", priv->snd_card.name ?
+               priv->snd_card.name : "");
+
+       if (multi) {
+               struct device_node *np = NULL;
+               int i;
+               for (i = 0; (np = of_get_next_child(node, np)); i++) {
+                       dev_dbg(dev, "\tlink %d:\n", i);
+                       ret = simple_card_dai_link_of(np, dev, dai_link + i,
+                                                     dai_props + i, false);
+                       if (ret < 0) {
+                               of_node_put(np);
+                               return ret;
+                       }
+               }
+       } else {
+               ret = simple_card_dai_link_of(node, dev, dai_link, dai_props,
+                                             true);
+               if (ret < 0)
+                       return ret;
+       }
 
-       /* card name is created from CPU/CODEC dai name */
-       name = devm_kzalloc(dev,
-                           strlen(info->cpu_dai.name)   +
-                           strlen(info->codec_dai.name) + 2,
-                           GFP_KERNEL);
-       sprintf(name, "%s-%s", info->cpu_dai.name, info->codec_dai.name);
-       info->name = info->card = name;
+       if (!priv->snd_card.name)
+               priv->snd_card.name = priv->snd_card.dai_link->name;
 
-       /* simple-card assumes platform == cpu */
-       *of_platform = *of_cpu;
-
-       dev_dbg(dev, "card-name : %s\n", info->card);
-       dev_dbg(dev, "platform : %04x\n", info->daifmt);
-       dev_dbg(dev, "cpu : %s / %04x / %d\n",
-               info->cpu_dai.name,
-               info->cpu_dai.fmt,
-               info->cpu_dai.sysclk);
-       dev_dbg(dev, "codec : %s / %04x / %d\n",
-               info->codec_dai.name,
-               info->codec_dai.fmt,
-               info->codec_dai.sysclk);
+       return 0;
+}
 
+/* update the reference count of the devices nodes at end of probe */
+static int asoc_simple_card_unref(struct platform_device *pdev)
+{
+       struct snd_soc_card *card = platform_get_drvdata(pdev);
+       struct snd_soc_dai_link *dai_link;
+       struct device_node *np;
+       int num_links;
+
+       for (num_links = 0, dai_link = card->dai_link;
+            num_links < card->num_links;
+            num_links++, dai_link++) {
+               np = (struct device_node *) dai_link->cpu_of_node;
+               if (np)
+                       of_node_put(np);
+               np = (struct device_node *) dai_link->codec_of_node;
+               if (np)
+                       of_node_put(np);
+       }
        return 0;
 }
 
 static int asoc_simple_card_probe(struct platform_device *pdev)
 {
-       struct asoc_simple_card_info *cinfo;
+       struct simple_card_data *priv;
+       struct snd_soc_dai_link *dai_link;
        struct device_node *np = pdev->dev.of_node;
-       struct device_node *of_cpu, *of_codec, *of_platform;
        struct device *dev = &pdev->dev;
-       int ret;
+       int num_links, multi, ret;
 
-       cinfo           = NULL;
-       of_cpu          = NULL;
-       of_codec        = NULL;
-       of_platform     = NULL;
+       /* get the number of DAI links */
+       if (np && of_get_child_by_name(np, "simple-audio-card,dai-link")) {
+               num_links = of_get_child_count(np);
+               multi = 1;
+       } else {
+               num_links = 1;
+               multi = 0;
+       }
+
+       /* allocate the private data and the DAI link array */
+       priv = devm_kzalloc(dev,
+                       sizeof(*priv) + sizeof(*dai_link) * num_links,
+                       GFP_KERNEL);
+       if (!priv)
+               return -ENOMEM;
 
-       cinfo = devm_kzalloc(dev, sizeof(*cinfo), GFP_KERNEL);
-       if (!cinfo)
+       /*
+        * init snd_soc_card
+        */
+       priv->snd_card.owner = THIS_MODULE;
+       priv->snd_card.dev = dev;
+       dai_link = priv->dai_link;
+       priv->snd_card.dai_link = dai_link;
+       priv->snd_card.num_links = num_links;
+
+       /* get room for the other properties */
+       priv->dai_props = devm_kzalloc(dev,
+                       sizeof(*priv->dai_props) * num_links,
+                       GFP_KERNEL);
+       if (!priv->dai_props)
                return -ENOMEM;
 
        if (np && of_device_is_available(np)) {
-               cinfo->snd_card.dev = dev;
 
-               ret = asoc_simple_card_parse_of(np, cinfo, dev,
-                                               &of_cpu,
-                                               &of_codec,
-                                               &of_platform);
+               ret = asoc_simple_card_parse_of(np, priv, dev, multi);
                if (ret < 0) {
                        if (ret != -EPROBE_DEFER)
                                dev_err(dev, "parse error %d\n", ret);
-                       return ret;
+                       goto err;
                }
+
+               /*
+                * soc_bind_dai_link() will check cpu name
+                * after of_node matching if dai_link has cpu_dai_name.
+                * but, it will never match if name was created by fmt_single_name()
+                * remove cpu_dai_name to escape name matching.
+                * see
+                *      fmt_single_name()
+                *      fmt_multiple_name()
+                */
+               if (num_links == 1)
+                       dai_link->cpu_dai_name = NULL;
+
        } else {
-               if (!dev->platform_data) {
+               struct asoc_simple_card_info *cinfo;
+
+               cinfo = dev->platform_data;
+               if (!cinfo) {
                        dev_err(dev, "no info for asoc-simple-card\n");
                        return -EINVAL;
                }
 
-               memcpy(cinfo, dev->platform_data, sizeof(*cinfo));
-               cinfo->snd_card.dev = dev;
-       }
+               if (!cinfo->name ||
+                   !cinfo->codec_dai.name ||
+                   !cinfo->codec ||
+                   !cinfo->platform ||
+                   !cinfo->cpu_dai.name) {
+                       dev_err(dev, "insufficient asoc_simple_card_info settings\n");
+                       return -EINVAL;
+               }
 
-       if (!cinfo->name        ||
-           !cinfo->card        ||
-           !cinfo->codec_dai.name      ||
-           !(cinfo->codec              || of_codec)    ||
-           !(cinfo->platform           || of_platform) ||
-           !(cinfo->cpu_dai.name       || of_cpu)) {
-               dev_err(dev, "insufficient asoc_simple_card_info settings\n");
-               return -EINVAL;
+               priv->snd_card.name     = (cinfo->card) ? cinfo->card : cinfo->name;
+               dai_link->name          = cinfo->name;
+               dai_link->stream_name   = cinfo->name;
+               dai_link->platform_name = cinfo->platform;
+               dai_link->codec_name    = cinfo->codec;
+               dai_link->cpu_dai_name  = cinfo->cpu_dai.name;
+               dai_link->codec_dai_name = cinfo->codec_dai.name;
+               memcpy(&priv->dai_props->cpu_dai, &cinfo->cpu_dai,
+                                       sizeof(priv->dai_props->cpu_dai));
+               memcpy(&priv->dai_props->codec_dai, &cinfo->codec_dai,
+                                       sizeof(priv->dai_props->codec_dai));
+
+               priv->dai_props->cpu_dai.fmt    |= cinfo->daifmt;
+               priv->dai_props->codec_dai.fmt  |= cinfo->daifmt;
        }
 
        /*
         * init snd_soc_dai_link
         */
-       cinfo->snd_link.name            = cinfo->name;
-       cinfo->snd_link.stream_name     = cinfo->name;
-       cinfo->snd_link.cpu_dai_name    = cinfo->cpu_dai.name;
-       cinfo->snd_link.platform_name   = cinfo->platform;
-       cinfo->snd_link.codec_name      = cinfo->codec;
-       cinfo->snd_link.codec_dai_name  = cinfo->codec_dai.name;
-       cinfo->snd_link.cpu_of_node     = of_cpu;
-       cinfo->snd_link.codec_of_node   = of_codec;
-       cinfo->snd_link.platform_of_node = of_platform;
-       cinfo->snd_link.init            = asoc_simple_card_dai_init;
+       dai_link->init = asoc_simple_card_dai_init;
 
-       /*
-        * init snd_soc_card
-        */
-       cinfo->snd_card.name            = cinfo->card;
-       cinfo->snd_card.owner           = THIS_MODULE;
-       cinfo->snd_card.dai_link        = &cinfo->snd_link;
-       cinfo->snd_card.num_links       = 1;
+       snd_soc_card_set_drvdata(&priv->snd_card, priv);
 
-       snd_soc_card_set_drvdata(&cinfo->snd_card, cinfo);
+       ret = devm_snd_soc_register_card(&pdev->dev, &priv->snd_card);
 
-       return devm_snd_soc_register_card(&pdev->dev, &cinfo->snd_card);
+err:
+       asoc_simple_card_unref(pdev);
+       return ret;
 }
 
 static const struct of_device_id asoc_simple_of_match[] = {
@@ -272,11 +494,11 @@ MODULE_DEVICE_TABLE(of, asoc_simple_of_match);
 
 static struct platform_driver asoc_simple_card = {
        .driver = {
-               .name   = "asoc-simple-card",
+               .name = "asoc-simple-card",
                .owner = THIS_MODULE,
                .of_match_table = asoc_simple_of_match,
        },
-       .probe          = asoc_simple_card_probe,
+       .probe = asoc_simple_card_probe,
 };
 
 module_platform_driver(asoc_simple_card);
index ff60e11..80245b6 100644 (file)
@@ -37,7 +37,7 @@ config SND_SOC_SH4_SIU
 config SND_SOC_RCAR
        tristate "R-Car series SRU/SCU/SSIU/SSI support"
        select SND_SIMPLE_CARD
-       select REGMAP
+       select REGMAP_MMIO
        help
          This option enables R-Car SUR/SCU/SSIU/SSI sound support
 
@@ -56,7 +56,7 @@ config SND_SH7760_AC97
 
 config SND_SIU_MIGOR
        tristate "SIU sound support on Migo-R"
-       depends on SH_MIGOR
+       depends on SH_MIGOR && I2C
        select SND_SOC_SH4_SIU
        select SND_SOC_WM8978
        help
index 1967f44..7a6b632 100644 (file)
@@ -233,7 +233,6 @@ struct fsi_stream {
         */
        struct dma_chan         *chan;
        struct work_struct      work;
-       dma_addr_t              dma;
        int                     dma_id;
        int                     loop_cnt;
        int                     additional_pos;
@@ -1279,11 +1278,6 @@ static irqreturn_t fsi_interrupt(int irq, void *data)
  */
 static int fsi_dma_init(struct fsi_priv *fsi, struct fsi_stream *io)
 {
-       struct snd_pcm_runtime *runtime = io->substream->runtime;
-       struct snd_soc_dai *dai = fsi_get_dai(io->substream);
-       enum dma_data_direction dir = fsi_stream_is_play(fsi, io) ?
-                               DMA_TO_DEVICE : DMA_FROM_DEVICE;
-
        /*
         * 24bit data : 24bit bus / package in back
         * 16bit data : 16bit bus / stream mode
@@ -1293,19 +1287,7 @@ static int fsi_dma_init(struct fsi_priv *fsi, struct fsi_stream *io)
 
        io->loop_cnt = 2; /* push 1st, 2nd period first, then 3rd, 4th... */
        io->additional_pos = 0;
-       io->dma = dma_map_single(dai->dev, runtime->dma_area,
-                                snd_pcm_lib_buffer_bytes(io->substream), dir);
-       return 0;
-}
-
-static int fsi_dma_quit(struct fsi_priv *fsi, struct fsi_stream *io)
-{
-       struct snd_soc_dai *dai = fsi_get_dai(io->substream);
-       enum dma_data_direction dir = fsi_stream_is_play(fsi, io) ?
-               DMA_TO_DEVICE : DMA_FROM_DEVICE;
 
-       dma_unmap_single(dai->dev, io->dma,
-                        snd_pcm_lib_buffer_bytes(io->substream), dir);
        return 0;
 }
 
@@ -1317,7 +1299,8 @@ static dma_addr_t fsi_dma_get_area(struct fsi_stream *io, int additional)
        if (period >= runtime->periods)
                period = 0;
 
-       return io->dma + samples_to_bytes(runtime, period * io->period_samples);
+       return runtime->dma_addr +
+               samples_to_bytes(runtime, period * io->period_samples);
 }
 
 static void fsi_dma_complete(void *data)
@@ -1325,12 +1308,6 @@ static void fsi_dma_complete(void *data)
        struct fsi_stream *io = (struct fsi_stream *)data;
        struct fsi_priv *fsi = fsi_stream_to_priv(io);
        struct snd_pcm_runtime *runtime = io->substream->runtime;
-       struct snd_soc_dai *dai = fsi_get_dai(io->substream);
-       enum dma_data_direction dir = fsi_stream_is_play(fsi, io) ?
-               DMA_TO_DEVICE : DMA_FROM_DEVICE;
-
-       dma_sync_single_for_cpu(dai->dev, fsi_dma_get_area(io, 0),
-                       samples_to_bytes(runtime, io->period_samples), dir);
 
        io->buff_sample_pos += io->period_samples;
        io->period_pos++;
@@ -1369,8 +1346,6 @@ static void fsi_dma_do_work(struct work_struct *work)
        for (i = 0; i < io->loop_cnt; i++) {
                buf     = fsi_dma_get_area(io, io->additional_pos);
 
-               dma_sync_single_for_device(dai->dev, buf, len, dir);
-
                desc = dmaengine_prep_slave_single(io->chan, buf, len, dir,
                                        DMA_PREP_INTERRUPT | DMA_CTRL_ACK);
                if (!desc) {
@@ -1495,7 +1470,6 @@ static int fsi_dma_remove(struct fsi_priv *fsi, struct fsi_stream *io)
 
 static struct fsi_stream_handler fsi_dma_push_handler = {
        .init           = fsi_dma_init,
-       .quit           = fsi_dma_quit,
        .probe          = fsi_dma_probe,
        .transfer       = fsi_dma_transfer,
        .remove         = fsi_dma_remove,
@@ -1711,9 +1685,9 @@ static int fsi_dai_set_fmt(struct snd_soc_dai *dai, unsigned int fmt)
        /* set master/slave audio interface */
        switch (fmt & SND_SOC_DAIFMT_MASTER_MASK) {
        case SND_SOC_DAIFMT_CBM_CFM:
-               fsi->clk_master = 1;
                break;
        case SND_SOC_DAIFMT_CBS_CFS:
+               fsi->clk_master = 1; /* codec is slave, cpu is master */
                break;
        default:
                return -EINVAL;
@@ -1850,16 +1824,10 @@ static void fsi_pcm_free(struct snd_pcm *pcm)
 
 static int fsi_pcm_new(struct snd_soc_pcm_runtime *rtd)
 {
-       struct snd_pcm *pcm = rtd->pcm;
-
-       /*
-        * dont use SNDRV_DMA_TYPE_DEV, since it will oops the SH kernel
-        * in MMAP mode (i.e. aplay -M)
-        */
        return snd_pcm_lib_preallocate_pages_for_all(
-               pcm,
-               SNDRV_DMA_TYPE_CONTINUOUS,
-               snd_dma_continuous_data(GFP_KERNEL),
+               rtd->pcm,
+               SNDRV_DMA_TYPE_DEV,
+               rtd->card->snd_card->dev,
                PREALLOC_BUFFER, PREALLOC_BUFFER_MAX);
 }
 
index 0ff492d..9ac5364 100644 (file)
@@ -1,2 +1,2 @@
-snd-soc-rcar-objs      := core.o gen.o scu.o adg.o ssi.o
+snd-soc-rcar-objs      := core.o gen.o src.o adg.o ssi.o dvc.o
 obj-$(CONFIG_SND_SOC_RCAR)     += snd-soc-rcar.o
\ No newline at end of file
index a53235c..fc41a0e 100644 (file)
@@ -25,15 +25,183 @@ struct rsnd_adg {
 };
 
 #define for_each_rsnd_clk(pos, adg, i)         \
-       for (i = 0, (pos) = adg->clk[i];        \
-            i < CLKMAX;                        \
-            i++, (pos) = adg->clk[i])
+       for (i = 0;                             \
+            (i < CLKMAX) &&                    \
+            ((pos) = adg->clk[i]);             \
+            i++)
 #define rsnd_priv_to_adg(priv) ((struct rsnd_adg *)(priv)->adg)
 
-static int rsnd_adg_set_convert_clk_gen1(struct rsnd_priv *priv,
-                                        struct rsnd_mod *mod,
-                                        unsigned int src_rate,
-                                        unsigned int dst_rate)
+
+static u32 rsnd_adg_ssi_ws_timing_gen2(struct rsnd_dai_stream *io)
+{
+       struct rsnd_mod *mod = rsnd_io_to_mod_ssi(io);
+       struct rsnd_priv *priv = rsnd_mod_to_priv(mod);
+       int id = rsnd_mod_id(mod);
+       int ws = id;
+
+       if (rsnd_ssi_is_pin_sharing(rsnd_ssi_mod_get(priv, id))) {
+               switch (id) {
+               case 1:
+               case 2:
+                       ws = 0;
+                       break;
+               case 4:
+                       ws = 3;
+                       break;
+               case 8:
+                       ws = 7;
+                       break;
+               }
+       }
+
+       return (0x6 + ws) << 8;
+}
+
+int rsnd_adg_set_cmd_timsel_gen2(struct rsnd_dai *rdai,
+                                struct rsnd_mod *mod,
+                                struct rsnd_dai_stream *io)
+{
+       int id = rsnd_mod_id(mod);
+       int shift = (id % 2) ? 16 : 0;
+       u32 mask, val;
+
+       val = rsnd_adg_ssi_ws_timing_gen2(io);
+
+       val  = val      << shift;
+       mask = 0xffff   << shift;
+
+       rsnd_mod_bset(mod, CMDOUT_TIMSEL, mask, val);
+
+       return 0;
+}
+
+static int rsnd_adg_set_src_timsel_gen2(struct rsnd_dai *rdai,
+                                       struct rsnd_mod *mod,
+                                       struct rsnd_dai_stream *io,
+                                       u32 timsel)
+{
+       int is_play = rsnd_dai_is_play(rdai, io);
+       int id = rsnd_mod_id(mod);
+       int shift = (id % 2) ? 16 : 0;
+       u32 mask, ws;
+       u32 in, out;
+
+       ws = rsnd_adg_ssi_ws_timing_gen2(io);
+
+       in  = (is_play) ? timsel : ws;
+       out = (is_play) ? ws     : timsel;
+
+       in   = in       << shift;
+       out  = out      << shift;
+       mask = 0xffff   << shift;
+
+       switch (id / 2) {
+       case 0:
+               rsnd_mod_bset(mod, SRCIN_TIMSEL0,  mask, in);
+               rsnd_mod_bset(mod, SRCOUT_TIMSEL0, mask, out);
+               break;
+       case 1:
+               rsnd_mod_bset(mod, SRCIN_TIMSEL1,  mask, in);
+               rsnd_mod_bset(mod, SRCOUT_TIMSEL1, mask, out);
+               break;
+       case 2:
+               rsnd_mod_bset(mod, SRCIN_TIMSEL2,  mask, in);
+               rsnd_mod_bset(mod, SRCOUT_TIMSEL2, mask, out);
+               break;
+       case 3:
+               rsnd_mod_bset(mod, SRCIN_TIMSEL3,  mask, in);
+               rsnd_mod_bset(mod, SRCOUT_TIMSEL3, mask, out);
+               break;
+       case 4:
+               rsnd_mod_bset(mod, SRCIN_TIMSEL4,  mask, in);
+               rsnd_mod_bset(mod, SRCOUT_TIMSEL4, mask, out);
+               break;
+       }
+
+       return 0;
+}
+
+int rsnd_adg_set_convert_clk_gen2(struct rsnd_mod *mod,
+                                 struct rsnd_dai *rdai,
+                                 struct rsnd_dai_stream *io,
+                                 unsigned int src_rate,
+                                 unsigned int dst_rate)
+{
+       struct rsnd_priv *priv = rsnd_mod_to_priv(mod);
+       struct rsnd_adg *adg = rsnd_priv_to_adg(priv);
+       struct device *dev = rsnd_priv_to_dev(priv);
+       int idx, sel, div, step, ret;
+       u32 val, en;
+       unsigned int min, diff;
+       unsigned int sel_rate [] = {
+               clk_get_rate(adg->clk[CLKA]),   /* 0000: CLKA */
+               clk_get_rate(adg->clk[CLKB]),   /* 0001: CLKB */
+               clk_get_rate(adg->clk[CLKC]),   /* 0010: CLKC */
+               adg->rbga_rate_for_441khz_div_6,/* 0011: RBGA */
+               adg->rbgb_rate_for_48khz_div_6, /* 0100: RBGB */
+       };
+
+       min = ~0;
+       val = 0;
+       en = 0;
+       for (sel = 0; sel < ARRAY_SIZE(sel_rate); sel++) {
+               idx = 0;
+               step = 2;
+
+               if (!sel_rate[sel])
+                       continue;
+
+               for (div = 2; div <= 98304; div += step) {
+                       diff = abs(src_rate - sel_rate[sel] / div);
+                       if (min > diff) {
+                               val = (sel << 8) | idx;
+                               min = diff;
+                               en = 1 << (sel + 1); /* fixme */
+                       }
+
+                       /*
+                        * step of 0_0000 / 0_0001 / 0_1101
+                        * are out of order
+                        */
+                       if ((idx > 2) && (idx % 2))
+                               step *= 2;
+                       if (idx == 0x1c) {
+                               div += step;
+                               step *= 2;
+                       }
+                       idx++;
+               }
+       }
+
+       if (min == ~0) {
+               dev_err(dev, "no Input clock\n");
+               return -EIO;
+       }
+
+       ret = rsnd_adg_set_src_timsel_gen2(rdai, mod, io, val);
+       if (ret < 0) {
+               dev_err(dev, "timsel error\n");
+               return ret;
+       }
+
+       rsnd_mod_bset(mod, DIV_EN, en, en);
+
+       return 0;
+}
+
+int rsnd_adg_set_convert_timing_gen2(struct rsnd_mod *mod,
+                                    struct rsnd_dai *rdai,
+                                    struct rsnd_dai_stream *io)
+{
+       u32 val = rsnd_adg_ssi_ws_timing_gen2(io);
+
+       return rsnd_adg_set_src_timsel_gen2(rdai, mod, io, val);
+}
+
+int rsnd_adg_set_convert_clk_gen1(struct rsnd_priv *priv,
+                                 struct rsnd_mod *mod,
+                                 unsigned int src_rate,
+                                 unsigned int dst_rate)
 {
        struct rsnd_adg *adg = rsnd_priv_to_adg(priv);
        struct device *dev = rsnd_priv_to_dev(priv);
@@ -91,18 +259,6 @@ find_rate:
        return 0;
 }
 
-int rsnd_adg_set_convert_clk(struct rsnd_priv *priv,
-                            struct rsnd_mod *mod,
-                            unsigned int src_rate,
-                            unsigned int dst_rate)
-{
-       if (rsnd_is_gen1(priv))
-               return rsnd_adg_set_convert_clk_gen1(priv, mod,
-                                                    src_rate, dst_rate);
-
-       return -EINVAL;
-}
-
 static void rsnd_adg_set_ssi_clk(struct rsnd_mod *mod, u32 val)
 {
        int id = rsnd_mod_id(mod);
@@ -254,7 +410,7 @@ static void rsnd_adg_ssi_clk_init(struct rsnd_priv *priv, struct rsnd_adg *adg)
 }
 
 int rsnd_adg_probe(struct platform_device *pdev,
-                  struct rcar_snd_info *info,
+                  const struct rsnd_of_data *of_data,
                   struct rsnd_priv *priv)
 {
        struct rsnd_adg *adg;
@@ -268,16 +424,13 @@ int rsnd_adg_probe(struct platform_device *pdev,
                return -ENOMEM;
        }
 
-       adg->clk[CLKA] = clk_get(NULL, "audio_clk_a");
-       adg->clk[CLKB] = clk_get(NULL, "audio_clk_b");
-       adg->clk[CLKC] = clk_get(NULL, "audio_clk_c");
-       adg->clk[CLKI] = clk_get(NULL, "audio_clk_internal");
-       for_each_rsnd_clk(clk, adg, i) {
-               if (IS_ERR(clk)) {
-                       dev_err(dev, "Audio clock failed\n");
-                       return -EIO;
-               }
-       }
+       adg->clk[CLKA]  = devm_clk_get(dev, "clk_a");
+       adg->clk[CLKB]  = devm_clk_get(dev, "clk_b");
+       adg->clk[CLKC]  = devm_clk_get(dev, "clk_c");
+       adg->clk[CLKI]  = devm_clk_get(dev, "clk_i");
+
+       for_each_rsnd_clk(clk, adg, i)
+               dev_dbg(dev, "clk %d : %p\n", i, clk);
 
        rsnd_adg_ssi_clk_init(priv, adg);
 
@@ -287,14 +440,3 @@ int rsnd_adg_probe(struct platform_device *pdev,
 
        return 0;
 }
-
-void rsnd_adg_remove(struct platform_device *pdev,
-                    struct rsnd_priv *priv)
-{
-       struct rsnd_adg *adg = priv->adg;
-       struct clk *clk;
-       int i;
-
-       for_each_rsnd_clk(clk, adg, i)
-               clk_put(clk);
-}
index 743de5e..1922ec5 100644 (file)
  *   |  +- ssi[2]
  *   |  ...
  *   |
- *   | ** these control scu
+ *   | ** these control src
  *   |
- *   +- scu
+ *   +- src
  *      |
- *      +- scu[0]
- *      +- scu[1]
- *      +- scu[2]
+ *      +- src[0]
+ *      +- src[1]
+ *      +- src[2]
  *      ...
  *
  *
 #define RSND_RATES SNDRV_PCM_RATE_8000_96000
 #define RSND_FMTS (SNDRV_PCM_FMTBIT_S24_LE | SNDRV_PCM_FMTBIT_S16_LE)
 
+static struct rsnd_of_data rsnd_of_data_gen1 = {
+       .flags = RSND_GEN1,
+};
+
+static struct rsnd_of_data rsnd_of_data_gen2 = {
+       .flags = RSND_GEN2,
+};
+
+static struct of_device_id rsnd_of_match[] = {
+       { .compatible = "renesas,rcar_sound-gen1", .data = &rsnd_of_data_gen1 },
+       { .compatible = "renesas,rcar_sound-gen2", .data = &rsnd_of_data_gen2 },
+       {},
+};
+MODULE_DEVICE_TABLE(of, rsnd_of_match);
+
 /*
  *     rsnd_platform functions
  */
        (!(priv->info->func) ? 0 :              \
         priv->info->func(param))
 
+#define rsnd_is_enable_path(io, name) \
+       ((io)->info ? (io)->info->name : NULL)
+#define rsnd_info_id(priv, io, name) \
+       ((io)->info->name - priv->info->name##_info)
+
 /*
  *     rsnd_mod functions
  */
@@ -118,105 +138,188 @@ char *rsnd_mod_name(struct rsnd_mod *mod)
        return mod->ops->name;
 }
 
+char *rsnd_mod_dma_name(struct rsnd_mod *mod)
+{
+       if (!mod || !mod->ops)
+               return "unknown";
+
+       if (!mod->ops->dma_name)
+               return mod->ops->name;
+
+       return mod->ops->dma_name(mod);
+}
+
 void rsnd_mod_init(struct rsnd_priv *priv,
                   struct rsnd_mod *mod,
                   struct rsnd_mod_ops *ops,
+                  enum rsnd_mod_type type,
                   int id)
 {
        mod->priv       = priv;
        mod->id         = id;
        mod->ops        = ops;
-       INIT_LIST_HEAD(&mod->list);
+       mod->type       = type;
 }
 
 /*
  *     rsnd_dma functions
  */
-static void rsnd_dma_continue(struct rsnd_dma *dma)
+void rsnd_dma_stop(struct rsnd_dma *dma)
 {
-       /* push next A or B plane */
-       dma->submit_loop = 1;
-       schedule_work(&dma->work);
+       dmaengine_terminate_all(dma->chan);
 }
 
-void rsnd_dma_start(struct rsnd_dma *dma)
+static void rsnd_dma_complete(void *data)
 {
-       /* push both A and B plane*/
-       dma->submit_loop = 2;
-       schedule_work(&dma->work);
+       struct rsnd_dma *dma = (struct rsnd_dma *)data;
+       struct rsnd_mod *mod = rsnd_dma_to_mod(dma);
+       struct rsnd_dai_stream *io = rsnd_mod_to_io(mod);
+
+       /*
+        * Renesas sound Gen1 needs 1 DMAC,
+        * Gen2 needs 2 DMAC.
+        * In Gen2 case, it are Audio-DMAC, and Audio-DMAC-peri-peri.
+        * But, Audio-DMAC-peri-peri doesn't have interrupt,
+        * and this driver is assuming that here.
+        *
+        * If Audio-DMAC-peri-peri has interrpt,
+        * rsnd_dai_pointer_update() will be called twice,
+        * ant it will breaks io->byte_pos
+        */
+
+       rsnd_dai_pointer_update(io, io->byte_per_period);
 }
 
-void rsnd_dma_stop(struct rsnd_dma *dma)
+void rsnd_dma_start(struct rsnd_dma *dma)
 {
-       dma->submit_loop = 0;
-       cancel_work_sync(&dma->work);
-       dmaengine_terminate_all(dma->chan);
+       struct rsnd_mod *mod = rsnd_dma_to_mod(dma);
+       struct rsnd_priv *priv = rsnd_mod_to_priv(mod);
+       struct rsnd_dai_stream *io = rsnd_mod_to_io(mod);
+       struct snd_pcm_substream *substream = io->substream;
+       struct device *dev = rsnd_priv_to_dev(priv);
+       struct dma_async_tx_descriptor *desc;
+
+       desc = dmaengine_prep_dma_cyclic(dma->chan,
+                                        (dma->addr) ? dma->addr :
+                                        substream->runtime->dma_addr,
+                                        snd_pcm_lib_buffer_bytes(substream),
+                                        snd_pcm_lib_period_bytes(substream),
+                                        dma->dir,
+                                        DMA_PREP_INTERRUPT | DMA_CTRL_ACK);
+
+       if (!desc) {
+               dev_err(dev, "dmaengine_prep_slave_sg() fail\n");
+               return;
+       }
+
+       desc->callback          = rsnd_dma_complete;
+       desc->callback_param    = dma;
+
+       if (dmaengine_submit(desc) < 0) {
+               dev_err(dev, "dmaengine_submit() fail\n");
+               return;
+       }
+
+       dma_async_issue_pending(dma->chan);
 }
 
-static void rsnd_dma_complete(void *data)
+int rsnd_dma_available(struct rsnd_dma *dma)
 {
-       struct rsnd_dma *dma = (struct rsnd_dma *)data;
-       struct rsnd_priv *priv = dma->priv;
-       unsigned long flags;
+       return !!dma->chan;
+}
 
-       rsnd_lock(priv, flags);
+#define DMA_NAME_SIZE 16
+#define MOD_MAX 4 /* MEM/SSI/SRC/DVC */
+static int _rsnd_dma_of_name(char *dma_name, struct rsnd_mod *mod)
+{
+       if (mod)
+               return snprintf(dma_name, DMA_NAME_SIZE / 2, "%s%d",
+                        rsnd_mod_dma_name(mod), rsnd_mod_id(mod));
+       else
+               return snprintf(dma_name, DMA_NAME_SIZE / 2, "mem");
 
-       dma->complete(dma);
+}
 
-       if (dma->submit_loop)
-               rsnd_dma_continue(dma);
+static void rsnd_dma_of_name(struct rsnd_mod *mod_from,
+                            struct rsnd_mod *mod_to,
+                            char *dma_name)
+{
+       int index = 0;
 
-       rsnd_unlock(priv, flags);
+       index = _rsnd_dma_of_name(dma_name + index, mod_from);
+       *(dma_name + index++) = '_';
+       index = _rsnd_dma_of_name(dma_name + index, mod_to);
 }
 
-static void rsnd_dma_do_work(struct work_struct *work)
+static void rsnd_dma_of_path(struct rsnd_dma *dma,
+                            int is_play,
+                            struct rsnd_mod **mod_from,
+                            struct rsnd_mod **mod_to)
 {
-       struct rsnd_dma *dma = container_of(work, struct rsnd_dma, work);
-       struct rsnd_priv *priv = dma->priv;
-       struct device *dev = rsnd_priv_to_dev(priv);
-       struct dma_async_tx_descriptor *desc;
-       dma_addr_t buf;
-       size_t len;
-       int i;
+       struct rsnd_mod *this = rsnd_dma_to_mod(dma);
+       struct rsnd_dai_stream *io = rsnd_mod_to_io(this);
+       struct rsnd_mod *ssi = rsnd_io_to_mod_ssi(io);
+       struct rsnd_mod *src = rsnd_io_to_mod_src(io);
+       struct rsnd_mod *dvc = rsnd_io_to_mod_dvc(io);
+       struct rsnd_mod *mod[MOD_MAX];
+       int i, index;
 
-       for (i = 0; i < dma->submit_loop; i++) {
 
-               if (dma->inquiry(dma, &buf, &len) < 0)
-                       return;
+       for (i = 0; i < MOD_MAX; i++)
+               mod[i] = NULL;
 
-               desc = dmaengine_prep_slave_single(
-                       dma->chan, buf, len, dma->dir,
-                       DMA_PREP_INTERRUPT | DMA_CTRL_ACK);
-               if (!desc) {
-                       dev_err(dev, "dmaengine_prep_slave_sg() fail\n");
-                       return;
+       /*
+        * in play case...
+        *
+        * src -> dst
+        *
+        * mem -> SSI
+        * mem -> SRC -> SSI
+        * mem -> SRC -> DVC -> SSI
+        */
+       mod[0] = NULL; /* for "mem" */
+       index = 1;
+       for (i = 1; i < MOD_MAX; i++) {
+               if (!src) {
+                       mod[i] = ssi;
+               } else if (!dvc) {
+                       mod[i] = src;
+                       src = NULL;
+               } else {
+                       if ((!is_play) && (this == src))
+                               this = dvc;
+
+                       mod[i] = (is_play) ? src : dvc;
+                       i++;
+                       mod[i] = (is_play) ? dvc : src;
+                       src = NULL;
+                       dvc = NULL;
                }
 
-               desc->callback          = rsnd_dma_complete;
-               desc->callback_param    = dma;
-
-               if (dmaengine_submit(desc) < 0) {
-                       dev_err(dev, "dmaengine_submit() fail\n");
-                       return;
-               }
+               if (mod[i] == this)
+                       index = i;
 
-               dma_async_issue_pending(dma->chan);
+               if (mod[i] == ssi)
+                       break;
        }
-}
 
-int rsnd_dma_available(struct rsnd_dma *dma)
-{
-       return !!dma->chan;
+       if (is_play) {
+               *mod_from = mod[index - 1];
+               *mod_to   = mod[index];
+       } else {
+               *mod_from = mod[index];
+               *mod_to   = mod[index - 1];
+       }
 }
 
 int rsnd_dma_init(struct rsnd_priv *priv, struct rsnd_dma *dma,
-                 int is_play, int id,
-                 int (*inquiry)(struct rsnd_dma *dma,
-                                 dma_addr_t *buf, int *len),
-                 int (*complete)(struct rsnd_dma *dma))
+                 int is_play, int id)
 {
        struct device *dev = rsnd_priv_to_dev(priv);
        struct dma_slave_config cfg;
+       struct rsnd_mod *mod_from;
+       struct rsnd_mod *mod_to;
+       char dma_name[DMA_NAME_SIZE];
        dma_cap_mask_t mask;
        int ret;
 
@@ -228,28 +331,33 @@ int rsnd_dma_init(struct rsnd_priv *priv, struct rsnd_dma *dma,
        dma_cap_zero(mask);
        dma_cap_set(DMA_SLAVE, mask);
 
+       rsnd_dma_of_path(dma, is_play, &mod_from, &mod_to);
+       rsnd_dma_of_name(mod_from, mod_to, dma_name);
+
+       cfg.slave_id    = id;
+       cfg.direction   = is_play ? DMA_MEM_TO_DEV : DMA_DEV_TO_MEM;
+       cfg.src_addr    = rsnd_gen_dma_addr(priv, mod_from, is_play, 1);
+       cfg.dst_addr    = rsnd_gen_dma_addr(priv, mod_to,   is_play, 0);
+       cfg.src_addr_width = DMA_SLAVE_BUSWIDTH_4_BYTES;
+       cfg.dst_addr_width = DMA_SLAVE_BUSWIDTH_4_BYTES;
+
+       dev_dbg(dev, "dma : %s %pad -> %pad\n",
+               dma_name, &cfg.src_addr, &cfg.dst_addr);
+
        dma->chan = dma_request_slave_channel_compat(mask, shdma_chan_filter,
                                                     (void *)id, dev,
-                                                    is_play ? "tx" : "rx");
+                                                    dma_name);
        if (!dma->chan) {
                dev_err(dev, "can't get dma channel\n");
                return -EIO;
        }
 
-       cfg.slave_id    = id;
-       cfg.dst_addr    = 0; /* use default addr when playback */
-       cfg.src_addr    = 0; /* use default addr when capture */
-       cfg.direction   = is_play ? DMA_MEM_TO_DEV : DMA_DEV_TO_MEM;
-
        ret = dmaengine_slave_config(dma->chan, &cfg);
        if (ret < 0)
                goto rsnd_dma_init_err;
 
-       dma->dir = is_play ? DMA_TO_DEVICE : DMA_FROM_DEVICE;
-       dma->priv = priv;
-       dma->inquiry = inquiry;
-       dma->complete = complete;
-       INIT_WORK(&dma->work, rsnd_dma_do_work);
+       dma->addr = is_play ? cfg.src_addr : cfg.dst_addr;
+       dma->dir = is_play ? DMA_MEM_TO_DEV : DMA_DEV_TO_MEM;
 
        return 0;
 
@@ -269,28 +377,70 @@ void  rsnd_dma_quit(struct rsnd_priv *priv,
 }
 
 /*
+ *     settting function
+ */
+u32 rsnd_get_adinr(struct rsnd_mod *mod)
+{
+       struct rsnd_priv *priv = rsnd_mod_to_priv(mod);
+       struct rsnd_dai_stream *io = rsnd_mod_to_io(mod);
+       struct snd_pcm_runtime *runtime = rsnd_io_to_runtime(io);
+       struct device *dev = rsnd_priv_to_dev(priv);
+       u32 adinr = runtime->channels;
+
+       switch (runtime->sample_bits) {
+       case 16:
+               adinr |= (8 << 16);
+               break;
+       case 32:
+               adinr |= (0 << 16);
+               break;
+       default:
+               dev_warn(dev, "not supported sample bits\n");
+               return 0;
+       }
+
+       return adinr;
+}
+
+/*
  *     rsnd_dai functions
  */
-#define rsnd_dai_call(rdai, io, fn)                    \
-({                                                     \
-       struct rsnd_mod *mod, *n;                       \
-       int ret = 0;                                    \
-       for_each_rsnd_mod(mod, n, io) {                 \
-               ret = rsnd_mod_call(mod, fn, rdai, io); \
-               if (ret < 0)                            \
-                       break;                          \
-       }                                               \
-       ret;                                            \
+#define __rsnd_mod_call(mod, func, rdai...)                    \
+({                                                             \
+       struct rsnd_priv *priv = rsnd_mod_to_priv(mod);         \
+       struct device *dev = rsnd_priv_to_dev(priv);            \
+       dev_dbg(dev, "%s [%d] %s\n",                            \
+               rsnd_mod_name(mod), rsnd_mod_id(mod), #func);   \
+       (mod)->ops->func(mod, rdai);                            \
+})
+
+#define rsnd_mod_call(mod, func, rdai...)      \
+       (!(mod) ? -ENODEV :                     \
+        !((mod)->ops->func) ? 0 :              \
+        __rsnd_mod_call(mod, func, rdai))
+
+#define rsnd_dai_call(fn, io, rdai...)                         \
+({                                                             \
+       struct rsnd_mod *mod;                                   \
+       int ret = 0, i;                                         \
+       for (i = 0; i < RSND_MOD_MAX; i++) {                    \
+               mod = (io)->mod[i];                             \
+               if (!mod)                                       \
+                       continue;                               \
+               ret = rsnd_mod_call(mod, fn, rdai);             \
+               if (ret < 0)                                    \
+                       break;                                  \
+       }                                                       \
+       ret;                                                    \
 })
 
-int rsnd_dai_connect(struct rsnd_dai *rdai,
-                    struct rsnd_mod *mod,
-                    struct rsnd_dai_stream *io)
+static int rsnd_dai_connect(struct rsnd_mod *mod,
+                           struct rsnd_dai_stream *io)
 {
        if (!mod)
                return -EIO;
 
-       if (!list_empty(&mod->list)) {
+       if (io->mod[mod->type]) {
                struct rsnd_priv *priv = rsnd_mod_to_priv(mod);
                struct device *dev = rsnd_priv_to_dev(priv);
 
@@ -300,14 +450,8 @@ int rsnd_dai_connect(struct rsnd_dai *rdai,
                return -EIO;
        }
 
-       list_add_tail(&mod->list, &io->head);
-
-       return 0;
-}
-
-int rsnd_dai_disconnect(struct rsnd_mod *mod)
-{
-       list_del_init(&mod->list);
+       io->mod[mod->type] = mod;
+       mod->io = io;
 
        return 0;
 }
@@ -316,7 +460,7 @@ int rsnd_dai_id(struct rsnd_priv *priv, struct rsnd_dai *rdai)
 {
        int id = rdai - priv->rdai;
 
-       if ((id < 0) || (id >= rsnd_dai_nr(priv)))
+       if ((id < 0) || (id >= rsnd_rdai_nr(priv)))
                return -EINVAL;
 
        return id;
@@ -324,7 +468,7 @@ int rsnd_dai_id(struct rsnd_priv *priv, struct rsnd_dai *rdai)
 
 struct rsnd_dai *rsnd_dai_get(struct rsnd_priv *priv, int id)
 {
-       if ((id < 0) || (id >= rsnd_dai_nr(priv)))
+       if ((id < 0) || (id >= rsnd_rdai_nr(priv)))
                return NULL;
 
        return priv->rdai + id;
@@ -382,10 +526,6 @@ static int rsnd_dai_stream_init(struct rsnd_dai_stream *io,
 {
        struct snd_pcm_runtime *runtime = substream->runtime;
 
-       if (!list_empty(&io->head))
-               return -EIO;
-
-       INIT_LIST_HEAD(&io->head);
        io->substream           = substream;
        io->byte_pos            = 0;
        io->period_pos          = 0;
@@ -421,10 +561,7 @@ static int rsnd_soc_dai_trigger(struct snd_pcm_substream *substream, int cmd,
        struct rsnd_priv *priv = snd_soc_dai_get_drvdata(dai);
        struct rsnd_dai *rdai = rsnd_dai_to_rdai(dai);
        struct rsnd_dai_stream *io = rsnd_rdai_to_io(rdai, substream);
-       struct rsnd_mod *mod = rsnd_ssi_mod_get_frm_dai(priv,
-                                               rsnd_dai_id(priv, rdai),
-                                               rsnd_dai_is_play(rdai, io));
-       int ssi_id = rsnd_mod_id(mod);
+       int ssi_id = rsnd_mod_id(rsnd_io_to_mod_ssi(io));
        int ret;
        unsigned long flags;
 
@@ -440,28 +577,20 @@ static int rsnd_soc_dai_trigger(struct snd_pcm_substream *substream, int cmd,
                if (ret < 0)
                        goto dai_trigger_end;
 
-               ret = rsnd_gen_path_init(priv, rdai, io);
-               if (ret < 0)
-                       goto dai_trigger_end;
-
-               ret = rsnd_dai_call(rdai, io, init);
+               ret = rsnd_dai_call(init, io, rdai);
                if (ret < 0)
                        goto dai_trigger_end;
 
-               ret = rsnd_dai_call(rdai, io, start);
+               ret = rsnd_dai_call(start, io, rdai);
                if (ret < 0)
                        goto dai_trigger_end;
                break;
        case SNDRV_PCM_TRIGGER_STOP:
-               ret = rsnd_dai_call(rdai, io, stop);
-               if (ret < 0)
-                       goto dai_trigger_end;
-
-               ret = rsnd_dai_call(rdai, io, quit);
+               ret = rsnd_dai_call(stop, io, rdai);
                if (ret < 0)
                        goto dai_trigger_end;
 
-               ret = rsnd_gen_path_exit(priv, rdai, io);
+               ret = rsnd_dai_call(quit, io, rdai);
                if (ret < 0)
                        goto dai_trigger_end;
 
@@ -486,49 +615,50 @@ static int rsnd_soc_dai_set_fmt(struct snd_soc_dai *dai, unsigned int fmt)
        /* set master/slave audio interface */
        switch (fmt & SND_SOC_DAIFMT_MASTER_MASK) {
        case SND_SOC_DAIFMT_CBM_CFM:
-               rdai->clk_master = 1;
+               rdai->clk_master = 0;
                break;
        case SND_SOC_DAIFMT_CBS_CFS:
-               rdai->clk_master = 0;
+               rdai->clk_master = 1; /* codec is slave, cpu is master */
                break;
        default:
                return -EINVAL;
        }
 
-       /* set clock inversion */
-       switch (fmt & SND_SOC_DAIFMT_INV_MASK) {
-       case SND_SOC_DAIFMT_NB_IF:
-               rdai->bit_clk_inv = 0;
-               rdai->frm_clk_inv = 1;
-               break;
-       case SND_SOC_DAIFMT_IB_NF:
-               rdai->bit_clk_inv = 1;
-               rdai->frm_clk_inv = 0;
-               break;
-       case SND_SOC_DAIFMT_IB_IF:
-               rdai->bit_clk_inv = 1;
-               rdai->frm_clk_inv = 1;
-               break;
-       case SND_SOC_DAIFMT_NB_NF:
-       default:
-               rdai->bit_clk_inv = 0;
-               rdai->frm_clk_inv = 0;
-               break;
-       }
-
        /* set format */
        switch (fmt & SND_SOC_DAIFMT_FORMAT_MASK) {
        case SND_SOC_DAIFMT_I2S:
                rdai->sys_delay = 0;
                rdai->data_alignment = 0;
+               rdai->frm_clk_inv = 0;
                break;
        case SND_SOC_DAIFMT_LEFT_J:
                rdai->sys_delay = 1;
                rdai->data_alignment = 0;
+               rdai->frm_clk_inv = 1;
                break;
        case SND_SOC_DAIFMT_RIGHT_J:
                rdai->sys_delay = 1;
                rdai->data_alignment = 1;
+               rdai->frm_clk_inv = 1;
+               break;
+       }
+
+       /* set clock inversion */
+       switch (fmt & SND_SOC_DAIFMT_INV_MASK) {
+       case SND_SOC_DAIFMT_NB_IF:
+               rdai->bit_clk_inv =  rdai->bit_clk_inv;
+               rdai->frm_clk_inv = !rdai->frm_clk_inv;
+               break;
+       case SND_SOC_DAIFMT_IB_NF:
+               rdai->bit_clk_inv = !rdai->bit_clk_inv;
+               rdai->frm_clk_inv =  rdai->frm_clk_inv;
+               break;
+       case SND_SOC_DAIFMT_IB_IF:
+               rdai->bit_clk_inv = !rdai->bit_clk_inv;
+               rdai->frm_clk_inv = !rdai->frm_clk_inv;
+               break;
+       case SND_SOC_DAIFMT_NB_NF:
+       default:
                break;
        }
 
@@ -540,26 +670,157 @@ static const struct snd_soc_dai_ops rsnd_soc_dai_ops = {
        .set_fmt        = rsnd_soc_dai_set_fmt,
 };
 
+#define rsnd_path_parse(priv, io, type)                                \
+({                                                             \
+       struct rsnd_mod *mod;                                   \
+       int ret = 0;                                            \
+       int id = -1;                                            \
+                                                               \
+       if (rsnd_is_enable_path(io, type)) {                    \
+               id = rsnd_info_id(priv, io, type);              \
+               if (id >= 0) {                                  \
+                       mod = rsnd_##type##_mod_get(priv, id);  \
+                       ret = rsnd_dai_connect(mod, io);        \
+               }                                               \
+       }                                                       \
+       ret;                                                    \
+})
+
+static int rsnd_path_init(struct rsnd_priv *priv,
+                         struct rsnd_dai *rdai,
+                         struct rsnd_dai_stream *io)
+{
+       int ret;
+
+       /*
+        * Gen1 is created by SRU/SSI, and this SRU is base module of
+        * Gen2's SCU/SSIU/SSI. (Gen2 SCU/SSIU came from SRU)
+        *
+        * Easy image is..
+        *      Gen1 SRU = Gen2 SCU + SSIU + etc
+        *
+        * Gen2 SCU path is very flexible, but, Gen1 SRU (SCU parts) is
+        * using fixed path.
+        */
+
+       /* SRC */
+       ret = rsnd_path_parse(priv, io, src);
+       if (ret < 0)
+               return ret;
+
+       /* SSI */
+       ret = rsnd_path_parse(priv, io, ssi);
+       if (ret < 0)
+               return ret;
+
+       /* DVC */
+       ret = rsnd_path_parse(priv, io, dvc);
+       if (ret < 0)
+               return ret;
+
+       return ret;
+}
+
+static void rsnd_of_parse_dai(struct platform_device *pdev,
+                             const struct rsnd_of_data *of_data,
+                             struct rsnd_priv *priv)
+{
+       struct device_node *dai_node,   *dai_np;
+       struct device_node *ssi_node,   *ssi_np;
+       struct device_node *src_node,   *src_np;
+       struct device_node *dvc_node,   *dvc_np;
+       struct device_node *playback, *capture;
+       struct rsnd_dai_platform_info *dai_info;
+       struct rcar_snd_info *info = rsnd_priv_to_info(priv);
+       struct device *dev = &pdev->dev;
+       int nr, i;
+       int dai_i, ssi_i, src_i, dvc_i;
+
+       if (!of_data)
+               return;
+
+       dai_node = of_get_child_by_name(dev->of_node, "rcar_sound,dai");
+       if (!dai_node)
+               return;
+
+       nr = of_get_child_count(dai_node);
+       if (!nr)
+               return;
+
+       dai_info = devm_kzalloc(dev,
+                               sizeof(struct rsnd_dai_platform_info) * nr,
+                               GFP_KERNEL);
+       if (!dai_info) {
+               dev_err(dev, "dai info allocation error\n");
+               return;
+       }
+
+       info->dai_info_nr       = nr;
+       info->dai_info          = dai_info;
+
+       ssi_node = of_get_child_by_name(dev->of_node, "rcar_sound,ssi");
+       src_node = of_get_child_by_name(dev->of_node, "rcar_sound,src");
+       dvc_node = of_get_child_by_name(dev->of_node, "rcar_sound,dvc");
+
+#define mod_parse(name)                                                        \
+if (name##_node) {                                                     \
+       struct rsnd_##name##_platform_info *name##_info;                \
+                                                                       \
+       name##_i = 0;                                                   \
+       for_each_child_of_node(name##_node, name##_np) {                \
+               name##_info = info->name##_info + name##_i;             \
+                                                                       \
+               if (name##_np == playback)                              \
+                       dai_info->playback.name = name##_info;          \
+               if (name##_np == capture)                               \
+                       dai_info->capture.name = name##_info;           \
+                                                                       \
+               name##_i++;                                             \
+       }                                                               \
+}
+
+       /*
+        * parse all dai
+        */
+       dai_i = 0;
+       for_each_child_of_node(dai_node, dai_np) {
+               dai_info = info->dai_info + dai_i;
+
+               for (i = 0;; i++) {
+
+                       playback = of_parse_phandle(dai_np, "playback", i);
+                       capture  = of_parse_phandle(dai_np, "capture", i);
+
+                       if (!playback && !capture)
+                               break;
+
+                       mod_parse(ssi);
+                       mod_parse(src);
+                       mod_parse(dvc);
+
+                       of_node_put(playback);
+                       of_node_put(capture);
+               }
+
+               dai_i++;
+       }
+}
+
 static int rsnd_dai_probe(struct platform_device *pdev,
-                         struct rcar_snd_info *info,
+                         const struct rsnd_of_data *of_data,
                          struct rsnd_priv *priv)
 {
        struct snd_soc_dai_driver *drv;
+       struct rcar_snd_info *info = rsnd_priv_to_info(priv);
        struct rsnd_dai *rdai;
-       struct rsnd_mod *pmod, *cmod;
+       struct rsnd_ssi_platform_info *pmod, *cmod;
        struct device *dev = rsnd_priv_to_dev(priv);
        int dai_nr;
        int i;
 
-       /* get max dai nr */
-       for (dai_nr = 0; dai_nr < 32; dai_nr++) {
-               pmod = rsnd_ssi_mod_get_frm_dai(priv, dai_nr, 1);
-               cmod = rsnd_ssi_mod_get_frm_dai(priv, dai_nr, 0);
-
-               if (!pmod && !cmod)
-                       break;
-       }
+       rsnd_of_parse_dai(pdev, of_data, priv);
 
+       dai_nr = info->dai_info_nr;
        if (!dai_nr) {
                dev_err(dev, "no dai\n");
                return -EIO;
@@ -572,17 +833,19 @@ static int rsnd_dai_probe(struct platform_device *pdev,
                return -ENOMEM;
        }
 
+       priv->rdai_nr   = dai_nr;
+       priv->daidrv    = drv;
+       priv->rdai      = rdai;
+
        for (i = 0; i < dai_nr; i++) {
+               rdai[i].info = &info->dai_info[i];
 
-               pmod = rsnd_ssi_mod_get_frm_dai(priv, i, 1);
-               cmod = rsnd_ssi_mod_get_frm_dai(priv, i, 0);
+               pmod = rdai[i].info->playback.ssi;
+               cmod = rdai[i].info->capture.ssi;
 
                /*
                 *      init rsnd_dai
                 */
-               INIT_LIST_HEAD(&rdai[i].playback.head);
-               INIT_LIST_HEAD(&rdai[i].capture.head);
-
                snprintf(rdai[i].name, RSND_DAI_NAME_SIZE, "rsnd-dai.%d", i);
 
                /*
@@ -595,12 +858,18 @@ static int rsnd_dai_probe(struct platform_device *pdev,
                        drv[i].playback.formats         = RSND_FMTS;
                        drv[i].playback.channels_min    = 2;
                        drv[i].playback.channels_max    = 2;
+
+                       rdai[i].playback.info = &info->dai_info[i].playback;
+                       rsnd_path_init(priv, &rdai[i], &rdai[i].playback);
                }
                if (cmod) {
                        drv[i].capture.rates            = RSND_RATES;
                        drv[i].capture.formats          = RSND_FMTS;
                        drv[i].capture.channels_min     = 2;
                        drv[i].capture.channels_max     = 2;
+
+                       rdai[i].capture.info = &info->dai_info[i].capture;
+                       rsnd_path_init(priv, &rdai[i], &rdai[i].capture);
                }
 
                dev_dbg(dev, "%s (%s/%s)\n", rdai[i].name,
@@ -608,18 +877,9 @@ static int rsnd_dai_probe(struct platform_device *pdev,
                        cmod ? "capture" : "  --   ");
        }
 
-       priv->dai_nr    = dai_nr;
-       priv->daidrv    = drv;
-       priv->rdai      = rdai;
-
        return 0;
 }
 
-static void rsnd_dai_remove(struct platform_device *pdev,
-                         struct rsnd_priv *priv)
-{
-}
-
 /*
  *             pcm ops
  */
@@ -683,6 +943,18 @@ static struct snd_pcm_ops rsnd_pcm_ops = {
 
 static int rsnd_pcm_new(struct snd_soc_pcm_runtime *rtd)
 {
+       struct snd_soc_dai *dai = rtd->cpu_dai;
+       struct rsnd_dai *rdai = rsnd_dai_to_rdai(dai);
+       int ret;
+
+       ret = rsnd_dai_call(pcm_new, &rdai->playback, rdai, rtd);
+       if (ret)
+               return ret;
+
+       ret = rsnd_dai_call(pcm_new, &rdai->capture, rdai, rtd);
+       if (ret)
+               return ret;
+
        return snd_pcm_lib_preallocate_pages_for_all(
                rtd->pcm,
                SNDRV_DMA_TYPE_DEV,
@@ -713,9 +985,31 @@ static int rsnd_probe(struct platform_device *pdev)
        struct rcar_snd_info *info;
        struct rsnd_priv *priv;
        struct device *dev = &pdev->dev;
-       int ret;
+       struct rsnd_dai *rdai;
+       const struct of_device_id *of_id = of_match_device(rsnd_of_match, dev);
+       const struct rsnd_of_data *of_data;
+       int (*probe_func[])(struct platform_device *pdev,
+                           const struct rsnd_of_data *of_data,
+                           struct rsnd_priv *priv) = {
+               rsnd_gen_probe,
+               rsnd_ssi_probe,
+               rsnd_src_probe,
+               rsnd_dvc_probe,
+               rsnd_adg_probe,
+               rsnd_dai_probe,
+       };
+       int ret, i;
+
+       info = NULL;
+       of_data = NULL;
+       if (of_id) {
+               info = devm_kzalloc(&pdev->dev,
+                                   sizeof(struct rcar_snd_info), GFP_KERNEL);
+               of_data = of_id->data;
+       } else {
+               info = pdev->dev.platform_data;
+       }
 
-       info = pdev->dev.platform_data;
        if (!info) {
                dev_err(dev, "driver needs R-Car sound information\n");
                return -ENODEV;
@@ -730,32 +1024,28 @@ static int rsnd_probe(struct platform_device *pdev)
                return -ENODEV;
        }
 
-       priv->dev       = dev;
+       priv->pdev      = pdev;
        priv->info      = info;
        spin_lock_init(&priv->lock);
 
        /*
         *      init each module
         */
-       ret = rsnd_gen_probe(pdev, info, priv);
-       if (ret < 0)
-               return ret;
-
-       ret = rsnd_scu_probe(pdev, info, priv);
-       if (ret < 0)
-               return ret;
-
-       ret = rsnd_adg_probe(pdev, info, priv);
-       if (ret < 0)
-               return ret;
+       for (i = 0; i < ARRAY_SIZE(probe_func); i++) {
+               ret = probe_func[i](pdev, of_data, priv);
+               if (ret)
+                       return ret;
+       }
 
-       ret = rsnd_ssi_probe(pdev, info, priv);
-       if (ret < 0)
-               return ret;
+       for_each_rsnd_dai(rdai, priv, i) {
+               ret = rsnd_dai_call(probe, &rdai->playback, rdai);
+               if (ret)
+                       goto exit_snd_probe;
 
-       ret = rsnd_dai_probe(pdev, info, priv);
-       if (ret < 0)
-               return ret;
+               ret = rsnd_dai_call(probe, &rdai->capture, rdai);
+               if (ret)
+                       goto exit_snd_probe;
+       }
 
        /*
         *      asoc register
@@ -767,7 +1057,7 @@ static int rsnd_probe(struct platform_device *pdev)
        }
 
        ret = snd_soc_register_component(dev, &rsnd_soc_component,
-                                        priv->daidrv, rsnd_dai_nr(priv));
+                                        priv->daidrv, rsnd_rdai_nr(priv));
        if (ret < 0) {
                dev_err(dev, "cannot snd dai register\n");
                goto exit_snd_soc;
@@ -782,6 +1072,11 @@ static int rsnd_probe(struct platform_device *pdev)
 
 exit_snd_soc:
        snd_soc_unregister_platform(dev);
+exit_snd_probe:
+       for_each_rsnd_dai(rdai, priv, i) {
+               rsnd_dai_call(remove, &rdai->playback, rdai);
+               rsnd_dai_call(remove, &rdai->capture, rdai);
+       }
 
        return ret;
 }
@@ -789,24 +1084,23 @@ exit_snd_soc:
 static int rsnd_remove(struct platform_device *pdev)
 {
        struct rsnd_priv *priv = dev_get_drvdata(&pdev->dev);
+       struct rsnd_dai *rdai;
+       int ret = 0, i;
 
        pm_runtime_disable(&pdev->dev);
 
-       /*
-        *      remove each module
-        */
-       rsnd_ssi_remove(pdev, priv);
-       rsnd_adg_remove(pdev, priv);
-       rsnd_scu_remove(pdev, priv);
-       rsnd_dai_remove(pdev, priv);
-       rsnd_gen_remove(pdev, priv);
+       for_each_rsnd_dai(rdai, priv, i) {
+               ret |= rsnd_dai_call(remove, &rdai->playback, rdai);
+               ret |= rsnd_dai_call(remove, &rdai->capture, rdai);
+       }
 
-       return 0;
+       return ret;
 }
 
 static struct platform_driver rsnd_driver = {
        .driver = {
                .name   = "rcar_sound",
+               .of_match_table = rsnd_of_match,
        },
        .probe          = rsnd_probe,
        .remove         = rsnd_remove,
diff --git a/sound/soc/sh/rcar/dvc.c b/sound/soc/sh/rcar/dvc.c
new file mode 100644 (file)
index 0000000..3f44393
--- /dev/null
@@ -0,0 +1,356 @@
+/*
+ * Renesas R-Car DVC support
+ *
+ * Copyright (C) 2014 Renesas Solutions Corp.
+ * Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ */
+#include "rsnd.h"
+
+#define RSND_DVC_NAME_SIZE     16
+#define RSND_DVC_VOLUME_MAX    100
+#define RSND_DVC_VOLUME_NUM    2
+
+#define DVC_NAME "dvc"
+
+struct rsnd_dvc {
+       struct rsnd_dvc_platform_info *info; /* rcar_snd.h */
+       struct rsnd_mod mod;
+       struct clk *clk;
+       u8 volume[RSND_DVC_VOLUME_NUM];
+       u8 mute[RSND_DVC_VOLUME_NUM];
+};
+
+#define rsnd_mod_to_dvc(_mod)  \
+       container_of((_mod), struct rsnd_dvc, mod)
+
+#define for_each_rsnd_dvc(pos, priv, i)                                \
+       for ((i) = 0;                                           \
+            ((i) < rsnd_dvc_nr(priv)) &&                       \
+            ((pos) = (struct rsnd_dvc *)(priv)->dvc + i);      \
+            i++)
+
+static void rsnd_dvc_volume_update(struct rsnd_mod *mod)
+{
+       struct rsnd_dvc *dvc = rsnd_mod_to_dvc(mod);
+       u32 max = (0x00800000 - 1);
+       u32 vol[RSND_DVC_VOLUME_NUM];
+       u32 mute = 0;
+       int i;
+
+       for (i = 0; i < RSND_DVC_VOLUME_NUM; i++) {
+               vol[i] = max / RSND_DVC_VOLUME_MAX * dvc->volume[i];
+               mute |= (!!dvc->mute[i]) << i;
+       }
+
+       rsnd_mod_write(mod, DVC_VOL0R, vol[0]);
+       rsnd_mod_write(mod, DVC_VOL1R, vol[1]);
+
+       rsnd_mod_write(mod, DVC_ZCMCR, mute);
+}
+
+static int rsnd_dvc_probe_gen2(struct rsnd_mod *mod,
+                              struct rsnd_dai *rdai)
+{
+       struct rsnd_priv *priv = rsnd_mod_to_priv(mod);
+       struct device *dev = rsnd_priv_to_dev(priv);
+
+       dev_dbg(dev, "%s (Gen2) is probed\n", rsnd_mod_name(mod));
+
+       return 0;
+}
+
+static int rsnd_dvc_init(struct rsnd_mod *dvc_mod,
+                        struct rsnd_dai *rdai)
+{
+       struct rsnd_dvc *dvc = rsnd_mod_to_dvc(dvc_mod);
+       struct rsnd_dai_stream *io = rsnd_mod_to_io(dvc_mod);
+       struct rsnd_priv *priv = rsnd_mod_to_priv(dvc_mod);
+       struct rsnd_mod *src_mod = rsnd_io_to_mod_src(io);
+       struct device *dev = rsnd_priv_to_dev(priv);
+       int dvc_id = rsnd_mod_id(dvc_mod);
+       int src_id = rsnd_mod_id(src_mod);
+       u32 route[] = {
+               [0] = 0x30000,
+               [1] = 0x30001,
+               [2] = 0x40000,
+               [3] = 0x10000,
+               [4] = 0x20000,
+               [5] = 0x40100
+       };
+
+       if (src_id >= ARRAY_SIZE(route)) {
+               dev_err(dev, "DVC%d isn't connected to SRC%d\n", dvc_id, src_id);
+               return -EINVAL;
+       }
+
+       clk_prepare_enable(dvc->clk);
+
+       /*
+        * fixme
+        * it doesn't support CTU/MIX
+        */
+       rsnd_mod_write(dvc_mod, CMD_ROUTE_SLCT, route[src_id]);
+
+       rsnd_mod_write(dvc_mod, DVC_SWRSR, 0);
+       rsnd_mod_write(dvc_mod, DVC_SWRSR, 1);
+
+       rsnd_mod_write(dvc_mod, DVC_DVUIR, 1);
+
+       rsnd_mod_write(dvc_mod, DVC_ADINR, rsnd_get_adinr(dvc_mod));
+
+       /*  enable Volume / Mute */
+       rsnd_mod_write(dvc_mod, DVC_DVUCR, 0x101);
+
+       /* ch0/ch1 Volume */
+       rsnd_dvc_volume_update(dvc_mod);
+
+       rsnd_mod_write(dvc_mod, DVC_DVUIR, 0);
+
+       rsnd_mod_write(dvc_mod, DVC_DVUER, 1);
+
+       rsnd_adg_set_cmd_timsel_gen2(rdai, dvc_mod, io);
+
+       return 0;
+}
+
+static int rsnd_dvc_quit(struct rsnd_mod *mod,
+                        struct rsnd_dai *rdai)
+{
+       struct rsnd_dvc *dvc = rsnd_mod_to_dvc(mod);
+
+       clk_disable_unprepare(dvc->clk);
+
+       return 0;
+}
+
+static int rsnd_dvc_start(struct rsnd_mod *mod,
+                         struct rsnd_dai *rdai)
+{
+       rsnd_mod_write(mod, CMD_CTRL, 0x10);
+
+       return 0;
+}
+
+static int rsnd_dvc_stop(struct rsnd_mod *mod,
+                        struct rsnd_dai *rdai)
+{
+       rsnd_mod_write(mod, CMD_CTRL, 0);
+
+       return 0;
+}
+
+static int rsnd_dvc_volume_info(struct snd_kcontrol *kctrl,
+                              struct snd_ctl_elem_info *uinfo)
+{
+       struct rsnd_mod *mod = snd_kcontrol_chip(kctrl);
+       struct rsnd_dvc *dvc = rsnd_mod_to_dvc(mod);
+       u8 *val = (u8 *)kctrl->private_value;
+
+       uinfo->count = RSND_DVC_VOLUME_NUM;
+       uinfo->value.integer.min = 0;
+
+       if (val == dvc->volume) {
+               uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER;
+               uinfo->value.integer.max = RSND_DVC_VOLUME_MAX;
+       } else {
+               uinfo->type = SNDRV_CTL_ELEM_TYPE_BOOLEAN;
+               uinfo->value.integer.max = 1;
+       }
+
+       return 0;
+}
+
+static int rsnd_dvc_volume_get(struct snd_kcontrol *kctrl,
+                             struct snd_ctl_elem_value *ucontrol)
+{
+       u8 *val = (u8 *)kctrl->private_value;
+       int i;
+
+       for (i = 0; i < RSND_DVC_VOLUME_NUM; i++)
+               ucontrol->value.integer.value[i] = val[i];
+
+       return 0;
+}
+
+static int rsnd_dvc_volume_put(struct snd_kcontrol *kctrl,
+                             struct snd_ctl_elem_value *ucontrol)
+{
+       struct rsnd_mod *mod = snd_kcontrol_chip(kctrl);
+       u8 *val = (u8 *)kctrl->private_value;
+       int i, change = 0;
+
+       for (i = 0; i < RSND_DVC_VOLUME_NUM; i++) {
+               change |= (ucontrol->value.integer.value[i] != val[i]);
+               val[i] = ucontrol->value.integer.value[i];
+       }
+
+       if (change)
+               rsnd_dvc_volume_update(mod);
+
+       return change;
+}
+
+static int __rsnd_dvc_pcm_new(struct rsnd_mod *mod,
+                             struct rsnd_dai *rdai,
+                             struct snd_soc_pcm_runtime *rtd,
+                             const unsigned char *name,
+                             u8 *private)
+{
+       struct snd_card *card = rtd->card->snd_card;
+       struct snd_kcontrol *kctrl;
+       struct snd_kcontrol_new knew = {
+               .iface          = SNDRV_CTL_ELEM_IFACE_MIXER,
+               .name           = name,
+               .info           = rsnd_dvc_volume_info,
+               .get            = rsnd_dvc_volume_get,
+               .put            = rsnd_dvc_volume_put,
+               .private_value  = (unsigned long)private,
+       };
+       int ret;
+
+       kctrl = snd_ctl_new1(&knew, mod);
+       if (!kctrl)
+               return -ENOMEM;
+
+       ret = snd_ctl_add(card, kctrl);
+       if (ret < 0)
+               return ret;
+
+       return 0;
+}
+
+static int rsnd_dvc_pcm_new(struct rsnd_mod *mod,
+                           struct rsnd_dai *rdai,
+                           struct snd_soc_pcm_runtime *rtd)
+{
+       struct rsnd_dai_stream *io = rsnd_mod_to_io(mod);
+       struct rsnd_dvc *dvc = rsnd_mod_to_dvc(mod);
+       int ret;
+
+       /* Volume */
+       ret = __rsnd_dvc_pcm_new(mod, rdai, rtd,
+                       rsnd_dai_is_play(rdai, io) ?
+                       "DVC Out Playback Volume" : "DVC In Capture Volume",
+                       dvc->volume);
+       if (ret < 0)
+               return ret;
+
+       /* Mute */
+       ret = __rsnd_dvc_pcm_new(mod, rdai, rtd,
+                       rsnd_dai_is_play(rdai, io) ?
+                       "DVC Out Mute Switch" : "DVC In Mute Switch",
+                       dvc->mute);
+       if (ret < 0)
+               return ret;
+
+       return 0;
+}
+
+static struct rsnd_mod_ops rsnd_dvc_ops = {
+       .name           = DVC_NAME,
+       .probe          = rsnd_dvc_probe_gen2,
+       .init           = rsnd_dvc_init,
+       .quit           = rsnd_dvc_quit,
+       .start          = rsnd_dvc_start,
+       .stop           = rsnd_dvc_stop,
+       .pcm_new        = rsnd_dvc_pcm_new,
+};
+
+struct rsnd_mod *rsnd_dvc_mod_get(struct rsnd_priv *priv, int id)
+{
+       if (WARN_ON(id < 0 || id >= rsnd_dvc_nr(priv)))
+               id = 0;
+
+       return &((struct rsnd_dvc *)(priv->dvc) + id)->mod;
+}
+
+static void rsnd_of_parse_dvc(struct platform_device *pdev,
+                             const struct rsnd_of_data *of_data,
+                             struct rsnd_priv *priv)
+{
+       struct device_node *node;
+       struct rsnd_dvc_platform_info *dvc_info;
+       struct rcar_snd_info *info = rsnd_priv_to_info(priv);
+       struct device *dev = &pdev->dev;
+       int nr;
+
+       if (!of_data)
+               return;
+
+       node = of_get_child_by_name(dev->of_node, "rcar_sound,dvc");
+       if (!node)
+               return;
+
+       nr = of_get_child_count(node);
+       if (!nr)
+               goto rsnd_of_parse_dvc_end;
+
+       dvc_info = devm_kzalloc(dev,
+                               sizeof(struct rsnd_dvc_platform_info) * nr,
+                               GFP_KERNEL);
+       if (!dvc_info) {
+               dev_err(dev, "dvc info allocation error\n");
+               goto rsnd_of_parse_dvc_end;
+       }
+
+       info->dvc_info          = dvc_info;
+       info->dvc_info_nr       = nr;
+
+rsnd_of_parse_dvc_end:
+       of_node_put(node);
+}
+
+int rsnd_dvc_probe(struct platform_device *pdev,
+                  const struct rsnd_of_data *of_data,
+                  struct rsnd_priv *priv)
+{
+       struct rcar_snd_info *info = rsnd_priv_to_info(priv);
+       struct device *dev = rsnd_priv_to_dev(priv);
+       struct rsnd_dvc *dvc;
+       struct clk *clk;
+       char name[RSND_DVC_NAME_SIZE];
+       int i, nr;
+
+       rsnd_of_parse_dvc(pdev, of_data, priv);
+
+       nr = info->dvc_info_nr;
+       if (!nr)
+               return 0;
+
+       /* This driver doesn't support Gen1 at this point */
+       if (rsnd_is_gen1(priv)) {
+               dev_warn(dev, "CMD is not supported on Gen1\n");
+               return -EINVAL;
+       }
+
+       dvc     = devm_kzalloc(dev, sizeof(*dvc) * nr, GFP_KERNEL);
+       if (!dvc) {
+               dev_err(dev, "CMD allocate failed\n");
+               return -ENOMEM;
+       }
+
+       priv->dvc_nr    = nr;
+       priv->dvc       = dvc;
+
+       for_each_rsnd_dvc(dvc, priv, i) {
+               snprintf(name, RSND_DVC_NAME_SIZE, "%s.%d",
+                        DVC_NAME, i);
+
+               clk = devm_clk_get(dev, name);
+               if (IS_ERR(clk))
+                       return PTR_ERR(clk);
+
+               dvc->info = &info->dvc_info[i];
+               dvc->clk  = clk;
+
+               rsnd_mod_init(priv, &dvc->mod, &rsnd_dvc_ops, RSND_MOD_DVC, i);
+
+               dev_dbg(dev, "CMD%d probed\n", i);
+       }
+
+       return 0;
+}
index add088b..f95e7ab 100644 (file)
@@ -15,63 +15,35 @@ struct rsnd_gen {
 
        struct rsnd_gen_ops *ops;
 
-       struct regmap *regmap;
+       struct regmap *regmap[RSND_BASE_MAX];
        struct regmap_field *regs[RSND_REG_MAX];
 };
 
 #define rsnd_priv_to_gen(p)    ((struct rsnd_gen *)(p)->gen)
 
-#define RSND_REG_SET(gen, id, reg_id, offset, _id_offset, _id_size)    \
-       [id] = {                                                        \
-               .reg = (unsigned int)gen->base[reg_id] + offset,        \
-               .lsb = 0,                                               \
-               .msb = 31,                                              \
-               .id_size = _id_size,                                    \
-               .id_offset = _id_offset,                                \
-       }
-
-/*
- *             basic function
- */
-static int rsnd_regmap_write32(void *context, const void *_data, size_t count)
-{
-       struct rsnd_priv *priv = context;
-       struct device *dev = rsnd_priv_to_dev(priv);
-       u32 *data = (u32 *)_data;
-       u32 val = data[1];
-       void __iomem *reg = (void *)data[0];
-
-       iowrite32(val, reg);
-
-       dev_dbg(dev, "w %p : %08x\n", reg, val);
-
-       return 0;
-}
-
-static int rsnd_regmap_read32(void *context,
-                             const void *_data, size_t reg_size,
-                             void *_val, size_t val_size)
-{
-       struct rsnd_priv *priv = context;
-       struct device *dev = rsnd_priv_to_dev(priv);
-       u32 *data = (u32 *)_data;
-       u32 *val = (u32 *)_val;
-       void __iomem *reg = (void *)data[0];
-
-       *val = ioread32(reg);
-
-       dev_dbg(dev, "r %p : %08x\n", reg, *val);
+struct rsnd_regmap_field_conf {
+       int idx;
+       unsigned int reg_offset;
+       unsigned int id_offset;
+};
 
-       return 0;
+#define RSND_REG_SET(id, offset, _id_offset)   \
+{                                              \
+       .idx = id,                              \
+       .reg_offset = offset,                   \
+       .id_offset = _id_offset,                \
 }
+/* single address mapping */
+#define RSND_GEN_S_REG(id, offset)     \
+       RSND_REG_SET(RSND_REG_##id, offset, 0)
 
-static struct regmap_bus rsnd_regmap_bus = {
-       .write                          = rsnd_regmap_write32,
-       .read                           = rsnd_regmap_read32,
-       .reg_format_endian_default      = REGMAP_ENDIAN_NATIVE,
-       .val_format_endian_default      = REGMAP_ENDIAN_NATIVE,
-};
+/* multi address mapping */
+#define RSND_GEN_M_REG(id, offset, _id_offset) \
+       RSND_REG_SET(RSND_REG_##id, offset, _id_offset)
 
+/*
+ *             basic function
+ */
 static int rsnd_is_accessible_reg(struct rsnd_priv *priv,
                                  struct rsnd_gen *gen, enum rsnd_reg reg)
 {
@@ -88,6 +60,7 @@ static int rsnd_is_accessible_reg(struct rsnd_priv *priv,
 u32 rsnd_read(struct rsnd_priv *priv,
              struct rsnd_mod *mod, enum rsnd_reg reg)
 {
+       struct device *dev = rsnd_priv_to_dev(priv);
        struct rsnd_gen *gen = rsnd_priv_to_gen(priv);
        u32 val;
 
@@ -96,6 +69,8 @@ u32 rsnd_read(struct rsnd_priv *priv,
 
        regmap_fields_read(gen->regs[reg], rsnd_mod_id(mod), &val);
 
+       dev_dbg(dev, "r %s - 0x%04d : %08x\n", rsnd_mod_name(mod), reg, val);
+
        return val;
 }
 
@@ -103,17 +78,21 @@ void rsnd_write(struct rsnd_priv *priv,
                struct rsnd_mod *mod,
                enum rsnd_reg reg, u32 data)
 {
+       struct device *dev = rsnd_priv_to_dev(priv);
        struct rsnd_gen *gen = rsnd_priv_to_gen(priv);
 
        if (!rsnd_is_accessible_reg(priv, gen, reg))
                return;
 
        regmap_fields_write(gen->regs[reg], rsnd_mod_id(mod), data);
+
+       dev_dbg(dev, "w %s - 0x%04d : %08x\n", rsnd_mod_name(mod), reg, data);
 }
 
 void rsnd_bset(struct rsnd_priv *priv, struct rsnd_mod *mod,
               enum rsnd_reg reg, u32 mask, u32 data)
 {
+       struct device *dev = rsnd_priv_to_dev(priv);
        struct rsnd_gen *gen = rsnd_priv_to_gen(priv);
 
        if (!rsnd_is_accessible_reg(priv, gen, reg))
@@ -121,176 +100,264 @@ void rsnd_bset(struct rsnd_priv *priv, struct rsnd_mod *mod,
 
        regmap_fields_update_bits(gen->regs[reg], rsnd_mod_id(mod),
                                  mask, data);
+
+       dev_dbg(dev, "b %s - 0x%04d : %08x/%08x\n",
+               rsnd_mod_name(mod), reg, data, mask);
 }
 
-static int rsnd_gen_regmap_init(struct rsnd_priv *priv,
-                               struct rsnd_gen  *gen,
-                               struct reg_field *regf)
+#define rsnd_gen_regmap_init(priv, id_size, reg_id, conf)              \
+       _rsnd_gen_regmap_init(priv, id_size, reg_id, conf, ARRAY_SIZE(conf))
+static int _rsnd_gen_regmap_init(struct rsnd_priv *priv,
+                                int id_size,
+                                int reg_id,
+                                struct rsnd_regmap_field_conf *conf,
+                                int conf_size)
 {
-       int i;
+       struct platform_device *pdev = rsnd_priv_to_pdev(priv);
+       struct rsnd_gen *gen = rsnd_priv_to_gen(priv);
        struct device *dev = rsnd_priv_to_dev(priv);
+       struct resource *res;
        struct regmap_config regc;
+       struct regmap_field *regs;
+       struct regmap *regmap;
+       struct reg_field regf;
+       void __iomem *base;
+       int i;
 
        memset(&regc, 0, sizeof(regc));
        regc.reg_bits = 32;
        regc.val_bits = 32;
+       regc.reg_stride = 4;
 
-       gen->regmap = devm_regmap_init(dev, &rsnd_regmap_bus, priv, &regc);
-       if (IS_ERR(gen->regmap)) {
-               dev_err(dev, "regmap error %ld\n", PTR_ERR(gen->regmap));
-               return PTR_ERR(gen->regmap);
-       }
+       res = platform_get_resource(pdev, IORESOURCE_MEM, reg_id);
+       if (!res)
+               return -ENODEV;
 
-       for (i = 0; i < RSND_REG_MAX; i++) {
-               gen->regs[i] = NULL;
-               if (!regf[i].reg)
-                       continue;
+       base = devm_ioremap_resource(dev, res);
+       if (IS_ERR(base))
+               return PTR_ERR(base);
 
-               gen->regs[i] = devm_regmap_field_alloc(dev, gen->regmap, regf[i]);
-               if (IS_ERR(gen->regs[i]))
-                       return PTR_ERR(gen->regs[i]);
+       regmap = devm_regmap_init_mmio(dev, base, &regc);
+       if (IS_ERR(regmap))
+               return PTR_ERR(regmap);
 
+       gen->base[reg_id] = base;
+       gen->regmap[reg_id] = regmap;
+
+       for (i = 0; i < conf_size; i++) {
+
+               regf.reg        = conf[i].reg_offset;
+               regf.id_offset  = conf[i].id_offset;
+               regf.lsb        = 0;
+               regf.msb        = 31;
+               regf.id_size    = id_size;
+
+               regs = devm_regmap_field_alloc(dev, regmap, regf);
+               if (IS_ERR(regs))
+                       return PTR_ERR(regs);
+
+               gen->regs[conf[i].idx] = regs;
        }
 
        return 0;
 }
 
-int rsnd_gen_path_init(struct rsnd_priv *priv,
-                      struct rsnd_dai *rdai,
-                      struct rsnd_dai_stream *io)
-{
-       struct rsnd_mod *mod;
-       int ret;
-       int id;
+/*
+ *     DMA read/write register offset
+ *
+ *     RSND_xxx_I_N    for Audio DMAC input
+ *     RSND_xxx_O_N    for Audio DMAC output
+ *     RSND_xxx_I_P    for Audio DMAC peri peri input
+ *     RSND_xxx_O_P    for Audio DMAC peri peri output
+ *
+ *     ex) R-Car H2 case
+ *           mod        / DMAC in    / DMAC out   / DMAC PP in / DMAC pp out
+ *     SSI : 0xec541000 / 0xec241008 / 0xec24100c
+ *     SSIU: 0xec541000 / 0xec100000 / 0xec100000 / 0xec400000 / 0xec400000
+ *     SCU : 0xec500000 / 0xec000000 / 0xec004000 / 0xec300000 / 0xec304000
+ *     CMD : 0xec500000 /            / 0xec008000                0xec308000
+ */
+#define RDMA_SSI_I_N(addr, i)  (addr ##_reg - 0x00300000 + (0x40 * i) + 0x8)
+#define RDMA_SSI_O_N(addr, i)  (addr ##_reg - 0x00300000 + (0x40 * i) + 0xc)
 
-       /*
-        * Gen1 is created by SRU/SSI, and this SRU is base module of
-        * Gen2's SCU/SSIU/SSI. (Gen2 SCU/SSIU came from SRU)
-        *
-        * Easy image is..
-        *      Gen1 SRU = Gen2 SCU + SSIU + etc
-        *
-        * Gen2 SCU path is very flexible, but, Gen1 SRU (SCU parts) is
-        * using fixed path.
-        *
-        * Then, SSI id = SCU id here
-        */
+#define RDMA_SSIU_I_N(addr, i) (addr ##_reg - 0x00441000 + (0x1000 * i))
+#define RDMA_SSIU_O_N(addr, i) (addr ##_reg - 0x00441000 + (0x1000 * i))
 
-       /* get SSI's ID */
-       mod = rsnd_ssi_mod_get_frm_dai(priv,
-                                      rsnd_dai_id(priv, rdai),
-                                      rsnd_dai_is_play(rdai, io));
-       id = rsnd_mod_id(mod);
+#define RDMA_SSIU_I_P(addr, i) (addr ##_reg - 0x00141000 + (0x1000 * i))
+#define RDMA_SSIU_O_P(addr, i) (addr ##_reg - 0x00141000 + (0x1000 * i))
 
-       /* SSI */
-       mod = rsnd_ssi_mod_get(priv, id);
-       ret = rsnd_dai_connect(rdai, mod, io);
-       if (ret < 0)
-               return ret;
+#define RDMA_SRC_I_N(addr, i)  (addr ##_reg - 0x00500000 + (0x400 * i))
+#define RDMA_SRC_O_N(addr, i)  (addr ##_reg - 0x004fc000 + (0x400 * i))
 
-       /* SCU */
-       mod = rsnd_scu_mod_get(priv, id);
-       ret = rsnd_dai_connect(rdai, mod, io);
+#define RDMA_SRC_I_P(addr, i)  (addr ##_reg - 0x00200000 + (0x400 * i))
+#define RDMA_SRC_O_P(addr, i)  (addr ##_reg - 0x001fc000 + (0x400 * i))
 
-       return ret;
-}
+#define RDMA_CMD_O_N(addr, i)  (addr ##_reg - 0x004f8000 + (0x400 * i))
+#define RDMA_CMD_O_P(addr, i)  (addr ##_reg - 0x001f8000 + (0x400 * i))
 
-int rsnd_gen_path_exit(struct rsnd_priv *priv,
-                      struct rsnd_dai *rdai,
-                      struct rsnd_dai_stream *io)
+static dma_addr_t
+rsnd_gen2_dma_addr(struct rsnd_priv *priv,
+                  struct rsnd_mod *mod,
+                  int is_play, int is_from)
 {
-       struct rsnd_mod *mod, *n;
-       int ret = 0;
+       struct platform_device *pdev = rsnd_priv_to_pdev(priv);
+       struct device *dev = rsnd_priv_to_dev(priv);
+       struct rsnd_dai_stream *io = rsnd_mod_to_io(mod);
+       dma_addr_t ssi_reg = platform_get_resource(pdev,
+                               IORESOURCE_MEM, RSND_GEN2_SSI)->start;
+       dma_addr_t src_reg = platform_get_resource(pdev,
+                               IORESOURCE_MEM, RSND_GEN2_SCU)->start;
+       int is_ssi = !!(rsnd_io_to_mod_ssi(io) == mod);
+       int use_src = !!rsnd_io_to_mod_src(io);
+       int use_dvc = !!rsnd_io_to_mod_dvc(io);
+       int id = rsnd_mod_id(mod);
+       struct dma_addr {
+               dma_addr_t out_addr;
+               dma_addr_t in_addr;
+       } dma_addrs[3][2][3] = {
+               /* SRC */
+               {{{ 0,                          0 },
+               /* Capture */
+                 { RDMA_SRC_O_N(src, id),      RDMA_SRC_I_P(src, id) },
+                 { RDMA_CMD_O_N(src, id),      RDMA_SRC_I_P(src, id) } },
+                /* Playback */
+                {{ 0,                          0, },
+                 { RDMA_SRC_O_P(src, id),      RDMA_SRC_I_N(src, id) },
+                 { RDMA_CMD_O_P(src, id),      RDMA_SRC_I_N(src, id) } }
+               },
+               /* SSI */
+               /* Capture */
+               {{{ RDMA_SSI_O_N(ssi, id),      0 },
+                 { RDMA_SSIU_O_P(ssi, id),     0 },
+                 { RDMA_SSIU_O_P(ssi, id),     0 } },
+                /* Playback */
+                {{ 0,                          RDMA_SSI_I_N(ssi, id) },
+                 { 0,                          RDMA_SSIU_I_P(ssi, id) },
+                 { 0,                          RDMA_SSIU_I_P(ssi, id) } }
+               },
+               /* SSIU */
+               /* Capture */
+               {{{ RDMA_SSIU_O_N(ssi, id),     0 },
+                 { RDMA_SSIU_O_P(ssi, id),     0 },
+                 { RDMA_SSIU_O_P(ssi, id),     0 } },
+                /* Playback */
+                {{ 0,                          RDMA_SSIU_I_N(ssi, id) },
+                 { 0,                          RDMA_SSIU_I_P(ssi, id) },
+                 { 0,                          RDMA_SSIU_I_P(ssi, id) } } },
+       };
+
+       /* it shouldn't happen */
+       if (use_dvc && !use_src)
+               dev_err(dev, "DVC is selected without SRC\n");
+
+       /* use SSIU or SSI ? */
+       if (is_ssi && (0 == strcmp(rsnd_mod_dma_name(mod), "ssiu")))
+               is_ssi++;
 
+       return (is_from) ?
+               dma_addrs[is_ssi][is_play][use_src + use_dvc].out_addr :
+               dma_addrs[is_ssi][is_play][use_src + use_dvc].in_addr;
+}
+
+dma_addr_t rsnd_gen_dma_addr(struct rsnd_priv *priv,
+                            struct rsnd_mod *mod,
+                            int is_play, int is_from)
+{
        /*
-        * remove all mod from rdai
+        * gen1 uses default DMA addr
         */
-       for_each_rsnd_mod(mod, n, io)
-               ret |= rsnd_dai_disconnect(mod);
+       if (rsnd_is_gen1(priv))
+               return 0;
 
-       return ret;
+       if (!mod)
+               return 0;
+
+       return rsnd_gen2_dma_addr(priv, mod, is_play, is_from);
 }
 
 /*
  *             Gen2
  */
-
-/* single address mapping */
-#define RSND_GEN2_S_REG(gen, reg, id, offset)                          \
-       RSND_REG_SET(gen, RSND_REG_##id, RSND_GEN2_##reg, offset, 0, 10)
-
-/* multi address mapping */
-#define RSND_GEN2_M_REG(gen, reg, id, offset, _id_offset)              \
-       RSND_REG_SET(gen, RSND_REG_##id, RSND_GEN2_##reg, offset, _id_offset, 10)
-
-static int rsnd_gen2_regmap_init(struct rsnd_priv *priv, struct rsnd_gen *gen)
-{
-       struct reg_field regf[RSND_REG_MAX] = {
-               RSND_GEN2_S_REG(gen, SSIU,      SSI_MODE0,      0x800),
-               RSND_GEN2_S_REG(gen, SSIU,      SSI_MODE1,      0x804),
-               /* FIXME: it needs SSI_MODE2/3 in the future */
-               RSND_GEN2_M_REG(gen, SSIU,      INT_ENABLE,     0x18,   0x80),
-
-               RSND_GEN2_S_REG(gen, ADG,       BRRA,           0x00),
-               RSND_GEN2_S_REG(gen, ADG,       BRRB,           0x04),
-               RSND_GEN2_S_REG(gen, ADG,       SSICKR,         0x08),
-               RSND_GEN2_S_REG(gen, ADG,       AUDIO_CLK_SEL0, 0x0c),
-               RSND_GEN2_S_REG(gen, ADG,       AUDIO_CLK_SEL1, 0x10),
-               RSND_GEN2_S_REG(gen, ADG,       AUDIO_CLK_SEL2, 0x14),
-
-               RSND_GEN2_M_REG(gen, SSI,       SSICR,          0x00,   0x40),
-               RSND_GEN2_M_REG(gen, SSI,       SSISR,          0x04,   0x40),
-               RSND_GEN2_M_REG(gen, SSI,       SSITDR,         0x08,   0x40),
-               RSND_GEN2_M_REG(gen, SSI,       SSIRDR,         0x0c,   0x40),
-               RSND_GEN2_M_REG(gen, SSI,       SSIWSR,         0x20,   0x40),
-       };
-
-       return rsnd_gen_regmap_init(priv, gen, regf);
-}
-
 static int rsnd_gen2_probe(struct platform_device *pdev,
-                          struct rcar_snd_info *info,
                           struct rsnd_priv *priv)
 {
        struct device *dev = rsnd_priv_to_dev(priv);
-       struct rsnd_gen *gen = rsnd_priv_to_gen(priv);
-       struct resource *scu_res;
-       struct resource *adg_res;
-       struct resource *ssiu_res;
-       struct resource *ssi_res;
-       int ret;
-
-       /*
-        * map address
-        */
-       scu_res  = platform_get_resource(pdev, IORESOURCE_MEM, RSND_GEN2_SCU);
-       adg_res  = platform_get_resource(pdev, IORESOURCE_MEM, RSND_GEN2_ADG);
-       ssiu_res = platform_get_resource(pdev, IORESOURCE_MEM, RSND_GEN2_SSIU);
-       ssi_res  = platform_get_resource(pdev, IORESOURCE_MEM, RSND_GEN2_SSI);
-
-       gen->base[RSND_GEN2_SCU]  = devm_ioremap_resource(dev, scu_res);
-       gen->base[RSND_GEN2_ADG]  = devm_ioremap_resource(dev, adg_res);
-       gen->base[RSND_GEN2_SSIU] = devm_ioremap_resource(dev, ssiu_res);
-       gen->base[RSND_GEN2_SSI]  = devm_ioremap_resource(dev, ssi_res);
-       if (IS_ERR(gen->base[RSND_GEN2_SCU])  ||
-           IS_ERR(gen->base[RSND_GEN2_ADG])  ||
-           IS_ERR(gen->base[RSND_GEN2_SSIU]) ||
-           IS_ERR(gen->base[RSND_GEN2_SSI]))
-               return -ENODEV;
-
-       ret = rsnd_gen2_regmap_init(priv, gen);
-       if (ret < 0)
-               return ret;
-
-       dev_dbg(dev, "Gen2 device probed\n");
-       dev_dbg(dev, "SRU  : %08x => %p\n", scu_res->start,
-               gen->base[RSND_GEN2_SCU]);
-       dev_dbg(dev, "ADG  : %08x => %p\n", adg_res->start,
-               gen->base[RSND_GEN2_ADG]);
-       dev_dbg(dev, "SSIU : %08x => %p\n", ssiu_res->start,
-               gen->base[RSND_GEN2_SSIU]);
-       dev_dbg(dev, "SSI  : %08x => %p\n", ssi_res->start,
-               gen->base[RSND_GEN2_SSI]);
+       struct rsnd_regmap_field_conf conf_ssiu[] = {
+               RSND_GEN_S_REG(SSI_MODE0,       0x800),
+               RSND_GEN_S_REG(SSI_MODE1,       0x804),
+               /* FIXME: it needs SSI_MODE2/3 in the future */
+               RSND_GEN_M_REG(SSI_BUSIF_MODE,  0x0,    0x80),
+               RSND_GEN_M_REG(SSI_BUSIF_ADINR, 0x4,    0x80),
+               RSND_GEN_M_REG(BUSIF_DALIGN,    0x8,    0x80),
+               RSND_GEN_M_REG(SSI_CTRL,        0x10,   0x80),
+               RSND_GEN_M_REG(INT_ENABLE,      0x18,   0x80),
+       };
+       struct rsnd_regmap_field_conf conf_scu[] = {
+               RSND_GEN_M_REG(SRC_BUSIF_MODE,  0x0,    0x20),
+               RSND_GEN_M_REG(SRC_ROUTE_MODE0, 0xc,    0x20),
+               RSND_GEN_M_REG(SRC_CTRL,        0x10,   0x20),
+               RSND_GEN_M_REG(CMD_ROUTE_SLCT,  0x18c,  0x20),
+               RSND_GEN_M_REG(CMD_CTRL,        0x190,  0x20),
+               RSND_GEN_M_REG(SRC_SWRSR,       0x200,  0x40),
+               RSND_GEN_M_REG(SRC_SRCIR,       0x204,  0x40),
+               RSND_GEN_M_REG(SRC_ADINR,       0x214,  0x40),
+               RSND_GEN_M_REG(SRC_IFSCR,       0x21c,  0x40),
+               RSND_GEN_M_REG(SRC_IFSVR,       0x220,  0x40),
+               RSND_GEN_M_REG(SRC_SRCCR,       0x224,  0x40),
+               RSND_GEN_M_REG(SRC_BSDSR,       0x22c,  0x40),
+               RSND_GEN_M_REG(SRC_BSISR,       0x238,  0x40),
+               RSND_GEN_M_REG(DVC_SWRSR,       0xe00,  0x100),
+               RSND_GEN_M_REG(DVC_DVUIR,       0xe04,  0x100),
+               RSND_GEN_M_REG(DVC_ADINR,       0xe08,  0x100),
+               RSND_GEN_M_REG(DVC_DVUCR,       0xe10,  0x100),
+               RSND_GEN_M_REG(DVC_ZCMCR,       0xe14,  0x100),
+               RSND_GEN_M_REG(DVC_VOL0R,       0xe28,  0x100),
+               RSND_GEN_M_REG(DVC_VOL1R,       0xe2c,  0x100),
+               RSND_GEN_M_REG(DVC_DVUER,       0xe48,  0x100),
+       };
+       struct rsnd_regmap_field_conf conf_adg[] = {
+               RSND_GEN_S_REG(BRRA,            0x00),
+               RSND_GEN_S_REG(BRRB,            0x04),
+               RSND_GEN_S_REG(SSICKR,          0x08),
+               RSND_GEN_S_REG(AUDIO_CLK_SEL0,  0x0c),
+               RSND_GEN_S_REG(AUDIO_CLK_SEL1,  0x10),
+               RSND_GEN_S_REG(AUDIO_CLK_SEL2,  0x14),
+               RSND_GEN_S_REG(DIV_EN,          0x30),
+               RSND_GEN_S_REG(SRCIN_TIMSEL0,   0x34),
+               RSND_GEN_S_REG(SRCIN_TIMSEL1,   0x38),
+               RSND_GEN_S_REG(SRCIN_TIMSEL2,   0x3c),
+               RSND_GEN_S_REG(SRCIN_TIMSEL3,   0x40),
+               RSND_GEN_S_REG(SRCIN_TIMSEL4,   0x44),
+               RSND_GEN_S_REG(SRCOUT_TIMSEL0,  0x48),
+               RSND_GEN_S_REG(SRCOUT_TIMSEL1,  0x4c),
+               RSND_GEN_S_REG(SRCOUT_TIMSEL2,  0x50),
+               RSND_GEN_S_REG(SRCOUT_TIMSEL3,  0x54),
+               RSND_GEN_S_REG(SRCOUT_TIMSEL4,  0x58),
+               RSND_GEN_S_REG(CMDOUT_TIMSEL,   0x5c),
+       };
+       struct rsnd_regmap_field_conf conf_ssi[] = {
+               RSND_GEN_M_REG(SSICR,           0x00,   0x40),
+               RSND_GEN_M_REG(SSISR,           0x04,   0x40),
+               RSND_GEN_M_REG(SSITDR,          0x08,   0x40),
+               RSND_GEN_M_REG(SSIRDR,          0x0c,   0x40),
+               RSND_GEN_M_REG(SSIWSR,          0x20,   0x40),
+       };
+       int ret_ssiu;
+       int ret_scu;
+       int ret_adg;
+       int ret_ssi;
+
+       ret_ssiu = rsnd_gen_regmap_init(priv, 10, RSND_GEN2_SSIU, conf_ssiu);
+       ret_scu  = rsnd_gen_regmap_init(priv, 10, RSND_GEN2_SCU,  conf_scu);
+       ret_adg  = rsnd_gen_regmap_init(priv, 10, RSND_GEN2_ADG,  conf_adg);
+       ret_ssi  = rsnd_gen_regmap_init(priv, 10, RSND_GEN2_SSI,  conf_ssi);
+       if (ret_ssiu < 0 ||
+           ret_scu  < 0 ||
+           ret_adg  < 0 ||
+           ret_ssi  < 0)
+               return ret_ssiu | ret_scu | ret_adg | ret_ssi;
+
+       dev_dbg(dev, "Gen2 is probed\n");
 
        return 0;
 }
@@ -299,106 +366,87 @@ static int rsnd_gen2_probe(struct platform_device *pdev,
  *             Gen1
  */
 
-/* single address mapping */
-#define RSND_GEN1_S_REG(gen, reg, id, offset)  \
-       RSND_REG_SET(gen, RSND_REG_##id, RSND_GEN1_##reg, offset, 0, 9)
-
-/* multi address mapping */
-#define RSND_GEN1_M_REG(gen, reg, id, offset, _id_offset)      \
-       RSND_REG_SET(gen, RSND_REG_##id, RSND_GEN1_##reg, offset, _id_offset, 9)
-
-static int rsnd_gen1_regmap_init(struct rsnd_priv *priv, struct rsnd_gen *gen)
-{
-       struct reg_field regf[RSND_REG_MAX] = {
-               RSND_GEN1_S_REG(gen, SRU,       SRC_ROUTE_SEL,  0x00),
-               RSND_GEN1_S_REG(gen, SRU,       SRC_TMG_SEL0,   0x08),
-               RSND_GEN1_S_REG(gen, SRU,       SRC_TMG_SEL1,   0x0c),
-               RSND_GEN1_S_REG(gen, SRU,       SRC_TMG_SEL2,   0x10),
-               RSND_GEN1_S_REG(gen, SRU,       SRC_ROUTE_CTRL, 0xc0),
-               RSND_GEN1_S_REG(gen, SRU,       SSI_MODE0,      0xD0),
-               RSND_GEN1_S_REG(gen, SRU,       SSI_MODE1,      0xD4),
-               RSND_GEN1_M_REG(gen, SRU,       BUSIF_MODE,     0x20,   0x4),
-               RSND_GEN1_M_REG(gen, SRU,       SRC_ROUTE_MODE0,0x50,   0x8),
-               RSND_GEN1_M_REG(gen, SRU,       SRC_SWRSR,      0x200,  0x40),
-               RSND_GEN1_M_REG(gen, SRU,       SRC_SRCIR,      0x204,  0x40),
-               RSND_GEN1_M_REG(gen, SRU,       SRC_ADINR,      0x214,  0x40),
-               RSND_GEN1_M_REG(gen, SRU,       SRC_IFSCR,      0x21c,  0x40),
-               RSND_GEN1_M_REG(gen, SRU,       SRC_IFSVR,      0x220,  0x40),
-               RSND_GEN1_M_REG(gen, SRU,       SRC_SRCCR,      0x224,  0x40),
-               RSND_GEN1_M_REG(gen, SRU,       SRC_MNFSR,      0x228,  0x40),
-
-               RSND_GEN1_S_REG(gen, ADG,       BRRA,           0x00),
-               RSND_GEN1_S_REG(gen, ADG,       BRRB,           0x04),
-               RSND_GEN1_S_REG(gen, ADG,       SSICKR,         0x08),
-               RSND_GEN1_S_REG(gen, ADG,       AUDIO_CLK_SEL0, 0x0c),
-               RSND_GEN1_S_REG(gen, ADG,       AUDIO_CLK_SEL1, 0x10),
-               RSND_GEN1_S_REG(gen, ADG,       AUDIO_CLK_SEL3, 0x18),
-               RSND_GEN1_S_REG(gen, ADG,       AUDIO_CLK_SEL4, 0x1c),
-               RSND_GEN1_S_REG(gen, ADG,       AUDIO_CLK_SEL5, 0x20),
-
-               RSND_GEN1_M_REG(gen, SSI,       SSICR,          0x00,   0x40),
-               RSND_GEN1_M_REG(gen, SSI,       SSISR,          0x04,   0x40),
-               RSND_GEN1_M_REG(gen, SSI,       SSITDR,         0x08,   0x40),
-               RSND_GEN1_M_REG(gen, SSI,       SSIRDR,         0x0c,   0x40),
-               RSND_GEN1_M_REG(gen, SSI,       SSIWSR,         0x20,   0x40),
-       };
-
-       return rsnd_gen_regmap_init(priv, gen, regf);
-}
-
 static int rsnd_gen1_probe(struct platform_device *pdev,
-                          struct rcar_snd_info *info,
                           struct rsnd_priv *priv)
 {
        struct device *dev = rsnd_priv_to_dev(priv);
-       struct rsnd_gen *gen = rsnd_priv_to_gen(priv);
-       struct resource *sru_res;
-       struct resource *adg_res;
-       struct resource *ssi_res;
-       int ret;
-
-       /*
-        * map address
-        */
-       sru_res = platform_get_resource(pdev, IORESOURCE_MEM, RSND_GEN1_SRU);
-       adg_res = platform_get_resource(pdev, IORESOURCE_MEM, RSND_GEN1_ADG);
-       ssi_res = platform_get_resource(pdev, IORESOURCE_MEM, RSND_GEN1_SSI);
-
-       gen->base[RSND_GEN1_SRU] = devm_ioremap_resource(dev, sru_res);
-       gen->base[RSND_GEN1_ADG] = devm_ioremap_resource(dev, adg_res);
-       gen->base[RSND_GEN1_SSI] = devm_ioremap_resource(dev, ssi_res);
-       if (IS_ERR(gen->base[RSND_GEN1_SRU]) ||
-           IS_ERR(gen->base[RSND_GEN1_ADG]) ||
-           IS_ERR(gen->base[RSND_GEN1_SSI]))
-               return -ENODEV;
+       struct rsnd_regmap_field_conf conf_sru[] = {
+               RSND_GEN_S_REG(SRC_ROUTE_SEL,   0x00),
+               RSND_GEN_S_REG(SRC_TMG_SEL0,    0x08),
+               RSND_GEN_S_REG(SRC_TMG_SEL1,    0x0c),
+               RSND_GEN_S_REG(SRC_TMG_SEL2,    0x10),
+               RSND_GEN_S_REG(SRC_ROUTE_CTRL,  0xc0),
+               RSND_GEN_S_REG(SSI_MODE0,       0xD0),
+               RSND_GEN_S_REG(SSI_MODE1,       0xD4),
+               RSND_GEN_M_REG(SRC_BUSIF_MODE,  0x20,   0x4),
+               RSND_GEN_M_REG(SRC_ROUTE_MODE0, 0x50,   0x8),
+               RSND_GEN_M_REG(SRC_SWRSR,       0x200,  0x40),
+               RSND_GEN_M_REG(SRC_SRCIR,       0x204,  0x40),
+               RSND_GEN_M_REG(SRC_ADINR,       0x214,  0x40),
+               RSND_GEN_M_REG(SRC_IFSCR,       0x21c,  0x40),
+               RSND_GEN_M_REG(SRC_IFSVR,       0x220,  0x40),
+               RSND_GEN_M_REG(SRC_SRCCR,       0x224,  0x40),
+               RSND_GEN_M_REG(SRC_MNFSR,       0x228,  0x40),
+       };
+       struct rsnd_regmap_field_conf conf_adg[] = {
+               RSND_GEN_S_REG(BRRA,            0x00),
+               RSND_GEN_S_REG(BRRB,            0x04),
+               RSND_GEN_S_REG(SSICKR,          0x08),
+               RSND_GEN_S_REG(AUDIO_CLK_SEL0,  0x0c),
+               RSND_GEN_S_REG(AUDIO_CLK_SEL1,  0x10),
+               RSND_GEN_S_REG(AUDIO_CLK_SEL3,  0x18),
+               RSND_GEN_S_REG(AUDIO_CLK_SEL4,  0x1c),
+               RSND_GEN_S_REG(AUDIO_CLK_SEL5,  0x20),
+       };
+       struct rsnd_regmap_field_conf conf_ssi[] = {
+               RSND_GEN_M_REG(SSICR,           0x00,   0x40),
+               RSND_GEN_M_REG(SSISR,           0x04,   0x40),
+               RSND_GEN_M_REG(SSITDR,          0x08,   0x40),
+               RSND_GEN_M_REG(SSIRDR,          0x0c,   0x40),
+               RSND_GEN_M_REG(SSIWSR,          0x20,   0x40),
+       };
+       int ret_sru;
+       int ret_adg;
+       int ret_ssi;
 
-       ret = rsnd_gen1_regmap_init(priv, gen);
-       if (ret < 0)
-               return ret;
+       ret_sru  = rsnd_gen_regmap_init(priv, 9, RSND_GEN1_SRU,  conf_sru);
+       ret_adg  = rsnd_gen_regmap_init(priv, 9, RSND_GEN1_ADG,  conf_adg);
+       ret_ssi  = rsnd_gen_regmap_init(priv, 9, RSND_GEN1_SSI,  conf_ssi);
+       if (ret_sru  < 0 ||
+           ret_adg  < 0 ||
+           ret_ssi  < 0)
+               return ret_sru | ret_adg | ret_ssi;
 
-       dev_dbg(dev, "Gen1 device probed\n");
-       dev_dbg(dev, "SRU : %08x => %p\n",      sru_res->start,
-                                               gen->base[RSND_GEN1_SRU]);
-       dev_dbg(dev, "ADG : %08x => %p\n",      adg_res->start,
-                                               gen->base[RSND_GEN1_ADG]);
-       dev_dbg(dev, "SSI : %08x => %p\n",      ssi_res->start,
-                                               gen->base[RSND_GEN1_SSI]);
+       dev_dbg(dev, "Gen1 is probed\n");
 
        return 0;
-
 }
 
 /*
  *             Gen
  */
+static void rsnd_of_parse_gen(struct platform_device *pdev,
+                             const struct rsnd_of_data *of_data,
+                             struct rsnd_priv *priv)
+{
+       struct rcar_snd_info *info = priv->info;
+
+       if (!of_data)
+               return;
+
+       info->flags = of_data->flags;
+}
+
 int rsnd_gen_probe(struct platform_device *pdev,
-                  struct rcar_snd_info *info,
+                  const struct rsnd_of_data *of_data,
                   struct rsnd_priv *priv)
 {
        struct device *dev = rsnd_priv_to_dev(priv);
        struct rsnd_gen *gen;
        int ret;
 
+       rsnd_of_parse_gen(pdev, of_data, priv);
+
        gen = devm_kzalloc(dev, sizeof(*gen), GFP_KERNEL);
        if (!gen) {
                dev_err(dev, "GEN allocate failed\n");
@@ -409,17 +457,12 @@ int rsnd_gen_probe(struct platform_device *pdev,
 
        ret = -ENODEV;
        if (rsnd_is_gen1(priv))
-               ret = rsnd_gen1_probe(pdev, info, priv);
+               ret = rsnd_gen1_probe(pdev, priv);
        else if (rsnd_is_gen2(priv))
-               ret = rsnd_gen2_probe(pdev, info, priv);
+               ret = rsnd_gen2_probe(pdev, priv);
 
        if (ret < 0)
                dev_err(dev, "unknown generation R-Car sound device\n");
 
        return ret;
 }
-
-void rsnd_gen_remove(struct platform_device *pdev,
-                    struct rsnd_priv *priv)
-{
-}
index 4ca66cd..d119adf 100644 (file)
@@ -17,6 +17,8 @@
 #include <linux/io.h>
 #include <linux/list.h>
 #include <linux/module.h>
+#include <linux/of_device.h>
+#include <linux/of_irq.h>
 #include <linux/sh_dma.h>
 #include <linux/workqueue.h>
 #include <sound/rcar_snd.h>
  */
 enum rsnd_reg {
        /* SRU/SCU/SSIU */
-       RSND_REG_SRC_ROUTE_SEL,         /* for Gen1 */
-       RSND_REG_SRC_TMG_SEL0,          /* for Gen1 */
-       RSND_REG_SRC_TMG_SEL1,          /* for Gen1 */
-       RSND_REG_SRC_TMG_SEL2,          /* for Gen1 */
-       RSND_REG_SRC_ROUTE_CTRL,        /* for Gen1 */
        RSND_REG_SSI_MODE0,
        RSND_REG_SSI_MODE1,
-       RSND_REG_BUSIF_MODE,
-       RSND_REG_INT_ENABLE,            /* for Gen2 */
+       RSND_REG_SRC_BUSIF_MODE,
        RSND_REG_SRC_ROUTE_MODE0,
        RSND_REG_SRC_SWRSR,
        RSND_REG_SRC_SRCIR,
@@ -48,7 +44,15 @@ enum rsnd_reg {
        RSND_REG_SRC_IFSCR,
        RSND_REG_SRC_IFSVR,
        RSND_REG_SRC_SRCCR,
-       RSND_REG_SRC_MNFSR,
+       RSND_REG_CMD_ROUTE_SLCT,
+       RSND_REG_DVC_SWRSR,
+       RSND_REG_DVC_DVUIR,
+       RSND_REG_DVC_ADINR,
+       RSND_REG_DVC_DVUCR,
+       RSND_REG_DVC_ZCMCR,
+       RSND_REG_DVC_VOL0R,
+       RSND_REG_DVC_VOL1R,
+       RSND_REG_DVC_DVUER,
 
        /* ADG */
        RSND_REG_BRRA,
@@ -56,10 +60,6 @@ enum rsnd_reg {
        RSND_REG_SSICKR,
        RSND_REG_AUDIO_CLK_SEL0,
        RSND_REG_AUDIO_CLK_SEL1,
-       RSND_REG_AUDIO_CLK_SEL2,
-       RSND_REG_AUDIO_CLK_SEL3,        /* for Gen1 */
-       RSND_REG_AUDIO_CLK_SEL4,        /* for Gen1 */
-       RSND_REG_AUDIO_CLK_SEL5,        /* for Gen1 */
 
        /* SSI */
        RSND_REG_SSICR,
@@ -68,9 +68,69 @@ enum rsnd_reg {
        RSND_REG_SSIRDR,
        RSND_REG_SSIWSR,
 
+       /* SHARE see below */
+       RSND_REG_SHARE01,
+       RSND_REG_SHARE02,
+       RSND_REG_SHARE03,
+       RSND_REG_SHARE04,
+       RSND_REG_SHARE05,
+       RSND_REG_SHARE06,
+       RSND_REG_SHARE07,
+       RSND_REG_SHARE08,
+       RSND_REG_SHARE09,
+       RSND_REG_SHARE10,
+       RSND_REG_SHARE11,
+       RSND_REG_SHARE12,
+       RSND_REG_SHARE13,
+       RSND_REG_SHARE14,
+       RSND_REG_SHARE15,
+       RSND_REG_SHARE16,
+       RSND_REG_SHARE17,
+       RSND_REG_SHARE18,
+       RSND_REG_SHARE19,
+       RSND_REG_SHARE20,
+       RSND_REG_SHARE21,
+       RSND_REG_SHARE22,
+
        RSND_REG_MAX,
 };
 
+/* Gen1 only */
+#define RSND_REG_SRC_ROUTE_SEL         RSND_REG_SHARE01
+#define RSND_REG_SRC_TMG_SEL0          RSND_REG_SHARE02
+#define RSND_REG_SRC_TMG_SEL1          RSND_REG_SHARE03
+#define RSND_REG_SRC_TMG_SEL2          RSND_REG_SHARE04
+#define RSND_REG_SRC_ROUTE_CTRL                RSND_REG_SHARE05
+#define RSND_REG_SRC_MNFSR             RSND_REG_SHARE06
+#define RSND_REG_AUDIO_CLK_SEL3                RSND_REG_SHARE07
+#define RSND_REG_AUDIO_CLK_SEL4                RSND_REG_SHARE08
+#define RSND_REG_AUDIO_CLK_SEL5                RSND_REG_SHARE09
+
+/* Gen2 only */
+#define RSND_REG_SRC_CTRL              RSND_REG_SHARE01
+#define RSND_REG_SSI_CTRL              RSND_REG_SHARE02
+#define RSND_REG_SSI_BUSIF_MODE                RSND_REG_SHARE03
+#define RSND_REG_SSI_BUSIF_ADINR       RSND_REG_SHARE04
+#define RSND_REG_INT_ENABLE            RSND_REG_SHARE05
+#define RSND_REG_SRC_BSDSR             RSND_REG_SHARE06
+#define RSND_REG_SRC_BSISR             RSND_REG_SHARE07
+#define RSND_REG_DIV_EN                        RSND_REG_SHARE08
+#define RSND_REG_SRCIN_TIMSEL0         RSND_REG_SHARE09
+#define RSND_REG_SRCIN_TIMSEL1         RSND_REG_SHARE10
+#define RSND_REG_SRCIN_TIMSEL2         RSND_REG_SHARE11
+#define RSND_REG_SRCIN_TIMSEL3         RSND_REG_SHARE12
+#define RSND_REG_SRCIN_TIMSEL4         RSND_REG_SHARE13
+#define RSND_REG_SRCOUT_TIMSEL0                RSND_REG_SHARE14
+#define RSND_REG_SRCOUT_TIMSEL1                RSND_REG_SHARE15
+#define RSND_REG_SRCOUT_TIMSEL2                RSND_REG_SHARE16
+#define RSND_REG_SRCOUT_TIMSEL3                RSND_REG_SHARE17
+#define RSND_REG_SRCOUT_TIMSEL4                RSND_REG_SHARE18
+#define RSND_REG_AUDIO_CLK_SEL2                RSND_REG_SHARE19
+#define RSND_REG_CMD_CTRL              RSND_REG_SHARE20
+#define RSND_REG_CMDOUT_TIMSEL         RSND_REG_SHARE21
+#define RSND_REG_BUSIF_DALIGN          RSND_REG_SHARE22
+
+struct rsnd_of_data;
 struct rsnd_priv;
 struct rsnd_mod;
 struct rsnd_dai;
@@ -91,29 +151,23 @@ void rsnd_write(struct rsnd_priv *priv, struct rsnd_mod *mod,
                enum rsnd_reg reg, u32 data);
 void rsnd_bset(struct rsnd_priv *priv, struct rsnd_mod *mod, enum rsnd_reg reg,
                    u32 mask, u32 data);
+u32 rsnd_get_adinr(struct rsnd_mod *mod);
 
 /*
  *     R-Car DMA
  */
 struct rsnd_dma {
-       struct rsnd_priv        *priv;
        struct sh_dmae_slave    slave;
-       struct work_struct      work;
        struct dma_chan         *chan;
-       enum dma_data_direction dir;
-       int (*inquiry)(struct rsnd_dma *dma, dma_addr_t *buf, int *len);
-       int (*complete)(struct rsnd_dma *dma);
-
-       int submit_loop;
+       enum dma_transfer_direction dir;
+       dma_addr_t              addr;
 };
 
 void rsnd_dma_start(struct rsnd_dma *dma);
 void rsnd_dma_stop(struct rsnd_dma *dma);
 int rsnd_dma_available(struct rsnd_dma *dma);
 int rsnd_dma_init(struct rsnd_priv *priv, struct rsnd_dma *dma,
-       int is_play, int id,
-       int (*inquiry)(struct rsnd_dma *dma, dma_addr_t *buf, int *len),
-       int (*complete)(struct rsnd_dma *dma));
+       int is_play, int id);
 void  rsnd_dma_quit(struct rsnd_priv *priv,
                    struct rsnd_dma *dma);
 
@@ -121,60 +175,73 @@ void  rsnd_dma_quit(struct rsnd_priv *priv,
 /*
  *     R-Car sound mod
  */
+enum rsnd_mod_type {
+       RSND_MOD_SRC = 0,
+       RSND_MOD_SSI,
+       RSND_MOD_DVC,
+       RSND_MOD_MAX,
+};
 
 struct rsnd_mod_ops {
        char *name;
+       char* (*dma_name)(struct rsnd_mod *mod);
+       int (*probe)(struct rsnd_mod *mod,
+                    struct rsnd_dai *rdai);
+       int (*remove)(struct rsnd_mod *mod,
+                     struct rsnd_dai *rdai);
        int (*init)(struct rsnd_mod *mod,
-                   struct rsnd_dai *rdai,
-                   struct rsnd_dai_stream *io);
+                   struct rsnd_dai *rdai);
        int (*quit)(struct rsnd_mod *mod,
-                   struct rsnd_dai *rdai,
-                   struct rsnd_dai_stream *io);
+                   struct rsnd_dai *rdai);
        int (*start)(struct rsnd_mod *mod,
-                    struct rsnd_dai *rdai,
-                    struct rsnd_dai_stream *io);
+                    struct rsnd_dai *rdai);
        int (*stop)(struct rsnd_mod *mod,
-                   struct rsnd_dai *rdai,
-                   struct rsnd_dai_stream *io);
+                   struct rsnd_dai *rdai);
+       int (*pcm_new)(struct rsnd_mod *mod,
+                      struct rsnd_dai *rdai,
+                      struct snd_soc_pcm_runtime *rtd);
 };
 
+struct rsnd_dai_stream;
 struct rsnd_mod {
        int id;
+       enum rsnd_mod_type type;
        struct rsnd_priv *priv;
        struct rsnd_mod_ops *ops;
-       struct list_head list; /* connect to rsnd_dai playback/capture */
        struct rsnd_dma dma;
+       struct rsnd_dai_stream *io;
 };
 
 #define rsnd_mod_to_priv(mod) ((mod)->priv)
 #define rsnd_mod_to_dma(mod) (&(mod)->dma)
 #define rsnd_dma_to_mod(_dma) container_of((_dma), struct rsnd_mod, dma)
+#define rsnd_mod_to_io(mod) ((mod)->io)
 #define rsnd_mod_id(mod) ((mod)->id)
-#define for_each_rsnd_mod(pos, n, io)  \
-       list_for_each_entry_safe(pos, n, &(io)->head, list)
-#define rsnd_mod_call(mod, func, rdai, io)     \
-       (!(mod) ? -ENODEV :                     \
-        !((mod)->ops->func) ? 0 :              \
-        (mod)->ops->func(mod, rdai, io))
 
 void rsnd_mod_init(struct rsnd_priv *priv,
                   struct rsnd_mod *mod,
                   struct rsnd_mod_ops *ops,
+                  enum rsnd_mod_type type,
                   int id);
 char *rsnd_mod_name(struct rsnd_mod *mod);
+char *rsnd_mod_dma_name(struct rsnd_mod *mod);
 
 /*
  *     R-Car sound DAI
  */
 #define RSND_DAI_NAME_SIZE     16
 struct rsnd_dai_stream {
-       struct list_head head; /* head of rsnd_mod list */
        struct snd_pcm_substream *substream;
+       struct rsnd_mod *mod[RSND_MOD_MAX];
+       struct rsnd_dai_path_info *info; /* rcar_snd.h */
        int byte_pos;
        int period_pos;
        int byte_per_period;
        int next_period_byte;
 };
+#define rsnd_io_to_mod_ssi(io) ((io)->mod[RSND_MOD_SSI])
+#define rsnd_io_to_mod_src(io) ((io)->mod[RSND_MOD_SRC])
+#define rsnd_io_to_mod_dvc(io) ((io)->mod[RSND_MOD_DVC])
 
 struct rsnd_dai {
        char name[RSND_DAI_NAME_SIZE];
@@ -189,16 +256,14 @@ struct rsnd_dai {
        unsigned int data_alignment:1;
 };
 
-#define rsnd_dai_nr(priv) ((priv)->dai_nr)
+#define rsnd_rdai_nr(priv) ((priv)->rdai_nr)
 #define for_each_rsnd_dai(rdai, priv, i)               \
-       for (i = 0, (rdai) = rsnd_dai_get(priv, i);     \
-            i < rsnd_dai_nr(priv);                     \
-            i++, (rdai) = rsnd_dai_get(priv, i))
+       for (i = 0;                                     \
+            (i < rsnd_rdai_nr(priv)) &&                \
+            ((rdai) = rsnd_dai_get(priv, i));          \
+            i++)
 
 struct rsnd_dai *rsnd_dai_get(struct rsnd_priv *priv, int id);
-int rsnd_dai_disconnect(struct rsnd_mod *mod);
-int rsnd_dai_connect(struct rsnd_dai *rdai, struct rsnd_mod *mod,
-                    struct rsnd_dai_stream *io);
 int rsnd_dai_is_play(struct rsnd_dai *rdai, struct rsnd_dai_stream *io);
 int rsnd_dai_id(struct rsnd_priv *priv, struct rsnd_dai *rdai);
 #define rsnd_dai_get_platform_info(rdai) ((rdai)->info)
@@ -206,24 +271,21 @@ int rsnd_dai_id(struct rsnd_priv *priv, struct rsnd_dai *rdai);
 
 void rsnd_dai_pointer_update(struct rsnd_dai_stream *io, int cnt);
 int rsnd_dai_pointer_offset(struct rsnd_dai_stream *io, int additional);
+#define rsnd_dai_is_clk_master(rdai) ((rdai)->clk_master)
 
 /*
  *     R-Car Gen1/Gen2
  */
 int rsnd_gen_probe(struct platform_device *pdev,
-                  struct rcar_snd_info *info,
+                  const struct rsnd_of_data *of_data,
                   struct rsnd_priv *priv);
-void rsnd_gen_remove(struct platform_device *pdev,
-                    struct rsnd_priv *priv);
-int rsnd_gen_path_init(struct rsnd_priv *priv,
-                      struct rsnd_dai *rdai,
-                      struct rsnd_dai_stream *io);
-int rsnd_gen_path_exit(struct rsnd_priv *priv,
-                      struct rsnd_dai *rdai,
-                      struct rsnd_dai_stream *io);
 void __iomem *rsnd_gen_reg_get(struct rsnd_priv *priv,
                               struct rsnd_mod *mod,
                               enum rsnd_reg reg);
+dma_addr_t rsnd_gen_dma_addr(struct rsnd_priv *priv,
+                      struct rsnd_mod *mod,
+                      int is_play,  int is_from);
+
 #define rsnd_is_gen1(s)                (((s)->info->flags & RSND_GEN_MASK) == RSND_GEN1)
 #define rsnd_is_gen2(s)                (((s)->info->flags & RSND_GEN_MASK) == RSND_GEN2)
 
@@ -233,21 +295,34 @@ void __iomem *rsnd_gen_reg_get(struct rsnd_priv *priv,
 int rsnd_adg_ssi_clk_stop(struct rsnd_mod *mod);
 int rsnd_adg_ssi_clk_try_start(struct rsnd_mod *mod, unsigned int rate);
 int rsnd_adg_probe(struct platform_device *pdev,
-                  struct rcar_snd_info *info,
-                  struct rsnd_priv *priv);
-void rsnd_adg_remove(struct platform_device *pdev,
+                  const struct rsnd_of_data *of_data,
                   struct rsnd_priv *priv);
-int rsnd_adg_set_convert_clk(struct rsnd_priv *priv,
-                            struct rsnd_mod *mod,
-                            unsigned int src_rate,
-                            unsigned int dst_rate);
+int rsnd_adg_set_convert_clk_gen1(struct rsnd_priv *priv,
+                                 struct rsnd_mod *mod,
+                                 unsigned int src_rate,
+                                 unsigned int dst_rate);
+int rsnd_adg_set_convert_clk_gen2(struct rsnd_mod *mod,
+                                 struct rsnd_dai *rdai,
+                                 struct rsnd_dai_stream *io,
+                                 unsigned int src_rate,
+                                 unsigned int dst_rate);
+int rsnd_adg_set_convert_timing_gen2(struct rsnd_mod *mod,
+                                    struct rsnd_dai *rdai,
+                                    struct rsnd_dai_stream *io);
+int rsnd_adg_set_cmd_timsel_gen2(struct rsnd_dai *rdai,
+                                struct rsnd_mod *mod,
+                                struct rsnd_dai_stream *io);
 
 /*
  *     R-Car sound priv
  */
+struct rsnd_of_data {
+       u32 flags;
+};
+
 struct rsnd_priv {
 
-       struct device *dev;
+       struct platform_device *pdev;
        struct rcar_snd_info *info;
        spinlock_t lock;
 
@@ -257,10 +332,10 @@ struct rsnd_priv {
        void *gen;
 
        /*
-        * below value will be filled on rsnd_scu_probe()
+        * below value will be filled on rsnd_src_probe()
         */
-       void *scu;
-       int scu_nr;
+       void *src;
+       int src_nr;
 
        /*
         * below value will be filled on rsnd_adg_probe()
@@ -270,46 +345,83 @@ struct rsnd_priv {
        /*
         * below value will be filled on rsnd_ssi_probe()
         */
-       void *ssiu;
+       void *ssi;
+       int ssi_nr;
+
+       /*
+        * below value will be filled on rsnd_dvc_probe()
+        */
+       void *dvc;
+       int dvc_nr;
 
        /*
         * below value will be filled on rsnd_dai_probe()
         */
        struct snd_soc_dai_driver *daidrv;
        struct rsnd_dai *rdai;
-       int dai_nr;
+       int rdai_nr;
 };
 
-#define rsnd_priv_to_dev(priv) ((priv)->dev)
+#define rsnd_priv_to_pdev(priv)        ((priv)->pdev)
+#define rsnd_priv_to_dev(priv) (&(rsnd_priv_to_pdev(priv)->dev))
+#define rsnd_priv_to_info(priv)        ((priv)->info)
 #define rsnd_lock(priv, flags) spin_lock_irqsave(&priv->lock, flags)
 #define rsnd_unlock(priv, flags) spin_unlock_irqrestore(&priv->lock, flags)
 
+#define rsnd_info_is_playback(priv, type)                              \
+({                                                                     \
+       struct rcar_snd_info *info = rsnd_priv_to_info(priv);           \
+       int i, is_play = 0;                                             \
+       for (i = 0; i < info->dai_info_nr; i++) {                       \
+               if (info->dai_info[i].playback.type == (type)->info) {  \
+                       is_play = 1;                                    \
+                       break;                                          \
+               }                                                       \
+       }                                                               \
+       is_play;                                                        \
+})
+
 /*
- *     R-Car SCU
+ *     R-Car SRC
  */
-int rsnd_scu_probe(struct platform_device *pdev,
-                  struct rcar_snd_info *info,
+int rsnd_src_probe(struct platform_device *pdev,
+                  const struct rsnd_of_data *of_data,
                   struct rsnd_priv *priv);
-void rsnd_scu_remove(struct platform_device *pdev,
-                    struct rsnd_priv *priv);
-struct rsnd_mod *rsnd_scu_mod_get(struct rsnd_priv *priv, int id);
-bool rsnd_scu_hpbif_is_enable(struct rsnd_mod *mod);
-unsigned int rsnd_scu_get_ssi_rate(struct rsnd_priv *priv,
-                                  struct rsnd_mod *ssi_mod,
+struct rsnd_mod *rsnd_src_mod_get(struct rsnd_priv *priv, int id);
+unsigned int rsnd_src_get_ssi_rate(struct rsnd_priv *priv,
+                                  struct rsnd_dai_stream *io,
                                   struct snd_pcm_runtime *runtime);
+int rsnd_src_ssiu_start(struct rsnd_mod *ssi_mod,
+                       struct rsnd_dai *rdai,
+                       int use_busif);
+int rsnd_src_ssiu_stop(struct rsnd_mod *ssi_mod,
+                      struct rsnd_dai *rdai,
+                      int use_busif);
+int rsnd_src_enable_ssi_irq(struct rsnd_mod *ssi_mod,
+                           struct rsnd_dai *rdai);
 
-#define rsnd_scu_nr(priv) ((priv)->scu_nr)
+#define rsnd_src_nr(priv) ((priv)->src_nr)
 
 /*
  *     R-Car SSI
  */
 int rsnd_ssi_probe(struct platform_device *pdev,
-                  struct rcar_snd_info *info,
-                  struct rsnd_priv *priv);
-void rsnd_ssi_remove(struct platform_device *pdev,
+                  const struct rsnd_of_data *of_data,
                   struct rsnd_priv *priv);
 struct rsnd_mod *rsnd_ssi_mod_get(struct rsnd_priv *priv, int id);
-struct rsnd_mod *rsnd_ssi_mod_get_frm_dai(struct rsnd_priv *priv,
-                                         int dai_id, int is_play);
+int rsnd_ssi_is_pin_sharing(struct rsnd_mod *mod);
+
+/*
+ *     R-Car DVC
+ */
+int rsnd_dvc_probe(struct platform_device *pdev,
+                  const struct rsnd_of_data *of_data,
+                  struct rsnd_priv *priv);
+void rsnd_dvc_remove(struct platform_device *pdev,
+                    struct rsnd_priv *priv);
+struct rsnd_mod *rsnd_dvc_mod_get(struct rsnd_priv *priv, int id);
+
+#define rsnd_dvc_nr(priv) ((priv)->dvc_nr)
+
 
 #endif
diff --git a/sound/soc/sh/rcar/scu.c b/sound/soc/sh/rcar/scu.c
deleted file mode 100644 (file)
index 9bb08bb..0000000
+++ /dev/null
@@ -1,384 +0,0 @@
-/*
- * Renesas R-Car SCU support
- *
- * Copyright (C) 2013 Renesas Solutions Corp.
- * Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 as
- * published by the Free Software Foundation.
- */
-#include "rsnd.h"
-
-struct rsnd_scu {
-       struct rsnd_scu_platform_info *info; /* rcar_snd.h */
-       struct rsnd_mod mod;
-       struct clk *clk;
-};
-
-#define rsnd_scu_mode_flags(p) ((p)->info->flags)
-#define rsnd_scu_convert_rate(p) ((p)->info->convert_rate)
-
-#define RSND_SCU_NAME_SIZE 16
-
-/*
- * ADINR
- */
-#define OTBL_24                (0 << 16)
-#define OTBL_22                (2 << 16)
-#define OTBL_20                (4 << 16)
-#define OTBL_18                (6 << 16)
-#define OTBL_16                (8 << 16)
-
-/*
- *             image of SRC (Sampling Rate Converter)
- *
- * 96kHz   <-> +-----+ 48kHz   +-----+  48kHz  +-------+
- * 48kHz   <-> | SRC | <------>        | SSI | <-----> | codec |
- * 44.1kHz <-> +-----+         +-----+         +-------+
- * ...
- *
- */
-
-#define rsnd_mod_to_scu(_mod)  \
-       container_of((_mod), struct rsnd_scu, mod)
-
-#define for_each_rsnd_scu(pos, priv, i)                                        \
-       for ((i) = 0;                                                   \
-            ((i) < rsnd_scu_nr(priv)) &&                               \
-                    ((pos) = (struct rsnd_scu *)(priv)->scu + i);      \
-            i++)
-
-/* Gen1 only */
-static int rsnd_src_set_route_if_gen1(struct rsnd_priv *priv,
-                             struct rsnd_mod *mod,
-                             struct rsnd_dai *rdai,
-                             struct rsnd_dai_stream *io)
-{
-       struct scu_route_config {
-               u32 mask;
-               int shift;
-       } routes[] = {
-               { 0xF,  0, }, /* 0 */
-               { 0xF,  4, }, /* 1 */
-               { 0xF,  8, }, /* 2 */
-               { 0x7, 12, }, /* 3 */
-               { 0x7, 16, }, /* 4 */
-               { 0x7, 20, }, /* 5 */
-               { 0x7, 24, }, /* 6 */
-               { 0x3, 28, }, /* 7 */
-               { 0x3, 30, }, /* 8 */
-       };
-       struct rsnd_scu *scu = rsnd_mod_to_scu(mod);
-       u32 mask;
-       u32 val;
-       int shift;
-       int id;
-
-       /*
-        * Gen1 only
-        */
-       if (!rsnd_is_gen1(priv))
-               return 0;
-
-       id = rsnd_mod_id(mod);
-       if (id < 0 || id >= ARRAY_SIZE(routes))
-               return -EIO;
-
-       /*
-        * SRC_ROUTE_SELECT
-        */
-       val = rsnd_dai_is_play(rdai, io) ? 0x1 : 0x2;
-       val = val               << routes[id].shift;
-       mask = routes[id].mask  << routes[id].shift;
-
-       rsnd_mod_bset(mod, SRC_ROUTE_SEL, mask, val);
-
-       /*
-        * SRC_TIMING_SELECT
-        */
-       shift   = (id % 4) * 8;
-       mask    = 0x1F << shift;
-
-       /*
-        * ADG is used as source clock if SRC was used,
-        * then, SSI WS is used as destination clock.
-        * SSI WS is used as source clock if SRC is not used
-        * (when playback, source/destination become reverse when capture)
-        */
-       if (rsnd_scu_convert_rate(scu)) /* use ADG */
-               val = 0;
-       else if (8 == id)               /* use SSI WS, but SRU8 is special */
-               val = id << shift;
-       else                            /* use SSI WS */
-               val = (id + 1) << shift;
-
-       switch (id / 4) {
-       case 0:
-               rsnd_mod_bset(mod, SRC_TMG_SEL0, mask, val);
-               break;
-       case 1:
-               rsnd_mod_bset(mod, SRC_TMG_SEL1, mask, val);
-               break;
-       case 2:
-               rsnd_mod_bset(mod, SRC_TMG_SEL2, mask, val);
-               break;
-       }
-
-       return 0;
-}
-
-unsigned int rsnd_scu_get_ssi_rate(struct rsnd_priv *priv,
-                                  struct rsnd_mod *ssi_mod,
-                                  struct snd_pcm_runtime *runtime)
-{
-       struct rsnd_scu *scu;
-       unsigned int rate;
-
-       /* this function is assuming SSI id = SCU id here */
-       scu = rsnd_mod_to_scu(rsnd_scu_mod_get(priv, rsnd_mod_id(ssi_mod)));
-
-       /*
-        * return convert rate if SRC is used,
-        * otherwise, return runtime->rate as usual
-        */
-       rate = rsnd_scu_convert_rate(scu);
-       if (!rate)
-               rate = runtime->rate;
-
-       return rate;
-}
-
-static int rsnd_scu_convert_rate_ctrl(struct rsnd_priv *priv,
-                             struct rsnd_mod *mod,
-                             struct rsnd_dai *rdai,
-                             struct rsnd_dai_stream *io)
-{
-       struct snd_pcm_runtime *runtime = rsnd_io_to_runtime(io);
-       struct rsnd_scu *scu = rsnd_mod_to_scu(mod);
-       u32 convert_rate = rsnd_scu_convert_rate(scu);
-       u32 adinr = runtime->channels;
-
-       /* set/clear soft reset */
-       rsnd_mod_write(mod, SRC_SWRSR, 0);
-       rsnd_mod_write(mod, SRC_SWRSR, 1);
-
-       /* Initialize the operation of the SRC internal circuits */
-       rsnd_mod_write(mod, SRC_SRCIR, 1);
-
-       /* Set channel number and output bit length */
-       switch (runtime->sample_bits) {
-       case 16:
-               adinr |= OTBL_16;
-               break;
-       case 32:
-               adinr |= OTBL_24;
-               break;
-       default:
-               return -EIO;
-       }
-       rsnd_mod_write(mod, SRC_ADINR, adinr);
-
-       if (convert_rate) {
-               u32 fsrate = 0x0400000 / convert_rate * runtime->rate;
-               int ret;
-
-               /* Enable the initial value of IFS */
-               rsnd_mod_write(mod, SRC_IFSCR, 1);
-
-               /* Set initial value of IFS */
-               rsnd_mod_write(mod, SRC_IFSVR, fsrate);
-
-               /* Select SRC mode (fixed value) */
-               rsnd_mod_write(mod, SRC_SRCCR, 0x00010110);
-
-               /* Set the restriction value of the FS ratio (98%) */
-               rsnd_mod_write(mod, SRC_MNFSR, fsrate / 100 * 98);
-
-               if (rsnd_is_gen1(priv)) {
-                       /* no SRC_BFSSR settings, since SRC_SRCCR::BUFMD is 0 */
-               }
-
-               /* set convert clock */
-               ret = rsnd_adg_set_convert_clk(priv, mod,
-                                              runtime->rate,
-                                              convert_rate);
-               if (ret < 0)
-                       return ret;
-       }
-
-       /* Cancel the initialization and operate the SRC function */
-       rsnd_mod_write(mod, SRC_SRCIR, 0);
-
-       /* use DMA transfer */
-       rsnd_mod_write(mod, BUSIF_MODE, 1);
-
-       return 0;
-}
-
-static int rsnd_scu_transfer_start(struct rsnd_priv *priv,
-                                  struct rsnd_mod *mod,
-                                  struct rsnd_dai *rdai,
-                                  struct rsnd_dai_stream *io)
-{
-       struct rsnd_scu *scu = rsnd_mod_to_scu(mod);
-       int id = rsnd_mod_id(mod);
-       u32 val;
-
-       if (rsnd_is_gen1(priv)) {
-               val = (1 << id);
-               rsnd_mod_bset(mod, SRC_ROUTE_CTRL, val, val);
-       }
-
-       if (rsnd_scu_convert_rate(scu))
-               rsnd_mod_write(mod, SRC_ROUTE_MODE0, 1);
-
-       return 0;
-}
-
-static int rsnd_scu_transfer_stop(struct rsnd_priv *priv,
-                                 struct rsnd_mod *mod,
-                                 struct rsnd_dai *rdai,
-                                 struct rsnd_dai_stream *io)
-{
-       struct rsnd_scu *scu = rsnd_mod_to_scu(mod);
-       int id = rsnd_mod_id(mod);
-       u32 mask;
-
-       if (rsnd_is_gen1(priv)) {
-               mask = (1 << id);
-               rsnd_mod_bset(mod, SRC_ROUTE_CTRL, mask, 0);
-       }
-
-       if (rsnd_scu_convert_rate(scu))
-               rsnd_mod_write(mod, SRC_ROUTE_MODE0, 0);
-
-       return 0;
-}
-
-bool rsnd_scu_hpbif_is_enable(struct rsnd_mod *mod)
-{
-       struct rsnd_scu *scu = rsnd_mod_to_scu(mod);
-       u32 flags = rsnd_scu_mode_flags(scu);
-
-       return !!(flags & RSND_SCU_USE_HPBIF);
-}
-
-static int rsnd_scu_start(struct rsnd_mod *mod,
-                         struct rsnd_dai *rdai,
-                         struct rsnd_dai_stream *io)
-{
-       struct rsnd_priv *priv = rsnd_mod_to_priv(mod);
-       struct rsnd_scu *scu = rsnd_mod_to_scu(mod);
-       struct device *dev = rsnd_priv_to_dev(priv);
-       int ret;
-
-       /*
-        * SCU will be used if it has RSND_SCU_USE_HPBIF flags
-        */
-       if (!rsnd_scu_hpbif_is_enable(mod)) {
-               /* it use PIO transter */
-               dev_dbg(dev, "%s%d is not used\n",
-                       rsnd_mod_name(mod), rsnd_mod_id(mod));
-
-               return 0;
-       }
-
-       clk_enable(scu->clk);
-
-       /* it use DMA transter */
-
-       ret = rsnd_src_set_route_if_gen1(priv, mod, rdai, io);
-       if (ret < 0)
-               return ret;
-
-       ret = rsnd_scu_convert_rate_ctrl(priv, mod, rdai, io);
-       if (ret < 0)
-               return ret;
-
-       ret = rsnd_scu_transfer_start(priv, mod, rdai, io);
-       if (ret < 0)
-               return ret;
-
-       dev_dbg(dev, "%s%d start\n", rsnd_mod_name(mod), rsnd_mod_id(mod));
-
-       return 0;
-}
-
-static int rsnd_scu_stop(struct rsnd_mod *mod,
-                         struct rsnd_dai *rdai,
-                         struct rsnd_dai_stream *io)
-{
-       struct rsnd_priv *priv = rsnd_mod_to_priv(mod);
-       struct rsnd_scu *scu = rsnd_mod_to_scu(mod);
-
-       if (!rsnd_scu_hpbif_is_enable(mod))
-               return 0;
-
-       rsnd_scu_transfer_stop(priv, mod, rdai, io);
-
-       clk_disable(scu->clk);
-
-       return 0;
-}
-
-static struct rsnd_mod_ops rsnd_scu_ops = {
-       .name   = "scu",
-       .start  = rsnd_scu_start,
-       .stop   = rsnd_scu_stop,
-};
-
-struct rsnd_mod *rsnd_scu_mod_get(struct rsnd_priv *priv, int id)
-{
-       if (WARN_ON(id < 0 || id >= rsnd_scu_nr(priv)))
-               id = 0;
-
-       return &((struct rsnd_scu *)(priv->scu) + id)->mod;
-}
-
-int rsnd_scu_probe(struct platform_device *pdev,
-                  struct rcar_snd_info *info,
-                  struct rsnd_priv *priv)
-{
-       struct device *dev = rsnd_priv_to_dev(priv);
-       struct rsnd_scu *scu;
-       struct clk *clk;
-       char name[RSND_SCU_NAME_SIZE];
-       int i, nr;
-
-       /*
-        * init SCU
-        */
-       nr      = info->scu_info_nr;
-       scu     = devm_kzalloc(dev, sizeof(*scu) * nr, GFP_KERNEL);
-       if (!scu) {
-               dev_err(dev, "SCU allocate failed\n");
-               return -ENOMEM;
-       }
-
-       priv->scu_nr    = nr;
-       priv->scu       = scu;
-
-       for_each_rsnd_scu(scu, priv, i) {
-               snprintf(name, RSND_SCU_NAME_SIZE, "scu.%d", i);
-
-               clk = devm_clk_get(dev, name);
-               if (IS_ERR(clk))
-                       return PTR_ERR(clk);
-
-               rsnd_mod_init(priv, &scu->mod,
-                             &rsnd_scu_ops, i);
-               scu->info = &info->scu_info[i];
-               scu->clk = clk;
-
-               dev_dbg(dev, "SCU%d probed\n", i);
-       }
-       dev_dbg(dev, "scu probed\n");
-
-       return 0;
-}
-
-void rsnd_scu_remove(struct platform_device *pdev,
-                    struct rsnd_priv *priv)
-{
-}
diff --git a/sound/soc/sh/rcar/src.c b/sound/soc/sh/rcar/src.c
new file mode 100644 (file)
index 0000000..9183e01
--- /dev/null
@@ -0,0 +1,753 @@
+/*
+ * Renesas R-Car SRC support
+ *
+ * Copyright (C) 2013 Renesas Solutions Corp.
+ * Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ */
+#include "rsnd.h"
+
+#define SRC_NAME "src"
+
+struct rsnd_src {
+       struct rsnd_src_platform_info *info; /* rcar_snd.h */
+       struct rsnd_mod mod;
+       struct clk *clk;
+};
+
+#define RSND_SRC_NAME_SIZE 16
+
+#define rsnd_src_convert_rate(p) ((p)->info->convert_rate)
+#define rsnd_mod_to_src(_mod)                          \
+       container_of((_mod), struct rsnd_src, mod)
+#define rsnd_src_dma_available(src) \
+       rsnd_dma_available(rsnd_mod_to_dma(&(src)->mod))
+
+#define for_each_rsnd_src(pos, priv, i)                                \
+       for ((i) = 0;                                           \
+            ((i) < rsnd_src_nr(priv)) &&                       \
+            ((pos) = (struct rsnd_src *)(priv)->src + i);      \
+            i++)
+
+
+/*
+ *             image of SRC (Sampling Rate Converter)
+ *
+ * 96kHz   <-> +-----+ 48kHz   +-----+  48kHz  +-------+
+ * 48kHz   <-> | SRC | <------>        | SSI | <-----> | codec |
+ * 44.1kHz <-> +-----+         +-----+         +-------+
+ * ...
+ *
+ */
+
+/*
+ * src.c is caring...
+ *
+ * Gen1
+ *
+ * [mem] -> [SRU] -> [SSI]
+ *        |--------|
+ *
+ * Gen2
+ *
+ * [mem] -> [SRC] -> [SSIU] -> [SSI]
+ *        |-----------------|
+ */
+
+/*
+ *     How to use SRC bypass mode for debugging
+ *
+ * SRC has bypass mode, and it is useful for debugging.
+ * In Gen2 case,
+ * SRCm_MODE controls whether SRC is used or not
+ * SSI_MODE0 controls whether SSIU which receives SRC data
+ * is used or not.
+ * Both SRCm_MODE/SSI_MODE0 settings are needed if you use SRC,
+ * but SRC bypass mode needs SSI_MODE0 only.
+ *
+ * This driver request
+ * struct rsnd_src_platform_info {
+ *     u32 convert_rate;
+ *     int dma_id;
+ * }
+ *
+ * rsnd_src_convert_rate() indicates
+ * above convert_rate, and it controls
+ * whether SRC is used or not.
+ *
+ * ex) doesn't use SRC
+ * static struct rsnd_dai_platform_info rsnd_dai = {
+ *     .playback = { .ssi = &rsnd_ssi[0], },
+ * };
+ *
+ * ex) uses SRC
+ * static struct rsnd_src_platform_info rsnd_src[] = {
+ *     RSND_SCU(48000, 0),
+ *     ...
+ * };
+ * static struct rsnd_dai_platform_info rsnd_dai = {
+ *     .playback = { .ssi = &rsnd_ssi[0], .src = &rsnd_src[0] },
+ * };
+ *
+ * ex) uses SRC bypass mode
+ * static struct rsnd_src_platform_info rsnd_src[] = {
+ *     RSND_SCU(0, 0),
+ *     ...
+ * };
+ * static struct rsnd_dai_platform_info rsnd_dai = {
+ *     .playback = { .ssi = &rsnd_ssi[0], .src = &rsnd_src[0] },
+ * };
+ *
+ */
+
+/*
+ *             Gen1/Gen2 common functions
+ */
+int rsnd_src_ssiu_start(struct rsnd_mod *ssi_mod,
+                       struct rsnd_dai *rdai,
+                       int use_busif)
+{
+       struct rsnd_dai_stream *io = rsnd_mod_to_io(ssi_mod);
+       struct snd_pcm_runtime *runtime = rsnd_io_to_runtime(io);
+       int ssi_id = rsnd_mod_id(ssi_mod);
+
+       /*
+        * SSI_MODE0
+        */
+       rsnd_mod_bset(ssi_mod, SSI_MODE0, (1 << ssi_id),
+                     !use_busif << ssi_id);
+
+       /*
+        * SSI_MODE1
+        */
+       if (rsnd_ssi_is_pin_sharing(ssi_mod)) {
+               int shift = -1;
+               switch (ssi_id) {
+               case 1:
+                       shift = 0;
+                       break;
+               case 2:
+                       shift = 2;
+                       break;
+               case 4:
+                       shift = 16;
+                       break;
+               }
+
+               if (shift >= 0)
+                       rsnd_mod_bset(ssi_mod, SSI_MODE1,
+                                     0x3 << shift,
+                                     rsnd_dai_is_clk_master(rdai) ?
+                                     0x2 << shift : 0x1 << shift);
+       }
+
+       /*
+        * DMA settings for SSIU
+        */
+       if (use_busif) {
+               u32 val = 0x76543210;
+               u32 mask = ~0;
+
+               rsnd_mod_write(ssi_mod, SSI_BUSIF_ADINR,
+                              rsnd_get_adinr(ssi_mod));
+               rsnd_mod_write(ssi_mod, SSI_BUSIF_MODE,  1);
+               rsnd_mod_write(ssi_mod, SSI_CTRL, 0x1);
+
+               mask <<= runtime->channels * 4;
+               val = val & mask;
+
+               switch (runtime->sample_bits) {
+               case 16:
+                       val |= 0x67452301 & ~mask;
+                       break;
+               case 32:
+                       val |= 0x76543210 & ~mask;
+                       break;
+               }
+               rsnd_mod_write(ssi_mod, BUSIF_DALIGN, val);
+
+       }
+
+       return 0;
+}
+
+int rsnd_src_ssiu_stop(struct rsnd_mod *ssi_mod,
+                       struct rsnd_dai *rdai,
+                       int use_busif)
+{
+       /*
+        * DMA settings for SSIU
+        */
+       if (use_busif)
+               rsnd_mod_write(ssi_mod, SSI_CTRL, 0);
+
+       return 0;
+}
+
+int rsnd_src_enable_ssi_irq(struct rsnd_mod *ssi_mod,
+                           struct rsnd_dai *rdai)
+{
+       struct rsnd_priv *priv = rsnd_mod_to_priv(ssi_mod);
+
+       /* enable PIO interrupt if Gen2 */
+       if (rsnd_is_gen2(priv))
+               rsnd_mod_write(ssi_mod, INT_ENABLE, 0x0f000000);
+
+       return 0;
+}
+
+unsigned int rsnd_src_get_ssi_rate(struct rsnd_priv *priv,
+                                  struct rsnd_dai_stream *io,
+                                  struct snd_pcm_runtime *runtime)
+{
+       struct rsnd_mod *src_mod = rsnd_io_to_mod_src(io);
+       struct rsnd_src *src;
+       unsigned int rate = 0;
+
+       if (src_mod) {
+               src = rsnd_mod_to_src(src_mod);
+
+               /*
+                * return convert rate if SRC is used,
+                * otherwise, return runtime->rate as usual
+                */
+               rate = rsnd_src_convert_rate(src);
+       }
+
+       if (!rate)
+               rate = runtime->rate;
+
+       return rate;
+}
+
+static int rsnd_src_set_convert_rate(struct rsnd_mod *mod,
+                                    struct rsnd_dai *rdai)
+{
+       struct rsnd_dai_stream *io = rsnd_mod_to_io(mod);
+       struct snd_pcm_runtime *runtime = rsnd_io_to_runtime(io);
+       struct rsnd_src *src = rsnd_mod_to_src(mod);
+       u32 convert_rate = rsnd_src_convert_rate(src);
+       u32 fsrate = 0;
+
+       if (convert_rate)
+               fsrate = 0x0400000 / convert_rate * runtime->rate;
+
+       /* set/clear soft reset */
+       rsnd_mod_write(mod, SRC_SWRSR, 0);
+       rsnd_mod_write(mod, SRC_SWRSR, 1);
+
+       /*
+        * Initialize the operation of the SRC internal circuits
+        * see rsnd_src_start()
+        */
+       rsnd_mod_write(mod, SRC_SRCIR, 1);
+
+       /* Set channel number and output bit length */
+       rsnd_mod_write(mod, SRC_ADINR, rsnd_get_adinr(mod));
+
+       /* Enable the initial value of IFS */
+       if (fsrate) {
+               rsnd_mod_write(mod, SRC_IFSCR, 1);
+
+               /* Set initial value of IFS */
+               rsnd_mod_write(mod, SRC_IFSVR, fsrate);
+       }
+
+       /* use DMA transfer */
+       rsnd_mod_write(mod, SRC_BUSIF_MODE, 1);
+
+       return 0;
+}
+
+static int rsnd_src_init(struct rsnd_mod *mod,
+                        struct rsnd_dai *rdai)
+{
+       struct rsnd_src *src = rsnd_mod_to_src(mod);
+
+       clk_prepare_enable(src->clk);
+
+       return 0;
+}
+
+static int rsnd_src_quit(struct rsnd_mod *mod,
+                        struct rsnd_dai *rdai)
+{
+       struct rsnd_src *src = rsnd_mod_to_src(mod);
+
+       clk_disable_unprepare(src->clk);
+
+       return 0;
+}
+
+static int rsnd_src_start(struct rsnd_mod *mod,
+                         struct rsnd_dai *rdai)
+{
+       struct rsnd_src *src = rsnd_mod_to_src(mod);
+
+       /*
+        * Cancel the initialization and operate the SRC function
+        * see rsnd_src_set_convert_rate()
+        */
+       rsnd_mod_write(mod, SRC_SRCIR, 0);
+
+       if (rsnd_src_convert_rate(src))
+               rsnd_mod_write(mod, SRC_ROUTE_MODE0, 1);
+
+       return 0;
+}
+
+
+static int rsnd_src_stop(struct rsnd_mod *mod,
+                        struct rsnd_dai *rdai)
+{
+       struct rsnd_src *src = rsnd_mod_to_src(mod);
+
+       if (rsnd_src_convert_rate(src))
+               rsnd_mod_write(mod, SRC_ROUTE_MODE0, 0);
+
+       return 0;
+}
+
+/*
+ *             Gen1 functions
+ */
+static int rsnd_src_set_route_gen1(struct rsnd_mod *mod,
+                                  struct rsnd_dai *rdai)
+{
+       struct rsnd_dai_stream *io = rsnd_mod_to_io(mod);
+       struct src_route_config {
+               u32 mask;
+               int shift;
+       } routes[] = {
+               { 0xF,  0, }, /* 0 */
+               { 0xF,  4, }, /* 1 */
+               { 0xF,  8, }, /* 2 */
+               { 0x7, 12, }, /* 3 */
+               { 0x7, 16, }, /* 4 */
+               { 0x7, 20, }, /* 5 */
+               { 0x7, 24, }, /* 6 */
+               { 0x3, 28, }, /* 7 */
+               { 0x3, 30, }, /* 8 */
+       };
+       u32 mask;
+       u32 val;
+       int id;
+
+       id = rsnd_mod_id(mod);
+       if (id < 0 || id >= ARRAY_SIZE(routes))
+               return -EIO;
+
+       /*
+        * SRC_ROUTE_SELECT
+        */
+       val = rsnd_dai_is_play(rdai, io) ? 0x1 : 0x2;
+       val = val               << routes[id].shift;
+       mask = routes[id].mask  << routes[id].shift;
+
+       rsnd_mod_bset(mod, SRC_ROUTE_SEL, mask, val);
+
+       return 0;
+}
+
+static int rsnd_src_set_convert_timing_gen1(struct rsnd_mod *mod,
+                                           struct rsnd_dai *rdai)
+{
+       struct rsnd_dai_stream *io = rsnd_mod_to_io(mod);
+       struct rsnd_priv *priv = rsnd_mod_to_priv(mod);
+       struct rsnd_src *src = rsnd_mod_to_src(mod);
+       struct snd_pcm_runtime *runtime = rsnd_io_to_runtime(io);
+       u32 convert_rate = rsnd_src_convert_rate(src);
+       u32 mask;
+       u32 val;
+       int shift;
+       int id = rsnd_mod_id(mod);
+       int ret;
+
+       /*
+        * SRC_TIMING_SELECT
+        */
+       shift   = (id % 4) * 8;
+       mask    = 0x1F << shift;
+
+       /*
+        * ADG is used as source clock if SRC was used,
+        * then, SSI WS is used as destination clock.
+        * SSI WS is used as source clock if SRC is not used
+        * (when playback, source/destination become reverse when capture)
+        */
+       ret = 0;
+       if (convert_rate) {
+               /* use ADG */
+               val = 0;
+               ret = rsnd_adg_set_convert_clk_gen1(priv, mod,
+                                                   runtime->rate,
+                                                   convert_rate);
+       } else if (8 == id) {
+               /* use SSI WS, but SRU8 is special */
+               val = id << shift;
+       } else {
+               /* use SSI WS */
+               val = (id + 1) << shift;
+       }
+
+       if (ret < 0)
+               return ret;
+
+       switch (id / 4) {
+       case 0:
+               rsnd_mod_bset(mod, SRC_TMG_SEL0, mask, val);
+               break;
+       case 1:
+               rsnd_mod_bset(mod, SRC_TMG_SEL1, mask, val);
+               break;
+       case 2:
+               rsnd_mod_bset(mod, SRC_TMG_SEL2, mask, val);
+               break;
+       }
+
+       return 0;
+}
+
+static int rsnd_src_set_convert_rate_gen1(struct rsnd_mod *mod,
+                                         struct rsnd_dai *rdai)
+{
+       int ret;
+
+       ret = rsnd_src_set_convert_rate(mod, rdai);
+       if (ret < 0)
+               return ret;
+
+       /* Select SRC mode (fixed value) */
+       rsnd_mod_write(mod, SRC_SRCCR, 0x00010110);
+
+       /* Set the restriction value of the FS ratio (98%) */
+       rsnd_mod_write(mod, SRC_MNFSR,
+                      rsnd_mod_read(mod, SRC_IFSVR) / 100 * 98);
+
+       /* no SRC_BFSSR settings, since SRC_SRCCR::BUFMD is 0 */
+
+       return 0;
+}
+
+static int rsnd_src_probe_gen1(struct rsnd_mod *mod,
+                             struct rsnd_dai *rdai)
+{
+       struct rsnd_priv *priv = rsnd_mod_to_priv(mod);
+       struct device *dev = rsnd_priv_to_dev(priv);
+
+       dev_dbg(dev, "%s (Gen1) is probed\n", rsnd_mod_name(mod));
+
+       return 0;
+}
+
+static int rsnd_src_init_gen1(struct rsnd_mod *mod,
+                             struct rsnd_dai *rdai)
+{
+       int ret;
+
+       ret = rsnd_src_init(mod, rdai);
+       if (ret < 0)
+               return ret;
+
+       ret = rsnd_src_set_route_gen1(mod, rdai);
+       if (ret < 0)
+               return ret;
+
+       ret = rsnd_src_set_convert_rate_gen1(mod, rdai);
+       if (ret < 0)
+               return ret;
+
+       ret = rsnd_src_set_convert_timing_gen1(mod, rdai);
+       if (ret < 0)
+               return ret;
+
+       return 0;
+}
+
+static int rsnd_src_start_gen1(struct rsnd_mod *mod,
+                              struct rsnd_dai *rdai)
+{
+       int id = rsnd_mod_id(mod);
+
+       rsnd_mod_bset(mod, SRC_ROUTE_CTRL, (1 << id), (1 << id));
+
+       return rsnd_src_start(mod, rdai);
+}
+
+static int rsnd_src_stop_gen1(struct rsnd_mod *mod,
+                             struct rsnd_dai *rdai)
+{
+       int id = rsnd_mod_id(mod);
+
+       rsnd_mod_bset(mod, SRC_ROUTE_CTRL, (1 << id), 0);
+
+       return rsnd_src_stop(mod, rdai);
+}
+
+static struct rsnd_mod_ops rsnd_src_gen1_ops = {
+       .name   = SRC_NAME,
+       .probe  = rsnd_src_probe_gen1,
+       .init   = rsnd_src_init_gen1,
+       .quit   = rsnd_src_quit,
+       .start  = rsnd_src_start_gen1,
+       .stop   = rsnd_src_stop_gen1,
+};
+
+/*
+ *             Gen2 functions
+ */
+static int rsnd_src_set_convert_rate_gen2(struct rsnd_mod *mod,
+                                         struct rsnd_dai *rdai)
+{
+       struct rsnd_priv *priv = rsnd_mod_to_priv(mod);
+       struct device *dev = rsnd_priv_to_dev(priv);
+       struct rsnd_dai_stream *io = rsnd_mod_to_io(mod);
+       struct snd_pcm_runtime *runtime = rsnd_io_to_runtime(io);
+       struct rsnd_src *src = rsnd_mod_to_src(mod);
+       uint ratio;
+       int ret;
+
+       /* 6 - 1/6 are very enough ratio for SRC_BSDSR */
+       if (!rsnd_src_convert_rate(src))
+               ratio = 0;
+       else if (rsnd_src_convert_rate(src) > runtime->rate)
+               ratio = 100 * rsnd_src_convert_rate(src) / runtime->rate;
+       else
+               ratio = 100 * runtime->rate / rsnd_src_convert_rate(src);
+
+       if (ratio > 600) {
+               dev_err(dev, "FSO/FSI ratio error\n");
+               return -EINVAL;
+       }
+
+       ret = rsnd_src_set_convert_rate(mod, rdai);
+       if (ret < 0)
+               return ret;
+
+       rsnd_mod_write(mod, SRC_SRCCR, 0x00011110);
+
+       switch (rsnd_mod_id(mod)) {
+       case 5:
+       case 6:
+       case 7:
+       case 8:
+               rsnd_mod_write(mod, SRC_BSDSR, 0x02400000);
+               break;
+       default:
+               rsnd_mod_write(mod, SRC_BSDSR, 0x01800000);
+               break;
+       }
+
+       rsnd_mod_write(mod, SRC_BSISR, 0x00100060);
+
+       return 0;
+}
+
+static int rsnd_src_set_convert_timing_gen2(struct rsnd_mod *mod,
+                                           struct rsnd_dai *rdai)
+{
+       struct rsnd_dai_stream *io = rsnd_mod_to_io(mod);
+       struct snd_pcm_runtime *runtime = rsnd_io_to_runtime(io);
+       struct rsnd_src *src = rsnd_mod_to_src(mod);
+       u32 convert_rate = rsnd_src_convert_rate(src);
+       int ret;
+
+       if (convert_rate)
+               ret = rsnd_adg_set_convert_clk_gen2(mod, rdai, io,
+                                                   runtime->rate,
+                                                   convert_rate);
+       else
+               ret = rsnd_adg_set_convert_timing_gen2(mod, rdai, io);
+
+       return ret;
+}
+
+static int rsnd_src_probe_gen2(struct rsnd_mod *mod,
+                              struct rsnd_dai *rdai)
+{
+       struct rsnd_priv *priv = rsnd_mod_to_priv(mod);
+       struct rsnd_src *src = rsnd_mod_to_src(mod);
+       struct device *dev = rsnd_priv_to_dev(priv);
+       int ret;
+
+       ret = rsnd_dma_init(priv,
+                           rsnd_mod_to_dma(mod),
+                           rsnd_info_is_playback(priv, src),
+                           src->info->dma_id);
+       if (ret < 0)
+               dev_err(dev, "SRC DMA failed\n");
+
+       dev_dbg(dev, "%s (Gen2) is probed\n", rsnd_mod_name(mod));
+
+       return ret;
+}
+
+static int rsnd_src_remove_gen2(struct rsnd_mod *mod,
+                               struct rsnd_dai *rdai)
+{
+       rsnd_dma_quit(rsnd_mod_to_priv(mod), rsnd_mod_to_dma(mod));
+
+       return 0;
+}
+
+static int rsnd_src_init_gen2(struct rsnd_mod *mod,
+                             struct rsnd_dai *rdai)
+{
+       int ret;
+
+       ret = rsnd_src_init(mod, rdai);
+       if (ret < 0)
+               return ret;
+
+       ret = rsnd_src_set_convert_rate_gen2(mod, rdai);
+       if (ret < 0)
+               return ret;
+
+       ret = rsnd_src_set_convert_timing_gen2(mod, rdai);
+       if (ret < 0)
+               return ret;
+
+       return 0;
+}
+
+static int rsnd_src_start_gen2(struct rsnd_mod *mod,
+                              struct rsnd_dai *rdai)
+{
+       struct rsnd_dai_stream *io = rsnd_mod_to_io(mod);
+       struct rsnd_src *src = rsnd_mod_to_src(mod);
+       u32 val = rsnd_io_to_mod_dvc(io) ? 0x01 : 0x11;
+
+       rsnd_dma_start(rsnd_mod_to_dma(&src->mod));
+
+       rsnd_mod_write(mod, SRC_CTRL, val);
+
+       return rsnd_src_start(mod, rdai);
+}
+
+static int rsnd_src_stop_gen2(struct rsnd_mod *mod,
+                             struct rsnd_dai *rdai)
+{
+       struct rsnd_src *src = rsnd_mod_to_src(mod);
+
+       rsnd_mod_write(mod, SRC_CTRL, 0);
+
+       rsnd_dma_stop(rsnd_mod_to_dma(&src->mod));
+
+       return rsnd_src_stop(mod, rdai);
+}
+
+static struct rsnd_mod_ops rsnd_src_gen2_ops = {
+       .name   = SRC_NAME,
+       .probe  = rsnd_src_probe_gen2,
+       .remove = rsnd_src_remove_gen2,
+       .init   = rsnd_src_init_gen2,
+       .quit   = rsnd_src_quit,
+       .start  = rsnd_src_start_gen2,
+       .stop   = rsnd_src_stop_gen2,
+};
+
+struct rsnd_mod *rsnd_src_mod_get(struct rsnd_priv *priv, int id)
+{
+       if (WARN_ON(id < 0 || id >= rsnd_src_nr(priv)))
+               id = 0;
+
+       return &((struct rsnd_src *)(priv->src) + id)->mod;
+}
+
+static void rsnd_of_parse_src(struct platform_device *pdev,
+                             const struct rsnd_of_data *of_data,
+                             struct rsnd_priv *priv)
+{
+       struct device_node *src_node;
+       struct rcar_snd_info *info = rsnd_priv_to_info(priv);
+       struct rsnd_src_platform_info *src_info;
+       struct device *dev = &pdev->dev;
+       int nr;
+
+       if (!of_data)
+               return;
+
+       src_node = of_get_child_by_name(dev->of_node, "rcar_sound,src");
+       if (!src_node)
+               return;
+
+       nr = of_get_child_count(src_node);
+       if (!nr)
+               goto rsnd_of_parse_src_end;
+
+       src_info = devm_kzalloc(dev,
+                               sizeof(struct rsnd_src_platform_info) * nr,
+                               GFP_KERNEL);
+       if (!src_info) {
+               dev_err(dev, "src info allocation error\n");
+               goto rsnd_of_parse_src_end;
+       }
+
+       info->src_info          = src_info;
+       info->src_info_nr       = nr;
+
+rsnd_of_parse_src_end:
+       of_node_put(src_node);
+}
+
+int rsnd_src_probe(struct platform_device *pdev,
+                  const struct rsnd_of_data *of_data,
+                  struct rsnd_priv *priv)
+{
+       struct rcar_snd_info *info = rsnd_priv_to_info(priv);
+       struct device *dev = rsnd_priv_to_dev(priv);
+       struct rsnd_src *src;
+       struct rsnd_mod_ops *ops;
+       struct clk *clk;
+       char name[RSND_SRC_NAME_SIZE];
+       int i, nr;
+
+       ops = NULL;
+       if (rsnd_is_gen1(priv))
+               ops = &rsnd_src_gen1_ops;
+       if (rsnd_is_gen2(priv))
+               ops = &rsnd_src_gen2_ops;
+       if (!ops) {
+               dev_err(dev, "unknown Generation\n");
+               return -EIO;
+       }
+
+       rsnd_of_parse_src(pdev, of_data, priv);
+
+       /*
+        * init SRC
+        */
+       nr      = info->src_info_nr;
+       if (!nr)
+               return 0;
+
+       src     = devm_kzalloc(dev, sizeof(*src) * nr, GFP_KERNEL);
+       if (!src) {
+               dev_err(dev, "SRC allocate failed\n");
+               return -ENOMEM;
+       }
+
+       priv->src_nr    = nr;
+       priv->src       = src;
+
+       for_each_rsnd_src(src, priv, i) {
+               snprintf(name, RSND_SRC_NAME_SIZE, "%s.%d",
+                        SRC_NAME, i);
+
+               clk = devm_clk_get(dev, name);
+               if (IS_ERR(clk))
+                       return PTR_ERR(clk);
+
+               src->info = &info->src_info[i];
+               src->clk = clk;
+
+               rsnd_mod_init(priv, &src->mod, ops, RSND_MOD_SRC, i);
+
+               dev_dbg(dev, "SRC%d probed\n", i);
+       }
+
+       return 0;
+}
index 4b8cf7c..34e8400 100644 (file)
@@ -57,6 +57,8 @@
  */
 #define CONT           (1 << 8)        /* WS Continue Function */
 
+#define SSI_NAME "ssi"
+
 struct rsnd_ssi {
        struct clk *clk;
        struct rsnd_ssi_platform_info *info; /* rcar_snd.h */
@@ -64,107 +66,42 @@ struct rsnd_ssi {
        struct rsnd_mod mod;
 
        struct rsnd_dai *rdai;
-       struct rsnd_dai_stream *io;
        u32 cr_own;
        u32 cr_clk;
        u32 cr_etc;
        int err;
-       int dma_offset;
        unsigned int usrcnt;
        unsigned int rate;
 };
 
-struct rsnd_ssiu {
-       u32 ssi_mode0;
-       u32 ssi_mode1;
-
-       int ssi_nr;
-       struct rsnd_ssi *ssi;
-};
-
 #define for_each_rsnd_ssi(pos, priv, i)                                        \
        for (i = 0;                                                     \
             (i < rsnd_ssi_nr(priv)) &&                                 \
-               ((pos) = ((struct rsnd_ssiu *)((priv)->ssiu))->ssi + i); \
+               ((pos) = ((struct rsnd_ssi *)(priv)->ssi + i));         \
             i++)
 
-#define rsnd_ssi_nr(priv) (((struct rsnd_ssiu *)((priv)->ssiu))->ssi_nr)
+#define rsnd_ssi_nr(priv) ((priv)->ssi_nr)
 #define rsnd_mod_to_ssi(_mod) container_of((_mod), struct rsnd_ssi, mod)
 #define rsnd_dma_to_ssi(dma)  rsnd_mod_to_ssi(rsnd_dma_to_mod(dma))
 #define rsnd_ssi_pio_available(ssi) ((ssi)->info->pio_irq > 0)
 #define rsnd_ssi_dma_available(ssi) \
        rsnd_dma_available(rsnd_mod_to_dma(&(ssi)->mod))
 #define rsnd_ssi_clk_from_parent(ssi) ((ssi)->parent)
-#define rsnd_rdai_is_clk_master(rdai) ((rdai)->clk_master)
 #define rsnd_ssi_mode_flags(p) ((p)->info->flags)
 #define rsnd_ssi_dai_id(ssi) ((ssi)->info->dai_id)
-#define rsnd_ssi_to_ssiu(ssi)\
-       (((struct rsnd_ssiu *)((ssi) - rsnd_mod_id(&(ssi)->mod))) - 1)
 
-static void rsnd_ssi_mode_set(struct rsnd_priv *priv,
-                             struct rsnd_dai *rdai,
-                             struct rsnd_ssi *ssi)
+static int rsnd_ssi_use_busif(struct rsnd_mod *mod)
 {
-       struct device *dev = rsnd_priv_to_dev(priv);
-       struct rsnd_mod *scu;
-       struct rsnd_ssiu *ssiu = rsnd_ssi_to_ssiu(ssi);
-       int id = rsnd_mod_id(&ssi->mod);
-       u32 flags;
-       u32 val;
-
-       scu   = rsnd_scu_mod_get(priv, rsnd_mod_id(&ssi->mod));
-
-       /*
-        * SSI_MODE0
-        */
-
-       /* see also BUSIF_MODE */
-       if (rsnd_scu_hpbif_is_enable(scu)) {
-               ssiu->ssi_mode0 &= ~(1 << id);
-               dev_dbg(dev, "SSI%d uses DEPENDENT mode\n", id);
-       } else {
-               ssiu->ssi_mode0 |= (1 << id);
-               dev_dbg(dev, "SSI%d uses INDEPENDENT mode\n", id);
-       }
-
-       /*
-        * SSI_MODE1
-        */
-#define ssi_parent_set(p, sync, adg, ext)              \
-       do {                                            \
-               ssi->parent = ssiu->ssi + p;            \
-               if (rsnd_rdai_is_clk_master(rdai))      \
-                       val = adg;                      \
-               else                                    \
-                       val = ext;                      \
-               if (flags & RSND_SSI_SYNC)              \
-                       val |= sync;                    \
-       } while (0)
-
-       flags = rsnd_ssi_mode_flags(ssi);
-       if (flags & RSND_SSI_CLK_PIN_SHARE) {
-
-               val = 0;
-               switch (id) {
-               case 1:
-                       ssi_parent_set(0, (1 << 4), (0x2 << 0), (0x1 << 0));
-                       break;
-               case 2:
-                       ssi_parent_set(0, (1 << 4), (0x2 << 2), (0x1 << 2));
-                       break;
-               case 4:
-                       ssi_parent_set(3, (1 << 20), (0x2 << 16), (0x1 << 16));
-                       break;
-               case 8:
-                       ssi_parent_set(7, 0, 0, 0);
-                       break;
-               }
+       struct rsnd_ssi *ssi = rsnd_mod_to_ssi(mod);
+       struct rsnd_dai_stream *io = rsnd_mod_to_io(mod);
+       int use_busif = 0;
 
-               ssiu->ssi_mode1 |= val;
-       }
+       if (!(rsnd_ssi_mode_flags(ssi) & RSND_SSI_NO_BUSIF))
+               use_busif = 1;
+       if (rsnd_io_to_mod_src(io))
+               use_busif = 1;
 
-       rsnd_mod_write(&ssi->mod, SSI_MODE0, ssiu->ssi_mode0);
-       rsnd_mod_write(&ssi->mod, SSI_MODE1, ssiu->ssi_mode1);
+       return use_busif;
 }
 
 static void rsnd_ssi_status_check(struct rsnd_mod *mod,
@@ -200,7 +137,7 @@ static int rsnd_ssi_master_clk_start(struct rsnd_ssi *ssi,
                1, 2, 4, 8, 16, 6, 12,
        };
        unsigned int main_rate;
-       unsigned int rate = rsnd_scu_get_ssi_rate(priv, &ssi->mod, runtime);
+       unsigned int rate = rsnd_src_get_ssi_rate(priv, io, runtime);
 
        /*
         * Find best clock, and try to start ADG
@@ -250,9 +187,9 @@ static void rsnd_ssi_hw_start(struct rsnd_ssi *ssi,
        u32 cr;
 
        if (0 == ssi->usrcnt) {
-               clk_enable(ssi->clk);
+               clk_prepare_enable(ssi->clk);
 
-               if (rsnd_rdai_is_clk_master(rdai)) {
+               if (rsnd_dai_is_clk_master(rdai)) {
                        if (rsnd_ssi_clk_from_parent(ssi))
                                rsnd_ssi_hw_start(ssi->parent, rdai, io);
                        else
@@ -302,14 +239,14 @@ static void rsnd_ssi_hw_stop(struct rsnd_ssi *ssi,
                rsnd_mod_write(&ssi->mod, SSICR, cr);   /* disabled all */
                rsnd_ssi_status_check(&ssi->mod, IIRQ);
 
-               if (rsnd_rdai_is_clk_master(rdai)) {
+               if (rsnd_dai_is_clk_master(rdai)) {
                        if (rsnd_ssi_clk_from_parent(ssi))
                                rsnd_ssi_hw_stop(ssi->parent, rdai);
                        else
                                rsnd_ssi_master_clk_stop(ssi);
                }
 
-               clk_disable(ssi->clk);
+               clk_disable_unprepare(ssi->clk);
        }
 
        dev_dbg(dev, "ssi%d hw stopped\n", rsnd_mod_id(&ssi->mod));
@@ -319,12 +256,10 @@ static void rsnd_ssi_hw_stop(struct rsnd_ssi *ssi,
  *     SSI mod common functions
  */
 static int rsnd_ssi_init(struct rsnd_mod *mod,
-                        struct rsnd_dai *rdai,
-                        struct rsnd_dai_stream *io)
+                        struct rsnd_dai *rdai)
 {
        struct rsnd_ssi *ssi = rsnd_mod_to_ssi(mod);
-       struct rsnd_priv *priv = rsnd_mod_to_priv(mod);
-       struct device *dev = rsnd_priv_to_dev(priv);
+       struct rsnd_dai_stream *io = rsnd_mod_to_io(mod);
        struct snd_pcm_runtime *runtime = rsnd_io_to_runtime(io);
        u32 cr;
 
@@ -365,32 +300,23 @@ static int rsnd_ssi_init(struct rsnd_mod *mod,
         * set ssi parameter
         */
        ssi->rdai       = rdai;
-       ssi->io         = io;
        ssi->cr_own     = cr;
        ssi->err        = -1; /* ignore 1st error */
 
-       rsnd_ssi_mode_set(priv, rdai, ssi);
-
-       dev_dbg(dev, "%s.%d init\n", rsnd_mod_name(mod), rsnd_mod_id(mod));
-
        return 0;
 }
 
 static int rsnd_ssi_quit(struct rsnd_mod *mod,
-                        struct rsnd_dai *rdai,
-                        struct rsnd_dai_stream *io)
+                        struct rsnd_dai *rdai)
 {
        struct rsnd_ssi *ssi = rsnd_mod_to_ssi(mod);
        struct rsnd_priv *priv = rsnd_mod_to_priv(mod);
        struct device *dev = rsnd_priv_to_dev(priv);
 
-       dev_dbg(dev, "%s.%d quit\n", rsnd_mod_name(mod), rsnd_mod_id(mod));
-
        if (ssi->err > 0)
                dev_warn(dev, "ssi under/over flow err = %d\n", ssi->err);
 
        ssi->rdai       = NULL;
-       ssi->io         = NULL;
        ssi->cr_own     = 0;
        ssi->err        = 0;
 
@@ -414,8 +340,9 @@ static void rsnd_ssi_record_error(struct rsnd_ssi *ssi, u32 status)
 static irqreturn_t rsnd_ssi_pio_interrupt(int irq, void *data)
 {
        struct rsnd_ssi *ssi = data;
-       struct rsnd_dai_stream *io = ssi->io;
-       u32 status = rsnd_mod_read(&ssi->mod, SSISR);
+       struct rsnd_mod *mod = &ssi->mod;
+       struct rsnd_dai_stream *io = rsnd_mod_to_io(mod);
+       u32 status = rsnd_mod_read(mod, SSISR);
        irqreturn_t ret = IRQ_NONE;
 
        if (io && (status & DIRQ)) {
@@ -432,9 +359,9 @@ static irqreturn_t rsnd_ssi_pio_interrupt(int irq, void *data)
                 * see rsnd_ssi_init()
                 */
                if (rsnd_dai_is_play(rdai, io))
-                       rsnd_mod_write(&ssi->mod, SSITDR, *buf);
+                       rsnd_mod_write(mod, SSITDR, *buf);
                else
-                       *buf = rsnd_mod_read(&ssi->mod, SSIRDR);
+                       *buf = rsnd_mod_read(mod, SSIRDR);
 
                rsnd_dai_pointer_update(io, sizeof(*buf));
 
@@ -444,120 +371,150 @@ static irqreturn_t rsnd_ssi_pio_interrupt(int irq, void *data)
        return ret;
 }
 
-static int rsnd_ssi_pio_start(struct rsnd_mod *mod,
-                             struct rsnd_dai *rdai,
-                             struct rsnd_dai_stream *io)
+static int rsnd_ssi_pio_probe(struct rsnd_mod *mod,
+                             struct rsnd_dai *rdai)
 {
        struct rsnd_priv *priv = rsnd_mod_to_priv(mod);
-       struct rsnd_ssi *ssi = rsnd_mod_to_ssi(mod);
        struct device *dev = rsnd_priv_to_dev(priv);
+       struct rsnd_ssi *ssi = rsnd_mod_to_ssi(mod);
+       int irq = ssi->info->pio_irq;
+       int ret;
+
+       ret = devm_request_irq(dev, irq,
+                              rsnd_ssi_pio_interrupt,
+                              IRQF_SHARED,
+                              dev_name(dev), ssi);
+       if (ret)
+               dev_err(dev, "SSI request interrupt failed\n");
+
+       dev_dbg(dev, "%s (PIO) is probed\n", rsnd_mod_name(mod));
+
+       return ret;
+}
+
+static int rsnd_ssi_pio_start(struct rsnd_mod *mod,
+                             struct rsnd_dai *rdai)
+{
+       struct rsnd_ssi *ssi = rsnd_mod_to_ssi(mod);
+       struct rsnd_dai_stream *io = rsnd_mod_to_io(mod);
 
        /* enable PIO IRQ */
        ssi->cr_etc = UIEN | OIEN | DIEN;
 
-       /* enable PIO interrupt if gen2 */
-       if (rsnd_is_gen2(priv))
-               rsnd_mod_write(&ssi->mod, INT_ENABLE, 0x0f000000);
+       rsnd_src_ssiu_start(mod, rdai, 0);
 
-       rsnd_ssi_hw_start(ssi, rdai, io);
+       rsnd_src_enable_ssi_irq(mod, rdai);
 
-       dev_dbg(dev, "%s.%d start\n", rsnd_mod_name(mod), rsnd_mod_id(mod));
+       rsnd_ssi_hw_start(ssi, rdai, io);
 
        return 0;
 }
 
 static int rsnd_ssi_pio_stop(struct rsnd_mod *mod,
-                            struct rsnd_dai *rdai,
-                            struct rsnd_dai_stream *io)
+                            struct rsnd_dai *rdai)
 {
-       struct rsnd_priv *priv = rsnd_mod_to_priv(mod);
-       struct device *dev = rsnd_priv_to_dev(priv);
        struct rsnd_ssi *ssi = rsnd_mod_to_ssi(mod);
 
-       dev_dbg(dev, "%s.%d stop\n", rsnd_mod_name(mod), rsnd_mod_id(mod));
-
        ssi->cr_etc = 0;
 
        rsnd_ssi_hw_stop(ssi, rdai);
 
+       rsnd_src_ssiu_stop(mod, rdai, 0);
+
        return 0;
 }
 
 static struct rsnd_mod_ops rsnd_ssi_pio_ops = {
-       .name   = "ssi (pio)",
+       .name   = SSI_NAME,
+       .probe  = rsnd_ssi_pio_probe,
        .init   = rsnd_ssi_init,
        .quit   = rsnd_ssi_quit,
        .start  = rsnd_ssi_pio_start,
        .stop   = rsnd_ssi_pio_stop,
 };
 
-static int rsnd_ssi_dma_inquiry(struct rsnd_dma *dma, dma_addr_t *buf, int *len)
+static int rsnd_ssi_dma_probe(struct rsnd_mod *mod,
+                         struct rsnd_dai *rdai)
 {
-       struct rsnd_ssi *ssi = rsnd_dma_to_ssi(dma);
-       struct rsnd_dai_stream *io = ssi->io;
-       struct snd_pcm_runtime *runtime = rsnd_io_to_runtime(io);
+       struct rsnd_priv *priv = rsnd_mod_to_priv(mod);
+       struct rsnd_ssi *ssi = rsnd_mod_to_ssi(mod);
+       struct device *dev = rsnd_priv_to_dev(priv);
+       int dma_id = ssi->info->dma_id;
+       int ret;
 
-       *len = io->byte_per_period;
-       *buf = runtime->dma_addr +
-               rsnd_dai_pointer_offset(io, ssi->dma_offset + *len);
-       ssi->dma_offset = *len; /* it cares A/B plane */
+       ret = rsnd_dma_init(
+               priv, rsnd_mod_to_dma(mod),
+               rsnd_info_is_playback(priv, ssi),
+               dma_id);
 
-       return 0;
-}
+       if (ret < 0)
+               dev_err(dev, "SSI DMA failed\n");
 
-static int rsnd_ssi_dma_complete(struct rsnd_dma *dma)
-{
-       struct rsnd_ssi *ssi = rsnd_dma_to_ssi(dma);
-       struct rsnd_dai_stream *io = ssi->io;
-       u32 status = rsnd_mod_read(&ssi->mod, SSISR);
+       dev_dbg(dev, "%s (DMA) is probed\n", rsnd_mod_name(mod));
 
-       rsnd_ssi_record_error(ssi, status);
+       return ret;
+}
 
-       rsnd_dai_pointer_update(ssi->io, io->byte_per_period);
+static int rsnd_ssi_dma_remove(struct rsnd_mod *mod,
+                              struct rsnd_dai *rdai)
+{
+       rsnd_dma_quit(rsnd_mod_to_priv(mod), rsnd_mod_to_dma(mod));
 
        return 0;
 }
 
 static int rsnd_ssi_dma_start(struct rsnd_mod *mod,
-                             struct rsnd_dai *rdai,
-                             struct rsnd_dai_stream *io)
+                             struct rsnd_dai *rdai)
 {
        struct rsnd_ssi *ssi = rsnd_mod_to_ssi(mod);
        struct rsnd_dma *dma = rsnd_mod_to_dma(&ssi->mod);
+       struct rsnd_dai_stream *io = rsnd_mod_to_io(mod);
 
        /* enable DMA transfer */
        ssi->cr_etc = DMEN;
-       ssi->dma_offset = 0;
+
+       rsnd_src_ssiu_start(mod, rdai, rsnd_ssi_use_busif(mod));
 
        rsnd_dma_start(dma);
 
        rsnd_ssi_hw_start(ssi, ssi->rdai, io);
 
        /* enable WS continue */
-       if (rsnd_rdai_is_clk_master(rdai))
+       if (rsnd_dai_is_clk_master(rdai))
                rsnd_mod_write(&ssi->mod, SSIWSR, CONT);
 
        return 0;
 }
 
 static int rsnd_ssi_dma_stop(struct rsnd_mod *mod,
-                            struct rsnd_dai *rdai,
-                            struct rsnd_dai_stream *io)
+                            struct rsnd_dai *rdai)
 {
        struct rsnd_ssi *ssi = rsnd_mod_to_ssi(mod);
        struct rsnd_dma *dma = rsnd_mod_to_dma(&ssi->mod);
 
        ssi->cr_etc = 0;
 
+       rsnd_ssi_record_error(ssi, rsnd_mod_read(mod, SSISR));
+
        rsnd_ssi_hw_stop(ssi, rdai);
 
        rsnd_dma_stop(dma);
 
+       rsnd_src_ssiu_stop(mod, rdai, 1);
+
        return 0;
 }
 
+static char *rsnd_ssi_dma_name(struct rsnd_mod *mod)
+{
+       return rsnd_ssi_use_busif(mod) ? "ssiu" : SSI_NAME;
+}
+
 static struct rsnd_mod_ops rsnd_ssi_dma_ops = {
-       .name   = "ssi (dma)",
+       .name   = SSI_NAME,
+       .dma_name = rsnd_ssi_dma_name,
+       .probe  = rsnd_ssi_dma_probe,
+       .remove = rsnd_ssi_dma_remove,
        .init   = rsnd_ssi_init,
        .quit   = rsnd_ssi_quit,
        .start  = rsnd_ssi_dma_start,
@@ -567,90 +524,145 @@ static struct rsnd_mod_ops rsnd_ssi_dma_ops = {
 /*
  *             Non SSI
  */
-static int rsnd_ssi_non(struct rsnd_mod *mod,
-                       struct rsnd_dai *rdai,
-                       struct rsnd_dai_stream *io)
-{
-       struct rsnd_priv *priv = rsnd_mod_to_priv(mod);
-       struct device *dev = rsnd_priv_to_dev(priv);
-
-       dev_dbg(dev, "%s\n", __func__);
-
-       return 0;
-}
-
 static struct rsnd_mod_ops rsnd_ssi_non_ops = {
-       .name   = "ssi (non)",
-       .init   = rsnd_ssi_non,
-       .quit   = rsnd_ssi_non,
-       .start  = rsnd_ssi_non,
-       .stop   = rsnd_ssi_non,
+       .name   = SSI_NAME,
 };
 
 /*
  *             ssi mod function
  */
-struct rsnd_mod *rsnd_ssi_mod_get_frm_dai(struct rsnd_priv *priv,
-                                         int dai_id, int is_play)
+struct rsnd_mod *rsnd_ssi_mod_get(struct rsnd_priv *priv, int id)
 {
-       struct rsnd_ssi *ssi;
-       int i, has_play;
+       if (WARN_ON(id < 0 || id >= rsnd_ssi_nr(priv)))
+               id = 0;
 
-       is_play = !!is_play;
+       return &((struct rsnd_ssi *)(priv->ssi) + id)->mod;
+}
 
-       for_each_rsnd_ssi(ssi, priv, i) {
-               if (rsnd_ssi_dai_id(ssi) != dai_id)
-                       continue;
+int rsnd_ssi_is_pin_sharing(struct rsnd_mod *mod)
+{
+       struct rsnd_ssi *ssi = rsnd_mod_to_ssi(mod);
 
-               has_play = !!(rsnd_ssi_mode_flags(ssi) & RSND_SSI_PLAY);
+       return !!(rsnd_ssi_mode_flags(ssi) & RSND_SSI_CLK_PIN_SHARE);
+}
 
-               if (is_play == has_play)
-                       return &ssi->mod;
-       }
+static void rsnd_ssi_parent_clk_setup(struct rsnd_priv *priv, struct rsnd_ssi *ssi)
+{
+       if (!rsnd_ssi_is_pin_sharing(&ssi->mod))
+               return;
 
-       return NULL;
+       switch (rsnd_mod_id(&ssi->mod)) {
+       case 1:
+       case 2:
+               ssi->parent = rsnd_mod_to_ssi(rsnd_ssi_mod_get(priv, 0));
+               break;
+       case 4:
+               ssi->parent = rsnd_mod_to_ssi(rsnd_ssi_mod_get(priv, 3));
+               break;
+       case 8:
+               ssi->parent = rsnd_mod_to_ssi(rsnd_ssi_mod_get(priv, 7));
+               break;
+       }
 }
 
-struct rsnd_mod *rsnd_ssi_mod_get(struct rsnd_priv *priv, int id)
+
+static void rsnd_of_parse_ssi(struct platform_device *pdev,
+                             const struct rsnd_of_data *of_data,
+                             struct rsnd_priv *priv)
 {
-       if (WARN_ON(id < 0 || id >= rsnd_ssi_nr(priv)))
-               id = 0;
+       struct device_node *node;
+       struct device_node *np;
+       struct rsnd_ssi_platform_info *ssi_info;
+       struct rcar_snd_info *info = rsnd_priv_to_info(priv);
+       struct device *dev = &pdev->dev;
+       int nr, i;
+
+       if (!of_data)
+               return;
+
+       node = of_get_child_by_name(dev->of_node, "rcar_sound,ssi");
+       if (!node)
+               return;
+
+       nr = of_get_child_count(node);
+       if (!nr)
+               goto rsnd_of_parse_ssi_end;
+
+       ssi_info = devm_kzalloc(dev,
+                               sizeof(struct rsnd_ssi_platform_info) * nr,
+                               GFP_KERNEL);
+       if (!ssi_info) {
+               dev_err(dev, "ssi info allocation error\n");
+               goto rsnd_of_parse_ssi_end;
+       }
+
+       info->ssi_info          = ssi_info;
+       info->ssi_info_nr       = nr;
+
+       i = -1;
+       for_each_child_of_node(node, np) {
+               i++;
+
+               ssi_info = info->ssi_info + i;
+
+               /*
+                * pin settings
+                */
+               if (of_get_property(np, "shared-pin", NULL))
+                       ssi_info->flags |= RSND_SSI_CLK_PIN_SHARE;
+
+               /*
+                * irq
+                */
+               ssi_info->pio_irq = irq_of_parse_and_map(np, 0);
 
-       return &(((struct rsnd_ssiu *)(priv->ssiu))->ssi + id)->mod;
+               /*
+                * DMA
+                */
+               ssi_info->dma_id = of_get_property(np, "pio-transfer", NULL) ?
+                       0 : 1;
+
+               if (of_get_property(np, "no-busif", NULL))
+                       ssi_info->flags |= RSND_SSI_NO_BUSIF;
+       }
+
+rsnd_of_parse_ssi_end:
+       of_node_put(node);
 }
 
 int rsnd_ssi_probe(struct platform_device *pdev,
-                  struct rcar_snd_info *info,
+                  const struct rsnd_of_data *of_data,
                   struct rsnd_priv *priv)
 {
+       struct rcar_snd_info *info = rsnd_priv_to_info(priv);
        struct rsnd_ssi_platform_info *pinfo;
        struct device *dev = rsnd_priv_to_dev(priv);
        struct rsnd_mod_ops *ops;
        struct clk *clk;
-       struct rsnd_ssiu *ssiu;
        struct rsnd_ssi *ssi;
        char name[RSND_SSI_NAME_SIZE];
-       int i, nr, ret;
+       int i, nr;
+
+       rsnd_of_parse_ssi(pdev, of_data, priv);
 
        /*
         *      init SSI
         */
        nr      = info->ssi_info_nr;
-       ssiu    = devm_kzalloc(dev, sizeof(*ssiu) + (sizeof(*ssi) * nr),
-                              GFP_KERNEL);
-       if (!ssiu) {
+       ssi     = devm_kzalloc(dev, sizeof(*ssi) * nr, GFP_KERNEL);
+       if (!ssi) {
                dev_err(dev, "SSI allocate failed\n");
                return -ENOMEM;
        }
 
-       priv->ssiu      = ssiu;
-       ssiu->ssi       = (struct rsnd_ssi *)(ssiu + 1);
-       ssiu->ssi_nr    = nr;
+       priv->ssi       = ssi;
+       priv->ssi_nr    = nr;
 
        for_each_rsnd_ssi(ssi, priv, i) {
                pinfo = &info->ssi_info[i];
 
-               snprintf(name, RSND_SSI_NAME_SIZE, "ssi.%d", i);
+               snprintf(name, RSND_SSI_NAME_SIZE, "%s.%d",
+                        SSI_NAME, i);
 
                clk = devm_clk_get(dev, name);
                if (IS_ERR(clk))
@@ -660,61 +672,15 @@ int rsnd_ssi_probe(struct platform_device *pdev,
                ssi->clk        = clk;
 
                ops = &rsnd_ssi_non_ops;
+               if (pinfo->dma_id > 0)
+                       ops = &rsnd_ssi_dma_ops;
+               else if (rsnd_ssi_pio_available(ssi))
+                       ops = &rsnd_ssi_pio_ops;
 
-               /*
-                * SSI DMA case
-                */
-               if (pinfo->dma_id > 0) {
-                       ret = rsnd_dma_init(
-                               priv, rsnd_mod_to_dma(&ssi->mod),
-                               (rsnd_ssi_mode_flags(ssi) & RSND_SSI_PLAY),
-                               pinfo->dma_id,
-                               rsnd_ssi_dma_inquiry,
-                               rsnd_ssi_dma_complete);
-                       if (ret < 0)
-                               dev_info(dev, "SSI DMA failed. try PIO transter\n");
-                       else
-                               ops     = &rsnd_ssi_dma_ops;
-
-                       dev_dbg(dev, "SSI%d use DMA transfer\n", i);
-               }
-
-               /*
-                * SSI PIO case
-                */
-               if (!rsnd_ssi_dma_available(ssi) &&
-                    rsnd_ssi_pio_available(ssi)) {
-                       ret = devm_request_irq(dev, pinfo->pio_irq,
-                                              &rsnd_ssi_pio_interrupt,
-                                              IRQF_SHARED,
-                                              dev_name(dev), ssi);
-                       if (ret) {
-                               dev_err(dev, "SSI request interrupt failed\n");
-                               return ret;
-                       }
+               rsnd_mod_init(priv, &ssi->mod, ops, RSND_MOD_SSI, i);
 
-                       ops     = &rsnd_ssi_pio_ops;
-
-                       dev_dbg(dev, "SSI%d use PIO transfer\n", i);
-               }
-
-               rsnd_mod_init(priv, &ssi->mod, ops, i);
+               rsnd_ssi_parent_clk_setup(priv, ssi);
        }
 
-       dev_dbg(dev, "ssi probed\n");
-
        return 0;
 }
-
-void rsnd_ssi_remove(struct platform_device *pdev,
-                  struct rsnd_priv *priv)
-{
-       struct rsnd_ssi *ssi;
-       int i;
-
-       for_each_rsnd_ssi(ssi, priv, i) {
-               if (rsnd_ssi_dma_available(ssi))
-                       rsnd_dma_quit(priv, rsnd_mod_to_dma(&ssi->mod));
-       }
-
-}
index fe1df50..c75d008 100644 (file)
@@ -3609,6 +3609,30 @@ int snd_soc_dai_set_fmt(struct snd_soc_dai *dai, unsigned int fmt)
 EXPORT_SYMBOL_GPL(snd_soc_dai_set_fmt);
 
 /**
+ * snd_soc_of_xlate_tdm_slot - generate tx/rx slot mask.
+ * @slots: Number of slots in use.
+ * @tx_mask: bitmask representing active TX slots.
+ * @rx_mask: bitmask representing active RX slots.
+ *
+ * Generates the TDM tx and rx slot default masks for DAI.
+ */
+static int snd_soc_of_xlate_tdm_slot_mask(unsigned int slots,
+                                         unsigned int *tx_mask,
+                                         unsigned int *rx_mask)
+{
+       if (*tx_mask || *rx_mask)
+               return 0;
+
+       if (!slots)
+               return -EINVAL;
+
+       *tx_mask = (1 << slots) - 1;
+       *rx_mask = (1 << slots) - 1;
+
+       return 0;
+}
+
+/**
  * snd_soc_dai_set_tdm_slot - configure DAI TDM.
  * @dai: DAI
  * @tx_mask: bitmask representing active TX slots.
@@ -3622,6 +3646,12 @@ EXPORT_SYMBOL_GPL(snd_soc_dai_set_fmt);
 int snd_soc_dai_set_tdm_slot(struct snd_soc_dai *dai,
        unsigned int tx_mask, unsigned int rx_mask, int slots, int slot_width)
 {
+       if (dai->driver && dai->driver->ops->of_xlate_tdm_slot_mask)
+               dai->driver->ops->of_xlate_tdm_slot_mask(slots,
+                                               &tx_mask, &rx_mask);
+       else
+               snd_soc_of_xlate_tdm_slot_mask(slots, &tx_mask, &rx_mask);
+
        if (dai->driver && dai->driver->ops->set_tdm_slot)
                return dai->driver->ops->set_tdm_slot(dai, tx_mask, rx_mask,
                                slots, slot_width);
@@ -4417,6 +4447,122 @@ int snd_soc_of_parse_card_name(struct snd_soc_card *card,
 }
 EXPORT_SYMBOL_GPL(snd_soc_of_parse_card_name);
 
+static const struct snd_soc_dapm_widget simple_widgets[] = {
+       SND_SOC_DAPM_MIC("Microphone", NULL),
+       SND_SOC_DAPM_LINE("Line", NULL),
+       SND_SOC_DAPM_HP("Headphone", NULL),
+       SND_SOC_DAPM_SPK("Speaker", NULL),
+};
+
+int snd_soc_of_parse_audio_simple_widgets(struct snd_soc_card *card,
+                                         const char *propname)
+{
+       struct device_node *np = card->dev->of_node;
+       struct snd_soc_dapm_widget *widgets;
+       const char *template, *wname;
+       int i, j, num_widgets, ret;
+
+       num_widgets = of_property_count_strings(np, propname);
+       if (num_widgets < 0) {
+               dev_err(card->dev,
+                       "ASoC: Property '%s' does not exist\n", propname);
+               return -EINVAL;
+       }
+       if (num_widgets & 1) {
+               dev_err(card->dev,
+                       "ASoC: Property '%s' length is not even\n", propname);
+               return -EINVAL;
+       }
+
+       num_widgets /= 2;
+       if (!num_widgets) {
+               dev_err(card->dev, "ASoC: Property '%s's length is zero\n",
+                       propname);
+               return -EINVAL;
+       }
+
+       widgets = devm_kcalloc(card->dev, num_widgets, sizeof(*widgets),
+                              GFP_KERNEL);
+       if (!widgets) {
+               dev_err(card->dev,
+                       "ASoC: Could not allocate memory for widgets\n");
+               return -ENOMEM;
+       }
+
+       for (i = 0; i < num_widgets; i++) {
+               ret = of_property_read_string_index(np, propname,
+                       2 * i, &template);
+               if (ret) {
+                       dev_err(card->dev,
+                               "ASoC: Property '%s' index %d read error:%d\n",
+                               propname, 2 * i, ret);
+                       return -EINVAL;
+               }
+
+               for (j = 0; j < ARRAY_SIZE(simple_widgets); j++) {
+                       if (!strncmp(template, simple_widgets[j].name,
+                                    strlen(simple_widgets[j].name))) {
+                               widgets[i] = simple_widgets[j];
+                               break;
+                       }
+               }
+
+               if (j >= ARRAY_SIZE(simple_widgets)) {
+                       dev_err(card->dev,
+                               "ASoC: DAPM widget '%s' is not supported\n",
+                               template);
+                       return -EINVAL;
+               }
+
+               ret = of_property_read_string_index(np, propname,
+                                                   (2 * i) + 1,
+                                                   &wname);
+               if (ret) {
+                       dev_err(card->dev,
+                               "ASoC: Property '%s' index %d read error:%d\n",
+                               propname, (2 * i) + 1, ret);
+                       return -EINVAL;
+               }
+
+               widgets[i].name = wname;
+       }
+
+       card->dapm_widgets = widgets;
+       card->num_dapm_widgets = num_widgets;
+
+       return 0;
+}
+EXPORT_SYMBOL_GPL(snd_soc_of_parse_audio_simple_widgets);
+
+int snd_soc_of_parse_tdm_slot(struct device_node *np,
+                             unsigned int *slots,
+                             unsigned int *slot_width)
+{
+       u32 val;
+       int ret;
+
+       if (of_property_read_bool(np, "dai-tdm-slot-num")) {
+               ret = of_property_read_u32(np, "dai-tdm-slot-num", &val);
+               if (ret)
+                       return ret;
+
+               if (slots)
+                       *slots = val;
+       }
+
+       if (of_property_read_bool(np, "dai-tdm-slot-width")) {
+               ret = of_property_read_u32(np, "dai-tdm-slot-width", &val);
+               if (ret)
+                       return ret;
+
+               if (slot_width)
+                       *slot_width = val;
+       }
+
+       return 0;
+}
+EXPORT_SYMBOL_GPL(snd_soc_of_parse_tdm_slot);
+
 int snd_soc_of_parse_audio_routing(struct snd_soc_card *card,
                                   const char *propname)
 {
@@ -4474,7 +4620,9 @@ int snd_soc_of_parse_audio_routing(struct snd_soc_card *card,
 EXPORT_SYMBOL_GPL(snd_soc_of_parse_audio_routing);
 
 unsigned int snd_soc_of_parse_daifmt(struct device_node *np,
-                                    const char *prefix)
+                                    const char *prefix,
+                                    struct device_node **bitclkmaster,
+                                    struct device_node **framemaster)
 {
        int ret, i;
        char prop[128];
@@ -4557,9 +4705,13 @@ unsigned int snd_soc_of_parse_daifmt(struct device_node *np,
         */
        snprintf(prop, sizeof(prop), "%sbitclock-master", prefix);
        bit = !!of_get_property(np, prop, NULL);
+       if (bit && bitclkmaster)
+               *bitclkmaster = of_parse_phandle(np, prop, 0);
 
        snprintf(prop, sizeof(prop), "%sframe-master", prefix);
        frame = !!of_get_property(np, prop, NULL);
+       if (frame && framemaster)
+               *framemaster = of_parse_phandle(np, prop, 0);
 
        switch ((bit << 4) + frame) {
        case 0x11: